@webority/ui-elements 0.7.6 → 0.7.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -76,7 +76,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
76
76
  ];
77
77
  }
78
78
  constructor() {
79
- super(), this._value = "", this._label = "", this._optionsProp = null, this._loading = !1, this._active = -1, this._timer = null, this._reqSeq = 0;
79
+ super(), this._value = "", this._label = "", this._optionsProp = null, this._loading = !1, this._active = -1, this._timer = null, this._reqSeq = 0, this._pendingSearch = null;
80
80
  try {
81
81
  this._internals = this.attachInternals();
82
82
  } catch {
@@ -84,7 +84,14 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
84
84
  }
85
85
  }
86
86
  connectedCallback() {
87
- this._rendered || (this._defaultCaptured ||= (this._defaultValue = this._value, !0), this.render());
87
+ if (!this._rendered) {
88
+ this._defaultCaptured ||= (this._defaultValue = this._value, !0), this.render();
89
+ return;
90
+ }
91
+ if (this._bindGlobal?.(), this._pendingSearch) {
92
+ let { query: e, seq: t } = this._pendingSearch;
93
+ clearTimeout(this._timer), this._timer = setTimeout(() => this._fireSearch(e, t), this._debounceMs);
94
+ }
88
95
  }
89
96
  formResetCallback() {
90
97
  this.value = this._defaultValue || "";
@@ -154,14 +161,16 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
154
161
  render() {
155
162
  this._snapshotDeclared();
156
163
  let e = this.getAttribute("placeholder") || "Search…", t = this.getAttribute("size"), n = t === "sm" ? " search-select-sm" : t === "lg" ? " search-select-lg" : "";
157
- this.innerHTML = `
164
+ this.id ||= `wui-autocomplete-${Math.random().toString(36).slice(2, 9)}`;
165
+ let r = `${this.id}-listbox`;
166
+ this._listboxId = r, this.innerHTML = `
158
167
  <div class="search-select${n}">
159
- <div class="input search-select-control search-select-ac" role="combobox" aria-haspopup="listbox" aria-expanded="false" aria-label="${m(this._accessibleName())}">
168
+ <div class="input search-select-control search-select-ac" role="combobox" aria-haspopup="listbox" aria-expanded="false" aria-controls="${m(r)}" aria-label="${m(this._accessibleName())}">
160
169
  <input class="search-select-input search-select-ac-input" placeholder="${m(e)}" aria-autocomplete="list" autocomplete="off"${this.hasAttribute("disabled") ? " disabled" : ""} />
161
170
  <span class="search-select-spinner spinner-border spinner-border-sm" role="status" aria-hidden="true" hidden></span>
162
171
  <button type="button" class="search-select-clear" aria-label="Clear" hidden><i class="bi bi-x" aria-hidden="true"></i></button>
163
172
  </div>
164
- <div class="search-select-menu search-select-menu-fixed" role="listbox" tabindex="-1" hidden>
173
+ <div class="search-select-menu search-select-menu-fixed" role="listbox" id="${m(r)}" tabindex="-1" hidden>
165
174
  <div class="search-select-options"></div>
166
175
  <div class="search-select-empty" hidden>No matches</div>
167
176
  <div class="search-select-hint" hidden>Type to search…</div>
@@ -199,27 +208,28 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
199
208
  let a = n.trim(), o = this._allowCustom && a && !this._matchesKnownOption(a) ? [...i, {
200
209
  value: a,
201
210
  custom: !0
202
- }] : i;
203
- t.optionsWrap.innerHTML = o.map((e) => {
211
+ }] : i, s = this._listboxId || `${this.id || "wui-autocomplete"}-listbox`;
212
+ t.optionsWrap.innerHTML = o.map((e, t) => {
213
+ let n = `${s}-opt-${t}`;
204
214
  if (e.custom) {
205
215
  let t = `Add “${u(e.value)}”`;
206
- return `<button type="button" role="option" class="search-select-option search-select-option-custom" data-value="${m(e.value)}" data-custom="true" aria-selected="false">${t}</button>`;
216
+ return `<button type="button" role="option" id="${m(n)}" class="search-select-option search-select-option-custom" data-value="${m(e.value)}" data-custom="true" aria-selected="false">${t}</button>`;
207
217
  }
208
- let t = String(e.value) === String(this._value);
209
- return `<button type="button" role="option" class="search-select-option${t ? " selected" : ""}" data-value="${m(e.value)}" aria-selected="${t}">${f(e)}</button>`;
210
- }).join(""), this._active = -1;
211
- let s = r.length < this._minChars;
212
- t.hint && (t.hint.hidden = !(this._remote && s && !i.length)), t.empty && (t.empty.hidden = this._loading || o.length > 0 || this._remote && s);
218
+ let r = String(e.value) === String(this._value);
219
+ return `<button type="button" role="option" id="${m(n)}" class="search-select-option${r ? " selected" : ""}" data-value="${m(e.value)}" aria-selected="${r}">${f(e)}</button>`;
220
+ }).join(""), this._active = -1, t.control?.removeAttribute("aria-activedescendant");
221
+ let c = r.length < this._minChars;
222
+ t.hint && (t.hint.hidden = !(this._remote && c && !i.length)), t.empty && (t.empty.hidden = this._loading || o.length > 0 || this._remote && c);
213
223
  }
214
224
  _wire() {
215
225
  this._teardown();
216
226
  let e = this._refs();
217
227
  if (!e.control || !e.input) return;
218
- let t = () => i(e.control, e.menu, { matchWidth: !0 }), n = () => this._optionEls().filter((e) => !e.hidden), r = (e) => {
219
- let t = n();
220
- this._active = e;
228
+ let t = () => i(e.control, e.menu, { matchWidth: !0 }), n = () => this._optionEls().filter((e) => !e.hidden), r = (t) => {
229
+ let r = n();
230
+ this._active = t;
221
231
  for (let e of this._optionEls()) e.classList.remove("is-active");
222
- e >= 0 && t[e] && (t[e].classList.add("is-active"), t[e].scrollIntoView({ block: "nearest" }));
232
+ t >= 0 && r[t] ? (r[t].classList.add("is-active"), r[t].scrollIntoView({ block: "nearest" }), e.control.setAttribute("aria-activedescendant", r[t].id)) : e.control.removeAttribute("aria-activedescendant");
223
233
  }, o = () => !e.menu.hidden, s = () => {
224
234
  e.menu.hidden = !1, e.control.setAttribute("aria-expanded", "true"), e.control.classList.add("open"), t(), this._renderOptions();
225
235
  }, l = () => {
@@ -239,17 +249,15 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
239
249
  e.input.addEventListener("focus", () => s()), e.input.addEventListener("input", () => {
240
250
  let t = e.input.value;
241
251
  if (e.clear && (e.clear.hidden = !t), o() || s(), this._remote) {
242
- if (this._renderOptions(t), clearTimeout(this._timer), t.trim().length < this._minChars) return;
252
+ if (this._renderOptions(t), clearTimeout(this._timer), t.trim().length < this._minChars) {
253
+ this._pendingSearch = null;
254
+ return;
255
+ }
243
256
  let e = ++this._reqSeq;
244
- this._timer = setTimeout(() => {
245
- this.dispatchEvent(new CustomEvent("search", {
246
- bubbles: !0,
247
- detail: {
248
- query: t,
249
- seq: e
250
- }
251
- }));
252
- }, this._debounceMs);
257
+ this._pendingSearch = {
258
+ query: t,
259
+ seq: e
260
+ }, this._timer = setTimeout(() => this._fireSearch(t, e), this._debounceMs);
253
261
  } else this._renderOptions(t);
254
262
  }), e.input.addEventListener("keydown", (t) => {
255
263
  let i = n();
@@ -274,14 +282,25 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
274
282
  t && r(this._optionEls().indexOf(t));
275
283
  }), e.optionsWrap.addEventListener("mouseleave", () => r(-1)), e.clear?.addEventListener("click", () => {
276
284
  this._value = "", this._label = "", c(this, ""), e.input.value = "", e.clear.hidden = !0, this._renderOptions(""), this.dispatchEvent(new Event("change", { bubbles: !0 })), e.input.focus();
277
- }), this._onDocClick = (e) => {
278
- o() && !this.contains(e.target) && l();
279
- }, document.addEventListener("click", this._onDocClick), a(this, () => {
280
- o() && t();
281
- });
285
+ }), this._bindGlobal = () => {
286
+ this._teardown(), this._onDocClick = (e) => {
287
+ o() && !this.contains(e.target) && l();
288
+ }, document.addEventListener("click", this._onDocClick), a(this, () => {
289
+ o() && t();
290
+ });
291
+ }, this._bindGlobal();
292
+ }
293
+ _fireSearch(e, t) {
294
+ this._pendingSearch = null, this.dispatchEvent(new CustomEvent("search", {
295
+ bubbles: !0,
296
+ detail: {
297
+ query: e,
298
+ seq: t
299
+ }
300
+ }));
282
301
  }
283
302
  _teardown() {
284
- this._onDocClick && document.removeEventListener("click", this._onDocClick), o(this), clearTimeout(this._timer);
303
+ this._onDocClick &&= (document.removeEventListener("click", this._onDocClick), null), o(this), clearTimeout(this._timer);
285
304
  }
286
305
  disconnectedCallback() {
287
306
  this._teardown();
@@ -314,17 +333,17 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
314
333
  m: t[2] - 1,
315
334
  d: +t[3]
316
335
  } : null;
317
- }, ee = (e) => {
336
+ }, x = (e) => {
318
337
  let t = b(e);
319
338
  return t ? `${v(t.d)} ${g[t.m].slice(0, 3)} ${t.y}` : "";
320
- }, x = (e, t) => new Date(e, t + 1, 0).getDate(), S = (e, t) => {
339
+ }, S = (e, t) => new Date(e, t + 1, 0).getDate(), C = (e, t) => {
321
340
  for (; t < 0;) t += 12, --e;
322
341
  for (; t > 11;) t -= 12, e += 1;
323
342
  return {
324
343
  y: e,
325
344
  m: t
326
345
  };
327
- }, te = class extends HTMLElement {
346
+ }, w = class extends HTMLElement {
328
347
  static formAssociated = !0;
329
348
  static get observedAttributes() {
330
349
  return [
@@ -351,7 +370,11 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
351
370
  this._viewY = e.getFullYear(), this._viewM = e.getMonth(), this._mode = "days", this._focus = null, this._slide = "";
352
371
  }
353
372
  connectedCallback() {
354
- this._rendered || this.render();
373
+ if (!this._rendered) {
374
+ this.render();
375
+ return;
376
+ }
377
+ this._bindGlobal?.();
355
378
  }
356
379
  attributeChangedCallback(e, t, n) {
357
380
  this._rendered && (e === "value" ? (this._value = n || "", this._syncFormValue(), this._syncTrigger()) : e === "first-day" ? this.querySelector(".datepicker-pop")?.hidden || this._renderView() : this.render());
@@ -370,14 +393,14 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
370
393
  return Number.isInteger(e) && e >= 0 && e <= 6 ? e : 0;
371
394
  }
372
395
  render() {
373
- this._defaultValue === void 0 && (this._defaultValue = this.getAttribute("value") || ""), this._value = this.getAttribute("value") || this._value;
396
+ this._defaultValue === void 0 && (this._defaultValue = this.getAttribute("value") || "", this._value = this._defaultValue || this._value);
374
397
  let e = this.getAttribute("placeholder") || "Enter Date", t = b(this._value);
375
398
  t && (this._viewY = t.y, this._viewM = t.m);
376
399
  let n = this.getAttribute("size"), r = n === "sm" ? " input-sm" : n === "lg" ? " input-lg" : "", i = this.getAttribute("aria-label"), a = this.getAttribute("aria-describedby");
377
400
  this.innerHTML = `
378
401
  <div class="datepicker">
379
402
  <button type="button" class="input datepicker-trigger${r}${t ? " has-value" : ""}" aria-haspopup="dialog" aria-expanded="false"${this.hasAttribute("disabled") ? " disabled" : ""}${i ? ` aria-label="${u(i)}"` : ""}${a ? ` aria-describedby="${u(a)}"` : ""}>
380
- <span data-trigger-label class="${t ? "" : "search-select-placeholder"}">${t ? ee(this._value) : u(e)}</span>
403
+ <span data-trigger-label class="${t ? "" : "search-select-placeholder"}">${t ? x(this._value) : u(e)}</span>
381
404
  <i class="bi bi-calendar3" aria-hidden="true"></i>
382
405
  </button>
383
406
  <div class="datepicker-pop" role="dialog" aria-modal="false" hidden></div>
@@ -390,7 +413,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
390
413
  let e = this.querySelector(".datepicker-trigger"), t = this.querySelector("[data-trigger-label]");
391
414
  if (!t) return;
392
415
  let n = b(this._value);
393
- t.textContent = n ? ee(this._value) : this.getAttribute("placeholder") || "Enter Date", t.classList.toggle("search-select-placeholder", !n), e?.classList.toggle("has-value", !!n);
416
+ t.textContent = n ? x(this._value) : this.getAttribute("placeholder") || "Enter Date", t.classList.toggle("search-select-placeholder", !n), e?.classList.toggle("has-value", !!n);
394
417
  }
395
418
  _limits() {
396
419
  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;
@@ -401,7 +424,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
401
424
  },
402
425
  monthDisabled: (e, t) => {
403
426
  let i = new Date(e, t, 1).getTime();
404
- return new Date(e, t, x(e, t)).getTime() < n || i > r;
427
+ return new Date(e, t, S(e, t)).getTime() < n || i > r;
405
428
  },
406
429
  yearDisabled: (e) => {
407
430
  let t = new Date(e, 0, 1).getTime();
@@ -414,7 +437,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
414
437
  e && (this._mode === "months" ? e.innerHTML = this._monthsHtml() : this._mode === "years" ? e.innerHTML = this._yearsHtml() : e.innerHTML = this._daysHtml(), this._focusActive());
415
438
  }
416
439
  _daysHtml() {
417
- let e = this._firstDay(), t = (new Date(this._viewY, this._viewM, 1).getDay() - e + 7) % 7, n = x(this._viewY, this._viewM), r = b(this._value), i = /* @__PURE__ */ new Date(), { dayDisabled: a } = this._limits(), o = this._focus || r || {
440
+ 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 || {
418
441
  y: this._viewY,
419
442
  m: this._viewM,
420
443
  d: 1
@@ -426,10 +449,10 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
426
449
  u ? "is-today" : "",
427
450
  l ? "is-selected" : ""
428
451
  ].filter(Boolean).join(" ")}" data-iso="${c}" role="gridcell" tabindex="${d && !f ? "0" : "-1"}"${l ? " aria-selected=\"true\"" : ""}${f ? " disabled aria-disabled=\"true\"" : ""}>${n}</button>`;
429
- }, c = "", l = S(this._viewY, this._viewM - 1), u = x(l.y, l.m);
452
+ }, c = "", l = C(this._viewY, this._viewM - 1), u = S(l.y, l.m);
430
453
  for (let e = t - 1; e >= 0; e--) c += s(l.y, l.m, u - e, !0);
431
454
  for (let e = 1; e <= n; e++) c += s(this._viewY, this._viewM, e, !1);
432
- let d = S(this._viewY, this._viewM + 1), f = (7 - (t + n) % 7) % 7;
455
+ let d = C(this._viewY, this._viewM + 1), f = (7 - (t + n) % 7) % 7;
433
456
  for (let e = 1; e <= f; e++) c += s(d.y, d.m, e, !0);
434
457
  let p = _.map((t, n) => _[(n + e) % 7]).map((e) => `<span>${e}</span>`).join("");
435
458
  return `
@@ -489,7 +512,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
489
512
  i(e, t);
490
513
  }
491
514
  _setFocus(e, t, n, r) {
492
- let { y: i, m: a } = S(e, t);
515
+ let { y: i, m: a } = C(e, t);
493
516
  this._focus = {
494
517
  y: i,
495
518
  m: a,
@@ -521,13 +544,13 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
521
544
  case "End": return n(6 - (new Date(t.y, t.m, t.d).getDay() - this._firstDay() + 7) % 7, "slide-next");
522
545
  case "PageUp": {
523
546
  e.preventDefault();
524
- let n = S(t.y, t.m - (e.shiftKey ? 12 : 1));
525
- return this._setFocus(n.y, n.m, Math.min(t.d, x(n.y, n.m)), "slide-prev");
547
+ let n = C(t.y, t.m - (e.shiftKey ? 12 : 1));
548
+ return this._setFocus(n.y, n.m, Math.min(t.d, S(n.y, n.m)), "slide-prev");
526
549
  }
527
550
  case "PageDown": {
528
551
  e.preventDefault();
529
- let n = S(t.y, t.m + (e.shiftKey ? 12 : 1));
530
- return this._setFocus(n.y, n.m, Math.min(t.d, x(n.y, n.m)), "slide-next");
552
+ let n = C(t.y, t.m + (e.shiftKey ? 12 : 1));
553
+ return this._setFocus(n.y, n.m, Math.min(t.d, S(n.y, n.m)), "slide-next");
531
554
  }
532
555
  case "Enter":
533
556
  case " ":
@@ -560,7 +583,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
560
583
  let t = e.target.closest("[data-nav]");
561
584
  if (t) {
562
585
  this._viewNavigated = !0, this._slide = Number(t.dataset.nav) < 0 ? "slide-prev" : "slide-next";
563
- let e = S(this._viewY, this._viewM + Number(t.dataset.nav));
586
+ let e = C(this._viewY, this._viewM + Number(t.dataset.nav));
564
587
  this._viewY = e.y, this._viewM = e.m, this._focus = {
565
588
  y: e.y,
566
589
  m: e.m,
@@ -610,22 +633,24 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
610
633
  s && !s.disabled && (this.value = s.dataset.iso, this.dispatchEvent(new Event("change", { bubbles: !0 })), this._close());
611
634
  }), this._onKeyBound = (e) => {
612
635
  r() && this._onKey(e);
613
- }, t.addEventListener("keydown", this._onKeyBound), this._onDocClick = (e) => {
614
- let t = this._popClick;
615
- this._popClick = !1, r() && !t && !this.contains(e.target) && this._close();
616
- }, document.addEventListener("click", this._onDocClick), this._onDocKey = (e) => {
617
- r() && e.key === "Escape" && this._close();
618
- }, document.addEventListener("keydown", this._onDocKey), a(this, () => {
619
- r() && this._position(e, t);
620
- }), this._syncFormValue();
636
+ }, t.addEventListener("keydown", this._onKeyBound), this._bindGlobal = () => {
637
+ this._teardown(), this._onDocClick = (e) => {
638
+ let t = this._popClick;
639
+ this._popClick = !1, r() && !t && !this.contains(e.target) && this._close();
640
+ }, document.addEventListener("click", this._onDocClick), this._onDocKey = (e) => {
641
+ r() && e.key === "Escape" && this._close();
642
+ }, document.addEventListener("keydown", this._onDocKey), a(this, () => {
643
+ r() && this._position(e, t);
644
+ });
645
+ }, this._bindGlobal(), this._syncFormValue();
621
646
  }
622
647
  _teardown() {
623
- this._onDocClick && document.removeEventListener("click", this._onDocClick), this._onDocKey && document.removeEventListener("keydown", this._onDocKey), o(this);
648
+ this._onDocClick &&= (document.removeEventListener("click", this._onDocClick), null), this._onDocKey &&= (document.removeEventListener("keydown", this._onDocKey), null), o(this);
624
649
  }
625
650
  disconnectedCallback() {
626
651
  this._teardown();
627
652
  }
628
- }, C = [
653
+ }, ee = [
629
654
  "January",
630
655
  "February",
631
656
  "March",
@@ -638,7 +663,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
638
663
  "October",
639
664
  "November",
640
665
  "December"
641
- ], w = [
666
+ ], te = [
642
667
  "Su",
643
668
  "Mo",
644
669
  "Tu",
@@ -655,7 +680,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
655
680
  } : null;
656
681
  }, D = (e) => {
657
682
  let t = E(e);
658
- return t ? `${T(t.d)} ${C[t.m].slice(0, 3)} ${t.y}` : "";
683
+ return t ? `${T(t.d)} ${ee[t.m].slice(0, 3)} ${t.y}` : "";
659
684
  }, O = (e, t) => new Date(e, t + 1, 0).getDate(), k = (e, t) => {
660
685
  for (; t < 0;) t += 12, --e;
661
686
  for (; t > 11;) t -= 12, e += 1;
@@ -663,7 +688,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
663
688
  y: e,
664
689
  m: t
665
690
  };
666
- }, A = class extends HTMLElement {
691
+ }, re = class extends HTMLElement {
667
692
  static formAssociated = !0;
668
693
  static get observedAttributes() {
669
694
  return [
@@ -694,7 +719,11 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
694
719
  this._viewY = e.getFullYear(), this._viewM = e.getMonth();
695
720
  }
696
721
  connectedCallback() {
697
- this._rendered || this.render();
722
+ if (!this._rendered) {
723
+ this.render();
724
+ return;
725
+ }
726
+ this._bindGlobal?.();
698
727
  }
699
728
  attributeChangedCallback(e, t, n) {
700
729
  this._rendered && (e === "start" || e === "end" ? (this._start = this.getAttribute("start") || "", this._end = this.getAttribute("end") || "", this._syncTrigger(), this._syncMirrors()) : this.render());
@@ -723,7 +752,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
723
752
  };
724
753
  }
725
754
  render() {
726
- this._defaultStart === void 0 && (this._defaultStart = this.getAttribute("start") || "", this._defaultEnd = this.getAttribute("end") || ""), this._start = this.getAttribute("start") || this._start, this._end = this.getAttribute("end") || this._end;
755
+ this._defaultStart === void 0 && (this._defaultStart = this.getAttribute("start") || "", this._defaultEnd = this.getAttribute("end") || "", this._start = this._defaultStart || this._start, this._end = this._defaultEnd || this._end);
727
756
  let e = E(this._start);
728
757
  e && (this._viewY = e.y, this._viewM = e.m);
729
758
  let t = this.getAttribute("size"), n = t === "sm" ? " input-sm" : t === "lg" ? " input-lg" : "", { text: r, empty: i } = this._label(), a = this.getAttribute("aria-label"), o = this.getAttribute("aria-describedby");
@@ -765,7 +794,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
765
794
  };
766
795
  }
767
796
  _monthHtml(e, t) {
768
- let n = this._firstDay(), r = (new Date(e, t, 1).getDay() - n + 7) % 7, i = O(e, t), a = this._limits(), o = w.map((e, t) => w[(t + n) % 7]).map((e) => `<span>${e}</span>`).join(""), s = (e, t, n, r) => {
797
+ let n = this._firstDay(), r = (new Date(e, t, 1).getDay() - n + 7) % 7, i = O(e, t), a = this._limits(), o = te.map((e, t) => te[(t + n) % 7]).map((e) => `<span>${e}</span>`).join(""), s = (e, t, n, r) => {
769
798
  let i = ne(e, t, n), o = a(e, t, n);
770
799
  return `<button type="button" class="${["datepicker-day", r ? "is-outside" : ""].filter(Boolean).join(" ")}" data-iso="${i}"${o ? " disabled" : ""}>${n}</button>`;
771
800
  }, c = "", l = k(e, t - 1), u = O(l.y, l.m);
@@ -775,7 +804,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
775
804
  for (let e = 1; e <= f; e++) c += s(d.y, d.m, e, !0);
776
805
  return `
777
806
  <div class="daterange-cal">
778
- <div class="datepicker-month-label">${C[t]} ${e}</div>
807
+ <div class="datepicker-month-label">${ee[t]} ${e}</div>
779
808
  <div class="datepicker-weekdays">${o}</div>
780
809
  <div class="datepicker-grid" role="grid">${c}</div>
781
810
  </div>`;
@@ -857,22 +886,24 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
857
886
  }), t.addEventListener("mouseover", (e) => {
858
887
  let t = e.target.closest(".datepicker-day[data-iso]");
859
888
  t && this._start && !this._end && (this._hover = t.dataset.iso, this._paint());
860
- }), this._onDocClick = (e) => {
861
- let t = this._popClick;
862
- this._popClick = !1, r() && !t && !this.contains(e.target) && this._close();
863
- }, document.addEventListener("click", this._onDocClick), this._onDocKey = (e) => {
864
- r() && e.key === "Escape" && this._close();
865
- }, document.addEventListener("keydown", this._onDocKey), a(this, () => {
866
- r() && this._position(e, t);
867
- }), this._syncMirrors();
889
+ }), this._bindGlobal = () => {
890
+ this._teardown(), this._onDocClick = (e) => {
891
+ let t = this._popClick;
892
+ this._popClick = !1, r() && !t && !this.contains(e.target) && this._close();
893
+ }, document.addEventListener("click", this._onDocClick), this._onDocKey = (e) => {
894
+ r() && e.key === "Escape" && this._close();
895
+ }, document.addEventListener("keydown", this._onDocKey), a(this, () => {
896
+ r() && this._position(e, t);
897
+ });
898
+ }, this._bindGlobal(), this._syncMirrors();
868
899
  }
869
900
  _teardown() {
870
- this._onDocClick && document.removeEventListener("click", this._onDocClick), this._onDocKey && document.removeEventListener("keydown", this._onDocKey), o(this);
901
+ this._onDocClick &&= (document.removeEventListener("click", this._onDocClick), null), this._onDocKey &&= (document.removeEventListener("keydown", this._onDocKey), null), o(this);
871
902
  }
872
903
  disconnectedCallback() {
873
904
  this._teardown();
874
905
  }
875
- }, j = class extends HTMLElement {
906
+ }, ie = class extends HTMLElement {
876
907
  static formAssociated = !0;
877
908
  _accessibleName() {
878
909
  return this.getAttribute("aria-label") || this.getAttribute("placeholder") || "Select";
@@ -900,11 +931,17 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
900
931
  connectedCallback() {
901
932
  if (!this._rendered) {
902
933
  if (!this._valuesInit && !this._optionsProp && !this._values.length) {
903
- let e = [...this.querySelectorAll(":scope > wui-option[selected]")].map((e) => e.getAttribute("value") ?? e.textContent.trim());
904
- e.length && (this._values = e.map(String));
934
+ let e = this.getAttribute("value");
935
+ if (e != null && e !== "") this._values = e.split(",").map((e) => e.trim()).filter(Boolean);
936
+ else {
937
+ let e = [...this.querySelectorAll(":scope > wui-option[selected]")].map((e) => e.getAttribute("value") ?? e.textContent.trim());
938
+ e.length && (this._values = e.map(String));
939
+ }
905
940
  }
906
941
  this._valuesInit = !0, this._defaultCaptured ||= (this._defaultValues = this._values.slice(), !0), this.render();
942
+ return;
907
943
  }
944
+ this._bindGlobal?.();
908
945
  }
909
946
  formResetCallback() {
910
947
  this.values = (this._defaultValues || []).slice();
@@ -916,7 +953,11 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
916
953
  return this._values.slice();
917
954
  }
918
955
  set values(e) {
919
- this._values = Array.isArray(e) ? e.map(String) : [], c(this, this._values.join(",")), this._rendered && this._renderControl();
956
+ if (this._values = Array.isArray(e) ? e.map(String) : [], c(this, this._values.join(",")), this._rendered) {
957
+ this._renderControl();
958
+ let e = this.querySelector(".search-select-input");
959
+ this._renderOptions(e ? e.value : "");
960
+ }
920
961
  }
921
962
  set options(e) {
922
963
  this._optionsProp = Array.isArray(e) ? e : null, this.isConnected && this.render();
@@ -949,15 +990,17 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
949
990
  render() {
950
991
  this._snapshotDeclared();
951
992
  let e = this.hasAttribute("searchable"), t = this.getAttribute("search-placeholder") || "Search…", n = this.getAttribute("icon"), r = this.getAttribute("size"), i = r === "sm" ? " search-select-sm" : r === "lg" ? " search-select-lg" : "";
952
- c(this, this._values.join(",")), this.innerHTML = `
993
+ c(this, this._values.join(",")), this.id ||= `wui-multiselect-${Math.random().toString(36).slice(2, 9)}`;
994
+ let a = `${this.id}-listbox`;
995
+ this._listboxId = a, this.innerHTML = `
953
996
  <div class="search-select${i}">
954
- <div class="input search-select-control search-select-multi" role="combobox" aria-haspopup="listbox" aria-expanded="false" aria-label="${M(this._accessibleName())}"${this.hasAttribute("disabled") ? " aria-disabled=\"true\"" : " tabindex=\"0\""}>
955
- ${n ? `<i class="bi bi-${M(n)} search-select-icon" aria-hidden="true"></i>` : ""}
997
+ <div class="input search-select-control search-select-multi" role="combobox" aria-haspopup="listbox" aria-expanded="false" aria-controls="${A(a)}" aria-label="${A(this._accessibleName())}"${this.hasAttribute("disabled") ? " aria-disabled=\"true\"" : " tabindex=\"0\""}>
998
+ ${n ? `<i class="bi bi-${A(n)} search-select-icon" aria-hidden="true"></i>` : ""}
956
999
  <div class="ms-chips" data-chips></div>
957
1000
  <i class="bi bi-chevron-down search-select-caret" aria-hidden="true"></i>
958
1001
  </div>
959
- <div class="search-select-menu search-select-menu-fixed" role="listbox" aria-multiselectable="true" tabindex="-1" hidden>
960
- ${e ? `<div class="search-select-search"><i class="bi bi-search" aria-hidden="true"></i><input class="search-select-input" placeholder="${M(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>` : ""}
1002
+ <div class="search-select-menu search-select-menu-fixed" role="listbox" id="${A(a)}" aria-multiselectable="true" tabindex="-1" hidden>
1003
+ ${e ? `<div class="search-select-search"><i class="bi bi-search" aria-hidden="true"></i><input class="search-select-input" placeholder="${A(t)}" aria-autocomplete="list" /><button type="button" class="search-select-clear" aria-label="Clear search" hidden><i class="bi bi-x" aria-hidden="true"></i></button></div>` : ""}
961
1004
  <div class="search-select-options"></div>
962
1005
  <div class="search-select-empty" hidden>No matches</div>
963
1006
  </div>
@@ -971,7 +1014,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
971
1014
  e.innerHTML = `<span class="search-select-placeholder">${u(t)}</span>`;
972
1015
  return;
973
1016
  }
974
- 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="${M(e)}" aria-label="Remove ${re(this._labelFor(e))}"><i class="bi bi-x" aria-hidden="true"></i></button></span>`).join(""), this._collapseChips();
1017
+ e.innerHTML = this._values.map((e) => `<span class="chip chip-sm"><span class="chip-label">${this._labelHtmlFor(e)}</span><button type="button" class="chip-remove" data-remove="${A(e)}" aria-label="Remove ${A(ae(this._labelFor(e)))}"><i class="bi bi-x" aria-hidden="true"></i></button></span>`).join(""), this._collapseChips();
975
1018
  }
976
1019
  _collapseChips() {
977
1020
  let e = this.querySelector("[data-chips]");
@@ -995,22 +1038,22 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
995
1038
  let t = this.querySelector(".search-select-options"), n = this.querySelector(".search-select-empty");
996
1039
  if (!t) return;
997
1040
  let r = (e || "").trim().toLowerCase(), i = this._readOptions();
998
- r && (i = i.filter((e) => re(e.label).toLowerCase().includes(r))), t.innerHTML = i.map((e) => {
999
- let t = this._values.includes(String(e.value));
1000
- return `<button type="button" role="option" class="search-select-option${t ? " selected" : ""}" data-value="${M(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>`;
1001
- }).join(""), n && (n.hidden = i.length > 0), this._active = -1;
1041
+ r && (i = i.filter((e) => ae(e.label).toLowerCase().includes(r)));
1042
+ let a = this._listboxId || `${this.id || "wui-multiselect"}-listbox`;
1043
+ t.innerHTML = i.map((e, t) => {
1044
+ let n = this._values.includes(String(e.value));
1045
+ return `<button type="button" role="option" id="${A(`${a}-opt-${t}`)}" class="search-select-option${n ? " selected" : ""}" data-value="${A(e.value)}" aria-selected="${n}"><span class="ms-opt-label">${f(e)}</span><span class="ms-check"><i class="bi bi-check" aria-hidden="true"></i></span></button>`;
1046
+ }).join(""), n && (n.hidden = i.length > 0), this._active = -1, this.querySelector(".search-select-control")?.removeAttribute("aria-activedescendant");
1002
1047
  }
1003
1048
  _wire() {
1004
1049
  this._teardown();
1005
1050
  let e = this.querySelector(".search-select-control"), t = this.querySelector(".search-select-menu"), n = this.querySelector(".search-select-input"), r = this.querySelector(".search-select-clear"), o = this.querySelector(".search-select-options");
1006
1051
  if (!e || !t) return;
1007
- let s = () => this.hasAttribute("disabled");
1008
- !this._ro && typeof ResizeObserver < "u" && (this._ro = new ResizeObserver(() => this._collapseChips()), this._ro.observe(this));
1009
- let l = () => i(e, t, { matchWidth: !0 }), u = () => [...this.querySelectorAll(".search-select-option")], d = () => u().filter((e) => !e.hidden), f = (e) => {
1010
- let t = d();
1011
- this._active = e;
1052
+ let s = () => this.hasAttribute("disabled"), l = () => i(e, t, { matchWidth: !0 }), u = () => [...this.querySelectorAll(".search-select-option")], d = () => u().filter((e) => !e.hidden), f = (t) => {
1053
+ let n = d();
1054
+ this._active = t;
1012
1055
  for (let e of u()) e.classList.remove("is-active");
1013
- e >= 0 && t[e] && (t[e].classList.add("is-active"), t[e].scrollIntoView({ block: "nearest" }));
1056
+ t >= 0 && n[t] ? (n[t].classList.add("is-active"), n[t].scrollIntoView({ block: "nearest" }), e.setAttribute("aria-activedescendant", n[t].id)) : e.removeAttribute("aria-activedescendant");
1014
1057
  }, p = () => !t.hidden, m = () => {
1015
1058
  s() || (t.hidden = !1, e.setAttribute("aria-expanded", "true"), e.classList.add("open"), l(), n && (n.value = "", this._renderOptions(""), n.focus()));
1016
1059
  }, h = () => {
@@ -1052,19 +1095,21 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
1052
1095
  return;
1053
1096
  }
1054
1097
  (e.key === "ArrowDown" || e.key === "Enter" || e.key === " ") && (e.preventDefault(), m());
1055
- }), this._onDocClick = (e) => {
1056
- p() && !this.contains(e.target) && h();
1057
- }, document.addEventListener("click", this._onDocClick), a(this, () => {
1058
- p() && l();
1059
- });
1098
+ }), this._bindGlobal = () => {
1099
+ this._teardown(), !this._ro && typeof ResizeObserver < "u" && (this._ro = new ResizeObserver(() => this._collapseChips()), this._ro.observe(this)), this._onDocClick = (e) => {
1100
+ p() && !this.contains(e.target) && h();
1101
+ }, document.addEventListener("click", this._onDocClick), a(this, () => {
1102
+ p() && l();
1103
+ });
1104
+ }, this._bindGlobal();
1060
1105
  }
1061
1106
  _teardown() {
1062
- this._onDocClick && document.removeEventListener("click", this._onDocClick), o(this);
1107
+ this._onDocClick &&= (document.removeEventListener("click", this._onDocClick), null), o(this);
1063
1108
  }
1064
1109
  disconnectedCallback() {
1065
1110
  this._teardown(), this._ro?.disconnect(), this._ro = null;
1066
1111
  }
1067
- }, M = (e) => String(e ?? "").replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;"), re = (e) => String(e ?? "").replace(/<[^>]*>/g, ""), ie = /[^0-9]/g, ae = /[^0-9a-zA-Z]/g, oe = class extends HTMLElement {
1112
+ }, A = (e) => String(e ?? "").replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;"), ae = (e) => String(e ?? "").replace(/<[^>]*>/g, ""), oe = /[^0-9]/g, se = /[^0-9a-zA-Z]/g, j = class extends HTMLElement {
1068
1113
  static formAssociated = !0;
1069
1114
  static get observedAttributes() {
1070
1115
  return [
@@ -1095,7 +1140,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
1095
1140
  this._value = this._clean(e), c(this, this._value), this._paint();
1096
1141
  }
1097
1142
  _clean(e) {
1098
- return (e == null ? "" : String(e)).replace(this.mode === "alphanumeric" ? ae : ie, "").slice(0, this.length);
1143
+ return (e == null ? "" : String(e)).replace(this.mode === "alphanumeric" ? se : oe, "").slice(0, this.length);
1099
1144
  }
1100
1145
  constructor() {
1101
1146
  super();
@@ -1175,7 +1220,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
1175
1220
  disconnectedCallback() {
1176
1221
  this._onSelectionChange && document.removeEventListener("selectionchange", this._onSelectionChange);
1177
1222
  }
1178
- }, se = [
1223
+ }, M = [
1179
1224
  [
1180
1225
  "AF",
1181
1226
  "Afghanistan",
@@ -2401,7 +2446,7 @@ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&am
2401
2446
  "Zimbabwe",
2402
2447
  "263"
2403
2448
  ]
2404
- ], N = (e) => (se.find((t) => t[0] === e) || [
2449
+ ], N = (e) => (M.find((t) => t[0] === e) || [
2405
2450
  "",
2406
2451
  "",
2407
2452
  ""
@@ -2515,7 +2560,7 @@ var V = class extends HTMLElement {
2515
2560
  this._defaultValue === void 0 && (this._defaultValue = this.getAttribute("value") || "");
2516
2561
  let e = this.getAttribute("placeholder") || R(this._country) || "Enter phone number";
2517
2562
  this._country = this.getAttribute("country") || this._country;
2518
- let t = se.map(([e, t, n]) => `<button type="button" role="option" class="country-dropdown-item${e === this._country ? " selected" : ""}" data-iso="${e}"><span class="${P(e)}" aria-hidden="true"></span><span class="country-name-text">${t}<span class="country-code-text">+${n}</span></span></button>`).join("");
2563
+ let t = M.map(([e, t, n]) => `<button type="button" role="option" class="country-dropdown-item${e === this._country ? " selected" : ""}" data-iso="${e}"><span class="${P(e)}" aria-hidden="true"></span><span class="country-name-text">${t}<span class="country-code-text">+${n}</span></span></button>`).join("");
2519
2564
  this.innerHTML = `
2520
2565
  <div class="phone-input-wrap">
2521
2566
  <div class="phone-country-adornment">
@@ -2628,7 +2673,11 @@ var V = class extends HTMLElement {
2628
2673
  this._value = "", this._optionsProp = null, this._active = -1;
2629
2674
  }
2630
2675
  connectedCallback() {
2631
- this._rendered || this.render();
2676
+ if (!this._rendered) {
2677
+ this.render();
2678
+ return;
2679
+ }
2680
+ this._bindGlobal?.();
2632
2681
  }
2633
2682
  attributeChangedCallback(e, t, n) {
2634
2683
  if (e === "value") {
@@ -2669,23 +2718,25 @@ var V = class extends HTMLElement {
2669
2718
  render() {
2670
2719
  this._defaultValue === void 0 && (this._defaultValue = this.getAttribute("value") || ""), this._snapshotDeclared();
2671
2720
  let e = this._readOptions(), t = this.hasAttribute("searchable"), n = this.hasAttribute("clearable"), r = this.getAttribute("size"), i = r === "sm" ? " search-select-sm" : r === "lg" ? " search-select-lg" : "", a = this.getAttribute("icon"), o = this.getAttribute("prefix"), s = this.getAttribute("placeholder") || "Select...", l = this.getAttribute("search-placeholder") || "Search...", d = e.find((e) => String(e.value) === String(this._value)) || e.find((e) => e.selected);
2672
- d && (this._value = String(d.value)), c(this, this._value);
2673
- let p = e.map((e) => {
2674
- let t = String(e.value) === String(this._value);
2675
- return `<button type="button" role="option" class="search-select-option${t ? " selected" : ""}" data-value="${W(e.value)}" aria-selected="${t}">${f(e)}</button>`;
2721
+ d && (this._value = String(d.value)), c(this, this._value), this.id ||= `wui-select-${Math.random().toString(36).slice(2, 9)}`;
2722
+ let p = `${this.id}-listbox`;
2723
+ this._listboxId = p;
2724
+ let m = e.map((e, t) => {
2725
+ let n = String(e.value) === String(this._value);
2726
+ return `<button type="button" role="option" id="${W(`${p}-opt-${t}`)}" class="search-select-option${n ? " selected" : ""}" data-value="${W(e.value)}" aria-selected="${n}">${f(e)}</button>`;
2676
2727
  }).join("");
2677
2728
  this.innerHTML = `
2678
2729
  <div class="search-select${this.hasAttribute("compact") ? " search-select-compact" : ""}${i}">
2679
- <button type="button" role="combobox" class="input search-select-control" aria-haspopup="listbox" aria-expanded="false" aria-label="${W(this._accessibleName())}"${this.hasAttribute("disabled") ? " disabled" : ""}>
2730
+ <button type="button" role="combobox" class="input search-select-control" aria-haspopup="listbox" aria-expanded="false" aria-controls="${W(p)}" aria-label="${W(this._accessibleName())}"${this.hasAttribute("disabled") ? " disabled" : ""}>
2680
2731
  ${a ? `<i class="bi bi-${W(a)} search-select-icon" aria-hidden="true"></i>` : ""}
2681
2732
  ${o ? `<span class="search-select-prefix">${u(o)}</span>` : ""}
2682
2733
  <span class="${d ? "" : "search-select-placeholder"}" data-label>${d ? f(d) : u(s)}</span>
2683
2734
  ${n ? "<span class=\"search-select-reset\" role=\"button\" aria-label=\"Clear selection\" hidden><i class=\"bi bi-x-lg\" aria-hidden=\"true\"></i></span>" : ""}
2684
2735
  <i class="bi bi-chevron-down search-select-caret" aria-hidden="true"></i>
2685
2736
  </button>
2686
- <div class="search-select-menu search-select-menu-fixed" role="listbox" tabindex="-1" hidden>
2737
+ <div class="search-select-menu search-select-menu-fixed" role="listbox" id="${W(p)}" tabindex="-1" hidden>
2687
2738
  ${t ? `<div class="search-select-search"><i class="bi bi-search" aria-hidden="true"></i><input class="search-select-input" placeholder="${W(l)}" aria-autocomplete="list" /><button type="button" class="search-select-clear" aria-label="Clear search" hidden><i class="bi bi-x" aria-hidden="true"></i></button></div>` : ""}
2688
- <div class="search-select-options">${p}<div class="search-select-empty" hidden>No matches</div></div>
2739
+ <div class="search-select-options">${m}<div class="search-select-empty" hidden>No matches</div></div>
2689
2740
  </div>
2690
2741
  </div>`, this._rendered = !0, c(this, this._value), this._wire(), this._syncReset();
2691
2742
  }
@@ -2728,11 +2779,11 @@ var V = class extends HTMLElement {
2728
2779
  let t = e.control.getBoundingClientRect();
2729
2780
  e.menu.style.width = "max-content", e.menu.style.minWidth = `${t.width}px`, e.menu.style.maxWidth = "280px", i(e.control, e.menu);
2730
2781
  } else i(e.control, e.menu, { matchWidth: !0 });
2731
- }, n = (e) => {
2732
- let t = this._visible();
2733
- this._active = e;
2782
+ }, n = (t) => {
2783
+ let n = this._visible();
2784
+ this._active = t;
2734
2785
  for (let e of this._optionEls()) e.classList.remove("is-active");
2735
- e >= 0 && t[e] && (t[e].classList.add("is-active"), t[e].scrollIntoView({ block: "nearest" }));
2786
+ t >= 0 && n[t] ? (n[t].classList.add("is-active"), n[t].scrollIntoView({ block: "nearest" }), e.control.setAttribute("aria-activedescendant", n[t].id)) : e.control.removeAttribute("aria-activedescendant");
2736
2787
  }, r = (t) => {
2737
2788
  let n = t.trim().toLowerCase(), r = 0;
2738
2789
  for (let e of this._optionEls()) {
@@ -2768,14 +2819,16 @@ var V = class extends HTMLElement {
2768
2819
  r(e.search.value), n(-1);
2769
2820
  }), e.clear?.addEventListener("click", () => {
2770
2821
  e.search.value = "", r(""), e.search.focus();
2771
- }), e.menu.addEventListener("keydown", u), this._onDocClick = (e) => {
2772
- o() && !this.contains(e.target) && c();
2773
- }, document.addEventListener("click", this._onDocClick), a(this, () => {
2774
- o() && t();
2775
- });
2822
+ }), e.menu.addEventListener("keydown", u), this._bindGlobal = () => {
2823
+ this._teardown(), this._onDocClick = (e) => {
2824
+ o() && !this.contains(e.target) && c();
2825
+ }, document.addEventListener("click", this._onDocClick), a(this, () => {
2826
+ o() && t();
2827
+ });
2828
+ }, this._bindGlobal();
2776
2829
  }
2777
2830
  _teardown() {
2778
- this._onDocClick && document.removeEventListener("click", this._onDocClick), o(this);
2831
+ this._onDocClick &&= (document.removeEventListener("click", this._onDocClick), null), o(this);
2779
2832
  }
2780
2833
  disconnectedCallback() {
2781
2834
  this._teardown();
@@ -2807,10 +2860,32 @@ var V = class extends HTMLElement {
2807
2860
  } catch {
2808
2861
  this._internals = null;
2809
2862
  }
2810
- this._value = 50, this._start = 25, this._end = 75, this._isDragging = !1, this._dragThumb = null, this._pointerDownListener = null, this._pointerMoveListener = null, this._pointerUpListener = null;
2863
+ this._value = 50, this._start = 25, this._end = 75, this._isDragging = !1, this._dragThumb = null, this._pointerDownListener = null, this._pointerMoveListener = null, this._pointerUpListener = null, this._thumbKeyListener = null, this._trackClickListener = null;
2811
2864
  }
2812
2865
  connectedCallback() {
2813
- this._rendered || this.render();
2866
+ if (!this._rendered) {
2867
+ this.render();
2868
+ return;
2869
+ }
2870
+ this._wire();
2871
+ }
2872
+ get value() {
2873
+ return this._value;
2874
+ }
2875
+ set value(e) {
2876
+ this._value = this._snapToStep(this._clamp(K(e, this._value))), this._syncValue(), this._syncMirrors();
2877
+ }
2878
+ get start() {
2879
+ return this._start;
2880
+ }
2881
+ set start(e) {
2882
+ this._start = Math.min(this._snapToStep(this._clamp(K(e, this._start))), this._end), this._syncValue(), this._syncMirrors();
2883
+ }
2884
+ get end() {
2885
+ return this._end;
2886
+ }
2887
+ set end(e) {
2888
+ this._end = Math.max(this._snapToStep(this._clamp(K(e, this._end))), this._start), this._syncValue(), this._syncMirrors();
2814
2889
  }
2815
2890
  attributeChangedCallback(e, t, n) {
2816
2891
  if (e === "value" || e === "start" || e === "end" || e === "min" || e === "max" || e === "step") {
@@ -2823,27 +2898,28 @@ var V = class extends HTMLElement {
2823
2898
  this._isRange() ? this._resetRange() : this._resetSingle();
2824
2899
  }
2825
2900
  _updateFromAttribute(e) {
2826
- let t = (e) => Number.parseFloat(e) || 0;
2827
- e === "value" ? this._value = this._snapToStep(this._clamp(t(this.getAttribute("value")))) : e === "start" ? this._start = this._snapToStep(this._clamp(t(this.getAttribute("start")))) : e === "end" && (this._end = this._snapToStep(this._clamp(t(this.getAttribute("end")))));
2901
+ e === "value" ? this._value = this._snapToStep(this._clamp(K(this.getAttribute("value"), this._value))) : e === "start" ? this._start = this._snapToStep(this._clamp(K(this.getAttribute("start"), this._start))) : e === "end" && (this._end = this._snapToStep(this._clamp(K(this.getAttribute("end"), this._end))));
2828
2902
  }
2829
2903
  _isRange() {
2830
2904
  return this.hasAttribute("range");
2831
2905
  }
2832
2906
  _min() {
2833
- return Number.parseFloat(this.getAttribute("min")) || 0;
2907
+ return K(this.getAttribute("min"), 0);
2834
2908
  }
2835
2909
  _max() {
2836
- return Number.parseFloat(this.getAttribute("max")) || 100;
2910
+ return K(this.getAttribute("max"), 100);
2837
2911
  }
2838
2912
  _step() {
2839
- return Number.parseFloat(this.getAttribute("step")) || 1;
2913
+ return K(this.getAttribute("step"), 1);
2840
2914
  }
2841
2915
  _clamp(e) {
2842
2916
  return Math.max(this._min(), Math.min(e, this._max()));
2843
2917
  }
2844
2918
  _snapToStep(e) {
2845
2919
  let t = this._step();
2846
- return t <= 0 ? e : Math.round(e / t) * t;
2920
+ if (t <= 0) return e;
2921
+ let n = this._min();
2922
+ return this._clamp(n + Math.round((e - n) / t) * t);
2847
2923
  }
2848
2924
  _captureDefaults() {
2849
2925
  this._defaultsCaptured ||= (this._isRange() ? (this._defaultStart = this._start, this._defaultEnd = this._end) : this._defaultValue = this._value, !0);
@@ -2858,7 +2934,7 @@ var V = class extends HTMLElement {
2858
2934
  this._captureDefaults();
2859
2935
  let e = this._min(), t = this._max(), n = this._isRange(), r = this.getAttribute("size"), i = r === "sm" ? " slider-sm" : r === "lg" ? " slider-lg" : "", a = this.hasAttribute("disabled");
2860
2936
  n ? (this._start = this._clamp(this._start), this._end = this._clamp(this._end), this._start > this._end && ([this._start, this._end] = [this._end, this._start])) : this._value = this._clamp(this._value);
2861
- let o = (n) => (n - e) / (t - e) * 100, s = n ? o(this._start) : 0, c = o(n ? this._end : this._value);
2937
+ let o = (n) => t === e ? 0 : (n - e) / (t - e) * 100, s = n ? o(this._start) : 0, c = o(n ? this._end : this._value);
2862
2938
  this.innerHTML = `
2863
2939
  <div class="slider${i}">
2864
2940
  <div class="slider-track" role="presentation"></div>
@@ -2911,7 +2987,7 @@ var V = class extends HTMLElement {
2911
2987
  }
2912
2988
  _syncValue() {
2913
2989
  if (!this._rendered) return;
2914
- let e = this._min(), t = this._max(), n = (n) => (n - e) / (t - e) * 100, r = this.querySelector(".slider-fill");
2990
+ let e = this._min(), t = this._max(), n = (n) => t === e ? 0 : (n - e) / (t - e) * 100, r = this.querySelector(".slider-fill");
2915
2991
  if (this._isRange()) {
2916
2992
  let e = n(this._start), t = n(this._end);
2917
2993
  r && (r.style.left = `${e}%`, r.style.right = `${100 - t}%`);
@@ -2946,8 +3022,8 @@ var V = class extends HTMLElement {
2946
3022
  _valueAtPosition(e) {
2947
3023
  let t = this.querySelector(".slider-track");
2948
3024
  if (!t) return this._min();
2949
- let n = t.getBoundingClientRect(), r = Math.max(0, Math.min(1, (e - n.left) / n.width)), i = this._min() + r * (this._max() - this._min()), a = this._step();
2950
- return Math.round(i / a) * a;
3025
+ let n = t.getBoundingClientRect(), r = Math.max(0, Math.min(1, (e - n.left) / n.width)), i = this._min() + r * (this._max() - this._min());
3026
+ return this._snapToStep(i);
2951
3027
  }
2952
3028
  _nearestThumb(e) {
2953
3029
  return Math.abs(e - this._start) <= Math.abs(e - this._end) ? "start" : "end";
@@ -2979,29 +3055,30 @@ var V = class extends HTMLElement {
2979
3055
  }
2980
3056
  }, this._pointerUpListener = () => {
2981
3057
  this._isDragging && (this._isDragging = !1, this._dragThumb = null, document.removeEventListener("pointermove", this._pointerMoveListener), document.removeEventListener("pointerup", this._pointerUpListener), this._syncMirrors(), this.dispatchEvent(new Event("change", { bubbles: !0 })));
2982
- }, e.forEach((e) => {
2983
- e.addEventListener("pointerdown", this._pointerDownListener), e.addEventListener("keydown", (t) => {
2984
- if (this.hasAttribute("disabled")) return;
2985
- let n = this._step(), r = n * 10, i = null, a = e.getAttribute("data-thumb");
2986
- t.key === "ArrowLeft" || t.key === "ArrowDown" ? (t.preventDefault(), i = (a === "end" ? this._end : a === "start" ? this._start : this._value) - n) : t.key === "ArrowRight" || t.key === "ArrowUp" ? (t.preventDefault(), i = (a === "end" ? this._end : a === "start" ? this._start : this._value) + n) : t.key === "PageDown" ? (t.preventDefault(), i = (a === "end" ? this._end : a === "start" ? this._start : this._value) - r) : t.key === "PageUp" ? (t.preventDefault(), i = (a === "end" ? this._end : a === "start" ? this._start : this._value) + r) : t.key === "Home" ? (t.preventDefault(), i = this._min()) : t.key === "End" && (t.preventDefault(), i = this._max()), i != null && (i = this._clamp(i), a === "single" ? this._value = i : a === "start" ? this._start = Math.min(i, this._end) : a === "end" && (this._end = Math.max(i, this._start)), this._syncValue(), this._syncMirrors(), this.dispatchEvent(new Event("change", { bubbles: !0 })));
2987
- });
2988
- }), t && t.addEventListener("click", (e) => {
3058
+ }, this._thumbKeyListener = (e) => {
3059
+ let t = e.currentTarget;
3060
+ if (this.hasAttribute("disabled")) return;
3061
+ let n = this._step(), r = n * 10, i = null, a = t.getAttribute("data-thumb"), o = a === "end" ? this._end : a === "start" ? this._start : this._value;
3062
+ e.key === "ArrowLeft" || e.key === "ArrowDown" ? (e.preventDefault(), i = o - n) : e.key === "ArrowRight" || e.key === "ArrowUp" ? (e.preventDefault(), i = o + n) : e.key === "PageDown" ? (e.preventDefault(), i = o - r) : e.key === "PageUp" ? (e.preventDefault(), i = o + r) : e.key === "Home" ? (e.preventDefault(), i = this._min()) : e.key === "End" && (e.preventDefault(), i = this._max()), i != null && (i = this._clamp(i), a === "single" ? this._value = i : a === "start" ? this._start = Math.min(i, this._end) : a === "end" && (this._end = Math.max(i, this._start)), this._syncValue(), this._syncMirrors(), this.dispatchEvent(new Event("change", { bubbles: !0 })));
3063
+ }, this._trackClickListener = (e) => {
2989
3064
  if (this.hasAttribute("disabled")) return;
2990
3065
  let t = this._valueAtPosition(e.clientX);
2991
- n ? this._nearestThumb(t) === "start" ? this._start = Math.min(t, this._end) : this._end = Math.max(t, this._start) : this._value = this._clamp(t), this._syncValue(), this._syncMirrors(), this.dispatchEvent(new Event("change", { bubbles: !0 }));
2992
- });
3066
+ n ? this._nearestThumb(t) === "start" ? this._start = Math.min(this._clamp(t), this._end) : this._end = Math.max(this._clamp(t), this._start) : this._value = this._clamp(t), this._syncValue(), this._syncMirrors(), this.dispatchEvent(new Event("change", { bubbles: !0 }));
3067
+ }, e.forEach((e) => {
3068
+ e.addEventListener("pointerdown", this._pointerDownListener), e.addEventListener("keydown", this._thumbKeyListener);
3069
+ }), t?.addEventListener("click", this._trackClickListener);
2993
3070
  }
2994
3071
  _teardown() {
2995
- this.querySelectorAll(".slider-thumb").forEach((e) => {
2996
- e.removeEventListener("pointerdown", this._pointerDownListener), e.removeEventListener("keydown", this._pointerMoveListener);
2997
- }), document.removeEventListener("pointermove", this._pointerMoveListener), document.removeEventListener("pointerup", this._pointerUpListener);
2998
- let e = this.querySelector(".slider-track");
2999
- e && e.removeEventListener("click", this._pointerUpListener);
3072
+ for (let e of this.querySelectorAll(".slider-thumb")) e.removeEventListener("pointerdown", this._pointerDownListener), e.removeEventListener("keydown", this._thumbKeyListener);
3073
+ document.removeEventListener("pointermove", this._pointerMoveListener), document.removeEventListener("pointerup", this._pointerUpListener), this._isDragging = !1, this._dragThumb = null, this.querySelector(".slider-track")?.removeEventListener("click", this._trackClickListener);
3000
3074
  }
3001
3075
  disconnectedCallback() {
3002
3076
  this._teardown();
3003
3077
  }
3004
- }, ue = (e) => String(e ?? "").replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;"), K = class extends HTMLElement {
3078
+ }, K = (e, t) => {
3079
+ let n = Number.parseFloat(e);
3080
+ return Number.isFinite(n) ? n : t;
3081
+ }, ue = (e) => String(e ?? "").replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;"), de = class extends HTMLElement {
3005
3082
  static formAssociated = !0;
3006
3083
  _accessibleName() {
3007
3084
  return this.getAttribute("aria-label") || this.getAttribute("placeholder") || "Add tags";
@@ -3012,7 +3089,9 @@ var V = class extends HTMLElement {
3012
3089
  "disabled",
3013
3090
  "size",
3014
3091
  "max-tags",
3015
- "aria-label"
3092
+ "aria-label",
3093
+ "separators",
3094
+ "allow-duplicates"
3016
3095
  ];
3017
3096
  }
3018
3097
  constructor() {
@@ -3026,19 +3105,31 @@ var V = class extends HTMLElement {
3026
3105
  connectedCallback() {
3027
3106
  if (!this._rendered) {
3028
3107
  if (!this._valuesInit && !this._values.length) {
3029
- let e = [...this.querySelectorAll(":scope > wui-tag")].map((e) => e.textContent.trim());
3030
- e.length && (this._values = e.map(String));
3108
+ let e = this.getAttribute("value");
3109
+ if (e != null && e !== "") this._values = e.split(",").map((e) => e.trim()).filter(Boolean);
3110
+ else {
3111
+ let e = [...this.querySelectorAll(":scope > wui-tag")].map((e) => e.textContent.trim());
3112
+ e.length && (this._values = e.map(String));
3113
+ }
3031
3114
  }
3032
3115
  this._valuesInit = !0, this._defaultCaptured ||= (this._defaultValues = this._values.slice(), !0), this.render();
3116
+ return;
3033
3117
  }
3118
+ this._wire();
3034
3119
  }
3035
3120
  formResetCallback() {
3036
3121
  this.values = (this._defaultValues || []).slice(), this._draftText = "";
3037
3122
  let e = this.querySelector("[data-input]");
3038
3123
  e && (e.value = "");
3039
3124
  }
3040
- attributeChangedCallback() {
3041
- this._rendered && this.render();
3125
+ attributeChangedCallback(e) {
3126
+ if (this._rendered) {
3127
+ if (e === "separators" || e === "allow-duplicates") {
3128
+ this._wire();
3129
+ return;
3130
+ }
3131
+ this.render();
3132
+ }
3042
3133
  }
3043
3134
  get values() {
3044
3135
  return this._values.slice();
@@ -3063,7 +3154,7 @@ var V = class extends HTMLElement {
3063
3154
  e.innerHTML = "";
3064
3155
  return;
3065
3156
  }
3066
- e.innerHTML = this._values.map((e) => `<span class="chip chip-sm"><span class="chip-label">${de(e)}</span><button type="button" class="chip-remove" data-remove="${q(e)}" aria-label="Remove ${q(e)}"><i class="bi bi-x" aria-hidden="true"></i></button></span>`).join("");
3157
+ e.innerHTML = this._values.map((e) => `<span class="chip chip-sm"><span class="chip-label">${fe(e)}</span><button type="button" class="chip-remove" data-remove="${q(e)}" aria-label="Remove ${q(e)}"><i class="bi bi-x" aria-hidden="true"></i></button></span>`).join("");
3067
3158
  }
3068
3159
  }
3069
3160
  _wire() {
@@ -3081,16 +3172,7 @@ var V = class extends HTMLElement {
3081
3172
  (!this._values.some((e) => a ? e === t : e.toLowerCase() === n) || a) && (this._values.push(t), this._renderControl(), s());
3082
3173
  }, u = (e) => {
3083
3174
  this._values = this._values.filter((t) => t !== e), this._renderControl(), s();
3084
- };
3085
- e.addEventListener("click", (e) => {
3086
- if (n()) return;
3087
- let r = e.target.closest("[data-remove]");
3088
- if (r) {
3089
- e.stopPropagation(), u(r.dataset.remove), t.focus();
3090
- return;
3091
- }
3092
- t.focus();
3093
- }), t.addEventListener("keydown", (e) => {
3175
+ }, d = (e) => {
3094
3176
  if (e.key === "Enter" && o.has("Enter")) {
3095
3177
  e.preventDefault(), l(t.value), t.value = "";
3096
3178
  return;
@@ -3109,7 +3191,7 @@ var V = class extends HTMLElement {
3109
3191
  return;
3110
3192
  }
3111
3193
  e.key === "Backspace" && !t.value && this._values.length && (e.preventDefault(), u(this._values[this._values.length - 1])), e.key === "Escape" && (t.value = "");
3112
- }), t.addEventListener("paste", (e) => {
3194
+ }, f = (e) => {
3113
3195
  e.preventDefault();
3114
3196
  let n = e.clipboardData.getData("text/plain"), a = [];
3115
3197
  for (let e of r) {
@@ -3122,22 +3204,28 @@ var V = class extends HTMLElement {
3122
3204
  a.length || a.push(n.trim());
3123
3205
  for (let e of a) if (l(e), i && this._values.length >= parseInt(i, 10)) break;
3124
3206
  t.value = "";
3125
- }), this._onDocClick = (e) => {
3207
+ };
3208
+ this._onControlClick = (e) => {
3209
+ if (n()) return;
3210
+ let r = e.target.closest("[data-remove]");
3211
+ if (r) {
3212
+ e.stopPropagation(), u(r.dataset.remove), t.focus();
3213
+ return;
3214
+ }
3215
+ t.focus();
3216
+ }, this._onInputKey = d, this._onInputPaste = f, e.addEventListener("click", this._onControlClick), t.addEventListener("keydown", this._onInputKey), t.addEventListener("paste", this._onInputPaste), this._onDocClick = (e) => {
3126
3217
  this.contains(e.target) || t.blur();
3127
3218
  }, document.addEventListener("click", this._onDocClick);
3128
3219
  }
3129
3220
  _teardown() {
3130
- this._onDocClick && document.removeEventListener("click", this._onDocClick);
3131
- let e = this.querySelector("[data-input]");
3132
- if (e) {
3133
- let t = e, n = t.cloneNode(!1);
3134
- t.replaceWith(n);
3135
- }
3221
+ this._onDocClick &&= (document.removeEventListener("click", this._onDocClick), null);
3222
+ let e = this.querySelector(".search-select-control"), t = this.querySelector("[data-input]");
3223
+ e && this._onControlClick && e.removeEventListener("click", this._onControlClick), t && this._onInputKey && (t.removeEventListener("keydown", this._onInputKey), t.removeEventListener("paste", this._onInputPaste));
3136
3224
  }
3137
3225
  disconnectedCallback() {
3138
3226
  this._teardown();
3139
3227
  }
3140
- }, de = (e) => String(e ?? "").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"), q = (e) => String(e ?? "").replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;"), J = (e) => String(e).padStart(2, "0"), fe = (e, t) => `${J(e)}:${J(t)}`, Y = (e) => {
3228
+ }, fe = (e) => String(e ?? "").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"), q = (e) => String(e ?? "").replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;"), J = (e) => String(e).padStart(2, "0"), pe = (e, t) => `${J(e)}:${J(t)}`, Y = (e) => {
3141
3229
  let t = /^(\d{2}):(\d{2})$/.exec(e || "");
3142
3230
  return t ? {
3143
3231
  h: +t[1],
@@ -3145,10 +3233,10 @@ var V = class extends HTMLElement {
3145
3233
  } : null;
3146
3234
  }, X = (e, t = "24") => {
3147
3235
  if (!e) return "";
3148
- if (t === "24") return fe(e.h, e.m);
3236
+ if (t === "24") return pe(e.h, e.m);
3149
3237
  let n = e.h % 12 || 12, r = e.h >= 12 ? "PM" : "AM";
3150
3238
  return `${n}:${J(e.m)} ${r}`;
3151
- }, pe = class extends HTMLElement {
3239
+ }, me = class extends HTMLElement {
3152
3240
  static formAssociated = !0;
3153
3241
  static get observedAttributes() {
3154
3242
  return [
@@ -3175,7 +3263,11 @@ var V = class extends HTMLElement {
3175
3263
  this._value = "", this._focus = null;
3176
3264
  }
3177
3265
  connectedCallback() {
3178
- this._rendered || this.render();
3266
+ if (!this._rendered) {
3267
+ this.render();
3268
+ return;
3269
+ }
3270
+ this._bindGlobal?.();
3179
3271
  }
3180
3272
  attributeChangedCallback(e, t, n) {
3181
3273
  this._rendered && (e === "value" ? (this._value = n || "", this._syncFormValue(), this._syncTrigger()) : this.render());
@@ -3190,7 +3282,7 @@ var V = class extends HTMLElement {
3190
3282
  this._value = e || "", c(this, this._value), this._syncTrigger();
3191
3283
  }
3192
3284
  render() {
3193
- this._defaultValue === void 0 && (this._defaultValue = this.getAttribute("value") || ""), this._value = this.getAttribute("value") || this._value;
3285
+ this._defaultValue === void 0 && (this._defaultValue = this.getAttribute("value") || "", this._value = this._defaultValue || this._value);
3194
3286
  let e = this.getAttribute("placeholder") || "Select time", t = Y(this._value), n = this.getAttribute("format") || "24", r = this.getAttribute("size"), i = r === "sm" ? " input-sm" : r === "lg" ? " input-lg" : "", a = this.getAttribute("aria-label"), o = this.getAttribute("aria-describedby");
3195
3287
  this.innerHTML = `
3196
3288
  <div class="timepicker">
@@ -3229,7 +3321,7 @@ var V = class extends HTMLElement {
3229
3321
  if (!e) return;
3230
3322
  let t = this.getAttribute("format") || "24", n = this._buildTimes(), r = Y(this._value), i = this._focus, a = "";
3231
3323
  for (let e = 0; e < n.length; e++) {
3232
- let o = n[e], s = fe(o.h, o.m), c = r && r.h === o.h && r.m === o.m;
3324
+ let o = n[e], s = pe(o.h, o.m), c = r && r.h === o.h && r.m === o.m;
3233
3325
  a += `<button type="button" class="timepicker-option${c ? " is-selected" : ""}" data-hm="${s}" role="option" tabindex="${i === e ? "0" : "-1"}"${c ? " aria-selected=\"true\"" : ""}>${X(o, t)}</button>`;
3234
3326
  }
3235
3327
  e.innerHTML = a, this._focusActive();
@@ -3285,29 +3377,31 @@ var V = class extends HTMLElement {
3285
3377
  t && !t.disabled && (this.value = t.dataset.hm, this.dispatchEvent(new Event("change", { bubbles: !0 })), this._close());
3286
3378
  }), this._onKeyBound = (e) => {
3287
3379
  n() && this._onKey(e);
3288
- }, t.addEventListener("keydown", this._onKeyBound), this._onDocClick = (e) => {
3289
- let t = this._popClick;
3290
- this._popClick = !1, n() && !t && !this.contains(e.target) && this._close();
3291
- }, document.addEventListener("click", this._onDocClick), this._onDocKey = (e) => {
3292
- n() && e.key === "Escape" && this._close();
3293
- }, document.addEventListener("keydown", this._onDocKey), a(this, () => {
3294
- n() && this._position(e, t);
3295
- }), this._syncFormValue();
3380
+ }, t.addEventListener("keydown", this._onKeyBound), this._bindGlobal = () => {
3381
+ this._teardown(), this._onDocClick = (e) => {
3382
+ let t = this._popClick;
3383
+ this._popClick = !1, n() && !t && !this.contains(e.target) && this._close();
3384
+ }, document.addEventListener("click", this._onDocClick), this._onDocKey = (e) => {
3385
+ n() && e.key === "Escape" && this._close();
3386
+ }, document.addEventListener("keydown", this._onDocKey), a(this, () => {
3387
+ n() && this._position(e, t);
3388
+ });
3389
+ }, this._bindGlobal(), this._syncFormValue();
3296
3390
  }
3297
3391
  _teardown() {
3298
- this._onDocClick && document.removeEventListener("click", this._onDocClick), this._onDocKey && document.removeEventListener("keydown", this._onDocKey), o(this);
3392
+ this._onDocClick &&= (document.removeEventListener("click", this._onDocClick), null), this._onDocKey &&= (document.removeEventListener("keydown", this._onDocKey), null), o(this);
3299
3393
  }
3300
3394
  disconnectedCallback() {
3301
3395
  this._teardown();
3302
3396
  }
3303
- }, me = "image/png,image/jpeg,image/webp", he = 5, ge = {
3397
+ }, he = "image/png,image/jpeg,image/webp", ge = 5, _e = {
3304
3398
  "image/png": [".png"],
3305
3399
  "image/jpeg": [".jpg", ".jpeg"],
3306
3400
  "image/webp": [".webp"],
3307
3401
  "image/gif": [".gif"],
3308
3402
  "image/svg+xml": [".svg"],
3309
3403
  "application/pdf": [".pdf"]
3310
- }, _e = {
3404
+ }, ve = {
3311
3405
  "image/png": "PNG",
3312
3406
  "image/jpeg": "JPG",
3313
3407
  "image/webp": "WEBP",
@@ -3321,7 +3415,7 @@ var V = class extends HTMLElement {
3321
3415
  ".gif": "GIF",
3322
3416
  ".svg": "SVG",
3323
3417
  ".pdf": "PDF"
3324
- }, Z = (e) => String(e || "").split(",").map((e) => e.trim().toLowerCase()).filter(Boolean), Q = [
3418
+ }, Z = (e) => String(e || "").split(",").map((e) => e.trim().toLowerCase()).filter(Boolean), ye = [
3325
3419
  ".png",
3326
3420
  ".jpg",
3327
3421
  ".jpeg",
@@ -3332,44 +3426,44 @@ var V = class extends HTMLElement {
3332
3426
  ".avif",
3333
3427
  ".heic"
3334
3428
  ];
3335
- function ve(e) {
3429
+ function be(e) {
3336
3430
  if (!e) return !1;
3337
3431
  let t = typeof e == "object" && e.type ? String(e.type).toLowerCase() : "";
3338
3432
  if (t) return t.startsWith("image/");
3339
3433
  let n = typeof e == "string" ? e : e.name || e.url || "", r = String(n).toLowerCase();
3340
- return Q.some((e) => r.endsWith(e));
3434
+ return ye.some((e) => r.endsWith(e));
3341
3435
  }
3342
- function ye(e) {
3436
+ function xe(e) {
3343
3437
  let t = Z(e);
3344
- return t.length ? t.every((e) => e.startsWith(".") ? Q.includes(e) : e === "image/*" || e.startsWith("image/")) : !1;
3438
+ return t.length ? t.every((e) => e.startsWith(".") ? ye.includes(e) : e === "image/*" || e.startsWith("image/")) : !1;
3345
3439
  }
3346
- function be(e) {
3440
+ function Se(e) {
3347
3441
  let t = [];
3348
3442
  for (let n of Z(e)) {
3349
- let e = _e[n] || (n.startsWith(".") ? n.slice(1).toUpperCase() : n.toUpperCase());
3443
+ let e = ve[n] || (n.startsWith(".") ? n.slice(1).toUpperCase() : n.toUpperCase());
3350
3444
  t.includes(e) || t.push(e);
3351
3445
  }
3352
3446
  return t.length <= 1 ? t[0] || "supported" : `${t.slice(0, -1).join(", ")} or ${t[t.length - 1]}`;
3353
3447
  }
3354
- function xe(e, t) {
3448
+ function Ce(e, t) {
3355
3449
  let n = Z(t);
3356
3450
  if (!n.length) return !0;
3357
3451
  let r = (e.type || "").toLowerCase(), i = (e.name || "").toLowerCase();
3358
- 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)));
3452
+ return n.some((e) => e.startsWith(".") ? i.endsWith(e) : e.endsWith("/*") ? r.startsWith(e.slice(0, -1)) : r && r === e ? !0 : !r && (_e[e] || []).some((e) => i.endsWith(e)));
3359
3453
  }
3360
- function Se(e, t = {}) {
3454
+ function we(e, t = {}) {
3361
3455
  if (!e) return null;
3362
- let n = t.accept === void 0 ? me : t.accept, r = t.maxSizeMb || 5;
3363
- return xe(e, n) ? e.size > r * 1024 * 1024 ? `Keep the file under ${r} MB.` : null : `Choose a ${be(n)} file.`;
3456
+ let n = t.accept === void 0 ? he : t.accept, r = t.maxSizeMb || 5;
3457
+ return Ce(e, n) ? e.size > r * 1024 * 1024 ? `Keep the file under ${r} MB.` : null : `Choose a ${Se(n)} file.`;
3364
3458
  }
3365
3459
  //#endregion
3366
3460
  //#region src/index.js
3367
- var $ = (e, t) => {
3461
+ var Q = (e, t) => {
3368
3462
  typeof customElements < "u" && !customElements.get(e) && customElements.define(e, t);
3369
3463
  };
3370
- function Ce() {
3371
- $("wui-select", U), $("wui-phone", V), $("wui-datepicker", te), $("wui-date-range", A), $("wui-slider", G), $("wui-timepicker", pe), $("wui-autocomplete", p), $("wui-multiselect", j), $("wui-taginput", K), $("wui-otp", oe), $("wui-status-icon", n);
3464
+ function $() {
3465
+ Q("wui-select", U), Q("wui-phone", V), Q("wui-datepicker", w), Q("wui-date-range", re), Q("wui-slider", G), Q("wui-timepicker", me), Q("wui-autocomplete", p), Q("wui-multiselect", ie), Q("wui-taginput", de), Q("wui-otp", j), Q("wui-status-icon", n);
3372
3466
  }
3373
- Ce();
3467
+ $();
3374
3468
  //#endregion
3375
- export { me as DEFAULT_IMAGE_ACCEPT, he as DEFAULT_MAX_SIZE_MB, t as STATUS_TONES, p as WuiAutocomplete, te as WuiDatePicker, A as WuiDateRange, j as WuiMultiSelect, oe as WuiOtp, V as WuiPhone, U as WuiSelect, G as WuiSlider, n as WuiStatusIcon, K as WuiTagInput, pe as WuiTimePicker, be as acceptLabel, Ce as defineWeborityElements, ve as isImageFile, ye as isImageOnlyAccept, xe as matchesAccept, Se as validateFile };
3469
+ export { he as DEFAULT_IMAGE_ACCEPT, ge as DEFAULT_MAX_SIZE_MB, t as STATUS_TONES, p as WuiAutocomplete, w as WuiDatePicker, re as WuiDateRange, ie as WuiMultiSelect, j as WuiOtp, V as WuiPhone, U as WuiSelect, G as WuiSlider, n as WuiStatusIcon, de as WuiTagInput, me as WuiTimePicker, Se as acceptLabel, $ as defineWeborityElements, be as isImageFile, xe as isImageOnlyAccept, Ce as matchesAccept, we as validateFile };