use-mask-input 3.5.1 → 3.6.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "use-mask-input",
3
- "version": "3.5.1",
3
+ "version": "3.6.0",
4
4
  "description": "A react Hook for build elegant input masks. Compatible with React Hook Form",
5
5
  "author": "Eduardo Borges<euduardoborges@gmail.com>",
6
6
  "type": "module",
@@ -55,7 +55,7 @@
55
55
  "eslint-plugin-jsx-a11y": "^6.10.2",
56
56
  "eslint-plugin-react": "^7.37.5",
57
57
  "eslint-plugin-react-hooks": "^5.2.0",
58
- "inputmask": "5.0.10-beta.52",
58
+ "inputmask": "5.0.10-beta.61",
59
59
  "react-hook-form": "7.62.0",
60
60
  "read-pkg": "9.0.1",
61
61
  "semantic-release": "24.2.7",
package/src/types.ts CHANGED
@@ -3,21 +3,21 @@ import type { Options as MaskOptions } from './inputmask.types';
3
3
  export type { UseFormRegister, UseFormRegisterReturn } from 'react-hook-form';
4
4
 
5
5
  export type Mask = 'datetime'
6
- | 'email'
7
- | 'numeric'
8
- | 'currency'
9
- | 'decimal'
10
- | 'integer'
11
- | 'percentage'
12
- | 'url'
13
- | 'ip'
14
- | 'mac'
15
- | 'ssn'
16
- | 'brl-currency'
17
- | 'cpf'
18
- | 'cnpj'
19
- | (string & {})
20
- | (string[] & {})
21
- | null;
6
+ | 'email'
7
+ | 'numeric'
8
+ | 'currency'
9
+ | 'decimal'
10
+ | 'integer'
11
+ | 'percentage'
12
+ | 'url'
13
+ | 'ip'
14
+ | 'mac'
15
+ | 'ssn'
16
+ | 'brl-currency'
17
+ | 'cpf'
18
+ | 'cnpj'
19
+ | (string & {})
20
+ | (string[] & {})
21
+ | null;
22
22
  export type Options = MaskOptions;
23
- export type Input = HTMLInputElement | HTMLTextAreaElement | HTMLElement | null;
23
+ export type Input = HTMLInputElement | HTMLTextAreaElement | HTMLElement;
@@ -79,7 +79,7 @@ export default function getMaskOptions(mask?: Mask, _options?: Options): Options
79
79
  ...options,
80
80
  },
81
81
  cnpj: {
82
- mask: '99.999.999/9999-99',
82
+ mask: ['A|9{2}.A|9{3}.A|9{3}/A|9{4}-9{2}'],
83
83
  placeholder: '__.___.___/____-__',
84
84
  ...options,
85
85
  },
package/src/withMask.ts CHANGED
@@ -8,17 +8,11 @@ import interopDefaultSync from './utils/moduleInterop';
8
8
  import type { Input, Mask, Options } from './types';
9
9
 
10
10
  export default function withMask(mask: Mask, options?: Options) {
11
- return (input: Input): Input => {
12
- //
13
- if (isServer) return input;
14
- if (mask === null) return input;
11
+ return (input: Input | null): void => {
12
+ if (isServer || mask === null || !input) return;
15
13
 
16
14
  const maskInput = interopDefaultSync(inputmask)(getMaskOptions(mask, options));
17
15
 
18
- if (input) {
19
- maskInput.mask(input);
20
- }
21
-
22
- return input;
16
+ maskInput.mask(input);
23
17
  };
24
18
  }