react-ajala
Advanced tools
Comparing version
@@ -1,8 +0,8 @@ | ||
import { jsxs as rt, jsx as Q } from "react/jsx-runtime"; | ||
import { createContext as ht, useState as N, useRef as X, useEffect as b, useContext as dt } from "react"; | ||
import { createPortal as F } from "react-dom"; | ||
var pt = Object.defineProperty, et = (l) => { | ||
import { jsxs as ot, jsx as K } from "react/jsx-runtime"; | ||
import { createContext as lt, useState as q, useRef as rt, useEffect as W, useContext as ht } from "react"; | ||
import { createPortal as Q } from "react-dom"; | ||
var dt = Object.defineProperty, k = (l) => { | ||
throw TypeError(l); | ||
}, _t = (l, t, e) => t in l ? pt(l, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : l[t] = e, p = (l, t, e) => _t(l, typeof t != "symbol" ? t + "" : t, e), Y = (l, t, e) => t.has(l) || et("Cannot " + e), _ = (l, t, e) => (Y(l, t, "read from private field"), e ? e.call(l) : t.get(l)), E = (l, t, e) => t.has(l) ? et("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(l) : t.set(l, e), L = (l, t, e, a) => (Y(l, t, "write to private field"), t.set(l, e), e), y = (l, t, e) => (Y(l, t, "access private method"), e); | ||
function vt(l) { | ||
}, pt = (l, t, e) => t in l ? dt(l, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : l[t] = e, p = (l, t, e) => pt(l, typeof t != "symbol" ? t + "" : t, e), V = (l, t, e) => t.has(l) || k("Cannot " + e), _ = (l, t, e) => (V(l, t, "read from private field"), e ? e.call(l) : t.get(l)), E = (l, t, e) => t.has(l) ? k("Cannot add the same private member more than once") : t instanceof WeakSet ? t.add(l) : t.set(l, e), L = (l, t, e, a) => (V(l, t, "write to private field"), t.set(l, e), e), y = (l, t, e) => (V(l, t, "access private method"), e); | ||
function _t(l) { | ||
const t = /* @__PURE__ */ new Map(), e = [], a = []; | ||
@@ -17,3 +17,3 @@ for (const n of l) | ||
} | ||
function k(l) { | ||
function X(l) { | ||
const t = {}, e = [ | ||
@@ -46,3 +46,3 @@ "id", | ||
} | ||
function M(l, t, e) { | ||
function I(l, t, e) { | ||
const a = JSON.parse(JSON.stringify(l)); | ||
@@ -54,5 +54,5 @@ return t.forEach((s) => { | ||
o > -1 && (a[o][s.key] = s[e]); | ||
}), vt(a); | ||
}), _t(a); | ||
} | ||
function tt(l, t) { | ||
function F(l, t) { | ||
let e = JSON.parse( | ||
@@ -62,3 +62,3 @@ JSON.stringify(l) | ||
return Object.values(t).forEach((a) => { | ||
a && (e = M( | ||
a && (e = I( | ||
e, | ||
@@ -71,3 +71,3 @@ a, | ||
const A = (l, t, e) => (e = Math.max(0, Math.min(1, e)), l + (t - l) * e); | ||
function mt(l, t) { | ||
function vt(l, t) { | ||
let e = null; | ||
@@ -80,3 +80,3 @@ return function(...a) { | ||
} | ||
function B(l) { | ||
function b(l) { | ||
const t = /* @__PURE__ */ new Set(), e = []; | ||
@@ -93,6 +93,6 @@ for (let a = 0; a < l.length; a++) { | ||
} | ||
var P, it, at, nt; | ||
class gt { | ||
var M, tt, et, it; | ||
class mt { | ||
constructor(t) { | ||
E(this, P), p(this, "ajala"), p(this, "tooltip_element"), p(this, "wrapper_element"), p(this, "tooltip_container_element"), p(this, "arrow_element"), p(this, "overlay_element"), p(this, "overlay_path"), p(this, "next_btn"), p(this, "prev_btn"), p(this, "close_btn"), p(this, "is_default_tooltip_element"), p(this, "navigation"), p(this, "placement"), this.ajala = t, this.wrapper_element = document.createElement("div"), this.is_default_tooltip_element = !1, this.tooltip_element = this.ajala.options.custom_tooltip || document.createElement("div"), this.tooltip_container_element = document.createElement("div"), this.overlay_element = document.createElementNS( | ||
E(this, M), p(this, "ajala"), p(this, "tooltip_element"), p(this, "wrapper_element"), p(this, "tooltip_container_element"), p(this, "arrow_element"), p(this, "overlay_element"), p(this, "overlay_path"), p(this, "next_btn"), p(this, "prev_btn"), p(this, "close_btn"), p(this, "is_default_tooltip_element"), p(this, "navigation"), p(this, "placement"), this.ajala = t, this.wrapper_element = document.createElement("div"), this.is_default_tooltip_element = !1, this.tooltip_element = this.ajala.options.custom_tooltip || document.createElement("div"), this.tooltip_container_element = document.createElement("div"), this.overlay_element = document.createElementNS( | ||
"http://www.w3.org/2000/svg", | ||
@@ -103,3 +103,3 @@ "svg" | ||
"path" | ||
), this.arrow_element = document.createElement("div"), this.next_btn = null, this.prev_btn = null, this.close_btn = null, this.closeOnOverlayClickHandler = this.closeOnOverlayClickHandler.bind(this), this.refresh = mt(this.refresh.bind(this), 200); | ||
), this.arrow_element = document.createElement("div"), this.next_btn = null, this.prev_btn = null, this.close_btn = null, this.closeOnOverlayClickHandler = this.closeOnOverlayClickHandler.bind(this), this.refresh = vt(this.refresh.bind(this), 200); | ||
} | ||
@@ -114,3 +114,3 @@ init() { | ||
this.closeOnOverlayClickHandler | ||
), this.ajala.options.custom_tooltip || y(this, P, it).call(this), this.ajala.options.custom_arrow ? this.arrow_element.appendChild(this.ajala.options.custom_arrow) : y(this, P, at).call(this); | ||
), this.ajala.options.custom_tooltip || y(this, M, tt).call(this), this.ajala.options.custom_arrow ? this.arrow_element.appendChild(this.ajala.options.custom_arrow) : y(this, M, et).call(this); | ||
const r = (t = this.ajala.options.default_arrow_options) != null && t.size ? `${(e = this.ajala.options.default_arrow_options) == null ? void 0 : e.size}px` : "48px"; | ||
@@ -135,3 +135,3 @@ this.arrow_element.style.position = "absolute", this.arrow_element.style.width = r, this.arrow_element.style.height = r, this.arrow_element.style.top = "0px", this.arrow_element.style.left = "0px", this.arrow_element.style.fill = ((a = this.ajala.options.default_arrow_options) == null ? void 0 : a.color) || "#000000", this.arrow_element.style.zIndex = "2", this.arrow_element.style.pointerEvents = "none", this.arrow_element.classList.add("ajala_tooltip_arrow"), (s = this.ajala.options.default_arrow_options) != null && s.hide || this.tooltip_container_element.appendChild(this.arrow_element), this.tooltip_container_element.style.position = "fixed", this.tooltip_container_element.style.top = "0px", this.tooltip_container_element.style.left = "0px", this.tooltip_container_element.style.zIndex = "20", this.tooltip_container_element.style.width = (o = this.ajala.options) != null && o.tooltip_width ? `${(i = this.ajala.options) == null ? void 0 : i.tooltip_width}px` : "250px", this.tooltip_container_element.style.height = (n = this.ajala.options) != null && n.tooltip_height ? `${(d = this.ajala.options) == null ? void 0 : d.tooltip_height}px` : "180px", this.tooltip_container_element.style.pointerEvents = "auto", this.tooltip_container_element.classList.add("ajala_tooltip_container"), this.tooltip_container_element.appendChild(this.tooltip_element), this.tooltip_container_element.style.transform = "translate(0px, 0px)", this.wrapper_element.style.position = "fixed", this.wrapper_element.style.top = "0px", this.wrapper_element.style.left = "0px", this.wrapper_element.style.zIndex = "9999999", this.wrapper_element.classList.add("ajala"), this.wrapper_element.append(this.tooltip_container_element); | ||
`, document.head.appendChild(m), (typeof ((h = this.ajala.options.overlay_options) == null ? void 0 : h.hide) > "u" || !((v = this.ajala.options.overlay_options) != null && v.hide)) && (y(this, P, nt).call(this), this.wrapper_element.append(this.overlay_element), document.body.classList.add("ajala_isOverlay")); | ||
`, document.head.appendChild(m), (typeof ((h = this.ajala.options.overlay_options) == null ? void 0 : h.hide) > "u" || !((v = this.ajala.options.overlay_options) != null && v.hide)) && (y(this, M, it).call(this), this.wrapper_element.append(this.overlay_element), document.body.classList.add("ajala_isOverlay")); | ||
} | ||
@@ -278,3 +278,3 @@ update(t) { | ||
} | ||
P = /* @__PURE__ */ new WeakSet(), it = function() { | ||
M = /* @__PURE__ */ new WeakSet(), tt = function() { | ||
var l, t, e, a, s, o; | ||
@@ -318,3 +318,3 @@ this.is_default_tooltip_element = !0; | ||
</div>`, this.next_btn = this.tooltip_element.querySelector(".ajala_btn_next"), this.prev_btn = this.tooltip_element.querySelector(".ajala_btn_prev"), this.close_btn = this.tooltip_element.querySelector(".ajala_close_btn"), i != null && i.class_name && this.tooltip_element.classList.add(i.class_name), i != null && i.hide_dot_nav && ((e = this.tooltip_element.querySelector(".ajala_dot_navs")) == null || e.remove()), i != null && i.hide_title && ((a = this.tooltip_element.querySelector(".ajala_title")) == null || a.remove()), i != null && i.hide_content && ((s = this.tooltip_element.querySelector(".ajala_content")) == null || s.remove()), i != null && i.hide_close_btn && ((o = this.close_btn) == null || o.remove()); | ||
}, at = function() { | ||
}, et = function() { | ||
var l, t; | ||
@@ -325,3 +325,3 @@ const e = (l = this.ajala.options.default_arrow_options) != null && l.size ? `${(t = this.ajala.options.default_arrow_options) == null ? void 0 : t.size}px` : "48px"; | ||
`; | ||
}, nt = function() { | ||
}, it = function() { | ||
var l, t, e; | ||
@@ -337,3 +337,3 @@ const a = ((t = (l = this.ajala.options.overlay_options) == null ? void 0 : l.opacity) == null ? void 0 : t.toString()) || " 0.7", s = ((e = this.ajala.options.overlay_options) == null ? void 0 : e.color) || " black"; | ||
}; | ||
class ut { | ||
class gt { | ||
constructor({ ajala: t, ui: e }) { | ||
@@ -487,3 +487,3 @@ p(this, "ajala"), p(this, "ui"), p(this, "placement"), p(this, "animations"), this.ajala = t, this.ui = e, this.next = this.next.bind(this), this.prev = this.prev.bind(this), this.close = this.close.bind(this); | ||
} | ||
class ct { | ||
class ut { | ||
constructor() { | ||
@@ -535,3 +535,3 @@ p(this, "_listeners"); | ||
var T; | ||
class ft { | ||
class ct { | ||
constructor({ | ||
@@ -592,4 +592,4 @@ ajala: t, | ||
T = /* @__PURE__ */ new WeakMap(); | ||
var C, R, z, U, J; | ||
class yt { | ||
var C, N, B, z, U; | ||
class ft { | ||
constructor({ | ||
@@ -610,3 +610,3 @@ ajala: t, | ||
let n = i.getBoundingClientRect(); | ||
const d = (f) => f > 0 ? -f : Math.abs(f); | ||
const d = (c) => c > 0 ? -c : Math.abs(c); | ||
if (!o) | ||
@@ -662,3 +662,3 @@ return { | ||
placement: v | ||
} = this.placement.getMetadata({ next_index: e }), r = y(this, C, z).call(this, { | ||
} = this.placement.getMetadata({ next_index: e }), r = y(this, C, B).call(this, { | ||
axis: i, | ||
@@ -668,6 +668,6 @@ target: t, | ||
spotlight_padding: h.padding | ||
}), m = y(this, C, U).call(this, { | ||
}), m = y(this, C, z).call(this, { | ||
align: n, | ||
target: t | ||
}), g = y(this, C, J).call(this, { | ||
}), g = y(this, C, U).call(this, { | ||
align: n, | ||
@@ -680,3 +680,3 @@ target: t | ||
else { | ||
const { auto_x_delta: x, auto_y_delta: u, auto_placement: f } = y(this, C, R).call(this, { | ||
const { auto_x_delta: x, auto_y_delta: u, auto_placement: c } = y(this, C, N).call(this, { | ||
target: t, | ||
@@ -686,3 +686,3 @@ axis_gutter: d, | ||
}); | ||
a = x, s = u, o = f; | ||
a = x, s = u, o = c; | ||
} | ||
@@ -693,3 +693,3 @@ else if (i === "left" || i === "right") | ||
else { | ||
const { auto_x_delta: x, auto_y_delta: u, auto_placement: f } = y(this, C, R).call(this, { | ||
const { auto_x_delta: x, auto_y_delta: u, auto_placement: c } = y(this, C, N).call(this, { | ||
target: t, | ||
@@ -699,6 +699,6 @@ axis_gutter: d, | ||
}); | ||
a = x, s = u, o = f; | ||
a = x, s = u, o = c; | ||
} | ||
else { | ||
const { auto_x_delta: x, auto_y_delta: u, auto_placement: f } = y(this, C, R).call(this, { | ||
const { auto_x_delta: x, auto_y_delta: u, auto_placement: c } = y(this, C, N).call(this, { | ||
target: t, | ||
@@ -708,3 +708,3 @@ axis_gutter: d, | ||
}); | ||
a = x, s = u, o = f; | ||
a = x, s = u, o = c; | ||
} | ||
@@ -720,3 +720,3 @@ return { | ||
} | ||
C = /* @__PURE__ */ new WeakSet(), R = function({ | ||
C = /* @__PURE__ */ new WeakSet(), N = function({ | ||
target: l, | ||
@@ -743,3 +743,3 @@ axis_gutter: t, | ||
i = a[n]; | ||
const d = i.split("_"), h = d[0], v = d[1], r = y(this, C, z).call(this, { | ||
const d = i.split("_"), h = d[0], v = d[1], r = y(this, C, B).call(this, { | ||
axis: h, | ||
@@ -749,6 +749,6 @@ target: l, | ||
spotlight_padding: e | ||
}), m = y(this, C, U).call(this, { | ||
}), m = y(this, C, z).call(this, { | ||
align: v, | ||
target: l | ||
}), g = y(this, C, J).call(this, { | ||
}), g = y(this, C, U).call(this, { | ||
align: v, | ||
@@ -772,3 +772,3 @@ target: l | ||
}; | ||
}, z = function({ | ||
}, B = function({ | ||
axis: l, | ||
@@ -800,3 +800,3 @@ target: t, | ||
return i; | ||
}, U = function({ | ||
}, z = function({ | ||
align: l, | ||
@@ -818,3 +818,3 @@ target: t | ||
return s; | ||
}, J = function({ | ||
}, U = function({ | ||
align: l, | ||
@@ -837,3 +837,3 @@ target: t | ||
}; | ||
class xt { | ||
class yt { | ||
constructor({ | ||
@@ -869,5 +869,5 @@ ajala: t, | ||
} | ||
class wt { | ||
class xt { | ||
constructor({ ajala: t, ui: e }) { | ||
p(this, "ajala"), p(this, "arrow"), p(this, "tooltip"), p(this, "overlay_cutout_svg_rect"), p(this, "ui"), p(this, "animations"), this.arrow = new ft({ ajala: t, ui: e, placement: this }), this.tooltip = new yt({ ajala: t, ui: e, placement: this }), this.overlay_cutout_svg_rect = new xt({ | ||
p(this, "ajala"), p(this, "arrow"), p(this, "tooltip"), p(this, "overlay_cutout_svg_rect"), p(this, "ui"), p(this, "animations"), this.arrow = new ct({ ajala: t, ui: e, placement: this }), this.tooltip = new ft({ ajala: t, ui: e, placement: this }), this.overlay_cutout_svg_rect = new yt({ | ||
ajala: t, | ||
@@ -898,4 +898,4 @@ ui: e, | ||
} | ||
var D, V; | ||
class jt { | ||
var R, J; | ||
class wt { | ||
constructor({ | ||
@@ -906,3 +906,3 @@ ajala: t, | ||
}) { | ||
E(this, D), p(this, "ajala"), p(this, "ui"), p(this, "placement"), p(this, "transition_type"), p(this, "is_animating", !1), p(this, "transition"); | ||
E(this, R), p(this, "ajala"), p(this, "ui"), p(this, "placement"), p(this, "transition_type"), p(this, "is_animating", !1), p(this, "transition"); | ||
var s; | ||
@@ -938,4 +938,4 @@ this.ajala = t, this.ui = e, this.placement = a, this.transition_type = ((s = this.ajala.options) == null ? void 0 : s.transition_type) || "traveller", this.transition = { | ||
if (!d) return; | ||
const g = m - n, x = Math.min(g / a, 1), u = v(x), f = A(t, e, u); | ||
o(f), x < 1 ? (h = requestAnimationFrame(r), this.is_animating = !0) : (i(), this.is_animating = !1); | ||
const g = m - n, x = Math.min(g / a, 1), u = v(x), c = A(t, e, u); | ||
o(c), x < 1 ? (h = requestAnimationFrame(r), this.is_animating = !0) : (i(), this.is_animating = !1); | ||
}; | ||
@@ -1014,3 +1014,3 @@ return h = requestAnimationFrame(r), { | ||
to: 1, | ||
duration: y(this, D, V).call(this, v), | ||
duration: y(this, R, J).call(this, v), | ||
onUpdate(r) { | ||
@@ -1039,3 +1039,3 @@ const m = (h == null ? void 0 : h.x) ?? 0, g = (h == null ? void 0 : h.y) ?? 0, x = m + (o + i) * r, u = g + (n + d) * r; | ||
to: 1, | ||
duration: y(this, D, V).call(this, n), | ||
duration: y(this, R, J).call(this, n), | ||
onUpdate(d) { | ||
@@ -1054,24 +1054,24 @@ s.style.visibility = "visible", s.style.transform = `translate(${o}px, ${i}px) scale(${d})`; | ||
} | ||
D = /* @__PURE__ */ new WeakSet(), V = function(l) { | ||
R = /* @__PURE__ */ new WeakSet(), J = function(l) { | ||
var t, e; | ||
return ((t = this.ajala.getFlattenSteps()[l]) == null ? void 0 : t.transition_duration) ?? ((e = this.ajala.options) == null ? void 0 : e.transition_duration) ?? 1e3; | ||
}; | ||
var j, w, c, O, H, W, st, ot; | ||
class St extends ct { | ||
var j, w, f, O, P, D, at, nt; | ||
class jt extends ut { | ||
constructor(t, { start_immediately: e = !0, ...a } = { | ||
start_immediately: !0 | ||
}) { | ||
super(), E(this, W), p(this, "options"), p(this, "is_active"), p(this, "initialized"), p(this, "original_steps"), p(this, "flatten_steps"), E(this, j), p(this, "active_step"), E(this, w), E(this, c), E(this, O), E(this, H); | ||
const s = B(t); | ||
super(), E(this, D), p(this, "options"), p(this, "is_active"), p(this, "initialized"), p(this, "original_steps"), p(this, "flatten_steps"), E(this, j), p(this, "active_step"), E(this, w), E(this, f), E(this, O), E(this, P); | ||
const s = b(t); | ||
this.options = { start_immediately: e, ...a }, this.is_active = !!this.options.start_immediately, this.original_steps = s, L(this, j, { | ||
instances: [], | ||
queries: {} | ||
}), this.flatten_steps = [], this.initialized = !0, this.active_step = this.flatten_steps[0], L(this, w, new gt(this)), L(this, c, new ut({ | ||
}), this.flatten_steps = [], this.initialized = !0, this.active_step = this.flatten_steps[0], L(this, w, new mt(this)), L(this, f, new gt({ | ||
ajala: this, | ||
ui: _(this, w) | ||
})), L(this, O, new wt({ ajala: this, ui: _(this, w) })), L(this, H, new jt({ | ||
})), L(this, O, new xt({ ajala: this, ui: _(this, w) })), L(this, P, new wt({ | ||
ajala: this, | ||
ui: _(this, w), | ||
placement: _(this, O) | ||
})), _(this, w).navigation = _(this, c), _(this, w).placement = _(this, O), _(this, c).placement = _(this, O), _(this, c).animations = _(this, H), _(this, O).animations = _(this, H), this.active_step = this.getFlattenSteps()[_(this, c).getValidNavIndex(0, "next")], this.destroy = this.destroy.bind(this); | ||
})), _(this, w).navigation = _(this, f), _(this, w).placement = _(this, O), _(this, f).placement = _(this, O), _(this, f).animations = _(this, P), _(this, O).animations = _(this, P), this.active_step = this.getFlattenSteps()[_(this, f).getValidNavIndex(0, "next")], this.destroy = this.destroy.bind(this); | ||
} | ||
@@ -1083,10 +1083,10 @@ /** | ||
this.initialized = !0; | ||
const e = B(this.original_steps); | ||
const e = b(this.original_steps); | ||
this.is_active = !!this.options.start_immediately, this.original_steps = e, L(this, j, { | ||
instances: [], | ||
queries: k(e) | ||
}), this.flatten_steps = tt( | ||
queries: X(e) | ||
}), this.flatten_steps = F( | ||
e, | ||
_(this, j).queries | ||
), y(this, W, ot).call(this), this.active_step = this.getFlattenSteps()[_(this, c).getValidNavIndex(0, "next")], this.is_active = !!this.options.start_immediately, _(this, w).init(), _(this, c).init(), (this.options.start_immediately || t) && this.start(); | ||
), y(this, D, nt).call(this), this.active_step = this.getFlattenSteps()[_(this, f).getValidNavIndex(0, "next")], this.is_active = !!this.options.start_immediately, _(this, w).init(), _(this, f).init(), (this.options.start_immediately || t) && this.start(); | ||
} | ||
@@ -1141,7 +1141,7 @@ /** | ||
updateSteps(t, e = !0) { | ||
const a = B(t); | ||
const a = b(t); | ||
this.original_steps = a, L(this, j, { | ||
instances: [], | ||
queries: k(a) | ||
}), this.flatten_steps = tt( | ||
queries: X(a) | ||
}), this.flatten_steps = F( | ||
a, | ||
@@ -1187,3 +1187,3 @@ _(this, j).queries | ||
start() { | ||
this.is_active = !0, this.active_step = this.getFlattenSteps()[_(this, c).getValidNavIndex(0, "next")], _(this, w).start(), _(this, c).start(), this.dispatchEvent({ | ||
this.is_active = !0, this.active_step = this.getFlattenSteps()[_(this, f).getValidNavIndex(0, "next")], _(this, w).start(), _(this, f).start(), this.dispatchEvent({ | ||
type: "onStart", | ||
@@ -1204,3 +1204,3 @@ data: this | ||
next() { | ||
this.is_active && _(this, c).next(); | ||
this.is_active && _(this, f).next(); | ||
} | ||
@@ -1211,3 +1211,3 @@ /** | ||
prev() { | ||
this.is_active && _(this, c).prev(); | ||
this.is_active && _(this, f).prev(); | ||
} | ||
@@ -1218,3 +1218,3 @@ /** | ||
close() { | ||
_(this, c).close(); | ||
_(this, f).close(); | ||
} | ||
@@ -1228,3 +1228,3 @@ /** | ||
const e = this.getFlattenSteps().findIndex((a) => a.id === t); | ||
e > -1 && _(this, c).goTo(e); | ||
e > -1 && _(this, f).goTo(e); | ||
} | ||
@@ -1241,10 +1241,10 @@ /** | ||
destroy() { | ||
y(this, W, st).call(this), _(this, w).destroy(), this.is_active = !1; | ||
y(this, D, at).call(this), _(this, w).destroy(), this.is_active = !1; | ||
} | ||
} | ||
j = /* @__PURE__ */ new WeakMap(), w = /* @__PURE__ */ new WeakMap(), c = /* @__PURE__ */ new WeakMap(), O = /* @__PURE__ */ new WeakMap(), H = /* @__PURE__ */ new WeakMap(), W = /* @__PURE__ */ new WeakSet(), st = function() { | ||
j = /* @__PURE__ */ new WeakMap(), w = /* @__PURE__ */ new WeakMap(), f = /* @__PURE__ */ new WeakMap(), O = /* @__PURE__ */ new WeakMap(), P = /* @__PURE__ */ new WeakMap(), D = /* @__PURE__ */ new WeakSet(), at = function() { | ||
_(this, j).instances.forEach((l) => { | ||
l.onchange = null; | ||
}), _(this, w).cleanUp(), _(this, c).cleanUp(); | ||
}, ot = function() { | ||
}), _(this, w).cleanUp(), _(this, f).cleanUp(); | ||
}, nt = function() { | ||
for (const [l, t] of Object.entries( | ||
@@ -1254,3 +1254,3 @@ _(this, j).queries | ||
const e = window.matchMedia(l); | ||
e.matches && (this.flatten_steps = M( | ||
e.matches && (this.flatten_steps = I( | ||
this.flatten_steps, | ||
@@ -1261,7 +1261,7 @@ t, | ||
const s = _(this, j).queries[a.media]; | ||
a.matches && s ? this.flatten_steps = M( | ||
a.matches && s ? this.flatten_steps = I( | ||
this.flatten_steps, | ||
s, | ||
"value" | ||
) : (s && (this.flatten_steps = M( | ||
) : (s && (this.flatten_steps = I( | ||
this.flatten_steps, | ||
@@ -1272,3 +1272,3 @@ s, | ||
const i = _(this, j).queries[o.media]; | ||
o.matches && i && (this.flatten_steps = M( | ||
o.matches && i && (this.flatten_steps = I( | ||
this.flatten_steps, | ||
@@ -1279,3 +1279,3 @@ i, | ||
})), _(this, w).update(), this.goToStep( | ||
this.getFlattenSteps()[_(this, c).getValidNavIndex(0, "next")].id | ||
this.getFlattenSteps()[_(this, f).getValidNavIndex(0, "next")].id | ||
); | ||
@@ -1285,4 +1285,4 @@ }, _(this, j).instances.push(e); | ||
}; | ||
const lt = ht(null); | ||
function At({ | ||
const st = lt(null); | ||
function Lt({ | ||
children: l, | ||
@@ -1296,29 +1296,29 @@ getInstance: t, | ||
}) { | ||
const [n, d] = N( | ||
const [n, d] = q( | ||
{} | ||
), [h, v] = N(), [r, m] = N(null), [g, x] = N(null), u = X(!0), f = X(null); | ||
return b(() => { | ||
let $ = null, I = null; | ||
f.current = document.createElement("div"), a && ($ = f.current), s && (I = f.current); | ||
const q = { | ||
), [h, v] = q(), [r, m] = q(null), [g, x] = q(null), u = rt(null); | ||
return W(() => { | ||
let c = null, $ = null; | ||
u.current = document.createElement("div"), a && (c = u.current), s && ($ = u.current); | ||
const H = { | ||
...o, | ||
custom_tooltip: $, | ||
custom_arrow: I | ||
}, S = new St(e, q); | ||
custom_tooltip: c, | ||
custom_arrow: $ | ||
}, S = new jt(e, H); | ||
return S.init(), t && t(S), d(S), () => { | ||
S.destroy(); | ||
}; | ||
}, []), b(() => { | ||
}, []), W(() => { | ||
if (!(n != null && n.initialized)) return; | ||
const $ = () => { | ||
const c = () => { | ||
v(n.getActiveStep()); | ||
}, I = () => { | ||
}, $ = () => { | ||
v(n.getActiveStep()); | ||
}, q = (S) => { | ||
var Z, G, K; | ||
m((Z = S == null ? void 0 : S.data) == null ? void 0 : Z.tooltip_container_element), x((G = S == null ? void 0 : S.data) == null ? void 0 : G.arrow_element), (K = f.current) == null || K.remove(); | ||
}, H = (S) => { | ||
var Y, Z, G; | ||
m((Y = S == null ? void 0 : S.data) == null ? void 0 : Y.tooltip_container_element), x((Z = S == null ? void 0 : S.data) == null ? void 0 : Z.arrow_element), (G = u.current) == null || G.remove(); | ||
}; | ||
return n.addEventListener("onAfterDomInsert", q), n.addEventListener("onStart", $), n.addEventListener( | ||
return n.addEventListener("onAfterDomInsert", H), n.addEventListener("onStart", c), n.addEventListener( | ||
"onTransitionComplete", | ||
I | ||
$ | ||
), i != null && i.onStart && n.addEventListener("onStart", i.onStart), i != null && i.onFinish && n.addEventListener("onFinish", i.onFinish), i != null && i.onClose && n.addEventListener("onClose", i.onClose), i != null && i.onNext && n.addEventListener("onNext", i.onNext), i != null && i.onPrev && n.addEventListener("onPrev", i.onPrev), i != null && i.onTransitionComplete && n.addEventListener( | ||
@@ -1328,8 +1328,8 @@ "onTransitionComplete", | ||
), () => { | ||
n != null && n.initialized && (n.removeEventListener("onStart", $), n.removeEventListener( | ||
n != null && n.initialized && (n.removeEventListener("onStart", c), n.removeEventListener( | ||
"onAfterDomInsert", | ||
q | ||
H | ||
), n.removeEventListener( | ||
"onTransitionComplete", | ||
I | ||
$ | ||
), i != null && i.onStart && n.removeEventListener("onStart", i.onStart), i != null && i.onFinish && n.removeEventListener("onFinish", i.onFinish), i != null && i.onClose && n.removeEventListener("onClose", i.onClose), i != null && i.onNext && n.removeEventListener("onNext", i.onNext), i != null && i.onPrev && n.removeEventListener("onPrev", i.onPrev), i != null && i.onTransitionComplete && n.removeEventListener( | ||
@@ -1348,21 +1348,15 @@ "onTransitionComplete", | ||
i == null ? void 0 : i.onTransitionComplete | ||
]), b(() => { | ||
if (u.current) { | ||
u.current = !1; | ||
return; | ||
} | ||
return n != null && n.initialized && (o == null || delete o.custom_tooltip, o == null || delete o.custom_arrow, n.updateOptions(o, !1), n.updateSteps(e, !1)), () => { | ||
u.current = !0; | ||
}; | ||
}, [o, e, n]), /* @__PURE__ */ rt(lt.Provider, { value: n, children: [ | ||
]), W(() => { | ||
n != null && n.initialized && (o == null || delete o.custom_tooltip, o == null || delete o.custom_arrow, n.updateOptions(o, !1), n.updateSteps(e, !1), n.is_active && n.restart()); | ||
}, [o, e, n]), /* @__PURE__ */ ot(st.Provider, { value: n, children: [ | ||
l, | ||
a && r && F( | ||
/* @__PURE__ */ Q(a, { active_step: h, ajala: n }), | ||
a && r && Q( | ||
/* @__PURE__ */ K(a, { active_step: h, ajala: n }), | ||
r | ||
), | ||
s && g && F(/* @__PURE__ */ Q(s, {}), g) | ||
s && g && Q(/* @__PURE__ */ K(s, {}), g) | ||
] }); | ||
} | ||
function Ot() { | ||
const l = dt(lt); | ||
function At() { | ||
const l = ht(st); | ||
if (!l) | ||
@@ -1375,5 +1369,5 @@ throw new Error( | ||
export { | ||
St as AjalaJourney, | ||
At as AjalaJourneyProvider, | ||
Ot as useAjalaJourneyContext | ||
jt as AjalaJourney, | ||
Lt as AjalaJourneyProvider, | ||
At as useAjalaJourneyContext | ||
}; |
{ | ||
"name": "react-ajala", | ||
"private": false, | ||
"version": "0.2.10", | ||
"version": "0.2.11", | ||
"type": "module", | ||
@@ -6,0 +6,0 @@ "main": "./dist/react-ajala.cjs", |
Sorry, the diff of this file is not supported yet
97540
-0.15%1565
-0.38%