@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.
- package/es/Address/did-address.js +18 -13
- package/es/Colors/themes/default.js +0 -1
- package/es/Colors/themes/temp.js +10 -1
- package/es/ContactForm/index.js +2 -2
- package/es/DID/index.js +0 -1
- package/es/Dialog/confirm.js +1 -99
- package/es/Dialog/dialog.js +4 -7
- package/es/Dialog/index.js +1 -1
- package/es/Dialog/use-confirm.js +105 -0
- package/es/Locale/selector.js +1 -1
- package/es/Locale/util.js +10 -5
- package/es/NFTDisplay/index.js +0 -1
- package/es/Passport/index.js +2 -0
- package/es/Passport/passport.js +103 -0
- package/es/SessionBlocklet/index.js +1 -1
- package/es/SessionUser/components/logged-in.js +1 -1
- package/es/SessionUser/components/un-login.js +1 -1
- package/es/SessionUser/components/user-info.js +1 -1
- package/es/SessionUser/index.js +2 -2
- package/es/Tabs/index.js +88 -2
- package/es/Theme/theme.js +12 -3
- package/es/Util/passport.js +62 -0
- package/lib/ActionButton/index.js +6 -7
- package/lib/ActivityIndicator/index.js +4 -4
- package/lib/Address/compact-text.js +6 -6
- package/lib/Address/did-address.js +25 -21
- package/lib/Address/index.js +4 -4
- package/lib/Address/responsive-did-address.js +4 -4
- package/lib/Alert/index.js +5 -6
- package/lib/AnimationWaiter/index.js +4 -4
- package/lib/Async/index.js +6 -6
- package/lib/Avatar/did-motif.js +5 -6
- package/lib/Avatar/etherscan-blockies.js +2 -3
- package/lib/Avatar/index.js +4 -4
- package/lib/Badge/index.js +5 -6
- package/lib/Blocklet/blocklet.js +4 -4
- package/lib/Blocklet/index.js +3 -4
- package/lib/Blocklet/utils.js +3 -5
- package/lib/BlockletContext/index.js +1 -2
- package/lib/BlockletNFT/index.js +4 -4
- package/lib/Button/index.js +1 -2
- package/lib/Button/wrap.js +4 -4
- package/lib/ButtonGroup/index.js +1 -2
- package/lib/ClickToCopy/copy-button.js +4 -4
- package/lib/ClickToCopy/index.js +6 -6
- package/lib/CodeBlock/LightBox.js +1 -2
- package/lib/CodeBlock/index.js +4 -4
- package/lib/Colors/themes/default.js +1 -2
- package/lib/Colors/themes/temp.js +11 -3
- package/lib/ContactForm/index.js +2 -2
- package/lib/CookieConsent/index.js +6 -6
- package/lib/CountDown/index.js +4 -4
- package/lib/DID/index.js +7 -9
- package/lib/Datatable/CustomToolbar.js +2 -2
- package/lib/Datatable/index.js +49 -49
- package/lib/Datatable/utils.js +2 -3
- package/lib/Dialog/confirm.js +5 -113
- package/lib/Dialog/dialog.js +14 -18
- package/lib/Dialog/index.js +3 -4
- package/lib/Dialog/use-confirm.js +126 -0
- package/lib/Earth/index.js +7 -8
- package/lib/Empty/index.js +5 -6
- package/lib/Header/auto-hidden.js +5 -6
- package/lib/Header/header.js +5 -6
- package/lib/Header/responsive-header.js +5 -6
- package/lib/Icon/image.js +4 -4
- package/lib/Icon/index.js +6 -7
- package/lib/Img/index.js +5 -6
- package/lib/InfoRow/index.js +5 -6
- package/lib/Layout/dashboard/external-link.js +4 -4
- package/lib/Layout/dashboard/full-page.js +5 -6
- package/lib/Layout/dashboard/index.js +4 -4
- package/lib/Layout/dashboard/sidebar.js +5 -6
- package/lib/Layout/dashboard-legacy/header.js +4 -4
- package/lib/Layout/dashboard-legacy/index.js +4 -4
- package/lib/Layout/dashboard-legacy/sidebar.js +4 -4
- package/lib/Layout/index.js +4 -4
- package/lib/Locale/browser-lang.js +1 -2
- package/lib/Locale/context.js +6 -8
- package/lib/Locale/languages.js +7 -9
- package/lib/Locale/selector.js +5 -5
- package/lib/Locale/util.js +12 -11
- package/lib/Logo/index.js +4 -4
- package/lib/NFTDisplay/aspect-ratio-container.js +5 -6
- package/lib/NFTDisplay/broken.js +4 -4
- package/lib/NFTDisplay/index.js +5 -7
- package/lib/NFTDisplay/svg-embedder/img.js +5 -6
- package/lib/NFTDisplay/svg-embedder/inline-svg.js +5 -6
- package/lib/NavMenu/nav-menu.js +5 -6
- package/lib/NavMenu/style.js +2 -4
- package/lib/PageScroller/index.js +6 -7
- package/lib/Passport/index.js +9 -0
- package/lib/Passport/passport.js +116 -0
- package/lib/PoweredByArcBlock/index.js +4 -4
- package/lib/PricingTable/PricingPlan.js +1 -2
- package/lib/PricingTable/index.js +1 -2
- package/lib/QRCode/index.js +5 -6
- package/lib/RelativeTime/index.js +4 -4
- package/lib/Result/common.js +4 -4
- package/lib/Result/index.js +7 -8
- package/lib/Result/result.js +5 -6
- package/lib/Result/translations.js +2 -3
- package/lib/Screenshot/BaseScreenshot/index.js +5 -6
- package/lib/Screenshot/BaseScreenshot/shells/Macbook.js +10 -15
- package/lib/Screenshot/BaseScreenshot/shells/Phone.js +10 -15
- package/lib/Screenshot/index.js +5 -6
- package/lib/SessionBlocklet/index.js +5 -5
- package/lib/SessionManager/index.js +1 -2
- package/lib/SessionUser/components/logged-in.js +5 -5
- package/lib/SessionUser/components/session-user-item.js +5 -6
- package/lib/SessionUser/components/session-user-switch.js +4 -4
- package/lib/SessionUser/components/un-login.js +1 -1
- package/lib/SessionUser/components/user-info.js +1 -1
- package/lib/SessionUser/index.js +2 -2
- package/lib/SessionUser/libs/translation.js +2 -3
- package/lib/Spinner/index.js +13 -14
- package/lib/SplitButton/index.js +4 -4
- package/lib/Switch/index.js +5 -6
- package/lib/Tabs/index.js +98 -11
- package/lib/Tag/index.js +5 -6
- package/lib/TextCollapse/index.js +5 -6
- package/lib/Theme/index.js +6 -7
- package/lib/Theme/theme.js +18 -11
- package/lib/Toast/index.js +12 -13
- package/lib/Typography/index.js +4 -4
- package/lib/Util/constant.js +10 -20
- package/lib/Util/deprecate.js +4 -4
- package/lib/Util/index.js +2 -4
- package/lib/Util/passport.js +72 -0
- package/lib/Util/wallet.js +1 -2
- package/lib/Video/index.js +4 -4
- package/lib/Wallet/Action.js +4 -4
- package/lib/Wallet/Download.js +4 -4
- package/lib/WebWalletSWKeeper/index.js +5 -6
- package/lib/withTheme/index.js +5 -6
- package/lib/withTracker/error_boundary.js +2 -2
- package/lib/withTracker/index.js +8 -9
- package/package.json +12 -6
- package/src/Address/did-address.jsx +15 -12
- package/src/Colors/themes/temp.js +9 -0
- package/src/Dialog/confirm.jsx +94 -0
- package/src/Dialog/{dialog.js → dialog.jsx} +14 -7
- package/src/Dialog/index.js +1 -1
- package/src/Dialog/use-confirm.jsx +114 -0
- package/src/Locale/selector.jsx +1 -1
- package/src/Locale/util.js +12 -5
- package/src/Passport/index.jsx +3 -0
- package/src/Passport/passport.jsx +99 -0
- package/src/SessionBlocklet/index.jsx +1 -1
- package/src/SessionUser/components/logged-in.jsx +1 -1
- package/src/SessionUser/components/un-login.jsx +1 -1
- package/src/SessionUser/components/user-info.jsx +1 -1
- package/src/SessionUser/index.jsx +1 -1
- package/src/Tabs/index.jsx +124 -0
- package/src/Theme/theme.js +13 -3
- package/src/Util/passport.js +75 -0
- package/src/Dialog/confirm.js +0 -201
- package/src/Tabs/index.js +0 -45
package/lib/withTracker/index.js
CHANGED
|
@@ -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(
|
|
14
|
-
function _interopRequireWildcard(
|
|
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(
|
|
17
|
-
function _objectSpread(
|
|
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(
|
|
20
|
-
function _toPrimitive(
|
|
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.
|
|
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": "
|
|
347
|
+
"gitHead": "2402b2d3888dcac685215c373afd7651e6907acc",
|
|
344
348
|
"dependencies": {
|
|
345
349
|
"@arcblock/did-motif": "^1.1.13",
|
|
346
|
-
"@arcblock/icons": "^2.9.
|
|
347
|
-
"@arcblock/
|
|
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/
|
|
352
|
-
"@fontsource/ubuntu-mono": "^
|
|
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
|
-
|
|
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 &&
|
|
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">
|
package/src/Dialog/index.js
CHANGED
|
@@ -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
|
+
}
|
package/src/Locale/selector.jsx
CHANGED
|
@@ -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';
|
package/src/Locale/util.js
CHANGED
|
@@ -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
|
-
|
|
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 &&
|
|
9
|
-
return replace(
|
|
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(
|
|
21
|
+
return replace(fallbackValue, data);
|
|
15
22
|
}
|
|
16
|
-
return replace(
|
|
23
|
+
return replace(translationValue, data);
|
|
17
24
|
};
|
|
18
25
|
|
|
19
26
|
export const t = translate;
|
|
@@ -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 '
|
|
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
|
|
|
@@ -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 '
|
|
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';
|
|
@@ -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,
|