neue Homepage auf react basis

This commit is contained in:
2026-08-07 21:39:30 +02:00
parent 164bdd19ad
commit ee89442c04
52191 changed files with 1230242 additions and 58 deletions
+91
View File
@@ -0,0 +1,91 @@
# Versions
## 0.3.0
_Jun 11, 2026_
- **Breaking change:** Replace `@base-ui/utils/detectBrowser` with the new `@base-ui/utils/platform` namespace (#4920) by @romgrk
- Fix `useStore` returning stale values when the store or selector arguments change (#4866) by @chuganzy
- Update `reselect` to 5.2.0 (#4910) by @IzumiSy
- Build the package with a flat output structure (#4959) by @brijeshb42
## 0.2.9
_May 19, 2026_
- Improve `ReactStore` mount performance with interaction splitting (#4661) by @atomiks
- Add `getDefaultFormSubmitter` helper (#4713) by @michaldudak
- Do not use `Math.random()` in `useStableCallback` (#4732) by @michaldudak
## 0.2.8
_Apr 20, 2026_
- Deprecate `isMouseWithinBounds` (#4604) by @atomiks
## 0.2.7
_Apr 13, 2026_
- Update `StoreInspector` to use shadow DOM-safe DOM utilities (#4412) by @atomiks
- Move `createSelectorMemoized` into a separate module to reduce bundle size (#4336) by @atomiks
- Disallow optional and default parameters in `createSelector` combiners (#4299) by @JCQuintas
- Add `addEventListener` and `mergeCleanups` helpers (#4504) by @atomiks
- Fix `useControlled` warnings for circular or unserializable default values (#4452) by @Profesor08
- Support pointer events in `isMouseWithinBounds` (#4528) by @atomiks
## 0.2.6
_Mar 12, 2026_
- Add `createFormatErrorMessage` factory function (#4190) by @brijeshb42
## 0.2.5
_Feb 12, 2026_
- Refactor `ReactStore` and speed up `useStore` (#3384, #3445) by @romgrk
- Reduce `useScrollLock` style recalculation with classic scrollbars (#3854) by @mdm317
- Fix event handling in `useEnhancedClickHandler` (#3981) by @sai6855
## 0.2.4
_Jan 15, 2026_
- Add `visuallyHiddenInput` for visually hidden form controls (#3606) by @atomiks
- Improve `useScrollLock` stable scrollbar gutter detection for custom scrollbars (#3575) by @chuganzy
- Fix `ReactStore` synced value updates when detached triggers remount (#3724) by @atomiks
## 0.2.3
_Dec 11, 2025_
- Rename package from `@base-ui-components/utils` to `@base-ui/utils` (#3462) by @mnajdova
## 0.2.2
_Dec 4, 2025_
- Use raw `useSyncExternalStore` with React 19+ in `useStore` (#3360) by @romgrk
## 0.2.1
_Nov 27, 2025_
- Fix React <=18 ref access in `getReactElementRef` (#3257) by @atomiks
- Make `useScrollLock` cleanup safely check `removeEventListener` (#3264) by @Copilot
- Improve `ReactStore.useSyncedValues` performance for stable objects (#3277) by @michaldudak
- Avoid recreating `ReactStore.useStateSetter` callbacks (#3316) by @romgrk
## 0.2.0
_Nov 17, 2025_
- Add infrastructure to support nested stores (#3037) by @michaldudak
- Export `useScrollLock` (#3233) by @atomiks
## 0.1.0
_Jul 30, 2025_
Initial release
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2019 Material-UI SAS
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+3
View File
@@ -0,0 +1,3 @@
# @base-ui/utils
A collection of React utility functions for Base UI.
+12
View File
@@ -0,0 +1,12 @@
type EventTargetWithListeners = Pick<EventTarget, 'addEventListener' | 'removeEventListener'>;
type KnownEventTarget = AbortSignal | Document | Element | HTMLElement | MediaQueryList | SVGElement | VisualViewport | Window;
type EventMap<Target> = Target extends Window ? WindowEventMap : Target extends Document ? DocumentEventMap : Target extends MediaQueryList ? MediaQueryListEventMap : Target extends VisualViewport ? VisualViewportEventMap : Target extends SVGElement ? SVGElementEventMap : Target extends HTMLElement ? HTMLElementEventMap : Target extends Element ? ElementEventMap & GlobalEventHandlersEventMap : Target extends AbortSignal ? AbortSignalEventMap : never;
type TypedEventListener<Target, Event> = {
handleEvent(event: Event): void;
} | ((this: Target, event: Event) => void);
/**
* Adds an event listener and returns a cleanup function to remove it.
*/
export declare function addEventListener<Target extends KnownEventTarget, Type extends keyof EventMap<Target>>(target: Target, type: Type, listener: TypedEventListener<Target, EventMap<Target>[Type]>, options?: boolean | AddEventListenerOptions): () => void;
export declare function addEventListener(target: EventTargetWithListeners, type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): () => void;
export {};
+12
View File
@@ -0,0 +1,12 @@
type EventTargetWithListeners = Pick<EventTarget, 'addEventListener' | 'removeEventListener'>;
type KnownEventTarget = AbortSignal | Document | Element | HTMLElement | MediaQueryList | SVGElement | VisualViewport | Window;
type EventMap<Target> = Target extends Window ? WindowEventMap : Target extends Document ? DocumentEventMap : Target extends MediaQueryList ? MediaQueryListEventMap : Target extends VisualViewport ? VisualViewportEventMap : Target extends SVGElement ? SVGElementEventMap : Target extends HTMLElement ? HTMLElementEventMap : Target extends Element ? ElementEventMap & GlobalEventHandlersEventMap : Target extends AbortSignal ? AbortSignalEventMap : never;
type TypedEventListener<Target, Event> = {
handleEvent(event: Event): void;
} | ((this: Target, event: Event) => void);
/**
* Adds an event listener and returns a cleanup function to remove it.
*/
export declare function addEventListener<Target extends KnownEventTarget, Type extends keyof EventMap<Target>>(target: Target, type: Type, listener: TypedEventListener<Target, EventMap<Target>[Type]>, options?: boolean | AddEventListenerOptions): () => void;
export declare function addEventListener(target: EventTargetWithListeners, type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): () => void;
export {};
+16
View File
@@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.addEventListener = addEventListener;
/**
* Adds an event listener and returns a cleanup function to remove it.
*/
function addEventListener(target, type, listener, options) {
target.addEventListener(type, listener, options);
return () => {
target.removeEventListener(type, listener, options);
};
}
+10
View File
@@ -0,0 +1,10 @@
/**
* Adds an event listener and returns a cleanup function to remove it.
*/
export function addEventListener(target, type, listener, options) {
target.addEventListener(type, listener, options);
return () => {
target.removeEventListener(type, listener, options);
};
}
+3
View File
@@ -0,0 +1,3 @@
export declare function NOOP(): void;
export declare const EMPTY_ARRAY: readonly any[];
export declare const EMPTY_OBJECT: Readonly<{}>;
+3
View File
@@ -0,0 +1,3 @@
export declare function NOOP(): void;
export declare const EMPTY_ARRAY: readonly any[];
export declare const EMPTY_OBJECT: Readonly<{}>;
+10
View File
@@ -0,0 +1,10 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.EMPTY_OBJECT = exports.EMPTY_ARRAY = void 0;
exports.NOOP = NOOP;
function NOOP() {}
const EMPTY_ARRAY = exports.EMPTY_ARRAY = Object.freeze([]);
const EMPTY_OBJECT = exports.EMPTY_OBJECT = Object.freeze({});
+3
View File
@@ -0,0 +1,3 @@
export function NOOP() {}
export const EMPTY_ARRAY = Object.freeze([]);
export const EMPTY_OBJECT = Object.freeze({});
+2
View File
@@ -0,0 +1,2 @@
export declare function error(...messages: string[]): void;
export declare function reset(): void;
+2
View File
@@ -0,0 +1,2 @@
export declare function error(...messages: string[]): void;
export declare function reset(): void;
+23
View File
@@ -0,0 +1,23 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.error = error;
exports.reset = reset;
let set;
if (process.env.NODE_ENV !== 'production') {
set = new Set();
}
function error(...messages) {
if (process.env.NODE_ENV !== 'production') {
const messageKey = messages.join(' ');
if (!set.has(messageKey)) {
set.add(messageKey);
console.error(`Base UI: ${messageKey}`);
}
}
}
function reset() {
set?.clear();
}
+16
View File
@@ -0,0 +1,16 @@
let set;
if (process.env.NODE_ENV !== 'production') {
set = new Set();
}
export function error(...messages) {
if (process.env.NODE_ENV !== 'production') {
const messageKey = messages.join(' ');
if (!set.has(messageKey)) {
set.add(messageKey);
console.error(`Base UI: ${messageKey}`);
}
}
}
export function reset() {
set?.clear();
}
+72
View File
@@ -0,0 +1,72 @@
import * as React from 'react';
export type Instance = {
didInitialize: boolean;
};
type HookType = {
before: (instance: any) => void;
after: (instance: any) => void;
};
export declare function getInstance(): Instance | undefined;
export declare function setInstance(instance: Instance | undefined): void;
export declare function register(hook: HookType): void;
/**
* Wraps a component function to enable performance optimizations for internal hooks.
*
* **Performance Optimization:**
* Components wrapped with `fastComponent` have access to a shared "instance" context that enables
* specialized hook implementations to batch operations and reduce overhead. The wrapper creates a
* stable instance object that persists across renders, sets it as the current context, calls
* registered hooks before and after rendering, then clears the context. The primary benefit is
* with `useStore`, where multiple store subscriptions within the same component are collapsed into
* a single `useSyncExternalStore` subscription per store, significantly reducing re-render overhead.
* This optimization is only active on React 19+; on earlier versions `useStore` falls back to a
* separate subscription per call.
*
* **Requirements:**
* - The component function should follow standard React component patterns
* - `useStore` calls must keep a stable order and count across renders, as batched hooks are
* matched by call index
* - Do not rely on the instance context outside of specialized hooks
*
* @param fn - The component function to wrap
* @returns A wrapped component with the same signature as the input function
*
* @example
* ```tsx
* // Wrapping a component to enable optimized useStore batching
* export const TooltipRoot = fastComponent(function TooltipRoot(props) {
* // These useStore calls share a single subscription
* const open = useStore(store, (state) => state.open);
* const disabled = useStore(store, (state) => state.disabled);
* const value = useStore(store, (state) => state.value);
* // ...
* });
* ```
*/
export declare function fastComponent<P extends object, E extends HTMLElement, R extends React.ReactNode>(fn: (props: P) => R): typeof fn;
/**
* Wraps a component function with ref forwarding to enable performance optimizations for internal hooks.
*
* This is a convenience wrapper that combines `fastComponent` with `React.forwardRef`, enabling
* both performance optimizations and proper ref forwarding. See `fastComponent` for details on
* the performance benefits.
*
* @param fn - The component function that accepts props and a forwarded ref
* @returns A wrapped component with ref forwarding enabled
*
* @example
* ```tsx
* // Wrapping a component with ref forwarding and optimized hooks
* export const TooltipTrigger = fastComponentRef(function TooltipTrigger(
* props,
* forwardedRef
* ) {
* const store = useContext(TooltipContext);
* const open = useStore(store, (state) => state.open);
* // ... component logic with ref
* return <button ref={forwardedRef} {...props} />;
* });
* ```
*/
export declare function fastComponentRef<P extends object, E extends Element, R extends React.ReactNode>(fn: (props: React.PropsWithoutRef<P>, forwardedRef: React.Ref<E>) => R): React.ForwardRefExoticComponent<React.PropsWithoutRef<P> & React.RefAttributes<E>>;
export {};
+72
View File
@@ -0,0 +1,72 @@
import * as React from 'react';
export type Instance = {
didInitialize: boolean;
};
type HookType = {
before: (instance: any) => void;
after: (instance: any) => void;
};
export declare function getInstance(): Instance | undefined;
export declare function setInstance(instance: Instance | undefined): void;
export declare function register(hook: HookType): void;
/**
* Wraps a component function to enable performance optimizations for internal hooks.
*
* **Performance Optimization:**
* Components wrapped with `fastComponent` have access to a shared "instance" context that enables
* specialized hook implementations to batch operations and reduce overhead. The wrapper creates a
* stable instance object that persists across renders, sets it as the current context, calls
* registered hooks before and after rendering, then clears the context. The primary benefit is
* with `useStore`, where multiple store subscriptions within the same component are collapsed into
* a single `useSyncExternalStore` subscription per store, significantly reducing re-render overhead.
* This optimization is only active on React 19+; on earlier versions `useStore` falls back to a
* separate subscription per call.
*
* **Requirements:**
* - The component function should follow standard React component patterns
* - `useStore` calls must keep a stable order and count across renders, as batched hooks are
* matched by call index
* - Do not rely on the instance context outside of specialized hooks
*
* @param fn - The component function to wrap
* @returns A wrapped component with the same signature as the input function
*
* @example
* ```tsx
* // Wrapping a component to enable optimized useStore batching
* export const TooltipRoot = fastComponent(function TooltipRoot(props) {
* // These useStore calls share a single subscription
* const open = useStore(store, (state) => state.open);
* const disabled = useStore(store, (state) => state.disabled);
* const value = useStore(store, (state) => state.value);
* // ...
* });
* ```
*/
export declare function fastComponent<P extends object, E extends HTMLElement, R extends React.ReactNode>(fn: (props: P) => R): typeof fn;
/**
* Wraps a component function with ref forwarding to enable performance optimizations for internal hooks.
*
* This is a convenience wrapper that combines `fastComponent` with `React.forwardRef`, enabling
* both performance optimizations and proper ref forwarding. See `fastComponent` for details on
* the performance benefits.
*
* @param fn - The component function that accepts props and a forwarded ref
* @returns A wrapped component with ref forwarding enabled
*
* @example
* ```tsx
* // Wrapping a component with ref forwarding and optimized hooks
* export const TooltipTrigger = fastComponentRef(function TooltipTrigger(
* props,
* forwardedRef
* ) {
* const store = useContext(TooltipContext);
* const open = useStore(store, (state) => state.open);
* // ... component logic with ref
* return <button ref={forwardedRef} {...props} />;
* });
* ```
*/
export declare function fastComponentRef<P extends object, E extends Element, R extends React.ReactNode>(fn: (props: React.PropsWithoutRef<P>, forwardedRef: React.Ref<E>) => R): React.ForwardRefExoticComponent<React.PropsWithoutRef<P> & React.RefAttributes<E>>;
export {};
+114
View File
@@ -0,0 +1,114 @@
"use strict";
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.fastComponent = fastComponent;
exports.fastComponentRef = fastComponentRef;
exports.getInstance = getInstance;
exports.register = register;
exports.setInstance = setInstance;
var React = _interopRequireWildcard(require("react"));
var _useRefWithInit = require("./useRefWithInit");
const hooks = [];
let currentInstance = undefined;
function getInstance() {
return currentInstance;
}
function setInstance(instance) {
currentInstance = instance;
}
function register(hook) {
hooks.push(hook);
}
/**
* Wraps a component function to enable performance optimizations for internal hooks.
*
* **Performance Optimization:**
* Components wrapped with `fastComponent` have access to a shared "instance" context that enables
* specialized hook implementations to batch operations and reduce overhead. The wrapper creates a
* stable instance object that persists across renders, sets it as the current context, calls
* registered hooks before and after rendering, then clears the context. The primary benefit is
* with `useStore`, where multiple store subscriptions within the same component are collapsed into
* a single `useSyncExternalStore` subscription per store, significantly reducing re-render overhead.
* This optimization is only active on React 19+; on earlier versions `useStore` falls back to a
* separate subscription per call.
*
* **Requirements:**
* - The component function should follow standard React component patterns
* - `useStore` calls must keep a stable order and count across renders, as batched hooks are
* matched by call index
* - Do not rely on the instance context outside of specialized hooks
*
* @param fn - The component function to wrap
* @returns A wrapped component with the same signature as the input function
*
* @example
* ```tsx
* // Wrapping a component to enable optimized useStore batching
* export const TooltipRoot = fastComponent(function TooltipRoot(props) {
* // These useStore calls share a single subscription
* const open = useStore(store, (state) => state.open);
* const disabled = useStore(store, (state) => state.disabled);
* const value = useStore(store, (state) => state.value);
* // ...
* });
* ```
*/
function fastComponent(fn) {
const FastComponent = (props, forwardedRef) => {
const instance = (0, _useRefWithInit.useRefWithInit)(createInstance).current;
let result;
try {
currentInstance = instance;
for (const hook of hooks) {
hook.before(instance);
}
result = fn(props, forwardedRef);
for (const hook of hooks) {
hook.after(instance);
}
instance.didInitialize = true;
} finally {
currentInstance = undefined;
}
return result;
};
FastComponent.displayName = fn.displayName || fn.name;
return FastComponent;
}
/**
* Wraps a component function with ref forwarding to enable performance optimizations for internal hooks.
*
* This is a convenience wrapper that combines `fastComponent` with `React.forwardRef`, enabling
* both performance optimizations and proper ref forwarding. See `fastComponent` for details on
* the performance benefits.
*
* @param fn - The component function that accepts props and a forwarded ref
* @returns A wrapped component with ref forwarding enabled
*
* @example
* ```tsx
* // Wrapping a component with ref forwarding and optimized hooks
* export const TooltipTrigger = fastComponentRef(function TooltipTrigger(
* props,
* forwardedRef
* ) {
* const store = useContext(TooltipContext);
* const open = useStore(store, (state) => state.open);
* // ... component logic with ref
* return <button ref={forwardedRef} {...props} />;
* });
* ```
*/
function fastComponentRef(fn) {
return /*#__PURE__*/React.forwardRef(fastComponent(fn));
}
function createInstance() {
return {
didInitialize: false
};
}
+103
View File
@@ -0,0 +1,103 @@
import * as React from 'react';
import { useRefWithInit } from "./useRefWithInit.mjs";
const hooks = [];
let currentInstance = undefined;
export function getInstance() {
return currentInstance;
}
export function setInstance(instance) {
currentInstance = instance;
}
export function register(hook) {
hooks.push(hook);
}
/**
* Wraps a component function to enable performance optimizations for internal hooks.
*
* **Performance Optimization:**
* Components wrapped with `fastComponent` have access to a shared "instance" context that enables
* specialized hook implementations to batch operations and reduce overhead. The wrapper creates a
* stable instance object that persists across renders, sets it as the current context, calls
* registered hooks before and after rendering, then clears the context. The primary benefit is
* with `useStore`, where multiple store subscriptions within the same component are collapsed into
* a single `useSyncExternalStore` subscription per store, significantly reducing re-render overhead.
* This optimization is only active on React 19+; on earlier versions `useStore` falls back to a
* separate subscription per call.
*
* **Requirements:**
* - The component function should follow standard React component patterns
* - `useStore` calls must keep a stable order and count across renders, as batched hooks are
* matched by call index
* - Do not rely on the instance context outside of specialized hooks
*
* @param fn - The component function to wrap
* @returns A wrapped component with the same signature as the input function
*
* @example
* ```tsx
* // Wrapping a component to enable optimized useStore batching
* export const TooltipRoot = fastComponent(function TooltipRoot(props) {
* // These useStore calls share a single subscription
* const open = useStore(store, (state) => state.open);
* const disabled = useStore(store, (state) => state.disabled);
* const value = useStore(store, (state) => state.value);
* // ...
* });
* ```
*/
export function fastComponent(fn) {
const FastComponent = (props, forwardedRef) => {
const instance = useRefWithInit(createInstance).current;
let result;
try {
currentInstance = instance;
for (const hook of hooks) {
hook.before(instance);
}
result = fn(props, forwardedRef);
for (const hook of hooks) {
hook.after(instance);
}
instance.didInitialize = true;
} finally {
currentInstance = undefined;
}
return result;
};
FastComponent.displayName = fn.displayName || fn.name;
return FastComponent;
}
/**
* Wraps a component function with ref forwarding to enable performance optimizations for internal hooks.
*
* This is a convenience wrapper that combines `fastComponent` with `React.forwardRef`, enabling
* both performance optimizations and proper ref forwarding. See `fastComponent` for details on
* the performance benefits.
*
* @param fn - The component function that accepts props and a forwarded ref
* @returns A wrapped component with ref forwarding enabled
*
* @example
* ```tsx
* // Wrapping a component with ref forwarding and optimized hooks
* export const TooltipTrigger = fastComponentRef(function TooltipTrigger(
* props,
* forwardedRef
* ) {
* const store = useContext(TooltipContext);
* const open = useStore(store, (state) => state.open);
* // ... component logic with ref
* return <button ref={forwardedRef} {...props} />;
* });
* ```
*/
export function fastComponentRef(fn) {
return /*#__PURE__*/React.forwardRef(fastComponent(fn));
}
function createInstance() {
return {
didInitialize: false
};
}
+1
View File
@@ -0,0 +1 @@
export declare function fastObjectShallowCompare<T extends Record<string, any> | null>(a: T, b: T): boolean;
+1
View File
@@ -0,0 +1 @@
export declare function fastObjectShallowCompare<T extends Record<string, any> | null>(a: T, b: T): boolean;
+35
View File
@@ -0,0 +1,35 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.fastObjectShallowCompare = fastObjectShallowCompare;
// https://github.com/mui/mui-x/blob/master/packages/x-internals/src/fastObjectShallowCompare/fastObjectShallowCompare.ts
const is = Object.is;
function fastObjectShallowCompare(a, b) {
if (a === b) {
return true;
}
if (!(a instanceof Object) || !(b instanceof Object)) {
return false;
}
let aLength = 0;
let bLength = 0;
/* eslint-disable guard-for-in */
for (const key in a) {
aLength += 1;
if (!is(a[key], b[key])) {
return false;
}
if (!(key in b)) {
return false;
}
}
/* eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-unused-vars */
for (const _ in b) {
bLength += 1;
}
return aLength === bLength;
}
+29
View File
@@ -0,0 +1,29 @@
// https://github.com/mui/mui-x/blob/master/packages/x-internals/src/fastObjectShallowCompare/fastObjectShallowCompare.ts
const is = Object.is;
export function fastObjectShallowCompare(a, b) {
if (a === b) {
return true;
}
if (!(a instanceof Object) || !(b instanceof Object)) {
return false;
}
let aLength = 0;
let bLength = 0;
/* eslint-disable guard-for-in */
for (const key in a) {
aLength += 1;
if (!is(a[key], b[key])) {
return false;
}
if (!(key in b)) {
return false;
}
}
/* eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-unused-vars */
for (const _ in b) {
bLength += 1;
}
return aLength === bLength;
}
+18
View File
@@ -0,0 +1,18 @@
/**
* Creates a formatErrorMessage function with a custom URL and prefix.
* @param baseUrl - The base URL for the error page (e.g., 'https://base-ui.com/production-error')
* @param prefix - The prefix for the error message (e.g., 'Base UI')
* @returns A function that formats error messages with the given URL and prefix
*/
export declare function createFormatErrorMessage(baseUrl: string, prefix: string): (code: number, ...args: string[]) => string;
/**
* WARNING: Don't import this directly. It's imported by the code generated by
* `@mui/internal-babel-plugin-minify-errors`. Make sure to always use string literals in `Error`
* constructors to ensure the plugin works as expected. Supported patterns include:
* throw new Error('My message');
* throw new Error(`My message: ${foo}`);
* throw new Error(`My message: ${foo}` + 'another string');
* ...
*/
declare const formatErrorMessage: (code: number, ...args: string[]) => string;
export default formatErrorMessage;
+18
View File
@@ -0,0 +1,18 @@
/**
* Creates a formatErrorMessage function with a custom URL and prefix.
* @param baseUrl - The base URL for the error page (e.g., 'https://base-ui.com/production-error')
* @param prefix - The prefix for the error message (e.g., 'Base UI')
* @returns A function that formats error messages with the given URL and prefix
*/
export declare function createFormatErrorMessage(baseUrl: string, prefix: string): (code: number, ...args: string[]) => string;
/**
* WARNING: Don't import this directly. It's imported by the code generated by
* `@mui/internal-babel-plugin-minify-errors`. Make sure to always use string literals in `Error`
* constructors to ensure the plugin works as expected. Supported patterns include:
* throw new Error('My message');
* throw new Error(`My message: ${foo}`);
* throw new Error(`My message: ${foo}` + 'another string');
* ...
*/
declare const formatErrorMessage: (code: number, ...args: string[]) => string;
export default formatErrorMessage;
+33
View File
@@ -0,0 +1,33 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.createFormatErrorMessage = createFormatErrorMessage;
exports.default = void 0;
/**
* Creates a formatErrorMessage function with a custom URL and prefix.
* @param baseUrl - The base URL for the error page (e.g., 'https://base-ui.com/production-error')
* @param prefix - The prefix for the error message (e.g., 'Base UI')
* @returns A function that formats error messages with the given URL and prefix
*/
function createFormatErrorMessage(baseUrl, prefix) {
return function formatErrorMessage(code, ...args) {
const url = new URL(baseUrl);
url.searchParams.set('code', code.toString());
args.forEach(arg => url.searchParams.append('args[]', arg));
return `${prefix} error #${code}; visit ${url} for the full message.`;
};
}
/**
* WARNING: Don't import this directly. It's imported by the code generated by
* `@mui/internal-babel-plugin-minify-errors`. Make sure to always use string literals in `Error`
* constructors to ensure the plugin works as expected. Supported patterns include:
* throw new Error('My message');
* throw new Error(`My message: ${foo}`);
* throw new Error(`My message: ${foo}` + 'another string');
* ...
*/
const formatErrorMessage = createFormatErrorMessage('https://base-ui.com/production-error', 'Base UI');
var _default = exports.default = formatErrorMessage;
+26
View File
@@ -0,0 +1,26 @@
/**
* Creates a formatErrorMessage function with a custom URL and prefix.
* @param baseUrl - The base URL for the error page (e.g., 'https://base-ui.com/production-error')
* @param prefix - The prefix for the error message (e.g., 'Base UI')
* @returns A function that formats error messages with the given URL and prefix
*/
export function createFormatErrorMessage(baseUrl, prefix) {
return function formatErrorMessage(code, ...args) {
const url = new URL(baseUrl);
url.searchParams.set('code', code.toString());
args.forEach(arg => url.searchParams.append('args[]', arg));
return `${prefix} error #${code}; visit ${url} for the full message.`;
};
}
/**
* WARNING: Don't import this directly. It's imported by the code generated by
* `@mui/internal-babel-plugin-minify-errors`. Make sure to always use string literals in `Error`
* constructors to ensure the plugin works as expected. Supported patterns include:
* throw new Error('My message');
* throw new Error(`My message: ${foo}`);
* throw new Error(`My message: ${foo}` + 'another string');
* ...
*/
const formatErrorMessage = createFormatErrorMessage('https://base-ui.com/production-error', 'Base UI');
export default formatErrorMessage;
+1
View File
@@ -0,0 +1 @@
export declare function generateId(prefix: string): string;
+1
View File
@@ -0,0 +1 @@
export declare function generateId(prefix: string): string;
+11
View File
@@ -0,0 +1,11 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.generateId = generateId;
let counter = 0;
function generateId(prefix) {
counter += 1;
return `${prefix}-${Math.random().toString(36).slice(2, 6)}-${counter}`;
}
+5
View File
@@ -0,0 +1,5 @@
let counter = 0;
export function generateId(prefix) {
counter += 1;
return `${prefix}-${Math.random().toString(36).slice(2, 6)}-${counter}`;
}
+13
View File
@@ -0,0 +1,13 @@
export type DefaultFormSubmitter = HTMLButtonElement | HTMLInputElement;
/**
* Returns the default button a browser uses for implicit form submission.
*
* This is useful for custom form controls that need to mirror native Enter key behavior.
* Clicking the returned submitter preserves browser semantics such as the submitter's click
* event, `SubmitEvent.submitter`, and submitter-specific attributes.
*
* The function follows the controls exposed by `form.elements`, which includes controls associated
* through the `form` attribute. Disabled submitters can be returned because the default button is
* determined before disabled state is considered; clicking a disabled submitter is a no-op.
*/
export declare function getDefaultFormSubmitter(form: HTMLFormElement | null): DefaultFormSubmitter | null;
+13
View File
@@ -0,0 +1,13 @@
export type DefaultFormSubmitter = HTMLButtonElement | HTMLInputElement;
/**
* Returns the default button a browser uses for implicit form submission.
*
* This is useful for custom form controls that need to mirror native Enter key behavior.
* Clicking the returned submitter preserves browser semantics such as the submitter's click
* event, `SubmitEvent.submitter`, and submitter-specific attributes.
*
* The function follows the controls exposed by `form.elements`, which includes controls associated
* through the `form` attribute. Disabled submitters can be returned because the default button is
* determined before disabled state is considered; clicking a disabled submitter is a no-op.
*/
export declare function getDefaultFormSubmitter(form: HTMLFormElement | null): DefaultFormSubmitter | null;
+35
View File
@@ -0,0 +1,35 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getDefaultFormSubmitter = getDefaultFormSubmitter;
/**
* Returns the default button a browser uses for implicit form submission.
*
* This is useful for custom form controls that need to mirror native Enter key behavior.
* Clicking the returned submitter preserves browser semantics such as the submitter's click
* event, `SubmitEvent.submitter`, and submitter-specific attributes.
*
* The function follows the controls exposed by `form.elements`, which includes controls associated
* through the `form` attribute. Disabled submitters can be returned because the default button is
* determined before disabled state is considered; clicking a disabled submitter is a no-op.
*/
function getDefaultFormSubmitter(form) {
if (!form) {
return null;
}
for (const candidate of form.elements) {
const tagName = candidate.tagName;
if (tagName === 'BUTTON' || tagName === 'INPUT') {
const button = candidate;
// Intentionally excludes input[type="image"]: Chromium omits it from form.elements,
// so supporting it would require separate traversal for an exotic submitter type.
if (button.type === 'submit') {
return button;
}
}
}
return null;
}
+29
View File
@@ -0,0 +1,29 @@
/**
* Returns the default button a browser uses for implicit form submission.
*
* This is useful for custom form controls that need to mirror native Enter key behavior.
* Clicking the returned submitter preserves browser semantics such as the submitter's click
* event, `SubmitEvent.submitter`, and submitter-specific attributes.
*
* The function follows the controls exposed by `form.elements`, which includes controls associated
* through the `form` attribute. Disabled submitters can be returned because the default button is
* determined before disabled state is considered; clicking a disabled submitter is a no-op.
*/
export function getDefaultFormSubmitter(form) {
if (!form) {
return null;
}
for (const candidate of form.elements) {
const tagName = candidate.tagName;
if (tagName === 'BUTTON' || tagName === 'INPUT') {
const button = candidate;
// Intentionally excludes input[type="image"]: Chromium omits it from form.elements,
// so supporting it would require separate traversal for an exotic submitter type.
if (button.type === 'submit') {
return button;
}
}
}
return null;
}
+5
View File
@@ -0,0 +1,5 @@
import * as React from 'react';
/**
* Extracts the `ref` from a React element, handling different React versions.
*/
export declare function getReactElementRef(element: unknown): React.Ref<unknown> | null;
+5
View File
@@ -0,0 +1,5 @@
import * as React from 'react';
/**
* Extracts the `ref` from a React element, handling different React versions.
*/
export declare function getReactElementRef(element: unknown): React.Ref<unknown> | null;
+20
View File
@@ -0,0 +1,20 @@
"use strict";
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getReactElementRef = getReactElementRef;
var React = _interopRequireWildcard(require("react"));
var _reactVersion = require("./reactVersion");
/**
* Extracts the `ref` from a React element, handling different React versions.
*/
function getReactElementRef(element) {
if (! /*#__PURE__*/React.isValidElement(element)) {
return null;
}
const reactElement = element;
const propsWithRef = reactElement.props;
return ((0, _reactVersion.isReactVersionAtLeast)(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
}
+14
View File
@@ -0,0 +1,14 @@
import * as React from 'react';
import { isReactVersionAtLeast } from "./reactVersion.mjs";
/**
* Extracts the `ref` from a React element, handling different React versions.
*/
export function getReactElementRef(element) {
if (! /*#__PURE__*/React.isValidElement(element)) {
return null;
}
const reactElement = element;
const propsWithRef = reactElement.props;
return (isReactVersionAtLeast(19) ? propsWithRef?.ref : reactElement.ref) ?? null;
}
+1
View File
@@ -0,0 +1 @@
export declare function inertValue(value?: boolean): boolean | undefined;
+1
View File
@@ -0,0 +1 @@
export declare function inertValue(value?: boolean): boolean | undefined;
+14
View File
@@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.inertValue = inertValue;
var _reactVersion = require("./reactVersion");
function inertValue(value) {
if ((0, _reactVersion.isReactVersionAtLeast)(19)) {
return value;
}
// compatibility with React < 19
return value ? 'true' : undefined;
}
+8
View File
@@ -0,0 +1,8 @@
import { isReactVersionAtLeast } from "./reactVersion.mjs";
export function inertValue(value) {
if (isReactVersionAtLeast(19)) {
return value;
}
// compatibility with React < 19
return value ? 'true' : undefined;
}
+1
View File
@@ -0,0 +1 @@
export declare function isElementDisabled(element: HTMLElement | null): boolean;
+1
View File
@@ -0,0 +1 @@
export declare function isElementDisabled(element: HTMLElement | null): boolean;
+9
View File
@@ -0,0 +1,9 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isElementDisabled = isElementDisabled;
function isElementDisabled(element) {
return element == null || element.hasAttribute('disabled') || element.getAttribute('aria-disabled') === 'true';
}
+3
View File
@@ -0,0 +1,3 @@
export function isElementDisabled(element) {
return element == null || element.hasAttribute('disabled') || element.getAttribute('aria-disabled') === 'true';
}
+4
View File
@@ -0,0 +1,4 @@
/**
* @deprecated This utility is no longer used internally and will be removed in the next version.
*/
export declare function isMouseWithinBounds(event: React.MouseEvent<HTMLElement> | React.PointerEvent<HTMLElement>): boolean;
+4
View File
@@ -0,0 +1,4 @@
/**
* @deprecated This utility is no longer used internally and will be removed in the next version.
*/
export declare function isMouseWithinBounds(event: React.MouseEvent<HTMLElement> | React.PointerEvent<HTMLElement>): boolean;
+19
View File
@@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isMouseWithinBounds = isMouseWithinBounds;
/**
* @deprecated This utility is no longer used internally and will be removed in the next version.
*/
function isMouseWithinBounds(event) {
const targetRect = event.currentTarget.getBoundingClientRect();
// Safari randomly fires `mouseleave` incorrectly when the item is
// aligned to the trigger. This is a workaround to prevent the highlight
// from being removed while the cursor is still within the bounds of the item.
// https://github.com/mui/base-ui/issues/869
const isWithinBounds = targetRect.top + 1 <= event.clientY && event.clientY <= targetRect.bottom - 1 && targetRect.left + 1 <= event.clientX && event.clientX <= targetRect.right - 1;
return isWithinBounds;
}
+13
View File
@@ -0,0 +1,13 @@
/**
* @deprecated This utility is no longer used internally and will be removed in the next version.
*/
export function isMouseWithinBounds(event) {
const targetRect = event.currentTarget.getBoundingClientRect();
// Safari randomly fires `mouseleave` incorrectly when the item is
// aligned to the trigger. This is a workaround to prevent the highlight
// from being removed while the cursor is still within the bounds of the item.
// https://github.com/mui/base-ui/issues/869
const isWithinBounds = targetRect.top + 1 <= event.clientY && event.clientY <= targetRect.bottom - 1 && targetRect.left + 1 <= event.clientX && event.clientX <= targetRect.right - 1;
return isWithinBounds;
}
+6
View File
@@ -0,0 +1,6 @@
type Cleanup = false | null | undefined | (() => void);
/**
* Combines multiple cleanup functions into a single cleanup function.
*/
export declare function mergeCleanups(...cleanups: Cleanup[]): () => void;
export {};
+6
View File
@@ -0,0 +1,6 @@
type Cleanup = false | null | undefined | (() => void);
/**
* Combines multiple cleanup functions into a single cleanup function.
*/
export declare function mergeCleanups(...cleanups: Cleanup[]): () => void;
export {};
+19
View File
@@ -0,0 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.mergeCleanups = mergeCleanups;
/**
* Combines multiple cleanup functions into a single cleanup function.
*/
function mergeCleanups(...cleanups) {
return () => {
for (let i = 0; i < cleanups.length; i += 1) {
const cleanup = cleanups[i];
if (cleanup) {
cleanup();
}
}
};
}
+13
View File
@@ -0,0 +1,13 @@
/**
* Combines multiple cleanup functions into a single cleanup function.
*/
export function mergeCleanups(...cleanups) {
return () => {
for (let i = 0; i < cleanups.length; i += 1) {
const cleanup = cleanups[i];
if (cleanup) {
cleanup();
}
}
};
}
+1
View File
@@ -0,0 +1 @@
export declare function mergeObjects<A extends object | undefined, B extends object | undefined>(a: A, b: B): NonNullable<A> | NonNullable<B> | (A & B) | undefined;
+1
View File
@@ -0,0 +1 @@
export declare function mergeObjects<A extends object | undefined, B extends object | undefined>(a: A, b: B): NonNullable<A> | NonNullable<B> | (A & B) | undefined;
+21
View File
@@ -0,0 +1,21 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.mergeObjects = mergeObjects;
function mergeObjects(a, b) {
if (a && !b) {
return a;
}
if (!a && b) {
return b;
}
if (a || b) {
return {
...a,
...b
};
}
return undefined;
}
+15
View File
@@ -0,0 +1,15 @@
export function mergeObjects(a, b) {
if (a && !b) {
return a;
}
if (!a && b) {
return b;
}
if (a || b) {
return {
...a,
...b
};
}
return undefined;
}
+2
View File
@@ -0,0 +1,2 @@
export { getWindow as ownerWindow } from '@floating-ui/utils/dom';
export declare function ownerDocument(node: Element | null): Document;
+2
View File
@@ -0,0 +1,2 @@
export { getWindow as ownerWindow } from '@floating-ui/utils/dom';
export declare function ownerDocument(node: Element | null): Document;
+16
View File
@@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.ownerDocument = ownerDocument;
Object.defineProperty(exports, "ownerWindow", {
enumerable: true,
get: function () {
return _dom.getWindow;
}
});
var _dom = require("@floating-ui/utils/dom");
function ownerDocument(node) {
return node?.ownerDocument || document;
}
+4
View File
@@ -0,0 +1,4 @@
export { getWindow as ownerWindow } from '@floating-ui/utils/dom';
export function ownerDocument(node) {
return node?.ownerDocument || document;
}
+600
View File
@@ -0,0 +1,600 @@
{
"name": "@base-ui/utils",
"version": "0.3.2",
"author": "MUI Team",
"description": "A collection of React utility functions for Base UI.",
"license": "MIT",
"repository": {
"type": "git",
"url": "git+https://github.com/mui/base-ui.git",
"directory": "packages/utils"
},
"dependencies": {
"@babel/runtime": "^7.29.2",
"@floating-ui/utils": "^0.2.12",
"reselect": "^5.2.0",
"use-sync-external-store": "^1.6.0"
},
"peerDependencies": {
"@types/react": "^17 || ^18 || ^19",
"react": "^17 || ^18 || ^19",
"react-dom": "^17 || ^18 || ^19"
},
"peerDependenciesMeta": {
"@types/react": {
"optional": true
}
},
"sideEffects": false,
"publishConfig": {
"access": "public"
},
"type": "commonjs",
"exports": {
"./package.json": "./package.json",
"./store": {
"import": {
"types": "./store/index.d.mts",
"default": "./store/index.mjs"
},
"require": {
"types": "./store/index.d.ts",
"default": "./store/index.js"
},
"default": {
"types": "./store/index.d.mts",
"default": "./store/index.mjs"
}
},
"./platform": {
"import": {
"types": "./platform/index.d.mts",
"default": "./platform/index.mjs"
},
"require": {
"types": "./platform/index.d.ts",
"default": "./platform/index.js"
},
"default": {
"types": "./platform/index.d.mts",
"default": "./platform/index.mjs"
}
},
"./addEventListener": {
"import": {
"types": "./addEventListener.d.mts",
"default": "./addEventListener.mjs"
},
"require": {
"types": "./addEventListener.d.ts",
"default": "./addEventListener.js"
},
"default": {
"types": "./addEventListener.d.mts",
"default": "./addEventListener.mjs"
}
},
"./empty": {
"import": {
"types": "./empty.d.mts",
"default": "./empty.mjs"
},
"require": {
"types": "./empty.d.ts",
"default": "./empty.js"
},
"default": {
"types": "./empty.d.mts",
"default": "./empty.mjs"
}
},
"./error": {
"import": {
"types": "./error.d.mts",
"default": "./error.mjs"
},
"require": {
"types": "./error.d.ts",
"default": "./error.js"
},
"default": {
"types": "./error.d.mts",
"default": "./error.mjs"
}
},
"./fastHooks": {
"import": {
"types": "./fastHooks.d.mts",
"default": "./fastHooks.mjs"
},
"require": {
"types": "./fastHooks.d.ts",
"default": "./fastHooks.js"
},
"default": {
"types": "./fastHooks.d.mts",
"default": "./fastHooks.mjs"
}
},
"./fastObjectShallowCompare": {
"import": {
"types": "./fastObjectShallowCompare.d.mts",
"default": "./fastObjectShallowCompare.mjs"
},
"require": {
"types": "./fastObjectShallowCompare.d.ts",
"default": "./fastObjectShallowCompare.js"
},
"default": {
"types": "./fastObjectShallowCompare.d.mts",
"default": "./fastObjectShallowCompare.mjs"
}
},
"./formatErrorMessage": {
"import": {
"types": "./formatErrorMessage.d.mts",
"default": "./formatErrorMessage.mjs"
},
"require": {
"types": "./formatErrorMessage.d.ts",
"default": "./formatErrorMessage.js"
},
"default": {
"types": "./formatErrorMessage.d.mts",
"default": "./formatErrorMessage.mjs"
}
},
"./generateId": {
"import": {
"types": "./generateId.d.mts",
"default": "./generateId.mjs"
},
"require": {
"types": "./generateId.d.ts",
"default": "./generateId.js"
},
"default": {
"types": "./generateId.d.mts",
"default": "./generateId.mjs"
}
},
"./getDefaultFormSubmitter": {
"import": {
"types": "./getDefaultFormSubmitter.d.mts",
"default": "./getDefaultFormSubmitter.mjs"
},
"require": {
"types": "./getDefaultFormSubmitter.d.ts",
"default": "./getDefaultFormSubmitter.js"
},
"default": {
"types": "./getDefaultFormSubmitter.d.mts",
"default": "./getDefaultFormSubmitter.mjs"
}
},
"./getReactElementRef": {
"import": {
"types": "./getReactElementRef.d.mts",
"default": "./getReactElementRef.mjs"
},
"require": {
"types": "./getReactElementRef.d.ts",
"default": "./getReactElementRef.js"
},
"default": {
"types": "./getReactElementRef.d.mts",
"default": "./getReactElementRef.mjs"
}
},
"./inertValue": {
"import": {
"types": "./inertValue.d.mts",
"default": "./inertValue.mjs"
},
"require": {
"types": "./inertValue.d.ts",
"default": "./inertValue.js"
},
"default": {
"types": "./inertValue.d.mts",
"default": "./inertValue.mjs"
}
},
"./isElementDisabled": {
"import": {
"types": "./isElementDisabled.d.mts",
"default": "./isElementDisabled.mjs"
},
"require": {
"types": "./isElementDisabled.d.ts",
"default": "./isElementDisabled.js"
},
"default": {
"types": "./isElementDisabled.d.mts",
"default": "./isElementDisabled.mjs"
}
},
"./isMouseWithinBounds": {
"import": {
"types": "./isMouseWithinBounds.d.mts",
"default": "./isMouseWithinBounds.mjs"
},
"require": {
"types": "./isMouseWithinBounds.d.ts",
"default": "./isMouseWithinBounds.js"
},
"default": {
"types": "./isMouseWithinBounds.d.mts",
"default": "./isMouseWithinBounds.mjs"
}
},
"./mergeCleanups": {
"import": {
"types": "./mergeCleanups.d.mts",
"default": "./mergeCleanups.mjs"
},
"require": {
"types": "./mergeCleanups.d.ts",
"default": "./mergeCleanups.js"
},
"default": {
"types": "./mergeCleanups.d.mts",
"default": "./mergeCleanups.mjs"
}
},
"./mergeObjects": {
"import": {
"types": "./mergeObjects.d.mts",
"default": "./mergeObjects.mjs"
},
"require": {
"types": "./mergeObjects.d.ts",
"default": "./mergeObjects.js"
},
"default": {
"types": "./mergeObjects.d.mts",
"default": "./mergeObjects.mjs"
}
},
"./owner": {
"import": {
"types": "./owner.d.mts",
"default": "./owner.mjs"
},
"require": {
"types": "./owner.d.ts",
"default": "./owner.js"
},
"default": {
"types": "./owner.d.mts",
"default": "./owner.mjs"
}
},
"./reactVersion": {
"import": {
"types": "./reactVersion.d.mts",
"default": "./reactVersion.mjs"
},
"require": {
"types": "./reactVersion.d.ts",
"default": "./reactVersion.js"
},
"default": {
"types": "./reactVersion.d.mts",
"default": "./reactVersion.mjs"
}
},
"./safeReact": {
"import": {
"types": "./safeReact.d.mts",
"default": "./safeReact.mjs"
},
"require": {
"types": "./safeReact.d.ts",
"default": "./safeReact.js"
},
"default": {
"types": "./safeReact.d.mts",
"default": "./safeReact.mjs"
}
},
"./testUtils": {
"import": {
"types": "./testUtils.d.mts",
"default": "./testUtils.mjs"
},
"require": {
"types": "./testUtils.d.ts",
"default": "./testUtils.js"
},
"default": {
"types": "./testUtils.d.mts",
"default": "./testUtils.mjs"
}
},
"./useAnimationFrame": {
"import": {
"types": "./useAnimationFrame.d.mts",
"default": "./useAnimationFrame.mjs"
},
"require": {
"types": "./useAnimationFrame.d.ts",
"default": "./useAnimationFrame.js"
},
"default": {
"types": "./useAnimationFrame.d.mts",
"default": "./useAnimationFrame.mjs"
}
},
"./useControlled": {
"import": {
"types": "./useControlled.d.mts",
"default": "./useControlled.mjs"
},
"require": {
"types": "./useControlled.d.ts",
"default": "./useControlled.js"
},
"default": {
"types": "./useControlled.d.mts",
"default": "./useControlled.mjs"
}
},
"./useEnhancedClickHandler": {
"import": {
"types": "./useEnhancedClickHandler.d.mts",
"default": "./useEnhancedClickHandler.mjs"
},
"require": {
"types": "./useEnhancedClickHandler.d.ts",
"default": "./useEnhancedClickHandler.js"
},
"default": {
"types": "./useEnhancedClickHandler.d.mts",
"default": "./useEnhancedClickHandler.mjs"
}
},
"./useForcedRerendering": {
"import": {
"types": "./useForcedRerendering.d.mts",
"default": "./useForcedRerendering.mjs"
},
"require": {
"types": "./useForcedRerendering.d.ts",
"default": "./useForcedRerendering.js"
},
"default": {
"types": "./useForcedRerendering.d.mts",
"default": "./useForcedRerendering.mjs"
}
},
"./useId": {
"import": {
"types": "./useId.d.mts",
"default": "./useId.mjs"
},
"require": {
"types": "./useId.d.ts",
"default": "./useId.js"
},
"default": {
"types": "./useId.d.mts",
"default": "./useId.mjs"
}
},
"./useIdleCallback": {
"import": {
"types": "./useIdleCallback.d.mts",
"default": "./useIdleCallback.mjs"
},
"require": {
"types": "./useIdleCallback.d.ts",
"default": "./useIdleCallback.js"
},
"default": {
"types": "./useIdleCallback.d.mts",
"default": "./useIdleCallback.mjs"
}
},
"./useInterval": {
"import": {
"types": "./useInterval.d.mts",
"default": "./useInterval.mjs"
},
"require": {
"types": "./useInterval.d.ts",
"default": "./useInterval.js"
},
"default": {
"types": "./useInterval.d.mts",
"default": "./useInterval.mjs"
}
},
"./useIsoLayoutEffect": {
"import": {
"types": "./useIsoLayoutEffect.d.mts",
"default": "./useIsoLayoutEffect.mjs"
},
"require": {
"types": "./useIsoLayoutEffect.d.ts",
"default": "./useIsoLayoutEffect.js"
},
"default": {
"types": "./useIsoLayoutEffect.d.mts",
"default": "./useIsoLayoutEffect.mjs"
}
},
"./useMergedRefs": {
"import": {
"types": "./useMergedRefs.d.mts",
"default": "./useMergedRefs.mjs"
},
"require": {
"types": "./useMergedRefs.d.ts",
"default": "./useMergedRefs.js"
},
"default": {
"types": "./useMergedRefs.d.mts",
"default": "./useMergedRefs.mjs"
}
},
"./useOnFirstRender": {
"import": {
"types": "./useOnFirstRender.d.mts",
"default": "./useOnFirstRender.mjs"
},
"require": {
"types": "./useOnFirstRender.d.ts",
"default": "./useOnFirstRender.js"
},
"default": {
"types": "./useOnFirstRender.d.mts",
"default": "./useOnFirstRender.mjs"
}
},
"./useOnMount": {
"import": {
"types": "./useOnMount.d.mts",
"default": "./useOnMount.mjs"
},
"require": {
"types": "./useOnMount.d.ts",
"default": "./useOnMount.js"
},
"default": {
"types": "./useOnMount.d.mts",
"default": "./useOnMount.mjs"
}
},
"./usePreviousValue": {
"import": {
"types": "./usePreviousValue.d.mts",
"default": "./usePreviousValue.mjs"
},
"require": {
"types": "./usePreviousValue.d.ts",
"default": "./usePreviousValue.js"
},
"default": {
"types": "./usePreviousValue.d.mts",
"default": "./usePreviousValue.mjs"
}
},
"./useRefWithInit": {
"import": {
"types": "./useRefWithInit.d.mts",
"default": "./useRefWithInit.mjs"
},
"require": {
"types": "./useRefWithInit.d.ts",
"default": "./useRefWithInit.js"
},
"default": {
"types": "./useRefWithInit.d.mts",
"default": "./useRefWithInit.mjs"
}
},
"./useScrollLock": {
"import": {
"types": "./useScrollLock.d.mts",
"default": "./useScrollLock.mjs"
},
"require": {
"types": "./useScrollLock.d.ts",
"default": "./useScrollLock.js"
},
"default": {
"types": "./useScrollLock.d.mts",
"default": "./useScrollLock.mjs"
}
},
"./useStableCallback": {
"import": {
"types": "./useStableCallback.d.mts",
"default": "./useStableCallback.mjs"
},
"require": {
"types": "./useStableCallback.d.ts",
"default": "./useStableCallback.js"
},
"default": {
"types": "./useStableCallback.d.mts",
"default": "./useStableCallback.mjs"
}
},
"./useTimeout": {
"import": {
"types": "./useTimeout.d.mts",
"default": "./useTimeout.mjs"
},
"require": {
"types": "./useTimeout.d.ts",
"default": "./useTimeout.js"
},
"default": {
"types": "./useTimeout.d.mts",
"default": "./useTimeout.mjs"
}
},
"./useValueAsRef": {
"import": {
"types": "./useValueAsRef.d.mts",
"default": "./useValueAsRef.mjs"
},
"require": {
"types": "./useValueAsRef.d.ts",
"default": "./useValueAsRef.js"
},
"default": {
"types": "./useValueAsRef.d.mts",
"default": "./useValueAsRef.mjs"
}
},
"./visuallyHidden": {
"import": {
"types": "./visuallyHidden.d.mts",
"default": "./visuallyHidden.mjs"
},
"require": {
"types": "./visuallyHidden.d.ts",
"default": "./visuallyHidden.js"
},
"default": {
"types": "./visuallyHidden.d.mts",
"default": "./visuallyHidden.mjs"
}
},
"./warn": {
"import": {
"types": "./warn.d.mts",
"default": "./warn.mjs"
},
"require": {
"types": "./warn.d.ts",
"default": "./warn.js"
},
"default": {
"types": "./warn.d.mts",
"default": "./warn.mjs"
}
},
"./*.test": null,
"./*.spec": null
},
"imports": {
"#formatErrorMessage": {
"import": {
"types": "./formatErrorMessage.d.mts",
"default": "./formatErrorMessage.mjs"
},
"require": {
"types": "./formatErrorMessage.d.ts",
"default": "./formatErrorMessage.js"
},
"default": {
"types": "./formatErrorMessage.d.mts",
"default": "./formatErrorMessage.mjs"
}
}
}
}
+6
View File
@@ -0,0 +1,6 @@
/** WebKit: Safari, all iOS browsers, GNOME Web. Excludes Blink. */
export declare const webkit: boolean;
/** Gecko: Firefox. */
export declare const gecko: boolean;
/** Blink: Chrome, Edge, Opera, Brave, and other Chromium-based browsers. */
export declare const blink: boolean;
+6
View File
@@ -0,0 +1,6 @@
/** WebKit: Safari, all iOS browsers, GNOME Web. Excludes Blink. */
export declare const webkit: boolean;
/** Gecko: Firefox. */
export declare const gecko: boolean;
/** Blink: Chrome, Edge, Opera, Brave, and other Chromium-based browsers. */
export declare const blink: boolean;
+26
View File
@@ -0,0 +1,26 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.webkit = exports.gecko = exports.blink = void 0;
var _shared = require("./shared");
// WebKit (Safari, all iOS browsers, GNOME Web). Distinguished from Blink by
// the legacy `-webkit-backdrop-filter` name — Blink forked from WebKit in 2013
// and only ships the unprefixed `backdrop-filter`.
/** WebKit: Safari, all iOS browsers, GNOME Web. Excludes Blink. */
const webkit = exports.webkit = typeof CSS !== 'undefined' && !!CSS.supports?.('-webkit-backdrop-filter:none');
// Anchored to `!webkit` so engines are mutually exclusive by construction.
// Firefox-on-iOS uses WebKit (its UA marker is `FxiOS/`, not `Firefox/`); the
// `!webkit` prefix also defends against future iOS-browser UA changes that
// might inject `Firefox` into a WebKit-based UA.
/** Gecko: Firefox. */
const gecko = exports.gecko = !webkit && _shared.lowerUserAgent.includes('firefox');
// All Chromium-based browsers ship `Chrome/` or `Chromium/` in their UA — both
// share the `chrom` prefix, so a single substring check covers Chrome, Edge,
// Opera, Brave, etc. Chrome-on-iOS uses `CriOS/` and stays WebKit. The positive
// UA check also makes this SSR-safe — an empty UA matches nothing.
/** Blink: Chrome, Edge, Opera, Brave, and other Chromium-based browsers. */
const blink = exports.blink = !webkit && _shared.lowerUserAgent.includes('chrom');
+21
View File
@@ -0,0 +1,21 @@
import { lowerUserAgent } from "./shared.mjs";
// WebKit (Safari, all iOS browsers, GNOME Web). Distinguished from Blink by
// the legacy `-webkit-backdrop-filter` name — Blink forked from WebKit in 2013
// and only ships the unprefixed `backdrop-filter`.
/** WebKit: Safari, all iOS browsers, GNOME Web. Excludes Blink. */
export const webkit = typeof CSS !== 'undefined' && !!CSS.supports?.('-webkit-backdrop-filter:none');
// Anchored to `!webkit` so engines are mutually exclusive by construction.
// Firefox-on-iOS uses WebKit (its UA marker is `FxiOS/`, not `Firefox/`); the
// `!webkit` prefix also defends against future iOS-browser UA changes that
// might inject `Firefox` into a WebKit-based UA.
/** Gecko: Firefox. */
export const gecko = !webkit && lowerUserAgent.includes('firefox');
// All Chromium-based browsers ship `Chrome/` or `Chromium/` in their UA — both
// share the `chrom` prefix, so a single substring check covers Chrome, Edge,
// Opera, Brave, etc. Chrome-on-iOS uses `CriOS/` and stays WebKit. The positive
// UA check also makes this SSR-safe — an empty UA matches nothing.
/** Blink: Chrome, Edge, Opera, Brave, and other Chromium-based browsers. */
export const blink = !webkit && lowerUserAgent.includes('chrom');
+2
View File
@@ -0,0 +1,2 @@
/** Running in jsdom or HappyDOM (used by unit tests). */
export declare const jsdom: boolean;
+2
View File
@@ -0,0 +1,2 @@
/** Running in jsdom or HappyDOM (used by unit tests). */
export declare const jsdom: boolean;
+9
View File
@@ -0,0 +1,9 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.jsdom = void 0;
var _shared = require("./shared");
/** Running in jsdom or HappyDOM (used by unit tests). */
const jsdom = exports.jsdom = /jsdom|happydom/.test(_shared.lowerUserAgent);
+4
View File
@@ -0,0 +1,4 @@
import { lowerUserAgent } from "./shared.mjs";
/** Running in jsdom or HappyDOM (used by unit tests). */
export const jsdom = /jsdom|happydom/.test(lowerUserAgent);
+26
View File
@@ -0,0 +1,26 @@
/**
* Static platform-detection flags, evaluated once at module load. SSR-safe —
* every flag is `false` when `navigator` is undefined.
*
* Scope is intentionally limited to traits that don't change at runtime (OS,
* rendering engine, environment). Dynamic capabilities like input modality
* (pointer/touch/hover) belong in a separate feature-detection layer because
* they can change mid-session (e.g. plugging in a mouse).
*
* Import as a namespace and pick the most precise group for the quirk:
*
* ```ts
* import { platform } from '@base-ui/utils/platform';
* if (platform.os.mac) { ... }
* if (platform.engine.webkit) { ... }
* ```
*
* Each category is its own module under `./platform/*`, so unused namespaces
* tree-shake away.
*
* - `os.*` for OS-specific behavior (keyboard shortcuts, native menus).
* - `engine.*` for rendering-engine bugs (CSS, layout, focus).
* - `screenReader.*` for AT-specific accessibility workarounds.
* - `env.*` for test-environment gating.
*/
export * as platform from "./parts.mjs";
+26
View File
@@ -0,0 +1,26 @@
/**
* Static platform-detection flags, evaluated once at module load. SSR-safe —
* every flag is `false` when `navigator` is undefined.
*
* Scope is intentionally limited to traits that don't change at runtime (OS,
* rendering engine, environment). Dynamic capabilities like input modality
* (pointer/touch/hover) belong in a separate feature-detection layer because
* they can change mid-session (e.g. plugging in a mouse).
*
* Import as a namespace and pick the most precise group for the quirk:
*
* ```ts
* import { platform } from '@base-ui/utils/platform';
* if (platform.os.mac) { ... }
* if (platform.engine.webkit) { ... }
* ```
*
* Each category is its own module under `./platform/*`, so unused namespaces
* tree-shake away.
*
* - `os.*` for OS-specific behavior (keyboard shortcuts, native menus).
* - `engine.*` for rendering-engine bugs (CSS, layout, focus).
* - `screenReader.*` for AT-specific accessibility workarounds.
* - `env.*` for test-environment gating.
*/
export * as platform from "./parts.js";
+9
View File
@@ -0,0 +1,9 @@
"use strict";
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.platform = void 0;
var _platform = _interopRequireWildcard(require("./parts"));
exports.platform = _platform;
+27
View File
@@ -0,0 +1,27 @@
/**
* Static platform-detection flags, evaluated once at module load. SSR-safe —
* every flag is `false` when `navigator` is undefined.
*
* Scope is intentionally limited to traits that don't change at runtime (OS,
* rendering engine, environment). Dynamic capabilities like input modality
* (pointer/touch/hover) belong in a separate feature-detection layer because
* they can change mid-session (e.g. plugging in a mouse).
*
* Import as a namespace and pick the most precise group for the quirk:
*
* ```ts
* import { platform } from '@base-ui/utils/platform';
* if (platform.os.mac) { ... }
* if (platform.engine.webkit) { ... }
* ```
*
* Each category is its own module under `./platform/*`, so unused namespaces
* tree-shake away.
*
* - `os.*` for OS-specific behavior (keyboard shortcuts, native menus).
* - `engine.*` for rendering-engine bugs (CSS, layout, focus).
* - `screenReader.*` for AT-specific accessibility workarounds.
* - `env.*` for test-environment gating.
*/
export * as platform from "./parts.mjs";
+11
View File
@@ -0,0 +1,11 @@
/** iPhone, iPad (including iPadOS 13+ reporting as macOS), iPod. */
export declare const ios: boolean;
export declare const android: boolean;
/** macOS desktop. Excludes iPadOS, which reports as `MacIntel`. */
export declare const mac: boolean;
/** Windows desktop. */
export declare const windows: boolean;
/** Linux desktop (including Chrome OS). */
export declare const linux: boolean;
/** Any Apple OS (`mac || ios`). */
export declare const apple: boolean;
+11
View File
@@ -0,0 +1,11 @@
/** iPhone, iPad (including iPadOS 13+ reporting as macOS), iPod. */
export declare const ios: boolean;
export declare const android: boolean;
/** macOS desktop. Excludes iPadOS, which reports as `MacIntel`. */
export declare const mac: boolean;
/** Windows desktop. */
export declare const windows: boolean;
/** Linux desktop (including Chrome OS). */
export declare const linux: boolean;
/** Any Apple OS (`mac || ios`). */
export declare const apple: boolean;
+28
View File
@@ -0,0 +1,28 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.windows = exports.mac = exports.linux = exports.ios = exports.apple = exports.android = void 0;
var _shared = require("./shared");
// iPadOS 13+ reports `MacIntel` for `navigator.platform`; disambiguated via
// `maxTouchPoints` so iPad is classified as iOS, not macOS.
// https://github.com/mui/base-ui/issues/1309
/** iPhone, iPad (including iPadOS 13+ reporting as macOS), iPod. */
const ios = exports.ios = /^i(os$|p)/.test(_shared.lowerPlatform) || _shared.lowerPlatform === 'macintel' && _shared.maxTouchPoints > 1;
/** Android phones, tablets, and embedded Android browsers. */
const ANDROID_STRING = 'android';
const android = exports.android = _shared.lowerPlatform === ANDROID_STRING || _shared.lowerUserAgent.includes(ANDROID_STRING);
/** macOS desktop. Excludes iPadOS, which reports as `MacIntel`. */
const mac = exports.mac = !ios && _shared.lowerPlatform.startsWith('mac');
/** Windows desktop. */
const windows = exports.windows = _shared.lowerPlatform.startsWith('win');
/** Linux desktop (including Chrome OS). */
const linux = exports.linux = !android && /^(linux|chrome os)/.test(_shared.lowerPlatform);
/** Any Apple OS (`mac || ios`). */
const apple = exports.apple = mac || ios;
+23
View File
@@ -0,0 +1,23 @@
import { lowerUserAgent, lowerPlatform, maxTouchPoints } from "./shared.mjs";
// iPadOS 13+ reports `MacIntel` for `navigator.platform`; disambiguated via
// `maxTouchPoints` so iPad is classified as iOS, not macOS.
// https://github.com/mui/base-ui/issues/1309
/** iPhone, iPad (including iPadOS 13+ reporting as macOS), iPod. */
export const ios = /^i(os$|p)/.test(lowerPlatform) || lowerPlatform === 'macintel' && maxTouchPoints > 1;
/** Android phones, tablets, and embedded Android browsers. */
const ANDROID_STRING = 'android';
export const android = lowerPlatform === ANDROID_STRING || lowerUserAgent.includes(ANDROID_STRING);
/** macOS desktop. Excludes iPadOS, which reports as `MacIntel`. */
export const mac = !ios && lowerPlatform.startsWith('mac');
/** Windows desktop. */
export const windows = lowerPlatform.startsWith('win');
/** Linux desktop (including Chrome OS). */
export const linux = !android && /^(linux|chrome os)/.test(lowerPlatform);
/** Any Apple OS (`mac || ios`). */
export const apple = mac || ios;
+4
View File
@@ -0,0 +1,4 @@
export * as os from "./os.mjs";
export * as engine from "./engine.mjs";
export * as screenReader from "./screen-reader.mjs";
export * as env from "./env.mjs";
+4
View File
@@ -0,0 +1,4 @@
export * as os from "./os.js";
export * as engine from "./engine.js";
export * as screenReader from "./screen-reader.js";
export * as env from "./env.js";
+15
View File
@@ -0,0 +1,15 @@
"use strict";
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.screenReader = exports.os = exports.env = exports.engine = void 0;
var _os = _interopRequireWildcard(require("./os"));
exports.os = _os;
var _engine = _interopRequireWildcard(require("./engine"));
exports.engine = _engine;
var _screenReader = _interopRequireWildcard(require("./screen-reader"));
exports.screenReader = _screenReader;
var _env = _interopRequireWildcard(require("./env"));
exports.env = _env;
+4
View File
@@ -0,0 +1,4 @@
export * as os from "./os.mjs";
export * as engine from "./engine.mjs";
export * as screenReader from "./screen-reader.mjs";
export * as env from "./env.mjs";
+5
View File
@@ -0,0 +1,5 @@
/**
* The user *may* be using VoiceOver — actual activation is not detectable.
* True on any Apple platform (macOS, iOS, iPadOS).
*/
export declare const voiceOver: boolean;
+5
View File
@@ -0,0 +1,5 @@
/**
* The user *may* be using VoiceOver — actual activation is not detectable.
* True on any Apple platform (macOS, iOS, iPadOS).
*/
export declare const voiceOver: boolean;
+17
View File
@@ -0,0 +1,17 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.voiceOver = void 0;
var _os = require("./os");
// Whether a screen reader is *actually* running cannot be detected. These flags
// identify platforms where a specific screen reader could be active. VoiceOver
// is the system screen reader on Apple platforms and works with every browser
// there, so the flag is purely an OS check; engine-specific quirks (e.g. the
// NSAccessibility virtual-cursor focus path) should be gated at the call site.
/**
* The user *may* be using VoiceOver — actual activation is not detectable.
* True on any Apple platform (macOS, iOS, iPadOS).
*/
const voiceOver = exports.voiceOver = _os.apple;
+12
View File
@@ -0,0 +1,12 @@
import { apple } from "./os.mjs";
// Whether a screen reader is *actually* running cannot be detected. These flags
// identify platforms where a specific screen reader could be active. VoiceOver
// is the system screen reader on Apple platforms and works with every browser
// there, so the flag is purely an OS check; engine-specific quirks (e.g. the
// NSAccessibility virtual-cursor focus path) should be gated at the call site.
/**
* The user *may* be using VoiceOver — actual activation is not detectable.
* True on any Apple platform (macOS, iOS, iPadOS).
*/
export const voiceOver = apple;
+4
View File
@@ -0,0 +1,4 @@
declare const maxTouchPoints: number;
export declare const lowerUserAgent: string;
export declare const lowerPlatform: string;
export { maxTouchPoints };
+4
View File
@@ -0,0 +1,4 @@
declare const maxTouchPoints: number;
export declare const lowerUserAgent: string;
export declare const lowerPlatform: string;
export { maxTouchPoints };
+51
View File
@@ -0,0 +1,51 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.maxTouchPoints = exports.lowerUserAgent = exports.lowerPlatform = void 0;
/**
* Reads `navigator.userAgent` / `navigator.platform` (legacy but universally
* supported) into a normalized shape. In development, prefers the modern
* `navigator.userAgentData` API on Chromium to avoid DevTools warnings about
* the deprecated reads; that branch is dead-code-eliminated in production
* builds to keep the bundle small.
*
* Returns empty/zero values when `navigator` is undefined (SSR), so every
* derived flag safely evaluates to `false`.
*/
function readRawData() {
if (typeof navigator === 'undefined') {
return {
userAgent: '',
platform: '',
maxTouchPoints: 0
};
}
if (process.env.NODE_ENV !== 'production') {
const uaData = navigator.userAgentData;
if (uaData && Array.isArray(uaData.brands)) {
return {
userAgent: uaData.brands.map(({
brand,
version
}) => `${brand}/${version}`).join(' '),
platform: uaData.platform ?? navigator.platform ?? '',
maxTouchPoints: navigator.maxTouchPoints ?? 0
};
}
}
return {
userAgent: navigator.userAgent,
platform: navigator.platform ?? '',
maxTouchPoints: navigator.maxTouchPoints ?? 0
};
}
const {
userAgent,
platform,
maxTouchPoints
} = readRawData();
exports.maxTouchPoints = maxTouchPoints;
const lowerUserAgent = exports.lowerUserAgent = userAgent.toLowerCase();
const lowerPlatform = exports.lowerPlatform = platform.toLowerCase();
+45
View File
@@ -0,0 +1,45 @@
/**
* Reads `navigator.userAgent` / `navigator.platform` (legacy but universally
* supported) into a normalized shape. In development, prefers the modern
* `navigator.userAgentData` API on Chromium to avoid DevTools warnings about
* the deprecated reads; that branch is dead-code-eliminated in production
* builds to keep the bundle small.
*
* Returns empty/zero values when `navigator` is undefined (SSR), so every
* derived flag safely evaluates to `false`.
*/
function readRawData() {
if (typeof navigator === 'undefined') {
return {
userAgent: '',
platform: '',
maxTouchPoints: 0
};
}
if (process.env.NODE_ENV !== 'production') {
const uaData = navigator.userAgentData;
if (uaData && Array.isArray(uaData.brands)) {
return {
userAgent: uaData.brands.map(({
brand,
version
}) => `${brand}/${version}`).join(' '),
platform: uaData.platform ?? navigator.platform ?? '',
maxTouchPoints: navigator.maxTouchPoints ?? 0
};
}
}
return {
userAgent: navigator.userAgent,
platform: navigator.platform ?? '',
maxTouchPoints: navigator.maxTouchPoints ?? 0
};
}
const {
userAgent,
platform,
maxTouchPoints
} = readRawData();
export const lowerUserAgent = userAgent.toLowerCase();
export const lowerPlatform = platform.toLowerCase();
export { maxTouchPoints };
+3
View File
@@ -0,0 +1,3 @@
type SupportedVersions = 17 | 18 | 19;
export declare function isReactVersionAtLeast(reactVersionToCheck: SupportedVersions): boolean;
export {};
+3
View File
@@ -0,0 +1,3 @@
type SupportedVersions = 17 | 18 | 19;
export declare function isReactVersionAtLeast(reactVersionToCheck: SupportedVersions): boolean;
export {};
+12
View File
@@ -0,0 +1,12 @@
"use strict";
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isReactVersionAtLeast = isReactVersionAtLeast;
var React = _interopRequireWildcard(require("react"));
const majorVersion = parseInt(React.version, 10);
function isReactVersionAtLeast(reactVersionToCheck) {
return majorVersion >= reactVersionToCheck;
}
+5
View File
@@ -0,0 +1,5 @@
import * as React from 'react';
const majorVersion = parseInt(React.version, 10);
export function isReactVersionAtLeast(reactVersionToCheck) {
return majorVersion >= reactVersionToCheck;
}
+10
View File
@@ -0,0 +1,10 @@
import * as React from 'react';
/**
* A clone of the React namespace for reading APIs that may be missing in older
* supported React versions. Bundlers can rewrite direct `React.someNewApi`
* reads into named imports, which breaks React 17. Reading from this cloned
* object keeps those lookups optional.
*
* @see https://github.com/mui/material-ui/issues/41190#issuecomment-2040873379
*/
export declare const SafeReact: typeof React;
+10
View File
@@ -0,0 +1,10 @@
import * as React from 'react';
/**
* A clone of the React namespace for reading APIs that may be missing in older
* supported React versions. Bundlers can rewrite direct `React.someNewApi`
* reads into named imports, which breaks React 17. Reading from this cloned
* object keeps those lookups optional.
*
* @see https://github.com/mui/material-ui/issues/41190#issuecomment-2040873379
*/
export declare const SafeReact: typeof React;
+19
View File
@@ -0,0 +1,19 @@
"use strict";
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.SafeReact = void 0;
var React = _interopRequireWildcard(require("react"));
/**
* A clone of the React namespace for reading APIs that may be missing in older
* supported React versions. Bundlers can rewrite direct `React.someNewApi`
* reads into named imports, which breaks React 17. Reading from this cloned
* object keeps those lookups optional.
*
* @see https://github.com/mui/material-ui/issues/41190#issuecomment-2040873379
*/
const SafeReact = exports.SafeReact = {
...React
};
+13
View File
@@ -0,0 +1,13 @@
import * as React from 'react';
/**
* A clone of the React namespace for reading APIs that may be missing in older
* supported React versions. Bundlers can rewrite direct `React.someNewApi`
* reads into named imports, which breaks React 17. Reading from this cloned
* object keeps those lookups optional.
*
* @see https://github.com/mui/material-ui/issues/41190#issuecomment-2040873379
*/
export const SafeReact = {
...React
};

Some files were not shown because too many files have changed in this diff Show More