@golemui/gui-lit 1.2.0 → 1.2.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 (91) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/{accordion.element-BIgxl5e9.js → accordion.element-C9GzfKrY.js} +29 -30
  3. package/alert.element-CHn49Yaf.js +55 -0
  4. package/button.element-C9fHivSw.js +59 -0
  5. package/{calendar.element-Cv3RBphf.js → calendar.element-XkojKTJk.js} +30 -31
  6. package/checkbox.element-DU_tVMXu.js +66 -0
  7. package/currency.element-BmAH5KS_.js +73 -0
  8. package/date-picker.element-Bg3rF95F.js +94 -0
  9. package/{date-time-calendar.element-DlbWZjoe.js → date-time-calendar.element-sywQCeQQ.js} +24 -24
  10. package/date-time-picker.element-HHpwjWTQ.js +107 -0
  11. package/{date-time.element-CLLxM2nV.js → date-time.element-ucETvSTC.js} +26 -26
  12. package/{date.element-B8ZHK9KJ.js → date.element-BEHGxRFF.js} +27 -27
  13. package/default-list-item-renderer-CuPJ9jUD.js +24 -0
  14. package/{dropdown.element-DMZ7oL5n.js → dropdown.element-DUqG_p1x.js} +85 -84
  15. package/{flex.element-DG4Uaj_X.js → flex.element-pwba7621.js} +27 -28
  16. package/{grid.element-DCZsh-3J.js → grid.element-C8K7_Qi3.js} +29 -30
  17. package/index.js +1316 -3883
  18. package/index.umd.cjs +117 -2132
  19. package/{list.element-ADtUK2na.js → list.element-ZtEMKE2x.js} +41 -40
  20. package/markdown-text.element-DDm36qD0.js +54 -0
  21. package/markdown.element-DWz3U9rG.js +84 -0
  22. package/number.element-VkG5wScD.js +71 -0
  23. package/package.json +6 -6
  24. package/password.element-C5vQHq5P.js +72 -0
  25. package/radiogroup.element-CKdO9HwO.js +69 -0
  26. package/{range-calendar.element-D5eb2f7p.js → range-calendar.element-BznGrej5.js} +23 -24
  27. package/{range-date-input.element-C35grlYo.js → range-date-input.element-BloTHRDl.js} +24 -24
  28. package/range-date-picker.element-DKhwFasW.js +98 -0
  29. package/{range-date-time-calendar.element-BV0J96Gu.js → range-date-time-calendar.element-CZCET-sb.js} +26 -26
  30. package/{range-date-time-input.element-CzgRbR9F.js → range-date-time-input.element-Dr2VrYhG.js} +24 -24
  31. package/range-date-time-picker.element-CYeIMWLp.js +109 -0
  32. package/{range-time-input.element-BOHLUO8z.js → range-time-input.element-7OZhPQqx.js} +23 -23
  33. package/range-time-picker.element-D0mRFZkK.js +96 -0
  34. package/renderer.element-DbsFoBba.js +48 -0
  35. package/{repeater.element-Da8YN1Vy.js → repeater.element-DGEbwvhY.js} +54 -65
  36. package/select.element-Bb_9jAVB.js +76 -0
  37. package/{tabs.element-CvcIA8P3.js → tabs.element-BYDNF_pm.js} +49 -50
  38. package/tags.element-BSN3i9Gx.js +73 -0
  39. package/textarea.element-Dl1ZEOqO.js +71 -0
  40. package/textinput.element-C5Vbbkxq.js +68 -0
  41. package/{time-picker.element-C3oR0EkQ.js → time-picker.element-Crmj9YDy.js} +26 -26
  42. package/{time.element-X286nthD.js → time.element-DfSeAZp4.js} +29 -29
  43. package/toggle.element-ORsprZ2M.js +66 -0
  44. package/alert.element-DPWq9-0F.js +0 -56
  45. package/button.element-CJay43iR.js +0 -132
  46. package/calendar-DleRbmvP.js +0 -267
  47. package/checkbox.element-CpmrzdH0.js +0 -200
  48. package/currency.element-Cezgzbbs.js +0 -276
  49. package/date-DBuYpvcO.js +0 -849
  50. package/date-input-B3yHsn-g.js +0 -204
  51. package/date-picker.element-ByZefznr.js +0 -357
  52. package/date-time-calendar-CB5cNoOX.js +0 -374
  53. package/date-time-input-DrY68YDX.js +0 -246
  54. package/date-time-picker.element-CYwmumfq.js +0 -440
  55. package/day-status-ljexnwEO.js +0 -554
  56. package/errors-Bs_vYN-_.js +0 -110
  57. package/focus-leave.controller-2gV0pQd5.js +0 -73
  58. package/list-D730tmGN.js +0 -297
  59. package/markdown-text-X-BRJT6K.js +0 -30
  60. package/markdown-text.element-B8TfVLIO.js +0 -55
  61. package/markdown.element-D5zcxAUS.js +0 -693
  62. package/number.element-DEY5tR_y.js +0 -291
  63. package/numeric-jmOOKz30.js +0 -12
  64. package/one-of-anKkm7mD.js +0 -50
  65. package/part-templates-VORbpgs2.js +0 -691
  66. package/password.element-C1aQh_iz.js +0 -240
  67. package/pill-ranges-DpvWwP-3.js +0 -48
  68. package/pills-BDMO2NiR.js +0 -348
  69. package/popup.controller-B33OvX_y.js +0 -86
  70. package/radiogroup.element-B2G-XyGx.js +0 -235
  71. package/range-calendar-D7sG24Kx.js +0 -466
  72. package/range-commit-8-MmYUyo.js +0 -14
  73. package/range-date-input-BChaoBC1.js +0 -311
  74. package/range-date-picker.element-Do5YsL5V.js +0 -434
  75. package/range-date-time-calendar-DulGK2EQ.js +0 -734
  76. package/range-date-time-input-8ggqckP7.js +0 -353
  77. package/range-date-time-picker.element-hi5KdopZ.js +0 -472
  78. package/range-selection-CU3hxLJE.js +0 -25
  79. package/range-time-input-D7GFdDeA.js +0 -348
  80. package/range-time-picker.element-DDNQMA_u.js +0 -470
  81. package/renderer.element-CNyMn2Lu.js +0 -49
  82. package/select.element-SDxBhGjz.js +0 -266
  83. package/tabs-DzSCq_98.js +0 -13
  84. package/tags.element-Bnhfevp3.js +0 -369
  85. package/templates-Df7abEkB.js +0 -92
  86. package/textarea.element-Dx7eYEnl.js +0 -239
  87. package/textinput.element-BnIoDRmY.js +0 -205
  88. package/time-input-Kk4EX6at.js +0 -201
  89. package/time-list-DLcq8BAp.js +0 -217
  90. package/time-picker-DLj1rhOf.js +0 -299
  91. package/toggle.element-Dokdat_o.js +0 -203
@@ -1,734 +0,0 @@
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-Df7abEkB.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-ljexnwEO.js";
6
- import { G as C } from "./focus-leave.controller-2gV0pQd5.js";
7
- import "./pills-BDMO2NiR.js";
8
- import "./time-picker-DLj1rhOf.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);