use-mask-input 3.11.0 → 3.11.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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,26 @@
1
+ ## 3.11.1
2
+
3
+ ### Patch Changes
4
+
5
+ - 20230ee: fix: stop `maxLength` from blocking input on masked fields
6
+
7
+ A mask like `999.999.999-99` keeps its literals and placeholder in the input's
8
+ value, so `maxlength` counted characters nobody typed. The browser refused
9
+ keystrokes, and inputmask copied the attribute into a validator that rejects any
10
+ buffer longer than it. Any `maxLength` at or below the masked length rejected
11
+ every keystroke, and larger values silently truncated.
12
+
13
+ The attribute is now removed before the mask is applied, but only for masks that
14
+ render characters on their own. Open-ended masks such as `numeric`, `integer`
15
+ and `decimal` render nothing while empty, so their `maxLength` still caps
16
+ exactly what it says it caps and is left untouched.
17
+
18
+ Closes #191
19
+
20
+ - 46fb75d: fix(react-hook-form): fire `onChange` on the first select-all + delete for predefined values
21
+
22
+ When a React Hook Form field had a predefined value, the mask was applied before RHF wrote that value onto the element, leaving Inputmask's internal buffer out of sync with the DOM. The first `Ctrl+A` + `Delete` was swallowed and did not trigger `onChange`. The RHF ref now runs before the mask is applied, so Inputmask is seeded with the current value and stays in sync from the start.
23
+
1
24
  ## 3.11.0
2
25
 
3
26
  ### Minor Changes
package/dist/antd.cjs CHANGED
@@ -1,2 +1,2 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./withMask-BkTzstzt.cjs");let t=require("react");function n(n){return(0,t.useMemo)(()=>{let t=new Map;return(r,i,a)=>{if(!n)throw Error(`registerFn is required`);let o=n(r,a),{ref:s}=o,c=e.o(r,i);t.has(c)||t.set(c,t=>{let n=t?e.d(t.input):null;n&&e.n(n,i,a),s&&s(n)});let l={...o,ref:t.get(c)};return e.s(l,s),l}},[n])}function r(n){let{mask:r,register:i,options:a}=n,o=(0,t.useRef)(null),s=(0,t.useRef)(r),c=(0,t.useRef)(a),l=(0,t.useRef)(null),u=(0,t.useCallback)(()=>e.a(o.current),[]);s.current=r,c.current=a;let d=(0,t.useCallback)(t=>{if(!t){o.current=null;return}o.current=e.d(t.input),o.current&&o.current!==l.current&&(e.t(s.current,c.current)(o.current),l.current=o.current)},[]);return(0,t.useEffect)(()=>{e.l||!o.current||!i||i(o.current)},[i]),e.l?e.c((()=>{}),()=>``):e.c(d,u)}exports.useHookFormMaskAntd=n,exports.useMaskInputAntd=r;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./withMask-BQpBm8zG.cjs");let t=require("react");function n(n){return(0,t.useMemo)(()=>{let t=new Map;return(r,i,a)=>{if(!n)throw Error(`registerFn is required`);let o=n(r,a),{ref:s}=o,c=e.o(r,i);t.has(c)||t.set(c,t=>{let n=t?e.u(t.input):null;n&&e.n(n,i,a),s&&s(n)});let l={...o,ref:t.get(c)};return e.s(l,s),l}},[n])}function r(n){let{mask:r,register:i,options:a}=n,o=(0,t.useRef)(null),s=(0,t.useRef)(r),c=(0,t.useRef)(a),l=(0,t.useRef)(null),u=(0,t.useCallback)(()=>e.a(o.current),[]);s.current=r,c.current=a;let d=(0,t.useCallback)(t=>{if(!t){o.current=null;return}o.current=e.u(t.input),o.current&&o.current!==l.current&&(e.t(s.current,c.current)(o.current),l.current=o.current)},[]);return(0,t.useEffect)(()=>{e.l||!o.current||!i||i(o.current)},[i]),e.l?e.c((()=>{}),()=>``):e.c(d,u)}exports.useHookFormMaskAntd=n,exports.useMaskInputAntd=r;
2
2
  //# sourceMappingURL=antd.cjs.map
package/dist/antd.d.cts CHANGED
@@ -1,7 +1,6 @@
1
- import { a as UnmaskedValueApi, d as UseFormRegister, l as RegisterOptions, n as Mask, o as UseHookFormMaskReturn, p as Path, r as Options, u as FieldValues } from "./index-Do9euvWK.cjs";
1
+ import { a as UnmaskedValueApi, d as UseFormRegister, l as RegisterOptions, n as Mask, o as UseHookFormMaskReturn, p as Path, r as Options, u as FieldValues } from "./index-HfKPnOg0.cjs";
2
2
  import { InputRef } from "antd";
3
3
  import { RefCallback } from "react";
4
-
5
4
  //#region src/antd/useHookFormMaskAntd.d.ts
6
5
  type UseHookFormMaskAntdReturn<T extends FieldValues> = Omit<UseHookFormMaskReturn<T>, 'ref'> & {
7
6
  ref: RefCallback<InputRef | null>;
package/dist/antd.d.mts CHANGED
@@ -1,7 +1,6 @@
1
- import { a as UnmaskedValueApi, d as UseFormRegister, l as RegisterOptions, n as Mask, o as UseHookFormMaskReturn, p as Path, r as Options, u as FieldValues } from "./index-Do9euvWK.mjs";
1
+ import { a as UnmaskedValueApi, d as UseFormRegister, l as RegisterOptions, n as Mask, o as UseHookFormMaskReturn, p as Path, r as Options, u as FieldValues } from "./index-HfKPnOg0.mjs";
2
2
  import { RefCallback } from "react";
3
3
  import { InputRef } from "antd";
4
-
5
4
  //#region src/antd/useHookFormMaskAntd.d.ts
6
5
  type UseHookFormMaskAntdReturn<T extends FieldValues> = Omit<UseHookFormMaskReturn<T>, 'ref'> & {
7
6
  ref: RefCallback<InputRef | null>;
package/dist/antd.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import{a as e,c as t,d as n,l as r,n as i,o as a,s as o,t as s}from"./withMask-C-wAMt0W.mjs";import{useCallback as c,useEffect as l,useMemo as u,useRef as d}from"react";function f(e){return u(()=>{let t=new Map;return(r,s,c)=>{if(!e)throw Error(`registerFn is required`);let l=e(r,c),{ref:u}=l,d=a(r,s);t.has(d)||t.set(d,e=>{let t=e?n(e.input):null;t&&i(t,s,c),u&&u(t)});let f={...l,ref:t.get(d)};return o(f,u),f}},[e])}function p(i){let{mask:a,register:o,options:u}=i,f=d(null),p=d(a),m=d(u),h=d(null),g=c(()=>e(f.current),[]);p.current=a,m.current=u;let _=c(e=>{if(!e){f.current=null;return}f.current=n(e.input),f.current&&f.current!==h.current&&(s(p.current,m.current)(f.current),h.current=f.current)},[]);return l(()=>{r||!f.current||!o||o(f.current)},[o]),r?t((()=>{}),()=>``):t(_,g)}export{f as useHookFormMaskAntd,p as useMaskInputAntd};
1
+ import{a as e,c as t,l as n,n as r,o as i,s as a,t as o,u as s}from"./withMask-DlC13MV7.mjs";import{useCallback as c,useEffect as l,useMemo as u,useRef as d}from"react";function f(e){return u(()=>{let t=new Map;return(n,o,c)=>{if(!e)throw Error(`registerFn is required`);let l=e(n,c),{ref:u}=l,d=i(n,o);t.has(d)||t.set(d,e=>{let t=e?s(e.input):null;t&&r(t,o,c),u&&u(t)});let f={...l,ref:t.get(d)};return a(f,u),f}},[e])}function p(r){let{mask:i,register:a,options:u}=r,f=d(null),p=d(i),m=d(u),h=d(null),g=c(()=>e(f.current),[]);p.current=i,m.current=u;let _=c(e=>{if(!e){f.current=null;return}f.current=s(e.input),f.current&&f.current!==h.current&&(o(p.current,m.current)(f.current),h.current=f.current)},[]);return l(()=>{n||!f.current||!a||a(f.current)},[a]),n?t((()=>{}),()=>``):t(_,g)}export{f as useHookFormMaskAntd,p as useMaskInputAntd};
2
2
  //# sourceMappingURL=antd.mjs.map