@up-group-ui/react-controls
Version:
Up shared react controls
64 lines (63 loc) • 2.52 kB
TypeScript
import * as React from 'react';
import ValidationManager from '../Validation/ValidationManager';
import { ErrorDisplayMode } from '../Validation/ErrorDisplay';
import { Tooltip } from '../../../Display/Tooltip';
import { WithThemeProps } from '../../../../Common/theming/withTheme';
import { TestableComponentProps } from '../../../../Common/utils/types';
declare type RenderHelp = (children: React.ReactNode) => JSX.Element;
declare type HandlerShowError = (state: any) => boolean;
export interface BaseControlProps<_BaseType> extends TestableComponentProps, WithThemeProps {
name?: string;
onChange?: (event: React.ChangeEvent<any>, arg: _BaseType, error: string) => void;
value?: _BaseType;
defaultValue?: _BaseType;
disabled?: boolean;
readonly?: boolean;
tooltip?: string | Tooltip;
isRequired?: boolean;
showError?: boolean | HandlerShowError;
hasError?: boolean;
showSuccess?: boolean;
errorDisplayMode?: ErrorDisplayMode;
error?: string;
touched?: boolean;
helpMessage?: string | RenderHelp;
tabIndex?: number;
onClear?: () => void;
maxCharMsg?: string;
maxCharMsgShowNumber?: number;
forceMaxChar?: boolean;
}
export interface BaseControlState<_BaseType> {
error?: string;
value?: _BaseType;
extra?: any;
}
export declare abstract class BaseControlComponent<_Props, _BaseType> extends React.Component<BaseControlProps<_BaseType> & _Props, BaseControlState<_BaseType>> {
_validationManager: ValidationManager;
static defaultProps: BaseControlProps<any>;
constructor(props?: BaseControlProps<_BaseType> & _Props, context?: any);
private initWithProps;
protected registerValidations(): void;
abstract getValue(args: any): _BaseType;
protected setValue: (receiveValue: any) => _BaseType;
get isControlled(): boolean;
get currentValue(): _BaseType;
abstract renderControl(): JSX.Element;
private checkAndDispatch;
validateProps(nextProps: any): void;
handleChangeEvent: (event: React.ChangeEvent<any>, value?: _BaseType) => void;
handleClearEvent: (value: _BaseType) => void;
private checkData;
get hasError(): boolean;
abstract showError(): any;
abstract showSuccess(): any;
get error(): string;
onFocus: (event: any) => void;
onBlur: (event: any) => void;
get isFocused(): boolean;
get isTouched(): boolean;
render(): any;
dispatchOnChange: (data: _BaseType, event: React.ChangeEvent<any>, error: string) => void;
}
export {};