@golemui/gui-lit 1.0.3 → 1.1.1-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/{button.element-3a7rRHbA.js → button.element-CJay43iR.js} +16 -13
  3. package/calendar-D31xNsxx.js +267 -0
  4. package/{range-calendar.element-_1bHW_c1.js → calendar.element-BhFrCsns.js} +16 -16
  5. package/{checkbox.element-CVskoXEc.js → checkbox.element-DAAVB651.js} +49 -49
  6. package/{currency.element-5GSakkxF.js → currency.element-D8A2ObpM.js} +15 -11
  7. package/{date-CDUlLuYy.js → date-DBuYpvcO.js} +88 -29
  8. package/date-input-DLiMreSS.js +204 -0
  9. package/date-picker.element-DeUQtbLg.js +357 -0
  10. package/date-time-calendar-DzU-FtVl.js +374 -0
  11. package/date-time-calendar.element-BLBcVsFu.js +95 -0
  12. package/date-time-input-DZaz2heD.js +246 -0
  13. package/date-time-picker.element-BUbLdV6i.js +440 -0
  14. package/date-time.element-B5onfSBG.js +93 -0
  15. package/{date.element-BZO0UQez.js → date.element-BsKhLrEc.js} +27 -19
  16. package/day-status-CsWStVQV.js +554 -0
  17. package/{dropdown.element-CyJbVAA5.js → dropdown.element-CXpMwJsU.js} +53 -37
  18. package/{errors-QjKhr6mA.js → errors-Byb2dIhK.js} +3 -2
  19. package/focus-leave.controller-2gV0pQd5.js +73 -0
  20. package/index.js +1635 -948
  21. package/index.umd.cjs +2046 -601
  22. package/lib/components/date-picker.element.d.ts +0 -11
  23. package/lib/components/date-time-calendar.element.d.ts +18 -0
  24. package/lib/components/date-time-picker.element.d.ts +18 -0
  25. package/lib/components/date-time.element.d.ts +18 -0
  26. package/lib/components/dropdown.element.d.ts +2 -0
  27. package/lib/components/range-calendar.element.d.ts +2 -1
  28. package/lib/components/range-date-picker.element.d.ts +0 -15
  29. package/lib/components/range-date-time-calendar.element.d.ts +18 -0
  30. package/lib/components/range-date-time-input.element.d.ts +18 -0
  31. package/lib/components/range-date-time-picker.element.d.ts +18 -0
  32. package/lib/components/range-time-input.element.d.ts +18 -0
  33. package/lib/components/range-time-picker.element.d.ts +18 -0
  34. package/lib/components/time-picker.element.d.ts +18 -0
  35. package/lib/components/time.element.d.ts +18 -0
  36. package/list-D730tmGN.js +297 -0
  37. package/{list.element-Co3V3Cn5.js → list.element-eo3DIOrp.js} +23 -23
  38. package/{markdown.element-p-kC47D7.js → markdown.element-FbtwdnAv.js} +310 -218
  39. package/{number.element-CBr47IiY.js → number.element-BEpOCzXy.js} +76 -61
  40. package/package.json +6 -6
  41. package/part-templates-VORbpgs2.js +691 -0
  42. package/{password.element-n-R9RbkB.js → password.element-CBaB8h5b.js} +19 -17
  43. package/pill-ranges-DpvWwP-3.js +48 -0
  44. package/{pills-B66qz_KX.js → pills-BDMO2NiR.js} +84 -59
  45. package/popup.controller-B33OvX_y.js +86 -0
  46. package/{radiogroup.element-CeQn623u.js → radiogroup.element-KWzBx8mx.js} +55 -51
  47. package/range-calendar-DO_woqcF.js +466 -0
  48. package/{calendar.element-DcnTyvfg.js → range-calendar.element-DHLZhpnj.js} +37 -29
  49. package/range-commit-8-MmYUyo.js +14 -0
  50. package/range-date-input-Br7XqQPK.js +311 -0
  51. package/{range-date-input.element-BqzAF0O3.js → range-date-input.element-BdD4SlB4.js} +12 -8
  52. package/range-date-picker.element-DWRHiAoC.js +434 -0
  53. package/range-date-time-calendar-B3EMgN1E.js +734 -0
  54. package/range-date-time-calendar.element-Coea6RF4.js +97 -0
  55. package/range-date-time-input-Cu-T_nuC.js +353 -0
  56. package/range-date-time-input.element-Cti44iuW.js +87 -0
  57. package/range-date-time-picker.element-CDN2RL1y.js +472 -0
  58. package/range-selection-CU3hxLJE.js +25 -0
  59. package/range-time-input-BP9ZL9O8.js +348 -0
  60. package/range-time-input.element-B7wtHJoQ.js +84 -0
  61. package/range-time-picker.element-CPIAiQPC.js +470 -0
  62. package/{repeater.element-CtNgB4F5.js → repeater.element-BM1Keckd.js} +1 -1
  63. package/{select.element-jcDF1h-g.js → select.element-eepcXTpL.js} +117 -107
  64. package/{tabs.element-BvAyI71N.js → tabs.element-CvcIA8P3.js} +1 -0
  65. package/{tags.element-CX3vQL8L.js → tags.element-CPHgotb0.js} +21 -14
  66. package/templates-Dmr34nwp.js +88 -0
  67. package/{textarea.element-HThYqdR_.js → textarea.element-CiNEy9uq.js} +8 -7
  68. package/{textinput.element-CkXNzMUg.js → textinput.element-AL2Nr768.js} +10 -9
  69. package/time-input-5dkSm8UW.js +201 -0
  70. package/time-list-DLcq8BAp.js +217 -0
  71. package/time-picker-g337F8d0.js +299 -0
  72. package/time-picker.element-DLihegjg.js +89 -0
  73. package/time.element-BneqgMlQ.js +85 -0
  74. package/{toggle.element-C1kCw5H8.js → toggle.element-Cz91CRdp.js} +44 -43
  75. package/abstract-calendar-D0-077XJ.js +0 -545
  76. package/calendar-BclCC9VJ.js +0 -96
  77. package/date-input-DCdGWRio.js +0 -268
  78. package/date-picker.element-k7AJFQ5W.js +0 -168
  79. package/list-D1oKnH89.js +0 -283
  80. package/range-calendar-CBINu84w.js +0 -255
  81. package/range-date-input-BYXzqnr1.js +0 -395
  82. package/range-date-picker.element-BCBefgvY.js +0 -182
  83. package/templates-Dk1jxLwS.js +0 -75
@@ -1,395 +0,0 @@
1
- import { LitElement as D, nothing as g, html as c } from "lit";
2
- import { repeat as b } from "lit-html/directives/repeat.js";
3
- import { property as h, state as v, customElement as _ } from "lit/decorators.js";
4
- import { classMap as $ } from "lit/directives/class-map.js";
5
- import { live as I } from "lit/directives/live.js";
6
- import { G as A, b as w, c as P } from "./templates-Dk1jxLwS.js";
7
- import { p as y, t as f, m as S } from "./date-CDUlLuYy.js";
8
- import "./pills-B66qz_KX.js";
9
- import { styleMap as E } from "lit-html/directives/style-map.js";
10
- var M = Object.defineProperty, C = Object.getOwnPropertyDescriptor, d = (t, e, s, a) => {
11
- for (var r = a > 1 ? void 0 : a ? C(e, s) : e, i = t.length - 1, l; i >= 0; i--)
12
- (l = t[i]) && (r = (a ? l(e, s, r) : l(r)) || r);
13
- return a && r && M(e, s, r), r;
14
- };
15
- let o = class extends D {
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.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 A(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.onPillRemoveEvent = (t) => {
30
- if (this.disabled || this.readOnly) return;
31
- const e = this.getSortedPills(), s = e.findIndex(
32
- (i) => `${i.start}-${i.end ?? i.start}` === t.detail.key
33
- );
34
- if (s < 0) return;
35
- const a = e[s], r = (this.value ?? []).filter(
36
- (i) => !(i.start === a.start && (i.end ?? null) === (a.end ?? null))
37
- );
38
- this.value = r, this.dispatchEvent(
39
- new CustomEvent("change", {
40
- detail: { value: this.value },
41
- bubbles: !0,
42
- composed: !0
43
- })
44
- ), r.length === 0 && requestAnimationFrame(() => {
45
- this.querySelector(
46
- ".gui-range-date-input__field input"
47
- )?.focus();
48
- });
49
- }, this.onPillClickEvent = (t) => {
50
- const s = this.getSortedPills().find((a) => `${a.start}-${a.end ?? a.start}` === t.detail.key);
51
- s && this.onPillClick(s);
52
- };
53
- }
54
- createRenderRoot() {
55
- return this;
56
- }
57
- connectedCallback() {
58
- super.connectedCallback(), this.classList.add("gui-field");
59
- }
60
- render() {
61
- const t = {
62
- uid: this.uid,
63
- label: this.label,
64
- errors: this.errors,
65
- touched: this.touched,
66
- required: this.required,
67
- disabled: this.disabled,
68
- readonly: this.readOnly,
69
- value: this.value,
70
- hint: this.hint
71
- }, e = new Intl.DateTimeFormat(this.localeId ?? "en", {
72
- year: "numeric",
73
- month: "numeric",
74
- day: "numeric"
75
- }).formatToParts(/* @__PURE__ */ new Date()), a = this.getSortedPills().map((i) => {
76
- const l = this.formatDateForDisplay(i.start), n = i.end ? this.formatDateForDisplay(i.end) : l, u = `${l} - ${n}`;
77
- return {
78
- key: `${i.start}-${i.end ?? i.start}`,
79
- label: u,
80
- ariaLabel: `${this.removePillAriaLabel ?? "Remove date"} ${u}`
81
- };
82
- }), r = {
83
- "gui-widget-icon": !0,
84
- [this.icon]: !!this.icon
85
- };
86
- return c`
87
- ${this.label ? w(this.uid, t, !1, void 0, !1) : g}
88
-
89
- <div class="gui-widget">
90
- <div
91
- class="gui-widget-input gui-range-date-input ${this.icon ? "gui-range-date-input--icon" : ""}"
92
- role="group"
93
- aria-label=${this.label ?? "Date range input"}
94
- >
95
- ${this.icon ? c`<span class=${$(r)} data-icon=${this.icon}></span>` : g}
96
-
97
- <gui-pills
98
- class="gui-range-date-input__pills"
99
- style=${E(a.length ? {} : { "min-width": 0 })}
100
- .items=${a}
101
- .removable=${!0}
102
- .clickable=${!0}
103
- .bubble=${!0}
104
- ?disabled=${this.disabled}
105
- ?readonly=${this.readOnly}
106
- .removeAriaLabel=${this.removePillAriaLabel ?? "Remove date"}
107
- .compactAriaLabel=${`${a.length} date ranges`}
108
- @pillremove=${this.onPillRemoveEvent}
109
- @pillclick=${this.onPillClickEvent}
110
- ></gui-pills>
111
-
112
- <div class="gui-range-date-input__inputs">
113
- <div
114
- class="gui-range-date-input__field"
115
- role="group"
116
- aria-label=${this.startDateAriaLabel ?? "Start date"}
117
- >
118
- ${this.renderDateInputs("start", e)}
119
- </div>
120
-
121
- <span class="gui-range-date-input__separator">${this.separator ?? "-"}</span>
122
-
123
- <div
124
- class="gui-range-date-input__field"
125
- role="group"
126
- aria-label=${this.endDateAriaLabel ?? "End date"}
127
- >
128
- ${this.renderDateInputs("end", e)}
129
- </div>
130
- </div>
131
- </div>
132
-
133
- ${this.showErrors && this.errors?.length ? P(this.uid, t) : g}
134
- </div>
135
- `;
136
- }
137
- renderDateInputs(t, e) {
138
- const s = t === "start" ? this._startDate : this._endDate;
139
- return b(
140
- e,
141
- (a) => `${t}-${a.type}`,
142
- (a, r) => {
143
- const i = t === "start" && r === 0 ? 0 : -1;
144
- switch (a.type) {
145
- case "day":
146
- return this.renderInput(t, "day", "dd", 2, i, s.day);
147
- case "month":
148
- return this.renderInput(t, "month", "mm", 2, i, s.month);
149
- case "year":
150
- return this.renderInput(t, "year", "yyyy", 4, i, s.year);
151
- case "literal":
152
- return c`<span class="gui-range-date-input__separator">${a.value}</span>`;
153
- default:
154
- return "";
155
- }
156
- }
157
- );
158
- }
159
- renderInput(t, e, s, a, r, i) {
160
- return c`
161
- <div class="gui-range-date-input__touch-target">
162
- <input
163
- type="text"
164
- inputmode="numeric"
165
- class="gui-range-date-input__part ${e === "year" ? "gui-range-date-input__year" : ""}"
166
- data-type=${e}
167
- data-group=${t}
168
- maxlength=${a}
169
- placeholder=${s}
170
- tabindex=${r}
171
- ?required=${this.required}
172
- ?disabled=${this.disabled}
173
- ?readonly=${this.readOnly}
174
- autocomplete="off"
175
- .value=${I(i)}
176
- @keydown=${this.handleKeyDown}
177
- @keyup=${(l) => this.handleKeyUp(l, t, e)}
178
- @focus=${this.handleFocus}
179
- @blur=${(l) => this.handleBlur(l, t, e)}
180
- @change=${(l) => this.handleChange(l, t, e)}
181
- />
182
- <div class="gui-range-date-input__visual-underline"></div>
183
- </div>
184
- `;
185
- }
186
- formatDateForDisplay(t) {
187
- const e = y(t);
188
- return isNaN(e.getTime()) ? t : new Intl.DateTimeFormat(this.localeId ?? "en", {
189
- year: "numeric",
190
- month: "2-digit",
191
- day: "2-digit"
192
- }).format(e);
193
- }
194
- getSortedPills() {
195
- return !this.value || !Array.isArray(this.value) ? [] : [...this.value].sort(
196
- (t, e) => y(t.start).getTime() - y(e.start).getTime()
197
- );
198
- }
199
- onPillClick(t) {
200
- this.dispatchEvent(
201
- new CustomEvent("pillClick", {
202
- detail: { range: t },
203
- bubbles: !0,
204
- composed: !0
205
- })
206
- );
207
- }
208
- handleKeyDown(t) {
209
- [
210
- "Backspace",
211
- "Tab",
212
- "ArrowUp",
213
- "ArrowDown",
214
- "ArrowLeft",
215
- "ArrowRight",
216
- "Delete",
217
- "Enter"
218
- ].includes(t.key) || t.ctrlKey || t.metaKey || this.readOnly || /^[0-9]$/.test(t.key) || t.preventDefault();
219
- }
220
- handleFocus(t) {
221
- this.dispatchEvent(new CustomEvent("focus", { detail: t }));
222
- }
223
- handleKeyUp(t, e, s) {
224
- if (this.readOnly) return;
225
- const a = window.getComputedStyle(this).direction === "rtl", r = t.target, i = this.getGroupInputs(e), l = i.indexOf(r);
226
- if (r.value.length === r.maxLength && /^[0-9]$/.test(t.key))
227
- if (l === i.length - 1) {
228
- if (e === "start") {
229
- const n = this.getGroupInputs("end");
230
- n.length > 0 && n[0].focus();
231
- }
232
- } else
233
- i[l + 1].focus();
234
- switch (t.key) {
235
- case "Enter": {
236
- if (this.tryCreatePill(), this.value && this.value.length > 0) {
237
- const n = this.value[this.value.length - 1];
238
- this.onPillClick(n);
239
- }
240
- break;
241
- }
242
- case "ArrowUp": {
243
- const n = isNaN(parseInt(r.value, 10) + 1) ? 1 : parseInt(r.value, 10) + 1;
244
- this.setDatePartValue(e, s, n), r.select(), this.tryCreatePill();
245
- break;
246
- }
247
- case "ArrowDown": {
248
- const n = isNaN(parseInt(r.value, 10) - 1) ? 1 : parseInt(r.value, 10) - 1;
249
- this.setDatePartValue(e, s, n), r.select(), this.tryCreatePill();
250
- break;
251
- }
252
- case "ArrowLeft": {
253
- const n = a ? l + 1 : l - 1;
254
- if (n >= 0 && n < i.length)
255
- i[n].focus(), i[n].select();
256
- else {
257
- const u = a ? "end" : "start";
258
- if (e !== u) {
259
- const p = this.getGroupInputs(u);
260
- if (p.length > 0) {
261
- const m = p[p.length - 1];
262
- m.focus(), m.select();
263
- }
264
- }
265
- }
266
- break;
267
- }
268
- case "ArrowRight": {
269
- const n = a ? l - 1 : l + 1;
270
- if (n >= 0 && n < i.length)
271
- i[n].focus(), i[n].select();
272
- else {
273
- const u = a ? "start" : "end";
274
- if (e !== u) {
275
- const p = this.getGroupInputs(u);
276
- p.length > 0 && (p[0].focus(), p[0].select());
277
- }
278
- }
279
- break;
280
- }
281
- }
282
- }
283
- handleChange(t, e, s) {
284
- if (t.stopImmediatePropagation(), this.readOnly) return;
285
- const r = t.target.value.replace(/[^0-9]/g, "");
286
- this.updateDatePart(e, s, r), this.tryCreatePill();
287
- }
288
- handleBlur(t, e, s) {
289
- const a = t.target, r = parseInt(a.value, 10);
290
- if (!isNaN(r) && r > 0) {
291
- const i = s === "year" ? 4 : 2;
292
- a.value = r.toString().padStart(i, "0");
293
- }
294
- this.dispatchEvent(new CustomEvent("blur"));
295
- }
296
- getGroupInputs(t) {
297
- return Array.from(this.querySelectorAll(`input[data-group="${t}"]`));
298
- }
299
- setDatePartValue(t, e, s) {
300
- const a = t === "start" ? this._startDate : this._endDate, r = e === "year" ? 4 : 2;
301
- e === "day" && (a.day = s.toString().padStart(r, "0")), e === "month" && (a.month = s.toString().padStart(r, "0")), e === "year" && (a.year = s.toString().padStart(r, "0")), t === "start" ? this._startDate = { ...a } : this._endDate = { ...a };
302
- }
303
- updateDatePart(t, e, s) {
304
- t === "start" ? this._startDate = { ...this._startDate, [e]: s } : this._endDate = { ...this._endDate, [e]: s };
305
- }
306
- validateDateParts(t) {
307
- let e = parseInt(t.year, 10), s = parseInt(t.month, 10), a = parseInt(t.day, 10);
308
- if (isNaN(e) || isNaN(s) || isNaN(a) || String(e).length < 4) return null;
309
- e = Math.max(this.MIN_YEAR, Math.min(this.MAX_YEAR, e)), s = Math.max(this.MIN_MONTH, Math.min(this.MAX_MONTH, s)), a = Math.max(this.MIN_DAY, Math.min(this.MAX_DAY, a));
310
- const r = this.MAX_VALID_DAY(s, e);
311
- return a > r ? (this.dispatchEvent(
312
- new CustomEvent("inputError", {
313
- detail: {
314
- message: "Invalid date: day is greater than the maximum valid day for the month and year."
315
- },
316
- bubbles: !0
317
- })
318
- ), null) : new Date(e, s - 1, a);
319
- }
320
- tryCreatePill() {
321
- const t = this.validateDateParts(this._startDate), e = this.validateDateParts(this._endDate);
322
- if (!t || !e) return;
323
- let s = t, a = e;
324
- e.getTime() < t.getTime() && (s = e, a = t);
325
- const r = f(s), i = f(a), l = r === i ? { start: r } : { start: r, end: i }, n = this.value ? [...this.value] : [];
326
- n.push(l), this.value = S(n), this._startDate = { day: "", month: "", year: "" }, this._endDate = { day: "", month: "", year: "" }, this.dispatchEvent(
327
- new CustomEvent("change", {
328
- detail: { value: this.value },
329
- bubbles: !0,
330
- composed: !0
331
- })
332
- ), requestAnimationFrame(() => {
333
- const u = this.getGroupInputs("start");
334
- u.length > 0 && u[0].focus();
335
- }), this.requestUpdate();
336
- }
337
- };
338
- d([
339
- h({ type: String })
340
- ], o.prototype, "uid", 2);
341
- d([
342
- h({ type: String })
343
- ], o.prototype, "label", 2);
344
- d([
345
- h({ type: String, attribute: "locale-id" })
346
- ], o.prototype, "localeId", 2);
347
- d([
348
- h({ type: Array })
349
- ], o.prototype, "errors", 2);
350
- d([
351
- h({ type: Boolean })
352
- ], o.prototype, "showErrors", 2);
353
- d([
354
- h({ type: Boolean })
355
- ], o.prototype, "touched", 2);
356
- d([
357
- h({ type: Boolean })
358
- ], o.prototype, "required", 2);
359
- d([
360
- h({ type: Boolean })
361
- ], o.prototype, "disabled", 2);
362
- d([
363
- h({ type: Boolean, attribute: "readonly" })
364
- ], o.prototype, "readOnly", 2);
365
- d([
366
- h({ type: Array })
367
- ], o.prototype, "value", 2);
368
- d([
369
- h({ type: String })
370
- ], o.prototype, "hint", 2);
371
- d([
372
- h({ type: String })
373
- ], o.prototype, "icon", 2);
374
- d([
375
- h({ type: String })
376
- ], o.prototype, "removePillAriaLabel", 2);
377
- d([
378
- h({ type: String })
379
- ], o.prototype, "startDateAriaLabel", 2);
380
- d([
381
- h({ type: String })
382
- ], o.prototype, "endDateAriaLabel", 2);
383
- d([
384
- h({ type: String })
385
- ], o.prototype, "separator", 2);
386
- d([
387
- v()
388
- ], o.prototype, "_startDate", 2);
389
- d([
390
- v()
391
- ], o.prototype, "_endDate", 2);
392
- o = d([
393
- _("gui-range-date")
394
- ], o);
395
- typeof customElements < "u" && !customElements.get("gui-range-date") && customElements.define("gui-range-date", o);
@@ -1,182 +0,0 @@
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 "./range-calendar-CBINu84w.js";
4
- import "./range-date-input-BYXzqnr1.js";
5
- import { consume as $, provide as f } from "@lit/context";
6
- import { LitElement as v, html as d, nothing as b } from "lit";
7
- import { property as w, query as p, state as h, customElement as y } from "lit/decorators.js";
8
- import "rxjs";
9
- import { classMap as O } from "lit/directives/class-map.js";
10
- var x = Object.defineProperty, k = Object.getOwnPropertyDescriptor, n = (t, e, a, i) => {
11
- for (var s = i > 1 ? void 0 : i ? k(e, a) : e, l = t.length - 1, o; l >= 0; l--)
12
- (o = t[l]) && (s = (i ? o(e, a, s) : o(s)) || s);
13
- return i && s && x(e, a, s), s;
14
- };
15
- let r = class extends v {
16
- constructor() {
17
- super(...arguments), this.adapter = new c(), this.isCalendarOpen = !1, this.focusDate = void 0, this.subscriptions = [], this._ignoreNextFocusOut = !1, this.onFocusOut = (t) => {
18
- if (this._ignoreNextFocusOut) {
19
- this._ignoreNextFocusOut = !1;
20
- return;
21
- }
22
- if (!this.isCalendarOpen) return;
23
- const e = t.relatedTarget;
24
- e && this.contains(e) || this.closeCalendar();
25
- }, this.onDocumentClick = (t) => {
26
- if (!this.isCalendarOpen) return;
27
- const e = t.composedPath(), a = this.dateInput && e.includes(this.dateInput), i = this.calendarInput && e.includes(this.calendarInput);
28
- !a && !i && this.closeCalendar();
29
- }, this.onDropdownToggle = (t) => {
30
- t.detail?.open && this.isCalendarOpen && this.closeCalendar();
31
- };
32
- }
33
- createRenderRoot() {
34
- return this;
35
- }
36
- updated(t) {
37
- super.updated(t);
38
- const e = this.adapter.templateData.size;
39
- e ? this.style.flex = String(e) : this.style.removeProperty("flex");
40
- }
41
- connectedCallback() {
42
- super.connectedCallback(), document.addEventListener("click", this.onDocumentClick), this.addEventListener("focusout", this.onFocusOut), this.addEventListener("dropdowntoggle", this.onDropdownToggle), this.classList.add("gui-range-date-picker", "gui-field"), this.adapter.context = this.formContext, this.adapter.init(this.widget), this.subscriptions.push(
43
- this.adapter.templateDataChanged$.subscribe(() => this.requestUpdate())
44
- );
45
- }
46
- render() {
47
- super.render();
48
- const t = g("datePicker", this.adapter.templateData), e = this.isCalendarOpen ? d`<gui-range-calendar
49
- id="calendar-input"
50
- .uid=${this.widget.uid}
51
- .hint=${this.adapter.templateData.hint}
52
- ?touched=${this.adapter.templateData.touched}
53
- ?required=${this.adapter.templateData.validator?.required}
54
- ?disabled=${this.adapter.templateData.disabled}
55
- ?readonly=${this.adapter.templateData.readonly}
56
- .value=${this.adapter.templateData.value}
57
- .focusDate=${this.focusDate}
58
- .prevMonthIcon=${this.adapter.templateData.prevMonthIcon}
59
- .nextMonthIcon=${this.adapter.templateData.nextMonthIcon}
60
- .prevMonthAriaLabel=${this.adapter.templateData.prevMonthAriaLabel}
61
- .nextMonthAriaLabel=${this.adapter.templateData.nextMonthAriaLabel}
62
- .dayFormat=${this.adapter.templateData.dayFormat}
63
- .weekdayFormat=${this.adapter.templateData.weekdayFormat}
64
- .monthFormat=${this.adapter.templateData.monthFormat}
65
- .minDate=${this.adapter.templateData.minDate}
66
- .maxDate=${this.adapter.templateData.maxDate}
67
- .disabledRanges=${this.adapter.templateData.disabledRanges}
68
- .numberOfMonths=${this.adapter.templateData.numberOfMonths}
69
- .localeId=${this.adapter.templateData.lang}
70
- .hidePills=${!0}
71
- @blur=${this.onBlurCalendar}
72
- @change=${this.valueChanged}
73
- ></gui-range-calendar>` : b;
74
- return d`
75
- ${D(this.widget.uid, {
76
- ...this.adapter.templateData,
77
- required: this.adapter.templateData.validator?.required
78
- })}
79
-
80
- <div
81
- role="button"
82
- tabindex="-1"
83
- class="gui-widget"
84
- aria-expanded=${this.isCalendarOpen}
85
- @keyup=${(a) => this.onKeyUp(a)}
86
- @click=${(a) => this.toggleCalendar(a)}
87
- >
88
- <gui-range-date
89
- id="date-input"
90
- class=${O(t.widgetClasses)}
91
- .uid=${this.widget.uid}
92
- .hint=${this.adapter.templateData.hint}
93
- .showErrors=${!1}
94
- .errors=${this.adapter.templateData.errors}
95
- ?touched=${this.adapter.templateData.touched}
96
- ?required=${this.adapter.templateData.validator?.required}
97
- ?disabled=${this.adapter.templateData.disabled}
98
- ?readonly=${this.adapter.templateData.readonly}
99
- .value=${this.adapter.templateData.value}
100
- .icon=${this.adapter.templateData.icon}
101
- .localeId=${this.adapter.templateData.lang}
102
- .separator=${this.adapter.templateData.separator}
103
- .removePillAriaLabel=${this.adapter.templateData.removePillAriaLabel}
104
- .startDateAriaLabel=${this.adapter.templateData.startDateAriaLabel}
105
- .endDateAriaLabel=${this.adapter.templateData.endDateAriaLabel}
106
- @inputError=${this.onInputError}
107
- @blur=${() => this.adapter.onBlur()}
108
- @focus=${this.openCalendar}
109
- @change=${this.valueChanged}
110
- @pillClick=${this.onPillClick}
111
- ></gui-range-date>
112
- <span class="gui-range-date-picker__arrow"
113
- ><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 256 256">
114
- <path
115
- 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"
116
- ></path></svg
117
- ></span>
118
-
119
- ${e}
120
- </div>
121
-
122
- ${C(this.widget.uid, this.adapter.templateData)}
123
- `;
124
- }
125
- valueChanged(t) {
126
- this.adapter.injectValidationIssues(null), this.adapter.valueChanged(t.detail.value);
127
- }
128
- onBlurCalendar() {
129
- this.adapter.onBlur(), this.closeCalendar();
130
- }
131
- onInputError(t) {
132
- this.adapter.injectValidationIssues([t.detail.message]);
133
- }
134
- onPillClick(t) {
135
- this.focusDate = t.detail.range.start, this.openCalendar();
136
- }
137
- onKeyUp(t) {
138
- const e = t;
139
- e.target === e.currentTarget && (e?.key === "Enter" || e?.key === " ") && (this.isCalendarOpen ? this.closeCalendar() : this.openCalendar());
140
- }
141
- toggleCalendar(t) {
142
- const e = t.target, a = e.closest(".gui-range-date-input__part"), i = e.closest("gui-range-calendar");
143
- a || i ? this.openCalendar() : this.isCalendarOpen ? this.closeCalendar() : this.openCalendar();
144
- }
145
- openCalendar() {
146
- this.querySelector(".gui-pills__dropdown") && (this._ignoreNextFocusOut = !0), this.closePillsDropdown(), this.isCalendarOpen || (this.isCalendarOpen = !0, this.requestUpdate());
147
- }
148
- closeCalendar() {
149
- this.isCalendarOpen = !1, this.requestUpdate();
150
- }
151
- closePillsDropdown() {
152
- this.querySelector("gui-pills")?.closeDropdown?.();
153
- }
154
- disconnectedCallback() {
155
- super.disconnectedCallback(), document.removeEventListener("click", this.onDocumentClick), this.removeEventListener("focusout", this.onFocusOut), this.removeEventListener("dropdowntoggle", this.onDropdownToggle), this.adapter.destroy(), this.subscriptions.forEach((t) => t.unsubscribe());
156
- }
157
- };
158
- n([
159
- $({ context: u }),
160
- w({ attribute: !1 })
161
- ], r.prototype, "formContext", 2);
162
- n([
163
- f({ context: m })
164
- ], r.prototype, "adapter", 2);
165
- n([
166
- p("#date-input")
167
- ], r.prototype, "dateInput", 2);
168
- n([
169
- p("#calendar-input")
170
- ], r.prototype, "calendarInput", 2);
171
- n([
172
- h()
173
- ], r.prototype, "isCalendarOpen", 2);
174
- n([
175
- h()
176
- ], r.prototype, "focusDate", 2);
177
- r = n([
178
- y("gui-range-date-picker-input")
179
- ], r);
180
- export {
181
- r as RangeDatePickerElement
182
- };
@@ -1,75 +0,0 @@
1
- import { filterTap as A } from "@golemui/core";
2
- import { html as o, nothing as t } from "lit";
3
- import { classMap as y } from "lit/directives/class-map.js";
4
- class T {
5
- constructor(r, e) {
6
- r.addController(this), this.getTargets = e.getTargets, this.getState = e.getState;
7
- }
8
- hostConnected() {
9
- }
10
- hostUpdated() {
11
- const r = this.getTargets();
12
- if (!r) return;
13
- let e = [];
14
- r instanceof NodeList ? e = Array.from(r) : Array.isArray(r) ? e = r : e = [r];
15
- const { uid: l, templateData: a } = this.getState(), { touched: b, errors: c, readonly: f, disabled: _, hint: v } = a, $ = b && c && c.length > 0;
16
- A(
17
- e,
18
- (i) => !!i,
19
- (i) => {
20
- const n = (d, g) => {
21
- g ? i.setAttribute(d, g) : i.removeAttribute(d);
22
- };
23
- n("aria-describedby", v ? `${l}_hint` : null), n("aria-invalid", $ ? "true" : null), n("aria-errormessage", $ ? `${l}_errors` : null), n("aria-readonly", _ || f ? "true" : null);
24
- }
25
- );
26
- }
27
- }
28
- const q = (s, r, e = !1, l = void 0, a = !0) => a ? r.label ? o`<label
29
- class="gui-label"
30
- for=${s}
31
- data-cy=${`${s}_label`}
32
- id=${l ? `${s}_${l}_label` : `${s}_label`}
33
- >
34
- ${r.label + (r.required ? " *" : "")} ${h(s, r)}
35
- ${e ? u(s, r) : t}
36
- </label>` : t : r.label ? o`<span
37
- class="gui-label"
38
- data-cy=${`${s}_label`}
39
- id=${l ? `${s}_${l}_label` : `${s}_label`}
40
- >
41
- ${r.label + (r.required ? " *" : "")} ${h(s, r)}
42
- ${e ? u(s, r) : t}
43
- </span>` : t, h = (s, r) => r.hint ? o`<div class="gui-widget-hint" id=${`${s}_hint`}>${r.hint}</div>` : o``, E = (s, r) => {
44
- const e = {
45
- [`gui-${s}--icon`]: !1,
46
- [`gui-${s}--icon-right`]: !1
47
- };
48
- if (r.icon) {
49
- e[`gui-${s}--icon`] = !0;
50
- const l = {
51
- "gui-widget-icon": !0,
52
- [r.icon]: !0
53
- };
54
- return {
55
- widgetClasses: e,
56
- html: o`<span class=${y(l)} data-icon=${r.icon}></span>`
57
- };
58
- } else
59
- return { widgetClasses: e, html: o`` };
60
- }, u = (s, r) => {
61
- const e = r.touched && r.errors && r.errors.length > 0;
62
- return o`${e ? o`<ul class="gui-validator" id=${`${s}_errors`} data-cy=${`${s}_validator-errors`}>
63
- ${r.errors?.map(
64
- (l) => o`<li class="gui-validator__error" role="alert" data-cy=${`${s}_validator-error`}>
65
- ${l}
66
- </li>`
67
- )}
68
- </ul>` : ""}`;
69
- };
70
- export {
71
- T as G,
72
- E as a,
73
- q as b,
74
- u as c
75
- };