@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.js CHANGED
@@ -16634,6 +16634,7 @@ function HeadbarNavMenuItem({
16634
16634
  }) {
16635
16635
  const [open, setOpen] = React2.useState(false);
16636
16636
  const closeTimerRef = React2.useRef(null);
16637
+ const wasOpenOnPointerDownRef = React2.useRef(false);
16637
16638
  const clearCloseTimer = () => {
16638
16639
  if (!closeTimerRef.current) return;
16639
16640
  clearTimeout(closeTimerRef.current);
@@ -16650,6 +16651,13 @@ function HeadbarNavMenuItem({
16650
16651
  closeTimerRef.current = null;
16651
16652
  }, 120);
16652
16653
  };
16654
+ const navigateToFirstEnabledChild = () => {
16655
+ const firstEnabledChild = item.children?.find((child) => !child.disabled);
16656
+ if (!firstEnabledChild) return false;
16657
+ setOpen(false);
16658
+ onNavigate?.(firstEnabledChild.id);
16659
+ return true;
16660
+ };
16653
16661
  React2.useEffect(() => clearCloseTimer, []);
16654
16662
  return /* @__PURE__ */ jsxRuntime.jsxs(DropdownMenu2__namespace.Root, { modal: false, open, onOpenChange: setOpen, children: [
16655
16663
  /* @__PURE__ */ jsxRuntime.jsx(DropdownMenu2__namespace.Trigger, { asChild: true, children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -16662,7 +16670,22 @@ function HeadbarNavMenuItem({
16662
16670
  endIcon: /* @__PURE__ */ jsxRuntime.jsx(HeadbarChevronIcon, { open }),
16663
16671
  label: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "truncate whitespace-nowrap", children: label }),
16664
16672
  disabled: item.disabled,
16665
- onClick: () => setOpen(true),
16673
+ onClick: () => {
16674
+ const wasOpenOnPointerDown = wasOpenOnPointerDownRef.current;
16675
+ wasOpenOnPointerDownRef.current = false;
16676
+ if (wasOpenOnPointerDown && navigateToFirstEnabledChild()) return;
16677
+ setOpen(true);
16678
+ },
16679
+ onPointerDown: () => {
16680
+ wasOpenOnPointerDownRef.current = open;
16681
+ },
16682
+ onPointerCancel: () => {
16683
+ wasOpenOnPointerDownRef.current = false;
16684
+ },
16685
+ onKeyDown: (event) => {
16686
+ if (!open || event.key !== "Enter" && event.key !== " ") return;
16687
+ if (navigateToFirstEnabledChild()) event.preventDefault();
16688
+ },
16666
16689
  onMouseEnter: openMenu,
16667
16690
  onMouseLeave: scheduleCloseMenu,
16668
16691
  style: getHeadbarItemStyle(isActive || open, useTokenRadius),
@@ -16701,7 +16724,7 @@ function HeadbarNavMenuItem({
16701
16724
  {
16702
16725
  disabled: child.disabled,
16703
16726
  className: cn2(
16704
- "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)))]",
16727
+ "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)))]",
16705
16728
  menuItemRadiusClass
16706
16729
  ),
16707
16730
  style: getHeadbarItemStyle(