@blocklet/ui-react 3.0.39 → 3.0.41

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.
@@ -11,7 +11,7 @@ import C from "../Icon/index.js";
11
11
  import A from "../hooks/use-mobile.js";
12
12
  import { splitNavColumns as E } from "../utils.js";
13
13
  function F({ links: e = [], flowLayout: d = !1, columns: u, ...x }) {
14
- const [g, b] = N(-1), y = A({ key: "md" }), h = e.some((t) => t.items?.length), k = !y && h && j(u) && u > 1, p = ({ label: t, link: o, icon: i, render: a, props: n }) => {
14
+ const [g, b] = N(-1), w = A({ key: "md" }), h = e.some((t) => t.items?.length), k = !w && h && j(u) && u > 1, p = ({ label: t, link: o, icon: i, render: a, props: n }) => {
15
15
  let s = t;
16
16
  if (a)
17
17
  s = a({ label: t, link: o, props: n });
@@ -33,7 +33,7 @@ function F({ links: e = [], flowLayout: d = !1, columns: u, ...x }) {
33
33
  i && /* @__PURE__ */ r(C, { icon: i, size: 20, sx: { mr: 0.5 } }),
34
34
  s
35
35
  ] });
36
- }, w = $(() => e?.length ? d ? e.map((t, o) => /* @__PURE__ */ r("span", { className: "footer-links-item", children: p(t) }, o)) : k ? E(e, { columns: u }).map((t, o) => /* @__PURE__ */ r("div", { className: "footer-links-column", children: t.filter((i) => i.group).map((i, a) => {
36
+ }, y = $(() => e?.length ? d ? e.map((t, o) => /* @__PURE__ */ r("span", { className: "footer-links-item", children: p(t) }, o)) : k ? E(e, { columns: u }).map((t, o) => /* @__PURE__ */ r("div", { className: "footer-links-column", children: t.filter((i) => i.group).map((i, a) => {
37
37
  const { items: n } = i;
38
38
  return /* @__PURE__ */ m("div", { className: "footer-links-group", children: [
39
39
  /* @__PURE__ */ r("span", { className: "footer-links-item", children: p(i) }),
@@ -82,7 +82,7 @@ function F({ links: e = [], flowLayout: d = !1, columns: u, ...x }) {
82
82
  "footer-links--flow": d,
83
83
  "footer-links--columns": k
84
84
  }),
85
- children: /* @__PURE__ */ r("div", { className: "footer-links-inner", children: w })
85
+ children: /* @__PURE__ */ r("div", { className: "footer-links-inner", children: y })
86
86
  }
87
87
  ) : null;
88
88
  }
@@ -131,6 +131,7 @@ const R = z("div")`
131
131
  position: relative;
132
132
  padding: 6px 8px;
133
133
  font-size: 14px;
134
+ white-space: nowrap;
134
135
  &--new::after {
135
136
  content: 'New';
136
137
  color: ${({ theme: e }) => e.palette.info.main};
@@ -1,141 +1,153 @@
1
- import { jsx as n } from "react/jsx-runtime";
2
- import { useMemo as k } from "react";
3
- import { useMemoizedFn as $ } from "ahooks";
4
- import { withErrorBoundary as N } from "react-error-boundary";
5
- import { ErrorFallback as H } from "@arcblock/ux/lib/ErrorBoundary";
6
- import { styled as y, useTheme as C, deepmerge as T, ThemeProvider as _ } from "@arcblock/ux/lib/Theme";
7
- import { ResponsiveHeader as E } from "@arcblock/ux/lib/Header";
8
- import B, { Products as F } from "@arcblock/ux/lib/NavMenu";
9
- import { useLocaleContext as L } from "@arcblock/ux/lib/Locale/context";
10
- import { translate as P } from "@arcblock/ux/lib/Locale/util";
11
- import R from "@arcblock/ux/lib/hooks/use-blocklet-logo";
12
- import z from "lodash/omit";
13
- import A from "lodash/isFinite";
14
- import M from "clsx";
1
+ import { jsx as a } from "react/jsx-runtime";
2
+ import { useMemo as f } from "react";
3
+ import { useMemoizedFn as N } from "ahooks";
4
+ import { withErrorBoundary as $ } from "react-error-boundary";
5
+ import { ErrorFallback as C } from "@arcblock/ux/lib/ErrorBoundary";
6
+ import { styled as H, useTheme as _, deepmerge as w, ThemeProvider as A } from "@arcblock/ux/lib/Theme";
7
+ import { ResponsiveHeader as B } from "@arcblock/ux/lib/Header";
8
+ import L, { Products as R } from "@arcblock/ux/lib/NavMenu";
9
+ import { useLocaleContext as F } from "@arcblock/ux/lib/Locale/context";
10
+ import { translate as M } from "@arcblock/ux/lib/Locale/util";
11
+ import O from "@arcblock/ux/lib/hooks/use-blocklet-logo";
12
+ import P from "lodash/omit";
13
+ import I from "lodash/isFinite";
14
+ import z from "clsx";
15
15
  import W from "../Icon/index.js";
16
- import { mapRecursive as j, flatRecursive as S, matchPaths as U } from "../utils.js";
17
- import { formatBlockletInfo as K, getLocalizedNavigation as O, publicPath as q } from "../blocklets.js";
16
+ import { mapRecursive as S, flatRecursive as U, matchPaths as j } from "../utils.js";
17
+ import { formatBlockletInfo as G, getLocalizedNavigation as K, publicPath as q } from "../blocklets.js";
18
18
  import D from "../common/header-addons.js";
19
- import { useWalletHiddenTopbar as G } from "../common/wallet-hidden-topbar.js";
20
- import J from "../libs/with-hide-when-embed.js";
21
- const Q = {
19
+ import { useWalletHiddenTopbar as J } from "../common/wallet-hidden-topbar.js";
20
+ import Q from "../libs/with-hide-when-embed.js";
21
+ const V = {
22
22
  en: {
23
23
  products: "Products"
24
24
  },
25
25
  zh: {
26
26
  products: "产品"
27
27
  }
28
- }, V = (e) => {
29
- if (!e?.length)
28
+ }, X = (r) => {
29
+ if (!r?.length)
30
30
  return { navItems: [], activeId: null };
31
- let r = 1;
32
- const s = j(e, (o) => {
33
- const i = o.icon ? /* @__PURE__ */ n(W, { icon: o.icon }) : null;
34
- if (o.items)
31
+ let t = 1;
32
+ const c = S(r, (e) => {
33
+ const i = e.icon ? /* @__PURE__ */ a(W, { icon: e.icon }) : null;
34
+ if (e.items)
35
35
  return {
36
- id: `${r++}`,
37
- label: o.title,
36
+ id: `${t++}`,
37
+ label: e.title,
38
38
  icon: i,
39
- children: o.items
39
+ children: e.items
40
40
  };
41
- let l = {};
42
- return (o.link?.startsWith("http") || o.link?.startsWith("//")) && (l = {
41
+ let s = {};
42
+ return (e.link?.startsWith("http") || e.link?.startsWith("//")) && (s = {
43
43
  target: "_blank",
44
44
  rel: "noreferrer"
45
45
  }), {
46
- id: `${r++}`,
47
- label: /* @__PURE__ */ n("a", { href: o.link, ...l, children: o.title }),
46
+ id: `${t++}`,
47
+ label: /* @__PURE__ */ a("a", { href: e.link, ...s, children: e.title }),
48
48
  icon: i,
49
- description: o.description,
50
- link: o.link
49
+ description: e.description,
50
+ link: e.link
51
51
  };
52
- }, "items"), a = S(s), d = U(a.map((o) => o.link));
53
- return { navItems: s, activeId: d >= 0 ? a[d].id : null };
52
+ }, "items"), l = U(c), p = j(l.map((e) => e.link));
53
+ return { navItems: c, activeId: p >= 0 ? l[p].id : null };
54
54
  };
55
- function X({
56
- meta: e = {},
57
- addons: r = void 0,
58
- sessionManagerProps: u = {
55
+ function Y({
56
+ meta: r = {},
57
+ addons: t = void 0,
58
+ sessionManagerProps: h = {
59
59
  showRole: !0
60
60
  },
61
- homeLink: s = q,
62
- theme: a = void 0,
63
- hideNavMenu: d = !1,
64
- showDomainWarningDialog: o = !0,
61
+ homeLink: c = q,
62
+ theme: l = void 0,
63
+ hideNavMenu: p = !1,
64
+ showDomainWarningDialog: e = !0,
65
65
  ...i
66
66
  }) {
67
- G();
68
- const l = C(), { locale: h } = L() || {}, v = $((t, f = {}) => P(Q, t, h, "en", f)), m = k(() => {
69
- const t = Object.assign({}, window.blocklet, e);
67
+ J();
68
+ const s = _(), { locale: b } = F() || {}, x = N((o, n = {}) => M(V, o, b, "en", n)), d = f(() => {
69
+ const o = Object.assign({}, window.blocklet, r);
70
70
  try {
71
- return K(t);
72
- } catch (f) {
73
- return console.error("Failed to format blocklet info", f, t), t;
71
+ return G(o);
72
+ } catch (n) {
73
+ return console.error("Failed to format blocklet info", n, o), o;
74
74
  }
75
- }, [e]), c = k(() => T(l, a), [l, a]), x = R({
76
- meta: e,
77
- theme: a
78
- });
79
- if (!m.appName)
75
+ }, [r]), m = f(() => w(s, l), [s, l]), y = O({
76
+ meta: r,
77
+ theme: l
78
+ }), { productsOrder: g, productsType: k } = f(() => {
79
+ let { USE_ARCBLOCK_THEME: o, USE_AIGNE_THEME: n } = d;
80
+ return o = parseInt(o, 10), n = parseInt(n, 10), I(n) ? {
81
+ productsOrder: n,
82
+ productsType: "AIGNE"
83
+ } : I(o) ? {
84
+ productsOrder: o,
85
+ productsType: "ARCBLOCK"
86
+ } : {
87
+ productsOrder: null,
88
+ productsType: null
89
+ };
90
+ }, [d]);
91
+ if (!d.appName)
80
92
  return null;
81
- const I = O(m?.navigation?.header, h), b = V(I), { navItems: p, activeId: w } = b, g = parseInt(window.blocklet?.USE_ARCBLOCK_THEME, 10);
82
- return A(g) && p.splice(g, 0, {
83
- label: v("products"),
93
+ const T = K(d?.navigation?.header, b), v = X(T), { navItems: u, activeId: E } = v;
94
+ return k && Number.isInteger(g) && u.splice(g, 0, {
95
+ label: x("products"),
84
96
  // eslint-disable-next-line react/no-unstable-nested-components
85
- children: ({ isOpen: t }) => /* @__PURE__ */ n(F, { isOpen: t })
86
- }), /* @__PURE__ */ n(_, { theme: c, children: /* @__PURE__ */ n(
87
- Y,
97
+ children: () => /* @__PURE__ */ a(R, { type: k })
98
+ }), /* @__PURE__ */ a(A, { theme: m, children: /* @__PURE__ */ a(
99
+ Z,
88
100
  {
89
- homeLink: s,
90
- logo: /* @__PURE__ */ n("img", { src: x, alt: "logo" }),
101
+ homeLink: c,
102
+ logo: /* @__PURE__ */ a("img", { src: y, alt: "logo" }),
91
103
  addons: (
92
104
  // @ts-ignore
93
- /* @__PURE__ */ n(
105
+ /* @__PURE__ */ a(
94
106
  D,
95
107
  {
96
- formattedBlocklet: m,
97
- addons: typeof r == "function" ? (t) => r(t, { navigation: b }) : r,
98
- sessionManagerProps: u,
99
- showDomainWarningDialog: o
108
+ formattedBlocklet: d,
109
+ addons: typeof t == "function" ? (o) => t(o, { navigation: v }) : t,
110
+ sessionManagerProps: h,
111
+ showDomainWarningDialog: e
100
112
  }
101
113
  )
102
114
  ),
103
- ...z(i, ["bordered"]),
115
+ ...P(i, ["bordered"]),
104
116
  $bordered: i?.bordered,
105
- $bgcolor: c.palette.background.default,
106
- className: M("blocklet__header", i.className),
107
- children: d || !p?.length ? null : ({ isMobile: t }) => (
117
+ $bgcolor: m.palette.background.default,
118
+ className: z("blocklet__header", i.className),
119
+ children: p || !u?.length ? null : ({ isMobile: o }) => (
108
120
  // @ts-ignore
109
- /* @__PURE__ */ n(
110
- B,
121
+ /* @__PURE__ */ a(
122
+ L,
111
123
  {
112
- mode: t ? "inline" : "horizontal",
113
- activeId: w,
114
- items: p,
124
+ mode: o ? "inline" : "horizontal",
125
+ activeId: E,
126
+ items: u,
115
127
  className: "header-nav",
116
128
  bgColor: "transparent",
117
- textColor: c.palette.grey[500],
118
- activeTextColor: c.palette.text.primary
129
+ textColor: m.palette.grey[500],
130
+ activeTextColor: m.palette.text.primary
119
131
  }
120
132
  )
121
133
  )
122
134
  }
123
135
  ) });
124
136
  }
125
- const Y = y(E)`
126
- ${({ $bgcolor: e }) => `background-color: ${e || "#fff"};`}
137
+ const Z = H(B)`
138
+ ${({ $bgcolor: r }) => `background-color: ${r || "#fff"};`}
127
139
  .header-logo {
128
140
  min-width: 44px;
129
141
  }
130
- ${({ $bordered: e, theme: r }) => e ? `border-bottom: 1px solid ${r.palette.divider};` : ""}
131
- ${(e) => e.theme.breakpoints.down("md")} {
142
+ ${({ $bordered: r, theme: t }) => r ? `border-bottom: 1px solid ${t.palette.divider};` : ""}
143
+ ${(r) => r.theme.breakpoints.down("md")} {
132
144
  .header-logo {
133
145
  min-width: 32px;
134
146
  }
135
147
  }
136
- `, wo = N(J(X), {
137
- FallbackComponent: H
148
+ `, ye = $(Q(Y), {
149
+ FallbackComponent: C
138
150
  });
139
151
  export {
140
- wo as default
152
+ ye as default
141
153
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/ui-react",
3
- "version": "3.0.39",
3
+ "version": "3.0.41",
4
4
  "description": "Some useful front-end web components that can be used in Blocklets.",
5
5
  "keywords": [
6
6
  "react",
@@ -35,9 +35,9 @@
35
35
  "dependencies": {
36
36
  "@abtnode/constant": "^1.16.46",
37
37
  "@abtnode/util": "^1.16.46",
38
- "@arcblock/bridge": "3.0.39",
39
- "@arcblock/icons": "3.0.39",
40
- "@arcblock/react-hooks": "3.0.39",
38
+ "@arcblock/bridge": "3.0.41",
39
+ "@arcblock/icons": "3.0.41",
40
+ "@arcblock/react-hooks": "3.0.41",
41
41
  "@arcblock/ws": "^1.21.0",
42
42
  "@blocklet/constant": "^1.16.46",
43
43
  "@blocklet/did-space-react": "^1.1.11",
@@ -91,5 +91,5 @@
91
91
  "jest": "^29.7.0",
92
92
  "unbuild": "^2.0.0"
93
93
  },
94
- "gitHead": "0b0937b6a161c7332622ae0001849a7d3b2904f1"
94
+ "gitHead": "e4bf7c421b39bfc7b969653e580047629e5338b5"
95
95
  }
@@ -4,6 +4,7 @@ import SocialMediaIcons from './demo/social-media-icons';
4
4
  import Copyright from './demo/copyright';
5
5
  import Footer from './demo/footer';
6
6
  import ArcblockSite from './demo/arcblock-site';
7
+ import AigneSite from './demo/aigne-site';
7
8
 
8
9
  export default {
9
10
  title: 'Blocklet-UI-React/Footer',
@@ -29,4 +30,4 @@ ArcblockSite.argTypes = {
29
30
  locale: { control: 'select', options: ['en', 'zh'] },
30
31
  };
31
32
 
32
- export { Brand, Links, SocialMediaIcons, Copyright, Footer, ArcblockSite };
33
+ export { Brand, Links, SocialMediaIcons, Copyright, Footer, ArcblockSite, AigneSite };
@@ -193,6 +193,7 @@ const Root = styled('div')`
193
193
  position: relative;
194
194
  padding: 6px 8px;
195
195
  font-size: 14px;
196
+ white-space: nowrap;
196
197
  &--new::after {
197
198
  content: 'New';
198
199
  color: ${({ theme }) => theme.palette.info.main};
@@ -4,7 +4,7 @@ import { withErrorBoundary } from 'react-error-boundary';
4
4
  import { ErrorFallback } from '@arcblock/ux/lib/ErrorBoundary';
5
5
  import { styled, useTheme, deepmerge, ThemeProvider } from '@arcblock/ux/lib/Theme';
6
6
  import { ResponsiveHeader } from '@arcblock/ux/lib/Header';
7
- import NavMenu, { Products } from '@arcblock/ux/lib/NavMenu';
7
+ import NavMenu, { Products, ProductsType } 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
10
  import useBlockletLogo from '@arcblock/ux/lib/hooks/use-blocklet-logo';
@@ -133,6 +133,34 @@ function Header({
133
133
  theme: themeOverrides,
134
134
  });
135
135
 
136
+ // 显示 Products 导航
137
+ const { productsOrder, productsType } = useMemo<{
138
+ productsOrder: number | null;
139
+ productsType: ProductsType | null;
140
+ }>(() => {
141
+ let { USE_ARCBLOCK_THEME, USE_AIGNE_THEME } = formattedBlocklet;
142
+ USE_ARCBLOCK_THEME = parseInt(USE_ARCBLOCK_THEME, 10);
143
+ USE_AIGNE_THEME = parseInt(USE_AIGNE_THEME, 10);
144
+
145
+ if (isFinite(USE_AIGNE_THEME)) {
146
+ return {
147
+ productsOrder: USE_AIGNE_THEME,
148
+ productsType: 'AIGNE',
149
+ };
150
+ }
151
+ if (isFinite(USE_ARCBLOCK_THEME)) {
152
+ return {
153
+ productsOrder: USE_ARCBLOCK_THEME,
154
+ productsType: 'ARCBLOCK',
155
+ };
156
+ }
157
+
158
+ return {
159
+ productsOrder: null,
160
+ productsType: null,
161
+ };
162
+ }, [formattedBlocklet]);
163
+
136
164
  if (!formattedBlocklet.appName) {
137
165
  return null;
138
166
  }
@@ -140,13 +168,11 @@ function Header({
140
168
  const parsedNavigation = parseNavigation(navigation);
141
169
  const { navItems, activeId } = parsedNavigation;
142
170
 
143
- // 显示 Products 导航
144
- const productsNavOrder = parseInt(window.blocklet?.USE_ARCBLOCK_THEME, 10);
145
- if (isFinite(productsNavOrder)) {
146
- navItems.splice(productsNavOrder, 0, {
171
+ if (productsType && Number.isInteger(productsOrder)) {
172
+ navItems.splice(productsOrder, 0, {
147
173
  label: t('products'),
148
174
  // eslint-disable-next-line react/no-unstable-nested-components
149
- children: ({ isOpen }: { isOpen: boolean }) => <Products isOpen={isOpen} />,
175
+ children: () => <Products type={productsType} />,
150
176
  });
151
177
  }
152
178