UNPKG

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