@stll/ui 0.90.1 → 0.91.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.
@@ -8,8 +8,8 @@ import { DAY_CALENDAR_SLOT_HEIGHT_PX, boundsHeight, extendRange, getDayBounds, g
8
8
  import { getTopicColor } from "./topic-colors.js";
9
9
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
10
10
  import { useState } from "react";
11
- import { panic } from "better-result";
12
11
  import { Temporal } from "temporal-polyfill/full";
12
+ import { panic } from "better-result";
13
13
  // src/calendar/day-calendar.tsx
14
14
  const COLUMN_TRACKS = {
15
15
  narrow: "minmax(0, 0.6fr)",
@@ -1,5 +1,5 @@
1
- import { Result, panic } from "better-result";
2
1
  import { Temporal } from "temporal-polyfill/full";
2
+ import { Result, panic } from "better-result";
3
3
  // src/calendar/day-calendar.logic.ts
4
4
  const DAY_CALENDAR_GRANULARITIES = [
5
5
  15,
@@ -1,5 +1,5 @@
1
- import { Result, panic } from "better-result";
2
1
  import { Temporal } from "temporal-polyfill/full";
2
+ import { Result, panic } from "better-result";
3
3
  // src/calendar/resource-calendar.logic.ts
4
4
  const ISO_DATE_PATTERN = /^\d{4}-\d{2}-\d{2}$/u;
5
5
  const toPlainDate = (value) => {
@@ -1,9 +1,10 @@
1
1
  "use client";
2
+ import { useMountEffect } from "../effects/effects.js";
2
3
  import { CheckIcon, CopyToClipboardIcon } from "../icons.js";
3
4
  import { cn } from "../lib/utils.js";
4
5
  import { Button } from "./button.js";
5
6
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
- import { useCallback, useEffect, useRef, useState } from "react";
7
+ import { useCallback, useRef, useState } from "react";
7
8
  // src/components/copy-button.tsx
8
9
  const COPIED_RESET_MS = 1500;
9
10
  const SWAP_CLASS = "col-start-1 row-start-1 transition-[opacity,scale] duration-200 ease-out motion-reduce:transition-none";
@@ -69,9 +70,9 @@ const useCopiedFeedback = () => {
69
70
  }
70
71
  setCopied(false);
71
72
  }, []);
72
- useEffect(() => () => {
73
+ useMountEffect(() => () => {
73
74
  if (resetTimerRef.current !== null) clearTimeout(resetTimerRef.current);
74
- }, []);
75
+ });
75
76
  return {
76
77
  copied,
77
78
  confirm,
@@ -12,8 +12,8 @@ import { TimeField } from "./time-field.js";
12
12
  import { TruncatedText } from "./truncated-text.js";
13
13
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
14
14
  import { useCallback, useId, useMemo, useRef, useState, useSyncExternalStore } from "react";
15
- import { Result, panic } from "better-result";
16
15
  import { Temporal } from "temporal-polyfill/full";
16
+ import { Result, panic } from "better-result";
17
17
  // src/components/date-picker-popover.tsx
18
18
  const toISODate = (date) => date.toString();
19
19
  const toUTCDateTime = (date) => date.toZonedDateTime({
@@ -1,9 +1,9 @@
1
1
  "use client";
2
- import { useLatest } from "../effects/effects.js";
2
+ import { useLatest, useMountEffect } from "../effects/effects.js";
3
3
  import { containedHandler } from "../hooks/use-contained-handler.js";
4
4
  import { cn } from "../lib/utils.js";
5
5
  import { jsx, jsxs } from "react/jsx-runtime";
6
- import { useCallback, useEffect, useRef, useState } from "react";
6
+ import { useCallback, useRef, useState } from "react";
7
7
  // src/components/hex-color-picker.tsx
8
8
  /**
9
9
  * Hex color picker — saturation/brightness square + hue strip.
@@ -221,7 +221,7 @@ const InteractiveArea = ({ onMove, onKey, children, ...rest }) => {
221
221
  win.addEventListener(moveType, handleMove);
222
222
  win.addEventListener(endType, handleEnd);
223
223
  };
224
- useEffect(() => detachListeners, []);
224
+ useMountEffect(() => detachListeners);
225
225
  const handleStart = (e) => {
226
226
  const el = container.current;
227
227
  if (!el) return;
@@ -1,34 +1,35 @@
1
1
  "use client";
2
+ import { useObservedValue } from "../effects/dom.js";
3
+ import { useExternalSyncEffect } from "../effects/effects.js";
2
4
  import { containedEventHandler } from "../hooks/use-contained-handler.js";
3
5
  import { ChevronLeftIcon, ChevronRightIcon } from "../icons.js";
4
6
  import { SCROLL_EDGE_FADE_CLASS, writeScrollEdgeFade } from "../lib/scroll-edge-fade.js";
5
7
  import { cn } from "../lib/utils.js";
6
8
  import { jsx, jsxs } from "react/jsx-runtime";
7
- import { useCallback, useState } from "react";
9
+ import { useState } from "react";
8
10
  // src/components/horizontal-scroller.tsx
9
11
  const CONTROL_CLASS = "bg-background text-foreground shrink-0 rounded-full border p-1 shadow-sm";
10
12
  const INERT_CONTROL_CLASS = "pointer-events-none w-0 overflow-hidden border-0 p-0 opacity-0 focus-visible:w-auto focus-visible:border focus-visible:p-1 focus-visible:opacity-100";
11
13
  const HorizontalScroller = ({ children, className, nextLabel, previousLabel, contentClassName, viewportClassName, ...props }) => {
12
14
  const [viewport, setViewport] = useState(null);
13
- const [state, setState] = useState({
14
- canScrollEnd: false,
15
- canScrollStart: false
16
- });
17
- const measure = useCallback((node) => {
18
- writeScrollEdgeFade(node);
19
- const rowWidth = rowContentWidth(node.parentElement) ?? node.clientWidth;
20
- setState(fitsRow(node.scrollWidth, rowWidth) ? {
21
- canScrollEnd: false,
22
- canScrollStart: false
23
- } : scrollState(node.scrollLeft, node.scrollWidth, node.clientWidth, getComputedStyle(node).direction === "rtl" ? "rtl" : "ltr"));
24
- }, []);
25
- const viewportRef = useCallback((node) => {
26
- setViewport(node);
27
- if (!node) return;
28
- const observer = new ResizeObserver(() => measure(node));
15
+ const state = useObservedValue(viewport, (node, emit) => {
16
+ const measure = () => {
17
+ writeScrollEdgeFade(node);
18
+ emit(measureScrollState(node));
19
+ };
20
+ const observer = new ResizeObserver(measure);
29
21
  observer.observe(node);
30
22
  if (node.firstElementChild !== null) observer.observe(node.firstElementChild);
31
- measure(node);
23
+ node.addEventListener("scroll", measure, { passive: true });
24
+ measure();
25
+ return () => {
26
+ observer.disconnect();
27
+ node.removeEventListener("scroll", measure);
28
+ };
29
+ }, [], NO_SCROLL);
30
+ useExternalSyncEffect(() => {
31
+ if (viewport === null) return;
32
+ const node = viewport;
32
33
  const onWheel = (event) => {
33
34
  if (event.ctrlKey || event.deltaX !== 0 || event.deltaY === 0 || node.scrollWidth <= node.clientWidth) return;
34
35
  const rtl = getComputedStyle(node).direction === "rtl";
@@ -40,10 +41,9 @@ const HorizontalScroller = ({ children, className, nextLabel, previousLabel, con
40
41
  };
41
42
  node.addEventListener("wheel", onWheel, { passive: false });
42
43
  return () => {
43
- observer.disconnect();
44
44
  node.removeEventListener("wheel", onWheel);
45
45
  };
46
- }, [measure]);
46
+ }, [viewport]);
47
47
  const scroll = (inlineDirection) => {
48
48
  if (!viewport) return;
49
49
  const rtl = getComputedStyle(viewport).direction === "rtl";
@@ -52,7 +52,6 @@ const HorizontalScroller = ({ children, className, nextLabel, previousLabel, con
52
52
  left: viewport.clientWidth * .8 * inlineDirection * (rtl ? -1 : 1)
53
53
  });
54
54
  };
55
- const onScroll = (event) => measure(event.currentTarget);
56
55
  const overflows = state.canScrollStart || state.canScrollEnd;
57
56
  return /* @__PURE__ */ jsxs("div", {
58
57
  className: cn("flex min-w-0 items-center", className),
@@ -77,8 +76,7 @@ const HorizontalScroller = ({ children, className, nextLabel, previousLabel, con
77
76
  }),
78
77
  /* @__PURE__ */ jsx("div", {
79
78
  className: cn("scrollbar-subtle min-w-0 flex-1 overflow-x-auto overscroll-x-contain [--fade-size:2.5rem]", SCROLL_EDGE_FADE_CLASS, viewportClassName),
80
- onScroll,
81
- ref: viewportRef,
79
+ ref: setViewport,
82
80
  children: /* @__PURE__ */ jsx("div", {
83
81
  className: cn("w-max min-w-full", contentClassName),
84
82
  children
@@ -98,6 +96,14 @@ const HorizontalScroller = ({ children, className, nextLabel, previousLabel, con
98
96
  ]
99
97
  });
100
98
  };
99
+ const NO_SCROLL = {
100
+ canScrollEnd: false,
101
+ canScrollStart: false
102
+ };
103
+ const measureScrollState = (node) => {
104
+ const rowWidth = rowContentWidth(node.parentElement) ?? node.clientWidth;
105
+ return fitsRow(node.scrollWidth, rowWidth) ? NO_SCROLL : scrollState(node.scrollLeft, node.scrollWidth, node.clientWidth, getComputedStyle(node).direction === "rtl" ? "rtl" : "ltr");
106
+ };
101
107
  const scrollState = (scrollLeft, scrollWidth, clientWidth, direction) => {
102
108
  const maximum = Math.max(0, scrollWidth - clientWidth);
103
109
  const position = direction === "rtl" ? Math.abs(scrollLeft) : scrollLeft;
@@ -1,43 +1,56 @@
1
1
  "use client";
2
+ import { useObservedValue } from "../effects/dom.js";
3
+ import { useExternalSyncEffect } from "../effects/effects.js";
2
4
  import { cn } from "../lib/utils.js";
3
5
  import { withoutDirectionalControls } from "./bidi-text.js";
4
6
  import { Tooltip, TooltipContent as TooltipPopup, TooltipTrigger } from "./tooltip.js";
5
7
  import { TruncatedText } from "./truncated-text.js";
6
8
  import { jsx, jsxs } from "react/jsx-runtime";
7
- import { useCallback, useId, useState } from "react";
9
+ import { useId, useState } from "react";
8
10
  // src/components/identity-text.tsx
11
+ const UNMEASURED = {
12
+ overflow: false,
13
+ hasFocusOwner: false
14
+ };
15
+ const focusOwnerOf = (node) => node.parentElement?.closest("a[href],button,[tabindex]") ?? null;
9
16
  /** Discloses clipped names on hover and when their owning control receives focus. */
10
17
  const IdentityText = ({ children, className }) => {
11
18
  const triggerId = useId();
12
- const [overflow, setOverflow] = useState(false);
13
- const [hasFocusOwner, setHasFocusOwner] = useState(false);
19
+ const [node, setNode] = useState(null);
14
20
  const [open, setOpen] = useState(false);
15
21
  const name = withoutDirectionalControls(children);
16
- const textRef = useCallback((node) => {
17
- if (node === null) return;
18
- const measure = () => setOverflow(node.scrollWidth > node.clientWidth);
22
+ const { overflow, hasFocusOwner } = useObservedValue(node, (observed, emit) => {
23
+ const hasOwner = focusOwnerOf(observed) !== null;
24
+ const measure = () => emit({
25
+ overflow: observed.scrollWidth > observed.clientWidth,
26
+ hasFocusOwner: hasOwner
27
+ });
19
28
  const observer = new ResizeObserver(measure);
20
- observer.observe(node);
29
+ observer.observe(observed);
21
30
  const contentObserver = new MutationObserver(measure);
22
- contentObserver.observe(node, {
31
+ contentObserver.observe(observed, {
23
32
  childList: true,
24
33
  characterData: true,
25
34
  subtree: true
26
35
  });
27
36
  measure();
28
- const focusOwner = node.parentElement?.closest("a[href],button,[tabindex]");
29
- setHasFocusOwner(focusOwner !== null && focusOwner !== void 0);
30
- const show = () => setOpen(true);
31
- const hide = () => setOpen(false);
32
- focusOwner?.addEventListener("focus", show);
33
- focusOwner?.addEventListener("blur", hide);
34
37
  return () => {
35
38
  observer.disconnect();
36
39
  contentObserver.disconnect();
37
- focusOwner?.removeEventListener("focus", show);
38
- focusOwner?.removeEventListener("blur", hide);
39
40
  };
40
- }, []);
41
+ }, [], UNMEASURED);
42
+ useExternalSyncEffect(() => {
43
+ const focusOwner = node === null ? null : focusOwnerOf(node);
44
+ if (focusOwner === null) return;
45
+ const show = () => setOpen(true);
46
+ const hide = () => setOpen(false);
47
+ focusOwner.addEventListener("focus", show);
48
+ focusOwner.addEventListener("blur", hide);
49
+ return () => {
50
+ focusOwner.removeEventListener("focus", show);
51
+ focusOwner.removeEventListener("blur", hide);
52
+ };
53
+ }, [node]);
41
54
  return /* @__PURE__ */ jsxs(Tooltip, {
42
55
  disabled: !overflow,
43
56
  onOpenChange: setOpen,
@@ -56,7 +69,7 @@ const IdentityText = ({ children, className }) => {
56
69
  className: cn("focus-visible:ring-ring outline-none [unicode-bidi:isolate] focus-visible:ring-2", className),
57
70
  dir: "auto",
58
71
  hint: false,
59
- ref: textRef,
72
+ ref: setNode,
60
73
  role: overflow && !hasFocusOwner ? "button" : void 0,
61
74
  tabIndex: overflow && !hasFocusOwner ? 0 : void 0
62
75
  }),
@@ -1,7 +1,7 @@
1
- import { useLatest } from "../effects/effects.js";
1
+ import { useExternalSyncEffect, useLatest, useMountEffect } from "../effects/effects.js";
2
2
  import { OutcomeScreenView } from "./outcome-screen-view.js";
3
3
  import { jsx } from "react/jsx-runtime";
4
- import { useEffect, useRef } from "react";
4
+ import { useRef } from "react";
5
5
  // src/components/outcome-screen.tsx
6
6
  /** How long a tab that asked to close waits before it counts as still open. */
7
7
  const CLOSE_FALLBACK_MS = 150;
@@ -9,7 +9,7 @@ const CLOSE_FALLBACK_MS = 150;
9
9
  const useCloseTab = (closeTab) => {
10
10
  const latest = useLatest(closeTab);
11
11
  const wantsClose = closeTab !== void 0;
12
- useEffect(() => {
12
+ useExternalSyncEffect(() => {
13
13
  const request = wantsClose ? latest.current : void 0;
14
14
  let fallback;
15
15
  if (request !== void 0) {
@@ -31,9 +31,9 @@ const useCloseTab = (closeTab) => {
31
31
  */
32
32
  const useFocusedHeading = () => {
33
33
  const heading = useRef(null);
34
- useEffect(() => {
34
+ useMountEffect(() => {
35
35
  heading.current?.focus({ preventScroll: true });
36
- }, []);
36
+ });
37
37
  return heading;
38
38
  };
39
39
  const OutcomeScreen = ({ closeTab, ...view }) => {
@@ -1,5 +1,6 @@
1
1
  "use client";
2
- import { useLatest, useLayoutSyncEffect } from "../effects/effects.js";
2
+ import { useObservedValue } from "../effects/dom.js";
3
+ import { useExternalSyncEffect, useLatest, useLayoutSyncEffect, useMountEffect } from "../effects/effects.js";
3
4
  import { ChevronRightIcon } from "../icons.js";
4
5
  import "../lib/panel-inset.js";
5
6
  import { cn } from "../lib/utils.js";
@@ -10,7 +11,7 @@ import { ScrollArea } from "./scroll-area.js";
10
11
  import { Tooltip, TooltipContent as TooltipPopup, TooltipTrigger } from "./tooltip.js";
11
12
  import { TruncatedText } from "./truncated-text.js";
12
13
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
13
- import { memo, useCallback, useEffect, useId, useMemo, useRef, useState } from "react";
14
+ import { memo, useCallback, useId, useMemo, useRef, useState } from "react";
14
15
  import { Temporal } from "temporal-polyfill/full";
15
16
  // src/components/outline-rail.tsx
16
17
  /**
@@ -44,6 +45,7 @@ const RAIL_MAX_TICKS = 40;
44
45
  const WHEEL_EDGE_TOLERANCE = 1;
45
46
  const HOVER_OPEN_DWELL_MS = 150;
46
47
  const ACTIVE_ROW_ATTRIBUTE = "data-outline-active";
48
+ const NO_TICK_POSITIONS = {};
47
49
  /** The entry as one line of text: label, then its title when it has one. */
48
50
  const outlineEntryText = (item) => item.title === void 0 ? item.label : `${item.label} ${item.title}`;
49
51
  const MAX_ROW_PORTRAITS = 3;
@@ -231,7 +233,6 @@ const OutlineRail = ({ items: itemsProp, scrollContainerRef, resolvePct, onJump,
231
233
  const [stableItems, setStableItems] = useState(itemsProp);
232
234
  const items = reconcileOutlineItems(stableItems, itemsProp);
233
235
  if (items !== stableItems) setStableItems(items);
234
- const [pctById, setPctById] = useState(/* @__PURE__ */ new Map());
235
236
  const [derivedActive, setDerivedActive] = useState(null);
236
237
  const [hovered, setHovered] = useState(false);
237
238
  const [focusWithin, setFocusWithin] = useState(false);
@@ -244,7 +245,7 @@ const OutlineRail = ({ items: itemsProp, scrollContainerRef, resolvePct, onJump,
244
245
  const openTimer = useRef(null);
245
246
  const manualLockUntil = useRef(0);
246
247
  const panelRef = useRef(null);
247
- const railRef = useRef(null);
248
+ const [railElement, setRailElement] = useState(null);
248
249
  const focusedTickRef = useRef(null);
249
250
  const resolvePctRef = useLatest(resolvePct);
250
251
  const onJumpRef = useLatest(onJump);
@@ -286,32 +287,28 @@ const OutlineRail = ({ items: itemsProp, scrollContainerRef, resolvePct, onJump,
286
287
  }
287
288
  return cap;
288
289
  }, [items, maxLevel]);
289
- const recalc = useCallback(() => {
290
+ const pctById = useObservedValue(railElement, (_rail, emit) => {
290
291
  const container = scrollContainerRef.current;
291
- if (!container) return;
292
- const next = /* @__PURE__ */ new Map();
293
- for (const item of items) {
294
- const pct = resolvePct(item.id, container);
295
- if (pct !== null) next.set(item.id, pct);
296
- }
297
- setPctById(next);
298
- }, [
299
- items,
300
- scrollContainerRef,
301
- resolvePct
302
- ]);
303
- const recalcRef = useLatest(recalc);
304
- useEffect(() => {
305
- recalc();
306
- }, [recalc]);
307
- useEffect(() => {
308
- const container = scrollContainerRef.current;
309
- if (!container) return;
310
- const observer = new ResizeObserver(() => recalcRef.current());
292
+ if (!container) return () => void 0;
293
+ const measure = () => {
294
+ const next = [];
295
+ for (const item of items) {
296
+ const pct = resolvePct(item.id, container);
297
+ if (pct !== null) next.push([item.id, pct]);
298
+ }
299
+ emit(Object.fromEntries(next));
300
+ };
301
+ measure();
302
+ const observer = new ResizeObserver(measure);
311
303
  observer.observe(container);
312
304
  return () => observer.disconnect();
313
- }, [recalcRef, scrollContainerRef]);
314
- useEffect(() => {
305
+ }, [
306
+ items,
307
+ resolvePct,
308
+ scrollContainerRef
309
+ ], NO_TICK_POSITIONS);
310
+ const tickPct = (id) => Object.hasOwn(pctById, id) ? pctById[id] : void 0;
311
+ useExternalSyncEffect(() => {
315
312
  if (activeId !== void 0) return;
316
313
  const container = scrollContainerRef.current;
317
314
  if (!container || items.length === 0) return;
@@ -431,12 +428,12 @@ const OutlineRail = ({ items: itemsProp, scrollContainerRef, resolvePct, onJump,
431
428
  setHovered(false);
432
429
  setFocusWithin(false);
433
430
  }, []);
434
- useEffect(() => () => {
431
+ useMountEffect(() => () => {
435
432
  if (closeTimer.current !== null) clearTimeout(closeTimer.current);
436
433
  if (openTimer.current !== null) clearTimeout(openTimer.current);
437
- }, []);
434
+ });
438
435
  const visibleTicks = items.flatMap((item) => {
439
- const pct = pctById.get(item.id);
436
+ const pct = tickPct(item.id);
440
437
  return pct !== void 0 && (item.portraits !== void 0 || item.level <= railLevelCap) ? [{
441
438
  item,
442
439
  pct
@@ -445,12 +442,12 @@ const OutlineRail = ({ items: itemsProp, scrollContainerRef, resolvePct, onJump,
445
442
  const hasPanel = items.length >= 2 || header !== void 0;
446
443
  if (!hasPanel && !items.some((item) => item.portraits !== void 0)) return null;
447
444
  const visibleTickIds = new Set(visibleTicks.map(({ item }) => item.id));
448
- const ghostPct = hoveredId !== null && !visibleTickIds.has(hoveredId) ? pctById.get(hoveredId) : void 0;
445
+ const ghostPct = hoveredId !== null && !visibleTickIds.has(hoveredId) ? tickPct(hoveredId) : void 0;
449
446
  const ghostItem = ghostPct === void 0 ? void 0 : items.find((item) => item.id === hoveredId);
450
447
  return /* @__PURE__ */ jsxs("div", {
451
448
  "aria-label": ariaLabel,
452
449
  className: OUTLINE_PRESENTATION_CLASS[presentation],
453
- ref: railRef,
450
+ ref: setRailElement,
454
451
  role: "group",
455
452
  style: {
456
453
  marginBlockEnd: bottomInset ?? "max(env(safe-area-inset-bottom, 0px), var(--document-panel-bottom-inset, 0px))",
@@ -485,7 +482,7 @@ const OutlineRail = ({ items: itemsProp, scrollContainerRef, resolvePct, onJump,
485
482
  "aria-label": tickLabel,
486
483
  className: cn("absolute end-0 rounded-full transition-[width,height,opacity] duration-150", isHovered || isActive ? "opacity-100" : "opacity-45 hover:opacity-90", portraits !== void 0 && "focus-visible:outline-ring z-10 after:absolute after:-inset-x-2 after:-inset-y-2.5 focus-visible:outline-2 focus-visible:outline-offset-2 pointer-coarse:after:-inset-x-3.5 pointer-coarse:after:-inset-y-5"),
487
484
  onBlur: (event) => {
488
- if (!railRef.current?.contains(event.relatedTarget)) closePanel();
485
+ if (!railElement?.contains(event.relatedTarget)) closePanel();
489
486
  },
490
487
  onClick: () => jumpTo(item.id),
491
488
  onFocus: (event) => {
@@ -533,7 +530,7 @@ const OutlineRail = ({ items: itemsProp, scrollContainerRef, resolvePct, onJump,
533
530
  tabIndex: -1,
534
531
  className: cn("bg-popover text-popover-foreground flex min-h-0 flex-col", presentation === "popover" && "border-border absolute rounded-xl border shadow-lg transition-[opacity,transform] duration-150", outlinePanelVisibilityClass(presentation, panelOpen)),
535
532
  onBlurCapture: (event) => {
536
- if (!railRef.current?.contains(event.relatedTarget)) {
533
+ if (!railElement?.contains(event.relatedTarget)) {
537
534
  closePanel();
538
535
  return;
539
536
  }
@@ -546,7 +543,7 @@ const OutlineRail = ({ items: itemsProp, scrollContainerRef, resolvePct, onJump,
546
543
  onKeyDown: (event) => {
547
544
  if (event.key !== "Escape" || presentation !== "popover") return;
548
545
  const tickSelector = `button[aria-controls="${CSS.escape(panelId)}"]`;
549
- (focusedTickRef.current ?? railRef.current?.querySelector(`${tickSelector}[aria-current="true"]`) ?? railRef.current?.querySelector(tickSelector))?.focus();
546
+ (focusedTickRef.current ?? railElement?.querySelector(`${tickSelector}[aria-current="true"]`) ?? railElement?.querySelector(tickSelector))?.focus();
550
547
  closePanel();
551
548
  },
552
549
  onMouseEnter: openPanel,
@@ -1,8 +1,9 @@
1
+ import { useExternalSyncEffect } from "../effects/effects.js";
1
2
  import { RUN_MARK_SIZES, RUN_MARK_TONES, RUN_STATE_MARKS } from "./run-state-mark.shared.js";
2
3
  import { STATUS_MARK_RING_RADIUS, STATUS_MARK_RUNNING_ARC, STATUS_MARK_SPIN_MS, STATUS_MARK_STROKE_WIDTH, STATUS_MARK_TRACK_OPACITY, STATUS_MARK_VIEWBOX } from "./status-mark.shared.js";
3
4
  import { sansFontFamily } from "./text.native.js";
4
5
  import { jsx, jsxs } from "react/jsx-runtime";
5
- import { useEffect, useState } from "react";
6
+ import { useState } from "react";
6
7
  import { panic } from "better-result";
7
8
  import { Animated, Easing, Text } from "react-native";
8
9
  import Svg, { Circle } from "react-native-svg";
@@ -45,7 +46,7 @@ const RunningRing = ({ colorVariable, px }) => {
45
46
  const resolved = useCSSVariable(colorVariable);
46
47
  const color = typeof resolved === "string" ? resolved : "currentColor";
47
48
  const [turn] = useState(() => new Animated.Value(0));
48
- useEffect(() => {
49
+ useExternalSyncEffect(() => {
49
50
  const spin = Animated.loop(Animated.timing(turn, {
50
51
  duration: STATUS_MARK_SPIN_MS,
51
52
  easing: (progress) => Easing.linear(progress),
@@ -1,7 +1,10 @@
1
1
  "use client";
2
+ import { useObservedValue } from "../effects/dom.js";
3
+ import { useLatestCallback } from "../effects/effects.js";
4
+ import { containedEventHandler } from "../hooks/use-contained-handler.js";
2
5
  import { cn } from "../lib/utils.js";
3
6
  import { jsx } from "react/jsx-runtime";
4
- import { useEffect, useState } from "react";
7
+ import { useState } from "react";
5
8
  // src/components/scroll-to-top.tsx
6
9
  /**
7
10
  * Scroll-to-top affordance — a subtle floating button that fades in once a
@@ -9,22 +12,26 @@ import { useEffect, useState } from "react";
9
12
  * (instant, not animated, so it stays snappy on very long documents).
10
13
  */
11
14
  const ScrollToTop = ({ scrollContainerRef, threshold = 600, label = "Scroll to top", className }) => {
12
- const [visible, setVisible] = useState(false);
13
- useEffect(() => {
15
+ const [button, setButton] = useState(null);
16
+ const visible = useObservedValue(button, (_button, emit) => {
14
17
  const container = scrollContainerRef.current;
15
- if (!container) return;
16
- const onScroll = () => setVisible(container.scrollTop > threshold);
18
+ if (!container) return () => void 0;
19
+ const onScroll = () => emit(container.scrollTop > threshold);
17
20
  onScroll();
18
21
  container.addEventListener("scroll", onScroll, { passive: true });
19
22
  return () => container.removeEventListener("scroll", onScroll);
20
- }, [scrollContainerRef, threshold]);
23
+ }, [scrollContainerRef, threshold], false);
24
+ const scrollToTop = useLatestCallback(() => {
25
+ scrollContainerRef.current?.scrollTo({
26
+ top: 0,
27
+ behavior: "instant"
28
+ });
29
+ });
21
30
  return /* @__PURE__ */ jsx("button", {
22
31
  "aria-label": label,
23
32
  className: cn("border-border bg-popover/90 text-muted-foreground hover:text-foreground absolute end-6 bottom-6 z-30 flex size-9 items-center justify-center rounded-full border shadow-md backdrop-blur transition-[opacity,transform] duration-200", visible ? "translate-y-0 opacity-100" : "pointer-events-none translate-y-2 opacity-0", className),
24
- onClick: () => scrollContainerRef.current?.scrollTo({
25
- top: 0,
26
- behavior: "instant"
27
- }),
33
+ onClick: containedEventHandler(scrollToTop),
34
+ ref: setButton,
28
35
  type: "button",
29
36
  children: /* @__PURE__ */ jsx("svg", {
30
37
  "aria-hidden": true,
@@ -1,29 +1,32 @@
1
1
  "use client";
2
+ import { useObservedValue } from "../effects/dom.js";
3
+ import { useLayoutSyncEffect } from "../effects/effects.js";
4
+ import { useComposedRefs } from "../effects/refs.js";
2
5
  import { hasTabOrderChanged, revealActiveTab } from "../lib/tab-order.js";
3
- import { cn, composeRefs } from "../lib/utils.js";
6
+ import { cn } from "../lib/utils.js";
4
7
  import { TABS_INDICATOR_DEFAULT_CLASS, TABS_LIST_BASE_CLASS, TABS_LIST_DEFAULT_CLASS, TABS_TAB_CLASS } from "./tabs-classes.js";
5
8
  import { jsx, jsxs } from "react/jsx-runtime";
6
- import { useEffect, useLayoutEffect, useRef, useState } from "react";
9
+ import { useRef, useState } from "react";
7
10
  import { Tabs as Tabs$1 } from "@base-ui/react/tabs";
8
11
  // src/components/tabs.tsx
9
- const useIsoLayoutEffect = typeof window === "undefined" ? useEffect : useLayoutEffect;
10
12
  const Tabs = ({ className, ...props }) => /* @__PURE__ */ jsx(Tabs$1.Root, {
11
13
  className: cn("flex flex-col gap-2 data-[orientation=vertical]:flex-row", className),
12
14
  "data-slot": "tabs",
13
15
  ...props
14
16
  });
15
17
  const TabsList = ({ variant = "default", className, children, ref, ...props }) => {
16
- const listRef = useRef(null);
18
+ const [list, setList] = useState(null);
19
+ const composedListRef = useComposedRefs(setList, ref);
17
20
  const tabOrderRef = useRef([]);
18
- const [, setRemeasureToken] = useState(0);
19
- useIsoLayoutEffect(() => {
20
- const tabs = listRef.current ? [...listRef.current.children] : [];
21
- const previousTabs = tabOrderRef.current;
21
+ const reordersRef = useRef(0);
22
+ useObservedValue(list, (observed, emit) => {
23
+ const tabs = [...observed.children];
24
+ if (hasTabOrderChanged(tabOrderRef.current, tabs)) reordersRef.current += 1;
22
25
  tabOrderRef.current = tabs;
23
- if (hasTabOrderChanged(previousTabs, tabs)) setRemeasureToken((token) => token + 1);
24
- });
25
- useIsoLayoutEffect(() => {
26
- const list = listRef.current;
26
+ emit(reordersRef.current);
27
+ return () => void 0;
28
+ }, [children], 0);
29
+ useLayoutSyncEffect(() => {
27
30
  if (list === null || typeof ResizeObserver === "undefined") return;
28
31
  const observer = new ResizeObserver(() => {
29
32
  revealActiveTab(list);
@@ -32,11 +35,11 @@ const TabsList = ({ variant = "default", className, children, ref, ...props }) =
32
35
  return () => {
33
36
  observer.disconnect();
34
37
  };
35
- }, []);
38
+ }, [list]);
36
39
  return /* @__PURE__ */ jsxs(Tabs$1.List, {
37
40
  className: cn(TABS_LIST_BASE_CLASS, "scrollbar-none overflow-auto data-[orientation=horizontal]:overflow-y-hidden data-[orientation=horizontal]:overscroll-x-contain data-[orientation=vertical]:overflow-x-hidden data-[orientation=vertical]:overscroll-y-contain [&::-webkit-scrollbar]:hidden", "data-[orientation=vertical]:flex-col", variant === "default" ? TABS_LIST_DEFAULT_CLASS : "*:data-[slot=tabs-tab]:hover:bg-accent data-[orientation=horizontal]:py-1 data-[orientation=vertical]:px-1", className),
38
41
  "data-slot": "tabs-list",
39
- ref: composeRefs(listRef, ref),
42
+ ref: composedListRef,
40
43
  ...props,
41
44
  children: [children, /* @__PURE__ */ jsx(Tabs$1.Indicator, {
42
45
  className: cn("absolute bottom-0 left-0 h-(--active-tab-height) w-(--active-tab-width) translate-x-(--active-tab-left) -translate-y-(--active-tab-bottom) transition-[width,translate] duration-200 ease-in-out", variant === "underline" ? "bg-primary z-10 data-[orientation=horizontal]:h-0.5 data-[orientation=vertical]:w-0.5 data-[orientation=vertical]:-translate-x-px" : TABS_INDICATOR_DEFAULT_CLASS),
@@ -1,4 +1,5 @@
1
1
  "use client";
2
+ import { useExternalSyncEffect, useLatestCallback } from "../effects/effects.js";
2
3
  import { useContentDir } from "../hooks/use-content-dir.js";
3
4
  import { CONTROL_SIZE } from "../lib/control-size.js";
4
5
  import { cn } from "../lib/utils.js";
@@ -26,13 +27,16 @@ const Textarea = ({ className, id, name, disabled, value, defaultValue, size = C
26
27
  if (counted) setTypedLength(event.currentTarget.value.length);
27
28
  onChange?.(event);
28
29
  };
29
- const syncCountOnFormReset = (control) => {
30
+ const [control, setControl] = useState(null);
31
+ const countsUncontrolled = counted && value === void 0;
32
+ const trackValue = useLatestCallback(contentDir.trackValue);
33
+ useExternalSyncEffect(() => {
30
34
  const textarea = control?.querySelector("textarea");
31
35
  const form = textarea?.form;
32
- if (!counted || value !== void 0 || !textarea || !form) return;
36
+ if (!countsUncontrolled || !textarea || !form) return;
33
37
  const handleReset = () => {
34
38
  setTimeout(() => {
35
- contentDir.trackValue(textarea.value);
39
+ trackValue(textarea.value);
36
40
  setTypedLength(textarea.value.length);
37
41
  }, 0);
38
42
  };
@@ -40,7 +44,11 @@ const Textarea = ({ className, id, name, disabled, value, defaultValue, size = C
40
44
  return () => {
41
45
  form.removeEventListener("reset", handleReset);
42
46
  };
43
- };
47
+ }, [
48
+ control,
49
+ countsUncontrolled,
50
+ trackValue
51
+ ]);
44
52
  const textareaStyle = maxRows === void 0 ? style : {
45
53
  ...style,
46
54
  "--textarea-max-rows": maxRows
@@ -50,7 +58,7 @@ const Textarea = ({ className, id, name, disabled, value, defaultValue, size = C
50
58
  "data-appearance": appearance,
51
59
  "data-size": size,
52
60
  "data-slot": "textarea-control",
53
- ref: syncCountOnFormReset,
61
+ ref: setControl,
54
62
  children: [/* @__PURE__ */ jsx(Field.Control, {
55
63
  id,
56
64
  name,
@@ -1,4 +1,5 @@
1
1
  "use client";
2
+ import { useExternalSyncEffect } from "../effects/effects.js";
2
3
  import { useIsMobile } from "../hooks/use-mobile.js";
3
4
  import { NewChatIcon } from "../icons.js";
4
5
  import { InspectorRail, InspectorRailCell, InspectorRailContent, InspectorRailFooter, InspectorRailIconButton } from "../inspector/chrome.js";
@@ -7,7 +8,7 @@ import { SAFE_AREA_BOTTOM_EDGE_CLASS_NAME, SAFE_AREA_TOP_EDGE_CLASS_NAME } from
7
8
  import { cn } from "../lib/utils.js";
8
9
  import { Sheet, SheetContent as SheetPopup, SheetTitle, SheetTrigger } from "./sheet.js";
9
10
  import { jsx, jsxs } from "react/jsx-runtime";
10
- import { useEffect, useId, useRef } from "react";
11
+ import { useId, useRef } from "react";
11
12
  // src/components/workspace-shell.tsx
12
13
  /**
13
14
  * Stella's complete authenticated workspace frame. It owns the dynamic
@@ -24,7 +25,7 @@ const WorkspaceShell = ({ children, endDock, navigation, skipToContentLabel, top
24
25
  const compactNavigation = navigation.mode === "shell-managed" ? navigation.compact : null;
25
26
  const compactNavigationOpen = compactNavigation?.open ?? false;
26
27
  const onCompactNavigationOpenChange = compactNavigation?.onOpenChange;
27
- useEffect(() => {
28
+ useExternalSyncEffect(() => {
28
29
  if (!isCompact && compactNavigationOpen) onCompactNavigationOpenChange?.(false);
29
30
  }, [
30
31
  compactNavigationOpen,
@@ -0,0 +1,9 @@
1
+ import { Ref } from "react";
2
+ /**
3
+ * `composeRefs(...refs)`, memoized on the member refs: the same callback for
4
+ * as long as every member is the same ref, a new one (so React re-attaches)
5
+ * exactly when one of them changes. Pass refs that are themselves stable (a
6
+ * ref object, a `useState` setter, a ref from a hook or a prop); keep the
7
+ * number of refs fixed for a call site.
8
+ */
9
+ export declare const useComposedRefs: <T>(...refs: (Ref<T> | undefined)[]) => ((node: T | null) => (() => void) | undefined);
@@ -0,0 +1,12 @@
1
+ import { composeRefs } from "../lib/utils.js";
2
+ import { useMemo } from "react";
3
+ // src/effects/refs.ts
4
+ /**
5
+ * `composeRefs(...refs)`, memoized on the member refs: the same callback for
6
+ * as long as every member is the same ref, a new one (so React re-attaches)
7
+ * exactly when one of them changes. Pass refs that are themselves stable (a
8
+ * ref object, a `useState` setter, a ref from a hook or a prop); keep the
9
+ * number of refs fixed for a call site.
10
+ */
11
+ const useComposedRefs = (...refs) => useMemo(() => composeRefs(...refs), refs);
12
+ export { useComposedRefs };
package/dist/index.js CHANGED
@@ -11,8 +11,8 @@ import { Breadcrumb, BreadcrumbEllipsis, BreadcrumbItem, BreadcrumbLink, Breadcr
11
11
  import { BUTTON_CONTENT, BUTTON_SIZE_CONTENT, Button, ButtonTextRun, buttonAccessibleDisabledClass, buttonVariants } from "./components/button.js";
12
12
  import { Checkbox } from "./components/checkbox.js";
13
13
  import { Collapsible, CollapsiblePanel, CollapsibleTrigger } from "./components/collapsible.js";
14
- import { Inspector, InspectorActions, InspectorContent, InspectorDescription, InspectorEmptyRow, InspectorHeader, InspectorHeaderText, InspectorProperty, InspectorPropertyLabel, InspectorPropertyList, InspectorPropertyValue, InspectorRail, InspectorRailCell, InspectorRailContent, InspectorRailFooter, InspectorRailIconButton, InspectorRailTab, InspectorSection, InspectorSectionTitle, InspectorTitle } from "./inspector/chrome.js";
15
14
  import { ColorPicker, ColorPickerContent, DEFAULT_PRESETS } from "./components/color-picker.js";
15
+ import { Inspector, InspectorActions, InspectorContent, InspectorDescription, InspectorEmptyRow, InspectorHeader, InspectorHeaderText, InspectorProperty, InspectorPropertyLabel, InspectorPropertyList, InspectorPropertyValue, InspectorRail, InspectorRailCell, InspectorRailContent, InspectorRailFooter, InspectorRailIconButton, InspectorRailTab, InspectorSection, InspectorSectionTitle, InspectorTitle } from "./inspector/chrome.js";
16
16
  import { Combobox, ComboboxChip, ComboboxChips, ComboboxChipsInput, ComboboxClear, ComboboxCollection, ComboboxEmpty, ComboboxGroup, ComboboxGroupLabel, ComboboxInput, ComboboxItem, ComboboxList, ComboboxPopup, ComboboxRow, ComboboxSeparator, ComboboxStatus, ComboboxTrigger, ComboboxValue } from "./components/combobox.js";
17
17
  import { Command, CommandCollection, CommandDialog, CommandDialogPopup, CommandDialogTrigger, CommandEmpty, CommandFooter, CommandGroup, CommandGroupLabel, CommandInput, CommandItem, CommandList, CommandPanel, CommandSeparator, CommandShortcut } from "./components/command.js";
18
18
  import { COPIED_RESET_MS, CopyButton, CopyFeedback, useCopiedFeedback, useCopyConfirmation } from "./components/copy-button.js";
@@ -22,8 +22,8 @@ import { assertConsecutiveCalendarDates, getResourceCalendarPlacement, layoutRes
22
22
  import { DatePickerPopover } from "./components/date-picker-popover.js";
23
23
  import { DetailsGrid, DetailsItem } from "./components/details-grid.js";
24
24
  import { DestructiveActionConfirmation, useDestructiveActionConfirmation } from "./components/destructive-action-confirmation.js";
25
- import { TABLE_FIRST_LINE } from "./components/table-layout.js";
26
25
  import { DestructiveConfirmDialog } from "./components/destructive-confirm-dialog.js";
26
+ import { TABLE_FIRST_LINE } from "./components/table-layout.js";
27
27
  import { DIALOG_MOBILE_LAYOUT, DIALOG_SIZE_CLASS_NAMES, Dialog, DialogBackdrop, DialogClose, DialogContent as DialogPopup, DialogCreateHandle, DialogDescription, DialogFooter, DialogHeader, DialogPanel, DialogPortal, DialogProvider, DialogTitle, DialogTrigger, DialogViewport } from "./components/dialog.js";
28
28
  import { DirectionalIcon } from "./components/directional-icon.js";
29
29
  import { Field, FieldControl, FieldDescription, FieldError, FieldItem, FieldLabel, FieldValidity } from "./components/field.js";
@@ -1,13 +1,14 @@
1
1
  import { Button } from "../components/button.js";
2
2
  import { DropdownMenu as Menu, DropdownMenuContent as MenuPopup, DropdownMenuItem as MenuItem, DropdownMenuTrigger as MenuTrigger } from "../components/menu.js";
3
3
  import { Tooltip, TooltipContent as TooltipPopup, TooltipTrigger } from "../components/tooltip.js";
4
+ import { useExternalSyncEffect } from "../effects/effects.js";
4
5
  import { INLINE_OVERFLOW_ITEM_ATTRIBUTE, INLINE_OVERFLOW_TRIGGER_ATTRIBUTE, useInlineOverflow } from "../hooks/use-inline-overflow.js";
5
6
  import { ChevronDownIcon } from "../icons.js";
6
7
  import { splitInlineOverflow } from "../lib/inline-overflow.js";
7
8
  import { cn } from "../lib/utils.js";
8
9
  import { TOOLBAR_ROW_HEIGHT } from "./layout-tokens.js";
9
10
  import { jsx, jsxs } from "react/jsx-runtime";
10
- import { useEffect, useRef } from "react";
11
+ import { useRef } from "react";
11
12
  // src/inspector/facet-bar.tsx
12
13
  /**
13
14
  * Inspector subtab row: a single line of pill chips at toolbar-row
@@ -32,7 +33,7 @@ const InspectorFacetBar = ({ facet, facets, labels, disabledFacets, pulseSeq, ac
32
33
  });
33
34
  const { visible: visibleFacets, overflow: overflowFacets } = splitInlineOverflow(facets, visibleCount, activeIndex);
34
35
  const overflowing = overflowFacets.length > 0;
35
- useEffect(() => {
36
+ useExternalSyncEffect(() => {
36
37
  if (pulseSeq === void 0 || pulseSeq === lastPulseSeq.current) return;
37
38
  lastPulseSeq.current = pulseSeq;
38
39
  const activeChip = container?.querySelector("[data-facet-chip-active]");
@@ -1,5 +1,6 @@
1
1
  "use client";
2
2
  import { Button } from "../components/button.js";
3
+ import { useExternalSyncEffect, useMountEffect } from "../effects/effects.js";
3
4
  import { GripVerticalIcon } from "../icons.js";
4
5
  import "../lib/overlay-layer.js";
5
6
  import { cn } from "../lib/utils.js";
@@ -343,15 +344,15 @@ const KanbanSortableBoard = ({ children, onDragEnd, mouseActivationDistance, col
343
344
  const [interactionReady, setInteractionReady] = React.useState(false);
344
345
  const interactionReadyNotified = React.useRef(false);
345
346
  const defaultSensors = useKanbanSortableSensors(keyboardCoordinates, mouseActivationDistance);
346
- React.useEffect(() => {
347
+ useMountEffect(() => {
347
348
  const frame = requestAnimationFrame(() => {
348
349
  setInteractionReady(true);
349
350
  });
350
351
  return () => {
351
352
  cancelAnimationFrame(frame);
352
353
  };
353
- }, []);
354
- React.useEffect(() => {
354
+ });
355
+ useExternalSyncEffect(() => {
355
356
  if (!interactionReady || interactionReadyNotified.current) return;
356
357
  interactionReadyNotified.current = true;
357
358
  onInteractionReady?.();
@@ -1,4 +1,5 @@
1
1
  import { DirectionalIcon } from "../components/directional-icon.js";
2
+ import { useExternalSyncEffect, useMountEffect } from "../effects/effects.js";
2
3
  import { ChevronDownIcon } from "../icons.js";
3
4
  import { cn } from "../lib/utils.js";
4
5
  import { createBandPeekController } from "./band-peek.js";
@@ -8,7 +9,7 @@ import { KANBAN_CARD_DRAG_MIME } from "./drag-interactions.js";
8
9
  import { KANBAN_CHROME_TOGGLE_COARSE_TARGET_CLASS, KANBAN_COLLAPSED_BAND_WIDTH_CLASS, KANBAN_COLUMN_WIDTH_CLASS } from "./layout-tokens.js";
9
10
  import { KANBAN_STICKY_TOP_CLASS, KANBAN_STICKY_TOP_VAR, KanbanCollapsedBandCaption } from "./sticky-lane.js";
10
11
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
11
- import { useEffect, useMemo, useRef, useState } from "react";
12
+ import { useMemo, useRef, useState } from "react";
12
13
  // src/kanban/subgroup-board.tsx
13
14
  /**
14
15
  * How far a lane's own pinned row reaches: its identity line over the line of
@@ -49,7 +50,7 @@ const KanbanSubgroupBoard = ({ scrollRef, matrix, renderColumnHeader, renderLane
49
50
  const [peekingBandId, setPeekingBandId] = useState(null);
50
51
  const headerRef = useRef(null);
51
52
  const [headerHeight, setHeaderHeight] = useState(0);
52
- useEffect(() => {
53
+ useMountEffect(() => {
53
54
  const header = headerRef.current;
54
55
  if (header === null) return;
55
56
  const observer = new ResizeObserver(() => {
@@ -57,10 +58,10 @@ const KanbanSubgroupBoard = ({ scrollRef, matrix, renderColumnHeader, renderLane
57
58
  });
58
59
  observer.observe(header);
59
60
  return () => observer.disconnect();
60
- }, []);
61
+ });
61
62
  const [peek] = useState(() => createBandPeekController({ onChange: setPeekingBandId }));
62
- useEffect(() => () => peek.dispose(), [peek]);
63
- useEffect(() => {
63
+ useExternalSyncEffect(() => () => peek.dispose(), [peek]);
64
+ useExternalSyncEffect(() => {
64
65
  const end = () => peek.dragEnded();
65
66
  window.addEventListener("dragend", end);
66
67
  window.addEventListener("drop", end);
@@ -70,7 +71,7 @@ const KanbanSubgroupBoard = ({ scrollRef, matrix, renderColumnHeader, renderLane
70
71
  };
71
72
  }, [peek]);
72
73
  const previousDragOverBandId = useRef(null);
73
- useEffect(() => {
74
+ useExternalSyncEffect(() => {
74
75
  if (dragOverBandId === void 0 || isDragging === false || dragOverBandId === previousDragOverBandId.current) return;
75
76
  const previous = previousDragOverBandId.current;
76
77
  previousDragOverBandId.current = dragOverBandId;
@@ -88,7 +89,7 @@ const KanbanSubgroupBoard = ({ scrollRef, matrix, renderColumnHeader, renderLane
88
89
  peek,
89
90
  peekingBandId
90
91
  ]);
91
- useEffect(() => {
92
+ useExternalSyncEffect(() => {
92
93
  if (isDragging === false) {
93
94
  previousDragOverBandId.current = null;
94
95
  peek.dragEnded();
@@ -150,7 +151,7 @@ const KanbanSubgroupBoard = ({ scrollRef, matrix, renderColumnHeader, renderLane
150
151
  const isBandFolded = (band) => peekingBandId !== band.id && isBandCollapsedNow(band);
151
152
  const peekedBand = peekingBandId === null ? null : spans.find((span) => span.band?.id === peekingBandId)?.band ?? null;
152
153
  const staleBandId = peekingBandId !== null && (peekedBand === null || !isBandCollapsedNow(peekedBand)) ? peekingBandId : null;
153
- useEffect(() => {
154
+ useExternalSyncEffect(() => {
154
155
  if (staleBandId !== null) peek.bandExpanded(staleBandId);
155
156
  }, [peek, staleBandId]);
156
157
  const setBandCollapsed = (band, collapsed) => {
@@ -429,7 +430,7 @@ const isKanbanCardDragEvent = (event) => event.dataTransfer.types.includes(KANBA
429
430
  * band open.
430
431
  */
431
432
  const FoldedBandSlot = ({ band, children, className, peek }) => {
432
- useEffect(() => () => peek.slotUnmounted(band.id), [peek, band.id]);
433
+ useExternalSyncEffect(() => () => peek.slotUnmounted(band.id), [peek, band.id]);
433
434
  return /* @__PURE__ */ jsx("div", {
434
435
  className,
435
436
  "data-kanban-band": band.id,
@@ -1,9 +1,10 @@
1
+ import { useLayoutMeasurement } from "../effects/dom.js";
1
2
  import { resolveOptionColor } from "../lib/option-color.js";
2
3
  import { cn } from "../lib/utils.js";
3
4
  import { useKanbanDropTarget } from "./sortable-interactions.js";
4
5
  import { KANBAN_CARD_STICKY_TOP_VAR, KANBAN_STICKY_TOP_CLASS, resolveKanbanCardStickyTop } from "./sticky-lane.js";
5
6
  import { jsx, jsxs } from "react/jsx-runtime";
6
- import { useId, useLayoutEffect, useRef, useState } from "react";
7
+ import { useId, useRef, useState } from "react";
7
8
  import { useDndContext } from "@dnd-kit/core";
8
9
  import { SortableContext, verticalListSortingStrategy } from "@dnd-kit/sortable";
9
10
  import { defaultRangeExtractor, useVirtualizer } from "@tanstack/react-virtual";
@@ -95,28 +96,12 @@ const KanbanVirtualCell = ({ rows, getRowKey, renderRow, pagination, sortable, c
95
96
  backgroundColor
96
97
  });
97
98
  const hasStickyFooter = footerPlacement === "sticky-start" && footer !== null && footer !== void 0;
98
- const stickyFooterRef = useRef(null);
99
- const [stickyFooterHeight, setStickyFooterHeight] = useState(0);
100
- useLayoutEffect(() => {
101
- const element = stickyFooterRef.current;
102
- if (element === null) {
103
- setStickyFooterHeight(0);
104
- return;
105
- }
106
- const measure = (height) => {
107
- setStickyFooterHeight((current) => current === height ? current : height);
108
- };
109
- measure(element.getBoundingClientRect().height);
110
- const observer = new ResizeObserver(() => {
111
- measure(element.getBoundingClientRect().height);
112
- });
113
- observer.observe(element);
114
- return () => observer.disconnect();
115
- }, [hasStickyFooter]);
99
+ const [stickyFooterElement, setStickyFooterElement] = useState(null);
100
+ const stickyFooterHeight = useLayoutMeasurement(stickyFooterElement, measureHeight, [], 0);
116
101
  const stickyFooter = hasStickyFooter ? /* @__PURE__ */ jsx("div", {
117
102
  className: cn("bg-background sticky z-10", KANBAN_STICKY_TOP_CLASS),
118
103
  "data-kanban-cell-footer": "sticky-start",
119
- ref: stickyFooterRef,
104
+ ref: setStickyFooterElement,
120
105
  children: /* @__PURE__ */ jsx("div", {
121
106
  className: cn("pb-2", surface === void 0 ? KANBAN_CELL_SURFACE_CLASS : "bg-(--kanban-cell-surface)"),
122
107
  children: footer
@@ -165,6 +150,9 @@ const KanbanVirtualCell = ({ rows, getRowKey, renderRow, pagination, sortable, c
165
150
  children: content
166
151
  });
167
152
  };
153
+ function measureHeight(element) {
154
+ return element.getBoundingClientRect().height;
155
+ }
168
156
  function resolveKanbanCellAppearance({ accent, active, backgroundColor }) {
169
157
  const accentVariants = accent === void 0 ? void 0 : resolveOptionColor(accent);
170
158
  const accentBackground = accentVariants === void 0 ? void 0 : `color-mix(in srgb, var(${KANBAN_CELL_ACCENT_VAR}) ${active ? KANBAN_CELL_ACCENT_ACTIVE_ALPHA : KANBAN_CELL_ACCENT_RESTING_ALPHA}%, var(--background))`;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stll/ui",
3
- "version": "0.90.1",
3
+ "version": "0.91.0",
4
4
  "description": "Stella's design system: bidi-aware React primitives built on Base UI, the dockable inspector pane, and the Tailwind v4 theme they are styled with.",
5
5
  "keywords": [
6
6
  "base-ui",
@@ -998,6 +998,10 @@
998
998
  "./effects-dom": {
999
999
  "types": "./dist/effects/dom.d.ts",
1000
1000
  "import": "./dist/effects/dom.js"
1001
+ },
1002
+ "./effects-refs": {
1003
+ "types": "./dist/effects/refs.d.ts",
1004
+ "import": "./dist/effects/refs.js"
1001
1005
  }
1002
1006
  },
1003
1007
  "publishConfig": {