@iyulab/components 1.57.1 → 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 (39) hide show
  1. package/CHANGELOG.md +52 -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/dates.d.ts +4 -0
  19. package/dist/components/calendar/dates.js +5 -1
  20. package/dist/components/calendar/datetime.d.ts +14 -0
  21. package/dist/components/calendar/datetime.js +35 -0
  22. package/dist/components/calendar/picker.styles.js +35 -0
  23. package/dist/components/carousel/UCarousel.d.ts +7 -1
  24. package/dist/components/carousel/UCarousel.js +8 -1
  25. package/dist/components/date-picker/UDatePicker.d.ts +29 -1
  26. package/dist/components/date-picker/UDatePicker.js +89 -31
  27. package/dist/components/date-picker/UDatePicker.styles.js +0 -19
  28. package/dist/components/date-range-picker/UDateRangePicker.d.ts +69 -7
  29. package/dist/components/date-range-picker/UDateRangePicker.js +205 -34
  30. package/dist/index.js +2 -2
  31. package/dist/utilities/Locale.d.ts +2 -2
  32. package/dist/utilities/Locale.js +2 -2
  33. package/dist/utilities/format.d.ts +32 -4
  34. package/dist/utilities/format.js +131 -15
  35. package/package.json +1 -1
  36. package/skills/iyulab-components/references/components/carousel.md +3 -1
  37. package/skills/iyulab-components/references/components/date-picker.md +34 -2
  38. package/skills/iyulab-components/references/components/date-range-picker.md +52 -5
  39. package/skills/iyulab-components/references/utilities/locale.md +1 -1
@@ -5,12 +5,13 @@ 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 { dateTextPattern, formatDateRangeText, parseDateRange } from "../../utilities/format.js";
8
+ import { dateTextPattern, formatDateRangeText, formatDateTimeRangeText, parseDateRange, parseDateTimeRange } 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
13
  import { DateTextController } from "../calendar/date-text-controller.js";
14
+ import { normalizeTime, splitDateTime, toDateTimeOffset } from "../calendar/datetime.js";
14
15
  import { styles } from "../calendar/picker.styles.js";
15
16
  import { resolvePresets } from "./presets.js";
16
17
  import { styles as styles$1 } from "./UDateRangePicker.styles.js";
@@ -19,34 +20,54 @@ import { customElement, property, query, state } from "lit/decorators.js";
19
20
  import { ifDefined } from "lit/directives/if-defined.js";
20
21
  //#region src/components/date-range-picker/UDateRangePicker.ts
21
22
  var ISO_DATE = /^\d{4}-\d{2}-\d{2}$/;
22
- /** Splits `"start/end"` into its two ISO dates — `undefined` unless both halves are ISO dates. */
23
- function parseInterval(value) {
23
+ var ISO_DATE_TIME = /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}/;
24
+ /** Splits `"start/end"` into its two halves — ISO dates, or in `mode="datetime"` ISO date-times;
25
+ * `undefined` unless both halves have that shape. */
26
+ function parseInterval(value, mode) {
24
27
  if (!value) return void 0;
25
28
  const [start, end, ...rest] = value.split("/");
26
- if (rest.length || !ISO_DATE.test(start ?? "") || !ISO_DATE.test(end ?? "")) return void 0;
29
+ const shape = mode === "datetime" ? ISO_DATE_TIME : ISO_DATE;
30
+ if (rest.length || !shape.test(start ?? "") || !shape.test(end ?? "")) return void 0;
27
31
  return {
28
32
  start,
29
33
  end
30
34
  };
31
35
  }
36
+ /** Whether `start` comes after `end` — by day in `date` mode, by instant in `datetime` mode. */
37
+ function reversed(start, end, mode) {
38
+ return mode === "datetime" ? new Date(start).getTime() > new Date(end).getTime() : start > end;
39
+ }
40
+ /** The ISO day of a half (`YYYY-MM-DD` either way). */
41
+ var dayPart = (half) => half.slice(0, 10);
32
42
  var UDateRangePicker = class UDateRangePicker extends UFormControlElement {
33
43
  constructor(..._args) {
34
44
  super(..._args);
35
45
  this.clearable = false;
36
46
  this.format = "iso";
37
47
  this.presets = [];
48
+ this.confirm = false;
49
+ this.mode = "date";
50
+ this.seconds = false;
38
51
  this.calendarId = `u-date-range-picker-calendar-${Math.random().toString(36).slice(2, 8)}`;
39
52
  this.open = false;
40
53
  this.textEntry = new DateTextController(this, {
41
54
  toValue: (text) => {
42
55
  if (!text.trim()) return void 0;
43
- const range = parseDateRange(text, { format: this.format });
44
- return range ? `${range.start}/${range.end}` : null;
56
+ const range = this.parseTyped(text);
57
+ if (!range) return null;
58
+ return this.build(dayPart(range.start), dayPart(range.end), {
59
+ start: range.start.slice(11) || this.wholeDay.start,
60
+ end: range.end.slice(11) || this.wholeDay.end
61
+ });
62
+ },
63
+ dayOf: (text) => {
64
+ const start = this.parseTyped(text)?.start;
65
+ return start ? dayPart(start) : null;
45
66
  },
46
- dayOf: (text) => parseDateRange(text, { format: this.format })?.start ?? null,
47
67
  shown: () => {
48
- const range = parseInterval(this.value);
49
- return range ? formatDateRangeText(range.start, range.end, this.format) : this.value ?? "";
68
+ const range = parseInterval(this.value, this.mode);
69
+ if (!range) return this.value ?? "";
70
+ return this.mode === "datetime" ? formatDateTimeRangeText(range.start, range.end, this.format, void 0, this.seconds) : formatDateRangeText(range.start, range.end, this.format);
50
71
  },
51
72
  onChange: () => this.emitChange(),
52
73
  onBadText: () => {
@@ -59,7 +80,7 @@ var UDateRangePicker = class UDateRangePicker extends UFormControlElement {
59
80
  interactive: () => !this.effectivelyDisabled && !this.readonly
60
81
  });
61
82
  this.handleRangeSelect = (e) => {
62
- this.commitRange(e.detail.start, e.detail.end);
83
+ this.commitRange(e.detail.start, e.detail.end, this.workingTimes());
63
84
  };
64
85
  this.handleCalendarKeydown = (e) => {
65
86
  if (e.key !== "Escape") return;
@@ -80,10 +101,21 @@ var UDateRangePicker = class UDateRangePicker extends UFormControlElement {
80
101
  this.textInputEl?.focus();
81
102
  };
82
103
  this.handleFooterResetClick = () => {
104
+ if (this.confirm) {
105
+ this.staged = void 0;
106
+ return;
107
+ }
83
108
  this.resetValue();
84
109
  this.popoverEl?.hide();
85
110
  this.textInputEl?.focus();
86
111
  };
112
+ this.handleApplyClick = () => {
113
+ this.commitValue(this.staged);
114
+ };
115
+ this.handleCancelClick = () => {
116
+ this.popoverEl?.hide();
117
+ this.textInputEl?.focus();
118
+ };
87
119
  this.handleClearKeydown = (e) => {
88
120
  if (e.key !== "Enter" && e.key !== " ") return;
89
121
  e.preventDefault();
@@ -97,32 +129,78 @@ var UDateRangePicker = class UDateRangePicker extends UFormControlElement {
97
129
  styles$1
98
130
  ];
99
131
  }
100
- /** First day of the range (ISO), or `undefined` when there is no complete range. */
132
+ /** Start of the range — the ISO day, or in `mode="datetime"` the ISO date-time; `undefined` when
133
+ * there is no complete range. */
101
134
  get start() {
102
- return parseInterval(this.value)?.start;
135
+ return parseInterval(this.value, this.mode)?.start;
103
136
  }
104
- /** Last day of the range (ISO), or `undefined` when there is no complete range. */
137
+ /** End of the range — the ISO day, or in `mode="datetime"` the ISO date-time; `undefined` when
138
+ * there is no complete range. */
105
139
  get end() {
106
- return parseInterval(this.value)?.end;
140
+ return parseInterval(this.value, this.mode)?.end;
141
+ }
142
+ /** Times a whole-day range takes in `mode="datetime"` — a preset or a first calendar pick: from
143
+ * the first minute (or second, with `seconds`) to the last. */
144
+ get wholeDay() {
145
+ return this.seconds ? {
146
+ start: "00:00:00",
147
+ end: "23:59:59"
148
+ } : {
149
+ start: "00:00",
150
+ end: "23:59"
151
+ };
107
152
  }
108
153
  willUpdate(changed) {
109
154
  super.willUpdate(changed);
110
155
  if (changed.has("value")) {
111
- const range = parseInterval(this.value);
112
- if (range && range.start > range.end) this.value = `${range.end}/${range.start}`;
156
+ const range = parseInterval(this.value, this.mode);
157
+ if (range && reversed(range.start, range.end, this.mode)) this.value = `${range.end}/${range.start}`;
113
158
  }
159
+ if (this.open && (changed.has("open") || changed.has("value"))) this.staged = this.value;
160
+ }
161
+ /** What the open calendar shows and edits: the staged range with `confirm`, otherwise the value. */
162
+ get working() {
163
+ return this.confirm && this.open ? this.staged : this.value;
164
+ }
165
+ /** The times the working range has — or, without one, the ones the next range takes. */
166
+ workingTimes() {
167
+ const range = parseInterval(this.working, this.mode);
168
+ if (this.mode !== "datetime" || !range) return this.pendingTimes ?? this.wholeDay;
169
+ return {
170
+ start: splitDateTime(range.start, true).time,
171
+ end: splitDateTime(range.end, true).time
172
+ };
173
+ }
174
+ /** The value for two days (and, in `mode="datetime"`, two times), earlier first. */
175
+ build(startDay, endDay, times) {
176
+ if (this.mode !== "datetime") return `${startDay}/${endDay}`;
177
+ const start = toDateTimeOffset(startDay, times.start);
178
+ const end = toDateTimeOffset(endDay, times.end);
179
+ return reversed(start, end, this.mode) ? `${end}/${start}` : `${start}/${end}`;
180
+ }
181
+ /** Typed text as a range — days, or in `mode="datetime"` local date-times. A day typed without a
182
+ * time keeps the working range's time at that end. */
183
+ parseTyped(text) {
184
+ if (this.mode !== "datetime") return parseDateRange(text, { format: this.format });
185
+ const times = this.workingTimes();
186
+ return parseDateTimeRange(text, {
187
+ format: this.format,
188
+ startTime: times.start,
189
+ endTime: times.end,
190
+ seconds: this.seconds
191
+ });
114
192
  }
115
193
  shouldValidate(changed) {
116
- return super.shouldValidate(changed) || changed.has("min") || changed.has("max");
194
+ return super.shouldValidate(changed) || changed.has("min") || changed.has("max") || changed.has("isDateDisabled");
117
195
  }
118
196
  updated(changed) {
119
197
  super.updated(changed);
120
198
  if (changed.has("value")) this.internals?.setFormValue(this.value ?? "");
121
199
  if (changed.has("open")) this.internals?.states[this.open ? "add" : "delete"]("open");
122
- if (changed.has("open") && this.open) this.textEntry.calendarOpened(this.start ?? /* @__PURE__ */ new Date());
200
+ if (changed.has("open") && this.open) this.textEntry.calendarOpened(this.start ? dayPart(this.start) : /* @__PURE__ */ new Date());
123
201
  }
124
202
  render() {
125
- const pattern = dateTextPattern(this.format);
203
+ const pattern = this.mode === "datetime" ? `${dateTextPattern(this.format)} ${this.seconds ? "HH:mm:ss" : "HH:mm"}` : dateTextPattern(this.format);
126
204
  return html`
127
205
  <u-field part="field"
128
206
  ?required=${this.required}
@@ -192,6 +270,8 @@ var UDateRangePicker = class UDateRangePicker extends UFormControlElement {
192
270
  }
193
271
  renderCalendar() {
194
272
  const presets = resolvePresets(this.presets, /* @__PURE__ */ new Date(), (name) => devWarnOnce(`date-range-preset:${name}`, `u-date-range-picker: unknown preset "${name}" — it is not listed.`));
273
+ const working = parseInterval(this.working, this.mode);
274
+ const showClear = this.clearable && !!this.working;
195
275
  return html`
196
276
  <div class="body">
197
277
  ${presets.length ? this.renderPresets(presets) : ""}
@@ -200,43 +280,112 @@ var UDateRangePicker = class UDateRangePicker extends UFormControlElement {
200
280
  exportparts="calendar-month, calendar-header, calendar-title, calendar-weekdays, calendar-grid, calendar-week, day"
201
281
  selection="range"
202
282
  visible-months="2"
203
- .start=${this.start}
204
- .end=${this.end}
283
+ .start=${working && dayPart(working.start)}
284
+ .end=${working && dayPart(working.end)}
205
285
  .min=${this.min}
206
286
  .max=${this.max}
287
+ .isDateDisabled=${this.isDateDisabled}
207
288
  @range-select=${this.handleRangeSelect}
208
289
  @keydown=${this.handleCalendarKeydown}
209
290
  ></u-calendar>
210
- ${this.clearable && this.value ? html`
291
+ ${this.renderTimeRow()}
292
+ ${showClear || this.confirm ? html`
211
293
  <div class="calendar-footer" part="calendar-footer">
212
- <u-button variant="ghost" size="sm" @click=${this.handleFooterResetClick}>${Locale.getValue("clear")}</u-button>
294
+ ${showClear ? html`
295
+ <u-button variant="ghost" size="sm" @click=${this.handleFooterResetClick}>${Locale.getValue("clear")}</u-button>
296
+ ` : ""}
297
+ ${this.confirm ? html`
298
+ <span class="confirm-actions">
299
+ <u-button variant="ghost" size="sm" @click=${this.handleCancelClick}>${Locale.getValue("cancel")}</u-button>
300
+ <u-button size="sm" @click=${this.handleApplyClick}>${Locale.getValue("apply")}</u-button>
301
+ </span>
302
+ ` : ""}
213
303
  </div>
214
304
  ` : ""}
215
305
  </div>
216
306
  </div>
217
307
  `;
218
308
  }
309
+ renderTimeRow() {
310
+ if (this.mode !== "datetime") return "";
311
+ const times = this.workingTimes();
312
+ return html`
313
+ <div class="calendar-time" part="calendar-time">
314
+ <label class="time-field">${Locale.getValue("startTime")}
315
+ <input type="time" class="time-input" part="time-input"
316
+ step=${ifDefined(this.seconds ? "1" : void 0)}
317
+ .value=${normalizeTime(times.start, this.seconds)}
318
+ @change=${(e) => this.handleTimeChange("start", e)}
319
+ />
320
+ </label>
321
+ <label class="time-field">${Locale.getValue("endTime")}
322
+ <input type="time" class="time-input" part="time-input"
323
+ step=${ifDefined(this.seconds ? "1" : void 0)}
324
+ .value=${normalizeTime(times.end, this.seconds)}
325
+ @change=${(e) => this.handleTimeChange("end", e)}
326
+ />
327
+ </label>
328
+ </div>
329
+ `;
330
+ }
331
+ /** A time input changed — with a range, that end moves (committed at once, or staged with
332
+ * `confirm`; the calendar stays open); without one, the next range takes it. A start time set
333
+ * after the end on the same day swaps the two, as a reversed range always is. */
334
+ handleTimeChange(which, e) {
335
+ const time = normalizeTime(e.target.value || this.wholeDay[which], this.seconds);
336
+ const times = {
337
+ ...this.workingTimes(),
338
+ [which]: time
339
+ };
340
+ this.pendingTimes = times;
341
+ const range = parseInterval(this.working, this.mode);
342
+ if (!range) return;
343
+ const next = this.build(dayPart(range.start), dayPart(range.end), times);
344
+ if (this.confirm) {
345
+ this.staged = next;
346
+ return;
347
+ }
348
+ const changed = next !== this.value;
349
+ this.textEntry.clear();
350
+ this.value = next;
351
+ if (changed) this.emitChange();
352
+ }
219
353
  renderPresets(presets) {
220
354
  return html`
221
355
  <div class="presets" part="presets" role="group" aria-label=${Locale.getValue("quickRanges")}>
222
356
  ${presets.map((p) => html`
223
357
  <button type="button" class="preset" part="preset"
224
- aria-pressed=${`${p.start}/${p.end}` === this.value}
225
- ?disabled=${this.outOfBounds(p)}
226
- @click=${() => this.commitRange(p.start, p.end)}
358
+ aria-pressed=${this.build(p.start, p.end, this.wholeDay) === this.working}
359
+ ?disabled=${this.unavailable(p)}
360
+ @click=${() => this.commitRange(p.start, p.end, this.wholeDay)}
227
361
  >${p.label}</button>
228
362
  `)}
229
363
  </div>
230
364
  `;
231
365
  }
232
- /** A preset that reaches outside `min`/`max` is not offered — its label would promise more
233
- * than the picker may hold. */
234
- outOfBounds(p) {
235
- return !!this.min && p.start < this.min || !!this.max && p.end > this.max;
366
+ /** A preset that reaches outside `min`/`max`, or starts or ends on a disabled day, is not
367
+ * offered — its label would promise a range the calendar itself refuses. */
368
+ unavailable(p) {
369
+ return !!this.min && p.start < this.min || !!this.max && p.end > this.max || this.endpointDisabled(p);
370
+ }
371
+ /** Whether `isDateDisabled` refuses either end of the range (the days between may be disabled). */
372
+ endpointDisabled(p) {
373
+ return !!this.isDateDisabled && (this.isDateDisabled(dayPart(p.start)) || this.isDateDisabled(dayPart(p.end)));
374
+ }
375
+ /** A user-chosen range of days (calendar or preset) at `times` (`mode="datetime"`): set it,
376
+ * announce it, close the calendar — or, with `confirm`, stage it for Apply. A calendar pick keeps
377
+ * the times already set; a preset covers its days whole. */
378
+ commitRange(start, end, times) {
379
+ const next = this.build(start, end, times);
380
+ if (this.confirm) {
381
+ this.staged = next;
382
+ return;
383
+ }
384
+ this.commitValue(next);
236
385
  }
237
- /** A user-chosen range (calendar or preset): set it, announce it, close the calendar. */
238
- commitRange(start, end) {
239
- const next = `${start}/${end}`;
386
+ /** Commits `next` as the value (firing `change` when it differs), closes the calendar and
387
+ * returns focus to the text box. */
388
+ commitValue(next) {
240
389
  const changed = next !== this.value;
241
390
  this.textEntry.clear();
242
391
  this.value = next;
@@ -263,7 +412,11 @@ var UDateRangePicker = class UDateRangePicker extends UFormControlElement {
263
412
  setValidity() {
264
413
  let flags = {};
265
414
  let message = "";
266
- const range = parseInterval(this.value);
415
+ const parsed = parseInterval(this.value, this.mode);
416
+ const range = parsed && {
417
+ start: dayPart(parsed.start),
418
+ end: dayPart(parsed.end)
419
+ };
267
420
  if (this.textEntry.badText) {
268
421
  flags = { badInput: true };
269
422
  message = Locale.getValue("badInput");
@@ -279,6 +432,9 @@ var UDateRangePicker = class UDateRangePicker extends UFormControlElement {
279
432
  } else if (range && this.max && parseISODate(range.end) > parseISODate(this.max)) {
280
433
  flags = { rangeOverflow: true };
281
434
  message = Locale.getValue("rangeOverflow", { max: this.max });
435
+ } else if (range && this.endpointDisabled(range)) {
436
+ flags = { stepMismatch: true };
437
+ message = Locale.getValue("dateUnavailable");
282
438
  }
283
439
  this.commit(flags, message, this.textInputEl ?? this.containerEl ?? void 0);
284
440
  }
@@ -301,6 +457,7 @@ __decorate([property({
301
457
  type: Boolean,
302
458
  reflect: true
303
459
  }), __decorateMetadata("design:type", Boolean)], UDateRangePicker.prototype, "clearable", void 0);
460
+ __decorate([property({ attribute: false }), __decorateMetadata("design:type", Object)], UDateRangePicker.prototype, "isDateDisabled", void 0);
304
461
  __decorate([property({ type: String }), __decorateMetadata("design:type", String)], UDateRangePicker.prototype, "placeholder", void 0);
305
462
  __decorate([property({
306
463
  type: String,
@@ -310,10 +467,24 @@ __decorate([property({
310
467
  attribute: "presets",
311
468
  converter: { fromAttribute: (v) => (v ?? "").split(/\s+/).filter(Boolean) }
312
469
  }), __decorateMetadata("design:type", Array)], UDateRangePicker.prototype, "presets", void 0);
470
+ __decorate([property({
471
+ type: Boolean,
472
+ reflect: true
473
+ }), __decorateMetadata("design:type", Boolean)], UDateRangePicker.prototype, "confirm", void 0);
474
+ __decorate([property({
475
+ type: String,
476
+ reflect: true
477
+ }), __decorateMetadata("design:type", Object)], UDateRangePicker.prototype, "mode", void 0);
478
+ __decorate([property({
479
+ type: Boolean,
480
+ reflect: true
481
+ }), __decorateMetadata("design:type", Boolean)], UDateRangePicker.prototype, "seconds", void 0);
313
482
  __decorate([query(".container", true), __decorateMetadata("design:type", typeof HTMLElement === "undefined" ? Object : HTMLElement)], UDateRangePicker.prototype, "containerEl", void 0);
314
483
  __decorate([query("u-popover", true), __decorateMetadata("design:type", typeof UPopover === "undefined" ? Object : UPopover)], UDateRangePicker.prototype, "popoverEl", void 0);
315
484
  __decorate([query("u-calendar"), __decorateMetadata("design:type", typeof UCalendar === "undefined" ? Object : UCalendar)], UDateRangePicker.prototype, "calendarEl", void 0);
316
485
  __decorate([state(), __decorateMetadata("design:type", Boolean)], UDateRangePicker.prototype, "open", void 0);
486
+ __decorate([state(), __decorateMetadata("design:type", String)], UDateRangePicker.prototype, "staged", void 0);
487
+ __decorate([state(), __decorateMetadata("design:type", Object)], UDateRangePicker.prototype, "pendingTimes", void 0);
317
488
  UDateRangePicker = __decorate([customElement("u-date-range-picker")], UDateRangePicker);
318
489
  //#endregion
319
490
  export { UDateRangePicker };
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, formatDateRangeText, formatDateText, formatDateTimeText, formatNumber, parseDate, parseDateRange, parseDateTime, parseNumber } from "./utilities/format.js";
29
+ import { dateTextPattern, formatCurrency, formatDate, formatDateRange, formatDateRangeText, formatDateText, formatDateTimeRangeText, formatDateTimeText, formatNumber, parseDate, parseDateRange, parseDateTime, parseDateTimeRange, 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, formatDateRangeText, formatDateText, formatDateTimeText, formatNumber, getDefaultBaseUrl, getParentElement, isCoarsePointer, isFocusCandidate, isImeComposing, jsonAttrConverter, parseDate, parseDateRange, 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, formatDateTimeRangeText, formatDateTimeText, formatNumber, getDefaultBaseUrl, getParentElement, isCoarsePointer, isFocusCandidate, isImeComposing, jsonAttrConverter, parseDate, parseDateRange, parseDateTime, parseDateTimeRange, parseNumber, querySelectorAllWithin, querySelectorDeep, querySelectorWithin, resetDevWarnings, setDefaultBaseUrl, urlAttrConverter };
@@ -12,7 +12,7 @@ export type SupportedLocale = 'en' | 'ko' | 'ja' | 'zh-CN' | 'zh-TW' | 'es' | 'f
12
12
  /** 내장 로케일은 자동완성되지만, 임의의 BCP47 태그도 그대로 받는다. */
13
13
  export type LocaleTag = SupportedLocale | (string & {});
14
14
  /** 라이브러리가 제공하는 chrome 문자열 키. 지금은 검증 메시지뿐이지만 이후 다른 UI 문구도 추가될 수 있다. */
15
- export type LocaleMessageKey = 'valueMissing' | 'badInput' | 'typeMismatch' | 'patternMismatch' | 'rangeUnderflow' | 'rangeOverflow' | 'stepMismatch' | 'tooShort' | 'tooLong' | 'increment' | 'decrement' | 'clear' | 'today' | 'time' | 'showPassword' | 'hidePassword' | 'previousSlide' | 'nextSlide' | 'goToSlide' | 'stopSlideRotation' | 'startSlideRotation' | 'chooseDate' | 'chooseDateRange' | 'yesterday' | 'last7Days' | 'last30Days' | 'thisWeek' | 'lastWeek' | 'thisMonth' | 'lastMonth' | 'thisYear' | 'quickRanges' | 'rangeStartChosen' | 'previousMonth' | 'nextMonth' | 'close' | 'copy' | 'copied' | 'chooseFile' | 'noFileChosen' | 'filesSelected' | 'resizePanels' | 'breadcrumb' | 'search' | 'alertError' | 'alertWarning' | 'alertSuccess' | 'alertInfo' | 'alertNotice' | 'alertMessage' | 'remove' | 'closeTab' | 'confirm' | 'cancel';
15
+ export type LocaleMessageKey = 'valueMissing' | 'badInput' | 'typeMismatch' | 'patternMismatch' | 'rangeUnderflow' | 'rangeOverflow' | 'stepMismatch' | 'tooShort' | 'tooLong' | 'increment' | 'decrement' | 'clear' | 'today' | 'time' | 'showPassword' | 'hidePassword' | 'previousSlide' | 'nextSlide' | 'goToSlide' | 'stopSlideRotation' | 'startSlideRotation' | 'chooseDate' | 'chooseDateRange' | 'yesterday' | 'last7Days' | 'last30Days' | 'thisWeek' | 'lastWeek' | 'thisMonth' | 'lastMonth' | 'thisYear' | 'quickRanges' | 'rangeStartChosen' | 'previousMonth' | 'nextMonth' | 'close' | 'copy' | 'copied' | 'chooseFile' | 'noFileChosen' | 'filesSelected' | 'resizePanels' | 'breadcrumb' | 'search' | 'alertError' | 'alertWarning' | 'alertSuccess' | 'alertInfo' | 'alertNotice' | 'alertMessage' | 'remove' | 'closeTab' | 'confirm' | 'cancel' | 'apply' | 'dateUnavailable' | 'startTime' | 'endTime' | 'timeAm' | 'timePm';
16
16
  type LocaleTable = Record<LocaleMessageKey, string>;
17
17
  /**
18
18
  * 한 패키지(또는 앱 영역)의 문자열 묶음.
@@ -64,7 +64,7 @@ export declare class Locale {
64
64
  * 현재 활성 로케일 기준으로 메시지를 조회합니다.
65
65
  * `params`가 있으면 템플릿의 `{name}` 자리를 치환합니다.
66
66
  */
67
- static getValue(key: LocaleMessageKey, params?: Record<string, string | number>): string;
67
+ static getValue(key: LocaleMessageKey, params?: Record<string, string | number>, locale?: LocaleTag): string;
68
68
  /**
69
69
  * 네임스페이스 핸들을 얻습니다 — 같은 이름이면 **같은 저장소**를 가리킵니다.
70
70
  *
@@ -125,8 +125,8 @@ var Locale = class {
125
125
  * 현재 활성 로케일 기준으로 메시지를 조회합니다.
126
126
  * `params`가 있으면 템플릿의 `{name}` 자리를 치환합니다.
127
127
  */
128
- static getValue(key, params) {
129
- return interpolate(lookup(active, key), params);
128
+ static getValue(key, params, locale) {
129
+ return interpolate(lookup(locale ?? active, key), params);
130
130
  }
131
131
  /**
132
132
  * 네임스페이스 핸들을 얻습니다 — 같은 이름이면 **같은 저장소**를 가리킵니다.
@@ -84,17 +84,22 @@ export declare function parseDate(text: string, options?: {
84
84
  /**
85
85
  * Reads a date and a time of day as people type them and returns local `YYYY-MM-DDTHH:mm`, or `null`.
86
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`.
87
+ * (`9:05`, `09:05`, `09:05:30` — seconds are dropped). With `seconds`, the result is
88
+ * `YYYY-MM-DDTHH:mm:ss` and typed seconds are kept (`:00` when none are typed). Text with only a date
89
+ * takes `defaultTime` (`00:00` unless given). An hour above 23, or a minute or second above 59, is `null`.
89
90
  */
90
91
  export declare function parseDateTime(text: string, options?: {
91
92
  format?: DateTextFormat;
92
93
  locale?: LocaleTag;
93
94
  referenceDate?: Date;
94
95
  defaultTime?: string;
96
+ seconds?: boolean;
95
97
  }): 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
+ * Writes local `YYYY-MM-DDTHH:mm` (or a longer ISO date-time) as `{date} HH:mm`, the date part as
100
+ * {@link formatDateText} writes it — `{date} HH:mm:ss` with `seconds`.
101
+ */
102
+ export declare function formatDateTimeText(isoLocal: string, format?: DateTextFormat, locale?: LocaleTag, seconds?: boolean): string;
98
103
  /**
99
104
  * Reads a period of days as people type it — `2026-10-01 ~ 2026-10-31`, `2026-10-01 – 10-31`,
100
105
  * the ISO interval `2026-10-01/2026-10-31`, or a single day (a one-day range) — and returns
@@ -112,3 +117,26 @@ export declare function parseDateRange(text: string, options?: {
112
117
  } | null;
113
118
  /** Writes a period as `{start} – {end}`, each day as {@link formatDateText} writes it. */
114
119
  export declare function formatDateRangeText(start: string, end: string, format?: DateTextFormat, locale?: LocaleTag): string;
120
+ /**
121
+ * Reads a period with times of day — `2026-10-01 09:00 ~ 2026-10-31 18:00`, `2026-10-01 09:00 ~ 18:00`
122
+ * (a time alone ends on the first day), the ISO interval `2026-10-01T09:00/2026-10-31T18:00`, or the
123
+ * day forms {@link parseDateRange} reads — and returns `{ start, end }` as local `YYYY-MM-DDTHH:mm`,
124
+ * earlier first, or `null`. A day typed without a time takes `startTime` (default `00:00`) at the
125
+ * start and `endTime` (default `23:59`) at the end, so a period of days covers them whole; one day
126
+ * alone runs from `startTime` to `endTime` that day. A short second day takes the first day's year,
127
+ * or the next year when it would otherwise fall before the first day. With `seconds`, both ends are
128
+ * `YYYY-MM-DDTHH:mm:ss` (see {@link parseDateTime}).
129
+ */
130
+ export declare function parseDateTimeRange(text: string, options?: {
131
+ format?: DateTextFormat;
132
+ locale?: LocaleTag;
133
+ referenceDate?: Date;
134
+ startTime?: string;
135
+ endTime?: string;
136
+ seconds?: boolean;
137
+ }): {
138
+ start: string;
139
+ end: string;
140
+ } | null;
141
+ /** Writes a period with times as `{start} – {end}`, each as {@link formatDateTimeText} writes it. */
142
+ export declare function formatDateTimeRangeText(start: string, end: string, format?: DateTextFormat, locale?: LocaleTag, seconds?: boolean): string;