/** @packageDocumentation * @module Inputs */ import * as React from "react"; import { CommonProps } from "../../utils/Props"; import { Omit } from "../../utils/typeUtils"; /** Bounds function prototype for [[NumericInput]] component * @beta @deprecated use NumberInput */ export declare type BoundsFunctionProp = number | (() => number | undefined); /** @internal @deprecated use NumberInput */ export declare type ReactStepFunctionProp = number | ((component: ReactNumericInput, direction: string) => number | undefined); /** Base properties for the [[NumericInput]] component * @beta @deprecated use NumberInput */ export interface ReactNumericInputProps extends Omit, "min" | "max" | "step" | "onChange" | "defaultValue" | "onInvalid">, CommonProps { componentClass?: string; defaultValue?: number | string; format?: ((value: number | null, strValue: string) => string); max?: BoundsFunctionProp; maxLength?: number; min?: BoundsFunctionProp; mobile?: boolean | "auto" | (() => boolean); noStyle?: boolean; noValidate?: boolean | string; onBlur?: React.FocusEventHandler; onChange?: ((value: number | null, stringValue: string, input: HTMLInputElement) => void); onFocus?: React.FocusEventHandler; onInput?: React.FormEventHandler; onInvalid?: ((error: string, value: number | null, stringValue: string) => void); onKeyDown?: React.KeyboardEventHandler; onSelect?: React.ReactEventHandler; onValid?: ((value: number | null, stringValue: string) => void); parse?: ((value: string) => number | null); precision?: number | (() => number | null | undefined); snap?: boolean; /** @internal */ step?: ReactStepFunctionProp; strict: boolean; value?: number | string; /** Indicates whether to set focus to the input element */ setFocus?: boolean; } /** @internal */ interface ReactNumericInputState { selectionStart?: number | null; selectionEnd?: number | null; btnDownHover?: boolean; btnDownActive?: boolean; btnUpHover?: boolean; btnUpActive?: boolean; value?: number | null; stringValue?: string; } /** @internal @deprecated use NumberInput */ export declare class ReactNumericInput extends React.Component { /** * The default behavior is to start from 0, use step of 1 and display * integers */ static defaultProps: { step: number; min: number; max: number; precision: null; parse: null; format: null; mobile: string; strict: boolean; componentClass: string; style: {}; }; /** * This are the default styles that act as base for all the component * instances. One can modify this object to change the default styles * of all the widgets on the page. */ private static _style; /** * When click and hold on a button - the speed of auto changing the value. * This is a static property and can be modified if needed. */ static SPEED: number; /** * When click and hold on a button - the delay before auto changing the value. * This is a static property and can be modified if needed. */ static DELAY: number; /** * The constant indicating up direction (or increasing in general) */ static DIRECTION_UP: string; /** * The constant indicating down direction (or decreasing in general) */ static DIRECTION_DOWN: string; /** * The step timer * @type {number} */ private _timer; /** * This holds the last known validation error. We need to compare that with * new errors and detect validation changes... * @type {string} */ private _valid; private _isStrict; private _ignoreValueChange; private _isUnmounted; private _inputFocus; private _refsWrapper?; /** @internal */ refsInput: HTMLInputElement | undefined; /** * Set the initial state and bind this._stop to the instance. */ constructor(props: ReactNumericInputProps); private _propsToState; /** * After the component has been rendered into the DOM, do whatever is * needed to "reconnect" it to the outer world, i.e. restore selection, * call some of the callbacks, validate etc. */ componentDidUpdate(prevProps: ReactNumericInputProps, prevState: ReactNumericInputState): void; /** * This is used to clear the timer if any */ componentWillUnmount(): void; /** * Adds getValueAsNumber and setValue methods to the input DOM element. */ componentDidMount(): void; /** * Unless noValidate is set to true, the component will check the * existing validation state (if any) and will toggle the "has-error" * CSS class on the wrapper */ private checkValidity; /** * Used internally to parse the argument x to it's numeric representation. * If the argument cannot be converted to finite number returns 0; If a * "precision" prop is specified uses it round the number with that * precision (no fixed precision here because the return value is float, not * string). */ private _toNumber; /** * This is used internally to parse any string into a number. It will * delegate to this.props.parse function if one is provided. Otherwise it * will just use parseFloat. */ private _parse; /** * This is used internally to format a number to its display representation. * It will invoke the this.props.format function if one is provided. */ private _format; /** * The internal method that actually sets the new value on the input */ private _step; /** * This binds the Up/Down arrow key listeners */ private _onKeyDown; /** * Stops the widget from auto-changing by clearing the timer (if any) */ private _stop; /** * Increments the value with one step and the enters a recursive calls * after DELAY. This is bound to the mousedown event on the "up" button * and will be stopped on mouseout/mouseup. * @param {boolean} _recursive The method is passing this to itself while * it is in recursive mode. * @return void */ private increase; /** * Decrements the value with one step and the enters a recursive calls * after DELAY. This is bound to the mousedown event on the "down" button * and will be stopped on mouseout/mouseup. * @param {boolean} _recursive The method is passing this to itself while * it is in recursive mode. * @return void */ private decrease; /** * Handles the mousedown event on the up/down buttons. Changes The * internal value and sets up a delay for auto increment/decrement * (until mouseup or mouseleave) */ private onMouseDown; /** * Handles the touchstart event on the up/down buttons. Changes The * internal value and DOES NOT sets up a delay for auto increment/decrement. * Note that this calls e.preventDefault() so the event is not used for * creating a virtual mousedown after it */ private onTouchStart; private _onTouchEnd; /** * Helper method to invoke event callback functions if they are provided * in the props. * @param {string} callbackName The name of the function prop * @param {*[]} args Any additional argument are passed thru */ private _invokeEventCallback; /** * Renders an input wrapped in relative span and up/down buttons * @return {Element} */ render(): JSX.Element; } export {}; //# sourceMappingURL=ReactNumericInput.d.ts.map