@iyulab/components 1.55.0 → 1.57.0

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,42 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.57.0] - 2026-10-03
4
+
5
+ ### Added
6
+
7
+ - **`u-date-range-picker` takes a typed range.** The field is a text box like `u-date-picker`'s: type
8
+ `2026-10-01 ~ 2026-10-31` (also `–`, ` - `, the ISO interval with `/`, a short second day such as
9
+ `10-31`, or one day for a one-day range) and press Enter or leave the field. A second day without a
10
+ year that would fall before the first runs into the next year (`2025-12-20 ~ 01-05`). It shows
11
+ `YYYY-MM-DD – YYYY-MM-DD` in every browser language; `format="locale"` uses the locale's numeric
12
+ order. Clicking the field opens the calendar and keeps the caret in the text box; ArrowDown or
13
+ Alt+ArrowDown moves into the calendar. Text that is not a range clears the value and reports
14
+ `badInput`. New CSS part `input`.
15
+ - **`parseDateRange`, `formatDateRangeText`** next to `parseDate`.
16
+
17
+ ### Changed
18
+
19
+ - **`u-date-range-picker`: the trigger text is `YYYY-MM-DD – YYYY-MM-DD`** (was the locale's joined
20
+ range, e.g. `Mar 6 – Apr 3, 2026`) so that what is shown can be typed back, and a click keeps focus
21
+ in the text box — the same as `u-date-picker`.
22
+
23
+ ## [1.56.0] - 2026-10-03
24
+
25
+ ### Added
26
+
27
+ - **`u-date-picker mode="datetime"` takes a typed date and time.** The field is the same text box as in
28
+ `mode="date"`: type `2026-10-02 14:30` (or `9:05`; seconds are dropped) and press Enter or leave the
29
+ field. It shows `YYYY-MM-DD HH:mm` whatever the browser language (`format="locale"` writes the date
30
+ part in the locale's numeric order). Typing only a date keeps the time already set. An impossible time
31
+ (`25:00`) clears the value and reports `badInput`. The value is still a full ISO-8601 `DateTimeOffset`.
32
+ - **`parseDateTime`, `formatDateTimeText`** next to `parseDate`.
33
+
34
+ ### Changed
35
+
36
+ - **`u-date-picker mode="datetime"`: the trigger text is `YYYY-MM-DD HH:mm`** (was the locale's medium
37
+ date and short time, e.g. `Oct 2, 2026, 2:30 PM`), and a click keeps focus in the text box — the same
38
+ as `mode="date"` since 1.55.0.
39
+
3
40
  ## [1.55.0] - 2026-10-03
4
41
 
5
42
  ### Added
@@ -6,12 +6,13 @@ import { UPopover } from '../popover/UPopover.js';
6
6
  export type DatePickerMode = 'date' | 'datetime';
7
7
  /**
8
8
  * A single-date(-time)-selection form control. In `mode="date"` (default) the value follows
9
- * the same convention as the native `input[type=date]`: an ISO `YYYY-MM-DD` string, and the
10
- * field is a text box — type `2026-10-02`, `20261002` or `10-02` (this year) and press Enter or
11
- * leave the field; the calendar is a helper. The text shows as `YYYY-MM-DD` whatever the browser
12
- * language, or in the locale's numeric order with `format="locale"`. Clicking the field opens the
13
- * calendar and keeps typing in the field; ArrowDown (or Alt+ArrowDown) moves into the calendar.
14
- * Text that is not a date clears the value and reports `badInput`, like the native input. In
9
+ * the same convention as the native `input[type=date]`: an ISO `YYYY-MM-DD` string. The field is a
10
+ * text box in both modes — type `2026-10-02`, `20261002` or `10-02` (this year), plus a time
11
+ * (`2026-10-02 14:30`) in `mode="datetime"`, and press Enter or leave the field; the calendar is a
12
+ * helper. The text shows as `YYYY-MM-DD` (`YYYY-MM-DD HH:mm`) whatever the browser language, or in
13
+ * the locale's numeric order with `format="locale"`. Clicking the field opens the calendar and keeps
14
+ * typing in the field; ArrowDown (or Alt+ArrowDown) moves into the calendar. Text that is not a date
15
+ * clears the value and reports `badInput`, like the native input. In
15
16
  * `mode="datetime"` the value is a complete ISO-8601 `DateTimeOffset` string
16
17
  * (`YYYY-MM-DDTHH:mm:ss±HH:mm`) — the component always fills in seconds and the browser's
17
18
  * local UTC offset, so the value is unconditionally valid regardless of how coarse the time
@@ -29,7 +30,7 @@ export type DatePickerMode = 'date' | 'datetime';
29
30
  * as a CSS hook for consumers who want to react to the open/closed state from outside.
30
31
  *
31
32
  * @csspart field - the u-field element
32
- * @csspart input - the text box (`mode="date"` only)
33
+ * @csspart input - the text box
33
34
  * @csspart container - the element wrapping the trigger area
34
35
  * @csspart popover - the popover element showing the calendar
35
36
  * @csspart calendar - the calendar container
@@ -66,12 +67,13 @@ export declare class UDatePicker extends UFormControlElement<string> {
66
67
  max?: string;
67
68
  /** Whether to show the clear button */
68
69
  clearable: boolean;
69
- /** Placeholder text (shown on the trigger when there is no value). In `mode="date"` it defaults
70
- * to the pattern to type (`YYYY-MM-DD`). */
70
+ /** Placeholder text (shown when there is no value). Defaults to the pattern to type
71
+ * (`YYYY-MM-DD`, or `YYYY-MM-DD HH:mm` in `mode="datetime"`). */
71
72
  placeholder?: string;
72
- /** How the `mode="date"` text box writes and reads a date: `iso` (default, `YYYY-MM-DD` in every
73
- * language) or `locale` (the active locale's numeric order, e.g. `10/02/2026` in `en-US`). ISO
74
- * and `20261002` are read in both. The value is ISO either way. */
73
+ /** How the text box writes and reads the date: `iso` (default, `YYYY-MM-DD` in every language)
74
+ * or `locale` (the active locale's numeric order, e.g. `10/02/2026` in `en-US`). ISO and
75
+ * `20261002` are read in both. The time, in `mode="datetime"`, is always `HH:mm`. The value is
76
+ * ISO either way. */
75
77
  format: DateTextFormat;
76
78
  containerEl?: HTMLElement;
77
79
  popoverEl?: UPopover;
@@ -82,7 +84,7 @@ export declare class UDatePicker extends UFormControlElement<string> {
82
84
  /** Time-of-day for the next selection while no `value` exists yet (`mode="datetime"` only) —
83
85
  * once `value` is set, the time input reads/writes its time portion directly instead. */
84
86
  private pendingTime;
85
- /** What the person is typing in the `mode="date"` text box, until it is committed; `null` shows the value. */
87
+ /** What the person is typing in the text box, until it is committed; `null` shows the value. */
86
88
  private draft;
87
89
  /** The committed text was not a date — the value is empty and validity reports `badInput`. */
88
90
  private badText;
@@ -107,6 +109,9 @@ export declare class UDatePicker extends UFormControlElement<string> {
107
109
  private handleDaySelect;
108
110
  private get textInputEl();
109
111
  private openCalendar;
112
+ /** The typed text as a date (ISO) and, in `mode="datetime"`, a time — or `null` when it is not one.
113
+ * Typing only a date in `mode="datetime"` keeps the time already set (or the pending one). */
114
+ private parseTyped;
110
115
  private handleTextInput;
111
116
  /** A click anywhere on the field (not on its clear or calendar button) opens the calendar and
112
117
  * puts the caret in the text box — the person can pick a day or keep typing. */
@@ -4,7 +4,7 @@ import { UFormControlElement } from "../UFormControlElement.js";
4
4
  import "../button/UButton.js";
5
5
  import "../icon/UIcon.js";
6
6
  import { Locale } from "../../utilities/Locale.js";
7
- import { dateTextPattern, formatDate, formatDateText, parseDate } from "../../utilities/format.js";
7
+ import { dateTextPattern, formatDateText, formatDateTimeText, parseDate, parseDateTime } from "../../utilities/format.js";
8
8
  import { isOutOfRange, parseISODate, toISODate } from "../calendar/dates.js";
9
9
  import { UCalendar } from "../calendar/UCalendar.js";
10
10
  import "../field/UField.js";
@@ -66,8 +66,8 @@ var UDatePicker = class UDatePicker extends UFormControlElement {
66
66
  };
67
67
  this.handleTextInput = (e) => {
68
68
  this.draft = e.target.value;
69
- const typed = parseDate(this.draft, { format: this.format });
70
- if (typed && this.open) this.calendarEl?.showDate(typed);
69
+ const typed = this.parseTyped(this.draft);
70
+ if (typed && this.open) this.calendarEl?.showDate(typed.date);
71
71
  };
72
72
  this.handleContainerClick = (e) => {
73
73
  if (e.target.closest?.("u-icon")) return;
@@ -92,9 +92,10 @@ var UDatePicker = class UDatePicker extends UFormControlElement {
92
92
  this.commitText = () => {
93
93
  if (this.draft === null) return;
94
94
  const text = this.draft;
95
- const iso = parseDate(text, { format: this.format });
96
- this.badText = !!text.trim() && iso === null;
97
- const next = iso ? buildValue(parseISODate(iso), this.mode, this.pendingTime) : void 0;
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;
98
99
  const changed = next !== this.value;
99
100
  this.value = next;
100
101
  this.draft = this.badText ? text : null;
@@ -148,19 +149,16 @@ var UDatePicker = class UDatePicker extends UFormControlElement {
148
149
  if (changed.has("open")) this.internals?.states[this.open ? "add" : "delete"]("open");
149
150
  if (changed.has("open") && this.open) {
150
151
  const calendar = this.calendarEl;
151
- const base = (this.draft !== null ? parseDate(this.draft, { format: this.format }) : null) ?? (this.value ? toISODate(splitValue(this.value).date) : toISODate(/* @__PURE__ */ new Date()));
152
+ const base = (this.draft !== null ? this.parseTyped(this.draft)?.date : void 0) ?? (this.value ? toISODate(splitValue(this.value).date) : toISODate(/* @__PURE__ */ new Date()));
152
153
  calendar?.showDate(base);
153
- const moveFocus = this.mode !== "date" || this.focusCalendarOnOpen;
154
+ const moveFocus = this.focusCalendarOnOpen;
154
155
  this.focusCalendarOnOpen = false;
155
156
  if (moveFocus) this.popoverEl?.updateComplete.then(() => calendar?.focusDay());
156
157
  }
157
158
  }
158
159
  render() {
159
- const displayText = this.value ? formatDate(this.value, this.mode === "datetime" ? {
160
- dateStyle: "medium",
161
- timeStyle: "short"
162
- } : void 0) : "";
163
- const textEntry = this.mode === "date";
160
+ 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) : "";
164
162
  return html`
165
163
  <u-field part="field"
166
164
  ?required=${this.required}
@@ -170,10 +168,10 @@ var UDatePicker = class UDatePicker extends UFormControlElement {
170
168
  .description=${this.description}
171
169
  .validationMessage=${this.validationMessage}
172
170
  >
173
- ${textEntry ? html`<div class="container" part="container" @click=${this.handleContainerClick}>
171
+ <div class="container" part="container" @click=${this.handleContainerClick}>
174
172
  <input class="text-input" part="input"
175
173
  type="text"
176
- inputmode="numeric"
174
+ inputmode=${datetime ? "text" : "numeric"}
177
175
  autocomplete="off"
178
176
  role="combobox"
179
177
  aria-haspopup="dialog"
@@ -182,24 +180,14 @@ var UDatePicker = class UDatePicker extends UFormControlElement {
182
180
  aria-label=${ifDefined(this.resolvedAriaLabel)}
183
181
  aria-description=${ifDefined(this.resolvedAriaDescription)}
184
182
  aria-invalid=${this.badText ? "true" : "false"}
185
- placeholder=${this.placeholder ?? dateTextPattern(this.format)}
186
- .value=${this.draft ?? (this.value ? formatDateText(toISODate(splitValue(this.value).date), this.format) : "")}
183
+ placeholder=${this.placeholder ?? (datetime ? `${dateTextPattern(this.format)} HH:mm` : dateTextPattern(this.format))}
184
+ .value=${this.draft ?? shown}
187
185
  ?disabled=${this.effectivelyDisabled}
188
186
  ?readonly=${this.readonly}
189
187
  @input=${this.handleTextInput}
190
188
  @keydown=${this.handleTextKeydown}
191
189
  @blur=${this.commitText}
192
- />` : html`<div class="container" part="container"
193
- tabindex=${this.effectivelyDisabled ? "-1" : "0"}
194
- role="combobox"
195
- aria-disabled=${ifDefined(this.effectivelyDisabled ? "true" : void 0)}
196
- aria-haspopup="dialog"
197
- aria-expanded=${this.open}
198
- aria-label=${ifDefined(this.resolvedAriaLabel)}
199
- aria-description=${ifDefined(this.resolvedAriaDescription)}
200
- aria-controls=${this.calendarId}
201
- >
202
- <span class="text-content ${!displayText ? "placeholder" : ""}">${displayText || this.placeholder || ""}</span>`}
190
+ />
203
191
  <u-icon class="suffix-item"
204
192
  ?hidden=${!this.clearable || !this.value || this.effectivelyDisabled || this.readonly}
205
193
  role="button"
@@ -210,7 +198,7 @@ var UDatePicker = class UDatePicker extends UFormControlElement {
210
198
  @click=${this.handleClearClick}
211
199
  @keydown=${this.handleClearKeydown}
212
200
  ></u-icon>
213
- ${textEntry ? html`<u-icon class="suffix-item calendar-button"
201
+ <u-icon class="suffix-item calendar-button"
214
202
  role="button"
215
203
  tabindex="-1"
216
204
  aria-label=${Locale.getValue("chooseDate")}
@@ -218,10 +206,7 @@ var UDatePicker = class UDatePicker extends UFormControlElement {
218
206
  lib="internal"
219
207
  name="calendar"
220
208
  @click=${this.handleCalendarButtonClick}
221
- ></u-icon>` : html`<u-icon class="suffix-item"
222
- lib="internal"
223
- name="calendar"
224
- ></u-icon>`}
209
+ ></u-icon>
225
210
  </div>
226
211
  </u-field>
227
212
 
@@ -230,7 +215,7 @@ var UDatePicker = class UDatePicker extends UFormControlElement {
230
215
  role="dialog"
231
216
  aria-label=${Locale.getValue("chooseDate")}
232
217
  for=".container"
233
- trigger=${textEntry ? "manual" : "click"}
218
+ trigger="manual"
234
219
  strategy="fixed"
235
220
  placement="bottom-start"
236
221
  offset="4"
@@ -308,6 +293,26 @@ var UDatePicker = class UDatePicker extends UFormControlElement {
308
293
  this.focusCalendarOnOpen = focusGrid;
309
294
  if (this.containerEl) this.popoverEl?.show(this.containerEl);
310
295
  }
296
+ /** The typed text as a date (ISO) and, in `mode="datetime"`, a time — or `null` when it is not one.
297
+ * Typing only a date in `mode="datetime"` keeps the time already set (or the pending one). */
298
+ parseTyped(text) {
299
+ if (this.mode !== "datetime") {
300
+ const date = parseDate(text, { format: this.format });
301
+ return date ? {
302
+ date,
303
+ time: this.pendingTime
304
+ } : null;
305
+ }
306
+ const keep = this.value ? splitValue(this.value).time : this.pendingTime;
307
+ const dt = parseDateTime(text, {
308
+ format: this.format,
309
+ defaultTime: keep
310
+ });
311
+ return dt ? {
312
+ date: dt.slice(0, 10),
313
+ time: dt.slice(11, 16)
314
+ } : null;
315
+ }
311
316
  resetValue() {
312
317
  const hadValue = !!this.value;
313
318
  this.draft = null;
@@ -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,12 @@ export declare class UDateRangePicker extends UFormControlElement<string> {
76
88
  calendarEl?: UCalendar;
77
89
  private readonly calendarId;
78
90
  private open;
91
+ /** What the person is typing, until it is committed; `null` shows the value. */
92
+ private draft;
93
+ /** The committed text was not a range — the value is empty and validity reports `badInput`. */
94
+ private badText;
95
+ /** Set when the calendar opens by keyboard (or its button): focus then moves into the grid. */
96
+ private focusCalendarOnOpen;
79
97
  protected willUpdate(changed: PropertyValues): void;
80
98
  protected shouldValidate(changed: PropertyValues): boolean;
81
99
  protected updated(changed: PropertyValues): void;
@@ -88,6 +106,18 @@ export declare class UDateRangePicker extends UFormControlElement<string> {
88
106
  private handleRangeSelect;
89
107
  /** A user-chosen range (calendar or preset): set it, announce it, close the calendar. */
90
108
  private commitRange;
109
+ private get textInputEl();
110
+ private openCalendar;
111
+ /** A click on the field (not on its clear or calendar button) opens the calendar and keeps the caret in the text box. */
112
+ private handleContainerClick;
113
+ private handleCalendarButtonClick;
114
+ private handleTextInput;
115
+ /** ArrowDown / Alt+ArrowDown opens the calendar and moves into it; Enter commits what was typed. */
116
+ private handleTextKeydown;
117
+ /** Turns the typed text into the value — empty clears it; text that is not a range clears it and
118
+ * reports `badInput` (the text stays to be fixed); a range reaching outside `min`/`max` is kept
119
+ * and reported as out of range. */
120
+ private commitText;
91
121
  /** Escape that reaches the picker closes the calendar — the calendar keeps the first Escape
92
122
  * for itself while a range is half picked. */
93
123
  private handleCalendarKeydown;
@@ -102,7 +132,6 @@ export declare class UDateRangePicker extends UFormControlElement<string> {
102
132
  private emitChange;
103
133
  protected setValidity(): void;
104
134
  reset(): void;
105
- /** `.container` is a div — no native `disabled`, so a disabled picker ignores `focus()` here. */
106
135
  focus(options?: FocusOptions): void;
107
136
  blur(): void;
108
137
  }
@@ -5,7 +5,7 @@ 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";
@@ -32,17 +32,58 @@ var UDateRangePicker = class UDateRangePicker extends UFormControlElement {
32
32
  constructor(..._args) {
33
33
  super(..._args);
34
34
  this.clearable = false;
35
+ this.format = "iso";
35
36
  this.presets = [];
36
37
  this.calendarId = `u-date-range-picker-calendar-${Math.random().toString(36).slice(2, 8)}`;
37
38
  this.open = false;
39
+ this.draft = null;
40
+ this.badText = false;
41
+ this.focusCalendarOnOpen = false;
38
42
  this.handleRangeSelect = (e) => {
39
43
  this.commitRange(e.detail.start, e.detail.end);
40
44
  };
45
+ this.handleContainerClick = (e) => {
46
+ if (e.target.closest?.("u-icon")) return;
47
+ const input = this.textInputEl;
48
+ if (input && this.renderRoot instanceof ShadowRoot && this.renderRoot.activeElement !== input) input.focus();
49
+ this.openCalendar(false);
50
+ };
51
+ this.handleCalendarButtonClick = (e) => {
52
+ e.stopPropagation();
53
+ if (this.open) {
54
+ this.popoverEl?.hide();
55
+ this.textInputEl?.focus();
56
+ } else this.openCalendar(true);
57
+ };
58
+ this.handleTextInput = (e) => {
59
+ this.draft = e.target.value;
60
+ const typed = parseDateRange(this.draft, { format: this.format });
61
+ if (typed && this.open) this.calendarEl?.showDate(typed.start);
62
+ };
63
+ this.handleTextKeydown = (e) => {
64
+ if (e.key === "ArrowDown") {
65
+ e.preventDefault();
66
+ this.commitText();
67
+ this.openCalendar(true);
68
+ } else if (e.key === "Enter" && !e.isComposing) this.commitText();
69
+ };
70
+ this.commitText = () => {
71
+ if (this.draft === null) return;
72
+ const text = this.draft;
73
+ const range = parseDateRange(text, { format: this.format });
74
+ this.badText = !!text.trim() && range === null;
75
+ const next = range ? `${range.start}/${range.end}` : void 0;
76
+ const changed = next !== this.value;
77
+ this.value = next;
78
+ this.draft = this.badText ? text : null;
79
+ if (changed) this.emitChange();
80
+ else if (this.badText && !this.novalidate) this.validate();
81
+ };
41
82
  this.handleCalendarKeydown = (e) => {
42
83
  if (e.key !== "Escape") return;
43
84
  e.preventDefault();
44
85
  this.popoverEl?.hide();
45
- this.containerEl?.focus();
86
+ this.textInputEl?.focus();
46
87
  };
47
88
  this.handlePopoverShow = () => {
48
89
  this.open = true;
@@ -54,12 +95,12 @@ var UDateRangePicker = class UDateRangePicker extends UFormControlElement {
54
95
  e.preventDefault();
55
96
  e.stopPropagation();
56
97
  this.resetValue();
57
- this.containerEl?.focus();
98
+ this.textInputEl?.focus();
58
99
  };
59
100
  this.handleFooterResetClick = () => {
60
101
  this.resetValue();
61
102
  this.popoverEl?.hide();
62
- this.containerEl?.focus();
103
+ this.textInputEl?.focus();
63
104
  };
64
105
  this.handleClearKeydown = (e) => {
65
106
  if (e.key !== "Enter" && e.key !== " ") return;
@@ -98,13 +139,17 @@ var UDateRangePicker = class UDateRangePicker extends UFormControlElement {
98
139
  if (changed.has("open")) this.internals?.states[this.open ? "add" : "delete"]("open");
99
140
  if (changed.has("open") && this.open) {
100
141
  const calendar = this.calendarEl;
101
- calendar?.showDate(this.start ?? /* @__PURE__ */ new Date());
102
- this.popoverEl?.updateComplete.then(() => calendar?.focusDay());
142
+ const typed = this.draft !== null ? parseDateRange(this.draft, { format: this.format }) : null;
143
+ calendar?.showDate(typed?.start ?? this.start ?? /* @__PURE__ */ new Date());
144
+ const moveFocus = this.focusCalendarOnOpen;
145
+ this.focusCalendarOnOpen = false;
146
+ if (moveFocus) this.popoverEl?.updateComplete.then(() => calendar?.focusDay());
103
147
  }
104
148
  }
105
149
  render() {
106
150
  const range = parseInterval(this.value);
107
- const displayText = range ? formatDateRange(range.start, range.end) : this.value ?? "";
151
+ const shown = range ? formatDateRangeText(range.start, range.end, this.format) : this.value ?? "";
152
+ const pattern = dateTextPattern(this.format);
108
153
  return html`
109
154
  <u-field part="field"
110
155
  ?required=${this.required}
@@ -114,17 +159,25 @@ var UDateRangePicker = class UDateRangePicker extends UFormControlElement {
114
159
  .description=${this.description}
115
160
  .validationMessage=${this.validationMessage}
116
161
  >
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>
162
+ <div class="container" part="container" @click=${this.handleContainerClick}>
163
+ <input class="text-input" part="input"
164
+ type="text"
165
+ autocomplete="off"
166
+ role="combobox"
167
+ aria-haspopup="dialog"
168
+ aria-expanded=${this.open}
169
+ aria-controls=${this.calendarId}
170
+ aria-label=${ifDefined(this.resolvedAriaLabel)}
171
+ aria-description=${ifDefined(this.resolvedAriaDescription)}
172
+ aria-invalid=${this.badText ? "true" : "false"}
173
+ placeholder=${this.placeholder ?? `${pattern} – ${pattern}`}
174
+ .value=${this.draft ?? shown}
175
+ ?disabled=${this.effectivelyDisabled}
176
+ ?readonly=${this.readonly}
177
+ @input=${this.handleTextInput}
178
+ @keydown=${this.handleTextKeydown}
179
+ @blur=${this.commitText}
180
+ />
128
181
  <u-icon class="suffix-item"
129
182
  ?hidden=${!this.clearable || !this.value || this.effectivelyDisabled || this.readonly}
130
183
  role="button"
@@ -135,9 +188,14 @@ var UDateRangePicker = class UDateRangePicker extends UFormControlElement {
135
188
  @click=${this.handleClearClick}
136
189
  @keydown=${this.handleClearKeydown}
137
190
  ></u-icon>
138
- <u-icon class="suffix-item"
191
+ <u-icon class="suffix-item calendar-button"
192
+ role="button"
193
+ tabindex="-1"
194
+ aria-label=${Locale.getValue("chooseDateRange")}
195
+ ?hidden=${this.effectivelyDisabled || this.readonly}
139
196
  lib="internal"
140
197
  name="calendar"
198
+ @click=${this.handleCalendarButtonClick}
141
199
  ></u-icon>
142
200
  </div>
143
201
  </u-field>
@@ -147,7 +205,7 @@ var UDateRangePicker = class UDateRangePicker extends UFormControlElement {
147
205
  role="dialog"
148
206
  aria-label=${Locale.getValue("chooseDateRange")}
149
207
  for=".container"
150
- trigger="click"
208
+ trigger="manual"
151
209
  strategy="fixed"
152
210
  placement="bottom-start"
153
211
  offset="4"
@@ -207,13 +265,29 @@ var UDateRangePicker = class UDateRangePicker extends UFormControlElement {
207
265
  commitRange(start, end) {
208
266
  const next = `${start}/${end}`;
209
267
  const changed = next !== this.value;
268
+ this.draft = null;
269
+ this.badText = false;
210
270
  this.value = next;
211
271
  if (changed) this.emitChange();
212
272
  this.popoverEl?.hide();
213
- this.containerEl?.focus();
273
+ this.textInputEl?.focus();
274
+ }
275
+ get textInputEl() {
276
+ return this.renderRoot.querySelector(".text-input");
277
+ }
278
+ openCalendar(focusGrid) {
279
+ if (this.effectivelyDisabled || this.readonly) return;
280
+ if (this.open) {
281
+ if (focusGrid) this.calendarEl?.focusDay();
282
+ return;
283
+ }
284
+ this.focusCalendarOnOpen = focusGrid;
285
+ if (this.containerEl) this.popoverEl?.show(this.containerEl);
214
286
  }
215
287
  resetValue() {
216
288
  const hadValue = !!this.value;
289
+ this.draft = null;
290
+ this.badText = false;
217
291
  this.value = void 0;
218
292
  if (hadValue) this.emitChange();
219
293
  }
@@ -228,7 +302,10 @@ var UDateRangePicker = class UDateRangePicker extends UFormControlElement {
228
302
  let flags = {};
229
303
  let message = "";
230
304
  const range = parseInterval(this.value);
231
- if (this.required && !this.value) {
305
+ if (this.badText) {
306
+ flags = { badInput: true };
307
+ message = Locale.getValue("badInput");
308
+ } else if (this.required && !this.value) {
232
309
  flags = { valueMissing: true };
233
310
  message = Locale.getValue("valueMissing");
234
311
  } else if (this.value && !range) {
@@ -241,19 +318,20 @@ var UDateRangePicker = class UDateRangePicker extends UFormControlElement {
241
318
  flags = { rangeOverflow: true };
242
319
  message = Locale.getValue("rangeOverflow", { max: this.max });
243
320
  }
244
- this.commit(flags, message, this.containerEl ?? void 0);
321
+ this.commit(flags, message, this.textInputEl ?? this.containerEl ?? void 0);
245
322
  }
246
323
  reset() {
247
324
  this.value = void 0;
325
+ this.draft = null;
326
+ this.badText = false;
248
327
  this.invalid = false;
249
328
  }
250
- /** `.container` is a div — no native `disabled`, so a disabled picker ignores `focus()` here. */
251
329
  focus(options) {
252
330
  if (this.effectivelyDisabled) return;
253
- this.containerEl?.focus(options);
331
+ this.textInputEl?.focus(options);
254
332
  }
255
333
  blur() {
256
- this.containerEl?.blur();
334
+ this.textInputEl?.blur();
257
335
  }
258
336
  };
259
337
  __decorate([property({ type: String }), __decorateMetadata("design:type", String)], UDateRangePicker.prototype, "min", void 0);
@@ -263,6 +341,10 @@ __decorate([property({
263
341
  reflect: true
264
342
  }), __decorateMetadata("design:type", Boolean)], UDateRangePicker.prototype, "clearable", void 0);
265
343
  __decorate([property({ type: String }), __decorateMetadata("design:type", String)], UDateRangePicker.prototype, "placeholder", void 0);
344
+ __decorate([property({
345
+ type: String,
346
+ reflect: true
347
+ }), __decorateMetadata("design:type", Object)], UDateRangePicker.prototype, "format", void 0);
266
348
  __decorate([property({
267
349
  attribute: "presets",
268
350
  converter: { fromAttribute: (v) => (v ?? "").split(/\s+/).filter(Boolean) }
@@ -271,6 +353,8 @@ __decorate([query(".container", true), __decorateMetadata("design:type", typeof
271
353
  __decorate([query("u-popover", true), __decorateMetadata("design:type", typeof UPopover === "undefined" ? Object : UPopover)], UDateRangePicker.prototype, "popoverEl", void 0);
272
354
  __decorate([query("u-calendar"), __decorateMetadata("design:type", typeof UCalendar === "undefined" ? Object : UCalendar)], UDateRangePicker.prototype, "calendarEl", void 0);
273
355
  __decorate([state(), __decorateMetadata("design:type", Boolean)], UDateRangePicker.prototype, "open", void 0);
356
+ __decorate([state(), __decorateMetadata("design:type", Object)], UDateRangePicker.prototype, "draft", void 0);
357
+ __decorate([state(), __decorateMetadata("design:type", Object)], UDateRangePicker.prototype, "badText", void 0);
274
358
  UDateRangePicker = __decorate([customElement("u-date-range-picker")], UDateRangePicker);
275
359
  //#endregion
276
360
  export { UDateRangePicker };
@@ -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, formatNumber, parseDate, 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, formatNumber, getDefaultBaseUrl, getParentElement, isCoarsePointer, isFocusCandidate, isImeComposing, jsonAttrConverter, parseDate, 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 };
@@ -81,3 +81,34 @@ export declare function parseDate(text: string, options?: {
81
81
  locale?: LocaleTag;
82
82
  referenceDate?: Date;
83
83
  }): string | null;
84
+ /**
85
+ * Reads a date and a time of day as people type them and returns local `YYYY-MM-DDTHH:mm`, or `null`.
86
+ * The date part is anything {@link parseDate} reads; the time follows a space or `T` as `HH:mm`
87
+ * (`9:05`, `09:05`, `09:05:30` — seconds are dropped). Text with only a date takes `defaultTime`
88
+ * (`00:00` unless given). An hour above 23 or a minute above 59 is `null`.
89
+ */
90
+ export declare function parseDateTime(text: string, options?: {
91
+ format?: DateTextFormat;
92
+ locale?: LocaleTag;
93
+ referenceDate?: Date;
94
+ defaultTime?: string;
95
+ }): string | null;
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
+ 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;
@@ -220,5 +220,80 @@ function parseDate(text, options = {}) {
220
220
  if (date.getFullYear() !== y || date.getMonth() !== mo - 1 || date.getDate() !== d) return null;
221
221
  return `${String(y).padStart(4, "0")}-${String(mo).padStart(2, "0")}-${String(d).padStart(2, "0")}`;
222
222
  }
223
+ /**
224
+ * Reads a date and a time of day as people type them and returns local `YYYY-MM-DDTHH:mm`, or `null`.
225
+ * The date part is anything {@link parseDate} reads; the time follows a space or `T` as `HH:mm`
226
+ * (`9:05`, `09:05`, `09:05:30` — seconds are dropped). Text with only a date takes `defaultTime`
227
+ * (`00:00` unless given). An hour above 23 or a minute above 59 is `null`.
228
+ */
229
+ function parseDateTime(text, options = {}) {
230
+ const t = text.trim();
231
+ const m = /^(.*?)(?:[T\s]+(\d{1,2}):(\d{2})(?::\d{2})?)?$/.exec(t);
232
+ if (!m) return null;
233
+ const date = parseDate(m[1], options);
234
+ if (!date) return null;
235
+ if (m[2] === void 0) {
236
+ const fallback = options.defaultTime ?? "00:00";
237
+ return /^\d{2}:\d{2}$/.test(fallback) ? `${date}T${fallback}` : null;
238
+ }
239
+ const h = Number(m[2]);
240
+ const min = Number(m[3]);
241
+ if (h > 23 || min > 59) return null;
242
+ return `${date}T${String(h).padStart(2, "0")}:${String(min).padStart(2, "0")}`;
243
+ }
244
+ /** Writes local `YYYY-MM-DDTHH:mm` (or a longer ISO date-time) as `{date} HH:mm`, the date part as {@link formatDateText} writes it. */
245
+ function formatDateTimeText(isoLocal, format = "iso", locale) {
246
+ const m = /^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2})/.exec(isoLocal);
247
+ return m ? `${formatDateText(m[1], format, locale)} ${m[2]}` : isoLocal;
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
+ }
223
298
  //#endregion
224
- export { dateTextPattern, formatCurrency, formatDate, formatDateRange, formatDateText, formatNumber, parseDate, 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.55.0",
4
+ "version": "1.57.0",
5
5
  "keywords": [
6
6
  "iyulab",
7
7
  "components",
@@ -21,8 +21,10 @@ order instead (`10/02/2026` in `en-US`, `02.10.2026` in `de` — ISO is still re
21
21
  field opens the calendar and keeps the caret in the text box; ArrowDown (or Alt+ArrowDown) moves
22
22
  into the calendar. Text that is not a date clears the value and reports `badInput` (the text stays
23
23
  so it can be fixed); a date outside `min`/`max` is kept and reported as out of range.
24
- The parser and formatter are exported as `parseDate`, `formatDateText` and `dateTextPattern`.
25
- `mode="datetime"` keeps the calendar-only trigger.
24
+ In `mode="datetime"` the text box takes a time after the date (`2026-10-02 14:30`, `9:05`, seconds
25
+ dropped) and shows `YYYY-MM-DD HH:mm`; typing only a date keeps the time already set.
26
+ The parser and formatter are exported as `parseDate`, `parseDateTime`, `formatDateText`,
27
+ `formatDateTimeText` and `dateTextPattern`.
26
28
 
27
29
  The calendar popover has a footer with a "Today" quick-action button (selects today's date —
28
30
  in `mode="datetime"` this also sets the time to right now — disabled when today falls outside
@@ -51,8 +53,8 @@ day preserves whatever time-of-day was already set; only the "Today" button over
51
53
  | `min` | `string` | — | — | Minimum selectable date (ISO `YYYY-MM-DD`, date-only in both modes) |
52
54
  | `max` | `string` | — | — | Maximum selectable date (ISO `YYYY-MM-DD`, date-only in both modes) |
53
55
  | `clearable` | `boolean` | `false` | ✓ | Show clear button |
54
- | `placeholder` | `string` | — | — | Placeholder text (defaults to the pattern to type in `mode="date"`, e.g. `YYYY-MM-DD`) |
55
- | `format` | `'iso' \| 'locale'` | `'iso'` | ✓ | How the `mode="date"` text box writes and reads a date |
56
+ | `placeholder` | `string` | — | — | Placeholder text (defaults to the pattern to type, e.g. `YYYY-MM-DD` or `YYYY-MM-DD HH:mm`) |
57
+ | `format` | `'iso' \| 'locale'` | `'iso'` | ✓ | How the text box writes and reads the date part |
56
58
  | `disabled` | `boolean` | `false` | ✓ | Disable |
57
59
  | `readonly` | `boolean` | `false` | ✓ | Read-only |
58
60
  | `required` | `boolean` | `false` | ✓ | Required |
@@ -83,7 +85,7 @@ day preserves whatever time-of-day was already set; only the "Today" button over
83
85
  |------|-------------|
84
86
  | `field` | The `u-field` element |
85
87
  | `container` | The element wrapping the trigger area |
86
- | `input` | The text box (`mode="date"` only) |
88
+ | `input` | The text box |
87
89
  | `popover` | The popover element showing the calendar |
88
90
  | `calendar` | The calendar container |
89
91
  | `calendar-header` | The month navigation header |
@@ -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 |