UNPKG

@crossed/ui

Version:

A universal & performant styling library for React Native, Next.js & React

86 lines (85 loc) 3.29 kB
var __defProp = Object.defineProperty; var __getOwnPropDesc = Object.getOwnPropertyDescriptor; var __getOwnPropNames = Object.getOwnPropertyNames; var __hasOwnProp = Object.prototype.hasOwnProperty; var __export = (target, all) => { for (var name in all) __defProp(target, name, { get: all[name], enumerable: true }); }; var __copyProps = (to, from, except, desc) => { if (from && typeof from === "object" || typeof from === "function") { for (let key of __getOwnPropNames(from)) if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable }); } return to; }; var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); var DropDownMenu_exports = {}; __export(DropDownMenu_exports, { DropDownMenu: () => DropDownMenu }); module.exports = __toCommonJS(DropDownMenu_exports); var import_jsx_runtime = require("react/jsx-runtime"); var import_core = require("@crossed/core"); var import_overlay = require("../overlay"); var import_react = require("react"); var import_MenuList = require("./MenuList"); var import_Divider = require("../layout/Divider"); var import_useMedia = require("../useMedia"); const DropDownRoot = (0, import_react.memo)( ({ children, placement = "bottom-end", triggerStrategy = "onPress", ...props }) => { return /* @__PURE__ */ (0, import_jsx_runtime.jsx)( import_overlay.Popover, { placement, triggerStrategy, ...props, children } ); } ); const DropDowmMenuTrigger = ({ ...props }) => { return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_overlay.Popover.Trigger, { ...props }); }; const DropDownMenuContent = ({ children, style }) => { const { md } = (0, import_useMedia.useMedia)(); return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_overlay.Popover.Content, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_MenuList.MenuList, { style, bordered: md, children }) }); }; const DropDownMenuItem = ({ children, onPress, ...props }) => { const { onClose } = (0, import_overlay.useFloatingContext)(); return /* @__PURE__ */ (0, import_jsx_runtime.jsx)( import_MenuList.MenuList.Item, { ...props, onPress: (0, import_core.composeEventHandlers)(onPress, onClose), children } ); }; const DropDownMenuItemLabel = ({ children, ...props }) => { return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_MenuList.MenuList.Label, { ...props, children }); }; const DropDownMenuItemTitle = ({ children, ...props }) => { return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_MenuList.MenuList.Title, { ...props, children }); }; const DropDownMenuDivider = (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Divider.Divider, { ...props }); const DropDownMenu = (0, import_core.withStaticProperties)(DropDownRoot, { Trigger: DropDowmMenuTrigger, Content: DropDownMenuContent, Item: DropDownMenuItem, Label: DropDownMenuItemLabel, Title: DropDownMenuItemTitle, Divider: DropDownMenuDivider }); // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { DropDownMenu }); //# sourceMappingURL=DropDownMenu.js.map