UNPKG

@payfit/unity-components

Version:

76 lines (75 loc) • 3.13 kB
import { Icon as e } from "../../icon/Icon.js"; import { useMenuContext as t } from "../Menu.context.js"; import { forwardRef as n } from "react"; import { uyTv as r } from "@payfit/unity-themes"; import { Fragment as i, jsx as a, jsxs as o } from "react/jsx-runtime"; import { MenuItem as s } from "react-aria-components/Menu"; //#region src/core/components/menu/parts/RawMenuItem.tsx var c = r({ base: [ "uy:cursor-pointer uy:group", "uy:flex uy:items-center uy:px-150 uy:py-125 uy:sm:py-100 uy:gap-100 uy:rounded-50 uy:typography-body uy:text-content-neutral", "uy:data-[open=true]:bg-surface-neutral-active", "uy:not-aria-disabled:data-[hovered=true]:bg-surface-neutral-hover", "uy:not-aria-disabled:data-[pressed=true]:bg-surface-neutral-pressed", "uy:active:bg-surface-neutral-active", "uy:data-[focused=true]:not-data-[focus-visible=true]:outline-0 uy:data-[focus-visible=true]:outline-2 uy:data-[focus-visible=true]:outline-offset-2 uy:data-[focus-visible=true]:outline-utility-focus-ring", "uy:aria-disabled:text-content-neutral-disabled uy:aria-disabled:cursor-not-allowed" ], variants: { compact: { true: "uy:px-100 uy:py-100 uy:sm:py-50", false: "" } }, defaultVariants: { compact: !1 } }), l = n(function({ prefix: n, children: r, id: l, textValue: u, isTruncated: d = !1, href: f, target: p, rel: m, onAction: h, className: g, isDisabled: _, suffix: v, ...y }, b) { let { compact: x } = t(), S = d ? u : void 0; return /* @__PURE__ */ a(s, { ref: b, id: l, textValue: u, href: f, target: p, rel: m, isDisabled: _, onAction: h, className: c({ compact: x, className: g }), ...y, children: (t) => /* @__PURE__ */ o(i, { children: [ n != null && /* @__PURE__ */ a("div", { "data-unity-slot": "MenuItem.prefix", className: "uy:flex uy:size-300 uy:shrink-0 uy:items-center uy:justify-center uy:text-content-neutral-low uy:group-aria-disabled:text-content-neutral-disabled", children: n }), /* @__PURE__ */ a("div", { "data-unity-slot": "MenuItem.content", className: "uy:min-w-0 uy:min-h-300 uy:flex-1 uy:typography-body", title: S, children: typeof r == "function" ? r(t) : typeof r == "string" ? /* @__PURE__ */ a("span", { className: d ? "uy:block uy:truncate" : "uy:block", children: r }) : r }), v != null && v !== !1 && /* @__PURE__ */ a("div", { "data-unity-slot": "MenuItem.suffix", className: "uy:flex uy:shrink-0 uy:items-center uy:justify-center uy:text-content-neutral-low uy:group-aria-disabled:text-content-neutral-disabled", children: v }), t.hasSubmenu && /* @__PURE__ */ a("div", { "data-unity-slot": "MenuItem.disclosure", className: "uy:flex uy:shrink-0 uy:items-center uy:justify-center uy:text-content-neutral-low uy:group-aria-disabled:text-content-neutral-disabled", children: /* @__PURE__ */ a(e, { src: "CaretRightOutlined", role: "presentation", size: 20, color: t.isDisabled ? "content.neutral.disabled" : "content.neutral.low" }) }) ] }) }); }); l.displayName = "RawMenuItem"; //#endregion export { l as RawMenuItem };