@blocklet/ui-react 2.13.14 → 2.13.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.
@@ -6,12 +6,12 @@ import { SessionContext } from "@arcblock/did-connect/lib/Session";
6
6
  import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
7
7
  import UxImg from "@arcblock/ux/lib/Img";
8
8
  import UxDashboard from "@arcblock/ux/lib/Layout/dashboard";
9
+ import useBlockletLogo from "@arcblock/ux/lib/hooks/use-blocklet-logo";
9
10
  import { BlockletMetaProps, SessionManagerProps } from "../types.js";
10
11
  import { mapRecursive, flatRecursive, matchPaths } from "../utils.js";
11
12
  import { publicPath, formatBlockletInfo, getLocalizedNavigation, filterNavByRole } from "../blocklets.js";
12
13
  import HeaderAddons from "../common/header-addons.js";
13
14
  import { useWalletHiddenTopbar } from "../common/wallet-hidden-topbar.js";
14
- import useBlockletLogo from "../hooks/use-blocklet-logo.js";
15
15
  function Dashboard({
16
16
  meta,
17
17
  fallbackUrl,
@@ -5,13 +5,13 @@ import { styled, useTheme, deepmerge, ThemeProvider } from "@arcblock/ux/lib/The
5
5
  import { withErrorBoundary } from "react-error-boundary";
6
6
  import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
7
7
  import { ErrorFallback } from "@arcblock/ux/lib/ErrorBoundary";
8
+ import useBlockletLogo from "@arcblock/ux/lib/hooks/use-blocklet-logo";
8
9
  import omit from "lodash/omit";
9
10
  import InternalFooter from "./internal-footer.js";
10
11
  import { mapRecursive } from "../utils.js";
11
12
  import { formatBlockletInfo, getLocalizedNavigation } from "../blocklets.js";
12
13
  import { BlockletMetaProps } from "../types.js";
13
14
  import withHideWhenEmbed from "../libs/with-hide-when-embed.js";
14
- import useBlockletLogo from "../hooks/use-blocklet-logo.js";
15
15
  function Footer({ meta, theme: themeOverrides, ...rest }) {
16
16
  const { locale } = useLocaleContext() || {};
17
17
  const parentTheme = useTheme();
@@ -8,6 +8,7 @@ import { ResponsiveHeader } from "@arcblock/ux/lib/Header";
8
8
  import NavMenu, { Products } from "@arcblock/ux/lib/NavMenu";
9
9
  import { useLocaleContext } from "@arcblock/ux/lib/Locale/context";
10
10
  import { translate } from "@arcblock/ux/lib/Locale/util";
11
+ import useBlockletLogo from "@arcblock/ux/lib/hooks/use-blocklet-logo";
11
12
  import omit from "lodash/omit";
12
13
  import isFinite from "lodash/isFinite";
13
14
  import clsx from "clsx";
@@ -17,7 +18,6 @@ import { publicPath, formatBlockletInfo, getLocalizedNavigation } from "../block
17
18
  import HeaderAddons from "../common/header-addons.js";
18
19
  import { useWalletHiddenTopbar } from "../common/wallet-hidden-topbar.js";
19
20
  import withHideWhenEmbed from "../libs/with-hide-when-embed.js";
20
- import useBlockletLogo from "../hooks/use-blocklet-logo.js";
21
21
  const translations = {
22
22
  en: {
23
23
  products: "Products"
@@ -147,7 +147,22 @@ export default function ThirdPartyItem({
147
147
  overflow: "hidden"
148
148
  },
149
149
  children: [
150
- /* @__PURE__ */ jsx(Box, { component: Icon, icon, width: "1em", height: "1em", sx: { flexShrink: 0, fontSize: 16 } }),
150
+ /* @__PURE__ */ jsx(
151
+ Box,
152
+ {
153
+ component: Icon,
154
+ icon,
155
+ width: "1em",
156
+ height: "1em",
157
+ fill: "currentColor",
158
+ sx: {
159
+ flexShrink: 0,
160
+ fontSize: 16,
161
+ // githubIcon 不支持变色,dark 模式做一个反色处理
162
+ filter: ({ palette }) => item?.provider === LOGIN_PROVIDER.GITHUB && palette.mode === "dark" ? "invert(1)" : "none"
163
+ }
164
+ }
165
+ ),
151
166
  /* @__PURE__ */ jsx(
152
167
  Box,
153
168
  {
@@ -1,6 +1,5 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
- import { Box, Button, FormControl, IconButton, TextField, Typography } from "@mui/material";
3
- import styled from "@emotion/styled";
2
+ import { Box, Button, FormControl, IconButton, styled, TextField, Typography } from "@mui/material";
4
3
  import RemoveIcon from "@mui/icons-material/Remove";
5
4
  import AddIcon from "@mui/icons-material/Add";
6
5
  import { useEffect, useMemo, useState } from "react";
@@ -173,14 +172,14 @@ export function LinkPreviewInput({
173
172
  link
174
173
  )) });
175
174
  }
176
- const LinkDiv = styled.span`
175
+ const LinkDiv = styled("span")`
177
176
  flex: 1;
178
177
  white-space: nowrap;
179
178
  overflow: hidden;
180
179
  text-overflow: ellipsis;
181
180
  &,
182
181
  & > * {
183
- color: #222;
182
+ color: ${({ theme }) => theme.palette.text.primary};
184
183
  }
185
184
 
186
185
  & > * {
@@ -53,11 +53,13 @@ export default function UserInfo({
53
53
  title: t("registerFrom"),
54
54
  content: readableProvider
55
55
  });
56
- userInfoListData.push({
57
- icon: /* @__PURE__ */ jsx(Icon, { fontSize: 16, icon: CaptivePortalRoundedIcon }),
58
- title: t("invitedBy"),
59
- content: user?.inviter ? /* @__PURE__ */ jsx(DID, { style: { maxWidth: 260 }, did: user.inviter, showQrcode: true, copyable: true, compact: true, responsive: true, locale }) : "-"
60
- });
56
+ if (user?.inviter) {
57
+ userInfoListData.push({
58
+ icon: /* @__PURE__ */ jsx(Icon, { fontSize: 16, icon: CaptivePortalRoundedIcon }),
59
+ title: t("invitedBy"),
60
+ content: /* @__PURE__ */ jsx(DID, { style: { maxWidth: 260 }, did: user.inviter, showQrcode: true, copyable: true, compact: true, responsive: true, locale })
61
+ });
62
+ }
61
63
  }
62
64
  return /* @__PURE__ */ jsx(
63
65
  Box,
@@ -318,12 +318,10 @@ export default function UserSessions({
318
318
  },
319
319
  ".MuiTableCell-head": {
320
320
  whiteSpace: "nowrap",
321
- fontWeight: "bold",
322
- backgroundColor: "background.default"
321
+ fontWeight: "bold"
323
322
  },
324
323
  ".MuiTableRow-root": {
325
324
  border: "unset",
326
- backgroundColor: "background.default",
327
325
  "&:nth-child(even)": {
328
326
  backgroundColor: "grey.50",
329
327
  "&:hover": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/ui-react",
3
- "version": "2.13.14",
3
+ "version": "2.13.15",
4
4
  "description": "Some useful front-end web components that can be used in Blocklets.",
5
5
  "keywords": [
6
6
  "react",
@@ -34,8 +34,8 @@
34
34
  "dependencies": {
35
35
  "@abtnode/constant": "^1.16.42",
36
36
  "@abtnode/util": "^1.16.42",
37
- "@arcblock/bridge": "^2.13.14",
38
- "@arcblock/react-hooks": "^2.13.14",
37
+ "@arcblock/bridge": "^2.13.15",
38
+ "@arcblock/react-hooks": "^2.13.15",
39
39
  "@arcblock/ws": "^1.20.2",
40
40
  "@blocklet/constant": "^1.16.42",
41
41
  "@blocklet/did-space-react": "^1.0.48",
@@ -94,5 +94,5 @@
94
94
  "jest": "^29.7.0",
95
95
  "unbuild": "^2.0.0"
96
96
  },
97
- "gitHead": "b9f48199169b641a2d3277806501471a56dd496d"
97
+ "gitHead": "94d15cfb22e13272502bb40863c5b059cb13eab5"
98
98
  }
@@ -7,12 +7,12 @@ import { SessionContext } from '@arcblock/did-connect/lib/Session';
7
7
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
8
8
  import UxImg from '@arcblock/ux/lib/Img';
9
9
  import UxDashboard from '@arcblock/ux/lib/Layout/dashboard';
10
+ import useBlockletLogo from '@arcblock/ux/lib/hooks/use-blocklet-logo';
10
11
  import { BlockletMetaProps, SessionManagerProps } from '../types';
11
12
  import { mapRecursive, flatRecursive, matchPaths } from '../utils';
12
13
  import { publicPath, formatBlockletInfo, getLocalizedNavigation, filterNavByRole } from '../blocklets';
13
14
  import HeaderAddons from '../common/header-addons';
14
15
  import { useWalletHiddenTopbar } from '../common/wallet-hidden-topbar';
15
- import useBlockletLogo from '../hooks/use-blocklet-logo';
16
16
 
17
17
  /**
18
18
  * 专门用于 (composable) blocklet 的 Dashboard 组件, 解析 blocklet meta 中 section 为 dashboard 的 navigation 数据, 渲染一个 UX Dashboard
@@ -4,6 +4,7 @@ import { styled, useTheme, deepmerge, ThemeProvider } from '@arcblock/ux/lib/The
4
4
  import { withErrorBoundary } from 'react-error-boundary';
5
5
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
6
6
  import { ErrorFallback } from '@arcblock/ux/lib/ErrorBoundary';
7
+ import useBlockletLogo from '@arcblock/ux/lib/hooks/use-blocklet-logo';
7
8
  import omit from 'lodash/omit';
8
9
 
9
10
  import InternalFooter from './internal-footer';
@@ -11,7 +12,6 @@ import { mapRecursive } from '../utils';
11
12
  import { formatBlockletInfo, getLocalizedNavigation } from '../blocklets';
12
13
  import { BlockletMetaProps } from '../types';
13
14
  import withHideWhenEmbed from '../libs/with-hide-when-embed';
14
- import useBlockletLogo from '../hooks/use-blocklet-logo';
15
15
 
16
16
  /**
17
17
  * 专门用于 (composable) blocklet 的 Footer 组件, 基于 blocklet meta 中的数据渲染
@@ -7,6 +7,7 @@ import { ResponsiveHeader } from '@arcblock/ux/lib/Header';
7
7
  import NavMenu, { Products } from '@arcblock/ux/lib/NavMenu';
8
8
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
9
9
  import { translate } from '@arcblock/ux/lib/Locale/util';
10
+ import useBlockletLogo from '@arcblock/ux/lib/hooks/use-blocklet-logo';
10
11
  import omit from 'lodash/omit';
11
12
  import isFinite from 'lodash/isFinite';
12
13
  import type { BoxProps, Breakpoint } from '@mui/material';
@@ -19,7 +20,6 @@ import HeaderAddons from '../common/header-addons';
19
20
  import { useWalletHiddenTopbar } from '../common/wallet-hidden-topbar';
20
21
  import { BlockletMetaProps, SessionManagerProps } from '../@types';
21
22
  import withHideWhenEmbed from '../libs/with-hide-when-embed';
22
- import useBlockletLogo from '../hooks/use-blocklet-logo';
23
23
 
24
24
  const translations = {
25
25
  en: {
@@ -170,7 +170,20 @@ export default function ThirdPartyItem({
170
170
  lineHeight: 1,
171
171
  overflow: 'hidden',
172
172
  }}>
173
- <Box component={Icon} icon={icon} width="1em" height="1em" sx={{ flexShrink: 0, fontSize: 16 }} />
173
+ <Box
174
+ component={Icon}
175
+ icon={icon}
176
+ width="1em"
177
+ height="1em"
178
+ fill="currentColor"
179
+ sx={{
180
+ flexShrink: 0,
181
+ fontSize: 16,
182
+ // githubIcon 不支持变色,dark 模式做一个反色处理
183
+ filter: ({ palette }) =>
184
+ item?.provider === LOGIN_PROVIDER.GITHUB && palette.mode === 'dark' ? 'invert(1)' : 'none',
185
+ }}
186
+ />
174
187
  <Box
175
188
  sx={{
176
189
  flex: 1,
@@ -1,5 +1,4 @@
1
- import { Box, Button, FormControl, IconButton, TextField, Typography } from '@mui/material';
2
- import styled from '@emotion/styled';
1
+ import { Box, Button, FormControl, IconButton, styled, TextField, Typography } from '@mui/material';
3
2
  import RemoveIcon from '@mui/icons-material/Remove';
4
3
  import AddIcon from '@mui/icons-material/Add';
5
4
  import { ChangeEvent, useEffect, useMemo, useState } from 'react';
@@ -224,14 +223,14 @@ export function LinkPreviewInput({
224
223
  );
225
224
  }
226
225
 
227
- const LinkDiv = styled.span`
226
+ const LinkDiv = styled('span')`
228
227
  flex: 1;
229
228
  white-space: nowrap;
230
229
  overflow: hidden;
231
230
  text-overflow: ellipsis;
232
231
  &,
233
232
  & > * {
234
- color: #222;
233
+ color: ${({ theme }) => theme.palette.text.primary};
235
234
  }
236
235
 
237
236
  & > * {
@@ -63,15 +63,15 @@ export default function UserInfo({
63
63
  title: t('registerFrom'),
64
64
  content: readableProvider,
65
65
  });
66
- userInfoListData.push({
67
- icon: <Icon fontSize={16} icon={CaptivePortalRoundedIcon} />,
68
- title: t('invitedBy'),
69
- content: user?.inviter ? (
70
- <DID style={{ maxWidth: 260 }} did={user.inviter} showQrcode copyable compact responsive locale={locale} />
71
- ) : (
72
- '-'
73
- ),
74
- });
66
+ if (user?.inviter) {
67
+ userInfoListData.push({
68
+ icon: <Icon fontSize={16} icon={CaptivePortalRoundedIcon} />,
69
+ title: t('invitedBy'),
70
+ content: (
71
+ <DID style={{ maxWidth: 260 }} did={user.inviter} showQrcode copyable compact responsive locale={locale} />
72
+ ),
73
+ });
74
+ }
75
75
  }
76
76
 
77
77
  return (
@@ -391,11 +391,9 @@ export default function UserSessions({
391
391
  '.MuiTableCell-head': {
392
392
  whiteSpace: 'nowrap',
393
393
  fontWeight: 'bold',
394
- backgroundColor: 'background.default',
395
394
  },
396
395
  '.MuiTableRow-root': {
397
396
  border: 'unset',
398
- backgroundColor: 'background.default',
399
397
  '&:nth-child(even)': {
400
398
  backgroundColor: 'grey.50',
401
399
  '&:hover': {
@@ -1,8 +0,0 @@
1
- import { type Breakpoint } from '@mui/material';
2
- import { type ThemeOptions } from '@blocklet/theme';
3
- export default function useBlockletLogo({ key, meta, theme: themeOverrides, square, }?: {
4
- key?: number | Breakpoint;
5
- meta?: any;
6
- theme?: ThemeOptions;
7
- square?: boolean;
8
- }): any;
@@ -1,23 +0,0 @@
1
- import { useTheme } from "@arcblock/ux/lib/Theme";
2
- import { useCreation } from "ahooks";
3
- import useMobile from "./use-mobile.js";
4
- export default function useBlockletLogo({
5
- key = "sm",
6
- meta = {},
7
- theme: themeOverrides = {},
8
- square
9
- } = {}) {
10
- const isMobileDevice = useMobile({ key });
11
- const theme = useTheme();
12
- const mode = useCreation(() => {
13
- return themeOverrides?.palette?.mode || theme.palette.mode;
14
- }, [theme, themeOverrides]);
15
- const finalAppLogo = useCreation(() => {
16
- const { appLogo, appLogoDark, appLogoRect, appLogoRectDark } = Object.assign(window.blocklet ?? {}, meta);
17
- const isDark = mode === "dark";
18
- const squareLogo = (isDark ? appLogoDark : appLogo) || appLogo;
19
- const rectLogo = (isDark ? appLogoRectDark || appLogoDark : appLogoRect) || appLogoRect;
20
- return isMobileDevice || square ? squareLogo : rectLogo || squareLogo || "";
21
- }, [mode, meta, isMobileDevice, square]);
22
- return finalAppLogo;
23
- }
@@ -1,32 +0,0 @@
1
- import { type Breakpoint } from '@mui/material';
2
- import { type ThemeOptions } from '@blocklet/theme';
3
- import { useTheme } from '@arcblock/ux/lib/Theme';
4
- import { useCreation } from 'ahooks';
5
- import useMobile from './use-mobile';
6
-
7
- export default function useBlockletLogo({
8
- key = 'sm',
9
- meta = {},
10
- theme: themeOverrides = {},
11
- square,
12
- }: { key?: number | Breakpoint; meta?: any; theme?: ThemeOptions; square?: boolean } = {}) {
13
- const isMobileDevice = useMobile({ key });
14
- const theme = useTheme();
15
-
16
- const mode = useCreation(() => {
17
- return themeOverrides?.palette?.mode || theme.palette.mode;
18
- }, [theme, themeOverrides]);
19
-
20
- const finalAppLogo = useCreation(() => {
21
- const { appLogo, appLogoDark, appLogoRect, appLogoRectDark } = Object.assign(window.blocklet ?? {}, meta);
22
- const isDark = mode === 'dark';
23
-
24
- const squareLogo = (isDark ? appLogoDark : appLogo) || appLogo;
25
- // 深色模式尽可能优先使用深色图标
26
- const rectLogo = (isDark ? appLogoRectDark || appLogoDark : appLogoRect) || appLogoRect;
27
-
28
- return isMobileDevice || square ? squareLogo : rectLogo || squareLogo || '';
29
- }, [mode, meta, isMobileDevice, square]);
30
-
31
- return finalAppLogo;
32
- }