@blocklet/ui-react 2.12.32 → 2.12.34
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.
- package/lib/@types/index.d.ts +2 -1
- package/lib/UserCenter/components/nft.js +2 -1
- package/lib/UserCenter/components/user-info/address.d.ts +2 -1
- package/lib/UserCenter/components/user-info/address.js +19 -6
- package/lib/UserCenter/components/user-info/metadata.js +17 -7
- package/lib/UserCenter/libs/locales.d.ts +4 -0
- package/lib/UserCenter/libs/locales.js +4 -0
- package/package.json +4 -4
- package/src/@types/index.ts +2 -1
- package/src/UserCenter/components/nft.tsx +7 -1
- package/src/UserCenter/components/user-info/address.tsx +19 -7
- package/src/UserCenter/components/user-info/metadata.tsx +27 -11
- package/src/UserCenter/libs/locales.ts +4 -0
package/lib/@types/index.d.ts
CHANGED
|
@@ -41,9 +41,10 @@ export default function Nft({ user }) {
|
|
|
41
41
|
};
|
|
42
42
|
const content = useCreation(() => {
|
|
43
43
|
if (loading) {
|
|
44
|
+
const skeletonItems = ["skeleton-1", "skeleton-2", "skeleton-3", "skeleton-4", "skeleton-5"].map((id) => /* @__PURE__ */ jsx(Skeleton, { variant: "rectangular", width: "15%", height: 166, sx: { borderRadius: 2, flexShrink: 0 } }, id));
|
|
44
45
|
return /* @__PURE__ */ jsxs(Box, { display: "flex", flexDirection: "column", gap: 2, children: [
|
|
45
46
|
/* @__PURE__ */ jsx(Skeleton, { width: "20%" }),
|
|
46
|
-
/* @__PURE__ */ jsx(
|
|
47
|
+
/* @__PURE__ */ jsx(Box, { display: "flex", flexDirection: "row", gap: 2, flexWrap: "nowrap", children: skeletonItems })
|
|
47
48
|
] });
|
|
48
49
|
}
|
|
49
50
|
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
@@ -3,7 +3,8 @@ interface AddressErrors {
|
|
|
3
3
|
country?: string;
|
|
4
4
|
province?: string;
|
|
5
5
|
city?: string;
|
|
6
|
-
|
|
6
|
+
line1?: string;
|
|
7
|
+
line2?: string;
|
|
7
8
|
postalCode?: string;
|
|
8
9
|
}
|
|
9
10
|
export default function AddressEditor({ address, errors, handleChange, defaultCountry, }: {
|
|
@@ -89,14 +89,27 @@ export default function AddressEditor({
|
|
|
89
89
|
/* @__PURE__ */ jsx(
|
|
90
90
|
EditableField,
|
|
91
91
|
{
|
|
92
|
-
value: address.
|
|
93
|
-
onChange: (value) => handleChange("
|
|
94
|
-
placeholder: t("profile.address.
|
|
95
|
-
label: t("profile.address.
|
|
92
|
+
value: address.line1 || "",
|
|
93
|
+
onChange: (value) => handleChange("line1", value),
|
|
94
|
+
placeholder: t("profile.address.line1"),
|
|
95
|
+
label: t("profile.address.line1"),
|
|
96
96
|
component: "textarea",
|
|
97
97
|
editable: true,
|
|
98
|
-
rows:
|
|
99
|
-
errorMsg: errors.
|
|
98
|
+
rows: 2,
|
|
99
|
+
errorMsg: errors.line1
|
|
100
|
+
}
|
|
101
|
+
),
|
|
102
|
+
/* @__PURE__ */ jsx(
|
|
103
|
+
EditableField,
|
|
104
|
+
{
|
|
105
|
+
value: address.line2 || "",
|
|
106
|
+
onChange: (value) => handleChange("line2", value),
|
|
107
|
+
placeholder: t("profile.address.line2"),
|
|
108
|
+
label: t("profile.address.line2"),
|
|
109
|
+
component: "textarea",
|
|
110
|
+
editable: true,
|
|
111
|
+
rows: 2,
|
|
112
|
+
errorMsg: errors.line2
|
|
100
113
|
}
|
|
101
114
|
),
|
|
102
115
|
/* @__PURE__ */ jsx(
|
|
@@ -10,6 +10,7 @@ import { joinURL } from "ufo";
|
|
|
10
10
|
import Button from "@arcblock/ux/lib/Button";
|
|
11
11
|
import PhoneInput, { validatePhoneNumber } from "@arcblock/ux/lib/PhoneInput";
|
|
12
12
|
import cloneDeep from "lodash/cloneDeep";
|
|
13
|
+
import omit from "lodash/omit";
|
|
13
14
|
import { mergeSx } from "@arcblock/ux/lib/Util/style";
|
|
14
15
|
import { useCreation, useMemoizedFn, useReactive } from "ahooks";
|
|
15
16
|
import { useMemo, useRef, useState, memo, forwardRef, useEffect, lazy } from "react";
|
|
@@ -72,7 +73,8 @@ export default function UserMetadataComponent({
|
|
|
72
73
|
country: "",
|
|
73
74
|
province: "",
|
|
74
75
|
city: "",
|
|
75
|
-
|
|
76
|
+
line1: "",
|
|
77
|
+
line2: "",
|
|
76
78
|
postalCode: ""
|
|
77
79
|
});
|
|
78
80
|
useEffect(() => {
|
|
@@ -105,7 +107,8 @@ export default function UserMetadataComponent({
|
|
|
105
107
|
country: "",
|
|
106
108
|
province: "",
|
|
107
109
|
city: "",
|
|
108
|
-
|
|
110
|
+
line1: "",
|
|
111
|
+
line2: "",
|
|
109
112
|
postalCode: ""
|
|
110
113
|
}
|
|
111
114
|
);
|
|
@@ -232,7 +235,8 @@ export default function UserMetadataComponent({
|
|
|
232
235
|
if ([validateMsg, addressValidateMsg].some((o) => Object.values(o).some((e) => e))) {
|
|
233
236
|
return;
|
|
234
237
|
}
|
|
235
|
-
|
|
238
|
+
const newAddress = omit(address, "detailedAddress");
|
|
239
|
+
onSave({ metadata, address: newAddress });
|
|
236
240
|
setEditable(false);
|
|
237
241
|
setVisible(false);
|
|
238
242
|
};
|
|
@@ -296,10 +300,16 @@ export default function UserMetadataComponent({
|
|
|
296
300
|
editable: editing,
|
|
297
301
|
placeholder: "Location",
|
|
298
302
|
label: t("profile.location"),
|
|
299
|
-
tooltip: isMyself ? /* @__PURE__ */
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
+
tooltip: isMyself ? /* @__PURE__ */ jsx(Fragment, { children: ["line1", "line2"].map((k) => {
|
|
304
|
+
const value = address[k];
|
|
305
|
+
if (!value) {
|
|
306
|
+
return null;
|
|
307
|
+
}
|
|
308
|
+
return /* @__PURE__ */ jsxs(Box, { children: [
|
|
309
|
+
/* @__PURE__ */ jsx(Typography, { variant: "caption", component: "p", fontWeight: 600, sx: { mb: 0 }, children: t(`profile.address.${k}`) }),
|
|
310
|
+
/* @__PURE__ */ jsx(Typography, { variant: "caption", component: "span", children: address[k] })
|
|
311
|
+
] }, k);
|
|
312
|
+
}) }) : null,
|
|
303
313
|
renderValue: () => {
|
|
304
314
|
const fullLocation = [address.country, address.province, address.city || metadata.location || ""].filter(Boolean).join(" ");
|
|
305
315
|
return /* @__PURE__ */ jsx(Typography, { component: "span", children: fullLocation });
|
|
@@ -144,6 +144,8 @@ export declare const translations: {
|
|
|
144
144
|
country: string;
|
|
145
145
|
province: string;
|
|
146
146
|
city: string;
|
|
147
|
+
line1: string;
|
|
148
|
+
line2: string;
|
|
147
149
|
detailedAddress: string;
|
|
148
150
|
postalCode: string;
|
|
149
151
|
invalidPostalCode: string;
|
|
@@ -296,6 +298,8 @@ export declare const translations: {
|
|
|
296
298
|
country: string;
|
|
297
299
|
province: string;
|
|
298
300
|
city: string;
|
|
301
|
+
line1: string;
|
|
302
|
+
line2: string;
|
|
299
303
|
detailedAddress: string;
|
|
300
304
|
postalCode: string;
|
|
301
305
|
invalidPostalCode: string;
|
|
@@ -144,6 +144,8 @@ export const translations = {
|
|
|
144
144
|
country: "\u56FD\u5BB6/\u5730\u533A",
|
|
145
145
|
province: "\u5DDE/\u7701",
|
|
146
146
|
city: "\u57CE\u5E02/\u9547",
|
|
147
|
+
line1: "\u5730\u5740",
|
|
148
|
+
line2: "\u5730\u57402",
|
|
147
149
|
detailedAddress: "\u8BE6\u7EC6\u5730\u5740",
|
|
148
150
|
postalCode: "\u90AE\u653F\u7F16\u7801",
|
|
149
151
|
invalidPostalCode: "\u90AE\u653F\u7F16\u7801\u683C\u5F0F\u4E0D\u6B63\u786E"
|
|
@@ -296,6 +298,8 @@ export const translations = {
|
|
|
296
298
|
country: "Country/Region",
|
|
297
299
|
province: "State/Province",
|
|
298
300
|
city: "City/Town",
|
|
301
|
+
line1: "Address",
|
|
302
|
+
line2: "Address 2",
|
|
299
303
|
detailedAddress: "Detailed Address",
|
|
300
304
|
postalCode: "Postal Code",
|
|
301
305
|
invalidPostalCode: "Postal code is invalid"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/ui-react",
|
|
3
|
-
"version": "2.12.
|
|
3
|
+
"version": "2.12.34",
|
|
4
4
|
"description": "Some useful front-end web components that can be used in Blocklets.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"react",
|
|
@@ -33,8 +33,8 @@
|
|
|
33
33
|
},
|
|
34
34
|
"dependencies": {
|
|
35
35
|
"@abtnode/constant": "^1.16.40",
|
|
36
|
-
"@arcblock/bridge": "^2.12.
|
|
37
|
-
"@arcblock/react-hooks": "^2.12.
|
|
36
|
+
"@arcblock/bridge": "^2.12.34",
|
|
37
|
+
"@arcblock/react-hooks": "^2.12.34",
|
|
38
38
|
"@arcblock/ws": "^1.19.15",
|
|
39
39
|
"@blocklet/did-space-react": "^1.0.35",
|
|
40
40
|
"@iconify-icons/logos": "^1.2.36",
|
|
@@ -87,5 +87,5 @@
|
|
|
87
87
|
"jest": "^29.7.0",
|
|
88
88
|
"unbuild": "^2.0.0"
|
|
89
89
|
},
|
|
90
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "6a16f801fc0fcbbe88888c5854023c647e0012d9"
|
|
91
91
|
}
|
package/src/@types/index.ts
CHANGED
|
@@ -64,10 +64,16 @@ export default function Nft({ user }: { user: User }) {
|
|
|
64
64
|
|
|
65
65
|
const content = useCreation(() => {
|
|
66
66
|
if (loading) {
|
|
67
|
+
const skeletonItems = ['skeleton-1', 'skeleton-2', 'skeleton-3', 'skeleton-4', 'skeleton-5'].map((id) => (
|
|
68
|
+
<Skeleton key={id} variant="rectangular" width="15%" height={166} sx={{ borderRadius: 2, flexShrink: 0 }} />
|
|
69
|
+
));
|
|
70
|
+
|
|
67
71
|
return (
|
|
68
72
|
<Box display="flex" flexDirection="column" gap={2}>
|
|
69
73
|
<Skeleton width="20%" />
|
|
70
|
-
<
|
|
74
|
+
<Box display="flex" flexDirection="row" gap={2} flexWrap="nowrap">
|
|
75
|
+
{skeletonItems}
|
|
76
|
+
</Box>
|
|
71
77
|
</Box>
|
|
72
78
|
);
|
|
73
79
|
}
|
|
@@ -36,7 +36,8 @@ interface AddressErrors {
|
|
|
36
36
|
country?: string;
|
|
37
37
|
province?: string;
|
|
38
38
|
city?: string;
|
|
39
|
-
|
|
39
|
+
line1?: string;
|
|
40
|
+
line2?: string;
|
|
40
41
|
postalCode?: string;
|
|
41
42
|
}
|
|
42
43
|
|
|
@@ -98,14 +99,25 @@ export default function AddressEditor({
|
|
|
98
99
|
</Box>
|
|
99
100
|
|
|
100
101
|
<EditableField
|
|
101
|
-
value={address.
|
|
102
|
-
onChange={(value) => handleChange('
|
|
103
|
-
placeholder={t('profile.address.
|
|
104
|
-
label={t('profile.address.
|
|
102
|
+
value={address.line1 || ''}
|
|
103
|
+
onChange={(value) => handleChange('line1', value)}
|
|
104
|
+
placeholder={t('profile.address.line1')}
|
|
105
|
+
label={t('profile.address.line1')}
|
|
105
106
|
component="textarea"
|
|
106
107
|
editable
|
|
107
|
-
rows={
|
|
108
|
-
errorMsg={errors.
|
|
108
|
+
rows={2}
|
|
109
|
+
errorMsg={errors.line1}
|
|
110
|
+
/>
|
|
111
|
+
|
|
112
|
+
<EditableField
|
|
113
|
+
value={address.line2 || ''}
|
|
114
|
+
onChange={(value) => handleChange('line2', value)}
|
|
115
|
+
placeholder={t('profile.address.line2')}
|
|
116
|
+
label={t('profile.address.line2')}
|
|
117
|
+
component="textarea"
|
|
118
|
+
editable
|
|
119
|
+
rows={2}
|
|
120
|
+
errorMsg={errors.line2}
|
|
109
121
|
/>
|
|
110
122
|
|
|
111
123
|
<EditableField
|
|
@@ -11,6 +11,7 @@ import { joinURL } from 'ufo';
|
|
|
11
11
|
import Button from '@arcblock/ux/lib/Button';
|
|
12
12
|
import PhoneInput, { PhoneValue, validatePhoneNumber } from '@arcblock/ux/lib/PhoneInput';
|
|
13
13
|
import cloneDeep from 'lodash/cloneDeep';
|
|
14
|
+
import omit from 'lodash/omit';
|
|
14
15
|
import { mergeSx } from '@arcblock/ux/lib/Util/style';
|
|
15
16
|
|
|
16
17
|
import { useCreation, useMemoizedFn, useReactive } from 'ahooks';
|
|
@@ -86,7 +87,8 @@ export default function UserMetadataComponent({
|
|
|
86
87
|
country: '',
|
|
87
88
|
province: '',
|
|
88
89
|
city: '',
|
|
89
|
-
|
|
90
|
+
line1: '',
|
|
91
|
+
line2: '',
|
|
90
92
|
postalCode: '',
|
|
91
93
|
});
|
|
92
94
|
|
|
@@ -129,7 +131,8 @@ export default function UserMetadataComponent({
|
|
|
129
131
|
country: '',
|
|
130
132
|
province: '',
|
|
131
133
|
city: '',
|
|
132
|
-
|
|
134
|
+
line1: '',
|
|
135
|
+
line2: '',
|
|
133
136
|
postalCode: '',
|
|
134
137
|
}
|
|
135
138
|
);
|
|
@@ -288,7 +291,10 @@ export default function UserMetadataComponent({
|
|
|
288
291
|
return;
|
|
289
292
|
}
|
|
290
293
|
|
|
291
|
-
|
|
294
|
+
// 兼容代码。移除之前的 detailedAddress 字段
|
|
295
|
+
const newAddress = omit(address, 'detailedAddress');
|
|
296
|
+
|
|
297
|
+
onSave({ metadata, address: newAddress });
|
|
292
298
|
setEditable(false);
|
|
293
299
|
setVisible(false);
|
|
294
300
|
};
|
|
@@ -348,14 +354,24 @@ export default function UserMetadataComponent({
|
|
|
348
354
|
label={t('profile.location')}
|
|
349
355
|
tooltip={
|
|
350
356
|
isMyself ? (
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
357
|
+
<>
|
|
358
|
+
{['line1', 'line2'].map((k) => {
|
|
359
|
+
const value = address[k as keyof UserAddress];
|
|
360
|
+
if (!value) {
|
|
361
|
+
return null;
|
|
362
|
+
}
|
|
363
|
+
return (
|
|
364
|
+
<Box key={k}>
|
|
365
|
+
<Typography variant="caption" component="p" fontWeight={600} sx={{ mb: 0 }}>
|
|
366
|
+
{t(`profile.address.${k}`)}
|
|
367
|
+
</Typography>
|
|
368
|
+
<Typography variant="caption" component="span">
|
|
369
|
+
{address[k as keyof UserAddress]}
|
|
370
|
+
</Typography>
|
|
371
|
+
</Box>
|
|
372
|
+
);
|
|
373
|
+
})}
|
|
374
|
+
</>
|
|
359
375
|
) : null
|
|
360
376
|
}
|
|
361
377
|
renderValue={() => {
|
|
@@ -146,6 +146,8 @@ export const translations = {
|
|
|
146
146
|
country: '国家/地区',
|
|
147
147
|
province: '州/省',
|
|
148
148
|
city: '城市/镇',
|
|
149
|
+
line1: '地址',
|
|
150
|
+
line2: '地址2',
|
|
149
151
|
detailedAddress: '详细地址',
|
|
150
152
|
postalCode: '邮政编码',
|
|
151
153
|
invalidPostalCode: '邮政编码格式不正确',
|
|
@@ -300,6 +302,8 @@ export const translations = {
|
|
|
300
302
|
country: 'Country/Region',
|
|
301
303
|
province: 'State/Province',
|
|
302
304
|
city: 'City/Town',
|
|
305
|
+
line1: 'Address',
|
|
306
|
+
line2: 'Address 2',
|
|
303
307
|
detailedAddress: 'Detailed Address',
|
|
304
308
|
postalCode: 'Postal Code',
|
|
305
309
|
invalidPostalCode: 'Postal code is invalid',
|