@mui/material 6.0.0-beta.0 → 6.0.0-beta.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 (207) 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 +48 -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 +1 -1
  21. package/Modal/ModalManager.d.ts +25 -0
  22. package/Modal/ModalManager.js +211 -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 +1 -1
  36. package/Popper/BasePopper.d.ts +7 -0
  37. package/Popper/BasePopper.js +370 -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 +647 -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 +3 -3
  60. package/Snackbar/useSnackbar.d.ts +14 -0
  61. package/Snackbar/useSnackbar.js +133 -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 +222 -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 +1 -1
  77. package/Unstable_TrapFocus/FocusTrap.d.ts +10 -0
  78. package/Unstable_TrapFocus/FocusTrap.js +330 -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/modern/Autocomplete/Autocomplete.js +1 -1
  86. package/modern/Badge/Badge.js +2 -2
  87. package/modern/Badge/useBadge.js +41 -0
  88. package/modern/Badge/useBadge.types.js +1 -0
  89. package/modern/Breadcrumbs/Breadcrumbs.js +1 -1
  90. package/modern/ClickAwayListener/ClickAwayListener.js +178 -0
  91. package/modern/ClickAwayListener/index.js +1 -1
  92. package/modern/InputBase/InputBase.js +2 -2
  93. package/modern/ListItem/ListItem.js +1 -1
  94. package/modern/Menu/Menu.js +1 -1
  95. package/modern/Modal/Modal.js +1 -1
  96. package/modern/Modal/ModalManager.js +211 -0
  97. package/modern/Modal/index.js +1 -1
  98. package/modern/Modal/useModal.js +195 -0
  99. package/modern/Modal/useModal.types.js +1 -0
  100. package/modern/NoSsr/NoSsr.js +73 -0
  101. package/modern/NoSsr/NoSsr.types.js +1 -0
  102. package/modern/NoSsr/index.js +1 -1
  103. package/modern/Popover/Popover.js +1 -1
  104. package/modern/Popper/BasePopper.js +370 -0
  105. package/modern/Popper/BasePopper.types.js +1 -0
  106. package/modern/Popper/Popper.js +1 -1
  107. package/modern/Popper/index.js +2 -1
  108. package/modern/Popper/popperClasses.js +7 -0
  109. package/modern/Portal/Portal.js +92 -0
  110. package/modern/Portal/Portal.types.js +1 -0
  111. package/modern/Portal/index.js +1 -1
  112. package/modern/Slider/Slider.js +3 -2
  113. package/modern/Slider/useSlider.js +647 -0
  114. package/modern/Slider/useSlider.types.js +1 -0
  115. package/modern/Snackbar/Snackbar.js +3 -3
  116. package/modern/Snackbar/useSnackbar.js +133 -0
  117. package/modern/Snackbar/useSnackbar.types.js +1 -0
  118. package/modern/SwipeableDrawer/SwipeableDrawer.js +1 -1
  119. package/modern/TabScrollButton/TabScrollButton.js +1 -1
  120. package/modern/TablePagination/TablePagination.js +1 -1
  121. package/modern/Tabs/Tabs.js +1 -1
  122. package/modern/TextareaAutosize/TextareaAutosize.js +222 -0
  123. package/modern/TextareaAutosize/TextareaAutosize.types.js +1 -0
  124. package/modern/TextareaAutosize/index.js +1 -1
  125. package/modern/Tooltip/Tooltip.js +1 -1
  126. package/modern/Unstable_TrapFocus/FocusTrap.js +330 -0
  127. package/modern/Unstable_TrapFocus/FocusTrap.types.js +1 -0
  128. package/modern/Unstable_TrapFocus/index.js +1 -1
  129. package/modern/index.js +2 -2
  130. package/modern/useAutocomplete/useAutocomplete.js +976 -2
  131. package/modern/utils/PolymorphicComponent.js +1 -0
  132. package/modern/utils/areArraysEqual.js +4 -0
  133. package/modern/utils/index.js +1 -1
  134. package/modern/utils/isHostComponent.js +7 -0
  135. package/modern/utils/omitEventHandlers.js +18 -0
  136. package/modern/utils/shouldSpreadAdditionalProps.js +1 -1
  137. package/modern/utils/useSlot.js +3 -1
  138. package/node/Autocomplete/Autocomplete.js +3 -3
  139. package/node/Badge/Badge.js +5 -5
  140. package/node/Badge/useBadge.js +46 -0
  141. package/node/Badge/useBadge.types.js +5 -0
  142. package/node/Breadcrumbs/Breadcrumbs.js +2 -2
  143. package/node/ClickAwayListener/ClickAwayListener.js +184 -0
  144. package/node/ClickAwayListener/index.js +1 -1
  145. package/node/InputBase/InputBase.js +7 -7
  146. package/node/ListItem/ListItem.js +3 -3
  147. package/node/Menu/Menu.js +3 -3
  148. package/node/Modal/Modal.js +2 -2
  149. package/node/Modal/ModalManager.js +219 -0
  150. package/node/Modal/index.js +2 -2
  151. package/node/Modal/useModal.js +205 -0
  152. package/node/Modal/useModal.types.js +5 -0
  153. package/node/NoSsr/NoSsr.js +81 -0
  154. package/node/NoSsr/NoSsr.types.js +5 -0
  155. package/node/NoSsr/index.js +3 -2
  156. package/node/Popover/Popover.js +2 -2
  157. package/node/Popper/BasePopper.js +379 -0
  158. package/node/Popper/BasePopper.types.js +5 -0
  159. package/node/Popper/Popper.js +2 -2
  160. package/node/Popper/index.js +14 -1
  161. package/node/Popper/popperClasses.js +15 -0
  162. package/node/Portal/Portal.js +100 -0
  163. package/node/Portal/Portal.types.js +5 -0
  164. package/node/Portal/index.js +3 -2
  165. package/node/Slider/Slider.js +14 -13
  166. package/node/Slider/useSlider.js +670 -0
  167. package/node/Slider/useSlider.types.js +5 -0
  168. package/node/Snackbar/Snackbar.js +6 -6
  169. package/node/Snackbar/useSnackbar.js +141 -0
  170. package/node/Snackbar/useSnackbar.types.js +5 -0
  171. package/node/SwipeableDrawer/SwipeableDrawer.js +2 -2
  172. package/node/TabScrollButton/TabScrollButton.js +3 -3
  173. package/node/TablePagination/TablePagination.js +2 -2
  174. package/node/Tabs/Tabs.js +3 -3
  175. package/node/TextareaAutosize/TextareaAutosize.js +230 -0
  176. package/node/TextareaAutosize/TextareaAutosize.types.js +5 -0
  177. package/node/TextareaAutosize/index.js +3 -2
  178. package/node/Tooltip/Tooltip.js +5 -5
  179. package/node/Unstable_TrapFocus/FocusTrap.js +339 -0
  180. package/node/Unstable_TrapFocus/FocusTrap.types.js +5 -0
  181. package/node/Unstable_TrapFocus/index.js +3 -2
  182. package/node/index.js +3 -3
  183. package/node/useAutocomplete/useAutocomplete.js +985 -18
  184. package/node/utils/PolymorphicComponent.js +5 -0
  185. package/node/utils/areArraysEqual.js +10 -0
  186. package/node/utils/index.js +2 -2
  187. package/node/utils/isHostComponent.js +13 -0
  188. package/node/utils/omitEventHandlers.js +24 -0
  189. package/node/utils/shouldSpreadAdditionalProps.js +3 -2
  190. package/node/utils/useSlot.js +6 -4
  191. package/package.json +8 -8
  192. package/styles/overrides.d.ts +1 -1
  193. package/useAutocomplete/useAutocomplete.d.ts +468 -2
  194. package/useAutocomplete/useAutocomplete.js +976 -2
  195. package/utils/PolymorphicComponent.d.ts +17 -0
  196. package/utils/PolymorphicComponent.js +1 -0
  197. package/utils/areArraysEqual.d.ts +3 -0
  198. package/utils/areArraysEqual.js +4 -0
  199. package/utils/index.d.ts +2 -1
  200. package/utils/index.js +1 -1
  201. package/utils/isHostComponent.d.ts +6 -0
  202. package/utils/isHostComponent.js +7 -0
  203. package/utils/omitEventHandlers.d.ts +9 -0
  204. package/utils/omitEventHandlers.js +18 -0
  205. package/utils/shouldSpreadAdditionalProps.js +1 -1
  206. package/utils/types.d.ts +2 -1
  207. package/utils/useSlot.js +3 -1
@@ -0,0 +1,219 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ModalManager = void 0;
7
+ exports.ariaHidden = ariaHidden;
8
+ var _utils = require("@mui/utils");
9
+ // Is a vertical scrollbar displayed?
10
+ function isOverflowing(container) {
11
+ const doc = (0, _utils.unstable_ownerDocument)(container);
12
+ if (doc.body === container) {
13
+ return (0, _utils.unstable_ownerWindow)(container).innerWidth > doc.documentElement.clientWidth;
14
+ }
15
+ return container.scrollHeight > container.clientHeight;
16
+ }
17
+ function ariaHidden(element, show) {
18
+ if (show) {
19
+ element.setAttribute('aria-hidden', 'true');
20
+ } else {
21
+ element.removeAttribute('aria-hidden');
22
+ }
23
+ }
24
+ function getPaddingRight(element) {
25
+ return parseInt((0, _utils.unstable_ownerWindow)(element).getComputedStyle(element).paddingRight, 10) || 0;
26
+ }
27
+ function isAriaHiddenForbiddenOnElement(element) {
28
+ // The forbidden HTML tags are the ones from ARIA specification that
29
+ // can be children of body and can't have aria-hidden attribute.
30
+ // cf. https://www.w3.org/TR/html-aria/#docconformance
31
+ const forbiddenTagNames = ['TEMPLATE', 'SCRIPT', 'STYLE', 'LINK', 'MAP', 'META', 'NOSCRIPT', 'PICTURE', 'COL', 'COLGROUP', 'PARAM', 'SLOT', 'SOURCE', 'TRACK'];
32
+ const isForbiddenTagName = forbiddenTagNames.indexOf(element.tagName) !== -1;
33
+ const isInputHidden = element.tagName === 'INPUT' && element.getAttribute('type') === 'hidden';
34
+ return isForbiddenTagName || isInputHidden;
35
+ }
36
+ function ariaHiddenSiblings(container, mountElement, currentElement, elementsToExclude, show) {
37
+ const blacklist = [mountElement, currentElement, ...elementsToExclude];
38
+ [].forEach.call(container.children, element => {
39
+ const isNotExcludedElement = blacklist.indexOf(element) === -1;
40
+ const isNotForbiddenElement = !isAriaHiddenForbiddenOnElement(element);
41
+ if (isNotExcludedElement && isNotForbiddenElement) {
42
+ ariaHidden(element, show);
43
+ }
44
+ });
45
+ }
46
+ function findIndexOf(items, callback) {
47
+ let idx = -1;
48
+ items.some((item, index) => {
49
+ if (callback(item)) {
50
+ idx = index;
51
+ return true;
52
+ }
53
+ return false;
54
+ });
55
+ return idx;
56
+ }
57
+ function handleContainer(containerInfo, props) {
58
+ const restoreStyle = [];
59
+ const container = containerInfo.container;
60
+ if (!props.disableScrollLock) {
61
+ if (isOverflowing(container)) {
62
+ // Compute the size before applying overflow hidden to avoid any scroll jumps.
63
+ const scrollbarSize = (0, _utils.unstable_getScrollbarSize)((0, _utils.unstable_ownerDocument)(container));
64
+ restoreStyle.push({
65
+ value: container.style.paddingRight,
66
+ property: 'padding-right',
67
+ el: container
68
+ });
69
+ // Use computed style, here to get the real padding to add our scrollbar width.
70
+ container.style.paddingRight = `${getPaddingRight(container) + scrollbarSize}px`;
71
+
72
+ // .mui-fixed is a global helper.
73
+ const fixedElements = (0, _utils.unstable_ownerDocument)(container).querySelectorAll('.mui-fixed');
74
+ [].forEach.call(fixedElements, element => {
75
+ restoreStyle.push({
76
+ value: element.style.paddingRight,
77
+ property: 'padding-right',
78
+ el: element
79
+ });
80
+ element.style.paddingRight = `${getPaddingRight(element) + scrollbarSize}px`;
81
+ });
82
+ }
83
+ let scrollContainer;
84
+ if (container.parentNode instanceof DocumentFragment) {
85
+ scrollContainer = (0, _utils.unstable_ownerDocument)(container).body;
86
+ } else {
87
+ // Support html overflow-y: auto for scroll stability between pages
88
+ // https://css-tricks.com/snippets/css/force-vertical-scrollbar/
89
+ const parent = container.parentElement;
90
+ const containerWindow = (0, _utils.unstable_ownerWindow)(container);
91
+ scrollContainer = (parent == null ? void 0 : parent.nodeName) === 'HTML' && containerWindow.getComputedStyle(parent).overflowY === 'scroll' ? parent : container;
92
+ }
93
+
94
+ // Block the scroll even if no scrollbar is visible to account for mobile keyboard
95
+ // screensize shrink.
96
+ restoreStyle.push({
97
+ value: scrollContainer.style.overflow,
98
+ property: 'overflow',
99
+ el: scrollContainer
100
+ }, {
101
+ value: scrollContainer.style.overflowX,
102
+ property: 'overflow-x',
103
+ el: scrollContainer
104
+ }, {
105
+ value: scrollContainer.style.overflowY,
106
+ property: 'overflow-y',
107
+ el: scrollContainer
108
+ });
109
+ scrollContainer.style.overflow = 'hidden';
110
+ }
111
+ const restore = () => {
112
+ restoreStyle.forEach(({
113
+ value,
114
+ el,
115
+ property
116
+ }) => {
117
+ if (value) {
118
+ el.style.setProperty(property, value);
119
+ } else {
120
+ el.style.removeProperty(property);
121
+ }
122
+ });
123
+ };
124
+ return restore;
125
+ }
126
+ function getHiddenSiblings(container) {
127
+ const hiddenSiblings = [];
128
+ [].forEach.call(container.children, element => {
129
+ if (element.getAttribute('aria-hidden') === 'true') {
130
+ hiddenSiblings.push(element);
131
+ }
132
+ });
133
+ return hiddenSiblings;
134
+ }
135
+ /**
136
+ * @ignore - do not document.
137
+ *
138
+ * Proper state management for containers and the modals in those containers.
139
+ * Simplified, but inspired by react-overlay's ModalManager class.
140
+ * Used by the Modal to ensure proper styling of containers.
141
+ */
142
+ class ModalManager {
143
+ constructor() {
144
+ this.modals = [];
145
+ this.containers = [];
146
+ }
147
+ add(modal, container) {
148
+ let 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
+ const hiddenSiblings = getHiddenSiblings(container);
160
+ ariaHiddenSiblings(container, modal.mount, modal.modalRef, hiddenSiblings, true);
161
+ const containerIndex = findIndexOf(this.containers, item => item.container === container);
162
+ if (containerIndex !== -1) {
163
+ this.containers[containerIndex].modals.push(modal);
164
+ return modalIndex;
165
+ }
166
+ this.containers.push({
167
+ modals: [modal],
168
+ container,
169
+ restore: null,
170
+ hiddenSiblings
171
+ });
172
+ return modalIndex;
173
+ }
174
+ mount(modal, props) {
175
+ const containerIndex = findIndexOf(this.containers, item => item.modals.indexOf(modal) !== -1);
176
+ const containerInfo = this.containers[containerIndex];
177
+ if (!containerInfo.restore) {
178
+ containerInfo.restore = handleContainer(containerInfo, props);
179
+ }
180
+ }
181
+ remove(modal, ariaHiddenState = true) {
182
+ const modalIndex = this.modals.indexOf(modal);
183
+ if (modalIndex === -1) {
184
+ return modalIndex;
185
+ }
186
+ const containerIndex = findIndexOf(this.containers, item => item.modals.indexOf(modal) !== -1);
187
+ const containerInfo = this.containers[containerIndex];
188
+ containerInfo.modals.splice(containerInfo.modals.indexOf(modal), 1);
189
+ this.modals.splice(modalIndex, 1);
190
+
191
+ // If that was the last modal in a container, clean up the container.
192
+ if (containerInfo.modals.length === 0) {
193
+ // The modal might be closed before it had the chance to be mounted in the DOM.
194
+ if (containerInfo.restore) {
195
+ containerInfo.restore();
196
+ }
197
+ if (modal.modalRef) {
198
+ // In case the modal wasn't in the DOM yet.
199
+ ariaHidden(modal.modalRef, ariaHiddenState);
200
+ }
201
+ ariaHiddenSiblings(containerInfo.container, modal.mount, modal.modalRef, containerInfo.hiddenSiblings, false);
202
+ this.containers.splice(containerIndex, 1);
203
+ } else {
204
+ // Otherwise make sure the next top modal is visible to a screen reader.
205
+ const nextTop = containerInfo.modals[containerInfo.modals.length - 1];
206
+ // as soon as a modal is adding its modalRef is undefined. it can't set
207
+ // aria-hidden because the dom element doesn't exist either
208
+ // when modal was unmounted before modalRef gets null
209
+ if (nextTop.modalRef) {
210
+ ariaHidden(nextTop.modalRef, false);
211
+ }
212
+ }
213
+ return modalIndex;
214
+ }
215
+ isTopModal(modal) {
216
+ return this.modals.length > 0 && this.modals[this.modals.length - 1] === modal;
217
+ }
218
+ }
219
+ exports.ModalManager = ModalManager;
@@ -12,7 +12,7 @@ var _exportNames = {
12
12
  Object.defineProperty(exports, "ModalManager", {
13
13
  enumerable: true,
14
14
  get: function () {
15
- return _unstable_useModal.ModalManager;
15
+ return _ModalManager.ModalManager;
16
16
  }
17
17
  });
18
18
  Object.defineProperty(exports, "default", {
@@ -27,7 +27,7 @@ Object.defineProperty(exports, "modalClasses", {
27
27
  return _modalClasses.default;
28
28
  }
29
29
  });
30
- var _unstable_useModal = require("@mui/base/unstable_useModal");
30
+ var _ModalManager = require("./ModalManager");
31
31
  var _Modal = _interopRequireDefault(require("./Modal"));
32
32
  var _modalClasses = _interopRequireWildcard(require("./modalClasses"));
33
33
  Object.keys(_modalClasses).forEach(function (key) {
@@ -0,0 +1,205 @@
1
+ "use strict";
2
+ 'use client';
3
+
4
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+ var React = _interopRequireWildcard(require("react"));
10
+ var _utils = require("@mui/utils");
11
+ var _extractEventHandlers = _interopRequireDefault(require("@mui/utils/extractEventHandlers"));
12
+ var _ModalManager = require("./ModalManager");
13
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
14
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
15
+ function getContainer(container) {
16
+ return typeof container === 'function' ? container() : container;
17
+ }
18
+ function getHasTransition(children) {
19
+ return children ? children.props.hasOwnProperty('in') : false;
20
+ }
21
+
22
+ // A modal manager used to track and manage the state of open Modals.
23
+ // Modals don't open on the server so this won't conflict with concurrent requests.
24
+ const defaultManager = new _ModalManager.ModalManager();
25
+ /**
26
+ *
27
+ * Demos:
28
+ *
29
+ * - [Modal](https://next.mui.com/base-ui/react-modal/#hook)
30
+ *
31
+ * API:
32
+ *
33
+ * - [useModal API](https://next.mui.com/base-ui/react-modal/hooks-api/#use-modal)
34
+ */
35
+ function useModal(parameters) {
36
+ const {
37
+ container,
38
+ disableEscapeKeyDown = false,
39
+ disableScrollLock = false,
40
+ // @ts-ignore internal logic - Base UI supports the manager as a prop too
41
+ manager = defaultManager,
42
+ closeAfterTransition = false,
43
+ onTransitionEnter,
44
+ onTransitionExited,
45
+ children,
46
+ onClose,
47
+ open,
48
+ rootRef
49
+ } = parameters;
50
+
51
+ // @ts-ignore internal logic
52
+ const modal = React.useRef({});
53
+ const mountNodeRef = React.useRef(null);
54
+ const modalRef = React.useRef(null);
55
+ const handleRef = (0, _utils.unstable_useForkRef)(modalRef, rootRef);
56
+ const [exited, setExited] = React.useState(!open);
57
+ const hasTransition = getHasTransition(children);
58
+ let ariaHiddenProp = true;
59
+ if (parameters['aria-hidden'] === 'false' || parameters['aria-hidden'] === false) {
60
+ ariaHiddenProp = false;
61
+ }
62
+ const getDoc = () => (0, _utils.unstable_ownerDocument)(mountNodeRef.current);
63
+ const getModal = () => {
64
+ modal.current.modalRef = modalRef.current;
65
+ modal.current.mount = mountNodeRef.current;
66
+ return modal.current;
67
+ };
68
+ const handleMounted = () => {
69
+ manager.mount(getModal(), {
70
+ disableScrollLock
71
+ });
72
+
73
+ // Fix a bug on Chrome where the scroll isn't initially 0.
74
+ if (modalRef.current) {
75
+ modalRef.current.scrollTop = 0;
76
+ }
77
+ };
78
+ const handleOpen = (0, _utils.unstable_useEventCallback)(() => {
79
+ const resolvedContainer = getContainer(container) || getDoc().body;
80
+ manager.add(getModal(), resolvedContainer);
81
+
82
+ // The element was already mounted.
83
+ if (modalRef.current) {
84
+ handleMounted();
85
+ }
86
+ });
87
+ const isTopModal = React.useCallback(() => manager.isTopModal(getModal()), [manager]);
88
+ const handlePortalRef = (0, _utils.unstable_useEventCallback)(node => {
89
+ mountNodeRef.current = node;
90
+ if (!node) {
91
+ return;
92
+ }
93
+ if (open && isTopModal()) {
94
+ handleMounted();
95
+ } else if (modalRef.current) {
96
+ (0, _ModalManager.ariaHidden)(modalRef.current, ariaHiddenProp);
97
+ }
98
+ });
99
+ const handleClose = React.useCallback(() => {
100
+ manager.remove(getModal(), ariaHiddenProp);
101
+ }, [ariaHiddenProp, manager]);
102
+ React.useEffect(() => {
103
+ return () => {
104
+ handleClose();
105
+ };
106
+ }, [handleClose]);
107
+ React.useEffect(() => {
108
+ if (open) {
109
+ handleOpen();
110
+ } else if (!hasTransition || !closeAfterTransition) {
111
+ handleClose();
112
+ }
113
+ }, [open, handleClose, hasTransition, closeAfterTransition, handleOpen]);
114
+ const createHandleKeyDown = otherHandlers => event => {
115
+ var _otherHandlers$onKeyD;
116
+ (_otherHandlers$onKeyD = otherHandlers.onKeyDown) == null || _otherHandlers$onKeyD.call(otherHandlers, event);
117
+
118
+ // The handler doesn't take event.defaultPrevented into account:
119
+ //
120
+ // event.preventDefault() is meant to stop default behaviors like
121
+ // clicking a checkbox to check it, hitting a button to submit a form,
122
+ // and hitting left arrow to move the cursor in a text input etc.
123
+ // Only special HTML elements have these default behaviors.
124
+ if (event.key !== 'Escape' || event.which === 229 ||
125
+ // Wait until IME is settled.
126
+ !isTopModal()) {
127
+ return;
128
+ }
129
+ if (!disableEscapeKeyDown) {
130
+ // Swallow the event, in case someone is listening for the escape key on the body.
131
+ event.stopPropagation();
132
+ if (onClose) {
133
+ onClose(event, 'escapeKeyDown');
134
+ }
135
+ }
136
+ };
137
+ const createHandleBackdropClick = otherHandlers => event => {
138
+ var _otherHandlers$onClic;
139
+ (_otherHandlers$onClic = otherHandlers.onClick) == null || _otherHandlers$onClic.call(otherHandlers, event);
140
+ if (event.target !== event.currentTarget) {
141
+ return;
142
+ }
143
+ if (onClose) {
144
+ onClose(event, 'backdropClick');
145
+ }
146
+ };
147
+ const getRootProps = (otherHandlers = {}) => {
148
+ const propsEventHandlers = (0, _extractEventHandlers.default)(parameters);
149
+
150
+ // The custom event handlers shouldn't be spread on the root element
151
+ delete propsEventHandlers.onTransitionEnter;
152
+ delete propsEventHandlers.onTransitionExited;
153
+ const externalEventHandlers = {
154
+ ...propsEventHandlers,
155
+ ...otherHandlers
156
+ };
157
+ return {
158
+ role: 'presentation',
159
+ ...externalEventHandlers,
160
+ onKeyDown: createHandleKeyDown(externalEventHandlers),
161
+ ref: handleRef
162
+ };
163
+ };
164
+ const getBackdropProps = (otherHandlers = {}) => {
165
+ const externalEventHandlers = otherHandlers;
166
+ return {
167
+ 'aria-hidden': true,
168
+ ...externalEventHandlers,
169
+ onClick: createHandleBackdropClick(externalEventHandlers),
170
+ open
171
+ };
172
+ };
173
+ const getTransitionProps = () => {
174
+ const handleEnter = () => {
175
+ setExited(false);
176
+ if (onTransitionEnter) {
177
+ onTransitionEnter();
178
+ }
179
+ };
180
+ const handleExited = () => {
181
+ setExited(true);
182
+ if (onTransitionExited) {
183
+ onTransitionExited();
184
+ }
185
+ if (closeAfterTransition) {
186
+ handleClose();
187
+ }
188
+ };
189
+ return {
190
+ onEnter: (0, _utils.unstable_createChainedFunction)(handleEnter, children == null ? void 0 : children.props.onEnter),
191
+ onExited: (0, _utils.unstable_createChainedFunction)(handleExited, children == null ? void 0 : children.props.onExited)
192
+ };
193
+ };
194
+ return {
195
+ getRootProps,
196
+ getBackdropProps,
197
+ getTransitionProps,
198
+ rootRef: handleRef,
199
+ portalRef: handlePortalRef,
200
+ isTopModal,
201
+ exited,
202
+ hasTransition
203
+ };
204
+ }
205
+ var _default = exports.default = useModal;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -0,0 +1,81 @@
1
+ "use strict";
2
+ 'use client';
3
+
4
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+ var React = _interopRequireWildcard(require("react"));
10
+ var _propTypes = _interopRequireDefault(require("prop-types"));
11
+ var _utils = require("@mui/utils");
12
+ var _jsxRuntime = require("react/jsx-runtime");
13
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
14
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
15
+ /**
16
+ * NoSsr purposely removes components from the subject of Server Side Rendering (SSR).
17
+ *
18
+ * This component can be useful in a variety of situations:
19
+ *
20
+ * * Escape hatch for broken dependencies not supporting SSR.
21
+ * * Improve the time-to-first paint on the client by only rendering above the fold.
22
+ * * Reduce the rendering time on the server.
23
+ * * Under too heavy server load, you can turn on service degradation.
24
+ *
25
+ * Demos:
26
+ *
27
+ * - [No SSR](https://next.mui.com/material-ui/react-no-ssr/)
28
+ *
29
+ * API:
30
+ *
31
+ * - [NoSsr API](https://next.mui.com/material-ui/api/no-ssr/)
32
+ */
33
+ function NoSsr(props) {
34
+ const {
35
+ children,
36
+ defer = false,
37
+ fallback = null
38
+ } = props;
39
+ const [mountedState, setMountedState] = React.useState(false);
40
+ (0, _utils.unstable_useEnhancedEffect)(() => {
41
+ if (!defer) {
42
+ setMountedState(true);
43
+ }
44
+ }, [defer]);
45
+ React.useEffect(() => {
46
+ if (defer) {
47
+ setMountedState(true);
48
+ }
49
+ }, [defer]);
50
+
51
+ // We need the Fragment here to force react-docgen to recognise NoSsr as a component.
52
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(React.Fragment, {
53
+ children: mountedState ? children : fallback
54
+ });
55
+ }
56
+ process.env.NODE_ENV !== "production" ? NoSsr.propTypes /* remove-proptypes */ = {
57
+ // ┌────────────────────────────── Warning ──────────────────────────────┐
58
+ // │ These PropTypes are generated from the TypeScript type definitions. │
59
+ // │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
60
+ // └─────────────────────────────────────────────────────────────────────┘
61
+ /**
62
+ * You can wrap a node.
63
+ */
64
+ children: _propTypes.default.node,
65
+ /**
66
+ * If `true`, the component will not only prevent server-side rendering.
67
+ * It will also defer the rendering of the children into a different screen frame.
68
+ * @default false
69
+ */
70
+ defer: _propTypes.default.bool,
71
+ /**
72
+ * The fallback content to display.
73
+ * @default null
74
+ */
75
+ fallback: _propTypes.default.node
76
+ } : void 0;
77
+ if (process.env.NODE_ENV !== 'production') {
78
+ // eslint-disable-next-line
79
+ NoSsr['propTypes' + ''] = (0, _utils.exactProp)(NoSsr.propTypes);
80
+ }
81
+ var _default = exports.default = NoSsr;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -1,12 +1,13 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  Object.defineProperty(exports, "default", {
7
8
  enumerable: true,
8
9
  get: function () {
9
- return _NoSsr.NoSsr;
10
+ return _NoSsr.default;
10
11
  }
11
12
  });
12
- var _NoSsr = require("@mui/base/NoSsr");
13
+ var _NoSsr = _interopRequireDefault(require("./NoSsr"));
@@ -11,13 +11,13 @@ exports.getOffsetTop = getOffsetTop;
11
11
  var React = _interopRequireWildcard(require("react"));
12
12
  var _propTypes = _interopRequireDefault(require("prop-types"));
13
13
  var _clsx = _interopRequireDefault(require("clsx"));
14
- var _utils = require("@mui/base/utils");
15
14
  var _composeClasses = _interopRequireDefault(require("@mui/utils/composeClasses"));
16
15
  var _HTMLElementType = _interopRequireDefault(require("@mui/utils/HTMLElementType"));
17
16
  var _refType = _interopRequireDefault(require("@mui/utils/refType"));
18
17
  var _elementTypeAcceptingRef = _interopRequireDefault(require("@mui/utils/elementTypeAcceptingRef"));
19
18
  var _integerPropType = _interopRequireDefault(require("@mui/utils/integerPropType"));
20
19
  var _chainPropTypes = _interopRequireDefault(require("@mui/utils/chainPropTypes"));
20
+ var _isHostComponent = _interopRequireDefault(require("../utils/isHostComponent"));
21
21
  var _zeroStyled = require("../zero-styled");
22
22
  var _DefaultPropsProvider = require("../DefaultPropsProvider");
23
23
  var _debounce = _interopRequireDefault(require("../utils/debounce"));
@@ -349,7 +349,7 @@ const Popover = /*#__PURE__*/React.forwardRef(function Popover(inProps, ref) {
349
349
  const handlePaperRef = (0, _useForkRef.default)(paperRef, paperProps.ref);
350
350
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(RootSlot, {
351
351
  ...rootProps,
352
- ...(!(0, _utils.isHostComponent)(RootSlot) && {
352
+ ...(!(0, _isHostComponent.default)(RootSlot) && {
353
353
  slotProps: rootSlotPropsProp,
354
354
  disableScrollLock
355
355
  }),