@webority/ui-elements 0.34.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 (62) 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/formMirror-jGf5M4gk.js +29 -0
  48. package/dist/formatters-DusKbTyV.js +138 -0
  49. package/dist/helpers.js +5 -0
  50. package/dist/iconGlyphs.g-Cpg1BUHm.js +215 -0
  51. package/dist/kanban-BeVAItir.js +972 -0
  52. package/dist/listboxKeyNav-zts_8d5e.js +36 -0
  53. package/dist/optionLabel-Dn-I7zyp.js +16 -0
  54. package/dist/statusIcons-C3zjycpa.js +37 -0
  55. package/dist/textMatch-DEUjlkdy.js +27 -0
  56. package/dist/themeTransition-BpCuMnjk.js +589 -0
  57. package/dist/tokenCommit-VWz-2jEf.js +20 -0
  58. package/dist/ui-elements.global.js +118 -129
  59. package/dist/ui-elements.js +253 -8864
  60. package/dist/ui-phone.global.js +14 -0
  61. package/dist/wuiHttp-m0yQadwQ.js +117 -0
  62. package/package.json +28 -3
@@ -0,0 +1,393 @@
1
+ import { t as e } from "./elementBase-Bg1xpvup.js";
2
+ import { c as t } from "./wuiHttp-m0yQadwQ.js";
3
+ import { n, t as r } from "./formMirror-jGf5M4gk.js";
4
+ import { t as i } from "./iconGlyphs.g-Cpg1BUHm.js";
5
+ import { t as a } from "./listboxKeyNav-zts_8d5e.js";
6
+ //#region src/WuiTree.js
7
+ var o = [
8
+ "none",
9
+ "single",
10
+ "multiple"
11
+ ], s = "parentId", c = "Loading", l = "Could not load. Try again.", u = ":scope > input[data-wui-mirror]", d = [
12
+ "nodes",
13
+ "selection",
14
+ "selected",
15
+ "values",
16
+ "loadChildren",
17
+ "loadUrl",
18
+ "name"
19
+ ], f = 0;
20
+ function p(e, t, n) {
21
+ let r = document.createElement(e);
22
+ t && (r.className = t);
23
+ for (let [e, t] of Object.entries(n ?? {})) t != null && r.setAttribute(e, String(t));
24
+ return r;
25
+ }
26
+ var m = class extends e {
27
+ static get observedAttributes() {
28
+ return [
29
+ "selection",
30
+ "selected",
31
+ "name",
32
+ "aria-label",
33
+ "loading-text",
34
+ "error-text"
35
+ ];
36
+ }
37
+ constructor() {
38
+ super(), this._uid = `wui-tree-${++f}`, this._seq = 0, this._roots = [], this._byId = /* @__PURE__ */ new Map(), this._prev = null, this._staged = null, this._els = /* @__PURE__ */ new Map(), this._checked = /* @__PURE__ */ new Set(), this._selected = null, this._focusId = null, this._loader = null, this._list = null, this._live = null, this._ready = !1, this._nav = a({
39
+ getVisibleOptions: () => this._visible().map((e) => this._els.get(e.id)?.row),
40
+ getActive: () => this._visible().findIndex((e) => e.id === this._focusId),
41
+ setActive: (e) => this._focusNode(this._visible()[e]),
42
+ onEnter: () => {
43
+ let e = this._byId.get(this._focusId);
44
+ e && this._activate(e);
45
+ }
46
+ }), this._onKeyDown = (e) => this._handleKeyDown(e), this._onClick = (e) => this._handleClick(e), this._onFocusIn = (e) => {
47
+ let t = this._nodeFrom(e.target);
48
+ t && t.id !== this._focusId && this._setRoving(t);
49
+ };
50
+ }
51
+ connectedCallback() {
52
+ let e = {};
53
+ for (let t of d) Object.hasOwn(this, t) && (e[t] = this[t], delete this[t]);
54
+ if (!this._ready) {
55
+ this._ready = !0;
56
+ let e = this._readScript();
57
+ this.replaceChildren(), this._list = p("ul", "wui-tree"), this._list.setAttribute("role", "tree"), this._live = p("div", "visually-hidden", {
58
+ role: "status",
59
+ "aria-live": "polite"
60
+ }), this.append(this._list, this._live), e && this._adoptAll(e);
61
+ }
62
+ for (let [t, n] of Object.entries(e)) this[t] = n;
63
+ this.addEventListener("keydown", this._onKeyDown), this.addEventListener("click", this._onClick), this.addEventListener("focusin", this._onFocusIn), this._render(), this._loadOpenNodes();
64
+ }
65
+ disconnectedCallback() {
66
+ this.removeEventListener("keydown", this._onKeyDown), this.removeEventListener("click", this._onClick), this.removeEventListener("focusin", this._onFocusIn), this._nav.teardown();
67
+ }
68
+ attributeChangedCallback(e, t, n) {
69
+ e === "selected" && (this._selected = n), this._ready && this.isConnected && this._render();
70
+ }
71
+ get nodes() {
72
+ return this._roots.map((e) => e.raw);
73
+ }
74
+ set nodes(e) {
75
+ this._adoptAll(e ?? []), this._render(), this._loadOpenNodes();
76
+ }
77
+ get selection() {
78
+ let e = this.getAttribute("selection");
79
+ return o.includes(e) ? e : "none";
80
+ }
81
+ set selection(e) {
82
+ this.setAttribute("selection", String(e));
83
+ }
84
+ get selected() {
85
+ return this._selected;
86
+ }
87
+ set selected(e) {
88
+ this._selected = e == null ? null : String(e), this._render();
89
+ }
90
+ get values() {
91
+ let e = [], t = (n) => {
92
+ for (let r of n) this._state(r) === "checked" && e.push(r.id), r.children && t(r.children);
93
+ };
94
+ return t(this._roots), [...e, ...[...this._checked].filter((e) => !this._byId.has(e))];
95
+ }
96
+ set values(e) {
97
+ this._checked.clear();
98
+ for (let t of e ?? []) {
99
+ let e = this._byId.get(String(t));
100
+ e ? this._setChecked(e, !0) : this._checked.add(String(t));
101
+ }
102
+ this._render();
103
+ }
104
+ get loadChildren() {
105
+ return this._loader;
106
+ }
107
+ set loadChildren(e) {
108
+ this._loader = typeof e == "function" ? e : null;
109
+ }
110
+ get loadUrl() {
111
+ return this.getAttribute("load-url");
112
+ }
113
+ set loadUrl(e) {
114
+ e == null ? this.removeAttribute("load-url") : this.setAttribute("load-url", String(e));
115
+ }
116
+ get name() {
117
+ return this.getAttribute("name");
118
+ }
119
+ set name(e) {
120
+ e == null ? this.removeAttribute("name") : this.setAttribute("name", String(e));
121
+ }
122
+ get loadingText() {
123
+ return this.getAttribute("loading-text") ?? c;
124
+ }
125
+ set loadingText(e) {
126
+ this.setAttribute("loading-text", String(e ?? ""));
127
+ }
128
+ get errorText() {
129
+ return this.getAttribute("error-text") ?? l;
130
+ }
131
+ set errorText(e) {
132
+ this.setAttribute("error-text", String(e ?? ""));
133
+ }
134
+ _readScript() {
135
+ let e = this.querySelector(":scope > script[type='application/json']");
136
+ if (!e) return null;
137
+ try {
138
+ return JSON.parse(e.textContent);
139
+ } catch (e) {
140
+ return console.error("[@webority/ui-elements] <wui-tree> could not read its JSON nodes:", e?.message), null;
141
+ }
142
+ }
143
+ _adoptAll(e) {
144
+ let t = this._byId;
145
+ this._prev = t, this._byId = /* @__PURE__ */ new Map();
146
+ let n;
147
+ try {
148
+ n = this._adoptStaged(e, null, 1);
149
+ } catch (e) {
150
+ throw this._byId = t, e;
151
+ } finally {
152
+ this._prev = null;
153
+ }
154
+ this._roots = n;
155
+ for (let e of t.keys()) this._byId.has(e) || this._checked.delete(e);
156
+ for (let e of this._roots) this._passChecksDown(e);
157
+ this._focusId && !this._byId.has(this._focusId) && (this._focusId = null);
158
+ }
159
+ _adoptStaged(e, t, n) {
160
+ let r = [], i = [];
161
+ this._staged = {
162
+ ids: r,
163
+ checks: i
164
+ };
165
+ try {
166
+ let r = this._adopt(e, t, n);
167
+ for (let e of i) this._checked.add(e);
168
+ return r;
169
+ } catch (e) {
170
+ for (let e of r) this._byId.delete(e);
171
+ throw e;
172
+ } finally {
173
+ this._staged = null;
174
+ }
175
+ }
176
+ _adopt(e, t, n) {
177
+ if (!Array.isArray(e)) throw Error("<wui-tree> nodes must be an array.");
178
+ return e.map((e) => {
179
+ let r = e?.id == null ? "" : String(e.id);
180
+ if (!r) throw Error("<wui-tree> every node needs an id.");
181
+ if (this._byId.has(r)) throw Error(`<wui-tree> node id "${r}" is used twice.`);
182
+ let i = this._prev?.get(r), a = {
183
+ id: r,
184
+ raw: e,
185
+ parent: t,
186
+ level: n,
187
+ seq: ++this._seq,
188
+ label: e.label == null ? r : String(e.label),
189
+ icon: e.icon || null,
190
+ badge: e.badge == null || e.badge === "" ? null : String(e.badge),
191
+ badgeTone: e.badgeTone || null,
192
+ disabled: !!e.disabled,
193
+ hasChildren: !!e.hasChildren,
194
+ children: null,
195
+ expanded: i ? i.expanded : !!e.expanded,
196
+ loading: !1,
197
+ failed: !1
198
+ };
199
+ this._byId.set(r, a), this._staged.ids.push(r);
200
+ let o = e.children ?? (e.hasChildren ? i?.children?.map((e) => e.raw) : void 0);
201
+ return Array.isArray(o) && (a.children = this._adopt(o, a, n + 1)), a.loading = !!i?.loading && a.children === null && a.hasChildren, e.checked && !i && this._staged.checks.push(r), a;
202
+ });
203
+ }
204
+ _passChecksDown(e) {
205
+ e.children?.length && this._checked.has(e.id) && (this._checked.delete(e.id), this._setChecked(e, !0));
206
+ for (let t of e.children ?? []) this._passChecksDown(t);
207
+ }
208
+ _loadOpenNodes() {
209
+ queueMicrotask(() => {
210
+ if (this.isConnected) for (let e of [...this._byId.values()]) e.expanded && e.children === null && e.hasChildren && !e.loading && this._load(e);
211
+ });
212
+ }
213
+ _isBranch(e) {
214
+ return e.children ? e.children.length > 0 : e.hasChildren;
215
+ }
216
+ _visible() {
217
+ let e = [], t = (n) => {
218
+ for (let r of n) e.push(r), r.expanded && r.children && t(r.children);
219
+ };
220
+ return t(this._roots), e;
221
+ }
222
+ _state(e) {
223
+ if (e.children?.length) {
224
+ let t = 0, n = 0;
225
+ for (let r of e.children) {
226
+ let e = this._state(r);
227
+ e === "checked" ? t++ : e === "unchecked" && n++;
228
+ }
229
+ return t === e.children.length ? "checked" : n === e.children.length ? "unchecked" : "mixed";
230
+ }
231
+ return this._checked.has(e.id) ? "checked" : "unchecked";
232
+ }
233
+ _setChecked(e, t) {
234
+ if (e.children?.length) for (let n of e.children) n.disabled || this._setChecked(n, t);
235
+ else t ? this._checked.add(e.id) : this._checked.delete(e.id);
236
+ }
237
+ _nodeFrom(e) {
238
+ let t = e?.closest?.("li.wui-tree-item");
239
+ if (!t) return null;
240
+ for (let [e, n] of this._els) if (n.li === t) return this._byId.get(e) ?? null;
241
+ return null;
242
+ }
243
+ _emit(e, t) {
244
+ this.dispatchEvent(new CustomEvent(`wui-tree:${e}`, {
245
+ detail: t,
246
+ bubbles: !0,
247
+ composed: !0
248
+ }));
249
+ }
250
+ _announce(e) {
251
+ this._live && (this._live.textContent = e);
252
+ }
253
+ _setRoving(e) {
254
+ let t = this._els.get(this._focusId);
255
+ t && (t.li.tabIndex = -1), this._focusId = e.id;
256
+ let n = this._els.get(e.id);
257
+ n && (n.li.tabIndex = 0);
258
+ }
259
+ _focusNode(e) {
260
+ e && (this._setRoving(e), this._els.get(e.id)?.li.focus());
261
+ }
262
+ _activate(e) {
263
+ e.disabled || (this.selection === "single" && (this._selected = e.id, this._render(), this._syncForm()), this._emit("select", {
264
+ id: e.id,
265
+ node: e.raw
266
+ }));
267
+ }
268
+ _enabledLeaves(e) {
269
+ return e.disabled ? [] : e.children?.length ? e.children.flatMap((e) => this._enabledLeaves(e)) : [e];
270
+ }
271
+ _toggleCheck(e) {
272
+ let t = this._enabledLeaves(e);
273
+ if (!t.length) return;
274
+ let n = !t.every((e) => this._checked.has(e.id));
275
+ this._setChecked(e, n), this._render(), this._syncForm(), this._emit("check", {
276
+ id: e.id,
277
+ checked: n,
278
+ values: this.values
279
+ });
280
+ }
281
+ _toggleExpand(e) {
282
+ e.disabled || !this._isBranch(e) || (e.expanded ? (e.expanded = !1, this._render()) : this._expand(e));
283
+ }
284
+ _expand(e) {
285
+ e.expanded = !0, e.children === null ? this._load(e) : this._render();
286
+ }
287
+ async _load(e) {
288
+ if (e.loading) return;
289
+ e.loading = !0, e.failed = !1, this._announce(this.loadingText), this._render();
290
+ let t, n = null;
291
+ try {
292
+ t = await this._fetchChildren(e);
293
+ } catch (e) {
294
+ n = e;
295
+ }
296
+ let r = this._byId.get(e.id);
297
+ if (!r) {
298
+ this._announce("");
299
+ return;
300
+ }
301
+ if (r.loading) {
302
+ if (r.loading = !1, !n) try {
303
+ r.children = this._adoptStaged(t, r, r.level + 1), this._passChecksDown(r), this._announce("");
304
+ } catch (e) {
305
+ n = e;
306
+ }
307
+ n && (r.failed = !0, r.expanded = !1, this._announce(this.errorText), this._emit("error", {
308
+ id: r.id,
309
+ message: n?.message ?? String(n)
310
+ })), this._render(), this._syncForm();
311
+ }
312
+ }
313
+ async _fetchChildren(e) {
314
+ if (this._loader) return this._loader(e.raw);
315
+ let n = this.getAttribute("load-url");
316
+ if (!n) throw Error("<wui-tree> has a node with children to load but no loadChildren or load-url.");
317
+ let r = new URL(n, window.location.href);
318
+ r.searchParams.set(s, e.id);
319
+ let i = await t(r.href, { headers: { Accept: "application/json" } });
320
+ if (!i.ok) throw Error(`Loading children answered ${i.kind}.`);
321
+ return JSON.parse(i.html);
322
+ }
323
+ _handleClick(e) {
324
+ let t = this._nodeFrom(e.target);
325
+ !t || t.disabled || (this._focusNode(t), e.target.closest(".wui-tree-toggle") ? this._toggleExpand(t) : e.target.closest(".wui-tree-check") ? (e.preventDefault(), this._toggleCheck(t)) : this._activate(t));
326
+ }
327
+ _handleKeyDown(e) {
328
+ if (e.ctrlKey || e.metaKey || e.altKey) return;
329
+ let t = this._nodeFrom(e.target);
330
+ if (!(!t || e.target !== this._els.get(t.id)?.li)) if (e.key === "ArrowRight") {
331
+ if (e.preventDefault(), !this._isBranch(t) || t.disabled) return;
332
+ t.expanded ? t.children?.length && this._focusNode(t.children[0]) : this._expand(t);
333
+ } else e.key === "ArrowLeft" ? (e.preventDefault(), t.expanded && this._isBranch(t) && !t.disabled ? this._toggleExpand(t) : t.parent && this._focusNode(t.parent)) : e.key === " " ? (e.preventDefault(), this.selection === "multiple" ? this._toggleCheck(t) : this.selection === "single" && this._activate(t)) : this._nav.handler(e);
334
+ }
335
+ _syncForm() {
336
+ let e = this.selection;
337
+ if (e === "multiple") n(this, this.values);
338
+ else if (e === "single") r(this, this._selected ?? "");
339
+ else for (let e of this.querySelectorAll(u)) e.remove();
340
+ }
341
+ _render() {
342
+ if (!this._list) return;
343
+ let e = document.activeElement, t = !!e && this._list.contains(e), n = this._visible();
344
+ n.some((e) => e.id === this._focusId) || (this._focusId = (n.find((e) => e.id === this._selected) ?? n[0])?.id ?? null), this._els = /* @__PURE__ */ new Map();
345
+ let r = this.getAttribute("aria-label");
346
+ r ? this._list.setAttribute("aria-label", r) : this._list.removeAttribute("aria-label"), this._list.replaceChildren(...this._buildLevel(this._roots)), t && this._focusId && this._els.get(this._focusId)?.li.focus(), this._syncForm();
347
+ }
348
+ _buildLevel(e) {
349
+ return e.map((t, n) => this._buildItem(t, n + 1, e.length));
350
+ }
351
+ _buildItem(e, t, n) {
352
+ let r = this.selection, a = this._isBranch(e), o = this._state(e), s = p("li", "wui-tree-item", {
353
+ role: "treeitem",
354
+ tabindex: e.id === this._focusId ? 0 : -1,
355
+ "aria-level": e.level,
356
+ "aria-setsize": n,
357
+ "aria-posinset": t,
358
+ "aria-labelledby": `${this._uid}-${e.seq}`,
359
+ "aria-describedby": e.badge ? `${this._uid}-${e.seq}-badge` : null
360
+ });
361
+ a && s.setAttribute("aria-expanded", String(e.expanded)), e.disabled && s.setAttribute("aria-disabled", "true"), e.loading && s.setAttribute("aria-busy", "true"), r === "single" && s.setAttribute("aria-selected", String(e.id === this._selected)), r === "multiple" && s.setAttribute("aria-checked", o === "mixed" ? "mixed" : String(o === "checked"));
362
+ let c = p("div", "wui-tree-row", { role: "presentation" });
363
+ c.style.setProperty("--wui-tree-level", String(e.level - 1)), r === "single" && e.id === this._selected && c.classList.add("wui-tree-row-selected"), e.failed && c.classList.add("wui-tree-row-error");
364
+ let l = p("span", a ? "wui-tree-toggle" : "wui-tree-toggle wui-tree-toggle-leaf", { "aria-hidden": "true" });
365
+ if (a && (l.innerHTML = i("chevron-right", { size: 16 })), c.append(l), r === "multiple") {
366
+ let t = p("input", "form-check-input wui-tree-check", {
367
+ type: "checkbox",
368
+ tabindex: -1,
369
+ "aria-hidden": "true"
370
+ });
371
+ t.checked = o === "checked", t.indeterminate = o === "mixed", t.disabled = e.disabled, t.addEventListener("mousedown", (e) => e.preventDefault()), c.append(t);
372
+ }
373
+ if (e.icon) {
374
+ let t = p("span", "wui-tree-icon", { "aria-hidden": "true" });
375
+ t.innerHTML = i(e.icon, { size: 16 }), c.append(t);
376
+ }
377
+ let u = p("span", "wui-tree-label", { id: `${this._uid}-${e.seq}` });
378
+ if (u.textContent = e.label, c.append(u), e.badge) {
379
+ let t = p("span", `badge wui-tree-badge${e.badgeTone && e.badgeTone !== "neutral" ? ` badge-${e.badgeTone}` : ""}`, { id: `${this._uid}-${e.seq}-badge` });
380
+ t.textContent = e.badge, c.append(t);
381
+ }
382
+ if (e.loading && c.append(p("span", "wui-tree-spinner", { "aria-hidden": "true" })), s.append(c), e.expanded && e.children?.length) {
383
+ let t = p("ul", "wui-tree-group", { role: "group" });
384
+ t.append(...this._buildLevel(e.children)), s.append(t);
385
+ }
386
+ return this._els.set(e.id, {
387
+ li: s,
388
+ row: c
389
+ }), s;
390
+ }
391
+ };
392
+ //#endregion
393
+ export { m as t };
@@ -0,0 +1,221 @@
1
+ import { t as e } from "./elementBase-Bg1xpvup.js";
2
+ import { t } from "./iconGlyphs.g-Cpg1BUHm.js";
3
+ //#region src/WuiWizard.js
4
+ var n = "wui-wizard-step", r = class extends e {
5
+ static get observedAttributes() {
6
+ return [
7
+ "active",
8
+ "variant",
9
+ "orientation",
10
+ "non-linear",
11
+ "hide-stepper",
12
+ "hide-connectors",
13
+ "disabled",
14
+ "skippable",
15
+ "label",
16
+ "back-label",
17
+ "next-label",
18
+ "skip-label",
19
+ "finish-label"
20
+ ];
21
+ }
22
+ constructor() {
23
+ super(), this._active = 0, this._skipped = /* @__PURE__ */ new Set(), this._invalid = /* @__PURE__ */ new Set(), this._finished = !1, this._rendered = !1, this._reflecting = !1, this._beforeNext = null, this._header = null, this._footer = null, this._known = [], this._observer = null;
24
+ }
25
+ get active() {
26
+ return this._active;
27
+ }
28
+ set active(e) {
29
+ let t = Number.parseInt(e, 10);
30
+ Number.isFinite(t) && this._go(t, "set");
31
+ }
32
+ get beforeNext() {
33
+ return this._beforeNext;
34
+ }
35
+ set beforeNext(e) {
36
+ this._beforeNext = typeof e == "function" ? e : null;
37
+ }
38
+ get _steps() {
39
+ return [...this.querySelectorAll(`:scope > ${n}`)];
40
+ }
41
+ refresh() {
42
+ this._rendered && this._renderChrome();
43
+ }
44
+ connectedCallback() {
45
+ if (this._rendered) this._wire(), this._onStepsMutated();
46
+ else {
47
+ let e = Number.parseInt(this.getAttribute("active"), 10);
48
+ this._active = Number.isFinite(e) && e >= 0 ? e : 0, this.render();
49
+ }
50
+ }
51
+ disconnectedCallback() {
52
+ this._teardown();
53
+ }
54
+ attributeChangedCallback(e, t, n) {
55
+ if (!(!this._rendered || this._reflecting)) {
56
+ if (e === "active") {
57
+ let e = Number.parseInt(n, 10);
58
+ Number.isFinite(e) && this._go(e, "set");
59
+ return;
60
+ }
61
+ this._renderChrome();
62
+ }
63
+ }
64
+ render() {
65
+ let e = this._steps;
66
+ this._header || (this._header = document.createElement("nav"), this._header.className = "stepper wizard-stepper", this._footer = document.createElement("div"), this._footer.className = "form-actions wizard-footer form-actions-between", e.length ? (this.insertBefore(this._header, e[0]), e[e.length - 1].after(this._footer)) : (this.prepend(this._header), this.append(this._footer))), this._known = e, this._renderChrome(), this._rendered = !0, this._wire();
67
+ }
68
+ _renderChrome() {
69
+ let e = this._reconcileSteps();
70
+ this._placeChrome(e), this._clampActive(e), this._syncPanels(e), this._header.innerHTML = this._headerHtml(e), this._footer.innerHTML = this._footerHtml(e), this._header.hidden = this.hasAttribute("hide-stepper");
71
+ }
72
+ _clampActive(e) {
73
+ let t = Math.max(0, e.length - 1);
74
+ this._active > t && (this._active = t), this._active < 0 && (this._active = 0);
75
+ }
76
+ _reconcileSteps() {
77
+ let e = this._steps, t = this._known;
78
+ if (this._known = e, i(e, t)) return e;
79
+ let n = (n) => new Set([...n].map((n) => e.indexOf(t[n])).filter((e) => e >= 0));
80
+ this._skipped = n(this._skipped), this._invalid = n(this._invalid);
81
+ let r = t[this._active];
82
+ if (!r) return e;
83
+ let a = e.indexOf(r);
84
+ if (a < 0) {
85
+ let n = (t) => e.includes(t), r = t.slice(this._active + 1).find(n) ?? t.slice(0, this._active).reverse().find(n);
86
+ a = r ? e.indexOf(r) : this._active;
87
+ }
88
+ return a = Math.min(a, Math.max(0, e.length - 1)), a !== this._active && (this._active = a, this._reflectActive(a)), e;
89
+ }
90
+ _placeChrome(e) {
91
+ if (!e.length) return;
92
+ let t = e[e.length - 1];
93
+ this._header.nextElementSibling !== e[0] && this.insertBefore(this._header, e[0]), this._footer.previousElementSibling !== t && t.after(this._footer);
94
+ }
95
+ _onStepsMutated() {
96
+ if (!this._rendered) return;
97
+ let e = this._steps;
98
+ (!e.length || this._header.nextElementSibling === e[0] && this._footer.previousElementSibling === e[e.length - 1]) && i(e, this._known) || (this._renderChrome(), this._observer?.takeRecords());
99
+ }
100
+ _syncPanels(e) {
101
+ e.forEach((e, t) => {
102
+ let n = t === this._active;
103
+ e.classList.add("wizard-panel"), e.hidden = !n, e.setAttribute("role", "tabpanel"), e.setAttribute("aria-hidden", n ? "false" : "true");
104
+ });
105
+ }
106
+ _stepStatus(e, t) {
107
+ return e.getAttribute("status") || (this._invalid.has(t) ? "error" : this._finished ? "done" : t === this._active ? "active" : t < this._active ? this._skipped.has(t) ? "skipped" : "done" : "pending");
108
+ }
109
+ _headerHtml(e) {
110
+ let n = this.getAttribute("variant") === "journey", r = this.getAttribute("variant") === "icons", i = this.getAttribute("orientation") === "vertical", o = !this.hasAttribute("hide-connectors");
111
+ this._header.className = [
112
+ "stepper",
113
+ "wizard-stepper",
114
+ n && "stepper-journey",
115
+ r && "stepper-icons",
116
+ i && "stepper-vertical",
117
+ !o && "wui-stepper-no-connectors"
118
+ ].filter(Boolean).join(" "), this._header.setAttribute("aria-label", this.getAttribute("label") || "Progress");
119
+ let s = this.hasAttribute("non-linear");
120
+ return e.map((i, c) => {
121
+ let l = this._stepStatus(i, c), u = i.getAttribute("label") || "", d = i.getAttribute("description") || "", f = i.getAttribute("icon") || "", p = c + 1, m;
122
+ m = l === "done" ? t("check") : l === "error" ? t("alert-triangle") : l === "skipped" ? t("minus") : f ? t(f) : String(p);
123
+ let h = l === "pending" ? "step" : `step ${l}`, g = l === "active" ? " aria-current=\"step\"" : "", _ = s || c < this._active, v = d ? `<span class="step-desc">${a(d)}</span>` : "", y;
124
+ y = n ? `<span class="step-circle">${m}</span><span class="step-text"><span class="step-index">Step ${p}</span><span class="step-label">${a(u)}</span>${v}</span>` : r ? `<span class="step-circle">${m}</span><span class="step-index">Step ${p}</span><span class="step-label">${a(u)}</span>${v}` : `<span class="step-circle">${m}</span><span class="step-label">${a(u)}</span>${v}`;
125
+ let b = _ ? `<button type="button" class="${h}" data-step="${c}"${g}>${y}</button>` : `<div class="${h}"${g}>${y}</div>`;
126
+ return n && o && c < e.length - 1 ? `${b}<span class="step-line${l === "done" ? " done" : ""}" aria-hidden="true"></span>` : b;
127
+ }).join("");
128
+ }
129
+ _footerHtml(e) {
130
+ let n = this._active, r = e.length - 1, i = this.hasAttribute("disabled") ? " disabled" : "", o = e[n]?.hasAttribute("optional") || this.hasAttribute("skippable"), s = this.getAttribute("back-label") || "Back", c = this.getAttribute("next-label") || "Next", l = this.getAttribute("skip-label") || "Skip", u = this.getAttribute("finish-label") || "Finish";
131
+ return `${n > 0 ? `<button type="button" class="btn btn-secondary" data-nav="back"${i}>${t("arrow-left", { className: "me-2" })}${a(s)}</button>` : "<span></span>"}<span class="wizard-footer-actions">${o && n < r ? `<button type="button" class="btn btn-subtle" data-nav="skip"${i}>${a(l)}</button>` : ""}${n < r ? `<button type="button" class="btn btn-primary" data-nav="next"${i}>${a(c)}${t("arrow-right", { className: "ms-2" })}</button>` : `<button type="button" class="btn btn-primary" data-nav="finish"${i}>${a(u)}</button>`}</span>`;
132
+ }
133
+ _wire() {
134
+ this._teardown(), this._onHeaderClick = (e) => {
135
+ let t = e.target.closest("[data-step]");
136
+ t && this.contains(t) && this._stepTo(Number.parseInt(t.dataset.step, 10));
137
+ }, this._onFooterClick = (e) => {
138
+ let t = e.target.closest("[data-nav]");
139
+ if (!t || !this.contains(t) || this.hasAttribute("disabled")) return;
140
+ let n = t.dataset.nav;
141
+ n === "back" ? this._back() : n === "skip" ? this._skip() : (n === "next" || n === "finish") && this._next();
142
+ }, this._header.addEventListener("click", this._onHeaderClick), this._footer.addEventListener("click", this._onFooterClick), this._observer = new MutationObserver(() => this._onStepsMutated()), this._observer.observe(this, { childList: !0 });
143
+ }
144
+ _teardown() {
145
+ this._header && this._onHeaderClick && this._header.removeEventListener("click", this._onHeaderClick), this._footer && this._onFooterClick && this._footer.removeEventListener("click", this._onFooterClick), this._observer?.disconnect(), this._observer = null;
146
+ }
147
+ _stepTo(e) {
148
+ this.hasAttribute("disabled") || !this.hasAttribute("non-linear") && e >= this._active || this._go(e, "step");
149
+ }
150
+ _back() {
151
+ this._active > 0 && this._go(this._active - 1, "back");
152
+ }
153
+ async _next() {
154
+ this._reconcileSteps();
155
+ let e = this._active, t = this._steps, n = e >= t.length - 1, r = t[e];
156
+ if (!this.dispatchEvent(new CustomEvent("wui-wizard:beforechange", {
157
+ detail: n ? {
158
+ index: e,
159
+ next: e,
160
+ reason: "finish"
161
+ } : {
162
+ index: e,
163
+ next: e + 1,
164
+ reason: "next"
165
+ },
166
+ cancelable: !0
167
+ }))) return this._flagInvalid(e);
168
+ if (this._beforeNext) {
169
+ let i;
170
+ try {
171
+ i = await this._beforeNext(e);
172
+ } catch {
173
+ i = !1;
174
+ }
175
+ if (this._reconcileSteps(), t = this._steps, e = t.indexOf(r), e < 0) return;
176
+ if (n = e >= t.length - 1, i === !1) return this._flagInvalid(e);
177
+ }
178
+ if (this._invalid.delete(e), this._skipped.delete(e), n) return this._finish();
179
+ this._go(e + 1, "next");
180
+ }
181
+ _skip() {
182
+ let e = this._active, t = this._steps;
183
+ if (!(!t[e]?.hasAttribute("optional") && !this.hasAttribute("skippable"))) {
184
+ if (this._invalid.delete(e), this._skipped.add(e), this.dispatchEvent(new CustomEvent("wui-wizard:skip", { detail: { index: e } })), e >= t.length - 1) return this._finish();
185
+ this._go(e + 1, "skip");
186
+ }
187
+ }
188
+ _flagInvalid(e) {
189
+ this._invalid.add(e), this._renderChrome(), this.dispatchEvent(new CustomEvent("wui-wizard:invalid", { detail: { index: e } }));
190
+ }
191
+ _finish() {
192
+ this._invalid.delete(this._active), this._finished = !0, this._renderChrome(), this.dispatchEvent(new CustomEvent("wui-wizard:finish", { detail: { index: this._active } }));
193
+ }
194
+ _go(e, t) {
195
+ let n = this._reconcileSteps(), r = Math.max(0, n.length - 1), i = Math.min(Math.max(e, 0), r), a = this._active;
196
+ this._finished = !1, this._invalid.delete(a), this._active = i, this._reflectActive(i), this._renderChrome(), t !== "silent" && i !== a && this.dispatchEvent(new CustomEvent("wui-wizard:change", { detail: {
197
+ index: i,
198
+ previous: a,
199
+ reason: t
200
+ } }));
201
+ }
202
+ _reflectActive(e) {
203
+ this._reflecting = !0, this.setAttribute("active", String(e)), this._reflecting = !1;
204
+ }
205
+ }, i = (e, t) => e.length === t.length && e.every((e, n) => e === t[n]), a = (e) => String(e ?? "").replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;"), o = class extends e {
206
+ static get observedAttributes() {
207
+ return [
208
+ "label",
209
+ "description",
210
+ "optional",
211
+ "icon",
212
+ "status"
213
+ ];
214
+ }
215
+ attributeChangedCallback() {
216
+ let e = this.closest("wui-wizard");
217
+ e && typeof e.refresh == "function" && e.refresh();
218
+ }
219
+ };
220
+ //#endregion
221
+ export { r as n, o as t };
@@ -0,0 +1,23 @@
1
+ function e(e, t, n = {}) {
2
+ if (!e || !t) return;
3
+ let r = e.getBoundingClientRect(), i = n.clampHeight ? t.scrollTop : 0;
4
+ n.clampHeight && (t.style.maxHeight = "");
5
+ let a = t.offsetHeight, o = window.innerHeight - r.bottom, s = o < a + 4 && r.top > o;
6
+ if (t.classList.toggle("drop-up", s), t.style.position = "fixed", t.style.top = s ? `${Math.max(4, r.top - a - 4)}px` : `${r.bottom + 4}px`, n.clampHeight) {
7
+ let e = s ? r.top - 8 : window.innerHeight - r.bottom - 8;
8
+ e < a && (t.style.maxHeight = `${Math.max(e, 0)}px`), t.scrollTop = i;
9
+ }
10
+ n.matchWidth && (r.width >= 300 ? (t.style.minWidth = `${r.width}px`, t.style.width = `${r.width}px`, t.style.maxWidth = `${r.width}px`) : (t.style.minWidth = `${r.width}px`, t.style.width = "max-content", t.style.maxWidth = `${Math.min(400, window.innerWidth - 8)}px`));
11
+ let c = t.offsetWidth, l = Math.min(r.left, window.innerWidth - c - 4);
12
+ t.style.left = `${Math.max(4, l)}px`;
13
+ }
14
+ function t(e, t) {
15
+ n(e), e._reanchor = t, e._reanchorScroll = (n) => {
16
+ n.target instanceof Node && typeof e.contains == "function" && e.contains(n.target) || t();
17
+ }, window.addEventListener("resize", e._reanchor), window.addEventListener("scroll", e._reanchorScroll, !0);
18
+ }
19
+ function n(e) {
20
+ e?._reanchor && (window.removeEventListener("resize", e._reanchor), window.removeEventListener("scroll", e._reanchorScroll, !0), e._reanchor = null, e._reanchorScroll = null);
21
+ }
22
+ //#endregion
23
+ export { t as n, n as r, e as t };
@@ -0,0 +1,42 @@
1
+ //#region src/calendarMath.js
2
+ var e = [
3
+ "January",
4
+ "February",
5
+ "March",
6
+ "April",
7
+ "May",
8
+ "June",
9
+ "July",
10
+ "August",
11
+ "September",
12
+ "October",
13
+ "November",
14
+ "December"
15
+ ], t = [
16
+ "Su",
17
+ "Mo",
18
+ "Tu",
19
+ "We",
20
+ "Th",
21
+ "Fr",
22
+ "Sa"
23
+ ], n = (e) => String(e).padStart(2, "0"), r = (e, t, r) => `${e}-${n(t + 1)}-${n(r)}`, i = (e) => {
24
+ let t = /^(\d{4})-(\d{2})-(\d{2})$/.exec(e || "");
25
+ return t ? {
26
+ y: +t[1],
27
+ m: t[2] - 1,
28
+ d: +t[3]
29
+ } : null;
30
+ }, a = (t) => {
31
+ let r = i(t);
32
+ return r ? `${n(r.d)} ${e[r.m].slice(0, 3)} ${r.y}` : "";
33
+ }, o = (e, t) => new Date(e, t + 1, 0).getDate(), s = (e, t) => {
34
+ for (; t < 0;) t += 12, --e;
35
+ for (; t > 11;) t -= 12, e += 1;
36
+ return {
37
+ y: e,
38
+ m: t
39
+ };
40
+ };
41
+ //#endregion
42
+ export { a, o as i, t as n, i as o, s as r, r as s, e as t };