@heliofi/deposit-react 0.1.4 → 0.1.5-beta-2
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,29 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
2
5
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
* Note: This type is duplicated from deposit-embed to maintain package independence.
|
|
6
|
-
* The deposit-embed package is a private build artifact (embed script), not a library.
|
|
7
|
-
*/
|
|
8
|
-
/** Required: Deposit customer token */
|
|
6
|
+
export declare const MoonpayCommerceDeposit: (props: MoonpayCommerceDepositReactProps) => JSX.Element | null;
|
|
7
|
+
|
|
9
8
|
depositCustomerToken: string;
|
|
10
|
-
/** Optional: Success callback */
|
|
11
9
|
onSuccess?: () => void;
|
|
12
|
-
/** Optional: Error callback */
|
|
13
10
|
onError?: (error: {
|
|
14
11
|
message: string;
|
|
15
12
|
}) => void;
|
|
16
|
-
|
|
17
|
-
network?:
|
|
18
|
-
|
|
13
|
+
display?: DepositDisplay;
|
|
14
|
+
network?: DepositNetwork;
|
|
15
|
+
themeMode?: DepositThemeMode;
|
|
16
|
+
loadingText?: React.ReactNode;
|
|
19
17
|
debug?: boolean;
|
|
20
|
-
/** Optional: Display mode - inline (default), button, or new-tab */
|
|
21
|
-
display?: 'inline' | 'button' | 'new-tab';
|
|
22
|
-
/** Optional: Button text for button and new-tab modes */
|
|
23
|
-
buttonText?: string;
|
|
24
18
|
}
|
|
25
19
|
|
|
26
20
|
config: MoonpayCommerceDepositConfig;
|
|
21
|
+
trigger?: React.ComponentType<React.ButtonHTMLAttributes<HTMLButtonElement>>;
|
|
27
22
|
}
|
|
28
23
|
|
|
29
24
|
export { }
|
|
@@ -1,56 +1,70 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { useRef as
|
|
3
|
-
const
|
|
1
|
+
import { jsxs as E, jsx as i, Fragment as S } from "react/jsx-runtime";
|
|
2
|
+
import { useRef as C, useState as u, useEffect as p, useLayoutEffect as I } from "react";
|
|
3
|
+
const b = "v1", R = () => {
|
|
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
|
-
},
|
|
9
|
+
}, M = R(), g = "deposit-embed-script", O = `https://${M}/assets/index-${b}.js`, _ = ({ children: e }) => /* @__PURE__ */ E("div", { children: [
|
|
10
10
|
"Error loading Helio Deposit for React",
|
|
11
|
-
|
|
12
|
-
] }),
|
|
13
|
-
const
|
|
14
|
-
return
|
|
15
|
-
},
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
let
|
|
19
|
-
if (
|
|
20
|
-
const
|
|
21
|
-
if (
|
|
22
|
-
const
|
|
23
|
-
if (!
|
|
24
|
-
|
|
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
|
+
let o = !1;
|
|
19
|
+
if (r) return;
|
|
20
|
+
const c = () => {
|
|
21
|
+
if (o) return;
|
|
22
|
+
const n = window.moonpayCommerceDeposit;
|
|
23
|
+
if (!n) {
|
|
24
|
+
s(
|
|
25
25
|
"Unable to load Helio Deposit - missing init function on window.moonpayCommerceDeposit"
|
|
26
26
|
);
|
|
27
27
|
return;
|
|
28
28
|
}
|
|
29
|
-
v(() =>
|
|
30
|
-
},
|
|
31
|
-
const
|
|
32
|
-
return
|
|
33
|
-
|
|
29
|
+
v(() => n);
|
|
30
|
+
}, a = (n) => {
|
|
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
|
-
},
|
|
36
|
-
`script#${
|
|
35
|
+
}, f = document.querySelector(
|
|
36
|
+
`script#${g}`
|
|
37
37
|
);
|
|
38
|
-
if (
|
|
39
|
-
window.moonpayCommerceDeposit ?
|
|
38
|
+
if (f) {
|
|
39
|
+
window.moonpayCommerceDeposit ? c() : a(f);
|
|
40
40
|
return;
|
|
41
41
|
}
|
|
42
|
-
const
|
|
43
|
-
return
|
|
44
|
-
}, [
|
|
45
|
-
if (!(!
|
|
46
|
-
if (!
|
|
47
|
-
|
|
42
|
+
const y = h();
|
|
43
|
+
return a(y);
|
|
44
|
+
}, [r]), I(() => {
|
|
45
|
+
if (!(!r || !d)) {
|
|
46
|
+
if (!t.current) {
|
|
47
|
+
s("Missing element to mount Helio Deposit");
|
|
48
48
|
return;
|
|
49
49
|
}
|
|
50
|
-
|
|
50
|
+
r(t.current, e.config);
|
|
51
51
|
}
|
|
52
|
-
}, [
|
|
52
|
+
}, [r, d, e.config]), m) return /* @__PURE__ */ i(_, { children: m });
|
|
53
|
+
if (!r) return null;
|
|
54
|
+
if (e.trigger && e.config.display === "button") {
|
|
55
|
+
const o = e.trigger;
|
|
56
|
+
return /* @__PURE__ */ E(S, { children: [
|
|
57
|
+
/* @__PURE__ */ i("div", { ref: t }),
|
|
58
|
+
/* @__PURE__ */ i(
|
|
59
|
+
o,
|
|
60
|
+
{
|
|
61
|
+
onClick: () => r(t.current, { ...e.config, display: "modal" })
|
|
62
|
+
}
|
|
63
|
+
)
|
|
64
|
+
] });
|
|
65
|
+
}
|
|
66
|
+
return /* @__PURE__ */ i("div", { ref: t });
|
|
53
67
|
};
|
|
54
68
|
export {
|
|
55
|
-
|
|
69
|
+
T as MoonpayCommerceDeposit
|
|
56
70
|
};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@heliofi/deposit-react",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "0.1.
|
|
4
|
+
"version": "0.1.5-beta-2",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"dev": "vite",
|
|
@@ -39,8 +39,8 @@
|
|
|
39
39
|
"@testing-library/dom": "9.3.3",
|
|
40
40
|
"@testing-library/jest-dom": "5.16.5",
|
|
41
41
|
"@testing-library/react": "14.0.0",
|
|
42
|
-
"@types/react": "
|
|
43
|
-
"@types/react-dom": "
|
|
42
|
+
"@types/react": "19.2.7",
|
|
43
|
+
"@types/react-dom": "19.2.3",
|
|
44
44
|
"@typescript-eslint/eslint-plugin": "4.33.0",
|
|
45
45
|
"@typescript-eslint/parser": "4.33.0",
|
|
46
46
|
"@vitejs/plugin-react": "4.3.2",
|
|
@@ -48,8 +48,8 @@
|
|
|
48
48
|
"eslint-plugin-react": "7.33.2",
|
|
49
49
|
"eslint-plugin-react-hooks": "4.6.0",
|
|
50
50
|
"jsdom": "23.0.1",
|
|
51
|
-
"react": "
|
|
52
|
-
"react-dom": "
|
|
51
|
+
"react": "19.2.1",
|
|
52
|
+
"react-dom": "19.2.1",
|
|
53
53
|
"rimraf": "3.0.2",
|
|
54
54
|
"typescript": "5.1.6",
|
|
55
55
|
"vite": "5.4.8",
|