@blocklet/ui-react 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/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 +31 -57
- 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 +56 -101
- 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 +18 -11
- package/src/@types/index.ts +70 -0
- package/src/@types/shims.d.ts +12 -0
- package/src/Footer/index.jsx +1 -1
- package/src/Header/index.jsx +1 -1
- 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,243 @@
|
|
|
1
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import {
|
|
3
|
+
Box,
|
|
4
|
+
CircularProgress,
|
|
5
|
+
IconButton,
|
|
6
|
+
InputAdornment,
|
|
7
|
+
MenuItem,
|
|
8
|
+
Select,
|
|
9
|
+
TextField,
|
|
10
|
+
Typography
|
|
11
|
+
} from "@mui/material";
|
|
12
|
+
import { useCreation, useMemoizedFn, useReactive } from "ahooks";
|
|
13
|
+
import noop from "lodash/noop";
|
|
14
|
+
import isUrl from "is-url";
|
|
15
|
+
import { temp as colors } from "@arcblock/ux/lib/Colors";
|
|
16
|
+
import { Icon } from "@iconify/react";
|
|
17
|
+
import CloseRoundedIcon from "@iconify-icons/material-symbols/close-rounded";
|
|
18
|
+
import CheckIcon from "@iconify-icons/material-symbols/check";
|
|
19
|
+
import SendRoundedIcon from "@iconify-icons/material-symbols/send-rounded";
|
|
20
|
+
import EditSquareOutlineRoundedIcon from "@iconify-icons/material-symbols/edit-square-outline-rounded";
|
|
21
|
+
import DeleteOutlineRoundedIcon from "@iconify-icons/material-symbols/delete-outline-rounded";
|
|
22
|
+
import { translate } from "@arcblock/ux/lib/Locale/util";
|
|
23
|
+
import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
|
|
24
|
+
import { translations } from "../libs/locales.js";
|
|
25
|
+
export default function WebhookItem({
|
|
26
|
+
onTest = noop,
|
|
27
|
+
onDelete = noop,
|
|
28
|
+
onSave = noop,
|
|
29
|
+
onCancel = noop,
|
|
30
|
+
type = "slack",
|
|
31
|
+
url = "",
|
|
32
|
+
edit = false
|
|
33
|
+
}) {
|
|
34
|
+
const { locale } = useLocaleContext();
|
|
35
|
+
const t = useMemoizedFn((key, data = {}) => {
|
|
36
|
+
return translate(translations, key, locale, "en", data);
|
|
37
|
+
});
|
|
38
|
+
const currentState = useReactive({
|
|
39
|
+
type: type || "slack",
|
|
40
|
+
url: url || "",
|
|
41
|
+
edit: edit ?? false,
|
|
42
|
+
error: "",
|
|
43
|
+
loading: false
|
|
44
|
+
});
|
|
45
|
+
const checkUrl = useMemoizedFn(() => {
|
|
46
|
+
if (!currentState.url) {
|
|
47
|
+
currentState.error = t("common.required");
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
if (!isUrl(currentState.url)) {
|
|
51
|
+
currentState.error = t("common.invalid");
|
|
52
|
+
return false;
|
|
53
|
+
}
|
|
54
|
+
currentState.error = "";
|
|
55
|
+
return true;
|
|
56
|
+
});
|
|
57
|
+
const handleClose = useMemoizedFn(() => {
|
|
58
|
+
currentState.edit = false;
|
|
59
|
+
currentState.url = url || "";
|
|
60
|
+
currentState.type = type || "slack";
|
|
61
|
+
currentState.error = "";
|
|
62
|
+
currentState.loading = false;
|
|
63
|
+
onCancel();
|
|
64
|
+
});
|
|
65
|
+
const _onTest = useMemoizedFn(async (data) => {
|
|
66
|
+
currentState.loading = true;
|
|
67
|
+
await onTest(data);
|
|
68
|
+
currentState.loading = false;
|
|
69
|
+
});
|
|
70
|
+
const onSubmit = useMemoizedFn((fn) => {
|
|
71
|
+
return () => {
|
|
72
|
+
if (checkUrl()) {
|
|
73
|
+
fn({
|
|
74
|
+
type: currentState.type,
|
|
75
|
+
url: currentState.url
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
});
|
|
80
|
+
const inputAdornment = useCreation(() => {
|
|
81
|
+
if (currentState.error) {
|
|
82
|
+
return /* @__PURE__ */ jsx(Typography, { component: "span", color: "error", children: currentState.error });
|
|
83
|
+
}
|
|
84
|
+
if (currentState.edit) {
|
|
85
|
+
if (currentState.loading) {
|
|
86
|
+
return /* @__PURE__ */ jsx(CircularProgress, { size: 16 });
|
|
87
|
+
}
|
|
88
|
+
return /* @__PURE__ */ jsx(
|
|
89
|
+
IconButton,
|
|
90
|
+
{
|
|
91
|
+
size: "small",
|
|
92
|
+
onClick: onSubmit(_onTest),
|
|
93
|
+
sx: {
|
|
94
|
+
mr: -1
|
|
95
|
+
},
|
|
96
|
+
children: /* @__PURE__ */ jsx(Icon, { icon: SendRoundedIcon })
|
|
97
|
+
}
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
return null;
|
|
101
|
+
}, [currentState.error, currentState.edit, currentState.loading]);
|
|
102
|
+
return /* @__PURE__ */ jsxs(
|
|
103
|
+
Box,
|
|
104
|
+
{
|
|
105
|
+
sx: {
|
|
106
|
+
display: "flex",
|
|
107
|
+
gap: 1.5,
|
|
108
|
+
width: "100%",
|
|
109
|
+
alignItems: {
|
|
110
|
+
xs: "flex-start",
|
|
111
|
+
md: "center"
|
|
112
|
+
},
|
|
113
|
+
flexDirection: {
|
|
114
|
+
xs: "column",
|
|
115
|
+
md: "row"
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
children: [
|
|
119
|
+
/* @__PURE__ */ jsxs(
|
|
120
|
+
Select,
|
|
121
|
+
{
|
|
122
|
+
sx: {
|
|
123
|
+
borderRadius: 2,
|
|
124
|
+
"&.Mui-disabled": {
|
|
125
|
+
backgroundColor: colors.backgroundsBgField
|
|
126
|
+
}
|
|
127
|
+
},
|
|
128
|
+
disabled: !currentState.edit || currentState.loading,
|
|
129
|
+
size: "small",
|
|
130
|
+
value: currentState.type,
|
|
131
|
+
onChange: (e) => {
|
|
132
|
+
currentState.type = e.target.value;
|
|
133
|
+
},
|
|
134
|
+
children: [
|
|
135
|
+
/* @__PURE__ */ jsx(MenuItem, { value: "api", children: t("webhook.url") }),
|
|
136
|
+
/* @__PURE__ */ jsx(MenuItem, { value: "slack", children: t("webhook.slack") })
|
|
137
|
+
]
|
|
138
|
+
}
|
|
139
|
+
),
|
|
140
|
+
/* @__PURE__ */ jsxs(
|
|
141
|
+
Box,
|
|
142
|
+
{
|
|
143
|
+
sx: {
|
|
144
|
+
display: "flex",
|
|
145
|
+
alignItems: "center",
|
|
146
|
+
gap: 0.5,
|
|
147
|
+
width: "100%"
|
|
148
|
+
},
|
|
149
|
+
children: [
|
|
150
|
+
/* @__PURE__ */ jsx(
|
|
151
|
+
TextField,
|
|
152
|
+
{
|
|
153
|
+
sx: {
|
|
154
|
+
flex: 1,
|
|
155
|
+
".MuiInputBase-root": {
|
|
156
|
+
borderRadius: 2,
|
|
157
|
+
"&.Mui-disabled": {
|
|
158
|
+
backgroundColor: colors.backgroundsBgField
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
},
|
|
162
|
+
disabled: !currentState.edit || currentState.loading,
|
|
163
|
+
fullWidth: true,
|
|
164
|
+
size: "small",
|
|
165
|
+
required: true,
|
|
166
|
+
value: currentState.url,
|
|
167
|
+
onChange: (e) => {
|
|
168
|
+
currentState.url = e.target.value;
|
|
169
|
+
checkUrl();
|
|
170
|
+
},
|
|
171
|
+
error: !!currentState.error,
|
|
172
|
+
InputProps: {
|
|
173
|
+
endAdornment: /* @__PURE__ */ jsx(InputAdornment, { position: "end", children: inputAdornment })
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
),
|
|
177
|
+
/* @__PURE__ */ jsx(Box, { sx: { display: "flex", gap: 0.5 }, children: currentState.edit ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
178
|
+
/* @__PURE__ */ jsx(
|
|
179
|
+
IconButton,
|
|
180
|
+
{
|
|
181
|
+
color: "success",
|
|
182
|
+
onClick: onSubmit((...args) => {
|
|
183
|
+
onSave(...args);
|
|
184
|
+
currentState.edit = false;
|
|
185
|
+
}),
|
|
186
|
+
sx: {
|
|
187
|
+
borderRadius: 2,
|
|
188
|
+
border: `1px solid ${colors.strokeBorderBase}`
|
|
189
|
+
},
|
|
190
|
+
children: /* @__PURE__ */ jsx(Icon, { icon: CheckIcon })
|
|
191
|
+
}
|
|
192
|
+
),
|
|
193
|
+
/* @__PURE__ */ jsx(
|
|
194
|
+
IconButton,
|
|
195
|
+
{
|
|
196
|
+
color: "error",
|
|
197
|
+
onClick: handleClose,
|
|
198
|
+
sx: {
|
|
199
|
+
borderRadius: 2,
|
|
200
|
+
border: `1px solid ${colors.strokeBorderBase}`
|
|
201
|
+
},
|
|
202
|
+
children: /* @__PURE__ */ jsx(Icon, { icon: CloseRoundedIcon })
|
|
203
|
+
}
|
|
204
|
+
)
|
|
205
|
+
] }) : /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
206
|
+
/* @__PURE__ */ jsx(
|
|
207
|
+
IconButton,
|
|
208
|
+
{
|
|
209
|
+
onClick: () => {
|
|
210
|
+
currentState.edit = true;
|
|
211
|
+
},
|
|
212
|
+
sx: {
|
|
213
|
+
borderRadius: 2,
|
|
214
|
+
border: `1px solid ${colors.strokeBorderBase}`
|
|
215
|
+
},
|
|
216
|
+
children: /* @__PURE__ */ jsx(Icon, { icon: EditSquareOutlineRoundedIcon })
|
|
217
|
+
}
|
|
218
|
+
),
|
|
219
|
+
/* @__PURE__ */ jsx(
|
|
220
|
+
IconButton,
|
|
221
|
+
{
|
|
222
|
+
color: "error",
|
|
223
|
+
onClick: () => {
|
|
224
|
+
onDelete({
|
|
225
|
+
type: currentState.type,
|
|
226
|
+
url: currentState.url
|
|
227
|
+
});
|
|
228
|
+
},
|
|
229
|
+
sx: {
|
|
230
|
+
borderRadius: 2,
|
|
231
|
+
border: `1px solid ${colors.strokeBorderBase}`
|
|
232
|
+
},
|
|
233
|
+
children: /* @__PURE__ */ jsx(Icon, { icon: DeleteOutlineRoundedIcon })
|
|
234
|
+
}
|
|
235
|
+
)
|
|
236
|
+
] }) })
|
|
237
|
+
]
|
|
238
|
+
}
|
|
239
|
+
)
|
|
240
|
+
]
|
|
241
|
+
}
|
|
242
|
+
);
|
|
243
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as UserCenter } from './components/user-center';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as UserCenter } from "./components/user-center.js";
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export declare const translations: {
|
|
2
|
+
zh: {
|
|
3
|
+
settings: string;
|
|
4
|
+
noPassport: string;
|
|
5
|
+
passport: string;
|
|
6
|
+
notification: string;
|
|
7
|
+
email: string;
|
|
8
|
+
lastLogin: string;
|
|
9
|
+
createdAt: string;
|
|
10
|
+
registerFrom: string;
|
|
11
|
+
unknown: string;
|
|
12
|
+
walletNotification: string;
|
|
13
|
+
emailNotification: string;
|
|
14
|
+
phoneNotification: string;
|
|
15
|
+
addWebhook: string;
|
|
16
|
+
saveSuccess: string;
|
|
17
|
+
saveFailed: string;
|
|
18
|
+
webhookTested: string;
|
|
19
|
+
done: string;
|
|
20
|
+
emptyField: string;
|
|
21
|
+
emptyContent: string;
|
|
22
|
+
underProtected: string;
|
|
23
|
+
noUserFound: string;
|
|
24
|
+
notificationManagement: string;
|
|
25
|
+
privacyManagement: string;
|
|
26
|
+
webhook: {
|
|
27
|
+
url: string;
|
|
28
|
+
slack: string;
|
|
29
|
+
};
|
|
30
|
+
common: {
|
|
31
|
+
required: string;
|
|
32
|
+
invalid: string;
|
|
33
|
+
};
|
|
34
|
+
toPublic: string;
|
|
35
|
+
currentPassport: string;
|
|
36
|
+
};
|
|
37
|
+
en: {
|
|
38
|
+
settings: string;
|
|
39
|
+
noPassport: string;
|
|
40
|
+
passport: string;
|
|
41
|
+
notification: string;
|
|
42
|
+
email: string;
|
|
43
|
+
lastLogin: string;
|
|
44
|
+
createdAt: string;
|
|
45
|
+
registerFrom: string;
|
|
46
|
+
unknown: string;
|
|
47
|
+
walletNotification: string;
|
|
48
|
+
emailNotification: string;
|
|
49
|
+
phoneNotification: string;
|
|
50
|
+
addWebhook: string;
|
|
51
|
+
saveSuccess: string;
|
|
52
|
+
saveFailed: string;
|
|
53
|
+
webhookTested: string;
|
|
54
|
+
done: string;
|
|
55
|
+
emptyField: string;
|
|
56
|
+
notificationManagement: string;
|
|
57
|
+
privacyManagement: string;
|
|
58
|
+
emptyContent: string;
|
|
59
|
+
underProtected: string;
|
|
60
|
+
noUserFound: string;
|
|
61
|
+
webhook: {
|
|
62
|
+
url: string;
|
|
63
|
+
slack: string;
|
|
64
|
+
};
|
|
65
|
+
common: {
|
|
66
|
+
required: string;
|
|
67
|
+
invalid: string;
|
|
68
|
+
};
|
|
69
|
+
toPublic: string;
|
|
70
|
+
currentPassport: string;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
export const translations = {
|
|
2
|
+
zh: {
|
|
3
|
+
settings: "\u8BBE\u7F6E",
|
|
4
|
+
noPassport: "\u6682\u65E0\u901A\u884C\u8BC1",
|
|
5
|
+
passport: "\u901A\u884C\u8BC1",
|
|
6
|
+
notification: "\u901A\u77E5",
|
|
7
|
+
email: "\u90AE\u7BB1\u5730\u5740",
|
|
8
|
+
lastLogin: "\u4E0A\u6B21\u767B\u5F55",
|
|
9
|
+
createdAt: "\u521B\u5EFA\u65F6\u95F4",
|
|
10
|
+
registerFrom: "\u6CE8\u518C\u6765\u6E90",
|
|
11
|
+
unknown: "\u672A\u77E5",
|
|
12
|
+
walletNotification: "\u94B1\u5305\u901A\u77E5",
|
|
13
|
+
emailNotification: "\u90AE\u4EF6\u901A\u77E5",
|
|
14
|
+
phoneNotification: "\u77ED\u4FE1\u901A\u77E5",
|
|
15
|
+
addWebhook: "\u65B0\u589E\u5916\u90E8\u901A\u77E5",
|
|
16
|
+
saveSuccess: "\u4FDD\u5B58\u6210\u529F",
|
|
17
|
+
saveFailed: "\u4FDD\u5B58\u5931\u8D25",
|
|
18
|
+
webhookTested: "\u6D4B\u8BD5\u6D88\u606F\u5DF2\u7ECF\u53D1\u9001",
|
|
19
|
+
done: "\u5B8C\u6210",
|
|
20
|
+
emptyField: "\u672A\u586B\u5199",
|
|
21
|
+
emptyContent: "\u6682\u65E0\u5185\u5BB9",
|
|
22
|
+
underProtected: "\u7528\u6237\u5DF2\u8BBE\u7F6E\u9690\u79C1\u4FDD\u62A4",
|
|
23
|
+
noUserFound: "\u672A\u627E\u5230\u6307\u5B9A\u7684\u7528\u6237",
|
|
24
|
+
notificationManagement: "\u901A\u77E5\u7BA1\u7406",
|
|
25
|
+
privacyManagement: "\u9690\u79C1\u7BA1\u7406",
|
|
26
|
+
webhook: {
|
|
27
|
+
url: "\u81EA\u5B9A\u4E49URL",
|
|
28
|
+
slack: "Slack"
|
|
29
|
+
},
|
|
30
|
+
common: {
|
|
31
|
+
required: "\u5FC5\u586B\u7684",
|
|
32
|
+
invalid: "\u65E0\u6548"
|
|
33
|
+
},
|
|
34
|
+
toPublic: "\u516C\u5F00 \u201C{name}\u201D \u9875\u9762",
|
|
35
|
+
currentPassport: "\u5F53\u524D\u4F7F\u7528\u7684\u901A\u884C\u8BC1"
|
|
36
|
+
},
|
|
37
|
+
en: {
|
|
38
|
+
settings: "Settings",
|
|
39
|
+
noPassport: "No passport founded",
|
|
40
|
+
passport: "Passport",
|
|
41
|
+
notification: "Notification",
|
|
42
|
+
email: "Email",
|
|
43
|
+
lastLogin: "Last Login & IP",
|
|
44
|
+
createdAt: "Created At",
|
|
45
|
+
registerFrom: "Register From",
|
|
46
|
+
unknown: "Unknown",
|
|
47
|
+
walletNotification: "DID Wallet notification",
|
|
48
|
+
emailNotification: "Email notification",
|
|
49
|
+
phoneNotification: "SMS notification",
|
|
50
|
+
addWebhook: "Add external notification",
|
|
51
|
+
saveSuccess: "Save succeed",
|
|
52
|
+
saveFailed: "Save failed",
|
|
53
|
+
webhookTested: "Test message sent",
|
|
54
|
+
done: "Done",
|
|
55
|
+
emptyField: "Empty field",
|
|
56
|
+
notificationManagement: "Notification",
|
|
57
|
+
privacyManagement: "Privacy",
|
|
58
|
+
emptyContent: "Empty",
|
|
59
|
+
underProtected: "This page has protected privacy",
|
|
60
|
+
noUserFound: "No user found",
|
|
61
|
+
webhook: {
|
|
62
|
+
url: "Custom url",
|
|
63
|
+
slack: "Slack"
|
|
64
|
+
},
|
|
65
|
+
common: {
|
|
66
|
+
required: "Required",
|
|
67
|
+
invalid: "Invalid"
|
|
68
|
+
},
|
|
69
|
+
toPublic: 'Public "{name}" page',
|
|
70
|
+
currentPassport: "Passport currently in use"
|
|
71
|
+
}
|
|
72
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import joinURL from "url-join";
|
|
2
|
+
import { WELLKNOWN_SERVICE_PATH_PREFIX } from "@abtnode/constant";
|
|
3
|
+
import { createPassportSvg as _createPassportSvg } from "@arcblock/ux/lib/Util/passport";
|
|
4
|
+
export const formatAxiosError = (err) => {
|
|
5
|
+
const { response } = err;
|
|
6
|
+
if (response) {
|
|
7
|
+
return `Request failed: ${response.status} ${response.statusText}: ${JSON.stringify(response.data)}`;
|
|
8
|
+
}
|
|
9
|
+
return err.message;
|
|
10
|
+
};
|
|
11
|
+
export const createPassportSvg = (props) => _createPassportSvg({
|
|
12
|
+
...props,
|
|
13
|
+
issuerAvatarUrl: joinURL(window.location.origin, WELLKNOWN_SERVICE_PATH_PREFIX, "/blocklet/logo")
|
|
14
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export const publicPath: any;
|
|
2
|
+
export function formatTheme(theme: any): any;
|
|
3
|
+
export function getLocalizedNavigation(navigation: any, locale?: string): any;
|
|
4
|
+
export function formatNavigation(navigation: any): any;
|
|
5
|
+
export function parseNavigation(navigation: any): {
|
|
6
|
+
header: never[];
|
|
7
|
+
footer: never[];
|
|
8
|
+
social: never[];
|
|
9
|
+
bottom: never[];
|
|
10
|
+
dashboard: never[];
|
|
11
|
+
sessionManager: never[];
|
|
12
|
+
userCenter: never[];
|
|
13
|
+
} | null;
|
|
14
|
+
export function formatBlockletInfo(blockletInfo: any): any;
|
|
15
|
+
export function filterValidNavItems(navigation?: any[]): any;
|
|
16
|
+
export function filterNavByRole(nav: object[], userRole: string): any;
|
package/es/blocklets.js
CHANGED
|
@@ -1,25 +1,20 @@
|
|
|
1
|
-
import { mapRecursive, filterRecursive, isUrl } from './utils';
|
|
1
|
+
import { mapRecursive, filterRecursive, isUrl } from './utils.js';
|
|
2
|
+
|
|
2
3
|
export const publicPath = window?.blocklet?.groupPrefix || window?.blocklet?.prefix || '/';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* 格式化 theme (目前仅考虑 background)
|
|
6
7
|
*/
|
|
7
|
-
export const formatTheme = theme => {
|
|
8
|
-
const formatted = {
|
|
9
|
-
...theme
|
|
10
|
-
};
|
|
8
|
+
export const formatTheme = (theme) => {
|
|
9
|
+
const formatted = { ...theme };
|
|
11
10
|
const background = theme?.background;
|
|
12
11
|
if (typeof background === 'string') {
|
|
13
|
-
formatted.background = {
|
|
14
|
-
header: background,
|
|
15
|
-
footer: background,
|
|
16
|
-
default: background
|
|
17
|
-
};
|
|
12
|
+
formatted.background = { header: background, footer: background, default: background };
|
|
18
13
|
} else if (background && typeof background === 'object') {
|
|
19
14
|
formatted.background = {
|
|
20
15
|
header: background.header || background.default,
|
|
21
16
|
footer: background.footer || background.default,
|
|
22
|
-
default: background.default
|
|
17
|
+
default: background.default,
|
|
23
18
|
};
|
|
24
19
|
}
|
|
25
20
|
return formatted;
|
|
@@ -60,14 +55,19 @@ export const getLocalizedNavigation = (navigation, locale = 'en') => {
|
|
|
60
55
|
}
|
|
61
56
|
return link;
|
|
62
57
|
};
|
|
63
|
-
return mapRecursive(
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
58
|
+
return mapRecursive(
|
|
59
|
+
navigation,
|
|
60
|
+
(item) => {
|
|
61
|
+
return {
|
|
62
|
+
...item,
|
|
63
|
+
title: getTitle(item.title, locale),
|
|
64
|
+
// 仅对叶结点进行处理
|
|
65
|
+
link: !item.items?.length ? getLink(item.link, locale) : item.link,
|
|
66
|
+
_rawLink: item.link,
|
|
67
|
+
};
|
|
68
|
+
},
|
|
69
|
+
'items'
|
|
70
|
+
);
|
|
71
71
|
};
|
|
72
72
|
|
|
73
73
|
/**
|
|
@@ -75,22 +75,29 @@ export const getLocalizedNavigation = (navigation, locale = 'en') => {
|
|
|
75
75
|
*
|
|
76
76
|
* - role 统一为数组形式
|
|
77
77
|
*/
|
|
78
|
-
export const formatNavigation = navigation => {
|
|
79
|
-
return mapRecursive(
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
78
|
+
export const formatNavigation = (navigation) => {
|
|
79
|
+
return mapRecursive(
|
|
80
|
+
navigation,
|
|
81
|
+
(item) => {
|
|
82
|
+
if (item.role) {
|
|
83
|
+
return {
|
|
84
|
+
...item,
|
|
85
|
+
role: Array.isArray(item.role) ? item.role : [item.role],
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
return item;
|
|
89
|
+
},
|
|
90
|
+
'items'
|
|
91
|
+
);
|
|
88
92
|
};
|
|
89
|
-
|
|
93
|
+
|
|
94
|
+
export const parseNavigation = (navigation) => {
|
|
90
95
|
if (!navigation?.length) {
|
|
91
96
|
return null;
|
|
92
97
|
}
|
|
98
|
+
|
|
93
99
|
const formattedNav = formatNavigation(navigation);
|
|
100
|
+
|
|
94
101
|
const sections = {
|
|
95
102
|
header: [],
|
|
96
103
|
footer: [],
|
|
@@ -101,17 +108,18 @@ export const parseNavigation = navigation => {
|
|
|
101
108
|
// 对应 dashboard#sidenav 导航
|
|
102
109
|
dashboard: [],
|
|
103
110
|
// session manager menus
|
|
104
|
-
sessionManager: []
|
|
111
|
+
sessionManager: [],
|
|
112
|
+
userCenter: [],
|
|
105
113
|
};
|
|
106
114
|
|
|
107
115
|
// 对 navigation 顶层元素按 section 分组
|
|
108
|
-
formattedNav.forEach(item => {
|
|
116
|
+
formattedNav.forEach((item) => {
|
|
109
117
|
// item#section 为空时, 表示只存在于 header
|
|
110
118
|
if (!item.section) {
|
|
111
119
|
sections.header.push(item);
|
|
112
120
|
// item 出现在指定几个 section 中 (array)
|
|
113
121
|
} else if (Array.isArray(item.section)) {
|
|
114
|
-
item.section.forEach(sectionKey => {
|
|
122
|
+
item.section.forEach((sectionKey) => {
|
|
115
123
|
sections[sectionKey]?.push(item);
|
|
116
124
|
});
|
|
117
125
|
// item 出现在指定的一个 section 中 (string)
|
|
@@ -119,19 +127,18 @@ export const parseNavigation = navigation => {
|
|
|
119
127
|
sections[item.section]?.push(item);
|
|
120
128
|
}
|
|
121
129
|
});
|
|
130
|
+
|
|
122
131
|
return sections;
|
|
123
132
|
};
|
|
124
133
|
|
|
125
134
|
/**
|
|
126
135
|
* 格式化 blocklet info 数据
|
|
127
136
|
*/
|
|
128
|
-
export const formatBlockletInfo = blockletInfo => {
|
|
137
|
+
export const formatBlockletInfo = (blockletInfo) => {
|
|
129
138
|
if (!blockletInfo) {
|
|
130
139
|
return null;
|
|
131
140
|
}
|
|
132
|
-
const formatted = {
|
|
133
|
-
...blockletInfo
|
|
134
|
-
};
|
|
141
|
+
const formatted = { ...blockletInfo };
|
|
135
142
|
// theme
|
|
136
143
|
formatted.theme = formatTheme(formatted.theme);
|
|
137
144
|
// navigation
|
|
@@ -157,11 +164,15 @@ export const filterValidNavItems = (navigation = []) => {
|
|
|
157
164
|
* @returns 符合 role 权限的导航菜单数据
|
|
158
165
|
*/
|
|
159
166
|
export const filterNavByRole = (nav, userRole) => {
|
|
160
|
-
return filterRecursive(
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
167
|
+
return filterRecursive(
|
|
168
|
+
nav,
|
|
169
|
+
(item, context) => {
|
|
170
|
+
const isRoleMatched = !item.role || (userRole && item.role.includes(userRole));
|
|
171
|
+
if (!context.isLeaf) {
|
|
172
|
+
return isRoleMatched && context.filteredChildren?.length;
|
|
173
|
+
}
|
|
174
|
+
return isRoleMatched;
|
|
175
|
+
},
|
|
176
|
+
'items'
|
|
177
|
+
);
|
|
178
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
declare function HeaderAddons({ formattedBlocklet, addons, sessionManagerProps }: {
|
|
2
|
+
formattedBlocklet: any;
|
|
3
|
+
addons: any;
|
|
4
|
+
sessionManagerProps: any;
|
|
5
|
+
}): import("react").DetailedReactHTMLElement<import("react").InputHTMLAttributes<HTMLInputElement>, HTMLInputElement>;
|
|
6
|
+
declare namespace HeaderAddons {
|
|
7
|
+
namespace propTypes {
|
|
8
|
+
export let formattedBlocklet: any;
|
|
9
|
+
export let addons: any;
|
|
10
|
+
export { sessionManagerProps };
|
|
11
|
+
}
|
|
12
|
+
namespace defaultProps {
|
|
13
|
+
let addons_1: null;
|
|
14
|
+
export { addons_1 as addons };
|
|
15
|
+
export namespace sessionManagerProps_1 {
|
|
16
|
+
let showRole: boolean;
|
|
17
|
+
}
|
|
18
|
+
export { sessionManagerProps_1 as sessionManagerProps };
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
export default HeaderAddons;
|
|
22
|
+
import { sessionManagerProps } from '../types';
|