@inf-monkeys-tech/monkeys-design 1.0.37 → 1.0.38

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.js CHANGED
@@ -15805,7 +15805,7 @@ function UserAccountMenu({
15805
15805
  DropdownMenu2__namespace.Item,
15806
15806
  {
15807
15807
  disabled: item.disabled,
15808
- onSelect: item.onSelect,
15808
+ onSelect: item.disabled ? void 0 : item.onSelect,
15809
15809
  className: cn(
15810
15810
  "relative flex cursor-pointer select-none items-center gap-2 px-2 py-2 text-sm outline-none transition-colors hover:bg-[hsl(var(--accent))] hover:text-[hsl(var(--accent-foreground))] data-[disabled]:pointer-events-none data-[disabled]:opacity-50",
15811
15811
  radiusClass,
@@ -15831,6 +15831,7 @@ function cn2(...inputs) {
15831
15831
  }
15832
15832
  function NavButton({
15833
15833
  active,
15834
+ disabled,
15834
15835
  icon,
15835
15836
  postfix,
15836
15837
  onClick,
@@ -15838,11 +15839,16 @@ function NavButton({
15838
15839
  children
15839
15840
  }) {
15840
15841
  return /* @__PURE__ */ jsxRuntime.jsxs(
15841
- "div",
15842
+ "button",
15842
15843
  {
15844
+ type: "button",
15845
+ "aria-disabled": disabled,
15846
+ "aria-pressed": active,
15847
+ disabled,
15843
15848
  className: cn2(
15844
- "flex w-full cursor-pointer select-none items-center gap-2 rounded-xl border p-2 text-xs text-[hsl(var(--foreground))] transition-colors",
15845
- active ? "border-[hsl(var(--input))] bg-[hsl(var(--muted))] font-bold" : "border-transparent hover:border-[hsl(var(--input))]/60 hover:bg-[hsl(var(--muted))]/60",
15849
+ "flex w-full cursor-pointer select-none items-center gap-2 rounded-xl border p-2 text-left text-xs text-[hsl(var(--foreground))] transition-colors",
15850
+ active ? "border-[hsl(var(--input))] bg-[hsl(var(--muted))] font-bold" : disabled ? "border-transparent" : "border-transparent hover:border-[hsl(var(--input))]/60 hover:bg-[hsl(var(--muted))]/60",
15851
+ disabled && "!cursor-not-allowed opacity-60",
15846
15852
  className
15847
15853
  ),
15848
15854
  onClick,
@@ -16135,6 +16141,8 @@ function SidebarNavList({
16135
16141
  /* @__PURE__ */ jsxRuntime.jsx(
16136
16142
  NavButton,
16137
16143
  {
16144
+ active: item.id === resolvedActiveItemId,
16145
+ disabled: item.disabled,
16138
16146
  icon: item.icon,
16139
16147
  onClick: () => toggle(item.id),
16140
16148
  postfix: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-1 justify-end", children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -16159,10 +16167,11 @@ function SidebarNavList({
16159
16167
  children: item.label
16160
16168
  }
16161
16169
  ),
16162
- isExpanded && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-1 mt-1", children: item.children.map((child) => /* @__PURE__ */ jsxRuntime.jsx(
16170
+ isExpanded && !item.disabled && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-1 mt-1", children: item.children.map((child) => /* @__PURE__ */ jsxRuntime.jsx(
16163
16171
  NavButton,
16164
16172
  {
16165
16173
  active: child.id === resolvedActiveItemId,
16174
+ disabled: child.disabled,
16166
16175
  onClick: () => {
16167
16176
  setLocalActiveItemId(child.id);
16168
16177
  onNavigate?.(child.id);
@@ -16178,6 +16187,7 @@ function SidebarNavList({
16178
16187
  {
16179
16188
  icon: item.icon,
16180
16189
  active: item.id === resolvedActiveItemId,
16190
+ disabled: item.disabled,
16181
16191
  onClick: () => {
16182
16192
  setLocalActiveItemId(item.id);
16183
16193
  onNavigate?.(item.id);
@@ -16427,6 +16437,10 @@ function SidebarNavigationList({
16427
16437
  const [expandedByRoot, setExpandedByRoot] = React2.useState(
16428
16438
  {}
16429
16439
  );
16440
+ const canReveal = revealRequest ? items.some(
16441
+ (item) => item.id === revealRequest.id && !item.disabled
16442
+ ) : false;
16443
+ const activeRootId = findNavigationRootId(items, activeItemId);
16430
16444
  const toggleRoot = (id) => {
16431
16445
  setExpandedByRoot((current) => ({
16432
16446
  ...current,
@@ -16434,7 +16448,7 @@ function SidebarNavigationList({
16434
16448
  }));
16435
16449
  };
16436
16450
  React2.useEffect(() => {
16437
- if (!revealRequest) return;
16451
+ if (!revealRequest || !canReveal) return;
16438
16452
  setExpandedByRoot((current) => ({
16439
16453
  ...current,
16440
16454
  [revealRequest.id]: true
@@ -16452,7 +16466,7 @@ function SidebarNavigationList({
16452
16466
  }
16453
16467
  });
16454
16468
  return () => window.cancelAnimationFrame(frameId);
16455
- }, [revealRequest]);
16469
+ }, [canReveal, revealRequest]);
16456
16470
  return /* @__PURE__ */ jsxRuntime.jsxs(
16457
16471
  "div",
16458
16472
  {
@@ -16467,13 +16481,15 @@ function SidebarNavigationList({
16467
16481
  className: "monkeys-navigation-sidebar-nav flex w-full flex-col gap-2 text-xs text-[hsl(var(--foreground))]",
16468
16482
  children: items.map((item) => {
16469
16483
  const isGroup = Boolean(item.children?.length);
16470
- const isExpanded = Boolean(expandedByRoot[item.id]);
16471
- const isActive = activeItemId === item.id;
16484
+ const isExpanded = !item.disabled && Boolean(expandedByRoot[item.id]);
16485
+ const isActive = activeRootId === item.id;
16472
16486
  if (isGroup) {
16473
16487
  return /* @__PURE__ */ jsxRuntime.jsxs("div", { "data-navigation-sidebar-root-id": item.id, children: [
16474
16488
  /* @__PURE__ */ jsxRuntime.jsx(
16475
16489
  NavButton,
16476
16490
  {
16491
+ active: isActive,
16492
+ disabled: item.disabled,
16477
16493
  icon: item.icon,
16478
16494
  onClick: () => toggleRoot(item.id),
16479
16495
  postfix: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-1 justify-end", children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -16502,6 +16518,7 @@ function SidebarNavigationList({
16502
16518
  NavButton,
16503
16519
  {
16504
16520
  active: activeItemId === child.id,
16521
+ disabled: child.disabled,
16505
16522
  onClick: () => onNavigate?.(child.id),
16506
16523
  children: child.label
16507
16524
  },
@@ -16513,6 +16530,7 @@ function SidebarNavigationList({
16513
16530
  NavButton,
16514
16531
  {
16515
16532
  active: isActive,
16533
+ disabled: item.disabled,
16516
16534
  icon: item.icon,
16517
16535
  onClick: () => onNavigate?.(item.id),
16518
16536
  children: item.label
@@ -16628,9 +16646,11 @@ function Sidebar({
16628
16646
  appearance: NAVIGATION_LAYOUT_DEFAULT_APPEARANCE,
16629
16647
  tone: "muted",
16630
16648
  active: isActive,
16649
+ disabled: item.disabled,
16631
16650
  iconOnly: true,
16632
16651
  icon: item.icon,
16633
16652
  onClick: () => {
16653
+ if (item.disabled) return;
16634
16654
  onRevealRoot?.(item.id);
16635
16655
  onCollapsedChange?.(false);
16636
16656
  if (item.children?.length) return;
@@ -16707,6 +16727,7 @@ function HeadbarNavMenuItem({
16707
16727
  useTokenRadius
16708
16728
  }) {
16709
16729
  const [open, setOpen] = React2.useState(false);
16730
+ const isOpen = !item.disabled && open;
16710
16731
  const closeTimerRef = React2.useRef(null);
16711
16732
  const wasOpenOnPointerDownRef = React2.useRef(false);
16712
16733
  const clearCloseTimer = () => {
@@ -16715,6 +16736,7 @@ function HeadbarNavMenuItem({
16715
16736
  closeTimerRef.current = null;
16716
16737
  };
16717
16738
  const openMenu = () => {
16739
+ if (item.disabled) return;
16718
16740
  clearCloseTimer();
16719
16741
  setOpen(true);
16720
16742
  };
@@ -16733,98 +16755,111 @@ function HeadbarNavMenuItem({
16733
16755
  return true;
16734
16756
  };
16735
16757
  React2.useEffect(() => clearCloseTimer, []);
16736
- return /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenu2__namespace.Root, { modal: false, open, onOpenChange: setOpen, children: [
16737
- /* @__PURE__ */ jsxRuntime.jsx(DropdownMenu2__namespace.Trigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
16738
- BaseButton,
16739
- {
16740
- appearance: NAVIGATION_LAYOUT_DEFAULT_APPEARANCE,
16741
- tone: "muted",
16742
- active: isActive || open,
16743
- icon: item.icon,
16744
- endIcon: /* @__PURE__ */ jsxRuntime.jsx(HeadbarChevronIcon, { open }),
16745
- label: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate whitespace-nowrap", children: label }),
16746
- disabled: item.disabled,
16747
- onClick: () => {
16748
- const wasOpenOnPointerDown = wasOpenOnPointerDownRef.current;
16749
- wasOpenOnPointerDownRef.current = false;
16750
- if (wasOpenOnPointerDown && navigateToFirstEnabledChild()) return;
16751
- setOpen(true);
16752
- },
16753
- onPointerDown: () => {
16754
- wasOpenOnPointerDownRef.current = open;
16755
- },
16756
- onPointerCancel: () => {
16757
- wasOpenOnPointerDownRef.current = false;
16758
- },
16759
- onKeyDown: (event) => {
16760
- if (!open || event.key !== "Enter" && event.key !== " ") return;
16761
- if (navigateToFirstEnabledChild()) event.preventDefault();
16762
- },
16763
- onMouseEnter: openMenu,
16764
- onMouseLeave: scheduleCloseMenu,
16765
- style: getHeadbarItemStyle(
16766
- isActive || open,
16767
- compound ? false : useTokenRadius
16768
- ),
16769
- classNames: {
16770
- icon: "text-[inherit] [&_*]:!text-[inherit] [&_svg]:!stroke-current",
16771
- label: "text-[inherit] [&_*]:!text-[inherit]"
16772
- },
16773
- className: cn2(
16774
- "max-w-[12rem] shrink-0 border shadow-none",
16775
- compound && "!rounded-none !border-0 !bg-transparent",
16776
- menuButtonRadiusClass,
16777
- isActive || open ? "" : "hover:!bg-[var(--monkeys-component-navigation-headbar-item-hover-background,hsl(var(--muted)))] hover:!text-[var(--monkeys-component-navigation-headbar-item-hover-foreground,hsl(var(--foreground)))]"
16778
- )
16779
- }
16780
- ) }),
16781
- /* @__PURE__ */ jsxRuntime.jsx(DropdownMenu2__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
16782
- DropdownMenu2__namespace.Content,
16783
- {
16784
- align: "start",
16785
- sideOffset: 5,
16786
- onCloseAutoFocus: (event) => event.preventDefault(),
16787
- onMouseEnter: openMenu,
16788
- onMouseLeave: scheduleCloseMenu,
16789
- className: cn2(
16790
- "z-50 min-w-56 border p-1.5 animate-in fade-in-0 zoom-in-95",
16791
- menuContentRadiusClass
16792
- ),
16793
- style: {
16794
- background: "var(--monkeys-component-navigation-headbar-menu-background, hsl(var(--popover)))",
16795
- borderColor: "var(--monkeys-component-navigation-headbar-menu-border-color, hsl(var(--border)))",
16796
- color: "var(--monkeys-component-navigation-headbar-menu-foreground, hsl(var(--popover-foreground)))",
16797
- boxShadow: "var(--monkeys-component-navigation-headbar-menu-shadow, 0 10px 15px -3px rgb(0 0 0 / 0.1))",
16798
- backdropFilter: "blur(var(--monkeys-component-navigation-headbar-menu-backdrop-blur, 0px))"
16799
- },
16800
- children: item.children?.map((child) => /* @__PURE__ */ jsxRuntime.jsxs(
16801
- DropdownMenu2__namespace.Item,
16758
+ return /* @__PURE__ */ jsxRuntime.jsxs(
16759
+ DropdownMenu2__namespace.Root,
16760
+ {
16761
+ modal: false,
16762
+ open: isOpen,
16763
+ onOpenChange: (nextOpen) => setOpen(!item.disabled && nextOpen),
16764
+ children: [
16765
+ /* @__PURE__ */ jsxRuntime.jsx(DropdownMenu2__namespace.Trigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
16766
+ BaseButton,
16802
16767
  {
16803
- disabled: child.disabled,
16804
- className: cn2(
16805
- "relative flex cursor-pointer select-none items-center gap-2.5 px-3 py-2 text-sm outline-none transition-colors hover:!bg-[var(--monkeys-component-navigation-headbar-item-hover-background,hsl(var(--accent)))] hover:!text-[var(--monkeys-component-navigation-headbar-item-hover-foreground,hsl(var(--accent-foreground)))] focus:!bg-[var(--monkeys-component-navigation-headbar-item-hover-background,hsl(var(--accent)))] focus:!text-[var(--monkeys-component-navigation-headbar-item-hover-foreground,hsl(var(--accent-foreground)))] data-[highlighted]:!bg-[var(--monkeys-component-navigation-headbar-item-hover-background,hsl(var(--accent)))] data-[highlighted]:!text-[var(--monkeys-component-navigation-headbar-item-hover-foreground,hsl(var(--accent-foreground)))]",
16806
- menuItemRadiusClass
16807
- ),
16768
+ appearance: NAVIGATION_LAYOUT_DEFAULT_APPEARANCE,
16769
+ tone: "muted",
16770
+ active: isActive || isOpen,
16771
+ icon: item.icon,
16772
+ endIcon: /* @__PURE__ */ jsxRuntime.jsx(HeadbarChevronIcon, { open: isOpen }),
16773
+ label: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate whitespace-nowrap", children: label }),
16774
+ disabled: item.disabled,
16775
+ onClick: () => {
16776
+ const wasOpenOnPointerDown = wasOpenOnPointerDownRef.current;
16777
+ wasOpenOnPointerDownRef.current = false;
16778
+ if (wasOpenOnPointerDown && navigateToFirstEnabledChild()) return;
16779
+ setOpen(true);
16780
+ },
16781
+ onPointerDown: () => {
16782
+ wasOpenOnPointerDownRef.current = isOpen;
16783
+ },
16784
+ onPointerCancel: () => {
16785
+ wasOpenOnPointerDownRef.current = false;
16786
+ },
16787
+ onKeyDown: (event) => {
16788
+ if (!isOpen || event.key !== "Enter" && event.key !== " ")
16789
+ return;
16790
+ if (navigateToFirstEnabledChild()) event.preventDefault();
16791
+ },
16792
+ onMouseEnter: openMenu,
16793
+ onMouseLeave: scheduleCloseMenu,
16808
16794
  style: getHeadbarItemStyle(
16809
- child.id === activeItemId,
16810
- useTokenRadius
16795
+ isActive || isOpen,
16796
+ compound ? false : useTokenRadius
16811
16797
  ),
16812
- onSelect: () => {
16813
- if (child.disabled) return;
16814
- setOpen(false);
16815
- onNavigate?.(child.id);
16798
+ classNames: {
16799
+ icon: "text-[inherit] [&_*]:!text-[inherit] [&_svg]:!stroke-current",
16800
+ label: "text-[inherit] [&_*]:!text-[inherit]"
16816
16801
  },
16817
- children: [
16818
- child.icon ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "inline-flex h-4 w-4 shrink-0 items-center justify-center text-[hsl(var(--muted-foreground))]", children: child.icon }) : null,
16819
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "min-w-0 truncate", children: child.headbarLabel ?? child.label }),
16820
- child.trailing
16821
- ]
16822
- },
16823
- child.id
16824
- ))
16825
- }
16826
- ) })
16827
- ] });
16802
+ className: cn2(
16803
+ "max-w-[12rem] shrink-0 border shadow-none",
16804
+ compound && "!rounded-none !border-0 !bg-transparent",
16805
+ menuButtonRadiusClass,
16806
+ isActive || isOpen ? "" : "hover:!bg-[var(--monkeys-component-navigation-headbar-item-hover-background,hsl(var(--muted)))] hover:!text-[var(--monkeys-component-navigation-headbar-item-hover-foreground,hsl(var(--foreground)))]"
16807
+ )
16808
+ }
16809
+ ) }),
16810
+ /* @__PURE__ */ jsxRuntime.jsx(DropdownMenu2__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsx(
16811
+ DropdownMenu2__namespace.Content,
16812
+ {
16813
+ align: "start",
16814
+ sideOffset: 5,
16815
+ onCloseAutoFocus: (event) => event.preventDefault(),
16816
+ onMouseEnter: openMenu,
16817
+ onMouseLeave: scheduleCloseMenu,
16818
+ className: cn2(
16819
+ "z-50 min-w-56 border p-1.5 animate-in fade-in-0 zoom-in-95",
16820
+ menuContentRadiusClass
16821
+ ),
16822
+ style: {
16823
+ background: "var(--monkeys-component-navigation-headbar-menu-background, hsl(var(--popover)))",
16824
+ borderColor: "var(--monkeys-component-navigation-headbar-menu-border-color, hsl(var(--border)))",
16825
+ color: "var(--monkeys-component-navigation-headbar-menu-foreground, hsl(var(--popover-foreground)))",
16826
+ boxShadow: "var(--monkeys-component-navigation-headbar-menu-shadow, 0 10px 15px -3px rgb(0 0 0 / 0.1))",
16827
+ backdropFilter: "blur(var(--monkeys-component-navigation-headbar-menu-backdrop-blur, 0px))"
16828
+ },
16829
+ children: item.children?.map((child) => /* @__PURE__ */ jsxRuntime.jsxs(
16830
+ DropdownMenu2__namespace.Item,
16831
+ {
16832
+ disabled: child.disabled,
16833
+ className: cn2(
16834
+ "relative flex cursor-pointer select-none items-center gap-2.5 px-3 py-2 text-sm outline-none transition-colors hover:!bg-[var(--monkeys-component-navigation-headbar-item-hover-background,hsl(var(--accent)))] hover:!text-[var(--monkeys-component-navigation-headbar-item-hover-foreground,hsl(var(--accent-foreground)))] focus:!bg-[var(--monkeys-component-navigation-headbar-item-hover-background,hsl(var(--accent)))] focus:!text-[var(--monkeys-component-navigation-headbar-item-hover-foreground,hsl(var(--accent-foreground)))] data-[highlighted]:!bg-[var(--monkeys-component-navigation-headbar-item-hover-background,hsl(var(--accent)))] data-[highlighted]:!text-[var(--monkeys-component-navigation-headbar-item-hover-foreground,hsl(var(--accent-foreground)))]",
16835
+ menuItemRadiusClass
16836
+ ),
16837
+ style: getHeadbarItemStyle(
16838
+ child.id === activeItemId,
16839
+ useTokenRadius
16840
+ ),
16841
+ onSelect: () => {
16842
+ if (child.disabled) return;
16843
+ setOpen(false);
16844
+ onNavigate?.(child.id);
16845
+ },
16846
+ children: [
16847
+ child.icon ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "inline-flex h-4 w-4 shrink-0 items-center justify-center text-[hsl(var(--muted-foreground))]", children: child.icon }) : null,
16848
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "min-w-0 truncate", children: child.headbarLabel ?? child.label }),
16849
+ child.trailing
16850
+ ]
16851
+ },
16852
+ child.id
16853
+ ))
16854
+ }
16855
+ ) })
16856
+ ]
16857
+ }
16858
+ );
16859
+ }
16860
+ function blockEvent(event) {
16861
+ event.preventDefault();
16862
+ event.stopPropagation();
16828
16863
  }
16829
16864
  function NavigationHeadbarMenu({
16830
16865
  activeItemId,
@@ -16891,6 +16926,7 @@ function NavigationHeadbarMenu({
16891
16926
  "div",
16892
16927
  {
16893
16928
  "data-navigation-headbar-compound-item": item.id,
16929
+ "aria-disabled": item.disabled,
16894
16930
  className: cn2(
16895
16931
  "inline-flex min-w-0 shrink-0 items-center gap-0 overflow-hidden border shadow-none",
16896
16932
  menuButtonRadiusClass,
@@ -16910,7 +16946,17 @@ function NavigationHeadbarMenu({
16910
16946
  "span",
16911
16947
  {
16912
16948
  "data-navigation-headbar-secondary-action": item.id,
16913
- className: "inline-flex min-w-0 shrink-0 items-center",
16949
+ ...item.disabled && {
16950
+ inert: "",
16951
+ onClickCapture: blockEvent,
16952
+ onKeyDownCapture: blockEvent,
16953
+ onKeyUpCapture: blockEvent,
16954
+ onPointerDownCapture: blockEvent
16955
+ },
16956
+ className: cn2(
16957
+ "inline-flex min-w-0 shrink-0 items-center",
16958
+ item.disabled && "!cursor-not-allowed opacity-60"
16959
+ ),
16914
16960
  children: item.headbarSecondaryAction
16915
16961
  }
16916
16962
  )