@web3auth/modal 10.11.0 → 10.13.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.11.0";
5
+ const version = "10.13.0";
6
6
  const defaultConnectorsModalConfig = {
7
7
  hideWalletDiscovery: false,
8
8
  connectors: {
@@ -43,10 +43,10 @@ function SocialLoginButton(props) {
43
43
  "w3a--rounded-lg": buttonRadius === "rounded",
44
44
  "w3a--rounded-none": buttonRadius === "square"
45
45
  }),
46
- children: [showIcon && getProviderIcon(method, isDark, isPrimaryBtn), showText && jsxRuntime.jsx("p", {
46
+ children: [showIcon && getProviderIcon(method, isDark, isPrimaryBtn), children, showText && jsxRuntime.jsx("p", {
47
47
  className: "w3a--text-sm w3a--font-normal w3a--text-app-gray-900 dark:w3a--text-app-white",
48
48
  children: text
49
- }), children]
49
+ })]
50
50
  });
51
51
  }
52
52
 
@@ -67,6 +67,7 @@ function Login(props) {
67
67
  const [canShowMore, setCanShowMore] = react.useState(false);
68
68
  const [visibleRow, setVisibleRow] = react.useState([]);
69
69
  const [otherRow, setOtherRow] = react.useState([]);
70
+ const [mainOptionsRow, setMainOptionsRow] = react.useState([]);
70
71
  const [isPasswordLessCtaClicked, setIsPasswordLessCtaClicked] = react.useState(false);
71
72
  const [showOtpFlow, setShowOtpFlow] = react.useState(false);
72
73
  const [authConnection, setAuthConnection] = react.useState(undefined);
@@ -87,6 +88,7 @@ function Login(props) {
87
88
  });
88
89
  const visibleRows = [];
89
90
  const otherRows = [];
91
+ const mainOptionsRows = [];
90
92
  const loginMethodsOrder = (socialLoginsConfig.loginMethodsOrder || []).reduce((acc, method, index) => {
91
93
  acc[method] = index;
92
94
  return acc;
@@ -120,35 +122,19 @@ function Login(props) {
120
122
  const name = config.capitalizeFirstLetter(connectorConfig.name || method);
121
123
  const order = index + 1;
122
124
  const isPrimaryBtn = (socialLoginsConfig === null || socialLoginsConfig === void 0 || (_socialLoginsConfig$u = socialLoginsConfig.uiConfig) === null || _socialLoginsConfig$u === void 0 ? void 0 : _socialLoginsConfig$u.primaryButton) === "socialLogin" && order === 1;
125
+ const isMainOption = connectorConfig.mainOption;
123
126
  const loginOptionLength = loginOptions.length;
124
127
  const moreThanFour = loginOptionLength >= 4;
125
128
  const lengthCheck = moreThanFour ? order > 0 && order <= loginOptionLength : order > 0 && order < 4;
126
- if (lengthCheck) {
127
- visibleRows.push({
128
- method,
129
- isDark,
130
- isPrimaryBtn,
131
- name,
132
- connector: socialLoginsConfig.connector,
133
- loginParams: {
134
- authConnection: connectorConfig.authConnection || method,
135
- authConnectionId: connectorConfig.authConnectionId,
136
- groupedAuthConnectionId: connectorConfig.groupedAuthConnectionId,
137
- extraLoginOptions: connectorConfig.extraLoginOptions,
138
- name,
139
- login_hint: ""
140
- },
141
- order
142
- });
143
- }
144
- otherRows.push({
129
+ const rows = {
130
+ description: connectorConfig.description || "",
145
131
  method,
146
132
  isDark,
147
133
  isPrimaryBtn,
148
134
  name: name === "Twitter" ? "X" : name,
149
135
  connector: socialLoginsConfig.connector,
150
136
  loginParams: {
151
- authConnection: method,
137
+ authConnection: connectorConfig.authConnection || method,
152
138
  authConnectionId: connectorConfig.authConnectionId,
153
139
  groupedAuthConnectionId: connectorConfig.groupedAuthConnectionId,
154
140
  extraLoginOptions: connectorConfig.extraLoginOptions,
@@ -156,10 +142,17 @@ function Login(props) {
156
142
  login_hint: ""
157
143
  },
158
144
  order
159
- });
145
+ };
146
+ if (isMainOption) {
147
+ mainOptionsRows.push(rows);
148
+ } else if (lengthCheck) {
149
+ visibleRows.push(rows);
150
+ }
151
+ otherRows.push(rows);
160
152
  });
161
153
  setVisibleRow(visibleRows);
162
154
  setOtherRow(otherRows);
155
+ setMainOptionsRow(mainOptionsRows);
163
156
  setCanShowMore(maxOptions.length > 4); // Update the state based on the condition
164
157
  }, [socialLoginsConfig, isDark, buttonRadius]);
165
158
  const handleCustomLogin = async (authConnection, loginHint) => {
@@ -391,6 +384,7 @@ function Login(props) {
391
384
  isDark: isDark,
392
385
  visibleRow: visibleRow,
393
386
  canShowMore: canShowMore,
387
+ mainOptionsRow: mainOptionsRow,
394
388
  handleSocialLoginClick: handleSocialLoginClick,
395
389
  socialLoginsConfig: socialLoginsConfig,
396
390
  handleExpandSocialLogins: handleSocialLoginExpand,
@@ -28,6 +28,7 @@ function SocialLoginList(props) {
28
28
  const {
29
29
  visibleRow,
30
30
  otherRow,
31
+ mainOptionsRow,
31
32
  isDark,
32
33
  canShowMore,
33
34
  handleSocialLoginClick,
@@ -46,9 +47,30 @@ function SocialLoginList(props) {
46
47
  }
47
48
  };
48
49
  if (visibleRow.length !== 0 && (otherRow === null || otherRow === void 0 ? void 0 : otherRow.length) === 0) {
49
- return jsxRuntime.jsx("div", {
50
+ return jsxRuntime.jsxs("div", {
50
51
  className: "w3a--flex w3a--w-full w3a--flex-col w3a--items-center w3a--justify-center w3a--gap-y-2",
51
- children: jsxRuntime.jsxs("div", {
52
+ children: [jsxRuntime.jsx("div", {
53
+ className: "w3a--grid w3a--w-full w3a--gap-y-2",
54
+ children: mainOptionsRow.map(row => jsxRuntime.jsx(Button, {
55
+ type: Button_type.BUTTON_TYPE.SOCIAL,
56
+ props: {
57
+ showText: true,
58
+ text: row.description,
59
+ method: row.method,
60
+ isDark,
61
+ isPrimaryBtn: false,
62
+ btnStyle: "w3a--flex w3a--items-center !w3a--justify-center w3a--w-full w3a--h-11 w3a--group",
63
+ children: jsxRuntime.jsx(jsxRuntime.Fragment, {
64
+ children: getProviderIcon(row.method, isDark, ".svg")
65
+ }),
66
+ onClick: () => handleSocialLoginClick({
67
+ connector: row.connector,
68
+ loginParams: row.loginParams
69
+ }),
70
+ buttonRadius
71
+ }
72
+ }, row.method))
73
+ }), jsxRuntime.jsxs("div", {
52
74
  className: utils.cn("w3a--grid w3a--w-full w3a--gap-x-2", getGridRowFromVisibleLogin()),
53
75
  children: [visibleRow.filter((_, index) => visibleRow.length === 4 ? index <= 3 : index < 3).map(row => jsxRuntime.jsx(LoginHint, {
54
76
  content: "Last Login",
@@ -86,7 +108,7 @@ function SocialLoginList(props) {
86
108
  buttonRadius
87
109
  }
88
110
  })]
89
- })
111
+ })]
90
112
  });
91
113
  }
92
114
  return jsxRuntime.jsxs("div", {
@@ -81,7 +81,7 @@ function Widget(props) {
81
81
  } = params;
82
82
  setModalState(prevState => _objectSpread(_objectSpread({}, prevState), {}, {
83
83
  detailedLoaderConnector: connector,
84
- detailedLoaderAdapterName: noModal.CONNECTOR_NAMES[connector]
84
+ detailedLoaderConnectorName: noModal.CONNECTOR_NAMES[connector]
85
85
  }));
86
86
  // Call the passed-in handler with the params
87
87
  if (handleExternalWalletClick) handleExternalWalletClick(params);
@@ -34,9 +34,18 @@ export declare const defaultWagmiConfig: import("wagmi").Config<readonly [{
34
34
  sourceId?: number | undefined | undefined;
35
35
  testnet?: boolean | undefined | undefined;
36
36
  custom?: Record<string, unknown> | undefined;
37
+ extendSchema?: Record<string, unknown> | undefined;
37
38
  fees?: import("viem").ChainFees<undefined> | undefined;
38
39
  formatters?: undefined;
40
+ prepareTransactionRequest?: ((args: import("viem").PrepareTransactionRequestParameters, options: {
41
+ phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
42
+ }) => Promise<import("viem").PrepareTransactionRequestParameters>) | [fn: ((args: import("viem").PrepareTransactionRequestParameters, options: {
43
+ phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
44
+ }) => Promise<import("viem").PrepareTransactionRequestParameters>) | undefined, options: {
45
+ runAt: readonly ("beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters")[];
46
+ }] | undefined;
39
47
  serializers?: import("viem").ChainSerializers<undefined, import("viem").TransactionSerializable> | undefined;
48
+ verifyHash?: ((client: import("viem").Client, parameters: import("viem").VerifyHashActionParameters) => Promise<import("viem").VerifyHashActionReturnType>) | undefined;
40
49
  }], {
41
50
  1: import("viem").HttpTransport<undefined, false>;
42
51
  }, readonly []>;
@@ -3,6 +3,7 @@ export interface SocialLoginListProps {
3
3
  isDark: boolean;
4
4
  visibleRow: rowType[];
5
5
  canShowMore: boolean;
6
+ mainOptionsRow: rowType[];
6
7
  socialLoginsConfig: SocialLoginsConfig;
7
8
  otherRow?: rowType[];
8
9
  handleSocialLoginClick: (params: SocialLoginEventType) => void;
@@ -137,6 +137,7 @@ export type platform = "mobile" | "desktop" | "tablet";
137
137
  export type browser = "chrome" | "firefox" | "edge" | "safari" | "brave";
138
138
  export type mobileOs = "ios" | "android";
139
139
  export type rowType = {
140
+ description: string;
140
141
  method: string;
141
142
  isDark: boolean;
142
143
  isPrimaryBtn: boolean;
@@ -151,6 +152,7 @@ export type rowType = {
151
152
  extraLoginOptions?: ExtraLoginOptions;
152
153
  };
153
154
  order: number;
155
+ mainOption?: boolean;
154
156
  };
155
157
  export type PasswordlessHandlerParams = {
156
158
  authConnection: AUTH_CONNECTION_TYPE;
@@ -34,9 +34,18 @@ export declare const defaultWagmiConfig: import("wagmi").Config<readonly [{
34
34
  sourceId?: number | undefined | undefined;
35
35
  testnet?: boolean | undefined | undefined;
36
36
  custom?: Record<string, unknown> | undefined;
37
+ extendSchema?: Record<string, unknown> | undefined;
37
38
  fees?: import("viem").ChainFees<undefined> | undefined;
38
39
  formatters?: undefined;
40
+ prepareTransactionRequest?: ((args: import("viem").PrepareTransactionRequestParameters, options: {
41
+ phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
42
+ }) => Promise<import("viem").PrepareTransactionRequestParameters>) | [fn: ((args: import("viem").PrepareTransactionRequestParameters, options: {
43
+ phase: "beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters";
44
+ }) => Promise<import("viem").PrepareTransactionRequestParameters>) | undefined, options: {
45
+ runAt: readonly ("beforeFillTransaction" | "beforeFillParameters" | "afterFillParameters")[];
46
+ }] | undefined;
39
47
  serializers?: import("viem").ChainSerializers<undefined, import("viem").TransactionSerializable> | undefined;
48
+ verifyHash?: ((client: import("viem").Client, parameters: import("viem").VerifyHashActionParameters) => Promise<import("viem").VerifyHashActionReturnType>) | undefined;
40
49
  }], {
41
50
  1: import("viem").HttpTransport<undefined, false>;
42
51
  }, readonly []>;
@@ -1,6 +1,6 @@
1
1
  import { EVM_CONNECTORS } from '@web3auth/no-modal';
2
2
 
3
- const version = "10.11.0";
3
+ const version = "10.13.0";
4
4
  const defaultConnectorsModalConfig = {
5
5
  hideWalletDiscovery: false,
6
6
  connectors: {
@@ -41,10 +41,10 @@ function SocialLoginButton(props) {
41
41
  "w3a--rounded-lg": buttonRadius === "rounded",
42
42
  "w3a--rounded-none": buttonRadius === "square"
43
43
  }),
44
- children: [showIcon && getProviderIcon(method, isDark, isPrimaryBtn), showText && /*#__PURE__*/jsx("p", {
44
+ children: [showIcon && getProviderIcon(method, isDark, isPrimaryBtn), children, showText && /*#__PURE__*/jsx("p", {
45
45
  className: "w3a--text-sm w3a--font-normal w3a--text-app-gray-900 dark:w3a--text-app-white",
46
46
  children: text
47
- }), children]
47
+ })]
48
48
  });
49
49
  }
50
50
 
@@ -65,6 +65,7 @@ function Login(props) {
65
65
  const [canShowMore, setCanShowMore] = useState(false);
66
66
  const [visibleRow, setVisibleRow] = useState([]);
67
67
  const [otherRow, setOtherRow] = useState([]);
68
+ const [mainOptionsRow, setMainOptionsRow] = useState([]);
68
69
  const [isPasswordLessCtaClicked, setIsPasswordLessCtaClicked] = useState(false);
69
70
  const [showOtpFlow, setShowOtpFlow] = useState(false);
70
71
  const [authConnection, setAuthConnection] = useState(undefined);
@@ -85,6 +86,7 @@ function Login(props) {
85
86
  });
86
87
  const visibleRows = [];
87
88
  const otherRows = [];
89
+ const mainOptionsRows = [];
88
90
  const loginMethodsOrder = (socialLoginsConfig.loginMethodsOrder || []).reduce((acc, method, index) => {
89
91
  acc[method] = index;
90
92
  return acc;
@@ -121,35 +123,19 @@ function Login(props) {
121
123
  const name = capitalizeFirstLetter(connectorConfig.name || method);
122
124
  const order = index + 1;
123
125
  const isPrimaryBtn = (socialLoginsConfig === null || socialLoginsConfig === void 0 || (_socialLoginsConfig$u = socialLoginsConfig.uiConfig) === null || _socialLoginsConfig$u === void 0 ? void 0 : _socialLoginsConfig$u.primaryButton) === "socialLogin" && order === 1;
126
+ const isMainOption = connectorConfig.mainOption;
124
127
  const loginOptionLength = loginOptions.length;
125
128
  const moreThanFour = loginOptionLength >= 4;
126
129
  const lengthCheck = moreThanFour ? order > 0 && order <= loginOptionLength : order > 0 && order < 4;
127
- if (lengthCheck) {
128
- visibleRows.push({
129
- method,
130
- isDark,
131
- isPrimaryBtn,
132
- name,
133
- connector: socialLoginsConfig.connector,
134
- loginParams: {
135
- authConnection: connectorConfig.authConnection || method,
136
- authConnectionId: connectorConfig.authConnectionId,
137
- groupedAuthConnectionId: connectorConfig.groupedAuthConnectionId,
138
- extraLoginOptions: connectorConfig.extraLoginOptions,
139
- name,
140
- login_hint: ""
141
- },
142
- order
143
- });
144
- }
145
- otherRows.push({
130
+ const rows = {
131
+ description: connectorConfig.description || "",
146
132
  method,
147
133
  isDark,
148
134
  isPrimaryBtn,
149
135
  name: name === "Twitter" ? "X" : name,
150
136
  connector: socialLoginsConfig.connector,
151
137
  loginParams: {
152
- authConnection: method,
138
+ authConnection: connectorConfig.authConnection || method,
153
139
  authConnectionId: connectorConfig.authConnectionId,
154
140
  groupedAuthConnectionId: connectorConfig.groupedAuthConnectionId,
155
141
  extraLoginOptions: connectorConfig.extraLoginOptions,
@@ -157,10 +143,17 @@ function Login(props) {
157
143
  login_hint: ""
158
144
  },
159
145
  order
160
- });
146
+ };
147
+ if (isMainOption) {
148
+ mainOptionsRows.push(rows);
149
+ } else if (lengthCheck) {
150
+ visibleRows.push(rows);
151
+ }
152
+ otherRows.push(rows);
161
153
  });
162
154
  setVisibleRow(visibleRows);
163
155
  setOtherRow(otherRows);
156
+ setMainOptionsRow(mainOptionsRows);
164
157
  setCanShowMore(maxOptions.length > 4); // Update the state based on the condition
165
158
  }, [socialLoginsConfig, isDark, buttonRadius]);
166
159
  const handleCustomLogin = async (authConnection, loginHint) => {
@@ -394,6 +387,7 @@ function Login(props) {
394
387
  isDark: isDark,
395
388
  visibleRow: visibleRow,
396
389
  canShowMore: canShowMore,
390
+ mainOptionsRow: mainOptionsRow,
397
391
  handleSocialLoginClick: handleSocialLoginClick,
398
392
  socialLoginsConfig: socialLoginsConfig,
399
393
  handleExpandSocialLogins: handleSocialLoginExpand,
@@ -3,7 +3,7 @@ import { cn, getIcons } from '../../utils.js';
3
3
  import Button from '../Button/Button.js';
4
4
  import { BUTTON_TYPE } from '../Button/Button.type.js';
5
5
  import LoginHint from '../LoginHint/LoginHint.js';
6
- import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
6
+ import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
7
7
 
8
8
  function getProviderIcon(method, isDark, extension) {
9
9
  const imageId = method === AUTH_CONNECTION.TWITTER ? `login-X${isDark ? "-light" : "-dark"}` : `login-${method}${isDark ? "-light" : "-dark"}`;
@@ -26,6 +26,7 @@ function SocialLoginList(props) {
26
26
  const {
27
27
  visibleRow,
28
28
  otherRow,
29
+ mainOptionsRow,
29
30
  isDark,
30
31
  canShowMore,
31
32
  handleSocialLoginClick,
@@ -44,9 +45,30 @@ function SocialLoginList(props) {
44
45
  }
45
46
  };
46
47
  if (visibleRow.length !== 0 && (otherRow === null || otherRow === void 0 ? void 0 : otherRow.length) === 0) {
47
- return /*#__PURE__*/jsx("div", {
48
+ return /*#__PURE__*/jsxs("div", {
48
49
  className: "w3a--flex w3a--w-full w3a--flex-col w3a--items-center w3a--justify-center w3a--gap-y-2",
49
- children: /*#__PURE__*/jsxs("div", {
50
+ children: [/*#__PURE__*/jsx("div", {
51
+ className: "w3a--grid w3a--w-full w3a--gap-y-2",
52
+ children: mainOptionsRow.map(row => /*#__PURE__*/jsx(Button, {
53
+ type: BUTTON_TYPE.SOCIAL,
54
+ props: {
55
+ showText: true,
56
+ text: row.description,
57
+ method: row.method,
58
+ isDark,
59
+ isPrimaryBtn: false,
60
+ btnStyle: "w3a--flex w3a--items-center !w3a--justify-center w3a--w-full w3a--h-11 w3a--group",
61
+ children: /*#__PURE__*/jsx(Fragment, {
62
+ children: getProviderIcon(row.method, isDark, ".svg")
63
+ }),
64
+ onClick: () => handleSocialLoginClick({
65
+ connector: row.connector,
66
+ loginParams: row.loginParams
67
+ }),
68
+ buttonRadius
69
+ }
70
+ }, row.method))
71
+ }), /*#__PURE__*/jsxs("div", {
50
72
  className: cn("w3a--grid w3a--w-full w3a--gap-x-2", getGridRowFromVisibleLogin()),
51
73
  children: [visibleRow.filter((_, index) => visibleRow.length === 4 ? index <= 3 : index < 3).map(row => /*#__PURE__*/jsx(LoginHint, {
52
74
  content: "Last Login",
@@ -84,7 +106,7 @@ function SocialLoginList(props) {
84
106
  buttonRadius
85
107
  }
86
108
  })]
87
- })
109
+ })]
88
110
  });
89
111
  }
90
112
  return /*#__PURE__*/jsxs("div", {
@@ -79,7 +79,7 @@ function Widget(props) {
79
79
  } = params;
80
80
  setModalState(prevState => _objectSpread(_objectSpread({}, prevState), {}, {
81
81
  detailedLoaderConnector: connector,
82
- detailedLoaderAdapterName: CONNECTOR_NAMES[connector]
82
+ detailedLoaderConnectorName: CONNECTOR_NAMES[connector]
83
83
  }));
84
84
 
85
85
  // Call the passed-in handler with the params