1.0.2 • Published 3 years ago

nullstack-currency-input v1.0.2

Weekly downloads
2
License
MIT
Repository
github
Last release
3 years ago

Nullstack Currency Input

Simple input that converts user formatted input into a number and the other way around.

Install

npm install --save nullstack-currency-input

Usage with one way binding

import Nullstack from 'nullstack';
import CurrencyInput from 'nullstack-currency-input';

class Application extends Nullstack {

  price = 10;

  updatePrice({value}) {
    this.price = value;
  }

  render() {
    return (
      <CurrencyInput name="price" value={this.price} onchange={this.updatePrice} />
    )
  }

}

export default Application;

Usage with two way binding

import Nullstack from 'nullstack';
import CurrencyInput from 'nullstack-currency-input';

class Application extends Nullstack {

  price = 10;

  render() {
    return (
      <CurrencyInput bind={this.price} />
    )
  }

}

export default Application;

Changing the separator

The default separator is a "."

You can override it by passing a separator attribute to the input

<CurrencyInput bind={this.price} separator="," />

Customization

You can customize the following attributes:

  • id
  • class
  • placeholder
  • disabled
  • data-*

License

Nullstack Currency Input is released under the MIT License.