@mui/utils 6.0.0-alpha.6 → 6.0.0-alpha.8
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 +37 -2
- package/deepmerge/deepmerge.js +3 -2
- package/exactProp/exactProp.js +3 -3
- package/index.js +1 -1
- package/modern/deepmerge/deepmerge.js +3 -2
- package/modern/exactProp/exactProp.js +3 -3
- package/modern/index.js +1 -1
- package/modern/requirePropFactory/requirePropFactory.js +3 -2
- package/modern/resolveProps/resolveProps.js +10 -4
- package/modern/useTimeout/useTimeout.js +11 -12
- package/node/deepmerge/deepmerge.js +3 -3
- package/node/exactProp/exactProp.js +3 -4
- package/node/index.js +1 -1
- package/node/requirePropFactory/requirePropFactory.js +3 -3
- package/node/resolveProps/resolveProps.js +10 -5
- package/node/useTimeout/useTimeout.js +11 -12
- package/package.json +1 -1
- package/requirePropFactory/requirePropFactory.js +3 -2
- package/resolveProps/resolveProps.js +10 -4
- package/useTimeout/useTimeout.js +11 -12
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,40 @@
|
|
|
1
1
|
# [Versions](https://mui.com/versions/)
|
|
2
2
|
|
|
3
|
+
## v6.0.0-alpha.8
|
|
4
|
+
|
|
5
|
+
<!-- generated comparing v6.0.0-alpha.7..next -->
|
|
6
|
+
|
|
7
|
+
_May 21, 2024_
|
|
8
|
+
|
|
9
|
+
A big thanks to the 7 contributors who made this release possible.
|
|
10
|
+
This release was mostly about 🐛 bug fixes and 📚 documentation improvements.
|
|
11
|
+
|
|
12
|
+
### `@mui/material@6.0.0-alpha.7`
|
|
13
|
+
|
|
14
|
+
- ​<!-- 04 -->[material-ui] Filter only valid theme palette for generating styles (#42147) @siriwatknp
|
|
15
|
+
- ​<!-- 03 -->[material-ui] Remove UMD bundle (#42172) @ZeeshanTamboli
|
|
16
|
+
- ​<!-- 02 -->[material-ui][TextField] Deprecate `*Props` props (#42062) @DiegoAndai
|
|
17
|
+
|
|
18
|
+
### Docs
|
|
19
|
+
|
|
20
|
+
- ​<!-- 08 -->[docs] Remove Base UI from the README (#42307) @danilo-leal
|
|
21
|
+
- ​<!-- 07 -->[docs][material-ui] Fix typo in style interoperability with Tailwind CSS docs (#42279) @ZeeshanTamboli
|
|
22
|
+
- ​<!-- 06 -->[docs][material-ui] Add supported browsers section to migration guide (#42194) @DiegoAndai
|
|
23
|
+
- ​<!-- 05 -->[docs][material-ui][Pagination] Clarify pagination `page` prop API (#42220) @Mandar-Pandya
|
|
24
|
+
|
|
25
|
+
### Core
|
|
26
|
+
|
|
27
|
+
- ​<!-- 12 -->[blog] Update blog post OG image (#42270) @danilo-leal
|
|
28
|
+
- ​<!-- 11 -->[blog] Update Pigment CSS post (#42266) @danilo-leal
|
|
29
|
+
- ​<!-- 10 -->[docs] Remove LocalMonero (#42224) @oliviertassinari
|
|
30
|
+
- ​<!-- 08 -->[docs-infra] Fix keyboard navigation on page tabs (#42152) @danilo-leal
|
|
31
|
+
- ​<!-- 10 -->[code-infra] Remove raw-loader (#42275) @Janpot
|
|
32
|
+
- ​<!-- 09 -->[core] Remove outdated Babel plugins (#42140) @ZeeshanTamboli
|
|
33
|
+
- ​<!-- 12 -->[core] Fix a few more key spread issues (#42168) @oliviertassinari
|
|
34
|
+
- ​<!-- 01 -->[website] Avoid duplicate simple vs. rich (#42100) @oliviertassinari
|
|
35
|
+
|
|
36
|
+
All contributors of this release in alphabetical order: @danilo-leal, @DiegoAndai, @Janpot, @Mandar-Pandya, @oliviertassinari, @siriwatknp, @ZeeshanTamboli
|
|
37
|
+
|
|
3
38
|
## v6.0.0-alpha.7
|
|
4
39
|
|
|
5
40
|
<!-- generated comparing v6.0.0-alpha.6..next -->
|
|
@@ -53,7 +88,7 @@ All contributors of this release in alphabetical order: @aarongarciah, @alexfauq
|
|
|
53
88
|
|
|
54
89
|
_May 8, 2024_
|
|
55
90
|
|
|
56
|
-
A big thanks to the 10 contributors who made this release possible.
|
|
91
|
+
A big thanks to the 10 contributors who made this release possible.
|
|
57
92
|
|
|
58
93
|
### `@mui/material@6.0.0-alpha.6`
|
|
59
94
|
|
|
@@ -101,7 +136,7 @@ All contributors of this release in alphabetical order: @aarongarciah, @danilo-l
|
|
|
101
136
|
|
|
102
137
|
_May 1, 2024_
|
|
103
138
|
|
|
104
|
-
A big thanks to the 9 contributors who made this release possible.
|
|
139
|
+
A big thanks to the 9 contributors who made this release possible.
|
|
105
140
|
|
|
106
141
|
### `@mui/material@6.0.0-alpha.5`
|
|
107
142
|
|
package/deepmerge/deepmerge.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
1
|
// https://github.com/sindresorhus/is-plain-obj/blob/main/index.js
|
|
3
2
|
export function isPlainObject(item) {
|
|
4
3
|
if (typeof item !== 'object' || item === null) {
|
|
@@ -20,7 +19,9 @@ function deepClone(source) {
|
|
|
20
19
|
export default function deepmerge(target, source, options = {
|
|
21
20
|
clone: true
|
|
22
21
|
}) {
|
|
23
|
-
const output = options.clone ?
|
|
22
|
+
const output = options.clone ? {
|
|
23
|
+
...target
|
|
24
|
+
} : target;
|
|
24
25
|
if (isPlainObject(target) && isPlainObject(source)) {
|
|
25
26
|
Object.keys(source).forEach(key => {
|
|
26
27
|
// Avoid prototype pollution
|
package/exactProp/exactProp.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
1
|
// This module is based on https://github.com/airbnb/prop-types-exact repository.
|
|
3
2
|
// However, in order to reduce the number of dependencies and to remove some extra safe checks
|
|
4
3
|
// the module was forked.
|
|
@@ -8,7 +7,8 @@ export default function exactProp(propTypes) {
|
|
|
8
7
|
if (process.env.NODE_ENV === 'production') {
|
|
9
8
|
return propTypes;
|
|
10
9
|
}
|
|
11
|
-
return
|
|
10
|
+
return {
|
|
11
|
+
...propTypes,
|
|
12
12
|
[specialProperty]: props => {
|
|
13
13
|
const unsupportedProps = Object.keys(props).filter(prop => !propTypes.hasOwnProperty(prop));
|
|
14
14
|
if (unsupportedProps.length > 0) {
|
|
@@ -16,5 +16,5 @@ export default function exactProp(propTypes) {
|
|
|
16
16
|
}
|
|
17
17
|
return null;
|
|
18
18
|
}
|
|
19
|
-
}
|
|
19
|
+
};
|
|
20
20
|
}
|
package/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
1
|
// https://github.com/sindresorhus/is-plain-obj/blob/main/index.js
|
|
3
2
|
export function isPlainObject(item) {
|
|
4
3
|
if (typeof item !== 'object' || item === null) {
|
|
@@ -20,7 +19,9 @@ function deepClone(source) {
|
|
|
20
19
|
export default function deepmerge(target, source, options = {
|
|
21
20
|
clone: true
|
|
22
21
|
}) {
|
|
23
|
-
const output = options.clone ?
|
|
22
|
+
const output = options.clone ? {
|
|
23
|
+
...target
|
|
24
|
+
} : target;
|
|
24
25
|
if (isPlainObject(target) && isPlainObject(source)) {
|
|
25
26
|
Object.keys(source).forEach(key => {
|
|
26
27
|
// Avoid prototype pollution
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
1
|
// This module is based on https://github.com/airbnb/prop-types-exact repository.
|
|
3
2
|
// However, in order to reduce the number of dependencies and to remove some extra safe checks
|
|
4
3
|
// the module was forked.
|
|
@@ -8,7 +7,8 @@ export default function exactProp(propTypes) {
|
|
|
8
7
|
if (process.env.NODE_ENV === 'production') {
|
|
9
8
|
return propTypes;
|
|
10
9
|
}
|
|
11
|
-
return
|
|
10
|
+
return {
|
|
11
|
+
...propTypes,
|
|
12
12
|
[specialProperty]: props => {
|
|
13
13
|
const unsupportedProps = Object.keys(props).filter(prop => !propTypes.hasOwnProperty(prop));
|
|
14
14
|
if (unsupportedProps.length > 0) {
|
|
@@ -16,5 +16,5 @@ export default function exactProp(propTypes) {
|
|
|
16
16
|
}
|
|
17
17
|
return null;
|
|
18
18
|
}
|
|
19
|
-
}
|
|
19
|
+
};
|
|
20
20
|
}
|
package/modern/index.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
1
|
export default function requirePropFactory(componentNameInError, Component) {
|
|
3
2
|
if (process.env.NODE_ENV === 'production') {
|
|
4
3
|
return () => null;
|
|
5
4
|
}
|
|
6
5
|
|
|
7
6
|
// eslint-disable-next-line react/forbid-foreign-prop-types
|
|
8
|
-
const prevPropTypes = Component ?
|
|
7
|
+
const prevPropTypes = Component ? {
|
|
8
|
+
...Component.propTypes
|
|
9
|
+
} : null;
|
|
9
10
|
const requireProp = requiredProp => (props, propName, componentName, location, propFullName, ...args) => {
|
|
10
11
|
const propFullNameSafe = propFullName || propName;
|
|
11
12
|
const defaultTypeChecker = prevPropTypes?.[propFullNameSafe];
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
1
|
/**
|
|
3
2
|
* Add keys, values of `defaultProps` that does not exist in `props`
|
|
4
3
|
* @param {object} defaultProps
|
|
@@ -6,10 +5,15 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
6
5
|
* @returns {object} resolved props
|
|
7
6
|
*/
|
|
8
7
|
export default function resolveProps(defaultProps, props) {
|
|
9
|
-
const output =
|
|
8
|
+
const output = {
|
|
9
|
+
...props
|
|
10
|
+
};
|
|
10
11
|
Object.keys(defaultProps).forEach(propName => {
|
|
11
12
|
if (propName.toString().match(/^(components|slots)$/)) {
|
|
12
|
-
output[propName] =
|
|
13
|
+
output[propName] = {
|
|
14
|
+
...defaultProps[propName],
|
|
15
|
+
...output[propName]
|
|
16
|
+
};
|
|
13
17
|
} else if (propName.toString().match(/^(componentsProps|slotProps)$/)) {
|
|
14
18
|
const defaultSlotProps = defaultProps[propName] || {};
|
|
15
19
|
const slotProps = props[propName];
|
|
@@ -21,7 +25,9 @@ export default function resolveProps(defaultProps, props) {
|
|
|
21
25
|
// Reduce the iteration if the default slot props is empty
|
|
22
26
|
output[propName] = slotProps;
|
|
23
27
|
} else {
|
|
24
|
-
output[propName] =
|
|
28
|
+
output[propName] = {
|
|
29
|
+
...slotProps
|
|
30
|
+
};
|
|
25
31
|
Object.keys(defaultSlotProps).forEach(slotPropName => {
|
|
26
32
|
output[propName][slotPropName] = resolveProps(defaultSlotProps[slotPropName], slotProps[slotPropName]);
|
|
27
33
|
});
|
|
@@ -3,21 +3,11 @@
|
|
|
3
3
|
import useLazyRef from '../useLazyRef/useLazyRef';
|
|
4
4
|
import useOnMount from '../useOnMount/useOnMount';
|
|
5
5
|
export class Timeout {
|
|
6
|
-
constructor() {
|
|
7
|
-
this.currentId = null;
|
|
8
|
-
this.clear = () => {
|
|
9
|
-
if (this.currentId !== null) {
|
|
10
|
-
clearTimeout(this.currentId);
|
|
11
|
-
this.currentId = null;
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
this.disposeEffect = () => {
|
|
15
|
-
return this.clear;
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
6
|
static create() {
|
|
19
7
|
return new Timeout();
|
|
20
8
|
}
|
|
9
|
+
currentId = null;
|
|
10
|
+
|
|
21
11
|
/**
|
|
22
12
|
* Executes `fn` after `delay`, clearing any previously scheduled call.
|
|
23
13
|
*/
|
|
@@ -28,6 +18,15 @@ export class Timeout {
|
|
|
28
18
|
fn();
|
|
29
19
|
}, delay);
|
|
30
20
|
}
|
|
21
|
+
clear = () => {
|
|
22
|
+
if (this.currentId !== null) {
|
|
23
|
+
clearTimeout(this.currentId);
|
|
24
|
+
this.currentId = null;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
disposeEffect = () => {
|
|
28
|
+
return this.clear;
|
|
29
|
+
};
|
|
31
30
|
}
|
|
32
31
|
export default function useTimeout() {
|
|
33
32
|
const timeout = useLazyRef(Timeout.create).current;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.default = deepmerge;
|
|
8
7
|
exports.isPlainObject = isPlainObject;
|
|
9
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
8
|
// https://github.com/sindresorhus/is-plain-obj/blob/main/index.js
|
|
11
9
|
function isPlainObject(item) {
|
|
12
10
|
if (typeof item !== 'object' || item === null) {
|
|
@@ -28,7 +26,9 @@ function deepClone(source) {
|
|
|
28
26
|
function deepmerge(target, source, options = {
|
|
29
27
|
clone: true
|
|
30
28
|
}) {
|
|
31
|
-
const output = options.clone ?
|
|
29
|
+
const output = options.clone ? {
|
|
30
|
+
...target
|
|
31
|
+
} : target;
|
|
32
32
|
if (isPlainObject(target) && isPlainObject(source)) {
|
|
33
33
|
Object.keys(source).forEach(key => {
|
|
34
34
|
// Avoid prototype pollution
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.default = exactProp;
|
|
8
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
7
|
// This module is based on https://github.com/airbnb/prop-types-exact repository.
|
|
10
8
|
// However, in order to reduce the number of dependencies and to remove some extra safe checks
|
|
11
9
|
// the module was forked.
|
|
@@ -15,7 +13,8 @@ function exactProp(propTypes) {
|
|
|
15
13
|
if (process.env.NODE_ENV === 'production') {
|
|
16
14
|
return propTypes;
|
|
17
15
|
}
|
|
18
|
-
return
|
|
16
|
+
return {
|
|
17
|
+
...propTypes,
|
|
19
18
|
[specialProperty]: props => {
|
|
20
19
|
const unsupportedProps = Object.keys(props).filter(prop => !propTypes.hasOwnProperty(prop));
|
|
21
20
|
if (unsupportedProps.length > 0) {
|
|
@@ -23,5 +22,5 @@ function exactProp(propTypes) {
|
|
|
23
22
|
}
|
|
24
23
|
return null;
|
|
25
24
|
}
|
|
26
|
-
}
|
|
25
|
+
};
|
|
27
26
|
}
|
package/node/index.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.default = requirePropFactory;
|
|
8
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
7
|
function requirePropFactory(componentNameInError, Component) {
|
|
10
8
|
if (process.env.NODE_ENV === 'production') {
|
|
11
9
|
return () => null;
|
|
12
10
|
}
|
|
13
11
|
|
|
14
12
|
// eslint-disable-next-line react/forbid-foreign-prop-types
|
|
15
|
-
const prevPropTypes = Component ?
|
|
13
|
+
const prevPropTypes = Component ? {
|
|
14
|
+
...Component.propTypes
|
|
15
|
+
} : null;
|
|
16
16
|
const requireProp = requiredProp => (props, propName, componentName, location, propFullName, ...args) => {
|
|
17
17
|
const propFullNameSafe = propFullName || propName;
|
|
18
18
|
const defaultTypeChecker = prevPropTypes == null ? void 0 : prevPropTypes[propFullNameSafe];
|
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports.default = resolveProps;
|
|
8
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
9
7
|
/**
|
|
10
8
|
* Add keys, values of `defaultProps` that does not exist in `props`
|
|
11
9
|
* @param {object} defaultProps
|
|
@@ -13,10 +11,15 @@ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")
|
|
|
13
11
|
* @returns {object} resolved props
|
|
14
12
|
*/
|
|
15
13
|
function resolveProps(defaultProps, props) {
|
|
16
|
-
const output =
|
|
14
|
+
const output = {
|
|
15
|
+
...props
|
|
16
|
+
};
|
|
17
17
|
Object.keys(defaultProps).forEach(propName => {
|
|
18
18
|
if (propName.toString().match(/^(components|slots)$/)) {
|
|
19
|
-
output[propName] =
|
|
19
|
+
output[propName] = {
|
|
20
|
+
...defaultProps[propName],
|
|
21
|
+
...output[propName]
|
|
22
|
+
};
|
|
20
23
|
} else if (propName.toString().match(/^(componentsProps|slotProps)$/)) {
|
|
21
24
|
const defaultSlotProps = defaultProps[propName] || {};
|
|
22
25
|
const slotProps = props[propName];
|
|
@@ -28,7 +31,9 @@ function resolveProps(defaultProps, props) {
|
|
|
28
31
|
// Reduce the iteration if the default slot props is empty
|
|
29
32
|
output[propName] = slotProps;
|
|
30
33
|
} else {
|
|
31
|
-
output[propName] =
|
|
34
|
+
output[propName] = {
|
|
35
|
+
...slotProps
|
|
36
|
+
};
|
|
32
37
|
Object.keys(defaultSlotProps).forEach(slotPropName => {
|
|
33
38
|
output[propName][slotPropName] = resolveProps(defaultSlotProps[slotPropName], slotProps[slotPropName]);
|
|
34
39
|
});
|
|
@@ -10,21 +10,11 @@ exports.default = useTimeout;
|
|
|
10
10
|
var _useLazyRef = _interopRequireDefault(require("../useLazyRef/useLazyRef"));
|
|
11
11
|
var _useOnMount = _interopRequireDefault(require("../useOnMount/useOnMount"));
|
|
12
12
|
class Timeout {
|
|
13
|
-
constructor() {
|
|
14
|
-
this.currentId = null;
|
|
15
|
-
this.clear = () => {
|
|
16
|
-
if (this.currentId !== null) {
|
|
17
|
-
clearTimeout(this.currentId);
|
|
18
|
-
this.currentId = null;
|
|
19
|
-
}
|
|
20
|
-
};
|
|
21
|
-
this.disposeEffect = () => {
|
|
22
|
-
return this.clear;
|
|
23
|
-
};
|
|
24
|
-
}
|
|
25
13
|
static create() {
|
|
26
14
|
return new Timeout();
|
|
27
15
|
}
|
|
16
|
+
currentId = null;
|
|
17
|
+
|
|
28
18
|
/**
|
|
29
19
|
* Executes `fn` after `delay`, clearing any previously scheduled call.
|
|
30
20
|
*/
|
|
@@ -35,6 +25,15 @@ class Timeout {
|
|
|
35
25
|
fn();
|
|
36
26
|
}, delay);
|
|
37
27
|
}
|
|
28
|
+
clear = () => {
|
|
29
|
+
if (this.currentId !== null) {
|
|
30
|
+
clearTimeout(this.currentId);
|
|
31
|
+
this.currentId = null;
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
disposeEffect = () => {
|
|
35
|
+
return this.clear;
|
|
36
|
+
};
|
|
38
37
|
}
|
|
39
38
|
exports.Timeout = Timeout;
|
|
40
39
|
function useTimeout() {
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
1
|
export default function requirePropFactory(componentNameInError, Component) {
|
|
3
2
|
if (process.env.NODE_ENV === 'production') {
|
|
4
3
|
return () => null;
|
|
5
4
|
}
|
|
6
5
|
|
|
7
6
|
// eslint-disable-next-line react/forbid-foreign-prop-types
|
|
8
|
-
const prevPropTypes = Component ?
|
|
7
|
+
const prevPropTypes = Component ? {
|
|
8
|
+
...Component.propTypes
|
|
9
|
+
} : null;
|
|
9
10
|
const requireProp = requiredProp => (props, propName, componentName, location, propFullName, ...args) => {
|
|
10
11
|
const propFullNameSafe = propFullName || propName;
|
|
11
12
|
const defaultTypeChecker = prevPropTypes?.[propFullNameSafe];
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/esm/extends";
|
|
2
1
|
/**
|
|
3
2
|
* Add keys, values of `defaultProps` that does not exist in `props`
|
|
4
3
|
* @param {object} defaultProps
|
|
@@ -6,10 +5,15 @@ import _extends from "@babel/runtime/helpers/esm/extends";
|
|
|
6
5
|
* @returns {object} resolved props
|
|
7
6
|
*/
|
|
8
7
|
export default function resolveProps(defaultProps, props) {
|
|
9
|
-
const output =
|
|
8
|
+
const output = {
|
|
9
|
+
...props
|
|
10
|
+
};
|
|
10
11
|
Object.keys(defaultProps).forEach(propName => {
|
|
11
12
|
if (propName.toString().match(/^(components|slots)$/)) {
|
|
12
|
-
output[propName] =
|
|
13
|
+
output[propName] = {
|
|
14
|
+
...defaultProps[propName],
|
|
15
|
+
...output[propName]
|
|
16
|
+
};
|
|
13
17
|
} else if (propName.toString().match(/^(componentsProps|slotProps)$/)) {
|
|
14
18
|
const defaultSlotProps = defaultProps[propName] || {};
|
|
15
19
|
const slotProps = props[propName];
|
|
@@ -21,7 +25,9 @@ export default function resolveProps(defaultProps, props) {
|
|
|
21
25
|
// Reduce the iteration if the default slot props is empty
|
|
22
26
|
output[propName] = slotProps;
|
|
23
27
|
} else {
|
|
24
|
-
output[propName] =
|
|
28
|
+
output[propName] = {
|
|
29
|
+
...slotProps
|
|
30
|
+
};
|
|
25
31
|
Object.keys(defaultSlotProps).forEach(slotPropName => {
|
|
26
32
|
output[propName][slotPropName] = resolveProps(defaultSlotProps[slotPropName], slotProps[slotPropName]);
|
|
27
33
|
});
|
package/useTimeout/useTimeout.js
CHANGED
|
@@ -3,21 +3,11 @@
|
|
|
3
3
|
import useLazyRef from '../useLazyRef/useLazyRef';
|
|
4
4
|
import useOnMount from '../useOnMount/useOnMount';
|
|
5
5
|
export class Timeout {
|
|
6
|
-
constructor() {
|
|
7
|
-
this.currentId = null;
|
|
8
|
-
this.clear = () => {
|
|
9
|
-
if (this.currentId !== null) {
|
|
10
|
-
clearTimeout(this.currentId);
|
|
11
|
-
this.currentId = null;
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
this.disposeEffect = () => {
|
|
15
|
-
return this.clear;
|
|
16
|
-
};
|
|
17
|
-
}
|
|
18
6
|
static create() {
|
|
19
7
|
return new Timeout();
|
|
20
8
|
}
|
|
9
|
+
currentId = null;
|
|
10
|
+
|
|
21
11
|
/**
|
|
22
12
|
* Executes `fn` after `delay`, clearing any previously scheduled call.
|
|
23
13
|
*/
|
|
@@ -28,6 +18,15 @@ export class Timeout {
|
|
|
28
18
|
fn();
|
|
29
19
|
}, delay);
|
|
30
20
|
}
|
|
21
|
+
clear = () => {
|
|
22
|
+
if (this.currentId !== null) {
|
|
23
|
+
clearTimeout(this.currentId);
|
|
24
|
+
this.currentId = null;
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
disposeEffect = () => {
|
|
28
|
+
return this.clear;
|
|
29
|
+
};
|
|
31
30
|
}
|
|
32
31
|
export default function useTimeout() {
|
|
33
32
|
const timeout = useLazyRef(Timeout.create).current;
|