@geomak/ui 7.3.0 → 7.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -6,7 +6,7 @@ var React30 = require('react');
6
6
  var reactDom = require('react-dom');
7
7
  var jsxRuntime = require('react/jsx-runtime');
8
8
  var AvatarPrimitive = require('@radix-ui/react-avatar');
9
- var DropdownMenu = require('@radix-ui/react-dropdown-menu');
9
+ var DropdownMenu2 = require('@radix-ui/react-dropdown-menu');
10
10
  var Dialog = require('@radix-ui/react-dialog');
11
11
  var framerMotion = require('framer-motion');
12
12
  var TooltipPrimitive = require('@radix-ui/react-tooltip');
@@ -43,7 +43,7 @@ function _interopNamespace(e) {
43
43
 
44
44
  var React30__default = /*#__PURE__*/_interopDefault(React30);
45
45
  var AvatarPrimitive__namespace = /*#__PURE__*/_interopNamespace(AvatarPrimitive);
46
- var DropdownMenu__namespace = /*#__PURE__*/_interopNamespace(DropdownMenu);
46
+ var DropdownMenu2__namespace = /*#__PURE__*/_interopNamespace(DropdownMenu2);
47
47
  var Dialog__namespace = /*#__PURE__*/_interopNamespace(Dialog);
48
48
  var TooltipPrimitive__namespace = /*#__PURE__*/_interopNamespace(TooltipPrimitive);
49
49
  var TabsPrimitive__namespace = /*#__PURE__*/_interopNamespace(TabsPrimitive);
@@ -673,8 +673,8 @@ function MenuButton({
673
673
  side = "bottom",
674
674
  className = ""
675
675
  }) {
676
- return /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenu__namespace.Root, { children: [
677
- /* @__PURE__ */ jsxRuntime.jsx(DropdownMenu__namespace.Trigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
676
+ return /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenu2__namespace.Root, { children: [
677
+ /* @__PURE__ */ jsxRuntime.jsx(DropdownMenu2__namespace.Trigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
678
678
  Button_default,
679
679
  {
680
680
  variant,
@@ -688,8 +688,8 @@ function MenuButton({
688
688
  ] })
689
689
  }
690
690
  ) }),
691
- /* @__PURE__ */ jsxRuntime.jsx(DropdownMenu__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
692
- DropdownMenu__namespace.Content,
691
+ /* @__PURE__ */ jsxRuntime.jsx(DropdownMenu2__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
692
+ DropdownMenu2__namespace.Content,
693
693
  {
694
694
  align,
695
695
  side,
@@ -701,9 +701,9 @@ function MenuButton({
701
701
  "data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95"
702
702
  ].join(" "),
703
703
  children: items.map((item) => /* @__PURE__ */ jsxRuntime.jsxs(React30__default.default.Fragment, { children: [
704
- item.separatorBefore && /* @__PURE__ */ jsxRuntime.jsx(DropdownMenu__namespace.Separator, { className: "my-1 h-px bg-border" }),
704
+ item.separatorBefore && /* @__PURE__ */ jsxRuntime.jsx(DropdownMenu2__namespace.Separator, { className: "my-1 h-px bg-border" }),
705
705
  /* @__PURE__ */ jsxRuntime.jsxs(
706
- DropdownMenu__namespace.Item,
706
+ DropdownMenu2__namespace.Item,
707
707
  {
708
708
  disabled: item.disabled,
709
709
  onSelect: () => item.onSelect?.(),
@@ -1703,7 +1703,7 @@ function Stepper({
1703
1703
  const vertical = orientation === "vertical" || forcedVertical;
1704
1704
  const s = SIZES[size];
1705
1705
  const stateOf = (i) => i < current ? "completed" : i === current ? status : "pending";
1706
- const Label = ({ step, state, align }) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: align === "center" ? "mt-2 text-center" : "pt-0.5", children: [
1706
+ const Label2 = ({ step, state, align }) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: align === "center" ? "mt-2 text-center" : "pt-0.5", children: [
1707
1707
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: `font-medium leading-tight ${s.title} ${state === "pending" ? "text-foreground-muted" : "text-foreground"}`, children: step.title }),
1708
1708
  step.description && /* @__PURE__ */ jsxRuntime.jsx("div", { className: `mt-0.5 leading-snug text-foreground-muted ${s.desc}`, children: step.description })
1709
1709
  ] });
@@ -1718,7 +1718,7 @@ function Stepper({
1718
1718
  stepButton(i, /* @__PURE__ */ jsxRuntime.jsx(Indicator, { state, index: i, step, sizeKey: size })),
1719
1719
  !last && /* @__PURE__ */ jsxRuntime.jsx(VConnector, { filled: i < current, reduced })
1720
1720
  ] }),
1721
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: last ? "" : "pb-6", children: stepButton(i, /* @__PURE__ */ jsxRuntime.jsx(Label, { step, state, align: "left" })) })
1721
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: last ? "" : "pb-6", children: stepButton(i, /* @__PURE__ */ jsxRuntime.jsx(Label2, { step, state, align: "left" })) })
1722
1722
  ] }, step.key);
1723
1723
  }) });
1724
1724
  }
@@ -1737,7 +1737,7 @@ function Stepper({
1737
1737
  ) }),
1738
1738
  stepButton(i, /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center", children: [
1739
1739
  /* @__PURE__ */ jsxRuntime.jsx(Indicator, { state, index: i, step, sizeKey: size }),
1740
- /* @__PURE__ */ jsxRuntime.jsx(Label, { step, state, align: "center" })
1740
+ /* @__PURE__ */ jsxRuntime.jsx(Label2, { step, state, align: "center" })
1741
1741
  ] }))
1742
1742
  ] }, step.key);
1743
1743
  }) });
@@ -5889,13 +5889,82 @@ function TopBar({
5889
5889
  }
5890
5890
  );
5891
5891
  }
5892
+ function hasActiveDescendant(item) {
5893
+ return !!item.items?.some((c) => c.isActive || hasActiveDescendant(c));
5894
+ }
5895
+ var FLYOUT_PANEL = "z-[400] min-w-[11rem] rounded-lg border border-border bg-surface p-1 shadow-lg data-[state=open]:animate-in data-[state=open]:fade-in-0 data-[state=open]:zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95";
5896
+ function FlyoutItems({ items }) {
5897
+ return /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children: items.map((child) => {
5898
+ const cls = [
5899
+ "flex items-center gap-2.5 rounded-md px-2.5 py-1.5 text-sm outline-none cursor-pointer select-none transition-colors",
5900
+ child.isActive ? "text-accent data-[highlighted]:bg-accent/10" : "text-foreground data-[highlighted]:bg-surface-raised"
5901
+ ].join(" ");
5902
+ const label = /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
5903
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex-1 truncate", children: child.label }),
5904
+ child.badge !== void 0 && child.badge > 0 && /* @__PURE__ */ jsxRuntime.jsx("span", { className: "flex h-4 min-w-4 items-center justify-center rounded-full bg-status-error px-1 text-[9px] font-bold leading-none text-white", children: child.badge > 99 ? "99+" : child.badge })
5905
+ ] });
5906
+ if (child.items?.length) {
5907
+ return /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenu2__namespace.Sub, { children: [
5908
+ /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenu2__namespace.SubTrigger, { className: cls, children: [
5909
+ label,
5910
+ /* @__PURE__ */ jsxRuntime.jsx("svg", { viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, "aria-hidden": "true", className: "h-3.5 w-3.5 flex-shrink-0", children: /* @__PURE__ */ jsxRuntime.jsx("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "m9 6 6 6-6 6" }) })
5911
+ ] }),
5912
+ /* @__PURE__ */ jsxRuntime.jsx(DropdownMenu2__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(DropdownMenu2__namespace.SubContent, { sideOffset: 6, collisionPadding: 8, className: FLYOUT_PANEL, children: /* @__PURE__ */ jsxRuntime.jsx(FlyoutItems, { items: child.items }) }) })
5913
+ ] }, child.key);
5914
+ }
5915
+ return /* @__PURE__ */ jsxRuntime.jsx(DropdownMenu2__namespace.Item, { onSelect: () => child.onClick?.(), className: cls, children: label }, child.key);
5916
+ }) });
5917
+ }
5918
+ function CollapsedFlyout({ item, trigger }) {
5919
+ const [open, setOpen] = React30.useState(false);
5920
+ const closeTimer = React30__default.default.useRef(void 0);
5921
+ const openNow = () => {
5922
+ window.clearTimeout(closeTimer.current);
5923
+ setOpen(true);
5924
+ };
5925
+ const closeSoon = () => {
5926
+ window.clearTimeout(closeTimer.current);
5927
+ closeTimer.current = window.setTimeout(() => setOpen(false), 150);
5928
+ };
5929
+ React30__default.default.useEffect(() => () => window.clearTimeout(closeTimer.current), []);
5930
+ return /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenu2__namespace.Root, { open, onOpenChange: setOpen, modal: false, children: [
5931
+ /* @__PURE__ */ jsxRuntime.jsx(
5932
+ DropdownMenu2__namespace.Trigger,
5933
+ {
5934
+ asChild: true,
5935
+ onPointerEnter: openNow,
5936
+ onPointerLeave: closeSoon,
5937
+ onPointerDown: (e) => {
5938
+ if (e.pointerType === "mouse") e.preventDefault();
5939
+ },
5940
+ children: trigger
5941
+ }
5942
+ ),
5943
+ /* @__PURE__ */ jsxRuntime.jsx(DropdownMenu2__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsxs(
5944
+ DropdownMenu2__namespace.Content,
5945
+ {
5946
+ side: "right",
5947
+ align: "start",
5948
+ sideOffset: 8,
5949
+ collisionPadding: 8,
5950
+ className: FLYOUT_PANEL,
5951
+ onPointerEnter: openNow,
5952
+ onPointerLeave: closeSoon,
5953
+ children: [
5954
+ /* @__PURE__ */ jsxRuntime.jsx(DropdownMenu2__namespace.Label, { className: "px-2.5 pb-1 pt-1.5 text-xs font-semibold text-foreground-muted", children: item.label }),
5955
+ /* @__PURE__ */ jsxRuntime.jsx(FlyoutItems, { items: item.items })
5956
+ ]
5957
+ }
5958
+ ) })
5959
+ ] });
5960
+ }
5892
5961
  function NavItem({
5893
5962
  item,
5894
5963
  isExpanded,
5895
5964
  depth = 0
5896
5965
  }) {
5897
5966
  const hasChildren = !!(item.items && item.items.length);
5898
- const [open, setOpen] = React30.useState(item.defaultOpen ?? (hasChildren && !!item.items?.some((c) => c.isActive)));
5967
+ const [open, setOpen] = React30.useState(item.defaultOpen ?? (hasChildren && hasActiveDescendant(item)));
5899
5968
  const handleClick = () => {
5900
5969
  if (hasChildren && isExpanded) setOpen((o) => !o);
5901
5970
  item.onClick?.();
@@ -5905,13 +5974,14 @@ function NavItem({
5905
5974
  {
5906
5975
  type: "button",
5907
5976
  onClick: handleClick,
5977
+ "aria-label": !isExpanded && typeof item.label === "string" ? item.label : void 0,
5908
5978
  "aria-expanded": hasChildren && isExpanded ? open : void 0,
5909
5979
  style: isExpanded && depth > 0 ? { paddingLeft: 10 + depth * 18 } : void 0,
5910
5980
  className: [
5911
5981
  "group relative flex w-full items-center gap-2.5 rounded-md",
5912
5982
  "px-2.5 py-2 transition-colors duration-100",
5913
5983
  "focus:outline-none focus-visible:ring-2 focus-visible:ring-accent focus-visible:ring-inset",
5914
- item.isActive ? "bg-accent/10 text-accent" : "text-foreground-secondary hover:bg-surface-raised hover:text-foreground"
5984
+ item.isActive || !isExpanded && hasActiveDescendant(item) ? "bg-accent/10 text-accent" : "text-foreground-secondary hover:bg-surface-raised hover:text-foreground"
5915
5985
  ].join(" "),
5916
5986
  children: [
5917
5987
  /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "relative flex h-5 w-5 flex-shrink-0 items-center justify-center", children: [
@@ -5936,6 +6006,7 @@ function NavItem({
5936
6006
  }
5937
6007
  );
5938
6008
  if (!isExpanded) {
6009
+ if (hasChildren) return /* @__PURE__ */ jsxRuntime.jsx(CollapsedFlyout, { item, trigger: btn });
5939
6010
  return /* @__PURE__ */ jsxRuntime.jsx(Tooltip, { title: item.label, placement: "right", delayDuration: 200, children: btn });
5940
6011
  }
5941
6012
  if (!hasChildren) return btn;