@webority/ui-elements 0.36.0 → 0.38.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 (116) hide show
  1. package/dist/WuiAutocomplete-Comrnbmf.js +13 -0
  2. package/dist/WuiCommandPalette-CKna1GlO.js +2 -0
  3. package/dist/WuiConsentBanner-CFll7vxN.js +201 -0
  4. package/dist/WuiContextMenu-CBy0O4HT.js +1 -0
  5. package/dist/WuiCountrySelect-oLBUHvMM.js +1 -0
  6. package/dist/WuiDatePicker-nB1B3eWW.js +31 -0
  7. package/dist/WuiDateRange-Di5YE9mg.js +25 -0
  8. package/dist/WuiDock-BD2HgMmP.js +1 -0
  9. package/dist/WuiImageCrop-Cr3D2iPo.js +17 -0
  10. package/dist/WuiMultiSelect-BUw-7apM.js +25 -0
  11. package/dist/WuiOtp-BbO_75RB.js +14 -0
  12. package/dist/WuiPhone-GJglNelp.js +15 -0
  13. package/dist/WuiSelect-DvtN4qC2.js +14 -0
  14. package/dist/WuiSlider-Br6V2amU.js +49 -0
  15. package/dist/WuiSortable-Bd7Fz5Ox.js +1 -0
  16. package/dist/WuiTagInput-DzEZooIn.js +6 -0
  17. package/dist/WuiTimePicker-Bolpp93P.js +9 -0
  18. package/dist/WuiTour-DiKZEWeb.js +15 -0
  19. package/dist/WuiTree-SA0QU9AF.js +1 -0
  20. package/dist/WuiWizardStep-DIHxrXn9.js +1 -0
  21. package/dist/anchorOverlay-WcDeH46q.js +1 -0
  22. package/dist/calendarMath-BC2wGCD-.js +1 -0
  23. package/dist/countries-CvmZ2xpG.js +1 -0
  24. package/dist/elementBase-BlsR4tqa.js +1 -0
  25. package/dist/elements/autocomplete.js +1 -6
  26. package/dist/elements/command-palette.js +1 -6
  27. package/dist/elements/consent-banner.js +1 -6
  28. package/dist/elements/context-menu.js +1 -6
  29. package/dist/elements/country-select.js +1 -6
  30. package/dist/elements/date-range.js +1 -6
  31. package/dist/elements/datepicker.js +1 -6
  32. package/dist/elements/dock.js +1 -6
  33. package/dist/elements/image-crop.js +1 -6
  34. package/dist/elements/kanban.js +1 -6
  35. package/dist/elements/multiselect.js +1 -6
  36. package/dist/elements/otp.js +1 -6
  37. package/dist/elements/phone.js +1 -6
  38. package/dist/elements/select.js +1 -6
  39. package/dist/elements/slider.js +1 -6
  40. package/dist/elements/sortable.js +1 -6
  41. package/dist/elements/status-icon.js +1 -6
  42. package/dist/elements/taginput.js +1 -6
  43. package/dist/elements/timepicker.js +1 -6
  44. package/dist/elements/tour.js +1 -6
  45. package/dist/elements/tree.js +1 -6
  46. package/dist/elements/wizard.js +1 -5
  47. package/dist/examples.mobile.json-GS1_MGh9.js +1 -0
  48. package/dist/fileViewerImage-Y9QBn2Rj.js +6 -0
  49. package/dist/fileViewerMedia-CaJaVnjE.js +1 -0
  50. package/dist/fileViewerPdf-BN0zuehw.js +19 -0
  51. package/dist/fileViewerUi-DasgDsU-.js +1 -0
  52. package/dist/focusOrigin-2imUSs-u.js +1 -0
  53. package/dist/formMirror-BgY7zkC3.js +1 -0
  54. package/dist/formatters-BAE__8ye.js +1 -0
  55. package/dist/helpers.js +1 -5
  56. package/dist/iconGlyphs.g-CUm_mfze.js +1 -0
  57. package/dist/kanban-CdELdS3U.js +1 -0
  58. package/dist/listboxKeyNav-DMIvs9d6.js +1 -0
  59. package/dist/max-CNrKnpEj.js +17 -0
  60. package/dist/optionLabel-DsX2fhWs.js +1 -0
  61. package/dist/statusIcons-2X4iGkKL.js +10 -0
  62. package/dist/textMatch-wdY7XLIc.js +1 -0
  63. package/dist/themeTransition-lkmQm8FR.js +1 -0
  64. package/dist/tokenCommit-BKckxgtg.js +2 -0
  65. package/dist/ui-calendar.global.js +1 -1
  66. package/dist/ui-calendar.js +1 -9905
  67. package/dist/ui-chart.js +21 -34563
  68. package/dist/ui-chat-core.js +10 -347
  69. package/dist/ui-chat.js +10 -1066
  70. package/dist/ui-elements.global.js +52 -53
  71. package/dist/ui-elements.js +1 -692
  72. package/dist/ui-file-viewer.js +1 -311
  73. package/dist/ui-rich-text.js +193 -16887
  74. package/dist/wuiHttp-BC8co934.js +1 -0
  75. package/package.json +5 -7
  76. package/dist/WuiAutocomplete-ByxnwJNQ.js +0 -283
  77. package/dist/WuiCommandPalette-CtZ04JxZ.js +0 -130
  78. package/dist/WuiConsentBanner-oVe-jxCO.js +0 -399
  79. package/dist/WuiContextMenu-Bx_U2X3t.js +0 -211
  80. package/dist/WuiCountrySelect-CUAwKnL9.js +0 -28
  81. package/dist/WuiDatePicker-DkNbc-z7.js +0 -325
  82. package/dist/WuiDateRange-BocnVO6L.js +0 -233
  83. package/dist/WuiDock-BSDY9g8Q.js +0 -57
  84. package/dist/WuiImageCrop-1yaAONTk.js +0 -462
  85. package/dist/WuiMultiSelect-BrCGRNCt.js +0 -416
  86. package/dist/WuiOtp-D8-4Pqil.js +0 -128
  87. package/dist/WuiPhone-BvbhiP2r.js +0 -731
  88. package/dist/WuiSelect-BXrpiuXG.js +0 -214
  89. package/dist/WuiSlider-BcU0psYf.js +0 -256
  90. package/dist/WuiSortable-JjJqstSU.js +0 -280
  91. package/dist/WuiTagInput-D1ay3OcL.js +0 -158
  92. package/dist/WuiTimePicker-C7n-VFGt.js +0 -370
  93. package/dist/WuiTour-R5O9l--J.js +0 -205
  94. package/dist/WuiTree-DXP7pGeI.js +0 -393
  95. package/dist/WuiWizardStep-BU5w9_Ds.js +0 -221
  96. package/dist/anchorOverlay-DluGZ8ef.js +0 -23
  97. package/dist/calendarMath-BAF2Jkg_.js +0 -42
  98. package/dist/countries-B-M_LTgS.js +0 -1234
  99. package/dist/elementBase-Bg1xpvup.js +0 -9
  100. package/dist/examples.mobile.json-BMXTGiGC.js +0 -250
  101. package/dist/fileViewerImage-Dky4nQZS.js +0 -185
  102. package/dist/fileViewerMedia-DPk_YcvC.js +0 -133
  103. package/dist/fileViewerPdf-BnIsj-J-.js +0 -15799
  104. package/dist/fileViewerUi-R6hlcShk.js +0 -272
  105. package/dist/formMirror-jGf5M4gk.js +0 -29
  106. package/dist/formatters-DusKbTyV.js +0 -138
  107. package/dist/iconGlyphs.g-Cpg1BUHm.js +0 -215
  108. package/dist/kanban-BIiEMkTK.js +0 -985
  109. package/dist/listboxKeyNav-zts_8d5e.js +0 -36
  110. package/dist/max-BDKx469G.js +0 -14478
  111. package/dist/optionLabel-Dn-I7zyp.js +0 -16
  112. package/dist/statusIcons-C3zjycpa.js +0 -37
  113. package/dist/textMatch-DEUjlkdy.js +0 -27
  114. package/dist/themeTransition-BpCuMnjk.js +0 -589
  115. package/dist/tokenCommit-VWz-2jEf.js +0 -20
  116. package/dist/wuiHttp-oeHs7X_c.js +0 -118
@@ -1,416 +0,0 @@
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 };
@@ -1,128 +0,0 @@
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 };