mirror of https://gitee.com/answerdev/answer.git
feat(ui): Add color form component
This commit is contained in:
parent
ac76c3af0f
commit
e0d3b671c8
|
@ -274,18 +274,39 @@ const SchemaForm: FC<IProps> = ({
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const as = widget === 'textarea' ? 'textarea' : 'input';
|
if (widget === 'textarea') {
|
||||||
return (
|
return (
|
||||||
<Form.Group controlId={key} key={key} className="mb-3">
|
<Form.Group controlId={key} key={key} className="mb-3">
|
||||||
<Form.Label>{title}</Form.Label>
|
<Form.Label>{title}</Form.Label>
|
||||||
<Form.Control
|
<Form.Control
|
||||||
as={as}
|
as="textarea"
|
||||||
name={key}
|
name={key}
|
||||||
placeholder={options?.placeholder || ''}
|
placeholder={options?.placeholder || ''}
|
||||||
type={options?.type || 'text'}
|
type={options?.type || 'text'}
|
||||||
value={formData[key]?.value}
|
value={formData[key]?.value}
|
||||||
onChange={handleInputChange}
|
onChange={handleInputChange}
|
||||||
isInvalid={formData[key].isInvalid}
|
isInvalid={formData[key].isInvalid}
|
||||||
|
rows={options?.rows || 3}
|
||||||
|
/>
|
||||||
|
<Form.Control.Feedback type="invalid">
|
||||||
|
{formData[key]?.errorMsg}
|
||||||
|
</Form.Control.Feedback>
|
||||||
|
|
||||||
|
<Form.Text className="text-muted">{description}</Form.Text>
|
||||||
|
</Form.Group>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<Form.Group controlId={key} key={key} className="mb-3">
|
||||||
|
<Form.Label>{title}</Form.Label>
|
||||||
|
<Form.Control
|
||||||
|
name={key}
|
||||||
|
placeholder={options?.placeholder || ''}
|
||||||
|
type={options?.type || 'text'}
|
||||||
|
value={formData[key]?.value}
|
||||||
|
onChange={handleInputChange}
|
||||||
|
style={options?.type === 'color' ? { width: '6rem' } : {}}
|
||||||
|
isInvalid={formData[key].isInvalid}
|
||||||
/>
|
/>
|
||||||
<Form.Control.Feedback type="invalid">
|
<Form.Control.Feedback type="invalid">
|
||||||
{formData[key]?.errorMsg}
|
{formData[key]?.errorMsg}
|
||||||
|
|
Loading…
Reference in New Issue