import { PropertyValues } from 'lit'; import { FieldSize } from '../input/UInput.js'; import { UFormControlElement } from '../UFormControlElement.js'; import { DateTextFormat } from '../../utilities/format.js'; import { UCalendar } from '../calendar/UCalendar.js'; import { DateDisabledFn } from '../calendar/dates.js'; import { UPopover } from '../popover/UPopover.js'; export type DatePickerMode = 'date' | 'datetime'; export type { DateDisabledFn } from '../calendar/dates.js'; /** * A single-date(-time)-selection form control. In `mode="date"` (default) the value follows * the same convention as the native `input[type=date]`: an ISO `YYYY-MM-DD` string. The field is a * text box in both modes — type `2026-10-02`, `20261002` or `10-02` (this year), plus a time * (`2026-10-02 14:30`) in `mode="datetime"`, and press Enter or leave the field; the calendar is a * helper. The text shows as `YYYY-MM-DD` (`YYYY-MM-DD HH:mm`) whatever the browser language, or in * the locale's numeric order with `format="locale"`. Clicking the field opens the calendar and keeps * typing in the field; ArrowDown (or Alt+ArrowDown) moves into the calendar. Text that is not a date * clears the value and reports `badInput`, like the native input. In * `mode="datetime"` the value is a complete ISO-8601 `DateTimeOffset` string * (`YYYY-MM-DDTHH:mm:ss±HH:mm`) — the component always fills in seconds and the browser's * local UTC offset, so the value is unconditionally valid regardless of how coarse the time * input was. * * The calendar week starts on the active locale's first day of the week — Monday for `de` `fr` `ru`, * Saturday for `fa` `ar-EG`, Sunday for `en` `ko` `ja` — read from `Intl.Locale`. The weekday row, the * empty cells before the 1st and the Home/End keys all follow it. A browser that does not report week * information gets Sunday. * * Exposes a `:state(open)` custom state (via `ElementInternals.states`) while the calendar * popover is showing — style with `u-date-picker:state(open)::part(container)`. Unlike * `mode`/`clearable`, this state is never reflected as a public attribute — it exists purely * as a CSS hook for consumers who want to react to the open/closed state from outside. * * @csspart field - the u-field element * @csspart input - the text box * @csspart container - the element wrapping the trigger area * @csspart popover - the popover element showing the calendar * @csspart calendar - the calendar container * @csspart calendar-header - the month navigation header * @csspart calendar-title - the "Month Year" title * @csspart calendar-weekdays - the weekday header row * @csspart calendar-grid - the date grid * @csspart calendar-week - one week row inside the date grid * @csspart time-input - the time-of-day input (datetime mode only) * @csspart day - a date cell button * @csspart calendar-footer - the row holding the "today"/"clear" quick-action buttons * @csspart calendar-time - the row holding the time-of-day input (datetime mode only) * * @cssprop --u-date-picker-display - host `display` (default: inline-block). Set `block` to fill * the container width in forms and grid cells. * @cssprop --u-date-picker-width - host `width` (default: auto). Set `100%` where `block` alone * does not stretch the host (e.g. inside a flex container). * @cssprop --date-picker-min-text - minimum width of the text area (default: 4ch). When the suffix buttons (clear · calendar) share a * narrow box, the field overflows its host instead of folding the text to nothing. * @cssprop --date-picker-popover-width - width of the calendar popover (default: 296px, independent of trigger width — a fixed-width calendar reads more naturally) * * @event change - fires when the user clicks a date cell, confirms via keyboard, changes the * time input (datetime mode, once a date is set), or clicks the clear button — with `confirm`, * calendar picks fire it only when Apply commits a different value. Programmatic * value assignment does not fire it (same contract as native form controls). */ export declare class UDatePicker extends UFormControlElement { /** 목록 밖의 값은 어떤 규칙에도 안 걸려 조용히 기본 모양이 된다 — 개발 모드에서 한 번 알린다(`UElement.enumerated`). */ static enumerated: { size: readonly FieldSize[]; mode: readonly DatePickerMode[]; format: readonly DateTextFormat[]; descriptionDisplay: readonly import('../field/UField.js').FieldDescriptionDisplay[]; }; static styles: import('lit').CSSResultGroup[]; protected static fieldBox: boolean; /** 크기 — 다른 필드·버튼과 같은 세 단(`md` = `--u-density`(14px) · `sm` = 그 6/7(12px) · `lg` = 8/7(16px) — 밀도 단을 바꾸면 셋이 함께 움직인다). */ size: FieldSize; /** * 칸이 담을 글자 수 — 지정하면 폭을 정하지 않은 칸(기본 `inline-block`)이 «N자 + 지우기·달력 버튼 + 패딩» 폭으로 그려지고, * 그보다 좁게 주면 넘친다(글자 영역 하한이 N자가 된다). 값의 표시 형식(`format`)이 정하는 길이를 주면 칸이 꼭 그만큼이다. `u-input` 의 `chars` 와 같은 축이다. * 폭을 준 칸에서는 하한으로만 쓴다. */ chars?: number; /** `chars` 의 폭 — 그려지는 N자를 잰다(`ch` 는 글꼴 기능·자간을 빼고 잰다). */ private readonly charsWidth; /** `date` (default) selects a calendar day only. `datetime` also captures a time-of-day and * the value becomes a complete ISO-8601 `DateTimeOffset` string. */ mode: DatePickerMode; /** `mode="datetime"`: the time is entered to the second — the time input shows seconds and the * text box reads and shows `HH:mm:ss`. Without it the time is to the minute (the value always * carries seconds either way). */ seconds: boolean; /** Minimum value (ISO YYYY-MM-DD) — dates before this cannot be selected. Date-only even in * `mode="datetime"`; time-of-day is never range-checked. */ min?: string; /** Maximum value (ISO YYYY-MM-DD) — dates after this cannot be selected. Date-only even in * `mode="datetime"`; time-of-day is never range-checked. */ max?: string; /** Whether to show the clear button */ clearable: boolean; /** App rule for days that cannot be chosen — receives the ISO day, returns `true` to disable it * (weekends, holidays, fully booked days). Such days cannot be picked in the calendar ("Today" too); * a typed or assigned value on one reports `stepMismatch`. Property only. */ isDateDisabled?: DateDisabledFn; /** Placeholder text (shown when there is no value). Defaults to the pattern to type * (`YYYY-MM-DD`, or `YYYY-MM-DD HH:mm` in `mode="datetime"`). */ placeholder?: string; /** How the text box writes and reads the date: `iso` (default, `YYYY-MM-DD` in every language) * or `locale` (the active locale's numeric order, e.g. `10/02/2026` in `en-US`). ISO and * `20261002` are read in both. The time, in `mode="datetime"`, is always `HH:mm`. The value is * ISO either way. */ format: DateTextFormat; /** Picks in the calendar wait for an Apply button instead of committing at once. Choosing a day, * the time, "today" or "clear" inside the calendar only stages the choice; Apply commits it, fires * `change` and closes; Cancel, Escape or closing the calendar any other way drops it. Typing in * the text box still commits on Enter or leaving the field. */ confirm: boolean; containerEl?: HTMLElement; popoverEl?: UPopover; calendarEl?: UCalendar; /** Unique id wiring the combobox's `aria-controls` to the calendar dialog — mirrors USelect's `listboxId`. */ private readonly calendarId; private open; /** Time-of-day for the next selection while no `value` exists yet (`mode="datetime"` only) — * once `value` is set, the time input reads/writes its time portion directly instead. */ private pendingTime; /** With `confirm`, the choice made in the open calendar that Apply would commit. */ private staged?; /** The typed-date text box — what is being typed, committing it, opening the calendar. */ private readonly textEntry; protected shouldValidate(changed: PropertyValues): boolean; protected willUpdate(changed: PropertyValues): void; protected updated(changed: PropertyValues): void; /** What the open calendar shows and edits: the staged choice with `confirm`, otherwise the value. */ private get working(); /** The value as the text box shows it: `YYYY-MM-DD`, or `YYYY-MM-DD HH:mm` in `mode="datetime"`. */ private shownText; /** 보이는 접미 버튼 수 — 글자 영역 하한(`min-inline-size`)이 그만큼의 받는 상자를 뺀다. 아래 `?hidden` 조건과 같다. */ private suffixButtonCount; render(): import('lit-html').TemplateResult<1>; private renderCalendar; private renderTimeRow; private renderFooter; /** A day the calendar refuses — outside `min`/`max` or disabled by `isDateDisabled`. */ private unavailable; /** `timeOverride` lets a caller force the time-of-day (the "today" quick action wants * "right now", overriding whatever time was previously set) — a plain day-cell click omits * it, which preserves the existing time-of-day (or `pendingTime`) so switching the date * alone doesn't clobber a time the user already picked. */ private selectDay; /** Time input change — only commits into `value` once a date already exists (matches native * `datetime-local`: a time alone isn't a complete value). Before that, it just remembers * `pendingTime` for whenever a day gets picked. Doesn't close the popover or refocus the * trigger — unlike selecting a day, adjusting the time doesn't conclude the interaction. */ private handleTimeChange; private handleDaySelect; private get textInputEl(); /** The typed text as a date (ISO) and, in `mode="datetime"`, a time — or `null` when it is not one. * Typing only a date in `mode="datetime"` keeps the time already set (or the pending one). */ private parseTyped; /** Escape inside the grid closes the calendar and returns focus to the trigger — the grid * itself does not know it lives in a popover, so the picker owns this. */ private handleCalendarKeydown; private handlePopoverShow; private handlePopoverHide; private handleClearClick; /** "오늘" 퀵액션 — 달력이 이미 `data-today` 로 표시 중인 날을 실제로 선택하는 것뿐이라 * `selectDay`를 그대로 탄다 * (범위 밖이면 `selectDay`가 조용히 no-op — 클릭 불가 상태인 day 셀과 동일 규약). * datetime 모드에서는 "지금"을 통째로 채우는 것이 소비자 요청의 본질 * 이라 시간까지 `now`로 덮어쓴다 — 평범한 day 셀 클릭과 달리 기존 시각을 보존하지 않는다. */ private handleTodayClick; /** 캘린더 팝오버 안 "초기화" 퀵액션 — 트리거의 clear 아이콘(`handleClearClick`)과 값을 * 비우는 로직은 같지만, 팝오버가 열린 채로 눌렸으므로 선택 완료와 동일하게 닫아 준다. */ private handleFooterResetClick; /** `confirm` 모드의 «적용» — 달력에서 고른 것을 값으로 확정한다(비운 채면 값을 비운다). */ private handleApplyClick; /** `confirm` 모드의 «취소» — 고른 것은 다음에 열 때 값에서 다시 시작하므로 닫기만 하면 버려진다. */ private handleCancelClick; private resetValue; /** suffix `u-icon`은 순수 표시 요소(버튼 아님)라 네이티브 키보드 활성화가 없다 — * `role="button"`+`tabindex="0"`로 포커스 가능하게 한 뒤, Enter/Space를 같은 클릭 * 핸들러로 릴레이한다(`UInput`/`USelect`의 동일 패턴과 일치). */ private handleClearKeydown; private emitChange; protected setValidity(): void; reset(): void; /** `.container`는 div라 네이티브 `disabled`가 없다 — disabled일 때 `tabindex="-1"`로만 * Tab 순서에서 빠지고 프로그램적 `.focus()`는 여전히 통과하므로, `UInput.focus()`가 * 네이티브 `disabled` ``에서 얻는 것과 같은 no-op을 여기서 직접 재현한다. */ focus(options?: FocusOptions): void; blur(): void; } declare global { interface HTMLElementTagNameMap { 'u-date-picker': UDatePicker; } }