@justanarthur/modo-ui 2.3.0 → 2.4.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.
Files changed (123) hide show
  1. package/components/data-display/diff/index.tsx +19 -3
  2. package/components/inputs/choice-list/index.tsx +4 -3
  3. package/components/navigation/sidebar/menu-scope.tsx +142 -53
  4. package/components/navigation/sidebar/sidebar-menu-actions.tsx +5 -5
  5. package/components/navigation/sidebar/sidebar-menu-button.tsx +4 -7
  6. package/components/navigation/sidebar/sidebar-menu-item.tsx +39 -36
  7. package/components/navigation/sidebar/sidebar-menu-sub.tsx +3 -2
  8. package/components/overlays/command/index.tsx +70 -12
  9. package/components/overlays/dropdown/menu-popup.tsx +11 -2
  10. package/components/overlays/tooltip/index.tsx +9 -1
  11. package/dist/blocks/desktop-shell/index.js +10 -10
  12. package/dist/blocks/sidebar-app/index.js +13 -13
  13. package/dist/components/actions/copy/index.js +3 -3
  14. package/dist/components/containers/accordion/index.js +5 -5
  15. package/dist/components/containers/card/index.js +4 -4
  16. package/dist/components/data-display/diff/index.d.ts +1 -1
  17. package/dist/components/data-display/diff/index.js +1 -1
  18. package/dist/components/data-display/markdown/index.js +5 -5
  19. package/dist/components/data-display/table/index.js +4 -4
  20. package/dist/components/inputs/checkbox/index.js +6 -6
  21. package/dist/components/inputs/choice-list/index.js +5 -5
  22. package/dist/components/inputs/color-picker/index.js +7 -7
  23. package/dist/components/inputs/combobox/index.js +6 -6
  24. package/dist/components/inputs/date-time/calendar/index.js +5 -5
  25. package/dist/components/inputs/date-time/date-picker/index.js +12 -12
  26. package/dist/components/inputs/date-time/date-range-picker/index.js +12 -12
  27. package/dist/components/inputs/date-time/duration-picker/index.js +11 -11
  28. package/dist/components/inputs/date-time/month-picker/index.js +10 -10
  29. package/dist/components/inputs/date-time/time-picker/index.js +11 -11
  30. package/dist/components/inputs/input/index.js +2 -2
  31. package/dist/components/inputs/key-value/index.js +3 -3
  32. package/dist/components/inputs/number-input/index.js +3 -3
  33. package/dist/components/inputs/radio/index.js +5 -5
  34. package/dist/components/inputs/search/index.js +7 -7
  35. package/dist/components/inputs/select/index.js +6 -6
  36. package/dist/components/inputs/switch/index.js +4 -4
  37. package/dist/components/navigation/breadcrumb/index.js +8 -8
  38. package/dist/components/navigation/navigation-menu/index.js +6 -6
  39. package/dist/components/navigation/pagination/index.js +5 -5
  40. package/dist/components/navigation/sidebar/index.js +9 -9
  41. package/dist/components/navigation/tabs/index.js +4 -4
  42. package/dist/components/navigation/tree/index.js +5 -5
  43. package/dist/components/overlays/alert-dialog/index.js +3 -3
  44. package/dist/components/overlays/command/index.d.ts +6 -3
  45. package/dist/components/overlays/command/index.js +6 -6
  46. package/dist/components/overlays/context-menu/index.js +8 -8
  47. package/dist/components/overlays/dialog/index.js +2 -2
  48. package/dist/components/overlays/dropdown/index.js +7 -7
  49. package/dist/components/overlays/popover/index.js +2 -2
  50. package/dist/components/overlays/preview-card/index.js +2 -2
  51. package/dist/components/overlays/sheet/index.js +3 -3
  52. package/dist/components/overlays/tooltip/index.js +2 -2
  53. package/dist/docs/index.js +10 -10
  54. package/dist/index.d.ts +12 -6
  55. package/dist/index.js +53 -53
  56. package/dist/lib/fluid-hover-highlight.js +3 -2
  57. package/dist/lib/focus-ring.d.ts +5 -2
  58. package/dist/lib/focus-ring.js +2 -1
  59. package/dist/lib/goo-indicator.d.ts +5 -2
  60. package/dist/lib/goo-indicator.js +2 -1
  61. package/dist/lib/overlay.d.ts +8 -1
  62. package/dist/lib/overlay.js +3 -1
  63. package/dist/lib/scroll-column.js +4 -4
  64. package/dist/lib/use-fluid-hover.d.ts +3 -1
  65. package/dist/lib/use-fluid-hover.js +3 -1
  66. package/dist/lib/use-merge-split.js +3 -2
  67. package/dist/primitives/systems/fluid-hover/index.js +4 -4
  68. package/dist/shared/{components-m7d7r3r8.js → components-0bvxny7s.js} +2 -2
  69. package/dist/shared/{components-7xc2dne4.js → components-0ep66sg9.js} +5 -5
  70. package/dist/shared/{components-agjpst9b.js → components-0v4jxw7z.js} +1 -1
  71. package/dist/shared/{components-a3brpprb.js → components-1qw8hqwq.js} +7 -7
  72. package/dist/shared/{components-7c4a0egq.js → components-21hcwp85.js} +78 -43
  73. package/dist/shared/{components-kz6ak6kj.js → components-3qcgeay1.js} +2 -2
  74. package/dist/shared/{components-e52xgvd9.js → components-4fay97sm.js} +7 -7
  75. package/dist/shared/{components-fxw1122w.js → components-4fhjk3jz.js} +2 -2
  76. package/dist/shared/{components-czvraaw9.js → components-4m9stj7d.js} +10 -10
  77. package/dist/shared/{components-c515d6xr.js → components-5wykqxph.js} +6 -1
  78. package/dist/shared/{components-8e0fjgm9.js → components-7rn454aq.js} +11 -2
  79. package/dist/shared/{components-2tw25pk6.js → components-895m1f3s.js} +7 -7
  80. package/dist/shared/{components-b7p1pjcm.js → components-8m5e493q.js} +1 -1
  81. package/dist/shared/{components-rzy6h7s4.js → components-8nnhzeb3.js} +5 -5
  82. package/dist/shared/{components-1hga6pkn.js → components-8xe4h118.js} +5 -5
  83. package/dist/shared/{components-83jn0raj.js → components-9am5511q.js} +3 -3
  84. package/dist/shared/{components-g35n8tzm.js → components-9b2m90st.js} +1 -1
  85. package/dist/shared/{components-2bq4ng4d.js → components-9yrajpy0.js} +1 -1
  86. package/dist/shared/{components-mvwf8ckh.js → components-ac0x7zpq.js} +2 -2
  87. package/dist/shared/{components-q7zk70tx.js → components-af44r4y9.js} +1 -1
  88. package/dist/shared/{components-ex2xtqv7.js → components-br6t88cb.js} +1 -1
  89. package/dist/shared/{components-z0kz9rxj.js → components-bxqmbcz2.js} +6 -2
  90. package/dist/shared/{components-2v4mmw1s.js → components-cc9kfhkb.js} +169 -113
  91. package/dist/shared/{components-e7zxwja1.js → components-d4gkhy26.js} +1 -1
  92. package/dist/shared/{components-w1ysefg1.js → components-eawe4nxm.js} +1 -1
  93. package/dist/shared/{components-1sbnbq6a.js → components-fpgfs01m.js} +1 -1
  94. package/dist/shared/{components-tcm3k3wj.js → components-ft5dgjg6.js} +9 -2
  95. package/dist/shared/{components-h8v9nh5r.js → components-fv9y76b0.js} +15 -3
  96. package/dist/shared/{components-6g8a5nrs.js → components-fymenepq.js} +7 -7
  97. package/dist/shared/{components-8ybvpebx.js → components-greka6z2.js} +58 -18
  98. package/dist/shared/{components-k2gg1agj.js → components-gzve0nkp.js} +4 -4
  99. package/dist/shared/{components-fjg4j430.js → components-hjdv4y8d.js} +2 -2
  100. package/dist/shared/{components-k25zw9g8.js → components-hjk6dwsp.js} +1 -1
  101. package/dist/shared/{components-4fswe4kh.js → components-mb80a9wg.js} +1 -1
  102. package/dist/shared/{components-nh05qz8b.js → components-mzdbtgvz.js} +8 -8
  103. package/dist/shared/{components-x5v7e0fz.js → components-nmbcfwx8.js} +7 -7
  104. package/dist/shared/{components-9rebr89j.js → components-pw6gzev8.js} +1 -1
  105. package/dist/shared/{components-01e24999.js → components-pwsqp2np.js} +20 -10
  106. package/dist/shared/{components-eebf7f9c.js → components-qmkfpcw0.js} +8 -8
  107. package/dist/shared/{components-etgpz4zk.js → components-qrtcc8aw.js} +3 -3
  108. package/dist/shared/{components-nred2e6g.js → components-rgdspnth.js} +2 -2
  109. package/dist/shared/{components-gnsvnejm.js → components-rtwfh1gc.js} +2 -2
  110. package/dist/shared/{components-z87sanbc.js → components-s0megs1g.js} +4 -4
  111. package/dist/shared/{components-7g2q2ccp.js → components-sh8j39z3.js} +6 -6
  112. package/dist/shared/{components-vykcfb5r.js → components-v1zzr668.js} +3 -3
  113. package/dist/shared/{components-5vezp3e5.js → components-vcmky8ns.js} +6 -6
  114. package/dist/shared/{components-6xtntksc.js → components-xq8j9c2f.js} +8 -8
  115. package/dist/shared/{components-27fatggq.js → components-y9se9mx5.js} +3 -3
  116. package/dist/shared/{components-9ca0c92a.js → components-yfx0skxc.js} +1 -1
  117. package/dist/shared/{components-ta4e10mx.js → components-zckgawt6.js} +5 -5
  118. package/dist/styles.css +1 -1
  119. package/lib/focus-ring.tsx +15 -8
  120. package/lib/goo-indicator.tsx +20 -8
  121. package/lib/overlay.tsx +22 -1
  122. package/lib/use-fluid-hover.ts +96 -72
  123. package/package.json +1 -1
@@ -30,7 +30,7 @@ import {
30
30
  import {
31
31
  useFluidHover2,
32
32
  useRegisterFluidHoverItem2
33
- } from "./components-7c4a0egq.js";
33
+ } from "./components-21hcwp85.js";
34
34
  import {
35
35
  WeightLabel2
36
36
  } from "./components-y09nr7fe.js";
@@ -59,10 +59,10 @@ import {
59
59
  } from "./components-v2j3jx89.js";
60
60
  import {
61
61
  FluidHoverHighlight2
62
- } from "./components-g35n8tzm.js";
62
+ } from "./components-9b2m90st.js";
63
63
  import {
64
64
  FocusRing2
65
- } from "./components-c515d6xr.js";
65
+ } from "./components-5wykqxph.js";
66
66
  import {
67
67
  useRowFocus2
68
68
  } from "./components-vcte8p75.js";
@@ -3,15 +3,19 @@
3
3
  import {
4
4
  spring2
5
5
  } from "./components-45r18egt.js";
6
+ import {
7
+ useFluidHover2,
8
+ useRegisterFluidHoverItem2
9
+ } from "./components-21hcwp85.js";
6
10
  import {
7
11
  cn2
8
12
  } from "./components-xnp09586.js";
9
13
  import {
10
14
  GooIndicator2
11
- } from "./components-z0kz9rxj.js";
15
+ } from "./components-bxqmbcz2.js";
12
16
  import {
13
17
  FluidHoverHighlight2
14
- } from "./components-g35n8tzm.js";
18
+ } from "./components-9b2m90st.js";
15
19
  import {
16
20
  mergeRefs2
17
21
  } from "./components-bkwjvvkh.js";
@@ -28,10 +32,6 @@ import {
28
32
  import {
29
33
  useControllableState2
30
34
  } from "./components-wwd093xg.js";
31
- import {
32
- useFluidHover2,
33
- useRegisterFluidHoverItem2
34
- } from "./components-7c4a0egq.js";
35
35
  import {
36
36
  SizeScope2
37
37
  } from "./components-nz14rwtd.js";
@@ -13,18 +13,22 @@ import {
13
13
  useFieldState2,
14
14
  useFieldBox2
15
15
  } from "./components-1ztgy933.js";
16
+ import {
17
+ useFluidHover2,
18
+ useRegisterFluidHoverItem2
19
+ } from "./components-21hcwp85.js";
16
20
  import {
17
21
  useMorph2
18
22
  } from "./components-8pnvkrbw.js";
19
23
  import {
20
24
  GooIndicator2
21
- } from "./components-z0kz9rxj.js";
25
+ } from "./components-bxqmbcz2.js";
22
26
  import {
23
27
  FluidHoverHighlight2
24
- } from "./components-g35n8tzm.js";
28
+ } from "./components-9b2m90st.js";
25
29
  import {
26
30
  FocusRing2
27
- } from "./components-c515d6xr.js";
31
+ } from "./components-5wykqxph.js";
28
32
  import {
29
33
  useMergeRefs2
30
34
  } from "./components-bkwjvvkh.js";
@@ -37,7 +41,7 @@ import {
37
41
  useOverlay2,
38
42
  positionerProps2,
39
43
  usePortalContainer2
40
- } from "./components-tcm3k3wj.js";
44
+ } from "./components-ft5dgjg6.js";
41
45
  import {
42
46
  POPUP_SHAPE2,
43
47
  popupScrollAreaClass2,
@@ -63,10 +67,6 @@ import {
63
67
  import {
64
68
  slotRender2
65
69
  } from "./components-7wjkag2j.js";
66
- import {
67
- useFluidHover2,
68
- useRegisterFluidHoverItem2
69
- } from "./components-7c4a0egq.js";
70
70
  import {
71
71
  useKeyboardNavGate2
72
72
  } from "./components-tcyz2tdn.js";
@@ -7,7 +7,7 @@ import {
7
7
  } from "./components-29ebea21.js";
8
8
  import {
9
9
  ScrollColumn2
10
- } from "./components-ta4e10mx.js";
10
+ } from "./components-zckgawt6.js";
11
11
  import {
12
12
  useControllableState2
13
13
  } from "./components-wwd093xg.js";
@@ -16,11 +16,11 @@ import {
16
16
  columnsPopupClass,
17
17
  ColumnsPanel,
18
18
  PickerInput
19
- } from "./components-k2gg1agj.js";
19
+ } from "./components-gzve0nkp.js";
20
20
  import {
21
21
  pad,
22
22
  minuteOptions
23
- } from "./components-e7zxwja1.js";
23
+ } from "./components-d4gkhy26.js";
24
24
 
25
25
  // components/inputs/date-time/duration-picker/index.tsx
26
26
  import { formatDuration } from "date-fns";
@@ -24,7 +24,7 @@ import {
24
24
  } from "./components-bkwjvvkh.js";
25
25
  import {
26
26
  InputAdornment2
27
- } from "./components-q7zk70tx.js";
27
+ } from "./components-af44r4y9.js";
28
28
 
29
29
  // components/inputs/number-input/index.tsx
30
30
  import { NumberField } from "@base-ui/react/number-field";
@@ -3,22 +3,22 @@
3
3
  import {
4
4
  useReduceMotion2
5
5
  } from "./components-tz0axc0f.js";
6
+ import {
7
+ useFluidHover2,
8
+ useRegisterFluidHoverItem2
9
+ } from "./components-21hcwp85.js";
6
10
  import {
7
11
  cn2
8
12
  } from "./components-xnp09586.js";
9
13
  import {
10
14
  FluidHoverHighlight2
11
- } from "./components-g35n8tzm.js";
15
+ } from "./components-9b2m90st.js";
12
16
  import {
13
17
  useShape2
14
18
  } from "./components-kxpcj2ry.js";
15
19
  import {
16
20
  useSize2
17
21
  } from "./components-znspksk0.js";
18
- import {
19
- useFluidHover2,
20
- useRegisterFluidHoverItem2
21
- } from "./components-7c4a0egq.js";
22
22
 
23
23
  // lib/scroll-column.tsx
24
24
  import { useEffect, useRef } from "react";
package/dist/styles.css CHANGED
@@ -62,7 +62,7 @@
62
62
  }
63
63
  /* layer: theme */
64
64
  @layer theme{
65
- :root, :host { --spacing: 0.25rem; --default-transition-timingFunction: cubic-bezier(0.4, 0, 0.2, 1); --default-transition-duration: 150ms; --radius-none: 0; --font-sans: 'Inter Variable', ui-sans-serif, system-ui, sans-serif; --font-mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace; --ease-DEFAULT: cubic-bezier(0.4, 0, 0.2, 1); --radius-md: 0.375rem; --radius-DEFAULT: 0.25rem; --ease-out: cubic-bezier(0, 0, 0.2, 1); --container-sm: 24rem; --leading-relaxed: 1.625; --radius-3xl: 1.5rem; --radius-xl: 0.75rem; --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1); --leading-tight: 1.25; --radius-xs: 0.125rem; --leading-snug: 1.375; --leading-normal: 1.5; --radius-sm: 0.25rem; --radius-2xl: 1rem; --radius-lg: 0.5rem; --leading-none: 1; --container-2xl: 42rem; --default-font-family: var(--font-sans); --default-monoFont-family: var(--font-mono); }
65
+ :root, :host { --spacing: 0.25rem; --radius-3xl: 1.5rem; --radius-xl: 0.75rem; --default-transition-timingFunction: cubic-bezier(0.4, 0, 0.2, 1); --default-transition-duration: 150ms; --ease-DEFAULT: cubic-bezier(0.4, 0, 0.2, 1); --font-mono: ui-monospace, 'SF Mono', SFMono-Regular, Menlo, Consolas, monospace; --container-sm: 24rem; --radius-DEFAULT: 0.25rem; --radius-none: 0; --leading-tight: 1.25; --radius-md: 0.375rem; --font-sans: 'Inter Variable', ui-sans-serif, system-ui, sans-serif; --ease-out: cubic-bezier(0, 0, 0.2, 1); --ease-in-out: cubic-bezier(0.4, 0, 0.2, 1); --radius-sm: 0.25rem; --radius-2xl: 1rem; --radius-xs: 0.125rem; --leading-relaxed: 1.625; --leading-snug: 1.375; --leading-normal: 1.5; --container-2xl: 42rem; --radius-lg: 0.5rem; --leading-none: 1; --default-font-family: var(--font-sans); --default-monoFont-family: var(--font-mono); }
66
66
  }
67
67
  /* layer: base */
68
68
  @layer base{
@@ -6,10 +6,11 @@
6
6
  'use client'
7
7
 
8
8
  import { AnimatePresence, motion } from 'motion/react'
9
+ import { memo } from 'react'
9
10
  import { useReduceMotion } from './reduced-motion'
10
11
  import { useShape } from './shape-context'
11
12
  import { spring } from './springs'
12
- import type { ItemRect } from './use-fluid-hover'
13
+ import { type ItemRect, sameRect } from './use-fluid-hover'
13
14
  import { cn } from './utils'
14
15
 
15
16
  interface FocusRingProps {
@@ -21,13 +22,7 @@ interface FocusRingProps {
21
22
  className?: string
22
23
  }
23
24
 
24
- /**
25
- * A 1px `focus-ring` border drawn 2px outside the focused row. It springs
26
- * between rows on `spring.fast` (jumps under reduced motion) and fades out
27
- * when focus leaves. Render it inside the rows' `relative` container, above
28
- * the hover highlight.
29
- */
30
- export function FocusRing({ rect, instant = false, className }: FocusRingProps) {
25
+ function FocusRingBase({ rect, instant = false, className }: FocusRingProps) {
31
26
  const shape = useShape()
32
27
  const reduceMotion = useReduceMotion()
33
28
  const jump = instant || reduceMotion
@@ -47,3 +42,15 @@ export function FocusRing({ rect, instant = false, className }: FocusRingProps)
47
42
  </AnimatePresence>
48
43
  )
49
44
  }
45
+
46
+ /**
47
+ * A 1px `focus-ring` border drawn 2px outside the focused row. It springs
48
+ * between rows on `spring.fast` (jumps under reduced motion) and fades out
49
+ * when focus leaves. Render it inside the rows' `relative` container, above
50
+ * the hover highlight. Skips the render while its box and props hold (rects
51
+ * are fresh objects on every list render).
52
+ */
53
+ export const FocusRing = memo(
54
+ FocusRingBase,
55
+ (a, b) => sameRect(a.rect, b.rect) && a.instant === b.instant && a.className === b.className,
56
+ )
@@ -22,10 +22,10 @@
22
22
  'use client'
23
23
 
24
24
  import { animate, motion, type Transition, useMotionValue, type ValueAnimationTransition } from 'motion/react'
25
- import { type ReactNode, useId, useLayoutEffect, useRef, useState } from 'react'
25
+ import { memo, type ReactNode, useId, useLayoutEffect, useRef, useState } from 'react'
26
26
  import { useReduceMotion } from './reduced-motion'
27
27
  import { spring } from './springs'
28
- import type { ItemRect } from './use-fluid-hover'
28
+ import { type ItemRect, sameRect } from './use-fluid-hover'
29
29
  import { GOO_BLUR_RATIO, GOO_MATRIX } from './use-morph'
30
30
  import { cn } from './utils'
31
31
 
@@ -161,12 +161,7 @@ interface GooIndicatorProps {
161
161
  opacity?: number
162
162
  }
163
163
 
164
- /**
165
- * An indicator that travels between items with a liquid neck. Render it in the
166
- * items' `relative` container, beneath them: the items' text stays above it,
167
- * unfiltered.
168
- */
169
- export function GooIndicator({
164
+ function GooIndicatorBase({
170
165
  rect,
171
166
  from,
172
167
  className,
@@ -259,5 +254,22 @@ export function GooIndicator({
259
254
  )
260
255
  }
261
256
 
257
+ /**
258
+ * An indicator that travels between items with a liquid neck. Render it in the
259
+ * items' `relative` container, beneath them: the items' text stays above it,
260
+ * unfiltered. Its list re-renders on every hover; an indicator whose box did
261
+ * not move skips the render (rects are fresh objects each time).
262
+ */
263
+ export const GooIndicator = memo(
264
+ GooIndicatorBase,
265
+ (a, b) =>
266
+ sameRect(a.rect, b.rect) &&
267
+ sameRect(a.from, b.from) &&
268
+ a.className === b.className &&
269
+ a.shadow === b.shadow &&
270
+ a.transition === b.transition &&
271
+ a.opacity === b.opacity,
272
+ )
273
+
262
274
  export type { GooIndicatorProps, GooLayerProps }
263
275
  export { union }
package/lib/overlay.tsx CHANGED
@@ -19,6 +19,7 @@ import {
19
19
  useCallback,
20
20
  useContext,
21
21
  useMemo,
22
+ useState,
22
23
  } from 'react'
23
24
  import { useControllableState } from './use-controllable-state'
24
25
  import { inPlaceOffset, type MorphOrigin, type MorphProps, opensInPlace, useMorphOrigin } from './use-morph'
@@ -110,6 +111,18 @@ function useOverlay(part: string): OverlayState {
110
111
  return state
111
112
  }
112
113
 
114
+ /**
115
+ * False until `open` first turns true, then true for good. Content that
116
+ * mounts its machinery (the morph, a fluid hover, the portal) behind it costs
117
+ * nothing in a list of triggers until one opens, and stays mounted after, for
118
+ * its close and the next open.
119
+ */
120
+ function useOpenedOnce(open: boolean) {
121
+ const [opened, setOpened] = useState(open)
122
+ if (open && !opened) setOpened(true)
123
+ return opened || open
124
+ }
125
+
113
126
  /**
114
127
  * Base UI `Positioner` props for an anchored overlay: the content's
115
128
  * anchoring props over the overlay's defaults, pulled back over the trigger
@@ -159,4 +172,12 @@ function usePortalContainer(container?: HTMLElement | null) {
159
172
  }
160
173
 
161
174
  export type { Align, AnchorProps, CollisionProps, OpenChangeDetails, OverlayRootProps, OverlayState, Side }
162
- export { OverlayContext, PortalContainer, positionerProps, useOverlay, useOverlayRoot, usePortalContainer }
175
+ export {
176
+ OverlayContext,
177
+ PortalContainer,
178
+ positionerProps,
179
+ useOpenedOnce,
180
+ useOverlay,
181
+ useOverlayRoot,
182
+ usePortalContainer,
183
+ }
@@ -26,6 +26,12 @@ export interface ItemRect {
26
26
  width: number
27
27
  }
28
28
 
29
+ /** Two rects with the same box (either may be missing). */
30
+ export function sameRect(a: ItemRect | null | undefined, b: ItemRect | null | undefined) {
31
+ if (!a || !b) return a === b
32
+ return a.top === b.top && a.left === b.left && a.width === b.width && a.height === b.height
33
+ }
34
+
29
35
  export interface UseFluidHoverOptions {
30
36
  /**
31
37
  * Which direction to resolve the nearest item along.
@@ -204,14 +210,6 @@ function resolveActivator(element: HTMLElement): HTMLElement {
204
210
  return element.querySelector<HTMLElement>(ACTIVATOR_SELECTOR) ?? element
205
211
  }
206
212
 
207
- /**
208
- * How many frames the coalesced remeasure retries while the registered items
209
- * still have no layout box. A popup can be in the DOM one frame before it is
210
- * laid out; retrying beats publishing zeroed rects, and the cap keeps a list
211
- * that stays hidden for good from spinning frames forever.
212
- */
213
- const measurementAttempts = 3
214
-
215
213
  export function useFluidHover<T extends HTMLElement>(
216
214
  containerRef: RefObject<T | null>,
217
215
  options: UseFluidHoverOptions = {},
@@ -300,12 +298,7 @@ export function useFluidHover<T extends HTMLElement>(
300
298
  // compare) so redundant remeasures don't churn re-renders.
301
299
  const prev = itemRectsRef.current
302
300
  let changed = prev.length !== rects.length
303
- for (let i = 0; !changed && i < rects.length; i++) {
304
- const p = prev[i]
305
- const r = rects[i]
306
- if (p === r) continue // both undefined (sparse slot)
307
- changed = !p || !r || p.top !== r.top || p.left !== r.left || p.width !== r.width || p.height !== r.height
308
- }
301
+ for (let i = 0; !changed && i < rects.length; i++) changed = !sameRect(prev[i], rects[i])
309
302
  if (changed) {
310
303
  itemRectsRef.current = rects
311
304
  setItemRects(rects)
@@ -318,58 +311,92 @@ export function useFluidHover<T extends HTMLElement>(
318
311
  }, [runMeasurement])
319
312
 
320
313
  /**
321
- * The hook's single measurement pass: coalesces every trigger (item
322
- * registration, container resize) into one remeasure on the next frame and
323
- * is the only place readiness is reported, so `isMeasured` can never turn
324
- * true while another pass is still queued.
314
+ * The hook's single measurement pass, read right after the browser's own
315
+ * layout: every trigger (registration, `remeasure`, an item or the
316
+ * container resizing) lands in one ResizeObserver callback, where reading
317
+ * offsets costs no extra layout. Re-observing the container is the trigger
318
+ * (`observe` reports a laid-out target once), and a container without a box
319
+ * (a popup not laid out yet) reports when it gets one. It is the only place
320
+ * readiness turns true, so `isMeasured` can never be true while a pass is
321
+ * still queued.
325
322
  */
326
- const scheduleMeasurement = useCallback(
327
- (attemptsLeft: number) => {
328
- if (remeasureRafIdRef.current !== null) {
329
- cancelAnimationFrame(remeasureRafIdRef.current)
323
+ const onObserved = useCallback(() => {
324
+ if (runMeasurement()) setIsMeasured(true)
325
+ }, [runMeasurement])
326
+
327
+ const roRef = useRef<ResizeObserver | null>(null)
328
+ const observedContainerRef = useRef<HTMLElement | null>(null)
329
+ const getRo = useCallback(() => {
330
+ if (roRef.current === null && typeof ResizeObserver !== 'undefined') {
331
+ roRef.current = new ResizeObserver(onObserved)
332
+ }
333
+ return roRef.current
334
+ }, [onObserved])
335
+
336
+ // Re-observing the container makes the observer report it after the next
337
+ // layout. Deferred to a microtask: registrations run in the commit before
338
+ // the container's own ref attaches. Without ResizeObserver (tests), a frame.
339
+ const queuedRef = useRef(false)
340
+ const scheduleMeasurement = useCallback(() => {
341
+ if (queuedRef.current) return
342
+ queuedRef.current = true
343
+ queueMicrotask(() => {
344
+ queuedRef.current = false
345
+ const ro = getRo()
346
+ const container = containerRef.current
347
+ if (!ro || !container) {
348
+ if (remeasureRafIdRef.current !== null) cancelAnimationFrame(remeasureRafIdRef.current)
349
+ remeasureRafIdRef.current = requestAnimationFrame(() => {
350
+ remeasureRafIdRef.current = null
351
+ onObserved()
352
+ })
353
+ return
330
354
  }
331
- remeasureRafIdRef.current = requestAnimationFrame(() => {
332
- remeasureRafIdRef.current = null
333
- if (runMeasurement()) {
334
- setIsMeasured(true)
335
- } else if (attemptsLeft > 1) {
336
- scheduleMeasurement(attemptsLeft - 1)
337
- }
338
- })
339
- },
340
- [runMeasurement],
341
- )
355
+ if (observedContainerRef.current && observedContainerRef.current !== container) {
356
+ ro.unobserve(observedContainerRef.current)
357
+ }
358
+ observedContainerRef.current = container
359
+ ro.unobserve(container)
360
+ ro.observe(container, { box: 'border-box' })
361
+ })
362
+ }, [containerRef, getRo, onObserved])
342
363
 
343
364
  const remeasure = useCallback(() => {
344
365
  // Readiness drops first: until the pass below settles, the published rects
345
366
  // may not describe what is on screen, and an overlay positioned from them
346
367
  // would be corrected after mounting — which animates as a slide.
347
368
  setIsMeasured(false)
348
- scheduleMeasurement(measurementAttempts)
369
+ scheduleMeasurement()
349
370
  }, [scheduleMeasurement])
350
371
 
351
- // Observes the registered items themselves (not just the container): rows
352
- // that change size in place — e.g. the site-wide size step flipping while a
353
- // selection background is up — must invalidate the published rects even when
354
- // the container the effect below captured has since been remounted and the
355
- // ref points at a different element than the one being observed.
356
- const itemRoRef = useRef<ResizeObserver | null>(null)
357
- const getItemRo = useCallback(() => {
358
- if (itemRoRef.current === null && typeof ResizeObserver !== 'undefined') {
359
- itemRoRef.current = new ResizeObserver(() => scheduleMeasurement(measurementAttempts))
360
- }
361
- return itemRoRef.current
362
- }, [scheduleMeasurement])
372
+ // How many indices hold each element: a row that moves to another index
373
+ // within one batch must stay observed.
374
+ const observedRef = useRef(new Map<HTMLElement, number>())
375
+ const track = useCallback(
376
+ (element: HTMLElement, by: 1 | -1) => {
377
+ const count = (observedRef.current.get(element) ?? 0) + by
378
+ if (count > 0) observedRef.current.set(element, count)
379
+ else observedRef.current.delete(element)
380
+ // Border box: a row whose padding animates (actions revealed on hover)
381
+ // keeps its rect, so it must not remeasure the list every frame.
382
+ if (by === 1 && count === 1) getRo()?.observe(element, { box: 'border-box' })
383
+ if (count === 0) roRef.current?.unobserve(element)
384
+ },
385
+ [getRo],
386
+ )
363
387
 
364
388
  const registerItem = useCallback(
365
389
  (index: number, element: HTMLElement | null) => {
390
+ const previous = itemsRef.current.get(index)
391
+ // The same element at the same index (a parent re-registering its whole
392
+ // set) changes nothing.
393
+ if (element && previous === element) return
394
+ if (previous) track(previous, -1)
366
395
  if (element) {
367
396
  itemsRef.current.set(index, element)
368
- getItemRo()?.observe(element)
397
+ track(element, 1)
369
398
  if (index === activeIndexRef.current) element.setAttribute(ACTIVE_ATTR, '')
370
399
  } else {
371
- const previous = itemsRef.current.get(index)
372
- if (previous) itemRoRef.current?.unobserve(previous)
373
400
  // The mark leaves with the element: a row that only moved to another
374
401
  // index (a filtering list re-ordering) must not carry it there.
375
402
  previous?.removeAttribute(ACTIVE_ATTR)
@@ -382,13 +409,12 @@ export function useFluidHover<T extends HTMLElement>(
382
409
  setActiveIndex(current => (current === index && !itemsRef.current.has(index) ? null : current))
383
410
  }
384
411
  }
385
- // Coalesce rapid register/unregister calls (e.g. when an AnimatePresence
386
- // remounts a list of rows) into a single remeasure on the next frame,
387
- // so consumers don't have to manually call measureItems after the
388
- // container's children swap.
412
+ // Coalesced: a list remounting its rows (an AnimatePresence swap) runs
413
+ // one pass, after layout, so consumers don't call measureItems after
414
+ // the container's children swap.
389
415
  remeasure()
390
416
  },
391
- [remeasure, getItemRo],
417
+ [remeasure, track],
392
418
  )
393
419
 
394
420
  const handleMouseMove = useCallback(
@@ -474,30 +500,28 @@ export function useFluidHover<T extends HTMLElement>(
474
500
  [isItemDisabled, gapClick, gapClickMaxDistance],
475
501
  )
476
502
 
477
- // Remeasure when the container resizes — a reflow moves items even though
478
- // the registered set is unchanged, which would otherwise leave itemRects
479
- // stale. Coalesced through the same rAF as register/unregister. Readiness is
480
- // deliberately not dropped: the item set is unchanged, so the published rects
503
+ // The container resizing reflows the items even though the set is
504
+ // unchanged. Readiness is deliberately not dropped: the published rects
481
505
  // stay usable, and hiding overlays on every reflow would flicker them.
482
506
  useEffect(() => {
483
507
  const container = containerRef.current
484
- if (!container || typeof ResizeObserver === 'undefined') return
485
- const ro = new ResizeObserver(() => scheduleMeasurement(measurementAttempts))
486
- ro.observe(container)
487
- return () => ro.disconnect()
488
- }, [containerRef, scheduleMeasurement])
508
+ const ro = getRo()
509
+ if (!container || !ro) return
510
+ observedContainerRef.current = container
511
+ ro.observe(container, { box: 'border-box' })
512
+ return () => {
513
+ ro.unobserve(container)
514
+ if (observedContainerRef.current === container) observedContainerRef.current = null
515
+ }
516
+ }, [containerRef, getRo])
489
517
 
490
- // Clean up rAF and the item observer on unmount
491
518
  useEffect(() => {
492
519
  return () => {
493
- if (rafIdRef.current !== null) {
494
- cancelAnimationFrame(rafIdRef.current)
495
- }
496
- if (remeasureRafIdRef.current !== null) {
497
- cancelAnimationFrame(remeasureRafIdRef.current)
498
- }
499
- itemRoRef.current?.disconnect()
500
- itemRoRef.current = null
520
+ if (rafIdRef.current !== null) cancelAnimationFrame(rafIdRef.current)
521
+ if (remeasureRafIdRef.current !== null) cancelAnimationFrame(remeasureRafIdRef.current)
522
+ roRef.current?.disconnect()
523
+ roRef.current = null
524
+ observedRef.current.clear()
501
525
  }
502
526
  }, [])
503
527
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@justanarthur/modo-ui",
3
3
  "type": "module",
4
- "version": "2.3.0",
4
+ "version": "2.4.0",
5
5
  "description": "Fluid Functionalism (Base UI flavor, MIT © 2026 Micka Touillaud) ported to UnoCSS: motion springs, fluid hover, a two-step size ladder and an eight-level elevated surface system. Documented with modo.",
6
6
  "license": "MIT",
7
7
  "keywords": [