feat(web/input): support default values (#66)

* feat(web/dialog): Support placeholders

* feat(web/dialog): Support default values

* feat(web/dialog): Support default state of checkbox

* feat(web/dialog): Support placeholder for number input

* feat(web/dialog): Support default value for select
This commit is contained in:
ANTOND
2022-08-05 15:10:37 +02:00
committed by GitHub
parent 14a04c4b68
commit 1990e3792f
6 changed files with 38 additions and 5 deletions

View File

@@ -7,6 +7,7 @@ import {
Input,
} from "@chakra-ui/react";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { useEffect } from "react";
import { Row } from "../../../interfaces/dialog";
interface Props {
@@ -18,6 +19,10 @@ interface Props {
}
const InputField: React.FC<Props> = (props) => {
useEffect(() => {
if(props.row.default) props.handleChange(props.row.default, props.index);
}, []);
return (
<>
<Box mb={3} textAlign="left">
@@ -31,6 +36,8 @@ const InputField: React.FC<Props> = (props) => {
)}
<Input
onChange={(e) => props.handleChange(e.target.value, props.index)}
placeholder={props.row.placeholder}
defaultValue={props.row.default}
type={
!props.row.password || props.passwordStates[props.index]
? "text"