@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.
- package/dist/Calendar/Calendar.d.ts.map +1 -1
- package/dist/Calendar/Calendar.js +11 -2
- package/dist/Calendar/getInitialFocusDate.d.ts +8 -3
- package/dist/Calendar/getInitialFocusDate.d.ts.map +1 -1
- package/dist/Calendar/getInitialFocusDate.js +42 -7
- package/dist/CheckboxInput/CheckboxInput.d.ts.map +1 -1
- package/dist/CheckboxInput/CheckboxInput.js +9 -4
- package/dist/CheckboxList/CheckboxListItem.d.ts.map +1 -1
- package/dist/CheckboxList/CheckboxListItem.js +3 -8
- package/dist/DateInput/useTypedDate.d.ts.map +1 -1
- package/dist/DateInput/useTypedDate.js +3 -2
- package/dist/DateTimeInput/DateTimeInput.d.ts.map +1 -1
- package/dist/DateTimeInput/DateTimeInput.js +6 -3
- package/dist/DateTimeInput/NativeDateSegment.d.ts.map +1 -1
- package/dist/DateTimeInput/NativeDateSegment.js +23 -9
- package/dist/DateTimeInput/NativeTimeSegment.d.ts.map +1 -1
- package/dist/DateTimeInput/NativeTimeSegment.js +22 -8
- package/dist/Drawer/Drawer.d.ts.map +1 -1
- package/dist/Drawer/Drawer.js +7 -5
- package/dist/DropdownMenu/MenuBottomSheetActionList.d.ts.map +1 -1
- package/dist/DropdownMenu/MenuBottomSheetActionList.js +5 -1
- package/dist/Item/Item.d.ts +1 -1
- package/dist/Item/Item.d.ts.map +1 -1
- package/dist/Item/Item.js +4 -2
- package/dist/Link/useLinkify.d.ts.map +1 -1
- package/dist/Link/useLinkify.js +3 -2
- package/dist/List/List.d.ts +4 -1
- package/dist/List/List.d.ts.map +1 -1
- package/dist/Markdown/Markdown.d.ts.map +1 -1
- package/dist/Markdown/Markdown.js +8 -0
- package/dist/RadioList/RadioListItem.d.ts.map +1 -1
- package/dist/RadioList/RadioListItem.js +19 -4
- package/dist/SegmentedControl/useSegmentedSelectionMotion.d.ts +43 -15
- package/dist/SegmentedControl/useSegmentedSelectionMotion.d.ts.map +1 -1
- package/dist/SegmentedControl/useSegmentedSelectionMotion.js +108 -18
- package/dist/SegmentedControl/useSegmentedTouchTracking.d.ts.map +1 -1
- package/dist/SegmentedControl/useSegmentedTouchTracking.js +5 -0
- package/dist/Table/plugins/sortable/useTableSortableState.d.ts.map +1 -1
- package/dist/Table/plugins/sortable/useTableSortableState.js +7 -3
- package/dist/Token/Token.d.ts.map +1 -1
- package/dist/Token/Token.js +2 -0
- package/dist/Tokenizer/Tokenizer.d.ts.map +1 -1
- package/dist/Tokenizer/Tokenizer.js +85 -12
- package/dist/astryx.css +11 -10
- package/dist/gestures/GestureHost.d.ts +5 -0
- package/dist/gestures/GestureHost.d.ts.map +1 -1
- package/dist/gestures/GestureHost.js +54 -28
- package/dist/hooks/menuPressGesture.d.ts +39 -2
- package/dist/hooks/menuPressGesture.d.ts.map +1 -1
- package/dist/hooks/menuPressGesture.js +92 -5
- package/dist/hooks/scrollOwnerRegistry.d.ts +0 -1
- package/dist/hooks/scrollOwnerRegistry.d.ts.map +1 -1
- package/dist/hooks/scrollOwnerRegistry.js +4 -1
- package/dist/hooks/useClickableContainer.d.ts +6 -4
- package/dist/hooks/useClickableContainer.d.ts.map +1 -1
- package/dist/hooks/useClickableContainer.js +11 -8
- package/dist/hooks/useFocusTrap.d.ts.map +1 -1
- package/dist/hooks/useFocusTrap.js +6 -0
- package/dist/hooks/useMenuPress.d.ts.map +1 -1
- package/dist/hooks/useMenuPress.js +35 -2
- package/dist/hooks/useStreamingText.d.ts.map +1 -1
- package/dist/hooks/useStreamingText.js +38 -23
- package/dist/i18n/generated-english/DateInput/useTypedDate.generated.js +2 -2
- package/dist/i18n/generated-locales/en.generated.js +2 -2
- package/dist/i18n/generated-locales/pseudo.generated.js +2 -2
- package/dist/motion/uikit/segmented.d.ts +35 -7
- package/dist/motion/uikit/segmented.d.ts.map +1 -1
- package/dist/motion/uikit/segmented.js +39 -11
- package/dist/privateAttributes/press.stylex.d.ts.map +1 -1
- package/dist/privateAttributes/press.stylex.js +1 -1
- package/dist/privateAttributes/pressBox.stylex.d.ts +12 -4
- package/dist/privateAttributes/pressBox.stylex.d.ts.map +1 -1
- package/dist/privateAttributes/pressBox.stylex.js +21 -4
- package/dist/privateAttributes/tokenRemove.stylex.d.ts +5 -0
- package/dist/privateAttributes/tokenRemove.stylex.d.ts.map +1 -0
- package/dist/privateAttributes/tokenRemove.stylex.js +25 -0
- package/dist/theme/defineTheme.d.ts +0 -1
- package/dist/theme/defineTheme.d.ts.map +1 -1
- package/dist/utils/inputAge.d.ts +5 -2
- package/dist/utils/inputAge.d.ts.map +1 -1
- package/dist/utils/inputAge.js +4 -1
- package/dist/utils/pressFeedback.d.ts.map +1 -1
- package/dist/utils/pressFeedback.js +60 -9
- package/locales/en.json +3 -3
- package/locales/pseudo.json +2 -2
- package/package.json +5 -5
- package/src/Calendar/Calendar.tsx +11 -1
- package/src/Calendar/getInitialFocusDate.ts +70 -8
- package/src/CheckboxInput/CheckboxInput.doc.mjs +16 -2
- package/src/CheckboxInput/CheckboxInput.tsx +32 -23
- package/src/CheckboxList/CheckboxList.doc.mjs +1 -1
- package/src/CheckboxList/CheckboxListItem.tsx +3 -6
- package/src/DateInput/useTypedDate.ts +9 -6
- package/src/DateTimeInput/DateTimeInput.tsx +7 -3
- package/src/DateTimeInput/NativeDateSegment.tsx +28 -10
- package/src/DateTimeInput/NativeTimeSegment.tsx +19 -9
- package/src/Drawer/Drawer.tsx +7 -5
- package/src/DropdownMenu/MenuBottomSheetActionList.tsx +3 -0
- package/src/Item/Item.doc.mjs +2 -1
- package/src/Item/Item.tsx +7 -3
- package/src/Link/useLinkify.tsx +7 -9
- package/src/List/List.doc.mjs +9 -21
- package/src/List/List.tsx +4 -1
- package/src/List/ListItem.doc.mjs +4 -2
- package/src/Markdown/Markdown.tsx +7 -0
- package/src/RadioList/RadioListItem.tsx +60 -30
- package/src/SegmentedControl/SegmentedControl.doc.mjs +3 -3
- package/src/SegmentedControl/useSegmentedSelectionMotion.ts +115 -19
- package/src/SegmentedControl/useSegmentedTouchTracking.ts +5 -0
- package/src/Table/plugins/sortable/useTableSortableState.tsx +5 -1
- package/src/Token/Token.tsx +2 -0
- package/src/Tokenizer/Tokenizer.tsx +102 -7
- package/src/gestures/GestureHost.ts +62 -32
- package/src/hooks/menuPressGesture.ts +116 -9
- package/src/hooks/scrollOwnerRegistry.ts +8 -1
- package/src/hooks/useClickableContainer.ts +11 -8
- package/src/hooks/useFocusTrap.ts +6 -0
- package/src/hooks/useMenuPress.ts +32 -2
- package/src/hooks/useStreamingText.ts +30 -25
- package/src/i18n/generated-english/DateInput/useTypedDate.generated.ts +2 -2
- package/src/i18n/generated-locales/en.generated.ts +2 -2
- package/src/i18n/generated-locales/pseudo.generated.ts +2 -2
- package/src/motion/MEASUREMENTS.md +2 -3
- package/src/motion/uikit/segmented.ts +35 -10
- package/src/privateAttributes/press.stylex.ts +2 -8
- package/src/privateAttributes/pressBox.stylex.ts +23 -4
- package/src/privateAttributes/tokenRemove.stylex.ts +27 -0
- package/src/theme/defineTheme.ts +0 -1
- package/src/theme/useThemeName.doc.mjs +69 -0
- package/src/utils/inputAge.ts +5 -2
- 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
|
|
79
|
+
/** Written by the press controller while the row is pressed. */
|
|
80
80
|
const PRESSED_ON = '[data-astryx-press="on"]';
|
|
81
|
-
/** Written by the
|
|
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.
|
|
135
|
-
//
|
|
136
|
-
//
|
|
137
|
-
//
|
|
138
|
-
// row that owns the press
|
|
139
|
-
// paints that row's press
|
|
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(
|
|
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
|
|
160
|
-
// discrete, so no transition can delay the onset
|
|
161
|
-
// row's `pressedAlpha` arms
|
|
162
|
-
//
|
|
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
|
-
|
|
167
|
-
|
|
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`)
|
|
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
|
|
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
|
-
//
|
|
315
|
-
//
|
|
316
|
-
|
|
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', {
|
|
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
|
-
|
|
808
|
-
|
|
809
|
-
|
|
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
|
-
|
|
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
|
-
|
|
123
|
-
|
|
124
|
-
|
|
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
|
-
//
|
|
133
|
+
// retiring this cache would replay that rejected edit on blur.
|
|
128
134
|
if (!isFocused) {
|
|
129
|
-
|
|
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
|
-
|
|
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
|
-
[
|
|
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
|
-
|
|
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
|
-
|
|
147
|
-
|
|
148
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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(
|
package/src/Drawer/Drawer.tsx
CHANGED
|
@@ -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
|
-
|
|
575
|
-
|
|
576
|
-
|
|
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 :
|
|
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) => {
|
package/src/Item/Item.doc.mjs
CHANGED
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:
|
|
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,
|
package/src/Link/useLinkify.tsx
CHANGED
|
@@ -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:
|
|
76
|
+
href: match => match[0],
|
|
77
77
|
isExternal: true,
|
|
78
78
|
};
|
|
79
79
|
|
|
80
|
-
//
|
|
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:
|
|
83
|
-
|
|
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
|
);
|
package/src/List/List.doc.mjs
CHANGED
|
@@ -164,14 +164,10 @@ export const docs = {
|
|
|
164
164
|
],
|
|
165
165
|
anatomy: [
|
|
166
166
|
{
|
|
167
|
-
name: '
|
|
168
|
-
required: true,
|
|
169
|
-
description: 'Heading that labels the list.',
|
|
170
|
-
},
|
|
171
|
-
{
|
|
172
|
-
name: 'Description',
|
|
167
|
+
name: 'Header',
|
|
173
168
|
required: false,
|
|
174
|
-
description:
|
|
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: '
|
|
246
|
-
required: true,
|
|
247
|
-
description: 'Heading that labels the list.',
|
|
248
|
-
},
|
|
249
|
-
{
|
|
250
|
-
name: 'Description',
|
|
241
|
+
name: 'Header',
|
|
251
242
|
required: false,
|
|
252
|
-
description:
|
|
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: '
|
|
327
|
-
required: true,
|
|
328
|
-
description: 'Heading that labels the list.',
|
|
329
|
-
},
|
|
330
|
-
{
|
|
331
|
-
name: 'Description',
|
|
318
|
+
name: 'Header',
|
|
332
319
|
required: false,
|
|
333
|
-
description:
|
|
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
|
-
/**
|
|
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:
|
|
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:
|
|
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
|
|