UNPKG

2.02 kBJavaScriptView Raw
1'use client';
2
3import * as React from 'react';
4import PropTypes from 'prop-types';
5import { exactProp } from '@mui/utils';
6import { DropdownContext } from '../useDropdown/DropdownContext';
7import { useDropdown } from '../useDropdown/useDropdown';
8/**
9 *
10 * Demos:
11 *
12 * - [Menu](https://mui.com/base-ui/react-menu/)
13 *
14 * API:
15 *
16 * - [Dropdown API](https://mui.com/base-ui/react-menu/components-api/#dropdown)
17 */
18import { jsx as _jsx } from "react/jsx-runtime";
19function Dropdown(props) {
20 const {
21 children,
22 open,
23 defaultOpen,
24 onOpenChange
25 } = props;
26 const {
27 contextValue
28 } = useDropdown({
29 defaultOpen,
30 onOpenChange,
31 open
32 });
33 return /*#__PURE__*/_jsx(DropdownContext.Provider, {
34 value: contextValue,
35 children: children
36 });
37}
38process.env.NODE_ENV !== "production" ? Dropdown.propTypes /* remove-proptypes */ = {
39 // ┌────────────────────────────── Warning ──────────────────────────────┐
40 // │ These PropTypes are generated from the TypeScript type definitions. │
41 // │ To update them, edit the TypeScript types and run `pnpm proptypes`. │
42 // └─────────────────────────────────────────────────────────────────────┘
43 /**
44 * @ignore
45 */
46 children: PropTypes.node,
47 /**
48 * If `true`, the dropdown is initially open.
49 */
50 defaultOpen: PropTypes.bool,
51 /**
52 * Callback fired when the component requests to be opened or closed.
53 */
54 onOpenChange: PropTypes.func,
55 /**
56 * Allows to control whether the dropdown is open.
57 * This is a controlled counterpart of `defaultOpen`.
58 */
59 open: PropTypes.bool
60} : void 0;
61if (process.env.NODE_ENV !== 'production') {
62 // eslint-disable-next-line
63 Dropdown['propTypes' + ''] = exactProp(Dropdown.propTypes);
64}
65export { Dropdown };
\No newline at end of file