@blocklet/ui-react 3.0.0 → 3.0.2

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.
@@ -1,4 +1,4 @@
1
- import { jsxs as p, jsx as t, Fragment as y } from "react/jsx-runtime";
1
+ import { jsxs as f, jsx as e, Fragment as y } from "react/jsx-runtime";
2
2
  import { Box as o, Skeleton as g, Typography as w, Pagination as k } from "@mui/material";
3
3
  import { useMemoizedFn as C, useReactive as b, useRequest as F, useCreation as z } from "ahooks";
4
4
  import N from "axios";
@@ -8,28 +8,28 @@ import { WELLKNOWN_SERVICE_PATH_PREFIX as j } from "@abtnode/constant";
8
8
  import { translate as E } from "@arcblock/ux/lib/Locale/util";
9
9
  import { useLocaleContext as I } from "@arcblock/ux/lib/Locale/context";
10
10
  import { translations as S } from "../libs/locales.js";
11
- function H({ user: d }) {
12
- const { locale: x } = I(), m = C((r, n = {}) => E(S, r, x, "en", n)), e = b({
11
+ function H({ user: p }) {
12
+ const { locale: x } = I(), d = C((r, n = {}) => E(S, r, x, "en", n)), t = b({
13
13
  page: 1,
14
14
  size: 20
15
- }), c = F(
16
- async (r = e) => (await N.get(`${j}/ocap/listAssets`, {
15
+ }), m = F(
16
+ async (r = t) => (await N.get(`${j}/ocap/listAssets`, {
17
17
  params: {
18
- ownerAddress: d.did,
18
+ ownerAddress: p.did,
19
19
  ...r
20
20
  }
21
21
  })).data,
22
22
  {
23
- defaultParams: [e],
24
- refreshDeps: [d.did, e]
23
+ defaultParams: [t],
24
+ refreshDeps: [p.did, t]
25
25
  }
26
- ), { loading: i, data: s } = c, l = (s == null ? void 0 : s.page) ?? { cursor: 0, next: !1, total: 0 }, f = (r, n) => {
27
- e.page = n, c.run(e);
26
+ ), { loading: i, data: s } = m, l = (s == null ? void 0 : s.page) ?? { cursor: 0, next: !1, total: 0 }, c = (r, n) => {
27
+ t.page = n, m.run(t);
28
28
  }, h = z(() => {
29
29
  var r, n;
30
30
  if (i) {
31
- const a = ["skeleton-1", "skeleton-2", "skeleton-3", "skeleton-4", "skeleton-5"].map((u) => /* @__PURE__ */ t(g, { variant: "rectangular", width: "15%", height: 166, sx: { borderRadius: 1, flexShrink: 0 } }, u));
32
- return /* @__PURE__ */ p(
31
+ const a = ["skeleton-1", "skeleton-2", "skeleton-3", "skeleton-4", "skeleton-5"].map((u) => /* @__PURE__ */ e(g, { variant: "rectangular", width: "15%", height: 166, sx: { borderRadius: 1, flexShrink: 0 } }, u));
32
+ return /* @__PURE__ */ f(
33
33
  o,
34
34
  {
35
35
  sx: {
@@ -38,8 +38,8 @@ function H({ user: d }) {
38
38
  gap: 2
39
39
  },
40
40
  children: [
41
- /* @__PURE__ */ t(g, { width: "20%" }),
42
- /* @__PURE__ */ t(
41
+ /* @__PURE__ */ e(g, { width: "20%" }),
42
+ /* @__PURE__ */ e(
43
43
  o,
44
44
  {
45
45
  sx: {
@@ -55,8 +55,8 @@ function H({ user: d }) {
55
55
  }
56
56
  );
57
57
  }
58
- return /* @__PURE__ */ p(y, { children: [
59
- /* @__PURE__ */ t(
58
+ return /* @__PURE__ */ f(y, { children: [
59
+ /* @__PURE__ */ e(
60
60
  w,
61
61
  {
62
62
  sx: {
@@ -64,10 +64,11 @@ function H({ user: d }) {
64
64
  fontWeight: 600,
65
65
  mb: 2.5
66
66
  },
67
- children: m("common.nft")
67
+ children: d("common.nft")
68
68
  }
69
69
  ),
70
- /* @__PURE__ */ p(
70
+ ((r = s == null ? void 0 : s.assets) == null ? void 0 : r.length) === 0 && !i && /* @__PURE__ */ e(o, { sx: { display: "flex", justifyContent: "center", alignItems: "center", width: "100%", height: "100%" }, children: /* @__PURE__ */ e(R, { children: d("common.noNFT") }) }),
71
+ /* @__PURE__ */ e(
71
72
  o,
72
73
  {
73
74
  className: "nft-list-wrapper",
@@ -82,48 +83,33 @@ function H({ user: d }) {
82
83
  },
83
84
  gap: 2.5
84
85
  },
85
- children: [
86
- (r = s == null ? void 0 : s.assets) == null ? void 0 : r.map((a) => /* @__PURE__ */ t(
87
- o,
88
- {
89
- sx: {
90
- flexShrink: 0,
91
- width: { xs: 120, sm: 120, md: 120, lg: 166 },
92
- height: { xs: 120, sm: 120, md: 120, lg: 166 }
93
- },
94
- children: /* @__PURE__ */ t(
95
- P,
96
- {
97
- data: a.display,
98
- address: a.address,
99
- inset: !0,
100
- imageFilter: {
101
- imageFilter: "resize",
102
- w: "500",
103
- f: "webp"
104
- }
105
- }
106
- )
86
+ children: (n = s == null ? void 0 : s.assets) == null ? void 0 : n.map((a) => /* @__PURE__ */ e(
87
+ o,
88
+ {
89
+ sx: {
90
+ flexShrink: 0,
91
+ width: { xs: 120, sm: 120, md: 120, lg: 166 },
92
+ height: { xs: 120, sm: 120, md: 120, lg: 166 }
107
93
  },
108
- a.address
109
- )),
110
- ((n = s == null ? void 0 : s.assets) == null ? void 0 : n.length) === 0 && !i && /* @__PURE__ */ t(
111
- o,
112
- {
113
- sx: {
114
- display: "flex",
115
- justifyContent: "center",
116
- alignItems: "center",
117
- width: "100%",
118
- height: "100%"
119
- },
120
- children: /* @__PURE__ */ t(R, { children: m("common.noNFT") })
121
- }
122
- )
123
- ]
94
+ children: /* @__PURE__ */ e(
95
+ P,
96
+ {
97
+ data: a.display,
98
+ address: a.address,
99
+ inset: !0,
100
+ imageFilter: {
101
+ imageFilter: "resize",
102
+ w: "500",
103
+ f: "webp"
104
+ }
105
+ }
106
+ )
107
+ },
108
+ a.address
109
+ ))
124
110
  }
125
111
  ),
126
- l.next || e.page > 1 ? /* @__PURE__ */ t(
112
+ l.next || t.page > 1 ? /* @__PURE__ */ e(
127
113
  k,
128
114
  {
129
115
  sx: {
@@ -131,15 +117,15 @@ function H({ user: d }) {
131
117
  justifyContent: "center",
132
118
  mt: 2
133
119
  },
134
- page: e.page,
135
- onChange: f,
136
- count: Math.ceil(l.total / e.size),
120
+ page: t.page,
121
+ onChange: c,
122
+ count: Math.ceil(l.total / t.size),
137
123
  size: "small"
138
124
  }
139
125
  ) : null
140
126
  ] });
141
- }, [i, l, e.page, e.size, f]);
142
- return /* @__PURE__ */ t(o, { sx: { border: "1px solid", borderColor: "divider", borderRadius: 1, p: 2, mb: 5 }, children: h });
127
+ }, [i, l, t.page, t.size, c]);
128
+ return /* @__PURE__ */ e(o, { sx: { border: "1px solid", borderColor: "divider", borderRadius: 1, p: 2, mb: 5 }, children: h });
143
129
  }
144
130
  export {
145
131
  H as default
@@ -1,64 +1,64 @@
1
- import { jsx as t, jsxs as g } from "react/jsx-runtime";
2
- import { useState as y, useMemo as w, useEffect as L } from "react";
3
- import { styled as b, Box as c, Typography as C, IconButton as I, Button as F, useTheme as E, FormControl as U, TextField as D } from "@mui/material";
4
- import { Remove as S, Add as k } from "@mui/icons-material";
5
- import { translate as R } from "@arcblock/ux/lib/Locale/util";
6
- import { useMemoizedFn as j } from "ahooks";
7
- import { useLocaleContext as B } from "@arcblock/ux/lib/Locale/context";
8
- import T from "@arcblock/icons/lib/Link";
1
+ import { jsx as t, jsxs as m } from "react/jsx-runtime";
2
+ import { useState as v, useMemo as b } from "react";
3
+ import { styled as L, Box as d, Typography as w, IconButton as C, Button as I, useTheme as k, FormControl as D, TextField as F } from "@mui/material";
4
+ import { Remove as S, Add as B } from "@mui/icons-material";
5
+ import { translate as E } from "@arcblock/ux/lib/Locale/util";
6
+ import { useMemoizedFn as T } from "ahooks";
7
+ import { useLocaleContext as U } from "@arcblock/ux/lib/Locale/context";
8
+ import j from "@arcblock/icons/lib/Link";
9
9
  import { mergeSx as z } from "@arcblock/ux/lib/Util/style";
10
- import { joinURL as M, withoutProtocol as P } from "ufo";
11
- import { isValidUrl as v } from "./utils.js";
12
- import { translations as W } from "../../libs/locales.js";
13
- import { inputFieldStyle as _, commonInputStyle as A } from "../editable-field.js";
14
- function V(e) {
15
- return P(e);
10
+ import { withoutProtocol as M } from "ufo";
11
+ import { isValidUrl as f } from "./utils.js";
12
+ import { translations as P } from "../../libs/locales.js";
13
+ import { inputFieldStyle as R, commonInputStyle as W } from "../editable-field.js";
14
+ function _(e) {
15
+ return M(e);
16
16
  }
17
- function $({
17
+ function A({
18
18
  value: e,
19
19
  onChange: n,
20
20
  errorMsg: i
21
21
  }) {
22
- return /* @__PURE__ */ t(U, { fullWidth: !0, children: /* @__PURE__ */ t(
23
- D,
22
+ return /* @__PURE__ */ t(D, { fullWidth: !0, children: /* @__PURE__ */ t(
23
+ F,
24
24
  {
25
25
  variant: "outlined",
26
26
  value: e,
27
- onChange: (r) => {
28
- const d = r.target.value;
29
- n(d);
27
+ onChange: (a) => {
28
+ const c = a.target.value;
29
+ n(c);
30
30
  },
31
31
  fullWidth: !0,
32
32
  error: !!i,
33
33
  helperText: i,
34
- sx: z(_, i ? {} : A)
34
+ sx: z(R, i ? {} : W)
35
35
  }
36
36
  ) });
37
37
  }
38
- function q({ links: e = [], onChange: n }) {
39
- const { locale: i } = B(), l = j((a, o = {}) => R(W, a, i, "en", o)), [r, d] = y([!1]), f = w(() => {
40
- const a = e[e.length - 1];
41
- return !v(a) || r.length > 0 && r[r.length - 1];
42
- }, [r, e]), p = () => {
43
- (e.length < 5 || !f) && n([...e, ""]);
44
- }, u = (a) => {
45
- const o = e.filter((h, x) => x !== a), s = r.filter((h, x) => x !== a);
46
- d(s), n(o);
47
- }, m = (a, o) => {
38
+ function V({ links: e = [], onChange: n }) {
39
+ const { locale: i } = U(), l = T((o, r = {}) => E(P, o, i, "en", r)), [a, c] = v([!1]), u = b(() => {
40
+ const o = e[e.length - 1];
41
+ return !f(o) || a.length > 0 && a[a.length - 1];
42
+ }, [a, e]), x = () => {
43
+ (e.length < 5 || !u) && n([...e, ""]);
44
+ }, g = (o) => {
45
+ const r = e.filter((p, h) => h !== o), s = a.filter((p, h) => h !== o);
46
+ c(s), n(r);
47
+ }, y = (o, r) => {
48
48
  const s = [...e];
49
- s[a] = o;
50
- const h = [...r];
51
- h[a] = !!(o && !v(o)), d(h), n(s);
49
+ s[o] = r;
50
+ const p = [...a];
51
+ p[o] = !!(r && !f(r)), c(p), n(s);
52
52
  };
53
- return /* @__PURE__ */ g(
54
- c,
53
+ return /* @__PURE__ */ m(
54
+ d,
55
55
  {
56
56
  sx: {
57
57
  width: "100%"
58
58
  },
59
59
  children: [
60
60
  /* @__PURE__ */ t(
61
- c,
61
+ d,
62
62
  {
63
63
  sx: {
64
64
  display: "flex",
@@ -66,11 +66,11 @@ function q({ links: e = [], onChange: n }) {
66
66
  alignItems: "center",
67
67
  gap: 1
68
68
  },
69
- children: /* @__PURE__ */ t(C, { variant: "subtitle1", gutterBottom: !0, sx: { mb: 0, fontSize: "12px", color: "text.primary" }, children: l("profile.socialMedia") })
69
+ children: /* @__PURE__ */ t(w, { variant: "subtitle1", gutterBottom: !0, sx: { mb: 0, fontSize: "12px", color: "text.primary" }, children: l("profile.socialMedia") })
70
70
  }
71
71
  ),
72
- e.map((a, o) => /* @__PURE__ */ g(
73
- c,
72
+ e.map((o, r) => /* @__PURE__ */ m(
73
+ d,
74
74
  {
75
75
  sx: {
76
76
  display: "flex",
@@ -79,25 +79,25 @@ function q({ links: e = [], onChange: n }) {
79
79
  },
80
80
  children: [
81
81
  /* @__PURE__ */ t(
82
- $,
82
+ A,
83
83
  {
84
- value: a,
85
- onChange: (s) => m(o, s),
86
- errorMsg: r[o] ? l("profile.invalidURL") : ""
84
+ value: o,
85
+ onChange: (s) => y(r, s),
86
+ errorMsg: a[r] ? l("profile.invalidURL") : ""
87
87
  }
88
88
  ),
89
- /* @__PURE__ */ t(I, { onClick: () => u(o), children: /* @__PURE__ */ t(S, { sx: { color: "text.secondary" } }) })
89
+ /* @__PURE__ */ t(C, { onClick: () => g(r), children: /* @__PURE__ */ t(S, { sx: { color: "text.secondary" } }) })
90
90
  ]
91
91
  },
92
- o
92
+ r
93
93
  )),
94
- e.length < 5 && /* @__PURE__ */ g(
95
- F,
94
+ e.length < 5 && /* @__PURE__ */ m(
95
+ I,
96
96
  {
97
97
  fullWidth: !0,
98
98
  variant: "outlined",
99
- disabled: f,
100
- onClick: p,
99
+ disabled: u,
100
+ onClick: x,
101
101
  size: "small",
102
102
  sx: {
103
103
  height: "40px",
@@ -113,7 +113,7 @@ function q({ links: e = [], onChange: n }) {
113
113
  }
114
114
  },
115
115
  children: [
116
- /* @__PURE__ */ t(k, {}),
116
+ /* @__PURE__ */ t(B, {}),
117
117
  " ",
118
118
  /* @__PURE__ */ t("span", { children: l("profile.addLink") })
119
119
  ]
@@ -123,31 +123,17 @@ function q({ links: e = [], onChange: n }) {
123
123
  }
124
124
  );
125
125
  }
126
- function G({ link: e }) {
127
- const [n, i] = y(""), [l, r] = y(!1), f = E().palette.mode === "dark";
128
- return L(() => {
129
- try {
130
- if (e) {
131
- const p = new URL(e), u = M(p.origin, "favicon.ico"), m = new Image();
132
- m.src = u, m.onload = () => {
133
- i(u), r(!1);
134
- }, m.onerror = () => {
135
- r(!0), i("");
136
- };
137
- } else
138
- r(!0), i("");
139
- } catch {
140
- r(!0);
141
- }
142
- }, [e]), e ? l || !n ? /* @__PURE__ */ t(T, { width: 20, height: 20, style: { filter: f ? "brightness(0) saturate(100%) invert(1)" : "none" } }) : /* @__PURE__ */ t("img", { src: n, alt: "Favicon", width: 20, height: 20 }) : null;
126
+ function $({ link: e }) {
127
+ const i = k().palette.mode === "dark";
128
+ return e ? /* @__PURE__ */ t(j, { width: 20, height: 20, style: { filter: i ? "brightness(0) saturate(100%) invert(1)" : "none" } }) : null;
143
129
  }
144
- function ie({
130
+ function oe({
145
131
  editable: e = !1,
146
132
  links: n = [],
147
133
  onChange: i
148
134
  }) {
149
- return e ? /* @__PURE__ */ t(q, { links: n, onChange: i }) : /* @__PURE__ */ t(
150
- c,
135
+ return e ? /* @__PURE__ */ t(V, { links: n, onChange: i }) : /* @__PURE__ */ t(
136
+ d,
151
137
  {
152
138
  sx: {
153
139
  width: "100%",
@@ -155,8 +141,8 @@ function ie({
155
141
  flexDirection: "column",
156
142
  gap: 2
157
143
  },
158
- children: n.map((l) => /* @__PURE__ */ g(
159
- c,
144
+ children: n.map((l) => /* @__PURE__ */ m(
145
+ d,
160
146
  {
161
147
  sx: {
162
148
  display: "flex",
@@ -166,8 +152,8 @@ function ie({
166
152
  width: "100%"
167
153
  },
168
154
  children: [
169
- /* @__PURE__ */ t(G, { link: l }),
170
- /* @__PURE__ */ t(H, { children: /* @__PURE__ */ t(c, { component: "a", href: l, style: { textDecoration: "none" }, target: "_blank", rel: "noopener noreferrer", children: V(l) }) })
155
+ /* @__PURE__ */ t($, { link: l }),
156
+ /* @__PURE__ */ t(q, { children: /* @__PURE__ */ t(d, { component: "a", href: l, style: { textDecoration: "none" }, target: "_blank", rel: "noopener noreferrer", children: _(l) }) })
171
157
  ]
172
158
  },
173
159
  l
@@ -175,7 +161,7 @@ function ie({
175
161
  }
176
162
  );
177
163
  }
178
- const H = b("span")`
164
+ const q = L("span")`
179
165
  flex: 1;
180
166
  white-space: nowrap;
181
167
  overflow: hidden;
@@ -194,5 +180,5 @@ const H = b("span")`
194
180
  }
195
181
  `;
196
182
  export {
197
- ie as LinkPreviewInput
183
+ oe as LinkPreviewInput
198
184
  };
@@ -1,29 +1,28 @@
1
1
  import { jsxs as x, Fragment as A, jsx as a } from "react/jsx-runtime";
2
- import { lazy as P, memo as mo, createElement as ho, useState as G, useRef as fo, useEffect as so, useMemo as H } from "react";
2
+ import { lazy as P, memo as mo, createElement as ho, useState as H, useRef as fo, useEffect as so, useMemo as Q } from "react";
3
3
  import { Icon as yo } from "@iconify/react";
4
4
  import { Backdrop as xo, Box as f, useMediaQuery as bo, SwipeableDrawer as uo, Typography as S, Tooltip as go } from "@mui/material";
5
5
  import Co from "@emotion/styled";
6
- import { joinURL as vo } from "ufo";
7
6
  import O from "@arcblock/ux/lib/Button";
8
- import Q, { detectCountryFromPhone as Y, getCountryNameByCountry as wo, validatePhoneNumber as ko, getDialCodeByCountry as Eo } from "@arcblock/ux/lib/PhoneInput";
7
+ import U, { detectCountryFromPhone as Y, getCountryNameByCountry as vo, validatePhoneNumber as wo, getDialCodeByCountry as ko } from "@arcblock/ux/lib/PhoneInput";
9
8
  import k from "lodash/cloneDeep";
10
- import Io from "lodash/omit";
11
- import { mergeSx as zo } from "@arcblock/ux/lib/Util/style";
9
+ import Eo from "lodash/omit";
10
+ import { mergeSx as Io } from "@arcblock/ux/lib/Util/style";
12
11
  import { LOGIN_PROVIDER as _ } from "@arcblock/ux/lib/Util/constant";
13
- import { useReactive as E, useCreation as I, useMemoizedFn as Po } from "ahooks";
14
- import { translate as Vo } from "@arcblock/ux/lib/Locale/util";
15
- import Bo from "validator/lib/isEmail";
12
+ import { useReactive as E, useCreation as I, useMemoizedFn as zo } from "ahooks";
13
+ import { translate as Po } from "@arcblock/ux/lib/Locale/util";
14
+ import Vo from "validator/lib/isEmail";
16
15
  import q from "validator/lib/isPostalCode";
17
- import { useLocaleContext as Lo } from "@arcblock/ux/lib/Locale/context";
18
- import { useBrowser as jo } from "@arcblock/react-hooks";
16
+ import { useLocaleContext as Bo } from "@arcblock/ux/lib/Locale/context";
17
+ import { useBrowser as Lo } from "@arcblock/react-hooks";
19
18
  import No from "@arcblock/ux/lib/UserCard/Content/clock";
20
- import { translations as Ao } from "../../libs/locales.js";
21
- import g, { inputFieldStyle as So, commonInputStyle as Oo } from "../editable-field.js";
22
- import { LinkPreviewInput as Ro } from "./link-preview-input.js";
23
- import { defaultButtonStyle as J, currentTimezone as R, primaryButtonStyle as Do } from "./utils.js";
24
- import { TimezoneSelect as Wo } from "./timezone-select.js";
25
- import To from "./address.js";
26
- const Fo = P(() => import("@arcblock/icons/lib/Location")), Mo = P(() => import("@arcblock/icons/lib/Timezone")), $o = P(() => import("@arcblock/icons/lib/Email")), Uo = P(() => import("@arcblock/icons/lib/Phone")), z = {
19
+ import { translations as jo } from "../../libs/locales.js";
20
+ import g, { inputFieldStyle as Ao, commonInputStyle as So } from "../editable-field.js";
21
+ import { LinkPreviewInput as Oo } from "./link-preview-input.js";
22
+ import { defaultButtonStyle as J, currentTimezone as R, primaryButtonStyle as Ro } from "./utils.js";
23
+ import { TimezoneSelect as Do } from "./timezone-select.js";
24
+ import Wo from "./address.js";
25
+ const To = P(() => import("@arcblock/icons/lib/Location")), Fo = P(() => import("@arcblock/icons/lib/Timezone")), Mo = P(() => import("@arcblock/icons/lib/Email")), $o = P(() => import("@arcblock/icons/lib/Phone")), z = {
27
26
  width: 20,
28
27
  height: 20
29
28
  }, K = 200, X = mo(function({
@@ -46,14 +45,14 @@ const Fo = P(() => import("@arcblock/icons/lib/Location")), Mo = P(() => import(
46
45
  );
47
46
  });
48
47
  X.displayName = "BackdropWrap";
49
- function xe({
48
+ function se({
50
49
  isMyself: m,
51
50
  user: o,
52
51
  onSave: V,
53
52
  isMobile: b
54
53
  }) {
55
- var $, U;
56
- const [Z, B] = G(!1), [oo, C] = G(!1), eo = fo(null), no = jo(), u = bo("(max-width:640px)") || no.mobile.any, p = E({
54
+ var $, G;
55
+ const [Z, B] = H(!1), [oo, C] = H(!1), eo = fo(null), no = Lo(), u = bo("(max-width:640px)") || no.mobile.any, p = E({
57
56
  email: "",
58
57
  phone: ""
59
58
  }), s = E({
@@ -67,7 +66,7 @@ function xe({
67
66
  so(() => {
68
67
  u || C(!1);
69
68
  }, [u]);
70
- const D = I(() => (o == null ? void 0 : o.phoneVerified) ?? !1, [o == null ? void 0 : o.phoneVerified]), W = I(() => (o == null ? void 0 : o.emailVerified) ?? !1, [o == null ? void 0 : o.emailVerified]), { locale: L } = Lo(), c = Po((n, i = {}) => Vo(Ao, n, L, "en", i)), l = E(
69
+ const D = I(() => (o == null ? void 0 : o.phoneVerified) ?? !1, [o == null ? void 0 : o.phoneVerified]), W = I(() => (o == null ? void 0 : o.emailVerified) ?? !1, [o == null ? void 0 : o.emailVerified]), { locale: L } = Bo(), c = zo((n, i = {}) => Po(jo, n, L, "en", i)), l = E(
71
70
  o != null && o.metadata ? k(o.metadata) : {
72
71
  joinedAt: o == null ? void 0 : o.createdAt,
73
72
  email: o == null ? void 0 : o.email,
@@ -85,10 +84,10 @@ function xe({
85
84
  line2: "",
86
85
  postalCode: ""
87
86
  }
88
- ), to = I(() => !!(o != null && o.address), [($ = o == null ? void 0 : o.address) == null ? void 0 : $.country]), y = H(() => {
87
+ ), to = I(() => !!(o != null && o.address), [($ = o == null ? void 0 : o.address) == null ? void 0 : $.country]), y = Q(() => {
89
88
  var n;
90
89
  return (n = o == null ? void 0 : o.address) != null && n.country ? o.address.country : L === "zh" ? "cn" : "us";
91
- }, [(U = o == null ? void 0 : o.address) == null ? void 0 : U.country, L]), j = I(() => {
90
+ }, [(G = o == null ? void 0 : o.address) == null ? void 0 : G.country, L]), N = I(() => {
92
91
  const n = l.phone ?? (o == null ? void 0 : o.phone) ?? {
93
92
  country: y,
94
93
  phone: ""
@@ -130,7 +129,7 @@ function xe({
130
129
  t[e] = "";
131
130
  });
132
131
  }), u ? C(!1) : B(!1);
133
- }, ao = H(() => {
132
+ }, ao = Q(() => {
134
133
  var i;
135
134
  const n = ((i = l == null ? void 0 : l.links) == null ? void 0 : i.map((t) => t.url)) || [""];
136
135
  return n.length > 0 ? n : [""];
@@ -147,7 +146,7 @@ function xe({
147
146
  url: t
148
147
  } : {
149
148
  url: t,
150
- favicon: vo(t, "favicon.ico")
149
+ favicon: t
151
150
  };
152
151
  });
153
152
  h(i, "links");
@@ -156,7 +155,7 @@ function xe({
156
155
  var d, v;
157
156
  const t = i, e = l[t];
158
157
  if (e && typeof e == "string" && (l[t] = e.trim()), t === "bio" && (l[t] = (d = l[t]) == null ? void 0 : d.slice(0, K)), t === "timezone" && (l[t] = e || R), t === "phone" && e && typeof e == "object") {
159
- const w = e, co = Eo(w.country), N = ((v = w.phoneNumber) == null ? void 0 : v.replace(new RegExp(`^\\+${co}`), "")) || "", po = (N == null ? void 0 : N.trim().length) > 0;
158
+ const w = e, co = ko(w.country), j = ((v = w.phoneNumber) == null ? void 0 : v.replace(new RegExp(`^\\+${co}`), "")) || "", po = (j == null ? void 0 : j.trim().length) > 0;
160
159
  l[t] = {
161
160
  country: w.country,
162
161
  ...po ? { phoneNumber: w.phoneNumber } : {}
@@ -164,7 +163,7 @@ function xe({
164
163
  }
165
164
  }), r.postalCode && !q(r.postalCode, "any") && (s.postalCode = c("profile.address.invalidPostalCode")), [p, s].some((i) => Object.values(i).some((t) => t)))
166
165
  return;
167
- const n = Io(r, "detailedAddress");
166
+ const n = Eo(r, "detailedAddress");
168
167
  n.country || (n.country = y), V({ metadata: l, address: n }), B(!1), C(!1);
169
168
  }, M = (n, i = "self") => {
170
169
  var t;
@@ -212,7 +211,7 @@ function xe({
212
211
  }
213
212
  ) : null,
214
213
  n && m && to ? /* @__PURE__ */ a(
215
- To,
214
+ Wo,
216
215
  {
217
216
  address: r,
218
217
  errors: s,
@@ -243,10 +242,10 @@ function xe({
243
242
  /* @__PURE__ */ a(S, { variant: "caption", component: "span", children: r[e] })
244
243
  ] }, e) : null) }) : null,
245
244
  renderValue: () => {
246
- const d = [r != null && r.country ? wo(r == null ? void 0 : r.country) : "", r.province, r.city || l.location || ""].filter(Boolean).join(" ");
245
+ const d = [r != null && r.country ? vo(r == null ? void 0 : r.country) : "", r.province, r.city || l.location || ""].filter(Boolean).join(" ");
247
246
  return /* @__PURE__ */ a(S, { component: "span", children: d });
248
247
  },
249
- icon: /* @__PURE__ */ a(Fo, { ...z })
248
+ icon: /* @__PURE__ */ a(To, { ...z })
250
249
  }
251
250
  ),
252
251
  /* @__PURE__ */ a(
@@ -256,11 +255,11 @@ function xe({
256
255
  onChange: (e) => h(e, "timezone"),
257
256
  editable: n,
258
257
  placeholder: "timezone",
259
- icon: /* @__PURE__ */ a(Mo, { ...z }),
258
+ icon: /* @__PURE__ */ a(Fo, { ...z }),
260
259
  label: c("profile.timezone"),
261
260
  renderValue: (e) => /* @__PURE__ */ a(No, { value: e }),
262
261
  children: /* @__PURE__ */ a(
263
- Wo,
262
+ Do,
264
263
  {
265
264
  value: l.timezone || R,
266
265
  onChange: (e) => h(e, "timezone"),
@@ -280,7 +279,7 @@ function xe({
280
279
  canEdit: !W,
281
280
  verified: W,
282
281
  placeholder: "Email",
283
- icon: /* @__PURE__ */ a($o, { ...z }),
282
+ icon: /* @__PURE__ */ a(Mo, { ...z }),
284
283
  label: /* @__PURE__ */ x(A, { children: [
285
284
  c("profile.email"),
286
285
  (o == null ? void 0 : o.sourceProvider) === _.EMAIL ? /* @__PURE__ */ a(go, { title: c("profile.emailSourceProviderNotAllowEdit"), children: /* @__PURE__ */ a(
@@ -310,25 +309,25 @@ function xe({
310
309
  ) : null,
311
310
  onValueValidate: (e) => {
312
311
  let d = "";
313
- e && !Bo(e) && (d = c("profile.emailInvalid")), p.email = d;
312
+ e && !Vo(e) && (d = c("profile.emailInvalid")), p.email = d;
314
313
  }
315
314
  }
316
315
  ),
317
316
  /* @__PURE__ */ a(
318
317
  g,
319
318
  {
320
- value: j.phone,
319
+ value: N.phone,
321
320
  editable: n,
322
321
  hidePreview: !m,
323
322
  canEdit: !D,
324
323
  verified: D,
325
324
  placeholder: "Phone",
326
- icon: /* @__PURE__ */ a(Uo, { ...z }),
325
+ icon: /* @__PURE__ */ a($o, { ...z }),
327
326
  onChange: (e) => h(e, "phone"),
328
327
  label: c("profile.phone"),
329
- renderValue: () => m ? /* @__PURE__ */ a(Q, { value: j, preview: !0 }) : null,
328
+ renderValue: () => m ? /* @__PURE__ */ a(U, { value: N, preview: !0 }) : null,
330
329
  children: /* @__PURE__ */ a(
331
- Q,
330
+ U,
332
331
  {
333
332
  variant: "outlined",
334
333
  className: "editable-field",
@@ -336,12 +335,12 @@ function xe({
336
335
  sx: { backgroundColor: "transparent" },
337
336
  placeholder: "Phone"
338
337
  },
339
- value: j,
338
+ value: N,
340
339
  error: !!p.phone,
341
340
  helperText: p.phone,
342
- sx: zo(So, p.phone ? {} : Oo),
341
+ sx: Io(Ao, p.phone ? {} : So),
343
342
  onChange: (e) => {
344
- ko(e.phone, e.country) ? p.phone = "" : p.phone = c("profile.phoneInvalid"), h(
343
+ wo(e.phone, e.country) ? p.phone = "" : p.phone = c("profile.phoneInvalid"), h(
345
344
  {
346
345
  country: e.country,
347
346
  phoneNumber: e.phone
@@ -353,7 +352,7 @@ function xe({
353
352
  )
354
353
  }
355
354
  ),
356
- /* @__PURE__ */ a(Ro, { editable: n, links: ao, onChange: lo }),
355
+ /* @__PURE__ */ a(Oo, { editable: n, links: ao, onChange: lo }),
357
356
  n && m ? /* @__PURE__ */ x(
358
357
  f,
359
358
  {
@@ -384,7 +383,7 @@ function xe({
384
383
  disabled: !!p.email || !!p.phone,
385
384
  variant: "outlined",
386
385
  sx: {
387
- ...Do,
386
+ ...Ro,
388
387
  minWidth: "54px",
389
388
  "&.Mui-disabled": {
390
389
  backgroundColor: "rgba(0, 0, 0, 0.12)"
@@ -506,5 +505,5 @@ const Go = Co(f)`
506
505
  }
507
506
  `;
508
507
  export {
509
- xe as default
508
+ se as default
510
509
  };
@@ -1,50 +1,94 @@
1
- import c from "moment-timezone";
2
1
  import a from "dayjs";
3
- import { DurationEnum as s } from "../../../@types/index.js";
4
- const u = 3600, d = 1800, m = 600, f = 300, b = 60, p = 1, g = c.tz.guess(), A = () => c.tz.names().map((r) => {
5
- const n = c.tz(r).utcOffset() / 60, t = Math.floor(n), i = n % 1 * 60;
6
- return { label: `GMT${t >= 0 ? "+" : ""}${t}:${i === 30 ? "30" : "00"}`, value: r };
7
- }).sort((r, n) => {
8
- const [t, i] = r.label.replace("GMT", "").split(":").map(Number), [l, y] = n.label.replace("GMT", "").split(":").map(Number), T = t * 60 + i;
9
- return l * 60 + y - T;
10
- }).map((r) => ({
11
- label: `(${r.label}) ${r.value}`,
12
- value: r.value
13
- })), M = (o) => /^(https?:\/\/)?((([a-zA-Z\d]([a-zA-Z\d-]*[a-zA-Z\d])*)\.)+[a-zA-Z]{2,}|((\d{1,3}\.){3}\d{1,3}))(:\d+)?(\/[-a-zA-Z\d%_.~+]*)*(\?[;&a-zA-Z\d%_.~+=-]*)?(#[a-zA-Z\d_]*)?$/.test(o), N = (o) => {
14
- var n;
15
- let e = ((n = o == null ? void 0 : o.dateRange) == null ? void 0 : n.map((t) => a(t))) ?? [];
16
- const r = a();
17
- switch (o == null ? void 0 : o.duration) {
18
- case s.ThirtyMinutes:
19
- e = [r, r.add(30, "minutes")];
2
+ import T from "dayjs/plugin/timezone";
3
+ import g from "dayjs/plugin/utc";
4
+ import { DurationEnum as i } from "../../../@types/index.js";
5
+ a.extend(g);
6
+ a.extend(T);
7
+ const l = 3600, u = 1800, m = 600, d = 300, f = 60, p = 1, M = a.tz.guess(), A = [
8
+ "America/New_York",
9
+ "America/Chicago",
10
+ "America/Denver",
11
+ "America/Los_Angeles",
12
+ "Europe/London",
13
+ "Europe/Paris",
14
+ "Europe/Berlin",
15
+ "Europe/Rome",
16
+ "Asia/Tokyo",
17
+ "Asia/Shanghai",
18
+ "Asia/Hong_Kong",
19
+ "Asia/Singapore",
20
+ "Asia/Seoul",
21
+ "Asia/Kolkata",
22
+ "Australia/Sydney",
23
+ "Australia/Melbourne",
24
+ "Pacific/Auckland",
25
+ "America/Sao_Paulo",
26
+ "America/Mexico_City",
27
+ "Africa/Cairo",
28
+ "UTC"
29
+ ], h = () => {
30
+ if (typeof Intl < "u" && Intl.supportedValuesOf)
31
+ try {
32
+ return Intl.supportedValuesOf("timeZone");
33
+ } catch {
34
+ console.warn("Intl.supportedValuesOf not supported, falling back to common timezones");
35
+ }
36
+ if (typeof Intl < "u" && Intl.DateTimeFormat)
37
+ try {
38
+ if (new Intl.DateTimeFormat("en", { timeZone: "UTC" }).resolvedOptions().timeZone)
39
+ return A;
40
+ } catch {
41
+ console.warn("Intl.DateTimeFormat timezone support limited");
42
+ }
43
+ return A;
44
+ }, I = () => h().map((e) => {
45
+ try {
46
+ const t = a.tz(a(), e).utcOffset() / 60, n = Math.floor(t), s = t % 1 * 60;
47
+ return { label: `GMT${n >= 0 ? "+" : ""}${n}:${s === 30 ? "30" : "00"}`, value: e };
48
+ } catch {
49
+ return console.warn(`Timezone ${e} not supported, skipping`), null;
50
+ }
51
+ }).filter((e) => e !== null).sort((e, t) => {
52
+ const [n, s] = e.label.replace("GMT", "").split(":").map(Number), [c, b] = t.label.replace("GMT", "").split(":").map(Number), y = n * 60 + s;
53
+ return c * 60 + b - y;
54
+ }).map((e) => ({
55
+ label: `(${e.label}) ${e.value}`,
56
+ value: e.value
57
+ })), N = (r) => /^(https?:\/\/)?((([a-zA-Z\d]([a-zA-Z\d-]*[a-zA-Z\d])*)\.)+[a-zA-Z]{2,}|((\d{1,3}\.){3}\d{1,3}))(:\d+)?(\/[-a-zA-Z\d%_.~+]*)*(\?[;&a-zA-Z\d%_.~+=-]*)?(#[a-zA-Z\d_]*)?$/.test(r), _ = (r) => {
58
+ var t;
59
+ let o = ((t = r == null ? void 0 : r.dateRange) == null ? void 0 : t.map((n) => a(n))) ?? [];
60
+ const e = a();
61
+ switch (r == null ? void 0 : r.duration) {
62
+ case i.ThirtyMinutes:
63
+ o = [e, e.add(30, "minutes")];
20
64
  break;
21
- case s.OneHour:
22
- e = [r, r.add(1, "hour")];
65
+ case i.OneHour:
66
+ o = [e, e.add(1, "hour")];
23
67
  break;
24
- case s.FourHours:
25
- e = [r, r.add(4, "hours")];
68
+ case i.FourHours:
69
+ o = [e, e.add(4, "hours")];
26
70
  break;
27
- case s.Today:
28
- e = [r, r.endOf("day")];
71
+ case i.Today:
72
+ o = [e, e.endOf("day")];
29
73
  break;
30
- case s.ThisWeek:
31
- e = [r, r.endOf("week")];
74
+ case i.ThisWeek:
75
+ o = [e, e.endOf("week")];
32
76
  break;
33
- case s.NoClear:
34
- e = [r, r];
77
+ case i.NoClear:
78
+ o = [e, e];
35
79
  break;
36
80
  }
37
- return e.map((t) => t.toDate());
38
- }, S = (o) => {
39
- const e = a();
40
- return e.isAfter(a(o[0])) && e.isBefore(a(o[1]));
41
- }, O = (o) => {
42
- const { duration: e, dateRange: r } = o ?? {};
43
- return !e || !r ? !1 : e === s.NoClear || a(r == null ? void 0 : r[0]).isSame(a(r == null ? void 0 : r[1]));
44
- }, v = (o) => {
45
- const e = a(), n = a(o).diff(e, "seconds"), t = (i) => i * 1e3;
46
- return n >= u ? t(u) : n >= d ? t(d) : n >= m ? t(m) : n >= f ? t(f) : n >= b ? t(b) : n >= p ? t(p) : 0;
47
- }, B = {
81
+ return o.map((n) => n.toDate());
82
+ }, E = (r) => {
83
+ const o = a();
84
+ return o.isAfter(a(r[0])) && o.isBefore(a(r[1]));
85
+ }, Z = (r) => {
86
+ const { duration: o, dateRange: e } = r ?? {};
87
+ return !o || !e ? !1 : o === i.NoClear || a(e == null ? void 0 : e[0]).isSame(a(e == null ? void 0 : e[1]));
88
+ }, v = (r) => {
89
+ const o = a(), t = a(r).diff(o, "seconds"), n = (s) => s * 1e3;
90
+ return t >= l ? n(l) : t >= u ? n(u) : t >= m ? n(m) : t >= d ? n(d) : t >= f ? n(f) : t >= p ? n(p) : 0;
91
+ }, w = {
48
92
  color: "text.primary",
49
93
  borderColor: "grey.100",
50
94
  backgroundColor: "background.default",
@@ -54,7 +98,7 @@ const u = 3600, d = 1800, m = 600, f = 300, b = 60, p = 1, g = c.tz.guess(), A =
54
98
  },
55
99
  py: 0.5,
56
100
  borderRadius: 1
57
- }, Z = {
101
+ }, B = {
58
102
  color: "primary.contrastText",
59
103
  borderColor: "primary.main",
60
104
  backgroundColor: "primary.main",
@@ -66,13 +110,13 @@ const u = 3600, d = 1800, m = 600, f = 300, b = 60, p = 1, g = c.tz.guess(), A =
66
110
  borderRadius: 1
67
111
  };
68
112
  export {
69
- g as currentTimezone,
70
- B as defaultButtonStyle,
71
- N as getStatusDuration,
113
+ M as currentTimezone,
114
+ w as defaultButtonStyle,
115
+ _ as getStatusDuration,
72
116
  v as getTimeRemaining,
73
- A as getTimezones,
74
- O as isNotClear,
75
- M as isValidUrl,
76
- S as isWithinTimeRange,
77
- Z as primaryButtonStyle
117
+ I as getTimezones,
118
+ Z as isNotClear,
119
+ N as isValidUrl,
120
+ E as isWithinTimeRange,
121
+ B as primaryButtonStyle
78
122
  };
@@ -1,4 +1,4 @@
1
1
  export { H as default };
2
- declare function H({ user: d }: {
2
+ declare function H({ user: p }: {
3
3
  user: any;
4
4
  }): import('react').ReactElement<unknown, string | import('react').JSXElementConstructor<any>>;
@@ -1,5 +1,5 @@
1
- export { ie as LinkPreviewInput };
2
- declare function ie({ editable: e, links: n, onChange: i }: {
1
+ export { oe as LinkPreviewInput };
2
+ declare function oe({ editable: e, links: n, onChange: i }: {
3
3
  editable?: boolean | undefined;
4
4
  links?: any[] | undefined;
5
5
  onChange: any;
@@ -1,5 +1,5 @@
1
- export { xe as default };
2
- declare function xe({ isMyself: m, user: o, onSave: V, isMobile: b }: {
1
+ export { se as default };
2
+ declare function se({ isMyself: m, user: o, onSave: V, isMobile: b }: {
3
3
  isMyself: any;
4
4
  user: any;
5
5
  onSave: any;
@@ -1,5 +1,5 @@
1
- declare const g: string;
2
- declare const B: {
1
+ declare const M: string;
2
+ declare const w: {
3
3
  color: string;
4
4
  borderColor: string;
5
5
  backgroundColor: string;
@@ -10,16 +10,16 @@ declare const B: {
10
10
  py: number;
11
11
  borderRadius: number;
12
12
  };
13
- declare function N(o: any): any;
14
- declare function v(o: any): number;
15
- declare function A(): {
13
+ declare function _(r: any): any;
14
+ declare function v(r: any): number;
15
+ declare function I(): {
16
16
  label: string;
17
17
  value: string;
18
18
  }[];
19
- declare function O(o: any): boolean;
20
- declare function M(o: any): boolean;
21
- declare function S(o: any): boolean;
22
- declare const Z: {
19
+ declare function Z(r: any): boolean;
20
+ declare function N(r: any): boolean;
21
+ declare function E(r: any): boolean;
22
+ declare const B: {
23
23
  color: string;
24
24
  borderColor: string;
25
25
  backgroundColor: string;
@@ -30,4 +30,4 @@ declare const Z: {
30
30
  py: number;
31
31
  borderRadius: number;
32
32
  };
33
- export { g as currentTimezone, B as defaultButtonStyle, N as getStatusDuration, v as getTimeRemaining, A as getTimezones, O as isNotClear, M as isValidUrl, S as isWithinTimeRange, Z as primaryButtonStyle };
33
+ export { M as currentTimezone, w as defaultButtonStyle, _ as getStatusDuration, v as getTimeRemaining, I as getTimezones, Z as isNotClear, N as isValidUrl, E as isWithinTimeRange, B as primaryButtonStyle };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/ui-react",
3
- "version": "3.0.0",
3
+ "version": "3.0.2",
4
4
  "description": "Some useful front-end web components that can be used in Blocklets.",
5
5
  "keywords": [
6
6
  "react",
@@ -34,9 +34,9 @@
34
34
  "dependencies": {
35
35
  "@abtnode/constant": "^1.16.44",
36
36
  "@abtnode/util": "^1.16.44",
37
- "@arcblock/bridge": "3.0.0",
38
- "@arcblock/icons": "3.0.0",
39
- "@arcblock/react-hooks": "3.0.0",
37
+ "@arcblock/bridge": "3.0.2",
38
+ "@arcblock/icons": "3.0.2",
39
+ "@arcblock/react-hooks": "3.0.2",
40
40
  "@arcblock/ws": "^1.20.14",
41
41
  "@blocklet/constant": "^1.16.44",
42
42
  "@blocklet/did-space-react": "^1.0.62",
@@ -54,7 +54,6 @@
54
54
  "is-url": "^1.2.4",
55
55
  "js-cookie": "^2.2.1",
56
56
  "lodash": "^4.17.21",
57
- "moment-timezone": "^0.5.48",
58
57
  "notistack": "^2.0.8",
59
58
  "p-all": "^5.0.0",
60
59
  "p-queue": "^6.6.2",
@@ -89,5 +88,5 @@
89
88
  "jest": "^29.7.0",
90
89
  "unbuild": "^2.0.0"
91
90
  },
92
- "gitHead": "b001c32ca85d40d8a0784ca581bfd54d90550b24"
91
+ "gitHead": "82d588535242081273ada50bca749f532689b785"
93
92
  }
@@ -97,6 +97,12 @@ export default function Nft({ user }: { user: User }) {
97
97
  }}>
98
98
  {t('common.nft')}
99
99
  </Typography>
100
+
101
+ {data?.assets?.length === 0 && !loading && (
102
+ <Box sx={{ display: 'flex', justifyContent: 'center', alignItems: 'center', width: '100%', height: '100%' }}>
103
+ <Empty>{t('common.noNFT')}</Empty>
104
+ </Box>
105
+ )}
100
106
  <Box
101
107
  className="nft-list-wrapper"
102
108
  sx={{
@@ -130,18 +136,6 @@ export default function Nft({ user }: { user: User }) {
130
136
  />
131
137
  </Box>
132
138
  ))}
133
- {data?.assets?.length === 0 && !loading && (
134
- <Box
135
- sx={{
136
- display: 'flex',
137
- justifyContent: 'center',
138
- alignItems: 'center',
139
- width: '100%',
140
- height: '100%',
141
- }}>
142
- <Empty>{t('common.noNFT')}</Empty>
143
- </Box>
144
- )}
145
139
  </Box>
146
140
  {dataPage.next || paging.page > 1 ? (
147
141
  <Pagination
@@ -1,4 +1,4 @@
1
- import { ChangeEvent, useEffect, useMemo, useState } from 'react';
1
+ import { ChangeEvent, useMemo, useState } from 'react';
2
2
  import { Box, Button, FormControl, IconButton, styled, TextField, Typography, useTheme } from '@mui/material';
3
3
  import { Remove as RemoveIcon, Add as AddIcon } from '@mui/icons-material';
4
4
  import { translate } from '@arcblock/ux/lib/Locale/util';
@@ -6,7 +6,7 @@ import { useMemoizedFn } from 'ahooks';
6
6
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
7
7
  import LinkIcon from '@arcblock/icons/lib/Link';
8
8
  import { mergeSx } from '@arcblock/ux/lib/Util/style';
9
- import { joinURL, withoutProtocol } from 'ufo';
9
+ import { withoutProtocol } from 'ufo';
10
10
  import { isValidUrl } from './utils';
11
11
  import { translations } from '../../libs/locales';
12
12
  import { commonInputStyle, inputFieldStyle } from '../editable-field';
@@ -158,49 +158,16 @@ function DynamicLinkForm({ links = [], onChange }: { links: string[]; onChange:
158
158
  * favicon 预览
159
159
  */
160
160
  function FaviconPreview({ link }: { link: string }) {
161
- const [favicon, setFavicon] = useState('');
162
- const [iconError, setIconError] = useState(false); // 控制是否显示默认图标
163
161
  const theme = useTheme();
164
162
  const isDark = theme.palette.mode === 'dark';
165
163
 
166
- useEffect(() => {
167
- try {
168
- if (link) {
169
- const url = new URL(link);
170
- const faviconUrl = joinURL(url.origin, 'favicon.ico');
171
-
172
- // 尝试加载 Favicon
173
- const img = new Image();
174
- img.src = faviconUrl;
175
- // TODO: CSP 导致解析失败
176
- img.onload = () => {
177
- setFavicon(faviconUrl);
178
- setIconError(false);
179
- };
180
- img.onerror = () => {
181
- setIconError(true);
182
- setFavicon('');
183
- };
184
- } else {
185
- setIconError(true);
186
- setFavicon('');
187
- }
188
- } catch (error) {
189
- setIconError(true); // URL 解析失败,直接回退到默认图标
190
- }
191
- }, [link]);
192
-
193
164
  if (!link) {
194
165
  return null;
195
166
  }
196
167
 
197
- if (iconError || !favicon) {
198
- return (
199
- <LinkIcon width={20} height={20} style={{ filter: isDark ? 'brightness(0) saturate(100%) invert(1)' : 'none' }} />
200
- );
201
- }
202
-
203
- return <img src={favicon} alt="Favicon" width={20} height={20} />;
168
+ return (
169
+ <LinkIcon width={20} height={20} style={{ filter: isDark ? 'brightness(0) saturate(100%) invert(1)' : 'none' }} />
170
+ );
204
171
  }
205
172
 
206
173
  export function LinkPreviewInput({
@@ -3,7 +3,6 @@ import { Box, Backdrop, useMediaQuery, SwipeableDrawer, Typography, Tooltip } fr
3
3
  import type { BackdropProps } from '@mui/material';
4
4
 
5
5
  import styled from '@emotion/styled';
6
- import { joinURL } from 'ufo';
7
6
  import Button from '@arcblock/ux/lib/Button';
8
7
  import PhoneInput, {
9
8
  PhoneValue,
@@ -271,7 +270,7 @@ export default function UserMetadataComponent({
271
270
  }
272
271
  return {
273
272
  url: link,
274
- favicon: joinURL(link, 'favicon.ico'),
273
+ favicon: link,
275
274
  };
276
275
  });
277
276
  onChange(newLinks, 'links');
@@ -1,7 +1,12 @@
1
- import moment from 'moment-timezone';
2
1
  import dayjs from 'dayjs';
2
+ import timezone from 'dayjs/plugin/timezone';
3
+ import utc from 'dayjs/plugin/utc';
3
4
  import { DurationEnum, UserMetadata } from '../../../@types';
4
5
 
6
+ // 扩展 dayjs 插件
7
+ dayjs.extend(utc);
8
+ dayjs.extend(timezone);
9
+
5
10
  const HOUR = 3600;
6
11
  const MINUTES_30 = 1800;
7
12
  const MINUTES_10 = 600;
@@ -9,19 +14,80 @@ const MINUTES_5 = 300;
9
14
  const MINUTES_1 = 60;
10
15
  const SECOND = 1;
11
16
 
12
- export const currentTimezone = moment.tz.guess();
17
+ export const currentTimezone = dayjs.tz.guess();
18
+
19
+ // 常用时区列表,作为兼容性 fallback
20
+ const COMMON_TIMEZONES = [
21
+ 'America/New_York',
22
+ 'America/Chicago',
23
+ 'America/Denver',
24
+ 'America/Los_Angeles',
25
+ 'Europe/London',
26
+ 'Europe/Paris',
27
+ 'Europe/Berlin',
28
+ 'Europe/Rome',
29
+ 'Asia/Tokyo',
30
+ 'Asia/Shanghai',
31
+ 'Asia/Hong_Kong',
32
+ 'Asia/Singapore',
33
+ 'Asia/Seoul',
34
+ 'Asia/Kolkata',
35
+ 'Australia/Sydney',
36
+ 'Australia/Melbourne',
37
+ 'Pacific/Auckland',
38
+ 'America/Sao_Paulo',
39
+ 'America/Mexico_City',
40
+ 'Africa/Cairo',
41
+ 'UTC',
42
+ ];
43
+
44
+ // 获取时区列表的兼容性函数
45
+ const getTimezoneList = () => {
46
+ // 优先使用现代 API
47
+ if (typeof Intl !== 'undefined' && Intl.supportedValuesOf) {
48
+ try {
49
+ return Intl.supportedValuesOf('timeZone');
50
+ } catch (error) {
51
+ console.warn('Intl.supportedValuesOf not supported, falling back to common timezones');
52
+ }
53
+ }
13
54
 
14
- export const getTimezones = () => {
15
- const timezones = moment.tz.names();
55
+ // 尝试使用 Intl.DateTimeFormat 获取时区
56
+ if (typeof Intl !== 'undefined' && Intl.DateTimeFormat) {
57
+ try {
58
+ // 使用 resolvedOptions 检测当前时区是否可用
59
+ const formatter = new Intl.DateTimeFormat('en', { timeZone: 'UTC' });
60
+ if (formatter.resolvedOptions().timeZone) {
61
+ return COMMON_TIMEZONES;
62
+ }
63
+ } catch (error) {
64
+ console.warn('Intl.DateTimeFormat timezone support limited');
65
+ }
66
+ }
16
67
 
17
- const formattedTimezones = timezones.map((tz) => {
18
- const offset = moment.tz(tz).utcOffset() / 60; // 计算 UTC 偏移 (小时)
19
- const hours = Math.floor(offset);
20
- const minutes = (offset % 1) * 60;
21
- const label = `GMT${hours >= 0 ? '+' : ''}${hours}:${minutes === 30 ? '30' : '00'}`;
68
+ // 最后的 fallback
69
+ return COMMON_TIMEZONES;
70
+ };
22
71
 
23
- return { label, value: tz };
24
- });
72
+ export const getTimezones = () => {
73
+ const timezones = getTimezoneList();
74
+
75
+ const formattedTimezones = timezones
76
+ .map((tz) => {
77
+ try {
78
+ const offset = dayjs.tz(dayjs(), tz).utcOffset() / 60; // 计算 UTC 偏移 (小时)
79
+ const hours = Math.floor(offset);
80
+ const minutes = (offset % 1) * 60;
81
+ const label = `GMT${hours >= 0 ? '+' : ''}${hours}:${minutes === 30 ? '30' : '00'}`;
82
+
83
+ return { label, value: tz };
84
+ } catch (error) {
85
+ // 如果时区不支持,跳过
86
+ console.warn(`Timezone ${tz} not supported, skipping`);
87
+ return null;
88
+ }
89
+ })
90
+ .filter((tz): tz is { label: string; value: string } => tz !== null); // 类型守卫
25
91
 
26
92
  return formattedTimezones
27
93
  .sort((a, b) => {