UNPKG

@frontify/fondue

Version:
43 lines (42 loc) 1.74 kB
import { jsxs as f, jsx as t } from "react/jsx-runtime"; import { useFocusRing as p } from "@react-aria/focus"; import { useState as c, useRef as w } from "react"; import d from "../../foundation/Icon/Generated/IconDotsHorizontal.es.js"; import { FOCUS_VISIBLE_STYLE as b } from "../../utilities/focusStyle.es.js"; import { merge as v } from "../../utilities/merge.es.js"; import { Menu as g } from "../Menu/Menu.es.js"; import { MenuItem as h } from "../MenuItem/MenuItem.es.js"; const x = ({ items: s, "data-test-id": i = "overflow-menu" }) => { const [o, n] = c(!1), r = w(null), { isFocusVisible: l, focusProps: a } = p(), u = () => { var e; (e = r.current) == null || e.focus(), n(!1); }; return /* @__PURE__ */ f("div", { "data-test-id": i, className: "tw-relative tw-bottom-0 tw-top-0 tw-flex", children: [ /* @__PURE__ */ t( "button", { "aria-haspopup": "true", "aria-expanded": o, "aria-label": "Open overflow menu", ref: r, className: v([ "tw-w-6 tw-h-6 hover:tw-bg-box-neutral-strong-inverse-hover tw-rounded tw-flex tw-justify-center tw-items-center", o ? "tw-bg-box-neutral-strong-inverse-pressed" : "tw-bg-box-neutral-strong-inverse", l && b ]), type: "button", onClick: () => { n(!o); }, ...a, children: /* @__PURE__ */ t(d, {}) } ), /* @__PURE__ */ t(g, { triggerRef: r, onClose: u, open: o, children: s.map((e, m) => /* @__PURE__ */ t(h, { link: e.link, onClick: e.onClick, children: e.label }, `overflow-menu-item-${m}`)) }) ] }); }; x.displayName = "FondueOverflowMenu"; export { x as OverflowMenu }; //# sourceMappingURL=OverflowMenu.es.js.map