use-mask-input 3.10.0 → 3.10.2
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 +17 -1
- package/dist/antd.cjs +1 -65
- package/dist/antd.cjs.map +1 -1
- package/dist/antd.d.cts +12 -10
- package/dist/{antd.d.ts → antd.d.mts} +12 -10
- package/dist/antd.mjs +2 -0
- package/dist/antd.mjs.map +1 -0
- package/dist/index-BmKzoe0X.d.cts +836 -0
- package/dist/index-BmKzoe0X.d.mts +836 -0
- package/dist/index.cjs +1 -173
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -15
- package/dist/{index.d.ts → index.d.mts} +18 -15
- package/dist/index.mjs +2 -0
- package/dist/index.mjs.map +1 -0
- package/dist/withMask-VWeBqi_u.cjs +2 -0
- package/dist/withMask-VWeBqi_u.cjs.map +1 -0
- package/dist/withMask-jrErtLYS.mjs +2 -0
- package/dist/withMask-jrErtLYS.mjs.map +1 -0
- package/package.json +42 -22
- package/src/api/withMask.ts +1 -1
- package/src/core/inputmask.ts +10 -0
- package/src/core/maskEngine.ts +2 -2
- package/src/utils/maskHelpers.ts +5 -3
- package/dist/antd.js +0 -63
- package/dist/antd.js.map +0 -1
- package/dist/chunk-DTC7JTZP.cjs +0 -3925
- package/dist/chunk-DTC7JTZP.cjs.map +0 -1
- package/dist/chunk-TVCNC3TP.js +0 -3915
- package/dist/chunk-TVCNC3TP.js.map +0 -1
- package/dist/index-D8KkaDbQ.d.cts +0 -596
- package/dist/index-D8KkaDbQ.d.ts +0 -596
- package/dist/index.js +0 -165
- package/dist/index.js.map +0 -1
- package/src/antd/useHookFormMaskAntd.spec.ts +0 -181
- package/src/antd/useMaskInputAntd-server.spec.tsx +0 -37
- package/src/antd/useMaskInputAntd.spec.tsx +0 -131
- package/src/api/useHookFormMask.spec.ts +0 -259
- package/src/api/useMaskInput-server.spec.tsx +0 -30
- package/src/api/useMaskInput.spec.tsx +0 -238
- package/src/api/withHookFormMask.spec.ts +0 -179
- package/src/api/withMask.spec.ts +0 -137
- package/src/api/withTanStackFormMask.spec.ts +0 -76
- package/src/core/elementResolver.spec.ts +0 -175
- package/src/core/maskConfig.spec.ts +0 -208
- package/src/core/maskEngine.spec.ts +0 -114
- package/src/utils/flow.spec.ts +0 -57
- package/src/utils/isServer.spec.ts +0 -15
- package/src/utils/moduleInterop.spec.ts +0 -37
package/package.json
CHANGED
|
@@ -1,27 +1,38 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "use-mask-input",
|
|
3
|
-
"version": "3.10.
|
|
3
|
+
"version": "3.10.2",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "A react Hook for build elegant input masks. Compatible with React Hook Form",
|
|
6
|
+
"license": "MIT",
|
|
6
7
|
"author": "Eduardo Borges<euduardoborges@gmail.com>",
|
|
7
8
|
"type": "module",
|
|
8
9
|
"repository": {
|
|
9
10
|
"url": "https://github.com/eduardoborges/use-mask-input"
|
|
10
11
|
},
|
|
11
12
|
"main": "./dist/index.cjs",
|
|
12
|
-
"module": "./dist/index.
|
|
13
|
-
"types": "./dist/index.d.
|
|
13
|
+
"module": "./dist/index.mjs",
|
|
14
|
+
"types": "./dist/index.d.mts",
|
|
14
15
|
"source": "./src/index.tsx",
|
|
15
16
|
"exports": {
|
|
16
17
|
".": {
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
"import": {
|
|
19
|
+
"types": "./dist/index.d.mts",
|
|
20
|
+
"default": "./dist/index.mjs"
|
|
21
|
+
},
|
|
22
|
+
"require": {
|
|
23
|
+
"types": "./dist/index.d.cts",
|
|
24
|
+
"default": "./dist/index.cjs"
|
|
25
|
+
}
|
|
20
26
|
},
|
|
21
27
|
"./antd": {
|
|
22
|
-
"
|
|
23
|
-
|
|
24
|
-
|
|
28
|
+
"import": {
|
|
29
|
+
"types": "./dist/antd.d.mts",
|
|
30
|
+
"default": "./dist/antd.mjs"
|
|
31
|
+
},
|
|
32
|
+
"require": {
|
|
33
|
+
"types": "./dist/antd.d.cts",
|
|
34
|
+
"default": "./dist/antd.cjs"
|
|
35
|
+
}
|
|
25
36
|
}
|
|
26
37
|
},
|
|
27
38
|
"engines": {
|
|
@@ -31,33 +42,42 @@
|
|
|
31
42
|
"files": [
|
|
32
43
|
"dist",
|
|
33
44
|
"src",
|
|
45
|
+
"!src/**/*.spec.*",
|
|
46
|
+
"!dist/*-stats.json",
|
|
34
47
|
"README.md",
|
|
35
48
|
"CHANGELOG.md"
|
|
36
49
|
],
|
|
37
50
|
"peerDependencies": {
|
|
51
|
+
"antd": ">=5",
|
|
38
52
|
"react": ">=17",
|
|
39
53
|
"react-dom": ">=17"
|
|
40
54
|
},
|
|
55
|
+
"peerDependenciesMeta": {
|
|
56
|
+
"antd": {
|
|
57
|
+
"optional": true
|
|
58
|
+
}
|
|
59
|
+
},
|
|
41
60
|
"devDependencies": {
|
|
61
|
+
"@codecov/rollup-plugin": "^2.0.1",
|
|
42
62
|
"@testing-library/dom": "^10.4.1",
|
|
43
63
|
"@testing-library/react": "^16.3.2",
|
|
44
64
|
"@types/inputmask": "5.0.7",
|
|
45
|
-
"@types/node": "^25.
|
|
46
|
-
"@types/react": "
|
|
47
|
-
"@types/react-dom": "
|
|
48
|
-
"@vitest/coverage-v8": "4.1.
|
|
49
|
-
"antd": "^6.3
|
|
50
|
-
"oxlint": "1.57.0",
|
|
65
|
+
"@types/node": "^25.9.1",
|
|
66
|
+
"@types/react": "^19.2.15",
|
|
67
|
+
"@types/react-dom": "^19.2.3",
|
|
68
|
+
"@vitest/coverage-v8": "4.1.7",
|
|
69
|
+
"antd": "^6.4.3",
|
|
51
70
|
"inputmask": "5.0.10-beta.61",
|
|
52
|
-
"jsdom": "^
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
71
|
+
"jsdom": "^29.1.1",
|
|
72
|
+
"oxlint": "1.66.0",
|
|
73
|
+
"react-hook-form": "7.76.0",
|
|
74
|
+
"tsdown": "^0.22.0",
|
|
75
|
+
"typescript": "~6.0.3",
|
|
76
|
+
"vitest": "4.1.7"
|
|
57
77
|
},
|
|
58
78
|
"scripts": {
|
|
59
|
-
"build": "
|
|
60
|
-
"dev": "
|
|
79
|
+
"build": "tsdown",
|
|
80
|
+
"dev": "tsdown --watch",
|
|
61
81
|
"lint": "oxlint ./src",
|
|
62
82
|
"test": "vitest --dir ./src --run --coverage",
|
|
63
83
|
"type-check": "tsc --noEmit",
|
package/src/api/withMask.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable import-x/no-extraneous-dependencies */
|
|
2
|
-
import inputmask from 'inputmask';
|
|
2
|
+
import inputmask from '../core/inputmask';
|
|
3
3
|
|
|
4
4
|
import { getMaskOptions } from '../core/maskConfig';
|
|
5
5
|
import { getUnmaskedValue, makeMaskCacheKey, setUnmaskedValue } from '../utils';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/* eslint-disable import-x/no-extraneous-dependencies, import/no-unassigned-import */
|
|
2
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
3
|
+
// @ts-ignore Inputmask exposes this ESM file but not its subpath types in app builds.
|
|
4
|
+
import Inputmask from 'inputmask/lib/inputmask.js';
|
|
5
|
+
|
|
6
|
+
import 'inputmask/lib/extensions/inputmask.extensions.js';
|
|
7
|
+
import 'inputmask/lib/extensions/inputmask.date.extensions.js';
|
|
8
|
+
import 'inputmask/lib/extensions/inputmask.numeric.extensions.js';
|
|
9
|
+
|
|
10
|
+
export default Inputmask;
|
package/src/core/maskEngine.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable import-x/no-extraneous-dependencies */
|
|
2
|
-
import inputmask from 'inputmask';
|
|
2
|
+
import inputmask from './inputmask';
|
|
3
3
|
|
|
4
4
|
import { getMaskOptions } from './maskConfig';
|
|
5
5
|
import { moduleInterop } from '../utils';
|
|
@@ -14,7 +14,7 @@ import type { Mask, Options } from '../types';
|
|
|
14
14
|
* @param options - Optional configuration options
|
|
15
15
|
* @returns A mask instance
|
|
16
16
|
*/
|
|
17
|
-
export function createMaskInstance(mask: Mask, options?: Options):
|
|
17
|
+
export function createMaskInstance(mask: Mask, options?: Options): ReturnType<typeof inputmask> {
|
|
18
18
|
const inputmaskInstance = moduleInterop(inputmask);
|
|
19
19
|
return inputmaskInstance(getMaskOptions(mask, options));
|
|
20
20
|
}
|
package/src/utils/maskHelpers.ts
CHANGED
|
@@ -2,6 +2,10 @@ import { findInputElement, resolveInputRef } from '../core/elementResolver';
|
|
|
2
2
|
|
|
3
3
|
import type { Input, Mask, UnmaskedValueApi } from '../types';
|
|
4
4
|
|
|
5
|
+
type MaskedElement = (HTMLInputElement | HTMLTextAreaElement) & {
|
|
6
|
+
inputmask?: { unmaskedvalue?: () => string };
|
|
7
|
+
};
|
|
8
|
+
|
|
5
9
|
/**
|
|
6
10
|
* Builds a stable string key from a field name and mask, used to cache ref
|
|
7
11
|
* callbacks so their identity stays stable across renders.
|
|
@@ -39,9 +43,7 @@ export function getUnmaskedValue(input: Input | null): string {
|
|
|
39
43
|
const element = resolveUnmaskedInput(input);
|
|
40
44
|
if (!element) return '';
|
|
41
45
|
|
|
42
|
-
const inputmask =
|
|
43
|
-
| { unmaskedvalue?: () => string }
|
|
44
|
-
| undefined;
|
|
46
|
+
const { inputmask } = element as MaskedElement;
|
|
45
47
|
|
|
46
48
|
if (inputmask && typeof inputmask.unmaskedvalue === 'function') {
|
|
47
49
|
return inputmask.unmaskedvalue();
|
package/dist/antd.js
DELETED
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import { makeMaskCacheKey, setPrevRef, getUnmaskedValue, resolveInputRef, withMask, isServer_default, setUnmaskedValue, applyMaskToElement } from './chunk-TVCNC3TP.js';
|
|
2
|
-
import { useMemo, useRef, useCallback, useEffect } from 'react';
|
|
3
|
-
|
|
4
|
-
function useHookFormMaskAntd(registerFn) {
|
|
5
|
-
return useMemo(() => {
|
|
6
|
-
const refCache = /* @__PURE__ */ new Map();
|
|
7
|
-
return (fieldName, mask, options) => {
|
|
8
|
-
if (!registerFn) throw new Error("registerFn is required");
|
|
9
|
-
const registerReturn = registerFn(fieldName, options);
|
|
10
|
-
const { ref } = registerReturn;
|
|
11
|
-
const cacheKey = makeMaskCacheKey(fieldName, mask);
|
|
12
|
-
if (!refCache.has(cacheKey)) {
|
|
13
|
-
const refWithMask = (inputRef) => {
|
|
14
|
-
const element = inputRef ? resolveInputRef(inputRef.input) : null;
|
|
15
|
-
if (element) applyMaskToElement(element, mask, options);
|
|
16
|
-
if (ref) ref(element);
|
|
17
|
-
};
|
|
18
|
-
refCache.set(cacheKey, refWithMask);
|
|
19
|
-
}
|
|
20
|
-
const result = {
|
|
21
|
-
...registerReturn,
|
|
22
|
-
ref: refCache.get(cacheKey)
|
|
23
|
-
};
|
|
24
|
-
setPrevRef(result, ref);
|
|
25
|
-
return result;
|
|
26
|
-
};
|
|
27
|
-
}, [registerFn]);
|
|
28
|
-
}
|
|
29
|
-
function useMaskInputAntd(props) {
|
|
30
|
-
const { mask, register, options } = props;
|
|
31
|
-
const ref = useRef(null);
|
|
32
|
-
const maskRef = useRef(mask);
|
|
33
|
-
const optionsRef = useRef(options);
|
|
34
|
-
const maskedElementRef = useRef(null);
|
|
35
|
-
const unmaskedValue = useCallback(() => getUnmaskedValue(ref.current), []);
|
|
36
|
-
maskRef.current = mask;
|
|
37
|
-
optionsRef.current = options;
|
|
38
|
-
const refCallback = useCallback((input) => {
|
|
39
|
-
if (!input) {
|
|
40
|
-
ref.current = null;
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
|
-
ref.current = resolveInputRef(input.input);
|
|
44
|
-
if (ref.current && ref.current !== maskedElementRef.current) {
|
|
45
|
-
withMask(maskRef.current, optionsRef.current)(ref.current);
|
|
46
|
-
maskedElementRef.current = ref.current;
|
|
47
|
-
}
|
|
48
|
-
}, []);
|
|
49
|
-
useEffect(() => {
|
|
50
|
-
if (isServer_default || !ref.current || !register) return;
|
|
51
|
-
register(ref.current);
|
|
52
|
-
}, [register]);
|
|
53
|
-
if (isServer_default) {
|
|
54
|
-
const noop = (() => {
|
|
55
|
-
});
|
|
56
|
-
return setUnmaskedValue(noop, () => "");
|
|
57
|
-
}
|
|
58
|
-
return setUnmaskedValue(refCallback, unmaskedValue);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export { useHookFormMaskAntd, useMaskInputAntd };
|
|
62
|
-
//# sourceMappingURL=antd.js.map
|
|
63
|
-
//# sourceMappingURL=antd.js.map
|
package/dist/antd.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/antd/useHookFormMaskAntd.ts","../src/antd/useMaskInputAntd.ts"],"names":[],"mappings":"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","file":"antd.js","sourcesContent":["import { useMemo } from 'react';\n\nimport { applyMaskToElement, resolveInputRef } from '../core';\nimport { makeMaskCacheKey, setPrevRef } from '../utils';\n\nimport type { InputRef } from 'antd';\nimport type { RefCallback } from 'react';\nimport type {\n FieldValues, Path,\n RegisterOptions,\n UseFormRegister,\n} from 'react-hook-form';\n\nimport type { Mask, Options, UseHookFormMaskReturn } from '../types';\n\nexport type UseHookFormMaskAntdReturn<T extends FieldValues> = Omit<\n UseHookFormMaskReturn<T>,\n 'ref'\n> & { ref: RefCallback<InputRef | null> };\n\n/**\n * Ant Design version of useHookFormMask.\n * Creates a masked register that works with Ant Design Input (ref receives InputRef).\n *\n * @template T - The form data type\n * @template D - The register options type\n * @param registerFn - The register function from useForm hook\n * @returns A function that registers a field with mask support for Ant Design Input\n */\nexport default function useHookFormMaskAntd<\n T extends FieldValues, D extends RegisterOptions,\n>(registerFn: UseFormRegister<T>): ((fieldName: Path<T>, mask: Mask, options?: (\n D & Options) | Options | D) => UseHookFormMaskAntdReturn<T>) {\n //\n return useMemo(() => {\n const refCache = new Map<string, RefCallback<InputRef | null>>();\n\n return (fieldName: Path<T>, mask: Mask, options?: (\n D & Options) | Options | D): UseHookFormMaskAntdReturn<T> => {\n if (!registerFn) throw new Error('registerFn is required');\n\n const registerReturn = registerFn(fieldName, options as Options);\n const { ref } = registerReturn as UseHookFormMaskReturn<T>;\n\n const cacheKey = makeMaskCacheKey(fieldName, mask);\n\n if (!refCache.has(cacheKey)) {\n const refWithMask: RefCallback<InputRef | null> = (inputRef) => {\n const element = inputRef ? resolveInputRef(inputRef.input) : null;\n if (element) applyMaskToElement(element, mask, options as Options);\n if (ref) ref(element);\n };\n refCache.set(cacheKey, refWithMask);\n }\n\n const result = {\n ...registerReturn,\n ref: refCache.get(cacheKey),\n } as UseHookFormMaskAntdReturn<T>;\n\n setPrevRef(result, ref);\n\n return result;\n };\n }, [registerFn]);\n}\n","import { useCallback, useEffect, useRef } from 'react';\n\nimport withMask from '../api/withMask';\nimport { resolveInputRef } from '../core';\nimport isServer from '../utils/isServer';\nimport { getUnmaskedValue, setUnmaskedValue } from '../utils';\n\nimport type { InputRef } from 'antd';\n\nimport type { Mask, Options, UnmaskedValueApi } from '../types';\n\ntype UseMaskInputAntdReturn = ((input: InputRef | null) => void) & UnmaskedValueApi;\n\ninterface UseMaskInputOptions {\n mask: Mask;\n register?: (element: HTMLElement) => void;\n options?: Options;\n}\n\n/**\n * React hook for applying input masks to Ant Design form elements.\n *\n * @param props - Configuration object\n * @param props.mask - The mask pattern to apply\n * @param props.register - Optional callback that receives the element\n * @param props.options - Optional mask configuration options\n * @returns A ref callback function to attach to the Ant Design Input element\n */\nexport default function useMaskInputAntd(props: UseMaskInputOptions): UseMaskInputAntdReturn {\n const { mask, register, options } = props;\n const ref = useRef<HTMLInputElement | null>(null);\n const maskRef = useRef(mask);\n const optionsRef = useRef(options);\n const maskedElementRef = useRef<HTMLInputElement | null>(null);\n const unmaskedValue = useCallback(() => getUnmaskedValue(ref.current), []);\n\n maskRef.current = mask;\n optionsRef.current = options;\n\n const refCallback = useCallback((input: InputRef | null): void => {\n if (!input) {\n ref.current = null;\n return;\n }\n\n ref.current = resolveInputRef(input.input);\n\n if (ref.current && ref.current !== maskedElementRef.current) {\n withMask(maskRef.current, optionsRef.current)(ref.current);\n maskedElementRef.current = ref.current;\n }\n }, []);\n\n useEffect(() => {\n if (isServer || !ref.current || !register) return;\n register(ref.current);\n }, [register]);\n\n if (isServer) {\n const noop = (() => {\n // server doesn't have dom, so just do nothing\n }) as unknown as UseMaskInputAntdReturn;\n\n return setUnmaskedValue(noop, () => '');\n }\n\n return setUnmaskedValue(refCallback as UseMaskInputAntdReturn, unmaskedValue);\n}\n"]}
|