ngx-mask 22.2.0 → 22.2.1
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/README.md +11 -2
- package/llms-full.txt +459 -0
- package/llms.txt +31 -0
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
<p align="center">
|
|
2
|
+
<img src=".github/assets/logo.svg" alt="ngx-mask logo" width="120" height="120" />
|
|
3
|
+
</p>
|
|
4
|
+
|
|
1
5
|
<h1 align="center">ngx-mask</h1>
|
|
2
6
|
|
|
3
7
|
<p align="center">
|
|
@@ -17,8 +21,8 @@ A powerful Angular directive for input masking with customizable patterns
|
|
|
17
21
|
<a href="https://www.npmjs.com/package/ngx-mask">
|
|
18
22
|
<img src="https://img.shields.io/npm/dm/ngx-mask.svg" alt="npm monthly downloads">
|
|
19
23
|
</a>
|
|
20
|
-
<a href="https://
|
|
21
|
-
<img src="https://img.shields.io/
|
|
24
|
+
<a href="https://github.com/NepipenkoIgor/ngx-mask/commits/develop">
|
|
25
|
+
<img src="https://img.shields.io/github/last-commit/NepipenkoIgor/ngx-mask.svg" alt="Last commit">
|
|
22
26
|
</a>
|
|
23
27
|
<a href="https://www.npmjs.com/package/ngx-mask">
|
|
24
28
|
<img src="https://img.shields.io/npm/types/ngx-mask.svg" alt="TypeScript support">
|
|
@@ -45,6 +49,7 @@ A powerful Angular directive for input masking with customizable patterns
|
|
|
45
49
|
- [Quick Start](#quick-start)
|
|
46
50
|
- [Standalone Applications](#standalone-applications)
|
|
47
51
|
- [NgModule-based Applications](#ngmodule-based-applications)
|
|
52
|
+
- [For AI Agents](#for-ai-agents)
|
|
48
53
|
- [Contributing](#contributing)
|
|
49
54
|
|
|
50
55
|
## Features
|
|
@@ -251,6 +256,10 @@ export class AppModule {}
|
|
|
251
256
|
export class AppModule {}
|
|
252
257
|
```
|
|
253
258
|
|
|
259
|
+
## For AI Agents
|
|
260
|
+
|
|
261
|
+
ngx-mask ships an [`llms.txt`](llms.txt) (index) and [`llms-full.txt`](llms-full.txt) (full API reference with inline code snippets), following the [llmstxt.org](https://llmstxt.org) convention, so tools like Claude Code, Codex and other coding agents can ground themselves in the current API without guessing. The library is also indexed on [Context7](https://context7.com/nepipenkoigor/ngx-mask) for MCP-based doc retrieval.
|
|
262
|
+
|
|
254
263
|
## Contributing
|
|
255
264
|
|
|
256
265
|
We welcome contributions! Please read our [contributing guidelines](CONTRIBUTING.md) to learn about our development process and how you can propose bugfixes and improvements.
|
package/llms-full.txt
ADDED
|
@@ -0,0 +1,459 @@
|
|
|
1
|
+
# ngx-mask
|
|
2
|
+
|
|
3
|
+
> Input masking library for modern Angular. One standalone directive (`NgxMaskDirective`) and pipe (`NgxMaskPipe`) cover Reactive Forms, template-driven forms and Signal Forms through a `ControlValueAccessor`, and run in zoneless and SSR apps. No `NgxMaskModule` in current versions — configuration is registered via `provideEnvironmentNgxMask()` / `provideNgxMask()`. No runtime dependencies beyond Angular, ~15 KB gzipped.
|
|
4
|
+
|
|
5
|
+
npm package: `ngx-mask`. Supports Angular 17+ (see version pins below for older Angular). Source: https://github.com/NepipenkoIgor/ngx-mask
|
|
6
|
+
|
|
7
|
+
## Installation
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install ngx-mask
|
|
11
|
+
# or
|
|
12
|
+
bun add ngx-mask
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
Older Angular versions need a pinned ngx-mask release:
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install ngx-mask@16.4.2 # Angular 16.x
|
|
19
|
+
npm install ngx-mask@15.2.3 # Angular 15.x
|
|
20
|
+
npm install ngx-mask@14.3.3 # Angular 14.x
|
|
21
|
+
npm install ngx-mask@13.2.2 # Angular 13.x / 12.x
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Setup: standalone application
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
// app.config.ts
|
|
28
|
+
import { ApplicationConfig } from '@angular/core';
|
|
29
|
+
import { provideEnvironmentNgxMask } from 'ngx-mask';
|
|
30
|
+
|
|
31
|
+
export const appConfig: ApplicationConfig = {
|
|
32
|
+
providers: [provideEnvironmentNgxMask()],
|
|
33
|
+
};
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
```typescript
|
|
37
|
+
// any component that uses the mask
|
|
38
|
+
import { Component } from '@angular/core';
|
|
39
|
+
import { NgxMaskDirective } from 'ngx-mask';
|
|
40
|
+
|
|
41
|
+
@Component({
|
|
42
|
+
selector: 'app-example',
|
|
43
|
+
standalone: true,
|
|
44
|
+
imports: [NgxMaskDirective],
|
|
45
|
+
template: `<input mask="0000" />`,
|
|
46
|
+
})
|
|
47
|
+
export class ExampleComponent {}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
With custom application-wide config:
|
|
51
|
+
|
|
52
|
+
```typescript
|
|
53
|
+
import { NgxMaskConfig } from 'ngx-mask';
|
|
54
|
+
|
|
55
|
+
const maskConfig: Partial<NgxMaskConfig> = { validation: false };
|
|
56
|
+
|
|
57
|
+
bootstrapApplication(AppComponent, { providers: [provideEnvironmentNgxMask(maskConfig)] }).catch(
|
|
58
|
+
(err) => console.error(err)
|
|
59
|
+
);
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
Per-component/feature override (replaces, does not merge with, the environment config for that subtree):
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
import { Component } from '@angular/core';
|
|
66
|
+
import { NgxMaskDirective, provideNgxMask } from 'ngx-mask';
|
|
67
|
+
|
|
68
|
+
@Component({
|
|
69
|
+
selector: 'my-feature',
|
|
70
|
+
standalone: true,
|
|
71
|
+
imports: [NgxMaskDirective],
|
|
72
|
+
providers: [provideNgxMask({ thousandSeparator: ',' })],
|
|
73
|
+
template: `<input mask="separator.2" />`,
|
|
74
|
+
})
|
|
75
|
+
export class PriceInputComponent {}
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Directive inputs (e.g. `[thousandSeparator]`) always win over `provideNgxMask()`, which always wins over `provideEnvironmentNgxMask()`, which wins over library defaults.
|
|
79
|
+
|
|
80
|
+
## Setup: NgModule-based application
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
import { NgModule } from '@angular/core';
|
|
84
|
+
import { NgxMaskDirective, NgxMaskPipe, provideEnvironmentNgxMask } from 'ngx-mask';
|
|
85
|
+
|
|
86
|
+
@NgModule({
|
|
87
|
+
imports: [NgxMaskDirective, NgxMaskPipe],
|
|
88
|
+
exports: [NgxMaskDirective, NgxMaskPipe],
|
|
89
|
+
providers: [provideEnvironmentNgxMask()],
|
|
90
|
+
})
|
|
91
|
+
export class AppModule {}
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
Migrating from ngx-mask ≤ 14 (`NgxMaskModule` only exists there, for Angular < 15):
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
// Before (ngx-mask <= 14)
|
|
98
|
+
@NgModule({ imports: [NgxMaskModule.forRoot(maskConfig)] })
|
|
99
|
+
export class AppModule {}
|
|
100
|
+
|
|
101
|
+
// After (current ngx-mask)
|
|
102
|
+
@NgModule({
|
|
103
|
+
imports: [NgxMaskDirective],
|
|
104
|
+
providers: [provideEnvironmentNgxMask(maskConfig)],
|
|
105
|
+
})
|
|
106
|
+
export class AppModule {}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## Common pitfalls
|
|
110
|
+
|
|
111
|
+
- `NullInjectorError: No provider for InjectionToken ngx-mask config` — the directive/pipe is used with no provider in scope. Add `provideEnvironmentNgxMask()` to bootstrap providers (or `provideNgxMask()` to the component).
|
|
112
|
+
- `NgxMaskModule` not found — that API is ngx-mask ≤ 14 only. Use the standalone imports + provider functions above.
|
|
113
|
+
- Config seems ignored — a closer `provideNgxMask()` in a parent component *replaces* (does not merge with) the environment config for that subtree; directive inputs override both.
|
|
114
|
+
|
|
115
|
+
## Basic usage: directive and pipe
|
|
116
|
+
|
|
117
|
+
```html
|
|
118
|
+
<input type="text" mask="0000" />
|
|
119
|
+
<input type="text" [mask]="maskPattern" />
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
```html
|
|
123
|
+
<span>{{ phone | mask: '(000) 000-0000' }}</span>
|
|
124
|
+
<span>{{ value | mask: 'separator' : { thousandSeparator: ',', suffix: ' sm' } }}</span>
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
Built-in pattern tokens:
|
|
128
|
+
|
|
129
|
+
| token | meaning |
|
|
130
|
+
| ----- | ------- |
|
|
131
|
+
| `0` | digit (0-9), required |
|
|
132
|
+
| `9` | digit (0-9), optional |
|
|
133
|
+
| `A` | letter or digit |
|
|
134
|
+
| `S` | letter only |
|
|
135
|
+
| `U` | uppercase letter only |
|
|
136
|
+
| `L` | lowercase letter only |
|
|
137
|
+
|
|
138
|
+
| mask example | matches |
|
|
139
|
+
| ---------------- | -------------- |
|
|
140
|
+
| `9999-99-99` | `2017-04-15` |
|
|
141
|
+
| `0*.00` | `2017.22` |
|
|
142
|
+
| `000.000.000-99` | `048.457.987-98` |
|
|
143
|
+
| `AAAA` | `0F6g` |
|
|
144
|
+
| `SSSS` | `asDF` |
|
|
145
|
+
| `UUUU` | `ASDF` |
|
|
146
|
+
| `LLLL` | `asdf` |
|
|
147
|
+
|
|
148
|
+
## Mask Options reference
|
|
149
|
+
|
|
150
|
+
All options below are directive inputs (`<input [optionName]="value" mask="...">`) and are also accepted by `provideEnvironmentNgxMask(options)` / `provideNgxMask(options)` as an `NgxMaskOptions` object.
|
|
151
|
+
|
|
152
|
+
### specialCharacters (string[])
|
|
153
|
+
|
|
154
|
+
Default special characters: `- / ( ) . : (space) + , @ [ ] " '`. Overriding this array replaces the defaults entirely — list every character you need.
|
|
155
|
+
|
|
156
|
+
```html
|
|
157
|
+
<input type="text" [specialCharacters]="['[', ']', '\\']" mask="[00]\[000]" />
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
```text
|
|
161
|
+
Input value: 789-874.98
|
|
162
|
+
Masked value: [78]\[987]
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### patterns (`{ [char: string]: { pattern: RegExp, optional?: boolean } }`)
|
|
166
|
+
|
|
167
|
+
```html
|
|
168
|
+
<input type="text" [patterns]="customPatterns" mask="(000-000)" />
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
```typescript
|
|
172
|
+
public customPatterns = { '0': { pattern: new RegExp('[a-zA-Z]') } };
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
```text
|
|
176
|
+
Input value: 789HelloWorld
|
|
177
|
+
Masked value: (Hel-loW)
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
### Custom pattern definition with a symbol
|
|
181
|
+
|
|
182
|
+
```typescript
|
|
183
|
+
pattern = {
|
|
184
|
+
B: {
|
|
185
|
+
pattern: new RegExp('\\d'),
|
|
186
|
+
symbol: 'X',
|
|
187
|
+
},
|
|
188
|
+
};
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Reserved characters `h`, `d`, `m`, `s` are used by date/time patterns — avoid them in custom patterns. `*` is reserved for `0*`-style "any length of digits" masks.
|
|
192
|
+
|
|
193
|
+
### prefix (string)
|
|
194
|
+
|
|
195
|
+
```html
|
|
196
|
+
<input type="text" prefix="+7" mask="(000) 000 00 00" />
|
|
197
|
+
```
|
|
198
|
+
|
|
199
|
+
### instantPrefix (boolean)
|
|
200
|
+
|
|
201
|
+
Controls whether the prefix shows on an empty model.
|
|
202
|
+
|
|
203
|
+
```html
|
|
204
|
+
<input type="text" prefix="+7" instantPrefix="false" mask="(000) 000 00 00" />
|
|
205
|
+
<input type="text" prefix="+7" instantPrefix="true" mask="(000) 000 00 00" />
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
### suffix (string)
|
|
209
|
+
|
|
210
|
+
```html
|
|
211
|
+
<input type="text" suffix="$" mask="0000" />
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### dropSpecialCharacters (boolean | string[])
|
|
215
|
+
|
|
216
|
+
Default `true` — special characters are stripped from the model value.
|
|
217
|
+
|
|
218
|
+
```html
|
|
219
|
+
<input type="text" [dropSpecialCharacters]="false" mask="000-000.00" />
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
```text
|
|
223
|
+
Input value: 789-874.98
|
|
224
|
+
Model value: 789-874.98
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### showMaskTyped (boolean)
|
|
228
|
+
|
|
229
|
+
Default `false` — show the mask skeleton while typing.
|
|
230
|
+
|
|
231
|
+
```html
|
|
232
|
+
<input mask="(000) 000-0000" prefix="+7" [showMaskTyped]="true" />
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### allowNegativeNumbers (boolean)
|
|
236
|
+
|
|
237
|
+
Default `false`.
|
|
238
|
+
|
|
239
|
+
```html
|
|
240
|
+
<input type="text" [allowNegativeNumbers]="true" mask="separator.2" />
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
```text
|
|
244
|
+
Input value: -10,000.45
|
|
245
|
+
Model value: -10000.45
|
|
246
|
+
```
|
|
247
|
+
|
|
248
|
+
### placeHolderCharacter (string)
|
|
249
|
+
|
|
250
|
+
Default `_`. Only relevant when `showMaskTyped` is `true`.
|
|
251
|
+
|
|
252
|
+
```html
|
|
253
|
+
<input mask="(000) 000-0000" prefix="+7" [showMaskTyped]="true" placeHolderCharacter="*" />
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### clearIfNotMatch (boolean)
|
|
257
|
+
|
|
258
|
+
Default `false` — clears the input if the typed value does not fully match the mask.
|
|
259
|
+
|
|
260
|
+
### typeFromDecimals (boolean)
|
|
261
|
+
|
|
262
|
+
Default `false`. Opt-in "banking"/calculator-style typing for `separator.N` masks (N > 0): digits fill from the decimal end (`5` -> `0.05`, then `7` -> `0.57`, then `3` -> `5.73`; backspace shifts back). Works with `thousandSeparator`, `prefix`/`suffix`, `allowNegativeNumbers`, `separatorLimit`.
|
|
263
|
+
|
|
264
|
+
```html
|
|
265
|
+
<input type="text" mask="separator.2" [typeFromDecimals]="true" thousandSeparator="," />
|
|
266
|
+
<!-- typing 1 2 3 4 5 6 renders: 0.01 -> 0.12 -> 1.23 -> 12.34 -> 123.45 -> 1,234.56 -->
|
|
267
|
+
```
|
|
268
|
+
|
|
269
|
+
```typescript
|
|
270
|
+
provideNgxMask({ typeFromDecimals: true });
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
### defaultValueOnBlur (string)
|
|
274
|
+
|
|
275
|
+
Default `null`. When set, this raw value is written through the mask pipeline on blur whenever the control's unmasked value is empty.
|
|
276
|
+
|
|
277
|
+
```html
|
|
278
|
+
<input type="text" mask="separator.2" defaultValueOnBlur="0" />
|
|
279
|
+
<!-- user clears the input and blurs -> displayed "0", model 0 -->
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
With `showMaskTyped`:
|
|
283
|
+
|
|
284
|
+
```html
|
|
285
|
+
<input type="text" mask="0000" [showMaskTyped]="true" defaultValueOnBlur="9" />
|
|
286
|
+
<!-- user blurs the empty input -> displayed "9___", model "9" -->
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
```typescript
|
|
290
|
+
provideNgxMask({ defaultValueOnBlur: '0' });
|
|
291
|
+
```
|
|
292
|
+
|
|
293
|
+
For conditional/computed defaults, use transform functions instead:
|
|
294
|
+
|
|
295
|
+
```typescript
|
|
296
|
+
public outputTransformFn = (value: string | number | undefined | null) => (value === '' || value == null ? 0 : value);
|
|
297
|
+
public inputTransformFn = (value: unknown) => (value === '' || value == null ? '0' : (value as string | number));
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
### Pipe with a custom pattern: `[string, pattern]`
|
|
301
|
+
|
|
302
|
+
```html
|
|
303
|
+
<span>{{ phone | mask: customMask }}</span>
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
```typescript
|
|
307
|
+
pattern = { P: { pattern: new RegExp('\\d') } };
|
|
308
|
+
customMask: [string, typeof pattern] = ['PPP-PPP', pattern];
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
### Repeat mask with `{n}`
|
|
312
|
+
|
|
313
|
+
```html
|
|
314
|
+
<input type="text" mask="A{4}" />
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
### Thousand separator / decimal masks (`separator`)
|
|
318
|
+
|
|
319
|
+
```html
|
|
320
|
+
<input type="text" mask="separator" />
|
|
321
|
+
<!-- default separator: space -->
|
|
322
|
+
|
|
323
|
+
<input type="text" mask="separator" thousandSeparator="." />
|
|
324
|
+
|
|
325
|
+
<input type="text" mask="separator.2" />
|
|
326
|
+
<!-- .N = decimal precision; 2 is common for currency, 0 disables decimals -->
|
|
327
|
+
```
|
|
328
|
+
|
|
329
|
+
```text
|
|
330
|
+
Input: 1234.56 -> Masked: 1 234.56 (default space separator)
|
|
331
|
+
Input: 1234,56 -> Masked: 1.234,56 (thousandSeparator=".")
|
|
332
|
+
Input: 1234.56 -> Masked: 1,234 (thousandSeparator="," , separator.0)
|
|
333
|
+
```
|
|
334
|
+
|
|
335
|
+
```html
|
|
336
|
+
<input type="text" mask="separator.2" thousandSeparator="." />
|
|
337
|
+
<input type="text" mask="separator.2" thousandSeparator="," />
|
|
338
|
+
<input type="text" mask="separator.0" thousandSeparator="." />
|
|
339
|
+
<input type="text" mask="separator.0" thousandSeparator="," />
|
|
340
|
+
|
|
341
|
+
<input type="text" mask="separator.2" [leadZero]="true" />
|
|
342
|
+
<!-- Input: 12 -> Masked: 12.00 | Input: 12.1 -> Masked: 12.10 -->
|
|
343
|
+
|
|
344
|
+
<input type="text" mask="separator.2" separatorLimit="1000" />
|
|
345
|
+
<!-- caps digits before the decimal point: Input 12345678,56 -> Masked 1.234,56 -->
|
|
346
|
+
```
|
|
347
|
+
|
|
348
|
+
On a `separator` mask with `decimalMarker=","`, the numeric-keypad decimal key inserts `,` while the main-keyboard `.` keeps its normal behavior.
|
|
349
|
+
|
|
350
|
+
### Time validation (24h)
|
|
351
|
+
|
|
352
|
+
```html
|
|
353
|
+
<input type="text" mask="Hh:m0:s0" />
|
|
354
|
+
```
|
|
355
|
+
|
|
356
|
+
### Date validation
|
|
357
|
+
|
|
358
|
+
```html
|
|
359
|
+
<input type="text" mask="d0/M0/0000" />
|
|
360
|
+
```
|
|
361
|
+
|
|
362
|
+
### leadZeroDateTime (boolean)
|
|
363
|
+
|
|
364
|
+
Default `false`. Replaces skipped date/time digits with `0`.
|
|
365
|
+
|
|
366
|
+
```html
|
|
367
|
+
<input type="text" mask="d0/M0/0000" [leadZeroDateTime]="true" />
|
|
368
|
+
<!-- Input: 422020 -> Masked: 04/02/2020 -->
|
|
369
|
+
|
|
370
|
+
<input type="text" mask="Hh:m0:s0" [leadZeroDateTime]="true" />
|
|
371
|
+
<!-- Input: 777 -> Masked: 07:07:07 -->
|
|
372
|
+
```
|
|
373
|
+
|
|
374
|
+
### Percent validation
|
|
375
|
+
|
|
376
|
+
```html
|
|
377
|
+
<input type="text" mask="percent" suffix="%" />
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
`percent` accepts multiple decimal markers via `[decimalMarker]="['.', ',']"` (both `12.5` and `12,5`).
|
|
381
|
+
|
|
382
|
+
### FormControl validation
|
|
383
|
+
|
|
384
|
+
Default `true`.
|
|
385
|
+
|
|
386
|
+
```html
|
|
387
|
+
<input type="text" mask="00 00" [validation]="true" />
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
### Secure / hidden input
|
|
391
|
+
|
|
392
|
+
```html
|
|
393
|
+
<input placeholder="Secure input" [hiddenInput]="true" mask="XXX/X0/0000" />
|
|
394
|
+
```
|
|
395
|
+
|
|
396
|
+
Date tokens `d` (day) and `M` (month) can be hidden too, keeping the year visible:
|
|
397
|
+
|
|
398
|
+
```html
|
|
399
|
+
<input placeholder="Secure date input" [hiddenInput]="true" mask="d0/M0/0000" />
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
### Built-in validated masks: IP, CPF/CNPJ
|
|
403
|
+
|
|
404
|
+
```html
|
|
405
|
+
<input mask="IP" />
|
|
406
|
+
<input mask="CPF_CNPJ" />
|
|
407
|
+
<input mask="CPF_CNPJ_ALPHA" />
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
### Multi-mask expressions with `||`
|
|
411
|
+
|
|
412
|
+
```html
|
|
413
|
+
<input mask="000.000.000-00||00.000.000/0000-00" />
|
|
414
|
+
<input mask="(00) 0000-0000||(00) 0 0000-0000" />
|
|
415
|
+
<input mask="00||SS" />
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
### Custom mask aliases
|
|
419
|
+
|
|
420
|
+
Define named masks once in config, reference by name in `mask`. Aliases resolve before other mask processing and may expand to a `||` multi-mask expression.
|
|
421
|
+
|
|
422
|
+
```typescript
|
|
423
|
+
provideNgxMask({
|
|
424
|
+
maskAliases: {
|
|
425
|
+
PHONE_BR: '(00) 00000-0000',
|
|
426
|
+
MY_DOC: '000-AAA||0000-AAA',
|
|
427
|
+
},
|
|
428
|
+
});
|
|
429
|
+
```
|
|
430
|
+
|
|
431
|
+
```html
|
|
432
|
+
<input mask="PHONE_BR" />
|
|
433
|
+
<input mask="MY_DOC" />
|
|
434
|
+
```
|
|
435
|
+
|
|
436
|
+
Alias keys must be UPPER_SNAKE_CASE and must not shadow built-in tokens (`IP`, `CPF_CNPJ`, `CPF_CNPJ_ALPHA`, ...) — a shadowing alias is ignored with a one-time console warning. The alias map is static per injector (no runtime changes). Security: alias values are mask expressions evaluated by the library — define them statically, never from untrusted user input.
|
|
437
|
+
|
|
438
|
+
### maskFilled output event
|
|
439
|
+
|
|
440
|
+
```html
|
|
441
|
+
<input mask="0000" (maskFilled)="maskFilled()" />
|
|
442
|
+
```
|
|
443
|
+
|
|
444
|
+
## Version compatibility
|
|
445
|
+
|
|
446
|
+
- Angular 17+: latest ngx-mask, full feature set (this doc).
|
|
447
|
+
- Angular 16.x: `ngx-mask@16.4.2`
|
|
448
|
+
- Angular 15.x: `ngx-mask@15.2.3`
|
|
449
|
+
- Angular 14.x: `ngx-mask@14.3.3`
|
|
450
|
+
- Angular 13.x / 12.x: `ngx-mask@13.2.2`
|
|
451
|
+
- Only Angular 17+ builds receive new features and updates.
|
|
452
|
+
|
|
453
|
+
## Links
|
|
454
|
+
|
|
455
|
+
- Live demo & interactive docs: https://nepipenkoigor.github.io/ngx-mask/
|
|
456
|
+
- Full USAGE reference: https://github.com/NepipenkoIgor/ngx-mask/blob/develop/USAGE.md
|
|
457
|
+
- README: https://github.com/NepipenkoIgor/ngx-mask/blob/develop/README.md
|
|
458
|
+
- Changelog: https://github.com/NepipenkoIgor/ngx-mask/blob/develop/CHANGELOG.md
|
|
459
|
+
- Issues: https://github.com/NepipenkoIgor/ngx-mask/issues
|
package/llms.txt
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# ngx-mask
|
|
2
|
+
|
|
3
|
+
> Input masking library for modern Angular. One standalone directive (`NgxMaskDirective`) and pipe (`NgxMaskPipe`) cover Reactive Forms, template-driven forms and Signal Forms through a `ControlValueAccessor`, and run in zoneless and SSR apps. No `NgxMaskModule` in current versions — configuration is registered via `provideEnvironmentNgxMask()` / `provideNgxMask()`. No runtime dependencies beyond Angular, ~15 KB gzipped.
|
|
4
|
+
|
|
5
|
+
Use this file to find the right doc before answering questions about ngx-mask, generating code with it, or upgrading a project to a current version. Package name on npm: `ngx-mask`. Supports Angular 17+ (see README for older-Angular version pins).
|
|
6
|
+
|
|
7
|
+
## Full reference (single file, code-only)
|
|
8
|
+
|
|
9
|
+
- [llms-full.txt](https://github.com/NepipenkoIgor/ngx-mask/blob/develop/llms-full.txt): the entire API in one file with inline runnable code snippets — installation, standalone/NgModule setup, every `NgxMaskOptions` field, all built-in masks (date, time, percent, IP, CPF_CNPJ, separator/thousands, secure input, multi-mask `||`, custom aliases). Prefer this file when grounding code generation for ngx-mask.
|
|
10
|
+
|
|
11
|
+
## Setup
|
|
12
|
+
|
|
13
|
+
- [Installation & Quick Start](https://github.com/NepipenkoIgor/ngx-mask/blob/develop/README.md#installation): npm/bun install commands, version pins for Angular 12–16, standalone and NgModule bootstrap, `provideEnvironmentNgxMask` vs `provideNgxMask`, migrating off `NgxMaskModule.forRoot()` (ngx-mask ≤14 only).
|
|
14
|
+
- [Live demo & interactive docs](https://nepipenkoigor.github.io/ngx-mask/): runnable examples for every mask pattern and option.
|
|
15
|
+
|
|
16
|
+
## Usage & configuration
|
|
17
|
+
|
|
18
|
+
- [USAGE.md](https://github.com/NepipenkoIgor/ngx-mask/blob/develop/USAGE.md): the full reference — directive (`mask="..."`) and pipe (`{{ value | mask: '...' }}`) usage, all `NgxMaskOptions` (specialCharacters, prefix/suffix, dropSpecialCharacters, showMaskTyped, allowNegativeNumbers, placeHolderCharacter, clearIfNotMatch, defaultValueOnBlur, thousandSeparator, leadZeroDateTime, custom mask aliases, `maskFilled`), built-in validated masks (date, time, percent, IP, CPF_CNPJ, CPF_CNPJ_ALPHA), secure/hidden input, multi-mask expressions (`|`), and common pitfalls.
|
|
19
|
+
- Provider precedence: directive input > `provideNgxMask()` (subtree) > `provideEnvironmentNgxMask()` (app-wide) > library defaults.
|
|
20
|
+
|
|
21
|
+
## Reference
|
|
22
|
+
|
|
23
|
+
- [CHANGELOG.md](https://github.com/NepipenkoIgor/ngx-mask/blob/develop/CHANGELOG.md): version history and breaking changes.
|
|
24
|
+
- [CONTRIBUTING.md](https://github.com/NepipenkoIgor/ngx-mask/blob/develop/CONTRIBUTING.md): dev setup, commit convention, PR process.
|
|
25
|
+
- Source: `projects/ngx-mask-lib/src/lib/` — `ngx-mask.directive.ts`, `ngx-mask.pipe.ts`, `ngx-mask.service.ts`, `ngx-mask-applier.service.ts`, `ngx-mask.config.ts` (option types), `mask-handlers/` (cpf-cnpj, ip, percent, separator, generic-pattern).
|
|
26
|
+
|
|
27
|
+
## Notes for code generation
|
|
28
|
+
|
|
29
|
+
- Always import `NgxMaskDirective` / `NgxMaskPipe` directly (standalone) — never `NgxMaskModule`, which only exists in ngx-mask ≤14 for Angular <15.
|
|
30
|
+
- Register config with `provideEnvironmentNgxMask(config?)` (root) or `provideNgxMask(config?)` (per component/route), not a module `forRoot()`.
|
|
31
|
+
- Mask string goes on the `mask` input (`<input mask="0000">`) or as the pipe's first argument; per-usage option overrides are the pipe's second argument.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ngx-mask",
|
|
3
|
-
"version": "22.2.
|
|
3
|
+
"version": "22.2.1",
|
|
4
4
|
"description": "Input masking for modern Angular — Reactive, template-driven and Signal Forms, zoneless and SSR ready. Dates, numbers, separators, custom patterns.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ng2-mask",
|
|
@@ -18,6 +18,8 @@
|
|
|
18
18
|
"files": [
|
|
19
19
|
"LICENSE",
|
|
20
20
|
"README.md",
|
|
21
|
+
"llms.txt",
|
|
22
|
+
"llms-full.txt",
|
|
21
23
|
"fesm2022/ngx-mask.mjs",
|
|
22
24
|
"fesm2022/ngx-mask.mjs.map",
|
|
23
25
|
"types",
|