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