@zerohash-sdk/crypto-account-link-react 1.2.1 → 1.2.4
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/dist/index.d.ts +1 -1
- package/dist/index.js +29 -29
- package/package.json +1 -1
- package/src/lib/crypto-account-link-react.tsx +4 -4
package/dist/index.d.ts
CHANGED
|
@@ -44,7 +44,7 @@ declare type AppEvent<TType extends string = string, TData = Record<string, unkn
|
|
|
44
44
|
* // With callback functions
|
|
45
45
|
* <CryptoAccountLink
|
|
46
46
|
* jwt="your-jwt-token"
|
|
47
|
-
* theme="
|
|
47
|
+
* theme="light"
|
|
48
48
|
* onLoaded={() => console.log('Crypto account link loaded and ready')}
|
|
49
49
|
* onCompleted={(data) => console.log('Account linked successfully', data)}
|
|
50
50
|
* onClose={() => console.log('Crypto account link closed')}
|
package/dist/index.js
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
import
|
|
1
|
+
import m, { useRef as x, useEffect as f } from "react";
|
|
2
2
|
const b = {
|
|
3
3
|
local: "http://localhost:5173/crypto-account-link-web/index.js",
|
|
4
4
|
dev: "https://connect-sdk.dev.0hash.com/crypto-account-link-web/index.js",
|
|
5
5
|
cert: "https://sdk.sandbox.connect.xyz/crypto-account-link-web/index.js",
|
|
6
6
|
prod: "https://sdk.connect.xyz/crypto-account-link-web/index.js"
|
|
7
|
-
}, I = "zerohash-crypto-account-link-script",
|
|
8
|
-
jwt:
|
|
9
|
-
env:
|
|
10
|
-
theme:
|
|
11
|
-
isPayouts:
|
|
12
|
-
onCompleted:
|
|
13
|
-
onError:
|
|
14
|
-
onClose:
|
|
15
|
-
onLoaded:
|
|
16
|
-
onExternalAccountCreated:
|
|
17
|
-
onEvent:
|
|
18
|
-
...
|
|
7
|
+
}, I = "zerohash-crypto-account-link-script", y = "zerohash-crypto-account-link", R = (e = "prod") => b[e], w = ({
|
|
8
|
+
jwt: e,
|
|
9
|
+
env: o = "prod",
|
|
10
|
+
theme: r,
|
|
11
|
+
isPayouts: h = !1,
|
|
12
|
+
onCompleted: n,
|
|
13
|
+
onError: s,
|
|
14
|
+
onClose: i,
|
|
15
|
+
onLoaded: p,
|
|
16
|
+
onExternalAccountCreated: d,
|
|
17
|
+
onEvent: l,
|
|
18
|
+
...k
|
|
19
19
|
}) => {
|
|
20
|
-
const
|
|
21
|
-
return
|
|
22
|
-
const t =
|
|
23
|
-
t && (r && (t.
|
|
24
|
-
}, [r, n, s, i, p, d]),
|
|
25
|
-
const t = R(
|
|
26
|
-
if (document.getElementById(
|
|
20
|
+
const u = x(null);
|
|
21
|
+
return f(() => {
|
|
22
|
+
const t = u.current;
|
|
23
|
+
t && (r !== void 0 && (t.theme = r), n && (t.onCompleted = n), s && (t.onError = s), i && (t.onClose = i), p && (t.onLoaded = p), d && (t.onExternalAccountCreated = d), l && (t.onEvent = l));
|
|
24
|
+
}, [r, n, s, i, p, d, l]), f(() => {
|
|
25
|
+
const t = R(o), a = `${I}-${o}`;
|
|
26
|
+
if (document.getElementById(a))
|
|
27
27
|
return;
|
|
28
28
|
const c = document.createElement("script");
|
|
29
|
-
c.id =
|
|
30
|
-
console.error(`Failed to load the script for ${
|
|
29
|
+
c.id = a, c.src = t, c.type = "module", c.async = !0, c.onerror = () => {
|
|
30
|
+
console.error(`Failed to load the script for ${y} from ${o} environment.`);
|
|
31
31
|
}, document.head.appendChild(c);
|
|
32
|
-
}, [
|
|
33
|
-
ref:
|
|
34
|
-
jwt:
|
|
35
|
-
env:
|
|
36
|
-
theme:
|
|
37
|
-
"is-payouts":
|
|
38
|
-
...
|
|
32
|
+
}, [o]), m.createElement(y, {
|
|
33
|
+
ref: u,
|
|
34
|
+
jwt: e,
|
|
35
|
+
env: o,
|
|
36
|
+
theme: r,
|
|
37
|
+
"is-payouts": h,
|
|
38
|
+
...k
|
|
39
39
|
});
|
|
40
40
|
};
|
|
41
41
|
export {
|
package/package.json
CHANGED
|
@@ -228,7 +228,7 @@ interface CryptoAccountLinkElement
|
|
|
228
228
|
extends HTMLElement,
|
|
229
229
|
Pick<
|
|
230
230
|
CryptoAccountLinkProps,
|
|
231
|
-
'onCompleted' | 'onError' | 'onClose' | 'onLoaded' | 'onEvent' | 'onExternalAccountCreated'
|
|
231
|
+
'theme' | 'onCompleted' | 'onError' | 'onClose' | 'onLoaded' | 'onEvent' | 'onExternalAccountCreated'
|
|
232
232
|
> {}
|
|
233
233
|
|
|
234
234
|
/**
|
|
@@ -263,7 +263,7 @@ interface CryptoAccountLinkElement
|
|
|
263
263
|
* // With callback functions
|
|
264
264
|
* <CryptoAccountLink
|
|
265
265
|
* jwt="your-jwt-token"
|
|
266
|
-
* theme="
|
|
266
|
+
* theme="light"
|
|
267
267
|
* onLoaded={() => console.log('Crypto account link loaded and ready')}
|
|
268
268
|
* onCompleted={(data) => console.log('Account linked successfully', data)}
|
|
269
269
|
* onClose={() => console.log('Crypto account link closed')}
|
|
@@ -290,18 +290,18 @@ export const CryptoAccountLink: React.FC<CryptoAccountLinkProps> = ({
|
|
|
290
290
|
}) => {
|
|
291
291
|
const ref = useRef<CryptoAccountLinkElement | null>(null);
|
|
292
292
|
|
|
293
|
-
// Set up callback functions on the web component element
|
|
294
293
|
useEffect(() => {
|
|
295
294
|
const element = ref.current;
|
|
296
295
|
if (!element) return;
|
|
297
296
|
|
|
297
|
+
if (theme !== undefined) element.theme = theme;
|
|
298
298
|
if (onCompleted) element.onCompleted = onCompleted;
|
|
299
299
|
if (onError) element.onError = onError;
|
|
300
300
|
if (onClose) element.onClose = onClose;
|
|
301
301
|
if (onLoaded) element.onLoaded = onLoaded;
|
|
302
302
|
if (onExternalAccountCreated) element.onExternalAccountCreated = onExternalAccountCreated;
|
|
303
303
|
if (onEvent) element.onEvent = onEvent;
|
|
304
|
-
}, [onCompleted, onError, onClose, onLoaded, onExternalAccountCreated, onEvent]);
|
|
304
|
+
}, [theme, onCompleted, onError, onClose, onLoaded, onExternalAccountCreated, onEvent]);
|
|
305
305
|
|
|
306
306
|
// Load connect script to render the web component.
|
|
307
307
|
useEffect(() => {
|