UNPKG

@chief-editor/ui

Version:

UI Component for chief editor

33 lines (32 loc) 1.62 kB
import { UnionOmit } from '@co-hooks/util'; import { CSSProperties, ChangeEventHandler, ClipboardEventHandler, CompositionEventHandler, FocusEventHandler, HTMLAttributes, KeyboardEventHandler, ReactNode, Ref } from 'react'; import { InputCommonAttributes, TextareaCommonAttributes } from './const'; export interface IInputWrapper<T> { domRef?: Ref<HTMLLabelElement>; inputRef?: Ref<T>; prefix?: ReactNode; suffix?: ReactNode; clear?: ReactNode; inputClassName?: string; inputStyle?: CSSProperties; tag?: 'input' | 'textarea'; type?: 'text' | 'password' | 'email' | 'url' | 'search'; value?: string; disabled?: boolean; disableSuffixAnimation?: boolean; onValueChange?: (value: string) => void; onChange?: ChangeEventHandler<T>; onFocus?: FocusEventHandler<T>; onBlur?: FocusEventHandler<T>; onKeyDown?: KeyboardEventHandler<T>; onKeyUp?: KeyboardEventHandler<T>; onKeyPress?: KeyboardEventHandler<T>; onPressEnter?: KeyboardEventHandler<T>; onCompositionStart?: CompositionEventHandler<T>; onCompositionUpdate?: CompositionEventHandler<T>; onCompositionEnd?: CompositionEventHandler<T>; onCopy?: ClipboardEventHandler<T>; } export declare type InputCommonProps<T> = T extends HTMLInputElement ? InputCommonAttributes : TextareaCommonAttributes; export declare type IInputWrapperProps<T> = UnionOmit<IInputWrapper<T>, HTMLAttributes<HTMLLabelElement> & InputCommonProps<T>>; export declare function InputWrapper<T extends HTMLInputElement | HTMLTextAreaElement = HTMLInputElement>(props: IInputWrapperProps<T>): JSX.Element;