use-mask-input 3.1.0 → 3.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,28 +1,24 @@
1
- # use-mask-input
1
+ # 🥸 use-mask-input
2
2
 
3
- [![NPM](https://img.shields.io/npm/v/use-mask-input.svg)](https://www.npmjs.com/package/use-mask-input) [![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com) [![Bundle Size](https://badgen.net/bundlephobia/minzip/use-mask-input)](https://bundlephobia.com/result?p=use-mask-input)
3
+ [![NPM](https://img.shields.io/npm/v/use-mask-input.svg)](https://www.npmjs.com/package/use-mask-input) [![Bundle Size](https://badgen.net/bundlephobia/minzip/use-mask-input)](https://bundlephobia.com/result?p=use-mask-input)
4
4
 
5
5
  A React Hook for build elegant and simple input masks.
6
6
 
7
- ## Todo
8
- - [x] Add react-final-form support
9
- - [x] Simplify API
10
- - [ ] Make tests :P
11
- - [ ] Better example page with GH pages
12
-
7
+ ---
13
8
 
14
9
  ## Features
15
-
10
+ - 🎯 Simple API
16
11
  - ✨ Compatible with [React Hook Form](https://github.com/react-hook-form/react-hook-form)
17
12
  - 🏁 Compatible with [React Final Form](https://github.com/final-form/react-final-form)
18
- - 🎯 Simple API
13
+
14
+ ## Know Issues
15
+
16
+ - Not compatible with Next.js, but we are working on it
19
17
 
20
18
  ## Install
21
19
 
22
- ```bash
23
- npm install --save use-mask-input
24
- ## or
25
- yarn add use-mask-input
20
+ ```sh
21
+ npm i use-mask-input
26
22
  ```
27
23
 
28
24
  ## Quickstart
@@ -64,10 +60,12 @@ function App() {
64
60
 
65
61
  ## Usage with React Final Form
66
62
 
63
+ Just use `withMask` normaly.
64
+
67
65
  ```jsx
68
66
  import React from 'react';
69
67
  import { Form, Field } from 'react-final-form';
70
- import { withHookFormMask } from 'use-mask-input';
68
+ import { withMask } from 'use-mask-input';
71
69
 
72
70
  function App() {
73
71
  ...
@@ -89,7 +87,3 @@ function App() {
89
87
  );
90
88
  }
91
89
  ```
92
-
93
- ## License
94
-
95
- MIT © [eduardoborges](https://github.com/eduardoborges)
package/dist/index.cjs CHANGED
@@ -6,9 +6,23 @@ var react = require('react');
6
6
  var Inputmask = require('inputmask');
7
7
 
8
8
  const isServer = !(typeof window !== 'undefined' && window.document && window.document.createElement);
9
- const compose = (fn1, ...fns)=>fns.reduce((prevFn, nextFn)=>(value)=>prevFn(nextFn(value)), fn1);
10
- const sum = compose((x)=>x + 1, (x)=>x + 1);
11
- console.log(sum(1));
9
+ function flow(...funcs) {
10
+ const { length } = funcs;
11
+ let index = length;
12
+ while(index--){
13
+ if (typeof funcs[index] !== 'function') {
14
+ throw new TypeError('Expected a function');
15
+ }
16
+ }
17
+ return (...args)=>{
18
+ let i = 0;
19
+ let result = length ? funcs[i].apply(this, args) : args[0];
20
+ while(++i < length){
21
+ result = funcs[i].call(this, result);
22
+ }
23
+ return result;
24
+ };
25
+ }
12
26
 
13
27
  function _define_property$2(obj, key, value) {
14
28
  if (key in obj) {
@@ -119,10 +133,9 @@ const withHookFormMask = (register, mask, options)=>{
119
133
  if (register) {
120
134
  const { ref } = register;
121
135
  const maskInput = Inputmask(_object_spread$1({
122
- mask,
123
- jitMasking: true
136
+ mask: mask || undefined
124
137
  }, options));
125
- newRef = compose((_ref)=>{
138
+ newRef = flow((_ref)=>{
126
139
  if (_ref) maskInput.mask(_ref);
127
140
  return _ref;
128
141
  }, ref);
@@ -164,7 +177,7 @@ const withMask = (mask, options)=>(input)=>{
164
177
  //
165
178
  if (isServer) return input;
166
179
  const maskInput = Inputmask(_object_spread({
167
- mask
180
+ mask: mask || undefined
168
181
  }, options));
169
182
  if (input) {
170
183
  maskInput.mask(input);
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","sources":["../src/utils.ts","../src/useMaskInput.ts","../src/withHookFormMask.ts","../src/withMask.ts"],"sourcesContent":["export const isServer = !(\n typeof window !== 'undefined'\n && window.document\n && window.document.createElement\n);\n\nexport const pipe = <T extends any[], R>(\n fn1: (...args: T) => R,\n ...fns: Array<(a: R) => R>\n) => {\n const piped = fns.reduce(\n (prevFn, nextFn) => (value: R) => nextFn(prevFn(value)),\n (value) => value,\n );\n return (...args: T) => piped(fn1(...args));\n};\n\nexport const compose = <R>(\n fn1: (a: R) => R, ...fns: Array<(a: R) => R>\n) => fns.reduce((prevFn, nextFn) => (value) => prevFn(nextFn(value)), fn1);\n\nconst sum = compose(\n (x: number) => x + 1,\n (x: number) => x + 1,\n);\n\nconsole.log(sum(1));\n","import { useEffect, useRef } from 'react';\nimport Inputmask from 'inputmask';\nimport { isServer } from './utils';\n\ninterface UseInputMaskOptions {\n mask: Inputmask.Options['mask']\n register?(element: HTMLElement): void\n options?: Inputmask.Options\n}\n\nconst useInputMask = (props: UseInputMaskOptions) => {\n const { mask, register, options } = props;\n const ref = useRef<HTMLInputElement>(null);\n if (isServer) return ref;\n\n useEffect(() => {\n if (!isServer) {\n if (!ref.current) return;\n\n const maskInput = Inputmask({\n mask,\n ...options,\n });\n\n maskInput.mask(ref.current);\n\n if (register && ref.current) {\n register(ref.current);\n }\n }\n }, [mask, register, options]);\n\n return ref;\n};\n\nexport default useInputMask;\n","import Inputmask from 'inputmask';\n\nimport { compose } from './utils';\nimport { Mask, Options, Register } from './types';\n\nexport const withHookFormMask = (register: Register, mask: Mask, options?: Options) => {\n //\n let newRef;\n\n if (register) {\n const { ref } = register;\n\n const maskInput = Inputmask({\n mask,\n jitMasking: true,\n ...options,\n });\n\n newRef = compose((_ref: HTMLElement) => {\n if (_ref) maskInput.mask(_ref);\n return _ref;\n }, ref);\n }\n\n return {\n ...register,\n ref: newRef,\n };\n};\n","import Inputmask from 'inputmask';\nimport { isServer } from './utils';\nimport { Input, Mask, Options } from './types';\n\nexport const withMask = (mask: Mask, options?: Options) => (input: Input) => {\n //\n if (isServer) return input;\n\n const maskInput = Inputmask({\n mask,\n ...options,\n });\n\n if (input) {\n maskInput.mask(input);\n }\n\n return input;\n};\n"],"names":["isServer","window","document","createElement","compose","fn1","fns","reduce","prevFn","nextFn","value","sum","x","console","log","useInputMask","props","mask","register","options","ref","useRef","useEffect","current","maskInput","Inputmask","_object_spread","withHookFormMask","newRef","jitMasking","_ref","withMask","input"],"mappings":";;;;;;;AAAO,MAAMA,QAAAA,GAAW,EACtB,OAAOC,MAAW,KAAA,WAAA,IACfA,MAAOC,CAAAA,QAAQ,IACfD,MAAOC,CAAAA,QAAQ,CAACC,aAAa,CAChC,CAAA;AAaK,MAAMC,OAAU,GAAA,CACrBC,GAAkB,EAAA,GAAGC,MAClBA,GAAIC,CAAAA,MAAM,CAAC,CAACC,QAAQC,MAAW,GAAA,CAACC,QAAUF,MAAOC,CAAAA,MAAAA,CAAOC,SAASL,GAAK,CAAA,CAAA;AAE3E,MAAMM,GAAAA,GAAMP,QACV,CAACQ,CAAAA,GAAcA,IAAI,CACnB,EAAA,CAACA,IAAcA,CAAI,GAAA,CAAA,CAAA,CAAA;AAGrBC,OAAQC,CAAAA,GAAG,CAACH,GAAI,CAAA,CAAA,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AChBVI,MAAAA,YAAAA,GAAe,CAACC,KAA+B,GAAA;AACnD,IAAA,MAAM,EAAEC,IAAI,GAAEC,WAAUC,OAAAA,GAAS,GAAGH,KAAAA,CAAAA;IACpC,MAAMI,GAAAA,GAAMC,aAAyB,IAAI,CAAA,CAAA;AACzC,IAAA,IAAIrB,UAAU,OAAOoB,GAAAA,CAAAA;AAErBE,IAAAA,eAAAA,CAAU,IAAM;AACd,QAAA,IAAI,CAACtB,QAAU,EAAA;YACb,IAAI,CAACoB,GAAIG,CAAAA,OAAO,EAAE,OAAA;AAElB,YAAA,MAAMC,YAAYC,SAAU,CAAAC,gBAAA,CAAA;AAC1BT,gBAAAA,IAAAA;AACGE,aAAAA,EAAAA,OAAAA,CAAAA,CAAAA,CAAAA;YAGLK,SAAUP,CAAAA,IAAI,CAACG,GA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BR,YAAAA,IAAAA;AACGE,SAAAA,EAAAA,OAAAA,CAAAA,CAAAA,CAAAA;AAGL,QAAA,IAAIa,KAAO,EAAA;AACTR,YAAAA,SAAAA,CAAUP,IAAI,CAACe,KAAAA,CAAAA,CAAAA;SAChB;QAED,OAAOA,KAAAA,CAAAA;;;;;;;"}
1
+ {"version":3,"file":"index.cjs","sources":["../src/utils.ts","../src/useMaskInput.ts","../src/withHookFormMask.ts","../src/withMask.ts"],"sourcesContent":["export const isServer = !(\n typeof window !== 'undefined'\n && window.document\n && window.document.createElement\n);\n\nexport function flow(...funcs: Array<Function>) : Function {\n const { length } = funcs;\n let index = length;\n while (index--) {\n if (typeof funcs[index] !== 'function') {\n throw new TypeError('Expected a function');\n }\n }\n return (...args: Array<Function>) => {\n let i = 0;\n let result = length ? funcs[i].apply(this, args) : args[0];\n while (++i < length) {\n result = funcs[i].call(this, result);\n }\n return result;\n };\n}\n","import { useEffect, useRef } from 'react';\nimport Inputmask from 'inputmask';\nimport { isServer } from './utils';\n\ninterface UseInputMaskOptions {\n mask: Inputmask.Options['mask']\n register?(element: HTMLElement): void\n options?: Inputmask.Options\n}\n\nconst useInputMask = (props: UseInputMaskOptions) => {\n const { mask, register, options } = props;\n const ref = useRef<HTMLInputElement>(null);\n if (isServer) return ref;\n\n useEffect(() => {\n if (!isServer) {\n if (!ref.current) return;\n\n const maskInput = Inputmask({\n mask,\n ...options,\n });\n\n maskInput.mask(ref.current);\n\n if (register && ref.current) {\n register(ref.current);\n }\n }\n }, [mask, register, options]);\n\n return ref;\n};\n\nexport default useInputMask;\n","import Inputmask from 'inputmask';\nimport { RefCallback } from 'react';\nimport { flow } from './utils';\nimport { Mask, Options, Register } from './types';\n\nexport const withHookFormMask = (register: Register, mask: Mask, options?: Options): Register => {\n //\n let newRef;\n\n if (register) {\n const { ref } = register;\n\n const maskInput = Inputmask({\n mask: mask || undefined,\n ...options,\n });\n\n newRef = flow((_ref: HTMLElement) => {\n if (_ref) maskInput.mask(_ref);\n return _ref;\n }, ref) as RefCallback<HTMLElement>;\n }\n\n return {\n ...register,\n ref: newRef as RefCallback<HTMLElement>,\n };\n};\n","import Inputmask from 'inputmask';\nimport { isServer } from './utils';\nimport { Input, Mask, Options } from './types';\n\nexport const withMask = (mask?: Mask, options?: Options) => (input: Input) => {\n //\n if (isServer) return input;\n\n const maskInput = Inputmask({\n mask: mask || undefined,\n ...options,\n });\n\n if (input) {\n maskInput.mask(input);\n }\n\n return input;\n};\n"],"names":["isServer","window","document","createElement","flow","funcs","length","index","TypeError","args","i","result","apply","call","useInputMask","props","mask","register","options","ref","useRef","useEffect","current","maskInput","Inputmask","_object_spread","withHookFormMask","newRef","undefined","_ref","withMask","input"],"mappings":";;;;;;;AAAO,MAAMA,QAAAA,GAAW,EACtB,OAAOC,MAAW,KAAA,WAAA,IACfA,MAAOC,CAAAA,QAAQ,IACfD,MAAOC,CAAAA,QAAQ,CAACC,aAAa,CAChC,CAAA;AAEK,SAASC,IAAAA,CAAK,GAAGC,KAAsB,EAAa;IACzD,MAAM,EAAEC,MAAM,GAAE,GAAGD,KAAAA,CAAAA;AACnB,IAAA,IAAIE,KAAQD,GAAAA,MAAAA,CAAAA;AACZ,IAAA,MAAOC,KAAS,EAAA,CAAA;AACd,QAAA,IAAI,OAAOF,KAAK,CAACE,KAAAA,CAAM,KAAK,UAAY,EAAA;YACtC,MAAM,IAAIC,UAAU,qBAAuB,CAAA,CAAA;SAC5C;AACH,KAAA;IACA,OAAO,CAAC,GAAGC,IAA0B,GAAA;AACnC,QAAA,IAAIC,CAAI,GAAA,CAAA,CAAA;AACR,QAAA,IAAIC,MAASL,GAAAA,MAAAA,GAASD,KAAK,CAACK,CAAE,CAAA,CAACE,KAAK,CAAC,IAAI,EAAEH,IAAQA,CAAAA,GAAAA,IAAI,CAAC,CAAE,CAAA,CAAA;QAC1D,MAAO,EAAEC,IAAIJ,MAAQ,CAAA;AACnBK,YAAAA,MAAAA,GAASN,KAAK,CAACK,CAAAA,CAAE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U,CAAAC,gBAAA,CAAA;AAC1BT,YAAAA,IAAAA,EAAMA,IAAQY,IAAAA,SAAAA;AACXV,SAAAA,EAAAA,OAAAA,CAAAA,CAAAA,CAAAA;QAGLS,MAASvB,GAAAA,IAAAA,CAAK,CAACyB,IAAsB,GAAA;YACnC,IAAIA,IAAAA,EAAMN,SAAUP,CAAAA,IAAI,CAACa,IAAAA,CAAAA,CAAAA;YACzB,OAAOA,IAAAA,CAAAA;SACNV,EAAAA,GAAAA,CAAAA,CAAAA;KACJ;AAED,IAAA,OAAO,oBACFF,CAAAA,gBAAAA,CAAAA,EAAAA,EAAAA,QAAAA,CAAAA,EAAAA;QACHE,GAAKQ,EAAAA,MAAAA;;AAET;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MCvBaG,QAAW,GAAA,CAACd,IAAaE,EAAAA,OAAAA,GAAsB,CAACa,KAAiB,GAAA;;AAE5E,QAAA,IAAI/B,UAAU,OAAO+B,KAAAA,CAAAA;AAErB,QAAA,MAAMR,YAAYC,SAAU,CAAA,cAAA,CAAA;AAC1BR,YAAAA,IAAAA,EAAMA,IAAQY,IAAAA,SAAAA;AACXV,SAAAA,EAAAA,OAAAA,CAAAA,CAAAA,CAAAA;AAGL,QAAA,IAAIa,KAAO,EAAA;AACTR,YAAAA,SAAAA,CAAUP,IAAI,CAACe,KAAAA,CAAAA,CAAAA;SAChB;QAED,OAAOA,KAAAA,CAAAA;;;;;;;"}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import * as react from 'react';
2
2
  import Inputmask$1 from 'inputmask';
3
- import * as react_hook_form from 'react-hook-form';
4
3
  import { UseFormRegisterReturn } from 'react-hook-form';
5
4
 
6
5
  interface UseInputMaskOptions {
@@ -15,20 +14,8 @@ type Mask = Inputmask.Options['mask'];
15
14
  type Options = Inputmask.Options;
16
15
  type Input = HTMLInputElement | HTMLTextAreaElement | HTMLElement | HTMLInputElement | null;
17
16
 
18
- declare const withHookFormMask: (register: Register, mask: Mask, options?: Options) => {
19
- ref: ((a: any) => any) | undefined;
20
- onChange: react_hook_form.ChangeHandler;
21
- onBlur: react_hook_form.ChangeHandler;
22
- name: string;
23
- min?: string | number | undefined;
24
- max?: string | number | undefined;
25
- maxLength?: number | undefined;
26
- minLength?: number | undefined;
27
- pattern?: string | undefined;
28
- required?: boolean | undefined;
29
- disabled?: boolean | undefined;
30
- };
17
+ declare const withHookFormMask: (register: Register, mask: Mask, options?: Options) => Register;
31
18
 
32
- declare const withMask: (mask: Mask, options?: Options) => (input: Input) => Input;
19
+ declare const withMask: (mask?: Mask, options?: Options) => (input: Input) => Input;
33
20
 
34
21
  export { useInputMask as default, withHookFormMask, withMask };
package/dist/index.js CHANGED
@@ -2,9 +2,23 @@ import { useRef, useEffect } from 'react';
2
2
  import Inputmask from 'inputmask';
3
3
 
4
4
  const isServer = !(typeof window !== 'undefined' && window.document && window.document.createElement);
5
- const compose = (fn1, ...fns)=>fns.reduce((prevFn, nextFn)=>(value)=>prevFn(nextFn(value)), fn1);
6
- const sum = compose((x)=>x + 1, (x)=>x + 1);
7
- console.log(sum(1));
5
+ function flow(...funcs) {
6
+ const { length } = funcs;
7
+ let index = length;
8
+ while(index--){
9
+ if (typeof funcs[index] !== 'function') {
10
+ throw new TypeError('Expected a function');
11
+ }
12
+ }
13
+ return (...args)=>{
14
+ let i = 0;
15
+ let result = length ? funcs[i].apply(this, args) : args[0];
16
+ while(++i < length){
17
+ result = funcs[i].call(this, result);
18
+ }
19
+ return result;
20
+ };
21
+ }
8
22
 
9
23
  function _define_property$2(obj, key, value) {
10
24
  if (key in obj) {
@@ -115,10 +129,9 @@ const withHookFormMask = (register, mask, options)=>{
115
129
  if (register) {
116
130
  const { ref } = register;
117
131
  const maskInput = Inputmask(_object_spread$1({
118
- mask,
119
- jitMasking: true
132
+ mask: mask || undefined
120
133
  }, options));
121
- newRef = compose((_ref)=>{
134
+ newRef = flow((_ref)=>{
122
135
  if (_ref) maskInput.mask(_ref);
123
136
  return _ref;
124
137
  }, ref);
@@ -160,7 +173,7 @@ const withMask = (mask, options)=>(input)=>{
160
173
  //
161
174
  if (isServer) return input;
162
175
  const maskInput = Inputmask(_object_spread({
163
- mask
176
+ mask: mask || undefined
164
177
  }, options));
165
178
  if (input) {
166
179
  maskInput.mask(input);
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/utils.ts","../src/useMaskInput.ts","../src/withHookFormMask.ts","../src/withMask.ts"],"sourcesContent":["export const isServer = !(\n typeof window !== 'undefined'\n && window.document\n && window.document.createElement\n);\n\nexport const pipe = <T extends any[], R>(\n fn1: (...args: T) => R,\n ...fns: Array<(a: R) => R>\n) => {\n const piped = fns.reduce(\n (prevFn, nextFn) => (value: R) => nextFn(prevFn(value)),\n (value) => value,\n );\n return (...args: T) => piped(fn1(...args));\n};\n\nexport const compose = <R>(\n fn1: (a: R) => R, ...fns: Array<(a: R) => R>\n) => fns.reduce((prevFn, nextFn) => (value) => prevFn(nextFn(value)), fn1);\n\nconst sum = compose(\n (x: number) => x + 1,\n (x: number) => x + 1,\n);\n\nconsole.log(sum(1));\n","import { useEffect, useRef } from 'react';\nimport Inputmask from 'inputmask';\nimport { isServer } from './utils';\n\ninterface UseInputMaskOptions {\n mask: Inputmask.Options['mask']\n register?(element: HTMLElement): void\n options?: Inputmask.Options\n}\n\nconst useInputMask = (props: UseInputMaskOptions) => {\n const { mask, register, options } = props;\n const ref = useRef<HTMLInputElement>(null);\n if (isServer) return ref;\n\n useEffect(() => {\n if (!isServer) {\n if (!ref.current) return;\n\n const maskInput = Inputmask({\n mask,\n ...options,\n });\n\n maskInput.mask(ref.current);\n\n if (register && ref.current) {\n register(ref.current);\n }\n }\n }, [mask, register, options]);\n\n return ref;\n};\n\nexport default useInputMask;\n","import Inputmask from 'inputmask';\n\nimport { compose } from './utils';\nimport { Mask, Options, Register } from './types';\n\nexport const withHookFormMask = (register: Register, mask: Mask, options?: Options) => {\n //\n let newRef;\n\n if (register) {\n const { ref } = register;\n\n const maskInput = Inputmask({\n mask,\n jitMasking: true,\n ...options,\n });\n\n newRef = compose((_ref: HTMLElement) => {\n if (_ref) maskInput.mask(_ref);\n return _ref;\n }, ref);\n }\n\n return {\n ...register,\n ref: newRef,\n };\n};\n","import Inputmask from 'inputmask';\nimport { isServer } from './utils';\nimport { Input, Mask, Options } from './types';\n\nexport const withMask = (mask: Mask, options?: Options) => (input: Input) => {\n //\n if (isServer) return input;\n\n const maskInput = Inputmask({\n mask,\n ...options,\n });\n\n if (input) {\n maskInput.mask(input);\n }\n\n return input;\n};\n"],"names":["isServer","window","document","createElement","compose","fn1","fns","reduce","prevFn","nextFn","value","sum","x","console","log","useInputMask","props","mask","register","options","ref","useRef","useEffect","current","maskInput","Inputmask","_object_spread","withHookFormMask","newRef","jitMasking","_ref","withMask","input"],"mappings":";;;AAAO,MAAMA,QAAAA,GAAW,EACtB,OAAOC,MAAW,KAAA,WAAA,IACfA,MAAOC,CAAAA,QAAQ,IACfD,MAAOC,CAAAA,QAAQ,CAACC,aAAa,CAChC,CAAA;AAaK,MAAMC,OAAU,GAAA,CACrBC,GAAkB,EAAA,GAAGC,MAClBA,GAAIC,CAAAA,MAAM,CAAC,CAACC,QAAQC,MAAW,GAAA,CAACC,QAAUF,MAAOC,CAAAA,MAAAA,CAAOC,SAASL,GAAK,CAAA,CAAA;AAE3E,MAAMM,GAAAA,GAAMP,QACV,CAACQ,CAAAA,GAAcA,IAAI,CACnB,EAAA,CAACA,IAAcA,CAAI,GAAA,CAAA,CAAA,CAAA;AAGrBC,OAAQC,CAAAA,GAAG,CAACH,GAAI,CAAA,CAAA,CAAA,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AChBVI,MAAAA,YAAAA,GAAe,CAACC,KAA+B,GAAA;AACnD,IAAA,MAAM,EAAEC,IAAI,GAAEC,WAAUC,OAAAA,GAAS,GAAGH,KAAAA,CAAAA;IACpC,MAAMI,GAAAA,GAAMC,OAAyB,IAAI,CAAA,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J;AAED,IAAA,OAAO,oBACFF,CAAAA,gBAAAA,CAAAA,EAAAA,EAAAA,QAAAA,CAAAA,EAAAA;QACHE,GAAKQ,EAAAA,MAAAA;;AAET;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MCxBaG,QAAW,GAAA,CAACd,IAAYE,EAAAA,OAAAA,GAAsB,CAACa,KAAiB,GAAA;;AAE3E,QAAA,IAAIhC,UAAU,OAAOgC,KAAAA,CAAAA;AAErB,QAAA,MAAMR,YAAYC,SAAU,CAAA,cAAA,CAAA;AAC1BR,YAAAA,IAAAA;AACGE,SAAAA,EAAAA,OAAAA,CAAAA,CAAAA,CAAAA;AAGL,QAAA,IAAIa,KAAO,EAAA;AACTR,YAAAA,SAAAA,CAAUP,IAAI,CAACe,KAAAA,CAAAA,CAAAA;SAChB;QAED,OAAOA,KAAAA,CAAAA;;;;;"}
1
+ {"version":3,"file":"index.js","sources":["../src/utils.ts","../src/useMaskInput.ts","../src/withHookFormMask.ts","../src/withMask.ts"],"sourcesContent":["export const isServer = !(\n typeof window !== 'undefined'\n && window.document\n && window.document.createElement\n);\n\nexport function flow(...funcs: Array<Function>) : Function {\n const { length } = funcs;\n let index = length;\n while (index--) {\n if (typeof funcs[index] !== 'function') {\n throw new TypeError('Expected a function');\n }\n }\n return (...args: Array<Function>) => {\n let i = 0;\n let result = length ? funcs[i].apply(this, args) : args[0];\n while (++i < length) {\n result = funcs[i].call(this, result);\n }\n return result;\n };\n}\n","import { useEffect, useRef } from 'react';\nimport Inputmask from 'inputmask';\nimport { isServer } from './utils';\n\ninterface UseInputMaskOptions {\n mask: Inputmask.Options['mask']\n register?(element: HTMLElement): void\n options?: Inputmask.Options\n}\n\nconst useInputMask = (props: UseInputMaskOptions) => {\n const { mask, register, options } = props;\n const ref = useRef<HTMLInputElement>(null);\n if (isServer) return ref;\n\n useEffect(() => {\n if (!isServer) {\n if (!ref.current) return;\n\n const maskInput = Inputmask({\n mask,\n ...options,\n });\n\n maskInput.mask(ref.current);\n\n if (register && ref.current) {\n register(ref.current);\n }\n }\n }, [mask, register, options]);\n\n return ref;\n};\n\nexport default useInputMask;\n","import Inputmask from 'inputmask';\nimport { RefCallback } from 'react';\nimport { flow } from './utils';\nimport { Mask, Options, Register } from './types';\n\nexport const withHookFormMask = (register: Register, mask: Mask, options?: Options): Register => {\n //\n let newRef;\n\n if (register) {\n const { ref } = register;\n\n const maskInput = Inputmask({\n mask: mask || undefined,\n ...options,\n });\n\n newRef = flow((_ref: HTMLElement) => {\n if (_ref) maskInput.mask(_ref);\n return _ref;\n }, ref) as RefCallback<HTMLElement>;\n }\n\n return {\n ...register,\n ref: newRef as RefCallback<HTMLElement>,\n };\n};\n","import Inputmask from 'inputmask';\nimport { isServer } from './utils';\nimport { Input, Mask, Options } from './types';\n\nexport const withMask = (mask?: Mask, options?: Options) => (input: Input) => {\n //\n if (isServer) return input;\n\n const maskInput = Inputmask({\n mask: mask || undefined,\n ...options,\n });\n\n if (input) {\n maskInput.mask(input);\n }\n\n return input;\n};\n"],"names":["isServer","window","document","createElement","flow","funcs","length","index","TypeError","args","i","result","apply","call","useInputMask","props","mask","register","options","ref","useRef","useEffect","current","maskInput","Inputmask","_object_spread","withHookFormMask","newRef","undefined","_ref","withMask","input"],"mappings":";;;AAAO,MAAMA,QAAAA,GAAW,EACtB,OAAOC,MAAW,KAAA,WAAA,IACfA,MAAOC,CAAAA,QAAQ,IACfD,MAAOC,CAAAA,QAAQ,CAACC,aAAa,CAChC,CAAA;AAEK,SAASC,IAAAA,CAAK,GAAGC,KAAsB,EAAa;IACzD,MAAM,EAAEC,MAAM,GAAE,GAAGD,KAAAA,CAAAA;AACnB,IAAA,IAAIE,KAAQD,GAAAA,MAAAA,CAAAA;AACZ,IAAA,MAAOC,KAAS,EAAA,CAAA;AACd,QAAA,IAAI,OAAOF,KAAK,CAACE,KAAAA,CAAM,KAAK,UAAY,EAAA;YACtC,MAAM,IAAIC,UAAU,qBAAuB,CAAA,CAAA;SAC5C;AACH,KAA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 -1,40 +1,40 @@
1
1
  {
2
2
  "name": "use-mask-input",
3
- "version": "3.1.0",
3
+ "version": "3.1.2",
4
4
  "description": "A react Hook for build elegant input masks. Compatible with React Hook Form",
5
5
  "author": "eduardoborges",
6
- "license": "MIT",
7
6
  "repository": "https://github.com/eduardoborges/use-mask-input",
8
- "source": "src/index.tsx",
9
- "main": "dist/index.js",
10
- "module": "dist/index.js",
11
- "types": "dist/index.d.ts",
7
+ "source": "./src/index.tsx",
8
+ "main": "./dist/index.js",
9
+ "module": "./dist/index.js",
10
+ "types": "./dist/index.d.ts",
12
11
  "exports": {
13
12
  "import": "./dist/index.js",
14
13
  "require": "./dist/index.cjs",
15
14
  "types": "./dist/index.d.ts"
16
15
  },
17
16
  "engines": {
18
- "node": ">=18",
17
+ "node": ">=16",
19
18
  "npm": ">=7"
20
19
  },
21
20
  "scripts": {
22
- "build": "./scripts.sh build",
23
- "lint": "./scripts.sh lint",
24
- "test": "./scripts.sh test",
25
- "prepare": "./scripts.sh prepare"
21
+ "build": "./sh build",
22
+ "dev": "./sh dev",
23
+ "lint": "./sh lint",
24
+ "test": "./sh test",
25
+ "prepare": "./sh prepare",
26
+ "example": "./sh example"
26
27
  },
27
28
  "files": [
28
29
  "dist",
29
30
  "src"
30
31
  ],
31
32
  "dependencies": {
32
- "inputmask": "5.0.8",
33
- "react-hook-form": "^7"
33
+ "inputmask": "5.0.8"
34
34
  },
35
35
  "peerDependencies": {
36
- "react": ">=16.4 || ^17.0.0 || ^18.0.0",
37
- "react-dom": ">=16.4 || ^17.0.0 || ^18.0.0"
36
+ "react": ">=16.4 || 17 || 18",
37
+ "react-dom": ">=16.4 || 17 || 18"
38
38
  },
39
39
  "devDependencies": {
40
40
  "@semantic-release/changelog": "6.0.3",
@@ -44,7 +44,7 @@
44
44
  "@semantic-release/npm": "10.0.3",
45
45
  "@semantic-release/release-notes-generator": "11.0.1",
46
46
  "@types/inputmask": "^5.0.3",
47
- "@types/node": "18",
47
+ "@types/node": "16",
48
48
  "@types/react": ">=16.4 || ^17.0.0 || ^18.0.0",
49
49
  "@types/react-dom": ">=16.4 || ^17.0.0 || ^18.0.0",
50
50
  "@typescript-eslint/eslint-plugin": "5.59.2",
@@ -56,6 +56,7 @@
56
56
  "eslint-plugin-jsx-a11y": "6.7.1",
57
57
  "eslint-plugin-react": "7.32.2",
58
58
  "eslint-plugin-react-hooks": "^4.6.0",
59
+ "react-hook-form": "^7",
59
60
  "read-pkg": "^8.0.0",
60
61
  "rollup": "^3.21.4",
61
62
  "rollup-plugin-dts": "^5.3.0",
package/src/utils.spec.ts CHANGED
@@ -1,13 +1,14 @@
1
- /* eslint-disable import/no-extraneous-dependencies */
2
1
  import { describe } from 'vitest';
3
- import { compose } from './utils';
4
2
 
5
- describe('test use_mask_input', (test) => {
6
- test('test use-mask-input.flow', ({ expect }) => {
7
- const sum = compose(
8
- (x: number) => x + 1,
9
- (x: number) => x + 1,
10
- );
11
- expect(sum(1)).toBe(3);
3
+ import { flow } from './utils';
4
+
5
+ describe('utils', (it) => {
6
+ it('flow', ({ expect }) => {
7
+ const res = flow(
8
+ (a: number) => a + 1,
9
+ (a:number) => a + 2,
10
+ )(1);
11
+
12
+ expect(res).toBe(4);
12
13
  });
13
14
  });
package/src/utils.ts CHANGED
@@ -4,24 +4,20 @@ export const isServer = !(
4
4
  && window.document.createElement
5
5
  );
6
6
 
7
- export const pipe = <T extends any[], R>(
8
- fn1: (...args: T) => R,
9
- ...fns: Array<(a: R) => R>
10
- ) => {
11
- const piped = fns.reduce(
12
- (prevFn, nextFn) => (value: R) => nextFn(prevFn(value)),
13
- (value) => value,
14
- );
15
- return (...args: T) => piped(fn1(...args));
16
- };
17
-
18
- export const compose = <R>(
19
- fn1: (a: R) => R, ...fns: Array<(a: R) => R>
20
- ) => fns.reduce((prevFn, nextFn) => (value) => prevFn(nextFn(value)), fn1);
21
-
22
- const sum = compose(
23
- (x: number) => x + 1,
24
- (x: number) => x + 1,
25
- );
26
-
27
- console.log(sum(1));
7
+ export function flow(...funcs: Array<Function>) : Function {
8
+ const { length } = funcs;
9
+ let index = length;
10
+ while (index--) {
11
+ if (typeof funcs[index] !== 'function') {
12
+ throw new TypeError('Expected a function');
13
+ }
14
+ }
15
+ return (...args: Array<Function>) => {
16
+ let i = 0;
17
+ let result = length ? funcs[i].apply(this, args) : args[0];
18
+ while (++i < length) {
19
+ result = funcs[i].call(this, result);
20
+ }
21
+ return result;
22
+ };
23
+ }
@@ -1,9 +1,9 @@
1
1
  import Inputmask from 'inputmask';
2
-
3
- import { compose } from './utils';
2
+ import { RefCallback } from 'react';
3
+ import { flow } from './utils';
4
4
  import { Mask, Options, Register } from './types';
5
5
 
6
- export const withHookFormMask = (register: Register, mask: Mask, options?: Options) => {
6
+ export const withHookFormMask = (register: Register, mask: Mask, options?: Options): Register => {
7
7
  //
8
8
  let newRef;
9
9
 
@@ -11,19 +11,18 @@ export const withHookFormMask = (register: Register, mask: Mask, options?: Optio
11
11
  const { ref } = register;
12
12
 
13
13
  const maskInput = Inputmask({
14
- mask,
15
- jitMasking: true,
14
+ mask: mask || undefined,
16
15
  ...options,
17
16
  });
18
17
 
19
- newRef = compose((_ref: HTMLElement) => {
18
+ newRef = flow((_ref: HTMLElement) => {
20
19
  if (_ref) maskInput.mask(_ref);
21
20
  return _ref;
22
- }, ref);
21
+ }, ref) as RefCallback<HTMLElement>;
23
22
  }
24
23
 
25
24
  return {
26
25
  ...register,
27
- ref: newRef,
26
+ ref: newRef as RefCallback<HTMLElement>,
28
27
  };
29
28
  };
package/src/withMask.ts CHANGED
@@ -2,12 +2,12 @@ import Inputmask from 'inputmask';
2
2
  import { isServer } from './utils';
3
3
  import { Input, Mask, Options } from './types';
4
4
 
5
- export const withMask = (mask: Mask, options?: Options) => (input: Input) => {
5
+ export const withMask = (mask?: Mask, options?: Options) => (input: Input) => {
6
6
  //
7
7
  if (isServer) return input;
8
8
 
9
9
  const maskInput = Inputmask({
10
- mask,
10
+ mask: mask || undefined,
11
11
  ...options,
12
12
  });
13
13