@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
@@ -73,6 +73,41 @@ var styles = css`
73
73
  margin-top: 4px;
74
74
  border-top: 1px solid var(--u-border-color-weak, #EEEEEE);
75
75
  }
76
+
77
+ /* mode="datetime" 의 시간 칸 줄 — 단일 피커는 칸 하나, 기간 피커는 이름 붙은 칸 둘. */
78
+ .calendar-time {
79
+ display: flex;
80
+ justify-content: flex-end;
81
+ flex-wrap: wrap;
82
+ gap: 4px 12px;
83
+ padding: 4px 4px 0;
84
+ }
85
+ .time-field {
86
+ display: inline-flex;
87
+ align-items: center;
88
+ gap: 6px;
89
+ color: var(--u-txt-color-weak, #616161);
90
+ }
91
+ .time-input {
92
+ font-family: inherit;
93
+ font-size: 0.9em;
94
+ padding: 2px 6px;
95
+ border: 1px solid var(--u-input-border-color, #E0E0E0);
96
+ border-radius: 0.25em;
97
+ background-color: var(--u-input-bg-color, #FFFFFF);
98
+ color: var(--u-txt-color, #212121);
99
+ }
100
+ .time-input:focus-visible {
101
+ outline: none;
102
+ box-shadow: 0 0 0 1px var(--u-input-border-color-focus, #1565C0);
103
+ }
104
+
105
+ /* confirm 모드의 취소·적용 — 줄 끝에 붙는다(빠른 동작이 없으면 혼자서도 오른쪽). */
106
+ .confirm-actions {
107
+ display: flex;
108
+ gap: 4px;
109
+ margin-inline-start: auto;
110
+ }
76
111
  `;
77
112
  //#endregion
78
113
  export { styles };
@@ -7,7 +7,8 @@ import { UElement } from '../UElement.js';
7
7
  *
8
8
  * `autoplay` 이면 회전 제어 버튼(정지/시작)이 인디케이터 줄의 첫 자리에 그려진다. 포인터가 캐러셀 위에
9
9
  * 있는 동안은 잠시 멈추고, 키보드 초점이 안으로 들어오면 사용자가 다시 시작할 때까지 멈춘다
10
- * (WAI-ARIA APG Carousel · WCAG 2.2.2).
10
+ * (WAI-ARIA APG Carousel · WCAG 2.2.2). 사용자가 동작 줄이기(`prefers-reduced-motion: reduce`)를
11
+ * 켜 두었으면 정지 상태로 시작하고(시작 버튼으로 켤 수 있다), 보는 중에 그 설정이 켜지면 멈춘다.
11
12
  *
12
13
  * @csspart slides - 슬라이드 컨테이너
13
14
  * @csspart prev-button - 이전 버튼
@@ -46,6 +47,8 @@ export declare class UCarousel extends UElement {
46
47
  /** 포인터가 캐러셀 위에 있다 — 그동안만 잠시 멈춘다. */
47
48
  private hovered;
48
49
  private autoplayTimer?;
50
+ /** `prefers-reduced-motion: reduce` 질의 — 연결된 동안만 듣는다. */
51
+ private reducedMotion?;
49
52
  private dragStartX;
50
53
  private dragStartTime;
51
54
  private pointerDown;
@@ -75,6 +78,9 @@ export declare class UCarousel extends UElement {
75
78
  private toggleRotation;
76
79
  /** 키보드 초점이 들어오면 멈춘다 — 포인터로 누른 초점은 멈추지 않는다(누른 버튼이 정지 버튼이면 그 클릭이 결정한다). */
77
80
  private handleFocusIn;
81
+ /** 보는 중에 동작 줄이기가 켜지면 멈춘다. 꺼질 때는 다시 시작하지 않는다 — 멈춘 것을 움직이게
82
+ * 하는 것은 사용자의 몫이다. */
83
+ private handleReducedMotionChange;
78
84
  private handlePointerEnter;
79
85
  private handlePointerLeave;
80
86
  private handleClickCancel;
@@ -92,6 +92,9 @@ var UCarousel = class UCarousel extends UElement {
92
92
  const origin = e.composedPath()[0];
93
93
  if (origin instanceof Element && origin.matches(":focus-visible")) this.rotationStopped = true;
94
94
  };
95
+ this.handleReducedMotionChange = (e) => {
96
+ if (e.matches && this.autoplay) this.rotationStopped = true;
97
+ };
95
98
  this.handlePointerEnter = (e) => {
96
99
  if (e.pointerType === "mouse") this.hovered = true;
97
100
  };
@@ -133,10 +136,14 @@ var UCarousel = class UCarousel extends UElement {
133
136
  this.addEventListener("focusin", this.handleFocusIn);
134
137
  this.addEventListener("pointerenter", this.handlePointerEnter);
135
138
  this.addEventListener("pointerleave", this.handlePointerLeave);
139
+ this.reducedMotion = window.matchMedia?.("(prefers-reduced-motion: reduce)");
140
+ this.reducedMotion?.addEventListener("change", this.handleReducedMotionChange);
136
141
  if (this.rotating) this.startAutoplay();
137
142
  }
138
143
  disconnectedCallback() {
139
144
  this.stopAutoplay();
145
+ this.reducedMotion?.removeEventListener("change", this.handleReducedMotionChange);
146
+ this.reducedMotion = void 0;
140
147
  this.removeEventListener("focusin", this.handleFocusIn);
141
148
  this.removeEventListener("pointerenter", this.handlePointerEnter);
142
149
  this.removeEventListener("pointerleave", this.handlePointerLeave);
@@ -144,7 +151,7 @@ var UCarousel = class UCarousel extends UElement {
144
151
  }
145
152
  willUpdate(changedProperties) {
146
153
  super.willUpdate(changedProperties);
147
- if (changedProperties.has("autoplay") && this.autoplay) this.rotationStopped = false;
154
+ if (changedProperties.has("autoplay") && this.autoplay) this.rotationStopped = !!this.reducedMotion?.matches;
148
155
  if (changedProperties.has("slidesPerView")) this.style.setProperty("--slides-per-view", String(this.perView));
149
156
  if (changedProperties.has("gap")) this.style.setProperty("--slide-gap", `${this.gap}px`);
150
157
  }
@@ -2,8 +2,10 @@ 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';
5
6
  import { UPopover } from '../popover/UPopover.js';
6
7
  export type DatePickerMode = 'date' | 'datetime';
8
+ export type { DateDisabledFn } from '../calendar/dates.js';
7
9
  /**
8
10
  * A single-date(-time)-selection form control. In `mode="date"` (default) the value follows
9
11
  * the same convention as the native `input[type=date]`: an ISO `YYYY-MM-DD` string. The field is a
@@ -51,7 +53,8 @@ export type DatePickerMode = 'date' | 'datetime';
51
53
  * @cssprop --date-picker-popover-width - width of the calendar popover (default: 296px, independent of trigger width — a fixed-width calendar reads more naturally)
52
54
  *
53
55
  * @event change - fires when the user clicks a date cell, confirms via keyboard, changes the
54
- * time input (datetime mode, once a date is set), or clicks the clear button. Programmatic
56
+ * time input (datetime mode, once a date is set), or clicks the clear button — with `confirm`,
57
+ * calendar picks fire it only when Apply commits a different value. Programmatic
55
58
  * value assignment does not fire it (same contract as native form controls).
56
59
  */
57
60
  export declare class UDatePicker extends UFormControlElement<string> {
@@ -59,6 +62,10 @@ export declare class UDatePicker extends UFormControlElement<string> {
59
62
  /** `date` (default) selects a calendar day only. `datetime` also captures a time-of-day and
60
63
  * the value becomes a complete ISO-8601 `DateTimeOffset` string. */
61
64
  mode: DatePickerMode;
65
+ /** `mode="datetime"`: the time is entered to the second — the time input shows seconds and the
66
+ * text box reads and shows `HH:mm:ss`. Without it the time is to the minute (the value always
67
+ * carries seconds either way). */
68
+ seconds: boolean;
62
69
  /** Minimum value (ISO YYYY-MM-DD) — dates before this cannot be selected. Date-only even in
63
70
  * `mode="datetime"`; time-of-day is never range-checked. */
64
71
  min?: string;
@@ -67,6 +74,10 @@ export declare class UDatePicker extends UFormControlElement<string> {
67
74
  max?: string;
68
75
  /** Whether to show the clear button */
69
76
  clearable: boolean;
77
+ /** App rule for days that cannot be chosen — receives the ISO day, returns `true` to disable it
78
+ * (weekends, holidays, fully booked days). Such days cannot be picked in the calendar ("Today" too);
79
+ * a typed or assigned value on one reports `stepMismatch`. Property only. */
80
+ isDateDisabled?: DateDisabledFn;
70
81
  /** Placeholder text (shown when there is no value). Defaults to the pattern to type
71
82
  * (`YYYY-MM-DD`, or `YYYY-MM-DD HH:mm` in `mode="datetime"`). */
72
83
  placeholder?: string;
@@ -75,6 +86,11 @@ export declare class UDatePicker extends UFormControlElement<string> {
75
86
  * `20261002` are read in both. The time, in `mode="datetime"`, is always `HH:mm`. The value is
76
87
  * ISO either way. */
77
88
  format: DateTextFormat;
89
+ /** Picks in the calendar wait for an Apply button instead of committing at once. Choosing a day,
90
+ * the time, "today" or "clear" inside the calendar only stages the choice; Apply commits it, fires
91
+ * `change` and closes; Cancel, Escape or closing the calendar any other way drops it. Typing in
92
+ * the text box still commits on Enter or leaving the field. */
93
+ confirm: boolean;
78
94
  containerEl?: HTMLElement;
79
95
  popoverEl?: UPopover;
80
96
  calendarEl?: UCalendar;
@@ -84,15 +100,23 @@ export declare class UDatePicker extends UFormControlElement<string> {
84
100
  /** Time-of-day for the next selection while no `value` exists yet (`mode="datetime"` only) —
85
101
  * once `value` is set, the time input reads/writes its time portion directly instead. */
86
102
  private pendingTime;
103
+ /** With `confirm`, the choice made in the open calendar that Apply would commit. */
104
+ private staged?;
87
105
  /** The typed-date text box — what is being typed, committing it, opening the calendar. */
88
106
  private readonly textEntry;
107
+ protected shouldValidate(changed: PropertyValues): boolean;
108
+ protected willUpdate(changed: PropertyValues): void;
89
109
  protected updated(changed: PropertyValues): void;
110
+ /** What the open calendar shows and edits: the staged choice with `confirm`, otherwise the value. */
111
+ private get working();
90
112
  /** The value as the text box shows it: `YYYY-MM-DD`, or `YYYY-MM-DD HH:mm` in `mode="datetime"`. */
91
113
  private shownText;
92
114
  render(): import('lit-html').TemplateResult<1>;
93
115
  private renderCalendar;
94
116
  private renderTimeRow;
95
117
  private renderFooter;
118
+ /** A day the calendar refuses — outside `min`/`max` or disabled by `isDateDisabled`. */
119
+ private unavailable;
96
120
  /** `timeOverride` lets a caller force the time-of-day (the "today" quick action wants
97
121
  * "right now", overriding whatever time was previously set) — a plain day-cell click omits
98
122
  * it, which preserves the existing time-of-day (or `pendingTime`) so switching the date
@@ -123,6 +147,10 @@ export declare class UDatePicker extends UFormControlElement<string> {
123
147
  /** 캘린더 팝오버 안 "초기화" 퀵액션 — 트리거의 clear 아이콘(`handleClearClick`)과 값을
124
148
  * 비우는 로직은 같지만, 팝오버가 열린 채로 눌렸으므로 선택 완료와 동일하게 닫아 준다. */
125
149
  private handleFooterResetClick;
150
+ /** `confirm` 모드의 «적용» — 달력에서 고른 것을 값으로 확정한다(비운 채면 값을 비운다). */
151
+ private handleApplyClick;
152
+ /** `confirm` 모드의 «취소» — 고른 것은 다음에 열 때 값에서 다시 시작하므로 닫기만 하면 버려진다. */
153
+ private handleCancelClick;
126
154
  private resetValue;
127
155
  /** suffix `u-icon`은 순수 표시 요소(버튼 아님)라 네이티브 키보드 활성화가 없다 —
128
156
  * `role="button"`+`tabindex="0"`로 포커스 가능하게 한 뒤, Enter/Space를 같은 클릭
@@ -5,48 +5,43 @@ 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
12
  import { DateTextController } from "../calendar/date-text-controller.js";
13
+ import { normalizeTime, splitDateTime, toDateTimeOffset } from "../calendar/datetime.js";
13
14
  import { styles } from "../calendar/picker.styles.js";
14
15
  import { styles as styles$1 } from "./UDatePicker.styles.js";
15
16
  import { html } from "lit";
16
17
  import { customElement, property, query, state } from "lit/decorators.js";
17
18
  import { ifDefined } from "lit/directives/if-defined.js";
18
19
  //#region src/components/date-picker/UDatePicker.ts
19
- /** `±HH:mm` for the browser's local timezone at `date` (DST-aware — recomputed per date,
20
- * not cached — `getTimezoneOffset()`'s sign is the inverse of the ISO-8601 offset sign). */
21
- function getLocalOffset(date) {
22
- const minutes = -date.getTimezoneOffset();
23
- const sign = minutes >= 0 ? "+" : "-";
24
- const abs = Math.abs(minutes);
25
- return `${sign}${String(Math.floor(abs / 60)).padStart(2, "0")}:${String(abs % 60).padStart(2, "0")}`;
26
- }
27
20
  /** Builds the `value` for the given mode — `datetime` always emits seconds + local offset so
28
21
  * the result is unconditionally a valid, unambiguous ISO-8601 `DateTimeOffset` regardless of
29
22
  * how coarse the UI input was (this is the guarantee the datetime mode request asked for). */
30
23
  function buildValue(date, mode, time) {
31
- return mode === "datetime" ? `${toISODate(date)}T${time}:00${getLocalOffset(date)}` : toISODate(date);
24
+ return mode === "datetime" ? toDateTimeOffset(toISODate(date), time) : toISODate(date);
32
25
  }
33
- /** Splits a `value` into its date portion (as a `Date`, via the local `parseISODate` above —
34
- * date-only, no timezone conversion) and its `HH:mm` time-of-day (`'00:00'` if absent —
35
- * 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. */
36
30
  function splitValue(value) {
37
- const [datePart, rest] = value.split("T");
38
- const match = rest?.match(/^(\d{2}:\d{2})/);
31
+ const { day, time } = splitDateTime(value, true);
39
32
  return {
40
- date: parseISODate(datePart),
41
- time: match ? match[1] : "00:00"
33
+ date: parseISODate(day),
34
+ time
42
35
  };
43
36
  }
44
37
  var UDatePicker = class UDatePicker extends UFormControlElement {
45
38
  constructor(..._args) {
46
39
  super(..._args);
47
40
  this.mode = "date";
41
+ this.seconds = false;
48
42
  this.clearable = false;
49
43
  this.format = "iso";
44
+ this.confirm = false;
50
45
  this.calendarId = `u-date-picker-calendar-${Math.random().toString(36).slice(2, 8)}`;
51
46
  this.open = false;
52
47
  this.pendingTime = "00:00";
@@ -71,8 +66,12 @@ var UDatePicker = class UDatePicker extends UFormControlElement {
71
66
  interactive: () => !this.effectivelyDisabled && !this.readonly
72
67
  });
73
68
  this.handleTimeChange = (e) => {
74
- const time = e.target.value || "00:00";
69
+ const time = normalizeTime(e.target.value || "00:00", this.seconds);
75
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
+ }
76
75
  if (!this.value) return;
77
76
  const iso = buildValue(splitValue(this.value).date, this.mode, time);
78
77
  const changed = iso !== this.value;
@@ -103,14 +102,32 @@ var UDatePicker = class UDatePicker extends UFormControlElement {
103
102
  };
104
103
  this.handleTodayClick = () => {
105
104
  const now = /* @__PURE__ */ new Date();
106
- 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;
107
107
  this.selectDay(now, time);
108
108
  };
109
109
  this.handleFooterResetClick = () => {
110
+ if (this.confirm) {
111
+ this.staged = void 0;
112
+ return;
113
+ }
110
114
  this.resetValue();
111
115
  this.popoverEl?.hide();
112
116
  (this.textInputEl ?? this.containerEl)?.focus();
113
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
+ };
114
131
  this.handleClearKeydown = (e) => {
115
132
  if (e.key !== "Enter" && e.key !== " ") return;
116
133
  e.preventDefault();
@@ -124,17 +141,28 @@ var UDatePicker = class UDatePicker extends UFormControlElement {
124
141
  styles$1
125
142
  ];
126
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
+ }
127
151
  updated(changed) {
128
152
  super.updated(changed);
129
153
  if (changed.has("value")) this.internals?.setFormValue(this.value ?? "");
130
154
  if (changed.has("open")) this.internals?.states[this.open ? "add" : "delete"]("open");
131
155
  if (changed.has("open") && this.open) this.textEntry.calendarOpened(this.value ? toISODate(splitValue(this.value).date) : /* @__PURE__ */ new Date());
132
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
+ }
133
161
  /** The value as the text box shows it: `YYYY-MM-DD`, or `YYYY-MM-DD HH:mm` in `mode="datetime"`. */
134
162
  shownText() {
135
163
  if (!this.value) return "";
136
164
  const { date, time } = splitValue(this.value);
137
- return this.mode === "datetime" ? formatDateTimeText(`${toISODate(date)}T${time}`, this.format) : formatDateText(toISODate(date), this.format);
165
+ return this.mode === "datetime" ? formatDateTimeText(`${toISODate(date)}T${time}`, this.format, void 0, this.seconds) : formatDateText(toISODate(date), this.format);
138
166
  }
139
167
  render() {
140
168
  const datetime = this.mode === "datetime";
@@ -159,7 +187,7 @@ var UDatePicker = class UDatePicker extends UFormControlElement {
159
187
  aria-label=${ifDefined(this.resolvedAriaLabel)}
160
188
  aria-description=${ifDefined(this.resolvedAriaDescription)}
161
189
  aria-invalid=${this.textEntry.badText ? "true" : "false"}
162
- placeholder=${this.placeholder ?? (datetime ? `${dateTextPattern(this.format)} HH:mm` : dateTextPattern(this.format))}
190
+ placeholder=${this.placeholder ?? (datetime ? `${dateTextPattern(this.format)} ${this.seconds ? "HH:mm:ss" : "HH:mm"}` : dateTextPattern(this.format))}
163
191
  .value=${this.textEntry.text}
164
192
  ?disabled=${this.effectivelyDisabled}
165
193
  ?readonly=${this.readonly}
@@ -210,9 +238,10 @@ var UDatePicker = class UDatePicker extends UFormControlElement {
210
238
  <div class="calendar" part="calendar">
211
239
  <u-calendar
212
240
  exportparts="calendar-header, calendar-title, calendar-weekdays, calendar-grid, calendar-week, day"
213
- .value=${this.value ? toISODate(splitValue(this.value).date) : void 0}
241
+ .value=${this.working ? toISODate(splitValue(this.working).date) : void 0}
214
242
  .min=${this.min}
215
243
  .max=${this.max}
244
+ .isDateDisabled=${this.isDateDisabled}
216
245
  @day-select=${this.handleDaySelect}
217
246
  @keydown=${this.handleCalendarKeydown}
218
247
  ></u-calendar>
@@ -223,40 +252,55 @@ var UDatePicker = class UDatePicker extends UFormControlElement {
223
252
  }
224
253
  renderTimeRow() {
225
254
  if (this.mode !== "datetime") return "";
226
- const time = this.value ? splitValue(this.value).time : this.pendingTime;
255
+ const time = this.working ? splitValue(this.working).time : this.pendingTime;
227
256
  return html`
228
257
  <div class="calendar-time" part="calendar-time">
229
258
  <input type="time" class="time-input" part="time-input"
230
259
  aria-label=${Locale.getValue("time")}
231
- .value=${time}
260
+ step=${ifDefined(this.seconds ? "1" : void 0)}
261
+ .value=${normalizeTime(time, this.seconds)}
232
262
  @change=${this.handleTimeChange}
233
263
  />
234
264
  </div>
235
265
  `;
236
266
  }
237
267
  renderFooter() {
238
- const todayDisabled = isOutOfRange(/* @__PURE__ */ new Date(), this.min, this.max);
268
+ const todayDisabled = this.unavailable(/* @__PURE__ */ new Date());
239
269
  return html`
240
270
  <div class="calendar-footer" part="calendar-footer">
241
271
  <u-button variant="ghost" size="sm" ?disabled=${todayDisabled} @click=${this.handleTodayClick}>${Locale.getValue("today")}</u-button>
242
- ${this.clearable && this.value ? html`
272
+ ${this.clearable && this.working ? html`
243
273
  <u-button variant="ghost" size="sm" @click=${this.handleFooterResetClick}>${Locale.getValue("clear")}</u-button>
244
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
+ ` : ""}
245
281
  </div>
246
282
  `;
247
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
+ }
248
288
  /** `timeOverride` lets a caller force the time-of-day (the "today" quick action wants
249
289
  * "right now", overriding whatever time was previously set) — a plain day-cell click omits
250
290
  * it, which preserves the existing time-of-day (or `pendingTime`) so switching the date
251
291
  * alone doesn't clobber a time the user already picked. */
252
292
  selectDay(date, timeOverride) {
253
- if (isOutOfRange(date, this.min, this.max)) return;
254
- 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);
255
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
+ }
256
301
  const changed = iso !== this.value;
257
302
  this.textEntry.clear();
258
303
  this.value = iso;
259
- if (this.mode === "datetime") this.pendingTime = time;
260
304
  if (changed) this.emitChange();
261
305
  this.popoverEl?.hide();
262
306
  (this.textInputEl ?? this.containerEl)?.focus();
@@ -277,11 +321,12 @@ var UDatePicker = class UDatePicker extends UFormControlElement {
277
321
  const keep = this.value ? splitValue(this.value).time : this.pendingTime;
278
322
  const dt = parseDateTime(text, {
279
323
  format: this.format,
280
- defaultTime: keep
324
+ defaultTime: keep,
325
+ seconds: this.seconds
281
326
  });
282
327
  return dt ? {
283
328
  date: dt.slice(0, 10),
284
- time: dt.slice(11, 16)
329
+ time: dt.slice(11)
285
330
  } : null;
286
331
  }
287
332
  resetValue() {
@@ -312,6 +357,9 @@ var UDatePicker = class UDatePicker extends UFormControlElement {
312
357
  } else if (this.value && this.max && splitValue(this.value).date.getTime() > parseISODate(this.max).getTime()) {
313
358
  flags = { rangeOverflow: true };
314
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");
315
363
  }
316
364
  this.commit(flags, message, this.textInputEl ?? this.containerEl ?? void 0);
317
365
  }
@@ -335,22 +383,32 @@ __decorate([property({
335
383
  type: String,
336
384
  reflect: true
337
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);
338
390
  __decorate([property({ type: String }), __decorateMetadata("design:type", String)], UDatePicker.prototype, "min", void 0);
339
391
  __decorate([property({ type: String }), __decorateMetadata("design:type", String)], UDatePicker.prototype, "max", void 0);
340
392
  __decorate([property({
341
393
  type: Boolean,
342
394
  reflect: true
343
395
  }), __decorateMetadata("design:type", Boolean)], UDatePicker.prototype, "clearable", void 0);
396
+ __decorate([property({ attribute: false }), __decorateMetadata("design:type", Object)], UDatePicker.prototype, "isDateDisabled", void 0);
344
397
  __decorate([property({ type: String }), __decorateMetadata("design:type", String)], UDatePicker.prototype, "placeholder", void 0);
345
398
  __decorate([property({
346
399
  type: String,
347
400
  reflect: true
348
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);
349
406
  __decorate([query(".container", true), __decorateMetadata("design:type", typeof HTMLElement === "undefined" ? Object : HTMLElement)], UDatePicker.prototype, "containerEl", void 0);
350
407
  __decorate([query("u-popover", true), __decorateMetadata("design:type", typeof UPopover === "undefined" ? Object : UPopover)], UDatePicker.prototype, "popoverEl", void 0);
351
408
  __decorate([query("u-calendar"), __decorateMetadata("design:type", typeof UCalendar === "undefined" ? Object : UCalendar)], UDatePicker.prototype, "calendarEl", void 0);
352
409
  __decorate([state(), __decorateMetadata("design:type", Boolean)], UDatePicker.prototype, "open", void 0);
353
410
  __decorate([state(), __decorateMetadata("design:type", String)], UDatePicker.prototype, "pendingTime", void 0);
411
+ __decorate([state(), __decorateMetadata("design:type", String)], UDatePicker.prototype, "staged", void 0);
354
412
  UDatePicker = __decorate([customElement("u-date-picker")], UDatePicker);
355
413
  //#endregion
356
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,29 +95,71 @@ 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;
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();
91
128
  /** The typed-range text box — what is being typed, committing it, opening the calendar. */
92
129
  private readonly textEntry;
93
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;
94
140
  protected shouldValidate(changed: PropertyValues): boolean;
95
141
  protected updated(changed: PropertyValues): void;
96
142
  render(): import('lit-html').TemplateResult<1>;
97
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;
98
149
  private renderPresets;
99
- /** A preset that reaches outside `min`/`max` is not offered — its label would promise more
100
- * than the picker may hold. */
101
- 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;
102
155
  private handleRangeSelect;
103
- /** 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. */
104
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;
105
163
  private get textInputEl();
106
164
  /** Escape that reaches the picker closes the calendar — the calendar keeps the first Escape
107
165
  * for itself while a range is half picked. */
@@ -110,6 +168,10 @@ export declare class UDateRangePicker extends UFormControlElement<string> {
110
168
  private handlePopoverHide;
111
169
  private handleClearClick;
112
170
  private handleFooterResetClick;
171
+ /** `confirm` 모드의 «적용» — 달력에서 고른 범위를 값으로 확정한다(비운 채면 값을 비운다). */
172
+ private handleApplyClick;
173
+ /** `confirm` 모드의 «취소» — 고른 것은 다음에 열 때 값에서 다시 시작하므로 닫기만 하면 버려진다. */
174
+ private handleCancelClick;
113
175
  private resetValue;
114
176
  /** The clear icon is a display element — relay Enter/Space to its click handler
115
177
  * (same pattern as `u-date-picker`, `u-input`, `u-select`). */