# reduce-mask

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

Latest version **1.2.5** (published 2018-06-05) · MIT license · 0 weekly downloads

## Install

```sh
npm install reduce-mask
pnpm add reduce-mask
yarn add reduce-mask
bun add reduce-mask
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.5 |
| Published | 2018-06-05 |
| First published | 2017-08-28 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 23.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | NPM reduce-mask |
| Maintainers | heyderpd |
| Keywords | input, mask, react, simple, fast, reduce, light |

## Links

- npm: https://www.npmjs.com/package/reduce-mask
- Repository: https://github.com/heyderpd/npm-reduce-mask
- Homepage: https://github.com/heyderpd/npm-reduce-mask#readme
- Issues: https://github.com/heyderpd/npm-reduce-mask/issues
- npm.io page: https://npm.io/package/reduce-mask

## Dependencies (2)

- [react](https://npm.io/package/react.md) ^16.4.0
- [pytils](https://npm.io/package/pytils.md) ^1.40.3

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.2.5 (latest) — 2018-06-05
- 1.2.4 — 2018-06-05
- 1.2.3 — 2018-05-30
- 1.2.2 — 2018-05-30
- 1.2.1 — 2018-05-29
- 1.2.0 — 2018-05-29
- 1.1.1 — 2018-05-29
- 1.1.0 — 2018-05-22
- 1.0.0 — 2018-05-21
- 0.7.9 — 2018-01-24
- 0.7.8 — 2018-01-24
- 0.7.7 — 2018-01-23
- 0.7.6 — 2017-09-25
- 0.7.5 — 2017-09-25
- 0.7.4 — 2017-09-25
- … 10 more at https://npm.io/package/reduce-mask/versions

## README

# 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](https://github.com/heyderpd). I'll be glad to help you.

## Thanks for [npm~lucasmreis](https://www.npmjs.com/~lucasmreis)

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

![ScreenShot](https://raw.githubusercontent.com/heyderpd/npm-reduce-mask/master/example.gif)
![ScreenShot](https://raw.githubusercontent.com/heyderpd/npm-reduce-mask/master/mult-mask.gif)

Example of Mult Mask:
```javascript
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:
```javascript
<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}
/>
```

---
_Source: https://npm.io/package/reduce-mask · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
