@astryxdesign/core 0.7.16-canary.ge95b87c → 0.7.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (183) hide show
  1. package/CHANGELOG.md +90 -0
  2. package/dist/BottomSheet/BottomSheet.d.ts.map +1 -1
  3. package/dist/BottomSheet/BottomSheet.js +38 -88
  4. package/dist/BottomSheet/BottomSheetPanel.d.ts +14 -6
  5. package/dist/BottomSheet/BottomSheetPanel.d.ts.map +1 -1
  6. package/dist/BottomSheet/BottomSheetPanel.js +26 -14
  7. package/dist/Button/Button.d.ts.map +1 -1
  8. package/dist/Button/Button.js +78 -3
  9. package/dist/Chat/ChatComposerInput.d.ts.map +1 -1
  10. package/dist/Chat/ChatComposerInput.js +1 -1
  11. package/dist/ContextMenu/ContextMenu.d.ts.map +1 -1
  12. package/dist/ContextMenu/ContextMenu.js +3 -0
  13. package/dist/DateInput/DateInput.d.ts +24 -0
  14. package/dist/DateInput/DateInput.d.ts.map +1 -1
  15. package/dist/DateInput/DateInput.js +12 -5
  16. package/dist/DateInput/index.d.ts +1 -1
  17. package/dist/DateInput/index.d.ts.map +1 -1
  18. package/dist/DateInput/useTypedDate.d.ts +12 -5
  19. package/dist/DateInput/useTypedDate.d.ts.map +1 -1
  20. package/dist/DateInput/useTypedDate.js +18 -16
  21. package/dist/DateTimeInput/DateTimeInput.d.ts +25 -0
  22. package/dist/DateTimeInput/DateTimeInput.d.ts.map +1 -1
  23. package/dist/DateTimeInput/DateTimeInput.js +10 -3
  24. package/dist/DateTimeInput/NativeTimeSegment.d.ts +3 -1
  25. package/dist/DateTimeInput/NativeTimeSegment.d.ts.map +1 -1
  26. package/dist/DateTimeInput/NativeTimeSegment.js +10 -1
  27. package/dist/DateTimeInput/index.d.ts +1 -1
  28. package/dist/DateTimeInput/index.d.ts.map +1 -1
  29. package/dist/Dialog/Dialog.d.ts.map +1 -1
  30. package/dist/Dialog/Dialog.js +3 -2
  31. package/dist/DropdownMenu/DropdownMenuSubMenu.d.ts.map +1 -1
  32. package/dist/DropdownMenu/DropdownMenuSubMenu.js +3 -0
  33. package/dist/Field/useEntryErrorBehavior.d.ts +8 -0
  34. package/dist/Field/useEntryErrorBehavior.d.ts.map +1 -0
  35. package/dist/Field/useEntryErrorBehavior.js +30 -0
  36. package/dist/FormLayout/FormLayout.d.ts +21 -2
  37. package/dist/FormLayout/FormLayout.d.ts.map +1 -1
  38. package/dist/FormLayout/FormLayout.js +5 -2
  39. package/dist/FormLayout/FormLayoutContext.d.ts +18 -2
  40. package/dist/FormLayout/FormLayoutContext.d.ts.map +1 -1
  41. package/dist/FormLayout/FormLayoutContext.js +22 -4
  42. package/dist/FormLayout/index.d.ts +1 -1
  43. package/dist/FormLayout/index.d.ts.map +1 -1
  44. package/dist/Layer/inputHold.d.ts +11 -1
  45. package/dist/Layer/inputHold.d.ts.map +1 -1
  46. package/dist/Layer/inputHold.js +114 -2
  47. package/dist/Layer/layerEntranceSide.d.ts.map +1 -1
  48. package/dist/Layer/layerEntranceSide.js +2 -1
  49. package/dist/Lightbox/Lightbox.d.ts.map +1 -1
  50. package/dist/Lightbox/Lightbox.js +63 -148
  51. package/dist/Lightbox/useZoomCore.d.ts +2 -13
  52. package/dist/Lightbox/useZoomCore.d.ts.map +1 -1
  53. package/dist/Lightbox/useZoomCore.js +7 -33
  54. package/dist/Lightbox/useZoomStage.d.ts.map +1 -1
  55. package/dist/Lightbox/useZoomStage.js +3 -9
  56. package/dist/Markdown/Markdown.d.ts.map +1 -1
  57. package/dist/Markdown/Markdown.js +7 -0
  58. package/dist/MetadataList/MetadataList.d.ts +2 -1
  59. package/dist/MetadataList/MetadataList.d.ts.map +1 -1
  60. package/dist/MetadataList/MetadataList.js +1 -1
  61. package/dist/NumberInput/NumberInput.d.ts +20 -2
  62. package/dist/NumberInput/NumberInput.d.ts.map +1 -1
  63. package/dist/NumberInput/NumberInput.js +4 -1
  64. package/dist/NumberInput/index.d.ts +1 -1
  65. package/dist/NumberInput/index.d.ts.map +1 -1
  66. package/dist/Outline/useOutlineFromDOM.d.ts.map +1 -1
  67. package/dist/Outline/useOutlineFromDOM.js +1 -0
  68. package/dist/Pagination/Pagination.d.ts.map +1 -1
  69. package/dist/Pagination/Pagination.js +1 -0
  70. package/dist/Popover/popoverSurfaceFrame.d.ts +4 -16
  71. package/dist/Popover/popoverSurfaceFrame.d.ts.map +1 -1
  72. package/dist/Popover/popoverSurfaceFrame.js +16 -31
  73. package/dist/Popover/usePopover.d.ts.map +1 -1
  74. package/dist/Popover/usePopover.js +3 -0
  75. package/dist/PowerSearch/PowerSearchValueEditor.d.ts.map +1 -1
  76. package/dist/PowerSearch/PowerSearchValueEditor.js +4 -0
  77. package/dist/SegmentedControl/useSegmentedTouchTracking.d.ts.map +1 -1
  78. package/dist/SegmentedControl/useSegmentedTouchTracking.js +18 -0
  79. package/dist/Selector/Selector.d.ts.map +1 -1
  80. package/dist/Selector/Selector.js +0 -2
  81. package/dist/Table/plugins/filtering/useTableFiltering.d.ts.map +1 -1
  82. package/dist/Table/plugins/filtering/useTableFiltering.js +2 -0
  83. package/dist/Thumbnail/Thumbnail.d.ts +2 -2
  84. package/dist/TimeInput/TimeInput.d.ts +24 -4
  85. package/dist/TimeInput/TimeInput.d.ts.map +1 -1
  86. package/dist/TimeInput/TimeInput.js +10 -4
  87. package/dist/TimeInput/index.d.ts +1 -1
  88. package/dist/TimeInput/index.d.ts.map +1 -1
  89. package/dist/TimeInput/useTypedTime.d.ts +17 -6
  90. package/dist/TimeInput/useTypedTime.d.ts.map +1 -1
  91. package/dist/TimeInput/useTypedTime.js +41 -18
  92. package/dist/Toast/Toast.d.ts +6 -1
  93. package/dist/Toast/Toast.d.ts.map +1 -1
  94. package/dist/Toast/Toast.js +17 -1
  95. package/dist/Toast/ToastViewport.d.ts.map +1 -1
  96. package/dist/Toast/ToastViewport.js +10 -9
  97. package/dist/astryx.css +36 -6
  98. package/dist/hooks/containerReveal.stylex.d.ts.map +1 -1
  99. package/dist/hooks/containerReveal.stylex.js +18 -15
  100. package/dist/hooks/useAnnounceRenderedText.d.ts +9 -3
  101. package/dist/hooks/useAnnounceRenderedText.d.ts.map +1 -1
  102. package/dist/hooks/useAnnounceRenderedText.js +9 -7
  103. package/dist/hooks/useContainerReveal.d.ts +8 -5
  104. package/dist/hooks/useContainerReveal.d.ts.map +1 -1
  105. package/dist/hooks/useContainerReveal.js +2 -1
  106. package/dist/i18n/generated-locales/en.generated.d.ts.map +1 -1
  107. package/dist/i18n/generated-locales/en.generated.js +1 -0
  108. package/dist/i18n/generated-locales/pseudo.generated.d.ts.map +1 -1
  109. package/dist/i18n/generated-locales/pseudo.generated.js +1 -0
  110. package/dist/internal/shared-context.d.ts +15 -0
  111. package/dist/internal/shared-context.d.ts.map +1 -0
  112. package/dist/internal/shared-context.js +15 -0
  113. package/dist/motion/animatedLayout.d.ts.map +1 -1
  114. package/dist/motion/animatedLayout.js +2 -17
  115. package/dist/motion/linearEasing.d.ts +9 -0
  116. package/dist/motion/linearEasing.d.ts.map +1 -0
  117. package/dist/motion/linearEasing.js +32 -0
  118. package/dist/motion/resolveMotion.d.ts +16 -0
  119. package/dist/motion/resolveMotion.d.ts.map +1 -1
  120. package/dist/motion/resolveMotion.js +40 -1
  121. package/locales/en.json +15 -11
  122. package/locales/pseudo.json +3 -0
  123. package/package.json +10 -5
  124. package/src/BottomSheet/BottomSheet.tsx +43 -101
  125. package/src/BottomSheet/BottomSheetPanel.tsx +46 -23
  126. package/src/Button/Button.tsx +132 -5
  127. package/src/Chat/ChatComposerInput.tsx +4 -0
  128. package/src/ContextMenu/ContextMenu.tsx +13 -0
  129. package/src/DateInput/DateInput.doc.mjs +18 -0
  130. package/src/DateInput/DateInput.tsx +35 -3
  131. package/src/DateInput/index.ts +1 -0
  132. package/src/DateInput/useTypedDate.ts +50 -12
  133. package/src/DateTimeInput/DateTimeInput.doc.mjs +18 -0
  134. package/src/DateTimeInput/DateTimeInput.tsx +38 -2
  135. package/src/DateTimeInput/NativeTimeSegment.tsx +16 -1
  136. package/src/DateTimeInput/index.ts +1 -0
  137. package/src/Dialog/Dialog.tsx +13 -2
  138. package/src/DropdownMenu/DropdownMenuSubMenu.tsx +13 -0
  139. package/src/Field/useEntryErrorBehavior.ts +34 -0
  140. package/src/FormLayout/FormLayout.doc.mjs +14 -0
  141. package/src/FormLayout/FormLayout.tsx +24 -2
  142. package/src/FormLayout/FormLayoutContext.ts +24 -4
  143. package/src/FormLayout/index.ts +5 -1
  144. package/src/Layer/inputHold.ts +137 -2
  145. package/src/Layer/layerEntranceSide.ts +2 -1
  146. package/src/Lightbox/Lightbox.doc.mjs +1 -1
  147. package/src/Lightbox/Lightbox.tsx +226 -357
  148. package/src/Lightbox/useZoomCore.ts +6 -49
  149. package/src/Lightbox/useZoomStage.ts +7 -17
  150. package/src/Markdown/Markdown.tsx +6 -0
  151. package/src/MetadataList/MetadataList.doc.mjs +16 -0
  152. package/src/MetadataList/MetadataList.tsx +3 -2
  153. package/src/NumberInput/NumberInput.doc.mjs +18 -0
  154. package/src/NumberInput/NumberInput.tsx +22 -1
  155. package/src/NumberInput/index.ts +1 -0
  156. package/src/Outline/useOutlineFromDOM.doc.mjs +99 -0
  157. package/src/Outline/useOutlineFromDOM.ts +1 -0
  158. package/src/Pagination/Pagination.tsx +1 -0
  159. package/src/Popover/popoverSurfaceFrame.ts +18 -41
  160. package/src/Popover/usePopover.tsx +13 -0
  161. package/src/PowerSearch/PowerSearchValueEditor.tsx +4 -0
  162. package/src/SegmentedControl/useSegmentedTouchTracking.ts +15 -0
  163. package/src/Selector/Selector.tsx +0 -1
  164. package/src/Table/plugins/filtering/useTableFiltering.tsx +2 -0
  165. package/src/Thumbnail/Thumbnail.doc.mjs +2 -2
  166. package/src/Thumbnail/Thumbnail.tsx +2 -2
  167. package/src/TimeInput/TimeInput.doc.mjs +21 -3
  168. package/src/TimeInput/TimeInput.tsx +38 -8
  169. package/src/TimeInput/index.ts +1 -0
  170. package/src/TimeInput/useTypedTime.ts +60 -18
  171. package/src/Toast/Toast.tsx +33 -2
  172. package/src/Toast/ToastViewport.tsx +14 -9
  173. package/src/hooks/containerReveal.stylex.ts +17 -15
  174. package/src/hooks/useAnnounceRenderedText.ts +18 -6
  175. package/src/hooks/useContainerReveal.doc.mjs +3 -3
  176. package/src/hooks/useContainerReveal.ts +8 -5
  177. package/src/i18n/generated-locales/en.generated.ts +1 -0
  178. package/src/i18n/generated-locales/pseudo.generated.ts +1 -0
  179. package/src/internal/shared-context.ts +15 -0
  180. package/src/motion/README.md +1 -0
  181. package/src/motion/animatedLayout.ts +6 -21
  182. package/src/motion/linearEasing.ts +35 -0
  183. package/src/motion/resolveMotion.ts +42 -1
@@ -4,8 +4,8 @@
4
4
 
5
5
  /**
6
6
  * @file DateInput.tsx
7
- * @input Uses React, useId, useCallback, useRef, useTypedDateField, Field, Icon, Calendar, usePopover, InputGroupContext
8
- * @output Exports DateInput component, DateInputProps, and DateInputEntryError
7
+ * @input Uses React, useId, useCallback, useRef, useTypedDateField, useEntryErrorBehavior, Field, Icon, Calendar, usePopover, InputGroupContext
8
+ * @output Exports DateInput component, DateInputProps, DateInputEntryError, and EntryErrorBehavior
9
9
  * @position Core implementation; consumed by index.ts, tested by DateInput.test.tsx
10
10
  *
11
11
  * SYNC: When modified, update these files to stay in sync:
@@ -26,6 +26,8 @@ import {
26
26
  } from 'react';
27
27
  import * as stylex from '@stylexjs/stylex';
28
28
  import {inputDisabledFocusStyles} from '../Field/inputDisabledFocus';
29
+ import {useEntryErrorBehavior} from '../Field/useEntryErrorBehavior';
30
+ import type {EntryErrorBehavior} from '../FormLayout/FormLayoutContext';
29
31
  import {
30
32
  colorVars,
31
33
  sizeVars,
@@ -194,6 +196,7 @@ export type {
194
196
  InputStatusType as DateInputStatusType,
195
197
  } from '../Field';
196
198
  export type {DateInputEntryError} from './useTypedDate';
199
+ export type {EntryErrorBehavior} from '../FormLayout/FormLayoutContext';
197
200
  import {mergeProps, isFocusDetached} from '../utils';
198
201
  import {joinAriaIDs} from '../utils/inputAria';
199
202
  import {
@@ -380,6 +383,29 @@ export interface DateInputProps extends Omit<
380
383
  */
381
384
  onEntryErrorChange?: (error: DateInputEntryError | null) => void;
382
385
 
386
+ /**
387
+ * When the field shows its own entry error: a typed date that it rejects,
388
+ * which `onEntryErrorChange` reports. It sets when the error shows, not when
389
+ * validation runs, so it is not React Aria's `validationBehavior` (native
390
+ * versus ARIA validation). It does not change a caller's `status`.
391
+ *
392
+ * - `'complete'` — a date the calendar does not have, or one outside `min`,
393
+ * `max`, or `dateConstraints`, shows as soon as the typed date is
394
+ * complete. Unreadable or unfinished text shows at Enter or blur.
395
+ * - `'blur-or-enter'` — every rejection waits for Enter or blur. The
396
+ * message, `aria-invalid`, the invalid styling, the announcement, and the
397
+ * `onEntryErrorChange` report then appear together. An edit that makes
398
+ * the text a date or empties it clears the error at once. An edit that
399
+ * leaves the text wrong keeps the shown error until the next Enter or
400
+ * blur.
401
+ *
402
+ * A date that the native control refuses shows at Enter or blur under both
403
+ * values.
404
+ *
405
+ * @default the nearest FormLayout's `defaultEntryErrorBehavior`, else `'complete'`
406
+ */
407
+ entryErrorBehavior?: EntryErrorBehavior;
408
+
383
409
  /**
384
410
  * How the status message is placed relative to the input.
385
411
  * - 'attached': message overlaps directly below the input (bordered treatment)
@@ -591,6 +617,7 @@ function PointerDateField({
591
617
  size: sizeProp,
592
618
  status,
593
619
  onEntryErrorChange,
620
+ entryErrorBehavior,
594
621
  statusVariant = 'attached',
595
622
  labelTooltip,
596
623
  hasClear = false,
@@ -701,6 +728,7 @@ function PointerDateField({
701
728
  const navigateToTypedDate = useCallback((date: ISODateString) => {
702
729
  calendarRef.current?.navigateTo(date);
703
730
  }, []);
731
+ const resolvedEntryErrorBehavior = useEntryErrorBehavior(entryErrorBehavior);
704
732
  const {
705
733
  typedDate,
706
734
  displayValue,
@@ -732,6 +760,7 @@ function PointerDateField({
732
760
  isStatusAnnounced: !inputGroup,
733
761
  onEntryErrorChange,
734
762
  hasPlaceholder: placeholderFromProps != null,
763
+ entryErrorBehavior: resolvedEntryErrorBehavior,
735
764
  });
736
765
 
737
766
  const {statusIcon, describedBy: statusTooltipDescribedBy} =
@@ -1181,8 +1210,10 @@ export function DateInput(props: DateInputProps) {
1181
1210
  nativePicker: _nativePicker,
1182
1211
  calendar: _calendar,
1183
1212
  // Only the pointer field takes typed text. The native field reads only
1184
- // whether the callback is set.
1213
+ // whether the callback is set. Its refused dates wait for Enter or blur
1214
+ // under every entry error behavior.
1185
1215
  onEntryErrorChange,
1216
+ entryErrorBehavior,
1186
1217
  ...rest
1187
1218
  } = props;
1188
1219
  switch (surface) {
@@ -1211,6 +1242,7 @@ export function DateInput(props: DateInputProps) {
1211
1242
  calendar={calendar}
1212
1243
  isDisabled={isDisabled}
1213
1244
  onEntryErrorChange={onEntryErrorChange}
1245
+ entryErrorBehavior={entryErrorBehavior}
1214
1246
  />
1215
1247
  );
1216
1248
  }
@@ -17,4 +17,5 @@ export type {
17
17
  DateInputStatus,
18
18
  DateInputStatusType,
19
19
  DateInputEntryError,
20
+ EntryErrorBehavior,
20
21
  } from './DateInput';
@@ -6,8 +6,9 @@
6
6
  * @file useTypedDate.ts
7
7
  * @input Provider locale and calendar, a field's format, bounds and constraints;
8
8
  * calendarDateParser, parseDateInput for other Gregorian text,
9
- * Field/useEntryErrorReport for the rejection status, alert and report, and
10
- * Field/useValueReplacesEntry for when a new value replaces a kept entry
9
+ * Field/useEntryErrorReport for the rejection status, alert and report,
10
+ * Field/useValueReplacesEntry for when a new value replaces a kept entry, and
11
+ * the field's resolved entry error behavior
11
12
  * @output Typed-date reading, committed text, the format hint, the calendar
12
13
  * description and rejection messages for a date text field, the typed
13
14
  * entry state that DateInput and DateTimeInput share, the
@@ -18,6 +19,7 @@
18
19
 
19
20
  import {useCallback, useMemo, useState} from 'react';
20
21
  import type {InputStatus} from '../Field/types';
22
+ import type {EntryErrorBehavior} from '../FormLayout/FormLayoutContext';
21
23
  import {useEntryErrorReport} from '../Field/useEntryErrorReport';
22
24
  import {useValueReplacesEntry} from '../Field/useValueReplacesEntry';
23
25
  import {useLocale} from '../i18n/useLocale';
@@ -123,13 +125,14 @@ export interface TypedDate {
123
125
  }
124
126
 
125
127
  /**
126
- * The rejection a result shows: the error of a complete date, or of text that
127
- * Enter or blur committed. Text that is not a date is never complete, so its
128
- * error waits for the commit.
128
+ * The rejection a result shows: the error of text that Enter or blur
129
+ * committed, or, under `'complete'`, of a complete date. Text that is not a
130
+ * date is never complete, so its error waits for the commit.
129
131
  */
130
132
  export function typedDateError(
131
133
  result: CalendarDateParseResult | null,
132
134
  isCommitted: boolean,
135
+ entryErrorBehavior: EntryErrorBehavior,
133
136
  ): TypedDateError | null {
134
137
  if (result == null) {
135
138
  return null;
@@ -142,7 +145,7 @@ export function typedDateError(
142
145
  }
143
146
  if (
144
147
  (result.kind === 'nonexistent' || result.kind === 'outOfRange') &&
145
- (result.isComplete || isCommitted)
148
+ (isCommitted || (result.isComplete && entryErrorBehavior === 'complete'))
146
149
  ) {
147
150
  return result.kind;
148
151
  }
@@ -161,8 +164,9 @@ function dateEntryError(
161
164
  text: string,
162
165
  min: ISODateString | undefined,
163
166
  max: ISODateString | undefined,
167
+ entryErrorBehavior: EntryErrorBehavior,
164
168
  ): DateInputEntryError | null {
165
- const error = typedDateError(result, isCommitted);
169
+ const error = typedDateError(result, isCommitted, entryErrorBehavior);
166
170
  if (error == null || result == null) {
167
171
  return null;
168
172
  }
@@ -349,6 +353,12 @@ export interface UseTypedDateFieldOptions extends UseTypedDateOptions {
349
353
  onEntryErrorChange?: (error: DateInputEntryError | null) => void;
350
354
  /** Whether the caller gave a placeholder, which replaces the format hint. */
351
355
  hasPlaceholder: boolean;
356
+ /**
357
+ * Under `'blur-or-enter'`, typing reveals no rejection: only Enter or blur
358
+ * does. An edit that makes the text a date or empties it still clears a
359
+ * revealed rejection at once.
360
+ */
361
+ entryErrorBehavior: EntryErrorBehavior;
352
362
  }
353
363
 
354
364
  export interface TypedDateField {
@@ -393,6 +403,7 @@ export function useTypedDateField({
393
403
  isStatusAnnounced,
394
404
  onEntryErrorChange,
395
405
  hasPlaceholder,
406
+ entryErrorBehavior,
396
407
  ...options
397
408
  }: UseTypedDateFieldOptions): TypedDateField {
398
409
  const typedDate = useTypedDate(options);
@@ -422,7 +433,11 @@ export function useTypedDateField({
422
433
  pendingInput !== null && pendingInput.trim()
423
434
  ? typedDate.parse(pendingInput)
424
435
  : null;
425
- const ownError = typedDateError(typedResult, isRejectionCommitted);
436
+ const ownError = typedDateError(
437
+ typedResult,
438
+ isRejectionCommitted,
439
+ entryErrorBehavior,
440
+ );
426
441
  const keptResult =
427
442
  ownError == null &&
428
443
  keptText !== null &&
@@ -438,14 +453,21 @@ export function useTypedDateField({
438
453
  ? {text: pendingInput, result: typedResult}
439
454
  : keptResult != null &&
440
455
  keptText !== null &&
441
- typedDateError(keptResult, true) != null
456
+ typedDateError(keptResult, true, entryErrorBehavior) != null
442
457
  ? {text: keptText, result: keptResult}
443
458
  : null;
444
459
  const errorMessage =
445
460
  shown != null ? typedDate.errorMessage(shown.result) : null;
446
461
  const entryError =
447
462
  shown != null
448
- ? dateEntryError(shown.result, true, shown.text, options.min, options.max)
463
+ ? dateEntryError(
464
+ shown.result,
465
+ true,
466
+ shown.text,
467
+ options.min,
468
+ options.max,
469
+ entryErrorBehavior,
470
+ )
449
471
  : null;
450
472
  const shownText = shown?.text ?? null;
451
473
  // Unreadable text that Enter or blur kept: the form posts the committed
@@ -530,7 +552,14 @@ export function useTypedDateField({
530
552
  const isEmpty = !text.trim();
531
553
  const error = isEmpty
532
554
  ? null
533
- : dateEntryError(result, false, text, options.min, options.max);
555
+ : dateEntryError(
556
+ result,
557
+ false,
558
+ text,
559
+ options.min,
560
+ options.max,
561
+ entryErrorBehavior,
562
+ );
534
563
  // An edit that leaves the entry rejected or unfinished keeps the shown
535
564
  // rejection.
536
565
  const nextKeptText =
@@ -554,6 +583,7 @@ export function useTypedDateField({
554
583
  reportEntryError,
555
584
  options.min,
556
585
  options.max,
586
+ entryErrorBehavior,
557
587
  report,
558
588
  onTypedDate,
559
589
  ],
@@ -581,7 +611,14 @@ export function useTypedDateField({
581
611
  setKeptCommits(count => count + 1);
582
612
  setKeptText(null);
583
613
  reportEntryError(
584
- dateEntryError(result, true, pendingInput, options.min, options.max),
614
+ dateEntryError(
615
+ result,
616
+ true,
617
+ pendingInput,
618
+ options.min,
619
+ options.max,
620
+ entryErrorBehavior,
621
+ ),
585
622
  );
586
623
  return;
587
624
  }
@@ -599,6 +636,7 @@ export function useTypedDateField({
599
636
  reportEntryError,
600
637
  options.min,
601
638
  options.max,
639
+ entryErrorBehavior,
602
640
  report,
603
641
  reset,
604
642
  firedEpoch,
@@ -182,6 +182,14 @@ export const docs = {
182
182
  description:
183
183
  "Called each time the date segment's rejection of typed text changes, and with null when the rejection ends. kind is 'unreadable', 'incomplete' (part of a date that Enter or blur cannot finish), 'nonexistent' (a date the calendar does not have), 'outOfRange' (before the date of min or after the date of max), or 'unavailable' (a day dateConstraints rules out); text is the typed text; date is the Gregorian ISO date the text names, for 'outOfRange' and 'unavailable'. It also runs when a new min, max, dateConstraints, or value, a calendar pick, disabling the field, or Enter or blur changes the rejection, and never twice for the same rejection; it reports null when the typed field leaves while its rejection stands, as when a presentation or pointer change shows the native or touch picker. With it, an error status with a message replaces the field's own message, and a rejection that starts under an unchanged error message announces that message once. The native and touch pickers take no typed text, so it never reports a rejection there.",
184
184
  },
185
+ {
186
+ name: 'entryErrorBehavior',
187
+ type: "'complete' | 'blur-or-enter'",
188
+ description:
189
+ "When both segments show their own entry errors: a typed date or time the field rejects. It sets when the error shows, not when validation runs, so it is not React Aria's validationBehavior (native versus ARIA validation), and it never changes a caller status. 'complete' shows a complete typed date the calendar does not have or that is out of range, a complete typed time outside the range, and a time the native control reports outside the range at once, and other rejected text at Enter or blur. 'blur-or-enter' holds every rejection until Enter or blur in its segment: the message, aria-invalid, the invalid styling, the announcement, and the date segment's onEntryErrorChange report then appear together. Under both values, an edit the field accepts or that empties the segment clears the error at once; under 'blur-or-enter', an edit that leaves the entry wrong keeps the shown error until the next Enter or blur. A date the native control refuses shows at Enter or blur under both values. The field's own value wins over the nearest FormLayout's defaultEntryErrorBehavior.",
190
+ default:
191
+ "the nearest FormLayout's defaultEntryErrorBehavior, else 'complete'",
192
+ },
185
193
  {
186
194
  name: 'labelTooltip',
187
195
  type: 'string',
@@ -588,6 +596,14 @@ export const docsZh = {
588
596
  description:
589
597
  "每当日期部分对输入文本的拒绝发生变化时调用,拒绝结束时传入 null。kind 为 'unreadable'、'incomplete'(按 Enter 或失焦也无法补全的部分日期)、'nonexistent'(该日历中不存在的日期)、'outOfRange'(早于 min 的日期或晚于 max 的日期)或 'unavailable'(被 dateConstraints 排除的日期);text 为输入的文本;date 为文本所指的公历 ISO 日期,用于 'outOfRange' 和 'unavailable'。新的 min、max、dateConstraints 或 value、在日历中选择日期、禁用字段,或按 Enter、失焦改变拒绝时也会调用;同一拒绝不会重复调用;拒绝仍存在时若输入字段被替换(例如展示方式或指针类型改变而显示原生或触控选择器),会传入 null。传入此回调后,带消息的 error 状态会替代字段自身的错误消息;若拒绝开始时该错误消息未变,字段会再播报一次该消息。原生和触控选择器不接受输入文本,因此不会报告拒绝。",
590
598
  },
599
+ {
600
+ name: 'entryErrorBehavior',
601
+ type: "'complete' | 'blur-or-enter'",
602
+ description:
603
+ "两个分段何时显示自身的输入错误:即字段拒绝的输入日期或时间。它设定错误何时显示,而不是何时校验,因此不同于 React Aria 的 validationBehavior(原生校验与 ARIA 校验之分),也不会改变调用方的 status。'complete' 立即显示完整输入但日历中不存在或超出范围的日期、完整输入但超出范围的时间,以及原生控件报告的超出范围的时间;其他被拒绝的文本在按 Enter 或失焦时显示。'blur-or-enter' 将每个拒绝保留到在该分段中按 Enter 或失焦:届时消息、aria-invalid、无效样式、播报和日期分段的 onEntryErrorChange 报告一起出现。两种取值下,字段接受的编辑或清空分段的编辑都会立即清除错误;在 'blur-or-enter' 下,输入仍然错误的编辑会保留已显示的错误,直到下一次按 Enter 或失焦。原生控件拒绝的日期在两种取值下都在按 Enter 或失焦时显示。字段自身的取值优先于最近的 FormLayout 的 defaultEntryErrorBehavior。",
604
+ default:
605
+ "最近的 FormLayout 的 defaultEntryErrorBehavior,否则为 'complete'",
606
+ },
591
607
  {
592
608
  name: 'labelTooltip',
593
609
  type: 'string',
@@ -754,6 +770,8 @@ export const docsDense = {
754
770
  'error/warning/success status w/ message; a rejected date (typed or native) or kept unreadable/unfinished text shows its own error instead, unless onEntryErrorChange is set and status is an error w/ message; a rejected typed time (complete, or at Enter/blur, text kept) shows its own error unless the date message shows or status is an error w/ message',
755
771
  onEntryErrorChange:
756
772
  "(error|null) on each typed-rejection change: kind 'unreadable'|'incomplete'|'nonexistent'|'outOfRange' (min/max)|'unavailable' (dateConstraints), text, date (Gregorian ISO, outOfRange/unavailable); also on new min/max/dateConstraints/value, calendar pick, disable, Enter/blur; never twice for one rejection; null when the typed field leaves mid-rejection (presentation/pointer switch); with it an error status w/ message replaces the field's own message, re-announced once if unchanged when a rejection starts; never a rejection on native/touch pickers",
773
+ entryErrorBehavior:
774
+ "'complete'|'blur-or-enter': when both segments' own rejections show (not when validation runs; not React Aria validationBehavior; never changes status). complete: complete nonexistent/out-of-range date, complete out-of-range time and native out-of-range time at once, other text at Enter/blur. blur-or-enter: message, aria-invalid, styling, announcement and date onEntryErrorChange report all wait for Enter/blur in that segment. Accepted or emptied entry clears at once; still-wrong edit keeps a shown error (blur-or-enter). Native date refusals wait for Enter/blur under both. Default: nearest FormLayout defaultEntryErrorBehavior, else complete",
757
775
  labelTooltip: 'tooltip text via info icon at label end',
758
776
  numberOfMonths:
759
777
  'Astryx pointer-calendar months shown simultaneously; ignored by native date controls and the mobile touch sheet',
@@ -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, DateInputEntryError, and native picker type; cleared values keep the pointer Calendar controlled-empty; typed date rejections reach onEntryErrorChange
8
+ * @output Exports DateTimeInput component, DateTimeInputProps, DateInputEntryError, EntryErrorBehavior, 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:
@@ -34,6 +34,8 @@ import {
34
34
  } from 'react';
35
35
  import * as stylex from '@stylexjs/stylex';
36
36
  import {inputDisabledFocusStyles} from '../Field/inputDisabledFocus';
37
+ import {useEntryErrorBehavior} from '../Field/useEntryErrorBehavior';
38
+ import type {EntryErrorBehavior} from '../FormLayout/FormLayoutContext';
37
39
  import {
38
40
  colorVars,
39
41
  sizeVars,
@@ -132,6 +134,7 @@ import english from '../i18n/generated-english/DateTimeInput/DateTimeInput.gener
132
134
 
133
135
  registerEnglishFallback(english);
134
136
  export type {DateInputEntryError} from '../DateInput/useTypedDate';
137
+ export type {EntryErrorBehavior} from '../FormLayout/FormLayoutContext';
135
138
  export type ISODateTimeString = string & {
136
139
  readonly __brand: 'ISODateTimeString';
137
140
  };
@@ -537,6 +540,30 @@ export interface DateTimeInputProps extends Omit<
537
540
  */
538
541
  onEntryErrorChange?: (error: DateInputEntryError | null) => void;
539
542
 
543
+ /**
544
+ * When both segments show their own entry errors: a typed date or time that
545
+ * the field rejects. It sets when the error shows, not when validation
546
+ * runs, so it is not React Aria's `validationBehavior` (native versus ARIA
547
+ * validation). It does not change a caller's `status`.
548
+ *
549
+ * - `'complete'` — a complete typed date the calendar does not have or that
550
+ * is out of range, and a complete typed time outside the range, show at
551
+ * once. A time the native control reports outside the range shows at
552
+ * once. Other rejected text shows at Enter or blur.
553
+ * - `'blur-or-enter'` — every rejection waits for Enter or blur in its
554
+ * segment. The message, `aria-invalid`, the invalid styling, the
555
+ * announcement, and the date segment's `onEntryErrorChange` report then
556
+ * appear together. An edit that the field accepts or that empties the
557
+ * segment clears the error at once. An edit that leaves the entry wrong
558
+ * keeps the shown error until the next Enter or blur.
559
+ *
560
+ * A date that the native control refuses shows at Enter or blur under both
561
+ * values.
562
+ *
563
+ * @default the nearest FormLayout's `defaultEntryErrorBehavior`, else `'complete'`
564
+ */
565
+ entryErrorBehavior?: EntryErrorBehavior;
566
+
540
567
  /**
541
568
  * Width of the field. Numbers are treated as pixels, strings are used as-is
542
569
  * (e.g. `'100%'`). Sizes the whole field (label, control, and status) so they
@@ -698,6 +725,7 @@ function PointerDateTimeField({
698
725
  size: sizeProp,
699
726
  status,
700
727
  onEntryErrorChange,
728
+ entryErrorBehavior,
701
729
  labelTooltip,
702
730
  numberOfMonths = 1,
703
731
  weekStartsOn,
@@ -858,6 +886,7 @@ function PointerDateTimeField({
858
886
  }
859
887
  }
860
888
  const nativeTimeValue = nativeTimeDraft ?? valueParts.time;
889
+ const resolvedEntryErrorBehavior = useEntryErrorBehavior(entryErrorBehavior);
861
890
  const typedTime = useTypedTime({
862
891
  value: valueParts.time,
863
892
  hourFormat,
@@ -870,6 +899,7 @@ function PointerDateTimeField({
870
899
  errorMessage: t('@astryx.timeInput.invalidTime'),
871
900
  isStatusAnnounced: true,
872
901
  status,
902
+ entryErrorBehavior: resolvedEntryErrorBehavior,
873
903
  });
874
904
  const timePendingInput = typedTime.pendingInput;
875
905
 
@@ -1084,6 +1114,7 @@ function PointerDateTimeField({
1084
1114
  isStatusAnnounced: true,
1085
1115
  onEntryErrorChange,
1086
1116
  hasPlaceholder: placeholderFromProps != null,
1117
+ entryErrorBehavior: resolvedEntryErrorBehavior,
1087
1118
  });
1088
1119
 
1089
1120
  const nativeDateRejection = useNativeDateRejection({
@@ -1974,6 +2005,7 @@ function PointerDateTimeField({
1974
2005
  ariaDescribedBy={ariaDescribedBy}
1975
2006
  isRejected={typedTime.isSurfaceRejectionShown}
1976
2007
  onRejectedChange={typedTime.setSurfaceRejected}
2008
+ onCommit={typedTime.commitSurface}
1977
2009
  alertMessage={timeAlertMessage}
1978
2010
  />
1979
2011
  ) : (
@@ -2187,7 +2219,11 @@ export function DateTimeInput(props: DateTimeInputProps) {
2187
2219
  return <PointerDateTimeField {...rest} nativeMode="adaptive" />;
2188
2220
  case 'sheet': {
2189
2221
  // The sheet takes no typed text.
2190
- const {onEntryErrorChange: _onEntryErrorChange, ...sheetProps} = rest;
2222
+ const {
2223
+ onEntryErrorChange: _onEntryErrorChange,
2224
+ entryErrorBehavior: _entryErrorBehavior,
2225
+ ...sheetProps
2226
+ } = rest;
2191
2227
  // Month indexes depend on the calendar. A new calendar remounts the sheet.
2192
2228
  return <TouchDateTimeField key={calendar} {...sheetProps} />;
2193
2229
  }
@@ -93,6 +93,8 @@ export type NativeTimeSegmentProps = {
93
93
  * it. The owner ends it when `value` changes.
94
94
  */
95
95
  onRejectedChange: (isRejected: boolean) => void;
96
+ /** Runs at Enter and blur, which show a rejection that waits for them. */
97
+ onCommit: () => void;
96
98
  /** The rejection message that no shown status announces. */
97
99
  alertMessage: string;
98
100
  /**
@@ -129,12 +131,14 @@ export function NativeTimeSegment({
129
131
  ariaDescribedBy,
130
132
  isRejected,
131
133
  onRejectedChange,
134
+ onCommit,
132
135
  alertMessage,
133
136
  controlProps,
134
137
  }: NativeTimeSegmentProps) {
135
138
  const {
136
139
  onFocus: onFocusProp,
137
140
  onBlur: onBlurProp,
141
+ onKeyDown: onKeyDownProp,
138
142
  ...inputProps
139
143
  } = controlProps ?? {};
140
144
  const locale = useLocale();
@@ -283,7 +287,17 @@ export function NativeTimeSegment({
283
287
  commitValue(domValue);
284
288
  }
285
289
  lastCommitRef.current = null;
286
- }, [commitValue, nativeValue, isRejected]);
290
+ onCommit();
291
+ }, [commitValue, nativeValue, isRejected, onCommit]);
292
+
293
+ const handleKeyDown = useCallback(
294
+ (e: React.KeyboardEvent<HTMLInputElement>) => {
295
+ if (e.key === 'Enter') {
296
+ onCommit();
297
+ }
298
+ },
299
+ [onCommit],
300
+ );
287
301
 
288
302
  const openPicker = useCallback(() => {
289
303
  if (isEffectivelyDisabled) {
@@ -330,6 +344,7 @@ export function NativeTimeSegment({
330
344
  onChange={handleChange}
331
345
  onFocus={chainEventHandlers(handleFocus, onFocusProp)}
332
346
  onBlur={chainEventHandlers(handleBlur, onBlurProp)}
347
+ onKeyDown={chainEventHandlers(handleKeyDown, onKeyDownProp)}
333
348
  min={min}
334
349
  max={max}
335
350
  step={60}
@@ -19,5 +19,6 @@ export type {
19
19
  DateTimeInputStatus,
20
20
  DateTimeInputStatusType,
21
21
  DateInputEntryError,
22
+ EntryErrorBehavior,
22
23
  ISODateTimeString,
23
24
  } from './DateTimeInput';
@@ -315,12 +315,23 @@ const styles = stylex.create({
315
315
  // Inline wrapper mirrors the dialog's visual styles without <dialog> behavior
316
316
  inlineWrapper: {
317
317
  padding: 0,
318
- borderWidth: 0,
319
- borderStyle: 'none',
320
318
  backgroundColor: colorVars['--color-background-surface'],
321
319
  '--_dialog-radius': radiusVars['--radius-container'],
322
320
  borderRadius: 'var(--_dialog-radius)',
323
321
  boxShadow: shadowVars['--shadow-high'],
322
+ // Forced colors removes box-shadow, which is this surface's only edge.
323
+ borderWidth: {
324
+ default: 0,
325
+ '@media (forced-colors: active)': '1px',
326
+ },
327
+ borderStyle: {
328
+ default: 'none',
329
+ '@media (forced-colors: active)': 'solid',
330
+ },
331
+ borderColor: {
332
+ default: null,
333
+ '@media (forced-colors: active)': 'CanvasText',
334
+ },
324
335
  display: 'flex',
325
336
  flexDirection: 'column',
326
337
  height: 'fit-content',
@@ -210,6 +210,19 @@ const flyoutStyles = stylex.create({
210
210
  borderRadius: 'var(--_dropdown-menu-radius)',
211
211
  backgroundColor: colorVars['--color-background-popover'],
212
212
  boxShadow: shadowVars['--shadow-low'],
213
+ // Forced colors removes box-shadow, which is this surface's only edge.
214
+ borderWidth: {
215
+ default: null,
216
+ '@media (forced-colors: active)': '1px',
217
+ },
218
+ borderStyle: {
219
+ default: null,
220
+ '@media (forced-colors: active)': 'solid',
221
+ },
222
+ borderColor: {
223
+ default: null,
224
+ '@media (forced-colors: active)': 'CanvasText',
225
+ },
213
226
  opacity: 1,
214
227
  transitionProperty: 'opacity',
215
228
  transitionDuration: durationVars['--duration-fast'],
@@ -0,0 +1,34 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ 'use client';
4
+
5
+ /**
6
+ * @file useEntryErrorBehavior.ts
7
+ * @input A field's own entryErrorBehavior and the nearest FormLayout's
8
+ * defaultEntryErrorBehavior
9
+ * @output The entry error behavior that the field follows
10
+ * @position Shared internal hook of the input-field family; used by DateInput,
11
+ * DateTimeInput, and TimeInput
12
+ *
13
+ * SYNC: When modified, update:
14
+ * - /packages/core/src/FormLayout/FormLayoutContext.ts (EntryErrorBehavior)
15
+ * - /packages/core/src/FormLayout/FormLayout.test.tsx (precedence tests)
16
+ */
17
+
18
+ import {use} from 'react';
19
+ import {
20
+ FormLayoutContext,
21
+ type EntryErrorBehavior,
22
+ } from '../FormLayout/FormLayoutContext';
23
+
24
+ /**
25
+ * The entry error behavior of a field: its own prop, else the nearest
26
+ * FormLayout's default, else `'complete'`. A layer starts a new FormLayout
27
+ * scope, so a field in a Dialog opened from a form takes no default from it.
28
+ */
29
+ export function useEntryErrorBehavior(
30
+ entryErrorBehavior: EntryErrorBehavior | undefined,
31
+ ): EntryErrorBehavior {
32
+ const {defaultEntryErrorBehavior} = use(FormLayoutContext);
33
+ return entryErrorBehavior ?? defaultEntryErrorBehavior ?? 'complete';
34
+ }
@@ -31,6 +31,12 @@ export const docs = {
31
31
  description:
32
32
  'The state the form treats as its default, so only the exception shows an optional/required indicator. With "optional", only fields marked isRequired show an indicator; with "required", only fields marked isOptional do. A field that restates the default shows nothing. Under "required" the unmarked fields also expose aria-required so screen readers match the visual default; aria-required only, never the native required attribute. CheckboxInput, Switch and CheckboxList are the exception: an unchecked box, an off switch or an empty group is an answer, so they take no required state from the default. A CheckboxInput or Switch is required only through its own isRequired. Leave unset for today\'s per-field behavior.',
33
33
  },
34
+ {
35
+ name: 'defaultEntryErrorBehavior',
36
+ type: "'complete' | 'blur-or-enter'",
37
+ description:
38
+ "When DateInput, DateTimeInput, TimeInput, and NumberInput fields in the layout show their own entry errors: a date, time, or number the field rejects. It sets when the error shows, not when validation runs, so it is not React Aria's validationBehavior (native versus ARIA validation), and it never changes a caller status. 'complete' shows each error at the field's own moment. 'blur-or-enter' holds the message, aria-invalid, the invalid styling, the announcement, and the onEntryErrorChange report until Enter or blur; an edit that makes the entry valid or empty still clears the error at once. NumberInput shows its errors only at Enter or blur under both values. A field's own entryErrorBehavior wins. A nested FormLayout replaces the default for its fields, and unset there means 'complete'. Content in a layer, such as a Dialog opened from the form, starts without it. Leave unset for 'complete'.",
39
+ },
34
40
  {
35
41
  name: 'children',
36
42
  type: 'ReactNode',
@@ -126,6 +132,12 @@ export const docsZh = {
126
132
  description:
127
133
  '表单视为默认的状态,因此仅例外字段显示可选/必填指示器。设为 "optional" 时,仅标记 isRequired 的字段显示指示器;设为 "required" 时,仅标记 isOptional 的字段显示。与默认一致的字段不显示任何内容。设为 "required" 时,未标记的字段仍会暴露 aria-required,使屏幕阅读器与视觉默认一致——仅作用于 aria-required,不改变原生 required 属性。CheckboxInput、Switch 和 CheckboxList 例外:未勾选的复选框、关闭的开关或空的复选框组本身就是一个回答,因此默认值不会赋予它们必填状态。CheckboxInput 或 Switch 只有通过自身的 isRequired 才会成为必填。不设置则保持当前逐字段行为。',
128
134
  },
135
+ {
136
+ name: 'defaultEntryErrorBehavior',
137
+ type: "'complete' | 'blur-or-enter'",
138
+ description:
139
+ "布局中的 DateInput、DateTimeInput、TimeInput 和 NumberInput 字段何时显示自身的输入错误:即字段拒绝的日期、时间或数字。它设定错误何时显示,而不是何时校验,因此不同于 React Aria 的 validationBehavior(原生校验与 ARIA 校验之分),也不会改变调用方的 status。'complete' 在每个字段自身的时机显示错误。'blur-or-enter' 将消息、aria-invalid、无效样式、播报和 onEntryErrorChange 报告保留到按 Enter 或失焦;使输入有效或为空的编辑仍会立即清除错误。NumberInput 在两种取值下都只在按 Enter 或失焦时显示错误。字段自身的 entryErrorBehavior 优先。嵌套的 FormLayout 会为其字段替换该默认值,未设置时即为 'complete'。图层中的内容(例如从表单打开的 Dialog)不继承该默认值。不设置即为 'complete'。",
140
+ },
129
141
  {
130
142
  name: 'children',
131
143
  type: 'ReactNode',
@@ -271,6 +283,8 @@ export const docsDense = {
271
283
  'Field arrangement. Vertical stacks top-to-bottom; horizontal uses one fractional grid track per field in logical inline order; horizontal-labels places labels on the inline-start side and collapses when the viewport is <=480px.',
272
284
  defaultOptionality:
273
285
  'State the form treats as default, so only the exception is marked. "optional" → only isRequired fields show an indicator; "required" → only isOptional fields do. Under "required" unmarked fields also expose aria-required (aria only, not native required), except CheckboxInput, Switch and CheckboxList, which take no required state from it (CheckboxInput and Switch are required only through their own isRequired). Unset = per-field behavior.',
286
+ defaultEntryErrorBehavior:
287
+ "'complete'|'blur-or-enter': when DateInput/DateTimeInput/TimeInput/NumberInput fields show their own rejections (not when validation runs; not React Aria validationBehavior; never changes status). blur-or-enter: message, aria-invalid, styling, announcement, onEntryErrorChange report wait for Enter/blur; valid or empty entry clears at once. NumberInput waits under both. Field prop wins; nested FormLayout replaces it (unset = complete); layers start without it. Unset = complete.",
274
288
  children:
275
289
  'Form fields to arrange. Accepts Astryx inputs + Field-wrapped custom controls.',
276
290
  xstyle:
@@ -14,6 +14,7 @@
14
14
  * - /packages/core/src/FormLayout/FormLayout.doc.mjs (props table)
15
15
  * - /packages/core/src/FormLayout/index.ts (exports if types change)
16
16
  * - /packages/core/src/Field/FieldLabel.tsx (defaultOptionality indicator resolution)
17
+ * - /packages/core/src/Field/useEntryErrorBehavior.ts (defaultEntryErrorBehavior resolution)
17
18
  * - /apps/storybook/stories/FormLayout.stories.tsx (storybook stories)
18
19
  * - /packages/cli/assets/templates/blocks/components/FormLayout/ (showcase blocks)
19
20
  */
@@ -24,6 +25,7 @@ import * as stylex from '@stylexjs/stylex';
24
25
  import {spacingVars} from '../theme/tokens.stylex';
25
26
  import {
26
27
  FormLayoutContext,
28
+ type EntryErrorBehavior,
27
29
  type FormLayoutDirection,
28
30
  type FormOptionality,
29
31
  } from './FormLayoutContext';
@@ -115,6 +117,25 @@ export interface FormLayoutProps extends BaseProps<HTMLDivElement> {
115
117
  * `'optional'`) shows nothing. An inner `FormLayout` shadows an outer one.
116
118
  */
117
119
  defaultOptionality?: FormOptionality;
120
+
121
+ /**
122
+ * When DateInput, DateTimeInput, TimeInput, and NumberInput fields in this
123
+ * layout show their own entry errors: a date, time, or number that the
124
+ * field rejects. It sets when the error shows, not when validation runs, so
125
+ * it is not React Aria's `validationBehavior` (native versus ARIA
126
+ * validation). It does not change a caller's `status`.
127
+ *
128
+ * - `'complete'` — each field shows the error at its own moment.
129
+ * - `'blur-or-enter'` — each field holds every sign of the error until the
130
+ * person presses Enter or leaves the field.
131
+ * - unset — the same as `'complete'`.
132
+ *
133
+ * NumberInput shows its errors only at Enter or blur under both values.
134
+ * A field's own `entryErrorBehavior` wins. An inner `FormLayout` replaces
135
+ * the default for its fields, and unset there means `'complete'`. Content
136
+ * in a layer, such as a Dialog opened from the form, starts without it.
137
+ */
138
+ defaultEntryErrorBehavior?: EntryErrorBehavior;
118
139
  }
119
140
 
120
141
  // =============================================================================
@@ -143,6 +164,7 @@ export function FormLayout({
143
164
  children,
144
165
  direction = 'vertical',
145
166
  defaultOptionality,
167
+ defaultEntryErrorBehavior,
146
168
  xstyle,
147
169
  className,
148
170
  style,
@@ -150,8 +172,8 @@ export function FormLayout({
150
172
  ...props
151
173
  }: FormLayoutProps) {
152
174
  const contextValue = useMemo(
153
- () => ({direction, defaultOptionality}),
154
- [direction, defaultOptionality],
175
+ () => ({direction, defaultOptionality, defaultEntryErrorBehavior}),
176
+ [direction, defaultOptionality, defaultEntryErrorBehavior],
155
177
  );
156
178
 
157
179
  return (