mensa 0.9.1 → 0.9.3

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.
@@ -1,666 +0,0 @@
1
- let z = {}, J;
2
- function F(e = {}) {
3
- z = {
4
- animate: !0,
5
- allowClose: !0,
6
- overlayClickBehavior: "close",
7
- overlayOpacity: 0.7,
8
- smoothScroll: !1,
9
- disableActiveInteraction: !1,
10
- showProgress: !1,
11
- stagePadding: 10,
12
- stageRadius: 5,
13
- popoverOffset: 10,
14
- showButtons: ["next", "previous", "close"],
15
- disableButtons: [],
16
- overlayColor: "#000",
17
- ...e
18
- };
19
- }
20
- function s(e) {
21
- return e ? z[e] : z;
22
- }
23
- function le(e) {
24
- J = e;
25
- }
26
- function _() {
27
- return J;
28
- }
29
- let I = {};
30
- function N(e, o) {
31
- I[e] = o;
32
- }
33
- function L(e) {
34
- var o;
35
- (o = I[e]) == null || o.call(I);
36
- }
37
- function de() {
38
- I = {};
39
- }
40
- function O(e, o, t, i) {
41
- return (e /= i / 2) < 1 ? t / 2 * e * e + o : -t / 2 * (--e * (e - 2) - 1) + o;
42
- }
43
- function U(e) {
44
- const o = 'a[href]:not([disabled]), button:not([disabled]), textarea:not([disabled]), input[type="text"]:not([disabled]), input[type="radio"]:not([disabled]), input[type="checkbox"]:not([disabled]), select:not([disabled])';
45
- return e.flatMap((t) => {
46
- const i = t.matches(o), d = Array.from(t.querySelectorAll(o));
47
- return [...i ? [t] : [], ...d];
48
- }).filter((t) => getComputedStyle(t).pointerEvents !== "none" && ve(t));
49
- }
50
- function ee(e) {
51
- if (!e || ue(e))
52
- return;
53
- const o = s("smoothScroll"), t = e.offsetHeight > window.innerHeight;
54
- e.scrollIntoView({
55
- // Removing the smooth scrolling for elements which exist inside the scrollable parent
56
- // This was causing the highlight to not properly render
57
- behavior: !o || pe(e) ? "auto" : "smooth",
58
- inline: "center",
59
- block: t ? "start" : "center"
60
- });
61
- }
62
- function pe(e) {
63
- if (!e || !e.parentElement)
64
- return;
65
- const o = e.parentElement;
66
- return o.scrollHeight > o.clientHeight;
67
- }
68
- function ue(e) {
69
- const o = e.getBoundingClientRect();
70
- return o.top >= 0 && o.left >= 0 && o.bottom <= (window.innerHeight || document.documentElement.clientHeight) && o.right <= (window.innerWidth || document.documentElement.clientWidth);
71
- }
72
- function ve(e) {
73
- return !!(e.offsetWidth || e.offsetHeight || e.getClientRects().length);
74
- }
75
- let D = {};
76
- function k(e, o) {
77
- D[e] = o;
78
- }
79
- function l(e) {
80
- return e ? D[e] : D;
81
- }
82
- function X() {
83
- D = {};
84
- }
85
- function fe(e, o, t, i) {
86
- let d = l("__activeStagePosition");
87
- const n = d || t.getBoundingClientRect(), f = i.getBoundingClientRect(), w = O(e, n.x, f.x - n.x, o), r = O(e, n.y, f.y - n.y, o), v = O(e, n.width, f.width - n.width, o), g = O(e, n.height, f.height - n.height, o);
88
- d = {
89
- x: w,
90
- y: r,
91
- width: v,
92
- height: g
93
- }, oe(d), k("__activeStagePosition", d);
94
- }
95
- function te(e) {
96
- if (!e)
97
- return;
98
- const o = e.getBoundingClientRect(), t = {
99
- x: o.x,
100
- y: o.y,
101
- width: o.width,
102
- height: o.height
103
- };
104
- k("__activeStagePosition", t), oe(t);
105
- }
106
- function he() {
107
- const e = l("__activeStagePosition"), o = l("__overlaySvg");
108
- if (!e)
109
- return;
110
- if (!o) {
111
- console.warn("No stage svg found.");
112
- return;
113
- }
114
- const t = window.innerWidth, i = window.innerHeight;
115
- o.setAttribute("viewBox", `0 0 ${t} ${i}`);
116
- }
117
- function ge(e) {
118
- const o = we(e);
119
- document.body.appendChild(o), re(o, (t) => {
120
- t.target.tagName === "path" && L("overlayClick");
121
- }), k("__overlaySvg", o);
122
- }
123
- function oe(e) {
124
- const o = l("__overlaySvg");
125
- if (!o) {
126
- ge(e);
127
- return;
128
- }
129
- const t = o.firstElementChild;
130
- if ((t == null ? void 0 : t.tagName) !== "path")
131
- throw new Error("no path element found in stage svg");
132
- t.setAttribute("d", ie(e));
133
- }
134
- function we(e) {
135
- const o = window.innerWidth, t = window.innerHeight, i = document.createElementNS("http://www.w3.org/2000/svg", "svg");
136
- i.classList.add("driver-overlay", "driver-overlay-animated"), i.setAttribute("viewBox", `0 0 ${o} ${t}`), i.setAttribute("xmlSpace", "preserve"), i.setAttribute("xmlnsXlink", "http://www.w3.org/1999/xlink"), i.setAttribute("version", "1.1"), i.setAttribute("preserveAspectRatio", "xMinYMin slice"), i.style.fillRule = "evenodd", i.style.clipRule = "evenodd", i.style.strokeLinejoin = "round", i.style.strokeMiterlimit = "2", i.style.zIndex = "10000", i.style.position = "fixed", i.style.top = "0", i.style.left = "0", i.style.width = "100%", i.style.height = "100%";
137
- const d = document.createElementNS("http://www.w3.org/2000/svg", "path");
138
- return d.setAttribute("d", ie(e)), d.style.fill = s("overlayColor") || "rgb(0,0,0)", d.style.opacity = `${s("overlayOpacity")}`, d.style.pointerEvents = "auto", d.style.cursor = "auto", i.appendChild(d), i;
139
- }
140
- function ie(e) {
141
- const o = window.innerWidth, t = window.innerHeight, i = s("stagePadding") || 0, d = s("stageRadius") || 0, n = e.width + i * 2, f = e.height + i * 2, w = Math.min(d, n / 2, f / 2), r = Math.floor(Math.max(w, 0)), v = e.x - i + r, g = e.y - i, y = n - r * 2, a = f - r * 2;
142
- return `M${o},0L0,0L0,${t}L${o},${t}L${o},0Z
143
- M${v},${g} h${y} a${r},${r} 0 0 1 ${r},${r} v${a} a${r},${r} 0 0 1 -${r},${r} h-${y} a${r},${r} 0 0 1 -${r},-${r} v-${a} a${r},${r} 0 0 1 ${r},-${r} z`;
144
- }
145
- function me() {
146
- const e = l("__overlaySvg");
147
- e && e.remove();
148
- }
149
- function ye() {
150
- const e = document.getElementById("driver-dummy-element");
151
- if (e)
152
- return e;
153
- let o = document.createElement("div");
154
- return o.id = "driver-dummy-element", o.style.width = "0", o.style.height = "0", o.style.pointerEvents = "none", o.style.opacity = "0", o.style.position = "fixed", o.style.top = "50%", o.style.left = "50%", document.body.appendChild(o), o;
155
- }
156
- function j(e) {
157
- const { element: o } = e;
158
- let t = typeof o == "function" ? o() : typeof o == "string" ? document.querySelector(o) : o;
159
- t || (t = ye()), be(t, e);
160
- }
161
- function xe() {
162
- const e = l("__activeElement"), o = l("__activeStep");
163
- e && (te(e), he(), ae(e, o));
164
- }
165
- function be(e, o) {
166
- var C;
167
- const i = Date.now(), d = l("__activeStep"), n = l("__activeElement") || e, f = !n || n === e, w = e.id === "driver-dummy-element", r = n.id === "driver-dummy-element", v = s("animate"), g = o.onHighlightStarted || s("onHighlightStarted"), y = (o == null ? void 0 : o.onHighlighted) || s("onHighlighted"), a = (d == null ? void 0 : d.onDeselected) || s("onDeselected"), p = s(), c = l();
168
- !f && a && a(r ? void 0 : n, d, {
169
- config: p,
170
- state: c,
171
- driver: _()
172
- }), g && g(w ? void 0 : e, o, {
173
- config: p,
174
- state: c,
175
- driver: _()
176
- });
177
- const u = !f && v;
178
- let h = !1;
179
- _e(), k("previousStep", d), k("previousElement", n), k("activeStep", o), k("activeElement", e);
180
- const m = () => {
181
- if (l("__transitionCallback") !== m)
182
- return;
183
- const b = Date.now() - i, E = 400 - b <= 400 / 2;
184
- o.popover && E && !h && u && (Q(e, o), h = !0), s("animate") && b < 400 ? fe(b, 400, n, e) : (te(e), y && y(w ? void 0 : e, o, {
185
- config: s(),
186
- state: l(),
187
- driver: _()
188
- }), k("__transitionCallback", void 0), k("__previousStep", d), k("__previousElement", n), k("__activeStep", o), k("__activeElement", e)), window.requestAnimationFrame(m);
189
- };
190
- k("__transitionCallback", m), window.requestAnimationFrame(m), ee(e), !u && o.popover && Q(e, o), n.classList.remove("driver-active-element", "driver-no-interaction"), n.removeAttribute("aria-haspopup"), n.removeAttribute("aria-expanded"), n.removeAttribute("aria-controls"), ((C = o.disableActiveInteraction) != null ? C : s("disableActiveInteraction")) && e.classList.add("driver-no-interaction"), e.classList.add("driver-active-element"), e.setAttribute("aria-haspopup", "dialog"), e.setAttribute("aria-expanded", "true"), e.setAttribute("aria-controls", "driver-popover-content");
191
- }
192
- function Ce() {
193
- var e;
194
- (e = document.getElementById("driver-dummy-element")) == null || e.remove(), document.querySelectorAll(".driver-active-element").forEach((o) => {
195
- o.classList.remove("driver-active-element", "driver-no-interaction"), o.removeAttribute("aria-haspopup"), o.removeAttribute("aria-expanded"), o.removeAttribute("aria-controls");
196
- });
197
- }
198
- function M() {
199
- const e = l("__resizeTimeout");
200
- e && window.cancelAnimationFrame(e), k("__resizeTimeout", window.requestAnimationFrame(xe));
201
- }
202
- function Pe(e) {
203
- var r;
204
- if (!l("isInitialized") || !(e.key === "Tab" || e.keyCode === 9))
205
- return;
206
- const i = l("__activeElement"), d = (r = l("popover")) == null ? void 0 : r.wrapper, n = U([
207
- ...d ? [d] : [],
208
- ...i ? [i] : []
209
- ]), f = n[0], w = n[n.length - 1];
210
- if (e.preventDefault(), e.shiftKey) {
211
- const v = n[n.indexOf(document.activeElement) - 1] || w;
212
- v == null || v.focus();
213
- } else {
214
- const v = n[n.indexOf(document.activeElement) + 1] || f;
215
- v == null || v.focus();
216
- }
217
- }
218
- function ne(e) {
219
- var t;
220
- ((t = s("allowKeyboardControl")) == null || t) && (e.key === "Escape" ? L("escapePress") : e.key === "ArrowRight" ? L("arrowRightPress") : e.key === "ArrowLeft" && L("arrowLeftPress"));
221
- }
222
- function re(e, o, t) {
223
- const i = (n, f) => {
224
- const w = n.target;
225
- e.contains(w) && ((!t || t(w)) && (n.preventDefault(), n.stopPropagation(), n.stopImmediatePropagation()), f == null || f(n));
226
- };
227
- document.addEventListener("pointerdown", i, !0), document.addEventListener("mousedown", i, !0), document.addEventListener("pointerup", i, !0), document.addEventListener("mouseup", i, !0), document.addEventListener(
228
- "click",
229
- (n) => {
230
- i(n, o);
231
- },
232
- !0
233
- );
234
- }
235
- function ke() {
236
- window.addEventListener("keyup", ne, !1), window.addEventListener("keydown", Pe, !1), window.addEventListener("resize", M), window.addEventListener("scroll", M);
237
- }
238
- function Se() {
239
- window.removeEventListener("keyup", ne), window.removeEventListener("resize", M), window.removeEventListener("scroll", M);
240
- }
241
- function _e() {
242
- const e = l("popover");
243
- e && (e.wrapper.style.display = "none");
244
- }
245
- function Q(e, o) {
246
- var b, P;
247
- let t = l("popover");
248
- t && document.body.removeChild(t.wrapper), t = Le(), document.body.appendChild(t.wrapper);
249
- const {
250
- title: i,
251
- description: d,
252
- showButtons: n,
253
- disableButtons: f,
254
- showProgress: w,
255
- nextBtnText: r = s("nextBtnText") || "Next &rarr;",
256
- prevBtnText: v = s("prevBtnText") || "&larr; Previous",
257
- progressText: g = s("progressText") || "{current} of {total}"
258
- } = o.popover || {};
259
- t.nextButton.innerHTML = r, t.previousButton.innerHTML = v, t.progress.innerHTML = g, i ? (t.title.innerHTML = i, t.title.style.display = "block") : t.title.style.display = "none", d ? (t.description.innerHTML = d, t.description.style.display = "block") : t.description.style.display = "none";
260
- const y = n || s("showButtons"), a = w || s("showProgress") || !1, p = (y == null ? void 0 : y.includes("next")) || (y == null ? void 0 : y.includes("previous")) || a;
261
- t.closeButton.style.display = y.includes("close") ? "block" : "none", p ? (t.footer.style.display = "flex", t.progress.style.display = a ? "block" : "none", t.nextButton.style.display = y.includes("next") ? "block" : "none", t.previousButton.style.display = y.includes("previous") ? "block" : "none") : t.footer.style.display = "none";
262
- const c = f || s("disableButtons") || [];
263
- c != null && c.includes("next") && (t.nextButton.disabled = !0, t.nextButton.classList.add("driver-popover-btn-disabled")), c != null && c.includes("previous") && (t.previousButton.disabled = !0, t.previousButton.classList.add("driver-popover-btn-disabled")), c != null && c.includes("close") && (t.closeButton.disabled = !0, t.closeButton.classList.add("driver-popover-btn-disabled"));
264
- const u = t.wrapper;
265
- u.style.display = "block", u.style.left = "", u.style.top = "", u.style.bottom = "", u.style.right = "", u.id = "driver-popover-content", u.setAttribute("role", "dialog"), u.setAttribute("aria-labelledby", "driver-popover-title"), u.setAttribute("aria-describedby", "driver-popover-description");
266
- const h = t.arrow;
267
- h.className = "driver-popover-arrow";
268
- const m = ((b = o.popover) == null ? void 0 : b.popoverClass) || s("popoverClass") || "";
269
- u.className = `driver-popover ${m}`.trim(), re(
270
- t.wrapper,
271
- (E) => {
272
- var B, R, W;
273
- const T = E.target, A = ((B = o.popover) == null ? void 0 : B.onNextClick) || s("onNextClick"), H = ((R = o.popover) == null ? void 0 : R.onPrevClick) || s("onPrevClick"), $ = ((W = o.popover) == null ? void 0 : W.onCloseClick) || s("onCloseClick");
274
- if (T.closest(".driver-popover-next-btn"))
275
- return A ? A(e, o, {
276
- config: s(),
277
- state: l(),
278
- driver: _()
279
- }) : L("nextClick");
280
- if (T.closest(".driver-popover-prev-btn"))
281
- return H ? H(e, o, {
282
- config: s(),
283
- state: l(),
284
- driver: _()
285
- }) : L("prevClick");
286
- if (T.closest(".driver-popover-close-btn"))
287
- return $ ? $(e, o, {
288
- config: s(),
289
- state: l(),
290
- driver: _()
291
- }) : L("closeClick");
292
- },
293
- (E) => !(t != null && t.description.contains(E)) && !(t != null && t.title.contains(E)) && typeof E.className == "string" && E.className.includes("driver-popover")
294
- ), k("popover", t);
295
- const x = ((P = o.popover) == null ? void 0 : P.onPopoverRender) || s("onPopoverRender");
296
- x && x(t, {
297
- config: s(),
298
- state: l(),
299
- driver: _()
300
- }), ae(e, o), ee(u);
301
- const C = e.classList.contains("driver-dummy-element"), S = U([u, ...C ? [] : [e]]);
302
- S.length > 0 && S[0].focus();
303
- }
304
- function se() {
305
- const e = l("popover");
306
- if (!(e != null && e.wrapper))
307
- return;
308
- const o = e.wrapper.getBoundingClientRect(), t = s("stagePadding") || 0, i = s("popoverOffset") || 0;
309
- return {
310
- width: o.width + t + i,
311
- height: o.height + t + i,
312
- realWidth: o.width,
313
- realHeight: o.height
314
- };
315
- }
316
- function Z(e, o) {
317
- const { elementDimensions: t, popoverDimensions: i, popoverPadding: d, popoverArrowDimensions: n } = o;
318
- return e === "start" ? Math.max(
319
- Math.min(
320
- t.top - d,
321
- window.innerHeight - i.realHeight - n.width
322
- ),
323
- n.width
324
- ) : e === "end" ? Math.max(
325
- Math.min(
326
- t.top - (i == null ? void 0 : i.realHeight) + t.height + d,
327
- window.innerHeight - (i == null ? void 0 : i.realHeight) - n.width
328
- ),
329
- n.width
330
- ) : e === "center" ? Math.max(
331
- Math.min(
332
- t.top + t.height / 2 - (i == null ? void 0 : i.realHeight) / 2,
333
- window.innerHeight - (i == null ? void 0 : i.realHeight) - n.width
334
- ),
335
- n.width
336
- ) : 0;
337
- }
338
- function G(e, o) {
339
- const { elementDimensions: t, popoverDimensions: i, popoverPadding: d, popoverArrowDimensions: n } = o;
340
- return e === "start" ? Math.max(
341
- Math.min(
342
- t.left - d,
343
- window.innerWidth - i.realWidth - n.width
344
- ),
345
- n.width
346
- ) : e === "end" ? Math.max(
347
- Math.min(
348
- t.left - (i == null ? void 0 : i.realWidth) + t.width + d,
349
- window.innerWidth - (i == null ? void 0 : i.realWidth) - n.width
350
- ),
351
- n.width
352
- ) : e === "center" ? Math.max(
353
- Math.min(
354
- t.left + t.width / 2 - (i == null ? void 0 : i.realWidth) / 2,
355
- window.innerWidth - (i == null ? void 0 : i.realWidth) - n.width
356
- ),
357
- n.width
358
- ) : 0;
359
- }
360
- function ae(e, o) {
361
- const t = l("popover");
362
- if (!t)
363
- return;
364
- const { align: i = "start", side: d = "left" } = (o == null ? void 0 : o.popover) || {}, n = i, f = e.id === "driver-dummy-element" ? "over" : d, w = s("stagePadding") || 0, r = se(), v = t.arrow.getBoundingClientRect(), g = e.getBoundingClientRect(), y = g.top - r.height;
365
- let a = y >= 0;
366
- const p = window.innerHeight - (g.bottom + r.height);
367
- let c = p >= 0;
368
- const u = g.left - r.width;
369
- let h = u >= 0;
370
- const m = window.innerWidth - (g.right + r.width);
371
- let x = m >= 0;
372
- const C = !a && !c && !h && !x;
373
- let S = f;
374
- if (f === "top" && a ? x = h = c = !1 : f === "bottom" && c ? x = h = a = !1 : f === "left" && h ? x = a = c = !1 : f === "right" && x && (h = a = c = !1), f === "over") {
375
- const b = window.innerWidth / 2 - r.realWidth / 2, P = window.innerHeight / 2 - r.realHeight / 2;
376
- t.wrapper.style.left = `${b}px`, t.wrapper.style.right = "auto", t.wrapper.style.top = `${P}px`, t.wrapper.style.bottom = "auto";
377
- } else if (C) {
378
- const b = window.innerWidth / 2 - (r == null ? void 0 : r.realWidth) / 2, P = 10;
379
- t.wrapper.style.left = `${b}px`, t.wrapper.style.right = "auto", t.wrapper.style.bottom = `${P}px`, t.wrapper.style.top = "auto";
380
- } else if (h) {
381
- const b = Math.min(
382
- u,
383
- window.innerWidth - (r == null ? void 0 : r.realWidth) - v.width
384
- ), P = Z(n, {
385
- elementDimensions: g,
386
- popoverDimensions: r,
387
- popoverPadding: w,
388
- popoverArrowDimensions: v
389
- });
390
- t.wrapper.style.left = `${b}px`, t.wrapper.style.top = `${P}px`, t.wrapper.style.bottom = "auto", t.wrapper.style.right = "auto", S = "left";
391
- } else if (x) {
392
- const b = Math.min(
393
- m,
394
- window.innerWidth - (r == null ? void 0 : r.realWidth) - v.width
395
- ), P = Z(n, {
396
- elementDimensions: g,
397
- popoverDimensions: r,
398
- popoverPadding: w,
399
- popoverArrowDimensions: v
400
- });
401
- t.wrapper.style.right = `${b}px`, t.wrapper.style.top = `${P}px`, t.wrapper.style.bottom = "auto", t.wrapper.style.left = "auto", S = "right";
402
- } else if (a) {
403
- const b = Math.min(
404
- y,
405
- window.innerHeight - r.realHeight - v.width
406
- );
407
- let P = G(n, {
408
- elementDimensions: g,
409
- popoverDimensions: r,
410
- popoverPadding: w,
411
- popoverArrowDimensions: v
412
- });
413
- t.wrapper.style.top = `${b}px`, t.wrapper.style.left = `${P}px`, t.wrapper.style.bottom = "auto", t.wrapper.style.right = "auto", S = "top";
414
- } else if (c) {
415
- const b = Math.min(
416
- p,
417
- window.innerHeight - (r == null ? void 0 : r.realHeight) - v.width
418
- );
419
- let P = G(n, {
420
- elementDimensions: g,
421
- popoverDimensions: r,
422
- popoverPadding: w,
423
- popoverArrowDimensions: v
424
- });
425
- t.wrapper.style.left = `${P}px`, t.wrapper.style.bottom = `${b}px`, t.wrapper.style.top = "auto", t.wrapper.style.right = "auto", S = "bottom";
426
- }
427
- C ? t.arrow.classList.add("driver-popover-arrow-none") : Ee(n, S, e);
428
- }
429
- function Ee(e, o, t) {
430
- const i = l("popover");
431
- if (!i)
432
- return;
433
- const d = t.getBoundingClientRect(), n = se(), f = i.arrow, w = n.width, r = window.innerWidth, v = d.width, g = d.left, y = n.height, a = window.innerHeight, p = d.top, c = d.height;
434
- f.className = "driver-popover-arrow";
435
- let u = o, h = e;
436
- if (o === "top" ? (g + v <= 0 ? (u = "right", h = "end") : g + v - w <= 0 && (u = "top", h = "start"), g >= r ? (u = "left", h = "end") : g + w >= r && (u = "top", h = "end")) : o === "bottom" ? (g + v <= 0 ? (u = "right", h = "start") : g + v - w <= 0 && (u = "bottom", h = "start"), g >= r ? (u = "left", h = "start") : g + w >= r && (u = "bottom", h = "end")) : o === "left" ? (p + c <= 0 ? (u = "bottom", h = "end") : p + c - y <= 0 && (u = "left", h = "start"), p >= a ? (u = "top", h = "end") : p + y >= a && (u = "left", h = "end")) : o === "right" && (p + c <= 0 ? (u = "bottom", h = "start") : p + c - y <= 0 && (u = "right", h = "start"), p >= a ? (u = "top", h = "start") : p + y >= a && (u = "right", h = "end")), !u)
437
- f.classList.add("driver-popover-arrow-none");
438
- else {
439
- f.classList.add(`driver-popover-arrow-side-${u}`), f.classList.add(`driver-popover-arrow-align-${h}`);
440
- const m = t.getBoundingClientRect(), x = f.getBoundingClientRect(), C = s("stagePadding") || 0, S = m.left - C < window.innerWidth && m.right + C > 0 && m.top - C < window.innerHeight && m.bottom + C > 0;
441
- o === "bottom" && S && (x.x > m.x && x.x + x.width < m.x + m.width ? i.wrapper.style.transform = "translateY(0)" : (f.classList.remove(`driver-popover-arrow-align-${h}`), f.classList.add("driver-popover-arrow-none"), i.wrapper.style.transform = `translateY(-${C / 2}px)`));
442
- }
443
- }
444
- function Le() {
445
- const e = document.createElement("div");
446
- e.classList.add("driver-popover");
447
- const o = document.createElement("div");
448
- o.classList.add("driver-popover-arrow");
449
- const t = document.createElement("header");
450
- t.id = "driver-popover-title", t.classList.add("driver-popover-title"), t.style.display = "none", t.innerText = "Popover Title";
451
- const i = document.createElement("div");
452
- i.id = "driver-popover-description", i.classList.add("driver-popover-description"), i.style.display = "none", i.innerText = "Popover description is here";
453
- const d = document.createElement("button");
454
- d.type = "button", d.classList.add("driver-popover-close-btn"), d.setAttribute("aria-label", "Close"), d.innerHTML = "&times;";
455
- const n = document.createElement("footer");
456
- n.classList.add("driver-popover-footer");
457
- const f = document.createElement("span");
458
- f.classList.add("driver-popover-progress-text"), f.innerText = "";
459
- const w = document.createElement("span");
460
- w.classList.add("driver-popover-navigation-btns");
461
- const r = document.createElement("button");
462
- r.type = "button", r.classList.add("driver-popover-prev-btn"), r.innerHTML = "&larr; Previous";
463
- const v = document.createElement("button");
464
- return v.type = "button", v.classList.add("driver-popover-next-btn"), v.innerHTML = "Next &rarr;", w.appendChild(r), w.appendChild(v), n.appendChild(f), n.appendChild(w), e.appendChild(d), e.appendChild(o), e.appendChild(t), e.appendChild(i), e.appendChild(n), {
465
- wrapper: e,
466
- arrow: o,
467
- title: t,
468
- description: i,
469
- footer: n,
470
- previousButton: r,
471
- nextButton: v,
472
- closeButton: d,
473
- footerButtons: w,
474
- progress: f
475
- };
476
- }
477
- function Te() {
478
- var o;
479
- const e = l("popover");
480
- e && ((o = e.wrapper.parentElement) == null || o.removeChild(e.wrapper));
481
- }
482
- function Ae(e = {}) {
483
- F(e);
484
- function o() {
485
- s("allowClose") && g();
486
- }
487
- function t() {
488
- const a = s("overlayClickBehavior");
489
- if (s("allowClose") && a === "close") {
490
- g();
491
- return;
492
- }
493
- a === "nextStep" && i();
494
- }
495
- function i() {
496
- const a = l("activeIndex"), p = s("steps") || [];
497
- if (typeof a == "undefined")
498
- return;
499
- const c = a + 1;
500
- p[c] ? v(c) : g();
501
- }
502
- function d() {
503
- const a = l("activeIndex"), p = s("steps") || [];
504
- if (typeof a == "undefined")
505
- return;
506
- const c = a - 1;
507
- p[c] ? v(c) : g();
508
- }
509
- function n(a) {
510
- (s("steps") || [])[a] ? v(a) : g();
511
- }
512
- function f() {
513
- var x;
514
- if (l("__transitionCallback"))
515
- return;
516
- const p = l("activeIndex"), c = l("__activeStep"), u = l("__activeElement");
517
- if (typeof p == "undefined" || typeof c == "undefined" || typeof l("activeIndex") == "undefined")
518
- return;
519
- const m = ((x = c.popover) == null ? void 0 : x.onPrevClick) || s("onPrevClick");
520
- if (m)
521
- return m(u, c, {
522
- config: s(),
523
- state: l(),
524
- driver: _()
525
- });
526
- d();
527
- }
528
- function w() {
529
- var m;
530
- if (l("__transitionCallback"))
531
- return;
532
- const p = l("activeIndex"), c = l("__activeStep"), u = l("__activeElement");
533
- if (typeof p == "undefined" || typeof c == "undefined")
534
- return;
535
- const h = ((m = c.popover) == null ? void 0 : m.onNextClick) || s("onNextClick");
536
- if (h)
537
- return h(u, c, {
538
- config: s(),
539
- state: l(),
540
- driver: _()
541
- });
542
- i();
543
- }
544
- function r() {
545
- l("isInitialized") || (k("isInitialized", !0), document.body.classList.add("driver-active", s("animate") ? "driver-fade" : "driver-simple"), ke(), N("overlayClick", t), N("escapePress", o), N("arrowLeftPress", f), N("arrowRightPress", w));
546
- }
547
- function v(a = 0) {
548
- var $, B, R, W, V, q, K, Y;
549
- const p = s("steps");
550
- if (!p) {
551
- console.error("No steps to drive through"), g();
552
- return;
553
- }
554
- if (!p[a]) {
555
- g();
556
- return;
557
- }
558
- k("__activeOnDestroyed", document.activeElement), k("activeIndex", a);
559
- const c = p[a], u = p[a + 1], h = p[a - 1], m = (($ = c.popover) == null ? void 0 : $.doneBtnText) || s("doneBtnText") || "Done", x = s("allowClose"), C = typeof ((B = c.popover) == null ? void 0 : B.showProgress) != "undefined" ? (R = c.popover) == null ? void 0 : R.showProgress : s("showProgress"), b = (((W = c.popover) == null ? void 0 : W.progressText) || s("progressText") || "{{current}} of {{total}}").replace("{{current}}", `${a + 1}`).replace("{{total}}", `${p.length}`), P = ((V = c.popover) == null ? void 0 : V.showButtons) || s("showButtons"), E = [
560
- "next",
561
- "previous",
562
- ...x ? ["close"] : []
563
- ].filter((ce) => !(P != null && P.length) || P.includes(ce)), T = ((q = c.popover) == null ? void 0 : q.onNextClick) || s("onNextClick"), A = ((K = c.popover) == null ? void 0 : K.onPrevClick) || s("onPrevClick"), H = ((Y = c.popover) == null ? void 0 : Y.onCloseClick) || s("onCloseClick");
564
- j({
565
- ...c,
566
- popover: {
567
- showButtons: E,
568
- nextBtnText: u ? void 0 : m,
569
- disableButtons: [...h ? [] : ["previous"]],
570
- showProgress: C,
571
- progressText: b,
572
- onNextClick: T || (() => {
573
- u ? v(a + 1) : g();
574
- }),
575
- onPrevClick: A || (() => {
576
- v(a - 1);
577
- }),
578
- onCloseClick: H || (() => {
579
- g();
580
- }),
581
- ...(c == null ? void 0 : c.popover) || {}
582
- }
583
- });
584
- }
585
- function g(a = !0) {
586
- const p = l("__activeElement"), c = l("__activeStep"), u = l("__activeOnDestroyed"), h = s("onDestroyStarted");
587
- if (a && h) {
588
- const C = !p || (p == null ? void 0 : p.id) === "driver-dummy-element";
589
- h(C ? void 0 : p, c, {
590
- config: s(),
591
- state: l(),
592
- driver: _()
593
- });
594
- return;
595
- }
596
- const m = (c == null ? void 0 : c.onDeselected) || s("onDeselected"), x = s("onDestroyed");
597
- if (document.body.classList.remove("driver-active", "driver-fade", "driver-simple"), Se(), Te(), Ce(), me(), de(), X(), p && c) {
598
- const C = p.id === "driver-dummy-element";
599
- m && m(C ? void 0 : p, c, {
600
- config: s(),
601
- state: l(),
602
- driver: _()
603
- }), x && x(C ? void 0 : p, c, {
604
- config: s(),
605
- state: l(),
606
- driver: _()
607
- });
608
- }
609
- u && u.focus();
610
- }
611
- const y = {
612
- isActive: () => l("isInitialized") || !1,
613
- refresh: M,
614
- drive: (a = 0) => {
615
- r(), v(a);
616
- },
617
- setConfig: F,
618
- setSteps: (a) => {
619
- X(), F({
620
- ...s(),
621
- steps: a
622
- });
623
- },
624
- getConfig: s,
625
- getState: l,
626
- getActiveIndex: () => l("activeIndex"),
627
- isFirstStep: () => l("activeIndex") === 0,
628
- isLastStep: () => {
629
- const a = s("steps") || [], p = l("activeIndex");
630
- return p !== void 0 && p === a.length - 1;
631
- },
632
- getActiveStep: () => l("activeStep"),
633
- getActiveElement: () => l("activeElement"),
634
- getPreviousElement: () => l("previousElement"),
635
- getPreviousStep: () => l("previousStep"),
636
- moveNext: i,
637
- movePrevious: d,
638
- moveTo: n,
639
- hasNextStep: () => {
640
- const a = s("steps") || [], p = l("activeIndex");
641
- return p !== void 0 && !!a[p + 1];
642
- },
643
- hasPreviousStep: () => {
644
- const a = s("steps") || [], p = l("activeIndex");
645
- return p !== void 0 && !!a[p - 1];
646
- },
647
- highlight: (a) => {
648
- r(), j({
649
- ...a,
650
- popover: a.popover ? {
651
- showButtons: [],
652
- showProgress: !1,
653
- progressText: "",
654
- ...a.popover
655
- } : void 0
656
- });
657
- },
658
- destroy: () => {
659
- g(!1);
660
- }
661
- };
662
- return le(y), y;
663
- }
664
- export {
665
- Ae as driver
666
- };