UNPKG

8.5 kBJavaScriptView Raw
1"use strict";
2'use client';
3
4var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard").default;
5var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
6Object.defineProperty(exports, "__esModule", {
7 value: true
8});
9exports.default = void 0;
10var _RtlProvider = require("@mui/system/RtlProvider");
11var _refType = _interopRequireDefault(require("@mui/utils/refType"));
12var _HTMLElementType = _interopRequireDefault(require("@mui/utils/HTMLElementType"));
13var _propTypes = _interopRequireDefault(require("prop-types"));
14var React = _interopRequireWildcard(require("react"));
15var _BasePopper = _interopRequireDefault(require("./BasePopper"));
16var _zeroStyled = require("../zero-styled");
17var _DefaultPropsProvider = require("../DefaultPropsProvider");
18var _jsxRuntime = require("react/jsx-runtime");
19const PopperRoot = (0, _zeroStyled.styled)(_BasePopper.default, {
20 name: 'MuiPopper',
21 slot: 'Root',
22 overridesResolver: (props, styles) => styles.root
23})({});
24
25/**
26 *
27 * Demos:
28 *
29 * - [Autocomplete](https://mui.com/material-ui/react-autocomplete/)
30 * - [Menu](https://mui.com/material-ui/react-menu/)
31 * - [Popper](https://mui.com/material-ui/react-popper/)
32 *
33 * API:
34 *
35 * - [Popper API](https://mui.com/material-ui/api/popper/)
36 */
37const Popper = /*#__PURE__*/React.forwardRef(function Popper(inProps, ref) {
38 const isRtl = (0, _RtlProvider.useRtl)();
39 const props = (0, _DefaultPropsProvider.useDefaultProps)({
40 props: inProps,
41 name: 'MuiPopper'
42 });
43 const {
44 anchorEl,
45 component,
46 components,
47 componentsProps,
48 container,
49 disablePortal,
50 keepMounted,
51 modifiers,
52 open,
53 placement,
54 popperOptions,
55 popperRef,
56 transition,
57 slots,
58 slotProps,
59 ...other
60 } = props;
61 const RootComponent = slots?.root ?? components?.Root;
62 const otherProps = {
63 anchorEl,
64 container,
65 disablePortal,
66 keepMounted,
67 modifiers,
68 open,
69 placement,
70 popperOptions,
71 popperRef,
72 transition,
73 ...other
74 };
75 return /*#__PURE__*/(0, _jsxRuntime.jsx)(PopperRoot, {
76 as: component,
77 direction: isRtl ? 'rtl' : 'ltr',
78 slots: {
79 root: RootComponent
80 },
81 slotProps: slotProps ?? componentsProps,
82 ...otherProps,
83 ref: ref
84 });
85});
86process.env.NODE_ENV !== "production" ? Popper.propTypes /* remove-proptypes */ = {
87 // ┌────────────────────────────── Warning ──────────────────────────────┐
88 // │ These PropTypes are generated from the TypeScript type definitions. │
89 // │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
90 // └─────────────────────────────────────────────────────────────────────┘
91 /**
92 * An HTML element, [virtualElement](https://popper.js.org/docs/v2/virtual-elements/),
93 * or a function that returns either.
94 * It's used to set the position of the popper.
95 * The return value will passed as the reference object of the Popper instance.
96 */
97 anchorEl: _propTypes.default /* @typescript-to-proptypes-ignore */.oneOfType([_HTMLElementType.default, _propTypes.default.object, _propTypes.default.func]),
98 /**
99 * Popper render function or node.
100 */
101 children: _propTypes.default /* @typescript-to-proptypes-ignore */.oneOfType([_propTypes.default.node, _propTypes.default.func]),
102 /**
103 * The component used for the root node.
104 * Either a string to use a HTML element or a component.
105 */
106 component: _propTypes.default.elementType,
107 /**
108 * The components used for each slot inside the Popper.
109 * Either a string to use a HTML element or a component.
110 *
111 * @deprecated use the `slots` prop instead. This prop will be removed in v7. [How to migrate](/material-ui/migration/migrating-from-deprecated-apis/).
112 * @default {}
113 */
114 components: _propTypes.default.shape({
115 Root: _propTypes.default.elementType
116 }),
117 /**
118 * The props used for each slot inside the Popper.
119 *
120 * @deprecated use the `slotProps` prop instead. This prop will be removed in v7. [How to migrate](/material-ui/migration/migrating-from-deprecated-apis/).
121 * @default {}
122 */
123 componentsProps: _propTypes.default.shape({
124 root: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object])
125 }),
126 /**
127 * An HTML element or function that returns one.
128 * The `container` will have the portal children appended to it.
129 *
130 * You can also provide a callback, which is called in a React layout effect.
131 * This lets you set the container from a ref, and also makes server-side rendering possible.
132 *
133 * By default, it uses the body of the top-level document object,
134 * so it's simply `document.body` most of the time.
135 */
136 container: _propTypes.default /* @typescript-to-proptypes-ignore */.oneOfType([_HTMLElementType.default, _propTypes.default.func]),
137 /**
138 * The `children` will be under the DOM hierarchy of the parent component.
139 * @default false
140 */
141 disablePortal: _propTypes.default.bool,
142 /**
143 * Always keep the children in the DOM.
144 * This prop can be useful in SEO situation or
145 * when you want to maximize the responsiveness of the Popper.
146 * @default false
147 */
148 keepMounted: _propTypes.default.bool,
149 /**
150 * Popper.js is based on a "plugin-like" architecture,
151 * most of its features are fully encapsulated "modifiers".
152 *
153 * A modifier is a function that is called each time Popper.js needs to
154 * compute the position of the popper.
155 * For this reason, modifiers should be very performant to avoid bottlenecks.
156 * To learn how to create a modifier, [read the modifiers documentation](https://popper.js.org/docs/v2/modifiers/).
157 */
158 modifiers: _propTypes.default.arrayOf(_propTypes.default.shape({
159 data: _propTypes.default.object,
160 effect: _propTypes.default.func,
161 enabled: _propTypes.default.bool,
162 fn: _propTypes.default.func,
163 name: _propTypes.default.any,
164 options: _propTypes.default.object,
165 phase: _propTypes.default.oneOf(['afterMain', 'afterRead', 'afterWrite', 'beforeMain', 'beforeRead', 'beforeWrite', 'main', 'read', 'write']),
166 requires: _propTypes.default.arrayOf(_propTypes.default.string),
167 requiresIfExists: _propTypes.default.arrayOf(_propTypes.default.string)
168 })),
169 /**
170 * If `true`, the component is shown.
171 */
172 open: _propTypes.default.bool.isRequired,
173 /**
174 * Popper placement.
175 * @default 'bottom'
176 */
177 placement: _propTypes.default.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']),
178 /**
179 * Options provided to the [`Popper.js`](https://popper.js.org/docs/v2/constructors/#options) instance.
180 * @default {}
181 */
182 popperOptions: _propTypes.default.shape({
183 modifiers: _propTypes.default.array,
184 onFirstUpdate: _propTypes.default.func,
185 placement: _propTypes.default.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']),
186 strategy: _propTypes.default.oneOf(['absolute', 'fixed'])
187 }),
188 /**
189 * A ref that points to the used popper instance.
190 */
191 popperRef: _refType.default,
192 /**
193 * The props used for each slot inside the Popper.
194 * @default {}
195 */
196 slotProps: _propTypes.default.shape({
197 root: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object])
198 }),
199 /**
200 * The components used for each slot inside the Popper.
201 * Either a string to use a HTML element or a component.
202 * @default {}
203 */
204 slots: _propTypes.default.shape({
205 root: _propTypes.default.elementType
206 }),
207 /**
208 * The system prop that allows defining system overrides as well as additional CSS styles.
209 */
210 sx: _propTypes.default.oneOfType([_propTypes.default.arrayOf(_propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object, _propTypes.default.bool])), _propTypes.default.func, _propTypes.default.object]),
211 /**
212 * Help supporting a react-transition-group/Transition component.
213 * @default false
214 */
215 transition: _propTypes.default.bool
216} : void 0;
217var _default = exports.default = Popper;
\No newline at end of file