@arcblock/ux 2.8.15 → 2.8.17
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/es/SessionManager/{account-item.js → components/account-item.js} +5 -5
- package/es/SessionManager/{add-account-item.js → components/add-account-item.js} +3 -3
- package/es/SessionManager/{federated-login-detecter.js → components/federated-login-detecter.js} +5 -5
- package/es/SessionManager/{manage-accounts.js → components/manage-accounts.js} +12 -9
- package/es/SessionManager/{manage-blocklet.js → components/manage-blocklet.js} +2 -2
- package/es/SessionManager/{menu-accordion.js → components/menu-accordion.js} +2 -2
- package/es/SessionManager/components/responsive-popper.js +24 -0
- package/es/SessionManager/components/user-drawer.js +65 -0
- package/es/SessionManager/{user-info.js → components/user-info.js} +7 -7
- package/es/SessionManager/{user-popper.js → components/user-popper.js} +5 -4
- package/es/SessionManager/index.js +9 -9
- package/lib/SessionManager/{account-item.js → components/account-item.js} +5 -5
- package/lib/SessionManager/{add-account-item.js → components/add-account-item.js} +3 -3
- package/lib/SessionManager/{federated-login-detecter.js → components/federated-login-detecter.js} +5 -5
- package/lib/SessionManager/{manage-accounts.js → components/manage-accounts.js} +12 -9
- package/lib/SessionManager/{manage-blocklet.js → components/manage-blocklet.js} +2 -2
- package/lib/SessionManager/{menu-accordion.js → components/menu-accordion.js} +2 -2
- package/lib/SessionManager/components/responsive-popper.js +34 -0
- package/lib/SessionManager/components/user-drawer.js +72 -0
- package/lib/SessionManager/{user-info.js → components/user-info.js} +7 -7
- package/lib/SessionManager/{user-popper.js → components/user-popper.js} +5 -2
- package/lib/SessionManager/index.js +9 -9
- package/package.json +4 -4
- package/src/SessionManager/{account-item.jsx → components/account-item.jsx} +5 -5
- package/src/SessionManager/{add-account-item.jsx → components/add-account-item.jsx} +3 -3
- package/src/SessionManager/{federated-login-detecter.jsx → components/federated-login-detecter.jsx} +5 -5
- package/src/SessionManager/{manage-accounts.jsx → components/manage-accounts.jsx} +32 -27
- package/src/SessionManager/{manage-blocklet.jsx → components/manage-blocklet.jsx} +2 -2
- package/src/SessionManager/{menu-accordion.jsx → components/menu-accordion.jsx} +2 -2
- package/src/SessionManager/components/responsive-popper.jsx +26 -0
- package/src/SessionManager/components/user-drawer.jsx +54 -0
- package/src/SessionManager/{user-info.jsx → components/user-info.jsx} +7 -7
- package/src/SessionManager/{user-popper.jsx → components/user-popper.jsx} +5 -4
- package/src/SessionManager/index.jsx +10 -10
- /package/es/SessionManager/{use-config.js → hooks/use-config.js} +0 -0
- /package/es/SessionManager/{translation.js → libs/translation.js} +0 -0
- /package/es/SessionManager/{utils.js → libs/utils.js} +0 -0
- /package/lib/SessionManager/{use-config.js → hooks/use-config.js} +0 -0
- /package/lib/SessionManager/{translation.js → libs/translation.js} +0 -0
- /package/lib/SessionManager/{utils.js → libs/utils.js} +0 -0
- /package/src/SessionManager/{use-config.js → hooks/use-config.js} +0 -0
- /package/src/SessionManager/{translation.js → libs/translation.js} +0 -0
- /package/src/SessionManager/{utils.js → libs/utils.js} +0 -0
|
@@ -9,11 +9,11 @@ import ApiIcon from '@iconify-icons/mdi/api';
|
|
|
9
9
|
import Auth0Icon from '@iconify-icons/logos/auth0-icon';
|
|
10
10
|
import TrashCanOutlineIcon from '@iconify-icons/mdi/trash-can-outline';
|
|
11
11
|
import { useCreation, useMemoizedFn } from 'ahooks';
|
|
12
|
-
import Avatar from '
|
|
13
|
-
import DID from '
|
|
14
|
-
import { translate } from '
|
|
15
|
-
import { translations } from '
|
|
16
|
-
import { getFederatedEnabled } from '
|
|
12
|
+
import Avatar from '../../Avatar';
|
|
13
|
+
import DID from '../../DID';
|
|
14
|
+
import { translate } from '../../Locale/util';
|
|
15
|
+
import { translations } from '../libs/translation';
|
|
16
|
+
import { getFederatedEnabled } from '../../Util/federated';
|
|
17
17
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
18
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
19
19
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -3,9 +3,9 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
import { MenuItem, Typography } from '@mui/material';
|
|
4
4
|
import AddIcon from '@iconify-icons/ion/ios-add-circle-outline';
|
|
5
5
|
import { useCreation, useMemoizedFn } from 'ahooks';
|
|
6
|
-
import { translate } from '
|
|
7
|
-
import { translations } from '
|
|
8
|
-
import { getApps } from '
|
|
6
|
+
import { translate } from '../../Locale/util';
|
|
7
|
+
import { translations } from '../libs/translation';
|
|
8
|
+
import { getApps } from '../../Util/federated';
|
|
9
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
10
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
11
|
export default function AddAccountItem({
|
package/es/SessionManager/{federated-login-detecter.js → components/federated-login-detecter.js}
RENAMED
|
@@ -7,11 +7,11 @@ import ShieldCheckIcon from '@iconify-icons/mdi/shield-check';
|
|
|
7
7
|
import { Icon } from '@iconify/react';
|
|
8
8
|
import { useCreation, useReactive } from 'ahooks';
|
|
9
9
|
import UserPopper from './user-popper';
|
|
10
|
-
import DidAvatar from '
|
|
11
|
-
import DidAddress from '
|
|
12
|
-
import Button from '
|
|
13
|
-
import Toast from '
|
|
14
|
-
import { getUserAvatar } from '
|
|
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
15
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
16
16
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
17
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
@@ -9,10 +9,10 @@ import DisconnectIcon from '@arcblock/icons/lib/Disconnect';
|
|
|
9
9
|
import noop from 'lodash/noop';
|
|
10
10
|
import AccountItem from './account-item';
|
|
11
11
|
import MenuAccordion from './menu-accordion';
|
|
12
|
-
import { translations } from '
|
|
13
|
-
import { translate } from '
|
|
14
|
-
import { useConfirm } from '
|
|
15
|
-
import { getSourceProvider } from '
|
|
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
16
|
import AddAccountItem from './add-account-item';
|
|
17
17
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
18
18
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
@@ -30,7 +30,8 @@ export default function ManageAccounts({
|
|
|
30
30
|
expanded,
|
|
31
31
|
onExpand,
|
|
32
32
|
accounts,
|
|
33
|
-
deleteAccount
|
|
33
|
+
deleteAccount,
|
|
34
|
+
hideLogout
|
|
34
35
|
}) {
|
|
35
36
|
const {
|
|
36
37
|
bindOAuth,
|
|
@@ -167,7 +168,7 @@ export default function ManageAccounts({
|
|
|
167
168
|
height: 24,
|
|
168
169
|
className: "session-manager-menu-icon"
|
|
169
170
|
}), !isRawWalletAccount ? `${t('bind')}DID Wallet` : `${t('bind')}${t('thirdParty')}`]
|
|
170
|
-
}), /*#__PURE__*/_jsxs(MenuItem, {
|
|
171
|
+
}), !hideLogout ? /*#__PURE__*/_jsxs(MenuItem, {
|
|
171
172
|
className: "session-manager-menu-item",
|
|
172
173
|
onClick: _onLogout,
|
|
173
174
|
disabled: disableLogout,
|
|
@@ -188,7 +189,7 @@ export default function ManageAccounts({
|
|
|
188
189
|
component: DisconnectIcon,
|
|
189
190
|
className: "session-manager-menu-icon"
|
|
190
191
|
}), t('disconnect')]
|
|
191
|
-
})]
|
|
192
|
+
}) : null]
|
|
192
193
|
}), confirmHolder]
|
|
193
194
|
});
|
|
194
195
|
}
|
|
@@ -205,12 +206,14 @@ ManageAccounts.propTypes = {
|
|
|
205
206
|
expanded: PropTypes.bool,
|
|
206
207
|
onExpand: PropTypes.func,
|
|
207
208
|
accounts: PropTypes.array.isRequired,
|
|
208
|
-
deleteAccount: PropTypes.func.isRequired
|
|
209
|
+
deleteAccount: PropTypes.func.isRequired,
|
|
210
|
+
hideLogout: PropTypes.bool
|
|
209
211
|
};
|
|
210
212
|
ManageAccounts.defaultProps = {
|
|
211
213
|
locale: 'en',
|
|
212
214
|
hasBindAccount: false,
|
|
213
215
|
disableLogout: false,
|
|
214
216
|
expanded: true,
|
|
215
|
-
onExpand: noop
|
|
217
|
+
onExpand: noop,
|
|
218
|
+
hideLogout: false
|
|
216
219
|
};
|
|
@@ -5,8 +5,8 @@ import { Icon } from '@iconify/react';
|
|
|
5
5
|
import AppsIcon from '@iconify-icons/mdi/apps';
|
|
6
6
|
import { MenuItem, SvgIcon } from '@mui/material';
|
|
7
7
|
import MenuAccordion from './menu-accordion';
|
|
8
|
-
import { translate } from '
|
|
9
|
-
import { translations } from '
|
|
8
|
+
import { translate } from '../../Locale/util';
|
|
9
|
+
import { translations } from '../libs/translation';
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
11
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
12
12
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -5,8 +5,8 @@ import { Icon } from '@iconify/react';
|
|
|
5
5
|
import isEmpty from 'lodash/isEmpty';
|
|
6
6
|
import isNil from 'lodash/isNil';
|
|
7
7
|
import { useCreation, useMemoizedFn } from 'ahooks';
|
|
8
|
-
import { translate } from '
|
|
9
|
-
import { translations } from '
|
|
8
|
+
import { translate } from '../../Locale/util';
|
|
9
|
+
import { translations } from '../libs/translation';
|
|
10
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
11
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
12
|
function isEmptyNode(node) {
|
|
@@ -0,0 +1,24 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
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: "right",
|
|
16
|
+
open: open,
|
|
17
|
+
onClose: onClose,
|
|
18
|
+
onOpen: onOpen,
|
|
19
|
+
sx: theme => ({
|
|
20
|
+
'& .MuiPaper-root': {
|
|
21
|
+
width: '100%'
|
|
22
|
+
},
|
|
23
|
+
'& .MuiChip-root .MuiChip-icon': {
|
|
24
|
+
color: theme.palette.success.main
|
|
25
|
+
},
|
|
26
|
+
'& .session-manager-menu-item': {
|
|
27
|
+
padding: '15px',
|
|
28
|
+
color: '#777',
|
|
29
|
+
fontSize: '16px',
|
|
30
|
+
'&:hover': {
|
|
31
|
+
backgroundColor: '#fbfbfb'
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
'& .session-manager-menu-icon': {
|
|
35
|
+
color: '#999',
|
|
36
|
+
marginRight: '8px'
|
|
37
|
+
}
|
|
38
|
+
}),
|
|
39
|
+
children: [/*#__PURE__*/_jsx(IconButton, {
|
|
40
|
+
sx: {
|
|
41
|
+
cursor: 'pointer',
|
|
42
|
+
position: 'absolute',
|
|
43
|
+
right: '8px',
|
|
44
|
+
top: '8px',
|
|
45
|
+
zIndex: 1
|
|
46
|
+
},
|
|
47
|
+
onClick: onClose,
|
|
48
|
+
children: /*#__PURE__*/_jsx(Icon, {
|
|
49
|
+
icon: CloseIcon,
|
|
50
|
+
width: 28,
|
|
51
|
+
height: 28
|
|
52
|
+
})
|
|
53
|
+
}), children]
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
UserDrawer.propTypes = {
|
|
57
|
+
children: PropTypes.any.isRequired,
|
|
58
|
+
open: PropTypes.bool.isRequired,
|
|
59
|
+
onOpen: PropTypes.func,
|
|
60
|
+
onClose: PropTypes.func
|
|
61
|
+
};
|
|
62
|
+
UserDrawer.defaultProps = {
|
|
63
|
+
onOpen: noop,
|
|
64
|
+
onClose: noop
|
|
65
|
+
};
|
|
@@ -5,13 +5,13 @@ import ShieldCheckIcon from '@iconify-icons/mdi/shield-check';
|
|
|
5
5
|
import ExpandMoreIcon from '@iconify-icons/mdi/expand-more';
|
|
6
6
|
import { Icon } from '@iconify/react';
|
|
7
7
|
import { useCreation, useMemoizedFn } from 'ahooks';
|
|
8
|
-
import DidAvatar from '
|
|
9
|
-
import DidAddress from '
|
|
10
|
-
import DID from '
|
|
11
|
-
import { getUserAvatar } from '
|
|
12
|
-
import { t as translate } from '
|
|
13
|
-
import { translations } from '
|
|
14
|
-
import Typography from '
|
|
8
|
+
import DidAvatar from '../../Avatar';
|
|
9
|
+
import DidAddress from '../../Address';
|
|
10
|
+
import DID from '../../DID';
|
|
11
|
+
import { getUserAvatar } from '../../Util';
|
|
12
|
+
import { t as translate } from '../../Locale/util';
|
|
13
|
+
import { translations } from '../libs/translation';
|
|
14
|
+
import Typography from '../../Typography';
|
|
15
15
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
16
16
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
17
|
export default function UserInfo({
|
|
@@ -2,7 +2,7 @@ import PropTypes from 'prop-types';
|
|
|
2
2
|
import { IconButton, Paper, Popper, ClickAwayListener } from '@mui/material';
|
|
3
3
|
import CloseIcon from '@iconify-icons/mdi/close';
|
|
4
4
|
import { Icon } from '@iconify/react';
|
|
5
|
-
import { styled } from '
|
|
5
|
+
import { styled } from '../../Theme';
|
|
6
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
7
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
8
8
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -30,6 +30,9 @@ export default function UserPopper({
|
|
|
30
30
|
maxHeight: 'calc(100vh - 80px)',
|
|
31
31
|
'& .MuiChip-root .MuiChip-icon': {
|
|
32
32
|
color: theme.palette.success.main
|
|
33
|
+
},
|
|
34
|
+
'& .MuiList-root': {
|
|
35
|
+
width: '320px'
|
|
33
36
|
}
|
|
34
37
|
}), dark && {
|
|
35
38
|
backgroundColor: '#27282c',
|
|
@@ -91,9 +94,7 @@ const StyledPopper = styled(Popper)`
|
|
|
91
94
|
}) => {
|
|
92
95
|
return theme.zIndex.tooltip;
|
|
93
96
|
}};
|
|
94
|
-
|
|
95
|
-
width: 320px;
|
|
96
|
-
}
|
|
97
|
+
|
|
97
98
|
.session-manager-menu-item {
|
|
98
99
|
padding: 15px;
|
|
99
100
|
color: #777;
|
|
@@ -9,15 +9,15 @@ import cloneDeep from 'lodash/cloneDeep';
|
|
|
9
9
|
import { useLatest, useMemoizedFn } from 'ahooks';
|
|
10
10
|
import DidAvatar from '../Avatar';
|
|
11
11
|
import { getUserAvatar, sleep } from '../Util';
|
|
12
|
-
import FederatedLoginDetecter from './federated-login-detecter';
|
|
13
|
-
import
|
|
14
|
-
import
|
|
12
|
+
import FederatedLoginDetecter from './components/federated-login-detecter';
|
|
13
|
+
import UserInfo from './components/user-info';
|
|
14
|
+
import ResponsivePopper from './components/responsive-popper';
|
|
15
15
|
import { translate } from '../Locale/util';
|
|
16
|
-
import ManageAccounts from './manage-accounts';
|
|
17
|
-
import ManageBlocklet from './manage-blocklet';
|
|
18
|
-
import { translations } from './translation';
|
|
19
|
-
import { getConnectedAccounts, getSourceProvider } from './utils';
|
|
20
|
-
import useConfig from './use-config';
|
|
16
|
+
import ManageAccounts from './components/manage-accounts';
|
|
17
|
+
import ManageBlocklet from './components/manage-blocklet';
|
|
18
|
+
import { translations } from './libs/translation';
|
|
19
|
+
import { getConnectedAccounts, getSourceProvider } from './libs/utils';
|
|
20
|
+
import useConfig from './hooks/use-config';
|
|
21
21
|
import { getCurrentApp, getFederatedApp } from '../Util/federated';
|
|
22
22
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
23
23
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -252,7 +252,7 @@ function SessionManager({
|
|
|
252
252
|
size: size,
|
|
253
253
|
shape: "circle"
|
|
254
254
|
})
|
|
255
|
-
}), /*#__PURE__*/_jsx(
|
|
255
|
+
}), /*#__PURE__*/_jsx(ResponsivePopper, {
|
|
256
256
|
open: userOpen,
|
|
257
257
|
onClose: onCloseUser,
|
|
258
258
|
anchorEl: userAnchorRef.current,
|
|
@@ -15,11 +15,11 @@ var _api = _interopRequireDefault(require("@iconify-icons/mdi/api"));
|
|
|
15
15
|
var _auth0Icon = _interopRequireDefault(require("@iconify-icons/logos/auth0-icon"));
|
|
16
16
|
var _trashCanOutline = _interopRequireDefault(require("@iconify-icons/mdi/trash-can-outline"));
|
|
17
17
|
var _ahooks = require("ahooks");
|
|
18
|
-
var _Avatar = _interopRequireDefault(require("
|
|
19
|
-
var _DID = _interopRequireDefault(require("
|
|
20
|
-
var _util = require("
|
|
21
|
-
var _translation = require("
|
|
22
|
-
var _federated = require("
|
|
18
|
+
var _Avatar = _interopRequireDefault(require("../../Avatar"));
|
|
19
|
+
var _DID = _interopRequireDefault(require("../../DID"));
|
|
20
|
+
var _util = require("../../Locale/util");
|
|
21
|
+
var _translation = require("../libs/translation");
|
|
22
|
+
var _federated = require("../../Util/federated");
|
|
23
23
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
24
24
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
25
25
|
function AccountItem(_ref) {
|
|
@@ -9,9 +9,9 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
9
9
|
var _material = require("@mui/material");
|
|
10
10
|
var _iosAddCircleOutline = _interopRequireDefault(require("@iconify-icons/ion/ios-add-circle-outline"));
|
|
11
11
|
var _ahooks = require("ahooks");
|
|
12
|
-
var _util = require("
|
|
13
|
-
var _translation = require("
|
|
14
|
-
var _federated = require("
|
|
12
|
+
var _util = require("../../Locale/util");
|
|
13
|
+
var _translation = require("../libs/translation");
|
|
14
|
+
var _federated = require("../../Util/federated");
|
|
15
15
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
17
|
function AddAccountItem(_ref) {
|
package/lib/SessionManager/{federated-login-detecter.js → components/federated-login-detecter.js}
RENAMED
|
@@ -13,11 +13,11 @@ var _shieldCheck = _interopRequireDefault(require("@iconify-icons/mdi/shield-che
|
|
|
13
13
|
var _react2 = require("@iconify/react");
|
|
14
14
|
var _ahooks = require("ahooks");
|
|
15
15
|
var _userPopper = _interopRequireDefault(require("./user-popper"));
|
|
16
|
-
var _Avatar = _interopRequireDefault(require("
|
|
17
|
-
var _Address = _interopRequireDefault(require("
|
|
18
|
-
var _Button = _interopRequireDefault(require("
|
|
19
|
-
var _Toast = _interopRequireDefault(require("
|
|
20
|
-
var _Util = require("
|
|
16
|
+
var _Avatar = _interopRequireDefault(require("../../Avatar"));
|
|
17
|
+
var _Address = _interopRequireDefault(require("../../Address"));
|
|
18
|
+
var _Button = _interopRequireDefault(require("../../Button"));
|
|
19
|
+
var _Toast = _interopRequireDefault(require("../../Toast"));
|
|
20
|
+
var _Util = require("../../Util");
|
|
21
21
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
22
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
23
|
const translations = {
|
|
@@ -14,10 +14,10 @@ var _Disconnect = _interopRequireDefault(require("@arcblock/icons/lib/Disconnect
|
|
|
14
14
|
var _noop = _interopRequireDefault(require("lodash/noop"));
|
|
15
15
|
var _accountItem = _interopRequireDefault(require("./account-item"));
|
|
16
16
|
var _menuAccordion = _interopRequireDefault(require("./menu-accordion"));
|
|
17
|
-
var _translation = require("
|
|
18
|
-
var _util = require("
|
|
19
|
-
var _confirm = require("
|
|
20
|
-
var _utils = require("
|
|
17
|
+
var _translation = require("../libs/translation");
|
|
18
|
+
var _util = require("../../Locale/util");
|
|
19
|
+
var _confirm = require("../../Dialog/confirm");
|
|
20
|
+
var _utils = require("../libs/utils");
|
|
21
21
|
var _addAccountItem = _interopRequireDefault(require("./add-account-item"));
|
|
22
22
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
23
23
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -40,7 +40,8 @@ function ManageAccounts(_ref) {
|
|
|
40
40
|
expanded,
|
|
41
41
|
onExpand,
|
|
42
42
|
accounts,
|
|
43
|
-
deleteAccount
|
|
43
|
+
deleteAccount,
|
|
44
|
+
hideLogout
|
|
44
45
|
} = _ref;
|
|
45
46
|
const {
|
|
46
47
|
bindOAuth,
|
|
@@ -180,7 +181,7 @@ function ManageAccounts(_ref) {
|
|
|
180
181
|
height: 24,
|
|
181
182
|
className: "session-manager-menu-icon"
|
|
182
183
|
}), !isRawWalletAccount ? "".concat(t('bind'), "DID Wallet") : "".concat(t('bind')).concat(t('thirdParty'))]
|
|
183
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.MenuItem, {
|
|
184
|
+
}), !hideLogout ? /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.MenuItem, {
|
|
184
185
|
className: "session-manager-menu-item",
|
|
185
186
|
onClick: _onLogout,
|
|
186
187
|
disabled: disableLogout,
|
|
@@ -201,7 +202,7 @@ function ManageAccounts(_ref) {
|
|
|
201
202
|
component: _Disconnect.default,
|
|
202
203
|
className: "session-manager-menu-icon"
|
|
203
204
|
}), t('disconnect')]
|
|
204
|
-
})]
|
|
205
|
+
}) : null]
|
|
205
206
|
}), confirmHolder]
|
|
206
207
|
});
|
|
207
208
|
}
|
|
@@ -218,12 +219,14 @@ ManageAccounts.propTypes = {
|
|
|
218
219
|
expanded: _propTypes.default.bool,
|
|
219
220
|
onExpand: _propTypes.default.func,
|
|
220
221
|
accounts: _propTypes.default.array.isRequired,
|
|
221
|
-
deleteAccount: _propTypes.default.func.isRequired
|
|
222
|
+
deleteAccount: _propTypes.default.func.isRequired,
|
|
223
|
+
hideLogout: _propTypes.default.bool
|
|
222
224
|
};
|
|
223
225
|
ManageAccounts.defaultProps = {
|
|
224
226
|
locale: 'en',
|
|
225
227
|
hasBindAccount: false,
|
|
226
228
|
disableLogout: false,
|
|
227
229
|
expanded: true,
|
|
228
|
-
onExpand: _noop.default
|
|
230
|
+
onExpand: _noop.default,
|
|
231
|
+
hideLogout: false
|
|
229
232
|
};
|
|
@@ -10,8 +10,8 @@ var _react = require("@iconify/react");
|
|
|
10
10
|
var _apps = _interopRequireDefault(require("@iconify-icons/mdi/apps"));
|
|
11
11
|
var _material = require("@mui/material");
|
|
12
12
|
var _menuAccordion = _interopRequireDefault(require("./menu-accordion"));
|
|
13
|
-
var _util = require("
|
|
14
|
-
var _translation = require("
|
|
13
|
+
var _util = require("../../Locale/util");
|
|
14
|
+
var _translation = require("../libs/translation");
|
|
15
15
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
16
|
const _excluded = ["svgIcon"];
|
|
17
17
|
/* eslint-disable react/no-array-index-key */
|
|
@@ -11,8 +11,8 @@ var _react = require("@iconify/react");
|
|
|
11
11
|
var _isEmpty = _interopRequireDefault(require("lodash/isEmpty"));
|
|
12
12
|
var _isNil = _interopRequireDefault(require("lodash/isNil"));
|
|
13
13
|
var _ahooks = require("ahooks");
|
|
14
|
-
var _util = require("
|
|
15
|
-
var _translation = require("
|
|
14
|
+
var _util = require("../../Locale/util");
|
|
15
|
+
var _translation = require("../libs/translation");
|
|
16
16
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
17
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
18
18
|
function isEmptyNode(node) {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = ResponsivePopper;
|
|
7
|
+
var _ahooks = require("ahooks");
|
|
8
|
+
var _userPopper = _interopRequireDefault(require("./user-popper"));
|
|
9
|
+
var _userDrawer = _interopRequireDefault(require("./user-drawer"));
|
|
10
|
+
var _Theme = require("../../Theme");
|
|
11
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
13
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
14
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
15
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
16
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
|
|
17
|
+
function _toPrimitive(input, hint) { if (typeof input !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (typeof res !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
18
|
+
function ResponsivePopper(props) {
|
|
19
|
+
const theme = (0, _Theme.useTheme)();
|
|
20
|
+
const size = (0, _ahooks.useSize)(document.body);
|
|
21
|
+
const isMobile = (0, _ahooks.useCreation)(() => {
|
|
22
|
+
if ((size === null || size === void 0 ? void 0 : size.width) <= theme.breakpoints.values.sm) {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
return false;
|
|
26
|
+
}, [theme, size]);
|
|
27
|
+
const WrapContainer = (0, _ahooks.useCreation)(() => {
|
|
28
|
+
if (isMobile) {
|
|
29
|
+
return _userDrawer.default;
|
|
30
|
+
}
|
|
31
|
+
return _userPopper.default;
|
|
32
|
+
}, [isMobile]);
|
|
33
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(WrapContainer, _objectSpread({}, props));
|
|
34
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = UserDrawer;
|
|
7
|
+
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
8
|
+
var _material = require("@mui/material");
|
|
9
|
+
var _close = _interopRequireDefault(require("@iconify-icons/mdi/close"));
|
|
10
|
+
var _react = require("@iconify/react");
|
|
11
|
+
var _noop = _interopRequireDefault(require("lodash/noop"));
|
|
12
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
14
|
+
function UserDrawer(_ref) {
|
|
15
|
+
let {
|
|
16
|
+
children,
|
|
17
|
+
open,
|
|
18
|
+
onOpen,
|
|
19
|
+
onClose
|
|
20
|
+
} = _ref;
|
|
21
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_material.Drawer, {
|
|
22
|
+
anchor: "right",
|
|
23
|
+
open: open,
|
|
24
|
+
onClose: onClose,
|
|
25
|
+
onOpen: onOpen,
|
|
26
|
+
sx: theme => ({
|
|
27
|
+
'& .MuiPaper-root': {
|
|
28
|
+
width: '100%'
|
|
29
|
+
},
|
|
30
|
+
'& .MuiChip-root .MuiChip-icon': {
|
|
31
|
+
color: theme.palette.success.main
|
|
32
|
+
},
|
|
33
|
+
'& .session-manager-menu-item': {
|
|
34
|
+
padding: '15px',
|
|
35
|
+
color: '#777',
|
|
36
|
+
fontSize: '16px',
|
|
37
|
+
'&:hover': {
|
|
38
|
+
backgroundColor: '#fbfbfb'
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
'& .session-manager-menu-icon': {
|
|
42
|
+
color: '#999',
|
|
43
|
+
marginRight: '8px'
|
|
44
|
+
}
|
|
45
|
+
}),
|
|
46
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.IconButton, {
|
|
47
|
+
sx: {
|
|
48
|
+
cursor: 'pointer',
|
|
49
|
+
position: 'absolute',
|
|
50
|
+
right: '8px',
|
|
51
|
+
top: '8px',
|
|
52
|
+
zIndex: 1
|
|
53
|
+
},
|
|
54
|
+
onClick: onClose,
|
|
55
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.Icon, {
|
|
56
|
+
icon: _close.default,
|
|
57
|
+
width: 28,
|
|
58
|
+
height: 28
|
|
59
|
+
})
|
|
60
|
+
}), children]
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
UserDrawer.propTypes = {
|
|
64
|
+
children: _propTypes.default.any.isRequired,
|
|
65
|
+
open: _propTypes.default.bool.isRequired,
|
|
66
|
+
onOpen: _propTypes.default.func,
|
|
67
|
+
onClose: _propTypes.default.func
|
|
68
|
+
};
|
|
69
|
+
UserDrawer.defaultProps = {
|
|
70
|
+
onOpen: _noop.default,
|
|
71
|
+
onClose: _noop.default
|
|
72
|
+
};
|
|
@@ -9,13 +9,13 @@ var _shieldCheck = _interopRequireDefault(require("@iconify-icons/mdi/shield-che
|
|
|
9
9
|
var _expandMore = _interopRequireDefault(require("@iconify-icons/mdi/expand-more"));
|
|
10
10
|
var _react = require("@iconify/react");
|
|
11
11
|
var _ahooks = require("ahooks");
|
|
12
|
-
var _Avatar = _interopRequireDefault(require("
|
|
13
|
-
var _Address = _interopRequireDefault(require("
|
|
14
|
-
var _DID = _interopRequireDefault(require("
|
|
15
|
-
var _Util = require("
|
|
16
|
-
var _util = require("
|
|
17
|
-
var _translation = require("
|
|
18
|
-
var _Typography = _interopRequireDefault(require("
|
|
12
|
+
var _Avatar = _interopRequireDefault(require("../../Avatar"));
|
|
13
|
+
var _Address = _interopRequireDefault(require("../../Address"));
|
|
14
|
+
var _DID = _interopRequireDefault(require("../../DID"));
|
|
15
|
+
var _Util = require("../../Util");
|
|
16
|
+
var _util = require("../../Locale/util");
|
|
17
|
+
var _translation = require("../libs/translation");
|
|
18
|
+
var _Typography = _interopRequireDefault(require("../../Typography"));
|
|
19
19
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
20
20
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
21
21
|
/* eslint-disable react/jsx-no-bind */
|
|
@@ -8,7 +8,7 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
|
8
8
|
var _material = require("@mui/material");
|
|
9
9
|
var _close = _interopRequireDefault(require("@iconify-icons/mdi/close"));
|
|
10
10
|
var _react = require("@iconify/react");
|
|
11
|
-
var _Theme = require("
|
|
11
|
+
var _Theme = require("../../Theme");
|
|
12
12
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
13
|
var _templateObject;
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
@@ -38,6 +38,9 @@ function UserPopper(_ref) {
|
|
|
38
38
|
maxHeight: 'calc(100vh - 80px)',
|
|
39
39
|
'& .MuiChip-root .MuiChip-icon': {
|
|
40
40
|
color: theme.palette.success.main
|
|
41
|
+
},
|
|
42
|
+
'& .MuiList-root': {
|
|
43
|
+
width: '320px'
|
|
41
44
|
}
|
|
42
45
|
}), dark && {
|
|
43
46
|
backgroundColor: '#27282c',
|
|
@@ -93,7 +96,7 @@ UserPopper.defaultProps = {
|
|
|
93
96
|
onClose: () => {},
|
|
94
97
|
autoClose: true
|
|
95
98
|
};
|
|
96
|
-
const StyledPopper = (0, _Theme.styled)(_material.Popper)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n z-index: ", ";\n
|
|
99
|
+
const StyledPopper = (0, _Theme.styled)(_material.Popper)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n z-index: ", ";\n\n .session-manager-menu-item {\n padding: 15px;\n color: #777;\n font-size: 16px;\n &:hover {\n background-color: #fbfbfb;\n }\n }\n .session-manager-menu-icon {\n color: #999;\n margin-right: 8px;\n }\n"])), _ref2 => {
|
|
97
100
|
let {
|
|
98
101
|
theme
|
|
99
102
|
} = _ref2;
|
|
@@ -13,15 +13,15 @@ var _cloneDeep = _interopRequireDefault(require("lodash/cloneDeep"));
|
|
|
13
13
|
var _ahooks = require("ahooks");
|
|
14
14
|
var _Avatar = _interopRequireDefault(require("../Avatar"));
|
|
15
15
|
var _Util = require("../Util");
|
|
16
|
-
var _federatedLoginDetecter = _interopRequireDefault(require("./federated-login-detecter"));
|
|
17
|
-
var
|
|
18
|
-
var
|
|
16
|
+
var _federatedLoginDetecter = _interopRequireDefault(require("./components/federated-login-detecter"));
|
|
17
|
+
var _userInfo = _interopRequireDefault(require("./components/user-info"));
|
|
18
|
+
var _responsivePopper = _interopRequireDefault(require("./components/responsive-popper"));
|
|
19
19
|
var _util = require("../Locale/util");
|
|
20
|
-
var _manageAccounts = _interopRequireDefault(require("./manage-accounts"));
|
|
21
|
-
var _manageBlocklet = _interopRequireDefault(require("./manage-blocklet"));
|
|
22
|
-
var _translation = require("./translation");
|
|
23
|
-
var _utils = require("./utils");
|
|
24
|
-
var _useConfig = _interopRequireDefault(require("./use-config"));
|
|
20
|
+
var _manageAccounts = _interopRequireDefault(require("./components/manage-accounts"));
|
|
21
|
+
var _manageBlocklet = _interopRequireDefault(require("./components/manage-blocklet"));
|
|
22
|
+
var _translation = require("./libs/translation");
|
|
23
|
+
var _utils = require("./libs/utils");
|
|
24
|
+
var _useConfig = _interopRequireDefault(require("./hooks/use-config"));
|
|
25
25
|
var _federated = require("../Util/federated");
|
|
26
26
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
27
27
|
const _excluded = ["session", "locale", "showText", "showRole", "switchDid", "switchProfile", "switchPassport", "disableLogout", "onLogin", "onLogout", "onSwitchDid", "onSwitchProfile", "onSwitchPassport", "onBindWallet", "menu", "menuRender", "dark", "size", "showManageBlocklet"];
|
|
@@ -268,7 +268,7 @@ function SessionManager(_ref) {
|
|
|
268
268
|
size: size,
|
|
269
269
|
shape: "circle"
|
|
270
270
|
})
|
|
271
|
-
})), /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
271
|
+
})), /*#__PURE__*/(0, _jsxRuntime.jsx)(_responsivePopper.default, {
|
|
272
272
|
open: userOpen,
|
|
273
273
|
onClose: onCloseUser,
|
|
274
274
|
anchorEl: userAnchorRef.current,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arcblock/ux",
|
|
3
|
-
"version": "2.8.
|
|
3
|
+
"version": "2.8.17",
|
|
4
4
|
"description": "Common used react components for arcblock products",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -322,11 +322,11 @@
|
|
|
322
322
|
"peerDependencies": {
|
|
323
323
|
"react": ">=18.1.0"
|
|
324
324
|
},
|
|
325
|
-
"gitHead": "
|
|
325
|
+
"gitHead": "bd7a8f9d5bfbd61bcb0f6ff57de4600d8afded7b",
|
|
326
326
|
"dependencies": {
|
|
327
327
|
"@arcblock/did-motif": "^1.1.13",
|
|
328
|
-
"@arcblock/icons": "^2.8.
|
|
329
|
-
"@arcblock/react-hooks": "^2.8.
|
|
328
|
+
"@arcblock/icons": "^2.8.17",
|
|
329
|
+
"@arcblock/react-hooks": "^2.8.17",
|
|
330
330
|
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
|
|
331
331
|
"@emotion/react": "^11.10.4",
|
|
332
332
|
"@emotion/styled": "^11.10.4",
|
|
@@ -10,11 +10,11 @@ import Auth0Icon from '@iconify-icons/logos/auth0-icon';
|
|
|
10
10
|
import TrashCanOutlineIcon from '@iconify-icons/mdi/trash-can-outline';
|
|
11
11
|
import { useCreation, useMemoizedFn } from 'ahooks';
|
|
12
12
|
|
|
13
|
-
import Avatar from '
|
|
14
|
-
import DID from '
|
|
15
|
-
import { translate } from '
|
|
16
|
-
import { translations } from '
|
|
17
|
-
import { getFederatedEnabled } from '
|
|
13
|
+
import Avatar from '../../Avatar';
|
|
14
|
+
import DID from '../../DID';
|
|
15
|
+
import { translate } from '../../Locale/util';
|
|
16
|
+
import { translations } from '../libs/translation';
|
|
17
|
+
import { getFederatedEnabled } from '../../Util/federated';
|
|
18
18
|
|
|
19
19
|
export default function AccountItem({ account, active, onDelete, onChoose, locale }) {
|
|
20
20
|
const t = useMemoizedFn((key, data = {}) => {
|
|
@@ -3,9 +3,9 @@ import PropTypes from 'prop-types';
|
|
|
3
3
|
import { MenuItem, Typography } from '@mui/material';
|
|
4
4
|
import AddIcon from '@iconify-icons/ion/ios-add-circle-outline';
|
|
5
5
|
import { useCreation, useMemoizedFn } from 'ahooks';
|
|
6
|
-
import { translate } from '
|
|
7
|
-
import { translations } from '
|
|
8
|
-
import { getApps } from '
|
|
6
|
+
import { translate } from '../../Locale/util';
|
|
7
|
+
import { translations } from '../libs/translation';
|
|
8
|
+
import { getApps } from '../../Util/federated';
|
|
9
9
|
|
|
10
10
|
export default function AddAccountItem({ onAdd, locale, session }) {
|
|
11
11
|
const t = useMemoizedFn((key, data = {}) => {
|
package/src/SessionManager/{federated-login-detecter.jsx → components/federated-login-detecter.jsx}
RENAMED
|
@@ -8,11 +8,11 @@ import { Icon } from '@iconify/react';
|
|
|
8
8
|
import { useCreation, useReactive } from 'ahooks';
|
|
9
9
|
|
|
10
10
|
import UserPopper from './user-popper';
|
|
11
|
-
import DidAvatar from '
|
|
12
|
-
import DidAddress from '
|
|
13
|
-
import Button from '
|
|
14
|
-
import Toast from '
|
|
15
|
-
import { getUserAvatar } from '
|
|
11
|
+
import DidAvatar from '../../Avatar';
|
|
12
|
+
import DidAddress from '../../Address';
|
|
13
|
+
import Button from '../../Button';
|
|
14
|
+
import Toast from '../../Toast';
|
|
15
|
+
import { getUserAvatar } from '../../Util';
|
|
16
16
|
|
|
17
17
|
const translations = {
|
|
18
18
|
en: {
|
|
@@ -10,10 +10,10 @@ import noop from 'lodash/noop';
|
|
|
10
10
|
|
|
11
11
|
import AccountItem from './account-item';
|
|
12
12
|
import MenuAccordion from './menu-accordion';
|
|
13
|
-
import { translations } from '
|
|
14
|
-
import { translate } from '
|
|
15
|
-
import { useConfirm } from '
|
|
16
|
-
import { getSourceProvider } from '
|
|
13
|
+
import { translations } from '../libs/translation';
|
|
14
|
+
import { translate } from '../../Locale/util';
|
|
15
|
+
import { useConfirm } from '../../Dialog/confirm';
|
|
16
|
+
import { getSourceProvider } from '../libs/utils';
|
|
17
17
|
import AddAccountItem from './add-account-item';
|
|
18
18
|
|
|
19
19
|
export default function ManageAccounts({
|
|
@@ -30,6 +30,7 @@ export default function ManageAccounts({
|
|
|
30
30
|
onExpand,
|
|
31
31
|
accounts,
|
|
32
32
|
deleteAccount,
|
|
33
|
+
hideLogout,
|
|
33
34
|
}) {
|
|
34
35
|
const { bindOAuth, configs: oauthConfigs } = session.useOAuth();
|
|
35
36
|
const t = useMemoizedFn((key, data = {}) => {
|
|
@@ -169,29 +170,31 @@ export default function ManageAccounts({
|
|
|
169
170
|
</MenuItem>
|
|
170
171
|
)}
|
|
171
172
|
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
173
|
+
{!hideLogout ? (
|
|
174
|
+
<MenuItem
|
|
175
|
+
className="session-manager-menu-item"
|
|
176
|
+
onClick={_onLogout}
|
|
177
|
+
disabled={disableLogout}
|
|
178
|
+
aria-label="Logout account"
|
|
179
|
+
sx={{
|
|
180
|
+
position: 'relative',
|
|
181
|
+
}}
|
|
182
|
+
data-cy="sessionManager-logout-trigger">
|
|
183
|
+
{pageState.logoutLoading ? (
|
|
184
|
+
<LinearProgress
|
|
185
|
+
sx={{
|
|
186
|
+
height: '2px',
|
|
187
|
+
position: 'absolute',
|
|
188
|
+
top: 0,
|
|
189
|
+
left: 0,
|
|
190
|
+
right: 0,
|
|
191
|
+
}}
|
|
192
|
+
/>
|
|
193
|
+
) : null}
|
|
194
|
+
<SvgIcon component={DisconnectIcon} className="session-manager-menu-icon" />
|
|
195
|
+
{t('disconnect')}
|
|
196
|
+
</MenuItem>
|
|
197
|
+
) : null}
|
|
195
198
|
</MenuAccordion>
|
|
196
199
|
{confirmHolder}
|
|
197
200
|
</>
|
|
@@ -212,6 +215,7 @@ ManageAccounts.propTypes = {
|
|
|
212
215
|
onExpand: PropTypes.func,
|
|
213
216
|
accounts: PropTypes.array.isRequired,
|
|
214
217
|
deleteAccount: PropTypes.func.isRequired,
|
|
218
|
+
hideLogout: PropTypes.bool,
|
|
215
219
|
};
|
|
216
220
|
|
|
217
221
|
ManageAccounts.defaultProps = {
|
|
@@ -220,4 +224,5 @@ ManageAccounts.defaultProps = {
|
|
|
220
224
|
disableLogout: false,
|
|
221
225
|
expanded: true,
|
|
222
226
|
onExpand: noop,
|
|
227
|
+
hideLogout: false,
|
|
223
228
|
};
|
|
@@ -6,8 +6,8 @@ import AppsIcon from '@iconify-icons/mdi/apps';
|
|
|
6
6
|
import { MenuItem, SvgIcon } from '@mui/material';
|
|
7
7
|
|
|
8
8
|
import MenuAccordion from './menu-accordion';
|
|
9
|
-
import { translate } from '
|
|
10
|
-
import { translations } from '
|
|
9
|
+
import { translate } from '../../Locale/util';
|
|
10
|
+
import { translations } from '../libs/translation';
|
|
11
11
|
|
|
12
12
|
export default function ManageBlocklet({ menu, menuRender, locale, expanded, onExpand }) {
|
|
13
13
|
const t = useMemoizedFn((key, data = {}) => {
|
|
@@ -5,8 +5,8 @@ import { Icon } from '@iconify/react';
|
|
|
5
5
|
import isEmpty from 'lodash/isEmpty';
|
|
6
6
|
import isNil from 'lodash/isNil';
|
|
7
7
|
import { useCreation, useMemoizedFn } from 'ahooks';
|
|
8
|
-
import { translate } from '
|
|
9
|
-
import { translations } from '
|
|
8
|
+
import { translate } from '../../Locale/util';
|
|
9
|
+
import { translations } from '../libs/translation';
|
|
10
10
|
|
|
11
11
|
function isEmptyNode(node) {
|
|
12
12
|
if (isNil(node)) {
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useCreation, useSize } from 'ahooks';
|
|
2
|
+
|
|
3
|
+
import UserPopper from './user-popper';
|
|
4
|
+
import UserDrawer from './user-drawer';
|
|
5
|
+
import { useTheme } from '../../Theme';
|
|
6
|
+
|
|
7
|
+
export default function ResponsivePopper(props) {
|
|
8
|
+
const theme = useTheme();
|
|
9
|
+
const size = useSize(document.body);
|
|
10
|
+
const isMobile = useCreation(() => {
|
|
11
|
+
if (size?.width <= theme.breakpoints.values.sm) {
|
|
12
|
+
return true;
|
|
13
|
+
}
|
|
14
|
+
return false;
|
|
15
|
+
}, [theme, size]);
|
|
16
|
+
|
|
17
|
+
const WrapContainer = useCreation(() => {
|
|
18
|
+
if (isMobile) {
|
|
19
|
+
return UserDrawer;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return UserPopper;
|
|
23
|
+
}, [isMobile]);
|
|
24
|
+
|
|
25
|
+
return <WrapContainer {...props} />;
|
|
26
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
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
|
+
|
|
7
|
+
export default function UserDrawer({ children, open, onOpen, onClose }) {
|
|
8
|
+
return (
|
|
9
|
+
<Drawer
|
|
10
|
+
anchor="right"
|
|
11
|
+
open={open}
|
|
12
|
+
onClose={onClose}
|
|
13
|
+
onOpen={onOpen}
|
|
14
|
+
sx={(theme) => ({
|
|
15
|
+
'& .MuiPaper-root': {
|
|
16
|
+
width: '100%',
|
|
17
|
+
},
|
|
18
|
+
'& .MuiChip-root .MuiChip-icon': {
|
|
19
|
+
color: theme.palette.success.main,
|
|
20
|
+
},
|
|
21
|
+
'& .session-manager-menu-item': {
|
|
22
|
+
padding: '15px',
|
|
23
|
+
color: '#777',
|
|
24
|
+
fontSize: '16px',
|
|
25
|
+
'&:hover': {
|
|
26
|
+
backgroundColor: '#fbfbfb',
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
'& .session-manager-menu-icon': {
|
|
30
|
+
color: '#999',
|
|
31
|
+
marginRight: '8px',
|
|
32
|
+
},
|
|
33
|
+
})}>
|
|
34
|
+
<IconButton
|
|
35
|
+
sx={{ cursor: 'pointer', position: 'absolute', right: '8px', top: '8px', zIndex: 1 }}
|
|
36
|
+
onClick={onClose}>
|
|
37
|
+
<Icon icon={CloseIcon} width={28} height={28} />
|
|
38
|
+
</IconButton>
|
|
39
|
+
{children}
|
|
40
|
+
</Drawer>
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
UserDrawer.propTypes = {
|
|
45
|
+
children: PropTypes.any.isRequired,
|
|
46
|
+
open: PropTypes.bool.isRequired,
|
|
47
|
+
onOpen: PropTypes.func,
|
|
48
|
+
onClose: PropTypes.func,
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
UserDrawer.defaultProps = {
|
|
52
|
+
onOpen: noop,
|
|
53
|
+
onClose: noop,
|
|
54
|
+
};
|
|
@@ -6,13 +6,13 @@ import ExpandMoreIcon from '@iconify-icons/mdi/expand-more';
|
|
|
6
6
|
import { Icon } from '@iconify/react';
|
|
7
7
|
import { useCreation, useMemoizedFn } from 'ahooks';
|
|
8
8
|
|
|
9
|
-
import DidAvatar from '
|
|
10
|
-
import DidAddress from '
|
|
11
|
-
import DID from '
|
|
12
|
-
import { getUserAvatar } from '
|
|
13
|
-
import { t as translate } from '
|
|
14
|
-
import { translations } from '
|
|
15
|
-
import Typography from '
|
|
9
|
+
import DidAvatar from '../../Avatar';
|
|
10
|
+
import DidAddress from '../../Address';
|
|
11
|
+
import DID from '../../DID';
|
|
12
|
+
import { getUserAvatar } from '../../Util';
|
|
13
|
+
import { t as translate } from '../../Locale/util';
|
|
14
|
+
import { translations } from '../libs/translation';
|
|
15
|
+
import Typography from '../../Typography';
|
|
16
16
|
|
|
17
17
|
export default function UserInfo({ session, locale, onSwitchProfile, onSwitchPassport, switchProfile, hasBindWallet }) {
|
|
18
18
|
const t = (key, data = {}) => {
|
|
@@ -2,7 +2,7 @@ import PropTypes from 'prop-types';
|
|
|
2
2
|
import { IconButton, Paper, Popper, ClickAwayListener } from '@mui/material';
|
|
3
3
|
import CloseIcon from '@iconify-icons/mdi/close';
|
|
4
4
|
import { Icon } from '@iconify/react';
|
|
5
|
-
import { styled } from '
|
|
5
|
+
import { styled } from '../../Theme';
|
|
6
6
|
|
|
7
7
|
export default function UserPopper({ anchorEl, dark, children, open, onClose, autoClose }) {
|
|
8
8
|
return (
|
|
@@ -20,6 +20,9 @@ export default function UserPopper({ anchorEl, dark, children, open, onClose, au
|
|
|
20
20
|
'& .MuiChip-root .MuiChip-icon': {
|
|
21
21
|
color: theme.palette.success.main,
|
|
22
22
|
},
|
|
23
|
+
'& .MuiList-root': {
|
|
24
|
+
width: '320px',
|
|
25
|
+
},
|
|
23
26
|
}),
|
|
24
27
|
dark && {
|
|
25
28
|
backgroundColor: '#27282c',
|
|
@@ -76,9 +79,7 @@ const StyledPopper = styled(Popper)`
|
|
|
76
79
|
z-index: ${({ theme }) => {
|
|
77
80
|
return theme.zIndex.tooltip;
|
|
78
81
|
}};
|
|
79
|
-
|
|
80
|
-
width: 320px;
|
|
81
|
-
}
|
|
82
|
+
|
|
82
83
|
.session-manager-menu-item {
|
|
83
84
|
padding: 15px;
|
|
84
85
|
color: #777;
|
|
@@ -10,15 +10,15 @@ import { useLatest, useMemoizedFn } from 'ahooks';
|
|
|
10
10
|
|
|
11
11
|
import DidAvatar from '../Avatar';
|
|
12
12
|
import { getUserAvatar, sleep } from '../Util';
|
|
13
|
-
import FederatedLoginDetecter from './federated-login-detecter';
|
|
14
|
-
import
|
|
15
|
-
import
|
|
13
|
+
import FederatedLoginDetecter from './components/federated-login-detecter';
|
|
14
|
+
import UserInfo from './components/user-info';
|
|
15
|
+
import ResponsivePopper from './components/responsive-popper';
|
|
16
16
|
import { translate } from '../Locale/util';
|
|
17
|
-
import ManageAccounts from './manage-accounts';
|
|
18
|
-
import ManageBlocklet from './manage-blocklet';
|
|
19
|
-
import { translations } from './translation';
|
|
20
|
-
import { getConnectedAccounts, getSourceProvider } from './utils';
|
|
21
|
-
import useConfig from './use-config';
|
|
17
|
+
import ManageAccounts from './components/manage-accounts';
|
|
18
|
+
import ManageBlocklet from './components/manage-blocklet';
|
|
19
|
+
import { translations } from './libs/translation';
|
|
20
|
+
import { getConnectedAccounts, getSourceProvider } from './libs/utils';
|
|
21
|
+
import useConfig from './hooks/use-config';
|
|
22
22
|
import { getCurrentApp, getFederatedApp } from '../Util/federated';
|
|
23
23
|
|
|
24
24
|
function SessionManager({
|
|
@@ -226,7 +226,7 @@ function SessionManager({
|
|
|
226
226
|
<DidAvatar variant="circle" did={session.user.did} src={avatar} size={size} shape="circle" />
|
|
227
227
|
</IconButton>
|
|
228
228
|
|
|
229
|
-
<
|
|
229
|
+
<ResponsivePopper open={userOpen} onClose={onCloseUser} anchorEl={userAnchorRef.current} dark={dark}>
|
|
230
230
|
<MenuList sx={{ p: 0 }}>
|
|
231
231
|
<UserInfo
|
|
232
232
|
session={session}
|
|
@@ -286,7 +286,7 @@ function SessionManager({
|
|
|
286
286
|
]
|
|
287
287
|
: null}
|
|
288
288
|
</MenuList>
|
|
289
|
-
</
|
|
289
|
+
</ResponsivePopper>
|
|
290
290
|
</>
|
|
291
291
|
);
|
|
292
292
|
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|