mirror of
https://github.com/CommunityOx/ox_lib.git
synced 2026-08-18 15:36:02 +01:00
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:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user