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

@@ -1,4 +1,5 @@
import { Box, Select } from "@chakra-ui/react";
import { useEffect } from "react";
import { Row } from "../../../interfaces/dialog";
interface Props {
@@ -8,11 +9,22 @@ interface Props {
}
const SelectField: React.FC<Props> = (props) => {
useEffect(() => {
if(props.row.default) {
props.row.options?.map((option) => {
if(props.row.default === option.value) {
props.handleChange(option.value, props.index);
}
});
}
}, []);
return (
<>
<Box mb={3} key={`select-${props.index}`}>
<Select
onChange={(e) => props.handleChange(e.target.value, props.index)}
defaultValue={props.row.default}
>
{/* Hacky workaround for selectable placeholder issue */}
<option value="" selected hidden disabled>