@start-base/react-form-elements
Version:
Simplify form elements and form management. Selection of user friendly inputs and wide customization abilities to match your design and functionality.
60 lines (56 loc) • 1.93 kB
TypeScript
import React, { ElementType } from 'react';
import { FieldError } from 'react-hook-form';
type Overwrite<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U;
interface CurrencyInputOnChangeValues {
float: number | null;
formatted: string;
value: string;
}
interface IntlConfig {
locale: string;
currency?: string;
}
type AmountInputRootProps = Overwrite<React.ComponentPropsWithRef<'input'>, {
allowDecimals?: boolean;
allowNegativeValue?: boolean;
id?: string;
maxLength?: number;
className?: string;
customInput?: ElementType;
decimalsLimit?: number;
decimalScale?: number;
defaultValue?: number | string;
disabled?: boolean;
fixedDecimalLength?: number;
onValueChange?: (value: string | undefined, name?: string, values?: CurrencyInputOnChangeValues) => void;
placeholder?: string;
prefix?: string;
suffix?: string;
step?: number;
decimalSeparator?: string;
groupSeparator?: string;
disableGroupSeparators?: boolean;
disableAbbreviations?: boolean;
intlConfig?: IntlConfig;
transformRawValue?: (rawValue: string) => string;
formatValueOnBlur?: boolean;
}>;
interface AmountInputProps extends AmountInputRootProps {
name: string;
error?: boolean | string | {
message?: string;
} | null | undefined | FieldError;
label?: string | null;
value?: string | number | readonly string[] | undefined;
inputClassName?: string | null;
labelClassName?: string | null;
errorClassName?: string | null;
prepend?: React.ReactNode | null;
prependClassName?: string | null;
append?: React.ReactNode | null;
appendClassName?: string | null;
disableShrink?: boolean;
disabled?: boolean;
}
declare const AmountInput: React.ForwardRefExoticComponent<Omit<AmountInputProps, "ref"> & React.RefAttributes<HTMLInputElement>>;
export { type AmountInputProps, AmountInput as default };