@heliofi/deposit-react 1.1.0 → 1.1.1-alpha.1784293065
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.
|
@@ -55,6 +55,7 @@ export declare const MoonpayCommerceDeposit: (props: MoonpayCommerceDepositReact
|
|
|
55
55
|
openWalletConnectInNewTab?: boolean;
|
|
56
56
|
themeMode?: DepositThemeMode;
|
|
57
57
|
variant?: DepositVariant;
|
|
58
|
+
/* Excluded from this release type: openSignal */
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
export declare const MoonpayCommerceDepositProvider: (props: PropsWithChildren) => JSX.Element;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { jsxs as D, jsx as c, Fragment as b } from "react/jsx-runtime";
|
|
2
|
-
import { useRef as
|
|
2
|
+
import { useRef as p, useEffect as m, useState as S, useLayoutEffect as k } from "react";
|
|
3
3
|
var P = {};
|
|
4
4
|
const A = "v1", T = () => {
|
|
5
5
|
try {
|
|
@@ -7,7 +7,7 @@ const A = "v1", T = () => {
|
|
|
7
7
|
} catch {
|
|
8
8
|
return "embed.deposits.hel.io";
|
|
9
9
|
}
|
|
10
|
-
}, H = T(), L = "deposit-embed-script",
|
|
10
|
+
}, H = T(), L = "deposit-embed-script", g = `https://${H}/assets/index-${A}.js`, j = ({ children: e }) => /* @__PURE__ */ D("div", { children: [
|
|
11
11
|
"Error loading Helio Deposit for React",
|
|
12
12
|
e ? `: ${e}` : ""
|
|
13
13
|
] }), I = (e, t) => {
|
|
@@ -15,48 +15,48 @@ const A = "v1", T = () => {
|
|
|
15
15
|
return n.setAttribute("type", "module"), n.setAttribute("id", t), n.setAttribute("src", e), document.body.appendChild(n), n;
|
|
16
16
|
}, w = (e) => document.querySelector(
|
|
17
17
|
`script#${e}`
|
|
18
|
-
),
|
|
18
|
+
), x = ({
|
|
19
19
|
scriptIdentifier: e,
|
|
20
20
|
scriptSrc: t
|
|
21
21
|
}) => {
|
|
22
22
|
const n = O(t, {
|
|
23
23
|
embedScriptSource: void 0
|
|
24
|
-
}),
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
}), o = p(!1);
|
|
25
|
+
m(() => {
|
|
26
|
+
o.current || (o.current = !0, !w(e) && I(n, e));
|
|
27
27
|
}, [n, e]);
|
|
28
|
-
}, O = (e, t) => t.embedScriptSource || e,
|
|
28
|
+
}, O = (e, t) => t.embedScriptSource || e, N = ({
|
|
29
29
|
type: e,
|
|
30
30
|
config: t,
|
|
31
31
|
scriptIdentifier: n,
|
|
32
|
-
scriptSrc:
|
|
33
|
-
trigger:
|
|
32
|
+
scriptSrc: o,
|
|
33
|
+
trigger: l
|
|
34
34
|
}) => {
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
const [
|
|
38
|
-
return
|
|
39
|
-
let
|
|
40
|
-
if (
|
|
41
|
-
const
|
|
42
|
-
if (
|
|
43
|
-
let
|
|
44
|
-
if (e === "paylink" ?
|
|
35
|
+
const s = p(null), [a, h] = S(!1);
|
|
36
|
+
m(() => h(!0), []);
|
|
37
|
+
const [r, F] = S(), [M, f] = S(""), E = O(o, t);
|
|
38
|
+
return m(() => {
|
|
39
|
+
let d = !1;
|
|
40
|
+
if (r) return;
|
|
41
|
+
const u = () => {
|
|
42
|
+
if (d) return;
|
|
43
|
+
let i;
|
|
44
|
+
if (e === "paylink" ? i = window.helioCheckout : i = window.moonpayCommerceDeposit, !i) {
|
|
45
45
|
f(
|
|
46
46
|
e === "paylink" ? "Unable to load MoonPay Commerce Checkout - missing init function on window.helioCheckout" : "Unable to load Helio Deposit - missing init function on window.moonpayCommerceDeposit"
|
|
47
47
|
);
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
|
-
F(() =>
|
|
51
|
-
}, v = (
|
|
50
|
+
F(() => i);
|
|
51
|
+
}, v = (i) => {
|
|
52
52
|
const y = () => f("Error loading script tag");
|
|
53
|
-
return
|
|
54
|
-
|
|
53
|
+
return i.addEventListener("load", u), i.addEventListener("error", y), () => {
|
|
54
|
+
d = !0, i.removeEventListener("load", u), i.removeEventListener("error", y);
|
|
55
55
|
};
|
|
56
56
|
}, C = w(n);
|
|
57
57
|
if (C) {
|
|
58
58
|
if (e === "paylink" && window.helioCheckout || e === "deposit" && window.moonpayCommerceDeposit) {
|
|
59
|
-
|
|
59
|
+
u();
|
|
60
60
|
return;
|
|
61
61
|
}
|
|
62
62
|
return v(C);
|
|
@@ -66,57 +66,63 @@ const A = "v1", T = () => {
|
|
|
66
66
|
n
|
|
67
67
|
);
|
|
68
68
|
return v(_);
|
|
69
|
-
}, [
|
|
70
|
-
if (!(!
|
|
71
|
-
if (!
|
|
69
|
+
}, [r, E, o, n, e]), k(() => {
|
|
70
|
+
if (!(!r || !a)) {
|
|
71
|
+
if (!s.current) {
|
|
72
72
|
f(
|
|
73
73
|
e === "paylink" ? "Missing element to mount MoonPay Commerce Checkout" : "Missing element to mount Helio Deposit"
|
|
74
74
|
);
|
|
75
75
|
return;
|
|
76
76
|
}
|
|
77
|
-
if (!
|
|
77
|
+
if (!l)
|
|
78
78
|
if (e === "paylink") {
|
|
79
|
-
const
|
|
80
|
-
s
|
|
79
|
+
const d = t;
|
|
80
|
+
r(s.current, d);
|
|
81
81
|
} else {
|
|
82
|
-
const
|
|
83
|
-
|
|
82
|
+
const d = r, u = t;
|
|
83
|
+
d(s.current, u);
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
|
-
}, [
|
|
86
|
+
}, [r, a, t, e, l]), { divRef: s, initFn: r, error: M, type: e };
|
|
87
87
|
}, R = {
|
|
88
88
|
scriptIdentifier: L,
|
|
89
|
-
scriptSrc:
|
|
89
|
+
scriptSrc: g
|
|
90
90
|
}, U = ({
|
|
91
91
|
config: e,
|
|
92
92
|
trigger: t
|
|
93
93
|
}) => {
|
|
94
|
-
const { divRef: n, initFn:
|
|
94
|
+
const { divRef: n, initFn: o, error: l } = N({
|
|
95
95
|
type: "deposit",
|
|
96
96
|
trigger: t,
|
|
97
97
|
config: e,
|
|
98
98
|
...R
|
|
99
|
-
}),
|
|
100
|
-
return
|
|
101
|
-
const
|
|
102
|
-
if (!(!
|
|
103
|
-
return
|
|
104
|
-
|
|
99
|
+
}), s = p(null), a = p(0);
|
|
100
|
+
return m(() => {
|
|
101
|
+
const r = s.current;
|
|
102
|
+
if (!(!r || !t))
|
|
103
|
+
return r.appendChild(t), () => {
|
|
104
|
+
r.contains(t) && r.removeChild(t);
|
|
105
105
|
};
|
|
106
|
-
}, [t, !!
|
|
106
|
+
}, [t, !!o]), l ? /* @__PURE__ */ c(j, { children: l }) : o ? t ? /* @__PURE__ */ D(b, { children: [
|
|
107
107
|
/* @__PURE__ */ c("div", { ref: n }),
|
|
108
108
|
/* @__PURE__ */ c(
|
|
109
109
|
"button",
|
|
110
110
|
{
|
|
111
|
-
onClick: () =>
|
|
111
|
+
onClick: () => {
|
|
112
|
+
a.current += 1, o(n.current, {
|
|
113
|
+
...e,
|
|
114
|
+
display: "modal",
|
|
115
|
+
openSignal: a.current
|
|
116
|
+
});
|
|
117
|
+
},
|
|
112
118
|
className: "hel-bg-transparent hel-border-none hel-outline-none hel-p-0 hel-m-0",
|
|
113
119
|
id: "moonpay-commerce-deposit-trigger",
|
|
114
120
|
type: "button",
|
|
115
|
-
children: /* @__PURE__ */ c("span", { ref:
|
|
121
|
+
children: /* @__PURE__ */ c("span", { ref: s })
|
|
116
122
|
}
|
|
117
123
|
)
|
|
118
124
|
] }) : /* @__PURE__ */ c("div", { ref: n }) : null;
|
|
119
|
-
}, W = (e) => /* @__PURE__ */ c(U, { ...e }), z = (e) => (
|
|
125
|
+
}, W = (e) => /* @__PURE__ */ c(U, { ...e }), z = (e) => (x(R), /* @__PURE__ */ c(b, { children: e.children }));
|
|
120
126
|
export {
|
|
121
127
|
W as MoonpayCommerceDeposit,
|
|
122
128
|
z as MoonpayCommerceDepositProvider
|