@blocklet/ui-react 3.1.26 → 3.1.28

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 (35) hide show
  1. package/lib/@types/index.d.ts +1 -1
  2. package/lib/Footer/links.js +26 -33
  3. package/lib/UserCenter/components/fallback.d.ts +8 -0
  4. package/lib/UserCenter/components/fallback.js +21 -0
  5. package/lib/UserCenter/components/user-center.js +205 -200
  6. package/lib/UserCenter/components/user-info/social-actions/chat.d.ts +5 -0
  7. package/lib/UserCenter/components/user-info/social-actions/chat.js +24 -0
  8. package/lib/UserCenter/components/user-info/social-actions/follow.d.ts +2 -0
  9. package/lib/UserCenter/components/user-info/social-actions/follow.js +19 -0
  10. package/lib/UserCenter/components/user-info/social-actions/index.d.ts +5 -0
  11. package/lib/UserCenter/components/user-info/social-actions/index.js +13 -0
  12. package/lib/UserCenter/components/user-info/user-basic-info.js +37 -35
  13. package/lib/UserCenter/libs/locales.d.ts +14 -0
  14. package/lib/UserCenter/libs/locales.js +16 -2
  15. package/lib/blocklets.js +56 -54
  16. package/lib/contexts/user-followers.d.ts +13 -0
  17. package/lib/contexts/user-followers.js +40 -0
  18. package/lib/hooks/use-follow.d.ts +12 -0
  19. package/lib/hooks/use-follow.js +47 -0
  20. package/lib/utils.d.ts +1 -0
  21. package/lib/utils.js +37 -36
  22. package/package.json +6 -6
  23. package/src/@types/index.ts +1 -1
  24. package/src/Footer/links.jsx +10 -7
  25. package/src/UserCenter/components/fallback.tsx +51 -0
  26. package/src/UserCenter/components/user-center.tsx +22 -12
  27. package/src/UserCenter/components/user-info/social-actions/chat.tsx +42 -0
  28. package/src/UserCenter/components/user-info/social-actions/follow.tsx +30 -0
  29. package/src/UserCenter/components/user-info/social-actions/index.tsx +17 -0
  30. package/src/UserCenter/components/user-info/user-basic-info.tsx +6 -0
  31. package/src/UserCenter/libs/locales.ts +14 -0
  32. package/src/blocklets.js +5 -1
  33. package/src/contexts/user-followers.tsx +54 -0
  34. package/src/hooks/use-follow.tsx +74 -0
  35. package/src/utils.js +5 -0
@@ -114,7 +114,7 @@ export type UserCenterTab = {
114
114
  value: string;
115
115
  label: string;
116
116
  url: string;
117
- protected: boolean;
117
+ protected: boolean | string;
118
118
  icon?: string;
119
119
  isPrivate?: boolean;
120
120
  };
@@ -1,39 +1,32 @@
1
- import { jsx as r, jsxs as m, Fragment as v } from "react/jsx-runtime";
2
- import { useState as N } from "react";
1
+ import { jsx as r, jsxs as m, Fragment as N } from "react/jsx-runtime";
2
+ import { useState as $ } from "react";
3
3
  import l from "prop-types";
4
- import { useCreation as $ } from "ahooks";
4
+ import { useCreation as M } from "ahooks";
5
5
  import j from "lodash/isInteger";
6
6
  import I from "lodash/isString";
7
7
  import { styled as z } from "@arcblock/ux/lib/Theme";
8
8
  import c from "clsx";
9
- import { ExpandMore as M } from "@mui/icons-material";
10
- import C from "../Icon/index.js";
9
+ import { ExpandMore as C } from "@mui/icons-material";
10
+ import P from "../Icon/index.js";
11
11
  import A from "../hooks/use-mobile.js";
12
- import { splitNavColumns as E } from "../utils.js";
13
- function F({ links: e = [], flowLayout: d = !1, columns: u, ...x }) {
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 }) => {
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
15
  let s = t;
16
16
  if (a)
17
17
  s = a({ label: t, link: o, props: n });
18
18
  else if (o && I(o)) {
19
- const f = o.startsWith("http") || o.startsWith("//");
20
- s = /* @__PURE__ */ r(
21
- "a",
22
- {
23
- href: o,
24
- "aria-label": `Footer link for ${t}`,
25
- target: f ? "_blank" : "_self",
26
- rel: f ? "noreferrer noopener" : void 0,
27
- ...n,
28
- children: t
29
- }
30
- );
31
- }
32
- return /* @__PURE__ */ m(v, { children: [
33
- i && /* @__PURE__ */ r(C, { icon: i, size: 20, sx: { mr: 0.5 } }),
19
+ const f = o.startsWith("http") || o.startsWith("//"), v = F(o) ? {} : {
20
+ target: f ? "_blank" : "_self",
21
+ rel: f ? "noreferrer noopener" : void 0
22
+ };
23
+ s = /* @__PURE__ */ r("a", { href: o, "aria-label": `Footer link for ${t}`, ...v, ...n, children: t });
24
+ }
25
+ return /* @__PURE__ */ m(N, { children: [
26
+ i && /* @__PURE__ */ r(P, { icon: i, size: 20, sx: { mr: 0.5 } }),
34
27
  s
35
28
  ] });
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) => {
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) => {
37
30
  const { items: n } = i;
38
31
  return /* @__PURE__ */ m("div", { className: "footer-links-group", children: [
39
32
  /* @__PURE__ */ r("span", { className: "footer-links-item", children: p(i) }),
@@ -59,7 +52,7 @@ function F({ links: e = [], flowLayout: d = !1, columns: u, ...x }) {
59
52
  /* @__PURE__ */ m("span", { className: "footer-links-item", children: [
60
53
  p(t),
61
54
  !!i?.length && /* @__PURE__ */ r("span", { className: "footer-links-group-expand-icon", children: /* @__PURE__ */ r(
62
- M,
55
+ C,
63
56
  {
64
57
  style: {
65
58
  transform: `rotate(${a ? 180 : 0}deg)`
@@ -72,21 +65,21 @@ function F({ links: e = [], flowLayout: d = !1, columns: u, ...x }) {
72
65
  },
73
66
  o
74
67
  );
75
- }) : null, [e, d, k, g]);
68
+ }) : null, [e, d, x, g]);
76
69
  return e?.length ? /* @__PURE__ */ r(
77
- R,
70
+ S,
78
71
  {
79
- ...x,
80
- className: c(x.className, {
72
+ ...k,
73
+ className: c(k.className, {
81
74
  "footer-links--grouped": h,
82
75
  "footer-links--flow": d,
83
- "footer-links--columns": k
76
+ "footer-links--columns": x
84
77
  }),
85
78
  children: /* @__PURE__ */ r("div", { className: "footer-links-inner", children: y })
86
79
  }
87
80
  ) : null;
88
81
  }
89
- F.propTypes = {
82
+ R.propTypes = {
90
83
  links: l.arrayOf(
91
84
  l.shape({
92
85
  label: l.string,
@@ -100,7 +93,7 @@ F.propTypes = {
100
93
  // 列布局
101
94
  columns: l.number.isRequired
102
95
  };
103
- const R = z("div")`
96
+ const S = z("div")`
104
97
  overflow: hidden;
105
98
  color: ${({ theme: e }) => e.palette.text.secondary};
106
99
  .footer-links-inner {
@@ -251,5 +244,5 @@ const R = z("div")`
251
244
  }
252
245
  `;
253
246
  export {
254
- F as default
247
+ R as default
255
248
  };
@@ -0,0 +1,8 @@
1
+ import { default as React } from 'react';
2
+ import { UserCenterTab } from '../../@types';
3
+ declare function Fallback({ currentActiveTab, isMyself, children, }: {
4
+ currentActiveTab: UserCenterTab;
5
+ isMyself: boolean;
6
+ children: React.ReactNode;
7
+ }): string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | import("react/jsx-runtime").JSX.Element | null | undefined;
8
+ export default Fallback;
@@ -0,0 +1,21 @@
1
+ import { jsx as e } from "react/jsx-runtime";
2
+ import n from "@arcblock/ux/lib/Empty";
3
+ import { translate as c } from "@arcblock/ux/lib/Locale/util";
4
+ import { useMemoizedFn as d } from "ahooks";
5
+ import { useLocaleContext as u } from "@arcblock/ux/lib/Locale/context";
6
+ import { translations as a } from "../libs/locales.js";
7
+ import { useUserFollowersContext as w } from "../../contexts/user-followers.js";
8
+ function k({
9
+ currentActiveTab: o,
10
+ isMyself: m,
11
+ children: l
12
+ }) {
13
+ const { locale: f } = u(), r = d((s, p = {}) => c(a, s, f, "en", p)), { followed: i } = w();
14
+ if (m || !o?.protected || o?.protected === "all")
15
+ return l;
16
+ const { protected: t } = o;
17
+ return t === !0 || t === "private" ? /* @__PURE__ */ e(n, { children: r("underProtected") }) : t === "follower-only" ? i ? l : /* @__PURE__ */ e(n, { children: r("followersOnly") }) : /* @__PURE__ */ e(n, { children: r("underProtected") });
18
+ }
19
+ export {
20
+ k as default
21
+ };