@heliofi/deposit-react 0.1.4 → 0.1.5-beta-1

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
- export declare const MoonpayCommerceDeposit: (props: MoonpayCommerceDepositReactProps) => JSX.Element | null;
1
+ /// <reference types="react" />
2
+
3
+
4
+
2
5
 
3
- /**
4
- * Configuration for MoonPay Commerce Deposit
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
- /** Optional: Network - test or main */
17
- network?: 'test' | 'main';
18
- /** Optional: Debug mode */
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,65 @@
1
- import { jsxs as g, jsx as f } from "react/jsx-runtime";
2
- import { useRef as y, useState as i, useEffect as E, useLayoutEffect as I } from "react";
3
- const C = "v1", R = () => {
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 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
- }, b = R(), l = "deposit-embed-script", M = `https://${b}/assets/index-${C}.js`, O = ({ children: t }) => /* @__PURE__ */ g("div", { children: [
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
- t ? `: ${t}` : ""
12
- ] }), _ = (t = M) => {
13
- const e = document.createElement("script");
14
- return e.setAttribute("type", "module"), e.setAttribute("id", l), e.setAttribute("src", t), document.body.appendChild(e), e;
15
- }, h = (t) => {
16
- const e = y(null), [c, D] = i(!1), [o, v] = i(), [u, n] = i("");
17
- return E(() => D(!0), []), E(() => {
18
- let d = !1;
19
- if (o) return;
20
- const s = () => {
21
- if (d) return;
22
- const r = window.moonpayCommerceDeposit;
23
- if (!r) {
24
- n(
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(() => r);
30
- }, m = (r) => {
31
- const a = () => n("Error loading script tag");
32
- return r.addEventListener("load", s), r.addEventListener("error", a), () => {
33
- d = !0, r.removeEventListener("load", s), r.removeEventListener("error", a);
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
- }, p = document.querySelector(
36
- `script#${l}`
35
+ }, f = document.querySelector(
36
+ `script#${g}`
37
37
  );
38
- if (p) {
39
- window.moonpayCommerceDeposit ? s() : m(p);
38
+ if (f) {
39
+ window.moonpayCommerceDeposit ? c() : a(f);
40
40
  return;
41
41
  }
42
- const S = _();
43
- return m(S);
44
- }, [o]), I(() => {
45
- if (!(!o || !c)) {
46
- if (!e.current) {
47
- n("Missing element to mount Helio Deposit");
42
+ const S = h();
43
+ return a(S);
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
- o(e.current, t.config);
50
+ r(t.current, e.config);
51
51
  }
52
- }, [o, c, t.config]), u ? /* @__PURE__ */ f(O, { children: u }) : o ? /* @__PURE__ */ f("div", { ref: e }) : null;
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(y, { children: [
57
+ /* @__PURE__ */ i("div", { ref: t }),
58
+ /* @__PURE__ */ i(o, { onClick: () => r(t.current, e.config) })
59
+ ] });
60
+ }
61
+ return /* @__PURE__ */ i("div", { ref: t });
53
62
  };
54
63
  export {
55
- h as MoonpayCommerceDeposit
64
+ T as MoonpayCommerceDeposit
56
65
  };
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",
4
+ "version": "0.1.5-beta-1",
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": "18.2.0",
43
- "@types/react-dom": "18.2.0",
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": "18.2.0",
52
- "react-dom": "18.2.0",
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",