o1-preview-2024-09-12· OpenAI
WildChat-4.8M (AI2)
adapte, melhore e simplifique, não comente: <TextField label="CEP" type="cep"…
- User
adapte, melhore e simplifique, não comente: <TextField label="CEP" type="cep" value={cep} onChange={(e) => setCep(e.target.value)} sx={{ width: 1 / 3, gridRow: '1' }} variant="outlined" />; interface CustomProps { onChange: (event: { target: { name: string; value: string } }) => void; name: string; }
const MascaraCEP = React.forwardRef<HTMLDivElement, CustomProps>( function MascaraCEP(props, ref){ const { onChange, ...other} = props; return( <IMaskInput {...other} mask="#0000-000" definitions={{ '#': /[1-9]/ }} inputRef={ref} onAccept={(value: any) => onChange({ target: { name: props.name, value } })} overwrite /> ) } )
- Assistantjsx
const CepMaskCustom = React.forwardRef(function CepMaskCustom(props, ref) { const { onChange, ...other } = props; return ( <IMaskInput {...other} mask="00000-000" inputRef={ref} onAccept={(value) => onChange({ target: { name: props.name, value } })} /> ); }); <TextField label="CEP" value={cep} onChange={(e) => setCep(e.target.value)} sx={{ width: '33%', gridRow: 1 }} variant="outlined" InputProps={{ inputComponent: CepMaskCustom, inputProps: { name: 'cep', }, }} />;