ngx-mask 22.2.1 → 22.2.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.
- package/fesm2022/ngx-mask.mjs +14 -4
- package/fesm2022/ngx-mask.mjs.map +1 -1
- package/package.json +2 -2
- package/types/ngx-mask.d.ts +2 -1
package/fesm2022/ngx-mask.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { InjectionToken, EventEmitter, inject, Injectable, signal, ElementRef, Renderer2, makeEnvironmentProviders, input, model, booleanAttribute, output, ChangeDetectorRef, Injector, effect, untracked, HostListener, Directive, Pipe } from '@angular/core';
|
|
2
|
+
import { InjectionToken, EventEmitter, inject, Injectable, signal, ElementRef, Renderer2, makeEnvironmentProviders, input, model, booleanAttribute, output, ChangeDetectorRef, Injector, effect, untracked, HostListener, Directive, EnvironmentInjector, Pipe } from '@angular/core';
|
|
3
3
|
import { DOCUMENT } from '@angular/common';
|
|
4
4
|
import { NgControl, NG_VALUE_ACCESSOR, NG_VALIDATORS } from '@angular/forms';
|
|
5
5
|
|
|
@@ -4033,11 +4033,22 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "22.1.7", ngImpor
|
|
|
4033
4033
|
|
|
4034
4034
|
class NgxMaskPipe {
|
|
4035
4035
|
defaultOptions = inject(NGX_MASK_CONFIG);
|
|
4036
|
-
|
|
4036
|
+
_environmentInjector = inject(EnvironmentInjector);
|
|
4037
|
+
_maskService;
|
|
4037
4038
|
_maskExpressionArray = [];
|
|
4038
4039
|
mask = '';
|
|
4039
4040
|
transform(value, mask, { patterns, maskAliases, ...config } = {}) {
|
|
4040
4041
|
let processedValue = value;
|
|
4042
|
+
// NgxMaskService is stateful (built for the directive, which keeps value history across
|
|
4043
|
+
// keystrokes), so each transform gets a fresh instance: nothing from a previous call can
|
|
4044
|
+
// leak into this one (#1669).
|
|
4045
|
+
this._maskService = Injector.create({
|
|
4046
|
+
providers: [
|
|
4047
|
+
NgxMaskService,
|
|
4048
|
+
{ provide: NGX_MASK_CONFIG, useValue: this.defaultOptions },
|
|
4049
|
+
],
|
|
4050
|
+
parent: this._environmentInjector,
|
|
4051
|
+
}).get(NgxMaskService);
|
|
4041
4052
|
// User-defined aliases expand BEFORE any other mask processing (incl. `||` handling).
|
|
4042
4053
|
const resolvedMask = resolveMaskAlias(mask, {
|
|
4043
4054
|
...this.defaultOptions.maskAliases,
|
|
@@ -4048,7 +4059,7 @@ class NgxMaskPipe {
|
|
|
4048
4059
|
...this.defaultOptions,
|
|
4049
4060
|
...config,
|
|
4050
4061
|
patterns: {
|
|
4051
|
-
...this.
|
|
4062
|
+
...this.defaultOptions.patterns,
|
|
4052
4063
|
...patterns,
|
|
4053
4064
|
},
|
|
4054
4065
|
};
|
|
@@ -4096,7 +4107,6 @@ class NgxMaskPipe {
|
|
|
4096
4107
|
if (this._maskService.decimalMarker === MaskExpression.COMMA) {
|
|
4097
4108
|
processedValue = processedValue.replace(MaskExpression.DOT, MaskExpression.COMMA);
|
|
4098
4109
|
}
|
|
4099
|
-
this._maskService.isNumberValue = true;
|
|
4100
4110
|
}
|
|
4101
4111
|
if (processedValue === null || typeof processedValue === 'undefined') {
|
|
4102
4112
|
return this._maskService.applyMask('', resolvedMask);
|