react-shassain-numeric
v1.0.2
Published
A react component for formatted number form fields
Downloads
12
Maintainers
Readme
react-shassain-numeric
A react component for formatted number form fields
react-shassain-numeric is a wrapper component for autonumeric.
Installition
npm install react-shassain-numeric --save
Usage
import ShassainNumeric from 'react-shassain-numeric';
export function USDMoneyInput(props){
const { value } = props; // number typed
return (
<ShassainNumeric
value={value}
currencySymbol="$"
minimumValue="0"
decimalCharacter="."
digitGroupSeparator=""
onChange={(event, value)=>{
console.log(event.target.value); // '1,234.5 $'
console.log(value); // 1234.5
}}
/>
);
}
// You can use predefinedOptions
import { predefinedOptions } from 'react-shassain-numeric';
export function PossitiveUSDMoneyInput(props){
const { value } = props; // number typed
return (
<ShassainNumeric
value={value}
preDefined={predefinedOptions.dollarPos}
onChange={(e, value)=> this.setState({ value })}
/>
);
}
// if you want to store value as string typed
export function NumberInput(props){
const { value } = props; // string typed
return (
<ShassainNumeric
value={value}
outputFormat="string"
onChange={(e, value)=> this.setState({ value })}
/>
);
}