@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.
@@ -2766,7 +2766,7 @@ function UserAccountMenu({
2766
2766
  DropdownMenu.Item,
2767
2767
  {
2768
2768
  disabled: item.disabled,
2769
- onSelect: item.onSelect,
2769
+ onSelect: item.disabled ? void 0 : item.onSelect,
2770
2770
  className: cn(
2771
2771
  "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",
2772
2772
  radiusClass,
@@ -2792,6 +2792,7 @@ function cn2(...inputs) {
2792
2792
  }
2793
2793
  function NavButton({
2794
2794
  active,
2795
+ disabled,
2795
2796
  icon,
2796
2797
  postfix,
2797
2798
  onClick,
@@ -2799,11 +2800,17 @@ function NavButton({
2799
2800
  children
2800
2801
  }) {
2801
2802
  return /* @__PURE__ */ jsxs(
2802
- "div",
2803
+ "button",
2803
2804
  {
2805
+ type: "button",
2806
+ "aria-disabled": disabled || void 0,
2807
+ "aria-pressed": active || void 0,
2808
+ "data-disabled": disabled || void 0,
2809
+ disabled,
2804
2810
  className: cn2(
2805
- "flex w-full cursor-pointer select-none items-center gap-2 rounded-xl border p-2 text-xs text-[hsl(var(--foreground))] transition-colors",
2811
+ "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",
2806
2812
  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",
2813
+ disabled && "!cursor-not-allowed opacity-60 hover:border-transparent hover:bg-transparent",
2807
2814
  className
2808
2815
  ),
2809
2816
  onClick,
@@ -3096,6 +3103,8 @@ function SidebarNavList({
3096
3103
  /* @__PURE__ */ jsx(
3097
3104
  NavButton,
3098
3105
  {
3106
+ active: item.id === resolvedActiveItemId,
3107
+ disabled: item.disabled,
3099
3108
  icon: item.icon,
3100
3109
  onClick: () => toggle(item.id),
3101
3110
  postfix: /* @__PURE__ */ jsx("div", { className: "flex flex-1 justify-end", children: /* @__PURE__ */ jsx(
@@ -3120,10 +3129,11 @@ function SidebarNavList({
3120
3129
  children: item.label
3121
3130
  }
3122
3131
  ),
3123
- isExpanded && /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1 mt-1", children: item.children.map((child) => /* @__PURE__ */ jsx(
3132
+ isExpanded && !item.disabled && /* @__PURE__ */ jsx("div", { className: "flex flex-col gap-1 mt-1", children: item.children.map((child) => /* @__PURE__ */ jsx(
3124
3133
  NavButton,
3125
3134
  {
3126
3135
  active: child.id === resolvedActiveItemId,
3136
+ disabled: child.disabled,
3127
3137
  onClick: () => {
3128
3138
  setLocalActiveItemId(child.id);
3129
3139
  onNavigate?.(child.id);
@@ -3139,6 +3149,7 @@ function SidebarNavList({
3139
3149
  {
3140
3150
  icon: item.icon,
3141
3151
  active: item.id === resolvedActiveItemId,
3152
+ disabled: item.disabled,
3142
3153
  onClick: () => {
3143
3154
  setLocalActiveItemId(item.id);
3144
3155
  onNavigate?.(item.id);
@@ -3388,6 +3399,10 @@ function SidebarNavigationList({
3388
3399
  const [expandedByRoot, setExpandedByRoot] = useState(
3389
3400
  {}
3390
3401
  );
3402
+ const canRevealRequestedRoot = revealRequest ? items.some(
3403
+ (item) => item.id === revealRequest.id && !item.disabled
3404
+ ) : false;
3405
+ const activeRootId = findNavigationRootId(items, activeItemId);
3391
3406
  const toggleRoot = (id) => {
3392
3407
  setExpandedByRoot((current) => ({
3393
3408
  ...current,
@@ -3395,7 +3410,7 @@ function SidebarNavigationList({
3395
3410
  }));
3396
3411
  };
3397
3412
  useEffect(() => {
3398
- if (!revealRequest) return;
3413
+ if (!revealRequest || !canRevealRequestedRoot) return;
3399
3414
  setExpandedByRoot((current) => ({
3400
3415
  ...current,
3401
3416
  [revealRequest.id]: true
@@ -3413,7 +3428,7 @@ function SidebarNavigationList({
3413
3428
  }
3414
3429
  });
3415
3430
  return () => window.cancelAnimationFrame(frameId);
3416
- }, [revealRequest]);
3431
+ }, [canRevealRequestedRoot, revealRequest]);
3417
3432
  return /* @__PURE__ */ jsxs(
3418
3433
  "div",
3419
3434
  {
@@ -3428,13 +3443,15 @@ function SidebarNavigationList({
3428
3443
  className: "monkeys-navigation-sidebar-nav flex w-full flex-col gap-2 text-xs text-[hsl(var(--foreground))]",
3429
3444
  children: items.map((item) => {
3430
3445
  const isGroup = Boolean(item.children?.length);
3431
- const isExpanded = Boolean(expandedByRoot[item.id]);
3432
- const isActive = activeItemId === item.id;
3446
+ const isExpanded = !item.disabled && Boolean(expandedByRoot[item.id]);
3447
+ const isActive = activeRootId === item.id;
3433
3448
  if (isGroup) {
3434
3449
  return /* @__PURE__ */ jsxs("div", { "data-navigation-sidebar-root-id": item.id, children: [
3435
3450
  /* @__PURE__ */ jsx(
3436
3451
  NavButton,
3437
3452
  {
3453
+ active: isActive,
3454
+ disabled: item.disabled,
3438
3455
  icon: item.icon,
3439
3456
  onClick: () => toggleRoot(item.id),
3440
3457
  postfix: /* @__PURE__ */ jsx("div", { className: "flex flex-1 justify-end", children: /* @__PURE__ */ jsx(
@@ -3463,6 +3480,7 @@ function SidebarNavigationList({
3463
3480
  NavButton,
3464
3481
  {
3465
3482
  active: activeItemId === child.id,
3483
+ disabled: child.disabled,
3466
3484
  onClick: () => onNavigate?.(child.id),
3467
3485
  children: child.label
3468
3486
  },
@@ -3474,6 +3492,7 @@ function SidebarNavigationList({
3474
3492
  NavButton,
3475
3493
  {
3476
3494
  active: isActive,
3495
+ disabled: item.disabled,
3477
3496
  icon: item.icon,
3478
3497
  onClick: () => onNavigate?.(item.id),
3479
3498
  children: item.label
@@ -3589,9 +3608,11 @@ function Sidebar({
3589
3608
  appearance: NAVIGATION_LAYOUT_DEFAULT_APPEARANCE,
3590
3609
  tone: "muted",
3591
3610
  active: isActive,
3611
+ disabled: item.disabled,
3592
3612
  iconOnly: true,
3593
3613
  icon: item.icon,
3594
3614
  onClick: () => {
3615
+ if (item.disabled) return;
3595
3616
  onRevealRoot?.(item.id);
3596
3617
  onCollapsedChange?.(false);
3597
3618
  if (item.children?.length) return;
@@ -3668,6 +3689,7 @@ function HeadbarNavMenuItem({
3668
3689
  useTokenRadius
3669
3690
  }) {
3670
3691
  const [open, setOpen] = useState(false);
3692
+ const menuOpen = !item.disabled && open;
3671
3693
  const closeTimerRef = useRef(null);
3672
3694
  const wasOpenOnPointerDownRef = useRef(false);
3673
3695
  const clearCloseTimer = () => {
@@ -3676,6 +3698,7 @@ function HeadbarNavMenuItem({
3676
3698
  closeTimerRef.current = null;
3677
3699
  };
3678
3700
  const openMenu = () => {
3701
+ if (item.disabled) return;
3679
3702
  clearCloseTimer();
3680
3703
  setOpen(true);
3681
3704
  };
@@ -3687,6 +3710,7 @@ function HeadbarNavMenuItem({
3687
3710
  }, 120);
3688
3711
  };
3689
3712
  const navigateToFirstEnabledChild = () => {
3713
+ if (item.disabled) return false;
3690
3714
  const firstEnabledChild = item.children?.find((child) => !child.disabled);
3691
3715
  if (!firstEnabledChild) return false;
3692
3716
  setOpen(false);
@@ -3694,98 +3718,113 @@ function HeadbarNavMenuItem({
3694
3718
  return true;
3695
3719
  };
3696
3720
  useEffect(() => clearCloseTimer, []);
3697
- return /* @__PURE__ */ jsxs(DropdownMenu.Root, { modal: false, open, onOpenChange: setOpen, children: [
3698
- /* @__PURE__ */ jsx(DropdownMenu.Trigger, { asChild: true, children: /* @__PURE__ */ jsx(
3699
- BaseButton,
3700
- {
3701
- appearance: NAVIGATION_LAYOUT_DEFAULT_APPEARANCE,
3702
- tone: "muted",
3703
- active: isActive || open,
3704
- icon: item.icon,
3705
- endIcon: /* @__PURE__ */ jsx(HeadbarChevronIcon, { open }),
3706
- label: /* @__PURE__ */ jsx("span", { className: "truncate whitespace-nowrap", children: label }),
3707
- disabled: item.disabled,
3708
- onClick: () => {
3709
- const wasOpenOnPointerDown = wasOpenOnPointerDownRef.current;
3710
- wasOpenOnPointerDownRef.current = false;
3711
- if (wasOpenOnPointerDown && navigateToFirstEnabledChild()) return;
3712
- setOpen(true);
3713
- },
3714
- onPointerDown: () => {
3715
- wasOpenOnPointerDownRef.current = open;
3716
- },
3717
- onPointerCancel: () => {
3718
- wasOpenOnPointerDownRef.current = false;
3719
- },
3720
- onKeyDown: (event) => {
3721
- if (!open || event.key !== "Enter" && event.key !== " ") return;
3722
- if (navigateToFirstEnabledChild()) event.preventDefault();
3723
- },
3724
- onMouseEnter: openMenu,
3725
- onMouseLeave: scheduleCloseMenu,
3726
- style: getHeadbarItemStyle(
3727
- isActive || open,
3728
- compound ? false : useTokenRadius
3729
- ),
3730
- classNames: {
3731
- icon: "text-[inherit] [&_*]:!text-[inherit] [&_svg]:!stroke-current",
3732
- label: "text-[inherit] [&_*]:!text-[inherit]"
3733
- },
3734
- className: cn2(
3735
- "max-w-[12rem] shrink-0 border shadow-none",
3736
- compound && "!rounded-none !border-0 !bg-transparent",
3737
- menuButtonRadiusClass,
3738
- 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)))]"
3739
- )
3740
- }
3741
- ) }),
3742
- /* @__PURE__ */ jsx(DropdownMenu.Portal, { children: /* @__PURE__ */ jsx(
3743
- DropdownMenu.Content,
3744
- {
3745
- align: "start",
3746
- sideOffset: 5,
3747
- onCloseAutoFocus: (event) => event.preventDefault(),
3748
- onMouseEnter: openMenu,
3749
- onMouseLeave: scheduleCloseMenu,
3750
- className: cn2(
3751
- "z-50 min-w-56 border p-1.5 animate-in fade-in-0 zoom-in-95",
3752
- menuContentRadiusClass
3753
- ),
3754
- style: {
3755
- background: "var(--monkeys-component-navigation-headbar-menu-background, hsl(var(--popover)))",
3756
- borderColor: "var(--monkeys-component-navigation-headbar-menu-border-color, hsl(var(--border)))",
3757
- color: "var(--monkeys-component-navigation-headbar-menu-foreground, hsl(var(--popover-foreground)))",
3758
- boxShadow: "var(--monkeys-component-navigation-headbar-menu-shadow, 0 10px 15px -3px rgb(0 0 0 / 0.1))",
3759
- backdropFilter: "blur(var(--monkeys-component-navigation-headbar-menu-backdrop-blur, 0px))"
3760
- },
3761
- children: item.children?.map((child) => /* @__PURE__ */ jsxs(
3762
- DropdownMenu.Item,
3721
+ return /* @__PURE__ */ jsxs(
3722
+ DropdownMenu.Root,
3723
+ {
3724
+ modal: false,
3725
+ open: menuOpen,
3726
+ onOpenChange: (nextOpen) => setOpen(item.disabled ? false : nextOpen),
3727
+ children: [
3728
+ /* @__PURE__ */ jsx(DropdownMenu.Trigger, { asChild: true, children: /* @__PURE__ */ jsx(
3729
+ BaseButton,
3763
3730
  {
3764
- disabled: child.disabled,
3765
- className: cn2(
3766
- "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)))]",
3767
- menuItemRadiusClass
3768
- ),
3731
+ appearance: NAVIGATION_LAYOUT_DEFAULT_APPEARANCE,
3732
+ tone: "muted",
3733
+ active: isActive || menuOpen,
3734
+ icon: item.icon,
3735
+ endIcon: /* @__PURE__ */ jsx(HeadbarChevronIcon, { open: menuOpen }),
3736
+ label: /* @__PURE__ */ jsx("span", { className: "truncate whitespace-nowrap", children: label }),
3737
+ disabled: item.disabled,
3738
+ onClick: () => {
3739
+ if (item.disabled) return;
3740
+ const wasOpenOnPointerDown = wasOpenOnPointerDownRef.current;
3741
+ wasOpenOnPointerDownRef.current = false;
3742
+ if (wasOpenOnPointerDown && navigateToFirstEnabledChild()) return;
3743
+ setOpen(true);
3744
+ },
3745
+ onPointerDown: () => {
3746
+ if (item.disabled) return;
3747
+ wasOpenOnPointerDownRef.current = menuOpen;
3748
+ },
3749
+ onPointerCancel: () => {
3750
+ wasOpenOnPointerDownRef.current = false;
3751
+ },
3752
+ onKeyDown: (event) => {
3753
+ if (item.disabled || !menuOpen || event.key !== "Enter" && event.key !== " ")
3754
+ return;
3755
+ if (navigateToFirstEnabledChild()) event.preventDefault();
3756
+ },
3757
+ onMouseEnter: openMenu,
3758
+ onMouseLeave: scheduleCloseMenu,
3769
3759
  style: getHeadbarItemStyle(
3770
- child.id === activeItemId,
3771
- useTokenRadius
3760
+ isActive || menuOpen,
3761
+ compound ? false : useTokenRadius
3772
3762
  ),
3773
- onSelect: () => {
3774
- if (child.disabled) return;
3775
- setOpen(false);
3776
- onNavigate?.(child.id);
3763
+ classNames: {
3764
+ icon: "text-[inherit] [&_*]:!text-[inherit] [&_svg]:!stroke-current",
3765
+ label: "text-[inherit] [&_*]:!text-[inherit]"
3777
3766
  },
3778
- children: [
3779
- 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,
3780
- /* @__PURE__ */ jsx("span", { className: "min-w-0 truncate", children: child.headbarLabel ?? child.label }),
3781
- child.trailing
3782
- ]
3783
- },
3784
- child.id
3785
- ))
3786
- }
3787
- ) })
3788
- ] });
3767
+ className: cn2(
3768
+ "max-w-[12rem] shrink-0 border shadow-none",
3769
+ compound && "!rounded-none !border-0 !bg-transparent",
3770
+ menuButtonRadiusClass,
3771
+ 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)))]"
3772
+ )
3773
+ }
3774
+ ) }),
3775
+ /* @__PURE__ */ jsx(DropdownMenu.Portal, { children: /* @__PURE__ */ jsx(
3776
+ DropdownMenu.Content,
3777
+ {
3778
+ align: "start",
3779
+ sideOffset: 5,
3780
+ onCloseAutoFocus: (event) => event.preventDefault(),
3781
+ onMouseEnter: openMenu,
3782
+ onMouseLeave: scheduleCloseMenu,
3783
+ className: cn2(
3784
+ "z-50 min-w-56 border p-1.5 animate-in fade-in-0 zoom-in-95",
3785
+ menuContentRadiusClass
3786
+ ),
3787
+ style: {
3788
+ background: "var(--monkeys-component-navigation-headbar-menu-background, hsl(var(--popover)))",
3789
+ borderColor: "var(--monkeys-component-navigation-headbar-menu-border-color, hsl(var(--border)))",
3790
+ color: "var(--monkeys-component-navigation-headbar-menu-foreground, hsl(var(--popover-foreground)))",
3791
+ boxShadow: "var(--monkeys-component-navigation-headbar-menu-shadow, 0 10px 15px -3px rgb(0 0 0 / 0.1))",
3792
+ backdropFilter: "blur(var(--monkeys-component-navigation-headbar-menu-backdrop-blur, 0px))"
3793
+ },
3794
+ children: item.children?.map((child) => /* @__PURE__ */ jsxs(
3795
+ DropdownMenu.Item,
3796
+ {
3797
+ disabled: child.disabled,
3798
+ className: cn2(
3799
+ "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)))]",
3800
+ menuItemRadiusClass
3801
+ ),
3802
+ style: getHeadbarItemStyle(
3803
+ child.id === activeItemId,
3804
+ useTokenRadius
3805
+ ),
3806
+ onSelect: () => {
3807
+ if (child.disabled) return;
3808
+ setOpen(false);
3809
+ onNavigate?.(child.id);
3810
+ },
3811
+ children: [
3812
+ 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,
3813
+ /* @__PURE__ */ jsx("span", { className: "min-w-0 truncate", children: child.headbarLabel ?? child.label }),
3814
+ child.trailing
3815
+ ]
3816
+ },
3817
+ child.id
3818
+ ))
3819
+ }
3820
+ ) })
3821
+ ]
3822
+ }
3823
+ );
3824
+ }
3825
+ function preventDisabledNavigationInteraction(event) {
3826
+ event.preventDefault();
3827
+ event.stopPropagation();
3789
3828
  }
3790
3829
  function NavigationHeadbarMenu({
3791
3830
  activeItemId,
@@ -3852,10 +3891,13 @@ function NavigationHeadbarMenu({
3852
3891
  "div",
3853
3892
  {
3854
3893
  "data-navigation-headbar-compound-item": item.id,
3894
+ "data-disabled": item.disabled || void 0,
3895
+ "aria-disabled": item.disabled || void 0,
3855
3896
  className: cn2(
3856
3897
  "inline-flex min-w-0 shrink-0 items-center gap-0 overflow-hidden border shadow-none",
3857
3898
  menuButtonRadiusClass,
3858
- 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)))]"
3899
+ 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)))]",
3900
+ item.disabled && "!cursor-not-allowed"
3859
3901
  ),
3860
3902
  style: getHeadbarCompoundStyle(isActive, useTokenRadius),
3861
3903
  children: [
@@ -3871,7 +3913,16 @@ function NavigationHeadbarMenu({
3871
3913
  "span",
3872
3914
  {
3873
3915
  "data-navigation-headbar-secondary-action": item.id,
3874
- className: "inline-flex min-w-0 shrink-0 items-center",
3916
+ "aria-disabled": item.disabled || void 0,
3917
+ ...item.disabled ? { inert: "" } : {},
3918
+ onClickCapture: item.disabled ? preventDisabledNavigationInteraction : void 0,
3919
+ onKeyDownCapture: item.disabled ? preventDisabledNavigationInteraction : void 0,
3920
+ onKeyUpCapture: item.disabled ? preventDisabledNavigationInteraction : void 0,
3921
+ onPointerDownCapture: item.disabled ? preventDisabledNavigationInteraction : void 0,
3922
+ className: cn2(
3923
+ "inline-flex min-w-0 shrink-0 items-center",
3924
+ item.disabled && "!cursor-not-allowed opacity-60"
3925
+ ),
3875
3926
  children: item.headbarSecondaryAction
3876
3927
  }
3877
3928
  )