matcha-components 20.45.0 → 20.47.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.
@@ -1,10 +1,10 @@
1
1
  import * as i0 from '@angular/core';
2
- import { EventEmitter, Output, HostBinding, Input, Component, ContentChildren, ElementRef, Renderer2, Inject, PLATFORM_ID, Injectable, ViewChild, ContentChild, HostListener, Directive, forwardRef, ChangeDetectionStrategy, InjectionToken, inject, DOCUMENT, TemplateRef, Optional, ViewEncapsulation, NgModule, createComponent, input, output, signal, Pipe } from '@angular/core';
2
+ import { EventEmitter, Output, HostBinding, Input, Component, ContentChildren, ElementRef, Renderer2, Inject, PLATFORM_ID, Injectable, ViewChild, ContentChild, HostListener, Directive, forwardRef, ChangeDetectionStrategy, InjectionToken, inject, TemplateRef, Optional, ViewEncapsulation, NgModule, createComponent, Pipe } from '@angular/core';
3
3
  import { animation, style, animate, trigger, transition, useAnimation, state, query, stagger, animateChild, sequence, group } from '@angular/animations';
4
4
  import { Subscription, Subject, BehaviorSubject, of, fromEvent } from 'rxjs';
5
5
  import { debounceTime, startWith, map, distinctUntilChanged, takeUntil, filter } from 'rxjs/operators';
6
6
  import * as i1 from '@angular/common';
7
- import { isPlatformBrowser, CommonModule } from '@angular/common';
7
+ import { isPlatformBrowser, DOCUMENT, CommonModule } from '@angular/common';
8
8
  import * as i2 from '@angular/forms';
9
9
  import { FormControlName, NG_VALUE_ACCESSOR, NgControl, NG_VALIDATORS, FormsModule, ReactiveFormsModule } from '@angular/forms';
10
10
  import * as i1$1 from '@angular/common/http';
@@ -11619,15 +11619,15 @@ const compatibleOptions = {
11619
11619
  outputTransformFn: (v) => v,
11620
11620
  maskFilled: new EventEmitter()
11621
11621
  };
11622
- class MatchaMaskCompatibleModule {
11623
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaMaskCompatibleModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
11624
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.0", ngImport: i0, type: MatchaMaskCompatibleModule, declarations: [MatchaMaskCompatibleDirective], imports: [CommonModule], exports: [MatchaMaskCompatibleDirective] }); }
11625
- static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaMaskCompatibleModule, providers: [
11622
+ class MatchaMaskModule {
11623
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaMaskModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
11624
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.0", ngImport: i0, type: MatchaMaskModule, declarations: [MatchaMaskCompatibleDirective], imports: [CommonModule], exports: [MatchaMaskCompatibleDirective] }); }
11625
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaMaskModule, providers: [
11626
11626
  MatchaMaskService,
11627
11627
  { provide: MATCHA_MASK_CONFIG, useValue: compatibleOptions }
11628
11628
  ], imports: [CommonModule] }); }
11629
11629
  }
11630
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaMaskCompatibleModule, decorators: [{
11630
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaMaskModule, decorators: [{
11631
11631
  type: NgModule,
11632
11632
  args: [{
11633
11633
  declarations: [MatchaMaskCompatibleDirective],
@@ -11649,11 +11649,11 @@ class MatchaInputPhoneModule {
11649
11649
  static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.0", ngImport: i0, type: MatchaInputPhoneModule, declarations: [MatchaInputPhoneComponent], imports: [CommonModule,
11650
11650
  MatchaFormFieldModule,
11651
11651
  FormsModule,
11652
- MatchaMaskCompatibleModule], exports: [MatchaInputPhoneComponent] }); }
11652
+ MatchaMaskModule], exports: [MatchaInputPhoneComponent] }); }
11653
11653
  static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaInputPhoneModule, imports: [CommonModule,
11654
11654
  MatchaFormFieldModule,
11655
11655
  FormsModule,
11656
- MatchaMaskCompatibleModule] }); }
11656
+ MatchaMaskModule] }); }
11657
11657
  }
11658
11658
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaInputPhoneModule, decorators: [{
11659
11659
  type: NgModule,
@@ -11663,7 +11663,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImpor
11663
11663
  CommonModule,
11664
11664
  MatchaFormFieldModule,
11665
11665
  FormsModule,
11666
- MatchaMaskCompatibleModule
11666
+ MatchaMaskModule
11667
11667
  ],
11668
11668
  exports: [MatchaInputPhoneComponent]
11669
11669
  }]
@@ -11855,7 +11855,7 @@ class MatchaComponentsModule {
11855
11855
  MatchaPageLayoutModule,
11856
11856
  MatchaDrawerModule,
11857
11857
  MatchaHighlightModule,
11858
- MatchaMaskCompatibleModule], exports: [MatchaAccordionModule,
11858
+ MatchaMaskModule], exports: [MatchaAccordionModule,
11859
11859
  MatchaAutocompleteModule,
11860
11860
  MatchaOptionModule,
11861
11861
  MatchaPanelModule,
@@ -11900,7 +11900,7 @@ class MatchaComponentsModule {
11900
11900
  MatchaAvatarModule,
11901
11901
  MatchaDrawerModule,
11902
11902
  MatchaHighlightModule,
11903
- MatchaMaskCompatibleModule] }); }
11903
+ MatchaMaskModule] }); }
11904
11904
  static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaComponentsModule, imports: [CommonModule,
11905
11905
  FormsModule,
11906
11906
  ReactiveFormsModule,
@@ -11948,7 +11948,7 @@ class MatchaComponentsModule {
11948
11948
  MatchaPageLayoutModule,
11949
11949
  MatchaDrawerModule,
11950
11950
  MatchaHighlightModule,
11951
- MatchaMaskCompatibleModule, MatchaAccordionModule,
11951
+ MatchaMaskModule, MatchaAccordionModule,
11952
11952
  MatchaAutocompleteModule,
11953
11953
  MatchaOptionModule,
11954
11954
  MatchaPanelModule,
@@ -11993,7 +11993,7 @@ class MatchaComponentsModule {
11993
11993
  MatchaAvatarModule,
11994
11994
  MatchaDrawerModule,
11995
11995
  MatchaHighlightModule,
11996
- MatchaMaskCompatibleModule] }); }
11996
+ MatchaMaskModule] }); }
11997
11997
  }
11998
11998
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaComponentsModule, decorators: [{
11999
11999
  type: NgModule,
@@ -12047,7 +12047,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImpor
12047
12047
  MatchaPageLayoutModule,
12048
12048
  MatchaDrawerModule,
12049
12049
  MatchaHighlightModule,
12050
- MatchaMaskCompatibleModule
12050
+ MatchaMaskModule
12051
12051
  ],
12052
12052
  exports: [MatchaAccordionModule,
12053
12053
  MatchaAutocompleteModule,
@@ -12094,7 +12094,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImpor
12094
12094
  MatchaAvatarModule,
12095
12095
  MatchaDrawerModule,
12096
12096
  MatchaHighlightModule,
12097
- MatchaMaskCompatibleModule
12097
+ MatchaMaskModule
12098
12098
  ],
12099
12099
  }]
12100
12100
  }] });
@@ -12145,945 +12145,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImpor
12145
12145
  }]
12146
12146
  }] });
12147
12147
 
12148
- class MatchaMaskDirective {
12149
- constructor() {
12150
- this.mask = input('', ...(ngDevMode ? [{ debugName: "mask" }] : []));
12151
- this.specialCharacters = input([], ...(ngDevMode ? [{ debugName: "specialCharacters" }] : []));
12152
- this.patterns = input({}, ...(ngDevMode ? [{ debugName: "patterns" }] : []));
12153
- this.prefix = input('', ...(ngDevMode ? [{ debugName: "prefix" }] : []));
12154
- this.suffix = input('', ...(ngDevMode ? [{ debugName: "suffix" }] : []));
12155
- this.thousandSeparator = input(' ', ...(ngDevMode ? [{ debugName: "thousandSeparator" }] : []));
12156
- this.decimalMarker = input('.', ...(ngDevMode ? [{ debugName: "decimalMarker" }] : []));
12157
- this.dropSpecialCharacters = input(null, ...(ngDevMode ? [{ debugName: "dropSpecialCharacters" }] : []));
12158
- this.hiddenInput = input(null, ...(ngDevMode ? [{ debugName: "hiddenInput" }] : []));
12159
- this.showMaskTyped = input(null, ...(ngDevMode ? [{ debugName: "showMaskTyped" }] : []));
12160
- this.placeHolderCharacter = input(null, ...(ngDevMode ? [{ debugName: "placeHolderCharacter" }] : []));
12161
- this.shownMaskExpression = input(null, ...(ngDevMode ? [{ debugName: "shownMaskExpression" }] : []));
12162
- this.clearIfNotMatch = input(null, ...(ngDevMode ? [{ debugName: "clearIfNotMatch" }] : []));
12163
- this.validation = input(null, ...(ngDevMode ? [{ debugName: "validation" }] : []));
12164
- this.separatorLimit = input('', ...(ngDevMode ? [{ debugName: "separatorLimit" }] : []));
12165
- this.allowNegativeNumbers = input(null, ...(ngDevMode ? [{ debugName: "allowNegativeNumbers" }] : []));
12166
- this.leadZeroDateTime = input(null, ...(ngDevMode ? [{ debugName: "leadZeroDateTime" }] : []));
12167
- this.leadZero = input(null, ...(ngDevMode ? [{ debugName: "leadZero" }] : []));
12168
- this.triggerOnMaskChange = input(null, ...(ngDevMode ? [{ debugName: "triggerOnMaskChange" }] : []));
12169
- this.apm = input(null, ...(ngDevMode ? [{ debugName: "apm" }] : []));
12170
- this.inputTransformFn = input(null, ...(ngDevMode ? [{ debugName: "inputTransformFn" }] : []));
12171
- this.outputTransformFn = input(null, ...(ngDevMode ? [{ debugName: "outputTransformFn" }] : []));
12172
- this.keepCharacterPositions = input(null, ...(ngDevMode ? [{ debugName: "keepCharacterPositions" }] : []));
12173
- this.instantPrefix = input(null, ...(ngDevMode ? [{ debugName: "instantPrefix" }] : []));
12174
- this.maskFilled = output();
12175
- this._maskValue = signal('', ...(ngDevMode ? [{ debugName: "_maskValue" }] : []));
12176
- this._inputValue = signal('', ...(ngDevMode ? [{ debugName: "_inputValue" }] : []));
12177
- this._position = signal(null, ...(ngDevMode ? [{ debugName: "_position" }] : []));
12178
- this._code = signal('', ...(ngDevMode ? [{ debugName: "_code" }] : []));
12179
- this._maskExpressionArray = signal([], ...(ngDevMode ? [{ debugName: "_maskExpressionArray" }] : []));
12180
- this._justPasted = signal(false, ...(ngDevMode ? [{ debugName: "_justPasted" }] : []));
12181
- this._isFocused = signal(false, ...(ngDevMode ? [{ debugName: "_isFocused" }] : []));
12182
- /**For IME composition event */
12183
- this._isComposing = signal(false, ...(ngDevMode ? [{ debugName: "_isComposing" }] : []));
12184
- this._maskService = inject(MatchaMaskService, { self: true });
12185
- this.document = inject(DOCUMENT);
12186
- this._config = inject(MATCHA_MASK_CONFIG);
12187
- // eslint-disable-next-line @typescript-eslint/no-empty-function
12188
- this.onChange = (_) => { };
12189
- // eslint-disable-next-line @typescript-eslint/no-empty-function
12190
- this.onTouch = () => { };
12191
- }
12192
- ngOnChanges(changes) {
12193
- const { mask, specialCharacters, patterns, prefix, suffix, thousandSeparator, decimalMarker, dropSpecialCharacters, hiddenInput, showMaskTyped, placeHolderCharacter, shownMaskExpression, clearIfNotMatch, validation, separatorLimit, allowNegativeNumbers, leadZeroDateTime, leadZero, triggerOnMaskChange, apm, inputTransformFn, outputTransformFn, keepCharacterPositions, instantPrefix, } = changes;
12194
- if (mask) {
12195
- if (mask.currentValue !== mask.previousValue && !mask.firstChange) {
12196
- this._maskService.maskChanged = true;
12197
- }
12198
- if (mask.currentValue && mask.currentValue.split("||" /* MaskExpression.OR */).length > 1) {
12199
- this._maskExpressionArray.set(mask.currentValue.split("||" /* MaskExpression.OR */).sort((a, b) => {
12200
- return a.length - b.length;
12201
- }));
12202
- this._setMask();
12203
- }
12204
- else {
12205
- this._maskExpressionArray.set([]);
12206
- this._maskValue.set(mask.currentValue || "" /* MaskExpression.EMPTY_STRING */);
12207
- this._maskService.maskExpression = this._maskValue();
12208
- }
12209
- }
12210
- if (specialCharacters) {
12211
- if (!specialCharacters.currentValue || !Array.isArray(specialCharacters.currentValue)) {
12212
- return;
12213
- }
12214
- else {
12215
- this._maskService.specialCharacters = specialCharacters.currentValue || [];
12216
- }
12217
- }
12218
- if (allowNegativeNumbers) {
12219
- this._maskService.allowNegativeNumbers = allowNegativeNumbers.currentValue;
12220
- if (this._maskService.allowNegativeNumbers) {
12221
- this._maskService.specialCharacters = this._maskService.specialCharacters.filter((c) => c !== "-" /* MaskExpression.MINUS */);
12222
- }
12223
- }
12224
- // Only overwrite the mask available patterns if a pattern has actually been passed in
12225
- if (patterns && patterns.currentValue) {
12226
- this._maskService.patterns = patterns.currentValue;
12227
- }
12228
- if (apm && apm.currentValue) {
12229
- this._maskService.apm = apm.currentValue;
12230
- }
12231
- if (instantPrefix) {
12232
- this._maskService.instantPrefix = instantPrefix.currentValue;
12233
- }
12234
- if (prefix) {
12235
- this._maskService.prefix = prefix.currentValue;
12236
- }
12237
- if (suffix) {
12238
- this._maskService.suffix = suffix.currentValue;
12239
- }
12240
- if (thousandSeparator) {
12241
- this._maskService.thousandSeparator = thousandSeparator.currentValue;
12242
- if (thousandSeparator.previousValue && thousandSeparator.currentValue) {
12243
- const previousDecimalMarker = this._maskService.decimalMarker;
12244
- if (thousandSeparator.currentValue === this._maskService.decimalMarker) {
12245
- this._maskService.decimalMarker =
12246
- thousandSeparator.currentValue === "," /* MaskExpression.COMMA */
12247
- ? "." /* MaskExpression.DOT */
12248
- : "," /* MaskExpression.COMMA */;
12249
- }
12250
- if (this._maskService.dropSpecialCharacters === true) {
12251
- this._maskService.specialCharacters = this._config.specialCharacters;
12252
- }
12253
- if (typeof previousDecimalMarker === 'string' &&
12254
- typeof this._maskService.decimalMarker === 'string') {
12255
- this._inputValue.set(this._inputValue()
12256
- .split(thousandSeparator.previousValue)
12257
- .join('')
12258
- .replace(previousDecimalMarker, this._maskService.decimalMarker));
12259
- this._maskService.actualValue = this._inputValue();
12260
- }
12261
- this._maskService.writingValue = true;
12262
- }
12263
- }
12264
- if (decimalMarker) {
12265
- this._maskService.decimalMarker = decimalMarker.currentValue;
12266
- }
12267
- if (dropSpecialCharacters) {
12268
- this._maskService.dropSpecialCharacters = dropSpecialCharacters.currentValue;
12269
- }
12270
- if (hiddenInput) {
12271
- this._maskService.hiddenInput = hiddenInput.currentValue;
12272
- if (hiddenInput.previousValue === true && hiddenInput.currentValue === false) {
12273
- this._inputValue.set(this._maskService.actualValue);
12274
- }
12275
- }
12276
- if (showMaskTyped) {
12277
- this._maskService.showMaskTyped = showMaskTyped.currentValue;
12278
- if (showMaskTyped.previousValue === false &&
12279
- showMaskTyped.currentValue === true &&
12280
- this._isFocused()) {
12281
- requestAnimationFrame(() => {
12282
- this._maskService._elementRef?.nativeElement.click();
12283
- });
12284
- }
12285
- }
12286
- if (placeHolderCharacter) {
12287
- this._maskService.placeHolderCharacter = placeHolderCharacter.currentValue;
12288
- }
12289
- if (shownMaskExpression) {
12290
- this._maskService.shownMaskExpression = shownMaskExpression.currentValue;
12291
- }
12292
- if (clearIfNotMatch) {
12293
- this._maskService.clearIfNotMatch = clearIfNotMatch.currentValue;
12294
- }
12295
- if (validation) {
12296
- this._maskService.validation = validation.currentValue;
12297
- }
12298
- if (separatorLimit) {
12299
- this._maskService.separatorLimit = separatorLimit.currentValue;
12300
- }
12301
- if (leadZeroDateTime) {
12302
- this._maskService.leadZeroDateTime = leadZeroDateTime.currentValue;
12303
- }
12304
- if (leadZero) {
12305
- this._maskService.leadZero = leadZero.currentValue;
12306
- }
12307
- if (triggerOnMaskChange) {
12308
- this._maskService.triggerOnMaskChange = triggerOnMaskChange.currentValue;
12309
- }
12310
- if (inputTransformFn) {
12311
- this._maskService.inputTransformFn = inputTransformFn.currentValue;
12312
- }
12313
- if (outputTransformFn) {
12314
- this._maskService.outputTransformFn = outputTransformFn.currentValue;
12315
- }
12316
- if (keepCharacterPositions) {
12317
- this._maskService.keepCharacterPositions = keepCharacterPositions.currentValue;
12318
- }
12319
- this._applyMask();
12320
- }
12321
- validate({ value }) {
12322
- const processedValue = typeof value === 'number' ? String(value) : value;
12323
- const maskValue = this._maskValue();
12324
- if (!this._maskService.validation || !maskValue) {
12325
- return null;
12326
- }
12327
- if (this._maskService.ipError) {
12328
- return this._createValidationError(processedValue);
12329
- }
12330
- if (this._maskService.cpfCnpjError) {
12331
- return this._createValidationError(processedValue);
12332
- }
12333
- if (maskValue.startsWith("separator" /* MaskExpression.SEPARATOR */)) {
12334
- return null;
12335
- }
12336
- if (withoutValidation.includes(maskValue)) {
12337
- return null;
12338
- }
12339
- if (this._maskService.clearIfNotMatch) {
12340
- return null;
12341
- }
12342
- if (timeMasks.includes(maskValue)) {
12343
- return this._validateTime(processedValue);
12344
- }
12345
- if (maskValue === "A*@A*.A*" /* MaskExpression.EMAIL_MASK */) {
12346
- const emailPattern = /^[^@]+@[^@]+\.[^@]+$/;
12347
- if (!emailPattern.test(processedValue) && processedValue) {
12348
- return this._createValidationError(processedValue);
12349
- }
12350
- else {
12351
- return null;
12352
- }
12353
- }
12354
- if (processedValue && processedValue.length >= 1) {
12355
- let counterOfOpt = 0;
12356
- if (maskValue.includes("{" /* MaskExpression.CURLY_BRACKETS_LEFT */) &&
12357
- maskValue.includes("}" /* MaskExpression.CURLY_BRACKETS_RIGHT */)) {
12358
- const lengthInsideCurlyBrackets = maskValue.slice(maskValue.indexOf("{" /* MaskExpression.CURLY_BRACKETS_LEFT */) + 1, maskValue.indexOf("}" /* MaskExpression.CURLY_BRACKETS_RIGHT */));
12359
- return lengthInsideCurlyBrackets === String(processedValue.length)
12360
- ? null
12361
- : this._createValidationError(processedValue);
12362
- }
12363
- if (maskValue.startsWith("percent" /* MaskExpression.PERCENT */)) {
12364
- return null;
12365
- }
12366
- for (const key in this._maskService.patterns) {
12367
- if (this._maskService.patterns[key]?.optional) {
12368
- if (maskValue.indexOf(key) !== maskValue.lastIndexOf(key)) {
12369
- const opt = maskValue
12370
- .split("" /* MaskExpression.EMPTY_STRING */)
12371
- .filter((i) => i === key)
12372
- .join("" /* MaskExpression.EMPTY_STRING */);
12373
- counterOfOpt += opt.length;
12374
- }
12375
- else if (maskValue.indexOf(key) !== -1) {
12376
- counterOfOpt++;
12377
- }
12378
- if (maskValue.indexOf(key) !== -1 &&
12379
- processedValue.length >= maskValue.indexOf(key)) {
12380
- return null;
12381
- }
12382
- if (counterOfOpt === maskValue.length) {
12383
- return null;
12384
- }
12385
- }
12386
- }
12387
- if ((maskValue.indexOf("*" /* MaskExpression.SYMBOL_STAR */) > 1 &&
12388
- processedValue.length < maskValue.indexOf("*" /* MaskExpression.SYMBOL_STAR */)) ||
12389
- (maskValue.indexOf("?" /* MaskExpression.SYMBOL_QUESTION */) > 1 &&
12390
- processedValue.length < maskValue.indexOf("?" /* MaskExpression.SYMBOL_QUESTION */))) {
12391
- return this._createValidationError(processedValue);
12392
- }
12393
- if (maskValue.indexOf("*" /* MaskExpression.SYMBOL_STAR */) === -1 ||
12394
- maskValue.indexOf("?" /* MaskExpression.SYMBOL_QUESTION */) === -1) {
12395
- const array = maskValue.split('*');
12396
- const length = this._maskService.dropSpecialCharacters
12397
- ? maskValue.length -
12398
- this._maskService.checkDropSpecialCharAmount(maskValue) -
12399
- counterOfOpt
12400
- : this.prefix()
12401
- ? maskValue.length + this.prefix().length - counterOfOpt
12402
- : maskValue.length - counterOfOpt;
12403
- if (array.length === 1) {
12404
- if (processedValue.length < length) {
12405
- return this._createValidationError(processedValue);
12406
- }
12407
- }
12408
- if (array.length > 1) {
12409
- const lastIndexArray = array[array.length - 1];
12410
- if (lastIndexArray &&
12411
- this._maskService.specialCharacters.includes(lastIndexArray[0]) &&
12412
- String(processedValue).includes(lastIndexArray[0] ?? '') &&
12413
- !this.dropSpecialCharacters()) {
12414
- const special = value.split(lastIndexArray[0]);
12415
- return special[special.length - 1].length === lastIndexArray.length - 1
12416
- ? null
12417
- : this._createValidationError(processedValue);
12418
- }
12419
- else if (((lastIndexArray &&
12420
- !this._maskService.specialCharacters.includes(lastIndexArray[0])) ||
12421
- !lastIndexArray ||
12422
- this._maskService.dropSpecialCharacters) &&
12423
- processedValue.length >= length - 1) {
12424
- return null;
12425
- }
12426
- else {
12427
- return this._createValidationError(processedValue);
12428
- }
12429
- }
12430
- }
12431
- if (maskValue.indexOf("*" /* MaskExpression.SYMBOL_STAR */) === 1 ||
12432
- maskValue.indexOf("?" /* MaskExpression.SYMBOL_QUESTION */) === 1) {
12433
- return null;
12434
- }
12435
- }
12436
- if (value) {
12437
- this.maskFilled.emit();
12438
- return null;
12439
- }
12440
- return null;
12441
- }
12442
- onPaste() {
12443
- this._justPasted.set(true);
12444
- }
12445
- onFocus() {
12446
- this._isFocused.set(true);
12447
- }
12448
- onModelChange(value) {
12449
- // on form reset we need to update the actualValue
12450
- if ((value === "" /* MaskExpression.EMPTY_STRING */ ||
12451
- value === null ||
12452
- typeof value === 'undefined') &&
12453
- this._maskService.actualValue) {
12454
- this._maskService.actualValue = this._maskService.getActualValue("" /* MaskExpression.EMPTY_STRING */);
12455
- }
12456
- }
12457
- onInput(e) {
12458
- // If IME is composing text, we wait for the composed text.
12459
- if (this._isComposing()) {
12460
- return;
12461
- }
12462
- const el = e.target;
12463
- const transformedValue = this._maskService.inputTransformFn
12464
- ? this._maskService.inputTransformFn(el.value)
12465
- : el.value;
12466
- if (el.type !== 'number') {
12467
- if (typeof transformedValue === 'string' || typeof transformedValue === 'number') {
12468
- el.value = transformedValue.toString();
12469
- this._inputValue.set(el.value);
12470
- this._setMask();
12471
- if (!this._maskValue()) {
12472
- this.onChange(el.value);
12473
- return;
12474
- }
12475
- let position = el.selectionStart === 1
12476
- ? el.selectionStart + this._maskService.prefix.length
12477
- : el.selectionStart;
12478
- if (this.showMaskTyped() &&
12479
- this.keepCharacterPositions() &&
12480
- this._maskService.placeHolderCharacter.length === 1) {
12481
- const suffix = this.suffix();
12482
- const prefix = this.prefix();
12483
- const inputSymbol = el.value.slice(position - 1, position);
12484
- const prefixLength = prefix.length;
12485
- const checkSymbols = this._maskService._checkSymbolMask(inputSymbol, this._maskService.maskExpression[position - 1 - prefixLength] ??
12486
- "" /* MaskExpression.EMPTY_STRING */);
12487
- const checkSpecialCharacter = this._maskService._checkSymbolMask(inputSymbol, this._maskService.maskExpression[position + 1 - prefixLength] ??
12488
- "" /* MaskExpression.EMPTY_STRING */);
12489
- const selectRangeBackspace = this._maskService.selStart === this._maskService.selEnd;
12490
- const selStart = Number(this._maskService.selStart) - prefixLength;
12491
- const selEnd = Number(this._maskService.selEnd) - prefixLength;
12492
- const backspaceOrDelete = this._code() === "Backspace" /* MaskExpression.BACKSPACE */ ||
12493
- this._code() === "Delete" /* MaskExpression.DELETE */;
12494
- if (backspaceOrDelete) {
12495
- if (!selectRangeBackspace) {
12496
- if (this._maskService.selStart === prefixLength) {
12497
- this._maskService.actualValue = `${prefix}${this._maskService.maskIsShown.slice(0, selEnd)}${this._inputValue().split(prefix).join('')}`;
12498
- }
12499
- else if (this._maskService.selStart ===
12500
- this._maskService.maskIsShown.length + prefixLength) {
12501
- this._maskService.actualValue = `${this._inputValue()}${this._maskService.maskIsShown.slice(selStart, selEnd)}`;
12502
- }
12503
- else {
12504
- this._maskService.actualValue = `${prefix}${this._inputValue()
12505
- .split(prefix)
12506
- .join('')
12507
- .slice(0, selStart)}${this._maskService.maskIsShown.slice(selStart, selEnd)}${this._maskService.actualValue.slice(selEnd + prefixLength, this._maskService.maskIsShown.length + prefixLength)}${suffix}`;
12508
- }
12509
- }
12510
- else if (!this._maskService.specialCharacters.includes(this._maskService.maskExpression.slice(position - prefixLength, position + 1 - prefixLength)) &&
12511
- selectRangeBackspace) {
12512
- if (selStart === 1 && prefix) {
12513
- this._maskService.actualValue = `${prefix}${this._maskService.placeHolderCharacter}${el.value
12514
- .split(prefix)
12515
- .join('')
12516
- .split(suffix)
12517
- .join('')}${suffix}`;
12518
- position = position - 1;
12519
- }
12520
- else {
12521
- const part1 = el.value.substring(0, position);
12522
- const part2 = el.value.substring(position);
12523
- this._maskService.actualValue = `${part1}${this._maskService.placeHolderCharacter}${part2}`;
12524
- }
12525
- }
12526
- position = this._code() === "Delete" /* MaskExpression.DELETE */ ? position + 1 : position;
12527
- }
12528
- if (!backspaceOrDelete) {
12529
- if (!checkSymbols && !checkSpecialCharacter && selectRangeBackspace) {
12530
- position = Number(el.selectionStart) - 1;
12531
- }
12532
- else if (this._maskService.specialCharacters.includes(el.value.slice(position, position + 1)) &&
12533
- checkSpecialCharacter &&
12534
- !this._maskService.specialCharacters.includes(el.value.slice(position + 1, position + 2))) {
12535
- this._maskService.actualValue = `${el.value.slice(0, position - 1)}${el.value.slice(position, position + 1)}${inputSymbol}${el.value.slice(position + 2)}`;
12536
- position = position + 1;
12537
- }
12538
- else if (checkSymbols) {
12539
- if (el.value.length === 1 && position === 1) {
12540
- this._maskService.actualValue = `${prefix}${inputSymbol}${this._maskService.maskIsShown.slice(1, this._maskService.maskIsShown.length)}${suffix}`;
12541
- }
12542
- else {
12543
- this._maskService.actualValue = `${el.value.slice(0, position - 1)}${inputSymbol}${el.value
12544
- .slice(position + 1)
12545
- .split(suffix)
12546
- .join('')}${suffix}`;
12547
- }
12548
- }
12549
- else if (prefix &&
12550
- el.value.length === 1 &&
12551
- position - prefixLength === 1 &&
12552
- this._maskService._checkSymbolMask(el.value, this._maskService.maskExpression[position - 1 - prefixLength] ??
12553
- "" /* MaskExpression.EMPTY_STRING */)) {
12554
- this._maskService.actualValue = `${prefix}${el.value}${this._maskService.maskIsShown.slice(1, this._maskService.maskIsShown.length)}${suffix}`;
12555
- }
12556
- }
12557
- }
12558
- let caretShift = 0;
12559
- let backspaceShift = false;
12560
- if (this._code() === "Delete" /* MaskExpression.DELETE */ && "separator" /* MaskExpression.SEPARATOR */) {
12561
- this._maskService.deletedSpecialCharacter = true;
12562
- }
12563
- if (this._inputValue().length >= this._maskService.maskExpression.length - 1 &&
12564
- this._code() !== "Backspace" /* MaskExpression.BACKSPACE */ &&
12565
- this._maskService.maskExpression === "d0/M0/0000" /* MaskExpression.DAYS_MONTHS_YEARS */ &&
12566
- position < 10) {
12567
- const inputSymbol = this._inputValue().slice(position - 1, position);
12568
- el.value =
12569
- this._inputValue().slice(0, position - 1) +
12570
- inputSymbol +
12571
- this._inputValue().slice(position + 1);
12572
- }
12573
- if (this._maskService.maskExpression === "d0/M0/0000" /* MaskExpression.DAYS_MONTHS_YEARS */ &&
12574
- this.leadZeroDateTime()) {
12575
- if ((position < 3 && Number(el.value) > 31 && Number(el.value) < 40) ||
12576
- (position === 5 && Number(el.value.slice(3, 5)) > 12)) {
12577
- position = position + 2;
12578
- }
12579
- }
12580
- if (this._maskService.maskExpression === "Hh:m0:s0" /* MaskExpression.HOURS_MINUTES_SECONDS */ &&
12581
- this.apm()) {
12582
- if (this._justPasted() && el.value.slice(0, 2) === "00" /* MaskExpression.DOUBLE_ZERO */) {
12583
- el.value = el.value.slice(1, 2) + el.value.slice(2, el.value.length);
12584
- }
12585
- el.value =
12586
- el.value === "00" /* MaskExpression.DOUBLE_ZERO */
12587
- ? "0" /* MaskExpression.NUMBER_ZERO */
12588
- : el.value;
12589
- }
12590
- this._maskService.applyValueChanges(position, this._justPasted(), this._code() === "Backspace" /* MaskExpression.BACKSPACE */ ||
12591
- this._code() === "Delete" /* MaskExpression.DELETE */, (shift, _backspaceShift) => {
12592
- this._justPasted.set(false);
12593
- caretShift = shift;
12594
- backspaceShift = _backspaceShift;
12595
- });
12596
- // only set the selection if the element is active
12597
- if (this._getActiveElement() !== el) {
12598
- return;
12599
- }
12600
- if (this._maskService.plusOnePosition) {
12601
- position = position + 1;
12602
- this._maskService.plusOnePosition = false;
12603
- }
12604
- // update position after applyValueChanges to prevent cursor on wrong position when it has an array of maskExpression
12605
- if (this._maskExpressionArray().length) {
12606
- if (this._code() === "Backspace" /* MaskExpression.BACKSPACE */) {
12607
- const specialChartMinusOne = this.specialCharacters().includes(this._maskService.actualValue.slice(position - 1, position));
12608
- const allowFewMaskChangeMask = this._maskService.removeMask(this._inputValue())?.length ===
12609
- this._maskService.removeMask(this._maskService.maskExpression)?.length;
12610
- const specialChartPlusOne = this.specialCharacters().includes(this._maskService.actualValue.slice(position, position + 1));
12611
- if (allowFewMaskChangeMask && !specialChartPlusOne) {
12612
- position = el.selectionStart + 1;
12613
- }
12614
- else {
12615
- position = specialChartMinusOne ? position - 1 : position;
12616
- }
12617
- }
12618
- else {
12619
- position =
12620
- el.selectionStart === 1
12621
- ? el.selectionStart + this._maskService.prefix.length
12622
- : el.selectionStart;
12623
- }
12624
- }
12625
- this._position.set(this._position() === 1 && this._inputValue().length === 1
12626
- ? null
12627
- : this._position());
12628
- let positionToApply = this._position()
12629
- ? this._inputValue().length + position + caretShift
12630
- : position +
12631
- (this._code() === "Backspace" /* MaskExpression.BACKSPACE */ && !backspaceShift
12632
- ? 0
12633
- : caretShift);
12634
- if (positionToApply > this._getActualInputLength()) {
12635
- positionToApply =
12636
- el.value === this._maskService.decimalMarker && el.value.length === 1
12637
- ? this._getActualInputLength() + 1
12638
- : this._getActualInputLength();
12639
- }
12640
- if (positionToApply < 0) {
12641
- positionToApply = 0;
12642
- }
12643
- el.setSelectionRange(positionToApply, positionToApply);
12644
- this._position.set(null);
12645
- }
12646
- else {
12647
- // eslint-disable-next-line no-console
12648
- console.warn('Matcha-mask writeValue work with string | number, your current value:', typeof transformedValue);
12649
- }
12650
- }
12651
- else {
12652
- if (!this._maskValue()) {
12653
- this.onChange(el.value);
12654
- return;
12655
- }
12656
- this._maskService.applyValueChanges(el.value.length, this._justPasted(), this._code() === "Backspace" /* MaskExpression.BACKSPACE */ || this._code() === "Delete" /* MaskExpression.DELETE */);
12657
- }
12658
- }
12659
- // IME starts
12660
- onCompositionStart() {
12661
- this._isComposing.set(true);
12662
- }
12663
- // IME completes
12664
- onCompositionEnd(e) {
12665
- this._isComposing.set(false);
12666
- this._justPasted.set(true);
12667
- this.onInput(e);
12668
- }
12669
- onBlur(e) {
12670
- if (this._maskValue()) {
12671
- const el = e.target;
12672
- if (this._maskService.leadZero &&
12673
- el.value.length > 0 &&
12674
- typeof this._maskService.decimalMarker === 'string') {
12675
- const maskExpression = this._maskService.maskExpression;
12676
- const decimalMarker = this._maskService.decimalMarker;
12677
- const suffix = this._maskService.suffix;
12678
- const precision = Number(this._maskService.maskExpression.slice(maskExpression.length - 1, maskExpression.length));
12679
- if (precision > 0) {
12680
- el.value = suffix ? el.value.split(suffix).join('') : el.value;
12681
- const decimalPart = el.value.split(decimalMarker)[1];
12682
- el.value = el.value.includes(decimalMarker)
12683
- ? el.value +
12684
- "0" /* MaskExpression.NUMBER_ZERO */.repeat(precision - decimalPart.length) +
12685
- suffix
12686
- : el.value +
12687
- decimalMarker +
12688
- "0" /* MaskExpression.NUMBER_ZERO */.repeat(precision) +
12689
- suffix;
12690
- this._maskService.actualValue = el.value;
12691
- }
12692
- }
12693
- this._maskService.clearIfNotMatchFn();
12694
- }
12695
- this._isFocused.set(false);
12696
- this.onTouch();
12697
- }
12698
- onClick(e) {
12699
- if (!this._maskValue()) {
12700
- return;
12701
- }
12702
- const el = e.target;
12703
- const posStart = 0;
12704
- const posEnd = 0;
12705
- if (el !== null &&
12706
- el.selectionStart !== null &&
12707
- el.selectionStart === el.selectionEnd &&
12708
- el.selectionStart > this._maskService.prefix.length &&
12709
- e.keyCode !== 38) {
12710
- if (this._maskService.showMaskTyped && !this.keepCharacterPositions()) {
12711
- // We are showing the mask in the input
12712
- this._maskService.maskIsShown = this._maskService.showMaskInInput();
12713
- if (el.setSelectionRange &&
12714
- this._maskService.prefix + this._maskService.maskIsShown === el.value) {
12715
- // the input ONLY contains the mask, so position the cursor at the start
12716
- el.focus();
12717
- el.setSelectionRange(posStart, posEnd);
12718
- }
12719
- else {
12720
- // the input contains some characters already
12721
- if (el.selectionStart > this._maskService.actualValue.length) {
12722
- // if the user clicked beyond our value's length, position the cursor at the end of our value
12723
- el.setSelectionRange(this._maskService.actualValue.length, this._maskService.actualValue.length);
12724
- }
12725
- }
12726
- }
12727
- }
12728
- const nextValue = el &&
12729
- (el.value === this._maskService.prefix
12730
- ? this._maskService.prefix + this._maskService.maskIsShown
12731
- : el.value);
12732
- /** Fix of cursor position jumping to end in most browsers no matter where cursor is inserted onFocus */
12733
- if (el && el.value !== nextValue) {
12734
- el.value = nextValue;
12735
- }
12736
- /** fix of cursor position with prefix when mouse click occur */
12737
- if (el &&
12738
- el.type !== 'number' &&
12739
- (el.selectionStart || el.selectionEnd) <=
12740
- this._maskService.prefix.length) {
12741
- const specialCharactersAtTheStart = this._maskService.maskExpression.match(new RegExp(`^[${this._maskService.specialCharacters.map((c) => `\\${c}`).join('')}]+`))?.[0].length || 0;
12742
- el.selectionStart = this._maskService.prefix.length + specialCharactersAtTheStart;
12743
- return;
12744
- }
12745
- /** select only inserted text */
12746
- if (el && el.selectionEnd > this._getActualInputLength()) {
12747
- el.selectionEnd = this._getActualInputLength();
12748
- }
12749
- }
12750
- onKeyDown(e) {
12751
- if (!this._maskValue()) {
12752
- return;
12753
- }
12754
- if (this._isComposing()) {
12755
- // User finalize their choice from IME composition, so trigger onInput() for the composed text.
12756
- if (e.key === 'Enter') {
12757
- this.onCompositionEnd(e);
12758
- }
12759
- return;
12760
- }
12761
- this._code.set(e.code ? e.code : e.key);
12762
- const el = e.target;
12763
- this._inputValue.set(el.value);
12764
- this._setMask();
12765
- if (el.type !== 'number') {
12766
- if (e.key === "ArrowUp" /* MaskExpression.ARROW_UP */) {
12767
- e.preventDefault();
12768
- }
12769
- if (e.key === "ArrowLeft" /* MaskExpression.ARROW_LEFT */ ||
12770
- e.key === "Backspace" /* MaskExpression.BACKSPACE */ ||
12771
- e.key === "Delete" /* MaskExpression.DELETE */) {
12772
- if (e.key === "Backspace" /* MaskExpression.BACKSPACE */ && el.value.length === 0) {
12773
- el.selectionStart = el.selectionEnd;
12774
- }
12775
- if (e.key === "Backspace" /* MaskExpression.BACKSPACE */ && el.selectionStart !== 0) {
12776
- const prefixLength = this.prefix().length;
12777
- // If specialChars is false, (shouldn't ever happen) then set to the defaults
12778
- const specialCharacters = this.specialCharacters().length
12779
- ? this.specialCharacters()
12780
- : this._config.specialCharacters;
12781
- if (prefixLength > 1 && el.selectionStart <= prefixLength) {
12782
- el.setSelectionRange(prefixLength, el.selectionEnd);
12783
- }
12784
- else {
12785
- if (this._inputValue().length !== el.selectionStart &&
12786
- el.selectionStart !== 1) {
12787
- while (specialCharacters.includes((this._inputValue()[el.selectionStart - 1] ??
12788
- "" /* MaskExpression.EMPTY_STRING */).toString()) &&
12789
- ((prefixLength >= 1 &&
12790
- el.selectionStart > prefixLength) ||
12791
- prefixLength === 0)) {
12792
- el.setSelectionRange(el.selectionStart - 1, el.selectionEnd);
12793
- }
12794
- }
12795
- }
12796
- }
12797
- this.checkSelectionOnDeletion(el);
12798
- if (this._maskService.prefix.length &&
12799
- el.selectionStart <= this._maskService.prefix.length &&
12800
- el.selectionEnd <= this._maskService.prefix.length) {
12801
- e.preventDefault();
12802
- }
12803
- const cursorStart = el.selectionStart;
12804
- if (e.key === "Backspace" /* MaskExpression.BACKSPACE */ &&
12805
- !el.readOnly &&
12806
- cursorStart === 0 &&
12807
- el.selectionEnd === el.value.length &&
12808
- el.value.length !== 0) {
12809
- this._position.set(this._maskService.prefix ? this._maskService.prefix.length : 0);
12810
- this._maskService.applyMask(this._maskService.prefix, this._maskService.maskExpression, this._position());
12811
- }
12812
- }
12813
- if (!!this.suffix() &&
12814
- this.suffix().length > 1 &&
12815
- this._inputValue().length - this.suffix().length < el.selectionStart) {
12816
- el.setSelectionRange(this._inputValue().length - this.suffix().length, this._inputValue().length);
12817
- }
12818
- else if ((e.code === 'KeyA' && e.ctrlKey) ||
12819
- (e.code === 'KeyA' && e.metaKey) // Cmd + A (Mac)
12820
- ) {
12821
- el.setSelectionRange(0, this._getActualInputLength());
12822
- e.preventDefault();
12823
- }
12824
- this._maskService.selStart = el.selectionStart;
12825
- this._maskService.selEnd = el.selectionEnd;
12826
- }
12827
- }
12828
- /** It writes the value in the input */
12829
- async writeValue(controlValue) {
12830
- let value = controlValue;
12831
- const inputTransformFn = this._maskService.inputTransformFn;
12832
- if (typeof value === 'object' && value !== null && 'value' in value) {
12833
- if ('disable' in value) {
12834
- this.setDisabledState(Boolean(value.disable));
12835
- }
12836
- value = value.value;
12837
- }
12838
- if (value !== null) {
12839
- value = inputTransformFn ? inputTransformFn(value) : value;
12840
- }
12841
- if (typeof value === 'string' ||
12842
- typeof value === 'number' ||
12843
- value === null ||
12844
- typeof value === 'undefined') {
12845
- if (value === null || typeof value === 'undefined' || value === '') {
12846
- this._maskService.currentValue = '';
12847
- this._maskService.previousValue = '';
12848
- }
12849
- let inputValue = value;
12850
- if (typeof inputValue === 'number' ||
12851
- this._maskValue().startsWith("separator" /* MaskExpression.SEPARATOR */)) {
12852
- inputValue = String(inputValue);
12853
- const localeDecimalMarker = this._maskService.currentLocaleDecimalMarker();
12854
- if (!Array.isArray(this._maskService.decimalMarker)) {
12855
- inputValue =
12856
- this._maskService.decimalMarker !== localeDecimalMarker
12857
- ? inputValue.replace(localeDecimalMarker, this._maskService.decimalMarker)
12858
- : inputValue;
12859
- }
12860
- if (this._maskService.leadZero &&
12861
- inputValue &&
12862
- this.mask() &&
12863
- this.dropSpecialCharacters() !== false) {
12864
- inputValue = this._maskService._checkPrecision(this._maskService.maskExpression, inputValue);
12865
- }
12866
- if (this._maskService.decimalMarker === "," /* MaskExpression.COMMA */ ||
12867
- (Array.isArray(this._maskService.decimalMarker) &&
12868
- this._maskService.thousandSeparator === "." /* MaskExpression.DOT */)) {
12869
- inputValue = inputValue
12870
- .toString()
12871
- .replace("." /* MaskExpression.DOT */, "," /* MaskExpression.COMMA */);
12872
- }
12873
- if (this.mask()?.startsWith("separator" /* MaskExpression.SEPARATOR */) && this.leadZero()) {
12874
- requestAnimationFrame(() => {
12875
- this._maskService.applyMask(inputValue?.toString() ?? '', this._maskService.maskExpression);
12876
- });
12877
- }
12878
- this._maskService.isNumberValue = true;
12879
- }
12880
- if (typeof inputValue !== 'string' || value === null || typeof value === 'undefined') {
12881
- inputValue = '';
12882
- }
12883
- this._inputValue.set(inputValue);
12884
- this._setMask();
12885
- if ((inputValue && this._maskService.maskExpression) ||
12886
- (this._maskService.maskExpression &&
12887
- (this._maskService.prefix || this._maskService.showMaskTyped))) {
12888
- // Let the service we know we are writing value so that triggering onChange function won't happen during applyMask
12889
- this._maskService.writingValue = true;
12890
- this._maskService.formElementProperty = [
12891
- 'value',
12892
- this._maskService.applyMask(inputValue, this._maskService.maskExpression),
12893
- ];
12894
- // Let the service know we've finished writing value
12895
- this._maskService.writingValue = false;
12896
- }
12897
- else {
12898
- this._maskService.formElementProperty = ['value', inputValue];
12899
- }
12900
- this._inputValue.set(inputValue);
12901
- }
12902
- else {
12903
- // eslint-disable-next-line no-console
12904
- console.warn('Matcha-mask writeValue work with string | number, your current value:', typeof value);
12905
- }
12906
- }
12907
- registerOnChange(fn) {
12908
- this._maskService.onChange = this.onChange = fn;
12909
- }
12910
- registerOnTouched(fn) {
12911
- this.onTouch = fn;
12912
- }
12913
- _getActiveElement(document = this.document) {
12914
- const shadowRootEl = document?.activeElement?.shadowRoot;
12915
- if (!shadowRootEl?.activeElement) {
12916
- return document.activeElement;
12917
- }
12918
- else {
12919
- return this._getActiveElement(shadowRootEl);
12920
- }
12921
- }
12922
- checkSelectionOnDeletion(el) {
12923
- const prefixLength = this.prefix().length;
12924
- const suffixLength = this.suffix().length;
12925
- const inputValueLength = this._inputValue().length;
12926
- el.selectionStart = Math.min(Math.max(prefixLength, el.selectionStart), inputValueLength - suffixLength);
12927
- el.selectionEnd = Math.min(Math.max(prefixLength, el.selectionEnd), inputValueLength - suffixLength);
12928
- }
12929
- /** It disables the input element */
12930
- setDisabledState(isDisabled) {
12931
- this._maskService.formElementProperty = ['disabled', isDisabled];
12932
- }
12933
- _applyMask() {
12934
- this._maskService.maskExpression = this._maskService._repeatPatternSymbols(this._maskValue() || '');
12935
- this._maskService.formElementProperty = [
12936
- 'value',
12937
- this._maskService.applyMask(this._inputValue(), this._maskService.maskExpression),
12938
- ];
12939
- }
12940
- _validateTime(value) {
12941
- const rowMaskLen = this._maskValue()
12942
- .split("" /* MaskExpression.EMPTY_STRING */)
12943
- .filter((s) => s !== ':').length;
12944
- if (!value) {
12945
- return null; // Don't validate empty values to allow for optional form control
12946
- }
12947
- if ((+(value[value.length - 1] ?? -1) === 0 && value.length < rowMaskLen) ||
12948
- value.length <= rowMaskLen - 2) {
12949
- return this._createValidationError(value);
12950
- }
12951
- return null;
12952
- }
12953
- _getActualInputLength() {
12954
- return (this._maskService.actualValue.length ||
12955
- this._maskService.actualValue.length + this._maskService.prefix.length);
12956
- }
12957
- _createValidationError(actualValue) {
12958
- return {
12959
- mask: {
12960
- requiredMask: this._maskValue(),
12961
- actualValue,
12962
- },
12963
- };
12964
- }
12965
- _setMask() {
12966
- this._maskExpressionArray().some((mask) => {
12967
- const specialChart = mask
12968
- .split("" /* MaskExpression.EMPTY_STRING */)
12969
- .some((char) => this._maskService.specialCharacters.includes(char));
12970
- if ((specialChart &&
12971
- this._inputValue() &&
12972
- this._areAllCharactersInEachStringSame(this._maskExpressionArray())) ||
12973
- mask.includes("{" /* MaskExpression.CURLY_BRACKETS_LEFT */)) {
12974
- const test = this._maskService.removeMask(this._inputValue())?.length <=
12975
- this._maskService.removeMask(mask)?.length;
12976
- if (test) {
12977
- const maskValue = mask.includes("{" /* MaskExpression.CURLY_BRACKETS_LEFT */)
12978
- ? this._maskService._repeatPatternSymbols(mask)
12979
- : mask;
12980
- this._maskValue.set(maskValue);
12981
- this._maskService.maskExpression = maskValue;
12982
- return test;
12983
- }
12984
- else {
12985
- const expression = this._maskExpressionArray()[this._maskExpressionArray().length - 1] ??
12986
- "" /* MaskExpression.EMPTY_STRING */;
12987
- const maskValue = expression.includes("{" /* MaskExpression.CURLY_BRACKETS_LEFT */)
12988
- ? this._maskService._repeatPatternSymbols(expression)
12989
- : expression;
12990
- this._maskValue.set(maskValue);
12991
- this._maskService.maskExpression = maskValue;
12992
- }
12993
- }
12994
- else {
12995
- const cleanMask = this._maskService.removeMask(mask);
12996
- const check = this._maskService
12997
- .removeMask(this._inputValue())
12998
- ?.split("" /* MaskExpression.EMPTY_STRING */)
12999
- .every((character, index) => {
13000
- const indexMask = cleanMask.charAt(index);
13001
- return this._maskService._checkSymbolMask(character, indexMask);
13002
- });
13003
- if (check || this._justPasted()) {
13004
- this._maskValue.set(mask);
13005
- this._maskService.maskExpression = mask;
13006
- return check;
13007
- }
13008
- }
13009
- });
13010
- }
13011
- _areAllCharactersInEachStringSame(array) {
13012
- const specialCharacters = this._maskService.specialCharacters;
13013
- function removeSpecialCharacters(str) {
13014
- const regex = new RegExp(`[${specialCharacters.map((ch) => `\\${ch}`).join('')}]`, 'g');
13015
- return str.replace(regex, '');
13016
- }
13017
- const processedArr = array.map(removeSpecialCharacters);
13018
- return processedArr.every((str) => {
13019
- const uniqueCharacters = new Set(str);
13020
- return uniqueCharacters.size === 1;
13021
- });
13022
- }
13023
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaMaskDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
13024
- static { this.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "17.1.0", version: "20.3.0", type: MatchaMaskDirective, isStandalone: false, selector: "input[mask], textarea[mask]", inputs: { mask: { classPropertyName: "mask", publicName: "mask", isSignal: true, isRequired: false, transformFunction: null }, specialCharacters: { classPropertyName: "specialCharacters", publicName: "specialCharacters", isSignal: true, isRequired: false, transformFunction: null }, patterns: { classPropertyName: "patterns", publicName: "patterns", isSignal: true, isRequired: false, transformFunction: null }, prefix: { classPropertyName: "prefix", publicName: "prefix", isSignal: true, isRequired: false, transformFunction: null }, suffix: { classPropertyName: "suffix", publicName: "suffix", isSignal: true, isRequired: false, transformFunction: null }, thousandSeparator: { classPropertyName: "thousandSeparator", publicName: "thousandSeparator", isSignal: true, isRequired: false, transformFunction: null }, decimalMarker: { classPropertyName: "decimalMarker", publicName: "decimalMarker", isSignal: true, isRequired: false, transformFunction: null }, dropSpecialCharacters: { classPropertyName: "dropSpecialCharacters", publicName: "dropSpecialCharacters", isSignal: true, isRequired: false, transformFunction: null }, hiddenInput: { classPropertyName: "hiddenInput", publicName: "hiddenInput", isSignal: true, isRequired: false, transformFunction: null }, showMaskTyped: { classPropertyName: "showMaskTyped", publicName: "showMaskTyped", isSignal: true, isRequired: false, transformFunction: null }, placeHolderCharacter: { classPropertyName: "placeHolderCharacter", publicName: "placeHolderCharacter", isSignal: true, isRequired: false, transformFunction: null }, shownMaskExpression: { classPropertyName: "shownMaskExpression", publicName: "shownMaskExpression", isSignal: true, isRequired: false, transformFunction: null }, clearIfNotMatch: { classPropertyName: "clearIfNotMatch", publicName: "clearIfNotMatch", isSignal: true, isRequired: false, transformFunction: null }, validation: { classPropertyName: "validation", publicName: "validation", isSignal: true, isRequired: false, transformFunction: null }, separatorLimit: { classPropertyName: "separatorLimit", publicName: "separatorLimit", isSignal: true, isRequired: false, transformFunction: null }, allowNegativeNumbers: { classPropertyName: "allowNegativeNumbers", publicName: "allowNegativeNumbers", isSignal: true, isRequired: false, transformFunction: null }, leadZeroDateTime: { classPropertyName: "leadZeroDateTime", publicName: "leadZeroDateTime", isSignal: true, isRequired: false, transformFunction: null }, leadZero: { classPropertyName: "leadZero", publicName: "leadZero", isSignal: true, isRequired: false, transformFunction: null }, triggerOnMaskChange: { classPropertyName: "triggerOnMaskChange", publicName: "triggerOnMaskChange", isSignal: true, isRequired: false, transformFunction: null }, apm: { classPropertyName: "apm", publicName: "apm", isSignal: true, isRequired: false, transformFunction: null }, inputTransformFn: { classPropertyName: "inputTransformFn", publicName: "inputTransformFn", isSignal: true, isRequired: false, transformFunction: null }, outputTransformFn: { classPropertyName: "outputTransformFn", publicName: "outputTransformFn", isSignal: true, isRequired: false, transformFunction: null }, keepCharacterPositions: { classPropertyName: "keepCharacterPositions", publicName: "keepCharacterPositions", isSignal: true, isRequired: false, transformFunction: null }, instantPrefix: { classPropertyName: "instantPrefix", publicName: "instantPrefix", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { maskFilled: "maskFilled" }, host: { listeners: { "paste": "onPaste()", "focus": "onFocus($event)", "ngModelChange": "onModelChange($event)", "input": "onInput($event)", "compositionstart": "onCompositionStart($event)", "compositionend": "onCompositionEnd($event)", "blur": "onBlur($event)", "click": "onClick($event)", "keydown": "onKeyDown($event)" } }, providers: [
13025
- {
13026
- provide: NG_VALUE_ACCESSOR,
13027
- useExisting: forwardRef(() => MatchaMaskDirective),
13028
- multi: true,
13029
- },
13030
- {
13031
- provide: NG_VALIDATORS,
13032
- useExisting: forwardRef(() => MatchaMaskDirective),
13033
- multi: true,
13034
- },
13035
- MatchaMaskService,
13036
- ], exportAs: ["mask", "matchaMask"], usesOnChanges: true, ngImport: i0 }); }
13037
- }
13038
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaMaskDirective, decorators: [{
13039
- type: Directive,
13040
- args: [{
13041
- selector: 'input[mask], textarea[mask]',
13042
- standalone: false,
13043
- providers: [
13044
- {
13045
- provide: NG_VALUE_ACCESSOR,
13046
- useExisting: forwardRef(() => MatchaMaskDirective),
13047
- multi: true,
13048
- },
13049
- {
13050
- provide: NG_VALIDATORS,
13051
- useExisting: forwardRef(() => MatchaMaskDirective),
13052
- multi: true,
13053
- },
13054
- MatchaMaskService,
13055
- ],
13056
- exportAs: 'mask,matchaMask',
13057
- }]
13058
- }], propDecorators: { onPaste: [{
13059
- type: HostListener,
13060
- args: ['paste']
13061
- }], onFocus: [{
13062
- type: HostListener,
13063
- args: ['focus', ['$event']]
13064
- }], onModelChange: [{
13065
- type: HostListener,
13066
- args: ['ngModelChange', ['$event']]
13067
- }], onInput: [{
13068
- type: HostListener,
13069
- args: ['input', ['$event']]
13070
- }], onCompositionStart: [{
13071
- type: HostListener,
13072
- args: ['compositionstart', ['$event']]
13073
- }], onCompositionEnd: [{
13074
- type: HostListener,
13075
- args: ['compositionend', ['$event']]
13076
- }], onBlur: [{
13077
- type: HostListener,
13078
- args: ['blur', ['$event']]
13079
- }], onClick: [{
13080
- type: HostListener,
13081
- args: ['click', ['$event']]
13082
- }], onKeyDown: [{
13083
- type: HostListener,
13084
- args: ['keydown', ['$event']]
13085
- }] } });
13086
-
13087
12148
  class MatchaMaskPipe {
13088
12149
  constructor() {
13089
12150
  this.defaultOptions = inject(MATCHA_MASK_CONFIG);
@@ -13182,64 +12243,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImpor
13182
12243
  }]
13183
12244
  }] });
13184
12245
 
13185
- const options = {
13186
- specialCharacters: ['/', '(', ')', '.', ':', '-', ' ', '+', ',', '@', '[', ']', '"', "'", '*'],
13187
- patterns: {
13188
- '0': { pattern: /\d/ },
13189
- '9': { pattern: /\d/, optional: true },
13190
- 'A': { pattern: /[a-zA-Z0-9]/ },
13191
- 'S': { pattern: /[a-zA-Z]/ }
13192
- },
13193
- prefix: '',
13194
- suffix: '',
13195
- thousandSeparator: '',
13196
- decimalMarker: '.',
13197
- clearIfNotMatch: false,
13198
- showMaskTyped: false,
13199
- placeHolderCharacter: '_',
13200
- shownMaskExpression: '',
13201
- dropSpecialCharacters: true,
13202
- hiddenInput: false,
13203
- validation: true,
13204
- instantPrefix: false,
13205
- separatorLimit: '',
13206
- apm: false,
13207
- allowNegativeNumbers: false,
13208
- leadZeroDateTime: false,
13209
- leadZero: false,
13210
- triggerOnMaskChange: false,
13211
- keepCharacterPositions: false,
13212
- inputTransformFn: (v) => v,
13213
- outputTransformFn: (v) => v,
13214
- maskFilled: new EventEmitter()
13215
- };
13216
- class MatchaMaskModule {
13217
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaMaskModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
13218
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.0", ngImport: i0, type: MatchaMaskModule, declarations: [MatchaMaskDirective, MatchaMaskPipe], imports: [CommonModule], exports: [MatchaMaskDirective,
13219
- MatchaMaskPipe] }); }
13220
- static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaMaskModule, providers: [
13221
- MatchaMaskService,
13222
- { provide: MATCHA_MASK_CONFIG, useValue: options }
13223
- ], imports: [CommonModule] }); }
13224
- }
13225
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaMaskModule, decorators: [{
13226
- type: NgModule,
13227
- args: [{
13228
- declarations: [MatchaMaskDirective, MatchaMaskPipe],
13229
- imports: [
13230
- CommonModule
13231
- ],
13232
- exports: [
13233
- MatchaMaskDirective,
13234
- MatchaMaskPipe
13235
- ],
13236
- providers: [
13237
- MatchaMaskService,
13238
- { provide: MATCHA_MASK_CONFIG, useValue: options }
13239
- ]
13240
- }]
13241
- }] });
13242
-
13243
12246
  class StepContentDirective {
13244
12247
  constructor(template) {
13245
12248
  this.template = template;
@@ -13271,5 +12274,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImpor
13271
12274
  * Generated bundle index. Do not edit.
13272
12275
  */
13273
12276
 
13274
- export { CopyButtonComponent, INITIAL_CONFIG, MATCHA_MASK_CONFIG, MATCHA_OPTION_PARENT, MatchaAccordionComponent, MatchaAccordionContentComponent, MatchaAccordionHeaderComponent, MatchaAccordionItemComponent, MatchaAccordionModule, MatchaAutocompleteComponent, MatchaAutocompleteModule, MatchaAutocompleteTriggerDirective, MatchaAvatarComponent, MatchaAvatarModule, MatchaBadgeDirective, MatchaBadgeModule, MatchaBreakpointObservableModule, MatchaBreakpointObserver, MatchaButtonComponent, MatchaButtonModule, MatchaButtonToggleComponent, MatchaButtonToggleModule, MatchaCardComponent, MatchaCardModule, MatchaCheckboxComponent, MatchaCheckboxModule, MatchaComponentsModule, MatchaDateRangeComponent, MatchaDateRangeModule, MatchaDividerComponent, MatchaDividerModule, MatchaDragDirective, MatchaDragHandleDirective, MatchaDrawerComponent, MatchaDrawerContainerComponent, MatchaDrawerContentComponent, MatchaDrawerModule, MatchaDropListComponent, MatchaDropListModule, MatchaElevationDirective, MatchaElevationModule, MatchaErrorComponent, MatchaFormFieldComponent, MatchaFormFieldModule, MatchaGridComponent, MatchaGridModule, MatchaHighlightComponent, MatchaHighlightModule, MatchaHintTextComponent, MatchaHintTextModule, MatchaIconComponent, MatchaIconModule, MatchaInfiniteScrollComponent, MatchaInfiniteScrollDataComponent, MatchaInfiniteScrollModule, MatchaInputDirective, MatchaInputModule, MatchaInputPhoneComponent, MatchaInputPhoneModule, MatchaLabelComponent, MatchaLazyloadComponent, MatchaLazyloadDataComponent, MatchaLazyloadModule, MatchaMaskApplierService, MatchaMaskCompatibleDirective, MatchaMaskCompatibleModule, MatchaMaskDirective, MatchaMaskModule, MatchaMaskPipe, MatchaMaskService, MatchaMasonryComponent, MatchaMasonryModule, MatchaMenuComponent, MatchaMenuModule, MatchaMenuTriggerForDirective, MatchaModalComponent, MatchaModalContentComponent, MatchaModalFooterComponent, MatchaModalHeaderComponent, MatchaModalModule, MatchaModalOptionsComponent, MatchaModalService, MatchaOptionComponent, MatchaOptionModule, MatchaOverlayService, MatchaPageLayoutComponent, MatchaPageLayoutModule, MatchaPaginatorComponent, MatchaPaginatorIntl, MatchaPaginatorModule, MatchaPanelComponent, MatchaPanelModule, MatchaProgressBarDirective, MatchaProgressBarModule, MatchaRadioComponent, MatchaRadioModule, MatchaRippleDirective, MatchaRippleModule, MatchaSelectComponent, MatchaSelectModule, MatchaSelectTriggerDirective, MatchaSidenavDirective, MatchaSidenavModule, MatchaSkeletonComponent, MatchaSkeletonModule, MatchaSlideToggleComponent, MatchaSlideToggleModule, MatchaSliderComponent, MatchaSliderModule, MatchaSnackBarDirective, MatchaSnackBarModule, MatchaSortHeaderDirective, MatchaSortHeaderModule, MatchaSpinComponent, MatchaSpinModule, MatchaSpinnerComponent, MatchaSpinnerModule, MatchaStepperComponent, MatchaStepperContentComponent, MatchaStepperControllerComponent, MatchaStepperModule, MatchaStepperStateService, MatchaTabItemComponent, MatchaTableDirective, MatchaTableModule, MatchaTabsComponent, MatchaTabsModule, MatchaTimeComponent, MatchaTimeModule, MatchaTitleComponent, MatchaTitleModule, MatchaToolbarButtonComponent, MatchaToolbarComponent, MatchaToolbarContentComponent, MatchaToolbarCustomButtonComponent, MatchaToolbarMainButtonComponent, MatchaToolbarModule, MatchaTooltipDirective, MatchaTooltipModule, NEW_CONFIG, NextStepDirective, PrevStepDirective, StepComponent, StepContentDirective, compatibleOptions, initialConfig, options, timeMasks, withoutValidation };
12277
+ export { CopyButtonComponent, INITIAL_CONFIG, MATCHA_MASK_CONFIG, MATCHA_OPTION_PARENT, MatchaAccordionComponent, MatchaAccordionContentComponent, MatchaAccordionHeaderComponent, MatchaAccordionItemComponent, MatchaAccordionModule, MatchaAutocompleteComponent, MatchaAutocompleteModule, MatchaAutocompleteTriggerDirective, MatchaAvatarComponent, MatchaAvatarModule, MatchaBadgeDirective, MatchaBadgeModule, MatchaBreakpointObservableModule, MatchaBreakpointObserver, MatchaButtonComponent, MatchaButtonModule, MatchaButtonToggleComponent, MatchaButtonToggleModule, MatchaCardComponent, MatchaCardModule, MatchaCheckboxComponent, MatchaCheckboxModule, MatchaComponentsModule, MatchaDateRangeComponent, MatchaDateRangeModule, MatchaDividerComponent, MatchaDividerModule, MatchaDragDirective, MatchaDragHandleDirective, MatchaDrawerComponent, MatchaDrawerContainerComponent, MatchaDrawerContentComponent, MatchaDrawerModule, MatchaDropListComponent, MatchaDropListModule, MatchaElevationDirective, MatchaElevationModule, MatchaErrorComponent, MatchaFormFieldComponent, MatchaFormFieldModule, MatchaGridComponent, MatchaGridModule, MatchaHighlightComponent, MatchaHighlightModule, MatchaHintTextComponent, MatchaHintTextModule, MatchaIconComponent, MatchaIconModule, MatchaInfiniteScrollComponent, MatchaInfiniteScrollDataComponent, MatchaInfiniteScrollModule, MatchaInputDirective, MatchaInputModule, MatchaInputPhoneComponent, MatchaInputPhoneModule, MatchaLabelComponent, MatchaLazyloadComponent, MatchaLazyloadDataComponent, MatchaLazyloadModule, MatchaMaskApplierService, MatchaMaskCompatibleDirective, MatchaMaskModule, MatchaMaskPipe, MatchaMaskService, MatchaMasonryComponent, MatchaMasonryModule, MatchaMenuComponent, MatchaMenuModule, MatchaMenuTriggerForDirective, MatchaModalComponent, MatchaModalContentComponent, MatchaModalFooterComponent, MatchaModalHeaderComponent, MatchaModalModule, MatchaModalOptionsComponent, MatchaModalService, MatchaOptionComponent, MatchaOptionModule, MatchaOverlayService, MatchaPageLayoutComponent, MatchaPageLayoutModule, MatchaPaginatorComponent, MatchaPaginatorIntl, MatchaPaginatorModule, MatchaPanelComponent, MatchaPanelModule, MatchaProgressBarDirective, MatchaProgressBarModule, MatchaRadioComponent, MatchaRadioModule, MatchaRippleDirective, MatchaRippleModule, MatchaSelectComponent, MatchaSelectModule, MatchaSelectTriggerDirective, MatchaSidenavDirective, MatchaSidenavModule, MatchaSkeletonComponent, MatchaSkeletonModule, MatchaSlideToggleComponent, MatchaSlideToggleModule, MatchaSliderComponent, MatchaSliderModule, MatchaSnackBarDirective, MatchaSnackBarModule, MatchaSortHeaderDirective, MatchaSortHeaderModule, MatchaSpinComponent, MatchaSpinModule, MatchaSpinnerComponent, MatchaSpinnerModule, MatchaStepperComponent, MatchaStepperContentComponent, MatchaStepperControllerComponent, MatchaStepperModule, MatchaStepperStateService, MatchaTabItemComponent, MatchaTableDirective, MatchaTableModule, MatchaTabsComponent, MatchaTabsModule, MatchaTimeComponent, MatchaTimeModule, MatchaTitleComponent, MatchaTitleModule, MatchaToolbarButtonComponent, MatchaToolbarComponent, MatchaToolbarContentComponent, MatchaToolbarCustomButtonComponent, MatchaToolbarMainButtonComponent, MatchaToolbarModule, MatchaTooltipDirective, MatchaTooltipModule, NEW_CONFIG, NextStepDirective, PrevStepDirective, StepComponent, StepContentDirective, compatibleOptions, initialConfig, timeMasks, withoutValidation };
13275
12278
  //# sourceMappingURL=matcha-components.mjs.map