@webority/ui-elements 0.7.5 → 0.7.7
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/dist/ui-elements.global.js +105 -46
- package/dist/ui-elements.js +855 -215
- package/package.json +1 -1
package/dist/ui-elements.js
CHANGED
|
@@ -43,6 +43,7 @@ function c(e, t) {
|
|
|
43
43
|
return;
|
|
44
44
|
}
|
|
45
45
|
r || (r = document.createElement("input"), r.type = "hidden", r.setAttribute(s, ""), e.appendChild(r)), r.name = n, r.value = t == null ? "" : String(t);
|
|
46
|
+
for (let t of [...r.attributes]) t.name.startsWith("data-val") && !e.hasAttribute(t.name) && r.removeAttribute(t.name);
|
|
46
47
|
for (let t of e.attributes) t.name.startsWith("data-val") && r.setAttribute(t.name, t.value);
|
|
47
48
|
r.disabled = e.hasAttribute("disabled");
|
|
48
49
|
}
|
|
@@ -75,7 +76,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
75
76
|
];
|
|
76
77
|
}
|
|
77
78
|
constructor() {
|
|
78
|
-
super(), this._value = "", this._label = "", this._optionsProp = null, this._loading = !1, this._active = -1, this._timer = null;
|
|
79
|
+
super(), this._value = "", this._label = "", this._optionsProp = null, this._loading = !1, this._active = -1, this._timer = null, this._reqSeq = 0, this._pendingSearch = null;
|
|
79
80
|
try {
|
|
80
81
|
this._internals = this.attachInternals();
|
|
81
82
|
} catch {
|
|
@@ -83,7 +84,14 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
83
84
|
}
|
|
84
85
|
}
|
|
85
86
|
connectedCallback() {
|
|
86
|
-
|
|
87
|
+
if (!this._rendered) {
|
|
88
|
+
this._defaultCaptured ||= (this._defaultValue = this._value, !0), this.render();
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
if (this._bindGlobal?.(), this._pendingSearch) {
|
|
92
|
+
let { query: e, seq: t } = this._pendingSearch;
|
|
93
|
+
clearTimeout(this._timer), this._timer = setTimeout(() => this._fireSearch(e, t), this._debounceMs);
|
|
94
|
+
}
|
|
87
95
|
}
|
|
88
96
|
formResetCallback() {
|
|
89
97
|
this.value = this._defaultValue || "";
|
|
@@ -153,14 +161,16 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
153
161
|
render() {
|
|
154
162
|
this._snapshotDeclared();
|
|
155
163
|
let e = this.getAttribute("placeholder") || "Search…", t = this.getAttribute("size"), n = t === "sm" ? " search-select-sm" : t === "lg" ? " search-select-lg" : "";
|
|
156
|
-
this.
|
|
164
|
+
this.id ||= `wui-autocomplete-${Math.random().toString(36).slice(2, 9)}`;
|
|
165
|
+
let r = `${this.id}-listbox`;
|
|
166
|
+
this._listboxId = r, this.innerHTML = `
|
|
157
167
|
<div class="search-select${n}">
|
|
158
|
-
<div class="input search-select-control search-select-ac" role="combobox" aria-haspopup="listbox" aria-expanded="false" aria-label="${m(this._accessibleName())}">
|
|
168
|
+
<div class="input search-select-control search-select-ac" role="combobox" aria-haspopup="listbox" aria-expanded="false" aria-controls="${m(r)}" aria-label="${m(this._accessibleName())}">
|
|
159
169
|
<input class="search-select-input search-select-ac-input" placeholder="${m(e)}" aria-autocomplete="list" autocomplete="off"${this.hasAttribute("disabled") ? " disabled" : ""} />
|
|
160
170
|
<span class="search-select-spinner spinner-border spinner-border-sm" role="status" aria-hidden="true" hidden></span>
|
|
161
171
|
<button type="button" class="search-select-clear" aria-label="Clear" hidden><i class="bi bi-x" aria-hidden="true"></i></button>
|
|
162
172
|
</div>
|
|
163
|
-
<div class="search-select-menu search-select-menu-fixed" role="listbox" tabindex="-1" hidden>
|
|
173
|
+
<div class="search-select-menu search-select-menu-fixed" role="listbox" id="${m(r)}" tabindex="-1" hidden>
|
|
164
174
|
<div class="search-select-options"></div>
|
|
165
175
|
<div class="search-select-empty" hidden>No matches</div>
|
|
166
176
|
<div class="search-select-hint" hidden>Type to search…</div>
|
|
@@ -198,26 +208,28 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
198
208
|
let a = n.trim(), o = this._allowCustom && a && !this._matchesKnownOption(a) ? [...i, {
|
|
199
209
|
value: a,
|
|
200
210
|
custom: !0
|
|
201
|
-
}] : i
|
|
202
|
-
t.optionsWrap.innerHTML = o.map((e) => {
|
|
211
|
+
}] : i, s = this._listboxId || `${this.id || "wui-autocomplete"}-listbox`;
|
|
212
|
+
t.optionsWrap.innerHTML = o.map((e, t) => {
|
|
213
|
+
let n = `${s}-opt-${t}`;
|
|
203
214
|
if (e.custom) {
|
|
204
215
|
let t = `Add “${u(e.value)}”`;
|
|
205
|
-
return `<button type="button" role="option" class="search-select-option search-select-option-custom" data-value="${m(e.value)}" data-custom="true" aria-selected="false">${t}</button>`;
|
|
216
|
+
return `<button type="button" role="option" id="${m(n)}" class="search-select-option search-select-option-custom" data-value="${m(e.value)}" data-custom="true" aria-selected="false">${t}</button>`;
|
|
206
217
|
}
|
|
207
|
-
let
|
|
208
|
-
return `<button type="button" role="option" class="search-select-option${
|
|
209
|
-
}).join(""), this._active = -1;
|
|
210
|
-
let
|
|
211
|
-
t.hint && (t.hint.hidden = !(this._remote &&
|
|
218
|
+
let r = String(e.value) === String(this._value);
|
|
219
|
+
return `<button type="button" role="option" id="${m(n)}" class="search-select-option${r ? " selected" : ""}" data-value="${m(e.value)}" aria-selected="${r}">${f(e)}</button>`;
|
|
220
|
+
}).join(""), this._active = -1, t.control?.removeAttribute("aria-activedescendant");
|
|
221
|
+
let c = r.length < this._minChars;
|
|
222
|
+
t.hint && (t.hint.hidden = !(this._remote && c && !i.length)), t.empty && (t.empty.hidden = this._loading || o.length > 0 || this._remote && c);
|
|
212
223
|
}
|
|
213
224
|
_wire() {
|
|
225
|
+
this._teardown();
|
|
214
226
|
let e = this._refs();
|
|
215
227
|
if (!e.control || !e.input) return;
|
|
216
|
-
let t = () => i(e.control, e.menu, { matchWidth: !0 }), n = () => this._optionEls().filter((e) => !e.hidden), r = (
|
|
217
|
-
let
|
|
218
|
-
this._active =
|
|
228
|
+
let t = () => i(e.control, e.menu, { matchWidth: !0 }), n = () => this._optionEls().filter((e) => !e.hidden), r = (t) => {
|
|
229
|
+
let r = n();
|
|
230
|
+
this._active = t;
|
|
219
231
|
for (let e of this._optionEls()) e.classList.remove("is-active");
|
|
220
|
-
|
|
232
|
+
t >= 0 && r[t] ? (r[t].classList.add("is-active"), r[t].scrollIntoView({ block: "nearest" }), e.control.setAttribute("aria-activedescendant", r[t].id)) : e.control.removeAttribute("aria-activedescendant");
|
|
221
233
|
}, o = () => !e.menu.hidden, s = () => {
|
|
222
234
|
e.menu.hidden = !1, e.control.setAttribute("aria-expanded", "true"), e.control.classList.add("open"), t(), this._renderOptions();
|
|
223
235
|
}, l = () => {
|
|
@@ -237,13 +249,15 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
237
249
|
e.input.addEventListener("focus", () => s()), e.input.addEventListener("input", () => {
|
|
238
250
|
let t = e.input.value;
|
|
239
251
|
if (e.clear && (e.clear.hidden = !t), o() || s(), this._remote) {
|
|
240
|
-
if (this._renderOptions(t), t.trim().length < this._minChars)
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
252
|
+
if (this._renderOptions(t), clearTimeout(this._timer), t.trim().length < this._minChars) {
|
|
253
|
+
this._pendingSearch = null;
|
|
254
|
+
return;
|
|
255
|
+
}
|
|
256
|
+
let e = ++this._reqSeq;
|
|
257
|
+
this._pendingSearch = {
|
|
258
|
+
query: t,
|
|
259
|
+
seq: e
|
|
260
|
+
}, this._timer = setTimeout(() => this._fireSearch(t, e), this._debounceMs);
|
|
247
261
|
} else this._renderOptions(t);
|
|
248
262
|
}), e.input.addEventListener("keydown", (t) => {
|
|
249
263
|
let i = n();
|
|
@@ -268,16 +282,30 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
268
282
|
t && r(this._optionEls().indexOf(t));
|
|
269
283
|
}), e.optionsWrap.addEventListener("mouseleave", () => r(-1)), e.clear?.addEventListener("click", () => {
|
|
270
284
|
this._value = "", this._label = "", c(this, ""), e.input.value = "", e.clear.hidden = !0, this._renderOptions(""), this.dispatchEvent(new Event("change", { bubbles: !0 })), e.input.focus();
|
|
271
|
-
}), this.
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
285
|
+
}), this._bindGlobal = () => {
|
|
286
|
+
this._teardown(), this._onDocClick = (e) => {
|
|
287
|
+
o() && !this.contains(e.target) && l();
|
|
288
|
+
}, document.addEventListener("click", this._onDocClick), a(this, () => {
|
|
289
|
+
o() && t();
|
|
290
|
+
});
|
|
291
|
+
}, this._bindGlobal();
|
|
292
|
+
}
|
|
293
|
+
_fireSearch(e, t) {
|
|
294
|
+
this._pendingSearch = null, this.dispatchEvent(new CustomEvent("search", {
|
|
295
|
+
bubbles: !0,
|
|
296
|
+
detail: {
|
|
297
|
+
query: e,
|
|
298
|
+
seq: t
|
|
299
|
+
}
|
|
300
|
+
}));
|
|
301
|
+
}
|
|
302
|
+
_teardown() {
|
|
303
|
+
this._onDocClick &&= (document.removeEventListener("click", this._onDocClick), null), o(this), clearTimeout(this._timer);
|
|
276
304
|
}
|
|
277
305
|
disconnectedCallback() {
|
|
278
|
-
this.
|
|
306
|
+
this._teardown();
|
|
279
307
|
}
|
|
280
|
-
}, m = (e) => String(e ?? "").replace(/"/g, """).replace(/</g, "<"), h = (e) => String(e ?? "").replace(/<[^>]*>/g, ""), g = [
|
|
308
|
+
}, m = (e) => String(e ?? "").replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<"), h = (e) => String(e ?? "").replace(/<[^>]*>/g, ""), g = [
|
|
281
309
|
"January",
|
|
282
310
|
"February",
|
|
283
311
|
"March",
|
|
@@ -342,10 +370,14 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
342
370
|
this._viewY = e.getFullYear(), this._viewM = e.getMonth(), this._mode = "days", this._focus = null, this._slide = "";
|
|
343
371
|
}
|
|
344
372
|
connectedCallback() {
|
|
345
|
-
this._rendered
|
|
373
|
+
if (!this._rendered) {
|
|
374
|
+
this.render();
|
|
375
|
+
return;
|
|
376
|
+
}
|
|
377
|
+
this._bindGlobal?.();
|
|
346
378
|
}
|
|
347
379
|
attributeChangedCallback(e, t, n) {
|
|
348
|
-
this._rendered && (e === "value" ? (this._value = n || "", this._syncTrigger()) : e === "first-day" ? this.querySelector(".datepicker-pop")?.hidden || this._renderView() : this.render());
|
|
380
|
+
this._rendered && (e === "value" ? (this._value = n || "", this._syncFormValue(), this._syncTrigger()) : e === "first-day" ? this.querySelector(".datepicker-pop")?.hidden || this._renderView() : this.render());
|
|
349
381
|
}
|
|
350
382
|
formResetCallback() {
|
|
351
383
|
this.value = this._defaultValue || "";
|
|
@@ -354,14 +386,14 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
354
386
|
return this._value;
|
|
355
387
|
}
|
|
356
388
|
set value(e) {
|
|
357
|
-
this._value = e || "", c(this, this._value), this._syncTrigger()
|
|
389
|
+
this._value = e || "", c(this, this._value), this._syncTrigger();
|
|
358
390
|
}
|
|
359
391
|
_firstDay() {
|
|
360
392
|
let e = Number.parseInt(this.getAttribute("first-day") ?? "", 10);
|
|
361
393
|
return Number.isInteger(e) && e >= 0 && e <= 6 ? e : 0;
|
|
362
394
|
}
|
|
363
395
|
render() {
|
|
364
|
-
this._defaultValue === void 0 && (this._defaultValue = this.getAttribute("value") || ""
|
|
396
|
+
this._defaultValue === void 0 && (this._defaultValue = this.getAttribute("value") || "", this._value = this._defaultValue || this._value);
|
|
365
397
|
let e = this.getAttribute("placeholder") || "Enter Date", t = b(this._value);
|
|
366
398
|
t && (this._viewY = t.y, this._viewM = t.m);
|
|
367
399
|
let n = this.getAttribute("size"), r = n === "sm" ? " input-sm" : n === "lg" ? " input-lg" : "", i = this.getAttribute("aria-label"), a = this.getAttribute("aria-describedby");
|
|
@@ -522,7 +554,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
522
554
|
}
|
|
523
555
|
case "Enter":
|
|
524
556
|
case " ":
|
|
525
|
-
e.preventDefault(), this._limits().dayDisabled(t.y, t.m, t.d) || (this.value = y(t.y, t.m, t.d), this._close());
|
|
557
|
+
e.preventDefault(), this._limits().dayDisabled(t.y, t.m, t.d) || (this.value = y(t.y, t.m, t.d), this.dispatchEvent(new Event("change", { bubbles: !0 })), this._close());
|
|
526
558
|
return;
|
|
527
559
|
case "Escape": return this._close();
|
|
528
560
|
default:
|
|
@@ -590,31 +622,35 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
590
622
|
}
|
|
591
623
|
if (e.target.closest("[data-today]")) {
|
|
592
624
|
let e = /* @__PURE__ */ new Date();
|
|
593
|
-
this.value = y(e.getFullYear(), e.getMonth(), e.getDate()), this._close();
|
|
625
|
+
this.value = y(e.getFullYear(), e.getMonth(), e.getDate()), this.dispatchEvent(new Event("change", { bubbles: !0 })), this._close();
|
|
594
626
|
return;
|
|
595
627
|
}
|
|
596
628
|
if (e.target.closest("[data-clear]")) {
|
|
597
|
-
this.value = "", this._close();
|
|
629
|
+
this.value = "", this.dispatchEvent(new Event("change", { bubbles: !0 })), this._close();
|
|
598
630
|
return;
|
|
599
631
|
}
|
|
600
632
|
let s = e.target.closest(".datepicker-day[data-iso]");
|
|
601
|
-
s && !s.disabled && (this.value = s.dataset.iso, this._close());
|
|
633
|
+
s && !s.disabled && (this.value = s.dataset.iso, this.dispatchEvent(new Event("change", { bubbles: !0 })), this._close());
|
|
602
634
|
}), this._onKeyBound = (e) => {
|
|
603
635
|
r() && this._onKey(e);
|
|
604
|
-
}, t.addEventListener("keydown", this._onKeyBound), this.
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
636
|
+
}, t.addEventListener("keydown", this._onKeyBound), this._bindGlobal = () => {
|
|
637
|
+
this._teardown(), this._onDocClick = (e) => {
|
|
638
|
+
let t = this._popClick;
|
|
639
|
+
this._popClick = !1, r() && !t && !this.contains(e.target) && this._close();
|
|
640
|
+
}, document.addEventListener("click", this._onDocClick), this._onDocKey = (e) => {
|
|
641
|
+
r() && e.key === "Escape" && this._close();
|
|
642
|
+
}, document.addEventListener("keydown", this._onDocKey), a(this, () => {
|
|
643
|
+
r() && this._position(e, t);
|
|
644
|
+
});
|
|
645
|
+
}, this._bindGlobal(), this._syncFormValue();
|
|
610
646
|
}
|
|
611
647
|
_teardown() {
|
|
612
|
-
this._onDocClick
|
|
648
|
+
this._onDocClick &&= (document.removeEventListener("click", this._onDocClick), null), this._onDocKey &&= (document.removeEventListener("keydown", this._onDocKey), null), o(this);
|
|
613
649
|
}
|
|
614
650
|
disconnectedCallback() {
|
|
615
651
|
this._teardown();
|
|
616
652
|
}
|
|
617
|
-
},
|
|
653
|
+
}, ee = [
|
|
618
654
|
"January",
|
|
619
655
|
"February",
|
|
620
656
|
"March",
|
|
@@ -627,7 +663,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
627
663
|
"October",
|
|
628
664
|
"November",
|
|
629
665
|
"December"
|
|
630
|
-
],
|
|
666
|
+
], te = [
|
|
631
667
|
"Su",
|
|
632
668
|
"Mo",
|
|
633
669
|
"Tu",
|
|
@@ -635,24 +671,24 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
635
671
|
"Th",
|
|
636
672
|
"Fr",
|
|
637
673
|
"Sa"
|
|
638
|
-
],
|
|
674
|
+
], T = (e) => String(e).padStart(2, "0"), ne = (e, t, n) => `${e}-${T(t + 1)}-${T(n)}`, E = (e) => {
|
|
639
675
|
let t = /^(\d{4})-(\d{2})-(\d{2})$/.exec(e || "");
|
|
640
676
|
return t ? {
|
|
641
677
|
y: +t[1],
|
|
642
678
|
m: t[2] - 1,
|
|
643
679
|
d: +t[3]
|
|
644
680
|
} : null;
|
|
645
|
-
},
|
|
646
|
-
let t =
|
|
647
|
-
return t ? `${
|
|
648
|
-
},
|
|
681
|
+
}, D = (e) => {
|
|
682
|
+
let t = E(e);
|
|
683
|
+
return t ? `${T(t.d)} ${ee[t.m].slice(0, 3)} ${t.y}` : "";
|
|
684
|
+
}, O = (e, t) => new Date(e, t + 1, 0).getDate(), k = (e, t) => {
|
|
649
685
|
for (; t < 0;) t += 12, --e;
|
|
650
686
|
for (; t > 11;) t -= 12, e += 1;
|
|
651
687
|
return {
|
|
652
688
|
y: e,
|
|
653
689
|
m: t
|
|
654
690
|
};
|
|
655
|
-
},
|
|
691
|
+
}, re = class extends HTMLElement {
|
|
656
692
|
static formAssociated = !0;
|
|
657
693
|
static get observedAttributes() {
|
|
658
694
|
return [
|
|
@@ -683,7 +719,11 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
683
719
|
this._viewY = e.getFullYear(), this._viewM = e.getMonth();
|
|
684
720
|
}
|
|
685
721
|
connectedCallback() {
|
|
686
|
-
this._rendered
|
|
722
|
+
if (!this._rendered) {
|
|
723
|
+
this.render();
|
|
724
|
+
return;
|
|
725
|
+
}
|
|
726
|
+
this._bindGlobal?.();
|
|
687
727
|
}
|
|
688
728
|
attributeChangedCallback(e, t, n) {
|
|
689
729
|
this._rendered && (e === "start" || e === "end" ? (this._start = this.getAttribute("start") || "", this._end = this.getAttribute("end") || "", this._syncTrigger(), this._syncMirrors()) : this.render());
|
|
@@ -695,7 +735,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
695
735
|
};
|
|
696
736
|
}
|
|
697
737
|
set value(e) {
|
|
698
|
-
this._start = e?.start || "", this._end = e?.end || "", this._syncTrigger(), this._syncMirrors()
|
|
738
|
+
this._start = e?.start || "", this._end = e?.end || "", this._syncTrigger(), this._syncMirrors();
|
|
699
739
|
}
|
|
700
740
|
_firstDay() {
|
|
701
741
|
let e = Number.parseInt(this.getAttribute("first-day") ?? "", 10);
|
|
@@ -707,13 +747,13 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
707
747
|
text: e,
|
|
708
748
|
empty: !0
|
|
709
749
|
} : {
|
|
710
|
-
text: `${
|
|
750
|
+
text: `${D(this._start) || "Start"} – ${D(this._end) || "End"}`,
|
|
711
751
|
empty: !1
|
|
712
752
|
};
|
|
713
753
|
}
|
|
714
754
|
render() {
|
|
715
|
-
this._defaultStart === void 0 && (this._defaultStart = this.getAttribute("start") || "", this._defaultEnd = this.getAttribute("end") || ""
|
|
716
|
-
let e =
|
|
755
|
+
this._defaultStart === void 0 && (this._defaultStart = this.getAttribute("start") || "", this._defaultEnd = this.getAttribute("end") || "", this._start = this._defaultStart || this._start, this._end = this._defaultEnd || this._end);
|
|
756
|
+
let e = E(this._start);
|
|
717
757
|
e && (this._viewY = e.y, this._viewM = e.m);
|
|
718
758
|
let t = this.getAttribute("size"), n = t === "sm" ? " input-sm" : t === "lg" ? " input-lg" : "", { text: r, empty: i } = this._label(), a = this.getAttribute("aria-label"), o = this.getAttribute("aria-describedby");
|
|
719
759
|
this.innerHTML = `
|
|
@@ -747,24 +787,24 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
747
787
|
r || (r = document.createElement("input"), r.type = "hidden", r.setAttribute("data-range-mirror", e), this.appendChild(r)), r.name = t, r.value = n || "", r.disabled = this.hasAttribute("disabled");
|
|
748
788
|
}
|
|
749
789
|
_limits() {
|
|
750
|
-
let e =
|
|
790
|
+
let e = E(this.getAttribute("min")), t = E(this.getAttribute("max")), n = e ? new Date(e.y, e.m, e.d).getTime() : -Infinity, r = t ? new Date(t.y, t.m, t.d).getTime() : Infinity;
|
|
751
791
|
return (e, t, i) => {
|
|
752
792
|
let a = new Date(e, t, i).getTime();
|
|
753
793
|
return a < n || a > r;
|
|
754
794
|
};
|
|
755
795
|
}
|
|
756
796
|
_monthHtml(e, t) {
|
|
757
|
-
let n = this._firstDay(), r = (new Date(e, t, 1).getDay() - n + 7) % 7, i =
|
|
758
|
-
let i =
|
|
797
|
+
let n = this._firstDay(), r = (new Date(e, t, 1).getDay() - n + 7) % 7, i = O(e, t), a = this._limits(), o = te.map((e, t) => te[(t + n) % 7]).map((e) => `<span>${e}</span>`).join(""), s = (e, t, n, r) => {
|
|
798
|
+
let i = ne(e, t, n), o = a(e, t, n);
|
|
759
799
|
return `<button type="button" class="${["datepicker-day", r ? "is-outside" : ""].filter(Boolean).join(" ")}" data-iso="${i}"${o ? " disabled" : ""}>${n}</button>`;
|
|
760
|
-
}, c = "", l =
|
|
800
|
+
}, c = "", l = k(e, t - 1), u = O(l.y, l.m);
|
|
761
801
|
for (let e = r - 1; e >= 0; e--) c += s(l.y, l.m, u - e, !0);
|
|
762
802
|
for (let n = 1; n <= i; n++) c += s(e, t, n, !1);
|
|
763
|
-
let d =
|
|
803
|
+
let d = k(e, t + 1), f = (7 - (r + i) % 7) % 7;
|
|
764
804
|
for (let e = 1; e <= f; e++) c += s(d.y, d.m, e, !0);
|
|
765
805
|
return `
|
|
766
806
|
<div class="daterange-cal">
|
|
767
|
-
<div class="datepicker-month-label">${
|
|
807
|
+
<div class="datepicker-month-label">${ee[t]} ${e}</div>
|
|
768
808
|
<div class="datepicker-weekdays">${o}</div>
|
|
769
809
|
<div class="datepicker-grid" role="grid">${c}</div>
|
|
770
810
|
</div>`;
|
|
@@ -772,7 +812,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
772
812
|
_renderView() {
|
|
773
813
|
let e = this.querySelector(".daterange-pop");
|
|
774
814
|
if (!e) return;
|
|
775
|
-
let t =
|
|
815
|
+
let t = k(this._viewY, this._viewM + 1);
|
|
776
816
|
e.innerHTML = `
|
|
777
817
|
<div class="daterange-head">
|
|
778
818
|
<button type="button" class="datepicker-nav-btn" data-nav="-1" aria-label="Previous month"><i class="bi bi-chevron-left" aria-hidden="true"></i></button>
|
|
@@ -798,7 +838,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
798
838
|
n.classList.toggle("is-range-start", i), n.classList.toggle("is-range-end", a), n.classList.toggle("in-range", o);
|
|
799
839
|
}
|
|
800
840
|
let i = e.querySelector("[data-range-hint]");
|
|
801
|
-
i && (i.textContent = this._start ? this._end ? `${
|
|
841
|
+
i && (i.textContent = this._start ? this._end ? `${D(this._start)} – ${D(this._end)}` : "Pick an end date" : "Pick a start date");
|
|
802
842
|
}
|
|
803
843
|
_position(e, t) {
|
|
804
844
|
i(e, t);
|
|
@@ -809,7 +849,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
809
849
|
return;
|
|
810
850
|
}
|
|
811
851
|
if (new Date(e).getTime() < new Date(this._start).getTime()) {
|
|
812
|
-
this._start = e, this._syncTrigger(), this._syncMirrors(), this._paint();
|
|
852
|
+
this._start = e, this._syncTrigger(), this._syncMirrors(), this._paint(), this.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
813
853
|
return;
|
|
814
854
|
}
|
|
815
855
|
this._end = e, this._syncTrigger(), this._syncMirrors(), this._paint(), this.dispatchEvent(new Event("change", { bubbles: !0 })), this._close();
|
|
@@ -820,7 +860,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
820
860
|
if (!e || !t) return;
|
|
821
861
|
let r = () => !t.hidden;
|
|
822
862
|
this._open = () => {
|
|
823
|
-
let r =
|
|
863
|
+
let r = E(this._start);
|
|
824
864
|
if (r) this._viewY = r.y, this._viewM = r.m;
|
|
825
865
|
else {
|
|
826
866
|
let e = /* @__PURE__ */ new Date();
|
|
@@ -833,7 +873,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
833
873
|
this._popClick = !0;
|
|
834
874
|
let t = e.target.closest("[data-nav]");
|
|
835
875
|
if (t) {
|
|
836
|
-
let e =
|
|
876
|
+
let e = k(this._viewY, this._viewM + Number(t.dataset.nav));
|
|
837
877
|
this._viewY = e.y, this._viewM = e.m, this._renderView();
|
|
838
878
|
return;
|
|
839
879
|
}
|
|
@@ -846,22 +886,24 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
846
886
|
}), t.addEventListener("mouseover", (e) => {
|
|
847
887
|
let t = e.target.closest(".datepicker-day[data-iso]");
|
|
848
888
|
t && this._start && !this._end && (this._hover = t.dataset.iso, this._paint());
|
|
849
|
-
}), this.
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
889
|
+
}), this._bindGlobal = () => {
|
|
890
|
+
this._teardown(), this._onDocClick = (e) => {
|
|
891
|
+
let t = this._popClick;
|
|
892
|
+
this._popClick = !1, r() && !t && !this.contains(e.target) && this._close();
|
|
893
|
+
}, document.addEventListener("click", this._onDocClick), this._onDocKey = (e) => {
|
|
894
|
+
r() && e.key === "Escape" && this._close();
|
|
895
|
+
}, document.addEventListener("keydown", this._onDocKey), a(this, () => {
|
|
896
|
+
r() && this._position(e, t);
|
|
897
|
+
});
|
|
898
|
+
}, this._bindGlobal(), this._syncMirrors();
|
|
857
899
|
}
|
|
858
900
|
_teardown() {
|
|
859
|
-
this._onDocClick
|
|
901
|
+
this._onDocClick &&= (document.removeEventListener("click", this._onDocClick), null), this._onDocKey &&= (document.removeEventListener("keydown", this._onDocKey), null), o(this);
|
|
860
902
|
}
|
|
861
903
|
disconnectedCallback() {
|
|
862
904
|
this._teardown();
|
|
863
905
|
}
|
|
864
|
-
},
|
|
906
|
+
}, ie = class extends HTMLElement {
|
|
865
907
|
static formAssociated = !0;
|
|
866
908
|
_accessibleName() {
|
|
867
909
|
return this.getAttribute("aria-label") || this.getAttribute("placeholder") || "Select";
|
|
@@ -889,11 +931,17 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
889
931
|
connectedCallback() {
|
|
890
932
|
if (!this._rendered) {
|
|
891
933
|
if (!this._valuesInit && !this._optionsProp && !this._values.length) {
|
|
892
|
-
let e =
|
|
893
|
-
e
|
|
934
|
+
let e = this.getAttribute("value");
|
|
935
|
+
if (e != null && e !== "") this._values = e.split(",").map((e) => e.trim()).filter(Boolean);
|
|
936
|
+
else {
|
|
937
|
+
let e = [...this.querySelectorAll(":scope > wui-option[selected]")].map((e) => e.getAttribute("value") ?? e.textContent.trim());
|
|
938
|
+
e.length && (this._values = e.map(String));
|
|
939
|
+
}
|
|
894
940
|
}
|
|
895
941
|
this._valuesInit = !0, this._defaultCaptured ||= (this._defaultValues = this._values.slice(), !0), this.render();
|
|
942
|
+
return;
|
|
896
943
|
}
|
|
944
|
+
this._bindGlobal?.();
|
|
897
945
|
}
|
|
898
946
|
formResetCallback() {
|
|
899
947
|
this.values = (this._defaultValues || []).slice();
|
|
@@ -905,7 +953,11 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
905
953
|
return this._values.slice();
|
|
906
954
|
}
|
|
907
955
|
set values(e) {
|
|
908
|
-
this._values = Array.isArray(e) ? e.map(String) : [], c(this, this._values.join(",")), this._rendered
|
|
956
|
+
if (this._values = Array.isArray(e) ? e.map(String) : [], c(this, this._values.join(",")), this._rendered) {
|
|
957
|
+
this._renderControl();
|
|
958
|
+
let e = this.querySelector(".search-select-input");
|
|
959
|
+
this._renderOptions(e ? e.value : "");
|
|
960
|
+
}
|
|
909
961
|
}
|
|
910
962
|
set options(e) {
|
|
911
963
|
this._optionsProp = Array.isArray(e) ? e : null, this.isConnected && this.render();
|
|
@@ -938,15 +990,17 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
938
990
|
render() {
|
|
939
991
|
this._snapshotDeclared();
|
|
940
992
|
let e = this.hasAttribute("searchable"), t = this.getAttribute("search-placeholder") || "Search…", n = this.getAttribute("icon"), r = this.getAttribute("size"), i = r === "sm" ? " search-select-sm" : r === "lg" ? " search-select-lg" : "";
|
|
941
|
-
c(this, this._values.join(",")), this.
|
|
993
|
+
c(this, this._values.join(",")), this.id ||= `wui-multiselect-${Math.random().toString(36).slice(2, 9)}`;
|
|
994
|
+
let a = `${this.id}-listbox`;
|
|
995
|
+
this._listboxId = a, this.innerHTML = `
|
|
942
996
|
<div class="search-select${i}">
|
|
943
|
-
<div class="input search-select-control search-select-multi" role="combobox" aria-haspopup="listbox" aria-expanded="false" aria-label="${
|
|
944
|
-
${n ? `<i class="bi bi-${
|
|
997
|
+
<div class="input search-select-control search-select-multi" role="combobox" aria-haspopup="listbox" aria-expanded="false" aria-controls="${A(a)}" aria-label="${A(this._accessibleName())}"${this.hasAttribute("disabled") ? " aria-disabled=\"true\"" : " tabindex=\"0\""}>
|
|
998
|
+
${n ? `<i class="bi bi-${A(n)} search-select-icon" aria-hidden="true"></i>` : ""}
|
|
945
999
|
<div class="ms-chips" data-chips></div>
|
|
946
1000
|
<i class="bi bi-chevron-down search-select-caret" aria-hidden="true"></i>
|
|
947
1001
|
</div>
|
|
948
|
-
<div class="search-select-menu search-select-menu-fixed" role="listbox" aria-multiselectable="true" tabindex="-1" hidden>
|
|
949
|
-
${e ? `<div class="search-select-search"><i class="bi bi-search" aria-hidden="true"></i><input class="search-select-input" placeholder="${
|
|
1002
|
+
<div class="search-select-menu search-select-menu-fixed" role="listbox" id="${A(a)}" aria-multiselectable="true" tabindex="-1" hidden>
|
|
1003
|
+
${e ? `<div class="search-select-search"><i class="bi bi-search" aria-hidden="true"></i><input class="search-select-input" placeholder="${A(t)}" aria-autocomplete="list" /><button type="button" class="search-select-clear" aria-label="Clear search" hidden><i class="bi bi-x" aria-hidden="true"></i></button></div>` : ""}
|
|
950
1004
|
<div class="search-select-options"></div>
|
|
951
1005
|
<div class="search-select-empty" hidden>No matches</div>
|
|
952
1006
|
</div>
|
|
@@ -960,7 +1014,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
960
1014
|
e.innerHTML = `<span class="search-select-placeholder">${u(t)}</span>`;
|
|
961
1015
|
return;
|
|
962
1016
|
}
|
|
963
|
-
e.innerHTML = this._values.map((e) => `<span class="chip chip-sm"><span class="chip-label">${this._labelHtmlFor(e)}</span><button type="button" class="chip-remove" data-remove="${
|
|
1017
|
+
e.innerHTML = this._values.map((e) => `<span class="chip chip-sm"><span class="chip-label">${this._labelHtmlFor(e)}</span><button type="button" class="chip-remove" data-remove="${A(e)}" aria-label="Remove ${A(ae(this._labelFor(e)))}"><i class="bi bi-x" aria-hidden="true"></i></button></span>`).join(""), this._collapseChips();
|
|
964
1018
|
}
|
|
965
1019
|
_collapseChips() {
|
|
966
1020
|
let e = this.querySelector("[data-chips]");
|
|
@@ -984,22 +1038,22 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
984
1038
|
let t = this.querySelector(".search-select-options"), n = this.querySelector(".search-select-empty");
|
|
985
1039
|
if (!t) return;
|
|
986
1040
|
let r = (e || "").trim().toLowerCase(), i = this._readOptions();
|
|
987
|
-
r && (i = i.filter((e) =>
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
1041
|
+
r && (i = i.filter((e) => ae(e.label).toLowerCase().includes(r)));
|
|
1042
|
+
let a = this._listboxId || `${this.id || "wui-multiselect"}-listbox`;
|
|
1043
|
+
t.innerHTML = i.map((e, t) => {
|
|
1044
|
+
let n = this._values.includes(String(e.value));
|
|
1045
|
+
return `<button type="button" role="option" id="${A(`${a}-opt-${t}`)}" class="search-select-option${n ? " selected" : ""}" data-value="${A(e.value)}" aria-selected="${n}"><span class="ms-opt-label">${f(e)}</span><span class="ms-check"><i class="bi bi-check" aria-hidden="true"></i></span></button>`;
|
|
1046
|
+
}).join(""), n && (n.hidden = i.length > 0), this._active = -1, this.querySelector(".search-select-control")?.removeAttribute("aria-activedescendant");
|
|
991
1047
|
}
|
|
992
1048
|
_wire() {
|
|
993
1049
|
this._teardown();
|
|
994
1050
|
let e = this.querySelector(".search-select-control"), t = this.querySelector(".search-select-menu"), n = this.querySelector(".search-select-input"), r = this.querySelector(".search-select-clear"), o = this.querySelector(".search-select-options");
|
|
995
1051
|
if (!e || !t) return;
|
|
996
|
-
let s = () => this.hasAttribute("disabled")
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
let t = d();
|
|
1000
|
-
this._active = e;
|
|
1052
|
+
let s = () => this.hasAttribute("disabled"), l = () => i(e, t, { matchWidth: !0 }), u = () => [...this.querySelectorAll(".search-select-option")], d = () => u().filter((e) => !e.hidden), f = (t) => {
|
|
1053
|
+
let n = d();
|
|
1054
|
+
this._active = t;
|
|
1001
1055
|
for (let e of u()) e.classList.remove("is-active");
|
|
1002
|
-
|
|
1056
|
+
t >= 0 && n[t] ? (n[t].classList.add("is-active"), n[t].scrollIntoView({ block: "nearest" }), e.setAttribute("aria-activedescendant", n[t].id)) : e.removeAttribute("aria-activedescendant");
|
|
1003
1057
|
}, p = () => !t.hidden, m = () => {
|
|
1004
1058
|
s() || (t.hidden = !1, e.setAttribute("aria-expanded", "true"), e.classList.add("open"), l(), n && (n.value = "", this._renderOptions(""), n.focus()));
|
|
1005
1059
|
}, h = () => {
|
|
@@ -1031,7 +1085,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
1031
1085
|
});
|
|
1032
1086
|
let y = (t) => {
|
|
1033
1087
|
let r = d();
|
|
1034
|
-
t.key === "ArrowDown" ? (t.preventDefault(), f(Math.min(this._active + 1, r.length - 1))) : t.key === "ArrowUp" ? (t.preventDefault(), f(Math.max(this._active - 1, 0))) : t.key === "Enter" ? (t.preventDefault(), r[this._active] && _(r[this._active].dataset.value)) : t.key === "Escape" ? (h(), e.focus()) : t.key === "Backspace" && !n
|
|
1088
|
+
t.key === "ArrowDown" ? (t.preventDefault(), f(Math.min(this._active + 1, r.length - 1))) : t.key === "ArrowUp" ? (t.preventDefault(), f(Math.max(this._active - 1, 0))) : t.key === "Enter" ? (t.preventDefault(), r[this._active] && _(r[this._active].dataset.value)) : t.key === "Escape" ? (h(), e.focus()) : t.key === "Backspace" && !n?.value && this._values.length && v(this._values[this._values.length - 1]);
|
|
1035
1089
|
};
|
|
1036
1090
|
n?.addEventListener("keydown", y), r?.addEventListener("click", () => {
|
|
1037
1091
|
n.value = "", this._renderOptions(""), r.hidden = !0, n.focus();
|
|
@@ -1041,19 +1095,22 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
1041
1095
|
return;
|
|
1042
1096
|
}
|
|
1043
1097
|
(e.key === "ArrowDown" || e.key === "Enter" || e.key === " ") && (e.preventDefault(), m());
|
|
1044
|
-
}), this.
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1098
|
+
}), this._bindGlobal = () => {
|
|
1099
|
+
this._teardown(), !this._ro && typeof ResizeObserver < "u" && (this._ro = new ResizeObserver(() => this._collapseChips()), this._ro.observe(this)), this._onDocClick = (e) => {
|
|
1100
|
+
p() && !this.contains(e.target) && h();
|
|
1101
|
+
}, document.addEventListener("click", this._onDocClick), a(this, () => {
|
|
1102
|
+
p() && l();
|
|
1103
|
+
});
|
|
1104
|
+
}, this._bindGlobal();
|
|
1049
1105
|
}
|
|
1050
1106
|
_teardown() {
|
|
1051
|
-
this._onDocClick
|
|
1107
|
+
this._onDocClick &&= (document.removeEventListener("click", this._onDocClick), null), o(this);
|
|
1052
1108
|
}
|
|
1053
1109
|
disconnectedCallback() {
|
|
1054
1110
|
this._teardown(), this._ro?.disconnect(), this._ro = null;
|
|
1055
1111
|
}
|
|
1056
|
-
},
|
|
1112
|
+
}, A = (e) => String(e ?? "").replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<"), ae = (e) => String(e ?? "").replace(/<[^>]*>/g, ""), oe = /[^0-9]/g, se = /[^0-9a-zA-Z]/g, j = class extends HTMLElement {
|
|
1113
|
+
static formAssociated = !0;
|
|
1057
1114
|
static get observedAttributes() {
|
|
1058
1115
|
return [
|
|
1059
1116
|
"value",
|
|
@@ -1083,10 +1140,21 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
1083
1140
|
this._value = this._clean(e), c(this, this._value), this._paint();
|
|
1084
1141
|
}
|
|
1085
1142
|
_clean(e) {
|
|
1086
|
-
return (e == null ? "" : String(e)).replace(this.mode === "alphanumeric" ?
|
|
1143
|
+
return (e == null ? "" : String(e)).replace(this.mode === "alphanumeric" ? se : oe, "").slice(0, this.length);
|
|
1144
|
+
}
|
|
1145
|
+
constructor() {
|
|
1146
|
+
super();
|
|
1147
|
+
try {
|
|
1148
|
+
this._internals = this.attachInternals();
|
|
1149
|
+
} catch {
|
|
1150
|
+
this._internals = null;
|
|
1151
|
+
}
|
|
1087
1152
|
}
|
|
1088
1153
|
connectedCallback() {
|
|
1089
|
-
this._rendered
|
|
1154
|
+
this._rendered ? this._onSelectionChange && document.addEventListener("selectionchange", this._onSelectionChange) : (this._defaultCaptured ||= (this._defaultValue = this._value, !0), this.render());
|
|
1155
|
+
}
|
|
1156
|
+
formResetCallback() {
|
|
1157
|
+
this._value = this._defaultValue || "", c(this, this._value), this._paint();
|
|
1090
1158
|
}
|
|
1091
1159
|
attributeChangedCallback(e, t, n) {
|
|
1092
1160
|
this._rendered && (e === "value" ? (this._value = this._clean(n), c(this, this._value), this._paint()) : this.render());
|
|
@@ -1145,11 +1213,14 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
1145
1213
|
"blur",
|
|
1146
1214
|
"select"
|
|
1147
1215
|
]) e.addEventListener(t, () => this._paint());
|
|
1148
|
-
document.
|
|
1216
|
+
this._onSelectionChange && document.removeEventListener("selectionchange", this._onSelectionChange), this._onSelectionChange = () => {
|
|
1149
1217
|
document.activeElement === e && this._paint();
|
|
1150
|
-
});
|
|
1218
|
+
}, document.addEventListener("selectionchange", this._onSelectionChange);
|
|
1219
|
+
}
|
|
1220
|
+
disconnectedCallback() {
|
|
1221
|
+
this._onSelectionChange && document.removeEventListener("selectionchange", this._onSelectionChange);
|
|
1151
1222
|
}
|
|
1152
|
-
},
|
|
1223
|
+
}, M = [
|
|
1153
1224
|
[
|
|
1154
1225
|
"AF",
|
|
1155
1226
|
"Afghanistan",
|
|
@@ -2375,56 +2446,56 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
2375
2446
|
"Zimbabwe",
|
|
2376
2447
|
"263"
|
|
2377
2448
|
]
|
|
2378
|
-
],
|
|
2449
|
+
], N = (e) => (M.find((t) => t[0] === e) || [
|
|
2379
2450
|
"",
|
|
2380
2451
|
"",
|
|
2381
2452
|
""
|
|
2382
|
-
])[2],
|
|
2383
|
-
function
|
|
2384
|
-
return
|
|
2453
|
+
])[2], P = (e) => `wui-flag wui-flag-${String(e).toLowerCase()}`, F = null, I = null;
|
|
2454
|
+
function ce() {
|
|
2455
|
+
return F ? Promise.resolve(F) : (I ||= Promise.all([import("./libphonenumber-js-BcNT8oq0.js"), import("./examples.mobile.json-BMXTGiGC.js")]).then(([e, t]) => (F = {
|
|
2385
2456
|
AsYouType: e.AsYouType,
|
|
2386
2457
|
getExampleNumber: e.getExampleNumber,
|
|
2387
2458
|
isValidPhoneNumber: e.isValidPhoneNumber,
|
|
2388
2459
|
examples: t.default || t
|
|
2389
|
-
},
|
|
2460
|
+
}, F)).catch(() => null), I);
|
|
2390
2461
|
}
|
|
2391
|
-
function
|
|
2392
|
-
if (!
|
|
2462
|
+
function L(e, t) {
|
|
2463
|
+
if (!F || !t) return t;
|
|
2393
2464
|
try {
|
|
2394
|
-
return new
|
|
2465
|
+
return new F.AsYouType(e).input(t);
|
|
2395
2466
|
} catch {
|
|
2396
2467
|
return t;
|
|
2397
2468
|
}
|
|
2398
2469
|
}
|
|
2399
|
-
function
|
|
2400
|
-
if (!
|
|
2470
|
+
function R(e) {
|
|
2471
|
+
if (!F) return null;
|
|
2401
2472
|
try {
|
|
2402
|
-
return
|
|
2473
|
+
return F.getExampleNumber(e, F.examples)?.formatNational() || null;
|
|
2403
2474
|
} catch {
|
|
2404
2475
|
return null;
|
|
2405
2476
|
}
|
|
2406
2477
|
}
|
|
2407
|
-
function
|
|
2408
|
-
if (!
|
|
2478
|
+
function z(e) {
|
|
2479
|
+
if (!F || !e) return null;
|
|
2409
2480
|
try {
|
|
2410
|
-
return
|
|
2481
|
+
return F.isValidPhoneNumber(e);
|
|
2411
2482
|
} catch {
|
|
2412
2483
|
return null;
|
|
2413
2484
|
}
|
|
2414
2485
|
}
|
|
2415
|
-
function
|
|
2416
|
-
if (!
|
|
2486
|
+
function le(e) {
|
|
2487
|
+
if (!F) return null;
|
|
2417
2488
|
try {
|
|
2418
|
-
let t =
|
|
2489
|
+
let t = F.getExampleNumber(e, F.examples);
|
|
2419
2490
|
return t?.nationalNumber ? t.nationalNumber.length : null;
|
|
2420
2491
|
} catch {
|
|
2421
2492
|
return null;
|
|
2422
2493
|
}
|
|
2423
2494
|
}
|
|
2424
|
-
function
|
|
2425
|
-
if (!
|
|
2495
|
+
function B(e) {
|
|
2496
|
+
if (!F || !e?.trim().startsWith("+")) return null;
|
|
2426
2497
|
try {
|
|
2427
|
-
let t = new
|
|
2498
|
+
let t = new F.AsYouType();
|
|
2428
2499
|
t.input(e.trim());
|
|
2429
2500
|
let n = t.getCountry();
|
|
2430
2501
|
return n ? {
|
|
@@ -2435,7 +2506,7 @@ function W(e) {
|
|
|
2435
2506
|
return null;
|
|
2436
2507
|
}
|
|
2437
2508
|
}
|
|
2438
|
-
var
|
|
2509
|
+
var V = class extends HTMLElement {
|
|
2439
2510
|
static formAssociated = !0;
|
|
2440
2511
|
static get observedAttributes() {
|
|
2441
2512
|
return [
|
|
@@ -2471,100 +2542,100 @@ var G = class extends HTMLElement {
|
|
|
2471
2542
|
this.value = this._defaultValue || "";
|
|
2472
2543
|
}
|
|
2473
2544
|
get value() {
|
|
2474
|
-
return `+${
|
|
2545
|
+
return this._national ? `+${N(this._country)}${this._national}` : "";
|
|
2475
2546
|
}
|
|
2476
2547
|
set value(e) {
|
|
2477
|
-
let t = String(e ?? "").trim(), n =
|
|
2548
|
+
let t = String(e ?? "").trim(), n = B(t);
|
|
2478
2549
|
if (n) this._country = n.country, this._national = n.national.replace(/[^0-9]/g, "");
|
|
2479
2550
|
else if (t.startsWith("+")) {
|
|
2480
|
-
let e = t.replace(/[^0-9]/g, ""), n = String(
|
|
2551
|
+
let e = t.replace(/[^0-9]/g, ""), n = String(N(this._country));
|
|
2481
2552
|
n && e.startsWith(n) && (e = e.slice(n.length)), this._national = e;
|
|
2482
2553
|
} else this._national = t.replace(/[^0-9]/g, "");
|
|
2483
|
-
n && this.getAttribute("country") !== this._country ? this.setAttribute("country", this._country) : this._rendered && this.render(), this.
|
|
2554
|
+
n && this.getAttribute("country") !== this._country ? this.setAttribute("country", this._country) : this._rendered && this.render(), this._syncMirror();
|
|
2484
2555
|
}
|
|
2485
|
-
|
|
2486
|
-
c(this, this.value)
|
|
2556
|
+
_syncMirror() {
|
|
2557
|
+
c(this, this.value);
|
|
2487
2558
|
}
|
|
2488
2559
|
render() {
|
|
2489
2560
|
this._defaultValue === void 0 && (this._defaultValue = this.getAttribute("value") || "");
|
|
2490
|
-
let e = this.getAttribute("placeholder") ||
|
|
2561
|
+
let e = this.getAttribute("placeholder") || R(this._country) || "Enter phone number";
|
|
2491
2562
|
this._country = this.getAttribute("country") || this._country;
|
|
2492
|
-
let t =
|
|
2563
|
+
let t = M.map(([e, t, n]) => `<button type="button" role="option" class="country-dropdown-item${e === this._country ? " selected" : ""}" data-iso="${e}"><span class="${P(e)}" aria-hidden="true"></span><span class="country-name-text">${t}<span class="country-code-text">+${n}</span></span></button>`).join("");
|
|
2493
2564
|
this.innerHTML = `
|
|
2494
2565
|
<div class="phone-input-wrap">
|
|
2495
2566
|
<div class="phone-country-adornment">
|
|
2496
2567
|
<button type="button" class="country-toggle" aria-haspopup="listbox" aria-expanded="false"${this.hasAttribute("disabled") ? " disabled" : ""}>
|
|
2497
|
-
<span class="${
|
|
2568
|
+
<span class="${P(this._country)}" data-flag aria-hidden="true"></span>
|
|
2498
2569
|
<i class="bi bi-chevron-down phone-chevron" aria-hidden="true"></i>
|
|
2499
|
-
<span class="phone-dial" data-dial>+${
|
|
2570
|
+
<span class="phone-dial" data-dial>+${N(this._country)}</span>
|
|
2500
2571
|
</button>
|
|
2501
2572
|
<div class="country-dropdown-menu" role="listbox" hidden>
|
|
2502
2573
|
<div class="dropdown-search-wrapper"><span class="dropdown-search-icon"><i class="bi bi-search" aria-hidden="true"></i></span><input type="text" class="dropdown-search-input" placeholder="Search country or code" aria-label="Search countries" /></div>
|
|
2503
2574
|
<div class="country-list-scroll">${t}<div class="country-empty" hidden>No countries found</div></div>
|
|
2504
2575
|
</div>
|
|
2505
2576
|
</div>
|
|
2506
|
-
<input type="tel" class="input" placeholder="${
|
|
2577
|
+
<input type="tel" class="input" placeholder="${H(e)}" value="${H(L(this._country, this._national))}"${this.getAttribute("aria-label") ? ` aria-label="${H(this.getAttribute("aria-label"))}"` : ""}${this.getAttribute("aria-describedby") ? ` aria-describedby="${H(this.getAttribute("aria-describedby"))}"` : ""}${this.hasAttribute("required") ? " required aria-required=\"true\"" : ""}${this.hasAttribute("disabled") ? " disabled" : ""} />
|
|
2507
2578
|
</div>
|
|
2508
2579
|
<div class="field-error" data-phone-error hidden></div>`, this._rendered = !0, c(this, this.value), this._wire();
|
|
2509
2580
|
}
|
|
2510
2581
|
_wire() {
|
|
2511
2582
|
this._teardown();
|
|
2512
|
-
let e = this.querySelector(".country-toggle"), t = this.querySelector(".phone-input-wrap"), n = this.querySelector(".country-dropdown-menu"), r = this.querySelector(".dropdown-search-input"), i = this.querySelector(".country-list-scroll"), a = this.querySelector(".country-empty"), o = this.querySelector("input[type=tel]"), s = this.querySelector("[data-flag]"),
|
|
2583
|
+
let e = this.querySelector(".country-toggle"), t = this.querySelector(".phone-input-wrap"), n = this.querySelector(".country-dropdown-menu"), r = this.querySelector(".dropdown-search-input"), i = this.querySelector(".country-list-scroll"), a = this.querySelector(".country-empty"), o = this.querySelector("input[type=tel]"), s = this.querySelector("[data-flag]"), c = this.querySelector("[data-dial]");
|
|
2513
2584
|
if (!e || !n) return;
|
|
2514
|
-
let
|
|
2585
|
+
let l = () => !n.hidden, u = () => {
|
|
2515
2586
|
let r = (t || e).getBoundingClientRect(), i = n.offsetWidth || 320, a = n.offsetHeight || 320, o = window.innerHeight - r.bottom, s = o < a + 6 && r.top > o ? r.top - a - 6 : r.bottom + 6, c = Math.min(Math.max(8, r.left), Math.max(8, window.innerWidth - i - 8));
|
|
2516
2587
|
n.style.top = `${Math.max(8, s)}px`, n.style.left = `${c}px`;
|
|
2588
|
+
}, d = () => {
|
|
2589
|
+
n.hidden = !1, e.setAttribute("aria-expanded", "true"), r.value = "", p(""), u(), r.focus();
|
|
2517
2590
|
}, f = () => {
|
|
2518
|
-
n.hidden = !1, e.setAttribute("aria-expanded", "true"), r.value = "", m(""), d(), r.focus();
|
|
2519
|
-
}, p = () => {
|
|
2520
2591
|
n.hidden = !0, e.setAttribute("aria-expanded", "false");
|
|
2521
2592
|
};
|
|
2522
2593
|
this._reposition = () => {
|
|
2523
|
-
|
|
2594
|
+
l() && u();
|
|
2524
2595
|
}, window.addEventListener("scroll", this._reposition, !0), window.addEventListener("resize", this._reposition);
|
|
2525
|
-
let
|
|
2596
|
+
let p = (e) => {
|
|
2526
2597
|
let t = e.trim().toLowerCase(), n = 0;
|
|
2527
2598
|
for (let e of i.querySelectorAll(".country-dropdown-item")) {
|
|
2528
2599
|
let r = !t || e.textContent.toLowerCase().includes(t);
|
|
2529
2600
|
e.hidden = !r, r && (n += 1);
|
|
2530
2601
|
}
|
|
2531
2602
|
a && (a.hidden = n > 0);
|
|
2532
|
-
},
|
|
2533
|
-
this._country = e, this.setAttribute("country", e), s && (s.className =
|
|
2603
|
+
}, m = (e) => {
|
|
2604
|
+
this._country = e, this.setAttribute("country", e), s && (s.className = P(e)), c && (c.textContent = `+${N(e)}`);
|
|
2534
2605
|
for (let t of i.querySelectorAll(".country-dropdown-item")) t.classList.toggle("selected", t.dataset.iso === e);
|
|
2535
|
-
|
|
2606
|
+
f(), this._syncMirror(), this.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
2536
2607
|
};
|
|
2537
|
-
e.addEventListener("click", () =>
|
|
2608
|
+
e.addEventListener("click", () => l() ? f() : d()), r.addEventListener("input", () => p(r.value)), i.addEventListener("click", (e) => {
|
|
2538
2609
|
let t = e.target.closest(".country-dropdown-item");
|
|
2539
|
-
t &&
|
|
2610
|
+
t && m(t.dataset.iso);
|
|
2540
2611
|
});
|
|
2541
|
-
let
|
|
2542
|
-
if (o.classList.toggle("is-invalid", e), e ? o.setAttribute("aria-invalid", "true") : o.removeAttribute("aria-invalid"),
|
|
2612
|
+
let h = this.querySelector("[data-phone-error]"), g = (e) => {
|
|
2613
|
+
if (o.classList.toggle("is-invalid", e), e ? o.setAttribute("aria-invalid", "true") : o.removeAttribute("aria-invalid"), h) {
|
|
2543
2614
|
if (e) {
|
|
2544
|
-
let e =
|
|
2545
|
-
|
|
2615
|
+
let e = R(this._country);
|
|
2616
|
+
h.textContent = e ? `Enter a valid phone number, e.g. ${e}` : "Enter a valid phone number";
|
|
2546
2617
|
}
|
|
2547
|
-
|
|
2618
|
+
h.hidden = !e;
|
|
2548
2619
|
}
|
|
2549
2620
|
};
|
|
2550
2621
|
o.addEventListener("input", () => {
|
|
2551
|
-
let e = o.value.replace(/[^0-9]/g, ""), t =
|
|
2622
|
+
let e = o.value.replace(/[^0-9]/g, ""), t = le(this._country);
|
|
2552
2623
|
t && e.length > t && (e = e.slice(0, t)), this._national = e;
|
|
2553
|
-
let n =
|
|
2554
|
-
o.value !== n && (o.value = n), this.
|
|
2624
|
+
let n = L(this._country, this._national);
|
|
2625
|
+
o.value !== n && (o.value = n), this._syncMirror(), this.dispatchEvent(new Event("change", { bubbles: !0 })), o.classList.contains("is-invalid") && (!this._national || z(this.value) === !0) && g(!1);
|
|
2555
2626
|
}), o.addEventListener("blur", () => {
|
|
2556
|
-
|
|
2627
|
+
g(this._national.length > 0 && z(this.value) === !1);
|
|
2557
2628
|
}), o.addEventListener("paste", (e) => {
|
|
2558
|
-
let t =
|
|
2559
|
-
t && (e.preventDefault(), this._national = t.national.replace(/[^0-9]/g, ""), t.country === this._country ? o.value =
|
|
2629
|
+
let t = B(e.clipboardData?.getData("text"));
|
|
2630
|
+
t && (e.preventDefault(), this._national = t.national.replace(/[^0-9]/g, ""), t.country === this._country ? o.value = L(this._country, this._national) : this.setAttribute("country", t.country), this._syncMirror(), this.dispatchEvent(new Event("change", { bubbles: !0 })), this.querySelector("input[type=tel]")?.focus());
|
|
2560
2631
|
}), this._onDocClick = (e) => {
|
|
2561
|
-
|
|
2562
|
-
}, document.addEventListener("click", this._onDocClick),
|
|
2563
|
-
if (!(!e || !o) && (this._national && (o.value =
|
|
2564
|
-
let e =
|
|
2632
|
+
l() && !this.contains(e.target) && f();
|
|
2633
|
+
}, document.addEventListener("click", this._onDocClick), ce().then((e) => {
|
|
2634
|
+
if (!(!e || !o) && (this._national && (o.value = L(this._country, this._national)), !this.getAttribute("placeholder"))) {
|
|
2635
|
+
let e = R(this._country);
|
|
2565
2636
|
e && (o.placeholder = e);
|
|
2566
2637
|
}
|
|
2567
|
-
}),
|
|
2638
|
+
}), this._syncMirror();
|
|
2568
2639
|
}
|
|
2569
2640
|
_teardown() {
|
|
2570
2641
|
this._reposition && (window.removeEventListener("scroll", this._reposition, !0), window.removeEventListener("resize", this._reposition)), this._onDocClick && document.removeEventListener("click", this._onDocClick);
|
|
@@ -2572,7 +2643,7 @@ var G = class extends HTMLElement {
|
|
|
2572
2643
|
disconnectedCallback() {
|
|
2573
2644
|
this._teardown();
|
|
2574
2645
|
}
|
|
2575
|
-
},
|
|
2646
|
+
}, H = (e) => String(e ?? "").replace(/"/g, """).replace(/</g, "<"), U = class extends HTMLElement {
|
|
2576
2647
|
static formAssociated = !0;
|
|
2577
2648
|
static get observedAttributes() {
|
|
2578
2649
|
return [
|
|
@@ -2602,7 +2673,11 @@ var G = class extends HTMLElement {
|
|
|
2602
2673
|
this._value = "", this._optionsProp = null, this._active = -1;
|
|
2603
2674
|
}
|
|
2604
2675
|
connectedCallback() {
|
|
2605
|
-
this._rendered
|
|
2676
|
+
if (!this._rendered) {
|
|
2677
|
+
this.render();
|
|
2678
|
+
return;
|
|
2679
|
+
}
|
|
2680
|
+
this._bindGlobal?.();
|
|
2606
2681
|
}
|
|
2607
2682
|
attributeChangedCallback(e, t, n) {
|
|
2608
2683
|
if (e === "value") {
|
|
@@ -2643,23 +2718,25 @@ var G = class extends HTMLElement {
|
|
|
2643
2718
|
render() {
|
|
2644
2719
|
this._defaultValue === void 0 && (this._defaultValue = this.getAttribute("value") || ""), this._snapshotDeclared();
|
|
2645
2720
|
let e = this._readOptions(), t = this.hasAttribute("searchable"), n = this.hasAttribute("clearable"), r = this.getAttribute("size"), i = r === "sm" ? " search-select-sm" : r === "lg" ? " search-select-lg" : "", a = this.getAttribute("icon"), o = this.getAttribute("prefix"), s = this.getAttribute("placeholder") || "Select...", l = this.getAttribute("search-placeholder") || "Search...", d = e.find((e) => String(e.value) === String(this._value)) || e.find((e) => e.selected);
|
|
2646
|
-
d && (this._value = String(d.value)), c(this, this._value)
|
|
2647
|
-
let p =
|
|
2648
|
-
|
|
2649
|
-
|
|
2721
|
+
d && (this._value = String(d.value)), c(this, this._value), this.id ||= `wui-select-${Math.random().toString(36).slice(2, 9)}`;
|
|
2722
|
+
let p = `${this.id}-listbox`;
|
|
2723
|
+
this._listboxId = p;
|
|
2724
|
+
let m = e.map((e, t) => {
|
|
2725
|
+
let n = String(e.value) === String(this._value);
|
|
2726
|
+
return `<button type="button" role="option" id="${W(`${p}-opt-${t}`)}" class="search-select-option${n ? " selected" : ""}" data-value="${W(e.value)}" aria-selected="${n}">${f(e)}</button>`;
|
|
2650
2727
|
}).join("");
|
|
2651
2728
|
this.innerHTML = `
|
|
2652
2729
|
<div class="search-select${this.hasAttribute("compact") ? " search-select-compact" : ""}${i}">
|
|
2653
|
-
<button type="button" role="combobox" class="input search-select-control" aria-haspopup="listbox" aria-expanded="false" aria-label="${
|
|
2654
|
-
${a ? `<i class="bi bi-${
|
|
2730
|
+
<button type="button" role="combobox" class="input search-select-control" aria-haspopup="listbox" aria-expanded="false" aria-controls="${W(p)}" aria-label="${W(this._accessibleName())}"${this.hasAttribute("disabled") ? " disabled" : ""}>
|
|
2731
|
+
${a ? `<i class="bi bi-${W(a)} search-select-icon" aria-hidden="true"></i>` : ""}
|
|
2655
2732
|
${o ? `<span class="search-select-prefix">${u(o)}</span>` : ""}
|
|
2656
2733
|
<span class="${d ? "" : "search-select-placeholder"}" data-label>${d ? f(d) : u(s)}</span>
|
|
2657
2734
|
${n ? "<span class=\"search-select-reset\" role=\"button\" aria-label=\"Clear selection\" hidden><i class=\"bi bi-x-lg\" aria-hidden=\"true\"></i></span>" : ""}
|
|
2658
2735
|
<i class="bi bi-chevron-down search-select-caret" aria-hidden="true"></i>
|
|
2659
2736
|
</button>
|
|
2660
|
-
<div class="search-select-menu search-select-menu-fixed" role="listbox" tabindex="-1" hidden>
|
|
2661
|
-
${t ? `<div class="search-select-search"><i class="bi bi-search" aria-hidden="true"></i><input class="search-select-input" placeholder="${
|
|
2662
|
-
<div class="search-select-options">${
|
|
2737
|
+
<div class="search-select-menu search-select-menu-fixed" role="listbox" id="${W(p)}" tabindex="-1" hidden>
|
|
2738
|
+
${t ? `<div class="search-select-search"><i class="bi bi-search" aria-hidden="true"></i><input class="search-select-input" placeholder="${W(l)}" aria-autocomplete="list" /><button type="button" class="search-select-clear" aria-label="Clear search" hidden><i class="bi bi-x" aria-hidden="true"></i></button></div>` : ""}
|
|
2739
|
+
<div class="search-select-options">${m}<div class="search-select-empty" hidden>No matches</div></div>
|
|
2663
2740
|
</div>
|
|
2664
2741
|
</div>`, this._rendered = !0, c(this, this._value), this._wire(), this._syncReset();
|
|
2665
2742
|
}
|
|
@@ -2687,7 +2764,7 @@ var G = class extends HTMLElement {
|
|
|
2687
2764
|
let t = e.dataset.value === String(this._value);
|
|
2688
2765
|
e.classList.toggle("selected", t), e.setAttribute("aria-selected", String(t));
|
|
2689
2766
|
}
|
|
2690
|
-
e && (e.innerHTML = t ? f(t) :
|
|
2767
|
+
e && (e.innerHTML = t ? f(t) : u(this.getAttribute("placeholder") || "Select..."), e.classList.toggle("search-select-placeholder", !t));
|
|
2691
2768
|
}
|
|
2692
2769
|
_syncReset() {
|
|
2693
2770
|
let { reset: e } = this._refs();
|
|
@@ -2702,11 +2779,11 @@ var G = class extends HTMLElement {
|
|
|
2702
2779
|
let t = e.control.getBoundingClientRect();
|
|
2703
2780
|
e.menu.style.width = "max-content", e.menu.style.minWidth = `${t.width}px`, e.menu.style.maxWidth = "280px", i(e.control, e.menu);
|
|
2704
2781
|
} else i(e.control, e.menu, { matchWidth: !0 });
|
|
2705
|
-
}, n = (
|
|
2706
|
-
let
|
|
2707
|
-
this._active =
|
|
2782
|
+
}, n = (t) => {
|
|
2783
|
+
let n = this._visible();
|
|
2784
|
+
this._active = t;
|
|
2708
2785
|
for (let e of this._optionEls()) e.classList.remove("is-active");
|
|
2709
|
-
|
|
2786
|
+
t >= 0 && n[t] ? (n[t].classList.add("is-active"), n[t].scrollIntoView({ block: "nearest" }), e.control.setAttribute("aria-activedescendant", n[t].id)) : e.control.removeAttribute("aria-activedescendant");
|
|
2710
2787
|
}, r = (t) => {
|
|
2711
2788
|
let n = t.trim().toLowerCase(), r = 0;
|
|
2712
2789
|
for (let e of this._optionEls()) {
|
|
@@ -2742,26 +2819,589 @@ var G = class extends HTMLElement {
|
|
|
2742
2819
|
r(e.search.value), n(-1);
|
|
2743
2820
|
}), e.clear?.addEventListener("click", () => {
|
|
2744
2821
|
e.search.value = "", r(""), e.search.focus();
|
|
2745
|
-
}), e.menu.addEventListener("keydown", u), this.
|
|
2746
|
-
|
|
2747
|
-
|
|
2748
|
-
|
|
2749
|
-
|
|
2822
|
+
}), e.menu.addEventListener("keydown", u), this._bindGlobal = () => {
|
|
2823
|
+
this._teardown(), this._onDocClick = (e) => {
|
|
2824
|
+
o() && !this.contains(e.target) && c();
|
|
2825
|
+
}, document.addEventListener("click", this._onDocClick), a(this, () => {
|
|
2826
|
+
o() && t();
|
|
2827
|
+
});
|
|
2828
|
+
}, this._bindGlobal();
|
|
2829
|
+
}
|
|
2830
|
+
_teardown() {
|
|
2831
|
+
this._onDocClick &&= (document.removeEventListener("click", this._onDocClick), null), o(this);
|
|
2832
|
+
}
|
|
2833
|
+
disconnectedCallback() {
|
|
2834
|
+
this._teardown();
|
|
2835
|
+
}
|
|
2836
|
+
}, W = (e) => String(e ?? "").replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<"), G = class extends HTMLElement {
|
|
2837
|
+
static formAssociated = !0;
|
|
2838
|
+
static get observedAttributes() {
|
|
2839
|
+
return [
|
|
2840
|
+
"min",
|
|
2841
|
+
"max",
|
|
2842
|
+
"step",
|
|
2843
|
+
"value",
|
|
2844
|
+
"start",
|
|
2845
|
+
"end",
|
|
2846
|
+
"name",
|
|
2847
|
+
"start-name",
|
|
2848
|
+
"end-name",
|
|
2849
|
+
"disabled",
|
|
2850
|
+
"size",
|
|
2851
|
+
"show-value",
|
|
2852
|
+
"unit",
|
|
2853
|
+
"aria-label"
|
|
2854
|
+
];
|
|
2855
|
+
}
|
|
2856
|
+
constructor() {
|
|
2857
|
+
super();
|
|
2858
|
+
try {
|
|
2859
|
+
this._internals = this.attachInternals();
|
|
2860
|
+
} catch {
|
|
2861
|
+
this._internals = null;
|
|
2862
|
+
}
|
|
2863
|
+
this._value = 50, this._start = 25, this._end = 75, this._isDragging = !1, this._dragThumb = null, this._pointerDownListener = null, this._pointerMoveListener = null, this._pointerUpListener = null, this._thumbKeyListener = null, this._trackClickListener = null;
|
|
2864
|
+
}
|
|
2865
|
+
connectedCallback() {
|
|
2866
|
+
if (!this._rendered) {
|
|
2867
|
+
this.render();
|
|
2868
|
+
return;
|
|
2869
|
+
}
|
|
2870
|
+
this._wire();
|
|
2871
|
+
}
|
|
2872
|
+
get value() {
|
|
2873
|
+
return this._value;
|
|
2874
|
+
}
|
|
2875
|
+
set value(e) {
|
|
2876
|
+
this._value = this._snapToStep(this._clamp(K(e, this._value))), this._syncValue(), this._syncMirrors();
|
|
2877
|
+
}
|
|
2878
|
+
get start() {
|
|
2879
|
+
return this._start;
|
|
2880
|
+
}
|
|
2881
|
+
set start(e) {
|
|
2882
|
+
this._start = Math.min(this._snapToStep(this._clamp(K(e, this._start))), this._end), this._syncValue(), this._syncMirrors();
|
|
2883
|
+
}
|
|
2884
|
+
get end() {
|
|
2885
|
+
return this._end;
|
|
2886
|
+
}
|
|
2887
|
+
set end(e) {
|
|
2888
|
+
this._end = Math.max(this._snapToStep(this._clamp(K(e, this._end))), this._start), this._syncValue(), this._syncMirrors();
|
|
2889
|
+
}
|
|
2890
|
+
attributeChangedCallback(e, t, n) {
|
|
2891
|
+
if (e === "value" || e === "start" || e === "end" || e === "min" || e === "max" || e === "step") {
|
|
2892
|
+
this._updateFromAttribute(e), this._rendered && (this._syncValue(), this._syncMirrors());
|
|
2893
|
+
return;
|
|
2894
|
+
}
|
|
2895
|
+
this._rendered && this.render();
|
|
2896
|
+
}
|
|
2897
|
+
formResetCallback() {
|
|
2898
|
+
this._isRange() ? this._resetRange() : this._resetSingle();
|
|
2899
|
+
}
|
|
2900
|
+
_updateFromAttribute(e) {
|
|
2901
|
+
e === "value" ? this._value = this._snapToStep(this._clamp(K(this.getAttribute("value"), this._value))) : e === "start" ? this._start = this._snapToStep(this._clamp(K(this.getAttribute("start"), this._start))) : e === "end" && (this._end = this._snapToStep(this._clamp(K(this.getAttribute("end"), this._end))));
|
|
2902
|
+
}
|
|
2903
|
+
_isRange() {
|
|
2904
|
+
return this.hasAttribute("range");
|
|
2905
|
+
}
|
|
2906
|
+
_min() {
|
|
2907
|
+
return K(this.getAttribute("min"), 0);
|
|
2908
|
+
}
|
|
2909
|
+
_max() {
|
|
2910
|
+
return K(this.getAttribute("max"), 100);
|
|
2911
|
+
}
|
|
2912
|
+
_step() {
|
|
2913
|
+
return K(this.getAttribute("step"), 1);
|
|
2914
|
+
}
|
|
2915
|
+
_clamp(e) {
|
|
2916
|
+
return Math.max(this._min(), Math.min(e, this._max()));
|
|
2917
|
+
}
|
|
2918
|
+
_snapToStep(e) {
|
|
2919
|
+
let t = this._step();
|
|
2920
|
+
if (t <= 0) return e;
|
|
2921
|
+
let n = this._min();
|
|
2922
|
+
return this._clamp(n + Math.round((e - n) / t) * t);
|
|
2923
|
+
}
|
|
2924
|
+
_captureDefaults() {
|
|
2925
|
+
this._defaultsCaptured ||= (this._isRange() ? (this._defaultStart = this._start, this._defaultEnd = this._end) : this._defaultValue = this._value, !0);
|
|
2926
|
+
}
|
|
2927
|
+
_resetSingle() {
|
|
2928
|
+
this._value = this._defaultValue ?? 50, this._syncValue(), this._syncMirrors();
|
|
2929
|
+
}
|
|
2930
|
+
_resetRange() {
|
|
2931
|
+
this._start = this._defaultStart ?? 25, this._end = this._defaultEnd ?? 75, this._syncValue(), this._syncMirrors();
|
|
2932
|
+
}
|
|
2933
|
+
render() {
|
|
2934
|
+
this._captureDefaults();
|
|
2935
|
+
let e = this._min(), t = this._max(), n = this._isRange(), r = this.getAttribute("size"), i = r === "sm" ? " slider-sm" : r === "lg" ? " slider-lg" : "", a = this.hasAttribute("disabled");
|
|
2936
|
+
n ? (this._start = this._clamp(this._start), this._end = this._clamp(this._end), this._start > this._end && ([this._start, this._end] = [this._end, this._start])) : this._value = this._clamp(this._value);
|
|
2937
|
+
let o = (n) => t === e ? 0 : (n - e) / (t - e) * 100, s = n ? o(this._start) : 0, c = o(n ? this._end : this._value);
|
|
2938
|
+
this.innerHTML = `
|
|
2939
|
+
<div class="slider${i}">
|
|
2940
|
+
<div class="slider-track" role="presentation"></div>
|
|
2941
|
+
<div class="slider-fill" style="left: ${s}%; right: ${100 - c}%;" role="presentation"></div>
|
|
2942
|
+
${n ? `
|
|
2943
|
+
<button
|
|
2944
|
+
type="button"
|
|
2945
|
+
role="slider"
|
|
2946
|
+
class="slider-thumb"
|
|
2947
|
+
data-thumb="start"
|
|
2948
|
+
aria-label="Minimum"
|
|
2949
|
+
aria-valuemin="${e}"
|
|
2950
|
+
aria-valuemax="${t}"
|
|
2951
|
+
aria-valuenow="${this._start}"
|
|
2952
|
+
aria-valuetext="${this._formatValue(this._start)}"
|
|
2953
|
+
${a ? "disabled" : ""}
|
|
2954
|
+
></button>
|
|
2955
|
+
<button
|
|
2956
|
+
type="button"
|
|
2957
|
+
role="slider"
|
|
2958
|
+
class="slider-thumb"
|
|
2959
|
+
data-thumb="end"
|
|
2960
|
+
aria-label="Maximum"
|
|
2961
|
+
aria-valuemin="${e}"
|
|
2962
|
+
aria-valuemax="${t}"
|
|
2963
|
+
aria-valuenow="${this._end}"
|
|
2964
|
+
aria-valuetext="${this._formatValue(this._end)}"
|
|
2965
|
+
${a ? "disabled" : ""}
|
|
2966
|
+
></button>
|
|
2967
|
+
` : `
|
|
2968
|
+
<button
|
|
2969
|
+
type="button"
|
|
2970
|
+
role="slider"
|
|
2971
|
+
class="slider-thumb"
|
|
2972
|
+
data-thumb="single"
|
|
2973
|
+
aria-valuemin="${e}"
|
|
2974
|
+
aria-valuemax="${t}"
|
|
2975
|
+
aria-valuenow="${this._value}"
|
|
2976
|
+
aria-valuetext="${this._formatValue(this._value)}"
|
|
2977
|
+
${a ? "disabled" : ""}
|
|
2978
|
+
aria-label="${ue(this.getAttribute("aria-label") || "Value")}"
|
|
2979
|
+
></button>
|
|
2980
|
+
`}
|
|
2981
|
+
${this.hasAttribute("show-value") ? n ? `<span class="slider-value">${this._formatValue(this._start)} – ${this._formatValue(this._end)}</span>` : `<span class="slider-value">${this._formatValue(this._value)}</span>` : ""}
|
|
2982
|
+
</div>
|
|
2983
|
+
`, this._rendered = !0, this._syncMirrors(), this._wire();
|
|
2984
|
+
}
|
|
2985
|
+
_formatValue(e) {
|
|
2986
|
+
return `${e}${this.getAttribute("unit") || ""}`;
|
|
2987
|
+
}
|
|
2988
|
+
_syncValue() {
|
|
2989
|
+
if (!this._rendered) return;
|
|
2990
|
+
let e = this._min(), t = this._max(), n = (n) => t === e ? 0 : (n - e) / (t - e) * 100, r = this.querySelector(".slider-fill");
|
|
2991
|
+
if (this._isRange()) {
|
|
2992
|
+
let e = n(this._start), t = n(this._end);
|
|
2993
|
+
r && (r.style.left = `${e}%`, r.style.right = `${100 - t}%`);
|
|
2994
|
+
let i = this.querySelector("[data-thumb=\"start\"]"), a = this.querySelector("[data-thumb=\"end\"]");
|
|
2995
|
+
i && (i.style.left = `${e}%`, i.setAttribute("aria-valuenow", String(this._start)), i.setAttribute("aria-valuetext", this._formatValue(this._start))), a && (a.style.left = `${t}%`, a.setAttribute("aria-valuenow", String(this._end)), a.setAttribute("aria-valuetext", this._formatValue(this._end)));
|
|
2996
|
+
let o = this.querySelector(".slider-value");
|
|
2997
|
+
o && (o.textContent = `${this._formatValue(this._start)} – ${this._formatValue(this._end)}`);
|
|
2998
|
+
} else {
|
|
2999
|
+
let e = n(this._value);
|
|
3000
|
+
r && (r.style.left = "0%", r.style.right = `${100 - e}%`);
|
|
3001
|
+
let t = this.querySelector(".slider-thumb");
|
|
3002
|
+
t && (t.style.left = `${e}%`, t.setAttribute("aria-valuenow", String(this._value)), t.setAttribute("aria-valuetext", this._formatValue(this._value)));
|
|
3003
|
+
let i = this.querySelector(".slider-value");
|
|
3004
|
+
i && (i.textContent = this._formatValue(this._value));
|
|
3005
|
+
}
|
|
3006
|
+
}
|
|
3007
|
+
_syncMirrors() {
|
|
3008
|
+
this._isRange() ? this._syncRangeMirrors() : this._syncSingleMirror();
|
|
3009
|
+
}
|
|
3010
|
+
_syncSingleMirror() {
|
|
3011
|
+
this.getAttribute("name") && c(this, String(this._value));
|
|
3012
|
+
}
|
|
3013
|
+
_syncRangeMirrors() {
|
|
3014
|
+
let e = this.getAttribute("start-name") || this.getAttribute("name"), t = this.getAttribute("end-name");
|
|
3015
|
+
this._mirrorRange("start", e, this._start), this._mirrorRange("end", t, this._end);
|
|
3016
|
+
}
|
|
3017
|
+
_mirrorRange(e, t, n) {
|
|
3018
|
+
if (!t) return;
|
|
3019
|
+
let r = this.querySelector(`input[type="hidden"][data-slider-mirror="${e}"]`);
|
|
3020
|
+
r || (r = document.createElement("input"), r.type = "hidden", r.setAttribute("data-slider-mirror", e), this.appendChild(r)), r.name = t, r.value = String(n), r.disabled = this.hasAttribute("disabled");
|
|
3021
|
+
}
|
|
3022
|
+
_valueAtPosition(e) {
|
|
3023
|
+
let t = this.querySelector(".slider-track");
|
|
3024
|
+
if (!t) return this._min();
|
|
3025
|
+
let n = t.getBoundingClientRect(), r = Math.max(0, Math.min(1, (e - n.left) / n.width)), i = this._min() + r * (this._max() - this._min());
|
|
3026
|
+
return this._snapToStep(i);
|
|
3027
|
+
}
|
|
3028
|
+
_nearestThumb(e) {
|
|
3029
|
+
return Math.abs(e - this._start) <= Math.abs(e - this._end) ? "start" : "end";
|
|
3030
|
+
}
|
|
3031
|
+
_wire() {
|
|
3032
|
+
if (this._teardown(), this.hasAttribute("disabled")) return;
|
|
3033
|
+
let e = this.querySelectorAll(".slider-thumb"), t = this.querySelector(".slider-track"), n = this._isRange();
|
|
3034
|
+
this._pointerDownListener = (e) => {
|
|
3035
|
+
if (this.hasAttribute("disabled")) return;
|
|
3036
|
+
let t = e.target.closest(".slider-thumb");
|
|
3037
|
+
t && (e.preventDefault(), this._isDragging = !0, this._dragThumb = t.getAttribute("data-thumb"), document.addEventListener("pointermove", this._pointerMoveListener), document.addEventListener("pointerup", this._pointerUpListener));
|
|
3038
|
+
}, this._pointerMoveListener = (e) => {
|
|
3039
|
+
if (!this._isDragging) return;
|
|
3040
|
+
e.preventDefault();
|
|
3041
|
+
let t = this._valueAtPosition(e.clientX);
|
|
3042
|
+
if (this._dragThumb === "single") this._value = this._clamp(t), this._syncValue(), this.dispatchEvent(new CustomEvent("slide", { detail: { value: this._value } }));
|
|
3043
|
+
else if (this._dragThumb === "start") {
|
|
3044
|
+
let e = Math.min(t, this._end);
|
|
3045
|
+
this._start = this._clamp(e), this._syncValue(), this.dispatchEvent(new CustomEvent("slide", { detail: {
|
|
3046
|
+
start: this._start,
|
|
3047
|
+
end: this._end
|
|
3048
|
+
} }));
|
|
3049
|
+
} else if (this._dragThumb === "end") {
|
|
3050
|
+
let e = Math.max(t, this._start);
|
|
3051
|
+
this._end = this._clamp(e), this._syncValue(), this.dispatchEvent(new CustomEvent("slide", { detail: {
|
|
3052
|
+
start: this._start,
|
|
3053
|
+
end: this._end
|
|
3054
|
+
} }));
|
|
3055
|
+
}
|
|
3056
|
+
}, this._pointerUpListener = () => {
|
|
3057
|
+
this._isDragging && (this._isDragging = !1, this._dragThumb = null, document.removeEventListener("pointermove", this._pointerMoveListener), document.removeEventListener("pointerup", this._pointerUpListener), this._syncMirrors(), this.dispatchEvent(new Event("change", { bubbles: !0 })));
|
|
3058
|
+
}, this._thumbKeyListener = (e) => {
|
|
3059
|
+
let t = e.currentTarget;
|
|
3060
|
+
if (this.hasAttribute("disabled")) return;
|
|
3061
|
+
let n = this._step(), r = n * 10, i = null, a = t.getAttribute("data-thumb"), o = a === "end" ? this._end : a === "start" ? this._start : this._value;
|
|
3062
|
+
e.key === "ArrowLeft" || e.key === "ArrowDown" ? (e.preventDefault(), i = o - n) : e.key === "ArrowRight" || e.key === "ArrowUp" ? (e.preventDefault(), i = o + n) : e.key === "PageDown" ? (e.preventDefault(), i = o - r) : e.key === "PageUp" ? (e.preventDefault(), i = o + r) : e.key === "Home" ? (e.preventDefault(), i = this._min()) : e.key === "End" && (e.preventDefault(), i = this._max()), i != null && (i = this._clamp(i), a === "single" ? this._value = i : a === "start" ? this._start = Math.min(i, this._end) : a === "end" && (this._end = Math.max(i, this._start)), this._syncValue(), this._syncMirrors(), this.dispatchEvent(new Event("change", { bubbles: !0 })));
|
|
3063
|
+
}, this._trackClickListener = (e) => {
|
|
3064
|
+
if (this.hasAttribute("disabled")) return;
|
|
3065
|
+
let t = this._valueAtPosition(e.clientX);
|
|
3066
|
+
n ? this._nearestThumb(t) === "start" ? this._start = Math.min(this._clamp(t), this._end) : this._end = Math.max(this._clamp(t), this._start) : this._value = this._clamp(t), this._syncValue(), this._syncMirrors(), this.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
3067
|
+
}, e.forEach((e) => {
|
|
3068
|
+
e.addEventListener("pointerdown", this._pointerDownListener), e.addEventListener("keydown", this._thumbKeyListener);
|
|
3069
|
+
}), t?.addEventListener("click", this._trackClickListener);
|
|
2750
3070
|
}
|
|
2751
3071
|
_teardown() {
|
|
2752
|
-
this.
|
|
3072
|
+
for (let e of this.querySelectorAll(".slider-thumb")) e.removeEventListener("pointerdown", this._pointerDownListener), e.removeEventListener("keydown", this._thumbKeyListener);
|
|
3073
|
+
document.removeEventListener("pointermove", this._pointerMoveListener), document.removeEventListener("pointerup", this._pointerUpListener), this._isDragging = !1, this._dragThumb = null, this.querySelector(".slider-track")?.removeEventListener("click", this._trackClickListener);
|
|
2753
3074
|
}
|
|
2754
3075
|
disconnectedCallback() {
|
|
2755
3076
|
this._teardown();
|
|
2756
3077
|
}
|
|
2757
|
-
},
|
|
3078
|
+
}, K = (e, t) => {
|
|
3079
|
+
let n = Number.parseFloat(e);
|
|
3080
|
+
return Number.isFinite(n) ? n : t;
|
|
3081
|
+
}, ue = (e) => String(e ?? "").replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<"), de = class extends HTMLElement {
|
|
3082
|
+
static formAssociated = !0;
|
|
3083
|
+
_accessibleName() {
|
|
3084
|
+
return this.getAttribute("aria-label") || this.getAttribute("placeholder") || "Add tags";
|
|
3085
|
+
}
|
|
3086
|
+
static get observedAttributes() {
|
|
3087
|
+
return [
|
|
3088
|
+
"placeholder",
|
|
3089
|
+
"disabled",
|
|
3090
|
+
"size",
|
|
3091
|
+
"max-tags",
|
|
3092
|
+
"aria-label",
|
|
3093
|
+
"separators",
|
|
3094
|
+
"allow-duplicates"
|
|
3095
|
+
];
|
|
3096
|
+
}
|
|
3097
|
+
constructor() {
|
|
3098
|
+
super(), this._values = [], this._draftText = "";
|
|
3099
|
+
try {
|
|
3100
|
+
this._internals = this.attachInternals();
|
|
3101
|
+
} catch {
|
|
3102
|
+
this._internals = null;
|
|
3103
|
+
}
|
|
3104
|
+
}
|
|
3105
|
+
connectedCallback() {
|
|
3106
|
+
if (!this._rendered) {
|
|
3107
|
+
if (!this._valuesInit && !this._values.length) {
|
|
3108
|
+
let e = this.getAttribute("value");
|
|
3109
|
+
if (e != null && e !== "") this._values = e.split(",").map((e) => e.trim()).filter(Boolean);
|
|
3110
|
+
else {
|
|
3111
|
+
let e = [...this.querySelectorAll(":scope > wui-tag")].map((e) => e.textContent.trim());
|
|
3112
|
+
e.length && (this._values = e.map(String));
|
|
3113
|
+
}
|
|
3114
|
+
}
|
|
3115
|
+
this._valuesInit = !0, this._defaultCaptured ||= (this._defaultValues = this._values.slice(), !0), this.render();
|
|
3116
|
+
return;
|
|
3117
|
+
}
|
|
3118
|
+
this._wire();
|
|
3119
|
+
}
|
|
3120
|
+
formResetCallback() {
|
|
3121
|
+
this.values = (this._defaultValues || []).slice(), this._draftText = "";
|
|
3122
|
+
let e = this.querySelector("[data-input]");
|
|
3123
|
+
e && (e.value = "");
|
|
3124
|
+
}
|
|
3125
|
+
attributeChangedCallback(e) {
|
|
3126
|
+
if (this._rendered) {
|
|
3127
|
+
if (e === "separators" || e === "allow-duplicates") {
|
|
3128
|
+
this._wire();
|
|
3129
|
+
return;
|
|
3130
|
+
}
|
|
3131
|
+
this.render();
|
|
3132
|
+
}
|
|
3133
|
+
}
|
|
3134
|
+
get values() {
|
|
3135
|
+
return this._values.slice();
|
|
3136
|
+
}
|
|
3137
|
+
set values(e) {
|
|
3138
|
+
this._values = Array.isArray(e) ? e.map(String) : [], c(this, this._values.join(",")), this._rendered && this._renderControl();
|
|
3139
|
+
}
|
|
3140
|
+
render() {
|
|
3141
|
+
let e = this.getAttribute("size"), t = e === "sm" ? " search-select-sm" : e === "lg" ? " search-select-lg" : "";
|
|
3142
|
+
c(this, this._values.join(",")), this.innerHTML = `
|
|
3143
|
+
<div class="search-select${t}">
|
|
3144
|
+
<div class="input search-select-control search-select-multi"${this.hasAttribute("disabled") ? " aria-disabled=\"true\"" : ""}>
|
|
3145
|
+
<div class="ms-chips" data-chips></div>
|
|
3146
|
+
<input type="text" class="ms-input" data-input aria-label="${q(this._accessibleName())}" placeholder="${q(this.getAttribute("placeholder") || "Add…")}" autocomplete="off"${this.hasAttribute("disabled") ? " disabled" : ""}/>
|
|
3147
|
+
</div>
|
|
3148
|
+
</div>`, this._rendered = !0, c(this, this._values.join(",")), this._renderControl(), this._wire();
|
|
3149
|
+
}
|
|
3150
|
+
_renderControl() {
|
|
3151
|
+
let e = this.querySelector("[data-chips]");
|
|
3152
|
+
if (e) {
|
|
3153
|
+
if (!this._values.length) {
|
|
3154
|
+
e.innerHTML = "";
|
|
3155
|
+
return;
|
|
3156
|
+
}
|
|
3157
|
+
e.innerHTML = this._values.map((e) => `<span class="chip chip-sm"><span class="chip-label">${fe(e)}</span><button type="button" class="chip-remove" data-remove="${q(e)}" aria-label="Remove ${q(e)}"><i class="bi bi-x" aria-hidden="true"></i></button></span>`).join("");
|
|
3158
|
+
}
|
|
3159
|
+
}
|
|
3160
|
+
_wire() {
|
|
3161
|
+
this._teardown();
|
|
3162
|
+
let e = this.querySelector(".search-select-control"), t = this.querySelector("[data-input]");
|
|
3163
|
+
if (!e || !t) return;
|
|
3164
|
+
let n = () => this.hasAttribute("disabled"), r = (this.getAttribute("separators") || "enter,comma").split(",").map((e) => e.trim()), i = this.getAttribute("max-tags"), a = this.hasAttribute("allow-duplicates"), o = /* @__PURE__ */ new Set();
|
|
3165
|
+
for (let e of r) e === "enter" ? o.add("Enter") : e === "comma" ? o.add(",") : e === "space" ? o.add(" ") : e === "tab" && o.add("Tab");
|
|
3166
|
+
let s = () => {
|
|
3167
|
+
c(this, this._values.join(",")), this.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
3168
|
+
}, l = (e) => {
|
|
3169
|
+
let t = e.trim();
|
|
3170
|
+
if (!t || i && this._values.length >= parseInt(i, 10)) return;
|
|
3171
|
+
let n = a ? t : t.toLowerCase();
|
|
3172
|
+
(!this._values.some((e) => a ? e === t : e.toLowerCase() === n) || a) && (this._values.push(t), this._renderControl(), s());
|
|
3173
|
+
}, u = (e) => {
|
|
3174
|
+
this._values = this._values.filter((t) => t !== e), this._renderControl(), s();
|
|
3175
|
+
}, d = (e) => {
|
|
3176
|
+
if (e.key === "Enter" && o.has("Enter")) {
|
|
3177
|
+
e.preventDefault(), l(t.value), t.value = "";
|
|
3178
|
+
return;
|
|
3179
|
+
}
|
|
3180
|
+
if (e.key === "," && o.has(",")) {
|
|
3181
|
+
e.preventDefault(), l(t.value.replace(/,+$/, "")), t.value = "";
|
|
3182
|
+
return;
|
|
3183
|
+
}
|
|
3184
|
+
if (e.key === " " && o.has(" ")) {
|
|
3185
|
+
let n = t.value.trim();
|
|
3186
|
+
n && (e.preventDefault(), l(n), t.value = "");
|
|
3187
|
+
return;
|
|
3188
|
+
}
|
|
3189
|
+
if (e.key === "Tab" && o.has("Tab")) {
|
|
3190
|
+
e.preventDefault(), l(t.value), t.value = "";
|
|
3191
|
+
return;
|
|
3192
|
+
}
|
|
3193
|
+
e.key === "Backspace" && !t.value && this._values.length && (e.preventDefault(), u(this._values[this._values.length - 1])), e.key === "Escape" && (t.value = "");
|
|
3194
|
+
}, f = (e) => {
|
|
3195
|
+
e.preventDefault();
|
|
3196
|
+
let n = e.clipboardData.getData("text/plain"), a = [];
|
|
3197
|
+
for (let e of r) {
|
|
3198
|
+
let t = e;
|
|
3199
|
+
if (t === "enter" ? t = "\n" : t === "comma" ? t = "," : t === "space" ? t = " " : t === "tab" && (t = " "), n.includes(t)) {
|
|
3200
|
+
a.push(...n.split(t).map((e) => e.trim()).filter((e) => e));
|
|
3201
|
+
break;
|
|
3202
|
+
}
|
|
3203
|
+
}
|
|
3204
|
+
a.length || a.push(n.trim());
|
|
3205
|
+
for (let e of a) if (l(e), i && this._values.length >= parseInt(i, 10)) break;
|
|
3206
|
+
t.value = "";
|
|
3207
|
+
};
|
|
3208
|
+
this._onControlClick = (e) => {
|
|
3209
|
+
if (n()) return;
|
|
3210
|
+
let r = e.target.closest("[data-remove]");
|
|
3211
|
+
if (r) {
|
|
3212
|
+
e.stopPropagation(), u(r.dataset.remove), t.focus();
|
|
3213
|
+
return;
|
|
3214
|
+
}
|
|
3215
|
+
t.focus();
|
|
3216
|
+
}, this._onInputKey = d, this._onInputPaste = f, e.addEventListener("click", this._onControlClick), t.addEventListener("keydown", this._onInputKey), t.addEventListener("paste", this._onInputPaste), this._onDocClick = (e) => {
|
|
3217
|
+
this.contains(e.target) || t.blur();
|
|
3218
|
+
}, document.addEventListener("click", this._onDocClick);
|
|
3219
|
+
}
|
|
3220
|
+
_teardown() {
|
|
3221
|
+
this._onDocClick &&= (document.removeEventListener("click", this._onDocClick), null);
|
|
3222
|
+
let e = this.querySelector(".search-select-control"), t = this.querySelector("[data-input]");
|
|
3223
|
+
e && this._onControlClick && e.removeEventListener("click", this._onControlClick), t && this._onInputKey && (t.removeEventListener("keydown", this._onInputKey), t.removeEventListener("paste", this._onInputPaste));
|
|
3224
|
+
}
|
|
3225
|
+
disconnectedCallback() {
|
|
3226
|
+
this._teardown();
|
|
3227
|
+
}
|
|
3228
|
+
}, fe = (e) => String(e ?? "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">"), q = (e) => String(e ?? "").replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<"), J = (e) => String(e).padStart(2, "0"), pe = (e, t) => `${J(e)}:${J(t)}`, Y = (e) => {
|
|
3229
|
+
let t = /^(\d{2}):(\d{2})$/.exec(e || "");
|
|
3230
|
+
return t ? {
|
|
3231
|
+
h: +t[1],
|
|
3232
|
+
m: +t[2]
|
|
3233
|
+
} : null;
|
|
3234
|
+
}, X = (e, t = "24") => {
|
|
3235
|
+
if (!e) return "";
|
|
3236
|
+
if (t === "24") return pe(e.h, e.m);
|
|
3237
|
+
let n = e.h % 12 || 12, r = e.h >= 12 ? "PM" : "AM";
|
|
3238
|
+
return `${n}:${J(e.m)} ${r}`;
|
|
3239
|
+
}, me = class extends HTMLElement {
|
|
3240
|
+
static formAssociated = !0;
|
|
3241
|
+
static get observedAttributes() {
|
|
3242
|
+
return [
|
|
3243
|
+
"value",
|
|
3244
|
+
"min",
|
|
3245
|
+
"max",
|
|
3246
|
+
"step",
|
|
3247
|
+
"format",
|
|
3248
|
+
"placeholder",
|
|
3249
|
+
"disabled",
|
|
3250
|
+
"required",
|
|
3251
|
+
"size",
|
|
3252
|
+
"aria-label",
|
|
3253
|
+
"aria-describedby"
|
|
3254
|
+
];
|
|
3255
|
+
}
|
|
3256
|
+
constructor() {
|
|
3257
|
+
super();
|
|
3258
|
+
try {
|
|
3259
|
+
this._internals = this.attachInternals();
|
|
3260
|
+
} catch {
|
|
3261
|
+
this._internals = null;
|
|
3262
|
+
}
|
|
3263
|
+
this._value = "", this._focus = null;
|
|
3264
|
+
}
|
|
3265
|
+
connectedCallback() {
|
|
3266
|
+
if (!this._rendered) {
|
|
3267
|
+
this.render();
|
|
3268
|
+
return;
|
|
3269
|
+
}
|
|
3270
|
+
this._bindGlobal?.();
|
|
3271
|
+
}
|
|
3272
|
+
attributeChangedCallback(e, t, n) {
|
|
3273
|
+
this._rendered && (e === "value" ? (this._value = n || "", this._syncFormValue(), this._syncTrigger()) : this.render());
|
|
3274
|
+
}
|
|
3275
|
+
formResetCallback() {
|
|
3276
|
+
this.value = this._defaultValue || "";
|
|
3277
|
+
}
|
|
3278
|
+
get value() {
|
|
3279
|
+
return this._value;
|
|
3280
|
+
}
|
|
3281
|
+
set value(e) {
|
|
3282
|
+
this._value = e || "", c(this, this._value), this._syncTrigger();
|
|
3283
|
+
}
|
|
3284
|
+
render() {
|
|
3285
|
+
this._defaultValue === void 0 && (this._defaultValue = this.getAttribute("value") || "", this._value = this._defaultValue || this._value);
|
|
3286
|
+
let e = this.getAttribute("placeholder") || "Select time", t = Y(this._value), n = this.getAttribute("format") || "24", r = this.getAttribute("size"), i = r === "sm" ? " input-sm" : r === "lg" ? " input-lg" : "", a = this.getAttribute("aria-label"), o = this.getAttribute("aria-describedby");
|
|
3287
|
+
this.innerHTML = `
|
|
3288
|
+
<div class="timepicker">
|
|
3289
|
+
<button type="button" class="input timepicker-trigger${i}${t ? " has-value" : ""}" aria-haspopup="listbox" aria-expanded="false"${this.hasAttribute("disabled") ? " disabled" : ""}${a ? ` aria-label="${u(a)}"` : ""}${o ? ` aria-describedby="${u(o)}"` : ""}>
|
|
3290
|
+
<span data-trigger-label class="${t ? "" : "timepicker-placeholder"}">${t ? X(t, n) : u(e)}</span>
|
|
3291
|
+
<i class="bi bi-clock" aria-hidden="true"></i>
|
|
3292
|
+
</button>
|
|
3293
|
+
<div class="timepicker-pop" role="listbox" tabindex="-1" hidden></div>
|
|
3294
|
+
</div>`, this._rendered = !0, c(this, this._value), this._wire();
|
|
3295
|
+
}
|
|
3296
|
+
_syncFormValue() {
|
|
3297
|
+
c(this, this._value);
|
|
3298
|
+
}
|
|
3299
|
+
_syncTrigger() {
|
|
3300
|
+
let e = this.querySelector(".timepicker-trigger"), t = this.querySelector("[data-trigger-label]");
|
|
3301
|
+
if (!t) return;
|
|
3302
|
+
let n = Y(this._value), r = this.getAttribute("format") || "24";
|
|
3303
|
+
t.textContent = n ? X(n, r) : this.getAttribute("placeholder") || "Select time", t.classList.toggle("timepicker-placeholder", !n), e?.classList.toggle("has-value", !!n);
|
|
3304
|
+
}
|
|
3305
|
+
_buildTimes() {
|
|
3306
|
+
let e = Math.max(1, parseInt(this.getAttribute("step") || "30", 10)), t = this.getAttribute("min") || "00:00", n = this.getAttribute("max") || "23:59", r = Y(t) || {
|
|
3307
|
+
h: 0,
|
|
3308
|
+
m: 0
|
|
3309
|
+
}, i = Y(n) || {
|
|
3310
|
+
h: 23,
|
|
3311
|
+
m: 59
|
|
3312
|
+
}, a = [], o = r.h, s = r.m;
|
|
3313
|
+
for (s = Math.ceil(s / e) * e, s >= 60 && (o += 1, s -= 60); o < i.h || o === i.h && s <= i.m;) a.push({
|
|
3314
|
+
h: o,
|
|
3315
|
+
m: s
|
|
3316
|
+
}), s += e, s >= 60 && (o += 1, s -= 60);
|
|
3317
|
+
return a;
|
|
3318
|
+
}
|
|
3319
|
+
_renderOptions() {
|
|
3320
|
+
let e = this.querySelector(".timepicker-pop");
|
|
3321
|
+
if (!e) return;
|
|
3322
|
+
let t = this.getAttribute("format") || "24", n = this._buildTimes(), r = Y(this._value), i = this._focus, a = "";
|
|
3323
|
+
for (let e = 0; e < n.length; e++) {
|
|
3324
|
+
let o = n[e], s = pe(o.h, o.m), c = r && r.h === o.h && r.m === o.m;
|
|
3325
|
+
a += `<button type="button" class="timepicker-option${c ? " is-selected" : ""}" data-hm="${s}" role="option" tabindex="${i === e ? "0" : "-1"}"${c ? " aria-selected=\"true\"" : ""}>${X(o, t)}</button>`;
|
|
3326
|
+
}
|
|
3327
|
+
e.innerHTML = a, this._focusActive();
|
|
3328
|
+
}
|
|
3329
|
+
_focusActive() {
|
|
3330
|
+
let e = this.querySelector(".timepicker-pop"), t = e?.querySelector("[tabindex=\"0\"]") || e?.querySelector(".is-selected");
|
|
3331
|
+
t && !e.hidden && t.focus();
|
|
3332
|
+
}
|
|
3333
|
+
_position(e, t) {
|
|
3334
|
+
i(e, t);
|
|
3335
|
+
}
|
|
3336
|
+
_onKey(e) {
|
|
3337
|
+
let t = [...this.querySelector(".timepicker-pop").querySelectorAll(".timepicker-option")];
|
|
3338
|
+
switch (e.key) {
|
|
3339
|
+
case "ArrowUp": {
|
|
3340
|
+
e.preventDefault();
|
|
3341
|
+
let t = Math.max((this._focus ?? 0) - 1, 0);
|
|
3342
|
+
this._focus = t, this._renderOptions();
|
|
3343
|
+
break;
|
|
3344
|
+
}
|
|
3345
|
+
case "ArrowDown": {
|
|
3346
|
+
e.preventDefault();
|
|
3347
|
+
let n = Math.min((this._focus ?? -1) + 1, t.length - 1);
|
|
3348
|
+
this._focus = n, this._renderOptions();
|
|
3349
|
+
break;
|
|
3350
|
+
}
|
|
3351
|
+
case "Enter":
|
|
3352
|
+
case " ":
|
|
3353
|
+
e.preventDefault(), t[this._focus] && (this.value = t[this._focus].dataset.hm, this.dispatchEvent(new Event("change", { bubbles: !0 })), this._close());
|
|
3354
|
+
break;
|
|
3355
|
+
case "Escape":
|
|
3356
|
+
this._close();
|
|
3357
|
+
break;
|
|
3358
|
+
default:
|
|
3359
|
+
}
|
|
3360
|
+
}
|
|
3361
|
+
_wire() {
|
|
3362
|
+
this._teardown();
|
|
3363
|
+
let e = this.querySelector(".timepicker-trigger"), t = this.querySelector(".timepicker-pop");
|
|
3364
|
+
if (!e || !t) return;
|
|
3365
|
+
let n = () => !t.hidden;
|
|
3366
|
+
this._open = () => {
|
|
3367
|
+
this._focus = null, this._renderOptions(), t.hidden = !1, e.setAttribute("aria-expanded", "true"), this._position(e, t);
|
|
3368
|
+
let n = t.querySelector(".is-selected");
|
|
3369
|
+
n ? this._focus = [...t.querySelectorAll(".timepicker-option")].indexOf(n) : this._focus = 0, this._renderOptions(), t.querySelector("[tabindex=\"0\"]")?.focus();
|
|
3370
|
+
}, this._close = () => {
|
|
3371
|
+
t.hidden = !0, e.setAttribute("aria-expanded", "false"), e.focus();
|
|
3372
|
+
}, e.addEventListener("click", () => n() ? this._close() : this._open()), e.addEventListener("keydown", (e) => {
|
|
3373
|
+
(e.key === "Enter" || e.key === " " || e.key === "ArrowDown") && (e.preventDefault(), n() || this._open());
|
|
3374
|
+
}), t.addEventListener("click", (e) => {
|
|
3375
|
+
this._popClick = !0;
|
|
3376
|
+
let t = e.target.closest(".timepicker-option");
|
|
3377
|
+
t && !t.disabled && (this.value = t.dataset.hm, this.dispatchEvent(new Event("change", { bubbles: !0 })), this._close());
|
|
3378
|
+
}), this._onKeyBound = (e) => {
|
|
3379
|
+
n() && this._onKey(e);
|
|
3380
|
+
}, t.addEventListener("keydown", this._onKeyBound), this._bindGlobal = () => {
|
|
3381
|
+
this._teardown(), this._onDocClick = (e) => {
|
|
3382
|
+
let t = this._popClick;
|
|
3383
|
+
this._popClick = !1, n() && !t && !this.contains(e.target) && this._close();
|
|
3384
|
+
}, document.addEventListener("click", this._onDocClick), this._onDocKey = (e) => {
|
|
3385
|
+
n() && e.key === "Escape" && this._close();
|
|
3386
|
+
}, document.addEventListener("keydown", this._onDocKey), a(this, () => {
|
|
3387
|
+
n() && this._position(e, t);
|
|
3388
|
+
});
|
|
3389
|
+
}, this._bindGlobal(), this._syncFormValue();
|
|
3390
|
+
}
|
|
3391
|
+
_teardown() {
|
|
3392
|
+
this._onDocClick &&= (document.removeEventListener("click", this._onDocClick), null), this._onDocKey &&= (document.removeEventListener("keydown", this._onDocKey), null), o(this);
|
|
3393
|
+
}
|
|
3394
|
+
disconnectedCallback() {
|
|
3395
|
+
this._teardown();
|
|
3396
|
+
}
|
|
3397
|
+
}, he = "image/png,image/jpeg,image/webp", ge = 5, _e = {
|
|
2758
3398
|
"image/png": [".png"],
|
|
2759
3399
|
"image/jpeg": [".jpg", ".jpeg"],
|
|
2760
3400
|
"image/webp": [".webp"],
|
|
2761
3401
|
"image/gif": [".gif"],
|
|
2762
3402
|
"image/svg+xml": [".svg"],
|
|
2763
3403
|
"application/pdf": [".pdf"]
|
|
2764
|
-
},
|
|
3404
|
+
}, ve = {
|
|
2765
3405
|
"image/png": "PNG",
|
|
2766
3406
|
"image/jpeg": "JPG",
|
|
2767
3407
|
"image/webp": "WEBP",
|
|
@@ -2775,7 +3415,7 @@ var G = class extends HTMLElement {
|
|
|
2775
3415
|
".gif": "GIF",
|
|
2776
3416
|
".svg": "SVG",
|
|
2777
3417
|
".pdf": "PDF"
|
|
2778
|
-
},
|
|
3418
|
+
}, Z = (e) => String(e || "").split(",").map((e) => e.trim().toLowerCase()).filter(Boolean), ye = [
|
|
2779
3419
|
".png",
|
|
2780
3420
|
".jpg",
|
|
2781
3421
|
".jpeg",
|
|
@@ -2786,44 +3426,44 @@ var G = class extends HTMLElement {
|
|
|
2786
3426
|
".avif",
|
|
2787
3427
|
".heic"
|
|
2788
3428
|
];
|
|
2789
|
-
function
|
|
3429
|
+
function be(e) {
|
|
2790
3430
|
if (!e) return !1;
|
|
2791
3431
|
let t = typeof e == "object" && e.type ? String(e.type).toLowerCase() : "";
|
|
2792
3432
|
if (t) return t.startsWith("image/");
|
|
2793
3433
|
let n = typeof e == "string" ? e : e.name || e.url || "", r = String(n).toLowerCase();
|
|
2794
|
-
return
|
|
3434
|
+
return ye.some((e) => r.endsWith(e));
|
|
2795
3435
|
}
|
|
2796
|
-
function
|
|
2797
|
-
let t =
|
|
2798
|
-
return t.length ? t.every((e) => e.startsWith(".") ?
|
|
3436
|
+
function xe(e) {
|
|
3437
|
+
let t = Z(e);
|
|
3438
|
+
return t.length ? t.every((e) => e.startsWith(".") ? ye.includes(e) : e === "image/*" || e.startsWith("image/")) : !1;
|
|
2799
3439
|
}
|
|
2800
|
-
function
|
|
3440
|
+
function Se(e) {
|
|
2801
3441
|
let t = [];
|
|
2802
|
-
for (let n of
|
|
2803
|
-
let e =
|
|
3442
|
+
for (let n of Z(e)) {
|
|
3443
|
+
let e = ve[n] || (n.startsWith(".") ? n.slice(1).toUpperCase() : n.toUpperCase());
|
|
2804
3444
|
t.includes(e) || t.push(e);
|
|
2805
3445
|
}
|
|
2806
3446
|
return t.length <= 1 ? t[0] || "supported" : `${t.slice(0, -1).join(", ")} or ${t[t.length - 1]}`;
|
|
2807
3447
|
}
|
|
2808
|
-
function
|
|
2809
|
-
let n =
|
|
3448
|
+
function Ce(e, t) {
|
|
3449
|
+
let n = Z(t);
|
|
2810
3450
|
if (!n.length) return !0;
|
|
2811
3451
|
let r = (e.type || "").toLowerCase(), i = (e.name || "").toLowerCase();
|
|
2812
|
-
return n.some((e) => e.startsWith(".") ? i.endsWith(e) : e.endsWith("/*") ? r.startsWith(e.slice(0, -1)) : r && r === e ? !0 : !r && (
|
|
3452
|
+
return n.some((e) => e.startsWith(".") ? i.endsWith(e) : e.endsWith("/*") ? r.startsWith(e.slice(0, -1)) : r && r === e ? !0 : !r && (_e[e] || []).some((e) => i.endsWith(e)));
|
|
2813
3453
|
}
|
|
2814
|
-
function
|
|
3454
|
+
function we(e, t = {}) {
|
|
2815
3455
|
if (!e) return null;
|
|
2816
|
-
let n = t.accept === void 0 ?
|
|
2817
|
-
return
|
|
3456
|
+
let n = t.accept === void 0 ? he : t.accept, r = t.maxSizeMb || 5;
|
|
3457
|
+
return Ce(e, n) ? e.size > r * 1024 * 1024 ? `Keep the file under ${r} MB.` : null : `Choose a ${Se(n)} file.`;
|
|
2818
3458
|
}
|
|
2819
3459
|
//#endregion
|
|
2820
3460
|
//#region src/index.js
|
|
2821
|
-
var
|
|
3461
|
+
var Q = (e, t) => {
|
|
2822
3462
|
typeof customElements < "u" && !customElements.get(e) && customElements.define(e, t);
|
|
2823
3463
|
};
|
|
2824
|
-
function
|
|
2825
|
-
|
|
3464
|
+
function $() {
|
|
3465
|
+
Q("wui-select", U), Q("wui-phone", V), Q("wui-datepicker", w), Q("wui-date-range", re), Q("wui-slider", G), Q("wui-timepicker", me), Q("wui-autocomplete", p), Q("wui-multiselect", ie), Q("wui-taginput", de), Q("wui-otp", j), Q("wui-status-icon", n);
|
|
2826
3466
|
}
|
|
2827
|
-
|
|
3467
|
+
$();
|
|
2828
3468
|
//#endregion
|
|
2829
|
-
export {
|
|
3469
|
+
export { he as DEFAULT_IMAGE_ACCEPT, ge as DEFAULT_MAX_SIZE_MB, t as STATUS_TONES, p as WuiAutocomplete, w as WuiDatePicker, re as WuiDateRange, ie as WuiMultiSelect, j as WuiOtp, V as WuiPhone, U as WuiSelect, G as WuiSlider, n as WuiStatusIcon, de as WuiTagInput, me as WuiTimePicker, Se as acceptLabel, $ as defineWeborityElements, be as isImageFile, xe as isImageOnlyAccept, Ce as matchesAccept, we as validateFile };
|