@web3auth/modal 10.8.2 → 10.8.3

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.8.2";
5
+ const version = "10.8.3";
6
6
  const defaultConnectorsModalConfig = {
7
7
  hideWalletDiscovery: false,
8
8
  connectors: {
@@ -118,7 +118,6 @@ function ConnectWallet(props) {
118
118
  };
119
119
  const handleChainFilterChange = chain => {
120
120
  setSelectedChain(chain);
121
- setIsShowAllWallets(false);
122
121
  };
123
122
  const filteredButtons = react.useMemo(() => {
124
123
  if (walletDiscoverySupported) {
@@ -137,6 +136,15 @@ function ConnectWallet(props) {
137
136
  if (isShowAllWallets) return totalExternalWalletsCount;
138
137
  return walletDiscoverySupported ? defaultButtons.length : installedWalletButtons.length;
139
138
  }, [walletDiscoverySupported, defaultButtons, installedWalletButtons, isShowAllWallets, totalExternalWalletsCount]);
139
+ // Automatically show all wallets if there are less than or equal to 15 wallets
140
+ // also resets everytime we search causing no. of wallets to change or select different chain
141
+ react.useEffect(() => {
142
+ if (walletDiscoverySupported && totalExternalWalletsCount <= 15) {
143
+ setIsShowAllWallets(true);
144
+ } else {
145
+ setIsShowAllWallets(false);
146
+ }
147
+ }, [walletDiscoverySupported, selectedChain, totalExternalWalletsCount]);
140
148
  /**
141
149
  * Wallet click logic
142
150
  * - For installed wallets
@@ -261,7 +269,8 @@ function ConnectWallet(props) {
261
269
  isDark: isDark,
262
270
  deviceDetails: deviceDetails,
263
271
  walletConnectUri: walletConnectUri,
264
- buttonRadius: buttonRadius
272
+ buttonRadius: buttonRadius,
273
+ isShowAllWallets: isShowAllWallets
265
274
  })]
266
275
  })]
267
276
  });
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
3
  var jsxRuntime = require('react/jsx-runtime');
4
- var react = require('react');
5
4
  var reactI18next = require('react-i18next');
6
5
  var localeImport = require('../../../localeImport.js');
7
6
  var utils = require('../../../utils.js');
@@ -114,17 +113,17 @@ function ConnectWalletList(props) {
114
113
  isDark,
115
114
  deviceDetails,
116
115
  walletConnectUri,
117
- buttonRadius
116
+ buttonRadius,
117
+ isShowAllWallets
118
118
  } = props;
119
- const [showMoreWallets, setShowMoreWallets] = react.useState(true);
120
119
  const onShowMoreWalletsClick = () => {
121
- setShowMoreWallets(false);
122
120
  handleMoreWallets();
123
121
  };
122
+ const showMoreWalletsButton = !isShowAllWallets;
124
123
  return jsxRuntime.jsxs(jsxRuntime.Fragment, {
125
124
  children: [jsxRuntime.jsx("ul", {
126
125
  className: utils.cn("w3a--overflow-y-auto w3a--flex w3a--flex-col w3a--gap-y-2 w3a--h-[280px] w3a--social-container w3a--pr-2.5", {
127
- "w3a--h-[328px]": !showMoreWallets
126
+ "w3a--h-[328px]": !showMoreWalletsButton
128
127
  }),
129
128
  children: externalButtons.length === 0 ? jsxRuntime.jsx(NoWalletsFound, {}) : jsxRuntime.jsx(WalletsFound, {
130
129
  externalButtons: externalButtons,
@@ -134,7 +133,7 @@ function ConnectWalletList(props) {
134
133
  walletConnectUri: walletConnectUri,
135
134
  buttonRadius: buttonRadius
136
135
  })
137
- }), showMoreWallets && totalExternalWalletsCount > 15 && !isLoading && initialWalletCount < totalExternalWalletsCount && jsxRuntime.jsx(MoreWalletsButton, {
136
+ }), showMoreWalletsButton && !isLoading && initialWalletCount < totalExternalWalletsCount && jsxRuntime.jsx(MoreWalletsButton, {
138
137
  totalExternalWalletsCount: totalExternalWalletsCount,
139
138
  initialWalletCount: initialWalletCount,
140
139
  handleMoreWallets: onShowMoreWalletsClick,
@@ -14,6 +14,7 @@ export interface ConnectWalletListProps {
14
14
  buttonRadius: ButtonRadiusType;
15
15
  handleWalletClick: (button: ExternalButton) => void;
16
16
  handleMoreWallets: () => void;
17
+ isShowAllWallets: boolean;
17
18
  }
18
19
  export type WalletsFoundProps = Pick<ConnectWalletListProps, "externalButtons" | "isLoading" | "handleWalletClick" | "deviceDetails" | "walletConnectUri" | "buttonRadius">;
19
20
  export type MoreWalletsButtonProps = Pick<ConnectWalletListProps, "totalExternalWalletsCount" | "initialWalletCount" | "handleMoreWallets" | "isLoading" | "isDark" | "buttonRadius">;
@@ -1,6 +1,6 @@
1
1
  import { EVM_CONNECTORS } from '@web3auth/no-modal';
2
2
 
3
- const version = "10.8.2";
3
+ const version = "10.8.3";
4
4
  const defaultConnectorsModalConfig = {
5
5
  hideWalletDiscovery: false,
6
6
  connectors: {
@@ -1,6 +1,6 @@
1
1
  import _objectSpread from '@babel/runtime/helpers/objectSpread2';
2
2
  import { WALLET_CONNECTORS, ANALYTICS_EVENTS, log } from '@web3auth/no-modal';
3
- import { useContext, useState, useMemo } from 'react';
3
+ import { useContext, useState, useMemo, useEffect } from 'react';
4
4
  import { CONNECT_WALLET_PAGES } from '../../constants.js';
5
5
  import { AnalyticsContext } from '../../context/AnalyticsContext.js';
6
6
  import { RootContext } from '../../context/RootContext.js';
@@ -116,7 +116,6 @@ function ConnectWallet(props) {
116
116
  };
117
117
  const handleChainFilterChange = chain => {
118
118
  setSelectedChain(chain);
119
- setIsShowAllWallets(false);
120
119
  };
121
120
  const filteredButtons = useMemo(() => {
122
121
  if (walletDiscoverySupported) {
@@ -136,6 +135,16 @@ function ConnectWallet(props) {
136
135
  return walletDiscoverySupported ? defaultButtons.length : installedWalletButtons.length;
137
136
  }, [walletDiscoverySupported, defaultButtons, installedWalletButtons, isShowAllWallets, totalExternalWalletsCount]);
138
137
 
138
+ // Automatically show all wallets if there are less than or equal to 15 wallets
139
+ // also resets everytime we search causing no. of wallets to change or select different chain
140
+ useEffect(() => {
141
+ if (walletDiscoverySupported && totalExternalWalletsCount <= 15) {
142
+ setIsShowAllWallets(true);
143
+ } else {
144
+ setIsShowAllWallets(false);
145
+ }
146
+ }, [walletDiscoverySupported, selectedChain, totalExternalWalletsCount]);
147
+
139
148
  /**
140
149
  * Wallet click logic
141
150
  * - For installed wallets
@@ -263,7 +272,8 @@ function ConnectWallet(props) {
263
272
  isDark: isDark,
264
273
  deviceDetails: deviceDetails,
265
274
  walletConnectUri: walletConnectUri,
266
- buttonRadius: buttonRadius
275
+ buttonRadius: buttonRadius,
276
+ isShowAllWallets: isShowAllWallets
267
277
  })]
268
278
  })]
269
279
  });
@@ -1,4 +1,3 @@
1
- import { useState } from 'react';
2
1
  import { useTranslation } from 'react-i18next';
3
2
  import i18nInstance from '../../../localeImport.js';
4
3
  import { cn, getIcons } from '../../../utils.js';
@@ -112,17 +111,17 @@ function ConnectWalletList(props) {
112
111
  isDark,
113
112
  deviceDetails,
114
113
  walletConnectUri,
115
- buttonRadius
114
+ buttonRadius,
115
+ isShowAllWallets
116
116
  } = props;
117
- const [showMoreWallets, setShowMoreWallets] = useState(true);
118
117
  const onShowMoreWalletsClick = () => {
119
- setShowMoreWallets(false);
120
118
  handleMoreWallets();
121
119
  };
120
+ const showMoreWalletsButton = !isShowAllWallets;
122
121
  return /*#__PURE__*/jsxs(Fragment, {
123
122
  children: [/*#__PURE__*/jsx("ul", {
124
123
  className: cn("w3a--overflow-y-auto w3a--flex w3a--flex-col w3a--gap-y-2 w3a--h-[280px] w3a--social-container w3a--pr-2.5", {
125
- "w3a--h-[328px]": !showMoreWallets
124
+ "w3a--h-[328px]": !showMoreWalletsButton
126
125
  }),
127
126
  children: externalButtons.length === 0 ? /*#__PURE__*/jsx(NoWalletsFound, {}) : /*#__PURE__*/jsx(WalletsFound, {
128
127
  externalButtons: externalButtons,
@@ -132,7 +131,7 @@ function ConnectWalletList(props) {
132
131
  walletConnectUri: walletConnectUri,
133
132
  buttonRadius: buttonRadius
134
133
  })
135
- }), showMoreWallets && totalExternalWalletsCount > 15 && !isLoading && initialWalletCount < totalExternalWalletsCount && /*#__PURE__*/jsx(MoreWalletsButton, {
134
+ }), showMoreWalletsButton && !isLoading && initialWalletCount < totalExternalWalletsCount && /*#__PURE__*/jsx(MoreWalletsButton, {
136
135
  totalExternalWalletsCount: totalExternalWalletsCount,
137
136
  initialWalletCount: initialWalletCount,
138
137
  handleMoreWallets: onShowMoreWalletsClick,