@blocklet/ui-react 2.11.14 → 2.11.16

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.
@@ -1,4 +1,5 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { useEffect } from "react";
2
3
  import { Box, Divider, Typography } from "@mui/material";
3
4
  import { useCreation, useMemoizedFn } from "ahooks";
4
5
  import { translate } from "@arcblock/ux/lib/Locale/util";
@@ -63,10 +64,17 @@ export default function Settings({
63
64
  {
64
65
  label: t("sessionManagement"),
65
66
  value: "session",
66
- content: /* @__PURE__ */ jsx(UserSessions, { user })
67
+ content: /* @__PURE__ */ jsx(UserSessions, { user, showUser: false })
67
68
  }
68
69
  ].filter(Boolean);
69
70
  }, [user, privacyConfigList]);
71
+ useEffect(() => {
72
+ const id = window.location.hash.slice(1);
73
+ if (id) {
74
+ const element = document.getElementById(id);
75
+ element?.scrollIntoView({ behavior: "smooth" });
76
+ }
77
+ }, []);
70
78
  return /* @__PURE__ */ jsx(
71
79
  Box,
72
80
  {
@@ -78,7 +86,7 @@ export default function Settings({
78
86
  },
79
87
  maxWidth: "100%"
80
88
  },
81
- children: tabs.map((tab, index) => /* @__PURE__ */ jsxs(Box, { children: [
89
+ children: tabs.map((tab, index) => /* @__PURE__ */ jsxs(Box, { id: tab.value, children: [
82
90
  /* @__PURE__ */ jsx(
83
91
  Typography,
84
92
  {
@@ -40,7 +40,7 @@ export default function UserCenter({
40
40
  stickySidebar = false
41
41
  }) {
42
42
  const { locale } = useLocaleContext();
43
- const isMobile = useMobile({});
43
+ const isMobile = useMobile({ key: "md" });
44
44
  const t = useMemoizedFn((key, data = {}) => {
45
45
  return translate(translations, key, locale, "en", data);
46
46
  });
@@ -10,9 +10,10 @@ import { getVisitorId } from "@arcblock/ux/lib/Util";
10
10
  import { useConfirm } from "@arcblock/ux/lib/Dialog";
11
11
  import pAll from "p-all";
12
12
  import PQueue from "p-queue";
13
- import { Box, Button, CircularProgress, Tooltip, Typography } from "@mui/material";
13
+ import { Box, Button, CircularProgress, Tooltip, Typography, useMediaQuery } from "@mui/material";
14
14
  import { memo, useContext, useEffect } from "react";
15
15
  import { SessionContext } from "@arcblock/did-connect/lib/Session";
16
+ import useMobile from "../../hooks/use-mobile.js";
16
17
  import UserSessionInfo from "./user-session-info.js";
17
18
  import { client } from "../../libs/client.js";
18
19
  import { translations } from "../libs/locales.js";
@@ -57,6 +58,8 @@ export default function UserSessions({
57
58
  const { session } = useContext(SessionContext);
58
59
  const currentVisitorId = getVisitorId();
59
60
  const { locale } = useLocaleContext();
61
+ const isMobile = useMobile({ key: "md" });
62
+ const isLg = useMediaQuery((theme) => theme.breakpoints.down("lg"));
60
63
  const { confirmApi, confirmHolder } = useConfirm();
61
64
  const t = useMemoizedFn((key, data = {}) => {
62
65
  return translate(translations, key, locale, "en", data);
@@ -257,7 +260,7 @@ export default function UserSessions({
257
260
  Box,
258
261
  {
259
262
  sx: {
260
- maxWidth: 920,
263
+ maxWidth: isMobile ? "unset" : isLg ? "calc(100vw - 300px)" : "920px",
261
264
  ".MuiTableCell-head": {
262
265
  whiteSpace: "nowrap",
263
266
  fontWeight: "bold"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/ui-react",
3
- "version": "2.11.14",
3
+ "version": "2.11.16",
4
4
  "description": "Some useful front-end web components that can be used in Blocklets.",
5
5
  "keywords": [
6
6
  "react",
@@ -32,8 +32,8 @@
32
32
  "url": "https://github.com/ArcBlock/ux/issues"
33
33
  },
34
34
  "dependencies": {
35
- "@arcblock/bridge": "^2.11.14",
36
- "@arcblock/react-hooks": "^2.11.14",
35
+ "@arcblock/bridge": "^2.11.16",
36
+ "@arcblock/react-hooks": "^2.11.16",
37
37
  "@blocklet/did-space-react": "^0.6.0",
38
38
  "@iconify-icons/logos": "^1.2.36",
39
39
  "@iconify-icons/material-symbols": "^1.2.58",
@@ -81,5 +81,5 @@
81
81
  "jest": "^29.7.0",
82
82
  "unbuild": "^2.0.0"
83
83
  },
84
- "gitHead": "6e1596d1a8ab9b74fd0588be21beb80eaeb68e35"
84
+ "gitHead": "1216fcd112e02c4135f5d748fe002cafaaebcfd9"
85
85
  }
@@ -1,3 +1,4 @@
1
+ import { useEffect } from 'react';
1
2
  import { Box, Divider, Typography } from '@mui/material';
2
3
  import type { BoxProps } from '@mui/material';
3
4
  import { useCreation, useMemoizedFn } from 'ahooks';
@@ -76,11 +77,20 @@ export default function Settings({
76
77
  {
77
78
  label: t('sessionManagement'),
78
79
  value: 'session',
79
- content: <UserSessions user={user} />,
80
+ content: <UserSessions user={user} showUser={false} />,
80
81
  },
81
82
  ].filter(Boolean);
82
83
  }, [user, privacyConfigList]);
83
84
 
85
+ // 支持 hash 锚点定位
86
+ useEffect(() => {
87
+ const id = window.location.hash.slice(1);
88
+ if (id) {
89
+ const element = document.getElementById(id);
90
+ element?.scrollIntoView({ behavior: 'smooth' });
91
+ }
92
+ }, []);
93
+
84
94
  return (
85
95
  <Box
86
96
  {...rest}
@@ -92,7 +102,7 @@ export default function Settings({
92
102
  maxWidth: '100%',
93
103
  }}>
94
104
  {tabs.map((tab, index) => (
95
- <Box key={tab.value}>
105
+ <Box id={tab.value} key={tab.value}>
96
106
  <Typography
97
107
  sx={{
98
108
  color: colors.foregroundsFgBase,
@@ -61,7 +61,7 @@ export default function UserCenter({
61
61
  readonly stickySidebar?: boolean;
62
62
  }) {
63
63
  const { locale } = useLocaleContext();
64
- const isMobile = useMobile({});
64
+ const isMobile = useMobile({ key: 'md' });
65
65
  const t = useMemoizedFn((key, data = {}) => {
66
66
  return translate(translations, key, locale, 'en', data);
67
67
  });
@@ -11,11 +11,12 @@ import { getVisitorId } from '@arcblock/ux/lib/Util';
11
11
  import { useConfirm } from '@arcblock/ux/lib/Dialog';
12
12
  import pAll from 'p-all';
13
13
  import PQueue from 'p-queue';
14
- import { Box, Button, CircularProgress, Tooltip, Typography } from '@mui/material';
14
+ import { Box, Button, CircularProgress, Tooltip, Typography, useMediaQuery } from '@mui/material';
15
15
  import { memo, ReactElement, useContext, useEffect } from 'react';
16
16
  import { UserSession } from '@blocklet/js-sdk';
17
17
  import { SessionContext } from '@arcblock/did-connect/lib/Session';
18
18
 
19
+ import useMobile from '../../hooks/use-mobile';
19
20
  import UserSessionInfo from './user-session-info';
20
21
  import { User, SessionContext as TSessionContext } from '../../@types';
21
22
  import { client } from '../../libs/client';
@@ -88,6 +89,8 @@ export default function UserSessions({
88
89
  const { session } = useContext<TSessionContext>(SessionContext);
89
90
  const currentVisitorId = getVisitorId();
90
91
  const { locale } = useLocaleContext();
92
+ const isMobile = useMobile({ key: 'md' });
93
+ const isLg = useMediaQuery((theme: any) => theme.breakpoints.down('lg'));
91
94
  const { confirmApi, confirmHolder } = useConfirm();
92
95
  const t = useMemoizedFn((key, data = {}) => {
93
96
  return translate(translations, key, locale, 'en', data);
@@ -308,7 +311,7 @@ export default function UserSessions({
308
311
  return (
309
312
  <Box
310
313
  sx={{
311
- maxWidth: 920,
314
+ maxWidth: isMobile ? 'unset' : isLg ? 'calc(100vw - 300px)' : '920px',
312
315
  '.MuiTableCell-head': {
313
316
  whiteSpace: 'nowrap',
314
317
  fontWeight: 'bold',