use-mask-input 3.4.1 → 3.5.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.4.1",
3
+ "version": "3.5.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",
package/src/index.tsx CHANGED
@@ -2,3 +2,4 @@ export * from './withHookFormMask';
2
2
  export * from './withMask';
3
3
  export * from './useHookFormMask';
4
4
  export * from './useMaskInput';
5
+ export * from './types';
@@ -1,10 +1,12 @@
1
1
  import inputmask from 'inputmask';
2
2
  import { RefCallback } from 'react';
3
3
  import {
4
- FieldValues, Path, UseFormRegister, RegisterOptions,
4
+ FieldValues, Path,
5
+ RegisterOptions,
6
+ UseFormRegister,
5
7
  } from 'react-hook-form';
6
- import { flow, getMaskOptions } from './utils';
7
8
  import { Mask, Options } from './types';
9
+ import { flow, getMaskOptions } from './utils';
8
10
 
9
11
  export function useHookFormMask<
10
12
  T extends FieldValues, D extends RegisterOptions,
@@ -17,7 +19,15 @@ export function useHookFormMask<
17
19
  const maskInput = inputmask(getMaskOptions(mask, options as any));
18
20
 
19
21
  const newRef = flow((_ref: HTMLElement) => {
20
- if (_ref) maskInput.mask(_ref);
22
+ if (_ref) {
23
+ const { nodeName } = _ref;
24
+
25
+ if (nodeName !== 'INPUT') {
26
+ maskInput.mask(_ref.querySelector('input') as HTMLElement);
27
+ } else {
28
+ maskInput.mask(_ref);
29
+ }
30
+ }
21
31
  return _ref;
22
32
  }, ref) as RefCallback<HTMLElement>;
23
33
 
@@ -63,6 +63,7 @@ export const getMaskOptions = (mask?: Mask, _options?: Options): Options => {
63
63
  },
64
64
 
65
65
  // alias for brazilians <3
66
+ // ty <3
66
67
  'brl-currency': {
67
68
  alias: 'currency',
68
69
  prefix: 'R$ ',