Mixins / foldkit-mixins-ui

Calendar

namespace · packages/mixins-ui/src/calendar.ts:1

export * as Calendar from './calendar.js'

In the guides

Members

Calendar.alongside

function · packages/mixins-ui/src/calendar/shown.ts:57

function alongside(
  model: CalendarModel,
  other: CalendarModel,
  offset: number,
): CalendarModel

model showing the month offset months from the one other shows, for two months side by side: after either changes its month, set the other from it (the second with 1, the first with -1). The same Model when it already shows that month.

Calendar.Args

const · packages/mixins-ui/src/calendar/state.ts:50

const Args: Schema.Struct<{ readonly id: Schema.String; readonly today: Schema.Struct<{ readonly year: Schema.Int; readonly month: Schema.Int; readonly day: Schema.Int; }>; readonly selection: Schema.optionalKey<TaggedUnion<{ readonly Single: { readonly date: Schema.OptionFromNullOr<Schema.Struct<{ readonly year: Schema.Int; readonly month: Schema.Int; readonly day: Schema.Int; }>>; }; readonly Range: { readonly start: Schema.OptionFromNullOr<Schema.Struct<{ readonly year: Schema.Int; readonly month: Schema.Int; readonly day: Schema.Int; }>>; readonly end: Schema.OptionFromNullOr<Schema.Struct<{ readonly year: Schema.Int; readonly month: Schema.Int; readonly day: Schema.Int; }>>; }; readonly Multiple: { readonly dates: Schema.$Array<Schema.Struct<{ readonly year: Schema.Int; readonly month: Schema.Int; readonly day: Schema.Int; }>>; }; }>>; readonly months: Schema.optionalKey<Schema.Literals<readonly [1, 2]>>; readonly minDate: Schema.optionalKey<Schema.Struct<{ readonly year: Schema.Int; readonly month: Schema.Int; readonly day: Schema.Int; }>>; readonly maxDate: Schema.optionalKey<Schema.Struct<{ readonly year: Schema.Int; readonly month: Schema.Int; readonly day: Schema.Int; }>>; readonly disabledDaysOfWeek: Schema.optionalKey<Schema.$Array<Schema.Literals<readonly ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]>>>; readonly disabledDates: Schema.optionalKey<Schema.$Array<Schema.Struct<{ readonly year: Schema.Int; readonly month: Schema.Int; readonly day …;

What a Calendar starts from: init's options, and Bundles.Calendar's args.

Calendar.CalendarOptions

interface · packages/mixins-ui/src/calendar.ts:310

interface CalendarOptions<Message> {
  readonly render?: ((resolved: ResolvedCalendar<Message>) => Html) | undefined
  readonly weekNumbers?: boolean | undefined
  readonly caption?: 'grid' | 'label' | undefined
  readonly dropdowns?: Dropdowns<Message> | undefined
  readonly paging?: 'both' | 'previous' | 'next' | 'none' | 'end' | undefined
  readonly preview?: Preview<Message> | undefined
  readonly detail?:
    ((date: Dates.CalendarDate) => Option.Option<string>) | undefined
}

What a Calendar draws beyond upstream's grid. Every option is off by default.

Calendar.CalendarSlots

const · packages/mixins-ui/src/calendar.ts:84

const CalendarSlots: Slots.Contract<{ readonly root: Slot.UnnamedSlot<Capability.Capability<"Container", readonly [Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>]>, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>; readonly header: Slot.UnnamedSlot<Capability.Capability<"Container", readonly [Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>]>, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>; readonly heading: Slot.UnnamedSlot<Capability.Capability<"Container", readonly [Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>]>, readonly Slot.EventName[], readonly Slot.AttributeName[], readonly Slot.RequirementName[], boolean>; readonly previousMonthButton: Slot.UnnamedSlot<Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>, readonly [Event.EventToken<"click">], readonly [Attr.AttrToken<"role">, Attr.AttrToken<"disabled">, Attr.AttrToken<"aria-disabled">], readonly Slot.RequirementName[], boolean>; readonly nextMonthButton: Slot.UnnamedSlot<Capability.Capability<"Interactive", readonly [Capability.Capability<"Base", readonly []>]>, readonly [Event.EventToken<"click">], readonly [Attr.AttrToken<"role">, Attr.AttrToken<"disabled">, Attr.AttrToken<"aria-disabled">], readonly Slot.RequirementName[], boolean>; readonly headingButton: Slot. …;

Calendar is a nested Submodel whose shape depends on model.viewMode. The top-level groups (root, grid, the navigation buttons) and per-item groups (columnHeaders[], weeks[].attributes, the day/month/year cells and their buttons) are each resolved with SlotView.buildersFor, so a contribution to a cell slot applies to every cell while each cell's base keeps its own event ownership (a disabled day omits OnClick). The rest are this package's, so the default drawing puts no markup outside a slot: header, the row of the heading and its paging buttons; heading, the month and year as text when the caption is a label; monthSelect and yearSelect, the caption's dropdowns; weekNumberHeader and weekNumber, a column of ISO week numbers; dayDetail, a line under a day's number, such as its price (detail); presets and preset, buttons that choose a whole selection (presetsView); and what view lays around the months: frame, the named group holding it all; body, the row of presets, months and aside; main, the months over the today button; months, the one or two month grids; todayButton; and aside and footer, which hold drawings the application gives.

Calendar.CalendarView

interface · packages/mixins-ui/src/calendar/view.ts:29

interface CalendarView<Outer> {
  readonly model: Model
  readonly onMessage: (message: Message) => Outer
  readonly label: string
  readonly weekNumbers?: boolean | undefined
  readonly caption?: Caption | undefined
  readonly paging?: 'both' | 'previous' | 'next' | 'none' | 'end' | undefined
  readonly today?: TodayButton | undefined
  readonly presets?: ReadonlyArray<Preset> | undefined
  readonly detail?:
    ((date: Dates.CalendarDate) => Option.Option<string>) | undefined
  readonly aside?: Html | undefined
  readonly footer?: Html | undefined
  readonly words?: Partial<CalendarWords> | undefined
  readonly style?: NamedStyle<typeof CalendarSlots> | undefined
  readonly mixins?: MixinList<Outer> | undefined
}

Calendar.CalendarViewPreset

type · packages/mixins-ui/src/calendar/view.ts:143

type CalendarViewPreset = Pick<
  CalendarView<never>,
  | 'weekNumbers'
  | 'caption'
  | 'paging'
  | 'today'
  | 'presets'
  | 'detail'
  | 'words'
  | 'style'
> & {
  readonly mixins?: MixinList<never>
}

What a Calendar is given once: its look and each option that holds no Message and no drawing. Named apart from Preset, a selection one press away.

Calendar.CalendarWords

interface · packages/mixins-ui/src/calendar/layout.ts:17

interface CalendarWords {
  readonly previousMonth: string
  readonly nextMonth: string
  readonly previousYears: string
  readonly nextYears: string
  readonly toMonths: string
  readonly toYears: string
  readonly daysGrid: string
  readonly week: string
  readonly monthsGrid: string
  readonly yearsGrid: string
  readonly month: string
  readonly year: string
  readonly presets: string
}

The fixed text a Calendar draws or says. Each is text; {blanks} are filled as noted.

Calendar.CaptionDropdowns

interface · packages/mixins-ui/src/calendar/layout.ts:58

interface CaptionDropdowns {
  readonly years?:
    | {
        readonly from: number
        readonly to: number
      }
    | undefined
  readonly month?: 'select' | 'label' | undefined
}

The caption's selects in place of its heading.

Calendar.configure

function · packages/mixins-ui/src/calendar/view.ts:155

function configure<const Names extends string = never>(
  config: Presets<CalendarViewPreset, Names>,
): {
  readonly view: <Outer>(
    options: CalendarView<Outer> & PresetOption<Names>,
    h: HtmlBuilder<Outer>,
  ) => Html
}

The application's own Calendar: base for every use, presets chosen at a use with preset (a set of options, not the calendar's own presets of selections), and the call over both. mixins concatenate in that order and words merge word by word; any other option given at the call replaces the preset's.

Calendar.DateRange

interface · packages/mixins-ui/src/calendar/selection.ts:97

interface DateRange {
  readonly start: Dates.CalendarDate
  readonly end: Dates.CalendarDate
}

A first and a last day, both chosen.

Calendar.datesOf

function · packages/mixins-ui/src/calendar/selection.ts:115

function datesOf(selection: Selection): ReadonlyArray<Dates.CalendarDate>

Every day the selection holds, in order: the one day, each day from a range's start to its end (only its start while it waits for an end), or the days chosen.

Calendar.day

function · packages/mixins-ui/src/calendar/selection.ts:169

function day(date: Dates.CalendarDate): Selection

A Single selection of date, as "Today" or "In a week" choose.

Calendar.draw

function · packages/mixins-ui/src/calendar.ts:567

function draw<Message>(
  calendar: ResolvedCalendar<Message>,
  h: HtmlBuilder<Message>,
): Html

The month grid in every mode, as upstream lays it out, with a header row of its own. The paging buttons hold ‹ and ›, which the Unicode bidi algorithm mirrors right to left, where the buttons also swap sides.

interface · packages/mixins-ui/src/calendar.ts:198

interface DropdownOption {
  readonly value: number
  readonly label: string
  readonly selected: boolean
  readonly disabled: boolean
}

One choice of a caption dropdown.

interface · packages/mixins-ui/src/calendar.ts:289

interface Dropdowns<Message> {
  readonly model: CalendarModel
  readonly onShow: (shown: Shown) => Message
  readonly years?:
    | {
        readonly from: number
        readonly to: number
      }
    | undefined
  readonly month?: 'select' | 'label' | undefined
  readonly words?:
    | {
        readonly month?: string
        readonly year?: string
      }
    | undefined
}

The month and year selects in place of the heading.

Calendar.empty

function · packages/mixins-ui/src/calendar/selection.ts:33

function empty(mode: Selection['_tag']): Selection

A selection of mode with nothing chosen.

Calendar.firstDate

function · packages/mixins-ui/src/calendar/selection.ts:89

function firstDate(selection: Selection): Option.Option<Dates.CalendarDate>

The selection's first day: where a calendar shows it from, as after a preset.

Calendar.init

function · packages/mixins-ui/src/calendar/state.ts:70

function init(args: Args): Model

Calendar.inputs

function · packages/mixins-ui/src/calendar.ts:807

function inputs<Message>(
  selection: Selection,
  mixins: MixinList<Message>,
  context: ResolveContext<unknown, Message>,
  options?: NoInfer<CalendarOptions<Message>>,
): {
  readonly maybeSelectedDate: Option.Option<Dates.CalendarDate>
  readonly toView: (attributes: CalendarAttributes) => Html
}

The Calendar's view inputs from one selection: toView above, and upstream's maybeSelectedDate read from the same selection, so the two cannot mark different days. Spread them into upstream Calendar.view's inputs.

Calendar.isComplete

function · packages/mixins-ui/src/calendar/selection.ts:69

function isComplete(selection: Selection): boolean

Whether the selection is whole: a day chosen, or both ends of a range. A Multiple selection never is, so a picker showing one stays open until it is dismissed.

Calendar.isoWeek

function · packages/mixins-ui/src/calendar.ts:340

function isoWeek(date: Dates.CalendarDate): number

The ISO 8601 week of date: the week of its Thursday, counted in that Thursday's year.

Calendar.isSame

function · packages/mixins-ui/src/calendar/selection.ts:134

function isSame(left: Selection, right: Selection): boolean

Whether two selections hold the same days the same way.

Calendar.lastDays

function · packages/mixins-ui/src/calendar/selection.ts:146

function lastDays(today: Dates.CalendarDate, days: number): Selection

A Range of the days days that end on today: "Last 7 days" is lastDays(today, 7).

Calendar.localeOf

function · packages/mixins-ui/src/calendar.ts:953

function localeOf(tag: string): Dates.LocaleConfig

The calendar's locale for a BCP 47 tag, from the engine's Intl: month and weekday names, the first day of the week (Intl's week info; Monday where the engine has none), and dates written in the language's own order. Pass it as upstream Calendar.init's locale.

Calendar.Message

const · packages/mixins-ui/src/calendar/state.ts:29

const Message: MessageUnion<{ readonly GotCalendarMessage: { readonly message: MessageUnion<{ readonly ClickedDay: { date: Schema.Struct<{ readonly year: Schema.Int; readonly month: Schema.Int; readonly day: Schema.Int; }>; }; readonly PressedKeyOnGrid: { key: Schema.String; isShift: Schema.Boolean; }; readonly ClickedPreviousMonthButton: {}; readonly ClickedNextMonthButton: {}; readonly ClickedHeading: {}; readonly SelectedMonth: { month: Schema.Int; }; readonly SelectedYear: { year: Schema.Int; }; readonly PagedYears: { direction: Schema.Literals<readonly [1, -1]>; }; readonly FocusedGrid: {}; readonly BlurredGrid: {}; readonly RefreshedToday: { today: Schema.Struct<{ readonly year: Schema.Int; readonly month: Schema.Int; readonly day: Schema.Int; }>; }; readonly CompletedFocusGrid: {}; }>; }; readonly GotSecondMessage: { readonly message: MessageUnion<{ readonly ClickedDay: { date: Schema.Struct<{ readonly year: Schema.Int; readonly month: Schema.Int; readonly day: Schema.Int; }>; }; readonly PressedKeyOnGrid: { key: Schema.String; isShift: Schema.Boolean; }; readonly ClickedPreviousMonthButton: {}; readonly ClickedNextMonthButton: {}; readonly ClickedHeading: {}; readonly SelectedMonth: { month: Schema.Int; }; readonly SelectedYear: { year: Schema.Int; }; readonly PagedYears: { direction: Schema.Literals<readonly [1, -1]>; }; readonly FocusedGrid: {}; readonly BlurredGrid: {}; readonly RefreshedToday: { today: Schema.Struct<{ readonly year: Schema.Int; readonly month: Schema.Int; readon …;

Calendar.Model

const · packages/mixins-ui/src/calendar/state.ts:18

const Model: Schema.Struct<{ readonly calendar: Schema.Struct<{ readonly id: Schema.String; readonly today: Schema.Struct<{ readonly year: Schema.Int; readonly month: Schema.Int; readonly day: Schema.Int; }>; readonly viewYear: Schema.Int; readonly viewMonth: Schema.Int; readonly viewMode: Schema.Literals<readonly ["Days", "Months", "Years"]>; readonly maybeFocusedDate: Schema.Option<Schema.Struct<{ readonly year: Schema.Int; readonly month: Schema.Int; readonly day: Schema.Int; }>>; readonly isGridFocused: Schema.Boolean; readonly locale: Schema.Struct<{ readonly firstDayOfWeek: Schema.Literals<readonly ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]>; readonly monthNames: Schema.Tuple<readonly [Schema.String, Schema.String, Schema.String, Schema.String, Schema.String, Schema.String, Schema.String, Schema.String, Schema.String, Schema.String, Schema.String, Schema.String]>; readonly shortMonthNames: Schema.Tuple<readonly [Schema.String, Schema.String, Schema.String, Schema.String, Schema.String, Schema.String, Schema.String, Schema.String, Schema.String, Schema.String, Schema.String, Schema.String]>; readonly dayNames: Schema.Tuple<readonly [Schema.String, Schema.String, Schema.String, Schema.String, Schema.String, Schema.String, Schema.String]>; readonly shortDayNames: Schema.Tuple<readonly [Schema.String, Schema.String, Schema.String, Schema.String, Schema.String, Schema.String, Schema.String]>; readonly longFormat: Schema.NonEmptyArray<import("foldkit/sc …;

Calendar.monthOf

function · packages/mixins-ui/src/calendar/selection.ts:160

function monthOf(today: Dates.CalendarDate, offset?: number): Selection

A Range of the whole month today is in, moved by offset months (-1 for last month).

Calendar.nextDays

function · packages/mixins-ui/src/calendar/selection.ts:153

function nextDays(today: Dates.CalendarDate, days: number): Selection

A Range of the days days that start on today.

Calendar.OutMessage

const · packages/mixins-ui/src/calendar/state.ts:43

const OutMessage: MessageUnion<{
  readonly Changed: {
    readonly selection: TaggedUnion<{
      readonly Single: {
        readonly date: Schema.OptionFromNullOr<
          Schema.Struct<{
            readonly year: Schema.Int
            readonly month: Schema.Int
            readonly day: Schema.Int
          }>
        >
      }
      readonly Range: {
        readonly start: Schema.OptionFromNullOr<
          Schema.Struct<{
            readonly year: Schema.Int
            readonly month: Schema.Int
            readonly day: Schema.Int
          }>
        >
        readonly end: Schema.OptionFromNullOr<
          Schema.Struct<{
            readonly year: Schema.Int
            readonly month: Schema.Int
            readonly day: Schema.Int
          }>
        >
      }
      readonly Multiple: {
        readonly dates: Schema.$Array<
          Schema.Struct<{
            readonly year: Schema.Int
            readonly month: Schema.Int
            readonly day: Schema.Int
          }>
        >
      }
    }>
  }
}>

Calendar.picked

function · packages/mixins-ui/src/calendar/selection.ts:41

function picked(selection: Selection, date: Dates.CalendarDate): Selection

The selection after a day is picked. Single takes the day. Range takes it as the other end of a start waiting for one, the earlier of the two becoming the start; otherwise the day starts a new range. Multiple adds the day, or removes it when it is chosen already, keeping the days in order.

Calendar.Preset

interface · packages/mixins-ui/src/calendar.ts:821

interface Preset {
  readonly label: string
  readonly selection: Selection
}

A named selection one press away, such as "Last 7 days".

Calendar.PresetsView

interface · packages/mixins-ui/src/calendar.ts:826

interface PresetsView<Message> {
  readonly presets: ReadonlyArray<Preset>
  readonly selection: Selection
  readonly onPick: (selection: Selection) => NoInfer<Message>
  readonly label?: string | undefined
  readonly style?: NamedStyle<typeof CalendarSlots> | undefined
  readonly mixins?: MixinList<Message> | undefined
}

Calendar.presetsView

function · packages/mixins-ui/src/calendar.ts:844

function presetsView<Message>(
  options: PresetsView<Message>,
  h: HtmlBuilder<Message>,
): Html

Presets beside a calendar, as shadcn and Zag draw them: a group of buttons, each choosing its whole selection, the one equal to the selection now pressed.

Calendar.Preview

interface · packages/mixins-ui/src/calendar.ts:303

interface Preview<Message> {
  readonly date: Option.Option<Dates.CalendarDate>
  readonly onPreview: (date: Option.Option<Dates.CalendarDate>) => Message
}

A range's preview: the day the pointer is on, while the range waits for its end.

Calendar.rangeOf

function · packages/mixins-ui/src/calendar/selection.ts:103

function rangeOf(selection: Selection): Option.Option<DateRange>

The range a Range selection holds once it has both ends; nothing for any other selection.

Calendar.readingKeys

const · packages/mixins-ui/src/calendar.ts:278

const readingKeys: Mixin<never>

Arrow keys read by the direction the calendar is drawn in: right to left, ArrowLeft goes to the next day, month or year, as the APG asks. Upstream's keys know no direction, and its bundles no view option reaches, so this is a Mount (ReadingKeys) that reads the key before upstream's handler does. Pass it beside the style where the page may be right to left. It is not built in because a Scene test must resolve every Mount with a Message, and this one has none to give.

Calendar.resolve

function · packages/mixins-ui/src/calendar.ts:417

function resolve<Input, Message>(
  render: CalendarAttributes,
  mixins: MixinList<Message>,
  context: ResolveContext<Input, Message>,
  options?: NoInfer<CalendarOptions<Message>>,
): ResolvedCalendar<Message>

Resolves every mode's nested groups, preserving the _tag and heading data.

Calendar.ResolvedCalendar

type · packages/mixins-ui/src/calendar.ts:264

type ResolvedCalendar<Message> =
  ResolvedDays<Message> | ResolvedMonths<Message> | ResolvedYears<Message>

Calendar.ResolvedCaption

type · packages/mixins-ui/src/calendar.ts:211

type ResolvedCaption<Message> =
  | {
      readonly _tag: 'Grid'
      readonly headingButton: SlotAttributes<Message>
    }
  | {
      readonly _tag: 'Label'
      readonly heading: SlotAttributes<Message>
    }
  | {
      readonly _tag: 'Dropdowns'
      readonly month: ResolvedDropdown<Message>
      readonly year: ResolvedDropdown<Message>
    }
  | {
      readonly _tag: 'YearDropdown'
      readonly heading: SlotAttributes<Message>
      readonly month: string
      readonly year: ResolvedDropdown<Message>
    }

What the days' header holds between its paging buttons.

Calendar.ResolvedColumnHeader

type · packages/mixins-ui/src/calendar.ts:167

type ResolvedColumnHeader<Message> = Omit<ColumnHeader, 'attributes'> & {
  readonly attributes: SlotAttributes<Message>
}

Calendar.ResolvedDayCell

type · packages/mixins-ui/src/calendar.ts:170

type ResolvedDayCell<Message> = Omit<
  DayCell,
  'cellAttributes' | 'buttonAttributes'
> & {
  readonly cellAttributes: SlotAttributes<Message>
  readonly buttonAttributes: SlotAttributes<Message>
  readonly detail: Option.Option<{
    readonly text: string
    readonly attributes: SlotAttributes<Message>
  }>
}

Calendar.ResolvedDays

interface · packages/mixins-ui/src/calendar.ts:227

interface ResolvedDays<Message> {
  readonly _tag: 'Days'
  readonly root: SlotAttributes<Message>
  readonly header: SlotAttributes<Message>
  readonly previousMonthButton: Option.Option<SlotAttributes<Message>>
  readonly nextMonthButton: Option.Option<SlotAttributes<Message>>
  readonly pagingAtEnd: boolean
  readonly caption: ResolvedCaption<Message>
  readonly heading: DaysModeAttributes['heading']
  readonly grid: SlotAttributes<Message>
  readonly headerRow: SlotAttributes<Message>
  readonly weekNumberHeader: Option.Option<SlotAttributes<Message>>
  readonly columnHeaders: ReadonlyArray<ResolvedColumnHeader<Message>>
  readonly weeks: ReadonlyArray<ResolvedWeek<Message>>
}

Calendar.ResolvedDropdown

interface · packages/mixins-ui/src/calendar.ts:205

interface ResolvedDropdown<Message> {
  readonly attributes: SlotAttributes<Message>
  readonly options: ReadonlyArray<DropdownOption>
}

Calendar.ResolvedMonthCell

type · packages/mixins-ui/src/calendar.ts:188

type ResolvedMonthCell<Message> = Omit<
  MonthCell,
  'cellAttributes' | 'buttonAttributes'
> & {
  readonly cellAttributes: SlotAttributes<Message>
  readonly buttonAttributes: SlotAttributes<Message>
}

Calendar.ResolvedMonths

interface · packages/mixins-ui/src/calendar.ts:245

interface ResolvedMonths<Message> {
  readonly _tag: 'Months'
  readonly root: SlotAttributes<Message>
  readonly header: SlotAttributes<Message>
  readonly headingButton: SlotAttributes<Message>
  readonly heading: MonthsModeAttributes['heading']
  readonly grid: SlotAttributes<Message>
  readonly cells: ReadonlyArray<ResolvedMonthCell<Message>>
}

Calendar.ResolvedWeek

type · packages/mixins-ui/src/calendar.ts:179

type ResolvedWeek<Message> = Omit<Week, 'attributes' | 'cells'> & {
  readonly attributes: SlotAttributes<Message>
  readonly cells: ReadonlyArray<ResolvedDayCell<Message>>
  readonly weekNumber: Option.Option<{
    readonly number: number
    readonly attributes: SlotAttributes<Message>
  }>
}

Calendar.ResolvedYearCell

type · packages/mixins-ui/src/calendar.ts:192

type ResolvedYearCell<Message> = Omit<
  YearCell,
  'cellAttributes' | 'buttonAttributes'
> & {
  readonly cellAttributes: SlotAttributes<Message>
  readonly buttonAttributes: SlotAttributes<Message>
}

Calendar.ResolvedYears

interface · packages/mixins-ui/src/calendar.ts:254

interface ResolvedYears<Message> {
  readonly _tag: 'Years'
  readonly root: SlotAttributes<Message>
  readonly header: SlotAttributes<Message>
  readonly previousPageButton: SlotAttributes<Message>
  readonly nextPageButton: SlotAttributes<Message>
  readonly heading: YearsModeAttributes['heading']
  readonly grid: SlotAttributes<Message>
  readonly cells: ReadonlyArray<ResolvedYearCell<Message>>
}

Calendar.secondId

function · packages/mixins-ui/src/calendar/state.ts:68

function secondId(id: string): string

The second month's id prefix, for a page that reads its cells.

Calendar.selectedDate

function · packages/mixins-ui/src/calendar/selection.ts:81

function selectedDate(selection: Selection): Option.Option<Dates.CalendarDate>

The one day a Single selection holds, for upstream's maybeSelectedDate: a DatePicker shows it on its trigger and submits it under name. Nothing for a Range or Multiple selection, whose days toView marks.

Calendar.Selection

const · packages/mixins-ui/src/calendar/selection.ts:19

const Selection: TaggedUnion<{
  readonly Single: {
    readonly date: Schema.OptionFromNullOr<
      Schema.Struct<{
        readonly year: Schema.Int
        readonly month: Schema.Int
        readonly day: Schema.Int
      }>
    >
  }
  readonly Range: {
    readonly start: Schema.OptionFromNullOr<
      Schema.Struct<{
        readonly year: Schema.Int
        readonly month: Schema.Int
        readonly day: Schema.Int
      }>
    >
    readonly end: Schema.OptionFromNullOr<
      Schema.Struct<{
        readonly year: Schema.Int
        readonly month: Schema.Int
        readonly day: Schema.Int
      }>
    >
  }
  readonly Multiple: {
    readonly dates: Schema.$Array<
      Schema.Struct<{
        readonly year: Schema.Int
        readonly month: Schema.Int
        readonly day: Schema.Int
      }>
    >
  }
}>

What the application has chosen on a Calendar: one day, a start and an end, or any number of days. The selection is the application's; the Calendar keeps only the month shown and the focus. Fold each SelectedDate through picked, and draw with toView(selection, …). The ends are stored as null, so a selection round-trips through JSON.

Calendar.set

function · packages/mixins-ui/src/calendar/state.ts:173

function set(model: Model, selection: Selection): Model

model holding selection, its month turned to the selection's first day: for a parent that sets the selection itself (a form reset, a value loaded later). Nothing is reported, since the parent chose it.

Calendar.show

function · packages/mixins-ui/src/calendar/shown.ts:32

function show(model: CalendarModel, shown: Shown): CalendarModel

The calendar showing shown: another month of the year shown, or the month shown in another year. The focused day keeps its number where the month has it, and stays inside the bounds. The same Model when that month is already shown.

Calendar.Shown

const · packages/mixins-ui/src/calendar/shown.ts:20

const Shown: TaggedUnion<{
  readonly Month: { readonly month: Schema.Int }
  readonly Year: { readonly year: Schema.Int }
}>

A month the caption's dropdowns move to: a month of the year shown, or the month shown in another year. Each says only what changed, so two changes before a redraw both land; show reads the rest from the Model.

Calendar.TodayButton

interface · packages/mixins-ui/src/calendar/layout.ts:68

interface TodayButton {
  readonly label: string
  readonly selects?: boolean | undefined
}

A button under the months that turns the calendar to today's month.

Calendar.toView

function · packages/mixins-ui/src/calendar.ts:790

function toView<Message>(
  selection: Selection,
  mixins: MixinList<Message>,
  context: ResolveContext<unknown, Message>,
  options?: NoInfer<CalendarOptions<Message>>,
): (attributes: CalendarAttributes) => Html

The calendar's toView, with the days selection holds marked: render receives its bundles with mixins applied and the marks added; without one, they are drawn by draw above. A Mixin that reads the mode needs resolve, whose input can be _tag. inputs gives it with the maybeSelectedDate that agrees with it. options adds week numbers, a caption of dropdowns or a label, hides a paging button, previews a range, and writes a detail under each day.

Calendar.update

function · packages/mixins-ui/src/calendar/state.ts:180

function update(model: Model, message: Message): Return

Calendar.view

function · packages/mixins-ui/src/calendar/view.ts:72

function view<Outer>(options: CalendarView<Outer>, h: HtmlBuilder<Outer>): Html

A Calendar: one month or two, with its presets before the months, a today button under them, and the application's aside and footer around them. Every press goes to onMessage; the selection is model.selection, read with Calendar.selectedDate, rangeOf or datesOf.

Calendar.words

const · packages/mixins-ui/src/calendar/layout.ts:41

const words = {
  previousMonth,
  nextMonth,
  previousYears,
  nextYears,
  toMonths,
  toYears,
  daysGrid,
  week,
  monthsGrid,
  yearsGrid,
  month,
  year,
  presets,
}

The words a Calendar uses when none are given: upstream's English.