@golemui/gui-lit 1.0.2 → 1.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/calendar-BuJgwvZx.js +254 -0
  3. package/{calendar.element-MubSE1bx.js → calendar.element-M5MPJmap.js} +1 -1
  4. package/{currency.element-BHXWcOEu.js → currency.element-CfFrAtrr.js} +20 -14
  5. package/{date-DTYg8sog.js → date-Bj9mI3GU.js} +106 -50
  6. package/date-input-cJDkNnVw.js +184 -0
  7. package/date-picker.element-va_-LGZD.js +312 -0
  8. package/date-time-calendar-BzRfkLKU.js +361 -0
  9. package/date-time-calendar.element-DC4NK0y1.js +93 -0
  10. package/date-time-input-BXxsfuyZ.js +214 -0
  11. package/date-time-picker.element-Dy-8cb-_.js +380 -0
  12. package/date-time.element-Bv4XdzMi.js +87 -0
  13. package/{date.element-BtVJSIRk.js → date.element-Consgsbb.js} +32 -27
  14. package/day-status-0-hJHrI7.js +530 -0
  15. package/{dropdown.element-DqzC6aXR.js → dropdown.element-WsD61Qel.js} +57 -48
  16. package/focus-leave.controller-2gV0pQd5.js +73 -0
  17. package/index.js +1209 -981
  18. package/index.umd.cjs +1574 -519
  19. package/lib/components/date-picker.element.d.ts +0 -11
  20. package/lib/components/date-time-calendar.element.d.ts +18 -0
  21. package/lib/components/date-time-picker.element.d.ts +18 -0
  22. package/lib/components/date-time.element.d.ts +18 -0
  23. package/lib/components/dropdown.element.d.ts +2 -0
  24. package/lib/components/range-calendar.element.d.ts +2 -1
  25. package/lib/components/range-date-picker.element.d.ts +0 -15
  26. package/lib/components/range-date-time-calendar.element.d.ts +18 -0
  27. package/lib/components/range-date-time-input.element.d.ts +18 -0
  28. package/lib/components/range-date-time-picker.element.d.ts +18 -0
  29. package/lib/components/range-time-input.element.d.ts +18 -0
  30. package/lib/components/range-time-picker.element.d.ts +18 -0
  31. package/lib/components/time-picker.element.d.ts +18 -0
  32. package/lib/components/time.element.d.ts +18 -0
  33. package/{list-D1oKnH89.js → list-CrLIL4by.js} +76 -61
  34. package/{list.element-Co3V3Cn5.js → list.element-DV82YxnJ.js} +22 -22
  35. package/{number.element-BhEyoOtc.js → number.element-CBr47IiY.js} +18 -16
  36. package/numeric-jmOOKz30.js +12 -0
  37. package/package.json +6 -6
  38. package/part-templates-Db871PS3.js +677 -0
  39. package/pill-ranges-DCqDmpkk.js +48 -0
  40. package/{pills-B66qz_KX.js → pills-Be1UrLgq.js} +4 -1
  41. package/popup.controller-eUDxE6jD.js +71 -0
  42. package/range-calendar-CKPYeSGt.js +452 -0
  43. package/{range-calendar.element-QTE6vGNP.js → range-calendar.element-D6KYq18B.js} +24 -20
  44. package/range-commit-8-MmYUyo.js +14 -0
  45. package/range-date-input-D--AqBMv.js +292 -0
  46. package/{range-date-input.element-Dj29D_OQ.js → range-date-input.element-D4nIXJbw.js} +8 -7
  47. package/range-date-picker.element-dhxPAAE6.js +386 -0
  48. package/range-date-time-calendar-yksWrR7b.js +720 -0
  49. package/range-date-time-calendar.element-C00aDefZ.js +95 -0
  50. package/range-date-time-input-B37TUoM3.js +322 -0
  51. package/range-date-time-input.element-DUnbv4ed.js +81 -0
  52. package/range-date-time-picker.element-Cbps6s_G.js +412 -0
  53. package/range-selection-CU3hxLJE.js +25 -0
  54. package/range-time-input-3lhqR1Ku.js +329 -0
  55. package/range-time-input.element-dU2iBdmJ.js +81 -0
  56. package/range-time-picker.element-v6nQsIPw.js +429 -0
  57. package/{select.element-jcDF1h-g.js → select.element-C0V-Bv3L.js} +94 -90
  58. package/{tags.element-CX3vQL8L.js → tags.element-DvwEpxpK.js} +1 -1
  59. package/time-input-BOhlBGJZ.js +181 -0
  60. package/time-list-Czo48bZm.js +217 -0
  61. package/time-picker-bFJ63ky8.js +261 -0
  62. package/time-picker.element-CYZVXgRS.js +85 -0
  63. package/time.element-fK3oLi49.js +82 -0
  64. package/abstract-calendar-BoqKPRmS.js +0 -545
  65. package/calendar-DTYKVYc3.js +0 -96
  66. package/date-input-BeQvyfln.js +0 -268
  67. package/date-picker.element-DabW_-0-.js +0 -166
  68. package/range-calendar-9skwbwlB.js +0 -255
  69. package/range-date-input-Uy8134vi.js +0 -395
  70. package/range-date-picker.element-CuKIBkIO.js +0 -182
@@ -0,0 +1,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);
@@ -0,0 +1,93 @@
1
+ import { InputWidgetAdapter as l, formContext as m, inputContext as p } from "@golemui/lit";
2
+ import "./date-time-calendar-BzRfkLKU.js";
3
+ import { consume as u, provide as h } from "@lit/context";
4
+ import { LitElement as c, html as $ } from "lit";
5
+ import { property as b, customElement as g } from "lit/decorators.js";
6
+ import "rxjs";
7
+ var v = Object.defineProperty, x = Object.getOwnPropertyDescriptor, d = (e, t, s, r) => {
8
+ for (var a = r > 1 ? void 0 : r ? x(t, s) : t, n = e.length - 1, o; n >= 0; n--)
9
+ (o = e[n]) && (a = (r ? o(t, s, a) : o(a)) || a);
10
+ return r && a && v(t, s, a), a;
11
+ };
12
+ let i = class extends c {
13
+ constructor() {
14
+ super(...arguments), this.adapter = new l(), this.subscriptions = [];
15
+ }
16
+ createRenderRoot() {
17
+ return this;
18
+ }
19
+ updated(e) {
20
+ super.updated(e);
21
+ const t = this.adapter.templateData.size;
22
+ t ? this.style.flex = String(t) : this.style.removeProperty("flex");
23
+ }
24
+ connectedCallback() {
25
+ super.connectedCallback(), this.classList.add("gui-date-time-calendar", "gui-field"), this.adapter.context = this.formContext, this.adapter.init(this.widget), this.subscriptions.push(
26
+ this.adapter.templateDataChanged$.subscribe(() => this.requestUpdate())
27
+ );
28
+ }
29
+ render() {
30
+ super.render();
31
+ const e = this.adapter.templateData;
32
+ return $`
33
+ <gui-date-time-calendar
34
+ .uid=${this.widget.uid}
35
+ .label=${e.label}
36
+ .hint=${e.hint}
37
+ .errors=${e.errors}
38
+ ?touched=${e.touched}
39
+ ?required=${e.validator?.required}
40
+ ?disabled=${e.disabled}
41
+ ?readonly=${e.readonly}
42
+ .value=${e.value}
43
+ .prevMonthIcon=${e.prevMonthIcon}
44
+ .nextMonthIcon=${e.nextMonthIcon}
45
+ .prevMonthAriaLabel=${e.prevMonthAriaLabel}
46
+ .nextMonthAriaLabel=${e.nextMonthAriaLabel}
47
+ .dayFormat=${e.dayFormat}
48
+ .weekdayFormat=${e.weekdayFormat}
49
+ .monthFormat=${e.monthFormat}
50
+ .minDate=${e.minDate}
51
+ .maxDate=${e.maxDate}
52
+ .disabledRanges=${e.disabledRanges}
53
+ .numberOfMonths=${e.numberOfMonths}
54
+ .localeId=${e.lang}
55
+ .hourFormat=${e.hourFormat}
56
+ .minuteStep=${e.minuteStep}
57
+ .minTime=${e.minTime}
58
+ .maxTime=${e.maxTime}
59
+ .disabledTimeRanges=${e.disabledTimeRanges}
60
+ ?allow-custom-time=${e.allowCustomTime}
61
+ .minTimeMessage=${e.minTimeMessage}
62
+ .maxTimeMessage=${e.maxTimeMessage}
63
+ .disabledTimeRangeMessage=${e.disabledTimeRangeMessage}
64
+ .noAvailableTimesMessage=${e.noAvailableTimesMessage}
65
+ @change=${this.valueChanged}
66
+ @inputError=${this.onInputError}
67
+ @blur=${() => this.adapter.onBlur()}
68
+ ></gui-date-time-calendar>
69
+ `;
70
+ }
71
+ valueChanged(e) {
72
+ this.adapter.injectValidationIssues(null), this.adapter.valueChanged(e.detail.value);
73
+ }
74
+ onInputError(e) {
75
+ this.adapter.injectValidationIssues([e.detail.message]);
76
+ }
77
+ disconnectedCallback() {
78
+ super.disconnectedCallback(), this.adapter.destroy(), this.subscriptions.forEach((e) => e.unsubscribe());
79
+ }
80
+ };
81
+ d([
82
+ u({ context: m }),
83
+ b({ attribute: !1 })
84
+ ], i.prototype, "formContext", 2);
85
+ d([
86
+ h({ context: p })
87
+ ], i.prototype, "adapter", 2);
88
+ i = d([
89
+ g("gui-date-time-calendar-input")
90
+ ], i);
91
+ export {
92
+ i as DateTimeCalendarElement
93
+ };
@@ -0,0 +1,214 @@
1
+ import { LitElement as h, nothing as u, html as p } from "lit";
2
+ import { property as i, customElement as m } from "lit/decorators.js";
3
+ import { classMap as c } from "lit/directives/class-map.js";
4
+ import { G as g, b as y, c as v } from "./templates-Dk1jxLwS.js";
5
+ import { G as b, g as D, w as f, z as E, a as S, r as T, b as M } from "./part-templates-Db871PS3.js";
6
+ import { d as x } from "./date-Bj9mI3GU.js";
7
+ var w = Object.defineProperty, C = Object.getOwnPropertyDescriptor, e = (s, r, n, a) => {
8
+ for (var o = a > 1 ? void 0 : a ? C(r, n) : r, l = s.length - 1, d; l >= 0; l--)
9
+ (d = s[l]) && (o = (a ? d(r, n, o) : d(o)) || o);
10
+ return a && o && w(r, n, o), o;
11
+ };
12
+ let t = class extends h {
13
+ constructor() {
14
+ super(...arguments), this.uid = void 0, this.label = void 0, this.localeId = void 0, this.errors = [], this.showErrors = !0, this.touched = !1, this.required = !1, this.disabled = !1, this.readOnly = !1, this.icon = "", this.hint = void 0, this.hourFormat = void 0, this.minuteStep = 1, this.invalidDateMessage = void 0, this.value = void 0, this.minDate = void 0, this.maxDate = void 0, this.minTime = void 0, this.maxTime = void 0, this.minDateMessage = void 0, this.maxDateMessage = void 0, this.minTimeMessage = void 0, this.maxTimeMessage = void 0, this.inputBlockClass = "gui-date-time-input", this.groups = ["default"], this._parts = new b(this, {
15
+ blockClass: this.inputBlockClass,
16
+ groups: this.groups,
17
+ getDescriptor: (s) => this.getPartDescriptor(s),
18
+ commitGroup: (s) => this.validateAndEmit(s),
19
+ isReadonly: () => !!this.readOnly,
20
+ isDisabled: () => !!this.disabled,
21
+ onEmptyPartBlur: () => this.dispatchEvent(new CustomEvent("change", { detail: { value: null }, bubbles: !0 })),
22
+ getHourFormat: () => this.localeData.effectiveHourFormat,
23
+ getDayPeriodLabels: () => this.localeData.dayPeriodLabels
24
+ }), this.ariaController = new g(this, {
25
+ getTargets: () => this.querySelectorAll(`.${this.inputBlockClass}`),
26
+ getState: () => ({
27
+ uid: this.uid,
28
+ templateData: {
29
+ hint: this.hint,
30
+ errors: this.errors,
31
+ readonly: this.readOnly,
32
+ disabled: this.disabled,
33
+ touched: this.touched
34
+ }
35
+ })
36
+ });
37
+ }
38
+ createRenderRoot() {
39
+ return this;
40
+ }
41
+ connectedCallback() {
42
+ super.connectedCallback(), this.classList.add("gui-field");
43
+ }
44
+ get localeData() {
45
+ return D(this.localeId, this.hourFormat, this.minuteStep, !0);
46
+ }
47
+ getPartDescriptor(s) {
48
+ return this.localeData.descriptors[s];
49
+ }
50
+ /**
51
+ * Constrains the date and time axes independently: `minDate`/`maxDate` bound
52
+ * the day, `minTime`/`maxTime` bound the time-of-day on every allowed day.
53
+ */
54
+ boundsError(s, r) {
55
+ return x(s, this.minDate, this.maxDate, void 0, {
56
+ minDateMessage: this.minDateMessage,
57
+ maxDateMessage: this.maxDateMessage
58
+ }) ?? f(E(r), {
59
+ minTime: this.minTime,
60
+ maxTime: this.maxTime,
61
+ minTimeMessage: this.minTimeMessage,
62
+ maxTimeMessage: this.maxTimeMessage
63
+ });
64
+ }
65
+ willUpdate(s) {
66
+ (!this.hasUpdated || s.has("value") || s.has("hourFormat") || s.has("localeId")) && this._parts.setGroupFromISO(
67
+ "default",
68
+ this.value ?? "",
69
+ "dateTime",
70
+ this.localeData.effectiveHourFormat
71
+ );
72
+ }
73
+ render() {
74
+ const s = {
75
+ uid: this.uid,
76
+ label: this.label,
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
+ hint: this.hint
85
+ }, r = {
86
+ blockClass: this.inputBlockClass,
87
+ groups: this.groups,
88
+ formatParts: S(this.localeId, this.localeData.effectiveHourFormat),
89
+ getDescriptor: (a) => this.getPartDescriptor(a),
90
+ getDisplayValue: this._parts.getPartDisplay,
91
+ required: this.required,
92
+ disabled: this.disabled,
93
+ partsReadonly: !!this.readOnly
94
+ }, n = {
95
+ "gui-widget-icon": !0,
96
+ [this.icon]: !0
97
+ };
98
+ return p`
99
+ ${this.label ? y(this.uid, s) : u}
100
+
101
+ <div class="gui-widget">
102
+ <div
103
+ class="gui-widget-input gui-parts gui-parts-ring gui-date-time-input ${this.icon ? "gui-calendar--icon" : ""}"
104
+ role="group"
105
+ >
106
+ ${T("default", r, this._parts)}
107
+ </div>
108
+ ${this.icon ? p`<span class=${c(n)} data-icon=${this.icon}></span>` : u}
109
+ </div>
110
+
111
+ ${this.showErrors && this.errors?.length ? v(this.uid, s) : u}
112
+ `;
113
+ }
114
+ validateAndEmit(s) {
115
+ const { effectiveHourFormat: r, descriptors: n } = this.localeData, { result: a, writeBacks: o } = M(this._parts.values[s] ?? {}, {
116
+ hourFormat: r,
117
+ descriptors: n,
118
+ invalidDateMessage: this.invalidDateMessage
119
+ });
120
+ if (this._parts.applyWriteBacks(s, o), a.kind === "incomplete") {
121
+ this.requestUpdate();
122
+ return;
123
+ }
124
+ if (a.kind === "invalid") {
125
+ this.dispatchEvent(
126
+ new CustomEvent("inputError", { detail: { message: a.message }, bubbles: !0 })
127
+ ), this.requestUpdate();
128
+ return;
129
+ }
130
+ const l = this.boundsError(a.iso, a.instant);
131
+ if (l) {
132
+ this.dispatchEvent(
133
+ new CustomEvent("change", { detail: { value: a.iso }, bubbles: !0 })
134
+ ), this.dispatchEvent(
135
+ new CustomEvent("inputError", { detail: { message: l }, bubbles: !0 })
136
+ ), this.requestUpdate();
137
+ return;
138
+ }
139
+ this.value = a.iso, this.dispatchEvent(new CustomEvent("change", { detail: { value: this.value }, bubbles: !0 })), this.requestUpdate();
140
+ }
141
+ };
142
+ e([
143
+ i({ type: String })
144
+ ], t.prototype, "uid", 2);
145
+ e([
146
+ i({ type: String })
147
+ ], t.prototype, "label", 2);
148
+ e([
149
+ i({ type: String, attribute: "locale-id" })
150
+ ], t.prototype, "localeId", 2);
151
+ e([
152
+ i({ type: Array })
153
+ ], t.prototype, "errors", 2);
154
+ e([
155
+ i({ type: Boolean })
156
+ ], t.prototype, "showErrors", 2);
157
+ e([
158
+ i({ type: Boolean })
159
+ ], t.prototype, "touched", 2);
160
+ e([
161
+ i({ type: Boolean })
162
+ ], t.prototype, "required", 2);
163
+ e([
164
+ i({ type: Boolean })
165
+ ], t.prototype, "disabled", 2);
166
+ e([
167
+ i({ type: Boolean, attribute: "readonly" })
168
+ ], t.prototype, "readOnly", 2);
169
+ e([
170
+ i({ type: String })
171
+ ], t.prototype, "icon", 2);
172
+ e([
173
+ i({ type: String })
174
+ ], t.prototype, "hint", 2);
175
+ e([
176
+ i({ type: String, attribute: "hour-format" })
177
+ ], t.prototype, "hourFormat", 2);
178
+ e([
179
+ i({ type: Number, attribute: "minute-step" })
180
+ ], t.prototype, "minuteStep", 2);
181
+ e([
182
+ i({ type: String, attribute: "invalid-date-message" })
183
+ ], t.prototype, "invalidDateMessage", 2);
184
+ e([
185
+ i({ type: String })
186
+ ], t.prototype, "value", 2);
187
+ e([
188
+ i({ type: String, attribute: "min-date" })
189
+ ], t.prototype, "minDate", 2);
190
+ e([
191
+ i({ type: String, attribute: "max-date" })
192
+ ], t.prototype, "maxDate", 2);
193
+ e([
194
+ i({ type: String, attribute: "min-time" })
195
+ ], t.prototype, "minTime", 2);
196
+ e([
197
+ i({ type: String, attribute: "max-time" })
198
+ ], t.prototype, "maxTime", 2);
199
+ e([
200
+ i({ type: String, attribute: "min-date-message" })
201
+ ], t.prototype, "minDateMessage", 2);
202
+ e([
203
+ i({ type: String, attribute: "max-date-message" })
204
+ ], t.prototype, "maxDateMessage", 2);
205
+ e([
206
+ i({ type: String, attribute: "min-time-message" })
207
+ ], t.prototype, "minTimeMessage", 2);
208
+ e([
209
+ i({ type: String, attribute: "max-time-message" })
210
+ ], t.prototype, "maxTimeMessage", 2);
211
+ t = e([
212
+ m("gui-date-time")
213
+ ], t);
214
+ typeof customElements < "u" && !customElements.get("gui-date-time") && customElements.define("gui-date-time", t);