@mui/utils 5.2.2 → 5.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,3 +1,3 @@
1
- export default function HTMLElementType(props: {
2
- [key: string]: unknown;
3
- }, propName: string, componentName: string, location: string, propFullName: string): Error | null;
1
+ export default function HTMLElementType(props: {
2
+ [key: string]: unknown;
3
+ }, propName: string, componentName: string, location: string, propFullName: string): Error | null;
@@ -1,2 +1,2 @@
1
- import PropTypes from 'prop-types';
2
- export default function chainPropTypes<A, B>(propType1: PropTypes.Validator<A>, propType2: PropTypes.Validator<B>): PropTypes.Validator<A & B>;
1
+ import PropTypes from 'prop-types';
2
+ export default function chainPropTypes<A, B>(propType1: PropTypes.Validator<A>, propType2: PropTypes.Validator<B>): PropTypes.Validator<A & B>;
@@ -1,7 +1,7 @@
1
- /**
2
- * Safe chained function.
3
- *
4
- * Will only create a new function if needed,
5
- * otherwise will pass back existing functions or null.
6
- */
7
- export default function createChainedFunction<Args extends any[], This>(...funcs: Array<(this: This, ...args: Args) => any>): (this: This, ...args: Args) => void;
1
+ /**
2
+ * Safe chained function.
3
+ *
4
+ * Will only create a new function if needed,
5
+ * otherwise will pass back existing functions or null.
6
+ */
7
+ export default function createChainedFunction<Args extends any[], This>(...funcs: Array<(this: This, ...args: Args) => any>): (this: This, ...args: Args) => void;
package/deepmerge.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export declare function isPlainObject(item: unknown): item is Record<keyof any, unknown>;
2
- export interface DeepmergeOptions {
3
- clone?: boolean;
4
- }
5
- export default function deepmerge<T>(target: T, source: unknown, options?: DeepmergeOptions): T;
1
+ export declare function isPlainObject(item: unknown): item is Record<keyof any, unknown>;
2
+ export interface DeepmergeOptions {
3
+ clone?: boolean;
4
+ }
5
+ export default function deepmerge<T>(target: T, source: unknown, options?: DeepmergeOptions): T;
@@ -1,3 +1,3 @@
1
- import PropTypes from 'prop-types';
2
- declare const elementAcceptingRef: PropTypes.Requireable<unknown>;
3
- export default elementAcceptingRef;
1
+ import PropTypes from 'prop-types';
2
+ declare const elementAcceptingRef: PropTypes.Requireable<unknown>;
3
+ export default elementAcceptingRef;
@@ -1,3 +1,3 @@
1
- import PropTypes from 'prop-types';
2
- declare const _default: PropTypes.Validator<PropTypes.ReactComponentLike | null | undefined>;
3
- export default _default;
1
+ import PropTypes from 'prop-types';
2
+ declare const _default: PropTypes.Validator<PropTypes.ReactComponentLike | null | undefined>;
3
+ export default _default;
package/esm/index.js CHANGED
@@ -29,4 +29,5 @@ export { default as unstable_getScrollbarSize } from './getScrollbarSize';
29
29
  export { detectScrollType as unstable_detectScrollType, getNormalizedScrollLeft as unstable_getNormalizedScrollLeft } from './scrollLeft';
30
30
  export { default as usePreviousProps } from './usePreviousProps';
31
31
  export { default as visuallyHidden } from './visuallyHidden';
32
- export { default as integerPropType } from './integerPropType';
32
+ export { default as integerPropType } from './integerPropType';
33
+ export { default as internal_resolveProps } from './resolveProps';
@@ -0,0 +1,18 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+
3
+ /**
4
+ * Add keys, values of `defaultProps` that does not exist in `props`
5
+ * @param {object} defaultProps
6
+ * @param {object} props
7
+ * @returns {object} resolved props
8
+ */
9
+ export default function resolveProps(defaultProps, props) {
10
+ const output = _extends({}, props);
11
+
12
+ Object.keys(defaultProps).forEach(propName => {
13
+ if (output[propName] === undefined) {
14
+ output[propName] = defaultProps[propName];
15
+ }
16
+ });
17
+ return output;
18
+ }
package/esm/setRef.js CHANGED
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * WARNING: Be sure to only call this inside a callback that is passed as a ref.
7
7
  * Otherwise, make sure to cleanup the previous {ref} if it changes. See
8
- * https://github.com/mui-org/material-ui/issues/13539
8
+ * https://github.com/mui/material-ui/issues/13539
9
9
  *
10
10
  * Useful if you want to expose the ref of an inner component to the public API
11
11
  * while still using it inside the component.
package/esm/useId.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as React from 'react';
2
2
  let globalId = 0;
3
- export default function useId(idOverride) {
3
+
4
+ function useGlobalId(idOverride) {
4
5
  const [defaultId, setDefaultId] = React.useState(idOverride);
5
6
  const id = idOverride || defaultId;
6
7
  React.useEffect(() => {
@@ -14,4 +15,23 @@ export default function useId(idOverride) {
14
15
  }
15
16
  }, [defaultId]);
16
17
  return id;
18
+ } // eslint-disable-next-line no-useless-concat -- Workaround for https://github.com/webpack/webpack/issues/14814
19
+
20
+
21
+ const maybeReactUseId = React['useId' + ''];
22
+ /**
23
+ *
24
+ * @example <div id={useId()} />
25
+ * @param idOverride
26
+ * @returns {string}
27
+ */
28
+
29
+ export default function useId(idOverride) {
30
+ if (maybeReactUseId !== undefined) {
31
+ const reactId = maybeReactUseId();
32
+ return idOverride != null ? idOverride : reactId;
33
+ } // eslint-disable-next-line react-hooks/rules-of-hooks -- `React.useId` is invariant at runtime.
34
+
35
+
36
+ return useGlobalId(idOverride);
17
37
  }
package/exactProp.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { ValidationMap } from 'prop-types';
2
- export default function exactProp<T>(propTypes: ValidationMap<T>): ValidationMap<T>;
1
+ import { ValidationMap } from 'prop-types';
2
+ export default function exactProp<T>(propTypes: ValidationMap<T>): ValidationMap<T>;
@@ -1,6 +1,6 @@
1
- /**
2
- * WARNING: Don't import this directly.
3
- * Use `MuiError` from `@mui/utils/macros/MuiError.macro` instead.
4
- * @param {number} code
5
- */
6
- export default function formatMuiErrorMessage(code: number): string;
1
+ /**
2
+ * WARNING: Don't import this directly.
3
+ * Use `MuiError` from `@mui/utils/macros/MuiError.macro` instead.
4
+ * @param {number} code
5
+ */
6
+ export default function formatMuiErrorMessage(code: number): string;
@@ -1,8 +1,8 @@
1
- import * as React from 'react';
2
- export declare function getFunctionName(fn: Function): string;
3
- /**
4
- * cherry-pick from
5
- * https://github.com/facebook/react/blob/769b1f270e1251d9dbdce0fcbd9e92e502d059b8/packages/shared/getComponentName.js
6
- * originally forked from recompose/getDisplayName with added IE11 support
7
- */
8
- export default function getDisplayName(Component: React.ElementType): string | undefined;
1
+ import * as React from 'react';
2
+ export declare function getFunctionName(fn: Function): string;
3
+ /**
4
+ * cherry-pick from
5
+ * https://github.com/facebook/react/blob/769b1f270e1251d9dbdce0fcbd9e92e502d059b8/packages/shared/getComponentName.js
6
+ * originally forked from recompose/getDisplayName with added IE11 support
7
+ */
8
+ export default function getDisplayName(Component: React.ElementType): string | undefined;
@@ -1 +1 @@
1
- export default function getScrollbarSize(doc: Document): number;
1
+ export default function getScrollbarSize(doc: Document): number;
package/index.d.ts CHANGED
@@ -1,32 +1,33 @@
1
- export { default as chainPropTypes } from './chainPropTypes';
2
- export { default as deepmerge } from './deepmerge';
3
- export { isPlainObject } from './deepmerge';
4
- export { default as elementAcceptingRef } from './elementAcceptingRef';
5
- export { default as elementTypeAcceptingRef } from './elementTypeAcceptingRef';
6
- export { default as exactProp } from './exactProp';
7
- export { default as formatMuiErrorMessage } from './formatMuiErrorMessage';
8
- export { default as getDisplayName } from './getDisplayName';
9
- export { default as HTMLElementType } from './HTMLElementType';
10
- export { default as ponyfillGlobal } from './ponyfillGlobal';
11
- export { default as refType } from './refType';
12
- export { default as unstable_capitalize } from './capitalize';
13
- export { default as unstable_createChainedFunction } from './createChainedFunction';
14
- export { default as unstable_debounce } from './debounce';
15
- export { default as unstable_deprecatedPropType } from './deprecatedPropType';
16
- export { default as unstable_isMuiElement } from './isMuiElement';
17
- export { default as unstable_ownerDocument } from './ownerDocument';
18
- export { default as unstable_ownerWindow } from './ownerWindow';
19
- export { default as unstable_requirePropFactory } from './requirePropFactory';
20
- export { default as unstable_setRef } from './setRef';
21
- export { default as unstable_useEnhancedEffect } from './useEnhancedEffect';
22
- export { default as unstable_useId } from './useId';
23
- export { default as unstable_unsupportedProp } from './unsupportedProp';
24
- export { default as unstable_useControlled } from './useControlled';
25
- export { default as unstable_useEventCallback } from './useEventCallback';
26
- export { default as unstable_useForkRef } from './useForkRef';
27
- export { default as unstable_useIsFocusVisible } from './useIsFocusVisible';
28
- export { default as unstable_getScrollbarSize } from './getScrollbarSize';
29
- export { detectScrollType as unstable_detectScrollType, getNormalizedScrollLeft as unstable_getNormalizedScrollLeft, } from './scrollLeft';
30
- export { default as usePreviousProps } from './usePreviousProps';
31
- export { default as visuallyHidden } from './visuallyHidden';
32
- export { default as integerPropType } from './integerPropType';
1
+ export { default as chainPropTypes } from './chainPropTypes';
2
+ export { default as deepmerge } from './deepmerge';
3
+ export { isPlainObject } from './deepmerge';
4
+ export { default as elementAcceptingRef } from './elementAcceptingRef';
5
+ export { default as elementTypeAcceptingRef } from './elementTypeAcceptingRef';
6
+ export { default as exactProp } from './exactProp';
7
+ export { default as formatMuiErrorMessage } from './formatMuiErrorMessage';
8
+ export { default as getDisplayName } from './getDisplayName';
9
+ export { default as HTMLElementType } from './HTMLElementType';
10
+ export { default as ponyfillGlobal } from './ponyfillGlobal';
11
+ export { default as refType } from './refType';
12
+ export { default as unstable_capitalize } from './capitalize';
13
+ export { default as unstable_createChainedFunction } from './createChainedFunction';
14
+ export { default as unstable_debounce } from './debounce';
15
+ export { default as unstable_deprecatedPropType } from './deprecatedPropType';
16
+ export { default as unstable_isMuiElement } from './isMuiElement';
17
+ export { default as unstable_ownerDocument } from './ownerDocument';
18
+ export { default as unstable_ownerWindow } from './ownerWindow';
19
+ export { default as unstable_requirePropFactory } from './requirePropFactory';
20
+ export { default as unstable_setRef } from './setRef';
21
+ export { default as unstable_useEnhancedEffect } from './useEnhancedEffect';
22
+ export { default as unstable_useId } from './useId';
23
+ export { default as unstable_unsupportedProp } from './unsupportedProp';
24
+ export { default as unstable_useControlled } from './useControlled';
25
+ export { default as unstable_useEventCallback } from './useEventCallback';
26
+ export { default as unstable_useForkRef } from './useForkRef';
27
+ export { default as unstable_useIsFocusVisible } from './useIsFocusVisible';
28
+ export { default as unstable_getScrollbarSize } from './getScrollbarSize';
29
+ export { detectScrollType as unstable_detectScrollType, getNormalizedScrollLeft as unstable_getNormalizedScrollLeft, } from './scrollLeft';
30
+ export { default as usePreviousProps } from './usePreviousProps';
31
+ export { default as visuallyHidden } from './visuallyHidden';
32
+ export { default as integerPropType } from './integerPropType';
33
+ export { default as internal_resolveProps } from './resolveProps';
package/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.2.2
1
+ /** @license MUI v5.4.2
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -64,6 +64,12 @@ Object.defineProperty(exports, "integerPropType", {
64
64
  return _integerPropType.default;
65
65
  }
66
66
  });
67
+ Object.defineProperty(exports, "internal_resolveProps", {
68
+ enumerable: true,
69
+ get: function () {
70
+ return _resolveProps.default;
71
+ }
72
+ });
67
73
  Object.defineProperty(exports, "isPlainObject", {
68
74
  enumerable: true,
69
75
  get: function () {
@@ -271,6 +277,8 @@ var _visuallyHidden = _interopRequireDefault(require("./visuallyHidden"));
271
277
 
272
278
  var _integerPropType = _interopRequireDefault(require("./integerPropType"));
273
279
 
280
+ var _resolveProps = _interopRequireDefault(require("./resolveProps"));
281
+
274
282
  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); }
275
283
 
276
284
  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; }
@@ -1,7 +1,7 @@
1
- export function getTypeByValue(value: any): any;
2
- declare function _default(props: any, propName: any, ...other: any[]): RangeError | null;
3
- declare namespace _default {
4
- export { requiredInteger as isRequired };
5
- }
6
- export default _default;
7
- declare function requiredInteger(props: any, propName: any, componentName: any, location: any): RangeError | null;
1
+ export function getTypeByValue(value: any): any;
2
+ declare function _default(props: any, propName: any, ...other: any[]): RangeError | null;
3
+ declare namespace _default {
4
+ export { requiredInteger as isRequired };
5
+ }
6
+ export default _default;
7
+ declare function requiredInteger(props: any, propName: any, componentName: any, location: any): RangeError | null;
package/isMuiElement.d.ts CHANGED
@@ -1 +1 @@
1
- export default function isMuiElement(element: any, muiNames: readonly string[]): boolean;
1
+ export default function isMuiElement(element: any, muiNames: readonly string[]): boolean;
package/legacy/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.2.2
1
+ /** @license MUI v5.4.2
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -34,4 +34,5 @@ export { default as unstable_getScrollbarSize } from './getScrollbarSize';
34
34
  export { detectScrollType as unstable_detectScrollType, getNormalizedScrollLeft as unstable_getNormalizedScrollLeft } from './scrollLeft';
35
35
  export { default as usePreviousProps } from './usePreviousProps';
36
36
  export { default as visuallyHidden } from './visuallyHidden';
37
- export { default as integerPropType } from './integerPropType';
37
+ export { default as integerPropType } from './integerPropType';
38
+ export { default as internal_resolveProps } from './resolveProps';
@@ -0,0 +1,18 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+
3
+ /**
4
+ * Add keys, values of `defaultProps` that does not exist in `props`
5
+ * @param {object} defaultProps
6
+ * @param {object} props
7
+ * @returns {object} resolved props
8
+ */
9
+ export default function resolveProps(defaultProps, props) {
10
+ var output = _extends({}, props);
11
+
12
+ Object.keys(defaultProps).forEach(function (propName) {
13
+ if (output[propName] === undefined) {
14
+ output[propName] = defaultProps[propName];
15
+ }
16
+ });
17
+ return output;
18
+ }
package/legacy/setRef.js CHANGED
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * WARNING: Be sure to only call this inside a callback that is passed as a ref.
7
7
  * Otherwise, make sure to cleanup the previous {ref} if it changes. See
8
- * https://github.com/mui-org/material-ui/issues/13539
8
+ * https://github.com/mui/material-ui/issues/13539
9
9
  *
10
10
  * Useful if you want to expose the ref of an inner component to the public API
11
11
  * while still using it inside the component.
package/legacy/useId.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as React from 'react';
2
2
  var globalId = 0;
3
- export default function useId(idOverride) {
3
+
4
+ function useGlobalId(idOverride) {
4
5
  var _React$useState = React.useState(idOverride),
5
6
  defaultId = _React$useState[0],
6
7
  setDefaultId = _React$useState[1];
@@ -17,4 +18,23 @@ export default function useId(idOverride) {
17
18
  }
18
19
  }, [defaultId]);
19
20
  return id;
21
+ } // eslint-disable-next-line no-useless-concat -- Workaround for https://github.com/webpack/webpack/issues/14814
22
+
23
+
24
+ var maybeReactUseId = React['useId' + ''];
25
+ /**
26
+ *
27
+ * @example <div id={useId()} />
28
+ * @param idOverride
29
+ * @returns {string}
30
+ */
31
+
32
+ export default function useId(idOverride) {
33
+ if (maybeReactUseId !== undefined) {
34
+ var reactId = maybeReactUseId();
35
+ return idOverride != null ? idOverride : reactId;
36
+ } // eslint-disable-next-line react-hooks/rules-of-hooks -- `React.useId` is invariant at runtime.
37
+
38
+
39
+ return useGlobalId(idOverride);
20
40
  }
package/modern/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /** @license MUI v5.2.2
1
+ /** @license MUI v5.4.2
2
2
  *
3
3
  * This source code is licensed under the MIT license found in the
4
4
  * LICENSE file in the root directory of this source tree.
@@ -34,4 +34,5 @@ export { default as unstable_getScrollbarSize } from './getScrollbarSize';
34
34
  export { detectScrollType as unstable_detectScrollType, getNormalizedScrollLeft as unstable_getNormalizedScrollLeft } from './scrollLeft';
35
35
  export { default as usePreviousProps } from './usePreviousProps';
36
36
  export { default as visuallyHidden } from './visuallyHidden';
37
- export { default as integerPropType } from './integerPropType';
37
+ export { default as integerPropType } from './integerPropType';
38
+ export { default as internal_resolveProps } from './resolveProps';
@@ -0,0 +1,18 @@
1
+ import _extends from "@babel/runtime/helpers/esm/extends";
2
+
3
+ /**
4
+ * Add keys, values of `defaultProps` that does not exist in `props`
5
+ * @param {object} defaultProps
6
+ * @param {object} props
7
+ * @returns {object} resolved props
8
+ */
9
+ export default function resolveProps(defaultProps, props) {
10
+ const output = _extends({}, props);
11
+
12
+ Object.keys(defaultProps).forEach(propName => {
13
+ if (output[propName] === undefined) {
14
+ output[propName] = defaultProps[propName];
15
+ }
16
+ });
17
+ return output;
18
+ }
package/modern/setRef.js CHANGED
@@ -5,7 +5,7 @@
5
5
  *
6
6
  * WARNING: Be sure to only call this inside a callback that is passed as a ref.
7
7
  * Otherwise, make sure to cleanup the previous {ref} if it changes. See
8
- * https://github.com/mui-org/material-ui/issues/13539
8
+ * https://github.com/mui/material-ui/issues/13539
9
9
  *
10
10
  * Useful if you want to expose the ref of an inner component to the public API
11
11
  * while still using it inside the component.
package/modern/useId.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as React from 'react';
2
2
  let globalId = 0;
3
- export default function useId(idOverride) {
3
+
4
+ function useGlobalId(idOverride) {
4
5
  const [defaultId, setDefaultId] = React.useState(idOverride);
5
6
  const id = idOverride || defaultId;
6
7
  React.useEffect(() => {
@@ -14,4 +15,23 @@ export default function useId(idOverride) {
14
15
  }
15
16
  }, [defaultId]);
16
17
  return id;
18
+ } // eslint-disable-next-line no-useless-concat -- Workaround for https://github.com/webpack/webpack/issues/14814
19
+
20
+
21
+ const maybeReactUseId = React['useId' + ''];
22
+ /**
23
+ *
24
+ * @example <div id={useId()} />
25
+ * @param idOverride
26
+ * @returns {string}
27
+ */
28
+
29
+ export default function useId(idOverride) {
30
+ if (maybeReactUseId !== undefined) {
31
+ const reactId = maybeReactUseId();
32
+ return idOverride ?? reactId;
33
+ } // eslint-disable-next-line react-hooks/rules-of-hooks -- `React.useId` is invariant at runtime.
34
+
35
+
36
+ return useGlobalId(idOverride);
17
37
  }
@@ -1 +1 @@
1
- export default function ownerDocument(node: Node | null | undefined): Document;
1
+ export default function ownerDocument(node: Node | null | undefined): Document;
package/ownerWindow.d.ts CHANGED
@@ -1 +1 @@
1
- export default function ownerWindow(node: Node | undefined): Window;
1
+ export default function ownerWindow(node: Node | undefined): Window;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mui/utils",
3
- "version": "5.2.2",
3
+ "version": "5.4.2",
4
4
  "private": false,
5
5
  "author": "MUI Team",
6
6
  "description": "Utility functions for React components.",
@@ -13,19 +13,23 @@
13
13
  ],
14
14
  "repository": {
15
15
  "type": "git",
16
- "url": "https://github.com/mui-org/material-ui.git",
16
+ "url": "https://github.com/mui/material-ui.git",
17
17
  "directory": "packages/mui-utils"
18
18
  },
19
19
  "license": "MIT",
20
20
  "bugs": {
21
- "url": "https://github.com/mui-org/material-ui/issues"
21
+ "url": "https://github.com/mui/material-ui/issues"
22
+ },
23
+ "homepage": "https://github.com/mui/material-ui/tree/master/packages/mui-utils",
24
+ "funding": {
25
+ "type": "opencollective",
26
+ "url": "https://opencollective.com/mui"
22
27
  },
23
- "homepage": "https://github.com/mui-org/material-ui/tree/master/packages/mui-utils",
24
28
  "peerDependencies": {
25
- "react": "^17.0.2"
29
+ "react": "^17.0.0"
26
30
  },
27
31
  "dependencies": {
28
- "@babel/runtime": "^7.16.3",
32
+ "@babel/runtime": "^7.17.0",
29
33
  "@types/prop-types": "^15.7.4",
30
34
  "@types/react-is": "^16.7.1 || ^17.0.0",
31
35
  "prop-types": "^15.7.2",
@@ -1,2 +1,2 @@
1
- declare const _default: any;
2
- export default _default;
1
+ declare const _default: any;
2
+ export default _default;
package/refType.d.ts CHANGED
@@ -1,3 +1,3 @@
1
- import PropTypes from 'prop-types';
2
- declare const refType: PropTypes.Requireable<object>;
3
- export default refType;
1
+ import PropTypes from 'prop-types';
2
+ declare const refType: PropTypes.Requireable<object>;
3
+ export default refType;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Add keys, values of `defaultProps` that does not exist in `props`
3
+ * @param {object} defaultProps
4
+ * @param {object} props
5
+ * @returns {object} resolved props
6
+ */
7
+ export default function resolveProps<T extends {
8
+ className?: string;
9
+ } & Record<string, unknown>>(defaultProps: T, props: T): T;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = resolveProps;
9
+
10
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
+
12
+ /**
13
+ * Add keys, values of `defaultProps` that does not exist in `props`
14
+ * @param {object} defaultProps
15
+ * @param {object} props
16
+ * @returns {object} resolved props
17
+ */
18
+ function resolveProps(defaultProps, props) {
19
+ const output = (0, _extends2.default)({}, props);
20
+ Object.keys(defaultProps).forEach(propName => {
21
+ if (output[propName] === undefined) {
22
+ output[propName] = defaultProps[propName];
23
+ }
24
+ });
25
+ return output;
26
+ }
package/setRef.d.ts CHANGED
@@ -1,15 +1,15 @@
1
- import * as React from 'react';
2
- /**
3
- * TODO v5: consider making it private
4
- *
5
- * passes {value} to {ref}
6
- *
7
- * WARNING: Be sure to only call this inside a callback that is passed as a ref.
8
- * Otherwise, make sure to cleanup the previous {ref} if it changes. See
9
- * https://github.com/mui-org/material-ui/issues/13539
10
- *
11
- * Useful if you want to expose the ref of an inner component to the public API
12
- * while still using it inside the component.
13
- * @param ref A ref callback or ref object. If anything falsy, this is a no-op.
14
- */
15
- export default function setRef<T>(ref: React.MutableRefObject<T | null> | ((instance: T | null) => void) | null | undefined, value: T | null): void;
1
+ import * as React from 'react';
2
+ /**
3
+ * TODO v5: consider making it private
4
+ *
5
+ * passes {value} to {ref}
6
+ *
7
+ * WARNING: Be sure to only call this inside a callback that is passed as a ref.
8
+ * Otherwise, make sure to cleanup the previous {ref} if it changes. See
9
+ * https://github.com/mui/material-ui/issues/13539
10
+ *
11
+ * Useful if you want to expose the ref of an inner component to the public API
12
+ * while still using it inside the component.
13
+ * @param ref A ref callback or ref object. If anything falsy, this is a no-op.
14
+ */
15
+ export default function setRef<T>(ref: React.MutableRefObject<T | null> | ((instance: T | null) => void) | null | undefined, value: T | null): void;
package/setRef.js CHANGED
@@ -12,7 +12,7 @@ exports.default = setRef;
12
12
  *
13
13
  * WARNING: Be sure to only call this inside a callback that is passed as a ref.
14
14
  * Otherwise, make sure to cleanup the previous {ref} if it changes. See
15
- * https://github.com/mui-org/material-ui/issues/13539
15
+ * https://github.com/mui/material-ui/issues/13539
16
16
  *
17
17
  * Useful if you want to expose the ref of an inner component to the public API
18
18
  * while still using it inside the component.
@@ -1,4 +1,4 @@
1
- /**
2
- * https://github.com/facebook/react/issues/14099#issuecomment-440013892
3
- */
4
- export default function useEventCallback<Args extends unknown[], Return>(fn: (...args: Args) => Return): (...args: Args) => Return;
1
+ /**
2
+ * https://github.com/facebook/react/issues/14099#issuecomment-440013892
3
+ */
4
+ export default function useEventCallback<Args extends unknown[], Return>(fn: (...args: Args) => Return): (...args: Args) => Return;
@@ -1 +1 @@
1
- export {};
1
+ export {};
package/useForkRef.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import * as React from 'react';
2
- export default function useForkRef<Instance>(refA: React.Ref<Instance> | null | undefined, refB: React.Ref<Instance> | null | undefined): React.Ref<Instance> | null;
1
+ import * as React from 'react';
2
+ export default function useForkRef<Instance>(refA: React.Ref<Instance> | null | undefined, refB: React.Ref<Instance> | null | undefined): React.Ref<Instance> | null;
package/useId.d.ts CHANGED
@@ -1 +1,7 @@
1
- export default function useId(idOverride?: string): string | undefined;
1
+ /**
2
+ *
3
+ * @example <div id={useId()} />
4
+ * @param idOverride
5
+ * @returns {string}
6
+ */
7
+ export default function useId(idOverride?: string): string | undefined;