@heliofi/deposit-react 1.1.1-alpha.1784034750 → 1.1.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.
@@ -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 S, useEffect as p, useState as h, useLayoutEffect as k } from "react";
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", j = `https://${H}/assets/index-${A}.js`, x = ({ children: e }) => /* @__PURE__ */ D("div", { children: [
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
- ), N = ({
18
+ ), x = ({
19
19
  scriptIdentifier: e,
20
20
  scriptSrc: t
21
21
  }) => {
22
22
  const n = O(t, {
23
23
  embedScriptSource: void 0
24
- }), r = S(!1);
25
- p(() => {
26
- r.current || (r.current = !0, !w(e) && I(n, e));
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, g = ({
28
+ }, O = (e, t) => t.embedScriptSource || e, N = ({
29
29
  type: e,
30
30
  config: t,
31
31
  scriptIdentifier: n,
32
- scriptSrc: r,
33
- trigger: a
32
+ scriptSrc: o,
33
+ trigger: l
34
34
  }) => {
35
- const i = S(null), [m, d] = h(!1);
36
- p(() => d(!0), []);
37
- const [s, F] = h(), [M, f] = h(""), E = O(r, t);
38
- return p(() => {
39
- let u = !1;
40
- if (s) return;
41
- const l = () => {
42
- if (u) return;
43
- let o;
44
- if (e === "paylink" ? o = window.helioCheckout : o = window.moonpayCommerceDeposit, !o) {
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(() => o);
51
- }, v = (o) => {
50
+ F(() => i);
51
+ }, v = (i) => {
52
52
  const y = () => f("Error loading script tag");
53
- return o.addEventListener("load", l), o.addEventListener("error", y), () => {
54
- u = !0, o.removeEventListener("load", l), o.removeEventListener("error", y);
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
- l();
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
- }, [s, E, r, n, e]), k(() => {
70
- if (!(!s || !m)) {
71
- if (!i.current) {
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 (!a)
77
+ if (!l)
78
78
  if (e === "paylink") {
79
- const u = t;
80
- s(i.current, u);
79
+ const d = t;
80
+ r(s.current, d);
81
81
  } else {
82
- const u = s, l = t;
83
- u(i.current, l);
82
+ const d = r, u = t;
83
+ d(s.current, u);
84
84
  }
85
85
  }
86
- }, [s, m, t, e, a]), { divRef: i, initFn: s, error: M, type: e };
86
+ }, [r, a, t, e, l]), { divRef: s, initFn: r, error: M, type: e };
87
87
  }, R = {
88
88
  scriptIdentifier: L,
89
- scriptSrc: j
89
+ scriptSrc: g
90
90
  }, U = ({
91
91
  config: e,
92
92
  trigger: t
93
93
  }) => {
94
- const { divRef: n, initFn: r, error: a } = g({
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
- }), i = S(null);
100
- return p(() => {
101
- const d = i.current;
102
- if (!(!d || !t))
103
- return d.appendChild(t), () => {
104
- d.contains(t) && d.removeChild(t);
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, !!r]), a ? /* @__PURE__ */ c(x, { children: a }) : r ? t ? /* @__PURE__ */ D(b, { children: [
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: () => r(n.current, { ...e, display: "modal" }),
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: i })
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) => (N(R), /* @__PURE__ */ c(b, { children: e.children }));
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
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@heliofi/deposit-react",
3
3
  "private": false,
4
- "version": "1.1.1-alpha.1784034750",
4
+ "version": "1.1.1",
5
5
  "type": "module",
6
6
  "scripts": {
7
7
  "dev": "vite",