@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.
- package/CHANGELOG.md +11 -0
- package/calendar-BuJgwvZx.js +254 -0
- package/{calendar.element-DcnTyvfg.js → calendar.element-M5MPJmap.js} +1 -1
- package/{currency.element-5GSakkxF.js → currency.element-CfFrAtrr.js} +4 -1
- package/{date-CDUlLuYy.js → date-Bj9mI3GU.js} +80 -29
- package/date-input-cJDkNnVw.js +184 -0
- package/date-picker.element-va_-LGZD.js +312 -0
- package/date-time-calendar-BzRfkLKU.js +361 -0
- package/date-time-calendar.element-DC4NK0y1.js +93 -0
- package/date-time-input-BXxsfuyZ.js +214 -0
- package/date-time-picker.element-Dy-8cb-_.js +380 -0
- package/date-time.element-Bv4XdzMi.js +87 -0
- package/{date.element-BZO0UQez.js → date.element-Consgsbb.js} +32 -27
- package/day-status-0-hJHrI7.js +530 -0
- package/{dropdown.element-CyJbVAA5.js → dropdown.element-WsD61Qel.js} +46 -36
- package/focus-leave.controller-2gV0pQd5.js +73 -0
- package/index.js +1199 -971
- package/index.umd.cjs +1582 -530
- package/lib/components/date-picker.element.d.ts +0 -11
- package/lib/components/date-time-calendar.element.d.ts +18 -0
- package/lib/components/date-time-picker.element.d.ts +18 -0
- package/lib/components/date-time.element.d.ts +18 -0
- package/lib/components/dropdown.element.d.ts +2 -0
- package/lib/components/range-calendar.element.d.ts +2 -1
- package/lib/components/range-date-picker.element.d.ts +0 -15
- package/lib/components/range-date-time-calendar.element.d.ts +18 -0
- package/lib/components/range-date-time-input.element.d.ts +18 -0
- package/lib/components/range-date-time-picker.element.d.ts +18 -0
- package/lib/components/range-time-input.element.d.ts +18 -0
- package/lib/components/range-time-picker.element.d.ts +18 -0
- package/lib/components/time-picker.element.d.ts +18 -0
- package/lib/components/time.element.d.ts +18 -0
- package/{list-D1oKnH89.js → list-CrLIL4by.js} +76 -61
- package/{list.element-Co3V3Cn5.js → list.element-DV82YxnJ.js} +22 -22
- package/package.json +6 -6
- package/part-templates-Db871PS3.js +677 -0
- package/pill-ranges-DCqDmpkk.js +48 -0
- package/{pills-B66qz_KX.js → pills-Be1UrLgq.js} +4 -1
- package/popup.controller-eUDxE6jD.js +71 -0
- package/range-calendar-CKPYeSGt.js +452 -0
- package/{range-calendar.element-_1bHW_c1.js → range-calendar.element-D6KYq18B.js} +24 -20
- package/range-commit-8-MmYUyo.js +14 -0
- package/range-date-input-D--AqBMv.js +292 -0
- package/{range-date-input.element-BqzAF0O3.js → range-date-input.element-D4nIXJbw.js} +8 -7
- package/range-date-picker.element-dhxPAAE6.js +386 -0
- package/range-date-time-calendar-yksWrR7b.js +720 -0
- package/range-date-time-calendar.element-C00aDefZ.js +95 -0
- package/range-date-time-input-B37TUoM3.js +322 -0
- package/range-date-time-input.element-DUnbv4ed.js +81 -0
- package/range-date-time-picker.element-Cbps6s_G.js +412 -0
- package/range-selection-CU3hxLJE.js +25 -0
- package/range-time-input-3lhqR1Ku.js +329 -0
- package/range-time-input.element-dU2iBdmJ.js +81 -0
- package/range-time-picker.element-v6nQsIPw.js +429 -0
- package/{select.element-jcDF1h-g.js → select.element-C0V-Bv3L.js} +94 -90
- package/{tags.element-CX3vQL8L.js → tags.element-DvwEpxpK.js} +1 -1
- package/time-input-BOhlBGJZ.js +181 -0
- package/time-list-Czo48bZm.js +217 -0
- package/time-picker-bFJ63ky8.js +261 -0
- package/time-picker.element-CYZVXgRS.js +85 -0
- package/time.element-fK3oLi49.js +82 -0
- package/abstract-calendar-D0-077XJ.js +0 -545
- package/calendar-BclCC9VJ.js +0 -96
- package/date-input-DCdGWRio.js +0 -268
- package/date-picker.element-k7AJFQ5W.js +0 -168
- package/range-calendar-CBINu84w.js +0 -255
- package/range-date-input-BYXzqnr1.js +0 -395
- package/range-date-picker.element-BCBefgvY.js +0 -182
|
@@ -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
|
-
};
|