Skip to content

An open source design system that's fully customizable and agent ready

TypeScript

feat(Calendar): weekday headers show abbreviated names where all seven fit in four characters (#9824)

Xinzi Zhou16a5397c9275
diff --git a/.changeset/calendar-weekday-abbreviated-names.md b/.changeset/calendar-weekday-abbreviated-names.md
new file mode 100644
index 0000000000..b9c7c01f92
--- /dev/null
+++ b/.changeset/calendar-weekday-abbreviated-names.md
@@ -0,0 +1,7 @@
+---
+'@astryxdesign/core': patch
+---
+
+[feat] Calendar: weekday headers show the locale's abbreviated names where all seven fit in four characters, and keep the short names otherwise. English now reads `Sun Mon Tue` instead of `Su Mo Tu`; French reads `dim. lun. mar.`, and Spanish, Swedish, Norwegian, Romanian, Greek, Serbian, Turkish, German, and Traditional Chinese switch the same way. Portuguese (Portugal), Arabic, Hebrew, Polish, Danish, and Vietnamese, whose abbreviated names are longer, keep their short names. A locale Astryx ships no translations for shows its own names instead of English: the abbreviated names where they fit the same way (Indonesian `Min Sen Sel`), else the narrow ones (Swahili `S M T`). The popovers of DateInput, DateRangeInput, and DateTimeInput follow because they render Calendar. The touch bottom sheets of DateInput and DateTimeInput now show the same names as Calendar in every locale: Portuguese (Portugal) no longer runs whole words such as `domingo` together, and Polish, Danish, Vietnamese, Arabic, and Hebrew switch to their short names there.
+
+@imdreamrunner
diff --git a/docs/specs/components/Calendar/Calendar.spec.md b/docs/specs/components/Calendar/Calendar.spec.md
index e1a40bd1ec..86dceabba7 100644
--- a/docs/specs/components/Calendar/Calendar.spec.md
+++ b/docs/specs/components/Calendar/Calendar.spec.md
@@ -13,10 +13,12 @@ review_triggers: [public-api, behavior, accessibility, theming]
verified_by:
[
packages/core/src/Calendar/Calendar.test.tsx,
+ packages/core/src/Calendar/getWeekdayHeaderNames.test.ts,
packages/core/src/hooks/useGridFocus.test.tsx,
packages/core/src/Calendar/__tests__/Calendar.a11y.test.tsx,
packages/core/src/Calendar/__tests__/Calendar.a11y.chromium.spec.ts,
scripts/check-knowledge.mjs,
+ scripts/generate-cldr-weekdays.test.mjs,
]
modules: []
families: []
@@ -36,15 +38,15 @@ system_specs: [spec:AST-020/FR15, spec:AST-085, spec:AST-102]
## Contract at a glance
-| Area | Contract |
-| ----------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
-| Public contract | None changes. `Calendar` and `CalendarProps` are exported from `@astryxdesign/core/Calendar`; `mode` selects a single date or a range, with `value`/`defaultValue`/`onChange`, bounds, constraints, span limits, focus date, and display options. |
-| Behavior | One or two months render as day grids under weekday headers (DD1); a day is picked by pointer or keyboard; each month grid holds at most one roving Tab stop, which arrow, Home/End, and Page keys move, following the reading direction. |
-| End-user impact | A keyboard or screen-reader user meets a named month grid, moves through it by day, week, and month, and hears each day's name, selection, today marker, and disabled state. |
-| Builder impact | None. |
-| Compatibility/readiness | Records shipped behavior apart from the weekday header form (DD1); no API or default change. Weekday headers show short names in every locale, the month buttons use native `disabled` at a bound and scale under reduced motion, day buttons hold a fixed size, and a key-moved Tab stop can go stale; all are listed under Current-state impact. |
-| Review checks | Reject a day grid without `role="grid"` or a name, two days in one month holding a Tab stop, an arrow key that stops following the reading direction, a selection or today state carried only by colour, a weekday header cut to a fixed number of characters, or a header row mixing abbreviated and short names. |
-| Governing rules | DD1 for the weekday headers; `architecture:public-component-api/INV1,INV5–INV8`; `architecture:component-theming-surface/INV3–INV7`; `spec:AST-020/FR15`; `spec:AST-085/FR1, FR4`; `spec:AST-102` FR4; `design:bidirectionality` DR6; `design:reduced-motion` DR1; `architecture:internationalization` INV8. |
+| Area | Contract |
+| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
+| Public contract | None changes. `Calendar` and `CalendarProps` are exported from `@astryxdesign/core/Calendar`; `mode` selects a single date or a range, with `value`/`defaultValue`/`onChange`, bounds, constraints, span limits, focus date, and display options. |
+| Behavior | One or two months render as day grids under weekday headers (DD1); a day is picked by pointer or keyboard; each month grid holds at most one roving Tab stop, which arrow, Home/End, and Page keys move, following the reading direction. |
+| End-user impact | A keyboard or screen-reader user meets a named month grid, moves through it by day, week, and month, and hears each day's name, selection, today marker, and disabled state. |
+| Builder impact | None. |
+| Compatibility/readiness | Records shipped behavior; no API or default change. The month buttons use native `disabled` at a bound and scale under reduced motion, day buttons hold a fixed size, and a key-moved Tab stop can go stale; all are listed under Current-state impact. |
+| Review checks | Reject a day grid without `role="grid"` or a name, two days in one month holding a Tab stop, an arrow key that stops following the reading direction, a selection or today state carried only by colour, a weekday header cut to a fixed number of characters, or a header row mixing abbreviated and short names. |
+| Governing rules | DD1 for the weekday headers; `architecture:public-component-api/INV1,INV5–INV8`; `architecture:component-theming-surface/INV3–INV7`; `spec:AST-020/FR15`; `spec:AST-085/FR1, FR4`; `spec:AST-102` FR4; `design:bidirectionality` DR6; `design:reduced-motion` DR1; `architecture:internationalization` INV8. |
This table is a review projection; the body below is authoritative.
@@ -180,9 +182,9 @@ Consumer migration instructions belong in consumer docs and release notes.
<!-- design-decisions:v1 -->
-| ID | Decision | Intent or reason | Applies to | Allowed variation |
-| --- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
-| DD1 | A locale's weekday column headers show its stand-alone abbreviated weekday names (the CLDR `abbreviated` width) when every one of the seven is at most four characters, and its stand-alone short names (the CLDR `short` width) otherwise; names are shown whole. English shows `Sun` to `Sat`; for example `pt-PT`, `ar`, `he`, `pl`, `da`, and `vi` keep their short names. Implementation gap: every locale shows its short names (`Su` to `Sa` in English). | Three letters read at a glance; two-letter names make `Tu` and `Th`, or `Sa` and `Su`, easy to confuse. Longer abbreviated names crowd, overlap, or wrap in the `md`-sized header column, so those locales keep the short form. Rejected: cutting a longer name to three characters, which misnames days in locales whose abbreviations differ. | Weekday headers of every month grid, in one- and two-month views, with or without week numbers, for every locale and `weekStartsOn` | Header typography and colour. The choice is per locale, so one header row never mixes abbreviated and short names; characters are user-perceived characters. |
+| ID | Decision | Intent or reason | Applies to | Allowed variation |
+| --- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
+| DD1 | A locale's weekday column headers show its stand-alone abbreviated weekday names (the CLDR `abbreviated` width) when every one of the seven is at most four characters, and its stand-alone short names (the CLDR `short` width) otherwise; names are shown whole. English shows `Sun` to `Sat`; for example `pt-PT`, `ar`, `he`, `pl`, `da`, and `vi` keep their short names. A locale with no shipped weekday data shows the abbreviated names its platform formats when all seven are at most four characters, and its platform's narrow names otherwise. | Three letters read at a glance; two-letter names make `Tu` and `Th`, or `Sa` and `Su`, easy to confuse. Longer abbreviated names crowd, overlap, or wrap in the `md`-sized header column, so those locales keep the short form. Rejected: cutting a longer name to three characters, which misnames days in locales whose abbreviations differ. | Weekday headers of every month grid, in one- and two-month views, with or without week numbers, for every locale and `weekStartsOn` | Header typography and colour. The choice is per locale, so one header row never mixes abbreviated and short names; characters are user-perceived characters. |
### Theming anatomy
@@ -225,7 +227,7 @@ button.
| FR7 | `Calendar.test.tsx` month-change announcement cases ("does not announce on initial render", "announces the new month politely when clicking next", "announces the next month when paging the grid with PageDown", "announces both months in a two-month view", "does not announce when selecting a date leaves the visible month unchanged") and range announcement cases ("announces the start pick and prompts for an end date", "announces the completed range in chronological order for a reverse pick") | Month buttons, Page keys, handle; single and two months; range start, complete, cleared | A missing, extra, or out-of-order announcement fails. Evidence gap: no test reaches the cleared-start announcement (the cleared-range case sets no `minRangeSpan`). | `audit:Calendar/accessibility` |
| FR1 (labels) | `Calendar.test.tsx` ("starts each stand-alone month label with a capital in %s", "leaves the month label as Intl gives it where CLDR does not capitalize in %s"), `plainDate.test.ts` `plainDateFormatStandaloneMonthYear` | es, fr, pl, ru two-month view; vi, de, en | A lower-case stand-alone month where CLDR titlecases it, a capital where it does not, or a second month left lower case fails. | `audit:Calendar/behavior` |
| FR2 (size) | Evidence gap: no test asserts day-button size or text growth | — | — | `audit:Calendar/layout` |
-| DD1 | Evidence gap: the `Calendar.test.tsx` day-name cases ("displays day names", "uses the provider locale for stand-alone short day names", "rotates localized day names by numeric weekday index") assert the short names in every locale | English; a locale whose abbreviated names are all within four characters, such as `fr`; a locale above it, such as `pt-PT` or `pl`; `weekStartsOn` rotation; with week numbers | A locale within the limit showing short names, a locale above it showing abbreviated names, a row mixing the two, or a name cut short fails. | `audit:Calendar/layout` |
+| DD1 | `Calendar.test.tsx` ("displays day names", "uses the provider locale for weekday header names", "rotates localized day names by numeric weekday index", "shows abbreviated weekday names in a locale where all seven fit in four characters", "keeps short weekday names in %s, where an abbreviated name runs past four characters" for `pt-PT` and `pl-PL`, "shows the platform abbreviated names for a locale with no shipped weekday data" for `id-ID`, "shows the platform narrow names for an unshipped locale whose abbreviated names run past four characters" for `sw-KE`); `getWeekdayHeaderNames.test.ts`; `scripts/generate-cldr-weekdays.test.mjs` ("matches every generated locale to its pinned raw CLDR source", "picks abbreviated names only where all seven fit in four characters") | English; a locale whose abbreviated names are all within four characters, such as `fr`; a locale above it, such as `pt-PT` or `pl`; `weekStartsOn` rotation; with week numbers | A locale within the limit showing short names, a locale above it showing abbreviated names, a row mixing the two, or a name cut short fails. | `audit:Calendar/layout` |
| AR1 (browser) | `Calendar.a11y.test.tsx` and `Calendar.a11y.chromium.spec.ts` over the shared grid states | Every representative state | A lost grid name, role, or start neighbourhood fails; browser-owned outcomes are reported. | `audit:Calendar/accessibility` |
| ORD1, ORD2, PR1 | ORD1 and ORD2 are covered by the FR3–FR5 and AR1 rows. Evidence gap: no test asserts the absence of per-cell listeners | — | — | `audit:Calendar/behavior` |
@@ -240,9 +242,6 @@ button.
FR15 records, against `design:reduced-motion` DR1.
- **Fixed day size (FR2).** Day buttons hold a fixed size instead of growing
with a set text size, against `spec:AST-102` FR4.
-- **Weekday header form (DD1).** Every locale shows its short weekday names,
- including locales whose abbreviated names fit within four characters, so
- English shows `Su` to `Sa` instead of `Sun` to `Sat`.
- **Month buttons at a bound (FR6).** Previous and Next become natively
disabled at `min` and `max`, so a keyboard user on the button that reaches the
bound loses focus, against `spec:AST-085` FR1 and FR4.
diff --git a/docs/specs/components/DateInput/DateInput.spec.md b/docs/specs/components/DateInput/DateInput.spec.md
index 034adc5c5d..e3fc5a8d93 100644
--- a/docs/specs/components/DateInput/DateInput.spec.md
+++ b/docs/specs/components/DateInput/DateInput.spec.md
@@ -111,6 +111,8 @@ Consumer migration instructions belong in consumer docs and release notes.
owned by `component:Field`, `component:FieldStatus`, and `family:input-fields`.
- Calendar-grid dates, navigation, and selection semantics — owned by
`component:Calendar`.
+- Weekday header names — set by `component:Calendar` DD1; the bottom-sheet
+ calendar shows them (FR19).
- Popover hosting and topmost dismissal — owned by `component:Popover` and
`family:overlay-dismissal`.
- Bottom-sheet hosting and dismissal — owned by `component:BottomSheet` and the
@@ -158,6 +160,7 @@ Consumer migration instructions belong in consumer docs and release notes.
| FR16 | Enter in the pointer field's text input commits typed text that has not been committed and is then held back, so a form never submits the value from before the commit. With no typed text pending, Enter is not prevented, so a form submits as it does from any text field, except on a disabled or busy field, where Enter does nothing (`spec:AST-085` FR2). |
| FR17 | In a sheet wheel, Arrow, Page, Home and End move through the wheel's enabled values in time order, skipping disabled ones, and stop at the first or last enabled value; a key with no enabled value in its direction commits nothing, under every presentation. On a 12-hour hour wheel, time order follows the full time (12 PM comes before 1 PM), not the column's row order. | Owner decision (cixzhang, 2026-11-02); current source |
| FR18 | While a wheel coasts, snaps or turns, no row carries the selection band's accent mark; the mark returns on the row that comes to rest, as UIPickerView does (`spec:AST-094` FR3). | Owner decision (cixzhang, 2026-11-02); UIDatePicker on the iOS 26.2 simulator; current source |
+| FR19 | The bottom-sheet calendar's weekday row MUST show the weekday names `component:Calendar` DD1 sets for the provider locale, in the order of the panes' day columns (`weekStartsOn`), so both pickers label a locale's columns alike. |
### Allowed variation
@@ -256,15 +259,15 @@ Consumer migration instructions belong in consumer docs and release notes.
## 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 |
+| 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`; weekday names: `component:Calendar` DD1 | Prominent | FR2, FR4, FR9, FR19 |
+| 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
@@ -340,6 +343,7 @@ clear-glyph target of its own.
| FR16 | `DateInput.test.tsx` "Enter submits the form when nothing is typed, and commits typed text without submitting" "Enter on a disabled field does not submit the form" and "Enter on a busy field does not submit the form" | Nothing typed; typed text; disabled; busy (`isLoading`) | An Enter that is prevented with nothing typed, or that submits before typed text commits, fails. | — |
| FR17 | `TimeInput/Presentation.test.tsx`: "at a 12:00–17:00 bound, ArrowDown from 5 PM commits nothing and ArrowDown from 12 PM commits 1 PM, under a finger", "… under a mouse". `Wheel.test.tsx`, the column under a mouse, and `PickerWheel.test.tsx`, the wheel under a finger: "at a 12:00–17:00 bound, moves a key to the next enabled row and stops at the last one", "at a 12:00–17:00 bound on a 12-hour hour wheel, steps in time order: nothing after 5 PM, and 1 PM after 12 PM", "moves a key from a row outside the bounds onto the first enabled row in its direction". | At a 12:00–17:00 bound, ArrowDown from 5 PM commits nothing and ArrowDown from 12 PM commits 1 PM, under a finger and a mouse | A key that commits a disabled value, leaves time order, or strands 12 PM fails. | `audit:DateInput/behavior` |
| FR18 | `PickerWheel.test.tsx` "marks no row while a fling coasts, then the row it rests on", "marks no row while the wheel snaps or turns, then the row it rests on". | A fling's coast, a slow release's snap and a key's turn, each to its rest | A row that carries the band's accent mark while the wheel moves, or a rest with no marked row, fails. | `audit:DateInput/behavior` |
+| FR19 | `DateInputTouch.test.tsx` "labels the columns with three-letter weekday names", "labels the columns in %s with the same names as the Calendar header" for `fr-FR`, `pt-PT`, `pl-PL`, and `id-ID`, "rotates the weekday header with weekStartsOn" | English; a locale within Calendar DD1's four-character limit; locales above it; a locale with no shipped weekday data; `weekStartsOn` rotation | A weekday row that differs from the Calendar header names for the same locale, or that does not rotate with `weekStartsOn`, fails. | — |
| Theming anatomy | `DateInput.test.tsx` clear-icon and calendar-toggle icon theme-target cases; `themingTargets.test.ts`; `scripts/check-knowledge.mjs` | Toggle, clear glyph, disabled root | A missing or moved target, or a stale anatomy mapping, fails. | `audit:DateInput/theming` |
## Current-state impact
diff --git a/docs/specs/components/DateTimeInput/DateTimeInput.spec.md b/docs/specs/components/DateTimeInput/DateTimeInput.spec.md
index acb8b32f9f..21a2bdfc82 100644
--- a/docs/specs/components/DateTimeInput/DateTimeInput.spec.md
+++ b/docs/specs/components/DateTimeInput/DateTimeInput.spec.md
@@ -113,7 +113,7 @@ Consumer migration instructions belong in consumer docs and release notes.
| ---- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- |
| FR1 | DateTimeInput MUST reflect one controlled date-time value across its visible segments and active picker, and MUST NOT reveal a competing selected date after the parent accepts a clear. | Public docs, controlled component seam, current source, focused tests |
| FR2 | Every committed date or time change MUST emit one valid combined ISO date-time value; clearing MUST emit `undefined`; changing time while no date is committed MUST emit nothing. | Public types, docs, current source, focused tests |
-| FR3 | `presentation`, deprecated `nativePicker`, precedence, pointer adaptation, forced surfaces, and per-segment native fallbacks MUST follow `spec:AST-043` FR1–FR4. The touch date sheet's month heading and month-pane names follow `component:DateInput` FR6. | `spec:AST-043` |
+| FR3 | `presentation`, deprecated `nativePicker`, precedence, pointer adaptation, forced surfaces, and per-segment native fallbacks MUST follow `spec:AST-043` FR1–FR4. The touch date sheet's month heading and month-pane names follow `component:DateInput` FR6, and its weekday row follows `component:DateInput` FR19. | `spec:AST-043` |
| FR4 | When `changeAction` is present, every value-change path MUST call `onChange` first, show the proposed controlled value optimistically, and contribute to one busy state until the controlled value accepts or replaces it. | `family:input-fields/FR6` |
| FR5 | The two pointer segments share one row while each retains its intrinsic basis; when the container is narrower, flex wrapping moves them into separate full-width rows. Each segment is the shared element height for its size, as a minimum that grows with a set text size under `spec:AST-102` FR4. Implementation gap: the height is fixed at that size. | Public docs, current source, focused layout tests; `spec:AST-102` FR4 |
| FR6 | Date-time bounds and date constraints MUST prevent invalid commits. Native controls MAY receive platform hints, but JavaScript validation remains the final commit boundary; calendar-only options MAY be unavailable on native surfaces. | Public docs, current source, focused presentation tests |
@@ -237,7 +237,7 @@ leading clock glyph uses `date-time-input-clock-icon`.
| Contract | Verification | Representative states | Mutation or failure expectation | Audit section |
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------- |
| FR1–FR2 | `DateTimeInput.test.tsx` | empty, calendar selection, typed date/time, clear | A stale Calendar selection, partial output, or invalid mutation makes a public-state test fail. | `audit:DateTimeInput/behavior` |
-| FR3, FR6 | `Presentation.test.tsx`, `NativePickerSegments.test.tsx`, `DateTimeInputTouch.test.tsx` | forced, adaptive, legacy, native fallback, constrained commit | A substituted surface, precedence drift, or invalid commit makes a presentation test fail. | `audit:DateTimeInput/surfaces` |
+| FR3, FR6 | `Presentation.test.tsx`, `NativePickerSegments.test.tsx`, `DateTimeInputTouch.test.tsx` (including "labels the date sheet columns in %s with the Calendar header names" for `en-US`, `pt-PT`, and `id-ID`) | forced, adaptive, legacy, native fallback, constrained commit | A substituted surface, precedence drift, or invalid commit makes a presentation test fail. | `audit:DateTimeInput/surfaces` |
| FR4, FR9, AR4 | `DateTimeInput.test.tsx`, `DateTimeInputTouch.test.tsx`; `BusyOwnerAnnouncement.test.tsx` DateTimeInput case | pending, loading, disabled reason | Mutation during busy/disabled state or stale optimistic output makes a state test fail. Evidence gap: no test asserts that caller handlers still run while disabled. | `audit:DateTimeInput/state` |
| FR5 | `DateTimeInput.test.tsx` | intrinsic row, narrow-container wrap classes | Removing the intrinsic basis or wrap styles makes the class-level layout assertions fail; rendered geometry remains review evidence. Evidence gap: no test asserts segment heights or text growth. | `audit:DateTimeInput/layout` |
| FR7, AR1–AR3 | `DateTimeInput.test.tsx`, `DateTimeInputTouch.test.tsx`; `DateTimeInput.test.tsx` "keeps the time list open on a press in the time input, closes it on a press elsewhere" | popovers, time options, keyboard/focus | Wrong role, name, state, keyboard behavior, or focus behavior makes a focused interaction test fail. A provider-locale test asserts the closed time text follows the locale's hour cycle and day period; the shared formatter's tests cover parsing. | `audit:DateTimeInput/interaction` |
diff --git a/packages/cli/api/component/__fixtures__/resolutions/modules.txt b/packages/cli/api/component/__fixtures__/resolutions/modules.txt
index 3a67d6b6f4..ddb4114d12 100644
--- a/packages/cli/api/component/__fixtures__/resolutions/modules.txt
+++ b/packages/cli/api/component/__fixtures__/resolutions/modules.txt
@@ -134,7 +134,7 @@ generateThemeRules generateThemeRules theme/MediaTheme.doc.mjs theme/generateThe
gestureCounter gestureCounter Layer/Layer.doc.mjs Layer/gestureCounter.ts
getInitialFocusDate getInitialFocusDate Calendar/Calendar.doc.mjs Calendar/getInitialFocusDate.ts
getLocaleDirection getLocaleDirection i18n/InternationalizationProvider.doc.mjs i18n/getLocaleDirection.ts
-getStandaloneShortWeekdayNames getStandaloneShortWeekdayNames Calendar/Calendar.doc.mjs Calendar/getStandaloneShortWeekdayNames.ts
+getWeekdayHeaderNames getWeekdayHeaderNames Calendar/Calendar.doc.mjs Calendar/getWeekdayHeaderNames.ts
glidingDivider glidingDivider Table/Table.doc.mjs Table/glidingDivider.ts
globalIconRegistry globalIconRegistry Icon/Icon.doc.mjs Icon/globalIconRegistry.tsx
grammar grammar CodeBlock/CodeBlock.doc.mjs CodeBlock/grammar.ts
diff --git a/packages/core/src/Calendar/Calendar.test.tsx b/packages/core/src/Calendar/Calendar.test.tsx
index 09a2fed6c6..52e069eb02 100644
--- a/packages/core/src/Calendar/Calendar.test.tsx
+++ b/packages/core/src/Calendar/Calendar.test.tsx
@@ -26,7 +26,7 @@ import {defineTheme} from '../theme/defineTheme';
import {generateThemeCSS} from '../theme/generateThemeRules';
import {__resetLiveRegionsForTest} from '../hooks/useAnnounce';
import {InternationalizationProvider} from '../i18n/InternationalizationProvider';
-import {standaloneShortWeekdayNamesByLocale} from './standaloneShortWeekdayNames.generated';
+import {weekdayHeaderNamesByLocale} from './weekdayHeaderNames.generated';
function generateThemeTestCSS(theme: Parameters<typeof generateThemeCSS>[0]) {
const {prose, component} = generateThemeCSS(theme);
@@ -149,18 +149,18 @@ describe('Calendar', () => {
it('displays day names', () => {
render(<Calendar />);
- expect(screen.getByText('Su')).toBeInTheDocument();
- expect(screen.getByText('Mo')).toBeInTheDocument();
- expect(screen.getByText('Tu')).toBeInTheDocument();
- expect(screen.getByText('We')).toBeInTheDocument();
- expect(screen.getByText('Th')).toBeInTheDocument();
- expect(screen.getByText('Fr')).toBeInTheDocument();
- expect(screen.getByText('Sa')).toBeInTheDocument();
+ expect(screen.getByText('Sun')).toBeInTheDocument();
+ expect(screen.getByText('Mon')).toBeInTheDocument();
+ expect(screen.getByText('Tue')).toBeInTheDocument();
+ expect(screen.getByText('Wed')).toBeInTheDocument();
+ expect(screen.getByText('Thu')).toBeInTheDocument();
+ expect(screen.getByText('Fri')).toBeInTheDocument();
+ expect(screen.getByText('Sat')).toBeInTheDocument();
});
- it('uses the provider locale for stand-alone short day names', () => {
- const localizedNames = standaloneShortWeekdayNamesByLocale.es;
- const englishNames = standaloneShortWeekdayNamesByLocale.en;
+ it('uses the provider locale for weekday header names', () => {
+ const localizedNames = weekdayHeaderNamesByLocale.es;
+ const englishNames = weekdayHeaderNamesByLocale.en;
expect(localizedNames).not.toEqual(englishNames);
const {rerender} = render(
@@ -184,7 +184,7 @@ describe('Calendar', () => {
});
it('rotates localized day names by numeric weekday index', () => {
- const localizedNames = standaloneShortWeekdayNamesByLocale.es;
+ const localizedNames = weekdayHeaderNamesByLocale.es;
render(
<InternationalizationProvider locale="es-ES">
@@ -197,6 +197,60 @@ describe('Calendar', () => {
).toEqual([...localizedNames.slice(1), localizedNames[0]]);
});
+ it('shows abbreviated weekday names in a locale where all seven fit in four characters', () => {
+ render(
+ <InternationalizationProvider locale="fr-FR">
+ <Calendar />
+ </InternationalizationProvider>,
+ );
+
+ expect(
+ screen.getAllByRole('columnheader').map(header => header.textContent),
+ ).toEqual(['dim.', 'lun.', 'mar.', 'mer.', 'jeu.', 'ven.', 'sam.']);
+ });
+
+ it.each([
+ ['pt-PT', ['dom.', 'seg.', 'ter.', 'qua.', 'qui.', 'sex.', 'sáb.']],
+ ['pl-PL', ['nie', 'pon', 'wto', 'śro', 'czw', 'pią', 'sob']],
+ ])(
+ 'keeps short weekday names in %s, where an abbreviated name runs past four characters',
+ (locale, shortNames) => {
+ render(
+ <InternationalizationProvider locale={locale}>
+ <Calendar />
+ </InternationalizationProvider>,
+ );
+
+ expect(
+ screen.getAllByRole('columnheader').map(header => header.textContent),
+ ).toEqual(shortNames);
+ },
+ );
+
+ it('shows the platform abbreviated names for a locale with no shipped weekday data', () => {
+ render(
+ <InternationalizationProvider locale="id-ID">
+ <Calendar />
+ </InternationalizationProvider>,
+ );
+
+ expect(
+ screen.getAllByRole('columnheader').map(header => header.textContent),
+ ).toEqual(['Min', 'Sen', 'Sel', 'Rab', 'Kam', 'Jum', 'Sab']);
+ });
+
+ it('shows the platform narrow names for an unshipped locale whose abbreviated names run past four characters', () => {
+ render(
+ <InternationalizationProvider locale="sw-KE">
+ <Calendar />
+ </InternationalizationProvider>,
+ );
+
+ expect(
+ screen.getAllByRole('columnheader').map(header => header.textContent),
+ ).toEqual(['S', 'M', 'T', 'W', 'T', 'F', 'S']);
+ });
+
it('updates the month header and subsequent navigation with provider locale', async () => {
const user = userEvent.setup();
const renderCalendar = (locale: 'en-US' | 'es-ES') => (
@@ -803,23 +857,23 @@ describe('Calendar', () => {
render(<Calendar weekStartsOn={1} />);
// First day name should be Monday
- const dayNames = screen.getAllByText(/^(Mo|Tu|We|Th|Fr|Sa|Su)$/);
- expect(dayNames[0]).toHaveTextContent('Mo');
+ const dayNames = screen.getAllByText(/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun)$/);
+ expect(dayNames[0]).toHaveTextContent('Mon');
});
it('accepts a three-letter day name for weekStartsOn', () => {
render(<Calendar weekStartsOn="mon" />);
// "mon" should behave exactly like the numeric 1 (Monday first).
- const dayNames = screen.getAllByText(/^(Mo|Tu|We|Th|Fr|Sa|Su)$/);
- expect(dayNames[0]).toHaveTextContent('Mo');
+ const dayNames = screen.getAllByText(/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun)$/);
+ expect(dayNames[0]).toHaveTextContent('Mon');
});
it('treats weekStartsOn day names case-insensitively', () => {
render(<Calendar weekStartsOn={'WED' as 'wed'} />);
- const dayNames = screen.getAllByText(/^(Mo|Tu|We|Th|Fr|Sa|Su)$/);
- expect(dayNames[0]).toHaveTextContent('We');
+ const dayNames = screen.getAllByText(/^(Mon|Tue|Wed|Thu|Fri|Sat|Sun)$/);
+ expect(dayNames[0]).toHaveTextContent('Wed');
});
// ─── Range Mode ──────────────────────────────────────────────
@@ -2072,7 +2126,7 @@ describe('Calendar', () => {
// Verify they contain day name abbreviations
const dayNames = columnHeaders.map(h => h.textContent);
- expect(dayNames).toEqual(['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa']);
+ expect(dayNames).toEqual(['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']);
});
it('button inside gridcell does not duplicate role="gridcell"', () => {
diff --git a/packages/core/src/Calendar/Calendar.tsx b/packages/core/src/Calendar/Calendar.tsx
index 69b9442840..18f69f4b78 100644
--- a/packages/core/src/Calendar/Calendar.tsx
+++ b/packages/core/src/Calendar/Calendar.tsx
@@ -70,6 +70,7 @@ import {focusOutlineProps} from '../utils/focusOutline.stylex';
import {interactionOverlayStyles} from '../utils/interactionOverlay.stylex';
import {usePressFeedback} from '../hooks/usePressFeedback';
import {getInitialFocusDate} from './getInitialFocusDate';
+import {getWeekdayHeaders} from './getWeekdayHeaderNames';
import {
computeDayCellState,
computeRangeRounding,
@@ -855,19 +856,15 @@ function MonthGrid({
const year = month.year;
// Use hooks for days generation and constraints
- const {days, weeks, dayNames} = useCalendarDays({
+ const {days, weeks} = useCalendarDays({
year,
month: month.month,
weekStartsOn,
hasVariableRowCount,
});
const dayNameHeaders = useMemo(
- () =>
- dayNames.map((name, offset) => ({
- dayOfWeek: ((weekStartsOn + offset) % 7) as DayOfWeek,
- name,
- })),
- [dayNames, weekStartsOn],
+ () => getWeekdayHeaders(locale, weekStartsOn),
+ [locale, weekStartsOn],
);
const rangeAnchor = useMemo(
diff --git a/packages/core/src/Calendar/getStandaloneShortWeekdayNames.test.ts b/packages/core/src/Calendar/getStandaloneShortWeekdayNames.test.ts
deleted file mode 100644
index f2692d7aa2..0000000000
--- a/packages/core/src/Calendar/getStandaloneShortWeekdayNames.test.ts
+++ /dev/null
@@ -1,54 +0,0 @@
-// Copyright (c) Meta Platforms, Inc. and affiliates.
-
-/**
- * @file getStandaloneShortWeekdayNames.test.ts
- * @input Private Calendar weekday locale resolver and generated CLDR data
- * @output Regression coverage for exact, language, extension, and safe fallback
- * @position Tests for getStandaloneShortWeekdayNames.ts
- */
-
-import {describe, expect, it} from 'vitest';
-import {getStandaloneShortWeekdayNames} from './getStandaloneShortWeekdayNames';
-import {standaloneShortWeekdayNamesByLocale} from './standaloneShortWeekdayNames.generated';
-
-describe('getStandaloneShortWeekdayNames', () => {
- it('preserves the default English weekday names', () => {
- expect(getStandaloneShortWeekdayNames('en')).toEqual([
- 'Su',
- 'Mo',
- 'Tu',
- 'We',
- 'Th',
- 'Fr',
- 'Sa',
- ]);
- });
-
- it('returns an exact generated locale entry', () => {
- expect(getStandaloneShortWeekdayNames('ar-SA')).toBe(
- standaloneShortWeekdayNamesByLocale['ar-SA'],
- );
- });
-
- it('ignores Unicode extensions when resolving an exact locale', () => {
- const expected = standaloneShortWeekdayNamesByLocale['zh-TW'];
-
- expect(getStandaloneShortWeekdayNames('zh-TW')).toBe(expected);
- expect(getStandaloneShortWeekdayNames('zh-TW-u-ca-chinese')).toBe(expected);
- });
-
- it('falls back from a regional locale to its base language', () => {
- expect(getStandaloneShortWeekdayNames('es-ES')).toBe(
- standaloneShortWeekdayNamesByLocale.es,
- );
- });
-
- it('safely falls back to English for malformed and unsupported locales', () => {
- expect(getStandaloneShortWeekdayNames('not_a_locale')).toBe(
- standaloneShortWeekdayNamesByLocale.en,
- );
- expect(getStandaloneShortWeekdayNames('xx-ZZ')).toBe(
- standaloneShortWeekdayNamesByLocale.en,
- );
- });
-});
diff --git a/packages/core/src/Calendar/getStandaloneShortWeekdayNames.ts b/packages/core/src/Calendar/getStandaloneShortWeekdayNames.ts
deleted file mode 100644
index 5022483124..0000000000
--- a/packages/core/src/Calendar/getStandaloneShortWeekdayNames.ts
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright (c) Meta Platforms, Inc. and affiliates.
-
-/**
- * @file getStandaloneShortWeekdayNames.ts
- * @input Generated CLDR stand-alone-short weekday table
- * @output Private locale resolver for Calendar weekday headers
- * @position Calendar-internal pure utility; not exported from the package
- */
-
-import {
- standaloneShortWeekdayNamesByLocale,
- type StandaloneShortWeekdayNames,
-} from './standaloneShortWeekdayNames.generated';
-
-const weekdayNamesByLocale: Readonly<
- Record<string, StandaloneShortWeekdayNames>
-> = standaloneShortWeekdayNamesByLocale;
-const englishWeekdayNames = weekdayNamesByLocale.en;
-
-/**
- * Resolve generated weekday reference data as exact locale -> language -> English.
- * Unicode extensions are ignored through Intl.Locale.baseName. Invalid tags and
- * valid but unsupported languages safely use English.
- */
-export function getStandaloneShortWeekdayNames(
- locale: string,
-): StandaloneShortWeekdayNames {
- try {
- const parsed = new Intl.Locale(locale);
- return (
- weekdayNamesByLocale[parsed.baseName] ??
- weekdayNamesByLocale[parsed.language] ??
- englishWeekdayNames
- );
- } catch {
- return englishWeekdayNames;
- }
-}
diff --git a/packages/core/src/Calendar/getWeekdayHeaderNames.test.ts b/packages/core/src/Calendar/getWeekdayHeaderNames.test.ts
new file mode 100644
index 0000000000..ad4180c051
--- /dev/null
+++ b/packages/core/src/Calendar/getWeekdayHeaderNames.test.ts
@@ -0,0 +1,136 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+/**
+ * @file getWeekdayHeaderNames.test.ts
+ * @input Private weekday header resolver and generated CLDR data
+ * @output Regression coverage for the per-locale width, rotation, exact,
+ * language, extension, platform, and English fallbacks
+ * @position Tests for getWeekdayHeaderNames.ts
+ */
+
+import {describe, expect, it} from 'vitest';
+import {getWeekdayHeaderNames} from './getWeekdayHeaderNames';
+import {weekdayHeaderNamesByLocale} from './weekdayHeaderNames.generated';
+
+describe('getWeekdayHeaderNames', () => {
+ it('gives English its three-letter abbreviated names', () => {
+ expect(getWeekdayHeaderNames('en')).toEqual([
+ 'Sun',
+ 'Mon',
+ 'Tue',
+ 'Wed',
+ 'Thu',
+ 'Fri',
+ 'Sat',
+ ]);
+ });
+
+ it('gives a locale whose abbreviated names fit in four characters those names', () => {
+ expect(getWeekdayHeaderNames('fr-FR')).toEqual([
+ 'dim.',
+ 'lun.',
+ 'mar.',
+ 'mer.',
+ 'jeu.',
+ 'ven.',
+ 'sam.',
+ ]);
+ });
+
+ it('keeps the short names where an abbreviated name runs past four characters', () => {
+ // pt-PT abbreviates with whole words (domingo), pl with "niedz.".
+ expect(getWeekdayHeaderNames('pt-PT')).toEqual([
+ 'dom.',
+ 'seg.',
+ 'ter.',
+ 'qua.',
+ 'qui.',
+ 'sex.',
+ 'sáb.',
+ ]);
+ expect(getWeekdayHeaderNames('pl-PL')).toEqual([
+ 'nie',
+ 'pon',
+ 'wto',
+ 'śro',
+ 'czw',
+ 'pią',
+ 'sob',
+ ]);
+ });
+
+ it('starts the row on weekStartsOn', () => {
+ expect(getWeekdayHeaderNames('en', 1)).toEqual([
+ 'Mon',
+ 'Tue',
+ 'Wed',
+ 'Thu',
+ 'Fri',
+ 'Sat',
+ 'Sun',
+ ]);
+ expect(getWeekdayHeaderNames('en', 6)[0]).toBe('Sat');
+ });
+
+ it('returns an exact generated locale entry', () => {
+ expect(getWeekdayHeaderNames('ar-SA')).toEqual(
+ weekdayHeaderNamesByLocale['ar-SA'],
+ );
+ });
+
+ it('ignores Unicode extensions when resolving an exact locale', () => {
+ const expected = weekdayHeaderNamesByLocale['zh-TW'];
+
+ expect(getWeekdayHeaderNames('zh-TW')).toEqual(expected);
+ expect(getWeekdayHeaderNames('zh-TW-u-ca-chinese')).toEqual(expected);
+ });
+
+ it('falls back from a regional locale to its base language', () => {
+ expect(getWeekdayHeaderNames('es-ES')).toEqual(
+ weekdayHeaderNamesByLocale.es,
+ );
+ });
+
+ it('formats the platform abbreviated names for a language with no generated row', () => {
+ expect(getWeekdayHeaderNames('id-ID')).toEqual([
+ 'Min',
+ 'Sen',
+ 'Sel',
+ 'Rab',
+ 'Kam',
+ 'Jum',
+ 'Sab',
+ ]);
+ });
+
+ it('uses the platform narrow names where an unshipped language abbreviates past four characters', () => {
+ // sw abbreviates with whole words (Jumapili), fa with up to eight letters.
+ expect(getWeekdayHeaderNames('sw-KE')).toEqual([
+ 'S',
+ 'M',
+ 'T',
+ 'W',
+ 'T',
+ 'F',
+ 'S',
+ ]);
+ expect(getWeekdayHeaderNames('fa-IR')).toEqual([
+ 'ی',
+ 'د',
+ 'س',
+ 'چ',
+ 'پ',
+ 'ج',
+ 'ش',
+ ]);
+ });
+
+ it('safely falls back to English for malformed and unknown locales', () => {
+ expect(getWeekdayHeaderNames('not_a_locale')).toEqual(
+ weekdayHeaderNamesByLocale.en,
+ );
+ expect(getWeekdayHeaderNames('xx-ZZ')).toEqual(
+ weekdayHeaderNamesByLocale.en,
+ );
+ });
+});
diff --git a/packages/core/src/Calendar/getWeekdayHeaderNames.ts b/packages/core/src/Calendar/getWeekdayHeaderNames.ts
new file mode 100644
index 0000000000..02a40b90b8
--- /dev/null
+++ b/packages/core/src/Calendar/getWeekdayHeaderNames.ts
@@ -0,0 +1,88 @@
+// Copyright (c) Meta Platforms, Inc. and affiliates.
+
+/**
+ * @file getWeekdayHeaderNames.ts
+ * @input Generated CLDR weekday header table and the shared date formatter
+ * @output Private resolver for one locale's weekday header row
+ * @position Package-internal pure utility for the Calendar grid and the
+ * DateInput and DateTimeInput bottom sheets; not exported from the package
+ */
+
+import {characterCount} from '../utils/characters';
+import type {DayOfWeek} from '../utils/dateTypes';
+import {plainDateWeekdayNames} from '../utils/plainDate';
+import {
+ weekdayHeaderNamesByLocale,
+ type WeekdayHeaderNames,
+} from './weekdayHeaderNames.generated';
+
+const weekdayNamesByLocale: Readonly<Record<string, WeekdayHeaderNames>> =
+ weekdayHeaderNamesByLocale;
+const englishWeekdayNames = weekdayNamesByLocale.en;
+
+/** The longest abbreviated name a header row takes; the generator uses the same. */
+export const MAX_ABBREVIATED_HEADER_LENGTH = 4;
+
+function fitsHeader(names: ReadonlyArray<string>): boolean {
+ return names.every(
+ name => characterCount(name) <= MAX_ABBREVIATED_HEADER_LENGTH,
+ );
+}
+
+/**
+ * A language with no generated row keeps its own words. `Intl` has no CLDR
+ * short width, so names too long for the column fall to the narrow width.
+ */
+function sundayFirstNames(locale: string): ReadonlyArray<string> {
+ let parsed: Intl.Locale;
+ try {
+ parsed = new Intl.Locale(locale);
+ } catch {
+ return englishWeekdayNames;
+ }
+ const generated =
+ weekdayNamesByLocale[parsed.baseName] ??
+ weekdayNamesByLocale[parsed.language];
+ if (generated != null) {
+ return generated;
+ }
+ const abbreviated = plainDateWeekdayNames(parsed.baseName);
+ if (abbreviated == null) {
+ return englishWeekdayNames;
+ }
+ if (fitsHeader(abbreviated)) {
+ return abbreviated;
+ }
+ return (
+ plainDateWeekdayNames(parsed.baseName, 'narrow') ?? englishWeekdayNames
+ );
+}
+
+/** One weekday header cell: its day of week (a stable key, since narrow names repeat) and its name. */
+export interface WeekdayHeader {
+ dayOfWeek: DayOfWeek;
+ name: string;
+}
+
+/**
+ * The seven weekday headers for a locale, in column order for the week that
+ * starts on `weekStartsOn`. Unicode extensions are ignored.
+ */
+export function getWeekdayHeaders(
+ locale: string,
+ weekStartsOn: DayOfWeek = 0,
+): WeekdayHeader[] {
+ const names = sundayFirstNames(locale);
+ return Array.from({length: 7}, (_, offset) => {
+ const dayOfWeek = ((weekStartsOn + offset) % 7) as DayOfWeek;
+ return {dayOfWeek, name: names[dayOfWeek]};
+ });
+}
+
+/** The names alone, in the same order as `getWeekdayHeaders`. */
+export function getWeekdayHeaderNames(
+ locale: string,
+ weekStartsOn: DayOfWeek = 0,
+): string[] {
+ return getWeekdayHeaders(locale, weekStartsOn).map(header => header.name);
+}
diff --git a/packages/core/src/Calendar/hooks/useCalendarDays.test.ts b/packages/core/src/Calendar/hooks/useCalendarDays.test.ts
index 4b6a101217..4d85a72914 100644
--- a/packages/core/src/Calendar/hooks/useCalendarDays.test.ts
+++ b/packages/core/src/Calendar/hooks/useCalendarDays.test.ts
@@ -203,13 +203,13 @@ describe('useCalendarDays — day names', () => {
const {result} = renderHook(() => useCalendarDays({year: 2026, month: 6}));
expect(result.current.dayNames).toEqual([
- 'Su',
- 'Mo',
- 'Tu',
- 'We',
- 'Th',
- 'Fr',
- 'Sa',
+ 'Sun',
+ 'Mon',
+ 'Tue',
+ 'Wed',
+ 'Thu',
+ 'Fri',
+ 'Sat',
]);
});
@@ -219,13 +219,13 @@ describe('useCalendarDays — day names', () => {
);
expect(result.current.dayNames).toEqual([
- 'Mo',
- 'Tu',
- 'We',
- 'Th',
- 'Fr',
- 'Sa',
- 'Su',
+ 'Mon',
+ 'Tue',
+ 'Wed',
+ 'Thu',
+ 'Fri',
+ 'Sat',
+ 'Sun',
]);
});
@@ -235,13 +235,13 @@ describe('useCalendarDays — day names', () => {
);
expect(result.current.dayNames).toEqual([
- 'Sa',
- 'Su',
- 'Mo',
- 'Tu',
- 'We',
- 'Th',
- 'Fr',
+ 'Sat',
+ 'Sun',
+ 'Mon',
+ 'Tue',
+ 'Wed',
+ 'Thu',
+ 'Fri',
]);
});
});
diff --git a/packages/core/src/Calendar/hooks/useCalendarDays.ts b/packages/core/src/Calendar/hooks/useCalendarDays.ts
index 10aac9ef09..ac9b7799c1 100644
--- a/packages/core/src/Calendar/hooks/useCalendarDays.ts
+++ b/packages/core/src/Calendar/hooks/useCalendarDays.ts
@@ -22,7 +22,7 @@ import {
plainDateAddDays,
} from '../../utils/plainDate';
import {useLocale} from '../../i18n';
-import {getStandaloneShortWeekdayNames} from '../getStandaloneShortWeekdayNames';
+import {getWeekdayHeaderNames} from '../getWeekdayHeaderNames';
/**
* Represents a single day in the calendar grid.
@@ -111,15 +111,10 @@ export function useCalendarDays(
};
}, [year, month, weekStartsOn, hasVariableRowCount]);
- // Generated strings avoid Date anchors, so weekday headers cannot shift with
- // the runtime timezone. Keep numeric indices as the rotation source of truth.
- const dayNames = useMemo(() => {
- const names = getStandaloneShortWeekdayNames(locale);
- return Array.from(
- {length: 7},
- (_, index) => names[(index + weekStartsOn) % 7],
- );
- }, [locale, weekStartsOn]);
+ const dayNames = useMemo(
+ () => getWeekdayHeaderNames(locale, weekStartsOn),
+ [locale, weekStartsOn],
+ );
// Generate days array
const days = useMemo(() => {
diff --git a/packages/core/src/Calendar/standaloneShortWeekdayNames.generated.ts b/packages/core/src/Calendar/weekdayHeaderNames.generated.ts
similarity index 63%
rename from packages/core/src/Calendar/standaloneShortWeekdayNames.generated.ts
rename to packages/core/src/Calendar/weekdayHeaderNames.generated.ts
index a95c571c7c..0427c6b1e4 100644
--- a/packages/core/src/Calendar/standaloneShortWeekdayNames.generated.ts
+++ b/packages/core/src/Calendar/weekdayHeaderNames.generated.ts
@@ -5,7 +5,7 @@
* Do not edit by hand. Run `pnpm generate:cldr-weekdays` instead.
*/
-export type StandaloneShortWeekdayNames = readonly [
+export type WeekdayHeaderNames = readonly [
string,
string,
string,
@@ -15,36 +15,36 @@ export type StandaloneShortWeekdayNames = readonly [
string,
];
-export const standaloneShortWeekdayNamesByLocale = {
+export const weekdayHeaderNamesByLocale = {
af: ['So.', 'Ma.', 'Di.', 'Wo.', 'Do.', 'Vr.', 'Sa.'],
ar: ['أحد', 'إثنين', 'ثلاثاء', 'أربعاء', 'خميس', 'جمعة', 'سبت'],
'ar-SA': ['أحد', 'إثنين', 'ثلاثاء', 'أربعاء', 'خميس', 'جمعة', 'سبت'],
ca: ['dg.', 'dl.', 'dt.', 'dc.', 'dj.', 'dv.', 'ds.'],
cs: ['ne', 'po', 'út', 'st', 'čt', 'pá', 'so'],
da: ['sø.', 'ma.', 'ti.', 'on.', 'to.', 'fr.', 'lø.'],
- de: ['So.', 'Mo.', 'Di.', 'Mi.', 'Do.', 'Fr.', 'Sa.'],
- el: ['Κυ', 'Δε', 'Τρ', 'Τε', 'Πέ', 'Πα', 'Σά'],
- en: ['Su', 'Mo', 'Tu', 'We', 'Th', 'Fr', 'Sa'],
- es: ['DO', 'LU', 'MA', 'MI', 'JU', 'VI', 'SA'],
+ de: ['So', 'Mo', 'Di', 'Mi', 'Do', 'Fr', 'Sa'],
+ el: ['Κυρ', 'Δευ', 'Τρί', 'Τετ', 'Πέμ', 'Παρ', 'Σάβ'],
+ en: ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'],
+ es: ['dom', 'lun', 'mar', 'mié', 'jue', 'vie', 'sáb'],
fi: ['su', 'ma', 'ti', 'ke', 'to', 'pe', 'la'],
- fr: ['di', 'lu', 'ma', 'me', 'je', 've', 'sa'],
+ fr: ['dim.', 'lun.', 'mar.', 'mer.', 'jeu.', 'ven.', 'sam.'],
he: ['א׳', 'ב׳', 'ג׳', 'ד׳', 'ה׳', 'ו׳', 'ש׳'],
hu: ['V', 'H', 'K', 'Sze', 'Cs', 'P', 'Szo'],
it: ['dom', 'lun', 'mar', 'mer', 'gio', 'ven', 'sab'],
ja: ['日', '月', '火', '水', '木', '金', '土'],
ko: ['일', '월', '화', '수', '목', '금', '토'],
nl: ['zo', 'ma', 'di', 'wo', 'do', 'vr', 'za'],
- no: ['sø.', 'ma.', 'ti.', 'on.', 'to.', 'fr.', 'lø.'],
+ no: ['søn.', 'man.', 'tir.', 'ons.', 'tor.', 'fre.', 'lør.'],
pl: ['nie', 'pon', 'wto', 'śro', 'czw', 'pią', 'sob'],
pt: ['dom.', 'seg.', 'ter.', 'qua.', 'qui.', 'sex.', 'sáb.'],
'pt-PT': ['dom.', 'seg.', 'ter.', 'qua.', 'qui.', 'sex.', 'sáb.'],
- ro: ['du.', 'lu.', 'ma.', 'mi.', 'joi', 'vi.', 'sâ.'],
+ ro: ['dum.', 'lun.', 'mar.', 'mie.', 'joi', 'vin.', 'sâm.'],
ru: ['вс', 'пн', 'вт', 'ср', 'чт', 'пт', 'сб'],
- sr: ['не', 'по', 'ут', 'ср', 'че', 'пе', 'су'],
- sv: ['sö', 'må', 'ti', 'on', 'to', 'fr', 'lö'],
- tr: ['Pa', 'Pt', 'Sa', 'Ça', 'Pe', 'Cu', 'Ct'],
+ sr: ['нед', 'пон', 'уто', 'сре', 'чет', 'пет', 'суб'],
+ sv: ['sön', 'mån', 'tis', 'ons', 'tors', 'fre', 'lör'],
+ tr: ['Paz', 'Pzt', 'Sal', 'Çar', 'Per', 'Cum', 'Cmt'],
uk: ['нд', 'пн', 'вт', 'ср', 'чт', 'пт', 'сб'],
vi: ['CN', 'T2', 'T3', 'T4', 'T5', 'T6', 'T7'],
zh: ['周日', '周一', '周二', '周三', '周四', '周五', '周六'],
- 'zh-TW': ['日', '一', '二', '三', '四', '五', '六'],
-} as const satisfies Readonly<Record<string, StandaloneShortWeekdayNames>>;
+ 'zh-TW': ['週日', '週一', '週二', '週三', '週四', '週五', '週六'],
+} as const satisfies Readonly<Record<string, WeekdayHeaderNames>>;
diff --git a/packages/core/src/DateInput/DateInput.test.tsx b/packages/core/src/DateInput/DateInput.test.tsx
index b9a6859daf..bb6a245577 100644
--- a/packages/core/src/DateInput/DateInput.test.tsx
+++ b/packages/core/src/DateInput/DateInput.test.tsx
@@ -1486,13 +1486,13 @@ describe('DateInput', () => {
<DateInput label="Date" onChange={() => {}} />,
);
expect(openAndReadWeekdays(container)).toEqual([
- 'Su',
- 'Mo',
- 'Tu',
- 'We',
- 'Th',
- 'Fr',
- 'Sa',
+ 'Sun',
+ 'Mon',
+ 'Tue',
+ 'Wed',
+ 'Thu',
+ 'Fri',
+ 'Sat',
]);
});
@@ -1501,13 +1501,13 @@ describe('DateInput', () => {
<DateInput label="Date" onChange={() => {}} weekStartsOn={1} />,
);
expect(openAndReadWeekdays(container)).toEqual([
- 'Mo',
- 'Tu',
- 'We',
- 'Th',
- 'Fr',
- 'Sa',
- 'Su',
+ 'Mon',
+ 'Tue',
+ 'Wed',
+ 'Thu',
+ 'Fri',
+ 'Sat',
+ 'Sun',
]);
});
@@ -1516,13 +1516,13 @@ describe('DateInput', () => {
<DateInput label="Date" onChange={() => {}} weekStartsOn="mon" />,
);
expect(openAndReadWeekdays(container)).toEqual([
- 'Mo',
- 'Tu',
- 'We',
- 'Th',
- 'Fr',
- 'Sa',
- 'Su',
+ 'Mon',
+ 'Tue',
+ 'Wed',
+ 'Thu',
+ 'Fri',
+ 'Sat',
+ 'Sun',
]);
});
});
diff --git a/packages/core/src/DateInput/DateInputTouch.test.tsx b/packages/core/src/DateInput/DateInputTouch.test.tsx
index 5ddeaabc77..9024ebce7b 100644
--- a/packages/core/src/DateInput/DateInputTouch.test.tsx
+++ b/packages/core/src/DateInput/DateInputTouch.test.tsx
@@ -1228,15 +1228,11 @@ describe('DateInput — calendar surface', () => {
[...weekdayRow().children].map(c => c.textContent?.trim());
/**
- * Three letters, where Calendar's own header uses two.
- *
- * The sheet is full width — ~51px a column against Calendar's popover — so
- * there is room for the form people actually read, and a picker driven by
- * thumb should not make anyone decode "Tu" against "Th".
+ * The sheet labels its columns with the names Calendar's header uses, so a
+ * locale reads the same in both pickers.
*
* Exact equality, not `toHaveTextContent`: that matches substrings, so it
- * passes against "Sun" while asserting "Su" and would not have noticed this
- * change at all.
+ * passes against "Sun" while asserting "Su".
*/
it('labels the columns with three-letter weekday names', () => {
renderAndOpen();
@@ -1251,6 +1247,46 @@ describe('DateInput — calendar surface', () => {
]);
});
+ it.each([
+ ['fr-FR', ['dim.', 'lun.', 'mar.', 'mer.', 'jeu.', 'ven.', 'sam.']],
+ ['pt-PT', ['dom.', 'seg.', 'ter.', 'qua.', 'qui.', 'sex.', 'sáb.']],
+ ['pl-PL', ['nie', 'pon', 'wto', 'śro', 'czw', 'pią', 'sob']],
+ ['id-ID', ['Min', 'Sen', 'Sel', 'Rab', 'Kam', 'Jum', 'Sab']],
+ ])(
+ 'labels the columns in %s with the same names as the Calendar header',
+ (locale, names) => {
+ renderAndOpen(
+ <InternationalizationProvider locale={locale}>
+ <Controlled initial="2026-03-21" />
+ </InternationalizationProvider>,
+ );
+ expect(weekdayNames()).toEqual(names);
+ },
+ );
+
+ it('keeps seven aligned columns when repeated narrow names rotate in an open sheet', () => {
+ const errors = vi.spyOn(console, 'error').mockImplementation(() => {});
+ try {
+ const ui = (weekStartsOn: 0 | 1) => (
+ <InternationalizationProvider locale="sw-KE">
+ <Controlled initial="2026-03-21" weekStartsOn={weekStartsOn} />
+ </InternationalizationProvider>
+ );
+ withLayout(() => {
+ const {rerender} = render(ui(0));
+ fireEvent.click(field());
+ expect(weekdayNames()).toEqual(['S', 'M', 'T', 'W', 'T', 'F', 'S']);
+ rerender(ui(1));
+ });
+ expect(weekdayNames()).toEqual(['M', 'T', 'W', 'T', 'F', 'S', 'S']);
+ expect(
+ errors.mock.calls.some(call => String(call[0]).includes('same key')),
+ ).toBe(false);
+ } finally {
+ errors.mockRestore();
+ }
+ });
+
it('rotates the weekday header with weekStartsOn', () => {
renderAndOpen(<Controlled initial="2026-03-21" weekStartsOn={1} />);
expect(weekdayNames()).toEqual([
diff --git a/packages/core/src/DateInput/TouchDateField.tsx b/packages/core/src/DateInput/TouchDateField.tsx
index d70e38935e..6ea4423dc5 100644
--- a/packages/core/src/DateInput/TouchDateField.tsx
+++ b/packages/core/src/DateInput/TouchDateField.tsx
@@ -108,8 +108,6 @@ import {
formatSharedDate,
plainDateFromISO,
plainDateToday,
- plainDateFormat,
- DATE_FORMAT_WEEKDAY_ONLY,
type ISODateString,
} from '../utils';
import {plainDateFormatStandaloneMonthYear} from '../utils/plainDate';
@@ -117,6 +115,7 @@ import {chainEventHandlers} from '../utils/chainEventHandlers';
import {interactionOverlayStyles} from '../utils/interactionOverlay.stylex';
import {usePressFeedback} from '../hooks/usePressFeedback';
import {normalizeDayOfWeek} from '../utils/dateTypes';
+import {getWeekdayHeaders} from '../Calendar/getWeekdayHeaderNames';
import {MonthScroller, type MonthScrollerHandle} from './MonthScroller';
import {MonthYearWheels} from './MonthYearWheels';
import {
@@ -721,34 +720,8 @@ export function TouchDateField({
const {year, month} = fromMonthIndex(monthIndex);
- /**
- * Three-letter weekday names — "Sun", not Calendar's "Su".
- *
- * The sheet is full width and the columns are ~51px, so there is room for
- * the form people actually read, and a picker operated by thumb should not
- * make anyone decode "Tu" against "Th".
- *
- * This is CLDR's `abbreviated` width, which `Intl` produces natively — no
- * truncation, so the 28 non-English locales stay correct rather than being
- * sliced to three characters. (Verified against the CLDR tables for all 30
- * locales in the catalog.) Calendar's 2-letter row is CLDR's *short* width,
- * which `Intl` cannot express, which is exactly why that surface needs a
- * generated table and this one does not.
- *
- * Built here rather than taken from `useCalendarDays`, which supplies the
- * short form for Calendar's own header. The rotation matches: day 4 of
- * January 1970 was a Sunday, so offsetting from it by `weekStartsOn` walks
- * the week in the same order the panes lay out their columns.
- */
- const dayNames = useMemo(
- () =>
- Array.from({length: 7}, (_, offset) =>
- plainDateFormat(
- {year: 1970, month: 1, day: 4 + ((weekStartsOn + offset) % 7)},
- DATE_FORMAT_WEEKDAY_ONLY,
- locale,
- ),
- ),
+ const weekdayHeaders = useMemo(
+ () => getWeekdayHeaders(locale, weekStartsOn),
[locale, weekStartsOn],
);
const monthYearLabel = plainDateFormatStandaloneMonthYear(
@@ -1108,8 +1081,8 @@ export function TouchDateField({
styles.weekdays,
isWheelOpen && styles.weekdaysHidden,
)}>
- {dayNames.map(name => (
- <div key={name} {...stylex.props(styles.weekday)}>
+ {weekdayHeaders.map(({dayOfWeek, name}) => (
+ <div key={dayOfWeek} {...stylex.props(styles.weekday)}>
{name}
</div>
))}
diff --git a/packages/core/src/DateRangeInput/DateRangeInput.test.tsx b/packages/core/src/DateRangeInput/DateRangeInput.test.tsx
index 09384886c7..9ad621dd98 100644
--- a/packages/core/src/DateRangeInput/DateRangeInput.test.tsx
+++ b/packages/core/src/DateRangeInput/DateRangeInput.test.tsx
@@ -954,13 +954,13 @@ describe('DateRangeInput statusVariant forwarding', () => {
<DateRangeInput label="Range" value={null} onChange={() => {}} />,
);
expect(openAndReadWeekdays(container)).toEqual([
- 'Su',
- 'Mo',
- 'Tu',
- 'We',
- 'Th',
- 'Fr',
- 'Sa',
+ 'Sun',
+ 'Mon',
+ 'Tue',
+ 'Wed',
+ 'Thu',
+ 'Fri',
+ 'Sat',
]);
});
@@ -974,13 +974,13 @@ describe('DateRangeInput statusVariant forwarding', () => {
/>,
);
expect(openAndReadWeekdays(container)).toEqual([
- 'Mo',
- 'Tu',
- 'We',
- 'Th',
- 'Fr',
- 'Sa',
- 'Su',
+ 'Mon',
+ 'Tue',
+ 'Wed',
+ 'Thu',
+ 'Fri',
+ 'Sat',
+ 'Sun',
]);
});
@@ -994,13 +994,13 @@ describe('DateRangeInput statusVariant forwarding', () => {
/>,
);
expect(openAndReadWeekdays(container)).toEqual([
- 'Mo',
- 'Tu',
- 'We',
- 'Th',
- 'Fr',
- 'Sa',
- 'Su',
+ 'Mon',
+ 'Tue',
+ 'Wed',
+ 'Thu',
+ 'Fri',
+ 'Sat',
+ 'Sun',
]);
});
});
diff --git a/packages/core/src/DateTimeInput/DateTimeInput.test.tsx b/packages/core/src/DateTimeInput/DateTimeInput.test.tsx
index 40a8bc1b40..a379e1cc5a 100644
--- a/packages/core/src/DateTimeInput/DateTimeInput.test.tsx
+++ b/packages/core/src/DateTimeInput/DateTimeInput.test.tsx
@@ -2494,13 +2494,13 @@ describe('DateTimeInput', () => {
<DateTimeInput label="When" onChange={() => {}} />,
);
expect(openAndReadWeekdays(container)).toEqual([
- 'Su',
- 'Mo',
- 'Tu',
- 'We',
- 'Th',
- 'Fr',
- 'Sa',
+ 'Sun',
+ 'Mon',
+ 'Tue',
+ 'Wed',
+ 'Thu',
+ 'Fri',
+ 'Sat',
]);
});
@@ -2509,13 +2509,13 @@ describe('DateTimeInput', () => {
<DateTimeInput label="When" onChange={() => {}} weekStartsOn={1} />,
);
expect(openAndReadWeekdays(container)).toEqual([
- 'Mo',
- 'Tu',
- 'We',
- 'Th',
- 'Fr',
- 'Sa',
- 'Su',
+ 'Mon',
+ 'Tue',
+ 'Wed',
+ 'Thu',
+ 'Fri',
+ 'Sat',
+ 'Sun',
]);
});
@@ -2524,13 +2524,13 @@ describe('DateTimeInput', () => {
<DateTimeInput label="When" onChange={() => {}} weekStartsOn="mon" />,
);
expect(openAndReadWeekdays(container)).toEqual([
- 'Mo',
- 'Tu',
- 'We',
- 'Th',
- 'Fr',
- 'Sa',
- 'Su',
+ 'Mon',
+ 'Tue',
+ 'Wed',
+ 'Thu',
+ 'Fri',
+ 'Sat',
+ 'Sun',
]);
});
});
diff --git a/packages/core/src/DateTimeInput/DateTimeInputTouch.test.tsx b/packages/core/src/DateTimeInput/DateTimeInputTouch.test.tsx
index e99c9ce40b..2f65d8d054 100644
--- a/packages/core/src/DateTimeInput/DateTimeInputTouch.test.tsx
+++ b/packages/core/src/DateTimeInput/DateTimeInputTouch.test.tsx
@@ -29,6 +29,7 @@ import {Profiler, useState} from 'react';
import * as stylex from '@stylexjs/stylex';
import {readFileSync} from 'node:fs';
import {render, screen, fireEvent, within} from '@testing-library/react';
+import {InternationalizationProvider} from '../i18n';
import {DateTimeInput as CoreDateTimeInput} from './DateTimeInput';
import type {DateTimeInputProps, ISODateTimeString} from './DateTimeInput';
@@ -211,6 +212,65 @@ describe('DateTimeInput touch surface', () => {
});
});
+ it.each([
+ ['en-US', ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat']],
+ ['pt-PT', ['dom.', 'seg.', 'ter.', 'qua.', 'qui.', 'sex.', 'sáb.']],
+ ['id-ID', ['Min', 'Sen', 'Sel', 'Rab', 'Kam', 'Jum', 'Sab']],
+ ])(
+ 'labels the date sheet columns in %s with the Calendar header names',
+ (locale, names) => {
+ withMonthLayout(() => {
+ render(
+ <InternationalizationProvider locale={locale}>
+ <DateTimeInput label="Meeting" onChange={() => {}} />
+ </InternationalizationProvider>,
+ );
+ openDateSheet();
+ // The decorative weekday row is the only 7-cell aria-hidden block.
+ const row = [...document.querySelectorAll('[aria-hidden="true"]')].find(
+ el => el.children.length === 7,
+ );
+ expect(row).toBeDefined();
+ expect([...row!.children].map(c => c.textContent?.trim())).toEqual(
+ names,
+ );
+ });
+ },
+ );
+
+ it('keeps seven aligned date sheet columns when repeated narrow names rotate', () => {
+ const errors = vi.spyOn(console, 'error').mockImplementation(() => {});
+ const readRow = () =>
+ [
+ ...([...document.querySelectorAll('[aria-hidden="true"]')].find(
+ el => el.children.length === 7,
+ )?.children ?? []),
+ ].map(c => c.textContent?.trim());
+ try {
+ const ui = (weekStartsOn: 0 | 1) => (
+ <InternationalizationProvider locale="sw-KE">
+ <DateTimeInput
+ label="Meeting"
+ onChange={() => {}}
+ weekStartsOn={weekStartsOn}
+ />
+ </InternationalizationProvider>
+ );
+ withMonthLayout(() => {
+ const {rerender} = render(ui(0));
+ openDateSheet();
+ expect(readRow()).toEqual(['S', 'M', 'T', 'W', 'T', 'F', 'S']);
+ rerender(ui(1));
+ });
+ expect(readRow()).toEqual(['M', 'T', 'W', 'T', 'F', 'S', 'S']);
+ expect(
+ errors.mock.calls.some(call => String(call[0]).includes('same key')),
+ ).toBe(false);
+ } finally {
+ errors.mockRestore();
+ }
+ });
+
it('uses intrinsic wrapping for the closed touch segments', () => {
const {container} = render(
<DateTimeInput label="Meeting" onChange={() => {}} />,
diff --git a/packages/core/src/DateTimeInput/TouchDateTimeField.tsx b/packages/core/src/DateTimeInput/TouchDateTimeField.tsx
index 1348e65c73..ea83b9c752 100644
--- a/packages/core/src/DateTimeInput/TouchDateTimeField.tsx
+++ b/packages/core/src/DateTimeInput/TouchDateTimeField.tsx
@@ -70,6 +70,7 @@ import {rtlStyles} from '../utils/rtlStyles';
import {themeProps} from '../utils/themeProps';
import {normalizeDayOfWeek} from '../utils/dateTypes';
import {formatLocaleTime} from '../utils/timeFormat';
+import {getWeekdayHeaders} from '../Calendar/getWeekdayHeaderNames';
import {
formatISOTime,
isImeKeyEvent,
@@ -84,7 +85,6 @@ import {chainEventHandlers} from '../utils/chainEventHandlers';
import {joinAriaIDs} from '../utils/inputAria';
import {
DATE_FORMAT_LONG,
- DATE_FORMAT_WEEKDAY_ONLY,
plainDateFormat,
plainDateFromISO,
plainDateToday,
@@ -658,16 +658,9 @@ export function TouchDateTimeField({
const canStepBack = monthIndex > minMonthIndex;
const canStepForward = monthIndex < maxMonthIndex;
- const dayNames = useMemo(
- () =>
- Array.from({length: 7}, (_, offset) =>
- plainDateFormat(
- {year: 1970, month: 1, day: 4 + ((weekStartsOn + offset) % 7)},
- DATE_FORMAT_WEEKDAY_ONLY,
- locale,
- ),
- ),
- [weekStartsOn, locale],
+ const weekdayHeaders = useMemo(
+ () => getWeekdayHeaders(locale, weekStartsOn),
+ [locale, weekStartsOn],
);
const monthYearLabel = plainDateFormatStandaloneMonthYear(
{year, month, day: 1},
@@ -1143,8 +1136,8 @@ export function TouchDateTimeField({
isWheelOpen && styles.touchDateSurfaceHidden,
)}>
<div aria-hidden="true" {...stylex.props(styles.touchWeekdays)}>
- {dayNames.map(name => (
- <div key={name} {...stylex.props(styles.touchWeekday)}>
+ {weekdayHeaders.map(({dayOfWeek, name}) => (
+ <div key={dayOfWeek} {...stylex.props(styles.touchWeekday)}>
{name}
</div>
))}
diff --git a/packages/core/src/utils/plainDate.test.ts b/packages/core/src/utils/plainDate.test.ts
index 5088d6bdc0..3d89751f28 100644
--- a/packages/core/src/utils/plainDate.test.ts
+++ b/packages/core/src/utils/plainDate.test.ts
@@ -29,6 +29,7 @@ import {
plainDateGetWeekNumber,
plainDateFormat,
plainDateFormatStandaloneMonthYear,
+ plainDateWeekdayNames,
plainDateFormatDayNumber,
formatSharedDate,
DATE_FORMAT_LONG,
@@ -984,3 +985,42 @@ describe('plainDateFormatDayNumber', () => {
expect(plainDateFormatDayNumber(1234, 'en')).toBe('1234');
});
});
+
+describe('plainDateWeekdayNames', () => {
+ it('formats the abbreviated weekday names Sunday first', () => {
+ expect(plainDateWeekdayNames('en')).toEqual([
+ 'Sun',
+ 'Mon',
+ 'Tue',
+ 'Wed',
+ 'Thu',
+ 'Fri',
+ 'Sat',
+ ]);
+ expect(plainDateWeekdayNames('id-ID')).toEqual([
+ 'Min',
+ 'Sen',
+ 'Sel',
+ 'Rab',
+ 'Kam',
+ 'Jum',
+ 'Sab',
+ ]);
+ });
+
+ it('formats the narrow width on request', () => {
+ expect(plainDateWeekdayNames('en', 'narrow')).toEqual([
+ 'S',
+ 'M',
+ 'T',
+ 'W',
+ 'T',
+ 'F',
+ 'S',
+ ]);
+ });
+
+ it('returns null for a language the platform has no data for', () => {
+ expect(plainDateWeekdayNames('xx-ZZ')).toBeNull();
+ });
+});
diff --git a/packages/core/src/utils/plainDate.ts b/packages/core/src/utils/plainDate.ts
index d5d2d2ab7a..5c0de3f807 100644
--- a/packages/core/src/utils/plainDate.ts
+++ b/packages/core/src/utils/plainDate.ts
@@ -359,14 +359,37 @@ export function plainDateFormatStandaloneMonthYear(
// e.g. "Sun" (locale-dependent) — the weekday on its own, abbreviated.
//
-// This is CLDR's `abbreviated` width, which `Intl` reaches natively. Note
-// that Calendar's 2-letter header ("Su") is CLDR's *short* width, a
-// different thing that `Intl` cannot express at all — which is why that one
-// needs the generated lookup table beside it and this one does not.
+// This is CLDR's `abbreviated` width. Weekday headers prefer a generated
+// table, because `Intl` has no short width.
export const DATE_FORMAT_WEEKDAY_ONLY: Intl.DateTimeFormatOptions = {
weekday: 'short',
};
+/**
+ * The platform's weekday names for a locale, Sunday first, in `Intl`'s
+ * `short` width (CLDR's abbreviated) or its `narrow` width. Returns `null`
+ * when the platform has no data for the locale's language, so a caller uses
+ * its own fallback instead of the host's default locale.
+ */
+export function plainDateWeekdayNames(
+ locale: Locale,
+ width: 'short' | 'narrow' = 'short',
+): string[] | null {
+ const options: Intl.DateTimeFormatOptions = {weekday: width};
+ // A language the platform lacks resolves to the host's default locale.
+ const resolved = dateTimeFormatFor(locale, {
+ ...options,
+ calendar: 'gregory',
+ }).resolvedOptions().locale;
+ if (new Intl.Locale(resolved).language !== new Intl.Locale(locale).language) {
+ return null;
+ }
+ // January 4, 1970 was a Sunday.
+ return Array.from({length: 7}, (_, day) =>
+ plainDateFormat({year: 1970, month: 1, day: 4 + day}, options, locale),
+ );
+}
+
// e.g. "January" (locale-dependent) — the month on its own, for a control
// that shows a list of months and carries the year separately.
export const DATE_FORMAT_MONTH_ONLY: Intl.DateTimeFormatOptions = {
diff --git a/scripts/generate-cldr-weekdays.mjs b/scripts/generate-cldr-weekdays.mjs
index 9e88a72681..0a56be2a6a 100644
--- a/scripts/generate-cldr-weekdays.mjs
+++ b/scripts/generate-cldr-weekdays.mjs
@@ -1,7 +1,13 @@
// Copyright (c) Meta Platforms, Inc. and affiliates.
/**
- * Generates Calendar's compact CLDR stand-alone-short weekday table.
+ * Generates the weekday header names that Calendar and the DateInput bottom
+ * sheet show, one row of seven names per locale.
+ *
+ * A locale gets its CLDR stand-alone abbreviated names when every one of the
+ * seven is at most four user-perceived characters, and its stand-alone short
+ * names otherwise. Longer names do not fit the day column. One width is chosen
+ * per locale, so a header row never mixes the two.
*
* The runtime package consumes only the checked-in TypeScript output. Raw CLDR
* data stays in root development dependencies and is read only by this script.
@@ -23,7 +29,7 @@ const OUTPUT_FILE = path.join(
'core',
'src',
'Calendar',
- 'standaloneShortWeekdayNames.generated.ts',
+ 'weekdayHeaderNames.generated.ts',
);
const CLDR_DATES_ROOT = path.dirname(
require.resolve('cldr-dates-full/package.json'),
@@ -39,6 +45,8 @@ const LIKELY_SUBTAGS = readJson(
path.join(CLDR_CORE_ROOT, 'supplemental', 'likelySubtags.json'),
).supplemental.likelySubtags;
const DAY_KEYS = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'];
+export const MAX_ABBREVIATED_LENGTH = 4;
+const graphemes = new Intl.Segmenter('en', {granularity: 'grapheme'});
const EXCLUDED_LOCALE_FILES = new Set(['en.json', 'pseudo.json']);
if (CLDR_DATES_PACKAGE.version !== CLDR_CORE_PACKAGE.version) {
@@ -162,8 +170,8 @@ export function getGeneratedLocaleSources() {
sources.set(parsed.language, languageSource);
if (
availableLocales.has(parsed.baseName) ||
- JSON.stringify(readStandaloneShortWeekdays(exactSource)) !==
- JSON.stringify(readStandaloneShortWeekdays(languageSource))
+ JSON.stringify(selectWeekdayHeaderNames(exactSource)) !==
+ JSON.stringify(selectWeekdayHeaderNames(languageSource))
) {
sources.set(parsed.baseName, exactSource);
}
@@ -182,8 +190,11 @@ export function getGeneratedLocales() {
return Object.keys(getGeneratedLocaleSources());
}
-/** Read one CLDR locale's Gregorian stand-alone-short weekdays, Sunday first. */
-export function readStandaloneShortWeekdays(locale) {
+/**
+ * Read one CLDR locale's Gregorian stand-alone weekdays in one width
+ * (`short` or `abbreviated`), Sunday first.
+ */
+export function readStandaloneWeekdays(locale, width) {
const file = path.join(CLDR_MAIN_DIR, locale, 'ca-gregorian.json');
if (!fs.existsSync(file)) {
throw new Error(
@@ -193,38 +204,50 @@ export function readStandaloneShortWeekdays(locale) {
const document = readJson(file);
const localeData = document.main?.[locale];
- const shortDays =
- localeData?.dates?.calendars?.gregorian?.days?.['stand-alone']?.short;
+ const days =
+ localeData?.dates?.calendars?.gregorian?.days?.['stand-alone']?.[width];
- if (!shortDays || typeof shortDays !== 'object') {
+ if (!days || typeof days !== 'object') {
throw new Error(
- `Missing dates.calendars.gregorian.days["stand-alone"].short for ${locale} in ${path.relative(REPO_ROOT, file)}`,
+ `Missing dates.calendars.gregorian.days["stand-alone"].${width} for ${locale} in ${path.relative(REPO_ROOT, file)}`,
);
}
return DAY_KEYS.map(day => {
- const value = shortDays[day];
+ const value = days[day];
if (typeof value !== 'string' || value.length === 0) {
throw new Error(
- `Missing stand-alone-short value for ${locale}.${day} in ${path.relative(REPO_ROOT, file)}`,
+ `Missing stand-alone-${width} value for ${locale}.${day} in ${path.relative(REPO_ROOT, file)}`,
);
}
return value;
});
}
+export function graphemeLength(text) {
+ return [...graphemes.segment(text)].length;
+}
+
+/** Pick the header width for one CLDR locale: abbreviated when all seven fit. */
+export function selectWeekdayHeaderNames(locale) {
+ const abbreviated = readStandaloneWeekdays(locale, 'abbreviated');
+ return abbreviated.every(name => graphemeLength(name) <= MAX_ABBREVIATED_LENGTH)
+ ? abbreviated
+ : readStandaloneWeekdays(locale, 'short');
+}
+
export function generateWeekdayData() {
return Object.fromEntries(
Object.entries(getGeneratedLocaleSources()).map(([locale, source]) => [
locale,
- readStandaloneShortWeekdays(source),
+ selectWeekdayHeaderNames(source),
]),
);
}
export async function renderGeneratedFile() {
const data = generateWeekdayData();
- const source = `// Copyright (c) Meta Platforms, Inc. and affiliates.\n\n/**\n * @generated by scripts/generate-cldr-weekdays.mjs from Unicode CLDR ${CLDR_DATES_PACKAGE.version}.\n * Do not edit by hand. Run \`pnpm generate:cldr-weekdays\` instead.\n */\n\nexport type StandaloneShortWeekdayNames = readonly [\n string,\n string,\n string,\n string,\n string,\n string,\n string,\n];\n\nexport const standaloneShortWeekdayNamesByLocale = ${JSON.stringify(data)} as const satisfies Readonly<\n Record<string, StandaloneShortWeekdayNames>\n>;\n`;
+ const source = `// Copyright (c) Meta Platforms, Inc. and affiliates.\n\n/**\n * @generated by scripts/generate-cldr-weekdays.mjs from Unicode CLDR ${CLDR_DATES_PACKAGE.version}.\n * Do not edit by hand. Run \`pnpm generate:cldr-weekdays\` instead.\n */\n\nexport type WeekdayHeaderNames = readonly [\n string,\n string,\n string,\n string,\n string,\n string,\n string,\n];\n\nexport const weekdayHeaderNamesByLocale = ${JSON.stringify(data)} as const satisfies Readonly<\n Record<string, WeekdayHeaderNames>\n>;\n`;
const prettierConfig = await resolveConfig(OUTPUT_FILE);
return format(source, {...prettierConfig, filepath: OUTPUT_FILE});
diff --git a/scripts/generate-cldr-weekdays.test.mjs b/scripts/generate-cldr-weekdays.test.mjs
index a4a1c259ae..440418ae67 100644
--- a/scripts/generate-cldr-weekdays.test.mjs
+++ b/scripts/generate-cldr-weekdays.test.mjs
@@ -8,21 +8,25 @@ import {describe, expect, it} from 'vitest';
import {
getGeneratedLocales,
getGeneratedLocaleSources,
+ MAX_ABBREVIATED_LENGTH,
renderGeneratedFile,
resolveCldrSourceLocale,
} from './generate-cldr-weekdays.mjs';
-import {standaloneShortWeekdayNamesByLocale} from '../packages/core/src/Calendar/standaloneShortWeekdayNames.generated';
+import {weekdayHeaderNamesByLocale} from '../packages/core/src/Calendar/weekdayHeaderNames.generated';
+import {MAX_ABBREVIATED_HEADER_LENGTH} from '../packages/core/src/Calendar/getWeekdayHeaderNames';
const require = createRequire(import.meta.url);
const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
const CLDR_ROOT = path.dirname(require.resolve('cldr-dates-full/package.json'));
const OUTPUT_FILE = path.join(
ROOT,
- 'packages/core/src/Calendar/standaloneShortWeekdayNames.generated.ts',
+ 'packages/core/src/Calendar/weekdayHeaderNames.generated.ts',
);
const DAY_KEYS = ['sun', 'mon', 'tue', 'wed', 'thu', 'fri', 'sat'];
-function readRawCldr(locale) {
+const graphemes = new Intl.Segmenter('en', {granularity: 'grapheme'});
+
+function readRawCldr(locale, width) {
const document = JSON.parse(
fs.readFileSync(
path.join(CLDR_ROOT, 'main', locale, 'ca-gregorian.json'),
@@ -30,10 +34,18 @@ function readRawCldr(locale) {
),
);
const days =
- document.main[locale].dates.calendars.gregorian.days['stand-alone'].short;
+ document.main[locale].dates.calendars.gregorian.days['stand-alone'][width];
return DAY_KEYS.map(day => days[day]);
}
+function expectedHeaderNames(locale) {
+ const abbreviated = readRawCldr(locale, 'abbreviated');
+ const fits = abbreviated.every(
+ name => [...graphemes.segment(name)].length <= MAX_ABBREVIATED_LENGTH,
+ );
+ return fits ? abbreviated : readRawCldr(locale, 'short');
+}
+
describe('generate-cldr-weekdays', () => {
it('matches checked-in generated output deterministically', async () => {
const first = await renderGeneratedFile();
@@ -54,16 +66,16 @@ describe('generate-cldr-weekdays', () => {
it('matches every generated locale to its pinned raw CLDR source', () => {
const generatedLocales = getGeneratedLocales();
const sources = getGeneratedLocaleSources();
- const checkedInLocales = Object.keys(standaloneShortWeekdayNamesByLocale);
+ const checkedInLocales = Object.keys(weekdayHeaderNamesByLocale);
expect(checkedInLocales.toSorted()).toEqual(generatedLocales.toSorted());
for (const locale of generatedLocales) {
const source = sources[locale];
- const weekdays = standaloneShortWeekdayNamesByLocale[locale];
+ const weekdays = weekdayHeaderNamesByLocale[locale];
expect(source).toBeDefined();
- expect(weekdays).toEqual(readRawCldr(source));
+ expect(weekdays).toEqual(expectedHeaderNames(source));
expect(weekdays).toHaveLength(7);
for (const weekday of weekdays) {
expect(typeof weekday).toBe('string');
@@ -72,4 +84,31 @@ describe('generate-cldr-weekdays', () => {
expect(new Set(weekdays).size).toBe(7);
}
});
+
+ it('picks abbreviated names only where all seven fit in four characters', () => {
+ expect(MAX_ABBREVIATED_LENGTH).toBe(4);
+ // The runtime fallback for unshipped languages applies the same limit.
+ expect(MAX_ABBREVIATED_HEADER_LENGTH).toBe(MAX_ABBREVIATED_LENGTH);
+ expect(weekdayHeaderNamesByLocale.en).toEqual([
+ 'Sun',
+ 'Mon',
+ 'Tue',
+ 'Wed',
+ 'Thu',
+ 'Fri',
+ 'Sat',
+ ]);
+ expect(weekdayHeaderNamesByLocale.en).toEqual(
+ readRawCldr('en', 'abbreviated'),
+ );
+ expect(weekdayHeaderNamesByLocale.fr).toEqual(
+ readRawCldr('fr', 'abbreviated'),
+ );
+ // Whole-word or longer abbreviations keep the whole locale on short names.
+ for (const locale of ['pt-PT', 'pl', 'he', 'da', 'vi', 'ar']) {
+ expect(weekdayHeaderNamesByLocale[locale]).toEqual(
+ readRawCldr(getGeneratedLocaleSources()[locale], 'short'),
+ );
+ }
+ });
});