@geomak/ui 7.3.0 → 7.3.1

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,39 @@ 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
+ }
5892
5918
  function NavItem({
5893
5919
  item,
5894
5920
  isExpanded,
5895
5921
  depth = 0
5896
5922
  }) {
5897
5923
  const hasChildren = !!(item.items && item.items.length);
5898
- const [open, setOpen] = React30.useState(item.defaultOpen ?? (hasChildren && !!item.items?.some((c) => c.isActive)));
5924
+ const [open, setOpen] = React30.useState(item.defaultOpen ?? (hasChildren && hasActiveDescendant(item)));
5899
5925
  const handleClick = () => {
5900
5926
  if (hasChildren && isExpanded) setOpen((o) => !o);
5901
5927
  item.onClick?.();
@@ -5905,13 +5931,14 @@ function NavItem({
5905
5931
  {
5906
5932
  type: "button",
5907
5933
  onClick: handleClick,
5934
+ "aria-label": !isExpanded && typeof item.label === "string" ? item.label : void 0,
5908
5935
  "aria-expanded": hasChildren && isExpanded ? open : void 0,
5909
5936
  style: isExpanded && depth > 0 ? { paddingLeft: 10 + depth * 18 } : void 0,
5910
5937
  className: [
5911
5938
  "group relative flex w-full items-center gap-2.5 rounded-md",
5912
5939
  "px-2.5 py-2 transition-colors duration-100",
5913
5940
  "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"
5941
+ item.isActive || !isExpanded && hasActiveDescendant(item) ? "bg-accent/10 text-accent" : "text-foreground-secondary hover:bg-surface-raised hover:text-foreground"
5915
5942
  ].join(" "),
5916
5943
  children: [
5917
5944
  /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "relative flex h-5 w-5 flex-shrink-0 items-center justify-center", children: [
@@ -5936,6 +5963,15 @@ function NavItem({
5936
5963
  }
5937
5964
  );
5938
5965
  if (!isExpanded) {
5966
+ if (hasChildren) {
5967
+ return /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenu2__namespace.Root, { children: [
5968
+ /* @__PURE__ */ jsxRuntime.jsx(DropdownMenu2__namespace.Trigger, { asChild: true, children: btn }),
5969
+ /* @__PURE__ */ jsxRuntime.jsx(DropdownMenu2__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenu2__namespace.Content, { side: "right", align: "start", sideOffset: 8, collisionPadding: 8, className: FLYOUT_PANEL, children: [
5970
+ /* @__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 }),
5971
+ /* @__PURE__ */ jsxRuntime.jsx(FlyoutItems, { items: item.items })
5972
+ ] }) })
5973
+ ] });
5974
+ }
5939
5975
  return /* @__PURE__ */ jsxRuntime.jsx(Tooltip, { title: item.label, placement: "right", delayDuration: 200, children: btn });
5940
5976
  }
5941
5977
  if (!hasChildren) return btn;