@meetreeve/ui 0.16.0 → 0.17.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.d.mts CHANGED
@@ -462,6 +462,20 @@ declare function reconcileLadder(ladder: SidebarLadder, registry: FallbackModule
462
462
  */
463
463
  declare function resolveLadder(raw: unknown, registry: FallbackModuleDef[], groupOrder: string[]): SidebarLadder;
464
464
 
465
+ /**
466
+ * DEV-13848: how long a hover-opened panel survives the pointer leaving it.
467
+ * It used to close on the very first `mouseleave`, so crossing the gap or
468
+ * cutting diagonally toward a lower row shut it — "a narrow gate" (Matt).
469
+ */
470
+ declare const HOVER_CLOSE_DELAY_MS = 300;
471
+ /**
472
+ * DEV-13848: hover intent for SWITCHING groups. A diagonal path from one
473
+ * group's trigger to the lower rows of its panel passes over the next
474
+ * group's trigger; opening that one instantly force-closed the panel the
475
+ * user was heading for. AppSidebar passes this as `hoverOpenDelayMs` while a
476
+ * sibling is open, so a pointer merely passing through never claims the slot.
477
+ */
478
+ declare const HOVER_SWITCH_DELAY_MS = 150;
465
479
  interface FlyoutChild {
466
480
  moduleId: string;
467
481
  label: string;
@@ -509,6 +523,12 @@ interface FlyoutProps {
509
523
  */
510
524
  onOpenChange?: (open: boolean) => void;
511
525
  forceClosed?: boolean;
526
+ /**
527
+ * DEV-13848: delay before a HOVER opens this instance (clicks stay
528
+ * instant); leaving before it elapses cancels the open. Default 0. A
529
+ * coordinator sets it while a sibling is open — see HOVER_SWITCH_DELAY_MS.
530
+ */
531
+ hoverOpenDelayMs?: number;
512
532
  className?: string;
513
533
  }
514
534
  /**
@@ -546,7 +566,7 @@ interface FlyoutProps {
546
566
  * than working around it. jsdom never computes real scrollable-overflow
547
567
  * geometry, so no unit test caught this — only an actual browser render did.
548
568
  */
549
- declare function Flyout({ label, icon, active, children, linkComponent, collapsed, onOpenChange, forceClosed, className, }: FlyoutProps): react.JSX.Element;
569
+ declare function Flyout({ label, icon, active, children, linkComponent, collapsed, onOpenChange, forceClosed, hoverOpenDelayMs, className, }: FlyoutProps): react.JSX.Element;
550
570
 
551
571
  /**
552
572
  * ContextSwitcher (DEV-4408) — promoted out of reeve-frontend's
@@ -925,4 +945,4 @@ interface ConnectorPickerProps {
925
945
  }
926
946
  declare function ConnectorPicker({ client, purpose, lens, layout, onConnected, }: ConnectorPickerProps): react.JSX.Element | null;
927
947
 
928
- export { type AppRungItem, AppSidebar, type AppSidebarBrand, type AppSidebarModuleDef, type AppSidebarProps, type AppSidebarTopItem, type Brand, BrandGlyph, type BrandGlyphProps, type ConnectableAccess, type ConnectableCapability, type ConnectableEntry, type ConnectableTransport, type ConnectionKind, type ConnectorConnectionHealth, type ConnectorCredentialField, type ConnectorCredentialTestResult, type ConnectorGrant, type ConnectorGrantInput, type ConnectorGranteeType, type ConnectorGuideStep, ConnectorPicker, type ConnectorPickerClient, type ConnectorPickerLens, type ConnectorPickerProps, type ConnectorRoleOption, type ConnectorSetupGuide, type ContextOrgGroup, ContextSwitcher, type ContextSwitcherItem, type ContextSwitcherProps, type FallbackModuleDef, Flyout, type FlyoutChild, type FlyoutProps, GLYPH_CANVAS_FILL, type GroupRungItem, type HeaderNavItem, InfoTip, type InfoTipProps, LOCKUP_GAP, LOCKUP_ROW, MARK_CAP_RATIO, MARK_WEIGHT, type OrgConnectPolicy, REEVE_ACCENT, ResponsiveHeader, type ResponsiveHeaderProps, type RungItem, type SidebarLadder, type SidebarLadderParsed, type SidebarRung, type UseLadderRungOptions, WORDMARK_WEIGHT, accessLabel, deriveFallbackLadder, faviconUrl, groupByOrg, reconcileLadder, resolveLadder, useLadderRung, useResponsivePlaceholder, zSidebarLadder };
948
+ export { type AppRungItem, AppSidebar, type AppSidebarBrand, type AppSidebarModuleDef, type AppSidebarProps, type AppSidebarTopItem, type Brand, BrandGlyph, type BrandGlyphProps, type ConnectableAccess, type ConnectableCapability, type ConnectableEntry, type ConnectableTransport, type ConnectionKind, type ConnectorConnectionHealth, type ConnectorCredentialField, type ConnectorCredentialTestResult, type ConnectorGrant, type ConnectorGrantInput, type ConnectorGranteeType, type ConnectorGuideStep, ConnectorPicker, type ConnectorPickerClient, type ConnectorPickerLens, type ConnectorPickerProps, type ConnectorRoleOption, type ConnectorSetupGuide, type ContextOrgGroup, ContextSwitcher, type ContextSwitcherItem, type ContextSwitcherProps, type FallbackModuleDef, Flyout, type FlyoutChild, type FlyoutProps, GLYPH_CANVAS_FILL, type GroupRungItem, HOVER_CLOSE_DELAY_MS, HOVER_SWITCH_DELAY_MS, type HeaderNavItem, InfoTip, type InfoTipProps, LOCKUP_GAP, LOCKUP_ROW, MARK_CAP_RATIO, MARK_WEIGHT, type OrgConnectPolicy, REEVE_ACCENT, ResponsiveHeader, type ResponsiveHeaderProps, type RungItem, type SidebarLadder, type SidebarLadderParsed, type SidebarRung, type UseLadderRungOptions, WORDMARK_WEIGHT, accessLabel, deriveFallbackLadder, faviconUrl, groupByOrg, reconcileLadder, resolveLadder, useLadderRung, useResponsivePlaceholder, zSidebarLadder };
package/dist/index.d.ts CHANGED
@@ -462,6 +462,20 @@ declare function reconcileLadder(ladder: SidebarLadder, registry: FallbackModule
462
462
  */
463
463
  declare function resolveLadder(raw: unknown, registry: FallbackModuleDef[], groupOrder: string[]): SidebarLadder;
464
464
 
465
+ /**
466
+ * DEV-13848: how long a hover-opened panel survives the pointer leaving it.
467
+ * It used to close on the very first `mouseleave`, so crossing the gap or
468
+ * cutting diagonally toward a lower row shut it — "a narrow gate" (Matt).
469
+ */
470
+ declare const HOVER_CLOSE_DELAY_MS = 300;
471
+ /**
472
+ * DEV-13848: hover intent for SWITCHING groups. A diagonal path from one
473
+ * group's trigger to the lower rows of its panel passes over the next
474
+ * group's trigger; opening that one instantly force-closed the panel the
475
+ * user was heading for. AppSidebar passes this as `hoverOpenDelayMs` while a
476
+ * sibling is open, so a pointer merely passing through never claims the slot.
477
+ */
478
+ declare const HOVER_SWITCH_DELAY_MS = 150;
465
479
  interface FlyoutChild {
466
480
  moduleId: string;
467
481
  label: string;
@@ -509,6 +523,12 @@ interface FlyoutProps {
509
523
  */
510
524
  onOpenChange?: (open: boolean) => void;
511
525
  forceClosed?: boolean;
526
+ /**
527
+ * DEV-13848: delay before a HOVER opens this instance (clicks stay
528
+ * instant); leaving before it elapses cancels the open. Default 0. A
529
+ * coordinator sets it while a sibling is open — see HOVER_SWITCH_DELAY_MS.
530
+ */
531
+ hoverOpenDelayMs?: number;
512
532
  className?: string;
513
533
  }
514
534
  /**
@@ -546,7 +566,7 @@ interface FlyoutProps {
546
566
  * than working around it. jsdom never computes real scrollable-overflow
547
567
  * geometry, so no unit test caught this — only an actual browser render did.
548
568
  */
549
- declare function Flyout({ label, icon, active, children, linkComponent, collapsed, onOpenChange, forceClosed, className, }: FlyoutProps): react.JSX.Element;
569
+ declare function Flyout({ label, icon, active, children, linkComponent, collapsed, onOpenChange, forceClosed, hoverOpenDelayMs, className, }: FlyoutProps): react.JSX.Element;
550
570
 
551
571
  /**
552
572
  * ContextSwitcher (DEV-4408) — promoted out of reeve-frontend's
@@ -925,4 +945,4 @@ interface ConnectorPickerProps {
925
945
  }
926
946
  declare function ConnectorPicker({ client, purpose, lens, layout, onConnected, }: ConnectorPickerProps): react.JSX.Element | null;
927
947
 
928
- export { type AppRungItem, AppSidebar, type AppSidebarBrand, type AppSidebarModuleDef, type AppSidebarProps, type AppSidebarTopItem, type Brand, BrandGlyph, type BrandGlyphProps, type ConnectableAccess, type ConnectableCapability, type ConnectableEntry, type ConnectableTransport, type ConnectionKind, type ConnectorConnectionHealth, type ConnectorCredentialField, type ConnectorCredentialTestResult, type ConnectorGrant, type ConnectorGrantInput, type ConnectorGranteeType, type ConnectorGuideStep, ConnectorPicker, type ConnectorPickerClient, type ConnectorPickerLens, type ConnectorPickerProps, type ConnectorRoleOption, type ConnectorSetupGuide, type ContextOrgGroup, ContextSwitcher, type ContextSwitcherItem, type ContextSwitcherProps, type FallbackModuleDef, Flyout, type FlyoutChild, type FlyoutProps, GLYPH_CANVAS_FILL, type GroupRungItem, type HeaderNavItem, InfoTip, type InfoTipProps, LOCKUP_GAP, LOCKUP_ROW, MARK_CAP_RATIO, MARK_WEIGHT, type OrgConnectPolicy, REEVE_ACCENT, ResponsiveHeader, type ResponsiveHeaderProps, type RungItem, type SidebarLadder, type SidebarLadderParsed, type SidebarRung, type UseLadderRungOptions, WORDMARK_WEIGHT, accessLabel, deriveFallbackLadder, faviconUrl, groupByOrg, reconcileLadder, resolveLadder, useLadderRung, useResponsivePlaceholder, zSidebarLadder };
948
+ export { type AppRungItem, AppSidebar, type AppSidebarBrand, type AppSidebarModuleDef, type AppSidebarProps, type AppSidebarTopItem, type Brand, BrandGlyph, type BrandGlyphProps, type ConnectableAccess, type ConnectableCapability, type ConnectableEntry, type ConnectableTransport, type ConnectionKind, type ConnectorConnectionHealth, type ConnectorCredentialField, type ConnectorCredentialTestResult, type ConnectorGrant, type ConnectorGrantInput, type ConnectorGranteeType, type ConnectorGuideStep, ConnectorPicker, type ConnectorPickerClient, type ConnectorPickerLens, type ConnectorPickerProps, type ConnectorRoleOption, type ConnectorSetupGuide, type ContextOrgGroup, ContextSwitcher, type ContextSwitcherItem, type ContextSwitcherProps, type FallbackModuleDef, Flyout, type FlyoutChild, type FlyoutProps, GLYPH_CANVAS_FILL, type GroupRungItem, HOVER_CLOSE_DELAY_MS, HOVER_SWITCH_DELAY_MS, type HeaderNavItem, InfoTip, type InfoTipProps, LOCKUP_GAP, LOCKUP_ROW, MARK_CAP_RATIO, MARK_WEIGHT, type OrgConnectPolicy, REEVE_ACCENT, ResponsiveHeader, type ResponsiveHeaderProps, type RungItem, type SidebarLadder, type SidebarLadderParsed, type SidebarRung, type UseLadderRungOptions, WORDMARK_WEIGHT, accessLabel, deriveFallbackLadder, faviconUrl, groupByOrg, reconcileLadder, resolveLadder, useLadderRung, useResponsivePlaceholder, zSidebarLadder };
package/dist/index.js CHANGED
@@ -37,6 +37,8 @@ __export(src_exports, {
37
37
  ContextSwitcher: () => ContextSwitcher,
38
38
  Flyout: () => Flyout,
39
39
  GLYPH_CANVAS_FILL: () => GLYPH_CANVAS_FILL,
40
+ HOVER_CLOSE_DELAY_MS: () => HOVER_CLOSE_DELAY_MS,
41
+ HOVER_SWITCH_DELAY_MS: () => HOVER_SWITCH_DELAY_MS,
40
42
  InfoTip: () => InfoTip,
41
43
  LOCKUP_GAP: () => LOCKUP_GAP,
42
44
  LOCKUP_ROW: () => LOCKUP_ROW,
@@ -796,6 +798,9 @@ function useLadderRung(ladder, containerRef, options = {}) {
796
798
  var import_react7 = require("react");
797
799
  var import_jsx_runtime4 = require("react/jsx-runtime");
798
800
  var PANEL_GAP = 4;
801
+ var HOVER_CLOSE_DELAY_MS = 300;
802
+ var HOVER_SLOP = 16;
803
+ var HOVER_SWITCH_DELAY_MS = 150;
799
804
  function Flyout({
800
805
  label,
801
806
  icon,
@@ -805,6 +810,7 @@ function Flyout({
805
810
  collapsed = false,
806
811
  onOpenChange,
807
812
  forceClosed = false,
813
+ hoverOpenDelayMs = 0,
808
814
  className
809
815
  }) {
810
816
  const [hoverOpen, setHoverOpen] = (0, import_react7.useState)(false);
@@ -816,9 +822,39 @@ function Flyout({
816
822
  const triggerRef = (0, import_react7.useRef)(null);
817
823
  const panelRef = (0, import_react7.useRef)(null);
818
824
  const firstItemRef = (0, import_react7.useRef)(null);
825
+ const closeTimer = (0, import_react7.useRef)(null);
826
+ const openTimer = (0, import_react7.useRef)(null);
819
827
  const prefersReducedMotion = useMediaQuery("(prefers-reduced-motion: reduce)");
820
828
  const Icon = resolveIcon(icon);
821
829
  const LinkEl = linkComponent ?? "a";
830
+ const cancelOpen = (0, import_react7.useCallback)(() => {
831
+ if (openTimer.current) clearTimeout(openTimer.current);
832
+ openTimer.current = null;
833
+ }, []);
834
+ const cancelClose = (0, import_react7.useCallback)(() => {
835
+ if (closeTimer.current) clearTimeout(closeTimer.current);
836
+ closeTimer.current = null;
837
+ cancelOpen();
838
+ }, [cancelOpen]);
839
+ const hoverEnter = () => {
840
+ cancelClose();
841
+ if (hoverOpenDelayMs <= 0) {
842
+ setHoverOpen(true);
843
+ return;
844
+ }
845
+ openTimer.current = setTimeout(() => {
846
+ openTimer.current = null;
847
+ setHoverOpen(true);
848
+ }, hoverOpenDelayMs);
849
+ };
850
+ const hoverLeave = () => {
851
+ cancelClose();
852
+ closeTimer.current = setTimeout(() => {
853
+ closeTimer.current = null;
854
+ setHoverOpen(false);
855
+ }, HOVER_CLOSE_DELAY_MS);
856
+ };
857
+ (0, import_react7.useEffect)(() => cancelClose, [cancelClose]);
822
858
  const reposition = (0, import_react7.useCallback)(() => {
823
859
  const rect = triggerRef.current?.getBoundingClientRect();
824
860
  if (rect) setPanelPosition({ top: rect.top, left: rect.right + PANEL_GAP });
@@ -830,10 +866,11 @@ function Flyout({
830
866
  }, [wantsOpen]);
831
867
  (0, import_react7.useEffect)(() => {
832
868
  if (forceClosed) {
869
+ cancelClose();
833
870
  setHoverOpen(false);
834
871
  setClickOpen(false);
835
872
  }
836
- }, [forceClosed]);
873
+ }, [forceClosed, cancelClose]);
837
874
  (0, import_react7.useLayoutEffect)(() => {
838
875
  if (open) reposition();
839
876
  }, [open, reposition]);
@@ -849,6 +886,7 @@ function Flyout({
849
886
  useDismissableDisclosure({
850
887
  open,
851
888
  onClose: () => {
889
+ cancelOpen();
852
890
  setHoverOpen(false);
853
891
  setClickOpen(false);
854
892
  },
@@ -863,8 +901,8 @@ function Flyout({
863
901
  {
864
902
  "data-testid": "ladder-flyout",
865
903
  className: cn("relative", className),
866
- onMouseEnter: () => setHoverOpen(true),
867
- onMouseLeave: () => setHoverOpen(false),
904
+ onMouseEnter: hoverEnter,
905
+ onMouseLeave: hoverLeave,
868
906
  children: [
869
907
  /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
870
908
  "button",
@@ -875,7 +913,10 @@ function Flyout({
875
913
  "aria-expanded": open,
876
914
  "aria-controls": panelId,
877
915
  title: collapsed ? label : void 0,
878
- onClick: () => setClickOpen((v) => !v),
916
+ onClick: () => {
917
+ cancelOpen();
918
+ setClickOpen((v) => !v);
919
+ },
879
920
  className: cn(
880
921
  "group flex w-full items-center gap-2.5 rounded-md px-3 py-1.5 text-sm transition-colors",
881
922
  collapsed && "justify-center px-0",
@@ -904,44 +945,61 @@ function Flyout({
904
945
  ]
905
946
  }
906
947
  ),
907
- open && panelPosition && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
948
+ open && panelPosition && // DEV-13848 hit area: a DOM child of the wrapper above, so the pointer
949
+ // moving through it never fires the wrapper's mouseleave. Starts at
950
+ // the trigger's right edge (bridging PANEL_GAP) and pads HOVER_SLOP
951
+ // around the panel; the panel itself renders exactly where it did.
952
+ // `panelRef` lives here so a click in the slop isn't an "outside" one.
953
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
908
954
  "div",
909
955
  {
910
956
  ref: panelRef,
911
- id: panelId,
912
- "data-testid": "ladder-flyout-panel",
913
- style: { position: "fixed", top: panelPosition.top, left: panelPosition.left },
914
- className: cn(
915
- "z-50 flex min-w-[12rem] flex-col gap-0.5 rounded-md border border-border bg-background p-2 shadow-lg",
916
- !prefersReducedMotion && "transition-all duration-150 ease-out"
917
- ),
918
- children: children.map((child, i) => (
919
- // `ref` on the first row (DEV-4391): the "focus moves into the
920
- // panel on click open" behavior above needs a real
921
- // HTMLAnchorElement here. A custom `linkComponent` must forward
922
- // its ref to the underlying <a> for that to keep working —
923
- // true for `next/link` (the intended consumer here) and for any
924
- // React 19 function component (ref-as-prop, no forwardRef
925
- // needed). A non-forwarding custom component on React <19 just
926
- // silently loses the focus-on-open behavior (a console ref
927
- // warning, not a crash) — same tradeoff any Link-injection
928
- // pattern accepts; not a regression from today's plain `<a>`.
929
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
930
- LinkEl,
931
- {
932
- ref: i === 0 ? firstItemRef : void 0,
933
- href: child.href,
934
- "aria-current": child.active ? "page" : void 0,
935
- style: TOUCH_TARGET_STYLE,
936
- className: cn(
937
- "flex items-center truncate rounded-md px-3 py-1.5 text-sm transition-colors",
938
- child.active ? "bg-primary/10 text-foreground" : "text-muted-foreground hover:bg-foreground/5 hover:text-foreground"
939
- ),
940
- children: child.label
941
- },
942
- child.moduleId
943
- )
944
- ))
957
+ "data-testid": "ladder-flyout-hit-area",
958
+ className: "z-50",
959
+ style: {
960
+ position: "fixed",
961
+ top: panelPosition.top - HOVER_SLOP,
962
+ left: panelPosition.left - PANEL_GAP,
963
+ padding: `${HOVER_SLOP}px ${HOVER_SLOP}px ${HOVER_SLOP}px ${PANEL_GAP}px`
964
+ },
965
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
966
+ "div",
967
+ {
968
+ id: panelId,
969
+ "data-testid": "ladder-flyout-panel",
970
+ className: cn(
971
+ "flex min-w-[12rem] flex-col gap-0.5 rounded-md border border-border bg-background p-2 shadow-lg",
972
+ !prefersReducedMotion && "transition-all duration-150 ease-out"
973
+ ),
974
+ children: children.map((child, i) => (
975
+ // `ref` on the first row (DEV-4391): the "focus moves into the
976
+ // panel on click open" behavior above needs a real
977
+ // HTMLAnchorElement here. A custom `linkComponent` must forward
978
+ // its ref to the underlying <a> for that to keep working —
979
+ // true for `next/link` (the intended consumer here) and for any
980
+ // React 19 function component (ref-as-prop, no forwardRef
981
+ // needed). A non-forwarding custom component on React <19 just
982
+ // silently loses the focus-on-open behavior (a console ref
983
+ // warning, not a crash) — same tradeoff any Link-injection
984
+ // pattern accepts; not a regression from today's plain `<a>`.
985
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
986
+ LinkEl,
987
+ {
988
+ ref: i === 0 ? firstItemRef : void 0,
989
+ href: child.href,
990
+ "aria-current": child.active ? "page" : void 0,
991
+ style: TOUCH_TARGET_STYLE,
992
+ className: cn(
993
+ "flex items-center truncate rounded-md px-3 py-1.5 text-sm transition-colors",
994
+ child.active ? "bg-primary/10 text-foreground" : "text-muted-foreground hover:bg-foreground/5 hover:text-foreground"
995
+ ),
996
+ children: child.label
997
+ },
998
+ child.moduleId
999
+ )
1000
+ ))
1001
+ }
1002
+ )
945
1003
  }
946
1004
  )
947
1005
  ]
@@ -1122,6 +1180,7 @@ function AppSidebar({
1122
1180
  linkComponent,
1123
1181
  collapsed: collapsedRow,
1124
1182
  forceClosed: openFlyoutId !== null && openFlyoutId !== item.id,
1183
+ hoverOpenDelayMs: openFlyoutId !== null && openFlyoutId !== item.id ? HOVER_SWITCH_DELAY_MS : 0,
1125
1184
  onOpenChange: (isOpen) => handleFlyoutOpenChange(item.id, isOpen),
1126
1185
  children
1127
1186
  },
@@ -2591,6 +2650,8 @@ function ManageSharing({
2591
2650
  ContextSwitcher,
2592
2651
  Flyout,
2593
2652
  GLYPH_CANVAS_FILL,
2653
+ HOVER_CLOSE_DELAY_MS,
2654
+ HOVER_SWITCH_DELAY_MS,
2594
2655
  InfoTip,
2595
2656
  LOCKUP_GAP,
2596
2657
  LOCKUP_ROW,
package/dist/index.mjs CHANGED
@@ -739,6 +739,9 @@ function useLadderRung(ladder, containerRef, options = {}) {
739
739
  import { useCallback as useCallback2, useEffect as useEffect4, useId as useId2, useLayoutEffect as useLayoutEffect2, useRef as useRef3, useState as useState5 } from "react";
740
740
  import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
741
741
  var PANEL_GAP = 4;
742
+ var HOVER_CLOSE_DELAY_MS = 300;
743
+ var HOVER_SLOP = 16;
744
+ var HOVER_SWITCH_DELAY_MS = 150;
742
745
  function Flyout({
743
746
  label,
744
747
  icon,
@@ -748,6 +751,7 @@ function Flyout({
748
751
  collapsed = false,
749
752
  onOpenChange,
750
753
  forceClosed = false,
754
+ hoverOpenDelayMs = 0,
751
755
  className
752
756
  }) {
753
757
  const [hoverOpen, setHoverOpen] = useState5(false);
@@ -759,9 +763,39 @@ function Flyout({
759
763
  const triggerRef = useRef3(null);
760
764
  const panelRef = useRef3(null);
761
765
  const firstItemRef = useRef3(null);
766
+ const closeTimer = useRef3(null);
767
+ const openTimer = useRef3(null);
762
768
  const prefersReducedMotion = useMediaQuery("(prefers-reduced-motion: reduce)");
763
769
  const Icon = resolveIcon(icon);
764
770
  const LinkEl = linkComponent ?? "a";
771
+ const cancelOpen = useCallback2(() => {
772
+ if (openTimer.current) clearTimeout(openTimer.current);
773
+ openTimer.current = null;
774
+ }, []);
775
+ const cancelClose = useCallback2(() => {
776
+ if (closeTimer.current) clearTimeout(closeTimer.current);
777
+ closeTimer.current = null;
778
+ cancelOpen();
779
+ }, [cancelOpen]);
780
+ const hoverEnter = () => {
781
+ cancelClose();
782
+ if (hoverOpenDelayMs <= 0) {
783
+ setHoverOpen(true);
784
+ return;
785
+ }
786
+ openTimer.current = setTimeout(() => {
787
+ openTimer.current = null;
788
+ setHoverOpen(true);
789
+ }, hoverOpenDelayMs);
790
+ };
791
+ const hoverLeave = () => {
792
+ cancelClose();
793
+ closeTimer.current = setTimeout(() => {
794
+ closeTimer.current = null;
795
+ setHoverOpen(false);
796
+ }, HOVER_CLOSE_DELAY_MS);
797
+ };
798
+ useEffect4(() => cancelClose, [cancelClose]);
765
799
  const reposition = useCallback2(() => {
766
800
  const rect = triggerRef.current?.getBoundingClientRect();
767
801
  if (rect) setPanelPosition({ top: rect.top, left: rect.right + PANEL_GAP });
@@ -773,10 +807,11 @@ function Flyout({
773
807
  }, [wantsOpen]);
774
808
  useEffect4(() => {
775
809
  if (forceClosed) {
810
+ cancelClose();
776
811
  setHoverOpen(false);
777
812
  setClickOpen(false);
778
813
  }
779
- }, [forceClosed]);
814
+ }, [forceClosed, cancelClose]);
780
815
  useLayoutEffect2(() => {
781
816
  if (open) reposition();
782
817
  }, [open, reposition]);
@@ -792,6 +827,7 @@ function Flyout({
792
827
  useDismissableDisclosure({
793
828
  open,
794
829
  onClose: () => {
830
+ cancelOpen();
795
831
  setHoverOpen(false);
796
832
  setClickOpen(false);
797
833
  },
@@ -806,8 +842,8 @@ function Flyout({
806
842
  {
807
843
  "data-testid": "ladder-flyout",
808
844
  className: cn("relative", className),
809
- onMouseEnter: () => setHoverOpen(true),
810
- onMouseLeave: () => setHoverOpen(false),
845
+ onMouseEnter: hoverEnter,
846
+ onMouseLeave: hoverLeave,
811
847
  children: [
812
848
  /* @__PURE__ */ jsxs4(
813
849
  "button",
@@ -818,7 +854,10 @@ function Flyout({
818
854
  "aria-expanded": open,
819
855
  "aria-controls": panelId,
820
856
  title: collapsed ? label : void 0,
821
- onClick: () => setClickOpen((v) => !v),
857
+ onClick: () => {
858
+ cancelOpen();
859
+ setClickOpen((v) => !v);
860
+ },
822
861
  className: cn(
823
862
  "group flex w-full items-center gap-2.5 rounded-md px-3 py-1.5 text-sm transition-colors",
824
863
  collapsed && "justify-center px-0",
@@ -847,44 +886,61 @@ function Flyout({
847
886
  ]
848
887
  }
849
888
  ),
850
- open && panelPosition && /* @__PURE__ */ jsx4(
889
+ open && panelPosition && // DEV-13848 hit area: a DOM child of the wrapper above, so the pointer
890
+ // moving through it never fires the wrapper's mouseleave. Starts at
891
+ // the trigger's right edge (bridging PANEL_GAP) and pads HOVER_SLOP
892
+ // around the panel; the panel itself renders exactly where it did.
893
+ // `panelRef` lives here so a click in the slop isn't an "outside" one.
894
+ /* @__PURE__ */ jsx4(
851
895
  "div",
852
896
  {
853
897
  ref: panelRef,
854
- id: panelId,
855
- "data-testid": "ladder-flyout-panel",
856
- style: { position: "fixed", top: panelPosition.top, left: panelPosition.left },
857
- className: cn(
858
- "z-50 flex min-w-[12rem] flex-col gap-0.5 rounded-md border border-border bg-background p-2 shadow-lg",
859
- !prefersReducedMotion && "transition-all duration-150 ease-out"
860
- ),
861
- children: children.map((child, i) => (
862
- // `ref` on the first row (DEV-4391): the "focus moves into the
863
- // panel on click open" behavior above needs a real
864
- // HTMLAnchorElement here. A custom `linkComponent` must forward
865
- // its ref to the underlying <a> for that to keep working —
866
- // true for `next/link` (the intended consumer here) and for any
867
- // React 19 function component (ref-as-prop, no forwardRef
868
- // needed). A non-forwarding custom component on React <19 just
869
- // silently loses the focus-on-open behavior (a console ref
870
- // warning, not a crash) — same tradeoff any Link-injection
871
- // pattern accepts; not a regression from today's plain `<a>`.
872
- /* @__PURE__ */ jsx4(
873
- LinkEl,
874
- {
875
- ref: i === 0 ? firstItemRef : void 0,
876
- href: child.href,
877
- "aria-current": child.active ? "page" : void 0,
878
- style: TOUCH_TARGET_STYLE,
879
- className: cn(
880
- "flex items-center truncate rounded-md px-3 py-1.5 text-sm transition-colors",
881
- child.active ? "bg-primary/10 text-foreground" : "text-muted-foreground hover:bg-foreground/5 hover:text-foreground"
882
- ),
883
- children: child.label
884
- },
885
- child.moduleId
886
- )
887
- ))
898
+ "data-testid": "ladder-flyout-hit-area",
899
+ className: "z-50",
900
+ style: {
901
+ position: "fixed",
902
+ top: panelPosition.top - HOVER_SLOP,
903
+ left: panelPosition.left - PANEL_GAP,
904
+ padding: `${HOVER_SLOP}px ${HOVER_SLOP}px ${HOVER_SLOP}px ${PANEL_GAP}px`
905
+ },
906
+ children: /* @__PURE__ */ jsx4(
907
+ "div",
908
+ {
909
+ id: panelId,
910
+ "data-testid": "ladder-flyout-panel",
911
+ className: cn(
912
+ "flex min-w-[12rem] flex-col gap-0.5 rounded-md border border-border bg-background p-2 shadow-lg",
913
+ !prefersReducedMotion && "transition-all duration-150 ease-out"
914
+ ),
915
+ children: children.map((child, i) => (
916
+ // `ref` on the first row (DEV-4391): the "focus moves into the
917
+ // panel on click open" behavior above needs a real
918
+ // HTMLAnchorElement here. A custom `linkComponent` must forward
919
+ // its ref to the underlying <a> for that to keep working —
920
+ // true for `next/link` (the intended consumer here) and for any
921
+ // React 19 function component (ref-as-prop, no forwardRef
922
+ // needed). A non-forwarding custom component on React <19 just
923
+ // silently loses the focus-on-open behavior (a console ref
924
+ // warning, not a crash) — same tradeoff any Link-injection
925
+ // pattern accepts; not a regression from today's plain `<a>`.
926
+ /* @__PURE__ */ jsx4(
927
+ LinkEl,
928
+ {
929
+ ref: i === 0 ? firstItemRef : void 0,
930
+ href: child.href,
931
+ "aria-current": child.active ? "page" : void 0,
932
+ style: TOUCH_TARGET_STYLE,
933
+ className: cn(
934
+ "flex items-center truncate rounded-md px-3 py-1.5 text-sm transition-colors",
935
+ child.active ? "bg-primary/10 text-foreground" : "text-muted-foreground hover:bg-foreground/5 hover:text-foreground"
936
+ ),
937
+ children: child.label
938
+ },
939
+ child.moduleId
940
+ )
941
+ ))
942
+ }
943
+ )
888
944
  }
889
945
  )
890
946
  ]
@@ -1065,6 +1121,7 @@ function AppSidebar({
1065
1121
  linkComponent,
1066
1122
  collapsed: collapsedRow,
1067
1123
  forceClosed: openFlyoutId !== null && openFlyoutId !== item.id,
1124
+ hoverOpenDelayMs: openFlyoutId !== null && openFlyoutId !== item.id ? HOVER_SWITCH_DELAY_MS : 0,
1068
1125
  onOpenChange: (isOpen) => handleFlyoutOpenChange(item.id, isOpen),
1069
1126
  children
1070
1127
  },
@@ -2533,6 +2590,8 @@ export {
2533
2590
  ContextSwitcher,
2534
2591
  Flyout,
2535
2592
  GLYPH_CANVAS_FILL,
2593
+ HOVER_CLOSE_DELAY_MS,
2594
+ HOVER_SWITCH_DELAY_MS,
2536
2595
  InfoTip,
2537
2596
  LOCKUP_GAP,
2538
2597
  LOCKUP_ROW,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meetreeve/ui",
3
- "version": "0.16.0",
3
+ "version": "0.17.0",
4
4
  "description": "Shared brand-adaptive UI primitives for MindFortress frontends — min-size tokens, a favicon→logo→monogram BrandGlyph, a responsive header that keeps the search bar usable on mobile, AppSidebar's viewport-driven auto-collapse ladder, and the StageRail flow-of-cards primitives.",
5
5
  "license": "UNLICENSED",
6
6
  "main": "./dist/index.js",