1.2.5 • Published 6 years ago

reduce-mask v1.2.5

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

REDUCE MASK

Simple and light mask in react, can use mult mask for same input.

This mask don't break your cursor, will re position the cursosr to relative final position.

  • Work in Mobile, Safari, Mozila etc.
  • Re position text cursor to relative position.
  • Return evt with masked and unmasked value.
  • Accept multiple masks, use the mask best fits for the value.
  • Will update if change mask, defaultValue, onChange

in the future:

Other formats than numbers

I will help if you have any difficulty =)

Contact me by github:heyderpd. I'll be glad to help you.

Thanks for npm~lucasmreis

  • The mask accept only number in this version
  • Mask accept any char, but '_' is a placeholder for the number

ScreenShot ScreenShot

Example of Mult Mask:

import ReduceMask from 'reduce-mask'

const onChange = evt => {
  const { value, maskedValue } = evt.target
  /*
    value = '12345678912'
    maskedValue = '123.456.789-12'

    do your this.setState(evt)
  */
}

<ReduceMask
  name='cpf/cnpj'
  mask={['___.___.___-__', '__.___.___/____-__']}
  placeholder='Ex: 123.456.789-12'
  defaultValue='12345678912'
  onChange={onChange}
/>

Example:

<ReduceMask
  name='phone'
  mask='(__) ____-_____'
  placeholder='Ex: (99) 1234-5678'
  defaultValue='9912345678'
  onChange={onChange}
/>

<ReduceMask
  name='cpf'
  mask='___.___.___-__'
  placeholder='Ex: 123.456.789-12'
  onChange={onChange}
/>

<ReduceMask
  name='cnpj'
  mask='__.___.___/____-__'
  placeholder='Ex: 12.456.789/1234-56'
  onChange={onChange}
/>
1.2.5

6 years ago

1.2.4

6 years ago

1.2.3

6 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago

0.7.9

6 years ago

0.7.8

6 years ago

0.7.7

6 years ago

0.7.6

7 years ago

0.7.5

7 years ago

0.7.4

7 years ago

0.7.3

7 years ago

0.7.2

7 years ago

0.7.1

7 years ago

0.7.0

7 years ago

0.5.1

7 years ago

0.5.0

7 years ago

0.1.5

7 years ago

0.1.1

7 years ago

0.1.0

7 years ago

0.0.0

7 years ago