@blocklet/ui-react 2.9.31 → 2.9.33
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/ComponentInstaller/use-component-installed.js +1 -1
- package/es/UserCenter/components/user-center.d.ts +2 -1
- package/es/UserCenter/components/user-center.js +47 -31
- package/lib/@types/index.d.ts +1 -0
- package/lib/ComponentInstaller/use-component-installed.js +1 -1
- package/lib/UserCenter/components/user-center.d.ts +2 -1
- package/lib/UserCenter/components/user-center.js +49 -36
- package/package.json +5 -4
- package/src/@types/index.ts +1 -0
- package/src/ComponentInstaller/use-component-installed.js +1 -1
- package/src/UserCenter/components/user-center.tsx +38 -24
package/es/@types/index.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ function useComponentInstalled({ did, onInstalled, onError }) {
|
|
|
19
19
|
|
|
20
20
|
const optComponents = useMemo(() => {
|
|
21
21
|
if (!optionalComponents || !optionalComponents.length) {
|
|
22
|
-
return
|
|
22
|
+
return [];
|
|
23
23
|
}
|
|
24
24
|
const didSet = parseDidToSet(didKeys);
|
|
25
25
|
const components = optionalComponents.filter((c) => didSet.has(c.meta.did));
|
|
@@ -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
|
}
|
|
@@ -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
|
@@ -35,7 +35,7 @@ function useComponentInstalled({
|
|
|
35
35
|
} = window.blocklet;
|
|
36
36
|
const optComponents = (0, _react.useMemo)(() => {
|
|
37
37
|
if (!optionalComponents || !optionalComponents.length) {
|
|
38
|
-
return
|
|
38
|
+
return [];
|
|
39
39
|
}
|
|
40
40
|
const didSet = parseDidToSet(didKeys);
|
|
41
41
|
const components = optionalComponents.filter(c => didSet.has(c.meta.did));
|
|
@@ -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
|
}
|
|
@@ -279,7 +282,7 @@ function UserCenter({
|
|
|
279
282
|
my: -3,
|
|
280
283
|
backgroundColor: _Colors.temp.strokeSep
|
|
281
284
|
}
|
|
282
|
-
}), /* @__PURE__ */(0, _jsxRuntime.
|
|
285
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Box, {
|
|
283
286
|
sx: {
|
|
284
287
|
width: {
|
|
285
288
|
sx: "100%",
|
|
@@ -288,46 +291,56 @@ function UserCenter({
|
|
|
288
291
|
maxWidth: "100%",
|
|
289
292
|
display: "flex",
|
|
290
293
|
flexDirection: "column",
|
|
291
|
-
gap: 2.5
|
|
294
|
+
gap: 2.5,
|
|
295
|
+
position: "relative"
|
|
292
296
|
},
|
|
293
|
-
children:
|
|
294
|
-
isMyself,
|
|
295
|
-
switchPassport: session.switchPassport,
|
|
296
|
-
switchProfile: session.switchProfile,
|
|
297
|
-
openSettings,
|
|
298
|
-
user: userState.data,
|
|
297
|
+
children: /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
299
298
|
sx: {
|
|
300
|
-
|
|
301
|
-
xs: "
|
|
302
|
-
md: "
|
|
299
|
+
position: {
|
|
300
|
+
xs: "static",
|
|
301
|
+
md: stickySidebar ? "sticky" : "static"
|
|
302
|
+
},
|
|
303
|
+
top: theme => stickySidebar ? theme.spacing(3) : "unset"
|
|
304
|
+
},
|
|
305
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_userBasicInfo.default, {
|
|
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
|
+
}
|
|
303
316
|
}
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
317
|
+
}), isMyself ? /* @__PURE__ */(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
318
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
319
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
320
|
+
sx: {
|
|
321
|
+
fontWeight: 600,
|
|
322
|
+
mb: 1.5
|
|
323
|
+
},
|
|
324
|
+
children: t("myInfo")
|
|
325
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_userInfo.default, {
|
|
326
|
+
user: userState.data
|
|
327
|
+
})]
|
|
328
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsxs)(_material.Box, {
|
|
329
|
+
children: [/* @__PURE__ */(0, _jsxRuntime.jsx)(_material.Typography, {
|
|
330
|
+
sx: {
|
|
331
|
+
fontWeight: 600,
|
|
332
|
+
mb: 1.5
|
|
333
|
+
},
|
|
334
|
+
children: t("passport")
|
|
335
|
+
}), /* @__PURE__ */(0, _jsxRuntime.jsx)(_passport.default, {
|
|
336
|
+
user: userState.data
|
|
337
|
+
})]
|
|
315
338
|
})]
|
|
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]
|
|
339
|
+
}) : null]
|
|
340
|
+
})
|
|
328
341
|
})]
|
|
329
342
|
});
|
|
330
|
-
}, [userState, userCenterTabs]);
|
|
343
|
+
}, [userState, userCenterTabs, isMyself, currentActiveTab, privacyState, currentTab, stickySidebar]);
|
|
331
344
|
if (!disableAutoRedirect && !currentTab && formattedBlocklet?.navigation?.userCenter?.length > 0) {
|
|
332
345
|
window.location.replace(formattedBlocklet?.navigation?.userCenter[0]?.link);
|
|
333
346
|
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.33",
|
|
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.33",
|
|
67
|
+
"@arcblock/ux": "^2.9.33",
|
|
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": "168b2bb058ab4487f2653c602431dbe6af5f9f97"
|
|
103
104
|
}
|
package/src/@types/index.ts
CHANGED
|
@@ -19,7 +19,7 @@ function useComponentInstalled({ did, onInstalled, onError }) {
|
|
|
19
19
|
|
|
20
20
|
const optComponents = useMemo(() => {
|
|
21
21
|
if (!optionalComponents || !optionalComponents.length) {
|
|
22
|
-
return
|
|
22
|
+
return [];
|
|
23
23
|
}
|
|
24
24
|
const didSet = parseDidToSet(didKeys);
|
|
25
25
|
const components = optionalComponents.filter((c) => didSet.has(c.meta.did));
|
|
@@ -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
|
}
|
|
@@ -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);
|