@web3auth/modal 10.3.1 → 10.4.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.
@@ -2,7 +2,7 @@
2
2
 
3
3
  var noModal = require('@web3auth/no-modal');
4
4
 
5
- const version = "10.3.1";
5
+ const version = "10.4.0";
6
6
  const defaultConnectorsModalConfig = {
7
7
  hideWalletDiscovery: false,
8
8
  connectors: {
@@ -391,7 +391,8 @@ class Web3Auth extends noModal.Web3AuthNoModal {
391
391
  showOnModal: true
392
392
  };
393
393
  }
394
- embedWalletConfigMap.set(groupedAuthConnectionId || authConnectionId, authConnectionConfig);
394
+ const id = this.getCombinedConnectionId(authConnectionId, groupedAuthConnectionId);
395
+ embedWalletConfigMap.set(id, authConnectionConfig);
395
396
  }
396
397
  const dashboardConnectorConfig = {
397
398
  [noModal.WALLET_CONNECTORS.AUTH]: {
@@ -415,15 +416,16 @@ class Web3Auth extends noModal.Web3AuthNoModal {
415
416
  }
416
417
  // only throw error if one of them is defined in the config.
417
418
  if (groupedAuthConnectionId || authConnectionId) {
418
- if (!embedWalletConfigMap.has(groupedAuthConnectionId || authConnectionId)) throw noModal.WalletInitializationError.invalidParams(`Invalid auth connection config, authConnection: ${key}. Missing AuthConnectionConfig from the dashboard.`);
419
- const configFromDashboard = embedWalletConfigMap.get(groupedAuthConnectionId || authConnectionId);
420
- this.modalConfig.connectors[noModal.WALLET_CONNECTORS.AUTH].loginMethods[key] = {
419
+ const id = this.getCombinedConnectionId(authConnectionId, groupedAuthConnectionId);
420
+ if (!embedWalletConfigMap.has(id)) throw noModal.WalletInitializationError.invalidParams(`Invalid auth connection config, authConnection: ${key}. Missing AuthConnectionConfig from the dashboard.`);
421
+ const configFromDashboard = embedWalletConfigMap.get(id);
422
+ this.modalConfig.connectors[noModal.WALLET_CONNECTORS.AUTH].loginMethods[key] = _objectSpread(_objectSpread({}, userConfig), {}, {
421
423
  authConnection: configFromDashboard.authConnection,
422
424
  authConnectionId: configFromDashboard.authConnectionId,
423
425
  groupedAuthConnectionId: configFromDashboard.groupedAuthConnectionId,
424
426
  isDefault: configFromDashboard.isDefault || false,
425
427
  extraLoginOptions: _objectSpread(_objectSpread({}, configFromDashboard.jwtParameters), userConfig.extraLoginOptions)
426
- };
428
+ });
427
429
  }
428
430
  });
429
431
  this.modalConfig.connectors = deepmerge(dashboardConnectorConfig, noModal.cloneDeep(this.modalConfig.connectors || {}));
@@ -567,6 +569,13 @@ class Web3Auth extends noModal.Web3AuthNoModal {
567
569
  }
568
570
  });
569
571
  }
572
+ getCombinedConnectionId(authConnectionId, groupedAuthConnectionId) {
573
+ let id = authConnectionId;
574
+ if (groupedAuthConnectionId) {
575
+ id = `${groupedAuthConnectionId}_${authConnectionId}`;
576
+ }
577
+ return id;
578
+ }
570
579
  }
571
580
 
572
581
  exports.Web3Auth = Web3Auth;
@@ -27,6 +27,7 @@ function ConnectWallet(props) {
27
27
  deviceDetails,
28
28
  buttonRadius = "pill",
29
29
  chainNamespace,
30
+ isExternalWalletModeOnly,
30
31
  onBackClick,
31
32
  handleExternalWalletClick,
32
33
  handleWalletDetailsHeight
@@ -215,9 +216,17 @@ function ConnectWallet(props) {
215
216
  }
216
217
  return walletConnectUri;
217
218
  }, [metamaskConnectUri, selectedButton, selectedWallet, walletConnectUri]);
219
+ const disableBackButton = react.useMemo(() => {
220
+ // If wallet is selected, show the back button
221
+ if (selectedWallet) return false;
222
+ // Otherwise, if external wallet mode only, login screen is skipped so back button is not needed
223
+ if (isExternalWalletModeOnly) return true;
224
+ return false;
225
+ }, [selectedWallet, isExternalWalletModeOnly]);
218
226
  return jsxRuntime.jsxs("div", {
219
227
  className: "w3a--relative w3a--flex w3a--flex-1 w3a--flex-col w3a--gap-y-4",
220
228
  children: [jsxRuntime.jsx(ConnectWalletHeader, {
229
+ disableBackButton: disableBackButton,
221
230
  onBackClick: handleBack,
222
231
  currentPage: currentPage,
223
232
  selectedButton: selectedButton
@@ -229,7 +238,7 @@ function ConnectWallet(props) {
229
238
  logoImage: `https://images.web3auth.io/login-${selectedButton.name}.${selectedButton.imgExtension}`
230
239
  }) : jsxRuntime.jsxs("div", {
231
240
  className: "w3a--flex w3a--flex-col w3a--gap-y-2",
232
- children: [jsxRuntime.jsx(ConnectWalletChainFilter, {
241
+ children: [chainNamespace.length > 1 && jsxRuntime.jsx(ConnectWalletChainFilter, {
233
242
  isDark: isDark,
234
243
  isLoading: isLoading,
235
244
  selectedChain: selectedChain,
@@ -7,6 +7,7 @@ var localeImport = require('../../../localeImport.js');
7
7
 
8
8
  function ConnectWalletHeader(props) {
9
9
  const {
10
+ disableBackButton,
10
11
  onBackClick,
11
12
  currentPage,
12
13
  selectedButton
@@ -21,7 +22,7 @@ function ConnectWalletHeader(props) {
21
22
  };
22
23
  return jsxRuntime.jsxs("div", {
23
24
  className: "w3a--flex w3a--items-center w3a--justify-between",
24
- children: [jsxRuntime.jsx("button", {
25
+ children: [!disableBackButton ? jsxRuntime.jsx("button", {
25
26
  type: "button",
26
27
  className: "w3a--z-20 w3a--flex w3a--size-5 w3a--cursor-pointer w3a--items-center w3a--justify-center w3a--rounded-full",
27
28
  onClick: handleBack,
@@ -37,7 +38,7 @@ function ConnectWalletHeader(props) {
37
38
  clipRule: "evenodd"
38
39
  })
39
40
  })
40
- }), jsxRuntime.jsx("p", {
41
+ }) : jsxRuntime.jsx("div", {}), jsxRuntime.jsx("p", {
41
42
  className: "w3a--text-base w3a--font-medium w3a--text-app-gray-900 dark:w3a--text-app-white",
42
43
  children: currentPage === constants.CONNECT_WALLET_PAGES.SELECTED_WALLET ? selectedButton === null || selectedButton === void 0 ? void 0 : selectedButton.displayName : currentPage === constants.CONNECT_WALLET_PAGES.CONNECT_WALLET ? t("modal.connectYourWallet") : currentPage
43
44
  }), jsxRuntime.jsx("div", {
@@ -62,7 +62,7 @@ function Login(props) {
62
62
  const [countryFlag, setCountryFlag] = react.useState("");
63
63
  const [passwordlessErrorMessage, setPasswordlessErrorMessage] = react.useState("");
64
64
  const [otpErrorMessage, setOtpErrorMessage] = react.useState("");
65
- const [expand, setExpand] = react.useState(false);
65
+ const [expandSocialLogins, setExpandSocialLogins] = react.useState(false);
66
66
  const [canShowMore, setCanShowMore] = react.useState(false);
67
67
  const [visibleRow, setVisibleRow] = react.useState([]);
68
68
  const [otherRow, setOtherRow] = react.useState([]);
@@ -75,14 +75,14 @@ function Login(props) {
75
75
  const [showCaptcha, setShowCaptcha] = react.useState(false);
76
76
  const [captchaError, setCaptchaError] = react.useState("");
77
77
  const captchaRef = react.useRef(null);
78
- const handleExpand = () => {
79
- setExpand(prev => !prev);
78
+ const handleSocialLoginExpand = () => {
79
+ setExpandSocialLogins(prev => !prev);
80
80
  setIsPasswordLessCtaClicked(false);
81
81
  handleSocialLoginHeight();
82
82
  };
83
83
  react.useEffect(() => {
84
84
  const maxOptions = Object.keys(socialLoginsConfig.loginMethods).filter(loginMethodKey => {
85
- return socialLoginsConfig.loginMethods[loginMethodKey].showOnModal;
85
+ return socialLoginsConfig.loginMethods[loginMethodKey].showOnModal && !restrictedLoginMethods.includes(loginMethodKey);
86
86
  });
87
87
  const visibleRows = [];
88
88
  const otherRows = [];
@@ -273,15 +273,6 @@ function Login(props) {
273
273
  };
274
274
  if (isSmsPasswordLessLoginVisible) getLocation();
275
275
  }, [isSmsPasswordLessLoginVisible]);
276
- const handleConnectWallet = e => {
277
- analytics === null || analytics === void 0 || analytics.track(noModal.ANALYTICS_EVENTS.EXTERNAL_WALLET_LIST_EXPANDED, {
278
- total_external_wallets: totalExternalWallets,
279
- installed_external_wallets: installedExternalWallets.length
280
- });
281
- setIsPasswordLessCtaClicked(false);
282
- e.preventDefault();
283
- if (handleExternalWalletBtnClick) handleExternalWalletBtnClick(true);
284
- };
285
276
  const handleOtpComplete = async otp => {
286
277
  setOtpLoading(true);
287
278
  if (otpErrorMessage) setOtpErrorMessage("");
@@ -367,6 +358,20 @@ function Login(props) {
367
358
  // always show MetaMask
368
359
  return installedExternalWalletConfig.filter(wallet => wallet.name === noModal.WALLET_CONNECTORS.METAMASK);
369
360
  }, [installedExternalWalletConfig, showInstalledExternalWallets]);
361
+ const handleConnectWallet = react.useCallback(e => {
362
+ analytics === null || analytics === void 0 || analytics.track(noModal.ANALYTICS_EVENTS.EXTERNAL_WALLET_LIST_EXPANDED, {
363
+ total_external_wallets: totalExternalWallets,
364
+ installed_external_wallets: installedExternalWallets.length
365
+ });
366
+ setIsPasswordLessCtaClicked(false);
367
+ e === null || e === void 0 || e.preventDefault();
368
+ if (handleExternalWalletBtnClick) handleExternalWalletBtnClick(true);
369
+ }, [analytics, handleExternalWalletBtnClick, installedExternalWallets.length, totalExternalWallets]);
370
+ react.useEffect(() => {
371
+ if (showExternalWalletButton && !areSocialLoginsVisible && !showPasswordLessInput) {
372
+ handleConnectWallet();
373
+ }
374
+ }, [showExternalWalletButton, areSocialLoginsVisible, showPasswordLessInput, handleConnectWallet]);
370
375
  if (showOtpFlow) {
371
376
  return jsxRuntime.jsx(LoginOtp, {
372
377
  otpLoading: otpLoading,
@@ -386,7 +391,7 @@ function Login(props) {
386
391
  canShowMore: canShowMore,
387
392
  handleSocialLoginClick: handleSocialLoginClick,
388
393
  socialLoginsConfig: socialLoginsConfig,
389
- handleExpandSocialLogins: handleExpand,
394
+ handleExpandSocialLogins: handleSocialLoginExpand,
390
395
  buttonRadius: buttonRadius
391
396
  }, "social-login-section");
392
397
  };
@@ -522,7 +527,7 @@ function Login(props) {
522
527
  }
523
528
  return sections;
524
529
  };
525
- const expandedView = () => socialLoginSection(otherRow);
530
+ const socialLoginExpandedView = () => socialLoginSection(otherRow);
526
531
  return jsxRuntime.jsxs("div", {
527
532
  className: "w3a--flex w3a--flex-col w3a--items-center w3a--gap-y-4 w3a--p-2",
528
533
  children: [jsxRuntime.jsxs("div", {
@@ -553,7 +558,7 @@ function Login(props) {
553
558
  children: t(captchaError)
554
559
  }), !showCaptcha && jsxRuntime.jsxs("div", {
555
560
  className: "w3a--flex w3a--w-full w3a--flex-col w3a--items-center w3a--justify-center w3a--gap-y-2",
556
- children: [!expand && defaultView(), expand && expandedView()]
561
+ children: [!expandSocialLogins && defaultView(), expandSocialLogins && socialLoginExpandedView()]
557
562
  })]
558
563
  });
559
564
  }
@@ -92,6 +92,9 @@ function Root(props) {
92
92
  }));
93
93
  if (handleExternalWalletBtnClick) handleExternalWalletBtnClick(flag);
94
94
  };
95
+ const isExternalWalletModeOnly = react.useMemo(() => {
96
+ return !showPasswordLessInput && !areSocialLoginsVisible;
97
+ }, [areSocialLoginsVisible, showPasswordLessInput]);
95
98
  // Wallet Details
96
99
  const mobileInstallLinks = react.useMemo(() => {
97
100
  var _bodyState$installLin;
@@ -427,6 +430,7 @@ function Root(props) {
427
430
  chainNamespace: chainNamespaces,
428
431
  buttonRadius: buttonRadiusType,
429
432
  handleWalletDetailsHeight: handleWalletDetailsHeight,
433
+ isExternalWalletModeOnly: isExternalWalletModeOnly,
430
434
  onBackClick: onBackClick,
431
435
  handleExternalWalletClick: preHandleExternalWalletClick
432
436
  })]
@@ -100,7 +100,7 @@ function Widget(props) {
100
100
  var _modalState$socialLog, _modalState$socialLog2;
101
101
  if (modalState.showExternalWalletsOnly) return false;
102
102
  if (Object.keys(((_modalState$socialLog = modalState.socialLoginsConfig) === null || _modalState$socialLog === void 0 ? void 0 : _modalState$socialLog.loginMethods) || {}).length === 0) return false;
103
- const isAnySocialLoginVisible = Object.entries(((_modalState$socialLog2 = modalState.socialLoginsConfig) === null || _modalState$socialLog2 === void 0 ? void 0 : _modalState$socialLog2.loginMethods) || {}).some(([k, v]) => k !== auth.AUTH_CONNECTION.EMAIL_PASSWORDLESS && v.showOnModal !== false);
103
+ const isAnySocialLoginVisible = Object.entries(((_modalState$socialLog2 = modalState.socialLoginsConfig) === null || _modalState$socialLog2 === void 0 ? void 0 : _modalState$socialLog2.loginMethods) || {}).some(([k, v]) => ![auth.AUTH_CONNECTION.EMAIL_PASSWORDLESS, auth.AUTH_CONNECTION.SMS_PASSWORDLESS].includes(k) && v.showOnModal !== false);
104
104
  return isAnySocialLoginVisible;
105
105
  }, [modalState]);
106
106
  // Memo for checking if email passwordless login is visible
@@ -34,4 +34,5 @@ export declare class Web3Auth extends Web3AuthNoModal implements IWeb3AuthModal
34
34
  private onExternalWalletLogin;
35
35
  private onModalVisibility;
36
36
  private getChainNamespaces;
37
+ private getCombinedConnectionId;
37
38
  }
@@ -16,6 +16,7 @@ export interface ConnectWalletProps {
16
16
  };
17
17
  chainNamespace: ChainNamespaceType[];
18
18
  buttonRadius: ButtonRadiusType;
19
+ isExternalWalletModeOnly: boolean;
19
20
  onBackClick?: (flag: boolean) => void;
20
21
  handleExternalWalletClick: (params: {
21
22
  connector: string;
@@ -1,5 +1,6 @@
1
1
  import { ExternalButton } from "../../../interfaces";
2
2
  export interface ConnectWalletHeaderProps {
3
+ disableBackButton?: boolean;
3
4
  onBackClick: () => void;
4
5
  currentPage: string;
5
6
  selectedButton: ExternalButton;
@@ -1,6 +1,6 @@
1
1
  import { EVM_CONNECTORS } from '@web3auth/no-modal';
2
2
 
3
- const version = "10.3.1";
3
+ const version = "10.4.0";
4
4
  const defaultConnectorsModalConfig = {
5
5
  hideWalletDiscovery: false,
6
6
  connectors: {
@@ -406,7 +406,8 @@ class Web3Auth extends Web3AuthNoModal {
406
406
  showOnModal: true
407
407
  };
408
408
  }
409
- embedWalletConfigMap.set(groupedAuthConnectionId || authConnectionId, authConnectionConfig);
409
+ const id = this.getCombinedConnectionId(authConnectionId, groupedAuthConnectionId);
410
+ embedWalletConfigMap.set(id, authConnectionConfig);
410
411
  }
411
412
  const dashboardConnectorConfig = {
412
413
  [WALLET_CONNECTORS.AUTH]: {
@@ -432,15 +433,16 @@ class Web3Auth extends Web3AuthNoModal {
432
433
 
433
434
  // only throw error if one of them is defined in the config.
434
435
  if (groupedAuthConnectionId || authConnectionId) {
435
- if (!embedWalletConfigMap.has(groupedAuthConnectionId || authConnectionId)) throw WalletInitializationError.invalidParams(`Invalid auth connection config, authConnection: ${key}. Missing AuthConnectionConfig from the dashboard.`);
436
- const configFromDashboard = embedWalletConfigMap.get(groupedAuthConnectionId || authConnectionId);
437
- this.modalConfig.connectors[WALLET_CONNECTORS.AUTH].loginMethods[key] = {
436
+ const id = this.getCombinedConnectionId(authConnectionId, groupedAuthConnectionId);
437
+ if (!embedWalletConfigMap.has(id)) throw WalletInitializationError.invalidParams(`Invalid auth connection config, authConnection: ${key}. Missing AuthConnectionConfig from the dashboard.`);
438
+ const configFromDashboard = embedWalletConfigMap.get(id);
439
+ this.modalConfig.connectors[WALLET_CONNECTORS.AUTH].loginMethods[key] = _objectSpread(_objectSpread({}, userConfig), {}, {
438
440
  authConnection: configFromDashboard.authConnection,
439
441
  authConnectionId: configFromDashboard.authConnectionId,
440
442
  groupedAuthConnectionId: configFromDashboard.groupedAuthConnectionId,
441
443
  isDefault: configFromDashboard.isDefault || false,
442
444
  extraLoginOptions: _objectSpread(_objectSpread({}, configFromDashboard.jwtParameters), userConfig.extraLoginOptions)
443
- };
445
+ });
444
446
  }
445
447
  });
446
448
  this.modalConfig.connectors = deepmerge(dashboardConnectorConfig, cloneDeep(this.modalConfig.connectors || {}));
@@ -598,6 +600,13 @@ class Web3Auth extends Web3AuthNoModal {
598
600
  }
599
601
  });
600
602
  }
603
+ getCombinedConnectionId(authConnectionId, groupedAuthConnectionId) {
604
+ let id = authConnectionId;
605
+ if (groupedAuthConnectionId) {
606
+ id = `${groupedAuthConnectionId}_${authConnectionId}`;
607
+ }
608
+ return id;
609
+ }
601
610
  }
602
611
 
603
612
  export { Web3Auth };
@@ -25,6 +25,7 @@ function ConnectWallet(props) {
25
25
  deviceDetails,
26
26
  buttonRadius = "pill",
27
27
  chainNamespace,
28
+ isExternalWalletModeOnly,
28
29
  onBackClick,
29
30
  handleExternalWalletClick,
30
31
  handleWalletDetailsHeight
@@ -217,9 +218,17 @@ function ConnectWallet(props) {
217
218
  }
218
219
  return walletConnectUri;
219
220
  }, [metamaskConnectUri, selectedButton, selectedWallet, walletConnectUri]);
221
+ const disableBackButton = useMemo(() => {
222
+ // If wallet is selected, show the back button
223
+ if (selectedWallet) return false;
224
+ // Otherwise, if external wallet mode only, login screen is skipped so back button is not needed
225
+ if (isExternalWalletModeOnly) return true;
226
+ return false;
227
+ }, [selectedWallet, isExternalWalletModeOnly]);
220
228
  return /*#__PURE__*/jsxs("div", {
221
229
  className: "w3a--relative w3a--flex w3a--flex-1 w3a--flex-col w3a--gap-y-4",
222
230
  children: [/*#__PURE__*/jsx(ConnectWalletHeader, {
231
+ disableBackButton: disableBackButton,
223
232
  onBackClick: handleBack,
224
233
  currentPage: currentPage,
225
234
  selectedButton: selectedButton
@@ -231,7 +240,7 @@ function ConnectWallet(props) {
231
240
  logoImage: `https://images.web3auth.io/login-${selectedButton.name}.${selectedButton.imgExtension}`
232
241
  }) : /*#__PURE__*/jsxs("div", {
233
242
  className: "w3a--flex w3a--flex-col w3a--gap-y-2",
234
- children: [/*#__PURE__*/jsx(ConnectWalletChainFilter, {
243
+ children: [chainNamespace.length > 1 && /*#__PURE__*/jsx(ConnectWalletChainFilter, {
235
244
  isDark: isDark,
236
245
  isLoading: isLoading,
237
246
  selectedChain: selectedChain,
@@ -5,6 +5,7 @@ import { jsxs, jsx } from 'react/jsx-runtime';
5
5
 
6
6
  function ConnectWalletHeader(props) {
7
7
  const {
8
+ disableBackButton,
8
9
  onBackClick,
9
10
  currentPage,
10
11
  selectedButton
@@ -19,7 +20,7 @@ function ConnectWalletHeader(props) {
19
20
  };
20
21
  return /*#__PURE__*/jsxs("div", {
21
22
  className: "w3a--flex w3a--items-center w3a--justify-between",
22
- children: [/*#__PURE__*/jsx("button", {
23
+ children: [!disableBackButton ? /*#__PURE__*/jsx("button", {
23
24
  type: "button",
24
25
  className: "w3a--z-20 w3a--flex w3a--size-5 w3a--cursor-pointer w3a--items-center w3a--justify-center w3a--rounded-full",
25
26
  onClick: handleBack,
@@ -35,7 +36,7 @@ function ConnectWalletHeader(props) {
35
36
  clipRule: "evenodd"
36
37
  })
37
38
  })
38
- }), /*#__PURE__*/jsx("p", {
39
+ }) : /*#__PURE__*/jsx("div", {}), /*#__PURE__*/jsx("p", {
39
40
  className: "w3a--text-base w3a--font-medium w3a--text-app-gray-900 dark:w3a--text-app-white",
40
41
  children: currentPage === CONNECT_WALLET_PAGES.SELECTED_WALLET ? selectedButton === null || selectedButton === void 0 ? void 0 : selectedButton.displayName : currentPage === CONNECT_WALLET_PAGES.CONNECT_WALLET ? t("modal.connectYourWallet") : currentPage
41
42
  }), /*#__PURE__*/jsx("div", {
@@ -1,8 +1,8 @@
1
1
  import _objectSpread from '@babel/runtime/helpers/objectSpread2';
2
2
  import HCaptcha from '@hcaptcha/react-hcaptcha';
3
3
  import { AUTH_CONNECTION } from '@web3auth/auth';
4
- import { WALLET_CONNECTORS, log, ANALYTICS_EVENTS, WalletLoginError } from '@web3auth/no-modal';
5
- import { useContext, useState, useRef, useEffect, useMemo } from 'react';
4
+ import { WALLET_CONNECTORS, ANALYTICS_EVENTS, log, WalletLoginError } from '@web3auth/no-modal';
5
+ import { useContext, useState, useRef, useEffect, useMemo, useCallback } from 'react';
6
6
  import { useTranslation } from 'react-i18next';
7
7
  import { capitalizeFirstLetter, CAPTCHA_SITE_KEY } from '../../config.js';
8
8
  import { DEFAULT_LOGO_DARK, DEFAULT_LOGO_LIGHT } from '../../constants.js';
@@ -60,7 +60,7 @@ function Login(props) {
60
60
  const [countryFlag, setCountryFlag] = useState("");
61
61
  const [passwordlessErrorMessage, setPasswordlessErrorMessage] = useState("");
62
62
  const [otpErrorMessage, setOtpErrorMessage] = useState("");
63
- const [expand, setExpand] = useState(false);
63
+ const [expandSocialLogins, setExpandSocialLogins] = useState(false);
64
64
  const [canShowMore, setCanShowMore] = useState(false);
65
65
  const [visibleRow, setVisibleRow] = useState([]);
66
66
  const [otherRow, setOtherRow] = useState([]);
@@ -73,14 +73,14 @@ function Login(props) {
73
73
  const [showCaptcha, setShowCaptcha] = useState(false);
74
74
  const [captchaError, setCaptchaError] = useState("");
75
75
  const captchaRef = useRef(null);
76
- const handleExpand = () => {
77
- setExpand(prev => !prev);
76
+ const handleSocialLoginExpand = () => {
77
+ setExpandSocialLogins(prev => !prev);
78
78
  setIsPasswordLessCtaClicked(false);
79
79
  handleSocialLoginHeight();
80
80
  };
81
81
  useEffect(() => {
82
82
  const maxOptions = Object.keys(socialLoginsConfig.loginMethods).filter(loginMethodKey => {
83
- return socialLoginsConfig.loginMethods[loginMethodKey].showOnModal;
83
+ return socialLoginsConfig.loginMethods[loginMethodKey].showOnModal && !restrictedLoginMethods.includes(loginMethodKey);
84
84
  });
85
85
  const visibleRows = [];
86
86
  const otherRows = [];
@@ -274,15 +274,6 @@ function Login(props) {
274
274
  };
275
275
  if (isSmsPasswordLessLoginVisible) getLocation();
276
276
  }, [isSmsPasswordLessLoginVisible]);
277
- const handleConnectWallet = e => {
278
- analytics === null || analytics === void 0 || analytics.track(ANALYTICS_EVENTS.EXTERNAL_WALLET_LIST_EXPANDED, {
279
- total_external_wallets: totalExternalWallets,
280
- installed_external_wallets: installedExternalWallets.length
281
- });
282
- setIsPasswordLessCtaClicked(false);
283
- e.preventDefault();
284
- if (handleExternalWalletBtnClick) handleExternalWalletBtnClick(true);
285
- };
286
277
  const handleOtpComplete = async otp => {
287
278
  setOtpLoading(true);
288
279
  if (otpErrorMessage) setOtpErrorMessage("");
@@ -370,6 +361,20 @@ function Login(props) {
370
361
  // always show MetaMask
371
362
  return installedExternalWalletConfig.filter(wallet => wallet.name === WALLET_CONNECTORS.METAMASK);
372
363
  }, [installedExternalWalletConfig, showInstalledExternalWallets]);
364
+ const handleConnectWallet = useCallback(e => {
365
+ analytics === null || analytics === void 0 || analytics.track(ANALYTICS_EVENTS.EXTERNAL_WALLET_LIST_EXPANDED, {
366
+ total_external_wallets: totalExternalWallets,
367
+ installed_external_wallets: installedExternalWallets.length
368
+ });
369
+ setIsPasswordLessCtaClicked(false);
370
+ e === null || e === void 0 || e.preventDefault();
371
+ if (handleExternalWalletBtnClick) handleExternalWalletBtnClick(true);
372
+ }, [analytics, handleExternalWalletBtnClick, installedExternalWallets.length, totalExternalWallets]);
373
+ useEffect(() => {
374
+ if (showExternalWalletButton && !areSocialLoginsVisible && !showPasswordLessInput) {
375
+ handleConnectWallet();
376
+ }
377
+ }, [showExternalWalletButton, areSocialLoginsVisible, showPasswordLessInput, handleConnectWallet]);
373
378
  if (showOtpFlow) {
374
379
  return /*#__PURE__*/jsx(LoginOtp, {
375
380
  otpLoading: otpLoading,
@@ -389,7 +394,7 @@ function Login(props) {
389
394
  canShowMore: canShowMore,
390
395
  handleSocialLoginClick: handleSocialLoginClick,
391
396
  socialLoginsConfig: socialLoginsConfig,
392
- handleExpandSocialLogins: handleExpand,
397
+ handleExpandSocialLogins: handleSocialLoginExpand,
393
398
  buttonRadius: buttonRadius
394
399
  }, "social-login-section");
395
400
  };
@@ -527,7 +532,7 @@ function Login(props) {
527
532
  }
528
533
  return sections;
529
534
  };
530
- const expandedView = () => socialLoginSection(otherRow);
535
+ const socialLoginExpandedView = () => socialLoginSection(otherRow);
531
536
  return /*#__PURE__*/jsxs("div", {
532
537
  className: "w3a--flex w3a--flex-col w3a--items-center w3a--gap-y-4 w3a--p-2",
533
538
  children: [/*#__PURE__*/jsxs("div", {
@@ -558,7 +563,7 @@ function Login(props) {
558
563
  children: t(captchaError)
559
564
  }), !showCaptcha && /*#__PURE__*/jsxs("div", {
560
565
  className: "w3a--flex w3a--w-full w3a--flex-col w3a--items-center w3a--justify-center w3a--gap-y-2",
561
- children: [!expand && defaultView(), expand && expandedView()]
566
+ children: [!expandSocialLogins && defaultView(), expandSocialLogins && socialLoginExpandedView()]
562
567
  })]
563
568
  });
564
569
  }
@@ -90,6 +90,9 @@ function Root(props) {
90
90
  }));
91
91
  if (handleExternalWalletBtnClick) handleExternalWalletBtnClick(flag);
92
92
  };
93
+ const isExternalWalletModeOnly = useMemo(() => {
94
+ return !showPasswordLessInput && !areSocialLoginsVisible;
95
+ }, [areSocialLoginsVisible, showPasswordLessInput]);
93
96
 
94
97
  // Wallet Details
95
98
  const mobileInstallLinks = useMemo(() => {
@@ -438,6 +441,7 @@ function Root(props) {
438
441
  chainNamespace: chainNamespaces,
439
442
  buttonRadius: buttonRadiusType,
440
443
  handleWalletDetailsHeight: handleWalletDetailsHeight,
444
+ isExternalWalletModeOnly: isExternalWalletModeOnly,
441
445
  onBackClick: onBackClick,
442
446
  handleExternalWalletClick: preHandleExternalWalletClick
443
447
  })]
@@ -100,7 +100,7 @@ function Widget(props) {
100
100
  var _modalState$socialLog, _modalState$socialLog2;
101
101
  if (modalState.showExternalWalletsOnly) return false;
102
102
  if (Object.keys(((_modalState$socialLog = modalState.socialLoginsConfig) === null || _modalState$socialLog === void 0 ? void 0 : _modalState$socialLog.loginMethods) || {}).length === 0) return false;
103
- const isAnySocialLoginVisible = Object.entries(((_modalState$socialLog2 = modalState.socialLoginsConfig) === null || _modalState$socialLog2 === void 0 ? void 0 : _modalState$socialLog2.loginMethods) || {}).some(([k, v]) => k !== AUTH_CONNECTION.EMAIL_PASSWORDLESS && v.showOnModal !== false);
103
+ const isAnySocialLoginVisible = Object.entries(((_modalState$socialLog2 = modalState.socialLoginsConfig) === null || _modalState$socialLog2 === void 0 ? void 0 : _modalState$socialLog2.loginMethods) || {}).some(([k, v]) => ![AUTH_CONNECTION.EMAIL_PASSWORDLESS, AUTH_CONNECTION.SMS_PASSWORDLESS].includes(k) && v.showOnModal !== false);
104
104
  return isAnySocialLoginVisible;
105
105
  }, [modalState]);
106
106