@mui/material 9.0.0 → 9.1.0
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.js +73 -17
- package/Autocomplete/Autocomplete.mjs +73 -17
- package/Avatar/Avatar.js +4 -0
- package/Avatar/Avatar.mjs +4 -0
- package/Backdrop/Backdrop.d.mts +2 -2
- package/Backdrop/Backdrop.d.ts +2 -2
- package/Badge/Badge.js +31 -24
- package/Badge/Badge.mjs +31 -24
- package/BottomNavigationAction/BottomNavigationAction.js +6 -2
- package/BottomNavigationAction/BottomNavigationAction.mjs +6 -2
- package/Button/Button.js +19 -6
- package/Button/Button.mjs +19 -6
- package/ButtonBase/ButtonBase.d.mts +7 -0
- package/ButtonBase/ButtonBase.d.ts +7 -0
- package/ButtonBase/ButtonBase.js +5 -2
- package/ButtonBase/ButtonBase.mjs +5 -2
- package/ButtonBase/Ripple.js +21 -11
- package/ButtonBase/Ripple.mjs +21 -11
- package/ButtonBase/TouchRipple.js +252 -116
- package/ButtonBase/TouchRipple.mjs +253 -117
- package/CHANGELOG.md +216 -1245
- package/CardActionArea/CardActionArea.js +2 -1
- package/CardActionArea/CardActionArea.mjs +2 -1
- package/Checkbox/Checkbox.js +2 -1
- package/Checkbox/Checkbox.mjs +2 -1
- package/Chip/Chip.js +2 -1
- package/Chip/Chip.mjs +2 -1
- package/CircularProgress/CircularProgress.d.mts +12 -2
- package/CircularProgress/CircularProgress.d.ts +12 -2
- package/CircularProgress/CircularProgress.js +115 -58
- package/CircularProgress/CircularProgress.mjs +114 -58
- package/ClickAwayListener/ClickAwayListener.js +3 -6
- package/ClickAwayListener/ClickAwayListener.mjs +3 -6
- 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 +13 -6
- package/Dialog/Dialog.mjs +13 -6
- package/Drawer/Drawer.d.mts +2 -2
- package/Drawer/Drawer.d.ts +2 -2
- package/Drawer/Drawer.js +18 -4
- package/Drawer/Drawer.mjs +18 -4
- package/Fab/Fab.js +9 -2
- package/Fab/Fab.mjs +9 -2
- 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.d.mts +4 -0
- package/FilledInput/FilledInput.d.ts +4 -0
- package/FilledInput/FilledInput.js +22 -23
- package/FilledInput/FilledInput.mjs +22 -23
- package/FormControl/useFormControl.d.mts +12 -2
- package/FormControl/useFormControl.d.ts +12 -2
- package/FormControl/useFormControl.js +13 -0
- package/FormControl/useFormControl.mjs +12 -0
- package/FormControlLabel/FormControlLabel.js +5 -8
- package/FormControlLabel/FormControlLabel.mjs +5 -8
- package/FormGroup/FormGroup.js +2 -5
- package/FormGroup/FormGroup.mjs +2 -5
- package/FormHelperText/FormHelperText.js +2 -5
- package/FormHelperText/FormHelperText.mjs +2 -5
- package/FormLabel/FormLabel.js +2 -5
- package/FormLabel/FormLabel.mjs +2 -5
- 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 +3 -9
- package/IconButton/IconButton.mjs +3 -9
- package/Input/Input.d.mts +4 -0
- package/Input/Input.d.ts +4 -0
- package/Input/Input.js +9 -2
- package/Input/Input.mjs +9 -2
- package/InputBase/InputBase.d.mts +2 -1
- package/InputBase/InputBase.d.ts +2 -1
- package/InputBase/InputBase.js +52 -16
- package/InputBase/InputBase.mjs +52 -16
- package/InputLabel/InputLabel.js +7 -9
- package/InputLabel/InputLabel.mjs +7 -9
- package/LICENSE +1 -1
- package/LinearProgress/LinearProgress.d.mts +12 -2
- package/LinearProgress/LinearProgress.d.ts +12 -2
- package/LinearProgress/LinearProgress.js +225 -126
- package/LinearProgress/LinearProgress.mjs +224 -126
- package/List/List.js +2 -1
- package/List/List.mjs +2 -1
- package/ListItem/ListItem.js +2 -1
- package/ListItem/ListItem.mjs +2 -1
- package/ListItemButton/ListItemButton.js +9 -2
- package/ListItemButton/ListItemButton.mjs +9 -2
- package/Menu/Menu.d.mts +1 -1
- package/Menu/Menu.d.ts +1 -1
- package/MenuItem/MenuItem.js +7 -1
- package/MenuItem/MenuItem.mjs +7 -1
- package/MenuList/MenuList.js +2 -1
- package/MenuList/MenuList.mjs +2 -1
- package/MobileStepper/MobileStepper.js +2 -1
- package/MobileStepper/MobileStepper.mjs +2 -1
- package/NativeSelect/NativeSelect.js +2 -5
- package/NativeSelect/NativeSelect.mjs +2 -5
- package/OutlinedInput/NotchedOutline.js +4 -3
- package/OutlinedInput/NotchedOutline.mjs +4 -3
- package/OutlinedInput/OutlinedInput.js +13 -23
- package/OutlinedInput/OutlinedInput.mjs +13 -23
- 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/PigmentContainer/PigmentContainer.js +0 -1
- package/PigmentContainer/PigmentContainer.mjs +0 -1
- package/Popover/Popover.d.mts +1 -1
- package/Popover/Popover.d.ts +1 -1
- package/Popper/BasePopper.js +23 -1
- package/Popper/BasePopper.mjs +23 -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/Select.js +2 -5
- package/Select/Select.mjs +2 -5
- package/Select/SelectInput.js +276 -24
- package/Select/SelectInput.mjs +276 -24
- 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 +97 -47
- package/Slide/Slide.mjs +97 -47
- package/Slider/Slider.js +14 -4
- package/Slider/Slider.mjs +14 -4
- package/Slider/useSlider.js +4 -3
- package/Slider/useSlider.mjs +4 -3
- 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/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/SvgIcon/SvgIcon.js +2 -1
- package/SvgIcon/SvgIcon.mjs +2 -1
- package/SwipeableDrawer/SwipeableDrawer.js +21 -6
- package/SwipeableDrawer/SwipeableDrawer.mjs +21 -6
- package/Switch/Switch.js +10 -8
- package/Switch/Switch.mjs +10 -8
- package/TableSortLabel/TableSortLabel.js +2 -1
- package/TableSortLabel/TableSortLabel.mjs +2 -1
- package/Tabs/ScrollbarSize.js +2 -1
- package/Tabs/ScrollbarSize.mjs +2 -1
- package/Tabs/Tabs.js +16 -4
- package/Tabs/Tabs.mjs +16 -4
- package/Tooltip/Tooltip.d.mts +2 -2
- package/Tooltip/Tooltip.d.ts +2 -2
- package/Tooltip/Tooltip.js +29 -108
- package/Tooltip/Tooltip.mjs +29 -108
- package/Unstable_TrapFocus/FocusTrap.js +60 -22
- package/Unstable_TrapFocus/FocusTrap.mjs +60 -22
- 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 +444 -0
- package/internal/Transition.mjs +436 -0
- package/internal/react-transition-group.d.mts +8 -0
- package/internal/react-transition-group.d.ts +8 -0
- package/package.json +50 -50
- 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/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/responsiveFontSizes.js +19 -8
- package/styles/responsiveFontSizes.mjs +19 -8
- 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/styles/useThemeProps.d.mts +3 -3
- package/styles/useThemeProps.d.ts +3 -3
- 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 +51 -2
- package/transitions/utils.d.ts +51 -2
- package/transitions/utils.js +97 -4
- package/transitions/utils.mjs +94 -4
- package/useAutocomplete/useAutocomplete.d.mts +12 -6
- package/useAutocomplete/useAutocomplete.d.ts +12 -6
- package/useAutocomplete/useAutocomplete.js +230 -55
- package/useAutocomplete/useAutocomplete.mjs +230 -55
- package/utils/contains.d.mts +2 -0
- package/utils/contains.d.ts +2 -0
- package/utils/contains.js +9 -0
- package/utils/contains.mjs +2 -0
- package/utils/focusable.d.mts +7 -0
- package/utils/focusable.d.ts +7 -0
- package/utils/focusable.js +20 -0
- package/utils/focusable.mjs +13 -0
- package/utils/getEventTarget.d.mts +2 -0
- package/utils/getEventTarget.d.ts +2 -0
- package/utils/getEventTarget.js +9 -0
- package/utils/getEventTarget.mjs +2 -0
- package/utils/mergeSlotProps.js +2 -8
- package/utils/mergeSlotProps.mjs +1 -8
- package/version/index.js +2 -2
- package/version/index.mjs +2 -2
- package/FormControl/formControlState.js +0 -21
- package/FormControl/formControlState.mjs +0 -15
- /package/transitions/{transition.js → types.js} +0 -0
- /package/transitions/{transition.mjs → types.mjs} +0 -0
|
@@ -0,0 +1,444 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/// <reference path="./react-transition-group.d.ts" />
|
|
3
|
+
'use client';
|
|
4
|
+
|
|
5
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
6
|
+
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports.default = void 0;
|
|
11
|
+
var React = _interopRequireWildcard(require("react"));
|
|
12
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
13
|
+
var _useEnhancedEffect = _interopRequireDefault(require("@mui/utils/useEnhancedEffect"));
|
|
14
|
+
var _useValueAsRef = _interopRequireDefault(require("@mui/utils/useValueAsRef"));
|
|
15
|
+
var _TransitionGroupContext = _interopRequireDefault(require("react-transition-group/TransitionGroupContext"));
|
|
16
|
+
var _utils = require("../transitions/utils");
|
|
17
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
18
|
+
// Material UI transitions must still work inside react-transition-group's TransitionGroup.
|
|
19
|
+
// Import only its context module; do not import its Transition or TransitionGroup components.
|
|
20
|
+
|
|
21
|
+
function resolveTimeouts(timeout) {
|
|
22
|
+
if (timeout == null) {
|
|
23
|
+
return {
|
|
24
|
+
appear: undefined,
|
|
25
|
+
enter: undefined,
|
|
26
|
+
exit: undefined
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
if (typeof timeout === 'number') {
|
|
30
|
+
return {
|
|
31
|
+
appear: timeout,
|
|
32
|
+
enter: timeout,
|
|
33
|
+
exit: timeout
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
const enter = timeout.enter;
|
|
37
|
+
const exit = timeout.exit;
|
|
38
|
+
const appear = timeout.appear !== undefined ? timeout.appear : enter;
|
|
39
|
+
return {
|
|
40
|
+
appear,
|
|
41
|
+
enter,
|
|
42
|
+
exit
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
* Resolves the authored completion timeout for the current transition phase.
|
|
48
|
+
* Auto durations are read by the caller at scheduling time so Grow/Collapse
|
|
49
|
+
* can pass the latest measured value without storing it in React state.
|
|
50
|
+
*/
|
|
51
|
+
function getCompletionTimeout(params) {
|
|
52
|
+
if (params.autoTimeout != null) {
|
|
53
|
+
return params.autoTimeout;
|
|
54
|
+
}
|
|
55
|
+
const resolved = resolveTimeouts(params.timeout);
|
|
56
|
+
if (params.currentStatus === 'entering') {
|
|
57
|
+
return params.isAppearing ? resolved.appear ?? resolved.enter ?? null : resolved.enter ?? null;
|
|
58
|
+
}
|
|
59
|
+
return resolved.exit ?? null;
|
|
60
|
+
}
|
|
61
|
+
function Transition(props) {
|
|
62
|
+
const {
|
|
63
|
+
in: inProp = false,
|
|
64
|
+
appear = false,
|
|
65
|
+
enter = true,
|
|
66
|
+
exit = true,
|
|
67
|
+
mountOnEnter = false,
|
|
68
|
+
unmountOnExit = false,
|
|
69
|
+
timeout,
|
|
70
|
+
addEndListener,
|
|
71
|
+
reduceMotion = false,
|
|
72
|
+
getAutoTimeout,
|
|
73
|
+
nodeRef,
|
|
74
|
+
onEnter,
|
|
75
|
+
onEntering,
|
|
76
|
+
onEntered,
|
|
77
|
+
onExit,
|
|
78
|
+
onExiting,
|
|
79
|
+
onExited,
|
|
80
|
+
children,
|
|
81
|
+
...childProps
|
|
82
|
+
} = props;
|
|
83
|
+
const parentGroup = React.useContext(_TransitionGroupContext.default);
|
|
84
|
+
|
|
85
|
+
// react-transition-group's TransitionGroup tells children whether the group
|
|
86
|
+
// is still mounting. Material UI needs two values from that:
|
|
87
|
+
// - shouldEnterOnMount: whether this child should run an enter animation now.
|
|
88
|
+
// - isAppearing: the value passed to enter callbacks.
|
|
89
|
+
// A child added after the group mounted still enters, but callbacks receive
|
|
90
|
+
// isAppearing=false because the parent group is no longer mounting.
|
|
91
|
+
const shouldEnterOnMount = parentGroup && !parentGroup.isMounting ? enter : appear;
|
|
92
|
+
const [status, setStatus] = React.useState(() => {
|
|
93
|
+
if (inProp) {
|
|
94
|
+
return shouldEnterOnMount ? 'exited' : 'entered';
|
|
95
|
+
}
|
|
96
|
+
if (mountOnEnter || unmountOnExit) {
|
|
97
|
+
return 'unmounted';
|
|
98
|
+
}
|
|
99
|
+
return 'exited';
|
|
100
|
+
});
|
|
101
|
+
const statusRef = React.useRef(status);
|
|
102
|
+
statusRef.current = status;
|
|
103
|
+
const shouldAppearOnMountRef = React.useRef(inProp && shouldEnterOnMount);
|
|
104
|
+
const mountedRef = React.useRef(false);
|
|
105
|
+
const nextCallbackRef = React.useRef(null);
|
|
106
|
+
// Remember which status already fired lifecycle callbacks. React StrictMode
|
|
107
|
+
// can run effects twice in development; this prevents duplicate callbacks.
|
|
108
|
+
const lastFiredStatusRef = React.useRef(status);
|
|
109
|
+
// Store the isAppearing value for the current enter transition. performEnter
|
|
110
|
+
// sets it before the status effect later calls onEntering/onEntered.
|
|
111
|
+
const isAppearingRef = React.useRef(false);
|
|
112
|
+
// Capture reduced motion at the start of each phase so prop updates do not
|
|
113
|
+
// change the completion timing for an active transition.
|
|
114
|
+
const transitionReduceMotionRef = React.useRef(reduceMotion);
|
|
115
|
+
|
|
116
|
+
// Transition end callbacks can run after props changed. Read props through
|
|
117
|
+
// this ref so delayed work uses the latest callbacks and timeout settings.
|
|
118
|
+
const propsRef = (0, _useValueAsRef.default)({
|
|
119
|
+
timeout,
|
|
120
|
+
addEndListener,
|
|
121
|
+
reduceMotion,
|
|
122
|
+
getAutoTimeout,
|
|
123
|
+
onEnter,
|
|
124
|
+
onEntering,
|
|
125
|
+
onEntered,
|
|
126
|
+
onExit,
|
|
127
|
+
onExiting,
|
|
128
|
+
onExited,
|
|
129
|
+
enter,
|
|
130
|
+
exit,
|
|
131
|
+
mountOnEnter,
|
|
132
|
+
unmountOnExit,
|
|
133
|
+
nodeRef,
|
|
134
|
+
parentGroup
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
// Effects below depend on these helpers. Keep their identity stable; they read
|
|
138
|
+
// changing props through propsRef.
|
|
139
|
+
const cancelPendingCallback = React.useCallback(() => {
|
|
140
|
+
if (nextCallbackRef.current !== null) {
|
|
141
|
+
nextCallbackRef.current.cancel();
|
|
142
|
+
nextCallbackRef.current = null;
|
|
143
|
+
}
|
|
144
|
+
}, []);
|
|
145
|
+
const makeCallback = React.useCallback(handler => {
|
|
146
|
+
let active = true;
|
|
147
|
+
const wrapped = () => {
|
|
148
|
+
if (active) {
|
|
149
|
+
active = false;
|
|
150
|
+
nextCallbackRef.current = null;
|
|
151
|
+
handler();
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
wrapped.cancel = () => {
|
|
155
|
+
active = false;
|
|
156
|
+
};
|
|
157
|
+
nextCallbackRef.current = wrapped;
|
|
158
|
+
return wrapped;
|
|
159
|
+
}, []);
|
|
160
|
+
const scheduleTransitionEnd = React.useCallback((nextStatus, currentStatus) => {
|
|
161
|
+
let timeoutId;
|
|
162
|
+
const clearTimer = () => {
|
|
163
|
+
if (timeoutId !== undefined) {
|
|
164
|
+
clearTimeout(timeoutId);
|
|
165
|
+
timeoutId = undefined;
|
|
166
|
+
}
|
|
167
|
+
};
|
|
168
|
+
const done = makeCallback(() => {
|
|
169
|
+
clearTimer();
|
|
170
|
+
statusRef.current = nextStatus;
|
|
171
|
+
setStatus(nextStatus);
|
|
172
|
+
});
|
|
173
|
+
const cancelDone = done.cancel;
|
|
174
|
+
done.cancel = () => {
|
|
175
|
+
clearTimer();
|
|
176
|
+
cancelDone();
|
|
177
|
+
};
|
|
178
|
+
const node = propsRef.current.nodeRef.current;
|
|
179
|
+
const listener = propsRef.current.addEndListener;
|
|
180
|
+
const hasAutoTimeout = propsRef.current.getAutoTimeout !== undefined;
|
|
181
|
+
const autoTimeout = propsRef.current.getAutoTimeout?.();
|
|
182
|
+
const authoredTimeout = getCompletionTimeout({
|
|
183
|
+
currentStatus,
|
|
184
|
+
isAppearing: isAppearingRef.current,
|
|
185
|
+
timeout: propsRef.current.timeout,
|
|
186
|
+
autoTimeout
|
|
187
|
+
});
|
|
188
|
+
const transitionReduceMotion = transitionReduceMotionRef.current;
|
|
189
|
+
// Auto-duration consumers may skip measurement under reduced motion, but
|
|
190
|
+
// still need a 0ms timeout when they provide addEndListener.
|
|
191
|
+
const fallbackTimeout = authoredTimeout ?? (transitionReduceMotion && hasAutoTimeout ? 0 : null);
|
|
192
|
+
const scheduleTimer = value => {
|
|
193
|
+
timeoutId = setTimeout(done, value);
|
|
194
|
+
};
|
|
195
|
+
if (!node) {
|
|
196
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
197
|
+
console.warn(['MUI: The transition child does not expose a DOM element.', 'Make sure the child accepts a ref and forwards it to the underlying DOM element.', 'The transition animation cannot be observed without a DOM element and will be skipped.'].join('\n'));
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
// Match react-transition-group: if there is no DOM node, there is no
|
|
201
|
+
// transition to observe, so finish on the next tick.
|
|
202
|
+
scheduleTimer(0);
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
205
|
+
if (listener) {
|
|
206
|
+
if (fallbackTimeout != null) {
|
|
207
|
+
scheduleTimer(transitionReduceMotion ? 0 : fallbackTimeout);
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// With nodeRef, react-transition-group calls addEndListener(done).
|
|
211
|
+
// Material UI has long supported addEndListener(node, done). Keep both call
|
|
212
|
+
// shapes so existing transition wrappers do not have to change.
|
|
213
|
+
if (listener.length >= 2) {
|
|
214
|
+
listener(node, done);
|
|
215
|
+
} else {
|
|
216
|
+
listener(done);
|
|
217
|
+
}
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
scheduleTimer(transitionReduceMotion ? 0 : authoredTimeout ?? 0);
|
|
221
|
+
}, [makeCallback, propsRef]);
|
|
222
|
+
const performEnter = React.useCallback(mounting => {
|
|
223
|
+
const current = propsRef.current;
|
|
224
|
+
const isAppearing = current.parentGroup ? current.parentGroup.isMounting : mounting;
|
|
225
|
+
isAppearingRef.current = isAppearing;
|
|
226
|
+
|
|
227
|
+
// On updates, enter=false skips the enter animation. Move straight to
|
|
228
|
+
// entered; the status effect will call onEntered, but onEnter/onEntering
|
|
229
|
+
// must not fire.
|
|
230
|
+
if (!mounting && !current.enter) {
|
|
231
|
+
statusRef.current = 'entered';
|
|
232
|
+
setStatus('entered');
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
235
|
+
transitionReduceMotionRef.current = current.reduceMotion;
|
|
236
|
+
current.onEnter?.(isAppearing);
|
|
237
|
+
statusRef.current = 'entering';
|
|
238
|
+
setStatus('entering');
|
|
239
|
+
}, [propsRef]);
|
|
240
|
+
const performExit = React.useCallback(() => {
|
|
241
|
+
const current = propsRef.current;
|
|
242
|
+
if (!current.exit) {
|
|
243
|
+
statusRef.current = 'exited';
|
|
244
|
+
setStatus('exited');
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
transitionReduceMotionRef.current = current.reduceMotion;
|
|
248
|
+
current.onExit?.();
|
|
249
|
+
statusRef.current = 'exiting';
|
|
250
|
+
setStatus('exiting');
|
|
251
|
+
}, [propsRef]);
|
|
252
|
+
const updateStatus = React.useCallback((mounting, nextStatus) => {
|
|
253
|
+
cancelPendingCallback();
|
|
254
|
+
if (nextStatus === 'entering') {
|
|
255
|
+
const current = propsRef.current;
|
|
256
|
+
// If the node was just mounted, read layout before entering so the
|
|
257
|
+
// browser applies the starting styles before the animation begins.
|
|
258
|
+
if (current.mountOnEnter || current.unmountOnExit) {
|
|
259
|
+
const node = current.nodeRef.current;
|
|
260
|
+
if (node) {
|
|
261
|
+
(0, _utils.reflow)(node);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
performEnter(mounting);
|
|
265
|
+
} else {
|
|
266
|
+
performExit();
|
|
267
|
+
}
|
|
268
|
+
}, [cancelPendingCallback, performEnter, performExit, propsRef]);
|
|
269
|
+
|
|
270
|
+
// Runs on mount. useEnhancedEffect is needed because the initial appear
|
|
271
|
+
// transition may read layout before paint. In StrictMode development builds,
|
|
272
|
+
// React mounts, cleans up, and mounts again; cleanup cancels pending work and
|
|
273
|
+
// the second mount restarts the same transition.
|
|
274
|
+
(0, _useEnhancedEffect.default)(() => {
|
|
275
|
+
mountedRef.current = true;
|
|
276
|
+
if (shouldAppearOnMountRef.current) {
|
|
277
|
+
shouldAppearOnMountRef.current = false;
|
|
278
|
+
updateStatus(true, 'entering');
|
|
279
|
+
}
|
|
280
|
+
return () => {
|
|
281
|
+
mountedRef.current = false;
|
|
282
|
+
cancelPendingCallback();
|
|
283
|
+
};
|
|
284
|
+
}, [cancelPendingCallback, updateStatus]);
|
|
285
|
+
|
|
286
|
+
// Reconcile the rendered status after `in` or status changes:
|
|
287
|
+
// - opening from unmounted first renders the child as exited so refs exist.
|
|
288
|
+
// - unmountOnExit removes the child after the exited state commits.
|
|
289
|
+
// This matches react-transition-group's observable status steps without
|
|
290
|
+
// running work after unrelated commits.
|
|
291
|
+
(0, _useEnhancedEffect.default)(() => {
|
|
292
|
+
if (!mountedRef.current) {
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
295
|
+
const current = statusRef.current;
|
|
296
|
+
if (inProp) {
|
|
297
|
+
if (current === 'unmounted') {
|
|
298
|
+
// Opening from unmounted needs one render with the child present so
|
|
299
|
+
// refs are attached before the enter animation starts.
|
|
300
|
+
statusRef.current = 'exited';
|
|
301
|
+
setStatus('exited');
|
|
302
|
+
} else if (current !== 'entering' && current !== 'entered') {
|
|
303
|
+
updateStatus(false, 'entering');
|
|
304
|
+
}
|
|
305
|
+
} else if (current === 'entering' || current === 'entered') {
|
|
306
|
+
updateStatus(false, 'exiting');
|
|
307
|
+
} else if (current === 'exited' && unmountOnExit) {
|
|
308
|
+
statusRef.current = 'unmounted';
|
|
309
|
+
setStatus('unmounted');
|
|
310
|
+
}
|
|
311
|
+
}, [inProp, status, unmountOnExit, updateStatus]);
|
|
312
|
+
|
|
313
|
+
// Fire lifecycle callbacks for committed status changes. The guard prevents
|
|
314
|
+
// duplicate callbacks in StrictMode; propsRef keeps delayed callbacks fresh.
|
|
315
|
+
(0, _useEnhancedEffect.default)(() => {
|
|
316
|
+
// `unmounted` is bookkeeping, not a real transition state. Do not fire
|
|
317
|
+
// callbacks when moving into or out of it; otherwise the first open with
|
|
318
|
+
// mountOnEnter/unmountOnExit would look like a completed exit.
|
|
319
|
+
if (status === 'unmounted' || lastFiredStatusRef.current === 'unmounted') {
|
|
320
|
+
lastFiredStatusRef.current = status;
|
|
321
|
+
return;
|
|
322
|
+
}
|
|
323
|
+
const prev = lastFiredStatusRef.current;
|
|
324
|
+
if (prev === status) {
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
lastFiredStatusRef.current = status;
|
|
328
|
+
const current = propsRef.current;
|
|
329
|
+
if (status === 'entering') {
|
|
330
|
+
current.onEntering?.(isAppearingRef.current);
|
|
331
|
+
scheduleTransitionEnd('entered', 'entering');
|
|
332
|
+
} else if (status === 'exiting') {
|
|
333
|
+
current.onExiting?.();
|
|
334
|
+
scheduleTransitionEnd('exited', 'exiting');
|
|
335
|
+
} else if (status === 'entered') {
|
|
336
|
+
current.onEntered?.(isAppearingRef.current);
|
|
337
|
+
} else if (status === 'exited') {
|
|
338
|
+
current.onExited?.();
|
|
339
|
+
}
|
|
340
|
+
}, [propsRef, scheduleTransitionEnd, status]);
|
|
341
|
+
if (status === 'unmounted') {
|
|
342
|
+
return null;
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
// Nested Material UI transitions should not inherit this transition's parent group.
|
|
346
|
+
// A null context keeps an outer TransitionGroup from controlling them.
|
|
347
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_TransitionGroupContext.default.Provider, {
|
|
348
|
+
value: null,
|
|
349
|
+
children: children(status, childProps)
|
|
350
|
+
});
|
|
351
|
+
}
|
|
352
|
+
process.env.NODE_ENV !== "production" ? Transition.propTypes /* remove-proptypes */ = {
|
|
353
|
+
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
|
354
|
+
// │ These PropTypes are generated from the TypeScript type definitions. │
|
|
355
|
+
// │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
|
|
356
|
+
// └─────────────────────────────────────────────────────────────────────┘
|
|
357
|
+
/**
|
|
358
|
+
* @ignore
|
|
359
|
+
*/
|
|
360
|
+
addEndListener: _propTypes.default.func,
|
|
361
|
+
/**
|
|
362
|
+
* @ignore
|
|
363
|
+
*/
|
|
364
|
+
appear: _propTypes.default.bool,
|
|
365
|
+
/**
|
|
366
|
+
* @ignore
|
|
367
|
+
*/
|
|
368
|
+
children: _propTypes.default.func.isRequired,
|
|
369
|
+
/**
|
|
370
|
+
* @ignore
|
|
371
|
+
*/
|
|
372
|
+
enter: _propTypes.default.bool,
|
|
373
|
+
/**
|
|
374
|
+
* @ignore
|
|
375
|
+
*/
|
|
376
|
+
exit: _propTypes.default.bool,
|
|
377
|
+
/**
|
|
378
|
+
* @ignore
|
|
379
|
+
*/
|
|
380
|
+
getAutoTimeout: _propTypes.default.func,
|
|
381
|
+
/**
|
|
382
|
+
* @ignore
|
|
383
|
+
*/
|
|
384
|
+
in: _propTypes.default.bool,
|
|
385
|
+
/**
|
|
386
|
+
* @ignore
|
|
387
|
+
*/
|
|
388
|
+
mountOnEnter: _propTypes.default.bool,
|
|
389
|
+
/**
|
|
390
|
+
* @ignore
|
|
391
|
+
*/
|
|
392
|
+
nodeRef: _propTypes.default.shape({
|
|
393
|
+
current: (props, propName) => {
|
|
394
|
+
if (props[propName] == null) {
|
|
395
|
+
return null;
|
|
396
|
+
}
|
|
397
|
+
if (typeof props[propName] !== 'object' || props[propName].nodeType !== 1) {
|
|
398
|
+
return new Error(`Expected prop '${propName}' to be of type Element`);
|
|
399
|
+
}
|
|
400
|
+
return null;
|
|
401
|
+
}
|
|
402
|
+
}).isRequired,
|
|
403
|
+
/**
|
|
404
|
+
* @ignore
|
|
405
|
+
*/
|
|
406
|
+
onEnter: _propTypes.default.func,
|
|
407
|
+
/**
|
|
408
|
+
* @ignore
|
|
409
|
+
*/
|
|
410
|
+
onEntered: _propTypes.default.func,
|
|
411
|
+
/**
|
|
412
|
+
* @ignore
|
|
413
|
+
*/
|
|
414
|
+
onEntering: _propTypes.default.func,
|
|
415
|
+
/**
|
|
416
|
+
* @ignore
|
|
417
|
+
*/
|
|
418
|
+
onExit: _propTypes.default.func,
|
|
419
|
+
/**
|
|
420
|
+
* @ignore
|
|
421
|
+
*/
|
|
422
|
+
onExited: _propTypes.default.func,
|
|
423
|
+
/**
|
|
424
|
+
* @ignore
|
|
425
|
+
*/
|
|
426
|
+
onExiting: _propTypes.default.func,
|
|
427
|
+
/**
|
|
428
|
+
* @ignore
|
|
429
|
+
*/
|
|
430
|
+
reduceMotion: _propTypes.default.bool,
|
|
431
|
+
/**
|
|
432
|
+
* @ignore
|
|
433
|
+
*/
|
|
434
|
+
timeout: _propTypes.default.oneOfType([_propTypes.default.number, _propTypes.default.shape({
|
|
435
|
+
appear: _propTypes.default.number,
|
|
436
|
+
enter: _propTypes.default.number,
|
|
437
|
+
exit: _propTypes.default.number
|
|
438
|
+
})]),
|
|
439
|
+
/**
|
|
440
|
+
* @ignore
|
|
441
|
+
*/
|
|
442
|
+
unmountOnExit: _propTypes.default.bool
|
|
443
|
+
} : void 0;
|
|
444
|
+
var _default = exports.default = Transition;
|