@mui/material 5.16.1 → 5.16.2

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 (252) hide show
  1. package/Autocomplete/Autocomplete.d.ts +6 -7
  2. package/Autocomplete/Autocomplete.js +1 -1
  3. package/Badge/Badge.d.ts +1 -1
  4. package/Badge/Badge.js +2 -2
  5. package/Badge/useBadge.d.ts +13 -0
  6. package/Badge/useBadge.js +41 -0
  7. package/Badge/useBadge.types.d.ts +40 -0
  8. package/Badge/useBadge.types.js +1 -0
  9. package/Breadcrumbs/Breadcrumbs.d.ts +1 -1
  10. package/Breadcrumbs/Breadcrumbs.js +1 -1
  11. package/CHANGELOG.md +18 -0
  12. package/ClickAwayListener/ClickAwayListener.d.ts +47 -0
  13. package/ClickAwayListener/ClickAwayListener.js +178 -0
  14. package/ClickAwayListener/index.d.ts +2 -2
  15. package/ClickAwayListener/index.js +1 -1
  16. package/InputBase/InputBase.js +2 -2
  17. package/ListItem/ListItem.js +1 -1
  18. package/Menu/Menu.js +1 -1
  19. package/Modal/Modal.d.ts +1 -1
  20. package/Modal/Modal.js +2 -2
  21. package/Modal/ModalManager.d.ts +25 -0
  22. package/Modal/ModalManager.js +213 -0
  23. package/Modal/index.d.ts +1 -1
  24. package/Modal/index.js +1 -1
  25. package/Modal/useModal.d.ts +13 -0
  26. package/Modal/useModal.js +195 -0
  27. package/Modal/useModal.types.d.ts +115 -0
  28. package/Modal/useModal.types.js +1 -0
  29. package/NoSsr/NoSsr.d.ts +25 -0
  30. package/NoSsr/NoSsr.js +73 -0
  31. package/NoSsr/NoSsr.types.d.ts +18 -0
  32. package/NoSsr/NoSsr.types.js +1 -0
  33. package/NoSsr/index.d.ts +3 -2
  34. package/NoSsr/index.js +1 -1
  35. package/Popover/Popover.js +2 -1
  36. package/Popper/BasePopper.d.ts +7 -0
  37. package/Popper/BasePopper.js +372 -0
  38. package/Popper/BasePopper.types.d.ts +130 -0
  39. package/Popper/BasePopper.types.js +1 -0
  40. package/Popper/Popper.d.ts +1 -1
  41. package/Popper/Popper.js +1 -1
  42. package/Popper/index.d.ts +2 -1
  43. package/Popper/index.js +2 -1
  44. package/Popper/popperClasses.d.ts +8 -0
  45. package/Popper/popperClasses.js +7 -0
  46. package/Portal/Portal.d.ts +16 -0
  47. package/Portal/Portal.js +92 -0
  48. package/Portal/Portal.types.d.ts +23 -0
  49. package/Portal/Portal.types.js +1 -0
  50. package/Portal/index.d.ts +3 -2
  51. package/Portal/index.js +1 -1
  52. package/Slider/Slider.d.ts +2 -2
  53. package/Slider/Slider.js +3 -2
  54. package/Slider/useSlider.d.ts +14 -0
  55. package/Slider/useSlider.js +655 -0
  56. package/Slider/useSlider.types.d.ts +228 -0
  57. package/Slider/useSlider.types.js +1 -0
  58. package/Snackbar/Snackbar.d.ts +1 -1
  59. package/Snackbar/Snackbar.js +4 -5
  60. package/Snackbar/useSnackbar.d.ts +14 -0
  61. package/Snackbar/useSnackbar.js +131 -0
  62. package/Snackbar/useSnackbar.types.d.ts +60 -0
  63. package/Snackbar/useSnackbar.types.js +1 -0
  64. package/SwipeableDrawer/SwipeableDrawer.js +1 -1
  65. package/TabScrollButton/TabScrollButton.d.ts +1 -1
  66. package/TabScrollButton/TabScrollButton.js +1 -1
  67. package/TablePagination/TablePagination.js +1 -1
  68. package/Tabs/Tabs.d.ts +1 -1
  69. package/Tabs/Tabs.js +1 -1
  70. package/TextareaAutosize/TextareaAutosize.d.ts +14 -0
  71. package/TextareaAutosize/TextareaAutosize.js +223 -0
  72. package/TextareaAutosize/TextareaAutosize.types.d.ts +13 -0
  73. package/TextareaAutosize/TextareaAutosize.types.js +1 -0
  74. package/TextareaAutosize/index.d.ts +3 -2
  75. package/TextareaAutosize/index.js +1 -1
  76. package/Tooltip/Tooltip.js +2 -3
  77. package/Unstable_TrapFocus/FocusTrap.d.ts +10 -0
  78. package/Unstable_TrapFocus/FocusTrap.js +332 -0
  79. package/Unstable_TrapFocus/FocusTrap.types.d.ts +51 -0
  80. package/Unstable_TrapFocus/FocusTrap.types.js +1 -0
  81. package/Unstable_TrapFocus/index.d.ts +2 -2
  82. package/Unstable_TrapFocus/index.js +1 -1
  83. package/index.d.ts +1 -1
  84. package/index.js +2 -2
  85. package/legacy/Autocomplete/Autocomplete.js +1 -1
  86. package/legacy/Badge/Badge.js +2 -2
  87. package/legacy/Badge/useBadge.js +42 -0
  88. package/legacy/Badge/useBadge.types.js +1 -0
  89. package/legacy/Breadcrumbs/Breadcrumbs.js +1 -1
  90. package/legacy/ClickAwayListener/ClickAwayListener.js +181 -0
  91. package/legacy/ClickAwayListener/index.js +1 -1
  92. package/legacy/InputBase/InputBase.js +2 -2
  93. package/legacy/ListItem/ListItem.js +1 -1
  94. package/legacy/Menu/Menu.js +1 -1
  95. package/legacy/Modal/Modal.js +2 -2
  96. package/legacy/Modal/ModalManager.js +233 -0
  97. package/legacy/Modal/index.js +1 -1
  98. package/legacy/Modal/useModal.js +206 -0
  99. package/legacy/Modal/useModal.types.js +1 -0
  100. package/legacy/NoSsr/NoSsr.js +75 -0
  101. package/legacy/NoSsr/NoSsr.types.js +1 -0
  102. package/legacy/NoSsr/index.js +1 -1
  103. package/legacy/Popover/Popover.js +2 -1
  104. package/legacy/Popper/BasePopper.js +380 -0
  105. package/legacy/Popper/BasePopper.types.js +1 -0
  106. package/legacy/Popper/Popper.js +1 -1
  107. package/legacy/Popper/index.js +2 -1
  108. package/legacy/Popper/popperClasses.js +7 -0
  109. package/legacy/Portal/Portal.js +92 -0
  110. package/legacy/Portal/Portal.types.js +1 -0
  111. package/legacy/Portal/index.js +1 -1
  112. package/legacy/Slider/Slider.js +3 -2
  113. package/legacy/Slider/useSlider.js +701 -0
  114. package/legacy/Slider/useSlider.types.js +1 -0
  115. package/legacy/Snackbar/Snackbar.js +4 -5
  116. package/legacy/Snackbar/useSnackbar.js +141 -0
  117. package/legacy/Snackbar/useSnackbar.types.js +1 -0
  118. package/legacy/SwipeableDrawer/SwipeableDrawer.js +1 -1
  119. package/legacy/TabScrollButton/TabScrollButton.js +1 -1
  120. package/legacy/TablePagination/TablePagination.js +1 -1
  121. package/legacy/Tabs/Tabs.js +1 -1
  122. package/legacy/TextareaAutosize/TextareaAutosize.js +220 -0
  123. package/legacy/TextareaAutosize/TextareaAutosize.types.js +1 -0
  124. package/legacy/TextareaAutosize/index.js +1 -1
  125. package/legacy/Tooltip/Tooltip.js +2 -3
  126. package/legacy/Unstable_TrapFocus/FocusTrap.js +341 -0
  127. package/legacy/Unstable_TrapFocus/FocusTrap.types.js +1 -0
  128. package/legacy/Unstable_TrapFocus/index.js +1 -1
  129. package/legacy/index.js +2 -2
  130. package/legacy/useAutocomplete/useAutocomplete.js +1078 -2
  131. package/legacy/utils/PolymorphicComponent.js +1 -0
  132. package/legacy/utils/areArraysEqual.js +9 -0
  133. package/legacy/utils/index.js +1 -1
  134. package/legacy/utils/shouldSpreadAdditionalProps.js +1 -1
  135. package/legacy/utils/useSlot.js +3 -1
  136. package/modern/Autocomplete/Autocomplete.js +1 -1
  137. package/modern/Badge/Badge.js +2 -2
  138. package/modern/Badge/useBadge.js +41 -0
  139. package/modern/Badge/useBadge.types.js +1 -0
  140. package/modern/Breadcrumbs/Breadcrumbs.js +1 -1
  141. package/modern/ClickAwayListener/ClickAwayListener.js +178 -0
  142. package/modern/ClickAwayListener/index.js +1 -1
  143. package/modern/InputBase/InputBase.js +2 -2
  144. package/modern/ListItem/ListItem.js +1 -1
  145. package/modern/Menu/Menu.js +1 -1
  146. package/modern/Modal/Modal.js +2 -2
  147. package/modern/Modal/ModalManager.js +213 -0
  148. package/modern/Modal/index.js +1 -1
  149. package/modern/Modal/useModal.js +193 -0
  150. package/modern/Modal/useModal.types.js +1 -0
  151. package/modern/NoSsr/NoSsr.js +73 -0
  152. package/modern/NoSsr/NoSsr.types.js +1 -0
  153. package/modern/NoSsr/index.js +1 -1
  154. package/modern/Popover/Popover.js +2 -1
  155. package/modern/Popper/BasePopper.js +371 -0
  156. package/modern/Popper/BasePopper.types.js +1 -0
  157. package/modern/Popper/Popper.js +1 -1
  158. package/modern/Popper/index.js +2 -1
  159. package/modern/Popper/popperClasses.js +7 -0
  160. package/modern/Portal/Portal.js +92 -0
  161. package/modern/Portal/Portal.types.js +1 -0
  162. package/modern/Portal/index.js +1 -1
  163. package/modern/Slider/Slider.js +3 -2
  164. package/modern/Slider/useSlider.js +643 -0
  165. package/modern/Slider/useSlider.types.js +1 -0
  166. package/modern/Snackbar/Snackbar.js +4 -5
  167. package/modern/Snackbar/useSnackbar.js +131 -0
  168. package/modern/Snackbar/useSnackbar.types.js +1 -0
  169. package/modern/SwipeableDrawer/SwipeableDrawer.js +1 -1
  170. package/modern/TabScrollButton/TabScrollButton.js +1 -1
  171. package/modern/TablePagination/TablePagination.js +1 -1
  172. package/modern/Tabs/Tabs.js +1 -1
  173. package/modern/TextareaAutosize/TextareaAutosize.js +223 -0
  174. package/modern/TextareaAutosize/TextareaAutosize.types.js +1 -0
  175. package/modern/TextareaAutosize/index.js +1 -1
  176. package/modern/Tooltip/Tooltip.js +2 -3
  177. package/modern/Unstable_TrapFocus/FocusTrap.js +331 -0
  178. package/modern/Unstable_TrapFocus/FocusTrap.types.js +1 -0
  179. package/modern/Unstable_TrapFocus/index.js +1 -1
  180. package/modern/index.js +2 -2
  181. package/modern/useAutocomplete/useAutocomplete.js +987 -2
  182. package/modern/utils/PolymorphicComponent.js +1 -0
  183. package/modern/utils/areArraysEqual.js +4 -0
  184. package/modern/utils/index.js +1 -1
  185. package/modern/utils/shouldSpreadAdditionalProps.js +1 -1
  186. package/modern/utils/useSlot.js +3 -1
  187. package/node/Autocomplete/Autocomplete.js +3 -3
  188. package/node/Badge/Badge.js +5 -5
  189. package/node/Badge/useBadge.js +46 -0
  190. package/node/Badge/useBadge.types.js +5 -0
  191. package/node/Breadcrumbs/Breadcrumbs.js +2 -2
  192. package/node/ClickAwayListener/ClickAwayListener.js +184 -0
  193. package/node/ClickAwayListener/index.js +1 -1
  194. package/node/InputBase/InputBase.js +7 -7
  195. package/node/ListItem/ListItem.js +3 -3
  196. package/node/Menu/Menu.js +3 -3
  197. package/node/Modal/Modal.js +5 -5
  198. package/node/Modal/ModalManager.js +221 -0
  199. package/node/Modal/index.js +2 -2
  200. package/node/Modal/useModal.js +203 -0
  201. package/node/Modal/useModal.types.js +5 -0
  202. package/node/NoSsr/NoSsr.js +81 -0
  203. package/node/NoSsr/NoSsr.types.js +5 -0
  204. package/node/NoSsr/index.js +3 -2
  205. package/node/Popover/Popover.js +5 -4
  206. package/node/Popper/BasePopper.js +380 -0
  207. package/node/Popper/BasePopper.types.js +5 -0
  208. package/node/Popper/Popper.js +2 -2
  209. package/node/Popper/index.js +14 -1
  210. package/node/Popper/popperClasses.js +15 -0
  211. package/node/Portal/Portal.js +100 -0
  212. package/node/Portal/Portal.types.js +5 -0
  213. package/node/Portal/index.js +3 -2
  214. package/node/Slider/Slider.js +14 -13
  215. package/node/Slider/useSlider.js +666 -0
  216. package/node/Slider/useSlider.types.js +5 -0
  217. package/node/Snackbar/Snackbar.js +9 -10
  218. package/node/Snackbar/useSnackbar.js +139 -0
  219. package/node/Snackbar/useSnackbar.types.js +5 -0
  220. package/node/SwipeableDrawer/SwipeableDrawer.js +2 -2
  221. package/node/TabScrollButton/TabScrollButton.js +3 -3
  222. package/node/TablePagination/TablePagination.js +2 -2
  223. package/node/Tabs/Tabs.js +3 -3
  224. package/node/TextareaAutosize/TextareaAutosize.js +230 -0
  225. package/node/TextareaAutosize/TextareaAutosize.types.js +5 -0
  226. package/node/TextareaAutosize/index.js +3 -2
  227. package/node/Tooltip/Tooltip.js +10 -11
  228. package/node/Unstable_TrapFocus/FocusTrap.js +339 -0
  229. package/node/Unstable_TrapFocus/FocusTrap.types.js +5 -0
  230. package/node/Unstable_TrapFocus/index.js +3 -2
  231. package/node/index.js +3 -3
  232. package/node/useAutocomplete/useAutocomplete.js +997 -18
  233. package/node/utils/PolymorphicComponent.js +5 -0
  234. package/node/utils/areArraysEqual.js +10 -0
  235. package/node/utils/index.js +2 -2
  236. package/node/utils/shouldSpreadAdditionalProps.js +3 -2
  237. package/node/utils/useSlot.js +6 -4
  238. package/package.json +4 -5
  239. package/styles/overrides.d.ts +1 -1
  240. package/umd/material-ui.development.js +9190 -9248
  241. package/umd/material-ui.production.min.js +3 -3
  242. package/useAutocomplete/useAutocomplete.d.ts +460 -2
  243. package/useAutocomplete/useAutocomplete.js +994 -2
  244. package/utils/PolymorphicComponent.d.ts +17 -0
  245. package/utils/PolymorphicComponent.js +1 -0
  246. package/utils/areArraysEqual.d.ts +3 -0
  247. package/utils/areArraysEqual.js +4 -0
  248. package/utils/index.d.ts +2 -1
  249. package/utils/index.js +1 -1
  250. package/utils/shouldSpreadAdditionalProps.js +1 -1
  251. package/utils/types.d.ts +2 -1
  252. package/utils/useSlot.js +3 -1
package/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/material v5.16.1
2
+ * @mui/material v5.16.2
3
3
  *
4
4
  * @license MIT
5
5
  * This source code is licensed under the MIT license found in the
@@ -281,7 +281,7 @@ export * from './Zoom';
281
281
  export { default as useAutocomplete } from './useAutocomplete';
282
282
  export { default as GlobalStyles } from './GlobalStyles';
283
283
  export * from './GlobalStyles';
284
- export { unstable_composeClasses } from '@mui/base/composeClasses';
284
+ export { unstable_composeClasses } from '@mui/utils';
285
285
  export { default as generateUtilityClass } from './generateUtilityClass';
286
286
  export * from './generateUtilityClass';
287
287
  export { default as generateUtilityClasses } from './generateUtilityClasses';
@@ -9,9 +9,9 @@ import PropTypes from 'prop-types';
9
9
  import clsx from 'clsx';
10
10
  import integerPropType from '@mui/utils/integerPropType';
11
11
  import chainPropTypes from '@mui/utils/chainPropTypes';
12
- import { useAutocomplete, createFilterOptions } from '@mui/base';
13
12
  import composeClasses from '@mui/utils/composeClasses';
14
13
  import { alpha } from '@mui/system/colorManipulator';
14
+ import useAutocomplete, { createFilterOptions } from '../useAutocomplete';
15
15
  import Popper from '../Popper';
16
16
  import ListSubheader from '../ListSubheader';
17
17
  import Paper from '../Paper';
@@ -9,8 +9,8 @@ import PropTypes from 'prop-types';
9
9
  import clsx from 'clsx';
10
10
  import usePreviousProps from '@mui/utils/usePreviousProps';
11
11
  import composeClasses from '@mui/utils/composeClasses';
12
- import { useBadge } from '@mui/base/useBadge';
13
- import { useSlotProps } from '@mui/base/utils';
12
+ import useSlotProps from '@mui/utils/useSlotProps';
13
+ import useBadge from './useBadge';
14
14
  import { styled } from '../zero-styled';
15
15
  import { useDefaultProps } from '../DefaultPropsProvider';
16
16
  import capitalize from '../utils/capitalize';
@@ -0,0 +1,42 @@
1
+ 'use client';
2
+
3
+ import { usePreviousProps } from '@mui/utils';
4
+ /**
5
+ *
6
+ * Demos:
7
+ *
8
+ * - [Badge](https://next.mui.com/base-ui/react-badge/#hook)
9
+ *
10
+ * API:
11
+ *
12
+ * - [useBadge API](https://next.mui.com/base-ui/react-badge/hooks-api/#use-badge)
13
+ */
14
+ function useBadge(parameters) {
15
+ var badgeContentProp = parameters.badgeContent,
16
+ _parameters$invisible = parameters.invisible,
17
+ invisibleProp = _parameters$invisible === void 0 ? false : _parameters$invisible,
18
+ _parameters$max = parameters.max,
19
+ maxProp = _parameters$max === void 0 ? 99 : _parameters$max,
20
+ _parameters$showZero = parameters.showZero,
21
+ showZero = _parameters$showZero === void 0 ? false : _parameters$showZero;
22
+ var prevProps = usePreviousProps({
23
+ badgeContent: badgeContentProp,
24
+ max: maxProp
25
+ });
26
+ var invisible = invisibleProp;
27
+ if (invisibleProp === false && badgeContentProp === 0 && !showZero) {
28
+ invisible = true;
29
+ }
30
+ var _ref = invisible ? prevProps : parameters,
31
+ badgeContent = _ref.badgeContent,
32
+ _ref$max = _ref.max,
33
+ max = _ref$max === void 0 ? maxProp : _ref$max;
34
+ var displayValue = badgeContent && Number(badgeContent) > max ? "".concat(max, "+") : badgeContent;
35
+ return {
36
+ badgeContent: badgeContent,
37
+ invisible: invisible,
38
+ max: max,
39
+ displayValue: displayValue
40
+ };
41
+ }
42
+ export default useBadge;
@@ -0,0 +1 @@
1
+ export {};
@@ -9,8 +9,8 @@ import { isFragment } from 'react-is';
9
9
  import PropTypes from 'prop-types';
10
10
  import clsx from 'clsx';
11
11
  import integerPropType from '@mui/utils/integerPropType';
12
- import { useSlotProps } from '@mui/base/utils';
13
12
  import composeClasses from '@mui/utils/composeClasses';
13
+ import useSlotProps from '@mui/utils/useSlotProps';
14
14
  import styled from '../styles/styled';
15
15
  import { useDefaultProps } from '../DefaultPropsProvider';
16
16
  import Typography from '../Typography';
@@ -0,0 +1,181 @@
1
+ 'use client';
2
+
3
+ import * as React from 'react';
4
+ import PropTypes from 'prop-types';
5
+ import { elementAcceptingRef, exactProp, unstable_ownerDocument as ownerDocument, unstable_useForkRef as useForkRef, unstable_useEventCallback as useEventCallback } from '@mui/utils';
6
+
7
+ // TODO: return `EventHandlerName extends `on${infer EventName}` ? Lowercase<EventName> : never` once generatePropTypes runs with TS 4.1
8
+ import { jsx as _jsx } from "react/jsx-runtime";
9
+ function mapEventPropToEvent(eventProp) {
10
+ return eventProp.substring(2).toLowerCase();
11
+ }
12
+ function clickedRootScrollbar(event, doc) {
13
+ return doc.documentElement.clientWidth < event.clientX || doc.documentElement.clientHeight < event.clientY;
14
+ }
15
+ /**
16
+ * Listen for click events that occur somewhere in the document, outside of the element itself.
17
+ * For instance, if you need to hide a menu when people click anywhere else on your page.
18
+ *
19
+ * Demos:
20
+ *
21
+ * - [Click-Away Listener](https://mui.com/material-ui/react-click-away-listener/)
22
+ * - [Menu](https://mui.com/material-ui/react-menu/)
23
+ *
24
+ * API:
25
+ *
26
+ * - [ClickAwayListener API](https://mui.com/material-ui/api/click-away-listener/)
27
+ */
28
+ function ClickAwayListener(props) {
29
+ var children = props.children,
30
+ _props$disableReactTr = props.disableReactTree,
31
+ disableReactTree = _props$disableReactTr === void 0 ? false : _props$disableReactTr,
32
+ _props$mouseEvent = props.mouseEvent,
33
+ mouseEvent = _props$mouseEvent === void 0 ? 'onClick' : _props$mouseEvent,
34
+ onClickAway = props.onClickAway,
35
+ _props$touchEvent = props.touchEvent,
36
+ touchEvent = _props$touchEvent === void 0 ? 'onTouchEnd' : _props$touchEvent;
37
+ var movedRef = React.useRef(false);
38
+ var nodeRef = React.useRef(null);
39
+ var activatedRef = React.useRef(false);
40
+ var syntheticEventRef = React.useRef(false);
41
+ React.useEffect(function () {
42
+ // Ensure that this component is not "activated" synchronously.
43
+ // https://github.com/facebook/react/issues/20074
44
+ setTimeout(function () {
45
+ activatedRef.current = true;
46
+ }, 0);
47
+ return function () {
48
+ activatedRef.current = false;
49
+ };
50
+ }, []);
51
+ var handleRef = useForkRef(
52
+ // @ts-expect-error TODO upstream fix
53
+ children.ref, nodeRef);
54
+
55
+ // The handler doesn't take event.defaultPrevented into account:
56
+ //
57
+ // event.preventDefault() is meant to stop default behaviors like
58
+ // clicking a checkbox to check it, hitting a button to submit a form,
59
+ // and hitting left arrow to move the cursor in a text input etc.
60
+ // Only special HTML elements have these default behaviors.
61
+ var handleClickAway = useEventCallback(function (event) {
62
+ // Given developers can stop the propagation of the synthetic event,
63
+ // we can only be confident with a positive value.
64
+ var insideReactTree = syntheticEventRef.current;
65
+ syntheticEventRef.current = false;
66
+ var doc = ownerDocument(nodeRef.current);
67
+
68
+ // 1. IE11 support, which trigger the handleClickAway even after the unbind
69
+ // 2. The child might render null.
70
+ // 3. Behave like a blur listener.
71
+ if (!activatedRef.current || !nodeRef.current || 'clientX' in event && clickedRootScrollbar(event, doc)) {
72
+ return;
73
+ }
74
+
75
+ // Do not act if user performed touchmove
76
+ if (movedRef.current) {
77
+ movedRef.current = false;
78
+ return;
79
+ }
80
+ var insideDOM;
81
+
82
+ // If not enough, can use https://github.com/DieterHolvoet/event-propagation-path/blob/master/propagationPath.js
83
+ if (event.composedPath) {
84
+ insideDOM = event.composedPath().indexOf(nodeRef.current) > -1;
85
+ } else {
86
+ insideDOM = !doc.documentElement.contains(
87
+ // @ts-expect-error returns `false` as intended when not dispatched from a Node
88
+ event.target) || nodeRef.current.contains(
89
+ // @ts-expect-error returns `false` as intended when not dispatched from a Node
90
+ event.target);
91
+ }
92
+ if (!insideDOM && (disableReactTree || !insideReactTree)) {
93
+ onClickAway(event);
94
+ }
95
+ });
96
+
97
+ // Keep track of mouse/touch events that bubbled up through the portal.
98
+ var createHandleSynthetic = function createHandleSynthetic(handlerName) {
99
+ return function (event) {
100
+ syntheticEventRef.current = true;
101
+ var childrenPropsHandler = children.props[handlerName];
102
+ if (childrenPropsHandler) {
103
+ childrenPropsHandler(event);
104
+ }
105
+ };
106
+ };
107
+ var childrenProps = {
108
+ ref: handleRef
109
+ };
110
+ if (touchEvent !== false) {
111
+ childrenProps[touchEvent] = createHandleSynthetic(touchEvent);
112
+ }
113
+ React.useEffect(function () {
114
+ if (touchEvent !== false) {
115
+ var mappedTouchEvent = mapEventPropToEvent(touchEvent);
116
+ var doc = ownerDocument(nodeRef.current);
117
+ var handleTouchMove = function handleTouchMove() {
118
+ movedRef.current = true;
119
+ };
120
+ doc.addEventListener(mappedTouchEvent, handleClickAway);
121
+ doc.addEventListener('touchmove', handleTouchMove);
122
+ return function () {
123
+ doc.removeEventListener(mappedTouchEvent, handleClickAway);
124
+ doc.removeEventListener('touchmove', handleTouchMove);
125
+ };
126
+ }
127
+ return undefined;
128
+ }, [handleClickAway, touchEvent]);
129
+ if (mouseEvent !== false) {
130
+ childrenProps[mouseEvent] = createHandleSynthetic(mouseEvent);
131
+ }
132
+ React.useEffect(function () {
133
+ if (mouseEvent !== false) {
134
+ var mappedMouseEvent = mapEventPropToEvent(mouseEvent);
135
+ var doc = ownerDocument(nodeRef.current);
136
+ doc.addEventListener(mappedMouseEvent, handleClickAway);
137
+ return function () {
138
+ doc.removeEventListener(mappedMouseEvent, handleClickAway);
139
+ };
140
+ }
141
+ return undefined;
142
+ }, [handleClickAway, mouseEvent]);
143
+ return /*#__PURE__*/_jsx(React.Fragment, {
144
+ children: /*#__PURE__*/React.cloneElement(children, childrenProps)
145
+ });
146
+ }
147
+ process.env.NODE_ENV !== "production" ? ClickAwayListener.propTypes /* remove-proptypes */ = {
148
+ // ┌────────────────────────────── Warning ──────────────────────────────┐
149
+ // │ These PropTypes are generated from the TypeScript type definitions. │
150
+ // │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
151
+ // └─────────────────────────────────────────────────────────────────────┘
152
+ /**
153
+ * The wrapped element.
154
+ */
155
+ children: elementAcceptingRef.isRequired,
156
+ /**
157
+ * If `true`, the React tree is ignored and only the DOM tree is considered.
158
+ * This prop changes how portaled elements are handled.
159
+ * @default false
160
+ */
161
+ disableReactTree: PropTypes.bool,
162
+ /**
163
+ * The mouse event to listen to. You can disable the listener by providing `false`.
164
+ * @default 'onClick'
165
+ */
166
+ mouseEvent: PropTypes.oneOf(['onClick', 'onMouseDown', 'onMouseUp', 'onPointerDown', 'onPointerUp', false]),
167
+ /**
168
+ * Callback fired when a "click away" event is detected.
169
+ */
170
+ onClickAway: PropTypes.func.isRequired,
171
+ /**
172
+ * The touch event to listen to. You can disable the listener by providing `false`.
173
+ * @default 'onTouchEnd'
174
+ */
175
+ touchEvent: PropTypes.oneOf(['onTouchEnd', 'onTouchStart', false])
176
+ } : void 0;
177
+ if (process.env.NODE_ENV !== 'production') {
178
+ // eslint-disable-next-line
179
+ ClickAwayListener['propTypes' + ''] = exactProp(ClickAwayListener.propTypes);
180
+ }
181
+ export { ClickAwayListener };
@@ -1 +1 @@
1
- export { ClickAwayListener as default } from '@mui/base/ClickAwayListener';
1
+ export { ClickAwayListener as default } from './ClickAwayListener';
@@ -9,9 +9,9 @@ import PropTypes from 'prop-types';
9
9
  import clsx from 'clsx';
10
10
  import elementTypeAcceptingRef from '@mui/utils/elementTypeAcceptingRef';
11
11
  import refType from '@mui/utils/refType';
12
- import { TextareaAutosize } from '@mui/base';
13
- import { isHostComponent } from '@mui/base/utils';
14
12
  import composeClasses from '@mui/utils/composeClasses';
13
+ import isHostComponent from '@mui/utils/isHostComponent';
14
+ import TextareaAutosize from '../TextareaAutosize';
15
15
  import formControlState from '../FormControl/formControlState';
16
16
  import FormControlContext from '../FormControl/FormControlContext';
17
17
  import useFormControl from '../FormControl/useFormControl';
@@ -6,11 +6,11 @@ import _extends from "@babel/runtime/helpers/esm/extends";
6
6
  import * as React from 'react';
7
7
  import PropTypes from 'prop-types';
8
8
  import clsx from 'clsx';
9
- import { isHostComponent } from '@mui/base/utils';
10
9
  import composeClasses from '@mui/utils/composeClasses';
11
10
  import elementTypeAcceptingRef from '@mui/utils/elementTypeAcceptingRef';
12
11
  import chainPropTypes from '@mui/utils/chainPropTypes';
13
12
  import { alpha } from '@mui/system/colorManipulator';
13
+ import isHostComponent from '@mui/utils/isHostComponent';
14
14
  import styled from '../styles/styled';
15
15
  import { useDefaultProps } from '../DefaultPropsProvider';
16
16
  import ButtonBase from '../ButtonBase';
@@ -7,9 +7,9 @@ import { isFragment } from 'react-is';
7
7
  import PropTypes from 'prop-types';
8
8
  import clsx from 'clsx';
9
9
  import composeClasses from '@mui/utils/composeClasses';
10
- import { useSlotProps } from '@mui/base/utils';
11
10
  import HTMLElementType from '@mui/utils/HTMLElementType';
12
11
  import { useRtl } from '@mui/system/RtlProvider';
12
+ import useSlotProps from '@mui/utils/useSlotProps';
13
13
  import MenuList from '../MenuList';
14
14
  import Popover, { PopoverPaper } from '../Popover';
15
15
  import styled, { rootShouldForwardProp } from '../styles/styled';
@@ -7,14 +7,14 @@ import PropTypes from 'prop-types';
7
7
  import clsx from 'clsx';
8
8
  import HTMLElementType from '@mui/utils/HTMLElementType';
9
9
  import elementAcceptingRef from '@mui/utils/elementAcceptingRef';
10
- import { useSlotProps } from '@mui/base/utils';
11
- import { unstable_useModal as useModal } from '@mui/base/unstable_useModal';
12
10
  import composeClasses from '@mui/utils/composeClasses';
11
+ import useSlotProps from '@mui/utils/useSlotProps';
13
12
  import FocusTrap from '../Unstable_TrapFocus';
14
13
  import Portal from '../Portal';
15
14
  import styled from '../styles/styled';
16
15
  import { useDefaultProps } from '../DefaultPropsProvider';
17
16
  import Backdrop from '../Backdrop';
17
+ import useModal from './useModal';
18
18
  import { getModalUtilityClass } from './modalClasses';
19
19
  import { jsx as _jsx } from "react/jsx-runtime";
20
20
  import { jsxs as _jsxs } from "react/jsx-runtime";
@@ -0,0 +1,233 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
+ import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
4
+ import { unstable_ownerWindow as ownerWindow, unstable_ownerDocument as ownerDocument, unstable_getScrollbarSize as getScrollbarSize } from '@mui/utils';
5
+ // Is a vertical scrollbar displayed?
6
+ function isOverflowing(container) {
7
+ var doc = ownerDocument(container);
8
+ if (doc.body === container) {
9
+ return ownerWindow(container).innerWidth > doc.documentElement.clientWidth;
10
+ }
11
+ return container.scrollHeight > container.clientHeight;
12
+ }
13
+ export function ariaHidden(element, show) {
14
+ if (show) {
15
+ element.setAttribute('aria-hidden', 'true');
16
+ } else {
17
+ element.removeAttribute('aria-hidden');
18
+ }
19
+ }
20
+ function getPaddingRight(element) {
21
+ return parseInt(ownerWindow(element).getComputedStyle(element).paddingRight, 10) || 0;
22
+ }
23
+ function isAriaHiddenForbiddenOnElement(element) {
24
+ // The forbidden HTML tags are the ones from ARIA specification that
25
+ // can be children of body and can't have aria-hidden attribute.
26
+ // cf. https://www.w3.org/TR/html-aria/#docconformance
27
+ var forbiddenTagNames = ['TEMPLATE', 'SCRIPT', 'STYLE', 'LINK', 'MAP', 'META', 'NOSCRIPT', 'PICTURE', 'COL', 'COLGROUP', 'PARAM', 'SLOT', 'SOURCE', 'TRACK'];
28
+ var isForbiddenTagName = forbiddenTagNames.indexOf(element.tagName) !== -1;
29
+ var isInputHidden = element.tagName === 'INPUT' && element.getAttribute('type') === 'hidden';
30
+ return isForbiddenTagName || isInputHidden;
31
+ }
32
+ function ariaHiddenSiblings(container, mountElement, currentElement, elementsToExclude, show) {
33
+ var blacklist = [mountElement, currentElement].concat(_toConsumableArray(elementsToExclude));
34
+ [].forEach.call(container.children, function (element) {
35
+ var isNotExcludedElement = blacklist.indexOf(element) === -1;
36
+ var isNotForbiddenElement = !isAriaHiddenForbiddenOnElement(element);
37
+ if (isNotExcludedElement && isNotForbiddenElement) {
38
+ ariaHidden(element, show);
39
+ }
40
+ });
41
+ }
42
+ function findIndexOf(items, callback) {
43
+ var idx = -1;
44
+ items.some(function (item, index) {
45
+ if (callback(item)) {
46
+ idx = index;
47
+ return true;
48
+ }
49
+ return false;
50
+ });
51
+ return idx;
52
+ }
53
+ function handleContainer(containerInfo, props) {
54
+ var restoreStyle = [];
55
+ var container = containerInfo.container;
56
+ if (!props.disableScrollLock) {
57
+ if (isOverflowing(container)) {
58
+ // Compute the size before applying overflow hidden to avoid any scroll jumps.
59
+ var scrollbarSize = getScrollbarSize(ownerDocument(container));
60
+ restoreStyle.push({
61
+ value: container.style.paddingRight,
62
+ property: 'padding-right',
63
+ el: container
64
+ });
65
+ // Use computed style, here to get the real padding to add our scrollbar width.
66
+ container.style.paddingRight = "".concat(getPaddingRight(container) + scrollbarSize, "px");
67
+
68
+ // .mui-fixed is a global helper.
69
+ var fixedElements = ownerDocument(container).querySelectorAll('.mui-fixed');
70
+ [].forEach.call(fixedElements, function (element) {
71
+ restoreStyle.push({
72
+ value: element.style.paddingRight,
73
+ property: 'padding-right',
74
+ el: element
75
+ });
76
+ element.style.paddingRight = "".concat(getPaddingRight(element) + scrollbarSize, "px");
77
+ });
78
+ }
79
+ var scrollContainer;
80
+ if (container.parentNode instanceof DocumentFragment) {
81
+ scrollContainer = ownerDocument(container).body;
82
+ } else {
83
+ // Support html overflow-y: auto for scroll stability between pages
84
+ // https://css-tricks.com/snippets/css/force-vertical-scrollbar/
85
+ var parent = container.parentElement;
86
+ var containerWindow = ownerWindow(container);
87
+ scrollContainer = (parent == null ? void 0 : parent.nodeName) === 'HTML' && containerWindow.getComputedStyle(parent).overflowY === 'scroll' ? parent : container;
88
+ }
89
+
90
+ // Block the scroll even if no scrollbar is visible to account for mobile keyboard
91
+ // screensize shrink.
92
+ restoreStyle.push({
93
+ value: scrollContainer.style.overflow,
94
+ property: 'overflow',
95
+ el: scrollContainer
96
+ }, {
97
+ value: scrollContainer.style.overflowX,
98
+ property: 'overflow-x',
99
+ el: scrollContainer
100
+ }, {
101
+ value: scrollContainer.style.overflowY,
102
+ property: 'overflow-y',
103
+ el: scrollContainer
104
+ });
105
+ scrollContainer.style.overflow = 'hidden';
106
+ }
107
+ var restore = function restore() {
108
+ restoreStyle.forEach(function (_ref) {
109
+ var value = _ref.value,
110
+ el = _ref.el,
111
+ property = _ref.property;
112
+ if (value) {
113
+ el.style.setProperty(property, value);
114
+ } else {
115
+ el.style.removeProperty(property);
116
+ }
117
+ });
118
+ };
119
+ return restore;
120
+ }
121
+ function getHiddenSiblings(container) {
122
+ var hiddenSiblings = [];
123
+ [].forEach.call(container.children, function (element) {
124
+ if (element.getAttribute('aria-hidden') === 'true') {
125
+ hiddenSiblings.push(element);
126
+ }
127
+ });
128
+ return hiddenSiblings;
129
+ }
130
+ /**
131
+ * @ignore - do not document.
132
+ *
133
+ * Proper state management for containers and the modals in those containers.
134
+ * Simplified, but inspired by react-overlay's ModalManager class.
135
+ * Used by the Modal to ensure proper styling of containers.
136
+ */
137
+ export var ModalManager = /*#__PURE__*/function () {
138
+ function ModalManager() {
139
+ _classCallCheck(this, ModalManager);
140
+ this.containers = void 0;
141
+ this.modals = void 0;
142
+ this.modals = [];
143
+ this.containers = [];
144
+ }
145
+ _createClass(ModalManager, [{
146
+ key: "add",
147
+ value: function add(modal, container) {
148
+ var modalIndex = this.modals.indexOf(modal);
149
+ if (modalIndex !== -1) {
150
+ return modalIndex;
151
+ }
152
+ modalIndex = this.modals.length;
153
+ this.modals.push(modal);
154
+
155
+ // If the modal we are adding is already in the DOM.
156
+ if (modal.modalRef) {
157
+ ariaHidden(modal.modalRef, false);
158
+ }
159
+ var hiddenSiblings = getHiddenSiblings(container);
160
+ ariaHiddenSiblings(container, modal.mount, modal.modalRef, hiddenSiblings, true);
161
+ var containerIndex = findIndexOf(this.containers, function (item) {
162
+ return item.container === container;
163
+ });
164
+ if (containerIndex !== -1) {
165
+ this.containers[containerIndex].modals.push(modal);
166
+ return modalIndex;
167
+ }
168
+ this.containers.push({
169
+ modals: [modal],
170
+ container: container,
171
+ restore: null,
172
+ hiddenSiblings: hiddenSiblings
173
+ });
174
+ return modalIndex;
175
+ }
176
+ }, {
177
+ key: "mount",
178
+ value: function mount(modal, props) {
179
+ var containerIndex = findIndexOf(this.containers, function (item) {
180
+ return item.modals.indexOf(modal) !== -1;
181
+ });
182
+ var containerInfo = this.containers[containerIndex];
183
+ if (!containerInfo.restore) {
184
+ containerInfo.restore = handleContainer(containerInfo, props);
185
+ }
186
+ }
187
+ }, {
188
+ key: "remove",
189
+ value: function remove(modal) {
190
+ var ariaHiddenState = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
191
+ var modalIndex = this.modals.indexOf(modal);
192
+ if (modalIndex === -1) {
193
+ return modalIndex;
194
+ }
195
+ var containerIndex = findIndexOf(this.containers, function (item) {
196
+ return item.modals.indexOf(modal) !== -1;
197
+ });
198
+ var containerInfo = this.containers[containerIndex];
199
+ containerInfo.modals.splice(containerInfo.modals.indexOf(modal), 1);
200
+ this.modals.splice(modalIndex, 1);
201
+
202
+ // If that was the last modal in a container, clean up the container.
203
+ if (containerInfo.modals.length === 0) {
204
+ // The modal might be closed before it had the chance to be mounted in the DOM.
205
+ if (containerInfo.restore) {
206
+ containerInfo.restore();
207
+ }
208
+ if (modal.modalRef) {
209
+ // In case the modal wasn't in the DOM yet.
210
+ ariaHidden(modal.modalRef, ariaHiddenState);
211
+ }
212
+ ariaHiddenSiblings(containerInfo.container, modal.mount, modal.modalRef, containerInfo.hiddenSiblings, false);
213
+ this.containers.splice(containerIndex, 1);
214
+ } else {
215
+ // Otherwise make sure the next top modal is visible to a screen reader.
216
+ var nextTop = containerInfo.modals[containerInfo.modals.length - 1];
217
+ // as soon as a modal is adding its modalRef is undefined. it can't set
218
+ // aria-hidden because the dom element doesn't exist either
219
+ // when modal was unmounted before modalRef gets null
220
+ if (nextTop.modalRef) {
221
+ ariaHidden(nextTop.modalRef, false);
222
+ }
223
+ }
224
+ return modalIndex;
225
+ }
226
+ }, {
227
+ key: "isTopModal",
228
+ value: function isTopModal(modal) {
229
+ return this.modals.length > 0 && this.modals[this.modals.length - 1] === modal;
230
+ }
231
+ }]);
232
+ return ModalManager;
233
+ }();
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
 
3
- export { ModalManager } from '@mui/base/unstable_useModal';
3
+ export { ModalManager } from './ModalManager';
4
4
  export { default } from './Modal';
5
5
  export { default as modalClasses } from './modalClasses';
6
6
  export * from './modalClasses';