@mui/utils
Advanced tools
Comparing version 5.10.9 to 5.10.14
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -9,5 +8,3 @@ value: true | ||
exports.default = capitalize; | ||
var _formatMuiErrorMessage2 = _interopRequireDefault(require("./formatMuiErrorMessage")); | ||
// It should to be noted that this function isn't equivalent to `text-transform: capitalize`. | ||
@@ -21,4 +18,3 @@ // | ||
} | ||
return string.charAt(0).toUpperCase() + string.slice(1); | ||
} |
import PropTypes from 'prop-types'; | ||
export default function chainPropTypes<A, B>(propType1: PropTypes.Validator<A>, propType2: PropTypes.Validator<B>): PropTypes.Validator<A & B>; |
@@ -7,3 +7,2 @@ "use strict"; | ||
exports.default = chainPropTypes; | ||
function chainPropTypes(propType1, propType2) { | ||
@@ -13,3 +12,2 @@ if (process.env.NODE_ENV === 'production') { | ||
} | ||
return function validate(...args) { | ||
@@ -16,0 +14,0 @@ return propType1(...args) || propType2(...args); |
@@ -0,0 +0,0 @@ declare const ClassNameGenerator: { |
@@ -7,5 +7,3 @@ "use strict"; | ||
exports.default = void 0; | ||
const defaultGenerator = componentName => componentName; | ||
const createClassNameGenerator = () => { | ||
@@ -17,16 +15,12 @@ let generate = defaultGenerator; | ||
}, | ||
generate(componentName) { | ||
return generate(componentName); | ||
}, | ||
reset() { | ||
generate = defaultGenerator; | ||
} | ||
}; | ||
}; | ||
const ClassNameGenerator = createClassNameGenerator(); | ||
var _default = ClassNameGenerator; | ||
exports.default = _default; |
export { default } from './ClassNameGenerator'; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -14,3 +13,2 @@ value: true | ||
}); | ||
var _ClassNameGenerator = _interopRequireDefault(require("./ClassNameGenerator")); |
export default function composeClasses<ClassKey extends string>(slots: Record<ClassKey, ReadonlyArray<string | false | undefined | null>>, getUtilityClass: (slot: string) => string, classes: Record<string, string> | undefined): Record<ClassKey, string>; |
@@ -7,6 +7,6 @@ "use strict"; | ||
exports.default = composeClasses; | ||
function composeClasses(slots, getUtilityClass, classes) { | ||
const output = {}; | ||
Object.keys(slots).forEach( // `Objet.keys(slots)` can't be wider than `T` because we infer `T` from `slots`. | ||
Object.keys(slots).forEach( | ||
// `Objet.keys(slots)` can't be wider than `T` because we infer `T` from `slots`. | ||
// @ts-expect-error https://github.com/microsoft/TypeScript/pull/12253#issuecomment-263132208 | ||
@@ -17,3 +17,2 @@ slot => { | ||
acc.push(getUtilityClass(key)); | ||
if (classes && classes[key]) { | ||
@@ -23,3 +22,2 @@ acc.push(classes[key]); | ||
} | ||
return acc; | ||
@@ -26,0 +24,0 @@ }, []).join(' '); |
export { default } from './composeClasses'; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -14,3 +13,2 @@ value: true | ||
}); | ||
var _composeClasses = _interopRequireDefault(require("./composeClasses")); |
@@ -0,0 +0,0 @@ /** |
@@ -7,3 +7,2 @@ "use strict"; | ||
exports.default = createChainedFunction; | ||
/** | ||
@@ -20,3 +19,2 @@ * Safe chained function. | ||
} | ||
return function chainedFunction(...args) { | ||
@@ -23,0 +21,0 @@ acc.apply(this, args); |
@@ -7,3 +7,2 @@ "use strict"; | ||
exports.default = debounce; | ||
// Corresponds to 10 frames at 60 Hz. | ||
@@ -13,3 +12,2 @@ // A few bytes payload overhead when lodash/debounce is ~3 kB and debounce ~300 B. | ||
let timeout; | ||
function debounced(...args) { | ||
@@ -19,12 +17,9 @@ const later = () => { | ||
}; | ||
clearTimeout(timeout); | ||
timeout = setTimeout(later, wait); | ||
} | ||
debounced.clear = () => { | ||
clearTimeout(timeout); | ||
}; | ||
return debounced; | ||
} |
@@ -0,0 +0,0 @@ export declare function isPlainObject(item: unknown): item is Record<keyof any, unknown>; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -10,9 +9,6 @@ value: true | ||
exports.isPlainObject = isPlainObject; | ||
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); | ||
function isPlainObject(item) { | ||
return item !== null && typeof item === 'object' && item.constructor === Object; | ||
} | ||
function deepmerge(target, source, options = { | ||
@@ -22,3 +18,2 @@ clone: true | ||
const output = options.clone ? (0, _extends2.default)({}, target) : target; | ||
if (isPlainObject(target) && isPlainObject(source)) { | ||
@@ -30,3 +25,2 @@ Object.keys(source).forEach(key => { | ||
} | ||
if (isPlainObject(source[key]) && key in target && isPlainObject(target[key])) { | ||
@@ -40,4 +34,3 @@ // Since `output` is a clone of `target` and we have narrowed `target` in this block we can cast to the same type. | ||
} | ||
return output; | ||
} |
@@ -7,3 +7,2 @@ "use strict"; | ||
exports.default = deprecatedPropType; | ||
function deprecatedPropType(validator, reason) { | ||
@@ -13,13 +12,10 @@ if (process.env.NODE_ENV === 'production') { | ||
} | ||
return (props, propName, componentName, location, propFullName) => { | ||
const componentNameSafe = componentName || '<<anonymous>>'; | ||
const propFullNameSafe = propFullName || propName; | ||
if (typeof props[propName] !== 'undefined') { | ||
return new Error(`The ${location} \`${propFullNameSafe}\` of ` + `\`${componentNameSafe}\` is deprecated. ${reason}`); | ||
} | ||
return null; | ||
}; | ||
} |
import PropTypes from 'prop-types'; | ||
declare const elementAcceptingRef: PropTypes.Requireable<unknown>; | ||
export default elementAcceptingRef; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -9,7 +8,4 @@ value: true | ||
exports.default = void 0; | ||
var _propTypes = _interopRequireDefault(require("prop-types")); | ||
var _chainPropTypes = _interopRequireDefault(require("./chainPropTypes")); | ||
function isClassComponent(elementType) { | ||
@@ -22,8 +18,7 @@ // elementType.prototype?.isReactComponent | ||
} | ||
function acceptingRef(props, propName, componentName, location, propFullName) { | ||
const element = props[propName]; | ||
const safePropName = propFullName || propName; | ||
if (element == null || // When server-side rendering React doesn't warn either. | ||
if (element == null || | ||
// When server-side rendering React doesn't warn either. | ||
// This is not an accurate check for SSR. | ||
@@ -35,3 +30,2 @@ // This is only in place for Emotion compat. | ||
} | ||
let warningHint; | ||
@@ -48,14 +42,10 @@ const elementType = element.type; | ||
*/ | ||
if (typeof elementType === 'function' && !isClassComponent(elementType)) { | ||
warningHint = 'Did you accidentally use a plain function component for an element instead?'; | ||
} | ||
if (warningHint !== undefined) { | ||
return new Error(`Invalid ${location} \`${safePropName}\` supplied to \`${componentName}\`. ` + `Expected an element that can hold a ref. ${warningHint} ` + 'For more information see https://mui.com/r/caveat-with-refs-guide'); | ||
} | ||
return null; | ||
} | ||
const elementAcceptingRef = (0, _chainPropTypes.default)(_propTypes.default.element, acceptingRef); | ||
@@ -62,0 +52,0 @@ elementAcceptingRef.isRequired = (0, _chainPropTypes.default)(_propTypes.default.element.isRequired, acceptingRef); |
import PropTypes from 'prop-types'; | ||
declare const _default: PropTypes.Validator<PropTypes.ReactComponentLike | null | undefined>; | ||
export default _default; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -9,7 +8,4 @@ value: true | ||
exports.default = void 0; | ||
var _propTypes = _interopRequireDefault(require("prop-types")); | ||
var _chainPropTypes = _interopRequireDefault(require("./chainPropTypes")); | ||
function isClassComponent(elementType) { | ||
@@ -22,8 +18,7 @@ // elementType.prototype?.isReactComponent | ||
} | ||
function elementTypeAcceptingRef(props, propName, componentName, location, propFullName) { | ||
const propValue = props[propName]; | ||
const safePropName = propFullName || propName; | ||
if (propValue == null || // When server-side rendering React doesn't warn either. | ||
if (propValue == null || | ||
// When server-side rendering React doesn't warn either. | ||
// This is not an accurate check for SSR. | ||
@@ -35,4 +30,4 @@ // This is only in place for emotion compat. | ||
} | ||
let warningHint; | ||
let warningHint; | ||
/** | ||
@@ -47,16 +42,11 @@ * Blacklisting instead of whitelisting | ||
*/ | ||
if (typeof propValue === 'function' && !isClassComponent(propValue)) { | ||
warningHint = 'Did you accidentally provide a plain function component instead?'; | ||
} | ||
if (warningHint !== undefined) { | ||
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'); | ||
} | ||
return null; | ||
} | ||
var _default = (0, _chainPropTypes.default)(_propTypes.default.elementType, elementTypeAcceptingRef); | ||
exports.default = _default; |
@@ -10,4 +10,3 @@ import _formatMuiErrorMessage from "./formatMuiErrorMessage"; | ||
} | ||
return string.charAt(0).toUpperCase() + string.slice(1); | ||
} |
@@ -5,3 +5,2 @@ export default function chainPropTypes(propType1, propType2) { | ||
} | ||
return function validate(...args) { | ||
@@ -8,0 +7,0 @@ return propType1(...args) || propType2(...args); |
const defaultGenerator = componentName => componentName; | ||
const createClassNameGenerator = () => { | ||
@@ -9,15 +8,11 @@ let generate = defaultGenerator; | ||
}, | ||
generate(componentName) { | ||
return generate(componentName); | ||
}, | ||
reset() { | ||
generate = defaultGenerator; | ||
} | ||
}; | ||
}; | ||
const ClassNameGenerator = createClassNameGenerator(); | ||
export default ClassNameGenerator; |
export default function composeClasses(slots, getUtilityClass, classes) { | ||
const output = {}; | ||
Object.keys(slots).forEach( // `Objet.keys(slots)` can't be wider than `T` because we infer `T` from `slots`. | ||
Object.keys(slots).forEach( | ||
// `Objet.keys(slots)` can't be wider than `T` because we infer `T` from `slots`. | ||
// @ts-expect-error https://github.com/microsoft/TypeScript/pull/12253#issuecomment-263132208 | ||
@@ -9,3 +10,2 @@ slot => { | ||
acc.push(getUtilityClass(key)); | ||
if (classes && classes[key]) { | ||
@@ -15,3 +15,2 @@ acc.push(classes[key]); | ||
} | ||
return acc; | ||
@@ -18,0 +17,0 @@ }, []).join(' '); |
@@ -12,3 +12,2 @@ /** | ||
} | ||
return function chainedFunction(...args) { | ||
@@ -15,0 +14,0 @@ acc.apply(this, args); |
@@ -5,3 +5,2 @@ // Corresponds to 10 frames at 60 Hz. | ||
let timeout; | ||
function debounced(...args) { | ||
@@ -11,12 +10,9 @@ const later = () => { | ||
}; | ||
clearTimeout(timeout); | ||
timeout = setTimeout(later, wait); | ||
} | ||
debounced.clear = () => { | ||
clearTimeout(timeout); | ||
}; | ||
return debounced; | ||
} |
@@ -9,3 +9,2 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
const output = options.clone ? _extends({}, target) : target; | ||
if (isPlainObject(target) && isPlainObject(source)) { | ||
@@ -17,3 +16,2 @@ Object.keys(source).forEach(key => { | ||
} | ||
if (isPlainObject(source[key]) && key in target && isPlainObject(target[key])) { | ||
@@ -27,4 +25,3 @@ // Since `output` is a clone of `target` and we have narrowed `target` in this block we can cast to the same type. | ||
} | ||
return output; | ||
} |
@@ -5,13 +5,10 @@ export default function deprecatedPropType(validator, reason) { | ||
} | ||
return (props, propName, componentName, location, propFullName) => { | ||
const componentNameSafe = componentName || '<<anonymous>>'; | ||
const propFullNameSafe = propFullName || propName; | ||
if (typeof props[propName] !== 'undefined') { | ||
return new Error(`The ${location} \`${propFullNameSafe}\` of ` + `\`${componentNameSafe}\` is deprecated. ${reason}`); | ||
} | ||
return null; | ||
}; | ||
} |
import PropTypes from 'prop-types'; | ||
import chainPropTypes from './chainPropTypes'; | ||
function isClassComponent(elementType) { | ||
@@ -11,8 +10,7 @@ // elementType.prototype?.isReactComponent | ||
} | ||
function acceptingRef(props, propName, componentName, location, propFullName) { | ||
const element = props[propName]; | ||
const safePropName = propFullName || propName; | ||
if (element == null || // When server-side rendering React doesn't warn either. | ||
if (element == null || | ||
// When server-side rendering React doesn't warn either. | ||
// This is not an accurate check for SSR. | ||
@@ -24,3 +22,2 @@ // This is only in place for Emotion compat. | ||
} | ||
let warningHint; | ||
@@ -37,16 +34,12 @@ const elementType = element.type; | ||
*/ | ||
if (typeof elementType === 'function' && !isClassComponent(elementType)) { | ||
warningHint = 'Did you accidentally use a plain function component for an element instead?'; | ||
} | ||
if (warningHint !== undefined) { | ||
return new Error(`Invalid ${location} \`${safePropName}\` supplied to \`${componentName}\`. ` + `Expected an element that can hold a ref. ${warningHint} ` + 'For more information see https://mui.com/r/caveat-with-refs-guide'); | ||
} | ||
return null; | ||
} | ||
const elementAcceptingRef = chainPropTypes(PropTypes.element, acceptingRef); | ||
elementAcceptingRef.isRequired = chainPropTypes(PropTypes.element.isRequired, acceptingRef); | ||
export default elementAcceptingRef; |
import PropTypes from 'prop-types'; | ||
import chainPropTypes from './chainPropTypes'; | ||
function isClassComponent(elementType) { | ||
@@ -11,8 +10,7 @@ // elementType.prototype?.isReactComponent | ||
} | ||
function elementTypeAcceptingRef(props, propName, componentName, location, propFullName) { | ||
const propValue = props[propName]; | ||
const safePropName = propFullName || propName; | ||
if (propValue == null || // When server-side rendering React doesn't warn either. | ||
if (propValue == null || | ||
// When server-side rendering React doesn't warn either. | ||
// This is not an accurate check for SSR. | ||
@@ -24,4 +22,4 @@ // This is only in place for emotion compat. | ||
} | ||
let warningHint; | ||
let warningHint; | ||
/** | ||
@@ -36,14 +34,10 @@ * Blacklisting instead of whitelisting | ||
*/ | ||
if (typeof propValue === 'function' && !isClassComponent(propValue)) { | ||
warningHint = 'Did you accidentally provide a plain function component instead?'; | ||
} | ||
if (warningHint !== undefined) { | ||
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'); | ||
} | ||
return null; | ||
} | ||
export default chainPropTypes(PropTypes.elementType, elementTypeAcceptingRef); |
@@ -5,2 +5,3 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
// the module was forked. | ||
const specialProperty = 'exact-prop: \u200b'; | ||
@@ -11,11 +12,8 @@ export default function exactProp(propTypes) { | ||
} | ||
return _extends({}, propTypes, { | ||
[specialProperty]: props => { | ||
const unsupportedProps = Object.keys(props).filter(prop => !propTypes.hasOwnProperty(prop)); | ||
if (unsupportedProps.length > 0) { | ||
return new Error(`The following props are not supported: ${unsupportedProps.map(prop => `\`${prop}\``).join(', ')}. Please remove them.`); | ||
} | ||
return null; | ||
@@ -22,0 +20,0 @@ } |
@@ -10,6 +10,4 @@ /** | ||
// see https://babeljs.io/docs/en/babel-plugin-transform-template-literals#loose | ||
/* eslint-disable prefer-template */ | ||
let url = 'https://mui.com/production-error/?code=' + code; | ||
for (let i = 1; i < arguments.length; i += 1) { | ||
@@ -20,5 +18,4 @@ // rest params over-transpile for this case | ||
} | ||
return 'Minified MUI error #' + code + '; visit ' + url + ' for the full message.'; | ||
/* eslint-enable prefer-template */ | ||
} |
@@ -1,4 +0,5 @@ | ||
import { ForwardRef, Memo } from 'react-is'; // Simplified polyfill for IE11 support | ||
import { ForwardRef, Memo } from 'react-is'; | ||
// Simplified polyfill for IE11 support | ||
// https://github.com/JamesMGreene/Function.name/blob/58b314d4a983110c3682f1228f845d39ccca1817/Function.name.js#L3 | ||
const fnNameMatchRegex = /^\s*function(?:\s|\s*\/\*.*\*\/\s*)+([^(\s/]*)\s*/; | ||
@@ -10,7 +11,5 @@ export function getFunctionName(fn) { | ||
} | ||
function getFunctionComponentName(Component, fallback = '') { | ||
return Component.displayName || Component.name || getFunctionName(Component) || fallback; | ||
} | ||
function getWrappedName(outerType, innerType, wrapperName) { | ||
@@ -20,2 +19,3 @@ const functionName = getFunctionComponentName(innerType); | ||
} | ||
/** | ||
@@ -26,4 +26,2 @@ * cherry-pick from | ||
*/ | ||
export default function getDisplayName(Component) { | ||
@@ -33,12 +31,10 @@ if (Component == null) { | ||
} | ||
if (typeof Component === 'string') { | ||
return Component; | ||
} | ||
if (typeof Component === 'function') { | ||
return getFunctionComponentName(Component, 'Component'); | ||
} // TypeScript can't have components as objects but they exist in the form of `memo` or `Suspense` | ||
} | ||
// TypeScript can't have components as objects but they exist in the form of `memo` or `Suspense` | ||
if (typeof Component === 'object') { | ||
@@ -48,6 +44,4 @@ switch (Component.$$typeof) { | ||
return getWrappedName(Component, Component.render, 'ForwardRef'); | ||
case Memo: | ||
return getWrappedName(Component, Component.type, 'memo'); | ||
default: | ||
@@ -57,4 +51,3 @@ return undefined; | ||
} | ||
return undefined; | ||
} |
@@ -5,15 +5,11 @@ export default function HTMLElementType(props, propName, componentName, location, propFullName) { | ||
} | ||
const propValue = props[propName]; | ||
const safePropName = propFullName || propName; | ||
if (propValue == null) { | ||
return null; | ||
} | ||
if (propValue && propValue.nodeType !== 1) { | ||
return new Error(`Invalid ${location} \`${safePropName}\` supplied to \`${componentName}\`. ` + `Expected an HTMLElement.`); | ||
} | ||
return null; | ||
} |
export function getTypeByValue(value) { | ||
const valueType = typeof value; | ||
switch (valueType) { | ||
@@ -9,13 +8,9 @@ case 'number': | ||
} | ||
if (!Number.isFinite(value)) { | ||
return 'Infinity'; | ||
} | ||
if (value !== Math.floor(value)) { | ||
return 'float'; | ||
} | ||
return 'number'; | ||
case 'object': | ||
@@ -25,10 +20,9 @@ if (value === null) { | ||
} | ||
return value.constructor.name; | ||
default: | ||
return valueType; | ||
} | ||
} // IE 11 support | ||
} | ||
// IE 11 support | ||
function ponyfillIsInteger(x) { | ||
@@ -38,8 +32,5 @@ // eslint-disable-next-line no-restricted-globals | ||
} | ||
const isInteger = Number.isInteger || ponyfillIsInteger; | ||
function requiredInteger(props, propName, componentName, location) { | ||
const propValue = props[propName]; | ||
if (propValue == null || !isInteger(propValue)) { | ||
@@ -49,22 +40,16 @@ const propType = getTypeByValue(propValue); | ||
} | ||
return null; | ||
} | ||
function validator(props, propName, ...other) { | ||
const propValue = props[propName]; | ||
if (propValue === undefined) { | ||
return null; | ||
} | ||
return requiredInteger(props, propName, ...other); | ||
} | ||
function validatorNoop() { | ||
return null; | ||
} | ||
validator.isRequired = requiredInteger; | ||
validatorNoop.isRequired = validatorNoop; | ||
export default process.env.NODE_ENV === 'production' ? validatorNoop : validator; |
@@ -5,14 +5,11 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
return () => null; | ||
} // eslint-disable-next-line react/forbid-foreign-prop-types | ||
} | ||
// eslint-disable-next-line react/forbid-foreign-prop-types | ||
const prevPropTypes = Component ? _extends({}, Component.propTypes) : null; | ||
const requireProp = requiredProp => (props, propName, componentName, location, propFullName, ...args) => { | ||
const propFullNameSafe = propFullName || propName; | ||
const defaultTypeChecker = prevPropTypes == null ? void 0 : prevPropTypes[propFullNameSafe]; | ||
if (defaultTypeChecker) { | ||
const typeCheckerResult = defaultTypeChecker(props, propName, componentName, location, propFullName, ...args); | ||
if (typeCheckerResult) { | ||
@@ -22,11 +19,8 @@ return typeCheckerResult; | ||
} | ||
if (typeof props[propName] !== 'undefined' && !props[requiredProp]) { | ||
return new Error(`The prop \`${propFullNameSafe}\` of ` + `\`${componentNameInError}\` can only be used together with the \`${requiredProp}\` prop.`); | ||
} | ||
return null; | ||
}; | ||
return requireProp; | ||
} |
import _extends from "@babel/runtime/helpers/esm/extends"; | ||
/** | ||
@@ -11,3 +10,2 @@ * Add keys, values of `defaultProps` that does not exist in `props` | ||
const output = _extends({}, props); | ||
Object.keys(defaultProps).forEach(propName => { | ||
@@ -14,0 +12,0 @@ if (output[propName] === undefined) { |
// Source from https://github.com/alitaheri/normalize-scroll-left | ||
let cachedType; | ||
/** | ||
@@ -22,3 +23,2 @@ * Based on the jquery plugin https://github.com/othree/jquery.rtl-scroll-type | ||
*/ | ||
export function detectScrollType() { | ||
@@ -28,3 +28,2 @@ if (cachedType) { | ||
} | ||
const dummy = document.createElement('div'); | ||
@@ -44,3 +43,2 @@ const container = document.createElement('div'); | ||
cachedType = 'reverse'; | ||
if (dummy.scrollLeft > 0) { | ||
@@ -50,3 +48,2 @@ cachedType = 'default'; | ||
dummy.scrollLeft = 1; | ||
if (dummy.scrollLeft === 0) { | ||
@@ -56,23 +53,20 @@ cachedType = 'negative'; | ||
} | ||
document.body.removeChild(dummy); | ||
return cachedType; | ||
} // Based on https://stackoverflow.com/a/24394376 | ||
} | ||
// Based on https://stackoverflow.com/a/24394376 | ||
export function getNormalizedScrollLeft(element, direction) { | ||
const scrollLeft = element.scrollLeft; // Perform the calculations only when direction is rtl to avoid messing up the ltr behavior | ||
const scrollLeft = element.scrollLeft; | ||
// Perform the calculations only when direction is rtl to avoid messing up the ltr behavior | ||
if (direction !== 'rtl') { | ||
return scrollLeft; | ||
} | ||
const type = detectScrollType(); | ||
switch (type) { | ||
case 'negative': | ||
return element.scrollWidth - element.clientWidth + scrollLeft; | ||
case 'reverse': | ||
return element.scrollWidth - element.clientWidth - scrollLeft; | ||
default: | ||
@@ -79,0 +73,0 @@ return scrollLeft; |
@@ -5,10 +5,7 @@ export default function unsupportedProp(props, propName, componentName, location, propFullName) { | ||
} | ||
const propFullNameSafe = propFullName || propName; | ||
if (typeof props[propName] !== 'undefined') { | ||
return new Error(`The prop \`${propFullNameSafe}\` is not supported. Please remove it.`); | ||
} | ||
return null; | ||
} |
@@ -15,3 +15,2 @@ /* eslint-disable react-hooks/rules-of-hooks, react-hooks/exhaustive-deps */ | ||
const value = isControlled ? controlled : valueState; | ||
if (process.env.NODE_ENV !== 'production') { | ||
@@ -32,3 +31,2 @@ React.useEffect(() => { | ||
} | ||
const setValueIfUncontrolled = React.useCallback(newValue => { | ||
@@ -35,0 +33,0 @@ if (!isControlled) { |
import * as React from 'react'; | ||
import useEnhancedEffect from './useEnhancedEffect'; | ||
/** | ||
* https://github.com/facebook/react/issues/14099#issuecomment-440013892 | ||
*/ | ||
export default function useEventCallback(fn) { | ||
@@ -12,5 +12,6 @@ const ref = React.useRef(fn); | ||
}); | ||
return React.useCallback((...args) => // @ts-expect-error hide `this` | ||
return React.useCallback((...args) => | ||
// @ts-expect-error hide `this` | ||
// tslint:disable-next-line:ban-comma-operator | ||
(0, ref.current)(...args), []); | ||
} |
@@ -13,3 +13,2 @@ import * as React from 'react'; | ||
} | ||
return instance => { | ||
@@ -19,4 +18,5 @@ refs.forEach(ref => { | ||
}); | ||
}; // eslint-disable-next-line react-hooks/exhaustive-deps | ||
}; | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, refs); | ||
} |
import * as React from 'react'; | ||
let globalId = 0; | ||
function useGlobalId(idOverride) { | ||
@@ -18,5 +17,5 @@ const [defaultId, setDefaultId] = React.useState(idOverride); | ||
return id; | ||
} // eslint-disable-next-line no-useless-concat -- Workaround for https://github.com/webpack/webpack/issues/14814 | ||
} | ||
// eslint-disable-next-line no-useless-concat -- Workaround for https://github.com/webpack/webpack/issues/14814 | ||
const maybeReactUseId = React['useId' + '']; | ||
@@ -29,3 +28,2 @@ /** | ||
*/ | ||
export default function useId(idOverride) { | ||
@@ -35,6 +33,5 @@ if (maybeReactUseId !== undefined) { | ||
return idOverride != null ? idOverride : reactId; | ||
} // eslint-disable-next-line react-hooks/rules-of-hooks -- `React.useId` is invariant at runtime. | ||
} | ||
// eslint-disable-next-line react-hooks/rules-of-hooks -- `React.useId` is invariant at runtime. | ||
return useGlobalId(idOverride); | ||
} |
@@ -21,2 +21,3 @@ // based on https://github.com/WICG/focus-visible/blob/v4.1.5/src/focus-visible.js | ||
}; | ||
/** | ||
@@ -29,3 +30,2 @@ * Computes whether the given element should automatically trigger the | ||
*/ | ||
function focusTriggersKeyboardModality(node) { | ||
@@ -36,17 +36,14 @@ const { | ||
} = node; | ||
if (tagName === 'INPUT' && inputTypesWhitelist[type] && !node.readOnly) { | ||
return true; | ||
} | ||
if (tagName === 'TEXTAREA' && !node.readOnly) { | ||
return true; | ||
} | ||
if (node.isContentEditable) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
/** | ||
@@ -59,4 +56,2 @@ * Keep track of our keyboard modality state with `hadKeyboardEvent`. | ||
*/ | ||
function handleKeyDown(event) { | ||
@@ -66,5 +61,5 @@ if (event.metaKey || event.altKey || event.ctrlKey) { | ||
} | ||
hadKeyboardEvent = true; | ||
} | ||
/** | ||
@@ -77,8 +72,5 @@ * If at any point a user clicks with a pointing device, ensure that we change | ||
*/ | ||
function handlePointerDown() { | ||
hadKeyboardEvent = false; | ||
} | ||
function handleVisibilityChange() { | ||
@@ -95,3 +87,2 @@ if (this.visibilityState === 'hidden') { | ||
} | ||
function prepare(doc) { | ||
@@ -104,3 +95,2 @@ doc.addEventListener('keydown', handleKeyDown, true); | ||
} | ||
export function teardown(doc) { | ||
@@ -113,3 +103,2 @@ doc.removeEventListener('keydown', handleKeyDown, true); | ||
} | ||
function isFocusVisible(event) { | ||
@@ -119,16 +108,15 @@ const { | ||
} = event; | ||
try { | ||
return target.matches(':focus-visible'); | ||
} catch (error) {// Browsers not implementing :focus-visible will throw a SyntaxError. | ||
} catch (error) { | ||
// Browsers not implementing :focus-visible will throw a SyntaxError. | ||
// We use our own heuristic for those browsers. | ||
// Rethrow might be better if it's not the expected error but do we really | ||
// want to crash if focus-visible malfunctioned? | ||
} // No need for validFocusTarget check. The user does that by attaching it to | ||
} | ||
// No need for validFocusTarget check. The user does that by attaching it to | ||
// focusable events only. | ||
return hadKeyboardEvent || focusTriggersKeyboardModality(target); | ||
} | ||
export default function useIsFocusVisible() { | ||
@@ -141,6 +129,6 @@ const ref = React.useCallback(node => { | ||
const isFocusVisibleRef = React.useRef(false); | ||
/** | ||
* Should be called if a blur event is fired | ||
*/ | ||
function handleBlurVisible() { | ||
@@ -165,10 +153,8 @@ // checking against potential state variable does not suffice if we focus and blur synchronously. | ||
} | ||
return false; | ||
} | ||
/** | ||
* Should be called if a blur event is fired | ||
*/ | ||
function handleFocusVisible(event) { | ||
@@ -179,6 +165,4 @@ if (isFocusVisible(event)) { | ||
} | ||
return false; | ||
} | ||
return { | ||
@@ -185,0 +169,0 @@ isFocusVisibleRef, |
import * as React from 'react'; | ||
const usePreviousProps = value => { | ||
@@ -10,3 +9,2 @@ const ref = React.useRef({}); | ||
}; | ||
export default usePreviousProps; |
import { ValidationMap } from 'prop-types'; | ||
export default function exactProp<T>(propTypes: ValidationMap<T>): ValidationMap<T>; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -9,10 +8,8 @@ value: true | ||
exports.default = exactProp; | ||
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); | ||
// This module is based on https://github.com/airbnb/prop-types-exact repository. | ||
// However, in order to reduce the number of dependencies and to remove some extra safe checks | ||
// the module was forked. | ||
const specialProperty = 'exact-prop: \u200b'; | ||
function exactProp(propTypes) { | ||
@@ -22,11 +19,8 @@ if (process.env.NODE_ENV === 'production') { | ||
} | ||
return (0, _extends2.default)({}, propTypes, { | ||
[specialProperty]: props => { | ||
const unsupportedProps = Object.keys(props).filter(prop => !propTypes.hasOwnProperty(prop)); | ||
if (unsupportedProps.length > 0) { | ||
return new Error(`The following props are not supported: ${unsupportedProps.map(prop => `\`${prop}\``).join(', ')}. Please remove them.`); | ||
} | ||
return null; | ||
@@ -33,0 +27,0 @@ } |
@@ -0,0 +0,0 @@ /** |
@@ -7,3 +7,2 @@ "use strict"; | ||
exports.default = formatMuiErrorMessage; | ||
/** | ||
@@ -18,6 +17,4 @@ * WARNING: Don't import this directly. | ||
// see https://babeljs.io/docs/en/babel-plugin-transform-template-literals#loose | ||
/* eslint-disable prefer-template */ | ||
let url = 'https://mui.com/production-error/?code=' + code; | ||
for (let i = 1; i < arguments.length; i += 1) { | ||
@@ -28,5 +25,4 @@ // rest params over-transpile for this case | ||
} | ||
return 'Minified MUI error #' + code + '; visit ' + url + ' for the full message.'; | ||
/* eslint-enable prefer-template */ | ||
} |
export declare type GlobalStateSlot = 'active' | 'checked' | 'completed' | 'disabled' | 'error' | 'expanded' | 'focused' | 'focusVisible' | 'required' | 'selected'; | ||
export default function generateUtilityClass(componentName: string, slot: string, globalStatePrefix?: string): string; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -9,5 +8,3 @@ value: true | ||
exports.default = generateUtilityClass; | ||
var _ClassNameGenerator = _interopRequireDefault(require("../ClassNameGenerator")); | ||
const globalStateClassesMapping = { | ||
@@ -25,3 +22,2 @@ active: 'active', | ||
}; | ||
function generateUtilityClass(componentName, slot, globalStatePrefix = 'Mui') { | ||
@@ -28,0 +24,0 @@ const globalStateClass = globalStateClassesMapping[slot]; |
export { default } from './generateUtilityClass'; | ||
export * from './generateUtilityClass'; |
@@ -13,5 +13,3 @@ "use strict"; | ||
}); | ||
var _generateUtilityClass = _interopRequireWildcard(require("./generateUtilityClass")); | ||
Object.keys(_generateUtilityClass).forEach(function (key) { | ||
@@ -28,5 +26,3 @@ if (key === "default" || key === "__esModule") return; | ||
}); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } |
export default function generateUtilityClasses<T extends string>(componentName: string, slots: T[], globalStatePrefix?: string): Record<T, string>; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -9,5 +8,3 @@ value: true | ||
exports.default = generateUtilityClasses; | ||
var _generateUtilityClass = _interopRequireDefault(require("../generateUtilityClass")); | ||
function generateUtilityClasses(componentName, slots, globalStatePrefix = 'Mui') { | ||
@@ -14,0 +11,0 @@ const result = {}; |
export { default } from './generateUtilityClasses'; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -14,3 +13,2 @@ value: true | ||
}); | ||
var _generateUtilityClasses = _interopRequireDefault(require("./generateUtilityClasses")); |
@@ -0,0 +0,0 @@ import * as React from 'react'; |
@@ -8,9 +8,6 @@ "use strict"; | ||
exports.getFunctionName = getFunctionName; | ||
var _reactIs = require("react-is"); | ||
// Simplified polyfill for IE11 support | ||
// https://github.com/JamesMGreene/Function.name/blob/58b314d4a983110c3682f1228f845d39ccca1817/Function.name.js#L3 | ||
const fnNameMatchRegex = /^\s*function(?:\s|\s*\/\*.*\*\/\s*)+([^(\s/]*)\s*/; | ||
function getFunctionName(fn) { | ||
@@ -21,7 +18,5 @@ const match = `${fn}`.match(fnNameMatchRegex); | ||
} | ||
function getFunctionComponentName(Component, fallback = '') { | ||
return Component.displayName || Component.name || getFunctionName(Component) || fallback; | ||
} | ||
function getWrappedName(outerType, innerType, wrapperName) { | ||
@@ -31,2 +26,3 @@ const functionName = getFunctionComponentName(innerType); | ||
} | ||
/** | ||
@@ -37,4 +33,2 @@ * cherry-pick from | ||
*/ | ||
function getDisplayName(Component) { | ||
@@ -44,12 +38,10 @@ if (Component == null) { | ||
} | ||
if (typeof Component === 'string') { | ||
return Component; | ||
} | ||
if (typeof Component === 'function') { | ||
return getFunctionComponentName(Component, 'Component'); | ||
} // TypeScript can't have components as objects but they exist in the form of `memo` or `Suspense` | ||
} | ||
// TypeScript can't have components as objects but they exist in the form of `memo` or `Suspense` | ||
if (typeof Component === 'object') { | ||
@@ -59,6 +51,4 @@ switch (Component.$$typeof) { | ||
return getWrappedName(Component, Component.render, 'ForwardRef'); | ||
case _reactIs.Memo: | ||
return getWrappedName(Component, Component.type, 'memo'); | ||
default: | ||
@@ -68,4 +58,3 @@ return undefined; | ||
} | ||
return undefined; | ||
} |
export default function getScrollbarSize(doc: Document): number; |
@@ -7,3 +7,2 @@ "use strict"; | ||
exports.default = getScrollbarSize; | ||
// A change of the browser zoom change the scrollbar size. | ||
@@ -10,0 +9,0 @@ // Credit https://github.com/twbs/bootstrap/blob/488fd8afc535ca3a6ad4dc581f5e89217b6a36ac/js/src/util/scrollbar.js#L14-L18 |
export default function HTMLElementType(props: { | ||
[key: string]: unknown; | ||
}, propName: string, componentName: string, location: string, propFullName: string): Error | null; |
@@ -7,3 +7,2 @@ "use strict"; | ||
exports.default = HTMLElementType; | ||
function HTMLElementType(props, propName, componentName, location, propFullName) { | ||
@@ -13,15 +12,11 @@ if (process.env.NODE_ENV === 'production') { | ||
} | ||
const propValue = props[propName]; | ||
const safePropName = propFullName || propName; | ||
if (propValue == null) { | ||
return null; | ||
} | ||
if (propValue && propValue.nodeType !== 1) { | ||
return new Error(`Invalid ${location} \`${safePropName}\` supplied to \`${componentName}\`. ` + `Expected an HTMLElement.`); | ||
} | ||
return null; | ||
} |
@@ -0,0 +0,0 @@ export { default as chainPropTypes } from './chainPropTypes'; |
42
index.js
@@ -1,2 +0,2 @@ | ||
/** @license MUI v5.10.9 | ||
/** @license MUI v5.10.14 | ||
* | ||
@@ -9,3 +9,2 @@ * This source code is licensed under the MIT license found in the | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -282,71 +281,36 @@ value: true | ||
}); | ||
var _chainPropTypes = _interopRequireDefault(require("./chainPropTypes")); | ||
var _deepmerge = _interopRequireWildcard(require("./deepmerge")); | ||
var _elementAcceptingRef = _interopRequireDefault(require("./elementAcceptingRef")); | ||
var _elementTypeAcceptingRef = _interopRequireDefault(require("./elementTypeAcceptingRef")); | ||
var _exactProp = _interopRequireDefault(require("./exactProp")); | ||
var _formatMuiErrorMessage = _interopRequireDefault(require("./formatMuiErrorMessage")); | ||
var _getDisplayName = _interopRequireDefault(require("./getDisplayName")); | ||
var _HTMLElementType = _interopRequireDefault(require("./HTMLElementType")); | ||
var _ponyfillGlobal = _interopRequireDefault(require("./ponyfillGlobal")); | ||
var _refType = _interopRequireDefault(require("./refType")); | ||
var _capitalize = _interopRequireDefault(require("./capitalize")); | ||
var _createChainedFunction = _interopRequireDefault(require("./createChainedFunction")); | ||
var _debounce = _interopRequireDefault(require("./debounce")); | ||
var _deprecatedPropType = _interopRequireDefault(require("./deprecatedPropType")); | ||
var _isMuiElement = _interopRequireDefault(require("./isMuiElement")); | ||
var _ownerDocument = _interopRequireDefault(require("./ownerDocument")); | ||
var _ownerWindow = _interopRequireDefault(require("./ownerWindow")); | ||
var _requirePropFactory = _interopRequireDefault(require("./requirePropFactory")); | ||
var _setRef = _interopRequireDefault(require("./setRef")); | ||
var _useEnhancedEffect = _interopRequireDefault(require("./useEnhancedEffect")); | ||
var _useId = _interopRequireDefault(require("./useId")); | ||
var _unsupportedProp = _interopRequireDefault(require("./unsupportedProp")); | ||
var _useControlled = _interopRequireDefault(require("./useControlled")); | ||
var _useEventCallback = _interopRequireDefault(require("./useEventCallback")); | ||
var _useForkRef = _interopRequireDefault(require("./useForkRef")); | ||
var _useIsFocusVisible = _interopRequireDefault(require("./useIsFocusVisible")); | ||
var _getScrollbarSize = _interopRequireDefault(require("./getScrollbarSize")); | ||
var _scrollLeft = require("./scrollLeft"); | ||
var _usePreviousProps = _interopRequireDefault(require("./usePreviousProps")); | ||
var _visuallyHidden = _interopRequireDefault(require("./visuallyHidden")); | ||
var _integerPropType = _interopRequireDefault(require("./integerPropType")); | ||
var _resolveProps = _interopRequireDefault(require("./resolveProps")); | ||
var _composeClasses = _interopRequireDefault(require("./composeClasses")); | ||
var _generateUtilityClass = _interopRequireWildcard(require("./generateUtilityClass")); | ||
Object.keys(_generateUtilityClass).forEach(function (key) { | ||
@@ -363,9 +327,5 @@ if (key === "default" || key === "__esModule") return; | ||
}); | ||
var _generateUtilityClasses = _interopRequireDefault(require("./generateUtilityClasses")); | ||
var _ClassNameGenerator = _interopRequireDefault(require("./ClassNameGenerator")); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } |
@@ -0,0 +0,0 @@ export function getTypeByValue(value: any): any; |
@@ -8,6 +8,4 @@ "use strict"; | ||
exports.getTypeByValue = getTypeByValue; | ||
function getTypeByValue(value) { | ||
const valueType = typeof value; | ||
switch (valueType) { | ||
@@ -18,13 +16,9 @@ case 'number': | ||
} | ||
if (!Number.isFinite(value)) { | ||
return 'Infinity'; | ||
} | ||
if (value !== Math.floor(value)) { | ||
return 'float'; | ||
} | ||
return 'number'; | ||
case 'object': | ||
@@ -34,11 +28,9 @@ if (value === null) { | ||
} | ||
return value.constructor.name; | ||
default: | ||
return valueType; | ||
} | ||
} // IE 11 support | ||
} | ||
// IE 11 support | ||
function ponyfillIsInteger(x) { | ||
@@ -48,8 +40,5 @@ // eslint-disable-next-line no-restricted-globals | ||
} | ||
const isInteger = Number.isInteger || ponyfillIsInteger; | ||
function requiredInteger(props, propName, componentName, location) { | ||
const propValue = props[propName]; | ||
if (propValue == null || !isInteger(propValue)) { | ||
@@ -59,25 +48,17 @@ const propType = getTypeByValue(propValue); | ||
} | ||
return null; | ||
} | ||
function validator(props, propName, ...other) { | ||
const propValue = props[propName]; | ||
if (propValue === undefined) { | ||
return null; | ||
} | ||
return requiredInteger(props, propName, ...other); | ||
} | ||
function validatorNoop() { | ||
return null; | ||
} | ||
validator.isRequired = requiredInteger; | ||
validatorNoop.isRequired = validatorNoop; | ||
var _default = process.env.NODE_ENV === 'production' ? validatorNoop : validator; | ||
exports.default = _default; |
export default function isMuiElement(element: any, muiNames: readonly string[]): boolean; |
@@ -7,11 +7,7 @@ "use strict"; | ||
exports.default = isMuiElement; | ||
var React = _interopRequireWildcard(require("react")); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function isMuiElement(element, muiNames) { | ||
return /*#__PURE__*/React.isValidElement(element) && muiNames.indexOf(element.type.muiName) !== -1; | ||
} |
@@ -10,4 +10,3 @@ import _formatMuiErrorMessage from "./formatMuiErrorMessage"; | ||
} | ||
return string.charAt(0).toUpperCase() + string.slice(1); | ||
} |
@@ -7,3 +7,2 @@ export default function chainPropTypes(propType1, propType2) { | ||
} | ||
return function validate() { | ||
@@ -10,0 +9,0 @@ return propType1.apply(void 0, arguments) || propType2.apply(void 0, arguments); |
var defaultGenerator = function defaultGenerator(componentName) { | ||
return componentName; | ||
}; | ||
var createClassNameGenerator = function createClassNameGenerator() { | ||
@@ -19,4 +18,3 @@ var _generate = defaultGenerator; | ||
}; | ||
var ClassNameGenerator = createClassNameGenerator(); | ||
export default ClassNameGenerator; |
export default function composeClasses(slots, getUtilityClass, classes) { | ||
var output = {}; | ||
Object.keys(slots).forEach( // `Objet.keys(slots)` can't be wider than `T` because we infer `T` from `slots`. | ||
Object.keys(slots).forEach( | ||
// `Objet.keys(slots)` can't be wider than `T` because we infer `T` from `slots`. | ||
// @ts-expect-error https://github.com/microsoft/TypeScript/pull/12253#issuecomment-263132208 | ||
@@ -9,3 +10,2 @@ function (slot) { | ||
acc.push(getUtilityClass(key)); | ||
if (classes && classes[key]) { | ||
@@ -15,3 +15,2 @@ acc.push(classes[key]); | ||
} | ||
return acc; | ||
@@ -18,0 +17,0 @@ }, []).join(' '); |
@@ -11,3 +11,2 @@ /** | ||
} | ||
return funcs.reduce(function (acc, func) { | ||
@@ -17,3 +16,2 @@ if (func == null) { | ||
} | ||
return function chainedFunction() { | ||
@@ -23,3 +21,2 @@ for (var _len2 = arguments.length, args = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) { | ||
} | ||
acc.apply(this, args); | ||
@@ -26,0 +23,0 @@ func.apply(this, args); |
@@ -6,23 +6,17 @@ // Corresponds to 10 frames at 60 Hz. | ||
var timeout; | ||
function debounced() { | ||
var _this = this; | ||
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
var later = function later() { | ||
func.apply(_this, args); | ||
}; | ||
clearTimeout(timeout); | ||
timeout = setTimeout(later, wait); | ||
} | ||
debounced.clear = function () { | ||
clearTimeout(timeout); | ||
}; | ||
return debounced; | ||
} |
@@ -11,3 +11,2 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
var output = options.clone ? _extends({}, target) : target; | ||
if (isPlainObject(target) && isPlainObject(source)) { | ||
@@ -19,3 +18,2 @@ Object.keys(source).forEach(function (key) { | ||
} | ||
if (isPlainObject(source[key]) && key in target && isPlainObject(target[key])) { | ||
@@ -29,4 +27,3 @@ // Since `output` is a clone of `target` and we have narrowed `target` in this block we can cast to the same type. | ||
} | ||
return output; | ||
} |
@@ -7,13 +7,10 @@ export default function deprecatedPropType(validator, reason) { | ||
} | ||
return function (props, propName, componentName, location, propFullName) { | ||
var componentNameSafe = componentName || '<<anonymous>>'; | ||
var propFullNameSafe = propFullName || propName; | ||
if (typeof props[propName] !== 'undefined') { | ||
return new Error("The ".concat(location, " `").concat(propFullNameSafe, "` of ") + "`".concat(componentNameSafe, "` is deprecated. ").concat(reason)); | ||
} | ||
return null; | ||
}; | ||
} |
import PropTypes from 'prop-types'; | ||
import chainPropTypes from './chainPropTypes'; | ||
function isClassComponent(elementType) { | ||
// elementType.prototype?.isReactComponent | ||
var _elementType$prototyp = elementType.prototype, | ||
prototype = _elementType$prototyp === void 0 ? {} : _elementType$prototyp; | ||
prototype = _elementType$prototyp === void 0 ? {} : _elementType$prototyp; | ||
return Boolean(prototype.isReactComponent); | ||
} | ||
function acceptingRef(props, propName, componentName, location, propFullName) { | ||
var element = props[propName]; | ||
var safePropName = propFullName || propName; | ||
if (element == null || // When server-side rendering React doesn't warn either. | ||
if (element == null || | ||
// When server-side rendering React doesn't warn either. | ||
// This is not an accurate check for SSR. | ||
@@ -22,3 +20,2 @@ // This is only in place for Emotion compat. | ||
} | ||
var warningHint; | ||
@@ -35,16 +32,12 @@ var elementType = element.type; | ||
*/ | ||
if (typeof elementType === 'function' && !isClassComponent(elementType)) { | ||
warningHint = 'Did you accidentally use a plain function component for an element instead?'; | ||
} | ||
if (warningHint !== undefined) { | ||
return new Error("Invalid ".concat(location, " `").concat(safePropName, "` supplied to `").concat(componentName, "`. ") + "Expected an element that can hold a ref. ".concat(warningHint, " ") + 'For more information see https://mui.com/r/caveat-with-refs-guide'); | ||
} | ||
return null; | ||
} | ||
var elementAcceptingRef = chainPropTypes(PropTypes.element, acceptingRef); | ||
elementAcceptingRef.isRequired = chainPropTypes(PropTypes.element.isRequired, acceptingRef); | ||
export default elementAcceptingRef; |
import PropTypes from 'prop-types'; | ||
import chainPropTypes from './chainPropTypes'; | ||
function isClassComponent(elementType) { | ||
// elementType.prototype?.isReactComponent | ||
var _elementType$prototyp = elementType.prototype, | ||
prototype = _elementType$prototyp === void 0 ? {} : _elementType$prototyp; | ||
prototype = _elementType$prototyp === void 0 ? {} : _elementType$prototyp; | ||
return Boolean(prototype.isReactComponent); | ||
} | ||
function elementTypeAcceptingRef(props, propName, componentName, location, propFullName) { | ||
var propValue = props[propName]; | ||
var safePropName = propFullName || propName; | ||
if (propValue == null || // When server-side rendering React doesn't warn either. | ||
if (propValue == null || | ||
// When server-side rendering React doesn't warn either. | ||
// This is not an accurate check for SSR. | ||
@@ -22,4 +20,4 @@ // This is only in place for emotion compat. | ||
} | ||
var warningHint; | ||
var warningHint; | ||
/** | ||
@@ -34,14 +32,10 @@ * Blacklisting instead of whitelisting | ||
*/ | ||
if (typeof propValue === 'function' && !isClassComponent(propValue)) { | ||
warningHint = 'Did you accidentally provide a plain function component instead?'; | ||
} | ||
if (warningHint !== undefined) { | ||
return new Error("Invalid ".concat(location, " `").concat(safePropName, "` supplied to `").concat(componentName, "`. ") + "Expected an element type that can hold a ref. ".concat(warningHint, " ") + 'For more information see https://mui.com/r/caveat-with-refs-guide'); | ||
} | ||
return null; | ||
} | ||
export default chainPropTypes(PropTypes.elementType, elementTypeAcceptingRef); |
@@ -6,2 +6,3 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty"; | ||
// the module was forked. | ||
var specialProperty = "exact-prop: \u200B"; | ||
@@ -12,3 +13,2 @@ export default function exactProp(propTypes) { | ||
} | ||
return _extends({}, propTypes, _defineProperty({}, specialProperty, function (props) { | ||
@@ -18,3 +18,2 @@ var unsupportedProps = Object.keys(props).filter(function (prop) { | ||
}); | ||
if (unsupportedProps.length > 0) { | ||
@@ -25,5 +24,4 @@ return new Error("The following props are not supported: ".concat(unsupportedProps.map(function (prop) { | ||
} | ||
return null; | ||
})); | ||
} |
@@ -10,6 +10,4 @@ /** | ||
// see https://babeljs.io/docs/en/babel-plugin-transform-template-literals#loose | ||
/* eslint-disable prefer-template */ | ||
var url = 'https://mui.com/production-error/?code=' + code; | ||
for (var i = 1; i < arguments.length; i += 1) { | ||
@@ -20,5 +18,4 @@ // rest params over-transpile for this case | ||
} | ||
return 'Minified MUI error #' + code + '; visit ' + url + ' for the full message.'; | ||
/* eslint-enable prefer-template */ | ||
} |
import _typeof from "@babel/runtime/helpers/esm/typeof"; | ||
import { ForwardRef, Memo } from 'react-is'; // Simplified polyfill for IE11 support | ||
import { ForwardRef, Memo } from 'react-is'; | ||
// Simplified polyfill for IE11 support | ||
// https://github.com/JamesMGreene/Function.name/blob/58b314d4a983110c3682f1228f845d39ccca1817/Function.name.js#L3 | ||
var fnNameMatchRegex = /^\s*function(?:\s|\s*\/\*.*\*\/\s*)+([^(\s/]*)\s*/; | ||
@@ -11,3 +12,2 @@ export function getFunctionName(fn) { | ||
} | ||
function getFunctionComponentName(Component) { | ||
@@ -17,3 +17,2 @@ var fallback = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : ''; | ||
} | ||
function getWrappedName(outerType, innerType, wrapperName) { | ||
@@ -23,2 +22,3 @@ var functionName = getFunctionComponentName(innerType); | ||
} | ||
/** | ||
@@ -29,4 +29,2 @@ * cherry-pick from | ||
*/ | ||
export default function getDisplayName(Component) { | ||
@@ -36,12 +34,10 @@ if (Component == null) { | ||
} | ||
if (typeof Component === 'string') { | ||
return Component; | ||
} | ||
if (typeof Component === 'function') { | ||
return getFunctionComponentName(Component, 'Component'); | ||
} // TypeScript can't have components as objects but they exist in the form of `memo` or `Suspense` | ||
} | ||
// TypeScript can't have components as objects but they exist in the form of `memo` or `Suspense` | ||
if (_typeof(Component) === 'object') { | ||
@@ -51,6 +47,4 @@ switch (Component.$$typeof) { | ||
return getWrappedName(Component, Component.render, 'ForwardRef'); | ||
case Memo: | ||
return getWrappedName(Component, Component.type, 'memo'); | ||
default: | ||
@@ -60,4 +54,3 @@ return undefined; | ||
} | ||
return undefined; | ||
} |
@@ -5,15 +5,11 @@ export default function HTMLElementType(props, propName, componentName, location, propFullName) { | ||
} | ||
var propValue = props[propName]; | ||
var safePropName = propFullName || propName; | ||
if (propValue == null) { | ||
return null; | ||
} | ||
if (propValue && propValue.nodeType !== 1) { | ||
return new Error("Invalid ".concat(location, " `").concat(safePropName, "` supplied to `").concat(componentName, "`. ") + "Expected an HTMLElement."); | ||
} | ||
return null; | ||
} |
@@ -1,2 +0,2 @@ | ||
/** @license MUI v5.10.9 | ||
/** @license MUI v5.10.14 | ||
* | ||
@@ -3,0 +3,0 @@ * This source code is licensed under the MIT license found in the |
import _typeof from "@babel/runtime/helpers/esm/typeof"; | ||
export function getTypeByValue(value) { | ||
var valueType = _typeof(value); | ||
switch (valueType) { | ||
@@ -10,13 +9,9 @@ case 'number': | ||
} | ||
if (!Number.isFinite(value)) { | ||
return 'Infinity'; | ||
} | ||
if (value !== Math.floor(value)) { | ||
return 'float'; | ||
} | ||
return 'number'; | ||
case 'object': | ||
@@ -26,10 +21,9 @@ if (value === null) { | ||
} | ||
return value.constructor.name; | ||
default: | ||
return valueType; | ||
} | ||
} // IE 11 support | ||
} | ||
// IE 11 support | ||
function ponyfillIsInteger(x) { | ||
@@ -39,8 +33,5 @@ // eslint-disable-next-line no-restricted-globals | ||
} | ||
var isInteger = Number.isInteger || ponyfillIsInteger; | ||
function requiredInteger(props, propName, componentName, location) { | ||
var propValue = props[propName]; | ||
if (propValue == null || !isInteger(propValue)) { | ||
@@ -50,26 +41,19 @@ var propType = getTypeByValue(propValue); | ||
} | ||
return null; | ||
} | ||
function validator(props, propName) { | ||
var propValue = props[propName]; | ||
if (propValue === undefined) { | ||
return null; | ||
} | ||
for (var _len = arguments.length, other = new Array(_len > 2 ? _len - 2 : 0), _key = 2; _key < _len; _key++) { | ||
other[_key - 2] = arguments[_key]; | ||
} | ||
return requiredInteger.apply(void 0, [props, propName].concat(other)); | ||
} | ||
function validatorNoop() { | ||
return null; | ||
} | ||
validator.isRequired = requiredInteger; | ||
validatorNoop.isRequired = validatorNoop; | ||
export default process.env.NODE_ENV === 'production' ? validatorNoop : validator; |
@@ -7,7 +7,6 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
}; | ||
} // eslint-disable-next-line react/forbid-foreign-prop-types | ||
} | ||
// eslint-disable-next-line react/forbid-foreign-prop-types | ||
var prevPropTypes = Component ? _extends({}, Component.propTypes) : null; | ||
var requireProp = function requireProp(requiredProp) { | ||
@@ -17,3 +16,2 @@ return function (props, propName, componentName, location, propFullName) { | ||
var defaultTypeChecker = prevPropTypes == null ? void 0 : prevPropTypes[propFullNameSafe]; | ||
if (defaultTypeChecker) { | ||
@@ -23,5 +21,3 @@ for (var _len = arguments.length, args = new Array(_len > 5 ? _len - 5 : 0), _key = 5; _key < _len; _key++) { | ||
} | ||
var typeCheckerResult = defaultTypeChecker.apply(void 0, [props, propName, componentName, location, propFullName].concat(args)); | ||
if (typeCheckerResult) { | ||
@@ -31,12 +27,9 @@ return typeCheckerResult; | ||
} | ||
if (typeof props[propName] !== 'undefined' && !props[requiredProp]) { | ||
return new Error("The prop `".concat(propFullNameSafe, "` of ") + "`".concat(componentNameInError, "` can only be used together with the `").concat(requiredProp, "` prop.")); | ||
} | ||
return null; | ||
}; | ||
}; | ||
return requireProp; | ||
} |
import _extends from "@babel/runtime/helpers/esm/extends"; | ||
/** | ||
@@ -11,3 +10,2 @@ * Add keys, values of `defaultProps` that does not exist in `props` | ||
var output = _extends({}, props); | ||
Object.keys(defaultProps).forEach(function (propName) { | ||
@@ -14,0 +12,0 @@ if (output[propName] === undefined) { |
// Source from https://github.com/alitaheri/normalize-scroll-left | ||
var cachedType; | ||
/** | ||
@@ -22,3 +23,2 @@ * Based on the jquery plugin https://github.com/othree/jquery.rtl-scroll-type | ||
*/ | ||
export function detectScrollType() { | ||
@@ -28,3 +28,2 @@ if (cachedType) { | ||
} | ||
var dummy = document.createElement('div'); | ||
@@ -44,3 +43,2 @@ var container = document.createElement('div'); | ||
cachedType = 'reverse'; | ||
if (dummy.scrollLeft > 0) { | ||
@@ -50,3 +48,2 @@ cachedType = 'default'; | ||
dummy.scrollLeft = 1; | ||
if (dummy.scrollLeft === 0) { | ||
@@ -56,23 +53,20 @@ cachedType = 'negative'; | ||
} | ||
document.body.removeChild(dummy); | ||
return cachedType; | ||
} // Based on https://stackoverflow.com/a/24394376 | ||
} | ||
// Based on https://stackoverflow.com/a/24394376 | ||
export function getNormalizedScrollLeft(element, direction) { | ||
var scrollLeft = element.scrollLeft; // Perform the calculations only when direction is rtl to avoid messing up the ltr behavior | ||
var scrollLeft = element.scrollLeft; | ||
// Perform the calculations only when direction is rtl to avoid messing up the ltr behavior | ||
if (direction !== 'rtl') { | ||
return scrollLeft; | ||
} | ||
var type = detectScrollType(); | ||
switch (type) { | ||
case 'negative': | ||
return element.scrollWidth - element.clientWidth + scrollLeft; | ||
case 'reverse': | ||
return element.scrollWidth - element.clientWidth - scrollLeft; | ||
default: | ||
@@ -79,0 +73,0 @@ return scrollLeft; |
@@ -5,10 +5,7 @@ export default function unsupportedProp(props, propName, componentName, location, propFullName) { | ||
} | ||
var propFullNameSafe = propFullName || propName; | ||
if (typeof props[propName] !== 'undefined') { | ||
return new Error("The prop `".concat(propFullNameSafe, "` is not supported. Please remove it.")); | ||
} | ||
return null; | ||
} |
@@ -5,17 +5,13 @@ /* eslint-disable react-hooks/rules-of-hooks, react-hooks/exhaustive-deps */ | ||
var controlled = _ref.controlled, | ||
defaultProp = _ref.default, | ||
name = _ref.name, | ||
_ref$state = _ref.state, | ||
state = _ref$state === void 0 ? 'value' : _ref$state; | ||
defaultProp = _ref.default, | ||
name = _ref.name, | ||
_ref$state = _ref.state, | ||
state = _ref$state === void 0 ? 'value' : _ref$state; | ||
// isControlled is ignored in the hook dependency lists as it should never change. | ||
var _React$useRef = React.useRef(controlled !== undefined), | ||
isControlled = _React$useRef.current; | ||
isControlled = _React$useRef.current; | ||
var _React$useState = React.useState(defaultProp), | ||
valueState = _React$useState[0], | ||
setValue = _React$useState[1]; | ||
valueState = _React$useState[0], | ||
setValue = _React$useState[1]; | ||
var value = isControlled ? controlled : valueState; | ||
if (process.env.NODE_ENV !== 'production') { | ||
@@ -27,6 +23,4 @@ React.useEffect(function () { | ||
}, [state, name, controlled]); | ||
var _React$useRef2 = React.useRef(defaultProp), | ||
defaultValue = _React$useRef2.current; | ||
defaultValue = _React$useRef2.current; | ||
React.useEffect(function () { | ||
@@ -38,3 +32,2 @@ if (!isControlled && defaultValue !== defaultProp) { | ||
} | ||
var setValueIfUncontrolled = React.useCallback(function (newValue) { | ||
@@ -41,0 +34,0 @@ if (!isControlled) { |
import * as React from 'react'; | ||
import useEnhancedEffect from './useEnhancedEffect'; | ||
/** | ||
* https://github.com/facebook/react/issues/14099#issuecomment-440013892 | ||
*/ | ||
export default function useEventCallback(fn) { | ||
@@ -13,3 +13,4 @@ var ref = React.useRef(fn); | ||
return React.useCallback(function () { | ||
return (// @ts-expect-error hide `this` | ||
return ( | ||
// @ts-expect-error hide `this` | ||
// tslint:disable-next-line:ban-comma-operator | ||
@@ -16,0 +17,0 @@ (0, ref.current).apply(void 0, arguments) |
@@ -7,3 +7,2 @@ import * as React from 'react'; | ||
} | ||
/** | ||
@@ -20,3 +19,2 @@ * This will create a new function if the refs passed to this hook change and are all defined. | ||
} | ||
return function (instance) { | ||
@@ -26,4 +24,5 @@ refs.forEach(function (ref) { | ||
}); | ||
}; // eslint-disable-next-line react-hooks/exhaustive-deps | ||
}; | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, refs); | ||
} |
import * as React from 'react'; | ||
var globalId = 0; | ||
function useGlobalId(idOverride) { | ||
var _React$useState = React.useState(idOverride), | ||
defaultId = _React$useState[0], | ||
setDefaultId = _React$useState[1]; | ||
defaultId = _React$useState[0], | ||
setDefaultId = _React$useState[1]; | ||
var id = idOverride || defaultId; | ||
@@ -21,5 +19,5 @@ React.useEffect(function () { | ||
return id; | ||
} // eslint-disable-next-line no-useless-concat -- Workaround for https://github.com/webpack/webpack/issues/14814 | ||
} | ||
// eslint-disable-next-line no-useless-concat -- Workaround for https://github.com/webpack/webpack/issues/14814 | ||
var maybeReactUseId = React['useId' + '']; | ||
@@ -32,3 +30,2 @@ /** | ||
*/ | ||
export default function useId(idOverride) { | ||
@@ -38,6 +35,5 @@ if (maybeReactUseId !== undefined) { | ||
return idOverride != null ? idOverride : reactId; | ||
} // eslint-disable-next-line react-hooks/rules-of-hooks -- `React.useId` is invariant at runtime. | ||
} | ||
// eslint-disable-next-line react-hooks/rules-of-hooks -- `React.useId` is invariant at runtime. | ||
return useGlobalId(idOverride); | ||
} |
@@ -21,2 +21,3 @@ // based on https://github.com/WICG/focus-visible/blob/v4.1.5/src/focus-visible.js | ||
}; | ||
/** | ||
@@ -29,22 +30,18 @@ * Computes whether the given element should automatically trigger the | ||
*/ | ||
function focusTriggersKeyboardModality(node) { | ||
var _ref = node, | ||
type = _ref.type, | ||
tagName = _ref.tagName; | ||
type = _ref.type, | ||
tagName = _ref.tagName; | ||
if (tagName === 'INPUT' && inputTypesWhitelist[type] && !node.readOnly) { | ||
return true; | ||
} | ||
if (tagName === 'TEXTAREA' && !node.readOnly) { | ||
return true; | ||
} | ||
if (node.isContentEditable) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
/** | ||
@@ -57,4 +54,2 @@ * Keep track of our keyboard modality state with `hadKeyboardEvent`. | ||
*/ | ||
function handleKeyDown(event) { | ||
@@ -64,5 +59,5 @@ if (event.metaKey || event.altKey || event.ctrlKey) { | ||
} | ||
hadKeyboardEvent = true; | ||
} | ||
/** | ||
@@ -75,8 +70,5 @@ * If at any point a user clicks with a pointing device, ensure that we change | ||
*/ | ||
function handlePointerDown() { | ||
hadKeyboardEvent = false; | ||
} | ||
function handleVisibilityChange() { | ||
@@ -93,3 +85,2 @@ if (this.visibilityState === 'hidden') { | ||
} | ||
function prepare(doc) { | ||
@@ -102,3 +93,2 @@ doc.addEventListener('keydown', handleKeyDown, true); | ||
} | ||
export function teardown(doc) { | ||
@@ -111,19 +101,17 @@ doc.removeEventListener('keydown', handleKeyDown, true); | ||
} | ||
function isFocusVisible(event) { | ||
var target = event.target; | ||
try { | ||
return target.matches(':focus-visible'); | ||
} catch (error) {// Browsers not implementing :focus-visible will throw a SyntaxError. | ||
} catch (error) { | ||
// Browsers not implementing :focus-visible will throw a SyntaxError. | ||
// We use our own heuristic for those browsers. | ||
// Rethrow might be better if it's not the expected error but do we really | ||
// want to crash if focus-visible malfunctioned? | ||
} // No need for validFocusTarget check. The user does that by attaching it to | ||
} | ||
// No need for validFocusTarget check. The user does that by attaching it to | ||
// focusable events only. | ||
return hadKeyboardEvent || focusTriggersKeyboardModality(target); | ||
} | ||
export default function useIsFocusVisible() { | ||
@@ -136,6 +124,6 @@ var ref = React.useCallback(function (node) { | ||
var isFocusVisibleRef = React.useRef(false); | ||
/** | ||
* Should be called if a blur event is fired | ||
*/ | ||
function handleBlurVisible() { | ||
@@ -160,10 +148,8 @@ // checking against potential state variable does not suffice if we focus and blur synchronously. | ||
} | ||
return false; | ||
} | ||
/** | ||
* Should be called if a blur event is fired | ||
*/ | ||
function handleFocusVisible(event) { | ||
@@ -174,6 +160,4 @@ if (isFocusVisible(event)) { | ||
} | ||
return false; | ||
} | ||
return { | ||
@@ -180,0 +164,0 @@ isFocusVisibleRef: isFocusVisibleRef, |
import * as React from 'react'; | ||
var usePreviousProps = function usePreviousProps(value) { | ||
@@ -10,3 +9,2 @@ var ref = React.useRef({}); | ||
}; | ||
export default usePreviousProps; |
@@ -10,4 +10,3 @@ import _formatMuiErrorMessage from "./formatMuiErrorMessage"; | ||
} | ||
return string.charAt(0).toUpperCase() + string.slice(1); | ||
} |
@@ -5,3 +5,2 @@ export default function chainPropTypes(propType1, propType2) { | ||
} | ||
return function validate(...args) { | ||
@@ -8,0 +7,0 @@ return propType1(...args) || propType2(...args); |
const defaultGenerator = componentName => componentName; | ||
const createClassNameGenerator = () => { | ||
@@ -9,15 +8,11 @@ let generate = defaultGenerator; | ||
}, | ||
generate(componentName) { | ||
return generate(componentName); | ||
}, | ||
reset() { | ||
generate = defaultGenerator; | ||
} | ||
}; | ||
}; | ||
const ClassNameGenerator = createClassNameGenerator(); | ||
export default ClassNameGenerator; |
export default function composeClasses(slots, getUtilityClass, classes) { | ||
const output = {}; | ||
Object.keys(slots).forEach( // `Objet.keys(slots)` can't be wider than `T` because we infer `T` from `slots`. | ||
Object.keys(slots).forEach( | ||
// `Objet.keys(slots)` can't be wider than `T` because we infer `T` from `slots`. | ||
// @ts-expect-error https://github.com/microsoft/TypeScript/pull/12253#issuecomment-263132208 | ||
@@ -9,3 +10,2 @@ slot => { | ||
acc.push(getUtilityClass(key)); | ||
if (classes && classes[key]) { | ||
@@ -15,3 +15,2 @@ acc.push(classes[key]); | ||
} | ||
return acc; | ||
@@ -18,0 +17,0 @@ }, []).join(' '); |
@@ -12,3 +12,2 @@ /** | ||
} | ||
return function chainedFunction(...args) { | ||
@@ -15,0 +14,0 @@ acc.apply(this, args); |
@@ -5,3 +5,2 @@ // Corresponds to 10 frames at 60 Hz. | ||
let timeout; | ||
function debounced(...args) { | ||
@@ -11,12 +10,9 @@ const later = () => { | ||
}; | ||
clearTimeout(timeout); | ||
timeout = setTimeout(later, wait); | ||
} | ||
debounced.clear = () => { | ||
clearTimeout(timeout); | ||
}; | ||
return debounced; | ||
} |
@@ -9,3 +9,2 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
const output = options.clone ? _extends({}, target) : target; | ||
if (isPlainObject(target) && isPlainObject(source)) { | ||
@@ -17,3 +16,2 @@ Object.keys(source).forEach(key => { | ||
} | ||
if (isPlainObject(source[key]) && key in target && isPlainObject(target[key])) { | ||
@@ -27,4 +25,3 @@ // Since `output` is a clone of `target` and we have narrowed `target` in this block we can cast to the same type. | ||
} | ||
return output; | ||
} |
@@ -5,13 +5,10 @@ export default function deprecatedPropType(validator, reason) { | ||
} | ||
return (props, propName, componentName, location, propFullName) => { | ||
const componentNameSafe = componentName || '<<anonymous>>'; | ||
const propFullNameSafe = propFullName || propName; | ||
if (typeof props[propName] !== 'undefined') { | ||
return new Error(`The ${location} \`${propFullNameSafe}\` of ` + `\`${componentNameSafe}\` is deprecated. ${reason}`); | ||
} | ||
return null; | ||
}; | ||
} |
import PropTypes from 'prop-types'; | ||
import chainPropTypes from './chainPropTypes'; | ||
function isClassComponent(elementType) { | ||
@@ -11,8 +10,7 @@ // elementType.prototype?.isReactComponent | ||
} | ||
function acceptingRef(props, propName, componentName, location, propFullName) { | ||
const element = props[propName]; | ||
const safePropName = propFullName || propName; | ||
if (element == null || // When server-side rendering React doesn't warn either. | ||
if (element == null || | ||
// When server-side rendering React doesn't warn either. | ||
// This is not an accurate check for SSR. | ||
@@ -24,3 +22,2 @@ // This is only in place for Emotion compat. | ||
} | ||
let warningHint; | ||
@@ -37,16 +34,12 @@ const elementType = element.type; | ||
*/ | ||
if (typeof elementType === 'function' && !isClassComponent(elementType)) { | ||
warningHint = 'Did you accidentally use a plain function component for an element instead?'; | ||
} | ||
if (warningHint !== undefined) { | ||
return new Error(`Invalid ${location} \`${safePropName}\` supplied to \`${componentName}\`. ` + `Expected an element that can hold a ref. ${warningHint} ` + 'For more information see https://mui.com/r/caveat-with-refs-guide'); | ||
} | ||
return null; | ||
} | ||
const elementAcceptingRef = chainPropTypes(PropTypes.element, acceptingRef); | ||
elementAcceptingRef.isRequired = chainPropTypes(PropTypes.element.isRequired, acceptingRef); | ||
export default elementAcceptingRef; |
import PropTypes from 'prop-types'; | ||
import chainPropTypes from './chainPropTypes'; | ||
function isClassComponent(elementType) { | ||
@@ -11,8 +10,7 @@ // elementType.prototype?.isReactComponent | ||
} | ||
function elementTypeAcceptingRef(props, propName, componentName, location, propFullName) { | ||
const propValue = props[propName]; | ||
const safePropName = propFullName || propName; | ||
if (propValue == null || // When server-side rendering React doesn't warn either. | ||
if (propValue == null || | ||
// When server-side rendering React doesn't warn either. | ||
// This is not an accurate check for SSR. | ||
@@ -24,4 +22,4 @@ // This is only in place for emotion compat. | ||
} | ||
let warningHint; | ||
let warningHint; | ||
/** | ||
@@ -36,14 +34,10 @@ * Blacklisting instead of whitelisting | ||
*/ | ||
if (typeof propValue === 'function' && !isClassComponent(propValue)) { | ||
warningHint = 'Did you accidentally provide a plain function component instead?'; | ||
} | ||
if (warningHint !== undefined) { | ||
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'); | ||
} | ||
return null; | ||
} | ||
export default chainPropTypes(PropTypes.elementType, elementTypeAcceptingRef); |
@@ -5,2 +5,3 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
// the module was forked. | ||
const specialProperty = 'exact-prop: \u200b'; | ||
@@ -11,11 +12,8 @@ export default function exactProp(propTypes) { | ||
} | ||
return _extends({}, propTypes, { | ||
[specialProperty]: props => { | ||
const unsupportedProps = Object.keys(props).filter(prop => !propTypes.hasOwnProperty(prop)); | ||
if (unsupportedProps.length > 0) { | ||
return new Error(`The following props are not supported: ${unsupportedProps.map(prop => `\`${prop}\``).join(', ')}. Please remove them.`); | ||
} | ||
return null; | ||
@@ -22,0 +20,0 @@ } |
@@ -10,6 +10,4 @@ /** | ||
// see https://babeljs.io/docs/en/babel-plugin-transform-template-literals#loose | ||
/* eslint-disable prefer-template */ | ||
let url = 'https://mui.com/production-error/?code=' + code; | ||
for (let i = 1; i < arguments.length; i += 1) { | ||
@@ -20,5 +18,4 @@ // rest params over-transpile for this case | ||
} | ||
return 'Minified MUI error #' + code + '; visit ' + url + ' for the full message.'; | ||
/* eslint-enable prefer-template */ | ||
} |
@@ -1,4 +0,5 @@ | ||
import { ForwardRef, Memo } from 'react-is'; // Simplified polyfill for IE11 support | ||
import { ForwardRef, Memo } from 'react-is'; | ||
// Simplified polyfill for IE11 support | ||
// https://github.com/JamesMGreene/Function.name/blob/58b314d4a983110c3682f1228f845d39ccca1817/Function.name.js#L3 | ||
const fnNameMatchRegex = /^\s*function(?:\s|\s*\/\*.*\*\/\s*)+([^(\s/]*)\s*/; | ||
@@ -10,7 +11,5 @@ export function getFunctionName(fn) { | ||
} | ||
function getFunctionComponentName(Component, fallback = '') { | ||
return Component.displayName || Component.name || getFunctionName(Component) || fallback; | ||
} | ||
function getWrappedName(outerType, innerType, wrapperName) { | ||
@@ -20,2 +19,3 @@ const functionName = getFunctionComponentName(innerType); | ||
} | ||
/** | ||
@@ -26,4 +26,2 @@ * cherry-pick from | ||
*/ | ||
export default function getDisplayName(Component) { | ||
@@ -33,12 +31,10 @@ if (Component == null) { | ||
} | ||
if (typeof Component === 'string') { | ||
return Component; | ||
} | ||
if (typeof Component === 'function') { | ||
return getFunctionComponentName(Component, 'Component'); | ||
} // TypeScript can't have components as objects but they exist in the form of `memo` or `Suspense` | ||
} | ||
// TypeScript can't have components as objects but they exist in the form of `memo` or `Suspense` | ||
if (typeof Component === 'object') { | ||
@@ -48,6 +44,4 @@ switch (Component.$$typeof) { | ||
return getWrappedName(Component, Component.render, 'ForwardRef'); | ||
case Memo: | ||
return getWrappedName(Component, Component.type, 'memo'); | ||
default: | ||
@@ -57,4 +51,3 @@ return undefined; | ||
} | ||
return undefined; | ||
} |
@@ -5,15 +5,11 @@ export default function HTMLElementType(props, propName, componentName, location, propFullName) { | ||
} | ||
const propValue = props[propName]; | ||
const safePropName = propFullName || propName; | ||
if (propValue == null) { | ||
return null; | ||
} | ||
if (propValue && propValue.nodeType !== 1) { | ||
return new Error(`Invalid ${location} \`${safePropName}\` supplied to \`${componentName}\`. ` + `Expected an HTMLElement.`); | ||
} | ||
return null; | ||
} |
@@ -1,2 +0,2 @@ | ||
/** @license MUI v5.10.9 | ||
/** @license MUI v5.10.14 | ||
* | ||
@@ -3,0 +3,0 @@ * This source code is licensed under the MIT license found in the |
export function getTypeByValue(value) { | ||
const valueType = typeof value; | ||
switch (valueType) { | ||
@@ -9,13 +8,9 @@ case 'number': | ||
} | ||
if (!Number.isFinite(value)) { | ||
return 'Infinity'; | ||
} | ||
if (value !== Math.floor(value)) { | ||
return 'float'; | ||
} | ||
return 'number'; | ||
case 'object': | ||
@@ -25,10 +20,9 @@ if (value === null) { | ||
} | ||
return value.constructor.name; | ||
default: | ||
return valueType; | ||
} | ||
} // IE 11 support | ||
} | ||
// IE 11 support | ||
function ponyfillIsInteger(x) { | ||
@@ -38,8 +32,5 @@ // eslint-disable-next-line no-restricted-globals | ||
} | ||
const isInteger = Number.isInteger || ponyfillIsInteger; | ||
function requiredInteger(props, propName, componentName, location) { | ||
const propValue = props[propName]; | ||
if (propValue == null || !isInteger(propValue)) { | ||
@@ -49,22 +40,16 @@ const propType = getTypeByValue(propValue); | ||
} | ||
return null; | ||
} | ||
function validator(props, propName, ...other) { | ||
const propValue = props[propName]; | ||
if (propValue === undefined) { | ||
return null; | ||
} | ||
return requiredInteger(props, propName, ...other); | ||
} | ||
function validatorNoop() { | ||
return null; | ||
} | ||
validator.isRequired = requiredInteger; | ||
validatorNoop.isRequired = validatorNoop; | ||
export default process.env.NODE_ENV === 'production' ? validatorNoop : validator; |
@@ -5,14 +5,11 @@ import _extends from "@babel/runtime/helpers/esm/extends"; | ||
return () => null; | ||
} // eslint-disable-next-line react/forbid-foreign-prop-types | ||
} | ||
// eslint-disable-next-line react/forbid-foreign-prop-types | ||
const prevPropTypes = Component ? _extends({}, Component.propTypes) : null; | ||
const requireProp = requiredProp => (props, propName, componentName, location, propFullName, ...args) => { | ||
const propFullNameSafe = propFullName || propName; | ||
const defaultTypeChecker = prevPropTypes?.[propFullNameSafe]; | ||
if (defaultTypeChecker) { | ||
const typeCheckerResult = defaultTypeChecker(props, propName, componentName, location, propFullName, ...args); | ||
if (typeCheckerResult) { | ||
@@ -22,11 +19,8 @@ return typeCheckerResult; | ||
} | ||
if (typeof props[propName] !== 'undefined' && !props[requiredProp]) { | ||
return new Error(`The prop \`${propFullNameSafe}\` of ` + `\`${componentNameInError}\` can only be used together with the \`${requiredProp}\` prop.`); | ||
} | ||
return null; | ||
}; | ||
return requireProp; | ||
} |
import _extends from "@babel/runtime/helpers/esm/extends"; | ||
/** | ||
@@ -11,3 +10,2 @@ * Add keys, values of `defaultProps` that does not exist in `props` | ||
const output = _extends({}, props); | ||
Object.keys(defaultProps).forEach(propName => { | ||
@@ -14,0 +12,0 @@ if (output[propName] === undefined) { |
// Source from https://github.com/alitaheri/normalize-scroll-left | ||
let cachedType; | ||
/** | ||
@@ -22,3 +23,2 @@ * Based on the jquery plugin https://github.com/othree/jquery.rtl-scroll-type | ||
*/ | ||
export function detectScrollType() { | ||
@@ -28,3 +28,2 @@ if (cachedType) { | ||
} | ||
const dummy = document.createElement('div'); | ||
@@ -44,3 +43,2 @@ const container = document.createElement('div'); | ||
cachedType = 'reverse'; | ||
if (dummy.scrollLeft > 0) { | ||
@@ -50,3 +48,2 @@ cachedType = 'default'; | ||
dummy.scrollLeft = 1; | ||
if (dummy.scrollLeft === 0) { | ||
@@ -56,23 +53,20 @@ cachedType = 'negative'; | ||
} | ||
document.body.removeChild(dummy); | ||
return cachedType; | ||
} // Based on https://stackoverflow.com/a/24394376 | ||
} | ||
// Based on https://stackoverflow.com/a/24394376 | ||
export function getNormalizedScrollLeft(element, direction) { | ||
const scrollLeft = element.scrollLeft; // Perform the calculations only when direction is rtl to avoid messing up the ltr behavior | ||
const scrollLeft = element.scrollLeft; | ||
// Perform the calculations only when direction is rtl to avoid messing up the ltr behavior | ||
if (direction !== 'rtl') { | ||
return scrollLeft; | ||
} | ||
const type = detectScrollType(); | ||
switch (type) { | ||
case 'negative': | ||
return element.scrollWidth - element.clientWidth + scrollLeft; | ||
case 'reverse': | ||
return element.scrollWidth - element.clientWidth - scrollLeft; | ||
default: | ||
@@ -79,0 +73,0 @@ return scrollLeft; |
@@ -5,10 +5,7 @@ export default function unsupportedProp(props, propName, componentName, location, propFullName) { | ||
} | ||
const propFullNameSafe = propFullName || propName; | ||
if (typeof props[propName] !== 'undefined') { | ||
return new Error(`The prop \`${propFullNameSafe}\` is not supported. Please remove it.`); | ||
} | ||
return null; | ||
} |
@@ -15,3 +15,2 @@ /* eslint-disable react-hooks/rules-of-hooks, react-hooks/exhaustive-deps */ | ||
const value = isControlled ? controlled : valueState; | ||
if (process.env.NODE_ENV !== 'production') { | ||
@@ -32,3 +31,2 @@ React.useEffect(() => { | ||
} | ||
const setValueIfUncontrolled = React.useCallback(newValue => { | ||
@@ -35,0 +33,0 @@ if (!isControlled) { |
import * as React from 'react'; | ||
import useEnhancedEffect from './useEnhancedEffect'; | ||
/** | ||
* https://github.com/facebook/react/issues/14099#issuecomment-440013892 | ||
*/ | ||
export default function useEventCallback(fn) { | ||
@@ -12,5 +12,6 @@ const ref = React.useRef(fn); | ||
}); | ||
return React.useCallback((...args) => // @ts-expect-error hide `this` | ||
return React.useCallback((...args) => | ||
// @ts-expect-error hide `this` | ||
// tslint:disable-next-line:ban-comma-operator | ||
(0, ref.current)(...args), []); | ||
} |
@@ -13,3 +13,2 @@ import * as React from 'react'; | ||
} | ||
return instance => { | ||
@@ -19,4 +18,5 @@ refs.forEach(ref => { | ||
}); | ||
}; // eslint-disable-next-line react-hooks/exhaustive-deps | ||
}; | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, refs); | ||
} |
import * as React from 'react'; | ||
let globalId = 0; | ||
function useGlobalId(idOverride) { | ||
@@ -18,5 +17,5 @@ const [defaultId, setDefaultId] = React.useState(idOverride); | ||
return id; | ||
} // eslint-disable-next-line no-useless-concat -- Workaround for https://github.com/webpack/webpack/issues/14814 | ||
} | ||
// eslint-disable-next-line no-useless-concat -- Workaround for https://github.com/webpack/webpack/issues/14814 | ||
const maybeReactUseId = React['useId' + '']; | ||
@@ -29,3 +28,2 @@ /** | ||
*/ | ||
export default function useId(idOverride) { | ||
@@ -35,6 +33,5 @@ if (maybeReactUseId !== undefined) { | ||
return idOverride ?? reactId; | ||
} // eslint-disable-next-line react-hooks/rules-of-hooks -- `React.useId` is invariant at runtime. | ||
} | ||
// eslint-disable-next-line react-hooks/rules-of-hooks -- `React.useId` is invariant at runtime. | ||
return useGlobalId(idOverride); | ||
} |
@@ -21,2 +21,3 @@ // based on https://github.com/WICG/focus-visible/blob/v4.1.5/src/focus-visible.js | ||
}; | ||
/** | ||
@@ -29,3 +30,2 @@ * Computes whether the given element should automatically trigger the | ||
*/ | ||
function focusTriggersKeyboardModality(node) { | ||
@@ -36,17 +36,14 @@ const { | ||
} = node; | ||
if (tagName === 'INPUT' && inputTypesWhitelist[type] && !node.readOnly) { | ||
return true; | ||
} | ||
if (tagName === 'TEXTAREA' && !node.readOnly) { | ||
return true; | ||
} | ||
if (node.isContentEditable) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
/** | ||
@@ -59,4 +56,2 @@ * Keep track of our keyboard modality state with `hadKeyboardEvent`. | ||
*/ | ||
function handleKeyDown(event) { | ||
@@ -66,5 +61,5 @@ if (event.metaKey || event.altKey || event.ctrlKey) { | ||
} | ||
hadKeyboardEvent = true; | ||
} | ||
/** | ||
@@ -77,8 +72,5 @@ * If at any point a user clicks with a pointing device, ensure that we change | ||
*/ | ||
function handlePointerDown() { | ||
hadKeyboardEvent = false; | ||
} | ||
function handleVisibilityChange() { | ||
@@ -95,3 +87,2 @@ if (this.visibilityState === 'hidden') { | ||
} | ||
function prepare(doc) { | ||
@@ -104,3 +95,2 @@ doc.addEventListener('keydown', handleKeyDown, true); | ||
} | ||
export function teardown(doc) { | ||
@@ -113,3 +103,2 @@ doc.removeEventListener('keydown', handleKeyDown, true); | ||
} | ||
function isFocusVisible(event) { | ||
@@ -119,16 +108,15 @@ const { | ||
} = event; | ||
try { | ||
return target.matches(':focus-visible'); | ||
} catch (error) {// Browsers not implementing :focus-visible will throw a SyntaxError. | ||
} catch (error) { | ||
// Browsers not implementing :focus-visible will throw a SyntaxError. | ||
// We use our own heuristic for those browsers. | ||
// Rethrow might be better if it's not the expected error but do we really | ||
// want to crash if focus-visible malfunctioned? | ||
} // No need for validFocusTarget check. The user does that by attaching it to | ||
} | ||
// No need for validFocusTarget check. The user does that by attaching it to | ||
// focusable events only. | ||
return hadKeyboardEvent || focusTriggersKeyboardModality(target); | ||
} | ||
export default function useIsFocusVisible() { | ||
@@ -141,6 +129,6 @@ const ref = React.useCallback(node => { | ||
const isFocusVisibleRef = React.useRef(false); | ||
/** | ||
* Should be called if a blur event is fired | ||
*/ | ||
function handleBlurVisible() { | ||
@@ -165,10 +153,8 @@ // checking against potential state variable does not suffice if we focus and blur synchronously. | ||
} | ||
return false; | ||
} | ||
/** | ||
* Should be called if a blur event is fired | ||
*/ | ||
function handleFocusVisible(event) { | ||
@@ -179,6 +165,4 @@ if (isFocusVisible(event)) { | ||
} | ||
return false; | ||
} | ||
return { | ||
@@ -185,0 +169,0 @@ isFocusVisibleRef, |
import * as React from 'react'; | ||
const usePreviousProps = value => { | ||
@@ -10,3 +9,2 @@ const ref = React.useRef({}); | ||
}; | ||
export default usePreviousProps; |
export default function ownerDocument(node: Node | null | undefined): Document; |
@@ -7,5 +7,4 @@ "use strict"; | ||
exports.default = ownerDocument; | ||
function ownerDocument(node) { | ||
return node && node.ownerDocument || document; | ||
} |
export default function ownerWindow(node: Node | undefined): Window; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -9,5 +8,3 @@ value: true | ||
exports.default = ownerWindow; | ||
var _ownerDocument = _interopRequireDefault(require("./ownerDocument")); | ||
function ownerWindow(node) { | ||
@@ -14,0 +11,0 @@ const doc = (0, _ownerDocument.default)(node); |
{ | ||
"name": "@mui/utils", | ||
"version": "5.10.9", | ||
"version": "5.10.14", | ||
"private": false, | ||
@@ -32,3 +32,3 @@ "author": "MUI Team", | ||
"dependencies": { | ||
"@babel/runtime": "^7.19.0", | ||
"@babel/runtime": "^7.20.1", | ||
"@types/prop-types": "^15.7.5", | ||
@@ -35,0 +35,0 @@ "@types/react-is": "^16.7.1 || ^17.0.0", |
declare const _default: any; | ||
export default _default; |
@@ -7,7 +7,5 @@ "use strict"; | ||
exports.default = void 0; | ||
/* eslint-disable */ | ||
// https://github.com/zloirock/core-js/issues/86#issuecomment-115759028 | ||
var _default = typeof window != 'undefined' && window.Math == Math ? window : typeof self != 'undefined' && self.Math == Math ? self : Function('return this')(); | ||
exports.default = _default; |
import PropTypes from 'prop-types'; | ||
declare const refType: PropTypes.Requireable<object>; | ||
export default refType; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -9,8 +8,5 @@ value: true | ||
exports.default = void 0; | ||
var _propTypes = _interopRequireDefault(require("prop-types")); | ||
const refType = _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object]); | ||
var _default = refType; | ||
exports.default = _default; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -9,20 +8,15 @@ value: true | ||
exports.default = requirePropFactory; | ||
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); | ||
function requirePropFactory(componentNameInError, Component) { | ||
if (process.env.NODE_ENV === 'production') { | ||
return () => null; | ||
} // eslint-disable-next-line react/forbid-foreign-prop-types | ||
} | ||
// eslint-disable-next-line react/forbid-foreign-prop-types | ||
const prevPropTypes = Component ? (0, _extends2.default)({}, Component.propTypes) : null; | ||
const requireProp = requiredProp => (props, propName, componentName, location, propFullName, ...args) => { | ||
const propFullNameSafe = propFullName || propName; | ||
const defaultTypeChecker = prevPropTypes == null ? void 0 : prevPropTypes[propFullNameSafe]; | ||
if (defaultTypeChecker) { | ||
const typeCheckerResult = defaultTypeChecker(props, propName, componentName, location, propFullName, ...args); | ||
if (typeCheckerResult) { | ||
@@ -32,11 +26,8 @@ return typeCheckerResult; | ||
} | ||
if (typeof props[propName] !== 'undefined' && !props[requiredProp]) { | ||
return new Error(`The prop \`${propFullNameSafe}\` of ` + `\`${componentNameInError}\` can only be used together with the \`${requiredProp}\` prop.`); | ||
} | ||
return null; | ||
}; | ||
return requireProp; | ||
} |
@@ -0,0 +0,0 @@ /** |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -9,5 +8,3 @@ value: true | ||
exports.default = resolveProps; | ||
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); | ||
/** | ||
@@ -14,0 +11,0 @@ * Add keys, values of `defaultProps` that does not exist in `props` |
@@ -10,2 +10,3 @@ "use strict"; | ||
let cachedType; | ||
/** | ||
@@ -30,3 +31,2 @@ * Based on the jquery plugin https://github.com/othree/jquery.rtl-scroll-type | ||
*/ | ||
function detectScrollType() { | ||
@@ -36,3 +36,2 @@ if (cachedType) { | ||
} | ||
const dummy = document.createElement('div'); | ||
@@ -52,3 +51,2 @@ const container = document.createElement('div'); | ||
cachedType = 'reverse'; | ||
if (dummy.scrollLeft > 0) { | ||
@@ -58,3 +56,2 @@ cachedType = 'default'; | ||
dummy.scrollLeft = 1; | ||
if (dummy.scrollLeft === 0) { | ||
@@ -64,24 +61,20 @@ cachedType = 'negative'; | ||
} | ||
document.body.removeChild(dummy); | ||
return cachedType; | ||
} // Based on https://stackoverflow.com/a/24394376 | ||
} | ||
// Based on https://stackoverflow.com/a/24394376 | ||
function getNormalizedScrollLeft(element, direction) { | ||
const scrollLeft = element.scrollLeft; // Perform the calculations only when direction is rtl to avoid messing up the ltr behavior | ||
const scrollLeft = element.scrollLeft; | ||
// Perform the calculations only when direction is rtl to avoid messing up the ltr behavior | ||
if (direction !== 'rtl') { | ||
return scrollLeft; | ||
} | ||
const type = detectScrollType(); | ||
switch (type) { | ||
case 'negative': | ||
return element.scrollWidth - element.clientWidth + scrollLeft; | ||
case 'reverse': | ||
return element.scrollWidth - element.clientWidth - scrollLeft; | ||
default: | ||
@@ -88,0 +81,0 @@ return scrollLeft; |
@@ -0,0 +0,0 @@ import * as React from 'react'; |
@@ -7,3 +7,2 @@ "use strict"; | ||
exports.default = setRef; | ||
/** | ||
@@ -10,0 +9,0 @@ * TODO v5: consider making it private |
@@ -7,3 +7,2 @@ "use strict"; | ||
exports.default = unsupportedProp; | ||
function unsupportedProp(props, propName, componentName, location, propFullName) { | ||
@@ -13,10 +12,7 @@ if (process.env.NODE_ENV === 'production') { | ||
} | ||
const propFullNameSafe = propFullName || propName; | ||
if (typeof props[propName] !== 'undefined') { | ||
return new Error(`The prop \`${propFullNameSafe}\` is not supported. Please remove it.`); | ||
} | ||
return null; | ||
} |
@@ -7,10 +7,7 @@ "use strict"; | ||
exports.default = useControlled; | ||
var React = _interopRequireWildcard(require("react")); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
/* eslint-disable react-hooks/rules-of-hooks, react-hooks/exhaustive-deps */ | ||
/* eslint-disable react-hooks/rules-of-hooks, react-hooks/exhaustive-deps */ | ||
function useControlled({ | ||
@@ -28,3 +25,2 @@ controlled, | ||
const value = isControlled ? controlled : valueState; | ||
if (process.env.NODE_ENV !== 'production') { | ||
@@ -45,3 +41,2 @@ React.useEffect(() => { | ||
} | ||
const setValueIfUncontrolled = React.useCallback(newValue => { | ||
@@ -48,0 +43,0 @@ if (!isControlled) { |
@@ -7,11 +7,7 @@ "use strict"; | ||
exports.default = void 0; | ||
var React = _interopRequireWildcard(require("react")); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
const useEnhancedEffect = typeof window !== 'undefined' ? React.useLayoutEffect : React.useEffect; | ||
var _default = useEnhancedEffect; | ||
exports.default = _default; |
@@ -0,0 +0,0 @@ /** |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -9,11 +8,6 @@ value: true | ||
exports.default = useEventCallback; | ||
var React = _interopRequireWildcard(require("react")); | ||
var _useEnhancedEffect = _interopRequireDefault(require("./useEnhancedEffect")); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
/** | ||
@@ -27,5 +21,6 @@ * https://github.com/facebook/react/issues/14099#issuecomment-440013892 | ||
}); | ||
return React.useCallback((...args) => // @ts-expect-error hide `this` | ||
return React.useCallback((...args) => | ||
// @ts-expect-error hide `this` | ||
// tslint:disable-next-line:ban-comma-operator | ||
(0, ref.current)(...args), []); | ||
} |
export {}; |
import * as React from 'react'; | ||
export default function useForkRef<Instance>(...refs: Array<React.Ref<Instance> | undefined>): React.RefCallback<Instance> | null; |
"use strict"; | ||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -9,11 +8,6 @@ value: true | ||
exports.default = useForkRef; | ||
var React = _interopRequireWildcard(require("react")); | ||
var _setRef = _interopRequireDefault(require("./setRef")); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function useForkRef(...refs) { | ||
@@ -29,3 +23,2 @@ /** | ||
} | ||
return instance => { | ||
@@ -35,4 +28,5 @@ refs.forEach(ref => { | ||
}); | ||
}; // eslint-disable-next-line react-hooks/exhaustive-deps | ||
}; | ||
// eslint-disable-next-line react-hooks/exhaustive-deps | ||
}, refs); | ||
} |
@@ -0,0 +0,0 @@ /** |
15
useId.js
@@ -7,11 +7,6 @@ "use strict"; | ||
exports.default = useId; | ||
var React = _interopRequireWildcard(require("react")); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
let globalId = 0; | ||
function useGlobalId(idOverride) { | ||
@@ -31,5 +26,5 @@ const [defaultId, setDefaultId] = React.useState(idOverride); | ||
return id; | ||
} // eslint-disable-next-line no-useless-concat -- Workaround for https://github.com/webpack/webpack/issues/14814 | ||
} | ||
// eslint-disable-next-line no-useless-concat -- Workaround for https://github.com/webpack/webpack/issues/14814 | ||
const maybeReactUseId = React['useId' + '']; | ||
@@ -42,3 +37,2 @@ /** | ||
*/ | ||
function useId(idOverride) { | ||
@@ -48,6 +42,5 @@ if (maybeReactUseId !== undefined) { | ||
return idOverride != null ? idOverride : reactId; | ||
} // eslint-disable-next-line react-hooks/rules-of-hooks -- `React.useId` is invariant at runtime. | ||
} | ||
// eslint-disable-next-line react-hooks/rules-of-hooks -- `React.useId` is invariant at runtime. | ||
return useGlobalId(idOverride); | ||
} |
@@ -0,0 +0,0 @@ import * as React from 'react'; |
@@ -8,10 +8,7 @@ "use strict"; | ||
exports.teardown = teardown; | ||
var React = _interopRequireWildcard(require("react")); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
// based on https://github.com/WICG/focus-visible/blob/v4.1.5/src/focus-visible.js | ||
// based on https://github.com/WICG/focus-visible/blob/v4.1.5/src/focus-visible.js | ||
let hadKeyboardEvent = true; | ||
@@ -35,2 +32,3 @@ let hadFocusVisibleRecently = false; | ||
}; | ||
/** | ||
@@ -43,3 +41,2 @@ * Computes whether the given element should automatically trigger the | ||
*/ | ||
function focusTriggersKeyboardModality(node) { | ||
@@ -50,17 +47,14 @@ const { | ||
} = node; | ||
if (tagName === 'INPUT' && inputTypesWhitelist[type] && !node.readOnly) { | ||
return true; | ||
} | ||
if (tagName === 'TEXTAREA' && !node.readOnly) { | ||
return true; | ||
} | ||
if (node.isContentEditable) { | ||
return true; | ||
} | ||
return false; | ||
} | ||
/** | ||
@@ -73,4 +67,2 @@ * Keep track of our keyboard modality state with `hadKeyboardEvent`. | ||
*/ | ||
function handleKeyDown(event) { | ||
@@ -80,5 +72,5 @@ if (event.metaKey || event.altKey || event.ctrlKey) { | ||
} | ||
hadKeyboardEvent = true; | ||
} | ||
/** | ||
@@ -91,8 +83,5 @@ * If at any point a user clicks with a pointing device, ensure that we change | ||
*/ | ||
function handlePointerDown() { | ||
hadKeyboardEvent = false; | ||
} | ||
function handleVisibilityChange() { | ||
@@ -109,3 +98,2 @@ if (this.visibilityState === 'hidden') { | ||
} | ||
function prepare(doc) { | ||
@@ -118,3 +106,2 @@ doc.addEventListener('keydown', handleKeyDown, true); | ||
} | ||
function teardown(doc) { | ||
@@ -127,3 +114,2 @@ doc.removeEventListener('keydown', handleKeyDown, true); | ||
} | ||
function isFocusVisible(event) { | ||
@@ -133,16 +119,15 @@ const { | ||
} = event; | ||
try { | ||
return target.matches(':focus-visible'); | ||
} catch (error) {// Browsers not implementing :focus-visible will throw a SyntaxError. | ||
} catch (error) { | ||
// Browsers not implementing :focus-visible will throw a SyntaxError. | ||
// We use our own heuristic for those browsers. | ||
// Rethrow might be better if it's not the expected error but do we really | ||
// want to crash if focus-visible malfunctioned? | ||
} // No need for validFocusTarget check. The user does that by attaching it to | ||
} | ||
// No need for validFocusTarget check. The user does that by attaching it to | ||
// focusable events only. | ||
return hadKeyboardEvent || focusTriggersKeyboardModality(target); | ||
} | ||
function useIsFocusVisible() { | ||
@@ -155,6 +140,6 @@ const ref = React.useCallback(node => { | ||
const isFocusVisibleRef = React.useRef(false); | ||
/** | ||
* Should be called if a blur event is fired | ||
*/ | ||
function handleBlurVisible() { | ||
@@ -179,10 +164,8 @@ // checking against potential state variable does not suffice if we focus and blur synchronously. | ||
} | ||
return false; | ||
} | ||
/** | ||
* Should be called if a blur event is fired | ||
*/ | ||
function handleFocusVisible(event) { | ||
@@ -193,6 +176,4 @@ if (isFocusVisible(event)) { | ||
} | ||
return false; | ||
} | ||
return { | ||
@@ -199,0 +180,0 @@ isFocusVisibleRef, |
declare const usePreviousProps: (value: object) => object; | ||
export default usePreviousProps; |
@@ -7,9 +7,5 @@ "use strict"; | ||
exports.default = void 0; | ||
var React = _interopRequireWildcard(require("react")); | ||
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } | ||
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
const usePreviousProps = value => { | ||
@@ -22,4 +18,3 @@ const ref = React.useRef({}); | ||
}; | ||
var _default = usePreviousProps; | ||
exports.default = _default; |
declare const visuallyHidden: import('react').CSSProperties; | ||
export default visuallyHidden; |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
684191
4147
Updated@babel/runtime@^7.20.1