@mui/utils 7.0.1 → 7.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +60 -0
- package/esm/index.js +1 -1
- package/esm/useForkRef/useForkRef.d.ts +1 -2
- package/esm/useForkRef/useForkRef.js +32 -12
- package/index.js +1 -1
- package/modern/useForkRef/useForkRef.d.ts +1 -2
- package/package.json +4 -12
- package/useForkRef/useForkRef.d.ts +1 -2
- package/useForkRef/useForkRef.js +32 -13
- package/modern/ClassNameGenerator/ClassNameGenerator.js +0 -17
- package/modern/ClassNameGenerator/index.js +0 -1
- package/modern/HTMLElementType/HTMLElementType.js +0 -14
- package/modern/HTMLElementType/index.js +0 -1
- package/modern/appendOwnerState/appendOwnerState.js +0 -28
- package/modern/appendOwnerState/index.js +0 -1
- package/modern/capitalize/capitalize.js +0 -11
- package/modern/capitalize/index.js +0 -1
- package/modern/chainPropTypes/chainPropTypes.js +0 -8
- package/modern/chainPropTypes/index.js +0 -1
- package/modern/clamp/clamp.js +0 -4
- package/modern/clamp/index.js +0 -1
- package/modern/composeClasses/composeClasses.js +0 -53
- package/modern/composeClasses/index.js +0 -1
- package/modern/createChainedFunction/createChainedFunction.js +0 -17
- package/modern/createChainedFunction/index.js +0 -1
- package/modern/debounce/debounce.js +0 -17
- package/modern/debounce/index.js +0 -2
- package/modern/deepmerge/deepmerge.js +0 -64
- package/modern/deepmerge/index.js +0 -2
- package/modern/deprecatedPropType/deprecatedPropType.js +0 -13
- package/modern/deprecatedPropType/index.js +0 -1
- package/modern/elementAcceptingRef/elementAcceptingRef.js +0 -42
- package/modern/elementAcceptingRef/index.js +0 -1
- package/modern/elementTypeAcceptingRef/elementTypeAcceptingRef.js +0 -40
- package/modern/elementTypeAcceptingRef/index.js +0 -1
- package/modern/exactProp/exactProp.js +0 -20
- package/modern/exactProp/index.js +0 -1
- package/modern/extractEventHandlers/extractEventHandlers.js +0 -18
- package/modern/extractEventHandlers/index.js +0 -1
- package/modern/formatMuiErrorMessage/formatMuiErrorMessage.js +0 -15
- package/modern/formatMuiErrorMessage/index.js +0 -1
- package/modern/generateUtilityClass/generateUtilityClass.js +0 -22
- package/modern/generateUtilityClass/index.js +0 -2
- package/modern/generateUtilityClasses/generateUtilityClasses.js +0 -8
- package/modern/generateUtilityClasses/index.js +0 -1
- package/modern/getDisplayName/getDisplayName.js +0 -38
- package/modern/getDisplayName/index.js +0 -1
- package/modern/getReactElementRef/getReactElementRef.js +0 -18
- package/modern/getReactElementRef/index.js +0 -1
- package/modern/getReactNodeRef/getReactNodeRef.js +0 -23
- package/modern/getReactNodeRef/index.js +0 -1
- package/modern/getScrollbarSize/getScrollbarSize.js +0 -7
- package/modern/getScrollbarSize/index.js +0 -1
- package/modern/getValidReactChildren/getValidReactChildren.js +0 -11
- package/modern/getValidReactChildren/index.js +0 -1
- package/modern/index.js +0 -57
- package/modern/integerPropType/index.js +0 -2
- package/modern/integerPropType/integerPropType.js +0 -44
- package/modern/isFocusVisible/index.js +0 -1
- package/modern/isFocusVisible/isFocusVisible.js +0 -15
- package/modern/isHostComponent/index.js +0 -1
- package/modern/isHostComponent/isHostComponent.js +0 -7
- package/modern/isMuiElement/index.js +0 -1
- package/modern/isMuiElement/isMuiElement.js +0 -8
- package/modern/mergeSlotProps/index.js +0 -1
- package/modern/mergeSlotProps/mergeSlotProps.js +0 -90
- package/modern/omitEventHandlers/index.js +0 -1
- package/modern/omitEventHandlers/omitEventHandlers.js +0 -18
- package/modern/ownerDocument/index.js +0 -1
- package/modern/ownerDocument/ownerDocument.js +0 -3
- package/modern/ownerWindow/index.js +0 -1
- package/modern/ownerWindow/ownerWindow.js +0 -5
- package/modern/package.json +0 -1
- package/modern/ponyfillGlobal/index.js +0 -1
- package/modern/ponyfillGlobal/ponyfillGlobal.js +0 -6
- package/modern/refType/index.js +0 -1
- package/modern/refType/refType.js +0 -3
- package/modern/requirePropFactory/index.js +0 -1
- package/modern/requirePropFactory/requirePropFactory.js +0 -25
- package/modern/resolveComponentProps/index.js +0 -1
- package/modern/resolveComponentProps/resolveComponentProps.js +0 -11
- package/modern/resolveProps/index.js +0 -1
- package/modern/resolveProps/resolveProps.js +0 -43
- package/modern/setRef/index.js +0 -1
- package/modern/setRef/setRef.js +0 -20
- package/modern/types/index.js +0 -1
- package/modern/unsupportedProp/index.js +0 -1
- package/modern/unsupportedProp/unsupportedProp.js +0 -10
- package/modern/useControlled/index.js +0 -1
- package/modern/useControlled/useControlled.js +0 -41
- package/modern/useEnhancedEffect/index.js +0 -1
- package/modern/useEnhancedEffect/useEnhancedEffect.js +0 -13
- package/modern/useEventCallback/index.js +0 -1
- package/modern/useEventCallback/useEventCallback.js +0 -20
- package/modern/useForkRef/index.js +0 -1
- package/modern/useForkRef/useForkRef.js +0 -40
- package/modern/useId/index.js +0 -1
- package/modern/useId/useId.js +0 -45
- package/modern/useIsFocusVisible/index.js +0 -2
- package/modern/useIsFocusVisible/useIsFocusVisible.js +0 -163
- package/modern/useLazyRef/index.js +0 -1
- package/modern/useLazyRef/useLazyRef.js +0 -19
- package/modern/useLocalStorageState/index.js +0 -1
- package/modern/useLocalStorageState/useLocalStorageState.js +0 -108
- package/modern/useOnMount/index.js +0 -1
- package/modern/useOnMount/useOnMount.js +0 -14
- package/modern/usePreviousProps/index.js +0 -1
- package/modern/usePreviousProps/usePreviousProps.js +0 -11
- package/modern/useSlotProps/index.js +0 -1
- package/modern/useSlotProps/useSlotProps.js +0 -38
- package/modern/useTimeout/index.js +0 -2
- package/modern/useTimeout/useTimeout.js +0 -35
- package/modern/visuallyHidden/index.js +0 -1
- package/modern/visuallyHidden/visuallyHidden.js +0 -12
- package/tsconfig.build.tsbuildinfo +0 -1
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import PropTypes from 'prop-types';
|
|
2
|
-
import chainPropTypes from "../chainPropTypes/index.js";
|
|
3
|
-
function isClassComponent(elementType) {
|
|
4
|
-
// elementType.prototype?.isReactComponent
|
|
5
|
-
const {
|
|
6
|
-
prototype = {}
|
|
7
|
-
} = elementType;
|
|
8
|
-
return Boolean(prototype.isReactComponent);
|
|
9
|
-
}
|
|
10
|
-
function elementTypeAcceptingRef(props, propName, componentName, location, propFullName) {
|
|
11
|
-
const propValue = props[propName];
|
|
12
|
-
const safePropName = propFullName || propName;
|
|
13
|
-
if (propValue == null ||
|
|
14
|
-
// When server-side rendering React doesn't warn either.
|
|
15
|
-
// This is not an accurate check for SSR.
|
|
16
|
-
// This is only in place for emotion compat.
|
|
17
|
-
// TODO: Revisit once https://github.com/facebook/react/issues/20047 is resolved.
|
|
18
|
-
typeof window === 'undefined') {
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
21
|
-
let warningHint;
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Blacklisting instead of whitelisting
|
|
25
|
-
*
|
|
26
|
-
* Blacklisting will miss some components, such as React.Fragment. Those will at least
|
|
27
|
-
* trigger a warning in React.
|
|
28
|
-
* We can't whitelist because there is no safe way to detect React.forwardRef
|
|
29
|
-
* or class components. "Safe" means there's no public API.
|
|
30
|
-
*
|
|
31
|
-
*/
|
|
32
|
-
if (typeof propValue === 'function' && !isClassComponent(propValue)) {
|
|
33
|
-
warningHint = 'Did you accidentally provide a plain function component instead?';
|
|
34
|
-
}
|
|
35
|
-
if (warningHint !== undefined) {
|
|
36
|
-
return new Error(`Invalid ${location} \`${safePropName}\` supplied to \`${componentName}\`. ` + `Expected an element type that can hold a ref. ${warningHint} ` + 'For more information see https://mui.com/r/caveat-with-refs-guide');
|
|
37
|
-
}
|
|
38
|
-
return null;
|
|
39
|
-
}
|
|
40
|
-
export default chainPropTypes(PropTypes.elementType, elementTypeAcceptingRef);
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./elementTypeAcceptingRef.js";
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
// This module is based on https://github.com/airbnb/prop-types-exact repository.
|
|
2
|
-
// However, in order to reduce the number of dependencies and to remove some extra safe checks
|
|
3
|
-
// the module was forked.
|
|
4
|
-
|
|
5
|
-
const specialProperty = 'exact-prop: \u200b';
|
|
6
|
-
export default function exactProp(propTypes) {
|
|
7
|
-
if (process.env.NODE_ENV === 'production') {
|
|
8
|
-
return propTypes;
|
|
9
|
-
}
|
|
10
|
-
return {
|
|
11
|
-
...propTypes,
|
|
12
|
-
[specialProperty]: props => {
|
|
13
|
-
const unsupportedProps = Object.keys(props).filter(prop => !propTypes.hasOwnProperty(prop));
|
|
14
|
-
if (unsupportedProps.length > 0) {
|
|
15
|
-
return new Error(`The following props are not supported: ${unsupportedProps.map(prop => `\`${prop}\``).join(', ')}. Please remove them.`);
|
|
16
|
-
}
|
|
17
|
-
return null;
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./exactProp.js";
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Extracts event handlers from a given object.
|
|
3
|
-
* A prop is considered an event handler if it is a function and its name starts with `on`.
|
|
4
|
-
*
|
|
5
|
-
* @param object An object to extract event handlers from.
|
|
6
|
-
* @param excludeKeys An array of keys to exclude from the returned object.
|
|
7
|
-
*/
|
|
8
|
-
function extractEventHandlers(object, excludeKeys = []) {
|
|
9
|
-
if (object === undefined) {
|
|
10
|
-
return {};
|
|
11
|
-
}
|
|
12
|
-
const result = {};
|
|
13
|
-
Object.keys(object).filter(prop => prop.match(/^on[A-Z]/) && typeof object[prop] === 'function' && !excludeKeys.includes(prop)).forEach(prop => {
|
|
14
|
-
result[prop] = object[prop];
|
|
15
|
-
});
|
|
16
|
-
return result;
|
|
17
|
-
}
|
|
18
|
-
export default extractEventHandlers;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./extractEventHandlers.js";
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* WARNING: Don't import this directly. It's imported by the code generated by
|
|
3
|
-
* `@mui/interal-babel-plugin-minify-errors`. Make sure to always use string literals in `Error`
|
|
4
|
-
* constructors to ensure the plugin works as expected. Supported patterns include:
|
|
5
|
-
* throw new Error('My message');
|
|
6
|
-
* throw new Error(`My message: ${foo}`);
|
|
7
|
-
* throw new Error(`My message: ${foo}` + 'another string');
|
|
8
|
-
* ...
|
|
9
|
-
* @param {number} code
|
|
10
|
-
*/
|
|
11
|
-
export default function formatMuiErrorMessage(code, ...args) {
|
|
12
|
-
const url = new URL(`https://mui.com/production-error/?code=${code}`);
|
|
13
|
-
args.forEach(arg => url.searchParams.append('args[]', arg));
|
|
14
|
-
return `Minified MUI error #${code}; visit ${url} for the full message.`;
|
|
15
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./formatMuiErrorMessage.js";
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import ClassNameGenerator from "../ClassNameGenerator/index.js";
|
|
2
|
-
export const globalStateClasses = {
|
|
3
|
-
active: 'active',
|
|
4
|
-
checked: 'checked',
|
|
5
|
-
completed: 'completed',
|
|
6
|
-
disabled: 'disabled',
|
|
7
|
-
error: 'error',
|
|
8
|
-
expanded: 'expanded',
|
|
9
|
-
focused: 'focused',
|
|
10
|
-
focusVisible: 'focusVisible',
|
|
11
|
-
open: 'open',
|
|
12
|
-
readOnly: 'readOnly',
|
|
13
|
-
required: 'required',
|
|
14
|
-
selected: 'selected'
|
|
15
|
-
};
|
|
16
|
-
export default function generateUtilityClass(componentName, slot, globalStatePrefix = 'Mui') {
|
|
17
|
-
const globalStateClass = globalStateClasses[slot];
|
|
18
|
-
return globalStateClass ? `${globalStatePrefix}-${globalStateClass}` : `${ClassNameGenerator.generate(componentName)}-${slot}`;
|
|
19
|
-
}
|
|
20
|
-
export function isGlobalState(slot) {
|
|
21
|
-
return globalStateClasses[slot] !== undefined;
|
|
22
|
-
}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import generateUtilityClass from "../generateUtilityClass/index.js";
|
|
2
|
-
export default function generateUtilityClasses(componentName, slots, globalStatePrefix = 'Mui') {
|
|
3
|
-
const result = {};
|
|
4
|
-
slots.forEach(slot => {
|
|
5
|
-
result[slot] = generateUtilityClass(componentName, slot, globalStatePrefix);
|
|
6
|
-
});
|
|
7
|
-
return result;
|
|
8
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./generateUtilityClasses.js";
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { ForwardRef, Memo } from 'react-is';
|
|
2
|
-
function getFunctionComponentName(Component, fallback = '') {
|
|
3
|
-
return Component.displayName || Component.name || fallback;
|
|
4
|
-
}
|
|
5
|
-
function getWrappedName(outerType, innerType, wrapperName) {
|
|
6
|
-
const functionName = getFunctionComponentName(innerType);
|
|
7
|
-
return outerType.displayName || (functionName !== '' ? `${wrapperName}(${functionName})` : wrapperName);
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* cherry-pick from
|
|
12
|
-
* https://github.com/facebook/react/blob/769b1f270e1251d9dbdce0fcbd9e92e502d059b8/packages/shared/getComponentName.js
|
|
13
|
-
* originally forked from recompose/getDisplayName
|
|
14
|
-
*/
|
|
15
|
-
export default function getDisplayName(Component) {
|
|
16
|
-
if (Component == null) {
|
|
17
|
-
return undefined;
|
|
18
|
-
}
|
|
19
|
-
if (typeof Component === 'string') {
|
|
20
|
-
return Component;
|
|
21
|
-
}
|
|
22
|
-
if (typeof Component === 'function') {
|
|
23
|
-
return getFunctionComponentName(Component, 'Component');
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
// TypeScript can't have components as objects but they exist in the form of `memo` or `Suspense`
|
|
27
|
-
if (typeof Component === 'object') {
|
|
28
|
-
switch (Component.$$typeof) {
|
|
29
|
-
case ForwardRef:
|
|
30
|
-
return getWrappedName(Component, Component.render, 'ForwardRef');
|
|
31
|
-
case Memo:
|
|
32
|
-
return getWrappedName(Component, Component.type, 'memo');
|
|
33
|
-
default:
|
|
34
|
-
return undefined;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
return undefined;
|
|
38
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./getDisplayName.js";
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Returns the ref of a React element handling differences between React 19 and older versions.
|
|
5
|
-
* It will throw runtime error if the element is not a valid React element.
|
|
6
|
-
*
|
|
7
|
-
* @param element React.ReactElement
|
|
8
|
-
* @returns React.Ref<any> | null
|
|
9
|
-
*/
|
|
10
|
-
export default function getReactElementRef(element) {
|
|
11
|
-
// 'ref' is passed as prop in React 19, whereas 'ref' is directly attached to children in older versions
|
|
12
|
-
if (parseInt(React.version, 10) >= 19) {
|
|
13
|
-
return element?.props?.ref || null;
|
|
14
|
-
}
|
|
15
|
-
// @ts-expect-error element.ref is not included in the ReactElement type
|
|
16
|
-
// https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/70189
|
|
17
|
-
return element?.ref || null;
|
|
18
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./getReactElementRef.js";
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Returns the ref of a React node handling differences between React 19 and older versions.
|
|
5
|
-
* It will return null if the node is not a valid React element.
|
|
6
|
-
*
|
|
7
|
-
* @param element React.ReactNode
|
|
8
|
-
* @returns React.Ref<any> | null
|
|
9
|
-
*
|
|
10
|
-
* @deprecated Use getReactElementRef instead
|
|
11
|
-
*/
|
|
12
|
-
export default function getReactNodeRef(element) {
|
|
13
|
-
if (!element || ! /*#__PURE__*/React.isValidElement(element)) {
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
// 'ref' is passed as prop in React 19, whereas 'ref' is directly attached to children in older versions
|
|
18
|
-
return element.props.propertyIsEnumerable('ref') ? element.props.ref :
|
|
19
|
-
// @ts-expect-error element.ref is not included in the ReactElement type
|
|
20
|
-
// We cannot check for it, but isValidElement is true at this point
|
|
21
|
-
// https://github.com/DefinitelyTyped/DefinitelyTyped/discussions/70189
|
|
22
|
-
element.ref;
|
|
23
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./getReactNodeRef.js";
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
// A change of the browser zoom change the scrollbar size.
|
|
2
|
-
// Credit https://github.com/twbs/bootstrap/blob/488fd8afc535ca3a6ad4dc581f5e89217b6a36ac/js/src/util/scrollbar.js#L14-L18
|
|
3
|
-
export default function getScrollbarSize(win = window) {
|
|
4
|
-
// https://developer.mozilla.org/en-US/docs/Web/API/Window/innerWidth#usage_notes
|
|
5
|
-
const documentWidth = win.document.documentElement.clientWidth;
|
|
6
|
-
return win.innerWidth - documentWidth;
|
|
7
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./getScrollbarSize.js";
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Gets only the valid children of a component,
|
|
5
|
-
* and ignores any nullish or falsy child.
|
|
6
|
-
*
|
|
7
|
-
* @param children the children
|
|
8
|
-
*/
|
|
9
|
-
export default function getValidReactChildren(children) {
|
|
10
|
-
return React.Children.toArray(children).filter(child => /*#__PURE__*/React.isValidElement(child));
|
|
11
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./getValidReactChildren.js";
|
package/modern/index.js
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @mui/utils v7.0.1
|
|
3
|
-
*
|
|
4
|
-
* @license MIT
|
|
5
|
-
* This source code is licensed under the MIT license found in the
|
|
6
|
-
* LICENSE file in the root directory of this source tree.
|
|
7
|
-
*/
|
|
8
|
-
export { default as chainPropTypes } from "./chainPropTypes/index.js";
|
|
9
|
-
export { default as deepmerge } from "./deepmerge/index.js";
|
|
10
|
-
export { isPlainObject } from "./deepmerge/index.js";
|
|
11
|
-
export { default as elementAcceptingRef } from "./elementAcceptingRef/index.js";
|
|
12
|
-
export { default as elementTypeAcceptingRef } from "./elementTypeAcceptingRef/index.js";
|
|
13
|
-
export { default as exactProp } from "./exactProp/index.js";
|
|
14
|
-
export { default as formatMuiErrorMessage } from "./formatMuiErrorMessage/index.js";
|
|
15
|
-
export { default as getDisplayName } from "./getDisplayName/index.js";
|
|
16
|
-
export { default as HTMLElementType } from "./HTMLElementType/index.js";
|
|
17
|
-
export { default as ponyfillGlobal } from "./ponyfillGlobal/index.js";
|
|
18
|
-
export { default as refType } from "./refType/index.js";
|
|
19
|
-
export { default as unstable_capitalize } from "./capitalize/index.js";
|
|
20
|
-
export { default as unstable_createChainedFunction } from "./createChainedFunction/index.js";
|
|
21
|
-
export { default as unstable_debounce } from "./debounce/index.js";
|
|
22
|
-
export { default as unstable_deprecatedPropType } from "./deprecatedPropType/index.js";
|
|
23
|
-
export { default as unstable_isMuiElement } from "./isMuiElement/index.js";
|
|
24
|
-
export { default as unstable_ownerDocument } from "./ownerDocument/index.js";
|
|
25
|
-
export { default as unstable_ownerWindow } from "./ownerWindow/index.js";
|
|
26
|
-
export { default as unstable_requirePropFactory } from "./requirePropFactory/index.js";
|
|
27
|
-
export { default as unstable_setRef } from "./setRef/index.js";
|
|
28
|
-
export { default as unstable_useEnhancedEffect } from "./useEnhancedEffect/index.js";
|
|
29
|
-
export { default as unstable_useId } from "./useId/index.js";
|
|
30
|
-
export { default as unstable_unsupportedProp } from "./unsupportedProp/index.js";
|
|
31
|
-
export { default as unstable_useControlled } from "./useControlled/index.js";
|
|
32
|
-
export { default as unstable_useEventCallback } from "./useEventCallback/index.js";
|
|
33
|
-
export { default as unstable_useForkRef } from "./useForkRef/index.js";
|
|
34
|
-
export { default as unstable_useLazyRef } from "./useLazyRef/index.js";
|
|
35
|
-
export { default as unstable_useTimeout, Timeout as unstable_Timeout } from "./useTimeout/index.js";
|
|
36
|
-
export { default as unstable_useOnMount } from "./useOnMount/index.js";
|
|
37
|
-
export { default as unstable_useIsFocusVisible } from "./useIsFocusVisible/index.js";
|
|
38
|
-
export { default as unstable_isFocusVisible } from "./isFocusVisible/index.js";
|
|
39
|
-
export { default as unstable_getScrollbarSize } from "./getScrollbarSize/index.js";
|
|
40
|
-
export { default as usePreviousProps } from "./usePreviousProps/index.js";
|
|
41
|
-
export { default as getValidReactChildren } from "./getValidReactChildren/index.js";
|
|
42
|
-
export { default as visuallyHidden } from "./visuallyHidden/index.js";
|
|
43
|
-
export { default as integerPropType } from "./integerPropType/index.js";
|
|
44
|
-
export { default as internal_resolveProps } from "./resolveProps/index.js";
|
|
45
|
-
export { default as unstable_composeClasses } from "./composeClasses/index.js";
|
|
46
|
-
export { default as unstable_generateUtilityClass } from "./generateUtilityClass/index.js";
|
|
47
|
-
export { isGlobalState as unstable_isGlobalState } from "./generateUtilityClass/index.js";
|
|
48
|
-
export * from "./generateUtilityClass/index.js";
|
|
49
|
-
export { default as unstable_generateUtilityClasses } from "./generateUtilityClasses/index.js";
|
|
50
|
-
export { default as unstable_ClassNameGenerator } from "./ClassNameGenerator/index.js";
|
|
51
|
-
export { default as clamp } from "./clamp/index.js";
|
|
52
|
-
export { default as unstable_useSlotProps } from "./useSlotProps/index.js";
|
|
53
|
-
export { default as unstable_resolveComponentProps } from "./resolveComponentProps/index.js";
|
|
54
|
-
export { default as unstable_extractEventHandlers } from "./extractEventHandlers/index.js";
|
|
55
|
-
export { default as unstable_getReactNodeRef } from "./getReactNodeRef/index.js";
|
|
56
|
-
export { default as unstable_getReactElementRef } from "./getReactElementRef/index.js";
|
|
57
|
-
export * from "./types/index.js";
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
export function getTypeByValue(value) {
|
|
2
|
-
const valueType = typeof value;
|
|
3
|
-
switch (valueType) {
|
|
4
|
-
case 'number':
|
|
5
|
-
if (Number.isNaN(value)) {
|
|
6
|
-
return 'NaN';
|
|
7
|
-
}
|
|
8
|
-
if (!Number.isFinite(value)) {
|
|
9
|
-
return 'Infinity';
|
|
10
|
-
}
|
|
11
|
-
if (value !== Math.floor(value)) {
|
|
12
|
-
return 'float';
|
|
13
|
-
}
|
|
14
|
-
return 'number';
|
|
15
|
-
case 'object':
|
|
16
|
-
if (value === null) {
|
|
17
|
-
return 'null';
|
|
18
|
-
}
|
|
19
|
-
return value.constructor.name;
|
|
20
|
-
default:
|
|
21
|
-
return valueType;
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
function requiredInteger(props, propName, componentName, location) {
|
|
25
|
-
const propValue = props[propName];
|
|
26
|
-
if (propValue == null || !Number.isInteger(propValue)) {
|
|
27
|
-
const propType = getTypeByValue(propValue);
|
|
28
|
-
return new RangeError(`Invalid ${location} \`${propName}\` of type \`${propType}\` supplied to \`${componentName}\`, expected \`integer\`.`);
|
|
29
|
-
}
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
function validator(props, propName, ...other) {
|
|
33
|
-
const propValue = props[propName];
|
|
34
|
-
if (propValue === undefined) {
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
return requiredInteger(props, propName, ...other);
|
|
38
|
-
}
|
|
39
|
-
function validatorNoop() {
|
|
40
|
-
return null;
|
|
41
|
-
}
|
|
42
|
-
validator.isRequired = requiredInteger;
|
|
43
|
-
validatorNoop.isRequired = validatorNoop;
|
|
44
|
-
export default process.env.NODE_ENV === 'production' ? validatorNoop : validator;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./isFocusVisible.js";
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Returns a boolean indicating if the event's target has :focus-visible
|
|
3
|
-
*/
|
|
4
|
-
export default function isFocusVisible(element) {
|
|
5
|
-
try {
|
|
6
|
-
return element.matches(':focus-visible');
|
|
7
|
-
} catch (error) {
|
|
8
|
-
// Do not warn on jsdom tests, otherwise all tests that rely on focus have to be skipped
|
|
9
|
-
// Tests that rely on `:focus-visible` will still have to be skipped in jsdom
|
|
10
|
-
if (process.env.NODE_ENV !== 'production' && !/jsdom/.test(window.navigator.userAgent)) {
|
|
11
|
-
console.warn(['MUI: The `:focus-visible` pseudo class is not supported in this browser.', 'Some components rely on this feature to work properly.'].join('\n'));
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
return false;
|
|
15
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./isHostComponent.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./isMuiElement.js";
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
export default function isMuiElement(element, muiNames) {
|
|
3
|
-
return /*#__PURE__*/React.isValidElement(element) && muiNames.indexOf(
|
|
4
|
-
// For server components `muiName` is avaialble in element.type._payload.value.muiName
|
|
5
|
-
// relevant info - https://github.com/facebook/react/blob/2807d781a08db8e9873687fccc25c0f12b4fb3d4/packages/react/src/ReactLazy.js#L45
|
|
6
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
7
|
-
element.type.muiName ?? element.type?._payload?.value?.muiName) !== -1;
|
|
8
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./mergeSlotProps.js";
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
import clsx from 'clsx';
|
|
2
|
-
import extractEventHandlers from "../extractEventHandlers/index.js";
|
|
3
|
-
import omitEventHandlers from "../omitEventHandlers/index.js";
|
|
4
|
-
/**
|
|
5
|
-
* Merges the slot component internal props (usually coming from a hook)
|
|
6
|
-
* with the externally provided ones.
|
|
7
|
-
*
|
|
8
|
-
* The merge order is (the latter overrides the former):
|
|
9
|
-
* 1. The internal props (specified as a getter function to work with get*Props hook result)
|
|
10
|
-
* 2. Additional props (specified internally on a Base UI component)
|
|
11
|
-
* 3. External props specified on the owner component. These should only be used on a root slot.
|
|
12
|
-
* 4. External props specified in the `slotProps.*` prop.
|
|
13
|
-
* 5. The `className` prop - combined from all the above.
|
|
14
|
-
* @param parameters
|
|
15
|
-
* @returns
|
|
16
|
-
*/
|
|
17
|
-
function mergeSlotProps(parameters) {
|
|
18
|
-
const {
|
|
19
|
-
getSlotProps,
|
|
20
|
-
additionalProps,
|
|
21
|
-
externalSlotProps,
|
|
22
|
-
externalForwardedProps,
|
|
23
|
-
className
|
|
24
|
-
} = parameters;
|
|
25
|
-
if (!getSlotProps) {
|
|
26
|
-
// The simpler case - getSlotProps is not defined, so no internal event handlers are defined,
|
|
27
|
-
// so we can simply merge all the props without having to worry about extracting event handlers.
|
|
28
|
-
const joinedClasses = clsx(additionalProps?.className, className, externalForwardedProps?.className, externalSlotProps?.className);
|
|
29
|
-
const mergedStyle = {
|
|
30
|
-
...additionalProps?.style,
|
|
31
|
-
...externalForwardedProps?.style,
|
|
32
|
-
...externalSlotProps?.style
|
|
33
|
-
};
|
|
34
|
-
const props = {
|
|
35
|
-
...additionalProps,
|
|
36
|
-
...externalForwardedProps,
|
|
37
|
-
...externalSlotProps
|
|
38
|
-
};
|
|
39
|
-
if (joinedClasses.length > 0) {
|
|
40
|
-
props.className = joinedClasses;
|
|
41
|
-
}
|
|
42
|
-
if (Object.keys(mergedStyle).length > 0) {
|
|
43
|
-
props.style = mergedStyle;
|
|
44
|
-
}
|
|
45
|
-
return {
|
|
46
|
-
props,
|
|
47
|
-
internalRef: undefined
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
// In this case, getSlotProps is responsible for calling the external event handlers.
|
|
52
|
-
// We don't need to include them in the merged props because of this.
|
|
53
|
-
|
|
54
|
-
const eventHandlers = extractEventHandlers({
|
|
55
|
-
...externalForwardedProps,
|
|
56
|
-
...externalSlotProps
|
|
57
|
-
});
|
|
58
|
-
const componentsPropsWithoutEventHandlers = omitEventHandlers(externalSlotProps);
|
|
59
|
-
const otherPropsWithoutEventHandlers = omitEventHandlers(externalForwardedProps);
|
|
60
|
-
const internalSlotProps = getSlotProps(eventHandlers);
|
|
61
|
-
|
|
62
|
-
// The order of classes is important here.
|
|
63
|
-
// Emotion (that we use in libraries consuming Base UI) depends on this order
|
|
64
|
-
// to properly override style. It requires the most important classes to be last
|
|
65
|
-
// (see https://github.com/mui/material-ui/pull/33205) for the related discussion.
|
|
66
|
-
const joinedClasses = clsx(internalSlotProps?.className, additionalProps?.className, className, externalForwardedProps?.className, externalSlotProps?.className);
|
|
67
|
-
const mergedStyle = {
|
|
68
|
-
...internalSlotProps?.style,
|
|
69
|
-
...additionalProps?.style,
|
|
70
|
-
...externalForwardedProps?.style,
|
|
71
|
-
...externalSlotProps?.style
|
|
72
|
-
};
|
|
73
|
-
const props = {
|
|
74
|
-
...internalSlotProps,
|
|
75
|
-
...additionalProps,
|
|
76
|
-
...otherPropsWithoutEventHandlers,
|
|
77
|
-
...componentsPropsWithoutEventHandlers
|
|
78
|
-
};
|
|
79
|
-
if (joinedClasses.length > 0) {
|
|
80
|
-
props.className = joinedClasses;
|
|
81
|
-
}
|
|
82
|
-
if (Object.keys(mergedStyle).length > 0) {
|
|
83
|
-
props.style = mergedStyle;
|
|
84
|
-
}
|
|
85
|
-
return {
|
|
86
|
-
props,
|
|
87
|
-
internalRef: internalSlotProps.ref
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
export default mergeSlotProps;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./omitEventHandlers.js";
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Removes event handlers from the given object.
|
|
3
|
-
* A field is considered an event handler if it is a function with a name beginning with `on`.
|
|
4
|
-
*
|
|
5
|
-
* @param object Object to remove event handlers from.
|
|
6
|
-
* @returns Object with event handlers removed.
|
|
7
|
-
*/
|
|
8
|
-
function omitEventHandlers(object) {
|
|
9
|
-
if (object === undefined) {
|
|
10
|
-
return {};
|
|
11
|
-
}
|
|
12
|
-
const result = {};
|
|
13
|
-
Object.keys(object).filter(prop => !(prop.match(/^on[A-Z]/) && typeof object[prop] === 'function')).forEach(prop => {
|
|
14
|
-
result[prop] = object[prop];
|
|
15
|
-
});
|
|
16
|
-
return result;
|
|
17
|
-
}
|
|
18
|
-
export default omitEventHandlers;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./ownerDocument.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./ownerWindow.js";
|
package/modern/package.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type":"module","sideEffects":false}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./ponyfillGlobal.js";
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
|
-
/**
|
|
3
|
-
* https://github.com/zloirock/core-js/issues/86#issuecomment-115759028
|
|
4
|
-
* @deprecated Use `globalThis` instead.
|
|
5
|
-
*/
|
|
6
|
-
export default typeof window != 'undefined' && window.Math == Math ? window : typeof self != 'undefined' && self.Math == Math ? self : Function('return this')();
|
package/modern/refType/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./refType.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./requirePropFactory.js";
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export default function requirePropFactory(componentNameInError, Component) {
|
|
2
|
-
if (process.env.NODE_ENV === 'production') {
|
|
3
|
-
return () => null;
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
// eslint-disable-next-line react/forbid-foreign-prop-types
|
|
7
|
-
const prevPropTypes = Component ? {
|
|
8
|
-
...Component.propTypes
|
|
9
|
-
} : null;
|
|
10
|
-
const requireProp = requiredProp => (props, propName, componentName, location, propFullName, ...args) => {
|
|
11
|
-
const propFullNameSafe = propFullName || propName;
|
|
12
|
-
const defaultTypeChecker = prevPropTypes?.[propFullNameSafe];
|
|
13
|
-
if (defaultTypeChecker) {
|
|
14
|
-
const typeCheckerResult = defaultTypeChecker(props, propName, componentName, location, propFullName, ...args);
|
|
15
|
-
if (typeCheckerResult) {
|
|
16
|
-
return typeCheckerResult;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
if (typeof props[propName] !== 'undefined' && !props[requiredProp]) {
|
|
20
|
-
return new Error(`The prop \`${propFullNameSafe}\` of ` + `\`${componentNameInError}\` can only be used together with the \`${requiredProp}\` prop.`);
|
|
21
|
-
}
|
|
22
|
-
return null;
|
|
23
|
-
};
|
|
24
|
-
return requireProp;
|
|
25
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./resolveComponentProps.js";
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* If `componentProps` is a function, calls it with the provided `ownerState`.
|
|
3
|
-
* Otherwise, just returns `componentProps`.
|
|
4
|
-
*/
|
|
5
|
-
function resolveComponentProps(componentProps, ownerState, slotState) {
|
|
6
|
-
if (typeof componentProps === 'function') {
|
|
7
|
-
return componentProps(ownerState, slotState);
|
|
8
|
-
}
|
|
9
|
-
return componentProps;
|
|
10
|
-
}
|
|
11
|
-
export default resolveComponentProps;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./resolveProps.js";
|