@astryxdesign/core 0.7.15 → 0.7.16-canary.g8514aae
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/BottomSheet/BottomSheet.d.ts.map +1 -1
- package/dist/BottomSheet/BottomSheet.js +11 -6
- package/dist/DateInput/DateInput.d.ts +3 -3
- package/dist/DateInput/DateInput.d.ts.map +1 -1
- package/dist/DateInput/DateInput.js +13 -2
- package/dist/DateInput/NativeDateField.d.ts +1 -1
- package/dist/DateInput/NativeDateField.d.ts.map +1 -1
- package/dist/DateInput/NativeDateField.js +48 -31
- package/dist/DateInput/useTypedDate.d.ts +66 -6
- package/dist/DateInput/useTypedDate.d.ts.map +1 -1
- package/dist/DateInput/useTypedDate.js +151 -21
- package/dist/DateTimeInput/DateTimeInput.d.ts +3 -3
- package/dist/DateTimeInput/DateTimeInput.d.ts.map +1 -1
- package/dist/DateTimeInput/DateTimeInput.js +26 -3
- package/dist/DateTimeInput/NativeDateSegment.d.ts +8 -1
- package/dist/DateTimeInput/NativeDateSegment.d.ts.map +1 -1
- package/dist/DateTimeInput/NativeDateSegment.js +20 -14
- package/dist/Field/InputClearButton.d.ts.map +1 -1
- package/dist/Field/InputClearButton.js +4 -2
- package/dist/InfoTip/InfoTip.d.ts +1 -1
- package/dist/InfoTip/InfoTip.d.ts.map +1 -1
- package/dist/InfoTip/InfoTip.js +4 -1
- package/dist/Layer/layerAnimations.stylex.d.ts.map +1 -1
- package/dist/Layer/layerAnimations.stylex.js +17 -13
- package/dist/Layer/layerEntranceSide.d.ts +24 -10
- package/dist/Layer/layerEntranceSide.d.ts.map +1 -1
- package/dist/Layer/layerEntranceSide.js +28 -13
- package/dist/Layer/useLayer.d.ts.map +1 -1
- package/dist/Layer/useLayer.js +14 -11
- package/dist/List/ListItem.d.ts +3 -2
- package/dist/List/ListItem.d.ts.map +1 -1
- package/dist/List/ListReorderHandle.d.ts +7 -0
- package/dist/List/ListReorderHandle.d.ts.map +1 -1
- package/dist/List/ListReorderHandle.js +42 -58
- package/dist/List/listReorderContext.d.ts.map +1 -1
- package/dist/List/listReorderContext.js +4 -4
- package/dist/List/listReorderEngine.d.ts +50 -2
- package/dist/List/listReorderEngine.d.ts.map +1 -1
- package/dist/List/listReorderEngine.js +205 -10
- package/dist/MoreMenu/MoreMenu.d.ts +1 -1
- package/dist/MoreMenu/MoreMenu.d.ts.map +1 -1
- package/dist/MoreMenu/MoreMenu.js +4 -1
- package/dist/PowerSearch/PowerSearch.d.ts +1 -1
- package/dist/PowerSearch/PowerSearch.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearch.js +8 -4
- package/dist/PowerSearch/PowerSearchEditPopover.d.ts +4 -1
- package/dist/PowerSearch/PowerSearchEditPopover.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearchEditPopover.js +4 -1
- package/dist/PowerSearch/PowerSearchFilterEditor.d.ts +1 -1
- package/dist/PowerSearch/PowerSearchFilterEditor.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearchFilterEditor.js +7 -3
- package/dist/PowerSearch/PowerSearchToken.d.ts +1 -1
- package/dist/PowerSearch/PowerSearchToken.d.ts.map +1 -1
- package/dist/PowerSearch/PowerSearchToken.js +4 -1
- package/dist/Selector/useSelectorPresentation.d.ts.map +1 -1
- package/dist/Selector/useSelectorPresentation.js +13 -12
- package/dist/Slider/Slider.d.ts.map +1 -1
- package/dist/Slider/Slider.js +6 -8
- package/dist/Table/BaseTable.d.ts +1 -1
- package/dist/Table/BaseTable.d.ts.map +1 -1
- package/dist/Table/BaseTable.js +265 -197
- package/dist/Table/Table.d.ts +5 -1
- package/dist/Table/Table.d.ts.map +1 -1
- package/dist/Table/index.d.ts +5 -3
- package/dist/Table/index.d.ts.map +1 -1
- package/dist/Table/index.js +2 -1
- package/dist/Table/plugins/infiniteScroll/TableInfiniteScrollWide.a11y.chromium.spec.d.ts.map +1 -0
- package/dist/Table/plugins/infiniteScroll/index.d.ts +9 -0
- package/dist/Table/plugins/infiniteScroll/index.d.ts.map +1 -0
- package/dist/Table/plugins/infiniteScroll/index.js +9 -0
- package/dist/Table/plugins/infiniteScroll/useTableInfiniteScroll.d.ts +29 -0
- package/dist/Table/plugins/infiniteScroll/useTableInfiniteScroll.d.ts.map +1 -0
- package/dist/Table/plugins/infiniteScroll/useTableInfiniteScroll.js +394 -0
- package/dist/Table/plugins/stickyColumns/useTableStickyColumns.d.ts.map +1 -1
- package/dist/Table/plugins/stickyColumns/useTableStickyColumns.js +21 -1
- package/dist/Table/plugins/virtualization/TableColumnWindow.d.ts +4 -0
- package/dist/Table/plugins/virtualization/TableColumnWindow.d.ts.map +1 -0
- package/dist/Table/plugins/virtualization/TableColumnWindow.js +109 -0
- package/dist/Table/plugins/virtualization/index.d.ts +3 -1
- package/dist/Table/plugins/virtualization/index.d.ts.map +1 -1
- package/dist/Table/plugins/virtualization/index.js +3 -2
- package/dist/Table/plugins/virtualization/useTableColumnWindow.d.ts +33 -0
- package/dist/Table/plugins/virtualization/useTableColumnWindow.d.ts.map +1 -0
- package/dist/Table/plugins/virtualization/useTableColumnWindow.js +143 -0
- package/dist/Table/plugins/virtualization/useTableColumnsVirtualization.d.ts +23 -0
- package/dist/Table/plugins/virtualization/useTableColumnsVirtualization.d.ts.map +1 -0
- package/dist/Table/plugins/virtualization/useTableColumnsVirtualization.js +37 -0
- package/dist/Table/tableColumnWindowing.d.ts +85 -0
- package/dist/Table/tableColumnWindowing.d.ts.map +1 -0
- package/dist/Table/tableColumnWindowing.js +47 -0
- package/dist/Table/tablePinnedColumnRuns.d.ts +23 -0
- package/dist/Table/tablePinnedColumnRuns.d.ts.map +1 -0
- package/dist/Table/tablePinnedColumnRuns.js +41 -0
- package/dist/Table/tableRuntime.d.ts +14 -2
- package/dist/Table/tableRuntime.d.ts.map +1 -1
- package/dist/Table/tableRuntime.js +32 -11
- package/dist/Table/types.d.ts +28 -2
- package/dist/Table/types.d.ts.map +1 -1
- package/dist/Table/useBaseTablePlugins.js +2 -2
- package/dist/TextArea/TextArea.d.ts +10 -1
- package/dist/TextArea/TextArea.d.ts.map +1 -1
- package/dist/TextArea/TextArea.js +2 -0
- package/dist/Toast/Toast.d.ts +1 -1
- package/dist/Toast/Toast.d.ts.map +1 -1
- package/dist/Toast/Toast.js +4 -2
- package/dist/astryx.css +10 -10
- package/dist/dragToSnapPoints/createDragToSnapPoints.d.ts +156 -0
- package/dist/dragToSnapPoints/createDragToSnapPoints.d.ts.map +1 -1
- package/dist/dragToSnapPoints/createDragToSnapPoints.js +313 -97
- package/dist/gestures/createPanGesture.d.ts +41 -0
- package/dist/gestures/createPanGesture.d.ts.map +1 -1
- package/dist/gestures/createPanGesture.js +66 -22
- package/dist/hooks/useMenuPress.d.ts.map +1 -1
- package/dist/hooks/useMenuPress.js +36 -2
- package/dist/i18n/generated-english/DateInput/NativeDateField.generated.d.ts.map +1 -1
- package/dist/i18n/generated-english/DateInput/NativeDateField.generated.js +0 -1
- package/dist/i18n/generated-english/DateTimeInput/NativeDateSegment.generated.d.ts.map +1 -1
- package/dist/i18n/generated-english/DateTimeInput/NativeDateSegment.generated.js +0 -1
- package/dist/i18n/generated-english/Table/plugins/infiniteScroll/useTableInfiniteScroll.generated.d.ts +8 -0
- package/dist/i18n/generated-english/Table/plugins/infiniteScroll/useTableInfiniteScroll.generated.d.ts.map +1 -0
- package/dist/i18n/generated-english/Table/plugins/infiniteScroll/useTableInfiniteScroll.generated.js +12 -0
- package/dist/i18n/generated-locales/en.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/en.generated.js +2 -0
- package/dist/i18n/generated-locales/pseudo.generated.d.ts.map +1 -1
- package/dist/i18n/generated-locales/pseudo.generated.js +2 -0
- package/dist/internal/touch.d.ts +1 -1
- package/dist/internal/touch.d.ts.map +1 -1
- package/dist/internal/touch.js +1 -1
- package/dist/motion/animator.d.ts +28 -1
- package/dist/motion/animator.d.ts.map +1 -1
- package/dist/motion/animator.js +99 -19
- package/dist/theme/generateThemeRules.d.ts.map +1 -1
- package/dist/theme/generateThemeRules.js +14 -3
- package/dist/theme/tokenReferences.d.ts +7 -15
- package/dist/theme/tokenReferences.d.ts.map +1 -1
- package/dist/theme/tokenReferences.js +49 -7
- package/dist/utils/clickGuard.d.ts +8 -1
- package/dist/utils/clickGuard.d.ts.map +1 -1
- package/dist/utils/clickGuard.js +24 -4
- package/dist/utils/themeProps.d.ts +8 -0
- package/dist/utils/themeProps.d.ts.map +1 -1
- package/dist/utils/themeProps.js +17 -0
- package/dist/utils/timeParser.d.ts +3 -1
- package/dist/utils/timeParser.d.ts.map +1 -1
- package/dist/utils/timeParser.js +7 -3
- package/dist/virtualization/listWindow.d.ts +18 -2
- package/dist/virtualization/listWindow.d.ts.map +1 -1
- package/dist/virtualization/listWindow.js +55 -2
- package/dist/virtualization/useInlineListWindow.d.ts +40 -0
- package/dist/virtualization/useInlineListWindow.d.ts.map +1 -0
- package/dist/virtualization/useInlineListWindow.js +58 -0
- package/locales/en.json +9 -1
- package/locales/pseudo.json +6 -0
- package/package.json +5 -5
- package/src/BottomSheet/BottomSheet.tsx +12 -8
- package/src/ButtonGroup/ButtonGroup.doc.mjs +5 -0
- package/src/CheckboxInput/CheckboxInput.doc.mjs +3 -0
- package/src/DateInput/DateInput.doc.mjs +3 -3
- package/src/DateInput/DateInput.tsx +27 -5
- package/src/DateInput/NativeDateField.tsx +58 -36
- package/src/DateInput/useTypedDate.ts +226 -55
- package/src/DateTimeInput/DateTimeInput.doc.mjs +3 -3
- package/src/DateTimeInput/DateTimeInput.tsx +38 -5
- package/src/DateTimeInput/NativeDateSegment.tsx +35 -13
- package/src/Field/InputClearButton.tsx +3 -1
- package/src/InfoTip/InfoTip.doc.mjs +2 -2
- package/src/InfoTip/InfoTip.tsx +3 -0
- package/src/Layer/layerAnimations.stylex.ts +13 -9
- package/src/Layer/layerEntranceSide.ts +48 -11
- package/src/Layer/useLayer.tsx +14 -12
- package/src/List/ListItem.tsx +3 -2
- package/src/List/ListReorderHandle.tsx +59 -77
- package/src/List/listReorderContext.ts +3 -4
- package/src/List/listReorderEngine.tsx +246 -11
- package/src/MoreMenu/MoreMenu.doc.mjs +2 -2
- package/src/MoreMenu/MoreMenu.tsx +3 -0
- package/src/NumberInput/NumberInput.doc.mjs +3 -0
- package/src/PowerSearch/PowerSearch.doc.mjs +2 -2
- package/src/PowerSearch/PowerSearch.tsx +7 -3
- package/src/PowerSearch/PowerSearchEditPopover.tsx +12 -2
- package/src/PowerSearch/PowerSearchFilterEditor.tsx +3 -0
- package/src/PowerSearch/PowerSearchToken.tsx +3 -0
- package/src/ProgressBar/ProgressBar.doc.mjs +3 -0
- package/src/SegmentedControl/SegmentedControl.doc.mjs +5 -0
- package/src/Selector/useSelectorPresentation.ts +16 -12
- package/src/Slider/Slider.tsx +6 -8
- package/src/StatusDot/StatusDot.doc.mjs +3 -0
- package/src/Switch/Switch.doc.mjs +3 -0
- package/src/TabList/TabList.doc.mjs +4 -0
- package/src/Table/BaseTable.tsx +406 -287
- package/src/Table/Table.doc.mjs +2 -2
- package/src/Table/Table.tsx +5 -1
- package/src/Table/index.ts +8 -1
- package/src/Table/plugins/infiniteScroll/index.ts +10 -0
- package/src/Table/plugins/infiniteScroll/useTableInfiniteScroll.tsx +523 -0
- package/src/Table/plugins/stickyColumns/useTableStickyColumns.tsx +31 -1
- package/src/Table/plugins/virtualization/TableColumnWindow.tsx +150 -0
- package/src/Table/plugins/virtualization/index.ts +3 -1
- package/src/Table/plugins/virtualization/useTableColumnWindow.ts +168 -0
- package/src/Table/plugins/virtualization/useTableColumnsVirtualization.ts +53 -0
- package/src/Table/tableColumnWindowing.ts +131 -0
- package/src/Table/tablePinnedColumnRuns.ts +55 -0
- package/src/Table/tableRuntime.ts +44 -11
- package/src/Table/types.ts +25 -2
- package/src/Table/useBaseTablePlugins.ts +2 -2
- package/src/Table/useTableColumnsVirtualization.doc.mjs +29 -0
- package/src/Table/useTableInfiniteScroll.doc.mjs +58 -0
- package/src/Text/Heading.doc.mjs +3 -0
- package/src/TextArea/TextArea.doc.mjs +15 -0
- package/src/TextArea/TextArea.tsx +11 -0
- package/src/TextInput/TextInput.doc.mjs +3 -0
- package/src/Toast/Toast.doc.mjs +2 -2
- package/src/Toast/Toast.tsx +3 -1
- package/src/TopNav/TopNav.doc.mjs +4 -0
- package/src/dragToSnapPoints/createDragToSnapPoints.ts +437 -119
- package/src/gestures/createPanGesture.ts +112 -39
- package/src/hooks/useMenuPress.ts +39 -0
- package/src/i18n/generated-english/DateInput/NativeDateField.generated.ts +0 -1
- package/src/i18n/generated-english/DateTimeInput/NativeDateSegment.generated.ts +0 -1
- package/src/i18n/generated-english/Table/plugins/infiniteScroll/useTableInfiniteScroll.generated.ts +13 -0
- package/src/i18n/generated-locales/en.generated.ts +2 -0
- package/src/i18n/generated-locales/pseudo.generated.ts +2 -0
- package/src/internal/touch.ts +5 -1
- package/src/motion/animator.ts +181 -23
- package/src/theme/generateThemeRules.ts +14 -3
- package/src/theme/tokenReferences.ts +48 -7
- package/src/utils/clickGuard.ts +30 -3
- package/src/utils/themeProps.ts +17 -0
- package/src/utils/timeParser.ts +7 -9
- package/src/virtualization/listWindow.ts +76 -2
- package/src/virtualization/useInlineListWindow.ts +119 -0
|
@@ -8,8 +8,9 @@
|
|
|
8
8
|
* calendarDateParser, and parseDateInput for other Gregorian text
|
|
9
9
|
* @output Typed-date reading, committed text, the format hint, the calendar
|
|
10
10
|
* description and rejection messages for a date text field, the typed
|
|
11
|
-
* entry state that DateInput and DateTimeInput share,
|
|
12
|
-
* DateInputEntryError that the field reports to its caller
|
|
11
|
+
* entry state that DateInput and DateTimeInput share, the
|
|
12
|
+
* DateInputEntryError that the field reports to its caller, and the
|
|
13
|
+
* rejection state of a native date control
|
|
13
14
|
* @position DateInput helper hook; used by DateInput and DateTimeInput
|
|
14
15
|
*/
|
|
15
16
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
@@ -36,12 +37,16 @@ function isSameEntryError(a, b) {
|
|
|
36
37
|
function isOutsideBounds(date, min, max) {
|
|
37
38
|
return min != null && plainDateIsBefore(date, plainDateFromISO(min)) || max != null && plainDateIsAfter(date, plainDateFromISO(max));
|
|
38
39
|
}
|
|
39
|
-
/**
|
|
40
|
+
/**
|
|
41
|
+
* The rejection a result shows: the error of a complete date, or of text that
|
|
42
|
+
* Enter or blur committed. Text that is not a date is never complete, so its
|
|
43
|
+
* error waits for the commit.
|
|
44
|
+
*/
|
|
40
45
|
export function typedDateError(result, isCommitted) {
|
|
41
46
|
if (result == null) {
|
|
42
47
|
return null;
|
|
43
48
|
}
|
|
44
|
-
if (result.kind === 'unreadable' || result.kind === 'incomplete' && isCommitted) {
|
|
49
|
+
if ((result.kind === 'unreadable' || result.kind === 'incomplete') && isCommitted) {
|
|
45
50
|
return 'unreadable';
|
|
46
51
|
}
|
|
47
52
|
if ((result.kind === 'nonexistent' || result.kind === 'outOfRange') && (result.isComplete || isCommitted)) {
|
|
@@ -50,6 +55,11 @@ export function typedDateError(result, isCommitted) {
|
|
|
50
55
|
return null;
|
|
51
56
|
}
|
|
52
57
|
|
|
58
|
+
/** Whether a result is a date that typing commits, which ends a rejection. */
|
|
59
|
+
function isAcceptedDate(result) {
|
|
60
|
+
return result.kind === 'value' && result.isComplete;
|
|
61
|
+
}
|
|
62
|
+
|
|
53
63
|
/** The rejection a result shows, as the field reports it to its caller. */
|
|
54
64
|
function dateEntryError(result, isCommitted, text, min, max) {
|
|
55
65
|
const error = typedDateError(result, isCommitted);
|
|
@@ -187,6 +197,9 @@ export function useTypedDateField({
|
|
|
187
197
|
const [pendingInput, setPendingInput] = useState(null);
|
|
188
198
|
// Set when Enter or blur keeps rejected text so the person can correct it.
|
|
189
199
|
const [isRejectionCommitted, setIsRejectionCommitted] = useState(false);
|
|
200
|
+
// Rejected text whose rejection stays shown while an edit leaves the entry
|
|
201
|
+
// rejected or unfinished.
|
|
202
|
+
const [keptText, setKeptText] = useState(null);
|
|
190
203
|
const [isFocused, setIsFocused] = useState(false);
|
|
191
204
|
// The date that typing last reported, so one typing session reports each
|
|
192
205
|
// date once. Only the handlers write it. A value from outside and a
|
|
@@ -199,17 +212,27 @@ export function useTypedDateField({
|
|
|
199
212
|
const [firedEpoch, setFiredEpoch] = useState(0);
|
|
200
213
|
const lastFiredDate = lastFired.epoch === firedEpoch ? lastFired.date : undefined;
|
|
201
214
|
const typedResult = pendingInput !== null && pendingInput.trim() ? typedDate.parse(pendingInput) : null;
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
215
|
+
const ownError = typedDateError(typedResult, isRejectionCommitted);
|
|
216
|
+
const keptResult = ownError == null && keptText !== null && typedResult != null && !isAcceptedDate(typedResult) ? typedDate.parse(keptText) : null;
|
|
217
|
+
// The rejection the field shows. A locked field hides it but keeps its
|
|
218
|
+
// state, so the rejection shows again once the field is editable.
|
|
219
|
+
const shown = isDisabled ? null : ownError != null && typedResult != null && pendingInput !== null ? {
|
|
220
|
+
text: pendingInput,
|
|
221
|
+
result: typedResult
|
|
222
|
+
} : keptResult != null && keptText !== null && typedDateError(keptResult, true) != null ? {
|
|
223
|
+
text: keptText,
|
|
224
|
+
result: keptResult
|
|
225
|
+
} : null;
|
|
226
|
+
const errorMessage = shown != null ? typedDate.errorMessage(shown.result) : null;
|
|
227
|
+
const typedStatus = errorMessage != null ? {
|
|
209
228
|
type: 'error',
|
|
210
229
|
message: errorMessage
|
|
211
230
|
} : undefined;
|
|
212
|
-
const entryError =
|
|
231
|
+
const entryError = shown != null ? dateEntryError(shown.result, true, shown.text, options.min, options.max) : null;
|
|
232
|
+
const shownText = shown?.text ?? null;
|
|
233
|
+
// Unreadable text that Enter or blur kept: the form posts the committed
|
|
234
|
+
// date, as it does where the text gives way to it.
|
|
235
|
+
const isKeptUnreadable = isRejectionCommitted && typedResult?.kind === 'unreadable';
|
|
213
236
|
|
|
214
237
|
// The rejection that the caller last received. Handlers report a rejection
|
|
215
238
|
// that they cause in the same update. A rejection that a prop change causes
|
|
@@ -264,7 +287,7 @@ export function useTypedDateField({
|
|
|
264
287
|
// Inside an InputGroup no Field announces the caller's status.
|
|
265
288
|
alertMessage = !isStatusAnnounced || isStatusRepeated ? callerErrorMessage : '';
|
|
266
289
|
} else {
|
|
267
|
-
alertMessage = isStatusAnnounced
|
|
290
|
+
alertMessage = isStatusAnnounced ? '' : errorMessage;
|
|
268
291
|
}
|
|
269
292
|
}
|
|
270
293
|
const reportEntryError = useCallback(error => {
|
|
@@ -309,6 +332,7 @@ export function useTypedDateField({
|
|
|
309
332
|
const reset = useCallback(() => {
|
|
310
333
|
setPendingInput(null);
|
|
311
334
|
setIsRejectionCommitted(false);
|
|
335
|
+
setKeptText(null);
|
|
312
336
|
reportEntryError(null);
|
|
313
337
|
}, [reportEntryError]);
|
|
314
338
|
|
|
@@ -323,6 +347,7 @@ export function useTypedDateField({
|
|
|
323
347
|
if (pendingInput !== null) {
|
|
324
348
|
setPendingInput(null);
|
|
325
349
|
setIsRejectionCommitted(false);
|
|
350
|
+
setKeptText(null);
|
|
326
351
|
}
|
|
327
352
|
}
|
|
328
353
|
}
|
|
@@ -337,6 +362,7 @@ export function useTypedDateField({
|
|
|
337
362
|
setFiredEpoch(epoch => epoch + 1);
|
|
338
363
|
setPendingInput(null);
|
|
339
364
|
setIsRejectionCommitted(false);
|
|
365
|
+
setKeptText(null);
|
|
340
366
|
}
|
|
341
367
|
}
|
|
342
368
|
const report = useCallback(date => {
|
|
@@ -354,18 +380,24 @@ export function useTypedDateField({
|
|
|
354
380
|
if (isDisabled) {
|
|
355
381
|
return;
|
|
356
382
|
}
|
|
357
|
-
setPendingInput(text);
|
|
358
|
-
setIsRejectionCommitted(false);
|
|
359
383
|
// Report a date only once more typing cannot change it.
|
|
360
384
|
const result = typedDate.parse(text);
|
|
361
|
-
|
|
385
|
+
const isEmpty = !text.trim();
|
|
386
|
+
const error = isEmpty ? null : dateEntryError(result, false, text, options.min, options.max);
|
|
387
|
+
// An edit that leaves the entry rejected or unfinished keeps the shown
|
|
388
|
+
// rejection.
|
|
389
|
+
const nextKeptText = error != null || isEmpty || isAcceptedDate(result) ? null : shownText;
|
|
390
|
+
setPendingInput(text);
|
|
391
|
+
setIsRejectionCommitted(false);
|
|
392
|
+
setKeptText(nextKeptText);
|
|
393
|
+
reportEntryError(error ?? (nextKeptText !== null ? entryError : null));
|
|
362
394
|
if (result.kind === 'value' && result.isComplete) {
|
|
363
395
|
const date = plainDateToISO(result.date);
|
|
364
396
|
if (report(date)) {
|
|
365
397
|
onTypedDate?.(date);
|
|
366
398
|
}
|
|
367
399
|
}
|
|
368
|
-
}, [isDisabled, typedDate, reportEntryError, options.min, options.max, report, onTypedDate]);
|
|
400
|
+
}, [isDisabled, typedDate, shownText, entryError, reportEntryError, options.min, options.max, report, onTypedDate]);
|
|
369
401
|
const commit = useCallback(() => {
|
|
370
402
|
if (pendingInput === null || isDisabled) {
|
|
371
403
|
return;
|
|
@@ -376,10 +408,11 @@ export function useTypedDateField({
|
|
|
376
408
|
return;
|
|
377
409
|
}
|
|
378
410
|
const result = typedDate.parse(pendingInput);
|
|
379
|
-
if (result.kind === 'incomplete' || result.kind === 'nonexistent' || result.kind === 'outOfRange') {
|
|
411
|
+
if (result.kind === 'unreadable' || result.kind === 'incomplete' || result.kind === 'nonexistent' || result.kind === 'outOfRange') {
|
|
380
412
|
// Keep the text and show why it cannot commit; never finish or adjust
|
|
381
413
|
// the date.
|
|
382
414
|
setIsRejectionCommitted(true);
|
|
415
|
+
setKeptText(null);
|
|
383
416
|
reportEntryError(dateEntryError(result, true, pendingInput, options.min, options.max));
|
|
384
417
|
return;
|
|
385
418
|
}
|
|
@@ -401,13 +434,15 @@ export function useTypedDateField({
|
|
|
401
434
|
setIsFocused(false);
|
|
402
435
|
commit();
|
|
403
436
|
}, [commit]);
|
|
404
|
-
const
|
|
437
|
+
const committedText = shownValue != null && /^\d{4}-\d{2}-\d{2}$/.test(shownValue) ? typedDate.formatCommitted(shownValue) : '';
|
|
438
|
+
const displayValue = pendingInput ?? committedText;
|
|
405
439
|
return {
|
|
406
440
|
typedDate,
|
|
407
441
|
displayValue,
|
|
408
442
|
formatHint: !hasPlaceholder && isFocused && !displayValue ? typedDate.getFormatHint() : null,
|
|
409
|
-
isPending: pendingInput !== null,
|
|
410
|
-
|
|
443
|
+
isPending: pendingInput !== null && !isKeptUnreadable,
|
|
444
|
+
hiddenFormValue: isKeptUnreadable ? committedText : null,
|
|
445
|
+
isInvalid: shown != null,
|
|
411
446
|
fieldStatus,
|
|
412
447
|
alertMessage,
|
|
413
448
|
handleChange,
|
|
@@ -416,4 +451,99 @@ export function useTypedDateField({
|
|
|
416
451
|
handleBlur,
|
|
417
452
|
reset
|
|
418
453
|
};
|
|
454
|
+
}
|
|
455
|
+
const NO_REFUSAL = {
|
|
456
|
+
held: null,
|
|
457
|
+
shown: null
|
|
458
|
+
};
|
|
459
|
+
|
|
460
|
+
/**
|
|
461
|
+
* The rejection of a native date control. While a person types the year, the
|
|
462
|
+
* control reports each partial year as a date, so a refused date waits for
|
|
463
|
+
* Enter or blur. The rejection then stays after the control restores the
|
|
464
|
+
* committed date, until the control reports a date the field accepts or
|
|
465
|
+
* nothing.
|
|
466
|
+
*/
|
|
467
|
+
export function useNativeDateRejection({
|
|
468
|
+
value,
|
|
469
|
+
isLocked,
|
|
470
|
+
status,
|
|
471
|
+
hasEntryErrorCallback,
|
|
472
|
+
isStatusAnnounced,
|
|
473
|
+
...options
|
|
474
|
+
}) {
|
|
475
|
+
const typedDate = useTypedDate({
|
|
476
|
+
...options,
|
|
477
|
+
calendar: 'gregory'
|
|
478
|
+
});
|
|
479
|
+
const [refusal, setRefusal] = useState(NO_REFUSAL);
|
|
480
|
+
const [prevValue, setPrevValue] = useState(value);
|
|
481
|
+
if (value !== prevValue) {
|
|
482
|
+
setPrevValue(value);
|
|
483
|
+
if (refusal !== NO_REFUSAL) {
|
|
484
|
+
setRefusal(NO_REFUSAL);
|
|
485
|
+
}
|
|
486
|
+
}
|
|
487
|
+
const refuse = useCallback(date => {
|
|
488
|
+
const held = plainDateToISO(date);
|
|
489
|
+
setRefusal(prev => prev.held === held ? prev : {
|
|
490
|
+
...prev,
|
|
491
|
+
held
|
|
492
|
+
});
|
|
493
|
+
}, []);
|
|
494
|
+
const clear = useCallback(() => setRefusal(NO_REFUSAL), []);
|
|
495
|
+
const commit = useCallback(() => {
|
|
496
|
+
if (!isLocked) {
|
|
497
|
+
setRefusal(prev => prev.held === null ? prev : {
|
|
498
|
+
held: null,
|
|
499
|
+
shown: prev.held
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
}, [isLocked]);
|
|
503
|
+
const message = !isLocked && refusal.shown !== null ? typedDate.errorMessage({
|
|
504
|
+
kind: 'outOfRange',
|
|
505
|
+
date: plainDateFromISO(refusal.shown),
|
|
506
|
+
isComplete: true
|
|
507
|
+
}) : null;
|
|
508
|
+
const callerErrorMessage = hasEntryErrorCallback && status?.type === 'error' && status.message ? status.message : null;
|
|
509
|
+
|
|
510
|
+
// A rejection that starts under the caller's error message changes no
|
|
511
|
+
// status, so the alert announces that message once. A later change of the
|
|
512
|
+
// caller's message ends the repeat, because Field announces the change.
|
|
513
|
+
const isRejected = message != null;
|
|
514
|
+
const [repeat, setRepeat] = useState({
|
|
515
|
+
isRejected: false,
|
|
516
|
+
message: null
|
|
517
|
+
});
|
|
518
|
+
if (repeat.isRejected !== isRejected) {
|
|
519
|
+
setRepeat({
|
|
520
|
+
isRejected,
|
|
521
|
+
message: isRejected ? callerErrorMessage : null
|
|
522
|
+
});
|
|
523
|
+
} else if (repeat.message !== null && repeat.message !== callerErrorMessage) {
|
|
524
|
+
setRepeat({
|
|
525
|
+
isRejected,
|
|
526
|
+
message: null
|
|
527
|
+
});
|
|
528
|
+
}
|
|
529
|
+
let alertMessage = '';
|
|
530
|
+
if (message != null) {
|
|
531
|
+
if (!isStatusAnnounced) {
|
|
532
|
+
alertMessage = callerErrorMessage ?? message;
|
|
533
|
+
} else if (callerErrorMessage != null && callerErrorMessage === repeat.message) {
|
|
534
|
+
alertMessage = callerErrorMessage;
|
|
535
|
+
}
|
|
536
|
+
}
|
|
537
|
+
return {
|
|
538
|
+
message,
|
|
539
|
+
fieldStatus: message != null && callerErrorMessage == null ? {
|
|
540
|
+
type: 'error',
|
|
541
|
+
message
|
|
542
|
+
} : status,
|
|
543
|
+
alertMessage,
|
|
544
|
+
isRefused: refusal !== NO_REFUSAL,
|
|
545
|
+
refuse,
|
|
546
|
+
clear,
|
|
547
|
+
commit
|
|
548
|
+
};
|
|
419
549
|
}
|
|
@@ -192,9 +192,9 @@ export interface DateTimeInputProps extends Omit<FieldInputBaseProps<HTMLInputEl
|
|
|
192
192
|
/**
|
|
193
193
|
* Status indicator for the input.
|
|
194
194
|
*
|
|
195
|
-
* For a
|
|
196
|
-
*
|
|
197
|
-
*
|
|
195
|
+
* For a date the date segment rejects, typed or picked in the native
|
|
196
|
+
* control, and for unreadable or unfinished date text that Enter or blur
|
|
197
|
+
* keeps, the field shows its own error message in place of `status`. With
|
|
198
198
|
* `onEntryErrorChange`, an `error` status with a message shows instead, and
|
|
199
199
|
* the field's own message applies only without one. A `warning` or
|
|
200
200
|
* `success` status never replaces a rejection.
|
|
@@ -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;AAE5D,OAAO,EACL,KAAK,mBAAmB,
|
|
1
|
+
{"version":3,"file":"DateTimeInput.d.ts","sourceRoot":"","sources":["../../src/DateTimeInput/DateTimeInput.tsx"],"names":[],"mappings":"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"}
|
|
@@ -40,7 +40,7 @@ import { parseISOTime, formatISOTime, isTimeInRange, adjustTime, isImeKeyEvent,
|
|
|
40
40
|
import { chainEventHandlers } from "../utils/chainEventHandlers.js";
|
|
41
41
|
import { joinAriaIDs } from "../utils/inputAria.js";
|
|
42
42
|
import { isRenderable } from "../utils/isRenderable.js";
|
|
43
|
-
import { useTypedDateField } from "../DateInput/useTypedDate.js";
|
|
43
|
+
import { useNativeDateRejection, useTypedDateField } from "../DateInput/useTypedDate.js";
|
|
44
44
|
import { useFieldInputStyling } from "../Field/fieldParts.js";
|
|
45
45
|
import { useAnnounce } from "../hooks/useAnnounce.js";
|
|
46
46
|
import { useMediaQuery } from "../hooks/useMediaQuery.js";
|
|
@@ -286,6 +286,8 @@ function PointerDateTimeField({
|
|
|
286
286
|
onKeyDown: onKeyDownProp,
|
|
287
287
|
...controlProps
|
|
288
288
|
} = rest;
|
|
289
|
+
// Form attributes pass through untyped, as other input attributes do.
|
|
290
|
+
const formControl = controlProps;
|
|
289
291
|
const t = useComponentTranslator();
|
|
290
292
|
const locale = useLocale();
|
|
291
293
|
const usesNativePicker = nativeMode !== 'off';
|
|
@@ -541,8 +543,9 @@ function PointerDateTimeField({
|
|
|
541
543
|
displayValue: dateDisplayValue,
|
|
542
544
|
formatHint: dateFormatHint,
|
|
543
545
|
isPending: isDatePending,
|
|
546
|
+
hiddenFormValue,
|
|
544
547
|
isInvalid: isDateInvalid,
|
|
545
|
-
fieldStatus,
|
|
548
|
+
fieldStatus: typedFieldStatus,
|
|
546
549
|
alertMessage: dateAlertMessage,
|
|
547
550
|
handleChange: handleTypedDateInput,
|
|
548
551
|
commit: commitDatePendingInput,
|
|
@@ -569,6 +572,19 @@ function PointerDateTimeField({
|
|
|
569
572
|
onEntryErrorChange,
|
|
570
573
|
hasPlaceholder: placeholderFromProps != null
|
|
571
574
|
});
|
|
575
|
+
const nativeDateRejection = useNativeDateRejection({
|
|
576
|
+
source: 'DateTimeInput',
|
|
577
|
+
format: 'date_long',
|
|
578
|
+
min: calendarMin,
|
|
579
|
+
max: calendarMax,
|
|
580
|
+
isDateDisabled,
|
|
581
|
+
value: valueParts.date,
|
|
582
|
+
isLocked: isEffectivelyDisabled || isBusy,
|
|
583
|
+
status,
|
|
584
|
+
hasEntryErrorCallback: onEntryErrorChange != null,
|
|
585
|
+
isStatusAnnounced: true
|
|
586
|
+
});
|
|
587
|
+
const fieldStatus = usesNativePicker ? nativeDateRejection.fieldStatus : typedFieldStatus;
|
|
572
588
|
|
|
573
589
|
// The detached message box carries its own glyph, so the helper shows no
|
|
574
590
|
// on-field icon.
|
|
@@ -1090,7 +1106,8 @@ function PointerDateTimeField({
|
|
|
1090
1106
|
isFocusableDisabled: true,
|
|
1091
1107
|
isEffectivelyRequired: isEffectivelyRequired,
|
|
1092
1108
|
isBusy: isBusy,
|
|
1093
|
-
statusType:
|
|
1109
|
+
statusType: fieldStatus?.type,
|
|
1110
|
+
rejection: nativeDateRejection,
|
|
1094
1111
|
ariaDescribedBy: ariaDescribedBy,
|
|
1095
1112
|
controlProps: {
|
|
1096
1113
|
...controlProps,
|
|
@@ -1127,6 +1144,7 @@ function PointerDateTimeField({
|
|
|
1127
1144
|
})
|
|
1128
1145
|
}), /*#__PURE__*/_jsx("input", {
|
|
1129
1146
|
...controlProps,
|
|
1147
|
+
name: hiddenFormValue === null ? formControl.name : undefined,
|
|
1130
1148
|
ref: mergedDateInputRef,
|
|
1131
1149
|
id: dateInputId,
|
|
1132
1150
|
type: "text",
|
|
@@ -1164,6 +1182,11 @@ function PointerDateTimeField({
|
|
|
1164
1182
|
className: "x1lliihq x98rzlu xeuugli xc342km xng3xce x1717udv x9ynric xjm74w1 xf9zqsd xw6l6zx xjbqb8w x1a2a7pz xeyghm5 xt0e3qv xv1l7n4"
|
|
1165
1183
|
}
|
|
1166
1184
|
}[!!isEffectivelyDisabled << 1 | !!isDateInvalid << 0]
|
|
1185
|
+
}), hiddenFormValue !== null && formControl.name != null && /*#__PURE__*/_jsx("input", {
|
|
1186
|
+
type: "hidden",
|
|
1187
|
+
name: formControl.name,
|
|
1188
|
+
form: formControl.form,
|
|
1189
|
+
value: hiddenFormValue
|
|
1167
1190
|
}), /*#__PURE__*/_jsx(VisuallyHidden, {
|
|
1168
1191
|
as: "div",
|
|
1169
1192
|
role: "alert",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { FieldInputBaseProps, FieldPartStyleProps } from '../Field/fieldParts.js';
|
|
2
|
+
import type { NativeDateRejection } from '../DateInput/useTypedDate.js';
|
|
2
3
|
import { plainDateFromISO, type ISODateString } from '../utils/index.js';
|
|
3
4
|
import type { InputStatusType } from '../Field/index.js';
|
|
4
5
|
export type NativeDateSegmentProps = {
|
|
@@ -15,7 +16,13 @@ export type NativeDateSegmentProps = {
|
|
|
15
16
|
isFocusableDisabled: boolean;
|
|
16
17
|
isEffectivelyRequired: boolean;
|
|
17
18
|
isBusy: boolean;
|
|
19
|
+
/** The field's status type, which a shown rejection makes `error`. */
|
|
18
20
|
statusType?: InputStatusType;
|
|
21
|
+
/**
|
|
22
|
+
* The rejection of a refused date. DateTimeInput shows its status as the
|
|
23
|
+
* field status.
|
|
24
|
+
*/
|
|
25
|
+
rejection: NativeDateRejection;
|
|
19
26
|
ariaDescribedBy?: string;
|
|
20
27
|
/**
|
|
21
28
|
* The caller's base props (data-*, aria-*, DOM handlers, …) for the native
|
|
@@ -25,7 +32,7 @@ export type NativeDateSegmentProps = {
|
|
|
25
32
|
controlProps?: Omit<FieldInputBaseProps<HTMLInputElement>, keyof FieldPartStyleProps | 'onChange' | 'defaultValue'>;
|
|
26
33
|
};
|
|
27
34
|
/** The native date half rendered inside DateTimeInput's date wrapper. */
|
|
28
|
-
export declare function NativeDateSegment({ id, inputRef, value, onChange, placeholder, min, max, isDateDisabled, isEffectivelyDisabled, isFocusableDisabled, isEffectivelyRequired, isBusy, statusType, ariaDescribedBy, controlProps, }: NativeDateSegmentProps): import("react").JSX.Element;
|
|
35
|
+
export declare function NativeDateSegment({ id, inputRef, value, onChange, placeholder, min, max, isDateDisabled, isEffectivelyDisabled, isFocusableDisabled, isEffectivelyRequired, isBusy, statusType, rejection, ariaDescribedBy, controlProps, }: NativeDateSegmentProps): import("react").JSX.Element;
|
|
29
36
|
export declare namespace NativeDateSegment {
|
|
30
37
|
var displayName: string;
|
|
31
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NativeDateSegment.d.ts","sourceRoot":"","sources":["../../src/DateTimeInput/NativeDateSegment.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"NativeDateSegment.d.ts","sourceRoot":"","sources":["../../src/DateTimeInput/NativeDateSegment.tsx"],"names":[],"mappings":"AA4BA,OAAO,KAAK,EACV,mBAAmB,EACnB,mBAAmB,EACpB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,KAAK,EAAC,mBAAmB,EAAC,MAAM,2BAA2B,CAAC;AAMnE,OAAO,EAIL,gBAAgB,EAGhB,KAAK,aAAa,EACnB,MAAM,UAAU,CAAC;AAElB,OAAO,KAAK,EAAC,eAAe,EAAC,MAAM,UAAU,CAAC;AAY9C,MAAM,MAAM,sBAAsB,GAAG;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,KAAK,CAAC,GAAG,CAAC,gBAAgB,CAAC,CAAC;IACtC,KAAK,CAAC,EAAE,aAAa,CAAC;IACtB,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,GAAG,SAAS,KAAK,IAAI,CAAC;IACrD,WAAW,EAAE,MAAM,CAAC;IACpB,GAAG,CAAC,EAAE,aAAa,CAAC;IACpB,GAAG,CAAC,EAAE,aAAa,CAAC;IACpB,cAAc,EAAE,CAAC,IAAI,EAAE,UAAU,CAAC,OAAO,gBAAgB,CAAC,KAAK,OAAO,CAAC;IACvE,qBAAqB,EAAE,OAAO,CAAC;IAC/B,kFAAkF;IAClF,mBAAmB,EAAE,OAAO,CAAC;IAC7B,qBAAqB,EAAE,OAAO,CAAC;IAC/B,MAAM,EAAE,OAAO,CAAC;IAChB,sEAAsE;IACtE,UAAU,CAAC,EAAE,eAAe,CAAC;IAC7B;;;OAGG;IACH,SAAS,EAAE,mBAAmB,CAAC;IAC/B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;;;OAIG;IACH,YAAY,CAAC,EAAE,IAAI,CACjB,mBAAmB,CAAC,gBAAgB,CAAC,EACrC,MAAM,mBAAmB,GAAG,UAAU,GAAG,cAAc,CACxD,CAAC;CACH,CAAC;AAEF,yEAAyE;AACzE,wBAAgB,iBAAiB,CAAC,EAChC,EAAE,EACF,QAAQ,EACR,KAAK,EACL,QAAQ,EACR,WAAW,EACX,GAAG,EACH,GAAG,EACH,cAAc,EACd,qBAAqB,EACrB,mBAAmB,EACnB,qBAAqB,EACrB,MAAM,EACN,UAAU,EACV,SAAS,EACT,eAAe,EACf,YAAY,GACb,EAAE,sBAAsB,+BAwQxB;yBAzRe,iBAAiB"}
|
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
/**
|
|
6
6
|
* @file NativeDateSegment.tsx
|
|
7
7
|
* @input Uses React, Icon, nativeDateSegments, and DateTimeInput's date state
|
|
8
|
+
* and native date rejection
|
|
8
9
|
* @output Exports NativeDateSegment — the OS-picker date half of DateTimeInput
|
|
9
10
|
* @position Internal DateTimeInput surface selected by `nativePicker`
|
|
10
11
|
*
|
|
@@ -53,12 +54,14 @@ export function NativeDateSegment({
|
|
|
53
54
|
isEffectivelyRequired,
|
|
54
55
|
isBusy,
|
|
55
56
|
statusType,
|
|
57
|
+
rejection,
|
|
56
58
|
ariaDescribedBy,
|
|
57
59
|
controlProps
|
|
58
60
|
}) {
|
|
59
61
|
const {
|
|
60
62
|
onFocus: onFocusProp,
|
|
61
63
|
onBlur: onBlurProp,
|
|
64
|
+
onKeyDown: onKeyDownProp,
|
|
62
65
|
...inputProps
|
|
63
66
|
} = controlProps ?? {};
|
|
64
67
|
const t = useComponentTranslator();
|
|
@@ -66,7 +69,6 @@ export function NativeDateSegment({
|
|
|
66
69
|
const isTouchPointer = useMediaQuery('(pointer: coarse)');
|
|
67
70
|
const internalInputRef = useRef(null);
|
|
68
71
|
const mergedInputRef = useMergedRefs(inputRef, internalInputRef);
|
|
69
|
-
const [rejectedValue, setRejectedValue] = useState(null);
|
|
70
72
|
const [isFocused, setIsFocused] = useState(false);
|
|
71
73
|
const [isSegmentEditable, setIsSegmentEditable] = useState(false);
|
|
72
74
|
const valueAtFocusRef = useRef(null);
|
|
@@ -87,12 +89,9 @@ export function NativeDateSegment({
|
|
|
87
89
|
if (!isFocused) {
|
|
88
90
|
setCommitEpoch(epoch => epoch + 1);
|
|
89
91
|
}
|
|
90
|
-
if (rejectedValue !== null) {
|
|
91
|
-
setRejectedValue(null);
|
|
92
|
-
}
|
|
93
92
|
}
|
|
94
93
|
const nativeValue = value && ISO_DATE.test(value) ? value : '';
|
|
95
|
-
const isInputValid =
|
|
94
|
+
const isInputValid = rejection.message == null;
|
|
96
95
|
const overlayText = nativeValue ? formatSharedDate(plainDateFromISO(nativeValue), 'date_long', locale) : placeholder;
|
|
97
96
|
const showsOverlay = !!overlayText && !(isFocused && isSegmentEditable);
|
|
98
97
|
const commitValue = useCallback(newValue => {
|
|
@@ -108,7 +107,7 @@ export function NativeDateSegment({
|
|
|
108
107
|
text: newValue,
|
|
109
108
|
epoch: commitEpoch
|
|
110
109
|
};
|
|
111
|
-
|
|
110
|
+
rejection.clear();
|
|
112
111
|
if (value !== undefined) {
|
|
113
112
|
onChange(undefined);
|
|
114
113
|
}
|
|
@@ -119,10 +118,10 @@ export function NativeDateSegment({
|
|
|
119
118
|
return;
|
|
120
119
|
}
|
|
121
120
|
if (isDateDisabled(parsed)) {
|
|
122
|
-
|
|
121
|
+
rejection.refuse(parsed);
|
|
123
122
|
return;
|
|
124
123
|
}
|
|
125
|
-
|
|
124
|
+
rejection.clear();
|
|
126
125
|
lastCommitRef.current = {
|
|
127
126
|
text: newValue,
|
|
128
127
|
epoch: commitEpoch
|
|
@@ -131,7 +130,7 @@ export function NativeDateSegment({
|
|
|
131
130
|
if (parsedISO !== value) {
|
|
132
131
|
onChange(parsedISO);
|
|
133
132
|
}
|
|
134
|
-
}, [commitEpoch, isDateDisabled, isEffectivelyDisabled, locale, onChange, value]);
|
|
133
|
+
}, [commitEpoch, isDateDisabled, isEffectivelyDisabled, locale, onChange, rejection, value]);
|
|
135
134
|
const handleChange = useCallback(event => {
|
|
136
135
|
commitValue(event.target.value);
|
|
137
136
|
}, [commitValue]);
|
|
@@ -178,15 +177,21 @@ export function NativeDateSegment({
|
|
|
178
177
|
const handleBlur = useCallback(() => {
|
|
179
178
|
const domValue = internalInputRef.current?.value;
|
|
180
179
|
const valueChangedWhileFocused = valueAtFocusRef.current !== null && valueAtFocusRef.current !== nativeValue;
|
|
181
|
-
const wasRejected = rejectedValue !== null;
|
|
182
180
|
valueAtFocusRef.current = null;
|
|
183
181
|
setIsFocused(false);
|
|
184
|
-
|
|
185
|
-
if (!valueChangedWhileFocused && !wasRejected && domValue !== undefined && domValue !== nativeValue) {
|
|
182
|
+
if (!valueChangedWhileFocused && !rejection.isRefused && domValue !== undefined && domValue !== nativeValue) {
|
|
186
183
|
commitValue(domValue);
|
|
187
184
|
}
|
|
188
185
|
lastCommitRef.current = null;
|
|
189
|
-
|
|
186
|
+
// The sync effect restores the committed date once focus leaves. The
|
|
187
|
+
// rejection stays shown, so the restore is never silent.
|
|
188
|
+
rejection.commit();
|
|
189
|
+
}, [commitValue, nativeValue, rejection]);
|
|
190
|
+
const handleKeyDown = useCallback(e => {
|
|
191
|
+
if (e.key === 'Enter') {
|
|
192
|
+
rejection.commit();
|
|
193
|
+
}
|
|
194
|
+
}, [rejection]);
|
|
190
195
|
const openPicker = useCallback(() => {
|
|
191
196
|
if (isEffectivelyDisabled) {
|
|
192
197
|
return;
|
|
@@ -234,6 +239,7 @@ export function NativeDateSegment({
|
|
|
234
239
|
onChange: handleChange,
|
|
235
240
|
onFocus: chainEventHandlers(handleFocus, onFocusProp),
|
|
236
241
|
onBlur: chainEventHandlers(handleBlur, onBlurProp),
|
|
242
|
+
onKeyDown: chainEventHandlers(handleKeyDown, onKeyDownProp),
|
|
237
243
|
min: min,
|
|
238
244
|
max: max,
|
|
239
245
|
disabled: isEffectivelyDisabled && !isFocusableDisabled,
|
|
@@ -253,7 +259,7 @@ export function NativeDateSegment({
|
|
|
253
259
|
as: "div",
|
|
254
260
|
role: "alert",
|
|
255
261
|
"aria-live": "assertive",
|
|
256
|
-
children:
|
|
262
|
+
children: rejection.alertMessage
|
|
257
263
|
})]
|
|
258
264
|
});
|
|
259
265
|
}
|
|
@@ -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;
|
|
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;AA8DD,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,SAAS,CAMxE;yBANe,gBAAgB;;;AAQhC;;;GAGG;AACH,wBAAgB,wBAAwB,CACtC,KAAK,EAAE,6BAA6B,GACnC,SAAS,CAMX"}
|
|
@@ -20,7 +20,7 @@ import { Button } from "../Button/Button.js";
|
|
|
20
20
|
import { BUTTON_HIT_AREA, ButtonHitAreaContext } from "../Button/buttonHitArea.js";
|
|
21
21
|
import { clampedHitInsets } from "../utils/hitArea.js";
|
|
22
22
|
import { Icon } from "../Icon/Icon.js";
|
|
23
|
-
import { themeProps } from "../utils/themeProps.js";
|
|
23
|
+
import { pickDataAttributes, themeProps } from "../utils/themeProps.js";
|
|
24
24
|
import { registerEnglishFallback, useComponentTranslator } from "../i18n/useComponentTranslator.js";
|
|
25
25
|
import english from "../i18n/generated-english/Field/InputClearButton.generated.js";
|
|
26
26
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -85,7 +85,8 @@ function renderInputClearButton({
|
|
|
85
85
|
onPointerDown,
|
|
86
86
|
onClickCapture,
|
|
87
87
|
xstyle,
|
|
88
|
-
iconClassName
|
|
88
|
+
iconClassName,
|
|
89
|
+
...rest
|
|
89
90
|
}) {
|
|
90
91
|
const {
|
|
91
92
|
className: iconTargetClassName
|
|
@@ -96,6 +97,7 @@ function renderInputClearButton({
|
|
|
96
97
|
return /*#__PURE__*/_jsx(ButtonHitAreaContext, {
|
|
97
98
|
value: CLEAR_BUTTON_HIT_AREA,
|
|
98
99
|
children: /*#__PURE__*/_jsx(Button, {
|
|
100
|
+
...pickDataAttributes(rest),
|
|
99
101
|
variant: "ghost",
|
|
100
102
|
size: "sm",
|
|
101
103
|
label: label
|
|
@@ -57,7 +57,7 @@ export interface InfoTipProps extends Pick<BaseProps, 'xstyle' | 'className' | '
|
|
|
57
57
|
* <InfoTip content="30-day rolling average." label="About this metric" />
|
|
58
58
|
* ```
|
|
59
59
|
*/
|
|
60
|
-
export declare function InfoTip({ content, label, size, ref, xstyle, className, style, }: InfoTipProps): ReactNode;
|
|
60
|
+
export declare function InfoTip({ content, label, size, ref, xstyle, className, style, ...rest }: InfoTipProps): ReactNode;
|
|
61
61
|
export declare namespace InfoTip {
|
|
62
62
|
var displayName: string;
|
|
63
63
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InfoTip.d.ts","sourceRoot":"","sources":["../../src/InfoTip/InfoTip.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAKL,KAAK,SAAS,EACd,KAAK,GAAG,EACT,MAAM,OAAO,CAAC;AAGf,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAO,KAAK,QAAQ,EAAC,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"InfoTip.d.ts","sourceRoot":"","sources":["../../src/InfoTip/InfoTip.tsx"],"names":[],"mappings":"AAIA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,EAKL,KAAK,SAAS,EACd,KAAK,GAAG,EACT,MAAM,OAAO,CAAC;AAGf,OAAO,KAAK,EAAC,SAAS,EAAC,MAAM,cAAc,CAAC;AAE5C,OAAO,EAAO,KAAK,QAAQ,EAAC,MAAM,cAAc,CAAC;AAuBjD;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG,QAAQ,CAAC;AAEnC,MAAM,WAAW,YAAa,SAAQ,IAAI,CACxC,SAAS,EACT,QAAQ,GAAG,WAAW,GAAG,OAAO,CACjC;IACC,wCAAwC;IACxC,GAAG,CAAC,EAAE,GAAG,CAAC,iBAAiB,CAAC,CAAC;IAC7B;;;OAGG;IACH,OAAO,EAAE,SAAS,CAAC;IACnB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,IAAI,CAAC,EAAE,WAAW,CAAC;CACpB;AA+BD;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,OAAO,CAAC,EACtB,OAAO,EACP,KAAK,EACL,IAAW,EACX,GAAG,EACH,MAAM,EACN,SAAS,EACT,KAAK,EACL,GAAG,IAAI,EACR,EAAE,YAAY,GAAG,SAAS,CAkF1B;yBA3Fe,OAAO"}
|
package/dist/InfoTip/InfoTip.js
CHANGED
|
@@ -31,6 +31,7 @@ import { focusOutlineStyles } from "../utils/focusOutline.stylex.js";
|
|
|
31
31
|
import { mergeProps } from "../utils/mergeProps.js";
|
|
32
32
|
import { useTouchHitArea } from "../utils/touchHitArea.js";
|
|
33
33
|
import { touchHitAreaStyles } from "../internal/touchHitArea.stylex.js";
|
|
34
|
+
import { pickDataAttributes } from "../utils/themeProps.js";
|
|
34
35
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
35
36
|
registerEnglishFallback(english);
|
|
36
37
|
|
|
@@ -84,7 +85,8 @@ export function InfoTip({
|
|
|
84
85
|
ref,
|
|
85
86
|
xstyle,
|
|
86
87
|
className,
|
|
87
|
-
style
|
|
88
|
+
style,
|
|
89
|
+
...rest
|
|
88
90
|
}) {
|
|
89
91
|
const t = useComponentTranslator();
|
|
90
92
|
const hitAreaRef = useTouchHitArea(true);
|
|
@@ -134,6 +136,7 @@ export function InfoTip({
|
|
|
134
136
|
// enclosing Dialog.
|
|
135
137
|
return /*#__PURE__*/_jsxs(_Fragment, {
|
|
136
138
|
children: [/*#__PURE__*/_jsx("button", {
|
|
139
|
+
...pickDataAttributes(rest),
|
|
137
140
|
ref: mergedRef,
|
|
138
141
|
type: "button",
|
|
139
142
|
"aria-label": label ?? t('@astryx.infoTip.label'),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"layerAnimations.stylex.d.ts","sourceRoot":"","sources":["../../src/Layer/layerAnimations.stylex.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"layerAnimations.stylex.d.ts","sourceRoot":"","sources":["../../src/Layer/layerAnimations.stylex.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,KAAK,MAAM,MAAM,kBAAkB,CAAC;AA8F3C;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuC1B,CAAC"}
|