@inf-monkeys-tech/monkeys-design 1.0.18 → 1.0.19

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
@@ -16599,6 +16599,7 @@ function HeadbarNavMenuItem({
16599
16599
  }) {
16600
16600
  const [open, setOpen] = useState(false);
16601
16601
  const closeTimerRef = useRef(null);
16602
+ const wasOpenOnPointerDownRef = useRef(false);
16602
16603
  const clearCloseTimer = () => {
16603
16604
  if (!closeTimerRef.current) return;
16604
16605
  clearTimeout(closeTimerRef.current);
@@ -16615,6 +16616,13 @@ function HeadbarNavMenuItem({
16615
16616
  closeTimerRef.current = null;
16616
16617
  }, 120);
16617
16618
  };
16619
+ const navigateToFirstEnabledChild = () => {
16620
+ const firstEnabledChild = item.children?.find((child) => !child.disabled);
16621
+ if (!firstEnabledChild) return false;
16622
+ setOpen(false);
16623
+ onNavigate?.(firstEnabledChild.id);
16624
+ return true;
16625
+ };
16618
16626
  useEffect(() => clearCloseTimer, []);
16619
16627
  return /* @__PURE__ */ jsxs(DropdownMenu2.Root, { modal: false, open, onOpenChange: setOpen, children: [
16620
16628
  /* @__PURE__ */ jsx(DropdownMenu2.Trigger, { asChild: true, children: /* @__PURE__ */ jsx(
@@ -16627,7 +16635,22 @@ function HeadbarNavMenuItem({
16627
16635
  endIcon: /* @__PURE__ */ jsx(HeadbarChevronIcon, { open }),
16628
16636
  label: /* @__PURE__ */ jsx("span", { className: "truncate whitespace-nowrap", children: label }),
16629
16637
  disabled: item.disabled,
16630
- onClick: () => setOpen(true),
16638
+ onClick: () => {
16639
+ const wasOpenOnPointerDown = wasOpenOnPointerDownRef.current;
16640
+ wasOpenOnPointerDownRef.current = false;
16641
+ if (wasOpenOnPointerDown && navigateToFirstEnabledChild()) return;
16642
+ setOpen(true);
16643
+ },
16644
+ onPointerDown: () => {
16645
+ wasOpenOnPointerDownRef.current = open;
16646
+ },
16647
+ onPointerCancel: () => {
16648
+ wasOpenOnPointerDownRef.current = false;
16649
+ },
16650
+ onKeyDown: (event) => {
16651
+ if (!open || event.key !== "Enter" && event.key !== " ") return;
16652
+ if (navigateToFirstEnabledChild()) event.preventDefault();
16653
+ },
16631
16654
  onMouseEnter: openMenu,
16632
16655
  onMouseLeave: scheduleCloseMenu,
16633
16656
  style: getHeadbarItemStyle(isActive || open, useTokenRadius),
@@ -16666,7 +16689,7 @@ function HeadbarNavMenuItem({
16666
16689
  {
16667
16690
  disabled: child.disabled,
16668
16691
  className: cn2(
16669
- "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)))]",
16692
+ "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)))] focus:bg-[var(--monkeys-component-navigation-headbar-item-hover-background,hsl(var(--accent)))] [&[data-highlighted]]:bg-[var(--monkeys-component-navigation-headbar-item-hover-background,hsl(var(--accent)))]",
16670
16693
  menuItemRadiusClass
16671
16694
  ),
16672
16695
  style: getHeadbarItemStyle(