@connect-xyz/withdraw-react 0.35.0 → 0.37.0

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/README.md CHANGED
@@ -64,6 +64,10 @@ function App() {
64
64
  console.log('Withdraw event:', type, 'Data:', data);
65
65
  };
66
66
 
67
+ const handleLoaded = () => {
68
+ console.log('Withdraw widget loaded and ready');
69
+ };
70
+
67
71
  return (
68
72
  <Withdraw
69
73
  jwt={jwt}
@@ -72,6 +76,7 @@ function App() {
72
76
  onClose={handleClose}
73
77
  onWithdrawal={handleWithdrawal}
74
78
  onEvent={handleEvent}
79
+ onLoaded={handleLoaded}
75
80
  />
76
81
  );
77
82
  }
@@ -113,6 +118,9 @@ function App() {
113
118
  onEvent={({ type, data }) => {
114
119
  console.log('Event type:', type, 'Event data:', data);
115
120
  }}
121
+ onLoaded={() => {
122
+ console.log('Withdraw widget loaded and ready');
123
+ }}
116
124
  />
117
125
  </div>
118
126
  );
@@ -134,6 +142,7 @@ export default App;
134
142
  | `onClose` | `() => void` | No | - | Callback when the widget is closed |
135
143
  | `onWithdrawal` | `({ data }) => void` | No | - | Callback for withdrawal completed |
136
144
  | `onEvent` | `({ type, data }) => void` | No | - | Callback for general events |
145
+ | `onLoaded` | `() => void` | No | - | Callback when the widget is loaded and ready |
137
146
 
138
147
  ## More Information & Support
139
148
 
package/dist/index.d.ts CHANGED
@@ -28,6 +28,8 @@ declare type CommonCallbacks<TEvent = AppEvent> = {
28
28
  onClose?: () => void;
29
29
  /** Called when a general event occurs */
30
30
  onEvent?: (event: TEvent) => void;
31
+ /** Called when the widget has loaded and is ready */
32
+ onLoaded?: () => void;
31
33
  };
32
34
 
33
35
  /**
@@ -88,6 +90,7 @@ declare type Theme = 'auto' | 'light' | 'dark';
88
90
  * @param onClose - Callback function for close events
89
91
  * @param onWithdrawal - Callback function for withdrawal events
90
92
  * @param onEvent - Callback function for general events
93
+ * @param onLoaded - Callback function called when the widget is fully loaded and ready
91
94
  *
92
95
  * @example
93
96
  * ```tsx
@@ -108,6 +111,7 @@ declare type Theme = 'auto' | 'light' | 'dark';
108
111
  * onClose={() => console.log('Withdraw closed')}
109
112
  * onWithdrawal={({ data }) => console.log('Withdrawal completed:', data.withdrawalId, 'Status:', data.status.value)}
110
113
  * onEvent={({ type, data }) => console.log('Event:', type, 'Withdrawal ID:', data.withdrawalId)}
114
+ * onLoaded={() => console.log('Withdraw widget loaded and ready')}
111
115
  * />
112
116
  * ```
113
117
  *
package/dist/index.js CHANGED
@@ -1,37 +1,38 @@
1
- import l, { useRef as w, useEffect as u } from "react";
2
- const h = {
1
+ import w, { useRef as h, useEffect as f } from "react";
2
+ const x = {
3
3
  sandbox: "https://sdk.sandbox.connect.xyz/withdraw-web/index.js",
4
4
  production: "https://sdk.connect.xyz/withdraw-web/index.js"
5
- }, x = "connect-withdraw-script", a = "connect-withdraw", y = (c = "production") => h[c], R = ({
5
+ }, y = "connect-withdraw-script", a = "connect-withdraw", I = (c = "production") => x[c], b = ({
6
6
  jwt: c,
7
7
  env: r = "production",
8
- theme: f,
8
+ theme: m,
9
9
  onError: n,
10
10
  onClose: o,
11
- onEvent: s,
12
- onWithdrawal: i,
13
- ...m
11
+ onEvent: i,
12
+ onWithdrawal: s,
13
+ onLoaded: d,
14
+ ...l
14
15
  }) => {
15
- const d = w(null);
16
- return u(() => {
17
- const t = d.current;
18
- t && (n && (t.onError = n), o && (t.onClose = o), s && (t.onEvent = s), i && (t.onWithdrawal = i));
19
- }, [n, o, s, i]), u(() => {
20
- const t = y(r), p = `${x}-${r}`;
21
- if (document.getElementById(p))
16
+ const p = h(null);
17
+ return f(() => {
18
+ const t = p.current;
19
+ t && (n && (t.onError = n), o && (t.onClose = o), i && (t.onEvent = i), s && (t.onWithdrawal = s), d && (t.onLoaded = d));
20
+ }, [n, o, i, s, d]), f(() => {
21
+ const t = I(r), u = `${y}-${r}`;
22
+ if (document.getElementById(u))
22
23
  return;
23
24
  const e = document.createElement("script");
24
- e.id = p, e.src = t, e.type = "module", e.async = !0, e.onerror = () => {
25
+ e.id = u, e.src = t, e.type = "module", e.async = !0, e.onerror = () => {
25
26
  console.error(`Failed to load the script for ${a} from ${r} environment.`);
26
27
  }, document.head.appendChild(e);
27
- }, [r]), l.createElement(a, {
28
- ref: d,
28
+ }, [r]), w.createElement(a, {
29
+ ref: p,
29
30
  jwt: c,
30
31
  env: r,
31
- theme: f,
32
- ...m
32
+ theme: m,
33
+ ...l
33
34
  });
34
35
  };
35
36
  export {
36
- R as Withdraw
37
+ b as Withdraw
37
38
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@connect-xyz/withdraw-react",
3
- "version": "0.35.0",
3
+ "version": "0.37.0",
4
4
  "private": false,
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",