GhostCalendar specification
Status: Proposed for GHO-102. Spec and implementation ship together; Zac approves both in PR review.
Purpose and user problems
GhostCalendar is a month-grid date surface for choosing one date or a range without an attached text field or popover. Applications need locale-aware week layout, min/max and custom disabled dates, keyboard navigation that matches the WAI-ARIA APG Date Picker Dialog grid, and values that serialize predictably for forms and APIs. The compound headless API mirrors other GhostVue families so a future GhostDatePicker (GHO-103) can embed the same grid in an overlay.
Non-goals
- Text input, popover, or dialog chrome (
GhostDatePicker/GhostPopover). - Time-of-day or time-zone conversion (use
CalendarDateonly; noTimepicker). - Multi-month carousels, infinite scroll, or virtualization.
- iCalendar import/export or scheduling recurrence.
- Replacing consumer-owned business rules beyond
minValue,maxValue, andisDateDisabled.
Public API
Parts and exports
Headless exports from @ghostvue/vue:
GhostCalendar(root state and context provider; renderless)GhostCalendarHeader(layout region for heading and navigation)GhostCalendarHeading(visible month/year label)GhostCalendarPrevButton(previous month control)GhostCalendarNextButton(next month control)GhostCalendarGrid(role="grid"month matrix with weekday headers)GhostCalendarCell(role="gridcell"date control)useGhostCalendar(composable returning navigation, selection, and helpers)- Types: props, slot props, exposed refs,
GhostCalendarSelectionMode,GhostCalendarValue,UseGhostCalendarOptions,UseGhostCalendarReturn, and re-exportedCalendarDateusage notes (values are@internationalized/dateCalendarDateinstances).
Themed exports from @ghostvue/themes:
- All headless parts above (wrappers with
data-themed) plus styles viadefault.css.
Date values and consumer conversion
- Public
modelValue/defaultValueuseCalendarDatefrom@internationalized/date(single mode) or{ start: CalendarDate; end: CalendarDate }(range mode, both ends inclusive when complete). - Convert to ISO calendar string:
date.toString()→YYYY-MM-DD. - Parse ISO:
parseDate(iso). - Convert to
Dateat local noon to avoid DST edges:new Date(date.year, date.month - 1, date.day). - Convert from
Date:new CalendarDate(d.getFullYear(), d.getMonth() + 1, d.getDate()). - The library pins
@internationalized/dateas a runtime dependency of@ghostvue/vue; consumers must not assume a different major API.
Props and configuration
GhostCalendar (root)
| Prop | Type | Default | Contract |
|---|---|---|---|
modelValue | GhostCalendarValue | null | undefined | Controlled selection. Omit for uncontrolled; null is a controlled empty selection (see below). |
defaultValue | GhostCalendarValue | undefined | Initial selection when modelValue is omitted. |
selectionMode | 'single' | 'range' | 'single' | Single date vs inclusive range. |
minValue | CalendarDate | undefined | undefined | Dates before this are disabled. |
maxValue | CalendarDate | undefined | undefined | Dates after this are disabled. |
isDateDisabled | (date: CalendarDate) => boolean | undefined | Additional disabled dates. |
locale | string | 'en-US' | Intl locale for weekday/month labels and default week start. |
weekStartsOn | 0 | 1 | ... | 6 | undefined | undefined | Override week start (Sunday = 0). When omitted, use locale preference. |
visibleMonth | CalendarDate | undefined | undefined | Controlled month anchor (first day of displayed month). |
defaultVisibleMonth | CalendarDate | undefined | undefined | Initial month when visibleMonth is omitted. |
today | CalendarDate | undefined | undefined | Required for deterministic SSR/tests. When omitted, "today" styling is not applied (no implicit new Date() during SSR). |
disabled | boolean | false | Disables grid interaction. |
GhostCalendarHeader, GhostCalendarHeading, nav buttons
| Part | Prop | Default | Contract |
|---|---|---|---|
GhostCalendarHeader | as | 'div' | role="group" with aria-label overridable. |
GhostCalendarHeading | as | 'h2' | id for aria-labelledby on grid. |
GhostCalendarPrevButton | as | 'button' | Previous month; type="button". |
GhostCalendarNextButton | as | 'button' | Next month; type="button". |
GhostCalendarGrid
| Prop | Type | Default | Contract |
|---|---|---|---|
as | element/component | 'div' | Renders weekday header row and body rows inside the grid host (role="grid"). Default slot optional; when omitted, renders GhostCalendarCell for each date in the month grid. |
Host uses role="grid", aria-labelledby → heading id when present, data-part="grid".
GhostCalendarCell
| Prop | Type | Default | Contract |
|---|---|---|---|
as | element/component | 'button' | Native button when as="button". |
date | CalendarDate | required | Calendar day this cell represents. |
v-model contracts
GhostCalendarowns selection viauseControllableStateonmodelValue.update:modelValueemits on user-driven selection changes; controlled parents that ignore the event keep the prior value.visibleMonthis independently controllable viauseControllableState; emitsupdate:visibleMonthwhen navigation changes the displayed month.- Range selection: first activation sets
startwithendequal tostart; second activation on a later day setsend; second on earlier day resetsstart; third activation starts a new range. - Single selection replaces the value on each activation.
- Controlled empty (
null) — added in GHO-208 forGhostDatePicker.modelValue: nullkeeps the calendar controlled while nothing is selected;undefinedstill means uncontrolled.nullpasses through the control-ownership check unchanged, then every selection reader (slotmodelValue,useGhostCalendar().modelValue, cell state) normalizes it to the existing empty output,undefined.defaultValueis ignored for the initial selection, visible month, and focus whilemodelValueisnull. Proposals emitted while controlled-empty use the existing payload types and have no effect until the parent applies them. SettingmodelValueback tonullclears a pending range start, so the next activation starts a new range.GhostCalendarValue, emitted payloads, and thedefaultValuecontract are unchanged.
Events, callbacks, slots, and exposed methods
GhostCalendaremitsupdate:modelValue,update:visibleMonth, andselect.select(date: CalendarDate)(composable:onSelect) fires exactly once for each accepted date activation, after theupdate:modelValueproposal and focus update. It fires for repeated activation of the same date and when a controlled parent ignores the proposal. Activations rejected because the date is outsideminValue/maxValue, unavailable viaisDateDisabled, outside the visible month, or the root isdisabledemit nothing. A pending range start and a completed one-day range propose the same{ start, end }shape; consumers that must tell them apart (such asGhostDatePicker, which owns its own range anchor per the DatePicker specification) countselectactivations instead of reading model proposals.- Default slot:
{ modelValue, visibleMonth, selectionMode }. GhostCalendarHeadingdefault slot:{ label, visibleMonth }(localized month/year string).GhostCalendarGridoptionalcellslot (and theGhostCalendarCelldefault slot) for custom cell content, typed asGhostCalendarGridCellSlotProps:date,disabled,selected,focused,today,outsideMonth,state,accessibleLabel, and the deprecatedformattedDate. Slot content replaces only the visible content; the cell keeps its role, state attributes, andaria-label. The fallback content isdate.day, so a template that wants the day number rendersdate.dayitself.accessibleLabelis the localized full date the cell already uses as its accessible name (aria-label). It is not the visible day number.formattedDateis deprecated: a same-value alias ofaccessibleLabel. Its name read as display text, so templates rendered the full date in every cell. Maintainer decision: addaccessibleLabel, keep passingformattedDatewith a@deprecatedJSDoc tag inGhostCalendarGridCellSlotProps, mark it deprecated in the manifests and docs, and remove it no earlier than 1.0.- Themed
GhostCalendarGridandGhostCalendarCelldeclare the same slot props, and@ghostvue/themesre-exportsGhostCalendarGridCellSlotProps.
- Parts expose
{ element, focus?, blur? }where they render a focusable host.
State model
- Visible month —
visibleMonthnormalized to the first day of that month. - Focused date — internal roving focus target within the grid; initialized from selection or
visibleMonthon mount. - Selection —
data-state="selected" | "range-start" | "range-end" | "range-middle" | "none"on cells. - Outside month — dates shown for layout padding use
data-outside-monthand are disabled for selection (still focusable unless disabled).
Loading, empty, disabled, read-only, and error states
- Root
disableddisables all cells and navigation buttons. - Root
disableddisables the entire calendar. minValue/maxValueare hard bounds: those dates cannot receive focus and keyboard moves stop at the bound.isDateDisabledmarks unavailable dates: they remain focusable, exposearia-disabled, and cannot be selected (React Aria / APG unavailable dates).- Outside-month padding days are not selectable (
aria-disabled) but remain focusable for grid continuity unless out of min/max bounds.
Consumer data
CalendarDateobjects are treated as immutable values (@internationalized/date).isDateDisabledmust be pure; the component does not cache across months beyond the rendered grid.
Accessibility contract
Follows WAI-ARIA APG Date Picker Dialog grid behavior.
Semantics and relationships
- Grid:
role="grid", labeled by heading when mounted. - Weekday row:
role="row"withrole="columnheader"cells. - Date row:
role="row"; each date:role="gridcell"containing a focusable control (defaultbutton) witharia-label= full spoken date,aria-selectedwhen selected, andaria-disabledwhen unavailable or outside-month (nativedisabledonly for min/max/root-disabled dates). Thetodaydate also carriesaria-current="date". - Visually hidden live region (
aria-live="polite") on the root announces month changes whenvisibleMonthupdates from keyboard or buttons. - Stable
data-part,data-ghost-calendar,.ghost-calendar-*classes.
Keyboard interaction (on grid with focus inside)
| Key | Behavior |
|---|---|
ArrowRight / Left | Previous / next day (RTL swaps horizontal). |
ArrowDown / Up | Next / previous week. |
Home / End | Start / end of week (respect weekStartsOn). |
PageDown / PageUp | Next / previous month (moves focus). |
Shift+PageDown/Up | Next / previous year. |
Enter / Space | Select focused date unless unavailable or out of bounds. |
Keyboard moves land on every in-bounds calendar day, including unavailable dates. Only minValue / maxValue stop arrow, home/end, and week moves. Month changes announce the new month label; month-sized moves clamp (e.g. Jan 31 + 1 month → last day of February).
Focus behavior
- Roving
tabindex: focused date0, other in-bounds cells-1. - Tab into grid focuses the selected date when present, else
todaywhen provided, else the first day ofvisibleMonth. - Prev/next buttons are in normal tab order before/after the grid per composition.
Assistive technology expectations
- Heading reflects visible month; live region repeats month on page navigation.
- Selected range announced via
aria-selectedon endpoints and selected singles.
Rendering and customization
ghost-calendar,ghost-calendar-header,ghost-calendar-heading,ghost-calendar-prev,ghost-calendar-next,ghost-calendar-grid,ghost-calendar-cellclasses.data-state,data-outside-month,data-todayon cells.- Consumer
classon parts is merged with the part class, never replaced. - Themed CSS uses existing
--ghost-*tokens only. The themed root renders a.ghost-themed-scopecontainer so every part (weekday header, week rows, cells) matches the recipe; week rows and the weekday header share one 7-column template. Themed previous/next buttons default to a decorative CSS chevron and keep theiraria-labelas the accessible name.
Environment behavior
SSR and hydration
- Pass explicit
todayfor stable today highlighting in SSR and tests. - No
document/windowduring setup; grid keyboard listeners attach inonMounted. Intland@internationalized/dateare pure; locale and pinned dates are deterministic.
Mobile and touch
- Pointer activation on cells selects dates; buttons activate month navigation.
Performance
- One month matrix (~42 cells) per grid; no virtualization.
- Global listeners only on the grid element while mounted.
Composition
- Reuses
useControllableState,useGhostId, patterns fromGhostTabs/GhostSelectfor context injection and attr merging. @internationalized/datefor calendar arithmetic;Intl.DateTimeFormatfor labels.
Test plan
- Unit: selection single/range, min/max bounds vs
isDateDisabledunavailable focus, controlled ignore,selectordering/repeat/disabled suppression, controlled-emptynull(ignored proposals, clearing a pending range), month navigation, keyboard moves, roving tabindex, disabled root, locale week start, SSR no document listeners. - Integration:
expectSsrHydrationcompound tree. - Themed ref smoke test (scaffold).
- E2e: basic example keyboard + pointer + Axe. Real-focus grid navigation and RTL arrow mirroring are tagged
@cross-browserand also run in Firefox and WebKit. - Visual baselines via
pnpm test:visual:dockerfor registered examples. - Type tests for consumer inference, including
#cellslot props (accessibleLabel, and the deprecatedformattedDatealias). - Unit:
#cellcontent keeps the cellaria-label;accessibleLabelequals it andformattedDatestays the same value.
Documentation plan
docs/components/calendar.mdAPI and a11y section.- Examples:
calendar/basic,calendar/range,calendar/controlled,calendar/locale,calendar/themed, andcalendar/deadlines(themed#celltemplate that keeps the day number and adds a marker).
Compatibility and release impact
- New
@ghostvue/vueand@ghostvue/themessurface; Changeset minor for newGhostCalendarfamily and new runtime dependency@internationalized/date@3.12.4. accessibleLabelcell slot prop: additive.formattedDatekeeps its value and type while deprecated, so existing#celltemplates are unaffected; Changeset minor for@ghostvue/vueand@ghostvue/themes(typed themed slots and the re-exported slot props type).
Open architectural questions
None; dependency choice recorded in GHO-102 (Zac, Nov 13, 2026).