@arcblock/ux 2.8.25 → 2.9.0

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