@mui/material 6.0.0-beta.0 → 6.0.0-beta.1
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.
- package/Autocomplete/Autocomplete.d.ts +6 -7
- package/Autocomplete/Autocomplete.js +1 -1
- package/Badge/Badge.d.ts +1 -1
- package/Badge/Badge.js +2 -2
- package/Badge/useBadge.d.ts +13 -0
- package/Badge/useBadge.js +41 -0
- package/Badge/useBadge.types.d.ts +40 -0
- package/Badge/useBadge.types.js +1 -0
- package/Breadcrumbs/Breadcrumbs.d.ts +1 -1
- package/Breadcrumbs/Breadcrumbs.js +1 -1
- package/CHANGELOG.md +32 -0
- package/ClickAwayListener/ClickAwayListener.d.ts +47 -0
- package/ClickAwayListener/ClickAwayListener.js +178 -0
- package/ClickAwayListener/index.d.ts +2 -2
- package/ClickAwayListener/index.js +1 -1
- package/InputBase/InputBase.js +2 -2
- package/ListItem/ListItem.js +1 -1
- package/Menu/Menu.js +1 -1
- package/Modal/Modal.d.ts +1 -1
- package/Modal/Modal.js +1 -1
- package/Modal/ModalManager.d.ts +25 -0
- package/Modal/ModalManager.js +211 -0
- package/Modal/index.d.ts +1 -1
- package/Modal/index.js +1 -1
- package/Modal/useModal.d.ts +13 -0
- package/Modal/useModal.js +195 -0
- package/Modal/useModal.types.d.ts +115 -0
- package/Modal/useModal.types.js +1 -0
- package/NoSsr/NoSsr.d.ts +25 -0
- package/NoSsr/NoSsr.js +73 -0
- package/NoSsr/NoSsr.types.d.ts +18 -0
- package/NoSsr/NoSsr.types.js +1 -0
- package/NoSsr/index.d.ts +3 -2
- package/NoSsr/index.js +1 -1
- package/Popover/Popover.js +1 -1
- package/Popper/BasePopper.d.ts +7 -0
- package/Popper/BasePopper.js +370 -0
- package/Popper/BasePopper.types.d.ts +130 -0
- package/Popper/BasePopper.types.js +1 -0
- package/Popper/Popper.d.ts +1 -1
- package/Popper/Popper.js +1 -1
- package/Popper/index.d.ts +2 -1
- package/Popper/index.js +2 -1
- package/Popper/popperClasses.d.ts +8 -0
- package/Popper/popperClasses.js +7 -0
- package/Portal/Portal.d.ts +16 -0
- package/Portal/Portal.js +92 -0
- package/Portal/Portal.types.d.ts +23 -0
- package/Portal/Portal.types.js +1 -0
- package/Portal/index.d.ts +3 -2
- package/Portal/index.js +1 -1
- package/Slider/Slider.d.ts +2 -2
- package/Slider/Slider.js +3 -2
- package/Slider/useSlider.d.ts +14 -0
- package/Slider/useSlider.js +647 -0
- package/Slider/useSlider.types.d.ts +228 -0
- package/Slider/useSlider.types.js +1 -0
- package/Snackbar/Snackbar.d.ts +1 -1
- package/Snackbar/Snackbar.js +3 -3
- package/Snackbar/useSnackbar.d.ts +14 -0
- package/Snackbar/useSnackbar.js +133 -0
- package/Snackbar/useSnackbar.types.d.ts +60 -0
- package/Snackbar/useSnackbar.types.js +1 -0
- package/SwipeableDrawer/SwipeableDrawer.js +1 -1
- package/TabScrollButton/TabScrollButton.d.ts +1 -1
- package/TabScrollButton/TabScrollButton.js +1 -1
- package/TablePagination/TablePagination.js +1 -1
- package/Tabs/Tabs.d.ts +1 -1
- package/Tabs/Tabs.js +1 -1
- package/TextareaAutosize/TextareaAutosize.d.ts +14 -0
- package/TextareaAutosize/TextareaAutosize.js +222 -0
- package/TextareaAutosize/TextareaAutosize.types.d.ts +13 -0
- package/TextareaAutosize/TextareaAutosize.types.js +1 -0
- package/TextareaAutosize/index.d.ts +3 -2
- package/TextareaAutosize/index.js +1 -1
- package/Tooltip/Tooltip.js +1 -1
- package/Unstable_TrapFocus/FocusTrap.d.ts +10 -0
- package/Unstable_TrapFocus/FocusTrap.js +330 -0
- package/Unstable_TrapFocus/FocusTrap.types.d.ts +51 -0
- package/Unstable_TrapFocus/FocusTrap.types.js +1 -0
- package/Unstable_TrapFocus/index.d.ts +2 -2
- package/Unstable_TrapFocus/index.js +1 -1
- package/index.d.ts +1 -1
- package/index.js +2 -2
- package/modern/Autocomplete/Autocomplete.js +1 -1
- package/modern/Badge/Badge.js +2 -2
- package/modern/Badge/useBadge.js +41 -0
- package/modern/Badge/useBadge.types.js +1 -0
- package/modern/Breadcrumbs/Breadcrumbs.js +1 -1
- package/modern/ClickAwayListener/ClickAwayListener.js +178 -0
- package/modern/ClickAwayListener/index.js +1 -1
- package/modern/InputBase/InputBase.js +2 -2
- package/modern/ListItem/ListItem.js +1 -1
- package/modern/Menu/Menu.js +1 -1
- package/modern/Modal/Modal.js +1 -1
- package/modern/Modal/ModalManager.js +211 -0
- package/modern/Modal/index.js +1 -1
- package/modern/Modal/useModal.js +195 -0
- package/modern/Modal/useModal.types.js +1 -0
- package/modern/NoSsr/NoSsr.js +73 -0
- package/modern/NoSsr/NoSsr.types.js +1 -0
- package/modern/NoSsr/index.js +1 -1
- package/modern/Popover/Popover.js +1 -1
- package/modern/Popper/BasePopper.js +370 -0
- package/modern/Popper/BasePopper.types.js +1 -0
- package/modern/Popper/Popper.js +1 -1
- package/modern/Popper/index.js +2 -1
- package/modern/Popper/popperClasses.js +7 -0
- package/modern/Portal/Portal.js +92 -0
- package/modern/Portal/Portal.types.js +1 -0
- package/modern/Portal/index.js +1 -1
- package/modern/Slider/Slider.js +3 -2
- package/modern/Slider/useSlider.js +647 -0
- package/modern/Slider/useSlider.types.js +1 -0
- package/modern/Snackbar/Snackbar.js +3 -3
- package/modern/Snackbar/useSnackbar.js +133 -0
- package/modern/Snackbar/useSnackbar.types.js +1 -0
- package/modern/SwipeableDrawer/SwipeableDrawer.js +1 -1
- package/modern/TabScrollButton/TabScrollButton.js +1 -1
- package/modern/TablePagination/TablePagination.js +1 -1
- package/modern/Tabs/Tabs.js +1 -1
- package/modern/TextareaAutosize/TextareaAutosize.js +222 -0
- package/modern/TextareaAutosize/TextareaAutosize.types.js +1 -0
- package/modern/TextareaAutosize/index.js +1 -1
- package/modern/Tooltip/Tooltip.js +1 -1
- package/modern/Unstable_TrapFocus/FocusTrap.js +330 -0
- package/modern/Unstable_TrapFocus/FocusTrap.types.js +1 -0
- package/modern/Unstable_TrapFocus/index.js +1 -1
- package/modern/index.js +2 -2
- package/modern/useAutocomplete/useAutocomplete.js +976 -2
- package/modern/utils/PolymorphicComponent.js +1 -0
- package/modern/utils/areArraysEqual.js +4 -0
- package/modern/utils/index.js +1 -1
- package/modern/utils/isHostComponent.js +7 -0
- package/modern/utils/omitEventHandlers.js +18 -0
- package/modern/utils/shouldSpreadAdditionalProps.js +1 -1
- package/modern/utils/useSlot.js +3 -1
- package/node/Autocomplete/Autocomplete.js +3 -3
- package/node/Badge/Badge.js +5 -5
- package/node/Badge/useBadge.js +46 -0
- package/node/Badge/useBadge.types.js +5 -0
- package/node/Breadcrumbs/Breadcrumbs.js +2 -2
- package/node/ClickAwayListener/ClickAwayListener.js +184 -0
- package/node/ClickAwayListener/index.js +1 -1
- package/node/InputBase/InputBase.js +7 -7
- package/node/ListItem/ListItem.js +3 -3
- package/node/Menu/Menu.js +3 -3
- package/node/Modal/Modal.js +2 -2
- package/node/Modal/ModalManager.js +219 -0
- package/node/Modal/index.js +2 -2
- package/node/Modal/useModal.js +205 -0
- package/node/Modal/useModal.types.js +5 -0
- package/node/NoSsr/NoSsr.js +81 -0
- package/node/NoSsr/NoSsr.types.js +5 -0
- package/node/NoSsr/index.js +3 -2
- package/node/Popover/Popover.js +2 -2
- package/node/Popper/BasePopper.js +379 -0
- package/node/Popper/BasePopper.types.js +5 -0
- package/node/Popper/Popper.js +2 -2
- package/node/Popper/index.js +14 -1
- package/node/Popper/popperClasses.js +15 -0
- package/node/Portal/Portal.js +100 -0
- package/node/Portal/Portal.types.js +5 -0
- package/node/Portal/index.js +3 -2
- package/node/Slider/Slider.js +14 -13
- package/node/Slider/useSlider.js +670 -0
- package/node/Slider/useSlider.types.js +5 -0
- package/node/Snackbar/Snackbar.js +6 -6
- package/node/Snackbar/useSnackbar.js +141 -0
- package/node/Snackbar/useSnackbar.types.js +5 -0
- package/node/SwipeableDrawer/SwipeableDrawer.js +2 -2
- package/node/TabScrollButton/TabScrollButton.js +3 -3
- package/node/TablePagination/TablePagination.js +2 -2
- package/node/Tabs/Tabs.js +3 -3
- package/node/TextareaAutosize/TextareaAutosize.js +230 -0
- package/node/TextareaAutosize/TextareaAutosize.types.js +5 -0
- package/node/TextareaAutosize/index.js +3 -2
- package/node/Tooltip/Tooltip.js +5 -5
- package/node/Unstable_TrapFocus/FocusTrap.js +339 -0
- package/node/Unstable_TrapFocus/FocusTrap.types.js +5 -0
- package/node/Unstable_TrapFocus/index.js +3 -2
- package/node/index.js +3 -3
- package/node/useAutocomplete/useAutocomplete.js +985 -18
- package/node/utils/PolymorphicComponent.js +5 -0
- package/node/utils/areArraysEqual.js +10 -0
- package/node/utils/index.js +2 -2
- package/node/utils/isHostComponent.js +13 -0
- package/node/utils/omitEventHandlers.js +24 -0
- package/node/utils/shouldSpreadAdditionalProps.js +3 -2
- package/node/utils/useSlot.js +6 -4
- package/package.json +6 -7
- package/styles/overrides.d.ts +1 -1
- package/useAutocomplete/useAutocomplete.d.ts +468 -2
- package/useAutocomplete/useAutocomplete.js +976 -2
- package/utils/PolymorphicComponent.d.ts +17 -0
- package/utils/PolymorphicComponent.js +1 -0
- package/utils/areArraysEqual.d.ts +3 -0
- package/utils/areArraysEqual.js +4 -0
- package/utils/index.d.ts +2 -1
- package/utils/index.js +1 -1
- package/utils/isHostComponent.d.ts +6 -0
- package/utils/isHostComponent.js +7 -0
- package/utils/omitEventHandlers.d.ts +9 -0
- package/utils/omitEventHandlers.js +18 -0
- package/utils/shouldSpreadAdditionalProps.js +1 -1
- package/utils/types.d.ts +2 -1
- 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;
|
package/node/Modal/index.js
CHANGED
|
@@ -12,7 +12,7 @@ var _exportNames = {
|
|
|
12
12
|
Object.defineProperty(exports, "ModalManager", {
|
|
13
13
|
enumerable: true,
|
|
14
14
|
get: function () {
|
|
15
|
-
return
|
|
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
|
|
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,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;
|
package/node/NoSsr/index.js
CHANGED
|
@@ -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.
|
|
10
|
+
return _NoSsr.default;
|
|
10
11
|
}
|
|
11
12
|
});
|
|
12
|
-
var _NoSsr = require("
|
|
13
|
+
var _NoSsr = _interopRequireDefault(require("./NoSsr"));
|
package/node/Popover/Popover.js
CHANGED
|
@@ -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,
|
|
352
|
+
...(!(0, _isHostComponent.default)(RootSlot) && {
|
|
353
353
|
slotProps: rootSlotPropsProp,
|
|
354
354
|
disableScrollLock
|
|
355
355
|
}),
|