@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
@@ -11,7 +11,7 @@ import {
11
11
  } from "./components-xnp09586.js";
12
12
  import {
13
13
  usePortalContainer2
14
- } from "./components-tcm3k3wj.js";
14
+ } from "./components-ft5dgjg6.js";
15
15
  import {
16
16
  useShape2
17
17
  } from "./components-kxpcj2ry.js";
@@ -27,7 +27,7 @@ import {
27
27
  DialogTitle2,
28
28
  DialogDescription2,
29
29
  DialogState2
30
- } from "./components-ex2xtqv7.js";
30
+ } from "./components-br6t88cb.js";
31
31
 
32
32
  // components/overlays/sheet/index.tsx
33
33
  import { Drawer as DrawerPrimitive } from "@base-ui/react/drawer";
@@ -36,7 +36,7 @@ import {
36
36
  import {
37
37
  useFluidHover2,
38
38
  useRegisterFluidHoverItem2
39
- } from "./components-7c4a0egq.js";
39
+ } from "./components-21hcwp85.js";
40
40
  import {
41
41
  SizeScope2
42
42
  } from "./components-nz14rwtd.js";
@@ -20,7 +20,7 @@ import {
20
20
  useOverlayRoot2,
21
21
  useOverlay2,
22
22
  usePortalContainer2
23
- } from "./components-tcm3k3wj.js";
23
+ } from "./components-ft5dgjg6.js";
24
24
  import {
25
25
  PopupSurface2
26
26
  } from "./components-nxqrw789.js";
@@ -6,6 +6,9 @@ import {
6
6
  import {
7
7
  spring2
8
8
  } from "./components-45r18egt.js";
9
+ import {
10
+ sameRect2
11
+ } from "./components-21hcwp85.js";
9
12
  import {
10
13
  GOO_MATRIX2,
11
14
  GOO_BLUR_RATIO2
@@ -16,7 +19,7 @@ import {
16
19
 
17
20
  // lib/goo-indicator.tsx
18
21
  import { animate, motion, useMotionValue } from "motion/react";
19
- import { useId, useLayoutEffect, useRef, useState } from "react";
22
+ import { memo, useId, useLayoutEffect, useRef, useState } from "react";
20
23
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
21
24
  var COVERAGE = "0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 255 0";
22
25
  var NECK = 0.5;
@@ -123,7 +126,7 @@ function GooLayer2({ active, blur, box, fill, children }) {
123
126
  ]
124
127
  });
125
128
  }
126
- function GooIndicator2({
129
+ function GooIndicatorBase({
127
130
  rect,
128
131
  from,
129
132
  className,
@@ -214,4 +217,5 @@ function GooIndicator2({
214
217
  ]
215
218
  });
216
219
  }
220
+ var GooIndicator2 = memo(GooIndicatorBase, (a, b) => sameRect2(a.rect, b.rect) && sameRect2(a.from, b.from) && a.className === b.className && a.shadow === b.shadow && a.transition === b.transition && a.opacity === b.opacity);
217
221
  export { union2, GooLayer2, GooIndicator2 };
@@ -46,19 +46,20 @@ import {
46
46
  } from "./components-ycwhrqe1.js";
47
47
  import {
48
48
  Sheet2
49
- } from "./components-mvwf8ckh.js";
49
+ } from "./components-ac0x7zpq.js";
50
+ import {
51
+ sameRect2,
52
+ useFluidHover2
53
+ } from "./components-21hcwp85.js";
50
54
  import {
51
55
  GooIndicator2
52
- } from "./components-z0kz9rxj.js";
56
+ } from "./components-bxqmbcz2.js";
53
57
  import {
54
58
  FluidHoverHighlight2
55
- } from "./components-g35n8tzm.js";
59
+ } from "./components-9b2m90st.js";
56
60
  import {
57
61
  FocusRing2
58
- } from "./components-c515d6xr.js";
59
- import {
60
- useFluidHover2
61
- } from "./components-7c4a0egq.js";
62
+ } from "./components-5wykqxph.js";
62
63
  import {
63
64
  useIsoLayoutEffect2
64
65
  } from "./components-v2j3jx89.js";
@@ -79,7 +80,7 @@ import {
79
80
  } from "./components-8wp8d8q1.js";
80
81
  import {
81
82
  Tooltip2
82
- } from "./components-8e0fjgm9.js";
83
+ } from "./components-7rn454aq.js";
83
84
 
84
85
  // components/navigation/sidebar/index.tsx
85
86
  import {
@@ -92,10 +93,13 @@ import {
92
93
  import { AnimatePresence, motion } from "motion/react";
93
94
  import {
94
95
  createContext,
96
+ memo,
95
97
  useCallback,
98
+ useContext,
96
99
  useMemo,
97
100
  useRef,
98
- useState
101
+ useState,
102
+ useSyncExternalStore
99
103
  } from "react";
100
104
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
101
105
  /*!
@@ -107,7 +111,29 @@ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
107
111
  var MenuScopeContext = createContext(null);
108
112
  var SidebarSelection2 = createContext(null);
109
113
  var MenuItemContext = createContext(null);
114
+ var MenuRowContext = createContext(null);
110
115
  var MenuActionsClusterContext = createContext(false);
116
+ var NO_SUBSCRIPTION = () => () => {};
117
+ var HOVERED = 1;
118
+ var ACTIVE = 2;
119
+ var TAB_STOP = 4;
120
+ function useRowState(rowRef) {
121
+ const scope = useContext(MenuScopeContext);
122
+ const flags = useSyncExternalStore(scope?.subscribe ?? NO_SUBSCRIPTION, () => {
123
+ const row = rowRef?.current;
124
+ if (!scope || !row)
125
+ return 0;
126
+ const { hovered, active, first } = scope.getSnapshot();
127
+ const isActive = active.includes(row);
128
+ const tabStop = active.length > 0 ? isActive : row === first;
129
+ return (row === hovered ? HOVERED : 0) | (isActive ? ACTIVE : 0) | (tabStop ? TAB_STOP : 0);
130
+ }, () => 0);
131
+ return {
132
+ isHovered: (flags & HOVERED) !== 0,
133
+ isActiveRow: (flags & ACTIVE) !== 0,
134
+ isTabStop: (flags & TAB_STOP) !== 0
135
+ };
136
+ }
111
137
  function rowHidden(el) {
112
138
  return el.closest('[data-sidebar="menu-sub"][data-state="closed"]') !== null;
113
139
  }
@@ -152,6 +178,24 @@ function gutterVars(item) {
152
178
  const rest = item?.actionsShowOnHover ? rowGutter(0, item.hasBadge) : hover;
153
179
  return { "--row-gutter": `${rest}px`, "--row-gutter-hover": `${hover}px` };
154
180
  }
181
+ function sameBackgrounds(a, b) {
182
+ return a.length === b.length && a.every((x, i) => x.key === b[i]?.key && x.rowChanged === b[i]?.rowChanged && sameRect2(x.rect, b[i]?.rect));
183
+ }
184
+ var ActiveBackgrounds = memo(function ActiveBackgrounds({ items, className }) {
185
+ return /* @__PURE__ */ jsx(AnimatePresence, {
186
+ children: items.map(({ key, rect, rowChanged }) => /* @__PURE__ */ jsx(motion.div, {
187
+ className: "pointer-events-none absolute top-0 left-0",
188
+ initial: false,
189
+ animate: { opacity: 1 },
190
+ exit: { opacity: 0, transition: spring2.moderate.exit },
191
+ children: /* @__PURE__ */ jsx(GooIndicator2, {
192
+ rect,
193
+ className,
194
+ transition: rowChanged ? spring2.moderate : false
195
+ })
196
+ }, key))
197
+ });
198
+ }, (a, b) => a.className === b.className && sameBackgrounds(a.items, b.items));
155
199
  function useMenuScope(containerRef, { focusRing = true } = {}) {
156
200
  const { activeIndex, setActiveIndex, itemRects, isMeasured, sessionRef, handlers, registerItem } = useFluidHover2(containerRef, { isItemDisabled: rowSkipped });
157
201
  const rowsRef = useRef(new Set);
@@ -159,54 +203,72 @@ function useMenuScope(containerRef, { focusRing = true } = {}) {
159
203
  const activeMapRef = useRef(new Map);
160
204
  const [orderedRows, setOrderedRows] = useState([]);
161
205
  const orderedRowsRef = useRef(orderedRows);
162
- orderedRowsRef.current = orderedRows;
163
206
  const registeredCountRef = useRef(0);
164
207
  const [activeRows, setActiveRows] = useState([]);
165
208
  const [focusedRowEl, setFocusedRowEl] = useState(null);
166
- const recomputeActive = useCallback(() => {
167
- const next = orderedRowsRef.current.filter((el) => activeMapRef.current.get(el) && !rowSkipped(el));
168
- setActiveRows((prev) => sameElements(prev, next) ? prev : next);
169
- }, []);
170
209
  const rowButton = useCallback((row) => rowButtonsRef.current.get(row) ?? row.querySelector(':scope > [data-sidebar="menu-button"], :scope > [data-sidebar="menu-sub-button"]'), []);
210
+ const staleRef = useRef(false);
171
211
  const syncRows = useCallback(() => {
212
+ staleRef.current = false;
172
213
  const sorted = [...rowsRef.current].sort(byDomOrder);
173
- orderedRowsRef.current = sorted;
174
- setOrderedRows((prev) => sameElements(prev, sorted) ? prev : sorted);
214
+ if (!sameElements(orderedRowsRef.current, sorted)) {
215
+ orderedRowsRef.current = sorted;
216
+ setOrderedRows(sorted);
217
+ }
175
218
  for (const [i, el] of sorted.entries())
176
219
  registerItem(i, rowButton(el) ?? el);
177
220
  for (let i = sorted.length;i < registeredCountRef.current; i++)
178
221
  registerItem(i, null);
179
222
  registeredCountRef.current = sorted.length;
180
- recomputeActive();
181
- }, [registerItem, recomputeActive, rowButton]);
223
+ const active = sorted.filter((el) => activeMapRef.current.get(el) && !rowSkipped(el));
224
+ setActiveRows((prev) => sameElements(prev, active) ? prev : active);
225
+ }, [registerItem, rowButton]);
226
+ const rows = useCallback(() => {
227
+ if (staleRef.current)
228
+ syncRows();
229
+ return orderedRowsRef.current;
230
+ }, [syncRows]);
231
+ const invalidate = useCallback(() => {
232
+ if (staleRef.current)
233
+ return;
234
+ staleRef.current = true;
235
+ queueMicrotask(() => {
236
+ if (staleRef.current)
237
+ syncRows();
238
+ });
239
+ }, [syncRows]);
182
240
  const registerRow = useCallback((el) => {
183
241
  rowsRef.current.add(el);
184
- syncRows();
242
+ invalidate();
185
243
  return () => {
186
244
  rowsRef.current.delete(el);
187
245
  rowButtonsRef.current.delete(el);
188
246
  activeMapRef.current.delete(el);
189
- syncRows();
247
+ invalidate();
190
248
  };
191
- }, [syncRows]);
249
+ }, [invalidate]);
192
250
  const setRowButton = useCallback((row, button) => {
193
251
  if (button)
194
252
  rowButtonsRef.current.set(row, button);
195
253
  else
196
254
  rowButtonsRef.current.delete(row);
197
- syncRows();
198
- }, [syncRows]);
255
+ invalidate();
256
+ }, [invalidate]);
199
257
  const setRowActive = useCallback((row, active) => {
258
+ if (activeMapRef.current.get(row) === active)
259
+ return;
200
260
  activeMapRef.current.set(row, active);
201
- recomputeActive();
202
- }, [recomputeActive]);
261
+ invalidate();
262
+ }, [invalidate]);
203
263
  const refreshVisibility = useCallback(() => {
204
- recomputeActive();
264
+ const ordered = rows();
265
+ const active = ordered.filter((el) => activeMapRef.current.get(el) && !rowSkipped(el));
266
+ setActiveRows((prev) => sameElements(prev, active) ? prev : active);
205
267
  setActiveIndex((prev) => {
206
- const row = prev !== null ? orderedRowsRef.current[prev] : undefined;
268
+ const row = prev !== null ? ordered[prev] : undefined;
207
269
  return row && rowSkipped(row) ? null : prev;
208
270
  });
209
- }, [recomputeActive, setActiveIndex]);
271
+ }, [rows, setActiveIndex]);
210
272
  const overlayRect = useCallback((row) => {
211
273
  if (!row)
212
274
  return null;
@@ -235,12 +297,12 @@ function useMenuScope(containerRef, { focusRing = true } = {}) {
235
297
  const row = target.closest('[data-sidebar="menu-item"],[data-sidebar="menu-sub-item"]');
236
298
  if (!row)
237
299
  return;
238
- const idx = orderedRowsRef.current.indexOf(row);
300
+ const idx = rows().indexOf(row);
239
301
  if (idx === -1)
240
302
  return;
241
303
  setActiveIndex(idx);
242
304
  setFocusedRowEl(target.matches(":focus-visible") ? row : null);
243
- }, [setActiveIndex]);
305
+ }, [rows, setActiveIndex]);
244
306
  const onBlur = useCallback((e) => {
245
307
  if (containerRef.current?.contains(e.relatedTarget))
246
308
  return;
@@ -269,16 +331,28 @@ function useMenuScope(containerRef, { focusRing = true } = {}) {
269
331
  }
270
332
  }, [containerRef]);
271
333
  const hoveredRowEl = activeIndex !== null ? orderedRows[activeIndex] ?? null : null;
334
+ const snapshotRef = useRef({ hovered: null, active: [], first: null });
335
+ const listenersRef = useRef(new Set);
336
+ const firstRowEl = orderedRows[0] ?? null;
337
+ useIsoLayoutEffect2(() => {
338
+ const prev = snapshotRef.current;
339
+ if (prev.hovered === hoveredRowEl && prev.active === activeRows && prev.first === firstRowEl)
340
+ return;
341
+ snapshotRef.current = { hovered: hoveredRowEl, active: activeRows, first: firstRowEl };
342
+ for (const listener of listenersRef.current)
343
+ listener();
344
+ }, [hoveredRowEl, activeRows, firstRowEl]);
272
345
  const value = useMemo(() => ({
273
346
  registerRow,
274
347
  setRowButton,
275
348
  setRowActive,
276
- hoveredRowEl,
277
- activeRows,
278
- firstRowEl: orderedRows[0] ?? null,
279
- hasActive: activeRows.length > 0,
280
- refreshVisibility
281
- }), [registerRow, setRowButton, setRowActive, hoveredRowEl, activeRows, orderedRows, refreshVisibility]);
349
+ refreshVisibility,
350
+ subscribe: (listener) => {
351
+ listenersRef.current.add(listener);
352
+ return () => listenersRef.current.delete(listener);
353
+ },
354
+ getSnapshot: () => snapshotRef.current
355
+ }), [registerRow, setRowButton, setRowActive, refreshVisibility]);
282
356
  const shape = useShape2();
283
357
  const rowLevel = useCallback((row) => row.closest('[data-sidebar="menu-sub"]') ?? containerRef.current, [containerRef]);
284
358
  const prevTargetsRef = useRef({ hover: null, focus: null, actives: new Map });
@@ -315,18 +389,9 @@ function useMenuScope(containerRef, { focusRing = true } = {}) {
315
389
  const hoverAnchorRect = hoverAnchorRow ? overlayRect(hoverAnchorRow) : null;
316
390
  const overlays = isMeasured ? /* @__PURE__ */ jsxs(Fragment, {
317
391
  children: [
318
- /* @__PURE__ */ jsx(AnimatePresence, {
319
- children: activeRects.map(({ key, rect, rowChanged }) => /* @__PURE__ */ jsx(motion.div, {
320
- className: "pointer-events-none absolute top-0 left-0",
321
- initial: false,
322
- animate: { opacity: 1 },
323
- exit: { opacity: 0, transition: spring2.moderate.exit },
324
- children: /* @__PURE__ */ jsx(GooIndicator2, {
325
- rect,
326
- className: cn2("bg-active", shape.bg),
327
- transition: rowChanged ? spring2.moderate : false
328
- })
329
- }, key))
392
+ /* @__PURE__ */ jsx(ActiveBackgrounds, {
393
+ items: activeRects,
394
+ className: cn2("bg-active", shape.bg)
330
395
  }),
331
396
  /* @__PURE__ */ jsx(FluidHoverHighlight2, {
332
397
  rect: hoverRect,
@@ -358,7 +423,7 @@ function useMenuScope(containerRef, { focusRing = true } = {}) {
358
423
  }
359
424
 
360
425
  // components/navigation/sidebar/sidebar-context.tsx
361
- import { createContext as createContext2, useContext } from "react";
426
+ import { createContext as createContext2, useContext as useContext2 } from "react";
362
427
  /*!
363
428
  * Ported from Fluid Functionalism — github.com/mickadesign/fluid-functionalism
364
429
  * `registry/default/sidebar-core.tsx` @ b3587bdbd83fc66c2a6aae3817ffb856cb09260b
@@ -375,7 +440,7 @@ var SIDEBAR_MIN_WIDTH2 = 160;
375
440
  var SIDEBAR_MAX_WIDTH2 = 360;
376
441
  var SidebarContext = createContext2(null);
377
442
  function useSidebar2() {
378
- const ctx = useContext(SidebarContext);
443
+ const ctx = useContext2(SidebarContext);
379
444
  if (!ctx)
380
445
  throw new Error("useSidebar must be used within a SidebarProvider");
381
446
  return ctx;
@@ -391,7 +456,7 @@ import {
391
456
  createContext as createContext3,
392
457
  forwardRef,
393
458
  isValidElement,
394
- useContext as useContext2,
459
+ useContext as useContext3,
395
460
  useEffect,
396
461
  useId,
397
462
  useMemo as useMemo2,
@@ -559,7 +624,7 @@ var SidebarGroup2 = forwardRef(({ className, collapsible = false, open: openProp
559
624
  SidebarGroup2.displayName = "SidebarGroup";
560
625
  var SidebarGroupLabel2 = forwardRef(({ className, render, asChild, children, ...props }, ref) => {
561
626
  const size = useSize2();
562
- const group = useContext2(SidebarGroupContext);
627
+ const group = useContext3(SidebarGroupContext);
563
628
  const shape = useShape2();
564
629
  const ChevronRightIcon = useIcon2("chevron-right");
565
630
  const { template, content } = resolveSlotTemplate2(render, asChild, children);
@@ -616,7 +681,7 @@ var GroupActionsContext = createContext3(false);
616
681
  var SidebarGroupAction2 = forwardRef(({ className, render, asChild, children, style, ...props }, ref) => {
617
682
  const shape = useShape2();
618
683
  const size = useSize2();
619
- const inCluster = useContext2(GroupActionsContext);
684
+ const inCluster = useContext3(GroupActionsContext);
620
685
  const { template, content } = resolveSlotTemplate2(render, asChild, children);
621
686
  return slotElement2(template, "button", {
622
687
  ref,
@@ -651,7 +716,7 @@ SidebarGroupContent2.displayName = "SidebarGroupContent";
651
716
  import {
652
717
  Children as Children3,
653
718
  forwardRef as forwardRef2,
654
- useContext as useContext3,
719
+ useContext as useContext4,
655
720
  useId as useId2
656
721
  } from "react";
657
722
  import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
@@ -664,8 +729,8 @@ import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
664
729
  var SidebarMenuAction2 = forwardRef2(({ className, showOnHover = false, render, asChild, children, onClick, style, ...props }, ref) => {
665
730
  const shape = useShape2();
666
731
  const size = useSize2();
667
- const item = useContext3(MenuItemContext);
668
- const inCluster = useContext3(MenuActionsClusterContext);
732
+ const item = useContext4(MenuRowContext);
733
+ const inCluster = useContext4(MenuActionsClusterContext);
669
734
  const { template, content } = resolveSlotTemplate2(render, asChild, children);
670
735
  const setActions = item?.setActions;
671
736
  useIsoLayoutEffect2(() => {
@@ -690,7 +755,7 @@ var SidebarMenuAction2 = forwardRef2(({ className, showOnHover = false, render,
690
755
  });
691
756
  SidebarMenuAction2.displayName = "SidebarMenuAction";
692
757
  var SidebarMenuActions2 = forwardRef2(({ className, showOnHover = false, children, ...props }, ref) => {
693
- const item = useContext3(MenuItemContext);
758
+ const item = useContext4(MenuRowContext);
694
759
  const size = useSize2();
695
760
  const count = Children3.count(children);
696
761
  const setActions = item?.setActions;
@@ -711,9 +776,9 @@ var SidebarMenuActions2 = forwardRef2(({ className, showOnHover = false, childre
711
776
  });
712
777
  SidebarMenuActions2.displayName = "SidebarMenuActions";
713
778
  var SidebarMenuBadge2 = forwardRef2(({ className, ...props }, ref) => {
714
- const item = useContext3(MenuItemContext);
779
+ const item = useContext4(MenuRowContext);
715
780
  const size = useSize2();
716
- const lit = item?.isActiveRow ?? false;
781
+ const lit = useRowState(item?.rowRef).isActiveRow;
717
782
  const setHasBadge = item?.setHasBadge;
718
783
  useIsoLayoutEffect2(() => {
719
784
  setHasBadge?.(true);
@@ -759,7 +824,7 @@ import { cva } from "class-variance-authority";
759
824
  import { motion as motion3 } from "motion/react";
760
825
  import {
761
826
  forwardRef as forwardRef3,
762
- useContext as useContext4,
827
+ useContext as useContext5,
763
828
  useRef as useRef3
764
829
  } from "react";
765
830
  import { jsx as jsx5, jsxs as jsxs5, Fragment as Fragment4 } from "react/jsx-runtime";
@@ -794,9 +859,8 @@ var SidebarMenuButton2 = forwardRef3(({
794
859
  children,
795
860
  ...props
796
861
  }, ref) => {
797
- const scope = useContext4(MenuScopeContext);
798
- const item = useContext4(MenuItemContext);
799
- const selection = useContext4(SidebarSelection2);
862
+ const item = useContext5(MenuItemContext);
863
+ const selection = useContext5(SidebarSelection2);
800
864
  const shape = useShape2();
801
865
  const sizeClasses = useSize2(size);
802
866
  const buttonRef = useRef3(null);
@@ -815,9 +879,9 @@ var SidebarMenuButton2 = forwardRef3(({
815
879
  return () => setButtonEl?.(null);
816
880
  }, [setButtonEl]);
817
881
  const resolvedDot = dot ?? (status ? status === "idle" ? "ring" : "filled" : undefined);
818
- const lit = effectiveActive || (item?.isHovered ?? false);
819
- const row = item?.rowRef.current ?? null;
820
- const tabIdx = effectiveActive ? 0 : scope?.hasActive ? -1 : row !== null && row === scope?.firstRowEl ? 0 : -1;
882
+ const row = useRowState(item?.rowRef);
883
+ const lit = effectiveActive || row.isHovered;
884
+ const tabIdx = effectiveActive || row.isTabStop ? 0 : -1;
821
885
  const { template, content } = resolveSlotTemplate2(render, asChild, children);
822
886
  const inner = /* @__PURE__ */ jsxs5(Fragment4, {
823
887
  children: [
@@ -890,7 +954,7 @@ SidebarMenuButton2.displayName = "SidebarMenuButton";
890
954
  import {
891
955
  forwardRef as forwardRef4,
892
956
  useCallback as useCallback2,
893
- useContext as useContext5,
957
+ useContext as useContext6,
894
958
  useMemo as useMemo3,
895
959
  useRef as useRef4,
896
960
  useState as useState4
@@ -926,7 +990,7 @@ var SidebarMenu2 = forwardRef4(({ className, size, focusRing, children, ...props
926
990
  });
927
991
  SidebarMenu2.displayName = "SidebarMenu";
928
992
  function useMenuRow(rowRef, isSubRow, sub) {
929
- const scope = useContext5(MenuScopeContext);
993
+ const scope = useContext6(MenuScopeContext);
930
994
  const registerRow = scope?.registerRow;
931
995
  const setRowButton = scope?.setRowButton;
932
996
  const setRowActive = scope?.setRowActive;
@@ -951,19 +1015,16 @@ function useMenuRow(rowRef, isSubRow, sub) {
951
1015
  if (rowRef.current && setRowButton)
952
1016
  setRowButton(rowRef.current, el);
953
1017
  }, [setRowButton, rowRef]);
954
- const isHovered = rowRef.current !== null && scope?.hoveredRowEl === rowRef.current;
955
- const isActiveRow = rowRef.current !== null && (scope?.activeRows.includes(rowRef.current) ?? false);
956
1018
  const [trailing, setTrailing] = useState4({ actionCount: 0, actionsShowOnHover: false, hasBadge: false });
957
1019
  const setActions = useCallback2((count, showOnHover) => setTrailing((prev) => prev.actionCount === count && prev.actionsShowOnHover === showOnHover ? prev : { ...prev, actionCount: count, actionsShowOnHover: showOnHover }), []);
958
1020
  const setHasBadge = useCallback2((hasBadge) => setTrailing((prev) => prev.hasBadge === hasBadge ? prev : { ...prev, hasBadge }), []);
959
1021
  const [open, setOpen] = useControllableState2(sub?.open, sub?.defaultOpen ?? false, sub?.onOpenChange);
960
1022
  const subOpen = sub?.collapsible ? open : undefined;
961
1023
  const toggleSub = useCallback2(() => setOpen((prev) => !prev), [setOpen]);
962
- return useMemo3(() => ({
1024
+ const row = useMemo3(() => ({ rowRef, isSubRow, setActions, setHasBadge }), [rowRef, isSubRow, setActions, setHasBadge]);
1025
+ const item = useMemo3(() => ({
963
1026
  rowRef,
964
1027
  attachRow,
965
- isHovered,
966
- isActiveRow,
967
1028
  isSubRow,
968
1029
  setActive,
969
1030
  setButtonEl,
@@ -972,49 +1033,43 @@ function useMenuRow(rowRef, isSubRow, sub) {
972
1033
  setHasBadge,
973
1034
  subOpen,
974
1035
  toggleSub
975
- }), [
976
- rowRef,
977
- attachRow,
978
- isHovered,
979
- isActiveRow,
980
- isSubRow,
981
- setActive,
982
- setButtonEl,
983
- trailing,
984
- setActions,
985
- setHasBadge,
986
- subOpen,
987
- toggleSub
988
- ]);
1036
+ }), [rowRef, attachRow, isSubRow, setActive, setButtonEl, trailing, setActions, setHasBadge, subOpen, toggleSub]);
1037
+ return { item, row };
989
1038
  }
990
1039
  var SidebarMenuItem2 = forwardRef4(({ collapsible, open, defaultOpen, onOpenChange, className, children, ...props }, ref) => {
991
1040
  const rowRef = useRef4(null);
992
- const item = useMenuRow(rowRef, false, { collapsible, open, defaultOpen, onOpenChange });
993
- const row = useMergeRefs2(item.attachRow, ref);
994
- return /* @__PURE__ */ jsx6(MenuItemContext.Provider, {
995
- value: item,
996
- children: /* @__PURE__ */ jsx6("li", {
997
- ref: row,
998
- "data-sidebar": "menu-item",
999
- className: cn2("group/menu-item relative", className),
1000
- ...props,
1001
- children
1041
+ const { item, row } = useMenuRow(rowRef, false, { collapsible, open, defaultOpen, onOpenChange });
1042
+ const attach = useMergeRefs2(item.attachRow, ref);
1043
+ return /* @__PURE__ */ jsx6(MenuRowContext.Provider, {
1044
+ value: row,
1045
+ children: /* @__PURE__ */ jsx6(MenuItemContext.Provider, {
1046
+ value: item,
1047
+ children: /* @__PURE__ */ jsx6("li", {
1048
+ ref: attach,
1049
+ "data-sidebar": "menu-item",
1050
+ className: cn2("group/menu-item relative", className),
1051
+ ...props,
1052
+ children
1053
+ })
1002
1054
  })
1003
1055
  });
1004
1056
  });
1005
1057
  SidebarMenuItem2.displayName = "SidebarMenuItem";
1006
1058
  var SidebarMenuSubItem2 = forwardRef4(({ className, children, ...props }, ref) => {
1007
1059
  const rowRef = useRef4(null);
1008
- const item = useMenuRow(rowRef, true);
1009
- const row = useMergeRefs2(item.attachRow, ref);
1010
- return /* @__PURE__ */ jsx6(MenuItemContext.Provider, {
1011
- value: item,
1012
- children: /* @__PURE__ */ jsx6("li", {
1013
- ref: row,
1014
- "data-sidebar": "menu-sub-item",
1015
- className: cn2("group/menu-sub-item relative", className),
1016
- ...props,
1017
- children
1060
+ const { item, row } = useMenuRow(rowRef, true);
1061
+ const attach = useMergeRefs2(item.attachRow, ref);
1062
+ return /* @__PURE__ */ jsx6(MenuRowContext.Provider, {
1063
+ value: row,
1064
+ children: /* @__PURE__ */ jsx6(MenuItemContext.Provider, {
1065
+ value: item,
1066
+ children: /* @__PURE__ */ jsx6("li", {
1067
+ ref: attach,
1068
+ "data-sidebar": "menu-sub-item",
1069
+ className: cn2("group/menu-sub-item relative", className),
1070
+ ...props,
1071
+ children
1072
+ })
1018
1073
  })
1019
1074
  });
1020
1075
  });
@@ -1024,7 +1079,7 @@ SidebarMenuSubItem2.displayName = "SidebarMenuSubItem";
1024
1079
  import { motion as motion4 } from "motion/react";
1025
1080
  import {
1026
1081
  forwardRef as forwardRef5,
1027
- useContext as useContext6,
1082
+ useContext as useContext7,
1028
1083
  useRef as useRef5
1029
1084
  } from "react";
1030
1085
  import { jsx as jsx7, jsxs as jsxs7, Fragment as Fragment5 } from "react/jsx-runtime";
@@ -1035,9 +1090,9 @@ import { jsx as jsx7, jsxs as jsxs7, Fragment as Fragment5 } from "react/jsx-run
1035
1090
  * Local changes: see PORTING.md.
1036
1091
  */
1037
1092
  var SidebarMenuSub2 = forwardRef5(({ className, open: openProp, children, ...props }, ref) => {
1038
- const row = useContext6(MenuItemContext);
1093
+ const row = useContext7(MenuItemContext);
1039
1094
  const open = openProp ?? row?.subOpen ?? true;
1040
- const refreshVisibility = useContext6(MenuScopeContext)?.refreshVisibility;
1095
+ const refreshVisibility = useContext7(MenuScopeContext)?.refreshVisibility;
1041
1096
  useIsoLayoutEffect2(() => {
1042
1097
  refreshVisibility?.();
1043
1098
  }, [open, refreshVisibility]);
@@ -1073,8 +1128,8 @@ var SidebarMenuSubButton2 = forwardRef5(({
1073
1128
  children,
1074
1129
  ...props
1075
1130
  }, ref) => {
1076
- const item = useContext6(MenuItemContext);
1077
- const selection = useContext6(SidebarSelection2);
1131
+ const item = useContext7(MenuItemContext);
1132
+ const selection = useContext7(SidebarSelection2);
1078
1133
  const isActive = isActiveProp || value !== undefined && selection?.value === value;
1079
1134
  const shape = useShape2();
1080
1135
  const sizeClasses = useSize2(size);
@@ -1089,7 +1144,8 @@ var SidebarMenuSubButton2 = forwardRef5(({
1089
1144
  setButtonEl?.(buttonRef.current);
1090
1145
  return () => setButtonEl?.(null);
1091
1146
  }, [setButtonEl]);
1092
- const lit = isActive || (item?.isHovered ?? false);
1147
+ const { isHovered } = useRowState(item?.rowRef);
1148
+ const lit = isActive || isHovered;
1093
1149
  const { template, content } = resolveSlotTemplate2(render, asChild, children);
1094
1150
  const asButton = !template && value !== undefined && props.href === undefined;
1095
1151
  return slotElement2(template, asButton ? "button" : "a", {
@@ -8,7 +8,7 @@ import {
8
8
  } from "./components-xnp09586.js";
9
9
  import {
10
10
  ScrollColumn2
11
- } from "./components-ta4e10mx.js";
11
+ } from "./components-zckgawt6.js";
12
12
 
13
13
  // components/inputs/date-time/time-columns.tsx
14
14
  import { format } from "date-fns";
@@ -12,7 +12,7 @@ import {
12
12
  import {
13
13
  union2,
14
14
  GooLayer2
15
- } from "./components-z0kz9rxj.js";
15
+ } from "./components-bxqmbcz2.js";
16
16
 
17
17
  // lib/use-merge-split.tsx
18
18
  import { AnimatePresence, motion } from "motion/react";
@@ -35,7 +35,7 @@ import {
35
35
  } from "./components-nwa2a9tq.js";
36
36
  import {
37
37
  Tooltip2
38
- } from "./components-8e0fjgm9.js";
38
+ } from "./components-7rn454aq.js";
39
39
 
40
40
  // components/actions/copy/index.tsx
41
41
  import { AnimatePresence, animate, motion, useMotionValue } from "motion/react";
@@ -17,7 +17,8 @@ import {
17
17
  createContext,
18
18
  useCallback,
19
19
  useContext,
20
- useMemo
20
+ useMemo,
21
+ useState
21
22
  } from "react";
22
23
  import { jsx } from "react/jsx-runtime";
23
24
  var OverlayContext2 = createContext(null);
@@ -38,6 +39,12 @@ function useOverlay2(part) {
38
39
  throw new Error(`${part} must be inside its overlay's root.`);
39
40
  return state;
40
41
  }
42
+ function useOpenedOnce2(open) {
43
+ const [opened, setOpened] = useState(open);
44
+ if (open && !opened)
45
+ setOpened(true);
46
+ return opened || open;
47
+ }
41
48
  function positionerProps2({
42
49
  side,
43
50
  align,
@@ -71,4 +78,4 @@ function usePortalContainer2(container) {
71
78
  const scoped = useContext(PortalContainerContext);
72
79
  return container ?? scoped ?? undefined;
73
80
  }
74
- export { OverlayContext2, useOverlayRoot2, useOverlay2, positionerProps2, PortalContainer2, usePortalContainer2 };
81
+ export { OverlayContext2, useOverlayRoot2, useOverlay2, useOpenedOnce2, positionerProps2, PortalContainer2, usePortalContainer2 };