@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.
Files changed (278) hide show
  1. package/Accordion/Accordion.d.mts +2 -2
  2. package/Accordion/Accordion.d.ts +2 -2
  3. package/Accordion/Accordion.js +3 -2
  4. package/Accordion/Accordion.mjs +3 -2
  5. package/AccordionSummary/AccordionSummary.js +27 -29
  6. package/AccordionSummary/AccordionSummary.mjs +27 -29
  7. package/Autocomplete/Autocomplete.js +73 -17
  8. package/Autocomplete/Autocomplete.mjs +73 -17
  9. package/Avatar/Avatar.js +4 -0
  10. package/Avatar/Avatar.mjs +4 -0
  11. package/Backdrop/Backdrop.d.mts +2 -2
  12. package/Backdrop/Backdrop.d.ts +2 -2
  13. package/Badge/Badge.js +31 -24
  14. package/Badge/Badge.mjs +31 -24
  15. package/BottomNavigationAction/BottomNavigationAction.js +6 -2
  16. package/BottomNavigationAction/BottomNavigationAction.mjs +6 -2
  17. package/Button/Button.js +19 -6
  18. package/Button/Button.mjs +19 -6
  19. package/ButtonBase/ButtonBase.d.mts +7 -0
  20. package/ButtonBase/ButtonBase.d.ts +7 -0
  21. package/ButtonBase/ButtonBase.js +5 -2
  22. package/ButtonBase/ButtonBase.mjs +5 -2
  23. package/ButtonBase/Ripple.js +21 -11
  24. package/ButtonBase/Ripple.mjs +21 -11
  25. package/ButtonBase/TouchRipple.js +252 -116
  26. package/ButtonBase/TouchRipple.mjs +253 -117
  27. package/CHANGELOG.md +216 -1245
  28. package/CardActionArea/CardActionArea.js +2 -1
  29. package/CardActionArea/CardActionArea.mjs +2 -1
  30. package/Checkbox/Checkbox.js +2 -1
  31. package/Checkbox/Checkbox.mjs +2 -1
  32. package/Chip/Chip.js +2 -1
  33. package/Chip/Chip.mjs +2 -1
  34. package/CircularProgress/CircularProgress.d.mts +12 -2
  35. package/CircularProgress/CircularProgress.d.ts +12 -2
  36. package/CircularProgress/CircularProgress.js +115 -58
  37. package/CircularProgress/CircularProgress.mjs +114 -58
  38. package/ClickAwayListener/ClickAwayListener.js +3 -6
  39. package/ClickAwayListener/ClickAwayListener.mjs +3 -6
  40. package/Collapse/Collapse.d.mts +15 -3
  41. package/Collapse/Collapse.d.ts +15 -3
  42. package/Collapse/Collapse.js +44 -31
  43. package/Collapse/Collapse.mjs +43 -30
  44. package/Dialog/Dialog.d.mts +2 -2
  45. package/Dialog/Dialog.d.ts +2 -2
  46. package/Dialog/Dialog.js +13 -6
  47. package/Dialog/Dialog.mjs +13 -6
  48. package/Drawer/Drawer.d.mts +2 -2
  49. package/Drawer/Drawer.d.ts +2 -2
  50. package/Drawer/Drawer.js +18 -4
  51. package/Drawer/Drawer.mjs +18 -4
  52. package/Fab/Fab.js +9 -2
  53. package/Fab/Fab.mjs +9 -2
  54. package/Fade/Fade.d.mts +15 -2
  55. package/Fade/Fade.d.ts +15 -2
  56. package/Fade/Fade.js +46 -19
  57. package/Fade/Fade.mjs +45 -18
  58. package/FilledInput/FilledInput.d.mts +4 -0
  59. package/FilledInput/FilledInput.d.ts +4 -0
  60. package/FilledInput/FilledInput.js +22 -23
  61. package/FilledInput/FilledInput.mjs +22 -23
  62. package/FormControl/useFormControl.d.mts +12 -2
  63. package/FormControl/useFormControl.d.ts +12 -2
  64. package/FormControl/useFormControl.js +13 -0
  65. package/FormControl/useFormControl.mjs +12 -0
  66. package/FormControlLabel/FormControlLabel.js +5 -8
  67. package/FormControlLabel/FormControlLabel.mjs +5 -8
  68. package/FormGroup/FormGroup.js +2 -5
  69. package/FormGroup/FormGroup.mjs +2 -5
  70. package/FormHelperText/FormHelperText.js +2 -5
  71. package/FormHelperText/FormHelperText.mjs +2 -5
  72. package/FormLabel/FormLabel.js +2 -5
  73. package/FormLabel/FormLabel.mjs +2 -5
  74. package/Grow/Grow.d.mts +15 -2
  75. package/Grow/Grow.d.ts +15 -2
  76. package/Grow/Grow.js +45 -28
  77. package/Grow/Grow.mjs +44 -27
  78. package/IconButton/IconButton.js +3 -9
  79. package/IconButton/IconButton.mjs +3 -9
  80. package/Input/Input.d.mts +4 -0
  81. package/Input/Input.d.ts +4 -0
  82. package/Input/Input.js +9 -2
  83. package/Input/Input.mjs +9 -2
  84. package/InputBase/InputBase.d.mts +2 -1
  85. package/InputBase/InputBase.d.ts +2 -1
  86. package/InputBase/InputBase.js +52 -16
  87. package/InputBase/InputBase.mjs +52 -16
  88. package/InputLabel/InputLabel.js +7 -9
  89. package/InputLabel/InputLabel.mjs +7 -9
  90. package/LICENSE +1 -1
  91. package/LinearProgress/LinearProgress.d.mts +12 -2
  92. package/LinearProgress/LinearProgress.d.ts +12 -2
  93. package/LinearProgress/LinearProgress.js +225 -126
  94. package/LinearProgress/LinearProgress.mjs +224 -126
  95. package/List/List.js +2 -1
  96. package/List/List.mjs +2 -1
  97. package/ListItem/ListItem.js +2 -1
  98. package/ListItem/ListItem.mjs +2 -1
  99. package/ListItemButton/ListItemButton.js +9 -2
  100. package/ListItemButton/ListItemButton.mjs +9 -2
  101. package/Menu/Menu.d.mts +1 -1
  102. package/Menu/Menu.d.ts +1 -1
  103. package/MenuItem/MenuItem.js +7 -1
  104. package/MenuItem/MenuItem.mjs +7 -1
  105. package/MenuList/MenuList.js +2 -1
  106. package/MenuList/MenuList.mjs +2 -1
  107. package/MobileStepper/MobileStepper.js +2 -1
  108. package/MobileStepper/MobileStepper.mjs +2 -1
  109. package/NativeSelect/NativeSelect.js +2 -5
  110. package/NativeSelect/NativeSelect.mjs +2 -5
  111. package/OutlinedInput/NotchedOutline.js +4 -3
  112. package/OutlinedInput/NotchedOutline.mjs +4 -3
  113. package/OutlinedInput/OutlinedInput.js +13 -23
  114. package/OutlinedInput/OutlinedInput.mjs +13 -23
  115. package/PaginationItem/PaginationItem.js +2 -1
  116. package/PaginationItem/PaginationItem.mjs +2 -1
  117. package/Paper/Paper.js +2 -1
  118. package/Paper/Paper.mjs +2 -1
  119. package/PigmentContainer/PigmentContainer.js +0 -1
  120. package/PigmentContainer/PigmentContainer.mjs +0 -1
  121. package/Popover/Popover.d.mts +1 -1
  122. package/Popover/Popover.d.ts +1 -1
  123. package/Popper/BasePopper.js +23 -1
  124. package/Popper/BasePopper.mjs +23 -1
  125. package/README.md +3 -2
  126. package/Radio/RadioButtonIcon.js +3 -2
  127. package/Radio/RadioButtonIcon.mjs +3 -2
  128. package/Rating/Rating.js +2 -1
  129. package/Rating/Rating.mjs +2 -1
  130. package/Select/Select.js +2 -5
  131. package/Select/Select.mjs +2 -5
  132. package/Select/SelectInput.js +276 -24
  133. package/Select/SelectInput.mjs +276 -24
  134. package/Select/utils/closedTypeahead.js +73 -0
  135. package/Select/utils/closedTypeahead.mjs +63 -0
  136. package/Skeleton/Skeleton.js +22 -2
  137. package/Skeleton/Skeleton.mjs +22 -2
  138. package/Slide/Slide.d.mts +15 -2
  139. package/Slide/Slide.d.ts +15 -2
  140. package/Slide/Slide.js +97 -47
  141. package/Slide/Slide.mjs +97 -47
  142. package/Slider/Slider.js +14 -4
  143. package/Slider/Slider.mjs +14 -4
  144. package/Slider/useSlider.js +4 -3
  145. package/Slider/useSlider.mjs +4 -3
  146. package/Snackbar/Snackbar.d.mts +2 -2
  147. package/Snackbar/Snackbar.d.ts +2 -2
  148. package/SpeedDial/SpeedDial.d.mts +1 -1
  149. package/SpeedDial/SpeedDial.d.ts +1 -1
  150. package/SpeedDial/SpeedDial.js +6 -2
  151. package/SpeedDial/SpeedDial.mjs +6 -2
  152. package/SpeedDialAction/SpeedDialAction.js +11 -2
  153. package/SpeedDialAction/SpeedDialAction.mjs +12 -3
  154. package/SpeedDialIcon/SpeedDialIcon.js +40 -37
  155. package/SpeedDialIcon/SpeedDialIcon.mjs +40 -37
  156. package/Step/Step.js +47 -15
  157. package/Step/Step.mjs +47 -15
  158. package/StepButton/StepButton.js +9 -3
  159. package/StepButton/StepButton.mjs +9 -3
  160. package/StepConnector/StepConnector.js +10 -0
  161. package/StepConnector/StepConnector.mjs +10 -0
  162. package/StepContent/StepContent.d.mts +2 -2
  163. package/StepContent/StepContent.d.ts +2 -2
  164. package/StepContent/StepContent.js +26 -2
  165. package/StepContent/StepContent.mjs +26 -2
  166. package/StepIcon/StepIcon.js +2 -1
  167. package/StepIcon/StepIcon.mjs +2 -1
  168. package/StepLabel/StepLabel.js +52 -7
  169. package/StepLabel/StepLabel.mjs +52 -7
  170. package/Stepper/Stepper.d.mts +2 -0
  171. package/Stepper/Stepper.d.ts +2 -0
  172. package/Stepper/Stepper.js +18 -0
  173. package/Stepper/Stepper.mjs +18 -0
  174. package/SvgIcon/SvgIcon.js +2 -1
  175. package/SvgIcon/SvgIcon.mjs +2 -1
  176. package/SwipeableDrawer/SwipeableDrawer.js +21 -6
  177. package/SwipeableDrawer/SwipeableDrawer.mjs +21 -6
  178. package/Switch/Switch.js +10 -8
  179. package/Switch/Switch.mjs +10 -8
  180. package/TableSortLabel/TableSortLabel.js +2 -1
  181. package/TableSortLabel/TableSortLabel.mjs +2 -1
  182. package/Tabs/ScrollbarSize.js +2 -1
  183. package/Tabs/ScrollbarSize.mjs +2 -1
  184. package/Tabs/Tabs.js +16 -4
  185. package/Tabs/Tabs.mjs +16 -4
  186. package/Tooltip/Tooltip.d.mts +2 -2
  187. package/Tooltip/Tooltip.d.ts +2 -2
  188. package/Tooltip/Tooltip.js +29 -108
  189. package/Tooltip/Tooltip.mjs +29 -108
  190. package/Unstable_TrapFocus/FocusTrap.js +60 -22
  191. package/Unstable_TrapFocus/FocusTrap.mjs +60 -22
  192. package/Zoom/Zoom.d.mts +15 -2
  193. package/Zoom/Zoom.d.ts +15 -2
  194. package/Zoom/Zoom.js +43 -16
  195. package/Zoom/Zoom.mjs +42 -15
  196. package/index.js +1 -1
  197. package/index.mjs +1 -1
  198. package/internal/Transition.d.mts +34 -0
  199. package/internal/Transition.d.ts +34 -0
  200. package/internal/Transition.js +444 -0
  201. package/internal/Transition.mjs +436 -0
  202. package/internal/react-transition-group.d.mts +8 -0
  203. package/internal/react-transition-group.d.ts +8 -0
  204. package/package.json +50 -50
  205. package/styles/createMotion.d.mts +8 -0
  206. package/styles/createMotion.d.ts +8 -0
  207. package/styles/createMotion.js +13 -0
  208. package/styles/createMotion.mjs +7 -0
  209. package/styles/createThemeFoundation.d.mts +2 -0
  210. package/styles/createThemeFoundation.d.ts +2 -0
  211. package/styles/createThemeNoVars.d.mts +3 -0
  212. package/styles/createThemeNoVars.d.ts +3 -0
  213. package/styles/createThemeNoVars.js +5 -0
  214. package/styles/createThemeNoVars.mjs +5 -0
  215. package/styles/createTransitions.d.mts +6 -2
  216. package/styles/createTransitions.d.ts +6 -2
  217. package/styles/createTransitions.js +12 -4
  218. package/styles/createTransitions.mjs +12 -4
  219. package/styles/enhanceHighContrast.d.mts +70 -0
  220. package/styles/enhanceHighContrast.d.ts +70 -0
  221. package/styles/enhanceHighContrast.js +502 -0
  222. package/styles/enhanceHighContrast.mjs +495 -0
  223. package/styles/index.d.mts +2 -0
  224. package/styles/index.d.ts +2 -0
  225. package/styles/index.js +8 -0
  226. package/styles/index.mjs +1 -0
  227. package/styles/reducedMotion.d.mts +7 -0
  228. package/styles/reducedMotion.d.ts +7 -0
  229. package/styles/reducedMotion.js +21 -0
  230. package/styles/reducedMotion.mjs +14 -0
  231. package/styles/responsiveFontSizes.js +19 -8
  232. package/styles/responsiveFontSizes.mjs +19 -8
  233. package/styles/shouldSkipGeneratingVar.js +1 -1
  234. package/styles/shouldSkipGeneratingVar.mjs +1 -1
  235. package/styles/stringifyTheme.js +1 -0
  236. package/styles/stringifyTheme.mjs +1 -0
  237. package/styles/useThemeProps.d.mts +3 -3
  238. package/styles/useThemeProps.d.ts +3 -3
  239. package/transitions/index.d.mts +1 -1
  240. package/transitions/index.d.ts +1 -1
  241. package/transitions/index.js +0 -11
  242. package/transitions/index.mjs +1 -1
  243. package/transitions/transition.d.mts +1 -12
  244. package/transitions/transition.d.ts +1 -12
  245. package/transitions/types.d.mts +73 -0
  246. package/transitions/types.d.ts +73 -0
  247. package/transitions/useReducedMotion.d.mts +14 -0
  248. package/transitions/useReducedMotion.d.ts +14 -0
  249. package/transitions/useReducedMotion.js +117 -0
  250. package/transitions/useReducedMotion.mjs +110 -0
  251. package/transitions/utils.d.mts +51 -2
  252. package/transitions/utils.d.ts +51 -2
  253. package/transitions/utils.js +97 -4
  254. package/transitions/utils.mjs +94 -4
  255. package/useAutocomplete/useAutocomplete.d.mts +12 -6
  256. package/useAutocomplete/useAutocomplete.d.ts +12 -6
  257. package/useAutocomplete/useAutocomplete.js +230 -55
  258. package/useAutocomplete/useAutocomplete.mjs +230 -55
  259. package/utils/contains.d.mts +2 -0
  260. package/utils/contains.d.ts +2 -0
  261. package/utils/contains.js +9 -0
  262. package/utils/contains.mjs +2 -0
  263. package/utils/focusable.d.mts +7 -0
  264. package/utils/focusable.d.ts +7 -0
  265. package/utils/focusable.js +20 -0
  266. package/utils/focusable.mjs +13 -0
  267. package/utils/getEventTarget.d.mts +2 -0
  268. package/utils/getEventTarget.d.ts +2 -0
  269. package/utils/getEventTarget.js +9 -0
  270. package/utils/getEventTarget.mjs +2 -0
  271. package/utils/mergeSlotProps.js +2 -8
  272. package/utils/mergeSlotProps.mjs +1 -8
  273. package/version/index.js +2 -2
  274. package/version/index.mjs +2 -2
  275. package/FormControl/formControlState.js +0 -21
  276. package/FormControl/formControlState.mjs +0 -15
  277. /package/transitions/{transition.js → types.js} +0 -0
  278. /package/transitions/{transition.mjs → types.mjs} +0 -0
package/Slide/Slide.d.mts CHANGED
@@ -1,6 +1,15 @@
1
1
  import * as React from 'react';
2
- import { TransitionProps } from "../transitions/transition.mjs";
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/transition.js";
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,49 +10,63 @@ 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
- // Translate the node so it can't be seen on the screen.
30
- // Later, we're going to translate the node back to its original location with `none`.
31
- function getTranslateValue(direction, node, resolvedContainer) {
31
+ /**
32
+ * Detects SwipeableDrawer's active-swipe `translate(x, y)` transform.
33
+ * Keep this in sync with SwipeableDrawer.setPosition.
34
+ */
35
+ function isGestureTranslate(transform) {
36
+ return typeof transform === 'string' && /^translate\(.+,\s*.+\)$/.test(transform);
37
+ }
38
+
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) {
41
+ const {
42
+ resetInlineTransform = true
43
+ } = options;
32
44
  const containerRect = resolvedContainer && resolvedContainer.getBoundingClientRect();
33
45
  const containerWindow = (0, _utils2.ownerWindow)(node);
34
-
35
- // Clear the inline transform and transition before reading layout and computed
36
- // style so we compute from the element's natural position, not its previous
37
- // off-screen translation. The transition must also be cleared, otherwise the
38
- // browser may report an animated intermediate value from a still-running
39
- // enter transition when reading getComputedStyle during exit.
40
- const previousTransform = node.style.transform;
41
- const previousTransition = node.style.transition;
42
- node.style.transition = '';
43
- node.style.transform = '';
44
- const rect = node.getBoundingClientRect();
45
- const computedStyle = containerWindow.getComputedStyle(node);
46
- const transform = computedStyle.getPropertyValue('transform');
47
- node.style.transform = previousTransform;
48
- node.style.transition = previousTransition;
49
- let offsetX = 0;
50
- let offsetY = 0;
51
- if (transform && transform !== 'none' && typeof transform === 'string') {
52
- const transformValues = transform.split('(')[1].split(')')[0].split(',');
53
- offsetX = parseInt(transformValues[4], 10);
54
- offsetY = parseInt(transformValues[5], 10);
46
+ let rect;
47
+ let transform;
48
+ if (resetInlineTransform) {
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.
52
+ const previousTransform = node.style.transform;
53
+ const previousTransition = node.style.transition;
54
+ node.style.transition = '';
55
+ node.style.transform = '';
56
+ rect = node.getBoundingClientRect();
57
+ const computedStyle = containerWindow.getComputedStyle(node);
58
+ transform = computedStyle.getPropertyValue('transform');
59
+ node.style.transform = previousTransform;
60
+ node.style.transition = previousTransition;
61
+ } else {
62
+ rect = node.getBoundingClientRect();
63
+ const computedStyle = containerWindow.getComputedStyle(node);
64
+ transform = computedStyle.getPropertyValue('transform');
55
65
  }
66
+ const {
67
+ offsetX,
68
+ offsetY
69
+ } = (0, _utils.getTranslateOffsets)(transform);
56
70
  if (direction === 'left') {
57
71
  if (containerRect) {
58
72
  return `translateX(${containerRect.right + offsetX - rect.left}px)`;
@@ -81,9 +95,9 @@ function getTranslateValue(direction, node, resolvedContainer) {
81
95
  function resolveContainer(containerPropProp) {
82
96
  return typeof containerPropProp === 'function' ? containerPropProp() : containerPropProp;
83
97
  }
84
- function setTranslateValue(direction, node, containerProp) {
98
+ function setTranslateValue(direction, node, containerProp, options) {
85
99
  const resolvedContainer = resolveContainer(containerProp);
86
- const transform = getTranslateValue(direction, node, resolvedContainer);
100
+ const transform = getTranslateValue(direction, node, resolvedContainer, options);
87
101
  if (transform) {
88
102
  node.style.transform = transform;
89
103
  }
@@ -91,7 +105,6 @@ function setTranslateValue(direction, node, containerProp) {
91
105
 
92
106
  /**
93
107
  * The Slide transition is used by the [Drawer](/material-ui/react-drawer/) component.
94
- * It uses [react-transition-group](https://github.com/reactjs/react-transition-group) internally.
95
108
  */
96
109
  const Slide = /*#__PURE__*/React.forwardRef(function Slide(props, ref) {
97
110
  const theme = (0, _zeroStyled.useTheme)();
@@ -108,6 +121,7 @@ const Slide = /*#__PURE__*/React.forwardRef(function Slide(props, ref) {
108
121
  appear = true,
109
122
  children,
110
123
  container: containerProp,
124
+ disablePrefersReducedMotion = false,
111
125
  direction = 'down',
112
126
  easing: easingProp = defaultEasing,
113
127
  in: inProp,
@@ -121,11 +135,15 @@ const Slide = /*#__PURE__*/React.forwardRef(function Slide(props, ref) {
121
135
  timeout = defaultTimeout,
122
136
  ...other
123
137
  } = props;
138
+ const reducedMotion = (0, _useReducedMotion.default)(theme.motion.reducedMotion, disablePrefersReducedMotion);
124
139
  const childrenRef = React.useRef(null);
140
+ const preserveInlineTransformRef = React.useRef(false);
125
141
  const handleRef = (0, _useForkRef.default)((0, _getReactElementRef.default)(children), childrenRef, ref);
126
142
  const handleEnter = (0, _utils.normalizedTransitionCallback)(childrenRef, (node, isAppearing) => {
127
143
  setTranslateValue(direction, node, containerProp);
128
- (0, _utils.reflow)(node);
144
+ if (!reducedMotion.shouldReduceMotion) {
145
+ (0, _utils.reflow)(node);
146
+ }
129
147
  if (onEnter) {
130
148
  onEnter(node, isAppearing);
131
149
  }
@@ -138,7 +156,15 @@ const Slide = /*#__PURE__*/React.forwardRef(function Slide(props, ref) {
138
156
  }, {
139
157
  mode: 'enter'
140
158
  });
141
- node.style.transition = theme.transitions.create('transform', transitionProps);
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
+ });
142
168
  node.style.transform = 'none';
143
169
  if (onEntering) {
144
170
  onEntering(node, isAppearing);
@@ -154,32 +180,45 @@ const Slide = /*#__PURE__*/React.forwardRef(function Slide(props, ref) {
154
180
  }, {
155
181
  mode: 'exit'
156
182
  });
157
- node.style.transition = theme.transitions.create('transform', transitionProps);
158
- setTranslateValue(direction, node, containerProp);
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
+ });
192
+ const preserveInlineTransform = isGestureTranslate(node.style.transform);
193
+ preserveInlineTransformRef.current = preserveInlineTransform;
194
+
195
+ // Preserve SwipeableDrawer's inline gesture transform during exit. Slide's
196
+ // own off-screen translateX/Y transforms still use the reset path.
197
+ setTranslateValue(direction, node, containerProp, {
198
+ resetInlineTransform: !preserveInlineTransform
199
+ });
159
200
  if (onExit) {
160
201
  onExit(node);
161
202
  }
162
203
  });
163
204
  const handleExited = (0, _utils.normalizedTransitionCallback)(childrenRef, node => {
164
- // No need for transitions when the component is hidden
205
+ preserveInlineTransformRef.current = false;
206
+ // Hidden nodes stay off-screen without animating.
165
207
  node.style.transition = '';
166
208
  if (onExited) {
167
209
  onExited(node);
168
210
  }
169
211
  });
170
- const handleAddEndListener = next => {
171
- if (addEndListener) {
172
- // Old call signature before `react-transition-group` implemented `nodeRef`
173
- addEndListener(childrenRef.current, next);
174
- }
175
- };
212
+ const handleAddEndListener = addEndListener ? next => {
213
+ addEndListener(childrenRef.current, next);
214
+ } : undefined;
176
215
  const updatePosition = React.useCallback(() => {
177
216
  if (childrenRef.current) {
178
217
  setTranslateValue(direction, childrenRef.current, containerProp);
179
218
  }
180
219
  }, [direction, containerProp]);
181
220
  React.useEffect(() => {
182
- // Skip configuration where the position is screen size invariant.
221
+ // Skip resize listeners when the off-screen position does not depend on screen size.
183
222
  if (inProp || direction === 'down' || direction === 'right') {
184
223
  return undefined;
185
224
  }
@@ -196,13 +235,13 @@ const Slide = /*#__PURE__*/React.forwardRef(function Slide(props, ref) {
196
235
  };
197
236
  }, [direction, inProp, containerProp]);
198
237
  React.useEffect(() => {
199
- if (!inProp) {
200
- // We need to update the position of the drawer when the direction change and
201
- // when it's hidden.
238
+ if (!inProp && !preserveInlineTransformRef.current) {
239
+ // While hidden, keep the child at the correct off-screen position if
240
+ // direction or container changes.
202
241
  updatePosition();
203
242
  }
204
243
  }, [inProp, updatePosition]);
205
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactTransitionGroup.Transition, {
244
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Transition.default, {
206
245
  nodeRef: childrenRef,
207
246
  onEnter: handleEnter,
208
247
  onEntered: handleEntered,
@@ -213,12 +252,15 @@ const Slide = /*#__PURE__*/React.forwardRef(function Slide(props, ref) {
213
252
  addEndListener: handleAddEndListener,
214
253
  appear: appear,
215
254
  in: inProp,
255
+ reduceMotion: reducedMotion.shouldReduceMotion,
216
256
  timeout: timeout,
217
257
  ...other,
218
258
  children: (state, {
219
259
  ownerState,
220
260
  ...restChildProps
221
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.
222
264
  let childStyle;
223
265
  if (state === 'exited' && !inProp) {
224
266
  childStyle = style || children.props.style ? {
@@ -248,9 +290,12 @@ process.env.NODE_ENV !== "production" ? Slide.propTypes /* remove-proptypes */ =
248
290
  // │ To update them, edit the d.ts file and run `pnpm proptypes`. │
249
291
  // └─────────────────────────────────────────────────────────────────────┘
250
292
  /**
251
- * Add a custom transition end trigger. Called with the transitioning DOM
252
- * node and a done callback. Allows for more fine grained transition end
253
- * logic. Note: Timeouts are still used as a fallback if provided.
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.
254
299
  */
255
300
  addEndListener: _propTypes.default.func,
256
301
  /**
@@ -288,6 +333,11 @@ process.env.NODE_ENV !== "production" ? Slide.propTypes /* remove-proptypes */ =
288
333
  * @default 'down'
289
334
  */
290
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,
291
341
  /**
292
342
  * The transition timing function.
293
343
  * You may specify a single easing or a object containing enter and exit values.
package/Slide/Slide.mjs CHANGED
@@ -2,49 +2,63 @@
2
2
 
3
3
  import * as React from 'react';
4
4
  import PropTypes from 'prop-types';
5
- import { Transition } from 'react-transition-group';
6
5
  import chainPropTypes from '@mui/utils/chainPropTypes';
7
6
  import HTMLElementType from '@mui/utils/HTMLElementType';
8
7
  import elementAcceptingRef from '@mui/utils/elementAcceptingRef';
9
8
  import getReactElementRef from '@mui/utils/getReactElementRef';
9
+ import Transition from "../internal/Transition.mjs";
10
10
  import isLayoutSupported from "../utils/isLayoutSupported.mjs";
11
11
  import debounce from "../utils/debounce.mjs";
12
12
  import useForkRef from "../utils/useForkRef.mjs";
13
13
  import { useTheme } from "../zero-styled/index.mjs";
14
- import { normalizedTransitionCallback, reflow, getTransitionProps } from "../transitions/utils.mjs";
14
+ import useReducedMotion from "../transitions/useReducedMotion.mjs";
15
+ import { normalizedTransitionCallback, reflow, getTransitionProps, getTranslateOffsets } from "../transitions/utils.mjs";
15
16
  import { ownerWindow } from "../utils/index.mjs";
16
17
  import { jsx as _jsx } from "react/jsx-runtime";
17
18
  const hiddenStyles = {
18
19
  visibility: 'hidden'
19
20
  };
21
+ const DEFAULT_TRANSLATE_OPTIONS = {};
20
22
 
21
- // Translate the node so it can't be seen on the screen.
22
- // Later, we're going to translate the node back to its original location with `none`.
23
- function getTranslateValue(direction, node, resolvedContainer) {
23
+ /**
24
+ * Detects SwipeableDrawer's active-swipe `translate(x, y)` transform.
25
+ * Keep this in sync with SwipeableDrawer.setPosition.
26
+ */
27
+ function isGestureTranslate(transform) {
28
+ return typeof transform === 'string' && /^translate\(.+,\s*.+\)$/.test(transform);
29
+ }
30
+
31
+ // Move the node off-screen. Later we reset transform to `none` to slide it in.
32
+ function getTranslateValue(direction, node, resolvedContainer, options = DEFAULT_TRANSLATE_OPTIONS) {
33
+ const {
34
+ resetInlineTransform = true
35
+ } = options;
24
36
  const containerRect = resolvedContainer && resolvedContainer.getBoundingClientRect();
25
37
  const containerWindow = ownerWindow(node);
26
-
27
- // Clear the inline transform and transition before reading layout and computed
28
- // style so we compute from the element's natural position, not its previous
29
- // off-screen translation. The transition must also be cleared, otherwise the
30
- // browser may report an animated intermediate value from a still-running
31
- // enter transition when reading getComputedStyle during exit.
32
- const previousTransform = node.style.transform;
33
- const previousTransition = node.style.transition;
34
- node.style.transition = '';
35
- node.style.transform = '';
36
- const rect = node.getBoundingClientRect();
37
- const computedStyle = containerWindow.getComputedStyle(node);
38
- const transform = computedStyle.getPropertyValue('transform');
39
- node.style.transform = previousTransform;
40
- node.style.transition = previousTransition;
41
- let offsetX = 0;
42
- let offsetY = 0;
43
- if (transform && transform !== 'none' && typeof transform === 'string') {
44
- const transformValues = transform.split('(')[1].split(')')[0].split(',');
45
- offsetX = parseInt(transformValues[4], 10);
46
- offsetY = parseInt(transformValues[5], 10);
38
+ let rect;
39
+ let transform;
40
+ if (resetInlineTransform) {
41
+ // Read layout from the element's natural position, not from a previous
42
+ // off-screen transform. Clear transition too, or the browser may report an
43
+ // in-between animated value during exit.
44
+ const previousTransform = node.style.transform;
45
+ const previousTransition = node.style.transition;
46
+ node.style.transition = '';
47
+ node.style.transform = '';
48
+ rect = node.getBoundingClientRect();
49
+ const computedStyle = containerWindow.getComputedStyle(node);
50
+ transform = computedStyle.getPropertyValue('transform');
51
+ node.style.transform = previousTransform;
52
+ node.style.transition = previousTransition;
53
+ } else {
54
+ rect = node.getBoundingClientRect();
55
+ const computedStyle = containerWindow.getComputedStyle(node);
56
+ transform = computedStyle.getPropertyValue('transform');
47
57
  }
58
+ const {
59
+ offsetX,
60
+ offsetY
61
+ } = getTranslateOffsets(transform);
48
62
  if (direction === 'left') {
49
63
  if (containerRect) {
50
64
  return `translateX(${containerRect.right + offsetX - rect.left}px)`;
@@ -73,9 +87,9 @@ function getTranslateValue(direction, node, resolvedContainer) {
73
87
  function resolveContainer(containerPropProp) {
74
88
  return typeof containerPropProp === 'function' ? containerPropProp() : containerPropProp;
75
89
  }
76
- export function setTranslateValue(direction, node, containerProp) {
90
+ export function setTranslateValue(direction, node, containerProp, options) {
77
91
  const resolvedContainer = resolveContainer(containerProp);
78
- const transform = getTranslateValue(direction, node, resolvedContainer);
92
+ const transform = getTranslateValue(direction, node, resolvedContainer, options);
79
93
  if (transform) {
80
94
  node.style.transform = transform;
81
95
  }
@@ -83,7 +97,6 @@ export function setTranslateValue(direction, node, containerProp) {
83
97
 
84
98
  /**
85
99
  * The Slide transition is used by the [Drawer](/material-ui/react-drawer/) component.
86
- * It uses [react-transition-group](https://github.com/reactjs/react-transition-group) internally.
87
100
  */
88
101
  const Slide = /*#__PURE__*/React.forwardRef(function Slide(props, ref) {
89
102
  const theme = useTheme();
@@ -100,6 +113,7 @@ const Slide = /*#__PURE__*/React.forwardRef(function Slide(props, ref) {
100
113
  appear = true,
101
114
  children,
102
115
  container: containerProp,
116
+ disablePrefersReducedMotion = false,
103
117
  direction = 'down',
104
118
  easing: easingProp = defaultEasing,
105
119
  in: inProp,
@@ -113,11 +127,15 @@ const Slide = /*#__PURE__*/React.forwardRef(function Slide(props, ref) {
113
127
  timeout = defaultTimeout,
114
128
  ...other
115
129
  } = props;
130
+ const reducedMotion = useReducedMotion(theme.motion.reducedMotion, disablePrefersReducedMotion);
116
131
  const childrenRef = React.useRef(null);
132
+ const preserveInlineTransformRef = React.useRef(false);
117
133
  const handleRef = useForkRef(getReactElementRef(children), childrenRef, ref);
118
134
  const handleEnter = normalizedTransitionCallback(childrenRef, (node, isAppearing) => {
119
135
  setTranslateValue(direction, node, containerProp);
120
- reflow(node);
136
+ if (!reducedMotion.shouldReduceMotion) {
137
+ reflow(node);
138
+ }
121
139
  if (onEnter) {
122
140
  onEnter(node, isAppearing);
123
141
  }
@@ -130,7 +148,15 @@ const Slide = /*#__PURE__*/React.forwardRef(function Slide(props, ref) {
130
148
  }, {
131
149
  mode: 'enter'
132
150
  });
133
- node.style.transition = theme.transitions.create('transform', transitionProps);
151
+ const transitionTiming = reducedMotion.getTransitionTiming({
152
+ duration: transitionProps.duration,
153
+ delay: transitionProps.delay
154
+ });
155
+ node.style.transition = theme.transitions.create('transform', {
156
+ duration: transitionTiming.duration,
157
+ easing: transitionProps.easing,
158
+ delay: transitionTiming.delay
159
+ });
134
160
  node.style.transform = 'none';
135
161
  if (onEntering) {
136
162
  onEntering(node, isAppearing);
@@ -146,32 +172,45 @@ const Slide = /*#__PURE__*/React.forwardRef(function Slide(props, ref) {
146
172
  }, {
147
173
  mode: 'exit'
148
174
  });
149
- node.style.transition = theme.transitions.create('transform', transitionProps);
150
- setTranslateValue(direction, node, containerProp);
175
+ const transitionTiming = reducedMotion.getTransitionTiming({
176
+ duration: transitionProps.duration,
177
+ delay: transitionProps.delay
178
+ });
179
+ node.style.transition = theme.transitions.create('transform', {
180
+ duration: transitionTiming.duration,
181
+ easing: transitionProps.easing,
182
+ delay: transitionTiming.delay
183
+ });
184
+ const preserveInlineTransform = isGestureTranslate(node.style.transform);
185
+ preserveInlineTransformRef.current = preserveInlineTransform;
186
+
187
+ // Preserve SwipeableDrawer's inline gesture transform during exit. Slide's
188
+ // own off-screen translateX/Y transforms still use the reset path.
189
+ setTranslateValue(direction, node, containerProp, {
190
+ resetInlineTransform: !preserveInlineTransform
191
+ });
151
192
  if (onExit) {
152
193
  onExit(node);
153
194
  }
154
195
  });
155
196
  const handleExited = normalizedTransitionCallback(childrenRef, node => {
156
- // No need for transitions when the component is hidden
197
+ preserveInlineTransformRef.current = false;
198
+ // Hidden nodes stay off-screen without animating.
157
199
  node.style.transition = '';
158
200
  if (onExited) {
159
201
  onExited(node);
160
202
  }
161
203
  });
162
- const handleAddEndListener = next => {
163
- if (addEndListener) {
164
- // Old call signature before `react-transition-group` implemented `nodeRef`
165
- addEndListener(childrenRef.current, next);
166
- }
167
- };
204
+ const handleAddEndListener = addEndListener ? next => {
205
+ addEndListener(childrenRef.current, next);
206
+ } : undefined;
168
207
  const updatePosition = React.useCallback(() => {
169
208
  if (childrenRef.current) {
170
209
  setTranslateValue(direction, childrenRef.current, containerProp);
171
210
  }
172
211
  }, [direction, containerProp]);
173
212
  React.useEffect(() => {
174
- // Skip configuration where the position is screen size invariant.
213
+ // Skip resize listeners when the off-screen position does not depend on screen size.
175
214
  if (inProp || direction === 'down' || direction === 'right') {
176
215
  return undefined;
177
216
  }
@@ -188,9 +227,9 @@ const Slide = /*#__PURE__*/React.forwardRef(function Slide(props, ref) {
188
227
  };
189
228
  }, [direction, inProp, containerProp]);
190
229
  React.useEffect(() => {
191
- if (!inProp) {
192
- // We need to update the position of the drawer when the direction change and
193
- // when it's hidden.
230
+ if (!inProp && !preserveInlineTransformRef.current) {
231
+ // While hidden, keep the child at the correct off-screen position if
232
+ // direction or container changes.
194
233
  updatePosition();
195
234
  }
196
235
  }, [inProp, updatePosition]);
@@ -205,12 +244,15 @@ const Slide = /*#__PURE__*/React.forwardRef(function Slide(props, ref) {
205
244
  addEndListener: handleAddEndListener,
206
245
  appear: appear,
207
246
  in: inProp,
247
+ reduceMotion: reducedMotion.shouldReduceMotion,
208
248
  timeout: timeout,
209
249
  ...other,
210
250
  children: (state, {
211
251
  ownerState,
212
252
  ...restChildProps
213
253
  }) => {
254
+ // Do not pass ownerState to a DOM child. ownerState is only for
255
+ // Material UI styling, and React would treat it as an invalid DOM attribute.
214
256
  let childStyle;
215
257
  if (state === 'exited' && !inProp) {
216
258
  childStyle = style || children.props.style ? {
@@ -240,9 +282,12 @@ process.env.NODE_ENV !== "production" ? Slide.propTypes /* remove-proptypes */ =
240
282
  // │ To update them, edit the d.ts file and run `pnpm proptypes`. │
241
283
  // └─────────────────────────────────────────────────────────────────────┘
242
284
  /**
243
- * Add a custom transition end trigger. Called with the transitioning DOM
244
- * node and a done callback. Allows for more fine grained transition end
245
- * logic. Note: Timeouts are still used as a fallback if provided.
285
+ * Add a custom transition end trigger.
286
+ * Use it when you need custom logic to decide when the transition has ended.
287
+ * Note: Timeouts are still used as a fallback if provided.
288
+ *
289
+ * @param {HTMLElement} node The transitioning DOM node.
290
+ * @param {Function} done Call this when the transition has finished.
246
291
  */
247
292
  addEndListener: PropTypes.func,
248
293
  /**
@@ -280,6 +325,11 @@ process.env.NODE_ENV !== "production" ? Slide.propTypes /* remove-proptypes */ =
280
325
  * @default 'down'
281
326
  */
282
327
  direction: PropTypes.oneOf(['down', 'left', 'right', 'up']),
328
+ /**
329
+ * If `true`, the transition ignores `theme.motion.reducedMotion` and keeps its normal timing.
330
+ * @default false
331
+ */
332
+ disablePrefersReducedMotion: PropTypes.bool,
283
333
  /**
284
334
  * The transition timing function.
285
335
  * You may specify a single easing or a object containing enter and exit values.