import { type Era } from '../../core/date.js'; export * from './calendar-select.js'; import { UiElement } from '../shared/element.js'; /** * Modern, accessible calendar month grid following the WAI-ARIA APG "Date Picker Dialog" grid model. * Inspired by Cally: * - Single date, range date, and multi-date selection (`multi`) * - Multi-month side-by-side view (`months`, 1 to 12; `page-by="single"` turns one month at a time) * - Cally's heading selects (``, ``; slot `heading` for your own) * - Cally's options: `show-outside-days`, `show-week-numbers`, `weekday-format`, `today`, `getDayParts`; * ←/→ swap right-to-left * - Fully round circular days and seamless continuous range ribbons * - Rich CSS parts for deep customization * * @csspart months - Multi-month layout container * @csspart month-view - Container of a single month * @csspart month-title - A month's name above its grid when two months show (the header then has the year only) * @csspart header - Month / year row container * @csspart nav - Previous / next navigation buttons * @csspart prev-button - The previous month button * @csspart next-button - The next month button * @csspart heading - The month and year selects' row (the `heading` slot) * @csspart month-select - The default heading's month select (``'s `select`) * @csspart year-select - The default heading's year select (``'s `select`) * @csspart grid - The table grid of days * @csspart table - The table grid of days * @csspart thead - The table header row with weekday labels * @csspart th - Individual weekday heading cell (also `day-N`, 0 = Sunday; the week-number heading also `weeknumber`) * @csspart weeknumber - A week-number cell (`show-week-numbers`) * @csspart tbody - The table body of weeks * @csspart row - Each week table row * @csspart cell - Each day table cell * @csspart day - Each day button; its state adds `day-N` (0 = Sunday), `selected`, `today`, `outside` (another month), * `disabled` (before `min` / after `max`), `disallowed` (refused by `isDateDisabled`), `range-start`, `range-end`, * `in-range`, and the names `getDayParts` returns * @csspart today-button - The optional "Today" footer button * @csspart footer - The footer container * * @cssprop --ui-calendar-day-radius - Corner radius of a day button (default 9999px for circular days) * @cssprop --ui-calendar-today-dot-radius - Corner radius of today's indicator dot (default 50%) * @cssprop --ui-calendar-day-focus - The keyboard focus ring on a day * @cssprop --ui-calendar-selected-focus - Focus ring on a selected day * * @fires ui-pick - Detail `{ date }`, when a day is activated * @fires ui-multi-pick - Detail `{ date, values }`, in multi mode when a day is toggled * @fires ui-focus-change - Detail `{ date }`, when keyboard or navigation moves the focused date * @fires change - Detail `{ value, endValue, values }`, native-like change event on a pick (with `range`, once both ends are picked) * @fires ui-range-start - Detail `{ date }`, with `range`: the first end was picked (Cally `rangestart`) * @fires ui-range-end - Detail `{ date }`, with `range`: the second end was picked (Cally `rangeend`) * @fires ui-page-change - Detail `{ start, end }`, the first and last day shown after the months on show changed (Cally `pagechange`) * * @slot previous - Replaces the previous button's arrow icon * @slot next - Replaces the next button's arrow icon * @slot heading - Replaces the month and year selects; `` / `` put here follow the calendar */ export declare class UiCalendar extends UiElement { static readonly styles: import("lit").CSSResult[]; /** Chosen day (start day in range mode), ISO yyyy-mm-dd. */ value: string; /** Range mode: chosen end day, ISO yyyy-mm-dd. */ endValue: string; /** Whether range selection is enabled. */ range: boolean; /** Multi-date selection mode: select multiple individual dates (like Cally's calendar-multi). */ multi: boolean; /** Selected dates in multi mode (array or comma/space-separated ISO string). */ values: string[] | string; /** Months on show side by side, 1 to 12 (default 1; 12 paged by the page is a calendar year, from January). */ months: number; /** With more than one month, ‹ › and the keys turn a whole page (`months`, the default) or one month (`single`), as Cally's `page-by`. */ pageBy: 'months' | 'single'; /** Show the days of the months before and after, in six weeks (Cally `show-outside-days`); by default they are blank and only the weeks the month needs show. Several months never show them. */ showOutsideDays: boolean; /** A column of ISO week numbers before the weeks (Cally `show-week-numbers`). */ showWeekNumbers: boolean; /** Weekday headings `narrow` (S / อา) or `short` (Sun / อา.); by default narrow in Thai, short otherwise (Cally `format-weekday`). */ weekdayFormat: 'narrow' | 'short' | ''; /** The day marked as today, ISO (default the real today): for tests, demos and another time zone (Cally `today`). */ today: string; /** Extra `part` names for a day, e.g. `holiday` (Cally `getDayParts`). */ getDayParts?: (date: Date) => string; /** Range mode: which end a pick will set; drives the preview highlight. */ activeField: 'start' | 'end'; /** Day that holds the roving tab stop; its month is shown. */ focusDate: Date; /** Minimum selectable ISO date. */ min: string; /** Maximum selectable ISO date. */ max: string; /** Callback to disable individual dates (e.g. weekends, holidays). */ isDateDisabled?: (date: Date) => boolean | string; /** BCP 47 locale for names and labels. Defaults to the nearest `lang`. */ locale: string; /** Year era: `be` (พ.ศ.) or `ce` (ค.ศ.). Defaults to `be` for Thai locales. */ era: Era | ''; /** 0 = Sunday … 6 = Saturday. */ firstDay: number; /** Whether to display the "Today" footer shortcut button. */ showToday: boolean; /** Range mode: the last day the pointer rested on, for the provisional range preview (kept when it leaves the grid, as Cally; a key clears it). */ private hoverDate; /** First month on show; it turns a whole page only when focus leaves the shown months (Cally page-by="months"). */ private pageStart?; private readonly focusedDay; private readonly liveId; private readonly localize; private get resolvedLocale(); private get resolvedEra(); /** Selected dates as clean ISO array in multi mode. */ get multiValues(): string[]; /** Move DOM focus with focusDate only when the user is navigating the grid itself. */ private focusFromGrid; /** Puts DOM focus on the day that holds the roving tab stop. */ focusDay(): void; /** The calendar's Tab stops in order: ‹, its own month and year selects (not when `heading` is slotted), ›, the day that holds the tab stop and Today. */ tabStops(): HTMLElement[]; /** Months on show side by side: 1 to 12. */ private get monthCount(); /** How far ‹ › turn the page: the whole page, or one month with `page-by="single"`. */ private get pageStep(); /** The day shown as today. */ private get todayDate(); protected willUpdate(changed: Map): void; protected updated(changed: Map): void; /** A weekday's heading: `weekday-format`, else the translation's own names when it matches the language, else narrow in Thai and short otherwise. */ private weekdayNames; /** Weekday headings from translation when matching current language, otherwise Intl. */ private ownWeekdays; private get messages(); private get limits(); private unavailable; private dtf; private pick; /** The pointer's day previews the range; a day that can't be picked leaves the preview where it is (Cally). */ private onDayHover; /** A clicked day also takes roving focus; one before `min` / after `max` does nothing (Cally: a disabled button). */ private onDayClick; private moveFocus; /** ‹ › turn the page; focus moves only when its day leaves the page (Cally). */ private turnPage; private onGridKeydown; /** Information marking a day's place in the range (start, end, inside). */ private rangeInfo; /** The day the heading's selects move from: the focused day; with several months, that day in the first month (the one they show). */ private get yearBase(); /** What the heading's selects show (one view for both; each takes its label). */ private headingView; /** Selects slotted into `heading` (or inside what is slotted there) get the calendar's view, as its own do. */ private readonly syncHeading; /** A heading select's choice moves focus there (Cally `focusday`), without taking DOM focus from the select. */ private onHeadingFocusDay; /** A day's classes and parts: the parts add Cally's (its weekday `day-N`, `disabled` past min / max, `disallowed`) and `getDayParts`'. */ private dayLook; private renderDay; /** ‹, the month and year selects (`heading` slot), ›. Several months (Cally): one header over all, the year select only (each grid has its month's name). */ private renderMonthHeader; /** * One month's grid, named by the live region (several months: after its month and year, as each needs its own name); * `title` (several months): its name above it. Only the month's own days show, in the weeks they fall in (Cally), * unless `show-outside-days` (one month); `show-week-numbers` adds a column of ISO week numbers. */ private renderMonthGrid; private renderFooter; /** Focus on the day with the tab stop, or with `{ target: 'previous' | 'next' }` on a month arrow (Cally's `focus()`). */ focus(options?: FocusOptions & { target?: 'day' | 'previous' | 'next'; }): void; render(): import("lit-html").TemplateResult<1>; private renderLiveRegion; } export interface CalendarDateDetail { date: Date; } /** The first and last day on show (`ui-page-change`). */ export interface CalendarPageDetail { start: Date; end: Date; } export interface CalendarMultiDetail { date: Date; values: string[]; } export interface CalendarChangeDetail { value?: string; endValue?: string; values?: string[]; } export interface UiCalendarEventMap extends HTMLElementEventMap { 'ui-pick': CustomEvent; 'ui-multi-pick': CustomEvent; 'ui-focus-change': CustomEvent; 'ui-range-start': CustomEvent; 'ui-range-end': CustomEvent; 'ui-page-change': CustomEvent; change: CustomEvent; } export interface UiCalendar { addEventListener(type: K, listener: (this: UiCalendar, event: UiCalendarEventMap[K]) => unknown, options?: boolean | AddEventListenerOptions): void; addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void; removeEventListener(type: K, listener: (this: UiCalendar, event: UiCalendarEventMap[K]) => unknown, options?: boolean | EventListenerOptions): void; removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void; } declare global { interface HTMLElementTagNameMap { 'ui-calendar': UiCalendar; } }