@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.
- package/dist/WuiAutocomplete-ByxnwJNQ.js +283 -0
- package/dist/WuiCommandPalette-CtZ04JxZ.js +130 -0
- package/dist/WuiConsentBanner-oVe-jxCO.js +399 -0
- package/dist/WuiContextMenu-Bx_U2X3t.js +211 -0
- package/dist/WuiCountrySelect-CUAwKnL9.js +28 -0
- package/dist/WuiDatePicker-DkNbc-z7.js +325 -0
- package/dist/WuiDateRange-BocnVO6L.js +233 -0
- package/dist/WuiDock-BSDY9g8Q.js +57 -0
- package/dist/WuiImageCrop-1yaAONTk.js +462 -0
- package/dist/WuiMultiSelect-BrCGRNCt.js +416 -0
- package/dist/WuiOtp-D8-4Pqil.js +128 -0
- package/dist/WuiPhone-BvbhiP2r.js +731 -0
- package/dist/WuiSelect-BXrpiuXG.js +214 -0
- package/dist/WuiSlider-BcU0psYf.js +256 -0
- package/dist/WuiSortable-JjJqstSU.js +280 -0
- package/dist/WuiTagInput-D1ay3OcL.js +158 -0
- package/dist/WuiTimePicker-C7n-VFGt.js +370 -0
- package/dist/WuiTour-R5O9l--J.js +205 -0
- package/dist/WuiTree-Ds-8tNgs.js +393 -0
- package/dist/WuiWizardStep-BU5w9_Ds.js +221 -0
- package/dist/anchorOverlay-DluGZ8ef.js +23 -0
- package/dist/calendarMath-BAF2Jkg_.js +42 -0
- package/dist/countries-B-M_LTgS.js +1234 -0
- package/dist/elementBase-Bg1xpvup.js +9 -0
- package/dist/elements/autocomplete.js +6 -0
- package/dist/elements/command-palette.js +6 -0
- package/dist/elements/consent-banner.js +6 -0
- package/dist/elements/context-menu.js +6 -0
- package/dist/elements/country-select.js +6 -0
- package/dist/elements/date-range.js +6 -0
- package/dist/elements/datepicker.js +6 -0
- package/dist/elements/dock.js +6 -0
- package/dist/elements/image-crop.js +6 -0
- package/dist/elements/kanban.js +6 -0
- package/dist/elements/multiselect.js +6 -0
- package/dist/elements/otp.js +6 -0
- package/dist/elements/phone.js +6 -0
- package/dist/elements/select.js +6 -0
- package/dist/elements/slider.js +6 -0
- package/dist/elements/sortable.js +6 -0
- package/dist/elements/status-icon.js +6 -0
- package/dist/elements/taginput.js +6 -0
- package/dist/elements/timepicker.js +6 -0
- package/dist/elements/tour.js +6 -0
- package/dist/elements/tree.js +6 -0
- package/dist/elements/wizard.js +5 -0
- package/dist/formMirror-jGf5M4gk.js +29 -0
- package/dist/formatters-DusKbTyV.js +138 -0
- package/dist/helpers.js +5 -0
- package/dist/iconGlyphs.g-Cpg1BUHm.js +215 -0
- package/dist/kanban-BeVAItir.js +972 -0
- package/dist/listboxKeyNav-zts_8d5e.js +36 -0
- package/dist/optionLabel-Dn-I7zyp.js +16 -0
- package/dist/statusIcons-C3zjycpa.js +37 -0
- package/dist/textMatch-DEUjlkdy.js +27 -0
- package/dist/themeTransition-BpCuMnjk.js +589 -0
- package/dist/tokenCommit-VWz-2jEf.js +20 -0
- package/dist/ui-elements.global.js +118 -129
- package/dist/ui-elements.js +253 -8864
- package/dist/ui-phone.global.js +14 -0
- package/dist/wuiHttp-m0yQadwQ.js +117 -0
- package/package.json +28 -3
|
@@ -0,0 +1,370 @@
|
|
|
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 { t as i } from "./formMirror-jGf5M4gk.js";
|
|
4
|
+
import { t as a } from "./iconGlyphs.g-Cpg1BUHm.js";
|
|
5
|
+
//#region src/WuiTimePicker.js
|
|
6
|
+
var o = (e) => String(e).padStart(2, "0"), s = (e, t) => `${o(e)}:${o(t)}`, c = (e) => {
|
|
7
|
+
let t = /^(\d{2}):(\d{2})$/.exec(e || "");
|
|
8
|
+
return t ? {
|
|
9
|
+
h: +t[1],
|
|
10
|
+
m: +t[2]
|
|
11
|
+
} : null;
|
|
12
|
+
}, l = (e, t = "24") => {
|
|
13
|
+
if (!e) return "";
|
|
14
|
+
if (t === "24") return s(e.h, e.m);
|
|
15
|
+
let n = e.h % 12 || 12, r = e.h >= 12 ? "PM" : "AM";
|
|
16
|
+
return `${n}:${o(e.m)} ${r}`;
|
|
17
|
+
}, u = (e) => {
|
|
18
|
+
let t = String(e || "").trim().toLowerCase(), n = /^(\d{1,2})(?:[:.](\d{2})|(\d{2}))?\s*(?:([ap])\.?\s*(?:m\.?)?)?$/.exec(t);
|
|
19
|
+
if (!n) return null;
|
|
20
|
+
let r = +n[1], i = +(n[2] ?? n[3] ?? "0");
|
|
21
|
+
if (i > 59) return null;
|
|
22
|
+
if (n[4]) {
|
|
23
|
+
if (r < 1 || r > 12) return null;
|
|
24
|
+
r = r % 12 + (n[4] === "p" ? 12 : 0);
|
|
25
|
+
} else if (r > 23) return null;
|
|
26
|
+
return {
|
|
27
|
+
h: r,
|
|
28
|
+
m: i
|
|
29
|
+
};
|
|
30
|
+
}, d = 0, f = class extends e {
|
|
31
|
+
static formAssociated = !0;
|
|
32
|
+
static get observedAttributes() {
|
|
33
|
+
return [
|
|
34
|
+
"value",
|
|
35
|
+
"min",
|
|
36
|
+
"max",
|
|
37
|
+
"step",
|
|
38
|
+
"format",
|
|
39
|
+
"placeholder",
|
|
40
|
+
"disabled",
|
|
41
|
+
"required",
|
|
42
|
+
"size",
|
|
43
|
+
"aria-label",
|
|
44
|
+
"aria-describedby",
|
|
45
|
+
"aria-invalid"
|
|
46
|
+
];
|
|
47
|
+
}
|
|
48
|
+
constructor() {
|
|
49
|
+
super();
|
|
50
|
+
try {
|
|
51
|
+
this._internals = this.attachInternals();
|
|
52
|
+
} catch {
|
|
53
|
+
this._internals = null;
|
|
54
|
+
}
|
|
55
|
+
this._value = "", this._uid = `wui-tp-${++d}`, this._typedError = "", this._typeahead = "", this._typeaheadTimer = null, this.addEventListener("focusout", (e) => {
|
|
56
|
+
this._isOpen?.() && e.relatedTarget && !this.contains(e.relatedTarget) && this._close({ commit: !0 });
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
connectedCallback() {
|
|
60
|
+
if (!this._rendered) {
|
|
61
|
+
this.render();
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
this._bindGlobal?.();
|
|
65
|
+
}
|
|
66
|
+
attributeChangedCallback(e, t, n) {
|
|
67
|
+
if (this._rendered) switch (e) {
|
|
68
|
+
case "value":
|
|
69
|
+
this._value = n || "", this._typedError = "", this._syncFormValue(), this._syncText(), this._syncInvalid();
|
|
70
|
+
return;
|
|
71
|
+
case "aria-invalid":
|
|
72
|
+
case "aria-describedby":
|
|
73
|
+
this._syncInvalid();
|
|
74
|
+
return;
|
|
75
|
+
case "aria-label":
|
|
76
|
+
case "placeholder":
|
|
77
|
+
case "disabled":
|
|
78
|
+
case "required":
|
|
79
|
+
this._syncAttrs();
|
|
80
|
+
return;
|
|
81
|
+
default: this.render();
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
formResetCallback() {
|
|
85
|
+
this.value = this._defaultValue || "";
|
|
86
|
+
}
|
|
87
|
+
get value() {
|
|
88
|
+
return this._value;
|
|
89
|
+
}
|
|
90
|
+
set value(e) {
|
|
91
|
+
this._value = e || "", this._typedError = "", i(this, this._value), this._syncText(), this._syncInvalid();
|
|
92
|
+
}
|
|
93
|
+
_format() {
|
|
94
|
+
return this.getAttribute("format") || "24";
|
|
95
|
+
}
|
|
96
|
+
_step() {
|
|
97
|
+
return Math.max(1, parseInt(this.getAttribute("step") || "30", 10) || 30);
|
|
98
|
+
}
|
|
99
|
+
_bounds() {
|
|
100
|
+
let e = c(this.getAttribute("min")) || {
|
|
101
|
+
h: 0,
|
|
102
|
+
m: 0
|
|
103
|
+
}, t = c(this.getAttribute("max")) || {
|
|
104
|
+
h: 23,
|
|
105
|
+
m: 59
|
|
106
|
+
};
|
|
107
|
+
return {
|
|
108
|
+
min: e.h * 60 + e.m,
|
|
109
|
+
max: t.h * 60 + t.m
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
_allowed(e, t) {
|
|
113
|
+
let n = e * 60 + t, { min: r, max: i } = this._bounds();
|
|
114
|
+
return n >= r && n <= i && n % this._step() === 0;
|
|
115
|
+
}
|
|
116
|
+
_times() {
|
|
117
|
+
let e = [];
|
|
118
|
+
for (let t = 0; t < 1440; t += this._step()) {
|
|
119
|
+
let n = Math.floor(t / 60), r = t % 60;
|
|
120
|
+
this._allowed(n, r) && e.push({
|
|
121
|
+
h: n,
|
|
122
|
+
m: r
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
return e;
|
|
126
|
+
}
|
|
127
|
+
_refusal(e) {
|
|
128
|
+
if (this._allowed(e.h, e.m)) return "";
|
|
129
|
+
let t = this._format(), { min: n, max: r } = this._bounds(), i = e.h * 60 + e.m, a = (e) => l({
|
|
130
|
+
h: Math.floor(e / 60),
|
|
131
|
+
m: e % 60
|
|
132
|
+
}, t);
|
|
133
|
+
if (i < n || i > r) {
|
|
134
|
+
let e = !!c(this.getAttribute("min")), t = !!c(this.getAttribute("max"));
|
|
135
|
+
return e && t ? `Enter a time between ${a(n)} and ${a(r)}.` : e ? `Enter a time at or after ${a(n)}.` : `Enter a time at or before ${a(r)}.`;
|
|
136
|
+
}
|
|
137
|
+
return `Enter a time in ${this._step()}-minute steps.`;
|
|
138
|
+
}
|
|
139
|
+
render() {
|
|
140
|
+
this._defaultValue === void 0 && (this._defaultValue = this.getAttribute("value") || "", this._value = this._defaultValue || this._value), this._isOpen = null;
|
|
141
|
+
let e = this.getAttribute("size"), t = e === "sm" ? " input-sm" : e === "lg" ? " input-lg" : "", n = this._uid;
|
|
142
|
+
this.innerHTML = `
|
|
143
|
+
<div class="timepicker">
|
|
144
|
+
<div class="wui-timepicker-field">
|
|
145
|
+
<input type="text" class="input timepicker-trigger${t}" id="${n}-input" role="combobox" aria-haspopup="dialog" aria-expanded="false" aria-controls="${n}-pop" aria-autocomplete="none" autocomplete="off" spellcheck="false">
|
|
146
|
+
<button type="button" class="wui-timepicker-toggle" tabindex="-1" aria-label="Choose time" aria-haspopup="dialog" aria-expanded="false" aria-controls="${n}-pop">${a("clock")}</button>
|
|
147
|
+
</div>
|
|
148
|
+
<div class="timepicker-pop" id="${n}-pop" role="dialog" aria-label="Choose time" hidden></div>
|
|
149
|
+
<div class="field-error wui-timepicker-error" id="${n}-error" hidden></div>
|
|
150
|
+
</div>`, this._rendered = !0, this._syncAttrs(), this._syncText(), this._syncInvalid(), i(this, this._value), this._wire();
|
|
151
|
+
}
|
|
152
|
+
_input() {
|
|
153
|
+
return this.querySelector(".timepicker-trigger");
|
|
154
|
+
}
|
|
155
|
+
_pop() {
|
|
156
|
+
return this.querySelector(".timepicker-pop");
|
|
157
|
+
}
|
|
158
|
+
_syncFormValue() {
|
|
159
|
+
i(this, this._value);
|
|
160
|
+
}
|
|
161
|
+
_syncAttrs() {
|
|
162
|
+
let e = this._input(), t = this.querySelector(".wui-timepicker-toggle");
|
|
163
|
+
if (!e) return;
|
|
164
|
+
let n = this.hasAttribute("disabled");
|
|
165
|
+
e.disabled = n, t && (t.disabled = n), e.placeholder = this.getAttribute("placeholder") || "Select time", this.hasAttribute("required") ? e.setAttribute("aria-required", "true") : e.removeAttribute("aria-required");
|
|
166
|
+
let r = this.getAttribute("aria-label");
|
|
167
|
+
r ? e.setAttribute("aria-label", r) : e.removeAttribute("aria-label"), i(this, this._value), n && this._isOpen?.() && this._close({ commit: !1 });
|
|
168
|
+
}
|
|
169
|
+
_syncText() {
|
|
170
|
+
let e = this._input();
|
|
171
|
+
e && (e.value = l(c(this._value), this._format()), this._isOpen?.() && this._syncColumns());
|
|
172
|
+
}
|
|
173
|
+
_syncInvalid() {
|
|
174
|
+
let e = this._input(), t = this.querySelector(".wui-timepicker-error");
|
|
175
|
+
if (!e || !t) return;
|
|
176
|
+
let n = this._typedError;
|
|
177
|
+
t.textContent = n, t.hidden = !n, this.hasAttribute("aria-invalid") || n ? e.setAttribute("aria-invalid", "true") : e.removeAttribute("aria-invalid");
|
|
178
|
+
let r = [this.getAttribute("aria-describedby"), n ? t.id : null].filter(Boolean).join(" ");
|
|
179
|
+
r ? e.setAttribute("aria-describedby", r) : e.removeAttribute("aria-describedby"), e.setCustomValidity?.(n);
|
|
180
|
+
}
|
|
181
|
+
_commitText() {
|
|
182
|
+
let e = this._input();
|
|
183
|
+
if (!e || e.value === l(c(this._value), this._format())) return !0;
|
|
184
|
+
let t = e.value.trim(), n = "";
|
|
185
|
+
if (t) {
|
|
186
|
+
let e = u(t), r = e ? this._refusal(e) : `Enter a time like ${this._format() === "12" ? "7:45 PM" : "19:45"}.`;
|
|
187
|
+
if (r) return this._typedError = r, this._syncInvalid(), !1;
|
|
188
|
+
n = s(e.h, e.m);
|
|
189
|
+
}
|
|
190
|
+
let r = n !== this._value;
|
|
191
|
+
return this.value = n, r && this.dispatchEvent(new Event("change", { bubbles: !0 })), !0;
|
|
192
|
+
}
|
|
193
|
+
_pending() {
|
|
194
|
+
let e = u(this._input()?.value);
|
|
195
|
+
return e && this._allowed(e.h, e.m) ? e : null;
|
|
196
|
+
}
|
|
197
|
+
_columnsHtml() {
|
|
198
|
+
let e = this._format(), t = this._times(), n = (e, t, n) => `<div class="wui-timepicker-col" role="listbox" aria-label="${t}" data-col="${e}">${n.map((e) => `<button type="button" class="timepicker-option" role="option" tabindex="-1" aria-selected="false" data-v="${e.v}">${e.text}</button>`).join("")}</div>`, r = [...new Set(t.map((e) => e.h))], i = [...new Set(t.map((e) => e.m))].sort((e, t) => e - t), a;
|
|
199
|
+
if (e === "12") {
|
|
200
|
+
let e = [...new Set(r.map((e) => e % 12))].sort((e, t) => e - t), t = [...new Set(r.map((e) => e >= 12 ? "pm" : "am"))].sort();
|
|
201
|
+
a = n("hour", "Hour", e.map((e) => ({
|
|
202
|
+
v: e,
|
|
203
|
+
text: String(e || 12)
|
|
204
|
+
}))) + n("minute", "Minute", i.map((e) => ({
|
|
205
|
+
v: e,
|
|
206
|
+
text: o(e)
|
|
207
|
+
}))) + n("period", "AM or PM", t.map((e) => ({
|
|
208
|
+
v: e,
|
|
209
|
+
text: e.toUpperCase()
|
|
210
|
+
})));
|
|
211
|
+
} else a = n("hour", "Hour", r.map((e) => ({
|
|
212
|
+
v: e,
|
|
213
|
+
text: o(e)
|
|
214
|
+
}))) + n("minute", "Minute", i.map((e) => ({
|
|
215
|
+
v: e,
|
|
216
|
+
text: o(e)
|
|
217
|
+
})));
|
|
218
|
+
return `<div class="wui-timepicker-cols">${a}</div>`;
|
|
219
|
+
}
|
|
220
|
+
_selectedIn(e, t) {
|
|
221
|
+
return t ? e === "minute" ? String(t.m) : e === "period" ? t.h >= 12 ? "pm" : "am" : String(this._format() === "12" ? t.h % 12 : t.h) : null;
|
|
222
|
+
}
|
|
223
|
+
_optionEnabled(e, t, n) {
|
|
224
|
+
if (!n) return !0;
|
|
225
|
+
let r = this._format() === "12", i = n.h >= 12, a = (e) => r ? [e + (i ? 12 : 0)] : [e], o = Array.from({ length: 60 }, (e, t) => t);
|
|
226
|
+
if (e === "hour") return a(+t).some((e) => o.some((t) => this._allowed(e, t)));
|
|
227
|
+
if (e === "minute") return this._allowed(n.h, +t);
|
|
228
|
+
let s = t === "pm" ? 12 : 0;
|
|
229
|
+
return Array.from({ length: 12 }, (e, t) => s + t).some((e) => o.some((t) => this._allowed(e, t)));
|
|
230
|
+
}
|
|
231
|
+
_syncColumns({ scroll: e = !1 } = {}) {
|
|
232
|
+
let t = this._pop();
|
|
233
|
+
if (!t) return;
|
|
234
|
+
let n = this._pending();
|
|
235
|
+
for (let r of t.querySelectorAll(".wui-timepicker-col")) {
|
|
236
|
+
let t = r.dataset.col, i = this._selectedIn(t, n), a = [...r.querySelectorAll(".timepicker-option")], o = null;
|
|
237
|
+
for (let e of a) {
|
|
238
|
+
let r = e.dataset.v === i;
|
|
239
|
+
e.classList.toggle("is-selected", r), e.setAttribute("aria-selected", r ? "true" : "false"), e.disabled = !r && !this._optionEnabled(t, e.dataset.v, n), r && (o = e);
|
|
240
|
+
}
|
|
241
|
+
o = o || a.find((e) => !e.disabled) || null;
|
|
242
|
+
for (let e of a) e.tabIndex = e === o ? 0 : -1;
|
|
243
|
+
e && o && (r.scrollTop = o.offsetTop - (r.clientHeight - o.offsetHeight) / 2);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
_pick(e, t) {
|
|
247
|
+
let n = this._times();
|
|
248
|
+
if (!n.length) return;
|
|
249
|
+
let r = this._pending() || n[0], i = this._format() === "12", a = r.h, o = r.m;
|
|
250
|
+
if (e === "minute" ? o = +t : a = e === "period" ? a % 12 + (t === "pm" ? 12 : 0) : i ? +t + (r.h >= 12 ? 12 : 0) : +t, !this._allowed(a, o)) {
|
|
251
|
+
let t = a * 60 + o, r = n.filter((t) => e === "minute" ? t.m === o : e === "period" ? t.h >= 12 == a >= 12 : i ? t.h % 12 == a % 12 && t.h >= 12 == a >= 12 : t.h === a).sort((e, n) => Math.abs(e.h * 60 + e.m - t) - Math.abs(n.h * 60 + n.m - t))[0];
|
|
252
|
+
if (!r) return;
|
|
253
|
+
a = r.h, o = r.m;
|
|
254
|
+
}
|
|
255
|
+
let s = this._input();
|
|
256
|
+
s.value = l({
|
|
257
|
+
h: a,
|
|
258
|
+
m: o
|
|
259
|
+
}, this._format()), this._typedError = "", this._syncInvalid(), this._syncColumns();
|
|
260
|
+
}
|
|
261
|
+
_position() {
|
|
262
|
+
r(this.querySelector(".wui-timepicker-field"), this._pop());
|
|
263
|
+
}
|
|
264
|
+
_onColumnKey(e) {
|
|
265
|
+
let t = e.target.closest?.(".timepicker-option"), n = t?.closest(".wui-timepicker-col");
|
|
266
|
+
if (!t || !n) return;
|
|
267
|
+
let r = [...n.querySelectorAll(".timepicker-option")].filter((e) => !e.disabled), i = r.indexOf(t), a = [...this._pop().querySelectorAll(".wui-timepicker-col")], o = (e) => {
|
|
268
|
+
e && (this._pick(n.dataset.col, e.dataset.v), (n.querySelector(".timepicker-option.is-selected") || e).focus());
|
|
269
|
+
};
|
|
270
|
+
switch (e.key) {
|
|
271
|
+
case "ArrowDown":
|
|
272
|
+
e.preventDefault(), o(r[Math.min(i + 1, r.length - 1)]);
|
|
273
|
+
return;
|
|
274
|
+
case "ArrowUp":
|
|
275
|
+
e.preventDefault(), o(r[Math.max(i - 1, 0)]);
|
|
276
|
+
return;
|
|
277
|
+
case "Home":
|
|
278
|
+
e.preventDefault(), o(r[0]);
|
|
279
|
+
return;
|
|
280
|
+
case "End":
|
|
281
|
+
e.preventDefault(), o(r[r.length - 1]);
|
|
282
|
+
return;
|
|
283
|
+
case "PageDown":
|
|
284
|
+
e.preventDefault(), o(r[Math.min(i + 8, r.length - 1)]);
|
|
285
|
+
return;
|
|
286
|
+
case "PageUp":
|
|
287
|
+
e.preventDefault(), o(r[Math.max(i - 8, 0)]);
|
|
288
|
+
return;
|
|
289
|
+
case "ArrowRight":
|
|
290
|
+
case "ArrowLeft":
|
|
291
|
+
e.preventDefault(), a[a.indexOf(n) + (e.key === "ArrowRight" ? 1 : -1)]?.querySelector(".timepicker-option[tabindex=\"0\"]")?.focus();
|
|
292
|
+
return;
|
|
293
|
+
case "Enter":
|
|
294
|
+
e.preventDefault(), this._close({
|
|
295
|
+
commit: !0,
|
|
296
|
+
refocus: !0
|
|
297
|
+
});
|
|
298
|
+
return;
|
|
299
|
+
case " ":
|
|
300
|
+
e.preventDefault(), o(t);
|
|
301
|
+
return;
|
|
302
|
+
case "Escape":
|
|
303
|
+
e.preventDefault(), this._close({
|
|
304
|
+
commit: !1,
|
|
305
|
+
refocus: !0
|
|
306
|
+
});
|
|
307
|
+
return;
|
|
308
|
+
default: e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey && (e.preventDefault(), clearTimeout(this._typeaheadTimer), this._typeahead += e.key.toLowerCase(), this._typeaheadTimer = setTimeout(() => {
|
|
309
|
+
this._typeahead = "", this._typeaheadTimer = null;
|
|
310
|
+
}, 500), o(r.find((e) => e.textContent.trim().toLowerCase().startsWith(this._typeahead))));
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
_wire() {
|
|
314
|
+
this._teardown();
|
|
315
|
+
let e = this._input(), r = this.querySelector(".wui-timepicker-toggle"), i = this._pop(), a = this.querySelector(".timepicker");
|
|
316
|
+
if (!e || !i) return;
|
|
317
|
+
let o = () => !i.hidden;
|
|
318
|
+
this._isOpen = o;
|
|
319
|
+
let s = () => {
|
|
320
|
+
o() && this._position();
|
|
321
|
+
}, c = () => i.querySelector(".wui-timepicker-col .timepicker-option[tabindex=\"0\"]")?.focus();
|
|
322
|
+
this._open = ({ focus: n = !1 } = {}) => {
|
|
323
|
+
this.hasAttribute("disabled") || (o() || (i.innerHTML = this._columnsHtml(), i.hidden = !1, a?.classList.add("open"), e.setAttribute("aria-expanded", "true"), r?.setAttribute("aria-expanded", "true"), this._position(), t(this, s), this._syncColumns({ scroll: !0 })), n && c());
|
|
324
|
+
}, this._close = ({ commit: t = !0, refocus: s = !1 } = {}) => {
|
|
325
|
+
if (!o()) return;
|
|
326
|
+
let c = i.contains(document.activeElement);
|
|
327
|
+
i.hidden = !0, i.innerHTML = "", a?.classList.remove("open"), e.setAttribute("aria-expanded", "false"), r?.setAttribute("aria-expanded", "false"), n(this), clearTimeout(this._typeaheadTimer), this._typeaheadTimer = null, this._typeahead = "", t ? this._commitText() : (this._typedError = "", this._syncText(), this._syncInvalid()), (s || c) && e.focus();
|
|
328
|
+
}, e.addEventListener("pointerdown", (e) => {
|
|
329
|
+
this._lastPointer = e.pointerType;
|
|
330
|
+
}), e.addEventListener("click", () => {
|
|
331
|
+
this._lastPointer !== "touch" && !o() && this._open(), this._lastPointer = null;
|
|
332
|
+
}), r?.addEventListener("click", () => {
|
|
333
|
+
o() ? this._close({
|
|
334
|
+
commit: !0,
|
|
335
|
+
refocus: !0
|
|
336
|
+
}) : this._open({ focus: !0 });
|
|
337
|
+
}), e.addEventListener("keydown", (e) => {
|
|
338
|
+
if (e.key === "ArrowDown" || e.key === "ArrowUp") e.preventDefault(), this._open({ focus: !0 });
|
|
339
|
+
else if (e.key === "Enter") {
|
|
340
|
+
let t = o(), n = this._commitText();
|
|
341
|
+
t && n && this._close({ commit: !1 }), (!n || t) && e.preventDefault();
|
|
342
|
+
} else e.key === "Escape" && o() ? (e.preventDefault(), this._close({ commit: !1 })) : e.key === "Tab" && o() && this._close({ commit: !0 });
|
|
343
|
+
}), e.addEventListener("input", (e) => {
|
|
344
|
+
e.stopPropagation(), this._typedError && (this._typedError = "", this._syncInvalid()), o() && this._syncColumns({ scroll: !0 });
|
|
345
|
+
}), e.addEventListener("change", (e) => {
|
|
346
|
+
e.stopPropagation(), o() || this._commitText();
|
|
347
|
+
}), i.addEventListener("click", (e) => {
|
|
348
|
+
this._popClick = !0;
|
|
349
|
+
let t = e.target.closest(".timepicker-option"), n = t?.closest(".wui-timepicker-col");
|
|
350
|
+
t && n && !t.disabled && this._pick(n.dataset.col, t.dataset.v);
|
|
351
|
+
}), i.addEventListener("keydown", (e) => {
|
|
352
|
+
o() && this._onColumnKey(e);
|
|
353
|
+
}), this._bindGlobal = () => {
|
|
354
|
+
this._teardown(), this._onDocClick = (e) => {
|
|
355
|
+
let t = this._popClick;
|
|
356
|
+
this._popClick = !1, o() && !t && !this.contains(e.target) && this._close({ commit: !0 });
|
|
357
|
+
}, document.addEventListener("click", this._onDocClick), this._onDocKey = (e) => {
|
|
358
|
+
o() && e.key === "Escape" && this._close({ commit: !1 });
|
|
359
|
+
}, document.addEventListener("keydown", this._onDocKey), o() && t(this, s);
|
|
360
|
+
}, this._bindGlobal();
|
|
361
|
+
}
|
|
362
|
+
_teardown() {
|
|
363
|
+
this._onDocClick &&= (document.removeEventListener("click", this._onDocClick), null), this._onDocKey &&= (document.removeEventListener("keydown", this._onDocKey), null), n(this), clearTimeout(this._typeaheadTimer), this._typeaheadTimer = null, this._typeahead = "";
|
|
364
|
+
}
|
|
365
|
+
disconnectedCallback() {
|
|
366
|
+
this._teardown();
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
//#endregion
|
|
370
|
+
export { f as t };
|
|
@@ -0,0 +1,205 @@
|
|
|
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
|
+
//#region src/WuiTour.js
|
|
4
|
+
var i = "wui-tour-step", a = "wui-tour-seen:", o = {
|
|
5
|
+
back: "Back",
|
|
6
|
+
next: "Next",
|
|
7
|
+
skip: "Skip",
|
|
8
|
+
done: "Done"
|
|
9
|
+
}, s = {
|
|
10
|
+
back: "back-label",
|
|
11
|
+
next: "next-label",
|
|
12
|
+
skip: "skip-label",
|
|
13
|
+
done: "done-label"
|
|
14
|
+
}, c = 4, l = 0;
|
|
15
|
+
function u(e = a, t = globalThis.localStorage) {
|
|
16
|
+
return {
|
|
17
|
+
isSeen: async (n) => t.getItem(e + n) === "1",
|
|
18
|
+
markSeen: async (n) => {
|
|
19
|
+
t.setItem(e + n, "1");
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
var d = (e) => !e?.isConnected || getComputedStyle(e).visibility === "hidden" ? !1 : e.getClientRects().length > 0, f = class extends e {
|
|
24
|
+
static get observedAttributes() {
|
|
25
|
+
return ["open"];
|
|
26
|
+
}
|
|
27
|
+
constructor() {
|
|
28
|
+
super(), this.seenStore = null, this.onBeforeStep = null, this._run = 0, this._running = !1, this._layer = null;
|
|
29
|
+
}
|
|
30
|
+
connectedCallback() {
|
|
31
|
+
this.hasAttribute("open") && this.start();
|
|
32
|
+
}
|
|
33
|
+
disconnectedCallback() {
|
|
34
|
+
this.stop();
|
|
35
|
+
}
|
|
36
|
+
attributeChangedCallback(e, t, n) {
|
|
37
|
+
e !== "open" || !this.isConnected || (n === null ? this.stop() : this.start());
|
|
38
|
+
}
|
|
39
|
+
get tourId() {
|
|
40
|
+
return this.getAttribute("tour-id") || "";
|
|
41
|
+
}
|
|
42
|
+
set tourId(e) {
|
|
43
|
+
e == null || e === "" ? this.removeAttribute("tour-id") : this.setAttribute("tour-id", String(e));
|
|
44
|
+
}
|
|
45
|
+
_stepList() {
|
|
46
|
+
return Array.from(this.querySelectorAll(`:scope > ${i}`), (e) => ({
|
|
47
|
+
target: e.getAttribute("target") || "",
|
|
48
|
+
title: e.getAttribute("title") || void 0,
|
|
49
|
+
description: e.textContent.trim()
|
|
50
|
+
}));
|
|
51
|
+
}
|
|
52
|
+
_store() {
|
|
53
|
+
return this.seenStore ? this.seenStore : this.getAttribute("seen-store") === "local" ? u() : globalThis.window?.WUI?.tour?.seenStore || null;
|
|
54
|
+
}
|
|
55
|
+
_label(e) {
|
|
56
|
+
return this.getAttribute(s[e]) || o[e];
|
|
57
|
+
}
|
|
58
|
+
async start() {
|
|
59
|
+
if (this._running) return;
|
|
60
|
+
this._running = !0;
|
|
61
|
+
let e = ++this._run;
|
|
62
|
+
this.hasAttribute("open") || this.setAttribute("open", "");
|
|
63
|
+
try {
|
|
64
|
+
await this._start(e);
|
|
65
|
+
} catch (t) {
|
|
66
|
+
throw e === this._run && (this._running = !1), t;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
async _start(e) {
|
|
70
|
+
this._steps = this._stepList();
|
|
71
|
+
let t = this._store();
|
|
72
|
+
if (t && !this.tourId) throw Error("<wui-tour> needs a tour-id to use a seen store.");
|
|
73
|
+
if (t && await t.isSeen(this.tourId)) {
|
|
74
|
+
e === this._run && this._finish("alreadySeen");
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
this._returnFocus = document.activeElement;
|
|
78
|
+
let n = await this._locate(0, 1, e);
|
|
79
|
+
if (e === this._run) {
|
|
80
|
+
if (!n) {
|
|
81
|
+
this._finish("noTargets");
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
this._firstIndex = n.index, this._build(), this._show(n);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
stop() {
|
|
88
|
+
this._running && (this._run++, this._teardown(), this._running = !1, this.hasAttribute("open") && this.removeAttribute("open"));
|
|
89
|
+
}
|
|
90
|
+
async _locate(e, t, n) {
|
|
91
|
+
let r = this._steps;
|
|
92
|
+
for (let i = e; i >= 0 && i < r.length; i += t) {
|
|
93
|
+
let e = r[i];
|
|
94
|
+
if (await this._beforeStep(e, i), n !== this._run) return null;
|
|
95
|
+
let t = document.querySelector(e.target);
|
|
96
|
+
if (d(t)) return {
|
|
97
|
+
index: i,
|
|
98
|
+
target: t
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
async _beforeStep(e, t) {
|
|
104
|
+
let n = [];
|
|
105
|
+
this.dispatchEvent(new CustomEvent("wui-tour:beforestep", {
|
|
106
|
+
bubbles: !0,
|
|
107
|
+
detail: {
|
|
108
|
+
step: e,
|
|
109
|
+
index: t,
|
|
110
|
+
wait: (e) => n.push(e)
|
|
111
|
+
}
|
|
112
|
+
})), await Promise.all(n), typeof this.onBeforeStep == "function" && await this.onBeforeStep(e, t);
|
|
113
|
+
}
|
|
114
|
+
_build() {
|
|
115
|
+
let e = `wui-tour-${++l}`, n = document.createElement("div");
|
|
116
|
+
n.className = "wui-tour-layer", n.innerHTML = `
|
|
117
|
+
<div class="wui-tour-spot" aria-hidden="true"></div>
|
|
118
|
+
<div class="wui-tour-card" role="dialog" aria-modal="true" tabindex="-1" aria-labelledby="${e}-title" aria-describedby="${e}-text">
|
|
119
|
+
<p class="wui-tour-position"></p>
|
|
120
|
+
<h2 class="wui-tour-title" id="${e}-title"></h2>
|
|
121
|
+
<p class="wui-tour-text" id="${e}-text"></p>
|
|
122
|
+
<div class="wui-tour-actions">
|
|
123
|
+
<button type="button" class="btn btn-sm btn-link wui-tour-skip"></button>
|
|
124
|
+
<div class="wui-tour-nav">
|
|
125
|
+
<button type="button" class="btn btn-sm btn-outline-secondary wui-tour-back"></button>
|
|
126
|
+
<button type="button" class="btn btn-sm btn-primary wui-tour-next"></button>
|
|
127
|
+
</div>
|
|
128
|
+
</div>
|
|
129
|
+
</div>
|
|
130
|
+
<div class="visually-hidden" role="status" aria-live="polite"></div>`, document.body.appendChild(n), this._layer = n, this._spot = n.querySelector(".wui-tour-spot"), this._card = n.querySelector(".wui-tour-card"), this._live = n.querySelector("[role=status]"), this._card.querySelector(".wui-tour-skip").addEventListener("click", () => this._close("skipped")), this._card.querySelector(".wui-tour-back").addEventListener("click", () => this._move(-1)), this._card.querySelector(".wui-tour-next").addEventListener("click", () => this._move(1)), this._onKey = (e) => this._key(e), this._onFocusIn = (e) => {
|
|
131
|
+
this._layer && !this._layer.contains(e.target) && this._card.focus();
|
|
132
|
+
}, document.addEventListener("keydown", this._onKey, !0), document.addEventListener("focusin", this._onFocusIn), t(n, () => this._place());
|
|
133
|
+
}
|
|
134
|
+
_show(e) {
|
|
135
|
+
this._current = e;
|
|
136
|
+
let { index: t, target: n } = e, r = this._steps[t], i = this._steps, a = t === i.length - 1, o = this._card;
|
|
137
|
+
o.querySelector(".wui-tour-position").textContent = `Step ${t + 1} of ${i.length}`;
|
|
138
|
+
let s = o.querySelector(".wui-tour-title");
|
|
139
|
+
s.textContent = r.title || "", s.hidden = !r.title, o.querySelector(".wui-tour-text").textContent = r.description || "", o.querySelector(".wui-tour-skip").textContent = this._label("skip"), o.querySelector(".wui-tour-back").textContent = this._label("back"), o.querySelector(".wui-tour-back").hidden = t <= this._firstIndex, o.querySelector(".wui-tour-next").textContent = this._label(a ? "done" : "next"), this._live.textContent = [
|
|
140
|
+
`Step ${t + 1} of ${i.length}`,
|
|
141
|
+
r.title,
|
|
142
|
+
r.description
|
|
143
|
+
].filter(Boolean).join(". "), n.scrollIntoView?.({
|
|
144
|
+
block: "center",
|
|
145
|
+
inline: "nearest"
|
|
146
|
+
}), this._place(), (!o.contains(document.activeElement) || document.activeElement.hidden) && o.focus(), this.dispatchEvent(new CustomEvent("wui-tour:step", {
|
|
147
|
+
bubbles: !0,
|
|
148
|
+
detail: {
|
|
149
|
+
step: r,
|
|
150
|
+
index: t
|
|
151
|
+
}
|
|
152
|
+
}));
|
|
153
|
+
}
|
|
154
|
+
_place() {
|
|
155
|
+
if (!this._current || !this._layer) return;
|
|
156
|
+
let e = this._current.target.getBoundingClientRect(), t = this._spot.style;
|
|
157
|
+
t.top = `${e.top - c}px`, t.left = `${e.left - c}px`, t.width = `${e.width + c * 2}px`, t.height = `${e.height + c * 2}px`, r(this._spot, this._card, { clampHeight: !0 });
|
|
158
|
+
}
|
|
159
|
+
async _move(e) {
|
|
160
|
+
if (!this._current || this._moving) return;
|
|
161
|
+
this._moving = !0;
|
|
162
|
+
let t = this._run;
|
|
163
|
+
try {
|
|
164
|
+
let n = await this._locate(this._current.index + e, e, t);
|
|
165
|
+
if (t !== this._run) return;
|
|
166
|
+
n ? this._show(n) : e > 0 && await this._close("finished");
|
|
167
|
+
} finally {
|
|
168
|
+
this._moving = !1;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
_key(e) {
|
|
172
|
+
if (!(!this._layer || e.altKey || e.ctrlKey || e.metaKey)) {
|
|
173
|
+
if (e.key === "Escape") e.preventDefault(), e.stopPropagation(), this._close("skipped");
|
|
174
|
+
else if (e.key === "ArrowRight" || e.key === "ArrowLeft") e.preventDefault(), e.key === "ArrowRight" ? this._move(1) : this._current.index > this._firstIndex && this._move(-1);
|
|
175
|
+
else if (e.key === "Tab") {
|
|
176
|
+
let t = Array.from(this._card.querySelectorAll("button")).filter((e) => !e.hidden), n = t[0], r = t[t.length - 1], i = document.activeElement;
|
|
177
|
+
!this._card.contains(i) || e.shiftKey && (i === n || i === this._card) ? (e.preventDefault(), (e.shiftKey ? r : n).focus()) : !e.shiftKey && i === r && (e.preventDefault(), n.focus());
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
_teardown() {
|
|
182
|
+
if (!this._layer) return;
|
|
183
|
+
document.removeEventListener("keydown", this._onKey, !0), document.removeEventListener("focusin", this._onFocusIn), n(this._layer), this._layer.remove(), this._layer = null, this._current = null;
|
|
184
|
+
let e = this._returnFocus;
|
|
185
|
+
this._returnFocus = null, e?.isConnected && e.focus?.();
|
|
186
|
+
}
|
|
187
|
+
async _close(e) {
|
|
188
|
+
let t = this._run;
|
|
189
|
+
this._teardown();
|
|
190
|
+
let n = this._store();
|
|
191
|
+
try {
|
|
192
|
+
n && t === this._run && await n.markSeen(this.tourId);
|
|
193
|
+
} finally {
|
|
194
|
+
this._finish(e);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
_finish(e) {
|
|
198
|
+
this._run++, this._running = !1, this.hasAttribute("open") && this.removeAttribute("open"), this.dispatchEvent(new CustomEvent("wui-tour:close", {
|
|
199
|
+
bubbles: !0,
|
|
200
|
+
detail: { reason: e }
|
|
201
|
+
}));
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
//#endregion
|
|
205
|
+
export { u as n, f as t };
|