@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,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);
@@ -0,0 +1,380 @@
1
+ import { InputWidgetAdapter as b, formContext as y, inputContext as $ } from "@golemui/lit";
2
+ import { LitElement as u, html as l, nothing as v } from "lit";
3
+ import { property as a, query as g, customElement as c } from "lit/decorators.js";
4
+ import { classMap as M } from "lit/directives/class-map.js";
5
+ import "./date-time-input-BXxsfuyZ.js";
6
+ import "./date-time-calendar-BzRfkLKU.js";
7
+ import { G as T } from "./popup.controller-eUDxE6jD.js";
8
+ import { t as f, d as x, b as D } from "./date-Bj9mI3GU.js";
9
+ import { p as S, y as w, h as R, z as _ } from "./part-templates-Db871PS3.js";
10
+ import { a as I, b as C, c as A } from "./templates-Dk1jxLwS.js";
11
+ import { consume as E, provide as F } from "@lit/context";
12
+ import "rxjs";
13
+ var O = Object.defineProperty, k = Object.getOwnPropertyDescriptor, i = (e, s, n, r) => {
14
+ for (var o = r > 1 ? void 0 : r ? k(s, n) : s, d = e.length - 1, m; d >= 0; d--)
15
+ (m = e[d]) && (o = (r ? m(s, n, o) : m(o)) || o);
16
+ return r && o && O(s, n, o), o;
17
+ };
18
+ let t = class extends u {
19
+ constructor() {
20
+ 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.hourFormat = void 0, this.minuteStep = void 0, this.minTime = void 0, this.maxTime = void 0, this.disabledTimeRanges = void 0, this.allowCustomTime = !1, this.invalidDateMessage = void 0, this.minDateMessage = void 0, this.maxDateMessage = void 0, this.disabledDateRangeMessage = void 0, this.minTimeMessage = void 0, this.maxTimeMessage = void 0, this.disabledTimeRangeMessage = void 0, this.noAvailableTimesMessage = void 0, this._popup = new T(this, {
21
+ getInteriorElements: () => [this._dateRef, this._calendarRef],
22
+ focusRestoreSelector: "gui-date-time input",
23
+ isDisabled: () => !!this.disabled,
24
+ clickIntent: (e) => e.closest(".gui-calendar__day-button") || e.closest(".gui-time-list__option") ? "ignore" : e.closest(".gui-date-time-input__part") || e.closest("gui-date-time-calendar") ? "open" : "toggle",
25
+ keyToggleMode: "toggle"
26
+ });
27
+ }
28
+ createRenderRoot() {
29
+ return this;
30
+ }
31
+ render() {
32
+ const e = I("datePicker", { icon: this.icon }), s = this._popup.open ? l`<gui-date-time-calendar
33
+ id="calendar-input"
34
+ .uid=${this.uid}
35
+ .hint=${this.hint}
36
+ ?touched=${this.touched}
37
+ ?required=${this.required}
38
+ ?disabled=${this.disabled}
39
+ ?readonly=${this.readOnly}
40
+ .value=${this.value}
41
+ .prevMonthIcon=${this.prevMonthIcon}
42
+ .nextMonthIcon=${this.nextMonthIcon}
43
+ .prevMonthAriaLabel=${this.prevMonthAriaLabel}
44
+ .nextMonthAriaLabel=${this.nextMonthAriaLabel}
45
+ .dayFormat=${this.dayFormat}
46
+ .weekdayFormat=${this.weekdayFormat}
47
+ .monthFormat=${this.monthFormat}
48
+ .minDate=${this.minDate}
49
+ .maxDate=${this.maxDate}
50
+ .disabledRanges=${this.disabledRanges}
51
+ .numberOfMonths=${this.numberOfMonths}
52
+ .localeId=${this.localeId}
53
+ .hourFormat=${this.hourFormat}
54
+ .minuteStep=${this.minuteStep}
55
+ .minTime=${this.minTime}
56
+ .maxTime=${this.maxTime}
57
+ .disabledTimeRanges=${this.disabledTimeRanges}
58
+ .allowCustomTime=${this.allowCustomTime}
59
+ .minTimeMessage=${this.minTimeMessage}
60
+ .maxTimeMessage=${this.maxTimeMessage}
61
+ .disabledTimeRangeMessage=${this.disabledTimeRangeMessage}
62
+ .noAvailableTimesMessage=${this.noAvailableTimesMessage}
63
+ @blur=${this.onCalendarBlur}
64
+ @change=${this.onCalendarChange}
65
+ ></gui-date-time-calendar>` : v;
66
+ return l`
67
+ ${C(this.uid ?? "", {
68
+ label: this.label,
69
+ hint: this.hint,
70
+ required: this.required
71
+ })}
72
+
73
+ <div
74
+ role="button"
75
+ tabindex="-1"
76
+ class="gui-widget"
77
+ aria-expanded=${this._popup.open}
78
+ @keyup=${this._popup.onAnchorKeyUp}
79
+ @keydown=${this._popup.onAnchorKeyDown}
80
+ @click=${this._popup.onAnchorClick}
81
+ >
82
+ <gui-date-time
83
+ id="date-input"
84
+ class=${M(e.widgetClasses)}
85
+ .uid=${this.uid}
86
+ .hint=${this.hint}
87
+ .showErrors=${!1}
88
+ .errors=${this.errors}
89
+ ?touched=${this.touched}
90
+ ?required=${this.required}
91
+ ?disabled=${this.disabled}
92
+ ?readonly=${this.readOnly}
93
+ .value=${this.value}
94
+ .icon=${this.icon}
95
+ .localeId=${this.localeId}
96
+ .hourFormat=${this.hourFormat}
97
+ .minuteStep=${this.minuteStep}
98
+ .minTime=${this.minTime}
99
+ .maxTime=${this.maxTime}
100
+ .invalidDateMessage=${this.invalidDateMessage}
101
+ .minTimeMessage=${this.minTimeMessage}
102
+ .maxTimeMessage=${this.maxTimeMessage}
103
+ @blur=${this.onDateBlur}
104
+ @focus=${this._popup.show}
105
+ @change=${this.onDateChange}
106
+ ></gui-date-time>
107
+ <span class="gui-date-time-picker__arrow"
108
+ ><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 256 256">
109
+ <path
110
+ 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"
111
+ ></path></svg
112
+ ></span>
113
+
114
+ ${s}
115
+ </div>
116
+
117
+ ${this.showErrors ? A(this.uid ?? "", { errors: this.errors, touched: this.touched }) : ""}
118
+ `;
119
+ }
120
+ onDateChange(e) {
121
+ e.stopPropagation(), this.commitValue(e.detail.value);
122
+ }
123
+ onDateBlur() {
124
+ this.dispatchEvent(new CustomEvent("blur"));
125
+ }
126
+ onCalendarChange(e) {
127
+ if (!this._popup.open) {
128
+ e.stopPropagation();
129
+ return;
130
+ }
131
+ e.stopPropagation(), this.commitValue(e.detail.value), e.detail.value && e.detail.commit && this._popup.close();
132
+ }
133
+ commitValue(e) {
134
+ this.value = e ?? void 0;
135
+ const s = this.validateBounds(this.value);
136
+ this.dispatchEvent(
137
+ new CustomEvent("change", {
138
+ detail: { value: e ?? null },
139
+ bubbles: !0,
140
+ composed: !0
141
+ })
142
+ ), s && this.dispatchEvent(
143
+ new CustomEvent("inputError", {
144
+ detail: { message: s },
145
+ bubbles: !0,
146
+ composed: !0
147
+ })
148
+ );
149
+ }
150
+ validateBounds(e) {
151
+ if (!e) return null;
152
+ const s = S(e);
153
+ if (isNaN(s.getTime())) return null;
154
+ const n = f(s), r = x(n, this.minDate, this.maxDate, this.disabledRanges, {
155
+ minDateMessage: this.minDateMessage,
156
+ maxDateMessage: this.maxDateMessage,
157
+ disabledDateRangeMessage: this.disabledDateRangeMessage
158
+ });
159
+ if (r) return r;
160
+ const o = w(this.disabledTimeRanges, n);
161
+ return R(_(s), o) ? this.disabledTimeRangeMessage ?? D : null;
162
+ }
163
+ // The calendar's blur already bubbles up to the host, so only close here.
164
+ onCalendarBlur() {
165
+ this._popup.close();
166
+ }
167
+ };
168
+ i([
169
+ a({ type: String })
170
+ ], t.prototype, "uid", 2);
171
+ i([
172
+ a({ type: String })
173
+ ], t.prototype, "label", 2);
174
+ i([
175
+ a({ type: String })
176
+ ], t.prototype, "hint", 2);
177
+ i([
178
+ a({ type: String })
179
+ ], t.prototype, "icon", 2);
180
+ i([
181
+ a({ type: Array })
182
+ ], t.prototype, "errors", 2);
183
+ i([
184
+ a({ type: Boolean })
185
+ ], t.prototype, "showErrors", 2);
186
+ i([
187
+ a({ type: Boolean })
188
+ ], t.prototype, "touched", 2);
189
+ i([
190
+ a({ type: Boolean })
191
+ ], t.prototype, "required", 2);
192
+ i([
193
+ a({ type: Boolean })
194
+ ], t.prototype, "disabled", 2);
195
+ i([
196
+ a({ type: Boolean, attribute: "readonly" })
197
+ ], t.prototype, "readOnly", 2);
198
+ i([
199
+ a({ type: String, attribute: "locale-id" })
200
+ ], t.prototype, "localeId", 2);
201
+ i([
202
+ a({ type: String })
203
+ ], t.prototype, "value", 2);
204
+ i([
205
+ a({ type: String, attribute: "prev-month-icon" })
206
+ ], t.prototype, "prevMonthIcon", 2);
207
+ i([
208
+ a({ type: String, attribute: "next-month-icon" })
209
+ ], t.prototype, "nextMonthIcon", 2);
210
+ i([
211
+ a({ type: String, attribute: "prev-month-aria-label" })
212
+ ], t.prototype, "prevMonthAriaLabel", 2);
213
+ i([
214
+ a({ type: String, attribute: "next-month-aria-label" })
215
+ ], t.prototype, "nextMonthAriaLabel", 2);
216
+ i([
217
+ a({ type: String, attribute: "day-format" })
218
+ ], t.prototype, "dayFormat", 2);
219
+ i([
220
+ a({ type: String, attribute: "weekday-format" })
221
+ ], t.prototype, "weekdayFormat", 2);
222
+ i([
223
+ a({ type: String, attribute: "month-format" })
224
+ ], t.prototype, "monthFormat", 2);
225
+ i([
226
+ a({ type: String, attribute: "min-date" })
227
+ ], t.prototype, "minDate", 2);
228
+ i([
229
+ a({ type: String, attribute: "max-date" })
230
+ ], t.prototype, "maxDate", 2);
231
+ i([
232
+ a({ type: Array, attribute: "disabled-ranges" })
233
+ ], t.prototype, "disabledRanges", 2);
234
+ i([
235
+ a({ type: Number, attribute: "number-of-months" })
236
+ ], t.prototype, "numberOfMonths", 2);
237
+ i([
238
+ a({ type: String, attribute: "hour-format" })
239
+ ], t.prototype, "hourFormat", 2);
240
+ i([
241
+ a({ type: Number, attribute: "minute-step" })
242
+ ], t.prototype, "minuteStep", 2);
243
+ i([
244
+ a({ type: String, attribute: "min-time" })
245
+ ], t.prototype, "minTime", 2);
246
+ i([
247
+ a({ type: String, attribute: "max-time" })
248
+ ], t.prototype, "maxTime", 2);
249
+ i([
250
+ a({ type: Array, attribute: "disabled-time-ranges" })
251
+ ], t.prototype, "disabledTimeRanges", 2);
252
+ i([
253
+ a({ type: Boolean, attribute: "allow-custom-time" })
254
+ ], t.prototype, "allowCustomTime", 2);
255
+ i([
256
+ a({ type: String, attribute: "invalid-date-message" })
257
+ ], t.prototype, "invalidDateMessage", 2);
258
+ i([
259
+ a({ type: String, attribute: "min-date-message" })
260
+ ], t.prototype, "minDateMessage", 2);
261
+ i([
262
+ a({ type: String, attribute: "max-date-message" })
263
+ ], t.prototype, "maxDateMessage", 2);
264
+ i([
265
+ a({ type: String, attribute: "disabled-date-range-message" })
266
+ ], t.prototype, "disabledDateRangeMessage", 2);
267
+ i([
268
+ a({ type: String, attribute: "min-time-message" })
269
+ ], t.prototype, "minTimeMessage", 2);
270
+ i([
271
+ a({ type: String, attribute: "max-time-message" })
272
+ ], t.prototype, "maxTimeMessage", 2);
273
+ i([
274
+ a({ type: String, attribute: "disabled-time-range-message" })
275
+ ], t.prototype, "disabledTimeRangeMessage", 2);
276
+ i([
277
+ a({ type: String, attribute: "no-available-times-message" })
278
+ ], t.prototype, "noAvailableTimesMessage", 2);
279
+ i([
280
+ g("#date-input")
281
+ ], t.prototype, "_dateRef", 2);
282
+ i([
283
+ g("#calendar-input")
284
+ ], t.prototype, "_calendarRef", 2);
285
+ t = i([
286
+ c("gui-date-time-picker")
287
+ ], t);
288
+ typeof customElements < "u" && !customElements.get("gui-date-time-picker") && customElements.define("gui-date-time-picker", t);
289
+ var L = Object.defineProperty, P = Object.getOwnPropertyDescriptor, h = (e, s, n, r) => {
290
+ for (var o = r > 1 ? void 0 : r ? P(s, n) : s, d = e.length - 1, m; d >= 0; d--)
291
+ (m = e[d]) && (o = (r ? m(s, n, o) : m(o)) || o);
292
+ return r && o && L(s, n, o), o;
293
+ };
294
+ let p = class extends u {
295
+ constructor() {
296
+ super(...arguments), this.adapter = new b(), this.subscriptions = [];
297
+ }
298
+ createRenderRoot() {
299
+ return this;
300
+ }
301
+ updated(e) {
302
+ super.updated(e);
303
+ const s = this.adapter.templateData.size;
304
+ s ? this.style.flex = String(s) : this.style.removeProperty("flex");
305
+ }
306
+ connectedCallback() {
307
+ super.connectedCallback(), this.classList.add("gui-date-time-picker", "gui-field"), this.adapter.context = this.formContext, this.adapter.init(this.widget), this.subscriptions.push(
308
+ this.adapter.templateDataChanged$.subscribe(() => this.requestUpdate())
309
+ );
310
+ }
311
+ render() {
312
+ super.render();
313
+ const e = this.adapter.templateData;
314
+ return l`
315
+ <gui-date-time-picker
316
+ .uid=${this.widget.uid}
317
+ .label=${e.label}
318
+ .hint=${e.hint}
319
+ .errors=${e.errors}
320
+ ?touched=${e.touched}
321
+ ?required=${e.validator?.required}
322
+ ?disabled=${e.disabled}
323
+ ?readonly=${e.readonly}
324
+ .value=${e.value}
325
+ .icon=${e.icon}
326
+ .localeId=${e.lang}
327
+ .prevMonthIcon=${e.prevMonthIcon}
328
+ .nextMonthIcon=${e.nextMonthIcon}
329
+ .prevMonthAriaLabel=${e.prevMonthAriaLabel}
330
+ .nextMonthAriaLabel=${e.nextMonthAriaLabel}
331
+ .dayFormat=${e.dayFormat}
332
+ .weekdayFormat=${e.weekdayFormat}
333
+ .monthFormat=${e.monthFormat}
334
+ .minDate=${e.minDate}
335
+ .maxDate=${e.maxDate}
336
+ .disabledRanges=${e.disabledRanges}
337
+ .numberOfMonths=${e.numberOfMonths}
338
+ .hourFormat=${e.hourFormat}
339
+ .minuteStep=${e.minuteStep}
340
+ .minTime=${e.minTime}
341
+ .maxTime=${e.maxTime}
342
+ .disabledTimeRanges=${e.disabledTimeRanges}
343
+ ?allow-custom-time=${e.allowCustomTime}
344
+ .invalidDateMessage=${e.invalidDateMessage}
345
+ .minDateMessage=${e.minDateMessage}
346
+ .maxDateMessage=${e.maxDateMessage}
347
+ .disabledDateRangeMessage=${e.disabledDateRangeMessage}
348
+ .minTimeMessage=${e.minTimeMessage}
349
+ .maxTimeMessage=${e.maxTimeMessage}
350
+ .disabledTimeRangeMessage=${e.disabledTimeRangeMessage}
351
+ .noAvailableTimesMessage=${e.noAvailableTimesMessage}
352
+ @inputError=${this.onInputError}
353
+ @blur=${() => this.adapter.onBlur()}
354
+ @change=${this.valueChanged}
355
+ ></gui-date-time-picker>
356
+ `;
357
+ }
358
+ valueChanged(e) {
359
+ this.adapter.injectValidationIssues(null), this.adapter.valueChanged(e.detail.value);
360
+ }
361
+ onInputError(e) {
362
+ this.adapter.injectValidationIssues([e.detail.message]);
363
+ }
364
+ disconnectedCallback() {
365
+ super.disconnectedCallback(), this.adapter.destroy(), this.subscriptions.forEach((e) => e.unsubscribe());
366
+ }
367
+ };
368
+ h([
369
+ E({ context: y }),
370
+ a({ attribute: !1 })
371
+ ], p.prototype, "formContext", 2);
372
+ h([
373
+ F({ context: $ })
374
+ ], p.prototype, "adapter", 2);
375
+ p = h([
376
+ c("gui-date-time-picker-input")
377
+ ], p);
378
+ export {
379
+ p as DateTimePickerElement
380
+ };