@blocklet/ui-react 2.12.31 → 2.12.32

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.
@@ -100,15 +100,18 @@ export default function UserMetadataComponent({
100
100
  }
101
101
  }
102
102
  );
103
- const address = useCreation(() => {
104
- return user?.address || {
103
+ const address = useReactive(
104
+ user?.address ? cloneDeep(user.address) : {
105
105
  country: "",
106
106
  province: "",
107
107
  city: "",
108
108
  detailedAddress: "",
109
109
  postalCode: ""
110
- };
111
- }, [user?.address]);
110
+ }
111
+ );
112
+ const isSupportAddress = useCreation(() => {
113
+ return !!user?.address;
114
+ }, [user?.address?.country]);
112
115
  const defaultCountry = useMemo(() => {
113
116
  if (user?.address?.country) {
114
117
  return user.address.country;
@@ -277,7 +280,7 @@ export default function UserMetadataComponent({
277
280
  children: t("profile.editProfile")
278
281
  }
279
282
  ) : null,
280
- editing && isMyself ? /* @__PURE__ */ jsx(
283
+ editing && isMyself && isSupportAddress ? /* @__PURE__ */ jsx(
281
284
  AddressEditor,
282
285
  {
283
286
  address,
@@ -321,7 +324,8 @@ export default function UserMetadataComponent({
321
324
  {
322
325
  value: metadata.timezone || currentTimezone,
323
326
  onChange: (value) => onChange(value, "timezone"),
324
- disabled: !editing
327
+ disabled: !editing,
328
+ mode
325
329
  }
326
330
  )
327
331
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/ui-react",
3
- "version": "2.12.31",
3
+ "version": "2.12.32",
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.31",
37
- "@arcblock/react-hooks": "^2.12.31",
36
+ "@arcblock/bridge": "^2.12.32",
37
+ "@arcblock/react-hooks": "^2.12.32",
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": "4cbd86dc8a13177c124a939f6dd2739a484bdd21"
90
+ "gitHead": "d968d5785a045b629da9d13864687d9abcb0461b"
91
91
  }
@@ -122,17 +122,22 @@ export default function UserMetadataComponent({
122
122
  }
123
123
  );
124
124
 
125
- const address = useCreation(() => {
126
- return (
127
- user?.address || {
128
- country: '',
129
- province: '',
130
- city: '',
131
- detailedAddress: '',
132
- postalCode: '',
133
- }
134
- );
135
- }, [user?.address]);
125
+ const address: UserAddress = useReactive(
126
+ user?.address
127
+ ? cloneDeep(user.address)
128
+ : {
129
+ country: '',
130
+ province: '',
131
+ city: '',
132
+ detailedAddress: '',
133
+ postalCode: '',
134
+ }
135
+ );
136
+
137
+ // 判断是否支持地址, 如果已经支持则返回 {}, 否则返回为 undefined
138
+ const isSupportAddress = useCreation(() => {
139
+ return !!user?.address;
140
+ }, [user?.address?.country]);
136
141
 
137
142
  /**
138
143
  * 获取默认的国家
@@ -327,7 +332,7 @@ export default function UserMetadataComponent({
327
332
  </Button>
328
333
  ) : null}
329
334
 
330
- {editing && isMyself ? (
335
+ {editing && isMyself && isSupportAddress ? (
331
336
  <AddressEditor
332
337
  address={address}
333
338
  errors={addressValidateMsg}
@@ -377,6 +382,7 @@ export default function UserMetadataComponent({
377
382
  value={metadata.timezone || currentTimezone}
378
383
  onChange={(value) => onChange(value, 'timezone')}
379
384
  disabled={!editing}
385
+ mode={mode}
380
386
  />
381
387
  </EditableField>
382
388