UNPKG

@mui/material

Version:

React components that implement Google's Material Design.

191 lines (189 loc) 8.67 kB
"use strict"; var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault"); Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends")); var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose")); var _PopperUnstyled = _interopRequireDefault(require("@mui/base/PopperUnstyled")); var _system = require("@mui/system"); var _utils = require("@mui/utils"); var _propTypes = _interopRequireDefault(require("prop-types")); var React = _interopRequireWildcard(require("react")); var _styles = require("../styles"); var _jsxRuntime = require("react/jsx-runtime"); const _excluded = ["components", "componentsProps", "slots", "slotProps"]; function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); } function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; } const PopperRoot = (0, _styles.styled)(_PopperUnstyled.default, { name: 'MuiPopper', slot: 'Root', overridesResolver: (props, styles) => styles.root })({}); /** * * Demos: * * - [Autocomplete](https://mui.com/material-ui/react-autocomplete/) * - [Menu](https://mui.com/material-ui/react-menu/) * - [Popper](https://mui.com/material-ui/react-popper/) * * API: * * - [Popper API](https://mui.com/material-ui/api/popper/) */ const Popper = /*#__PURE__*/React.forwardRef(function Popper(inProps, ref) { var _slots$root; const theme = (0, _system.useThemeWithoutDefault)(); const props = (0, _styles.useThemeProps)({ props: inProps, name: 'MuiPopper' }); const { components, componentsProps, slots, slotProps } = props, other = (0, _objectWithoutPropertiesLoose2.default)(props, _excluded); const RootComponent = (_slots$root = slots == null ? void 0 : slots.root) != null ? _slots$root : components == null ? void 0 : components.Root; return /*#__PURE__*/(0, _jsxRuntime.jsx)(PopperRoot, (0, _extends2.default)({ direction: theme == null ? void 0 : theme.direction, slots: { root: RootComponent }, slotProps: slotProps != null ? slotProps : componentsProps }, other, { ref: ref })); }); process.env.NODE_ENV !== "production" ? Popper.propTypes /* remove-proptypes */ = { // ----------------------------- Warning -------------------------------- // | These PropTypes are generated from the TypeScript type definitions | // | To update them edit TypeScript types and run "yarn proptypes" | // ---------------------------------------------------------------------- /** * An HTML element, [virtualElement](https://popper.js.org/docs/v2/virtual-elements/), * or a function that returns either. * It's used to set the position of the popper. * The return value will passed as the reference object of the Popper instance. */ anchorEl: _propTypes.default /* @typescript-to-proptypes-ignore */.oneOfType([_utils.HTMLElementType, _propTypes.default.object, _propTypes.default.func]), /** * Popper render function or node. */ children: _propTypes.default /* @typescript-to-proptypes-ignore */.oneOfType([_propTypes.default.node, _propTypes.default.func]), /** * @ignore */ component: _propTypes.default /* @typescript-to-proptypes-ignore */.elementType, /** * The components used for each slot inside the Popper. * Either a string to use a HTML element or a component. * @default {} */ components: _propTypes.default.shape({ Root: _propTypes.default.elementType }), /** * The props used for each slot inside the Popper. * @default {} */ componentsProps: _propTypes.default.shape({ root: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object]) }), /** * An HTML element or function that returns one. * The `container` will have the portal children appended to it. * * By default, it uses the body of the top-level document object, * so it's simply `document.body` most of the time. */ container: _propTypes.default /* @typescript-to-proptypes-ignore */.oneOfType([_utils.HTMLElementType, _propTypes.default.func]), /** * The `children` will be under the DOM hierarchy of the parent component. * @default false */ disablePortal: _propTypes.default.bool, /** * Always keep the children in the DOM. * This prop can be useful in SEO situation or * when you want to maximize the responsiveness of the Popper. * @default false */ keepMounted: _propTypes.default.bool, /** * Popper.js is based on a "plugin-like" architecture, * most of its features are fully encapsulated "modifiers". * * A modifier is a function that is called each time Popper.js needs to * compute the position of the popper. * For this reason, modifiers should be very performant to avoid bottlenecks. * To learn how to create a modifier, [read the modifiers documentation](https://popper.js.org/docs/v2/modifiers/). */ modifiers: _propTypes.default.arrayOf(_propTypes.default.shape({ data: _propTypes.default.object, effect: _propTypes.default.func, enabled: _propTypes.default.bool, fn: _propTypes.default.func, name: _propTypes.default.any, options: _propTypes.default.object, phase: _propTypes.default.oneOf(['afterMain', 'afterRead', 'afterWrite', 'beforeMain', 'beforeRead', 'beforeWrite', 'main', 'read', 'write']), requires: _propTypes.default.arrayOf(_propTypes.default.string), requiresIfExists: _propTypes.default.arrayOf(_propTypes.default.string) })), /** * If `true`, the component is shown. */ open: _propTypes.default.bool.isRequired, /** * @ignore */ ownerState: _propTypes.default.any, /** * Popper placement. * @default 'bottom' */ 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']), /** * Options provided to the [`Popper.js`](https://popper.js.org/docs/v2/constructors/#options) instance. * @default {} */ popperOptions: _propTypes.default.shape({ modifiers: _propTypes.default.array, onFirstUpdate: _propTypes.default.func, 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']), strategy: _propTypes.default.oneOf(['absolute', 'fixed']) }), /** * A ref that points to the used popper instance. */ popperRef: _utils.refType, /** * The props used for each slot inside the Popper. * @default {} */ slotProps: _propTypes.default.shape({ root: _propTypes.default.oneOfType([_propTypes.default.func, _propTypes.default.object]) }), /** * The components used for each slot inside the Popper. * Either a string to use a HTML element or a component. * @default {} */ slots: _propTypes.default.shape({ root: _propTypes.default.elementType }), /** * The system prop that allows defining system overrides as well as additional CSS styles. */ 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]), /** * Help supporting a react-transition-group/Transition component. * @default false */ transition: _propTypes.default.bool } : void 0; var _default = Popper; exports.default = _default;