@blocklet/ui-react 3.4.5 → 3.4.7

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,6 +1,6 @@
1
1
  import { jsx as e, jsxs as f } from "react/jsx-runtime";
2
2
  import { useState as I, useMemo as C } from "react";
3
- import { styled as k, Box as p, Typography as y, IconButton as D, Button as U, useTheme as S, FormControl as B, TextField as F } from "@mui/material";
3
+ import { Box as p, Typography as y, IconButton as k, Button as D, useTheme as U, styled as S, FormControl as B, TextField as F } from "@mui/material";
4
4
  import { Remove as T, Add as _ } from "@mui/icons-material";
5
5
  import { translate as z } from "@arcblock/ux/lib/Locale/util";
6
6
  import { useMemoizedFn as E } from "ahooks";
@@ -83,14 +83,14 @@ function q({ links: t = [], onChange: s }) {
83
83
  },
84
84
  children: [
85
85
  /* @__PURE__ */ e($, { value: o, onChange: (c) => b(n, c), errorMsg: a }),
86
- /* @__PURE__ */ e(D, { onClick: () => L(n), children: /* @__PURE__ */ e(T, { sx: { color: "text.secondary" } }) })
86
+ /* @__PURE__ */ e(k, { onClick: () => L(n), children: /* @__PURE__ */ e(T, { sx: { color: "text.secondary" } }) })
87
87
  ]
88
88
  },
89
89
  n
90
90
  );
91
91
  }),
92
92
  t.length < g ? /* @__PURE__ */ f(
93
- U,
93
+ D,
94
94
  {
95
95
  fullWidth: !0,
96
96
  variant: "outlined",
@@ -122,7 +122,7 @@ function q({ links: t = [], onChange: s }) {
122
122
  );
123
123
  }
124
124
  function G({ link: t }) {
125
- const l = S().palette.mode === "dark";
125
+ const l = U().palette.mode === "dark";
126
126
  if (!t)
127
127
  return null;
128
128
  const { icon: r, options: i } = W(t) || {};
@@ -174,7 +174,7 @@ function ut({
174
174
  }
175
175
  );
176
176
  }
177
- const H = k("span")`
177
+ const H = S("span")`
178
178
  flex: 1;
179
179
  white-space: nowrap;
180
180
  overflow: hidden;
@@ -1,7 +1,7 @@
1
1
  import { jsxs as y, Fragment as B, jsx as t } from "react/jsx-runtime";
2
- import { memo as te, createElement as re, useState as R, useRef as ie, useEffect as ae, useMemo as D } from "react";
2
+ import { useState as R, useRef as te, useEffect as re, useMemo as D, memo as ie, createElement as ae } from "react";
3
3
  import { Icon as le } from "@iconify/react";
4
- import { Backdrop as de, Box as m, useMediaQuery as ce, SwipeableDrawer as pe, Typography as L, Tooltip as se } from "@mui/material";
4
+ import { useMediaQuery as de, SwipeableDrawer as ce, Box as m, Typography as L, Tooltip as se, Backdrop as pe } from "@mui/material";
5
5
  import me from "@emotion/styled";
6
6
  import N from "@arcblock/ux/lib/Button";
7
7
  import F, { detectCountryFromPhone as T, getCountryNameByCountry as ue, validatePhoneNumber as he, getDialCodeByCountry as fe } from "@arcblock/ux/lib/PhoneInput";
@@ -29,12 +29,12 @@ import Se from "./address.js";
29
29
  const E = {
30
30
  width: 20,
31
31
  height: 20
32
- }, H = 200, Q = te(function({
32
+ }, H = 200, Q = ie(function({
33
33
  ref: r,
34
34
  ...I
35
35
  }) {
36
- return /* @__PURE__ */ re(
37
- de,
36
+ return /* @__PURE__ */ ae(
37
+ pe,
38
38
  {
39
39
  ref: r,
40
40
  component: "div",
@@ -50,12 +50,12 @@ const E = {
50
50
  });
51
51
  Q.displayName = "BackdropWrap";
52
52
  function mo({
53
- isMyself: p,
53
+ isMyself: s,
54
54
  user: r,
55
55
  onSave: I,
56
56
  isMobile: x
57
57
  }) {
58
- const [U, P] = R(!1), [Y, C] = R(!1), _ = ie(null), q = we(), b = ce("(max-width:640px)") || q.mobile.any, c = w({
58
+ const [U, P] = R(!1), [Y, C] = R(!1), _ = te(null), q = we(), b = de("(max-width:640px)") || q.mobile.any, c = w({
59
59
  email: "",
60
60
  phone: ""
61
61
  }), u = w({
@@ -66,7 +66,7 @@ function mo({
66
66
  line2: "",
67
67
  postalCode: ""
68
68
  });
69
- ae(() => {
69
+ re(() => {
70
70
  b || C(!1);
71
71
  }, [b]);
72
72
  const j = k(() => r?.phoneVerified ?? !1, [r?.phoneVerified]), A = k(() => r?.emailVerified ?? !1, [r?.emailVerified]), { locale: z } = ve(), d = be((o, n = {}) => ge(Ve, o, z, "en", n)), a = w(
@@ -108,10 +108,10 @@ function mo({
108
108
  country: h,
109
109
  phone: ""
110
110
  };
111
- }, [a.phone, r?.phone, h]), s = (o, n) => {
111
+ }, [a.phone, r?.phone, h]), p = (o, n) => {
112
112
  a[n] = o;
113
113
  }, K = (o, n) => {
114
- l[o] = n, o === "city" && s(n, "location"), o === "postalCode" ? u.postalCode = n && !$(n, "any") ? d("profile.address.invalidPostalCode") : "" : u[o] = "";
114
+ l[o] = n, o === "city" && p(n, "location"), o === "postalCode" ? u.postalCode = n && !$(n, "any") ? d("profile.address.invalidPostalCode") : "" : u[o] = "";
115
115
  }, S = () => {
116
116
  b ? C(!0) : P(!0);
117
117
  }, O = () => {
@@ -147,7 +147,7 @@ function mo({
147
147
  favicon: e
148
148
  };
149
149
  });
150
- s(n, "links");
150
+ p(n, "links");
151
151
  }, ee = () => {
152
152
  if (Object.keys(a).forEach((n) => {
153
153
  const e = n, i = a[e];
@@ -176,7 +176,7 @@ function mo({
176
176
  g,
177
177
  {
178
178
  value: a.bio ?? "",
179
- onChange: (e) => s(e, "bio"),
179
+ onChange: (e) => p(e, "bio"),
180
180
  editable: o,
181
181
  placeholder: "Bio",
182
182
  component: "textarea",
@@ -189,7 +189,7 @@ function mo({
189
189
  }
190
190
  }
191
191
  ),
192
- !o && p ? /* @__PURE__ */ t(
192
+ !o && s ? /* @__PURE__ */ t(
193
193
  N,
194
194
  {
195
195
  size: x ? "small" : "large",
@@ -205,7 +205,7 @@ function mo({
205
205
  children: d("profile.editProfile")
206
206
  }
207
207
  ) : null,
208
- o && p && J ? /* @__PURE__ */ t(
208
+ o && s && J ? /* @__PURE__ */ t(
209
209
  Se,
210
210
  {
211
211
  address: l,
@@ -217,11 +217,11 @@ function mo({
217
217
  g,
218
218
  {
219
219
  value: a.location ?? r?.address?.city ?? "",
220
- onChange: (e) => s(e, "location"),
220
+ onChange: (e) => p(e, "location"),
221
221
  editable: o,
222
222
  placeholder: "Location",
223
223
  label: d("profile.location"),
224
- tooltip: p && (l.line1 || l.line2) ? /* @__PURE__ */ t(B, { children: ["line1", "line2"].map((e) => l[e] ? /* @__PURE__ */ y(m, { children: [
224
+ tooltip: s && (l.line1 || l.line2) ? /* @__PURE__ */ t(B, { children: ["line1", "line2"].map((e) => l[e] ? /* @__PURE__ */ y(m, { children: [
225
225
  /* @__PURE__ */ t(
226
226
  L,
227
227
  {
@@ -247,7 +247,7 @@ function mo({
247
247
  g,
248
248
  {
249
249
  value: a.timezone || "",
250
- onChange: (e) => s(e, "timezone"),
250
+ onChange: (e) => p(e, "timezone"),
251
251
  editable: o,
252
252
  placeholder: "timezone",
253
253
  icon: /* @__PURE__ */ t(Pe, { ...E }),
@@ -257,7 +257,7 @@ function mo({
257
257
  Ae,
258
258
  {
259
259
  value: a.timezone ?? "",
260
- onChange: (e) => s(e, "timezone"),
260
+ onChange: (e) => p(e, "timezone"),
261
261
  disabled: !o,
262
262
  mode: n
263
263
  }
@@ -269,7 +269,7 @@ function mo({
269
269
  {
270
270
  value: a.email ?? r?.email ?? "",
271
271
  editable: o,
272
- hidePreview: !p,
272
+ hidePreview: !s,
273
273
  disabled: r?.sourceProvider === M.EMAIL,
274
274
  canEdit: !A,
275
275
  verified: A,
@@ -289,9 +289,9 @@ function mo({
289
289
  }
290
290
  ) }) : null
291
291
  ] }),
292
- onChange: (e) => s(e, "email"),
292
+ onChange: (e) => p(e, "email"),
293
293
  errorMsg: c.email,
294
- renderValue: (e) => p ? /* @__PURE__ */ t(
294
+ renderValue: (e) => s ? /* @__PURE__ */ t(
295
295
  "a",
296
296
  {
297
297
  href: `mailto:${e}`,
@@ -313,29 +313,31 @@ function mo({
313
313
  {
314
314
  value: V.phone,
315
315
  editable: o,
316
- hidePreview: !p,
316
+ hidePreview: !s,
317
317
  canEdit: !j,
318
318
  verified: j,
319
319
  placeholder: "Phone",
320
320
  icon: /* @__PURE__ */ t(Ie, { ...E }),
321
- onChange: (e) => s(e, "phone"),
321
+ onChange: (e) => p(e, "phone"),
322
322
  label: d("profile.phone"),
323
- renderValue: () => p ? /* @__PURE__ */ t(F, { value: V, preview: !0 }) : null,
323
+ renderValue: () => s ? /* @__PURE__ */ t(F, { value: V, preview: !0 }) : null,
324
324
  children: /* @__PURE__ */ t(
325
325
  F,
326
326
  {
327
327
  variant: "outlined",
328
328
  className: "editable-field",
329
- InputProps: {
330
- sx: { backgroundColor: "transparent" },
331
- placeholder: "Phone"
329
+ slotProps: {
330
+ input: {
331
+ sx: { backgroundColor: "transparent" },
332
+ placeholder: "Phone"
333
+ }
332
334
  },
333
335
  value: V,
334
336
  error: !!c.phone,
335
337
  helperText: c.phone,
336
338
  sx: xe(Be, c.phone ? {} : Le),
337
339
  onChange: (e) => {
338
- he(e.phone, e.country) ? c.phone = "" : c.phone = d("profile.phoneInvalid"), s(
340
+ he(e.phone, e.country) ? c.phone = "" : c.phone = d("profile.phoneInvalid"), p(
339
341
  {
340
342
  country: e.country,
341
343
  phoneNumber: e.phone
@@ -348,7 +350,7 @@ function mo({
348
350
  }
349
351
  ),
350
352
  /* @__PURE__ */ t(Ne, { editable: o, links: X, onChange: Z }),
351
- o && p ? /* @__PURE__ */ y(
353
+ o && s ? /* @__PURE__ */ y(
352
354
  m,
353
355
  {
354
356
  style: { width: "100%" },
@@ -397,7 +399,7 @@ function mo({
397
399
  return /* @__PURE__ */ y(B, { children: [
398
400
  W(U),
399
401
  b && /* @__PURE__ */ y(
400
- pe,
402
+ ce,
401
403
  {
402
404
  sx: {
403
405
  zIndex: 9999
@@ -6,19 +6,19 @@ import { useMemoizedFn as V } from "ahooks";
6
6
  import { translate as Y } from "@arcblock/ux/lib/Locale/util";
7
7
  import { useLocaleContext as $ } from "@arcblock/ux/lib/Locale/context";
8
8
  import q from "lodash/noop";
9
- import { useState as C, useEffect as j } from "react";
9
+ import { lazy as G, useState as C, useEffect as j } from "react";
10
10
  import I from "@arcblock/ux/lib/Toast";
11
- import { parseURL as G, joinURL as H } from "ufo";
12
- import { KeyboardArrowUp as J, KeyboardArrowDown as X } from "@mui/icons-material";
13
- import { getBlockletSDK as Z } from "@blocklet/js-sdk";
14
- import { translations as _ } from "../../libs/locales.js";
11
+ import { parseURL as H, joinURL as J } from "ufo";
12
+ import { KeyboardArrowUp as X, KeyboardArrowDown as Z } from "@mui/icons-material";
13
+ import { getBlockletSDK as _ } from "@blocklet/js-sdk";
14
+ import { translations as P } from "../../libs/locales.js";
15
15
  import { formatAxiosError as R } from "../../libs/utils.js";
16
- import { currentTimezone as P, getStatusDuration as M, isValidUrl as tt, isDuplicateUrl as rt } from "./utils.js";
17
- import et from "./switch-role.js";
18
- import ot from "./metadata.js";
16
+ import { currentTimezone as M, getStatusDuration as tt, isValidUrl as rt, isDuplicateUrl as et } from "./utils.js";
17
+ import ot from "./switch-role.js";
19
18
  import at from "./user-status.js";
20
19
  import nt from "./user-info.js";
21
20
  import it from "./social-actions/index.js";
21
+ const lt = G(() => import("./metadata.js"));
22
22
  function kt({
23
23
  user: t,
24
24
  isMyself: o = !0,
@@ -31,7 +31,7 @@ function kt({
31
31
  isShowSocialActions: D = !1,
32
32
  ...m
33
33
  }) {
34
- const h = Z(), { locale: x } = $(), [g, v] = C(void 0), w = V((i, e = {}) => Y(_, i, x, "en", e)), [d, S] = C(!a || c);
34
+ const h = _(), { locale: x } = $(), [g, v] = C(void 0), w = V((i, e = {}) => Y(P, i, x, "en", e)), [d, S] = C(!a || c);
35
35
  j(() => {
36
36
  v(t?.metadata?.status);
37
37
  }, [t]), j(() => {
@@ -41,7 +41,7 @@ function kt({
41
41
  if (o)
42
42
  try {
43
43
  if (i) {
44
- const e = M(i);
44
+ const e = tt(i);
45
45
  i.dateRange = e.length > 0 ? e : g?.dateRange ?? [];
46
46
  }
47
47
  v(i), await h.user.saveProfile({
@@ -62,10 +62,10 @@ function kt({
62
62
  const { metadata: e, address: E } = i;
63
63
  try {
64
64
  const p = e?.links?.map((n, U) => {
65
- if (!n.url || !tt(n.url) || U > 0 && e.links?.slice(0, U)?.some((K) => rt(K.url, n.url)))
65
+ if (!n.url || !rt(n.url) || U > 0 && e.links?.slice(0, U)?.some((K) => et(K.url, n.url)))
66
66
  return null;
67
67
  try {
68
- return G(n.url).protocol || (n.url = H("https://", n.url)), n;
68
+ return H(n.url).protocol || (n.url = J("https://", n.url)), n;
69
69
  } catch {
70
70
  return console.error("Invalid URL:", n.url), null;
71
71
  }
@@ -146,7 +146,7 @@ function kt({
146
146
  isMobile: a,
147
147
  size: m.size || (a ? 64 : 100),
148
148
  isMyself: o,
149
- timezone: t?.metadata?.timezone || P,
149
+ timezone: t?.metadata?.timezone || M,
150
150
  status: g,
151
151
  onChange: L
152
152
  }
@@ -188,7 +188,7 @@ function kt({
188
188
  children: t?.fullName
189
189
  }
190
190
  ),
191
- o ? /* @__PURE__ */ r(et, { user: t, switchPassport: k }) : null
191
+ o ? /* @__PURE__ */ r(ot, { user: t, switchPassport: k }) : null
192
192
  ]
193
193
  }
194
194
  ),
@@ -211,7 +211,7 @@ function kt({
211
211
  }
212
212
  ),
213
213
  !o && D ? /* @__PURE__ */ r(s, { sx: { mt: 2 }, children: /* @__PURE__ */ r(it, { user: t }) }) : null,
214
- /* @__PURE__ */ r(ot, { isMobile: a, isMyself: o, user: t, onSave: B }),
214
+ /* @__PURE__ */ r(lt, { isMobile: a, isMyself: o, user: t, onSave: B }),
215
215
  o ? /* @__PURE__ */ l(N, { children: [
216
216
  /* @__PURE__ */ r(T, { sx: { my: a ? 1 : 3 } }),
217
217
  a && !c ? /* @__PURE__ */ r(
@@ -234,7 +234,7 @@ function kt({
234
234
  opacity: 0.8
235
235
  }
236
236
  },
237
- children: d ? /* @__PURE__ */ r(J, {}) : /* @__PURE__ */ r(X, {})
237
+ children: d ? /* @__PURE__ */ r(X, {}) : /* @__PURE__ */ r(Z, {})
238
238
  }
239
239
  )
240
240
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/ui-react",
3
- "version": "3.4.5",
3
+ "version": "3.4.7",
4
4
  "description": "Some useful front-end web components that can be used in Blocklets.",
5
5
  "keywords": [
6
6
  "react",
@@ -8,6 +8,7 @@
8
8
  "component",
9
9
  "blocklet"
10
10
  ],
11
+ "sideEffects": false,
11
12
  "author": "wangshijun<wangshijun2010@gmail.com>",
12
13
  "homepage": "https://www.arcblock.io/docs/blocklet-ui-react",
13
14
  "license": "Apache-2.0",
@@ -35,11 +36,11 @@
35
36
  "dependencies": {
36
37
  "@abtnode/constant": "^1.17.7",
37
38
  "@abtnode/util": "^1.17.7",
38
- "@arcblock/bridge": "3.4.5",
39
- "@arcblock/icons": "3.4.5",
40
- "@arcblock/react-hooks": "3.4.5",
41
- "@arcblock/ws": "^1.28.2",
42
- "@blocklet/did-space-react": "^1.2.14",
39
+ "@arcblock/bridge": "3.4.7",
40
+ "@arcblock/icons": "3.4.7",
41
+ "@arcblock/react-hooks": "3.4.7",
42
+ "@arcblock/ws": "^1.28.5",
43
+ "@blocklet/did-space-react": "^1.2.15",
43
44
  "@iconify-icons/logos": "^1.2.36",
44
45
  "@iconify-icons/material-symbols": "^1.2.58",
45
46
  "@iconify-icons/tabler": "^1.2.95",
@@ -82,7 +83,7 @@
82
83
  "access": "public"
83
84
  },
84
85
  "devDependencies": {
85
- "@arcblock/did-connect-react": "3.4.5",
86
+ "@arcblock/did-connect-react": "3.4.7",
86
87
  "@babel/preset-env": "^7.28.0",
87
88
  "@babel/preset-react": "^7.27.1",
88
89
  "@babel/preset-typescript": "^7.27.1",
@@ -96,5 +97,5 @@
96
97
  "typescript": "~5.5.4",
97
98
  "unbuild": "^2.0.0"
98
99
  },
99
- "gitHead": "a944f14b25e2fd8cd0e7e32b3c3ce276961e6b64"
100
+ "gitHead": "eb0fca0015ba4ee80affb3b03d47505c45f8ec1c"
100
101
  }
@@ -497,9 +497,11 @@ export default function UserMetadataComponent({
497
497
  <PhoneInput
498
498
  variant="outlined"
499
499
  className="editable-field"
500
- InputProps={{
501
- sx: { backgroundColor: 'transparent' },
502
- placeholder: 'Phone',
500
+ slotProps={{
501
+ input: {
502
+ sx: { backgroundColor: 'transparent' },
503
+ placeholder: 'Phone',
504
+ },
503
505
  }}
504
506
  value={phoneValue}
505
507
  error={!!validateMsg.phone}
@@ -6,7 +6,7 @@ import { useMemoizedFn } from 'ahooks';
6
6
  import { translate } from '@arcblock/ux/lib/Locale/util';
7
7
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
8
8
  import noop from 'lodash/noop';
9
- import { useEffect, useState } from 'react';
9
+ import { lazy, useEffect, useState } from 'react';
10
10
  import Toast from '@arcblock/ux/lib/Toast';
11
11
  import type { AxiosError } from 'axios';
12
12
  import { parseURL, joinURL } from 'ufo';
@@ -21,11 +21,13 @@ import type { User, UserAddress, UserMetadata } from '../../../@types';
21
21
  import { formatAxiosError } from '../../libs/utils';
22
22
  import { currentTimezone, getStatusDuration, isValidUrl, isDuplicateUrl } from './utils';
23
23
  import SwitchRole from './switch-role';
24
- import UserMetadataComponent from './metadata';
24
+
25
25
  import UserStatus from './user-status';
26
26
  import UserInfo from './user-info';
27
27
  import SocialActions from './social-actions';
28
28
 
29
+ const UserMetadataComponent = lazy(() => import('./metadata'));
30
+
29
31
  export default function UserBasicInfo({
30
32
  user,
31
33
  isMyself = true,