1.0.1 • Published 5 years ago

number-input-lib v1.0.1

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

number-input

Library for number input

NPM JavaScript Style Guide

Install

npm install --save number-input-lib

Usage

import React, { Component } from 'react'

import NumberInput from 'number-input-lib'

class Example extends Component {
  render () {
    return (
      <NumberInput type="positive-integer"
                   onChange={(value) => console.log(value)}
                   onInvalidValue={(value) => console.log(value)}/>

      <NumberInput type="integer"
                   onChange={(value) => console.log(value)}
                   onInvalidValue={(value) => console.log(value)}/>

      <NumberInput type="positive-float"
                   onChange={(value) => console.log(value)}
                   precision={3}
                   onInvalidValue={(value) => console.log(value)}/>

      <NumberInput type="float"
                   onChange={(value) => console.log(value)}
                   precision={3}
                   onInvalidValue={(value) => console.log(value)}/>
    )
  }
}

All the properties of input tag are available to NumberInput tag. Apart from input properties some extra properties are provided based on the provided type to NumberInput.

positive-integer

S.NoPropertytypeDescription
1onInvalidInputfunctionWhen invalid value is typed then this method is called and invalid value is provided as parameter

integer

S.NoPropertytypeDescription
1onInvalidInputfunctionWhen invalid value is typed then this method is called and invalid value is provided as parameter

positive-float

S.NoPropertytypeDescription
1onInvalidInputfunctionWhen invalid value is typed then this method is called and invalid value is provided as parameter
2precisionnumberSpecify the maximum number of decimal places allowed

float

S.NoPropertytypeDescription
1onInvalidInputfunctionWhen invalid value is typed then this method is called and invalid value is provided as parameter
2precisionnumberSpecify the maximum number of decimal places allowed

##Demo Demo is available here and code for the same is available here

License

MIT © thenakliman