@aptos-labs/wallet-adapter-mui-design 5.1.3 → 5.3.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 CHANGED
@@ -1,5 +1,26 @@
1
1
  # @aptos-labs/wallet-adapter-mui-design
2
2
 
3
+ ## 5.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - d2d308c: Bump @aptos-connect/wallet-adapter-plugin to 2.7.0
8
+ - b3474b3: Update AC dns to web.petra.app
9
+ - 499e03e: Rename aptos connect to petra web
10
+
11
+ ### Patch Changes
12
+
13
+ - Updated dependencies [d2d308c]
14
+ - Updated dependencies [b3474b3]
15
+ - Updated dependencies [499e03e]
16
+ - @aptos-labs/wallet-adapter-react@7.2.0
17
+
18
+ ## 5.2.0
19
+
20
+ ### Minor Changes
21
+
22
+ - 7cfd347: Add cross chain wallet support to MUI wallet selector
23
+
3
24
  ## 5.1.3
4
25
 
5
26
  ### Patch Changes
package/dist/index.js CHANGED
@@ -288,7 +288,7 @@ function WalletsModal(_a) {
288
288
  },
289
289
  children: hasAptosConnectWallets ? /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
290
290
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: "Log in or sign up" }),
291
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: "with Social + Aptos Connect" })
291
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: "with Social + Petra Web" })
292
292
  ] }) : "Connect Wallet"
293
293
  }
294
294
  ),
@@ -372,7 +372,7 @@ function WalletsModal(_a) {
372
372
  appearance: "none"
373
373
  },
374
374
  children: [
375
- "Aptos Connect ",
375
+ "Petra Web ",
376
376
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.ArrowForward, { sx: { height: 16, width: 16 } })
377
377
  ]
378
378
  }
@@ -532,7 +532,7 @@ function renderEducationScreen(screen) {
532
532
  },
533
533
  children: [
534
534
  /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material3.IconButton, { onClick: screen.cancel, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_icons_material2.ArrowBack, {}) }),
535
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material3.Typography, { variant: "body1", component: "h2", width: "100%", align: "center", children: "About Aptos Connect" })
535
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_material3.Typography, { variant: "body1", component: "h2", width: "100%", align: "center", children: "About Petra Web" })
536
536
  ]
537
537
  }
538
538
  ),
package/dist/index.mjs CHANGED
@@ -297,7 +297,7 @@ function WalletsModal(_a) {
297
297
  },
298
298
  children: hasAptosConnectWallets ? /* @__PURE__ */ jsxs3(Fragment2, { children: [
299
299
  /* @__PURE__ */ jsx3("span", { children: "Log in or sign up" }),
300
- /* @__PURE__ */ jsx3("span", { children: "with Social + Aptos Connect" })
300
+ /* @__PURE__ */ jsx3("span", { children: "with Social + Petra Web" })
301
301
  ] }) : "Connect Wallet"
302
302
  }
303
303
  ),
@@ -381,7 +381,7 @@ function WalletsModal(_a) {
381
381
  appearance: "none"
382
382
  },
383
383
  children: [
384
- "Aptos Connect ",
384
+ "Petra Web ",
385
385
  /* @__PURE__ */ jsx3(ArrowForward, { sx: { height: 16, width: 16 } })
386
386
  ]
387
387
  }
@@ -541,7 +541,7 @@ function renderEducationScreen(screen) {
541
541
  },
542
542
  children: [
543
543
  /* @__PURE__ */ jsx3(IconButton, { onClick: screen.cancel, children: /* @__PURE__ */ jsx3(ArrowBack, {}) }),
544
- /* @__PURE__ */ jsx3(Typography2, { variant: "body1", component: "h2", width: "100%", align: "center", children: "About Aptos Connect" })
544
+ /* @__PURE__ */ jsx3(Typography2, { variant: "body1", component: "h2", width: "100%", align: "center", children: "About Petra Web" })
545
545
  ]
546
546
  }
547
547
  ),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aptos-labs/wallet-adapter-mui-design",
3
- "version": "5.1.3",
3
+ "version": "5.3.0",
4
4
  "description": "Aptos Wallet Adapter mui design",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
@@ -41,7 +41,7 @@
41
41
  "@emotion/styled": "^11.10.5",
42
42
  "@mui/icons-material": "^5.11.0",
43
43
  "@mui/material": "^5.11.6",
44
- "@aptos-labs/wallet-adapter-react": "7.1.3"
44
+ "@aptos-labs/wallet-adapter-react": "7.2.0"
45
45
  },
46
46
  "peerDependencies": {
47
47
  "react": "^18.0.0 || ^19.0.0",
@@ -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
  </>
@@ -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 "./WalletConnector";
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"
@@ -106,12 +224,13 @@ export default function WalletsModal({
106
224
  {hasAptosConnectWallets ? (
107
225
  <>
108
226
  <span>Log in or sign up</span>
109
- <span>with Social + Aptos Connect</span>
227
+ <span>with Social + Petra Web</span>
110
228
  </>
111
229
  ) : (
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) => (
@@ -177,7 +297,7 @@ export default function WalletsModal({
177
297
  appearance: "none",
178
298
  }}
179
299
  >
180
- Aptos Connect <ArrowForward sx={{ height: 16, width: 16 }} />
300
+ Petra Web <ArrowForward sx={{ height: 16, width: 16 }} />
181
301
  </Box>
182
302
  </Typography>
183
303
 
@@ -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
- <Stack sx={{ gap: 1 }}>
217
- {availableWallets.map((wallet) => (
218
- <WalletRow
219
- key={wallet.name}
220
- wallet={wallet}
221
- onConnect={handleClose}
222
- />
223
- ))}
224
- {!!installableWallets.length && (
225
- <>
226
- <Button
227
- variant="text"
228
- size="small"
229
- onClick={() => setExpanded((prev) => !prev)}
230
- endIcon={
231
- <ExpandMore sx={{ height: "20px", width: "20px" }} />
232
- }
233
- >
234
- More Wallets
235
- </Button>
236
- <Collapse in={expanded} timeout="auto" unmountOnExit>
237
- <Stack sx={{ gap: 1 }}>
238
- {installableWallets.map((wallet) => (
239
- <WalletRow
240
- key={wallet.name}
241
- wallet={wallet}
242
- onConnect={handleClose}
243
- />
244
- ))}
245
- </Stack>
246
- </Collapse>
247
- </>
248
- )}
249
- </Stack>
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>
@@ -340,7 +465,7 @@ function renderEducationScreen(screen: AboutAptosConnectEducationScreen) {
340
465
  <ArrowBack />
341
466
  </IconButton>
342
467
  <Typography variant="body1" component="h2" width="100%" align="center">
343
- About Aptos Connect
468
+ About Petra Web
344
469
  </Typography>
345
470
  </Box>
346
471
 
@@ -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
+ }