@webority/ui-elements 0.7.8 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ui-elements.global.js +61 -61
- package/dist/ui-elements.js +544 -338
- package/package.json +1 -1
package/dist/ui-elements.js
CHANGED
|
@@ -48,16 +48,47 @@ function c(e, t) {
|
|
|
48
48
|
r.disabled = e.hasAttribute("disabled");
|
|
49
49
|
}
|
|
50
50
|
//#endregion
|
|
51
|
+
//#region src/listboxKeyNav.js
|
|
52
|
+
function l(e) {
|
|
53
|
+
let { getVisibleOptions: t, getActive: n, setActive: r, onEnter: i, onEscape: a, onTypeahead: o, typeaheadMs: s = 500 } = e, c = "", l = null, u = () => {
|
|
54
|
+
clearTimeout(l), l = null, c = "";
|
|
55
|
+
};
|
|
56
|
+
return {
|
|
57
|
+
handler: (e) => {
|
|
58
|
+
let d = t(), f = n(), p = e.target?.tagName === "INPUT" || e.target?.tagName === "TEXTAREA";
|
|
59
|
+
if (e.key === "ArrowDown") e.preventDefault(), r(Math.min(f + 1, d.length - 1));
|
|
60
|
+
else if (e.key === "ArrowUp") e.preventDefault(), r(Math.max(f - 1, 0));
|
|
61
|
+
else if (e.key === "Home" && !p) e.preventDefault(), d.length && r(0);
|
|
62
|
+
else if (e.key === "End" && !p) e.preventDefault(), d.length && r(d.length - 1);
|
|
63
|
+
else if (e.key === "PageDown" && !p) {
|
|
64
|
+
if (e.preventDefault(), !d.length) return;
|
|
65
|
+
r(Math.min((f < 0 ? 0 : f) + 8, d.length - 1));
|
|
66
|
+
} else if (e.key === "PageUp" && !p) {
|
|
67
|
+
if (e.preventDefault(), !d.length) return;
|
|
68
|
+
r(Math.max((f < 0 ? 0 : f) - 8, 0));
|
|
69
|
+
} else if (e.key === "Enter") i && (e.preventDefault(), i(d[f], d));
|
|
70
|
+
else if (e.key === "Escape") a && a();
|
|
71
|
+
else if (e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey && e.target?.tagName !== "INPUT" && e.target?.tagName !== "TEXTAREA") {
|
|
72
|
+
e.preventDefault(), clearTimeout(l), c += e.key.toLowerCase(), l = setTimeout(u, s);
|
|
73
|
+
let t = d.findIndex((e) => e.textContent.trim().toLowerCase().startsWith(c));
|
|
74
|
+
t >= 0 && (r(t), o && o(e.key, t, d));
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
clearTypeahead: u,
|
|
78
|
+
teardown: u
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
//#endregion
|
|
51
82
|
//#region src/optionLabel.js
|
|
52
|
-
var
|
|
83
|
+
var u = Symbol("wui.trustedHtml"), d = (e) => String(e ?? "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'"), f = (e) => {
|
|
53
84
|
if (!e) return "";
|
|
54
85
|
let t = String(e).toLowerCase().replace(/[^a-z0-9-]/g, "");
|
|
55
86
|
return t ? `<i class="bi bi-${t}" aria-hidden="true"></i>` : "";
|
|
56
|
-
},
|
|
87
|
+
}, p = (e) => {
|
|
57
88
|
if (e == null) return "";
|
|
58
|
-
let t = e[
|
|
89
|
+
let t = e[u] ? String(e.label ?? "") : d(e.label), n = f(e.icon);
|
|
59
90
|
return n ? `<span class="wui-opt-label">${n}${t}</span>` : t;
|
|
60
|
-
},
|
|
91
|
+
}, m = class extends HTMLElement {
|
|
61
92
|
static formAssociated = !0;
|
|
62
93
|
_accessibleName() {
|
|
63
94
|
return this.getAttribute("aria-label") || this.getAttribute("placeholder") || "Select";
|
|
@@ -109,12 +140,12 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
109
140
|
set value(e) {
|
|
110
141
|
this._value = e == null ? "" : String(e), c(this, this._value);
|
|
111
142
|
let t = this._readOptions().find((e) => String(e.value) === this._value);
|
|
112
|
-
this._label = t ?
|
|
143
|
+
this._label = t ? g(t.label) : "", this._syncInput(), this._renderOptions("");
|
|
113
144
|
}
|
|
114
145
|
set options(e) {
|
|
115
146
|
this._optionsProp = Array.isArray(e) ? e : [];
|
|
116
147
|
let t = this._readOptions().find((e) => String(e.value) === this._value);
|
|
117
|
-
t && (this._label =
|
|
148
|
+
t && (this._label = g(t.label)), this._renderOptions(), this._syncInput();
|
|
118
149
|
}
|
|
119
150
|
get options() {
|
|
120
151
|
return this._readOptions();
|
|
@@ -133,7 +164,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
133
164
|
}
|
|
134
165
|
_matchesKnownOption(e) {
|
|
135
166
|
let t = e.toLowerCase();
|
|
136
|
-
return this._readOptions().some((e) =>
|
|
167
|
+
return this._readOptions().some((e) => g(e.label).toLowerCase() === t || String(e.value ?? "").toLowerCase() === t);
|
|
137
168
|
}
|
|
138
169
|
get _minChars() {
|
|
139
170
|
return Math.max(0, Number(this.getAttribute("min-chars")) || +!!this._remote);
|
|
@@ -151,7 +182,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
151
182
|
value: e.getAttribute("value") ?? e.textContent.trim(),
|
|
152
183
|
label: e.innerHTML,
|
|
153
184
|
icon: e.getAttribute("icon") || void 0,
|
|
154
|
-
[
|
|
185
|
+
[u]: !0,
|
|
155
186
|
selected: e.hasAttribute("selected")
|
|
156
187
|
})));
|
|
157
188
|
}
|
|
@@ -165,12 +196,12 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
165
196
|
let r = `${this.id}-listbox`;
|
|
166
197
|
this._listboxId = r, this.innerHTML = `
|
|
167
198
|
<div class="search-select${n}">
|
|
168
|
-
<div class="input search-select-control search-select-ac" role="combobox" aria-haspopup="listbox" aria-expanded="false" aria-controls="${
|
|
169
|
-
<input class="search-select-input search-select-ac-input" placeholder="${
|
|
199
|
+
<div class="input search-select-control search-select-ac" role="combobox" aria-haspopup="listbox" aria-expanded="false" aria-controls="${h(r)}" aria-label="${h(this._accessibleName())}">
|
|
200
|
+
<input class="search-select-input search-select-ac-input" placeholder="${h(e)}" aria-autocomplete="list" autocomplete="off"${this.hasAttribute("disabled") ? " disabled" : ""} />
|
|
170
201
|
<span class="search-select-spinner spinner-border spinner-border-sm" role="status" aria-hidden="true" hidden></span>
|
|
171
202
|
<button type="button" class="search-select-clear" aria-label="Clear" hidden><i class="bi bi-x" aria-hidden="true"></i></button>
|
|
172
203
|
</div>
|
|
173
|
-
<div class="search-select-menu search-select-menu-fixed" role="listbox" id="${
|
|
204
|
+
<div class="search-select-menu search-select-menu-fixed" role="listbox" id="${h(r)}" tabindex="-1" hidden>
|
|
174
205
|
<div class="search-select-options"></div>
|
|
175
206
|
<div class="search-select-empty" hidden>No matches</div>
|
|
176
207
|
<div class="search-select-hint" hidden>Type to search…</div>
|
|
@@ -204,7 +235,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
204
235
|
let t = this._refs();
|
|
205
236
|
if (!t.optionsWrap) return;
|
|
206
237
|
let n = e ?? (t.input ? t.input.value : ""), r = n.trim().toLowerCase(), i = this._readOptions();
|
|
207
|
-
!this._remote && r && (i = i.filter((e) =>
|
|
238
|
+
!this._remote && r && (i = i.filter((e) => g(e.label).toLowerCase().includes(r)));
|
|
208
239
|
let a = n.trim(), o = this._allowCustom && a && !this._matchesKnownOption(a) ? [...i, {
|
|
209
240
|
value: a,
|
|
210
241
|
custom: !0
|
|
@@ -212,11 +243,11 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
212
243
|
t.optionsWrap.innerHTML = o.map((e, t) => {
|
|
213
244
|
let n = `${s}-opt-${t}`;
|
|
214
245
|
if (e.custom) {
|
|
215
|
-
let t = `Add “${
|
|
216
|
-
return `<button type="button" role="option" id="${
|
|
246
|
+
let t = `Add “${d(e.value)}”`;
|
|
247
|
+
return `<button type="button" role="option" id="${h(n)}" class="search-select-option search-select-option-custom" data-value="${h(e.value)}" data-custom="true" aria-selected="false">${t}</button>`;
|
|
217
248
|
}
|
|
218
249
|
let r = String(e.value) === String(this._value);
|
|
219
|
-
return `<button type="button" role="option" id="${
|
|
250
|
+
return `<button type="button" role="option" id="${h(n)}" class="search-select-option${r ? " selected" : ""}" data-value="${h(e.value)}" aria-selected="${r}">${p(e)}</button>`;
|
|
220
251
|
}).join(""), this._active = -1, t.control?.removeAttribute("aria-activedescendant");
|
|
221
252
|
let c = r.length < this._minChars;
|
|
222
253
|
t.hint && (t.hint.hidden = !(this._remote && c && !i.length)), t.empty && (t.empty.hidden = this._loading || o.length > 0 || this._remote && c);
|
|
@@ -232,20 +263,20 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
232
263
|
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");
|
|
233
264
|
}, o = () => !e.menu.hidden, s = () => {
|
|
234
265
|
e.menu.hidden = !1, e.control.setAttribute("aria-expanded", "true"), e.control.classList.add("open"), t(), this._renderOptions();
|
|
235
|
-
},
|
|
266
|
+
}, u = () => {
|
|
236
267
|
e.menu.hidden = !0, e.control.setAttribute("aria-expanded", "false"), e.control.classList.remove("open"), r(-1), clearTimeout(this._typeaheadTimer), this._typeaheadTimer = null, this._typeahead = "", this._syncInput();
|
|
237
|
-
},
|
|
268
|
+
}, d = (t) => {
|
|
238
269
|
let n = t.dataset.custom === "true";
|
|
239
|
-
this._value = t.dataset.value, this._label = n ? t.dataset.value :
|
|
270
|
+
this._value = t.dataset.value, this._label = n ? t.dataset.value : g(t.innerHTML), c(this, this._value), e.input.value = this._label, this.dispatchEvent(new CustomEvent("change", {
|
|
240
271
|
bubbles: !0,
|
|
241
272
|
detail: { isCustom: n }
|
|
242
|
-
})),
|
|
243
|
-
},
|
|
273
|
+
})), u(), e.input.focus();
|
|
274
|
+
}, f = (t) => {
|
|
244
275
|
this._value = t, this._label = t, c(this, t), e.input.value = t, this.dispatchEvent(new CustomEvent("change", {
|
|
245
276
|
bubbles: !0,
|
|
246
277
|
detail: { isCustom: !0 }
|
|
247
|
-
})),
|
|
248
|
-
},
|
|
278
|
+
})), u();
|
|
279
|
+
}, p = () => {
|
|
249
280
|
let t = e.input.value;
|
|
250
281
|
if (e.clear && (e.clear.hidden = !t), o() || s(), this._remote) {
|
|
251
282
|
if (this._renderOptions(t), clearTimeout(this._timer), t.trim().length < this._minChars) {
|
|
@@ -258,42 +289,43 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
258
289
|
seq: e
|
|
259
290
|
}, this._timer = setTimeout(() => this._fireSearch(t, e), this._debounceMs);
|
|
260
291
|
} else this._renderOptions(t);
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
else if (t.key === "End" && o() && !a) t.preventDefault(), i.length && r(i.length - 1);
|
|
269
|
-
else if (t.key === "PageDown" && o() && !a) {
|
|
270
|
-
if (t.preventDefault(), !i.length) return;
|
|
271
|
-
let e = this._active < 0 ? 0 : this._active;
|
|
272
|
-
r(Math.min(e + 8, i.length - 1));
|
|
273
|
-
} else if (t.key === "PageUp" && o() && !a) {
|
|
274
|
-
if (t.preventDefault(), !i.length) return;
|
|
275
|
-
let e = this._active < 0 ? 0 : this._active;
|
|
276
|
-
r(Math.max(e - 8, 0));
|
|
277
|
-
} else if (t.key === "Enter") {
|
|
278
|
-
if (i[this._active]) t.preventDefault(), u(i[this._active]);
|
|
292
|
+
};
|
|
293
|
+
this._navHandler = l({
|
|
294
|
+
getVisibleOptions: n,
|
|
295
|
+
getActive: () => this._active,
|
|
296
|
+
setActive: (e) => r(e),
|
|
297
|
+
onEnter: (t, n) => {
|
|
298
|
+
if (n[this._active]) d(n[this._active]);
|
|
279
299
|
else if (this._allowCustom) {
|
|
280
|
-
let
|
|
281
|
-
|
|
300
|
+
let t = e.input.value.trim();
|
|
301
|
+
t && !this._matchesKnownOption(t) && f(t);
|
|
282
302
|
}
|
|
283
|
-
}
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
let e = i.findIndex((e) => e.textContent.trim().toLowerCase().startsWith(this._typeahead));
|
|
287
|
-
e >= 0 && r(e);
|
|
303
|
+
},
|
|
304
|
+
onEscape: () => {
|
|
305
|
+
this._navHandler.clearTypeahead(), u();
|
|
288
306
|
}
|
|
307
|
+
});
|
|
308
|
+
let m = (e) => {
|
|
309
|
+
let t = e.target?.tagName === "INPUT" || e.target?.tagName === "TEXTAREA";
|
|
310
|
+
if (e.key === "ArrowDown") {
|
|
311
|
+
e.preventDefault(), o() || s();
|
|
312
|
+
let t = n();
|
|
313
|
+
r(Math.min(this._active + 1, t.length - 1));
|
|
314
|
+
return;
|
|
315
|
+
} else if (e.key === "ArrowUp") {
|
|
316
|
+
e.preventDefault(), r(Math.max(this._active - 1, 0));
|
|
317
|
+
return;
|
|
318
|
+
} else if ((e.key === "Home" || e.key === "End" || e.key === "PageDown" || e.key === "PageUp") && (!o() || t)) return;
|
|
319
|
+
else if (e.key.length === 1 && (e.ctrlKey || e.metaKey || e.altKey || !o() || e.target?.tagName === "INPUT" || e.target?.tagName === "TEXTAREA") && (!o() || e.target?.tagName === "INPUT" || e.target?.tagName === "TEXTAREA")) return;
|
|
320
|
+
this._navHandler.handler(e);
|
|
289
321
|
};
|
|
290
|
-
e.input.addEventListener("focus", () => s()), e.input.addEventListener("input",
|
|
322
|
+
e.input.addEventListener("focus", () => s()), e.input.addEventListener("input", p), e.input.addEventListener("keydown", m), e.menu.addEventListener("keydown", m), e.input.addEventListener("blur", (t) => {
|
|
291
323
|
if (!this._allowCustom || t.relatedTarget && this.contains(t.relatedTarget)) return;
|
|
292
324
|
let n = e.input.value.trim();
|
|
293
|
-
!n || n === this._label || this._matchesKnownOption(n) ||
|
|
325
|
+
!n || n === this._label || this._matchesKnownOption(n) || f(n);
|
|
294
326
|
}), e.optionsWrap.addEventListener("click", (e) => {
|
|
295
327
|
let t = e.target.closest(".search-select-option");
|
|
296
|
-
t &&
|
|
328
|
+
t && d(t);
|
|
297
329
|
}), e.optionsWrap.addEventListener("mousemove", (e) => {
|
|
298
330
|
let t = e.target.closest(".search-select-option");
|
|
299
331
|
t && r(this._optionEls().indexOf(t));
|
|
@@ -301,7 +333,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
301
333
|
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();
|
|
302
334
|
}), this._bindGlobal = () => {
|
|
303
335
|
this._teardown(), this._onDocClick = (e) => {
|
|
304
|
-
o() && !this.contains(e.target) &&
|
|
336
|
+
o() && !this.contains(e.target) && u();
|
|
305
337
|
}, document.addEventListener("click", this._onDocClick), a(this, () => {
|
|
306
338
|
o() && t();
|
|
307
339
|
});
|
|
@@ -317,12 +349,12 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
317
349
|
}));
|
|
318
350
|
}
|
|
319
351
|
_teardown() {
|
|
320
|
-
this._onDocClick &&= (document.removeEventListener("click", this._onDocClick), null), o(this), clearTimeout(this._timer),
|
|
352
|
+
this._onDocClick &&= (document.removeEventListener("click", this._onDocClick), null), o(this), clearTimeout(this._timer), this._navHandler?.teardown();
|
|
321
353
|
}
|
|
322
354
|
disconnectedCallback() {
|
|
323
355
|
this._teardown();
|
|
324
356
|
}
|
|
325
|
-
},
|
|
357
|
+
}, h = (e) => String(e ?? "").replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<"), g = (e) => String(e ?? "").replace(/<[^>]*>/g, ""), _ = [
|
|
326
358
|
"January",
|
|
327
359
|
"February",
|
|
328
360
|
"March",
|
|
@@ -335,7 +367,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
335
367
|
"October",
|
|
336
368
|
"November",
|
|
337
369
|
"December"
|
|
338
|
-
],
|
|
370
|
+
], v = [
|
|
339
371
|
"Su",
|
|
340
372
|
"Mo",
|
|
341
373
|
"Tu",
|
|
@@ -343,24 +375,24 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
343
375
|
"Th",
|
|
344
376
|
"Fr",
|
|
345
377
|
"Sa"
|
|
346
|
-
],
|
|
378
|
+
], y = (e) => String(e).padStart(2, "0"), b = (e, t, n) => `${e}-${y(t + 1)}-${y(n)}`, x = (e) => {
|
|
347
379
|
let t = /^(\d{4})-(\d{2})-(\d{2})$/.exec(e || "");
|
|
348
380
|
return t ? {
|
|
349
381
|
y: +t[1],
|
|
350
382
|
m: t[2] - 1,
|
|
351
383
|
d: +t[3]
|
|
352
384
|
} : null;
|
|
353
|
-
},
|
|
354
|
-
let t =
|
|
355
|
-
return t ? `${
|
|
356
|
-
},
|
|
385
|
+
}, S = (e) => {
|
|
386
|
+
let t = x(e);
|
|
387
|
+
return t ? `${y(t.d)} ${_[t.m].slice(0, 3)} ${t.y}` : "";
|
|
388
|
+
}, C = (e, t) => new Date(e, t + 1, 0).getDate(), w = (e, t) => {
|
|
357
389
|
for (; t < 0;) t += 12, --e;
|
|
358
390
|
for (; t > 11;) t -= 12, e += 1;
|
|
359
391
|
return {
|
|
360
392
|
y: e,
|
|
361
393
|
m: t
|
|
362
394
|
};
|
|
363
|
-
},
|
|
395
|
+
}, T = class extends HTMLElement {
|
|
364
396
|
static formAssociated = !0;
|
|
365
397
|
static get observedAttributes() {
|
|
366
398
|
return [
|
|
@@ -411,13 +443,13 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
411
443
|
}
|
|
412
444
|
render() {
|
|
413
445
|
this._defaultValue === void 0 && (this._defaultValue = this.getAttribute("value") || "", this._value = this._defaultValue || this._value);
|
|
414
|
-
let e = this.getAttribute("placeholder") || "Enter Date", t =
|
|
446
|
+
let e = this.getAttribute("placeholder") || "Enter Date", t = x(this._value);
|
|
415
447
|
t && (this._viewY = t.y, this._viewM = t.m);
|
|
416
448
|
let n = this.getAttribute("size"), r = n === "sm" ? " input-sm" : n === "lg" ? " input-lg" : "", i = this.getAttribute("aria-label"), a = this.getAttribute("aria-describedby");
|
|
417
449
|
this.innerHTML = `
|
|
418
450
|
<div class="datepicker">
|
|
419
|
-
<button type="button" class="input datepicker-trigger${r}${t ? " has-value" : ""}" aria-haspopup="dialog" aria-expanded="false"${this.hasAttribute("disabled") ? " disabled" : ""}${i ? ` aria-label="${
|
|
420
|
-
<span data-trigger-label class="${t ? "" : "search-select-placeholder"}">${t ?
|
|
451
|
+
<button type="button" class="input datepicker-trigger${r}${t ? " has-value" : ""}" aria-haspopup="dialog" aria-expanded="false"${this.hasAttribute("disabled") ? " disabled" : ""}${i ? ` aria-label="${d(i)}"` : ""}${a ? ` aria-describedby="${d(a)}"` : ""}>
|
|
452
|
+
<span data-trigger-label class="${t ? "" : "search-select-placeholder"}">${t ? S(this._value) : d(e)}</span>
|
|
421
453
|
<i class="bi bi-calendar3" aria-hidden="true"></i>
|
|
422
454
|
</button>
|
|
423
455
|
<div class="datepicker-pop" role="dialog" aria-modal="false" hidden></div>
|
|
@@ -429,11 +461,11 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
429
461
|
_syncTrigger() {
|
|
430
462
|
let e = this.querySelector(".datepicker-trigger"), t = this.querySelector("[data-trigger-label]");
|
|
431
463
|
if (!t) return;
|
|
432
|
-
let n =
|
|
433
|
-
t.textContent = n ?
|
|
464
|
+
let n = x(this._value);
|
|
465
|
+
t.textContent = n ? S(this._value) : this.getAttribute("placeholder") || "Enter Date", t.classList.toggle("search-select-placeholder", !n), e?.classList.toggle("has-value", !!n);
|
|
434
466
|
}
|
|
435
467
|
_limits() {
|
|
436
|
-
let e =
|
|
468
|
+
let e = x(this.getAttribute("min")), t = x(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;
|
|
437
469
|
return {
|
|
438
470
|
dayDisabled: (e, t, i) => {
|
|
439
471
|
let a = new Date(e, t, i).getTime();
|
|
@@ -441,7 +473,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
441
473
|
},
|
|
442
474
|
monthDisabled: (e, t) => {
|
|
443
475
|
let i = new Date(e, t, 1).getTime();
|
|
444
|
-
return new Date(e, t,
|
|
476
|
+
return new Date(e, t, C(e, t)).getTime() < n || i > r;
|
|
445
477
|
},
|
|
446
478
|
yearDisabled: (e) => {
|
|
447
479
|
let t = new Date(e, 0, 1).getTime();
|
|
@@ -454,28 +486,28 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
454
486
|
e && (this._mode === "months" ? e.innerHTML = this._monthsHtml() : this._mode === "years" ? e.innerHTML = this._yearsHtml() : e.innerHTML = this._daysHtml(), this._focusActive());
|
|
455
487
|
}
|
|
456
488
|
_daysHtml() {
|
|
457
|
-
let e = this._firstDay(), t = (new Date(this._viewY, this._viewM, 1).getDay() - e + 7) % 7, n =
|
|
489
|
+
let e = this._firstDay(), t = (new Date(this._viewY, this._viewM, 1).getDay() - e + 7) % 7, n = C(this._viewY, this._viewM), r = x(this._value), i = /* @__PURE__ */ new Date(), { dayDisabled: a } = this._limits(), o = this._focus || r || {
|
|
458
490
|
y: this._viewY,
|
|
459
491
|
m: this._viewM,
|
|
460
492
|
d: 1
|
|
461
493
|
}, s = (e, t, n, s) => {
|
|
462
|
-
let c =
|
|
494
|
+
let c = b(e, t, n), l = r && r.y === e && r.m === t && r.d === n, u = i.getFullYear() === e && i.getMonth() === t && i.getDate() === n, d = o.y === e && o.m === t && o.d === n, f = a(e, t, n);
|
|
463
495
|
return `<button type="button" class="${[
|
|
464
496
|
"datepicker-day",
|
|
465
497
|
s ? "is-outside" : "",
|
|
466
498
|
u ? "is-today" : "",
|
|
467
499
|
l ? "is-selected" : ""
|
|
468
500
|
].filter(Boolean).join(" ")}" data-iso="${c}" role="gridcell" tabindex="${d && !f ? "0" : "-1"}"${l ? " aria-selected=\"true\"" : ""}${f ? " disabled aria-disabled=\"true\"" : ""}>${n}</button>`;
|
|
469
|
-
}, c = "", l =
|
|
501
|
+
}, c = "", l = w(this._viewY, this._viewM - 1), u = C(l.y, l.m);
|
|
470
502
|
for (let e = t - 1; e >= 0; e--) c += s(l.y, l.m, u - e, !0);
|
|
471
503
|
for (let e = 1; e <= n; e++) c += s(this._viewY, this._viewM, e, !1);
|
|
472
|
-
let d =
|
|
504
|
+
let d = w(this._viewY, this._viewM + 1), f = (7 - (t + n) % 7) % 7;
|
|
473
505
|
for (let e = 1; e <= f; e++) c += s(d.y, d.m, e, !0);
|
|
474
|
-
let p =
|
|
506
|
+
let p = v.map((t, n) => v[(n + e) % 7]).map((e) => `<span>${e}</span>`).join("");
|
|
475
507
|
return `
|
|
476
508
|
<div class="datepicker-head">
|
|
477
509
|
<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>
|
|
478
|
-
<button type="button" class="datepicker-month" data-view="months" aria-label="Choose month and year">${
|
|
510
|
+
<button type="button" class="datepicker-month" data-view="months" aria-label="Choose month and year">${_[this._viewM]} ${this._viewY}</button>
|
|
479
511
|
<button type="button" class="datepicker-nav-btn" data-nav="1" aria-label="Next month"><i class="bi bi-chevron-right" aria-hidden="true"></i></button>
|
|
480
512
|
</div>
|
|
481
513
|
<div class="datepicker-weekdays">${p}</div>
|
|
@@ -486,14 +518,14 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
486
518
|
</div>`;
|
|
487
519
|
}
|
|
488
520
|
_monthsHtml() {
|
|
489
|
-
let e =
|
|
521
|
+
let e = x(this._value), t = /* @__PURE__ */ new Date(), { monthDisabled: n } = this._limits(), r = "";
|
|
490
522
|
for (let i = 0; i < 12; i++) {
|
|
491
523
|
let a = e && e.y === this._viewY && e.m === i, o = t.getFullYear() === this._viewY && t.getMonth() === i, s = n(this._viewY, i), c = [
|
|
492
524
|
"datepicker-cell",
|
|
493
525
|
o ? "is-today" : "",
|
|
494
526
|
a ? "is-selected" : ""
|
|
495
527
|
].filter(Boolean).join(" ");
|
|
496
|
-
r += `<button type="button" class="${c}" data-month="${i}"${s ? " disabled" : ""}>${
|
|
528
|
+
r += `<button type="button" class="${c}" data-month="${i}"${s ? " disabled" : ""}>${_[i].slice(0, 3)}</button>`;
|
|
497
529
|
}
|
|
498
530
|
return `
|
|
499
531
|
<div class="datepicker-head">
|
|
@@ -504,7 +536,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
504
536
|
<div class="datepicker-cells">${r}</div>`;
|
|
505
537
|
}
|
|
506
538
|
_yearsHtml() {
|
|
507
|
-
let e =
|
|
539
|
+
let e = x(this._value), t = (/* @__PURE__ */ new Date()).getFullYear(), { yearDisabled: n } = this._limits(), r = this._viewY - (this._viewY % 10 + 10) % 10 - 1, i = "";
|
|
508
540
|
for (let a = 0; a < 12; a++) {
|
|
509
541
|
let o = r + a, s = e && e.y === o, c = t === o, l = n(o), u = [
|
|
510
542
|
"datepicker-cell",
|
|
@@ -529,21 +561,21 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
529
561
|
i(e, t);
|
|
530
562
|
}
|
|
531
563
|
_setFocus(e, t, n, r) {
|
|
532
|
-
let { y: i, m: a } =
|
|
564
|
+
let { y: i, m: a } = w(e, t);
|
|
533
565
|
this._focus = {
|
|
534
566
|
y: i,
|
|
535
567
|
m: a,
|
|
536
568
|
d: n
|
|
537
569
|
};
|
|
538
570
|
let o = i !== this._viewY || a !== this._viewM;
|
|
539
|
-
this._viewY = i, this._viewM = a, this._slide = o && r || "", this._renderView(), this._slide = "", this.querySelector(`.datepicker-day[data-iso="${
|
|
571
|
+
this._viewY = i, this._viewM = a, this._slide = o && r || "", this._renderView(), this._slide = "", this.querySelector(`.datepicker-day[data-iso="${b(i, a, n)}"]`)?.focus();
|
|
540
572
|
}
|
|
541
573
|
_onKey(e) {
|
|
542
574
|
if (this._mode !== "days") {
|
|
543
575
|
e.key === "Escape" && this._close();
|
|
544
576
|
return;
|
|
545
577
|
}
|
|
546
|
-
let t = this._focus ||
|
|
578
|
+
let t = this._focus || x(this._value) || {
|
|
547
579
|
y: this._viewY,
|
|
548
580
|
m: this._viewM,
|
|
549
581
|
d: 1
|
|
@@ -561,17 +593,17 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
561
593
|
case "End": return n(6 - (new Date(t.y, t.m, t.d).getDay() - this._firstDay() + 7) % 7, "slide-next");
|
|
562
594
|
case "PageUp": {
|
|
563
595
|
e.preventDefault();
|
|
564
|
-
let n =
|
|
565
|
-
return this._setFocus(n.y, n.m, Math.min(t.d,
|
|
596
|
+
let n = w(t.y, t.m - (e.shiftKey ? 12 : 1));
|
|
597
|
+
return this._setFocus(n.y, n.m, Math.min(t.d, C(n.y, n.m)), "slide-prev");
|
|
566
598
|
}
|
|
567
599
|
case "PageDown": {
|
|
568
600
|
e.preventDefault();
|
|
569
|
-
let n =
|
|
570
|
-
return this._setFocus(n.y, n.m, Math.min(t.d,
|
|
601
|
+
let n = w(t.y, t.m + (e.shiftKey ? 12 : 1));
|
|
602
|
+
return this._setFocus(n.y, n.m, Math.min(t.d, C(n.y, n.m)), "slide-next");
|
|
571
603
|
}
|
|
572
604
|
case "Enter":
|
|
573
605
|
case " ":
|
|
574
|
-
e.preventDefault(), this._limits().dayDisabled(t.y, t.m, t.d) || (this.value =
|
|
606
|
+
e.preventDefault(), this._limits().dayDisabled(t.y, t.m, t.d) || (this.value = b(t.y, t.m, t.d), this.dispatchEvent(new Event("change", { bubbles: !0 })), this._close());
|
|
575
607
|
return;
|
|
576
608
|
case "Escape": return this._close();
|
|
577
609
|
default:
|
|
@@ -583,11 +615,11 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
583
615
|
if (!e || !t) return;
|
|
584
616
|
let r = () => !t.hidden;
|
|
585
617
|
this._open = () => {
|
|
586
|
-
if (!
|
|
618
|
+
if (!x(this._value) && !this._viewNavigated) {
|
|
587
619
|
let e = /* @__PURE__ */ new Date();
|
|
588
620
|
this._viewY = e.getFullYear(), this._viewM = e.getMonth();
|
|
589
621
|
}
|
|
590
|
-
let r =
|
|
622
|
+
let r = x(this._value), i = /* @__PURE__ */ new Date();
|
|
591
623
|
this._mode = "days", this._focus = r || {
|
|
592
624
|
y: this._viewY,
|
|
593
625
|
m: this._viewM,
|
|
@@ -600,7 +632,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
600
632
|
let t = e.target.closest("[data-nav]");
|
|
601
633
|
if (t) {
|
|
602
634
|
this._viewNavigated = !0, this._slide = Number(t.dataset.nav) < 0 ? "slide-prev" : "slide-next";
|
|
603
|
-
let e =
|
|
635
|
+
let e = w(this._viewY, this._viewM + Number(t.dataset.nav));
|
|
604
636
|
this._viewY = e.y, this._viewM = e.m, this._focus = {
|
|
605
637
|
y: e.y,
|
|
606
638
|
m: e.m,
|
|
@@ -639,7 +671,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
639
671
|
}
|
|
640
672
|
if (e.target.closest("[data-today]")) {
|
|
641
673
|
let e = /* @__PURE__ */ new Date();
|
|
642
|
-
this.value =
|
|
674
|
+
this.value = b(e.getFullYear(), e.getMonth(), e.getDate()), this.dispatchEvent(new Event("change", { bubbles: !0 })), this._close();
|
|
643
675
|
return;
|
|
644
676
|
}
|
|
645
677
|
if (e.target.closest("[data-clear]")) {
|
|
@@ -667,45 +699,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
667
699
|
disconnectedCallback() {
|
|
668
700
|
this._teardown();
|
|
669
701
|
}
|
|
670
|
-
},
|
|
671
|
-
"January",
|
|
672
|
-
"February",
|
|
673
|
-
"March",
|
|
674
|
-
"April",
|
|
675
|
-
"May",
|
|
676
|
-
"June",
|
|
677
|
-
"July",
|
|
678
|
-
"August",
|
|
679
|
-
"September",
|
|
680
|
-
"October",
|
|
681
|
-
"November",
|
|
682
|
-
"December"
|
|
683
|
-
], T = [
|
|
684
|
-
"Su",
|
|
685
|
-
"Mo",
|
|
686
|
-
"Tu",
|
|
687
|
-
"We",
|
|
688
|
-
"Th",
|
|
689
|
-
"Fr",
|
|
690
|
-
"Sa"
|
|
691
|
-
], E = (e) => String(e).padStart(2, "0"), te = (e, t, n) => `${e}-${E(t + 1)}-${E(n)}`, D = (e) => {
|
|
692
|
-
let t = /^(\d{4})-(\d{2})-(\d{2})$/.exec(e || "");
|
|
693
|
-
return t ? {
|
|
694
|
-
y: +t[1],
|
|
695
|
-
m: t[2] - 1,
|
|
696
|
-
d: +t[3]
|
|
697
|
-
} : null;
|
|
698
|
-
}, O = (e) => {
|
|
699
|
-
let t = D(e);
|
|
700
|
-
return t ? `${E(t.d)} ${w[t.m].slice(0, 3)} ${t.y}` : "";
|
|
701
|
-
}, k = (e, t) => new Date(e, t + 1, 0).getDate(), A = (e, t) => {
|
|
702
|
-
for (; t < 0;) t += 12, --e;
|
|
703
|
-
for (; t > 11;) t -= 12, e += 1;
|
|
704
|
-
return {
|
|
705
|
-
y: e,
|
|
706
|
-
m: t
|
|
707
|
-
};
|
|
708
|
-
}, j = class extends HTMLElement {
|
|
702
|
+
}, ee = class extends HTMLElement {
|
|
709
703
|
static formAssociated = !0;
|
|
710
704
|
static get observedAttributes() {
|
|
711
705
|
return [
|
|
@@ -764,19 +758,19 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
764
758
|
text: e,
|
|
765
759
|
empty: !0
|
|
766
760
|
} : {
|
|
767
|
-
text: `${
|
|
761
|
+
text: `${S(this._start) || "Start"} – ${S(this._end) || "End"}`,
|
|
768
762
|
empty: !1
|
|
769
763
|
};
|
|
770
764
|
}
|
|
771
765
|
render() {
|
|
772
766
|
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);
|
|
773
|
-
let e =
|
|
767
|
+
let e = x(this._start);
|
|
774
768
|
e && (this._viewY = e.y, this._viewM = e.m);
|
|
775
769
|
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");
|
|
776
770
|
this.innerHTML = `
|
|
777
771
|
<div class="daterange">
|
|
778
|
-
<button type="button" class="input daterange-trigger${n}${i ? "" : " has-value"}" aria-haspopup="dialog" aria-expanded="false"${this.hasAttribute("disabled") ? " disabled" : ""}${a ? ` aria-label="${
|
|
779
|
-
<span data-range-label class="${i ? "search-select-placeholder" : ""}">${
|
|
772
|
+
<button type="button" class="input daterange-trigger${n}${i ? "" : " has-value"}" aria-haspopup="dialog" aria-expanded="false"${this.hasAttribute("disabled") ? " disabled" : ""}${a ? ` aria-label="${d(a)}"` : ""}${o ? ` aria-describedby="${d(o)}"` : ""}>
|
|
773
|
+
<span data-range-label class="${i ? "search-select-placeholder" : ""}">${d(r)}</span>
|
|
780
774
|
<i class="bi bi-calendar-range" aria-hidden="true"></i>
|
|
781
775
|
</button>
|
|
782
776
|
<div class="daterange-pop" role="dialog" aria-modal="false" hidden></div>
|
|
@@ -804,24 +798,24 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
804
798
|
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");
|
|
805
799
|
}
|
|
806
800
|
_limits() {
|
|
807
|
-
let e =
|
|
801
|
+
let e = x(this.getAttribute("min")), t = x(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;
|
|
808
802
|
return (e, t, i) => {
|
|
809
803
|
let a = new Date(e, t, i).getTime();
|
|
810
804
|
return a < n || a > r;
|
|
811
805
|
};
|
|
812
806
|
}
|
|
813
807
|
_monthHtml(e, t) {
|
|
814
|
-
let n = this._firstDay(), r = (new Date(e, t, 1).getDay() - n + 7) % 7, i =
|
|
815
|
-
let i =
|
|
808
|
+
let n = this._firstDay(), r = (new Date(e, t, 1).getDay() - n + 7) % 7, i = C(e, t), a = this._limits(), o = v.map((e, t) => v[(t + n) % 7]).map((e) => `<span>${e}</span>`).join(""), s = (e, t, n, r) => {
|
|
809
|
+
let i = b(e, t, n), o = a(e, t, n);
|
|
816
810
|
return `<button type="button" class="${["datepicker-day", r ? "is-outside" : ""].filter(Boolean).join(" ")}" data-iso="${i}"${o ? " disabled" : ""}>${n}</button>`;
|
|
817
|
-
}, c = "", l =
|
|
811
|
+
}, c = "", l = w(e, t - 1), u = C(l.y, l.m);
|
|
818
812
|
for (let e = r - 1; e >= 0; e--) c += s(l.y, l.m, u - e, !0);
|
|
819
813
|
for (let n = 1; n <= i; n++) c += s(e, t, n, !1);
|
|
820
|
-
let d =
|
|
814
|
+
let d = w(e, t + 1), f = (7 - (r + i) % 7) % 7;
|
|
821
815
|
for (let e = 1; e <= f; e++) c += s(d.y, d.m, e, !0);
|
|
822
816
|
return `
|
|
823
817
|
<div class="daterange-cal">
|
|
824
|
-
<div class="datepicker-month-label">${
|
|
818
|
+
<div class="datepicker-month-label">${_[t]} ${e}</div>
|
|
825
819
|
<div class="datepicker-weekdays">${o}</div>
|
|
826
820
|
<div class="datepicker-grid" role="grid">${c}</div>
|
|
827
821
|
</div>`;
|
|
@@ -829,7 +823,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
829
823
|
_renderView() {
|
|
830
824
|
let e = this.querySelector(".daterange-pop");
|
|
831
825
|
if (!e) return;
|
|
832
|
-
let t =
|
|
826
|
+
let t = w(this._viewY, this._viewM + 1);
|
|
833
827
|
e.innerHTML = `
|
|
834
828
|
<div class="daterange-head">
|
|
835
829
|
<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>
|
|
@@ -855,7 +849,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
855
849
|
n.classList.toggle("is-range-start", i), n.classList.toggle("is-range-end", a), n.classList.toggle("in-range", o);
|
|
856
850
|
}
|
|
857
851
|
let i = e.querySelector("[data-range-hint]");
|
|
858
|
-
i && (i.textContent = this._start ? this._end ? `${
|
|
852
|
+
i && (i.textContent = this._start ? this._end ? `${S(this._start)} – ${S(this._end)}` : "Pick an end date" : "Pick a start date");
|
|
859
853
|
}
|
|
860
854
|
_position(e, t) {
|
|
861
855
|
i(e, t);
|
|
@@ -877,7 +871,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
877
871
|
if (!e || !t) return;
|
|
878
872
|
let r = () => !t.hidden;
|
|
879
873
|
this._open = () => {
|
|
880
|
-
let r =
|
|
874
|
+
let r = x(this._start);
|
|
881
875
|
if (r) this._viewY = r.y, this._viewM = r.m;
|
|
882
876
|
else {
|
|
883
877
|
let e = /* @__PURE__ */ new Date();
|
|
@@ -890,7 +884,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
890
884
|
this._popClick = !0;
|
|
891
885
|
let t = e.target.closest("[data-nav]");
|
|
892
886
|
if (t) {
|
|
893
|
-
let e =
|
|
887
|
+
let e = w(this._viewY, this._viewM + Number(t.dataset.nav));
|
|
894
888
|
this._viewY = e.y, this._viewM = e.m, this._renderView();
|
|
895
889
|
return;
|
|
896
890
|
}
|
|
@@ -920,7 +914,59 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
920
914
|
disconnectedCallback() {
|
|
921
915
|
this._teardown();
|
|
922
916
|
}
|
|
923
|
-
},
|
|
917
|
+
}, E = class extends HTMLElement {
|
|
918
|
+
static get observedAttributes() {
|
|
919
|
+
return [
|
|
920
|
+
"static",
|
|
921
|
+
"max-scale",
|
|
922
|
+
"radius"
|
|
923
|
+
];
|
|
924
|
+
}
|
|
925
|
+
constructor() {
|
|
926
|
+
super(), this._pointerMoveListener = null, this._pointerLeaveListener = null, this._frame = 0, this._pointerX = 0;
|
|
927
|
+
}
|
|
928
|
+
connectedCallback() {
|
|
929
|
+
this._wire();
|
|
930
|
+
}
|
|
931
|
+
disconnectedCallback() {
|
|
932
|
+
this._teardown();
|
|
933
|
+
}
|
|
934
|
+
attributeChangedCallback(e, t, n) {
|
|
935
|
+
e === "static" && this.isConnected && this._wire();
|
|
936
|
+
}
|
|
937
|
+
_maxScale() {
|
|
938
|
+
return D(this.getAttribute("max-scale"), 1.6);
|
|
939
|
+
}
|
|
940
|
+
_radius() {
|
|
941
|
+
return D(this.getAttribute("radius"), 100);
|
|
942
|
+
}
|
|
943
|
+
_magnifyEnabled() {
|
|
944
|
+
return !(this.hasAttribute("static") || typeof matchMedia == "function" && (matchMedia("(pointer: coarse)").matches || matchMedia("(prefers-reduced-motion: reduce)").matches));
|
|
945
|
+
}
|
|
946
|
+
_applyMagnification() {
|
|
947
|
+
this._frame = 0;
|
|
948
|
+
let e = this._maxScale(), t = this._radius();
|
|
949
|
+
for (let n of this.querySelectorAll(".dock-item")) {
|
|
950
|
+
let r = n.getBoundingClientRect(), i = Math.abs(this._pointerX - (r.left + r.width / 2)), a = Math.max(0, 1 - i / t), o = 1 + (e - 1) * a;
|
|
951
|
+
n.style.setProperty("--wui-dock-mag", o.toFixed(3));
|
|
952
|
+
}
|
|
953
|
+
}
|
|
954
|
+
_resetMagnification() {
|
|
955
|
+
this._frame &&= (cancelAnimationFrame(this._frame), 0);
|
|
956
|
+
for (let e of this.querySelectorAll(".dock-item")) e.style.removeProperty("--wui-dock-mag");
|
|
957
|
+
}
|
|
958
|
+
_wire() {
|
|
959
|
+
this._teardown(), this._magnifyEnabled() && (this._pointerMoveListener = (e) => {
|
|
960
|
+
this._pointerX = e.clientX, this._frame ||= requestAnimationFrame(() => this._applyMagnification());
|
|
961
|
+
}, this._pointerLeaveListener = () => this._resetMagnification(), this.addEventListener("pointermove", this._pointerMoveListener), this.addEventListener("pointerleave", this._pointerLeaveListener));
|
|
962
|
+
}
|
|
963
|
+
_teardown() {
|
|
964
|
+
this._pointerMoveListener &&= (this.removeEventListener("pointermove", this._pointerMoveListener), null), this._pointerLeaveListener &&= (this.removeEventListener("pointerleave", this._pointerLeaveListener), null), this._resetMagnification();
|
|
965
|
+
}
|
|
966
|
+
}, D = (e, t) => {
|
|
967
|
+
let n = Number.parseFloat(e);
|
|
968
|
+
return Number.isFinite(n) ? n : t;
|
|
969
|
+
}, te = class extends HTMLElement {
|
|
924
970
|
static formAssociated = !0;
|
|
925
971
|
_accessibleName() {
|
|
926
972
|
return this.getAttribute("aria-label") || this.getAttribute("placeholder") || "Select";
|
|
@@ -989,7 +1035,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
989
1035
|
value: e.getAttribute("value") ?? e.textContent.trim(),
|
|
990
1036
|
label: e.innerHTML,
|
|
991
1037
|
icon: e.getAttribute("icon") || void 0,
|
|
992
|
-
[
|
|
1038
|
+
[u]: !0,
|
|
993
1039
|
selected: e.hasAttribute("selected")
|
|
994
1040
|
})));
|
|
995
1041
|
}
|
|
@@ -1002,7 +1048,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
1002
1048
|
}
|
|
1003
1049
|
_labelHtmlFor(e) {
|
|
1004
1050
|
let t = this._readOptions().find((t) => String(t.value) === String(e));
|
|
1005
|
-
return t ?
|
|
1051
|
+
return t ? p(t) : d(e);
|
|
1006
1052
|
}
|
|
1007
1053
|
render() {
|
|
1008
1054
|
this._snapshotDeclared();
|
|
@@ -1011,13 +1057,13 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
1011
1057
|
let a = `${this.id}-listbox`;
|
|
1012
1058
|
this._listboxId = a, this.innerHTML = `
|
|
1013
1059
|
<div class="search-select${i}">
|
|
1014
|
-
<div class="input search-select-control search-select-multi" role="combobox" aria-haspopup="listbox" aria-expanded="false" aria-controls="${
|
|
1015
|
-
${n ? `<i class="bi bi-${
|
|
1060
|
+
<div class="input search-select-control search-select-multi" role="combobox" aria-haspopup="listbox" aria-expanded="false" aria-controls="${O(a)}" aria-label="${O(this._accessibleName())}"${this.hasAttribute("disabled") ? " aria-disabled=\"true\"" : " tabindex=\"0\""}>
|
|
1061
|
+
${n ? `<i class="bi bi-${O(n)} search-select-icon" aria-hidden="true"></i>` : ""}
|
|
1016
1062
|
<div class="ms-chips" data-chips></div>
|
|
1017
1063
|
<i class="bi bi-chevron-down search-select-caret" aria-hidden="true"></i>
|
|
1018
1064
|
</div>
|
|
1019
|
-
<div class="search-select-menu search-select-menu-fixed" role="listbox" id="${
|
|
1020
|
-
${e ? `<div class="search-select-search"><i class="bi bi-search" aria-hidden="true"></i><input class="search-select-input" placeholder="${
|
|
1065
|
+
<div class="search-select-menu search-select-menu-fixed" role="listbox" id="${O(a)}" aria-multiselectable="true" tabindex="-1" hidden>
|
|
1066
|
+
${e ? `<div class="search-select-search"><i class="bi bi-search" aria-hidden="true"></i><input class="search-select-input" placeholder="${O(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>` : ""}
|
|
1021
1067
|
<div class="search-select-options"></div>
|
|
1022
1068
|
<div class="search-select-empty" hidden>No matches</div>
|
|
1023
1069
|
</div>
|
|
@@ -1028,10 +1074,10 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
1028
1074
|
if (!e) return;
|
|
1029
1075
|
let t = this.getAttribute("placeholder") || "Select…";
|
|
1030
1076
|
if (!this._values.length) {
|
|
1031
|
-
e.innerHTML = `<span class="search-select-placeholder">${
|
|
1077
|
+
e.innerHTML = `<span class="search-select-placeholder">${d(t)}</span>`;
|
|
1032
1078
|
return;
|
|
1033
1079
|
}
|
|
1034
|
-
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="${
|
|
1080
|
+
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="${O(e)}" aria-label="Remove ${O(k(this._labelFor(e)))}"><i class="bi bi-x" aria-hidden="true"></i></button></span>`).join(""), this._collapseChips();
|
|
1035
1081
|
}
|
|
1036
1082
|
_collapseChips() {
|
|
1037
1083
|
let e = this.querySelector("[data-chips]");
|
|
@@ -1055,99 +1101,91 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
1055
1101
|
let t = this.querySelector(".search-select-options"), n = this.querySelector(".search-select-empty");
|
|
1056
1102
|
if (!t) return;
|
|
1057
1103
|
let r = (e || "").trim().toLowerCase(), i = this._readOptions();
|
|
1058
|
-
r && (i = i.filter((e) =>
|
|
1104
|
+
r && (i = i.filter((e) => k(e.label).toLowerCase().includes(r)));
|
|
1059
1105
|
let a = this._listboxId || `${this.id || "wui-multiselect"}-listbox`;
|
|
1060
1106
|
t.innerHTML = i.map((e, t) => {
|
|
1061
1107
|
let n = this._values.includes(String(e.value));
|
|
1062
|
-
return `<button type="button" role="option" id="${
|
|
1108
|
+
return `<button type="button" role="option" id="${O(`${a}-opt-${t}`)}" class="search-select-option${n ? " selected" : ""}" data-value="${O(e.value)}" aria-selected="${n}"><span class="ms-opt-label">${p(e)}</span><span class="ms-check"><i class="bi bi-check" aria-hidden="true"></i></span></button>`;
|
|
1063
1109
|
}).join(""), n && (n.hidden = i.length > 0), this._active = -1, this.querySelector(".search-select-control")?.removeAttribute("aria-activedescendant");
|
|
1064
1110
|
}
|
|
1065
1111
|
_wire() {
|
|
1066
1112
|
this._teardown();
|
|
1067
1113
|
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");
|
|
1068
1114
|
if (!e || !t) return;
|
|
1069
|
-
let s = () => this.hasAttribute("disabled"),
|
|
1070
|
-
let n =
|
|
1115
|
+
let s = () => this.hasAttribute("disabled"), u = () => i(e, t, { matchWidth: !0 }), d = () => [...this.querySelectorAll(".search-select-option")], f = () => d().filter((e) => !e.hidden), p = (t) => {
|
|
1116
|
+
let n = f();
|
|
1071
1117
|
this._active = t;
|
|
1072
|
-
for (let e of
|
|
1118
|
+
for (let e of d()) e.classList.remove("is-active");
|
|
1073
1119
|
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");
|
|
1074
|
-
},
|
|
1075
|
-
s() || (t.hidden = !1, e.setAttribute("aria-expanded", "true"), e.classList.add("open"),
|
|
1076
|
-
}, h = () => {
|
|
1077
|
-
t.hidden = !0, e.setAttribute("aria-expanded", "false"), e.classList.remove("open"), f(-1), clearTimeout(this._typeaheadTimer), this._typeaheadTimer = null, this._typeahead = "";
|
|
1120
|
+
}, m = () => !t.hidden, h = () => {
|
|
1121
|
+
s() || (t.hidden = !1, e.setAttribute("aria-expanded", "true"), e.classList.add("open"), u(), n && (n.value = "", this._renderOptions(""), n.focus()));
|
|
1078
1122
|
}, g = () => {
|
|
1123
|
+
t.hidden = !0, e.setAttribute("aria-expanded", "false"), e.classList.remove("open"), p(-1), clearTimeout(this._typeaheadTimer), this._typeaheadTimer = null, this._typeahead = "";
|
|
1124
|
+
}, _ = () => {
|
|
1079
1125
|
c(this, this._values.join(",")), this.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
1080
|
-
}, _ = (e) => {
|
|
1081
|
-
let t = String(e);
|
|
1082
|
-
this._values.includes(t) ? this._values = this._values.filter((e) => e !== t) : this._values = [...this._values, t], this._renderControl(), this._renderOptions(n ? n.value : ""), g();
|
|
1083
1126
|
}, v = (e) => {
|
|
1084
|
-
|
|
1127
|
+
let t = String(e);
|
|
1128
|
+
this._values.includes(t) ? this._values = this._values.filter((e) => e !== t) : this._values = [...this._values, t], this._renderControl(), this._renderOptions(n ? n.value : ""), _();
|
|
1129
|
+
}, y = (e) => {
|
|
1130
|
+
this._values = this._values.filter((t) => t !== String(e)), this._renderControl(), this._renderOptions(n ? n.value : ""), _();
|
|
1085
1131
|
};
|
|
1086
1132
|
e.addEventListener("click", (e) => {
|
|
1087
1133
|
if (s()) return;
|
|
1088
1134
|
let t = e.target.closest("[data-remove]");
|
|
1089
1135
|
if (t) {
|
|
1090
|
-
e.stopPropagation(),
|
|
1136
|
+
e.stopPropagation(), y(t.dataset.remove);
|
|
1091
1137
|
return;
|
|
1092
1138
|
}
|
|
1093
|
-
|
|
1139
|
+
m() ? g() : h();
|
|
1094
1140
|
}), o.addEventListener("click", (e) => {
|
|
1095
1141
|
let t = e.target.closest(".search-select-option");
|
|
1096
|
-
t && (
|
|
1142
|
+
t && (v(t.dataset.value), n?.focus());
|
|
1097
1143
|
}), o.addEventListener("mousemove", (e) => {
|
|
1098
1144
|
let t = e.target.closest(".search-select-option");
|
|
1099
|
-
t && f(
|
|
1100
|
-
}), o.addEventListener("mouseleave", () =>
|
|
1101
|
-
this._renderOptions(n.value), r && (r.hidden = !n.value),
|
|
1145
|
+
t && p(f().indexOf(t));
|
|
1146
|
+
}), o.addEventListener("mouseleave", () => p(-1)), n?.addEventListener("input", () => {
|
|
1147
|
+
this._renderOptions(n.value), r && (r.hidden = !n.value), p(-1);
|
|
1148
|
+
}), this._navHandler = l({
|
|
1149
|
+
getVisibleOptions: f,
|
|
1150
|
+
getActive: () => this._active,
|
|
1151
|
+
setActive: (e) => p(e),
|
|
1152
|
+
onEnter: (e) => {
|
|
1153
|
+
e && v(e.dataset.value);
|
|
1154
|
+
},
|
|
1155
|
+
onEscape: () => {
|
|
1156
|
+
this._navHandler.clearTypeahead(), g(), e.focus();
|
|
1157
|
+
}
|
|
1102
1158
|
});
|
|
1103
|
-
let
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
if (t.key === "ArrowDown") t.preventDefault(), f(Math.min(this._active + 1, r.length - 1));
|
|
1108
|
-
else if (t.key === "ArrowUp") t.preventDefault(), f(Math.max(this._active - 1, 0));
|
|
1109
|
-
else if (t.key === "Home" && !i) t.preventDefault(), r.length && f(0);
|
|
1110
|
-
else if (t.key === "End" && !i) t.preventDefault(), r.length && f(r.length - 1);
|
|
1111
|
-
else if (t.key === "PageDown" && !i) {
|
|
1112
|
-
if (t.preventDefault(), !r.length) return;
|
|
1113
|
-
let e = this._active < 0 ? 0 : this._active;
|
|
1114
|
-
f(Math.min(e + 8, r.length - 1));
|
|
1115
|
-
} else if (t.key === "PageUp" && !i) {
|
|
1116
|
-
if (t.preventDefault(), !r.length) return;
|
|
1117
|
-
let e = this._active < 0 ? 0 : this._active;
|
|
1118
|
-
f(Math.max(e - 8, 0));
|
|
1119
|
-
} else if (t.key === "Enter") t.preventDefault(), r[this._active] && _(r[this._active].dataset.value);
|
|
1120
|
-
else if (t.key === "Escape") h(), e.focus();
|
|
1121
|
-
else if (t.key === "Backspace" && !n?.value && this._values.length) v(this._values[this._values.length - 1]);
|
|
1122
|
-
else if (t.key.length === 1 && !t.ctrlKey && !t.metaKey && !t.altKey && t.target?.tagName !== "INPUT" && t.target?.tagName !== "TEXTAREA") {
|
|
1123
|
-
t.preventDefault(), clearTimeout(this._typeaheadTimer), this._typeahead += t.key.toLowerCase(), this._typeaheadTimer = setTimeout(y, 500);
|
|
1124
|
-
let e = r.findIndex((e) => e.textContent.trim().toLowerCase().startsWith(this._typeahead));
|
|
1125
|
-
e >= 0 && f(e);
|
|
1159
|
+
let b = (e) => {
|
|
1160
|
+
if (e.key === "Backspace" && !n?.value && this._values.length) {
|
|
1161
|
+
y(this._values[this._values.length - 1]);
|
|
1162
|
+
return;
|
|
1126
1163
|
}
|
|
1164
|
+
this._navHandler.handler(e);
|
|
1127
1165
|
};
|
|
1128
1166
|
n?.addEventListener("keydown", b), r?.addEventListener("click", () => {
|
|
1129
1167
|
n.value = "", this._renderOptions(""), r.hidden = !0, n.focus();
|
|
1130
1168
|
}), e.addEventListener("keydown", (e) => {
|
|
1131
|
-
if (
|
|
1169
|
+
if (m()) {
|
|
1132
1170
|
b(e);
|
|
1133
1171
|
return;
|
|
1134
1172
|
}
|
|
1135
|
-
(e.key === "ArrowDown" || e.key === "Enter" || e.key === " ") && (e.preventDefault(),
|
|
1173
|
+
(e.key === "ArrowDown" || e.key === "Enter" || e.key === " ") && (e.preventDefault(), h());
|
|
1136
1174
|
}), this._bindGlobal = () => {
|
|
1137
1175
|
this._teardown(), !this._ro && typeof ResizeObserver < "u" && (this._ro = new ResizeObserver(() => this._collapseChips()), this._ro.observe(this)), this._onDocClick = (e) => {
|
|
1138
|
-
|
|
1176
|
+
m() && !this.contains(e.target) && g();
|
|
1139
1177
|
}, document.addEventListener("click", this._onDocClick), a(this, () => {
|
|
1140
|
-
|
|
1178
|
+
m() && u();
|
|
1141
1179
|
});
|
|
1142
1180
|
}, this._bindGlobal();
|
|
1143
1181
|
}
|
|
1144
1182
|
_teardown() {
|
|
1145
|
-
this._onDocClick &&= (document.removeEventListener("click", this._onDocClick), null), o(this),
|
|
1183
|
+
this._onDocClick &&= (document.removeEventListener("click", this._onDocClick), null), o(this), this._navHandler?.teardown();
|
|
1146
1184
|
}
|
|
1147
1185
|
disconnectedCallback() {
|
|
1148
1186
|
this._teardown(), this._ro?.disconnect(), this._ro = null;
|
|
1149
1187
|
}
|
|
1150
|
-
},
|
|
1188
|
+
}, O = (e) => String(e ?? "").replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<"), k = (e) => String(e ?? "").replace(/<[^>]*>/g, ""), ne = /[^0-9]/g, re = /[^0-9a-zA-Z]/g, ie = class extends HTMLElement {
|
|
1151
1189
|
static formAssociated = !0;
|
|
1152
1190
|
static get observedAttributes() {
|
|
1153
1191
|
return [
|
|
@@ -1178,7 +1216,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
1178
1216
|
this._value = this._clean(e), c(this, this._value), this._paint();
|
|
1179
1217
|
}
|
|
1180
1218
|
_clean(e) {
|
|
1181
|
-
return (e == null ? "" : String(e)).replace(this.mode === "alphanumeric" ?
|
|
1219
|
+
return (e == null ? "" : String(e)).replace(this.mode === "alphanumeric" ? re : ne, "").slice(0, this.length);
|
|
1182
1220
|
}
|
|
1183
1221
|
constructor() {
|
|
1184
1222
|
super();
|
|
@@ -1258,7 +1296,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
1258
1296
|
disconnectedCallback() {
|
|
1259
1297
|
this._onSelectionChange && document.removeEventListener("selectionchange", this._onSelectionChange);
|
|
1260
1298
|
}
|
|
1261
|
-
},
|
|
1299
|
+
}, ae = [
|
|
1262
1300
|
[
|
|
1263
1301
|
"AF",
|
|
1264
1302
|
"Afghanistan",
|
|
@@ -2484,56 +2522,56 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
2484
2522
|
"Zimbabwe",
|
|
2485
2523
|
"263"
|
|
2486
2524
|
]
|
|
2487
|
-
],
|
|
2525
|
+
], A = (e) => (ae.find((t) => t[0] === e) || [
|
|
2488
2526
|
"",
|
|
2489
2527
|
"",
|
|
2490
2528
|
""
|
|
2491
|
-
])[2],
|
|
2492
|
-
function
|
|
2493
|
-
return
|
|
2529
|
+
])[2], j = (e) => `wui-flag wui-flag-${String(e).toLowerCase()}`, M = null, N = null;
|
|
2530
|
+
function oe() {
|
|
2531
|
+
return M ? Promise.resolve(M) : (N ||= Promise.all([import("./libphonenumber-js-BcNT8oq0.js"), import("./examples.mobile.json-BMXTGiGC.js")]).then(([e, t]) => (M = {
|
|
2494
2532
|
AsYouType: e.AsYouType,
|
|
2495
2533
|
getExampleNumber: e.getExampleNumber,
|
|
2496
2534
|
isValidPhoneNumber: e.isValidPhoneNumber,
|
|
2497
2535
|
examples: t.default || t
|
|
2498
|
-
},
|
|
2536
|
+
}, M)).catch(() => null), N);
|
|
2499
2537
|
}
|
|
2500
|
-
function
|
|
2501
|
-
if (!
|
|
2538
|
+
function P(e, t) {
|
|
2539
|
+
if (!M || !t) return t;
|
|
2502
2540
|
try {
|
|
2503
|
-
return new
|
|
2541
|
+
return new M.AsYouType(e).input(t);
|
|
2504
2542
|
} catch {
|
|
2505
2543
|
return t;
|
|
2506
2544
|
}
|
|
2507
2545
|
}
|
|
2508
|
-
function
|
|
2509
|
-
if (!
|
|
2546
|
+
function F(e) {
|
|
2547
|
+
if (!M) return null;
|
|
2510
2548
|
try {
|
|
2511
|
-
return
|
|
2549
|
+
return M.getExampleNumber(e, M.examples)?.formatNational() || null;
|
|
2512
2550
|
} catch {
|
|
2513
2551
|
return null;
|
|
2514
2552
|
}
|
|
2515
2553
|
}
|
|
2516
|
-
function
|
|
2517
|
-
if (!
|
|
2554
|
+
function I(e) {
|
|
2555
|
+
if (!M || !e) return null;
|
|
2518
2556
|
try {
|
|
2519
|
-
return
|
|
2557
|
+
return M.isValidPhoneNumber(e);
|
|
2520
2558
|
} catch {
|
|
2521
2559
|
return null;
|
|
2522
2560
|
}
|
|
2523
2561
|
}
|
|
2524
|
-
function
|
|
2525
|
-
if (!
|
|
2562
|
+
function se(e) {
|
|
2563
|
+
if (!M) return null;
|
|
2526
2564
|
try {
|
|
2527
|
-
let t =
|
|
2565
|
+
let t = M.getExampleNumber(e, M.examples);
|
|
2528
2566
|
return t?.nationalNumber ? t.nationalNumber.length : null;
|
|
2529
2567
|
} catch {
|
|
2530
2568
|
return null;
|
|
2531
2569
|
}
|
|
2532
2570
|
}
|
|
2533
|
-
function
|
|
2534
|
-
if (!
|
|
2571
|
+
function L(e) {
|
|
2572
|
+
if (!M || !e?.trim().startsWith("+")) return null;
|
|
2535
2573
|
try {
|
|
2536
|
-
let t = new
|
|
2574
|
+
let t = new M.AsYouType();
|
|
2537
2575
|
t.input(e.trim());
|
|
2538
2576
|
let n = t.getCountry();
|
|
2539
2577
|
return n ? {
|
|
@@ -2544,7 +2582,7 @@ function B(e) {
|
|
|
2544
2582
|
return null;
|
|
2545
2583
|
}
|
|
2546
2584
|
}
|
|
2547
|
-
var
|
|
2585
|
+
var R = class extends HTMLElement {
|
|
2548
2586
|
static formAssociated = !0;
|
|
2549
2587
|
static get observedAttributes() {
|
|
2550
2588
|
return [
|
|
@@ -2584,13 +2622,13 @@ var V = class extends HTMLElement {
|
|
|
2584
2622
|
this.value = this._defaultValue || "";
|
|
2585
2623
|
}
|
|
2586
2624
|
get value() {
|
|
2587
|
-
return this._national ? `+${
|
|
2625
|
+
return this._national ? `+${A(this._country)}${this._national}` : "";
|
|
2588
2626
|
}
|
|
2589
2627
|
set value(e) {
|
|
2590
|
-
let t = String(e ?? "").trim(), n =
|
|
2628
|
+
let t = String(e ?? "").trim(), n = L(t);
|
|
2591
2629
|
if (n) this._country = n.country, this._national = n.national.replace(/[^0-9]/g, "");
|
|
2592
2630
|
else if (t.startsWith("+")) {
|
|
2593
|
-
let e = t.replace(/[^0-9]/g, ""), n = String(
|
|
2631
|
+
let e = t.replace(/[^0-9]/g, ""), n = String(A(this._country));
|
|
2594
2632
|
n && e.startsWith(n) && (e = e.slice(n.length)), this._national = e;
|
|
2595
2633
|
} else this._national = t.replace(/[^0-9]/g, "");
|
|
2596
2634
|
n && this.getAttribute("country") !== this._country ? this.setAttribute("country", this._country) : this._rendered && this.render(), this._committedValue = this.value, this._syncMirror();
|
|
@@ -2606,25 +2644,25 @@ var V = class extends HTMLElement {
|
|
|
2606
2644
|
}
|
|
2607
2645
|
render() {
|
|
2608
2646
|
this._defaultValue === void 0 && (this._defaultValue = this.getAttribute("value") || ""), this._country = this.getAttribute("country") || this._country;
|
|
2609
|
-
let e = this.getAttribute("placeholder") ||
|
|
2647
|
+
let e = this.getAttribute("placeholder") || F(this._country) || "Enter phone number";
|
|
2610
2648
|
this.id ||= `wui-phone-${Math.random().toString(36).slice(2, 9)}`;
|
|
2611
2649
|
let t = `${this.id}-listbox`;
|
|
2612
2650
|
this._listboxId = t;
|
|
2613
|
-
let n =
|
|
2651
|
+
let n = ae.map(([e, n, r], i) => `<button type="button" role="option" id="${z(`${t}-opt-${i}`)}" class="country-dropdown-item${e === this._country ? " selected" : ""}" data-iso="${e}" aria-selected="${e === this._country}"><span class="${j(e)}" aria-hidden="true"></span><span class="country-name-text">${n}<span class="country-code-text">+${r}</span></span></button>`).join("");
|
|
2614
2652
|
this.innerHTML = `
|
|
2615
2653
|
<div class="phone-input-wrap">
|
|
2616
2654
|
<div class="phone-country-adornment">
|
|
2617
|
-
<button type="button" class="country-toggle" aria-haspopup="listbox" aria-expanded="false" aria-controls="${
|
|
2618
|
-
<span class="${
|
|
2655
|
+
<button type="button" class="country-toggle" aria-haspopup="listbox" aria-expanded="false" aria-controls="${z(t)}"${this.hasAttribute("disabled") ? " disabled" : ""}>
|
|
2656
|
+
<span class="${j(this._country)}" data-flag aria-hidden="true"></span>
|
|
2619
2657
|
<i class="bi bi-chevron-down phone-chevron" aria-hidden="true"></i>
|
|
2620
|
-
<span class="phone-dial" data-dial>+${
|
|
2658
|
+
<span class="phone-dial" data-dial>+${A(this._country)}</span>
|
|
2621
2659
|
</button>
|
|
2622
|
-
<div class="country-dropdown-menu" role="listbox" id="${
|
|
2623
|
-
<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" aria-controls="${
|
|
2660
|
+
<div class="country-dropdown-menu" role="listbox" id="${z(t)}" tabindex="-1" hidden>
|
|
2661
|
+
<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" aria-controls="${z(t)}" aria-autocomplete="list" /></div>
|
|
2624
2662
|
<div class="country-list-scroll">${n}<div class="country-empty" hidden>No countries found</div></div>
|
|
2625
2663
|
</div>
|
|
2626
2664
|
</div>
|
|
2627
|
-
<input type="tel" class="input" placeholder="${
|
|
2665
|
+
<input type="tel" class="input" placeholder="${z(e)}" value="${z(P(this._country, this._national))}"${this.getAttribute("aria-label") ? ` aria-label="${z(this.getAttribute("aria-label"))}"` : ""}${this.getAttribute("aria-describedby") ? ` aria-describedby="${z(this.getAttribute("aria-describedby"))}"` : ""}${this.hasAttribute("required") ? " required aria-required=\"true\"" : ""}${this.hasAttribute("disabled") ? " disabled" : ""} />
|
|
2628
2666
|
</div>
|
|
2629
2667
|
<div class="field-error" data-phone-error hidden></div>`, this._rendered = !0, c(this, this.value), this._wire();
|
|
2630
2668
|
}
|
|
@@ -2655,12 +2693,12 @@ var V = class extends HTMLElement {
|
|
|
2655
2693
|
}
|
|
2656
2694
|
c && (c.hidden = n > 0);
|
|
2657
2695
|
}, v = (e) => {
|
|
2658
|
-
this._country = e, this.getAttribute("country") !== e && (this._suppressCountryRender = !0, this.setAttribute("country", e), this._suppressCountryRender = !1), u && (u.className =
|
|
2696
|
+
this._country = e, this.getAttribute("country") !== e && (this._suppressCountryRender = !0, this.setAttribute("country", e), this._suppressCountryRender = !1), u && (u.className = j(e)), d && (d.textContent = `+${A(e)}`);
|
|
2659
2697
|
for (let t of this._itemEls()) {
|
|
2660
2698
|
let n = t.dataset.iso === e;
|
|
2661
2699
|
t.classList.toggle("selected", n), t.setAttribute("aria-selected", String(n));
|
|
2662
2700
|
}
|
|
2663
|
-
!this.getAttribute("placeholder") && l && (l.placeholder =
|
|
2701
|
+
!this.getAttribute("placeholder") && l && (l.placeholder = F(e) || "Enter phone number"), l && this._national && (l.value = P(e, this._national)), g(), this._syncMirror(), this._emitChange(), l?.focus();
|
|
2664
2702
|
}, y = (t) => {
|
|
2665
2703
|
let n = this._visibleItems();
|
|
2666
2704
|
if (t.key === "ArrowDown") {
|
|
@@ -2694,7 +2732,7 @@ var V = class extends HTMLElement {
|
|
|
2694
2732
|
let b = this.querySelector("[data-phone-error]"), x = (e) => {
|
|
2695
2733
|
if (l.classList.toggle("is-invalid", e), e ? l.setAttribute("aria-invalid", "true") : l.removeAttribute("aria-invalid"), b) {
|
|
2696
2734
|
if (e) {
|
|
2697
|
-
let e =
|
|
2735
|
+
let e = F(this._country);
|
|
2698
2736
|
b.textContent = e ? `Enter a valid phone number, e.g. ${e}` : "Enter a valid phone number";
|
|
2699
2737
|
}
|
|
2700
2738
|
b.hidden = !e;
|
|
@@ -2702,15 +2740,15 @@ var V = class extends HTMLElement {
|
|
|
2702
2740
|
};
|
|
2703
2741
|
l.addEventListener("input", (e) => {
|
|
2704
2742
|
e.stopPropagation();
|
|
2705
|
-
let t = l.value.replace(/[^0-9]/g, ""), n =
|
|
2743
|
+
let t = l.value.replace(/[^0-9]/g, ""), n = se(this._country);
|
|
2706
2744
|
n && t.length > n && (t = t.slice(0, n)), this._national = t;
|
|
2707
|
-
let r =
|
|
2708
|
-
l.value !== r && (l.value = r), this._syncMirror(), this._emitInput(), l.classList.contains("is-invalid") && (!this._national ||
|
|
2745
|
+
let r = P(this._country, this._national);
|
|
2746
|
+
l.value !== r && (l.value = r), this._syncMirror(), this._emitInput(), l.classList.contains("is-invalid") && (!this._national || I(this.value) === !0) && x(!1);
|
|
2709
2747
|
}), l.addEventListener("change", (e) => e.stopPropagation()), l.addEventListener("blur", () => {
|
|
2710
|
-
x(this._national.length > 0 &&
|
|
2748
|
+
x(this._national.length > 0 && I(this.value) === !1), this.value !== this._committedValue && this._emitChange();
|
|
2711
2749
|
}), l.addEventListener("paste", (e) => {
|
|
2712
|
-
let t =
|
|
2713
|
-
t && (e.preventDefault(), this._national = t.national.replace(/[^0-9]/g, ""), t.country === this._country ? l.value =
|
|
2750
|
+
let t = L(e.clipboardData?.getData("text"));
|
|
2751
|
+
t && (e.preventDefault(), this._national = t.national.replace(/[^0-9]/g, ""), t.country === this._country ? l.value = P(this._country, this._national) : this.setAttribute("country", t.country), this._syncMirror(), this._emitInput(), this._emitChange(), this.querySelector("input[type=tel]")?.focus());
|
|
2714
2752
|
}), this._bindGlobal = () => {
|
|
2715
2753
|
this._teardownGlobals?.(), this._onDocClick = (e) => {
|
|
2716
2754
|
f() && !this.contains(e.target) && g();
|
|
@@ -2719,9 +2757,9 @@ var V = class extends HTMLElement {
|
|
|
2719
2757
|
});
|
|
2720
2758
|
}, this._teardownGlobals = () => {
|
|
2721
2759
|
this._onDocClick &&= (document.removeEventListener("click", this._onDocClick), null), o(this);
|
|
2722
|
-
}, this._bindGlobal(),
|
|
2723
|
-
if (!(!e || !l.isConnected) && (this._national && (l.value =
|
|
2724
|
-
let e =
|
|
2760
|
+
}, this._bindGlobal(), oe().then((e) => {
|
|
2761
|
+
if (!(!e || !l.isConnected) && (this._national && (l.value = P(this._country, this._national)), !this.getAttribute("placeholder"))) {
|
|
2762
|
+
let e = F(this._country);
|
|
2725
2763
|
e && (l.placeholder = e);
|
|
2726
2764
|
}
|
|
2727
2765
|
}), this._syncMirror();
|
|
@@ -2732,7 +2770,7 @@ var V = class extends HTMLElement {
|
|
|
2732
2770
|
disconnectedCallback() {
|
|
2733
2771
|
this._teardown();
|
|
2734
2772
|
}
|
|
2735
|
-
},
|
|
2773
|
+
}, z = (e) => String(e ?? "").replace(/"/g, """).replace(/</g, "<"), B = class extends HTMLElement {
|
|
2736
2774
|
static formAssociated = !0;
|
|
2737
2775
|
static get observedAttributes() {
|
|
2738
2776
|
return [
|
|
@@ -2797,7 +2835,7 @@ var V = class extends HTMLElement {
|
|
|
2797
2835
|
value: e.getAttribute("value") ?? e.textContent.trim(),
|
|
2798
2836
|
label: e.innerHTML,
|
|
2799
2837
|
icon: e.getAttribute("icon") || void 0,
|
|
2800
|
-
[
|
|
2838
|
+
[u]: !0,
|
|
2801
2839
|
selected: e.hasAttribute("selected")
|
|
2802
2840
|
})));
|
|
2803
2841
|
}
|
|
@@ -2806,25 +2844,25 @@ var V = class extends HTMLElement {
|
|
|
2806
2844
|
}
|
|
2807
2845
|
render() {
|
|
2808
2846
|
this._defaultValue === void 0 && (this._defaultValue = this.getAttribute("value") || ""), this._snapshotDeclared();
|
|
2809
|
-
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...",
|
|
2810
|
-
|
|
2811
|
-
let
|
|
2812
|
-
this._listboxId =
|
|
2847
|
+
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...", u = e.find((e) => String(e.value) === String(this._value)) || e.find((e) => e.selected);
|
|
2848
|
+
u && (this._value = String(u.value)), c(this, this._value), this.id ||= `wui-select-${Math.random().toString(36).slice(2, 9)}`;
|
|
2849
|
+
let f = `${this.id}-listbox`;
|
|
2850
|
+
this._listboxId = f;
|
|
2813
2851
|
let m = e.map((e, t) => {
|
|
2814
2852
|
let n = String(e.value) === String(this._value);
|
|
2815
|
-
return `<button type="button" role="option" id="${
|
|
2853
|
+
return `<button type="button" role="option" id="${V(`${f}-opt-${t}`)}" class="search-select-option${n ? " selected" : ""}" data-value="${V(e.value)}" aria-selected="${n}">${p(e)}</button>`;
|
|
2816
2854
|
}).join("");
|
|
2817
2855
|
this.innerHTML = `
|
|
2818
2856
|
<div class="search-select${this.hasAttribute("compact") ? " search-select-compact" : ""}${i}">
|
|
2819
|
-
<button type="button" role="combobox" class="input search-select-control" aria-haspopup="listbox" aria-expanded="false" aria-controls="${
|
|
2820
|
-
${a ? `<i class="bi bi-${
|
|
2821
|
-
${o ? `<span class="search-select-prefix">${
|
|
2822
|
-
<span class="${
|
|
2857
|
+
<button type="button" role="combobox" class="input search-select-control" aria-haspopup="listbox" aria-expanded="false" aria-controls="${V(f)}" aria-label="${V(this._accessibleName())}"${this.hasAttribute("disabled") ? " disabled" : ""}>
|
|
2858
|
+
${a ? `<i class="bi bi-${V(a)} search-select-icon" aria-hidden="true"></i>` : ""}
|
|
2859
|
+
${o ? `<span class="search-select-prefix">${d(o)}</span>` : ""}
|
|
2860
|
+
<span class="${u ? "" : "search-select-placeholder"}" data-label>${u ? p(u) : d(s)}</span>
|
|
2823
2861
|
${n ? "<span class=\"search-select-reset\" role=\"button\" aria-label=\"Clear selection\" hidden><i class=\"bi bi-x-lg\" aria-hidden=\"true\"></i></span>" : ""}
|
|
2824
2862
|
<i class="bi bi-chevron-down search-select-caret" aria-hidden="true"></i>
|
|
2825
2863
|
</button>
|
|
2826
|
-
<div class="search-select-menu search-select-menu-fixed" role="listbox" id="${
|
|
2827
|
-
${t ? `<div class="search-select-search"><i class="bi bi-search" aria-hidden="true"></i><input class="search-select-input" placeholder="${
|
|
2864
|
+
<div class="search-select-menu search-select-menu-fixed" role="listbox" id="${V(f)}" tabindex="-1" hidden>
|
|
2865
|
+
${t ? `<div class="search-select-search"><i class="bi bi-search" aria-hidden="true"></i><input class="search-select-input" placeholder="${V(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>` : ""}
|
|
2828
2866
|
<div class="search-select-options">${m}<div class="search-select-empty" hidden>No matches</div></div>
|
|
2829
2867
|
</div>
|
|
2830
2868
|
</div>`, this._rendered = !0, c(this, this._value), this._wire(), this._syncReset();
|
|
@@ -2853,7 +2891,7 @@ var V = class extends HTMLElement {
|
|
|
2853
2891
|
let t = e.dataset.value === String(this._value);
|
|
2854
2892
|
e.classList.toggle("selected", t), e.setAttribute("aria-selected", String(t));
|
|
2855
2893
|
}
|
|
2856
|
-
e && (e.innerHTML = t ?
|
|
2894
|
+
e && (e.innerHTML = t ? p(t) : d(this.getAttribute("placeholder") || "Select..."), e.classList.toggle("search-select-placeholder", !t));
|
|
2857
2895
|
}
|
|
2858
2896
|
_syncReset() {
|
|
2859
2897
|
let { reset: e } = this._refs();
|
|
@@ -2883,44 +2921,31 @@ var V = class extends HTMLElement {
|
|
|
2883
2921
|
}, o = () => !e.menu.hidden, s = () => {
|
|
2884
2922
|
e.menu.hidden = !1, e.control.setAttribute("aria-expanded", "true"), e.control.classList.add("open"), t(), e.search && (e.search.value = "", r(""), e.search.focus()), n(this._optionEls().findIndex((e) => e.classList.contains("selected")));
|
|
2885
2923
|
}, c = () => {
|
|
2886
|
-
e.menu.hidden = !0, e.control.setAttribute("aria-expanded", "false"), e.control.classList.remove("open"), n(-1)
|
|
2887
|
-
},
|
|
2924
|
+
e.menu.hidden = !0, e.control.setAttribute("aria-expanded", "false"), e.control.classList.remove("open"), n(-1);
|
|
2925
|
+
}, u = (t) => {
|
|
2888
2926
|
this.value = t.dataset.value, this.dispatchEvent(new Event("change", { bubbles: !0 })), c(), e.control.focus();
|
|
2889
|
-
}, u = () => {
|
|
2890
|
-
clearTimeout(this._typeaheadTimer), this._typeaheadTimer = null, this._typeahead = "";
|
|
2891
|
-
}, d = (t) => {
|
|
2892
|
-
let r = this._visible(), i = t.target?.tagName === "INPUT" || t.target?.tagName === "TEXTAREA";
|
|
2893
|
-
if (t.key === "ArrowDown") t.preventDefault(), n(Math.min(this._active + 1, r.length - 1));
|
|
2894
|
-
else if (t.key === "ArrowUp") t.preventDefault(), n(Math.max(this._active - 1, 0));
|
|
2895
|
-
else if (t.key === "Home" && !i) t.preventDefault(), r.length && n(0);
|
|
2896
|
-
else if (t.key === "End" && !i) t.preventDefault(), r.length && n(r.length - 1);
|
|
2897
|
-
else if (t.key === "PageDown" && !i) {
|
|
2898
|
-
if (t.preventDefault(), !r.length) return;
|
|
2899
|
-
let e = this._active < 0 ? 0 : this._active;
|
|
2900
|
-
n(Math.min(e + 8, r.length - 1));
|
|
2901
|
-
} else if (t.key === "PageUp" && !i) {
|
|
2902
|
-
if (t.preventDefault(), !r.length) return;
|
|
2903
|
-
let e = this._active < 0 ? 0 : this._active;
|
|
2904
|
-
n(Math.max(e - 8, 0));
|
|
2905
|
-
} else if (t.key === "Enter") t.preventDefault(), r[this._active] && l(r[this._active]);
|
|
2906
|
-
else if (t.key === "Escape") c(), e.control.focus();
|
|
2907
|
-
else if (t.key.length === 1 && !t.ctrlKey && !t.metaKey && !t.altKey && t.target?.tagName !== "INPUT" && t.target?.tagName !== "TEXTAREA") {
|
|
2908
|
-
t.preventDefault(), clearTimeout(this._typeaheadTimer), this._typeahead += t.key.toLowerCase(), this._typeaheadTimer = setTimeout(u, 500);
|
|
2909
|
-
let e = r.findIndex((e) => e.textContent.trim().toLowerCase().startsWith(this._typeahead));
|
|
2910
|
-
e >= 0 && n(e);
|
|
2911
|
-
}
|
|
2912
2927
|
};
|
|
2913
|
-
|
|
2928
|
+
this._navHandler = l({
|
|
2929
|
+
getVisibleOptions: () => this._visible(),
|
|
2930
|
+
getActive: () => this._active,
|
|
2931
|
+
setActive: (e) => n(e),
|
|
2932
|
+
onEnter: (e) => {
|
|
2933
|
+
e && u(e);
|
|
2934
|
+
},
|
|
2935
|
+
onEscape: () => {
|
|
2936
|
+
this._navHandler.clearTypeahead(), c(), e.control.focus();
|
|
2937
|
+
}
|
|
2938
|
+
}), e.reset?.addEventListener("click", (t) => {
|
|
2914
2939
|
t.stopPropagation(), this.value = "", this.dispatchEvent(new Event("change", { bubbles: !0 })), e.control.focus();
|
|
2915
2940
|
}), e.control.addEventListener("click", () => o() ? c() : s()), e.control.addEventListener("keydown", (e) => {
|
|
2916
2941
|
if (o()) {
|
|
2917
|
-
|
|
2942
|
+
this._navHandler.handler(e);
|
|
2918
2943
|
return;
|
|
2919
2944
|
}
|
|
2920
2945
|
(e.key === "ArrowDown" || e.key === "Enter" || e.key === " ") && (e.preventDefault(), s());
|
|
2921
2946
|
}), e.optionsWrap.addEventListener("click", (e) => {
|
|
2922
2947
|
let t = e.target.closest(".search-select-option");
|
|
2923
|
-
t &&
|
|
2948
|
+
t && u(t);
|
|
2924
2949
|
}), e.optionsWrap.addEventListener("mousemove", (e) => {
|
|
2925
2950
|
let t = e.target.closest(".search-select-option");
|
|
2926
2951
|
t && n(this._visible().indexOf(t));
|
|
@@ -2928,7 +2953,7 @@ var V = class extends HTMLElement {
|
|
|
2928
2953
|
r(e.search.value), n(-1);
|
|
2929
2954
|
}), e.clear?.addEventListener("click", () => {
|
|
2930
2955
|
e.search.value = "", r(""), e.search.focus();
|
|
2931
|
-
}), e.menu.addEventListener("keydown",
|
|
2956
|
+
}), e.menu.addEventListener("keydown", this._navHandler.handler), this._bindGlobal = () => {
|
|
2932
2957
|
this._teardown(), this._onDocClick = (e) => {
|
|
2933
2958
|
o() && !this.contains(e.target) && c();
|
|
2934
2959
|
}, document.addEventListener("click", this._onDocClick), a(this, () => {
|
|
@@ -2937,12 +2962,12 @@ var V = class extends HTMLElement {
|
|
|
2937
2962
|
}, this._bindGlobal();
|
|
2938
2963
|
}
|
|
2939
2964
|
_teardown() {
|
|
2940
|
-
this._onDocClick &&= (document.removeEventListener("click", this._onDocClick), null), o(this),
|
|
2965
|
+
this._onDocClick &&= (document.removeEventListener("click", this._onDocClick), null), o(this), this._navHandler?.teardown();
|
|
2941
2966
|
}
|
|
2942
2967
|
disconnectedCallback() {
|
|
2943
2968
|
this._teardown();
|
|
2944
2969
|
}
|
|
2945
|
-
},
|
|
2970
|
+
}, V = (e) => String(e ?? "").replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<"), H = class extends HTMLElement {
|
|
2946
2971
|
static formAssociated = !0;
|
|
2947
2972
|
static get observedAttributes() {
|
|
2948
2973
|
return [
|
|
@@ -2982,19 +3007,19 @@ var V = class extends HTMLElement {
|
|
|
2982
3007
|
return this._value;
|
|
2983
3008
|
}
|
|
2984
3009
|
set value(e) {
|
|
2985
|
-
this._value = this._snapToStep(this._clamp(
|
|
3010
|
+
this._value = this._snapToStep(this._clamp(U(e, this._value))), this._syncValue(), this._syncMirrors();
|
|
2986
3011
|
}
|
|
2987
3012
|
get start() {
|
|
2988
3013
|
return this._start;
|
|
2989
3014
|
}
|
|
2990
3015
|
set start(e) {
|
|
2991
|
-
this._start = Math.min(this._snapToStep(this._clamp(
|
|
3016
|
+
this._start = Math.min(this._snapToStep(this._clamp(U(e, this._start))), this._end), this._syncValue(), this._syncMirrors();
|
|
2992
3017
|
}
|
|
2993
3018
|
get end() {
|
|
2994
3019
|
return this._end;
|
|
2995
3020
|
}
|
|
2996
3021
|
set end(e) {
|
|
2997
|
-
this._end = Math.max(this._snapToStep(this._clamp(
|
|
3022
|
+
this._end = Math.max(this._snapToStep(this._clamp(U(e, this._end))), this._start), this._syncValue(), this._syncMirrors();
|
|
2998
3023
|
}
|
|
2999
3024
|
attributeChangedCallback(e, t, n) {
|
|
3000
3025
|
if (e === "value" || e === "start" || e === "end" || e === "min" || e === "max" || e === "step") {
|
|
@@ -3007,19 +3032,19 @@ var V = class extends HTMLElement {
|
|
|
3007
3032
|
this._isRange() ? this._resetRange() : this._resetSingle();
|
|
3008
3033
|
}
|
|
3009
3034
|
_updateFromAttribute(e) {
|
|
3010
|
-
e === "value" ? this._value = this._snapToStep(this._clamp(
|
|
3035
|
+
e === "value" ? this._value = this._snapToStep(this._clamp(U(this.getAttribute("value"), this._value))) : e === "start" ? this._start = this._snapToStep(this._clamp(U(this.getAttribute("start"), this._start))) : e === "end" && (this._end = this._snapToStep(this._clamp(U(this.getAttribute("end"), this._end))));
|
|
3011
3036
|
}
|
|
3012
3037
|
_isRange() {
|
|
3013
3038
|
return this.hasAttribute("range");
|
|
3014
3039
|
}
|
|
3015
3040
|
_min() {
|
|
3016
|
-
return
|
|
3041
|
+
return U(this.getAttribute("min"), 0);
|
|
3017
3042
|
}
|
|
3018
3043
|
_max() {
|
|
3019
|
-
return
|
|
3044
|
+
return U(this.getAttribute("max"), 100);
|
|
3020
3045
|
}
|
|
3021
3046
|
_step() {
|
|
3022
|
-
return
|
|
3047
|
+
return U(this.getAttribute("step"), 1);
|
|
3023
3048
|
}
|
|
3024
3049
|
_clamp(e) {
|
|
3025
3050
|
return Math.max(this._min(), Math.min(e, this._max()));
|
|
@@ -3084,7 +3109,7 @@ var V = class extends HTMLElement {
|
|
|
3084
3109
|
aria-valuenow="${this._value}"
|
|
3085
3110
|
aria-valuetext="${this._formatValue(this._value)}"
|
|
3086
3111
|
${a ? "disabled" : ""}
|
|
3087
|
-
aria-label="${
|
|
3112
|
+
aria-label="${ce(this.getAttribute("aria-label") || "Value")}"
|
|
3088
3113
|
></button>
|
|
3089
3114
|
`}
|
|
3090
3115
|
${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>` : ""}
|
|
@@ -3184,10 +3209,10 @@ var V = class extends HTMLElement {
|
|
|
3184
3209
|
disconnectedCallback() {
|
|
3185
3210
|
this._teardown();
|
|
3186
3211
|
}
|
|
3187
|
-
},
|
|
3212
|
+
}, U = (e, t) => {
|
|
3188
3213
|
let n = Number.parseFloat(e);
|
|
3189
3214
|
return Number.isFinite(n) ? n : t;
|
|
3190
|
-
},
|
|
3215
|
+
}, ce = (e) => String(e ?? "").replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<"), W = class extends HTMLElement {
|
|
3191
3216
|
static formAssociated = !0;
|
|
3192
3217
|
_accessibleName() {
|
|
3193
3218
|
return this.getAttribute("aria-label") || this.getAttribute("placeholder") || "Add tags";
|
|
@@ -3251,8 +3276,8 @@ var V = class extends HTMLElement {
|
|
|
3251
3276
|
c(this, this._values.join(",")), this.innerHTML = `
|
|
3252
3277
|
<div class="search-select${t}">
|
|
3253
3278
|
<div class="input search-select-control search-select-multi"${this.hasAttribute("disabled") ? " aria-disabled=\"true\"" : ""}>
|
|
3279
|
+
<input type="text" class="ms-input" data-input aria-label="${G(this._accessibleName())}" placeholder="${G(this.getAttribute("placeholder") || "Add…")}" autocomplete="off"${this.hasAttribute("disabled") ? " disabled" : ""}/>
|
|
3254
3280
|
<div class="ms-chips" data-chips></div>
|
|
3255
|
-
<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" : ""}/>
|
|
3256
3281
|
</div>
|
|
3257
3282
|
</div>`, this._rendered = !0, c(this, this._values.join(",")), this._renderControl(), this._wire();
|
|
3258
3283
|
}
|
|
@@ -3263,7 +3288,7 @@ var V = class extends HTMLElement {
|
|
|
3263
3288
|
e.innerHTML = "";
|
|
3264
3289
|
return;
|
|
3265
3290
|
}
|
|
3266
|
-
e.innerHTML = this._values.map((e) => `<span class="chip chip-sm"><span class="chip-label">${
|
|
3291
|
+
e.innerHTML = this._values.map((e) => `<span class="chip chip-sm"><span class="chip-label">${le(e)}</span><button type="button" class="chip-remove" data-remove="${G(e)}" aria-label="Remove ${G(e)}"><i class="bi bi-x" aria-hidden="true"></i></button></span>`).join("");
|
|
3267
3292
|
}
|
|
3268
3293
|
}
|
|
3269
3294
|
_wire() {
|
|
@@ -3334,18 +3359,18 @@ var V = class extends HTMLElement {
|
|
|
3334
3359
|
disconnectedCallback() {
|
|
3335
3360
|
this._teardown();
|
|
3336
3361
|
}
|
|
3337
|
-
},
|
|
3362
|
+
}, le = (e) => String(e ?? "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">"), G = (e) => String(e ?? "").replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<"), K = (e) => String(e).padStart(2, "0"), q = (e, t) => `${K(e)}:${K(t)}`, J = (e) => {
|
|
3338
3363
|
let t = /^(\d{2}):(\d{2})$/.exec(e || "");
|
|
3339
3364
|
return t ? {
|
|
3340
3365
|
h: +t[1],
|
|
3341
3366
|
m: +t[2]
|
|
3342
3367
|
} : null;
|
|
3343
|
-
},
|
|
3368
|
+
}, Y = (e, t = "24") => {
|
|
3344
3369
|
if (!e) return "";
|
|
3345
|
-
if (t === "24") return
|
|
3370
|
+
if (t === "24") return q(e.h, e.m);
|
|
3346
3371
|
let n = e.h % 12 || 12, r = e.h >= 12 ? "PM" : "AM";
|
|
3347
|
-
return `${n}:${
|
|
3348
|
-
},
|
|
3372
|
+
return `${n}:${K(e.m)} ${r}`;
|
|
3373
|
+
}, X = class extends HTMLElement {
|
|
3349
3374
|
static formAssociated = !0;
|
|
3350
3375
|
static get observedAttributes() {
|
|
3351
3376
|
return [
|
|
@@ -3392,11 +3417,11 @@ var V = class extends HTMLElement {
|
|
|
3392
3417
|
}
|
|
3393
3418
|
render() {
|
|
3394
3419
|
this._defaultValue === void 0 && (this._defaultValue = this.getAttribute("value") || "", this._value = this._defaultValue || this._value);
|
|
3395
|
-
let e = this.getAttribute("placeholder") || "Select time", t =
|
|
3420
|
+
let e = this.getAttribute("placeholder") || "Select time", t = J(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");
|
|
3396
3421
|
this.innerHTML = `
|
|
3397
3422
|
<div class="timepicker">
|
|
3398
|
-
<button type="button" class="input timepicker-trigger${i}${t ? " has-value" : ""}" aria-haspopup="listbox" aria-expanded="false"${this.hasAttribute("disabled") ? " disabled" : ""}${a ? ` aria-label="${
|
|
3399
|
-
<span data-trigger-label class="${t ? "" : "timepicker-placeholder"}">${t ?
|
|
3423
|
+
<button type="button" class="input timepicker-trigger${i}${t ? " has-value" : ""}" aria-haspopup="listbox" aria-expanded="false"${this.hasAttribute("disabled") ? " disabled" : ""}${a ? ` aria-label="${d(a)}"` : ""}${o ? ` aria-describedby="${d(o)}"` : ""}>
|
|
3424
|
+
<span data-trigger-label class="${t ? "" : "timepicker-placeholder"}">${t ? Y(t, n) : d(e)}</span>
|
|
3400
3425
|
<i class="bi bi-clock" aria-hidden="true"></i>
|
|
3401
3426
|
</button>
|
|
3402
3427
|
<div class="timepicker-pop" role="listbox" tabindex="-1" hidden></div>
|
|
@@ -3408,14 +3433,14 @@ var V = class extends HTMLElement {
|
|
|
3408
3433
|
_syncTrigger() {
|
|
3409
3434
|
let e = this.querySelector(".timepicker-trigger"), t = this.querySelector("[data-trigger-label]");
|
|
3410
3435
|
if (!t) return;
|
|
3411
|
-
let n =
|
|
3412
|
-
t.textContent = n ?
|
|
3436
|
+
let n = J(this._value), r = this.getAttribute("format") || "24";
|
|
3437
|
+
t.textContent = n ? Y(n, r) : this.getAttribute("placeholder") || "Select time", t.classList.toggle("timepicker-placeholder", !n), e?.classList.toggle("has-value", !!n);
|
|
3413
3438
|
}
|
|
3414
3439
|
_buildTimes() {
|
|
3415
|
-
let e = Math.max(1, parseInt(this.getAttribute("step") || "30", 10)), t = this.getAttribute("min") || "00:00", n = this.getAttribute("max") || "23:59", r =
|
|
3440
|
+
let e = Math.max(1, parseInt(this.getAttribute("step") || "30", 10)), t = this.getAttribute("min") || "00:00", n = this.getAttribute("max") || "23:59", r = J(t) || {
|
|
3416
3441
|
h: 0,
|
|
3417
3442
|
m: 0
|
|
3418
|
-
}, i =
|
|
3443
|
+
}, i = J(n) || {
|
|
3419
3444
|
h: 23,
|
|
3420
3445
|
m: 59
|
|
3421
3446
|
}, a = [], o = r.h, s = r.m;
|
|
@@ -3428,10 +3453,10 @@ var V = class extends HTMLElement {
|
|
|
3428
3453
|
_renderOptions() {
|
|
3429
3454
|
let e = this.querySelector(".timepicker-pop");
|
|
3430
3455
|
if (!e) return;
|
|
3431
|
-
let t = this.getAttribute("format") || "24", n = this._buildTimes(), r =
|
|
3456
|
+
let t = this.getAttribute("format") || "24", n = this._buildTimes(), r = J(this._value), i = this._focus, a = "";
|
|
3432
3457
|
for (let e = 0; e < n.length; e++) {
|
|
3433
|
-
let o = n[e], s =
|
|
3434
|
-
a += `<button type="button" class="timepicker-option${c ? " is-selected" : ""}" data-hm="${s}" role="option" tabindex="${i === e ? "0" : "-1"}"${c ? " aria-selected=\"true\"" : ""}>${
|
|
3458
|
+
let o = n[e], s = q(o.h, o.m), c = r && r.h === o.h && r.m === o.m;
|
|
3459
|
+
a += `<button type="button" class="timepicker-option${c ? " is-selected" : ""}" data-hm="${s}" role="option" tabindex="${i === e ? "0" : "-1"}"${c ? " aria-selected=\"true\"" : ""}>${Y(o, t)}</button>`;
|
|
3435
3460
|
}
|
|
3436
3461
|
e.innerHTML = a, this._focusActive();
|
|
3437
3462
|
}
|
|
@@ -3529,14 +3554,195 @@ var V = class extends HTMLElement {
|
|
|
3529
3554
|
disconnectedCallback() {
|
|
3530
3555
|
this._teardown();
|
|
3531
3556
|
}
|
|
3532
|
-
},
|
|
3557
|
+
}, ue = "wui-wizard-step", de = class extends HTMLElement {
|
|
3558
|
+
static get observedAttributes() {
|
|
3559
|
+
return [
|
|
3560
|
+
"active",
|
|
3561
|
+
"variant",
|
|
3562
|
+
"orientation",
|
|
3563
|
+
"non-linear",
|
|
3564
|
+
"hide-stepper",
|
|
3565
|
+
"disabled",
|
|
3566
|
+
"skippable",
|
|
3567
|
+
"label",
|
|
3568
|
+
"back-label",
|
|
3569
|
+
"next-label",
|
|
3570
|
+
"skip-label",
|
|
3571
|
+
"finish-label"
|
|
3572
|
+
];
|
|
3573
|
+
}
|
|
3574
|
+
constructor() {
|
|
3575
|
+
super(), this._active = 0, this._skipped = /* @__PURE__ */ new Set(), this._invalid = /* @__PURE__ */ new Set(), this._finished = !1, this._rendered = !1, this._reflecting = !1, this._beforeNext = null, this._header = null, this._footer = null;
|
|
3576
|
+
}
|
|
3577
|
+
get active() {
|
|
3578
|
+
return this._active;
|
|
3579
|
+
}
|
|
3580
|
+
set active(e) {
|
|
3581
|
+
let t = Number.parseInt(e, 10);
|
|
3582
|
+
Number.isFinite(t) && this._go(t, "set");
|
|
3583
|
+
}
|
|
3584
|
+
get beforeNext() {
|
|
3585
|
+
return this._beforeNext;
|
|
3586
|
+
}
|
|
3587
|
+
set beforeNext(e) {
|
|
3588
|
+
this._beforeNext = typeof e == "function" ? e : null;
|
|
3589
|
+
}
|
|
3590
|
+
get _steps() {
|
|
3591
|
+
return [...this.querySelectorAll(`:scope > ${ue}`)];
|
|
3592
|
+
}
|
|
3593
|
+
refresh() {
|
|
3594
|
+
this._rendered && this._renderChrome();
|
|
3595
|
+
}
|
|
3596
|
+
connectedCallback() {
|
|
3597
|
+
if (this._rendered) this._wire();
|
|
3598
|
+
else {
|
|
3599
|
+
let e = Number.parseInt(this.getAttribute("active"), 10);
|
|
3600
|
+
this._active = Number.isFinite(e) && e >= 0 ? e : 0, this.render();
|
|
3601
|
+
}
|
|
3602
|
+
}
|
|
3603
|
+
disconnectedCallback() {
|
|
3604
|
+
this._teardown();
|
|
3605
|
+
}
|
|
3606
|
+
attributeChangedCallback(e, t, n) {
|
|
3607
|
+
if (!(!this._rendered || this._reflecting)) {
|
|
3608
|
+
if (e === "active") {
|
|
3609
|
+
let e = Number.parseInt(n, 10);
|
|
3610
|
+
Number.isFinite(e) && e !== this._active && this._go(e, "set");
|
|
3611
|
+
return;
|
|
3612
|
+
}
|
|
3613
|
+
this._renderChrome();
|
|
3614
|
+
}
|
|
3615
|
+
}
|
|
3616
|
+
render() {
|
|
3617
|
+
let e = this._steps;
|
|
3618
|
+
this._header || (this._header = document.createElement("nav"), this._header.className = "stepper wizard-stepper", this._footer = document.createElement("div"), this._footer.className = "form-actions wizard-footer form-actions-between", e.length ? (this.insertBefore(this._header, e[0]), e[e.length - 1].after(this._footer)) : (this.prepend(this._header), this.append(this._footer))), this._renderChrome(), this._rendered = !0, this._wire();
|
|
3619
|
+
}
|
|
3620
|
+
_renderChrome() {
|
|
3621
|
+
let e = this._steps;
|
|
3622
|
+
this._clampActive(e), this._syncPanels(e), this._header.innerHTML = this._headerHtml(e), this._footer.innerHTML = this._footerHtml(e), this._header.hidden = this.hasAttribute("hide-stepper");
|
|
3623
|
+
}
|
|
3624
|
+
_clampActive(e) {
|
|
3625
|
+
let t = Math.max(0, e.length - 1);
|
|
3626
|
+
this._active > t && (this._active = t), this._active < 0 && (this._active = 0);
|
|
3627
|
+
}
|
|
3628
|
+
_syncPanels(e) {
|
|
3629
|
+
e.forEach((e, t) => {
|
|
3630
|
+
let n = t === this._active;
|
|
3631
|
+
e.classList.add("wizard-panel"), e.hidden = !n, e.setAttribute("role", "tabpanel"), e.setAttribute("aria-hidden", n ? "false" : "true");
|
|
3632
|
+
});
|
|
3633
|
+
}
|
|
3634
|
+
_stepStatus(e, t) {
|
|
3635
|
+
return e.getAttribute("status") || (this._invalid.has(t) ? "error" : this._finished ? "done" : t === this._active ? "active" : t < this._active ? this._skipped.has(t) ? "skipped" : "done" : "pending");
|
|
3636
|
+
}
|
|
3637
|
+
_headerHtml(e) {
|
|
3638
|
+
let t = this.getAttribute("variant") === "journey", n = this.getAttribute("variant") === "icons", r = this.getAttribute("orientation") === "vertical";
|
|
3639
|
+
this._header.className = [
|
|
3640
|
+
"stepper",
|
|
3641
|
+
"wizard-stepper",
|
|
3642
|
+
t && "stepper-journey",
|
|
3643
|
+
n && "stepper-icons",
|
|
3644
|
+
r && "stepper-vertical"
|
|
3645
|
+
].filter(Boolean).join(" "), this._header.setAttribute("aria-label", this.getAttribute("label") || "Progress");
|
|
3646
|
+
let i = this.hasAttribute("non-linear");
|
|
3647
|
+
return e.map((e, r) => {
|
|
3648
|
+
let a = this._stepStatus(e, r), o = e.getAttribute("label") || "", s = e.getAttribute("description") || "", c = e.getAttribute("icon") || "", l = r + 1, u;
|
|
3649
|
+
u = a === "done" ? "<i class=\"bi bi-check-lg\" aria-hidden=\"true\"></i>" : a === "error" ? "<i class=\"bi bi-exclamation-triangle\" aria-hidden=\"true\"></i>" : a === "skipped" ? "<i class=\"bi bi-dash-lg\" aria-hidden=\"true\"></i>" : c ? `<i class="bi bi-${fe(c)}" aria-hidden="true"></i>` : String(l);
|
|
3650
|
+
let d = a === "pending" ? "step" : `step ${a}`, f = a === "active" ? " aria-current=\"step\"" : "", p = i || r < this._active, m = s ? `<span class="step-desc">${Z(s)}</span>` : "", h;
|
|
3651
|
+
return h = t ? `<span class="step-circle">${u}</span><span class="step-text"><span class="step-index">Step ${l}</span><span class="step-label">${Z(o)}</span>${m}</span>` : n ? `<span class="step-circle">${u}</span><span class="step-index">Step ${l}</span><span class="step-label">${Z(o)}</span>${m}` : `<span class="step-circle">${u}</span><span class="step-label">${Z(o)}</span>${m}`, p ? `<button type="button" class="${d}" data-step="${r}"${f}>${h}</button>` : `<div class="${d}"${f}>${h}</div>`;
|
|
3652
|
+
}).join("");
|
|
3653
|
+
}
|
|
3654
|
+
_footerHtml(e) {
|
|
3655
|
+
let t = this._active, n = e.length - 1, r = this.hasAttribute("disabled") ? " disabled" : "", i = e[t]?.hasAttribute("optional") || this.hasAttribute("skippable"), a = this.getAttribute("back-label") || "Back", o = this.getAttribute("next-label") || "Next", s = this.getAttribute("skip-label") || "Skip", c = this.getAttribute("finish-label") || "Finish";
|
|
3656
|
+
return `${t > 0 ? `<button type="button" class="btn btn-ghost" data-nav="back"${r}>${Z(a)}</button>` : "<span></span>"}<span class="wizard-footer-actions">${i && t < n ? `<button type="button" class="btn btn-subtle" data-nav="skip"${r}>${Z(s)}</button>` : ""}${t < n ? `<button type="button" class="btn btn-primary" data-nav="next"${r}>${Z(o)}</button>` : `<button type="button" class="btn btn-primary" data-nav="finish"${r}>${Z(c)}</button>`}</span>`;
|
|
3657
|
+
}
|
|
3658
|
+
_wire() {
|
|
3659
|
+
this._teardown(), this._onHeaderClick = (e) => {
|
|
3660
|
+
let t = e.target.closest("[data-step]");
|
|
3661
|
+
t && this.contains(t) && this._stepTo(Number.parseInt(t.dataset.step, 10));
|
|
3662
|
+
}, this._onFooterClick = (e) => {
|
|
3663
|
+
let t = e.target.closest("[data-nav]");
|
|
3664
|
+
if (!t || !this.contains(t) || this.hasAttribute("disabled")) return;
|
|
3665
|
+
let n = t.dataset.nav;
|
|
3666
|
+
n === "back" ? this._back() : n === "skip" ? this._skip() : n === "next" ? this._next() : n === "finish" && this._finish();
|
|
3667
|
+
}, this._header.addEventListener("click", this._onHeaderClick), this._footer.addEventListener("click", this._onFooterClick);
|
|
3668
|
+
}
|
|
3669
|
+
_teardown() {
|
|
3670
|
+
this._header && this._onHeaderClick && this._header.removeEventListener("click", this._onHeaderClick), this._footer && this._onFooterClick && this._footer.removeEventListener("click", this._onFooterClick);
|
|
3671
|
+
}
|
|
3672
|
+
_stepTo(e) {
|
|
3673
|
+
this.hasAttribute("disabled") || !this.hasAttribute("non-linear") && e >= this._active || this._go(e, "step");
|
|
3674
|
+
}
|
|
3675
|
+
_back() {
|
|
3676
|
+
this._active > 0 && this._go(this._active - 1, "back");
|
|
3677
|
+
}
|
|
3678
|
+
async _next() {
|
|
3679
|
+
let e = this._active, t = this._steps;
|
|
3680
|
+
if (!this.dispatchEvent(new CustomEvent("wui-wizard:beforechange", {
|
|
3681
|
+
detail: {
|
|
3682
|
+
index: e,
|
|
3683
|
+
next: e + 1,
|
|
3684
|
+
reason: "next"
|
|
3685
|
+
},
|
|
3686
|
+
cancelable: !0
|
|
3687
|
+
}))) return this._flagInvalid(e);
|
|
3688
|
+
if (this._beforeNext) {
|
|
3689
|
+
let t;
|
|
3690
|
+
try {
|
|
3691
|
+
t = await this._beforeNext(e);
|
|
3692
|
+
} catch {
|
|
3693
|
+
t = !1;
|
|
3694
|
+
}
|
|
3695
|
+
if (t === !1) return this._flagInvalid(e);
|
|
3696
|
+
}
|
|
3697
|
+
if (this._invalid.delete(e), this._skipped.delete(e), e >= t.length - 1) return this._finish();
|
|
3698
|
+
this._go(e + 1, "next");
|
|
3699
|
+
}
|
|
3700
|
+
_skip() {
|
|
3701
|
+
let e = this._active, t = this._steps;
|
|
3702
|
+
if (!(!t[e]?.hasAttribute("optional") && !this.hasAttribute("skippable"))) {
|
|
3703
|
+
if (this._invalid.delete(e), this._skipped.add(e), this.dispatchEvent(new CustomEvent("wui-wizard:skip", { detail: { index: e } })), e >= t.length - 1) return this._finish();
|
|
3704
|
+
this._go(e + 1, "skip");
|
|
3705
|
+
}
|
|
3706
|
+
}
|
|
3707
|
+
_flagInvalid(e) {
|
|
3708
|
+
this._invalid.add(e), this._renderChrome(), this.dispatchEvent(new CustomEvent("wui-wizard:invalid", { detail: { index: e } }));
|
|
3709
|
+
}
|
|
3710
|
+
_finish() {
|
|
3711
|
+
this._invalid.delete(this._active), this._finished = !0, this._renderChrome(), this.dispatchEvent(new CustomEvent("wui-wizard:finish", { detail: { index: this._active } }));
|
|
3712
|
+
}
|
|
3713
|
+
_go(e, t) {
|
|
3714
|
+
let n = this._steps, r = Math.max(0, n.length - 1), i = Math.min(Math.max(e, 0), r), a = this._active;
|
|
3715
|
+
this._finished = !1, this._invalid.delete(a), this._active = i, this._reflectActive(i), this._renderChrome(), t !== "silent" && i !== a && this.dispatchEvent(new CustomEvent("wui-wizard:change", { detail: {
|
|
3716
|
+
index: i,
|
|
3717
|
+
previous: a,
|
|
3718
|
+
reason: t
|
|
3719
|
+
} }));
|
|
3720
|
+
}
|
|
3721
|
+
_reflectActive(e) {
|
|
3722
|
+
this._reflecting = !0, this.setAttribute("active", String(e)), this._reflecting = !1;
|
|
3723
|
+
}
|
|
3724
|
+
}, Z = (e) => String(e ?? "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">"), fe = (e) => String(e ?? "").replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """), pe = class extends HTMLElement {
|
|
3725
|
+
static get observedAttributes() {
|
|
3726
|
+
return [
|
|
3727
|
+
"label",
|
|
3728
|
+
"description",
|
|
3729
|
+
"optional",
|
|
3730
|
+
"icon",
|
|
3731
|
+
"status"
|
|
3732
|
+
];
|
|
3733
|
+
}
|
|
3734
|
+
attributeChangedCallback() {
|
|
3735
|
+
let e = this.closest("wui-wizard");
|
|
3736
|
+
e && typeof e.refresh == "function" && e.refresh();
|
|
3737
|
+
}
|
|
3738
|
+
}, me = "image/png,image/jpeg,image/webp", he = 5, ge = {
|
|
3533
3739
|
"image/png": [".png"],
|
|
3534
3740
|
"image/jpeg": [".jpg", ".jpeg"],
|
|
3535
3741
|
"image/webp": [".webp"],
|
|
3536
3742
|
"image/gif": [".gif"],
|
|
3537
3743
|
"image/svg+xml": [".svg"],
|
|
3538
3744
|
"application/pdf": [".pdf"]
|
|
3539
|
-
},
|
|
3745
|
+
}, _e = {
|
|
3540
3746
|
"image/png": "PNG",
|
|
3541
3747
|
"image/jpeg": "JPG",
|
|
3542
3748
|
"image/webp": "WEBP",
|
|
@@ -3550,7 +3756,7 @@ var V = class extends HTMLElement {
|
|
|
3550
3756
|
".gif": "GIF",
|
|
3551
3757
|
".svg": "SVG",
|
|
3552
3758
|
".pdf": "PDF"
|
|
3553
|
-
},
|
|
3759
|
+
}, Q = (e) => String(e || "").split(",").map((e) => e.trim().toLowerCase()).filter(Boolean), ve = [
|
|
3554
3760
|
".png",
|
|
3555
3761
|
".jpg",
|
|
3556
3762
|
".jpeg",
|
|
@@ -3561,44 +3767,44 @@ var V = class extends HTMLElement {
|
|
|
3561
3767
|
".avif",
|
|
3562
3768
|
".heic"
|
|
3563
3769
|
];
|
|
3564
|
-
function
|
|
3770
|
+
function ye(e) {
|
|
3565
3771
|
if (!e) return !1;
|
|
3566
3772
|
let t = typeof e == "object" && e.type ? String(e.type).toLowerCase() : "";
|
|
3567
3773
|
if (t) return t.startsWith("image/");
|
|
3568
3774
|
let n = typeof e == "string" ? e : e.name || e.url || "", r = String(n).toLowerCase();
|
|
3569
|
-
return
|
|
3775
|
+
return ve.some((e) => r.endsWith(e));
|
|
3570
3776
|
}
|
|
3571
|
-
function
|
|
3572
|
-
let t =
|
|
3573
|
-
return t.length ? t.every((e) => e.startsWith(".") ?
|
|
3777
|
+
function be(e) {
|
|
3778
|
+
let t = Q(e);
|
|
3779
|
+
return t.length ? t.every((e) => e.startsWith(".") ? ve.includes(e) : e === "image/*" || e.startsWith("image/")) : !1;
|
|
3574
3780
|
}
|
|
3575
|
-
function
|
|
3781
|
+
function xe(e) {
|
|
3576
3782
|
let t = [];
|
|
3577
|
-
for (let n of
|
|
3578
|
-
let e =
|
|
3783
|
+
for (let n of Q(e)) {
|
|
3784
|
+
let e = _e[n] || (n.startsWith(".") ? n.slice(1).toUpperCase() : n.toUpperCase());
|
|
3579
3785
|
t.includes(e) || t.push(e);
|
|
3580
3786
|
}
|
|
3581
3787
|
return t.length <= 1 ? t[0] || "supported" : `${t.slice(0, -1).join(", ")} or ${t[t.length - 1]}`;
|
|
3582
3788
|
}
|
|
3583
|
-
function
|
|
3584
|
-
let n =
|
|
3789
|
+
function Se(e, t) {
|
|
3790
|
+
let n = Q(t);
|
|
3585
3791
|
if (!n.length) return !0;
|
|
3586
3792
|
let r = (e.type || "").toLowerCase(), i = (e.name || "").toLowerCase();
|
|
3587
|
-
return n.some((e) => e.startsWith(".") ? i.endsWith(e) : e.endsWith("/*") ? r.startsWith(e.slice(0, -1)) : r && r === e ? !0 : !r && (
|
|
3793
|
+
return n.some((e) => e.startsWith(".") ? i.endsWith(e) : e.endsWith("/*") ? r.startsWith(e.slice(0, -1)) : r && r === e ? !0 : !r && (ge[e] || []).some((e) => i.endsWith(e)));
|
|
3588
3794
|
}
|
|
3589
|
-
function
|
|
3795
|
+
function Ce(e, t = {}) {
|
|
3590
3796
|
if (!e) return null;
|
|
3591
|
-
let n = t.accept === void 0 ?
|
|
3592
|
-
return
|
|
3797
|
+
let n = t.accept === void 0 ? me : t.accept, r = t.maxSizeMb || 5;
|
|
3798
|
+
return Se(e, n) ? e.size > r * 1024 * 1024 ? `Keep the file under ${r} MB.` : null : `Choose a ${xe(n)} file.`;
|
|
3593
3799
|
}
|
|
3594
3800
|
//#endregion
|
|
3595
3801
|
//#region src/index.js
|
|
3596
|
-
var
|
|
3802
|
+
var $ = (e, t) => {
|
|
3597
3803
|
typeof customElements < "u" && !customElements.get(e) && customElements.define(e, t);
|
|
3598
3804
|
};
|
|
3599
|
-
function
|
|
3600
|
-
|
|
3805
|
+
function we() {
|
|
3806
|
+
$("wui-select", B), $("wui-phone", R), $("wui-datepicker", T), $("wui-date-range", ee), $("wui-dock", E), $("wui-slider", H), $("wui-timepicker", X), $("wui-autocomplete", m), $("wui-multiselect", te), $("wui-taginput", W), $("wui-otp", ie), $("wui-status-icon", n), $("wui-wizard-step", pe), $("wui-wizard", de);
|
|
3601
3807
|
}
|
|
3602
|
-
|
|
3808
|
+
we();
|
|
3603
3809
|
//#endregion
|
|
3604
|
-
export {
|
|
3810
|
+
export { me as DEFAULT_IMAGE_ACCEPT, he as DEFAULT_MAX_SIZE_MB, t as STATUS_TONES, m as WuiAutocomplete, T as WuiDatePicker, ee as WuiDateRange, E as WuiDock, te as WuiMultiSelect, ie as WuiOtp, R as WuiPhone, B as WuiSelect, H as WuiSlider, n as WuiStatusIcon, W as WuiTagInput, X as WuiTimePicker, de as WuiWizard, pe as WuiWizardStep, xe as acceptLabel, we as defineWeborityElements, ye as isImageFile, be as isImageOnlyAccept, Se as matchesAccept, Ce as validateFile };
|