@golemui/gui-lit 0.14.0 → 0.15.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.
- package/CHANGELOG.md +22 -0
- package/{button.element-ATNRRDN3.js → button.element-DxwYDdu6.js} +49 -45
- package/{currency.element-C7SZkoPP.js → currency.element-ybKzwXEh.js} +11 -10
- package/{date-input-e0k3oBof.js → date-input-D_Swskk4.js} +5 -5
- package/{date-picker.element-D6v6aHR5.js → date-picker.element-CP2_u_ZE.js} +1 -1
- package/{date.element-COU_mEUt.js → date.element-p6aB6OGd.js} +1 -1
- package/{dropdown.element-DCUI5Y7I.js → dropdown.element-8OaBgk7F.js} +1 -0
- package/index.js +271 -279
- package/index.umd.cjs +268 -195
- package/lib/components/range-date-picker.element.d.ts +3 -0
- package/lib/components/tags.element.d.ts +17 -0
- package/{markdown.element-CT1JOOM3.js → markdown.element-1IF3G5KX.js} +1 -0
- package/{number.element-HaXEg_7U.js → number.element-zgd4L5hn.js} +7 -6
- package/package.json +6 -6
- package/{password.element-B4-0SCe4.js → password.element-BT65mDsp.js} +1 -0
- package/pills-D0yyi-op.js +323 -0
- package/range-calendar-CZGBBOzO.js +258 -0
- package/{range-calendar.element-C-4qqRGK.js → range-calendar.element-DQZXvd-L.js} +1 -1
- package/range-date-input-CcPYH7P3.js +398 -0
- package/{range-date-input.element-D3xRMAaY.js → range-date-input.element-v71P-oUp.js} +1 -1
- package/{range-date-picker.element-Vgj3tFlQ.js → range-date-picker.element-CA-KcQhA.js} +60 -51
- package/{select.element-DuGZjlZY.js → select.element-CjWqp9dd.js} +1 -1
- package/tags.element-ed1_51GA.js +365 -0
- package/{textarea.element-C8yx2u0o.js → textarea.element-BTJLqnnI.js} +6 -5
- package/{textinput.element-DKuplF1A.js → textinput.element-zI0iG-Cq.js} +4 -3
- package/range-calendar-qpakwAba.js +0 -326
- package/range-date-input-DFnvo-KK.js +0 -507
|
@@ -1,507 +0,0 @@
|
|
|
1
|
-
import "@golemui/gui-shared";
|
|
2
|
-
import { LitElement as w, nothing as g, html as p } from "lit";
|
|
3
|
-
import { repeat as v } from "lit-html/directives/repeat.js";
|
|
4
|
-
import { property as h, state as y, customElement as D } from "lit/decorators.js";
|
|
5
|
-
import { classMap as m } from "lit/directives/class-map.js";
|
|
6
|
-
import { live as P } from "lit/directives/live.js";
|
|
7
|
-
import { G as I, b as A, c as $ } from "./templates-Dk1jxLwS.js";
|
|
8
|
-
import { t as f, m as O } from "./date-CG1562vW.js";
|
|
9
|
-
import { c as b } from "./tabs-DzSCq_98.js";
|
|
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);
|