@iyulab/components 1.57.0 → 1.58.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.
Files changed (41) hide show
  1. package/CHANGELOG.md +61 -0
  2. package/dist/assets/locales/ar.json.js +12 -2
  3. package/dist/assets/locales/de.json.js +12 -2
  4. package/dist/assets/locales/en.json.js +12 -2
  5. package/dist/assets/locales/es.json.js +14 -2
  6. package/dist/assets/locales/fr.json.js +12 -2
  7. package/dist/assets/locales/id.json.js +12 -2
  8. package/dist/assets/locales/ja.json.js +14 -2
  9. package/dist/assets/locales/ko.json.js +14 -2
  10. package/dist/assets/locales/pt-BR.json.js +12 -2
  11. package/dist/assets/locales/ru.json.js +12 -2
  12. package/dist/assets/locales/th.json.js +14 -2
  13. package/dist/assets/locales/vi.json.js +12 -2
  14. package/dist/assets/locales/zh-CN.json.js +14 -2
  15. package/dist/assets/locales/zh-TW.json.js +14 -2
  16. package/dist/components/calendar/UCalendar.d.ts +4 -0
  17. package/dist/components/calendar/UCalendar.js +5 -4
  18. package/dist/components/calendar/date-text-controller.d.ts +62 -0
  19. package/dist/components/calendar/date-text-controller.js +90 -0
  20. package/dist/components/calendar/dates.d.ts +4 -0
  21. package/dist/components/calendar/dates.js +5 -1
  22. package/dist/components/calendar/datetime.d.ts +14 -0
  23. package/dist/components/calendar/datetime.js +35 -0
  24. package/dist/components/calendar/picker.styles.js +35 -0
  25. package/dist/components/carousel/UCarousel.d.ts +7 -1
  26. package/dist/components/carousel/UCarousel.js +8 -1
  27. package/dist/components/date-picker/UDatePicker.d.ts +33 -21
  28. package/dist/components/date-picker/UDatePicker.js +128 -103
  29. package/dist/components/date-picker/UDatePicker.styles.js +0 -19
  30. package/dist/components/date-range-picker/UDateRangePicker.d.ts +71 -24
  31. package/dist/components/date-range-picker/UDateRangePicker.js +233 -103
  32. package/dist/index.js +2 -2
  33. package/dist/utilities/Locale.d.ts +2 -2
  34. package/dist/utilities/Locale.js +2 -2
  35. package/dist/utilities/format.d.ts +32 -4
  36. package/dist/utilities/format.js +131 -15
  37. package/package.json +1 -1
  38. package/skills/iyulab-components/references/components/carousel.md +3 -1
  39. package/skills/iyulab-components/references/components/date-picker.md +34 -2
  40. package/skills/iyulab-components/references/components/date-range-picker.md +52 -5
  41. package/skills/iyulab-components/references/utilities/locale.md +1 -1
@@ -5,103 +5,83 @@ import "../button/UButton.js";
5
5
  import "../icon/UIcon.js";
6
6
  import { Locale } from "../../utilities/Locale.js";
7
7
  import { dateTextPattern, formatDateText, formatDateTimeText, parseDate, parseDateTime } from "../../utilities/format.js";
8
- import { isOutOfRange, parseISODate, toISODate } from "../calendar/dates.js";
8
+ import { isDayUnavailable, 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";
13
+ import { normalizeTime, splitDateTime, toDateTimeOffset } from "../calendar/datetime.js";
12
14
  import { styles } from "../calendar/picker.styles.js";
13
15
  import { styles as styles$1 } from "./UDatePicker.styles.js";
14
16
  import { html } from "lit";
15
17
  import { customElement, property, query, state } from "lit/decorators.js";
16
18
  import { ifDefined } from "lit/directives/if-defined.js";
17
19
  //#region src/components/date-picker/UDatePicker.ts
18
- /** `±HH:mm` for the browser's local timezone at `date` (DST-aware — recomputed per date,
19
- * not cached — `getTimezoneOffset()`'s sign is the inverse of the ISO-8601 offset sign). */
20
- function getLocalOffset(date) {
21
- const minutes = -date.getTimezoneOffset();
22
- const sign = minutes >= 0 ? "+" : "-";
23
- const abs = Math.abs(minutes);
24
- return `${sign}${String(Math.floor(abs / 60)).padStart(2, "0")}:${String(abs % 60).padStart(2, "0")}`;
25
- }
26
20
  /** Builds the `value` for the given mode — `datetime` always emits seconds + local offset so
27
21
  * the result is unconditionally a valid, unambiguous ISO-8601 `DateTimeOffset` regardless of
28
22
  * how coarse the UI input was (this is the guarantee the datetime mode request asked for). */
29
23
  function buildValue(date, mode, time) {
30
- return mode === "datetime" ? `${toISODate(date)}T${time}:00${getLocalOffset(date)}` : toISODate(date);
24
+ return mode === "datetime" ? toDateTimeOffset(toISODate(date), time) : toISODate(date);
31
25
  }
32
- /** Splits a `value` into its date portion (as a `Date`, via the local `parseISODate` above —
33
- * date-only, no timezone conversion) and its `HH:mm` time-of-day (`'00:00'` if absent —
34
- * covers both plain date-mode values and a datetime value with no time captured yet). */
26
+ /** Splits a `value` into its date portion (as a local-midnight `Date` — no timezone conversion)
27
+ * and its `HH:mm:ss` time-of-day (`'00:00:00'` if absent — covers both plain date-mode values and a
28
+ * datetime value with no time captured yet). Seconds are kept here whatever `seconds` says, so
29
+ * picking another day never drops seconds a value already has. */
35
30
  function splitValue(value) {
36
- const [datePart, rest] = value.split("T");
37
- const match = rest?.match(/^(\d{2}:\d{2})/);
31
+ const { day, time } = splitDateTime(value, true);
38
32
  return {
39
- date: parseISODate(datePart),
40
- time: match ? match[1] : "00:00"
33
+ date: parseISODate(day),
34
+ time
41
35
  };
42
36
  }
43
37
  var UDatePicker = class UDatePicker extends UFormControlElement {
44
38
  constructor(..._args) {
45
39
  super(..._args);
46
40
  this.mode = "date";
41
+ this.seconds = false;
47
42
  this.clearable = false;
48
43
  this.format = "iso";
44
+ this.confirm = false;
49
45
  this.calendarId = `u-date-picker-calendar-${Math.random().toString(36).slice(2, 8)}`;
50
46
  this.open = false;
51
47
  this.pendingTime = "00:00";
52
- this.draft = null;
53
- this.badText = false;
54
- this.focusCalendarOnOpen = false;
48
+ this.textEntry = new DateTextController(this, {
49
+ toValue: (text) => {
50
+ if (!text.trim()) return void 0;
51
+ const typed = this.parseTyped(text);
52
+ if (!typed) return null;
53
+ if (this.mode === "datetime") this.pendingTime = typed.time;
54
+ return buildValue(parseISODate(typed.date), this.mode, typed.time);
55
+ },
56
+ dayOf: (text) => this.parseTyped(text)?.date ?? null,
57
+ shown: () => this.shownText(),
58
+ onChange: () => this.emitChange(),
59
+ onBadText: () => {
60
+ if (!this.novalidate) this.validate();
61
+ },
62
+ popover: () => this.popoverEl,
63
+ calendar: () => this.calendarEl,
64
+ container: () => this.containerEl,
65
+ input: () => this.textInputEl,
66
+ interactive: () => !this.effectivelyDisabled && !this.readonly
67
+ });
55
68
  this.handleTimeChange = (e) => {
56
- const time = e.target.value || "00:00";
69
+ const time = normalizeTime(e.target.value || "00:00", this.seconds);
57
70
  this.pendingTime = time;
71
+ if (this.confirm) {
72
+ if (this.staged) this.staged = buildValue(splitValue(this.staged).date, this.mode, time);
73
+ return;
74
+ }
58
75
  if (!this.value) return;
59
76
  const iso = buildValue(splitValue(this.value).date, this.mode, time);
60
77
  const changed = iso !== this.value;
78
+ this.textEntry.clear();
61
79
  this.value = iso;
62
80
  if (changed) this.emitChange();
63
81
  };
64
82
  this.handleDaySelect = (e) => {
65
83
  this.selectDay(parseISODate(e.detail.date));
66
84
  };
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
85
  this.handleCalendarKeydown = (e) => {
106
86
  if (e.key !== "Escape") return;
107
87
  e.preventDefault();
@@ -122,14 +102,32 @@ var UDatePicker = class UDatePicker extends UFormControlElement {
122
102
  };
123
103
  this.handleTodayClick = () => {
124
104
  const now = /* @__PURE__ */ new Date();
125
- const time = this.mode === "datetime" ? `${String(now.getHours()).padStart(2, "0")}:${String(now.getMinutes()).padStart(2, "0")}` : void 0;
105
+ const pad = (n) => String(n).padStart(2, "0");
106
+ const time = this.mode === "datetime" ? `${pad(now.getHours())}:${pad(now.getMinutes())}${this.seconds ? `:${pad(now.getSeconds())}` : ""}` : void 0;
126
107
  this.selectDay(now, time);
127
108
  };
128
109
  this.handleFooterResetClick = () => {
110
+ if (this.confirm) {
111
+ this.staged = void 0;
112
+ return;
113
+ }
129
114
  this.resetValue();
130
115
  this.popoverEl?.hide();
131
116
  (this.textInputEl ?? this.containerEl)?.focus();
132
117
  };
118
+ this.handleApplyClick = () => {
119
+ const next = this.staged;
120
+ const changed = next !== this.value;
121
+ this.textEntry.clear();
122
+ this.value = next;
123
+ if (changed) this.emitChange();
124
+ this.popoverEl?.hide();
125
+ (this.textInputEl ?? this.containerEl)?.focus();
126
+ };
127
+ this.handleCancelClick = () => {
128
+ this.popoverEl?.hide();
129
+ (this.textInputEl ?? this.containerEl)?.focus();
130
+ };
133
131
  this.handleClearKeydown = (e) => {
134
132
  if (e.key !== "Enter" && e.key !== " ") return;
135
133
  e.preventDefault();
@@ -143,22 +141,31 @@ var UDatePicker = class UDatePicker extends UFormControlElement {
143
141
  styles$1
144
142
  ];
145
143
  }
144
+ shouldValidate(changed) {
145
+ return super.shouldValidate(changed) || changed.has("min") || changed.has("max") || changed.has("isDateDisabled");
146
+ }
147
+ willUpdate(changed) {
148
+ super.willUpdate(changed);
149
+ if (this.open && (changed.has("open") || changed.has("value"))) this.staged = this.value;
150
+ }
146
151
  updated(changed) {
147
152
  super.updated(changed);
148
153
  if (changed.has("value")) this.internals?.setFormValue(this.value ?? "");
149
154
  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
- }
155
+ if (changed.has("open") && this.open) this.textEntry.calendarOpened(this.value ? toISODate(splitValue(this.value).date) : /* @__PURE__ */ new Date());
156
+ }
157
+ /** What the open calendar shows and edits: the staged choice with `confirm`, otherwise the value. */
158
+ get working() {
159
+ return this.confirm && this.open ? this.staged : this.value;
160
+ }
161
+ /** The value as the text box shows it: `YYYY-MM-DD`, or `YYYY-MM-DD HH:mm` in `mode="datetime"`. */
162
+ shownText() {
163
+ if (!this.value) return "";
164
+ const { date, time } = splitValue(this.value);
165
+ return this.mode === "datetime" ? formatDateTimeText(`${toISODate(date)}T${time}`, this.format, void 0, this.seconds) : formatDateText(toISODate(date), this.format);
158
166
  }
159
167
  render() {
160
168
  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
169
  return html`
163
170
  <u-field part="field"
164
171
  ?required=${this.required}
@@ -168,7 +175,7 @@ var UDatePicker = class UDatePicker extends UFormControlElement {
168
175
  .description=${this.description}
169
176
  .validationMessage=${this.validationMessage}
170
177
  >
171
- <div class="container" part="container" @click=${this.handleContainerClick}>
178
+ <div class="container" part="container" @click=${this.textEntry.handleContainerClick}>
172
179
  <input class="text-input" part="input"
173
180
  type="text"
174
181
  inputmode=${datetime ? "text" : "numeric"}
@@ -179,14 +186,14 @@ var UDatePicker = class UDatePicker extends UFormControlElement {
179
186
  aria-controls=${this.calendarId}
180
187
  aria-label=${ifDefined(this.resolvedAriaLabel)}
181
188
  aria-description=${ifDefined(this.resolvedAriaDescription)}
182
- aria-invalid=${this.badText ? "true" : "false"}
183
- placeholder=${this.placeholder ?? (datetime ? `${dateTextPattern(this.format)} HH:mm` : dateTextPattern(this.format))}
184
- .value=${this.draft ?? shown}
189
+ aria-invalid=${this.textEntry.badText ? "true" : "false"}
190
+ placeholder=${this.placeholder ?? (datetime ? `${dateTextPattern(this.format)} ${this.seconds ? "HH:mm:ss" : "HH:mm"}` : dateTextPattern(this.format))}
191
+ .value=${this.textEntry.text}
185
192
  ?disabled=${this.effectivelyDisabled}
186
193
  ?readonly=${this.readonly}
187
- @input=${this.handleTextInput}
188
- @keydown=${this.handleTextKeydown}
189
- @blur=${this.commitText}
194
+ @input=${this.textEntry.handleInput}
195
+ @keydown=${this.textEntry.handleKeydown}
196
+ @blur=${this.textEntry.commit}
190
197
  />
191
198
  <u-icon class="suffix-item"
192
199
  ?hidden=${!this.clearable || !this.value || this.effectivelyDisabled || this.readonly}
@@ -205,7 +212,7 @@ var UDatePicker = class UDatePicker extends UFormControlElement {
205
212
  ?hidden=${this.effectivelyDisabled || this.readonly}
206
213
  lib="internal"
207
214
  name="calendar"
208
- @click=${this.handleCalendarButtonClick}
215
+ @click=${this.textEntry.handleCalendarButtonClick}
209
216
  ></u-icon>
210
217
  </div>
211
218
  </u-field>
@@ -231,9 +238,10 @@ var UDatePicker = class UDatePicker extends UFormControlElement {
231
238
  <div class="calendar" part="calendar">
232
239
  <u-calendar
233
240
  exportparts="calendar-header, calendar-title, calendar-weekdays, calendar-grid, calendar-week, day"
234
- .value=${this.value ? toISODate(splitValue(this.value).date) : void 0}
241
+ .value=${this.working ? toISODate(splitValue(this.working).date) : void 0}
235
242
  .min=${this.min}
236
243
  .max=${this.max}
244
+ .isDateDisabled=${this.isDateDisabled}
237
245
  @day-select=${this.handleDaySelect}
238
246
  @keydown=${this.handleCalendarKeydown}
239
247
  ></u-calendar>
@@ -244,39 +252,55 @@ var UDatePicker = class UDatePicker extends UFormControlElement {
244
252
  }
245
253
  renderTimeRow() {
246
254
  if (this.mode !== "datetime") return "";
247
- const time = this.value ? splitValue(this.value).time : this.pendingTime;
255
+ const time = this.working ? splitValue(this.working).time : this.pendingTime;
248
256
  return html`
249
257
  <div class="calendar-time" part="calendar-time">
250
258
  <input type="time" class="time-input" part="time-input"
251
259
  aria-label=${Locale.getValue("time")}
252
- .value=${time}
260
+ step=${ifDefined(this.seconds ? "1" : void 0)}
261
+ .value=${normalizeTime(time, this.seconds)}
253
262
  @change=${this.handleTimeChange}
254
263
  />
255
264
  </div>
256
265
  `;
257
266
  }
258
267
  renderFooter() {
259
- const todayDisabled = isOutOfRange(/* @__PURE__ */ new Date(), this.min, this.max);
268
+ const todayDisabled = this.unavailable(/* @__PURE__ */ new Date());
260
269
  return html`
261
270
  <div class="calendar-footer" part="calendar-footer">
262
271
  <u-button variant="ghost" size="sm" ?disabled=${todayDisabled} @click=${this.handleTodayClick}>${Locale.getValue("today")}</u-button>
263
- ${this.clearable && this.value ? html`
272
+ ${this.clearable && this.working ? html`
264
273
  <u-button variant="ghost" size="sm" @click=${this.handleFooterResetClick}>${Locale.getValue("clear")}</u-button>
265
274
  ` : ""}
275
+ ${this.confirm ? html`
276
+ <span class="confirm-actions">
277
+ <u-button variant="ghost" size="sm" @click=${this.handleCancelClick}>${Locale.getValue("cancel")}</u-button>
278
+ <u-button size="sm" @click=${this.handleApplyClick}>${Locale.getValue("apply")}</u-button>
279
+ </span>
280
+ ` : ""}
266
281
  </div>
267
282
  `;
268
283
  }
284
+ /** A day the calendar refuses — outside `min`/`max` or disabled by `isDateDisabled`. */
285
+ unavailable(date) {
286
+ return isDayUnavailable(date, this.min, this.max, this.isDateDisabled);
287
+ }
269
288
  /** `timeOverride` lets a caller force the time-of-day (the "today" quick action wants
270
289
  * "right now", overriding whatever time was previously set) — a plain day-cell click omits
271
290
  * it, which preserves the existing time-of-day (or `pendingTime`) so switching the date
272
291
  * alone doesn't clobber a time the user already picked. */
273
292
  selectDay(date, timeOverride) {
274
- if (isOutOfRange(date, this.min, this.max)) return;
275
- const time = timeOverride ?? (this.value ? splitValue(this.value).time : this.pendingTime);
293
+ if (this.unavailable(date)) return;
294
+ const time = timeOverride ?? (this.working ? splitValue(this.working).time : this.pendingTime);
276
295
  const iso = buildValue(date, this.mode, time);
296
+ if (this.mode === "datetime") this.pendingTime = time;
297
+ if (this.confirm) {
298
+ this.staged = iso;
299
+ return;
300
+ }
277
301
  const changed = iso !== this.value;
302
+ this.textEntry.clear();
278
303
  this.value = iso;
279
- if (this.mode === "datetime") this.pendingTime = time;
280
304
  if (changed) this.emitChange();
281
305
  this.popoverEl?.hide();
282
306
  (this.textInputEl ?? this.containerEl)?.focus();
@@ -284,15 +308,6 @@ var UDatePicker = class UDatePicker extends UFormControlElement {
284
308
  get textInputEl() {
285
309
  return this.renderRoot.querySelector(".text-input");
286
310
  }
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
311
  /** The typed text as a date (ISO) and, in `mode="datetime"`, a time — or `null` when it is not one.
297
312
  * Typing only a date in `mode="datetime"` keeps the time already set (or the pending one). */
298
313
  parseTyped(text) {
@@ -306,17 +321,17 @@ var UDatePicker = class UDatePicker extends UFormControlElement {
306
321
  const keep = this.value ? splitValue(this.value).time : this.pendingTime;
307
322
  const dt = parseDateTime(text, {
308
323
  format: this.format,
309
- defaultTime: keep
324
+ defaultTime: keep,
325
+ seconds: this.seconds
310
326
  });
311
327
  return dt ? {
312
328
  date: dt.slice(0, 10),
313
- time: dt.slice(11, 16)
329
+ time: dt.slice(11)
314
330
  } : null;
315
331
  }
316
332
  resetValue() {
317
333
  const hadValue = !!this.value;
318
- this.draft = null;
319
- this.badText = false;
334
+ this.textEntry.clear();
320
335
  this.value = void 0;
321
336
  if (hadValue) this.emitChange();
322
337
  }
@@ -330,7 +345,7 @@ var UDatePicker = class UDatePicker extends UFormControlElement {
330
345
  setValidity() {
331
346
  let flags = {};
332
347
  let message = "";
333
- if (this.badText) {
348
+ if (this.textEntry.badText) {
334
349
  flags = { badInput: true };
335
350
  message = Locale.getValue("badInput");
336
351
  } else if (this.required && !this.value) {
@@ -342,13 +357,15 @@ var UDatePicker = class UDatePicker extends UFormControlElement {
342
357
  } else if (this.value && this.max && splitValue(this.value).date.getTime() > parseISODate(this.max).getTime()) {
343
358
  flags = { rangeOverflow: true };
344
359
  message = Locale.getValue("rangeOverflow", { max: this.max });
360
+ } else if (this.value && this.isDateDisabled?.(toISODate(splitValue(this.value).date))) {
361
+ flags = { stepMismatch: true };
362
+ message = Locale.getValue("dateUnavailable");
345
363
  }
346
364
  this.commit(flags, message, this.textInputEl ?? this.containerEl ?? void 0);
347
365
  }
348
366
  reset() {
349
367
  this.value = void 0;
350
- this.draft = null;
351
- this.badText = false;
368
+ this.textEntry.clear();
352
369
  this.invalid = false;
353
370
  }
354
371
  /** `.container`는 div라 네이티브 `disabled`가 없다 — disabled일 때 `tabindex="-1"`로만
@@ -366,24 +383,32 @@ __decorate([property({
366
383
  type: String,
367
384
  reflect: true
368
385
  }), __decorateMetadata("design:type", Object)], UDatePicker.prototype, "mode", void 0);
386
+ __decorate([property({
387
+ type: Boolean,
388
+ reflect: true
389
+ }), __decorateMetadata("design:type", Boolean)], UDatePicker.prototype, "seconds", void 0);
369
390
  __decorate([property({ type: String }), __decorateMetadata("design:type", String)], UDatePicker.prototype, "min", void 0);
370
391
  __decorate([property({ type: String }), __decorateMetadata("design:type", String)], UDatePicker.prototype, "max", void 0);
371
392
  __decorate([property({
372
393
  type: Boolean,
373
394
  reflect: true
374
395
  }), __decorateMetadata("design:type", Boolean)], UDatePicker.prototype, "clearable", void 0);
396
+ __decorate([property({ attribute: false }), __decorateMetadata("design:type", Object)], UDatePicker.prototype, "isDateDisabled", void 0);
375
397
  __decorate([property({ type: String }), __decorateMetadata("design:type", String)], UDatePicker.prototype, "placeholder", void 0);
376
398
  __decorate([property({
377
399
  type: String,
378
400
  reflect: true
379
401
  }), __decorateMetadata("design:type", Object)], UDatePicker.prototype, "format", void 0);
402
+ __decorate([property({
403
+ type: Boolean,
404
+ reflect: true
405
+ }), __decorateMetadata("design:type", Boolean)], UDatePicker.prototype, "confirm", void 0);
380
406
  __decorate([query(".container", true), __decorateMetadata("design:type", typeof HTMLElement === "undefined" ? Object : HTMLElement)], UDatePicker.prototype, "containerEl", void 0);
381
407
  __decorate([query("u-popover", true), __decorateMetadata("design:type", typeof UPopover === "undefined" ? Object : UPopover)], UDatePicker.prototype, "popoverEl", void 0);
382
408
  __decorate([query("u-calendar"), __decorateMetadata("design:type", typeof UCalendar === "undefined" ? Object : UCalendar)], UDatePicker.prototype, "calendarEl", void 0);
383
409
  __decorate([state(), __decorateMetadata("design:type", Boolean)], UDatePicker.prototype, "open", void 0);
384
410
  __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);
411
+ __decorate([state(), __decorateMetadata("design:type", String)], UDatePicker.prototype, "staged", void 0);
387
412
  UDatePicker = __decorate([customElement("u-date-picker")], UDatePicker);
388
413
  //#endregion
389
414
  export { UDatePicker };
@@ -36,25 +36,6 @@ var styles = css`
36
36
  .calendar-button {
37
37
  cursor: pointer;
38
38
  }
39
-
40
- .calendar-time {
41
- display: flex;
42
- justify-content: flex-end;
43
- padding: 4px 4px 0;
44
- }
45
- .time-input {
46
- font-family: inherit;
47
- font-size: 0.9em;
48
- padding: 2px 6px;
49
- border: 1px solid var(--u-input-border-color, #E0E0E0);
50
- border-radius: 0.25em;
51
- background-color: var(--u-input-bg-color, #FFFFFF);
52
- color: var(--u-txt-color, #212121);
53
- }
54
- .time-input:focus-visible {
55
- outline: none;
56
- box-shadow: 0 0 0 1px var(--u-input-border-color-focus, #1565C0);
57
- }
58
39
  `;
59
40
  //#endregion
60
41
  export { styles };
@@ -2,6 +2,8 @@ import { PropertyValues } from 'lit';
2
2
  import { UFormControlElement } from '../UFormControlElement.js';
3
3
  import { DateTextFormat } from '../../utilities/format.js';
4
4
  import { UCalendar } from '../calendar/UCalendar.js';
5
+ import { DateDisabledFn } from '../calendar/dates.js';
6
+ import { DatePickerMode } from '../date-picker/UDatePicker.js';
5
7
  import { UPopover } from '../popover/UPopover.js';
6
8
  import { DateRangePresetOption } from './presets.js';
7
9
  export type { DateRangePreset, DateRangePresetName, DateRangePresetOption } from './presets.js';
@@ -20,6 +22,12 @@ export type { DateRangePreset, DateRangePresetName, DateRangePresetOption } from
20
22
  * in the text box; ArrowDown (or Alt+ArrowDown) moves into the calendar. Text that is not a range
21
23
  * clears the value and reports `badInput`.
22
24
  *
25
+ * `mode="datetime"` adds a start time and an end time: each half of the value is a complete
26
+ * ISO-8601 `DateTimeOffset` (`2026-10-01T09:00:00+09:00/2026-10-31T18:00:00+09:00`), and the text
27
+ * box reads `2026-10-01 09:00 ~ 2026-10-31 18:00` or `2026-10-01 09:00 ~ 18:00` (a time alone ends on
28
+ * the first day). The first range picked covers its days whole (00:00 to 23:59); after that, picking
29
+ * other days keeps the times set. `min`/`max` and `isDateDisabled` stay date-only.
30
+ *
23
31
  * The calendar shows two months. The first day chosen is an anchor and the range previews up to
24
32
  * the day under the pointer or keyboard focus; the second day completes the range, fires
25
33
  * `change` and closes the calendar. Escape while an anchor is set drops it; Escape again closes.
@@ -48,6 +56,8 @@ export type { DateRangePreset, DateRangePresetName, DateRangePresetOption } from
48
56
  * @csspart calendar-grid - a date grid
49
57
  * @csspart calendar-week - one week row inside a date grid
50
58
  * @csspart day - a date cell button
59
+ * @csspart calendar-time - the row holding the start and end time inputs (`mode="datetime"` only)
60
+ * @csspart time-input - a time-of-day input (`mode="datetime"` only)
51
61
  * @csspart calendar-footer - the row holding the "clear" quick action
52
62
  * @csspart presets - the list of quick ranges beside the calendar
53
63
  * @csspart preset - one quick-range button
@@ -57,7 +67,8 @@ export type { DateRangePreset, DateRangePresetName, DateRangePresetOption } from
57
67
  * @cssprop --u-date-range-picker-width - host `width` (default: auto). Set `100%` where `block`
58
68
  * alone does not stretch the host (e.g. inside a flex container).
59
69
  *
60
- * @event change - fires when the user completes a range or clears it. Programmatic value
70
+ * @event change - fires when the user completes a range or clears it (with `confirm`, when Apply
71
+ * commits a different value). Programmatic value
61
72
  * assignment does not fire it (same contract as native form controls).
62
73
  */
63
74
  export declare class UDateRangePicker extends UFormControlElement<string> {
@@ -68,6 +79,11 @@ export declare class UDateRangePicker extends UFormControlElement<string> {
68
79
  max?: string;
69
80
  /** Whether to show the clear button */
70
81
  clearable: boolean;
82
+ /** App rule for days that cannot be chosen — receives the ISO day, returns `true` to disable it.
83
+ * Such a day cannot start or end a range, though a range may run across it (a week across a
84
+ * weekend); a preset that starts or ends on one is disabled. A typed or assigned range that starts
85
+ * or ends on one reports `stepMismatch`. Property only. */
86
+ isDateDisabled?: DateDisabledFn;
71
87
  /** Placeholder text (shown when there is no value). Defaults to the pattern to type. */
72
88
  placeholder?: string;
73
89
  /** How the text box writes and reads each day: `iso` (default, `YYYY-MM-DD` in every language) or
@@ -79,45 +95,72 @@ export declare class UDateRangePicker extends UFormControlElement<string> {
79
95
  * (`presets="today last7Days thisMonth"`). Empty (default) shows no list.
80
96
  */
81
97
  presets: DateRangePresetOption[];
82
- /** First day of the range (ISO), or `undefined` when there is no complete range. */
98
+ /** Picks in the calendar wait for an Apply button instead of committing at once. Completing a
99
+ * range, choosing a preset or "clear" inside the calendar only stages the choice; Apply commits
100
+ * it, fires `change` and closes; Cancel, Escape or closing the calendar any other way drops it.
101
+ * Typing in the text box still commits on Enter or leaving the field. */
102
+ confirm: boolean;
103
+ /** `date` (default) picks a period of days. `datetime` adds a start and an end time; each half of
104
+ * the value becomes a complete ISO-8601 `DateTimeOffset` (`…T09:00:00+09:00/…T18:00:00+09:00`). */
105
+ mode: DatePickerMode;
106
+ /** `mode="datetime"`: times are entered to the second — the time inputs show seconds, the text box
107
+ * reads and shows `HH:mm:ss`, and a whole day ends at `23:59:59`. */
108
+ seconds: boolean;
109
+ /** Start of the range — the ISO day, or in `mode="datetime"` the ISO date-time; `undefined` when
110
+ * there is no complete range. */
83
111
  get start(): string | undefined;
84
- /** Last day of the range (ISO), or `undefined` when there is no complete range. */
112
+ /** End of the range — the ISO day, or in `mode="datetime"` the ISO date-time; `undefined` when
113
+ * there is no complete range. */
85
114
  get end(): string | undefined;
86
115
  containerEl?: HTMLElement;
87
116
  popoverEl?: UPopover;
88
117
  calendarEl?: UCalendar;
89
118
  private readonly calendarId;
90
119
  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;
120
+ /** With `confirm`, the range chosen in the open calendar that Apply would commit. */
121
+ private staged?;
122
+ /** `mode="datetime"`: the times the next range takes while there is none yet — once a range
123
+ * exists, the time inputs read and write its halves instead. */
124
+ private pendingTimes?;
125
+ /** Times a whole-day range takes in `mode="datetime"` — a preset or a first calendar pick: from
126
+ * the first minute (or second, with `seconds`) to the last. */
127
+ private get wholeDay();
128
+ /** The typed-range text box — what is being typed, committing it, opening the calendar. */
129
+ private readonly textEntry;
97
130
  protected willUpdate(changed: PropertyValues): void;
131
+ /** What the open calendar shows and edits: the staged range with `confirm`, otherwise the value. */
132
+ private get working();
133
+ /** The times the working range has — or, without one, the ones the next range takes. */
134
+ private workingTimes;
135
+ /** The value for two days (and, in `mode="datetime"`, two times), earlier first. */
136
+ private build;
137
+ /** Typed text as a range — days, or in `mode="datetime"` local date-times. A day typed without a
138
+ * time keeps the working range's time at that end. */
139
+ private parseTyped;
98
140
  protected shouldValidate(changed: PropertyValues): boolean;
99
141
  protected updated(changed: PropertyValues): void;
100
142
  render(): import('lit-html').TemplateResult<1>;
101
143
  private renderCalendar;
144
+ private renderTimeRow;
145
+ /** A time input changed — with a range, that end moves (committed at once, or staged with
146
+ * `confirm`; the calendar stays open); without one, the next range takes it. A start time set
147
+ * after the end on the same day swaps the two, as a reversed range always is. */
148
+ private handleTimeChange;
102
149
  private renderPresets;
103
- /** A preset that reaches outside `min`/`max` is not offered — its label would promise more
104
- * than the picker may hold. */
105
- private outOfBounds;
150
+ /** A preset that reaches outside `min`/`max`, or starts or ends on a disabled day, is not
151
+ * offered — its label would promise a range the calendar itself refuses. */
152
+ private unavailable;
153
+ /** Whether `isDateDisabled` refuses either end of the range (the days between may be disabled). */
154
+ private endpointDisabled;
106
155
  private handleRangeSelect;
107
- /** A user-chosen range (calendar or preset): set it, announce it, close the calendar. */
156
+ /** A user-chosen range of days (calendar or preset) at `times` (`mode="datetime"`): set it,
157
+ * announce it, close the calendar — or, with `confirm`, stage it for Apply. A calendar pick keeps
158
+ * the times already set; a preset covers its days whole. */
108
159
  private commitRange;
160
+ /** Commits `next` as the value (firing `change` when it differs), closes the calendar and
161
+ * returns focus to the text box. */
162
+ private commitValue;
109
163
  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;
121
164
  /** Escape that reaches the picker closes the calendar — the calendar keeps the first Escape
122
165
  * for itself while a range is half picked. */
123
166
  private handleCalendarKeydown;
@@ -125,6 +168,10 @@ export declare class UDateRangePicker extends UFormControlElement<string> {
125
168
  private handlePopoverHide;
126
169
  private handleClearClick;
127
170
  private handleFooterResetClick;
171
+ /** `confirm` 모드의 «적용» — 달력에서 고른 범위를 값으로 확정한다(비운 채면 값을 비운다). */
172
+ private handleApplyClick;
173
+ /** `confirm` 모드의 «취소» — 고른 것은 다음에 열 때 값에서 다시 시작하므로 닫기만 하면 버려진다. */
174
+ private handleCancelClick;
128
175
  private resetValue;
129
176
  /** The clear icon is a display element — relay Enter/Space to its click handler
130
177
  * (same pattern as `u-date-picker`, `u-input`, `u-select`). */