UNPKG

@coocoon/react-awesome-query-builder

Version:

User-friendly query builder for React. Demo: https://ukrbublik.github.io/react-awesome-query-builder

42 lines (37 loc) 959 B
import React from "react"; import TextField from "@mui/material/TextField"; import FormControl from "@mui/material/FormControl"; export default (props) => { const {value, setValue, config, readonly, min, max, step, placeholder, customProps} = props; const onChange = e => { let val = e.target.value; if (val === "" || val === null) val = undefined; else val = Number(val); setValue(val); }; const numberValue = value == undefined ? "" : value; return ( <FormControl> <TextField variant="standard" type="number" value={numberValue} placeholder={!readonly ? placeholder : ""} InputProps={{ readOnly: readonly, }} inputProps={{ min: min, max: max, step: step, }} disabled={readonly} onChange={onChange} size="small" {...customProps} /> </FormControl> ); };