@webority/ui-elements 0.33.0 → 0.35.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (65) hide show
  1. package/dist/WuiAutocomplete-ByxnwJNQ.js +283 -0
  2. package/dist/WuiCommandPalette-CtZ04JxZ.js +130 -0
  3. package/dist/WuiConsentBanner-oVe-jxCO.js +399 -0
  4. package/dist/WuiContextMenu-Bx_U2X3t.js +211 -0
  5. package/dist/WuiCountrySelect-CUAwKnL9.js +28 -0
  6. package/dist/WuiDatePicker-DkNbc-z7.js +325 -0
  7. package/dist/WuiDateRange-BocnVO6L.js +233 -0
  8. package/dist/WuiDock-BSDY9g8Q.js +57 -0
  9. package/dist/WuiImageCrop-1yaAONTk.js +462 -0
  10. package/dist/WuiMultiSelect-BrCGRNCt.js +416 -0
  11. package/dist/WuiOtp-D8-4Pqil.js +128 -0
  12. package/dist/WuiPhone-BvbhiP2r.js +731 -0
  13. package/dist/WuiSelect-BXrpiuXG.js +214 -0
  14. package/dist/WuiSlider-BcU0psYf.js +256 -0
  15. package/dist/WuiSortable-JjJqstSU.js +280 -0
  16. package/dist/WuiTagInput-D1ay3OcL.js +158 -0
  17. package/dist/WuiTimePicker-C7n-VFGt.js +370 -0
  18. package/dist/WuiTour-R5O9l--J.js +205 -0
  19. package/dist/WuiTree-Ds-8tNgs.js +393 -0
  20. package/dist/WuiWizardStep-BU5w9_Ds.js +221 -0
  21. package/dist/anchorOverlay-DluGZ8ef.js +23 -0
  22. package/dist/calendarMath-BAF2Jkg_.js +42 -0
  23. package/dist/countries-B-M_LTgS.js +1234 -0
  24. package/dist/elementBase-Bg1xpvup.js +9 -0
  25. package/dist/elements/autocomplete.js +6 -0
  26. package/dist/elements/command-palette.js +6 -0
  27. package/dist/elements/consent-banner.js +6 -0
  28. package/dist/elements/context-menu.js +6 -0
  29. package/dist/elements/country-select.js +6 -0
  30. package/dist/elements/date-range.js +6 -0
  31. package/dist/elements/datepicker.js +6 -0
  32. package/dist/elements/dock.js +6 -0
  33. package/dist/elements/image-crop.js +6 -0
  34. package/dist/elements/kanban.js +6 -0
  35. package/dist/elements/multiselect.js +6 -0
  36. package/dist/elements/otp.js +6 -0
  37. package/dist/elements/phone.js +6 -0
  38. package/dist/elements/select.js +6 -0
  39. package/dist/elements/slider.js +6 -0
  40. package/dist/elements/sortable.js +6 -0
  41. package/dist/elements/status-icon.js +6 -0
  42. package/dist/elements/taginput.js +6 -0
  43. package/dist/elements/timepicker.js +6 -0
  44. package/dist/elements/tour.js +6 -0
  45. package/dist/elements/tree.js +6 -0
  46. package/dist/elements/wizard.js +5 -0
  47. package/dist/{fileViewerMedia-BYBcznPT.js → fileViewerMedia-DPk_YcvC.js} +4 -0
  48. package/dist/formMirror-jGf5M4gk.js +29 -0
  49. package/dist/formatters-DusKbTyV.js +138 -0
  50. package/dist/helpers.js +5 -0
  51. package/dist/iconGlyphs.g-Cpg1BUHm.js +215 -0
  52. package/dist/kanban-BeVAItir.js +972 -0
  53. package/dist/listboxKeyNav-zts_8d5e.js +36 -0
  54. package/dist/optionLabel-Dn-I7zyp.js +16 -0
  55. package/dist/statusIcons-C3zjycpa.js +37 -0
  56. package/dist/textMatch-DEUjlkdy.js +27 -0
  57. package/dist/themeTransition-BpCuMnjk.js +589 -0
  58. package/dist/tokenCommit-VWz-2jEf.js +20 -0
  59. package/dist/ui-elements.global.js +118 -129
  60. package/dist/ui-elements.js +253 -8864
  61. package/dist/ui-file-viewer.global.js +1 -1
  62. package/dist/ui-file-viewer.js +6 -2
  63. package/dist/ui-phone.global.js +14 -0
  64. package/dist/wuiHttp-m0yQadwQ.js +117 -0
  65. package/package.json +28 -3
@@ -0,0 +1,416 @@
1
+ import { t as e } from "./elementBase-Bg1xpvup.js";
2
+ import { n as t, r as n, t as r } from "./anchorOverlay-DluGZ8ef.js";
3
+ import { n as i } from "./formMirror-jGf5M4gk.js";
4
+ import { t as a } from "./iconGlyphs.g-Cpg1BUHm.js";
5
+ import { n as o, t as s } from "./listboxKeyNav-zts_8d5e.js";
6
+ import { n as c, r as l, t as u } from "./optionLabel-Dn-I7zyp.js";
7
+ import { i as d, t as f } from "./tokenCommit-VWz-2jEf.js";
8
+ //#region src/WuiMultiSelect.js
9
+ var p = class extends e {
10
+ static formAssociated = !0;
11
+ _accessibleName() {
12
+ return this.getAttribute("aria-label") || this.getAttribute("placeholder") || "Select";
13
+ }
14
+ static get observedAttributes() {
15
+ return [
16
+ "placeholder",
17
+ "search-placeholder",
18
+ "searchable",
19
+ "disabled",
20
+ "icon",
21
+ "size",
22
+ "collapse-chips",
23
+ "aria-label",
24
+ "aria-invalid",
25
+ "allow-custom",
26
+ "custom-pattern",
27
+ "custom-invalid-message"
28
+ ];
29
+ }
30
+ constructor() {
31
+ super(), this._values = [], this._optionsProp = null, this._active = -1, this._typeahead = "", this._typeaheadTimer = null, this._customError = "";
32
+ try {
33
+ this._internals = this.attachInternals();
34
+ } catch {
35
+ this._internals = null;
36
+ }
37
+ }
38
+ connectedCallback() {
39
+ if (!this._rendered) {
40
+ if (!this._valuesInit && !this._optionsProp && !this._values.length) {
41
+ let e = this.getAttribute("value");
42
+ if (e != null && e !== "") this._values = e.split(",").map((e) => e.trim()).filter(Boolean);
43
+ else {
44
+ let e = [...this.querySelectorAll(":scope > wui-option[selected]")].map((e) => e.getAttribute("value") ?? e.textContent.trim());
45
+ e.length && (this._values = e.map(String));
46
+ }
47
+ }
48
+ this._valuesInit = !0, this._defaultCaptured ||= (this._defaultValues = this._values.slice(), !0), this.render();
49
+ return;
50
+ }
51
+ this._bindGlobal?.();
52
+ }
53
+ formResetCallback() {
54
+ this.values = (this._defaultValues || []).slice();
55
+ let e = this.querySelector("[data-input]");
56
+ e && (e.value = ""), this._setCustomError("");
57
+ }
58
+ attributeChangedCallback(e) {
59
+ if (e === "aria-invalid") {
60
+ this._syncInvalid();
61
+ return;
62
+ }
63
+ e === "custom-pattern" || e === "custom-invalid-message" || this._rendered && this.render();
64
+ }
65
+ _syncInvalid() {
66
+ let e = this.querySelector(".search-select-control");
67
+ e && (this.hasAttribute("aria-invalid") || this._customError ? e.setAttribute("aria-invalid", "true") : e.removeAttribute("aria-invalid"));
68
+ }
69
+ get values() {
70
+ return this._values.slice();
71
+ }
72
+ set values(e) {
73
+ this._values = Array.isArray(e) ? e.map(String) : [], i(this, this._values), this._rendered && (this._renderControl(), this._renderOptions(this._query()));
74
+ }
75
+ set options(e) {
76
+ if (this._optionsProp = Array.isArray(e) ? e : null, this._rendered && this._allowCustom) {
77
+ this._renderControl(), this._renderOptions(this._query());
78
+ return;
79
+ }
80
+ this.isConnected && this.render();
81
+ }
82
+ get options() {
83
+ return this._readOptions();
84
+ }
85
+ get validateCustom() {
86
+ return this._validateCustom ?? null;
87
+ }
88
+ set validateCustom(e) {
89
+ this._validateCustom = typeof e == "function" ? e : null;
90
+ }
91
+ get _allowCustom() {
92
+ return this.hasAttribute("allow-custom");
93
+ }
94
+ _query() {
95
+ let e = this.querySelector(this._allowCustom ? "[data-input]" : ".search-select-input");
96
+ return e ? e.value : "";
97
+ }
98
+ _snapshotDeclared() {
99
+ if (this._declared) return;
100
+ let e = [...this.querySelectorAll(":scope > wui-option")];
101
+ e.length && (this._declared = e.map((e) => {
102
+ let t = {
103
+ value: e.getAttribute("value") ?? e.textContent.trim(),
104
+ label: e.innerHTML,
105
+ icon: e.getAttribute("icon") || void 0,
106
+ [u]: !0,
107
+ selected: e.hasAttribute("selected")
108
+ };
109
+ for (let [n, r] of h) {
110
+ let i = e.getAttribute(n);
111
+ i && (t[r] = i);
112
+ }
113
+ return e.hasAttribute("disabled") && (t.disabled = !0), t;
114
+ }));
115
+ }
116
+ _readOptions() {
117
+ return this._optionsProp ? this._optionsProp : (this._snapshotDeclared(), this._declared || []);
118
+ }
119
+ _labelFor(e) {
120
+ let t = this._readOptions().find((t) => String(t.value) === String(e));
121
+ return t ? t.label : e;
122
+ }
123
+ _labelHtmlFor(e) {
124
+ let t = this._readOptions().find((t) => String(t.value) === String(e));
125
+ return t ? l(t) : c(e);
126
+ }
127
+ render() {
128
+ this._snapshotDeclared();
129
+ let e = this._allowCustom, t = this.hasAttribute("searchable") && !e, n = this.getAttribute("search-placeholder") || "Search…", r = this.getAttribute("icon"), o = this.getAttribute("size"), s = o === "sm" ? " search-select-sm" : o === "lg" ? " search-select-lg" : "";
130
+ i(this, this._values), this.id ||= `wui-multiselect-${Math.random().toString(36).slice(2, 9)}`;
131
+ let c = `${this.id}-listbox`;
132
+ this._listboxId = c;
133
+ let l = this.hasAttribute("disabled");
134
+ if (e) {
135
+ let e = `${this.id}-custom-error`;
136
+ this.innerHTML = `
137
+ <div class="search-select${s}">
138
+ <div class="input search-select-control search-select-multi"${this.hasAttribute("aria-invalid") ? " aria-invalid=\"true\"" : ""}${l ? " aria-disabled=\"true\"" : ""}>
139
+ ${r ? a(r, { className: "search-select-icon" }) : ""}
140
+ <div class="ms-chips" data-chips><input type="text" class="ms-input" data-input role="combobox" aria-autocomplete="list" aria-haspopup="listbox" aria-expanded="false" aria-controls="${S(c)}" aria-label="${S(this._accessibleName())}" aria-describedby="${S(e)}" autocomplete="off"${l ? " disabled" : ""} /></div>
141
+ ${a("chevron-down", { className: "search-select-caret" })}
142
+ </div>
143
+ <div class="search-select-menu search-select-menu-fixed" role="listbox" id="${S(c)}" aria-multiselectable="true" tabindex="-1" hidden>
144
+ <div class="search-select-options"></div>
145
+ </div>
146
+ </div>
147
+ <div class="field-error wui-ms-custom-error" id="${S(e)}" aria-live="polite" hidden></div>`;
148
+ } else this.innerHTML = `
149
+ <div class="search-select${s}">
150
+ <div class="input search-select-control search-select-multi" role="combobox" aria-haspopup="listbox" aria-expanded="false" aria-controls="${S(c)}" aria-label="${S(this._accessibleName())}"${this.hasAttribute("aria-invalid") ? " aria-invalid=\"true\"" : ""}${l ? " aria-disabled=\"true\"" : " tabindex=\"0\""}>
151
+ ${r ? a(r, { className: "search-select-icon" }) : ""}
152
+ <div class="ms-chips" data-chips></div>
153
+ ${a("chevron-down", { className: "search-select-caret" })}
154
+ </div>
155
+ <div class="search-select-menu search-select-menu-fixed" role="listbox" id="${S(c)}" aria-multiselectable="true" tabindex="-1" hidden>
156
+ ${t ? `<div class="search-select-search">${a("search")}<input class="search-select-input" placeholder="${S(n)}" aria-autocomplete="list" /><button type="button" class="search-select-clear" aria-label="Clear search" hidden>${a("x")}</button></div>` : ""}
157
+ <div class="search-select-options"></div>
158
+ <div class="search-select-empty" hidden>No matches</div>
159
+ </div>
160
+ </div>`;
161
+ this._rendered = !0, this._customError = "", i(this, this._values), this._renderControl(), this._renderOptions(), this._wire();
162
+ }
163
+ _renderControl() {
164
+ let e = this.querySelector("[data-chips]");
165
+ if (!e) return;
166
+ let t = this.getAttribute("placeholder") || "Select…", n = this._allowCustom ? e.querySelector("[data-input]") : null, r = 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="${S(e)}" aria-label="Remove ${S(C(this._labelFor(e)))}">${a("x")}</button></span>`).join("");
167
+ if (n) {
168
+ for (let t of [...e.querySelectorAll(":scope > .chip")]) t.remove();
169
+ n.insertAdjacentHTML("beforebegin", r), n.placeholder = this._values.length ? "" : t, this._collapseChips();
170
+ return;
171
+ }
172
+ if (!this._values.length) {
173
+ e.innerHTML = `<span class="search-select-placeholder">${c(t)}</span>`;
174
+ return;
175
+ }
176
+ e.innerHTML = r, this._collapseChips();
177
+ }
178
+ _collapseChips() {
179
+ let e = this.querySelector("[data-chips]");
180
+ if (!e || !this.hasAttribute("collapse-chips") || !this._values.length) return;
181
+ e.querySelector(".chip-more")?.remove();
182
+ let t = [...e.querySelectorAll(":scope > .chip:not(.chip-more)")];
183
+ for (let e of t) e.style.display = "";
184
+ if (!t.length) return;
185
+ let n = e.clientWidth, r = (e) => e.offsetLeft + e.offsetWidth;
186
+ if (r(t[t.length - 1]) <= n) return;
187
+ let i = document.createElement("span");
188
+ i.className = "chip chip-sm chip-more", i.textContent = `+${t.length}`, t[t.length - 1].after(i);
189
+ let a = i.offsetWidth + 6, o = 0;
190
+ for (let e of t) if (r(e) <= n - a) o += 1;
191
+ else break;
192
+ o < 1 && (o = 1);
193
+ for (let e = o; e < t.length; e += 1) t[e].style.display = "none";
194
+ i.textContent = `+${t.length - o}`;
195
+ }
196
+ _matches(e, t) {
197
+ return C(e.label).toLowerCase().includes(t) || String(e.description ?? "").toLowerCase().includes(t);
198
+ }
199
+ _optionNamed(e) {
200
+ let t = e.trim().toLowerCase();
201
+ return this._readOptions().find((e) => String(e.value ?? "").toLowerCase() === t || C(e.label).trim().toLowerCase() === t);
202
+ }
203
+ _renderOptions(e) {
204
+ let t = this.querySelector(".search-select-options"), n = this.querySelector(".search-select-empty");
205
+ if (!t) return;
206
+ let r = (e || "").trim(), i = r.toLowerCase(), o = this._readOptions();
207
+ i && (o = o.filter((e) => this._matches(e, i)));
208
+ let s = this._listboxId || `${this.id || "wui-multiselect"}-listbox`, u = this._allowCustom && r && !this._optionNamed(r), d = o.map((e, t) => {
209
+ let n = this._values.includes(String(e.value)), r = `${s}-opt-${t}`;
210
+ return g(e) ? y(e, r, n) : `<button type="button" role="option" id="${S(r)}" class="search-select-option${n ? " selected" : ""}" data-value="${S(e.value)}" aria-selected="${n}"><span class="ms-opt-label">${l(e)}</span><span class="ms-check">${a("check")}</span></button>`;
211
+ });
212
+ u && d.push(`<button type="button" role="option" id="${S(`${s}-opt-${o.length}`)}" class="search-select-option search-select-option-custom" data-value="${S(r)}" data-custom="true" aria-selected="false">Add “${c(r)}”</button>`), t.innerHTML = d.join(""), n && (n.hidden = o.length > 0), this._active = -1, this._combobox()?.removeAttribute("aria-activedescendant"), this._allowCustom && this._syncCustomMenu?.(), this._reanchor?.();
213
+ }
214
+ _combobox() {
215
+ return this._allowCustom ? this.querySelector("[data-input]") : this.querySelector(".search-select-control");
216
+ }
217
+ _setCustomError(e) {
218
+ this._customError = e || "";
219
+ let t = this.querySelector(".wui-ms-custom-error"), n = this.querySelector("[data-input]");
220
+ t && (t.textContent = this._customError, t.hidden = !this._customError), n && (this._customError ? n.setAttribute("aria-invalid", "true") : n.removeAttribute("aria-invalid")), this._syncInvalid();
221
+ }
222
+ _customRefusal(e) {
223
+ let t = this.getAttribute("custom-invalid-message") || "Enter a valid value.", n = this.getAttribute("custom-pattern");
224
+ if (n) {
225
+ let r = x(n);
226
+ if (r && !r.test(e)) return t;
227
+ }
228
+ let r = this._validateCustom;
229
+ if (r) {
230
+ let n = r(e);
231
+ return n === !0 ? "" : typeof n == "string" && n ? n : t;
232
+ }
233
+ return "";
234
+ }
235
+ _commitTyped(e) {
236
+ let t = e.trim().replace(/,+$/, "").trim();
237
+ if (!t) return "";
238
+ let n = this._optionNamed(t), r;
239
+ if (n) {
240
+ if (n.disabled) return n.disabledHint || this.getAttribute("custom-invalid-message") || "That option is not available.";
241
+ r = String(n.value);
242
+ } else {
243
+ let e = this._customRefusal(t);
244
+ if (e) return e;
245
+ r = t;
246
+ }
247
+ let i = r.toLowerCase();
248
+ return this._values.some((e) => e.toLowerCase() === i) || (this._values = [...this._values, r]), "";
249
+ }
250
+ _wire() {
251
+ this._teardown();
252
+ let e = this.querySelector(".search-select-control"), a = this.querySelector(".search-select-menu"), c = this.querySelector(".search-select-input"), l = this.querySelector(".search-select-clear"), u = this.querySelector(".search-select-options"), p = this._allowCustom, h = p ? this.querySelector("[data-input]") : null, g = h || e;
253
+ if (!e || !a) return;
254
+ let _ = () => this.hasAttribute("disabled"), v = () => r(e, a, { matchWidth: !0 }), y = () => [...this.querySelectorAll(".search-select-option")], b = () => y().filter((e) => !e.hidden), x = (e, { reveal: t = !0 } = {}) => {
255
+ let n = b();
256
+ this._active = e, o(u, e >= 0 && n[e] || null), e >= 0 && n[e] ? (t && n[e].scrollIntoView({ block: "nearest" }), g.setAttribute("aria-activedescendant", n[e].id)) : g.removeAttribute("aria-activedescendant");
257
+ }, S = !1, C = () => p ? S : !a.hidden, w = () => {
258
+ let t = S && y().length > 0, n = a.hidden;
259
+ a.hidden = !t, g.setAttribute("aria-expanded", String(t)), e.classList.toggle("open", t), t && n && v();
260
+ };
261
+ this._syncCustomMenu = p ? w : null;
262
+ let T = () => {
263
+ C() && v();
264
+ }, E = () => {
265
+ if (!_()) {
266
+ if (t(this, T), p) {
267
+ S = !0, w();
268
+ return;
269
+ }
270
+ a.hidden = !1, e.setAttribute("aria-expanded", "true"), e.classList.add("open"), v(), c && (c.value = "", this._renderOptions(""), c.focus());
271
+ }
272
+ }, D = () => {
273
+ p ? (S = !1, w()) : (a.hidden = !0, e.setAttribute("aria-expanded", "false"), e.classList.remove("open")), x(-1), clearTimeout(this._typeaheadTimer), this._typeaheadTimer = null, this._typeahead = "", n(this);
274
+ }, O = () => {
275
+ i(this, this._values), this.dispatchEvent(new Event("change", { bubbles: !0 }));
276
+ }, k = (e) => {
277
+ let t = String(e);
278
+ if (this._values.includes(t)) this._values = this._values.filter((e) => e !== t);
279
+ else if (p && this._values.some((e) => e.toLowerCase() === t.toLowerCase())) return;
280
+ else this._values = [...this._values, t];
281
+ this._renderControl(), this._renderOptions(this._query()), O();
282
+ }, A = (e) => {
283
+ this._values = this._values.filter((t) => t !== String(e)), this._renderControl(), this._renderOptions(this._query()), O();
284
+ }, j = (e, { quiet: t = !1 } = {}) => {
285
+ let n = this._values.length, r = f(e, m) ? d(e, m) : [e], i = [], a = "";
286
+ for (let e of r) {
287
+ let t = this._commitTyped(e);
288
+ t && (i.push(e.trim()), a ||= t);
289
+ }
290
+ t && i.length || (h.value = i.join(", "), this._setCustomError(a), this._values.length !== n && (this._renderControl(), O()), this._renderOptions(h.value));
291
+ }, M = (e) => {
292
+ if (!(!e || e.getAttribute("aria-disabled") === "true")) {
293
+ if (e.dataset.custom === "true") {
294
+ j(e.dataset.value);
295
+ return;
296
+ }
297
+ k(e.dataset.value), h?.value && (h.value = "", this._setCustomError(""), this._renderOptions(""));
298
+ }
299
+ };
300
+ e.addEventListener("click", (e) => {
301
+ if (_()) return;
302
+ let t = e.target.closest("[data-remove]");
303
+ if (t) {
304
+ e.stopPropagation(), A(t.dataset.remove), h?.focus();
305
+ return;
306
+ }
307
+ if (h) {
308
+ let t = C();
309
+ e.target !== h && h.focus(), e.target === h || !t ? E() : D();
310
+ return;
311
+ }
312
+ C() ? D() : E();
313
+ }), u.addEventListener("click", (e) => {
314
+ let t = e.target.closest(".search-select-option");
315
+ t && (M(t), (h || c)?.focus());
316
+ }), u.addEventListener("mousemove", (e) => {
317
+ let t = e.target.closest(".search-select-option");
318
+ t && !t.classList.contains("is-active") && x(b().indexOf(t), { reveal: !1 });
319
+ }), u.addEventListener("mouseleave", () => x(-1)), u.addEventListener("error", (e) => {
320
+ e.target?.classList?.contains("avatar-img") && e.target.remove();
321
+ }, !0), c?.addEventListener("input", () => {
322
+ this._renderOptions(c.value), l && (l.hidden = !c.value), x(-1);
323
+ }), this._navHandler = s({
324
+ getVisibleOptions: b,
325
+ getActive: () => this._active,
326
+ setActive: (e) => x(e),
327
+ onEnter: (e) => {
328
+ e ? M(e) : h?.value.trim() && j(h.value);
329
+ },
330
+ onEscape: () => {
331
+ this._navHandler.clearTypeahead(), D(), h || e.focus();
332
+ }
333
+ });
334
+ let N = (e) => {
335
+ let t = h || c;
336
+ if (e.key === "Backspace" && !t?.value && this._values.length) {
337
+ A(this._values[this._values.length - 1]);
338
+ return;
339
+ }
340
+ this._navHandler.handler(e);
341
+ };
342
+ if (c?.addEventListener("keydown", N), l?.addEventListener("click", () => {
343
+ c.value = "", this._renderOptions(""), l.hidden = !0, c.focus();
344
+ }), h) {
345
+ let t = (e) => {
346
+ e.target !== h && e.preventDefault();
347
+ };
348
+ u.addEventListener("mousedown", t), e.addEventListener("mousedown", t), h.addEventListener("focus", () => E()), h.addEventListener("input", () => {
349
+ this._customError && this._setCustomError(""), this._renderOptions(h.value), E();
350
+ }), h.addEventListener("keydown", (e) => {
351
+ if (e.key === "," && h.value.trim()) {
352
+ e.preventDefault(), j(h.value);
353
+ return;
354
+ }
355
+ if (e.key === "Enter") {
356
+ if (this._active < 0 && !h.value.trim()) return;
357
+ this._navHandler.handler(e);
358
+ return;
359
+ }
360
+ (e.key === "ArrowDown" || e.key === "ArrowUp") && !C() && E(), N(e);
361
+ }), h.addEventListener("paste", (e) => {
362
+ let t = e.clipboardData?.getData("text/plain") ?? "";
363
+ f(t, m) && (e.preventDefault(), j(`${h.value}${t}`));
364
+ }), h.addEventListener("blur", (e) => {
365
+ e.relatedTarget && this.contains(e.relatedTarget) || (h.value.trim() && j(h.value, { quiet: !0 }), D());
366
+ });
367
+ } else e.addEventListener("keydown", (e) => {
368
+ if (C()) {
369
+ N(e);
370
+ return;
371
+ }
372
+ (e.key === "ArrowDown" || e.key === "Enter" || e.key === " ") && (e.preventDefault(), E());
373
+ });
374
+ this._bindGlobal = () => {
375
+ this._teardown(), !this._ro && typeof ResizeObserver < "u" && (this._ro = new ResizeObserver(() => this._collapseChips()), this._ro.observe(this)), this._onDocClick = (e) => {
376
+ C() && !this.contains(e.target) && D();
377
+ }, document.addEventListener("click", this._onDocClick), C() && t(this, T);
378
+ }, this._bindGlobal();
379
+ }
380
+ _teardown() {
381
+ this._onDocClick &&= (document.removeEventListener("click", this._onDocClick), null), n(this), this._navHandler?.teardown();
382
+ }
383
+ disconnectedCallback() {
384
+ this._teardown(), this._ro?.disconnect(), this._ro = null;
385
+ }
386
+ }, m = [
387
+ ",",
388
+ ";",
389
+ "\n",
390
+ " "
391
+ ], h = [
392
+ ["description", "description"],
393
+ ["avatar", "avatar"],
394
+ ["initials", "initials"],
395
+ ["disabled-hint", "disabledHint"]
396
+ ], g = (e) => !!(e.description || e.avatar || e.initials || e.disabled || e.disabledHint), _ = (e) => {
397
+ let t = String(e ?? "").trim();
398
+ return /^(https?:)?\/\//i.test(t) || /^\/(?!\/)/.test(t) || /^data:image\/(png|jpe?g|gif|webp|avif);/i.test(t) ? t : "";
399
+ }, v = (e) => {
400
+ let t = _(e.avatar);
401
+ return !t && !e.initials ? "" : `<span class="avatar wui-opt-avatar" aria-hidden="true"><span class="avatar-face">${c(e.initials ?? "")}</span>${t ? `<img class="avatar-img" src="${S(t)}" alt="" />` : ""}</span>`;
402
+ }, y = (e, t, n) => {
403
+ let r = !!e.disabled, i = e.description ? `<span class="wui-opt-desc">${c(e.description)}</span>` : "", o = e.disabledHint && r ? `<span class="wui-opt-hint">${c(e.disabledHint)}</span>` : "";
404
+ return `<button type="button" role="option" id="${S(t)}" class="search-select-option wui-opt-rich${n ? " selected" : ""}" data-value="${S(e.value)}" aria-selected="${n}"${r ? " aria-disabled=\"true\"" : ""}><span class="ms-opt-label"><span class="wui-opt-name">${l(e)}</span>${i}</span>${o}${v(e)}<span class="ms-check">${a("check")}</span></button>`;
405
+ }, b = /* @__PURE__ */ new Map(), x = (e) => {
406
+ if (b.has(e)) return b.get(e);
407
+ let t = null;
408
+ try {
409
+ t = RegExp(`^(?:${e})$`, "u");
410
+ } catch {
411
+ console.warn(`<wui-multiselect> custom-pattern is not a valid regular expression and is ignored: ${e}`);
412
+ }
413
+ return b.set(e, t), t;
414
+ }, S = (e) => String(e ?? "").replace(/&/g, "&amp;").replace(/"/g, "&quot;").replace(/</g, "&lt;"), C = (e) => String(e ?? "").replace(/<[^>]*>/g, "");
415
+ //#endregion
416
+ export { p as t };
@@ -0,0 +1,128 @@
1
+ import { t as e } from "./elementBase-Bg1xpvup.js";
2
+ import { t } from "./formMirror-jGf5M4gk.js";
3
+ //#region src/WuiOtp.js
4
+ var n = /[^0-9]/g, r = /[^0-9a-zA-Z]/g, i = class extends e {
5
+ static formAssociated = !0;
6
+ static get observedAttributes() {
7
+ return [
8
+ "value",
9
+ "length",
10
+ "mode",
11
+ "disabled",
12
+ "aria-label"
13
+ ];
14
+ }
15
+ get length() {
16
+ let e = Number.parseInt(this.getAttribute("length") ?? "6", 10);
17
+ return Number.isFinite(e) && e > 0 ? e : 6;
18
+ }
19
+ set length(e) {
20
+ this.setAttribute("length", String(e));
21
+ }
22
+ get mode() {
23
+ return this.getAttribute("mode") === "alphanumeric" ? "alphanumeric" : "numeric";
24
+ }
25
+ set mode(e) {
26
+ this.setAttribute("mode", String(e ?? "numeric"));
27
+ }
28
+ get value() {
29
+ return this._value ?? "";
30
+ }
31
+ set value(e) {
32
+ this._value = this._clean(e), t(this, this._value), this._paint();
33
+ }
34
+ _clean(e) {
35
+ return (e == null ? "" : String(e)).replace(this.mode === "alphanumeric" ? r : n, "").slice(0, this.length);
36
+ }
37
+ constructor() {
38
+ super();
39
+ try {
40
+ this._internals = this.attachInternals();
41
+ } catch {
42
+ this._internals = null;
43
+ }
44
+ }
45
+ connectedCallback() {
46
+ this._rendered ? this._onSelectionChange && document.addEventListener("selectionchange", this._onSelectionChange) : (this._defaultCaptured ||= (this._defaultValue = this._value, !0), this.render());
47
+ }
48
+ formResetCallback() {
49
+ this._value = this._defaultValue || "", t(this, this._value), this._paint();
50
+ }
51
+ attributeChangedCallback(e, n, r) {
52
+ this._rendered && (e === "value" ? (this._value = this._clean(r), t(this, this._value), this._paint()) : this.render());
53
+ }
54
+ render() {
55
+ this._value = this._clean(this.getAttribute("value") ?? this._value);
56
+ let e = this.length, n = this.mode === "numeric", r = this.hasAttribute("disabled"), i = Array.from({ length: e }, () => "<span class=\"otp-slot\" aria-hidden=\"true\"></span>").join(""), a = this.getAttribute("aria-label"), o = a ? ` aria-label="${a.replace(/"/g, "&quot;")}"` : "";
57
+ this.innerHTML = `
58
+ <div class="otp">
59
+ <input
60
+ class="otp-field"
61
+ type="text"
62
+ autocomplete="one-time-code"
63
+ inputmode="${n ? "numeric" : "text"}"
64
+ ${n ? "pattern=\"[0-9]*\"" : ""}${o}
65
+ autocapitalize="off"
66
+ autocorrect="off"
67
+ spellcheck="false"
68
+ ${r ? "disabled" : ""} />
69
+ <div class="otp-slots" aria-hidden="true">${i}</div>
70
+ </div>`, this._rendered = !0, t(this, this._value), this._wire(), this._paint();
71
+ }
72
+ _refs() {
73
+ return {
74
+ input: this.querySelector(".otp-field"),
75
+ slots: [...this.querySelectorAll(".otp-slot")]
76
+ };
77
+ }
78
+ _paint() {
79
+ let { input: e, slots: t } = this._refs();
80
+ if (!e || !t.length) return;
81
+ e.value !== this._value && (e.value = this._value);
82
+ let n = e.selectionStart ?? this._value.length, r = Math.min(n, t.length - 1), i = document.activeElement === e;
83
+ t.forEach((e, t) => {
84
+ e.textContent = this._value[t] ?? "", e.classList.toggle("filled", !!this._value[t]), e.classList.toggle("active", i && t === r);
85
+ });
86
+ }
87
+ _wire() {
88
+ let { input: e } = this._refs();
89
+ if (!e) return;
90
+ let n = (e) => {
91
+ let n = this._clean(e), r = n !== this._value;
92
+ this._value = n, t(this, this._value), this._paint(), r && this.dispatchEvent(new Event("change", { bubbles: !0 })), r && n.length === this.length && this.dispatchEvent(new CustomEvent("complete", {
93
+ bubbles: !0,
94
+ detail: n
95
+ }));
96
+ };
97
+ e.addEventListener("input", () => {
98
+ let t = e.value;
99
+ if (this._value.length === this.length && t.length > this._value.length && t.startsWith(this._value)) {
100
+ let e = this._clean(t.slice(this._value.length));
101
+ if (e) {
102
+ n(e);
103
+ return;
104
+ }
105
+ }
106
+ n(t);
107
+ }), e.addEventListener("paste", (e) => {
108
+ let t = e.clipboardData?.getData("text");
109
+ t != null && (e.preventDefault(), n(t));
110
+ });
111
+ for (let t of [
112
+ "keyup",
113
+ "click",
114
+ "blur",
115
+ "select"
116
+ ]) e.addEventListener(t, () => this._paint());
117
+ e.addEventListener("focus", () => {
118
+ this._value.length === this.length && e.select(), this._paint();
119
+ }), this._onSelectionChange && document.removeEventListener("selectionchange", this._onSelectionChange), this._onSelectionChange = () => {
120
+ document.activeElement === e && this._paint();
121
+ }, document.addEventListener("selectionchange", this._onSelectionChange);
122
+ }
123
+ disconnectedCallback() {
124
+ this._onSelectionChange && document.removeEventListener("selectionchange", this._onSelectionChange);
125
+ }
126
+ };
127
+ //#endregion
128
+ export { i as t };