use-mask-input 3.1.1 → 3.2.0
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/dist/index.cjs +2 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +2 -15
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +13 -13
- package/src/withHookFormMask.ts +5 -4
- package/src/withMask.ts +2 -2
package/dist/index.cjs
CHANGED
|
@@ -133,7 +133,7 @@ const withHookFormMask = (register, mask, options)=>{
|
|
|
133
133
|
if (register) {
|
|
134
134
|
const { ref } = register;
|
|
135
135
|
const maskInput = Inputmask(_object_spread$1({
|
|
136
|
-
mask
|
|
136
|
+
mask: mask || undefined
|
|
137
137
|
}, options));
|
|
138
138
|
newRef = flow((_ref)=>{
|
|
139
139
|
if (_ref) maskInput.mask(_ref);
|
|
@@ -177,7 +177,7 @@ const withMask = (mask, options)=>(input)=>{
|
|
|
177
177
|
//
|
|
178
178
|
if (isServer) return input;
|
|
179
179
|
const maskInput = Inputmask(_object_spread({
|
|
180
|
-
mask
|
|
180
|
+
mask: mask || undefined
|
|
181
181
|
}, options));
|
|
182
182
|
if (input) {
|
|
183
183
|
maskInput.mask(input);
|
package/dist/index.cjs.map
CHANGED
|
@@ -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 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)
|
|
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,C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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: 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
|
-
};
|
|
17
|
+
declare const withHookFormMask: (register: Register, mask: Mask, options?: Options) => Register;
|
|
31
18
|
|
|
32
|
-
declare const withMask: (mask
|
|
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
|
@@ -129,7 +129,7 @@ const withHookFormMask = (register, mask, options)=>{
|
|
|
129
129
|
if (register) {
|
|
130
130
|
const { ref } = register;
|
|
131
131
|
const maskInput = Inputmask(_object_spread$1({
|
|
132
|
-
mask
|
|
132
|
+
mask: mask || undefined
|
|
133
133
|
}, options));
|
|
134
134
|
newRef = flow((_ref)=>{
|
|
135
135
|
if (_ref) maskInput.mask(_ref);
|
|
@@ -173,7 +173,7 @@ const withMask = (mask, options)=>(input)=>{
|
|
|
173
173
|
//
|
|
174
174
|
if (isServer) return input;
|
|
175
175
|
const maskInput = Inputmask(_object_spread({
|
|
176
|
-
mask
|
|
176
|
+
mask: mask || undefined
|
|
177
177
|
}, options));
|
|
178
178
|
if (input) {
|
|
179
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 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)
|
|
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,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,CAAAA,CAAAA;AAC/B,SAAA;QACA,OAAOA,MAAA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AA,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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "use-mask-input",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "A react Hook for build elegant input masks. Compatible with React Hook Form",
|
|
5
5
|
"author": "eduardoborges",
|
|
6
6
|
"repository": "https://github.com/eduardoborges/use-mask-input",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"src"
|
|
31
31
|
],
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"inputmask": "5.0.
|
|
33
|
+
"inputmask": "5.0.9-beta.16"
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"react": ">=16.4 || 17 || 18",
|
|
@@ -38,18 +38,18 @@
|
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
40
40
|
"@semantic-release/changelog": "6.0.3",
|
|
41
|
-
"@semantic-release/commit-analyzer": "
|
|
41
|
+
"@semantic-release/commit-analyzer": "10.0.1",
|
|
42
42
|
"@semantic-release/git": "10.0.1",
|
|
43
|
-
"@semantic-release/github": "
|
|
44
|
-
"@semantic-release/npm": "10.0.
|
|
45
|
-
"@semantic-release/release-notes-generator": "11.0.
|
|
43
|
+
"@semantic-release/github": "9.0.3",
|
|
44
|
+
"@semantic-release/npm": "10.0.4",
|
|
45
|
+
"@semantic-release/release-notes-generator": "11.0.3",
|
|
46
46
|
"@types/inputmask": "^5.0.3",
|
|
47
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
|
-
"@typescript-eslint/eslint-plugin": "5.59.
|
|
51
|
-
"@typescript-eslint/parser": "5.59.
|
|
52
|
-
"eslint": "8.
|
|
50
|
+
"@typescript-eslint/eslint-plugin": "5.59.11",
|
|
51
|
+
"@typescript-eslint/parser": "5.59.11",
|
|
52
|
+
"eslint": "8.42.0",
|
|
53
53
|
"eslint-config-airbnb": "19.0.4",
|
|
54
54
|
"eslint-config-airbnb-typescript": "^17.0.0",
|
|
55
55
|
"eslint-plugin-import": "2.27.5",
|
|
@@ -58,13 +58,13 @@
|
|
|
58
58
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
59
59
|
"react-hook-form": "^7",
|
|
60
60
|
"read-pkg": "^8.0.0",
|
|
61
|
-
"rollup": "^3.
|
|
61
|
+
"rollup": "^3.25.1",
|
|
62
62
|
"rollup-plugin-dts": "^5.3.0",
|
|
63
|
-
"rollup-plugin-swc3": "^0.8.
|
|
64
|
-
"semantic-release": "21.0.
|
|
63
|
+
"rollup-plugin-swc3": "^0.8.2",
|
|
64
|
+
"semantic-release": "21.0.5",
|
|
65
65
|
"simple-git-hooks": "^2.8.1",
|
|
66
66
|
"typescript": "4.9",
|
|
67
|
-
"vitest": "^0.
|
|
67
|
+
"vitest": "^0.32.0"
|
|
68
68
|
},
|
|
69
69
|
"simple-git-hooks": {
|
|
70
70
|
"pre-commit": "npm run lint && npm run test && npm run build"
|
package/src/withHookFormMask.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import Inputmask from 'inputmask';
|
|
2
|
+
import { RefCallback } from 'react';
|
|
2
3
|
import { flow } from './utils';
|
|
3
4
|
import { Mask, Options, Register } from './types';
|
|
4
5
|
|
|
5
|
-
export const withHookFormMask = (register: Register, mask: Mask, options?: Options) => {
|
|
6
|
+
export const withHookFormMask = (register: Register, mask: Mask, options?: Options): Register => {
|
|
6
7
|
//
|
|
7
8
|
let newRef;
|
|
8
9
|
|
|
@@ -10,18 +11,18 @@ export const withHookFormMask = (register: Register, mask: Mask, options?: Optio
|
|
|
10
11
|
const { ref } = register;
|
|
11
12
|
|
|
12
13
|
const maskInput = Inputmask({
|
|
13
|
-
mask,
|
|
14
|
+
mask: mask || undefined,
|
|
14
15
|
...options,
|
|
15
16
|
});
|
|
16
17
|
|
|
17
18
|
newRef = flow((_ref: HTMLElement) => {
|
|
18
19
|
if (_ref) maskInput.mask(_ref);
|
|
19
20
|
return _ref;
|
|
20
|
-
}, ref)
|
|
21
|
+
}, ref) as RefCallback<HTMLElement>;
|
|
21
22
|
}
|
|
22
23
|
|
|
23
24
|
return {
|
|
24
25
|
...register,
|
|
25
|
-
ref: newRef
|
|
26
|
+
ref: newRef as RefCallback<HTMLElement>,
|
|
26
27
|
};
|
|
27
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
|
|
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
|
|