An open source design system that's fully customizable and agent ready
TypeScript
[Component Audit] DateInput: honor native change actions (#7243)
Cindy Zhang2514d86d02ff
diff --git a/.changeset/date-input-native-change-action.md b/.changeset/date-input-native-change-action.mdnew file mode 100644index 0000000000..5e2e1ad62b--- /dev/null+++ b/.changeset/date-input-native-change-action.md@@ -0,0 +1,7 @@+---+'@astryxdesign/core': patch+---++[fix] DateInput: run changeAction with optimistic busy feedback on the native picker surface++@cixzhangdiff --git a/.github/scripts/accessibility-audit.integration.test.mjs b/.github/scripts/accessibility-audit.integration.test.mjsindex 7e072305e4..4a0f3799bd 100644--- a/.github/scripts/accessibility-audit.integration.test.mjs+++ b/.github/scripts/accessibility-audit.integration.test.mjs@@ -109,6 +109,7 @@ function runFixture(indexContent,components = 'core/Button',readySelector = null,+ stories = null,) {const dir = fs.mkdtempSync(path.join(os.tmpdir(), 'a11y-cli-fixture-'));const storybook = path.join(dir, 'storybook');@@ -135,6 +136,7 @@ function runFixture(...(readySelector == null? []: ['--ready-selector', readySelector]),+ ...(stories == null ? [] : ['--stories', stories]),],{cwd: REPO_ROOT,@@ -168,6 +170,23 @@ const VALID_INDEX = JSON.stringify({},});+const FOCUSED_INDEX = JSON.stringify({+ entries: {+ 'core-button--fixture': {+ id: 'core-button--fixture',+ title: 'Core/Button',+ name: 'Fixture',+ type: 'story',+ },+ 'core-button--other': {+ id: 'core-button--other',+ title: 'Core/Button',+ name: 'Other',+ type: 'story',+ },+ },+});+const PATTERN_INDEX = JSON.stringify({entries: {'a11y-button-pattern--clickable-card-disabled': {@@ -198,6 +217,36 @@ describe.sequential('accessibility-audit CLI readiness', () => {expect(result.report.readySelector).toBe('[role="menu"]');});+ it('audits only the requested owned story', () => {+ const result = runFixture(+ 'delayed',+ FOCUSED_INDEX,+ 'core/Button',+ null,+ 'core-button--fixture',+ );+ expect(result.status).toBe(0);+ expect(result.report.requestedStories).toEqual(['core-button--fixture']);+ expect(result.report.auditedStories.map(story => story.storyId)).toEqual([+ 'core-button--fixture',+ ]);+ });++ it('fails closed when a requested story is not owned by the component', () => {+ const result = runFixture(+ 'delayed',+ FOCUSED_INDEX,+ 'core/Button',+ null,+ 'core-link--missing',+ );+ expect(result.status).not.toBe(0);+ expect(result.stderr).toContain(+ 'Requested stories did not resolve in the selected component scope: core-link--missing',+ );+ expect(result.report).toBeNull();+ });+it('fails closed when a focused readiness selector stays absent', () => {const result = runFixture('selector-missing',diff --git a/.github/scripts/accessibility-audit.js b/.github/scripts/accessibility-audit.jsindex ca62e578ee..daebdebb9d 100644--- a/.github/scripts/accessibility-audit.js+++ b/.github/scripts/accessibility-audit.js@@ -5,7 +5,8 @@/*** @description Runs accessibility audits on component stories using axe-core* @input --storybook-dir <path> --output <file> [--components <comma-separated>]- * [--port <number>] [--ready-selector <css-selector>]+ * [--stories <comma-separated-story-ids>] [--port <number>]+ * [--ready-selector <css-selector>]* --baseline <path> (compare violations against a checked-in baseline)* --fail-on-new (exit 1 when violations not present in the baseline exist)* --update-baseline (rewrite the baseline file from this run's report)@@ -55,11 +56,16 @@ if (!Number.isInteger(port) || port < 1 || port > 65535) {}const componentsArg = getArg('components');const components = (componentsArg || '').split(',').filter(Boolean);+const storiesArg = getArg('stories');+const requestedStories = (storiesArg || '').split(',').filter(Boolean);// --components present but EMPTY means the caller derived an explicit empty// audit set (pr-a11y on a PR whose core/src changes map to no component —// e.g. a shared test file). Audit nothing and pass. Only an ABSENT flag// means "all stories" (the a11y-weekly contract).const emptyComponentSet = componentsArg !== null && components.length === 0;+if (storiesArg !== null && requestedStories.length === 0) {+ throw new Error('--stories requires at least one story id');+}const baselineFile = getArg('baseline');const readySelector = getArg('ready-selector');const failOnNew = hasFlag('fail-on-new');@@ -257,10 +263,24 @@ async function runAccessibilityAudit() {console.log(`Owner route: ${owner} -> ${ownedStoryIds.join(', ')}`);}const routedIds = new Set(routed.storyIds);+ const requestedStoryIds = new Set(requestedStories);const relevantStories = storyIds.filter(id => {if (id.endsWith('--docs')) return false;- return routedIds.has(id);+ return (+ routedIds.has(id) &&+ (storiesArg === null || requestedStoryIds.has(id))+ );});+ if (storiesArg !== null) {+ const unresolvedStories = requestedStories.filter(+ id => !relevantStories.includes(id),+ );+ if (unresolvedStories.length > 0) {+ throw new Error(+ `Requested stories did not resolve in the selected component scope: ${unresolvedStories.join(', ')}`,+ );+ }+ }// Group stories for scanning while retaining the legacy display identity for// safe baseline migration.@@ -462,6 +482,7 @@ async function runAccessibilityAudit() {}const report = {+ requestedStories,readySelector,ownerStoryRoutes: routed.ownerStoryRoutes,ownerStoryKeys,diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.ymlindex 282f49ff1c..3f4d8de465 100644--- a/.github/workflows/ci.yml+++ b/.github/workflows/ci.yml@@ -1696,6 +1696,33 @@ jobs:retention-days: 30if-no-files-found: error+ # DateInput's open-state audit story uses a play function to open the+ # popover. Restricting this focused pass to that story lets the selector+ # wait bind axe to the Calendar dialog without making every DateInput story+ # require an open overlay.+ - name: Run DateInput audit browser evidence+ if: github.event_name == 'pull_request' && startsWith(github.event.pull_request.title, '[Component Audit] DateInput:')+ env:+ ASTRYX_HEAD_SHA: ${{ github.event.pull_request.head.sha }}+ run: |+ node .github/scripts/accessibility-audit.js \+ --storybook-dir apps/storybook/dist \+ --output date-input-a11y-report.json \+ --components DateInput \+ --stories core-dateinput--open-calendar-audit \+ --ready-selector '[role="dialog"]' \+ --baseline .github/a11y-baseline.json \+ --fail-on-new++ - name: Upload DateInput audit evidence+ if: always() && github.event_name == 'pull_request' && startsWith(github.event.pull_request.title, '[Component Audit] DateInput:')+ uses: actions/upload-artifact@v7+ with:+ name: date-input-audit-evidence-${{ needs.build-storybook.outputs.short_hash }}+ path: date-input-a11y-report.json+ retention-days: 30+ if-no-files-found: error+# The CheckboxList and CheckboxListItem component audits grade the same# option rows: interactive row paint, focus, busy, disabled, read-only,# status, narrow, forced-colors, and RTL states from exact-head Chromiumdiff --git a/apps/storybook/rtl-audit/targets.json b/apps/storybook/rtl-audit/targets.jsonindex 6b12d1dd1b..72f551ad39 100644--- a/apps/storybook/rtl-audit/targets.json+++ b/apps/storybook/rtl-audit/targets.json@@ -129,6 +129,15 @@"next": "button[aria-label=\"Next month\"]"}},+ {+ "component": "DateInput",+ "storyId": "core-dateinput--clearable",+ "dims": ["D2"],+ "selectors": {+ "prev": "button[aria-label=\"Open calendar\"]",+ "next": "button[aria-label=\"Clear Event date\"]"+ }+ },{"component": "Carousel","storyId": "core-carousel--default",diff --git a/apps/storybook/stories/DateInput.stories.tsx b/apps/storybook/stories/DateInput.stories.tsxindex e6e9b306de..f7650bc5da 100644--- a/apps/storybook/stories/DateInput.stories.tsx+++ b/apps/storybook/stories/DateInput.stories.tsx@@ -440,7 +440,39 @@ export const WithSuccessStatus: Story = {},};+export const OpenCalendarAudit: Story = {+ tags: ['visual-theme-matrix'],+ render: args => {+ const [value, setValue] = useState<ISODateString | undefined>(+ '2026-01-25' as ISODateString,+ );+ return <DateInput {...args} value={value} onChange={setValue} />;+ },+ args: {+ label: 'Appointment date',+ presentation: 'popover',+ },+ play: async ({canvasElement}) => {+ const input =+ canvasElement.querySelector<HTMLInputElement>('[role="combobox"]');+ if (input == null) {+ throw new Error('DateInput audit fixture is missing its combobox');+ }+ input.click();+ await new Promise<void>(resolve =>+ requestAnimationFrame(() => requestAnimationFrame(() => resolve())),+ );+ if (input.getAttribute('aria-expanded') !== 'true') {+ throw new Error('DateInput audit fixture did not open its calendar');+ }+ if (canvasElement.ownerDocument.querySelector('[role="dialog"]') == null) {+ throw new Error('DateInput audit fixture rendered no Calendar dialog');+ }+ },+};+export const AllVariations: Story = {+ tags: ['visual-theme-matrix'],render: () => {const [value1, setValue1] = useState<ISODateString | undefined>(undefined);const [value2, setValue2] = useState<ISODateString | undefined>(diff --git a/packages/core/src/DateInput/DateInput.doc.mjs b/packages/core/src/DateInput/DateInput.doc.mjsindex 5c7bb74913..3e140bb5df 100644--- a/packages/core/src/DateInput/DateInput.doc.mjs+++ b/packages/core/src/DateInput/DateInput.doc.mjs@@ -93,7 +93,7 @@ export const docs = {},{name: 'dateConstraints',- type: 'Array<(date: Date) => boolean>',+ type: 'ReadonlyArray<(date: Date) => boolean>',description:'Array of custom constraint functions that disable specific dates.',},@@ -146,7 +146,7 @@ export const docs = {name: 'weekStartsOn',type: "0 | 1 | 2 | 3 | 4 | 5 | 6 | 'sun' | 'mon' | 'tue' | 'wed' | 'thu' | 'fri' | 'sat'",description:- 'First day of week in the calendar popover. A number (0 = Sunday to 6 = Saturday) or a three-letter day name.',+ 'First day of week in Astryx calendar surfaces. A number (0 = Sunday to 6 = Saturday) or a three-letter day name; native pickers remain browser/OS-owned.',default: '0',},{@@ -407,7 +407,7 @@ export const docsZh = {},{name: 'dateConstraints',- type: 'Array<(date: Date) => boolean>',+ type: 'ReadonlyArray<(date: Date) => boolean>',description: '自定义约束函数数组,用于禁用特定日期。',},{@@ -439,6 +439,12 @@ export const docsZh = {type: 'string',description: '通过标签末尾的信息图标显示的提示文本。',},+ {+ name: 'hasClear',+ type: 'boolean',+ description: '有日期值时显示清除按钮。点击后清除日期。',+ default: 'false',+ },{name: 'numberOfMonths',type: '1 | 2',@@ -449,7 +455,7 @@ export const docsZh = {name: 'weekStartsOn',type: "0 | 1 | 2 | 3 | 4 | 5 | 6 | 'sun' | 'mon' | 'tue' | 'wed' | 'thu' | 'fri' | 'sat'",description:- '日历弹出层中每周的起始日。可为数字(0=周日……6=周六)或三字母星期缩写。',+ 'Astryx 日历表面中每周的起始日。可为数字(0=周日……6=周六)或三字母星期缩写;原生选择器仍由浏览器或操作系统控制。',default: '0',},{@@ -473,6 +479,12 @@ export const docsZh = {"已弃用:请使用 presentation('touch'='adaptive-native'、'always'='native'、'never'='adaptive-bottom-sheet')。仍按已发布行为工作;同时设置时以 presentation 为准。",default: "'touch'",},+ {+ name: 'width',+ type: 'SizeValue',+ description:+ '字段宽度(数字按像素处理,字符串按原样使用,例如 “100%”)。统一调整标签、控件和状态消息的宽度。',+ },{name: 'xstyle',type: 'StyleXStyles',diff --git a/packages/core/src/DateInput/DateInput.spec.md b/packages/core/src/DateInput/DateInput.spec.mdnew file mode 100644index 0000000000..d9479dcd1a--- /dev/null+++ b/packages/core/src/DateInput/DateInput.spec.md@@ -0,0 +1,300 @@+---+schema_version: 3+template_version: 7+kind: component+id: component:DateInput+authority: draft+archive_reason: null+superseded_by: null+approved_by: null+approved_at: null+owners: [cixzhang]+review_triggers: [public-api, behavior, layout, theming, accessibility]+verified_by:+ [+ packages/core/src/DateInput/DateInput.test.tsx,+ packages/core/src/DateInput/DateInputTouch.test.tsx,+ packages/core/src/DateInput/NativeDateField.test.tsx,+ packages/core/src/DateInput/Presentation.test.tsx,+ packages/core/src/theme/themingTargets.test.ts,+ scripts/check-knowledge.mjs,+ ]+modules: []+families: [family:input-fields, family:overlay-dismissal]+design_specs: []+architecture:+ [+ architecture:component-theming-surface,+ architecture:interaction-modality,+ architecture:public-component-api,+ ]+contributing: []+system_specs: [spec:AST-043]+---++# DateInput component contract++This draft records shipped behavior plus one objective conformance fix already settled+by `family:input-fields/FR6`. It does not approve a new public API, default,+compatibility promise, ownership boundary, or visual direction.++## Contract at a glance++| Area | Contract |+| ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |+| Public contract | API shape and defaults remain unchanged. The native-picker surface now follows the existing `changeAction` order, optimistic-value, and busy-feedback contract. |+| Behavior | `presentation` selects the picker surface; an omitted value remains `adaptive-native`; `presentation` wins over deprecated `nativePicker`; every committed path emits the same controlled ISO-date value and action feedback. |+| End-user impact | People can type or pick one date using a surface suited to the primary pointer; native-picker saves now run instead of being silently dropped. |+| Builder impact | Existing native DateInput `changeAction` handlers now run after `onChange` and receive optimistic busy feedback. No API or migration work is required. |+| Compatibility/readiness | Compatible patch correction under the current input-field family rule. Released defaults and controlled ownership are preserved; exact-head browser evidence remains audit evidence rather than product authority. |+| Review checks | Reject a surface-mapping change, lost constraint, callback-order change, unlabeled field, unreachable disabled reason, changed close behavior, or a theming target placed on the wrong owner. |+| Governing rules | `spec:AST-043/FR1–FR5`; `family:input-fields/FR1–FR6, FR8–FR9`; `family:overlay-dismissal/FR1–FR7`, including its recorded BottomSheet adoption gap; the three architecture records linked above. |++This table is a review projection; the body below is authoritative only after this+record becomes `current`.++## Intent++DateInput presents one controlled calendar date through a labeled input-field+surface. A person may type the value or use a Calendar, bottom-sheet calendar, or+browser/OS date picker selected by the public presentation contract.++## Compatibility and migration++- Released default preserved: `yes`+- Compatibility class: compatible patch; no API shape or default changes, and the native+ surface now adopts the existing `changeAction` contract instead of dropping it+- Controlled/uncontrolled behavior: unchanged; DateInput remains controlled by+ `value`, with `undefined` representing no selected date+- Migration decision: `spec:AST-043/DEC-1` and `spec:AST-043/DEC-2` own the+ `presentation` vocabulary, default, deprecated `nativePicker` mapping, and+ precedence++Consumer migration instructions belong in consumer docs and release notes.++## Ownership boundary++**Owns**++- Selecting the pointer, bottom-sheet, or native field surface from the resolved+ public presentation.+- Parsing typed dates, formatting committed dates, enforcing DateInput constraints,+ and emitting one controlled ISO date or `undefined`.+- The DateInput field wrapper, calendar-toggle affordance, clear composition, and+ focus handoff between those controls and the selected picker surface.+- DateInput-specific composition of Field, Calendar, Popover, BottomSheet, and the+ browser/OS date control.++**Does not own / non-goals**++- Label, description, status, disabled-reason, width, and shared clear-button+ presentation — owned by `component:Field`, `component:FieldStatus`, and+ `family:input-fields`.+- Calendar-grid dates, navigation, and selection semantics — owned by+ `component:Calendar`.+- Popover hosting and topmost dismissal — owned by `component:Popover` and+ `family:overlay-dismissal`.+- Bottom-sheet hosting and dismissal — owned by `component:BottomSheet` and the+ overlay-dismissal family. The bottom-sheet surface inherits BottomSheet's recorded+ shared-dismissal adoption gap.+- Cross-component picker vocabulary and deprecated-prop migration — owned by+ `spec:AST-043`.+- Browser/OS picker appearance, locale, momentum, or hit areas.++## Public concepts++| Concept | Closed values or states | Meaning | Availability by variant/orientation/state | Default | Owner | Stability | Invalid-value behavior |+| ----------------------- | ------------------------------------------------------------------------------- | ---------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | ----------------- | ----------------------------------------------- | -------------------- | --------------------------------------------------------------------------------------- |+| selected date | `undefined` or `YYYY-MM-DD` ISO date | Controlled committed calendar date | Every surface | `undefined` | `component:DateInput` | stable | Types reject other values; unparseable typed text is announced and reverts on commit |+| presentation | `popover`, `bottom-sheet`, `native`, `adaptive-bottom-sheet`, `adaptive-native` | Surface that collects the date | Every pointer; adaptive values resolve by primary pointer | `adaptive-native` | `spec:AST-043` | stable | Types reject other values; DateInput has no text-only presentation |+| legacy native selection | `touch`, `always`, `never` | Deprecated mapping to the released picker behavior | Used only when `presentation` is absent | `touch` behavior | `spec:AST-043` | deprecated, retained | `presentation` wins when both props are present |+| committed display | `date`, `date_long`, `date_weekday`, `system_date`, or formatter function | Display shape for the committed ISO date | Closed field on every surface; never rewrites in-progress typed text | `date_long` | `component:DateInput` | stable | Function output is displayed; unparsable output cannot be re-committed as typed text |+| selectable range | optional `min`, `max`, and date-constraint predicates | Dates that may commit | Every surface; native surfaces validate on commit when the OS cannot disable them | unbounded | `component:DateInput` with `component:Calendar` | stable | A rejected date does not replace the controlled value and is announced where applicable |+| calendar configuration | one or two popover months; week start Sunday through Saturday | Calendar-grid layout | Week start applies to popover and bottom-sheet surfaces; month count applies only to the popover; neither is expressible by native pickers | one month, Sunday | `component:DateInput` with `component:Calendar` | stable | Types close the value set |+| field state | enabled, disabled, disabled with reason, busy, optional, required, status | Shared field semantics and supporting presentation | Every surface, with surface-specific control mechanics | enabled, not busy | `family:input-fields` | stable | Conflicting optional/required resolution follows the shared Field owner |+| clear affordance | absent or present while a committed value exists | Emits `undefined` and preserves the field interaction path | Every surface when `hasClear` and a value are present; hidden while disabled or busy | absent | `component:DateInput` with `component:Field` | stable | No control renders when there is no value |+| field shell | standalone Field or admitted InputGroup child | Ownership of label, status, and outer geometry | Pointer surface supports both; other surfaces preserve the same public field semantics | standalone | `family:input-fields` | stable | InputGroup context selects grouped adaptation |++## Behavioral and layout contract++Draft requirements identify their evidence basis; they do not turn observation into+approved policy.++| ID | Candidate invariant | Basis | Draft review state |+| ---- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------- | ----------------------------------------- |+| FR1 | DateInput MUST present the controlled ISO `value` and emit `onChange` with the next ISO date or `undefined` without maintaining a competing committed value. | Current source, docs, and focused tests | Verified shipped behavior |+| FR2 | The five `presentation` values MUST resolve to the fine/coarse surfaces in `spec:AST-043/FR1`; omitting both presentation props MUST preserve `adaptive-native`. | `spec:AST-043/FR1–FR3`; Presentation tests | Settled by current system authority |+| FR3 | Explicit `presentation` MUST outrank deprecated `nativePicker`; the legacy values MUST retain their mappings and development-only warning from `spec:AST-043/FR3–FR4`. | Current source, docs, and Presentation tests | Settled by current system authority |+| FR4 | Adaptive resolution MUST use the primary pointer rather than viewport width or any-pointer availability, so tablets receive a touch surface and touchscreen laptops retain the typable field. | Current source, consumer docs, and surface-selection tests | Verified shipped behavior |+| FR5 | Text, Calendar, bottom-sheet, and native commit paths MUST enforce `min`, `max`, and `dateConstraints`; a rejected value MUST NOT replace the controlled value. | Current source and all four focused suites | Verified shipped behavior |+| FR6 | Named committed formats MUST follow the InternationalizationProvider locale and shared Timestamp vocabulary; formatting MUST NOT rewrite in-progress typed text. | Current source, docs, locale tests, `spec:AST-043/FR5` | Verified shipped behavior |+| FR7 | Every value-change path MUST call `onChange` before `changeAction`, present the proposed value optimistically, and expose one busy state while the Action is pending. | `family:input-fields/FR6`; current source and focused tests | Settled shared rule and verified adoption |+| FR8 | The pointer field MUST open its Calendar from the input, calendar toggle, ArrowDown, or Alt+ArrowDown; Popover dismissal and focus return MUST remain owned by the shared Popover path. | Current source, Popover composition, keyboard/focus tests | Verified shipped behavior |+| FR9 | A pointer-surface Calendar selection MUST commit and close its Popover; a bottom-sheet Calendar selection MUST remain editable in the open sheet until Save closes the surface. | Current source and pointer/touch tests | Verified shipped behavior |+| FR10 | Standalone mode MUST compose Field; admitted InputGroup mode MUST remove competing Field chrome while preserving name, description, value, keyboard, focus, and editing semantics. | `family:input-fields/FR3`; current source and InputGroup tests | Settled shared rule and verified adoption |+| FR11 | Clear MUST emit `undefined` through the ordinary change pipeline. The pointer and bottom-sheet surfaces restore field focus using their shipped timing; the native surface MUST NOT reclaim focus because doing so reopens the OS picker. | Current source and focused clear tests | Verified shipped behavior |+| FR12 | Disabled-with-reason MUST remain focusable enough to expose its explanation while blocking mutation. Ordinary disabled and explicit-loading states remain inactive. During a pending Action, pointer and bottom-sheet surfaces remain inactive; the native surface stays focusable so the OS picker remains attached but rejects additional commits until the Action settles. | `family:input-fields/FR4–FR6`; current source and focused tests | Settled shared rule and verified adoption |++### Allowed variation++- **AV1 — Field presentation.** Label visibility, description, required/optional+ indicators, status placement, size, explicit width, and supported InputGroup+ composition may vary without changing the selected date.+- **AV2 — Date reachability.** Bounds, custom predicates, week start, month count,+ placeholder, and committed display format may vary within their public domains.+- **AV3 — Surface selection.** A caller may force any supported surface or retain the+ adaptive default; the resulting date value and shared field semantics remain the+ same.+- **AV4 — Theme output.** Themes may restyle admitted DateInput targets while shared+ Field, Calendar, Popover, BottomSheet, Icon, and clear-button owners retain their+ own targets and semantics.++### Representative states++| State | Required invariant | Allowed variation |+| ------------------ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------- |+| empty rest | Labelled field shows the placeholder and calendar affordance without a committed value. | Label, placeholder, size, width |+| committed rest | Field displays the controlled value in the selected committed format. | Format and locale |+| typing | Raw typed text remains visible until commit or reversion. | Parseable text form and locale |+| invalid typed text | Field reflects invalid state, announces the error, and preserves the prior committed value. | Invalid text |+| constrained date | Unreachable dates cannot commit on any surface. | Bound or predicate source |+| popover open | Input reflects expanded dialog state and the Calendar is reachable by pointer and keyboard. | Month count and week start |+| bottom sheet open | Touch calendar remains open across date corrections until Save. | Visible month and wheel state |+| native open/closed | Real date input retains its labelled controlled value while the browser/OS owns picker chrome. | Engine-provided picker |+| disabled | Mutation and activation are blocked. | With or without a reason |+| busy | `aria-busy` and one Spinner expose the save. New commits are blocked; the native picker stays focusable and may move its transient OS highlight without emitting another change. | Explicit loading or pending Action |+| clearable | A committed value has one labelled clear action that emits `undefined`. | Surface and value |+| status | Error, warning, or success remains named and uses shared status presentation. | Status type, message, placement |+| InputGroup | Group owns outer field chrome while DateInput preserves its field semantics. | Group prefix or suffix content |++### Transformation and precedence order++- **ORD1 — Surface.** Resolve explicit `presentation`; otherwise map deprecated+ `nativePicker`; otherwise use `adaptive-native`; then resolve adaptive values from+ the primary pointer.+- **ORD2 — Display.** While editing, display pending typed text; otherwise format the+ controlled or optimistic ISO value with the selected format and provider locale.+- **ORD3 — Commit.** Parse or receive the proposed date, reject it when constrained,+ call `onChange`, then start `changeAction` with the same proposed value and busy+ presentation.+- **ORD4 — Clear.** Emit `undefined` through ORD3, then apply the selected surface's+ shipped focus policy: pointer and bottom-sheet fields reclaim focus, while the native+ field does not reopen the OS picker.++### Performance and resources++- **PR1 — Bounded calendar window.** The bottom-sheet calendar mounts a bounded window+ of month panes around the visible month rather than the complete reachable century.+- **PR2 — Scroll work.** Scroll-driven measurement and selection updates remain+ animation-frame throttled or settle-driven; listeners, frames, timers, and observers+ are cleaned up on deactivation or unmount.++## Accessibility contract++- **AR1 — Field relationships.** Every surface keeps an accessible label; required,+ description, status, disabled-reason, and busy relationships remain programmatically+ exposed through the shared Field contract.+- **AR2 — Pointer combobox.** The typable field exposes combobox state and a dialog+ popup; ArrowDown and Alt+ArrowDown open it, Escape dismisses it outside active IME+ composition, and focus is not reclaimed from an intentional destination.+- **AR3 — Validation.** Invalid typed or native selections are exposed without color+ alone; rejected typed input uses an assertive alert and native rejection remains+ described to assistive technology.+- **AR4 — Disabled reason.** A disabled field with a reason remains focusable and+ described while all value mutation and picker activation stay blocked.+- **AR5 — Native control.** The browser/OS date input remains the labelled value owner;+ the painted committed-value overlay is excluded from the accessibility tree.+- **AR6 — Touch calendar.** The bottom-sheet Calendar preserves one reachable day per+ month, arrow-key date movement, named weekday columns, selected/today semantics,+ single-tab-stop wheels, and exactly one reachable footer action for the visible+ surface.+- **AR7 — Directionality.** DateInput's own calendar and clear controls exchange logical+ inline sides in RTL while preserving their labels and meanings; Calendar navigation+ remains owned and verified by `component:Calendar`.++## Design relationships++| Anatomy or state | Design requirement | Representation authority | Hierarchy role | Component contract |+| -------------------------------- | -------------------------------------------------------------------------------- | ------------------------------------------- | -------------- | ------------------ |+| Label and supporting text | Shared Field hierarchy surrounds one coherent input boundary. | `family:input-fields` and `component:Field` | Supporting | FR10, AR1 |+| Field surface | One stable bordered input surface contains value and end controls. | `family:input-fields/FR1–FR2` | Prominent | FR1, FR7, FR10 |+| Calendar affordance | Communicates the picker path without replacing typed entry. | Current source and consumer docs | Supporting | FR8 |+| Calendar popover | Presents date selection while preserving Field ownership. | `component:Calendar`, `component:Popover` | Prominent | FR5, FR8–FR9 |+| Bottom-sheet calendar | Presents the same date contract for a coarse pointer. | Current source and `spec:AST-043` | Prominent | FR2, FR4, FR9 |+| Native picker | Hands picker chrome to the browser/OS while retaining DateInput field semantics. | `spec:AST-043`, browser/OS | Prominent | FR2–FR6, AR5 |+| Clear, busy, and status controls | Use the shared input-family end-control and status relationships. | `family:input-fields` and shared primitives | Supporting | FR7, FR11–FR12 |++### Theming anatomy++<!-- anatomy-theming:v1 -->++```json+{+ "Label": {+ "delegatesTo": {"owner": "component:Field", "target": "field-label"}+ },+ "Text input": {"target": "date-input"},+ "Calendar icon": {"target": "date-input-toggle-icon"},+ "Calendar popover": {+ "delegatesTo": {"owner": "component:Popover", "target": "popover"}+ },+ "Clear button": {+ "delegatesTo": {"owner": "component:Field", "target": "input-clear-button"}+ },+ "Status message": {+ "delegatesTo": {"owner": "component:FieldStatus", "target": "field-status"}+ }+}+```++The `date-input` target owns the composite field surface. The+`date-input-toggle-icon` target reflects collapsed and expanded states on the icon+itself. The deprecated `date-input-clear-icon` alias remains compatibility metadata;+the shared `input-clear-icon` target owns current clear-glyph theming.++## Family and system relationships++- `family:input-fields` owns stable field sizing, end-control space, grouped+ adaptation, disabled reasons, loading, Transition Actions, status placement, and+ the iOS-only focus-zoom floor; DateInput adopts every listed concept.+- `family:overlay-dismissal` owns topmost Popover and BottomSheet dismissal. DateInput's+ Popover path uses the shared owner; its bottom-sheet path inherits BottomSheet's+ recorded adoption gap. DateInput owns only selection, open-state requests, and focus+ policy.+- `spec:AST-043` owns the picker presentation vocabulary, default, native fallback,+ deprecated mapping, and precedence.+- `architecture:component-theming-surface` owns target admission, painting-element+ placement, state reflection, and anatomy mapping.+- `architecture:interaction-modality` owns input-modality principles; DateInput uses+ the primary pointer to choose an interaction surface rather than a width breakpoint.+- `architecture:public-component-api` owns the package/export and public-prop boundary.++## Verification map++| Contract | Verification | Representative states | Mutation or failure expectation | Audit section |+| ---------------------------------------------------- | ------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | ------------------------------- |+| FR1, FR5–FR8, FR10–FR12; AR1–AR4 | `DateInput.test.tsx` | empty, valued, typing, invalid, constrained, open, disabled, busy, clear, status, grouped | Value, callbacks, ARIA, disabled guard, focus, or shared-field composition drifts | `audit:DateInput/pointer-field` |+| FR2–FR4 | `Presentation.test.tsx`, `NativeDateField.test.tsx`, `DateInputTouch.test.tsx` | every presentation, omitted props, every deprecated mapping, dual props, fine/coarse, touchscreen laptop | A value resolves to the wrong surface, width affects modality, or legacy behavior wins incorrectly | `audit:DateInput/presentation` |+| FR5–FR7; AR1, AR3–AR5 | `NativeDateField.test.tsx` | empty, valued, focused, constrained, disabled, clear, formatted, locale | Native commit, overlay, label, constraint, or focus reconciliation drifts | `audit:DateInput/native` |+| FR1, FR4–FR7, FR9, FR11–FR12; AR1, AR4, AR6; PR1–PR2 | `DateInputTouch.test.tsx` | closed/open, month grid, selection correction, wheels, bounds, keyboard, swipe, mouse drag, clear, busy | Touch value parity, bounded rendering, focus, semantics, or gesture ownership drifts | `audit:DateInput/touch` |+| FR2–FR3, FR6 | `DateInput.doc.mjs`, Storybook controls, `scripts/check-knowledge.mjs` | five presentation values, deprecated prop, named formats, English and Chinese docs | Source, docs, types, or default mappings disagree | `audit:DateInput/docs-api` |+| Theming anatomy | `DateInput.test.tsx`, `themingTargets.test.ts`, generated probe theme | root size/status/disabled, toggle state, shared clear target | Target class or state is missing, undocumented, or placed on the wrong element | `audit:DateInput/theming` |+| FR8; AR2 | `apps/storybook/stories/DateInput.stories.tsx`, component-scoped axe | open Calendar dialog plus closed field states | Important popup semantics stay unreachable to the browser audit | `audit:DateInput/a11y` |+| AR7 | `apps/storybook/rtl-audit/targets.json`, component RTL audit | calendar and clear controls in LTR and RTL | DateInput-owned controls fail to exchange logical inline order | `audit:DateInput/rtl` |++## Decision log++No component-local decision is created by this observational draft. The governing+presentation decisions remain in `spec:AST-043/DEC-1` through `DEC-3`.++## Open questions++None. Any future API, compatibility, ownership, or subjective visual change requires+its canonical current owner; this draft records only shipped behavior.++## Content boundary++This file does not duplicate consumer prop tables or examples, current audit results,+implementation steps, Calendar/Popover/BottomSheet internals, or input-family and+presentation-system rules. It links to those owners and records only DateInput's+observable composition and current evidence boundaries.diff --git a/packages/core/src/DateInput/DateInput.test.tsx b/packages/core/src/DateInput/DateInput.test.tsxindex b6e612432a..f621f25241 100644--- a/packages/core/src/DateInput/DateInput.test.tsx+++ b/packages/core/src/DateInput/DateInput.test.tsx@@ -16,6 +16,7 @@ import {fireEvent,waitFor,within,+ act,} from '@testing-library/react';import userEvent from '@testing-library/user-event';import {getButton, queryButton} from '../__tests__/fastRoleQueries';@@ -222,6 +223,34 @@ describe('DateInput', () => {expect(onChange).toHaveBeenCalledWith('2026-03-15');});+ it('runs changeAction after onChange for a typed date', async () => {+ const calls: string[] = [];+ let resolveAction: () => void = () => {};+ const changeAction = vi.fn(+ async () =>+ new Promise<void>(resolve => {+ calls.push('changeAction');+ resolveAction = resolve;+ }),+ );+ const onChange = vi.fn(() => calls.push('onChange'));+ render(+ <DateInput+ label="Date"+ onChange={onChange}+ changeAction={changeAction}+ />,+ );++ const input = screen.getByRole('combobox');+ fireEvent.change(input, {target: {value: '03/15/2026'}});++ expect(calls).toEqual(['onChange', 'changeAction']);+ expect(changeAction).toHaveBeenCalledExactlyOnceWith('2026-03-15');+ expect(input).toHaveAttribute('aria-busy', 'true');+ await act(async () => resolveAction());+ });+// --- P0: Text input respects min/max/dateConstraints ---it('does not call onChange when typed date is before min', () => {diff --git a/packages/core/src/DateInput/DateInput.tsx b/packages/core/src/DateInput/DateInput.tsxindex 97a2f75dc4..ba20f5ca06 100644--- a/packages/core/src/DateInput/DateInput.tsx+++ b/packages/core/src/DateInput/DateInput.tsx@@ -31,7 +31,6 @@ import {radiusVars,typographyVars,typeScaleVars,- borderVars,} from '../theme/tokens.stylex';import {Field,diff --git a/packages/core/src/DateInput/DateInputTouch.test.tsx b/packages/core/src/DateInput/DateInputTouch.test.tsxindex f07301fbe4..403f658852 100644--- a/packages/core/src/DateInput/DateInputTouch.test.tsx+++ b/packages/core/src/DateInput/DateInputTouch.test.tsx@@ -42,7 +42,6 @@ import {useState} from 'react';import type {ISODateString} from '../utils';import {InputGroup} from '../InputGroup';import {InternationalizationProvider} from '../i18n';-import {stableClassName} from '../naming';import {DateInput} from './DateInput';import {toMonthIndex,diff --git a/packages/core/src/DateInput/NativeDateField.test.tsx b/packages/core/src/DateInput/NativeDateField.test.tsxindex 39b1908add..0c09d68cb4 100644--- a/packages/core/src/DateInput/NativeDateField.test.tsx+++ b/packages/core/src/DateInput/NativeDateField.test.tsx@@ -20,7 +20,7 @@*/import {describe, it, expect, vi, beforeEach, afterEach} from 'vitest';-import {render, screen, fireEvent} from '@testing-library/react';+import {render, screen, fireEvent, act} from '@testing-library/react';import {DateInput} from './DateInput';import type * as NativeDateSegments from './nativeDateSegments';import {@@ -196,6 +196,48 @@ describe('DateInput nativePicker', () => {expect(onChange).toHaveBeenCalledExactlyOnceWith('2026-03-21');});+ it('runs changeAction after onChange and exposes the pending state', async () => {+ stubPointer(true);+ const calls: string[] = [];+ let resolveAction: () => void = () => {};+ const changeAction = vi.fn(+ async () =>+ new Promise<void>(resolve => {+ calls.push('changeAction');+ resolveAction = resolve;+ }),+ );+ const onChange = vi.fn(() => calls.push('onChange'));+ render(+ <DateInput+ label="Date"+ onChange={onChange}+ changeAction={changeAction}+ />,+ );++ fireEvent.change(getInput(), {target: {value: '2026-03-21'}});++ expect(calls).toEqual(['onChange', 'changeAction']);+ expect(changeAction).toHaveBeenCalledExactlyOnceWith('2026-03-21');+ expect(getInput()).not.toBeDisabled();+ expect(getInput()).toHaveAttribute('aria-busy', 'true');+ expect(screen.getByRole('status', {name: 'Loading'})).toBeInTheDocument();+ expect(screen.getByText('March 21, 2026')).toBeInTheDocument();++ fireEvent.change(getInput(), {target: {value: '2026-03-22'}});+ expect(onChange).toHaveBeenCalledTimes(1);+ expect(changeAction).toHaveBeenCalledTimes(1);+ expect(screen.getByText('March 21, 2026')).toBeInTheDocument();++ await act(async () => resolveAction());++ fireEvent.change(getInput(), {target: {value: '2026-03-22'}});+ expect(onChange).toHaveBeenCalledTimes(2);+ expect(changeAction).toHaveBeenNthCalledWith(2, '2026-03-22');+ await act(async () => resolveAction());+ });+it('fires onChange with undefined when the control is emptied', () => {stubPointer(true);const onChange = vi.fn();@@ -529,6 +571,36 @@ describe('DateInput nativePicker', () => {expect(getInput()).not.toHaveFocus();});+ it('runs clear through changeAction after onChange', async () => {+ stubPointer(true);+ const calls: string[] = [];+ let resolveAction: () => void = () => {};+ const changeAction = vi.fn(+ async () =>+ new Promise<void>(resolve => {+ calls.push('changeAction');+ resolveAction = resolve;+ }),+ );+ const onChange = vi.fn(() => calls.push('onChange'));+ render(+ <DateInput+ label="Date"+ value="2026-03-21"+ hasClear+ onChange={onChange}+ changeAction={changeAction}+ />,+ );++ fireEvent.click(screen.getByLabelText('Clear Date'));++ expect(calls).toEqual(['onChange', 'changeAction']);+ expect(changeAction).toHaveBeenCalledExactlyOnceWith(undefined);+ expect(screen.getByRole('status', {name: 'Loading'})).toBeInTheDocument();+ await act(async () => resolveAction());+ });+it('disables the control and its toggle when isDisabled', () => {stubPointer(true);render(<DateInput label="Date" isDisabled onChange={() => {}} />);diff --git a/packages/core/src/DateInput/NativeDateField.tsx b/packages/core/src/DateInput/NativeDateField.tsxindex 945c5af323..6edcf65310 100644--- a/packages/core/src/DateInput/NativeDateField.tsx+++ b/packages/core/src/DateInput/NativeDateField.tsx@@ -26,7 +26,15 @@* - /packages/core/src/DateInput/NativeDateField.test.tsx (tests)*/-import {useCallback, useEffect, useId, useRef, useState} from 'react';+import {+ useCallback,+ useEffect,+ useId,+ useOptimistic,+ useRef,+ useState,+ useTransition,+} from 'react';import * as stylex from '@stylexjs/stylex';import {useCalendarConstraints} from '../Calendar';import type {DateInputProps} from './DateInput';@@ -53,6 +61,7 @@ import {colorVars,radiusVars,sizeVars,+ spacingVars,typeScaleVars,typographyVars,} from '../theme/tokens.stylex';@@ -72,7 +81,7 @@ import {const styles = stylex.create({wrapper: {- gap: 8,+ gap: spacingVars['--spacing-2'],},iconButton: {display: 'flex',@@ -245,6 +254,7 @@ export function NativeDateField({disabledMessage,value,onChange,+ changeAction,isLoading = false,min,max,@@ -284,6 +294,13 @@ export function NativeDateField({const mergedInputRef = useMergedRefs(ref, inputRef);const inputGroup = useInputGroup();+ const [, startTransition] = useTransition();+ const [optimisticValue, setOptimisticValue] = useOptimistic(value);+ const isBusy = isLoading || optimisticValue !== value;+ // Keep the OS picker mounted and focusable while its own Action is pending.+ // Native TimeInput follows the same pattern: commit guards block duplicates,+ // while aria-busy and the Spinner communicate the save without detaching the+ // platform picker from its input.const isEffectivelyDisabled = isDisabled || isLoading;// Disabled-reason tooltip, same contract as the other two surfaces: a@@ -341,7 +358,8 @@ export function NativeDateField({// The control's own value is always ISO — the only form it accepts, and// what the picker reads and writes. `format` rides on the overlay instead.- const nativeValue = value && ISO_DATE.test(value) ? value : '';+ const nativeValue =+ optimisticValue && ISO_DATE.test(optimisticValue) ? optimisticValue : '';const isInputValid = rejectedValue === null;const formatValue = useCallback(@@ -362,9 +380,25 @@ export function NativeDateField({const overlayText = nativeValue ? formatValue(nativeValue) : placeholder;const showsOverlay = !!overlayText && !(isFocused && isSegmentEditable);+ const fireChange = useCallback(+ (newValue: ISODateString | undefined) => {+ if (isBusy) {+ return;+ }+ onChange?.(newValue);+ if (changeAction) {+ startTransition(async () => {+ setOptimisticValue(newValue);+ await changeAction(newValue);+ });+ }+ },+ [isBusy, onChange, changeAction, startTransition, setOptimisticValue],+ );+const commitValue = useCallback((newValue: string) => {- if (isEffectivelyDisabled) {+ if (isEffectivelyDisabled || isBusy) {return;}// The same edit can arrive twice — React's synthetic change and the@@ -377,7 +411,7 @@ export function NativeDateField({if (!newValue) {setRejectedValue(null);if (value !== undefined) {- onChange?.(undefined);+ fireChange(undefined);}return;}@@ -398,10 +432,10 @@ export function NativeDateField({setRejectedValue(null);const parsedISO = plainDateToISO(parsed);if (parsedISO !== value) {- onChange?.(parsedISO);+ fireChange(parsedISO);}},- [value, onChange, isDateDisabled, isEffectivelyDisabled, locale],+ [value, fireChange, isDateDisabled, isEffectivelyDisabled, isBusy, locale],);const handleChange = useCallback(@@ -486,8 +520,8 @@ export function NativeDateField({// focus-restore after a clear would pop the picker the tap just dismissed —// and on iOS that reads as the clear having done nothing.const handleClear = useCallback(() => {- onChange?.(undefined);- }, [onChange]);+ fireChange(undefined);+ }, [fireChange]);const openPicker = useCallback(() => {if (isEffectivelyDisabled) {@@ -580,7 +614,7 @@ export function NativeDateField({aria-invalid={status?.type === 'error' || !isInputValid ? 'true' : undefined}- aria-busy={isLoading || undefined}+ aria-busy={isBusy || undefined}{...stylex.props(styles.input,showsOverlay && styles.inputTextHidden,@@ -609,14 +643,14 @@ export function NativeDateField({<VisuallyHidden as="div" role="alert" aria-live="assertive">{!isInputValid ? t('@astryx.dateInput.invalidDate') : ''}</VisuallyHidden>- {hasClear && value !== undefined && !isEffectivelyDisabled && (+ {hasClear && value !== undefined && !isEffectivelyDisabled && !isBusy && (<InputClearButtonlabel={t('@astryx.dateInput.clear', {label})}onClick={handleClear}iconClassName={stableClassName('date-input-clear-icon')}/>)}- {isLoading && <Spinner size="sm" />}+ {isBusy && <Spinner size="sm" />}{statusIcon}{showsDisabledMessage &&disabledMessageTooltip.renderTooltip(disabledMessage)}diff --git a/packages/core/src/DateInput/usePointerDragScroll.ts b/packages/core/src/DateInput/usePointerDragScroll.tsindex f4770f30e5..140cc0cc38 100644--- a/packages/core/src/DateInput/usePointerDragScroll.ts+++ b/packages/core/src/DateInput/usePointerDragScroll.ts@@ -43,7 +43,7 @@* - /packages/core/src/DateInput/DateInputTouch.test.tsx*/-import {useEffect, useRef} from 'react';+import {useEffect} from 'react';/*** Movement below this stays a click. A mouse shifts a pixel or two under the