@blocklet/ui-react 3.2.17 → 3.2.19

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.
Files changed (39) hide show
  1. package/lib/Dashboard/app-shell/app-badge.d.ts +24 -0
  2. package/lib/Dashboard/app-shell/app-badge.js +48 -0
  3. package/lib/Dashboard/app-shell/app-header.d.ts +5 -0
  4. package/lib/Dashboard/app-shell/app-header.js +72 -0
  5. package/lib/Dashboard/app-shell/app-info-context.d.ts +42 -0
  6. package/lib/Dashboard/app-shell/app-info-context.js +83 -0
  7. package/lib/Dashboard/app-shell/badges/app-badge-default.d.ts +20 -0
  8. package/lib/Dashboard/app-shell/badges/app-badge-default.js +84 -0
  9. package/lib/Dashboard/app-shell/badges/app-badge-did.d.ts +5 -0
  10. package/lib/Dashboard/app-shell/badges/app-badge-did.js +16 -0
  11. package/lib/Dashboard/app-shell/badges/app-badge-state.d.ts +6 -0
  12. package/lib/Dashboard/app-shell/badges/app-badge-state.js +34 -0
  13. package/lib/Dashboard/app-shell/badges/app-badge-switch.d.ts +8 -0
  14. package/lib/Dashboard/app-shell/badges/app-badge-switch.js +66 -0
  15. package/lib/Dashboard/app-shell/badges/app-badge-version.d.ts +14 -0
  16. package/lib/Dashboard/app-shell/badges/app-badge-version.js +50 -0
  17. package/lib/Dashboard/app-shell/index.d.ts +4 -0
  18. package/lib/Dashboard/app-shell/index.js +9 -0
  19. package/lib/Dashboard/index.d.ts +12 -2
  20. package/lib/Dashboard/index.js +83 -63
  21. package/lib/Footer/internal-footer.js +11 -11
  22. package/lib/Footer/links.d.ts +5 -3
  23. package/lib/Footer/links.js +63 -61
  24. package/lib/utils.js +28 -28
  25. package/package.json +12 -6
  26. package/src/Dashboard/app-shell/app-badge.stories.tsx +64 -0
  27. package/src/Dashboard/app-shell/app-badge.tsx +94 -0
  28. package/src/Dashboard/app-shell/app-header.tsx +104 -0
  29. package/src/Dashboard/app-shell/app-info-context.tsx +182 -0
  30. package/src/Dashboard/app-shell/badges/app-badge-default.tsx +131 -0
  31. package/src/Dashboard/app-shell/badges/app-badge-did.tsx +28 -0
  32. package/src/Dashboard/app-shell/badges/app-badge-state.tsx +40 -0
  33. package/src/Dashboard/app-shell/badges/app-badge-switch.tsx +72 -0
  34. package/src/Dashboard/app-shell/badges/app-badge-version.tsx +60 -0
  35. package/src/Dashboard/app-shell/index.ts +5 -0
  36. package/src/Dashboard/index.jsx +17 -3
  37. package/src/Footer/internal-footer.jsx +1 -1
  38. package/src/Footer/links.jsx +11 -7
  39. package/src/utils.js +6 -3
@@ -1,52 +1,60 @@
1
- import { jsx as i } from "react/jsx-runtime";
1
+ import { jsx as r, jsxs as z } from "react/jsx-runtime";
2
2
  import "iconify-icon";
3
- import { use as R, useMemo as w, useLayoutEffect as L } from "react";
4
- import t from "prop-types";
5
- import { SessionContext as T } from "@arcblock/did-connect-react/lib/Session";
6
- import { useLocaleContext as z } from "@arcblock/ux/lib/Locale/context";
7
- import A from "@arcblock/ux/lib/Img";
8
- import C from "@arcblock/ux/lib/Layout/dashboard";
9
- import D from "@arcblock/ux/lib/hooks/use-blocklet-logo";
10
- import { SessionManagerProps as M, BlockletMetaProps as O } from "../types.js";
11
- import { mapRecursive as j, flatRecursive as H, matchPaths as S } from "../utils.js";
12
- import { formatBlockletInfo as _, getLocalizedNavigation as E, filterNavByRole as U, publicPath as m } from "../blocklets.js";
13
- import q from "../common/header-addons.js";
14
- import { useWalletHiddenTopbar as F } from "../common/wallet-hidden-topbar.js";
15
- function G({
16
- meta: a = {},
3
+ import { use as D, useMemo as w, useLayoutEffect as A } from "react";
4
+ import e from "prop-types";
5
+ import { SessionContext as M } from "@arcblock/did-connect-react/lib/Session";
6
+ import { useLocaleContext as j } from "@arcblock/ux/lib/Locale/context";
7
+ import H from "@arcblock/ux/lib/Img";
8
+ import O from "@arcblock/ux/lib/Layout/dashboard";
9
+ import S from "@arcblock/ux/lib/hooks/use-blocklet-logo";
10
+ import { SessionManagerProps as _, BlockletMetaProps as E } from "../types.js";
11
+ import { mapRecursive as U, flatRecursive as q, matchPaths as F } from "../utils.js";
12
+ import { formatBlockletInfo as G, getLocalizedNavigation as J, filterNavByRole as K, publicPath as m } from "../blocklets.js";
13
+ import Q from "../common/header-addons.js";
14
+ import { useWalletHiddenTopbar as V } from "../common/wallet-hidden-topbar.js";
15
+ import X from "./app-shell/app-header.js";
16
+ import { default as yo } from "./app-shell/app-badge.js";
17
+ import { AppInfoProvider as Y } from "./app-shell/app-info-context.js";
18
+ import { useAppInfo as Ao } from "./app-shell/app-info-context.js";
19
+ function Z({
20
+ meta: a = void 0,
17
21
  fallbackUrl: s = m,
18
22
  invalidPathFallback: l = null,
19
- headerAddons: k = void 0,
20
- sessionManagerProps: N = {
23
+ headerAddons: L = void 0,
24
+ sessionManagerProps: P = {
21
25
  showRole: !0,
22
26
  // dashboard 默认退出登录行为: 跳转到 (root) blocklet 首页
23
27
  onLogout: () => {
24
28
  window.location.href = m;
25
29
  }
26
30
  },
27
- links: c = [],
28
- showDomainWarningDialog: P = !0,
31
+ links: d = [],
32
+ showDomainWarningDialog: T = !0,
33
+ appPath: k = void 0,
34
+ appTab: I = void 0,
35
+ onAppTabChange: N = void 0,
36
+ children: B = void 0,
29
37
  ...h
30
38
  }) {
31
- F();
32
- const d = R(T)?.session?.user, g = d?.role, { locale: x, defaultLocale: y } = z() || {}, r = w(() => {
33
- const e = Object.assign({}, window.blocklet, a);
39
+ V();
40
+ const c = D(M)?.session?.user, g = c?.role, { locale: v, defaultLocale: x } = j() || {}, n = w(() => {
41
+ const t = Object.assign({}, window.blocklet, a);
34
42
  try {
35
- return _(e);
36
- } catch (n) {
37
- return console.error("Failed to format blocklet info", n, e), e;
43
+ return G(t);
44
+ } catch (i) {
45
+ return console.error("Failed to format blocklet info", i, t), t;
38
46
  }
39
- }, [a]), { localizedNav: v, flattened: f, matchedIndex: b } = w(() => {
40
- let e = E({
41
- navigation: r?.navigation?.dashboard,
42
- locale: x,
43
- defaultLocale: y
47
+ }, [a]), { localizedNav: b, flattened: p, matchedIndex: y } = w(() => {
48
+ let t = J({
49
+ navigation: n?.navigation?.dashboard,
50
+ locale: v,
51
+ defaultLocale: x
44
52
  }) || [];
45
- e = U(e, g), e = j(
46
- e,
53
+ t = K(t, g), t = U(
54
+ t,
47
55
  (o) => {
48
56
  let u = null;
49
- return o.icon && (o.icon.startsWith("http") || o.icon.startsWith("data:") ? u = /* @__PURE__ */ i(A, { src: o.icon }) : u = /* @__PURE__ */ i("iconify-icon", { height: "100%", width: "100%", icon: o.icon })), {
57
+ return o.icon && (o.icon.startsWith("http") || o.icon.startsWith("data:") ? u = /* @__PURE__ */ r(H, { src: o.icon }) : u = /* @__PURE__ */ r("iconify-icon", { height: "100%", width: "100%", icon: o.icon })), {
50
58
  id: o.id,
51
59
  title: o.title,
52
60
  url: o.link,
@@ -58,55 +66,67 @@ function G({
58
66
  },
59
67
  "items"
60
68
  );
61
- const n = H(e).filter((o) => !!o.url), p = S(n.map((o) => o.url));
62
- return p !== -1 && (n[p].active = !0), { localizedNav: e, flattened: n, matchedIndex: p };
63
- }, [r, x, y, g]), W = typeof c == "function" ? c(v) : [...v, ...c], B = D({
69
+ const i = q(t).filter((o) => !!o.url), f = F(i.map((o) => o.url));
70
+ return f !== -1 && (i[f].active = !0), { localizedNav: t, flattened: i, matchedIndex: f };
71
+ }, [n, v, x, g]), C = typeof d == "function" ? d(b) : [...b, ...d], W = S({
64
72
  meta: a
65
73
  });
66
- if (L(() => {
67
- d && !f?.length && s && (window.location.href = s);
68
- }, [s]), L(() => {
69
- d && f?.length && b === -1 && l && l();
70
- }, [l, f, b]), !r.appName)
74
+ if (A(() => {
75
+ c && !p?.length && s && (window.location.href = s);
76
+ }, [s]), A(() => {
77
+ c && p?.length && y === -1 && l && l();
78
+ }, [l, p, y]), !n.appName)
71
79
  return null;
72
- const { appName: I } = r;
73
- return /* @__PURE__ */ i(
74
- C,
80
+ const { appName: R } = n;
81
+ return /* @__PURE__ */ r(
82
+ O,
75
83
  {
76
- title: I,
84
+ title: R,
77
85
  fullWidth: !0,
78
86
  sidebarWidth: 128,
79
87
  legacy: !1,
80
- links: W,
88
+ links: C,
81
89
  ...h,
82
90
  headerProps: {
83
91
  homeLink: m,
84
- logo: /* @__PURE__ */ i("img", { src: B, alt: "logo" }),
85
- addons: /* @__PURE__ */ i(
86
- q,
92
+ logo: /* @__PURE__ */ r("img", { src: W, alt: "logo" }),
93
+ addons: /* @__PURE__ */ r(
94
+ Q,
87
95
  {
88
- formattedBlocklet: r,
89
- addons: k,
90
- sessionManagerProps: N,
91
- showDomainWarningDialog: P
96
+ formattedBlocklet: n,
97
+ addons: L,
98
+ sessionManagerProps: P,
99
+ showDomainWarningDialog: T
92
100
  }
93
101
  ),
94
102
  ...h.headerProps
95
- }
103
+ },
104
+ children: /* @__PURE__ */ z(Y, { path: k, currentTab: I, meta: a, children: [
105
+ /* @__PURE__ */ r(X, { onTabChange: N }),
106
+ B
107
+ ] })
96
108
  }
97
109
  );
98
110
  }
99
- G.propTypes = {
100
- meta: O,
111
+ Z.propTypes = {
112
+ meta: E,
101
113
  // 如果当前用户没有权限访问任何导航菜单, 则自动跳转到 fallbackUrl, 默认值为 publicPath, 设置为 null 表示禁用自动跳转
102
- fallbackUrl: t.string,
114
+ fallbackUrl: e.string,
103
115
  // 当前路径未匹配任何 nav links 时的 fallback, 默认行为跳转到首个可用的 nav link
104
- invalidPathFallback: t.func,
105
- headerAddons: t.oneOfType([t.func, t.node]),
106
- sessionManagerProps: M,
107
- links: t.oneOfType([t.array, t.func]),
108
- showDomainWarningDialog: t.bool
116
+ invalidPathFallback: e.func,
117
+ headerAddons: e.oneOfType([e.func, e.node]),
118
+ sessionManagerProps: _,
119
+ links: e.oneOfType([e.array, e.func]),
120
+ showDomainWarningDialog: e.bool,
121
+ appPath: e.string,
122
+ appTab: e.string,
123
+ onAppTabChange: e.func,
124
+ children: e.node
109
125
  };
110
126
  export {
111
- G as default
127
+ yo as AppBadge,
128
+ X as AppHeader,
129
+ Y as AppInfoProvider,
130
+ Z as default,
131
+ Ao as useAppInfo
112
132
  };
@@ -7,13 +7,13 @@ import y from "./links.js";
7
7
  import M from "./social-media.js";
8
8
  import O from "./copyright.js";
9
9
  import B from "./layout/standard.js";
10
- import N from "./layout/plain.js";
10
+ import C from "./layout/plain.js";
11
11
  const f = [
12
12
  {
13
13
  name: "plain",
14
14
  // 没有 navigation 和 socialMedia, 使用一个简单的两端对齐布局
15
15
  support: (t, o) => !o.navigation?.length && !o.socialMedia?.length,
16
- component: N
16
+ component: C
17
17
  },
18
18
  {
19
19
  name: "standard",
@@ -21,20 +21,20 @@ const f = [
21
21
  support: () => !0,
22
22
  component: B
23
23
  }
24
- ], S = f.reduce((t, o) => ({ ...t, [o.name]: o }), {});
25
- function C({ ...t }) {
24
+ ], N = f.reduce((t, o) => ({ ...t, [o.name]: o }), {});
25
+ function S({ ...t }) {
26
26
  const {
27
27
  brand: o = null,
28
28
  navigation: s = null,
29
29
  socialMedia: p = null,
30
30
  copyright: u = null,
31
- links: c = null,
31
+ links: m = null,
32
32
  layout: l = "auto",
33
33
  ...e
34
- } = t, g = () => o ? /* @__PURE__ */ r(L, { ...o }) : null, h = () => s?.length ? /* @__PURE__ */ r(y, { links: s, columns: 3 }) : null, k = () => p?.length ? /* @__PURE__ */ r(M, { items: p }) : null, b = () => {
34
+ } = t, g = () => o ? /* @__PURE__ */ r(L, { ...o }) : null, h = () => s?.length ? /* @__PURE__ */ r(y, { links: s, minColumns: 3 }) : null, k = () => p?.length ? /* @__PURE__ */ r(M, { items: p }) : null, b = () => {
35
35
  const i = u?.owner || o?.name;
36
36
  return i ? /* @__PURE__ */ r(O, { owner: i, year: u?.year || void 0 }) : null;
37
- }, x = () => c?.length ? /* @__PURE__ */ r(y, { flowLayout: !0, links: c }) : null, m = {
37
+ }, x = () => m?.length ? /* @__PURE__ */ r(y, { flowLayout: !0, links: m }) : null, c = {
38
38
  brand: g(),
39
39
  navigation: h(),
40
40
  socialMedia: k(),
@@ -42,7 +42,7 @@ function C({ ...t }) {
42
42
  links: x()
43
43
  };
44
44
  let a = null;
45
- if (l === "auto" ? a = f.find((i) => i.support(m, t)).component : a = S[l]?.component, !a)
45
+ if (l === "auto" ? a = f.find((i) => i.support(c, t)).component : a = N[l]?.component, !a)
46
46
  throw new Error(`layout ${l} is not supported.`);
47
47
  return /* @__PURE__ */ w(
48
48
  d,
@@ -56,7 +56,7 @@ function C({ ...t }) {
56
56
  ...Array.isArray(e.sx) ? e.sx : [e.sx]
57
57
  ],
58
58
  children: [
59
- /* @__PURE__ */ r(a, { elements: m, data: t }),
59
+ /* @__PURE__ */ r(a, { elements: c, data: t }),
60
60
  /* @__PURE__ */ r(
61
61
  d,
62
62
  {
@@ -75,7 +75,7 @@ function C({ ...t }) {
75
75
  }
76
76
  );
77
77
  }
78
- C.propTypes = {
78
+ S.propTypes = {
79
79
  brand: n.shape({
80
80
  name: n.node,
81
81
  description: n.string,
@@ -108,5 +108,5 @@ C.propTypes = {
108
108
  layout: n.oneOf(["auto", "standard", "plain"])
109
109
  };
110
110
  export {
111
- C as default
111
+ S as default
112
112
  };
@@ -2,11 +2,12 @@ import { default as PropTypes } from 'prop-types';
2
2
  /**
3
3
  * footer 中的 links (支持分组, 最多支持 2 级)
4
4
  */
5
- declare function Links({ links, flowLayout, columns, ...rest }: {
5
+ declare function Links({ links, flowLayout, minColumns, maxColumns, ...rest }: {
6
6
  [x: string]: any;
7
7
  links?: never[] | undefined;
8
8
  flowLayout?: boolean | undefined;
9
- columns: any;
9
+ minColumns?: number | undefined;
10
+ maxColumns?: number | undefined;
10
11
  }): import("react/jsx-runtime").JSX.Element | null;
11
12
  declare namespace Links {
12
13
  namespace propTypes {
@@ -17,7 +18,8 @@ declare namespace Links {
17
18
  props: PropTypes.Requireable<object>;
18
19
  }> | null | undefined)[]>;
19
20
  let flowLayout: PropTypes.Requireable<boolean>;
20
- let columns: PropTypes.Validator<number>;
21
+ let minColumns: PropTypes.Requireable<number>;
22
+ let maxColumns: PropTypes.Requireable<number>;
21
23
  }
22
24
  }
23
25
  export default Links;
@@ -1,58 +1,58 @@
1
- import { jsx as r, jsxs as m, Fragment as N } from "react/jsx-runtime";
2
- import { useState as $ } from "react";
3
- import l from "prop-types";
4
- import { useCreation as M } from "ahooks";
5
- import j from "lodash/isInteger";
6
- import I from "lodash/isString";
7
- import { styled as z } from "@arcblock/ux/lib/Theme";
8
- import c from "clsx";
9
- import { ExpandMore as C } from "@mui/icons-material";
10
- import P from "../Icon/index.js";
11
- import A from "../hooks/use-mobile.js";
12
- import { splitNavColumns as E, isMailProtocol as F } from "../utils.js";
13
- function R({ links: e = [], flowLayout: d = !1, columns: u, ...k }) {
14
- const [g, b] = $(-1), w = A({ key: "md" }), h = e.some((t) => t.items?.length), x = !w && h && j(u) && u > 1, p = ({ label: t, link: o, icon: i, render: a, props: n }) => {
15
- let s = t;
1
+ import { jsx as r, jsxs as d, Fragment as M } from "react/jsx-runtime";
2
+ import { useState as j } from "react";
3
+ import i from "prop-types";
4
+ import { useCreation as I } from "ahooks";
5
+ import z from "lodash/isInteger";
6
+ import P from "lodash/isString";
7
+ import { styled as F } from "@arcblock/ux/lib/Theme";
8
+ import u from "clsx";
9
+ import { ExpandMore as A } from "@mui/icons-material";
10
+ import E from "../Icon/index.js";
11
+ import S from "../hooks/use-mobile.js";
12
+ import { splitNavColumns as T, isMailProtocol as W } from "../utils.js";
13
+ function _({ links: e = [], flowLayout: g = !1, minColumns: f = 1, maxColumns: k = 4, ...h }) {
14
+ const [x, y] = j(-1), v = S({ key: "md" }), b = e.some((t) => t.items?.length), m = !v && b && z(f) && f > 1 && k >= f, w = m ? Math.min(Math.max(e.length, f), k) : 1, p = ({ label: t, link: o, icon: n, render: a, props: s }) => {
15
+ let l = t;
16
16
  if (a)
17
- s = a({ label: t, link: o, props: n });
18
- else if (o && I(o)) {
19
- const f = o.startsWith("http") || o.startsWith("//"), v = F(o) ? {} : {
20
- target: f ? "_blank" : "_self",
21
- rel: f ? "noreferrer noopener" : void 0
17
+ l = a({ label: t, link: o, props: s });
18
+ else if (o && P(o)) {
19
+ const c = o.startsWith("http") || o.startsWith("//"), $ = W(o) ? {} : {
20
+ target: c ? "_blank" : "_self",
21
+ rel: c ? "noreferrer noopener" : void 0
22
22
  };
23
- s = /* @__PURE__ */ r("a", { href: o, "aria-label": `Footer link for ${t}`, ...v, ...n, children: t });
23
+ l = /* @__PURE__ */ r("a", { href: o, "aria-label": `Footer link for ${t}`, ...$, ...s, children: t });
24
24
  }
25
- return /* @__PURE__ */ m(N, { children: [
26
- i && /* @__PURE__ */ r(P, { icon: i, size: 20, sx: { mr: 0.5 } }),
27
- s
25
+ return /* @__PURE__ */ d(M, { children: [
26
+ n && /* @__PURE__ */ r(E, { icon: n, size: 20, sx: { mr: 0.5 } }),
27
+ l
28
28
  ] });
29
- }, y = M(() => e?.length ? d ? e.map((t, o) => /* @__PURE__ */ r("span", { className: "footer-links-item", children: p(t) }, o)) : x ? E(e, { columns: u }).map((t, o) => /* @__PURE__ */ r("div", { className: "footer-links-column", children: t.filter((i) => i.group).map((i, a) => {
30
- const { items: n } = i;
31
- return /* @__PURE__ */ m("div", { className: "footer-links-group", children: [
32
- /* @__PURE__ */ r("span", { className: "footer-links-item", children: p(i) }),
33
- !!n?.length && /* @__PURE__ */ r("div", { className: "footer-links-sub", children: n.map((s, f) => /* @__PURE__ */ r(
29
+ }, N = I(() => e?.length ? g ? e.map((t, o) => /* @__PURE__ */ r("span", { className: "footer-links-item", children: p(t) }, o)) : m ? T(e, { columns: w }).map((t, o) => /* @__PURE__ */ r("div", { className: "footer-links-column", children: t.filter((n) => n.group).map((n, a) => {
30
+ const { items: s } = n;
31
+ return /* @__PURE__ */ d("div", { className: "footer-links-group", children: [
32
+ /* @__PURE__ */ r("span", { className: "footer-links-item", children: p(n) }),
33
+ !!s?.length && /* @__PURE__ */ r("div", { className: "footer-links-sub", children: s.map((l, c) => /* @__PURE__ */ r(
34
34
  "span",
35
35
  {
36
- className: c("footer-links-item", { "footer-links-item--new": s.isNew }),
37
- children: p(s)
36
+ className: u("footer-links-item", { "footer-links-item--new": l.isNew }),
37
+ children: p(l)
38
38
  },
39
- f
39
+ c
40
40
  )) })
41
41
  ] }, a);
42
42
  }) }, o)) : e.map((t, o) => {
43
- const { items: i } = t, a = o === g;
44
- return /* @__PURE__ */ m(
43
+ const { items: n } = t, a = o === x;
44
+ return /* @__PURE__ */ d(
45
45
  "div",
46
46
  {
47
- className: c("footer-links-group", {
47
+ className: u("footer-links-group", {
48
48
  "footer-links-group--active": a
49
49
  }),
50
- onClick: () => b(g === o ? -1 : o),
50
+ onClick: () => y(x === o ? -1 : o),
51
51
  children: [
52
- /* @__PURE__ */ m("span", { className: "footer-links-item", children: [
52
+ /* @__PURE__ */ d("span", { className: "footer-links-item", children: [
53
53
  p(t),
54
- !!i?.length && /* @__PURE__ */ r("span", { className: "footer-links-group-expand-icon", children: /* @__PURE__ */ r(
55
- C,
54
+ !!n?.length && /* @__PURE__ */ r("span", { className: "footer-links-group-expand-icon", children: /* @__PURE__ */ r(
55
+ A,
56
56
  {
57
57
  style: {
58
58
  transform: `rotate(${a ? 180 : 0}deg)`
@@ -60,40 +60,42 @@ function R({ links: e = [], flowLayout: d = !1, columns: u, ...k }) {
60
60
  }
61
61
  ) })
62
62
  ] }),
63
- !!i?.length && /* @__PURE__ */ r("div", { className: "footer-links-sub", children: i.map((n, s) => /* @__PURE__ */ r("span", { className: c("footer-links-item", { "footer-links-item--new": n.isNew }), children: p(n) }, s)) })
63
+ !!n?.length && /* @__PURE__ */ r("div", { className: "footer-links-sub", children: n.map((s, l) => /* @__PURE__ */ r("span", { className: u("footer-links-item", { "footer-links-item--new": s.isNew }), children: p(s) }, l)) })
64
64
  ]
65
65
  },
66
66
  o
67
67
  );
68
- }) : null, [e, d, x, g]);
68
+ }) : null, [e, g, m, x]);
69
69
  return e?.length ? /* @__PURE__ */ r(
70
- S,
70
+ C,
71
71
  {
72
- ...k,
73
- className: c(k.className, {
74
- "footer-links--grouped": h,
75
- "footer-links--flow": d,
76
- "footer-links--columns": x
72
+ columns: w,
73
+ ...h,
74
+ className: u(h.className, {
75
+ "footer-links--grouped": b,
76
+ "footer-links--flow": g,
77
+ "footer-links--columns": m
77
78
  }),
78
- children: /* @__PURE__ */ r("div", { className: "footer-links-inner", children: y })
79
+ children: /* @__PURE__ */ r("div", { className: "footer-links-inner", children: N })
79
80
  }
80
81
  ) : null;
81
82
  }
82
- R.propTypes = {
83
- links: l.arrayOf(
84
- l.shape({
85
- label: l.string,
86
- link: l.string,
87
- render: l.func,
88
- props: l.object
83
+ _.propTypes = {
84
+ links: i.arrayOf(
85
+ i.shape({
86
+ label: i.string,
87
+ link: i.string,
88
+ render: i.func,
89
+ props: i.object
89
90
  })
90
91
  ),
91
92
  // 流动布局, 简单的从左到右排列
92
- flowLayout: l.bool,
93
- // 列布局
94
- columns: l.number.isRequired
93
+ flowLayout: i.bool,
94
+ // 列布局,最小列数,最大列数
95
+ minColumns: i.number,
96
+ maxColumns: i.number
95
97
  };
96
- const S = z("div")`
98
+ const C = F("div", { shouldForwardProp: (e) => e !== "columns" })`
97
99
  overflow: hidden;
98
100
  color: ${({ theme: e }) => e.palette.text.secondary};
99
101
  .footer-links-inner {
@@ -158,7 +160,7 @@ const S = z("div")`
158
160
  /* columns 布局 */
159
161
  &.footer-links--columns {
160
162
  .footer-links-inner {
161
- gap: 96px;
163
+ gap: ${({ columns: e }) => `${288 / e}px`};
162
164
  }
163
165
  .footer-links-column {
164
166
  display: flex;
@@ -244,5 +246,5 @@ const S = z("div")`
244
246
  }
245
247
  `;
246
248
  export {
247
- R as default
249
+ _ as default
248
250
  };
package/lib/utils.js CHANGED
@@ -1,54 +1,54 @@
1
1
  const p = (n, r, e = "children") => n.map((t) => Array.isArray(t[e]) ? r({
2
2
  ...t,
3
3
  [e]: p(t[e], r, e)
4
- }) : r(t)), v = (n, r = "children") => {
4
+ }) : r(t)), A = (n, r = "children") => {
5
5
  const e = [];
6
6
  return p(n, (t) => e.push(t), r), e;
7
- }, A = (n, r = "children") => {
7
+ }, C = (n, r = "children") => {
8
8
  let e = 0;
9
9
  return p(n, () => e++, r), e;
10
- }, H = (n, r, e = "children") => n.map((t) => ({ ...t })).filter((t) => {
10
+ }, R = (n, r, e = "children") => n.map((t) => ({ ...t })).filter((t) => {
11
11
  const s = t[e];
12
12
  if (Array.isArray(s)) {
13
- const a = H(s, r, e);
13
+ const a = R(s, r, e);
14
14
  t[e] = a?.length ? a : void 0;
15
15
  }
16
16
  const l = { filteredChildren: t[e], isLeaf: !s?.length };
17
17
  return r(t, l);
18
- }), C = (n) => /^https?:\/\//.test(n), P = (n) => /^mailto:/i.test(n.trim()), S = (n) => /^[\w-]+:[\w-]+$/.test(n), R = (n) => {
18
+ }), P = (n) => /^https?:\/\//.test(n), S = (n) => /^mailto:/i.test(n.trim()), x = (n) => /^[\w-]+:[\w-]+$/.test(n), v = (n) => {
19
19
  if (!n || !n?.startsWith("/"))
20
20
  return !1;
21
21
  const r = (s) => s.endsWith("/") ? s : `${s}/`, e = r(window.location.pathname), t = r(new URL(n, window.location.origin).pathname);
22
22
  return e.startsWith(t);
23
- }, x = (n = []) => {
24
- const r = n.map((t, s) => ({ path: t, index: s })).filter((t) => R(t.path));
23
+ }, W = (n = []) => {
24
+ const r = n.map((t, s) => ({ path: t, index: s })).filter((t) => v(t.path));
25
25
  return r?.length ? r.slice(1).reduce((t, s) => t.path.length >= s.path.length ? t : s, r[0]).index : -1;
26
- }, W = (n, r = {}) => {
27
- const { columns: e = 1, breakInside: t = !1, groupHeight: s = 48, itemHeight: l = 24, childrenKey: a = "items" } = r, m = n.reduce((c, g) => c + s + (g[a]?.length || 0) * l, 0), h = Math.ceil(m / e), u = [[]];
28
- let o = 0, i = 0;
29
- const d = h * 0.2, f = (c) => i > h - d && o < e - 1 && i + c > h + d;
30
- return n.forEach((c) => {
31
- const g = s + (c[a]?.length || 0) * l;
32
- t && f(s) && (o++, i = 0, u[o] = []), !t && i > 0 && f(g) && (o++, i = 0, u[o] = []), u[o].push({
33
- ...c,
26
+ }, k = (n, r = {}) => {
27
+ const { columns: e = 1, breakInside: t = !1, groupHeight: s = 48, itemHeight: l = 24, childrenKey: a = "items" } = r, m = n.length, w = n.reduce((i, g) => i + s + (g[a]?.length || 0) * l, 0), h = Math.ceil(w / e), u = [[]];
28
+ let o = 0, c = 0;
29
+ const d = h * 0.2, f = (i) => c > h - d && o < e - 1 && c + i > h + d;
30
+ return n.forEach((i) => {
31
+ const g = s + (i[a]?.length || 0) * l;
32
+ t && f(s) && (o++, c = 0, u[o] = []), !t && c > 0 && (m <= e || f(g)) && (o++, c = 0, u[o] = []), u[o].push({
33
+ ...i,
34
34
  group: !0
35
- }), i += s, c[a] && c[a].forEach((w) => {
36
- t && f(l) && (o++, i = 0, u[o] = []), u[o].push({
37
- ...w,
35
+ }), c += s, i[a] && i[a].forEach((H) => {
36
+ t && f(l) && (o++, c = 0, u[o] = []), u[o].push({
37
+ ...H,
38
38
  group: !1
39
- }), i += l;
39
+ }), c += l;
40
40
  });
41
41
  }), u;
42
42
  };
43
43
  export {
44
- A as countRecursive,
45
- H as filterRecursive,
46
- v as flatRecursive,
47
- S as isIconifyString,
48
- P as isMailProtocol,
49
- C as isUrl,
44
+ C as countRecursive,
45
+ R as filterRecursive,
46
+ A as flatRecursive,
47
+ x as isIconifyString,
48
+ S as isMailProtocol,
49
+ P as isUrl,
50
50
  p as mapRecursive,
51
- R as matchPath,
52
- x as matchPaths,
53
- W as splitNavColumns
51
+ v as matchPath,
52
+ W as matchPaths,
53
+ k as splitNavColumns
54
54
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/ui-react",
3
- "version": "3.2.17",
3
+ "version": "3.2.19",
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.17.5",
37
37
  "@abtnode/util": "^1.17.5",
38
- "@arcblock/bridge": "3.2.17",
39
- "@arcblock/icons": "3.2.17",
40
- "@arcblock/react-hooks": "3.2.17",
38
+ "@arcblock/bridge": "3.2.19",
39
+ "@arcblock/icons": "3.2.19",
40
+ "@arcblock/react-hooks": "3.2.19",
41
41
  "@arcblock/ws": "^1.27.15",
42
42
  "@blocklet/did-space-react": "^1.2.10",
43
43
  "@iconify-icons/logos": "^1.2.36",
@@ -82,13 +82,19 @@
82
82
  "access": "public"
83
83
  },
84
84
  "devDependencies": {
85
- "@arcblock/did-connect-react": "3.2.17",
85
+ "@arcblock/did-connect-react": "3.2.19",
86
+ "@babel/preset-env": "^7.28.0",
87
+ "@babel/preset-react": "^7.27.1",
88
+ "@babel/preset-typescript": "^7.27.1",
86
89
  "@types/dompurify": "^3.2.0",
90
+ "@types/jest": "^29.5.14",
87
91
  "@types/ua-parser-js": "^0.7.39",
88
92
  "@types/validator": "^13.15.2",
93
+ "babel-jest": "29",
89
94
  "eslint-plugin-react-hooks": "^4.6.2",
90
95
  "jest": "^29.7.0",
96
+ "typescript": "~5.5.4",
91
97
  "unbuild": "^2.0.0"
92
98
  },
93
- "gitHead": "5f9c8a00065316075847d5b5e5a56874f0929f6e"
99
+ "gitHead": "8439c6a0c022c3fab219191ff035d737c422f3ff"
94
100
  }