@arcblock/ux 2.8.26 → 2.9.1
Sign up to get free protection for your applications and to get access to all the features.
- package/es/Address/did-address.js +33 -21
- package/es/AnimationWaiter/index.js +2 -1
- package/es/Avatar/index.js +1 -1
- package/es/BlockletContext/index.js +1 -1
- package/es/CardSelector/index.js +2 -1
- package/es/Colors/index.js +2 -1
- package/es/Colors/themes/temp.js +17 -0
- package/es/Datatable/TableSearch.js +2 -1
- package/es/Img/index.js +7 -6
- package/es/Locale/selector.js +15 -13
- package/es/NFTDisplay/index.js +2 -1
- package/es/QRCode/index.js +2 -1
- package/es/SessionBlocklet/index.js +169 -0
- package/es/SessionManager/index.js +2 -381
- package/es/SessionPermission/index.js +28 -0
- package/es/SessionUser/components/logged-in.js +224 -0
- package/es/SessionUser/components/session-user-item.js +148 -0
- package/es/SessionUser/components/session-user-switch.js +213 -0
- package/es/SessionUser/components/un-login.js +64 -0
- package/es/SessionUser/components/user-info.js +163 -0
- package/es/SessionUser/index.js +49 -0
- package/es/SessionUser/libs/translation.js +19 -0
- package/es/SessionUser/libs/utils.js +4 -0
- package/es/SplitButton/index.js +2 -1
- package/es/Toast/index.js +1 -1
- package/es/Util/constant.js +10 -0
- package/es/Util/index.js +11 -0
- package/lib/Address/did-address.js +36 -22
- package/lib/AnimationWaiter/index.js +2 -1
- package/lib/Avatar/index.js +1 -1
- package/lib/BlockletContext/index.js +1 -1
- package/lib/CardSelector/index.js +2 -1
- package/lib/Colors/index.js +7 -0
- package/lib/Colors/themes/temp.js +24 -0
- package/lib/Datatable/TableSearch.js +2 -1
- package/lib/Img/index.js +7 -6
- package/lib/Locale/selector.js +14 -13
- package/lib/NFTDisplay/index.js +2 -1
- package/lib/QRCode/index.js +2 -1
- package/lib/SessionBlocklet/index.js +187 -0
- package/lib/SessionManager/index.js +2 -390
- package/lib/SessionPermission/index.js +38 -0
- package/lib/SessionUser/components/logged-in.js +243 -0
- package/lib/SessionUser/components/session-user-item.js +163 -0
- package/lib/SessionUser/components/session-user-switch.js +232 -0
- package/lib/SessionUser/components/un-login.js +72 -0
- package/lib/SessionUser/components/user-info.js +175 -0
- package/lib/SessionUser/index.js +57 -0
- package/lib/SessionUser/libs/translation.js +26 -0
- package/lib/{SessionManager → SessionUser}/libs/utils.js +8 -1
- package/lib/SplitButton/index.js +2 -1
- package/lib/Toast/index.js +5 -5
- package/lib/Util/constant.js +26 -0
- package/lib/Util/index.js +16 -3
- package/package.json +19 -7
- package/src/Address/did-address.jsx +34 -20
- package/src/AnimationWaiter/index.js +2 -1
- package/src/Avatar/index.jsx +1 -1
- package/src/BlockletContext/index.jsx +1 -1
- package/src/CardSelector/index.jsx +2 -1
- package/src/Colors/index.js +1 -0
- package/src/Colors/themes/temp.js +18 -0
- package/src/Datatable/TableSearch.js +3 -1
- package/src/Img/{index.js → index.jsx} +8 -6
- package/src/Locale/selector.jsx +11 -8
- package/src/NFTDisplay/index.js +2 -1
- package/src/QRCode/index.js +2 -1
- package/src/SessionBlocklet/index.jsx +181 -0
- package/src/SessionManager/index.jsx +2 -369
- package/src/SessionPermission/index.jsx +28 -0
- package/src/SessionUser/components/logged-in.jsx +194 -0
- package/src/SessionUser/components/session-user-item.jsx +96 -0
- package/src/SessionUser/components/session-user-switch.jsx +222 -0
- package/src/SessionUser/components/un-login.jsx +55 -0
- package/src/SessionUser/components/user-info.jsx +165 -0
- package/src/SessionUser/index.jsx +38 -0
- package/src/SessionUser/libs/translation.js +19 -0
- package/src/{SessionManager → SessionUser}/libs/utils.js +4 -0
- package/src/SplitButton/index.js +2 -1
- package/src/Toast/index.js +1 -1
- package/src/Util/constant.js +12 -0
- package/src/Util/index.js +13 -0
- package/es/SessionManager/components/account-item.js +0 -212
- package/es/SessionManager/components/add-account-item.js +0 -57
- package/es/SessionManager/components/federated-login-detecter.js +0 -183
- package/es/SessionManager/components/manage-accounts.js +0 -219
- package/es/SessionManager/components/manage-blocklet.js +0 -70
- package/es/SessionManager/components/menu-accordion.js +0 -103
- package/es/SessionManager/components/responsive-popper.js +0 -24
- package/es/SessionManager/components/user-drawer.js +0 -68
- package/es/SessionManager/components/user-info.js +0 -143
- package/es/SessionManager/components/user-popper.js +0 -110
- package/es/SessionManager/hooks/use-config.js +0 -34
- package/es/SessionManager/libs/translation.js +0 -52
- package/es/SessionManager/libs/utils.js +0 -2
- package/lib/SessionManager/components/account-item.js +0 -219
- package/lib/SessionManager/components/add-account-item.js +0 -66
- package/lib/SessionManager/components/federated-login-detecter.js +0 -193
- package/lib/SessionManager/components/manage-accounts.js +0 -232
- package/lib/SessionManager/components/manage-blocklet.js +0 -86
- package/lib/SessionManager/components/menu-accordion.js +0 -111
- package/lib/SessionManager/components/responsive-popper.js +0 -34
- package/lib/SessionManager/components/user-drawer.js +0 -75
- package/lib/SessionManager/components/user-info.js +0 -160
- package/lib/SessionManager/components/user-popper.js +0 -104
- package/lib/SessionManager/hooks/use-config.js +0 -41
- package/lib/SessionManager/libs/translation.js +0 -59
- package/src/SessionManager/components/account-item.jsx +0 -156
- package/src/SessionManager/components/add-account-item.jsx +0 -49
- package/src/SessionManager/components/federated-login-detecter.jsx +0 -167
- package/src/SessionManager/components/manage-accounts.jsx +0 -228
- package/src/SessionManager/components/manage-blocklet.jsx +0 -70
- package/src/SessionManager/components/menu-accordion.jsx +0 -93
- package/src/SessionManager/components/responsive-popper.jsx +0 -26
- package/src/SessionManager/components/user-drawer.jsx +0 -57
- package/src/SessionManager/components/user-info.jsx +0 -117
- package/src/SessionManager/components/user-popper.jsx +0 -95
- package/src/SessionManager/hooks/use-config.js +0 -33
- package/src/SessionManager/libs/translation.js +0 -52
@@ -1,183 +0,0 @@
|
|
1
|
-
import PropTypes from 'prop-types';
|
2
|
-
import { useCallback } from 'react';
|
3
|
-
import Box from '@mui/material/Box';
|
4
|
-
import Chip from '@mui/material/Chip';
|
5
|
-
import Divider from '@mui/material/Divider';
|
6
|
-
import ShieldCheckIcon from '@iconify-icons/mdi/shield-check';
|
7
|
-
import { Icon } from '@iconify/react';
|
8
|
-
import { useCreation, useReactive } from 'ahooks';
|
9
|
-
import UserPopper from './user-popper';
|
10
|
-
import DidAvatar from '../../Avatar';
|
11
|
-
import DidAddress from '../../Address';
|
12
|
-
import Button from '../../Button';
|
13
|
-
import Toast from '../../Toast';
|
14
|
-
import { getUserAvatar } from '../../Util';
|
15
|
-
import { Fragment as _Fragment } from "react/jsx-runtime";
|
16
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
17
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
18
|
-
const translations = {
|
19
|
-
en: {
|
20
|
-
useToConnect({
|
21
|
-
master,
|
22
|
-
member
|
23
|
-
}) {
|
24
|
-
return /*#__PURE__*/_jsxs(_Fragment, {
|
25
|
-
children: ["Connect ", member, " with ", master, " account"]
|
26
|
-
});
|
27
|
-
},
|
28
|
-
connect: 'Connect Account',
|
29
|
-
loginFederatedFailed: 'Login federated account failed'
|
30
|
-
},
|
31
|
-
zh: {
|
32
|
-
useToConnect({
|
33
|
-
master,
|
34
|
-
member
|
35
|
-
}) {
|
36
|
-
return /*#__PURE__*/_jsxs(_Fragment, {
|
37
|
-
children: ["\u4F7F\u7528 ", master, " \u8D26\u53F7\u8FDE\u63A5 ", member]
|
38
|
-
});
|
39
|
-
},
|
40
|
-
connect: '连接账号',
|
41
|
-
loginFederatedFailed: '登录统一登录账号失败'
|
42
|
-
}
|
43
|
-
};
|
44
|
-
export default function FederatedLoginDetecter({
|
45
|
-
session,
|
46
|
-
anchorEl,
|
47
|
-
dark,
|
48
|
-
locale: _locale
|
49
|
-
}) {
|
50
|
-
const state = useReactive({
|
51
|
-
open: true
|
52
|
-
});
|
53
|
-
const federatedMaster = useCreation(() => {
|
54
|
-
return session.federatedMaster;
|
55
|
-
}, [session?.federatedMaster]);
|
56
|
-
const localeList = Object.keys(translations);
|
57
|
-
const locale = localeList.includes(_locale) ? _locale : localeList[0];
|
58
|
-
const onLoginFederated = useCallback(() => {
|
59
|
-
session?.login(err => {
|
60
|
-
if (err) {
|
61
|
-
Toast.error(err || translations[_locale].loginFederatedFailed);
|
62
|
-
} else {
|
63
|
-
state.open = false;
|
64
|
-
}
|
65
|
-
}, {
|
66
|
-
sourceAppPid: federatedMaster?.site?.appPid,
|
67
|
-
mode: federatedMaster?.user ? 'auto' : 'manual'
|
68
|
-
});
|
69
|
-
}, [session, federatedMaster?.site?.appPid, federatedMaster?.user, _locale, state]);
|
70
|
-
let appLogoUrl;
|
71
|
-
if (federatedMaster?.site) {
|
72
|
-
appLogoUrl = new URL(federatedMaster.site.appLogo, federatedMaster.site.appUrl);
|
73
|
-
appLogoUrl.searchParams.set('imageFilter', 'resize');
|
74
|
-
// HACK: 保持跟其他地方使用的尺寸一致,可以复用同一资源的缓存,减少网络请求
|
75
|
-
appLogoUrl.searchParams.set('w', '80');
|
76
|
-
appLogoUrl.searchParams.set('h', '80');
|
77
|
-
}
|
78
|
-
return federatedMaster?.site && /*#__PURE__*/_jsx(UserPopper, {
|
79
|
-
open: state.open,
|
80
|
-
anchorEl: anchorEl,
|
81
|
-
dark: dark,
|
82
|
-
autoClose: false,
|
83
|
-
onClose: () => {
|
84
|
-
state.open = false;
|
85
|
-
},
|
86
|
-
children: /*#__PURE__*/_jsxs(Box, {
|
87
|
-
p: 2,
|
88
|
-
children: [federatedMaster.site && /*#__PURE__*/_jsxs(Box, {
|
89
|
-
display: "flex",
|
90
|
-
alignItems: "center",
|
91
|
-
children: [/*#__PURE__*/_jsx(Box, {
|
92
|
-
component: "img",
|
93
|
-
mr: 2,
|
94
|
-
src: appLogoUrl.href,
|
95
|
-
alt: federatedMaster.site.appName,
|
96
|
-
width: "30px",
|
97
|
-
height: "30px"
|
98
|
-
}), /*#__PURE__*/_jsx(Box, {
|
99
|
-
sx: {
|
100
|
-
maxWidth: '260px'
|
101
|
-
},
|
102
|
-
children: translations[locale].useToConnect({
|
103
|
-
master: /*#__PURE__*/_jsx(Box, {
|
104
|
-
component: "a",
|
105
|
-
href: federatedMaster.site.appUrl,
|
106
|
-
target: "_blank",
|
107
|
-
sx: {
|
108
|
-
textDecoration: 'none',
|
109
|
-
fontWeight: 'bold',
|
110
|
-
color: 'primary.main',
|
111
|
-
fontSize: '1.2em'
|
112
|
-
},
|
113
|
-
children: federatedMaster.site.appName
|
114
|
-
}),
|
115
|
-
member: window.blocklet.appName
|
116
|
-
})
|
117
|
-
})]
|
118
|
-
}), federatedMaster?.site && federatedMaster?.user && /*#__PURE__*/_jsx(Divider, {
|
119
|
-
style: {
|
120
|
-
margin: '15px 0 10px 0'
|
121
|
-
}
|
122
|
-
}), federatedMaster?.user && /*#__PURE__*/_jsxs(Box, {
|
123
|
-
display: "flex",
|
124
|
-
alignItems: "center",
|
125
|
-
children: [/*#__PURE__*/_jsx(DidAvatar, {
|
126
|
-
variant: "circle",
|
127
|
-
did: federatedMaster.user.did,
|
128
|
-
src: getUserAvatar(federatedMaster.user.avatar),
|
129
|
-
size: 28,
|
130
|
-
shape: "circle"
|
131
|
-
}), /*#__PURE__*/_jsxs(Box, {
|
132
|
-
ml: 2,
|
133
|
-
children: [/*#__PURE__*/_jsxs(Box, {
|
134
|
-
display: "flex",
|
135
|
-
justifyContent: "space-between",
|
136
|
-
alignItems: "center",
|
137
|
-
children: [/*#__PURE__*/_jsx(Box, {
|
138
|
-
fontSize: 18,
|
139
|
-
children: federatedMaster.user.fullName
|
140
|
-
}), federatedMaster.user.role?.toUpperCase() && /*#__PURE__*/_jsx(Chip, {
|
141
|
-
label: federatedMaster.user.role?.toUpperCase(),
|
142
|
-
size: "small",
|
143
|
-
variant: "outlined",
|
144
|
-
sx: {
|
145
|
-
height: 'auto',
|
146
|
-
marginRight: 0,
|
147
|
-
fontSize: 12
|
148
|
-
},
|
149
|
-
icon: /*#__PURE__*/_jsx(Icon, {
|
150
|
-
icon: ShieldCheckIcon,
|
151
|
-
fontSize: 14
|
152
|
-
})
|
153
|
-
})]
|
154
|
-
}), /*#__PURE__*/_jsx(DidAddress, {
|
155
|
-
responsive: false,
|
156
|
-
children: federatedMaster.user.did
|
157
|
-
})]
|
158
|
-
})]
|
159
|
-
}), federatedMaster?.site && /*#__PURE__*/_jsx(Box, {
|
160
|
-
display: "flex",
|
161
|
-
justifyContent: "center",
|
162
|
-
mt: 2,
|
163
|
-
children: /*#__PURE__*/_jsx(Button, {
|
164
|
-
variant: "contained",
|
165
|
-
size: "small",
|
166
|
-
onClick: onLoginFederated,
|
167
|
-
children: translations[locale].connect
|
168
|
-
})
|
169
|
-
})]
|
170
|
-
})
|
171
|
-
});
|
172
|
-
}
|
173
|
-
FederatedLoginDetecter.propTypes = {
|
174
|
-
session: PropTypes.object.isRequired,
|
175
|
-
anchorEl: PropTypes.instanceOf(Element),
|
176
|
-
dark: PropTypes.bool,
|
177
|
-
locale: PropTypes.string
|
178
|
-
};
|
179
|
-
FederatedLoginDetecter.defaultProps = {
|
180
|
-
dark: false,
|
181
|
-
anchorEl: null,
|
182
|
-
locale: 'en'
|
183
|
-
};
|
@@ -1,219 +0,0 @@
|
|
1
|
-
/* eslint-disable react/jsx-no-bind */
|
2
|
-
import PropTypes from 'prop-types';
|
3
|
-
import { useMemoizedFn, useReactive, useUpdate } from 'ahooks';
|
4
|
-
import { LinearProgress, MenuItem, SvgIcon } from '@mui/material';
|
5
|
-
import { Icon } from '@iconify/react';
|
6
|
-
import AccountIcon from '@arcblock/icons/lib/Account';
|
7
|
-
import LinkIcon from '@iconify-icons/mdi/link';
|
8
|
-
import DisconnectIcon from '@arcblock/icons/lib/Disconnect';
|
9
|
-
import noop from 'lodash/noop';
|
10
|
-
import AccountItem from './account-item';
|
11
|
-
import MenuAccordion from './menu-accordion';
|
12
|
-
import { translations } from '../libs/translation';
|
13
|
-
import { translate } from '../../Locale/util';
|
14
|
-
import { useConfirm } from '../../Dialog/confirm';
|
15
|
-
import { getSourceProvider } from '../libs/utils';
|
16
|
-
import AddAccountItem from './add-account-item';
|
17
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
18
|
-
import { Fragment as _Fragment } from "react/jsx-runtime";
|
19
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
20
|
-
export default function ManageAccounts({
|
21
|
-
session,
|
22
|
-
locale,
|
23
|
-
onBindWallet,
|
24
|
-
onSwitchDid,
|
25
|
-
connectAccount,
|
26
|
-
close,
|
27
|
-
hasBindAccount,
|
28
|
-
disableLogout,
|
29
|
-
onLogout,
|
30
|
-
expanded,
|
31
|
-
onExpand,
|
32
|
-
accounts,
|
33
|
-
deleteAccount,
|
34
|
-
hideLogout
|
35
|
-
}) {
|
36
|
-
const {
|
37
|
-
bindOAuth,
|
38
|
-
configs: oauthConfigs
|
39
|
-
} = session.useOAuth();
|
40
|
-
const t = useMemoizedFn((key, data = {}) => {
|
41
|
-
return translate(translations, key, locale, 'en', data);
|
42
|
-
});
|
43
|
-
const {
|
44
|
-
confirmApi,
|
45
|
-
confirmHolder
|
46
|
-
} = useConfirm();
|
47
|
-
const update = useUpdate();
|
48
|
-
const pageState = useReactive({
|
49
|
-
logoutLoading: false
|
50
|
-
});
|
51
|
-
const onChoose = useMemoizedFn((account, {
|
52
|
-
active
|
53
|
-
}) => {
|
54
|
-
if (active) {
|
55
|
-
return;
|
56
|
-
}
|
57
|
-
close();
|
58
|
-
if (account.provider === 'auth0') {
|
59
|
-
// 如果切换的目标是 auth0,则直接打开 auth0 登录页面
|
60
|
-
session.switchDid((...args) => {
|
61
|
-
connectAccount();
|
62
|
-
onSwitchDid(...args);
|
63
|
-
}, {
|
64
|
-
allowWallet: false,
|
65
|
-
sourceAppPid: account.sourceAppPid
|
66
|
-
});
|
67
|
-
return;
|
68
|
-
}
|
69
|
-
const options = {
|
70
|
-
provider: account.provider,
|
71
|
-
sourceAppPid: account.sourceAppPid
|
72
|
-
};
|
73
|
-
if (account.did) {
|
74
|
-
options.forceConnected = account.did;
|
75
|
-
}
|
76
|
-
session.switchDid((...args) => {
|
77
|
-
connectAccount();
|
78
|
-
onSwitchDid(...args);
|
79
|
-
}, options);
|
80
|
-
});
|
81
|
-
const oauthConfigList = Object.entries(oauthConfigs).map(([key, value]) => {
|
82
|
-
return {
|
83
|
-
...value,
|
84
|
-
provider: key
|
85
|
-
};
|
86
|
-
}).filter(item => item.enabled);
|
87
|
-
const isRawWalletAccount = getSourceProvider(session.user) === 'wallet';
|
88
|
-
const onDelete = useMemoizedFn((account, {
|
89
|
-
active
|
90
|
-
}) => {
|
91
|
-
if (active) {
|
92
|
-
return;
|
93
|
-
}
|
94
|
-
confirmApi.open({
|
95
|
-
title: t('deleteAccountTitle'),
|
96
|
-
content: t('deleteAccountContent'),
|
97
|
-
confirmButtonText: t('confirm'),
|
98
|
-
cancelButtonText: t('cancel'),
|
99
|
-
onConfirm(done) {
|
100
|
-
deleteAccount(account);
|
101
|
-
update();
|
102
|
-
done();
|
103
|
-
}
|
104
|
-
});
|
105
|
-
});
|
106
|
-
const onAdd = useMemoizedFn(app => {
|
107
|
-
close();
|
108
|
-
session.switchDid((...args) => {
|
109
|
-
connectAccount();
|
110
|
-
update();
|
111
|
-
onSwitchDid(...args);
|
112
|
-
}, {
|
113
|
-
sourceAppPid: app.sourceAppPid,
|
114
|
-
provider: app.provider
|
115
|
-
});
|
116
|
-
});
|
117
|
-
const _onLogout = useMemoizedFn(async (...args) => {
|
118
|
-
pageState.logoutLoading = true;
|
119
|
-
try {
|
120
|
-
await onLogout(...args);
|
121
|
-
} finally {
|
122
|
-
pageState.logoutLoading = true;
|
123
|
-
}
|
124
|
-
});
|
125
|
-
function _onBindWallet() {
|
126
|
-
close();
|
127
|
-
// FIXME: @zhanghan 暂时切换回 isRawWalletAccount 的方式来判断,在 did-connect 改版时,简化这里的关系判断
|
128
|
-
if (!isRawWalletAccount) {
|
129
|
-
session.bindWallet(onBindWallet);
|
130
|
-
} else {
|
131
|
-
bindOAuth({
|
132
|
-
session
|
133
|
-
});
|
134
|
-
}
|
135
|
-
}
|
136
|
-
return /*#__PURE__*/_jsxs(_Fragment, {
|
137
|
-
children: [/*#__PURE__*/_jsxs(MenuAccordion, {
|
138
|
-
expanded: expanded,
|
139
|
-
onChange: onExpand,
|
140
|
-
locale: locale,
|
141
|
-
title: /*#__PURE__*/_jsxs(_Fragment, {
|
142
|
-
children: [/*#__PURE__*/_jsx(AccountIcon, {
|
143
|
-
className: "session-manager-menu-icon",
|
144
|
-
style: {
|
145
|
-
width: 24,
|
146
|
-
height: 24
|
147
|
-
}
|
148
|
-
}), t('accounts')]
|
149
|
-
}),
|
150
|
-
children: [accounts.map(item => /*#__PURE__*/_jsx(AccountItem, {
|
151
|
-
account: item,
|
152
|
-
locale: locale,
|
153
|
-
active: session.user.did === item.did,
|
154
|
-
onDelete: onDelete,
|
155
|
-
onChoose: onChoose
|
156
|
-
}, item.did)), /*#__PURE__*/_jsx(AddAccountItem, {
|
157
|
-
session: session,
|
158
|
-
locale: locale,
|
159
|
-
onAdd: onAdd
|
160
|
-
}), oauthConfigList.length > 0 && !hasBindAccount && /*#__PURE__*/_jsxs(MenuItem, {
|
161
|
-
className: "session-manager-menu-item",
|
162
|
-
onClick: _onBindWallet,
|
163
|
-
"aria-label": !isRawWalletAccount ? `${t('bind')}DID Wallet` : `${t('bind')}${t('thirdParty')}`,
|
164
|
-
"data-cy": "sessionManager-bind-trigger",
|
165
|
-
children: [/*#__PURE__*/_jsx(Icon, {
|
166
|
-
icon: LinkIcon,
|
167
|
-
width: 24,
|
168
|
-
height: 24,
|
169
|
-
className: "session-manager-menu-icon"
|
170
|
-
}), !isRawWalletAccount ? `${t('bind')}DID Wallet` : `${t('bind')}${t('thirdParty')}`]
|
171
|
-
}), !hideLogout ? /*#__PURE__*/_jsxs(MenuItem, {
|
172
|
-
className: "session-manager-menu-item",
|
173
|
-
onClick: _onLogout,
|
174
|
-
disabled: disableLogout,
|
175
|
-
"aria-label": "Logout account",
|
176
|
-
sx: {
|
177
|
-
position: 'relative'
|
178
|
-
},
|
179
|
-
"data-cy": "sessionManager-logout-trigger",
|
180
|
-
children: [pageState.logoutLoading ? /*#__PURE__*/_jsx(LinearProgress, {
|
181
|
-
sx: {
|
182
|
-
height: '2px',
|
183
|
-
position: 'absolute',
|
184
|
-
top: 0,
|
185
|
-
left: 0,
|
186
|
-
right: 0
|
187
|
-
}
|
188
|
-
}) : null, /*#__PURE__*/_jsx(SvgIcon, {
|
189
|
-
component: DisconnectIcon,
|
190
|
-
className: "session-manager-menu-icon"
|
191
|
-
}), t('disconnect')]
|
192
|
-
}) : null]
|
193
|
-
}), confirmHolder]
|
194
|
-
});
|
195
|
-
}
|
196
|
-
ManageAccounts.propTypes = {
|
197
|
-
session: PropTypes.object.isRequired,
|
198
|
-
locale: PropTypes.string,
|
199
|
-
onBindWallet: PropTypes.func.isRequired,
|
200
|
-
onSwitchDid: PropTypes.func.isRequired,
|
201
|
-
connectAccount: PropTypes.func.isRequired,
|
202
|
-
close: PropTypes.func.isRequired,
|
203
|
-
hasBindAccount: PropTypes.bool,
|
204
|
-
disableLogout: PropTypes.bool,
|
205
|
-
onLogout: PropTypes.func.isRequired,
|
206
|
-
expanded: PropTypes.bool,
|
207
|
-
onExpand: PropTypes.func,
|
208
|
-
accounts: PropTypes.array.isRequired,
|
209
|
-
deleteAccount: PropTypes.func.isRequired,
|
210
|
-
hideLogout: PropTypes.bool
|
211
|
-
};
|
212
|
-
ManageAccounts.defaultProps = {
|
213
|
-
locale: 'en',
|
214
|
-
hasBindAccount: false,
|
215
|
-
disableLogout: false,
|
216
|
-
expanded: true,
|
217
|
-
onExpand: noop,
|
218
|
-
hideLogout: false
|
219
|
-
};
|
@@ -1,70 +0,0 @@
|
|
1
|
-
/* eslint-disable react/no-array-index-key */
|
2
|
-
import PropTypes from 'prop-types';
|
3
|
-
import { useMemoizedFn } from 'ahooks';
|
4
|
-
import { Icon } from '@iconify/react';
|
5
|
-
import AppsIcon from '@iconify-icons/mdi/apps';
|
6
|
-
import { MenuItem, SvgIcon } from '@mui/material';
|
7
|
-
import MenuAccordion from './menu-accordion';
|
8
|
-
import { translate } from '../../Locale/util';
|
9
|
-
import { translations } from '../libs/translation';
|
10
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
11
|
-
import { Fragment as _Fragment } from "react/jsx-runtime";
|
12
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
13
|
-
export default function ManageBlocklet({
|
14
|
-
menu,
|
15
|
-
menuRender,
|
16
|
-
locale,
|
17
|
-
expanded,
|
18
|
-
onExpand
|
19
|
-
}) {
|
20
|
-
const t = useMemoizedFn((key, data = {}) => {
|
21
|
-
return translate(translations, key, locale, 'en', data);
|
22
|
-
});
|
23
|
-
return /*#__PURE__*/_jsxs(MenuAccordion, {
|
24
|
-
expanded: expanded,
|
25
|
-
locale: locale,
|
26
|
-
onChange: onExpand,
|
27
|
-
title: /*#__PURE__*/_jsxs(_Fragment, {
|
28
|
-
children: [/*#__PURE__*/_jsx(Icon, {
|
29
|
-
icon: AppsIcon,
|
30
|
-
width: 24,
|
31
|
-
height: 24,
|
32
|
-
className: "session-manager-menu-icon"
|
33
|
-
}), t('blocklet')]
|
34
|
-
}),
|
35
|
-
children: [Array.isArray(menu) && menu.map((menuItem, index) => {
|
36
|
-
const {
|
37
|
-
svgIcon,
|
38
|
-
...menuProps
|
39
|
-
} = menuItem;
|
40
|
-
return /*#__PURE__*/_jsxs(MenuItem, {
|
41
|
-
className: "session-manager-menu-item",
|
42
|
-
...menuProps,
|
43
|
-
icon: undefined,
|
44
|
-
label: undefined,
|
45
|
-
children: [svgIcon ? svgIcon && /*#__PURE__*/_jsx(SvgIcon, {
|
46
|
-
component: svgIcon,
|
47
|
-
className: "session-manager-menu-icon"
|
48
|
-
}) : menuItem.icon, menuItem.label]
|
49
|
-
}, index);
|
50
|
-
}), menuRender({
|
51
|
-
classes: {
|
52
|
-
menuItem: 'session-manager-menu-item',
|
53
|
-
menuIcon: 'session-manager-menu-icon'
|
54
|
-
}
|
55
|
-
})]
|
56
|
-
});
|
57
|
-
}
|
58
|
-
ManageBlocklet.propTypes = {
|
59
|
-
menu: PropTypes.array,
|
60
|
-
menuRender: PropTypes.func,
|
61
|
-
locale: PropTypes.string.isRequired,
|
62
|
-
expanded: PropTypes.bool,
|
63
|
-
onExpand: PropTypes.func
|
64
|
-
};
|
65
|
-
ManageBlocklet.defaultProps = {
|
66
|
-
menu: [],
|
67
|
-
menuRender: () => {},
|
68
|
-
expanded: true,
|
69
|
-
onExpand: () => {}
|
70
|
-
};
|
@@ -1,103 +0,0 @@
|
|
1
|
-
import PropTypes from 'prop-types';
|
2
|
-
import { Accordion, AccordionDetails, AccordionSummary, MenuItem } from '@mui/material';
|
3
|
-
import ExpandMoreIcon from '@iconify-icons/mdi/expand-more';
|
4
|
-
import { Icon } from '@iconify/react';
|
5
|
-
import isEmpty from 'lodash/isEmpty';
|
6
|
-
import isNil from 'lodash/isNil';
|
7
|
-
import { useCreation, useMemoizedFn } from 'ahooks';
|
8
|
-
import { translate } from '../../Locale/util';
|
9
|
-
import { translations } from '../libs/translation';
|
10
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
11
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
12
|
-
function isEmptyNode(node) {
|
13
|
-
if (isNil(node)) {
|
14
|
-
return true;
|
15
|
-
}
|
16
|
-
if (isEmpty(node)) {
|
17
|
-
return true;
|
18
|
-
}
|
19
|
-
if (Array.isArray(node)) {
|
20
|
-
return node.every(item => isEmptyNode(item));
|
21
|
-
}
|
22
|
-
return false;
|
23
|
-
}
|
24
|
-
export default function MenuAccordion({
|
25
|
-
title,
|
26
|
-
children,
|
27
|
-
locale,
|
28
|
-
expanded,
|
29
|
-
onChange
|
30
|
-
}) {
|
31
|
-
const isEmptyChildren = useCreation(() => isEmptyNode(children), [children]);
|
32
|
-
const t = useMemoizedFn((key, data = {}) => {
|
33
|
-
return translate(translations, key, locale, 'en', data);
|
34
|
-
});
|
35
|
-
return /*#__PURE__*/_jsxs(Accordion, {
|
36
|
-
expanded: expanded,
|
37
|
-
disableGutters: true,
|
38
|
-
elevation: 0,
|
39
|
-
onChange: (e, value) => {
|
40
|
-
onChange(value);
|
41
|
-
},
|
42
|
-
sx: {
|
43
|
-
'&.MuiAccordion-root:before': {
|
44
|
-
content: 'unset'
|
45
|
-
},
|
46
|
-
'.MuiAccordionSummary-root': {
|
47
|
-
minHeight: 'auto',
|
48
|
-
width: '100%'
|
49
|
-
},
|
50
|
-
'.MuiAccordionSummary-content': {
|
51
|
-
margin: 0
|
52
|
-
},
|
53
|
-
'.MuiAccordionDetails-root': {
|
54
|
-
padding: 0,
|
55
|
-
'.session-manager-menu-item': {
|
56
|
-
fontSize: '15px',
|
57
|
-
padding: '12px 15px 12px 42px',
|
58
|
-
whiteSpace: 'normal'
|
59
|
-
},
|
60
|
-
'.session-manager-menu-icon': {
|
61
|
-
height: '21px',
|
62
|
-
widht: '21px'
|
63
|
-
}
|
64
|
-
}
|
65
|
-
},
|
66
|
-
children: [/*#__PURE__*/_jsx(MenuItem, {
|
67
|
-
sx: {
|
68
|
-
padding: 0,
|
69
|
-
width: '100%'
|
70
|
-
},
|
71
|
-
children: /*#__PURE__*/_jsx(AccordionSummary, {
|
72
|
-
className: "session-manager-menu-item",
|
73
|
-
expandIcon: /*#__PURE__*/_jsx(Icon, {
|
74
|
-
icon: ExpandMoreIcon,
|
75
|
-
width: 24,
|
76
|
-
height: 24
|
77
|
-
}),
|
78
|
-
children: title
|
79
|
-
})
|
80
|
-
}), /*#__PURE__*/_jsx(AccordionDetails, {
|
81
|
-
children: isEmptyChildren ? /*#__PURE__*/_jsx(MenuItem, {
|
82
|
-
disabled: true,
|
83
|
-
className: "session-manager-menu-item",
|
84
|
-
sx: {
|
85
|
-
justifyContent: 'center'
|
86
|
-
},
|
87
|
-
children: t('noneMenu')
|
88
|
-
}, "empty") : children
|
89
|
-
})]
|
90
|
-
});
|
91
|
-
}
|
92
|
-
MenuAccordion.propTypes = {
|
93
|
-
title: PropTypes.any.isRequired,
|
94
|
-
children: PropTypes.any.isRequired,
|
95
|
-
locale: PropTypes.string,
|
96
|
-
expanded: PropTypes.bool,
|
97
|
-
onChange: PropTypes.func
|
98
|
-
};
|
99
|
-
MenuAccordion.defaultProps = {
|
100
|
-
locale: 'en',
|
101
|
-
expanded: true,
|
102
|
-
onChange: () => {}
|
103
|
-
};
|
@@ -1,24 +0,0 @@
|
|
1
|
-
import { useCreation, useSize } from 'ahooks';
|
2
|
-
import UserPopper from './user-popper';
|
3
|
-
import UserDrawer from './user-drawer';
|
4
|
-
import { useTheme } from '../../Theme';
|
5
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
6
|
-
export default function ResponsivePopper(props) {
|
7
|
-
const theme = useTheme();
|
8
|
-
const size = useSize(document.body);
|
9
|
-
const isMobile = useCreation(() => {
|
10
|
-
if (size?.width <= theme.breakpoints.values.sm) {
|
11
|
-
return true;
|
12
|
-
}
|
13
|
-
return false;
|
14
|
-
}, [theme, size]);
|
15
|
-
const WrapContainer = useCreation(() => {
|
16
|
-
if (isMobile) {
|
17
|
-
return UserDrawer;
|
18
|
-
}
|
19
|
-
return UserPopper;
|
20
|
-
}, [isMobile]);
|
21
|
-
return /*#__PURE__*/_jsx(WrapContainer, {
|
22
|
-
...props
|
23
|
-
});
|
24
|
-
}
|
@@ -1,68 +0,0 @@
|
|
1
|
-
import PropTypes from 'prop-types';
|
2
|
-
import { IconButton, Drawer } from '@mui/material';
|
3
|
-
import CloseIcon from '@iconify-icons/mdi/close';
|
4
|
-
import { Icon } from '@iconify/react';
|
5
|
-
import noop from 'lodash/noop';
|
6
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
7
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
8
|
-
export default function UserDrawer({
|
9
|
-
children,
|
10
|
-
open,
|
11
|
-
onOpen,
|
12
|
-
onClose
|
13
|
-
}) {
|
14
|
-
return /*#__PURE__*/_jsxs(Drawer, {
|
15
|
-
anchor: "bottom",
|
16
|
-
open: open,
|
17
|
-
onClose: onClose,
|
18
|
-
onOpen: onOpen,
|
19
|
-
sx: theme => ({
|
20
|
-
'& .MuiDrawer-paper.MuiPaper-root': {
|
21
|
-
width: '100%',
|
22
|
-
height: '90vh',
|
23
|
-
borderTopLeftRadius: '16px',
|
24
|
-
borderTopRightRadius: '16px'
|
25
|
-
},
|
26
|
-
'& .MuiChip-root .MuiChip-icon': {
|
27
|
-
color: theme.palette.success.main
|
28
|
-
},
|
29
|
-
'& .session-manager-menu-item': {
|
30
|
-
padding: '15px',
|
31
|
-
color: '#777',
|
32
|
-
fontSize: '16px',
|
33
|
-
'&:hover': {
|
34
|
-
backgroundColor: '#fbfbfb'
|
35
|
-
}
|
36
|
-
},
|
37
|
-
'& .session-manager-menu-icon': {
|
38
|
-
color: '#999',
|
39
|
-
marginRight: '8px'
|
40
|
-
}
|
41
|
-
}),
|
42
|
-
children: [/*#__PURE__*/_jsx(IconButton, {
|
43
|
-
sx: {
|
44
|
-
cursor: 'pointer',
|
45
|
-
position: 'absolute',
|
46
|
-
right: '8px',
|
47
|
-
top: '8px',
|
48
|
-
zIndex: 1
|
49
|
-
},
|
50
|
-
onClick: onClose,
|
51
|
-
children: /*#__PURE__*/_jsx(Icon, {
|
52
|
-
icon: CloseIcon,
|
53
|
-
width: 28,
|
54
|
-
height: 28
|
55
|
-
})
|
56
|
-
}), children]
|
57
|
-
});
|
58
|
-
}
|
59
|
-
UserDrawer.propTypes = {
|
60
|
-
children: PropTypes.any.isRequired,
|
61
|
-
open: PropTypes.bool.isRequired,
|
62
|
-
onOpen: PropTypes.func,
|
63
|
-
onClose: PropTypes.func
|
64
|
-
};
|
65
|
-
UserDrawer.defaultProps = {
|
66
|
-
onOpen: noop,
|
67
|
-
onClose: noop
|
68
|
-
};
|