@web3auth/modal 10.9.0 → 10.9.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.
- package/dist/lib.cjs/packages/modal/src/config.js +1 -1
- package/dist/lib.cjs/packages/modal/src/ui/components/ConnectWallet/ConnectWallet.js +5 -5
- package/dist/lib.cjs/packages/modal/src/ui/components/Login/Login.js +4 -3
- package/dist/lib.cjs/packages/modal/src/ui/components/Root/Root.js +17 -11
- package/dist/lib.cjs/types/ui/components/ConnectWallet/ConnectWallet.type.d.ts +1 -1
- package/dist/lib.cjs/types/ui/components/Login/Login.type.d.ts +1 -0
- package/dist/lib.esm/packages/modal/src/config.js +1 -1
- package/dist/lib.esm/packages/modal/src/ui/components/ConnectWallet/ConnectWallet.js +5 -5
- package/dist/lib.esm/packages/modal/src/ui/components/Login/Login.js +4 -3
- package/dist/lib.esm/packages/modal/src/ui/components/Root/Root.js +17 -11
- package/dist/modal.umd.min.js +1 -1
- package/package.json +2 -2
|
@@ -21,7 +21,7 @@ function ConnectWallet(props) {
|
|
|
21
21
|
walletConnectUri,
|
|
22
22
|
metamaskConnectUri,
|
|
23
23
|
walletRegistry,
|
|
24
|
-
|
|
24
|
+
allRegistryButtons,
|
|
25
25
|
customConnectorButtons,
|
|
26
26
|
connectorVisibilityMap,
|
|
27
27
|
deviceDetails,
|
|
@@ -63,16 +63,16 @@ function ConnectWallet(props) {
|
|
|
63
63
|
}, [walletRegistry]);
|
|
64
64
|
const allUniqueButtons = react.useMemo(() => {
|
|
65
65
|
const uniqueButtonSet = new Set();
|
|
66
|
-
return customConnectorButtons.concat(
|
|
66
|
+
return customConnectorButtons.concat(allRegistryButtons).filter(button => {
|
|
67
67
|
if (uniqueButtonSet.has(button.name)) return false;
|
|
68
68
|
uniqueButtonSet.add(button.name);
|
|
69
69
|
return true;
|
|
70
70
|
});
|
|
71
|
-
}, [
|
|
71
|
+
}, [allRegistryButtons, customConnectorButtons]);
|
|
72
72
|
const defaultButtonKeys = react.useMemo(() => new Set(Object.keys(walletRegistry.default)), [walletRegistry]);
|
|
73
73
|
const defaultButtons = react.useMemo(() => {
|
|
74
74
|
// display order: default injected buttons > custom adapter buttons > default non-injected buttons
|
|
75
|
-
const buttons = [...
|
|
75
|
+
const buttons = [...allRegistryButtons.filter(button => button.hasInjectedWallet && defaultButtonKeys.has(button.name)), ...customConnectorButtons, ...allRegistryButtons.filter(button => !button.hasInjectedWallet && defaultButtonKeys.has(button.name))].sort((a, b) => {
|
|
76
76
|
// favor MetaMask over other wallets
|
|
77
77
|
if (a.name === noModal.WALLET_CONNECTORS.METAMASK && b.name === noModal.WALLET_CONNECTORS.METAMASK) {
|
|
78
78
|
// favor installed MetaMask over non-installed MetaMask
|
|
@@ -96,7 +96,7 @@ function ConnectWallet(props) {
|
|
|
96
96
|
var _button$chainNamespac;
|
|
97
97
|
return selectedChain === "all" || ((_button$chainNamespac = button.chainNamespaces) === null || _button$chainNamespac === void 0 ? void 0 : _button$chainNamespac.includes(selectedChain));
|
|
98
98
|
});
|
|
99
|
-
}, [
|
|
99
|
+
}, [allRegistryButtons, customConnectorButtons, defaultButtonKeys, selectedChain]);
|
|
100
100
|
const installedWalletButtons = react.useMemo(() => {
|
|
101
101
|
const visibilityMap = connectorVisibilityMap;
|
|
102
102
|
return Object.keys(config).reduce((acc, localConnector) => {
|
|
@@ -35,6 +35,7 @@ function Login(props) {
|
|
|
35
35
|
isDark,
|
|
36
36
|
handleSocialLoginClick,
|
|
37
37
|
totalExternalWallets,
|
|
38
|
+
remainingUndisplayedWallets,
|
|
38
39
|
isEmailPasswordLessLoginVisible,
|
|
39
40
|
isSmsPasswordLessLoginVisible,
|
|
40
41
|
handleExternalWalletBtnClick,
|
|
@@ -448,7 +449,7 @@ function Login(props) {
|
|
|
448
449
|
src: utils.getIcons(isDark ? "chevron-right-dark" : "chevron-right-light"),
|
|
449
450
|
alt: "arrow"
|
|
450
451
|
})]
|
|
451
|
-
}, wallet.name)),
|
|
452
|
+
}, wallet.name)), remainingUndisplayedWallets > 0 && jsxRuntime.jsxs("button", {
|
|
452
453
|
type: "button",
|
|
453
454
|
className: utils.cn("w3a--btn !w3a--justify-between w3a--group w3a--relative w3a--overflow-hidden", {
|
|
454
455
|
"w3a--rounded-full": buttonRadius === "pill",
|
|
@@ -459,10 +460,10 @@ function Login(props) {
|
|
|
459
460
|
children: [jsxRuntime.jsx("p", {
|
|
460
461
|
className: "w3a--text-base w3a--font-normal w3a--text-app-gray-900 dark:w3a--text-app-white",
|
|
461
462
|
children: t("modal.external.all-wallets")
|
|
462
|
-
}), showExternalWalletCount &&
|
|
463
|
+
}), showExternalWalletCount && jsxRuntime.jsx("div", {
|
|
463
464
|
id: "external-wallet-count",
|
|
464
465
|
className: "w3a--absolute w3a--right-4 w3a--top-1/2 w3a--w-auto -w3a--translate-y-1/2 w3a--rounded-full w3a--bg-app-primary-100 w3a--px-2.5 w3a--py-0.5 w3a--text-xs w3a--font-medium w3a--text-app-primary-800 w3a--transition-all w3a--delay-300 w3a--duration-300 group-hover:w3a--translate-x-6 group-hover:w3a--opacity-0 group-hover:w3a--delay-0 dark:w3a--border dark:w3a--border-app-primary-500 dark:w3a--bg-transparent dark:w3a--text-app-primary-500",
|
|
465
|
-
children:
|
|
466
|
+
children: remainingUndisplayedWallets
|
|
466
467
|
}), jsxRuntime.jsx("img", {
|
|
467
468
|
id: "external-wallet-arrow",
|
|
468
469
|
className: "w3a--absolute w3a--right-4 w3a--top-1/2 -w3a--translate-x-10 -w3a--translate-y-1/2 w3a--opacity-0 w3a--transition-all w3a--duration-300\n group-hover:w3a--translate-x-0 group-hover:w3a--opacity-100",
|
|
@@ -242,7 +242,7 @@ function Root(props) {
|
|
|
242
242
|
return acc;
|
|
243
243
|
}, []);
|
|
244
244
|
}, [connectorVisibilityMap, chainNamespaces, config, deviceDetails.platform, isWalletConnectConnectorIncluded]);
|
|
245
|
-
const
|
|
245
|
+
const allRegistryButtons = react.useMemo(() => {
|
|
246
246
|
return [...generateWalletButtons(walletRegistry.default), ...generateWalletButtons(walletRegistry.others)];
|
|
247
247
|
}, [generateWalletButtons, walletRegistry.default, walletRegistry.others]);
|
|
248
248
|
const installedConnectorButtons = react.useMemo(() => {
|
|
@@ -265,7 +265,7 @@ function Root(props) {
|
|
|
265
265
|
const metamaskConnectorIdx = installedConnectors.findIndex(x => x.name === noModal.WALLET_CONNECTORS.METAMASK && !x.hasInjectedWallet);
|
|
266
266
|
if (metamaskConnectorIdx !== -1) {
|
|
267
267
|
const metamaskConnector = installedConnectors[metamaskConnectorIdx];
|
|
268
|
-
let metamaskRegistryButton =
|
|
268
|
+
let metamaskRegistryButton = allRegistryButtons.find(button => button.name === noModal.WALLET_CONNECTORS.METAMASK);
|
|
269
269
|
if (!metamaskRegistryButton) {
|
|
270
270
|
// use the default metamask registry item if it's not in the registry
|
|
271
271
|
metamaskRegistryButton = generateWalletButtons({
|
|
@@ -282,7 +282,7 @@ function Root(props) {
|
|
|
282
282
|
}
|
|
283
283
|
// make metamask the first button and limit the number of buttons
|
|
284
284
|
return installedConnectors;
|
|
285
|
-
}, [
|
|
285
|
+
}, [allRegistryButtons, config, connectorVisibilityMap, generateWalletButtons]);
|
|
286
286
|
const customConnectorButtons = react.useMemo(() => {
|
|
287
287
|
return installedConnectorButtons.filter(button => !button.hasInjectedWallet);
|
|
288
288
|
}, [installedConnectorButtons]);
|
|
@@ -291,14 +291,19 @@ function Root(props) {
|
|
|
291
291
|
// make metamask the first button and limit the number of buttons
|
|
292
292
|
return installedConnectorButtons.sort((a, _) => a.name === noModal.WALLET_CONNECTORS.METAMASK ? -1 : 1).slice(0, displayInstalledExternalWallets ? MAX_TOP_INSTALLED_CONNECTORS : 1);
|
|
293
293
|
}, [installedConnectorButtons, displayInstalledExternalWallets]);
|
|
294
|
-
const
|
|
295
|
-
const
|
|
296
|
-
return
|
|
297
|
-
if (
|
|
298
|
-
|
|
294
|
+
const allExternalWallets = react.useMemo(() => {
|
|
295
|
+
const uniqueButtonSet = new Set();
|
|
296
|
+
return installedConnectorButtons.concat(allRegistryButtons).filter(button => {
|
|
297
|
+
if (uniqueButtonSet.has(button.name)) return false;
|
|
298
|
+
uniqueButtonSet.add(button.name);
|
|
299
299
|
return true;
|
|
300
|
+
});
|
|
301
|
+
}, [allRegistryButtons, installedConnectorButtons]);
|
|
302
|
+
const remainingUndisplayedWallets = react.useMemo(() => {
|
|
303
|
+
return allExternalWallets.filter(button => {
|
|
304
|
+
return !topInstalledConnectorButtons.includes(button);
|
|
300
305
|
}).length;
|
|
301
|
-
}, [
|
|
306
|
+
}, [allExternalWallets, topInstalledConnectorButtons]);
|
|
302
307
|
const handleSocialLoginHeight = () => {
|
|
303
308
|
setIsSocialLoginsExpanded(prev => !prev);
|
|
304
309
|
};
|
|
@@ -409,7 +414,8 @@ function Root(props) {
|
|
|
409
414
|
installedExternalWalletConfig: topInstalledConnectorButtons,
|
|
410
415
|
isEmailPasswordLessLoginVisible: isEmailPasswordLessLoginVisible,
|
|
411
416
|
isSmsPasswordLessLoginVisible: isSmsPasswordLessLoginVisible,
|
|
412
|
-
totalExternalWallets:
|
|
417
|
+
totalExternalWallets: allExternalWallets.length,
|
|
418
|
+
remainingUndisplayedWallets: remainingUndisplayedWallets,
|
|
413
419
|
logoAlignment: logoAlignment,
|
|
414
420
|
buttonRadius: buttonRadiusType,
|
|
415
421
|
deviceDetails: deviceDetails,
|
|
@@ -423,7 +429,7 @@ function Root(props) {
|
|
|
423
429
|
metamaskConnectUri: modalState.metamaskConnectUri,
|
|
424
430
|
config: modalState.externalWalletsConfig,
|
|
425
431
|
walletRegistry: walletRegistry,
|
|
426
|
-
|
|
432
|
+
allRegistryButtons: allRegistryButtons,
|
|
427
433
|
connectorVisibilityMap: connectorVisibilityMap,
|
|
428
434
|
customConnectorButtons: customConnectorButtons,
|
|
429
435
|
deviceDetails: deviceDetails,
|
|
@@ -6,7 +6,7 @@ export interface ConnectWalletProps {
|
|
|
6
6
|
walletConnectUri: string | undefined;
|
|
7
7
|
metamaskConnectUri: string | undefined;
|
|
8
8
|
walletRegistry?: WalletRegistry;
|
|
9
|
-
|
|
9
|
+
allRegistryButtons: ExternalButton[];
|
|
10
10
|
customConnectorButtons: ExternalButton[];
|
|
11
11
|
connectorVisibilityMap: Record<string, boolean>;
|
|
12
12
|
deviceDetails: {
|
|
@@ -20,6 +20,7 @@ export interface LoginProps {
|
|
|
20
20
|
isEmailPasswordLessLoginVisible: boolean;
|
|
21
21
|
isSmsPasswordLessLoginVisible: boolean;
|
|
22
22
|
totalExternalWallets: number;
|
|
23
|
+
remainingUndisplayedWallets: number;
|
|
23
24
|
logoAlignment?: LogoAlignmentType;
|
|
24
25
|
buttonRadius?: ButtonRadiusType;
|
|
25
26
|
deviceDetails: {
|
|
@@ -19,7 +19,7 @@ function ConnectWallet(props) {
|
|
|
19
19
|
walletConnectUri,
|
|
20
20
|
metamaskConnectUri,
|
|
21
21
|
walletRegistry,
|
|
22
|
-
|
|
22
|
+
allRegistryButtons,
|
|
23
23
|
customConnectorButtons,
|
|
24
24
|
connectorVisibilityMap,
|
|
25
25
|
deviceDetails,
|
|
@@ -61,16 +61,16 @@ function ConnectWallet(props) {
|
|
|
61
61
|
}, [walletRegistry]);
|
|
62
62
|
const allUniqueButtons = useMemo(() => {
|
|
63
63
|
const uniqueButtonSet = new Set();
|
|
64
|
-
return customConnectorButtons.concat(
|
|
64
|
+
return customConnectorButtons.concat(allRegistryButtons).filter(button => {
|
|
65
65
|
if (uniqueButtonSet.has(button.name)) return false;
|
|
66
66
|
uniqueButtonSet.add(button.name);
|
|
67
67
|
return true;
|
|
68
68
|
});
|
|
69
|
-
}, [
|
|
69
|
+
}, [allRegistryButtons, customConnectorButtons]);
|
|
70
70
|
const defaultButtonKeys = useMemo(() => new Set(Object.keys(walletRegistry.default)), [walletRegistry]);
|
|
71
71
|
const defaultButtons = useMemo(() => {
|
|
72
72
|
// display order: default injected buttons > custom adapter buttons > default non-injected buttons
|
|
73
|
-
const buttons = [...
|
|
73
|
+
const buttons = [...allRegistryButtons.filter(button => button.hasInjectedWallet && defaultButtonKeys.has(button.name)), ...customConnectorButtons, ...allRegistryButtons.filter(button => !button.hasInjectedWallet && defaultButtonKeys.has(button.name))].sort((a, b) => {
|
|
74
74
|
// favor MetaMask over other wallets
|
|
75
75
|
if (a.name === WALLET_CONNECTORS.METAMASK && b.name === WALLET_CONNECTORS.METAMASK) {
|
|
76
76
|
// favor installed MetaMask over non-installed MetaMask
|
|
@@ -94,7 +94,7 @@ function ConnectWallet(props) {
|
|
|
94
94
|
var _button$chainNamespac;
|
|
95
95
|
return selectedChain === "all" || ((_button$chainNamespac = button.chainNamespaces) === null || _button$chainNamespac === void 0 ? void 0 : _button$chainNamespac.includes(selectedChain));
|
|
96
96
|
});
|
|
97
|
-
}, [
|
|
97
|
+
}, [allRegistryButtons, customConnectorButtons, defaultButtonKeys, selectedChain]);
|
|
98
98
|
const installedWalletButtons = useMemo(() => {
|
|
99
99
|
const visibilityMap = connectorVisibilityMap;
|
|
100
100
|
return Object.keys(config).reduce((acc, localConnector) => {
|
|
@@ -33,6 +33,7 @@ function Login(props) {
|
|
|
33
33
|
isDark,
|
|
34
34
|
handleSocialLoginClick,
|
|
35
35
|
totalExternalWallets,
|
|
36
|
+
remainingUndisplayedWallets,
|
|
36
37
|
isEmailPasswordLessLoginVisible,
|
|
37
38
|
isSmsPasswordLessLoginVisible,
|
|
38
39
|
handleExternalWalletBtnClick,
|
|
@@ -451,7 +452,7 @@ function Login(props) {
|
|
|
451
452
|
src: getIcons(isDark ? "chevron-right-dark" : "chevron-right-light"),
|
|
452
453
|
alt: "arrow"
|
|
453
454
|
})]
|
|
454
|
-
}, wallet.name)),
|
|
455
|
+
}, wallet.name)), remainingUndisplayedWallets > 0 && /*#__PURE__*/jsxs("button", {
|
|
455
456
|
type: "button",
|
|
456
457
|
className: cn("w3a--btn !w3a--justify-between w3a--group w3a--relative w3a--overflow-hidden", {
|
|
457
458
|
"w3a--rounded-full": buttonRadius === "pill",
|
|
@@ -462,10 +463,10 @@ function Login(props) {
|
|
|
462
463
|
children: [/*#__PURE__*/jsx("p", {
|
|
463
464
|
className: "w3a--text-base w3a--font-normal w3a--text-app-gray-900 dark:w3a--text-app-white",
|
|
464
465
|
children: t("modal.external.all-wallets")
|
|
465
|
-
}), showExternalWalletCount &&
|
|
466
|
+
}), showExternalWalletCount && /*#__PURE__*/jsx("div", {
|
|
466
467
|
id: "external-wallet-count",
|
|
467
468
|
className: "w3a--absolute w3a--right-4 w3a--top-1/2 w3a--w-auto -w3a--translate-y-1/2 w3a--rounded-full w3a--bg-app-primary-100 w3a--px-2.5 w3a--py-0.5 w3a--text-xs w3a--font-medium w3a--text-app-primary-800 w3a--transition-all w3a--delay-300 w3a--duration-300 group-hover:w3a--translate-x-6 group-hover:w3a--opacity-0 group-hover:w3a--delay-0 dark:w3a--border dark:w3a--border-app-primary-500 dark:w3a--bg-transparent dark:w3a--text-app-primary-500",
|
|
468
|
-
children:
|
|
469
|
+
children: remainingUndisplayedWallets
|
|
469
470
|
}), /*#__PURE__*/jsx("img", {
|
|
470
471
|
id: "external-wallet-arrow",
|
|
471
472
|
className: "w3a--absolute w3a--right-4 w3a--top-1/2 -w3a--translate-x-10 -w3a--translate-y-1/2 w3a--opacity-0 w3a--transition-all w3a--duration-300 group-hover:w3a--translate-x-0 group-hover:w3a--opacity-100",
|
|
@@ -243,7 +243,7 @@ function Root(props) {
|
|
|
243
243
|
return acc;
|
|
244
244
|
}, []);
|
|
245
245
|
}, [connectorVisibilityMap, chainNamespaces, config, deviceDetails.platform, isWalletConnectConnectorIncluded]);
|
|
246
|
-
const
|
|
246
|
+
const allRegistryButtons = useMemo(() => {
|
|
247
247
|
return [...generateWalletButtons(walletRegistry.default), ...generateWalletButtons(walletRegistry.others)];
|
|
248
248
|
}, [generateWalletButtons, walletRegistry.default, walletRegistry.others]);
|
|
249
249
|
const installedConnectorButtons = useMemo(() => {
|
|
@@ -267,7 +267,7 @@ function Root(props) {
|
|
|
267
267
|
const metamaskConnectorIdx = installedConnectors.findIndex(x => x.name === WALLET_CONNECTORS.METAMASK && !x.hasInjectedWallet);
|
|
268
268
|
if (metamaskConnectorIdx !== -1) {
|
|
269
269
|
const metamaskConnector = installedConnectors[metamaskConnectorIdx];
|
|
270
|
-
let metamaskRegistryButton =
|
|
270
|
+
let metamaskRegistryButton = allRegistryButtons.find(button => button.name === WALLET_CONNECTORS.METAMASK);
|
|
271
271
|
if (!metamaskRegistryButton) {
|
|
272
272
|
// use the default metamask registry item if it's not in the registry
|
|
273
273
|
metamaskRegistryButton = generateWalletButtons({
|
|
@@ -285,7 +285,7 @@ function Root(props) {
|
|
|
285
285
|
|
|
286
286
|
// make metamask the first button and limit the number of buttons
|
|
287
287
|
return installedConnectors;
|
|
288
|
-
}, [
|
|
288
|
+
}, [allRegistryButtons, config, connectorVisibilityMap, generateWalletButtons]);
|
|
289
289
|
const customConnectorButtons = useMemo(() => {
|
|
290
290
|
return installedConnectorButtons.filter(button => !button.hasInjectedWallet);
|
|
291
291
|
}, [installedConnectorButtons]);
|
|
@@ -295,14 +295,19 @@ function Root(props) {
|
|
|
295
295
|
// make metamask the first button and limit the number of buttons
|
|
296
296
|
return installedConnectorButtons.sort((a, _) => a.name === WALLET_CONNECTORS.METAMASK ? -1 : 1).slice(0, displayInstalledExternalWallets ? MAX_TOP_INSTALLED_CONNECTORS : 1);
|
|
297
297
|
}, [installedConnectorButtons, displayInstalledExternalWallets]);
|
|
298
|
-
const
|
|
299
|
-
const
|
|
300
|
-
return
|
|
301
|
-
if (
|
|
302
|
-
|
|
298
|
+
const allExternalWallets = useMemo(() => {
|
|
299
|
+
const uniqueButtonSet = new Set();
|
|
300
|
+
return installedConnectorButtons.concat(allRegistryButtons).filter(button => {
|
|
301
|
+
if (uniqueButtonSet.has(button.name)) return false;
|
|
302
|
+
uniqueButtonSet.add(button.name);
|
|
303
303
|
return true;
|
|
304
|
+
});
|
|
305
|
+
}, [allRegistryButtons, installedConnectorButtons]);
|
|
306
|
+
const remainingUndisplayedWallets = useMemo(() => {
|
|
307
|
+
return allExternalWallets.filter(button => {
|
|
308
|
+
return !topInstalledConnectorButtons.includes(button);
|
|
304
309
|
}).length;
|
|
305
|
-
}, [
|
|
310
|
+
}, [allExternalWallets, topInstalledConnectorButtons]);
|
|
306
311
|
const handleSocialLoginHeight = () => {
|
|
307
312
|
setIsSocialLoginsExpanded(prev => !prev);
|
|
308
313
|
};
|
|
@@ -420,7 +425,8 @@ function Root(props) {
|
|
|
420
425
|
installedExternalWalletConfig: topInstalledConnectorButtons,
|
|
421
426
|
isEmailPasswordLessLoginVisible: isEmailPasswordLessLoginVisible,
|
|
422
427
|
isSmsPasswordLessLoginVisible: isSmsPasswordLessLoginVisible,
|
|
423
|
-
totalExternalWallets:
|
|
428
|
+
totalExternalWallets: allExternalWallets.length,
|
|
429
|
+
remainingUndisplayedWallets: remainingUndisplayedWallets,
|
|
424
430
|
logoAlignment: logoAlignment,
|
|
425
431
|
buttonRadius: buttonRadiusType,
|
|
426
432
|
deviceDetails: deviceDetails,
|
|
@@ -434,7 +440,7 @@ function Root(props) {
|
|
|
434
440
|
metamaskConnectUri: modalState.metamaskConnectUri,
|
|
435
441
|
config: modalState.externalWalletsConfig,
|
|
436
442
|
walletRegistry: walletRegistry,
|
|
437
|
-
|
|
443
|
+
allRegistryButtons: allRegistryButtons,
|
|
438
444
|
connectorVisibilityMap: connectorVisibilityMap,
|
|
439
445
|
customConnectorButtons: customConnectorButtons,
|
|
440
446
|
deviceDetails: deviceDetails,
|