@mui/material 5.16.1 → 5.16.3

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 +35 -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 +5 -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
@@ -0,0 +1,341 @@
1
+ 'use client';
2
+
3
+ /* eslint-disable consistent-return, jsx-a11y/no-noninteractive-tabindex */
4
+ import * as React from 'react';
5
+ import PropTypes from 'prop-types';
6
+ import { exactProp, elementAcceptingRef, unstable_useForkRef as useForkRef, unstable_ownerDocument as ownerDocument } from '@mui/utils';
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ import { jsxs as _jsxs } from "react/jsx-runtime";
9
+ // Inspired by https://github.com/focus-trap/tabbable
10
+ var candidatesSelector = ['input', 'select', 'textarea', 'a[href]', 'button', '[tabindex]', 'audio[controls]', 'video[controls]', '[contenteditable]:not([contenteditable="false"])'].join(',');
11
+ function getTabIndex(node) {
12
+ var tabindexAttr = parseInt(node.getAttribute('tabindex') || '', 10);
13
+ if (!Number.isNaN(tabindexAttr)) {
14
+ return tabindexAttr;
15
+ }
16
+
17
+ // Browsers do not return `tabIndex` correctly for contentEditable nodes;
18
+ // https://bugs.chromium.org/p/chromium/issues/detail?id=661108&q=contenteditable%20tabindex&can=2
19
+ // so if they don't have a tabindex attribute specifically set, assume it's 0.
20
+ // in Chrome, <details/>, <audio controls/> and <video controls/> elements get a default
21
+ // `tabIndex` of -1 when the 'tabindex' attribute isn't specified in the DOM,
22
+ // yet they are still part of the regular tab order; in FF, they get a default
23
+ // `tabIndex` of 0; since Chrome still puts those elements in the regular tab
24
+ // order, consider their tab index to be 0.
25
+ if (node.contentEditable === 'true' || (node.nodeName === 'AUDIO' || node.nodeName === 'VIDEO' || node.nodeName === 'DETAILS') && node.getAttribute('tabindex') === null) {
26
+ return 0;
27
+ }
28
+ return node.tabIndex;
29
+ }
30
+ function isNonTabbableRadio(node) {
31
+ if (node.tagName !== 'INPUT' || node.type !== 'radio') {
32
+ return false;
33
+ }
34
+ if (!node.name) {
35
+ return false;
36
+ }
37
+ var getRadio = function getRadio(selector) {
38
+ return node.ownerDocument.querySelector("input[type=\"radio\"]".concat(selector));
39
+ };
40
+ var roving = getRadio("[name=\"".concat(node.name, "\"]:checked"));
41
+ if (!roving) {
42
+ roving = getRadio("[name=\"".concat(node.name, "\"]"));
43
+ }
44
+ return roving !== node;
45
+ }
46
+ function isNodeMatchingSelectorFocusable(node) {
47
+ if (node.disabled || node.tagName === 'INPUT' && node.type === 'hidden' || isNonTabbableRadio(node)) {
48
+ return false;
49
+ }
50
+ return true;
51
+ }
52
+ function defaultGetTabbable(root) {
53
+ var regularTabNodes = [];
54
+ var orderedTabNodes = [];
55
+ Array.from(root.querySelectorAll(candidatesSelector)).forEach(function (node, i) {
56
+ var nodeTabIndex = getTabIndex(node);
57
+ if (nodeTabIndex === -1 || !isNodeMatchingSelectorFocusable(node)) {
58
+ return;
59
+ }
60
+ if (nodeTabIndex === 0) {
61
+ regularTabNodes.push(node);
62
+ } else {
63
+ orderedTabNodes.push({
64
+ documentOrder: i,
65
+ tabIndex: nodeTabIndex,
66
+ node: node
67
+ });
68
+ }
69
+ });
70
+ return orderedTabNodes.sort(function (a, b) {
71
+ return a.tabIndex === b.tabIndex ? a.documentOrder - b.documentOrder : a.tabIndex - b.tabIndex;
72
+ }).map(function (a) {
73
+ return a.node;
74
+ }).concat(regularTabNodes);
75
+ }
76
+ function defaultIsEnabled() {
77
+ return true;
78
+ }
79
+
80
+ /**
81
+ * @ignore - internal component.
82
+ */
83
+ function FocusTrap(props) {
84
+ var children = props.children,
85
+ _props$disableAutoFoc = props.disableAutoFocus,
86
+ disableAutoFocus = _props$disableAutoFoc === void 0 ? false : _props$disableAutoFoc,
87
+ _props$disableEnforce = props.disableEnforceFocus,
88
+ disableEnforceFocus = _props$disableEnforce === void 0 ? false : _props$disableEnforce,
89
+ _props$disableRestore = props.disableRestoreFocus,
90
+ disableRestoreFocus = _props$disableRestore === void 0 ? false : _props$disableRestore,
91
+ _props$getTabbable = props.getTabbable,
92
+ getTabbable = _props$getTabbable === void 0 ? defaultGetTabbable : _props$getTabbable,
93
+ _props$isEnabled = props.isEnabled,
94
+ isEnabled = _props$isEnabled === void 0 ? defaultIsEnabled : _props$isEnabled,
95
+ open = props.open;
96
+ var ignoreNextEnforceFocus = React.useRef(false);
97
+ var sentinelStart = React.useRef(null);
98
+ var sentinelEnd = React.useRef(null);
99
+ var nodeToRestore = React.useRef(null);
100
+ var reactFocusEventTarget = React.useRef(null);
101
+ // This variable is useful when disableAutoFocus is true.
102
+ // It waits for the active element to move into the component to activate.
103
+ var activated = React.useRef(false);
104
+ var rootRef = React.useRef(null);
105
+ // @ts-expect-error TODO upstream fix
106
+ var handleRef = useForkRef(children.ref, rootRef);
107
+ var lastKeydown = React.useRef(null);
108
+ React.useEffect(function () {
109
+ // We might render an empty child.
110
+ if (!open || !rootRef.current) {
111
+ return;
112
+ }
113
+ activated.current = !disableAutoFocus;
114
+ }, [disableAutoFocus, open]);
115
+ React.useEffect(function () {
116
+ // We might render an empty child.
117
+ if (!open || !rootRef.current) {
118
+ return;
119
+ }
120
+ var doc = ownerDocument(rootRef.current);
121
+ if (!rootRef.current.contains(doc.activeElement)) {
122
+ if (!rootRef.current.hasAttribute('tabIndex')) {
123
+ if (process.env.NODE_ENV !== 'production') {
124
+ console.error(['MUI: The modal content node does not accept focus.', 'For the benefit of assistive technologies, ' + 'the tabIndex of the node is being set to "-1".'].join('\n'));
125
+ }
126
+ rootRef.current.setAttribute('tabIndex', '-1');
127
+ }
128
+ if (activated.current) {
129
+ rootRef.current.focus();
130
+ }
131
+ }
132
+ return function () {
133
+ // restoreLastFocus()
134
+ if (!disableRestoreFocus) {
135
+ // In IE11 it is possible for document.activeElement to be null resulting
136
+ // in nodeToRestore.current being null.
137
+ // Not all elements in IE11 have a focus method.
138
+ // Once IE11 support is dropped the focus() call can be unconditional.
139
+ if (nodeToRestore.current && nodeToRestore.current.focus) {
140
+ ignoreNextEnforceFocus.current = true;
141
+ nodeToRestore.current.focus();
142
+ }
143
+ nodeToRestore.current = null;
144
+ }
145
+ };
146
+ // Missing `disableRestoreFocus` which is fine.
147
+ // We don't support changing that prop on an open FocusTrap
148
+ // eslint-disable-next-line react-hooks/exhaustive-deps
149
+ }, [open]);
150
+ React.useEffect(function () {
151
+ // We might render an empty child.
152
+ if (!open || !rootRef.current) {
153
+ return;
154
+ }
155
+ var doc = ownerDocument(rootRef.current);
156
+ var loopFocus = function loopFocus(nativeEvent) {
157
+ lastKeydown.current = nativeEvent;
158
+ if (disableEnforceFocus || !isEnabled() || nativeEvent.key !== 'Tab') {
159
+ return;
160
+ }
161
+
162
+ // Make sure the next tab starts from the right place.
163
+ // doc.activeElement refers to the origin.
164
+ if (doc.activeElement === rootRef.current && nativeEvent.shiftKey) {
165
+ // We need to ignore the next contain as
166
+ // it will try to move the focus back to the rootRef element.
167
+ ignoreNextEnforceFocus.current = true;
168
+ if (sentinelEnd.current) {
169
+ sentinelEnd.current.focus();
170
+ }
171
+ }
172
+ };
173
+ var contain = function contain() {
174
+ var rootElement = rootRef.current;
175
+
176
+ // Cleanup functions are executed lazily in React 17.
177
+ // Contain can be called between the component being unmounted and its cleanup function being run.
178
+ if (rootElement === null) {
179
+ return;
180
+ }
181
+ if (!doc.hasFocus() || !isEnabled() || ignoreNextEnforceFocus.current) {
182
+ ignoreNextEnforceFocus.current = false;
183
+ return;
184
+ }
185
+
186
+ // The focus is already inside
187
+ if (rootElement.contains(doc.activeElement)) {
188
+ return;
189
+ }
190
+
191
+ // The disableEnforceFocus is set and the focus is outside of the focus trap (and sentinel nodes)
192
+ if (disableEnforceFocus && doc.activeElement !== sentinelStart.current && doc.activeElement !== sentinelEnd.current) {
193
+ return;
194
+ }
195
+
196
+ // if the focus event is not coming from inside the children's react tree, reset the refs
197
+ if (doc.activeElement !== reactFocusEventTarget.current) {
198
+ reactFocusEventTarget.current = null;
199
+ } else if (reactFocusEventTarget.current !== null) {
200
+ return;
201
+ }
202
+ if (!activated.current) {
203
+ return;
204
+ }
205
+ var tabbable = [];
206
+ if (doc.activeElement === sentinelStart.current || doc.activeElement === sentinelEnd.current) {
207
+ tabbable = getTabbable(rootRef.current);
208
+ }
209
+
210
+ // one of the sentinel nodes was focused, so move the focus
211
+ // to the first/last tabbable element inside the focus trap
212
+ if (tabbable.length > 0) {
213
+ var _lastKeydown$current, _lastKeydown$current2;
214
+ var isShiftTab = Boolean(((_lastKeydown$current = lastKeydown.current) == null ? void 0 : _lastKeydown$current.shiftKey) && ((_lastKeydown$current2 = lastKeydown.current) == null ? void 0 : _lastKeydown$current2.key) === 'Tab');
215
+ var focusNext = tabbable[0];
216
+ var focusPrevious = tabbable[tabbable.length - 1];
217
+ if (typeof focusNext !== 'string' && typeof focusPrevious !== 'string') {
218
+ if (isShiftTab) {
219
+ focusPrevious.focus();
220
+ } else {
221
+ focusNext.focus();
222
+ }
223
+ }
224
+ // no tabbable elements in the trap focus or the focus was outside of the focus trap
225
+ } else {
226
+ rootElement.focus();
227
+ }
228
+ };
229
+ doc.addEventListener('focusin', contain);
230
+ doc.addEventListener('keydown', loopFocus, true);
231
+
232
+ // With Edge, Safari and Firefox, no focus related events are fired when the focused area stops being a focused area.
233
+ // for example https://bugzilla.mozilla.org/show_bug.cgi?id=559561.
234
+ // Instead, we can look if the active element was restored on the BODY element.
235
+ //
236
+ // The whatwg spec defines how the browser should behave but does not explicitly mention any events:
237
+ // https://html.spec.whatwg.org/multipage/interaction.html#focus-fixup-rule.
238
+ var interval = setInterval(function () {
239
+ if (doc.activeElement && doc.activeElement.tagName === 'BODY') {
240
+ contain();
241
+ }
242
+ }, 50);
243
+ return function () {
244
+ clearInterval(interval);
245
+ doc.removeEventListener('focusin', contain);
246
+ doc.removeEventListener('keydown', loopFocus, true);
247
+ };
248
+ }, [disableAutoFocus, disableEnforceFocus, disableRestoreFocus, isEnabled, open, getTabbable]);
249
+ var onFocus = function onFocus(event) {
250
+ if (nodeToRestore.current === null) {
251
+ nodeToRestore.current = event.relatedTarget;
252
+ }
253
+ activated.current = true;
254
+ reactFocusEventTarget.current = event.target;
255
+ var childrenPropsHandler = children.props.onFocus;
256
+ if (childrenPropsHandler) {
257
+ childrenPropsHandler(event);
258
+ }
259
+ };
260
+ var handleFocusSentinel = function handleFocusSentinel(event) {
261
+ if (nodeToRestore.current === null) {
262
+ nodeToRestore.current = event.relatedTarget;
263
+ }
264
+ activated.current = true;
265
+ };
266
+ return /*#__PURE__*/_jsxs(React.Fragment, {
267
+ children: [/*#__PURE__*/_jsx("div", {
268
+ tabIndex: open ? 0 : -1,
269
+ onFocus: handleFocusSentinel,
270
+ ref: sentinelStart,
271
+ "data-testid": "sentinelStart"
272
+ }), /*#__PURE__*/React.cloneElement(children, {
273
+ ref: handleRef,
274
+ onFocus: onFocus
275
+ }), /*#__PURE__*/_jsx("div", {
276
+ tabIndex: open ? 0 : -1,
277
+ onFocus: handleFocusSentinel,
278
+ ref: sentinelEnd,
279
+ "data-testid": "sentinelEnd"
280
+ })]
281
+ });
282
+ }
283
+ process.env.NODE_ENV !== "production" ? FocusTrap.propTypes /* remove-proptypes */ = {
284
+ // ┌────────────────────────────── Warning ──────────────────────────────┐
285
+ // │ These PropTypes are generated from the TypeScript type definitions. │
286
+ // │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
287
+ // └─────────────────────────────────────────────────────────────────────┘
288
+ /**
289
+ * A single child content element.
290
+ */
291
+ children: elementAcceptingRef,
292
+ /**
293
+ * If `true`, the focus trap will not automatically shift focus to itself when it opens, and
294
+ * replace it to the last focused element when it closes.
295
+ * This also works correctly with any focus trap children that have the `disableAutoFocus` prop.
296
+ *
297
+ * Generally this should never be set to `true` as it makes the focus trap less
298
+ * accessible to assistive technologies, like screen readers.
299
+ * @default false
300
+ */
301
+ disableAutoFocus: PropTypes.bool,
302
+ /**
303
+ * If `true`, the focus trap will not prevent focus from leaving the focus trap while open.
304
+ *
305
+ * Generally this should never be set to `true` as it makes the focus trap less
306
+ * accessible to assistive technologies, like screen readers.
307
+ * @default false
308
+ */
309
+ disableEnforceFocus: PropTypes.bool,
310
+ /**
311
+ * If `true`, the focus trap will not restore focus to previously focused element once
312
+ * focus trap is hidden or unmounted.
313
+ * @default false
314
+ */
315
+ disableRestoreFocus: PropTypes.bool,
316
+ /**
317
+ * Returns an array of ordered tabbable nodes (i.e. in tab order) within the root.
318
+ * For instance, you can provide the "tabbable" npm dependency.
319
+ * @param {HTMLElement} root
320
+ */
321
+ getTabbable: PropTypes.func,
322
+ /**
323
+ * This prop extends the `open` prop.
324
+ * It allows to toggle the open state without having to wait for a rerender when changing the `open` prop.
325
+ * This prop should be memoized.
326
+ * It can be used to support multiple focus trap mounted at the same time.
327
+ * @default function defaultIsEnabled(): boolean {
328
+ * return true;
329
+ * }
330
+ */
331
+ isEnabled: PropTypes.func,
332
+ /**
333
+ * If `true`, focus is locked.
334
+ */
335
+ open: PropTypes.bool.isRequired
336
+ } : void 0;
337
+ if (process.env.NODE_ENV !== 'production') {
338
+ // eslint-disable-next-line
339
+ FocusTrap['propTypes' + ''] = exactProp(FocusTrap.propTypes);
340
+ }
341
+ export default FocusTrap;
@@ -0,0 +1 @@
1
+ export {};
@@ -1 +1 @@
1
- export { FocusTrap as default } from '@mui/base/FocusTrap';
1
+ export { default } from './FocusTrap';
package/legacy/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @mui/material v5.16.1
2
+ * @mui/material v5.16.3
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';