@webority/ui-elements 0.6.11 → 0.6.13
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/examples.mobile.json-BMXTGiGC.js +250 -0
- package/dist/libphonenumber-js-BcNT8oq0.js +11643 -0
- package/dist/ui-elements.global.js +85 -29
- package/dist/ui-elements.js +592 -103
- package/package.json +4 -1
package/dist/ui-elements.js
CHANGED
|
@@ -253,26 +253,35 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
253
253
|
}, x = (e) => {
|
|
254
254
|
let t = b(e);
|
|
255
255
|
return t ? `${v(t.d)} ${g[t.m].slice(0, 3)} ${t.y}` : "";
|
|
256
|
-
}, S =
|
|
256
|
+
}, S = (e, t) => new Date(e, t + 1, 0).getDate(), C = (e, t) => {
|
|
257
|
+
for (; t < 0;) t += 12, --e;
|
|
258
|
+
for (; t > 11;) t -= 12, e += 1;
|
|
259
|
+
return {
|
|
260
|
+
y: e,
|
|
261
|
+
m: t
|
|
262
|
+
};
|
|
263
|
+
}, w = class extends HTMLElement {
|
|
257
264
|
static get observedAttributes() {
|
|
258
265
|
return [
|
|
259
266
|
"value",
|
|
260
267
|
"min",
|
|
261
268
|
"max",
|
|
262
269
|
"placeholder",
|
|
263
|
-
"disabled"
|
|
270
|
+
"disabled",
|
|
271
|
+
"first-day",
|
|
272
|
+
"size"
|
|
264
273
|
];
|
|
265
274
|
}
|
|
266
275
|
constructor() {
|
|
267
276
|
super(), this._value = "";
|
|
268
277
|
let e = new Date(2e3, 0, 1);
|
|
269
|
-
this._viewY = e.getFullYear(), this._viewM = e.getMonth();
|
|
278
|
+
this._viewY = e.getFullYear(), this._viewM = e.getMonth(), this._mode = "days", this._focus = null, this._slide = "";
|
|
270
279
|
}
|
|
271
280
|
connectedCallback() {
|
|
272
281
|
this._rendered || this.render();
|
|
273
282
|
}
|
|
274
283
|
attributeChangedCallback(e, t, n) {
|
|
275
|
-
this._rendered && (e === "value" ? (this._value = n || "", this._syncTrigger()) : this.render());
|
|
284
|
+
this._rendered && (e === "value" ? (this._value = n || "", this._syncTrigger()) : e === "first-day" ? this.querySelector(".datepicker-pop")?.hidden || this._renderView() : this.render());
|
|
276
285
|
}
|
|
277
286
|
get value() {
|
|
278
287
|
return this._value;
|
|
@@ -280,86 +289,486 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
280
289
|
set value(e) {
|
|
281
290
|
this._value = e || "", c(this, this._value), this._syncTrigger(), this.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
282
291
|
}
|
|
292
|
+
_firstDay() {
|
|
293
|
+
let e = Number.parseInt(this.getAttribute("first-day") ?? "", 10);
|
|
294
|
+
return Number.isInteger(e) && e >= 0 && e <= 6 ? e : 0;
|
|
295
|
+
}
|
|
283
296
|
render() {
|
|
284
297
|
this._value = this.getAttribute("value") || this._value;
|
|
285
298
|
let e = this.getAttribute("placeholder") || "Enter Date", t = b(this._value);
|
|
286
|
-
t && (this._viewY = t.y, this._viewM = t.m)
|
|
299
|
+
t && (this._viewY = t.y, this._viewM = t.m);
|
|
300
|
+
let n = this.getAttribute("size"), r = n === "sm" ? " input-sm" : n === "lg" ? " input-lg" : "";
|
|
301
|
+
this.innerHTML = `
|
|
287
302
|
<div class="datepicker">
|
|
288
|
-
<button type="button" class="input datepicker-trigger" aria-haspopup="dialog" aria-expanded="false"${this.hasAttribute("disabled") ? " disabled" : ""}>
|
|
303
|
+
<button type="button" class="input datepicker-trigger${r}${t ? " has-value" : ""}" aria-haspopup="dialog" aria-expanded="false"${this.hasAttribute("disabled") ? " disabled" : ""}>
|
|
289
304
|
<span data-trigger-label class="${t ? "" : "search-select-placeholder"}">${t ? x(this._value) : e}</span>
|
|
290
305
|
<i class="bi bi-calendar3" aria-hidden="true"></i>
|
|
291
306
|
</button>
|
|
292
|
-
<div class="datepicker-pop" role="dialog" hidden></div>
|
|
307
|
+
<div class="datepicker-pop" role="dialog" aria-modal="false" hidden></div>
|
|
293
308
|
</div>`, this._rendered = !0, c(this, this._value), this._wire();
|
|
294
309
|
}
|
|
295
310
|
_syncFormValue() {
|
|
296
311
|
c(this, this._value);
|
|
297
312
|
}
|
|
298
313
|
_syncTrigger() {
|
|
299
|
-
let e = this.querySelector("[data-trigger-label]");
|
|
300
|
-
if (!
|
|
301
|
-
let
|
|
302
|
-
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
let e = this.
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
314
|
+
let e = this.querySelector(".datepicker-trigger"), t = this.querySelector("[data-trigger-label]");
|
|
315
|
+
if (!t) return;
|
|
316
|
+
let n = b(this._value);
|
|
317
|
+
t.textContent = n ? x(this._value) : this.getAttribute("placeholder") || "Enter Date", t.classList.toggle("search-select-placeholder", !n), e?.classList.toggle("has-value", !!n);
|
|
318
|
+
}
|
|
319
|
+
_limits() {
|
|
320
|
+
let e = b(this.getAttribute("min")), t = b(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;
|
|
321
|
+
return {
|
|
322
|
+
dayDisabled: (e, t, i) => {
|
|
323
|
+
let a = new Date(e, t, i).getTime();
|
|
324
|
+
return a < n || a > r;
|
|
325
|
+
},
|
|
326
|
+
monthDisabled: (e, t) => {
|
|
327
|
+
let i = new Date(e, t, 1).getTime();
|
|
328
|
+
return new Date(e, t, S(e, t)).getTime() < n || i > r;
|
|
329
|
+
},
|
|
330
|
+
yearDisabled: (e) => {
|
|
331
|
+
let t = new Date(e, 0, 1).getTime();
|
|
332
|
+
return new Date(e, 11, 31).getTime() < n || t > r;
|
|
333
|
+
}
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
_renderView() {
|
|
337
|
+
let e = this.querySelector(".datepicker-pop");
|
|
338
|
+
e && (this._mode === "months" ? e.innerHTML = this._monthsHtml() : this._mode === "years" ? e.innerHTML = this._yearsHtml() : e.innerHTML = this._daysHtml(), this._focusActive());
|
|
339
|
+
}
|
|
340
|
+
_daysHtml() {
|
|
341
|
+
let e = this._firstDay(), t = (new Date(this._viewY, this._viewM, 1).getDay() - e + 7) % 7, n = S(this._viewY, this._viewM), r = b(this._value), i = /* @__PURE__ */ new Date(), { dayDisabled: a } = this._limits(), o = this._focus || r || {
|
|
342
|
+
y: this._viewY,
|
|
343
|
+
m: this._viewM,
|
|
344
|
+
d: 1
|
|
345
|
+
}, s = (e, t, n, s) => {
|
|
346
|
+
let c = y(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);
|
|
347
|
+
return `<button type="button" class="${[
|
|
348
|
+
"datepicker-day",
|
|
349
|
+
s ? "is-outside" : "",
|
|
350
|
+
u ? "is-today" : "",
|
|
351
|
+
l ? "is-selected" : ""
|
|
352
|
+
].filter(Boolean).join(" ")}" data-iso="${c}" role="gridcell" tabindex="${d && !f ? "0" : "-1"}"${l ? " aria-selected=\"true\"" : ""}${f ? " disabled aria-disabled=\"true\"" : ""}>${n}</button>`;
|
|
353
|
+
}, c = "", l = C(this._viewY, this._viewM - 1), u = S(l.y, l.m);
|
|
354
|
+
for (let e = t - 1; e >= 0; e--) c += s(l.y, l.m, u - e, !0);
|
|
355
|
+
for (let e = 1; e <= n; e++) c += s(this._viewY, this._viewM, e, !1);
|
|
356
|
+
let d = C(this._viewY, this._viewM + 1), f = (7 - (t + n) % 7) % 7;
|
|
357
|
+
for (let e = 1; e <= f; e++) c += s(d.y, d.m, e, !0);
|
|
358
|
+
let p = _.map((t, n) => _[(n + e) % 7]).map((e) => `<span>${e}</span>`).join("");
|
|
359
|
+
return `
|
|
315
360
|
<div class="datepicker-head">
|
|
316
361
|
<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>
|
|
317
|
-
<
|
|
362
|
+
<button type="button" class="datepicker-month" data-view="months" aria-label="Choose month and year">${g[this._viewM]} ${this._viewY}</button>
|
|
318
363
|
<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>
|
|
319
364
|
</div>
|
|
320
|
-
<div class="datepicker-weekdays">${
|
|
321
|
-
<div class="datepicker-grid">${
|
|
322
|
-
<div class="datepicker-foot"
|
|
365
|
+
<div class="datepicker-weekdays">${p}</div>
|
|
366
|
+
<div class="datepicker-grid${this._slide ? ` ${this._slide}` : ""}" role="grid">${c}</div>
|
|
367
|
+
<div class="datepicker-foot">
|
|
368
|
+
<button type="button" class="datepicker-link" data-today>Today</button>
|
|
369
|
+
<button type="button" class="datepicker-link" data-clear>Clear</button>
|
|
370
|
+
</div>`;
|
|
371
|
+
}
|
|
372
|
+
_monthsHtml() {
|
|
373
|
+
let e = b(this._value), t = /* @__PURE__ */ new Date(), { monthDisabled: n } = this._limits(), r = "";
|
|
374
|
+
for (let i = 0; i < 12; i++) {
|
|
375
|
+
let a = e && e.y === this._viewY && e.m === i, o = t.getFullYear() === this._viewY && t.getMonth() === i, s = n(this._viewY, i), c = [
|
|
376
|
+
"datepicker-cell",
|
|
377
|
+
o ? "is-today" : "",
|
|
378
|
+
a ? "is-selected" : ""
|
|
379
|
+
].filter(Boolean).join(" ");
|
|
380
|
+
r += `<button type="button" class="${c}" data-month="${i}"${s ? " disabled" : ""}>${g[i].slice(0, 3)}</button>`;
|
|
381
|
+
}
|
|
382
|
+
return `
|
|
383
|
+
<div class="datepicker-head">
|
|
384
|
+
<button type="button" class="datepicker-nav-btn" data-nav-year="-1" aria-label="Previous year"><i class="bi bi-chevron-left" aria-hidden="true"></i></button>
|
|
385
|
+
<button type="button" class="datepicker-month" data-view="years" aria-label="Choose year">${this._viewY}</button>
|
|
386
|
+
<button type="button" class="datepicker-nav-btn" data-nav-year="1" aria-label="Next year"><i class="bi bi-chevron-right" aria-hidden="true"></i></button>
|
|
387
|
+
</div>
|
|
388
|
+
<div class="datepicker-cells">${r}</div>`;
|
|
389
|
+
}
|
|
390
|
+
_yearsHtml() {
|
|
391
|
+
let e = b(this._value), t = (/* @__PURE__ */ new Date()).getFullYear(), { yearDisabled: n } = this._limits(), r = this._viewY - (this._viewY % 10 + 10) % 10 - 1, i = "";
|
|
392
|
+
for (let a = 0; a < 12; a++) {
|
|
393
|
+
let o = r + a, s = e && e.y === o, c = t === o, l = n(o), u = [
|
|
394
|
+
"datepicker-cell",
|
|
395
|
+
c ? "is-today" : "",
|
|
396
|
+
s ? "is-selected" : ""
|
|
397
|
+
].filter(Boolean).join(" ");
|
|
398
|
+
i += `<button type="button" class="${u}" data-year="${o}"${l ? " disabled" : ""}>${o}</button>`;
|
|
399
|
+
}
|
|
400
|
+
return `
|
|
401
|
+
<div class="datepicker-head">
|
|
402
|
+
<button type="button" class="datepicker-nav-btn" data-nav-decade="-1" aria-label="Previous decade"><i class="bi bi-chevron-left" aria-hidden="true"></i></button>
|
|
403
|
+
<span class="datepicker-month">${r + 1} – ${r + 10}</span>
|
|
404
|
+
<button type="button" class="datepicker-nav-btn" data-nav-decade="1" aria-label="Next decade"><i class="bi bi-chevron-right" aria-hidden="true"></i></button>
|
|
405
|
+
</div>
|
|
406
|
+
<div class="datepicker-cells">${i}</div>`;
|
|
407
|
+
}
|
|
408
|
+
_focusActive() {
|
|
409
|
+
let e = this.querySelector(".datepicker-pop"), t = e?.querySelector("[tabindex=\"0\"]") || e?.querySelector(".is-selected") || e?.querySelector(".datepicker-day:not(:disabled), .datepicker-cell:not(:disabled)");
|
|
410
|
+
t && e.contains(document.activeElement) && t.focus();
|
|
323
411
|
}
|
|
324
412
|
_position(e, t) {
|
|
325
413
|
i(e, t);
|
|
326
414
|
}
|
|
415
|
+
_setFocus(e, t, n, r) {
|
|
416
|
+
let { y: i, m: a } = C(e, t);
|
|
417
|
+
this._focus = {
|
|
418
|
+
y: i,
|
|
419
|
+
m: a,
|
|
420
|
+
d: n
|
|
421
|
+
};
|
|
422
|
+
let o = i !== this._viewY || a !== this._viewM;
|
|
423
|
+
this._viewY = i, this._viewM = a, this._slide = o && r || "", this._renderView(), this._slide = "", this.querySelector(`.datepicker-day[data-iso="${y(i, a, n)}"]`)?.focus();
|
|
424
|
+
}
|
|
425
|
+
_onKey(e) {
|
|
426
|
+
if (this._mode !== "days") {
|
|
427
|
+
e.key === "Escape" && this._close();
|
|
428
|
+
return;
|
|
429
|
+
}
|
|
430
|
+
let t = this._focus || b(this._value) || {
|
|
431
|
+
y: this._viewY,
|
|
432
|
+
m: this._viewM,
|
|
433
|
+
d: 1
|
|
434
|
+
}, n = (n, r) => {
|
|
435
|
+
e.preventDefault();
|
|
436
|
+
let i = new Date(t.y, t.m, t.d + n);
|
|
437
|
+
this._setFocus(i.getFullYear(), i.getMonth(), i.getDate(), r);
|
|
438
|
+
};
|
|
439
|
+
switch (e.key) {
|
|
440
|
+
case "ArrowLeft": return n(-1, "slide-prev");
|
|
441
|
+
case "ArrowRight": return n(1, "slide-next");
|
|
442
|
+
case "ArrowUp": return n(-7, "slide-prev");
|
|
443
|
+
case "ArrowDown": return n(7, "slide-next");
|
|
444
|
+
case "Home": return n(-((new Date(t.y, t.m, t.d).getDay() - this._firstDay() + 7) % 7), "slide-prev");
|
|
445
|
+
case "End": return n(6 - (new Date(t.y, t.m, t.d).getDay() - this._firstDay() + 7) % 7, "slide-next");
|
|
446
|
+
case "PageUp": {
|
|
447
|
+
e.preventDefault();
|
|
448
|
+
let n = C(t.y, t.m - (e.shiftKey ? 12 : 1));
|
|
449
|
+
return this._setFocus(n.y, n.m, Math.min(t.d, S(n.y, n.m)), "slide-prev");
|
|
450
|
+
}
|
|
451
|
+
case "PageDown": {
|
|
452
|
+
e.preventDefault();
|
|
453
|
+
let n = C(t.y, t.m + (e.shiftKey ? 12 : 1));
|
|
454
|
+
return this._setFocus(n.y, n.m, Math.min(t.d, S(n.y, n.m)), "slide-next");
|
|
455
|
+
}
|
|
456
|
+
case "Enter":
|
|
457
|
+
case " ":
|
|
458
|
+
e.preventDefault(), this._limits().dayDisabled(t.y, t.m, t.d) || (this.value = y(t.y, t.m, t.d), this._close());
|
|
459
|
+
return;
|
|
460
|
+
case "Escape": return this._close();
|
|
461
|
+
default:
|
|
462
|
+
}
|
|
463
|
+
}
|
|
327
464
|
_wire() {
|
|
328
|
-
let e = this.querySelector(".datepicker-trigger"), t = this.querySelector(".datepicker-pop");
|
|
465
|
+
let e = this.querySelector(".datepicker-trigger"), t = this.querySelector(".datepicker-pop"), n = this.querySelector(".datepicker");
|
|
329
466
|
if (!e || !t) return;
|
|
330
|
-
let
|
|
467
|
+
let r = () => !t.hidden;
|
|
468
|
+
this._open = () => {
|
|
331
469
|
if (!b(this._value) && !this._viewNavigated) {
|
|
332
470
|
let e = /* @__PURE__ */ new Date();
|
|
333
471
|
this._viewY = e.getFullYear(), this._viewM = e.getMonth();
|
|
334
472
|
}
|
|
335
|
-
this.
|
|
336
|
-
|
|
337
|
-
|
|
473
|
+
let r = b(this._value), i = /* @__PURE__ */ new Date();
|
|
474
|
+
this._mode = "days", this._focus = r || {
|
|
475
|
+
y: this._viewY,
|
|
476
|
+
m: this._viewM,
|
|
477
|
+
d: i.getFullYear() === this._viewY && i.getMonth() === this._viewM ? i.getDate() : 1
|
|
478
|
+
}, this._renderView(), t.hidden = !1, n?.classList.add("open"), this._position(e, t), e.setAttribute("aria-expanded", "true"), t.querySelector("[tabindex=\"0\"]")?.focus();
|
|
479
|
+
}, this._close = () => {
|
|
480
|
+
t.hidden = !0, n?.classList.remove("open"), e.setAttribute("aria-expanded", "false"), e.focus();
|
|
481
|
+
}, e.addEventListener("click", () => r() ? this._close() : this._open()), t.addEventListener("click", (e) => {
|
|
482
|
+
this._popClick = !0;
|
|
483
|
+
let t = e.target.closest("[data-nav]");
|
|
484
|
+
if (t) {
|
|
485
|
+
this._viewNavigated = !0, this._slide = Number(t.dataset.nav) < 0 ? "slide-prev" : "slide-next";
|
|
486
|
+
let e = C(this._viewY, this._viewM + Number(t.dataset.nav));
|
|
487
|
+
this._viewY = e.y, this._viewM = e.m, this._focus = {
|
|
488
|
+
y: e.y,
|
|
489
|
+
m: e.m,
|
|
490
|
+
d: 1
|
|
491
|
+
}, this._renderView(), this._slide = "";
|
|
492
|
+
return;
|
|
493
|
+
}
|
|
494
|
+
let n = e.target.closest("[data-nav-year]");
|
|
495
|
+
if (n) {
|
|
496
|
+
this._viewY += Number(n.dataset.navYear), this._renderView();
|
|
497
|
+
return;
|
|
498
|
+
}
|
|
499
|
+
let r = e.target.closest("[data-nav-decade]");
|
|
500
|
+
if (r) {
|
|
501
|
+
this._viewY += Number(r.dataset.navDecade) * 10, this._renderView();
|
|
502
|
+
return;
|
|
503
|
+
}
|
|
504
|
+
let i = e.target.closest("[data-view]");
|
|
505
|
+
if (i) {
|
|
506
|
+
this._mode = i.dataset.view, this._renderView();
|
|
507
|
+
return;
|
|
508
|
+
}
|
|
509
|
+
let a = e.target.closest("[data-month]");
|
|
510
|
+
if (a && !a.disabled) {
|
|
511
|
+
this._viewNavigated = !0, this._viewM = Number(a.dataset.month), this._mode = "days", this._focus = {
|
|
512
|
+
y: this._viewY,
|
|
513
|
+
m: this._viewM,
|
|
514
|
+
d: 1
|
|
515
|
+
}, this._renderView();
|
|
516
|
+
return;
|
|
517
|
+
}
|
|
518
|
+
let o = e.target.closest("[data-year]");
|
|
519
|
+
if (o && !o.disabled) {
|
|
520
|
+
this._viewNavigated = !0, this._viewY = Number(o.dataset.year), this._mode = "months", this._renderView();
|
|
521
|
+
return;
|
|
522
|
+
}
|
|
523
|
+
if (e.target.closest("[data-today]")) {
|
|
524
|
+
let e = /* @__PURE__ */ new Date();
|
|
525
|
+
this.value = y(e.getFullYear(), e.getMonth(), e.getDate()), this._close();
|
|
526
|
+
return;
|
|
527
|
+
}
|
|
528
|
+
if (e.target.closest("[data-clear]")) {
|
|
529
|
+
this.value = "", this._close();
|
|
530
|
+
return;
|
|
531
|
+
}
|
|
532
|
+
let s = e.target.closest(".datepicker-day[data-iso]");
|
|
533
|
+
s && !s.disabled && (this.value = s.dataset.iso, this._close());
|
|
534
|
+
}), this._onKeyBound = (e) => {
|
|
535
|
+
r() && this._onKey(e);
|
|
536
|
+
}, t.addEventListener("keydown", this._onKeyBound), this._onDocClick = (e) => {
|
|
537
|
+
let t = this._popClick;
|
|
538
|
+
this._popClick = !1, r() && !t && !this.contains(e.target) && this._close();
|
|
539
|
+
}, document.addEventListener("click", this._onDocClick), a(this, () => {
|
|
540
|
+
r() && this._position(e, t);
|
|
541
|
+
}), this._syncFormValue();
|
|
542
|
+
}
|
|
543
|
+
disconnectedCallback() {
|
|
544
|
+
this._onDocClick && document.removeEventListener("click", this._onDocClick), o(this);
|
|
545
|
+
}
|
|
546
|
+
}, T = [
|
|
547
|
+
"January",
|
|
548
|
+
"February",
|
|
549
|
+
"March",
|
|
550
|
+
"April",
|
|
551
|
+
"May",
|
|
552
|
+
"June",
|
|
553
|
+
"July",
|
|
554
|
+
"August",
|
|
555
|
+
"September",
|
|
556
|
+
"October",
|
|
557
|
+
"November",
|
|
558
|
+
"December"
|
|
559
|
+
], E = [
|
|
560
|
+
"Su",
|
|
561
|
+
"Mo",
|
|
562
|
+
"Tu",
|
|
563
|
+
"We",
|
|
564
|
+
"Th",
|
|
565
|
+
"Fr",
|
|
566
|
+
"Sa"
|
|
567
|
+
], D = (e) => String(e).padStart(2, "0"), ee = (e, t, n) => `${e}-${D(t + 1)}-${D(n)}`, O = (e) => {
|
|
568
|
+
let t = /^(\d{4})-(\d{2})-(\d{2})$/.exec(e || "");
|
|
569
|
+
return t ? {
|
|
570
|
+
y: +t[1],
|
|
571
|
+
m: t[2] - 1,
|
|
572
|
+
d: +t[3]
|
|
573
|
+
} : null;
|
|
574
|
+
}, k = (e) => {
|
|
575
|
+
let t = O(e);
|
|
576
|
+
return t ? `${D(t.d)} ${T[t.m].slice(0, 3)} ${t.y}` : "";
|
|
577
|
+
}, A = (e, t) => new Date(e, t + 1, 0).getDate(), j = (e, t) => {
|
|
578
|
+
for (; t < 0;) t += 12, --e;
|
|
579
|
+
for (; t > 11;) t -= 12, e += 1;
|
|
580
|
+
return {
|
|
581
|
+
y: e,
|
|
582
|
+
m: t
|
|
583
|
+
};
|
|
584
|
+
}, M = class extends HTMLElement {
|
|
585
|
+
static get observedAttributes() {
|
|
586
|
+
return [
|
|
587
|
+
"start",
|
|
588
|
+
"end",
|
|
589
|
+
"min",
|
|
590
|
+
"max",
|
|
591
|
+
"placeholder",
|
|
592
|
+
"disabled",
|
|
593
|
+
"first-day",
|
|
594
|
+
"size"
|
|
595
|
+
];
|
|
596
|
+
}
|
|
597
|
+
constructor() {
|
|
598
|
+
super(), this._start = "", this._end = "", this._hover = "";
|
|
599
|
+
let e = new Date(2e3, 0, 1);
|
|
600
|
+
this._viewY = e.getFullYear(), this._viewM = e.getMonth();
|
|
601
|
+
}
|
|
602
|
+
connectedCallback() {
|
|
603
|
+
this._rendered || this.render();
|
|
604
|
+
}
|
|
605
|
+
attributeChangedCallback(e, t, n) {
|
|
606
|
+
this._rendered && (e === "start" || e === "end" ? (this._start = this.getAttribute("start") || "", this._end = this.getAttribute("end") || "", this._syncTrigger(), this._syncMirrors()) : this.render());
|
|
607
|
+
}
|
|
608
|
+
get value() {
|
|
609
|
+
return {
|
|
610
|
+
start: this._start,
|
|
611
|
+
end: this._end
|
|
612
|
+
};
|
|
613
|
+
}
|
|
614
|
+
set value(e) {
|
|
615
|
+
this._start = e?.start || "", this._end = e?.end || "", this._syncTrigger(), this._syncMirrors(), this.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
616
|
+
}
|
|
617
|
+
_firstDay() {
|
|
618
|
+
let e = Number.parseInt(this.getAttribute("first-day") ?? "", 10);
|
|
619
|
+
return Number.isInteger(e) && e >= 0 && e <= 6 ? e : 0;
|
|
620
|
+
}
|
|
621
|
+
_label() {
|
|
622
|
+
let e = this.getAttribute("placeholder") || "Start – End";
|
|
623
|
+
return !this._start && !this._end ? {
|
|
624
|
+
text: e,
|
|
625
|
+
empty: !0
|
|
626
|
+
} : {
|
|
627
|
+
text: `${k(this._start) || "Start"} – ${k(this._end) || "End"}`,
|
|
628
|
+
empty: !1
|
|
629
|
+
};
|
|
630
|
+
}
|
|
631
|
+
render() {
|
|
632
|
+
this._start = this.getAttribute("start") || this._start, this._end = this.getAttribute("end") || this._end;
|
|
633
|
+
let e = O(this._start);
|
|
634
|
+
e && (this._viewY = e.y, this._viewM = e.m);
|
|
635
|
+
let t = this.getAttribute("size"), n = t === "sm" ? " input-sm" : t === "lg" ? " input-lg" : "", { text: r, empty: i } = this._label();
|
|
636
|
+
this.innerHTML = `
|
|
637
|
+
<div class="daterange">
|
|
638
|
+
<button type="button" class="input daterange-trigger${n}${i ? "" : " has-value"}" aria-haspopup="dialog" aria-expanded="false"${this.hasAttribute("disabled") ? " disabled" : ""}>
|
|
639
|
+
<span data-range-label class="${i ? "search-select-placeholder" : ""}">${r}</span>
|
|
640
|
+
<i class="bi bi-calendar-range" aria-hidden="true"></i>
|
|
641
|
+
</button>
|
|
642
|
+
<div class="daterange-pop" role="dialog" aria-modal="false" hidden></div>
|
|
643
|
+
</div>`, this._rendered = !0, this._syncMirrors(), this._wire();
|
|
644
|
+
}
|
|
645
|
+
_syncTrigger() {
|
|
646
|
+
let e = this.querySelector(".daterange-trigger"), t = this.querySelector("[data-range-label]");
|
|
647
|
+
if (!t) return;
|
|
648
|
+
let { text: n, empty: r } = this._label();
|
|
649
|
+
t.textContent = n, t.classList.toggle("search-select-placeholder", r), e?.classList.toggle("has-value", !r);
|
|
650
|
+
}
|
|
651
|
+
_syncMirrors() {
|
|
652
|
+
let e = this.getAttribute("start-name") || this.getAttribute("name"), t = this.getAttribute("end-name");
|
|
653
|
+
this._mirror("start", e, this._start), this._mirror("end", t, this._end);
|
|
654
|
+
}
|
|
655
|
+
_mirror(e, t, n) {
|
|
656
|
+
if (!t) return;
|
|
657
|
+
let r = this.querySelector(`input[type="hidden"][data-range-mirror="${e}"]`);
|
|
658
|
+
r || (r = document.createElement("input"), r.type = "hidden", r.setAttribute("data-range-mirror", e), this.appendChild(r)), r.name = t, r.value = n || "";
|
|
659
|
+
}
|
|
660
|
+
_limits() {
|
|
661
|
+
let e = O(this.getAttribute("min")), t = O(this.getAttribute("max")), n = e ? new Date(e.y, e.m, e.d).getTime() : -Infinity, r = t ? new Date(t.y, t.m, t.d).getTime() : Infinity;
|
|
662
|
+
return (e, t, i) => {
|
|
663
|
+
let a = new Date(e, t, i).getTime();
|
|
664
|
+
return a < n || a > r;
|
|
338
665
|
};
|
|
339
|
-
|
|
666
|
+
}
|
|
667
|
+
_monthHtml(e, t) {
|
|
668
|
+
let n = this._firstDay(), r = (new Date(e, t, 1).getDay() - n + 7) % 7, i = A(e, t), a = this._limits(), o = E.map((e, t) => E[(t + n) % 7]).map((e) => `<span>${e}</span>`).join(""), s = (e, t, n, r) => {
|
|
669
|
+
let i = ee(e, t, n), o = a(e, t, n);
|
|
670
|
+
return `<button type="button" class="${["datepicker-day", r ? "is-outside" : ""].filter(Boolean).join(" ")}" data-iso="${i}"${o ? " disabled" : ""}>${n}</button>`;
|
|
671
|
+
}, c = "", l = j(e, t - 1), u = A(l.y, l.m);
|
|
672
|
+
for (let e = r - 1; e >= 0; e--) c += s(l.y, l.m, u - e, !0);
|
|
673
|
+
for (let n = 1; n <= i; n++) c += s(e, t, n, !1);
|
|
674
|
+
let d = j(e, t + 1), f = (7 - (r + i) % 7) % 7;
|
|
675
|
+
for (let e = 1; e <= f; e++) c += s(d.y, d.m, e, !0);
|
|
676
|
+
return `
|
|
677
|
+
<div class="daterange-cal">
|
|
678
|
+
<div class="datepicker-month-label">${T[t]} ${e}</div>
|
|
679
|
+
<div class="datepicker-weekdays">${o}</div>
|
|
680
|
+
<div class="datepicker-grid" role="grid">${c}</div>
|
|
681
|
+
</div>`;
|
|
682
|
+
}
|
|
683
|
+
_renderView() {
|
|
684
|
+
let e = this.querySelector(".daterange-pop");
|
|
685
|
+
if (!e) return;
|
|
686
|
+
let t = j(this._viewY, this._viewM + 1);
|
|
687
|
+
e.innerHTML = `
|
|
688
|
+
<div class="daterange-head">
|
|
689
|
+
<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>
|
|
690
|
+
<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>
|
|
691
|
+
</div>
|
|
692
|
+
<div class="daterange-cals">
|
|
693
|
+
${this._monthHtml(this._viewY, this._viewM)}
|
|
694
|
+
${this._monthHtml(t.y, t.m)}
|
|
695
|
+
</div>
|
|
696
|
+
<div class="datepicker-foot">
|
|
697
|
+
<span class="daterange-hint" data-range-hint></span>
|
|
698
|
+
<button type="button" class="datepicker-link" data-clear>Clear</button>
|
|
699
|
+
</div>`, this._paint();
|
|
700
|
+
}
|
|
701
|
+
_paint() {
|
|
702
|
+
let e = this.querySelector(".daterange-pop");
|
|
703
|
+
if (!e) return;
|
|
704
|
+
let t = this._start ? new Date(this._start).getTime() : null, n = this._end;
|
|
705
|
+
t && !this._end && this._hover && new Date(this._hover).getTime() >= t && (n = this._hover);
|
|
706
|
+
let r = n ? new Date(n).getTime() : null;
|
|
707
|
+
for (let n of e.querySelectorAll(".datepicker-day[data-iso]")) {
|
|
708
|
+
let e = new Date(n.dataset.iso).getTime(), i = t != null && e === t, a = r != null && e === r, o = t != null && r != null && e > t && e < r;
|
|
709
|
+
n.classList.toggle("is-range-start", i), n.classList.toggle("is-range-end", a), n.classList.toggle("in-range", o);
|
|
710
|
+
}
|
|
711
|
+
let i = e.querySelector("[data-range-hint]");
|
|
712
|
+
i && (i.textContent = this._start ? this._end ? `${k(this._start)} – ${k(this._end)}` : "Pick an end date" : "Pick a start date");
|
|
713
|
+
}
|
|
714
|
+
_position(e, t) {
|
|
715
|
+
i(e, t);
|
|
716
|
+
}
|
|
717
|
+
_pick(e) {
|
|
718
|
+
if (!this._start || this._start && this._end) {
|
|
719
|
+
this._start = e, this._end = "", this._hover = "", this._syncTrigger(), this._syncMirrors(), this._paint();
|
|
720
|
+
return;
|
|
721
|
+
}
|
|
722
|
+
if (new Date(e).getTime() < new Date(this._start).getTime()) {
|
|
723
|
+
this._start = e, this._paint();
|
|
724
|
+
return;
|
|
725
|
+
}
|
|
726
|
+
this._end = e, this._syncTrigger(), this._syncMirrors(), this._paint(), this.dispatchEvent(new Event("change", { bubbles: !0 })), this._close();
|
|
727
|
+
}
|
|
728
|
+
_wire() {
|
|
729
|
+
let e = this.querySelector(".daterange-trigger"), t = this.querySelector(".daterange-pop"), n = this.querySelector(".daterange");
|
|
730
|
+
if (!e || !t) return;
|
|
731
|
+
let r = () => !t.hidden;
|
|
732
|
+
this._open = () => {
|
|
733
|
+
let r = O(this._start);
|
|
734
|
+
if (r) this._viewY = r.y, this._viewM = r.m;
|
|
735
|
+
else {
|
|
736
|
+
let e = /* @__PURE__ */ new Date();
|
|
737
|
+
this._viewY = e.getFullYear(), this._viewM = e.getMonth();
|
|
738
|
+
}
|
|
739
|
+
this._renderView(), t.hidden = !1, n?.classList.add("open"), this._position(e, t), e.setAttribute("aria-expanded", "true");
|
|
740
|
+
}, this._close = () => {
|
|
741
|
+
t.hidden = !0, this._hover = "", n?.classList.remove("open"), e.setAttribute("aria-expanded", "false");
|
|
742
|
+
}, e.addEventListener("click", () => r() ? this._close() : this._open()), t.addEventListener("click", (e) => {
|
|
743
|
+
this._popClick = !0;
|
|
340
744
|
let t = e.target.closest("[data-nav]");
|
|
341
745
|
if (t) {
|
|
342
|
-
|
|
746
|
+
let e = j(this._viewY, this._viewM + Number(t.dataset.nav));
|
|
747
|
+
this._viewY = e.y, this._viewM = e.m, this._renderView();
|
|
343
748
|
return;
|
|
344
749
|
}
|
|
345
750
|
if (e.target.closest("[data-clear]")) {
|
|
346
|
-
this.
|
|
751
|
+
this._start = "", this._end = "", this._hover = "", this._syncTrigger(), this._syncMirrors(), this._renderView(), this.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
347
752
|
return;
|
|
348
753
|
}
|
|
349
754
|
let n = e.target.closest(".datepicker-day[data-iso]");
|
|
350
|
-
n && !n.disabled &&
|
|
755
|
+
n && !n.disabled && this._pick(n.dataset.iso);
|
|
756
|
+
}), t.addEventListener("mouseover", (e) => {
|
|
757
|
+
let t = e.target.closest(".datepicker-day[data-iso]");
|
|
758
|
+
t && this._start && !this._end && (this._hover = t.dataset.iso, this._paint());
|
|
351
759
|
}), this._onDocClick = (e) => {
|
|
352
|
-
|
|
760
|
+
let t = this._popClick;
|
|
761
|
+
this._popClick = !1, r() && !t && !this.contains(e.target) && this._close();
|
|
353
762
|
}, document.addEventListener("click", this._onDocClick), this._onDocKey = (e) => {
|
|
354
|
-
|
|
763
|
+
r() && e.key === "Escape" && this._close();
|
|
355
764
|
}, document.addEventListener("keydown", this._onDocKey), a(this, () => {
|
|
356
|
-
|
|
357
|
-
}), this.
|
|
765
|
+
r() && this._position(e, t);
|
|
766
|
+
}), this._syncMirrors();
|
|
358
767
|
}
|
|
359
768
|
disconnectedCallback() {
|
|
360
769
|
this._onDocClick && document.removeEventListener("click", this._onDocClick), this._onDocKey && document.removeEventListener("keydown", this._onDocKey), o(this);
|
|
361
770
|
}
|
|
362
|
-
},
|
|
771
|
+
}, N = class extends HTMLElement {
|
|
363
772
|
_accessibleName() {
|
|
364
773
|
return this.getAttribute("aria-label") || this.getAttribute("placeholder") || "Select";
|
|
365
774
|
}
|
|
@@ -429,13 +838,13 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
429
838
|
let e = this.hasAttribute("searchable"), t = this.getAttribute("search-placeholder") || "Search…", n = this.getAttribute("icon"), r = this.getAttribute("size"), i = r === "sm" ? " search-select-sm" : r === "lg" ? " search-select-lg" : "";
|
|
430
839
|
c(this, this._values.join(",")), this.innerHTML = `
|
|
431
840
|
<div class="search-select${i}">
|
|
432
|
-
<div class="input search-select-control search-select-multi" role="combobox" aria-haspopup="listbox" aria-expanded="false" aria-label="${
|
|
433
|
-
${n ? `<i class="bi bi-${
|
|
841
|
+
<div class="input search-select-control search-select-multi" role="combobox" aria-haspopup="listbox" aria-expanded="false" aria-label="${P(this._accessibleName())}"${this.hasAttribute("disabled") ? " aria-disabled=\"true\"" : ""}>
|
|
842
|
+
${n ? `<i class="bi bi-${P(n)} search-select-icon" aria-hidden="true"></i>` : ""}
|
|
434
843
|
<div class="ms-chips" data-chips></div>
|
|
435
844
|
<i class="bi bi-chevron-down search-select-caret" aria-hidden="true"></i>
|
|
436
845
|
</div>
|
|
437
846
|
<div class="search-select-menu search-select-menu-fixed" role="listbox" aria-multiselectable="true" tabindex="-1" hidden>
|
|
438
|
-
${e ? `<div class="search-select-search"><i class="bi bi-search" aria-hidden="true"></i><input class="search-select-input" placeholder="${
|
|
847
|
+
${e ? `<div class="search-select-search"><i class="bi bi-search" aria-hidden="true"></i><input class="search-select-input" placeholder="${P(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>` : ""}
|
|
439
848
|
<div class="search-select-options"></div>
|
|
440
849
|
<div class="search-select-empty" hidden>No matches</div>
|
|
441
850
|
</div>
|
|
@@ -449,7 +858,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
449
858
|
e.innerHTML = `<span class="search-select-placeholder">${u(t)}</span>`;
|
|
450
859
|
return;
|
|
451
860
|
}
|
|
452
|
-
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="${
|
|
861
|
+
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="${P(e)}" aria-label="Remove"><i class="bi bi-x" aria-hidden="true"></i></button></span>`).join(""), this._collapseChips();
|
|
453
862
|
}
|
|
454
863
|
_collapseChips() {
|
|
455
864
|
let e = this.querySelector("[data-chips]");
|
|
@@ -473,9 +882,9 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
473
882
|
let t = this.querySelector(".search-select-options"), n = this.querySelector(".search-select-empty");
|
|
474
883
|
if (!t) return;
|
|
475
884
|
let r = (e || "").trim().toLowerCase(), i = this._readOptions();
|
|
476
|
-
r && (i = i.filter((e) =>
|
|
885
|
+
r && (i = i.filter((e) => te(e.label).toLowerCase().includes(r))), t.innerHTML = i.map((e) => {
|
|
477
886
|
let t = this._values.includes(String(e.value));
|
|
478
|
-
return `<button type="button" role="option" class="search-select-option${t ? " selected" : ""}" data-value="${
|
|
887
|
+
return `<button type="button" role="option" class="search-select-option${t ? " selected" : ""}" data-value="${P(e.value)}" aria-selected="${t}"><span class="ms-opt-label">${f(e)}</span><span class="ms-check"><i class="bi bi-check" aria-hidden="true"></i></span></button>`;
|
|
479
888
|
}).join(""), n && (n.hidden = i.length > 0), this._active = -1;
|
|
480
889
|
}
|
|
481
890
|
_wire() {
|
|
@@ -537,7 +946,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
537
946
|
disconnectedCallback() {
|
|
538
947
|
this._onDocClick && document.removeEventListener("click", this._onDocClick), o(this), this._ro?.disconnect(), this._ro = null;
|
|
539
948
|
}
|
|
540
|
-
},
|
|
949
|
+
}, P = (e) => String(e ?? "").replace(/"/g, """).replace(/</g, "<"), te = (e) => String(e ?? "").replace(/<[^>]*>/g, ""), ne = /[^0-9]/g, re = /[^0-9a-zA-Z]/g, F = class extends HTMLElement {
|
|
541
950
|
static get observedAttributes() {
|
|
542
951
|
return [
|
|
543
952
|
"value",
|
|
@@ -567,7 +976,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
567
976
|
this._value = this._clean(e), c(this, this._value), this._paint();
|
|
568
977
|
}
|
|
569
978
|
_clean(e) {
|
|
570
|
-
return (e == null ? "" : String(e)).replace(this.mode === "alphanumeric" ?
|
|
979
|
+
return (e == null ? "" : String(e)).replace(this.mode === "alphanumeric" ? re : ne, "").slice(0, this.length);
|
|
571
980
|
}
|
|
572
981
|
connectedCallback() {
|
|
573
982
|
this._rendered || this.render();
|
|
@@ -633,7 +1042,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
633
1042
|
document.activeElement === e && this._paint();
|
|
634
1043
|
});
|
|
635
1044
|
}
|
|
636
|
-
},
|
|
1045
|
+
}, I = [
|
|
637
1046
|
[
|
|
638
1047
|
"AF",
|
|
639
1048
|
"Afghanistan",
|
|
@@ -1859,11 +2268,67 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
1859
2268
|
"Zimbabwe",
|
|
1860
2269
|
"263"
|
|
1861
2270
|
]
|
|
1862
|
-
],
|
|
2271
|
+
], L = (e) => (I.find((t) => t[0] === e) || [
|
|
1863
2272
|
"",
|
|
1864
2273
|
"",
|
|
1865
2274
|
""
|
|
1866
|
-
])[2],
|
|
2275
|
+
])[2], R = (e) => `wui-flag wui-flag-${String(e).toLowerCase()}`, z = null, B = null;
|
|
2276
|
+
function ie() {
|
|
2277
|
+
return z ? Promise.resolve(z) : (B ||= Promise.all([import("./libphonenumber-js-BcNT8oq0.js"), import("./examples.mobile.json-BMXTGiGC.js")]).then(([e, t]) => (z = {
|
|
2278
|
+
AsYouType: e.AsYouType,
|
|
2279
|
+
getExampleNumber: e.getExampleNumber,
|
|
2280
|
+
isValidPhoneNumber: e.isValidPhoneNumber,
|
|
2281
|
+
examples: t.default || t
|
|
2282
|
+
}, z)).catch(() => null), B);
|
|
2283
|
+
}
|
|
2284
|
+
function V(e, t) {
|
|
2285
|
+
if (!z || !t) return t;
|
|
2286
|
+
try {
|
|
2287
|
+
return new z.AsYouType(e).input(t);
|
|
2288
|
+
} catch {
|
|
2289
|
+
return t;
|
|
2290
|
+
}
|
|
2291
|
+
}
|
|
2292
|
+
function H(e) {
|
|
2293
|
+
if (!z) return null;
|
|
2294
|
+
try {
|
|
2295
|
+
return z.getExampleNumber(e, z.examples)?.formatNational() || null;
|
|
2296
|
+
} catch {
|
|
2297
|
+
return null;
|
|
2298
|
+
}
|
|
2299
|
+
}
|
|
2300
|
+
function U(e) {
|
|
2301
|
+
if (!z || !e) return null;
|
|
2302
|
+
try {
|
|
2303
|
+
return z.isValidPhoneNumber(e);
|
|
2304
|
+
} catch {
|
|
2305
|
+
return null;
|
|
2306
|
+
}
|
|
2307
|
+
}
|
|
2308
|
+
function ae(e) {
|
|
2309
|
+
if (!z) return null;
|
|
2310
|
+
try {
|
|
2311
|
+
let t = z.getExampleNumber(e, z.examples);
|
|
2312
|
+
return t?.nationalNumber ? t.nationalNumber.length : null;
|
|
2313
|
+
} catch {
|
|
2314
|
+
return null;
|
|
2315
|
+
}
|
|
2316
|
+
}
|
|
2317
|
+
function oe(e) {
|
|
2318
|
+
if (!z || !e?.trim().startsWith("+")) return null;
|
|
2319
|
+
try {
|
|
2320
|
+
let t = new z.AsYouType();
|
|
2321
|
+
t.input(e.trim());
|
|
2322
|
+
let n = t.getCountry();
|
|
2323
|
+
return n ? {
|
|
2324
|
+
country: n,
|
|
2325
|
+
national: t.getNationalNumber() || ""
|
|
2326
|
+
} : null;
|
|
2327
|
+
} catch {
|
|
2328
|
+
return null;
|
|
2329
|
+
}
|
|
2330
|
+
}
|
|
2331
|
+
var W = class extends HTMLElement {
|
|
1867
2332
|
static get observedAttributes() {
|
|
1868
2333
|
return [
|
|
1869
2334
|
"value",
|
|
@@ -1882,7 +2347,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
1882
2347
|
this._rendered && (e === "country" && (this._country = n || "IN"), this.render());
|
|
1883
2348
|
}
|
|
1884
2349
|
get value() {
|
|
1885
|
-
return `+${
|
|
2350
|
+
return `+${L(this._country)}${this._national}`;
|
|
1886
2351
|
}
|
|
1887
2352
|
set value(e) {
|
|
1888
2353
|
this._national = String(e ?? "").replace(/[^0-9]/g, ""), this._commit();
|
|
@@ -1891,64 +2356,88 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
1891
2356
|
c(this, this.value), this.dispatchEvent(new Event("change", { bubbles: !0 }));
|
|
1892
2357
|
}
|
|
1893
2358
|
render() {
|
|
1894
|
-
let e = this.getAttribute("placeholder") || "Enter phone number";
|
|
2359
|
+
let e = this.getAttribute("placeholder") || H(this._country) || "Enter phone number";
|
|
1895
2360
|
this._country = this.getAttribute("country") || this._country;
|
|
1896
|
-
let t =
|
|
2361
|
+
let t = I.map(([e, t, n]) => `<button type="button" role="option" class="country-dropdown-item${e === this._country ? " selected" : ""}" data-iso="${e}"><span class="${R(e)}" aria-hidden="true"></span><span class="country-name-text">${t}<span class="country-code-text">+${n}</span></span></button>`).join("");
|
|
1897
2362
|
this.innerHTML = `
|
|
1898
2363
|
<div class="phone-input-wrap">
|
|
1899
2364
|
<div class="phone-country-adornment">
|
|
1900
2365
|
<button type="button" class="country-toggle" aria-haspopup="listbox" aria-expanded="false"${this.hasAttribute("disabled") ? " disabled" : ""}>
|
|
1901
|
-
<span class="${
|
|
2366
|
+
<span class="${R(this._country)}" data-flag aria-hidden="true"></span>
|
|
1902
2367
|
<i class="bi bi-chevron-down phone-chevron" aria-hidden="true"></i>
|
|
1903
|
-
<span class="phone-dial" data-dial>+${
|
|
2368
|
+
<span class="phone-dial" data-dial>+${L(this._country)}</span>
|
|
1904
2369
|
</button>
|
|
1905
2370
|
<div class="country-dropdown-menu" role="listbox" hidden>
|
|
1906
2371
|
<div class="dropdown-search-wrapper"><span class="dropdown-search-icon"><i class="bi bi-search" aria-hidden="true"></i></span><input type="text" class="dropdown-search-input" placeholder="Search country or code" aria-label="Search countries" /></div>
|
|
1907
2372
|
<div class="country-list-scroll">${t}<div class="country-empty" hidden>No countries found</div></div>
|
|
1908
2373
|
</div>
|
|
1909
2374
|
</div>
|
|
1910
|
-
<input type="tel" class="input" placeholder="${
|
|
1911
|
-
</div
|
|
2375
|
+
<input type="tel" class="input" placeholder="${G(e)}" value="${G(V(this._country, this._national))}"${this.hasAttribute("disabled") ? " disabled" : ""} />
|
|
2376
|
+
</div>
|
|
2377
|
+
<div class="field-error" data-phone-error hidden></div>`, this._rendered = !0, c(this, this.value), this._wire();
|
|
1912
2378
|
}
|
|
1913
2379
|
_wire() {
|
|
1914
|
-
let e = this.querySelector(".country-toggle"), t = this.querySelector(".country-dropdown-menu"),
|
|
1915
|
-
if (!e || !
|
|
1916
|
-
let
|
|
1917
|
-
let
|
|
1918
|
-
|
|
1919
|
-
}, d = () => {
|
|
1920
|
-
t.hidden = !1, e.setAttribute("aria-expanded", "true"), n.value = "", p(""), u(), n.focus();
|
|
2380
|
+
let e = this.querySelector(".country-toggle"), t = this.querySelector(".phone-input-wrap"), n = this.querySelector(".country-dropdown-menu"), r = this.querySelector(".dropdown-search-input"), i = this.querySelector(".country-list-scroll"), a = this.querySelector(".country-empty"), o = this.querySelector("input[type=tel]"), s = this.querySelector("[data-flag]"), l = this.querySelector("[data-dial]");
|
|
2381
|
+
if (!e || !n) return;
|
|
2382
|
+
let u = () => !n.hidden, d = () => {
|
|
2383
|
+
let r = (t || e).getBoundingClientRect(), i = n.offsetWidth || 320, a = n.offsetHeight || 320, o = window.innerHeight - r.bottom, s = o < a + 6 && r.top > o ? r.top - a - 6 : r.bottom + 6, c = Math.min(Math.max(8, r.left), Math.max(8, window.innerWidth - i - 8));
|
|
2384
|
+
n.style.top = `${Math.max(8, s)}px`, n.style.left = `${c}px`;
|
|
1921
2385
|
}, f = () => {
|
|
1922
|
-
|
|
2386
|
+
n.hidden = !1, e.setAttribute("aria-expanded", "true"), r.value = "", m(""), d(), r.focus();
|
|
2387
|
+
}, p = () => {
|
|
2388
|
+
n.hidden = !0, e.setAttribute("aria-expanded", "false");
|
|
1923
2389
|
};
|
|
1924
2390
|
this._reposition = () => {
|
|
1925
|
-
|
|
2391
|
+
u() && d();
|
|
1926
2392
|
}, window.addEventListener("scroll", this._reposition, !0), window.addEventListener("resize", this._reposition);
|
|
1927
|
-
let
|
|
2393
|
+
let m = (e) => {
|
|
1928
2394
|
let t = e.trim().toLowerCase(), n = 0;
|
|
1929
|
-
for (let e of
|
|
2395
|
+
for (let e of i.querySelectorAll(".country-dropdown-item")) {
|
|
1930
2396
|
let r = !t || e.textContent.toLowerCase().includes(t);
|
|
1931
2397
|
e.hidden = !r, r && (n += 1);
|
|
1932
2398
|
}
|
|
1933
|
-
|
|
1934
|
-
},
|
|
1935
|
-
this._country = e, this.setAttribute("country", e),
|
|
1936
|
-
for (let t of
|
|
1937
|
-
|
|
2399
|
+
a && (a.hidden = n > 0);
|
|
2400
|
+
}, h = (e) => {
|
|
2401
|
+
this._country = e, this.setAttribute("country", e), s && (s.className = R(e)), l && (l.textContent = `+${L(e)}`);
|
|
2402
|
+
for (let t of i.querySelectorAll(".country-dropdown-item")) t.classList.toggle("selected", t.dataset.iso === e);
|
|
2403
|
+
p(), this._commit();
|
|
1938
2404
|
};
|
|
1939
|
-
e.addEventListener("click", () =>
|
|
2405
|
+
e.addEventListener("click", () => u() ? p() : f()), r.addEventListener("input", () => m(r.value)), i.addEventListener("click", (e) => {
|
|
1940
2406
|
let t = e.target.closest(".country-dropdown-item");
|
|
1941
|
-
t &&
|
|
1942
|
-
})
|
|
1943
|
-
|
|
2407
|
+
t && h(t.dataset.iso);
|
|
2408
|
+
});
|
|
2409
|
+
let g = this.querySelector("[data-phone-error]"), _ = (e) => {
|
|
2410
|
+
if (o.classList.toggle("is-invalid", e), e ? o.setAttribute("aria-invalid", "true") : o.removeAttribute("aria-invalid"), g) {
|
|
2411
|
+
if (e) {
|
|
2412
|
+
let e = H(this._country);
|
|
2413
|
+
g.textContent = e ? `Enter a valid phone number, e.g. ${e}` : "Enter a valid phone number";
|
|
2414
|
+
}
|
|
2415
|
+
g.hidden = !e;
|
|
2416
|
+
}
|
|
2417
|
+
};
|
|
2418
|
+
o.addEventListener("input", () => {
|
|
2419
|
+
let e = o.value.replace(/[^0-9]/g, ""), t = ae(this._country);
|
|
2420
|
+
t && e.length > t && (e = e.slice(0, t)), this._national = e;
|
|
2421
|
+
let n = V(this._country, this._national);
|
|
2422
|
+
o.value !== n && (o.value = n), this._commit(), o.classList.contains("is-invalid") && (!this._national || U(this.value) === !0) && _(!1);
|
|
2423
|
+
}), o.addEventListener("blur", () => {
|
|
2424
|
+
_(this._national.length > 0 && U(this.value) === !1);
|
|
2425
|
+
}), o.addEventListener("paste", (e) => {
|
|
2426
|
+
let t = oe(e.clipboardData?.getData("text"));
|
|
2427
|
+
t && (e.preventDefault(), this._national = t.national.replace(/[^0-9]/g, ""), t.country === this._country ? o.value = V(this._country, this._national) : this.setAttribute("country", t.country), this._commit(), this.querySelector("input[type=tel]")?.focus());
|
|
1944
2428
|
}), this._onDocClick = (e) => {
|
|
1945
|
-
|
|
1946
|
-
}, document.addEventListener("click", this._onDocClick),
|
|
2429
|
+
u() && !this.contains(e.target) && p();
|
|
2430
|
+
}, document.addEventListener("click", this._onDocClick), ie().then((e) => {
|
|
2431
|
+
if (!(!e || !o) && (this._national && (o.value = V(this._country, this._national)), !this.getAttribute("placeholder"))) {
|
|
2432
|
+
let e = H(this._country);
|
|
2433
|
+
e && (o.placeholder = e);
|
|
2434
|
+
}
|
|
2435
|
+
}), c(this, this.value);
|
|
1947
2436
|
}
|
|
1948
2437
|
disconnectedCallback() {
|
|
1949
2438
|
this._reposition && (window.removeEventListener("scroll", this._reposition, !0), window.removeEventListener("resize", this._reposition)), this._onDocClick && document.removeEventListener("click", this._onDocClick);
|
|
1950
2439
|
}
|
|
1951
|
-
},
|
|
2440
|
+
}, G = (e) => String(e ?? "").replace(/"/g, """).replace(/</g, "<"), K = class extends HTMLElement {
|
|
1952
2441
|
static get observedAttributes() {
|
|
1953
2442
|
return [
|
|
1954
2443
|
"value",
|
|
@@ -2008,19 +2497,19 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
2008
2497
|
d && (this._value = String(d.value)), c(this, this._value);
|
|
2009
2498
|
let p = e.map((e) => {
|
|
2010
2499
|
let t = String(e.value) === String(this._value);
|
|
2011
|
-
return `<button type="button" role="option" class="search-select-option${t ? " selected" : ""}" data-value="${
|
|
2500
|
+
return `<button type="button" role="option" class="search-select-option${t ? " selected" : ""}" data-value="${q(e.value)}" aria-selected="${t}">${f(e)}</button>`;
|
|
2012
2501
|
}).join("");
|
|
2013
2502
|
this.innerHTML = `
|
|
2014
2503
|
<div class="search-select${this.hasAttribute("compact") ? " search-select-compact" : ""}${i}">
|
|
2015
|
-
<button type="button" role="combobox" class="input search-select-control" aria-haspopup="listbox" aria-expanded="false" aria-label="${
|
|
2016
|
-
${a ? `<i class="bi bi-${
|
|
2504
|
+
<button type="button" role="combobox" class="input search-select-control" aria-haspopup="listbox" aria-expanded="false" aria-label="${q(this._accessibleName())}"${this.hasAttribute("disabled") ? " disabled" : ""}>
|
|
2505
|
+
${a ? `<i class="bi bi-${q(a)} search-select-icon" aria-hidden="true"></i>` : ""}
|
|
2017
2506
|
${o ? `<span class="search-select-prefix">${u(o)}</span>` : ""}
|
|
2018
2507
|
<span class="${d ? "" : "search-select-placeholder"}" data-label>${d ? f(d) : u(s)}</span>
|
|
2019
2508
|
${n ? "<span class=\"search-select-reset\" role=\"button\" aria-label=\"Clear selection\" hidden><i class=\"bi bi-x-lg\" aria-hidden=\"true\"></i></span>" : ""}
|
|
2020
2509
|
<i class="bi bi-chevron-down search-select-caret" aria-hidden="true"></i>
|
|
2021
2510
|
</button>
|
|
2022
2511
|
<div class="search-select-menu search-select-menu-fixed" role="listbox" tabindex="-1" hidden>
|
|
2023
|
-
${t ? `<div class="search-select-search"><i class="bi bi-search" aria-hidden="true"></i><input class="search-select-input" placeholder="${
|
|
2512
|
+
${t ? `<div class="search-select-search"><i class="bi bi-search" aria-hidden="true"></i><input class="search-select-input" placeholder="${q(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>` : ""}
|
|
2024
2513
|
<div class="search-select-options">${p}<div class="search-select-empty" hidden>No matches</div></div>
|
|
2025
2514
|
</div>
|
|
2026
2515
|
</div>`, this._rendered = !0, c(this, this._value), this._wire(), this._syncReset();
|
|
@@ -2112,14 +2601,14 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
2112
2601
|
disconnectedCallback() {
|
|
2113
2602
|
this._onDocClick && document.removeEventListener("click", this._onDocClick), o(this);
|
|
2114
2603
|
}
|
|
2115
|
-
},
|
|
2604
|
+
}, q = (e) => String(e ?? "").replace(/"/g, """).replace(/</g, "<"), J = "image/png,image/jpeg,image/webp", se = 5, ce = {
|
|
2116
2605
|
"image/png": [".png"],
|
|
2117
2606
|
"image/jpeg": [".jpg", ".jpeg"],
|
|
2118
2607
|
"image/webp": [".webp"],
|
|
2119
2608
|
"image/gif": [".gif"],
|
|
2120
2609
|
"image/svg+xml": [".svg"],
|
|
2121
2610
|
"application/pdf": [".pdf"]
|
|
2122
|
-
},
|
|
2611
|
+
}, le = {
|
|
2123
2612
|
"image/png": "PNG",
|
|
2124
2613
|
"image/jpeg": "JPG",
|
|
2125
2614
|
"image/webp": "WEBP",
|
|
@@ -2133,34 +2622,34 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
|
|
|
2133
2622
|
".gif": "GIF",
|
|
2134
2623
|
".svg": "SVG",
|
|
2135
2624
|
".pdf": "PDF"
|
|
2136
|
-
},
|
|
2137
|
-
function
|
|
2625
|
+
}, Y = (e) => String(e || "").split(",").map((e) => e.trim().toLowerCase()).filter(Boolean);
|
|
2626
|
+
function X(e) {
|
|
2138
2627
|
let t = [];
|
|
2139
|
-
for (let n of
|
|
2140
|
-
let e =
|
|
2628
|
+
for (let n of Y(e)) {
|
|
2629
|
+
let e = le[n] || (n.startsWith(".") ? n.slice(1).toUpperCase() : n.toUpperCase());
|
|
2141
2630
|
t.includes(e) || t.push(e);
|
|
2142
2631
|
}
|
|
2143
2632
|
return t.length <= 1 ? t[0] || "supported" : `${t.slice(0, -1).join(", ")} or ${t[t.length - 1]}`;
|
|
2144
2633
|
}
|
|
2145
|
-
function
|
|
2146
|
-
let n =
|
|
2634
|
+
function Z(e, t) {
|
|
2635
|
+
let n = Y(t);
|
|
2147
2636
|
if (!n.length) return !0;
|
|
2148
2637
|
let r = (e.type || "").toLowerCase(), i = (e.name || "").toLowerCase();
|
|
2149
|
-
return n.some((e) => e.startsWith(".") ? i.endsWith(e) : e.endsWith("/*") ? r.startsWith(e.slice(0, -1)) : r && r === e ? !0 : !r && (
|
|
2638
|
+
return n.some((e) => e.startsWith(".") ? i.endsWith(e) : e.endsWith("/*") ? r.startsWith(e.slice(0, -1)) : r && r === e ? !0 : !r && (ce[e] || []).some((e) => i.endsWith(e)));
|
|
2150
2639
|
}
|
|
2151
|
-
function
|
|
2640
|
+
function ue(e, t = {}) {
|
|
2152
2641
|
if (!e) return null;
|
|
2153
|
-
let n = t.accept === void 0 ?
|
|
2154
|
-
return
|
|
2642
|
+
let n = t.accept === void 0 ? J : t.accept, r = t.maxSizeMb || 5;
|
|
2643
|
+
return Z(e, n) ? e.size > r * 1024 * 1024 ? `Keep the file under ${r} MB.` : null : `Choose a ${X(n)} file.`;
|
|
2155
2644
|
}
|
|
2156
2645
|
//#endregion
|
|
2157
2646
|
//#region src/index.js
|
|
2158
|
-
var
|
|
2647
|
+
var Q = (e, t) => {
|
|
2159
2648
|
typeof customElements < "u" && !customElements.get(e) && customElements.define(e, t);
|
|
2160
2649
|
};
|
|
2161
|
-
function
|
|
2162
|
-
|
|
2650
|
+
function $() {
|
|
2651
|
+
Q("wui-select", K), Q("wui-phone", W), Q("wui-datepicker", w), Q("wui-date-range", M), Q("wui-autocomplete", p), Q("wui-multiselect", N), Q("wui-otp", F), Q("wui-status-icon", n);
|
|
2163
2652
|
}
|
|
2164
|
-
|
|
2653
|
+
$();
|
|
2165
2654
|
//#endregion
|
|
2166
|
-
export {
|
|
2655
|
+
export { J as DEFAULT_IMAGE_ACCEPT, se as DEFAULT_MAX_SIZE_MB, t as STATUS_TONES, p as WuiAutocomplete, w as WuiDatePicker, M as WuiDateRange, N as WuiMultiSelect, F as WuiOtp, W as WuiPhone, K as WuiSelect, n as WuiStatusIcon, X as acceptLabel, $ as defineWeborityElements, Z as matchesAccept, ue as validateFile };
|