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