UNPKG

react-numberinput

Version:

React Number input component. Allow to input formatted number values. Also you can use this component as example of inputCore component with reformat user function

43 lines (42 loc) 1.44 kB
import * as React from 'react'; import { IInputState, IInputValue, ISelectRange } from 'input-core'; interface IInputProps { value?: string; reformat?: (params: { value: Array<IInputValue>; input?: string; selection: ISelectRange; }) => IInputState; defaultValue?: string; onChange?: (e: React.SyntheticEvent) => void; onValueChange?: (params: { maskedValue: string; value: string; }) => void; getReference?: (el: HTMLInputElement) => void; onFocus?: (e: React.FocusEvent) => void; onBlur?: (e: React.FocusEvent) => void; removeOnlyZeroString?: boolean; } /** * Component that allow to format only numbers. (5 000, 123 456 789, etc.) * This component work on top of react-maskinput and define custom formatting function called `reformat`. * Also you can use this component as example to create you own components based on react-maskinput. */ declare class NumberInput extends React.Component<IInputProps> { applyValue: any; reformat: ({ value, input, selection }: { value: string; input?: string; selection: ISelectRange; }) => { value: string; maskedValue: string; visibleValue: string; selection: ISelectRange; }; handleLeadingZeros: (e: any) => void; getCallback: (applyValue: (value: string) => void) => void; render(): JSX.Element; } export default NumberInput;