@aptos-labs/wallet-adapter-mui-design 5.1.3 → 5.2.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.
- package/CHANGELOG.md +6 -0
- package/dist/index.d.mts +7 -2
- package/dist/index.d.ts +7 -2
- package/dist/index.js +124 -34
- package/dist/index.mjs +126 -34
- package/package.json +1 -1
- package/src/WalletConnector.tsx +3 -9
- package/src/WalletModel.tsx +191 -37
- package/src/types.ts +13 -0
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -7,7 +7,12 @@ interface WalletConnectorProps extends WalletSortingOptions {
|
|
|
7
7
|
handleNavigate?: () => void;
|
|
8
8
|
/** The max width of the wallet selector modal. Defaults to `xs`. */
|
|
9
9
|
modalMaxWidth?: Breakpoint;
|
|
10
|
+
crossChainWallets?: {
|
|
11
|
+
evm: boolean;
|
|
12
|
+
solana: boolean;
|
|
13
|
+
};
|
|
10
14
|
}
|
|
11
|
-
declare function WalletConnector({ networkSupport, handleNavigate, modalMaxWidth, ...walletSortingOptions }: WalletConnectorProps): react_jsx_runtime.JSX.Element;
|
|
12
15
|
|
|
13
|
-
|
|
16
|
+
declare function WalletConnector({ networkSupport, handleNavigate, modalMaxWidth, crossChainWallets, ...walletSortingOptions }: WalletConnectorProps): react_jsx_runtime.JSX.Element;
|
|
17
|
+
|
|
18
|
+
export { WalletConnector };
|
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,12 @@ interface WalletConnectorProps extends WalletSortingOptions {
|
|
|
7
7
|
handleNavigate?: () => void;
|
|
8
8
|
/** The max width of the wallet selector modal. Defaults to `xs`. */
|
|
9
9
|
modalMaxWidth?: Breakpoint;
|
|
10
|
+
crossChainWallets?: {
|
|
11
|
+
evm: boolean;
|
|
12
|
+
solana: boolean;
|
|
13
|
+
};
|
|
10
14
|
}
|
|
11
|
-
declare function WalletConnector({ networkSupport, handleNavigate, modalMaxWidth, ...walletSortingOptions }: WalletConnectorProps): react_jsx_runtime.JSX.Element;
|
|
12
15
|
|
|
13
|
-
|
|
16
|
+
declare function WalletConnector({ networkSupport, handleNavigate, modalMaxWidth, crossChainWallets, ...walletSortingOptions }: WalletConnectorProps): react_jsx_runtime.JSX.Element;
|
|
17
|
+
|
|
18
|
+
export { WalletConnector };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
|
+
var __defProps = Object.defineProperties;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
6
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
7
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
6
8
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
@@ -17,6 +19,7 @@ var __spreadValues = (a, b) => {
|
|
|
17
19
|
}
|
|
18
20
|
return a;
|
|
19
21
|
};
|
|
22
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
23
|
var __objRest = (source, exclude) => {
|
|
21
24
|
var target = {};
|
|
22
25
|
for (var prop in source)
|
|
@@ -225,21 +228,95 @@ function WalletsModal(_a) {
|
|
|
225
228
|
handleClose,
|
|
226
229
|
modalOpen,
|
|
227
230
|
networkSupport,
|
|
228
|
-
modalMaxWidth
|
|
231
|
+
modalMaxWidth,
|
|
232
|
+
crossChainWallets
|
|
229
233
|
} = _b, walletSortingOptions = __objRest(_b, [
|
|
230
234
|
"handleClose",
|
|
231
235
|
"modalOpen",
|
|
232
236
|
"networkSupport",
|
|
233
|
-
"modalMaxWidth"
|
|
237
|
+
"modalMaxWidth",
|
|
238
|
+
"crossChainWallets"
|
|
234
239
|
]);
|
|
235
240
|
const theme = (0, import_material3.useTheme)();
|
|
236
241
|
const [expanded, setExpanded] = (0, import_react3.useState)(false);
|
|
242
|
+
const [tabValue, setTabValue] = (0, import_react3.useState)(0);
|
|
243
|
+
const handleTabChange = (event, newValue) => {
|
|
244
|
+
setTabValue(newValue);
|
|
245
|
+
};
|
|
237
246
|
const { wallets = [], notDetectedWallets = [] } = (0, import_wallet_adapter_react3.useWallet)();
|
|
238
247
|
const { aptosConnectWallets, availableWallets, installableWallets } = (0, import_wallet_adapter_react3.groupAndSortWallets)(
|
|
239
248
|
[...wallets, ...notDetectedWallets],
|
|
240
249
|
walletSortingOptions
|
|
241
250
|
);
|
|
242
251
|
const hasAptosConnectWallets = !!aptosConnectWallets.length;
|
|
252
|
+
const crossChainMode = crossChainWallets && (crossChainWallets.evm || crossChainWallets.solana);
|
|
253
|
+
const { evmWallets, solanaWallets, aptosWallets } = crossChainMode ? availableWallets.reduce(
|
|
254
|
+
(acc, wallet) => {
|
|
255
|
+
if (wallet.name.includes("Ethereum")) {
|
|
256
|
+
acc.evmWallets.push(wallet);
|
|
257
|
+
} else if (wallet.name.includes("Solana")) {
|
|
258
|
+
acc.solanaWallets.push(wallet);
|
|
259
|
+
} else {
|
|
260
|
+
acc.aptosWallets.push(wallet);
|
|
261
|
+
}
|
|
262
|
+
return acc;
|
|
263
|
+
},
|
|
264
|
+
{ evmWallets: [], solanaWallets: [], aptosWallets: [] }
|
|
265
|
+
) : { evmWallets: [], solanaWallets: [], aptosWallets: availableWallets };
|
|
266
|
+
const {
|
|
267
|
+
evmInstallableWallets,
|
|
268
|
+
solanaInstallableWallets,
|
|
269
|
+
aptosInstallableWallets
|
|
270
|
+
} = crossChainMode ? installableWallets.reduce(
|
|
271
|
+
(acc, wallet) => {
|
|
272
|
+
if (wallet.name.includes("Ethereum")) {
|
|
273
|
+
acc.evmInstallableWallets.push(wallet);
|
|
274
|
+
} else if (wallet.name.includes("Solana")) {
|
|
275
|
+
acc.solanaInstallableWallets.push(wallet);
|
|
276
|
+
} else {
|
|
277
|
+
acc.aptosInstallableWallets.push(wallet);
|
|
278
|
+
}
|
|
279
|
+
return acc;
|
|
280
|
+
},
|
|
281
|
+
{
|
|
282
|
+
evmInstallableWallets: [],
|
|
283
|
+
solanaInstallableWallets: [],
|
|
284
|
+
aptosInstallableWallets: []
|
|
285
|
+
}
|
|
286
|
+
) : {
|
|
287
|
+
evmInstallableWallets: [],
|
|
288
|
+
solanaInstallableWallets: [],
|
|
289
|
+
aptosInstallableWallets: installableWallets
|
|
290
|
+
};
|
|
291
|
+
const tabsConfig = crossChainMode ? [
|
|
292
|
+
{ key: "aptos", label: "Aptos", enabled: true },
|
|
293
|
+
{ key: "solana", label: "Solana", enabled: crossChainWallets.solana },
|
|
294
|
+
{ key: "evm", label: "Ethereum", enabled: crossChainWallets.evm }
|
|
295
|
+
].filter((tab) => tab.enabled) : [];
|
|
296
|
+
const getTabIndex = (key) => tabsConfig.findIndex((tab) => tab.key === key);
|
|
297
|
+
const renderWalletList = (wallets2, installableWallets2) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
298
|
+
wallets2.map((wallet) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(WalletRow, { wallet, onConnect: handleClose }, wallet.name)),
|
|
299
|
+
!!installableWallets2.length && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
300
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
301
|
+
import_material3.Button,
|
|
302
|
+
{
|
|
303
|
+
variant: "text",
|
|
304
|
+
size: "small",
|
|
305
|
+
onClick: () => setExpanded((prev) => !prev),
|
|
306
|
+
endIcon: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.ExpandMore, { sx: { height: "20px", width: "20px" } }),
|
|
307
|
+
children: "More Wallets"
|
|
308
|
+
}
|
|
309
|
+
),
|
|
310
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material3.Collapse, { in: expanded, timeout: "auto", unmountOnExit: true, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material3.Stack, { sx: { gap: 1 }, children: installableWallets2.map((wallet) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
311
|
+
WalletRow,
|
|
312
|
+
{
|
|
313
|
+
wallet,
|
|
314
|
+
onConnect: handleClose
|
|
315
|
+
},
|
|
316
|
+
wallet.name
|
|
317
|
+
)) }) })
|
|
318
|
+
] })
|
|
319
|
+
] });
|
|
243
320
|
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
244
321
|
import_material3.Dialog,
|
|
245
322
|
{
|
|
@@ -422,36 +499,26 @@ function WalletsModal(_a) {
|
|
|
422
499
|
),
|
|
423
500
|
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material3.Divider, { sx: { color: grey[400], pt: 2 }, children: "Or" })
|
|
424
501
|
] }),
|
|
425
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
|
|
426
|
-
|
|
427
|
-
|
|
502
|
+
crossChainMode ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
|
|
503
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
504
|
+
import_material3.Tabs,
|
|
428
505
|
{
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material3.Collapse, { in: expanded, timeout: "auto", unmountOnExit: true, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material3.Stack, { sx: { gap: 1 }, children: installableWallets.map((wallet) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
446
|
-
WalletRow,
|
|
447
|
-
{
|
|
448
|
-
wallet,
|
|
449
|
-
onConnect: handleClose
|
|
450
|
-
},
|
|
451
|
-
wallet.name
|
|
452
|
-
)) }) })
|
|
453
|
-
] })
|
|
454
|
-
] })
|
|
506
|
+
value: tabValue,
|
|
507
|
+
onChange: handleTabChange,
|
|
508
|
+
textColor: "secondary",
|
|
509
|
+
indicatorColor: "secondary",
|
|
510
|
+
variant: "fullWidth",
|
|
511
|
+
"aria-label": "cross chain wallets tabs",
|
|
512
|
+
children: tabsConfig.map((tab, index) => /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material3.Tab, __spreadValues({ label: tab.label }, a11yProps(index)), tab.key))
|
|
513
|
+
}
|
|
514
|
+
),
|
|
515
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(TabPanel, { value: tabValue, index: getTabIndex("aptos"), children: renderWalletList(aptosWallets, aptosInstallableWallets) }),
|
|
516
|
+
crossChainWallets.solana && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(TabPanel, { value: tabValue, index: getTabIndex("solana"), children: renderWalletList(solanaWallets, solanaInstallableWallets) }),
|
|
517
|
+
crossChainWallets.evm && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(TabPanel, { value: tabValue, index: getTabIndex("evm"), children: renderWalletList(evmWallets, evmInstallableWallets) })
|
|
518
|
+
] }) : (
|
|
519
|
+
// Simple list mode (original WalletModel behavior)
|
|
520
|
+
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material3.Stack, { sx: { gap: 1 }, children: renderWalletList(availableWallets, installableWallets) })
|
|
521
|
+
)
|
|
455
522
|
] })
|
|
456
523
|
]
|
|
457
524
|
}
|
|
@@ -640,6 +707,26 @@ function renderEducationScreen(screen) {
|
|
|
640
707
|
)
|
|
641
708
|
] });
|
|
642
709
|
}
|
|
710
|
+
function TabPanel(props) {
|
|
711
|
+
const _a = props, { children, value, index } = _a, other = __objRest(_a, ["children", "value", "index"]);
|
|
712
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
|
|
713
|
+
"div",
|
|
714
|
+
__spreadProps(__spreadValues({
|
|
715
|
+
role: "tabpanel",
|
|
716
|
+
hidden: value !== index,
|
|
717
|
+
id: `simple-tabpanel-${index}`,
|
|
718
|
+
"aria-labelledby": `simple-tab-${index}`
|
|
719
|
+
}, other), {
|
|
720
|
+
children: value === index && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material3.Stack, { sx: { gap: 1 }, children })
|
|
721
|
+
})
|
|
722
|
+
);
|
|
723
|
+
}
|
|
724
|
+
function a11yProps(index) {
|
|
725
|
+
return {
|
|
726
|
+
id: `simple-tab-${index}`,
|
|
727
|
+
"aria-controls": `simple-tabpanel-${index}`
|
|
728
|
+
};
|
|
729
|
+
}
|
|
643
730
|
|
|
644
731
|
// src/WalletConnector.tsx
|
|
645
732
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
@@ -647,11 +734,13 @@ function WalletConnector(_a) {
|
|
|
647
734
|
var _b = _a, {
|
|
648
735
|
networkSupport,
|
|
649
736
|
handleNavigate,
|
|
650
|
-
modalMaxWidth
|
|
737
|
+
modalMaxWidth,
|
|
738
|
+
crossChainWallets
|
|
651
739
|
} = _b, walletSortingOptions = __objRest(_b, [
|
|
652
740
|
"networkSupport",
|
|
653
741
|
"handleNavigate",
|
|
654
|
-
"modalMaxWidth"
|
|
742
|
+
"modalMaxWidth",
|
|
743
|
+
"crossChainWallets"
|
|
655
744
|
]);
|
|
656
745
|
const [modalOpen, setModalOpen] = (0, import_react4.useState)(false);
|
|
657
746
|
const handleModalOpen = () => setModalOpen(true);
|
|
@@ -670,7 +759,8 @@ function WalletConnector(_a) {
|
|
|
670
759
|
handleClose,
|
|
671
760
|
modalOpen,
|
|
672
761
|
networkSupport,
|
|
673
|
-
modalMaxWidth
|
|
762
|
+
modalMaxWidth,
|
|
763
|
+
crossChainWallets
|
|
674
764
|
}, walletSortingOptions)
|
|
675
765
|
)
|
|
676
766
|
] });
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
2
4
|
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
6
|
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
@@ -14,6 +16,7 @@ var __spreadValues = (a, b) => {
|
|
|
14
16
|
}
|
|
15
17
|
return a;
|
|
16
18
|
};
|
|
19
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
17
20
|
var __objRest = (source, exclude) => {
|
|
18
21
|
var target = {};
|
|
19
22
|
for (var prop in source)
|
|
@@ -200,6 +203,8 @@ import {
|
|
|
200
203
|
ListItem as ListItem2,
|
|
201
204
|
ListItemText as ListItemText2,
|
|
202
205
|
Stack,
|
|
206
|
+
Tab,
|
|
207
|
+
Tabs,
|
|
203
208
|
Typography as Typography2,
|
|
204
209
|
useTheme
|
|
205
210
|
} from "@mui/material";
|
|
@@ -234,21 +239,95 @@ function WalletsModal(_a) {
|
|
|
234
239
|
handleClose,
|
|
235
240
|
modalOpen,
|
|
236
241
|
networkSupport,
|
|
237
|
-
modalMaxWidth
|
|
242
|
+
modalMaxWidth,
|
|
243
|
+
crossChainWallets
|
|
238
244
|
} = _b, walletSortingOptions = __objRest(_b, [
|
|
239
245
|
"handleClose",
|
|
240
246
|
"modalOpen",
|
|
241
247
|
"networkSupport",
|
|
242
|
-
"modalMaxWidth"
|
|
248
|
+
"modalMaxWidth",
|
|
249
|
+
"crossChainWallets"
|
|
243
250
|
]);
|
|
244
251
|
const theme = useTheme();
|
|
245
252
|
const [expanded, setExpanded] = useState3(false);
|
|
253
|
+
const [tabValue, setTabValue] = useState3(0);
|
|
254
|
+
const handleTabChange = (event, newValue) => {
|
|
255
|
+
setTabValue(newValue);
|
|
256
|
+
};
|
|
246
257
|
const { wallets = [], notDetectedWallets = [] } = useWallet3();
|
|
247
258
|
const { aptosConnectWallets, availableWallets, installableWallets } = groupAndSortWallets(
|
|
248
259
|
[...wallets, ...notDetectedWallets],
|
|
249
260
|
walletSortingOptions
|
|
250
261
|
);
|
|
251
262
|
const hasAptosConnectWallets = !!aptosConnectWallets.length;
|
|
263
|
+
const crossChainMode = crossChainWallets && (crossChainWallets.evm || crossChainWallets.solana);
|
|
264
|
+
const { evmWallets, solanaWallets, aptosWallets } = crossChainMode ? availableWallets.reduce(
|
|
265
|
+
(acc, wallet) => {
|
|
266
|
+
if (wallet.name.includes("Ethereum")) {
|
|
267
|
+
acc.evmWallets.push(wallet);
|
|
268
|
+
} else if (wallet.name.includes("Solana")) {
|
|
269
|
+
acc.solanaWallets.push(wallet);
|
|
270
|
+
} else {
|
|
271
|
+
acc.aptosWallets.push(wallet);
|
|
272
|
+
}
|
|
273
|
+
return acc;
|
|
274
|
+
},
|
|
275
|
+
{ evmWallets: [], solanaWallets: [], aptosWallets: [] }
|
|
276
|
+
) : { evmWallets: [], solanaWallets: [], aptosWallets: availableWallets };
|
|
277
|
+
const {
|
|
278
|
+
evmInstallableWallets,
|
|
279
|
+
solanaInstallableWallets,
|
|
280
|
+
aptosInstallableWallets
|
|
281
|
+
} = crossChainMode ? installableWallets.reduce(
|
|
282
|
+
(acc, wallet) => {
|
|
283
|
+
if (wallet.name.includes("Ethereum")) {
|
|
284
|
+
acc.evmInstallableWallets.push(wallet);
|
|
285
|
+
} else if (wallet.name.includes("Solana")) {
|
|
286
|
+
acc.solanaInstallableWallets.push(wallet);
|
|
287
|
+
} else {
|
|
288
|
+
acc.aptosInstallableWallets.push(wallet);
|
|
289
|
+
}
|
|
290
|
+
return acc;
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
evmInstallableWallets: [],
|
|
294
|
+
solanaInstallableWallets: [],
|
|
295
|
+
aptosInstallableWallets: []
|
|
296
|
+
}
|
|
297
|
+
) : {
|
|
298
|
+
evmInstallableWallets: [],
|
|
299
|
+
solanaInstallableWallets: [],
|
|
300
|
+
aptosInstallableWallets: installableWallets
|
|
301
|
+
};
|
|
302
|
+
const tabsConfig = crossChainMode ? [
|
|
303
|
+
{ key: "aptos", label: "Aptos", enabled: true },
|
|
304
|
+
{ key: "solana", label: "Solana", enabled: crossChainWallets.solana },
|
|
305
|
+
{ key: "evm", label: "Ethereum", enabled: crossChainWallets.evm }
|
|
306
|
+
].filter((tab) => tab.enabled) : [];
|
|
307
|
+
const getTabIndex = (key) => tabsConfig.findIndex((tab) => tab.key === key);
|
|
308
|
+
const renderWalletList = (wallets2, installableWallets2) => /* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
309
|
+
wallets2.map((wallet) => /* @__PURE__ */ jsx3(WalletRow, { wallet, onConnect: handleClose }, wallet.name)),
|
|
310
|
+
!!installableWallets2.length && /* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
311
|
+
/* @__PURE__ */ jsx3(
|
|
312
|
+
Button2,
|
|
313
|
+
{
|
|
314
|
+
variant: "text",
|
|
315
|
+
size: "small",
|
|
316
|
+
onClick: () => setExpanded((prev) => !prev),
|
|
317
|
+
endIcon: /* @__PURE__ */ jsx3(ExpandMore, { sx: { height: "20px", width: "20px" } }),
|
|
318
|
+
children: "More Wallets"
|
|
319
|
+
}
|
|
320
|
+
),
|
|
321
|
+
/* @__PURE__ */ jsx3(Collapse, { in: expanded, timeout: "auto", unmountOnExit: true, children: /* @__PURE__ */ jsx3(Stack, { sx: { gap: 1 }, children: installableWallets2.map((wallet) => /* @__PURE__ */ jsx3(
|
|
322
|
+
WalletRow,
|
|
323
|
+
{
|
|
324
|
+
wallet,
|
|
325
|
+
onConnect: handleClose
|
|
326
|
+
},
|
|
327
|
+
wallet.name
|
|
328
|
+
)) }) })
|
|
329
|
+
] })
|
|
330
|
+
] });
|
|
252
331
|
return /* @__PURE__ */ jsx3(
|
|
253
332
|
Dialog,
|
|
254
333
|
{
|
|
@@ -431,36 +510,26 @@ function WalletsModal(_a) {
|
|
|
431
510
|
),
|
|
432
511
|
/* @__PURE__ */ jsx3(Divider, { sx: { color: grey[400], pt: 2 }, children: "Or" })
|
|
433
512
|
] }),
|
|
434
|
-
/* @__PURE__ */ jsxs3(
|
|
435
|
-
|
|
436
|
-
|
|
513
|
+
crossChainMode ? /* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
514
|
+
/* @__PURE__ */ jsx3(
|
|
515
|
+
Tabs,
|
|
437
516
|
{
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
/* @__PURE__ */ jsx3(Collapse, { in: expanded, timeout: "auto", unmountOnExit: true, children: /* @__PURE__ */ jsx3(Stack, { sx: { gap: 1 }, children: installableWallets.map((wallet) => /* @__PURE__ */ jsx3(
|
|
455
|
-
WalletRow,
|
|
456
|
-
{
|
|
457
|
-
wallet,
|
|
458
|
-
onConnect: handleClose
|
|
459
|
-
},
|
|
460
|
-
wallet.name
|
|
461
|
-
)) }) })
|
|
462
|
-
] })
|
|
463
|
-
] })
|
|
517
|
+
value: tabValue,
|
|
518
|
+
onChange: handleTabChange,
|
|
519
|
+
textColor: "secondary",
|
|
520
|
+
indicatorColor: "secondary",
|
|
521
|
+
variant: "fullWidth",
|
|
522
|
+
"aria-label": "cross chain wallets tabs",
|
|
523
|
+
children: tabsConfig.map((tab, index) => /* @__PURE__ */ jsx3(Tab, __spreadValues({ label: tab.label }, a11yProps(index)), tab.key))
|
|
524
|
+
}
|
|
525
|
+
),
|
|
526
|
+
/* @__PURE__ */ jsx3(TabPanel, { value: tabValue, index: getTabIndex("aptos"), children: renderWalletList(aptosWallets, aptosInstallableWallets) }),
|
|
527
|
+
crossChainWallets.solana && /* @__PURE__ */ jsx3(TabPanel, { value: tabValue, index: getTabIndex("solana"), children: renderWalletList(solanaWallets, solanaInstallableWallets) }),
|
|
528
|
+
crossChainWallets.evm && /* @__PURE__ */ jsx3(TabPanel, { value: tabValue, index: getTabIndex("evm"), children: renderWalletList(evmWallets, evmInstallableWallets) })
|
|
529
|
+
] }) : (
|
|
530
|
+
// Simple list mode (original WalletModel behavior)
|
|
531
|
+
/* @__PURE__ */ jsx3(Stack, { sx: { gap: 1 }, children: renderWalletList(availableWallets, installableWallets) })
|
|
532
|
+
)
|
|
464
533
|
] })
|
|
465
534
|
]
|
|
466
535
|
}
|
|
@@ -649,6 +718,26 @@ function renderEducationScreen(screen) {
|
|
|
649
718
|
)
|
|
650
719
|
] });
|
|
651
720
|
}
|
|
721
|
+
function TabPanel(props) {
|
|
722
|
+
const _a = props, { children, value, index } = _a, other = __objRest(_a, ["children", "value", "index"]);
|
|
723
|
+
return /* @__PURE__ */ jsx3(
|
|
724
|
+
"div",
|
|
725
|
+
__spreadProps(__spreadValues({
|
|
726
|
+
role: "tabpanel",
|
|
727
|
+
hidden: value !== index,
|
|
728
|
+
id: `simple-tabpanel-${index}`,
|
|
729
|
+
"aria-labelledby": `simple-tab-${index}`
|
|
730
|
+
}, other), {
|
|
731
|
+
children: value === index && /* @__PURE__ */ jsx3(Stack, { sx: { gap: 1 }, children })
|
|
732
|
+
})
|
|
733
|
+
);
|
|
734
|
+
}
|
|
735
|
+
function a11yProps(index) {
|
|
736
|
+
return {
|
|
737
|
+
id: `simple-tab-${index}`,
|
|
738
|
+
"aria-controls": `simple-tabpanel-${index}`
|
|
739
|
+
};
|
|
740
|
+
}
|
|
652
741
|
|
|
653
742
|
// src/WalletConnector.tsx
|
|
654
743
|
import { Fragment as Fragment3, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
@@ -656,11 +745,13 @@ function WalletConnector(_a) {
|
|
|
656
745
|
var _b = _a, {
|
|
657
746
|
networkSupport,
|
|
658
747
|
handleNavigate,
|
|
659
|
-
modalMaxWidth
|
|
748
|
+
modalMaxWidth,
|
|
749
|
+
crossChainWallets
|
|
660
750
|
} = _b, walletSortingOptions = __objRest(_b, [
|
|
661
751
|
"networkSupport",
|
|
662
752
|
"handleNavigate",
|
|
663
|
-
"modalMaxWidth"
|
|
753
|
+
"modalMaxWidth",
|
|
754
|
+
"crossChainWallets"
|
|
664
755
|
]);
|
|
665
756
|
const [modalOpen, setModalOpen] = useState4(false);
|
|
666
757
|
const handleModalOpen = () => setModalOpen(true);
|
|
@@ -679,7 +770,8 @@ function WalletConnector(_a) {
|
|
|
679
770
|
handleClose,
|
|
680
771
|
modalOpen,
|
|
681
772
|
networkSupport,
|
|
682
|
-
modalMaxWidth
|
|
773
|
+
modalMaxWidth,
|
|
774
|
+
crossChainWallets
|
|
683
775
|
}, walletSortingOptions)
|
|
684
776
|
)
|
|
685
777
|
] });
|
package/package.json
CHANGED
package/src/WalletConnector.tsx
CHANGED
|
@@ -1,20 +1,13 @@
|
|
|
1
|
-
import { WalletSortingOptions } from "@aptos-labs/wallet-adapter-react";
|
|
2
|
-
import { Breakpoint } from "@mui/material";
|
|
3
1
|
import { useState } from "react";
|
|
4
2
|
import WalletButton from "./WalletButton";
|
|
5
3
|
import WalletsModal from "./WalletModel";
|
|
6
|
-
|
|
7
|
-
export interface WalletConnectorProps extends WalletSortingOptions {
|
|
8
|
-
networkSupport?: string;
|
|
9
|
-
handleNavigate?: () => void;
|
|
10
|
-
/** The max width of the wallet selector modal. Defaults to `xs`. */
|
|
11
|
-
modalMaxWidth?: Breakpoint;
|
|
12
|
-
}
|
|
4
|
+
import { WalletConnectorProps } from "./types";
|
|
13
5
|
|
|
14
6
|
export function WalletConnector({
|
|
15
7
|
networkSupport,
|
|
16
8
|
handleNavigate,
|
|
17
9
|
modalMaxWidth,
|
|
10
|
+
crossChainWallets,
|
|
18
11
|
...walletSortingOptions
|
|
19
12
|
}: WalletConnectorProps) {
|
|
20
13
|
const [modalOpen, setModalOpen] = useState(false);
|
|
@@ -32,6 +25,7 @@ export function WalletConnector({
|
|
|
32
25
|
modalOpen={modalOpen}
|
|
33
26
|
networkSupport={networkSupport}
|
|
34
27
|
modalMaxWidth={modalMaxWidth}
|
|
28
|
+
crossChainWallets={crossChainWallets}
|
|
35
29
|
{...walletSortingOptions}
|
|
36
30
|
/>
|
|
37
31
|
</>
|
package/src/WalletModel.tsx
CHANGED
|
@@ -20,6 +20,8 @@ import {
|
|
|
20
20
|
ListItem,
|
|
21
21
|
ListItemText,
|
|
22
22
|
Stack,
|
|
23
|
+
Tab,
|
|
24
|
+
Tabs,
|
|
23
25
|
Typography,
|
|
24
26
|
useTheme,
|
|
25
27
|
} from "@mui/material";
|
|
@@ -32,14 +34,19 @@ import {
|
|
|
32
34
|
ExpandMore,
|
|
33
35
|
LanOutlined as LanOutlinedIcon,
|
|
34
36
|
} from "@mui/icons-material";
|
|
35
|
-
import { useState } from "react";
|
|
36
|
-
import { WalletConnectorProps } from "./
|
|
37
|
+
import { SyntheticEvent, useState } from "react";
|
|
38
|
+
import { WalletConnectorProps } from "./types";
|
|
37
39
|
|
|
38
40
|
interface WalletsModalProps
|
|
39
41
|
extends Pick<WalletConnectorProps, "networkSupport" | "modalMaxWidth">,
|
|
40
42
|
WalletSortingOptions {
|
|
41
43
|
handleClose: () => void;
|
|
42
44
|
modalOpen: boolean;
|
|
45
|
+
// Make crossChainWallets optional - if not provided, shows single list
|
|
46
|
+
crossChainWallets?: {
|
|
47
|
+
evm: boolean;
|
|
48
|
+
solana: boolean;
|
|
49
|
+
};
|
|
43
50
|
}
|
|
44
51
|
|
|
45
52
|
export default function WalletsModal({
|
|
@@ -47,21 +54,131 @@ export default function WalletsModal({
|
|
|
47
54
|
modalOpen,
|
|
48
55
|
networkSupport,
|
|
49
56
|
modalMaxWidth,
|
|
57
|
+
crossChainWallets,
|
|
50
58
|
...walletSortingOptions
|
|
51
59
|
}: WalletsModalProps): JSX.Element {
|
|
52
60
|
const theme = useTheme();
|
|
53
61
|
const [expanded, setExpanded] = useState(false);
|
|
62
|
+
const [tabValue, setTabValue] = useState<number>(0);
|
|
63
|
+
|
|
64
|
+
const handleTabChange = (event: SyntheticEvent, newValue: number) => {
|
|
65
|
+
setTabValue(newValue);
|
|
66
|
+
};
|
|
54
67
|
|
|
55
68
|
const { wallets = [], notDetectedWallets = [] } = useWallet();
|
|
56
69
|
|
|
57
70
|
const { aptosConnectWallets, availableWallets, installableWallets } =
|
|
58
71
|
groupAndSortWallets(
|
|
59
72
|
[...wallets, ...notDetectedWallets],
|
|
60
|
-
walletSortingOptions
|
|
73
|
+
walletSortingOptions
|
|
61
74
|
);
|
|
62
75
|
|
|
63
76
|
const hasAptosConnectWallets = !!aptosConnectWallets.length;
|
|
64
77
|
|
|
78
|
+
// Determine if we should show tabs (cross-chain mode)
|
|
79
|
+
const crossChainMode =
|
|
80
|
+
crossChainWallets && (crossChainWallets.evm || crossChainWallets.solana);
|
|
81
|
+
|
|
82
|
+
// Group wallets by chain if in cross-chain mode
|
|
83
|
+
const { evmWallets, solanaWallets, aptosWallets } = crossChainMode
|
|
84
|
+
? availableWallets.reduce<{
|
|
85
|
+
evmWallets: AdapterWallet[];
|
|
86
|
+
solanaWallets: AdapterWallet[];
|
|
87
|
+
aptosWallets: AdapterWallet[];
|
|
88
|
+
}>(
|
|
89
|
+
(acc, wallet) => {
|
|
90
|
+
if (wallet.name.includes("Ethereum")) {
|
|
91
|
+
acc.evmWallets.push(wallet);
|
|
92
|
+
} else if (wallet.name.includes("Solana")) {
|
|
93
|
+
acc.solanaWallets.push(wallet);
|
|
94
|
+
} else {
|
|
95
|
+
acc.aptosWallets.push(wallet);
|
|
96
|
+
}
|
|
97
|
+
return acc;
|
|
98
|
+
},
|
|
99
|
+
{ evmWallets: [], solanaWallets: [], aptosWallets: [] }
|
|
100
|
+
)
|
|
101
|
+
: { evmWallets: [], solanaWallets: [], aptosWallets: availableWallets };
|
|
102
|
+
|
|
103
|
+
const {
|
|
104
|
+
evmInstallableWallets,
|
|
105
|
+
solanaInstallableWallets,
|
|
106
|
+
aptosInstallableWallets,
|
|
107
|
+
} = crossChainMode
|
|
108
|
+
? installableWallets.reduce<{
|
|
109
|
+
evmInstallableWallets: AdapterNotDetectedWallet[];
|
|
110
|
+
solanaInstallableWallets: AdapterNotDetectedWallet[];
|
|
111
|
+
aptosInstallableWallets: AdapterNotDetectedWallet[];
|
|
112
|
+
}>(
|
|
113
|
+
(acc, wallet) => {
|
|
114
|
+
if (wallet.name.includes("Ethereum")) {
|
|
115
|
+
acc.evmInstallableWallets.push(wallet);
|
|
116
|
+
} else if (wallet.name.includes("Solana")) {
|
|
117
|
+
acc.solanaInstallableWallets.push(wallet);
|
|
118
|
+
} else {
|
|
119
|
+
acc.aptosInstallableWallets.push(wallet);
|
|
120
|
+
}
|
|
121
|
+
return acc;
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
evmInstallableWallets: [],
|
|
125
|
+
solanaInstallableWallets: [],
|
|
126
|
+
aptosInstallableWallets: [],
|
|
127
|
+
}
|
|
128
|
+
)
|
|
129
|
+
: {
|
|
130
|
+
evmInstallableWallets: [],
|
|
131
|
+
solanaInstallableWallets: [],
|
|
132
|
+
aptosInstallableWallets: installableWallets,
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
// Calculate dynamic indices for tabs
|
|
136
|
+
const tabsConfig = crossChainMode
|
|
137
|
+
? [
|
|
138
|
+
{ key: "aptos", label: "Aptos", enabled: true },
|
|
139
|
+
{ key: "solana", label: "Solana", enabled: crossChainWallets!.solana },
|
|
140
|
+
{ key: "evm", label: "Ethereum", enabled: crossChainWallets!.evm },
|
|
141
|
+
].filter((tab) => tab.enabled)
|
|
142
|
+
: [];
|
|
143
|
+
|
|
144
|
+
const getTabIndex = (key: string) =>
|
|
145
|
+
tabsConfig.findIndex((tab) => tab.key === key);
|
|
146
|
+
|
|
147
|
+
// Render wallet list for a specific chain
|
|
148
|
+
const renderWalletList = (
|
|
149
|
+
wallets: AdapterWallet[],
|
|
150
|
+
installableWallets: AdapterNotDetectedWallet[]
|
|
151
|
+
) => (
|
|
152
|
+
<>
|
|
153
|
+
{wallets.map((wallet) => (
|
|
154
|
+
<WalletRow key={wallet.name} wallet={wallet} onConnect={handleClose} />
|
|
155
|
+
))}
|
|
156
|
+
{!!installableWallets.length && (
|
|
157
|
+
<>
|
|
158
|
+
<Button
|
|
159
|
+
variant="text"
|
|
160
|
+
size="small"
|
|
161
|
+
onClick={() => setExpanded((prev) => !prev)}
|
|
162
|
+
endIcon={<ExpandMore sx={{ height: "20px", width: "20px" }} />}
|
|
163
|
+
>
|
|
164
|
+
More Wallets
|
|
165
|
+
</Button>
|
|
166
|
+
<Collapse in={expanded} timeout="auto" unmountOnExit>
|
|
167
|
+
<Stack sx={{ gap: 1 }}>
|
|
168
|
+
{installableWallets.map((wallet) => (
|
|
169
|
+
<WalletRow
|
|
170
|
+
key={wallet.name}
|
|
171
|
+
wallet={wallet}
|
|
172
|
+
onConnect={handleClose}
|
|
173
|
+
/>
|
|
174
|
+
))}
|
|
175
|
+
</Stack>
|
|
176
|
+
</Collapse>
|
|
177
|
+
</>
|
|
178
|
+
)}
|
|
179
|
+
</>
|
|
180
|
+
);
|
|
181
|
+
|
|
65
182
|
return (
|
|
66
183
|
<Dialog
|
|
67
184
|
open={modalOpen}
|
|
@@ -92,6 +209,7 @@ export default function WalletsModal({
|
|
|
92
209
|
>
|
|
93
210
|
<CloseIcon />
|
|
94
211
|
</IconButton>
|
|
212
|
+
|
|
95
213
|
<AboutAptosConnect renderEducationScreen={renderEducationScreen}>
|
|
96
214
|
<Typography
|
|
97
215
|
align="center"
|
|
@@ -112,6 +230,7 @@ export default function WalletsModal({
|
|
|
112
230
|
"Connect Wallet"
|
|
113
231
|
)}
|
|
114
232
|
</Typography>
|
|
233
|
+
|
|
115
234
|
{networkSupport && (
|
|
116
235
|
<Box
|
|
117
236
|
sx={{
|
|
@@ -139,6 +258,7 @@ export default function WalletsModal({
|
|
|
139
258
|
</Typography>
|
|
140
259
|
</Box>
|
|
141
260
|
)}
|
|
261
|
+
|
|
142
262
|
{hasAptosConnectWallets && (
|
|
143
263
|
<Stack gap={1}>
|
|
144
264
|
{aptosConnectWallets.map((wallet) => (
|
|
@@ -213,40 +333,45 @@ export default function WalletsModal({
|
|
|
213
333
|
<Divider sx={{ color: grey[400], pt: 2 }}>Or</Divider>
|
|
214
334
|
</Stack>
|
|
215
335
|
)}
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
</
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
336
|
+
|
|
337
|
+
{/* Conditional rendering: Tabs for cross-chain, simple list for single-chain */}
|
|
338
|
+
{crossChainMode ? (
|
|
339
|
+
<>
|
|
340
|
+
<Tabs
|
|
341
|
+
value={tabValue}
|
|
342
|
+
onChange={handleTabChange}
|
|
343
|
+
textColor="secondary"
|
|
344
|
+
indicatorColor="secondary"
|
|
345
|
+
variant="fullWidth"
|
|
346
|
+
aria-label="cross chain wallets tabs"
|
|
347
|
+
>
|
|
348
|
+
{tabsConfig.map((tab, index) => (
|
|
349
|
+
<Tab key={tab.key} label={tab.label} {...a11yProps(index)} />
|
|
350
|
+
))}
|
|
351
|
+
</Tabs>
|
|
352
|
+
|
|
353
|
+
<TabPanel value={tabValue} index={getTabIndex("aptos")}>
|
|
354
|
+
{renderWalletList(aptosWallets, aptosInstallableWallets)}
|
|
355
|
+
</TabPanel>
|
|
356
|
+
|
|
357
|
+
{crossChainWallets!.solana && (
|
|
358
|
+
<TabPanel value={tabValue} index={getTabIndex("solana")}>
|
|
359
|
+
{renderWalletList(solanaWallets, solanaInstallableWallets)}
|
|
360
|
+
</TabPanel>
|
|
361
|
+
)}
|
|
362
|
+
|
|
363
|
+
{crossChainWallets!.evm && (
|
|
364
|
+
<TabPanel value={tabValue} index={getTabIndex("evm")}>
|
|
365
|
+
{renderWalletList(evmWallets, evmInstallableWallets)}
|
|
366
|
+
</TabPanel>
|
|
367
|
+
)}
|
|
368
|
+
</>
|
|
369
|
+
) : (
|
|
370
|
+
// Simple list mode (original WalletModel behavior)
|
|
371
|
+
<Stack sx={{ gap: 1 }}>
|
|
372
|
+
{renderWalletList(availableWallets, installableWallets)}
|
|
373
|
+
</Stack>
|
|
374
|
+
)}
|
|
250
375
|
</AboutAptosConnect>
|
|
251
376
|
</Stack>
|
|
252
377
|
</Dialog>
|
|
@@ -432,3 +557,32 @@ function renderEducationScreen(screen: AboutAptosConnectEducationScreen) {
|
|
|
432
557
|
</>
|
|
433
558
|
);
|
|
434
559
|
}
|
|
560
|
+
|
|
561
|
+
interface TabPanelProps {
|
|
562
|
+
children?: React.ReactNode;
|
|
563
|
+
index: number;
|
|
564
|
+
value: number;
|
|
565
|
+
}
|
|
566
|
+
|
|
567
|
+
function TabPanel(props: TabPanelProps) {
|
|
568
|
+
const { children, value, index, ...other } = props;
|
|
569
|
+
|
|
570
|
+
return (
|
|
571
|
+
<div
|
|
572
|
+
role="tabpanel"
|
|
573
|
+
hidden={value !== index}
|
|
574
|
+
id={`simple-tabpanel-${index}`}
|
|
575
|
+
aria-labelledby={`simple-tab-${index}`}
|
|
576
|
+
{...other}
|
|
577
|
+
>
|
|
578
|
+
{value === index && <Stack sx={{ gap: 1 }}>{children}</Stack>}
|
|
579
|
+
</div>
|
|
580
|
+
);
|
|
581
|
+
}
|
|
582
|
+
|
|
583
|
+
function a11yProps(index: number) {
|
|
584
|
+
return {
|
|
585
|
+
id: `simple-tab-${index}`,
|
|
586
|
+
"aria-controls": `simple-tabpanel-${index}`,
|
|
587
|
+
};
|
|
588
|
+
}
|
package/src/types.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { WalletSortingOptions } from "@aptos-labs/wallet-adapter-react";
|
|
2
|
+
import { Breakpoint } from "@mui/material";
|
|
3
|
+
|
|
4
|
+
export interface WalletConnectorProps extends WalletSortingOptions {
|
|
5
|
+
networkSupport?: string;
|
|
6
|
+
handleNavigate?: () => void;
|
|
7
|
+
/** The max width of the wallet selector modal. Defaults to `xs`. */
|
|
8
|
+
modalMaxWidth?: Breakpoint;
|
|
9
|
+
crossChainWallets?: {
|
|
10
|
+
evm: boolean;
|
|
11
|
+
solana: boolean;
|
|
12
|
+
};
|
|
13
|
+
}
|