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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "use-mask-input",
3
- "version": "3.10.3",
3
+ "version": "3.11.0",
4
4
  "private": false,
5
5
  "description": "A react Hook for build elegant input masks. Compatible with React Hook Form",
6
6
  "license": "MIT",
@@ -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
+ }
package/src/index.tsx CHANGED
@@ -7,6 +7,8 @@ export {
7
7
  withTanStackFormMask,
8
8
  } from './api';
9
9
 
10
+ export { formatWithMask, unformatWithMask } from './core';
11
+
10
12
  export type {
11
13
  Input,
12
14
  Mask,