Controlled react inputs with built-in formatting and validations
npm install react-controlled-inputsThe inputs are set to behave more like Excel cells do. When an input is focused, it will initially select the entire range.
./www)input type="text")For now, supported locales are:
* English
* French
If there is need for more, feel free to report an issue on the matter.
Any prop passed to the input will be forwarded to the actual input HTML element. You can refer to https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input for possible attributes.
Possible locale props: ["EN", "FR"] (case insensitive)
Normal text input:
``js
import { Input } from 'react-controlled-inputs';
`
Currency input:
`js
import { CurrencyInput } from 'react-controlled-inputs';
`
Percentage input:
`js
import { PercentageInput } from 'react-controlled-inputs';
`$3
input's container:
id: if passed to the Input, the container will have the same id with -container appended.
className: react-input-container
actual input:
Any className or id passed as prop is forwarded to the input HTML element. In addition, the input will have the type of input as class in lower case separated by -.CurrencyInput
* ex: for a the class currency-input will be added to the input element
To use the same formatter as used by the inputs elsewhere in your application (i.e. for a non-input numeric label):
`js
import { formatter } from 'react-controlled-inputs';
class ExampleComponent extends React.Component {
constructor(props) {
super(props);
this.f = new formatter(formatter.getSupportedLocales().EN);
}
changeLocale() {
this.f.locale = formatter.getSupportedLocales().FR;
}
}
``