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 { DatePickerMode } from '../date-picker/UDatePicker.js'; import { UPopover } from '../popover/UPopover.js'; import { DateRangePresetOption } from './presets.js'; export type { DateRangePreset, DateRangePresetName, DateRangePresetOption } from './presets.js'; /** * A date-range form control — one field for a period such as "orders placed between". * * The value is an ISO 8601 time interval of two calendar days, `YYYY-MM-DD/YYYY-MM-DD`, start * first: one string, so it works as an attribute and submits with a form as a single field. * `start` and `end` read the two halves. The picker never holds a reversed range — choosing the * earlier day second makes it the start, and a reversed value set from code is put in order. * * The field is a text box: type `2026-10-01 ~ 2026-10-31` (also `–`, ` - `, the ISO interval with * `/`, a short second day such as `10-31`, or one day for a one-day range) and press Enter or leave * the field. It shows `YYYY-MM-DD – YYYY-MM-DD` whatever the browser language, or the locale's * numeric order with `format="locale"`. Clicking the field opens the calendar and keeps the caret * in the text box; ArrowDown (or Alt+ArrowDown) moves into the calendar. Text that is not a range * clears the value and reports `badInput`. * * `mode="datetime"` adds a start time and an end time: each half of the value is a complete * ISO-8601 `DateTimeOffset` (`2026-10-01T09:00:00+09:00/2026-10-31T18:00:00+09:00`), and the text * box reads `2026-10-01 09:00 ~ 2026-10-31 18:00` or `2026-10-01 09:00 ~ 18:00` (a time alone ends on * the first day). The first range picked covers its days whole (00:00 to 23:59); after that, picking * other days keeps the times set. `min`/`max` and `isDateDisabled` stay date-only. * * The calendar shows two months. The first day chosen is an anchor and the range previews up to * the day under the pointer or keyboard focus; the second day completes the range, fires * `change` and closes the calendar. Escape while an anchor is set drops it; Escape again closes. * * `presets` adds a list of quick ranges beside the calendar — built-in names (`today`, `yesterday`, * `last7Days`, `last30Days`, `last3Months`, `last6Months`, `thisWeek`, `lastWeek`, `thisMonth`, `lastMonth`, `thisYear`, which * can be written as a space-separated attribute) and app-defined `{ label, range }` objects, in the * order given. Picking one sets the range at once, fires `change` and closes the calendar. A preset * whose range reaches outside `min`/`max` is disabled; the one equal to the current range is * marked `aria-pressed="true"`. Relative ranges are computed when drawn. * * The calendar week starts on the active locale's first day of the week (same as `u-date-picker`); * `thisWeek` and `lastWeek` follow it. * * Exposes a `:state(open)` custom state while the calendar is showing. * * @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-month - one month block * @csspart calendar-header - a month navigation header * @csspart calendar-title - a "Month Year" title * @csspart calendar-weekdays - a weekday header row * @csspart calendar-grid - a date grid * @csspart calendar-week - one week row inside a date grid * @csspart day - a date cell button * @csspart calendar-time - the row holding the start and end time inputs (`mode="datetime"` only) * @csspart time-input - a time-of-day input (`mode="datetime"` only) * @csspart calendar-footer - the row holding the "clear" quick action * @csspart presets - the list of quick ranges beside the calendar * @csspart preset - one quick-range button * * @cssprop --u-date-range-picker-display - host `display` (default: inline-block). Set `block` to * fill the container width in forms and grid cells. * @cssprop --u-date-range-picker-width - host `width` (default: auto). Set `100%` where `block` * alone does not stretch the host (e.g. inside a flex container). * @cssprop --date-range-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. * * @event change - fires when the user completes a range or clears it (with `confirm`, when Apply * commits a different value). Programmatic value * assignment does not fire it (same contract as native form controls). */ export declare class UDateRangePicker extends UFormControlElement { /** 목록 밖의 값은 어떤 규칙에도 안 걸려 조용히 기본 모양이 된다 — 개발 모드에서 한 번 알린다(`UElement.enumerated`). */ static enumerated: { size: readonly FieldSize[]; format: readonly DateTextFormat[]; mode: readonly DatePickerMode[]; 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자가 된다). 두 날짜와 구분자(`a – b`)를 담을 길이를 준다. `u-input` 의 `chars` 와 같은 축이다. * 폭을 준 칸에서는 하한으로만 쓴다. */ chars?: number; /** `chars` 의 폭 — 그려지는 N자를 잰다(`ch` 는 글꼴 기능·자간을 빼고 잰다). */ private readonly charsWidth; /** * `chars` 가 없을 때의 자연 폭 — 자리표시와 범위 글(두 날짜 + 구분자) 중 긴 쪽을 그려 잰다. 입력의 기본 폭(`size` 20)은 범위 * 자리표시보다 짧아 끝이 잘렸다. 치는 동안의 글자로는 늘리지 않는다(칸이 들썩이지 않게). */ private readonly naturalWidth; private textPattern; /** 자연 폭을 정하는 글 — 자리표시, 또는 같은 꼴의 범위 값(패턴 글자 자리에 숫자) 중 긴 쪽. */ private naturalSample; /** Earliest selectable day (ISO `YYYY-MM-DD`), inclusive. */ min?: string; /** Latest selectable day (ISO `YYYY-MM-DD`), inclusive. */ 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. * Such a day cannot start or end a range, though a range may run across it (a week across a * weekend); a preset that starts or ends on one is disabled. A typed or assigned range that starts * or ends on one reports `stepMismatch`. Property only. */ isDateDisabled?: DateDisabledFn; /** Placeholder text (shown when there is no value). Defaults to the pattern to type. */ placeholder?: string; /** How the text box writes and reads each day: `iso` (default, `YYYY-MM-DD` in every language) or * `locale` (the active locale's numeric order). ISO is read in both. The value is ISO either way. */ format: DateTextFormat; /** * Quick ranges listed beside the calendar, in display order — built-in names and app-defined * `{ label, range }` presets. As an attribute: space-separated built-in names * (`presets="today last7Days thisMonth"`). Empty (default) shows no list. */ presets: DateRangePresetOption[]; /** Picks in the calendar wait for an Apply button instead of committing at once. Completing a * range, choosing a preset 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; /** `date` (default) picks a period of days. `datetime` adds a start and an end time; each half of * the value becomes a complete ISO-8601 `DateTimeOffset` (`…T09:00:00+09:00/…T18:00:00+09:00`). */ mode: DatePickerMode; /** `mode="datetime"`: times are entered to the second — the time inputs show seconds, the text box * reads and shows `HH:mm:ss`, and a whole day ends at `23:59:59`. */ seconds: boolean; /** Start of the range — the ISO day, or in `mode="datetime"` the ISO date-time; `undefined` when * there is no complete range. */ get start(): string | undefined; /** End of the range — the ISO day, or in `mode="datetime"` the ISO date-time; `undefined` when * there is no complete range. */ get end(): string | undefined; containerEl?: HTMLElement; popoverEl?: UPopover; calendarEl?: UCalendar; private readonly calendarId; private open; /** With `confirm`, the range chosen in the open calendar that Apply would commit. */ private staged?; /** `mode="datetime"`: the times the next range takes while there is none yet — once a range * exists, the time inputs read and write its halves instead. */ private pendingTimes?; /** Times a whole-day range takes in `mode="datetime"` — a preset or a first calendar pick: from * the first minute (or second, with `seconds`) to the last. */ private get wholeDay(); /** The typed-range text box — what is being typed, committing it, opening the calendar. */ private readonly textEntry; protected willUpdate(changed: PropertyValues): void; /** What the open calendar shows and edits: the staged range with `confirm`, otherwise the value. */ private get working(); /** The times the working range has — or, without one, the ones the next range takes. */ private workingTimes; /** The value for two days (and, in `mode="datetime"`, two times), earlier first. */ private build; /** Typed text as a range — days, or in `mode="datetime"` local date-times. A day typed without a * time keeps the working range's time at that end. */ private parseTyped; protected shouldValidate(changed: PropertyValues): boolean; protected updated(changed: PropertyValues): void; /** 보이는 접미 버튼 수 — 글자 영역 하한(`min-inline-size`)이 그만큼의 받는 상자를 뺀다. 아래 `?hidden` 조건과 같다. */ private suffixButtonCount; render(): import('lit-html').TemplateResult<1>; private renderCalendar; private renderTimeRow; /** A time input changed — with a range, that end moves (committed at once, or staged with * `confirm`; the calendar stays open); without one, the next range takes it. A start time set * after the end on the same day swaps the two, as a reversed range always is. */ private handleTimeChange; private renderPresets; /** A preset that reaches outside `min`/`max`, or starts or ends on a disabled day, is not * offered — its label would promise a range the calendar itself refuses. */ private unavailable; /** Whether `isDateDisabled` refuses either end of the range (the days between may be disabled). */ private endpointDisabled; private handleRangeSelect; /** A user-chosen range of days (calendar or preset) at `times` (`mode="datetime"`): set it, * announce it, close the calendar — or, with `confirm`, stage it for Apply. A calendar pick keeps * the times already set; a preset covers its days whole. */ private commitRange; /** Commits `next` as the value (firing `change` when it differs), closes the calendar and * returns focus to the text box. */ private commitValue; private get textInputEl(); /** Escape that reaches the picker closes the calendar — the calendar keeps the first Escape * for itself while a range is half picked. */ private handleCalendarKeydown; private handlePopoverShow; private handlePopoverHide; private handleClearClick; private handleFooterResetClick; /** `confirm` 모드의 «적용» — 달력에서 고른 범위를 값으로 확정한다(비운 채면 값을 비운다). */ private handleApplyClick; /** `confirm` 모드의 «취소» — 고른 것은 다음에 열 때 값에서 다시 시작하므로 닫기만 하면 버려진다. */ private handleCancelClick; private resetValue; /** The clear icon is a display element — relay Enter/Space to its click handler * (same pattern as `u-date-picker`, `u-input`, `u-select`). */ private handleClearKeydown; private emitChange; protected setValidity(): void; reset(): void; focus(options?: FocusOptions): void; blur(): void; } declare global { interface HTMLElementTagNameMap { 'u-date-range-picker': UDateRangePicker; } }