UNPKG

1.62 kBTypeScriptView Raw
1import * as React from 'react';
2import { ValueType } from './utils/MiniDecimal';
3export interface InputNumberProps<T extends ValueType = ValueType> extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'value' | 'defaultValue' | 'onInput' | 'onChange'> {
4 /** value will show as string */
5 stringMode?: boolean;
6 defaultValue?: T;
7 value?: T;
8 prefixCls?: string;
9 className?: string;
10 style?: React.CSSProperties;
11 min?: T;
12 max?: T;
13 step?: ValueType;
14 tabIndex?: number;
15 controls?: boolean;
16 upHandler?: React.ReactNode;
17 downHandler?: React.ReactNode;
18 keyboard?: boolean;
19 /** Parse display value to validate number */
20 parser?: (displayValue: string | undefined) => T;
21 /** Transform `value` to display value show in input */
22 formatter?: (value: T | undefined, info: {
23 userTyping: boolean;
24 input: string;
25 }) => string;
26 /** Syntactic sugar of `formatter`. Config precision of display. */
27 precision?: number;
28 /** Syntactic sugar of `formatter`. Config decimal separator of display. */
29 decimalSeparator?: string;
30 onInput?: (text: string) => void;
31 onChange?: (value: T) => void;
32 onPressEnter?: React.KeyboardEventHandler<HTMLInputElement>;
33 onStep?: (value: T, info: {
34 offset: ValueType;
35 type: 'up' | 'down';
36 }) => void;
37}
38declare const InputNumber: (<T extends ValueType = ValueType>(props: InputNumberProps<T> & {
39 children?: React.ReactNode;
40} & {
41 ref?: React.Ref<HTMLInputElement>;
42}) => React.ReactElement) & {
43 displayName?: string;
44};
45export default InputNumber;