use-mask-input 3.0.6 → 3.1.1

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.
Files changed (66) hide show
  1. package/README.md +13 -19
  2. package/dist/index.cjs +191 -0
  3. package/dist/index.cjs.map +1 -0
  4. package/dist/index.d.ts +34 -3
  5. package/dist/index.js +184 -1
  6. package/dist/index.js.map +1 -1
  7. package/package.json +49 -48
  8. package/src/index.tsx +3 -2
  9. package/src/types.ts +6 -0
  10. package/src/useMaskInput.ts +12 -9
  11. package/src/utils.spec.ts +14 -0
  12. package/src/utils.ts +23 -0
  13. package/src/withHookFormMask.ts +8 -17
  14. package/src/withMask.ts +5 -6
  15. package/dist/example/App.example.d.ts +0 -3
  16. package/dist/example/index.d.ts +0 -1
  17. package/dist/index.modern.js +0 -2
  18. package/dist/index.modern.js.map +0 -1
  19. package/dist/index.umd.js +0 -2
  20. package/dist/index.umd.js.map +0 -1
  21. package/dist/useMaskInput.d.ts +0 -9
  22. package/dist/withHookFormMask.d.ts +0 -16
  23. package/dist/withMask.d.ts +0 -3
  24. package/node_modules/inputmask/LICENSE.txt +0 -7
  25. package/node_modules/inputmask/README.md +0 -1279
  26. package/node_modules/inputmask/bundle.js +0 -6
  27. package/node_modules/inputmask/dist/bindings/inputmask.binding.js +0 -26
  28. package/node_modules/inputmask/dist/inputmask.es6.js +0 -5
  29. package/node_modules/inputmask/dist/inputmask.js +0 -3031
  30. package/node_modules/inputmask/dist/inputmask.min.js +0 -8
  31. package/node_modules/inputmask/dist/jquery.inputmask.js +0 -2985
  32. package/node_modules/inputmask/dist/jquery.inputmask.min.js +0 -8
  33. package/node_modules/inputmask/lib/bindings/inputmask.binding.js +0 -26
  34. package/node_modules/inputmask/lib/bindings/inputmask.es6.js +0 -5
  35. package/node_modules/inputmask/lib/canUseDOM.js +0 -7
  36. package/node_modules/inputmask/lib/defaults.js +0 -101
  37. package/node_modules/inputmask/lib/definitions.js +0 -13
  38. package/node_modules/inputmask/lib/dependencyLibs/data.js +0 -8
  39. package/node_modules/inputmask/lib/dependencyLibs/events.js +0 -199
  40. package/node_modules/inputmask/lib/dependencyLibs/extend.js +0 -58
  41. package/node_modules/inputmask/lib/dependencyLibs/inputmask.dependencyLib.jquery.js +0 -13
  42. package/node_modules/inputmask/lib/dependencyLibs/inputmask.dependencyLib.js +0 -41
  43. package/node_modules/inputmask/lib/environment.js +0 -9
  44. package/node_modules/inputmask/lib/escapeRegex.js +0 -4
  45. package/node_modules/inputmask/lib/eventhandlers.js +0 -513
  46. package/node_modules/inputmask/lib/eventruler.js +0 -124
  47. package/node_modules/inputmask/lib/extensions/inputmask.date.extensions.js +0 -588
  48. package/node_modules/inputmask/lib/extensions/inputmask.extensions.js +0 -133
  49. package/node_modules/inputmask/lib/extensions/inputmask.numeric.extensions.js +0 -631
  50. package/node_modules/inputmask/lib/global/window.js +0 -3
  51. package/node_modules/inputmask/lib/inputHandling.js +0 -252
  52. package/node_modules/inputmask/lib/inputmask.js +0 -355
  53. package/node_modules/inputmask/lib/inputmaskElement.js +0 -33
  54. package/node_modules/inputmask/lib/jquery.inputmask.js +0 -81
  55. package/node_modules/inputmask/lib/keycode.json +0 -25
  56. package/node_modules/inputmask/lib/mask-lexer.js +0 -467
  57. package/node_modules/inputmask/lib/mask.js +0 -244
  58. package/node_modules/inputmask/lib/masktoken.js +0 -13
  59. package/node_modules/inputmask/lib/polyfills/Array.includes.js +0 -48
  60. package/node_modules/inputmask/lib/polyfills/Object.getPrototypeOf.js +0 -7
  61. package/node_modules/inputmask/lib/positioning.js +0 -348
  62. package/node_modules/inputmask/lib/validation-tests.js +0 -597
  63. package/node_modules/inputmask/lib/validation.js +0 -664
  64. package/node_modules/inputmask/package.json +0 -60
  65. package/src/example/App.example.tsx +0 -68
  66. package/src/example/index.tsx +0 -5
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 ADDED
@@ -0,0 +1,191 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var react = require('react');
6
+ var Inputmask = require('inputmask');
7
+
8
+ const isServer = !(typeof window !== 'undefined' && window.document && window.document.createElement);
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
+ }
26
+
27
+ function _define_property$2(obj, key, value) {
28
+ if (key in obj) {
29
+ Object.defineProperty(obj, key, {
30
+ value: value,
31
+ enumerable: true,
32
+ configurable: true,
33
+ writable: true
34
+ });
35
+ } else {
36
+ obj[key] = value;
37
+ }
38
+ return obj;
39
+ }
40
+ function _object_spread$2(target) {
41
+ for(var i = 1; i < arguments.length; i++){
42
+ var source = arguments[i] != null ? arguments[i] : {};
43
+ var ownKeys = Object.keys(source);
44
+ if (typeof Object.getOwnPropertySymbols === "function") {
45
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
46
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
47
+ }));
48
+ }
49
+ ownKeys.forEach(function(key) {
50
+ _define_property$2(target, key, source[key]);
51
+ });
52
+ }
53
+ return target;
54
+ }
55
+ const useInputMask = (props)=>{
56
+ const { mask , register , options } = props;
57
+ const ref = react.useRef(null);
58
+ if (isServer) return ref;
59
+ react.useEffect(()=>{
60
+ if (!isServer) {
61
+ if (!ref.current) return;
62
+ const maskInput = Inputmask(_object_spread$2({
63
+ mask
64
+ }, options));
65
+ maskInput.mask(ref.current);
66
+ if (register && ref.current) {
67
+ register(ref.current);
68
+ }
69
+ }
70
+ }, [
71
+ mask,
72
+ register,
73
+ options
74
+ ]);
75
+ return ref;
76
+ };
77
+
78
+ function _define_property$1(obj, key, value) {
79
+ if (key in obj) {
80
+ Object.defineProperty(obj, key, {
81
+ value: value,
82
+ enumerable: true,
83
+ configurable: true,
84
+ writable: true
85
+ });
86
+ } else {
87
+ obj[key] = value;
88
+ }
89
+ return obj;
90
+ }
91
+ function _object_spread$1(target) {
92
+ for(var i = 1; i < arguments.length; i++){
93
+ var source = arguments[i] != null ? arguments[i] : {};
94
+ var ownKeys = Object.keys(source);
95
+ if (typeof Object.getOwnPropertySymbols === "function") {
96
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
97
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
98
+ }));
99
+ }
100
+ ownKeys.forEach(function(key) {
101
+ _define_property$1(target, key, source[key]);
102
+ });
103
+ }
104
+ return target;
105
+ }
106
+ function ownKeys(object, enumerableOnly) {
107
+ var keys = Object.keys(object);
108
+ if (Object.getOwnPropertySymbols) {
109
+ var symbols = Object.getOwnPropertySymbols(object);
110
+ if (enumerableOnly) {
111
+ symbols = symbols.filter(function(sym) {
112
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
113
+ });
114
+ }
115
+ keys.push.apply(keys, symbols);
116
+ }
117
+ return keys;
118
+ }
119
+ function _object_spread_props(target, source) {
120
+ source = source != null ? source : {};
121
+ if (Object.getOwnPropertyDescriptors) {
122
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
123
+ } else {
124
+ ownKeys(Object(source)).forEach(function(key) {
125
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
126
+ });
127
+ }
128
+ return target;
129
+ }
130
+ const withHookFormMask = (register, mask, options)=>{
131
+ //
132
+ let newRef;
133
+ if (register) {
134
+ const { ref } = register;
135
+ const maskInput = Inputmask(_object_spread$1({
136
+ mask
137
+ }, options));
138
+ newRef = flow((_ref)=>{
139
+ if (_ref) maskInput.mask(_ref);
140
+ return _ref;
141
+ }, ref);
142
+ }
143
+ return _object_spread_props(_object_spread$1({}, register), {
144
+ ref: newRef
145
+ });
146
+ };
147
+
148
+ function _define_property(obj, key, value) {
149
+ if (key in obj) {
150
+ Object.defineProperty(obj, key, {
151
+ value: value,
152
+ enumerable: true,
153
+ configurable: true,
154
+ writable: true
155
+ });
156
+ } else {
157
+ obj[key] = value;
158
+ }
159
+ return obj;
160
+ }
161
+ function _object_spread(target) {
162
+ for(var i = 1; i < arguments.length; i++){
163
+ var source = arguments[i] != null ? arguments[i] : {};
164
+ var ownKeys = Object.keys(source);
165
+ if (typeof Object.getOwnPropertySymbols === "function") {
166
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
167
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
168
+ }));
169
+ }
170
+ ownKeys.forEach(function(key) {
171
+ _define_property(target, key, source[key]);
172
+ });
173
+ }
174
+ return target;
175
+ }
176
+ const withMask = (mask, options)=>(input)=>{
177
+ //
178
+ if (isServer) return input;
179
+ const maskInput = Inputmask(_object_spread({
180
+ mask
181
+ }, options));
182
+ if (input) {
183
+ maskInput.mask(input);
184
+ }
185
+ return input;
186
+ };
187
+
188
+ exports.default = useInputMask;
189
+ exports.withHookFormMask = withHookFormMask;
190
+ exports.withMask = withMask;
191
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +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 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 { flow } 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 ...options,\n });\n\n newRef = flow((_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","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","_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,QA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AAA;SAChB;QAED,OAAOA,KAAAA,CAAAA;;;;;;;"}
package/dist/index.d.ts CHANGED
@@ -1,3 +1,34 @@
1
- export { default } from './useMaskInput';
2
- export { default as withHookFormMask } from './withHookFormMask';
3
- export { default as withMask } from './withMask';
1
+ import * as react from 'react';
2
+ import Inputmask$1 from 'inputmask';
3
+ import * as react_hook_form from 'react-hook-form';
4
+ import { UseFormRegisterReturn } from 'react-hook-form';
5
+
6
+ interface UseInputMaskOptions {
7
+ mask: Inputmask$1.Options['mask'];
8
+ register?(element: HTMLElement): void;
9
+ options?: Inputmask$1.Options;
10
+ }
11
+ declare const useInputMask: (props: UseInputMaskOptions) => react.RefObject<HTMLInputElement>;
12
+
13
+ type Register = UseFormRegisterReturn;
14
+ type Mask = Inputmask.Options['mask'];
15
+ type Options = Inputmask.Options;
16
+ type Input = HTMLInputElement | HTMLTextAreaElement | HTMLElement | HTMLInputElement | null;
17
+
18
+ declare const withHookFormMask: (register: Register, mask: Mask, options?: Options) => {
19
+ ref: Function | 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
+ };
31
+
32
+ declare const withMask: (mask: Mask, options?: Options) => (input: Input) => Input;
33
+
34
+ export { useInputMask as default, withHookFormMask, withMask };
package/dist/index.js CHANGED
@@ -1,2 +1,185 @@
1
- function r(r){return r&&"object"==typeof r&&"default"in r?r.default:r}var t=require("react"),e=r(require("inputmask")),n=r(require("lodash.flowright"));function u(){return(u=Object.assign?Object.assign.bind():function(r){for(var t=1;t<arguments.length;t++){var e=arguments[t];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(r[n]=e[n])}return r}).apply(this,arguments)}exports.default=function(r){var n=r.mask,a=r.register,i=r.options,o=t.useRef(null);return t.useEffect(function(){o.current&&(e(u({mask:n},i)).mask(o.current),a&&o.current&&a(o.current))},[n,a,i]),o},exports.withHookFormMask=function(r,t,a){var i;if(r){var o=r.ref,s=e(u({mask:t,jitMasking:!0},a));i=n(o,function(r){return r&&s.mask(r),r})}return u({},r,{ref:i})},exports.withMask=function(r,t){return function(n){var a=e(u({mask:r},t));return n&&a.mask(n),n}};
1
+ import { useRef, useEffect } from 'react';
2
+ import Inputmask from 'inputmask';
3
+
4
+ const isServer = !(typeof window !== 'undefined' && window.document && window.document.createElement);
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
+ }
22
+
23
+ function _define_property$2(obj, key, value) {
24
+ if (key in obj) {
25
+ Object.defineProperty(obj, key, {
26
+ value: value,
27
+ enumerable: true,
28
+ configurable: true,
29
+ writable: true
30
+ });
31
+ } else {
32
+ obj[key] = value;
33
+ }
34
+ return obj;
35
+ }
36
+ function _object_spread$2(target) {
37
+ for(var i = 1; i < arguments.length; i++){
38
+ var source = arguments[i] != null ? arguments[i] : {};
39
+ var ownKeys = Object.keys(source);
40
+ if (typeof Object.getOwnPropertySymbols === "function") {
41
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
42
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
43
+ }));
44
+ }
45
+ ownKeys.forEach(function(key) {
46
+ _define_property$2(target, key, source[key]);
47
+ });
48
+ }
49
+ return target;
50
+ }
51
+ const useInputMask = (props)=>{
52
+ const { mask , register , options } = props;
53
+ const ref = useRef(null);
54
+ if (isServer) return ref;
55
+ useEffect(()=>{
56
+ if (!isServer) {
57
+ if (!ref.current) return;
58
+ const maskInput = Inputmask(_object_spread$2({
59
+ mask
60
+ }, options));
61
+ maskInput.mask(ref.current);
62
+ if (register && ref.current) {
63
+ register(ref.current);
64
+ }
65
+ }
66
+ }, [
67
+ mask,
68
+ register,
69
+ options
70
+ ]);
71
+ return ref;
72
+ };
73
+
74
+ function _define_property$1(obj, key, value) {
75
+ if (key in obj) {
76
+ Object.defineProperty(obj, key, {
77
+ value: value,
78
+ enumerable: true,
79
+ configurable: true,
80
+ writable: true
81
+ });
82
+ } else {
83
+ obj[key] = value;
84
+ }
85
+ return obj;
86
+ }
87
+ function _object_spread$1(target) {
88
+ for(var i = 1; i < arguments.length; i++){
89
+ var source = arguments[i] != null ? arguments[i] : {};
90
+ var ownKeys = Object.keys(source);
91
+ if (typeof Object.getOwnPropertySymbols === "function") {
92
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
93
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
94
+ }));
95
+ }
96
+ ownKeys.forEach(function(key) {
97
+ _define_property$1(target, key, source[key]);
98
+ });
99
+ }
100
+ return target;
101
+ }
102
+ function ownKeys(object, enumerableOnly) {
103
+ var keys = Object.keys(object);
104
+ if (Object.getOwnPropertySymbols) {
105
+ var symbols = Object.getOwnPropertySymbols(object);
106
+ if (enumerableOnly) {
107
+ symbols = symbols.filter(function(sym) {
108
+ return Object.getOwnPropertyDescriptor(object, sym).enumerable;
109
+ });
110
+ }
111
+ keys.push.apply(keys, symbols);
112
+ }
113
+ return keys;
114
+ }
115
+ function _object_spread_props(target, source) {
116
+ source = source != null ? source : {};
117
+ if (Object.getOwnPropertyDescriptors) {
118
+ Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
119
+ } else {
120
+ ownKeys(Object(source)).forEach(function(key) {
121
+ Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
122
+ });
123
+ }
124
+ return target;
125
+ }
126
+ const withHookFormMask = (register, mask, options)=>{
127
+ //
128
+ let newRef;
129
+ if (register) {
130
+ const { ref } = register;
131
+ const maskInput = Inputmask(_object_spread$1({
132
+ mask
133
+ }, options));
134
+ newRef = flow((_ref)=>{
135
+ if (_ref) maskInput.mask(_ref);
136
+ return _ref;
137
+ }, ref);
138
+ }
139
+ return _object_spread_props(_object_spread$1({}, register), {
140
+ ref: newRef
141
+ });
142
+ };
143
+
144
+ function _define_property(obj, key, value) {
145
+ if (key in obj) {
146
+ Object.defineProperty(obj, key, {
147
+ value: value,
148
+ enumerable: true,
149
+ configurable: true,
150
+ writable: true
151
+ });
152
+ } else {
153
+ obj[key] = value;
154
+ }
155
+ return obj;
156
+ }
157
+ function _object_spread(target) {
158
+ for(var i = 1; i < arguments.length; i++){
159
+ var source = arguments[i] != null ? arguments[i] : {};
160
+ var ownKeys = Object.keys(source);
161
+ if (typeof Object.getOwnPropertySymbols === "function") {
162
+ ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function(sym) {
163
+ return Object.getOwnPropertyDescriptor(source, sym).enumerable;
164
+ }));
165
+ }
166
+ ownKeys.forEach(function(key) {
167
+ _define_property(target, key, source[key]);
168
+ });
169
+ }
170
+ return target;
171
+ }
172
+ const withMask = (mask, options)=>(input)=>{
173
+ //
174
+ if (isServer) return input;
175
+ const maskInput = Inputmask(_object_spread({
176
+ mask
177
+ }, options));
178
+ if (input) {
179
+ maskInput.mask(input);
180
+ }
181
+ return input;
182
+ };
183
+
184
+ export { useInputMask as default, withHookFormMask, withMask };
2
185
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../src/useMaskInput.ts","../src/withHookFormMask.ts","../src/withMask.ts"],"sourcesContent":["import { useEffect, useRef } from 'react';\nimport Inputmask from 'inputmask';\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\n const ref = useRef<HTMLInputElement>(null);\n\n useEffect(() => {\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 }, [mask, register, options]);\n\n return ref;\n};\n\nexport default useInputMask;\n","/* eslint-disable @typescript-eslint/space-before-blocks */\n/* eslint-disable @typescript-eslint/no-unused-vars */\nimport Inputmask from 'inputmask';\nimport type { UseFormRegisterReturn } from 'react-hook-form';\nimport flowright from 'lodash.flowright';\n\nconst withHookFormMask = (\n registerReturn: UseFormRegisterReturn,\n mask: Inputmask.Options['mask'],\n options?: Inputmask.Options,\n) => {\n //\n let newRef;\n\n if (registerReturn){\n const { ref } = registerReturn;\n\n const maskInput = Inputmask({\n mask,\n jitMasking: true,\n ...options,\n });\n\n newRef = flowright(ref, (_ref) => {\n if (_ref) maskInput.mask(_ref);\n return _ref;\n });\n }\n\n return {\n ...registerReturn,\n ref: newRef,\n };\n};\n\nexport default withHookFormMask;\n","import Inputmask from 'inputmask';\n\nconst withFinalFormMask = (\n mask: Inputmask.Options['mask'],\n options?: Inputmask.Options,\n) => (input: HTMLElement | HTMLInputElement | null) => {\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\nexport default withFinalFormMask;\n"],"names":["props","mask","register","options","useRef","useEffect","ref","current","Inputmask","registerReturn","jitMasking","newRef","flowright","_ref","maskInput","input"],"mappings":"2YASqB,SAACA,GACpB,MAAoCA,EAA5BC,KAAMC,EAAsBF,EAAtBE,SAAUC,EAAYH,EAAZG,UAEZC,SAAyB,MAiBrC,OAfAC,YAAU,WACHC,EAAIC,UAESC,KAChBP,KAAAA,GACGE,IAGKF,KAAKK,EAAIC,SAEfL,GAAYI,EAAIC,SAClBL,EAASI,EAAIC,WAEd,CAACN,EAAMC,EAAUC,gCCrBG,SACvBM,EACAR,EACAE,GAGA,MAEA,GAAIM,EAAe,CACjB,MAAgBA,EAARH,MAEUE,KAChBP,KAAAA,EACAS,YAAY,GACTP,IAGLQ,EAASC,EAAUN,EAAK,SAACO,GAEvB,OADIA,GAAMC,EAAUb,KAAKY,OAK7B,YACKJ,GACHH,IAAKK,sBC7BiB,SACxBV,EACAE,mBACIY,GAEJ,MAAkBP,KAChBP,KAAAA,GACGE,IAOL,OAJIY,GACFD,EAAUb,KAAKc"}
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 { flow } 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 ...options,\n });\n\n newRef = flow((_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","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","_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,CAACG,IAAI,CAAC,IAAI,EAAEF,MAAAA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AAAA;AACGE,SAAAA,EAAAA,OAAAA,CAAAA,CAAAA,CAAAA;QAGLS,MAASvB,GAAAA,IAAAA,CAAK,CAACwB,IAAsB,GAAA;YACnC,IAAIA,IAAAA,EAAML,SAAUP,CAAAA,IAAI,CAACY,IAAAA,CAAAA,CAAAA;YACzB,OAAOA,IAAAA,CAAAA;SACNT,EAAAA,GAAAA,CAAAA,CAAAA;KACJ;AAED,IAAA,OAAO,oBACFF,CAAAA,gBAAAA,CAAAA,EAAAA,EAAAA,QAAAA,CAAAA,EAAAA;QACHE,GAAKQ,EAAAA,MAAAA;;AAET;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MCtBaE,QAAW,GAAA,CAACb,IAAYE,EAAAA,OAAAA,GAAsB,CAACY,KAAiB,GAAA;;AAE3E,QAAA,IAAI9B,UAAU,OAAO8B,KAAAA,CAAAA;AAErB,QAAA,MAAMP,YAAYC,SAAU,CAAA,cAAA,CAAA;AAC1BR,YAAAA,IAAAA;AACGE,SAAAA,EAAAA,OAAAA,CAAAA,CAAAA,CAAAA;AAGL,QAAA,IAAIY,KAAO,EAAA;AACTP,YAAAA,SAAAA,CAAUP,IAAI,CAACc,KAAAA,CAAAA,CAAAA;SAChB;QAED,OAAOA,KAAAA,CAAAA;;;;;"}
package/package.json CHANGED
@@ -1,71 +1,72 @@
1
1
  {
2
2
  "name": "use-mask-input",
3
- "version": "3.0.6",
3
+ "version": "3.1.1",
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.modern.js",
11
- "unpkg": "dist/index.umd.js",
12
- "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",
11
+ "exports": {
12
+ "import": "./dist/index.js",
13
+ "require": "./dist/index.cjs",
14
+ "types": "./dist/index.d.ts"
15
+ },
13
16
  "engines": {
14
- "node": ">=16"
17
+ "node": ">=16",
18
+ "npm": ">=7"
15
19
  },
16
20
  "scripts": {
17
- "build": "microbundle-crl --format modern,cjs,umd",
18
- "start": "vite",
19
- "prepare": "npm run build",
20
- "lint": "eslint src"
21
+ "build": "./sh build",
22
+ "dev": "./sh dev",
23
+ "lint": "./sh lint",
24
+ "test": "./sh test",
25
+ "prepare": "./sh prepare",
26
+ "example": "./sh example"
27
+ },
28
+ "files": [
29
+ "dist",
30
+ "src"
31
+ ],
32
+ "dependencies": {
33
+ "inputmask": "5.0.8"
21
34
  },
22
35
  "peerDependencies": {
23
- "react": ">=17",
24
- "react-dom": ">=17"
36
+ "react": ">=16.4 || 17 || 18",
37
+ "react-dom": ">=16.4 || 17 || 18"
25
38
  },
26
39
  "devDependencies": {
27
- "@semantic-release/changelog": "6.0.2",
40
+ "@semantic-release/changelog": "6.0.3",
28
41
  "@semantic-release/commit-analyzer": "9.0.2",
29
42
  "@semantic-release/git": "10.0.1",
30
43
  "@semantic-release/github": "8.0.7",
31
- "@semantic-release/npm": "9.0.2",
32
- "@semantic-release/release-notes-generator": "10.0.3",
44
+ "@semantic-release/npm": "10.0.3",
45
+ "@semantic-release/release-notes-generator": "11.0.1",
33
46
  "@types/inputmask": "^5.0.3",
34
- "@types/jest": "29.4.0",
35
- "@types/lodash.flowright": "^3.5.7",
36
- "@types/node": "18",
37
- "@types/react": ">=17",
38
- "@types/react-dom": ">=17",
39
- "@typescript-eslint/eslint-plugin": "5.50.0",
40
- "@typescript-eslint/parser": "5.50.0",
41
- "@vitejs/plugin-react": "3.0.1",
42
- "concurrently": "7.6.0",
43
- "cross-env": "7.0.3",
44
- "eslint": "8.33.0",
47
+ "@types/node": "16",
48
+ "@types/react": ">=16.4 || ^17.0.0 || ^18.0.0",
49
+ "@types/react-dom": ">=16.4 || ^17.0.0 || ^18.0.0",
50
+ "@typescript-eslint/eslint-plugin": "5.59.2",
51
+ "@typescript-eslint/parser": "5.59.2",
52
+ "eslint": "8.39.0",
45
53
  "eslint-config-airbnb": "19.0.4",
46
54
  "eslint-config-airbnb-typescript": "^17.0.0",
47
55
  "eslint-plugin-import": "2.27.5",
48
56
  "eslint-plugin-jsx-a11y": "6.7.1",
49
- "eslint-plugin-react": "7.32.1",
57
+ "eslint-plugin-react": "7.32.2",
50
58
  "eslint-plugin-react-hooks": "^4.6.0",
51
- "final-form": "4.20.9",
52
- "microbundle": "0.15.1",
53
- "microbundle-crl": "^0.13.11",
54
- "react-final-form": "6.5.9",
55
- "react-hook-form": "^7.42.1",
56
- "semantic-release": "20.1.0",
57
- "typescript": "4.9.5",
58
- "vite": "4.1.1"
59
- },
60
- "files": [
61
- "dist",
62
- "src"
63
- ],
64
- "dependencies": {
65
- "inputmask": "5.0.7",
66
- "lodash.flowright": "3.5.0"
59
+ "react-hook-form": "^7",
60
+ "read-pkg": "^8.0.0",
61
+ "rollup": "^3.21.4",
62
+ "rollup-plugin-dts": "^5.3.0",
63
+ "rollup-plugin-swc3": "^0.8.1",
64
+ "semantic-release": "21.0.2",
65
+ "simple-git-hooks": "^2.8.1",
66
+ "typescript": "4.9",
67
+ "vitest": "^0.31.0"
67
68
  },
68
- "bundleDependencies": [
69
- "inputmask"
70
- ]
69
+ "simple-git-hooks": {
70
+ "pre-commit": "npm run lint && npm run test && npm run build"
71
+ }
71
72
  }
package/src/index.tsx CHANGED
@@ -1,3 +1,4 @@
1
1
  export { default } from './useMaskInput';
2
- export { default as withHookFormMask } from './withHookFormMask';
3
- export { default as withMask } from './withMask';
2
+
3
+ export * from './withHookFormMask';
4
+ export * from './withMask';
package/src/types.ts ADDED
@@ -0,0 +1,6 @@
1
+ import type { UseFormRegisterReturn } from 'react-hook-form';
2
+
3
+ export type Register = UseFormRegisterReturn;
4
+ export type Mask = Inputmask.Options['mask'];
5
+ export type Options = Inputmask.Options;
6
+ export type Input = HTMLInputElement | HTMLTextAreaElement | HTMLElement | HTMLInputElement | null;