@blocklet/ui-react 2.9.32 → 2.9.34
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/@types/index.d.ts +1 -0
- package/es/UserCenter/components/user-center.d.ts +2 -1
- package/es/UserCenter/components/user-center.js +48 -32
- package/lib/@types/index.d.ts +1 -0
- package/lib/UserCenter/components/user-center.d.ts +2 -1
- package/lib/UserCenter/components/user-center.js +51 -37
- package/package.json +5 -4
- package/src/@types/index.ts +1 -0
- package/src/UserCenter/components/user-center.tsx +39 -25
package/es/@types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { BoxProps } from '@mui/material';
|
|
3
|
-
export default function UserCenter({ children, currentTab, contentProps, disableAutoRedirect, autoPopupSetting, hideFooter, headerProps, footerProps, userDid, }: {
|
|
3
|
+
export default function UserCenter({ children, currentTab, contentProps, disableAutoRedirect, autoPopupSetting, hideFooter, headerProps, footerProps, userDid, stickySidebar, }: {
|
|
4
4
|
readonly children: any;
|
|
5
5
|
readonly currentTab: string;
|
|
6
6
|
readonly contentProps?: BoxProps;
|
|
@@ -10,4 +10,5 @@ export default function UserCenter({ children, currentTab, contentProps, disable
|
|
|
10
10
|
readonly headerProps?: object;
|
|
11
11
|
readonly footerProps?: object;
|
|
12
12
|
readonly userDid?: string;
|
|
13
|
+
readonly stickySidebar?: boolean;
|
|
13
14
|
}): import("react").JSX.Element | null;
|
|
@@ -2,6 +2,7 @@ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useContext } from "react";
|
|
3
3
|
import { Box, CircularProgress, Typography } from "@mui/material";
|
|
4
4
|
import { useCreation, useMemoizedFn, useMount, useRequest } from "ahooks";
|
|
5
|
+
import pWaitFor from "p-wait-for";
|
|
5
6
|
import { SessionContext } from "@arcblock/did-connect/lib/Session";
|
|
6
7
|
import Tabs from "@arcblock/ux/lib/Tabs";
|
|
7
8
|
import Empty from "@arcblock/ux/lib/Empty";
|
|
@@ -29,7 +30,8 @@ export default function UserCenter({
|
|
|
29
30
|
hideFooter = false,
|
|
30
31
|
headerProps = {},
|
|
31
32
|
footerProps = {},
|
|
32
|
-
userDid
|
|
33
|
+
userDid,
|
|
34
|
+
stickySidebar = false
|
|
33
35
|
}) {
|
|
34
36
|
const { locale } = useLocaleContext();
|
|
35
37
|
const t = useMemoizedFn((key, data = {}) => {
|
|
@@ -59,6 +61,7 @@ export default function UserCenter({
|
|
|
59
61
|
}, [currentDid, session?.user?.did]);
|
|
60
62
|
const userState = useRequest(
|
|
61
63
|
async () => {
|
|
64
|
+
await pWaitFor(() => session.initialized);
|
|
62
65
|
if (isMyself) {
|
|
63
66
|
return session.user;
|
|
64
67
|
}
|
|
@@ -175,7 +178,7 @@ export default function UserCenter({
|
|
|
175
178
|
return /* @__PURE__ */ jsx(Box, { sx: { width: "100%" }, children: /* @__PURE__ */ jsx(ErrorFallback, { error: formatError }) });
|
|
176
179
|
}
|
|
177
180
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
178
|
-
/* @__PURE__ */ jsxs(Box, { sx: { flex: 1 }, children: [
|
|
181
|
+
/* @__PURE__ */ jsxs(Box, { sx: { flex: 1, overflow: "hidden" }, children: [
|
|
179
182
|
userState?.data?.fullName ? /* @__PURE__ */ jsx(
|
|
180
183
|
Typography,
|
|
181
184
|
{
|
|
@@ -272,7 +275,7 @@ export default function UserCenter({
|
|
|
272
275
|
}
|
|
273
276
|
}
|
|
274
277
|
),
|
|
275
|
-
/* @__PURE__ */
|
|
278
|
+
/* @__PURE__ */ jsx(
|
|
276
279
|
Box,
|
|
277
280
|
{
|
|
278
281
|
sx: {
|
|
@@ -283,40 +286,53 @@ export default function UserCenter({
|
|
|
283
286
|
maxWidth: "100%",
|
|
284
287
|
display: "flex",
|
|
285
288
|
flexDirection: "column",
|
|
286
|
-
gap: 2.5
|
|
289
|
+
gap: 2.5,
|
|
290
|
+
position: "relative"
|
|
287
291
|
},
|
|
288
|
-
children:
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
{
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
292
|
+
children: /* @__PURE__ */ jsxs(
|
|
293
|
+
Box,
|
|
294
|
+
{
|
|
295
|
+
sx: {
|
|
296
|
+
position: {
|
|
297
|
+
xs: "static",
|
|
298
|
+
md: stickySidebar ? "sticky" : "static"
|
|
299
|
+
},
|
|
300
|
+
top: (theme) => stickySidebar ? theme.spacing(3) : "unset"
|
|
301
|
+
},
|
|
302
|
+
children: [
|
|
303
|
+
/* @__PURE__ */ jsx(
|
|
304
|
+
UserBasicInfo,
|
|
305
|
+
{
|
|
306
|
+
isMyself,
|
|
307
|
+
switchPassport: session.switchPassport,
|
|
308
|
+
switchProfile: session.switchProfile,
|
|
309
|
+
openSettings,
|
|
310
|
+
user: userState.data,
|
|
311
|
+
sx: {
|
|
312
|
+
display: {
|
|
313
|
+
xs: "none",
|
|
314
|
+
md: "block"
|
|
315
|
+
}
|
|
316
|
+
}
|
|
301
317
|
}
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
]
|
|
314
|
-
|
|
315
|
-
|
|
318
|
+
),
|
|
319
|
+
isMyself ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
320
|
+
/* @__PURE__ */ jsxs(Box, { children: [
|
|
321
|
+
/* @__PURE__ */ jsx(Typography, { sx: { fontWeight: 600, mb: 1.5 }, children: t("myInfo") }),
|
|
322
|
+
/* @__PURE__ */ jsx(UserInfo, { user: userState.data })
|
|
323
|
+
] }),
|
|
324
|
+
/* @__PURE__ */ jsxs(Box, { children: [
|
|
325
|
+
/* @__PURE__ */ jsx(Typography, { sx: { fontWeight: 600, mb: 1.5 }, children: t("passport") }),
|
|
326
|
+
/* @__PURE__ */ jsx(Passport, { user: userState.data })
|
|
327
|
+
] })
|
|
328
|
+
] }) : null
|
|
329
|
+
]
|
|
330
|
+
}
|
|
331
|
+
)
|
|
316
332
|
}
|
|
317
333
|
)
|
|
318
334
|
] });
|
|
319
|
-
}, [userState, userCenterTabs]);
|
|
335
|
+
}, [userState, userCenterTabs, isMyself, currentActiveTab, privacyState, currentTab, stickySidebar]);
|
|
320
336
|
if (!disableAutoRedirect && !currentTab && formattedBlocklet?.navigation?.userCenter?.length > 0) {
|
|
321
337
|
window.location.replace(formattedBlocklet?.navigation?.userCenter[0]?.link);
|
|
322
338
|
return null;
|
package/lib/@types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { BoxProps } from '@mui/material';
|
|
3
|
-
export default function UserCenter({ children, currentTab, contentProps, disableAutoRedirect, autoPopupSetting, hideFooter, headerProps, footerProps, userDid, }: {
|
|
3
|
+
export default function UserCenter({ children, currentTab, contentProps, disableAutoRedirect, autoPopupSetting, hideFooter, headerProps, footerProps, userDid, stickySidebar, }: {
|
|
4
4
|
readonly children: any;
|
|
5
5
|
readonly currentTab: string;
|
|
6
6
|
readonly contentProps?: BoxProps;
|
|
@@ -10,4 +10,5 @@ export default function UserCenter({ children, currentTab, contentProps, disable
|
|
|
10
10
|
readonly headerProps?: object;
|
|
11
11
|
readonly footerProps?: object;
|
|
12
12
|
readonly userDid?: string;
|
|
13
|
+
readonly stickySidebar?: boolean;
|
|
13
14
|
}): import("react").JSX.Element | null;
|
|
@@ -8,6 +8,7 @@ var _jsxRuntime = require("react/jsx-runtime");
|
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
var _material = require("@mui/material");
|
|
10
10
|
var _ahooks = require("ahooks");
|
|
11
|
+
var _pWaitFor = _interopRequireDefault(require("p-wait-for"));
|
|
11
12
|
var _Session = require("@arcblock/did-connect/lib/Session");
|
|
12
13
|
var _Tabs = _interopRequireDefault(require("@arcblock/ux/lib/Tabs"));
|
|
13
14
|
var _Empty = _interopRequireDefault(require("@arcblock/ux/lib/Empty"));
|
|
@@ -36,7 +37,8 @@ function UserCenter({
|
|
|
36
37
|
hideFooter = false,
|
|
37
38
|
headerProps = {},
|
|
38
39
|
footerProps = {},
|
|
39
|
-
userDid
|
|
40
|
+
userDid,
|
|
41
|
+
stickySidebar = false
|
|
40
42
|
}) {
|
|
41
43
|
const {
|
|
42
44
|
locale
|
|
@@ -67,6 +69,7 @@ function UserCenter({
|
|
|
67
69
|
return false;
|
|
68
70
|
}, [currentDid, session?.user?.did]);
|
|
69
71
|
const userState = (0, _ahooks.useRequest)(async () => {
|
|
72
|
+
await (0, _pWaitFor.default)(() => session.initialized);
|
|
70
73
|
if (isMyself) {
|
|
71
74
|
return session.user;
|
|
72
75
|
}
|
|
@@ -191,7 +194,8 @@ function UserCenter({
|
|
|
191
194
|
return /* @__PURE__ */(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
192
195
|
children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
193
196
|
sx: {
|
|
194
|
-
flex: 1
|
|
197
|
+
flex: 1,
|
|
198
|
+
overflow: "hidden"
|
|
195
199
|
},
|
|
196
200
|
children: [userState?.data?.fullName ? /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
197
201
|
variant: "h4",
|
|
@@ -279,7 +283,7 @@ function UserCenter({
|
|
|
279
283
|
my: -3,
|
|
280
284
|
backgroundColor: _Colors.temp.strokeSep
|
|
281
285
|
}
|
|
282
|
-
}), /* @__PURE__ */(0, _jsxRuntime.
|
|
286
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
283
287
|
sx: {
|
|
284
288
|
width: {
|
|
285
289
|
sx: "100%",
|
|
@@ -288,46 +292,56 @@ function UserCenter({
|
|
|
288
292
|
maxWidth: "100%",
|
|
289
293
|
display: "flex",
|
|
290
294
|
flexDirection: "column",
|
|
291
|
-
gap: 2.5
|
|
295
|
+
gap: 2.5,
|
|
296
|
+
position: "relative"
|
|
292
297
|
},
|
|
293
|
-
children:
|
|
294
|
-
isMyself,
|
|
295
|
-
switchPassport: session.switchPassport,
|
|
296
|
-
switchProfile: session.switchProfile,
|
|
297
|
-
openSettings,
|
|
298
|
-
user: userState.data,
|
|
298
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
299
299
|
sx: {
|
|
300
|
-
|
|
301
|
-
xs: "
|
|
302
|
-
md: "
|
|
300
|
+
position: {
|
|
301
|
+
xs: "static",
|
|
302
|
+
md: stickySidebar ? "sticky" : "static"
|
|
303
|
+
},
|
|
304
|
+
top: theme => stickySidebar ? theme.spacing(3) : "unset"
|
|
305
|
+
},
|
|
306
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_userBasicInfo.default, {
|
|
307
|
+
isMyself,
|
|
308
|
+
switchPassport: session.switchPassport,
|
|
309
|
+
switchProfile: session.switchProfile,
|
|
310
|
+
openSettings,
|
|
311
|
+
user: userState.data,
|
|
312
|
+
sx: {
|
|
313
|
+
display: {
|
|
314
|
+
xs: "none",
|
|
315
|
+
md: "block"
|
|
316
|
+
}
|
|
303
317
|
}
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
318
|
+
}), isMyself ? /* @__PURE__ */(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
319
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
320
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
321
|
+
sx: {
|
|
322
|
+
fontWeight: 600,
|
|
323
|
+
mb: 1.5
|
|
324
|
+
},
|
|
325
|
+
children: t("myInfo")
|
|
326
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_userInfo.default, {
|
|
327
|
+
user: userState.data
|
|
328
|
+
})]
|
|
329
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
330
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
331
|
+
sx: {
|
|
332
|
+
fontWeight: 600,
|
|
333
|
+
mb: 1.5
|
|
334
|
+
},
|
|
335
|
+
children: t("passport")
|
|
336
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_passport.default, {
|
|
337
|
+
user: userState.data
|
|
338
|
+
})]
|
|
315
339
|
})]
|
|
316
|
-
})
|
|
317
|
-
|
|
318
|
-
sx: {
|
|
319
|
-
fontWeight: 600,
|
|
320
|
-
mb: 1.5
|
|
321
|
-
},
|
|
322
|
-
children: t("passport")
|
|
323
|
-
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_passport.default, {
|
|
324
|
-
user: userState.data
|
|
325
|
-
})]
|
|
326
|
-
})]
|
|
327
|
-
}) : null]
|
|
340
|
+
}) : null]
|
|
341
|
+
})
|
|
328
342
|
})]
|
|
329
343
|
});
|
|
330
|
-
}, [userState, userCenterTabs]);
|
|
344
|
+
}, [userState, userCenterTabs, isMyself, currentActiveTab, privacyState, currentTab, stickySidebar]);
|
|
331
345
|
if (!disableAutoRedirect && !currentTab && formattedBlocklet?.navigation?.userCenter?.length > 0) {
|
|
332
346
|
window.location.replace(formattedBlocklet?.navigation?.userCenter[0]?.link);
|
|
333
347
|
return null;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/ui-react",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.34",
|
|
4
4
|
"description": "Some useful front-end web components that can be used in Blocklets.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
},
|
|
64
64
|
"dependencies": {
|
|
65
65
|
"@abtnode/constant": "1.16.23",
|
|
66
|
-
"@arcblock/did-connect": "^2.9.
|
|
67
|
-
"@arcblock/ux": "^2.9.
|
|
66
|
+
"@arcblock/did-connect": "^2.9.34",
|
|
67
|
+
"@arcblock/ux": "^2.9.34",
|
|
68
68
|
"@blocklet/js-sdk": "1.16.23",
|
|
69
69
|
"@emotion/react": "^11.10.4",
|
|
70
70
|
"@emotion/styled": "^11.10.4",
|
|
@@ -78,6 +78,7 @@
|
|
|
78
78
|
"iconify-icons-material-symbols-400": "^0.0.1",
|
|
79
79
|
"is-url": "^1.2.4",
|
|
80
80
|
"lodash": "^4.17.21",
|
|
81
|
+
"p-wait-for": "^5.0.2",
|
|
81
82
|
"react-error-boundary": "^3.1.4",
|
|
82
83
|
"react-placeholder": "^4.1.0",
|
|
83
84
|
"ufo": "^1.3.2",
|
|
@@ -99,5 +100,5 @@
|
|
|
99
100
|
"jest": "^28.1.3",
|
|
100
101
|
"unbuild": "^2.0.0"
|
|
101
102
|
},
|
|
102
|
-
"gitHead": "
|
|
103
|
+
"gitHead": "a52271c4640fd0a418208eddccd4147a82eddbf5"
|
|
103
104
|
}
|
package/src/@types/index.ts
CHANGED
|
@@ -2,6 +2,7 @@ import { useContext } from 'react';
|
|
|
2
2
|
import { Box, CircularProgress, Typography } from '@mui/material';
|
|
3
3
|
import type { BoxProps } from '@mui/material';
|
|
4
4
|
import { useCreation, useMemoizedFn, useMount, useRequest } from 'ahooks';
|
|
5
|
+
import pWaitFor from 'p-wait-for';
|
|
5
6
|
|
|
6
7
|
import { SessionContext } from '@arcblock/did-connect/lib/Session';
|
|
7
8
|
import Tabs from '@arcblock/ux/lib/Tabs';
|
|
@@ -36,6 +37,7 @@ export default function UserCenter({
|
|
|
36
37
|
headerProps = {},
|
|
37
38
|
footerProps = {},
|
|
38
39
|
userDid,
|
|
40
|
+
stickySidebar = false,
|
|
39
41
|
}: {
|
|
40
42
|
readonly children: any;
|
|
41
43
|
readonly currentTab: string;
|
|
@@ -46,6 +48,7 @@ export default function UserCenter({
|
|
|
46
48
|
readonly headerProps?: object;
|
|
47
49
|
readonly footerProps?: object;
|
|
48
50
|
readonly userDid?: string;
|
|
51
|
+
readonly stickySidebar?: boolean;
|
|
49
52
|
}) {
|
|
50
53
|
const { locale } = useLocaleContext();
|
|
51
54
|
const t = useMemoizedFn((key, data = {}) => {
|
|
@@ -79,6 +82,7 @@ export default function UserCenter({
|
|
|
79
82
|
|
|
80
83
|
const userState = useRequest(
|
|
81
84
|
async () => {
|
|
85
|
+
await pWaitFor(() => session.initialized);
|
|
82
86
|
if (isMyself) {
|
|
83
87
|
return session.user;
|
|
84
88
|
}
|
|
@@ -215,7 +219,7 @@ export default function UserCenter({
|
|
|
215
219
|
|
|
216
220
|
return (
|
|
217
221
|
<>
|
|
218
|
-
<Box sx={{ flex: 1 }}>
|
|
222
|
+
<Box sx={{ flex: 1, overflow: 'hidden' }}>
|
|
219
223
|
{userState?.data?.fullName ? (
|
|
220
224
|
<Typography
|
|
221
225
|
variant="h4"
|
|
@@ -317,37 +321,47 @@ export default function UserCenter({
|
|
|
317
321
|
display: 'flex',
|
|
318
322
|
flexDirection: 'column',
|
|
319
323
|
gap: 2.5,
|
|
324
|
+
position: 'relative',
|
|
320
325
|
}}>
|
|
321
|
-
<
|
|
322
|
-
isMyself={isMyself}
|
|
323
|
-
switchPassport={session.switchPassport}
|
|
324
|
-
switchProfile={session.switchProfile}
|
|
325
|
-
openSettings={openSettings}
|
|
326
|
-
user={userState.data}
|
|
326
|
+
<Box
|
|
327
327
|
sx={{
|
|
328
|
-
|
|
329
|
-
xs: '
|
|
330
|
-
md: '
|
|
328
|
+
position: {
|
|
329
|
+
xs: 'static',
|
|
330
|
+
md: stickySidebar ? 'sticky' : 'static',
|
|
331
331
|
},
|
|
332
|
-
|
|
333
|
-
|
|
332
|
+
top: (theme) => (stickySidebar ? theme.spacing(3) : 'unset'),
|
|
333
|
+
}}>
|
|
334
|
+
<UserBasicInfo
|
|
335
|
+
isMyself={isMyself}
|
|
336
|
+
switchPassport={session.switchPassport}
|
|
337
|
+
switchProfile={session.switchProfile}
|
|
338
|
+
openSettings={openSettings}
|
|
339
|
+
user={userState.data}
|
|
340
|
+
sx={{
|
|
341
|
+
display: {
|
|
342
|
+
xs: 'none',
|
|
343
|
+
md: 'block',
|
|
344
|
+
},
|
|
345
|
+
}}
|
|
346
|
+
/>
|
|
334
347
|
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
348
|
+
{isMyself ? (
|
|
349
|
+
<>
|
|
350
|
+
<Box>
|
|
351
|
+
<Typography sx={{ fontWeight: 600, mb: 1.5 }}>{t('myInfo')}</Typography>
|
|
352
|
+
<UserInfo user={userState.data} />
|
|
353
|
+
</Box>
|
|
354
|
+
<Box>
|
|
355
|
+
<Typography sx={{ fontWeight: 600, mb: 1.5 }}>{t('passport')}</Typography>
|
|
356
|
+
<Passport user={userState.data} />
|
|
357
|
+
</Box>
|
|
358
|
+
</>
|
|
359
|
+
) : null}
|
|
360
|
+
</Box>
|
|
347
361
|
</Box>
|
|
348
362
|
</>
|
|
349
363
|
);
|
|
350
|
-
}, [userState, userCenterTabs]);
|
|
364
|
+
}, [userState, userCenterTabs, isMyself, currentActiveTab, privacyState, currentTab, stickySidebar]);
|
|
351
365
|
|
|
352
366
|
if (!disableAutoRedirect && !currentTab && formattedBlocklet?.navigation?.userCenter?.length > 0) {
|
|
353
367
|
window.location.replace(formattedBlocklet?.navigation?.userCenter[0]?.link);
|