@mui/material 9.0.1 → 9.1.1
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/Accordion/Accordion.d.mts +2 -2
- package/Accordion/Accordion.d.ts +2 -2
- package/Accordion/Accordion.js +3 -2
- package/Accordion/Accordion.mjs +3 -2
- package/AccordionSummary/AccordionSummary.js +27 -29
- package/AccordionSummary/AccordionSummary.mjs +27 -29
- package/Autocomplete/Autocomplete.d.mts +5 -1
- package/Autocomplete/Autocomplete.d.ts +5 -1
- package/Autocomplete/Autocomplete.js +13 -7
- package/Autocomplete/Autocomplete.mjs +13 -7
- package/Backdrop/Backdrop.d.mts +2 -2
- package/Backdrop/Backdrop.d.ts +2 -2
- package/Badge/Badge.js +28 -24
- package/Badge/Badge.mjs +28 -24
- package/BottomNavigationAction/BottomNavigationAction.js +6 -2
- package/BottomNavigationAction/BottomNavigationAction.mjs +6 -2
- package/Button/Button.js +11 -15
- package/Button/Button.mjs +11 -15
- package/ButtonBase/Ripple.js +21 -11
- package/ButtonBase/Ripple.mjs +21 -11
- package/ButtonBase/TouchRipple.js +252 -108
- package/ButtonBase/TouchRipple.mjs +253 -109
- package/CHANGELOG.md +122 -0
- package/CardActionArea/CardActionArea.js +2 -1
- package/CardActionArea/CardActionArea.mjs +2 -1
- package/Chip/Chip.js +2 -1
- package/Chip/Chip.mjs +2 -1
- package/CircularProgress/CircularProgress.js +85 -55
- package/CircularProgress/CircularProgress.mjs +84 -55
- package/Collapse/Collapse.d.mts +15 -3
- package/Collapse/Collapse.d.ts +15 -3
- package/Collapse/Collapse.js +44 -31
- package/Collapse/Collapse.mjs +43 -30
- package/Dialog/Dialog.d.mts +2 -2
- package/Dialog/Dialog.d.ts +2 -2
- package/Dialog/Dialog.js +2 -0
- package/Dialog/Dialog.mjs +2 -0
- package/Drawer/Drawer.d.mts +2 -2
- package/Drawer/Drawer.d.ts +2 -2
- package/Fab/Fab.js +2 -1
- package/Fab/Fab.mjs +2 -1
- package/Fade/Fade.d.mts +15 -2
- package/Fade/Fade.d.ts +15 -2
- package/Fade/Fade.js +46 -19
- package/Fade/Fade.mjs +45 -18
- package/FilledInput/FilledInput.js +4 -3
- package/FilledInput/FilledInput.mjs +4 -3
- package/Grow/Grow.d.mts +15 -2
- package/Grow/Grow.d.ts +15 -2
- package/Grow/Grow.js +45 -28
- package/Grow/Grow.mjs +44 -27
- package/IconButton/IconButton.js +2 -1
- package/IconButton/IconButton.mjs +2 -1
- package/InitColorSchemeScript/InitColorSchemeScript.d.mts +5 -5
- package/InitColorSchemeScript/InitColorSchemeScript.d.ts +5 -5
- package/Input/Input.js +3 -2
- package/Input/Input.mjs +3 -2
- package/InputBase/InputBase.js +2 -1
- package/InputBase/InputBase.mjs +2 -1
- package/InputLabel/InputLabel.js +2 -1
- package/InputLabel/InputLabel.mjs +2 -1
- package/LICENSE +1 -1
- package/LinearProgress/LinearProgress.js +187 -120
- package/LinearProgress/LinearProgress.mjs +186 -120
- package/ListItem/ListItem.js +2 -1
- package/ListItem/ListItem.mjs +2 -1
- package/ListItemButton/ListItemButton.js +2 -1
- package/ListItemButton/ListItemButton.mjs +2 -1
- package/Menu/Menu.d.mts +1 -1
- package/Menu/Menu.d.ts +1 -1
- package/MobileStepper/MobileStepper.js +2 -1
- package/MobileStepper/MobileStepper.mjs +2 -1
- package/OutlinedInput/NotchedOutline.js +4 -3
- package/OutlinedInput/NotchedOutline.mjs +4 -3
- package/PaginationItem/PaginationItem.js +2 -1
- package/PaginationItem/PaginationItem.mjs +2 -1
- package/Paper/Paper.js +2 -1
- package/Paper/Paper.mjs +2 -1
- package/Popover/Popover.d.mts +1 -1
- package/Popover/Popover.d.ts +1 -1
- package/README.md +3 -2
- package/Radio/RadioButtonIcon.js +3 -2
- package/Radio/RadioButtonIcon.mjs +3 -2
- package/Rating/Rating.js +2 -1
- package/Rating/Rating.mjs +2 -1
- package/Select/SelectInput.js +115 -25
- package/Select/SelectInput.mjs +115 -25
- package/Select/utils/SelectFocusSourceContext.d.mts +2 -2
- package/Select/utils/SelectFocusSourceContext.d.ts +2 -2
- package/Select/utils/closedTypeahead.js +73 -0
- package/Select/utils/closedTypeahead.mjs +63 -0
- package/Skeleton/Skeleton.js +22 -2
- package/Skeleton/Skeleton.mjs +22 -2
- package/Slide/Slide.d.mts +15 -2
- package/Slide/Slide.d.ts +15 -2
- package/Slide/Slide.js +53 -25
- package/Slide/Slide.mjs +52 -24
- package/Slider/Slider.js +4 -3
- package/Slider/Slider.mjs +4 -3
- package/Slider/SliderValueLabel.d.mts +2 -2
- package/Slider/SliderValueLabel.d.ts +2 -2
- package/Slider/useSlider.js +1 -1
- package/Slider/useSlider.mjs +1 -1
- package/Snackbar/Snackbar.d.mts +2 -2
- package/Snackbar/Snackbar.d.ts +2 -2
- package/SpeedDial/SpeedDial.d.mts +1 -1
- package/SpeedDial/SpeedDial.d.ts +1 -1
- package/SpeedDial/SpeedDial.js +6 -2
- package/SpeedDial/SpeedDial.mjs +6 -2
- package/SpeedDialAction/SpeedDialAction.js +11 -2
- package/SpeedDialAction/SpeedDialAction.mjs +12 -3
- package/SpeedDialIcon/SpeedDialIcon.js +40 -37
- package/SpeedDialIcon/SpeedDialIcon.mjs +40 -37
- package/Step/Step.js +47 -15
- package/Step/Step.mjs +47 -15
- package/Step/StepContext.d.mts +1 -1
- package/Step/StepContext.d.ts +1 -1
- package/StepButton/StepButton.js +9 -3
- package/StepButton/StepButton.mjs +9 -3
- package/StepConnector/StepConnector.js +10 -0
- package/StepConnector/StepConnector.mjs +10 -0
- package/StepContent/StepContent.d.mts +2 -2
- package/StepContent/StepContent.d.ts +2 -2
- package/StepContent/StepContent.js +26 -2
- package/StepContent/StepContent.mjs +26 -2
- package/StepIcon/StepIcon.js +2 -1
- package/StepIcon/StepIcon.mjs +2 -1
- package/StepLabel/StepLabel.js +52 -7
- package/StepLabel/StepLabel.mjs +52 -7
- package/Stepper/Stepper.d.mts +2 -0
- package/Stepper/Stepper.d.ts +2 -0
- package/Stepper/Stepper.js +18 -0
- package/Stepper/Stepper.mjs +18 -0
- package/Stepper/StepperContext.d.mts +1 -1
- package/Stepper/StepperContext.d.ts +1 -1
- package/SvgIcon/SvgIcon.js +2 -1
- package/SvgIcon/SvgIcon.mjs +2 -1
- package/SwipeableDrawer/SwipeableDrawer.js +14 -3
- package/SwipeableDrawer/SwipeableDrawer.mjs +14 -3
- package/Switch/Switch.js +3 -2
- package/Switch/Switch.mjs +3 -2
- package/TableSortLabel/TableSortLabel.js +2 -1
- package/TableSortLabel/TableSortLabel.mjs +2 -1
- package/Tabs/Tabs.js +14 -3
- package/Tabs/Tabs.mjs +14 -3
- package/Tooltip/Tooltip.d.mts +2 -2
- package/Tooltip/Tooltip.d.ts +2 -2
- package/Tooltip/Tooltip.js +3 -0
- package/Tooltip/Tooltip.mjs +3 -0
- package/Unstable_TrapFocus/FocusTrap.js +42 -8
- package/Unstable_TrapFocus/FocusTrap.mjs +42 -8
- package/Zoom/Zoom.d.mts +15 -2
- package/Zoom/Zoom.d.ts +15 -2
- package/Zoom/Zoom.js +43 -16
- package/Zoom/Zoom.mjs +42 -15
- package/index.js +1 -1
- package/index.mjs +1 -1
- package/internal/Transition.d.mts +34 -0
- package/internal/Transition.d.ts +34 -0
- package/internal/Transition.js +450 -0
- package/internal/Transition.mjs +442 -0
- package/internal/react-transition-group.d.mts +8 -0
- package/internal/react-transition-group.d.ts +8 -0
- package/package.json +7 -7
- package/styles/ThemeProviderWithVars.d.mts +7 -7
- package/styles/ThemeProviderWithVars.d.ts +7 -7
- package/styles/createGetSelector.d.mts +2 -2
- package/styles/createGetSelector.d.ts +2 -2
- package/styles/createMotion.d.mts +8 -0
- package/styles/createMotion.d.ts +8 -0
- package/styles/createMotion.js +13 -0
- package/styles/createMotion.mjs +7 -0
- package/styles/createThemeFoundation.d.mts +2 -0
- package/styles/createThemeFoundation.d.ts +2 -0
- package/styles/createThemeNoVars.d.mts +3 -0
- package/styles/createThemeNoVars.d.ts +3 -0
- package/styles/createThemeNoVars.js +5 -0
- package/styles/createThemeNoVars.mjs +5 -0
- package/styles/createTransitions.d.mts +6 -2
- package/styles/createTransitions.d.ts +6 -2
- package/styles/createTransitions.js +12 -4
- package/styles/createTransitions.mjs +12 -4
- package/styles/enhanceHighContrast.d.mts +70 -0
- package/styles/enhanceHighContrast.d.ts +70 -0
- package/styles/enhanceHighContrast.js +502 -0
- package/styles/enhanceHighContrast.mjs +495 -0
- package/styles/identifier.d.mts +1 -1
- package/styles/identifier.d.ts +1 -1
- package/styles/index.d.mts +2 -0
- package/styles/index.d.ts +2 -0
- package/styles/index.js +8 -0
- package/styles/index.mjs +1 -0
- package/styles/reducedMotion.d.mts +7 -0
- package/styles/reducedMotion.d.ts +7 -0
- package/styles/reducedMotion.js +21 -0
- package/styles/reducedMotion.mjs +14 -0
- package/styles/shouldSkipGeneratingVar.js +1 -1
- package/styles/shouldSkipGeneratingVar.mjs +1 -1
- package/styles/stringifyTheme.js +1 -0
- package/styles/stringifyTheme.mjs +1 -0
- package/transitions/index.d.mts +1 -1
- package/transitions/index.d.ts +1 -1
- package/transitions/index.js +0 -11
- package/transitions/index.mjs +1 -1
- package/transitions/transition.d.mts +1 -12
- package/transitions/transition.d.ts +1 -12
- package/transitions/types.d.mts +73 -0
- package/transitions/types.d.ts +73 -0
- package/transitions/useReducedMotion.d.mts +14 -0
- package/transitions/useReducedMotion.d.ts +14 -0
- package/transitions/useReducedMotion.js +117 -0
- package/transitions/useReducedMotion.mjs +110 -0
- package/transitions/utils.d.mts +34 -2
- package/transitions/utils.d.ts +34 -2
- package/transitions/utils.js +33 -4
- package/transitions/utils.mjs +31 -4
- package/useAutocomplete/useAutocomplete.d.mts +8 -1
- package/useAutocomplete/useAutocomplete.d.ts +8 -1
- package/useAutocomplete/useAutocomplete.js +66 -4
- package/useAutocomplete/useAutocomplete.mjs +66 -4
- package/utils/memoTheme.d.mts +1 -1
- package/utils/memoTheme.d.ts +1 -1
- package/utils/useSlot.d.mts +1 -1
- package/utils/useSlot.d.ts +1 -1
- package/version/index.js +2 -2
- package/version/index.mjs +2 -2
- /package/transitions/{transition.js → types.js} +0 -0
- /package/transitions/{transition.mjs → types.mjs} +0 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.canCycleRepeatedCharacter = canCycleRepeatedCharacter;
|
|
9
|
+
exports.getMatchingOptionIndex = getMatchingOptionIndex;
|
|
10
|
+
exports.getTypeaheadOptions = getTypeaheadOptions;
|
|
11
|
+
var React = _interopRequireWildcard(require("react"));
|
|
12
|
+
var _areEqualValues = _interopRequireDefault(require("./areEqualValues"));
|
|
13
|
+
function hasOwnValueProp(child) {
|
|
14
|
+
return Object.prototype.hasOwnProperty.call(child.props, 'value');
|
|
15
|
+
}
|
|
16
|
+
function getTextFromReactNode(node) {
|
|
17
|
+
if (typeof node === 'string' || typeof node === 'number') {
|
|
18
|
+
return String(node);
|
|
19
|
+
}
|
|
20
|
+
let text = '';
|
|
21
|
+
React.Children.forEach(node, child => {
|
|
22
|
+
if (typeof child === 'string' || typeof child === 'number') {
|
|
23
|
+
text += String(child);
|
|
24
|
+
} else if (/*#__PURE__*/React.isValidElement(child)) {
|
|
25
|
+
text += getTextFromReactNode(child.props.children);
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
return text;
|
|
29
|
+
}
|
|
30
|
+
function getMatchingOptionIndex(options, search, startIndex = 0) {
|
|
31
|
+
if (options.length === 0) {
|
|
32
|
+
return -1;
|
|
33
|
+
}
|
|
34
|
+
const normalizedStartIndex = (startIndex % options.length + options.length) % options.length;
|
|
35
|
+
for (let offset = 0; offset < options.length; offset += 1) {
|
|
36
|
+
const index = (normalizedStartIndex + offset) % options.length;
|
|
37
|
+
if (options[index].label.startsWith(search)) {
|
|
38
|
+
return index;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return -1;
|
|
42
|
+
}
|
|
43
|
+
function canCycleRepeatedCharacter(options, key) {
|
|
44
|
+
return !options.some(option => option.label[0] === key && option.label[1] === key);
|
|
45
|
+
}
|
|
46
|
+
function getTypeaheadOptions(childrenArray, value) {
|
|
47
|
+
const options = [];
|
|
48
|
+
let selectedIndex = -1;
|
|
49
|
+
for (let index = 0; index < childrenArray.length; index += 1) {
|
|
50
|
+
const child = childrenArray[index];
|
|
51
|
+
if (! /*#__PURE__*/React.isValidElement(child) || !hasOwnValueProp(child) || child.props.disabled) {
|
|
52
|
+
continue;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Closed typeahead cannot exclude CSS-hidden text because no option DOM is mounted.
|
|
56
|
+
const label = getTextFromReactNode(child.props.children).trim().toLowerCase();
|
|
57
|
+
if (label === '') {
|
|
58
|
+
continue;
|
|
59
|
+
}
|
|
60
|
+
if (selectedIndex === -1 && (0, _areEqualValues.default)(value, child.props.value)) {
|
|
61
|
+
selectedIndex = options.length;
|
|
62
|
+
}
|
|
63
|
+
options.push({
|
|
64
|
+
child,
|
|
65
|
+
label,
|
|
66
|
+
value: child.props.value
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
return {
|
|
70
|
+
options,
|
|
71
|
+
selectedIndex
|
|
72
|
+
};
|
|
73
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import areEqualValues from "./areEqualValues.mjs";
|
|
3
|
+
function hasOwnValueProp(child) {
|
|
4
|
+
return Object.prototype.hasOwnProperty.call(child.props, 'value');
|
|
5
|
+
}
|
|
6
|
+
function getTextFromReactNode(node) {
|
|
7
|
+
if (typeof node === 'string' || typeof node === 'number') {
|
|
8
|
+
return String(node);
|
|
9
|
+
}
|
|
10
|
+
let text = '';
|
|
11
|
+
React.Children.forEach(node, child => {
|
|
12
|
+
if (typeof child === 'string' || typeof child === 'number') {
|
|
13
|
+
text += String(child);
|
|
14
|
+
} else if (/*#__PURE__*/React.isValidElement(child)) {
|
|
15
|
+
text += getTextFromReactNode(child.props.children);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
return text;
|
|
19
|
+
}
|
|
20
|
+
export function getMatchingOptionIndex(options, search, startIndex = 0) {
|
|
21
|
+
if (options.length === 0) {
|
|
22
|
+
return -1;
|
|
23
|
+
}
|
|
24
|
+
const normalizedStartIndex = (startIndex % options.length + options.length) % options.length;
|
|
25
|
+
for (let offset = 0; offset < options.length; offset += 1) {
|
|
26
|
+
const index = (normalizedStartIndex + offset) % options.length;
|
|
27
|
+
if (options[index].label.startsWith(search)) {
|
|
28
|
+
return index;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
return -1;
|
|
32
|
+
}
|
|
33
|
+
export function canCycleRepeatedCharacter(options, key) {
|
|
34
|
+
return !options.some(option => option.label[0] === key && option.label[1] === key);
|
|
35
|
+
}
|
|
36
|
+
export function getTypeaheadOptions(childrenArray, value) {
|
|
37
|
+
const options = [];
|
|
38
|
+
let selectedIndex = -1;
|
|
39
|
+
for (let index = 0; index < childrenArray.length; index += 1) {
|
|
40
|
+
const child = childrenArray[index];
|
|
41
|
+
if (! /*#__PURE__*/React.isValidElement(child) || !hasOwnValueProp(child) || child.props.disabled) {
|
|
42
|
+
continue;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
// Closed typeahead cannot exclude CSS-hidden text because no option DOM is mounted.
|
|
46
|
+
const label = getTextFromReactNode(child.props.children).trim().toLowerCase();
|
|
47
|
+
if (label === '') {
|
|
48
|
+
continue;
|
|
49
|
+
}
|
|
50
|
+
if (selectedIndex === -1 && areEqualValues(value, child.props.value)) {
|
|
51
|
+
selectedIndex = options.length;
|
|
52
|
+
}
|
|
53
|
+
options.push({
|
|
54
|
+
child,
|
|
55
|
+
label,
|
|
56
|
+
value: child.props.value
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
options,
|
|
61
|
+
selectedIndex
|
|
62
|
+
};
|
|
63
|
+
}
|
package/Skeleton/Skeleton.js
CHANGED
|
@@ -15,6 +15,7 @@ var _styles = require("../styles");
|
|
|
15
15
|
var _zeroStyled = require("../zero-styled");
|
|
16
16
|
var _memoTheme = _interopRequireDefault(require("../utils/memoTheme"));
|
|
17
17
|
var _DefaultPropsProvider = require("../DefaultPropsProvider");
|
|
18
|
+
var _utils = require("../transitions/utils");
|
|
18
19
|
var _skeletonClasses = require("./skeletonClasses");
|
|
19
20
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
20
21
|
const useUtilityClasses = ownerState => {
|
|
@@ -84,6 +85,15 @@ const SkeletonRoot = (0, _zeroStyled.styled)('span', {
|
|
|
84
85
|
}) => {
|
|
85
86
|
const radiusUnit = (0, _styles.unstable_getUnit)(theme.shape.borderRadius) || 'px';
|
|
86
87
|
const radiusValue = (0, _styles.unstable_toUnitless)(theme.shape.borderRadius);
|
|
88
|
+
const reducedMotionPulseStyles = (0, _utils.getReducedMotionStyles)(theme, {
|
|
89
|
+
animation: 'none'
|
|
90
|
+
});
|
|
91
|
+
const reducedMotionWaveStyles = (0, _utils.getReducedMotionStyles)(theme, {
|
|
92
|
+
'&::after': {
|
|
93
|
+
animation: 'none',
|
|
94
|
+
display: 'none'
|
|
95
|
+
}
|
|
96
|
+
});
|
|
87
97
|
return {
|
|
88
98
|
display: 'block',
|
|
89
99
|
// Create a "on paper" color with sufficient contrast retaining the color
|
|
@@ -148,7 +158,12 @@ const SkeletonRoot = (0, _zeroStyled.styled)('span', {
|
|
|
148
158
|
style: pulseAnimation || {
|
|
149
159
|
animation: `${pulseKeyframe} 2s ease-in-out 0.5s infinite`
|
|
150
160
|
}
|
|
151
|
-
}, {
|
|
161
|
+
}, ...(reducedMotionPulseStyles ? [{
|
|
162
|
+
props: {
|
|
163
|
+
animation: 'pulse'
|
|
164
|
+
},
|
|
165
|
+
style: reducedMotionPulseStyles
|
|
166
|
+
}] : []), {
|
|
152
167
|
props: {
|
|
153
168
|
animation: 'wave'
|
|
154
169
|
},
|
|
@@ -182,7 +197,12 @@ const SkeletonRoot = (0, _zeroStyled.styled)('span', {
|
|
|
182
197
|
animation: `${waveKeyframe} 2s linear 0.5s infinite`
|
|
183
198
|
}
|
|
184
199
|
}
|
|
185
|
-
}
|
|
200
|
+
}, ...(reducedMotionWaveStyles ? [{
|
|
201
|
+
props: {
|
|
202
|
+
animation: 'wave'
|
|
203
|
+
},
|
|
204
|
+
style: reducedMotionWaveStyles
|
|
205
|
+
}] : [])]
|
|
186
206
|
};
|
|
187
207
|
}));
|
|
188
208
|
const Skeleton = /*#__PURE__*/React.forwardRef(function Skeleton(inProps, ref) {
|
package/Skeleton/Skeleton.mjs
CHANGED
|
@@ -8,6 +8,7 @@ import { unstable_getUnit as getUnit, unstable_toUnitless as toUnitless } from "
|
|
|
8
8
|
import { keyframes, css, styled } from "../zero-styled/index.mjs";
|
|
9
9
|
import memoTheme from "../utils/memoTheme.mjs";
|
|
10
10
|
import { useDefaultProps } from "../DefaultPropsProvider/index.mjs";
|
|
11
|
+
import { getReducedMotionStyles } from "../transitions/utils.mjs";
|
|
11
12
|
import { getSkeletonUtilityClass } from "./skeletonClasses.mjs";
|
|
12
13
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
14
|
const useUtilityClasses = ownerState => {
|
|
@@ -77,6 +78,15 @@ const SkeletonRoot = styled('span', {
|
|
|
77
78
|
}) => {
|
|
78
79
|
const radiusUnit = getUnit(theme.shape.borderRadius) || 'px';
|
|
79
80
|
const radiusValue = toUnitless(theme.shape.borderRadius);
|
|
81
|
+
const reducedMotionPulseStyles = getReducedMotionStyles(theme, {
|
|
82
|
+
animation: 'none'
|
|
83
|
+
});
|
|
84
|
+
const reducedMotionWaveStyles = getReducedMotionStyles(theme, {
|
|
85
|
+
'&::after': {
|
|
86
|
+
animation: 'none',
|
|
87
|
+
display: 'none'
|
|
88
|
+
}
|
|
89
|
+
});
|
|
80
90
|
return {
|
|
81
91
|
display: 'block',
|
|
82
92
|
// Create a "on paper" color with sufficient contrast retaining the color
|
|
@@ -141,7 +151,12 @@ const SkeletonRoot = styled('span', {
|
|
|
141
151
|
style: pulseAnimation || {
|
|
142
152
|
animation: `${pulseKeyframe} 2s ease-in-out 0.5s infinite`
|
|
143
153
|
}
|
|
144
|
-
}, {
|
|
154
|
+
}, ...(reducedMotionPulseStyles ? [{
|
|
155
|
+
props: {
|
|
156
|
+
animation: 'pulse'
|
|
157
|
+
},
|
|
158
|
+
style: reducedMotionPulseStyles
|
|
159
|
+
}] : []), {
|
|
145
160
|
props: {
|
|
146
161
|
animation: 'wave'
|
|
147
162
|
},
|
|
@@ -175,7 +190,12 @@ const SkeletonRoot = styled('span', {
|
|
|
175
190
|
animation: `${waveKeyframe} 2s linear 0.5s infinite`
|
|
176
191
|
}
|
|
177
192
|
}
|
|
178
|
-
}
|
|
193
|
+
}, ...(reducedMotionWaveStyles ? [{
|
|
194
|
+
props: {
|
|
195
|
+
animation: 'wave'
|
|
196
|
+
},
|
|
197
|
+
style: reducedMotionWaveStyles
|
|
198
|
+
}] : [])]
|
|
179
199
|
};
|
|
180
200
|
}));
|
|
181
201
|
const Skeleton = /*#__PURE__*/React.forwardRef(function Skeleton(inProps, ref) {
|
package/Slide/Slide.d.mts
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { TransitionProps } from "../transitions/
|
|
2
|
+
import { TransitionProps } from "../transitions/types.mjs";
|
|
3
3
|
export interface SlideProps extends TransitionProps {
|
|
4
|
+
/**
|
|
5
|
+
* Add a custom transition end trigger.
|
|
6
|
+
* Use it when you need custom logic to decide when the transition has ended.
|
|
7
|
+
* Note: Timeouts are still used as a fallback if provided.
|
|
8
|
+
*
|
|
9
|
+
* @param {HTMLElement} node The transitioning DOM node.
|
|
10
|
+
* @param {Function} done Call this when the transition has finished.
|
|
11
|
+
*/
|
|
12
|
+
addEndListener?: TransitionProps['addEndListener'] | undefined;
|
|
4
13
|
/**
|
|
5
14
|
* Perform the enter transition when it first mounts if `in` is also `true`.
|
|
6
15
|
* Set this to `false` to disable this behavior.
|
|
@@ -16,6 +25,11 @@ export interface SlideProps extends TransitionProps {
|
|
|
16
25
|
* It's used to set the container the Slide is transitioning from.
|
|
17
26
|
*/
|
|
18
27
|
container?: null | Element | ((element: Element) => Element) | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* If `true`, the transition ignores `theme.motion.reducedMotion` and keeps its normal timing.
|
|
30
|
+
* @default false
|
|
31
|
+
*/
|
|
32
|
+
disablePrefersReducedMotion?: boolean | undefined;
|
|
19
33
|
/**
|
|
20
34
|
* Direction the child node will enter from.
|
|
21
35
|
* @default 'down'
|
|
@@ -48,7 +62,6 @@ export interface SlideProps extends TransitionProps {
|
|
|
48
62
|
|
|
49
63
|
/**
|
|
50
64
|
* The Slide transition is used by the [Drawer](https://mui.com/material-ui/react-drawer/) component.
|
|
51
|
-
* It uses [react-transition-group](https://github.com/reactjs/react-transition-group) internally.
|
|
52
65
|
*
|
|
53
66
|
* Demos:
|
|
54
67
|
*
|
package/Slide/Slide.d.ts
CHANGED
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import { TransitionProps } from "../transitions/
|
|
2
|
+
import { TransitionProps } from "../transitions/types.js";
|
|
3
3
|
export interface SlideProps extends TransitionProps {
|
|
4
|
+
/**
|
|
5
|
+
* Add a custom transition end trigger.
|
|
6
|
+
* Use it when you need custom logic to decide when the transition has ended.
|
|
7
|
+
* Note: Timeouts are still used as a fallback if provided.
|
|
8
|
+
*
|
|
9
|
+
* @param {HTMLElement} node The transitioning DOM node.
|
|
10
|
+
* @param {Function} done Call this when the transition has finished.
|
|
11
|
+
*/
|
|
12
|
+
addEndListener?: TransitionProps['addEndListener'] | undefined;
|
|
4
13
|
/**
|
|
5
14
|
* Perform the enter transition when it first mounts if `in` is also `true`.
|
|
6
15
|
* Set this to `false` to disable this behavior.
|
|
@@ -16,6 +25,11 @@ export interface SlideProps extends TransitionProps {
|
|
|
16
25
|
* It's used to set the container the Slide is transitioning from.
|
|
17
26
|
*/
|
|
18
27
|
container?: null | Element | ((element: Element) => Element) | undefined;
|
|
28
|
+
/**
|
|
29
|
+
* If `true`, the transition ignores `theme.motion.reducedMotion` and keeps its normal timing.
|
|
30
|
+
* @default false
|
|
31
|
+
*/
|
|
32
|
+
disablePrefersReducedMotion?: boolean | undefined;
|
|
19
33
|
/**
|
|
20
34
|
* Direction the child node will enter from.
|
|
21
35
|
* @default 'down'
|
|
@@ -48,7 +62,6 @@ export interface SlideProps extends TransitionProps {
|
|
|
48
62
|
|
|
49
63
|
/**
|
|
50
64
|
* The Slide transition is used by the [Drawer](https://mui.com/material-ui/react-drawer/) component.
|
|
51
|
-
* It uses [react-transition-group](https://github.com/reactjs/react-transition-group) internally.
|
|
52
65
|
*
|
|
53
66
|
* Demos:
|
|
54
67
|
*
|
package/Slide/Slide.js
CHANGED
|
@@ -10,21 +10,23 @@ exports.default = void 0;
|
|
|
10
10
|
exports.setTranslateValue = setTranslateValue;
|
|
11
11
|
var React = _interopRequireWildcard(require("react"));
|
|
12
12
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
-
var _reactTransitionGroup = require("react-transition-group");
|
|
14
13
|
var _chainPropTypes = _interopRequireDefault(require("@mui/utils/chainPropTypes"));
|
|
15
14
|
var _HTMLElementType = _interopRequireDefault(require("@mui/utils/HTMLElementType"));
|
|
16
15
|
var _elementAcceptingRef = _interopRequireDefault(require("@mui/utils/elementAcceptingRef"));
|
|
17
16
|
var _getReactElementRef = _interopRequireDefault(require("@mui/utils/getReactElementRef"));
|
|
17
|
+
var _Transition = _interopRequireDefault(require("../internal/Transition"));
|
|
18
18
|
var _isLayoutSupported = _interopRequireDefault(require("../utils/isLayoutSupported"));
|
|
19
19
|
var _debounce = _interopRequireDefault(require("../utils/debounce"));
|
|
20
20
|
var _useForkRef = _interopRequireDefault(require("../utils/useForkRef"));
|
|
21
21
|
var _zeroStyled = require("../zero-styled");
|
|
22
|
+
var _useReducedMotion = _interopRequireDefault(require("../transitions/useReducedMotion"));
|
|
22
23
|
var _utils = require("../transitions/utils");
|
|
23
24
|
var _utils2 = require("../utils");
|
|
24
25
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
25
26
|
const hiddenStyles = {
|
|
26
27
|
visibility: 'hidden'
|
|
27
28
|
};
|
|
29
|
+
const DEFAULT_TRANSLATE_OPTIONS = {};
|
|
28
30
|
|
|
29
31
|
/**
|
|
30
32
|
* Detects SwipeableDrawer's active-swipe `translate(x, y)` transform.
|
|
@@ -34,9 +36,8 @@ function isGestureTranslate(transform) {
|
|
|
34
36
|
return typeof transform === 'string' && /^translate\(.+,\s*.+\)$/.test(transform);
|
|
35
37
|
}
|
|
36
38
|
|
|
37
|
-
//
|
|
38
|
-
|
|
39
|
-
function getTranslateValue(direction, node, resolvedContainer, options = {}) {
|
|
39
|
+
// Move the node off-screen. Later we reset transform to `none` to slide it in.
|
|
40
|
+
function getTranslateValue(direction, node, resolvedContainer, options = DEFAULT_TRANSLATE_OPTIONS) {
|
|
40
41
|
const {
|
|
41
42
|
resetInlineTransform = true
|
|
42
43
|
} = options;
|
|
@@ -45,9 +46,9 @@ function getTranslateValue(direction, node, resolvedContainer, options = {}) {
|
|
|
45
46
|
let rect;
|
|
46
47
|
let transform;
|
|
47
48
|
if (resetInlineTransform) {
|
|
48
|
-
//
|
|
49
|
-
//
|
|
50
|
-
//
|
|
49
|
+
// Read layout from the element's natural position, not from a previous
|
|
50
|
+
// off-screen transform. Clear transition too, or the browser may report an
|
|
51
|
+
// in-between animated value during exit.
|
|
51
52
|
const previousTransform = node.style.transform;
|
|
52
53
|
const previousTransition = node.style.transition;
|
|
53
54
|
node.style.transition = '';
|
|
@@ -104,7 +105,6 @@ function setTranslateValue(direction, node, containerProp, options) {
|
|
|
104
105
|
|
|
105
106
|
/**
|
|
106
107
|
* The Slide transition is used by the [Drawer](/material-ui/react-drawer/) component.
|
|
107
|
-
* It uses [react-transition-group](https://github.com/reactjs/react-transition-group) internally.
|
|
108
108
|
*/
|
|
109
109
|
const Slide = /*#__PURE__*/React.forwardRef(function Slide(props, ref) {
|
|
110
110
|
const theme = (0, _zeroStyled.useTheme)();
|
|
@@ -121,6 +121,7 @@ const Slide = /*#__PURE__*/React.forwardRef(function Slide(props, ref) {
|
|
|
121
121
|
appear = true,
|
|
122
122
|
children,
|
|
123
123
|
container: containerProp,
|
|
124
|
+
disablePrefersReducedMotion = false,
|
|
124
125
|
direction = 'down',
|
|
125
126
|
easing: easingProp = defaultEasing,
|
|
126
127
|
in: inProp,
|
|
@@ -134,12 +135,15 @@ const Slide = /*#__PURE__*/React.forwardRef(function Slide(props, ref) {
|
|
|
134
135
|
timeout = defaultTimeout,
|
|
135
136
|
...other
|
|
136
137
|
} = props;
|
|
138
|
+
const reducedMotion = (0, _useReducedMotion.default)(theme.motion.reducedMotion, disablePrefersReducedMotion);
|
|
137
139
|
const childrenRef = React.useRef(null);
|
|
138
140
|
const preserveInlineTransformRef = React.useRef(false);
|
|
139
141
|
const handleRef = (0, _useForkRef.default)((0, _getReactElementRef.default)(children), childrenRef, ref);
|
|
140
142
|
const handleEnter = (0, _utils.normalizedTransitionCallback)(childrenRef, (node, isAppearing) => {
|
|
141
143
|
setTranslateValue(direction, node, containerProp);
|
|
142
|
-
(
|
|
144
|
+
if (!reducedMotion.shouldReduceMotion) {
|
|
145
|
+
(0, _utils.reflow)(node);
|
|
146
|
+
}
|
|
143
147
|
if (onEnter) {
|
|
144
148
|
onEnter(node, isAppearing);
|
|
145
149
|
}
|
|
@@ -152,7 +156,15 @@ const Slide = /*#__PURE__*/React.forwardRef(function Slide(props, ref) {
|
|
|
152
156
|
}, {
|
|
153
157
|
mode: 'enter'
|
|
154
158
|
});
|
|
155
|
-
|
|
159
|
+
const transitionTiming = reducedMotion.getTransitionTiming({
|
|
160
|
+
duration: transitionProps.duration,
|
|
161
|
+
delay: transitionProps.delay
|
|
162
|
+
});
|
|
163
|
+
node.style.transition = theme.transitions.create('transform', {
|
|
164
|
+
duration: transitionTiming.duration,
|
|
165
|
+
easing: transitionProps.easing,
|
|
166
|
+
delay: transitionTiming.delay
|
|
167
|
+
});
|
|
156
168
|
node.style.transform = 'none';
|
|
157
169
|
if (onEntering) {
|
|
158
170
|
onEntering(node, isAppearing);
|
|
@@ -168,7 +180,15 @@ const Slide = /*#__PURE__*/React.forwardRef(function Slide(props, ref) {
|
|
|
168
180
|
}, {
|
|
169
181
|
mode: 'exit'
|
|
170
182
|
});
|
|
171
|
-
|
|
183
|
+
const transitionTiming = reducedMotion.getTransitionTiming({
|
|
184
|
+
duration: transitionProps.duration,
|
|
185
|
+
delay: transitionProps.delay
|
|
186
|
+
});
|
|
187
|
+
node.style.transition = theme.transitions.create('transform', {
|
|
188
|
+
duration: transitionTiming.duration,
|
|
189
|
+
easing: transitionProps.easing,
|
|
190
|
+
delay: transitionTiming.delay
|
|
191
|
+
});
|
|
172
192
|
const preserveInlineTransform = isGestureTranslate(node.style.transform);
|
|
173
193
|
preserveInlineTransformRef.current = preserveInlineTransform;
|
|
174
194
|
|
|
@@ -183,25 +203,22 @@ const Slide = /*#__PURE__*/React.forwardRef(function Slide(props, ref) {
|
|
|
183
203
|
});
|
|
184
204
|
const handleExited = (0, _utils.normalizedTransitionCallback)(childrenRef, node => {
|
|
185
205
|
preserveInlineTransformRef.current = false;
|
|
186
|
-
//
|
|
206
|
+
// Hidden nodes stay off-screen without animating.
|
|
187
207
|
node.style.transition = '';
|
|
188
208
|
if (onExited) {
|
|
189
209
|
onExited(node);
|
|
190
210
|
}
|
|
191
211
|
});
|
|
192
|
-
const handleAddEndListener = next => {
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
addEndListener(childrenRef.current, next);
|
|
196
|
-
}
|
|
197
|
-
};
|
|
212
|
+
const handleAddEndListener = addEndListener ? next => {
|
|
213
|
+
addEndListener(childrenRef.current, next);
|
|
214
|
+
} : undefined;
|
|
198
215
|
const updatePosition = React.useCallback(() => {
|
|
199
216
|
if (childrenRef.current) {
|
|
200
217
|
setTranslateValue(direction, childrenRef.current, containerProp);
|
|
201
218
|
}
|
|
202
219
|
}, [direction, containerProp]);
|
|
203
220
|
React.useEffect(() => {
|
|
204
|
-
// Skip
|
|
221
|
+
// Skip resize listeners when the off-screen position does not depend on screen size.
|
|
205
222
|
if (inProp || direction === 'down' || direction === 'right') {
|
|
206
223
|
return undefined;
|
|
207
224
|
}
|
|
@@ -219,12 +236,12 @@ const Slide = /*#__PURE__*/React.forwardRef(function Slide(props, ref) {
|
|
|
219
236
|
}, [direction, inProp, containerProp]);
|
|
220
237
|
React.useEffect(() => {
|
|
221
238
|
if (!inProp && !preserveInlineTransformRef.current) {
|
|
222
|
-
//
|
|
223
|
-
//
|
|
239
|
+
// While hidden, keep the child at the correct off-screen position if
|
|
240
|
+
// direction or container changes.
|
|
224
241
|
updatePosition();
|
|
225
242
|
}
|
|
226
243
|
}, [inProp, updatePosition]);
|
|
227
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
244
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Transition.default, {
|
|
228
245
|
nodeRef: childrenRef,
|
|
229
246
|
onEnter: handleEnter,
|
|
230
247
|
onEntered: handleEntered,
|
|
@@ -235,12 +252,15 @@ const Slide = /*#__PURE__*/React.forwardRef(function Slide(props, ref) {
|
|
|
235
252
|
addEndListener: handleAddEndListener,
|
|
236
253
|
appear: appear,
|
|
237
254
|
in: inProp,
|
|
255
|
+
reduceMotion: reducedMotion.shouldReduceMotion,
|
|
238
256
|
timeout: timeout,
|
|
239
257
|
...other,
|
|
240
258
|
children: (state, {
|
|
241
259
|
ownerState,
|
|
242
260
|
...restChildProps
|
|
243
261
|
}) => {
|
|
262
|
+
// Do not pass ownerState to a DOM child. ownerState is only for
|
|
263
|
+
// Material UI styling, and React would treat it as an invalid DOM attribute.
|
|
244
264
|
let childStyle;
|
|
245
265
|
if (state === 'exited' && !inProp) {
|
|
246
266
|
childStyle = style || children.props.style ? {
|
|
@@ -270,9 +290,12 @@ process.env.NODE_ENV !== "production" ? Slide.propTypes /* remove-proptypes */ =
|
|
|
270
290
|
// │ To update them, edit the d.ts file and run `pnpm proptypes`. │
|
|
271
291
|
// └─────────────────────────────────────────────────────────────────────┘
|
|
272
292
|
/**
|
|
273
|
-
* Add a custom transition end trigger.
|
|
274
|
-
*
|
|
275
|
-
*
|
|
293
|
+
* Add a custom transition end trigger.
|
|
294
|
+
* Use it when you need custom logic to decide when the transition has ended.
|
|
295
|
+
* Note: Timeouts are still used as a fallback if provided.
|
|
296
|
+
*
|
|
297
|
+
* @param {HTMLElement} node The transitioning DOM node.
|
|
298
|
+
* @param {Function} done Call this when the transition has finished.
|
|
276
299
|
*/
|
|
277
300
|
addEndListener: _propTypes.default.func,
|
|
278
301
|
/**
|
|
@@ -310,6 +333,11 @@ process.env.NODE_ENV !== "production" ? Slide.propTypes /* remove-proptypes */ =
|
|
|
310
333
|
* @default 'down'
|
|
311
334
|
*/
|
|
312
335
|
direction: _propTypes.default.oneOf(['down', 'left', 'right', 'up']),
|
|
336
|
+
/**
|
|
337
|
+
* If `true`, the transition ignores `theme.motion.reducedMotion` and keeps its normal timing.
|
|
338
|
+
* @default false
|
|
339
|
+
*/
|
|
340
|
+
disablePrefersReducedMotion: _propTypes.default.bool,
|
|
313
341
|
/**
|
|
314
342
|
* The transition timing function.
|
|
315
343
|
* You may specify a single easing or a object containing enter and exit values.
|