UNPKG

@frontify/fondue

Version:
41 lines (40 loc) 1.34 kB
import { jsx as t } from "react/jsx-runtime"; import { useMenu as I } from "@react-aria/menu"; import { useTreeState as M } from "@react-stately/tree"; import { useRef as b } from "react"; import { AriaList as R } from "./Aria/AriaList.es.js"; import { AriaMenuItem as g } from "./Aria/AriaMenuItem.es.js"; import { AriaSection as h } from "./Aria/AriaSection.es.js"; import { getMenuItems as k, getKeyItemRecord as K, mapToAriaProps as L, getDisabledItemIds as P } from "./Aria/helper.es.js"; const x = ({ menuBlocks: r, ariaLabel: a = "Action Menu", focus: c, border: p = !0, scrollable: u = !1, onClick: l }) => { const n = k(r), d = K(n), i = L(a, r), e = M({ ...i, selectionMode: "none", disabledKeys: P(n) }), s = b(null), { menuProps: f } = I({ ...i, autoFocus: c }, e, s); return /* @__PURE__ */ t(R, { ariaProps: { ...f }, ref: s, border: p, scrollable: u, children: [...e.collection].map((m) => { const { key: y, "aria-label": A } = m; return /* @__PURE__ */ t(h, { ariaLabel: A, children: [...m.childNodes].map((o) => /* @__PURE__ */ t( g, { menuItem: d[o.key], state: e, node: o, onClick: l }, o.key )) }, y); }) }); }; x.displayName = "FondueActionMenu"; export { x as ActionMenu }; //# sourceMappingURL=ActionMenu.es.js.map