@mui/material 9.0.1 → 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 (206) 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 +8 -6
  8. package/Autocomplete/Autocomplete.mjs +8 -6
  9. package/Backdrop/Backdrop.d.mts +2 -2
  10. package/Backdrop/Backdrop.d.ts +2 -2
  11. package/Badge/Badge.js +28 -24
  12. package/Badge/Badge.mjs +28 -24
  13. package/BottomNavigationAction/BottomNavigationAction.js +6 -2
  14. package/BottomNavigationAction/BottomNavigationAction.mjs +6 -2
  15. package/Button/Button.js +11 -15
  16. package/Button/Button.mjs +11 -15
  17. package/ButtonBase/Ripple.js +21 -11
  18. package/ButtonBase/Ripple.mjs +21 -11
  19. package/ButtonBase/TouchRipple.js +252 -116
  20. package/ButtonBase/TouchRipple.mjs +253 -117
  21. package/CHANGELOG.md +84 -0
  22. package/CardActionArea/CardActionArea.js +2 -1
  23. package/CardActionArea/CardActionArea.mjs +2 -1
  24. package/Chip/Chip.js +2 -1
  25. package/Chip/Chip.mjs +2 -1
  26. package/CircularProgress/CircularProgress.js +85 -55
  27. package/CircularProgress/CircularProgress.mjs +84 -55
  28. package/Collapse/Collapse.d.mts +15 -3
  29. package/Collapse/Collapse.d.ts +15 -3
  30. package/Collapse/Collapse.js +44 -31
  31. package/Collapse/Collapse.mjs +43 -30
  32. package/Dialog/Dialog.d.mts +2 -2
  33. package/Dialog/Dialog.d.ts +2 -2
  34. package/Dialog/Dialog.js +2 -0
  35. package/Dialog/Dialog.mjs +2 -0
  36. package/Drawer/Drawer.d.mts +2 -2
  37. package/Drawer/Drawer.d.ts +2 -2
  38. package/Fab/Fab.js +2 -1
  39. package/Fab/Fab.mjs +2 -1
  40. package/Fade/Fade.d.mts +15 -2
  41. package/Fade/Fade.d.ts +15 -2
  42. package/Fade/Fade.js +46 -19
  43. package/Fade/Fade.mjs +45 -18
  44. package/FilledInput/FilledInput.js +4 -3
  45. package/FilledInput/FilledInput.mjs +4 -3
  46. package/Grow/Grow.d.mts +15 -2
  47. package/Grow/Grow.d.ts +15 -2
  48. package/Grow/Grow.js +45 -28
  49. package/Grow/Grow.mjs +44 -27
  50. package/IconButton/IconButton.js +2 -1
  51. package/IconButton/IconButton.mjs +2 -1
  52. package/Input/Input.js +3 -2
  53. package/Input/Input.mjs +3 -2
  54. package/InputBase/InputBase.js +2 -1
  55. package/InputBase/InputBase.mjs +2 -1
  56. package/InputLabel/InputLabel.js +2 -1
  57. package/InputLabel/InputLabel.mjs +2 -1
  58. package/LICENSE +1 -1
  59. package/LinearProgress/LinearProgress.js +187 -120
  60. package/LinearProgress/LinearProgress.mjs +186 -120
  61. package/ListItem/ListItem.js +2 -1
  62. package/ListItem/ListItem.mjs +2 -1
  63. package/ListItemButton/ListItemButton.js +2 -1
  64. package/ListItemButton/ListItemButton.mjs +2 -1
  65. package/Menu/Menu.d.mts +1 -1
  66. package/Menu/Menu.d.ts +1 -1
  67. package/MobileStepper/MobileStepper.js +2 -1
  68. package/MobileStepper/MobileStepper.mjs +2 -1
  69. package/OutlinedInput/NotchedOutline.js +4 -3
  70. package/OutlinedInput/NotchedOutline.mjs +4 -3
  71. package/PaginationItem/PaginationItem.js +2 -1
  72. package/PaginationItem/PaginationItem.mjs +2 -1
  73. package/Paper/Paper.js +2 -1
  74. package/Paper/Paper.mjs +2 -1
  75. package/Popover/Popover.d.mts +1 -1
  76. package/Popover/Popover.d.ts +1 -1
  77. package/README.md +3 -2
  78. package/Radio/RadioButtonIcon.js +3 -2
  79. package/Radio/RadioButtonIcon.mjs +3 -2
  80. package/Rating/Rating.js +2 -1
  81. package/Rating/Rating.mjs +2 -1
  82. package/Select/SelectInput.js +115 -25
  83. package/Select/SelectInput.mjs +115 -25
  84. package/Select/utils/closedTypeahead.js +73 -0
  85. package/Select/utils/closedTypeahead.mjs +63 -0
  86. package/Skeleton/Skeleton.js +22 -2
  87. package/Skeleton/Skeleton.mjs +22 -2
  88. package/Slide/Slide.d.mts +15 -2
  89. package/Slide/Slide.d.ts +15 -2
  90. package/Slide/Slide.js +53 -25
  91. package/Slide/Slide.mjs +52 -24
  92. package/Slider/Slider.js +4 -3
  93. package/Slider/Slider.mjs +4 -3
  94. package/Slider/useSlider.js +1 -1
  95. package/Slider/useSlider.mjs +1 -1
  96. package/Snackbar/Snackbar.d.mts +2 -2
  97. package/Snackbar/Snackbar.d.ts +2 -2
  98. package/SpeedDial/SpeedDial.d.mts +1 -1
  99. package/SpeedDial/SpeedDial.d.ts +1 -1
  100. package/SpeedDial/SpeedDial.js +6 -2
  101. package/SpeedDial/SpeedDial.mjs +6 -2
  102. package/SpeedDialAction/SpeedDialAction.js +11 -2
  103. package/SpeedDialAction/SpeedDialAction.mjs +12 -3
  104. package/SpeedDialIcon/SpeedDialIcon.js +40 -37
  105. package/SpeedDialIcon/SpeedDialIcon.mjs +40 -37
  106. package/Step/Step.js +47 -15
  107. package/Step/Step.mjs +47 -15
  108. package/StepButton/StepButton.js +9 -3
  109. package/StepButton/StepButton.mjs +9 -3
  110. package/StepConnector/StepConnector.js +10 -0
  111. package/StepConnector/StepConnector.mjs +10 -0
  112. package/StepContent/StepContent.d.mts +2 -2
  113. package/StepContent/StepContent.d.ts +2 -2
  114. package/StepContent/StepContent.js +26 -2
  115. package/StepContent/StepContent.mjs +26 -2
  116. package/StepIcon/StepIcon.js +2 -1
  117. package/StepIcon/StepIcon.mjs +2 -1
  118. package/StepLabel/StepLabel.js +52 -7
  119. package/StepLabel/StepLabel.mjs +52 -7
  120. package/Stepper/Stepper.d.mts +2 -0
  121. package/Stepper/Stepper.d.ts +2 -0
  122. package/Stepper/Stepper.js +18 -0
  123. package/Stepper/Stepper.mjs +18 -0
  124. package/SvgIcon/SvgIcon.js +2 -1
  125. package/SvgIcon/SvgIcon.mjs +2 -1
  126. package/SwipeableDrawer/SwipeableDrawer.js +14 -3
  127. package/SwipeableDrawer/SwipeableDrawer.mjs +14 -3
  128. package/Switch/Switch.js +3 -2
  129. package/Switch/Switch.mjs +3 -2
  130. package/TableSortLabel/TableSortLabel.js +2 -1
  131. package/TableSortLabel/TableSortLabel.mjs +2 -1
  132. package/Tabs/Tabs.js +14 -3
  133. package/Tabs/Tabs.mjs +14 -3
  134. package/Tooltip/Tooltip.d.mts +2 -2
  135. package/Tooltip/Tooltip.d.ts +2 -2
  136. package/Tooltip/Tooltip.js +3 -0
  137. package/Tooltip/Tooltip.mjs +3 -0
  138. package/Unstable_TrapFocus/FocusTrap.js +42 -8
  139. package/Unstable_TrapFocus/FocusTrap.mjs +42 -8
  140. package/Zoom/Zoom.d.mts +15 -2
  141. package/Zoom/Zoom.d.ts +15 -2
  142. package/Zoom/Zoom.js +43 -16
  143. package/Zoom/Zoom.mjs +42 -15
  144. package/index.js +1 -1
  145. package/index.mjs +1 -1
  146. package/internal/Transition.d.mts +34 -0
  147. package/internal/Transition.d.ts +34 -0
  148. package/internal/Transition.js +444 -0
  149. package/internal/Transition.mjs +436 -0
  150. package/internal/react-transition-group.d.mts +8 -0
  151. package/internal/react-transition-group.d.ts +8 -0
  152. package/package.json +6 -6
  153. package/styles/createMotion.d.mts +8 -0
  154. package/styles/createMotion.d.ts +8 -0
  155. package/styles/createMotion.js +13 -0
  156. package/styles/createMotion.mjs +7 -0
  157. package/styles/createThemeFoundation.d.mts +2 -0
  158. package/styles/createThemeFoundation.d.ts +2 -0
  159. package/styles/createThemeNoVars.d.mts +3 -0
  160. package/styles/createThemeNoVars.d.ts +3 -0
  161. package/styles/createThemeNoVars.js +5 -0
  162. package/styles/createThemeNoVars.mjs +5 -0
  163. package/styles/createTransitions.d.mts +6 -2
  164. package/styles/createTransitions.d.ts +6 -2
  165. package/styles/createTransitions.js +12 -4
  166. package/styles/createTransitions.mjs +12 -4
  167. package/styles/enhanceHighContrast.d.mts +70 -0
  168. package/styles/enhanceHighContrast.d.ts +70 -0
  169. package/styles/enhanceHighContrast.js +502 -0
  170. package/styles/enhanceHighContrast.mjs +495 -0
  171. package/styles/index.d.mts +2 -0
  172. package/styles/index.d.ts +2 -0
  173. package/styles/index.js +8 -0
  174. package/styles/index.mjs +1 -0
  175. package/styles/reducedMotion.d.mts +7 -0
  176. package/styles/reducedMotion.d.ts +7 -0
  177. package/styles/reducedMotion.js +21 -0
  178. package/styles/reducedMotion.mjs +14 -0
  179. package/styles/shouldSkipGeneratingVar.js +1 -1
  180. package/styles/shouldSkipGeneratingVar.mjs +1 -1
  181. package/styles/stringifyTheme.js +1 -0
  182. package/styles/stringifyTheme.mjs +1 -0
  183. package/transitions/index.d.mts +1 -1
  184. package/transitions/index.d.ts +1 -1
  185. package/transitions/index.js +0 -11
  186. package/transitions/index.mjs +1 -1
  187. package/transitions/transition.d.mts +1 -12
  188. package/transitions/transition.d.ts +1 -12
  189. package/transitions/types.d.mts +73 -0
  190. package/transitions/types.d.ts +73 -0
  191. package/transitions/useReducedMotion.d.mts +14 -0
  192. package/transitions/useReducedMotion.d.ts +14 -0
  193. package/transitions/useReducedMotion.js +117 -0
  194. package/transitions/useReducedMotion.mjs +110 -0
  195. package/transitions/utils.d.mts +34 -2
  196. package/transitions/utils.d.ts +34 -2
  197. package/transitions/utils.js +33 -4
  198. package/transitions/utils.mjs +31 -4
  199. package/useAutocomplete/useAutocomplete.d.mts +8 -1
  200. package/useAutocomplete/useAutocomplete.d.ts +8 -1
  201. package/useAutocomplete/useAutocomplete.js +66 -4
  202. package/useAutocomplete/useAutocomplete.mjs +66 -4
  203. package/version/index.js +3 -3
  204. package/version/index.mjs +3 -3
  205. /package/transitions/{transition.js → types.js} +0 -0
  206. /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
+ }
@@ -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) {
@@ -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/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,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
- // Translate the node so it can't be seen on the screen.
38
- // Later, we're going to translate the node back to its original location with `none`.
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
- // Clear the inline transform and transition before reading layout and computed
49
- // style so we compute from the element's natural position, not its previous
50
- // off-screen translation.
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
- (0, _utils.reflow)(node);
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
- 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
+ });
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
- node.style.transition = theme.transitions.create('transform', transitionProps);
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
- // No need for transitions when the component is hidden
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
- if (addEndListener) {
194
- // Old call signature before `react-transition-group` implemented `nodeRef`
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 configuration where the position is screen size invariant.
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
- // We need to update the position of the drawer when the direction change and
223
- // when it's hidden.
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)(_reactTransitionGroup.Transition, {
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. Called with the transitioning DOM
274
- * node and a done callback. Allows for more fine grained transition end
275
- * 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.
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.