@blocklet/ui-react 2.12.35 → 2.12.37
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 +1 -1
- package/lib/UserCenter/components/user-info/address.js +0 -1
- package/lib/UserCenter/components/user-info/metadata.js +19 -4
- package/package.json +4 -4
- package/src/@types/index.ts +1 -1
- package/src/UserCenter/components/user-info/address.tsx +1 -2
- package/src/UserCenter/components/user-info/metadata.tsx +23 -4
package/lib/@types/index.d.ts
CHANGED
|
@@ -8,7 +8,11 @@ import Backdrop from "@mui/material/Backdrop";
|
|
|
8
8
|
import styled from "@emotion/styled";
|
|
9
9
|
import { joinURL } from "ufo";
|
|
10
10
|
import Button from "@arcblock/ux/lib/Button";
|
|
11
|
-
import PhoneInput, {
|
|
11
|
+
import PhoneInput, {
|
|
12
|
+
validatePhoneNumber,
|
|
13
|
+
getDialCodeByCountry,
|
|
14
|
+
getCountryNameByCountry
|
|
15
|
+
} from "@arcblock/ux/lib/PhoneInput";
|
|
12
16
|
import cloneDeep from "lodash/cloneDeep";
|
|
13
17
|
import omit from "lodash/omit";
|
|
14
18
|
import { mergeSx } from "@arcblock/ux/lib/Util/style";
|
|
@@ -119,7 +123,7 @@ export default function UserMetadataComponent({
|
|
|
119
123
|
if (user?.address?.country) {
|
|
120
124
|
return user.address.country;
|
|
121
125
|
}
|
|
122
|
-
return locale === "zh" ? "
|
|
126
|
+
return locale === "zh" ? "cn" : "us";
|
|
123
127
|
}, [user?.address?.country, locale]);
|
|
124
128
|
const phoneValue = useCreation(() => {
|
|
125
129
|
const phone = metadata.phone ?? user?.phone ?? {
|
|
@@ -135,7 +139,7 @@ export default function UserMetadataComponent({
|
|
|
135
139
|
if (typeof phone === "object") {
|
|
136
140
|
return {
|
|
137
141
|
country: phone.country,
|
|
138
|
-
phone: phone.phoneNumber
|
|
142
|
+
phone: phone.phoneNumber || ""
|
|
139
143
|
};
|
|
140
144
|
}
|
|
141
145
|
return {
|
|
@@ -228,6 +232,16 @@ export default function UserMetadataComponent({
|
|
|
228
232
|
if (k === "timezone") {
|
|
229
233
|
metadata[k] = value || currentTimezone;
|
|
230
234
|
}
|
|
235
|
+
if (k === "phone" && value && typeof value === "object") {
|
|
236
|
+
const phoneInput = value;
|
|
237
|
+
const dialCode = getDialCodeByCountry(phoneInput.country);
|
|
238
|
+
const phoneWithoutCode = phoneInput.phoneNumber?.replace(new RegExp(`^\\+${dialCode}`), "") || "";
|
|
239
|
+
const hasActualPhoneNumber = phoneWithoutCode?.trim().length > 0;
|
|
240
|
+
metadata[k] = {
|
|
241
|
+
country: phoneInput.country,
|
|
242
|
+
...hasActualPhoneNumber ? { phoneNumber: phoneInput.phoneNumber } : {}
|
|
243
|
+
};
|
|
244
|
+
}
|
|
231
245
|
});
|
|
232
246
|
if (address.postalCode && !isPostalCode(address.postalCode, "any")) {
|
|
233
247
|
addressValidateMsg.postalCode = t("profile.address.invalidPostalCode");
|
|
@@ -311,7 +325,8 @@ export default function UserMetadataComponent({
|
|
|
311
325
|
] }, k);
|
|
312
326
|
}) }) : null,
|
|
313
327
|
renderValue: () => {
|
|
314
|
-
const
|
|
328
|
+
const countryName = address?.country ? getCountryNameByCountry(address?.country) : "";
|
|
329
|
+
const fullLocation = [countryName, address.province, address.city || metadata.location || ""].filter(Boolean).join(" ");
|
|
315
330
|
return /* @__PURE__ */ jsx(Typography, { component: "span", children: fullLocation });
|
|
316
331
|
},
|
|
317
332
|
icon: /* @__PURE__ */ jsx(LocationIcon, { ...iconSize })
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/ui-react",
|
|
3
|
-
"version": "2.12.
|
|
3
|
+
"version": "2.12.37",
|
|
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.37",
|
|
37
|
+
"@arcblock/react-hooks": "^2.12.37",
|
|
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": "aa13701db7bd60b6b929a039b5701ca69208545b"
|
|
91
91
|
}
|
package/src/@types/index.ts
CHANGED
|
@@ -65,8 +65,7 @@ export default function AddressEditor({
|
|
|
65
65
|
editable
|
|
66
66
|
errorMsg={errors.country}
|
|
67
67
|
label={t('profile.address.country')}>
|
|
68
|
-
<CountrySelect
|
|
69
|
-
valueField="name"
|
|
68
|
+
<CountrySelect
|
|
70
69
|
value={address.country || defaultCountry}
|
|
71
70
|
onChange={(v) => handleChange('country', v)}
|
|
72
71
|
displayEmpty
|
|
@@ -9,7 +9,12 @@ import Backdrop, { BackdropProps } from '@mui/material/Backdrop';
|
|
|
9
9
|
import styled from '@emotion/styled';
|
|
10
10
|
import { joinURL } from 'ufo';
|
|
11
11
|
import Button from '@arcblock/ux/lib/Button';
|
|
12
|
-
import PhoneInput, {
|
|
12
|
+
import PhoneInput, {
|
|
13
|
+
PhoneValue,
|
|
14
|
+
validatePhoneNumber,
|
|
15
|
+
getDialCodeByCountry,
|
|
16
|
+
getCountryNameByCountry,
|
|
17
|
+
} from '@arcblock/ux/lib/PhoneInput';
|
|
13
18
|
import cloneDeep from 'lodash/cloneDeep';
|
|
14
19
|
import omit from 'lodash/omit';
|
|
15
20
|
import { mergeSx } from '@arcblock/ux/lib/Util/style';
|
|
@@ -152,7 +157,7 @@ export default function UserMetadataComponent({
|
|
|
152
157
|
return user.address.country;
|
|
153
158
|
}
|
|
154
159
|
|
|
155
|
-
return locale === 'zh' ? '
|
|
160
|
+
return locale === 'zh' ? 'cn' : 'us';
|
|
156
161
|
}, [user?.address?.country, locale]);
|
|
157
162
|
|
|
158
163
|
const phoneValue = useCreation((): PhoneValue => {
|
|
@@ -171,7 +176,7 @@ export default function UserMetadataComponent({
|
|
|
171
176
|
if (typeof phone === 'object') {
|
|
172
177
|
return {
|
|
173
178
|
country: phone.country,
|
|
174
|
-
phone: (phone as UserPhoneProps).phoneNumber,
|
|
179
|
+
phone: (phone as UserPhoneProps).phoneNumber || '',
|
|
175
180
|
};
|
|
176
181
|
}
|
|
177
182
|
|
|
@@ -279,6 +284,19 @@ export default function UserMetadataComponent({
|
|
|
279
284
|
if (k === 'timezone') {
|
|
280
285
|
metadata[k] = (value as string) || currentTimezone;
|
|
281
286
|
}
|
|
287
|
+
if (k === 'phone' && value && typeof value === 'object') {
|
|
288
|
+
const phoneInput = value as UserPhoneProps;
|
|
289
|
+
const dialCode = getDialCodeByCountry(phoneInput.country);
|
|
290
|
+
// 去除电话号码中的区号部分
|
|
291
|
+
const phoneWithoutCode = phoneInput.phoneNumber?.replace(new RegExp(`^\\+${dialCode}`), '') || '';
|
|
292
|
+
|
|
293
|
+
const hasActualPhoneNumber = phoneWithoutCode?.trim().length > 0;
|
|
294
|
+
|
|
295
|
+
metadata[k] = {
|
|
296
|
+
country: phoneInput.country,
|
|
297
|
+
...(hasActualPhoneNumber ? { phoneNumber: phoneInput.phoneNumber } : {}),
|
|
298
|
+
};
|
|
299
|
+
}
|
|
282
300
|
});
|
|
283
301
|
|
|
284
302
|
// 单独处理邮政编码验证,避免嵌套三元表达式
|
|
@@ -375,7 +393,8 @@ export default function UserMetadataComponent({
|
|
|
375
393
|
) : null
|
|
376
394
|
}
|
|
377
395
|
renderValue={() => {
|
|
378
|
-
const
|
|
396
|
+
const countryName = address?.country ? getCountryNameByCountry(address?.country) : '';
|
|
397
|
+
const fullLocation = [countryName, address.province, address.city || metadata.location || '']
|
|
379
398
|
.filter(Boolean)
|
|
380
399
|
.join(' ');
|
|
381
400
|
return <Typography component="span">{fullLocation}</Typography>;
|