On this pageTypes
Ui/Calendar
/**
* Discriminated union of attribute groups and derived data the calendar
* component provides to the consumer's `toView` callback. The variant
* matches `model.viewMode`. Pattern-match on `_tag` with `Match.tagsExhaustive`
* to render each mode.
*/
type CalendarAttributes = DaysModeAttributes | MonthsModeAttributes | YearsModeAttributes/** A column header for the day grid's first row (day-of-week labels). */
type ColumnHeader = Readonly<{
attributes: ReadonlyArray<ChildAttribute>
name: string
}>/** Information about a single day cell in the rendered calendar grid. */
type DayCell = Readonly<{
buttonAttributes: ReadonlyArray<ChildAttribute>
cellAttributes: ReadonlyArray<ChildAttribute>
date: CalendarDate
isDisabled: boolean
isFocused: boolean
isInViewMonth: boolean
isSelected: boolean
isToday: boolean
label: string
}>/** Attributes provided to the consumer when rendering the day grid. */
type DaysModeAttributes = Readonly<{
_tag: "Days"
columnHeaders: ReadonlyArray<ColumnHeader>
grid: ReadonlyArray<ChildAttribute>
headerRow: ReadonlyArray<ChildAttribute>
heading: Readonly<{
id: string
text: string
}>
headingButton: ReadonlyArray<ChildAttribute>
nextMonthButton: ReadonlyArray<ChildAttribute>
previousMonthButton: ReadonlyArray<ChildAttribute>
root: ReadonlyArray<ChildAttribute>
weeks: ReadonlyArray<Week>
}>/** Configuration for creating a calendar model with `init`. */
type InitConfig = Readonly<{
disabledDates: ReadonlyArray<CalendarDate>
disabledDaysOfWeek: ReadonlyArray<CalendarDomain.DayOfWeek>
id: string
initialViewDate: CalendarDate
locale: CalendarDomain.LocaleConfig
maxDate: CalendarDate
minDate: CalendarDate
today: CalendarDate
}>/**
* Information about a single month cell in the rendered months grid.
* `label` is the locale-aware full month name (e.g. "September"); `shortLabel`
* is the locale-aware abbreviation (e.g. "Sep"). Render whichever fits the
* cell. Never substring `label` to abbreviate, since that's not safe across
* locales.
*/
type MonthCell = Readonly<{
buttonAttributes: ReadonlyArray<ChildAttribute>
cellAttributes: ReadonlyArray<ChildAttribute>
isCurrentMonth: boolean
isDisabled: boolean
isFocused: boolean
isSelected: boolean
label: string
month: number
shortLabel: string
}>/**
* Attributes provided to the consumer when rendering the months grid. The
* 12 cells are pre-built in calendar (locale-ordered). The consumer arranges
* them in whatever grid layout they prefer (3×4 is the typical choice).
*/
type MonthsModeAttributes = Readonly<{
_tag: "Months"
cells: ReadonlyArray<MonthCell>
grid: ReadonlyArray<ChildAttribute>
heading: Readonly<{
id: string
text: string
}>
headingButton: ReadonlyArray<ChildAttribute>
root: ReadonlyArray<ChildAttribute>
}>/**
* Per-render view inputs passed to the Calendar connection's `embedView` method.
*
* The Calendar dispatches its own `ClickedDay` message on date commit
* and emits a `SelectedDate` OutMessage. Handle the selection in the
* Calendar connection's OutMessage fold.
*/
type ViewInputs = Readonly<{
maybeSelectedDate: Option.Option<CalendarDate>
toView: (attributes: CalendarAttributes) => Html
}> & ViewLabels/**
* Accessible labels and label builders accepted by Calendar views. DatePicker
* accepts the same fields and forwards them to its embedded CalendarDomain.
*/
type ViewLabels = Readonly<{
daysHeadingButtonLabel: string
monthsHeadingButtonLabel: string
nextMonthLabel: string
nextYearsPageLabel: string
previousMonthLabel: string
previousYearsPageLabel: string
toDaysGridLabel: (monthYear: string) => string
toMonthsGridLabel: (year: number) => string
toWeekLabel: (weekStart: CalendarDate) => string
toYearsGridLabel: (startYear: number, endYear: number) => string
}>/**
* A single week row in the day grid, carrying its own row attributes (role,
* aria-rowindex) alongside its 7 day cells.
*/
type Week = Readonly<{
attributes: ReadonlyArray<ChildAttribute>
cells: ReadonlyArray<DayCell>
}>/** Information about a single year cell in the rendered years grid. */
type YearCell = Readonly<{
buttonAttributes: ReadonlyArray<ChildAttribute>
cellAttributes: ReadonlyArray<ChildAttribute>
isCurrentYear: boolean
isDisabled: boolean
isFocused: boolean
isSelected: boolean
label: string
year: number
}>/**
* Attributes provided to the consumer when rendering the years grid. The
* 12 cells span one paged window; prev/next buttons page by 12 years.
*/
type YearsModeAttributes = Readonly<{
_tag: "Years"
cells: ReadonlyArray<YearCell>
grid: ReadonlyArray<ChildAttribute>
heading: Readonly<{
id: string
text: string
}>
nextPageButton: ReadonlyArray<ChildAttribute>
previousPageButton: ReadonlyArray<ChildAttribute>
root: ReadonlyArray<ChildAttribute>
}>