Skip to content

feat(date-field): add regional dateFormat and showDayOfWeek - #573

Open
interacsean wants to merge 8 commits into
mainfrom
feat/date-field/1883-regional-date-format-weekday
Open

interacsean wants to merge 8 commits into
mainfrom
feat/date-field/1883-regional-date-format-weekday

Conversation

@interacsean

@interacsean interacsean commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Closes https://github.com/tailor-inc/platform-planning/issues/1883

Demo

jpdate.mp4

What

Two opt-in additions to DateField, DatePicker and DateRangePicker:

  • dateFormat: "numeric" | "regional", plus an app-wide default on <AppShell dateInputDateFormat> (namespaced so a bare dateFormat stays free for broader app-wide formatting). The component prop overrides the shell setting.
    • "numeric" is the default and is today's behaviour, so nothing changes on upgrade. The docs, JSDoc and changeset note that the default is planned to become "regional" in a future major release.
    • "regional" uses the locale's written business form wherever that form keeps the month numeric: 2025年12月19日 for ja / zh, 2025년 12월 19일 for ko.
    • Locales whose written form spells the month as a word (en, de, fr, …) stay numeric. That is detected from Intl.formatToParts, with no locale table, so one app-wide setting is safe for multi-locale apps.
  • showDayOfWeek appends the locale's short day of the week where the locale places it: …19日(金) in ja, Fri, 12/19/2025 in en. It is read-only and outside the tab order. The visible span is aria-hidden; instead, the full day name is appended to the date segments' aria-valuetext (e.g. 19, Friday), so it's announced while editing.

Why

ja business screens need 年月日 and a day of the week next to dates where business days matter (e.g. closing dates). Today consumers swap a hand-built label in and out of the picker to get this; ra-support needs 137 lines for it. The issue has the details.

Notes for reviewers

  • When the day of the week updates. The engine emits on every keystroke once the date is complete, so the day of the week would otherwise flash an intermediate value: typing 25 shows the 2nd for one keystroke. To prevent that, the engine tracks a pending date segment, meaning one whose first digit could still take a second. While a segment is pending, the day of the week keeps showing the date from before the entry, muted, so the field doesn't reflow. It settles on auto-advance, on segment blur, or on any non-typing commit (arrows, shortcuts, calendar pick, controlled change). Time segments never pend.
  • ko-KR. ko fuses the unit onto the number (12월). regionalParts splits it into a numeric part plus a literal.
  • Day-of-week time zone. The day of the week is computed from the calendar date in UTC on both sides, so the host time zone can't shift it.
  • Open questions for the team (not blockers):
    • Intl outputs half-width (金); ja documents usually use full-width (金).
    • showDayOfWeek is per-component only. It could get a shell-wide default if that's wanted.
    • The –– day-of-week placeholder sits close to the range picker's – separator.
  • Out of scope, found while testing. This bug predates this branch: the DatePicker calendar opens on today's month, not on a typed value. It's being handled separately.

Testing

  • Unit tests (13 new) cover:
    • the default numeric form for ja
    • regional output for ja / zh / ko / en / de
    • shell default vs. prop override
    • day-of-week placement and placeholder
    • typing 25 with no flash
    • a single digit settling on blur
    • arrow-key updates
    • the range picker
  • Checked by hand in the vite-app showcase (/showcase/date-picker → "Date format + day of the week"): typing, arrow keys, and picking from the calendar.
  • Local runs: fmt:check, type-check, lint, test, build, check-dts, docs:check.

🤖 Generated with Claude Code

Add `dateFormat` ("numeric" | "regional") and `showWeekday` to DateField,
DatePicker and DateRangePicker, plus an app-wide `dateFormat` default on
AppShell. "regional" uses the locale's written form where it keeps the month
numeric (ja/zh/ko) and stays numeric elsewhere; the default stays "numeric".
The weekday is read-only and waits while a segment is mid-entry.

Refs tailor-inc/platform-planning#1883

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@interacsean

Copy link
Copy Markdown
Contributor Author

/review

@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

✅ Code Review completed successfully!

Code review complete for PR #573: reviewed the changed package surfaces, export impact, and prior review context; no unresolved High or Medium issues found, so no inline review comments were needed.

Generated by Code Review for #573

@github-actions

github-actions Bot commented Oct 5, 2026 •

Copy link
Copy Markdown
Contributor

Code Metrics Report

main (94f6a5a) #573 (44ecc98) +/-
Coverage 88.1% 88.2% +0.0%
Test Execution Time 2m20s 1m28s -52s
Details
  |                     | main (94f6a5a) | #573 (44ecc98) |  +/-  |
  |---------------------|----------------|----------------|-------|
+ | Coverage            |          88.1% |          88.2% | +0.0% |
  |   Files             |            207 |            207 |     0 |
  |   Lines             |           6176 |           6216 |   +40 |
+ |   Covered           |           5446 |           5487 |   +41 |
+ | Test Execution Time |          2m20s |          1m28s |  -52s |

Code coverage of files in pull request scope (93.7% → 94.3%, patch 100.0%)

Files Coverage +/- Patch Coverage Status
packages/core/src/components/appshell/appshell.tsx 78.3% 0.0% - modified
packages/core/src/components/date-field/date-field.tsx 100.0% 0.0% 100.0% modified
packages/core/src/components/date-field/date-input-group.tsx 85.4% +0.9% 100.0% modified
packages/core/src/components/date-field/date-range-input-group.tsx 100.0% 0.0% - modified
packages/core/src/components/date-field/date-range-picker.tsx 97.7% +0.0% 100.0% modified
packages/core/src/components/date-field/use-date-field-state.ts 97.7% +0.8% 100.0% modified
packages/core/src/contexts/appshell-context.tsx 95.2% +0.7% 100.0% modified
packages/core/src/index.ts 0.0% 0.0% - modified
packages/core/tests/test-utils.tsx 100.0% 0.0% - modified

Reported by octocov

interacsean and others added 3 commits October 5, 2026 13:58
…screen readers (#1883)

- Only date segments pend; editing hour/minute/second no longer blanks the weekday.
- While a date segment is mid-entry, keep the pre-entry weekday (muted) instead
  of a placeholder, so the field doesn't reflow where the weekday leads (en-US).
- Hide the weekday span from assistive tech and append the full weekday name to
  the date segments' aria-valuetext, so it's announced while editing.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…mat (#1883)

Rename the AppShell-wide default to `dateInputDateFormat` (and the type to
`DateInputDateFormat`) so `dateFormat` stays free for broader app-wide
formatting later and no longer collides with DescriptionCard's internal
`DateFormat`. Components keep their `dateFormat` prop.

Note in JSDoc, docs and the changeset that the default is planned to become
"regional" in a future major release.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… to appShellDateFormat (#1883)

"Weekday" reads as Mon–Fri; dayOfWeek matches the existing firstDayOfWeek
prop. showWeekday becomes showDayOfWeek and the segment type/data-type
becomes "dayOfWeek".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@interacsean interacsean changed the title feat(date-field): add regional dateFormat and showWeekday feat(date-field): add regional dateFormat and showDayOfWeek Oct 5, 2026
@interacsean
interacsean marked this pull request as ready for review October 5, 2026 03:28
@interacsean
interacsean requested a review from a team as a code owner October 5, 2026 03:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants