Skip to content

Latest commit

 

History

History
82 lines (56 loc) · 3.44 KB

README.md

File metadata and controls

82 lines (56 loc) · 3.44 KB

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.No Property type Description
1 onInvalidInput function When invalid value is typed then this
method is called and invalid value is
provided as parameter

integer

S.No Property type Description
1 onInvalidInput function When invalid value is typed then this
method is called and invalid value is
provided as parameter

positive-float

S.No Property type Description
1 onInvalidInput function When invalid value is typed then this
method is called and invalid value is
provided as parameter
2 precision number Specify the maximum number of decimal
places allowed

float

S.No Property type Description
1 onInvalidInput function When invalid value is typed then this
method is called and invalid value is
provided as parameter
2 precision number Specify the maximum number of decimal
places allowed

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

License

MIT © thenakliman