use-mask-input 3.10.1 → 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.
Files changed (46) hide show
  1. package/CHANGELOG.md +7 -1
  2. package/dist/antd.cjs +1 -65
  3. package/dist/antd.cjs.map +1 -1
  4. package/dist/antd.d.cts +12 -10
  5. package/dist/{antd.d.ts → antd.d.mts} +12 -10
  6. package/dist/antd.mjs +2 -0
  7. package/dist/antd.mjs.map +1 -0
  8. package/dist/index-BmKzoe0X.d.cts +836 -0
  9. package/dist/index-BmKzoe0X.d.mts +836 -0
  10. package/dist/index.cjs +1 -173
  11. package/dist/index.cjs.map +1 -1
  12. package/dist/index.d.cts +18 -15
  13. package/dist/{index.d.ts → index.d.mts} +18 -15
  14. package/dist/index.mjs +2 -0
  15. package/dist/index.mjs.map +1 -0
  16. package/dist/withMask-VWeBqi_u.cjs +2 -0
  17. package/dist/withMask-VWeBqi_u.cjs.map +1 -0
  18. package/dist/withMask-jrErtLYS.mjs +2 -0
  19. package/dist/withMask-jrErtLYS.mjs.map +1 -0
  20. package/package.json +42 -22
  21. package/dist/antd.js +0 -63
  22. package/dist/antd.js.map +0 -1
  23. package/dist/chunk-PMBRAXS4.cjs +0 -5876
  24. package/dist/chunk-PMBRAXS4.cjs.map +0 -1
  25. package/dist/chunk-XSTQDKDU.js +0 -5866
  26. package/dist/chunk-XSTQDKDU.js.map +0 -1
  27. package/dist/index-D8KkaDbQ.d.cts +0 -596
  28. package/dist/index-D8KkaDbQ.d.ts +0 -596
  29. package/dist/index.js +0 -165
  30. package/dist/index.js.map +0 -1
  31. package/src/antd/useHookFormMaskAntd.spec.ts +0 -181
  32. package/src/antd/useMaskInputAntd-server.spec.tsx +0 -37
  33. package/src/antd/useMaskInputAntd.spec.tsx +0 -131
  34. package/src/api/useHookFormMask.spec.ts +0 -259
  35. package/src/api/useMaskInput-server.spec.tsx +0 -30
  36. package/src/api/useMaskInput.spec.tsx +0 -238
  37. package/src/api/withHookFormMask.spec.ts +0 -179
  38. package/src/api/withMask.spec.ts +0 -137
  39. package/src/api/withTanStackFormMask.spec.ts +0 -76
  40. package/src/core/elementResolver.spec.ts +0 -175
  41. package/src/core/inputmask.spec.ts +0 -21
  42. package/src/core/maskConfig.spec.ts +0 -208
  43. package/src/core/maskEngine.spec.ts +0 -114
  44. package/src/utils/flow.spec.ts +0 -57
  45. package/src/utils/isServer.spec.ts +0 -15
  46. package/src/utils/moduleInterop.spec.ts +0 -37
@@ -0,0 +1,836 @@
1
+ import { RefCallback } from "react";
2
+
3
+ //#region ../../node_modules/.pnpm/react-hook-form@7.75.0_react@19.2.6/node_modules/react-hook-form/dist/types/path/common.d.ts
4
+ /**
5
+ * Type to query whether an array type T is a tuple type.
6
+ * @typeParam T - type which may be an array or tuple
7
+ * @example
8
+ * ```
9
+ * IsTuple<[number]> = true
10
+ * IsTuple<number[]> = false
11
+ * ```
12
+ */
13
+ type IsTuple<T extends ReadonlyArray<any>> = number extends T['length'] ? false : true;
14
+ /**
15
+ * Type which can be used to index an array or tuple type.
16
+ */
17
+ type ArrayKey = number;
18
+ /**
19
+ * Type which given a tuple type returns its own keys, i.e. only its indices.
20
+ * @typeParam T - tuple type
21
+ * @example
22
+ * ```
23
+ * TupleKeys<[number, string]> = '0' | '1'
24
+ * ```
25
+ */
26
+ type TupleKeys<T extends ReadonlyArray<any>> = Exclude<keyof T, keyof any[]>;
27
+ //#endregion
28
+ //#region ../../node_modules/.pnpm/react-hook-form@7.75.0_react@19.2.6/node_modules/react-hook-form/dist/types/path/eager.d.ts
29
+ /**
30
+ * Helper function to break apart T1 and check if any are equal to T2
31
+ *
32
+ * See {@link IsEqual}
33
+ */
34
+ type AnyIsEqual<T1, T2> = T1 extends T2 ? IsEqual<T1, T2> extends true ? true : never : never;
35
+ /**
36
+ * Helper type for recursively constructing paths through a type.
37
+ * This actually constructs the strings and recurses into nested
38
+ * object types.
39
+ *
40
+ * See {@link Path}
41
+ */
42
+ type PathImpl<K extends string | number, V, TraversedTypes> = V extends Primitive | BrowserNativeObject ? `${K}` : true extends AnyIsEqual<TraversedTypes, V> ? `${K}` : `${K}` | `${K}.${PathInternal<V, TraversedTypes | V>}`;
43
+ /**
44
+ * Helper type for recursively constructing paths through a type.
45
+ * This obscures the internal type param TraversedTypes from exported contract.
46
+ *
47
+ * See {@link Path}
48
+ */
49
+ type PathInternal<T, TraversedTypes = T> = T extends ReadonlyArray<infer V> ? IsTuple<T> extends true ? { [K in TupleKeys<T>]-?: PathImpl<K & string, T[K], TraversedTypes> }[TupleKeys<T>] : PathImpl<ArrayKey, V, TraversedTypes> : { [K in keyof T]-?: PathImpl<K & string, T[K], TraversedTypes> }[keyof T];
50
+ /**
51
+ * Type which eagerly collects all paths through a type
52
+ * @typeParam T - type which should be introspected
53
+ * @example
54
+ * ```
55
+ * Path<{foo: {bar: string}}> = 'foo' | 'foo.bar'
56
+ * ```
57
+ */
58
+ type Path<T> = T extends any ? PathInternal<T> : never;
59
+ /**
60
+ * See {@link Path}
61
+ */
62
+ type FieldPath<TFieldValues extends FieldValues> = Path<TFieldValues>;
63
+ /**
64
+ * Helper type for recursively constructing paths through a type.
65
+ * This actually constructs the strings and recurses into nested
66
+ * object types.
67
+ *
68
+ * See {@link ArrayPath}
69
+ */
70
+ type ArrayPathImpl<K extends string | number, V, TraversedTypes> = V extends Primitive | BrowserNativeObject ? IsAny<V> extends true ? string : never : V extends ReadonlyArray<infer U> ? U extends Primitive | BrowserNativeObject ? IsAny<V> extends true ? string : never : true extends AnyIsEqual<TraversedTypes, V> ? never : `${K}` | `${K}.${ArrayPathInternal<V, TraversedTypes | V>}` : true extends AnyIsEqual<TraversedTypes, V> ? never : `${K}.${ArrayPathInternal<V, TraversedTypes | V>}`;
71
+ /**
72
+ * Helper type for recursively constructing paths through a type.
73
+ * This obscures the internal type param TraversedTypes from exported contract.
74
+ *
75
+ * See {@link ArrayPath}
76
+ */
77
+ type ArrayPathInternal<T, TraversedTypes = T> = T extends ReadonlyArray<infer V> ? IsTuple<T> extends true ? { [K in TupleKeys<T>]-?: ArrayPathImpl<K & string, T[K], TraversedTypes> }[TupleKeys<T>] : ArrayPathImpl<ArrayKey, V, TraversedTypes> : { [K in keyof T]-?: ArrayPathImpl<K & string, T[K], TraversedTypes> }[keyof T];
78
+ /**
79
+ * Type which eagerly collects all paths through a type which point to an array
80
+ * type.
81
+ * @typeParam T - type which should be introspected.
82
+ * @example
83
+ * ```
84
+ * Path<{foo: {bar: string[], baz: number[]}}> = 'foo.bar' | 'foo.baz'
85
+ * ```
86
+ */
87
+ type ArrayPath<T> = T extends any ? ArrayPathInternal<T> : never;
88
+ /**
89
+ * Type to evaluate the type which the given path points to.
90
+ * @typeParam T - deeply nested type which is indexed by the path
91
+ * @typeParam P - path into the deeply nested type
92
+ * @example
93
+ * ```
94
+ * PathValue<{foo: {bar: string}}, 'foo.bar'> = string
95
+ * PathValue<[number, string], '1'> = string
96
+ * ```
97
+ */
98
+ type PathValue<T, P extends Path<T> | ArrayPath<T>> = PathValueImpl<T, P>;
99
+ type PathValueImpl<T, P extends string> = T extends any ? P extends `${infer K}.${infer R}` ? K extends keyof T ? undefined extends T[K] ? PathValueImpl<T[K], R> | undefined : PathValueImpl<T[K], R> : K extends `${ArrayKey}` ? T extends ReadonlyArray<infer V> ? PathValueImpl<V, R> : never : never : P extends keyof T ? T[P] : P extends `${ArrayKey}` ? T extends ReadonlyArray<infer V> ? V : T extends undefined ? undefined : never : never : never;
100
+ /**
101
+ * See {@link PathValue}
102
+ */
103
+ type FieldPathValue<TFieldValues extends FieldValues, TFieldPath extends FieldPath<TFieldValues>> = PathValue<TFieldValues, TFieldPath>;
104
+ //#endregion
105
+ //#region ../../node_modules/.pnpm/react-hook-form@7.75.0_react@19.2.6/node_modules/react-hook-form/dist/types/form.d.ts
106
+ type ChangeHandler = (event: {
107
+ target: any;
108
+ type?: any;
109
+ }) => Promise<void | boolean>;
110
+ type RefCallBack = (instance: any) => void;
111
+ type UseFormRegisterReturn<TFieldName extends InternalFieldName = InternalFieldName> = {
112
+ onChange: ChangeHandler;
113
+ onBlur: ChangeHandler;
114
+ ref: RefCallBack;
115
+ name: TFieldName;
116
+ min?: string | number;
117
+ max?: string | number;
118
+ maxLength?: number;
119
+ minLength?: number;
120
+ pattern?: string;
121
+ required?: boolean;
122
+ disabled?: boolean;
123
+ };
124
+ /**
125
+ * Register field into hook form with or without the actual DOM ref. You can invoke register anywhere in the component including at `useEffect`.
126
+ *
127
+ * @remarks
128
+ * [API](https://react-hook-form.com/docs/useform/register) • [Demo](https://codesandbox.io/s/react-hook-form-register-ts-ip2j3) • [Video](https://www.youtube.com/watch?v=JFIpCoajYkA)
129
+ *
130
+ * @param name - the path name to the form field value, name is required and unique
131
+ * @param options - register options include validation, disabled, unregister, value as and dependent validation
132
+ *
133
+ * @returns onChange, onBlur, name, ref, and native contribute attribute if browser validation is enabled.
134
+ *
135
+ * @example
136
+ * ```tsx
137
+ * // Register HTML native input
138
+ * <input {...register("input")} />
139
+ * <select {...register("select")} />
140
+ *
141
+ * // Register options
142
+ * <textarea {...register("textarea", { required: "This is required.", maxLength: 20 })} />
143
+ * <input type="number" {...register("name2", { valueAsNumber: true })} />
144
+ * <input {...register("name3", { deps: ["name2"] })} />
145
+ *
146
+ * // Register custom field at useEffect
147
+ * useEffect(() => {
148
+ * register("name4");
149
+ * register("name5", { value: "hiddenValue" });
150
+ * }, [register])
151
+ *
152
+ * // Register without ref
153
+ * const { onChange, onBlur, name } = register("name6")
154
+ * <input onChange={onChange} onBlur={onBlur} name={name} />
155
+ * ```
156
+ */
157
+ type UseFormRegister<TFieldValues extends FieldValues> = <TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>>(name: TFieldName, options?: RegisterOptions<TFieldValues, TFieldName>) => UseFormRegisterReturn<TFieldName>;
158
+ //#endregion
159
+ //#region ../../node_modules/.pnpm/react-hook-form@7.75.0_react@19.2.6/node_modules/react-hook-form/dist/types/utils.d.ts
160
+ interface File extends Blob {
161
+ readonly lastModified: number;
162
+ readonly name: string;
163
+ }
164
+ interface FileList$1 {
165
+ readonly length: number;
166
+ item(index: number): File | null;
167
+ [index: number]: File;
168
+ }
169
+ type Primitive = null | undefined | string | number | boolean | symbol | bigint;
170
+ type BrowserNativeObject = Date | FileList$1 | File;
171
+ /**
172
+ * Checks whether the type is any
173
+ * See {@link https://stackoverflow.com/a/49928360/3406963}
174
+ * @typeParam T - type which may be any
175
+ * ```
176
+ * IsAny<any> = true
177
+ * IsAny<string> = false
178
+ * ```
179
+ */
180
+ type IsAny<T> = 0 extends 1 & T ? true : false;
181
+ /**
182
+ * Checks whether T1 can be exactly (mutually) assigned to T2
183
+ * @typeParam T1 - type to check
184
+ * @typeParam T2 - type to check against
185
+ * ```
186
+ * IsEqual<string, string> = true
187
+ * IsEqual<'foo', 'foo'> = true
188
+ * IsEqual<string, number> = false
189
+ * IsEqual<string, number> = false
190
+ * IsEqual<string, 'foo'> = false
191
+ * IsEqual<'foo', string> = false
192
+ * IsEqual<'foo' | 'bar', 'foo'> = boolean // 'foo' is assignable, but 'bar' is not (true | false) -> boolean
193
+ * ```
194
+ */
195
+ type IsEqual<T1, T2> = T1 extends T2 ? (<G>() => G extends T1 ? 1 : 2) extends (<G>() => G extends T2 ? 1 : 2) ? true : false : false;
196
+ //#endregion
197
+ //#region ../../node_modules/.pnpm/react-hook-form@7.75.0_react@19.2.6/node_modules/react-hook-form/dist/types/fields.d.ts
198
+ type InternalFieldName = string;
199
+ type FieldValues = Record<string, any>;
200
+ //#endregion
201
+ //#region ../../node_modules/.pnpm/react-hook-form@7.75.0_react@19.2.6/node_modules/react-hook-form/dist/types/errors.d.ts
202
+ type Message = string;
203
+ //#endregion
204
+ //#region ../../node_modules/.pnpm/react-hook-form@7.75.0_react@19.2.6/node_modules/react-hook-form/dist/types/validator.d.ts
205
+ type ValidationValue = boolean | number | string | RegExp;
206
+ type ValidationRule<TValidationValue extends ValidationValue = ValidationValue> = TValidationValue | ValidationValueMessage<TValidationValue>;
207
+ type ValidationValueMessage<TValidationValue extends ValidationValue = ValidationValue> = {
208
+ value: TValidationValue;
209
+ message: Message;
210
+ };
211
+ type ValidateResult = Message | Message[] | boolean | undefined;
212
+ type Validate<TFieldValue, TFormValues> = (value: TFieldValue, formValues: TFormValues) => ValidateResult | Promise<ValidateResult>;
213
+ type RegisterOptions<TFieldValues extends FieldValues = FieldValues, TFieldName extends FieldPath<TFieldValues> = FieldPath<TFieldValues>> = Partial<{
214
+ required: Message | ValidationRule<boolean>;
215
+ min: ValidationRule<number | string>;
216
+ max: ValidationRule<number | string>;
217
+ maxLength: ValidationRule<number>;
218
+ minLength: ValidationRule<number>;
219
+ validate: Validate<FieldPathValue<TFieldValues, TFieldName>, TFieldValues> | Record<string, Validate<FieldPathValue<TFieldValues, TFieldName>, TFieldValues>>;
220
+ value: FieldPathValue<TFieldValues, TFieldName>;
221
+ setValueAs: (value: any) => any;
222
+ shouldUnregister?: boolean;
223
+ onChange?: (event: any) => void;
224
+ onBlur?: (event: any) => void;
225
+ disabled: boolean;
226
+ deps: FieldPath<TFieldValues> | FieldPath<TFieldValues>[];
227
+ }> & ({
228
+ pattern?: ValidationRule<RegExp>;
229
+ valueAsNumber?: false;
230
+ valueAsDate?: false;
231
+ } | {
232
+ pattern?: undefined;
233
+ valueAsNumber?: false;
234
+ valueAsDate?: true;
235
+ } | {
236
+ pattern?: undefined;
237
+ valueAsNumber?: true;
238
+ valueAsDate?: false;
239
+ });
240
+ //#endregion
241
+ //#region src/types/inputmask.types.d.ts
242
+ type Range = {
243
+ start: string;
244
+ end: string;
245
+ } | [string, string];
246
+ type PositionCaretOnClick = 'none' | 'lvp' | 'radixFocus' | 'select' | 'ignore';
247
+ type InputMode = 'verbatim' | 'none' | 'text' | 'decimal' | 'numeric' | 'tel' | 'search' | 'email' | 'url';
248
+ type Casing = 'upper' | 'lower' | 'title';
249
+ type DefinitionValidator = (chrs: string, maskset: any, pos: number, strict: boolean, opts: Options$1) => boolean | CommandObject;
250
+ interface Options$1 {
251
+ /**
252
+ * Change the mask placeholder. Instead of "_", you can change the unfilled
253
+ * characters mask as you like, simply by adding the placeholder option.
254
+ * For example, placeholder: " " will change the default autofill with empty
255
+ * values.
256
+ *
257
+ * @default "_"
258
+ */
259
+ placeholder?: string | undefined;
260
+ /**
261
+ * Definition of the symbols used to indicate an optional part in the mask.
262
+ *
263
+ * @default { start: "[", end: "]" }
264
+ */
265
+ optionalmarker?: Range | undefined;
266
+ /**
267
+ * Definition of the symbols used to indicate a quantifier in the mask.
268
+ *
269
+ * @default { start: "{", end: "}" }
270
+ */
271
+ quantifiermarker?: Range | undefined;
272
+ /**
273
+ * Definition of the symbols used to indicate a group in the mask.
274
+ *
275
+ * @default { start: "(", end: ")" }
276
+ */
277
+ groupmarker?: Range | undefined;
278
+ /**
279
+ * Definition of the symbols used to indicate an alternator part in the mask.
280
+ *
281
+ * @default "|"
282
+ */
283
+ alternatormarker?: string | undefined;
284
+ /**
285
+ * Definition of the symbols used to escape a part in the mask.
286
+ *
287
+ * @default "\\"
288
+ */
289
+ escapeChar?: string | undefined;
290
+ /**
291
+ * The mask to use.
292
+ */
293
+ mask?: string | string[] | ((opts: Options$1) => string | string[]) | undefined;
294
+ /**
295
+ * Use a regular expression as a mask. When using shorthands be aware that you need to double escape or use
296
+ * String.raw with a string literal.
297
+ */
298
+ regex?: string | undefined;
299
+ /**
300
+ * Execute a function when the mask is completed.
301
+ */
302
+ oncomplete?: (() => void) | undefined;
303
+ /**
304
+ * Execute a function when the mask is cleared.
305
+ */
306
+ onincomplete?: (() => void) | undefined;
307
+ /**
308
+ * Execute a function when the mask is cleared.
309
+ */
310
+ oncleared?: (() => void) | undefined;
311
+ /**
312
+ * Mask repeat function. Repeat the mask definition x-times.
313
+ * `*` ~ forever, otherwise specify an integer
314
+ *
315
+ * @default 0
316
+ */
317
+ repeat?: number | string | undefined;
318
+ /**
319
+ * Toggle to allocate as much possible or the opposite. Non-greedy repeat function. With the non-greedy option
320
+ * set to `false`, you can specify `*` as repeat. This makes an endless repeat.
321
+ *
322
+ * @default false
323
+ */
324
+ greedy?: boolean | undefined;
325
+ /**
326
+ * Automatically unmask the value when retrieved.
327
+ *
328
+ * When setting this option to true the plugin also expects the initial value from the server to be unmasked.
329
+ *
330
+ * @default false
331
+ */
332
+ autoUnmask?: boolean | undefined;
333
+ /**
334
+ * Remove the mask before submitting the form.
335
+ *
336
+ * @default false
337
+ */
338
+ removeMaskOnSubmit?: boolean | undefined;
339
+ /**
340
+ * Remove the empty mask on blur or when not empty remove the optional trailing part.
341
+ *
342
+ * @default true
343
+ */
344
+ clearMaskOnLostFocus?: boolean | undefined;
345
+ /**
346
+ * Toggle to insert or overwrite input. This option can be altered by pressing the Insert key.
347
+ *
348
+ * @default true
349
+ */
350
+ insertMode?: boolean | undefined;
351
+ /**
352
+ * Show selected caret when `insertMode = false`.
353
+ *
354
+ * @default true
355
+ */
356
+ insertModeVisual?: boolean | undefined;
357
+ /**
358
+ * Clear the incomplete input on blur.
359
+ *
360
+ * @default false
361
+ */
362
+ clearIncomplete?: boolean | undefined;
363
+ /**
364
+ * The alias to use.
365
+ *
366
+ * @default null
367
+ */
368
+ alias?: string | undefined;
369
+ /**
370
+ * Callback to implement autocomplete on certain keys for example.
371
+ */
372
+ onKeyDown?: ((event: KeyboardEvent, buffer: string[], caretPos: {
373
+ begin: number;
374
+ end: number;
375
+ }, opts: Options$1) => void) | undefined;
376
+ /**
377
+ * Executes before masking the initial value to allow preprocessing of the initial value.
378
+ */
379
+ onBeforeMask?: ((initialValue: string, opts: Options$1) => string) | undefined;
380
+ /**
381
+ * This callback allows for preprocessing the pasted value before actually handling the value for masking.
382
+ * This can be useful for stripping away some characters before processing. You can also disable pasting
383
+ * a value by returning false in the `onBeforePaste` call.
384
+ */
385
+ onBeforePaste?: ((pastedValue: string, opts: Options$1) => string) | undefined;
386
+ /**
387
+ * Executes before writing to the masked element. Use this to do some extra processing of the input. This can
388
+ * be useful when implementing an alias, ex. decimal alias, autofill the digits when leaving the inputfield.
389
+ */
390
+ onBeforeWrite?: ((event: KeyboardEvent, buffer: string[], caretPos: number, opts: Options$1) => CommandObject) | undefined;
391
+ /**
392
+ * Executes after unmasking to allow post-processing of the unmaskedvalue.
393
+ *
394
+ * @returns New unmasked value
395
+ */
396
+ onUnMask?: ((maskedValue: string, unmaskedValue: string) => string) | undefined;
397
+ /**
398
+ * Shows the mask when the input gets focus.
399
+ *
400
+ * @default true
401
+ */
402
+ showMaskOnFocus?: boolean | undefined;
403
+ /**
404
+ * Shows the mask when the input is hevered by the mouse cursor.
405
+ *
406
+ * @default true
407
+ */
408
+ showMaskOnHover?: boolean | undefined;
409
+ /**
410
+ * Callback function is executed on every keyvalidation with the key, result as the parameter.
411
+ */
412
+ onKeyValidation?: ((key: number, result: boolean) => void) | undefined;
413
+ /**
414
+ * A character which can be used to skip an optional part of a mask.
415
+ *
416
+ * @default " "
417
+ */
418
+ skipOptionalPartCharacter?: string | undefined;
419
+ /**
420
+ * Numeric input direction. Keeps the caret at the end.
421
+ *
422
+ * @default false
423
+ */
424
+ numericInput?: boolean | undefined;
425
+ /**
426
+ * Align the input to the right
427
+ *
428
+ * By setting the rightAlign you can specify to right-align an inputmask. This is only applied in combination of
429
+ * the `numericInput` option or the `dir-attribute`.
430
+ *
431
+ * @default true
432
+ */
433
+ rightAlign?: boolean | undefined;
434
+ /**
435
+ * Make escape behave like undo. (ctrl-Z) Pressing escape reverts the value to the value before focus.
436
+ *
437
+ * @default true
438
+ */
439
+ undoOnEscape?: boolean | undefined;
440
+ /**
441
+ * Define the radixpoint (decimal separator)
442
+ *
443
+ * @default ""
444
+ */
445
+ radixPoint?: string | undefined;
446
+ /**
447
+ * Define the groupseparator.
448
+ *
449
+ * @default ""
450
+ */
451
+ groupSeparator?: string | undefined;
452
+ /**
453
+ * Use in combination with the alternator syntax Try to keep the mask static while typing. Decisions to alter the
454
+ * mask will be postponed if possible.
455
+ *
456
+ * ex. $(selector).inputmask({ mask: ["+55-99-9999-9999", "+55-99-99999-9999", ], keepStatic: true });
457
+ *
458
+ * typing 1212345123 => should result in +55-12-1234-5123 type extra 4 => switch to +55-12-12345-1234
459
+ *
460
+ * When the option is not set, it will default to `false`, except for multiple masks it will default to `true`!
461
+ */
462
+ keepStatic?: boolean | null | undefined;
463
+ /**
464
+ * When enabled the caret position is set after the latest valid position on TAB.
465
+ *
466
+ * @default true
467
+ */
468
+ positionCaretOnTab?: boolean | undefined;
469
+ /**
470
+ * Allows for tabbing through the different parts of the masked field.
471
+ *
472
+ * @default false
473
+ */
474
+ tabThrough?: boolean | undefined;
475
+ /**
476
+ * List with the supported input types
477
+ *
478
+ * @default ["text", "tel", "url", "password", "search"]
479
+ */
480
+ supportsInputType?: string[] | undefined;
481
+ /**
482
+ * Specify keyCodes which should not be considered in the keypress event, otherwise the `preventDefault` will
483
+ * stop their default behavior especially in FF.
484
+ */
485
+ ignorables?: number[] | undefined;
486
+ /**
487
+ * With this call-in (hook) you can override the default implementation of the isComplete function.
488
+ */
489
+ isComplete?: ((buffer: string[], opts: Options$1) => boolean) | undefined;
490
+ /**
491
+ * Hook to postValidate the result from `isValid`. Useful for validating the entry as a whole.
492
+ */
493
+ postValidation?: ((buffer: string[], pos: number, char: string, currentResult: boolean, opts: Options$1, maskset: unknown, strict: boolean, fromCheckval: boolean) => boolean | CommandObject) | undefined;
494
+ /**
495
+ * Hook to preValidate the input. Useful for validating regardless of the definition.
496
+ *
497
+ * When returning `true`, the normal validation kicks in, otherwise, it is skipped.
498
+ *
499
+ * When returning a command object the actions are executed and further validation is stopped. If you want to
500
+ * continue further validation, you need to add the `rewritePosition` action.
501
+ */
502
+ preValidation?: ((buffer: string[], pos: number, char: string, isSelection: boolean, opts: Options$1, maskset: unknown, caretPos: {
503
+ begin: number;
504
+ end: number;
505
+ }, strict: boolean) => boolean | CommandObject) | undefined;
506
+ /**
507
+ * The `staticDefinitionSymbol` option is used to indicate that the static entries in the mask can match a
508
+ * certain definition. Especially useful with alternators so that static element in the mask can match
509
+ * another alternation.
510
+ *
511
+ * @default undefined
512
+ */
513
+ staticDefinitionSymbol?: string | undefined;
514
+ /**
515
+ * Just in time masking. With the `jitMasking` option you can enable jit masking. The mask will only be
516
+ * visible for the user entered characters.
517
+ *
518
+ * @default false
519
+ */
520
+ jitMasking?: boolean | undefined;
521
+ /**
522
+ * Return nothing from the input `value` property when the user hasn't entered anything. If this is false,
523
+ * the mask might be returned.
524
+ *
525
+ * @default true
526
+ */
527
+ nullable?: boolean | undefined;
528
+ /**
529
+ * Disable value property patching
530
+ *
531
+ * @default false
532
+ */
533
+ noValuePatching?: boolean | undefined;
534
+ /**
535
+ * Positioning of the caret on click.
536
+ *
537
+ * Options:
538
+ *
539
+ * * `none`
540
+ * * `lvp` - based on the last valid position (default)
541
+ * * `radixFocus` - position caret to radixpoint on initial click
542
+ * * `select` - select the whole input
543
+ * * `ignore` - ignore the click and continue the mask
544
+ *
545
+ * @default "lvp"
546
+ */
547
+ positionCaretOnClick?: PositionCaretOnClick | undefined;
548
+ /**
549
+ * Apply casing at the mask-level.
550
+ *
551
+ * @default undefined
552
+ */
553
+ casing?: Casing | undefined;
554
+ /**
555
+ * Specify the inputmode - already in place for when browsers start to support them
556
+ * https://html.spec.whatwg.org/#input-modalities:-the-inputmode-attribute
557
+ *
558
+ * @default "verbatim"
559
+ */
560
+ inputmode?: InputMode | undefined;
561
+ /**
562
+ * Specify to use the `data-inputmask` attributes or to ignore them.
563
+ *
564
+ * If you don't use data attributes you can disable the import by specifying `importDataAttributes: false`.
565
+ *
566
+ * @default true
567
+ */
568
+ importDataAttributes?: boolean | undefined;
569
+ /**
570
+ * Alter the behavior of the char shifting on entry or deletion.
571
+ *
572
+ * In some cases shifting the mask entries or deletion should be more restrictive.
573
+ *
574
+ * Ex. date masks. Shifting month to day makes no sense
575
+ *
576
+ * @default true
577
+ */
578
+ shiftPositions?: boolean | undefined;
579
+ /**
580
+ * Use the default defined definitions from the prototype.
581
+ *
582
+ * @default true
583
+ */
584
+ usePrototypeDefinitions?: boolean | undefined;
585
+ /**
586
+ * Minimum value. This needs to be in the same format as the `inputFormat` when used with the datetime alias.
587
+ */
588
+ min?: string | number | undefined;
589
+ /**
590
+ * Maximum value. This needs to be in the same format as the `inputFormat` when used with the datetime alias.
591
+ */
592
+ max?: string | number | undefined;
593
+ /**
594
+ * Number of fractionalDigits.
595
+ *
596
+ * Possible values:
597
+ *
598
+ * * A number describing the number of fractional digits.
599
+ * * `*`
600
+ * * Quantifier syntax like `2,4`. When the quantifier syntax is used, the `digitsOptional` option is ignored
601
+ *
602
+ * @default "*"
603
+ */
604
+ digits?: string | number | undefined;
605
+ /**
606
+ * Specify wheter the digits are optional.
607
+ *
608
+ * @default true
609
+ */
610
+ digitsOptional?: boolean | undefined;
611
+ /**
612
+ * Enforces the decimal part when leaving the input field.
613
+ *
614
+ * @default false
615
+ */
616
+ enforceDigitsOnBlur?: boolean | undefined;
617
+ /**
618
+ * Allow to enter -.
619
+ *
620
+ * @default true
621
+ */
622
+ allowMinus?: boolean | undefined;
623
+ /**
624
+ * Define your negationSymbol.
625
+ *
626
+ * @default { front: "-", back: "" }
627
+ */
628
+ negationSymbol?: {
629
+ front: string;
630
+ back: string;
631
+ } | undefined;
632
+ /**
633
+ * Define a prefix.
634
+ *
635
+ * @default ""
636
+ */
637
+ prefix?: string | undefined;
638
+ /**
639
+ * Define a suffix.
640
+ *
641
+ * @default ""
642
+ */
643
+ suffix?: string | undefined;
644
+ /**
645
+ * Set the maximum value when the user types a number which is greater that the value of max.
646
+ *
647
+ * @default false
648
+ */
649
+ SetMaxOnOverflow?: boolean | undefined;
650
+ /**
651
+ * Define the step the ctrl-up & ctrl-down must take.
652
+ *
653
+ * @default 1
654
+ */
655
+ step?: number | undefined;
656
+ /**
657
+ * Make unmasking returning a number instead of a string.
658
+ *
659
+ * Be warned that using the unmaskAsNumber option together with jQuery.serialize will fail as serialize expects a string. (See issue #1288)
660
+ *
661
+ * @default false
662
+ */
663
+ unmaskAsNumber?: boolean | undefined;
664
+ /**
665
+ * Indicates whether the value passed for initialization is text or a number.
666
+ *
667
+ * * `text` - radixpoint should be the same as in the options
668
+ * * `number` - radixpoint should be a . as the default for a number in js
669
+ *
670
+ * @default "text"
671
+ */
672
+ inputType?: 'text' | 'number' | undefined;
673
+ /**
674
+ * Set the function for rounding the values when set.
675
+ *
676
+ * Other examples:
677
+ * * `Math.floor`
678
+ * * `fn(x) { // do your own rounding logic // return x; }`
679
+ *
680
+ * @default Math.round
681
+ */
682
+ roundingFN?: ((input: number) => number) | undefined;
683
+ /**
684
+ * Define shortcuts. This will allow typing 1k => 1000, 2m => 2000000
685
+ *
686
+ * To disable just pass shortcuts: `null` as option
687
+ *
688
+ * @default {k: "000", m: "000000"}
689
+ */
690
+ shortcuts?: Record<string, string> | null | undefined;
691
+ /**
692
+ * Format used to input a date. This option is only effective for the datetime alias.
693
+ *
694
+ * Supported symbols
695
+ *
696
+ * * `d` - Day of the month as digits; no leading zero for single-digit days.
697
+ * * `dd` - Day of the month as digits; leading zero for single-digit days.
698
+ * * `ddd` - Day of the week as a three-letter abbreviation.
699
+ * * `dddd` - Day of the week as its full name.
700
+ * * `m` - Month as digits; no leading zero for single-digit months.
701
+ * * `mm` - Month as digits; leading zero for single-digit months.
702
+ * * `mmm` - Month as a three-letter abbreviation.
703
+ * * `mmmm` - Month as its full name.
704
+ * * `yy` - Year as last two digits; leading zero for years less than 10.
705
+ * * `yyyy` - Year as 4 digits.
706
+ * * `h` - Hours; no leading zero for single-digit hours (12-hour clock).
707
+ * * `hh` - Hours; leading zero for single-digit hours (12-hour clock).
708
+ * * `hx` - Hours; no limit; `x` = number of digits ~ use as h2, h3, ...
709
+ * * `H` - Hours; no leading zero for single-digit hours (24-hour clock).
710
+ * * `HH` - Hours; leading zero for single-digit hours (24-hour clock).
711
+ * * `Hx` - Hours; no limit; `x` = number of digits ~ use as H2, H3, ...
712
+ * * `M` - Minutes; no leading zero for single-digit minutes. Uppercase M unlike CF timeFormat's m to avoid
713
+ * conflict with months.
714
+ * * `MM` - Minutes; leading zero for single-digit minutes. Uppercase MM unlike CF timeFormat's mm to avoid
715
+ * conflict with months.
716
+ * * `s` - Seconds; no leading zero for single-digit seconds.
717
+ * * `ss` - Seconds; leading zero for single-digit seconds.
718
+ * * `l` - Milliseconds. 3 digits.
719
+ * * `L` - Milliseconds. 2 digits.
720
+ * * `t` - Lowercase, single-character time marker string: a or p.
721
+ * * `tt` - Two-character time marker string: am or pm.
722
+ * * `T` - Single-character time marker string: A or P.
723
+ * * `TT` - Two-character time marker string: AM or PM.
724
+ * * `Z` - US timezone abbreviation, e.g. EST or MDT. With non-US timezones or in the Opera browser, the
725
+ * GMT/UTC offset is returned, e.g. GMT-0500
726
+ * * `o` - GMT/UTC timezone offset, e.g. -0500 or +0230.
727
+ * * `S` - The date's ordinal suffix (st, nd, rd, or th). Works well with d.
728
+ *
729
+ * @default "isoDateTime"
730
+ */
731
+ inputFormat?: string | undefined;
732
+ /**
733
+ * Format of the unmasked value. This is only effective when used with the datetime alias.
734
+ */
735
+ outputFormat?: string | undefined;
736
+ /**
737
+ * Visual format when the input looses focus
738
+ */
739
+ displayFormat?: string | undefined;
740
+ /**
741
+ * Add new definitions to this inputmask.
742
+ */
743
+ definitions?: Record<string, Definition> | undefined;
744
+ /**
745
+ * Enable/disable prefilling of the year.
746
+ * Although you can just over type the proposed value without deleting, many seems to see a problem with the year prediction.
747
+ * This options is to disable this feature.
748
+ *
749
+ * @default true
750
+ */
751
+ prefillYear?: boolean | undefined;
752
+ }
753
+ interface Definition {
754
+ validator: string | DefinitionValidator;
755
+ casing?: Casing | undefined;
756
+ cardinality?: number | undefined;
757
+ placeholder?: string | undefined;
758
+ definitionSymbol?: string | undefined;
759
+ }
760
+ interface InsertPosition {
761
+ /**
762
+ * Position to insert.
763
+ */
764
+ pos: number;
765
+ /**
766
+ * Character to insert.
767
+ */
768
+ c: string;
769
+ /**
770
+ * @default true
771
+ */
772
+ fromIsValid?: boolean | undefined;
773
+ /**
774
+ * @default true
775
+ */
776
+ strict?: boolean | undefined;
777
+ }
778
+ interface CommandObject {
779
+ /**
780
+ * Position to insert.
781
+ */
782
+ pos?: number | undefined;
783
+ /**
784
+ * Character to insert.
785
+ */
786
+ c?: string | undefined;
787
+ /**
788
+ * Position of the caret.
789
+ */
790
+ caret?: number | undefined;
791
+ /**
792
+ * Position(s) to remove.
793
+ */
794
+ remove?: number | number[] | undefined;
795
+ /**
796
+ * Position(s) to add.
797
+ */
798
+ insert?: InsertPosition | InsertPosition[] | undefined;
799
+ /**
800
+ * * `true` => refresh validPositions from the complete buffer .
801
+ * * `{ start: , end: }` => refresh from start to end.
802
+ */
803
+ refreshFromBuffer?: true | {
804
+ start: number;
805
+ end: number;
806
+ } | undefined;
807
+ /**
808
+ * Rewrite the maskPos within the isvalid function.
809
+ */
810
+ rewritePosition?: number | undefined;
811
+ }
812
+ //#endregion
813
+ //#region src/types/index.d.ts
814
+ type Mask = 'datetime' | 'email' | 'numeric' | 'currency' | 'decimal' | 'integer' | 'percentage' | 'url' | 'ip' | 'mac' | 'ssn' | 'brl-currency' | 'cpf' | 'cnpj' | 'br-bank-account' | 'br-bank-agency' | (string & {}) | (string[] & {}) | null;
815
+ type Options = Options$1;
816
+ type Input = HTMLInputElement | HTMLTextAreaElement | HTMLElement;
817
+ interface UnmaskedValueApi {
818
+ unmaskedValue: () => string;
819
+ }
820
+ type UseMaskInputReturn = RefCallback<HTMLElement | null> & UnmaskedValueApi;
821
+ interface UseHookFormMaskReturn<T extends FieldValues> extends UseFormRegisterReturn<Path<T>>, UnmaskedValueApi {
822
+ ref: RefCallback<HTMLElement | null>;
823
+ prevRef: RefCallback<HTMLElement | null>;
824
+ }
825
+ interface TanStackFormInputProps {
826
+ name?: string;
827
+ ref?: RefCallback<HTMLElement | null>;
828
+ [key: string]: unknown;
829
+ }
830
+ type UseTanStackFormMaskReturn<T extends TanStackFormInputProps = TanStackFormInputProps> = Omit<T, 'ref'> & {
831
+ ref: RefCallback<HTMLElement | null>;
832
+ prevRef: RefCallback<HTMLElement | null> | undefined;
833
+ } & UnmaskedValueApi;
834
+ //#endregion
835
+ export { UnmaskedValueApi as a, UseTanStackFormMaskReturn as c, UseFormRegister as d, UseFormRegisterReturn as f, TanStackFormInputProps as i, RegisterOptions as l, Mask as n, UseHookFormMaskReturn as o, Path as p, Options as r, UseMaskInputReturn as s, Input as t, FieldValues as u };
836
+ //# sourceMappingURL=index-BmKzoe0X.d.mts.map