@connect-xyz/withdraw-react 0.35.0 → 0.36.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 +9 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +21 -20
- package/package.json +1 -1
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
|
|
2
|
-
const
|
|
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
|
-
},
|
|
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:
|
|
8
|
+
theme: m,
|
|
9
9
|
onError: n,
|
|
10
10
|
onClose: o,
|
|
11
|
-
onEvent:
|
|
12
|
-
onWithdrawal:
|
|
13
|
-
|
|
11
|
+
onEvent: i,
|
|
12
|
+
onWithdrawal: s,
|
|
13
|
+
onLoaded: d,
|
|
14
|
+
...l
|
|
14
15
|
}) => {
|
|
15
|
-
const
|
|
16
|
-
return
|
|
17
|
-
const t =
|
|
18
|
-
t && (n && (t.onError = n), o && (t.onClose = o),
|
|
19
|
-
}, [n, o, s,
|
|
20
|
-
const t =
|
|
21
|
-
if (document.getElementById(
|
|
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 =
|
|
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]),
|
|
28
|
-
ref:
|
|
28
|
+
}, [r]), w.createElement(a, {
|
|
29
|
+
ref: p,
|
|
29
30
|
jwt: c,
|
|
30
31
|
env: r,
|
|
31
|
-
theme:
|
|
32
|
-
...
|
|
32
|
+
theme: m,
|
|
33
|
+
...l
|
|
33
34
|
});
|
|
34
35
|
};
|
|
35
36
|
export {
|
|
36
|
-
|
|
37
|
+
b as Withdraw
|
|
37
38
|
};
|