Repository navigation
feat(Calendar): useCalendarDays and useCalendarNavigation take an optional calendar - #10007
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
AI review status for this pull request.
|
|
/approve-spec c330720 |
babf230 to
5ec2dc4
Compare
c330720 to
af09a12
Compare
…ional calendar Both hooks take `calendar?: CalendarSystem`, default `gregory`, and never read the provider calendar. With a calendar, `useCalendarDays` reads `year` and `month` in the calendar's numbers and keeps Gregorian dates, and `useCalendarNavigation` steps and labels calendar months and returns `visibleCalendarMonths` to feed `useCalendarDays`. Calendar now lays out its grids through the public hook. Without `calendar`, both hooks give the same Gregorian output as before.
af09a12 to
18715cb
Compare
PR Analysis Report🔎 Preview ·
|
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| Calendar · Storybook | 57.1 kB (+172 B) · 9.3 kB CSS (0) | 1,714 (+6) | ✗ · ✓ · ✓ |
| DateRangeInput | 75.7 kB (+170 B) · 11.2 kB CSS (0) | — | — · — · — |
| DateInput | 154.4 kB (+157 B) · 15.5 kB CSS (0) | — | — · — · — |
2 more components
| Component | Size | LoC | Visual · A11y · RTL |
|---|---|---|---|
| DateTimeInput | 176.3 kB (+145 B) · 17.2 kB CSS (0) | — | — · — · — |
| PowerSearch | 248.7 kB (+87 B) · 22.3 kB CSS (0) | — | — · — · — |
Visual changes: 2 snapshots in 1 component
A change is a question for the reviewer, not a failure.
| Component · story | Before | After | Diff |
|---|---|---|---|
| Calendar · Default (neutral, light) | ![]() |
![]() |
![]() |
| Calendar · Default (neutral, dark) | ![]() |
![]() |
![]() |
Package size: @astryxdesign/core 6.48 MB packed (+1.9 kB); no new dependencies.
API changes: core +3 · ~0 · −0
Committed API report behind this build: cli 9 rows, core 5 rows; run pnpm api:report.
3 API changes (advisory)
| Package | Where | Signature | Usage | |
|---|---|---|---|---|
| + | core |
. · Types · interface UseCalendarDaysOptions |
calendar?: CalendarSystem = 'gregory' |
import type {UseCalendarDaysOptions} from '@astryxdesign/core'; const x: UseCalendarDaysOptions = {calendar: …} |
| + | core |
. · Types · interface UseCalendarNavigationOptions |
calendar?: CalendarSystem = 'gregory' |
import type {UseCalendarNavigationOptions} from '@astryxdesign/core'; const x: UseCalendarNavigationOptions = {calendar: …} |
| + | core |
. · Types · interface UseCalendarNavigationReturn |
visibleCalendarMonths: { year: number; month: number }[] |
import type {UseCalendarNavigationReturn} from '@astryxdesign/core'; const x: UseCalendarNavigationReturn = {visibleCalendarMonths: …} |
Touched components checked; add ci:run-visual, ci:run-a11y or ci:run-rtl to run the full suites.
Generated by PR Enrichment workflow | View full report
There was a problem hiding this comment.
Approved pending CI: some CI jobs are still running on this head.
useCalendarDays and useCalendarNavigation now take an optional calendar. Without it, both hooks return their released Gregorian output. The new tests cover Persian, Hebrew leap years, Ethiopic, Chinese, Minguo and the other Gregorian-aligned calendars, and the new calendar cases fail without this change. The Calendar spec change (FR11) has an engineering owner's approval at this head.
- Non-blocking: the doc comment on
calendarMonthFromYearMonth(packages/core/src/utils/calendarSystem.ts, lines 251–252) says a month past the end of its year becomes the year's last month. That is true only for calendars that useTemporal, so consider narrowing it.
[Automated review]
| * The calendar month with these year and month numbers. A month past the end | ||
| * of its year becomes the last month of that year, as Temporal constrains it. |
There was a problem hiding this comment.
Non-blocking: this holds only on the Temporal branch. The Gregorian-aligned branch does not constrain: calendarMonthFromYearMonth('gregory', {year: 2026, month: 13}) returns a start of 2026-13-01 with no length, while Persian month 13 becomes Esfand. Suggested wording: "Temporal constrains a month past the end of its year to that year's last month. Gregorian-aligned calendars do not."
Only packages/core/api-report.md changes, as pnpm api:report writes it on main bfc1dcc: useClickableContainer's parameter spelling (meta#8085), the colorVars and inputWrapperStyles hashes after the dark-mode accent change (meta#9818), and the array spelling of visibleCalendarMonths (meta#10007).
…le (#10056) chore: regenerate the four core API report rows three merges left stale Only packages/core/api-report.md changes, as pnpm api:report writes it on main bfc1dcc: useClickableContainer's parameter spelling (#8085), the colorVars and inputWrapperStyles hashes after the dark-mode accent change (#9818), and the array spelling of visibleCalendarMonths (#10007).






This implements
spec:AST-111(approved in #9605) FR20.User need
Teams build their own month views on the public hooks when
Calendardoes not fit: a team availability grid, an archive browsed month by month, or a compact month strip beside a list. Since #9622,Calendarshows other calendar systems, but the hooks still lay out Gregorian months only. A team that needs Persian, Hebrew or Ethiopic months must rebuild month starts, lengths, leap months and labels on its own.Problem and solution fit
useCalendarDaystakescalendar?: CalendarSystem(defaultgregory). With a calendar,yearandmonthare the calendar's year and the month's position in that year, asTemporal.PlainDatenumbers them (1–13 in a Hebrew leap year). Each day keeps its Gregoriandateandiso.dayNumberis the day of the calendar month, andisOutsideis relative to the calendar month.dayNamesdo not change.useCalendarNavigationtakes the same option.navigateMonthsteps calendar months, andmonthYearLabelis written in the calendar with the same helper as Calendar's heading. A newvisibleCalendarMonths: {year, month}[]gives each visible month in the calendar's numbers, so it feedsuseCalendarDaysdirectly.baseMonthandvisibleMonthsstay the Gregorian first day of each month.InternationalizationProvidercalendar, so a caller's numbers keep their meaning when the application adds a provider calendar.Temporal, a calendar that needs it falls back to Gregorian months and warns once in development (FR5), through the same helpers asCalendar.Calendarnow lays out its grids through the publicuseCalendarDays, and the internal month-days hook is removed.Current specification
spec:AST-111FR20, with FR4 and FR5 (approved in spec(AST-111): date components use the calendar the application chooses #9605).component:Calendaras FR11, with a verification row.Public delta and caller burden
UseCalendarDaysOptions.calendar?: CalendarSystem = 'gregory'UseCalendarNavigationOptions.calendar?: CalendarSystem = 'gregory'UseCalendarNavigationReturn.visibleCalendarMonths: {year: number; month: number}[](in Gregorian numbers when no calendar is set)calendar, both hooks give the released output. The option is additive.gregory,iso8601,buddhist,rocandjapaneseneedTemporal, as forCalendar.Design and alternatives
yearandmonthmean when an application adds a provider calendar.useCalendarDayskeeps itsyear/monthinput and reads it in the calendar's numbers. The other option, a Gregorian date range or aTemporalobject, would change the hook's shape for every caller.navigateMonth's focus target stays a day offset (offset, default 7), as released. A day offset needs no clamping, and the default stays the same ascalendar: 'gregory'.Calendar's Page-key clamping is outside this hook's API.buddhistandroccount years from another epoch (2569 and 115 for 2026) and work withoutTemporal.Evidence
useCalendarDayswithoutcalendardeep-equals a verbatim copy of the released grid algorithm for six months (a six-row month, a 28-day month that starts onweekStartsOn, a leap February, two variable-row months including a six-row one, and a month across a year end), withdays,weeks,totalCellsanddayNames.calendar: 'gregory'gives the same output.useCalendarNavigationwithoutcalendarmatches the released months and label inen,th-TH,fa-IRandca.useCalendarDays.test.tsanduseCalendarNavigation.test.tspass unchanged.dayNumber1..30, and Mehr days outside.monthYearLabelmatches Calendar's heading for Persian and Hebrew two-month views, Japanese and Buddhist.visibleCalendarMonthsround-trips intouseCalendarDaysin Persian, Hebrew, Ethiopic, Chinese calendar and Minguo, and the second month starts the day after the first ends.Temporal, a Persian calendar falls back to Gregorian months and warns once. Buddhist keeps its years with no warning.Calendartests pass through the folded code path.Scope
Testing
tsc --noEmit(core)vitest run --maxWorkers=2 packages/core/src/Calendar packages/core/src/i18n packages/core/src/utils packages/core/src/docPropLiterals.test.ts: 1315 of 1316 pass. The one failure,hitArea.test.ts"batches every pending control into one frame", fails the same way on the base branch.packages/cli/api/component),docPropLiterals.test.tspnpm check:knowledge,pnpm check:changesets, ESLint on the changed filespre-review: 812 authored lines, no findingsWriting rubric results
Record touched:
component:Calendar.calendar: 'gregory'".