use-mask-input 3.10.3 → 3.11.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/CHANGELOG.md +6 -0
- package/README.md +2 -0
- package/dist/antd.cjs +1 -1
- package/dist/antd.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +23 -1
- package/dist/index.d.mts +23 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/{withMask-B4sSnU9K.cjs → withMask-BkTzstzt.cjs} +2 -2
- package/dist/{withMask-B4sSnU9K.cjs.map → withMask-BkTzstzt.cjs.map} +1 -1
- package/dist/{withMask-CKM8Ug6z.mjs → withMask-C-wAMt0W.mjs} +2 -2
- package/dist/{withMask-CKM8Ug6z.mjs.map → withMask-C-wAMt0W.mjs.map} +1 -1
- package/package.json +1 -1
- package/src/core/maskEngine.ts +28 -0
- package/src/index.tsx +2 -0
package/package.json
CHANGED
package/src/core/maskEngine.ts
CHANGED
|
@@ -45,3 +45,31 @@ export function applyMaskToElement(
|
|
|
45
45
|
maskInstance.mask(element);
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Formats a raw value using the given mask, without needing a mounted element.
|
|
51
|
+
* Useful for displaying already-persisted (unmasked) values in the UI.
|
|
52
|
+
*
|
|
53
|
+
* @param value - The raw value to format
|
|
54
|
+
* @param mask - The mask pattern
|
|
55
|
+
* @param options - Optional configuration options
|
|
56
|
+
* @returns The masked value
|
|
57
|
+
*/
|
|
58
|
+
export function formatWithMask(value: string, mask: Mask, options?: Options): string {
|
|
59
|
+
const inputmaskInstance = moduleInterop(inputmask);
|
|
60
|
+
return inputmaskInstance.format(value, getMaskOptions(mask, options));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Removes the mask from a formatted value, without needing a mounted element.
|
|
65
|
+
* Useful for sanitizing input before sending it to the backend.
|
|
66
|
+
*
|
|
67
|
+
* @param value - The masked value to unformat
|
|
68
|
+
* @param mask - The mask pattern
|
|
69
|
+
* @param options - Optional configuration options
|
|
70
|
+
* @returns The raw, unmasked value
|
|
71
|
+
*/
|
|
72
|
+
export function unformatWithMask(value: string, mask: Mask, options?: Options): string {
|
|
73
|
+
const inputmaskInstance = moduleInterop(inputmask);
|
|
74
|
+
return inputmaskInstance.unmask(value, getMaskOptions(mask, options));
|
|
75
|
+
}
|