@aptos-labs/wallet-adapter-ant-design 5.0.0 → 5.1.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 +12 -0
- package/dist/index.js +24 -1
- package/dist/index.mjs +33 -3
- package/package.json +2 -2
- package/src/WalletSelector.tsx +45 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @aptos-labs/wallet-adapter-ant-design
|
|
2
2
|
|
|
3
|
+
## 5.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 4d0b4ec: Modify the wallet button to have a dropdown with two options: "Copy Address" and "Disconnect"
|
|
8
|
+
|
|
9
|
+
## 5.0.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- @aptos-labs/wallet-adapter-react@7.0.1
|
|
14
|
+
|
|
3
15
|
## 5.0.0
|
|
4
16
|
|
|
5
17
|
### Major Changes
|
package/dist/index.js
CHANGED
|
@@ -94,6 +94,29 @@ function WalletSelector(_a) {
|
|
|
94
94
|
setWalletSelectorModalOpen(true);
|
|
95
95
|
}
|
|
96
96
|
};
|
|
97
|
+
const handleCopyAddress = () => {
|
|
98
|
+
if (account == null ? void 0 : account.address) {
|
|
99
|
+
navigator.clipboard.writeText(account.address.toString());
|
|
100
|
+
import_antd.message.success("Address copied to clipboard");
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
const handleDisconnect = () => {
|
|
104
|
+
disconnect();
|
|
105
|
+
};
|
|
106
|
+
const dropdownItems = [
|
|
107
|
+
{
|
|
108
|
+
key: "copy",
|
|
109
|
+
label: "Copy Address",
|
|
110
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.CopyOutlined, {}),
|
|
111
|
+
onClick: handleCopyAddress
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
key: "disconnect",
|
|
115
|
+
label: "Disconnect",
|
|
116
|
+
icon: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_icons.DisconnectOutlined, {}),
|
|
117
|
+
onClick: handleDisconnect
|
|
118
|
+
}
|
|
119
|
+
];
|
|
97
120
|
const closeModal = () => {
|
|
98
121
|
setWalletSelectorModalOpen(false);
|
|
99
122
|
if (setModalOpen) {
|
|
@@ -164,7 +187,7 @@ function WalletSelector(_a) {
|
|
|
164
187
|
})
|
|
165
188
|
);
|
|
166
189
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [
|
|
167
|
-
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.Button, { className: "wallet-button",
|
|
190
|
+
connected ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.Dropdown, { menu: { items: dropdownItems }, trigger: ["click"], children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.Button, { className: "wallet-button", children: buttonText }) }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_antd.Button, { className: "wallet-button", onClick: onWalletButtonClick, children: "Connect Wallet" }),
|
|
168
191
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_wallet_adapter_react.AboutAptosConnect, { renderEducationScreen: renderEducationScreens, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
169
192
|
import_antd.Modal,
|
|
170
193
|
__spreadProps(__spreadValues({}, modalProps), {
|
package/dist/index.mjs
CHANGED
|
@@ -31,7 +31,12 @@ var __objRest = (source, exclude) => {
|
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
// src/WalletSelector.tsx
|
|
34
|
-
import {
|
|
34
|
+
import {
|
|
35
|
+
ArrowLeftOutlined,
|
|
36
|
+
ArrowRightOutlined,
|
|
37
|
+
CopyOutlined,
|
|
38
|
+
DisconnectOutlined
|
|
39
|
+
} from "@ant-design/icons";
|
|
35
40
|
import {
|
|
36
41
|
AboutAptosConnect,
|
|
37
42
|
AptosPrivacyPolicy,
|
|
@@ -45,9 +50,11 @@ import {
|
|
|
45
50
|
Button,
|
|
46
51
|
Collapse,
|
|
47
52
|
Divider,
|
|
53
|
+
Dropdown,
|
|
48
54
|
Flex,
|
|
49
55
|
Modal,
|
|
50
|
-
Typography
|
|
56
|
+
Typography,
|
|
57
|
+
message
|
|
51
58
|
} from "antd";
|
|
52
59
|
import { useEffect, useState } from "react";
|
|
53
60
|
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
@@ -86,6 +93,29 @@ function WalletSelector(_a) {
|
|
|
86
93
|
setWalletSelectorModalOpen(true);
|
|
87
94
|
}
|
|
88
95
|
};
|
|
96
|
+
const handleCopyAddress = () => {
|
|
97
|
+
if (account == null ? void 0 : account.address) {
|
|
98
|
+
navigator.clipboard.writeText(account.address.toString());
|
|
99
|
+
message.success("Address copied to clipboard");
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
const handleDisconnect = () => {
|
|
103
|
+
disconnect();
|
|
104
|
+
};
|
|
105
|
+
const dropdownItems = [
|
|
106
|
+
{
|
|
107
|
+
key: "copy",
|
|
108
|
+
label: "Copy Address",
|
|
109
|
+
icon: /* @__PURE__ */ jsx(CopyOutlined, {}),
|
|
110
|
+
onClick: handleCopyAddress
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
key: "disconnect",
|
|
114
|
+
label: "Disconnect",
|
|
115
|
+
icon: /* @__PURE__ */ jsx(DisconnectOutlined, {}),
|
|
116
|
+
onClick: handleDisconnect
|
|
117
|
+
}
|
|
118
|
+
];
|
|
89
119
|
const closeModal = () => {
|
|
90
120
|
setWalletSelectorModalOpen(false);
|
|
91
121
|
if (setModalOpen) {
|
|
@@ -156,7 +186,7 @@ function WalletSelector(_a) {
|
|
|
156
186
|
})
|
|
157
187
|
);
|
|
158
188
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
159
|
-
/* @__PURE__ */ jsx(Button, { className: "wallet-button",
|
|
189
|
+
connected ? /* @__PURE__ */ jsx(Dropdown, { menu: { items: dropdownItems }, trigger: ["click"], children: /* @__PURE__ */ jsx(Button, { className: "wallet-button", children: buttonText }) }) : /* @__PURE__ */ jsx(Button, { className: "wallet-button", onClick: onWalletButtonClick, children: "Connect Wallet" }),
|
|
160
190
|
/* @__PURE__ */ jsx(AboutAptosConnect, { renderEducationScreen: renderEducationScreens, children: /* @__PURE__ */ jsx(
|
|
161
191
|
Modal,
|
|
162
192
|
__spreadProps(__spreadValues({}, modalProps), {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aptos-labs/wallet-adapter-ant-design",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.1.0",
|
|
4
4
|
"description": "Aptos Wallet Adapter ant-design",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"dependencies": {
|
|
46
46
|
"@ant-design/icons": "^5.3.7",
|
|
47
47
|
"antd": "^5.18.3",
|
|
48
|
-
"@aptos-labs/wallet-adapter-react": "7.0.
|
|
48
|
+
"@aptos-labs/wallet-adapter-react": "7.0.1"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"react": "^18.0.0 || ^19.0.0",
|
package/src/WalletSelector.tsx
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
ArrowLeftOutlined,
|
|
3
|
+
ArrowRightOutlined,
|
|
4
|
+
CopyOutlined,
|
|
5
|
+
DisconnectOutlined,
|
|
6
|
+
} from "@ant-design/icons";
|
|
2
7
|
import {
|
|
3
8
|
AboutAptosConnect,
|
|
4
9
|
AboutAptosConnectEducationScreen,
|
|
@@ -16,10 +21,13 @@ import {
|
|
|
16
21
|
Button,
|
|
17
22
|
Collapse,
|
|
18
23
|
Divider,
|
|
24
|
+
Dropdown,
|
|
19
25
|
Flex,
|
|
26
|
+
MenuProps,
|
|
20
27
|
Modal,
|
|
21
28
|
ModalProps,
|
|
22
29
|
Typography,
|
|
30
|
+
message,
|
|
23
31
|
} from "antd";
|
|
24
32
|
import { Dispatch, SetStateAction, useEffect, useState } from "react";
|
|
25
33
|
import "./styles.css";
|
|
@@ -57,7 +65,7 @@ export function WalletSelector({
|
|
|
57
65
|
const { aptosConnectWallets, availableWallets, installableWallets } =
|
|
58
66
|
groupAndSortWallets(
|
|
59
67
|
[...wallets, ...notDetectedWallets],
|
|
60
|
-
walletSortingOptions
|
|
68
|
+
walletSortingOptions
|
|
61
69
|
);
|
|
62
70
|
|
|
63
71
|
const hasAptosConnectWallets = !!aptosConnectWallets.length;
|
|
@@ -70,6 +78,32 @@ export function WalletSelector({
|
|
|
70
78
|
}
|
|
71
79
|
};
|
|
72
80
|
|
|
81
|
+
const handleCopyAddress = () => {
|
|
82
|
+
if (account?.address) {
|
|
83
|
+
navigator.clipboard.writeText(account.address.toString());
|
|
84
|
+
message.success("Address copied to clipboard");
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const handleDisconnect = () => {
|
|
89
|
+
disconnect();
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const dropdownItems: MenuProps["items"] = [
|
|
93
|
+
{
|
|
94
|
+
key: "copy",
|
|
95
|
+
label: "Copy Address",
|
|
96
|
+
icon: <CopyOutlined />,
|
|
97
|
+
onClick: handleCopyAddress,
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
key: "disconnect",
|
|
101
|
+
label: "Disconnect",
|
|
102
|
+
icon: <DisconnectOutlined />,
|
|
103
|
+
onClick: handleDisconnect,
|
|
104
|
+
},
|
|
105
|
+
];
|
|
106
|
+
|
|
73
107
|
const closeModal = () => {
|
|
74
108
|
setWalletSelectorModalOpen(false);
|
|
75
109
|
if (setModalOpen) {
|
|
@@ -146,9 +180,15 @@ export function WalletSelector({
|
|
|
146
180
|
|
|
147
181
|
return (
|
|
148
182
|
<>
|
|
149
|
-
|
|
150
|
-
{
|
|
151
|
-
|
|
183
|
+
{connected ? (
|
|
184
|
+
<Dropdown menu={{ items: dropdownItems }} trigger={["click"]}>
|
|
185
|
+
<Button className="wallet-button">{buttonText}</Button>
|
|
186
|
+
</Dropdown>
|
|
187
|
+
) : (
|
|
188
|
+
<Button className="wallet-button" onClick={onWalletButtonClick}>
|
|
189
|
+
Connect Wallet
|
|
190
|
+
</Button>
|
|
191
|
+
)}
|
|
152
192
|
<AboutAptosConnect renderEducationScreen={renderEducationScreens}>
|
|
153
193
|
<Modal
|
|
154
194
|
{...modalProps}
|