@webority/ui-elements 0.6.10 → 0.6.12

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.
@@ -27,22 +27,36 @@ function i(e, t, n = {}) {
27
27
  let c = t.offsetWidth, l = Math.min(i.left, window.innerWidth - c - r);
28
28
  t.style.left = `${Math.max(r, l)}px`;
29
29
  }
30
+ function a(e, t) {
31
+ o(e), e._reanchor = t, window.addEventListener("resize", e._reanchor), window.addEventListener("scroll", e._reanchor, !0);
32
+ }
33
+ function o(e) {
34
+ e?._reanchor && (window.removeEventListener("resize", e._reanchor), window.removeEventListener("scroll", e._reanchor, !0), e._reanchor = null);
35
+ }
30
36
  //#endregion
31
37
  //#region src/formMirror.js
32
- var a = "data-wui-mirror";
33
- function o(e, t) {
34
- let n = e.getAttribute("name"), r = e.querySelector(`:scope > input[${a}]`);
38
+ var s = "data-wui-mirror";
39
+ function c(e, t) {
40
+ let n = e.getAttribute("name"), r = e.querySelector(`:scope > input[${s}]`);
35
41
  if (!n) {
36
42
  r?.remove();
37
43
  return;
38
44
  }
39
- r || (r = document.createElement("input"), r.type = "hidden", r.setAttribute(a, ""), e.appendChild(r)), r.name = n, r.value = t == null ? "" : String(t);
45
+ r || (r = document.createElement("input"), r.type = "hidden", r.setAttribute(s, ""), e.appendChild(r)), r.name = n, r.value = t == null ? "" : String(t);
40
46
  for (let t of e.attributes) t.name.startsWith("data-val") && r.setAttribute(t.name, t.value);
41
47
  r.disabled = e.hasAttribute("disabled");
42
48
  }
43
49
  //#endregion
44
50
  //#region src/optionLabel.js
45
- var s = Symbol("wui.trustedHtml"), c = (e) => String(e ?? "").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;"), l = (e) => e?.[s] ? String(e.label ?? "") : c(e == null ? "" : e.label), u = class extends HTMLElement {
51
+ var l = Symbol("wui.trustedHtml"), u = (e) => String(e ?? "").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#39;"), d = (e) => {
52
+ if (!e) return "";
53
+ let t = String(e).toLowerCase().replace(/[^a-z0-9-]/g, "");
54
+ return t ? `<i class="bi bi-${t}" aria-hidden="true"></i>` : "";
55
+ }, f = (e) => {
56
+ if (e == null) return "";
57
+ let t = e[l] ? String(e.label ?? "") : u(e.label), n = d(e.icon);
58
+ return n ? `<span class="wui-opt-label">${n}${t}</span>` : t;
59
+ }, p = class extends HTMLElement {
46
60
  _accessibleName() {
47
61
  return this.getAttribute("aria-label") || this.getAttribute("placeholder") || "Select";
48
62
  }
@@ -54,6 +68,7 @@ var s = Symbol("wui.trustedHtml"), c = (e) => String(e ?? "").replace(/&/g, "&am
54
68
  "min-chars",
55
69
  "debounce",
56
70
  "remote",
71
+ "size",
57
72
  "aria-label"
58
73
  ];
59
74
  }
@@ -70,9 +85,9 @@ var s = Symbol("wui.trustedHtml"), c = (e) => String(e ?? "").replace(/&/g, "&am
70
85
  return this._value;
71
86
  }
72
87
  set value(e) {
73
- this._value = e == null ? "" : String(e), o(this, this._value);
88
+ this._value = e == null ? "" : String(e), c(this, this._value);
74
89
  let t = this._readOptions().find((e) => String(e.value) === this._value);
75
- t && (this._label = f(t.label)), this._syncInput();
90
+ t && (this._label = h(t.label)), this._syncInput();
76
91
  }
77
92
  set options(e) {
78
93
  this._optionsProp = Array.isArray(e) ? e : [], this._renderOptions();
@@ -102,7 +117,8 @@ var s = Symbol("wui.trustedHtml"), c = (e) => String(e ?? "").replace(/&/g, "&am
102
117
  e.length && (this._declared = e.map((e) => ({
103
118
  value: e.getAttribute("value") ?? e.textContent.trim(),
104
119
  label: e.innerHTML,
105
- [s]: !0,
120
+ icon: e.getAttribute("icon") || void 0,
121
+ [l]: !0,
106
122
  selected: e.hasAttribute("selected")
107
123
  })));
108
124
  }
@@ -111,11 +127,11 @@ var s = Symbol("wui.trustedHtml"), c = (e) => String(e ?? "").replace(/&/g, "&am
111
127
  }
112
128
  render() {
113
129
  this._snapshotDeclared();
114
- let e = this.getAttribute("placeholder") || "Search…";
130
+ let e = this.getAttribute("placeholder") || "Search…", t = this.getAttribute("size"), n = t === "sm" ? " search-select-sm" : t === "lg" ? " search-select-lg" : "";
115
131
  this.innerHTML = `
116
- <div class="search-select">
117
- <div class="input search-select-control search-select-ac" role="combobox" aria-haspopup="listbox" aria-expanded="false" aria-label="${d(this._accessibleName())}">
118
- <input class="search-select-input search-select-ac-input" placeholder="${d(e)}" aria-autocomplete="list" autocomplete="off"${this.hasAttribute("disabled") ? " disabled" : ""} />
132
+ <div class="search-select${n}">
133
+ <div class="input search-select-control search-select-ac" role="combobox" aria-haspopup="listbox" aria-expanded="false" aria-label="${m(this._accessibleName())}">
134
+ <input class="search-select-input search-select-ac-input" placeholder="${m(e)}" aria-autocomplete="list" autocomplete="off"${this.hasAttribute("disabled") ? " disabled" : ""} />
119
135
  <span class="search-select-spinner spinner-border spinner-border-sm" role="status" aria-hidden="true" hidden></span>
120
136
  <button type="button" class="search-select-clear" aria-label="Clear" hidden><i class="bi bi-x" aria-hidden="true"></i></button>
121
137
  </div>
@@ -124,7 +140,7 @@ var s = Symbol("wui.trustedHtml"), c = (e) => String(e ?? "").replace(/&/g, "&am
124
140
  <div class="search-select-empty" hidden>No matches</div>
125
141
  <div class="search-select-hint" hidden>Type to search…</div>
126
142
  </div>
127
- </div>`, this._rendered = !0, o(this, this._value), this._wire(), this._syncInput(), this._renderOptions();
143
+ </div>`, this._rendered = !0, c(this, this._value), this._wire(), this._syncInput(), this._renderOptions();
128
144
  }
129
145
  _refs() {
130
146
  return {
@@ -153,9 +169,9 @@ var s = Symbol("wui.trustedHtml"), c = (e) => String(e ?? "").replace(/&/g, "&am
153
169
  let t = this._refs();
154
170
  if (!t.optionsWrap) return;
155
171
  let n = (e ?? (t.input ? t.input.value : "")).trim().toLowerCase(), r = this._readOptions();
156
- !this._remote && n && (r = r.filter((e) => f(e.label).toLowerCase().includes(n))), t.optionsWrap.innerHTML = r.map((e) => {
172
+ !this._remote && n && (r = r.filter((e) => h(e.label).toLowerCase().includes(n))), t.optionsWrap.innerHTML = r.map((e) => {
157
173
  let t = String(e.value) === String(this._value);
158
- return `<button type="button" role="option" class="search-select-option${t ? " selected" : ""}" data-value="${d(e.value)}" aria-selected="${t}">${l(e)}</button>`;
174
+ return `<button type="button" role="option" class="search-select-option${t ? " selected" : ""}" data-value="${m(e.value)}" aria-selected="${t}">${f(e)}</button>`;
159
175
  }).join(""), this._active = -1;
160
176
  let i = n.length < this._minChars;
161
177
  t.hint && (t.hint.hidden = !(this._remote && i && !r.length)), t.empty && (t.empty.hidden = this._loading || r.length > 0 || this._remote && i);
@@ -168,16 +184,16 @@ var s = Symbol("wui.trustedHtml"), c = (e) => String(e ?? "").replace(/&/g, "&am
168
184
  this._active = e;
169
185
  for (let e of this._optionEls()) e.classList.remove("is-active");
170
186
  e >= 0 && t[e] && (t[e].classList.add("is-active"), t[e].scrollIntoView({ block: "nearest" }));
171
- }, a = () => !e.menu.hidden, s = () => {
187
+ }, o = () => !e.menu.hidden, s = () => {
172
188
  e.menu.hidden = !1, e.control.setAttribute("aria-expanded", "true"), e.control.classList.add("open"), t(), this._renderOptions();
173
- }, c = () => {
189
+ }, l = () => {
174
190
  e.menu.hidden = !0, e.control.setAttribute("aria-expanded", "false"), e.control.classList.remove("open"), r(-1), this._syncInput();
175
- }, l = (t) => {
176
- this._value = t.dataset.value, this._label = f(t.innerHTML), o(this, this._value), e.input.value = this._label, this.dispatchEvent(new Event("change", { bubbles: !0 })), c(), e.input.focus();
191
+ }, u = (t) => {
192
+ this._value = t.dataset.value, this._label = h(t.innerHTML), c(this, this._value), e.input.value = this._label, this.dispatchEvent(new Event("change", { bubbles: !0 })), l(), e.input.focus();
177
193
  };
178
194
  e.input.addEventListener("focus", () => s()), e.input.addEventListener("input", () => {
179
195
  let t = e.input.value;
180
- if (e.clear && (e.clear.hidden = !t), a() || s(), this._remote) {
196
+ if (e.clear && (e.clear.hidden = !t), o() || s(), this._remote) {
181
197
  if (this._renderOptions(t), t.trim().length < this._minChars) return;
182
198
  clearTimeout(this._timer), this._timer = setTimeout(() => {
183
199
  this.dispatchEvent(new CustomEvent("search", {
@@ -188,25 +204,25 @@ var s = Symbol("wui.trustedHtml"), c = (e) => String(e ?? "").replace(/&/g, "&am
188
204
  } else this._renderOptions(t);
189
205
  }), e.input.addEventListener("keydown", (e) => {
190
206
  let t = n();
191
- e.key === "ArrowDown" ? (e.preventDefault(), a() || s(), r(Math.min(this._active + 1, t.length - 1))) : e.key === "ArrowUp" ? (e.preventDefault(), r(Math.max(this._active - 1, 0))) : e.key === "Enter" ? t[this._active] && (e.preventDefault(), l(t[this._active])) : e.key === "Escape" && c();
207
+ e.key === "ArrowDown" ? (e.preventDefault(), o() || s(), r(Math.min(this._active + 1, t.length - 1))) : e.key === "ArrowUp" ? (e.preventDefault(), r(Math.max(this._active - 1, 0))) : e.key === "Enter" ? t[this._active] && (e.preventDefault(), u(t[this._active])) : e.key === "Escape" && l();
192
208
  }), e.optionsWrap.addEventListener("click", (e) => {
193
209
  let t = e.target.closest(".search-select-option");
194
- t && l(t);
210
+ t && u(t);
195
211
  }), e.optionsWrap.addEventListener("mousemove", (e) => {
196
212
  let t = e.target.closest(".search-select-option");
197
213
  t && r(this._optionEls().indexOf(t));
198
- }), e.clear?.addEventListener("click", () => {
199
- this._value = "", this._label = "", o(this, ""), e.input.value = "", e.clear.hidden = !0, this._renderOptions(""), this.dispatchEvent(new Event("change", { bubbles: !0 })), e.input.focus();
214
+ }), e.optionsWrap.addEventListener("mouseleave", () => r(-1)), e.clear?.addEventListener("click", () => {
215
+ 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();
200
216
  }), this._onDocClick = (e) => {
201
- a() && !this.contains(e.target) && c();
202
- }, document.addEventListener("click", this._onDocClick), window.addEventListener("resize", () => {
203
- a() && t();
217
+ o() && !this.contains(e.target) && l();
218
+ }, document.addEventListener("click", this._onDocClick), a(this, () => {
219
+ o() && t();
204
220
  });
205
221
  }
206
222
  disconnectedCallback() {
207
- this._onDocClick && document.removeEventListener("click", this._onDocClick), clearTimeout(this._timer);
223
+ this._onDocClick && document.removeEventListener("click", this._onDocClick), o(this), clearTimeout(this._timer);
208
224
  }
209
- }, d = (e) => String(e ?? "").replace(/"/g, "&quot;").replace(/</g, "&lt;"), f = (e) => String(e ?? "").replace(/<[^>]*>/g, ""), p = [
225
+ }, m = (e) => String(e ?? "").replace(/"/g, "&quot;").replace(/</g, "&lt;"), h = (e) => String(e ?? "").replace(/<[^>]*>/g, ""), g = [
210
226
  "January",
211
227
  "February",
212
228
  "March",
@@ -219,7 +235,7 @@ var s = Symbol("wui.trustedHtml"), c = (e) => String(e ?? "").replace(/&/g, "&am
219
235
  "October",
220
236
  "November",
221
237
  "December"
222
- ], m = [
238
+ ], _ = [
223
239
  "Su",
224
240
  "Mo",
225
241
  "Tu",
@@ -227,121 +243,532 @@ var s = Symbol("wui.trustedHtml"), c = (e) => String(e ?? "").replace(/&/g, "&am
227
243
  "Th",
228
244
  "Fr",
229
245
  "Sa"
230
- ], h = (e) => String(e).padStart(2, "0"), g = (e, t, n) => `${e}-${h(t + 1)}-${h(n)}`, _ = (e) => {
246
+ ], v = (e) => String(e).padStart(2, "0"), y = (e, t, n) => `${e}-${v(t + 1)}-${v(n)}`, b = (e) => {
231
247
  let t = /^(\d{4})-(\d{2})-(\d{2})$/.exec(e || "");
232
248
  return t ? {
233
249
  y: +t[1],
234
250
  m: t[2] - 1,
235
251
  d: +t[3]
236
252
  } : null;
237
- }, v = (e) => {
238
- let t = _(e);
239
- return t ? `${h(t.d)} ${p[t.m].slice(0, 3)} ${t.y}` : "";
240
- }, y = class extends HTMLElement {
253
+ }, x = (e) => {
254
+ let t = b(e);
255
+ return t ? `${v(t.d)} ${g[t.m].slice(0, 3)} ${t.y}` : "";
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 {
241
264
  static get observedAttributes() {
242
265
  return [
243
266
  "value",
244
267
  "min",
245
268
  "max",
246
269
  "placeholder",
247
- "disabled"
270
+ "disabled",
271
+ "first-day",
272
+ "size"
248
273
  ];
249
274
  }
250
275
  constructor() {
251
276
  super(), this._value = "";
252
277
  let e = new Date(2e3, 0, 1);
253
- 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 = "";
254
279
  }
255
280
  connectedCallback() {
256
281
  this._rendered || this.render();
257
282
  }
258
283
  attributeChangedCallback(e, t, n) {
259
- 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());
260
285
  }
261
286
  get value() {
262
287
  return this._value;
263
288
  }
264
289
  set value(e) {
265
- this._value = e || "", o(this, this._value), this._syncTrigger(), this.dispatchEvent(new Event("change", { bubbles: !0 }));
290
+ this._value = e || "", c(this, this._value), this._syncTrigger(), this.dispatchEvent(new Event("change", { bubbles: !0 }));
291
+ }
292
+ _firstDay() {
293
+ let e = Number.parseInt(this.getAttribute("first-day") ?? "", 10);
294
+ return Number.isInteger(e) && e >= 0 && e <= 6 ? e : 0;
266
295
  }
267
296
  render() {
268
297
  this._value = this.getAttribute("value") || this._value;
269
- let e = this.getAttribute("placeholder") || "Enter Date", t = _(this._value);
270
- t && (this._viewY = t.y, this._viewM = t.m), this.innerHTML = `
298
+ let e = this.getAttribute("placeholder") || "Enter Date", t = b(this._value);
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 = `
271
302
  <div class="datepicker">
272
- <button type="button" class="input datepicker-trigger" aria-haspopup="dialog" aria-expanded="false"${this.hasAttribute("disabled") ? " disabled" : ""}>
273
- <span data-trigger-label class="${t ? "" : "search-select-placeholder"}">${t ? v(this._value) : e}</span>
303
+ <button type="button" class="input datepicker-trigger${r}${t ? " has-value" : ""}" aria-haspopup="dialog" aria-expanded="false"${this.hasAttribute("disabled") ? " disabled" : ""}>
304
+ <span data-trigger-label class="${t ? "" : "search-select-placeholder"}">${t ? x(this._value) : e}</span>
274
305
  <i class="bi bi-calendar3" aria-hidden="true"></i>
275
306
  </button>
276
- <div class="datepicker-pop" role="dialog" hidden></div>
277
- </div>`, this._rendered = !0, o(this, this._value), this._wire();
307
+ <div class="datepicker-pop" role="dialog" aria-modal="false" hidden></div>
308
+ </div>`, this._rendered = !0, c(this, this._value), this._wire();
278
309
  }
279
310
  _syncFormValue() {
280
- o(this, this._value);
311
+ c(this, this._value);
281
312
  }
282
313
  _syncTrigger() {
283
- let e = this.querySelector("[data-trigger-label]");
284
- if (!e) return;
285
- let t = _(this._value);
286
- e.textContent = t ? v(this._value) : this.getAttribute("placeholder") || "Enter Date", e.classList.toggle("search-select-placeholder", !t);
287
- }
288
- _renderMonth() {
289
- let e = this.querySelector(".datepicker-pop"), t = new Date(this._viewY, this._viewM, 1).getDay(), n = new Date(this._viewY, this._viewM + 1, 0).getDate(), r = _(this._value), i = _(this.getAttribute("min")), a = _(this.getAttribute("max")), o = (e, t, n) => {
290
- let r = new Date(e, t, n).getTime();
291
- return !!(i && r < new Date(i.y, i.m, i.d).getTime() || a && r > new Date(a.y, a.m, a.d).getTime());
292
- }, s = "";
293
- for (let e = 0; e < t; e++) s += "<span class=\"datepicker-day is-outside\"></span>";
294
- for (let e = 1; e <= n; e++) {
295
- let t = g(this._viewY, this._viewM, e), n = r && r.y === this._viewY && r.m === this._viewM && r.d === e, i = o(this._viewY, this._viewM, e);
296
- s += `<button type="button" class="datepicker-day${n ? " selected" : ""}" data-iso="${t}"${i ? " disabled" : ""}>${e}</button>`;
297
- }
298
- e.innerHTML = `
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 `
299
360
  <div class="datepicker-head">
300
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>
301
- <span class="datepicker-month">${p[this._viewM]} ${this._viewY}</span>
362
+ <button type="button" class="datepicker-month" data-view="months" aria-label="Choose month and year">${g[this._viewM]} ${this._viewY}</button>
302
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>
303
364
  </div>
304
- <div class="datepicker-weekdays">${m.map((e) => `<span>${e}</span>`).join("")}</div>
305
- <div class="datepicker-grid">${s}</div>
306
- <div class="datepicker-foot"><button type="button" class="datepicker-link" data-clear>Clear</button></div>`;
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();
307
411
  }
308
412
  _position(e, t) {
309
413
  i(e, t);
310
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
+ }
311
464
  _wire() {
312
- 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");
313
466
  if (!e || !t) return;
314
- let n = () => !t.hidden, r = () => {
315
- if (!_(this._value) && !this._viewNavigated) {
467
+ let r = () => !t.hidden;
468
+ this._open = () => {
469
+ if (!b(this._value) && !this._viewNavigated) {
316
470
  let e = /* @__PURE__ */ new Date();
317
471
  this._viewY = e.getFullYear(), this._viewM = e.getMonth();
318
472
  }
319
- this._renderMonth(), t.hidden = !1, this._position(e, t), e.setAttribute("aria-expanded", "true");
320
- }, i = () => {
321
- t.hidden = !0, e.setAttribute("aria-expanded", "false");
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"), O = (e, t, n) => `${e}-${D(t + 1)}-${D(n)}`, k = (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
+ }, A = (e) => {
575
+ let t = k(e);
576
+ return t ? `${D(t.d)} ${T[t.m].slice(0, 3)} ${t.y}` : "";
577
+ }, j = (e, t) => new Date(e, t + 1, 0).getDate(), M = (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
+ }, N = 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
322
612
  };
323
- e.addEventListener("click", () => n() ? i() : r()), t.addEventListener("click", (e) => {
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: `${A(this._start) || "Start"} – ${A(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 = k(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 = k(this.getAttribute("min")), t = k(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;
665
+ };
666
+ }
667
+ _monthHtml(e, t) {
668
+ let n = this._firstDay(), r = (new Date(e, t, 1).getDay() - n + 7) % 7, i = j(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 = O(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 = M(e, t - 1), u = j(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 = M(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 = M(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 ? `${A(this._start)} – ${A(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 = k(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;
324
744
  let t = e.target.closest("[data-nav]");
325
745
  if (t) {
326
- this._viewNavigated = !0, this._viewM += Number(t.dataset.nav), this._viewM < 0 ? (this._viewM = 11, --this._viewY) : this._viewM > 11 && (this._viewM = 0, this._viewY += 1), this._renderMonth();
746
+ let e = M(this._viewY, this._viewM + Number(t.dataset.nav));
747
+ this._viewY = e.y, this._viewM = e.m, this._renderView();
327
748
  return;
328
749
  }
329
750
  if (e.target.closest("[data-clear]")) {
330
- this.value = "", i();
751
+ this._start = "", this._end = "", this._hover = "", this._syncTrigger(), this._syncMirrors(), this._renderView(), this.dispatchEvent(new Event("change", { bubbles: !0 }));
331
752
  return;
332
753
  }
333
754
  let n = e.target.closest(".datepicker-day[data-iso]");
334
- n && !n.disabled && (this.value = n.dataset.iso, i());
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());
335
759
  }), this._onDocClick = (e) => {
336
- n() && !this.contains(e.target) && i();
760
+ let t = this._popClick;
761
+ this._popClick = !1, r() && !t && !this.contains(e.target) && this._close();
337
762
  }, document.addEventListener("click", this._onDocClick), this._onDocKey = (e) => {
338
- n() && e.key === "Escape" && i();
339
- }, document.addEventListener("keydown", this._onDocKey), this._syncFormValue();
763
+ r() && e.key === "Escape" && this._close();
764
+ }, document.addEventListener("keydown", this._onDocKey), a(this, () => {
765
+ r() && this._position(e, t);
766
+ }), this._syncMirrors();
340
767
  }
341
768
  disconnectedCallback() {
342
- this._onDocClick && document.removeEventListener("click", this._onDocClick), this._onDocKey && document.removeEventListener("keydown", this._onDocKey);
769
+ this._onDocClick && document.removeEventListener("click", this._onDocClick), this._onDocKey && document.removeEventListener("keydown", this._onDocKey), o(this);
343
770
  }
344
- }, b = class extends HTMLElement {
771
+ }, P = class extends HTMLElement {
345
772
  _accessibleName() {
346
773
  return this.getAttribute("aria-label") || this.getAttribute("placeholder") || "Select";
347
774
  }
@@ -351,6 +778,9 @@ var s = Symbol("wui.trustedHtml"), c = (e) => String(e ?? "").replace(/&/g, "&am
351
778
  "search-placeholder",
352
779
  "searchable",
353
780
  "disabled",
781
+ "icon",
782
+ "size",
783
+ "collapse-chips",
354
784
  "aria-label"
355
785
  ];
356
786
  }
@@ -373,7 +803,7 @@ var s = Symbol("wui.trustedHtml"), c = (e) => String(e ?? "").replace(/&/g, "&am
373
803
  return this._values.slice();
374
804
  }
375
805
  set values(e) {
376
- this._values = Array.isArray(e) ? e.map(String) : [], o(this, this._values.join(",")), this._rendered && this._renderControl();
806
+ this._values = Array.isArray(e) ? e.map(String) : [], c(this, this._values.join(",")), this._rendered && this._renderControl();
377
807
  }
378
808
  set options(e) {
379
809
  this._optionsProp = Array.isArray(e) ? e : null, this.isConnected && this.render();
@@ -387,7 +817,8 @@ var s = Symbol("wui.trustedHtml"), c = (e) => String(e ?? "").replace(/&/g, "&am
387
817
  e.length && (this._declared = e.map((e) => ({
388
818
  value: e.getAttribute("value") ?? e.textContent.trim(),
389
819
  label: e.innerHTML,
390
- [s]: !0,
820
+ icon: e.getAttribute("icon") || void 0,
821
+ [l]: !0,
391
822
  selected: e.hasAttribute("selected")
392
823
  })));
393
824
  }
@@ -400,101 +831,122 @@ var s = Symbol("wui.trustedHtml"), c = (e) => String(e ?? "").replace(/&/g, "&am
400
831
  }
401
832
  _labelHtmlFor(e) {
402
833
  let t = this._readOptions().find((t) => String(t.value) === String(e));
403
- return t ? l(t) : c(e);
834
+ return t ? f(t) : u(e);
404
835
  }
405
836
  render() {
406
837
  this._snapshotDeclared();
407
- let e = this.hasAttribute("searchable"), t = this.getAttribute("search-placeholder") || "Search…";
408
- o(this, this._values.join(",")), this.innerHTML = `
409
- <div class="search-select">
410
- <div class="input search-select-control search-select-multi" role="combobox" aria-haspopup="listbox" aria-expanded="false" aria-label="${x(this._accessibleName())}"${this.hasAttribute("disabled") ? " aria-disabled=\"true\"" : ""}>
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" : "";
839
+ c(this, this._values.join(",")), this.innerHTML = `
840
+ <div class="search-select${i}">
841
+ <div class="input search-select-control search-select-multi" role="combobox" aria-haspopup="listbox" aria-expanded="false" aria-label="${F(this._accessibleName())}"${this.hasAttribute("disabled") ? " aria-disabled=\"true\"" : ""}>
842
+ ${n ? `<i class="bi bi-${F(n)} search-select-icon" aria-hidden="true"></i>` : ""}
411
843
  <div class="ms-chips" data-chips></div>
412
844
  <i class="bi bi-chevron-down search-select-caret" aria-hidden="true"></i>
413
845
  </div>
414
846
  <div class="search-select-menu search-select-menu-fixed" role="listbox" aria-multiselectable="true" tabindex="-1" hidden>
415
- ${e ? `<div class="search-select-search"><i class="bi bi-search" aria-hidden="true"></i><input class="search-select-input" placeholder="${x(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>` : ""}
847
+ ${e ? `<div class="search-select-search"><i class="bi bi-search" aria-hidden="true"></i><input class="search-select-input" placeholder="${F(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>` : ""}
416
848
  <div class="search-select-options"></div>
417
849
  <div class="search-select-empty" hidden>No matches</div>
418
850
  </div>
419
- </div>`, this._rendered = !0, o(this, this._values.join(",")), this._renderControl(), this._renderOptions(), this._wire();
851
+ </div>`, this._rendered = !0, c(this, this._values.join(",")), this._renderControl(), this._renderOptions(), this._wire();
420
852
  }
421
853
  _renderControl() {
422
854
  let e = this.querySelector("[data-chips]");
423
855
  if (!e) return;
424
856
  let t = this.getAttribute("placeholder") || "Select…";
425
857
  if (!this._values.length) {
426
- e.innerHTML = `<span class="search-select-placeholder">${c(t)}</span>`;
858
+ e.innerHTML = `<span class="search-select-placeholder">${u(t)}</span>`;
427
859
  return;
428
860
  }
429
- 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="${x(e)}" aria-label="Remove"><i class="bi bi-x" aria-hidden="true"></i></button></span>`).join("");
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="${F(e)}" aria-label="Remove"><i class="bi bi-x" aria-hidden="true"></i></button></span>`).join(""), this._collapseChips();
862
+ }
863
+ _collapseChips() {
864
+ let e = this.querySelector("[data-chips]");
865
+ if (!e || !this.hasAttribute("collapse-chips") || !this._values.length) return;
866
+ e.querySelector(".chip-more")?.remove();
867
+ let t = [...e.querySelectorAll(":scope > .chip:not(.chip-more)")];
868
+ for (let e of t) e.style.display = "";
869
+ if (!t.length) return;
870
+ let n = e.clientWidth, r = (e) => e.offsetLeft + e.offsetWidth;
871
+ if (r(t[t.length - 1]) <= n) return;
872
+ let i = document.createElement("span");
873
+ i.className = "chip chip-sm chip-more", i.textContent = `+${t.length}`, e.appendChild(i);
874
+ let a = i.offsetWidth + 6, o = 0;
875
+ for (let e of t) if (r(e) <= n - a) o += 1;
876
+ else break;
877
+ o < 1 && (o = 1);
878
+ for (let e = o; e < t.length; e += 1) t[e].style.display = "none";
879
+ i.textContent = `+${t.length - o}`;
430
880
  }
431
881
  _renderOptions(e) {
432
882
  let t = this.querySelector(".search-select-options"), n = this.querySelector(".search-select-empty");
433
883
  if (!t) return;
434
884
  let r = (e || "").trim().toLowerCase(), i = this._readOptions();
435
- r && (i = i.filter((e) => S(e.label).toLowerCase().includes(r))), t.innerHTML = i.map((e) => {
885
+ r && (i = i.filter((e) => ee(e.label).toLowerCase().includes(r))), t.innerHTML = i.map((e) => {
436
886
  let t = this._values.includes(String(e.value));
437
- return `<button type="button" role="option" class="search-select-option${t ? " selected" : ""}" data-value="${x(e.value)}" aria-selected="${t}"><span class="ms-check"><i class="bi bi-check" aria-hidden="true"></i></span><span class="ms-opt-label">${l(e)}</span></button>`;
887
+ return `<button type="button" role="option" class="search-select-option${t ? " selected" : ""}" data-value="${F(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>`;
438
888
  }).join(""), n && (n.hidden = i.length > 0), this._active = -1;
439
889
  }
440
890
  _wire() {
441
- 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"), a = this.querySelector(".search-select-options");
891
+ 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");
442
892
  if (!e || !t) return;
443
- let s = () => this.hasAttribute("disabled"), c = () => i(e, t, { matchWidth: !0 }), l = () => [...this.querySelectorAll(".search-select-option")], u = () => l().filter((e) => !e.hidden), d = (e) => {
444
- let t = u();
893
+ let s = () => this.hasAttribute("disabled");
894
+ !this._ro && typeof ResizeObserver < "u" && (this._ro = new ResizeObserver(() => this._collapseChips()), this._ro.observe(this));
895
+ let l = () => i(e, t, { matchWidth: !0 }), u = () => [...this.querySelectorAll(".search-select-option")], d = () => u().filter((e) => !e.hidden), f = (e) => {
896
+ let t = d();
445
897
  this._active = e;
446
- for (let e of l()) e.classList.remove("is-active");
898
+ for (let e of u()) e.classList.remove("is-active");
447
899
  e >= 0 && t[e] && (t[e].classList.add("is-active"), t[e].scrollIntoView({ block: "nearest" }));
448
- }, f = () => !t.hidden, p = () => {
449
- s() || (t.hidden = !1, e.setAttribute("aria-expanded", "true"), e.classList.add("open"), c(), n && (n.value = "", this._renderOptions(""), n.focus()));
450
- }, m = () => {
451
- t.hidden = !0, e.setAttribute("aria-expanded", "false"), e.classList.remove("open"), d(-1);
900
+ }, p = () => !t.hidden, m = () => {
901
+ s() || (t.hidden = !1, e.setAttribute("aria-expanded", "true"), e.classList.add("open"), l(), n && (n.value = "", this._renderOptions(""), n.focus()));
452
902
  }, h = () => {
453
- o(this, this._values.join(",")), this.dispatchEvent(new Event("change", { bubbles: !0 }));
454
- }, g = (e) => {
455
- let t = String(e);
456
- this._values.includes(t) ? this._values = this._values.filter((e) => e !== t) : this._values = [...this._values, t], this._renderControl(), this._renderOptions(n ? n.value : ""), h();
903
+ t.hidden = !0, e.setAttribute("aria-expanded", "false"), e.classList.remove("open"), f(-1);
904
+ }, g = () => {
905
+ c(this, this._values.join(",")), this.dispatchEvent(new Event("change", { bubbles: !0 }));
457
906
  }, _ = (e) => {
458
- this._values = this._values.filter((t) => t !== String(e)), this._renderControl(), this._renderOptions(n ? n.value : ""), h();
907
+ let t = String(e);
908
+ this._values.includes(t) ? this._values = this._values.filter((e) => e !== t) : this._values = [...this._values, t], this._renderControl(), this._renderOptions(n ? n.value : ""), g();
909
+ }, v = (e) => {
910
+ this._values = this._values.filter((t) => t !== String(e)), this._renderControl(), this._renderOptions(n ? n.value : ""), g();
459
911
  };
460
912
  e.addEventListener("click", (e) => {
461
913
  let t = e.target.closest("[data-remove]");
462
914
  if (t) {
463
- e.stopPropagation(), _(t.dataset.remove);
915
+ e.stopPropagation(), v(t.dataset.remove);
464
916
  return;
465
917
  }
466
- f() ? m() : p();
467
- }), a.addEventListener("click", (e) => {
918
+ p() ? h() : m();
919
+ }), o.addEventListener("click", (e) => {
468
920
  let t = e.target.closest(".search-select-option");
469
- t && (g(t.dataset.value), n?.focus());
470
- }), a.addEventListener("mousemove", (e) => {
921
+ t && (_(t.dataset.value), n?.focus());
922
+ }), o.addEventListener("mousemove", (e) => {
471
923
  let t = e.target.closest(".search-select-option");
472
- t && d(u().indexOf(t));
473
- }), n?.addEventListener("input", () => {
474
- this._renderOptions(n.value), r && (r.hidden = !n.value), d(-1);
924
+ t && f(d().indexOf(t));
925
+ }), o.addEventListener("mouseleave", () => f(-1)), n?.addEventListener("input", () => {
926
+ this._renderOptions(n.value), r && (r.hidden = !n.value), f(-1);
475
927
  });
476
- let v = (t) => {
477
- let r = u();
478
- t.key === "ArrowDown" ? (t.preventDefault(), d(Math.min(this._active + 1, r.length - 1))) : t.key === "ArrowUp" ? (t.preventDefault(), d(Math.max(this._active - 1, 0))) : t.key === "Enter" ? (t.preventDefault(), r[this._active] && g(r[this._active].dataset.value)) : t.key === "Escape" ? (m(), e.focus()) : t.key === "Backspace" && !n.value && this._values.length && _(this._values[this._values.length - 1]);
928
+ let y = (t) => {
929
+ let r = d();
930
+ t.key === "ArrowDown" ? (t.preventDefault(), f(Math.min(this._active + 1, r.length - 1))) : t.key === "ArrowUp" ? (t.preventDefault(), f(Math.max(this._active - 1, 0))) : t.key === "Enter" ? (t.preventDefault(), r[this._active] && _(r[this._active].dataset.value)) : t.key === "Escape" ? (h(), e.focus()) : t.key === "Backspace" && !n.value && this._values.length && v(this._values[this._values.length - 1]);
479
931
  };
480
- n?.addEventListener("keydown", v), r?.addEventListener("click", () => {
932
+ n?.addEventListener("keydown", y), r?.addEventListener("click", () => {
481
933
  n.value = "", this._renderOptions(""), r.hidden = !0, n.focus();
482
934
  }), e.addEventListener("keydown", (e) => {
483
- if (f()) {
484
- v(e);
935
+ if (p()) {
936
+ y(e);
485
937
  return;
486
938
  }
487
- (e.key === "ArrowDown" || e.key === "Enter" || e.key === " ") && (e.preventDefault(), p());
939
+ (e.key === "ArrowDown" || e.key === "Enter" || e.key === " ") && (e.preventDefault(), m());
488
940
  }), this._onDocClick = (e) => {
489
- f() && !this.contains(e.target) && m();
490
- }, document.addEventListener("click", this._onDocClick), window.addEventListener("resize", () => {
491
- f() && c();
941
+ p() && !this.contains(e.target) && h();
942
+ }, document.addEventListener("click", this._onDocClick), a(this, () => {
943
+ p() && l();
492
944
  });
493
945
  }
494
946
  disconnectedCallback() {
495
- this._onDocClick && document.removeEventListener("click", this._onDocClick);
947
+ this._onDocClick && document.removeEventListener("click", this._onDocClick), o(this), this._ro?.disconnect(), this._ro = null;
496
948
  }
497
- }, x = (e) => String(e ?? "").replace(/"/g, "&quot;").replace(/</g, "&lt;"), S = (e) => String(e ?? "").replace(/<[^>]*>/g, ""), C = /[^0-9]/g, w = /[^0-9a-zA-Z]/g, T = class extends HTMLElement {
949
+ }, F = (e) => String(e ?? "").replace(/"/g, "&quot;").replace(/</g, "&lt;"), ee = (e) => String(e ?? "").replace(/<[^>]*>/g, ""), I = /[^0-9]/g, L = /[^0-9a-zA-Z]/g, R = class extends HTMLElement {
498
950
  static get observedAttributes() {
499
951
  return [
500
952
  "value",
@@ -521,16 +973,16 @@ var s = Symbol("wui.trustedHtml"), c = (e) => String(e ?? "").replace(/&/g, "&am
521
973
  return this._value ?? "";
522
974
  }
523
975
  set value(e) {
524
- this._value = this._clean(e), o(this, this._value), this._paint();
976
+ this._value = this._clean(e), c(this, this._value), this._paint();
525
977
  }
526
978
  _clean(e) {
527
- return (e == null ? "" : String(e)).replace(this.mode === "alphanumeric" ? w : C, "").slice(0, this.length);
979
+ return (e == null ? "" : String(e)).replace(this.mode === "alphanumeric" ? L : I, "").slice(0, this.length);
528
980
  }
529
981
  connectedCallback() {
530
982
  this._rendered || this.render();
531
983
  }
532
984
  attributeChangedCallback(e, t, n) {
533
- this._rendered && (e === "value" ? (this._value = this._clean(n), o(this, this._value), this._paint()) : this.render());
985
+ this._rendered && (e === "value" ? (this._value = this._clean(n), c(this, this._value), this._paint()) : this.render());
534
986
  }
535
987
  render() {
536
988
  this._value = this._clean(this.getAttribute("value") ?? this._value);
@@ -548,7 +1000,7 @@ var s = Symbol("wui.trustedHtml"), c = (e) => String(e ?? "").replace(/&/g, "&am
548
1000
  spellcheck="false"
549
1001
  ${n ? "disabled" : ""} />
550
1002
  <div class="otp-slots" aria-hidden="true">${r}</div>
551
- </div>`, this._rendered = !0, o(this, this._value), this._wire(), this._paint();
1003
+ </div>`, this._rendered = !0, c(this, this._value), this._wire(), this._paint();
552
1004
  }
553
1005
  _refs() {
554
1006
  return {
@@ -570,7 +1022,7 @@ var s = Symbol("wui.trustedHtml"), c = (e) => String(e ?? "").replace(/&/g, "&am
570
1022
  if (!e) return;
571
1023
  let t = (e) => {
572
1024
  let t = this._clean(e), n = t !== this._value;
573
- this._value = t, o(this, this._value), this._paint(), n && this.dispatchEvent(new Event("change", { bubbles: !0 })), n && t.length === this.length && this.dispatchEvent(new CustomEvent("complete", {
1025
+ this._value = t, c(this, this._value), this._paint(), n && this.dispatchEvent(new Event("change", { bubbles: !0 })), n && t.length === this.length && this.dispatchEvent(new CustomEvent("complete", {
574
1026
  bubbles: !0,
575
1027
  detail: t
576
1028
  }));
@@ -590,7 +1042,7 @@ var s = Symbol("wui.trustedHtml"), c = (e) => String(e ?? "").replace(/&/g, "&am
590
1042
  document.activeElement === e && this._paint();
591
1043
  });
592
1044
  }
593
- }, E = [
1045
+ }, z = [
594
1046
  [
595
1047
  "AF",
596
1048
  "Afghanistan",
@@ -1816,11 +2268,11 @@ var s = Symbol("wui.trustedHtml"), c = (e) => String(e ?? "").replace(/&/g, "&am
1816
2268
  "Zimbabwe",
1817
2269
  "263"
1818
2270
  ]
1819
- ], D = (e) => (E.find((t) => t[0] === e) || [
2271
+ ], B = (e) => (z.find((t) => t[0] === e) || [
1820
2272
  "",
1821
2273
  "",
1822
2274
  ""
1823
- ])[2], O = (e) => `wui-flag wui-flag-${String(e).toLowerCase()}`, k = class extends HTMLElement {
2275
+ ])[2], V = (e) => `wui-flag wui-flag-${String(e).toLowerCase()}`, H = class extends HTMLElement {
1824
2276
  static get observedAttributes() {
1825
2277
  return [
1826
2278
  "value",
@@ -1839,36 +2291,36 @@ var s = Symbol("wui.trustedHtml"), c = (e) => String(e ?? "").replace(/&/g, "&am
1839
2291
  this._rendered && (e === "country" && (this._country = n || "IN"), this.render());
1840
2292
  }
1841
2293
  get value() {
1842
- return `+${D(this._country)}${this._national}`;
2294
+ return `+${B(this._country)}${this._national}`;
1843
2295
  }
1844
2296
  set value(e) {
1845
2297
  this._national = String(e ?? "").replace(/[^0-9]/g, ""), this._commit();
1846
2298
  }
1847
2299
  _commit() {
1848
- o(this, this.value), this.dispatchEvent(new Event("change", { bubbles: !0 }));
2300
+ c(this, this.value), this.dispatchEvent(new Event("change", { bubbles: !0 }));
1849
2301
  }
1850
2302
  render() {
1851
2303
  let e = this.getAttribute("placeholder") || "Enter phone number";
1852
2304
  this._country = this.getAttribute("country") || this._country;
1853
- let t = E.map(([e, t, n]) => `<button type="button" role="option" class="country-dropdown-item${e === this._country ? " selected" : ""}" data-iso="${e}"><span class="${O(e)}" aria-hidden="true"></span><span class="country-name-text">${t}<span class="country-code-text">+${n}</span></span></button>`).join("");
2305
+ let t = z.map(([e, t, n]) => `<button type="button" role="option" class="country-dropdown-item${e === this._country ? " selected" : ""}" data-iso="${e}"><span class="${V(e)}" aria-hidden="true"></span><span class="country-name-text">${t}<span class="country-code-text">+${n}</span></span></button>`).join("");
1854
2306
  this.innerHTML = `
1855
2307
  <div class="phone-input-wrap">
1856
2308
  <div class="phone-country-adornment">
1857
2309
  <button type="button" class="country-toggle" aria-haspopup="listbox" aria-expanded="false"${this.hasAttribute("disabled") ? " disabled" : ""}>
1858
- <span class="${O(this._country)}" data-flag aria-hidden="true"></span>
2310
+ <span class="${V(this._country)}" data-flag aria-hidden="true"></span>
1859
2311
  <i class="bi bi-chevron-down phone-chevron" aria-hidden="true"></i>
1860
- <span class="phone-dial" data-dial>+${D(this._country)}</span>
2312
+ <span class="phone-dial" data-dial>+${B(this._country)}</span>
1861
2313
  </button>
1862
2314
  <div class="country-dropdown-menu" role="listbox" hidden>
1863
2315
  <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>
1864
2316
  <div class="country-list-scroll">${t}<div class="country-empty" hidden>No countries found</div></div>
1865
2317
  </div>
1866
2318
  </div>
1867
- <input type="tel" class="input" placeholder="${A(e)}" value="${A(this._national)}"${this.hasAttribute("disabled") ? " disabled" : ""} />
1868
- </div>`, this._rendered = !0, o(this, this.value), this._wire();
2319
+ <input type="tel" class="input" placeholder="${U(e)}" value="${U(this._national)}"${this.hasAttribute("disabled") ? " disabled" : ""} />
2320
+ </div>`, this._rendered = !0, c(this, this.value), this._wire();
1869
2321
  }
1870
2322
  _wire() {
1871
- let e = this.querySelector(".country-toggle"), t = this.querySelector(".country-dropdown-menu"), n = this.querySelector(".dropdown-search-input"), r = this.querySelector(".country-list-scroll"), i = this.querySelector(".country-empty"), a = this.querySelector("input[type=tel]"), s = this.querySelector("[data-flag]"), c = this.querySelector("[data-dial]");
2323
+ let e = this.querySelector(".country-toggle"), t = this.querySelector(".country-dropdown-menu"), n = this.querySelector(".dropdown-search-input"), r = this.querySelector(".country-list-scroll"), i = this.querySelector(".country-empty"), a = this.querySelector("input[type=tel]"), o = this.querySelector("[data-flag]"), s = this.querySelector("[data-dial]");
1872
2324
  if (!e || !t) return;
1873
2325
  let l = () => !t.hidden, u = () => {
1874
2326
  let n = e.getBoundingClientRect(), r = t.offsetWidth || 320, i = t.offsetHeight || 320, a = window.innerHeight - n.bottom, o = a < i + 6 && n.top > a ? n.top - i - 6 : n.bottom + 6, s = Math.min(Math.max(8, n.left), Math.max(8, window.innerWidth - r - 8));
@@ -1889,7 +2341,7 @@ var s = Symbol("wui.trustedHtml"), c = (e) => String(e ?? "").replace(/&/g, "&am
1889
2341
  }
1890
2342
  i && (i.hidden = n > 0);
1891
2343
  }, m = (e) => {
1892
- this._country = e, this.setAttribute("country", e), s && (s.className = O(e)), c && (c.textContent = `+${D(e)}`);
2344
+ this._country = e, this.setAttribute("country", e), o && (o.className = V(e)), s && (s.textContent = `+${B(e)}`);
1893
2345
  for (let t of r.querySelectorAll(".country-dropdown-item")) t.classList.toggle("selected", t.dataset.iso === e);
1894
2346
  f(), this._commit();
1895
2347
  };
@@ -1900,12 +2352,12 @@ var s = Symbol("wui.trustedHtml"), c = (e) => String(e ?? "").replace(/&/g, "&am
1900
2352
  this._national = a.value.replace(/[^0-9]/g, ""), this._commit();
1901
2353
  }), this._onDocClick = (e) => {
1902
2354
  l() && !this.contains(e.target) && f();
1903
- }, document.addEventListener("click", this._onDocClick), o(this, this.value);
2355
+ }, document.addEventListener("click", this._onDocClick), c(this, this.value);
1904
2356
  }
1905
2357
  disconnectedCallback() {
1906
2358
  this._reposition && (window.removeEventListener("scroll", this._reposition, !0), window.removeEventListener("resize", this._reposition)), this._onDocClick && document.removeEventListener("click", this._onDocClick);
1907
2359
  }
1908
- }, A = (e) => String(e ?? "").replace(/"/g, "&quot;").replace(/</g, "&lt;"), j = class extends HTMLElement {
2360
+ }, U = (e) => String(e ?? "").replace(/"/g, "&quot;").replace(/</g, "&lt;"), W = class extends HTMLElement {
1909
2361
  static get observedAttributes() {
1910
2362
  return [
1911
2363
  "value",
@@ -1916,6 +2368,8 @@ var s = Symbol("wui.trustedHtml"), c = (e) => String(e ?? "").replace(/&/g, "&am
1916
2368
  "compact",
1917
2369
  "size",
1918
2370
  "clearable",
2371
+ "icon",
2372
+ "prefix",
1919
2373
  "aria-label"
1920
2374
  ];
1921
2375
  }
@@ -1935,7 +2389,7 @@ var s = Symbol("wui.trustedHtml"), c = (e) => String(e ?? "").replace(/&/g, "&am
1935
2389
  return this._value;
1936
2390
  }
1937
2391
  set value(e) {
1938
- this._value = e == null ? "" : String(e), o(this, this._value), this._syncSelected(), this._syncReset();
2392
+ this._value = e == null ? "" : String(e), c(this, this._value), this._syncSelected(), this._syncReset();
1939
2393
  }
1940
2394
  set options(e) {
1941
2395
  this._optionsProp = Array.isArray(e) ? e : null, this.isConnected && this.render();
@@ -1949,7 +2403,8 @@ var s = Symbol("wui.trustedHtml"), c = (e) => String(e ?? "").replace(/&/g, "&am
1949
2403
  e.length && (this._declared = e.map((e) => ({
1950
2404
  value: e.getAttribute("value") ?? e.textContent.trim(),
1951
2405
  label: e.innerHTML,
1952
- [s]: !0,
2406
+ icon: e.getAttribute("icon") || void 0,
2407
+ [l]: !0,
1953
2408
  selected: e.hasAttribute("selected")
1954
2409
  })));
1955
2410
  }
@@ -1958,24 +2413,26 @@ var s = Symbol("wui.trustedHtml"), c = (e) => String(e ?? "").replace(/&/g, "&am
1958
2413
  }
1959
2414
  render() {
1960
2415
  this._snapshotDeclared();
1961
- 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("placeholder") || "Select...", s = this.getAttribute("search-placeholder") || "Search...", u = e.find((e) => String(e.value) === String(this._value)) || e.find((e) => e.selected);
1962
- u && (this._value = String(u.value)), o(this, this._value);
1963
- let d = e.map((e) => {
2416
+ 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);
2417
+ d && (this._value = String(d.value)), c(this, this._value);
2418
+ let p = e.map((e) => {
1964
2419
  let t = String(e.value) === String(this._value);
1965
- return `<button type="button" role="option" class="search-select-option${t ? " selected" : ""}" data-value="${M(e.value)}" aria-selected="${t}">${l(e)}</button>`;
2420
+ return `<button type="button" role="option" class="search-select-option${t ? " selected" : ""}" data-value="${G(e.value)}" aria-selected="${t}">${f(e)}</button>`;
1966
2421
  }).join("");
1967
2422
  this.innerHTML = `
1968
2423
  <div class="search-select${this.hasAttribute("compact") ? " search-select-compact" : ""}${i}">
1969
- <button type="button" role="combobox" class="input search-select-control" aria-haspopup="listbox" aria-expanded="false" aria-label="${M(this._accessibleName())}"${this.hasAttribute("disabled") ? " disabled" : ""}>
1970
- <span class="${u ? "" : "search-select-placeholder"}" data-label>${u ? l(u) : c(a)}</span>
2424
+ <button type="button" role="combobox" class="input search-select-control" aria-haspopup="listbox" aria-expanded="false" aria-label="${G(this._accessibleName())}"${this.hasAttribute("disabled") ? " disabled" : ""}>
2425
+ ${a ? `<i class="bi bi-${G(a)} search-select-icon" aria-hidden="true"></i>` : ""}
2426
+ ${o ? `<span class="search-select-prefix">${u(o)}</span>` : ""}
2427
+ <span class="${d ? "" : "search-select-placeholder"}" data-label>${d ? f(d) : u(s)}</span>
1971
2428
  ${n ? "<span class=\"search-select-reset\" role=\"button\" aria-label=\"Clear selection\" hidden><i class=\"bi bi-x-lg\" aria-hidden=\"true\"></i></span>" : ""}
1972
2429
  <i class="bi bi-chevron-down search-select-caret" aria-hidden="true"></i>
1973
2430
  </button>
1974
2431
  <div class="search-select-menu search-select-menu-fixed" role="listbox" tabindex="-1" hidden>
1975
- ${t ? `<div class="search-select-search"><i class="bi bi-search" aria-hidden="true"></i><input class="search-select-input" placeholder="${M(s)}" 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>` : ""}
1976
- <div class="search-select-options">${d}<div class="search-select-empty" hidden>No matches</div></div>
2432
+ ${t ? `<div class="search-select-search"><i class="bi bi-search" aria-hidden="true"></i><input class="search-select-input" placeholder="${G(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>` : ""}
2433
+ <div class="search-select-options">${p}<div class="search-select-empty" hidden>No matches</div></div>
1977
2434
  </div>
1978
- </div>`, this._rendered = !0, o(this, this._value), this._wire(), this._syncReset();
2435
+ </div>`, this._rendered = !0, c(this, this._value), this._wire(), this._syncReset();
1979
2436
  }
1980
2437
  _refs() {
1981
2438
  return {
@@ -2001,7 +2458,7 @@ var s = Symbol("wui.trustedHtml"), c = (e) => String(e ?? "").replace(/&/g, "&am
2001
2458
  let t = e.dataset.value === String(this._value);
2002
2459
  e.classList.toggle("selected", t), e.setAttribute("aria-selected", String(t));
2003
2460
  }
2004
- e && (e.innerHTML = t ? l(t) : e.innerHTML, e.classList.toggle("search-select-placeholder", !t));
2461
+ e && (e.innerHTML = t ? f(t) : e.innerHTML, e.classList.toggle("search-select-placeholder", !t));
2005
2462
  }
2006
2463
  _syncReset() {
2007
2464
  let { reset: e } = this._refs();
@@ -2010,7 +2467,12 @@ var s = Symbol("wui.trustedHtml"), c = (e) => String(e ?? "").replace(/&/g, "&am
2010
2467
  _wire() {
2011
2468
  let e = this._refs();
2012
2469
  if (!e.control || !e.menu) return;
2013
- let t = () => i(e.control, e.menu, { matchWidth: !0 }), n = (e) => {
2470
+ let t = () => {
2471
+ if (this.hasAttribute("compact")) {
2472
+ let t = e.control.getBoundingClientRect();
2473
+ e.menu.style.width = "max-content", e.menu.style.minWidth = `${t.width}px`, e.menu.style.maxWidth = "280px", i(e.control, e.menu);
2474
+ } else i(e.control, e.menu, { matchWidth: !0 });
2475
+ }, n = (e) => {
2014
2476
  let t = this._visible();
2015
2477
  this._active = e;
2016
2478
  for (let e of this._optionEls()) e.classList.remove("is-active");
@@ -2022,51 +2484,51 @@ var s = Symbol("wui.trustedHtml"), c = (e) => String(e ?? "").replace(/&/g, "&am
2022
2484
  e.hidden = !t, t && (r += 1);
2023
2485
  }
2024
2486
  e.empty && (e.empty.hidden = r > 0), e.clear && (e.clear.hidden = !n);
2025
- }, a = () => !e.menu.hidden, o = () => {
2487
+ }, o = () => !e.menu.hidden, s = () => {
2026
2488
  e.menu.hidden = !1, e.control.setAttribute("aria-expanded", "true"), e.control.classList.add("open"), t(), e.search && (e.search.value = "", r(""), e.search.focus()), n(this._optionEls().findIndex((e) => e.classList.contains("selected")));
2027
- }, s = () => {
2489
+ }, c = () => {
2028
2490
  e.menu.hidden = !0, e.control.setAttribute("aria-expanded", "false"), e.control.classList.remove("open"), n(-1);
2029
- }, c = (t) => {
2030
- this.value = t.dataset.value, this.dispatchEvent(new Event("change", { bubbles: !0 })), s(), e.control.focus();
2031
2491
  }, l = (t) => {
2492
+ this.value = t.dataset.value, this.dispatchEvent(new Event("change", { bubbles: !0 })), c(), e.control.focus();
2493
+ }, u = (t) => {
2032
2494
  let r = this._visible();
2033
- t.key === "ArrowDown" ? (t.preventDefault(), n(Math.min(this._active + 1, r.length - 1))) : t.key === "ArrowUp" ? (t.preventDefault(), n(Math.max(this._active - 1, 0))) : t.key === "Enter" ? (t.preventDefault(), r[this._active] && c(r[this._active])) : t.key === "Escape" && (s(), e.control.focus());
2495
+ t.key === "ArrowDown" ? (t.preventDefault(), n(Math.min(this._active + 1, r.length - 1))) : t.key === "ArrowUp" ? (t.preventDefault(), n(Math.max(this._active - 1, 0))) : t.key === "Enter" ? (t.preventDefault(), r[this._active] && l(r[this._active])) : t.key === "Escape" && (c(), e.control.focus());
2034
2496
  };
2035
2497
  e.reset?.addEventListener("click", (t) => {
2036
2498
  t.stopPropagation(), this.value = "", this.dispatchEvent(new Event("change", { bubbles: !0 })), e.control.focus();
2037
- }), e.control.addEventListener("click", () => a() ? s() : o()), e.control.addEventListener("keydown", (e) => {
2038
- if (a()) {
2039
- l(e);
2499
+ }), e.control.addEventListener("click", () => o() ? c() : s()), e.control.addEventListener("keydown", (e) => {
2500
+ if (o()) {
2501
+ u(e);
2040
2502
  return;
2041
2503
  }
2042
- (e.key === "ArrowDown" || e.key === "Enter" || e.key === " ") && (e.preventDefault(), o());
2504
+ (e.key === "ArrowDown" || e.key === "Enter" || e.key === " ") && (e.preventDefault(), s());
2043
2505
  }), e.optionsWrap.addEventListener("click", (e) => {
2044
2506
  let t = e.target.closest(".search-select-option");
2045
- t && c(t);
2507
+ t && l(t);
2046
2508
  }), e.optionsWrap.addEventListener("mousemove", (e) => {
2047
2509
  let t = e.target.closest(".search-select-option");
2048
2510
  t && n(this._visible().indexOf(t));
2049
2511
  }), e.optionsWrap.addEventListener("mouseleave", () => n(-1)), e.search?.addEventListener("input", () => {
2050
2512
  r(e.search.value), n(-1);
2051
- }), e.search?.addEventListener("keydown", l), e.clear?.addEventListener("click", () => {
2513
+ }), e.search?.addEventListener("keydown", u), e.clear?.addEventListener("click", () => {
2052
2514
  e.search.value = "", r(""), e.search.focus();
2053
- }), e.menu.addEventListener("keydown", l), this._onDocClick = (e) => {
2054
- a() && !this.contains(e.target) && s();
2055
- }, document.addEventListener("click", this._onDocClick), window.addEventListener("resize", () => {
2056
- a() && t();
2515
+ }), e.menu.addEventListener("keydown", u), this._onDocClick = (e) => {
2516
+ o() && !this.contains(e.target) && c();
2517
+ }, document.addEventListener("click", this._onDocClick), a(this, () => {
2518
+ o() && t();
2057
2519
  });
2058
2520
  }
2059
2521
  disconnectedCallback() {
2060
- this._onDocClick && document.removeEventListener("click", this._onDocClick);
2522
+ this._onDocClick && document.removeEventListener("click", this._onDocClick), o(this);
2061
2523
  }
2062
- }, M = (e) => String(e ?? "").replace(/"/g, "&quot;").replace(/</g, "&lt;"), N = "image/png,image/jpeg,image/webp", P = 5, F = {
2524
+ }, G = (e) => String(e ?? "").replace(/"/g, "&quot;").replace(/</g, "&lt;"), K = "image/png,image/jpeg,image/webp", te = 5, q = {
2063
2525
  "image/png": [".png"],
2064
2526
  "image/jpeg": [".jpg", ".jpeg"],
2065
2527
  "image/webp": [".webp"],
2066
2528
  "image/gif": [".gif"],
2067
2529
  "image/svg+xml": [".svg"],
2068
2530
  "application/pdf": [".pdf"]
2069
- }, I = {
2531
+ }, J = {
2070
2532
  "image/png": "PNG",
2071
2533
  "image/jpeg": "JPG",
2072
2534
  "image/webp": "WEBP",
@@ -2080,34 +2542,34 @@ var s = Symbol("wui.trustedHtml"), c = (e) => String(e ?? "").replace(/&/g, "&am
2080
2542
  ".gif": "GIF",
2081
2543
  ".svg": "SVG",
2082
2544
  ".pdf": "PDF"
2083
- }, L = (e) => String(e || "").split(",").map((e) => e.trim().toLowerCase()).filter(Boolean);
2084
- function R(e) {
2545
+ }, Y = (e) => String(e || "").split(",").map((e) => e.trim().toLowerCase()).filter(Boolean);
2546
+ function X(e) {
2085
2547
  let t = [];
2086
- for (let n of L(e)) {
2087
- let e = I[n] || (n.startsWith(".") ? n.slice(1).toUpperCase() : n.toUpperCase());
2548
+ for (let n of Y(e)) {
2549
+ let e = J[n] || (n.startsWith(".") ? n.slice(1).toUpperCase() : n.toUpperCase());
2088
2550
  t.includes(e) || t.push(e);
2089
2551
  }
2090
2552
  return t.length <= 1 ? t[0] || "supported" : `${t.slice(0, -1).join(", ")} or ${t[t.length - 1]}`;
2091
2553
  }
2092
- function z(e, t) {
2093
- let n = L(t);
2554
+ function Z(e, t) {
2555
+ let n = Y(t);
2094
2556
  if (!n.length) return !0;
2095
2557
  let r = (e.type || "").toLowerCase(), i = (e.name || "").toLowerCase();
2096
- return n.some((e) => e.startsWith(".") ? i.endsWith(e) : e.endsWith("/*") ? r.startsWith(e.slice(0, -1)) : r && r === e ? !0 : !r && (F[e] || []).some((e) => i.endsWith(e)));
2558
+ return n.some((e) => e.startsWith(".") ? i.endsWith(e) : e.endsWith("/*") ? r.startsWith(e.slice(0, -1)) : r && r === e ? !0 : !r && (q[e] || []).some((e) => i.endsWith(e)));
2097
2559
  }
2098
- function B(e, t = {}) {
2560
+ function ne(e, t = {}) {
2099
2561
  if (!e) return null;
2100
- let n = t.accept === void 0 ? N : t.accept, r = t.maxSizeMb || 5;
2101
- return z(e, n) ? e.size > r * 1024 * 1024 ? `Keep the file under ${r} MB.` : null : `Choose a ${R(n)} file.`;
2562
+ let n = t.accept === void 0 ? K : t.accept, r = t.maxSizeMb || 5;
2563
+ return Z(e, n) ? e.size > r * 1024 * 1024 ? `Keep the file under ${r} MB.` : null : `Choose a ${X(n)} file.`;
2102
2564
  }
2103
2565
  //#endregion
2104
2566
  //#region src/index.js
2105
- var V = (e, t) => {
2567
+ var Q = (e, t) => {
2106
2568
  typeof customElements < "u" && !customElements.get(e) && customElements.define(e, t);
2107
2569
  };
2108
- function H() {
2109
- V("wui-select", j), V("wui-phone", k), V("wui-datepicker", y), V("wui-autocomplete", u), V("wui-multiselect", b), V("wui-otp", T), V("wui-status-icon", n);
2570
+ function $() {
2571
+ Q("wui-select", W), Q("wui-phone", H), Q("wui-datepicker", w), Q("wui-date-range", N), Q("wui-autocomplete", p), Q("wui-multiselect", P), Q("wui-otp", R), Q("wui-status-icon", n);
2110
2572
  }
2111
- H();
2573
+ $();
2112
2574
  //#endregion
2113
- export { N as DEFAULT_IMAGE_ACCEPT, P as DEFAULT_MAX_SIZE_MB, t as STATUS_TONES, u as WuiAutocomplete, y as WuiDatePicker, b as WuiMultiSelect, T as WuiOtp, k as WuiPhone, j as WuiSelect, n as WuiStatusIcon, R as acceptLabel, H as defineWeborityElements, z as matchesAccept, B as validateFile };
2575
+ export { K as DEFAULT_IMAGE_ACCEPT, te as DEFAULT_MAX_SIZE_MB, t as STATUS_TONES, p as WuiAutocomplete, w as WuiDatePicker, N as WuiDateRange, P as WuiMultiSelect, R as WuiOtp, H as WuiPhone, W as WuiSelect, n as WuiStatusIcon, X as acceptLabel, $ as defineWeborityElements, Z as matchesAccept, ne as validateFile };