@blocklet/ui-react 2.11.38 → 2.11.39
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/lib/Footer/index.js +2 -1
- package/lib/Header/index.js +2 -1
- package/lib/libs/constant.d.ts +1 -0
- package/lib/libs/constant.js +1 -0
- package/lib/libs/with-hide-when-embed.d.ts +4 -0
- package/lib/libs/with-hide-when-embed.js +19 -0
- package/package.json +4 -4
- package/src/Footer/index.jsx +2 -2
- package/src/Header/index.tsx +2 -1
- package/src/libs/constant.ts +1 -0
- package/src/libs/with-hide-when-embed.tsx +24 -0
package/lib/Footer/index.js
CHANGED
|
@@ -12,6 +12,7 @@ import InternalFooter from "./internal-footer.js";
|
|
|
12
12
|
import { mapRecursive } from "../utils.js";
|
|
13
13
|
import { formatBlockletInfo, getLocalizedNavigation } from "../blocklets.js";
|
|
14
14
|
import { BlockletMetaProps } from "../types.js";
|
|
15
|
+
import withHideWhenEmbed from "../libs/with-hide-when-embed.js";
|
|
15
16
|
function Footer({ meta, theme: themeOverrides, ...rest }) {
|
|
16
17
|
const { locale } = useLocaleContext() || {};
|
|
17
18
|
const formattedBlocklet = useMemo(() => {
|
|
@@ -77,6 +78,6 @@ const StyledInternalFooter = styled(InternalFooter)`
|
|
|
77
78
|
font-family: Inter, Avenir, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif,
|
|
78
79
|
'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
|
|
79
80
|
`;
|
|
80
|
-
export default withErrorBoundary(Footer, {
|
|
81
|
+
export default withErrorBoundary(withHideWhenEmbed(Footer), {
|
|
81
82
|
FallbackComponent: ErrorFallback
|
|
82
83
|
});
|
package/lib/Header/index.js
CHANGED
|
@@ -15,6 +15,7 @@ import { mapRecursive, flatRecursive, matchPaths } from "../utils.js";
|
|
|
15
15
|
import { publicPath, formatBlockletInfo, getLocalizedNavigation } from "../blocklets.js";
|
|
16
16
|
import HeaderAddons from "../common/header-addons.js";
|
|
17
17
|
import { useWalletHiddenTopbar } from "../common/wallet-hidden-topbar.js";
|
|
18
|
+
import withHideWhenEmbed from "../libs/with-hide-when-embed.js";
|
|
18
19
|
const parseNavigation = (navigation) => {
|
|
19
20
|
if (!navigation?.length) {
|
|
20
21
|
return { navItems: [], activeId: null };
|
|
@@ -144,6 +145,6 @@ const StyledUxHeader = styled(ResponsiveHeader)`
|
|
|
144
145
|
}
|
|
145
146
|
}
|
|
146
147
|
`;
|
|
147
|
-
export default withErrorBoundary(Header, {
|
|
148
|
+
export default withErrorBoundary(withHideWhenEmbed(Header), {
|
|
148
149
|
FallbackComponent: ErrorFallback
|
|
149
150
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const EMBED_MODE_KEY = "blocklet-ui-react-embed-mode";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const EMBED_MODE_KEY = "blocklet-ui-react-embed-mode";
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useSessionStorageState } from "ahooks";
|
|
3
|
+
import { EMBED_MODE_KEY } from "./constant.js";
|
|
4
|
+
export default function withHideWhenEmbed(Component) {
|
|
5
|
+
const displayName = Component.displayName || Component.name || "Component";
|
|
6
|
+
function WrappedComponent(props) {
|
|
7
|
+
const [embedMode] = useSessionStorageState(EMBED_MODE_KEY, {
|
|
8
|
+
defaultValue: 0,
|
|
9
|
+
listenStorageChange: true
|
|
10
|
+
});
|
|
11
|
+
const isEmbed = embedMode === 1;
|
|
12
|
+
if (isEmbed) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
return /* @__PURE__ */ jsx(Component, { ...props });
|
|
16
|
+
}
|
|
17
|
+
WrappedComponent.displayName = `withHideWhenEmbed(${displayName})`;
|
|
18
|
+
return WrappedComponent;
|
|
19
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/ui-react",
|
|
3
|
-
"version": "2.11.
|
|
3
|
+
"version": "2.11.39",
|
|
4
4
|
"description": "Some useful front-end web components that can be used in Blocklets.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@abtnode/constant": "^1.16.38",
|
|
36
|
-
"@arcblock/bridge": "^2.11.
|
|
37
|
-
"@arcblock/react-hooks": "^2.11.
|
|
36
|
+
"@arcblock/bridge": "^2.11.39",
|
|
37
|
+
"@arcblock/react-hooks": "^2.11.39",
|
|
38
38
|
"@arcblock/ws": "^1.19.9",
|
|
39
39
|
"@blocklet/did-space-react": "^1.0.15",
|
|
40
40
|
"@iconify-icons/logos": "^1.2.36",
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
"jest": "^29.7.0",
|
|
85
85
|
"unbuild": "^2.0.0"
|
|
86
86
|
},
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "25c50d858ec85c90cefcbe43b4e841f039b0800a"
|
|
88
88
|
}
|
package/src/Footer/index.jsx
CHANGED
|
@@ -12,7 +12,7 @@ import InternalFooter from './internal-footer';
|
|
|
12
12
|
import { mapRecursive } from '../utils';
|
|
13
13
|
import { formatBlockletInfo, getLocalizedNavigation } from '../blocklets';
|
|
14
14
|
import { BlockletMetaProps } from '../types';
|
|
15
|
-
|
|
15
|
+
import withHideWhenEmbed from '../libs/with-hide-when-embed';
|
|
16
16
|
/**
|
|
17
17
|
* 专门用于 (composable) blocklet 的 Footer 组件, 基于 blocklet meta 中的数据渲染
|
|
18
18
|
*/
|
|
@@ -90,6 +90,6 @@ const StyledInternalFooter = styled(InternalFooter)`
|
|
|
90
90
|
'Apple Color Emoji', 'Segoe UI Emoji', 'Segoe UI Symbol';
|
|
91
91
|
`;
|
|
92
92
|
|
|
93
|
-
export default withErrorBoundary(Footer, {
|
|
93
|
+
export default withErrorBoundary(withHideWhenEmbed(Footer), {
|
|
94
94
|
FallbackComponent: ErrorFallback,
|
|
95
95
|
});
|
package/src/Header/index.tsx
CHANGED
|
@@ -17,6 +17,7 @@ import { publicPath, formatBlockletInfo, getLocalizedNavigation } from '../block
|
|
|
17
17
|
import HeaderAddons from '../common/header-addons';
|
|
18
18
|
import { useWalletHiddenTopbar } from '../common/wallet-hidden-topbar';
|
|
19
19
|
import { BlockletMetaProps, SessionManagerProps } from '../@types';
|
|
20
|
+
import withHideWhenEmbed from '../libs/with-hide-when-embed';
|
|
20
21
|
|
|
21
22
|
// blocklet meta 中的 navigation 数据 => NavMenu 组件的 items
|
|
22
23
|
const parseNavigation = (navigation: any) => {
|
|
@@ -193,6 +194,6 @@ const StyledUxHeader = styled(ResponsiveHeader)<StyledUxHeaderProps>`
|
|
|
193
194
|
}
|
|
194
195
|
`;
|
|
195
196
|
|
|
196
|
-
export default withErrorBoundary(Header, {
|
|
197
|
+
export default withErrorBoundary(withHideWhenEmbed(Header), {
|
|
197
198
|
FallbackComponent: ErrorFallback,
|
|
198
199
|
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const EMBED_MODE_KEY = 'blocklet-ui-react-embed-mode';
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useSessionStorageState } from 'ahooks';
|
|
2
|
+
import { EMBED_MODE_KEY } from './constant';
|
|
3
|
+
|
|
4
|
+
export default function withHideWhenEmbed<T extends object>(Component: React.ComponentType<T>) {
|
|
5
|
+
const displayName = Component.displayName || Component.name || 'Component';
|
|
6
|
+
|
|
7
|
+
function WrappedComponent(props: T) {
|
|
8
|
+
const [embedMode] = useSessionStorageState(EMBED_MODE_KEY, {
|
|
9
|
+
defaultValue: 0,
|
|
10
|
+
listenStorageChange: true,
|
|
11
|
+
});
|
|
12
|
+
const isEmbed = embedMode === 1;
|
|
13
|
+
|
|
14
|
+
if (isEmbed) {
|
|
15
|
+
return null;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return <Component {...props} />;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
WrappedComponent.displayName = `withHideWhenEmbed(${displayName})`;
|
|
22
|
+
|
|
23
|
+
return WrappedComponent;
|
|
24
|
+
}
|