UNPKG

2.22 kBTypeScriptView Raw
1import { ValueType } from '@rc-component/mini-decimal';
2import * as React from 'react';
3export type { ValueType };
4export interface InputNumberProps<T extends ValueType = ValueType> extends Omit<React.InputHTMLAttributes<HTMLInputElement>, 'value' | 'defaultValue' | 'onInput' | 'onChange' | 'prefix' | 'suffix'> {
5 /** value will show as string */
6 stringMode?: boolean;
7 defaultValue?: T;
8 value?: T | null;
9 prefixCls?: string;
10 className?: string;
11 style?: React.CSSProperties;
12 min?: T;
13 max?: T;
14 step?: ValueType;
15 tabIndex?: number;
16 controls?: boolean;
17 prefix?: React.ReactNode;
18 suffix?: React.ReactNode;
19 addonBefore?: React.ReactNode;
20 addonAfter?: React.ReactNode;
21 classes?: {
22 affixWrapper?: string;
23 group?: string;
24 wrapper?: string;
25 };
26 classNames?: {
27 affixWrapper?: string;
28 group?: string;
29 wrapper?: string;
30 input?: string;
31 };
32 upHandler?: React.ReactNode;
33 downHandler?: React.ReactNode;
34 keyboard?: boolean;
35 /** Parse display value to validate number */
36 parser?: (displayValue: string | undefined) => T;
37 /** Transform `value` to display value show in input */
38 formatter?: (value: T | undefined, info: {
39 userTyping: boolean;
40 input: string;
41 }) => string;
42 /** Syntactic sugar of `formatter`. Config precision of display. */
43 precision?: number;
44 /** Syntactic sugar of `formatter`. Config decimal separator of display. */
45 decimalSeparator?: string;
46 onInput?: (text: string) => void;
47 onChange?: (value: T | null) => void;
48 onPressEnter?: React.KeyboardEventHandler<HTMLInputElement>;
49 onStep?: (value: T, info: {
50 offset: ValueType;
51 type: 'up' | 'down';
52 }) => void;
53 /**
54 * Trigger change onBlur event.
55 * If disabled, user must press enter or click handler to confirm the value update
56 */
57 changeOnBlur?: boolean;
58}
59declare const InputNumber: (<T extends ValueType = ValueType>(props: InputNumberProps<T> & {
60 children?: React.ReactNode;
61} & {
62 ref?: React.Ref<HTMLInputElement>;
63}) => React.ReactElement) & {
64 displayName?: string;
65};
66export default InputNumber;