@webority/ui-elements 0.7.1 → 0.7.3
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 +35 -35
- package/dist/ui-elements.js +177 -38
- package/package.json +1 -1
package/dist/ui-elements.js
CHANGED
|
@@ -16,7 +16,7 @@ var e = {
|
|
|
16
16
|
this.isConnected && this.render();
|
|
17
17
|
}
|
|
18
18
|
render() {
|
|
19
|
-
let t = this.getAttribute("tone"), n = this.getAttribute("size") ||
|
|
19
|
+
let t = this.getAttribute("tone"), n = Number.parseInt(this.getAttribute("size"), 10) || 72, r = e[t] || e.info;
|
|
20
20
|
this.innerHTML = `<svg width="${n}" height="${n}" viewBox="0 0 174 174" fill="none" xmlns="http://www.w3.org/2000/svg" aria-hidden="true">${r}</svg>`;
|
|
21
21
|
}
|
|
22
22
|
}, r = 4;
|
|
@@ -57,6 +57,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
57
57
|
let t = e[l] ? String(e.label ?? "") : u(e.label), n = d(e.icon);
|
|
58
58
|
return n ? `<span class="wui-opt-label">${n}${t}</span>` : t;
|
|
59
59
|
}, p = class extends HTMLElement {
|
|
60
|
+
static formAssociated = !0;
|
|
60
61
|
_accessibleName() {
|
|
61
62
|
return this.getAttribute("aria-label") || this.getAttribute("placeholder") || "Select";
|
|
62
63
|
}
|
|
@@ -69,17 +70,30 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
69
70
|
"debounce",
|
|
70
71
|
"remote",
|
|
71
72
|
"size",
|
|
72
|
-
"aria-label"
|
|
73
|
+
"aria-label",
|
|
74
|
+
"allow-custom"
|
|
73
75
|
];
|
|
74
76
|
}
|
|
75
77
|
constructor() {
|
|
76
78
|
super(), this._value = "", this._label = "", this._optionsProp = null, this._loading = !1, this._active = -1, this._timer = null;
|
|
79
|
+
try {
|
|
80
|
+
this._internals = this.attachInternals();
|
|
81
|
+
} catch {
|
|
82
|
+
this._internals = null;
|
|
83
|
+
}
|
|
77
84
|
}
|
|
78
85
|
connectedCallback() {
|
|
79
|
-
this._rendered || this.render();
|
|
86
|
+
this._rendered || (this._defaultCaptured ||= (this._defaultValue = this._value, !0), this.render());
|
|
87
|
+
}
|
|
88
|
+
formResetCallback() {
|
|
89
|
+
this.value = this._defaultValue || "";
|
|
80
90
|
}
|
|
81
91
|
attributeChangedCallback(e, t, n) {
|
|
82
|
-
|
|
92
|
+
if (e === "value") {
|
|
93
|
+
this.value = n;
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
this._rendered && this.render();
|
|
83
97
|
}
|
|
84
98
|
get value() {
|
|
85
99
|
return this._value;
|
|
@@ -106,6 +120,13 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
106
120
|
get _remote() {
|
|
107
121
|
return this.hasAttribute("remote");
|
|
108
122
|
}
|
|
123
|
+
get _allowCustom() {
|
|
124
|
+
return this.hasAttribute("allow-custom");
|
|
125
|
+
}
|
|
126
|
+
_matchesKnownOption(e) {
|
|
127
|
+
let t = e.toLowerCase();
|
|
128
|
+
return this._readOptions().some((e) => h(e.label).toLowerCase() === t || String(e.value ?? "").toLowerCase() === t);
|
|
129
|
+
}
|
|
109
130
|
get _minChars() {
|
|
110
131
|
return Math.max(0, Number(this.getAttribute("min-chars")) || +!!this._remote);
|
|
111
132
|
}
|
|
@@ -172,13 +193,22 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
172
193
|
_renderOptions(e) {
|
|
173
194
|
let t = this._refs();
|
|
174
195
|
if (!t.optionsWrap) return;
|
|
175
|
-
let n =
|
|
176
|
-
!this._remote &&
|
|
196
|
+
let n = e ?? (t.input ? t.input.value : ""), r = n.trim().toLowerCase(), i = this._readOptions();
|
|
197
|
+
!this._remote && r && (i = i.filter((e) => h(e.label).toLowerCase().includes(r)));
|
|
198
|
+
let a = n.trim(), o = this._allowCustom && a && !this._matchesKnownOption(a) ? [...i, {
|
|
199
|
+
value: a,
|
|
200
|
+
custom: !0
|
|
201
|
+
}] : i;
|
|
202
|
+
t.optionsWrap.innerHTML = o.map((e) => {
|
|
203
|
+
if (e.custom) {
|
|
204
|
+
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>`;
|
|
206
|
+
}
|
|
177
207
|
let t = String(e.value) === String(this._value);
|
|
178
208
|
return `<button type="button" role="option" class="search-select-option${t ? " selected" : ""}" data-value="${m(e.value)}" aria-selected="${t}">${f(e)}</button>`;
|
|
179
209
|
}).join(""), this._active = -1;
|
|
180
|
-
let
|
|
181
|
-
t.hint && (t.hint.hidden = !(this._remote &&
|
|
210
|
+
let s = r.length < this._minChars;
|
|
211
|
+
t.hint && (t.hint.hidden = !(this._remote && s && !i.length)), t.empty && (t.empty.hidden = this._loading || o.length > 0 || this._remote && s);
|
|
182
212
|
}
|
|
183
213
|
_wire() {
|
|
184
214
|
let e = this._refs();
|
|
@@ -193,7 +223,16 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
193
223
|
}, l = () => {
|
|
194
224
|
e.menu.hidden = !0, e.control.setAttribute("aria-expanded", "false"), e.control.classList.remove("open"), r(-1), this._syncInput();
|
|
195
225
|
}, u = (t) => {
|
|
196
|
-
|
|
226
|
+
let n = t.dataset.custom === "true";
|
|
227
|
+
this._value = t.dataset.value, this._label = n ? t.dataset.value : h(t.innerHTML), c(this, this._value), e.input.value = this._label, this.dispatchEvent(new CustomEvent("change", {
|
|
228
|
+
bubbles: !0,
|
|
229
|
+
detail: { isCustom: n }
|
|
230
|
+
})), l(), e.input.focus();
|
|
231
|
+
}, d = (t) => {
|
|
232
|
+
this._value = t, this._label = t, c(this, t), e.input.value = t, this.dispatchEvent(new CustomEvent("change", {
|
|
233
|
+
bubbles: !0,
|
|
234
|
+
detail: { isCustom: !0 }
|
|
235
|
+
})), l();
|
|
197
236
|
};
|
|
198
237
|
e.input.addEventListener("focus", () => s()), e.input.addEventListener("input", () => {
|
|
199
238
|
let t = e.input.value;
|
|
@@ -206,9 +245,21 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
206
245
|
}));
|
|
207
246
|
}, this._debounceMs);
|
|
208
247
|
} else this._renderOptions(t);
|
|
209
|
-
}), e.input.addEventListener("keydown", (
|
|
210
|
-
let
|
|
211
|
-
|
|
248
|
+
}), e.input.addEventListener("keydown", (t) => {
|
|
249
|
+
let i = n();
|
|
250
|
+
if (t.key === "ArrowDown") t.preventDefault(), o() || s(), r(Math.min(this._active + 1, i.length - 1));
|
|
251
|
+
else if (t.key === "ArrowUp") t.preventDefault(), r(Math.max(this._active - 1, 0));
|
|
252
|
+
else if (t.key === "Enter") {
|
|
253
|
+
if (i[this._active]) t.preventDefault(), u(i[this._active]);
|
|
254
|
+
else if (this._allowCustom) {
|
|
255
|
+
let n = e.input.value.trim();
|
|
256
|
+
n && !this._matchesKnownOption(n) && (t.preventDefault(), d(n));
|
|
257
|
+
}
|
|
258
|
+
} else t.key === "Escape" && l();
|
|
259
|
+
}), e.input.addEventListener("blur", (t) => {
|
|
260
|
+
if (!this._allowCustom || t.relatedTarget && this.contains(t.relatedTarget)) return;
|
|
261
|
+
let n = e.input.value.trim();
|
|
262
|
+
!n || n === this._label || this._matchesKnownOption(n) || d(n);
|
|
212
263
|
}), e.optionsWrap.addEventListener("click", (e) => {
|
|
213
264
|
let t = e.target.closest(".search-select-option");
|
|
214
265
|
t && u(t);
|
|
@@ -265,6 +316,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
265
316
|
m: t
|
|
266
317
|
};
|
|
267
318
|
}, w = class extends HTMLElement {
|
|
319
|
+
static formAssociated = !0;
|
|
268
320
|
static get observedAttributes() {
|
|
269
321
|
return [
|
|
270
322
|
"value",
|
|
@@ -273,11 +325,19 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
273
325
|
"placeholder",
|
|
274
326
|
"disabled",
|
|
275
327
|
"first-day",
|
|
276
|
-
"size"
|
|
328
|
+
"size",
|
|
329
|
+
"aria-label",
|
|
330
|
+
"aria-describedby"
|
|
277
331
|
];
|
|
278
332
|
}
|
|
279
333
|
constructor() {
|
|
280
|
-
super()
|
|
334
|
+
super();
|
|
335
|
+
try {
|
|
336
|
+
this._internals = this.attachInternals();
|
|
337
|
+
} catch {
|
|
338
|
+
this._internals = null;
|
|
339
|
+
}
|
|
340
|
+
this._value = "";
|
|
281
341
|
let e = new Date(2e3, 0, 1);
|
|
282
342
|
this._viewY = e.getFullYear(), this._viewM = e.getMonth(), this._mode = "days", this._focus = null, this._slide = "";
|
|
283
343
|
}
|
|
@@ -287,6 +347,9 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
287
347
|
attributeChangedCallback(e, t, n) {
|
|
288
348
|
this._rendered && (e === "value" ? (this._value = n || "", this._syncTrigger()) : e === "first-day" ? this.querySelector(".datepicker-pop")?.hidden || this._renderView() : this.render());
|
|
289
349
|
}
|
|
350
|
+
formResetCallback() {
|
|
351
|
+
this.value = this._defaultValue || "";
|
|
352
|
+
}
|
|
290
353
|
get value() {
|
|
291
354
|
return this._value;
|
|
292
355
|
}
|
|
@@ -298,14 +361,14 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
298
361
|
return Number.isInteger(e) && e >= 0 && e <= 6 ? e : 0;
|
|
299
362
|
}
|
|
300
363
|
render() {
|
|
301
|
-
this._value = this.getAttribute("value") || this._value;
|
|
364
|
+
this._defaultValue === void 0 && (this._defaultValue = this.getAttribute("value") || ""), this._value = this.getAttribute("value") || this._value;
|
|
302
365
|
let e = this.getAttribute("placeholder") || "Enter Date", t = b(this._value);
|
|
303
366
|
t && (this._viewY = t.y, this._viewM = t.m);
|
|
304
|
-
let n = this.getAttribute("size"), r = n === "sm" ? " input-sm" : n === "lg" ? " input-lg" : "";
|
|
367
|
+
let n = this.getAttribute("size"), r = n === "sm" ? " input-sm" : n === "lg" ? " input-lg" : "", i = this.getAttribute("aria-label"), a = this.getAttribute("aria-describedby");
|
|
305
368
|
this.innerHTML = `
|
|
306
369
|
<div class="datepicker">
|
|
307
|
-
<button type="button" class="input datepicker-trigger${r}${t ? " has-value" : ""}" aria-haspopup="dialog" aria-expanded="false"${this.hasAttribute("disabled") ? " disabled" : ""}>
|
|
308
|
-
<span data-trigger-label class="${t ? "" : "search-select-placeholder"}">${t ? x(this._value) : e}</span>
|
|
370
|
+
<button type="button" class="input datepicker-trigger${r}${t ? " has-value" : ""}" aria-haspopup="dialog" aria-expanded="false"${this.hasAttribute("disabled") ? " disabled" : ""}${i ? ` aria-label="${u(i)}"` : ""}${a ? ` aria-describedby="${u(a)}"` : ""}>
|
|
371
|
+
<span data-trigger-label class="${t ? "" : "search-select-placeholder"}">${t ? x(this._value) : u(e)}</span>
|
|
309
372
|
<i class="bi bi-calendar3" aria-hidden="true"></i>
|
|
310
373
|
</button>
|
|
311
374
|
<div class="datepicker-pop" role="dialog" aria-modal="false" hidden></div>
|
|
@@ -466,6 +529,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
466
529
|
}
|
|
467
530
|
}
|
|
468
531
|
_wire() {
|
|
532
|
+
this._teardown();
|
|
469
533
|
let e = this.querySelector(".datepicker-trigger"), t = this.querySelector(".datepicker-pop"), n = this.querySelector(".datepicker");
|
|
470
534
|
if (!e || !t) return;
|
|
471
535
|
let r = () => !t.hidden;
|
|
@@ -544,9 +608,12 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
544
608
|
r() && this._position(e, t);
|
|
545
609
|
}), this._syncFormValue();
|
|
546
610
|
}
|
|
547
|
-
|
|
611
|
+
_teardown() {
|
|
548
612
|
this._onDocClick && document.removeEventListener("click", this._onDocClick), o(this);
|
|
549
613
|
}
|
|
614
|
+
disconnectedCallback() {
|
|
615
|
+
this._teardown();
|
|
616
|
+
}
|
|
550
617
|
}, T = [
|
|
551
618
|
"January",
|
|
552
619
|
"February",
|
|
@@ -586,6 +653,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
586
653
|
m: t
|
|
587
654
|
};
|
|
588
655
|
}, M = class extends HTMLElement {
|
|
656
|
+
static formAssociated = !0;
|
|
589
657
|
static get observedAttributes() {
|
|
590
658
|
return [
|
|
591
659
|
"start",
|
|
@@ -595,11 +663,22 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
595
663
|
"placeholder",
|
|
596
664
|
"disabled",
|
|
597
665
|
"first-day",
|
|
598
|
-
"size"
|
|
666
|
+
"size",
|
|
667
|
+
"aria-label",
|
|
668
|
+
"aria-describedby",
|
|
669
|
+
"name",
|
|
670
|
+
"start-name",
|
|
671
|
+
"end-name"
|
|
599
672
|
];
|
|
600
673
|
}
|
|
601
674
|
constructor() {
|
|
602
|
-
super()
|
|
675
|
+
super();
|
|
676
|
+
try {
|
|
677
|
+
this._internals = this.attachInternals();
|
|
678
|
+
} catch {
|
|
679
|
+
this._internals = null;
|
|
680
|
+
}
|
|
681
|
+
this._start = "", this._end = "", this._hover = "";
|
|
603
682
|
let e = new Date(2e3, 0, 1);
|
|
604
683
|
this._viewY = e.getFullYear(), this._viewM = e.getMonth();
|
|
605
684
|
}
|
|
@@ -633,19 +712,25 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
633
712
|
};
|
|
634
713
|
}
|
|
635
714
|
render() {
|
|
636
|
-
this._start = this.getAttribute("start") || this._start, this._end = this.getAttribute("end") || this._end;
|
|
715
|
+
this._defaultStart === void 0 && (this._defaultStart = this.getAttribute("start") || "", this._defaultEnd = this.getAttribute("end") || ""), this._start = this.getAttribute("start") || this._start, this._end = this.getAttribute("end") || this._end;
|
|
637
716
|
let e = O(this._start);
|
|
638
717
|
e && (this._viewY = e.y, this._viewM = e.m);
|
|
639
|
-
let t = this.getAttribute("size"), n = t === "sm" ? " input-sm" : t === "lg" ? " input-lg" : "", { text: r, empty: i } = this._label();
|
|
718
|
+
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");
|
|
640
719
|
this.innerHTML = `
|
|
641
720
|
<div class="daterange">
|
|
642
|
-
<button type="button" class="input daterange-trigger${n}${i ? "" : " has-value"}" aria-haspopup="dialog" aria-expanded="false"${this.hasAttribute("disabled") ? " disabled" : ""}>
|
|
643
|
-
<span data-range-label class="${i ? "search-select-placeholder" : ""}">${r}</span>
|
|
721
|
+
<button type="button" class="input daterange-trigger${n}${i ? "" : " has-value"}" aria-haspopup="dialog" aria-expanded="false"${this.hasAttribute("disabled") ? " disabled" : ""}${a ? ` aria-label="${u(a)}"` : ""}${o ? ` aria-describedby="${u(o)}"` : ""}>
|
|
722
|
+
<span data-range-label class="${i ? "search-select-placeholder" : ""}">${u(r)}</span>
|
|
644
723
|
<i class="bi bi-calendar-range" aria-hidden="true"></i>
|
|
645
724
|
</button>
|
|
646
725
|
<div class="daterange-pop" role="dialog" aria-modal="false" hidden></div>
|
|
647
726
|
</div>`, this._rendered = !0, this._syncMirrors(), this._wire();
|
|
648
727
|
}
|
|
728
|
+
formResetCallback() {
|
|
729
|
+
this.value = {
|
|
730
|
+
start: this._defaultStart || "",
|
|
731
|
+
end: this._defaultEnd || ""
|
|
732
|
+
};
|
|
733
|
+
}
|
|
649
734
|
_syncTrigger() {
|
|
650
735
|
let e = this.querySelector(".daterange-trigger"), t = this.querySelector("[data-range-label]");
|
|
651
736
|
if (!t) return;
|
|
@@ -659,7 +744,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
659
744
|
_mirror(e, t, n) {
|
|
660
745
|
if (!t) return;
|
|
661
746
|
let r = this.querySelector(`input[type="hidden"][data-range-mirror="${e}"]`);
|
|
662
|
-
r || (r = document.createElement("input"), r.type = "hidden", r.setAttribute("data-range-mirror", e), this.appendChild(r)), r.name = t, r.value = n || "";
|
|
747
|
+
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");
|
|
663
748
|
}
|
|
664
749
|
_limits() {
|
|
665
750
|
let e = O(this.getAttribute("min")), t = O(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;
|
|
@@ -724,12 +809,13 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
724
809
|
return;
|
|
725
810
|
}
|
|
726
811
|
if (new Date(e).getTime() < new Date(this._start).getTime()) {
|
|
727
|
-
this._start = e, this._paint();
|
|
812
|
+
this._start = e, this._syncTrigger(), this._syncMirrors(), this._paint();
|
|
728
813
|
return;
|
|
729
814
|
}
|
|
730
815
|
this._end = e, this._syncTrigger(), this._syncMirrors(), this._paint(), this.dispatchEvent(new Event("change", { bubbles: !0 })), this._close();
|
|
731
816
|
}
|
|
732
817
|
_wire() {
|
|
818
|
+
this._teardown();
|
|
733
819
|
let e = this.querySelector(".daterange-trigger"), t = this.querySelector(".daterange-pop"), n = this.querySelector(".daterange");
|
|
734
820
|
if (!e || !t) return;
|
|
735
821
|
let r = () => !t.hidden;
|
|
@@ -769,10 +855,14 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
769
855
|
r() && this._position(e, t);
|
|
770
856
|
}), this._syncMirrors();
|
|
771
857
|
}
|
|
772
|
-
|
|
858
|
+
_teardown() {
|
|
773
859
|
this._onDocClick && document.removeEventListener("click", this._onDocClick), this._onDocKey && document.removeEventListener("keydown", this._onDocKey), o(this);
|
|
774
860
|
}
|
|
861
|
+
disconnectedCallback() {
|
|
862
|
+
this._teardown();
|
|
863
|
+
}
|
|
775
864
|
}, N = class extends HTMLElement {
|
|
865
|
+
static formAssociated = !0;
|
|
776
866
|
_accessibleName() {
|
|
777
867
|
return this.getAttribute("aria-label") || this.getAttribute("placeholder") || "Select";
|
|
778
868
|
}
|
|
@@ -790,6 +880,11 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
790
880
|
}
|
|
791
881
|
constructor() {
|
|
792
882
|
super(), this._values = [], this._optionsProp = null, this._active = -1;
|
|
883
|
+
try {
|
|
884
|
+
this._internals = this.attachInternals();
|
|
885
|
+
} catch {
|
|
886
|
+
this._internals = null;
|
|
887
|
+
}
|
|
793
888
|
}
|
|
794
889
|
connectedCallback() {
|
|
795
890
|
if (!this._rendered) {
|
|
@@ -797,9 +892,12 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
797
892
|
let e = [...this.querySelectorAll(":scope > wui-option[selected]")].map((e) => e.getAttribute("value") ?? e.textContent.trim());
|
|
798
893
|
e.length && (this._values = e.map(String));
|
|
799
894
|
}
|
|
800
|
-
this._valuesInit = !0, this.render();
|
|
895
|
+
this._valuesInit = !0, this._defaultCaptured ||= (this._defaultValues = this._values.slice(), !0), this.render();
|
|
801
896
|
}
|
|
802
897
|
}
|
|
898
|
+
formResetCallback() {
|
|
899
|
+
this.values = (this._defaultValues || []).slice();
|
|
900
|
+
}
|
|
803
901
|
attributeChangedCallback() {
|
|
804
902
|
this._rendered && this.render();
|
|
805
903
|
}
|
|
@@ -842,7 +940,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
842
940
|
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" : "";
|
|
843
941
|
c(this, this._values.join(",")), this.innerHTML = `
|
|
844
942
|
<div class="search-select${i}">
|
|
845
|
-
<div class="input search-select-control search-select-multi" role="combobox" aria-haspopup="listbox" aria-expanded="false" aria-label="${P(this._accessibleName())}"${this.hasAttribute("disabled") ? " aria-disabled=\"true\"" : ""}>
|
|
943
|
+
<div class="input search-select-control search-select-multi" role="combobox" aria-haspopup="listbox" aria-expanded="false" aria-label="${P(this._accessibleName())}"${this.hasAttribute("disabled") ? " aria-disabled=\"true\"" : " tabindex=\"0\""}>
|
|
846
944
|
${n ? `<i class="bi bi-${P(n)} search-select-icon" aria-hidden="true"></i>` : ""}
|
|
847
945
|
<div class="ms-chips" data-chips></div>
|
|
848
946
|
<i class="bi bi-chevron-down search-select-caret" aria-hidden="true"></i>
|
|
@@ -892,6 +990,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
892
990
|
}).join(""), n && (n.hidden = i.length > 0), this._active = -1;
|
|
893
991
|
}
|
|
894
992
|
_wire() {
|
|
993
|
+
this._teardown();
|
|
895
994
|
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");
|
|
896
995
|
if (!e || !t) return;
|
|
897
996
|
let s = () => this.hasAttribute("disabled");
|
|
@@ -914,6 +1013,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
914
1013
|
this._values = this._values.filter((t) => t !== String(e)), this._renderControl(), this._renderOptions(n ? n.value : ""), g();
|
|
915
1014
|
};
|
|
916
1015
|
e.addEventListener("click", (e) => {
|
|
1016
|
+
if (s()) return;
|
|
917
1017
|
let t = e.target.closest("[data-remove]");
|
|
918
1018
|
if (t) {
|
|
919
1019
|
e.stopPropagation(), v(t.dataset.remove);
|
|
@@ -947,8 +1047,11 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
947
1047
|
p() && l();
|
|
948
1048
|
});
|
|
949
1049
|
}
|
|
1050
|
+
_teardown() {
|
|
1051
|
+
this._onDocClick && document.removeEventListener("click", this._onDocClick), o(this);
|
|
1052
|
+
}
|
|
950
1053
|
disconnectedCallback() {
|
|
951
|
-
this.
|
|
1054
|
+
this._teardown(), this._ro?.disconnect(), this._ro = null;
|
|
952
1055
|
}
|
|
953
1056
|
}, P = (e) => String(e ?? "").replace(/"/g, """).replace(/</g, "<"), te = (e) => String(e ?? "").replace(/<[^>]*>/g, ""), ne = /[^0-9]/g, re = /[^0-9a-zA-Z]/g, F = class extends HTMLElement {
|
|
954
1057
|
static get observedAttributes() {
|
|
@@ -2333,23 +2436,40 @@ function W(e) {
|
|
|
2333
2436
|
}
|
|
2334
2437
|
}
|
|
2335
2438
|
var G = class extends HTMLElement {
|
|
2439
|
+
static formAssociated = !0;
|
|
2336
2440
|
static get observedAttributes() {
|
|
2337
2441
|
return [
|
|
2338
2442
|
"value",
|
|
2339
2443
|
"country",
|
|
2340
2444
|
"placeholder",
|
|
2341
|
-
"disabled"
|
|
2445
|
+
"disabled",
|
|
2446
|
+
"required",
|
|
2447
|
+
"aria-label",
|
|
2448
|
+
"aria-describedby"
|
|
2342
2449
|
];
|
|
2343
2450
|
}
|
|
2344
2451
|
constructor() {
|
|
2345
|
-
super()
|
|
2452
|
+
super();
|
|
2453
|
+
try {
|
|
2454
|
+
this._internals = this.attachInternals();
|
|
2455
|
+
} catch {
|
|
2456
|
+
this._internals = null;
|
|
2457
|
+
}
|
|
2458
|
+
this._country = "IN", this._national = "";
|
|
2346
2459
|
}
|
|
2347
2460
|
connectedCallback() {
|
|
2348
2461
|
this._rendered || this.render();
|
|
2349
2462
|
}
|
|
2350
2463
|
attributeChangedCallback(e, t, n) {
|
|
2464
|
+
if (e === "value") {
|
|
2465
|
+
this.value = n;
|
|
2466
|
+
return;
|
|
2467
|
+
}
|
|
2351
2468
|
this._rendered && (e === "country" && (this._country = n || "IN"), this.render());
|
|
2352
2469
|
}
|
|
2470
|
+
formResetCallback() {
|
|
2471
|
+
this.value = this._defaultValue || "";
|
|
2472
|
+
}
|
|
2353
2473
|
get value() {
|
|
2354
2474
|
return `+${L(this._country)}${this._national}`;
|
|
2355
2475
|
}
|
|
@@ -2366,6 +2486,7 @@ var G = class extends HTMLElement {
|
|
|
2366
2486
|
c(this, this.value), this.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
2367
2487
|
}
|
|
2368
2488
|
render() {
|
|
2489
|
+
this._defaultValue === void 0 && (this._defaultValue = this.getAttribute("value") || "");
|
|
2369
2490
|
let e = this.getAttribute("placeholder") || H(this._country) || "Enter phone number";
|
|
2370
2491
|
this._country = this.getAttribute("country") || this._country;
|
|
2371
2492
|
let t = I.map(([e, t, n]) => `<button type="button" role="option" class="country-dropdown-item${e === this._country ? " selected" : ""}" data-iso="${e}"><span class="${R(e)}" aria-hidden="true"></span><span class="country-name-text">${t}<span class="country-code-text">+${n}</span></span></button>`).join("");
|
|
@@ -2382,11 +2503,12 @@ var G = class extends HTMLElement {
|
|
|
2382
2503
|
<div class="country-list-scroll">${t}<div class="country-empty" hidden>No countries found</div></div>
|
|
2383
2504
|
</div>
|
|
2384
2505
|
</div>
|
|
2385
|
-
<input type="tel" class="input" placeholder="${K(e)}" value="${K(V(this._country, this._national))}"${this.hasAttribute("disabled") ? " disabled" : ""} />
|
|
2506
|
+
<input type="tel" class="input" placeholder="${K(e)}" value="${K(V(this._country, this._national))}"${this.getAttribute("aria-label") ? ` aria-label="${K(this.getAttribute("aria-label"))}"` : ""}${this.getAttribute("aria-describedby") ? ` aria-describedby="${K(this.getAttribute("aria-describedby"))}"` : ""}${this.hasAttribute("required") ? " required aria-required=\"true\"" : ""}${this.hasAttribute("disabled") ? " disabled" : ""} />
|
|
2386
2507
|
</div>
|
|
2387
2508
|
<div class="field-error" data-phone-error hidden></div>`, this._rendered = !0, c(this, this.value), this._wire();
|
|
2388
2509
|
}
|
|
2389
2510
|
_wire() {
|
|
2511
|
+
this._teardown();
|
|
2390
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]"), l = this.querySelector("[data-dial]");
|
|
2391
2513
|
if (!e || !n) return;
|
|
2392
2514
|
let u = () => !n.hidden, d = () => {
|
|
@@ -2444,10 +2566,14 @@ var G = class extends HTMLElement {
|
|
|
2444
2566
|
}
|
|
2445
2567
|
}), c(this, this.value);
|
|
2446
2568
|
}
|
|
2447
|
-
|
|
2569
|
+
_teardown() {
|
|
2448
2570
|
this._reposition && (window.removeEventListener("scroll", this._reposition, !0), window.removeEventListener("resize", this._reposition)), this._onDocClick && document.removeEventListener("click", this._onDocClick);
|
|
2449
2571
|
}
|
|
2572
|
+
disconnectedCallback() {
|
|
2573
|
+
this._teardown();
|
|
2574
|
+
}
|
|
2450
2575
|
}, K = (e) => String(e ?? "").replace(/"/g, """).replace(/</g, "<"), q = class extends HTMLElement {
|
|
2576
|
+
static formAssociated = !0;
|
|
2451
2577
|
static get observedAttributes() {
|
|
2452
2578
|
return [
|
|
2453
2579
|
"value",
|
|
@@ -2467,7 +2593,13 @@ var G = class extends HTMLElement {
|
|
|
2467
2593
|
return this.getAttribute("aria-label") || this.getAttribute("placeholder") || "Select";
|
|
2468
2594
|
}
|
|
2469
2595
|
constructor() {
|
|
2470
|
-
super()
|
|
2596
|
+
super();
|
|
2597
|
+
try {
|
|
2598
|
+
this._internals = this.attachInternals();
|
|
2599
|
+
} catch {
|
|
2600
|
+
this._internals = null;
|
|
2601
|
+
}
|
|
2602
|
+
this._value = "", this._optionsProp = null, this._active = -1;
|
|
2471
2603
|
}
|
|
2472
2604
|
connectedCallback() {
|
|
2473
2605
|
this._rendered || this.render();
|
|
@@ -2479,6 +2611,9 @@ var G = class extends HTMLElement {
|
|
|
2479
2611
|
}
|
|
2480
2612
|
this._rendered && this.render();
|
|
2481
2613
|
}
|
|
2614
|
+
formResetCallback() {
|
|
2615
|
+
this.value = this._defaultValue || "";
|
|
2616
|
+
}
|
|
2482
2617
|
get value() {
|
|
2483
2618
|
return this._value;
|
|
2484
2619
|
}
|
|
@@ -2506,7 +2641,7 @@ var G = class extends HTMLElement {
|
|
|
2506
2641
|
return this._optionsProp ? this._optionsProp : (this._snapshotDeclared(), this._declared || []);
|
|
2507
2642
|
}
|
|
2508
2643
|
render() {
|
|
2509
|
-
this._snapshotDeclared();
|
|
2644
|
+
this._defaultValue === void 0 && (this._defaultValue = this.getAttribute("value") || ""), this._snapshotDeclared();
|
|
2510
2645
|
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);
|
|
2511
2646
|
d && (this._value = String(d.value)), c(this, this._value);
|
|
2512
2647
|
let p = e.map((e) => {
|
|
@@ -2559,6 +2694,7 @@ var G = class extends HTMLElement {
|
|
|
2559
2694
|
e && (e.hidden = !(this.hasAttribute("clearable") && this._value !== "" && !this.hasAttribute("disabled")));
|
|
2560
2695
|
}
|
|
2561
2696
|
_wire() {
|
|
2697
|
+
this._teardown();
|
|
2562
2698
|
let e = this._refs();
|
|
2563
2699
|
if (!e.control || !e.menu) return;
|
|
2564
2700
|
let t = () => {
|
|
@@ -2612,9 +2748,12 @@ var G = class extends HTMLElement {
|
|
|
2612
2748
|
o() && t();
|
|
2613
2749
|
});
|
|
2614
2750
|
}
|
|
2615
|
-
|
|
2751
|
+
_teardown() {
|
|
2616
2752
|
this._onDocClick && document.removeEventListener("click", this._onDocClick), o(this);
|
|
2617
2753
|
}
|
|
2754
|
+
disconnectedCallback() {
|
|
2755
|
+
this._teardown();
|
|
2756
|
+
}
|
|
2618
2757
|
}, J = (e) => String(e ?? "").replace(/"/g, """).replace(/</g, "<"), Y = "image/png,image/jpeg,image/webp", oe = 5, se = {
|
|
2619
2758
|
"image/png": [".png"],
|
|
2620
2759
|
"image/jpeg": [".jpg", ".jpeg"],
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webority/ui-elements",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.3",
|
|
4
4
|
"description": "Webority framework-agnostic UI custom elements (<wui-*>) — the single implementation of the interactive components, styled by @webority/theme. Used natively in Razor and wrapped by @webority/ui-react.",
|
|
5
5
|
"license": "SEE LICENSE IN LICENSE",
|
|
6
6
|
"type": "module",
|