Merge remote-tracking branch 'github/feat/1.1.2/ui' into feat/1.1.2/user-center

This commit is contained in:
LinkinStars 2023-04-20 19:10:46 +08:00
commit 083c5a8a4c
7 changed files with 44 additions and 8 deletions

View File

@ -9,9 +9,16 @@ interface Props {
value: string;
onChange: (value: string) => void;
acceptType?: string;
readOnly?: boolean;
}
const Index: FC<Props> = ({ type = 'post', value, onChange, acceptType }) => {
const Index: FC<Props> = ({
type = 'post',
value,
onChange,
acceptType,
readOnly = false,
}) => {
const onUpload = (imgPath: string) => {
onChange(imgPath);
};
@ -29,11 +36,15 @@ const Index: FC<Props> = ({ type = 'post', value, onChange, acceptType }) => {
type={type}
uploadCallback={onUpload}
className="mb-0"
disabled={readOnly}
acceptType={acceptType}>
<Icon name="cloud-upload" />
</UploadImg>
<Button variant="outline-secondary" onClick={onRemove}>
<Button
disabled={readOnly}
variant="outline-secondary"
onClick={onRemove}>
<Icon name="trash" />
</Button>
</ButtonGroup>

View File

@ -10,6 +10,7 @@ interface Props {
enumValues: (string | boolean | number)[];
enumNames: string[];
formData: Type.FormDataType;
readOnly?: boolean;
}
const Index: FC<Props> = ({
type = 'radio',
@ -18,6 +19,7 @@ const Index: FC<Props> = ({
enumValues,
enumNames,
formData,
readOnly = false,
}) => {
const fieldObject = formData[fieldName];
const handleCheck = (
@ -45,7 +47,6 @@ const Index: FC<Props> = ({
<Form.Check
key={String(item)}
inline
required
type={type}
name={fieldName}
id={`form-${String(item)}`}
@ -54,6 +55,7 @@ const Index: FC<Props> = ({
feedback={fieldObject?.errorMsg}
feedbackType="invalid"
isInvalid={fieldObject?.isInvalid}
disabled={readOnly}
onChange={(evt) => handleCheck(evt, index)}
/>
);

View File

@ -9,8 +9,16 @@ interface Props {
fieldName: string;
onChange?: (fd: Type.FormDataType) => void;
formData: Type.FormDataType;
readOnly?: boolean;
}
const Index: FC<Props> = ({ title, fieldName, onChange, label, formData }) => {
const Index: FC<Props> = ({
title,
fieldName,
onChange,
label,
formData,
readOnly = false,
}) => {
const fieldObject = formData[fieldName];
const handleChange = (evt: React.ChangeEvent<HTMLInputElement>) => {
const { name, checked } = evt.currentTarget;
@ -28,7 +36,6 @@ const Index: FC<Props> = ({ title, fieldName, onChange, label, formData }) => {
};
return (
<Form.Check
required
id={`switch-${title}`}
name={fieldName}
type="switch"
@ -37,6 +44,7 @@ const Index: FC<Props> = ({ title, fieldName, onChange, label, formData }) => {
feedback={fieldObject?.errorMsg}
feedbackType="invalid"
isInvalid={fieldObject.isInvalid}
disabled={readOnly}
onChange={handleChange}
/>
);

View File

@ -7,8 +7,14 @@ interface Props {
fieldName: string;
onChange?: (fd: Type.FormDataType) => void;
formData: Type.FormDataType;
readOnly?: boolean;
}
const Index: FC<Props> = ({ fieldName, onChange, formData }) => {
const Index: FC<Props> = ({
fieldName,
onChange,
formData,
readOnly = false,
}) => {
const fieldObject = formData[fieldName];
const handleChange = (evt: React.ChangeEvent<HTMLSelectElement>) => {
const { name, value } = evt.currentTarget;
@ -29,6 +35,7 @@ const Index: FC<Props> = ({ fieldName, onChange, formData }) => {
value={fieldObject?.value || ''}
isInvalid={fieldObject?.isInvalid}
name={fieldName}
disabled={readOnly}
onChange={handleChange}
/>
);

View File

@ -10,6 +10,7 @@ interface Props {
fieldName: string;
onChange?: (fd: Type.FormDataType) => void;
formData: Type.FormDataType;
readOnly?: boolean;
}
const Index: FC<Props> = ({
type = 'avatar',
@ -17,10 +18,10 @@ const Index: FC<Props> = ({
fieldName,
onChange,
formData,
readOnly = false,
}) => {
const fieldObject = formData[fieldName];
const handleChange = (name: string, value: string) => {
console.log('upload: ', name, value);
const state = {
...formData,
[name]: {
@ -38,6 +39,7 @@ const Index: FC<Props> = ({
type={type}
acceptType={acceptType}
value={fieldObject?.value}
readOnly={readOnly}
onChange={(value) => handleChange(fieldName, value)}
/>
<Form.Control

View File

@ -380,6 +380,7 @@ const SchemaForm: ForwardRefRenderFunction<IRef, IProps> = (
enumValues={enumValues}
enumNames={enumNames}
formData={formData}
readOnly={readOnly}
/>
) : null}
{widget === 'switch' ? (
@ -389,6 +390,7 @@ const SchemaForm: ForwardRefRenderFunction<IRef, IProps> = (
fieldName={key}
onChange={onChange}
formData={formData}
readOnly={readOnly}
/>
) : null}
{widget === 'timezone' ? (
@ -396,6 +398,7 @@ const SchemaForm: ForwardRefRenderFunction<IRef, IProps> = (
fieldName={key}
onChange={onChange}
formData={formData}
readOnly={readOnly}
/>
) : null}
{widget === 'upload' ? (
@ -409,6 +412,7 @@ const SchemaForm: ForwardRefRenderFunction<IRef, IProps> = (
fieldName={key}
onChange={onChange}
formData={formData}
readOnly={readOnly}
/>
) : null}
{widget === 'textarea' ? (

View File

@ -52,7 +52,9 @@ const Index: React.FC<IProps> = ({
return (
<label
className={classnames('btn btn-outline-secondary uploadBtn', className)}>
className={classnames('btn btn-outline-secondary', className, {
disabled: !!disabled,
})}>
{children || (status ? t('upload_img.loading') : t('upload_img.name'))}
<input
type="file"