import './calendar.js'; import './date-field.js'; import { DatePickerPopup } from './date-picker-popup.js'; export type { DateFormat, Era } from '../../core/date.js'; /** * Carbon-style date picker following the WAI-ARIA APG "Date Picker Dialog" pattern. Each text box is * a `` (date-field.ts) and the month grid a `` (calendar.ts); this element * owns the state, the popover, typed-input rules, range rules and validation. * * - Users can type the date or pick it from the calendar. Typed text is parsed the way Carbon / * flatpickr do it: on blur or Enter the numbers are pulled out of whatever was typed * (`s10/12/2026sdsd` → 10/12/2026). Unlike flatpickr, nothing is guessed or discarded silently: * an incomplete date (`10/12`), an impossible one (`31/04`) or text with no date in it stays in * the field with a message, and a date outside min/max or refused by `isDateDisabled` is kept with its own message * (as Angular Material / MUI do). Text that already reads as a fully formatted, selectable date is * committed at once while typing. Thai digits ๐–๙ become 0–9. * - `isDateDisabled` (property) greys out and refuses individual days, e.g. weekends or holidays; * return a string instead of `true` to use it as the message. * - `clearable` adds a clear button inside the field. `size` sm / md / lg matches ui-text-input. * - `show-today` adds a "Today" button under the calendar (Carbon has none; opt-in, Ant / MUI style). * - `range` (Carbon `datePickerType="range"`): two fields, start (`value` / `name` / `label`) and * end (`end-value` / `end-name` / `end-label`), sharing one calendar. Without `end-name` the form gets one * `name` entry `start/end` (Carbon cds-date-picker's range value); with it, two entries. As Cally's range: a pick * keeps the calendar open for the end, with a preview on either side of the start (the pointer's day or the keyboard's; * a refused day doesn't move it); picking an end before the start swaps the two; with a whole range chosen, a pick * starts a new one; `change` fires once both ends are picked (or the calendar closes). A typed end before the start is * kept and reported instead of swapped. Days between are highlighted. * - Keyboard and focus as Carbon (cds-date-picker / React DatePicker, tested key by key): the calendar * opens when the text box gets focus (a click or Tab) and focus stays there, so typing continues and * the calendar follows the typed date. ↓ from the text box moves into the calendar (the field's date, else * today); Tab moves on to the next field, committing what was typed (Carbon: Tab goes into the calendar). In * the calendar Tab and Shift+Tab go round its own controls, ‹, the month, the year, › and the day (Cally, the APG date * picker dialog). The calendar icon is decorative (Carbon), not a button. Picking (the end, in a range) or Esc closes and returns * focus to the text box. * - Calendar keys: ←/→ day, ↑/↓ week, Home/End week start/end, PageUp/PageDown month, * Shift+PageUp/PageDown year, Enter/Space select, Esc close. While the end is picked the range * preview follows the keyboard focus or the pointer, whichever moved last. * - The calendar header has Cally's month and year selects; the month shows its own days, in the weeks it needs * (`show-outside-days`: six weeks with the days of the months before and after). * - Month changes are announced via a live region. * - Thai: `locale="th"`, a `lang="th"` attribute on the element or an ancestor, or `` * gives Thai labels and messages (see shared/localize.ts; register other languages) and shows * years in พ.ศ.; override with `era="ce"`. Typed years follow the same era. * - Form-associated: submits `value` as ISO yyyy-mm-dd (always ค.ศ.); honours required / min / max. * - `picker="auto"` (default) and `custom` open our calendar on every device (a tap on a touch screen opens it with a * day focused, so no on-screen keyboard covers it; a second tap on the box types); `native` opens the OS date picker * via showPicker(). On a phone (a touch screen under 42rem, core/sheet SHEET_MEDIA) `auto` opens the calendar in a * bottom sheet: a modal `` over a scrim (the page behind inert, focus kept inside, the page held still) that * Esc, the × button, a swipe down on its grip or a tap on the scrim closes, padded clear of the safe-area insets. * Focusing the box there doesn't open it (the box keeps focus, so you can type); a tap, ↓ or the toggle does. * `custom` keeps the popover on phones too; `sheet` uses the sheet on every device. * - `readonly` keeps and submits the value but blocks typing and the calendar; `warn` shows a * non-blocking warning. * - State on the host for app styles: `data-open` while the calendar is open, `data-show-error` / * `data-show-warn` while an error / warning line shows (range: under either field) * (e.g. `ui-date-picker[data-open]::part(base)`). * * @cssstate open - While its list or calendar is open (also `[data-open]`) * @cssstate show-error - While its error message shows (also `[data-show-error]`) * @cssstate show-warn - While its warning message shows (also `[data-show-warn]`) * @fires change - When a committed value (start or end) changes: blur, Enter, a calendar pick or clear. * @fires ui-range-start - Detail `{ date }`, `range`: a calendar pick began a range (its start), as Cally's `rangestart`; `change` waits for the end * @fires ui-range-end - Detail `{ date }`, `range`: a calendar pick finished a range (its end), as Cally's `rangeend` * A typed date outside min/max is still committed, with the field reporting the range error. * @slot label - Label content with markup; the `label` attribute is the plain-text fallback * @slot helper-text - Helper text with markup (links, bold); overrides `helper-text` * @slot warn-text - Warning text shown while `warn`; overrides `warn-text` * @slot invalid-text - Error text shown while invalid; overrides `invalid-text` * @slot end-label - Label of the end field in range mode; overrides `end-label` * @csspart base - The field box (range: also `start-base` / `end-base`; same for every field part) * @csspart label - The label * @csspart input - The text box * @csspart clear-button - The × button * @csspart toggle - The calendar icon (decorative, as Carbon) * @csspart status-icon - The error / warning icon * @csspart helper-text - The helper line * @csspart warning-text - The warning line * @csspart warn-text - Same line as `warning-text` (named after the `warn-text` attribute / slot) * @csspart error-text - The error line * @csspart invalid-text - Same line as `error-text` (named after the `invalid-text` attribute / slot) * @csspart calendar - The popover shell (in the bottom sheet: the sheet's panel) * @csspart sheet - The bottom sheet `` on a phone (`picker="auto"` / `sheet`; style its scrim with `::part(sheet)::backdrop`) * @csspart sheet-grip - The sheet's top bar, which a swipe down closes * @csspart sheet-close - The sheet's × button * @csspart header - Calendar month / year row * @csspart nav - Previous / next month buttons * @csspart heading - The month and year selects' row * @csspart month-select - The month select (``'s select) * @csspart year-select - The year select (``'s select) * @csspart month-title - A month's name over its grid when several show * @csspart grid - The table of days * @csspart day - Each day button (its state also: `selected`, `today`, `outside`, `disabled`, `disallowed`, `range-start`, `range-end`, `in-range`, and the names `getDayParts` returns) * @csspart weeknumber - A week-number cell (`show-week-numbers`) * @csspart today-button - The optional "Today" button * @cssprop --ui-field-border - Border on every side of the box (default none: Carbon's underline only; Kanok: a 1px outline) * @cssprop --ui-field-disabled-border-color - Border colour when disabled (default: the underline transparent) * @cssprop --ui-field-readonly-border-color - Border colour when read-only (default: a hairline underline) * @cssprop --ui-field-radius - Corner radius of the box (default 0; Kanok: 6px) * @cssprop --ui-field-background - Fill of the box (default `--ui-surface-1`; Kanok: transparent) * @cssprop --ui-label-font - Font of the label (default `--ui-font-caption`; Kanok: 14px semibold) * @cssprop --ui-label-color - Colour of the label (default `--ui-ink-muted`; Kanok: `--ui-ink`) * @cssprop --ui-menu-radius / --ui-menu-border / --ui-menu-shadow - Corners, border and shadow of the calendar (the menu settings) * @cssprop --ui-sheet-radius - The bottom sheet's top corners (default: the menu radius) * @cssprop --ui-modal-scrim - The bottom sheet's scrim, as the modal's (default Carbon's overlay) * @cssprop --ui-calendar-day-radius - Corner radius of a day (default 0; Kanok: 6px) * @cssprop --ui-calendar-today-dot-radius - Corner radius of today's dot (default 0, a square; Kanok: 50%, a dot) * @cssprop --ui-field-readonly-background - The box's fill when read-only (default transparent; Kanok: a faint ink tint, so read-only reads as set and never weaker than disabled) * @cssprop --ui-fluid-background / --ui-fluid-gap - A fluid box's fill and the space under it (default the layer's fill, 0: boxes that touch; Kanok: transparent, 8px) * @cssprop --ui-icon-control-radius - Corners of its small icon buttons, their hover fill and ring (default 0; Kanok: round) * @cssprop --ui-focus-offset - `outline-offset` of the month arrows' and Today's focus ring (default -2px: inside; Kanok: 2px outside) */ export declare class UiDatePicker extends DatePickerPopup { static hostStates: readonly string[]; static readonly formAssociated = true; static readonly shadowRootOptions: ShadowRootInit; static readonly styles: import("lit").CSSResult[]; /** The names `getDayParts` returned so far: the calendar's parts the picker exports. */ private dayPartNames; protected updated(changed: Map): void; /** Internal states as presence attributes on the host, so app styles can select them (same conditions as render). */ private syncHostState; private onInput; private onFieldKeydown; private onInputPointerDown; /** A touch or pen press on a box that may become the tap that opens the calendar. */ private tap; private onInputPointerUp; /** The finger scrolled the page instead: no tap. */ private onInputPointerCancel; /** Lifting the finger would focus the box (and raise the keyboard) after the tap opened the calendar: not then. */ private onInputTouchEnd; /** Touch (or `picker="native"`): a tap on the text box opens the OS date picker; the calendar icon is no button any more. */ private onInputClick; /** * Carbon: focusing a text box opens the calendar (focus stays in the box). Focus the picker puts back * itself (after a pick, Esc, a form's invalid event) doesn't. Range: the box with focus is the one picked for. */ private onInputFocusIn; /** * Like flatpickr's onBlur: focus moving into the calendar doesn't commit (the user may be about to * pick a day); any other blur commits what was typed. Native `change` isn't used because it also * fires on that move into the calendar. */ private onInputFocusOut; /** Returns false if the browser refused (then we fall back to our calendar). */ private openNativePicker; /** The OS picker can't grey out `isDateDisabled` days, so its pick is committed and validated like typed text. */ private onNativeChange; private clear; private select; /** * Range rules (core/date pickInRange); each box whose value the pick set shows it. The first pick of a range shows its * start at once but its `change` waits for the end (or the calendar closing), as Cally changes once both are picked. */ private selectInRange; private readonly slots; /** One field's error flag and message line (error > warning > helper; the warning only under the start field). */ private fieldStatus; /** One column: a `` fed with this field's text, state and message. */ private renderField; /** * The picker's slots reach the matching column: `label` / `helper-text` / `warn-text` / `invalid-text` → start, * `end-label` → end. A forwarding `` is rendered only when something is slotted: an empty forwarded slot still * counts as "assigned" inside ui-date-field and would hide its attribute-text fallback (label, helper, error). */ private renderForwardedSlots; /** The calendar's `ui-range-start` / `ui-range-end` stay in the picker's shadow root: the picker reports them itself. */ private readonly forwardRangeEvent; /** `getDayParts` for the calendar, noting each new name so the picker exports it. */ private readonly dayParts; private renderGrid; /** The sheet's top bar: a grip to swipe it down, and the × button. */ private renderSheetGrip; render(): import("lit-html").TemplateResult<1>; } declare global { interface HTMLElementTagNameMap { 'ui-date-picker': UiDatePicker; } }