@heliofi/deposit-react 0.1.5-beta-3 → 0.1.5-beta-5
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/helio-deposit-react.es.js +23 -23
- package/package.json +1 -1
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { jsxs as E, jsx as i, Fragment as y } from "react/jsx-runtime";
|
|
2
|
-
import { useRef as C, useState as u, useEffect as
|
|
2
|
+
import { useRef as C, useState as u, useEffect as p, useLayoutEffect as I } from "react";
|
|
3
3
|
const R = "v1", b = () => {
|
|
4
4
|
try {
|
|
5
5
|
return process.env.VITE_PROD_HOSTNAME || "embed.deposits.hel.io";
|
|
6
6
|
} catch {
|
|
7
7
|
return "embed.deposits.hel.io";
|
|
8
8
|
}
|
|
9
|
-
}, M = b(), g = "deposit-embed-script", O = `https://${M}/assets/index-${R}.js`, _ = ({ children:
|
|
9
|
+
}, M = b(), g = "deposit-embed-script", O = `https://${M}/assets/index-${R}.js`, _ = ({ children: e }) => /* @__PURE__ */ E("div", { children: [
|
|
10
10
|
"Error loading Helio Deposit for React",
|
|
11
|
-
|
|
12
|
-
] }), h = (
|
|
13
|
-
const
|
|
14
|
-
return
|
|
15
|
-
}, T = (
|
|
16
|
-
const
|
|
17
|
-
if (
|
|
11
|
+
e ? `: ${e}` : ""
|
|
12
|
+
] }), h = (e = O) => {
|
|
13
|
+
const t = document.createElement("script");
|
|
14
|
+
return t.setAttribute("type", "module"), t.setAttribute("id", g), t.setAttribute("src", e), document.body.appendChild(t), t;
|
|
15
|
+
}, T = (e) => {
|
|
16
|
+
const t = C(null), [d, D] = u(!1), [r, v] = u(), [m, s] = u("");
|
|
17
|
+
if (p(() => D(!0), []), p(() => {
|
|
18
18
|
let o = !1;
|
|
19
19
|
if (r) return;
|
|
20
20
|
const c = () => {
|
|
@@ -28,42 +28,42 @@ const R = "v1", b = () => {
|
|
|
28
28
|
}
|
|
29
29
|
v(() => n);
|
|
30
30
|
}, a = (n) => {
|
|
31
|
-
const
|
|
32
|
-
return n.addEventListener("load", c), n.addEventListener("error",
|
|
33
|
-
o = !0, n.removeEventListener("load", c), n.removeEventListener("error",
|
|
31
|
+
const l = () => s("Error loading script tag");
|
|
32
|
+
return n.addEventListener("load", c), n.addEventListener("error", l), () => {
|
|
33
|
+
o = !0, n.removeEventListener("load", c), n.removeEventListener("error", l);
|
|
34
34
|
};
|
|
35
|
-
},
|
|
35
|
+
}, f = document.querySelector(
|
|
36
36
|
`script#${g}`
|
|
37
37
|
);
|
|
38
|
-
if (
|
|
39
|
-
window.moonpayCommerceDeposit ? c() : a(
|
|
38
|
+
if (f) {
|
|
39
|
+
window.moonpayCommerceDeposit ? c() : a(f);
|
|
40
40
|
return;
|
|
41
41
|
}
|
|
42
42
|
const S = h();
|
|
43
43
|
return a(S);
|
|
44
44
|
}, [r]), I(() => {
|
|
45
45
|
if (!(!r || !d)) {
|
|
46
|
-
if (!
|
|
46
|
+
if (!t.current) {
|
|
47
47
|
s("Missing element to mount Helio Deposit");
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
|
-
r(
|
|
50
|
+
e.trigger || r(t.current, e.config);
|
|
51
51
|
}
|
|
52
|
-
}, [r, d,
|
|
52
|
+
}, [r, d, e.config, e.trigger]), m) return /* @__PURE__ */ i(_, { children: m });
|
|
53
53
|
if (!r) return null;
|
|
54
|
-
if (
|
|
55
|
-
const o =
|
|
54
|
+
if (e.trigger) {
|
|
55
|
+
const o = e.trigger;
|
|
56
56
|
return /* @__PURE__ */ E(y, { children: [
|
|
57
|
-
/* @__PURE__ */ i("div", { ref:
|
|
57
|
+
/* @__PURE__ */ i("div", { ref: t }),
|
|
58
58
|
/* @__PURE__ */ i(
|
|
59
59
|
o,
|
|
60
60
|
{
|
|
61
|
-
onClick: () => r(
|
|
61
|
+
onClick: () => r(t.current, { ...e.config, display: "modal" })
|
|
62
62
|
}
|
|
63
63
|
)
|
|
64
64
|
] });
|
|
65
65
|
}
|
|
66
|
-
return /* @__PURE__ */ i("div", { ref:
|
|
66
|
+
return /* @__PURE__ */ i("div", { ref: t });
|
|
67
67
|
};
|
|
68
68
|
export {
|
|
69
69
|
T as MoonpayCommerceDeposit
|