UNPKG

2.07 kBTypeScriptView Raw
1/// <reference types="react" />
2import React from 'react';
3export interface PropsType {
4 style?: any;
5 onChange?: (e: any) => void;
6 readOnly?: boolean;
7 disabled?: boolean;
8 onFocus?: (e?: any) => void;
9 onBlur?: (e: any) => void;
10 max?: number;
11 min?: number;
12 step?: string | number;
13 parser?: (v: any) => void;
14 precision?: number;
15 value?: number;
16 defaultValue?: number;
17 autoFocus?: boolean;
18}
19export interface StateType {
20 value: number;
21 inputValue?: number;
22 focused?: boolean;
23}
24export default abstract class BaseComponent<P extends PropsType = PropsType, S extends StateType = StateType> extends React.Component<P, S> {
25 static defaultProps: {
26 max: number;
27 min: number;
28 step: number;
29 style: {};
30 onChange: () => void;
31 onFocus: () => void;
32 onBlur: () => void;
33 parser: (input: string) => string;
34 };
35 autoStepTimer: any;
36 constructor(props: P);
37 componentWillReceiveProps(nextProps: P): void;
38 componentWillUnmount(): void;
39 abstract getValueFromEvent(e: any): any;
40 onChange: (e: any) => void;
41 onFocus: (...args: any[]) => void;
42 onBlur: (e: any, ...args: any[]) => void;
43 getCurrentValidValue: (value: any) => any;
44 getValidValue: (value: any) => any;
45 setValue: (v: any, callback?: any) => void;
46 getPrecision: (value: any) => number;
47 getMaxPrecision: (currentValue: any, ratio?: number) => number;
48 getPrecisionFactor: (currentValue: any, ratio?: number) => number;
49 toPrecisionAsStep: (num: any) => any;
50 isNotCompleteNumber: (num: any) => boolean;
51 toNumber: (num: any) => any;
52 toNumberWhenUserInput: (num: any) => any;
53 stepCompute: (type: "up" | "down", val: any, rat: any) => any;
54 step: (type: "up" | "down", e: any, ratio?: number) => boolean;
55 stop: () => void;
56 action: (type: "up" | "down", e: any, ratio?: any, recursive?: any) => void;
57 down: (e: any, ratio?: any, recursive?: any) => void;
58 up: (e: any, ratio?: any, recursive?: any) => void;
59}