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 +23 -0
- package/dist/antd.cjs +1 -1
- package/dist/antd.d.cts +1 -2
- package/dist/antd.d.mts +1 -2
- package/dist/antd.mjs +1 -1
- package/dist/{index-Do9euvWK.d.cts → index-HfKPnOg0.d.cts} +382 -383
- package/dist/{index-Do9euvWK.d.mts → index-HfKPnOg0.d.mts} +382 -383
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -2
- package/dist/index.d.mts +1 -2
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/withMask-BQpBm8zG.cjs +2 -0
- package/dist/withMask-BQpBm8zG.cjs.map +1 -0
- package/dist/withMask-DlC13MV7.mjs +2 -0
- package/dist/withMask-DlC13MV7.mjs.map +1 -0
- package/package.json +8 -8
- package/src/api/useHookFormMask.ts +20 -5
- package/src/api/withMask.ts +2 -0
- package/src/core/maskEngine.ts +56 -27
- package/dist/withMask-BkTzstzt.cjs +0 -2
- package/dist/withMask-BkTzstzt.cjs.map +0 -1
- package/dist/withMask-C-wAMt0W.mjs +0 -2
- package/dist/withMask-C-wAMt0W.mjs.map +0 -1
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-
|
|
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-
|
|
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-
|
|
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,
|
|
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
|