UNPKG

@ssplib/react-components

Version:
44 lines (43 loc) 2.3 kB
import { GridProps, InputLabelProps, TextFieldProps } from '@mui/material'; import React from 'react'; type HTMLInputType = React.InputHTMLAttributes<HTMLInputElement>['type']; export type MaskedInputType = 'cnpj' | 'cpf' | 'cpf_cnpj' | 'phone' | 'number' | 'rg' | 'cep' | 'sei'; export type InputType = MaskedInputType | HTMLInputType; type OmittedTextFieldProps = 'name' | 'type' | 'value' | 'onChange' | 'error' | 'helperText' | 'fullWidth' | 'size' | 'placeholder'; interface InputOwnProps { /** Tipo do campo - define máscara e validação */ type?: InputType; /** Nome do campo no formulário (obrigatório) */ name: string; /** Label exibido acima do campo */ title?: string; /** Campo obrigatório */ required?: boolean; /** Máscara customizada para type="number" */ numberMask?: string; /** Placeholder customizado (sobrescreve title) */ customPlaceholder?: string; /** Valor inicial do campo */ defaultValue?: string; /** Tamanho mínimo para validação (type="input") */ inputMinLength?: number; /** Tamanho máximo para validação (type="input") */ inputMaxLength?: number; /** Validação customizada */ customValidate?: (value: string, form: Record<string, any>) => string | undefined; /** Valor observado externamente: quando informado, o campo é sincronizado com esse valor (ex.: watchValue={context.formWatch('outroCampo')}) */ watchValue?: string; /** Props do Grid container */ gridProps?: Omit<GridProps, 'item' | 'xs' | 'sm' | 'md'>; /** Props do InputLabel */ labelProps?: Omit<InputLabelProps, 'required'>; } interface GridLayoutProps { xs?: GridProps['xs']; sm?: GridProps['sm']; md?: GridProps['md']; } export type InputProps = InputOwnProps & GridLayoutProps & Omit<TextFieldProps, OmittedTextFieldProps | keyof InputOwnProps>; export declare function Input({ type, name, title, required, numberMask, customPlaceholder, defaultValue, inputMinLength, inputMaxLength, customValidate, watchValue, xs, sm, md, gridProps, labelProps, disabled, sx, InputProps: inputPropsFromUser, InputLabelProps: inputLabelPropsFromUser, ...textFieldProps }: InputProps): JSX.Element; declare const _default: React.MemoExoticComponent<typeof Input>; export default _default;