@golemui/gui-lit 1.0.3 → 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 (68) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/calendar-BuJgwvZx.js +254 -0
  3. package/{calendar.element-DcnTyvfg.js → calendar.element-M5MPJmap.js} +1 -1
  4. package/{currency.element-5GSakkxF.js → currency.element-CfFrAtrr.js} +4 -1
  5. package/{date-CDUlLuYy.js → date-Bj9mI3GU.js} +80 -29
  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-BZO0UQez.js → date.element-Consgsbb.js} +32 -27
  14. package/day-status-0-hJHrI7.js +530 -0
  15. package/{dropdown.element-CyJbVAA5.js → dropdown.element-WsD61Qel.js} +46 -36
  16. package/focus-leave.controller-2gV0pQd5.js +73 -0
  17. package/index.js +1199 -971
  18. package/index.umd.cjs +1582 -530
  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/package.json +6 -6
  36. package/part-templates-Db871PS3.js +677 -0
  37. package/pill-ranges-DCqDmpkk.js +48 -0
  38. package/{pills-B66qz_KX.js → pills-Be1UrLgq.js} +4 -1
  39. package/popup.controller-eUDxE6jD.js +71 -0
  40. package/range-calendar-CKPYeSGt.js +452 -0
  41. package/{range-calendar.element-_1bHW_c1.js → range-calendar.element-D6KYq18B.js} +24 -20
  42. package/range-commit-8-MmYUyo.js +14 -0
  43. package/range-date-input-D--AqBMv.js +292 -0
  44. package/{range-date-input.element-BqzAF0O3.js → range-date-input.element-D4nIXJbw.js} +8 -7
  45. package/range-date-picker.element-dhxPAAE6.js +386 -0
  46. package/range-date-time-calendar-yksWrR7b.js +720 -0
  47. package/range-date-time-calendar.element-C00aDefZ.js +95 -0
  48. package/range-date-time-input-B37TUoM3.js +322 -0
  49. package/range-date-time-input.element-DUnbv4ed.js +81 -0
  50. package/range-date-time-picker.element-Cbps6s_G.js +412 -0
  51. package/range-selection-CU3hxLJE.js +25 -0
  52. package/range-time-input-3lhqR1Ku.js +329 -0
  53. package/range-time-input.element-dU2iBdmJ.js +81 -0
  54. package/range-time-picker.element-v6nQsIPw.js +429 -0
  55. package/{select.element-jcDF1h-g.js → select.element-C0V-Bv3L.js} +94 -90
  56. package/{tags.element-CX3vQL8L.js → tags.element-DvwEpxpK.js} +1 -1
  57. package/time-input-BOhlBGJZ.js +181 -0
  58. package/time-list-Czo48bZm.js +217 -0
  59. package/time-picker-bFJ63ky8.js +261 -0
  60. package/time-picker.element-CYZVXgRS.js +85 -0
  61. package/time.element-fK3oLi49.js +82 -0
  62. package/abstract-calendar-D0-077XJ.js +0 -545
  63. package/calendar-BclCC9VJ.js +0 -96
  64. package/date-input-DCdGWRio.js +0 -268
  65. package/date-picker.element-k7AJFQ5W.js +0 -168
  66. package/range-calendar-CBINu84w.js +0 -255
  67. package/range-date-input-BYXzqnr1.js +0 -395
  68. package/range-date-picker.element-BCBefgvY.js +0 -182
@@ -0,0 +1,312 @@
1
+ import { InputWidgetAdapter as b, formContext as y, inputContext as v } from "@golemui/lit";
2
+ import { LitElement as c, html as l, nothing as $ } from "lit";
3
+ import { property as i, query as m, customElement as g } from "lit/decorators.js";
4
+ import { classMap as M } from "lit/directives/class-map.js";
5
+ import "./date-input-cJDkNnVw.js";
6
+ import "./calendar-BuJgwvZx.js";
7
+ import { G as f } from "./popup.controller-eUDxE6jD.js";
8
+ import { d as D } from "./date-Bj9mI3GU.js";
9
+ import { a as x, b as w, c as _ } from "./templates-Dk1jxLwS.js";
10
+ import { consume as I, provide as C } from "@lit/context";
11
+ import "rxjs";
12
+ var E = Object.defineProperty, R = Object.getOwnPropertyDescriptor, a = (t, r, n, s) => {
13
+ for (var o = s > 1 ? void 0 : s ? R(r, n) : r, d = t.length - 1, p; d >= 0; d--)
14
+ (p = t[d]) && (o = (s ? p(r, n, o) : p(o)) || o);
15
+ return s && o && E(r, n, o), o;
16
+ };
17
+ let e = class extends c {
18
+ constructor() {
19
+ super(...arguments), this.uid = void 0, this.label = void 0, this.hint = void 0, this.icon = "", this.errors = [], this.showErrors = !0, this.touched = !1, this.required = !1, this.disabled = !1, this.readOnly = !1, this.localeId = void 0, this.value = void 0, this.prevMonthIcon = "", this.nextMonthIcon = "", this.prevMonthAriaLabel = void 0, this.nextMonthAriaLabel = void 0, this.dayFormat = void 0, this.weekdayFormat = void 0, this.monthFormat = void 0, this.minDate = void 0, this.maxDate = void 0, this.disabledRanges = void 0, this.numberOfMonths = void 0, this.invalidDateMessage = void 0, this.minDateMessage = void 0, this.maxDateMessage = void 0, this.disabledDateRangeMessage = void 0, this._popup = new f(this, {
20
+ getInteriorElements: () => [this._dateRef, this._calendarRef],
21
+ focusRestoreSelector: "gui-date input",
22
+ isDisabled: () => !!this.disabled,
23
+ clickIntent: (t) => t.closest(".gui-calendar__day-button") ? "ignore" : t.closest(".gui-date-input__part") || t.closest("gui-calendar") ? "open" : "toggle",
24
+ keyToggleMode: "toggle"
25
+ });
26
+ }
27
+ createRenderRoot() {
28
+ return this;
29
+ }
30
+ render() {
31
+ const t = x("datePicker", { icon: this.icon }), r = this._popup.open ? l`<gui-calendar
32
+ id="calendar-input"
33
+ .uid=${this.uid}
34
+ .hint=${this.hint}
35
+ ?touched=${this.touched}
36
+ ?required=${this.required}
37
+ ?disabled=${this.disabled}
38
+ ?readonly=${this.readOnly}
39
+ .value=${this.value}
40
+ .prevMonthIcon=${this.prevMonthIcon}
41
+ .nextMonthIcon=${this.nextMonthIcon}
42
+ .prevMonthAriaLabel=${this.prevMonthAriaLabel}
43
+ .nextMonthAriaLabel=${this.nextMonthAriaLabel}
44
+ .dayFormat=${this.dayFormat}
45
+ .weekdayFormat=${this.weekdayFormat}
46
+ .monthFormat=${this.monthFormat}
47
+ .minDate=${this.minDate}
48
+ .maxDate=${this.maxDate}
49
+ .disabledRanges=${this.disabledRanges}
50
+ .numberOfMonths=${this.numberOfMonths}
51
+ .localeId=${this.localeId}
52
+ @blur=${this.onCalendarBlur}
53
+ @change=${this.onCalendarChange}
54
+ ></gui-calendar>` : $;
55
+ return l`
56
+ ${w(this.uid ?? "", {
57
+ label: this.label,
58
+ hint: this.hint,
59
+ required: this.required
60
+ })}
61
+
62
+ <div
63
+ role="button"
64
+ tabindex="-1"
65
+ class="gui-widget"
66
+ aria-expanded=${this._popup.open}
67
+ @keyup=${this._popup.onAnchorKeyUp}
68
+ @keydown=${this._popup.onAnchorKeyDown}
69
+ @click=${this._popup.onAnchorClick}
70
+ >
71
+ <gui-date
72
+ id="date-input"
73
+ class=${M(t.widgetClasses)}
74
+ .uid=${this.uid}
75
+ .hint=${this.hint}
76
+ .showErrors=${!1}
77
+ .errors=${this.errors}
78
+ ?touched=${this.touched}
79
+ ?required=${this.required}
80
+ ?disabled=${this.disabled}
81
+ ?readonly=${this.readOnly}
82
+ .value=${this.value}
83
+ .icon=${this.icon}
84
+ .localeId=${this.localeId}
85
+ .invalidDateMessage=${this.invalidDateMessage}
86
+ @blur=${this.onDateBlur}
87
+ @focus=${this._popup.show}
88
+ @change=${this.onDateChange}
89
+ ></gui-date>
90
+ <span class="gui-date-picker__arrow"
91
+ ><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 256 256">
92
+ <path
93
+ d="M213.66,101.66l-80,80a8,8,0,0,1-11.32,0l-80-80A8,8,0,0,1,53.66,90.34L128,164.69l74.34-74.35a8,8,0,0,1,11.32,11.32Z"
94
+ ></path></svg
95
+ ></span>
96
+
97
+ ${r}
98
+ </div>
99
+
100
+ ${this.showErrors ? _(this.uid ?? "", { errors: this.errors, touched: this.touched }) : ""}
101
+ `;
102
+ }
103
+ onDateChange(t) {
104
+ t.stopPropagation(), this.commitValue(t.detail.value);
105
+ }
106
+ onDateBlur() {
107
+ this.dispatchEvent(new CustomEvent("blur"));
108
+ }
109
+ onCalendarChange(t) {
110
+ t.stopPropagation(), this.commitValue(t.detail.value), this._popup.close();
111
+ }
112
+ commitValue(t) {
113
+ this.value = t ?? void 0;
114
+ const r = this.validateBounds(this.value);
115
+ this.dispatchEvent(
116
+ new CustomEvent("change", {
117
+ detail: { value: t ?? null },
118
+ bubbles: !0,
119
+ composed: !0
120
+ })
121
+ ), r && this.dispatchEvent(
122
+ new CustomEvent("inputError", {
123
+ detail: { message: r },
124
+ bubbles: !0,
125
+ composed: !0
126
+ })
127
+ );
128
+ }
129
+ validateBounds(t) {
130
+ return t ? D(t, this.minDate, this.maxDate, this.disabledRanges, {
131
+ minDateMessage: this.minDateMessage,
132
+ maxDateMessage: this.maxDateMessage,
133
+ disabledDateRangeMessage: this.disabledDateRangeMessage
134
+ }) : null;
135
+ }
136
+ onCalendarBlur() {
137
+ this._popup.close();
138
+ }
139
+ };
140
+ a([
141
+ i({ type: String })
142
+ ], e.prototype, "uid", 2);
143
+ a([
144
+ i({ type: String })
145
+ ], e.prototype, "label", 2);
146
+ a([
147
+ i({ type: String })
148
+ ], e.prototype, "hint", 2);
149
+ a([
150
+ i({ type: String })
151
+ ], e.prototype, "icon", 2);
152
+ a([
153
+ i({ type: Array })
154
+ ], e.prototype, "errors", 2);
155
+ a([
156
+ i({ type: Boolean })
157
+ ], e.prototype, "showErrors", 2);
158
+ a([
159
+ i({ type: Boolean })
160
+ ], e.prototype, "touched", 2);
161
+ a([
162
+ i({ type: Boolean })
163
+ ], e.prototype, "required", 2);
164
+ a([
165
+ i({ type: Boolean })
166
+ ], e.prototype, "disabled", 2);
167
+ a([
168
+ i({ type: Boolean, attribute: "readonly" })
169
+ ], e.prototype, "readOnly", 2);
170
+ a([
171
+ i({ type: String, attribute: "locale-id" })
172
+ ], e.prototype, "localeId", 2);
173
+ a([
174
+ i({ type: String })
175
+ ], e.prototype, "value", 2);
176
+ a([
177
+ i({ type: String, attribute: "prev-month-icon" })
178
+ ], e.prototype, "prevMonthIcon", 2);
179
+ a([
180
+ i({ type: String, attribute: "next-month-icon" })
181
+ ], e.prototype, "nextMonthIcon", 2);
182
+ a([
183
+ i({ type: String, attribute: "prev-month-aria-label" })
184
+ ], e.prototype, "prevMonthAriaLabel", 2);
185
+ a([
186
+ i({ type: String, attribute: "next-month-aria-label" })
187
+ ], e.prototype, "nextMonthAriaLabel", 2);
188
+ a([
189
+ i({ type: String, attribute: "day-format" })
190
+ ], e.prototype, "dayFormat", 2);
191
+ a([
192
+ i({ type: String, attribute: "weekday-format" })
193
+ ], e.prototype, "weekdayFormat", 2);
194
+ a([
195
+ i({ type: String, attribute: "month-format" })
196
+ ], e.prototype, "monthFormat", 2);
197
+ a([
198
+ i({ type: String, attribute: "min-date" })
199
+ ], e.prototype, "minDate", 2);
200
+ a([
201
+ i({ type: String, attribute: "max-date" })
202
+ ], e.prototype, "maxDate", 2);
203
+ a([
204
+ i({ type: Array, attribute: "disabled-ranges" })
205
+ ], e.prototype, "disabledRanges", 2);
206
+ a([
207
+ i({ type: Number, attribute: "number-of-months" })
208
+ ], e.prototype, "numberOfMonths", 2);
209
+ a([
210
+ i({ type: String, attribute: "invalid-date-message" })
211
+ ], e.prototype, "invalidDateMessage", 2);
212
+ a([
213
+ i({ type: String, attribute: "min-date-message" })
214
+ ], e.prototype, "minDateMessage", 2);
215
+ a([
216
+ i({ type: String, attribute: "max-date-message" })
217
+ ], e.prototype, "maxDateMessage", 2);
218
+ a([
219
+ i({ type: String, attribute: "disabled-date-range-message" })
220
+ ], e.prototype, "disabledDateRangeMessage", 2);
221
+ a([
222
+ m("#date-input")
223
+ ], e.prototype, "_dateRef", 2);
224
+ a([
225
+ m("#calendar-input")
226
+ ], e.prototype, "_calendarRef", 2);
227
+ e = a([
228
+ g("gui-date-picker")
229
+ ], e);
230
+ typeof customElements < "u" && !customElements.get("gui-date-picker") && customElements.define("gui-date-picker", e);
231
+ var S = Object.defineProperty, k = Object.getOwnPropertyDescriptor, u = (t, r, n, s) => {
232
+ for (var o = s > 1 ? void 0 : s ? k(r, n) : r, d = t.length - 1, p; d >= 0; d--)
233
+ (p = t[d]) && (o = (s ? p(r, n, o) : p(o)) || o);
234
+ return s && o && S(r, n, o), o;
235
+ };
236
+ let h = class extends c {
237
+ constructor() {
238
+ super(...arguments), this.adapter = new b(), this.subscriptions = [];
239
+ }
240
+ createRenderRoot() {
241
+ return this;
242
+ }
243
+ updated(t) {
244
+ super.updated(t);
245
+ const r = this.adapter.templateData.size;
246
+ r ? this.style.flex = String(r) : this.style.removeProperty("flex");
247
+ }
248
+ connectedCallback() {
249
+ super.connectedCallback(), this.classList.add("gui-date-picker", "gui-field"), this.adapter.context = this.formContext, this.adapter.init(this.widget), this.subscriptions.push(
250
+ this.adapter.templateDataChanged$.subscribe(() => this.requestUpdate())
251
+ );
252
+ }
253
+ render() {
254
+ super.render();
255
+ const t = this.adapter.templateData;
256
+ return l`
257
+ <gui-date-picker
258
+ .uid=${this.widget.uid}
259
+ .label=${t.label}
260
+ .hint=${t.hint}
261
+ .errors=${t.errors}
262
+ ?touched=${t.touched}
263
+ ?required=${t.validator?.required}
264
+ ?disabled=${t.disabled}
265
+ ?readonly=${t.readonly}
266
+ .value=${t.value}
267
+ .icon=${t.icon}
268
+ .localeId=${t.lang}
269
+ .prevMonthIcon=${t.prevMonthIcon}
270
+ .nextMonthIcon=${t.nextMonthIcon}
271
+ .prevMonthAriaLabel=${t.prevMonthAriaLabel}
272
+ .nextMonthAriaLabel=${t.nextMonthAriaLabel}
273
+ .dayFormat=${t.dayFormat}
274
+ .weekdayFormat=${t.weekdayFormat}
275
+ .monthFormat=${t.monthFormat}
276
+ .minDate=${t.minDate}
277
+ .maxDate=${t.maxDate}
278
+ .disabledRanges=${t.disabledRanges}
279
+ .numberOfMonths=${t.numberOfMonths}
280
+ .invalidDateMessage=${t.invalidDateMessage}
281
+ .minDateMessage=${t.minDateMessage}
282
+ .maxDateMessage=${t.maxDateMessage}
283
+ .disabledDateRangeMessage=${t.disabledDateRangeMessage}
284
+ @inputError=${this.onInputError}
285
+ @blur=${() => this.adapter.onBlur()}
286
+ @change=${this.valueChanged}
287
+ ></gui-date-picker>
288
+ `;
289
+ }
290
+ valueChanged(t) {
291
+ this.adapter.injectValidationIssues(null), this.adapter.valueChanged(t.detail.value);
292
+ }
293
+ onInputError(t) {
294
+ this.adapter.injectValidationIssues([t.detail.message]);
295
+ }
296
+ disconnectedCallback() {
297
+ super.disconnectedCallback(), this.adapter.destroy(), this.subscriptions.forEach((t) => t.unsubscribe());
298
+ }
299
+ };
300
+ u([
301
+ I({ context: y }),
302
+ i({ attribute: !1 })
303
+ ], h.prototype, "formContext", 2);
304
+ u([
305
+ C({ context: v })
306
+ ], h.prototype, "adapter", 2);
307
+ h = u([
308
+ g("gui-date-picker-input")
309
+ ], h);
310
+ export {
311
+ h as DatePickerElement
312
+ };
@@ -0,0 +1,361 @@
1
+ import { LitElement as g, nothing as c, html as d } from "lit";
2
+ import { property as s, state as u, customElement as y } from "lit/decorators.js";
3
+ import { classMap as b } from "lit/directives/class-map.js";
4
+ import "./time-picker-bFJ63ky8.js";
5
+ import { G as v } from "./templates-Dk1jxLwS.js";
6
+ import { G as _, a as D, r as M, b as T, c as f, d as S, e as C } from "./day-status-0-hJHrI7.js";
7
+ import { G as O } from "./focus-leave.controller-2gV0pQd5.js";
8
+ import { p, f as I, h as x, t as m, j as $ } from "./date-Bj9mI3GU.js";
9
+ import { y as w, p as L, z as P } from "./part-templates-Db871PS3.js";
10
+ var G = Object.defineProperty, k = Object.getOwnPropertyDescriptor, a = (e, t, r, o) => {
11
+ for (var n = o > 1 ? void 0 : o ? k(t, r) : t, l = e.length - 1, h; l >= 0; l--)
12
+ (h = e[l]) && (n = (o ? h(t, r, n) : h(n)) || n);
13
+ return o && n && G(t, r, n), n;
14
+ };
15
+ let i = class extends g {
16
+ constructor() {
17
+ 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 = void 0, this.hourFormat = void 0, this.minuteStep = void 0, this.minTime = void 0, this.maxTime = void 0, this.disabledTimeRanges = void 0, this.minTimeMessage = void 0, this.maxTimeMessage = void 0, this.disabledTimeRangeMessage = void 0, this.noAvailableTimesMessage = void 0, this.allowCustomTime = !1, this._selectedDate = void 0, this._selectedTime = void 0, this._timeGridOpen = !1, this._internalValueChange = !1, this._nav = new _(this, {
18
+ getMinDate: () => this.minDate,
19
+ getMaxDate: () => this.maxDate,
20
+ getNumberOfMonths: () => this.numberOfMonths,
21
+ getDisabledRanges: () => this.disabledRanges,
22
+ onYearSelectorToggled: () => this._keyboard.onYearGridToggled()
23
+ }), this.ariaController = new v(this, {
24
+ getTargets: () => this.querySelectorAll(".gui-calendar-input"),
25
+ getState: () => ({
26
+ uid: this.uid,
27
+ templateData: {
28
+ hint: this.hint,
29
+ errors: this.errors,
30
+ readonly: this.readOnly,
31
+ disabled: this.disabled,
32
+ touched: this.touched
33
+ }
34
+ })
35
+ }), this._keyboard = new D(this, {
36
+ canGoPrev: () => this._nav.canGoPrev(),
37
+ canGoNext: () => this._nav.canGoNext(),
38
+ goPrev: () => this._nav.prevMonth(),
39
+ goNext: () => this._nav.nextMonth(),
40
+ // Enter/Space can only fire on a focused (hence enabled, in-month) day
41
+ // button; the `disabled`/`readOnly` host guards stay inside `selectDate`.
42
+ onActivateDay: (e) => {
43
+ const t = p(e);
44
+ this.selectDate({
45
+ date: t,
46
+ dayLabel: x(this.localeId, t),
47
+ isCurrentMonth: !0,
48
+ isToday: I(t),
49
+ isSelected: !1,
50
+ isFocusable: !0,
51
+ isDisabled: !1
52
+ });
53
+ },
54
+ onSelectYear: (e) => this._nav.selectYear(e),
55
+ onCloseYearGrid: () => this._nav.closeYearSelector(),
56
+ isYearGridOpen: () => this._nav.yearSelectorOpen
57
+ }), this._focusLeave = new O(this, {
58
+ onLeave: () => {
59
+ this.dispatchEvent(new CustomEvent("blur", { bubbles: !0, composed: !0 }));
60
+ }
61
+ });
62
+ }
63
+ /** The disabled time ranges in effect on the selected day. */
64
+ get resolvedTimeRanges() {
65
+ return this._selectedDate ? w(this.disabledTimeRanges, this._selectedDate) : [];
66
+ }
67
+ get timePicker() {
68
+ return this.querySelector("gui-time-picker");
69
+ }
70
+ createRenderRoot() {
71
+ return this;
72
+ }
73
+ connectedCallback() {
74
+ super.connectedCallback(), this.classList.add("gui-field");
75
+ }
76
+ willUpdate(e) {
77
+ if (e.has("value")) {
78
+ if (this._internalValueChange) {
79
+ this._internalValueChange = !1;
80
+ return;
81
+ }
82
+ if (this.value) {
83
+ const t = L(this.value);
84
+ isNaN(t.getTime()) || (this._selectedDate = m(t), this._selectedTime = P(t), $(t, this._nav.currentDate, this.numberOfMonths ?? 1) || (this._nav.currentDate = t));
85
+ } else this._selectedTime && (this._selectedDate = void 0, this._selectedTime = void 0);
86
+ }
87
+ }
88
+ setValueInternal(e) {
89
+ this._internalValueChange = !0, this.value = e;
90
+ }
91
+ emitChange(e, t = !1) {
92
+ this.dispatchEvent(
93
+ new CustomEvent("change", {
94
+ detail: { value: e, commit: t },
95
+ bubbles: !0,
96
+ composed: !0
97
+ })
98
+ );
99
+ }
100
+ selectDate(e) {
101
+ if (!e.isCurrentMonth || e.isDisabled || this.disabled || this.readOnly) return;
102
+ const t = m(e.date);
103
+ t !== this._selectedDate && (this._selectedDate = t, this._selectedTime = void 0, this.value && (this.setValueInternal(void 0), this.emitChange(null)));
104
+ }
105
+ commitTime(e, t = !1) {
106
+ this._selectedDate && (this._selectedTime = e, this.setValueInternal(`${this._selectedDate}T${e}`), this.emitChange(this.value, t));
107
+ }
108
+ onTimePickerChange(e) {
109
+ e.stopPropagation();
110
+ const t = e.detail.value, r = e.detail.commit === !0;
111
+ if (!t) {
112
+ this._selectedTime = void 0, this.value && (this.setValueInternal(void 0), this.emitChange(null));
113
+ return;
114
+ }
115
+ this.commitTime(t, r);
116
+ }
117
+ onListToggle(e) {
118
+ e.stopPropagation();
119
+ const { open: t } = e.detail;
120
+ if (t && this.readOnly) {
121
+ this.timePicker?.closeList();
122
+ return;
123
+ }
124
+ this._timeGridOpen = t, t && (this._nav.yearSelectorOpen = !1);
125
+ }
126
+ /** Closes the embedded time picker before flipping the year grid. */
127
+ toggleYearSelector() {
128
+ this.timePicker?.closeList(), this._nav.toggleYearSelector();
129
+ }
130
+ render() {
131
+ return M({
132
+ uid: this.uid,
133
+ label: this.label,
134
+ hint: this.hint,
135
+ errors: this.errors,
136
+ touched: this.touched,
137
+ required: this.required,
138
+ disabled: this.disabled,
139
+ numberOfMonths: this.numberOfMonths,
140
+ prevMonthIcon: this.prevMonthIcon,
141
+ nextMonthIcon: this.nextMonthIcon,
142
+ prevMonthAriaLabel: this.prevMonthAriaLabel,
143
+ nextMonthAriaLabel: this.nextMonthAriaLabel,
144
+ canGoPrev: this._nav.canGoPrev(),
145
+ canGoNext: this._nav.canGoNext(),
146
+ onPrevMonthClick: this._keyboard.onPrevMonthClick,
147
+ onNextMonthClick: this._keyboard.onNextMonthClick,
148
+ onFocusOut: this._focusLeave.onFocusOut,
149
+ renderAboveCalendar: () => c,
150
+ renderMonthPanel: (e) => T({
151
+ currentDate: this._nav.currentDate,
152
+ offset: e,
153
+ localeId: this.localeId,
154
+ monthFormat: this.monthFormat,
155
+ yearSelectorOpen: this._nav.yearSelectorOpen,
156
+ onToggleYearSelector: () => this.toggleYearSelector(),
157
+ renderBelowHeader: (t) => this.renderBelowHeader(t),
158
+ renderPanelBody: (t) => this.renderPanelBody(t)
159
+ })
160
+ });
161
+ }
162
+ /** The embedded time-picker row under the first panel's header. */
163
+ renderBelowHeader(e) {
164
+ return e !== 0 ? c : d`
165
+ <div class="gui-calendar__time-input-row">
166
+ <gui-time-picker
167
+ class="gui-time-picker gui-field"
168
+ .uid=${this.uid ? `${this.uid}-time` : void 0}
169
+ .showErrors=${!1}
170
+ ?required=${this.required}
171
+ ?disabled=${this.disabled || !this._selectedDate}
172
+ ?readonly=${this.readOnly}
173
+ .allowCustomTime=${this.allowCustomTime}
174
+ .value=${this._selectedTime}
175
+ .localeId=${this.localeId}
176
+ .hourFormat=${this.hourFormat}
177
+ .minuteStep=${this.minuteStep}
178
+ .minTime=${this.minTime}
179
+ .maxTime=${this.maxTime}
180
+ .disabledRanges=${this.resolvedTimeRanges}
181
+ .columns=${4}
182
+ .minTimeMessage=${this.minTimeMessage}
183
+ .maxTimeMessage=${this.maxTimeMessage}
184
+ .disabledRangeMessage=${this.disabledTimeRangeMessage}
185
+ .noAvailableTimesMessage=${this.noAvailableTimesMessage}
186
+ @change=${this.onTimePickerChange}
187
+ @listtoggle=${this.onListToggle}
188
+ ></gui-time-picker>
189
+ </div>
190
+ `;
191
+ }
192
+ renderPanelBody(e) {
193
+ return this._timeGridOpen && !this._nav.yearSelectorOpen && e === 0 ? d`` : f({
194
+ offset: e,
195
+ yearSelectorOpen: this._nav.yearSelectorOpen,
196
+ years: this._nav.yearList,
197
+ currentYear: this._nav.currentDate.getFullYear(),
198
+ onSelectYear: (t) => this._keyboard.selectYear(t),
199
+ onYearKeydown: this._keyboard.handleYearKeydown,
200
+ localeId: this.localeId,
201
+ getDays: (t) => this.getDaysInMonth(t),
202
+ renderDay: (t) => this.renderDay(t)
203
+ });
204
+ }
205
+ renderDay(e) {
206
+ const t = {
207
+ "gui-calendar__day-button": !0,
208
+ today: e.isToday,
209
+ selected: e.isSelected,
210
+ disabled: e.isDisabled,
211
+ "other-month": !e.isCurrentMonth
212
+ };
213
+ return d`
214
+ <button
215
+ type="button"
216
+ role="gridcell"
217
+ class=${b(t)}
218
+ tabindex=${e.isFocusable ? 0 : -1}
219
+ ?disabled=${!e.isCurrentMonth || e.isDisabled}
220
+ data-date=${m(e.date)}
221
+ @click=${() => this.selectDate(e)}
222
+ @keydown=${(r) => this._keyboard.handleDayKeydown(r)}
223
+ aria-selected=${e.isSelected}
224
+ >
225
+ ${e.dayLabel}
226
+ </button>
227
+ `;
228
+ }
229
+ getDaysInMonth(e) {
230
+ const t = this._selectedDate;
231
+ return S({
232
+ currentDate: this._nav.currentDate,
233
+ offset: e,
234
+ localeId: this.localeId,
235
+ numberOfMonths: this.numberOfMonths ?? 1,
236
+ isDisabled: (r) => this.isDisabled(r),
237
+ toDay: (r) => {
238
+ const o = C(r.date, { selectedISO: t }).isSelected;
239
+ return {
240
+ date: r.date,
241
+ dayLabel: r.dayLabel,
242
+ isCurrentMonth: r.isCurrentMonth,
243
+ isToday: r.isToday,
244
+ isDisabled: r.isDisabled,
245
+ isSelected: o,
246
+ isFocusable: (o || r.isToday) && r.isCurrentMonth
247
+ };
248
+ },
249
+ focusFallbackDates: [t ? p(t) : /* @__PURE__ */ new Date()]
250
+ });
251
+ }
252
+ isDisabled(e) {
253
+ return this._nav.isDisabled(e);
254
+ }
255
+ };
256
+ a([
257
+ s({ type: String })
258
+ ], i.prototype, "uid", 2);
259
+ a([
260
+ s({ type: String })
261
+ ], i.prototype, "label", 2);
262
+ a([
263
+ s({ type: String })
264
+ ], i.prototype, "hint", 2);
265
+ a([
266
+ s({ type: String, attribute: "locale-id" })
267
+ ], i.prototype, "localeId", 2);
268
+ a([
269
+ s({ type: Array })
270
+ ], i.prototype, "errors", 2);
271
+ a([
272
+ s({ type: Boolean })
273
+ ], i.prototype, "touched", 2);
274
+ a([
275
+ s({ type: Boolean })
276
+ ], i.prototype, "required", 2);
277
+ a([
278
+ s({ type: Boolean })
279
+ ], i.prototype, "disabled", 2);
280
+ a([
281
+ s({ type: Boolean, attribute: "readonly" })
282
+ ], i.prototype, "readOnly", 2);
283
+ a([
284
+ s({ type: String, attribute: "prev-month-icon" })
285
+ ], i.prototype, "prevMonthIcon", 2);
286
+ a([
287
+ s({ type: String, attribute: "next-month-icon" })
288
+ ], i.prototype, "nextMonthIcon", 2);
289
+ a([
290
+ s({ type: String, attribute: "prev-month-aria-label" })
291
+ ], i.prototype, "prevMonthAriaLabel", 2);
292
+ a([
293
+ s({ type: String, attribute: "next-month-aria-label" })
294
+ ], i.prototype, "nextMonthAriaLabel", 2);
295
+ a([
296
+ s({ type: String })
297
+ ], i.prototype, "dayFormat", 2);
298
+ a([
299
+ s({ type: String })
300
+ ], i.prototype, "weekdayFormat", 2);
301
+ a([
302
+ s({ type: String })
303
+ ], i.prototype, "monthFormat", 2);
304
+ a([
305
+ s({ type: String })
306
+ ], i.prototype, "minDate", 2);
307
+ a([
308
+ s({ type: String })
309
+ ], i.prototype, "maxDate", 2);
310
+ a([
311
+ s({ type: Array })
312
+ ], i.prototype, "disabledRanges", 2);
313
+ a([
314
+ s({ type: Number })
315
+ ], i.prototype, "numberOfMonths", 2);
316
+ a([
317
+ s({ type: String })
318
+ ], i.prototype, "value", 2);
319
+ a([
320
+ s({ type: String, attribute: "hour-format" })
321
+ ], i.prototype, "hourFormat", 2);
322
+ a([
323
+ s({ type: Number, attribute: "minute-step" })
324
+ ], i.prototype, "minuteStep", 2);
325
+ a([
326
+ s({ type: String, attribute: "min-time" })
327
+ ], i.prototype, "minTime", 2);
328
+ a([
329
+ s({ type: String, attribute: "max-time" })
330
+ ], i.prototype, "maxTime", 2);
331
+ a([
332
+ s({ type: Array, attribute: "disabled-time-ranges" })
333
+ ], i.prototype, "disabledTimeRanges", 2);
334
+ a([
335
+ s({ type: String, attribute: "min-time-message" })
336
+ ], i.prototype, "minTimeMessage", 2);
337
+ a([
338
+ s({ type: String, attribute: "max-time-message" })
339
+ ], i.prototype, "maxTimeMessage", 2);
340
+ a([
341
+ s({ type: String, attribute: "disabled-time-range-message" })
342
+ ], i.prototype, "disabledTimeRangeMessage", 2);
343
+ a([
344
+ s({ type: String, attribute: "no-available-times-message" })
345
+ ], i.prototype, "noAvailableTimesMessage", 2);
346
+ a([
347
+ s({ type: Boolean, attribute: "allow-custom-time" })
348
+ ], i.prototype, "allowCustomTime", 2);
349
+ a([
350
+ u()
351
+ ], i.prototype, "_selectedDate", 2);
352
+ a([
353
+ u()
354
+ ], i.prototype, "_selectedTime", 2);
355
+ a([
356
+ u()
357
+ ], i.prototype, "_timeGridOpen", 2);
358
+ i = a([
359
+ y("gui-date-time-calendar")
360
+ ], i);
361
+ typeof customElements < "u" && !customElements.get("gui-date-time-calendar") && customElements.define("gui-date-time-calendar", i);