@inf-monkeys-tech/monkeys-design 1.0.35 → 1.0.36

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