2.2.2 • Published 7 years ago

@tillhub/numpad v2.2.2

Weekly downloads
-
License
MIT
Repository
github
Last release
7 years ago

@tillhub/numpad

Simple numpad with display field, that also acts as an optional input field. It limits unser entry to numbers (positive and negative) with up to 2 decimals. It accepts a change handler function that is called with the current text value in the input field.

NPM JavaScript Style Guide

Install

npm install --save @tillhub/numpad

Usage

import React, { Component } from 'react'

import Numpad from '@tillhub/numpad'

class Example extends Component {
  render () {
    return (
      <Numpad />
    )
  }
}

Properties

The component accepts optional properties.

Propertytyperequiredexampledefaultdescription
handleChangefunctionnotext => console.log(text)() => {}This function will be called with the current text in the input field. It is triggered on every click in the keypad and on every change in the input field.
startValuestringno'15'nullThe input field will be initiated with this value.
disabledbooleannotruefalseIf set to true, the input field and the keypad will be greyed out and disabled.
withoutInputFieldbooleannotruefalseIf set to true, the input field will merely display values but not accept manual entry.
decimalSeparatorstringno',''.'Pass in optional decimal separator. For now, only ',' is allowed as an alternative to '.'.
widthstringno'800px''400px'Determines the width of the input field and keypad. Both will have equal width.
import React, { Component } from 'react'

import Numpad from '@tillhub/numpad'

class Example extends Component {
  render () {
    return (
      <Numpad
        handleChange={text => console.log(text)}
        startValue='67.5'
        width='500px'
      />
    )
  }
}

Slots

You can pass in children to fill a slot between the input field and keypad. A use case is for example to indicate a total.

import React, { Component } from 'react'

import Numpad from '@tillhub/numpad'

class Example extends Component {
  render () {
    return (
      <Numpad>
        <div>of 200</div>
      </Numpad>
    )
  }
}

License

MIT © qtotuan

2.2.2

7 years ago

2.2.1

7 years ago

2.2.0

7 years ago

2.1.4

7 years ago

2.1.3

7 years ago

2.1.2

7 years ago

2.1.1

7 years ago

2.1.0

7 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.1.4

7 years ago

1.1.3

7 years ago

1.1.2

7 years ago

1.1.1

7 years ago

1.1.0

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago