@blocklet/ui-react 2.12.49 → 2.12.51

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.
@@ -5,12 +5,13 @@ interface EditableFieldProps {
5
5
  onChange?: (value: string) => void;
6
6
  onValueValidate?: (value: string) => void;
7
7
  editable: boolean;
8
+ disabled?: boolean;
8
9
  component?: 'input' | 'textarea';
9
10
  placeholder?: string;
10
11
  rows?: number;
11
12
  maxLength?: number;
12
13
  icon?: React.ReactNode;
13
- label?: string;
14
+ label?: string | React.ReactNode;
14
15
  children?: React.ReactNode;
15
16
  tooltip?: TooltipProps['title'];
16
17
  inline?: boolean;
@@ -46,5 +47,5 @@ export declare const inputFieldStyle: {
46
47
  borderColor: string;
47
48
  };
48
49
  };
49
- declare function EditableField({ value, onChange, onValueValidate, errorMsg, editable, component, placeholder, rows, maxLength, icon, label, children, tooltip, inline, style, verified, canEdit, renderValue, }: EditableFieldProps): JSX.Element | null;
50
+ declare function EditableField({ value, onChange, onValueValidate, errorMsg, editable, component, placeholder, rows, maxLength, icon, label, children, tooltip, inline, style, verified, canEdit, renderValue, disabled, }: EditableFieldProps): JSX.Element | null;
50
51
  export default EditableField;
@@ -54,7 +54,8 @@ function EditableField({
54
54
  style = {},
55
55
  verified = false,
56
56
  canEdit = true,
57
- renderValue
57
+ renderValue,
58
+ disabled = false
58
59
  }) {
59
60
  const { locale } = useLocaleContext();
60
61
  const t = useMemoizedFn((key, data = {}) => {
@@ -96,7 +97,8 @@ function EditableField({
96
97
  onChange: (e) => handleChange(e.target.value),
97
98
  sx: mergeSx(inputFieldStyle, !errorMsg ? commonInputStyle : {}),
98
99
  error: Boolean(errorMsg),
99
- helperText: errorMsg
100
+ helperText: errorMsg,
101
+ disabled
100
102
  }
101
103
  );
102
104
  }
@@ -115,7 +117,8 @@ function EditableField({
115
117
  value,
116
118
  onChange: (e) => handleChange(e.target.value),
117
119
  error: Boolean(errorMsg),
118
- helperText: errorMsg
120
+ helperText: errorMsg,
121
+ disabled
119
122
  }
120
123
  ),
121
124
  maxLength && maxLength > 0 ? /* @__PURE__ */ jsxs(
@@ -1,10 +1,7 @@
1
1
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
2
2
  import { createElement } from "react";
3
- import Box from "@mui/material/Box";
4
- import useMediaQuery from "@mui/material/useMediaQuery";
5
- import SwipeableDrawer from "@mui/material/SwipeableDrawer";
6
- import Typography from "@mui/material/Typography";
7
- import Backdrop from "@mui/material/Backdrop";
3
+ import { Icon } from "@iconify/react";
4
+ import { Box, Backdrop, useMediaQuery, SwipeableDrawer, Typography, Tooltip } from "@mui/material";
8
5
  import styled from "@emotion/styled";
9
6
  import { joinURL } from "ufo";
10
7
  import Button from "@arcblock/ux/lib/Button";
@@ -17,6 +14,7 @@ import PhoneInput, {
17
14
  import cloneDeep from "lodash/cloneDeep";
18
15
  import omit from "lodash/omit";
19
16
  import { mergeSx } from "@arcblock/ux/lib/Util/style";
17
+ import { LOGIN_PROVIDER } from "@arcblock/ux/lib/Util/constant";
20
18
  import { useCreation, useMemoizedFn, useReactive } from "ahooks";
21
19
  import { useMemo, useRef, useState, memo, forwardRef, useEffect, lazy } from "react";
22
20
  import { translate } from "@arcblock/ux/lib/Locale/util";
@@ -365,11 +363,25 @@ export default function UserMetadataComponent({
365
363
  {
366
364
  value: metadata.email ?? user?.email ?? "",
367
365
  editable: editing,
366
+ disabled: user?.sourceProvider === LOGIN_PROVIDER.EMAIL,
368
367
  canEdit: !emailVerified,
369
368
  verified: emailVerified,
370
369
  placeholder: "Email",
371
370
  icon: /* @__PURE__ */ jsx(EmailIcon, { ...iconSize }),
372
- label: t("profile.email"),
371
+ label: /* @__PURE__ */ jsxs(Fragment, { children: [
372
+ t("profile.email"),
373
+ user?.sourceProvider === LOGIN_PROVIDER.EMAIL ? /* @__PURE__ */ jsx(Tooltip, { title: t("profile.emailSourceProviderNotAllowEdit"), children: /* @__PURE__ */ jsx(
374
+ Box,
375
+ {
376
+ component: Icon,
377
+ icon: "mdi:info-outline",
378
+ sx: {
379
+ verticalAlign: "middle",
380
+ ml: 0.25
381
+ }
382
+ }
383
+ ) }) : null
384
+ ] }),
373
385
  onChange: (value) => onChange(value, "email"),
374
386
  errorMsg: validateMsg.email,
375
387
  renderValue: (value) => /* @__PURE__ */ jsx(
@@ -123,6 +123,7 @@ export declare const translations: {
123
123
  localTime: string;
124
124
  email: string;
125
125
  emailInvalid: string;
126
+ emailSourceProviderNotAllowEdit: string;
126
127
  phone: string;
127
128
  phoneInvalid: string;
128
129
  editProfile: string;
@@ -276,6 +277,7 @@ export declare const translations: {
276
277
  localTime: string;
277
278
  email: string;
278
279
  emailInvalid: string;
280
+ emailSourceProviderNotAllowEdit: string;
279
281
  phone: string;
280
282
  phoneInvalid: string;
281
283
  editProfile: string;
@@ -123,6 +123,7 @@ export const translations = {
123
123
  localTime: "\u5F53\u5730\u65F6\u95F4:",
124
124
  email: "\u90AE\u7BB1\u5730\u5740",
125
125
  emailInvalid: "\u90AE\u7BB1\u683C\u5F0F\u4E0D\u6B63\u786E",
126
+ emailSourceProviderNotAllowEdit: "\u4F7F\u7528\u90AE\u7BB1\u6CE8\u518C\u7684\u7528\u6237\u4E0D\u5141\u8BB8\u4FEE\u6539\u90AE\u7BB1",
126
127
  phone: "\u7535\u8BDD\u53F7\u7801",
127
128
  phoneInvalid: "\u7535\u8BDD\u53F7\u7801\u683C\u5F0F\u4E0D\u6B63\u786E",
128
129
  editProfile: "\u7F16\u8F91\u8D44\u6599",
@@ -276,6 +277,7 @@ export const translations = {
276
277
  localTime: "Local Time: ",
277
278
  email: "Email",
278
279
  emailInvalid: "Email is invalid",
280
+ emailSourceProviderNotAllowEdit: "Email registered users are not allowed to edit email",
279
281
  phone: "Phone",
280
282
  phoneInvalid: "Phone number is invalid",
281
283
  editProfile: "Edit Profile",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/ui-react",
3
- "version": "2.12.49",
3
+ "version": "2.12.51",
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.49",
37
- "@arcblock/react-hooks": "^2.12.49",
36
+ "@arcblock/bridge": "^2.12.51",
37
+ "@arcblock/react-hooks": "^2.12.51",
38
38
  "@arcblock/ws": "^1.19.15",
39
39
  "@blocklet/did-space-react": "^1.0.37",
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": "ffebc9c5df6d576f08c3538b4db75d7ec8cf00be"
90
+ "gitHead": "b122909f88066cb3d5b1cd96f6658d6870ed85e1"
91
91
  }
@@ -13,12 +13,13 @@ interface EditableFieldProps {
13
13
  onChange?: (value: string) => void;
14
14
  onValueValidate?: (value: string) => void;
15
15
  editable: boolean;
16
+ disabled?: boolean;
16
17
  component?: 'input' | 'textarea';
17
18
  placeholder?: string;
18
19
  rows?: number;
19
20
  maxLength?: number; // 最大字符数
20
21
  icon?: React.ReactNode;
21
- label?: string;
22
+ label?: string | React.ReactNode;
22
23
  children?: React.ReactNode;
23
24
  tooltip?: TooltipProps['title'];
24
25
  inline?: boolean;
@@ -76,6 +77,7 @@ function EditableField({
76
77
  verified = false,
77
78
  canEdit = true,
78
79
  renderValue,
80
+ disabled = false,
79
81
  }: EditableFieldProps) {
80
82
  const { locale } = useLocaleContext();
81
83
  const t = useMemoizedFn((key, data = {}) => {
@@ -128,6 +130,7 @@ function EditableField({
128
130
  sx={mergeSx(inputFieldStyle, !errorMsg ? commonInputStyle : {})}
129
131
  error={Boolean(errorMsg)}
130
132
  helperText={errorMsg}
133
+ disabled={disabled}
131
134
  />
132
135
  );
133
136
  }
@@ -147,6 +150,7 @@ function EditableField({
147
150
  onChange={(e) => handleChange(e.target.value)}
148
151
  error={Boolean(errorMsg)}
149
152
  helperText={errorMsg}
153
+ disabled={disabled}
150
154
  />
151
155
  {maxLength && maxLength > 0 ? (
152
156
  <Typography
@@ -1,10 +1,8 @@
1
1
  /* eslint-disable react/no-unstable-nested-components */
2
2
  /* eslint-disable import/no-extraneous-dependencies */
3
- import Box from '@mui/material/Box';
4
- import useMediaQuery from '@mui/material/useMediaQuery';
5
- import SwipeableDrawer from '@mui/material/SwipeableDrawer';
6
- import Typography from '@mui/material/Typography';
7
- import Backdrop, { BackdropProps } from '@mui/material/Backdrop';
3
+ import { Icon } from '@iconify/react';
4
+ import { Box, Backdrop, useMediaQuery, SwipeableDrawer, Typography, Tooltip } from '@mui/material';
5
+ import type { BackdropProps } from '@mui/material';
8
6
 
9
7
  import styled from '@emotion/styled';
10
8
  import { joinURL } from 'ufo';
@@ -19,7 +17,7 @@ import PhoneInput, {
19
17
  import cloneDeep from 'lodash/cloneDeep';
20
18
  import omit from 'lodash/omit';
21
19
  import { mergeSx } from '@arcblock/ux/lib/Util/style';
22
-
20
+ import { LOGIN_PROVIDER } from '@arcblock/ux/lib/Util/constant';
23
21
  import { useCreation, useMemoizedFn, useReactive } from 'ahooks';
24
22
  import { useMemo, useRef, useState, memo, forwardRef, useEffect, lazy } from 'react';
25
23
  import { translate } from '@arcblock/ux/lib/Locale/util';
@@ -27,6 +25,7 @@ import isEmail from 'validator/lib/isEmail';
27
25
  import isPostalCode from 'validator/lib/isPostalCode';
28
26
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
29
27
  import { useBrowser } from '@arcblock/react-hooks';
28
+
30
29
  import { translations } from '../../libs/locales';
31
30
  import type { User, UserAddress, UserMetadata, UserPhoneProps } from '../../../@types';
32
31
  import EditableField, { commonInputStyle, inputFieldStyle } from '../editable-field';
@@ -430,11 +429,28 @@ export default function UserMetadataComponent({
430
429
  <EditableField
431
430
  value={metadata.email ?? user?.email ?? ''}
432
431
  editable={editing}
432
+ disabled={user?.sourceProvider === LOGIN_PROVIDER.EMAIL}
433
433
  canEdit={!emailVerified}
434
434
  verified={emailVerified}
435
435
  placeholder="Email"
436
436
  icon={<EmailIcon {...iconSize} />}
437
- label={t('profile.email')}
437
+ label={
438
+ <>
439
+ {t('profile.email')}
440
+ {user?.sourceProvider === LOGIN_PROVIDER.EMAIL ? (
441
+ <Tooltip title={t('profile.emailSourceProviderNotAllowEdit')}>
442
+ <Box
443
+ component={Icon}
444
+ icon="mdi:info-outline"
445
+ sx={{
446
+ verticalAlign: 'middle',
447
+ ml: 0.25,
448
+ }}
449
+ />
450
+ </Tooltip>
451
+ ) : null}
452
+ </>
453
+ }
438
454
  onChange={(value) => onChange(value, 'email')}
439
455
  errorMsg={validateMsg.email}
440
456
  renderValue={(value) => (
@@ -125,6 +125,7 @@ export const translations = {
125
125
  localTime: '当地时间:',
126
126
  email: '邮箱地址',
127
127
  emailInvalid: '邮箱格式不正确',
128
+ emailSourceProviderNotAllowEdit: '使用邮箱注册的用户不允许修改邮箱',
128
129
  phone: '电话号码',
129
130
  phoneInvalid: '电话号码格式不正确',
130
131
  editProfile: '编辑资料',
@@ -280,6 +281,7 @@ export const translations = {
280
281
  localTime: 'Local Time: ',
281
282
  email: 'Email',
282
283
  emailInvalid: 'Email is invalid',
284
+ emailSourceProviderNotAllowEdit: 'Email registered users are not allowed to edit email',
283
285
  phone: 'Phone',
284
286
  phoneInvalid: 'Phone number is invalid',
285
287
  editProfile: 'Edit Profile',