UNPKG

redux-form-numeric-field

Version:

a customized redux-form Field for entering numbers

73 lines (72 loc) 4.25 kB
import * as React from 'react'; import type { BaseFieldProps, WrappedFieldProps } from 'redux-form'; type NumberNormalizer = (value?: (string | number) | null | undefined) => (string | number) | null | undefined; type AdditionalProps = { input: { onKeyDown?: React.KeyboardEventHandler<any>; }; }; type BaseNumericFieldProps<P = {}> = BaseFieldProps<P & AdditionalProps> & { normalizeOnBlur?: any; normalizeNumber?: NumberNormalizer; }; export default function createNumericField(Field: React.ComponentType<BaseFieldProps<AdditionalProps>>): { new <P extends BaseNumericFieldProps<{}> = BaseNumericFieldProps<{}>>(props: P | Readonly<P>): { normalizeOnBlur: (value: any) => any; validate: (value: any, allValues: any, props: any, name: string) => string | null | undefined; KeyDownHandler: ({ input, onKeyDown, ...props }: WrappedFieldProps & { onKeyDown?: React.KeyboardEventHandler<any> | undefined; }) => React.ReactElement; render(): React.ReactElement; context: unknown; setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<P>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void; forceUpdate(callback?: (() => void) | undefined): void; readonly props: Readonly<P>; state: Readonly<{}>; refs: { [key: string]: React.ReactInstance; }; componentDidMount?(): void; shouldComponentUpdate?(nextProps: Readonly<P>, nextState: Readonly<{}>, nextContext: any): boolean; componentWillUnmount?(): void; componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void; getSnapshotBeforeUpdate?(prevProps: Readonly<P>, prevState: Readonly<{}>): any; componentDidUpdate?(prevProps: Readonly<P>, prevState: Readonly<{}>, snapshot?: any): void; componentWillMount?(): void; UNSAFE_componentWillMount?(): void; componentWillReceiveProps?(nextProps: Readonly<P>, nextContext: any): void; UNSAFE_componentWillReceiveProps?(nextProps: Readonly<P>, nextContext: any): void; componentWillUpdate?(nextProps: Readonly<P>, nextState: Readonly<{}>, nextContext: any): void; UNSAFE_componentWillUpdate?(nextProps: Readonly<P>, nextState: Readonly<{}>, nextContext: any): void; }; new <P extends BaseNumericFieldProps<{}> = BaseNumericFieldProps<{}>>(props: P, context: any): { normalizeOnBlur: (value: any) => any; validate: (value: any, allValues: any, props: any, name: string) => string | null | undefined; KeyDownHandler: ({ input, onKeyDown, ...props }: WrappedFieldProps & { onKeyDown?: React.KeyboardEventHandler<any> | undefined; }) => React.ReactElement; render(): React.ReactElement; context: unknown; setState<K extends never>(state: {} | ((prevState: Readonly<{}>, props: Readonly<P>) => {} | Pick<{}, K> | null) | Pick<{}, K> | null, callback?: (() => void) | undefined): void; forceUpdate(callback?: (() => void) | undefined): void; readonly props: Readonly<P>; state: Readonly<{}>; refs: { [key: string]: React.ReactInstance; }; componentDidMount?(): void; shouldComponentUpdate?(nextProps: Readonly<P>, nextState: Readonly<{}>, nextContext: any): boolean; componentWillUnmount?(): void; componentDidCatch?(error: Error, errorInfo: React.ErrorInfo): void; getSnapshotBeforeUpdate?(prevProps: Readonly<P>, prevState: Readonly<{}>): any; componentDidUpdate?(prevProps: Readonly<P>, prevState: Readonly<{}>, snapshot?: any): void; componentWillMount?(): void; UNSAFE_componentWillMount?(): void; componentWillReceiveProps?(nextProps: Readonly<P>, nextContext: any): void; UNSAFE_componentWillReceiveProps?(nextProps: Readonly<P>, nextContext: any): void; componentWillUpdate?(nextProps: Readonly<P>, nextState: Readonly<{}>, nextContext: any): void; UNSAFE_componentWillUpdate?(nextProps: Readonly<P>, nextState: Readonly<{}>, nextContext: any): void; }; contextType?: React.Context<any> | undefined; }; export {};