@iyulab/components 1.56.0 → 1.57.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,34 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.57.1] - 2026-10-03
4
+
5
+ ### Fixed
6
+
7
+ - **`u-date-picker`: picking a day after typing shows the picked day.** Text typed into the field but
8
+ not yet committed stayed in the box after a day was picked in the calendar (or the time changed), so
9
+ the field showed the half-typed text while the value was the picked day. `u-date-range-picker` already
10
+ cleared it; both pickers now share one implementation of the text box.
11
+
12
+ ## [1.57.0] - 2026-10-03
13
+
14
+ ### Added
15
+
16
+ - **`u-date-range-picker` takes a typed range.** The field is a text box like `u-date-picker`'s: type
17
+ `2026-10-01 ~ 2026-10-31` (also `–`, ` - `, the ISO interval with `/`, a short second day such as
18
+ `10-31`, or one day for a one-day range) and press Enter or leave the field. A second day without a
19
+ year that would fall before the first runs into the next year (`2025-12-20 ~ 01-05`). It shows
20
+ `YYYY-MM-DD – YYYY-MM-DD` in every browser language; `format="locale"` uses the locale's numeric
21
+ order. Clicking the field opens the calendar and keeps the caret in the text box; ArrowDown or
22
+ Alt+ArrowDown moves into the calendar. Text that is not a range clears the value and reports
23
+ `badInput`. New CSS part `input`.
24
+ - **`parseDateRange`, `formatDateRangeText`** next to `parseDate`.
25
+
26
+ ### Changed
27
+
28
+ - **`u-date-range-picker`: the trigger text is `YYYY-MM-DD – YYYY-MM-DD`** (was the locale's joined
29
+ range, e.g. `Mar 6 – Apr 3, 2026`) so that what is shown can be typed back, and a click keeps focus
30
+ in the text box — the same as `u-date-picker`.
31
+
3
32
  ## [1.56.0] - 2026-10-03
4
33
 
5
34
  ### Added
@@ -0,0 +1,62 @@
1
+ import { ReactiveController, ReactiveControllerHost } from 'lit';
2
+ import { UCalendar } from './UCalendar.js';
3
+ import { UPopover } from '../popover/UPopover.js';
4
+ /** What a picker with a typed-date text box gives the controller. */
5
+ export interface DateTextControllerOptions {
6
+ /** The value to commit for the typed text — `undefined` for empty text, `null` when it is not readable. */
7
+ toValue(text: string): string | undefined | null;
8
+ /** The ISO day the typed text points at, so an open calendar can follow the typing; `null` when none. */
9
+ dayOf(text: string): string | null;
10
+ /** The value as the text box shows it when nothing is being typed. */
11
+ shown(): string;
12
+ /** Called after a commit that changed the value — the picker validates and fires `change`. */
13
+ onChange(): void;
14
+ /** Called when unreadable text is committed without a value change — the picker re-validates. */
15
+ onBadText(): void;
16
+ popover(): UPopover | undefined;
17
+ calendar(): UCalendar | undefined;
18
+ container(): HTMLElement | undefined;
19
+ input(): HTMLInputElement | null;
20
+ /** Whether the picker takes input now (not disabled, not read-only). */
21
+ interactive(): boolean;
22
+ }
23
+ type Host = ReactiveControllerHost & HTMLElement & {
24
+ value?: string;
25
+ };
26
+ /**
27
+ * The typed-date text box shared by `u-date-picker` and `u-date-range-picker`: what is being typed
28
+ * (`draft`), whether the last commit was unreadable (`badText`), committing on Enter and blur,
29
+ * opening the calendar on a click (caret stays in the box) or ArrowDown (focus moves into the grid),
30
+ * and following the typing in an open calendar.
31
+ */
32
+ export declare class DateTextController implements ReactiveController {
33
+ private readonly host;
34
+ private readonly options;
35
+ /** What the person is typing, until it is committed; `null` shows the value. */
36
+ draft: string | null;
37
+ /** The committed text was not readable — the value is empty and validity reports `badInput`. */
38
+ badText: boolean;
39
+ private focusGridOnOpen;
40
+ constructor(host: Host, options: DateTextControllerOptions);
41
+ hostConnected(): void;
42
+ /** The text box's current text. */
43
+ get text(): string;
44
+ /** Forget what was typed — after a calendar pick, a clear or a reset. */
45
+ clear(): void;
46
+ /** Called when the calendar has opened: show the typed (or current) month and, if the opening
47
+ * came from the keyboard, move focus into the grid. */
48
+ calendarOpened(fallbackDay: string | Date): void;
49
+ open(focusGrid: boolean): void;
50
+ handleInput: (e: Event) => void;
51
+ /** ArrowDown / Alt+ArrowDown opens the calendar and moves into it (the combobox convention);
52
+ * Enter commits what was typed. Escape belongs to the popover layer — it closes the calendar. */
53
+ handleKeydown: (e: KeyboardEvent) => void;
54
+ /** A click on the field (not on its clear or calendar button) opens the calendar and keeps the
55
+ * caret in the text box — the person can pick a day or keep typing. */
56
+ handleContainerClick: (e: MouseEvent) => void;
57
+ handleCalendarButtonClick: (e: MouseEvent) => void;
58
+ /** Turns the typed text into the value. Empty text clears it; unreadable text also clears it and
59
+ * reports `badInput` while the text stays to be fixed (the native date input does the same). */
60
+ commit: () => void;
61
+ }
62
+ export {};
@@ -0,0 +1,90 @@
1
+ //#region src/components/calendar/date-text-controller.ts
2
+ /**
3
+ * The typed-date text box shared by `u-date-picker` and `u-date-range-picker`: what is being typed
4
+ * (`draft`), whether the last commit was unreadable (`badText`), committing on Enter and blur,
5
+ * opening the calendar on a click (caret stays in the box) or ArrowDown (focus moves into the grid),
6
+ * and following the typing in an open calendar.
7
+ */
8
+ var DateTextController = class {
9
+ constructor(host, options) {
10
+ this.host = host;
11
+ this.options = options;
12
+ this.draft = null;
13
+ this.badText = false;
14
+ this.focusGridOnOpen = false;
15
+ this.handleInput = (e) => {
16
+ this.draft = e.target.value;
17
+ this.host.requestUpdate();
18
+ const day = this.options.dayOf(this.draft);
19
+ if (day && this.options.popover()?.open) this.options.calendar()?.showDate(day);
20
+ };
21
+ this.handleKeydown = (e) => {
22
+ if (e.key === "ArrowDown") {
23
+ e.preventDefault();
24
+ this.commit();
25
+ this.open(true);
26
+ } else if (e.key === "Enter" && !e.isComposing) this.commit();
27
+ };
28
+ this.handleContainerClick = (e) => {
29
+ if (e.target.closest?.("u-icon")) return;
30
+ const input = this.options.input();
31
+ const root = this.host.shadowRoot;
32
+ if (input && root && root.activeElement !== input) input.focus();
33
+ this.open(false);
34
+ };
35
+ this.handleCalendarButtonClick = (e) => {
36
+ e.stopPropagation();
37
+ if (this.options.popover()?.open) {
38
+ this.options.popover()?.hide();
39
+ this.options.input()?.focus();
40
+ } else this.open(true);
41
+ };
42
+ this.commit = () => {
43
+ if (this.draft === null) return;
44
+ const text = this.draft;
45
+ const next = this.options.toValue(text);
46
+ this.badText = next === null;
47
+ const value = next ?? void 0;
48
+ const changed = value !== this.host.value;
49
+ this.host.value = value;
50
+ this.draft = this.badText ? text : null;
51
+ this.host.requestUpdate();
52
+ if (changed) this.options.onChange();
53
+ else if (this.badText) this.options.onBadText();
54
+ };
55
+ host.addController(this);
56
+ }
57
+ hostConnected() {}
58
+ /** The text box's current text. */
59
+ get text() {
60
+ return this.draft ?? this.options.shown();
61
+ }
62
+ /** Forget what was typed — after a calendar pick, a clear or a reset. */
63
+ clear() {
64
+ this.draft = null;
65
+ this.badText = false;
66
+ this.host.requestUpdate();
67
+ }
68
+ /** Called when the calendar has opened: show the typed (or current) month and, if the opening
69
+ * came from the keyboard, move focus into the grid. */
70
+ calendarOpened(fallbackDay) {
71
+ const calendar = this.options.calendar();
72
+ const typed = this.draft !== null ? this.options.dayOf(this.draft) : null;
73
+ calendar?.showDate(typed ?? fallbackDay);
74
+ const moveFocus = this.focusGridOnOpen;
75
+ this.focusGridOnOpen = false;
76
+ if (moveFocus) this.options.popover()?.updateComplete.then(() => calendar?.focusDay());
77
+ }
78
+ open(focusGrid) {
79
+ if (!this.options.interactive()) return;
80
+ if (this.options.popover()?.open) {
81
+ if (focusGrid) this.options.calendar()?.focusDay();
82
+ return;
83
+ }
84
+ this.focusGridOnOpen = focusGrid;
85
+ const container = this.options.container();
86
+ if (container) this.options.popover()?.show(container);
87
+ }
88
+ };
89
+ //#endregion
90
+ export { DateTextController };
@@ -84,14 +84,11 @@ export declare class UDatePicker extends UFormControlElement<string> {
84
84
  /** Time-of-day for the next selection while no `value` exists yet (`mode="datetime"` only) —
85
85
  * once `value` is set, the time input reads/writes its time portion directly instead. */
86
86
  private pendingTime;
87
- /** What the person is typing in the text box, until it is committed; `null` shows the value. */
88
- private draft;
89
- /** The committed text was not a date — the value is empty and validity reports `badInput`. */
90
- private badText;
91
- /** Set when the calendar opens by keyboard (or its button): focus then moves into the grid. A click
92
- * in the text box opens it too, but leaves the caret where the person is typing. */
93
- private focusCalendarOnOpen;
87
+ /** The typed-date text box — what is being typed, committing it, opening the calendar. */
88
+ private readonly textEntry;
94
89
  protected updated(changed: PropertyValues): void;
90
+ /** The value as the text box shows it: `YYYY-MM-DD`, or `YYYY-MM-DD HH:mm` in `mode="datetime"`. */
91
+ private shownText;
95
92
  render(): import('lit-html').TemplateResult<1>;
96
93
  private renderCalendar;
97
94
  private renderTimeRow;
@@ -108,22 +105,9 @@ export declare class UDatePicker extends UFormControlElement<string> {
108
105
  private handleTimeChange;
109
106
  private handleDaySelect;
110
107
  private get textInputEl();
111
- private openCalendar;
112
108
  /** The typed text as a date (ISO) and, in `mode="datetime"`, a time — or `null` when it is not one.
113
109
  * Typing only a date in `mode="datetime"` keeps the time already set (or the pending one). */
114
110
  private parseTyped;
115
- private handleTextInput;
116
- /** A click anywhere on the field (not on its clear or calendar button) opens the calendar and
117
- * puts the caret in the text box — the person can pick a day or keep typing. */
118
- private handleContainerClick;
119
- private handleCalendarButtonClick;
120
- /** ArrowDown / Alt+ArrowDown opens the calendar and moves into it (the combobox convention);
121
- * Enter commits what was typed. Escape is the popover layer's — it closes the calendar. */
122
- private handleTextKeydown;
123
- /** Turns the typed text into the value. Empty text clears it; text that is not a date also clears
124
- * it and reports `badInput` (the native date input does the same); a date outside `min`/`max` is
125
- * kept and reported as out of range — the person typed it, so it is not silently dropped. */
126
- private commitText;
127
111
  /** Escape inside the grid closes the calendar and returns focus to the trigger — the grid
128
112
  * itself does not know it lives in a popover, so the picker owns this. */
129
113
  private handleCalendarKeydown;
@@ -9,6 +9,7 @@ import { isOutOfRange, parseISODate, toISODate } from "../calendar/dates.js";
9
9
  import { UCalendar } from "../calendar/UCalendar.js";
10
10
  import "../field/UField.js";
11
11
  import { UPopover } from "../popover/UPopover.js";
12
+ import { DateTextController } from "../calendar/date-text-controller.js";
12
13
  import { styles } from "../calendar/picker.styles.js";
13
14
  import { styles as styles$1 } from "./UDatePicker.styles.js";
14
15
  import { html } from "lit";
@@ -49,59 +50,39 @@ var UDatePicker = class UDatePicker extends UFormControlElement {
49
50
  this.calendarId = `u-date-picker-calendar-${Math.random().toString(36).slice(2, 8)}`;
50
51
  this.open = false;
51
52
  this.pendingTime = "00:00";
52
- this.draft = null;
53
- this.badText = false;
54
- this.focusCalendarOnOpen = false;
53
+ this.textEntry = new DateTextController(this, {
54
+ toValue: (text) => {
55
+ if (!text.trim()) return void 0;
56
+ const typed = this.parseTyped(text);
57
+ if (!typed) return null;
58
+ if (this.mode === "datetime") this.pendingTime = typed.time;
59
+ return buildValue(parseISODate(typed.date), this.mode, typed.time);
60
+ },
61
+ dayOf: (text) => this.parseTyped(text)?.date ?? null,
62
+ shown: () => this.shownText(),
63
+ onChange: () => this.emitChange(),
64
+ onBadText: () => {
65
+ if (!this.novalidate) this.validate();
66
+ },
67
+ popover: () => this.popoverEl,
68
+ calendar: () => this.calendarEl,
69
+ container: () => this.containerEl,
70
+ input: () => this.textInputEl,
71
+ interactive: () => !this.effectivelyDisabled && !this.readonly
72
+ });
55
73
  this.handleTimeChange = (e) => {
56
74
  const time = e.target.value || "00:00";
57
75
  this.pendingTime = time;
58
76
  if (!this.value) return;
59
77
  const iso = buildValue(splitValue(this.value).date, this.mode, time);
60
78
  const changed = iso !== this.value;
79
+ this.textEntry.clear();
61
80
  this.value = iso;
62
81
  if (changed) this.emitChange();
63
82
  };
64
83
  this.handleDaySelect = (e) => {
65
84
  this.selectDay(parseISODate(e.detail.date));
66
85
  };
67
- this.handleTextInput = (e) => {
68
- this.draft = e.target.value;
69
- const typed = this.parseTyped(this.draft);
70
- if (typed && this.open) this.calendarEl?.showDate(typed.date);
71
- };
72
- this.handleContainerClick = (e) => {
73
- if (e.target.closest?.("u-icon")) return;
74
- const input = this.textInputEl;
75
- if (input && this.renderRoot instanceof ShadowRoot && this.renderRoot.activeElement !== input) input.focus();
76
- this.openCalendar(false);
77
- };
78
- this.handleCalendarButtonClick = (e) => {
79
- e.stopPropagation();
80
- if (this.open) {
81
- this.popoverEl?.hide();
82
- this.textInputEl?.focus();
83
- } else this.openCalendar(true);
84
- };
85
- this.handleTextKeydown = (e) => {
86
- if (e.key === "ArrowDown") {
87
- e.preventDefault();
88
- this.commitText();
89
- this.openCalendar(true);
90
- } else if (e.key === "Enter" && !e.isComposing) this.commitText();
91
- };
92
- this.commitText = () => {
93
- if (this.draft === null) return;
94
- const text = this.draft;
95
- const typed = this.parseTyped(text);
96
- this.badText = !!text.trim() && typed === null;
97
- const next = typed ? buildValue(parseISODate(typed.date), this.mode, typed.time) : void 0;
98
- if (typed && this.mode === "datetime") this.pendingTime = typed.time;
99
- const changed = next !== this.value;
100
- this.value = next;
101
- this.draft = this.badText ? text : null;
102
- if (changed) this.emitChange();
103
- else if (this.badText && !this.novalidate) this.validate();
104
- };
105
86
  this.handleCalendarKeydown = (e) => {
106
87
  if (e.key !== "Escape") return;
107
88
  e.preventDefault();
@@ -147,18 +128,16 @@ var UDatePicker = class UDatePicker extends UFormControlElement {
147
128
  super.updated(changed);
148
129
  if (changed.has("value")) this.internals?.setFormValue(this.value ?? "");
149
130
  if (changed.has("open")) this.internals?.states[this.open ? "add" : "delete"]("open");
150
- if (changed.has("open") && this.open) {
151
- const calendar = this.calendarEl;
152
- const base = (this.draft !== null ? this.parseTyped(this.draft)?.date : void 0) ?? (this.value ? toISODate(splitValue(this.value).date) : toISODate(/* @__PURE__ */ new Date()));
153
- calendar?.showDate(base);
154
- const moveFocus = this.focusCalendarOnOpen;
155
- this.focusCalendarOnOpen = false;
156
- if (moveFocus) this.popoverEl?.updateComplete.then(() => calendar?.focusDay());
157
- }
131
+ if (changed.has("open") && this.open) this.textEntry.calendarOpened(this.value ? toISODate(splitValue(this.value).date) : /* @__PURE__ */ new Date());
132
+ }
133
+ /** The value as the text box shows it: `YYYY-MM-DD`, or `YYYY-MM-DD HH:mm` in `mode="datetime"`. */
134
+ shownText() {
135
+ if (!this.value) return "";
136
+ const { date, time } = splitValue(this.value);
137
+ return this.mode === "datetime" ? formatDateTimeText(`${toISODate(date)}T${time}`, this.format) : formatDateText(toISODate(date), this.format);
158
138
  }
159
139
  render() {
160
140
  const datetime = this.mode === "datetime";
161
- const shown = this.value ? datetime ? formatDateTimeText(`${toISODate(splitValue(this.value).date)}T${splitValue(this.value).time}`, this.format) : formatDateText(toISODate(splitValue(this.value).date), this.format) : "";
162
141
  return html`
163
142
  <u-field part="field"
164
143
  ?required=${this.required}
@@ -168,7 +147,7 @@ var UDatePicker = class UDatePicker extends UFormControlElement {
168
147
  .description=${this.description}
169
148
  .validationMessage=${this.validationMessage}
170
149
  >
171
- <div class="container" part="container" @click=${this.handleContainerClick}>
150
+ <div class="container" part="container" @click=${this.textEntry.handleContainerClick}>
172
151
  <input class="text-input" part="input"
173
152
  type="text"
174
153
  inputmode=${datetime ? "text" : "numeric"}
@@ -179,14 +158,14 @@ var UDatePicker = class UDatePicker extends UFormControlElement {
179
158
  aria-controls=${this.calendarId}
180
159
  aria-label=${ifDefined(this.resolvedAriaLabel)}
181
160
  aria-description=${ifDefined(this.resolvedAriaDescription)}
182
- aria-invalid=${this.badText ? "true" : "false"}
161
+ aria-invalid=${this.textEntry.badText ? "true" : "false"}
183
162
  placeholder=${this.placeholder ?? (datetime ? `${dateTextPattern(this.format)} HH:mm` : dateTextPattern(this.format))}
184
- .value=${this.draft ?? shown}
163
+ .value=${this.textEntry.text}
185
164
  ?disabled=${this.effectivelyDisabled}
186
165
  ?readonly=${this.readonly}
187
- @input=${this.handleTextInput}
188
- @keydown=${this.handleTextKeydown}
189
- @blur=${this.commitText}
166
+ @input=${this.textEntry.handleInput}
167
+ @keydown=${this.textEntry.handleKeydown}
168
+ @blur=${this.textEntry.commit}
190
169
  />
191
170
  <u-icon class="suffix-item"
192
171
  ?hidden=${!this.clearable || !this.value || this.effectivelyDisabled || this.readonly}
@@ -205,7 +184,7 @@ var UDatePicker = class UDatePicker extends UFormControlElement {
205
184
  ?hidden=${this.effectivelyDisabled || this.readonly}
206
185
  lib="internal"
207
186
  name="calendar"
208
- @click=${this.handleCalendarButtonClick}
187
+ @click=${this.textEntry.handleCalendarButtonClick}
209
188
  ></u-icon>
210
189
  </div>
211
190
  </u-field>
@@ -275,6 +254,7 @@ var UDatePicker = class UDatePicker extends UFormControlElement {
275
254
  const time = timeOverride ?? (this.value ? splitValue(this.value).time : this.pendingTime);
276
255
  const iso = buildValue(date, this.mode, time);
277
256
  const changed = iso !== this.value;
257
+ this.textEntry.clear();
278
258
  this.value = iso;
279
259
  if (this.mode === "datetime") this.pendingTime = time;
280
260
  if (changed) this.emitChange();
@@ -284,15 +264,6 @@ var UDatePicker = class UDatePicker extends UFormControlElement {
284
264
  get textInputEl() {
285
265
  return this.renderRoot.querySelector(".text-input");
286
266
  }
287
- openCalendar(focusGrid) {
288
- if (this.effectivelyDisabled || this.readonly) return;
289
- if (this.open) {
290
- if (focusGrid) this.calendarEl?.focusDay();
291
- return;
292
- }
293
- this.focusCalendarOnOpen = focusGrid;
294
- if (this.containerEl) this.popoverEl?.show(this.containerEl);
295
- }
296
267
  /** The typed text as a date (ISO) and, in `mode="datetime"`, a time — or `null` when it is not one.
297
268
  * Typing only a date in `mode="datetime"` keeps the time already set (or the pending one). */
298
269
  parseTyped(text) {
@@ -315,8 +286,7 @@ var UDatePicker = class UDatePicker extends UFormControlElement {
315
286
  }
316
287
  resetValue() {
317
288
  const hadValue = !!this.value;
318
- this.draft = null;
319
- this.badText = false;
289
+ this.textEntry.clear();
320
290
  this.value = void 0;
321
291
  if (hadValue) this.emitChange();
322
292
  }
@@ -330,7 +300,7 @@ var UDatePicker = class UDatePicker extends UFormControlElement {
330
300
  setValidity() {
331
301
  let flags = {};
332
302
  let message = "";
333
- if (this.badText) {
303
+ if (this.textEntry.badText) {
334
304
  flags = { badInput: true };
335
305
  message = Locale.getValue("badInput");
336
306
  } else if (this.required && !this.value) {
@@ -347,8 +317,7 @@ var UDatePicker = class UDatePicker extends UFormControlElement {
347
317
  }
348
318
  reset() {
349
319
  this.value = void 0;
350
- this.draft = null;
351
- this.badText = false;
320
+ this.textEntry.clear();
352
321
  this.invalid = false;
353
322
  }
354
323
  /** `.container`는 div라 네이티브 `disabled`가 없다 — disabled일 때 `tabindex="-1"`로만
@@ -382,8 +351,6 @@ __decorate([query("u-popover", true), __decorateMetadata("design:type", typeof U
382
351
  __decorate([query("u-calendar"), __decorateMetadata("design:type", typeof UCalendar === "undefined" ? Object : UCalendar)], UDatePicker.prototype, "calendarEl", void 0);
383
352
  __decorate([state(), __decorateMetadata("design:type", Boolean)], UDatePicker.prototype, "open", void 0);
384
353
  __decorate([state(), __decorateMetadata("design:type", String)], UDatePicker.prototype, "pendingTime", void 0);
385
- __decorate([state(), __decorateMetadata("design:type", Object)], UDatePicker.prototype, "draft", void 0);
386
- __decorate([state(), __decorateMetadata("design:type", Object)], UDatePicker.prototype, "badText", void 0);
387
354
  UDatePicker = __decorate([customElement("u-date-picker")], UDatePicker);
388
355
  //#endregion
389
356
  export { UDatePicker };
@@ -1,5 +1,6 @@
1
1
  import { PropertyValues } from 'lit';
2
2
  import { UFormControlElement } from '../UFormControlElement.js';
3
+ import { DateTextFormat } from '../../utilities/format.js';
3
4
  import { UCalendar } from '../calendar/UCalendar.js';
4
5
  import { UPopover } from '../popover/UPopover.js';
5
6
  import { DateRangePresetOption } from './presets.js';
@@ -12,6 +13,13 @@ export type { DateRangePreset, DateRangePresetName, DateRangePresetOption } from
12
13
  * `start` and `end` read the two halves. The picker never holds a reversed range — choosing the
13
14
  * earlier day second makes it the start, and a reversed value set from code is put in order.
14
15
  *
16
+ * The field is a text box: type `2026-10-01 ~ 2026-10-31` (also `–`, ` - `, the ISO interval with
17
+ * `/`, a short second day such as `10-31`, or one day for a one-day range) and press Enter or leave
18
+ * the field. It shows `YYYY-MM-DD – YYYY-MM-DD` whatever the browser language, or the locale's
19
+ * numeric order with `format="locale"`. Clicking the field opens the calendar and keeps the caret
20
+ * in the text box; ArrowDown (or Alt+ArrowDown) moves into the calendar. Text that is not a range
21
+ * clears the value and reports `badInput`.
22
+ *
15
23
  * The calendar shows two months. The first day chosen is an anchor and the range previews up to
16
24
  * the day under the pointer or keyboard focus; the second day completes the range, fires
17
25
  * `change` and closes the calendar. Escape while an anchor is set drops it; Escape again closes.
@@ -29,6 +37,7 @@ export type { DateRangePreset, DateRangePresetName, DateRangePresetOption } from
29
37
  * Exposes a `:state(open)` custom state while the calendar is showing.
30
38
  *
31
39
  * @csspart field - the u-field element
40
+ * @csspart input - the text box
32
41
  * @csspart container - the element wrapping the trigger area
33
42
  * @csspart popover - the popover element showing the calendar
34
43
  * @csspart calendar - the calendar container
@@ -59,8 +68,11 @@ export declare class UDateRangePicker extends UFormControlElement<string> {
59
68
  max?: string;
60
69
  /** Whether to show the clear button */
61
70
  clearable: boolean;
62
- /** Placeholder text (shown on the trigger when there is no value) */
71
+ /** Placeholder text (shown when there is no value). Defaults to the pattern to type. */
63
72
  placeholder?: string;
73
+ /** How the text box writes and reads each day: `iso` (default, `YYYY-MM-DD` in every language) or
74
+ * `locale` (the active locale's numeric order). ISO is read in both. The value is ISO either way. */
75
+ format: DateTextFormat;
64
76
  /**
65
77
  * Quick ranges listed beside the calendar, in display order — built-in names and app-defined
66
78
  * `{ label, range }` presets. As an attribute: space-separated built-in names
@@ -76,6 +88,8 @@ export declare class UDateRangePicker extends UFormControlElement<string> {
76
88
  calendarEl?: UCalendar;
77
89
  private readonly calendarId;
78
90
  private open;
91
+ /** The typed-range text box — what is being typed, committing it, opening the calendar. */
92
+ private readonly textEntry;
79
93
  protected willUpdate(changed: PropertyValues): void;
80
94
  protected shouldValidate(changed: PropertyValues): boolean;
81
95
  protected updated(changed: PropertyValues): void;
@@ -88,6 +102,7 @@ export declare class UDateRangePicker extends UFormControlElement<string> {
88
102
  private handleRangeSelect;
89
103
  /** A user-chosen range (calendar or preset): set it, announce it, close the calendar. */
90
104
  private commitRange;
105
+ private get textInputEl();
91
106
  /** Escape that reaches the picker closes the calendar — the calendar keeps the first Escape
92
107
  * for itself while a range is half picked. */
93
108
  private handleCalendarKeydown;
@@ -102,7 +117,6 @@ export declare class UDateRangePicker extends UFormControlElement<string> {
102
117
  private emitChange;
103
118
  protected setValidity(): void;
104
119
  reset(): void;
105
- /** `.container` is a div — no native `disabled`, so a disabled picker ignores `focus()` here. */
106
120
  focus(options?: FocusOptions): void;
107
121
  blur(): void;
108
122
  }
@@ -5,11 +5,12 @@ import "../button/UButton.js";
5
5
  import { devWarnOnce } from "../../utilities/devWarning.js";
6
6
  import "../icon/UIcon.js";
7
7
  import { Locale } from "../../utilities/Locale.js";
8
- import { formatDateRange } from "../../utilities/format.js";
8
+ import { dateTextPattern, formatDateRangeText, parseDateRange } from "../../utilities/format.js";
9
9
  import { parseISODate } from "../calendar/dates.js";
10
10
  import { UCalendar } from "../calendar/UCalendar.js";
11
11
  import "../field/UField.js";
12
12
  import { UPopover } from "../popover/UPopover.js";
13
+ import { DateTextController } from "../calendar/date-text-controller.js";
13
14
  import { styles } from "../calendar/picker.styles.js";
14
15
  import { resolvePresets } from "./presets.js";
15
16
  import { styles as styles$1 } from "./UDateRangePicker.styles.js";
@@ -32,9 +33,31 @@ var UDateRangePicker = class UDateRangePicker extends UFormControlElement {
32
33
  constructor(..._args) {
33
34
  super(..._args);
34
35
  this.clearable = false;
36
+ this.format = "iso";
35
37
  this.presets = [];
36
38
  this.calendarId = `u-date-range-picker-calendar-${Math.random().toString(36).slice(2, 8)}`;
37
39
  this.open = false;
40
+ this.textEntry = new DateTextController(this, {
41
+ toValue: (text) => {
42
+ if (!text.trim()) return void 0;
43
+ const range = parseDateRange(text, { format: this.format });
44
+ return range ? `${range.start}/${range.end}` : null;
45
+ },
46
+ dayOf: (text) => parseDateRange(text, { format: this.format })?.start ?? null,
47
+ shown: () => {
48
+ const range = parseInterval(this.value);
49
+ return range ? formatDateRangeText(range.start, range.end, this.format) : this.value ?? "";
50
+ },
51
+ onChange: () => this.emitChange(),
52
+ onBadText: () => {
53
+ if (!this.novalidate) this.validate();
54
+ },
55
+ popover: () => this.popoverEl,
56
+ calendar: () => this.calendarEl,
57
+ container: () => this.containerEl,
58
+ input: () => this.textInputEl,
59
+ interactive: () => !this.effectivelyDisabled && !this.readonly
60
+ });
38
61
  this.handleRangeSelect = (e) => {
39
62
  this.commitRange(e.detail.start, e.detail.end);
40
63
  };
@@ -42,7 +65,7 @@ var UDateRangePicker = class UDateRangePicker extends UFormControlElement {
42
65
  if (e.key !== "Escape") return;
43
66
  e.preventDefault();
44
67
  this.popoverEl?.hide();
45
- this.containerEl?.focus();
68
+ this.textInputEl?.focus();
46
69
  };
47
70
  this.handlePopoverShow = () => {
48
71
  this.open = true;
@@ -54,12 +77,12 @@ var UDateRangePicker = class UDateRangePicker extends UFormControlElement {
54
77
  e.preventDefault();
55
78
  e.stopPropagation();
56
79
  this.resetValue();
57
- this.containerEl?.focus();
80
+ this.textInputEl?.focus();
58
81
  };
59
82
  this.handleFooterResetClick = () => {
60
83
  this.resetValue();
61
84
  this.popoverEl?.hide();
62
- this.containerEl?.focus();
85
+ this.textInputEl?.focus();
63
86
  };
64
87
  this.handleClearKeydown = (e) => {
65
88
  if (e.key !== "Enter" && e.key !== " ") return;
@@ -96,15 +119,10 @@ var UDateRangePicker = class UDateRangePicker extends UFormControlElement {
96
119
  super.updated(changed);
97
120
  if (changed.has("value")) this.internals?.setFormValue(this.value ?? "");
98
121
  if (changed.has("open")) this.internals?.states[this.open ? "add" : "delete"]("open");
99
- if (changed.has("open") && this.open) {
100
- const calendar = this.calendarEl;
101
- calendar?.showDate(this.start ?? /* @__PURE__ */ new Date());
102
- this.popoverEl?.updateComplete.then(() => calendar?.focusDay());
103
- }
122
+ if (changed.has("open") && this.open) this.textEntry.calendarOpened(this.start ?? /* @__PURE__ */ new Date());
104
123
  }
105
124
  render() {
106
- const range = parseInterval(this.value);
107
- const displayText = range ? formatDateRange(range.start, range.end) : this.value ?? "";
125
+ const pattern = dateTextPattern(this.format);
108
126
  return html`
109
127
  <u-field part="field"
110
128
  ?required=${this.required}
@@ -114,17 +132,25 @@ var UDateRangePicker = class UDateRangePicker extends UFormControlElement {
114
132
  .description=${this.description}
115
133
  .validationMessage=${this.validationMessage}
116
134
  >
117
- <div class="container" part="container"
118
- tabindex=${this.effectivelyDisabled ? "-1" : "0"}
119
- role="combobox"
120
- aria-disabled=${ifDefined(this.effectivelyDisabled ? "true" : void 0)}
121
- aria-haspopup="dialog"
122
- aria-expanded=${this.open}
123
- aria-label=${ifDefined(this.resolvedAriaLabel)}
124
- aria-description=${ifDefined(this.resolvedAriaDescription)}
125
- aria-controls=${this.calendarId}
126
- >
127
- <span class="text-content ${!displayText ? "placeholder" : ""}">${displayText || this.placeholder || ""}</span>
135
+ <div class="container" part="container" @click=${this.textEntry.handleContainerClick}>
136
+ <input class="text-input" part="input"
137
+ type="text"
138
+ autocomplete="off"
139
+ role="combobox"
140
+ aria-haspopup="dialog"
141
+ aria-expanded=${this.open}
142
+ aria-controls=${this.calendarId}
143
+ aria-label=${ifDefined(this.resolvedAriaLabel)}
144
+ aria-description=${ifDefined(this.resolvedAriaDescription)}
145
+ aria-invalid=${this.textEntry.badText ? "true" : "false"}
146
+ placeholder=${this.placeholder ?? `${pattern} – ${pattern}`}
147
+ .value=${this.textEntry.text}
148
+ ?disabled=${this.effectivelyDisabled}
149
+ ?readonly=${this.readonly}
150
+ @input=${this.textEntry.handleInput}
151
+ @keydown=${this.textEntry.handleKeydown}
152
+ @blur=${this.textEntry.commit}
153
+ />
128
154
  <u-icon class="suffix-item"
129
155
  ?hidden=${!this.clearable || !this.value || this.effectivelyDisabled || this.readonly}
130
156
  role="button"
@@ -135,9 +161,14 @@ var UDateRangePicker = class UDateRangePicker extends UFormControlElement {
135
161
  @click=${this.handleClearClick}
136
162
  @keydown=${this.handleClearKeydown}
137
163
  ></u-icon>
138
- <u-icon class="suffix-item"
164
+ <u-icon class="suffix-item calendar-button"
165
+ role="button"
166
+ tabindex="-1"
167
+ aria-label=${Locale.getValue("chooseDateRange")}
168
+ ?hidden=${this.effectivelyDisabled || this.readonly}
139
169
  lib="internal"
140
170
  name="calendar"
171
+ @click=${this.textEntry.handleCalendarButtonClick}
141
172
  ></u-icon>
142
173
  </div>
143
174
  </u-field>
@@ -147,7 +178,7 @@ var UDateRangePicker = class UDateRangePicker extends UFormControlElement {
147
178
  role="dialog"
148
179
  aria-label=${Locale.getValue("chooseDateRange")}
149
180
  for=".container"
150
- trigger="click"
181
+ trigger="manual"
151
182
  strategy="fixed"
152
183
  placement="bottom-start"
153
184
  offset="4"
@@ -207,13 +238,18 @@ var UDateRangePicker = class UDateRangePicker extends UFormControlElement {
207
238
  commitRange(start, end) {
208
239
  const next = `${start}/${end}`;
209
240
  const changed = next !== this.value;
241
+ this.textEntry.clear();
210
242
  this.value = next;
211
243
  if (changed) this.emitChange();
212
244
  this.popoverEl?.hide();
213
- this.containerEl?.focus();
245
+ this.textInputEl?.focus();
246
+ }
247
+ get textInputEl() {
248
+ return this.renderRoot.querySelector(".text-input");
214
249
  }
215
250
  resetValue() {
216
251
  const hadValue = !!this.value;
252
+ this.textEntry.clear();
217
253
  this.value = void 0;
218
254
  if (hadValue) this.emitChange();
219
255
  }
@@ -228,7 +264,10 @@ var UDateRangePicker = class UDateRangePicker extends UFormControlElement {
228
264
  let flags = {};
229
265
  let message = "";
230
266
  const range = parseInterval(this.value);
231
- if (this.required && !this.value) {
267
+ if (this.textEntry.badText) {
268
+ flags = { badInput: true };
269
+ message = Locale.getValue("badInput");
270
+ } else if (this.required && !this.value) {
232
271
  flags = { valueMissing: true };
233
272
  message = Locale.getValue("valueMissing");
234
273
  } else if (this.value && !range) {
@@ -241,19 +280,19 @@ var UDateRangePicker = class UDateRangePicker extends UFormControlElement {
241
280
  flags = { rangeOverflow: true };
242
281
  message = Locale.getValue("rangeOverflow", { max: this.max });
243
282
  }
244
- this.commit(flags, message, this.containerEl ?? void 0);
283
+ this.commit(flags, message, this.textInputEl ?? this.containerEl ?? void 0);
245
284
  }
246
285
  reset() {
247
286
  this.value = void 0;
287
+ this.textEntry.clear();
248
288
  this.invalid = false;
249
289
  }
250
- /** `.container` is a div — no native `disabled`, so a disabled picker ignores `focus()` here. */
251
290
  focus(options) {
252
291
  if (this.effectivelyDisabled) return;
253
- this.containerEl?.focus(options);
292
+ this.textInputEl?.focus(options);
254
293
  }
255
294
  blur() {
256
- this.containerEl?.blur();
295
+ this.textInputEl?.blur();
257
296
  }
258
297
  };
259
298
  __decorate([property({ type: String }), __decorateMetadata("design:type", String)], UDateRangePicker.prototype, "min", void 0);
@@ -263,6 +302,10 @@ __decorate([property({
263
302
  reflect: true
264
303
  }), __decorateMetadata("design:type", Boolean)], UDateRangePicker.prototype, "clearable", void 0);
265
304
  __decorate([property({ type: String }), __decorateMetadata("design:type", String)], UDateRangePicker.prototype, "placeholder", void 0);
305
+ __decorate([property({
306
+ type: String,
307
+ reflect: true
308
+ }), __decorateMetadata("design:type", Object)], UDateRangePicker.prototype, "format", void 0);
266
309
  __decorate([property({
267
310
  attribute: "presets",
268
311
  converter: { fromAttribute: (v) => (v ?? "").split(/\s+/).filter(Boolean) }
@@ -78,6 +78,25 @@ var styles = css`
78
78
  border-block-end: 1px solid var(--u-border-color-weak, #EEEEEE);
79
79
  }
80
80
  }
81
+
82
+ /* The trigger is a text box — it takes the container's room and reads like its text. */
83
+ .text-input {
84
+ flex: 1 1 auto;
85
+ min-width: 0;
86
+ border: none;
87
+ outline: none;
88
+ padding: 0;
89
+ margin: 0;
90
+ background: transparent;
91
+ color: inherit;
92
+ font: inherit;
93
+ }
94
+ .text-input::placeholder {
95
+ color: var(--u-txt-color-weak, #616161);
96
+ }
97
+ .calendar-button {
98
+ cursor: pointer;
99
+ }
81
100
  `;
82
101
  //#endregion
83
102
  export { styles };
package/dist/index.js CHANGED
@@ -26,7 +26,7 @@ import { UCheckbox } from "./components/checkbox/UCheckbox.js";
26
26
  import { UTag } from "./components/tag/UTag.js";
27
27
  import { UChip } from "./components/chip/UChip.js";
28
28
  import { UCopyButton } from "./components/copy-button/UCopyButton.js";
29
- import { dateTextPattern, formatCurrency, formatDate, formatDateRange, formatDateText, formatDateTimeText, formatNumber, parseDate, parseDateTime, parseNumber } from "./utilities/format.js";
29
+ import { dateTextPattern, formatCurrency, formatDate, formatDateRange, formatDateRangeText, formatDateText, formatDateTimeText, formatNumber, parseDate, parseDateRange, parseDateTime, parseNumber } from "./utilities/format.js";
30
30
  import { UField } from "./components/field/UField.js";
31
31
  import { UPopover } from "./components/popover/UPopover.js";
32
32
  import { UDatePicker } from "./components/date-picker/UDatePicker.js";
@@ -62,4 +62,4 @@ import { Dialog } from "./utilities/Dialog.js";
62
62
  import { Theme } from "./utilities/Theme.js";
63
63
  import { Toast } from "./utilities/Toast.js";
64
64
  import { decodeTsv, encodeTsv } from "./utilities/tsv.js";
65
- export { ALERT_STATUSES, BrowserStorage, Dialog, IconCache, IconRegistry, Locale, OverlayManager, Theme, Toast, UAlert, UAvatar, UBadge, UBreadcrumb, UBreadcrumbItem, UButton, UButtonGroup, UCard, UCarousel, UCheckbox, UChip, UCopyButton, UDatePicker, UDateRangePicker, UDialog, UDivider, UDrawer, UElement, UExpander, UField, UFileInput, UFloatingElement, UForm, UFormControlElement, UIcon, UIconButton, UInput, UMenu, UMenuItem, UOption, UOverlayElement, UPanel, UPopover, UProgressBar, UProgressRing, URadio, URating, USelect, USkeleton, USlider, USpinner, USplitPanel, USwitch, UTab, UTabPanel, UTag, UText, UTextarea, UTooltip, UTree, UTreeItem, arrayAttrConverter, booleanAttrConverter, createDevWarner, dateAttrConverter, dateTextPattern, decodeTsv, devWarnOnce, encodeTsv, formatCurrency, formatDate, formatDateRange, formatDateText, formatDateTimeText, formatNumber, getDefaultBaseUrl, getParentElement, isCoarsePointer, isFocusCandidate, isImeComposing, jsonAttrConverter, parseDate, parseDateTime, parseNumber, querySelectorAllWithin, querySelectorDeep, querySelectorWithin, resetDevWarnings, setDefaultBaseUrl, urlAttrConverter };
65
+ export { ALERT_STATUSES, BrowserStorage, Dialog, IconCache, IconRegistry, Locale, OverlayManager, Theme, Toast, UAlert, UAvatar, UBadge, UBreadcrumb, UBreadcrumbItem, UButton, UButtonGroup, UCard, UCarousel, UCheckbox, UChip, UCopyButton, UDatePicker, UDateRangePicker, UDialog, UDivider, UDrawer, UElement, UExpander, UField, UFileInput, UFloatingElement, UForm, UFormControlElement, UIcon, UIconButton, UInput, UMenu, UMenuItem, UOption, UOverlayElement, UPanel, UPopover, UProgressBar, UProgressRing, URadio, URating, USelect, USkeleton, USlider, USpinner, USplitPanel, USwitch, UTab, UTabPanel, UTag, UText, UTextarea, UTooltip, UTree, UTreeItem, arrayAttrConverter, booleanAttrConverter, createDevWarner, dateAttrConverter, dateTextPattern, decodeTsv, devWarnOnce, encodeTsv, formatCurrency, formatDate, formatDateRange, formatDateRangeText, formatDateText, formatDateTimeText, formatNumber, getDefaultBaseUrl, getParentElement, isCoarsePointer, isFocusCandidate, isImeComposing, jsonAttrConverter, parseDate, parseDateRange, parseDateTime, parseNumber, querySelectorAllWithin, querySelectorDeep, querySelectorWithin, resetDevWarnings, setDefaultBaseUrl, urlAttrConverter };
@@ -95,3 +95,20 @@ export declare function parseDateTime(text: string, options?: {
95
95
  }): string | null;
96
96
  /** Writes local `YYYY-MM-DDTHH:mm` (or a longer ISO date-time) as `{date} HH:mm`, the date part as {@link formatDateText} writes it. */
97
97
  export declare function formatDateTimeText(isoLocal: string, format?: DateTextFormat, locale?: LocaleTag): string;
98
+ /**
99
+ * Reads a period of days as people type it — `2026-10-01 ~ 2026-10-31`, `2026-10-01 – 10-31`,
100
+ * the ISO interval `2026-10-01/2026-10-31`, or a single day (a one-day range) — and returns
101
+ * `{ start, end }` as ISO dates, earlier first, or `null`. Each day is read by {@link parseDate}; a
102
+ * short second day (`10-31`) takes the first day's year, or the next year when it would otherwise
103
+ * fall before the first day (`2025-12-20 ~ 01-05`).
104
+ */
105
+ export declare function parseDateRange(text: string, options?: {
106
+ format?: DateTextFormat;
107
+ locale?: LocaleTag;
108
+ referenceDate?: Date;
109
+ }): {
110
+ start: string;
111
+ end: string;
112
+ } | null;
113
+ /** Writes a period as `{start} – {end}`, each day as {@link formatDateText} writes it. */
114
+ export declare function formatDateRangeText(start: string, end: string, format?: DateTextFormat, locale?: LocaleTag): string;
@@ -246,5 +246,54 @@ function formatDateTimeText(isoLocal, format = "iso", locale) {
246
246
  const m = /^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2})/.exec(isoLocal);
247
247
  return m ? `${formatDateText(m[1], format, locale)} ${m[2]}` : isoLocal;
248
248
  }
249
+ /** Separators read between the two days of a typed range: `~`, en/em dash, or ` - ` with spaces. */
250
+ var RANGE_SEPARATOR = /\s*[~–—]\s*|\s+-\s+/;
251
+ /**
252
+ * Reads a period of days as people type it — `2026-10-01 ~ 2026-10-31`, `2026-10-01 – 10-31`,
253
+ * the ISO interval `2026-10-01/2026-10-31`, or a single day (a one-day range) — and returns
254
+ * `{ start, end }` as ISO dates, earlier first, or `null`. Each day is read by {@link parseDate}; a
255
+ * short second day (`10-31`) takes the first day's year, or the next year when it would otherwise
256
+ * fall before the first day (`2025-12-20 ~ 01-05`).
257
+ */
258
+ function parseDateRange(text, options = {}) {
259
+ const t = text.trim();
260
+ if (!t) return null;
261
+ let parts = t.split(RANGE_SEPARATOR);
262
+ if (parts.length === 1) {
263
+ const iso = /^(\d{4}-\d{2}-\d{2})\/(\d{4}-\d{2}-\d{2})$/.exec(t);
264
+ if (iso) parts = [iso[1], iso[2]];
265
+ }
266
+ if (parts.length > 2) return null;
267
+ const start = parseDate(parts[0], options);
268
+ if (!start) return null;
269
+ if (parts.length === 1) return {
270
+ start,
271
+ end: start
272
+ };
273
+ const [y, m, d] = start.split("-").map(Number);
274
+ let end = parseDate(parts[1], {
275
+ ...options,
276
+ referenceDate: new Date(y, m - 1, d)
277
+ });
278
+ if (!end) return null;
279
+ if (end < start && !/\d{4}/.test(parts[1])) {
280
+ end = parseDate(parts[1], {
281
+ ...options,
282
+ referenceDate: new Date(y + 1, 0, 1)
283
+ });
284
+ if (!end) return null;
285
+ }
286
+ return start <= end ? {
287
+ start,
288
+ end
289
+ } : {
290
+ start: end,
291
+ end: start
292
+ };
293
+ }
294
+ /** Writes a period as `{start} – {end}`, each day as {@link formatDateText} writes it. */
295
+ function formatDateRangeText(start, end, format = "iso", locale) {
296
+ return `${formatDateText(start, format, locale)} – ${formatDateText(end, format, locale)}`;
297
+ }
249
298
  //#endregion
250
- export { dateTextPattern, formatCurrency, formatDate, formatDateRange, formatDateText, formatDateTimeText, formatNumber, parseDate, parseDateTime, parseNumber };
299
+ export { dateTextPattern, formatCurrency, formatDate, formatDateRange, formatDateRangeText, formatDateText, formatDateTimeText, formatNumber, parseDate, parseDateRange, parseDateTime, parseNumber };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@iyulab/components",
3
3
  "description": "web-components library based on lit-element made by iyulab",
4
- "version": "1.56.0",
4
+ "version": "1.57.1",
5
5
  "keywords": [
6
6
  "iyulab",
7
7
  "components",
@@ -24,6 +24,15 @@ code is put in order (no `change`).
24
24
 
25
25
  > The calendar week always starts on Sunday, regardless of locale.
26
26
 
27
+ **Typing a range.** The field is a text box: type `2026-10-01 ~ 2026-10-31` (also `–`, ` - `, the ISO
28
+ interval `2026-10-01/2026-10-31`, a short second day such as `10-31` — the first day's year, or the
29
+ next year when it would fall before the first day — or one day for a one-day range) and press Enter
30
+ or leave the field. It shows `YYYY-MM-DD – YYYY-MM-DD` in every browser language; `format="locale"`
31
+ uses the locale's numeric order for each day. Clicking the field opens the calendar and keeps the
32
+ caret in the text box; ArrowDown (or Alt+ArrowDown) moves into the calendar. Text that is not a range
33
+ clears the value and reports `badInput` (the text stays to be fixed). The reader and writer are
34
+ exported as `parseDateRange` and `formatDateRangeText`.
35
+
27
36
  ```html
28
37
  <u-date-range-picker name="ordered" label="Ordered"></u-date-range-picker>
29
38
 
@@ -88,7 +97,8 @@ picker.addEventListener('change', () => {
88
97
  | `min` | `string` | — | — | Earliest selectable day (ISO `YYYY-MM-DD`), inclusive |
89
98
  | `max` | `string` | — | — | Latest selectable day (ISO `YYYY-MM-DD`), inclusive |
90
99
  | `clearable` | `boolean` | `false` | ✓ | Show clear button |
91
- | `placeholder` | `string` | — | — | Placeholder text |
100
+ | `placeholder` | `string` | — | — | Placeholder text (defaults to the pattern to type) |
101
+ | `format` | `'iso' \| 'locale'` | `'iso'` | ✓ | How the text box writes and reads each day |
92
102
  | `presets` | `Array<DateRangePresetName \| DateRangePreset>` | `[]` | — | Quick ranges beside the calendar; attribute form is space-separated built-in names |
93
103
  | `disabled` | `boolean` | `false` | ✓ | Disable |
94
104
  | `readonly` | `boolean` | `false` | ✓ | Read-only |
@@ -123,6 +133,7 @@ Validation: `required` with no value → `valueMissing`; a value that is not two
123
133
  |------|-------------|
124
134
  | `field` | The `u-field` element |
125
135
  | `container` | The element wrapping the trigger area |
136
+ | `input` | The text box |
126
137
  | `popover` | The popover element showing the calendar |
127
138
  | `calendar` | The calendar container |
128
139
  | `calendar-month` | One month block |