@golemui/gui-lit 0.12.2 → 0.13.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/abstract-calendar-YDgwwbqe.js +528 -0
  3. package/{accordion.element-81uTv6Ms.js → accordion.element-ChLmV6QT.js} +24 -22
  4. package/{alert.element-DWrS5ggK.js → alert.element-9QFlqjj9.js} +23 -21
  5. package/button.element-ATNRRDN3.js +121 -0
  6. package/calendar-P9DzVryu.js +96 -0
  7. package/{calendar.element-C1rLK7aY.js → calendar.element-O2of7VBr.js} +25 -22
  8. package/checkbox.element-DMmer4Jw.js +199 -0
  9. package/currency.element-C7SZkoPP.js +266 -0
  10. package/date-CG1562vW.js +786 -0
  11. package/date-input-VJG8lMVN.js +266 -0
  12. package/{date-picker.element-GNC8f3Qi.js → date-picker.element-Bcyhc0fb.js} +29 -25
  13. package/{date.element-Dzw-UJzC.js → date.element-DfXmcgZi.js} +25 -22
  14. package/{dropdown.element-CebROj9s.js → dropdown.element-DCUI5Y7I.js} +24 -22
  15. package/errors-QjKhr6mA.js +109 -0
  16. package/{flex.element-BMqqfxjI.js → flex.element-B0sG0YT1.js} +24 -22
  17. package/{grid.element-CBMoOuLt.js → grid.element-Bf5aEjkj.js} +24 -22
  18. package/index.js +2708 -1174
  19. package/index.umd.cjs +982 -108
  20. package/lib/components/accordion.element.d.ts +7 -7
  21. package/lib/components/alert.element.d.ts +6 -6
  22. package/lib/components/button.element.d.ts +6 -6
  23. package/lib/components/calendar.element.d.ts +6 -6
  24. package/lib/components/checkbox.element.d.ts +6 -6
  25. package/lib/components/currency.element.d.ts +6 -6
  26. package/lib/components/date-picker.element.d.ts +6 -6
  27. package/lib/components/date.element.d.ts +6 -6
  28. package/lib/components/dropdown.element.d.ts +6 -6
  29. package/lib/components/flex.element.d.ts +6 -6
  30. package/lib/components/grid.element.d.ts +6 -6
  31. package/lib/components/list.element.d.ts +6 -6
  32. package/lib/components/markdown-text.element.d.ts +6 -6
  33. package/lib/components/markdown.element.d.ts +6 -6
  34. package/lib/components/number.element.d.ts +6 -6
  35. package/lib/components/password.element.d.ts +6 -6
  36. package/lib/components/radiogroup.element.d.ts +6 -6
  37. package/lib/components/range-calendar.element.d.ts +6 -6
  38. package/lib/components/range-date-input.element.d.ts +6 -6
  39. package/lib/components/range-date-picker.element.d.ts +6 -6
  40. package/lib/components/renderer.element.d.ts +6 -6
  41. package/lib/components/repeater.element.d.ts +6 -6
  42. package/lib/components/select.element.d.ts +6 -6
  43. package/lib/components/tabs.element.d.ts +6 -6
  44. package/lib/components/textarea.element.d.ts +6 -6
  45. package/lib/components/textinput.element.d.ts +6 -6
  46. package/lib/components/toggle.element.d.ts +6 -6
  47. package/lib/widget.loaders.d.ts +2 -2
  48. package/list-CtFsv7GB.js +284 -0
  49. package/{list.element-DIIgN_Ww.js → list.element-G8RNRZXU.js} +30 -27
  50. package/markdown-text-X-BRJT6K.js +30 -0
  51. package/{markdown-text.element-DY7b-dU5.js → markdown-text.element-C_1OqrGa.js} +23 -20
  52. package/markdown.element-CT1JOOM3.js +596 -0
  53. package/number.element-HaXEg_7U.js +282 -0
  54. package/one-of-DifUsEYY.js +48 -0
  55. package/package.json +6 -6
  56. package/password.element-B4-0SCe4.js +238 -0
  57. package/radiogroup.element-DzHLgRh1.js +232 -0
  58. package/range-calendar-qpakwAba.js +326 -0
  59. package/{range-calendar.element-Bli9UfhN.js → range-calendar.element-C-4qqRGK.js} +20 -17
  60. package/range-date-input-CrNpOVHt.js +507 -0
  61. package/{range-date-input.element-BwPvGk5F.js → range-date-input.element-Iq5Y7uLQ.js} +20 -17
  62. package/{range-date-picker.element-DJQOwDPh.js → range-date-picker.element-4bg4Uraq.js} +29 -25
  63. package/{renderer.element-B99qD2mz.js → renderer.element-DMsheQGi.js} +19 -17
  64. package/{repeater.element-AaifWsOB.js → repeater.element-Ry8HyMfW.js} +41 -27
  65. package/select.element-DuGZjlZY.js +257 -0
  66. package/tabs-DzSCq_98.js +13 -0
  67. package/{tabs.element-k8JMNDXi.js → tabs.element-VLrtF1j5.js} +31 -29
  68. package/templates-Dk1jxLwS.js +75 -0
  69. package/textarea.element-C8yx2u0o.js +237 -0
  70. package/textinput.element-DKuplF1A.js +204 -0
  71. package/toggle.element-NXRrhALB.js +201 -0
  72. package/button.element-hjhVBamJ.js +0 -56
  73. package/checkbox.element-bu9_MvED.js +0 -65
  74. package/currency.element-Bxv2WxAx.js +0 -72
  75. package/default-list-item-renderer-DNVEjKSX.js +0 -23
  76. package/markdown.element-ZD_n4ObO.js +0 -73
  77. package/number.element-B0E7W2TK.js +0 -70
  78. package/password.element-C4_eLdUO.js +0 -71
  79. package/radiogroup.element-BD8qBNoO.js +0 -68
  80. package/select.element-BLxtqB0A.js +0 -74
  81. package/textarea.element-DgDwfzYP.js +0 -70
  82. package/textinput.element-DSLFDjfb.js +0 -67
  83. package/toggle.element-BLu6F99u.js +0 -65
@@ -0,0 +1,507 @@
1
+ import { LitElement as w, nothing as g, html as p } from "lit";
2
+ import { property as h, state as y, customElement as D } from "lit/decorators.js";
3
+ import { live as P } from "lit/directives/live.js";
4
+ import { repeat as v } from "lit-html/directives/repeat.js";
5
+ import { classMap as m } from "lit/directives/class-map.js";
6
+ import { G as I, b as A, c as $ } from "./templates-Dk1jxLwS.js";
7
+ import { t as f, m as O } from "./date-CG1562vW.js";
8
+ import { c as b } from "./tabs-DzSCq_98.js";
9
+ import "@golemui/gui-shared";
10
+ var L = Object.defineProperty, S = Object.getOwnPropertyDescriptor, o = (t, e, i, a) => {
11
+ for (var s = a > 1 ? void 0 : a ? S(e, i) : e, r = t.length - 1, d; r >= 0; r--)
12
+ (d = t[r]) && (s = (a ? d(e, i, s) : d(s)) || s);
13
+ return a && s && L(e, i, s), s;
14
+ };
15
+ let l = class extends w {
16
+ constructor() {
17
+ 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.value = [], this.hint = void 0, this.icon = "", this.removePillAriaLabel = void 0, this.startDateAriaLabel = void 0, this.endDateAriaLabel = void 0, this.separator = void 0, this._startDate = { day: "", month: "", year: "" }, this._endDate = { day: "", month: "", year: "" }, this._isStartVisible = !0, this._isEndVisible = !0, this._showPillsList = !1, this.MIN_DAY = 1, this.MAX_DAY = 31, this.MAX_VALID_DAY = (t, e) => t === 2 ? new Date(e, 1, 29).getDate() === 29 || !e ? 29 : 28 : t === 4 || t === 6 || t === 9 || t === 11 ? 30 : 31, this.MIN_MONTH = 1, this.MAX_MONTH = 12, this.MIN_YEAR = 1e3, this.MAX_YEAR = 9999, this.ariaController = new I(this, {
18
+ getTargets: () => this.querySelectorAll(".gui-range-date-input"),
19
+ getState: () => ({
20
+ uid: this.uid,
21
+ templateData: {
22
+ hint: this.hint,
23
+ errors: this.errors,
24
+ readonly: this.readOnly,
25
+ disabled: this.disabled,
26
+ touched: this.touched
27
+ }
28
+ })
29
+ }), this.handleOutsideInteraction = (t) => {
30
+ const e = this.querySelector(".gui-range-date-input__pills-compact"), i = this.querySelector(".gui-range-date-input__pills-dropdown"), a = t.composedPath()[0];
31
+ !e?.contains(a) && !i?.contains(a) && (this._showPillsList = !1, this.removeOutsideListeners());
32
+ };
33
+ }
34
+ createRenderRoot() {
35
+ return this;
36
+ }
37
+ connectedCallback() {
38
+ super.connectedCallback(), this.classList.add("gui-field");
39
+ }
40
+ updated() {
41
+ this.setupObservers();
42
+ }
43
+ disconnectedCallback() {
44
+ super.disconnectedCallback(), this.disconnectObservers(), this.removeOutsideListeners();
45
+ }
46
+ render() {
47
+ const t = {
48
+ uid: this.uid,
49
+ label: this.label,
50
+ errors: this.errors,
51
+ touched: this.touched,
52
+ required: this.required,
53
+ disabled: this.disabled,
54
+ readonly: this.readOnly,
55
+ value: this.value,
56
+ hint: this.hint
57
+ }, e = new Intl.DateTimeFormat(this.localeId ?? "en", {
58
+ year: "numeric",
59
+ month: "numeric",
60
+ day: "numeric"
61
+ }).formatToParts(/* @__PURE__ */ new Date()), i = this.getSortedPills(), a = {
62
+ "gui-widget-icon": !0,
63
+ [this.icon]: !!this.icon
64
+ };
65
+ return p`
66
+ ${this.label ? A(this.uid, t, !1, void 0, !1) : g}
67
+
68
+ <div class="gui-widget">
69
+ <div
70
+ class="gui-range-date-input ${this.icon ? "gui-range-date-input--icon" : ""}"
71
+ role="group"
72
+ aria-label=${this.label ?? "Date range input"}
73
+ >
74
+ ${this.icon ? p`<span class=${m(a)} data-icon=${this.icon}></span>` : g}
75
+ ${i.length > 0 ? p`<div
76
+ class=${m({
77
+ "gui-range-date-input__pills-wrapper": !0,
78
+ "gui-range-date-input--start-shadow": !this._isStartVisible,
79
+ "gui-range-date-input--end-shadow": !this._isEndVisible
80
+ })}
81
+ >
82
+ <div class="gui-range-date-input__pills" role="list">
83
+ <span class="gui-sentinel gui-sentinel__start"></span>
84
+ ${v(
85
+ i,
86
+ (s) => `${s.start}-${s.end ?? s.start}`,
87
+ (s, r) => this.renderPill(s, r)
88
+ )}
89
+ <span class="gui-sentinel gui-sentinel__end"></span>
90
+ </div>
91
+ </div>
92
+ <div class="gui-range-date-input__pills-compact">
93
+ <button
94
+ type="button"
95
+ tabindex="0"
96
+ class="gui-range-date-input__pill--count"
97
+ aria-label="${i.length} date ranges"
98
+ @click=${this.togglePillsList}
99
+ >
100
+ ${i.length}
101
+ </button>
102
+ </div>` : g}
103
+
104
+ <div class="gui-range-date-input__inputs">
105
+ <div
106
+ class="gui-range-date-input__field"
107
+ role="group"
108
+ aria-label=${this.startDateAriaLabel ?? "Start date"}
109
+ >
110
+ ${this.renderDateInputs("start", e)}
111
+ </div>
112
+
113
+ <span class="gui-range-date-input__separator">${this.separator ?? "-"}</span>
114
+
115
+ <div
116
+ class="gui-range-date-input__field"
117
+ role="group"
118
+ aria-label=${this.endDateAriaLabel ?? "End date"}
119
+ >
120
+ ${this.renderDateInputs("end", e)}
121
+ </div>
122
+ </div>
123
+ </div>
124
+ ${this._showPillsList && i.length > 0 ? p`<div class="gui-range-date-input__pills-dropdown" role="list">
125
+ ${v(
126
+ i,
127
+ (s) => `${s.start}-${s.end ?? s.start}`,
128
+ (s, r) => this.renderPill(s, r)
129
+ )}
130
+ </div>` : g}
131
+ </div>
132
+
133
+ ${this.showErrors && this.errors?.length ? $(this.uid, t) : g}
134
+ `;
135
+ }
136
+ renderPill(t, e) {
137
+ const i = this.formatDateForDisplay(t.start), a = t.end ? this.formatDateForDisplay(t.end) : i, s = `${i} - ${a}`;
138
+ return p`
139
+ <div
140
+ class="gui-range-date-input__pill"
141
+ role="listitem"
142
+ tabindex="0"
143
+ aria-label="${this.removePillAriaLabel ?? "Remove date"} ${s}"
144
+ @click=${() => this.onPillClick(t)}
145
+ @focus=${this.handlePillFocus}
146
+ @keydown=${(r) => this.handlePillKeydown(r, e)}
147
+ >
148
+ <span class="gui-range-date-input__pill-text">${s}</span>
149
+ <button
150
+ type="button"
151
+ class="gui-range-date-input__pill-remove"
152
+ tabindex="-1"
153
+ ?disabled=${this.disabled || this.readOnly}
154
+ @click=${() => this.removePill(e)}
155
+ >
156
+ <svg
157
+ xmlns="http://www.w3.org/2000/svg"
158
+ width="16"
159
+ height="16"
160
+ viewBox="0 0 256 256"
161
+ fill="currentColor"
162
+ aria-hidden="true"
163
+ >
164
+ <path
165
+ d="M165.66,101.66,139.31,128l26.35,26.34a8,8,0,0,1-11.32,11.32L128,139.31l-26.34,26.35a8,8,0,0,1-11.32-11.32L116.69,128,90.34,101.66a8,8,0,0,1,11.32-11.32L128,116.69l26.34-26.35a8,8,0,0,1,11.32,11.32ZM232,128A104,104,0,1,1,128,24,104.11,104.11,0,0,1,232,128Zm-16,0a88,88,0,1,0-88,88A88.1,88.1,0,0,0,216,128Z"
166
+ ></path>
167
+ </svg>
168
+ </button>
169
+ </div>
170
+ `;
171
+ }
172
+ renderDateInputs(t, e) {
173
+ const i = t === "start" ? this._startDate : this._endDate;
174
+ return v(
175
+ e,
176
+ (a) => `${t}-${a.type}`,
177
+ (a, s) => {
178
+ const r = t === "start" && s === 0 ? 0 : -1;
179
+ switch (a.type) {
180
+ case "day":
181
+ return this.renderInput(t, "day", "dd", 2, r, i.day);
182
+ case "month":
183
+ return this.renderInput(t, "month", "mm", 2, r, i.month);
184
+ case "year":
185
+ return this.renderInput(t, "year", "yyyy", 4, r, i.year);
186
+ case "literal":
187
+ return p`<span class="gui-range-date-input__separator">${a.value}</span>`;
188
+ default:
189
+ return "";
190
+ }
191
+ }
192
+ );
193
+ }
194
+ renderInput(t, e, i, a, s, r) {
195
+ return p`
196
+ <div class="gui-range-date-input__touch-target">
197
+ <input
198
+ type="text"
199
+ inputmode="numeric"
200
+ class="gui-range-date-input__part ${e === "year" ? "gui-range-date-input__year" : ""}"
201
+ data-type=${e}
202
+ data-group=${t}
203
+ maxlength=${a}
204
+ placeholder=${i}
205
+ tabindex=${s}
206
+ ?required=${this.required}
207
+ ?disabled=${this.disabled}
208
+ ?readonly=${this.readOnly}
209
+ autocomplete="off"
210
+ .value=${P(r)}
211
+ @keydown=${this.handleKeyDown}
212
+ @keyup=${(d) => this.handleKeyUp(d, t, e)}
213
+ @focus=${this.handleFocus}
214
+ @blur=${(d) => this.handleBlur(d, t, e)}
215
+ @change=${(d) => this.handleChange(d, t, e)}
216
+ />
217
+ <div class="gui-range-date-input__visual-underline"></div>
218
+ </div>
219
+ `;
220
+ }
221
+ formatDateForDisplay(t) {
222
+ const e = new Date(t);
223
+ return isNaN(e.getTime()) ? t : new Intl.DateTimeFormat(this.localeId ?? "en", {
224
+ year: "numeric",
225
+ month: "2-digit",
226
+ day: "2-digit"
227
+ }).format(e);
228
+ }
229
+ getSortedPills() {
230
+ return !this.value || !Array.isArray(this.value) ? [] : [...this.value].sort(
231
+ (t, e) => new Date(t.start).getTime() - new Date(e.start).getTime()
232
+ );
233
+ }
234
+ togglePillsList() {
235
+ this._showPillsList = !this._showPillsList, this._showPillsList ? requestAnimationFrame(() => {
236
+ document.addEventListener("pointerdown", this.handleOutsideInteraction), document.addEventListener("focusin", this.handleOutsideInteraction), this.querySelector(
237
+ ".gui-range-date-input__pills-dropdown .gui-range-date-input__pill"
238
+ )?.focus();
239
+ }) : this.removeOutsideListeners();
240
+ }
241
+ removeOutsideListeners() {
242
+ document.removeEventListener("pointerdown", this.handleOutsideInteraction), document.removeEventListener("focusin", this.handleOutsideInteraction);
243
+ }
244
+ removePill(t) {
245
+ if (this.disabled || this.readOnly) return;
246
+ const e = this.getSortedPills();
247
+ e.splice(t, 1), this.value = [...e], this.dispatchEvent(
248
+ new CustomEvent("change", {
249
+ detail: { value: this.value },
250
+ bubbles: !0,
251
+ composed: !0
252
+ })
253
+ ), this._showPillsList && e.length === 0 && (this._showPillsList = !1, this.removeOutsideListeners()), requestAnimationFrame(() => {
254
+ const i = this._showPillsList ? ".gui-range-date-input__pills-dropdown .gui-range-date-input__pill" : ".gui-range-date-input__pills .gui-range-date-input__pill", a = this.querySelectorAll(i);
255
+ if (a.length > 0) {
256
+ const s = Math.min(t, a.length - 1);
257
+ a[s].focus();
258
+ } else
259
+ this.querySelector(
260
+ ".gui-range-date-input__field input"
261
+ )?.focus();
262
+ });
263
+ }
264
+ handlePillFocus(t) {
265
+ t.target.scrollIntoView({
266
+ behavior: "smooth",
267
+ block: "nearest",
268
+ inline: "nearest"
269
+ });
270
+ }
271
+ handlePillKeydown(t, e) {
272
+ if (t.key === "Delete" || t.key === "Backspace") {
273
+ t.preventDefault(), t.stopPropagation(), this.removePill(e);
274
+ return;
275
+ }
276
+ if (t.key === "Enter" || t.key === " ") {
277
+ t.preventDefault();
278
+ const r = this.getSortedPills();
279
+ r[e] && this.onPillClick(r[e]);
280
+ return;
281
+ }
282
+ const i = this._showPillsList, a = i ? "ArrowUp" : "ArrowLeft", s = i ? "ArrowDown" : "ArrowRight";
283
+ if (t.key === a || t.key === s) {
284
+ t.preventDefault();
285
+ const r = i ? ".gui-range-date-input__pills-dropdown .gui-range-date-input__pill" : ".gui-range-date-input__pills .gui-range-date-input__pill", d = this.querySelectorAll(r), n = t.key === a ? e - 1 : e + 1;
286
+ n >= 0 && n < d.length && d[n].focus();
287
+ }
288
+ }
289
+ onPillClick(t) {
290
+ this.dispatchEvent(
291
+ new CustomEvent("pillClick", {
292
+ detail: { range: t },
293
+ bubbles: !0,
294
+ composed: !0
295
+ })
296
+ );
297
+ }
298
+ handleKeyDown(t) {
299
+ [
300
+ "Backspace",
301
+ "Tab",
302
+ "ArrowUp",
303
+ "ArrowDown",
304
+ "ArrowLeft",
305
+ "ArrowRight",
306
+ "Delete",
307
+ "Enter"
308
+ ].includes(t.key) || t.ctrlKey || t.metaKey || this.readOnly || /^[0-9]$/.test(t.key) || t.preventDefault();
309
+ }
310
+ handleFocus(t) {
311
+ this.dispatchEvent(new CustomEvent("focus", { detail: t }));
312
+ }
313
+ handleKeyUp(t, e, i) {
314
+ if (this.readOnly) return;
315
+ const a = window.getComputedStyle(this).direction === "rtl", s = t.target, r = this.getGroupInputs(e), d = r.indexOf(s);
316
+ if (s.value.length === s.maxLength && /^[0-9]$/.test(t.key))
317
+ if (d === r.length - 1) {
318
+ if (e === "start") {
319
+ const n = this.getGroupInputs("end");
320
+ n.length > 0 && n[0].focus();
321
+ }
322
+ } else
323
+ r[d + 1].focus();
324
+ switch (t.key) {
325
+ case "Enter": {
326
+ if (this.tryCreatePill(), this.value && this.value.length > 0) {
327
+ const n = this.value[this.value.length - 1];
328
+ this.onPillClick(n);
329
+ }
330
+ break;
331
+ }
332
+ case "ArrowUp": {
333
+ const n = isNaN(parseInt(s.value, 10) + 1) ? 1 : parseInt(s.value, 10) + 1;
334
+ this.setDatePartValue(e, i, n), s.select(), this.tryCreatePill();
335
+ break;
336
+ }
337
+ case "ArrowDown": {
338
+ const n = isNaN(parseInt(s.value, 10) - 1) ? 1 : parseInt(s.value, 10) - 1;
339
+ this.setDatePartValue(e, i, n), s.select(), this.tryCreatePill();
340
+ break;
341
+ }
342
+ case "ArrowLeft": {
343
+ const n = a ? d + 1 : d - 1;
344
+ if (n >= 0 && n < r.length)
345
+ r[n].focus(), r[n].select();
346
+ else {
347
+ const u = a ? "end" : "start";
348
+ if (e !== u) {
349
+ const c = this.getGroupInputs(u);
350
+ if (c.length > 0) {
351
+ const _ = c[c.length - 1];
352
+ _.focus(), _.select();
353
+ }
354
+ }
355
+ }
356
+ break;
357
+ }
358
+ case "ArrowRight": {
359
+ const n = a ? d - 1 : d + 1;
360
+ if (n >= 0 && n < r.length)
361
+ r[n].focus(), r[n].select();
362
+ else {
363
+ const u = a ? "start" : "end";
364
+ if (e !== u) {
365
+ const c = this.getGroupInputs(u);
366
+ c.length > 0 && (c[0].focus(), c[0].select());
367
+ }
368
+ }
369
+ break;
370
+ }
371
+ }
372
+ }
373
+ handleChange(t, e, i) {
374
+ if (t.stopImmediatePropagation(), this.readOnly) return;
375
+ const s = t.target.value.replace(/[^0-9]/g, "");
376
+ this.updateDatePart(e, i, s), this.tryCreatePill();
377
+ }
378
+ handleBlur(t, e, i) {
379
+ const a = t.target, s = parseInt(a.value, 10);
380
+ if (!isNaN(s) && s > 0) {
381
+ const r = i === "year" ? 4 : 2;
382
+ a.value = s.toString().padStart(r, "0");
383
+ }
384
+ this.dispatchEvent(new CustomEvent("blur"));
385
+ }
386
+ getGroupInputs(t) {
387
+ return Array.from(this.querySelectorAll(`input[data-group="${t}"]`));
388
+ }
389
+ setDatePartValue(t, e, i) {
390
+ const a = t === "start" ? this._startDate : this._endDate, s = e === "year" ? 4 : 2;
391
+ e === "day" && (a.day = i.toString().padStart(s, "0")), e === "month" && (a.month = i.toString().padStart(s, "0")), e === "year" && (a.year = i.toString().padStart(s, "0")), t === "start" ? this._startDate = { ...a } : this._endDate = { ...a };
392
+ }
393
+ updateDatePart(t, e, i) {
394
+ t === "start" ? this._startDate = { ...this._startDate, [e]: i } : this._endDate = { ...this._endDate, [e]: i };
395
+ }
396
+ validateDateParts(t) {
397
+ let e = parseInt(t.year, 10), i = parseInt(t.month, 10), a = parseInt(t.day, 10);
398
+ if (isNaN(e) || isNaN(i) || isNaN(a) || String(e).length < 4) return null;
399
+ e = Math.max(this.MIN_YEAR, Math.min(this.MAX_YEAR, e)), i = Math.max(this.MIN_MONTH, Math.min(this.MAX_MONTH, i)), a = Math.max(this.MIN_DAY, Math.min(this.MAX_DAY, a));
400
+ const s = this.MAX_VALID_DAY(i, e);
401
+ return a > s ? (this.dispatchEvent(
402
+ new CustomEvent("inputError", {
403
+ detail: {
404
+ message: "Invalid date: day is greater than the maximum valid day for the month and year."
405
+ },
406
+ bubbles: !0
407
+ })
408
+ ), null) : new Date(e, i - 1, a);
409
+ }
410
+ setupObservers() {
411
+ const t = this.querySelector(".gui-sentinel__start"), e = this.querySelector(".gui-sentinel__end");
412
+ t && !this.startObserver && (this.startObserver = b(
413
+ t,
414
+ (i) => this._isStartVisible = i
415
+ )), e && !this.endObserver && (this.endObserver = b(
416
+ e,
417
+ (i) => this._isEndVisible = i
418
+ )), !t && this.startObserver && (this.startObserver.disconnect(), this.startObserver = void 0, this._isStartVisible = !0), !e && this.endObserver && (this.endObserver.disconnect(), this.endObserver = void 0, this._isEndVisible = !0);
419
+ }
420
+ disconnectObservers() {
421
+ this.startObserver?.disconnect(), this.endObserver?.disconnect(), this.startObserver = void 0, this.endObserver = void 0;
422
+ }
423
+ tryCreatePill() {
424
+ const t = this.validateDateParts(this._startDate), e = this.validateDateParts(this._endDate);
425
+ if (!t || !e) return;
426
+ let i = t, a = e;
427
+ e.getTime() < t.getTime() && (i = e, a = t);
428
+ const s = f(i), r = f(a), d = s === r ? { start: s } : { start: s, end: r }, n = this.value ? [...this.value] : [];
429
+ n.push(d), this.value = O(n), this._startDate = { day: "", month: "", year: "" }, this._endDate = { day: "", month: "", year: "" }, this.dispatchEvent(
430
+ new CustomEvent("change", {
431
+ detail: { value: this.value },
432
+ bubbles: !0,
433
+ composed: !0
434
+ })
435
+ ), requestAnimationFrame(() => {
436
+ const u = this.getGroupInputs("start");
437
+ u.length > 0 && u[0].focus();
438
+ }), this.requestUpdate();
439
+ }
440
+ };
441
+ o([
442
+ h({ type: String })
443
+ ], l.prototype, "uid", 2);
444
+ o([
445
+ h({ type: String })
446
+ ], l.prototype, "label", 2);
447
+ o([
448
+ h({ type: String, attribute: "locale-id" })
449
+ ], l.prototype, "localeId", 2);
450
+ o([
451
+ h({ type: Array })
452
+ ], l.prototype, "errors", 2);
453
+ o([
454
+ h({ type: Boolean })
455
+ ], l.prototype, "showErrors", 2);
456
+ o([
457
+ h({ type: Boolean })
458
+ ], l.prototype, "touched", 2);
459
+ o([
460
+ h({ type: Boolean })
461
+ ], l.prototype, "required", 2);
462
+ o([
463
+ h({ type: Boolean })
464
+ ], l.prototype, "disabled", 2);
465
+ o([
466
+ h({ type: Boolean, attribute: "readonly" })
467
+ ], l.prototype, "readOnly", 2);
468
+ o([
469
+ h({ type: Array })
470
+ ], l.prototype, "value", 2);
471
+ o([
472
+ h({ type: String })
473
+ ], l.prototype, "hint", 2);
474
+ o([
475
+ h({ type: String })
476
+ ], l.prototype, "icon", 2);
477
+ o([
478
+ h({ type: String })
479
+ ], l.prototype, "removePillAriaLabel", 2);
480
+ o([
481
+ h({ type: String })
482
+ ], l.prototype, "startDateAriaLabel", 2);
483
+ o([
484
+ h({ type: String })
485
+ ], l.prototype, "endDateAriaLabel", 2);
486
+ o([
487
+ h({ type: String })
488
+ ], l.prototype, "separator", 2);
489
+ o([
490
+ y()
491
+ ], l.prototype, "_startDate", 2);
492
+ o([
493
+ y()
494
+ ], l.prototype, "_endDate", 2);
495
+ o([
496
+ y()
497
+ ], l.prototype, "_isStartVisible", 2);
498
+ o([
499
+ y()
500
+ ], l.prototype, "_isEndVisible", 2);
501
+ o([
502
+ y()
503
+ ], l.prototype, "_showPillsList", 2);
504
+ l = o([
505
+ D("gui-range-date")
506
+ ], l);
507
+ typeof customElements < "u" && !customElements.get("gui-range-date") && customElements.define("gui-range-date", l);
@@ -1,15 +1,18 @@
1
- import * as d from "@golemui/lit";
2
- import { consume as o, provide as u } from "@lit/context";
3
- import { LitElement as h, html as c } from "lit";
4
- import { property as m, customElement as b } from "lit/decorators.js";
5
- var D = Object.defineProperty, g = Object.getOwnPropertyDescriptor, n = (t, e, s, r) => {
6
- for (var a = r > 1 ? void 0 : r ? g(e, s) : e, p = t.length - 1, l; p >= 0; p--)
1
+ import { InputWidgetAdapter as n, formContext as o, inputContext as u } from "@golemui/lit";
2
+ import "@golemui/gui-shared";
3
+ import "./range-date-input-CrNpOVHt.js";
4
+ import { consume as h, provide as m } from "@lit/context";
5
+ import { LitElement as c, html as b } from "lit";
6
+ import { property as D, customElement as g } from "lit/decorators.js";
7
+ import "rxjs";
8
+ var f = Object.defineProperty, $ = Object.getOwnPropertyDescriptor, d = (t, e, s, r) => {
9
+ for (var a = r > 1 ? void 0 : r ? $(e, s) : e, p = t.length - 1, l; p >= 0; p--)
7
10
  (l = t[p]) && (a = (r ? l(e, s, a) : l(a)) || a);
8
- return r && a && D(e, s, a), a;
11
+ return r && a && f(e, s, a), a;
9
12
  };
10
- let i = class extends h {
13
+ let i = class extends c {
11
14
  constructor() {
12
- super(...arguments), this.adapter = new d.InputWidgetAdapter(), this.subscriptions = [];
15
+ super(...arguments), this.adapter = new n(), this.subscriptions = [];
13
16
  }
14
17
  createRenderRoot() {
15
18
  return this;
@@ -25,7 +28,7 @@ let i = class extends h {
25
28
  );
26
29
  }
27
30
  render() {
28
- return super.render(), c`
31
+ return super.render(), b`
29
32
  <gui-range-date
30
33
  .uid=${this.widget.uid}
31
34
  .label=${this.adapter.templateData.label}
@@ -57,15 +60,15 @@ let i = class extends h {
57
60
  super.disconnectedCallback(), this.adapter.destroy(), this.subscriptions.forEach((t) => t.unsubscribe());
58
61
  }
59
62
  };
60
- n([
61
- o({ context: d.formContext }),
62
- m({ attribute: !1 })
63
+ d([
64
+ h({ context: o }),
65
+ D({ attribute: !1 })
63
66
  ], i.prototype, "formContext", 2);
64
- n([
65
- u({ context: d.inputContext })
67
+ d([
68
+ m({ context: u })
66
69
  ], i.prototype, "adapter", 2);
67
- i = n([
68
- b("gui-range-date-input")
70
+ i = d([
71
+ g("gui-range-date-input")
69
72
  ], i);
70
73
  export {
71
74
  i as RangeDateInputElement
@@ -1,17 +1,21 @@
1
- import * as p from "@golemui/lit";
2
- import { addIcon as c, addLabel as m, addErrors as g } from "@golemui/gui-components";
3
- import { consume as D, provide as C } from "@lit/context";
4
- import { LitElement as $, html as o, nothing as f } from "lit";
5
- import { property as v, query as h, state as u, customElement as b } from "lit/decorators.js";
6
- import { classMap as k } from "lit/directives/class-map.js";
7
- var y = Object.defineProperty, I = Object.getOwnPropertyDescriptor, n = (e, t, a, r) => {
8
- for (var i = r > 1 ? void 0 : r ? I(t, a) : t, l = e.length - 1, d; l >= 0; l--)
1
+ import { InputWidgetAdapter as c, formContext as u, inputContext as m } from "@golemui/lit";
2
+ import { a as g, b as D, c as C } from "./templates-Dk1jxLwS.js";
3
+ import "@golemui/gui-shared";
4
+ import "./range-calendar-qpakwAba.js";
5
+ import "./range-date-input-CrNpOVHt.js";
6
+ import { consume as $, provide as f } from "@lit/context";
7
+ import { LitElement as v, html as p, nothing as b } from "lit";
8
+ import { property as k, query as o, state as h, customElement as y } from "lit/decorators.js";
9
+ import "rxjs";
10
+ import { classMap as I } from "lit/directives/class-map.js";
11
+ var O = Object.defineProperty, w = Object.getOwnPropertyDescriptor, n = (e, t, a, r) => {
12
+ for (var i = r > 1 ? void 0 : r ? w(t, a) : t, l = e.length - 1, d; l >= 0; l--)
9
13
  (d = e[l]) && (i = (r ? d(t, a, i) : d(i)) || i);
10
- return r && i && y(t, a, i), i;
14
+ return r && i && O(t, a, i), i;
11
15
  };
12
- let s = class extends $ {
16
+ let s = class extends v {
13
17
  constructor() {
14
- super(...arguments), this.adapter = new p.InputWidgetAdapter(), this.isCalendarOpen = !1, this.focusDate = void 0, this.subscriptions = [], this.onFocusOut = (e) => {
18
+ super(...arguments), this.adapter = new c(), this.isCalendarOpen = !1, this.focusDate = void 0, this.subscriptions = [], this.onFocusOut = (e) => {
15
19
  if (!this.isCalendarOpen) return;
16
20
  const t = e.relatedTarget;
17
21
  t && this.contains(t) || this.closeCalendar();
@@ -36,7 +40,7 @@ let s = class extends $ {
36
40
  }
37
41
  render() {
38
42
  super.render();
39
- const e = c("datePicker", this.adapter.templateData), t = this.isCalendarOpen ? o`<gui-range-calendar
43
+ const e = g("datePicker", this.adapter.templateData), t = this.isCalendarOpen ? p`<gui-range-calendar
40
44
  id="calendar-input"
41
45
  .uid=${this.widget.uid}
42
46
  .hint=${this.adapter.templateData.hint}
@@ -61,9 +65,9 @@ let s = class extends $ {
61
65
  .hidePills=${!0}
62
66
  @blur=${this.onBlurCalendar}
63
67
  @change=${this.valueChanged}
64
- ></gui-range-calendar>` : f;
65
- return o`
66
- ${m(this.widget.uid, {
68
+ ></gui-range-calendar>` : b;
69
+ return p`
70
+ ${D(this.widget.uid, {
67
71
  ...this.adapter.templateData,
68
72
  required: this.adapter.templateData.validator?.required
69
73
  })}
@@ -78,7 +82,7 @@ let s = class extends $ {
78
82
  >
79
83
  <gui-range-date
80
84
  id="date-input"
81
- class=${k(e.widgetClasses)}
85
+ class=${I(e.widgetClasses)}
82
86
  .uid=${this.widget.uid}
83
87
  .hint=${this.adapter.templateData.hint}
84
88
  .showErrors=${!1}
@@ -110,7 +114,7 @@ let s = class extends $ {
110
114
  ${t}
111
115
  </div>
112
116
 
113
- ${g(this.widget.uid, this.adapter.templateData)}
117
+ ${C(this.widget.uid, this.adapter.templateData)}
114
118
  `;
115
119
  }
116
120
  valueChanged(e) {
@@ -144,26 +148,26 @@ let s = class extends $ {
144
148
  }
145
149
  };
146
150
  n([
147
- D({ context: p.formContext }),
148
- v({ attribute: !1 })
151
+ $({ context: u }),
152
+ k({ attribute: !1 })
149
153
  ], s.prototype, "formContext", 2);
150
154
  n([
151
- C({ context: p.inputContext })
155
+ f({ context: m })
152
156
  ], s.prototype, "adapter", 2);
153
157
  n([
154
- h("#date-input")
158
+ o("#date-input")
155
159
  ], s.prototype, "dateInput", 2);
156
160
  n([
157
- h("#calendar-input")
161
+ o("#calendar-input")
158
162
  ], s.prototype, "calendarInput", 2);
159
163
  n([
160
- u()
164
+ h()
161
165
  ], s.prototype, "isCalendarOpen", 2);
162
166
  n([
163
- u()
167
+ h()
164
168
  ], s.prototype, "focusDate", 2);
165
169
  s = n([
166
- b("gui-range-date-picker-input")
170
+ y("gui-range-date-picker-input")
167
171
  ], s);
168
172
  export {
169
173
  s as RangeDatePickerElement