@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,232 @@
1
+ import { InputWidgetAdapter as v, formContext as y, inputContext as $ } from "@golemui/lit";
2
+ import "@golemui/gui-shared";
3
+ import { LitElement as b, html as p, nothing as c } from "lit";
4
+ import { repeat as f } from "lit-html/directives/repeat.js";
5
+ import { property as s, customElement as g } from "lit/decorators.js";
6
+ import { G as C, b as D, c as _ } from "./templates-Dk1jxLwS.js";
7
+ import { u as F, i as O } from "./one-of-DifUsEYY.js";
8
+ import { consume as w, provide as E } from "@lit/context";
9
+ import "rxjs";
10
+ var S = Object.defineProperty, q = Object.getOwnPropertyDescriptor, o = (t, i, d, a) => {
11
+ for (var e = a > 1 ? void 0 : a ? q(i, d) : i, l = t.length - 1, n; l >= 0; l--)
12
+ (n = t[l]) && (e = (a ? n(i, d, e) : n(e)) || e);
13
+ return a && e && S(i, d, e), e;
14
+ };
15
+ let r = class extends b {
16
+ constructor() {
17
+ super(...arguments), this.uid = void 0, this.label = void 0, this.localeId = "en", this.errors = [], this.touched = !1, this.required = !1, this.disabled = !1, this.readOnly = !1, this.value = void 0, this.hint = void 0, this.options = [], this.labelField = void 0, this.valueField = void 0, this.direction = "column", this.optionsLoading = !1, this.hasMatchingValue = !1, this.ariaController = new C(this, {
18
+ getTargets: () => this.querySelectorAll(`input[name="${this.uid}"]`),
19
+ getState: () => ({
20
+ uid: this.uid,
21
+ templateData: {
22
+ hint: this.hint,
23
+ errors: this.errors,
24
+ touched: this.touched,
25
+ // Radiogroup inputs can't be readonly
26
+ readonly: !1,
27
+ disabled: !1
28
+ }
29
+ })
30
+ });
31
+ }
32
+ createRenderRoot() {
33
+ return this;
34
+ }
35
+ connectedCallback() {
36
+ super.connectedCallback(), this.classList.add("gui-field");
37
+ }
38
+ render() {
39
+ super.render();
40
+ const t = {
41
+ uid: this.uid,
42
+ label: this.label,
43
+ errors: this.errors,
44
+ touched: this.touched,
45
+ required: this.required,
46
+ disabled: this.disabled,
47
+ readonly: this.readOnly,
48
+ value: this.value,
49
+ hint: this.hint,
50
+ options: this.options,
51
+ labelField: this.labelField,
52
+ valueField: this.valueField,
53
+ direction: this.direction
54
+ };
55
+ this.options = F(this.options, {
56
+ labelField: this.labelField,
57
+ valueField: this.valueField
58
+ });
59
+ const i = this.value;
60
+ this.hasMatchingValue = this.options?.length ? this.options.find(({ value: a }) => a === i) !== void 0 : !1;
61
+ const d = this.optionsLoading ? p`<span>Loading...</span>` : p`
62
+ ${f(
63
+ this.options || [],
64
+ (a) => a?.value,
65
+ (a, e) => {
66
+ const l = this.hasMatchingValue && a.value === t.value, n = !this.hasMatchingValue && e === 0, m = l || n;
67
+ return p`<label for=${`${this.uid}_${e}`}>
68
+ <input
69
+ type="radio"
70
+ tabindex=${m ? "0" : "-1"}
71
+ id=${`${this.uid}_${e}`}
72
+ data-cy=${`${this.uid}_radiogroup_${e}`}
73
+ name=${this.uid}
74
+ value=${a.value}
75
+ ?checked=${l}
76
+ ?required=${t.required}
77
+ ?disabled=${t.disabled || t.readonly}
78
+ @change=${this.valueChanged}
79
+ @blur=${this.onBlur}
80
+ />
81
+ ${a.label}
82
+ </label>`;
83
+ }
84
+ )}
85
+ `;
86
+ return p`
87
+ ${D(this.uid, t, !1, void 0, !1)}
88
+
89
+ <div
90
+ class="gui-widget${this.direction === "row" ? " gui-widget--horizontal" : ""}"
91
+ role="radiogroup"
92
+ id=${this.uid}
93
+ aria-labelledby=${t.label ? `${this.uid}_label` : c}
94
+ aria-describedby=${t.hint ? `${this.uid}_hint` : c}
95
+ >
96
+ ${d}
97
+ </div>
98
+
99
+ ${_(this.uid, t)}
100
+ `;
101
+ }
102
+ valueChanged(t) {
103
+ if (t.stopPropagation(), !this.readOnly) {
104
+ const i = t.target;
105
+ this.dispatchEvent(
106
+ new CustomEvent("change", {
107
+ detail: { value: O(i.value, this.options) },
108
+ bubbles: !0,
109
+ composed: !0
110
+ })
111
+ );
112
+ }
113
+ }
114
+ onBlur() {
115
+ this.dispatchEvent(
116
+ new CustomEvent("blur", {
117
+ bubbles: !0,
118
+ composed: !0
119
+ })
120
+ );
121
+ }
122
+ };
123
+ o([
124
+ s({ type: String })
125
+ ], r.prototype, "uid", 2);
126
+ o([
127
+ s({ type: String })
128
+ ], r.prototype, "label", 2);
129
+ o([
130
+ s({ type: String, attribute: "locale-id" })
131
+ ], r.prototype, "localeId", 2);
132
+ o([
133
+ s({ type: Array })
134
+ ], r.prototype, "errors", 2);
135
+ o([
136
+ s({ type: Boolean })
137
+ ], r.prototype, "touched", 2);
138
+ o([
139
+ s({ type: Boolean })
140
+ ], r.prototype, "required", 2);
141
+ o([
142
+ s({ type: Boolean })
143
+ ], r.prototype, "disabled", 2);
144
+ o([
145
+ s({ type: Boolean, attribute: "readonly" })
146
+ ], r.prototype, "readOnly", 2);
147
+ o([
148
+ s({ type: String })
149
+ ], r.prototype, "value", 2);
150
+ o([
151
+ s({ type: String })
152
+ ], r.prototype, "hint", 2);
153
+ o([
154
+ s({ type: String })
155
+ ], r.prototype, "options", 2);
156
+ o([
157
+ s({ type: String })
158
+ ], r.prototype, "labelField", 2);
159
+ o([
160
+ s({ type: String })
161
+ ], r.prototype, "valueField", 2);
162
+ o([
163
+ s({ type: String })
164
+ ], r.prototype, "direction", 2);
165
+ r = o([
166
+ g("gui-radiogroup")
167
+ ], r);
168
+ typeof customElements < "u" && !customElements.get("gui-radiogroup") && customElements.define("gui-radiogroup", r);
169
+ var x = Object.defineProperty, P = Object.getOwnPropertyDescriptor, h = (t, i, d, a) => {
170
+ for (var e = a > 1 ? void 0 : a ? P(i, d) : i, l = t.length - 1, n; l >= 0; l--)
171
+ (n = t[l]) && (e = (a ? n(i, d, e) : n(e)) || e);
172
+ return a && e && x(i, d, e), e;
173
+ };
174
+ let u = class extends b {
175
+ constructor() {
176
+ super(...arguments), this.adapter = new v(), this.subscriptions = [];
177
+ }
178
+ createRenderRoot() {
179
+ return this;
180
+ }
181
+ updated(t) {
182
+ super.updated(t);
183
+ const i = this.adapter.templateData.size;
184
+ i ? this.style.flex = String(i) : this.style.removeProperty("flex");
185
+ }
186
+ connectedCallback() {
187
+ super.connectedCallback(), this.classList.add("gui-radiogroup", "gui-field"), this.adapter.context = this.formContext, this.adapter.init(this.widget), this.subscriptions.push(
188
+ this.adapter.templateDataChanged$.subscribe(() => this.requestUpdate())
189
+ );
190
+ }
191
+ render() {
192
+ return super.render(), p`
193
+ <gui-radiogroup
194
+ .uid=${this.widget.uid}
195
+ .label=${this.adapter.templateData.label}
196
+ .errors=${this.adapter.templateData.errors}
197
+ ?touched=${this.adapter.templateData.touched}
198
+ ?required=${this.adapter.templateData.validator?.required}
199
+ ?disabled=${this.adapter.templateData.disabled}
200
+ ?readonly=${this.adapter.templateData.readonly}
201
+ .value=${this.adapter.templateData.value}
202
+ .hint=${this.adapter.templateData.hint}
203
+ .options=${this.adapter.templateData.options}
204
+ .labelField=${this.adapter.templateData.labelField}
205
+ .valueField=${this.adapter.templateData.valueField}
206
+ .direction=${this.adapter.templateData.direction}
207
+ @change=${this.valueChanged}
208
+ @blur=${() => this.adapter.onBlur()}
209
+ ></gui-radiogroup>
210
+ `;
211
+ }
212
+ valueChanged(t) {
213
+ const i = t.detail.value;
214
+ this.adapter.valueChanged(i);
215
+ }
216
+ disconnectedCallback() {
217
+ super.disconnectedCallback(), this.adapter.destroy(), this.subscriptions.forEach((t) => t.unsubscribe());
218
+ }
219
+ };
220
+ h([
221
+ w({ context: y }),
222
+ s({ attribute: !1 })
223
+ ], u.prototype, "formContext", 2);
224
+ h([
225
+ E({ context: $ })
226
+ ], u.prototype, "adapter", 2);
227
+ u = h([
228
+ g("gui-radiogroup-input")
229
+ ], u);
230
+ export {
231
+ u as RadiogroupElement
232
+ };
@@ -0,0 +1,326 @@
1
+ import { html as v, nothing as m } from "lit";
2
+ import { property as f, state as g, customElement as R } from "lit/decorators.js";
3
+ import { classMap as p } from "lit/directives/class-map.js";
4
+ import { repeat as M } from "lit-html/directives/repeat.js";
5
+ import { i as d, a as $, b, g as A, m as P, c as _ } from "./date-CG1562vW.js";
6
+ import { c as w } from "./tabs-DzSCq_98.js";
7
+ import { A as k } from "./abstract-calendar-YDgwwbqe.js";
8
+ import "@golemui/gui-shared";
9
+ var E = Object.defineProperty, V = Object.getOwnPropertyDescriptor, h = (e, t, i, a) => {
10
+ for (var n = a > 1 ? void 0 : a ? V(t, i) : t, s = e.length - 1, r; s >= 0; s--)
11
+ (r = e[s]) && (n = (a ? r(t, i, n) : r(n)) || n);
12
+ return a && n && E(t, i, n), n;
13
+ };
14
+ let l = class extends k {
15
+ constructor() {
16
+ super(...arguments), this.value = [], this.focusDate = void 0, this.hidePills = !1, this.removePillAriaLabel = void 0, this._anchorDate = null, this._nextDate = null, this._isSelecting = !1, this._isStartVisible = !0, this._isEndVisible = !0, this._skipValueNavigation = !1;
17
+ }
18
+ createRenderRoot() {
19
+ return this;
20
+ }
21
+ connectedCallback() {
22
+ super.connectedCallback(), this.classList.add("gui-field");
23
+ }
24
+ willUpdate(e) {
25
+ if (e.has("value") && !e.has("focusDate")) {
26
+ if (this._skipValueNavigation)
27
+ this._skipValueNavigation = !1;
28
+ else if (this.value) {
29
+ const t = Array.isArray(this.value) ? this.value : [{ start: this.value }];
30
+ if (t.length > 0 && t[0].start) {
31
+ const i = new Date(t[0].start);
32
+ !isNaN(i.getTime()) && !d(i, this._currentDate, this.numberOfMonths ?? 1) && (this._currentDate = i);
33
+ }
34
+ }
35
+ }
36
+ if (e.has("focusDate") && this.focusDate) {
37
+ const t = new Date(this.focusDate);
38
+ isNaN(t.getTime()) || (d(t, this._currentDate, this.numberOfMonths ?? 1) || (this._currentDate = t), this.focusDate = void 0);
39
+ }
40
+ }
41
+ renderDay(e) {
42
+ const t = {
43
+ "gui-calendar__day-button": !0,
44
+ today: e.isToday,
45
+ "other-month": !e.isCurrentMonth,
46
+ "range-start": e.isRangeStart && !e.isOneDayRange,
47
+ "range-end": e.isRangeEnd && !e.isOneDayRange,
48
+ selected: e.isOneDayRange,
49
+ "in-range": e.isInRange,
50
+ "is-anchor": e.isAnchor,
51
+ "is-selecting": e.isSelecting,
52
+ disabled: e.isDisabled
53
+ };
54
+ return v`
55
+ <button
56
+ type="button"
57
+ role="gridcell"
58
+ class=${p(t)}
59
+ tabindex=${e.isFocusable ? 0 : -1}
60
+ ?disabled=${!e.isCurrentMonth || e.isDisabled}
61
+ data-date=${e.date.toISOString()}
62
+ @click=${(i) => this.selectDate(e, i)}
63
+ @mouseover=${() => this.onMouseOver(e)}
64
+ @focus=${() => this.onMouseOver(e)}
65
+ @keydown=${(i) => this.handleKeydown(i, e)}
66
+ aria-selected=${e.isRangeStart || e.isRangeEnd || e.isInRange ? "true" : "false"}
67
+ >
68
+ ${e.dayLabel}
69
+ </button>
70
+ `;
71
+ }
72
+ getDaysInMonth(e) {
73
+ const t = new Date(this._currentDate);
74
+ t.setDate(1), t.setMonth(t.getMonth() + e);
75
+ const i = this.generateDateGrid(e), a = t.getMonth();
76
+ let n = i.map((s) => {
77
+ const r = s.getMonth() === a, o = this.isDisabled(s), c = $(s), { isRangeStart: u, isRangeEnd: D, isInRange: y, isSelecting: O } = this.checkDateStatus(s), S = c || u, T = this._anchorDate ? b(s, this._anchorDate) : !1;
78
+ return {
79
+ date: s,
80
+ dayLabel: A(this.localeId, s),
81
+ isCurrentMonth: r,
82
+ isToday: c,
83
+ isRangeStart: u,
84
+ isRangeEnd: D,
85
+ isInRange: y,
86
+ isDisabled: o,
87
+ isOneDayRange: u && D,
88
+ isAnchor: T,
89
+ isFocusable: S,
90
+ isSelecting: O && r
91
+ };
92
+ });
93
+ for (let s = 0; s < 2; s++)
94
+ n.slice(-7).every((o) => !o.isCurrentMonth) && (n = n.slice(0, -7));
95
+ if (e === 0 && !n.some((s) => s.isFocusable)) {
96
+ const s = this.numberOfMonths ?? 1, r = d(/* @__PURE__ */ new Date(), this._currentDate, s), o = this.value?.some(
97
+ (c) => d(new Date(c.start), this._currentDate, s)
98
+ ) ?? !1;
99
+ if (!r && !o) {
100
+ const c = n.find((u) => u.isCurrentMonth && !u.isDisabled);
101
+ c && (c.isFocusable = !0);
102
+ }
103
+ }
104
+ return n;
105
+ }
106
+ checkDateStatus(e) {
107
+ let t = !1, i = !1, a = !1, n = !1;
108
+ if (this._isSelecting && this._nextDate && this._anchorDate) {
109
+ const s = this._nextDate.date, r = new Date(this._anchorDate);
110
+ s.getTime() > r.getTime() ? n = e.getTime() >= r.getTime() && e.getTime() <= s.getTime() : n = e.getTime() >= s.getTime() && e.getTime() <= r.getTime();
111
+ }
112
+ if (this.value && Array.isArray(this.value))
113
+ for (const s of this.value) {
114
+ const r = new Date(s.start);
115
+ if (b(e, r) && (t = !0, i = !s.end), s.end) {
116
+ const o = new Date(s.end);
117
+ b(e, o) && (i = !0);
118
+ const c = e.getTime(), u = r.getTime(), D = o.getTime();
119
+ c > u && c < D && (a = !0);
120
+ }
121
+ }
122
+ return { isRangeStart: t, isRangeEnd: i, isInRange: a, isSelecting: n };
123
+ }
124
+ selectDate(e, t = null) {
125
+ if (!e.isCurrentMonth || this.disabled || this.readOnly) return;
126
+ const i = e.date;
127
+ if (!this._anchorDate) {
128
+ this._isSelecting = !0, this._anchorDate = i;
129
+ return;
130
+ }
131
+ let a = this._anchorDate, n = i;
132
+ i < a && (a = i, n = this._anchorDate);
133
+ const s = this.calculateValidRanges(a, n), r = [...this.value || [], ...s];
134
+ this._skipValueNavigation = !0, this.value = P(r), this._isSelecting = !1, this._nextDate = null, this._anchorDate = null, this.dispatchEvent(
135
+ new CustomEvent("change", {
136
+ detail: { value: this.value },
137
+ bubbles: !0,
138
+ composed: !0
139
+ })
140
+ );
141
+ }
142
+ /**
143
+ * Calculates and returns an array of valid date ranges between the given start date and end date.
144
+ * A date range is considered valid if no dates within the range are disabled.
145
+ *
146
+ * @param {Date} startDate - The starting date for the range calculation.
147
+ * @param {Date} endDate - The ending date for the range calculation.
148
+ * @return {DateRange[]} An array of valid date ranges where each range defines consecutive, non-disabled dates.
149
+ */
150
+ calculateValidRanges(e, t) {
151
+ const i = [], a = new Date(e), n = new Date(t);
152
+ a.setHours(0, 0, 0, 0), n.setHours(0, 0, 0, 0);
153
+ let s = null;
154
+ for (; a <= n; ) {
155
+ if (!this.isDisabled(a))
156
+ s || (s = new Date(a));
157
+ else if (s) {
158
+ const o = new Date(a);
159
+ o.setDate(a.getDate() - 1), i.push(_(s, o)), s = null;
160
+ }
161
+ a.setDate(a.getDate() + 1);
162
+ }
163
+ return s && i.push(_(s, t)), i;
164
+ }
165
+ onMouseOver(e) {
166
+ this._isSelecting && (this._nextDate = e);
167
+ }
168
+ // --- Pills ---
169
+ updated() {
170
+ this.hidePills || this.setupObservers();
171
+ }
172
+ disconnectedCallback() {
173
+ super.disconnectedCallback(), this.disconnectObservers();
174
+ }
175
+ renderAboveCalendar() {
176
+ if (this.hidePills) return m;
177
+ const e = this.getSortedPills();
178
+ return e.length === 0 ? m : v`
179
+ <div
180
+ class=${p({
181
+ "gui-range-calendar__pills-wrapper": !0,
182
+ "gui-range-calendar--start-shadow": !this._isStartVisible,
183
+ "gui-range-calendar--end-shadow": !this._isEndVisible
184
+ })}
185
+ >
186
+ <div class="gui-range-calendar__pills" role="list">
187
+ <span class="gui-sentinel gui-sentinel__start"></span>
188
+ ${M(
189
+ e,
190
+ (t) => `${t.start}-${t.end ?? t.start}`,
191
+ (t, i) => this.renderPill(t, i)
192
+ )}
193
+ <span class="gui-sentinel gui-sentinel__end"></span>
194
+ </div>
195
+ </div>
196
+ `;
197
+ }
198
+ renderPill(e, t) {
199
+ const i = this.formatDateForDisplay(e.start), a = e.end ? this.formatDateForDisplay(e.end) : i, n = `${i} - ${a}`;
200
+ return v`
201
+ <div
202
+ class="gui-range-calendar__pill"
203
+ role="listitem"
204
+ tabindex="0"
205
+ aria-label="${this.removePillAriaLabel ?? "Remove date"} ${n}"
206
+ @click=${() => this.navigateToDate(e.start)}
207
+ @keydown=${(s) => this.handlePillKeydown(s, t)}
208
+ >
209
+ <span class="gui-range-calendar__pill-text">${n}</span>
210
+ <button
211
+ type="button"
212
+ class="gui-range-calendar__pill-remove"
213
+ tabindex="-1"
214
+ ?disabled=${this.disabled || this.readOnly}
215
+ @click=${(s) => {
216
+ s.stopPropagation(), this.removePill(t);
217
+ }}
218
+ >
219
+ <svg
220
+ xmlns="http://www.w3.org/2000/svg"
221
+ width="16"
222
+ height="16"
223
+ viewBox="0 0 256 256"
224
+ fill="currentColor"
225
+ aria-hidden="true"
226
+ >
227
+ <path
228
+ 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"
229
+ ></path>
230
+ </svg>
231
+ </button>
232
+ </div>
233
+ `;
234
+ }
235
+ formatDateForDisplay(e) {
236
+ const t = new Date(e);
237
+ return isNaN(t.getTime()) ? e : new Intl.DateTimeFormat(this.localeId ?? "en", {
238
+ year: "numeric",
239
+ month: "2-digit",
240
+ day: "2-digit"
241
+ }).format(t);
242
+ }
243
+ getSortedPills() {
244
+ return !this.value || !Array.isArray(this.value) ? [] : [...this.value].sort(
245
+ (e, t) => new Date(e.start).getTime() - new Date(t.start).getTime()
246
+ );
247
+ }
248
+ removePill(e) {
249
+ if (this.disabled || this.readOnly) return;
250
+ const t = this.getSortedPills();
251
+ t.splice(e, 1), this.value = [...t], this.dispatchEvent(
252
+ new CustomEvent("change", {
253
+ detail: { value: this.value },
254
+ bubbles: !0,
255
+ composed: !0
256
+ })
257
+ );
258
+ }
259
+ handlePillKeydown(e, t) {
260
+ if (e.key === "Delete" || e.key === "Backspace") {
261
+ e.preventDefault(), this.removePill(t);
262
+ return;
263
+ }
264
+ if (e.key === "Enter") {
265
+ e.preventDefault();
266
+ const i = this.getSortedPills();
267
+ i[t] && this.navigateToDate(i[t].start);
268
+ return;
269
+ }
270
+ if (e.key === "ArrowLeft" || e.key === "ArrowRight") {
271
+ e.preventDefault();
272
+ const i = this.querySelectorAll(
273
+ ".gui-range-calendar__pills .gui-range-calendar__pill"
274
+ ), a = e.key === "ArrowLeft" ? t - 1 : t + 1;
275
+ a >= 0 && a < i.length && i[a].focus();
276
+ }
277
+ }
278
+ navigateToDate(e) {
279
+ const t = new Date(e);
280
+ !isNaN(t.getTime()) && !d(t, this._currentDate, this.numberOfMonths ?? 1) && (this._currentDate = t);
281
+ }
282
+ setupObservers() {
283
+ const e = this.querySelector(".gui-sentinel__start"), t = this.querySelector(".gui-sentinel__end");
284
+ e && !this.startObserver && (this.startObserver = w(
285
+ e,
286
+ (i) => this._isStartVisible = i
287
+ )), t && !this.endObserver && (this.endObserver = w(
288
+ t,
289
+ (i) => this._isEndVisible = i
290
+ )), !e && this.startObserver && (this.startObserver.disconnect(), this.startObserver = void 0, this._isStartVisible = !0), !t && this.endObserver && (this.endObserver.disconnect(), this.endObserver = void 0, this._isEndVisible = !0);
291
+ }
292
+ disconnectObservers() {
293
+ this.startObserver?.disconnect(), this.endObserver?.disconnect(), this.startObserver = void 0, this.endObserver = void 0;
294
+ }
295
+ };
296
+ h([
297
+ f({ type: Array })
298
+ ], l.prototype, "value", 2);
299
+ h([
300
+ f({ type: String })
301
+ ], l.prototype, "focusDate", 2);
302
+ h([
303
+ f({ type: Boolean })
304
+ ], l.prototype, "hidePills", 2);
305
+ h([
306
+ f({ type: String })
307
+ ], l.prototype, "removePillAriaLabel", 2);
308
+ h([
309
+ g()
310
+ ], l.prototype, "_anchorDate", 2);
311
+ h([
312
+ g()
313
+ ], l.prototype, "_nextDate", 2);
314
+ h([
315
+ g()
316
+ ], l.prototype, "_isSelecting", 2);
317
+ h([
318
+ g()
319
+ ], l.prototype, "_isStartVisible", 2);
320
+ h([
321
+ g()
322
+ ], l.prototype, "_isEndVisible", 2);
323
+ l = h([
324
+ R("gui-range-calendar")
325
+ ], l);
326
+ typeof customElements < "u" && !customElements.get("gui-range-calendar") && customElements.define("gui-range-calendar", l);
@@ -1,15 +1,18 @@
1
- import * as n from "@golemui/lit";
2
- import { consume as o, provide as h } from "@lit/context";
3
- import { LitElement as m, html as u } from "lit";
4
- import { property as c, customElement as b } from "lit/decorators.js";
5
- var D = Object.defineProperty, $ = Object.getOwnPropertyDescriptor, d = (e, t, s, r) => {
6
- for (var a = r > 1 ? void 0 : r ? $(t, s) : t, p = e.length - 1, l; p >= 0; p--)
1
+ import { InputWidgetAdapter as d, formContext as o, inputContext as h } from "@golemui/lit";
2
+ import "@golemui/gui-shared";
3
+ import "./range-calendar-qpakwAba.js";
4
+ import { consume as m, provide as u } from "@lit/context";
5
+ import { LitElement as c, html as b } from "lit";
6
+ import { property as D, customElement as $ } from "lit/decorators.js";
7
+ import "rxjs";
8
+ var g = Object.defineProperty, f = Object.getOwnPropertyDescriptor, n = (e, t, s, r) => {
9
+ for (var a = r > 1 ? void 0 : r ? f(t, s) : t, p = e.length - 1, l; p >= 0; p--)
7
10
  (l = e[p]) && (a = (r ? l(t, s, a) : l(a)) || a);
8
- return r && a && D(t, s, a), a;
11
+ return r && a && g(t, s, a), a;
9
12
  };
10
- let i = class extends m {
13
+ let i = class extends c {
11
14
  constructor() {
12
- super(...arguments), this.adapter = new n.InputWidgetAdapter(), this.subscriptions = [];
15
+ super(...arguments), this.adapter = new d(), this.subscriptions = [];
13
16
  }
14
17
  createRenderRoot() {
15
18
  return this;
@@ -25,7 +28,7 @@ let i = class extends m {
25
28
  );
26
29
  }
27
30
  render() {
28
- return super.render(), u`
31
+ return super.render(), b`
29
32
  <gui-range-calendar
30
33
  .uid=${this.widget.uid}
31
34
  .label=${this.adapter.templateData.label}
@@ -63,15 +66,15 @@ let i = class extends m {
63
66
  super.disconnectedCallback(), this.adapter.destroy(), this.subscriptions.forEach((e) => e.unsubscribe());
64
67
  }
65
68
  };
66
- d([
67
- o({ context: n.formContext }),
68
- c({ attribute: !1 })
69
+ n([
70
+ m({ context: o }),
71
+ D({ attribute: !1 })
69
72
  ], i.prototype, "formContext", 2);
70
- d([
71
- h({ context: n.inputContext })
73
+ n([
74
+ u({ context: h })
72
75
  ], i.prototype, "adapter", 2);
73
- i = d([
74
- b("gui-range-calendar-input")
76
+ i = n([
77
+ $("gui-range-calendar-input")
75
78
  ], i);
76
79
  export {
77
80
  i as RangeCalendarElement