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