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/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import * as react_hook_form from 'react-hook-form';
2
2
  import { UseFormRegisterReturn, FieldValues, RegisterOptions, UseFormRegister, Path } from 'react-hook-form';
3
+ export { UseFormRegister, UseFormRegisterReturn } from 'react-hook-form';
3
4
  import * as react from 'react';
4
5
  import { RefCallback } from 'react';
5
6
 
@@ -606,4 +607,4 @@ interface UseInputMaskOptions {
606
607
  }
607
608
  declare const useInputMask: (props: UseInputMaskOptions) => react.RefObject<HTMLInputElement>;
608
609
 
609
- export { useHookFormMask, useInputMask, withHookFormMask, withMask };
610
+ export { type Input, type Mask, type Options, useHookFormMask, useInputMask, withHookFormMask, withMask };
package/dist/index.js CHANGED
@@ -3847,6 +3847,7 @@ const getMaskOptions = (mask, _options) => {
3847
3847
  ...options
3848
3848
  },
3849
3849
  // alias for brazilians <3
3850
+ // ty <3
3850
3851
  "brl-currency": {
3851
3852
  alias: "currency",
3852
3853
  prefix: "R$ ",
@@ -3905,7 +3906,14 @@ function useHookFormMask(registerFn) {
3905
3906
  const { ref, ...restRegister } = registerFn(fieldName, options);
3906
3907
  const maskInput = inputmask(getMaskOptions(mask, options));
3907
3908
  const newRef = flow((_ref) => {
3908
- if (_ref) maskInput.mask(_ref);
3909
+ if (_ref) {
3910
+ const { nodeName } = _ref;
3911
+ if (nodeName !== "INPUT") {
3912
+ maskInput.mask(_ref.querySelector("input"));
3913
+ } else {
3914
+ maskInput.mask(_ref);
3915
+ }
3916
+ }
3909
3917
  return _ref;
3910
3918
  }, ref);
3911
3919
  return {