UNPKG

form-tool

Version:

Create quickly and robustly with form hooks

379 lines (378 loc) 13.9 kB
import { ChangeEvent, FocusEvent, MouseEvent, RefObject } from 'react'; import { CSSObject } from 'styled-components'; import * as CSS from 'csstype'; import { TDefaultInputStyle } from './settings'; declare type TEqualTo = { value: string | number; errorMessage: string; }; export declare interface TOnChangeInput { value?: any; name: string; index?: number; error: boolean; hour?: boolean; date?: boolean; pass?: boolean; dataExtra?: any; email?: boolean; range?: number[]; minimum?: number; maximum?: number; format?: boolean; letters?: boolean; numeric?: boolean; required?: boolean; nameArray?: string; equalTo?: TEqualTo; nameObject?: string; typeNumeric?: boolean; event: ChangeEvent<HTMLInputElement | HTMLTextAreaElement>; } export declare type TInput = { name?: string; form?: string; title?: string; pass?: boolean; date?: boolean; hour?: boolean; dataExtra?: any; error?: boolean; email?: boolean; focus?: boolean; dataCy?: string; float?: boolean; range?: number[]; format?: boolean; minimum?: number; maximum?: number; numeric?: boolean; letters?: boolean; disabled?: boolean; dataIndex?: number; required?: boolean; equalTo?: TEqualTo; nameArray?: string; dataObject?: string; mediaTable?: boolean; mediaPhone?: boolean; validation?: boolean; placeholder?: string; formatDate?: boolean; formatHour?: boolean; formatPhone?: boolean; widthTable?: CSS.Property.Width; widthPhone?: CSS.Property.Width; rightLoading?: CSS.Property.Right; colorLoading?: CSS.Property.Color; bottomLoading?: CSS.Property.Bottom; maxWidthTable?: CSS.Property.MaxWidth; maxWidthPhone?: CSS.Property.MaxWidth; loadingContainer?: Node; type?: 'color' | 'date' | 'datetime-local' | 'email' | 'file' | 'hidden' | 'image' | 'month' | 'number' | 'password' | 'radio' | 'range' | 'reset' | 'search' | 'submit' | 'tel' | 'text' | 'time' | 'url' | 'week'; value: any; autoComplete?: 'off' | 'on' | 'nope'; onChange?: (args: TOnChangeInput) => void; onClick?: (e: MouseEvent<HTMLDivElement>) => void; onBlur?: (e: FocusEvent<HTMLInputElement>) => void; reference?: ((instance: HTMLInputElement | null) => void) | RefObject<HTMLInputElement> | null | undefined; click?: boolean; cStyles?: CSSObject; cWidth?: CSS.Property.Width; cMargin?: CSS.Property.Margin; cDisplay?: CSS.Property.Display; cPosition?: CSS.Property.Position; cMaxWidth?: CSS.Property.MaxWidth; cMinWidth?: CSS.Property.MinWidth; cFlexDirection?: CSS.Property.FlexDirection; cHoverDisplayTooltip?: CSS.Property.Display; lTitle?: string; lNotValue?: boolean; lStyles?: CSSObject; lActiveTitle?: boolean; lColor?: CSS.Property.Color; lBorder?: CSS.Property.Margin; lMargin?: CSS.Property.Margin; lPadding?: CSS.Property.Padding; lErrorColor?: CSS.Property.Color; lFontSize?: CSS.Property.FontSize; lOverflow?: CSS.Property.Overflow; lNotValueColor?: CSS.Property.Color; lTextAlign?: CSS.Property.TextAlign; lFontFamily?: CSS.Property.FontFamily; lWhiteSpace?: CSS.Property.WhiteSpace; lTextOverflow?: CSS.Property.TextOverflow; lHoverDisplayTooltip?: CSS.Property.Display; iAlt?: boolean; iTitle?: string; iStyles?: CSSObject; isLoading?: boolean; iActiveTitle?: boolean; iColor?: CSS.Property.Color; iWidth?: CSS.Property.Width; iBorder?: CSS.Property.Border; iOutline?: CSS.Property.Outline; iPadding?: CSS.Property.Padding; iFontSize?: CSS.Property.FontSize; iBorderError?: CSS.Property.Border; iBorderFocus?: CSS.Property.Border; iMinHeight?: CSS.Property.MinHeight; iTextAlign?: CSS.Property.TextAlign; iColorDisabled?: CSS.Property.Color; iBorderSuccess?: CSS.Property.Border; iFontFamily?: CSS.Property.FontFamily; iCursorDisabled?: CSS.Property.Cursor; iTransform?: CSS.Property.TextTransform; iColorDisabledClick?: CSS.Property.Color; iCursorDisabledClick?: CSS.Property.Cursor; iHoverDisplayTooltip?: CSS.Property.Display; iFontFamilyDisabled?: CSS.Property.FontFamily; iFontFamilyDisabledClick?: CSS.Property.FontFamily; iBackgroundColorDisabled?: CSS.Property.BackgroundColor; iBackgroundColorDisabledClick?: CSS.Property.BackgroundColor; symbol?: string; sStyles?: CSSObject; sizeLoading?: string; sLeft?: CSS.Property.Left; sColor?: CSS.Property.Color; sBottom?: CSS.Property.Bottom; sFontSize?: CSS.Property.FontSize; sPosition?: CSS.Property.Position; iBorderRadius?: CSS.Property.Border; sColorDisabled?: CSS.Property.Color; sFontFamily?: CSS.Property.FontFamily; sColorDisabledClick?: CSS.Property.Color; sFontFamilyDisabled?: CSS.Property.FontFamily; iBackgroundColor?: CSS.Property.BackgroundColor; sFontFamilyDisabledClick?: CSS.Property.FontFamily; tStyles?: CSSObject; typeNumeric?: boolean; tTop?: CSS.Property.Top; tLeft?: CSS.Property.Left; tColor?: CSS.Property.Color; tZIndex?: CSS.Property.ZIndex; tBorder?: CSS.Property.Border; tBottom?: CSS.Property.Bottom; tPadding?: CSS.Property.Padding; tDisplay?: CSS.Property.Display; tFontSize?: CSS.Property.FontSize; tPosition?: CSS.Property.Position; tTopAfterBefore?: CSS.Property.Top; tBoxShadow?: CSS.Property.BoxShadow; tLeftAfterBefore?: CSS.Property.Left; tFontFamily?: CSS.Property.FontFamily; tBorderAfterBefore?: CSS.Property.Border; tBottomAfterBefore?: CSS.Property.Bottom; tBorderRadius?: CSS.Property.BorderRadius; tContentAfterBefore?: CSS.Property.Content; tPositionAfterBefore?: CSS.Property.Position; tBackgroundColor?: CSS.Property.BackgroundColor; tPointerEventsAfterBefore?: CSS.Property.PointerEvents; errorMessagePass?: string; errorMessageEmail?: string; errorMessageLetter?: string; errorMessageNumeric?: string; errorMessageRequired?: string; errorMessageDate?: (value: string) => string; errorMessageHour?: (value: string) => string; errorMessageMinimum?: (value: number) => string; errorMessageMaximum?: (value: number) => string; errorMessageRange?: (min: number, max: number) => string; tiStyles?: CSSObject; tiColor?: CSS.Property.Color; tiZIndex?: CSS.Property.ZIndex; tiOpacity?: CSS.Property.Opacity; tiPadding?: CSS.Property.Padding; tiFontSize?: CSS.Property.FontSize; tiMaxWidth?: CSS.Property.MaxWidth; tiPosition?: CSS.Property.Position; tiOverflow?: CSS.Property.Overflow; tiMaxHeight?: CSS.Property.MaxHeight; tiWhiteSpace?: CSS.Property.WhiteSpace; tiFontFamily?: CSS.Property.FontFamily; tiBorderRadius?: CSS.Property.BorderRadius; tiTextOverflow?: CSS.Property.TextOverflow; tiBackgroundColor?: CSS.Property.BackgroundColor; tlStyles?: CSSObject; tlColor?: CSS.Property.Color; tlZIndex?: CSS.Property.ZIndex; tlOpacity?: CSS.Property.Opacity; tlPadding?: CSS.Property.Padding; tlFontSize?: CSS.Property.FontSize; tlMaxWidth?: CSS.Property.MaxWidth; tlPosition?: CSS.Property.Position; tlOverflow?: CSS.Property.Overflow; tlMaxHeight?: CSS.Property.MaxHeight; tlWhiteSpace?: CSS.Property.WhiteSpace; tlFontFamily?: CSS.Property.FontFamily; tlBorderRadius?: CSS.Property.BorderRadius; tlTextOverflow?: CSS.Property.TextOverflow; tlBackgroundColor?: CSS.Property.BackgroundColor; bStyles?: CSSObject; }; export declare type TTooltip = { tStyles?: CSSObject; gs?: TDefaultInputStyle; tTop?: CSS.Property.Top; tLeft?: CSS.Property.Left; tColor?: CSS.Property.Color; tZIndex?: CSS.Property.ZIndex; tBorder?: CSS.Property.Border; tBottom?: CSS.Property.Bottom; tPadding?: CSS.Property.Padding; tDisplay?: CSS.Property.Display; tFontSize?: CSS.Property.FontSize; tPosition?: CSS.Property.Position; tTopAfterBefore?: CSS.Property.Top; tBoxShadow?: CSS.Property.BoxShadow; tLeftAfterBefore?: CSS.Property.Left; tFontFamily?: CSS.Property.FontFamily; tBorderAfterBefore?: CSS.Property.Border; tBottomAfterBefore?: CSS.Property.Bottom; tBorderRadius?: CSS.Property.BorderRadius; tContentAfterBefore?: CSS.Property.Content; tPositionAfterBefore?: CSS.Property.Position; tBackgroundColor?: CSS.Property.BackgroundColor; tPointerEventsAfterBefore?: CSS.Property.PointerEvents; }; export declare type TContainerInput = { cStyles?: CSSObject; mediaTable?: boolean; mediaPhone?: boolean; gs?: TDefaultInputStyle; stylesTable?: CSSObject; stylesPhone?: CSSObject; cWidth?: CSS.Property.Width; cMargin?: CSS.Property.Margin; widthTable?: CSS.Property.Width; widthPhone?: CSS.Property.Width; cDisplay?: CSS.Property.Display; cMaxWidth?: CSS.Property.MaxWidth; cMinWidth?: CSS.Property.MinWidth; cPosition?: CSS.Property.Position; maxWidthTable?: CSS.Property.MaxWidth; maxWidthPhone?: CSS.Property.MaxWidth; cHoverDisplayTooltip?: CSS.Property.Display; cFlexDirection?: CSS.Property.FlexDirection; }; export declare type TLabelInput = { error?: boolean; lPadding?: CSS.Property.Padding; loading?: boolean; lStyles?: CSSObject; val?: string | number; lActiveTitle?: boolean; lNotValueColor?: string; gs?: TDefaultInputStyle; valLabel?: string | number; lColor?: CSS.Property.Color; lBorder?: CSS.Property.Border; lMargin?: CSS.Property.Margin; lErrorColor?: CSS.Property.Color; axis: { x?: number; y?: number; }; lFontSize?: CSS.Property.FontSize; lOverflow?: CSS.Property.Overflow; lTextAlign?: CSS.Property.TextAlign; lFontFamily?: CSS.Property.FontFamily; lWhiteSpace?: CSS.Property.WhiteSpace; lTextOverflow?: CSS.Property.TextOverflow; lHoverDisplayTooltip?: CSS.Property.Display; tlStyles?: CSSObject; tlColor?: CSS.Property.Color; tlZIndex?: CSS.Property.ZIndex; tlOpacity?: CSS.Property.Opacity; tlPadding?: CSS.Property.Padding; tlFontSize?: CSS.Property.FontSize; tlMaxWidth?: CSS.Property.MaxWidth; tlPosition?: CSS.Property.Position; tlOverflow?: CSS.Property.Overflow; tlMaxHeight?: CSS.Property.MaxHeight; tlFontFamily?: CSS.Property.FontFamily; tlVisibility?: CSS.Property.Visibility; tlWhiteSpace?: CSS.Property.WhiteSpace; tlBorderRadius?: CSS.Property.BorderRadius; tlTextOverflow?: CSS.Property.TextOverflow; tlBackgroundColor?: CSS.Property.BackgroundColor; }; export declare type TInputV = { click?: boolean; error?: boolean; iStyles?: CSSObject; iActiveTitle?: boolean; gs?: TDefaultInputStyle; valLabel?: string | number; iColor?: CSS.Property.Color; iWidth?: CSS.Property.Width; iBorder?: CSS.Property.Border; iPadding?: CSS.Property.Padding; iOutline?: CSS.Property.Outline; axis: { x?: number; y?: number; }; iFontSize?: CSS.Property.FontSize; iBorderFocus?: CSS.Property.Border; iBorderError?: CSS.Property.Border; iColorDisabled?: CSS.Property.Color; iMinHeight?: CSS.Property.MinHeight; iTextAlign?: CSS.Property.TextAlign; iBorderSuccess?: CSS.Property.Border; iFontFamily?: CSS.Property.FontFamily; iCursorDisabled?: CSS.Property.Cursor; iTransform?: CSS.Property.TextTransform; iColorDisabledClick?: CSS.Property.Color; iBorderRadius?: CSS.Property.BorderRadius; iCursorDisabledClick?: CSS.Property.Cursor; iHoverDisplayTooltip?: CSS.Property.Display; iFontFamilyDisabled?: CSS.Property.FontFamily; iBackgroundColor?: CSS.Property.BackgroundColor; iFontFamilyDisabledClick?: CSS.Property.FontFamily; iBackgroundColorDisabled?: CSS.Property.BackgroundColor; iBackgroundColorDisabledClick?: CSS.Property.BackgroundColor; }; export declare type TSymbolSpan = { click?: boolean; disabled?: boolean; sStyles?: CSSObject; gs?: TDefaultInputStyle; sLeft?: CSS.Property.Left; sColor?: CSS.Property.Color; sBottom?: CSS.Property.Bottom; sFontSize?: CSS.Property.FontSize; sPosition?: CSS.Property.Position; sColorDisabled?: CSS.Property.Color; sFontFamily?: CSS.Property.FontFamily; sColorDisabledClick?: CSS.Property.Color; sFontFamilyDisabled?: CSS.Property.FontFamily; sFontFamilyDisabledClick?: CSS.Property.FontFamily; }; export declare type TBoxInput = { bStyles?: CSSObject; tiStyles?: CSSObject; val?: string | number; iActiveTitle?: boolean; gs?: TDefaultInputStyle; tiColor?: CSS.Property.Color; tiZIndex?: CSS.Property.ZIndex; tiOpacity?: CSS.Property.Opacity; tiPadding?: CSS.Property.Padding; axis?: { x?: number; y?: number; }; tiFontSize?: CSS.Property.FontSize; tiMaxWidth?: CSS.Property.MaxWidth; tiPosition?: CSS.Property.Position; tiOverflow?: CSS.Property.Overflow; tiBorderRadius?: CSS.Property.Border; tiMaxHeight?: CSS.Property.MaxHeight; tiFontFamily?: CSS.Property.FontFamily; tiVisibility?: CSS.Property.Visibility; tiWhiteSpace?: CSS.Property.WhiteSpace; tiTextOverflow?: CSS.Property.TextOverflow; tiBackgroundColor?: CSS.Property.BackgroundColor; }; export {};