@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.mjs CHANGED
@@ -15770,7 +15770,7 @@ function UserAccountMenu({
15770
15770
  DropdownMenu2.Item,
15771
15771
  {
15772
15772
  disabled: item.disabled,
15773
- onSelect: item.onSelect,
15773
+ onSelect: item.disabled ? void 0 : item.onSelect,
15774
15774
  className: cn(
15775
15775
  "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",
15776
15776
  radiusClass,
@@ -15796,6 +15796,7 @@ function cn2(...inputs) {
15796
15796
  }
15797
15797
  function NavButton({
15798
15798
  active,
15799
+ disabled,
15799
15800
  icon,
15800
15801
  postfix,
15801
15802
  onClick,
@@ -15803,11 +15804,16 @@ function NavButton({
15803
15804
  children
15804
15805
  }) {
15805
15806
  return /* @__PURE__ */ jsxs(
15806
- "div",
15807
+ "button",
15807
15808
  {
15809
+ type: "button",
15810
+ "aria-disabled": disabled,
15811
+ "aria-pressed": active,
15812
+ disabled,
15808
15813
  className: cn2(
15809
- "flex w-full cursor-pointer select-none items-center gap-2 rounded-xl border p-2 text-xs text-[hsl(var(--foreground))] transition-colors",
15810
- 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",
15814
+ "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",
15815
+ 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",
15816
+ disabled && "!cursor-not-allowed opacity-60",
15811
15817
  className
15812
15818
  ),
15813
15819
  onClick,
@@ -16100,6 +16106,8 @@ function SidebarNavList({
16100
16106
  /* @__PURE__ */ jsx(
16101
16107
  NavButton,
16102
16108
  {
16109
+ active: item.id === resolvedActiveItemId,
16110
+ disabled: item.disabled,
16103
16111
  icon: item.icon,
16104
16112
  onClick: () => toggle(item.id),
16105
16113
  postfix: /* @__PURE__ */ jsx("div", { className: "flex flex-1 justify-end", children: /* @__PURE__ */ jsx(
@@ -16124,10 +16132,11 @@ function SidebarNavList({
16124
16132
  children: item.label
16125
16133
  }
16126
16134
  ),
16127
- isExpanded && /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1 mt-1", children: item.children.map((child) => /* @__PURE__ */ jsx(
16135
+ isExpanded && !item.disabled && /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1 mt-1", children: item.children.map((child) => /* @__PURE__ */ jsx(
16128
16136
  NavButton,
16129
16137
  {
16130
16138
  active: child.id === resolvedActiveItemId,
16139
+ disabled: child.disabled,
16131
16140
  onClick: () => {
16132
16141
  setLocalActiveItemId(child.id);
16133
16142
  onNavigate?.(child.id);
@@ -16143,6 +16152,7 @@ function SidebarNavList({
16143
16152
  {
16144
16153
  icon: item.icon,
16145
16154
  active: item.id === resolvedActiveItemId,
16155
+ disabled: item.disabled,
16146
16156
  onClick: () => {
16147
16157
  setLocalActiveItemId(item.id);
16148
16158
  onNavigate?.(item.id);
@@ -16392,6 +16402,10 @@ function SidebarNavigationList({
16392
16402
  const [expandedByRoot, setExpandedByRoot] = useState(
16393
16403
  {}
16394
16404
  );
16405
+ const canReveal = revealRequest ? items.some(
16406
+ (item) => item.id === revealRequest.id && !item.disabled
16407
+ ) : false;
16408
+ const activeRootId = findNavigationRootId(items, activeItemId);
16395
16409
  const toggleRoot = (id) => {
16396
16410
  setExpandedByRoot((current) => ({
16397
16411
  ...current,
@@ -16399,7 +16413,7 @@ function SidebarNavigationList({
16399
16413
  }));
16400
16414
  };
16401
16415
  useEffect(() => {
16402
- if (!revealRequest) return;
16416
+ if (!revealRequest || !canReveal) return;
16403
16417
  setExpandedByRoot((current) => ({
16404
16418
  ...current,
16405
16419
  [revealRequest.id]: true
@@ -16417,7 +16431,7 @@ function SidebarNavigationList({
16417
16431
  }
16418
16432
  });
16419
16433
  return () => window.cancelAnimationFrame(frameId);
16420
- }, [revealRequest]);
16434
+ }, [canReveal, revealRequest]);
16421
16435
  return /* @__PURE__ */ jsxs(
16422
16436
  "div",
16423
16437
  {
@@ -16432,13 +16446,15 @@ function SidebarNavigationList({
16432
16446
  className: "monkeys-navigation-sidebar-nav flex w-full flex-col gap-2 text-xs text-[hsl(var(--foreground))]",
16433
16447
  children: items.map((item) => {
16434
16448
  const isGroup = Boolean(item.children?.length);
16435
- const isExpanded = Boolean(expandedByRoot[item.id]);
16436
- const isActive = activeItemId === item.id;
16449
+ const isExpanded = !item.disabled && Boolean(expandedByRoot[item.id]);
16450
+ const isActive = activeRootId === item.id;
16437
16451
  if (isGroup) {
16438
16452
  return /* @__PURE__ */ jsxs("div", { "data-navigation-sidebar-root-id": item.id, children: [
16439
16453
  /* @__PURE__ */ jsx(
16440
16454
  NavButton,
16441
16455
  {
16456
+ active: isActive,
16457
+ disabled: item.disabled,
16442
16458
  icon: item.icon,
16443
16459
  onClick: () => toggleRoot(item.id),
16444
16460
  postfix: /* @__PURE__ */ jsx("div", { className: "flex flex-1 justify-end", children: /* @__PURE__ */ jsx(
@@ -16467,6 +16483,7 @@ function SidebarNavigationList({
16467
16483
  NavButton,
16468
16484
  {
16469
16485
  active: activeItemId === child.id,
16486
+ disabled: child.disabled,
16470
16487
  onClick: () => onNavigate?.(child.id),
16471
16488
  children: child.label
16472
16489
  },
@@ -16478,6 +16495,7 @@ function SidebarNavigationList({
16478
16495
  NavButton,
16479
16496
  {
16480
16497
  active: isActive,
16498
+ disabled: item.disabled,
16481
16499
  icon: item.icon,
16482
16500
  onClick: () => onNavigate?.(item.id),
16483
16501
  children: item.label
@@ -16593,9 +16611,11 @@ function Sidebar({
16593
16611
  appearance: NAVIGATION_LAYOUT_DEFAULT_APPEARANCE,
16594
16612
  tone: "muted",
16595
16613
  active: isActive,
16614
+ disabled: item.disabled,
16596
16615
  iconOnly: true,
16597
16616
  icon: item.icon,
16598
16617
  onClick: () => {
16618
+ if (item.disabled) return;
16599
16619
  onRevealRoot?.(item.id);
16600
16620
  onCollapsedChange?.(false);
16601
16621
  if (item.children?.length) return;
@@ -16672,6 +16692,7 @@ function HeadbarNavMenuItem({
16672
16692
  useTokenRadius
16673
16693
  }) {
16674
16694
  const [open, setOpen] = useState(false);
16695
+ const isOpen = !item.disabled && open;
16675
16696
  const closeTimerRef = useRef(null);
16676
16697
  const wasOpenOnPointerDownRef = useRef(false);
16677
16698
  const clearCloseTimer = () => {
@@ -16680,6 +16701,7 @@ function HeadbarNavMenuItem({
16680
16701
  closeTimerRef.current = null;
16681
16702
  };
16682
16703
  const openMenu = () => {
16704
+ if (item.disabled) return;
16683
16705
  clearCloseTimer();
16684
16706
  setOpen(true);
16685
16707
  };
@@ -16698,98 +16720,111 @@ function HeadbarNavMenuItem({
16698
16720
  return true;
16699
16721
  };
16700
16722
  useEffect(() => clearCloseTimer, []);
16701
- return /* @__PURE__ */ jsxs(DropdownMenu2.Root, { modal: false, open, onOpenChange: setOpen, children: [
16702
- /* @__PURE__ */ jsx(DropdownMenu2.Trigger, { asChild: true, children: /* @__PURE__ */ jsx(
16703
- BaseButton,
16704
- {
16705
- appearance: NAVIGATION_LAYOUT_DEFAULT_APPEARANCE,
16706
- tone: "muted",
16707
- active: isActive || open,
16708
- icon: item.icon,
16709
- endIcon: /* @__PURE__ */ jsx(HeadbarChevronIcon, { open }),
16710
- label: /* @__PURE__ */ jsx("span", { className: "truncate whitespace-nowrap", children: label }),
16711
- disabled: item.disabled,
16712
- onClick: () => {
16713
- const wasOpenOnPointerDown = wasOpenOnPointerDownRef.current;
16714
- wasOpenOnPointerDownRef.current = false;
16715
- if (wasOpenOnPointerDown && navigateToFirstEnabledChild()) return;
16716
- setOpen(true);
16717
- },
16718
- onPointerDown: () => {
16719
- wasOpenOnPointerDownRef.current = open;
16720
- },
16721
- onPointerCancel: () => {
16722
- wasOpenOnPointerDownRef.current = false;
16723
- },
16724
- onKeyDown: (event) => {
16725
- if (!open || event.key !== "Enter" && event.key !== " ") return;
16726
- if (navigateToFirstEnabledChild()) event.preventDefault();
16727
- },
16728
- onMouseEnter: openMenu,
16729
- onMouseLeave: scheduleCloseMenu,
16730
- style: getHeadbarItemStyle(
16731
- isActive || open,
16732
- compound ? false : useTokenRadius
16733
- ),
16734
- classNames: {
16735
- icon: "text-[inherit] [&_*]:!text-[inherit] [&_svg]:!stroke-current",
16736
- label: "text-[inherit] [&_*]:!text-[inherit]"
16737
- },
16738
- className: cn2(
16739
- "max-w-[12rem] shrink-0 border shadow-none",
16740
- compound && "!rounded-none !border-0 !bg-transparent",
16741
- menuButtonRadiusClass,
16742
- 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)))]"
16743
- )
16744
- }
16745
- ) }),
16746
- /* @__PURE__ */ jsx(DropdownMenu2.Portal, { children: /* @__PURE__ */ jsx(
16747
- DropdownMenu2.Content,
16748
- {
16749
- align: "start",
16750
- sideOffset: 5,
16751
- onCloseAutoFocus: (event) => event.preventDefault(),
16752
- onMouseEnter: openMenu,
16753
- onMouseLeave: scheduleCloseMenu,
16754
- className: cn2(
16755
- "z-50 min-w-56 border p-1.5 animate-in fade-in-0 zoom-in-95",
16756
- menuContentRadiusClass
16757
- ),
16758
- style: {
16759
- background: "var(--monkeys-component-navigation-headbar-menu-background, hsl(var(--popover)))",
16760
- borderColor: "var(--monkeys-component-navigation-headbar-menu-border-color, hsl(var(--border)))",
16761
- color: "var(--monkeys-component-navigation-headbar-menu-foreground, hsl(var(--popover-foreground)))",
16762
- boxShadow: "var(--monkeys-component-navigation-headbar-menu-shadow, 0 10px 15px -3px rgb(0 0 0 / 0.1))",
16763
- backdropFilter: "blur(var(--monkeys-component-navigation-headbar-menu-backdrop-blur, 0px))"
16764
- },
16765
- children: item.children?.map((child) => /* @__PURE__ */ jsxs(
16766
- DropdownMenu2.Item,
16723
+ return /* @__PURE__ */ jsxs(
16724
+ DropdownMenu2.Root,
16725
+ {
16726
+ modal: false,
16727
+ open: isOpen,
16728
+ onOpenChange: (nextOpen) => setOpen(!item.disabled && nextOpen),
16729
+ children: [
16730
+ /* @__PURE__ */ jsx(DropdownMenu2.Trigger, { asChild: true, children: /* @__PURE__ */ jsx(
16731
+ BaseButton,
16767
16732
  {
16768
- disabled: child.disabled,
16769
- className: cn2(
16770
- "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)))]",
16771
- menuItemRadiusClass
16772
- ),
16733
+ appearance: NAVIGATION_LAYOUT_DEFAULT_APPEARANCE,
16734
+ tone: "muted",
16735
+ active: isActive || isOpen,
16736
+ icon: item.icon,
16737
+ endIcon: /* @__PURE__ */ jsx(HeadbarChevronIcon, { open: isOpen }),
16738
+ label: /* @__PURE__ */ jsx("span", { className: "truncate whitespace-nowrap", children: label }),
16739
+ disabled: item.disabled,
16740
+ onClick: () => {
16741
+ const wasOpenOnPointerDown = wasOpenOnPointerDownRef.current;
16742
+ wasOpenOnPointerDownRef.current = false;
16743
+ if (wasOpenOnPointerDown && navigateToFirstEnabledChild()) return;
16744
+ setOpen(true);
16745
+ },
16746
+ onPointerDown: () => {
16747
+ wasOpenOnPointerDownRef.current = isOpen;
16748
+ },
16749
+ onPointerCancel: () => {
16750
+ wasOpenOnPointerDownRef.current = false;
16751
+ },
16752
+ onKeyDown: (event) => {
16753
+ if (!isOpen || event.key !== "Enter" && event.key !== " ")
16754
+ return;
16755
+ if (navigateToFirstEnabledChild()) event.preventDefault();
16756
+ },
16757
+ onMouseEnter: openMenu,
16758
+ onMouseLeave: scheduleCloseMenu,
16773
16759
  style: getHeadbarItemStyle(
16774
- child.id === activeItemId,
16775
- useTokenRadius
16760
+ isActive || isOpen,
16761
+ compound ? false : useTokenRadius
16776
16762
  ),
16777
- onSelect: () => {
16778
- if (child.disabled) return;
16779
- setOpen(false);
16780
- onNavigate?.(child.id);
16763
+ classNames: {
16764
+ icon: "text-[inherit] [&_*]:!text-[inherit] [&_svg]:!stroke-current",
16765
+ label: "text-[inherit] [&_*]:!text-[inherit]"
16781
16766
  },
16782
- children: [
16783
- child.icon ? /* @__PURE__ */ jsx("span", { className: "inline-flex h-4 w-4 shrink-0 items-center justify-center text-[hsl(var(--muted-foreground))]", children: child.icon }) : null,
16784
- /* @__PURE__ */ jsx("span", { className: "min-w-0 truncate", children: child.headbarLabel ?? child.label }),
16785
- child.trailing
16786
- ]
16787
- },
16788
- child.id
16789
- ))
16790
- }
16791
- ) })
16792
- ] });
16767
+ className: cn2(
16768
+ "max-w-[12rem] shrink-0 border shadow-none",
16769
+ compound && "!rounded-none !border-0 !bg-transparent",
16770
+ menuButtonRadiusClass,
16771
+ 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)))]"
16772
+ )
16773
+ }
16774
+ ) }),
16775
+ /* @__PURE__ */ jsx(DropdownMenu2.Portal, { children: /* @__PURE__ */ jsx(
16776
+ DropdownMenu2.Content,
16777
+ {
16778
+ align: "start",
16779
+ sideOffset: 5,
16780
+ onCloseAutoFocus: (event) => event.preventDefault(),
16781
+ onMouseEnter: openMenu,
16782
+ onMouseLeave: scheduleCloseMenu,
16783
+ className: cn2(
16784
+ "z-50 min-w-56 border p-1.5 animate-in fade-in-0 zoom-in-95",
16785
+ menuContentRadiusClass
16786
+ ),
16787
+ style: {
16788
+ background: "var(--monkeys-component-navigation-headbar-menu-background, hsl(var(--popover)))",
16789
+ borderColor: "var(--monkeys-component-navigation-headbar-menu-border-color, hsl(var(--border)))",
16790
+ color: "var(--monkeys-component-navigation-headbar-menu-foreground, hsl(var(--popover-foreground)))",
16791
+ boxShadow: "var(--monkeys-component-navigation-headbar-menu-shadow, 0 10px 15px -3px rgb(0 0 0 / 0.1))",
16792
+ backdropFilter: "blur(var(--monkeys-component-navigation-headbar-menu-backdrop-blur, 0px))"
16793
+ },
16794
+ children: item.children?.map((child) => /* @__PURE__ */ jsxs(
16795
+ DropdownMenu2.Item,
16796
+ {
16797
+ disabled: child.disabled,
16798
+ className: cn2(
16799
+ "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)))]",
16800
+ menuItemRadiusClass
16801
+ ),
16802
+ style: getHeadbarItemStyle(
16803
+ child.id === activeItemId,
16804
+ useTokenRadius
16805
+ ),
16806
+ onSelect: () => {
16807
+ if (child.disabled) return;
16808
+ setOpen(false);
16809
+ onNavigate?.(child.id);
16810
+ },
16811
+ children: [
16812
+ child.icon ? /* @__PURE__ */ jsx("span", { className: "inline-flex h-4 w-4 shrink-0 items-center justify-center text-[hsl(var(--muted-foreground))]", children: child.icon }) : null,
16813
+ /* @__PURE__ */ jsx("span", { className: "min-w-0 truncate", children: child.headbarLabel ?? child.label }),
16814
+ child.trailing
16815
+ ]
16816
+ },
16817
+ child.id
16818
+ ))
16819
+ }
16820
+ ) })
16821
+ ]
16822
+ }
16823
+ );
16824
+ }
16825
+ function blockEvent(event) {
16826
+ event.preventDefault();
16827
+ event.stopPropagation();
16793
16828
  }
16794
16829
  function NavigationHeadbarMenu({
16795
16830
  activeItemId,
@@ -16856,6 +16891,7 @@ function NavigationHeadbarMenu({
16856
16891
  "div",
16857
16892
  {
16858
16893
  "data-navigation-headbar-compound-item": item.id,
16894
+ "aria-disabled": item.disabled,
16859
16895
  className: cn2(
16860
16896
  "inline-flex min-w-0 shrink-0 items-center gap-0 overflow-hidden border shadow-none",
16861
16897
  menuButtonRadiusClass,
@@ -16875,7 +16911,17 @@ function NavigationHeadbarMenu({
16875
16911
  "span",
16876
16912
  {
16877
16913
  "data-navigation-headbar-secondary-action": item.id,
16878
- className: "inline-flex min-w-0 shrink-0 items-center",
16914
+ ...item.disabled && {
16915
+ inert: "",
16916
+ onClickCapture: blockEvent,
16917
+ onKeyDownCapture: blockEvent,
16918
+ onKeyUpCapture: blockEvent,
16919
+ onPointerDownCapture: blockEvent
16920
+ },
16921
+ className: cn2(
16922
+ "inline-flex min-w-0 shrink-0 items-center",
16923
+ item.disabled && "!cursor-not-allowed opacity-60"
16924
+ ),
16879
16925
  children: item.headbarSecondaryAction
16880
16926
  }
16881
16927
  )