@astryxdesign/core 0.7.14 → 0.7.15-canary.g79b95eb

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 (131) hide show
  1. package/dist/Calendar/Calendar.d.ts.map +1 -1
  2. package/dist/Calendar/Calendar.js +11 -2
  3. package/dist/Calendar/getInitialFocusDate.d.ts +8 -3
  4. package/dist/Calendar/getInitialFocusDate.d.ts.map +1 -1
  5. package/dist/Calendar/getInitialFocusDate.js +42 -7
  6. package/dist/CheckboxInput/CheckboxInput.d.ts.map +1 -1
  7. package/dist/CheckboxInput/CheckboxInput.js +9 -4
  8. package/dist/CheckboxList/CheckboxListItem.d.ts.map +1 -1
  9. package/dist/CheckboxList/CheckboxListItem.js +3 -8
  10. package/dist/DateInput/useTypedDate.d.ts.map +1 -1
  11. package/dist/DateInput/useTypedDate.js +3 -2
  12. package/dist/DateTimeInput/DateTimeInput.d.ts.map +1 -1
  13. package/dist/DateTimeInput/DateTimeInput.js +6 -3
  14. package/dist/DateTimeInput/NativeDateSegment.d.ts.map +1 -1
  15. package/dist/DateTimeInput/NativeDateSegment.js +23 -9
  16. package/dist/DateTimeInput/NativeTimeSegment.d.ts.map +1 -1
  17. package/dist/DateTimeInput/NativeTimeSegment.js +22 -8
  18. package/dist/Drawer/Drawer.d.ts.map +1 -1
  19. package/dist/Drawer/Drawer.js +7 -5
  20. package/dist/DropdownMenu/MenuBottomSheetActionList.d.ts.map +1 -1
  21. package/dist/DropdownMenu/MenuBottomSheetActionList.js +5 -1
  22. package/dist/Item/Item.d.ts +1 -1
  23. package/dist/Item/Item.d.ts.map +1 -1
  24. package/dist/Item/Item.js +4 -2
  25. package/dist/Link/useLinkify.d.ts.map +1 -1
  26. package/dist/Link/useLinkify.js +3 -2
  27. package/dist/List/List.d.ts +4 -1
  28. package/dist/List/List.d.ts.map +1 -1
  29. package/dist/Markdown/Markdown.d.ts.map +1 -1
  30. package/dist/Markdown/Markdown.js +8 -0
  31. package/dist/RadioList/RadioListItem.d.ts.map +1 -1
  32. package/dist/RadioList/RadioListItem.js +19 -4
  33. package/dist/SegmentedControl/useSegmentedSelectionMotion.d.ts +43 -15
  34. package/dist/SegmentedControl/useSegmentedSelectionMotion.d.ts.map +1 -1
  35. package/dist/SegmentedControl/useSegmentedSelectionMotion.js +108 -18
  36. package/dist/SegmentedControl/useSegmentedTouchTracking.d.ts.map +1 -1
  37. package/dist/SegmentedControl/useSegmentedTouchTracking.js +5 -0
  38. package/dist/Table/plugins/sortable/useTableSortableState.d.ts.map +1 -1
  39. package/dist/Table/plugins/sortable/useTableSortableState.js +7 -3
  40. package/dist/Token/Token.d.ts.map +1 -1
  41. package/dist/Token/Token.js +2 -0
  42. package/dist/Tokenizer/Tokenizer.d.ts.map +1 -1
  43. package/dist/Tokenizer/Tokenizer.js +85 -12
  44. package/dist/astryx.css +11 -10
  45. package/dist/gestures/GestureHost.d.ts +5 -0
  46. package/dist/gestures/GestureHost.d.ts.map +1 -1
  47. package/dist/gestures/GestureHost.js +54 -28
  48. package/dist/hooks/menuPressGesture.d.ts +39 -2
  49. package/dist/hooks/menuPressGesture.d.ts.map +1 -1
  50. package/dist/hooks/menuPressGesture.js +92 -5
  51. package/dist/hooks/scrollOwnerRegistry.d.ts +0 -1
  52. package/dist/hooks/scrollOwnerRegistry.d.ts.map +1 -1
  53. package/dist/hooks/scrollOwnerRegistry.js +4 -1
  54. package/dist/hooks/useClickableContainer.d.ts +6 -4
  55. package/dist/hooks/useClickableContainer.d.ts.map +1 -1
  56. package/dist/hooks/useClickableContainer.js +11 -8
  57. package/dist/hooks/useFocusTrap.d.ts.map +1 -1
  58. package/dist/hooks/useFocusTrap.js +6 -0
  59. package/dist/hooks/useMenuPress.d.ts.map +1 -1
  60. package/dist/hooks/useMenuPress.js +35 -2
  61. package/dist/hooks/useStreamingText.d.ts.map +1 -1
  62. package/dist/hooks/useStreamingText.js +38 -23
  63. package/dist/i18n/generated-english/DateInput/useTypedDate.generated.js +2 -2
  64. package/dist/i18n/generated-locales/en.generated.js +2 -2
  65. package/dist/i18n/generated-locales/pseudo.generated.js +2 -2
  66. package/dist/motion/uikit/segmented.d.ts +35 -7
  67. package/dist/motion/uikit/segmented.d.ts.map +1 -1
  68. package/dist/motion/uikit/segmented.js +39 -11
  69. package/dist/privateAttributes/press.stylex.d.ts.map +1 -1
  70. package/dist/privateAttributes/press.stylex.js +1 -1
  71. package/dist/privateAttributes/pressBox.stylex.d.ts +12 -4
  72. package/dist/privateAttributes/pressBox.stylex.d.ts.map +1 -1
  73. package/dist/privateAttributes/pressBox.stylex.js +21 -4
  74. package/dist/privateAttributes/tokenRemove.stylex.d.ts +5 -0
  75. package/dist/privateAttributes/tokenRemove.stylex.d.ts.map +1 -0
  76. package/dist/privateAttributes/tokenRemove.stylex.js +25 -0
  77. package/dist/theme/defineTheme.d.ts +0 -1
  78. package/dist/theme/defineTheme.d.ts.map +1 -1
  79. package/dist/utils/inputAge.d.ts +5 -2
  80. package/dist/utils/inputAge.d.ts.map +1 -1
  81. package/dist/utils/inputAge.js +4 -1
  82. package/dist/utils/pressFeedback.d.ts.map +1 -1
  83. package/dist/utils/pressFeedback.js +60 -9
  84. package/locales/en.json +3 -3
  85. package/locales/pseudo.json +2 -2
  86. package/package.json +5 -5
  87. package/src/Calendar/Calendar.tsx +11 -1
  88. package/src/Calendar/getInitialFocusDate.ts +70 -8
  89. package/src/CheckboxInput/CheckboxInput.doc.mjs +16 -2
  90. package/src/CheckboxInput/CheckboxInput.tsx +32 -23
  91. package/src/CheckboxList/CheckboxList.doc.mjs +1 -1
  92. package/src/CheckboxList/CheckboxListItem.tsx +3 -6
  93. package/src/DateInput/useTypedDate.ts +9 -6
  94. package/src/DateTimeInput/DateTimeInput.tsx +7 -3
  95. package/src/DateTimeInput/NativeDateSegment.tsx +28 -10
  96. package/src/DateTimeInput/NativeTimeSegment.tsx +19 -9
  97. package/src/Drawer/Drawer.tsx +7 -5
  98. package/src/DropdownMenu/MenuBottomSheetActionList.tsx +3 -0
  99. package/src/Item/Item.doc.mjs +2 -1
  100. package/src/Item/Item.tsx +7 -3
  101. package/src/Link/useLinkify.tsx +7 -9
  102. package/src/List/List.doc.mjs +9 -21
  103. package/src/List/List.tsx +4 -1
  104. package/src/List/ListItem.doc.mjs +4 -2
  105. package/src/Markdown/Markdown.tsx +7 -0
  106. package/src/RadioList/RadioListItem.tsx +60 -30
  107. package/src/SegmentedControl/SegmentedControl.doc.mjs +3 -3
  108. package/src/SegmentedControl/useSegmentedSelectionMotion.ts +115 -19
  109. package/src/SegmentedControl/useSegmentedTouchTracking.ts +5 -0
  110. package/src/Table/plugins/sortable/useTableSortableState.tsx +5 -1
  111. package/src/Token/Token.tsx +2 -0
  112. package/src/Tokenizer/Tokenizer.tsx +102 -7
  113. package/src/gestures/GestureHost.ts +62 -32
  114. package/src/hooks/menuPressGesture.ts +116 -9
  115. package/src/hooks/scrollOwnerRegistry.ts +8 -1
  116. package/src/hooks/useClickableContainer.ts +11 -8
  117. package/src/hooks/useFocusTrap.ts +6 -0
  118. package/src/hooks/useMenuPress.ts +32 -2
  119. package/src/hooks/useStreamingText.ts +30 -25
  120. package/src/i18n/generated-english/DateInput/useTypedDate.generated.ts +2 -2
  121. package/src/i18n/generated-locales/en.generated.ts +2 -2
  122. package/src/i18n/generated-locales/pseudo.generated.ts +2 -2
  123. package/src/motion/MEASUREMENTS.md +2 -3
  124. package/src/motion/uikit/segmented.ts +35 -10
  125. package/src/privateAttributes/press.stylex.ts +2 -8
  126. package/src/privateAttributes/pressBox.stylex.ts +23 -4
  127. package/src/privateAttributes/tokenRemove.stylex.ts +27 -0
  128. package/src/theme/defineTheme.ts +0 -1
  129. package/src/theme/useThemeName.doc.mjs +69 -0
  130. package/src/utils/inputAge.ts +5 -2
  131. package/src/utils/pressFeedback.ts +80 -9
@@ -76,10 +76,12 @@ registerEnglishFallback(english);
76
76
  // none of its code.
77
77
  registerBoxHold();
78
78
 
79
- /** Written by the touch press controller while the row is pressed. */
79
+ /** Written by the press controller while the row is pressed. */
80
80
  const PRESSED_ON = '[data-astryx-press="on"]';
81
- /** Written by the touch press controller for the press's release. */
81
+ /** Written by the press controller for the press's release. */
82
82
  const PRESSED_FADING = '[data-astryx-press="fading"]';
83
+ /** The row is pressed, and the press controller does not paint the press. */
84
+ const ACTIVE_UNPAINTED = `:active:not(${PRESSED_ON},${PRESSED_FADING})`;
83
85
 
84
86
  // The touch press's paint, declared by the shared overlay styles on the
85
87
  // element the controller writes to (`pressedAlpha`) at the press's strength,
@@ -113,12 +115,21 @@ const styles = stylex.create({
113
115
  [PRESSED_ON]: 'var(--_press-paint-image)',
114
116
  [PRESSED_FADING]: 'var(--_press-paint-image)',
115
117
  },
118
+ // While the controller paints the press, the indicator's `:active` fill
119
+ // stays off, so a mouse's press paints once.
120
+ '--_indicator-active-press': {
121
+ default: null,
122
+ [PRESSED_ON]: 'transparent',
123
+ [PRESSED_FADING]: 'transparent',
124
+ },
116
125
  },
117
126
  // Under a row that owns the press (CheckboxRowPressContext), this row is
118
127
  // never pressed. So it hands down that row's press paint, which the
119
128
  // built-in box reads too.
120
129
  indicatorRowPressImage: {
121
130
  '--_indicator-press-image': 'var(--_checkbox-row-press-paint, none)',
131
+ // The row paints every press, so the indicator draws no `:active` fill.
132
+ '--_indicator-active-press': 'transparent',
122
133
  },
123
134
  checkboxWrapper: {
124
135
  position: 'relative',
@@ -131,12 +142,13 @@ const styles = stylex.create({
131
142
  // The owner paints this layer over the resolved indicator, so a plain theme
132
143
  // replacement keeps the pressed feedback. An indicator with
133
144
  // `indicatorPressScope` paints its own press from what the row hands down,
134
- // so this layer stays off over it. A mouse keeps `:active` (see
135
- // interactionOverlay.stylex.ts). Under a coarse pointer that arm is dropped.
136
- // The touch press controller then writes the press attribute on the row.
137
- // This layer reads it off the scope marker, as the hover tint does. Under a
138
- // row that owns the press (CheckboxRowPressContext), the row's own checkbox
139
- // paints that row's press paint instead (indicatorRowPressOverlay).
145
+ // so this layer stays off over it. The press controller writes the press
146
+ // attribute on the row for every pointer: a finger, a mouse and a pen. This
147
+ // layer reads it off the scope marker, as the hover tint does. `:active`
148
+ // paints only a press the controller does not paint, and under a coarse
149
+ // pointer it is dropped. Under a row that owns the press
150
+ // (CheckboxRowPressContext), the row's own checkbox paints that row's press
151
+ // paint instead (indicatorRowPressOverlay).
140
152
  indicatorPressOverlay: {
141
153
  '::after': {
142
154
  // `when.descendant` takes a pseudo-class; `:is(*)` matches any marked
@@ -151,34 +163,31 @@ const styles = stylex.create({
151
163
  pointerEvents: 'none',
152
164
  backgroundColor: {
153
165
  default: 'transparent',
154
- [stylex.when.ancestor(':active', indicatorScope)]: {
166
+ [stylex.when.ancestor(ACTIVE_UNPAINTED, indicatorScope)]: {
155
167
  default: colorVars['--color-overlay-pressed'],
156
168
  '@media (pointer: coarse)': 'transparent',
157
169
  },
158
170
  },
159
- // The touch press, as an image layer over the colour: an image change is
160
- // discrete, so no transition can delay the onset, and the strength the
161
- // row's `pressedAlpha` arms own (1 while on, 1 → 0 over the release) is
162
- // what moves. Coarse pointers only, like the drop above.
171
+ // The controller's press paints as an image layer over the colour. An
172
+ // image change is discrete, so no transition can delay the onset. Only
173
+ // the strength moves: the row's `pressedAlpha` arms set it to 1 while
174
+ // on, and 1 → 0 over the release. This holds for every pointer, because
175
+ // the controller writes the attribute only for a press it paints.
163
176
  backgroundImage: {
164
177
  default: null,
165
- [stylex.when.ancestor(PRESSED_ON, indicatorScope)]: {
166
- default: null,
167
- '@media (pointer: coarse)': pressedOverlayImage,
168
- },
169
- [stylex.when.ancestor(PRESSED_FADING, indicatorScope)]: {
170
- default: null,
171
- '@media (pointer: coarse)': pressedOverlayImage,
172
- },
178
+ [stylex.when.ancestor(PRESSED_ON, indicatorScope)]: pressedOverlayImage,
179
+ [stylex.when.ancestor(PRESSED_FADING, indicatorScope)]:
180
+ pressedOverlayImage,
173
181
  },
174
182
  },
175
183
  },
176
184
  // The row's own checkbox when its row owns the press
177
185
  // (CheckboxRowPressContext). It paints only the paint that row declares
178
- // (`--_checkbox-row-press-paint`). No outer row, card or fine pointer
179
- // reaches it.
186
+ // (`--_checkbox-row-press-paint`), so it draws no `:active` fill. No outer
187
+ // row or card reaches it.
180
188
  indicatorRowPressOverlay: {
181
189
  '::after': {
190
+ backgroundColor: 'transparent',
182
191
  backgroundImage: 'var(--_checkbox-row-press-paint, none)',
183
192
  },
184
193
  },
@@ -262,7 +262,7 @@ export const docs = {
262
262
  {
263
263
  name: '--_checkbox-row-press-paint',
264
264
  description:
265
- "The touch press paint a row that owns its checkbox's press hands that checkbox's box: none at rest, and the press paint at the press's strength while the touch press controller presses that row under a coarse pointer. Set on the row by its own press arms; the box reads its nearest row's value, so a list placed in a row's content keeps its own rows' paint.",
265
+ "The press paint a row that owns its checkbox's press hands that checkbox's box: none at rest, and the press paint at the press's strength while the press controller presses that row, for every pointer. Set on the row by its own press arms; the box reads its nearest row's value, so a list placed in a row's content keeps its own rows' paint.",
266
266
  default: 'none',
267
267
  private: true,
268
268
  },
@@ -29,7 +29,6 @@ import type {InputStatus} from '../Field/types';
29
29
  import {CheckboxRowPressContext} from '../CheckboxInput/CheckboxRowPressContext';
30
30
  import {rowPressPaintStyles} from '../privateAttributes/press.stylex';
31
31
  import {interactionOverlayStyles} from '../utils/interactionOverlay.stylex';
32
- import {useTouchPresentation} from '../utils/touchPresentation';
33
32
  import {ListItem} from '../List/ListItem';
34
33
  import {ListContext} from '../List/ListContext';
35
34
  import {CheckboxListContext} from './CheckboxListContext';
@@ -311,11 +310,9 @@ export function CheckboxListItem({
311
310
  registerWithRequiredGroup,
312
311
  );
313
312
 
314
- // Under a finger, a delegating row is the option's only press surface. A
315
- // touch anywhere on it presses the row. A fine pointer keeps the box's own
316
- // press.
317
- const {isTouch} = useTouchPresentation();
318
- const rowOwnsPress = isTouch && hasRowInteraction && !effectiveDisabled;
313
+ // A delegating row is the option's only press surface, for every pointer. A
314
+ // press anywhere on it presses the row.
315
+ const rowOwnsPress = hasRowInteraction && !effectiveDisabled;
319
316
 
320
317
  // A read-only checkbox carries aria-readonly, which the row's clickable
321
318
  // container treats as a non-interactive target, so a click on it would be
@@ -186,10 +186,17 @@ export function useTypedDate({
186
186
  [calendar, locale],
187
187
  );
188
188
 
189
+ const isProviderCalendar = isGregorian
190
+ ? isGregorianCalendar(providerCalendar)
191
+ : calendar === providerCalendar;
192
+
189
193
  const errorMessage = useCallback(
190
194
  (result: CalendarDateParseResult) => {
191
195
  if (result.kind === 'nonexistent') {
192
- return t('@astryx.dateInput.nonexistentDate', {calendar: calendarName});
196
+ return t('@astryx.dateInput.nonexistentDate', {
197
+ named: isProviderCalendar ? 'no' : 'yes',
198
+ calendar: calendarName,
199
+ });
193
200
  }
194
201
  if (result.kind === 'outOfRange') {
195
202
  const boundFormat = typeof format === 'function' ? 'date_long' : format;
@@ -220,13 +227,9 @@ export function useTypedDate({
220
227
  }
221
228
  return t('@astryx.dateInput.invalidDate');
222
229
  },
223
- [t, calendarName, format, locale, calendar, min, max],
230
+ [t, isProviderCalendar, calendarName, format, locale, calendar, min, max],
224
231
  );
225
232
 
226
- const isProviderCalendar = isGregorian
227
- ? isGregorianCalendar(providerCalendar)
228
- : calendar === providerCalendar;
229
-
230
233
  return {
231
234
  calendar,
232
235
  prepare,
@@ -804,9 +804,13 @@ function PointerDateTimeField({
804
804
  const [nativeTimeDraft, setNativeTimeDraft] = useState<
805
805
  ISOTimeString | undefined
806
806
  >(undefined);
807
- const previousNativeValueRef = useRef(optimisticValue);
808
- if (optimisticValue !== previousNativeValueRef.current) {
809
- previousNativeValueRef.current = optimisticValue;
807
+ // The value the draft was held against. It is state: a ref written here
808
+ // would keep a value from a render React discards, and drop the draft on
809
+ // the next render.
810
+ const [previousNativeValue, setPreviousNativeValue] =
811
+ useState(optimisticValue);
812
+ if (optimisticValue !== previousNativeValue) {
813
+ setPreviousNativeValue(optimisticValue);
810
814
  if (nativeTimeDraft !== undefined) {
811
815
  setNativeTimeDraft(undefined);
812
816
  }
@@ -117,16 +117,22 @@ export function NativeDateSegment({
117
117
  const [isFocused, setIsFocused] = useState(false);
118
118
  const [isSegmentEditable, setIsSegmentEditable] = useState(false);
119
119
  const valueAtFocusRef = useRef<string | null>(null);
120
- const lastCommitRef = useRef<string | null>(null);
120
+ // The text the control last committed, so a repeated native event does not
121
+ // commit it twice. Each entry belongs to the commit epoch it was made in.
122
+ const lastCommitRef = useRef<{text: string; epoch: number} | null>(null);
121
123
 
122
- const prevValueRef = useRef(value);
123
- if (value !== prevValueRef.current) {
124
- prevValueRef.current = value;
124
+ // The value as last rendered, and an epoch that a value change while the
125
+ // control is unfocused moves on, retiring the last commit. Both are state:
126
+ // refs written here would keep a value from a render React discards.
127
+ const [prevValue, setPrevValue] = useState(value);
128
+ const [commitEpoch, setCommitEpoch] = useState(0);
129
+ if (value !== prevValue) {
130
+ setPrevValue(value);
125
131
  // Keep the accepted DOM value cached while a native picker is open. An
126
132
  // optimistic rollback changes the prop but leaves the focused control alone;
127
- // clearing this cache would replay that rejected edit on blur.
133
+ // retiring this cache would replay that rejected edit on blur.
128
134
  if (!isFocused) {
129
- lastCommitRef.current = null;
135
+ setCommitEpoch(epoch => epoch + 1);
130
136
  }
131
137
  if (rejectedValue !== null) {
132
138
  setRejectedValue(null);
@@ -145,12 +151,17 @@ export function NativeDateSegment({
145
151
  if (isEffectivelyDisabled) {
146
152
  return;
147
153
  }
148
- if (lastCommitRef.current === newValue) {
154
+ const last = lastCommitRef.current;
155
+ if (
156
+ last !== null &&
157
+ last.epoch === commitEpoch &&
158
+ last.text === newValue
159
+ ) {
149
160
  return;
150
161
  }
151
162
 
152
163
  if (!newValue) {
153
- lastCommitRef.current = newValue;
164
+ lastCommitRef.current = {text: newValue, epoch: commitEpoch};
154
165
  setRejectedValue(null);
155
166
  if (value !== undefined) {
156
167
  onChange(undefined);
@@ -168,13 +179,20 @@ export function NativeDateSegment({
168
179
  }
169
180
 
170
181
  setRejectedValue(null);
171
- lastCommitRef.current = newValue;
182
+ lastCommitRef.current = {text: newValue, epoch: commitEpoch};
172
183
  const parsedISO = plainDateToISO(parsed);
173
184
  if (parsedISO !== value) {
174
185
  onChange(parsedISO);
175
186
  }
176
187
  },
177
- [isDateDisabled, isEffectivelyDisabled, locale, onChange, value],
188
+ [
189
+ commitEpoch,
190
+ isDateDisabled,
191
+ isEffectivelyDisabled,
192
+ locale,
193
+ onChange,
194
+ value,
195
+ ],
178
196
  );
179
197
 
180
198
  const handleChange = useCallback(
@@ -141,15 +141,21 @@ export function NativeTimeSegment({
141
141
  const [isFocused, setIsFocused] = useState(false);
142
142
  const [isSegmentEditable, setIsSegmentEditable] = useState(false);
143
143
  const valueAtFocusRef = useRef<string | null>(null);
144
- const lastCommitRef = useRef<string | null>(null);
144
+ // The text the control last committed, so a repeated native event does not
145
+ // commit it twice. Each entry belongs to the commit epoch it was made in.
146
+ const lastCommitRef = useRef<{text: string; epoch: number} | null>(null);
145
147
 
146
- const prevValueRef = useRef(value);
147
- if (value !== prevValueRef.current) {
148
- prevValueRef.current = value;
148
+ // The value as last rendered, and an epoch that a value change while the
149
+ // control is unfocused moves on, retiring the last commit. Both are state:
150
+ // refs written here would keep a value from a render React discards.
151
+ const [prevValue, setPrevValue] = useState(value);
152
+ const [commitEpoch, setCommitEpoch] = useState(0);
153
+ if (value !== prevValue) {
154
+ setPrevValue(value);
149
155
  // Preserve the accepted DOM value while the OS wheel is open so an
150
156
  // optimistic rollback cannot replay that edit when the field blurs.
151
157
  if (!isFocused) {
152
- lastCommitRef.current = null;
158
+ setCommitEpoch(epoch => epoch + 1);
153
159
  }
154
160
  if (rejectedValue !== null) {
155
161
  setRejectedValue(null);
@@ -165,12 +171,16 @@ export function NativeTimeSegment({
165
171
 
166
172
  const commitValue = useCallback(
167
173
  (newValue: string) => {
168
- if (isEffectivelyDisabled || lastCommitRef.current === newValue) {
174
+ const last = lastCommitRef.current;
175
+ if (
176
+ isEffectivelyDisabled ||
177
+ (last !== null && last.epoch === commitEpoch && last.text === newValue)
178
+ ) {
169
179
  return;
170
180
  }
171
181
 
172
182
  if (!newValue) {
173
- lastCommitRef.current = newValue;
183
+ lastCommitRef.current = {text: newValue, epoch: commitEpoch};
174
184
  setRejectedValue(null);
175
185
  if (value !== undefined) {
176
186
  onChange(undefined);
@@ -188,12 +198,12 @@ export function NativeTimeSegment({
188
198
  }
189
199
 
190
200
  setRejectedValue(null);
191
- lastCommitRef.current = newValue;
201
+ lastCommitRef.current = {text: newValue, epoch: commitEpoch};
192
202
  if (normalized !== value) {
193
203
  onChange(normalized);
194
204
  }
195
205
  },
196
- [isEffectivelyDisabled, max, min, onChange, value],
206
+ [commitEpoch, isEffectivelyDisabled, max, min, onChange, value],
197
207
  );
198
208
 
199
209
  const handleChange = useCallback(
@@ -570,12 +570,14 @@ export function Drawer({
570
570
  // the same state that drives `isOpen` (`side={selected?.side ?? 'end'}`):
571
571
  // that state clears on close, so the live prop flips mid-exit and the panel
572
572
  // teleports to the other edge and slides out the wrong way. Children stay
573
- // mounted for the exit for the same reason; so does the anchor.
574
- const exitSideRef = useRef(side);
575
- if (isOpen) {
576
- exitSideRef.current = side;
573
+ // mounted for the exit for the same reason; so does the anchor. It is state,
574
+ // adjusted while the open drawer renders: a ref written here would keep the
575
+ // side of a render that React discards.
576
+ const [exitSide, setExitSide] = useState(side);
577
+ if (isOpen && side !== exitSide) {
578
+ setExitSide(side);
577
579
  }
578
- const anchoredSide = isOpen ? side : exitSideRef.current;
580
+ const anchoredSide = isOpen ? side : exitSide;
579
581
 
580
582
  const sideStyle = anchoredSide === 'start' ? styles.start : styles.end;
581
583
  const sideOpenStyle =
@@ -151,6 +151,9 @@ export function MenuBottomSheetActionList({
151
151
  <List
152
152
  ref={listComposedRef}
153
153
  density="spacious"
154
+ // Focus parks on the list when no row is lit, as in DropdownMenu's own
155
+ // menu, so a row a cancelled finger lit loses its highlight.
156
+ tabIndex={-1}
154
157
  xstyle={styles.list}
155
158
  {...menuPress.menuProps}>
156
159
  {items.map((option, index) => {
@@ -196,7 +196,8 @@ export const docs = {
196
196
  {
197
197
  name: 'isDisabled',
198
198
  type: 'boolean',
199
- description: 'Disabled state.',
199
+ description:
200
+ 'Disabled state. Interactive rows stay keyboard-reachable but cannot activate.',
200
201
  default: 'false',
201
202
  },
202
203
  {
package/src/Item/Item.tsx CHANGED
@@ -73,6 +73,7 @@ import {focusOutlineProps} from '../utils/focusOutline.stylex';
73
73
  import {interactionOverlayStyles} from '../utils/interactionOverlay.stylex';
74
74
  import {rowPressLayerStyles} from '../privateAttributes/press.stylex';
75
75
  import {isCoarsePointer} from '../utils/coarsePointer';
76
+ import {disabledInteractionProps} from '../utils/disabledInteraction';
76
77
  import {usePressFeedback} from '../hooks/usePressFeedback';
77
78
  import type {ItemSwipeBridge} from './ItemSwipeLayer';
78
79
 
@@ -280,7 +281,7 @@ export interface ItemProps extends BaseProps<HTMLElement> {
280
281
  isSelected?: boolean;
281
282
 
282
283
  /**
283
- * Disabled state.
284
+ * Disabled state. Interactive rows stay keyboard-reachable but cannot activate.
284
285
  * @default false
285
286
  */
286
287
  isDisabled?: boolean;
@@ -893,7 +894,7 @@ export function Item({
893
894
  <RowAnchor
894
895
  ref={anchorRef}
895
896
  {...(isDisabled
896
- ? {role: 'link', 'aria-disabled': true, tabIndex: -1}
897
+ ? {role: 'link', 'aria-disabled': true, tabIndex: 0}
897
898
  : {href, target, rel})}
898
899
  {...stylex.props(
899
900
  styles.invisibleAnchor,
@@ -907,7 +908,10 @@ export function Item({
907
908
  ref={actionButtonRef}
908
909
  type="button"
909
910
  onClick={onClick}
910
- disabled={isDisabled}
911
+ aria-disabled={isDisabled || undefined}
912
+ {...(isDisabled
913
+ ? disabledInteractionProps<HTMLButtonElement>()
914
+ : null)}
911
915
  {...stylex.props(
912
916
  styles.invisibleButton,
913
917
  isInline && styles.inlineContent,
@@ -73,14 +73,16 @@ export interface UseLinkifyOptions {
73
73
  // URL pattern: matches http(s) URLs
74
74
  const URL_PATTERN: LinkifyPattern = {
75
75
  pattern: /https?:\/\/[^\s<>'")\]},]+/g,
76
- href: (match) => match[0],
76
+ href: match => match[0],
77
77
  isExternal: true,
78
78
  };
79
79
 
80
- // Email pattern: matches email addresses
80
+ // A match starts only where a local part starts. The scan then reads each run
81
+ // of local-part characters once.
81
82
  const EMAIL_PATTERN: LinkifyPattern = {
82
- pattern: /[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g,
83
- href: (match) => `mailto:${match[0]}`,
83
+ pattern:
84
+ /(?<![a-zA-Z0-9._%+-])[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g,
85
+ href: match => `mailto:${match[0]}`,
84
86
  };
85
87
 
86
88
  const BUILTIN_PATTERNS: LinkifyPattern[] = [URL_PATTERN, EMAIL_PATTERN];
@@ -197,11 +199,7 @@ export function useLinkify(
197
199
 
198
200
  // The link
199
201
  nodes.push(
200
- <Link
201
- key={`linkify-${i}`}
202
- href={m.href}
203
- isExternalLink={m.isExternal}
204
- >
202
+ <Link key={`linkify-${i}`} href={m.href} isExternalLink={m.isExternal}>
205
203
  {m.label}
206
204
  </Link>,
207
205
  );
@@ -164,14 +164,10 @@ export const docs = {
164
164
  ],
165
165
  anatomy: [
166
166
  {
167
- name: 'List title',
168
- required: true,
169
- description: 'Heading that labels the list.',
170
- },
171
- {
172
- name: 'Description',
167
+ name: 'Header',
173
168
  required: false,
174
- description: 'Supplementary text below the title.',
169
+ description:
170
+ 'Optional content above the rows, from the header prop. It labels the list, and screen readers announce it as the list name.',
175
171
  },
176
172
  {
177
173
  name: 'List items',
@@ -242,14 +238,10 @@ export const docsZh = {
242
238
  ],
243
239
  anatomy: [
244
240
  {
245
- name: 'List title',
246
- required: true,
247
- description: 'Heading that labels the list.',
248
- },
249
- {
250
- name: 'Description',
241
+ name: 'Header',
251
242
  required: false,
252
- description: 'Supplementary text below the title.',
243
+ description:
244
+ 'Optional content above the rows, from the header prop. It labels the list, and screen readers announce it as the list name.',
253
245
  },
254
246
  {
255
247
  name: 'List items',
@@ -323,14 +315,10 @@ export const docsDense = {
323
315
  ],
324
316
  anatomy: [
325
317
  {
326
- name: 'List title',
327
- required: true,
328
- description: 'Heading that labels the list.',
329
- },
330
- {
331
- name: 'Description',
318
+ name: 'Header',
332
319
  required: false,
333
- description: 'Supplementary text below the title.',
320
+ description:
321
+ 'Optional content above the rows, from the header prop. It labels the list, and screen readers announce it as the list name.',
334
322
  },
335
323
  {
336
324
  name: 'List items',
package/src/List/List.tsx CHANGED
@@ -60,7 +60,10 @@ export {
60
60
  export interface ListProps extends BaseProps<
61
61
  HTMLUListElement | HTMLOListElement
62
62
  > {
63
- /** Ref forwarded to the root element */
63
+ /**
64
+ * Ref to the list element (`<ul>`, or `<ol>` for `listStyle="decimal"`),
65
+ * with or without a header.
66
+ */
64
67
  ref?: React.Ref<HTMLUListElement | HTMLOListElement>;
65
68
  /**
66
69
  * List items. Should be ListItem components.
@@ -98,7 +98,8 @@ export const docs = {
98
98
  {
99
99
  name: 'isDisabled',
100
100
  type: 'boolean',
101
- description: 'Disabled state; sets aria-disabled on the item.',
101
+ description:
102
+ 'Disabled state; interactive rows stay keyboard-reachable, expose aria-disabled, and cannot activate.',
102
103
  default: 'false',
103
104
  },
104
105
  {
@@ -245,7 +246,8 @@ export const docsDense = {
245
246
  target:
246
247
  'Link target attribute, only when href provided. target="_blank" auto-adds noopener noreferrer.',
247
248
  rel: 'Link relationship tokens. noopener noreferrer are merged for target="_blank".',
248
- isDisabled: 'Disabled state; sets aria-disabled.',
249
+ isDisabled:
250
+ 'Disabled state; interactive rows stay keyboard-reachable and cannot activate.',
249
251
  isSelected: 'Selected state; sets aria-current="true".',
250
252
  itemKey: "The row's identity for List animatedLayout and the key a reorderable List's onReorder reports; a row without one changes at once and has no reorder handle.",
251
253
  },
@@ -2472,6 +2472,10 @@ export function Markdown<
2472
2472
  return Math.min(Math.ceil(duration / tickMs), 12);
2473
2473
  }, [token]);
2474
2474
 
2475
+ // Render writes these fade-in refs on purpose, an accepted exception to the
2476
+ // runtime's ref rule. Text comes only from `smoothedText`. A render that
2477
+ // React discards shifts the fade spans by the text it added. The "streamed
2478
+ // text after a render React discards" tests pin why it is harmless.
2475
2479
  const prevBlocksRef = useRef<ReadonlyArray<RenderBlockNode>>([]);
2476
2480
  const prevInlineNodesRef = useRef<ReadonlyArray<RenderInlineNode>>([]);
2477
2481
  const boundariesRef = useRef<number[]>([]);
@@ -2483,6 +2487,7 @@ export function Markdown<
2483
2487
  ? countInlineTextLength(prevInlineNodesRef.current)
2484
2488
  : countBlockTextLength(prevBlocksRef.current);
2485
2489
  const next = computeBoundaries(boundariesRef.current, prevLen, maxSpans);
2490
+ // Render writes this on purpose: see the fade-in refs' note above.
2486
2491
  boundariesRef.current = next;
2487
2492
  return next;
2488
2493
  }, [display, smoothedLen, maxSpans]);
@@ -2596,6 +2601,7 @@ export function Markdown<
2596
2601
  );
2597
2602
 
2598
2603
  // Store current inline nodes for next render's boundary calculation.
2604
+ // Render writes this on purpose: see the fade-in refs' note above.
2599
2605
  prevInlineNodesRef.current = inlineNodes;
2600
2606
  prevBlocksRef.current = [];
2601
2607
 
@@ -2624,6 +2630,7 @@ export function Markdown<
2624
2630
  // Store current blocks for next render's boundary calculation.
2625
2631
  // This ref write is safe under StrictMode: both invocations produce the same
2626
2632
  // blocks (same smoothedText → same useMemo result), so both write the same value.
2633
+ // Render writes this on purpose: see the fade-in refs' note above.
2627
2634
  prevBlocksRef.current = blocks;
2628
2635
  prevInlineNodesRef.current = [];
2629
2636