UNPKG

zent

Version:

一套前端设计语言和基于React的实现

86 lines (85 loc) 2.67 kB
import { Component } from 'react'; import Decimal from 'big.js'; import Input, { IInputCoreProps } from '../input'; import { IDisabledContext } from '../disabled'; export interface INumberInputCommonProps extends Omit<IInputCoreProps, 'onChange' | 'type' | 'value' | 'onInput'> { type?: 'number'; showStepper?: boolean; showCounter?: boolean; step?: number; showTooltip?: boolean; } export interface INumberInputDecimalProps extends INumberInputCommonProps { integer?: false; value?: string | number; onChange?: (value: string) => void; decimal?: number; onInput?: (value: string) => void; min?: number | string; } export interface INumberInputIntegerProps extends INumberInputCommonProps { integer: true; value?: number | null; onChange?: (value: number | null) => void; min?: number; max?: number; onInput?: (value: string) => void; } export declare type INumberInputProps = INumberInputDecimalProps | INumberInputIntegerProps; export interface INumberInputIntegerState { prevProps: INumberInputIntegerProps; value: number | null; input: string; min: number; max: number; delta: number; pop?: { visible: boolean; text: string; type: string; }; } export interface INumberInputDecimalState { prevProps: INumberInputDecimalProps; value: Decimal; input: string; min: Decimal | null; max: Decimal | null; delta: Decimal; pop?: { visible: boolean; text: string | number; type: string; }; } export declare type INumberInputState = INumberInputIntegerState | INumberInputDecimalState; export declare class NumberInput extends Component<INumberInputProps, INumberInputState> { static defaultProps: { integer: boolean; type: string; decimal: number; size: string; }; static contextType: import("react").Context<IDisabledContext>; context: IDisabledContext; focused: boolean; timer: any; inputRef: import("react").RefObject<Input>; private inputContext; constructor(props: INumberInputProps); private onUserInput; private onFocus; private hideTooltip; private onBlur; private step; private inc; private dec; static getDerivedStateFromProps(props: INumberInputProps, prevState: INumberInputState): Partial<INumberInputState> | null; private checkPropsValue; componentDidMount(): void; componentDidUpdate(prevProps: INumberInputProps): void; renderChild(children: React.ReactNode): JSX.Element; renderInput(): JSX.Element; render(): JSX.Element; } export default NumberInput;