UNPKG

react-hook-currency

Version:

> This libraries propose to introduce two pseudo hooks, one capable of format currencies and another capable to simulate a cash register.

22 lines (21 loc) 911 B
import * as React from 'react'; import { Locales, Currencies } from '../constants'; export declare type CurrencyProps = { style?: 'currency' | 'decimal'; precision?: number; locale?: Locales | string; currency?: Currencies | string; negative?: 'allow' | 'always' | 'never'; }; export declare type ClickEvent = React.MouseEvent<HTMLInputElement, MouseEvent>; export declare type ChangeEvent = React.ChangeEvent<HTMLInputElement>; export declare type KeyboardEvent = React.KeyboardEvent<HTMLInputElement>; export declare type ReturnCurrency = { format: (rawVal: string) => string; onClick: (e: ClickEvent) => void; onChange: (e: ChangeEvent) => void; onKeyDown: (e: KeyboardEvent) => void; toNumber: (currency: string) => number; decimalSeparator: string; }; export declare const useCurrency: (props?: CurrencyProps | undefined) => ReturnCurrency;