UNPKG

choerodon-ui

Version:

An enterprise-class UI design language and React-based implementation

103 lines (102 loc) 3.84 kB
import React, { ChangeEventHandler, Component, InputHTMLAttributes, KeyboardEventHandler, ReactElement, ReactNode } from 'react'; import Group from './Group'; import Search from './Search'; import TextArea from './TextArea'; import { Size } from '../_util/enum'; import ConfigContext, { ConfigContextValue } from '../config-provider/ConfigContext'; export declare type InputSelection = { start: number | null; end: number | null; } | null; export interface AbstractInputProps<T> extends Omit<InputHTMLAttributes<T>, 'onChange' | 'onCopy' | 'size' | 'prefix'> { prefixCls?: string; label?: ReactNode; showLengthInfo?: boolean | 'never'; showPasswordEye?: boolean | 'hold' | 'nohold'; labelLayout?: 'float' | 'none'; onChange?: ChangeEventHandler<T>; onPressEnter?: KeyboardEventHandler<T>; } export interface InputProps extends AbstractInputProps<HTMLInputElement> { copy?: boolean; size?: Size; addonBefore?: ReactNode; addonAfter?: ReactNode; onCopy?: (value: any) => void; prefix?: ReactNode; suffix?: ReactNode; focused?: boolean; border?: boolean; typeCase?: 'upper' | 'lower'; dbc2sbc?: boolean; trimAll?: boolean; trim?: boolean; inputChinese?: boolean; } export interface InputState { value?: any; focused?: boolean; showPassword?: boolean; } export default class Input extends Component<InputProps, any> { static displayName: string; static get contextType(): typeof ConfigContext; static Group: typeof Group; static Search: typeof Search; static TextArea: typeof TextArea; static defaultProps: { type: string; disabled: boolean; readOnly: boolean; showLengthInfo: boolean; showPasswordEye: boolean; border: boolean; dbc2sbc: boolean; trim: boolean; trimAll: boolean; inputChinese: boolean; labelLayout: string; }; context: ConfigContextValue; state: InputState; input: HTMLInputElement; rendered?: HTMLDivElement; prefix?: HTMLSpanElement; suffix?: HTMLSpanElement; isOnComposition: boolean; inputSelection: InputSelection; constructor(props: any, context: ConfigContextValue); componentDidMount(): void; componentWillReceiveProps(nextProps: InputProps): void; componentDidUpdate(prevProps: InputProps): void; setRenderedStyle(): void; handleComposition: (e: React.CompositionEvent<Element>) => void; handleFocus: (e: React.FocusEvent<HTMLInputElement, Element>) => void; handleBlur: (e: React.FocusEvent<HTMLInputElement, Element>) => void; handleChange: (e: any) => void; handleCopy: () => void; handleTogglePassword: () => void; handleShowPassword: () => void; handleHidePassword: () => void; handleKeyDown: (e: React.KeyboardEvent<HTMLInputElement>) => void; saveInput: (node: HTMLInputElement) => void; saveRenderedRef: (node: HTMLDivElement) => void; savePrefix: (node: HTMLSpanElement) => void; saveSuffix: (node: HTMLSpanElement) => void; focus(): void; blur(): void; getPrefixCls(): string; getInputClassName(): string; transformValue(v: any): any; renderCopyIcon(prefixCls?: string): JSX.Element | null; renderShowPassword(prefixCls?: string): JSX.Element | undefined; getLengthInfo(prefixCls?: string): JSX.Element | null; renderFloatLabel(prefixCls?: string): ReactNode; getSizeClassName(name: string, prefixCls?: string): string; hasValue(): boolean; renderLabeledIcon(children: ReactElement<any>, prefixCls?: string): JSX.Element; renderInput(prefixCls?: string): JSX.Element; getWrapperClassName(prefixCls?: string): string; renderLabeledInput(children: ReactElement<any>, prefixCls?: string): JSX.Element; render(): JSX.Element; }