UNPKG

@crossed/ui

Version:

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

157 lines (156 loc) 4.96 kB
"use client"; 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 MenuList_exports = {}; __export(MenuList_exports, { MenuDivider: () => MenuDivider, MenuItem: () => MenuItem, MenuLabel: () => MenuLabel, MenuList: () => MenuList, MenuTitle: () => MenuTitle }); module.exports = __toCommonJS(MenuList_exports); var import_jsx_runtime = require("react/jsx-runtime"); var import_styled = require("@crossed/styled"); var import_Text = require("../typography/Text"); var import_YBox = require("../layout/YBox"); var import_Divider = require("../layout/Divider"); var import_core = require("@crossed/core"); var import_react = require("react"); var import_react_native = require("react-native"); const rootStyle = (0, import_styled.createStyles)(({ colors, space }) => ({ default: { base: { backgroundColor: colors.background.secondary, borderRadius: 12 } }, border: { base: { borderWidth: 1, borderColor: colors.border.primary } }, padded: { base: { padding: space.xs } } })); const itemStyles = (0, import_styled.createStyles)((t) => ({ padding: { base: { paddingTop: t.space.xs, paddingBottom: t.space.xs, paddingLeft: t.space.md, paddingRight: t.space.md } }, item: { "base": { display: "flex", flexDirection: "column", // alignItems: 'center', paddingHorizontal: t.space.md, justifyContent: "center", // height: 42, borderWidth: 0, borderRadius: 12 }, ":hover": { backgroundColor: t.colors.background.hover }, ":active": { backgroundColor: t.colors.background.active }, "web": { base: { transition: "all 170ms ease" }, ":focus-visible": { outlineColor: t.colors.border.brand } } } })); const MenuRoot = (0, import_react.memo)( (0, import_react.forwardRef)( ({ padded = true, bordered = true, ...props }, ref) => { return /* @__PURE__ */ (0, import_jsx_runtime.jsx)( import_YBox.YBox, { role: "list", alignItems: "stretch", space: padded ? "xxs" : void 0, ...props, style: (0, import_styled.composeStyles)( rootStyle.default, bordered && rootStyle.border, padded && rootStyle.padded, props.style ), ref } ); } ) ); MenuRoot.displayName = "MenuList"; const MenuDivider = (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Divider.Divider, { ...props }); MenuDivider.displayName = "MenuList.Divider"; const MenuItem = (0, import_styled.withReactive)( (0, import_react.forwardRef)( ({ asChild, style, children, ...props }, ref) => { const styleCallback = (0, import_react.useCallback)( ({ pressed }) => (0, import_styled.composeStyles)(itemStyles.item, itemStyles.padding, style).rnw({ active: pressed }).style, [style] ); return asChild && (0, import_react.isValidElement)(children) ? (0, import_react.cloneElement)(children, { style: styleCallback, role: "listitem" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_react_native.Pressable, { role: "listitem", ...props, style: styleCallback, ref, children }); } ) ); MenuItem.displayName = "MenuList.Item"; const MenuLabel = ({ style, ...props }) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)( import_Text.Text, { ...props, style: (0, import_styled.composeStyles)( itemStyles.padding, (0, import_styled.inlineStyle)(() => ({ base: { marginTop: 0 } })), style ) } ); MenuLabel.displayName = "MenuList.Label"; const MenuTitle = (props) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_Text.Text, { color: "secondary", ...props }); MenuTitle.displayName = "MenuList.Title"; const MenuList = (0, import_core.withStaticProperties)(MenuRoot, { Divider: MenuDivider, Item: MenuItem, Label: MenuLabel, Title: MenuTitle }); MenuList.displayName = "MenuList"; // Annotate the CommonJS export names for ESM import in node: 0 && (module.exports = { MenuDivider, MenuItem, MenuLabel, MenuList, MenuTitle }); //# sourceMappingURL=MenuList.js.map