@astryxdesign/core 0.7.15-canary.gf890983 → 0.7.15

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 (91) hide show
  1. package/CHANGELOG.md +72 -2
  2. package/dist/BottomSheet/BottomSheetPanel.d.ts.map +1 -1
  3. package/dist/BottomSheet/BottomSheetPanel.js +5 -4
  4. package/dist/CheckboxInput/CheckboxInput.d.ts.map +1 -1
  5. package/dist/CheckboxInput/CheckboxInput.js +10 -23
  6. package/dist/Item/Item.js +2 -2
  7. package/dist/Layer/useTouchTrigger.d.ts +12 -1
  8. package/dist/Layer/useTouchTrigger.d.ts.map +1 -1
  9. package/dist/Layer/useTouchTrigger.js +22 -3
  10. package/dist/Outline/useScrollSpy.d.ts.map +1 -1
  11. package/dist/Outline/useScrollSpy.js +22 -18
  12. package/dist/RadioList/RadioListItem.d.ts.map +1 -1
  13. package/dist/RadioList/RadioListItem.js +6 -32
  14. package/dist/Resizable/ResizeHandle.d.ts.map +1 -1
  15. package/dist/Resizable/ResizeHandle.js +5 -10
  16. package/dist/Resizable/useResizable.d.ts.map +1 -1
  17. package/dist/Resizable/useResizable.js +6 -5
  18. package/dist/Stepper/Step.js +8 -8
  19. package/dist/Table/plugins/sortable/useTableSortableState.d.ts.map +1 -1
  20. package/dist/Table/plugins/sortable/useTableSortableState.js +8 -4
  21. package/dist/Text/TruncationTooltip.d.ts.map +1 -1
  22. package/dist/Text/TruncationTooltip.js +10 -1
  23. package/dist/Toast/ToastViewport.d.ts.map +1 -1
  24. package/dist/Toast/ToastViewport.js +31 -6
  25. package/dist/Token/Token.js +2 -2
  26. package/dist/Tooltip/useTooltip.d.ts.map +1 -1
  27. package/dist/Tooltip/useTooltip.js +1 -1
  28. package/dist/TreeList/TreeListItem.js +2 -2
  29. package/dist/gestures/GestureHost.d.ts +38 -0
  30. package/dist/gestures/GestureHost.d.ts.map +1 -1
  31. package/dist/gestures/GestureHost.js +95 -1
  32. package/dist/gestures/contextRequest.d.ts +43 -0
  33. package/dist/gestures/contextRequest.d.ts.map +1 -0
  34. package/dist/gestures/contextRequest.js +167 -0
  35. package/dist/hooks/useClickableContainer.d.ts +1 -1
  36. package/dist/hooks/useClickableContainer.d.ts.map +1 -1
  37. package/dist/hooks/useClickableContainer.js +2 -2
  38. package/dist/hooks/useCommittedRef.d.ts +20 -0
  39. package/dist/hooks/useCommittedRef.d.ts.map +1 -0
  40. package/dist/hooks/useCommittedRef.js +38 -0
  41. package/dist/hooks/useMenuPress.d.ts.map +1 -1
  42. package/dist/hooks/useMenuPress.js +23 -27
  43. package/dist/i18n/generated-locales/en.generated.d.ts.map +1 -1
  44. package/dist/i18n/generated-locales/en.generated.js +2 -1
  45. package/dist/i18n/generated-locales/pseudo.generated.d.ts.map +1 -1
  46. package/dist/i18n/generated-locales/pseudo.generated.js +2 -1
  47. package/dist/internal/committed-ref.d.ts +15 -0
  48. package/dist/internal/committed-ref.d.ts.map +1 -0
  49. package/dist/internal/committed-ref.js +15 -0
  50. package/dist/internal/touch.d.ts +2 -1
  51. package/dist/internal/touch.d.ts.map +1 -1
  52. package/dist/internal/touch.js +1 -0
  53. package/dist/keyboard/keyboardHeight.d.ts.map +1 -1
  54. package/dist/keyboard/keyboardHeight.js +13 -9
  55. package/dist/keyboard/useMobileKeyboard.d.ts.map +1 -1
  56. package/dist/keyboard/useMobileKeyboard.js +8 -7
  57. package/dist/privateAttributes/press.stylex.d.ts +40 -10
  58. package/dist/privateAttributes/press.stylex.d.ts.map +1 -1
  59. package/dist/privateAttributes/press.stylex.js +46 -10
  60. package/locales/en.json +4 -0
  61. package/locales/pseudo.json +3 -0
  62. package/package.json +10 -5
  63. package/src/BottomSheet/BottomSheetPanel.tsx +5 -4
  64. package/src/CheckboxInput/CheckboxInput.tsx +20 -60
  65. package/src/Item/Item.tsx +2 -2
  66. package/src/Layer/useTouchTrigger.ts +30 -1
  67. package/src/Outline/useScrollSpy.ts +22 -22
  68. package/src/RadioList/RadioListItem.tsx +19 -79
  69. package/src/Resizable/ResizeHandle.tsx +5 -6
  70. package/src/Resizable/useResizable.ts +5 -5
  71. package/src/Stepper/Step.tsx +6 -6
  72. package/src/Stepper/Stepper.doc.mjs +8 -2
  73. package/src/Table/plugins/sortable/useTableSortableState.tsx +10 -4
  74. package/src/Text/TruncationTooltip.tsx +16 -1
  75. package/src/Toast/ToastViewport.tsx +31 -5
  76. package/src/Token/Token.tsx +2 -2
  77. package/src/Tooltip/useTooltip.tsx +1 -0
  78. package/src/TreeList/TreeListItem.tsx +2 -2
  79. package/src/gestures/GestureHost.ts +125 -1
  80. package/src/gestures/README.md +21 -0
  81. package/src/gestures/contextRequest.ts +206 -0
  82. package/src/hooks/useClickableContainer.ts +2 -2
  83. package/src/hooks/useCommittedRef.ts +39 -0
  84. package/src/hooks/useMenuPress.ts +59 -62
  85. package/src/i18n/generated-locales/en.generated.ts +1 -0
  86. package/src/i18n/generated-locales/pseudo.generated.ts +1 -0
  87. package/src/internal/committed-ref.ts +15 -0
  88. package/src/internal/touch.ts +3 -0
  89. package/src/keyboard/keyboardHeight.ts +15 -17
  90. package/src/keyboard/useMobileKeyboard.ts +8 -7
  91. package/src/privateAttributes/press.stylex.ts +109 -10
@@ -35,6 +35,7 @@
35
35
  */
36
36
 
37
37
  import {useCallback, useEffect, useRef, useState} from 'react';
38
+ import {useCommittedRef} from '../hooks/useCommittedRef';
38
39
  import {scrollingAncestor} from '../utils/scrollingAncestor';
39
40
  import type {OutlineItem} from './types';
40
41
 
@@ -126,11 +127,11 @@ function scrollToTarget(
126
127
  * the first), the first item is active; at the bottom, the last item is active.
127
128
  */
128
129
  function resolveActiveId(
129
- items: OutlineItem[],
130
+ ids: ReadonlyArray<string>,
130
131
  scrollRoot: HTMLElement | null,
131
132
  offset: number,
132
133
  ): string | undefined {
133
- if (items.length === 0) {
134
+ if (ids.length === 0) {
134
135
  return undefined;
135
136
  }
136
137
 
@@ -141,12 +142,12 @@ function resolveActiveId(
141
142
  : window.innerHeight + window.scrollY >=
142
143
  document.documentElement.scrollHeight - 2;
143
144
  if (atBottom) {
144
- return items[items.length - 1].id;
145
+ return ids[ids.length - 1];
145
146
  }
146
147
 
147
- let activeId = items[0].id;
148
- for (const item of items) {
149
- const element = document.getElementById(item.id);
148
+ let activeId = ids[0];
149
+ for (const id of ids) {
150
+ const element = document.getElementById(id);
150
151
  if (element == null) {
151
152
  continue;
152
153
  }
@@ -154,7 +155,7 @@ function resolveActiveId(
154
155
  // 1px of tolerance absorbs sub-pixel rounding after a scroll lands.
155
156
  const top = element.getBoundingClientRect().top;
156
157
  if (top <= getRestingTop(element, scrollRoot, offset) + 1) {
157
- activeId = item.id;
158
+ activeId = id;
158
159
  } else {
159
160
  break;
160
161
  }
@@ -218,7 +219,10 @@ export function useScrollSpy({
218
219
  const [uncontrolledActiveId, setUncontrolledActiveId] = useState<
219
220
  string | undefined
220
221
  >(items[0]?.id);
221
- const activeIdRef = useRef<string | undefined>(activeId);
222
+ // The uncontrolled active item, for the scroll listener's comparison. It
223
+ // starts as the state does, and every handler that sets the uncontrolled
224
+ // state writes it too.
225
+ const activeIdRef = useRef<string | undefined>(uncontrolledActiveId);
222
226
  // While true, scroll-spy ignores scroll updates because a navigation is
223
227
  // driving a programmatic scroll. Released when it settles or the user scrolls.
224
228
  const suppressRef = useRef(false);
@@ -232,14 +236,12 @@ export function useScrollSpy({
232
236
  // Latest scroll-position resolver, so a navigation can resume tracking when
233
237
  // the user scrolls during the programmatic scroll.
234
238
  const syncRef = useRef<(() => void) | null>(null);
235
- // Keep latest items/callback in refs so the scroll listener effect doesn't
236
- // re-subscribe on every render (items is a fresh array each render).
237
- const itemsRef = useRef(items);
238
- itemsRef.current = items;
239
- const onActiveIdChangeRef = useRef(onActiveIdChange);
240
- onActiveIdChangeRef.current = onActiveIdChange;
241
- const itemIds = items.map(item => item.id).join('\n');
242
- activeIdRef.current = isControlled ? activeId : uncontrolledActiveId;
239
+ // The scroll listener reads the callback through this ref, so it does not
240
+ // subscribe again on each render.
241
+ const onActiveIdChangeRef = useCommittedRef(onActiveIdChange);
242
+ // Items is a new array each render. The scroll listener subscribes with
243
+ // their ids, and subscribes again only when the ids change.
244
+ const itemIds = JSON.stringify(items.map(item => item.id));
243
245
 
244
246
  /**
245
247
  * The element whose scroll position drives the outline: the explicit
@@ -262,6 +264,7 @@ export function useScrollSpy({
262
264
 
263
265
  const scrollRoot = getScrollRoot();
264
266
  const scrollTarget: HTMLElement | Window = scrollRoot ?? window;
267
+ const ids = JSON.parse(itemIds) as string[];
265
268
 
266
269
  let frame = 0;
267
270
  const update = () => {
@@ -269,11 +272,7 @@ export function useScrollSpy({
269
272
  if (suppressRef.current) {
270
273
  return;
271
274
  }
272
- const nextActiveId = resolveActiveId(
273
- itemsRef.current,
274
- scrollRoot,
275
- offset,
276
- );
275
+ const nextActiveId = resolveActiveId(ids, scrollRoot, offset);
277
276
  if (nextActiveId != null && nextActiveId !== activeIdRef.current) {
278
277
  activeIdRef.current = nextActiveId;
279
278
  setUncontrolledActiveId(nextActiveId);
@@ -299,7 +298,7 @@ export function useScrollSpy({
299
298
  cancelAnimationFrame(frame);
300
299
  }
301
300
  };
302
- }, [isControlled, itemIds, offset, getScrollRoot]);
301
+ }, [isControlled, itemIds, offset, getScrollRoot, onActiveIdChangeRef]);
303
302
 
304
303
  // Tear down any in-flight navigation's listeners when the Outline unmounts.
305
304
  useEffect(() => {
@@ -310,6 +309,7 @@ export function useScrollSpy({
310
309
 
311
310
  const setActiveId = (nextActiveId: string) => {
312
311
  if (!isControlled) {
312
+ activeIdRef.current = nextActiveId;
313
313
  setUncontrolledActiveId(nextActiveId);
314
314
  }
315
315
  onActiveIdChange?.(nextActiveId);
@@ -25,7 +25,7 @@ import type {BaseProps} from '../BaseProps';
25
25
  import {RadioListContext} from './RadioList';
26
26
  import {RadioListReasonContext} from './RadioListReasonContext';
27
27
  import {joinAriaIDs} from '../utils/inputAria';
28
- import {colorVars, radiusVars} from '../theme/tokens.stylex';
28
+ import {radiusVars} from '../theme/tokens.stylex';
29
29
  import {isRenderable} from '../utils/isRenderable';
30
30
  import {mergeProps} from '../utils/mergeProps';
31
31
  import {rtlStyles} from '../utils/rtlStyles';
@@ -40,53 +40,19 @@ import {touchHitAreaStyles} from '../internal/touchHitArea.stylex';
40
40
  import {useIndicator} from '../Indicator/useIndicator';
41
41
  import {Item, type ItemAlign} from '../Item/Item';
42
42
  import {themeProps} from '../utils/themeProps';
43
- import {rowPressLayerStyles} from '../privateAttributes/press.stylex';
43
+ import {
44
+ indicatorPressPaintStyles,
45
+ rowPressLayerStyles,
46
+ rowPressPaintStyles,
47
+ } from '../privateAttributes/press.stylex';
44
48
 
45
49
  // Registered here, not in the press controller, so a page with no box carries
46
50
  // none of its code.
47
51
  registerBoxHold();
48
52
 
49
- // The touch press's paint, declared by the shared overlay styles on the
50
- // element the controller writes to (`pressedAlpha`) at the press's strength,
51
- // 1 while on and 1 → 0 over the release, and inherited resolved by the layer
52
- // that paints it. See interactionOverlay.stylex.ts.
53
- const pressedOverlayImage = 'var(--_press-paint-image)';
54
-
55
- /** Written by the press controller while the row is pressed. */
56
- const PRESSED_ON = '[data-astryx-press="on"]';
57
- /** Written by the press controller for the press's release. */
58
- const PRESSED_FADING = '[data-astryx-press="fading"]';
59
-
60
- /**
61
- * The nested controls that keep their own press, each at `:active`. It is
62
- * INTERACTIVE_SELECTORS (hooks/useClickableContainer.ts), which StyleX cannot
63
- * import, less the read-only ones. The row's own radio is the row's action,
64
- * so its press is the row's. CSS cannot tell it from a nested radio input, so
65
- * a nested one presses the circle too. RadioListItem.press.source-build.test.mjs
66
- * keeps the two lists equal.
67
- */
68
- const NESTED_CONTROL_ACTIVE =
69
- 'button:not([aria-readonly="true"]):active,' +
70
- 'a:not([aria-readonly="true"]):active,' +
71
- 'input:not([type="radio"],[aria-readonly="true"]):active,' +
72
- 'select:not([aria-readonly="true"]):active,' +
73
- 'textarea:not([aria-readonly="true"]):active,' +
74
- '[role="button"]:not([aria-readonly="true"]):active,' +
75
- '[role="link"]:not([aria-readonly="true"]):active,' +
76
- '[role="checkbox"]:not([aria-readonly="true"]):active,' +
77
- '[role="radio"]:not([aria-readonly="true"]):active,' +
78
- '[role="switch"]:not([aria-readonly="true"]):active,' +
79
- '[role="tab"]:not([aria-readonly="true"]):active,' +
80
- '[role="menuitem"]:not([aria-readonly="true"]):active,' +
81
- '[role="option"]:not([aria-readonly="true"]):active,' +
82
- '[role="combobox"]:not([aria-readonly="true"]):active,' +
83
- '[role="listbox"]:not([aria-readonly="true"]):active,' +
84
- '[role="slider"]:not([aria-readonly="true"]):active,' +
85
- '[role="spinbutton"]:not([aria-readonly="true"]):active,' +
86
- '[data-pressable-container]:not([aria-readonly="true"]):active';
87
-
88
53
  // The paint of a press the controller does not paint, declared on the row
89
- // and inherited by the layer over the circle. Internal: not a theme hook.
54
+ // (`rowPressPaintStyles.radioRow`) and inherited by the layer over the circle.
55
+ // Internal: not a theme hook.
90
56
  const ROW_PRESS = '--_radio-row-press';
91
57
 
92
58
  const styles = stylex.create({
@@ -98,16 +64,17 @@ const styles = stylex.create({
98
64
  flexShrink: 0,
99
65
  isolation: 'isolate',
100
66
  },
101
- // The row remains the large press target, but nested controls keep their
102
- // independent action and do not make the radio appear pressed: the
103
- // row declares the mouse press's paint (`rowStyles.press`) and this layer
104
- // reads it. This owner-drawn layer also survives a theme replacing the
105
- // indicator component.
67
+ // The row remains the large press target. Nested controls keep their own
68
+ // action and do not make the radio look pressed. The row declares the paint
69
+ // of a press the controller does not paint (`rowPressPaintStyles.radioRow`),
70
+ // and this layer reads it. This owner-drawn layer also survives a theme
71
+ // replacing the indicator component.
106
72
  // The press controller writes its press attribute on the row for every
107
- // pointer: a finger, a mouse and a pen. This layer reads it off the same
108
- // scope marker as the hover tint. The controller paints the innermost pressable.
73
+ // pointer: a finger, a mouse and a pen. Its image layer
74
+ // (`indicatorPressPaintStyles.image`) reads it off the same scope marker as
75
+ // the hover tint. The controller paints the innermost pressable.
109
76
  // A press on a control nested in the row is that control's. The row's
110
- // container rule (cancelNestedTouchPress) ends the row's paint at once.
77
+ // container rule (cancelNestedPress) ends the row's paint at once.
111
78
  // `:active` paints only a press the controller does not paint, and under a
112
79
  // coarse pointer it is dropped.
113
80
  indicatorPressOverlay: {
@@ -118,17 +85,6 @@ const styles = stylex.create({
118
85
  borderRadius: radiusVars['--radius-full'],
119
86
  pointerEvents: 'none',
120
87
  backgroundColor: `var(${ROW_PRESS}, transparent)`,
121
- // The controller's press paints as an image layer over the colour. An
122
- // image change is discrete, so no transition can delay the onset. Only
123
- // the strength moves: the row's `pressedAlpha` arms set it to 1 while
124
- // on, and 1 → 0 over the release. This holds for every pointer, because
125
- // the controller writes the attribute only for a press it paints.
126
- backgroundImage: {
127
- default: null,
128
- [stylex.when.ancestor(PRESSED_ON, indicatorScope)]: pressedOverlayImage,
129
- [stylex.when.ancestor(PRESSED_FADING, indicatorScope)]:
130
- pressedOverlayImage,
131
- },
132
88
  },
133
89
  },
134
90
  input: {
@@ -187,23 +143,6 @@ const rowStyles = stylex.create({
187
143
  // hovered row look identical by default (a theme can restyle either).
188
144
  backgroundColor: 'transparent',
189
145
  },
190
- // A press the controller does not paint: the controller's own press lives
191
- // on its attribute. The row is pressed, but not through a nested control.
192
- // Such a control keeps its own press, as the row's container rule decides
193
- // for the controller. The `:has()` is on the row itself and reaches no
194
- // descendant selector. So a change inside the row re-checks the row alone.
195
- // The circle's layer reads the paint through inheritance. A relation would
196
- // restyle everything under the row.
197
- press: {
198
- [ROW_PRESS]: {
199
- default: null,
200
- [`:active:not(${PRESSED_ON},${PRESSED_FADING}):not(:has(${NESTED_CONTROL_ACTIVE}))`]:
201
- {
202
- default: colorVars['--color-overlay-pressed'],
203
- '@media (pointer: coarse)': 'transparent',
204
- },
205
- },
206
- },
207
146
  });
208
147
 
209
148
  export interface RadioListItemProps extends BaseProps<HTMLDivElement> {
@@ -361,6 +300,7 @@ export function RadioListItem({
361
300
  styles.radioWrapper,
362
301
  wrapperSizeStyles[size],
363
302
  !isDisabled && styles.indicatorPressOverlay,
303
+ !isDisabled && indicatorPressPaintStyles.image,
364
304
  )}
365
305
  {...focusProps}>
366
306
  <input
@@ -468,7 +408,7 @@ export function RadioListItem({
468
408
  // styles so it wins within the base layer; a `radio-list-item` theme
469
409
  // still overrides it from the higher `astryx-theme` layer.
470
410
  rowStyles.root,
471
- !isDisabled && rowStyles.press,
411
+ !isDisabled && rowPressPaintStyles.radioRow,
472
412
  !isDisabled && touchHitAreaStyles.layer,
473
413
  xstyle,
474
414
  ] as StyleXStyles
@@ -50,6 +50,7 @@ import {separatorAttributes} from './separatorAttributes';
50
50
  import {themeProps} from '../utils/themeProps';
51
51
 
52
52
  import {useDevWarning} from '../hooks/useDevWarning';
53
+ import {useCommittedRef} from '../hooks/useCommittedRef';
53
54
  import {useIsomorphicLayoutEffect} from '../hooks/useIsomorphicLayoutEffect';
54
55
  import {useMergedRefs} from '../hooks/useMergedRefs';
55
56
  import {useInteractionModalityTracking} from '../utils/interactionModality';
@@ -437,15 +438,13 @@ export function ResizeHandle({
437
438
 
438
439
  // --- The region a `resizable` prop describes ---
439
440
 
440
- // The gesture reads the latest props at each input. A drag sees the region
441
- // as it is now, not as it was at the press.
442
- const resizableRef = useRef(resizable);
443
- resizableRef.current = resizable;
441
+ // The gesture reads the committed props at each input. A drag sees the
442
+ // region as it is now, not as it was at the press.
443
+ const resizableRef = useCommittedRef(resizable);
444
444
  // The region a drag in flight started on: told the gesture is over even
445
445
  // after the prop has gone.
446
446
  const dragRegionRef = useRef<ResizableProps | undefined>(undefined);
447
- const configRef = useRef({direction, isReversed, isDisabled});
448
- configRef.current = {direction, isReversed, isDisabled};
447
+ const configRef = useCommittedRef({direction, isReversed, isDisabled});
449
448
  const [isDragging, setIsDragging] = useState(false);
450
449
  const [regionGesture] = useState<ResizeGesture>(() => {
451
450
  const model: ResizeGestureModel = {
@@ -15,11 +15,11 @@
15
15
  import {
16
16
  useCallback,
17
17
  useReducer,
18
- useRef,
19
18
  useState,
20
19
  useSyncExternalStore,
21
20
  type RefObject,
22
21
  } from 'react';
22
+ import {useCommittedRef} from '../hooks/useCommittedRef';
23
23
  import {useIsomorphicLayoutEffect} from '../hooks/useIsomorphicLayoutEffect';
24
24
  import type {SizeValue} from '../utils/types';
25
25
  import type {ResizableSize} from './utils';
@@ -571,8 +571,8 @@ function useResizableController(
571
571
  options: CreateResizableOptions,
572
572
  regionSlot?: RegionPaneSlot,
573
573
  ): ResizableReading {
574
- const optionsRef = useRef(options);
575
- optionsRef.current = options;
574
+ // The committed options, which the factory starts from.
575
+ const optionsRef = useCommittedRef(options);
576
576
  const [slot] = useState(() => createSlot(readInitialResizableState(options)));
577
577
  const [serverInitial] = useState(() =>
578
578
  readInitialResizableState(options, 'server'),
@@ -601,7 +601,7 @@ function useResizableController(
601
601
  const passed = optionsRef.current;
602
602
  const resizable = start(passed);
603
603
  slot.set({resizable, passed});
604
- }, [slot, start]);
604
+ }, [optionsRef, slot, start]);
605
605
  useIsomorphicLayoutEffect(() => {
606
606
  follow();
607
607
  });
@@ -680,7 +680,7 @@ function useResizableController(
680
680
  readResizableInternals(resizable)?.suspend();
681
681
  slot.set({resizable, passed});
682
682
  return resizable;
683
- }, [slot, start]);
683
+ }, [optionsRef, slot, start]);
684
684
  const collapse = useCallback(() => {
685
685
  ensureResizable().collapse();
686
686
  }, [ensureResizable]);
@@ -1190,6 +1190,7 @@ export function Step({
1190
1190
  themeProps('step-indicator', {
1191
1191
  progress,
1192
1192
  status: status ?? undefined,
1193
+ disabled: isDisabled ? 'disabled' : null,
1193
1194
  }),
1194
1195
  stylex.props(styles.numberBadge, numberColorStyle),
1195
1196
  )}>
@@ -1264,6 +1265,7 @@ export function Step({
1264
1265
  themeProps('step-indicator', {
1265
1266
  progress,
1266
1267
  status: status ?? undefined,
1268
+ disabled: isDisabled ? 'disabled' : null,
1267
1269
  }),
1268
1270
  stylex.props(styles.icon, iconColorStyle),
1269
1271
  )}>
@@ -1315,14 +1317,11 @@ export function Step({
1315
1317
  : undefined;
1316
1318
 
1317
1319
  // Both text parts carry {progress, status}, the phase vocabulary of
1318
- // `step-indicator` above. The label additionally owns Stepper's disabled
1319
- // paint, so it alone carries disabled below.
1320
+ // `step-indicator` above. The indicator and the label each own disabled
1321
+ // paint, so each carries disabled; the description does not.
1320
1322
  const labelThemeProps = themeProps('step-label', {
1321
1323
  progress,
1322
1324
  status: status ?? undefined,
1323
- // The label owns Stepper's disabled paint (`styles.labelDisabled` above),
1324
- // so it owns the selector too. The description does not change under
1325
- // disabled and deliberately keeps the smaller {progress, status} surface.
1326
1325
  disabled: isDisabled ? 'disabled' : null,
1327
1326
  });
1328
1327
  const descriptionThemeProps = themeProps('step-description', {
@@ -1398,7 +1397,8 @@ export function Step({
1398
1397
  </div>
1399
1398
  ) : null;
1400
1399
 
1401
- // Theme data attributes reflect progress + optional semantic status.
1400
+ // The step paints nothing of its own when disabled, so it carries no
1401
+ // `disabled` selector.
1402
1402
  const stepThemeProps = themeProps('step', {
1403
1403
  progress,
1404
1404
  status: status ?? undefined,
@@ -121,7 +121,10 @@ export const docs = {
121
121
  {className: 'astryx-stepper-frame'},
122
122
  {className: 'astryx-stepper-summary'},
123
123
  {className: 'astryx-step', visualProps: ['progress', 'status']},
124
- {className: 'astryx-step-indicator', visualProps: ['progress', 'status']},
124
+ {
125
+ className: 'astryx-step-indicator',
126
+ visualProps: ['progress', 'status', 'disabled'],
127
+ },
125
128
  {
126
129
  className: 'astryx-step-label',
127
130
  visualProps: ['progress', 'status', 'disabled'],
@@ -334,7 +337,10 @@ export const docsZh = {
334
337
  {className: 'astryx-stepper-frame'},
335
338
  {className: 'astryx-stepper-summary'},
336
339
  {className: 'astryx-step', visualProps: ['progress', 'status']},
337
- {className: 'astryx-step-indicator', visualProps: ['progress', 'status']},
340
+ {
341
+ className: 'astryx-step-indicator',
342
+ visualProps: ['progress', 'status', 'disabled'],
343
+ },
338
344
  {
339
345
  className: 'astryx-step-label',
340
346
  visualProps: ['progress', 'status', 'disabled'],
@@ -287,13 +287,19 @@ export function useTableSortableState<
287
287
  const comparatorsRef = useRef(comparators);
288
288
  comparatorsRef.current = comparators;
289
289
 
290
- // Stable ref for onSortChange to avoid recreating sortConfig on inline callback identity changes
290
+ // The config holds one stable handler, so an inline callback does not
291
+ // recreate it. The handler reads the latest callback when the user sorts.
291
292
  const onSortChangeRef = useRef(onSortChange);
292
293
  onSortChangeRef.current = onSortChange;
294
+ const handleSortChange = useCallback(
295
+ (nextSort: TableSortState<TSortKey>) => onSortChangeRef.current(nextSort),
296
+ [],
297
+ );
293
298
 
294
299
  // Sorted data — memoized on sort state + data identity
295
300
  const sortedData = useMemo(
296
- () => sortData(data, sort, comparatorsRef.current, collator),
301
+ () => sortData(data, sort, comparators, collator),
302
+ // eslint-disable-next-line @eslint-react/exhaustive-deps -- comparator identity is not reactive: callers often pass an inline object
297
303
  [data, sort, collator],
298
304
  );
299
305
 
@@ -308,11 +314,11 @@ export function useTableSortableState<
308
314
  const sortConfig = useMemo(
309
315
  (): UseTableSortableConfig<TSortKey> => ({
310
316
  sort,
311
- onSortChange: onSortChangeRef.current,
317
+ onSortChange: handleSortChange,
312
318
  allowUnsortedState,
313
319
  isMultiSortEnabled,
314
320
  }),
315
- [sort, allowUnsortedState, isMultiSortEnabled],
321
+ [sort, handleSortChange, allowUnsortedState, isMultiSortEnabled],
316
322
  );
317
323
 
318
324
  return {sortedData, sort, sortConfig, applySort};
@@ -28,6 +28,7 @@ import type {LayerPlacement} from '../Layer';
28
28
  import {createModuleLoader} from '../utils/moduleLoader';
29
29
  import type {Tooltip as TooltipType} from '../Tooltip/Tooltip';
30
30
  import {useTapRecognizer} from '../Layer/useTouchTrigger';
31
+ import {isElement} from '../utils/nodeType';
31
32
  import {
32
33
  TooltipPresentInterestContext,
33
34
  type TooltipPresentInterestState,
@@ -140,7 +141,21 @@ export function useTruncationTooltipInterest(
140
141
  },
141
142
  [isEnabled, tapRecognizer, want, forget],
142
143
  );
143
- const onFocus = useCallback(() => want('focus'), [want]);
144
+ const onFocus = useCallback(
145
+ (event: FocusEvent<HTMLElement>) => {
146
+ const target = event.target;
147
+ if (
148
+ isElement(target) &&
149
+ target.matches(':focus-visible') &&
150
+ // Chrome on Android focuses a tapped child before the tap's click.
151
+ // Skip that focus, so the click still opens the tooltip.
152
+ !tapRecognizer.isTouchPressCurrent()
153
+ ) {
154
+ want('focus');
155
+ }
156
+ },
157
+ [want, tapRecognizer],
158
+ );
144
159
  const onBlur = useCallback(() => forget('focus'), [forget]);
145
160
  return {
146
161
  isWanted,
@@ -18,6 +18,7 @@
18
18
  */
19
19
 
20
20
  import {
21
+ Fragment,
21
22
  useCallback,
22
23
  useEffect,
23
24
  useLayoutEffect,
@@ -25,6 +26,7 @@ import {
25
26
  useRef,
26
27
  useState,
27
28
  } from 'react';
29
+ import {useCommittedRefInto} from '../hooks/useCommittedRef';
28
30
  import type {ReactNode} from 'react';
29
31
  import {createPortal} from 'react-dom';
30
32
  import * as stylex from '@stylexjs/stylex';
@@ -372,6 +374,21 @@ function ToastRow({
372
374
  }
373
375
  ToastRow.displayName = 'ToastRow';
374
376
 
377
+ /**
378
+ * ToastViewport renders ToastRefSync, which writes through useCommittedRefInto,
379
+ * before its children, so a child's layout cleanup reads the committed list.
380
+ */
381
+ function ToastRefSync<T>({
382
+ targetRef,
383
+ value,
384
+ }: {
385
+ targetRef: {current: T};
386
+ value: T;
387
+ }): null {
388
+ useCommittedRefInto(targetRef, value);
389
+ return null;
390
+ }
391
+
375
392
  /**
376
393
  * Container that renders and manages toast notifications. Place at the root
377
394
  * of your app to enable useToast(). Toasts stack with enter/exit
@@ -395,13 +412,20 @@ export function ToastViewport({
395
412
  const t = useComponentTranslator();
396
413
  const [toasts, setToasts] = useState<ToastEntry[]>([]);
397
414
  const [exitingIds, setExitingIds] = useState<Set<string>>(new Set());
415
+ // The handlers' list. addToast and removeToast move it ahead of the
416
+ // committed toasts within a batch, and each render resets it. It stays
417
+ // written during render on purpose. A reset at commit would drop a toast a
418
+ // handler raised while that render was in progress, as concurrent rendering
419
+ // allows.
398
420
  const toastsRef = useRef(toasts);
399
421
  toastsRef.current = toasts;
400
- // The list as last rendered: addToast moves toastsRef ahead of it within
401
- // a batch, so this tells a rendered toast from one raised since.
422
+ // The list as last committed, so a handler tells a rendered toast from one
423
+ // raised since. `ToastRefSync` writes it.
402
424
  const renderedToastsRef = useRef(toasts);
403
- renderedToastsRef.current = toasts;
404
- // Read by removeToast, which keeps one identity across renders.
425
+ // Read by removeToast, which keeps one identity across renders. It stays
426
+ // written during render on purpose. A dismissal reads the limit of the
427
+ // latest render. A toast that a pending lower limit hides leaves at once, so
428
+ // that commit cannot cut its exit.
405
429
  const maxVisibleRef = useRef(maxVisible);
406
430
  maxVisibleRef.current = maxVisible;
407
431
  // Rendered entries a repeat has replaced in this batch: still found by a
@@ -997,7 +1021,9 @@ export function ToastViewport({
997
1021
 
998
1022
  return (
999
1023
  <ToastContext value={contextValue}>
1000
- {children}
1024
+ <ToastRefSync targetRef={renderedToastsRef} value={toasts} />
1025
+ {/* Its own fiber, so a child it unmounts is unmounted after the sync. */}
1026
+ <Fragment>{children}</Fragment>
1001
1027
  {isTopLayer ? (
1002
1028
  <>
1003
1029
  <div ref={rootOutletRef} {...stylex.props(styles.rootOutlet)} />
@@ -39,7 +39,7 @@ import {themeProps} from '../utils/themeProps';
39
39
  import {focusOutlineProps} from '../utils/focusOutline.stylex';
40
40
  import {interactionOverlayStyles} from '../utils/interactionOverlay.stylex';
41
41
  import {usePressFeedback} from '../hooks/usePressFeedback';
42
- import {cancelNestedTouchPress} from '../hooks/useClickableContainer';
42
+ import {cancelNestedPress} from '../hooks/useClickableContainer';
43
43
  import type {TokenColorMap} from './index';
44
44
  import {disabledInteractionProps} from '../utils/disabledInteraction';
45
45
  import {TokenNamingContext} from './TokenNamingContext';
@@ -524,7 +524,7 @@ export function Token({
524
524
  e: React.PointerEvent<HTMLSpanElement>,
525
525
  ) => {
526
526
  rest.onPointerDown?.(e);
527
- cancelNestedTouchPress(
527
+ cancelNestedPress(
528
528
  e,
529
529
  e.currentTarget,
530
530
  e.currentTarget.querySelector(':scope > button'),
@@ -413,6 +413,7 @@ export function useTooltip(options: TooltipOptions = {}): TooltipReturn {
413
413
  hide: hideFromTouch,
414
414
  },
415
415
  handleReleaseInLayer,
416
+ true,
416
417
  );
417
418
 
418
419
  const isHeldOpen = useCallback(() => {
@@ -31,7 +31,7 @@ import {interactionOverlayStyles} from '../utils/interactionOverlay.stylex';
31
31
  import {rowPressLayerStyles} from '../privateAttributes/press.stylex';
32
32
  import {usePressFeedback} from '../hooks/usePressFeedback';
33
33
  import {
34
- cancelNestedTouchPress,
34
+ cancelNestedPress,
35
35
  hasInteractiveAncestor,
36
36
  useClickableContainer,
37
37
  } from '../hooks/useClickableContainer';
@@ -508,7 +508,7 @@ export function TreeListItem({
508
508
  chevron.contains(event.target)
509
509
  ? chevron
510
510
  : (linkRef.current ?? actionButtonRef.current);
511
- cancelNestedTouchPress(event, event.currentTarget, ownAction);
511
+ cancelNestedPress(event, event.currentTarget, ownAction);
512
512
  };
513
513
  const {onMouseUp: openLinkOnMiddleClick} = useClickableContainer({
514
514
  containerRef: linkRowRef,