Calendar

Records with dates, laid out on a month.

December 2026

SunMonTueWedThuFriSat

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/calendar

Usage

import type { Outcome } from "./ui/uicontext/components/domain/Outcome.ts"import { type Item, type Property, Value } from "./ui/uicontext/components/domain/Record.ts"import { Calendar } from "./ui/uicontext/components/kit/Calendar.ts"
const Message = UiSchema.TaggedEnum({	RequestedMonth: { month: Schema.String },	RequestedEditTask: { request: Schema.String, item: Schema.String, key: Schema.String, value: Value },	RequestedNewTask: { due: Value },})export const TaskCalendar = (	h: Html.H<typeof Message.Type>,	tasks: ReadonlyArray<Item>,	fields: ReadonlyArray<Property>,	month: string,	outcomes: ReadonlyArray<Outcome>,) =>	Calendar(h, {		props: { label: "Tasks", records: tasks, fields, view: { start: "due" }, month, create: "New task", outcomes },		onEmit: {			// the app owns the month, usually in the URL			RequestedMonth: ({ month }) => Message.RequestedMonth({ month }),			// dropping a task on another day is an edit of `due`; answer it through `outcomes`			RequestedEdit: (edit) => Message.RequestedEditTask(edit),			RequestedCreate: ({ values }) => Message.RequestedNewTask({ due: values?.["due"] ?? null }),			RequestedOpen: () => undefined,			RequestedAction: () => undefined,			RequestedReorder: () => undefined,			RequestedView: () => undefined,			Selected: () => undefined,		},	})

Examples

Close dates

Open deals by expected close, weeks from Monday. A busy day folds its extra deals behind a button.

December 2026

MonTueWedThuFriSatSun

Read only

People who can view but not edit see the same month, without dragging or adding.

December 2026

SunMonTueWedThuFriSat

API reference

Props

Calendar props
NameTypeDefaultDescription
labelrequiredstring—What these records are: "Tasks"
recordsrequiredItem[]—The records to show, in the order the app gives them
fieldsrequiredProperty[]—The fields the records share: their kinds, choices and formats
viewViewInput—How records show: start is the date field they sit on (the first date field by default), with filter, sort and hidden
chipstring[]—The fields a chip shows after its title, compactly; the first visible select field by default
monthrequiredstring—The month shown, "2026-12" (see monthOf)
links{ previous, next, today }—The links to the months around this one, printed by the app (see shiftMonth); without them the buttons ask with RequestedMonth
controlsbooleantrueDraw Previous, Today and Next above the month; true by default. Off when the app draws its own
todaystring—Today, "2026-12-03"; the device's date by default, read once the calendar is in the page
weekStartnumberSundayThe first day of the week, 0 (Sunday) to 6; Sunday by default
perDaynumber3How many chips a day shows before "N more"; 3 by default
createstring—Each day's number becomes a button with this label ("New task"), asking for a record on that day
readOnlystring—Why records can't be rescheduled here: "You can view this calendar, not edit it"
outcomesOutcome[]—How each requested change settled: pending, accepted, or refused with a reason
localestring—The locale numbers and dates are formatted in; the browser's by default
agentIdstring—The id agents know this view by; the label by default

Events

Calendar events
EventPayloadDescription
RequestedEdit{ request: string; item: string; key: string; value: Value }A value the person changed; answer through outcomes with the same request
RequestedOpen{ item: string }Open the record's page
RequestedCreate{ group?: string; title?: string; values?: Record<string, Value> }A new record, in the group it was added from ("" for the empty group)
RequestedAction{ action: string; items: string[] }One of the view's actions, on these records
RequestedReorder{ item: string; before: string | null }Move item before before, or last when it's null
RequestedView{ view: View }The person changed how the view shows records (its sort, grouping, widths); pass it back as view
Selected{ items: string[] }The selection changed
RequestedMonth{ month: string }Asks for another month ("2027-01"): from Previous, Today or Next, PageUp or PageDown, or an agent

Agent actions

What agents can do with Calendar
ActionDescription
ActivatedRecordOpen a record by id
ChoseMonthShow another month, "YYYY-MM"
MovedRecordReschedule a record to another day, "YYYY-MM-DD"; a date with a time keeps its time
ClickedCreateStart a new record on a day, "YYYY-MM-DD"

Accessibility

  • Previous, Today and Next move by a month; PageUp and PageDown do the same from anywhere in the calendar, and Shift moves by a year.
  • The month is a table: each weekday is a column header, each day says its full date, and today is marked as the current date.
  • Each record is a link or a button named by its title; its other fields are in its tooltip.

Source