import { DateAdapter } from "../useDate/adapters/adapter.mjs"; import "../useDate/adapters/index.mjs"; import { ComputedRef, MaybeRefOrGetter, Ref } from "vue"; //#region src/composables/createCalendar/index.d.ts /** * One day in the visible grid. * * A spill day from the adjacent month stays in the row. It is `outside` and * not selectable. */ interface CalendarCell { /** * `YYYY-MM-DD` when the grid can page to the day. A spill day before year * 0000 or after year 9999 keeps the adapter's string. That cell is outside * and disabled. */ iso: string; /** Day of the month, 1–31. */ day: number; /** Leading or trailing spill. Not selectable. */ outside: boolean; /** `min`, `max`, `disabled`, or a day that is not `YYYY-MM-DD`. */ disabled: boolean; /** This cell is the current day. */ today: boolean; /** This cell is the selected day, or it lies inside the range. */ selected: boolean; /** This cell is the focused day. It may also be disabled. */ focused: boolean; } /** One visible month. Not a list of months. */ interface CalendarMonth { /** `YYYY-MM`. */ anchor: string; /** Rows of 7 cells. Four to six rows, or six when `fixedWeeks` is set. */ weeks: CalendarCell[][]; } /** * Inclusive range. `start` without `end` is an open range. * * @example * ```ts * const calendar = createCalendar({ mode: 'range', month: '2026-08' }) * * calendar.select('2026-08-10') * calendar.select('2026-08-12') * calendar.value.value // { start: '2026-08-10', end: '2026-08-12' } * ``` */ interface CalendarRange { /** `YYYY-MM-DD`. Replaced when the next day is earlier, or when the range is already closed. */ start?: string; /** `YYYY-MM-DD`. Set for a day on or after `start` while the range is still open. */ end?: string; } /** Selected day, an open or closed range, or nothing. */ type CalendarValue = string | CalendarRange | undefined; /** One day, or a start and an end. */ type CalendarMode = 'single' | 'range'; /** Whole grid, a list of `YYYY-MM-DD` days, or a per-day predicate. */ type CalendarDisabled = boolean | readonly string[] | ((iso: string) => boolean); /** Step size for `move`. */ type CalendarUnit = 'day' | 'week' | 'month' | 'year'; /** Intl weekday length. `narrow` is one letter in most locales. */ type CalendarWeekdayFormat = 'long' | 'short' | 'narrow'; /** * Options for `createCalendar`. * * @example * ```ts * const calendar = createCalendar({ * mode: 'single', * month: '2026-08', * min: '2026-08-01', * max: '2026-08-31', * disabled: iso => iso === '2026-08-15', * firstDayOfWeek: 1, * }) * ``` */ interface CalendarOptions { /** * Date engine. Omit it to borrow an installed date plugin, or to use * `V0PlainDateAdapter` when none is installed. An adapter you pass is not * replaced, and its `firstDayOfWeek` is not written. */ adapter?: DateAdapter; /** Namespace of an installed date plugin. @default 'v0:date' */ namespace?: string; /** * Visible month. `YYYY-MM`, or a day whose month is used. Omitted means the * current month, clamped to `min` and `max`. A writable ref is written as * `YYYY-MM` when the grid pages. Inside a component it is also written when * `min` or `max` clamps the month it opened on. A day token stays while the * page stays in that month. A getter or a readonly ref is not written. */ month?: MaybeRefOrGetter; /** * Selected day, or `{ start, end }` in range mode. A ref is written back. * A getter or a readonly ref is not. Inside a component, changing `mode` * clears it. */ value?: MaybeRefOrGetter; /** * `'single'` selects one day. `'range'` selects a start and an end. * A ref or getter is read on each interaction. Inside a component, changing * it clears the selection. * * @default 'single' */ mode?: MaybeRefOrGetter; /** `YYYY-MM-DD`. Days before it are disabled. */ min?: MaybeRefOrGetter; /** `YYYY-MM-DD`. Days after it are disabled. */ max?: MaybeRefOrGetter; /** * `true` disables every day. An array of `YYYY-MM-DD` days disables those * days. A function disables the days it returns true for. A bare function is * the predicate and is called with the ISO day, not passed through `toValue`. * Navigation still runs. * * @default false */ disabled?: MaybeRefOrGetter; /** * `select` and `unselect` no-op. Cells stay enabled, and paging still runs. * * @default false */ readonly?: MaybeRefOrGetter; /** * Week start. `0` is Sunday. A finite number wins and is not written onto * the adapter. Omit it to follow the adapter, or an owned `locale`. */ firstDayOfWeek?: MaybeRefOrGetter; /** Pad the grid to six rows. @default false */ fixedWeeks?: MaybeRefOrGetter; /** * In single mode, clicking the selected day again does not clear it. * Another day still replaces it. `unselect()` no-ops. Range clicks ignore * this. Nothing is selected until the caller selects a day. * * @default false */ mandatory?: MaybeRefOrGetter; /** * BCP 47 tag. Written onto the adapter only when this call constructs it, * which moves the weekday columns and the month label. A borrowed adapter * keeps its own locale. */ locale?: MaybeRefOrGetter; /** Weekday column labels. @default 'narrow' */ weekdayFormat?: CalendarWeekdayFormat; } /** * Month grid and selection. * * @example * ```ts * const calendar = createCalendar({ month: '2026-08' }) * * calendar.today() // pages to today, selects nothing * calendar.selectToday() // selects today when that day is allowed * calendar.value.value * ``` */ interface CalendarContext { /** The visible month. One object, not an array. */ month: ComputedRef; /** Seven labels, rotated to the week start. */ weekdays: ComputedRef; /** Localized month and year. Year 0 follows Intl, which numbers that year 1. */ label: ComputedRef; /** `YYYY-MM`. */ anchor: Readonly>; /** `YYYY-MM-DD` navigation follows. May sit on a disabled in-month day. */ focused: Readonly>; /** ISO day, or `{ start, end }` in range mode. */ value: Readonly>; /** At the `min` month, or the first representable month. */ isFirst: Readonly>; /** At the `max` month, or the last representable month. */ isLast: Readonly>; /** * Selects an in-month day that is not disabled. * In single mode, a second click on that day clears it, unless `mandatory` is set. * In range mode, a later click sets the end or starts a new range. * * @example * ```ts * calendar.select('2026-08-12') * calendar.select('2026-08-12') // clears * ``` */ select: (iso: string) => void; /** Clears the selection. No-ops when `mandatory` or `readonly` is set. */ unselect: () => void; /** * Pages to the current month and focuses today. Selects nothing. * * @example * ```ts * calendar.today() * calendar.value.value // unchanged * ``` */ today: () => void; /** * Focuses today and selects it when that day is allowed. * * @example * ```ts * calendar.selectToday() * ``` */ selectToday: () => void; /** Page to the next month, clamped to `max`. */ next: () => void; /** Page to the previous month, clamped to `min`. */ prev: () => void; /** Page by whole months, clamped to `min` and `max`. */ step: (count: number) => void; /** `YYYY-MM` or `YYYY-MM-DD`. Pages and focuses. */ goto: (value: string) => void; /** * Walks the focused day and pages when it leaves the month. * A step past `min` or `max` lands on that wall. */ move: (unit: CalendarUnit, amount: number) => void; /** Page to the `min` month. No-op when `min` is unset. */ first: () => void; /** Page to the `max` month. No-op when `max` is unset. */ last: () => void; } /** * Gregorian month grid. * * Selection lives here. Pass `mode: 'range'` for a start and end on the same * grid. `today()` pages and focuses without selecting. `selectToday()` selects * when the day is allowed. * * @param options Month, selection, and bounds. * @returns The calendar context. * * @see https://0.vuetifyjs.com/composables/forms/create-calendar * * @example * ```ts * const calendar = createCalendar({ * month: '2026-02', * firstDayOfWeek: 0, * }) * * calendar.month.value.weeks.length // 4 * ``` */ declare function createCalendar(options: CalendarOptions & { adapter: DateAdapter; }): CalendarContext; declare function createCalendar(options?: CalendarOptions): CalendarContext; //#endregion export { CalendarCell, CalendarContext, CalendarDisabled, CalendarMode, CalendarMonth, CalendarOptions, CalendarRange, CalendarUnit, CalendarValue, CalendarWeekdayFormat, createCalendar };