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