@arcblock/ux 2.9.13 → 2.9.15

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.
Files changed (158) hide show
  1. package/es/Address/did-address.js +18 -13
  2. package/es/Colors/themes/default.js +0 -1
  3. package/es/Colors/themes/temp.js +10 -1
  4. package/es/ContactForm/index.js +2 -2
  5. package/es/DID/index.js +0 -1
  6. package/es/Dialog/confirm.js +1 -99
  7. package/es/Dialog/dialog.js +4 -7
  8. package/es/Dialog/index.js +1 -1
  9. package/es/Dialog/use-confirm.js +105 -0
  10. package/es/Locale/selector.js +1 -1
  11. package/es/Locale/util.js +10 -5
  12. package/es/NFTDisplay/index.js +0 -1
  13. package/es/Passport/index.js +2 -0
  14. package/es/Passport/passport.js +103 -0
  15. package/es/SessionBlocklet/index.js +1 -1
  16. package/es/SessionUser/components/logged-in.js +1 -1
  17. package/es/SessionUser/components/un-login.js +1 -1
  18. package/es/SessionUser/components/user-info.js +1 -1
  19. package/es/SessionUser/index.js +2 -2
  20. package/es/Tabs/index.js +88 -2
  21. package/es/Theme/theme.js +12 -3
  22. package/es/Util/passport.js +62 -0
  23. package/lib/ActionButton/index.js +6 -7
  24. package/lib/ActivityIndicator/index.js +4 -4
  25. package/lib/Address/compact-text.js +6 -6
  26. package/lib/Address/did-address.js +25 -21
  27. package/lib/Address/index.js +4 -4
  28. package/lib/Address/responsive-did-address.js +4 -4
  29. package/lib/Alert/index.js +5 -6
  30. package/lib/AnimationWaiter/index.js +4 -4
  31. package/lib/Async/index.js +6 -6
  32. package/lib/Avatar/did-motif.js +5 -6
  33. package/lib/Avatar/etherscan-blockies.js +2 -3
  34. package/lib/Avatar/index.js +4 -4
  35. package/lib/Badge/index.js +5 -6
  36. package/lib/Blocklet/blocklet.js +4 -4
  37. package/lib/Blocklet/index.js +3 -4
  38. package/lib/Blocklet/utils.js +3 -5
  39. package/lib/BlockletContext/index.js +1 -2
  40. package/lib/BlockletNFT/index.js +4 -4
  41. package/lib/Button/index.js +1 -2
  42. package/lib/Button/wrap.js +4 -4
  43. package/lib/ButtonGroup/index.js +1 -2
  44. package/lib/ClickToCopy/copy-button.js +4 -4
  45. package/lib/ClickToCopy/index.js +6 -6
  46. package/lib/CodeBlock/LightBox.js +1 -2
  47. package/lib/CodeBlock/index.js +4 -4
  48. package/lib/Colors/themes/default.js +1 -2
  49. package/lib/Colors/themes/temp.js +11 -3
  50. package/lib/ContactForm/index.js +2 -2
  51. package/lib/CookieConsent/index.js +6 -6
  52. package/lib/CountDown/index.js +4 -4
  53. package/lib/DID/index.js +7 -9
  54. package/lib/Datatable/CustomToolbar.js +2 -2
  55. package/lib/Datatable/index.js +49 -49
  56. package/lib/Datatable/utils.js +2 -3
  57. package/lib/Dialog/confirm.js +5 -113
  58. package/lib/Dialog/dialog.js +14 -18
  59. package/lib/Dialog/index.js +3 -4
  60. package/lib/Dialog/use-confirm.js +126 -0
  61. package/lib/Earth/index.js +7 -8
  62. package/lib/Empty/index.js +5 -6
  63. package/lib/Header/auto-hidden.js +5 -6
  64. package/lib/Header/header.js +5 -6
  65. package/lib/Header/responsive-header.js +5 -6
  66. package/lib/Icon/image.js +4 -4
  67. package/lib/Icon/index.js +6 -7
  68. package/lib/Img/index.js +5 -6
  69. package/lib/InfoRow/index.js +5 -6
  70. package/lib/Layout/dashboard/external-link.js +4 -4
  71. package/lib/Layout/dashboard/full-page.js +5 -6
  72. package/lib/Layout/dashboard/index.js +4 -4
  73. package/lib/Layout/dashboard/sidebar.js +5 -6
  74. package/lib/Layout/dashboard-legacy/header.js +4 -4
  75. package/lib/Layout/dashboard-legacy/index.js +4 -4
  76. package/lib/Layout/dashboard-legacy/sidebar.js +4 -4
  77. package/lib/Layout/index.js +4 -4
  78. package/lib/Locale/browser-lang.js +1 -2
  79. package/lib/Locale/context.js +6 -8
  80. package/lib/Locale/languages.js +7 -9
  81. package/lib/Locale/selector.js +5 -5
  82. package/lib/Locale/util.js +12 -11
  83. package/lib/Logo/index.js +4 -4
  84. package/lib/NFTDisplay/aspect-ratio-container.js +5 -6
  85. package/lib/NFTDisplay/broken.js +4 -4
  86. package/lib/NFTDisplay/index.js +5 -7
  87. package/lib/NFTDisplay/svg-embedder/img.js +5 -6
  88. package/lib/NFTDisplay/svg-embedder/inline-svg.js +5 -6
  89. package/lib/NavMenu/nav-menu.js +5 -6
  90. package/lib/NavMenu/style.js +2 -4
  91. package/lib/PageScroller/index.js +6 -7
  92. package/lib/Passport/index.js +9 -0
  93. package/lib/Passport/passport.js +116 -0
  94. package/lib/PoweredByArcBlock/index.js +4 -4
  95. package/lib/PricingTable/PricingPlan.js +1 -2
  96. package/lib/PricingTable/index.js +1 -2
  97. package/lib/QRCode/index.js +5 -6
  98. package/lib/RelativeTime/index.js +4 -4
  99. package/lib/Result/common.js +4 -4
  100. package/lib/Result/index.js +7 -8
  101. package/lib/Result/result.js +5 -6
  102. package/lib/Result/translations.js +2 -3
  103. package/lib/Screenshot/BaseScreenshot/index.js +5 -6
  104. package/lib/Screenshot/BaseScreenshot/shells/Macbook.js +10 -15
  105. package/lib/Screenshot/BaseScreenshot/shells/Phone.js +10 -15
  106. package/lib/Screenshot/index.js +5 -6
  107. package/lib/SessionBlocklet/index.js +5 -5
  108. package/lib/SessionManager/index.js +1 -2
  109. package/lib/SessionUser/components/logged-in.js +5 -5
  110. package/lib/SessionUser/components/session-user-item.js +5 -6
  111. package/lib/SessionUser/components/session-user-switch.js +4 -4
  112. package/lib/SessionUser/components/un-login.js +1 -1
  113. package/lib/SessionUser/components/user-info.js +1 -1
  114. package/lib/SessionUser/index.js +2 -2
  115. package/lib/SessionUser/libs/translation.js +2 -3
  116. package/lib/Spinner/index.js +13 -14
  117. package/lib/SplitButton/index.js +4 -4
  118. package/lib/Switch/index.js +5 -6
  119. package/lib/Tabs/index.js +98 -11
  120. package/lib/Tag/index.js +5 -6
  121. package/lib/TextCollapse/index.js +5 -6
  122. package/lib/Theme/index.js +6 -7
  123. package/lib/Theme/theme.js +18 -11
  124. package/lib/Toast/index.js +12 -13
  125. package/lib/Typography/index.js +4 -4
  126. package/lib/Util/constant.js +10 -20
  127. package/lib/Util/deprecate.js +4 -4
  128. package/lib/Util/index.js +2 -4
  129. package/lib/Util/passport.js +72 -0
  130. package/lib/Util/wallet.js +1 -2
  131. package/lib/Video/index.js +4 -4
  132. package/lib/Wallet/Action.js +4 -4
  133. package/lib/Wallet/Download.js +4 -4
  134. package/lib/WebWalletSWKeeper/index.js +5 -6
  135. package/lib/withTheme/index.js +5 -6
  136. package/lib/withTracker/error_boundary.js +2 -2
  137. package/lib/withTracker/index.js +8 -9
  138. package/package.json +12 -6
  139. package/src/Address/did-address.jsx +15 -12
  140. package/src/Colors/themes/temp.js +9 -0
  141. package/src/Dialog/confirm.jsx +94 -0
  142. package/src/Dialog/{dialog.js → dialog.jsx} +14 -7
  143. package/src/Dialog/index.js +1 -1
  144. package/src/Dialog/use-confirm.jsx +114 -0
  145. package/src/Locale/selector.jsx +1 -1
  146. package/src/Locale/util.js +12 -5
  147. package/src/Passport/index.jsx +3 -0
  148. package/src/Passport/passport.jsx +99 -0
  149. package/src/SessionBlocklet/index.jsx +1 -1
  150. package/src/SessionUser/components/logged-in.jsx +1 -1
  151. package/src/SessionUser/components/un-login.jsx +1 -1
  152. package/src/SessionUser/components/user-info.jsx +1 -1
  153. package/src/SessionUser/index.jsx +1 -1
  154. package/src/Tabs/index.jsx +124 -0
  155. package/src/Theme/theme.js +13 -3
  156. package/src/Util/passport.js +75 -0
  157. package/src/Dialog/confirm.js +0 -201
  158. package/src/Tabs/index.js +0 -45
@@ -10,15 +10,15 @@ var _ahooks = require("ahooks");
10
10
  var _reactRouterDom = require("react-router-dom");
11
11
  var _error_boundary = _interopRequireDefault(require("./error_boundary"));
12
12
  var _jsxRuntime = require("react/jsx-runtime");
13
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
14
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
14
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
15
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
16
- 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; }
17
- 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; }
16
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
17
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
18
18
  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; }
19
- function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return typeof key === "symbol" ? key : String(key); }
20
- 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 import/no-unresolved */
21
- var _default = function _default(WrappedComponent) {
19
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : String(i); }
20
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } /* eslint-disable import/no-unresolved */
21
+ var _default = exports.default = function _default(WrappedComponent) {
22
22
  let options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
23
23
  const {
24
24
  appVersion,
@@ -61,5 +61,4 @@ var _default = function _default(WrappedComponent) {
61
61
  }
62
62
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(WrappedComponent, _objectSpread({}, props));
63
63
  };
64
- };
65
- exports.default = _default;
64
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcblock/ux",
3
- "version": "2.9.13",
3
+ "version": "2.9.15",
4
4
  "description": "Common used react components for arcblock products",
5
5
  "keywords": [
6
6
  "react",
@@ -215,6 +215,10 @@
215
215
  "import": "./es/PageScroller/index.js",
216
216
  "require": "./lib/PageScroller/index.js"
217
217
  },
218
+ "./lib/Passport": {
219
+ "import": "./es/Passport/index.js",
220
+ "require": "./lib/Passport/index.js"
221
+ },
218
222
  "./lib/PoweredByArcBlock": {
219
223
  "import": "./es/PoweredByArcBlock/index.js",
220
224
  "require": "./lib/PoweredByArcBlock/index.js"
@@ -340,16 +344,17 @@
340
344
  "peerDependencies": {
341
345
  "react": ">=18.1.0"
342
346
  },
343
- "gitHead": "c32202066e023e3ca91905f3d3292ac480325cd4",
347
+ "gitHead": "2402b2d3888dcac685215c373afd7651e6907acc",
344
348
  "dependencies": {
345
349
  "@arcblock/did-motif": "^1.1.13",
346
- "@arcblock/icons": "^2.9.13",
347
- "@arcblock/react-hooks": "^2.9.13",
350
+ "@arcblock/icons": "^2.9.15",
351
+ "@arcblock/nft-display": "^2.9.15",
352
+ "@arcblock/react-hooks": "^2.9.15",
348
353
  "@babel/plugin-syntax-dynamic-import": "^7.8.3",
349
354
  "@emotion/react": "^11.10.4",
350
355
  "@emotion/styled": "^11.10.4",
351
- "@fontsource/lato": "^4.5.10",
352
- "@fontsource/ubuntu-mono": "^4.5.11",
356
+ "@fontsource/inter": "^5.0.16",
357
+ "@fontsource/ubuntu-mono": "^5.0.18",
353
358
  "@iconify-icons/logos": "^1.2.36",
354
359
  "@iconify-icons/material-symbols": "^1.2.58",
355
360
  "@iconify-icons/mdi": "^1.2.48",
@@ -368,6 +373,7 @@
368
373
  "devices.css": "^0.1.15",
369
374
  "highlight.js": "^11.6.0",
370
375
  "iconify-icon": "^1.0.8",
376
+ "iconify-icons-material-symbols-400": "^0.0.1",
371
377
  "is-svg": "^4.3.2",
372
378
  "js-cookie": "^2.2.1",
373
379
  "lodash": "^4.17.21",
@@ -92,20 +92,12 @@ const DidAddress = forwardRef(
92
92
  return (
93
93
  <Root as={component} size={size} {...rest} ref={ref}>
94
94
  {prepend}
95
+ <Box sx={{ display: 'none' }} ref={textRef}>
96
+ {children}
97
+ </Box>
95
98
  {/* 注意: 该元素必须渲染(可以隐藏), 以便 compact 模式下复制的文本是完整的 */}
96
99
  <Tooltip title={copyable ? '' : translations[locale].copied} placement="bottom" arrow open={copied}>
97
- <Box
98
- ref={textRef}
99
- component="span"
100
- className="did-address-text did-address-truncate"
101
- sx={{
102
- display: compact ? 'none' : 'inline',
103
- cursor: copyable ? 'text' : 'pointer',
104
- }}
105
- onDoubleClick={copyable ? noop : onCopy}>
106
- {children}
107
- </Box>
108
- {compact && (
100
+ {compact ? (
109
101
  <Box
110
102
  component="span"
111
103
  className="did-address-text"
@@ -120,6 +112,17 @@ const DidAddress = forwardRef(
120
112
  {children}
121
113
  </CompactText>
122
114
  </Box>
115
+ ) : (
116
+ <Box
117
+ component="span"
118
+ className="did-address-text did-address-truncate"
119
+ sx={{
120
+ display: compact ? 'none' : 'inline',
121
+ cursor: copyable ? 'text' : 'pointer',
122
+ }}
123
+ onDoubleClick={copyable ? noop : onCopy}>
124
+ {children}
125
+ </Box>
123
126
  )}
124
127
  </Tooltip>
125
128
  {copyElement}
@@ -13,6 +13,15 @@ const colors = {
13
13
  primaryBase: 'rgba(19, 125, 250, 1)',
14
14
  primary100: 'rgba(19, 125, 250, 1)',
15
15
  gray6: 'rgba(17, 22, 24, 0.06)',
16
+ backgroundsBgSubtitle: 'rgba(249, 250, 251, 1)',
17
+ backgroundsBgComponent: 'rgba(241, 243, 245, 1)',
18
+ backgroundsBgField: 'rgba(249, 250, 251, 1)',
19
+ foregroundsFgBase: 'rgba(3, 7, 18, 1)',
20
+ foregroundsFgSubtile: 'rgba(75, 85, 99, 1)',
21
+ strokeBorderBase: 'rgba(229, 231, 235, 1)',
22
+ strokeBorderStrong: 'rgba(209, 213, 219, 1)',
23
+ buttonsButtonNeutral: 'rgba(255, 255, 255, 1)',
24
+ buttonsButtonNeutralHover: 'rgba(243, 244, 246, 1)',
16
25
  };
17
26
 
18
27
  export default colors;
@@ -0,0 +1,94 @@
1
+ import PropTypes from 'prop-types';
2
+
3
+ import Button from '../Button';
4
+ import Dialog from './dialog';
5
+
6
+ /**
7
+ @typedef {Object} ConfirmProps
8
+ @property {boolean} open
9
+ @property {React.ReactNode} title
10
+ @property {React.ReactNode} children
11
+ @property {() => void | Promise<void>} onConfirm
12
+ @property {() => void | Promise<void>} onCancel
13
+ @property {boolean} [showCancelButton=true]
14
+ @property {{text: string, props?: import('../Button/wrap').ButtonProps}} [confirmButton={text: 'Confirm'}]
15
+ @property {{text: string, props?: import('../Button/wrap').ButtonProps}} [cancelButton={text: 'Cancel'}]
16
+ @property {import('@mui/material').PaperProps} [PaperProps={}]
17
+ */
18
+
19
+ // 注意排在 {...rest} 之后的 props 优先级更高
20
+ /**
21
+ *
22
+ * @param {ConfirmProps} props
23
+ * @returns {import('react').ReactComponentElement}
24
+ */
25
+ export default function Confirm({
26
+ title,
27
+ children,
28
+ onConfirm,
29
+ onCancel,
30
+ showCancelButton,
31
+ confirmButton,
32
+ cancelButton,
33
+ PaperProps,
34
+ ...rest
35
+ }) {
36
+ // 去除 dialog 默认的 300 最小高度
37
+ PaperProps.style = Object.assign(
38
+ {
39
+ minHeight: 0,
40
+ },
41
+ PaperProps.style
42
+ );
43
+
44
+ return (
45
+ <Dialog
46
+ title={title}
47
+ PaperProps={PaperProps}
48
+ {...rest}
49
+ onClose={() => onCancel()}
50
+ actions={
51
+ <>
52
+ {showCancelButton && (
53
+ <Button onClick={() => onCancel()} color="primary" {...cancelButton.props}>
54
+ {cancelButton.text}
55
+ </Button>
56
+ )}
57
+ <Button onClick={() => onConfirm()} color="primary" autoFocus {...confirmButton.props}>
58
+ {confirmButton.text}
59
+ </Button>
60
+ </>
61
+ }>
62
+ {children}
63
+ </Dialog>
64
+ );
65
+ }
66
+
67
+ Confirm.propTypes = {
68
+ title: PropTypes.node.isRequired,
69
+ children: PropTypes.node.isRequired,
70
+ onConfirm: PropTypes.func.isRequired,
71
+ onCancel: PropTypes.func.isRequired,
72
+ showCancelButton: PropTypes.bool,
73
+ // 可以传入 {text: ..., props: ...}
74
+ confirmButton: PropTypes.shape({
75
+ text: PropTypes.string.isRequired,
76
+ props: PropTypes.object,
77
+ }),
78
+ cancelButton: PropTypes.shape({
79
+ text: PropTypes.string.isRequired,
80
+ props: PropTypes.object,
81
+ }),
82
+ PaperProps: PropTypes.object,
83
+ };
84
+
85
+ Confirm.defaultProps = {
86
+ showCancelButton: true,
87
+ confirmButton: {
88
+ text: 'Confirm',
89
+ },
90
+ cancelButton: {
91
+ text: 'Cancel',
92
+ },
93
+ PaperProps: {},
94
+ };
@@ -1,10 +1,13 @@
1
1
  import PropTypes from 'prop-types';
2
- import MuiDialog from '@mui/material/Dialog';
3
- import MuiDialogContent from '@mui/material/DialogContent';
4
- import DialogActions from '@mui/material/DialogActions';
5
- import IconButton from '@mui/material/IconButton';
6
- import useMediaQuery from '@mui/material/useMediaQuery';
7
2
  import CloseIcon from '@mui/icons-material/Close';
3
+ import {
4
+ Typography,
5
+ Dialog as MuiDialog,
6
+ DialogContent as MuiDialogContent,
7
+ DialogActions,
8
+ IconButton,
9
+ useMediaQuery,
10
+ } from '@mui/material';
8
11
 
9
12
  import { styled, useTheme } from '../Theme';
10
13
 
@@ -25,7 +28,7 @@ import { styled, useTheme } from '../Theme';
25
28
  @property {boolean} [showCloseButton=true] - Whether or not to show the close button.
26
29
  @property {'left'|'center'|'right'} [actionsPosition='right'] - The position of the actions toolbar.
27
30
  @property {PaperStyle} [PaperProps] - Props to be passed down to the dialog paper.
28
- @property {(event: React.SyntheticEvent, reason: string) => void} [onClose] - Callback function fired when the dialog is closed.
31
+ @property {(event: React.SyntheticEvent, reason: string) => void} [onClose] - Callback function fired when the dialog is closed.
29
32
  */
30
33
 
31
34
  /**
@@ -74,7 +77,11 @@ function Dialog({ children, title, prepend, toolbar, actions, showCloseButton, a
74
77
  <div className="ux-dialog_left">
75
78
  {showCloseButton && isMobile && closeButton}
76
79
  {prepend && <div className="ux-dialog_prepend">{prepend}</div>}
77
- {title && <h6 className="ux-dialog_title">{title}</h6>}
80
+ {title && (
81
+ <Typography variant="h6" className="ux-dialog_title">
82
+ {title}
83
+ </Typography>
84
+ )}
78
85
  </div>
79
86
 
80
87
  <div className="ux-dialog_right">
@@ -1,4 +1,4 @@
1
1
  // eslint-disable-next-line no-restricted-exports
2
2
  export { default } from './dialog';
3
3
  export { default as Confirm } from './confirm';
4
- export { useConfirm } from './confirm';
4
+ export { default as useConfirm } from './use-confirm';
@@ -0,0 +1,114 @@
1
+ import { forwardRef, useImperativeHandle, useRef, useState } from 'react';
2
+ import { useMemoizedFn, useReactive } from 'ahooks';
3
+ import noop from 'lodash/noop';
4
+
5
+ import Confirm from './confirm';
6
+
7
+ const ConfirmHolder = forwardRef((props, ref) => {
8
+ // HACK: 这里默认值不使用 null,来避免开发环境中的字段必填警告
9
+ const [title, setTitle] = useState('');
10
+ const [content, setContent] = useState('');
11
+ const state = useReactive({
12
+ show: false,
13
+ onConfirm: noop,
14
+ onCancel: noop,
15
+ loading: false,
16
+ confirmButtonText: 'Confirm',
17
+ cancelButtonText: 'Cancel',
18
+ });
19
+ const open = useMemoizedFn((params = {}) => {
20
+ setTitle(params.title);
21
+ setContent(params.content);
22
+ state.onConfirm = params.onConfirm || noop;
23
+ state.onCancel = params.onCancel || noop;
24
+ state.showCancelButton = params.showCancelButton ?? true;
25
+ if (params.confirmButtonText) state.confirmButtonText = params.confirmButtonText;
26
+ if (params.cancelButtonText) state.cancelButtonText = params.cancelButtonText;
27
+
28
+ state.loading = false;
29
+ state.show = true;
30
+ });
31
+ const reset = useMemoizedFn(() => {
32
+ setTitle('');
33
+ setContent('');
34
+ state.onConfirm = noop;
35
+ state.onCancel = noop;
36
+ state.confirmButtonText = 'Confirm';
37
+ state.cancelButtonText = 'Cancel';
38
+ });
39
+ const close = useMemoizedFn(() => {
40
+ state.show = false;
41
+ setTimeout(() => {
42
+ reset();
43
+ }, 300);
44
+ });
45
+ const onCancel = useMemoizedFn(() => {
46
+ close();
47
+ state?.onCancel();
48
+ }, []);
49
+ const onConfirm = useMemoizedFn(async () => {
50
+ state.loading = true;
51
+ try {
52
+ await state?.onConfirm(close);
53
+ } finally {
54
+ state.loading = false;
55
+ }
56
+ }, []);
57
+ useImperativeHandle(
58
+ ref,
59
+ () => {
60
+ return {
61
+ open,
62
+ close,
63
+ };
64
+ },
65
+ [open, close]
66
+ );
67
+
68
+ return (
69
+ <Confirm
70
+ {...props}
71
+ open={state.show}
72
+ title={title}
73
+ onConfirm={onConfirm}
74
+ onCancel={onCancel}
75
+ confirmButton={{
76
+ text: state.confirmButtonText,
77
+ props: {
78
+ variant: 'contained',
79
+ color: 'primary',
80
+ loading: state.loading,
81
+ },
82
+ }}
83
+ showCancelButton={state.showCancelButton}
84
+ cancelButton={{
85
+ text: state.cancelButtonText,
86
+ props: {
87
+ variant: 'outlined',
88
+ color: 'primary',
89
+ },
90
+ }}>
91
+ {content}
92
+ </Confirm>
93
+ );
94
+ });
95
+
96
+ export default function useConfirm(props = {}) {
97
+ const confirmRef = useRef(null);
98
+
99
+ const open = useMemoizedFn((...args) => {
100
+ confirmRef.current?.open(...args);
101
+ });
102
+ const close = useMemoizedFn((...args) => {
103
+ confirmRef.current?.close(...args);
104
+ });
105
+ const confirmApi = {
106
+ open,
107
+ close,
108
+ };
109
+
110
+ return {
111
+ confirmHolder: <ConfirmHolder {...props} ref={confirmRef} />,
112
+ confirmApi,
113
+ };
114
+ }
@@ -3,8 +3,8 @@ import { useState, useContext, useRef, useMemo } from 'react';
3
3
  import PropTypes from 'prop-types';
4
4
  import { Button, Typography, IconButton, Popper, MenuItem, MenuList, Box, ClickAwayListener } from '@mui/material';
5
5
  import { Icon as IconifyIcon } from '@iconify/react';
6
- import LanguageIcon from '@iconify-icons/material-symbols/language';
7
6
  import CheckIcon from '@iconify-icons/material-symbols/check';
7
+ import LanguageIcon from 'iconify-icons-material-symbols-400/language';
8
8
  import noop from 'lodash/noop';
9
9
 
10
10
  import { getColor, getBackground } from '../Util';
@@ -1,19 +1,26 @@
1
+ import get from 'lodash/get';
2
+
1
3
  /* eslint-disable no-prototype-builtins */
2
4
  export const replace = (template, data) =>
3
5
  template.replace(/{(\w*)}/g, (m, key) => (data.hasOwnProperty(key) ? data[key] : ''));
4
6
 
5
7
  export const translate = (translations, key, locale, fallbackLocale = 'en', data = {}) => {
6
- if (!translations[locale] || !translations[locale][key]) {
8
+ const translation = translations[locale];
9
+ const translationValue = get(translation, key);
10
+ const fallbackValue = get(translations[fallbackLocale], key);
11
+
12
+ if (!translation || !translationValue) {
7
13
  console.warn(`Warning: no ${key} translation of ${locale}`);
8
- if (fallbackLocale && translations[fallbackLocale]?.[key]) {
9
- return replace(translations[fallbackLocale]?.[key], data);
14
+ if (fallbackLocale && fallbackValue) {
15
+ return replace(fallbackValue, data);
10
16
  }
11
17
  return key;
12
18
  }
19
+
13
20
  if (typeof translations[locale] === 'function' || translations[locale].then) {
14
- return replace(translations[fallbackLocale][key], data);
21
+ return replace(fallbackValue, data);
15
22
  }
16
- return replace(translations[locale][key], data);
23
+ return replace(translationValue, data);
17
24
  };
18
25
 
19
26
  export const t = translate;
@@ -0,0 +1,3 @@
1
+ import PassportItem from './passport';
2
+
3
+ export default PassportItem;
@@ -0,0 +1,99 @@
1
+ import PropTypes from 'prop-types';
2
+ import upperFirst from 'lodash/upperFirst';
3
+ import { Box } from '@mui/material';
4
+ import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
5
+ import RevokeIcon from '@arcblock/icons/lib/RevokeIcon';
6
+
7
+ export default function Passport({ passport, user, color, width, icon, children, createPassportSvg, ...rest }) {
8
+ const { t } = useLocaleContext();
9
+ return (
10
+ <Box
11
+ {...rest}
12
+ sx={{
13
+ display: 'flex',
14
+ alignItems: 'center',
15
+ ...rest?.sx,
16
+ }}>
17
+ <Box
18
+ className="passport-item__display"
19
+ // eslint-disable-next-line react/no-danger
20
+ dangerouslySetInnerHTML={{
21
+ __html: createPassportSvg({
22
+ title: passport.title || passport.name,
23
+ issuer: passport.issuer && passport.issuer.name,
24
+ issuerDid: passport.issuer && passport.issuer.id,
25
+ ownerName: user.fullName,
26
+ ownerDid: user.did,
27
+ ownerAvatarUrl: user.avatar,
28
+ revoked: passport.revoked,
29
+ preferredColor: color,
30
+ width,
31
+ }),
32
+ }}
33
+ />
34
+ <Box
35
+ className="passport-item__body"
36
+ sx={{
37
+ p: 0,
38
+ ml: 3,
39
+ mt: 0,
40
+ }}>
41
+ <Box
42
+ className="passport-item__title"
43
+ sx={{
44
+ display: 'flex',
45
+ alignItems: 'center',
46
+ fontWeight: 400,
47
+ fontSize: '16px',
48
+ lineHeight: 1.1875,
49
+ color: '#222222',
50
+ }}>
51
+ {upperFirst(passport.title)}
52
+ <Box
53
+ className="passport-item__status-icon"
54
+ sx={{
55
+ svg: {
56
+ fill: '#bfbfbf',
57
+ height: '1.2em',
58
+ marginLeft: '0.4em',
59
+ },
60
+ }}>
61
+ {icon}
62
+ {passport.revoked && <RevokeIcon />}
63
+ </Box>
64
+ </Box>
65
+ {passport.expirationDate && (
66
+ <Box
67
+ className="passport-item__title"
68
+ sx={{
69
+ display: 'flex',
70
+ alignItems: 'center',
71
+ fontWeight: 400,
72
+ fontSize: '16px',
73
+ lineHeight: 1.1875,
74
+ color: '#222222',
75
+ }}>
76
+ {t('team.passport.validUntil', { date: passport.expirationDate })}
77
+ </Box>
78
+ )}
79
+ {children}
80
+ </Box>
81
+ </Box>
82
+ );
83
+ }
84
+
85
+ Passport.propTypes = {
86
+ passport: PropTypes.any.isRequired,
87
+ user: PropTypes.any.isRequired,
88
+ color: PropTypes.string.isRequired,
89
+ createPassportSvg: PropTypes.func.isRequired,
90
+ icon: PropTypes.any,
91
+ children: PropTypes.any,
92
+ width: PropTypes.number,
93
+ };
94
+
95
+ Passport.defaultProps = {
96
+ icon: null,
97
+ children: null,
98
+ width: 150,
99
+ };
@@ -13,7 +13,7 @@ import {
13
13
  Typography,
14
14
  } from '@mui/material';
15
15
  import { Icon } from '@iconify/react';
16
- import DashboardOutlineRoundedIcon from '@iconify-icons/material-symbols/dashboard-outline-rounded';
16
+ import DashboardOutlineRoundedIcon from 'iconify-icons-material-symbols-400/dashboard-outline-rounded';
17
17
  import WidgetsOutlineRoundedIcon from '@iconify-icons/material-symbols/widgets-outline-rounded';
18
18
  import { useMemoizedFn, useReactive } from 'ahooks';
19
19
 
@@ -189,6 +189,6 @@ function SessionMenuItem({ icon, title, ...rest }) {
189
189
  }
190
190
 
191
191
  SessionMenuItem.propTypes = {
192
- icon: PropTypes.string.isRequired,
192
+ icon: PropTypes.any.isRequired,
193
193
  title: PropTypes.string.isRequired,
194
194
  };
@@ -1,7 +1,7 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import { Box, CircularProgress, IconButton } from '@mui/material';
3
3
  import { Icon } from '@iconify/react';
4
- import PersonOutlineRoundedIcon from '@iconify-icons/material-symbols/person-outline-rounded';
4
+ import PersonOutlineRoundedIcon from 'iconify-icons-material-symbols-400/person-outline-rounded';
5
5
  import { useRef } from 'react';
6
6
  import { useMemoizedFn } from 'ahooks';
7
7
  import noop from 'lodash/noop';
@@ -98,7 +98,7 @@ export default function UserInfo({
98
98
  />
99
99
  </Box>
100
100
 
101
- <Typography variant="h6" sx={{ wordBreak: 'break-all' }}>
101
+ <Typography variant="h6" sx={{ wordBreak: 'break-word' }}>
102
102
  {session.user.fullName}
103
103
  </Typography>
104
104
  </Box>
@@ -22,8 +22,8 @@ SessionUser.propTypes = {
22
22
  user: PropTypes.shape({
23
23
  did: PropTypes.string.isRequired,
24
24
  fullName: PropTypes.string.isRequired,
25
- email: PropTypes.string.isRequired,
26
25
  avatar: PropTypes.string.isRequired,
26
+ email: PropTypes.string,
27
27
  }),
28
28
  }).isRequired,
29
29
  onBindWallet: PropTypes.func,