@astryxdesign/core 0.7.15-canary.gea16e8d → 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.
- package/CHANGELOG.md +72 -2
- package/dist/BottomSheet/BottomSheetPanel.d.ts.map +1 -1
- package/dist/BottomSheet/BottomSheetPanel.js +5 -4
- package/dist/CheckboxInput/CheckboxInput.d.ts.map +1 -1
- package/dist/CheckboxInput/CheckboxInput.js +10 -23
- package/dist/DateInput/DateInput.d.ts +44 -0
- package/dist/DateInput/DateInput.d.ts.map +1 -1
- package/dist/DateInput/DateInput.js +7 -2
- package/dist/DateInput/NativeDateField.d.ts.map +1 -1
- package/dist/DateInput/NativeDateField.js +18 -8
- package/dist/DateInput/index.d.ts +1 -1
- package/dist/DateInput/index.d.ts.map +1 -1
- package/dist/DateInput/useTypedDate.d.ts +34 -3
- package/dist/DateInput/useTypedDate.d.ts.map +1 -1
- package/dist/DateInput/useTypedDate.js +178 -29
- package/dist/DateTimeInput/DateTimeInput.d.ts +28 -0
- package/dist/DateTimeInput/DateTimeInput.d.ts.map +1 -1
- package/dist/DateTimeInput/DateTimeInput.js +17 -6
- package/dist/DateTimeInput/index.d.ts +1 -1
- package/dist/DateTimeInput/index.d.ts.map +1 -1
- package/dist/Field/InputClearButton.d.ts +4 -1
- package/dist/Field/InputClearButton.d.ts.map +1 -1
- package/dist/Field/InputClearButton.js +4 -1
- package/dist/Item/Item.d.ts +11 -7
- package/dist/Item/Item.d.ts.map +1 -1
- package/dist/Item/Item.js +9 -7
- package/dist/Item/ItemSwipeLayer.d.ts.map +1 -1
- package/dist/Item/ItemSwipeLayer.js +60 -45
- package/dist/Item/useSwipeAction.d.ts +9 -5
- package/dist/Item/useSwipeAction.d.ts.map +1 -1
- package/dist/Item/useSwipeAction.js +27 -21
- package/dist/Layer/useLayer.d.ts +4 -9
- package/dist/Layer/useLayer.d.ts.map +1 -1
- package/dist/Layer/useLayer.js +6 -16
- package/dist/Layer/useTouchTrigger.d.ts +12 -1
- package/dist/Layer/useTouchTrigger.d.ts.map +1 -1
- package/dist/Layer/useTouchTrigger.js +22 -3
- package/dist/Outline/useScrollSpy.d.ts.map +1 -1
- package/dist/Outline/useScrollSpy.js +22 -18
- package/dist/RadioList/RadioListItem.d.ts.map +1 -1
- package/dist/RadioList/RadioListItem.js +6 -32
- package/dist/Resizable/ResizeHandle.d.ts.map +1 -1
- package/dist/Resizable/ResizeHandle.js +5 -10
- package/dist/Resizable/useResizable.d.ts.map +1 -1
- package/dist/Resizable/useResizable.js +6 -5
- package/dist/Stepper/Step.js +8 -8
- package/dist/Table/BaseTable.d.ts.map +1 -1
- package/dist/Table/BaseTable.js +5 -25
- package/dist/Table/internByIdentity.d.ts +15 -0
- package/dist/Table/internByIdentity.d.ts.map +1 -0
- package/dist/Table/internByIdentity.js +38 -0
- package/dist/Table/plugins/sortable/useTableSortableState.d.ts.map +1 -1
- package/dist/Table/plugins/sortable/useTableSortableState.js +8 -4
- package/dist/Table/useBaseTablePlugins.d.ts +2 -1
- package/dist/Table/useBaseTablePlugins.d.ts.map +1 -1
- package/dist/Table/useBaseTablePlugins.js +26 -54
- package/dist/Text/TruncationTooltip.d.ts.map +1 -1
- package/dist/Text/TruncationTooltip.js +10 -1
- package/dist/Timestamp/TimestampHoverCard.d.ts.map +1 -1
- package/dist/Timestamp/TimestampHoverCard.js +14 -13
- package/dist/Toast/ToastViewport.d.ts.map +1 -1
- package/dist/Toast/ToastViewport.js +31 -6
- package/dist/Token/Token.js +2 -2
- package/dist/Tokenizer/TokenizerBottomSheet.js +25 -12
- package/dist/Tooltip/useTooltip.d.ts.map +1 -1
- package/dist/Tooltip/useTooltip.js +1 -1
- package/dist/TreeList/TreeListItem.js +2 -2
- package/dist/gestures/GestureHost.d.ts +38 -0
- package/dist/gestures/GestureHost.d.ts.map +1 -1
- package/dist/gestures/GestureHost.js +95 -1
- package/dist/gestures/contextRequest.d.ts +43 -0
- package/dist/gestures/contextRequest.d.ts.map +1 -0
- package/dist/gestures/contextRequest.js +167 -0
- package/dist/hooks/useClickableContainer.d.ts +1 -1
- package/dist/hooks/useClickableContainer.d.ts.map +1 -1
- package/dist/hooks/useClickableContainer.js +2 -2
- package/dist/hooks/useCommittedRef.d.ts +20 -0
- package/dist/hooks/useCommittedRef.d.ts.map +1 -0
- package/dist/hooks/useCommittedRef.js +38 -0
- package/dist/hooks/useMenuPress.d.ts.map +1 -1
- package/dist/hooks/useMenuPress.js +23 -27
- package/dist/hooks/usePager.d.ts +3 -1
- package/dist/hooks/usePager.d.ts.map +1 -1
- package/dist/hooks/usePager.js +231 -31
- package/dist/i18n/generated-english/Timestamp/TimestampHoverCard.generated.d.ts.map +1 -1
- package/dist/i18n/generated-english/Timestamp/TimestampHoverCard.generated.js +1 -0
- package/dist/i18n/generated-locales/en.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/en.generated.js +3 -1
- package/dist/i18n/generated-locales/pseudo.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/pseudo.generated.js +3 -1
- package/dist/internal/committed-ref.d.ts +15 -0
- package/dist/internal/committed-ref.d.ts.map +1 -0
- package/dist/internal/committed-ref.js +15 -0
- package/dist/internal/touch.d.ts +2 -1
- package/dist/internal/touch.d.ts.map +1 -1
- package/dist/internal/touch.js +1 -0
- package/dist/keyboard/keyboardHeight.d.ts.map +1 -1
- package/dist/keyboard/keyboardHeight.js +13 -9
- package/dist/keyboard/useMobileKeyboard.d.ts.map +1 -1
- package/dist/keyboard/useMobileKeyboard.js +8 -7
- package/dist/privateAttributes/press.stylex.d.ts +40 -10
- package/dist/privateAttributes/press.stylex.d.ts.map +1 -1
- package/dist/privateAttributes/press.stylex.js +46 -10
- package/locales/en.json +8 -0
- package/locales/pseudo.json +6 -0
- package/package.json +10 -5
- package/src/BottomSheet/BottomSheetPanel.tsx +5 -4
- package/src/CheckboxInput/CheckboxInput.tsx +20 -60
- package/src/DateInput/DateInput.doc.mjs +19 -3
- package/src/DateInput/DateInput.tsx +54 -4
- package/src/DateInput/NativeDateField.tsx +28 -10
- package/src/DateInput/index.ts +1 -0
- package/src/DateInput/useTypedDate.ts +292 -42
- package/src/DateTimeInput/DateTimeInput.doc.mjs +19 -3
- package/src/DateTimeInput/DateTimeInput.tsx +45 -7
- package/src/DateTimeInput/index.ts +1 -0
- package/src/Field/InputClearButton.tsx +4 -1
- package/src/Item/Item.doc.mjs +1 -1
- package/src/Item/Item.tsx +16 -12
- package/src/Item/ItemSwipeLayer.tsx +65 -14
- package/src/Item/useSwipeAction.ts +56 -29
- package/src/Layer/useLayer.tsx +12 -37
- package/src/Layer/useTouchTrigger.ts +30 -1
- package/src/Outline/useScrollSpy.ts +22 -22
- package/src/RadioList/RadioListItem.tsx +19 -79
- package/src/Resizable/ResizeHandle.tsx +5 -6
- package/src/Resizable/useResizable.ts +5 -5
- package/src/Stepper/Step.tsx +6 -6
- package/src/Stepper/Stepper.doc.mjs +8 -2
- package/src/Table/BaseTable.tsx +4 -25
- package/src/Table/internByIdentity.ts +41 -0
- package/src/Table/plugins/sortable/useTableSortableState.tsx +10 -4
- package/src/Table/useBaseTablePlugins.ts +31 -67
- package/src/Text/TruncationTooltip.tsx +16 -1
- package/src/Timestamp/Timestamp.doc.mjs +3 -2
- package/src/Timestamp/TimestampHoverCard.tsx +27 -16
- package/src/Toast/ToastViewport.tsx +31 -5
- package/src/Token/Token.tsx +2 -2
- package/src/Tokenizer/TokenizerBottomSheet.tsx +35 -12
- package/src/Tooltip/useTooltip.tsx +1 -0
- package/src/TreeList/TreeListItem.tsx +2 -2
- package/src/gestures/GestureHost.ts +125 -1
- package/src/gestures/README.md +21 -0
- package/src/gestures/contextRequest.ts +206 -0
- package/src/hooks/useClickableContainer.ts +2 -2
- package/src/hooks/useCommittedRef.ts +39 -0
- package/src/hooks/useMenuPress.ts +59 -62
- package/src/hooks/usePager.ts +281 -27
- package/src/i18n/generated-english/Timestamp/TimestampHoverCard.generated.ts +1 -0
- package/src/i18n/generated-locales/en.generated.ts +2 -0
- package/src/i18n/generated-locales/pseudo.generated.ts +2 -0
- package/src/internal/committed-ref.ts +15 -0
- package/src/internal/touch.ts +3 -0
- package/src/keyboard/keyboardHeight.ts +15 -17
- package/src/keyboard/useMobileKeyboard.ts +8 -7
- package/src/privateAttributes/press.stylex.ts +109 -10
|
@@ -7,11 +7,12 @@
|
|
|
7
7
|
* @input Provider locale and calendar, a field's format, bounds and constraints;
|
|
8
8
|
* calendarDateParser, and parseDateInput for other Gregorian text
|
|
9
9
|
* @output Typed-date reading, committed text, the format hint, the calendar
|
|
10
|
-
* description and rejection messages for a date text field,
|
|
11
|
-
* entry state that DateInput and DateTimeInput share
|
|
10
|
+
* description and rejection messages for a date text field, the typed
|
|
11
|
+
* entry state that DateInput and DateTimeInput share, and the
|
|
12
|
+
* DateInputEntryError that the field reports to its caller
|
|
12
13
|
* @position DateInput helper hook; used by DateInput and DateTimeInput
|
|
13
14
|
*/
|
|
14
|
-
import { useCallback, useMemo, useRef, useState } from 'react';
|
|
15
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
15
16
|
import { useLocale } from "../i18n/useLocale.js";
|
|
16
17
|
import { useCalendarSystem } from "../i18n/useCalendarSystem.js";
|
|
17
18
|
import { registerEnglishFallback, useComponentTranslator } from "../i18n/useComponentTranslator.js";
|
|
@@ -24,6 +25,17 @@ registerEnglishFallback(english);
|
|
|
24
25
|
|
|
25
26
|
/** A rejected typed date, by the message it announces. */
|
|
26
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Why a date field rejects the text that a person typed. The field reports it
|
|
30
|
+
* through `onEntryErrorChange`, so the app can word its own message.
|
|
31
|
+
*/
|
|
32
|
+
|
|
33
|
+
function isSameEntryError(a, b) {
|
|
34
|
+
return a === b || a != null && b != null && a.kind === b.kind && a.text === b.text && a.date === b.date;
|
|
35
|
+
}
|
|
36
|
+
function isOutsideBounds(date, min, max) {
|
|
37
|
+
return min != null && plainDateIsBefore(date, plainDateFromISO(min)) || max != null && plainDateIsAfter(date, plainDateFromISO(max));
|
|
38
|
+
}
|
|
27
39
|
/** The rejection a result shows: errors of complete text, or of committed text. */
|
|
28
40
|
export function typedDateError(result, isCommitted) {
|
|
29
41
|
if (result == null) {
|
|
@@ -38,6 +50,31 @@ export function typedDateError(result, isCommitted) {
|
|
|
38
50
|
return null;
|
|
39
51
|
}
|
|
40
52
|
|
|
53
|
+
/** The rejection a result shows, as the field reports it to its caller. */
|
|
54
|
+
function dateEntryError(result, isCommitted, text, min, max) {
|
|
55
|
+
const error = typedDateError(result, isCommitted);
|
|
56
|
+
if (error == null || result == null) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
if (result.kind === 'incomplete') {
|
|
60
|
+
return {
|
|
61
|
+
kind: 'incomplete',
|
|
62
|
+
text
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
if (result.kind === 'outOfRange') {
|
|
66
|
+
return {
|
|
67
|
+
kind: isOutsideBounds(result.date, min, max) ? 'outOfRange' : 'unavailable',
|
|
68
|
+
text,
|
|
69
|
+
date: plainDateToISO(result.date)
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
kind: error,
|
|
74
|
+
text
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
|
|
41
78
|
/**
|
|
42
79
|
* Typed entry for a date text field in the active calendar. Values stay
|
|
43
80
|
* Gregorian; the calendar changes only what people type and read.
|
|
@@ -110,9 +147,7 @@ export function useTypedDate({
|
|
|
110
147
|
if (result.kind === 'outOfRange') {
|
|
111
148
|
const boundFormat = typeof format === 'function' ? 'date_long' : format;
|
|
112
149
|
const writeBound = bound => formatCalendarDateText(plainDateFromISO(bound), boundFormat, locale, calendar);
|
|
113
|
-
const
|
|
114
|
-
const isAfterMax = max != null && plainDateIsAfter(result.date, plainDateFromISO(max));
|
|
115
|
-
const bounds = !isBeforeMin && !isAfterMax ? 'none' : min != null && max != null ? 'both' : min != null ? 'min' : 'max';
|
|
150
|
+
const bounds = !isOutsideBounds(result.date, min, max) ? 'none' : min != null && max != null ? 'both' : min != null ? 'min' : 'max';
|
|
116
151
|
return t('@astryx.dateInput.outOfRangeDate', {
|
|
117
152
|
bounds,
|
|
118
153
|
min: min != null ? writeBound(min) : '',
|
|
@@ -143,6 +178,7 @@ export function useTypedDateField({
|
|
|
143
178
|
isDisabled,
|
|
144
179
|
status,
|
|
145
180
|
isStatusAnnounced,
|
|
181
|
+
onEntryErrorChange,
|
|
146
182
|
hasPlaceholder,
|
|
147
183
|
...options
|
|
148
184
|
}) {
|
|
@@ -153,8 +189,15 @@ export function useTypedDateField({
|
|
|
153
189
|
const [isRejectionCommitted, setIsRejectionCommitted] = useState(false);
|
|
154
190
|
const [isFocused, setIsFocused] = useState(false);
|
|
155
191
|
// The date that typing last reported, so one typing session reports each
|
|
156
|
-
// date once.
|
|
157
|
-
|
|
192
|
+
// date once. Only the handlers write it. A value from outside and a
|
|
193
|
+
// re-enable retire it by moving `firedEpoch` on, during render, so no
|
|
194
|
+
// render React discards can retire it.
|
|
195
|
+
const [lastFired, setLastFired] = useState({
|
|
196
|
+
date: undefined,
|
|
197
|
+
epoch: 0
|
|
198
|
+
});
|
|
199
|
+
const [firedEpoch, setFiredEpoch] = useState(0);
|
|
200
|
+
const lastFiredDate = lastFired.epoch === firedEpoch ? lastFired.date : undefined;
|
|
158
201
|
const typedResult = pendingInput !== null && pendingInput.trim() ? typedDate.parse(pendingInput) : null;
|
|
159
202
|
// A locked field hides the rejection but keeps its state, so the rejection
|
|
160
203
|
// shows again once the field is editable.
|
|
@@ -166,19 +209,117 @@ export function useTypedDateField({
|
|
|
166
209
|
type: 'error',
|
|
167
210
|
message: errorMessage
|
|
168
211
|
} : undefined;
|
|
169
|
-
const
|
|
212
|
+
const entryError = isDisabled ? null : dateEntryError(typedResult, isRejectionCommitted, pendingInput ?? '', options.min, options.max);
|
|
213
|
+
|
|
214
|
+
// The rejection that the caller last received. Handlers report a rejection
|
|
215
|
+
// that they cause in the same update. A rejection that a prop change causes
|
|
216
|
+
// reaches the caller only after the render. Until then the field keeps the
|
|
217
|
+
// caller's status, so it never shows and announces its own message just
|
|
218
|
+
// before the caller's message replaces it.
|
|
219
|
+
const [heardEntryError, setHeardEntryError] = useState(null);
|
|
220
|
+
const reportedEntryErrorRef = useRef(null);
|
|
221
|
+
// The callback of the latest commit, for the report at unmount.
|
|
222
|
+
const latestEntryErrorCallbackRef = useRef(onEntryErrorChange);
|
|
223
|
+
const hasEntryErrorCallback = onEntryErrorChange != null;
|
|
224
|
+
const isCallerBehind = hasEntryErrorCallback && !isSameEntryError(entryError, heardEntryError);
|
|
225
|
+
// A caller that receives rejections words them: its error message replaces
|
|
226
|
+
// the field's own message. A warning or a success never hides a rejection.
|
|
227
|
+
const callerErrorMessage = hasEntryErrorCallback && status?.type === 'error' && status.message ? status.message : null;
|
|
228
|
+
const fieldStatus = isCallerBehind || callerErrorMessage != null ? status : typedStatus ?? status;
|
|
229
|
+
|
|
230
|
+
// Field announces its status when the status appears or changes. A
|
|
231
|
+
// rejection that starts under the caller's error message changes no status,
|
|
232
|
+
// so the field's alert announces that message once for it. This record
|
|
233
|
+
// holds the error message that the status showed while no rejection stood.
|
|
234
|
+
// A change of the shown message during the rejection ends the repeat,
|
|
235
|
+
// because Field announces that change.
|
|
236
|
+
const shownErrorMessage = fieldStatus?.type === 'error' ? fieldStatus.message ?? null : null;
|
|
237
|
+
const [statusRecord, setStatusRecord] = useState({
|
|
238
|
+
message: shownErrorMessage,
|
|
239
|
+
isRepeatable: true
|
|
240
|
+
});
|
|
241
|
+
// The alert and the status change in the same render.
|
|
242
|
+
const statusRecordInput = `${entryError != null}:${shownErrorMessage}`;
|
|
243
|
+
const prevStatusRecordInputRef = useRef(statusRecordInput);
|
|
244
|
+
if (hasEntryErrorCallback && statusRecordInput !== prevStatusRecordInputRef.current) {
|
|
245
|
+
prevStatusRecordInputRef.current = statusRecordInput;
|
|
246
|
+
if (entryError == null) {
|
|
247
|
+
if (statusRecord.message !== shownErrorMessage || !statusRecord.isRepeatable) {
|
|
248
|
+
setStatusRecord({
|
|
249
|
+
message: shownErrorMessage,
|
|
250
|
+
isRepeatable: true
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
} else if (statusRecord.isRepeatable && statusRecord.message !== shownErrorMessage) {
|
|
254
|
+
setStatusRecord({
|
|
255
|
+
message: statusRecord.message,
|
|
256
|
+
isRepeatable: false
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
let alertMessage = '';
|
|
261
|
+
if (errorMessage != null && !isCallerBehind) {
|
|
262
|
+
if (callerErrorMessage != null) {
|
|
263
|
+
const isStatusRepeated = statusRecord.isRepeatable && statusRecord.message === callerErrorMessage;
|
|
264
|
+
// Inside an InputGroup no Field announces the caller's status.
|
|
265
|
+
alertMessage = !isStatusAnnounced || isStatusRepeated ? callerErrorMessage : '';
|
|
266
|
+
} else {
|
|
267
|
+
alertMessage = isStatusAnnounced && typedStatus != null ? '' : errorMessage;
|
|
268
|
+
}
|
|
269
|
+
}
|
|
270
|
+
const reportEntryError = useCallback(error => {
|
|
271
|
+
if (onEntryErrorChange == null) {
|
|
272
|
+
return;
|
|
273
|
+
}
|
|
274
|
+
setHeardEntryError(error);
|
|
275
|
+
if (!isSameEntryError(error, reportedEntryErrorRef.current)) {
|
|
276
|
+
reportedEntryErrorRef.current = error;
|
|
277
|
+
onEntryErrorChange(error);
|
|
278
|
+
}
|
|
279
|
+
}, [onEntryErrorChange]);
|
|
280
|
+
|
|
281
|
+
// Syncs the caller's entry error with a rejection that a new `min`, `max`,
|
|
282
|
+
// `dateConstraints`, `value`, or disabled state starts, changes, or ends.
|
|
283
|
+
useEffect(() => {
|
|
284
|
+
latestEntryErrorCallbackRef.current = onEntryErrorChange;
|
|
285
|
+
if (onEntryErrorChange == null) {
|
|
286
|
+
return;
|
|
287
|
+
}
|
|
288
|
+
if (!isSameEntryError(entryError, reportedEntryErrorRef.current)) {
|
|
289
|
+
reportedEntryErrorRef.current = entryError;
|
|
290
|
+
// Called through the ref: the set-state-in-effect rule takes a call to a
|
|
291
|
+
// hook parameter for the whole hook's body.
|
|
292
|
+
latestEntryErrorCallbackRef.current?.(entryError);
|
|
293
|
+
}
|
|
294
|
+
if (!isSameEntryError(entryError, heardEntryError)) {
|
|
295
|
+
// eslint-disable-next-line @eslint-react/set-state-in-effect -- shows the field's own message once the caller has the rejection
|
|
296
|
+
setHeardEntryError(entryError);
|
|
297
|
+
}
|
|
298
|
+
}, [entryError, heardEntryError, onEntryErrorChange]);
|
|
299
|
+
|
|
300
|
+
// Syncs the caller's entry error at unmount. A presentation or pointer
|
|
301
|
+
// change can replace the field while its reported rejection stands, and
|
|
302
|
+
// the rejection ends with the field.
|
|
303
|
+
useEffect(() => () => {
|
|
304
|
+
if (reportedEntryErrorRef.current != null) {
|
|
305
|
+
reportedEntryErrorRef.current = null;
|
|
306
|
+
latestEntryErrorCallbackRef.current?.(null);
|
|
307
|
+
}
|
|
308
|
+
}, []);
|
|
170
309
|
const reset = useCallback(() => {
|
|
171
310
|
setPendingInput(null);
|
|
172
311
|
setIsRejectionCommitted(false);
|
|
173
|
-
|
|
312
|
+
reportEntryError(null);
|
|
313
|
+
}, [reportEntryError]);
|
|
174
314
|
|
|
175
|
-
// A value from outside drops typed text.
|
|
176
|
-
// takes no extra render
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
315
|
+
// A value from outside drops typed text. Adjusted during render, so it
|
|
316
|
+
// takes no extra commit; state, so a render React discards takes its
|
|
317
|
+
// adjustment with it.
|
|
318
|
+
const [prevValue, setPrevValue] = useState(value);
|
|
319
|
+
if (value !== prevValue) {
|
|
320
|
+
setPrevValue(value);
|
|
321
|
+
if (value !== lastFiredDate) {
|
|
322
|
+
setFiredEpoch(epoch => epoch + 1);
|
|
182
323
|
if (pendingInput !== null) {
|
|
183
324
|
setPendingInput(null);
|
|
184
325
|
setIsRejectionCommitted(false);
|
|
@@ -189,23 +330,26 @@ export function useTypedDateField({
|
|
|
189
330
|
// Typing already reported this date through `onChange`. Once the field is
|
|
190
331
|
// editable, it shows its value. A retyped date then reports again. A focused
|
|
191
332
|
// field keeps the text until Enter or blur, which end the typing session.
|
|
192
|
-
const
|
|
193
|
-
if (isDisabled !==
|
|
194
|
-
|
|
195
|
-
if (!isDisabled && !isFocused && typedResult?.kind === 'value' && plainDateToISO(typedResult.date) ===
|
|
196
|
-
|
|
333
|
+
const [wasDisabled, setWasDisabled] = useState(isDisabled);
|
|
334
|
+
if (isDisabled !== wasDisabled) {
|
|
335
|
+
setWasDisabled(isDisabled);
|
|
336
|
+
if (!isDisabled && !isFocused && typedResult?.kind === 'value' && plainDateToISO(typedResult.date) === lastFiredDate) {
|
|
337
|
+
setFiredEpoch(epoch => epoch + 1);
|
|
197
338
|
setPendingInput(null);
|
|
198
339
|
setIsRejectionCommitted(false);
|
|
199
340
|
}
|
|
200
341
|
}
|
|
201
342
|
const report = useCallback(date => {
|
|
202
|
-
if (date === value || date ===
|
|
343
|
+
if (date === value || date === lastFiredDate) {
|
|
203
344
|
return false;
|
|
204
345
|
}
|
|
205
|
-
|
|
346
|
+
setLastFired({
|
|
347
|
+
date,
|
|
348
|
+
epoch: firedEpoch
|
|
349
|
+
});
|
|
206
350
|
onChange(date);
|
|
207
351
|
return true;
|
|
208
|
-
}, [value, onChange]);
|
|
352
|
+
}, [value, lastFiredDate, firedEpoch, onChange]);
|
|
209
353
|
const handleChange = useCallback(text => {
|
|
210
354
|
if (isDisabled) {
|
|
211
355
|
return;
|
|
@@ -214,13 +358,14 @@ export function useTypedDateField({
|
|
|
214
358
|
setIsRejectionCommitted(false);
|
|
215
359
|
// Report a date only once more typing cannot change it.
|
|
216
360
|
const result = typedDate.parse(text);
|
|
361
|
+
reportEntryError(dateEntryError(text.trim() ? result : null, false, text, options.min, options.max));
|
|
217
362
|
if (result.kind === 'value' && result.isComplete) {
|
|
218
363
|
const date = plainDateToISO(result.date);
|
|
219
364
|
if (report(date)) {
|
|
220
365
|
onTypedDate?.(date);
|
|
221
366
|
}
|
|
222
367
|
}
|
|
223
|
-
}, [isDisabled, typedDate, report, onTypedDate]);
|
|
368
|
+
}, [isDisabled, typedDate, reportEntryError, options.min, options.max, report, onTypedDate]);
|
|
224
369
|
const commit = useCallback(() => {
|
|
225
370
|
if (pendingInput === null || isDisabled) {
|
|
226
371
|
return;
|
|
@@ -235,15 +380,19 @@ export function useTypedDateField({
|
|
|
235
380
|
// Keep the text and show why it cannot commit; never finish or adjust
|
|
236
381
|
// the date.
|
|
237
382
|
setIsRejectionCommitted(true);
|
|
383
|
+
reportEntryError(dateEntryError(result, true, pendingInput, options.min, options.max));
|
|
238
384
|
return;
|
|
239
385
|
}
|
|
240
386
|
if (result.kind === 'value') {
|
|
241
387
|
report(plainDateToISO(result.date));
|
|
242
388
|
}
|
|
243
389
|
// A new typing session reports a retyped date again.
|
|
244
|
-
|
|
390
|
+
setLastFired({
|
|
391
|
+
date: undefined,
|
|
392
|
+
epoch: firedEpoch
|
|
393
|
+
});
|
|
245
394
|
reset();
|
|
246
|
-
}, [pendingInput, isDisabled, onClear, typedDate, report, reset]);
|
|
395
|
+
}, [pendingInput, isDisabled, onClear, typedDate, reportEntryError, options.min, options.max, report, reset, firedEpoch]);
|
|
247
396
|
const handleFocus = useCallback(() => {
|
|
248
397
|
setIsFocused(true);
|
|
249
398
|
typedDate.prepare();
|
|
@@ -260,7 +409,7 @@ export function useTypedDateField({
|
|
|
260
409
|
isPending: pendingInput !== null,
|
|
261
410
|
isInvalid: typedError != null,
|
|
262
411
|
fieldStatus,
|
|
263
|
-
alertMessage
|
|
412
|
+
alertMessage,
|
|
264
413
|
handleChange,
|
|
265
414
|
commit,
|
|
266
415
|
handleFocus,
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { type InputStatus } from '../Field/index.js';
|
|
2
2
|
import { type DayOfWeek, type DayOfWeekName } from '../Calendar/index.js';
|
|
3
3
|
import type { CalendarSystem } from '../utils/calendarSystem.js';
|
|
4
|
+
import { type DateInputEntryError } from '../DateInput/useTypedDate.js';
|
|
4
5
|
import { type FieldInputBaseProps } from '../Field/fieldParts.js';
|
|
5
6
|
import type { SizeValue } from '../utils/types.js';
|
|
6
7
|
import { type PickerPresentation } from '../utils/inputPresentation.js';
|
|
8
|
+
export type { DateInputEntryError } from '../DateInput/useTypedDate.js';
|
|
7
9
|
export type ISODateTimeString = string & {
|
|
8
10
|
readonly __brand: 'ISODateTimeString';
|
|
9
11
|
};
|
|
@@ -189,8 +191,34 @@ export interface DateTimeInputProps extends Omit<FieldInputBaseProps<HTMLInputEl
|
|
|
189
191
|
size?: DateTimeInputSize;
|
|
190
192
|
/**
|
|
191
193
|
* Status indicator for the input.
|
|
194
|
+
*
|
|
195
|
+
* For a typed date the date segment rejects, and for unfinished date text
|
|
196
|
+
* that Enter or blur keeps, the field shows its own error message in place
|
|
197
|
+
* of `status`. Unreadable date text is announced, not shown. With
|
|
198
|
+
* `onEntryErrorChange`, an `error` status with a message shows instead, and
|
|
199
|
+
* the field's own message applies only without one. A `warning` or
|
|
200
|
+
* `success` status never replaces a rejection.
|
|
192
201
|
*/
|
|
193
202
|
status?: InputStatus;
|
|
203
|
+
/**
|
|
204
|
+
* Called each time the date segment's rejection of typed text changes, with
|
|
205
|
+
* `null` when the rejection ends. `kind` is `'unreadable'`, `'incomplete'`,
|
|
206
|
+
* `'nonexistent'` (a date the calendar does not have), `'outOfRange'`
|
|
207
|
+
* (before the date of `min` or after the date of `max`), or `'unavailable'`
|
|
208
|
+
* (a day `dateConstraints` rules out). `text` is the typed text, and `date`
|
|
209
|
+
* is the Gregorian ISO date the text names, for `'outOfRange'` and
|
|
210
|
+
* `'unavailable'`.
|
|
211
|
+
*
|
|
212
|
+
* It also runs when a new `min`, `max`, `dateConstraints`, or `value`, a
|
|
213
|
+
* calendar pick, disabling the field, or Enter or blur changes the
|
|
214
|
+
* rejection, and never twice for the same rejection. It reports `null` when
|
|
215
|
+
* the typed field leaves while its rejection stands, as when a presentation
|
|
216
|
+
* or pointer change shows the native or touch picker. Passing it lets an
|
|
217
|
+
* `error` `status` word the rejection (see `status`). A rejection that
|
|
218
|
+
* starts under an unchanged error message announces that message once. The
|
|
219
|
+
* native and touch pickers take no typed text, so they report no rejection.
|
|
220
|
+
*/
|
|
221
|
+
onEntryErrorChange?: (error: DateInputEntryError | null) => void;
|
|
194
222
|
/**
|
|
195
223
|
* Width of the field. Numbers are treated as pixels, strings are used as-is
|
|
196
224
|
* (e.g. `'100%'`). Sizes the whole field (label, control, and status) so they
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DateTimeInput.d.ts","sourceRoot":"","sources":["../../src/DateTimeInput/DateTimeInput.tsx"],"names":[],"mappings":"AA6CA,OAAO,EAGL,KAAK,WAAW,EAKjB,MAAM,UAAU,CAAC;AAIlB,OAAO,EAIL,KAAK,SAAS,EACd,KAAK,aAAa,EACnB,MAAM,aAAa,CAAC;AAyBrB,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"DateTimeInput.d.ts","sourceRoot":"","sources":["../../src/DateTimeInput/DateTimeInput.tsx"],"names":[],"mappings":"AA6CA,OAAO,EAGL,KAAK,WAAW,EAKjB,MAAM,UAAU,CAAC;AAIlB,OAAO,EAIL,KAAK,SAAS,EACd,KAAK,aAAa,EACnB,MAAM,aAAa,CAAC;AAyBrB,OAAO,KAAK,EAAC,cAAc,EAAC,MAAM,yBAAyB,CAAC;AAE5D,OAAO,EACL,KAAK,mBAAmB,EAEzB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAEL,KAAK,mBAAmB,EACzB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,gBAAgB,CAAC;AAmB9C,OAAO,EAEL,KAAK,kBAAkB,EACxB,MAAM,4BAA4B,CAAC;AAUpC,YAAY,EAAC,mBA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C,KAAK,EAAE,mBAAmB,GAAG,IAAI,KAAK,IAAI,CAAC;IAEjE;;;;OAIG;IACH,KAAK,CAAC,EAAE,SAAS,CAAC;IAClB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB;;;;;OAKG;IACH,cAAc,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC;IAEvB;;;;;OAKG;IACH,YAAY,CAAC,EAAE,SAAS,GAAG,aAAa,CAAC;IAEzC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OA6BG;IACH,YAAY,CAAC,EAAE,yBAAyB,CAAC;IAEzC;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,YAAY,CAAC,EAAE,yBAAyB,CAAC;CAC1C;AA48CD;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,kBAAkB,+BAmDtD;yBAnDe,aAAa"}
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @file DateTimeInput.tsx
|
|
7
7
|
* @input Uses React, Field, Calendar, NativeDateSegment, NativeTimeSegment, TouchDateTimeField, usePopover, useAnnounce, time parsing utilities, StyleX intrinsic flex layout
|
|
8
|
-
* @output Exports DateTimeInput component, DateTimeInputProps, and native picker type; cleared values keep the pointer Calendar controlled-empty
|
|
8
|
+
* @output Exports DateTimeInput component, DateTimeInputProps, DateInputEntryError, and native picker type; cleared values keep the pointer Calendar controlled-empty; typed date rejections reach onEntryErrorChange
|
|
9
9
|
* @position Core implementation; consumed by index.ts, tested by DateTimeInput.test.tsx
|
|
10
10
|
*
|
|
11
11
|
* SYNC: When modified, update these files to stay in sync:
|
|
@@ -253,6 +253,7 @@ function PointerDateTimeField({
|
|
|
253
253
|
timeLabel,
|
|
254
254
|
size: sizeProp,
|
|
255
255
|
status,
|
|
256
|
+
onEntryErrorChange,
|
|
256
257
|
labelTooltip,
|
|
257
258
|
numberOfMonths = 1,
|
|
258
259
|
weekStartsOn,
|
|
@@ -560,9 +561,12 @@ function PointerDateTimeField({
|
|
|
560
561
|
onChange: handleTypedDateChange,
|
|
561
562
|
onClear: clearTypedDate,
|
|
562
563
|
onTypedDate: navigateToTypedDate,
|
|
563
|
-
|
|
564
|
+
// The native date control takes no typed text, so kept typed text and its
|
|
565
|
+
// rejection wait for the typed field.
|
|
566
|
+
isDisabled: isEffectivelyDisabled || usesNativePicker,
|
|
564
567
|
status,
|
|
565
568
|
isStatusAnnounced: true,
|
|
569
|
+
onEntryErrorChange,
|
|
566
570
|
hasPlaceholder: placeholderFromProps != null
|
|
567
571
|
});
|
|
568
572
|
|
|
@@ -1379,10 +1383,17 @@ export function DateTimeInput(props) {
|
|
|
1379
1383
|
nativeMode: "adaptive"
|
|
1380
1384
|
});
|
|
1381
1385
|
case 'sheet':
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
+
{
|
|
1387
|
+
// The sheet takes no typed text.
|
|
1388
|
+
const {
|
|
1389
|
+
onEntryErrorChange: _onEntryErrorChange,
|
|
1390
|
+
...sheetProps
|
|
1391
|
+
} = rest;
|
|
1392
|
+
// Month indexes depend on the calendar. A new calendar remounts the sheet.
|
|
1393
|
+
return /*#__PURE__*/_jsx(TouchDateTimeField, {
|
|
1394
|
+
...sheetProps
|
|
1395
|
+
}, calendar);
|
|
1396
|
+
}
|
|
1386
1397
|
case 'desktop':
|
|
1387
1398
|
return /*#__PURE__*/_jsx(PointerDateTimeField, {
|
|
1388
1399
|
...rest
|
|
@@ -5,5 +5,5 @@
|
|
|
5
5
|
* @position Package entry point for DateTimeInput
|
|
6
6
|
*/
|
|
7
7
|
export { DateTimeInput } from './DateTimeInput.js';
|
|
8
|
-
export type { DateTimeInputProps, DateTimeInputSize, DateTimeInputHourFormat, DateTimeInputNativePicker, DateTimeInputPresentation, DateTimeInputTimeIncrement, DateTimeInputTimeOptionInterval, DateTimeInputStatus, DateTimeInputStatusType, ISODateTimeString, } from './DateTimeInput.js';
|
|
8
|
+
export type { DateTimeInputProps, DateTimeInputSize, DateTimeInputHourFormat, DateTimeInputNativePicker, DateTimeInputPresentation, DateTimeInputTimeIncrement, DateTimeInputTimeOptionInterval, DateTimeInputStatus, DateTimeInputStatusType, DateInputEntryError, ISODateTimeString, } from './DateTimeInput.js';
|
|
9
9
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/DateTimeInput/index.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAC9C,YAAY,EACV,kBAAkB,EAClB,iBAAiB,EACjB,uBAAuB,EACvB,yBAAyB,EACzB,yBAAyB,EACzB,0BAA0B,EAC1B,+BAA+B,EAC/B,mBAAmB,EACnB,uBAAuB,EACvB,iBAAiB,GAClB,MAAM,iBAAiB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/DateTimeInput/index.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AAEH,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAC;AAC9C,YAAY,EACV,kBAAkB,EAClB,iBAAiB,EACjB,uBAAuB,EACvB,yBAAyB,EACzB,yBAAyB,EACzB,0BAA0B,EAC1B,+BAA+B,EAC/B,mBAAmB,EACnB,uBAAuB,EACvB,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,iBAAiB,CAAC"}
|
|
@@ -32,7 +32,10 @@ export declare function InputClearButton(props: InputClearButtonProps): ReactNod
|
|
|
32
32
|
export declare namespace InputClearButton {
|
|
33
33
|
var displayName: string;
|
|
34
34
|
}
|
|
35
|
-
/**
|
|
35
|
+
/**
|
|
36
|
+
* Internal variant for a clear button inside a layer trigger. It takes the
|
|
37
|
+
* keep-open props, so a press on it does not dismiss the open layer.
|
|
38
|
+
*/
|
|
36
39
|
export declare function InternalInputClearButton(props: InternalInputClearButtonProps): ReactNode;
|
|
37
40
|
export {};
|
|
38
41
|
//# sourceMappingURL=InputClearButton.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InputClearButton.d.ts","sourceRoot":"","sources":["../../src/Field/InputClearButton.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,OAAO,CAAC;AACrC,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAyE3C,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;IAC1D,MAAM,CAAC,EAAE,MAAM,CAAC,YAAY,CAAC;IAC7B,iFAAiF;IACjF,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,UAAU,6BAA8B,SAAQ,qBAAqB;IACnE,aAAa,EAAE,KAAK,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAC;IACtD,cAAc,EAAE,KAAK,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC;CACtD;AA4DD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,SAAS,CAMxE;yBANe,gBAAgB;;;AAQhC
|
|
1
|
+
{"version":3,"file":"InputClearButton.d.ts","sourceRoot":"","sources":["../../src/Field/InputClearButton.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,OAAO,CAAC;AACrC,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AAyE3C,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,CAAC,CAAC,EAAE,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;IAC1D,MAAM,CAAC,EAAE,MAAM,CAAC,YAAY,CAAC;IAC7B,iFAAiF;IACjF,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,UAAU,6BAA8B,SAAQ,qBAAqB;IACnE,aAAa,EAAE,KAAK,CAAC,mBAAmB,CAAC,WAAW,CAAC,CAAC;IACtD,cAAc,EAAE,KAAK,CAAC,iBAAiB,CAAC,WAAW,CAAC,CAAC;CACtD;AA4DD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,SAAS,CAMxE;yBANe,gBAAgB;;;AAQhC;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,6BAA6B,GACnC,SAAS,CAMX"}
|
|
@@ -136,7 +136,10 @@ export function InputClearButton(props) {
|
|
|
136
136
|
});
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
-
/**
|
|
139
|
+
/**
|
|
140
|
+
* Internal variant for a clear button inside a layer trigger. It takes the
|
|
141
|
+
* keep-open props, so a press on it does not dismiss the open layer.
|
|
142
|
+
*/
|
|
140
143
|
export function InternalInputClearButton(props) {
|
|
141
144
|
const t = useComponentTranslator();
|
|
142
145
|
return renderInputClearButton({
|
package/dist/Item/Item.d.ts
CHANGED
|
@@ -70,10 +70,12 @@ export interface ItemSwipeActions {
|
|
|
70
70
|
trailing?: ItemSwipeAction[];
|
|
71
71
|
}
|
|
72
72
|
/**
|
|
73
|
-
* `reveal`: past half the panel the row rests open with
|
|
74
|
-
* button; a long drag
|
|
75
|
-
*
|
|
76
|
-
*
|
|
73
|
+
* `reveal`: past half the panel, or after a fling, the row rests open with
|
|
74
|
+
* every entry a real button; a long drag fires the outermost. On a side with
|
|
75
|
+
* two or more entries, only a drag that starts on the open row fires it.
|
|
76
|
+
* `commit`: a release past the commit point slides the row out and fires a
|
|
77
|
+
* side's one entry; nothing rests, and the panel is presentational. On a side
|
|
78
|
+
* with two or more entries, `commit` fires none. A fling never fires an entry.
|
|
77
79
|
*/
|
|
78
80
|
export type ItemSwipeBehavior = 'reveal' | 'commit';
|
|
79
81
|
export interface ItemProps extends BaseProps<HTMLElement> {
|
|
@@ -223,9 +225,11 @@ export interface ItemProps extends BaseProps<HTMLElement> {
|
|
|
223
225
|
*/
|
|
224
226
|
swipeActions?: ItemSwipeActions;
|
|
225
227
|
/**
|
|
226
|
-
* What a swipe does
|
|
227
|
-
* and fires the outermost
|
|
228
|
-
*
|
|
228
|
+
* What a swipe does. `reveal` rests the row open with every entry tappable,
|
|
229
|
+
* and a long drag fires the outermost. On a side with two or more entries,
|
|
230
|
+
* only a drag from the open row fires it. `commit` slides the row out and
|
|
231
|
+
* fires a side's one entry on release. On a side with two or more entries,
|
|
232
|
+
* `commit` fires none.
|
|
229
233
|
* @default 'reveal'
|
|
230
234
|
*/
|
|
231
235
|
swipeBehavior?: ItemSwipeBehavior;
|
package/dist/Item/Item.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Item.d.ts","sourceRoot":"","sources":["../../src/Item/Item.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AAEH,OAAO,EAOL,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AAUf,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAuC5C,MAAM,MAAM,SAAS,GAAG,QAAQ,GAAG,OAAO,GAAG,YAAY,CAAC;AAC1D,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,UAAU,GAAG,UAAU,CAAC;AAE9D;;;GAGG;AACH,MAAM,MAAM,sBAAsB,GAAG,SAAS,GAAG,QAAQ,GAAG,aAAa,CAAC;AAE1E,yFAAyF;AACzF,MAAM,WAAW,eAAe;IAC9B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ;;;;OAIG;IACH,KAAK,EAAE,MAAM,CAAC;IACd,6BAA6B;IAC7B,IAAI,CAAC,EAAE,SAAS,CAAC;IACjB;;;;OAIG;IACH,UAAU,EAAE,MAAM,IAAI,GAAG,OAAO,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,SAAS,+BAqcX;yBAjee,IAAI"}
|
package/dist/Item/Item.js
CHANGED
|
@@ -46,7 +46,7 @@ import { ItemTrailingContext } from "./ItemTrailingContext.js";
|
|
|
46
46
|
import { useMergedRefs } from "../hooks/useMergedRefs.js";
|
|
47
47
|
import { computeTargetAndRel } from "../Link/computeTargetAndRel.js";
|
|
48
48
|
import { useLinkComponent } from "../Link/useLinkComponent.js";
|
|
49
|
-
import {
|
|
49
|
+
import { cancelNestedPress, PRESSABLE_CONTAINER_ATTRIBUTE, useClickableContainerProxy } from "../hooks/useClickableContainer.js";
|
|
50
50
|
import { useDevWarning } from "../hooks/useDevWarning.js";
|
|
51
51
|
import { themeProps } from "../utils/themeProps.js";
|
|
52
52
|
import { focusOutlineProps } from "../utils/focusOutline.stylex.js";
|
|
@@ -75,10 +75,12 @@ const LazyItemSwipeLayer = /*#__PURE__*/lazy(async () => import("./ItemSwipeLaye
|
|
|
75
75
|
/** One verb a sideways drag uncovers. Every field is known before the gesture begins. */
|
|
76
76
|
|
|
77
77
|
/**
|
|
78
|
-
* `reveal`: past half the panel the row rests open with
|
|
79
|
-
* button; a long drag
|
|
80
|
-
*
|
|
81
|
-
*
|
|
78
|
+
* `reveal`: past half the panel, or after a fling, the row rests open with
|
|
79
|
+
* every entry a real button; a long drag fires the outermost. On a side with
|
|
80
|
+
* two or more entries, only a drag that starts on the open row fires it.
|
|
81
|
+
* `commit`: a release past the commit point slides the row out and fires a
|
|
82
|
+
* side's one entry; nothing rests, and the panel is presentational. On a side
|
|
83
|
+
* with two or more entries, `commit` fires none. A fling never fires an entry.
|
|
82
84
|
*/
|
|
83
85
|
|
|
84
86
|
// =============================================================================
|
|
@@ -353,7 +355,7 @@ export function Item({
|
|
|
353
355
|
// it keeps the press. Such a row is not a clickable container: an enclosing
|
|
354
356
|
// card still treats it as part of its own surface.
|
|
355
357
|
const hasOwnAction = (onClick != null || href != null) && !hasParentRole && !isLinkRoot;
|
|
356
|
-
const pressOnRow = event =>
|
|
358
|
+
const pressOnRow = event => cancelNestedPress(event, event.currentTarget, href != null ? actionLinkRef.current : actionButtonRef.current);
|
|
357
359
|
const leadingSwipe = swipeActions?.leading ?? [];
|
|
358
360
|
const trailingSwipe = swipeActions?.trailing ?? [];
|
|
359
361
|
const hasSwipe = servesSwipeActions({
|
|
@@ -363,7 +365,7 @@ export function Item({
|
|
|
363
365
|
isLinkRoot,
|
|
364
366
|
role
|
|
365
367
|
});
|
|
366
|
-
useDevWarning('Item', '`swipeBehavior="commit"` fires
|
|
368
|
+
useDevWarning('Item', '`swipeBehavior="commit"` fires no entry on a side with two or more ' + 'entries. Give a committing side one entry, or use ' + '`swipeBehavior="reveal"`.', hasSwipe && swipeBehavior === 'commit' && (leadingSwipe.length > 1 || trailingSwipe.length > 1));
|
|
367
369
|
const swipeRootRef = useRef(null);
|
|
368
370
|
// Filled by the swipe layer once it has mounted; empty until then and on a
|
|
369
371
|
// row without swipe actions, when the forwarders below do nothing.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ItemSwipeLayer.d.ts","sourceRoot":"","sources":["../../src/Item/ItemSwipeLayer.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,
|
|
1
|
+
{"version":3,"file":"ItemSwipeLayer.d.ts","sourceRoot":"","sources":["../../src/Item/ItemSwipeLayer.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAA8B,KAAK,SAAS,EAAC,MAAM,OAAO,CAAC;AAclE,OAAO,EAEL,KAAK,aAAa,EAEnB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAC,eAAe,EAAE,iBAAiB,EAAC,MAAM,QAAQ,CAAC;AAM/D;;;;GAIG;AACH,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,aAAa,CAAC;IACxB,mBAAmB,EAAE,MAAM,OAAO,CAAC;CACpC;AAED,MAAM,WAAW,mBAAmB;IAClC,0EAA0E;IAC1E,OAAO,EAAE,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IACvC;;;OAGG;IACH,QAAQ,EAAE,CAAC,MAAM,EAAE,eAAe,GAAG,IAAI,KAAK,IAAI,CAAC;IACnD,OAAO,EAAE,eAAe,EAAE,CAAC;IAC3B,QAAQ,EAAE,eAAe,EAAE,CAAC;IAC5B,QAAQ,EAAE,iBAAiB,CAAC;CAC7B;AAgJD;;;GAGG;AACH,iBAAwB,cAAc,CAAC,EACrC,OAAO,EACP,QAAQ,EACR,OAAO,EACP,QAAQ,EACR,QAAQ,GACT,EAAE,mBAAmB,+BA+KrB;kBArLuB,cAAc;;;eAAd,cAAc"}
|