import { IErrorMessage } from '../error'; import { IThemeSize } from '../../styles/utils'; import { IThemeControl, IThemeGenreInput, ITypography } from '../../styles/utils/types'; import { ClipboardEventHandler, CSSProperties, FocusEventHandler, HTMLInputAutoCompleteAttribute, HTMLInputTypeAttribute, KeyboardEventHandler, PropsWithChildren, Ref } from 'react'; import { NumberFormatValues, NumericFormatProps, PatternFormatProps } from 'react-number-format'; type ICommonInput = { className?: string; style?: CSSProperties; error?: IErrorMessage; placeholder?: string; ref?: Ref; sxTypography?: ITypography; control?: IThemeControl; size: IThemeSize; tabIndex?: number; ariaLabel?: string; autoComplete?: HTMLInputAutoCompleteAttribute | string; genre: IThemeGenreInput; id?: string; inputMode?: 'text' | 'none' | 'tel' | 'url' | 'email' | 'numeric' | 'decimal' | 'search'; isBold?: boolean; isCenter?: boolean; isDisabled?: boolean; isFullRadius?: boolean; isHidden?: boolean; isHiddenBorder?: boolean; isMinWidthAsContent?: boolean; isNiceNumber?: boolean; isNoSpaces?: boolean; isReadOnly?: boolean; isRequired?: boolean; isWidthAsHeight?: boolean; isZeroRadius?: boolean; maxLength?: number; minLength?: number; name?: string; onBlur?: FocusEventHandler; onFocus?: FocusEventHandler; onKeyDown?: KeyboardEventHandler; onPaste?: ClipboardEventHandler; postfixChildren?: InputChildrenProps; prefixChildren?: InputChildrenProps; }; type IControlledValue = { value: string | number | null | undefined; defaultValue?: never; }; type IUnControlledValue = { defaultValue: string | number | null | undefined; value?: never; }; type IBaseInput = ICommonInput & (IControlledValue | IUnControlledValue); export type IInputStandard = IBaseInput & { variety: 'standard'; onChange?: (value: string) => void; type?: HTMLInputTypeAttribute; min?: number; max?: number; step?: number; }; export type IInputPattern = IBaseInput & { variety: 'pattern'; onChange?: (value: NumberFormatValues) => void; propsPattern: Pick; }; export type IInputNumeric = IBaseInput & { variety: 'numeric'; onChange?: (value: NumberFormatValues) => void; propsNumeric: Pick; }; export type IInput = IInputStandard | IInputPattern | IInputNumeric; export interface InputChildrenProps extends PropsWithChildren { left: string; right: string; width: string; isFocusInput?: boolean; } export {};