@golemui/gui-lit 1.0.2 → 1.1.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 (70) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/calendar-BuJgwvZx.js +254 -0
  3. package/{calendar.element-MubSE1bx.js → calendar.element-M5MPJmap.js} +1 -1
  4. package/{currency.element-BHXWcOEu.js → currency.element-CfFrAtrr.js} +20 -14
  5. package/{date-DTYg8sog.js → date-Bj9mI3GU.js} +106 -50
  6. package/date-input-cJDkNnVw.js +184 -0
  7. package/date-picker.element-va_-LGZD.js +312 -0
  8. package/date-time-calendar-BzRfkLKU.js +361 -0
  9. package/date-time-calendar.element-DC4NK0y1.js +93 -0
  10. package/date-time-input-BXxsfuyZ.js +214 -0
  11. package/date-time-picker.element-Dy-8cb-_.js +380 -0
  12. package/date-time.element-Bv4XdzMi.js +87 -0
  13. package/{date.element-BtVJSIRk.js → date.element-Consgsbb.js} +32 -27
  14. package/day-status-0-hJHrI7.js +530 -0
  15. package/{dropdown.element-DqzC6aXR.js → dropdown.element-WsD61Qel.js} +57 -48
  16. package/focus-leave.controller-2gV0pQd5.js +73 -0
  17. package/index.js +1209 -981
  18. package/index.umd.cjs +1574 -519
  19. package/lib/components/date-picker.element.d.ts +0 -11
  20. package/lib/components/date-time-calendar.element.d.ts +18 -0
  21. package/lib/components/date-time-picker.element.d.ts +18 -0
  22. package/lib/components/date-time.element.d.ts +18 -0
  23. package/lib/components/dropdown.element.d.ts +2 -0
  24. package/lib/components/range-calendar.element.d.ts +2 -1
  25. package/lib/components/range-date-picker.element.d.ts +0 -15
  26. package/lib/components/range-date-time-calendar.element.d.ts +18 -0
  27. package/lib/components/range-date-time-input.element.d.ts +18 -0
  28. package/lib/components/range-date-time-picker.element.d.ts +18 -0
  29. package/lib/components/range-time-input.element.d.ts +18 -0
  30. package/lib/components/range-time-picker.element.d.ts +18 -0
  31. package/lib/components/time-picker.element.d.ts +18 -0
  32. package/lib/components/time.element.d.ts +18 -0
  33. package/{list-D1oKnH89.js → list-CrLIL4by.js} +76 -61
  34. package/{list.element-Co3V3Cn5.js → list.element-DV82YxnJ.js} +22 -22
  35. package/{number.element-BhEyoOtc.js → number.element-CBr47IiY.js} +18 -16
  36. package/numeric-jmOOKz30.js +12 -0
  37. package/package.json +6 -6
  38. package/part-templates-Db871PS3.js +677 -0
  39. package/pill-ranges-DCqDmpkk.js +48 -0
  40. package/{pills-B66qz_KX.js → pills-Be1UrLgq.js} +4 -1
  41. package/popup.controller-eUDxE6jD.js +71 -0
  42. package/range-calendar-CKPYeSGt.js +452 -0
  43. package/{range-calendar.element-QTE6vGNP.js → range-calendar.element-D6KYq18B.js} +24 -20
  44. package/range-commit-8-MmYUyo.js +14 -0
  45. package/range-date-input-D--AqBMv.js +292 -0
  46. package/{range-date-input.element-Dj29D_OQ.js → range-date-input.element-D4nIXJbw.js} +8 -7
  47. package/range-date-picker.element-dhxPAAE6.js +386 -0
  48. package/range-date-time-calendar-yksWrR7b.js +720 -0
  49. package/range-date-time-calendar.element-C00aDefZ.js +95 -0
  50. package/range-date-time-input-B37TUoM3.js +322 -0
  51. package/range-date-time-input.element-DUnbv4ed.js +81 -0
  52. package/range-date-time-picker.element-Cbps6s_G.js +412 -0
  53. package/range-selection-CU3hxLJE.js +25 -0
  54. package/range-time-input-3lhqR1Ku.js +329 -0
  55. package/range-time-input.element-dU2iBdmJ.js +81 -0
  56. package/range-time-picker.element-v6nQsIPw.js +429 -0
  57. package/{select.element-jcDF1h-g.js → select.element-C0V-Bv3L.js} +94 -90
  58. package/{tags.element-CX3vQL8L.js → tags.element-DvwEpxpK.js} +1 -1
  59. package/time-input-BOhlBGJZ.js +181 -0
  60. package/time-list-Czo48bZm.js +217 -0
  61. package/time-picker-bFJ63ky8.js +261 -0
  62. package/time-picker.element-CYZVXgRS.js +85 -0
  63. package/time.element-fK3oLi49.js +82 -0
  64. package/abstract-calendar-BoqKPRmS.js +0 -545
  65. package/calendar-DTYKVYc3.js +0 -96
  66. package/date-input-BeQvyfln.js +0 -268
  67. package/date-picker.element-DabW_-0-.js +0 -166
  68. package/range-calendar-9skwbwlB.js +0 -255
  69. package/range-date-input-Uy8134vi.js +0 -395
  70. package/range-date-picker.element-CuKIBkIO.js +0 -182
@@ -0,0 +1,720 @@
1
+ import { LitElement as f, nothing as l, html as h } from "lit";
2
+ import { property as r, state as g, customElement as S } from "lit/decorators.js";
3
+ import { classMap as c } from "lit/directives/class-map.js";
4
+ import { G as k } from "./templates-Dk1jxLwS.js";
5
+ import { G as w, a as R, r as $, b as I, c as M, d as E, e as C } from "./day-status-0-hJHrI7.js";
6
+ import { G as L } from "./focus-leave.controller-2gV0pQd5.js";
7
+ import "./pills-Be1UrLgq.js";
8
+ import "./time-picker-bFJ63ky8.js";
9
+ import { p, t as m, i as O, D as v } from "./date-Bj9mI3GU.js";
10
+ import { r as x, f as A, b as P, s as B } from "./pill-ranges-DCqDmpkk.js";
11
+ import { i as F, s as N, r as y } from "./range-selection-CU3hxLJE.js";
12
+ import { p as G, e as D, f as _, i as Y, o as q, c as U, m as H, d as K, h as j, j as b, k as V, l as T } from "./part-templates-Db871PS3.js";
13
+ var W = Object.defineProperty, z = Object.getOwnPropertyDescriptor, n = (e, t, a, i) => {
14
+ for (var o = i > 1 ? void 0 : i ? z(t, a) : t, d = e.length - 1, u; d >= 0; d--)
15
+ (u = e[d]) && (o = (i ? u(t, a, o) : u(o)) || o);
16
+ return i && o && W(t, a, o), o;
17
+ };
18
+ let s = class extends f {
19
+ constructor() {
20
+ super(...arguments), this.uid = void 0, this.label = void 0, this.hint = void 0, this.localeId = void 0, this.errors = [], this.touched = void 0, this.required = !1, this.disabled = !1, this.readOnly = !1, this.prevMonthIcon = "", this.nextMonthIcon = "", this.prevMonthAriaLabel = "", this.nextMonthAriaLabel = "", this.dayFormat = "numeric", this.weekdayFormat = "narrow", this.monthFormat = "long", this.minDate = void 0, this.maxDate = void 0, this.disabledRanges = void 0, this.numberOfMonths = 1, this.value = [], this.focusDate = void 0, this.hidePills = !1, this.removePillAriaLabel = void 0, this.disabledDateRangeMessage = void 0, this.invalidRange = null, this.hourFormat = void 0, this.minuteStep = void 0, this.allowCustomTime = !1, this.startTimeLabel = void 0, this.endTimeLabel = void 0, this.minDateTime = void 0, this.maxDateTime = void 0, this.minDateTimeMessage = void 0, this.maxDateTimeMessage = void 0, this.disabledRangeMessage = void 0, this.noAvailableTimesMessage = void 0, this.dayCountAriaLabel = void 0, this.disabledDayCountAriaLabel = void 0, this._selection = F(), this._invalidRange = null, this._workingDateStart = void 0, this._workingDateEnd = void 0, this._workingTimeIn = void 0, this._workingTimeOut = void 0, this._openList = null, this._skipValueNavigation = !1, this._nav = new w(this, {
21
+ getMinDate: () => this.minDate,
22
+ getMaxDate: () => this.maxDate,
23
+ getNumberOfMonths: () => this.numberOfMonths,
24
+ getDisabledRanges: () => this.disabledRanges,
25
+ onYearSelectorToggled: () => this._keyboard.onYearGridToggled()
26
+ }), this.ariaController = new k(this, {
27
+ getTargets: () => this.querySelectorAll(".gui-calendar-input"),
28
+ getState: () => ({
29
+ uid: this.uid,
30
+ templateData: {
31
+ hint: this.hint,
32
+ errors: this.errors,
33
+ readonly: this.readOnly,
34
+ disabled: this.disabled,
35
+ touched: this.touched
36
+ }
37
+ })
38
+ }), this._keyboard = new R(this, {
39
+ canGoPrev: () => this._nav.canGoPrev(),
40
+ canGoNext: () => this._nav.canGoNext(),
41
+ goPrev: () => this._nav.prevMonth(),
42
+ goNext: () => this._nav.nextMonth(),
43
+ onActivateDay: (e, t) => this.selectDate(this.activationDay(e), t),
44
+ onSelectYear: (e) => this._nav.selectYear(e),
45
+ onCloseYearGrid: () => this._nav.closeYearSelector(),
46
+ isYearGridOpen: () => this._nav.yearSelectorOpen
47
+ }), this._focusLeave = new L(this, {
48
+ onLeave: () => this.dispatchEvent(new CustomEvent("blur", { bubbles: !0, composed: !0 }))
49
+ }), this.onPillRemoveEvent = (e) => {
50
+ if (this.disabled || this.readOnly) return;
51
+ const t = x(this.value, e.detail.key);
52
+ t && (this.value = t.next, this.dispatchEvent(
53
+ new CustomEvent("change", {
54
+ detail: { value: this.value },
55
+ bubbles: !0,
56
+ composed: !0
57
+ })
58
+ ));
59
+ }, this.onPillClickEvent = (e) => {
60
+ const t = A(this.getSortedPills(), e.detail.key);
61
+ t && this.navigateToDate(t.start);
62
+ };
63
+ }
64
+ /** The nav controller's month cursor, kept under its historical name. */
65
+ get _currentDate() {
66
+ return this._nav.currentDate;
67
+ }
68
+ set _currentDate(e) {
69
+ this._nav.currentDate = e;
70
+ }
71
+ /** The nav controller's year-grid flag; the time pickers close over it. */
72
+ get _yearSelectorOpen() {
73
+ return this._nav.yearSelectorOpen;
74
+ }
75
+ set _yearSelectorOpen(e) {
76
+ this._nav.yearSelectorOpen = e;
77
+ }
78
+ /**
79
+ * Full instant of an endpoint, used to order the pills — endpoints carry a
80
+ * time, so two ranges on the same day still sort by time.
81
+ */
82
+ parseEndpoint(e) {
83
+ return G(e);
84
+ }
85
+ /**
86
+ * Midnight-truncated calendar day of an endpoint, used to highlight the day
87
+ * grid.
88
+ */
89
+ endpointDay(e) {
90
+ return p(e.split("T")[0]);
91
+ }
92
+ /** Pill text for one committed range. */
93
+ formatPillLabel(e) {
94
+ const t = D(this.localeId, this.hourFormat), a = _(e.start, this.localeId, t), i = e.end ? _(e.end, this.localeId, t) : a;
95
+ return `${a} - ${i}`;
96
+ }
97
+ /** Highlights the parked working date range like a committed one. */
98
+ get workingRange() {
99
+ if (!(!this._workingDateStart || !this._workingDateEnd))
100
+ return {
101
+ start: p(this._workingDateStart),
102
+ end: p(this._workingDateEnd)
103
+ };
104
+ }
105
+ createRenderRoot() {
106
+ return this;
107
+ }
108
+ connectedCallback() {
109
+ super.connectedCallback(), this.classList.add("gui-field");
110
+ }
111
+ willUpdate(e) {
112
+ if ((!this.hasUpdated || e.has("minDateTime") || e.has("maxDateTime")) && (this.minDate = this.minDateTime ? this.minDateTime.split("T")[0] : void 0, this.maxDate = this.maxDateTime ? this.maxDateTime.split("T")[0] : void 0), e.has("invalidRange"))
113
+ if (this.invalidRange) {
114
+ const t = this.endpointDay(this.invalidRange.start), a = this.endpointDay(this.invalidRange.end);
115
+ this._invalidRange = isNaN(t.getTime()) || isNaN(a.getTime()) ? null : { start: t, end: a };
116
+ } else
117
+ this._invalidRange = null;
118
+ if (e.has("value") && !e.has("focusDate")) {
119
+ if (this._skipValueNavigation)
120
+ this._skipValueNavigation = !1;
121
+ else if (this.value) {
122
+ const t = Array.isArray(this.value) ? this.value : [{ start: this.value }];
123
+ t.length > 0 && t[0].start && this._nav.navigateToDate(this.endpointDay(t[0].start));
124
+ }
125
+ }
126
+ if (e.has("focusDate") && this.focusDate) {
127
+ const t = p(this.focusDate);
128
+ isNaN(t.getTime()) || (this._nav.navigateToDate(t), this.focusDate = void 0);
129
+ }
130
+ }
131
+ render() {
132
+ return $({
133
+ uid: this.uid,
134
+ label: this.label,
135
+ hint: this.hint,
136
+ errors: this.errors,
137
+ touched: this.touched,
138
+ required: this.required,
139
+ disabled: this.disabled,
140
+ numberOfMonths: this.numberOfMonths,
141
+ prevMonthIcon: this.prevMonthIcon,
142
+ nextMonthIcon: this.nextMonthIcon,
143
+ prevMonthAriaLabel: this.prevMonthAriaLabel,
144
+ nextMonthAriaLabel: this.nextMonthAriaLabel,
145
+ canGoPrev: this._nav.canGoPrev(),
146
+ canGoNext: this._nav.canGoNext(),
147
+ onPrevMonthClick: this._keyboard.onPrevMonthClick,
148
+ onNextMonthClick: this._keyboard.onNextMonthClick,
149
+ onFocusOut: this._focusLeave.onFocusOut,
150
+ renderAboveCalendar: () => this.renderAboveCalendar(),
151
+ renderMonthPanel: (e) => I({
152
+ currentDate: this._nav.currentDate,
153
+ offset: e,
154
+ localeId: this.localeId,
155
+ monthFormat: this.monthFormat,
156
+ yearSelectorOpen: this._nav.yearSelectorOpen,
157
+ onToggleYearSelector: () => this.toggleYearSelector(),
158
+ renderBelowHeader: (t) => this.renderBelowHeader(t),
159
+ renderPanelBody: (t) => this.renderPanelBody(t)
160
+ })
161
+ });
162
+ }
163
+ renderBelowHeader(e) {
164
+ if (e !== 0) return l;
165
+ const t = !this.disabled && !!this._workingDateStart, a = !this.disabled && !!this._workingTimeIn, i = this.startListBounds, o = this.endListBounds, d = {
166
+ "gui-range-date-time-calendar__time-row": !0,
167
+ "is-list-open": this._openList !== null
168
+ };
169
+ return h`
170
+ <div class=${c(d)}>
171
+ <div
172
+ class=${c({
173
+ "gui-range-date-time-calendar__time-column": !0,
174
+ "is-open": this._openList === "start"
175
+ })}
176
+ >
177
+ <gui-time-picker
178
+ class="gui-time-picker gui-field gui-range-date-time-calendar__start"
179
+ .uid=${this.uid ? `${this.uid}-start-time` : void 0}
180
+ .label=${this.startTimeLabel ?? "Start time"}
181
+ .showErrors=${!1}
182
+ ?required=${this.required}
183
+ ?disabled=${!t}
184
+ ?readonly=${this.readOnly}
185
+ .allowCustomTime=${this.allowCustomTime}
186
+ .value=${this._workingTimeIn}
187
+ .localeId=${this.localeId}
188
+ .hourFormat=${this.hourFormat}
189
+ .minuteStep=${this.minuteStep}
190
+ .minTime=${i.minTime}
191
+ .maxTime=${i.maxTime}
192
+ .disabledRanges=${this.resolvedStartTimeRanges}
193
+ .columns=${4}
194
+ .disabledRangeMessage=${this.disabledRangeMessage}
195
+ .noAvailableTimesMessage=${this.noAvailableTimesMessage}
196
+ @change=${this.onStartTimeChange}
197
+ @listtoggle=${(u) => this.onListToggle(u, "start")}
198
+ ></gui-time-picker>
199
+ </div>
200
+
201
+ <div
202
+ class=${c({
203
+ "gui-range-date-time-calendar__time-column": !0,
204
+ "is-open": this._openList === "end"
205
+ })}
206
+ >
207
+ <gui-time-picker
208
+ class="gui-time-picker gui-field gui-range-date-time-calendar__end"
209
+ .uid=${this.uid ? `${this.uid}-end-time` : void 0}
210
+ .label=${this.endTimeLabel ?? "End time"}
211
+ .showErrors=${!1}
212
+ ?required=${this.required}
213
+ ?disabled=${!a}
214
+ ?readonly=${this.readOnly}
215
+ .allowCustomTime=${this.allowCustomTime}
216
+ .value=${this._workingTimeOut}
217
+ .localeId=${this.localeId}
218
+ .hourFormat=${this.hourFormat}
219
+ .minuteStep=${this.minuteStep}
220
+ .minTime=${o.minTime}
221
+ .maxTime=${o.maxTime}
222
+ .disabledRanges=${this.resolvedEndTimeRanges}
223
+ .columns=${4}
224
+ .disabledRangeMessage=${this.disabledRangeMessage}
225
+ .noAvailableTimesMessage=${this.noAvailableTimesMessage}
226
+ @change=${this.onEndTimeChange}
227
+ @listtoggle=${(u) => this.onListToggle(u, "end")}
228
+ ></gui-time-picker>
229
+ </div>
230
+ </div>
231
+ `;
232
+ }
233
+ renderPanelBody(e) {
234
+ return this._openList && !this._yearSelectorOpen && e === 0 ? h`` : M({
235
+ offset: e,
236
+ yearSelectorOpen: this._nav.yearSelectorOpen,
237
+ years: this._nav.yearList,
238
+ currentYear: this._nav.currentDate.getFullYear(),
239
+ onSelectYear: (t) => this._keyboard.selectYear(t),
240
+ onYearKeydown: this._keyboard.handleYearKeydown,
241
+ localeId: this.localeId,
242
+ getDays: (t) => this.getDaysInMonth(t),
243
+ renderDay: (t) => this.renderDay(t)
244
+ });
245
+ }
246
+ /** Closes the time pickers before delegating to the nav controller. */
247
+ toggleYearSelector() {
248
+ this.startPicker?.closeList(), this.endPicker?.closeList(), this._nav.toggleYearSelector();
249
+ }
250
+ /**
251
+ * A day is unclickable only when a span covers it entirely.
252
+ */
253
+ isDisabled(e) {
254
+ const t = m(e);
255
+ return O(t, this.minDate, this.maxDate) ? !0 : Y(t, this.disabledRanges);
256
+ }
257
+ /**
258
+ * Rebuilds the day context for an Enter/Space activation from the button's
259
+ * `data-date`. Legitimate because a day button can only be focused when it
260
+ * is enabled and in-month; the `disabled`/`readOnly` guards stay in
261
+ * `selectDate`.
262
+ */
263
+ activationDay(e) {
264
+ return {
265
+ date: p(e),
266
+ isCurrentMonth: !0,
267
+ isDisabled: !1,
268
+ isFocusable: !0,
269
+ dayLabel: "",
270
+ isToday: !1,
271
+ isRangeStart: !1,
272
+ isRangeEnd: !1,
273
+ isInRange: !1,
274
+ isOneDayRange: !1,
275
+ isAnchor: !1,
276
+ isSelecting: !1,
277
+ isInvalidStart: !1,
278
+ isInvalidEnd: !1,
279
+ isInvalidInRange: !1
280
+ };
281
+ }
282
+ renderDay(e) {
283
+ const t = e.isInvalidStart && e.isInvalidEnd, a = {
284
+ "gui-calendar__day-button": !0,
285
+ today: e.isToday,
286
+ "other-month": !e.isCurrentMonth,
287
+ "range-start": e.isRangeStart && !e.isOneDayRange,
288
+ "range-end": e.isRangeEnd && !e.isOneDayRange,
289
+ selected: e.isOneDayRange,
290
+ "in-range": e.isInRange,
291
+ "invalid-range-start": e.isInvalidStart && !t,
292
+ "invalid-range-end": e.isInvalidEnd && !t,
293
+ "invalid-range-single": t,
294
+ "invalid-in-range": e.isInvalidInRange,
295
+ "is-anchor": e.isAnchor,
296
+ "is-selecting": e.isSelecting,
297
+ disabled: e.isDisabled
298
+ };
299
+ return h`
300
+ <button
301
+ type="button"
302
+ role="gridcell"
303
+ class=${c(a)}
304
+ tabindex=${e.isFocusable ? 0 : -1}
305
+ ?disabled=${!e.isCurrentMonth || e.isDisabled}
306
+ data-date=${m(e.date)}
307
+ @click=${(i) => this.selectDate(e, i)}
308
+ @mouseover=${() => this.onMouseOver(e)}
309
+ @focus=${() => this.onMouseOver(e)}
310
+ @keydown=${(i) => this._keyboard.handleDayKeydown(i)}
311
+ aria-selected=${e.isRangeStart || e.isRangeEnd || e.isInRange ? "true" : "false"}
312
+ >
313
+ ${this.renderDayContent(e)}
314
+ </button>
315
+ `;
316
+ }
317
+ getDaysInMonth(e) {
318
+ const t = (this.value ?? []).map((i) => ({
319
+ start: this.endpointDay(i.start),
320
+ end: i.end ? this.endpointDay(i.end) : void 0
321
+ })), a = N(this._selection);
322
+ return E({
323
+ currentDate: this._currentDate,
324
+ offset: e,
325
+ localeId: this.localeId,
326
+ numberOfMonths: this.numberOfMonths ?? 1,
327
+ isDisabled: (i) => this.isDisabled(i),
328
+ toDay: (i) => {
329
+ const o = C(i.date, {
330
+ ranges: t,
331
+ workingRange: this.workingRange,
332
+ anchor: this._selection.anchor,
333
+ selectingSpan: a,
334
+ invalidRange: this._invalidRange
335
+ });
336
+ return {
337
+ date: i.date,
338
+ dayLabel: i.dayLabel,
339
+ isCurrentMonth: i.isCurrentMonth,
340
+ isToday: i.isToday,
341
+ isRangeStart: o.isRangeStart,
342
+ isRangeEnd: o.isRangeEnd,
343
+ isInRange: o.isInRange,
344
+ isInvalidStart: o.isInvalidStart && i.isCurrentMonth,
345
+ isInvalidEnd: o.isInvalidEnd && i.isCurrentMonth,
346
+ isInvalidInRange: o.isInvalidInRange && i.isCurrentMonth,
347
+ isDisabled: i.isDisabled,
348
+ isOneDayRange: o.isOneDayRange,
349
+ isAnchor: o.isAnchor,
350
+ isFocusable: i.isToday || o.isRangeStart,
351
+ isSelecting: o.isSelecting && i.isCurrentMonth
352
+ };
353
+ },
354
+ focusFallbackDates: [
355
+ /* @__PURE__ */ new Date(),
356
+ ...(this.value ?? []).map((i) => this.endpointDay(i.start))
357
+ ]
358
+ });
359
+ }
360
+ selectDate(e, t = null) {
361
+ if (!e.isCurrentMonth || this.disabled || this.readOnly) return;
362
+ const { state: a, commit: i } = y(this._selection, {
363
+ type: "pick",
364
+ date: e.date
365
+ });
366
+ if (this._selection = a, !i) {
367
+ this.resetWorking(), this._invalidRange = null;
368
+ return;
369
+ }
370
+ if (this.spanCoversBlockedDay(i.start, i.end)) {
371
+ this._invalidRange = { start: i.start, end: i.end }, this.emitInputError(this.disabledRangeMessage ?? v), this.requestUpdate();
372
+ return;
373
+ }
374
+ this._invalidRange = null, this._workingDateStart = m(i.start), this._workingDateEnd = m(i.end), this._workingTimeIn = void 0, this._workingTimeOut = void 0;
375
+ }
376
+ spanCoversBlockedDay(e, t) {
377
+ const a = new Date(e);
378
+ a.setHours(0, 0, 0, 0);
379
+ const i = new Date(t);
380
+ for (i.setHours(0, 0, 0, 0); a <= i; ) {
381
+ if (this.isDisabled(a)) return !0;
382
+ a.setDate(a.getDate() + 1);
383
+ }
384
+ return !1;
385
+ }
386
+ onMouseOver(e) {
387
+ this._selection = y(this._selection, {
388
+ type: "hover",
389
+ date: e.date
390
+ }).state;
391
+ }
392
+ onStartTimeChange(e) {
393
+ if (e.stopPropagation(), e.detail.commit !== !0) return;
394
+ const t = e.detail.value;
395
+ if (!t || !this._workingDateStart) {
396
+ this._workingTimeIn = void 0, this._workingTimeOut = void 0;
397
+ return;
398
+ }
399
+ const a = this.timeError(t, this._workingDateStart, this.resolvedStartTimeRanges);
400
+ if (a) {
401
+ this._workingTimeIn = void 0, this._workingTimeOut = void 0, this.emitInputError(a);
402
+ return;
403
+ }
404
+ this._workingTimeIn = t, this._workingTimeOut = void 0;
405
+ }
406
+ onEndTimeChange(e) {
407
+ if (e.stopPropagation(), e.detail.commit !== !0) return;
408
+ const t = e.detail.value;
409
+ if (!t) {
410
+ this._workingTimeOut = void 0;
411
+ return;
412
+ }
413
+ if (!this._workingTimeIn || !this._workingDateStart || !this._workingDateEnd) return;
414
+ const a = this.timeError(t, this._workingDateEnd, this.resolvedEndTimeRanges);
415
+ if (a) {
416
+ this._workingTimeOut = t, this.emitInputError(a);
417
+ return;
418
+ }
419
+ const i = q(
420
+ `${this._workingDateStart}T${this._workingTimeIn}`,
421
+ `${this._workingDateEnd}T${t}`
422
+ );
423
+ if (U(i, this.disabledRanges)) {
424
+ this._workingTimeOut = t, this.emitInputError(this.disabledRangeMessage ?? v);
425
+ return;
426
+ }
427
+ this._skipValueNavigation = !0, this.value = H([...this.value ?? [], i]), this.resetWorking(), this.dispatchEvent(
428
+ new CustomEvent("change", { detail: { value: this.value }, bubbles: !0, composed: !0 })
429
+ );
430
+ }
431
+ /**
432
+ * The error for a committed endpoint `time` on `isoDay`: out of the instant
433
+ * window, or landing on a disabled slot.
434
+ */
435
+ timeError(e, t, a) {
436
+ const i = K(`${t}T${e}`, this.minDateTime, this.maxDateTime, {
437
+ minDateTimeMessage: this.minDateTimeMessage,
438
+ maxDateTimeMessage: this.maxDateTimeMessage
439
+ });
440
+ return i || (j(e, a) ? this.disabledRangeMessage ?? v : null);
441
+ }
442
+ resetWorking() {
443
+ this._workingDateStart = void 0, this._workingDateEnd = void 0, this._workingTimeIn = void 0, this._workingTimeOut = void 0, this._openList = null, this.resetPicker(this.startPicker), this.resetPicker(this.endPicker);
444
+ }
445
+ resetPicker(e) {
446
+ e && (e.value = void 0, e.closeList());
447
+ }
448
+ emitInputError(e) {
449
+ this.dispatchEvent(
450
+ new CustomEvent("inputError", { detail: { message: e }, bubbles: !0, composed: !0 })
451
+ );
452
+ }
453
+ get startPicker() {
454
+ return this.querySelector("gui-time-picker.gui-range-date-time-calendar__start");
455
+ }
456
+ get endPicker() {
457
+ return this.querySelector("gui-time-picker.gui-range-date-time-calendar__end");
458
+ }
459
+ pickerFor(e) {
460
+ return e === "start" ? this.startPicker : this.endPicker;
461
+ }
462
+ onListToggle(e, t) {
463
+ e.stopPropagation();
464
+ const { open: a } = e.detail;
465
+ if (a && this.readOnly) {
466
+ this.pickerFor(t)?.closeList();
467
+ return;
468
+ }
469
+ a ? (this.pickerFor(t === "start" ? "end" : "start")?.closeList(), this._openList = t, this._yearSelectorOpen = !1) : this._openList === t && (this._openList = null);
470
+ }
471
+ get resolvedStartTimeRanges() {
472
+ return this._workingDateStart ? b(this.disabledRanges, this._workingDateStart) : [];
473
+ }
474
+ get resolvedEndTimeRanges() {
475
+ return this._workingDateEnd ? b(this.disabledRanges, this._workingDateEnd) : [];
476
+ }
477
+ /** minTime/maxTime tightened by the instant bounds when this IS their day. */
478
+ dayClampedBounds(e) {
479
+ const t = {};
480
+ return this.minDateTime && e === this.minDateTime.split("T")[0] && (t.minTime = this.minDateTime.split("T")[1]), this.maxDateTime && e === this.maxDateTime.split("T")[0] && (t.maxTime = this.maxDateTime.split("T")[1]), t;
481
+ }
482
+ get startListBounds() {
483
+ return this._workingDateStart ? this.dayClampedBounds(this._workingDateStart) : {};
484
+ }
485
+ get endListBounds() {
486
+ if (!this._workingDateEnd) return {};
487
+ const e = this.dayClampedBounds(this._workingDateEnd);
488
+ if (this._workingDateEnd !== this._workingDateStart || !this._workingTimeIn) return e;
489
+ const t = V(this._workingTimeIn, this.minuteStep);
490
+ return t ? { minTime: t, maxTime: e.maxTime } : { minTime: "23:59:59", maxTime: "00:00:00" };
491
+ }
492
+ renderDayContent(e) {
493
+ const t = this.renderRangeCountBadge(e), a = this.renderDisabledSlotsBadge(e);
494
+ return t === l && a === l ? h`${e.dayLabel}` : h`${e.dayLabel}<span class="gui-range-date-time-calendar__badges"
495
+ >${t}${a}</span
496
+ >`;
497
+ }
498
+ /**
499
+ * Renders a count bubble plus its hover label as SIBLINGS (the label must not
500
+ * live inside the count span — the bubble shows only the number).
501
+ */
502
+ renderBadge(e, t, a, i) {
503
+ return h`<span class="gui-range-date-time-calendar__${e}" aria-label=${a}
504
+ >${t}</span
505
+ ><span class="gui-range-date-time-calendar__badge-tooltip" aria-hidden="true"
506
+ >${i.map((o) => h`<span>${o}</span>`)}</span
507
+ >`;
508
+ }
509
+ renderRangeCountBadge(e) {
510
+ if (!e.isCurrentMonth) return l;
511
+ const t = this.rangesOnDay(e.date);
512
+ if (t.length <= 1) return l;
513
+ const a = t.map((o) => this.formatPillLabel(o)), i = `${(this.dayCountAriaLabel ?? "{count} ranges").replace(
514
+ "{count}",
515
+ String(t.length)
516
+ )}: ${a.join(", ")}`;
517
+ return this.renderBadge("day-count", t.length, i, a);
518
+ }
519
+ renderDisabledSlotsBadge(e) {
520
+ if (!e.isCurrentMonth || e.isDisabled) return l;
521
+ const t = b(this.disabledRanges, m(e.date));
522
+ if (!t.length) return l;
523
+ const a = D(this.localeId, this.hourFormat), i = t.map(
524
+ (d) => `${T(d.start, this.localeId, a)} – ${T(
525
+ d.end,
526
+ this.localeId,
527
+ a
528
+ )}`
529
+ ), o = `${(this.disabledDayCountAriaLabel ?? "{count} disabled ranges").replace(
530
+ "{count}",
531
+ String(t.length)
532
+ )}: ${i.join(", ")}`;
533
+ return this.renderBadge("disabled-count", t.length, o, i);
534
+ }
535
+ /** Committed ranges covering `date`, a range counts on every day of its span. */
536
+ rangesOnDay(e) {
537
+ if (!this.value?.length) return [];
538
+ const t = m(e);
539
+ return this.value.filter((a) => {
540
+ const i = a.start.split("T")[0], o = (a.end ?? a.start).split("T")[0];
541
+ return t >= i && t <= o;
542
+ });
543
+ }
544
+ // --- Pills ---
545
+ renderAboveCalendar() {
546
+ if (this.hidePills) return l;
547
+ const e = this.getSortedPills();
548
+ if (e.length === 0) return l;
549
+ const t = P(
550
+ e,
551
+ (a) => this.formatPillLabel(a),
552
+ this.removePillAriaLabel ?? "Remove date"
553
+ );
554
+ return h`
555
+ <gui-pills
556
+ class="gui-range-calendar__pills"
557
+ .items=${t}
558
+ .removable=${!0}
559
+ .clickable=${!0}
560
+ .bubble=${!1}
561
+ ?disabled=${this.disabled}
562
+ ?readonly=${this.readOnly}
563
+ .removeAriaLabel=${this.removePillAriaLabel ?? "Remove date"}
564
+ @pillremove=${this.onPillRemoveEvent}
565
+ @pillclick=${this.onPillClickEvent}
566
+ ></gui-pills>
567
+ `;
568
+ }
569
+ getSortedPills() {
570
+ return B(
571
+ this.value,
572
+ (e, t) => this.parseEndpoint(e).getTime() - this.parseEndpoint(t).getTime()
573
+ );
574
+ }
575
+ navigateToDate(e) {
576
+ this._nav.navigateToDate(this.endpointDay(e));
577
+ }
578
+ };
579
+ n([
580
+ r({ type: String })
581
+ ], s.prototype, "uid", 2);
582
+ n([
583
+ r({ type: String })
584
+ ], s.prototype, "label", 2);
585
+ n([
586
+ r({ type: String })
587
+ ], s.prototype, "hint", 2);
588
+ n([
589
+ r({ type: String, attribute: "locale-id" })
590
+ ], s.prototype, "localeId", 2);
591
+ n([
592
+ r({ type: Array })
593
+ ], s.prototype, "errors", 2);
594
+ n([
595
+ r({ type: Boolean })
596
+ ], s.prototype, "touched", 2);
597
+ n([
598
+ r({ type: Boolean })
599
+ ], s.prototype, "required", 2);
600
+ n([
601
+ r({ type: Boolean })
602
+ ], s.prototype, "disabled", 2);
603
+ n([
604
+ r({ type: Boolean, attribute: "readonly" })
605
+ ], s.prototype, "readOnly", 2);
606
+ n([
607
+ r({ type: String, attribute: "prev-month-icon" })
608
+ ], s.prototype, "prevMonthIcon", 2);
609
+ n([
610
+ r({ type: String, attribute: "next-month-icon" })
611
+ ], s.prototype, "nextMonthIcon", 2);
612
+ n([
613
+ r({ type: String, attribute: "prev-month-aria-label" })
614
+ ], s.prototype, "prevMonthAriaLabel", 2);
615
+ n([
616
+ r({ type: String, attribute: "next-month-aria-label" })
617
+ ], s.prototype, "nextMonthAriaLabel", 2);
618
+ n([
619
+ r({ type: String })
620
+ ], s.prototype, "dayFormat", 2);
621
+ n([
622
+ r({ type: String })
623
+ ], s.prototype, "weekdayFormat", 2);
624
+ n([
625
+ r({ type: String })
626
+ ], s.prototype, "monthFormat", 2);
627
+ n([
628
+ r({ type: String })
629
+ ], s.prototype, "minDate", 2);
630
+ n([
631
+ r({ type: String })
632
+ ], s.prototype, "maxDate", 2);
633
+ n([
634
+ r({ type: Array, attribute: "disabled-ranges" })
635
+ ], s.prototype, "disabledRanges", 2);
636
+ n([
637
+ r({ type: Number })
638
+ ], s.prototype, "numberOfMonths", 2);
639
+ n([
640
+ r({ type: Array })
641
+ ], s.prototype, "value", 2);
642
+ n([
643
+ r({ type: String })
644
+ ], s.prototype, "focusDate", 2);
645
+ n([
646
+ r({ type: Boolean })
647
+ ], s.prototype, "hidePills", 2);
648
+ n([
649
+ r({ type: String })
650
+ ], s.prototype, "removePillAriaLabel", 2);
651
+ n([
652
+ r({ type: String, attribute: "disabled-date-range-message" })
653
+ ], s.prototype, "disabledDateRangeMessage", 2);
654
+ n([
655
+ r({ attribute: !1 })
656
+ ], s.prototype, "invalidRange", 2);
657
+ n([
658
+ r({ type: String, attribute: "hour-format" })
659
+ ], s.prototype, "hourFormat", 2);
660
+ n([
661
+ r({ type: Number, attribute: "minute-step" })
662
+ ], s.prototype, "minuteStep", 2);
663
+ n([
664
+ r({ type: Boolean, attribute: "allow-custom-time" })
665
+ ], s.prototype, "allowCustomTime", 2);
666
+ n([
667
+ r({ type: String, attribute: "start-time-label" })
668
+ ], s.prototype, "startTimeLabel", 2);
669
+ n([
670
+ r({ type: String, attribute: "end-time-label" })
671
+ ], s.prototype, "endTimeLabel", 2);
672
+ n([
673
+ r({ type: String, attribute: "min-date-time" })
674
+ ], s.prototype, "minDateTime", 2);
675
+ n([
676
+ r({ type: String, attribute: "max-date-time" })
677
+ ], s.prototype, "maxDateTime", 2);
678
+ n([
679
+ r({ type: String, attribute: "min-date-time-message" })
680
+ ], s.prototype, "minDateTimeMessage", 2);
681
+ n([
682
+ r({ type: String, attribute: "max-date-time-message" })
683
+ ], s.prototype, "maxDateTimeMessage", 2);
684
+ n([
685
+ r({ type: String, attribute: "disabled-range-message" })
686
+ ], s.prototype, "disabledRangeMessage", 2);
687
+ n([
688
+ r({ type: String, attribute: "no-available-times-message" })
689
+ ], s.prototype, "noAvailableTimesMessage", 2);
690
+ n([
691
+ r({ type: String, attribute: "day-count-aria-label" })
692
+ ], s.prototype, "dayCountAriaLabel", 2);
693
+ n([
694
+ r({ type: String, attribute: "disabled-day-count-aria-label" })
695
+ ], s.prototype, "disabledDayCountAriaLabel", 2);
696
+ n([
697
+ g()
698
+ ], s.prototype, "_selection", 2);
699
+ n([
700
+ g()
701
+ ], s.prototype, "_invalidRange", 2);
702
+ n([
703
+ g()
704
+ ], s.prototype, "_workingDateStart", 2);
705
+ n([
706
+ g()
707
+ ], s.prototype, "_workingDateEnd", 2);
708
+ n([
709
+ g()
710
+ ], s.prototype, "_workingTimeIn", 2);
711
+ n([
712
+ g()
713
+ ], s.prototype, "_workingTimeOut", 2);
714
+ n([
715
+ g()
716
+ ], s.prototype, "_openList", 2);
717
+ s = n([
718
+ S("gui-range-date-time-calendar")
719
+ ], s);
720
+ typeof customElements < "u" && !customElements.get("gui-range-date-time-calendar") && customElements.define("gui-range-date-time-calendar", s);