use-mask-input 3.4.2 → 3.5.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 +7 -0
- package/LICENSE +21 -0
- package/README.md +77 -1
- package/dist/index.d.ts +2 -1
- package/package.json +1 -1
- package/src/index.tsx +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
# [3.5.0](https://github.com/eduardoborges/use-mask-input/compare/3.4.2...3.5.0) (2025-07-14)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* Export types module for better TypeScript support ([#123](https://github.com/eduardoborges/use-mask-input/issues/123)) ([a4ee805](https://github.com/eduardoborges/use-mask-input/commit/a4ee805fa54490a11cd5f686fbf0fdf89f5761f4))
|
|
7
|
+
|
|
1
8
|
## [3.4.2](https://github.com/eduardoborges/use-mask-input/compare/3.4.1...3.4.2) (2024-11-22)
|
|
2
9
|
|
|
3
10
|
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Eduardo Borges
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -229,4 +229,80 @@ You can define the mask as a function that can allow you to preprocess the resul
|
|
|
229
229
|
|
|
230
230
|
## API
|
|
231
231
|
|
|
232
|
-
(
|
|
232
|
+
### `withMask(mask, options?)`
|
|
233
|
+
Attach a mask to an input via a `ref`:
|
|
234
|
+
```ts
|
|
235
|
+
const attach = withMask('999-9999', { clearIncomplete: true });
|
|
236
|
+
<input ref={attach} />;
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
- **mask**: `string` \| `string[]` \| `(opts: Options) => string \| string[]`
|
|
240
|
+
- **options**: `Options` (see below)
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
### `useHookFormMask(registerFn)`
|
|
245
|
+
Integrate masking with React-Hook-Form’s `register`:
|
|
246
|
+
```ts
|
|
247
|
+
const maskedRegister = useHookFormMask(register);
|
|
248
|
+
<input {...maskedRegister('phone', '999-9999', { showMaskOnFocus: true })} />;
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
---
|
|
252
|
+
|
|
253
|
+
### `Options`
|
|
254
|
+
|
|
255
|
+
| Option | Description | Type | Default |
|
|
256
|
+
|----------------------------|------------------------------------------------------------------------------------------------------|------------------------------|----------------------------------------------------|
|
|
257
|
+
| `mask` | Static mask, array of masks, or function returning mask(s) | `string \| string[] \| fn` | — |
|
|
258
|
+
| `regex` | Treat the mask as a regular expression | `string` | — |
|
|
259
|
+
| `placeholder` | Character shown for empty slots | `string` | `"_"` |
|
|
260
|
+
| `optionalmarker` | Delimiters for optional sections | `{ start: string; end: string }` | `{ start: "[", end: "]" }` |
|
|
261
|
+
| `quantifiermarker` | Delimiters for repetition ranges | `{ start: string; end: string }` | `{ start: "{", end: "}" }` |
|
|
262
|
+
| `groupmarker` | Delimiters for grouping | `{ start: string; end: string }` | `{ start: "(", end: ")" }` |
|
|
263
|
+
| `alternatormarker` | Character separating alternator options | `string` | `"|"` |
|
|
264
|
+
| `escapeChar` | Character to escape mask meta-symbols | `string` | `"\\"` |
|
|
265
|
+
| `definitions` | Custom symbol→validator mappings | `Record<string,Definition>` | — |
|
|
266
|
+
| `alias` | Built-in preset (“datetime”, “currency”, etc.) | `string` | — |
|
|
267
|
+
| `inputFormat` | Format string for datetime alias | `string` | — |
|
|
268
|
+
| `outputFormat` | Format of unmasked datetime value | `string` | — |
|
|
269
|
+
| `displayFormat` | Visual format when losing focus (datetime alias) | `string` | — |
|
|
270
|
+
| `clearMaskOnLostFocus` | Trim placeholders on blur | `boolean` | `true` |
|
|
271
|
+
| `showMaskOnFocus` | Show full mask when focused | `boolean` | `true` |
|
|
272
|
+
| `showMaskOnHover` | Show mask when hovering | `boolean` | `true` |
|
|
273
|
+
| `clearIncomplete` | Clear input if not fully filled on blur | `boolean` | `false` |
|
|
274
|
+
| `removeMaskOnSubmit` | Strip mask chars on form submit | `boolean` | `false` |
|
|
275
|
+
| `autoUnmask` | Always return unmasked value | `boolean` | `false` |
|
|
276
|
+
| `jitMasking` | Just-in-time masking (only show entered chars) | `boolean` | `false` |
|
|
277
|
+
| `nullable` | Return `""` if no input | `boolean` | `true` |
|
|
278
|
+
| `noValuePatching` | Disable `.value` patching hacks | `boolean` | `false` |
|
|
279
|
+
| `insertMode` | Insert vs overwrite | `boolean` | `true` |
|
|
280
|
+
| `insertModeVisual` | Highlight caret in overwrite mode | `boolean` | `true` |
|
|
281
|
+
| `positionCaretOnClick` | Caret placement on click: `"none"`, `"lvp"`, `"radixFocus"`, `"select"`, `"ignore"` | `string` | `"lvp"` |
|
|
282
|
+
| `positionCaretOnTab` | Move caret to last valid position on Tab | `boolean` | `true` |
|
|
283
|
+
| `tabThrough` | Tab between mask sections | `boolean` | `false` |
|
|
284
|
+
| `skipOptionalPartCharacter`| Character to skip optional blocks | `string` | `" "` |
|
|
285
|
+
| `numericInput` | Keep caret at end for numeric | `boolean` | `false` |
|
|
286
|
+
| `rightAlign` | Right-align numeric | `boolean` | `true` |
|
|
287
|
+
| `radixPoint` | Decimal separator | `string` | `""` |
|
|
288
|
+
| `groupSeparator` | Thousands separator | `string` | `""` |
|
|
289
|
+
| `digits` | Fractional digits count or range | `number \| string` | `"*"` |
|
|
290
|
+
| `digitsOptional` | Allow skipping fractional digits | `boolean` | `true` |
|
|
291
|
+
| `enforceDigitsOnBlur` | Force show fractional digits on blur | `boolean` | `false` |
|
|
292
|
+
| `allowMinus` | Permit minus sign | `boolean` | `true` |
|
|
293
|
+
| `negationSymbol` | Symbols for negative (e.g. `{ front: "-", back: "" }`) | `object` | `{ front: "-", back: "" }` |
|
|
294
|
+
| `prefix` | Static text prepended | `string` | `""` |
|
|
295
|
+
| `suffix` | Static text appended | `string` | `""` |
|
|
296
|
+
| `SetMaxOnOverflow` | Clamp value at `max` if exceeded | `boolean` | `false` |
|
|
297
|
+
| `min` | Minimum allowed (numeric/datetime) | `string \| number` | — |
|
|
298
|
+
| `max` | Maximum allowed (numeric/datetime) | `string \| number` | — |
|
|
299
|
+
| `step` | `Ctrl+↑/↓` increment step (numeric) | `number` | `1` |
|
|
300
|
+
| `repeat` | Repeat mask N times or `"*"` for infinite | `number \| string` | `0` |
|
|
301
|
+
| `greedy` | Greedy vs non-greedy repeat | `boolean` | `false` |
|
|
302
|
+
| `keepStatic` | Delay switching in alternator/multi-mask scenarios | `boolean \| null` | (multi-mask: `true`) |
|
|
303
|
+
| `importDataAttributes` | Read HTML `data-inputmask-*` attrs | `boolean` | `true` |
|
|
304
|
+
| `supportsInputType` | Allow masking on specified `inputmode` types | `string[]` | `["text","tel","url",`<br>`"password","search"]` |
|
|
305
|
+
| `ignorables` | Key codes to ignore | `number[]` | — |
|
|
306
|
+
| `prefillYear` | Pre-fill century in datetime alias | `boolean` | `true` |
|
|
307
|
+
| `casing` | Force letter casing: `"upper"`, `"lower"`, `"title"` | `string` | — |
|
|
308
|
+
| `inputmode` | Hint for on-screen keyboards (HTML `inputmode`) | `string` | `"verbatim"` |
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as react_hook_form from 'react-hook-form';
|
|
2
2
|
import { UseFormRegisterReturn, FieldValues, RegisterOptions, UseFormRegister, Path } from 'react-hook-form';
|
|
3
|
+
export { UseFormRegister, UseFormRegisterReturn } from 'react-hook-form';
|
|
3
4
|
import * as react from 'react';
|
|
4
5
|
import { RefCallback } from 'react';
|
|
5
6
|
|
|
@@ -606,4 +607,4 @@ interface UseInputMaskOptions {
|
|
|
606
607
|
}
|
|
607
608
|
declare const useInputMask: (props: UseInputMaskOptions) => react.RefObject<HTMLInputElement>;
|
|
608
609
|
|
|
609
|
-
export { useHookFormMask, useInputMask, withHookFormMask, withMask };
|
|
610
|
+
export { type Input, type Mask, type Options, useHookFormMask, useInputMask, withHookFormMask, withMask };
|
package/package.json
CHANGED
package/src/index.tsx
CHANGED