@arcblock/ux 2.7.21 → 2.7.22

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.
@@ -48,7 +48,8 @@ function SessionManager({
48
48
  const {
49
49
  connectAccount,
50
50
  config,
51
- setConfig
51
+ setConfig,
52
+ deleteAccount
52
53
  } = useConfig();
53
54
  const t = useMemoizedFn((key, data = {}) => {
54
55
  return translate(translations, key, locale, 'en', data);
@@ -286,7 +287,9 @@ function SessionManager({
286
287
  const cloneConfig = cloneDeep(config);
287
288
  cloneConfig.expandAccount = value;
288
289
  setConfig(cloneConfig);
289
- }
290
+ },
291
+ deleteAccount: deleteAccount,
292
+ accounts: config.accounts
290
293
  }), showManageBlocklet ? [/*#__PURE__*/_jsx(Divider, {}, "divider"), /*#__PURE__*/_jsx(ManageBlocklet, {
291
294
  menu: menu,
292
295
  menuRender: menuRender,
@@ -1,11 +1,12 @@
1
- /* eslint-disable react/prop-types */
2
1
  /* eslint-disable react/jsx-no-bind */
2
+ import PropTypes from 'prop-types';
3
3
  import { useMemoizedFn, useUpdate } from 'ahooks';
4
4
  import { MenuItem, SvgIcon } from '@mui/material';
5
5
  import { Icon } from '@iconify/react';
6
6
  import AccountIcon from '@arcblock/icons/lib/Account';
7
7
  import LinkIcon from '@iconify-icons/mdi/link';
8
8
  import DisconnectIcon from '@arcblock/icons/lib/Disconnect';
9
+ import noop from 'lodash/noop';
9
10
  import AccountItem from './account-item';
10
11
  import MenuAccordion from './menu-accordion';
11
12
  import { translations } from './translation';
@@ -13,7 +14,6 @@ import { translate } from '../Locale/util';
13
14
  import { useConfirm } from '../Dialog/confirm';
14
15
  import { getSourceProvider } from './utils';
15
16
  import AddAccountItem from './add-account-item';
16
- import useConfig from './use-config';
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";
@@ -28,7 +28,9 @@ export default function ManageAccounts({
28
28
  disableLogout,
29
29
  onLogout,
30
30
  expanded,
31
- onExpand
31
+ onExpand,
32
+ accounts,
33
+ deleteAccount
32
34
  }) {
33
35
  const {
34
36
  bindOAuth,
@@ -41,10 +43,6 @@ export default function ManageAccounts({
41
43
  confirmApi,
42
44
  confirmHolder
43
45
  } = useConfirm();
44
- const {
45
- deleteAccount,
46
- config
47
- } = useConfig();
48
46
  const update = useUpdate();
49
47
  const onChoose = useMemoizedFn((account, {
50
48
  active
@@ -137,7 +135,7 @@ export default function ManageAccounts({
137
135
  }
138
136
  }), t('accounts')]
139
137
  }),
140
- children: [config.accounts.map(item => /*#__PURE__*/_jsx(AccountItem, {
138
+ children: [accounts.map(item => /*#__PURE__*/_jsx(AccountItem, {
141
139
  account: item,
142
140
  locale: locale,
143
141
  active: session.user.did === item.did,
@@ -170,4 +168,26 @@ export default function ManageAccounts({
170
168
  })]
171
169
  }), confirmHolder]
172
170
  });
173
- }
171
+ }
172
+ ManageAccounts.propTypes = {
173
+ session: PropTypes.object.isRequired,
174
+ locale: PropTypes.string,
175
+ onBindWallet: PropTypes.func.isRequired,
176
+ onSwitchDid: PropTypes.func.isRequired,
177
+ connectAccount: PropTypes.func.isRequired,
178
+ close: PropTypes.func.isRequired,
179
+ hasBindAccount: PropTypes.bool,
180
+ disableLogout: PropTypes.bool,
181
+ onLogout: PropTypes.func.isRequired,
182
+ expanded: PropTypes.bool,
183
+ onExpand: PropTypes.func,
184
+ accounts: PropTypes.array.isRequired,
185
+ deleteAccount: PropTypes.func.isRequired
186
+ };
187
+ ManageAccounts.defaultProps = {
188
+ locale: 'en',
189
+ hasBindAccount: false,
190
+ disableLogout: false,
191
+ expanded: true,
192
+ onExpand: noop
193
+ };
@@ -63,7 +63,8 @@ function SessionManager(_ref) {
63
63
  const {
64
64
  connectAccount,
65
65
  config,
66
- setConfig
66
+ setConfig,
67
+ deleteAccount
67
68
  } = (0, _useConfig.default)();
68
69
  const t = (0, _ahooks.useMemoizedFn)(function (key) {
69
70
  let data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
@@ -305,7 +306,9 @@ function SessionManager(_ref) {
305
306
  const cloneConfig = (0, _cloneDeep.default)(config);
306
307
  cloneConfig.expandAccount = value;
307
308
  setConfig(cloneConfig);
308
- }
309
+ },
310
+ deleteAccount: deleteAccount,
311
+ accounts: config.accounts
309
312
  }), showManageBlocklet ? [/*#__PURE__*/(0, _jsxRuntime.jsx)(_material.Divider, {}, "divider"), /*#__PURE__*/(0, _jsxRuntime.jsx)(_manageBlocklet.default, {
310
313
  menu: menu,
311
314
  menuRender: menuRender,
@@ -4,12 +4,14 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.default = ManageAccounts;
7
+ var _propTypes = _interopRequireDefault(require("prop-types"));
7
8
  var _ahooks = require("ahooks");
8
9
  var _material = require("@mui/material");
9
10
  var _react = require("@iconify/react");
10
11
  var _Account = _interopRequireDefault(require("@arcblock/icons/lib/Account"));
11
12
  var _link = _interopRequireDefault(require("@iconify-icons/mdi/link"));
12
13
  var _Disconnect = _interopRequireDefault(require("@arcblock/icons/lib/Disconnect"));
14
+ var _noop = _interopRequireDefault(require("lodash/noop"));
13
15
  var _accountItem = _interopRequireDefault(require("./account-item"));
14
16
  var _menuAccordion = _interopRequireDefault(require("./menu-accordion"));
15
17
  var _translation = require("./translation");
@@ -17,14 +19,13 @@ var _util = require("../Locale/util");
17
19
  var _confirm = require("../Dialog/confirm");
18
20
  var _utils = require("./utils");
19
21
  var _addAccountItem = _interopRequireDefault(require("./add-account-item"));
20
- var _useConfig = _interopRequireDefault(require("./use-config"));
21
22
  var _jsxRuntime = require("react/jsx-runtime");
22
23
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
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; }
24
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; }
25
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; }
26
27
  function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
27
- 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/prop-types */ /* eslint-disable react/jsx-no-bind */
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 */
28
29
  function ManageAccounts(_ref) {
29
30
  let {
30
31
  session,
@@ -37,7 +38,9 @@ function ManageAccounts(_ref) {
37
38
  disableLogout,
38
39
  onLogout,
39
40
  expanded,
40
- onExpand
41
+ onExpand,
42
+ accounts,
43
+ deleteAccount
41
44
  } = _ref;
42
45
  const {
43
46
  bindOAuth,
@@ -51,10 +54,6 @@ function ManageAccounts(_ref) {
51
54
  confirmApi,
52
55
  confirmHolder
53
56
  } = (0, _confirm.useConfirm)();
54
- const {
55
- deleteAccount,
56
- config
57
- } = (0, _useConfig.default)();
58
57
  const update = (0, _ahooks.useUpdate)();
59
58
  const onChoose = (0, _ahooks.useMemoizedFn)((account, _ref2) => {
60
59
  let {
@@ -149,7 +148,7 @@ function ManageAccounts(_ref) {
149
148
  }
150
149
  }), t('accounts')]
151
150
  }),
152
- children: [config.accounts.map(item => /*#__PURE__*/(0, _jsxRuntime.jsx)(_accountItem.default, {
151
+ children: [accounts.map(item => /*#__PURE__*/(0, _jsxRuntime.jsx)(_accountItem.default, {
153
152
  account: item,
154
153
  locale: locale,
155
154
  active: session.user.did === item.did,
@@ -182,4 +181,26 @@ function ManageAccounts(_ref) {
182
181
  })]
183
182
  }), confirmHolder]
184
183
  });
185
- }
184
+ }
185
+ ManageAccounts.propTypes = {
186
+ session: _propTypes.default.object.isRequired,
187
+ locale: _propTypes.default.string,
188
+ onBindWallet: _propTypes.default.func.isRequired,
189
+ onSwitchDid: _propTypes.default.func.isRequired,
190
+ connectAccount: _propTypes.default.func.isRequired,
191
+ close: _propTypes.default.func.isRequired,
192
+ hasBindAccount: _propTypes.default.bool,
193
+ disableLogout: _propTypes.default.bool,
194
+ onLogout: _propTypes.default.func.isRequired,
195
+ expanded: _propTypes.default.bool,
196
+ onExpand: _propTypes.default.func,
197
+ accounts: _propTypes.default.array.isRequired,
198
+ deleteAccount: _propTypes.default.func.isRequired
199
+ };
200
+ ManageAccounts.defaultProps = {
201
+ locale: 'en',
202
+ hasBindAccount: false,
203
+ disableLogout: false,
204
+ expanded: true,
205
+ onExpand: _noop.default
206
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcblock/ux",
3
- "version": "2.7.21",
3
+ "version": "2.7.22",
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": "e92f763c6f07c8adf341ffc8ffa417adb98c47fa",
325
+ "gitHead": "09ea2ed5bc7fdbe617078b82f6c940d0e6507500",
326
326
  "dependencies": {
327
327
  "@arcblock/did-motif": "^1.1.13",
328
- "@arcblock/icons": "^2.7.21",
329
- "@arcblock/react-hooks": "^2.7.21",
328
+ "@arcblock/icons": "^2.7.22",
329
+ "@arcblock/react-hooks": "^2.7.22",
330
330
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
331
331
  "@emotion/react": "^11.10.4",
332
332
  "@emotion/styled": "^11.10.4",
@@ -44,7 +44,7 @@ function SessionManager({
44
44
  ...rest
45
45
  }) {
46
46
  const latestSession = useLatest(session);
47
- const { connectAccount, config, setConfig } = useConfig();
47
+ const { connectAccount, config, setConfig, deleteAccount } = useConfig();
48
48
  const t = useMemoizedFn((key, data = {}) => {
49
49
  return translate(translations, key, locale, 'en', data);
50
50
  });
@@ -260,6 +260,8 @@ function SessionManager({
260
260
  cloneConfig.expandAccount = value;
261
261
  setConfig(cloneConfig);
262
262
  }}
263
+ deleteAccount={deleteAccount}
264
+ accounts={config.accounts}
263
265
  />
264
266
 
265
267
  {/* 为了避免控制台出现警告,采用数组的方式 */}
@@ -1,11 +1,12 @@
1
- /* eslint-disable react/prop-types */
2
1
  /* eslint-disable react/jsx-no-bind */
2
+ import PropTypes from 'prop-types';
3
3
  import { useMemoizedFn, useUpdate } from 'ahooks';
4
4
  import { MenuItem, SvgIcon } from '@mui/material';
5
5
  import { Icon } from '@iconify/react';
6
6
  import AccountIcon from '@arcblock/icons/lib/Account';
7
7
  import LinkIcon from '@iconify-icons/mdi/link';
8
8
  import DisconnectIcon from '@arcblock/icons/lib/Disconnect';
9
+ import noop from 'lodash/noop';
9
10
 
10
11
  import AccountItem from './account-item';
11
12
  import MenuAccordion from './menu-accordion';
@@ -14,7 +15,6 @@ import { translate } from '../Locale/util';
14
15
  import { useConfirm } from '../Dialog/confirm';
15
16
  import { getSourceProvider } from './utils';
16
17
  import AddAccountItem from './add-account-item';
17
- import useConfig from './use-config';
18
18
 
19
19
  export default function ManageAccounts({
20
20
  session,
@@ -28,6 +28,8 @@ export default function ManageAccounts({
28
28
  onLogout,
29
29
  expanded,
30
30
  onExpand,
31
+ accounts,
32
+ deleteAccount,
31
33
  }) {
32
34
  const { bindOAuth, configs: oauthConfigs } = session.useOAuth();
33
35
  const t = useMemoizedFn((key, data = {}) => {
@@ -35,7 +37,6 @@ export default function ManageAccounts({
35
37
  });
36
38
 
37
39
  const { confirmApi, confirmHolder } = useConfirm();
38
- const { deleteAccount, config } = useConfig();
39
40
  const update = useUpdate();
40
41
 
41
42
  const onChoose = useMemoizedFn((account, { active }) => {
@@ -133,7 +134,7 @@ export default function ManageAccounts({
133
134
  {t('accounts')}
134
135
  </>
135
136
  }>
136
- {config.accounts.map((item) => (
137
+ {accounts.map((item) => (
137
138
  <AccountItem
138
139
  key={item.did}
139
140
  account={item}
@@ -170,3 +171,27 @@ export default function ManageAccounts({
170
171
  </>
171
172
  );
172
173
  }
174
+
175
+ ManageAccounts.propTypes = {
176
+ session: PropTypes.object.isRequired,
177
+ locale: PropTypes.string,
178
+ onBindWallet: PropTypes.func.isRequired,
179
+ onSwitchDid: PropTypes.func.isRequired,
180
+ connectAccount: PropTypes.func.isRequired,
181
+ close: PropTypes.func.isRequired,
182
+ hasBindAccount: PropTypes.bool,
183
+ disableLogout: PropTypes.bool,
184
+ onLogout: PropTypes.func.isRequired,
185
+ expanded: PropTypes.bool,
186
+ onExpand: PropTypes.func,
187
+ accounts: PropTypes.array.isRequired,
188
+ deleteAccount: PropTypes.func.isRequired,
189
+ };
190
+
191
+ ManageAccounts.defaultProps = {
192
+ locale: 'en',
193
+ hasBindAccount: false,
194
+ disableLogout: false,
195
+ expanded: true,
196
+ onExpand: noop,
197
+ };