@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.
- 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 +48 -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 +8 -8
- 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
package/Popover/Popover.js
CHANGED
|
@@ -3,13 +3,13 @@
|
|
|
3
3
|
import * as React from 'react';
|
|
4
4
|
import PropTypes from 'prop-types';
|
|
5
5
|
import clsx from 'clsx';
|
|
6
|
-
import { isHostComponent } from '@mui/base/utils';
|
|
7
6
|
import composeClasses from '@mui/utils/composeClasses';
|
|
8
7
|
import HTMLElementType from '@mui/utils/HTMLElementType';
|
|
9
8
|
import refType from '@mui/utils/refType';
|
|
10
9
|
import elementTypeAcceptingRef from '@mui/utils/elementTypeAcceptingRef';
|
|
11
10
|
import integerPropType from '@mui/utils/integerPropType';
|
|
12
11
|
import chainPropTypes from '@mui/utils/chainPropTypes';
|
|
12
|
+
import isHostComponent from '../utils/isHostComponent';
|
|
13
13
|
import { styled } from '../zero-styled';
|
|
14
14
|
import { useDefaultProps } from '../DefaultPropsProvider';
|
|
15
15
|
import debounce from '../utils/debounce';
|
|
@@ -0,0 +1,370 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import { chainPropTypes, HTMLElementType, refType, unstable_ownerDocument as ownerDocument, unstable_useEnhancedEffect as useEnhancedEffect, unstable_useForkRef as useForkRef } from '@mui/utils';
|
|
5
|
+
import { createPopper } from '@popperjs/core';
|
|
6
|
+
import PropTypes from 'prop-types';
|
|
7
|
+
import composeClasses from '@mui/utils/composeClasses';
|
|
8
|
+
import useSlotProps from '@mui/utils/useSlotProps';
|
|
9
|
+
import Portal from '../Portal';
|
|
10
|
+
import { getPopperUtilityClass } from './popperClasses';
|
|
11
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
12
|
+
function flipPlacement(placement, direction) {
|
|
13
|
+
if (direction === 'ltr') {
|
|
14
|
+
return placement;
|
|
15
|
+
}
|
|
16
|
+
switch (placement) {
|
|
17
|
+
case 'bottom-end':
|
|
18
|
+
return 'bottom-start';
|
|
19
|
+
case 'bottom-start':
|
|
20
|
+
return 'bottom-end';
|
|
21
|
+
case 'top-end':
|
|
22
|
+
return 'top-start';
|
|
23
|
+
case 'top-start':
|
|
24
|
+
return 'top-end';
|
|
25
|
+
default:
|
|
26
|
+
return placement;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
function resolveAnchorEl(anchorEl) {
|
|
30
|
+
return typeof anchorEl === 'function' ? anchorEl() : anchorEl;
|
|
31
|
+
}
|
|
32
|
+
function isHTMLElement(element) {
|
|
33
|
+
return element.nodeType !== undefined;
|
|
34
|
+
}
|
|
35
|
+
function isVirtualElement(element) {
|
|
36
|
+
return !isHTMLElement(element);
|
|
37
|
+
}
|
|
38
|
+
const useUtilityClasses = ownerState => {
|
|
39
|
+
const {
|
|
40
|
+
classes
|
|
41
|
+
} = ownerState;
|
|
42
|
+
const slots = {
|
|
43
|
+
root: ['root']
|
|
44
|
+
};
|
|
45
|
+
return composeClasses(slots, getPopperUtilityClass, classes);
|
|
46
|
+
};
|
|
47
|
+
const defaultPopperOptions = {};
|
|
48
|
+
const PopperTooltip = /*#__PURE__*/React.forwardRef(function PopperTooltip(props, forwardedRef) {
|
|
49
|
+
const {
|
|
50
|
+
anchorEl,
|
|
51
|
+
children,
|
|
52
|
+
direction,
|
|
53
|
+
disablePortal,
|
|
54
|
+
modifiers,
|
|
55
|
+
open,
|
|
56
|
+
placement: initialPlacement,
|
|
57
|
+
popperOptions,
|
|
58
|
+
popperRef: popperRefProp,
|
|
59
|
+
slotProps = {},
|
|
60
|
+
slots = {},
|
|
61
|
+
TransitionProps,
|
|
62
|
+
// @ts-ignore internal logic
|
|
63
|
+
ownerState: ownerStateProp,
|
|
64
|
+
// prevent from spreading to DOM, it can come from the parent component e.g. Select.
|
|
65
|
+
...other
|
|
66
|
+
} = props;
|
|
67
|
+
const tooltipRef = React.useRef(null);
|
|
68
|
+
const ownRef = useForkRef(tooltipRef, forwardedRef);
|
|
69
|
+
const popperRef = React.useRef(null);
|
|
70
|
+
const handlePopperRef = useForkRef(popperRef, popperRefProp);
|
|
71
|
+
const handlePopperRefRef = React.useRef(handlePopperRef);
|
|
72
|
+
useEnhancedEffect(() => {
|
|
73
|
+
handlePopperRefRef.current = handlePopperRef;
|
|
74
|
+
}, [handlePopperRef]);
|
|
75
|
+
React.useImperativeHandle(popperRefProp, () => popperRef.current, []);
|
|
76
|
+
const rtlPlacement = flipPlacement(initialPlacement, direction);
|
|
77
|
+
/**
|
|
78
|
+
* placement initialized from prop but can change during lifetime if modifiers.flip.
|
|
79
|
+
* modifiers.flip is essentially a flip for controlled/uncontrolled behavior
|
|
80
|
+
*/
|
|
81
|
+
const [placement, setPlacement] = React.useState(rtlPlacement);
|
|
82
|
+
const [resolvedAnchorElement, setResolvedAnchorElement] = React.useState(resolveAnchorEl(anchorEl));
|
|
83
|
+
React.useEffect(() => {
|
|
84
|
+
if (popperRef.current) {
|
|
85
|
+
popperRef.current.forceUpdate();
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
React.useEffect(() => {
|
|
89
|
+
if (anchorEl) {
|
|
90
|
+
setResolvedAnchorElement(resolveAnchorEl(anchorEl));
|
|
91
|
+
}
|
|
92
|
+
}, [anchorEl]);
|
|
93
|
+
useEnhancedEffect(() => {
|
|
94
|
+
if (!resolvedAnchorElement || !open) {
|
|
95
|
+
return undefined;
|
|
96
|
+
}
|
|
97
|
+
const handlePopperUpdate = data => {
|
|
98
|
+
setPlacement(data.placement);
|
|
99
|
+
};
|
|
100
|
+
if (process.env.NODE_ENV !== 'production') {
|
|
101
|
+
if (resolvedAnchorElement && isHTMLElement(resolvedAnchorElement) && resolvedAnchorElement.nodeType === 1) {
|
|
102
|
+
const box = resolvedAnchorElement.getBoundingClientRect();
|
|
103
|
+
if (process.env.NODE_ENV !== 'test' && box.top === 0 && box.left === 0 && box.right === 0 && box.bottom === 0) {
|
|
104
|
+
console.warn(['MUI: The `anchorEl` prop provided to the component is invalid.', 'The anchor element should be part of the document layout.', "Make sure the element is present in the document or that it's not display none."].join('\n'));
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
let popperModifiers = [{
|
|
109
|
+
name: 'preventOverflow',
|
|
110
|
+
options: {
|
|
111
|
+
altBoundary: disablePortal
|
|
112
|
+
}
|
|
113
|
+
}, {
|
|
114
|
+
name: 'flip',
|
|
115
|
+
options: {
|
|
116
|
+
altBoundary: disablePortal
|
|
117
|
+
}
|
|
118
|
+
}, {
|
|
119
|
+
name: 'onUpdate',
|
|
120
|
+
enabled: true,
|
|
121
|
+
phase: 'afterWrite',
|
|
122
|
+
fn: ({
|
|
123
|
+
state
|
|
124
|
+
}) => {
|
|
125
|
+
handlePopperUpdate(state);
|
|
126
|
+
}
|
|
127
|
+
}];
|
|
128
|
+
if (modifiers != null) {
|
|
129
|
+
popperModifiers = popperModifiers.concat(modifiers);
|
|
130
|
+
}
|
|
131
|
+
if (popperOptions && popperOptions.modifiers != null) {
|
|
132
|
+
popperModifiers = popperModifiers.concat(popperOptions.modifiers);
|
|
133
|
+
}
|
|
134
|
+
const popper = createPopper(resolvedAnchorElement, tooltipRef.current, {
|
|
135
|
+
placement: rtlPlacement,
|
|
136
|
+
...popperOptions,
|
|
137
|
+
modifiers: popperModifiers
|
|
138
|
+
});
|
|
139
|
+
handlePopperRefRef.current(popper);
|
|
140
|
+
return () => {
|
|
141
|
+
popper.destroy();
|
|
142
|
+
handlePopperRefRef.current(null);
|
|
143
|
+
};
|
|
144
|
+
}, [resolvedAnchorElement, disablePortal, modifiers, open, popperOptions, rtlPlacement]);
|
|
145
|
+
const childProps = {
|
|
146
|
+
placement: placement
|
|
147
|
+
};
|
|
148
|
+
if (TransitionProps !== null) {
|
|
149
|
+
childProps.TransitionProps = TransitionProps;
|
|
150
|
+
}
|
|
151
|
+
const classes = useUtilityClasses(props);
|
|
152
|
+
const Root = slots.root ?? 'div';
|
|
153
|
+
const rootProps = useSlotProps({
|
|
154
|
+
elementType: Root,
|
|
155
|
+
externalSlotProps: slotProps.root,
|
|
156
|
+
externalForwardedProps: other,
|
|
157
|
+
additionalProps: {
|
|
158
|
+
role: 'tooltip',
|
|
159
|
+
ref: ownRef
|
|
160
|
+
},
|
|
161
|
+
ownerState: props,
|
|
162
|
+
className: classes.root
|
|
163
|
+
});
|
|
164
|
+
return /*#__PURE__*/_jsx(Root, {
|
|
165
|
+
...rootProps,
|
|
166
|
+
children: typeof children === 'function' ? children(childProps) : children
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* @ignore - internal component.
|
|
172
|
+
*/
|
|
173
|
+
const Popper = /*#__PURE__*/React.forwardRef(function Popper(props, forwardedRef) {
|
|
174
|
+
const {
|
|
175
|
+
anchorEl,
|
|
176
|
+
children,
|
|
177
|
+
container: containerProp,
|
|
178
|
+
direction = 'ltr',
|
|
179
|
+
disablePortal = false,
|
|
180
|
+
keepMounted = false,
|
|
181
|
+
modifiers,
|
|
182
|
+
open,
|
|
183
|
+
placement = 'bottom',
|
|
184
|
+
popperOptions = defaultPopperOptions,
|
|
185
|
+
popperRef,
|
|
186
|
+
style,
|
|
187
|
+
transition = false,
|
|
188
|
+
slotProps = {},
|
|
189
|
+
slots = {},
|
|
190
|
+
...other
|
|
191
|
+
} = props;
|
|
192
|
+
const [exited, setExited] = React.useState(true);
|
|
193
|
+
const handleEnter = () => {
|
|
194
|
+
setExited(false);
|
|
195
|
+
};
|
|
196
|
+
const handleExited = () => {
|
|
197
|
+
setExited(true);
|
|
198
|
+
};
|
|
199
|
+
if (!keepMounted && !open && (!transition || exited)) {
|
|
200
|
+
return null;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
// If the container prop is provided, use that
|
|
204
|
+
// If the anchorEl prop is provided, use its parent body element as the container
|
|
205
|
+
// If neither are provided let the Modal take care of choosing the container
|
|
206
|
+
let container;
|
|
207
|
+
if (containerProp) {
|
|
208
|
+
container = containerProp;
|
|
209
|
+
} else if (anchorEl) {
|
|
210
|
+
const resolvedAnchorEl = resolveAnchorEl(anchorEl);
|
|
211
|
+
container = resolvedAnchorEl && isHTMLElement(resolvedAnchorEl) ? ownerDocument(resolvedAnchorEl).body : ownerDocument(null).body;
|
|
212
|
+
}
|
|
213
|
+
const display = !open && keepMounted && (!transition || exited) ? 'none' : undefined;
|
|
214
|
+
const transitionProps = transition ? {
|
|
215
|
+
in: open,
|
|
216
|
+
onEnter: handleEnter,
|
|
217
|
+
onExited: handleExited
|
|
218
|
+
} : undefined;
|
|
219
|
+
return /*#__PURE__*/_jsx(Portal, {
|
|
220
|
+
disablePortal: disablePortal,
|
|
221
|
+
container: container,
|
|
222
|
+
children: /*#__PURE__*/_jsx(PopperTooltip, {
|
|
223
|
+
anchorEl: anchorEl,
|
|
224
|
+
direction: direction,
|
|
225
|
+
disablePortal: disablePortal,
|
|
226
|
+
modifiers: modifiers,
|
|
227
|
+
ref: forwardedRef,
|
|
228
|
+
open: transition ? !exited : open,
|
|
229
|
+
placement: placement,
|
|
230
|
+
popperOptions: popperOptions,
|
|
231
|
+
popperRef: popperRef,
|
|
232
|
+
slotProps: slotProps,
|
|
233
|
+
slots: slots,
|
|
234
|
+
...other,
|
|
235
|
+
style: {
|
|
236
|
+
// Prevents scroll issue, waiting for Popper.js to add this style once initiated.
|
|
237
|
+
position: 'fixed',
|
|
238
|
+
// Fix Popper.js display issue
|
|
239
|
+
top: 0,
|
|
240
|
+
left: 0,
|
|
241
|
+
display,
|
|
242
|
+
...style
|
|
243
|
+
},
|
|
244
|
+
TransitionProps: transitionProps,
|
|
245
|
+
children: children
|
|
246
|
+
})
|
|
247
|
+
});
|
|
248
|
+
});
|
|
249
|
+
process.env.NODE_ENV !== "production" ? Popper.propTypes /* remove-proptypes */ = {
|
|
250
|
+
// ┌────────────────────────────── Warning ──────────────────────────────┐
|
|
251
|
+
// │ These PropTypes are generated from the TypeScript type definitions. │
|
|
252
|
+
// │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
|
|
253
|
+
// └─────────────────────────────────────────────────────────────────────┘
|
|
254
|
+
/**
|
|
255
|
+
* An HTML element, [virtualElement](https://popper.js.org/docs/v2/virtual-elements/),
|
|
256
|
+
* or a function that returns either.
|
|
257
|
+
* It's used to set the position of the popper.
|
|
258
|
+
* The return value will passed as the reference object of the Popper instance.
|
|
259
|
+
*/
|
|
260
|
+
anchorEl: chainPropTypes(PropTypes.oneOfType([HTMLElementType, PropTypes.object, PropTypes.func]), props => {
|
|
261
|
+
if (props.open) {
|
|
262
|
+
const resolvedAnchorEl = resolveAnchorEl(props.anchorEl);
|
|
263
|
+
if (resolvedAnchorEl && isHTMLElement(resolvedAnchorEl) && resolvedAnchorEl.nodeType === 1) {
|
|
264
|
+
const box = resolvedAnchorEl.getBoundingClientRect();
|
|
265
|
+
if (process.env.NODE_ENV !== 'test' && box.top === 0 && box.left === 0 && box.right === 0 && box.bottom === 0) {
|
|
266
|
+
return new Error(['MUI: The `anchorEl` prop provided to the component is invalid.', 'The anchor element should be part of the document layout.', "Make sure the element is present in the document or that it's not display none."].join('\n'));
|
|
267
|
+
}
|
|
268
|
+
} else if (!resolvedAnchorEl || typeof resolvedAnchorEl.getBoundingClientRect !== 'function' || isVirtualElement(resolvedAnchorEl) && resolvedAnchorEl.contextElement != null && resolvedAnchorEl.contextElement.nodeType !== 1) {
|
|
269
|
+
return new Error(['MUI: The `anchorEl` prop provided to the component is invalid.', 'It should be an HTML element instance or a virtualElement ', '(https://popper.js.org/docs/v2/virtual-elements/).'].join('\n'));
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
return null;
|
|
273
|
+
}),
|
|
274
|
+
/**
|
|
275
|
+
* Popper render function or node.
|
|
276
|
+
*/
|
|
277
|
+
children: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([PropTypes.node, PropTypes.func]),
|
|
278
|
+
/**
|
|
279
|
+
* An HTML element or function that returns one.
|
|
280
|
+
* The `container` will have the portal children appended to it.
|
|
281
|
+
*
|
|
282
|
+
* You can also provide a callback, which is called in a React layout effect.
|
|
283
|
+
* This lets you set the container from a ref, and also makes server-side rendering possible.
|
|
284
|
+
*
|
|
285
|
+
* By default, it uses the body of the top-level document object,
|
|
286
|
+
* so it's simply `document.body` most of the time.
|
|
287
|
+
*/
|
|
288
|
+
container: PropTypes /* @typescript-to-proptypes-ignore */.oneOfType([HTMLElementType, PropTypes.func]),
|
|
289
|
+
/**
|
|
290
|
+
* Direction of the text.
|
|
291
|
+
* @default 'ltr'
|
|
292
|
+
*/
|
|
293
|
+
direction: PropTypes.oneOf(['ltr', 'rtl']),
|
|
294
|
+
/**
|
|
295
|
+
* The `children` will be under the DOM hierarchy of the parent component.
|
|
296
|
+
* @default false
|
|
297
|
+
*/
|
|
298
|
+
disablePortal: PropTypes.bool,
|
|
299
|
+
/**
|
|
300
|
+
* Always keep the children in the DOM.
|
|
301
|
+
* This prop can be useful in SEO situation or
|
|
302
|
+
* when you want to maximize the responsiveness of the Popper.
|
|
303
|
+
* @default false
|
|
304
|
+
*/
|
|
305
|
+
keepMounted: PropTypes.bool,
|
|
306
|
+
/**
|
|
307
|
+
* Popper.js is based on a "plugin-like" architecture,
|
|
308
|
+
* most of its features are fully encapsulated "modifiers".
|
|
309
|
+
*
|
|
310
|
+
* A modifier is a function that is called each time Popper.js needs to
|
|
311
|
+
* compute the position of the popper.
|
|
312
|
+
* For this reason, modifiers should be very performant to avoid bottlenecks.
|
|
313
|
+
* To learn how to create a modifier, [read the modifiers documentation](https://popper.js.org/docs/v2/modifiers/).
|
|
314
|
+
*/
|
|
315
|
+
modifiers: PropTypes.arrayOf(PropTypes.shape({
|
|
316
|
+
data: PropTypes.object,
|
|
317
|
+
effect: PropTypes.func,
|
|
318
|
+
enabled: PropTypes.bool,
|
|
319
|
+
fn: PropTypes.func,
|
|
320
|
+
name: PropTypes.any,
|
|
321
|
+
options: PropTypes.object,
|
|
322
|
+
phase: PropTypes.oneOf(['afterMain', 'afterRead', 'afterWrite', 'beforeMain', 'beforeRead', 'beforeWrite', 'main', 'read', 'write']),
|
|
323
|
+
requires: PropTypes.arrayOf(PropTypes.string),
|
|
324
|
+
requiresIfExists: PropTypes.arrayOf(PropTypes.string)
|
|
325
|
+
})),
|
|
326
|
+
/**
|
|
327
|
+
* If `true`, the component is shown.
|
|
328
|
+
*/
|
|
329
|
+
open: PropTypes.bool.isRequired,
|
|
330
|
+
/**
|
|
331
|
+
* Popper placement.
|
|
332
|
+
* @default 'bottom'
|
|
333
|
+
*/
|
|
334
|
+
placement: PropTypes.oneOf(['auto-end', 'auto-start', 'auto', 'bottom-end', 'bottom-start', 'bottom', 'left-end', 'left-start', 'left', 'right-end', 'right-start', 'right', 'top-end', 'top-start', 'top']),
|
|
335
|
+
/**
|
|
336
|
+
* Options provided to the [`Popper.js`](https://popper.js.org/docs/v2/constructors/#options) instance.
|
|
337
|
+
* @default {}
|
|
338
|
+
*/
|
|
339
|
+
popperOptions: PropTypes.shape({
|
|
340
|
+
modifiers: PropTypes.array,
|
|
341
|
+
onFirstUpdate: PropTypes.func,
|
|
342
|
+
placement: PropTypes.oneOf(['auto-end', 'auto-start', 'auto', 'bottom-end', 'bottom-start', 'bottom', 'left-end', 'left-start', 'left', 'right-end', 'right-start', 'right', 'top-end', 'top-start', 'top']),
|
|
343
|
+
strategy: PropTypes.oneOf(['absolute', 'fixed'])
|
|
344
|
+
}),
|
|
345
|
+
/**
|
|
346
|
+
* A ref that points to the used popper instance.
|
|
347
|
+
*/
|
|
348
|
+
popperRef: refType,
|
|
349
|
+
/**
|
|
350
|
+
* The props used for each slot inside the Popper.
|
|
351
|
+
* @default {}
|
|
352
|
+
*/
|
|
353
|
+
slotProps: PropTypes.shape({
|
|
354
|
+
root: PropTypes.oneOfType([PropTypes.func, PropTypes.object])
|
|
355
|
+
}),
|
|
356
|
+
/**
|
|
357
|
+
* The components used for each slot inside the Popper.
|
|
358
|
+
* Either a string to use a HTML element or a component.
|
|
359
|
+
* @default {}
|
|
360
|
+
*/
|
|
361
|
+
slots: PropTypes.shape({
|
|
362
|
+
root: PropTypes.elementType
|
|
363
|
+
}),
|
|
364
|
+
/**
|
|
365
|
+
* Help supporting a react-transition-group/Transition component.
|
|
366
|
+
* @default false
|
|
367
|
+
*/
|
|
368
|
+
transition: PropTypes.bool
|
|
369
|
+
} : void 0;
|
|
370
|
+
export default Popper;
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { Instance, Options, OptionsGeneric, VirtualElement } from '@popperjs/core';
|
|
3
|
+
import { PortalProps } from '../Portal';
|
|
4
|
+
import { SlotComponentProps } from '../utils/types';
|
|
5
|
+
import { PolymorphicProps } from '../utils/PolymorphicComponent';
|
|
6
|
+
export type PopperPlacementType = Options['placement'];
|
|
7
|
+
export interface PopperRootSlotPropsOverrides {
|
|
8
|
+
}
|
|
9
|
+
export interface PopperTransitionProps {
|
|
10
|
+
in: boolean;
|
|
11
|
+
onEnter: () => void;
|
|
12
|
+
onExited: () => void;
|
|
13
|
+
}
|
|
14
|
+
export interface PopperChildrenProps {
|
|
15
|
+
placement: PopperPlacementType;
|
|
16
|
+
TransitionProps?: PopperTransitionProps;
|
|
17
|
+
}
|
|
18
|
+
export interface PopperOwnProps {
|
|
19
|
+
/**
|
|
20
|
+
* An HTML element, [virtualElement](https://popper.js.org/docs/v2/virtual-elements/),
|
|
21
|
+
* or a function that returns either.
|
|
22
|
+
* It's used to set the position of the popper.
|
|
23
|
+
* The return value will passed as the reference object of the Popper instance.
|
|
24
|
+
*/
|
|
25
|
+
anchorEl?: null | VirtualElement | HTMLElement | (() => HTMLElement) | (() => VirtualElement);
|
|
26
|
+
/**
|
|
27
|
+
* Popper render function or node.
|
|
28
|
+
*/
|
|
29
|
+
children?: React.ReactNode | ((props: PopperChildrenProps) => React.ReactNode);
|
|
30
|
+
/**
|
|
31
|
+
* An HTML element or function that returns one.
|
|
32
|
+
* The `container` will have the portal children appended to it.
|
|
33
|
+
*
|
|
34
|
+
* You can also provide a callback, which is called in a React layout effect.
|
|
35
|
+
* This lets you set the container from a ref, and also makes server-side rendering possible.
|
|
36
|
+
*
|
|
37
|
+
* By default, it uses the body of the top-level document object,
|
|
38
|
+
* so it's simply `document.body` most of the time.
|
|
39
|
+
*/
|
|
40
|
+
container?: PortalProps['container'];
|
|
41
|
+
/**
|
|
42
|
+
* Direction of the text.
|
|
43
|
+
* @default 'ltr'
|
|
44
|
+
*/
|
|
45
|
+
direction?: 'ltr' | 'rtl';
|
|
46
|
+
/**
|
|
47
|
+
* The `children` will be under the DOM hierarchy of the parent component.
|
|
48
|
+
* @default false
|
|
49
|
+
*/
|
|
50
|
+
disablePortal?: PortalProps['disablePortal'];
|
|
51
|
+
/**
|
|
52
|
+
* Always keep the children in the DOM.
|
|
53
|
+
* This prop can be useful in SEO situation or
|
|
54
|
+
* when you want to maximize the responsiveness of the Popper.
|
|
55
|
+
* @default false
|
|
56
|
+
*/
|
|
57
|
+
keepMounted?: boolean;
|
|
58
|
+
/**
|
|
59
|
+
* Popper.js is based on a "plugin-like" architecture,
|
|
60
|
+
* most of its features are fully encapsulated "modifiers".
|
|
61
|
+
*
|
|
62
|
+
* A modifier is a function that is called each time Popper.js needs to
|
|
63
|
+
* compute the position of the popper.
|
|
64
|
+
* For this reason, modifiers should be very performant to avoid bottlenecks.
|
|
65
|
+
* To learn how to create a modifier, [read the modifiers documentation](https://popper.js.org/docs/v2/modifiers/).
|
|
66
|
+
*/
|
|
67
|
+
modifiers?: Options['modifiers'];
|
|
68
|
+
/**
|
|
69
|
+
* If `true`, the component is shown.
|
|
70
|
+
*/
|
|
71
|
+
open: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Popper placement.
|
|
74
|
+
* @default 'bottom'
|
|
75
|
+
*/
|
|
76
|
+
placement?: PopperPlacementType;
|
|
77
|
+
/**
|
|
78
|
+
* Options provided to the [`Popper.js`](https://popper.js.org/docs/v2/constructors/#options) instance.
|
|
79
|
+
* @default {}
|
|
80
|
+
*/
|
|
81
|
+
popperOptions?: Partial<OptionsGeneric<any>>;
|
|
82
|
+
/**
|
|
83
|
+
* A ref that points to the used popper instance.
|
|
84
|
+
*/
|
|
85
|
+
popperRef?: React.Ref<Instance>;
|
|
86
|
+
/**
|
|
87
|
+
* The props used for each slot inside the Popper.
|
|
88
|
+
* @default {}
|
|
89
|
+
*/
|
|
90
|
+
slotProps?: {
|
|
91
|
+
root?: SlotComponentProps<'div', PopperRootSlotPropsOverrides, PopperOwnerState>;
|
|
92
|
+
};
|
|
93
|
+
/**
|
|
94
|
+
* The components used for each slot inside the Popper.
|
|
95
|
+
* Either a string to use a HTML element or a component.
|
|
96
|
+
* @default {}
|
|
97
|
+
*/
|
|
98
|
+
slots?: PopperSlots;
|
|
99
|
+
/**
|
|
100
|
+
* Help supporting a react-transition-group/Transition component.
|
|
101
|
+
* @default false
|
|
102
|
+
*/
|
|
103
|
+
transition?: boolean;
|
|
104
|
+
}
|
|
105
|
+
export interface PopperSlots {
|
|
106
|
+
/**
|
|
107
|
+
* The component that renders the root.
|
|
108
|
+
* @default 'div'
|
|
109
|
+
*/
|
|
110
|
+
root?: React.ElementType;
|
|
111
|
+
}
|
|
112
|
+
export type PopperOwnerState = PopperOwnProps;
|
|
113
|
+
export interface PopperTypeMap<AdditionalProps = {}, RootComponentType extends React.ElementType = 'div'> {
|
|
114
|
+
props: PopperOwnProps & AdditionalProps;
|
|
115
|
+
defaultComponent: RootComponentType;
|
|
116
|
+
}
|
|
117
|
+
export type PopperProps<RootComponentType extends React.ElementType = PopperTypeMap['defaultComponent']> = PolymorphicProps<PopperTypeMap<{}, RootComponentType>, RootComponentType>;
|
|
118
|
+
export type PopperTooltipOwnProps = Omit<PopperOwnProps, 'container' | 'keepMounted' | 'transition'> & {
|
|
119
|
+
TransitionProps?: PopperTransitionProps;
|
|
120
|
+
};
|
|
121
|
+
export interface PopperTooltipTypeMap<AdditionalProps = {}, RootComponentType extends React.ElementType = 'div'> {
|
|
122
|
+
props: PopperTooltipOwnProps & AdditionalProps;
|
|
123
|
+
defaultComponent: RootComponentType;
|
|
124
|
+
}
|
|
125
|
+
export type PopperTooltipProps<RootComponentType extends React.ElementType = PopperTooltipTypeMap['defaultComponent']> = PolymorphicProps<PopperTooltipTypeMap<{}, RootComponentType>, RootComponentType>;
|
|
126
|
+
export interface PopperRootSlotProps {
|
|
127
|
+
className?: string;
|
|
128
|
+
ref: React.Ref<any>;
|
|
129
|
+
ownerState: PopperOwnerState;
|
|
130
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/Popper/Popper.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { PopperProps as BasePopperProps } from '@mui/base/Popper';
|
|
2
1
|
import { SxProps } from '@mui/system';
|
|
3
2
|
import * as React from 'react';
|
|
3
|
+
import { PopperProps as BasePopperProps } from './BasePopper.types';
|
|
4
4
|
import { Theme } from '../styles';
|
|
5
5
|
export interface PopperProps extends Omit<BasePopperProps, 'direction'> {
|
|
6
6
|
/**
|
package/Popper/Popper.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import { Popper as BasePopper } from '@mui/base/Popper';
|
|
4
3
|
import { useRtl } from '@mui/system/RtlProvider';
|
|
5
4
|
import refType from '@mui/utils/refType';
|
|
6
5
|
import HTMLElementType from '@mui/utils/HTMLElementType';
|
|
7
6
|
import PropTypes from 'prop-types';
|
|
8
7
|
import * as React from 'react';
|
|
8
|
+
import BasePopper from './BasePopper';
|
|
9
9
|
import { styled } from '../zero-styled';
|
|
10
10
|
import { useDefaultProps } from '../DefaultPropsProvider';
|
|
11
11
|
import { jsx as _jsx } from "react/jsx-runtime";
|
package/Popper/index.d.ts
CHANGED
package/Popper/index.js
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface PopperClasses {
|
|
2
|
+
/** Class name applied to the root element. */
|
|
3
|
+
root: string;
|
|
4
|
+
}
|
|
5
|
+
export type PopperClassKey = keyof PopperClasses;
|
|
6
|
+
export declare function getPopperUtilityClass(slot: string): string;
|
|
7
|
+
declare const popperClasses: PopperClasses;
|
|
8
|
+
export default popperClasses;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import generateUtilityClasses from '@mui/utils/generateUtilityClasses';
|
|
2
|
+
import generateUtilityClass from '@mui/utils/generateUtilityClass';
|
|
3
|
+
export function getPopperUtilityClass(slot) {
|
|
4
|
+
return generateUtilityClass('MuiPopper', slot);
|
|
5
|
+
}
|
|
6
|
+
const popperClasses = generateUtilityClasses('MuiPopper', ['root']);
|
|
7
|
+
export default popperClasses;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { PortalProps } from './Portal.types';
|
|
3
|
+
/**
|
|
4
|
+
* Portals provide a first-class way to render children into a DOM node
|
|
5
|
+
* that exists outside the DOM hierarchy of the parent component.
|
|
6
|
+
*
|
|
7
|
+
* Demos:
|
|
8
|
+
*
|
|
9
|
+
* - [Portal](https://next.mui.com/material-ui/react-portal/)
|
|
10
|
+
*
|
|
11
|
+
* API:
|
|
12
|
+
*
|
|
13
|
+
* - [Portal API](https://next.mui.com/material-ui/api/portal/)
|
|
14
|
+
*/
|
|
15
|
+
declare const Portal: React.ForwardRefExoticComponent<PortalProps & React.RefAttributes<Element>>;
|
|
16
|
+
export default Portal;
|