@mui/utils 7.0.0 → 7.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +100 -0
- package/esm/index.js +1 -1
- package/esm/useForkRef/useForkRef.d.ts +1 -2
- package/esm/useForkRef/useForkRef.js +32 -12
- package/index.js +1 -1
- package/modern/useForkRef/useForkRef.d.ts +1 -2
- package/package.json +4 -12
- package/useForkRef/useForkRef.d.ts +1 -2
- package/useForkRef/useForkRef.js +32 -13
- package/modern/ClassNameGenerator/ClassNameGenerator.js +0 -17
- package/modern/ClassNameGenerator/index.js +0 -1
- package/modern/HTMLElementType/HTMLElementType.js +0 -14
- package/modern/HTMLElementType/index.js +0 -1
- package/modern/appendOwnerState/appendOwnerState.js +0 -28
- package/modern/appendOwnerState/index.js +0 -1
- package/modern/capitalize/capitalize.js +0 -11
- package/modern/capitalize/index.js +0 -1
- package/modern/chainPropTypes/chainPropTypes.js +0 -8
- package/modern/chainPropTypes/index.js +0 -1
- package/modern/clamp/clamp.js +0 -4
- package/modern/clamp/index.js +0 -1
- package/modern/composeClasses/composeClasses.js +0 -53
- package/modern/composeClasses/index.js +0 -1
- package/modern/createChainedFunction/createChainedFunction.js +0 -17
- package/modern/createChainedFunction/index.js +0 -1
- package/modern/debounce/debounce.js +0 -17
- package/modern/debounce/index.js +0 -2
- package/modern/deepmerge/deepmerge.js +0 -64
- package/modern/deepmerge/index.js +0 -2
- package/modern/deprecatedPropType/deprecatedPropType.js +0 -13
- package/modern/deprecatedPropType/index.js +0 -1
- package/modern/elementAcceptingRef/elementAcceptingRef.js +0 -42
- package/modern/elementAcceptingRef/index.js +0 -1
- package/modern/elementTypeAcceptingRef/elementTypeAcceptingRef.js +0 -40
- package/modern/elementTypeAcceptingRef/index.js +0 -1
- package/modern/exactProp/exactProp.js +0 -20
- package/modern/exactProp/index.js +0 -1
- package/modern/extractEventHandlers/extractEventHandlers.js +0 -18
- package/modern/extractEventHandlers/index.js +0 -1
- package/modern/formatMuiErrorMessage/formatMuiErrorMessage.js +0 -15
- package/modern/formatMuiErrorMessage/index.js +0 -1
- package/modern/generateUtilityClass/generateUtilityClass.js +0 -22
- package/modern/generateUtilityClass/index.js +0 -2
- package/modern/generateUtilityClasses/generateUtilityClasses.js +0 -8
- package/modern/generateUtilityClasses/index.js +0 -1
- package/modern/getDisplayName/getDisplayName.js +0 -38
- package/modern/getDisplayName/index.js +0 -1
- package/modern/getReactElementRef/getReactElementRef.js +0 -18
- package/modern/getReactElementRef/index.js +0 -1
- package/modern/getReactNodeRef/getReactNodeRef.js +0 -23
- package/modern/getReactNodeRef/index.js +0 -1
- package/modern/getScrollbarSize/getScrollbarSize.js +0 -7
- package/modern/getScrollbarSize/index.js +0 -1
- package/modern/getValidReactChildren/getValidReactChildren.js +0 -11
- package/modern/getValidReactChildren/index.js +0 -1
- package/modern/index.js +0 -57
- package/modern/integerPropType/index.js +0 -2
- package/modern/integerPropType/integerPropType.js +0 -44
- package/modern/isFocusVisible/index.js +0 -1
- package/modern/isFocusVisible/isFocusVisible.js +0 -15
- package/modern/isHostComponent/index.js +0 -1
- package/modern/isHostComponent/isHostComponent.js +0 -7
- package/modern/isMuiElement/index.js +0 -1
- package/modern/isMuiElement/isMuiElement.js +0 -8
- package/modern/mergeSlotProps/index.js +0 -1
- package/modern/mergeSlotProps/mergeSlotProps.js +0 -90
- package/modern/omitEventHandlers/index.js +0 -1
- package/modern/omitEventHandlers/omitEventHandlers.js +0 -18
- package/modern/ownerDocument/index.js +0 -1
- package/modern/ownerDocument/ownerDocument.js +0 -3
- package/modern/ownerWindow/index.js +0 -1
- package/modern/ownerWindow/ownerWindow.js +0 -5
- package/modern/package.json +0 -1
- package/modern/ponyfillGlobal/index.js +0 -1
- package/modern/ponyfillGlobal/ponyfillGlobal.js +0 -6
- package/modern/refType/index.js +0 -1
- package/modern/refType/refType.js +0 -3
- package/modern/requirePropFactory/index.js +0 -1
- package/modern/requirePropFactory/requirePropFactory.js +0 -25
- package/modern/resolveComponentProps/index.js +0 -1
- package/modern/resolveComponentProps/resolveComponentProps.js +0 -11
- package/modern/resolveProps/index.js +0 -1
- package/modern/resolveProps/resolveProps.js +0 -43
- package/modern/setRef/index.js +0 -1
- package/modern/setRef/setRef.js +0 -20
- package/modern/types/index.js +0 -1
- package/modern/unsupportedProp/index.js +0 -1
- package/modern/unsupportedProp/unsupportedProp.js +0 -10
- package/modern/useControlled/index.js +0 -1
- package/modern/useControlled/useControlled.js +0 -41
- package/modern/useEnhancedEffect/index.js +0 -1
- package/modern/useEnhancedEffect/useEnhancedEffect.js +0 -13
- package/modern/useEventCallback/index.js +0 -1
- package/modern/useEventCallback/useEventCallback.js +0 -20
- package/modern/useForkRef/index.js +0 -1
- package/modern/useForkRef/useForkRef.js +0 -40
- package/modern/useId/index.js +0 -1
- package/modern/useId/useId.js +0 -45
- package/modern/useIsFocusVisible/index.js +0 -2
- package/modern/useIsFocusVisible/useIsFocusVisible.js +0 -163
- package/modern/useLazyRef/index.js +0 -1
- package/modern/useLazyRef/useLazyRef.js +0 -19
- package/modern/useLocalStorageState/index.js +0 -1
- package/modern/useLocalStorageState/useLocalStorageState.js +0 -108
- package/modern/useOnMount/index.js +0 -1
- package/modern/useOnMount/useOnMount.js +0 -14
- package/modern/usePreviousProps/index.js +0 -1
- package/modern/usePreviousProps/usePreviousProps.js +0 -11
- package/modern/useSlotProps/index.js +0 -1
- package/modern/useSlotProps/useSlotProps.js +0 -38
- package/modern/useTimeout/index.js +0 -2
- package/modern/useTimeout/useTimeout.js +0 -35
- package/modern/visuallyHidden/index.js +0 -1
- package/modern/visuallyHidden/visuallyHidden.js +0 -12
- package/tsconfig.build.tsbuildinfo +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,105 @@
|
|
|
1
1
|
# [Versions](https://mui.com/versions/)
|
|
2
2
|
|
|
3
|
+
## 7.0.2
|
|
4
|
+
|
|
5
|
+
_Apr 9, 2025_
|
|
6
|
+
|
|
7
|
+
A big thanks to the 12 contributors who made this release possible.
|
|
8
|
+
|
|
9
|
+
### `@mui/material@7.0.2`
|
|
10
|
+
|
|
11
|
+
- [Autocomplete] Add ability to render custom single value (#45387) @ZeeshanTamboli
|
|
12
|
+
- [Autocomplete] Prevent shrink animation in controlled Autocomplete when initial `value` is provided (#45734) @imadx
|
|
13
|
+
- [AvatarGroup] Fix `spacing` prop ignoring value `0` (#45799) @Kartik-Murthy
|
|
14
|
+
- [Dialog] Deprecate composed classes (#45418) @sai6855
|
|
15
|
+
|
|
16
|
+
### `@mui/material-nextjs@7.0.2`
|
|
17
|
+
|
|
18
|
+
- Fix nonce issues (#45794) @Janpot
|
|
19
|
+
- Add warnings to nextjs router integration (#45778) @Janpot
|
|
20
|
+
|
|
21
|
+
### `@mui/styled-engine@7.0.2`
|
|
22
|
+
|
|
23
|
+
- Added caching to `StyledEngineProvider` to improve performance for running tests with Jest (#45846) @siriwatknp
|
|
24
|
+
|
|
25
|
+
### Core
|
|
26
|
+
|
|
27
|
+
- [blog] Improve upvote video (0646444) @oliviertassinari
|
|
28
|
+
- [code-infra] Remove webpack aliases (#45841) @Janpot
|
|
29
|
+
- [code-infra] Remove .tsbuildinfo from build folder (#45727) @Janpot
|
|
30
|
+
- [code-infra] Stabilize theme viewer screenshot tests (#45768) @Janpot
|
|
31
|
+
- [code-infra] Remove modern bundles (#45808) @Janpot
|
|
32
|
+
- Update buildTypes script to optionally remove css imports (#45835) @brijeshb42
|
|
33
|
+
- Allow repo to be accepted as an argument for releaseTag (#45801) @brijeshb42
|
|
34
|
+
- Update scripts to support base-ui (#45784) @brijeshb42
|
|
35
|
+
- Sync scorecards.yml across codebase (4de5076) @oliviertassinari
|
|
36
|
+
- Remove baseUrl and skipLibCheck (#45806) @Janpot
|
|
37
|
+
- [docs-infra] Fix redirect styles pages (#45848) @siriwatknp
|
|
38
|
+
- [docs-infra] Remove false-positive Vale rules (#45843) @oliviertassinari
|
|
39
|
+
- [docs-infra] Make sure Next.js can find package.json through its aliases (#45840) @Janpot
|
|
40
|
+
- [docs-infra] Fix Next.js brand name coverage (6915f8d) @oliviertassinari
|
|
41
|
+
- [docs-infra] Fix layout shift between MIT and commercial pages (#45760) @oliviertassinari
|
|
42
|
+
- [docs-infra] Non breaking space for ESM (#45758) @oliviertassinari
|
|
43
|
+
- [support-infra] Remove dead 'workflow_call:' (#45736) @oliviertassinari
|
|
44
|
+
- [utils] Support cleanup callbacks in useForkRef (#45621) @DiegoAndai
|
|
45
|
+
|
|
46
|
+
### Docs
|
|
47
|
+
|
|
48
|
+
- Fix pigment vite integration example (#44746) @brijeshb42
|
|
49
|
+
- Update migration instructions and codemod references for deprecated APIs (#45793) @sai6855
|
|
50
|
+
- Add TanStack Router routing example (#44930) @vetledv
|
|
51
|
+
- Fix layout shifting in icons page (#45779) @sai6855
|
|
52
|
+
- Fix migration instructions (#45762) @oliviertassinari
|
|
53
|
+
- Fix wrong TypeScript support version (#45761) @oliviertassinari
|
|
54
|
+
- Fix link to mui-joy/src/styles/components.d.ts (#45763) @oliviertassinari
|
|
55
|
+
- Fix 301 link (ae94c40) @oliviertassinari
|
|
56
|
+
- Fix 301 links (abd8f63) @oliviertassinari
|
|
57
|
+
- Fix 301 redirection (c7658de) @oliviertassinari
|
|
58
|
+
- [nextjs] Migrate from deprecated "legacyBehavior" prop (#44871) @oliviertassinari
|
|
59
|
+
- [nextjs] Document CSP for Next.js Pages Router (#45798) @Grohden
|
|
60
|
+
|
|
61
|
+
All contributors of this release in alphabetical order: @brijeshb42, @DiegoAndai, @Grohden, @imadx, @Janpot, @Kartik-Murthy, @oliviertassinari, @renovate[bot], @sai6855, @siriwatknp, @vetledv, @ZeeshanTamboli
|
|
62
|
+
|
|
63
|
+
## 7.0.1
|
|
64
|
+
|
|
65
|
+
<!-- generated comparing v7.0.0..master -->
|
|
66
|
+
|
|
67
|
+
_Mar 28, 2025_
|
|
68
|
+
|
|
69
|
+
A big thanks to the 7 contributors who made this release possible.
|
|
70
|
+
|
|
71
|
+
### `@mui/material@7.0.1`
|
|
72
|
+
|
|
73
|
+
- Export ThemeProviderProps (#45701) @aarongarciah
|
|
74
|
+
- [Fab] Fix default variant text color when using CSS vars (#45714) @aarongarciah
|
|
75
|
+
- Remove mention of v7 in deprecation messages (#45708) @DiegoAndai
|
|
76
|
+
- [Popover] Allow `null` in `anchorEl` function return type (#45045) @eduter
|
|
77
|
+
- Fix missing CSSProperties/MixinOptions types (#45706) @Janpot
|
|
78
|
+
|
|
79
|
+
### `@mui/icons-material@7.0.1`
|
|
80
|
+
|
|
81
|
+
- [code-infra] Fix icon-material type resolution under `moduleResolution: "node"` (#45704) @Janpot
|
|
82
|
+
- Bring back individual icon dts (#45711) @Janpot
|
|
83
|
+
|
|
84
|
+
### Core
|
|
85
|
+
|
|
86
|
+
- Improve the release instructions (#45688) @mnajdova
|
|
87
|
+
|
|
88
|
+
### Docs
|
|
89
|
+
|
|
90
|
+
- Fix Masonry and Toolpad dark mode demos (#45721) @siriwatknp
|
|
91
|
+
- Update v7 related copy (#45716) @aarongarciah
|
|
92
|
+
- Avoid unwanted undefined in page title (#45718) @aarongarciah
|
|
93
|
+
- Fix joy templates error (#45715) @siriwatknp
|
|
94
|
+
- Rename GitHub icon import (#45709) @micttyoid
|
|
95
|
+
- Fix Safari issue in dark mode (#45696) @mnajdova
|
|
96
|
+
- Fix `Grid`, `GridLegacy`, `Stack`, `Badge`, `Select`, `Autocomplete` demos CSS variables (#45693) @DiegoAndai
|
|
97
|
+
- Add "Material UI v7 is here" to the notifications (#45694) @DiegoAndai
|
|
98
|
+
- Fix `Breadcrumbs`, `List`, `Divider`, and `Typography` dark mode demos (#45692) @siriwatknp
|
|
99
|
+
- Fix Material Icons page in dark mode (#45691) @mnajdova
|
|
100
|
+
|
|
101
|
+
All contributors of this release in alphabetical order: @aarongarciah, @DiegoAndai, @eduter, @Janpot, @micttyoid, @mnajdova, @siriwatknp
|
|
102
|
+
|
|
3
103
|
## 7.0.0
|
|
4
104
|
|
|
5
105
|
<!-- generated comparing v7.0.0-rc.0..master -->
|
package/esm/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
* This is useful when you want to have the ref used in multiple places.
|
|
3
|
+
* Merges refs into a single memoized callback ref or `null`.
|
|
5
4
|
*
|
|
6
5
|
* ```tsx
|
|
7
6
|
* const rootRef = React.useRef<Instance>(null);
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
3
|
import * as React from 'react';
|
|
4
|
-
import setRef from "../setRef/index.js";
|
|
5
4
|
|
|
6
5
|
/**
|
|
7
|
-
*
|
|
8
|
-
* This is useful when you want to have the ref used in multiple places.
|
|
6
|
+
* Merges refs into a single memoized callback ref or `null`.
|
|
9
7
|
*
|
|
10
8
|
* ```tsx
|
|
11
9
|
* const rootRef = React.useRef<Instance>(null);
|
|
@@ -20,19 +18,41 @@ import setRef from "../setRef/index.js";
|
|
|
20
18
|
* @returns {React.RefCallback<Instance> | null} The new ref callback.
|
|
21
19
|
*/
|
|
22
20
|
export default function useForkRef(...refs) {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
21
|
+
const cleanupRef = React.useRef(undefined);
|
|
22
|
+
const refEffect = React.useCallback(instance => {
|
|
23
|
+
const cleanups = refs.map(ref => {
|
|
24
|
+
if (ref == null) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
if (typeof ref === 'function') {
|
|
28
|
+
const refCallback = ref;
|
|
29
|
+
const refCleanup = refCallback(instance);
|
|
30
|
+
return typeof refCleanup === 'function' ? refCleanup : () => {
|
|
31
|
+
refCallback(null);
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
ref.current = instance;
|
|
35
|
+
return () => {
|
|
36
|
+
ref.current = null;
|
|
37
|
+
};
|
|
38
|
+
});
|
|
39
|
+
return () => {
|
|
40
|
+
cleanups.forEach(refCleanup => refCleanup?.());
|
|
41
|
+
};
|
|
42
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
43
|
+
}, refs);
|
|
28
44
|
return React.useMemo(() => {
|
|
29
45
|
if (refs.every(ref => ref == null)) {
|
|
30
46
|
return null;
|
|
31
47
|
}
|
|
32
|
-
return
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
48
|
+
return value => {
|
|
49
|
+
if (cleanupRef.current) {
|
|
50
|
+
cleanupRef.current();
|
|
51
|
+
cleanupRef.current = undefined;
|
|
52
|
+
}
|
|
53
|
+
if (value != null) {
|
|
54
|
+
cleanupRef.current = refEffect(value);
|
|
55
|
+
}
|
|
36
56
|
};
|
|
37
57
|
// TODO: uncomment once we enable eslint-plugin-react-compiler // eslint-disable-next-line react-compiler/react-compiler -- intentionally ignoring that the dependency array must be an array literal
|
|
38
58
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
package/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
* This is useful when you want to have the ref used in multiple places.
|
|
3
|
+
* Merges refs into a single memoized callback ref or `null`.
|
|
5
4
|
*
|
|
6
5
|
* ```tsx
|
|
7
6
|
* const rootRef = React.useRef<Instance>(null);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mui/utils",
|
|
3
|
-
"version": "7.0.
|
|
3
|
+
"version": "7.0.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"author": "MUI Team",
|
|
6
6
|
"description": "Utility functions for React components.",
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
"url": "https://opencollective.com/mui-org"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@babel/runtime": "^7.
|
|
29
|
+
"@babel/runtime": "^7.27.0",
|
|
30
30
|
"@types/prop-types": "^15.7.14",
|
|
31
31
|
"clsx": "^2.1.1",
|
|
32
32
|
"prop-types": "^15.8.1",
|
|
33
|
-
"react-is": "^19.
|
|
34
|
-
"@mui/types": "^7.4.
|
|
33
|
+
"react-is": "^19.1.0",
|
|
34
|
+
"@mui/types": "^7.4.1"
|
|
35
35
|
},
|
|
36
36
|
"peerDependencies": {
|
|
37
37
|
"@types/react": "^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
@@ -61,10 +61,6 @@
|
|
|
61
61
|
"import": {
|
|
62
62
|
"types": "./esm/index.d.ts",
|
|
63
63
|
"default": "./esm/index.js"
|
|
64
|
-
},
|
|
65
|
-
"mui-modern": {
|
|
66
|
-
"types": "./modern/index.d.ts",
|
|
67
|
-
"default": "./modern/index.js"
|
|
68
64
|
}
|
|
69
65
|
},
|
|
70
66
|
"./*": {
|
|
@@ -75,10 +71,6 @@
|
|
|
75
71
|
"import": {
|
|
76
72
|
"types": "./esm/*/index.d.ts",
|
|
77
73
|
"default": "./esm/*/index.js"
|
|
78
|
-
},
|
|
79
|
-
"mui-modern": {
|
|
80
|
-
"types": "./modern/*/index.d.ts",
|
|
81
|
-
"default": "./modern/*/index.js"
|
|
82
74
|
}
|
|
83
75
|
},
|
|
84
76
|
"./esm": null,
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
* This is useful when you want to have the ref used in multiple places.
|
|
3
|
+
* Merges refs into a single memoized callback ref or `null`.
|
|
5
4
|
*
|
|
6
5
|
* ```tsx
|
|
7
6
|
* const rootRef = React.useRef<Instance>(null);
|
package/useForkRef/useForkRef.js
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
'use client';
|
|
3
3
|
|
|
4
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
5
4
|
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
6
5
|
Object.defineProperty(exports, "__esModule", {
|
|
7
6
|
value: true
|
|
8
7
|
});
|
|
9
8
|
exports.default = useForkRef;
|
|
10
9
|
var React = _interopRequireWildcard(require("react"));
|
|
11
|
-
var _setRef = _interopRequireDefault(require("../setRef"));
|
|
12
10
|
/**
|
|
13
|
-
*
|
|
14
|
-
* This is useful when you want to have the ref used in multiple places.
|
|
11
|
+
* Merges refs into a single memoized callback ref or `null`.
|
|
15
12
|
*
|
|
16
13
|
* ```tsx
|
|
17
14
|
* const rootRef = React.useRef<Instance>(null);
|
|
@@ -26,19 +23,41 @@ var _setRef = _interopRequireDefault(require("../setRef"));
|
|
|
26
23
|
* @returns {React.RefCallback<Instance> | null} The new ref callback.
|
|
27
24
|
*/
|
|
28
25
|
function useForkRef(...refs) {
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
26
|
+
const cleanupRef = React.useRef(undefined);
|
|
27
|
+
const refEffect = React.useCallback(instance => {
|
|
28
|
+
const cleanups = refs.map(ref => {
|
|
29
|
+
if (ref == null) {
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
if (typeof ref === 'function') {
|
|
33
|
+
const refCallback = ref;
|
|
34
|
+
const refCleanup = refCallback(instance);
|
|
35
|
+
return typeof refCleanup === 'function' ? refCleanup : () => {
|
|
36
|
+
refCallback(null);
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
ref.current = instance;
|
|
40
|
+
return () => {
|
|
41
|
+
ref.current = null;
|
|
42
|
+
};
|
|
43
|
+
});
|
|
44
|
+
return () => {
|
|
45
|
+
cleanups.forEach(refCleanup => refCleanup?.());
|
|
46
|
+
};
|
|
47
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
48
|
+
}, refs);
|
|
34
49
|
return React.useMemo(() => {
|
|
35
50
|
if (refs.every(ref => ref == null)) {
|
|
36
51
|
return null;
|
|
37
52
|
}
|
|
38
|
-
return
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
53
|
+
return value => {
|
|
54
|
+
if (cleanupRef.current) {
|
|
55
|
+
cleanupRef.current();
|
|
56
|
+
cleanupRef.current = undefined;
|
|
57
|
+
}
|
|
58
|
+
if (value != null) {
|
|
59
|
+
cleanupRef.current = refEffect(value);
|
|
60
|
+
}
|
|
42
61
|
};
|
|
43
62
|
// TODO: uncomment once we enable eslint-plugin-react-compiler // eslint-disable-next-line react-compiler/react-compiler -- intentionally ignoring that the dependency array must be an array literal
|
|
44
63
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
const defaultGenerator = componentName => componentName;
|
|
2
|
-
const createClassNameGenerator = () => {
|
|
3
|
-
let generate = defaultGenerator;
|
|
4
|
-
return {
|
|
5
|
-
configure(generator) {
|
|
6
|
-
generate = generator;
|
|
7
|
-
},
|
|
8
|
-
generate(componentName) {
|
|
9
|
-
return generate(componentName);
|
|
10
|
-
},
|
|
11
|
-
reset() {
|
|
12
|
-
generate = defaultGenerator;
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
};
|
|
16
|
-
const ClassNameGenerator = createClassNameGenerator();
|
|
17
|
-
export default ClassNameGenerator;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./ClassNameGenerator.js";
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export default function HTMLElementType(props, propName, componentName, location, propFullName) {
|
|
2
|
-
if (process.env.NODE_ENV === 'production') {
|
|
3
|
-
return null;
|
|
4
|
-
}
|
|
5
|
-
const propValue = props[propName];
|
|
6
|
-
const safePropName = propFullName || propName;
|
|
7
|
-
if (propValue == null) {
|
|
8
|
-
return null;
|
|
9
|
-
}
|
|
10
|
-
if (propValue && propValue.nodeType !== 1) {
|
|
11
|
-
return new Error(`Invalid ${location} \`${safePropName}\` supplied to \`${componentName}\`. ` + `Expected an HTMLElement.`);
|
|
12
|
-
}
|
|
13
|
-
return null;
|
|
14
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./HTMLElementType.js";
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import isHostComponent from "../isHostComponent/index.js";
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Type of the ownerState based on the type of an element it applies to.
|
|
5
|
-
* This resolves to the provided OwnerState for React components and `undefined` for host components.
|
|
6
|
-
* Falls back to `OwnerState | undefined` when the exact type can't be determined in development time.
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* Appends the ownerState object to the props, merging with the existing one if necessary.
|
|
11
|
-
*
|
|
12
|
-
* @param elementType Type of the element that owns the `existingProps`. If the element is a DOM node or undefined, `ownerState` is not applied.
|
|
13
|
-
* @param otherProps Props of the element.
|
|
14
|
-
* @param ownerState
|
|
15
|
-
*/
|
|
16
|
-
function appendOwnerState(elementType, otherProps, ownerState) {
|
|
17
|
-
if (elementType === undefined || isHostComponent(elementType)) {
|
|
18
|
-
return otherProps;
|
|
19
|
-
}
|
|
20
|
-
return {
|
|
21
|
-
...otherProps,
|
|
22
|
-
ownerState: {
|
|
23
|
-
...otherProps.ownerState,
|
|
24
|
-
...ownerState
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
export default appendOwnerState;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./appendOwnerState.js";
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import _formatErrorMessage from "@mui/utils/formatMuiErrorMessage";
|
|
2
|
-
// It should to be noted that this function isn't equivalent to `text-transform: capitalize`.
|
|
3
|
-
//
|
|
4
|
-
// A strict capitalization should uppercase the first letter of each word in the sentence.
|
|
5
|
-
// We only handle the first word.
|
|
6
|
-
export default function capitalize(string) {
|
|
7
|
-
if (typeof string !== 'string') {
|
|
8
|
-
throw new Error(process.env.NODE_ENV !== "production" ? 'MUI: `capitalize(string)` expects a string argument.' : _formatErrorMessage(7));
|
|
9
|
-
}
|
|
10
|
-
return string.charAt(0).toUpperCase() + string.slice(1);
|
|
11
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./capitalize.js";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./chainPropTypes.js";
|
package/modern/clamp/clamp.js
DELETED
package/modern/clamp/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./clamp.js";
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/* eslint no-restricted-syntax: 0, prefer-template: 0, guard-for-in: 0
|
|
2
|
-
---
|
|
3
|
-
These rules are preventing the performance optimizations below.
|
|
4
|
-
*/
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Compose classes from multiple sources.
|
|
8
|
-
*
|
|
9
|
-
* @example
|
|
10
|
-
* ```tsx
|
|
11
|
-
* const slots = {
|
|
12
|
-
* root: ['root', 'primary'],
|
|
13
|
-
* label: ['label'],
|
|
14
|
-
* };
|
|
15
|
-
*
|
|
16
|
-
* const getUtilityClass = (slot) => `MuiButton-${slot}`;
|
|
17
|
-
*
|
|
18
|
-
* const classes = {
|
|
19
|
-
* root: 'my-root-class',
|
|
20
|
-
* };
|
|
21
|
-
*
|
|
22
|
-
* const output = composeClasses(slots, getUtilityClass, classes);
|
|
23
|
-
* // {
|
|
24
|
-
* // root: 'MuiButton-root MuiButton-primary my-root-class',
|
|
25
|
-
* // label: 'MuiButton-label',
|
|
26
|
-
* // }
|
|
27
|
-
* ```
|
|
28
|
-
*
|
|
29
|
-
* @param slots a list of classes for each possible slot
|
|
30
|
-
* @param getUtilityClass a function to resolve the class based on the slot name
|
|
31
|
-
* @param classes the input classes from props
|
|
32
|
-
* @returns the resolved classes for all slots
|
|
33
|
-
*/
|
|
34
|
-
export default function composeClasses(slots, getUtilityClass, classes = undefined) {
|
|
35
|
-
const output = {};
|
|
36
|
-
for (const slotName in slots) {
|
|
37
|
-
const slot = slots[slotName];
|
|
38
|
-
let buffer = '';
|
|
39
|
-
let start = true;
|
|
40
|
-
for (let i = 0; i < slot.length; i += 1) {
|
|
41
|
-
const value = slot[i];
|
|
42
|
-
if (value) {
|
|
43
|
-
buffer += (start === true ? '' : ' ') + getUtilityClass(value);
|
|
44
|
-
start = false;
|
|
45
|
-
if (classes && classes[value]) {
|
|
46
|
-
buffer += ' ' + classes[value];
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
output[slotName] = buffer;
|
|
51
|
-
}
|
|
52
|
-
return output;
|
|
53
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./composeClasses.js";
|
|
@@ -1,17 +0,0 @@
|
|
|
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(...funcs) {
|
|
8
|
-
return funcs.reduce((acc, func) => {
|
|
9
|
-
if (func == null) {
|
|
10
|
-
return acc;
|
|
11
|
-
}
|
|
12
|
-
return function chainedFunction(...args) {
|
|
13
|
-
acc.apply(this, args);
|
|
14
|
-
func.apply(this, args);
|
|
15
|
-
};
|
|
16
|
-
}, () => {});
|
|
17
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./createChainedFunction.js";
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
// Corresponds to 10 frames at 60 Hz.
|
|
2
|
-
// A few bytes payload overhead when lodash/debounce is ~3 kB and debounce ~300 B.
|
|
3
|
-
export default function debounce(func, wait = 166) {
|
|
4
|
-
let timeout;
|
|
5
|
-
function debounced(...args) {
|
|
6
|
-
const later = () => {
|
|
7
|
-
// @ts-ignore
|
|
8
|
-
func.apply(this, args);
|
|
9
|
-
};
|
|
10
|
-
clearTimeout(timeout);
|
|
11
|
-
timeout = setTimeout(later, wait);
|
|
12
|
-
}
|
|
13
|
-
debounced.clear = () => {
|
|
14
|
-
clearTimeout(timeout);
|
|
15
|
-
};
|
|
16
|
-
return debounced;
|
|
17
|
-
}
|
package/modern/debounce/index.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { isValidElementType } from 'react-is';
|
|
3
|
-
|
|
4
|
-
// https://github.com/sindresorhus/is-plain-obj/blob/main/index.js
|
|
5
|
-
export function isPlainObject(item) {
|
|
6
|
-
if (typeof item !== 'object' || item === null) {
|
|
7
|
-
return false;
|
|
8
|
-
}
|
|
9
|
-
const prototype = Object.getPrototypeOf(item);
|
|
10
|
-
return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in item) && !(Symbol.iterator in item);
|
|
11
|
-
}
|
|
12
|
-
function deepClone(source) {
|
|
13
|
-
if (/*#__PURE__*/React.isValidElement(source) || isValidElementType(source) || !isPlainObject(source)) {
|
|
14
|
-
return source;
|
|
15
|
-
}
|
|
16
|
-
const output = {};
|
|
17
|
-
Object.keys(source).forEach(key => {
|
|
18
|
-
output[key] = deepClone(source[key]);
|
|
19
|
-
});
|
|
20
|
-
return output;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Merge objects deeply.
|
|
25
|
-
* It will shallow copy React elements.
|
|
26
|
-
*
|
|
27
|
-
* If `options.clone` is set to `false` the source object will be merged directly into the target object.
|
|
28
|
-
*
|
|
29
|
-
* @example
|
|
30
|
-
* ```ts
|
|
31
|
-
* deepmerge({ a: { b: 1 }, d: 2 }, { a: { c: 2 }, d: 4 });
|
|
32
|
-
* // => { a: { b: 1, c: 2 }, d: 4 }
|
|
33
|
-
* ````
|
|
34
|
-
*
|
|
35
|
-
* @param target The target object.
|
|
36
|
-
* @param source The source object.
|
|
37
|
-
* @param options The merge options.
|
|
38
|
-
* @param options.clone Set to `false` to merge the source object directly into the target object.
|
|
39
|
-
* @returns The merged object.
|
|
40
|
-
*/
|
|
41
|
-
export default function deepmerge(target, source, options = {
|
|
42
|
-
clone: true
|
|
43
|
-
}) {
|
|
44
|
-
const output = options.clone ? {
|
|
45
|
-
...target
|
|
46
|
-
} : target;
|
|
47
|
-
if (isPlainObject(target) && isPlainObject(source)) {
|
|
48
|
-
Object.keys(source).forEach(key => {
|
|
49
|
-
if (/*#__PURE__*/React.isValidElement(source[key]) || isValidElementType(source[key])) {
|
|
50
|
-
output[key] = source[key];
|
|
51
|
-
} else if (isPlainObject(source[key]) &&
|
|
52
|
-
// Avoid prototype pollution
|
|
53
|
-
Object.prototype.hasOwnProperty.call(target, key) && isPlainObject(target[key])) {
|
|
54
|
-
// Since `output` is a clone of `target` and we have narrowed `target` in this block we can cast to the same type.
|
|
55
|
-
output[key] = deepmerge(target[key], source[key], options);
|
|
56
|
-
} else if (options.clone) {
|
|
57
|
-
output[key] = isPlainObject(source[key]) ? deepClone(source[key]) : source[key];
|
|
58
|
-
} else {
|
|
59
|
-
output[key] = source[key];
|
|
60
|
-
}
|
|
61
|
-
});
|
|
62
|
-
}
|
|
63
|
-
return output;
|
|
64
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export default function deprecatedPropType(validator, reason) {
|
|
2
|
-
if (process.env.NODE_ENV === 'production') {
|
|
3
|
-
return () => null;
|
|
4
|
-
}
|
|
5
|
-
return (props, propName, componentName, location, propFullName) => {
|
|
6
|
-
const componentNameSafe = componentName || '<<anonymous>>';
|
|
7
|
-
const propFullNameSafe = propFullName || propName;
|
|
8
|
-
if (typeof props[propName] !== 'undefined') {
|
|
9
|
-
return new Error(`The ${location} \`${propFullNameSafe}\` of ` + `\`${componentNameSafe}\` is deprecated. ${reason}`);
|
|
10
|
-
}
|
|
11
|
-
return null;
|
|
12
|
-
};
|
|
13
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { default } from "./deprecatedPropType.js";
|