Records with dates, laid out on a month.
December 2026
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|---|---|---|---|---|---|
import { UiSchema } from "@effect/ui"import { Html } from "@effect/ui/html"import * as stylex from "@stylexjs/stylex"import { Schema } from "effect"import { Outcome } from "./ui/uicontext/components/domain/Outcome.ts"import { Calendar } from "./ui/uicontext/components/kit/Calendar.ts"import { Item, Value } from "./ui/uicontext/components/kit/Property.ts"import { sx } from "./ui/uicontext/components/Sx.ts"import { Toaster } from "./ui/uicontext/components/Toast.ts"import { applyEdit, issueFields, issues } from "./issues.ts"// The backlog by due date. Drag an issue to another day, or focus it and press Alt with an arrow// key. The app here won't put a due date on a weekend, so that move is refused and the issue goes// back. Press a day's number to add an issue due that day.const styles = stylex.create({ frame: { display: "flex", flexDirection: "column", minBlockSize: 640, inlineSize: "100%" },})const Message = UiSchema.TaggedEnum({ RequestedMonthIssues: { month: Schema.String }, RequestedEditIssue: { request: Schema.String, item: Schema.String, key: Schema.String, value: Value }, RequestedNewIssue: { due: Schema.String },})const weekend = (day: string) => [0, 6].includes(new Date(`${day.slice(0, 10)}T00:00:00Z`).getUTCDay())export const IssueCalendar = Html.component({ name: "IssueCalendar", model: Schema.Struct({ month: Schema.String, records: Schema.Array(Item), outcomes: Schema.Array(Outcome), next: Schema.Number }), message: Message,}).make({ init: () => ({ month: "2026-12", records: issues, outcomes: [], next: 145 }), update: { RequestedMonthIssues: ($, { month }) => $.evolve({ month }), RequestedEditIssue: ($, { request, item, key, value }) => key === "due" && typeof value === "string" && weekend(value) ? $.evolve({ outcomes: (o) => [...o.slice(-10), { _tag: "Refused", request, reason: "Due dates fall on working days." }] }) : $.evolve({ records: (records) => records.map((r) => (r.id === item ? applyEdit(r, key, value) : r)), outcomes: (o) => [...o.slice(-10), { _tag: "Accepted", request }], }), // a real app opens a new issue with the day filled in; this one adds a draft RequestedNewIssue: ($, { due }) => $.evolve({ next: (n) => n + 1, records: (records) => [ ...records, { id: `eng-${$.model.next}`, prefix: `ENG-${$.model.next}`, title: "New issue", values: { status: "todo", due } }, ], }), }, view: (h, { month, records, outcomes }) => Toaster(h, { children: [ h.div.attrs(sx(styles.frame)).children( Calendar(h, { props: { label: "Issues", records, fields: issueFields, view: { start: "due" }, chip: ["priority"], month, today: "2026-12-01", create: "New issue", outcomes, locale: "en-US", agentId: "calendar-issues", }, onEmit: { RequestedMonth: ({ month }) => Message.RequestedMonthIssues({ month }), RequestedEdit: (edit) => Message.RequestedEditIssue(edit), RequestedCreate: ({ values }) => { const due = values?.["due"] return typeof due === "string" ? Message.RequestedNewIssue({ due }) : undefined }, RequestedOpen: () => undefined, RequestedAction: () => undefined, RequestedReorder: () => undefined, RequestedView: () => undefined, Selected: () => undefined, }, }), ), ], }),})Installation
pnpm dlx shadcn@latest add checkfu/uicontext/calendarUsage
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
| Mon | Tue | Wed | Thu | Fri | Sat | Sun |
|---|---|---|---|---|---|---|
import { UiSchema } from "@effect/ui"import { Html } from "@effect/ui/html"import * as stylex from "@stylexjs/stylex"import { Schema } from "effect"import { Outcome } from "./ui/uicontext/components/domain/Outcome.ts"import { Calendar } from "./ui/uicontext/components/kit/Calendar.ts"import { Item, Value } from "./ui/uicontext/components/kit/Property.ts"import { sx } from "./ui/uicontext/components/Sx.ts"import { applyDealEdit, dealFields, deals } from "./deals.ts"// A sales team's expected close dates. December 4 is busy: the day shows two deals and a button// for the rest. One deal is locked while finance reviews it, so it can't be dragged.const styles = stylex.create({ frame: { display: "flex", flexDirection: "column", minBlockSize: 620, inlineSize: "100%" },})const Message = UiSchema.TaggedEnum({ RequestedMonthDeals: { month: Schema.String }, RequestedEditDeal: { request: Schema.String, item: Schema.String, key: Schema.String, value: Value },})export const CloseDates = Html.component({ name: "CloseDates", model: Schema.Struct({ month: Schema.String, records: Schema.Array(Item), outcomes: Schema.Array(Outcome) }), message: Message,}).make({ init: () => ({ month: "2026-12", records: deals, outcomes: [] }), update: { RequestedMonthDeals: ($, { month }) => $.evolve({ month }), RequestedEditDeal: ($, { request, item, key, value }) => $.evolve({ records: (records) => records.map((r) => (r.id === item ? applyDealEdit(r, key, value) : r)), outcomes: (o) => [...o.slice(-10), { _tag: "Accepted", request }], }), }, view: (h, { month, records, outcomes }) => h.div.attrs(sx(styles.frame)).children( Calendar(h, { props: { label: "Deals", records, fields: dealFields, // won and lost deals have closed: the calendar shows the open ones view: { start: "close", filter: { match: "all", conditions: [{ key: "stage", op: "isNot", value: ["won", "lost"] }] } }, chip: ["owner"], perDay: 3, month, today: "2026-12-01", weekStart: 1, outcomes, locale: "en-US", agentId: "calendar-deals", }, onEmit: { RequestedMonth: ({ month }) => Message.RequestedMonthDeals({ month }), RequestedEdit: (edit) => Message.RequestedEditDeal(edit), RequestedOpen: () => undefined, RequestedCreate: () => undefined, RequestedAction: () => undefined, RequestedReorder: () => undefined, RequestedView: () => undefined, Selected: () => undefined, }, }), ),})Read only
People who can view but not edit see the same month, without dragging or adding.
December 2026
| Sun | Mon | Tue | Wed | Thu | Fri | Sat |
|---|---|---|---|---|---|---|
import { UiSchema } from "@effect/ui"import { Html } from "@effect/ui/html"import * as stylex from "@stylexjs/stylex"import { Schema } from "effect"import { Calendar } from "./ui/uicontext/components/kit/Calendar.ts"import { sx } from "./ui/uicontext/components/Sx.ts"import { issueFields, issues } from "./issues.ts"// A calendar shared with people who can look but not change: `readOnly` turns off dragging and// adding, and the month is in the address as links the app prints.const styles = stylex.create({ frame: { display: "flex", flexDirection: "column", minBlockSize: 600, inlineSize: "100%" },})const Message = UiSchema.TaggedEnum({ RequestedMonthShared: { month: Schema.String } })export const SharedCalendar = Html.component({ name: "SharedCalendar", model: Schema.Struct({ month: Schema.String }), message: Message,}).make({ init: () => ({ month: "2026-12" }), update: { RequestedMonthShared: ($, { month }) => $.evolve({ month }) }, view: (h, { month }) => h.div.attrs(sx(styles.frame)).children( Calendar(h, { props: { label: "Release plan", records: issues, fields: issueFields, view: { start: "due" }, month, today: "2026-12-01", readOnly: "You can view this calendar, not edit it.", locale: "en-US", agentId: "calendar-shared", }, onEmit: { RequestedMonth: ({ month }) => Message.RequestedMonthShared({ month }), RequestedEdit: () => undefined, RequestedOpen: () => undefined, RequestedCreate: () => undefined, RequestedAction: () => undefined, RequestedReorder: () => undefined, RequestedView: () => undefined, Selected: () => undefined, }, }), ),})API reference
Props
| Name | Type | Default | Description |
|---|---|---|---|
labelrequired | string | — | What these records are: "Tasks" |
recordsrequired | Item[] | — | The records to show, in the order the app gives them |
fieldsrequired | Property[] | — | The fields the records share: their kinds, choices and formats |
view | ViewInput | — | How records show: start is the date field they sit on (the first date field by default), with filter, sort and hidden |
chip | string[] | — | The fields a chip shows after its title, compactly; the first visible select field by default |
monthrequired | string | — | 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 |
controls | boolean | true | Draw Previous, Today and Next above the month; true by default. Off when the app draws its own |
today | string | — | Today, "2026-12-03"; the device's date by default, read once the calendar is in the page |
weekStart | number | Sunday | The first day of the week, 0 (Sunday) to 6; Sunday by default |
perDay | number | 3 | How many chips a day shows before "N more"; 3 by default |
create | string | — | Each day's number becomes a button with this label ("New task"), asking for a record on that day |
readOnly | string | — | Why records can't be rescheduled here: "You can view this calendar, not edit it" |
outcomes | Outcome[] | — | How each requested change settled: pending, accepted, or refused with a reason |
locale | string | — | The locale numbers and dates are formatted in; the browser's by default |
agentId | string | — | The id agents know this view by; the label by default |
Events
| Event | Payload | Description |
|---|---|---|
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
| Action | Description |
|---|---|
ActivatedRecord | Open a record by id |
ChoseMonth | Show another month, "YYYY-MM" |
MovedRecord | Reschedule a record to another day, "YYYY-MM-DD"; a date with a time keeps its time |
ClickedCreate | Start 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.