@blocklet/ui-react 2.9.13 → 2.9.14
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/build.config.ts +29 -0
- package/es/@types/index.d.ts +63 -0
- package/es/@types/index.js +0 -0
- package/es/@types/shims.d.ts +12 -0
- package/es/Dashboard/index.d.ts +41 -0
- package/es/Dashboard/index.js +63 -97
- package/es/Footer/brand.d.ts +22 -0
- package/es/Footer/brand.js +20 -37
- package/es/Footer/copyright.d.ts +18 -0
- package/es/Footer/copyright.js +14 -16
- package/es/Footer/index.d.ts +6 -0
- package/es/Footer/index.js +30 -56
- package/es/Footer/internal-footer.d.ts +29 -0
- package/es/Footer/internal-footer.js +67 -94
- package/es/Footer/layout/plain.d.ts +15 -0
- package/es/Footer/layout/plain.js +19 -37
- package/es/Footer/layout/row.d.ts +18 -0
- package/es/Footer/layout/row.js +9 -19
- package/es/Footer/layout/standard.d.ts +15 -0
- package/es/Footer/layout/standard.js +29 -57
- package/es/Footer/links.d.ts +22 -0
- package/es/Footer/links.js +72 -104
- package/es/Footer/social-media.d.ts +14 -0
- package/es/Footer/social-media.js +35 -35
- package/es/Header/index.d.ts +9 -0
- package/es/Header/index.js +55 -100
- package/es/Icon/index.d.ts +23 -0
- package/es/Icon/index.js +23 -58
- package/es/UserCenter/assets/banner.png +0 -0
- package/es/UserCenter/components/notification.d.ts +5 -0
- package/es/UserCenter/components/notification.js +276 -0
- package/es/UserCenter/components/passport.d.ts +6 -0
- package/es/UserCenter/components/passport.js +69 -0
- package/es/UserCenter/components/privacy.d.ts +11 -0
- package/es/UserCenter/components/privacy.js +99 -0
- package/es/UserCenter/components/settings.d.ts +10 -0
- package/es/UserCenter/components/settings.js +68 -0
- package/es/UserCenter/components/user-basic-info.d.ts +8 -0
- package/es/UserCenter/components/user-basic-info.js +66 -0
- package/es/UserCenter/components/user-center.d.ts +9 -0
- package/es/UserCenter/components/user-center.js +397 -0
- package/es/UserCenter/components/user-info-item.d.ts +10 -0
- package/es/UserCenter/components/user-info-item.js +54 -0
- package/es/UserCenter/components/user-info.d.ts +6 -0
- package/es/UserCenter/components/user-info.js +68 -0
- package/es/UserCenter/components/webhook-item.d.ts +3 -0
- package/es/UserCenter/components/webhook-item.js +243 -0
- package/es/UserCenter/index.d.ts +1 -0
- package/es/UserCenter/index.js +1 -0
- package/es/UserCenter/libs/client.d.ts +2 -0
- package/es/UserCenter/libs/client.js +2 -0
- package/es/UserCenter/libs/locales.d.ts +72 -0
- package/es/UserCenter/libs/locales.js +72 -0
- package/es/UserCenter/libs/utils.d.ts +4 -0
- package/es/UserCenter/libs/utils.js +14 -0
- package/es/blocklets.d.ts +16 -0
- package/es/blocklets.js +56 -45
- package/es/common/header-addons.d.ts +22 -0
- package/es/common/header-addons.js +41 -59
- package/es/common/link-blocker.d.ts +7 -0
- package/es/common/link-blocker.js +10 -17
- package/es/common/overridable-theme-provider.d.ts +18 -0
- package/es/common/overridable-theme-provider.js +6 -16
- package/es/common/wallet-hidden-topbar.d.ts +1 -0
- package/es/common/wallet-hidden-topbar.js +12 -10
- package/es/index.d.ts +5 -0
- package/es/index.js +5 -0
- package/es/types.d.ts +2 -0
- package/es/types.js +17 -11
- package/es/utils.d.ts +8 -0
- package/es/utils.js +21 -26
- package/lib/@types/index.d.ts +63 -0
- package/lib/@types/index.js +1 -0
- package/lib/@types/shims.d.ts +12 -0
- package/lib/Dashboard/index.d.ts +41 -0
- package/lib/Dashboard/index.js +44 -71
- package/lib/Footer/brand.d.ts +22 -0
- package/lib/Footer/brand.js +65 -30
- package/lib/Footer/copyright.d.ts +18 -0
- package/lib/Footer/copyright.js +18 -23
- package/lib/Footer/index.d.ts +6 -0
- package/lib/Footer/index.js +33 -42
- package/lib/Footer/internal-footer.d.ts +29 -0
- package/lib/Footer/internal-footer.js +43 -59
- package/lib/Footer/layout/plain.d.ts +15 -0
- package/lib/Footer/layout/plain.js +25 -30
- package/lib/Footer/layout/row.d.ts +18 -0
- package/lib/Footer/layout/row.js +34 -23
- package/lib/Footer/layout/standard.d.ts +15 -0
- package/lib/Footer/layout/standard.js +35 -41
- package/lib/Footer/links.d.ts +22 -0
- package/lib/Footer/links.js +163 -60
- package/lib/Footer/social-media.d.ts +14 -0
- package/lib/Footer/social-media.js +31 -25
- package/lib/Header/index.d.ts +9 -0
- package/lib/Header/index.js +83 -76
- package/lib/Icon/index.d.ts +23 -0
- package/lib/Icon/index.js +37 -51
- package/lib/UserCenter/assets/banner.png +0 -0
- package/lib/UserCenter/components/notification.d.ts +5 -0
- package/lib/UserCenter/components/notification.js +261 -0
- package/lib/UserCenter/components/passport.d.ts +6 -0
- package/lib/UserCenter/components/passport.js +86 -0
- package/lib/UserCenter/components/privacy.d.ts +11 -0
- package/lib/UserCenter/components/privacy.js +101 -0
- package/lib/UserCenter/components/settings.d.ts +10 -0
- package/lib/UserCenter/components/settings.js +81 -0
- package/lib/UserCenter/components/user-basic-info.d.ts +8 -0
- package/lib/UserCenter/components/user-basic-info.js +67 -0
- package/lib/UserCenter/components/user-center.d.ts +9 -0
- package/lib/UserCenter/components/user-center.js +376 -0
- package/lib/UserCenter/components/user-info-item.d.ts +10 -0
- package/lib/UserCenter/components/user-info-item.js +46 -0
- package/lib/UserCenter/components/user-info.d.ts +6 -0
- package/lib/UserCenter/components/user-info.js +94 -0
- package/lib/UserCenter/components/webhook-item.d.ts +3 -0
- package/lib/UserCenter/components/webhook-item.js +236 -0
- package/lib/UserCenter/index.d.ts +1 -0
- package/lib/UserCenter/index.js +13 -0
- package/lib/UserCenter/libs/client.d.ts +2 -0
- package/lib/UserCenter/libs/client.js +8 -0
- package/lib/UserCenter/libs/locales.d.ts +72 -0
- package/lib/UserCenter/libs/locales.js +78 -0
- package/lib/UserCenter/libs/utils.d.ts +4 -0
- package/lib/UserCenter/libs/utils.js +25 -0
- package/lib/blocklets.d.ts +16 -0
- package/lib/blocklets.js +28 -36
- package/lib/common/header-addons.d.ts +22 -0
- package/lib/common/header-addons.js +24 -36
- package/lib/common/link-blocker.d.ts +7 -0
- package/lib/common/link-blocker.js +10 -18
- package/lib/common/overridable-theme-provider.d.ts +18 -0
- package/lib/common/overridable-theme-provider.js +9 -14
- package/lib/common/wallet-hidden-topbar.d.ts +1 -0
- package/lib/common/wallet-hidden-topbar.js +1 -3
- package/lib/index.d.ts +5 -0
- package/lib/index.js +52 -0
- package/lib/types.d.ts +2 -0
- package/lib/types.js +3 -5
- package/lib/utils.d.ts +8 -0
- package/lib/utils.js +16 -23
- package/package.json +17 -11
- package/src/@types/index.ts +70 -0
- package/src/@types/shims.d.ts +12 -0
- package/src/UserCenter/assets/banner.png +0 -0
- package/src/UserCenter/components/notification.tsx +275 -0
- package/src/UserCenter/components/passport.tsx +83 -0
- package/src/UserCenter/components/privacy.tsx +107 -0
- package/src/UserCenter/components/settings.tsx +78 -0
- package/src/UserCenter/components/user-basic-info.tsx +70 -0
- package/src/UserCenter/components/user-center.tsx +410 -0
- package/src/UserCenter/components/user-info-item.tsx +50 -0
- package/src/UserCenter/components/user-info.tsx +85 -0
- package/src/UserCenter/components/webhook-item.tsx +243 -0
- package/src/UserCenter/index.tsx +1 -0
- package/src/UserCenter/libs/client.ts +3 -0
- package/src/UserCenter/libs/locales.ts +72 -0
- package/src/UserCenter/libs/utils.ts +21 -0
- package/src/blocklets.js +2 -0
- package/src/index.ts +9 -0
- /package/src/common/{link-blocker.js → link-blocker.jsx} +0 -0
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Icon 组件, 基于 mui Avatar 组件扩展对 iconify 的支持
|
|
3
|
+
*/
|
|
4
|
+
declare function Icon({ icon, size, sx, ...rest }: {
|
|
5
|
+
[x: string]: any;
|
|
6
|
+
icon: any;
|
|
7
|
+
size: any;
|
|
8
|
+
sx: any;
|
|
9
|
+
}): import("react").JSX.Element | null;
|
|
10
|
+
declare namespace Icon {
|
|
11
|
+
namespace propTypes {
|
|
12
|
+
let icon: any;
|
|
13
|
+
let size: any;
|
|
14
|
+
let sx: any;
|
|
15
|
+
}
|
|
16
|
+
namespace defaultProps {
|
|
17
|
+
let size_1: null;
|
|
18
|
+
export { size_1 as size };
|
|
19
|
+
let sx_1: null;
|
|
20
|
+
export { sx_1 as sx };
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export default Icon;
|
package/lib/Icon/index.js
CHANGED
|
@@ -3,31 +3,19 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports
|
|
6
|
+
module.exports = Icon;
|
|
7
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
7
8
|
require("iconify-icon");
|
|
8
9
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
10
|
var _Avatar = _interopRequireDefault(require("@mui/material/Avatar"));
|
|
10
11
|
var _utils = require("../utils");
|
|
11
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
-
const _excluded = ["icon", "size", "sx"];
|
|
13
|
-
/**
|
|
14
|
-
* Icon 组件, 基于 mui Avatar 组件扩展对 iconify 的支持
|
|
15
|
-
*/
|
|
16
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
17
|
-
function
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
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; }
|
|
24
|
-
function Icon(_ref) {
|
|
25
|
-
let {
|
|
26
|
-
icon,
|
|
27
|
-
size,
|
|
28
|
-
sx
|
|
29
|
-
} = _ref,
|
|
30
|
-
rest = _objectWithoutProperties(_ref, _excluded);
|
|
13
|
+
function Icon({
|
|
14
|
+
icon,
|
|
15
|
+
size,
|
|
16
|
+
sx,
|
|
17
|
+
...rest
|
|
18
|
+
}) {
|
|
31
19
|
const _sx = [...(Array.isArray(sx) ? sx : [sx])];
|
|
32
20
|
if (size) {
|
|
33
21
|
_sx.push({
|
|
@@ -35,58 +23,56 @@ function Icon(_ref) {
|
|
|
35
23
|
height: size
|
|
36
24
|
});
|
|
37
25
|
}
|
|
38
|
-
// 禁用默认的 circular variant 样式
|
|
39
26
|
if (!rest.variant) {
|
|
40
27
|
_sx.push({
|
|
41
|
-
|
|
42
|
-
color:
|
|
43
|
-
fontWeight:
|
|
44
|
-
backgroundColor:
|
|
28
|
+
"&.MuiAvatar-root": {
|
|
29
|
+
color: "inherit",
|
|
30
|
+
fontWeight: "bold",
|
|
31
|
+
backgroundColor: "transparent",
|
|
45
32
|
borderRadius: 0
|
|
46
33
|
},
|
|
47
34
|
// 无 icon 背景时, svg icon 尺寸与窗口尺寸一致
|
|
48
|
-
|
|
49
|
-
width:
|
|
50
|
-
height:
|
|
35
|
+
"&.MuiAvatar-root svg": {
|
|
36
|
+
width: "100%",
|
|
37
|
+
height: "100%"
|
|
51
38
|
}
|
|
52
39
|
});
|
|
53
40
|
}
|
|
54
41
|
if ((0, _utils.isUrl)(icon)) {
|
|
55
|
-
return
|
|
56
|
-
as: "span"
|
|
57
|
-
|
|
42
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_Avatar.default, {
|
|
43
|
+
as: "span",
|
|
44
|
+
...rest,
|
|
58
45
|
src: icon,
|
|
59
46
|
sx: _sx
|
|
60
|
-
})
|
|
47
|
+
});
|
|
61
48
|
}
|
|
62
49
|
if ((0, _utils.isIconifyString)(icon)) {
|
|
63
|
-
// y = 0.6 * x + 4
|
|
64
50
|
const height = size ? 0.6 * size + 4 : 0;
|
|
65
|
-
return
|
|
66
|
-
as: "span"
|
|
67
|
-
|
|
51
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_Avatar.default, {
|
|
52
|
+
as: "span",
|
|
53
|
+
...rest,
|
|
68
54
|
sx: _sx,
|
|
69
|
-
children:
|
|
70
|
-
icon
|
|
71
|
-
height: height ||
|
|
55
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)("iconify-icon", {
|
|
56
|
+
icon,
|
|
57
|
+
height: height || void 0
|
|
72
58
|
})
|
|
73
|
-
})
|
|
59
|
+
});
|
|
74
60
|
}
|
|
75
|
-
|
|
76
|
-
if (icon && typeof icon === 'string') {
|
|
61
|
+
if (icon && typeof icon === "string") {
|
|
77
62
|
_sx.push({
|
|
78
|
-
|
|
79
|
-
display:
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
63
|
+
"&.MuiAvatar-root": {
|
|
64
|
+
display: "inline-flex",
|
|
65
|
+
...(size && {
|
|
66
|
+
fontSize: size - 2
|
|
67
|
+
})
|
|
68
|
+
}
|
|
83
69
|
});
|
|
84
|
-
return
|
|
85
|
-
as: "span"
|
|
86
|
-
|
|
70
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_Avatar.default, {
|
|
71
|
+
as: "span",
|
|
72
|
+
...rest,
|
|
87
73
|
sx: _sx,
|
|
88
74
|
children: Array.from(icon)[0]
|
|
89
|
-
})
|
|
75
|
+
});
|
|
90
76
|
}
|
|
91
77
|
return null;
|
|
92
78
|
}
|
|
Binary file
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
module.exports = Notification;
|
|
7
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
8
|
+
var _material = require("@mui/material");
|
|
9
|
+
var _ahooks = require("ahooks");
|
|
10
|
+
var _react = require("@iconify/react");
|
|
11
|
+
var _addRounded = _interopRequireDefault(require("@iconify-icons/material-symbols/add-rounded"));
|
|
12
|
+
var _Switch = _interopRequireDefault(require("@arcblock/ux/lib/Switch"));
|
|
13
|
+
var _Button = _interopRequireDefault(require("@arcblock/ux/lib/Button"));
|
|
14
|
+
var _Colors = require("@arcblock/ux/lib/Colors");
|
|
15
|
+
var _Toast = _interopRequireDefault(require("@arcblock/ux/lib/Toast"));
|
|
16
|
+
var _utils = require("@arcblock/ux/lib/SessionUser/libs/utils");
|
|
17
|
+
var _util = require("@arcblock/ux/lib/Locale/util");
|
|
18
|
+
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
19
|
+
var _locales = require("../libs/locales");
|
|
20
|
+
var _webhookItem = _interopRequireDefault(require("./webhook-item"));
|
|
21
|
+
var _utils2 = require("../libs/utils");
|
|
22
|
+
var _client = require("../libs/client");
|
|
23
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
24
|
+
function Notification({
|
|
25
|
+
user
|
|
26
|
+
}) {
|
|
27
|
+
const {
|
|
28
|
+
locale
|
|
29
|
+
} = (0, _context.useLocaleContext)();
|
|
30
|
+
const t = (0, _ahooks.useMemoizedFn)((key, data = {}) => {
|
|
31
|
+
return (0, _util.translate)(_locales.translations, key, locale, "en", data);
|
|
32
|
+
});
|
|
33
|
+
const currentState = (0, _ahooks.useReactive)({
|
|
34
|
+
showAdd: false
|
|
35
|
+
});
|
|
36
|
+
const notificationConfigState = (0, _ahooks.useRequest)(async () => {
|
|
37
|
+
const data = await _client.client.user.getUserNotificationConfig();
|
|
38
|
+
return data;
|
|
39
|
+
}, {
|
|
40
|
+
refreshDeps: [user],
|
|
41
|
+
loadingDelay: 300
|
|
42
|
+
});
|
|
43
|
+
const notifications = (0, _ahooks.useCreation)(() => {
|
|
44
|
+
return {
|
|
45
|
+
wallet: true,
|
|
46
|
+
email: true,
|
|
47
|
+
phone: false,
|
|
48
|
+
...(notificationConfigState?.data?.notifications || {})
|
|
49
|
+
};
|
|
50
|
+
}, [notificationConfigState?.data?.notifications]);
|
|
51
|
+
const webhooks = (0, _ahooks.useCreation)(() => {
|
|
52
|
+
return notificationConfigState?.data?.webhooks || [];
|
|
53
|
+
}, [notificationConfigState?.data?.webhooks]);
|
|
54
|
+
const onSaveChanges = (0, _ahooks.useMemoizedFn)(async values => {
|
|
55
|
+
try {
|
|
56
|
+
await _client.client.user.saveUserNotificationConfig(values);
|
|
57
|
+
_Toast.default.success(t("saveSuccess"));
|
|
58
|
+
notificationConfigState.run();
|
|
59
|
+
} catch (err) {
|
|
60
|
+
_Toast.default.error((0, _utils2.formatAxiosError)(err));
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
const handleChangeSwitch = (0, _ahooks.useMemoizedFn)(async (channel, value) => {
|
|
64
|
+
await onSaveChanges({
|
|
65
|
+
notifications: {
|
|
66
|
+
[channel]: value
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
});
|
|
70
|
+
const handleTestWebhook = async data => {
|
|
71
|
+
try {
|
|
72
|
+
await _client.client.user.testNotificationWebhook(data);
|
|
73
|
+
_Toast.default.success(t("webhookTested"));
|
|
74
|
+
} catch (err) {
|
|
75
|
+
_Toast.default.error((0, _utils2.formatAxiosError)(err));
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
const handleDeleteWebhook = (0, _ahooks.useMemoizedFn)(async index => {
|
|
79
|
+
await onSaveChanges({
|
|
80
|
+
webhooks: webhooks.filter((_, i) => i !== index)
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
const handleEditWebhook = (0, _ahooks.useMemoizedFn)(async (index, webhook) => {
|
|
84
|
+
await onSaveChanges({
|
|
85
|
+
webhooks: webhooks.map((item, i) => i === index ? webhook : item)
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
const handleAddWebhook = (0, _ahooks.useMemoizedFn)(async webhook => {
|
|
89
|
+
await onSaveChanges({
|
|
90
|
+
webhooks: [...webhooks, webhook]
|
|
91
|
+
});
|
|
92
|
+
currentState.showAdd = false;
|
|
93
|
+
});
|
|
94
|
+
if (notificationConfigState.error) {
|
|
95
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Alert, {
|
|
96
|
+
severity: "error",
|
|
97
|
+
children: notificationConfigState.error.message
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
if (notificationConfigState.loading || !notificationConfigState.data) {
|
|
101
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
102
|
+
sx: {
|
|
103
|
+
display: "flex",
|
|
104
|
+
justifyContent: "center",
|
|
105
|
+
alignItems: "center",
|
|
106
|
+
height: "100px"
|
|
107
|
+
},
|
|
108
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.CircularProgress, {})
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
112
|
+
sx: {
|
|
113
|
+
display: "flex",
|
|
114
|
+
flexDirection: "column",
|
|
115
|
+
gap: 2
|
|
116
|
+
},
|
|
117
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
118
|
+
sx: {
|
|
119
|
+
display: "flex",
|
|
120
|
+
flexDirection: "column",
|
|
121
|
+
gap: 1,
|
|
122
|
+
alignItems: "start",
|
|
123
|
+
".MuiFormControlLabel-root": {
|
|
124
|
+
gap: 1,
|
|
125
|
+
m: 0,
|
|
126
|
+
flexDirection: {
|
|
127
|
+
xs: "row-reverse",
|
|
128
|
+
md: "row"
|
|
129
|
+
},
|
|
130
|
+
width: {
|
|
131
|
+
xs: "100%",
|
|
132
|
+
md: "unset"
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
".MuiSwitch-track": {
|
|
136
|
+
borderRadius: "100vw"
|
|
137
|
+
},
|
|
138
|
+
".MuiSwitch-thumb": {
|
|
139
|
+
borderRadius: "100%"
|
|
140
|
+
},
|
|
141
|
+
".MuiSwitch-root.MuiSwitch-sizeSmall": {
|
|
142
|
+
height: "20px",
|
|
143
|
+
width: "36px",
|
|
144
|
+
".MuiSwitch-thumb": {
|
|
145
|
+
width: "16px",
|
|
146
|
+
height: "16px"
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
},
|
|
150
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_Switch.default, {
|
|
151
|
+
checked: notifications.wallet,
|
|
152
|
+
labelProps: {
|
|
153
|
+
label: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
|
|
154
|
+
color: "text.primary",
|
|
155
|
+
sx: {
|
|
156
|
+
fontSize: 14,
|
|
157
|
+
display: "flex",
|
|
158
|
+
flexFlow: "wrap",
|
|
159
|
+
columnGap: 1,
|
|
160
|
+
flex: 1
|
|
161
|
+
},
|
|
162
|
+
children: [t("walletNotification"), (0, _utils.getWalletDid)(user) && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
163
|
+
component: "span",
|
|
164
|
+
color: "text.secondary",
|
|
165
|
+
fontSize: 13,
|
|
166
|
+
children: (0, _utils.getWalletDid)(user)
|
|
167
|
+
})]
|
|
168
|
+
})
|
|
169
|
+
},
|
|
170
|
+
size: "small",
|
|
171
|
+
onChange: event => handleChangeSwitch("wallet", event.target.checked)
|
|
172
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_Switch.default, {
|
|
173
|
+
checked: notifications.email,
|
|
174
|
+
labelProps: {
|
|
175
|
+
label: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
|
|
176
|
+
color: "text.primary",
|
|
177
|
+
sx: {
|
|
178
|
+
fontSize: 14,
|
|
179
|
+
display: "flex",
|
|
180
|
+
flexFlow: "wrap",
|
|
181
|
+
columnGap: 1,
|
|
182
|
+
flex: 1
|
|
183
|
+
},
|
|
184
|
+
children: [t("emailNotification"), user?.email && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
185
|
+
component: "span",
|
|
186
|
+
color: "text.secondary",
|
|
187
|
+
fontSize: 13,
|
|
188
|
+
children: user?.email
|
|
189
|
+
})]
|
|
190
|
+
})
|
|
191
|
+
},
|
|
192
|
+
size: "small",
|
|
193
|
+
onChange: event => handleChangeSwitch("email", event.target.checked)
|
|
194
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_Switch.default, {
|
|
195
|
+
disabled: true,
|
|
196
|
+
checked: notifications.phone,
|
|
197
|
+
labelProps: {
|
|
198
|
+
label: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Typography, {
|
|
199
|
+
color: "text.primary",
|
|
200
|
+
sx: {
|
|
201
|
+
fontSize: 14,
|
|
202
|
+
display: "flex",
|
|
203
|
+
flexFlow: "wrap",
|
|
204
|
+
columnGap: 1,
|
|
205
|
+
flex: 1
|
|
206
|
+
},
|
|
207
|
+
children: [t("phoneNotification"), user?.phone && /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
208
|
+
component: "span",
|
|
209
|
+
color: "text.secondary",
|
|
210
|
+
fontSize: 13,
|
|
211
|
+
children: user?.phone
|
|
212
|
+
})]
|
|
213
|
+
})
|
|
214
|
+
},
|
|
215
|
+
size: "small",
|
|
216
|
+
onChange: event => handleChangeSwitch("phone", event.target.checked)
|
|
217
|
+
})]
|
|
218
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Divider, {}), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Stack, {
|
|
219
|
+
spacing: 1.5,
|
|
220
|
+
useFlexGap: true,
|
|
221
|
+
direction: "column",
|
|
222
|
+
alignItems: "start",
|
|
223
|
+
children: [webhooks.map((item, index) => /* @__PURE__ */(0, _jsxRuntime.jsx)(_webhookItem.default, {
|
|
224
|
+
onTest: handleTestWebhook,
|
|
225
|
+
onDelete: () => handleDeleteWebhook(index),
|
|
226
|
+
onSave: (...args) => handleEditWebhook(index, ...args),
|
|
227
|
+
type: item.type,
|
|
228
|
+
url: item.url,
|
|
229
|
+
edit: false
|
|
230
|
+
}, `${index}_${item.url}`)), currentState.showAdd && /* @__PURE__ */(0, _jsxRuntime.jsx)(_webhookItem.default, {
|
|
231
|
+
onTest: handleTestWebhook,
|
|
232
|
+
onCancel: () => {
|
|
233
|
+
currentState.showAdd = false;
|
|
234
|
+
},
|
|
235
|
+
onSave: (...args) => handleAddWebhook(...args),
|
|
236
|
+
edit: true
|
|
237
|
+
}, "add"), /* @__PURE__ */(0, _jsxRuntime.jsx)(_Button.default, {
|
|
238
|
+
variant: "outlined",
|
|
239
|
+
size: "small",
|
|
240
|
+
sx: {
|
|
241
|
+
color: _Colors.temp.foregroundsFgBase,
|
|
242
|
+
borderColor: _Colors.temp.strokeBorderBase,
|
|
243
|
+
backgroundColor: _Colors.temp.buttonsButtonNeutral,
|
|
244
|
+
"&:hover": {
|
|
245
|
+
borderColor: _Colors.temp.strokeBorderBase,
|
|
246
|
+
backgroundColor: _Colors.temp.buttonsButtonNeutralHover
|
|
247
|
+
},
|
|
248
|
+
py: 0.5,
|
|
249
|
+
borderRadius: 2
|
|
250
|
+
},
|
|
251
|
+
startIcon: /* @__PURE__ */(0, _jsxRuntime.jsx)(_react.Icon, {
|
|
252
|
+
icon: _addRounded.default
|
|
253
|
+
}),
|
|
254
|
+
onClick: () => {
|
|
255
|
+
currentState.showAdd = true;
|
|
256
|
+
},
|
|
257
|
+
children: t("addWebhook")
|
|
258
|
+
})]
|
|
259
|
+
})]
|
|
260
|
+
});
|
|
261
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
module.exports = Passport;
|
|
7
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
8
|
+
var _material = require("@mui/material");
|
|
9
|
+
var _Empty = _interopRequireDefault(require("@arcblock/ux/lib/Empty"));
|
|
10
|
+
var _Theme = require("@arcblock/ux/lib/Theme");
|
|
11
|
+
var _Colors = require("@arcblock/ux/lib/Colors");
|
|
12
|
+
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
13
|
+
var _Passport = _interopRequireDefault(require("@arcblock/ux/lib/Passport"));
|
|
14
|
+
var _constant = require("@abtnode/constant");
|
|
15
|
+
var _ahooks = require("ahooks");
|
|
16
|
+
var _uniqBy = _interopRequireDefault(require("lodash/uniqBy"));
|
|
17
|
+
var _utils = require("../libs/utils");
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
+
function Passport({
|
|
20
|
+
user,
|
|
21
|
+
...rest
|
|
22
|
+
}) {
|
|
23
|
+
const {
|
|
24
|
+
t
|
|
25
|
+
} = (0, _context.useLocaleContext)();
|
|
26
|
+
const theme = (0, _Theme.useTheme)();
|
|
27
|
+
const passports = (0, _ahooks.useCreation)(() => {
|
|
28
|
+
const passportList = (user?.passports || []).map(x => ({
|
|
29
|
+
...x,
|
|
30
|
+
revoked: x.status === _constant.PASSPORT_STATUS.REVOKED
|
|
31
|
+
}));
|
|
32
|
+
passportList.sort((a, b) => {
|
|
33
|
+
if (a.revoked === b.revoked) {
|
|
34
|
+
return 0;
|
|
35
|
+
}
|
|
36
|
+
if (a.revoked) {
|
|
37
|
+
return 1;
|
|
38
|
+
} else {
|
|
39
|
+
return -1;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
return (0, _uniqBy.default)(passportList, "role");
|
|
43
|
+
}, [user?.passports]);
|
|
44
|
+
const currentRole = (0, _ahooks.useCreation)(() => passports?.find(item => item.name === user.role), [passports, user?.role]);
|
|
45
|
+
const activeColor = (0, _ahooks.useCreation)(() => {
|
|
46
|
+
return theme?.palette?.primary?.main || _Colors.temp.textBase;
|
|
47
|
+
}, [theme?.palette?.primary?.main]);
|
|
48
|
+
if (passports.length === 0) {
|
|
49
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_Empty.default, {
|
|
50
|
+
children: t("noPassport")
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Stack, {
|
|
54
|
+
direction: "row",
|
|
55
|
+
spacing: 3,
|
|
56
|
+
flexWrap: "wrap",
|
|
57
|
+
useFlexGap: true,
|
|
58
|
+
...rest,
|
|
59
|
+
children: passports.map(x => /* @__PURE__ */(0, _jsxRuntime.jsx)(_Passport.default, {
|
|
60
|
+
passport: x,
|
|
61
|
+
user,
|
|
62
|
+
width: 200,
|
|
63
|
+
color: window.blocklet.passportColor,
|
|
64
|
+
createPassportSvg: _utils.createPassportSvg,
|
|
65
|
+
title: currentRole.role === x.role ? t("currentPassport") : "",
|
|
66
|
+
sx: {
|
|
67
|
+
flexDirection: "column",
|
|
68
|
+
alignItems: "center",
|
|
69
|
+
gap: 1,
|
|
70
|
+
".passport-item__display": {
|
|
71
|
+
width: 166,
|
|
72
|
+
height: 166,
|
|
73
|
+
borderRadius: 2,
|
|
74
|
+
px: 2,
|
|
75
|
+
display: "flex",
|
|
76
|
+
justifyContent: "center",
|
|
77
|
+
backgroundColor: "white",
|
|
78
|
+
boxShadow: currentRole.role === x.role ? `0px 2px 4px 0px ${activeColor}, 0px 1px 2px -1px ${activeColor}, 0px 0px 0px 1px ${activeColor} !important` : "0px 2px 4px 0px rgba(2, 7, 19, 0.04), 0px 1px 2px -1px rgba(2, 7, 19, 0.08), 0px 0px 0px 1px rgba(2, 7, 19, 0.08) !important"
|
|
79
|
+
},
|
|
80
|
+
".passport-item__body": {
|
|
81
|
+
marginLeft: "0 !important"
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
}, x.id))
|
|
85
|
+
});
|
|
86
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
type PrivacyConfig = {
|
|
3
|
+
key: string;
|
|
4
|
+
name: string;
|
|
5
|
+
value: boolean;
|
|
6
|
+
};
|
|
7
|
+
export default function Privacy({ configList, onSave }: {
|
|
8
|
+
configList: PrivacyConfig[];
|
|
9
|
+
onSave: () => void;
|
|
10
|
+
}): import("react").JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
module.exports = Privacy;
|
|
7
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
8
|
+
var _material = require("@mui/material");
|
|
9
|
+
var _Switch = _interopRequireDefault(require("@arcblock/ux/lib/Switch"));
|
|
10
|
+
var _react = require("react");
|
|
11
|
+
var _ahooks = require("ahooks");
|
|
12
|
+
var _util = require("@arcblock/ux/lib/Locale/util");
|
|
13
|
+
var _context = require("@arcblock/ux/lib/Locale/context");
|
|
14
|
+
var _Toast = _interopRequireDefault(require("@arcblock/ux/lib/Toast"));
|
|
15
|
+
var _locales = require("../libs/locales");
|
|
16
|
+
var _client = require("../libs/client");
|
|
17
|
+
var _utils = require("../libs/utils");
|
|
18
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
+
function Privacy({
|
|
20
|
+
configList,
|
|
21
|
+
onSave
|
|
22
|
+
}) {
|
|
23
|
+
const [dataList, setDataList] = (0, _react.useState)(configList);
|
|
24
|
+
const {
|
|
25
|
+
locale
|
|
26
|
+
} = (0, _context.useLocaleContext)();
|
|
27
|
+
const t = (0, _ahooks.useMemoizedFn)((key, data = {}) => {
|
|
28
|
+
return (0, _util.translate)(_locales.translations, key, locale, "en", data);
|
|
29
|
+
});
|
|
30
|
+
const handleChangeSwitch = (0, _ahooks.useMemoizedFn)(async (type, value) => {
|
|
31
|
+
try {
|
|
32
|
+
const result = await _client.client.user.saveUserPrivacyConfig({
|
|
33
|
+
[type]: !value
|
|
34
|
+
});
|
|
35
|
+
setDataList(dataList.map(item => {
|
|
36
|
+
return {
|
|
37
|
+
...item,
|
|
38
|
+
value: result?.[item.key] ?? item.value
|
|
39
|
+
};
|
|
40
|
+
}));
|
|
41
|
+
_Toast.default.success(t("saveSuccess"));
|
|
42
|
+
onSave();
|
|
43
|
+
} catch (err) {
|
|
44
|
+
_Toast.default.error((0, _utils.formatAxiosError)(err));
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
return /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
48
|
+
sx: {
|
|
49
|
+
display: "flex",
|
|
50
|
+
flexDirection: "column",
|
|
51
|
+
gap: 1,
|
|
52
|
+
alignItems: "start",
|
|
53
|
+
".MuiFormControlLabel-root": {
|
|
54
|
+
gap: 1,
|
|
55
|
+
m: 0,
|
|
56
|
+
flexDirection: {
|
|
57
|
+
xs: "row-reverse",
|
|
58
|
+
md: "row"
|
|
59
|
+
},
|
|
60
|
+
width: {
|
|
61
|
+
xs: "100%",
|
|
62
|
+
md: "unset"
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
".MuiSwitch-track": {
|
|
66
|
+
borderRadius: "100vw"
|
|
67
|
+
},
|
|
68
|
+
".MuiSwitch-thumb": {
|
|
69
|
+
borderRadius: "100%"
|
|
70
|
+
},
|
|
71
|
+
".MuiSwitch-root.MuiSwitch-sizeSmall": {
|
|
72
|
+
height: "20px",
|
|
73
|
+
width: "36px",
|
|
74
|
+
".MuiSwitch-thumb": {
|
|
75
|
+
width: "16px",
|
|
76
|
+
height: "16px"
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
children: dataList.map(item => /* @__PURE__ */(0, _jsxRuntime.jsx)(_Switch.default, {
|
|
81
|
+
checked: !item.value,
|
|
82
|
+
labelProps: {
|
|
83
|
+
label: /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
84
|
+
color: "text.primary",
|
|
85
|
+
sx: {
|
|
86
|
+
fontSize: 14,
|
|
87
|
+
display: "flex",
|
|
88
|
+
flexFlow: "wrap",
|
|
89
|
+
columnGap: 1,
|
|
90
|
+
flex: 1
|
|
91
|
+
},
|
|
92
|
+
children: t("toPublic", {
|
|
93
|
+
name: item.name
|
|
94
|
+
})
|
|
95
|
+
})
|
|
96
|
+
},
|
|
97
|
+
size: "small",
|
|
98
|
+
onChange: event => handleChangeSwitch(item.key, event.target.checked)
|
|
99
|
+
}, item.key))
|
|
100
|
+
});
|
|
101
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { BoxProps } from '@mui/material';
|
|
3
|
+
import { User, UserCenterTab } from '../../@types';
|
|
4
|
+
export default function Settings({ user, settings, onSave, ...rest }: {
|
|
5
|
+
user: User;
|
|
6
|
+
onSave: () => void;
|
|
7
|
+
settings: {
|
|
8
|
+
userCenterTabs: UserCenterTab[];
|
|
9
|
+
};
|
|
10
|
+
} & BoxProps): import("react").JSX.Element | undefined;
|