feat: Introduce InputCreator
This commit is contained in:
47
packages/web/src/components/InputCreator/index.tsx
Normal file
47
packages/web/src/components/InputCreator/index.tsx
Normal file
@@ -0,0 +1,47 @@
|
||||
import type { AppFields } from 'types/app';
|
||||
import { useFormContext } from "react-hook-form";
|
||||
|
||||
import TextField from 'components/TextField';
|
||||
|
||||
type InputCreatorProps = {
|
||||
onChange?: React.ChangeEventHandler;
|
||||
schema: AppFields;
|
||||
};
|
||||
|
||||
export default function InputCreator(props: InputCreatorProps) {
|
||||
const {
|
||||
onChange,
|
||||
schema,
|
||||
} = props;
|
||||
|
||||
const { control } = useFormContext();
|
||||
|
||||
const {
|
||||
key: name,
|
||||
label,
|
||||
type,
|
||||
required,
|
||||
readOnly,
|
||||
value,
|
||||
description,
|
||||
docUrl,
|
||||
clickToCopy,
|
||||
} = schema;
|
||||
|
||||
return (
|
||||
<TextField
|
||||
defaultValue={value}
|
||||
required={required}
|
||||
placeholder=""
|
||||
disabled={readOnly}
|
||||
readOnly={readOnly}
|
||||
onChange={onChange}
|
||||
name={name}
|
||||
label={label}
|
||||
fullWidth
|
||||
helperText={description}
|
||||
control={control}
|
||||
clickToCopy={clickToCopy}
|
||||
/>
|
||||
);
|
||||
};
|
Reference in New Issue
Block a user