cetec-design-system 3.4.0-0 → 3.5.1-0

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
@@ -9183,7 +9183,7 @@ function useListNavigation(context2, props) {
9183
9183
  const isCrossCloseKey = isCrossOrientationCloseKey(event.key, orientation, rtl, cols);
9184
9184
  const isParentCrossOpenKey = isCrossOrientationOpenKey(event.key, getParentOrientation(), rtl);
9185
9185
  const isMainKey = isMainOrientationKey(event.key, orientation);
9186
- const isNavigationKey = (nested ? isParentCrossOpenKey : isMainKey) || event.key === "Enter" || event.key.trim() === "";
9186
+ const isNavigationKey2 = (nested ? isParentCrossOpenKey : isMainKey) || event.key === "Enter" || event.key.trim() === "";
9187
9187
  if (virtual && open) {
9188
9188
  const rootNode = tree == null ? void 0 : tree.nodesRef.current.find((node) => node.parentId == null);
9189
9189
  const deepestNode = tree && rootNode ? getDeepestNode(tree.nodesRef.current, rootNode.id) : null;
@@ -9216,7 +9216,7 @@ function useListNavigation(context2, props) {
9216
9216
  if (!open && !openOnArrowKeyDown && isArrowKey) {
9217
9217
  return;
9218
9218
  }
9219
- if (isNavigationKey) {
9219
+ if (isNavigationKey2) {
9220
9220
  const isParentMainKey = isMainOrientationKey(event.key, getParentOrientation());
9221
9221
  keyRef.current = nested && isParentMainKey ? null : event.key;
9222
9222
  }
@@ -18338,6 +18338,52 @@ const hasMatchingItems = (children, filterContext) => {
18338
18338
  return true;
18339
18339
  });
18340
18340
  };
18341
+ const findSubMenuKeyPath = (children, target, trail = []) => {
18342
+ for (const childNode of Children.toArray(children)) {
18343
+ if (!isValidElement(childNode)) {
18344
+ continue;
18345
+ }
18346
+ const child = childNode;
18347
+ const componentType = getComponentType(child);
18348
+ const nextTrail = [...trail, String(child.key)];
18349
+ if (componentType === MENU_COMPONENT_TYPES.subMenu) {
18350
+ if (child.props.children === target) {
18351
+ return nextTrail;
18352
+ }
18353
+ const nested = findSubMenuKeyPath(
18354
+ child.props.children,
18355
+ target,
18356
+ nextTrail
18357
+ );
18358
+ if (nested) {
18359
+ return nested;
18360
+ }
18361
+ } else if (componentType === MENU_COMPONENT_TYPES.group) {
18362
+ const nested = findSubMenuKeyPath(
18363
+ child.props.children,
18364
+ target,
18365
+ nextTrail
18366
+ );
18367
+ if (nested) {
18368
+ return nested;
18369
+ }
18370
+ }
18371
+ }
18372
+ return null;
18373
+ };
18374
+ const findSubMenuChildren = (children, keyPath) => {
18375
+ const [key, ...rest] = keyPath;
18376
+ if (key === void 0) {
18377
+ return children;
18378
+ }
18379
+ const match = Children.toArray(children).find(
18380
+ (childNode) => isValidElement(childNode) && String(childNode.key) === key
18381
+ );
18382
+ if (!match) {
18383
+ return void 0;
18384
+ }
18385
+ return findSubMenuChildren(match.props.children, rest);
18386
+ };
18341
18387
  const getHighlightedTextParts = (value, query) => {
18342
18388
  if (!query.trim()) {
18343
18389
  return [{ text: value, match: false }];
@@ -18402,6 +18448,8 @@ function navigateListMainAxisLoop(listRef, direction, previousIndex) {
18402
18448
  }
18403
18449
  return previousIndex ?? null;
18404
18450
  }
18451
+ const focusableInLevelSelector = 'input:not([disabled]),select:not([disabled]),textarea:not([disabled]),button:not([disabled]),a[href],[tabindex]:not([tabindex="-1"])';
18452
+ const isTextEntryTarget = (target) => target instanceof HTMLElement && (target.isContentEditable || target instanceof HTMLTextAreaElement || target instanceof HTMLSelectElement || target instanceof HTMLInputElement && !["button", "checkbox", "submit", "reset"].includes(target.type));
18405
18453
  const defaultGetItemText = ({
18406
18454
  label: label2,
18407
18455
  description
@@ -18509,6 +18557,7 @@ const Menu = (props) => {
18509
18557
  }
18510
18558
  onOpenChange == null ? void 0 : onOpenChange(nextOpen);
18511
18559
  };
18560
+ const diginFocusIntentRef = useRef(null);
18512
18561
  const [diginLevels, setDiginLevels] = useState([]);
18513
18562
  const [wrapperSize, setWrapperSize] = useState({
18514
18563
  width: null,
@@ -18551,7 +18600,10 @@ const Menu = (props) => {
18551
18600
  const focus = useFocus(floating.context, {
18552
18601
  enabled: hasReference && triggerInteraction === "focus"
18553
18602
  });
18554
- const dismiss = useDismiss(floating.context, { enabled: hasReference });
18603
+ const dismiss = useDismiss(floating.context, {
18604
+ enabled: hasReference,
18605
+ escapeKey: diginDepth === 0
18606
+ });
18555
18607
  const role = useRole(floating.context, { role: "menu" });
18556
18608
  const listNavigation = useListNavigation(floating.context, {
18557
18609
  listRef,
@@ -18577,7 +18629,11 @@ const Menu = (props) => {
18577
18629
  }),
18578
18630
  [filterMode, getItemText, highlightMatches, query]
18579
18631
  );
18580
- const activeLevelChildren = ((_a = diginLevels[diginLevels.length - 1]) == null ? void 0 : _a.children) ?? children;
18632
+ const liveDiginLevels = diginLevels.map((level) => ({
18633
+ ...level,
18634
+ children: (level.path && findSubMenuChildren(children, level.path)) ?? level.children
18635
+ }));
18636
+ const activeLevelChildren = ((_a = liveDiginLevels[liveDiginLevels.length - 1]) == null ? void 0 : _a.children) ?? children;
18581
18637
  const hasVisibleResults = hasMatchingItems(
18582
18638
  activeLevelChildren,
18583
18639
  filterContextValue
@@ -18593,6 +18649,8 @@ const Menu = (props) => {
18593
18649
  setDiginLevels([]);
18594
18650
  },
18595
18651
  onPushDiginLevel: (title, levelChildren) => {
18652
+ const returnIndex = activeIndex;
18653
+ diginFocusIntentRef.current = "first";
18596
18654
  setDiginLevels((prev) => {
18597
18655
  const activeLevel2 = prev[prev.length - 1];
18598
18656
  if (activeLevel2 && activeLevel2.title === title && activeLevel2.children === levelChildren) {
@@ -18603,29 +18661,169 @@ const Menu = (props) => {
18603
18661
  {
18604
18662
  key: `${title}-${prev.length}`,
18605
18663
  title,
18606
- children: levelChildren
18664
+ children: levelChildren,
18665
+ returnIndex,
18666
+ path: findSubMenuKeyPath(children, levelChildren)
18607
18667
  }
18608
18668
  ];
18609
18669
  });
18610
18670
  },
18611
18671
  onPopDiginLevel: () => {
18672
+ const poppedLevel = diginLevels[diginLevels.length - 1];
18673
+ if (!poppedLevel) {
18674
+ return;
18675
+ }
18676
+ diginFocusIntentRef.current = { index: poppedLevel.returnIndex };
18612
18677
  setDiginLevels((prev) => prev.slice(0, -1));
18613
18678
  },
18614
18679
  diginDepth,
18615
18680
  onMenubarEdgeNavigate
18616
18681
  };
18682
+ useEffect(() => {
18683
+ const intent = diginFocusIntentRef.current;
18684
+ if (!intent) {
18685
+ return;
18686
+ }
18687
+ diginFocusIntentRef.current = null;
18688
+ setActiveIndex(null);
18689
+ let timer;
18690
+ const focusLevel = (attemptsLeft) => {
18691
+ var _a2;
18692
+ const levelElement = activeLevelRef.current;
18693
+ const index2 = intent === "first" ? findFirstEnabledListIndex(listRef) : intent.index;
18694
+ const item = index2 === null ? null : listRef.current[index2];
18695
+ if (item && item.isConnected && (levelElement == null ? void 0 : levelElement.contains(item)) && !item.hasAttribute("disabled")) {
18696
+ item.focus({ preventScroll: true });
18697
+ (_a2 = item.scrollIntoView) == null ? void 0 : _a2.call(item, { block: "nearest" });
18698
+ setActiveIndex(index2);
18699
+ return;
18700
+ }
18701
+ if (attemptsLeft > 0) {
18702
+ timer = setTimeout(() => focusLevel(attemptsLeft - 1), 16);
18703
+ return;
18704
+ }
18705
+ const focusables = Array.from(
18706
+ (levelElement == null ? void 0 : levelElement.querySelectorAll(focusableInLevelSelector)) ?? []
18707
+ );
18708
+ const fallback = focusables.find((element) => !element.matches("[data-menu-back]")) ?? focusables[0];
18709
+ fallback == null ? void 0 : fallback.focus({ preventScroll: true });
18710
+ };
18711
+ timer = setTimeout(() => focusLevel(3), 0);
18712
+ return () => {
18713
+ clearTimeout(timer);
18714
+ };
18715
+ }, [diginDepth]);
18716
+ const keepsFocusOnTrigger = Boolean(onMenubarEdgeNavigate) || triggerInteraction === "focus";
18717
+ useEffect(() => {
18718
+ if (!hasReference || !isOpen || activeIndex === null || keepsFocusOnTrigger) {
18719
+ return;
18720
+ }
18721
+ const timer = setTimeout(() => {
18722
+ const referenceElement = floating.elements.domReference;
18723
+ const floatingElement = floating.elements.floating;
18724
+ const activeElement2 = document.activeElement;
18725
+ const focusIsStranded = Boolean(referenceElement) && (activeElement2 === referenceElement || activeElement2 === document.body);
18726
+ const item = listRef.current[activeIndex];
18727
+ if (focusIsStranded && (item == null ? void 0 : item.isConnected) && (floatingElement == null ? void 0 : floatingElement.contains(item))) {
18728
+ item.focus({ preventScroll: true });
18729
+ }
18730
+ }, 50);
18731
+ return () => {
18732
+ clearTimeout(timer);
18733
+ };
18734
+ }, [
18735
+ activeIndex,
18736
+ floating.elements.domReference,
18737
+ floating.elements.floating,
18738
+ hasReference,
18739
+ isOpen,
18740
+ keepsFocusOnTrigger
18741
+ ]);
18742
+ const isComposingRef = useRef(false);
18743
+ useEffect(() => {
18744
+ let compositionTimeout;
18745
+ const handleCompositionStart = () => {
18746
+ clearTimeout(compositionTimeout);
18747
+ isComposingRef.current = true;
18748
+ };
18749
+ const handleCompositionEnd = () => {
18750
+ compositionTimeout = setTimeout(() => {
18751
+ isComposingRef.current = false;
18752
+ }, 5);
18753
+ };
18754
+ document.addEventListener("compositionstart", handleCompositionStart);
18755
+ document.addEventListener("compositionend", handleCompositionEnd);
18756
+ return () => {
18757
+ clearTimeout(compositionTimeout);
18758
+ document.removeEventListener("compositionstart", handleCompositionStart);
18759
+ document.removeEventListener("compositionend", handleCompositionEnd);
18760
+ };
18761
+ }, []);
18762
+ useEffect(() => {
18763
+ if (diginDepth === 0) {
18764
+ return;
18765
+ }
18766
+ const handleEscape = (event) => {
18767
+ if (event.key !== "Escape" || event.defaultPrevented || event.isComposing || isComposingRef.current) {
18768
+ return;
18769
+ }
18770
+ const activeElement2 = document.activeElement;
18771
+ const referenceElement = floating.elements.domReference;
18772
+ const floatingElement = floating.elements.floating;
18773
+ const focusIsInMenu = hasReference && activeElement2 === document.body || Boolean(floatingElement == null ? void 0 : floatingElement.contains(activeElement2)) || Boolean(referenceElement == null ? void 0 : referenceElement.contains(activeElement2));
18774
+ if (!focusIsInMenu) {
18775
+ return;
18776
+ }
18777
+ event.preventDefault();
18778
+ event.stopPropagation();
18779
+ rootContextValue.onPopDiginLevel();
18780
+ };
18781
+ document.addEventListener("keydown", handleEscape);
18782
+ return () => {
18783
+ document.removeEventListener("keydown", handleEscape);
18784
+ };
18785
+ });
18786
+ const handleLevelsKeyDown = (event) => {
18787
+ if (event.key !== "Escape" && event.key !== "Tab" && isTextEntryTarget(event.target)) {
18788
+ event.stopPropagation();
18789
+ }
18790
+ };
18791
+ const handleDiginKeyDown = (event) => {
18792
+ if (diginDepth > 0 && event.key === "ArrowLeft" && !event.defaultPrevented) {
18793
+ event.preventDefault();
18794
+ event.stopPropagation();
18795
+ rootContextValue.onPopDiginLevel();
18796
+ }
18797
+ };
18617
18798
  const navigateMainAxis = useCallback((direction) => {
18618
18799
  setActiveIndex(
18619
18800
  (prev) => navigateListMainAxisLoop(listRef, direction, prev)
18620
18801
  );
18621
18802
  }, []);
18803
+ const [firstEnabledIndex, setFirstEnabledIndex] = useState(
18804
+ null
18805
+ );
18806
+ useEffect(() => {
18807
+ let cancelled = false;
18808
+ queueMicrotask(() => {
18809
+ if (cancelled) {
18810
+ return;
18811
+ }
18812
+ const next = findFirstEnabledListIndex(listRef);
18813
+ setFirstEnabledIndex((previous) => previous === next ? previous : next);
18814
+ });
18815
+ return () => {
18816
+ cancelled = true;
18817
+ };
18818
+ });
18622
18819
  const menuListContextValue = {
18623
18820
  activeIndex,
18821
+ tabbableIndex: activeIndex ?? firstEnabledIndex,
18624
18822
  getItemProps: (userProps) => getItemProps(userProps),
18625
18823
  navigateMainAxis,
18626
18824
  nestedMenuDepth: 0
18627
18825
  };
18628
- const levels = [{ key: "root", title: "Menu", children }, ...diginLevels];
18826
+ const levels = [{ key: "root", title: "Menu", children }, ...liveDiginLevels];
18629
18827
  const activeLevel = levels[Math.min(diginDepth, levels.length - 1)];
18630
18828
  const levelCount = levels.length;
18631
18829
  const trackWidthPercent = levelCount * 100;
@@ -18691,6 +18889,10 @@ const Menu = (props) => {
18691
18889
  isMenuVisible,
18692
18890
  shouldUseDiginSizing
18693
18891
  ]);
18892
+ useLayoutEffect(() => {
18893
+ var _a2;
18894
+ (_a2 = sizeProbeRef.current) == null ? void 0 : _a2.querySelectorAll("[id]").forEach((element) => element.removeAttribute("id"));
18895
+ });
18694
18896
  const diginWrapperStyle = shouldUseDiginSizing && wrapperSize.width && wrapperSize.height ? {
18695
18897
  width: `${wrapperSize.width}px`,
18696
18898
  height: `${wrapperSize.height}px`
@@ -18707,120 +18909,130 @@ const Menu = (props) => {
18707
18909
  ...dsComponent("Menu"),
18708
18910
  ref: floating.refs.setFloating,
18709
18911
  className: cx(classes.wrapper, className),
18710
- ...getFloatingProps(),
18912
+ ...getFloatingProps({ onKeyDown: handleDiginKeyDown }),
18711
18913
  ...otherProps,
18712
18914
  style: floatingStyle,
18713
18915
  children: [
18714
18916
  !hasVisibleResults && /* @__PURE__ */ jsx(Box, { className: classes.noResults, children: renderNoResults ?? /* @__PURE__ */ jsx(Text, { textStyle: "body.sm", children: "No results found" }) }),
18715
- hasVisibleResults && /* @__PURE__ */ jsxs(Box, { className: classes.levelsViewport, children: [
18716
- shouldUseDiginSizing && /* @__PURE__ */ jsx(
18717
- Box,
18718
- {
18719
- ref: sizeProbeRef,
18720
- className: classes.sizeProbe,
18721
- "aria-hidden": true,
18722
- style: diginSizeProbeStyle,
18723
- children: /* @__PURE__ */ jsxs(Box, { className: classes.level, children: [
18724
- diginDepth > 0 && /* @__PURE__ */ jsxs(
18725
- Box,
18726
- {
18727
- as: "button",
18728
- type: "button",
18729
- className: classes.backHeader,
18730
- children: [
18731
- /* @__PURE__ */ jsx(Icon, { name: "caret-left", fill: "icon" }),
18732
- activeLevel.title
18733
- ]
18734
- }
18735
- ),
18736
- /* @__PURE__ */ jsx(Box, { className: listClassName, children: withLevelScopedKeys(
18737
- activeLevel.children,
18738
- `${activeLevel.key}-probe`
18739
- ) })
18740
- ] })
18741
- }
18742
- ),
18743
- /* @__PURE__ */ jsx(
18744
- Box,
18745
- {
18746
- className: classes.levelsTrack,
18747
- style: {
18748
- width: `${trackWidthPercent}%`,
18749
- transform: `translateX(-${trackTranslatePercent}%)`
18750
- },
18751
- children: levels.map((level, index2) => {
18752
- const isActiveLevel = index2 === diginDepth;
18753
- const levelChildren = withLevelScopedKeys(
18754
- level.children,
18755
- level.key
18756
- );
18757
- if (!isActiveLevel) {
18758
- return /* @__PURE__ */ jsxs(
18759
- Box,
18760
- {
18761
- className: classes.level,
18762
- style: {
18763
- flex: `0 0 ${levelWidthPercent}%`
18764
- },
18765
- "aria-hidden": true,
18766
- children: [
18767
- index2 > 0 && /* @__PURE__ */ jsxs(
18768
- Box,
18769
- {
18770
- as: "button",
18771
- type: "button",
18772
- className: classes.backHeader,
18773
- onClick: rootContextValue.onPopDiginLevel,
18774
- children: [
18775
- /* @__PURE__ */ jsx(Icon, { name: "caret-left" }),
18776
- level.title
18777
- ]
18778
- }
18779
- ),
18780
- /* @__PURE__ */ jsx(Box, { className: listClassName, children: levelChildren })
18781
- ]
18782
- },
18783
- level.key
18784
- );
18785
- }
18786
- return /* @__PURE__ */ jsx(
18787
- MenuListProvider,
18788
- {
18789
- value: menuListContextValue,
18790
- children: /* @__PURE__ */ jsx(FloatingList, { elementsRef: listRef, labelsRef, children: /* @__PURE__ */ jsxs(
18917
+ hasVisibleResults && /* @__PURE__ */ jsxs(
18918
+ Box,
18919
+ {
18920
+ className: classes.levelsViewport,
18921
+ onKeyDown: handleLevelsKeyDown,
18922
+ children: [
18923
+ shouldUseDiginSizing && /* @__PURE__ */ jsx(
18924
+ Box,
18925
+ {
18926
+ ref: sizeProbeRef,
18927
+ className: classes.sizeProbe,
18928
+ "aria-hidden": true,
18929
+ inert: true,
18930
+ style: diginSizeProbeStyle,
18931
+ children: /* @__PURE__ */ jsxs(Box, { className: classes.level, children: [
18932
+ diginDepth > 0 && /* @__PURE__ */ jsxs(
18791
18933
  Box,
18792
18934
  {
18793
- ref: activeLevelRef,
18794
- className: classes.level,
18795
- style: {
18796
- flex: `0 0 ${levelWidthPercent}%`
18797
- },
18935
+ as: "button",
18936
+ type: "button",
18937
+ className: classes.backHeader,
18798
18938
  children: [
18799
- index2 > 0 && /* @__PURE__ */ jsxs(
18800
- Box,
18801
- {
18802
- as: "button",
18803
- type: "button",
18804
- ref: activeBackHeaderRef,
18805
- className: classes.backHeader,
18806
- onClick: rootContextValue.onPopDiginLevel,
18807
- children: [
18808
- /* @__PURE__ */ jsx(Icon, { name: "caret-left" }),
18809
- level.title
18810
- ]
18811
- }
18812
- ),
18813
- /* @__PURE__ */ jsx(Box, { className: listClassName, children: levelChildren })
18939
+ /* @__PURE__ */ jsx(Icon, { name: "caret-left", fill: "icon" }),
18940
+ activeLevel.title
18814
18941
  ]
18815
18942
  }
18943
+ ),
18944
+ /* @__PURE__ */ jsx(Box, { className: listClassName, children: withLevelScopedKeys(
18945
+ activeLevel.children,
18946
+ `${activeLevel.key}-probe`
18816
18947
  ) })
18948
+ ] })
18949
+ }
18950
+ ),
18951
+ /* @__PURE__ */ jsx(
18952
+ Box,
18953
+ {
18954
+ className: classes.levelsTrack,
18955
+ style: {
18956
+ width: `${trackWidthPercent}%`,
18957
+ transform: `translateX(-${trackTranslatePercent}%)`
18817
18958
  },
18818
- level.key
18819
- );
18820
- })
18821
- }
18822
- )
18823
- ] })
18959
+ children: levels.map((level, index2) => {
18960
+ const isActiveLevel = index2 === diginDepth;
18961
+ const levelChildren = withLevelScopedKeys(
18962
+ level.children,
18963
+ level.key
18964
+ );
18965
+ if (!isActiveLevel) {
18966
+ return /* @__PURE__ */ jsxs(
18967
+ Box,
18968
+ {
18969
+ className: classes.level,
18970
+ style: {
18971
+ flex: `0 0 ${levelWidthPercent}%`
18972
+ },
18973
+ "aria-hidden": true,
18974
+ inert: true,
18975
+ children: [
18976
+ index2 > 0 && /* @__PURE__ */ jsxs(
18977
+ Box,
18978
+ {
18979
+ as: "button",
18980
+ type: "button",
18981
+ className: classes.backHeader,
18982
+ onClick: rootContextValue.onPopDiginLevel,
18983
+ children: [
18984
+ /* @__PURE__ */ jsx(Icon, { name: "caret-left" }),
18985
+ level.title
18986
+ ]
18987
+ }
18988
+ ),
18989
+ /* @__PURE__ */ jsx(Box, { className: listClassName, children: levelChildren })
18990
+ ]
18991
+ },
18992
+ level.key
18993
+ );
18994
+ }
18995
+ return /* @__PURE__ */ jsx(
18996
+ MenuListProvider,
18997
+ {
18998
+ value: menuListContextValue,
18999
+ children: /* @__PURE__ */ jsx(FloatingList, { elementsRef: listRef, labelsRef, children: /* @__PURE__ */ jsxs(
19000
+ Box,
19001
+ {
19002
+ ref: activeLevelRef,
19003
+ className: classes.level,
19004
+ style: {
19005
+ flex: `0 0 ${levelWidthPercent}%`
19006
+ },
19007
+ children: [
19008
+ index2 > 0 && /* @__PURE__ */ jsxs(
19009
+ Box,
19010
+ {
19011
+ as: "button",
19012
+ type: "button",
19013
+ ref: activeBackHeaderRef,
19014
+ "data-menu-back": "",
19015
+ className: classes.backHeader,
19016
+ onClick: rootContextValue.onPopDiginLevel,
19017
+ children: [
19018
+ /* @__PURE__ */ jsx(Icon, { name: "caret-left" }),
19019
+ level.title
19020
+ ]
19021
+ }
19022
+ ),
19023
+ /* @__PURE__ */ jsx(Box, { className: listClassName, children: levelChildren })
19024
+ ]
19025
+ }
19026
+ ) })
19027
+ },
19028
+ level.key
19029
+ );
19030
+ })
19031
+ }
19032
+ )
19033
+ ]
19034
+ }
19035
+ )
18824
19036
  ]
18825
19037
  }
18826
19038
  ) }) });
@@ -19143,6 +19355,12 @@ const MenuItem = (props) => {
19143
19355
  };
19144
19356
  const { onKeyDown: itemOnKeyDown, ...itemPropsRest } = itemProps;
19145
19357
  const handleItemKeyDown = (event) => {
19358
+ if (event.key === "ArrowLeft" && rootContext.diginDepth > 0 && ((listContext == null ? void 0 : listContext.nestedMenuDepth) ?? 0) === 0) {
19359
+ event.preventDefault();
19360
+ event.stopPropagation();
19361
+ rootContext.onPopDiginLevel();
19362
+ return;
19363
+ }
19146
19364
  if (event.key === "ArrowLeft" || event.key === "ArrowRight") {
19147
19365
  if (href) {
19148
19366
  itemOnKeyDown == null ? void 0 : itemOnKeyDown(event);
@@ -19204,7 +19422,7 @@ const MenuItem = (props) => {
19204
19422
  "data-selected": selected,
19205
19423
  "data-disabled": disabled,
19206
19424
  "data-active": listContext ? listContext.activeIndex === listItemData.index : false,
19207
- tabIndex: listContext ? listContext.activeIndex === listItemData.index ? 0 : -1 : 0,
19425
+ tabIndex: listContext ? (listContext.tabbableIndex ?? listContext.activeIndex) === listItemData.index ? 0 : -1 : 0,
19208
19426
  ...itemPropsRest,
19209
19427
  onKeyDown: handleItemKeyDown,
19210
19428
  ...restProps,
@@ -19444,7 +19662,7 @@ const SubMenu = (props) => {
19444
19662
  return true;
19445
19663
  };
19446
19664
  if (!applyFirst()) {
19447
- requestAnimationFrame(() => {
19665
+ setTimeout(() => {
19448
19666
  if (!applyFirst()) {
19449
19667
  openedFromParentArrowRightRef.current = false;
19450
19668
  }
@@ -19613,7 +19831,7 @@ const SubMenu = (props) => {
19613
19831
  "data-selected": selected,
19614
19832
  "data-disabled": disabled,
19615
19833
  "data-active": parentListContext ? parentListContext.activeIndex === listItemData.index : false,
19616
- tabIndex: parentListContext ? parentListContext.activeIndex === listItemData.index ? 0 : -1 : 0,
19834
+ tabIndex: parentListContext ? (parentListContext.tabbableIndex ?? parentListContext.activeIndex) === listItemData.index ? 0 : -1 : 0,
19617
19835
  ...diginButtonProps,
19618
19836
  type: "button",
19619
19837
  children: [
@@ -19674,7 +19892,7 @@ const SubMenu = (props) => {
19674
19892
  "data-selected": selected,
19675
19893
  "data-disabled": disabled,
19676
19894
  "data-active": parentListContext ? parentListContext.activeIndex === listItemData.index : false,
19677
- tabIndex: parentListContext ? parentListContext.activeIndex === listItemData.index ? 0 : -1 : 0,
19895
+ tabIndex: parentListContext ? (parentListContext.tabbableIndex ?? parentListContext.activeIndex) === listItemData.index ? 0 : -1 : 0,
19678
19896
  ...referencePropsWithoutRef,
19679
19897
  type: "button",
19680
19898
  children: [
@@ -23193,6 +23411,8 @@ const isSelectOptionElement = (child) => {
23193
23411
  const getOptionText = (option) => {
23194
23412
  return option.props.label;
23195
23413
  };
23414
+ const NAVIGATION_KEYS = /* @__PURE__ */ new Set(["ArrowUp", "ArrowDown", "Home", "End"]);
23415
+ const isNavigationKey = (event) => NAVIGATION_KEYS.has(event.key) || event.key.length === 1 && !event.ctrlKey && !event.metaKey && !event.altKey;
23196
23416
  const getSelectedDisplay = (options, value, multiple, placeholder) => {
23197
23417
  if (value === null || value === void 0 || value === "") {
23198
23418
  return placeholder;
@@ -23252,9 +23472,12 @@ const Select = (props) => {
23252
23472
  const [internalOpen, setInternalOpen] = useState(defaultOpen);
23253
23473
  const [internalValue, setInternalValue] = useState(defaultValue);
23254
23474
  const [activeIndex, setActiveIndex] = useState(null);
23475
+ const [hasNavigated, setHasNavigated] = useState(false);
23476
+ const [openedByKeyboard, setOpenedByKeyboard] = useState(false);
23255
23477
  const isOpenControlled = controlledOpen !== void 0;
23256
23478
  const isOpen = isOpenControlled ? controlledOpen : internalOpen;
23257
23479
  const value = controlledValue !== void 0 ? controlledValue : internalValue;
23480
+ const [prevIsOpen, setPrevIsOpen] = useState(isOpen);
23258
23481
  const options = useMemo(() => {
23259
23482
  return Children.toArray(children).filter(isSelectOptionElement);
23260
23483
  }, [children]);
@@ -23285,10 +23508,15 @@ const Select = (props) => {
23285
23508
  );
23286
23509
  }, [options]);
23287
23510
  const initialActiveIndex = selectedIndex >= 0 ? selectedIndex : firstEnabledIndex >= 0 ? firstEnabledIndex : null;
23288
- const resolvedActiveIndex = isOpen ? activeIndex ?? initialActiveIndex : null;
23511
+ if (isOpen !== prevIsOpen) {
23512
+ setPrevIsOpen(isOpen);
23513
+ setActiveIndex(isOpen ? initialActiveIndex : null);
23514
+ setHasNavigated(isOpen && openedByKeyboard);
23515
+ setOpenedByKeyboard(false);
23516
+ }
23517
+ const resolvedActiveIndex = isOpen ? activeIndex ?? (hasNavigated ? null : initialActiveIndex) : null;
23289
23518
  const activeOptionId = resolvedActiveIndex !== null ? `${triggerId}-option-${resolvedActiveIndex}` : void 0;
23290
23519
  const setOpenState = (nextOpen) => {
23291
- setActiveIndex(nextOpen ? initialActiveIndex : null);
23292
23520
  if (!isOpenControlled) {
23293
23521
  setInternalOpen(nextOpen);
23294
23522
  }
@@ -23376,6 +23604,7 @@ const Select = (props) => {
23376
23604
  }
23377
23605
  if (!isOpen && (event.key === "ArrowDown" || event.key === "ArrowUp" || event.key === "Enter" || event.key === " ")) {
23378
23606
  event.preventDefault();
23607
+ setOpenedByKeyboard(true);
23379
23608
  setOpenState(true);
23380
23609
  }
23381
23610
  if (!multiple && hasValue && (event.key === "Backspace" || event.key === "Delete")) {
@@ -23505,10 +23734,26 @@ const Select = (props) => {
23505
23734
  density,
23506
23735
  className: menuClasses.wrapper,
23507
23736
  style: floating.floatingStyles,
23508
- ...getFloatingProps(),
23737
+ ...getFloatingProps({
23738
+ // floating-ui also reports `onNavigate` while opening, so
23739
+ // only real input on the list counts as the user pointing
23740
+ // at a row. Option events bubble here, and the listbox
23741
+ // itself holds focus after the pointer leaves the options.
23742
+ onKeyDown: (event) => {
23743
+ if (isNavigationKey(event)) {
23744
+ setHasNavigated(true);
23745
+ }
23746
+ },
23747
+ onPointerMove: (event) => {
23748
+ if (event.pointerType !== "touch") {
23749
+ setHasNavigated(true);
23750
+ }
23751
+ }
23752
+ }),
23509
23753
  children: options.map((option, index2) => {
23510
23754
  const optionLabel = getOptionText(option);
23511
23755
  const isSelected = multiple ? selectedValueSet.has(option.props.value) : value === option.props.value;
23756
+ const isPointed = !option.props.disabled && hasNavigated && activeIndex === index2;
23512
23757
  return /* @__PURE__ */ jsx(
23513
23758
  ListItem,
23514
23759
  {
@@ -23522,7 +23767,7 @@ const Select = (props) => {
23522
23767
  variant: multiple ? "checkbox" : "default",
23523
23768
  label: optionLabel,
23524
23769
  description: option.props.description,
23525
- iconBefore: !multiple ? option.props.iconLeft ?? "check" : option.props.iconLeft,
23770
+ iconBefore: !multiple ? isSelected && isPointed ? "x" : option.props.iconLeft ?? "check" : option.props.iconLeft,
23526
23771
  iconBeforeFill: !multiple ? isSelected ? "icon" : option.props.iconLeft ? void 0 : "transparent" : void 0,
23527
23772
  iconAfter: option.props.iconRight,
23528
23773
  ...getItemProps({