matcha-components 20.44.0 → 20.45.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.
@@ -11806,1101 +11806,6 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImpor
11806
11806
  }]
11807
11807
  }] });
11808
11808
 
11809
- class MatchaMaskDirective {
11810
- constructor() {
11811
- this.mask = input('', ...(ngDevMode ? [{ debugName: "mask" }] : []));
11812
- this.specialCharacters = input([], ...(ngDevMode ? [{ debugName: "specialCharacters" }] : []));
11813
- this.patterns = input({}, ...(ngDevMode ? [{ debugName: "patterns" }] : []));
11814
- this.prefix = input('', ...(ngDevMode ? [{ debugName: "prefix" }] : []));
11815
- this.suffix = input('', ...(ngDevMode ? [{ debugName: "suffix" }] : []));
11816
- this.thousandSeparator = input(' ', ...(ngDevMode ? [{ debugName: "thousandSeparator" }] : []));
11817
- this.decimalMarker = input('.', ...(ngDevMode ? [{ debugName: "decimalMarker" }] : []));
11818
- this.dropSpecialCharacters = input(null, ...(ngDevMode ? [{ debugName: "dropSpecialCharacters" }] : []));
11819
- this.hiddenInput = input(null, ...(ngDevMode ? [{ debugName: "hiddenInput" }] : []));
11820
- this.showMaskTyped = input(null, ...(ngDevMode ? [{ debugName: "showMaskTyped" }] : []));
11821
- this.placeHolderCharacter = input(null, ...(ngDevMode ? [{ debugName: "placeHolderCharacter" }] : []));
11822
- this.shownMaskExpression = input(null, ...(ngDevMode ? [{ debugName: "shownMaskExpression" }] : []));
11823
- this.clearIfNotMatch = input(null, ...(ngDevMode ? [{ debugName: "clearIfNotMatch" }] : []));
11824
- this.validation = input(null, ...(ngDevMode ? [{ debugName: "validation" }] : []));
11825
- this.separatorLimit = input('', ...(ngDevMode ? [{ debugName: "separatorLimit" }] : []));
11826
- this.allowNegativeNumbers = input(null, ...(ngDevMode ? [{ debugName: "allowNegativeNumbers" }] : []));
11827
- this.leadZeroDateTime = input(null, ...(ngDevMode ? [{ debugName: "leadZeroDateTime" }] : []));
11828
- this.leadZero = input(null, ...(ngDevMode ? [{ debugName: "leadZero" }] : []));
11829
- this.triggerOnMaskChange = input(null, ...(ngDevMode ? [{ debugName: "triggerOnMaskChange" }] : []));
11830
- this.apm = input(null, ...(ngDevMode ? [{ debugName: "apm" }] : []));
11831
- this.inputTransformFn = input(null, ...(ngDevMode ? [{ debugName: "inputTransformFn" }] : []));
11832
- this.outputTransformFn = input(null, ...(ngDevMode ? [{ debugName: "outputTransformFn" }] : []));
11833
- this.keepCharacterPositions = input(null, ...(ngDevMode ? [{ debugName: "keepCharacterPositions" }] : []));
11834
- this.instantPrefix = input(null, ...(ngDevMode ? [{ debugName: "instantPrefix" }] : []));
11835
- this.maskFilled = output();
11836
- this._maskValue = signal('', ...(ngDevMode ? [{ debugName: "_maskValue" }] : []));
11837
- this._inputValue = signal('', ...(ngDevMode ? [{ debugName: "_inputValue" }] : []));
11838
- this._position = signal(null, ...(ngDevMode ? [{ debugName: "_position" }] : []));
11839
- this._code = signal('', ...(ngDevMode ? [{ debugName: "_code" }] : []));
11840
- this._maskExpressionArray = signal([], ...(ngDevMode ? [{ debugName: "_maskExpressionArray" }] : []));
11841
- this._justPasted = signal(false, ...(ngDevMode ? [{ debugName: "_justPasted" }] : []));
11842
- this._isFocused = signal(false, ...(ngDevMode ? [{ debugName: "_isFocused" }] : []));
11843
- /**For IME composition event */
11844
- this._isComposing = signal(false, ...(ngDevMode ? [{ debugName: "_isComposing" }] : []));
11845
- this._maskService = inject(MatchaMaskService, { self: true });
11846
- this.document = inject(DOCUMENT);
11847
- this._config = inject(MATCHA_MASK_CONFIG);
11848
- // eslint-disable-next-line @typescript-eslint/no-empty-function
11849
- this.onChange = (_) => { };
11850
- // eslint-disable-next-line @typescript-eslint/no-empty-function
11851
- this.onTouch = () => { };
11852
- }
11853
- ngOnChanges(changes) {
11854
- 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;
11855
- if (mask) {
11856
- if (mask.currentValue !== mask.previousValue && !mask.firstChange) {
11857
- this._maskService.maskChanged = true;
11858
- }
11859
- if (mask.currentValue && mask.currentValue.split("||" /* MaskExpression.OR */).length > 1) {
11860
- this._maskExpressionArray.set(mask.currentValue.split("||" /* MaskExpression.OR */).sort((a, b) => {
11861
- return a.length - b.length;
11862
- }));
11863
- this._setMask();
11864
- }
11865
- else {
11866
- this._maskExpressionArray.set([]);
11867
- this._maskValue.set(mask.currentValue || "" /* MaskExpression.EMPTY_STRING */);
11868
- this._maskService.maskExpression = this._maskValue();
11869
- }
11870
- }
11871
- if (specialCharacters) {
11872
- if (!specialCharacters.currentValue || !Array.isArray(specialCharacters.currentValue)) {
11873
- return;
11874
- }
11875
- else {
11876
- this._maskService.specialCharacters = specialCharacters.currentValue || [];
11877
- }
11878
- }
11879
- if (allowNegativeNumbers) {
11880
- this._maskService.allowNegativeNumbers = allowNegativeNumbers.currentValue;
11881
- if (this._maskService.allowNegativeNumbers) {
11882
- this._maskService.specialCharacters = this._maskService.specialCharacters.filter((c) => c !== "-" /* MaskExpression.MINUS */);
11883
- }
11884
- }
11885
- // Only overwrite the mask available patterns if a pattern has actually been passed in
11886
- if (patterns && patterns.currentValue) {
11887
- this._maskService.patterns = patterns.currentValue;
11888
- }
11889
- if (apm && apm.currentValue) {
11890
- this._maskService.apm = apm.currentValue;
11891
- }
11892
- if (instantPrefix) {
11893
- this._maskService.instantPrefix = instantPrefix.currentValue;
11894
- }
11895
- if (prefix) {
11896
- this._maskService.prefix = prefix.currentValue;
11897
- }
11898
- if (suffix) {
11899
- this._maskService.suffix = suffix.currentValue;
11900
- }
11901
- if (thousandSeparator) {
11902
- this._maskService.thousandSeparator = thousandSeparator.currentValue;
11903
- if (thousandSeparator.previousValue && thousandSeparator.currentValue) {
11904
- const previousDecimalMarker = this._maskService.decimalMarker;
11905
- if (thousandSeparator.currentValue === this._maskService.decimalMarker) {
11906
- this._maskService.decimalMarker =
11907
- thousandSeparator.currentValue === "," /* MaskExpression.COMMA */
11908
- ? "." /* MaskExpression.DOT */
11909
- : "," /* MaskExpression.COMMA */;
11910
- }
11911
- if (this._maskService.dropSpecialCharacters === true) {
11912
- this._maskService.specialCharacters = this._config.specialCharacters;
11913
- }
11914
- if (typeof previousDecimalMarker === 'string' &&
11915
- typeof this._maskService.decimalMarker === 'string') {
11916
- this._inputValue.set(this._inputValue()
11917
- .split(thousandSeparator.previousValue)
11918
- .join('')
11919
- .replace(previousDecimalMarker, this._maskService.decimalMarker));
11920
- this._maskService.actualValue = this._inputValue();
11921
- }
11922
- this._maskService.writingValue = true;
11923
- }
11924
- }
11925
- if (decimalMarker) {
11926
- this._maskService.decimalMarker = decimalMarker.currentValue;
11927
- }
11928
- if (dropSpecialCharacters) {
11929
- this._maskService.dropSpecialCharacters = dropSpecialCharacters.currentValue;
11930
- }
11931
- if (hiddenInput) {
11932
- this._maskService.hiddenInput = hiddenInput.currentValue;
11933
- if (hiddenInput.previousValue === true && hiddenInput.currentValue === false) {
11934
- this._inputValue.set(this._maskService.actualValue);
11935
- }
11936
- }
11937
- if (showMaskTyped) {
11938
- this._maskService.showMaskTyped = showMaskTyped.currentValue;
11939
- if (showMaskTyped.previousValue === false &&
11940
- showMaskTyped.currentValue === true &&
11941
- this._isFocused()) {
11942
- requestAnimationFrame(() => {
11943
- this._maskService._elementRef?.nativeElement.click();
11944
- });
11945
- }
11946
- }
11947
- if (placeHolderCharacter) {
11948
- this._maskService.placeHolderCharacter = placeHolderCharacter.currentValue;
11949
- }
11950
- if (shownMaskExpression) {
11951
- this._maskService.shownMaskExpression = shownMaskExpression.currentValue;
11952
- }
11953
- if (clearIfNotMatch) {
11954
- this._maskService.clearIfNotMatch = clearIfNotMatch.currentValue;
11955
- }
11956
- if (validation) {
11957
- this._maskService.validation = validation.currentValue;
11958
- }
11959
- if (separatorLimit) {
11960
- this._maskService.separatorLimit = separatorLimit.currentValue;
11961
- }
11962
- if (leadZeroDateTime) {
11963
- this._maskService.leadZeroDateTime = leadZeroDateTime.currentValue;
11964
- }
11965
- if (leadZero) {
11966
- this._maskService.leadZero = leadZero.currentValue;
11967
- }
11968
- if (triggerOnMaskChange) {
11969
- this._maskService.triggerOnMaskChange = triggerOnMaskChange.currentValue;
11970
- }
11971
- if (inputTransformFn) {
11972
- this._maskService.inputTransformFn = inputTransformFn.currentValue;
11973
- }
11974
- if (outputTransformFn) {
11975
- this._maskService.outputTransformFn = outputTransformFn.currentValue;
11976
- }
11977
- if (keepCharacterPositions) {
11978
- this._maskService.keepCharacterPositions = keepCharacterPositions.currentValue;
11979
- }
11980
- this._applyMask();
11981
- }
11982
- validate({ value }) {
11983
- const processedValue = typeof value === 'number' ? String(value) : value;
11984
- const maskValue = this._maskValue();
11985
- if (!this._maskService.validation || !maskValue) {
11986
- return null;
11987
- }
11988
- if (this._maskService.ipError) {
11989
- return this._createValidationError(processedValue);
11990
- }
11991
- if (this._maskService.cpfCnpjError) {
11992
- return this._createValidationError(processedValue);
11993
- }
11994
- if (maskValue.startsWith("separator" /* MaskExpression.SEPARATOR */)) {
11995
- return null;
11996
- }
11997
- if (withoutValidation.includes(maskValue)) {
11998
- return null;
11999
- }
12000
- if (this._maskService.clearIfNotMatch) {
12001
- return null;
12002
- }
12003
- if (timeMasks.includes(maskValue)) {
12004
- return this._validateTime(processedValue);
12005
- }
12006
- if (maskValue === "A*@A*.A*" /* MaskExpression.EMAIL_MASK */) {
12007
- const emailPattern = /^[^@]+@[^@]+\.[^@]+$/;
12008
- if (!emailPattern.test(processedValue) && processedValue) {
12009
- return this._createValidationError(processedValue);
12010
- }
12011
- else {
12012
- return null;
12013
- }
12014
- }
12015
- if (processedValue && processedValue.length >= 1) {
12016
- let counterOfOpt = 0;
12017
- if (maskValue.includes("{" /* MaskExpression.CURLY_BRACKETS_LEFT */) &&
12018
- maskValue.includes("}" /* MaskExpression.CURLY_BRACKETS_RIGHT */)) {
12019
- const lengthInsideCurlyBrackets = maskValue.slice(maskValue.indexOf("{" /* MaskExpression.CURLY_BRACKETS_LEFT */) + 1, maskValue.indexOf("}" /* MaskExpression.CURLY_BRACKETS_RIGHT */));
12020
- return lengthInsideCurlyBrackets === String(processedValue.length)
12021
- ? null
12022
- : this._createValidationError(processedValue);
12023
- }
12024
- if (maskValue.startsWith("percent" /* MaskExpression.PERCENT */)) {
12025
- return null;
12026
- }
12027
- for (const key in this._maskService.patterns) {
12028
- if (this._maskService.patterns[key]?.optional) {
12029
- if (maskValue.indexOf(key) !== maskValue.lastIndexOf(key)) {
12030
- const opt = maskValue
12031
- .split("" /* MaskExpression.EMPTY_STRING */)
12032
- .filter((i) => i === key)
12033
- .join("" /* MaskExpression.EMPTY_STRING */);
12034
- counterOfOpt += opt.length;
12035
- }
12036
- else if (maskValue.indexOf(key) !== -1) {
12037
- counterOfOpt++;
12038
- }
12039
- if (maskValue.indexOf(key) !== -1 &&
12040
- processedValue.length >= maskValue.indexOf(key)) {
12041
- return null;
12042
- }
12043
- if (counterOfOpt === maskValue.length) {
12044
- return null;
12045
- }
12046
- }
12047
- }
12048
- if ((maskValue.indexOf("*" /* MaskExpression.SYMBOL_STAR */) > 1 &&
12049
- processedValue.length < maskValue.indexOf("*" /* MaskExpression.SYMBOL_STAR */)) ||
12050
- (maskValue.indexOf("?" /* MaskExpression.SYMBOL_QUESTION */) > 1 &&
12051
- processedValue.length < maskValue.indexOf("?" /* MaskExpression.SYMBOL_QUESTION */))) {
12052
- return this._createValidationError(processedValue);
12053
- }
12054
- if (maskValue.indexOf("*" /* MaskExpression.SYMBOL_STAR */) === -1 ||
12055
- maskValue.indexOf("?" /* MaskExpression.SYMBOL_QUESTION */) === -1) {
12056
- const array = maskValue.split('*');
12057
- const length = this._maskService.dropSpecialCharacters
12058
- ? maskValue.length -
12059
- this._maskService.checkDropSpecialCharAmount(maskValue) -
12060
- counterOfOpt
12061
- : this.prefix()
12062
- ? maskValue.length + this.prefix().length - counterOfOpt
12063
- : maskValue.length - counterOfOpt;
12064
- if (array.length === 1) {
12065
- if (processedValue.length < length) {
12066
- return this._createValidationError(processedValue);
12067
- }
12068
- }
12069
- if (array.length > 1) {
12070
- const lastIndexArray = array[array.length - 1];
12071
- if (lastIndexArray &&
12072
- this._maskService.specialCharacters.includes(lastIndexArray[0]) &&
12073
- String(processedValue).includes(lastIndexArray[0] ?? '') &&
12074
- !this.dropSpecialCharacters()) {
12075
- const special = value.split(lastIndexArray[0]);
12076
- return special[special.length - 1].length === lastIndexArray.length - 1
12077
- ? null
12078
- : this._createValidationError(processedValue);
12079
- }
12080
- else if (((lastIndexArray &&
12081
- !this._maskService.specialCharacters.includes(lastIndexArray[0])) ||
12082
- !lastIndexArray ||
12083
- this._maskService.dropSpecialCharacters) &&
12084
- processedValue.length >= length - 1) {
12085
- return null;
12086
- }
12087
- else {
12088
- return this._createValidationError(processedValue);
12089
- }
12090
- }
12091
- }
12092
- if (maskValue.indexOf("*" /* MaskExpression.SYMBOL_STAR */) === 1 ||
12093
- maskValue.indexOf("?" /* MaskExpression.SYMBOL_QUESTION */) === 1) {
12094
- return null;
12095
- }
12096
- }
12097
- if (value) {
12098
- this.maskFilled.emit();
12099
- return null;
12100
- }
12101
- return null;
12102
- }
12103
- onPaste() {
12104
- this._justPasted.set(true);
12105
- }
12106
- onFocus() {
12107
- this._isFocused.set(true);
12108
- }
12109
- onModelChange(value) {
12110
- // on form reset we need to update the actualValue
12111
- if ((value === "" /* MaskExpression.EMPTY_STRING */ ||
12112
- value === null ||
12113
- typeof value === 'undefined') &&
12114
- this._maskService.actualValue) {
12115
- this._maskService.actualValue = this._maskService.getActualValue("" /* MaskExpression.EMPTY_STRING */);
12116
- }
12117
- }
12118
- onInput(e) {
12119
- // If IME is composing text, we wait for the composed text.
12120
- if (this._isComposing()) {
12121
- return;
12122
- }
12123
- const el = e.target;
12124
- const transformedValue = this._maskService.inputTransformFn
12125
- ? this._maskService.inputTransformFn(el.value)
12126
- : el.value;
12127
- if (el.type !== 'number') {
12128
- if (typeof transformedValue === 'string' || typeof transformedValue === 'number') {
12129
- el.value = transformedValue.toString();
12130
- this._inputValue.set(el.value);
12131
- this._setMask();
12132
- if (!this._maskValue()) {
12133
- this.onChange(el.value);
12134
- return;
12135
- }
12136
- let position = el.selectionStart === 1
12137
- ? el.selectionStart + this._maskService.prefix.length
12138
- : el.selectionStart;
12139
- if (this.showMaskTyped() &&
12140
- this.keepCharacterPositions() &&
12141
- this._maskService.placeHolderCharacter.length === 1) {
12142
- const suffix = this.suffix();
12143
- const prefix = this.prefix();
12144
- const inputSymbol = el.value.slice(position - 1, position);
12145
- const prefixLength = prefix.length;
12146
- const checkSymbols = this._maskService._checkSymbolMask(inputSymbol, this._maskService.maskExpression[position - 1 - prefixLength] ??
12147
- "" /* MaskExpression.EMPTY_STRING */);
12148
- const checkSpecialCharacter = this._maskService._checkSymbolMask(inputSymbol, this._maskService.maskExpression[position + 1 - prefixLength] ??
12149
- "" /* MaskExpression.EMPTY_STRING */);
12150
- const selectRangeBackspace = this._maskService.selStart === this._maskService.selEnd;
12151
- const selStart = Number(this._maskService.selStart) - prefixLength;
12152
- const selEnd = Number(this._maskService.selEnd) - prefixLength;
12153
- const backspaceOrDelete = this._code() === "Backspace" /* MaskExpression.BACKSPACE */ ||
12154
- this._code() === "Delete" /* MaskExpression.DELETE */;
12155
- if (backspaceOrDelete) {
12156
- if (!selectRangeBackspace) {
12157
- if (this._maskService.selStart === prefixLength) {
12158
- this._maskService.actualValue = `${prefix}${this._maskService.maskIsShown.slice(0, selEnd)}${this._inputValue().split(prefix).join('')}`;
12159
- }
12160
- else if (this._maskService.selStart ===
12161
- this._maskService.maskIsShown.length + prefixLength) {
12162
- this._maskService.actualValue = `${this._inputValue()}${this._maskService.maskIsShown.slice(selStart, selEnd)}`;
12163
- }
12164
- else {
12165
- this._maskService.actualValue = `${prefix}${this._inputValue()
12166
- .split(prefix)
12167
- .join('')
12168
- .slice(0, selStart)}${this._maskService.maskIsShown.slice(selStart, selEnd)}${this._maskService.actualValue.slice(selEnd + prefixLength, this._maskService.maskIsShown.length + prefixLength)}${suffix}`;
12169
- }
12170
- }
12171
- else if (!this._maskService.specialCharacters.includes(this._maskService.maskExpression.slice(position - prefixLength, position + 1 - prefixLength)) &&
12172
- selectRangeBackspace) {
12173
- if (selStart === 1 && prefix) {
12174
- this._maskService.actualValue = `${prefix}${this._maskService.placeHolderCharacter}${el.value
12175
- .split(prefix)
12176
- .join('')
12177
- .split(suffix)
12178
- .join('')}${suffix}`;
12179
- position = position - 1;
12180
- }
12181
- else {
12182
- const part1 = el.value.substring(0, position);
12183
- const part2 = el.value.substring(position);
12184
- this._maskService.actualValue = `${part1}${this._maskService.placeHolderCharacter}${part2}`;
12185
- }
12186
- }
12187
- position = this._code() === "Delete" /* MaskExpression.DELETE */ ? position + 1 : position;
12188
- }
12189
- if (!backspaceOrDelete) {
12190
- if (!checkSymbols && !checkSpecialCharacter && selectRangeBackspace) {
12191
- position = Number(el.selectionStart) - 1;
12192
- }
12193
- else if (this._maskService.specialCharacters.includes(el.value.slice(position, position + 1)) &&
12194
- checkSpecialCharacter &&
12195
- !this._maskService.specialCharacters.includes(el.value.slice(position + 1, position + 2))) {
12196
- this._maskService.actualValue = `${el.value.slice(0, position - 1)}${el.value.slice(position, position + 1)}${inputSymbol}${el.value.slice(position + 2)}`;
12197
- position = position + 1;
12198
- }
12199
- else if (checkSymbols) {
12200
- if (el.value.length === 1 && position === 1) {
12201
- this._maskService.actualValue = `${prefix}${inputSymbol}${this._maskService.maskIsShown.slice(1, this._maskService.maskIsShown.length)}${suffix}`;
12202
- }
12203
- else {
12204
- this._maskService.actualValue = `${el.value.slice(0, position - 1)}${inputSymbol}${el.value
12205
- .slice(position + 1)
12206
- .split(suffix)
12207
- .join('')}${suffix}`;
12208
- }
12209
- }
12210
- else if (prefix &&
12211
- el.value.length === 1 &&
12212
- position - prefixLength === 1 &&
12213
- this._maskService._checkSymbolMask(el.value, this._maskService.maskExpression[position - 1 - prefixLength] ??
12214
- "" /* MaskExpression.EMPTY_STRING */)) {
12215
- this._maskService.actualValue = `${prefix}${el.value}${this._maskService.maskIsShown.slice(1, this._maskService.maskIsShown.length)}${suffix}`;
12216
- }
12217
- }
12218
- }
12219
- let caretShift = 0;
12220
- let backspaceShift = false;
12221
- if (this._code() === "Delete" /* MaskExpression.DELETE */ && "separator" /* MaskExpression.SEPARATOR */) {
12222
- this._maskService.deletedSpecialCharacter = true;
12223
- }
12224
- if (this._inputValue().length >= this._maskService.maskExpression.length - 1 &&
12225
- this._code() !== "Backspace" /* MaskExpression.BACKSPACE */ &&
12226
- this._maskService.maskExpression === "d0/M0/0000" /* MaskExpression.DAYS_MONTHS_YEARS */ &&
12227
- position < 10) {
12228
- const inputSymbol = this._inputValue().slice(position - 1, position);
12229
- el.value =
12230
- this._inputValue().slice(0, position - 1) +
12231
- inputSymbol +
12232
- this._inputValue().slice(position + 1);
12233
- }
12234
- if (this._maskService.maskExpression === "d0/M0/0000" /* MaskExpression.DAYS_MONTHS_YEARS */ &&
12235
- this.leadZeroDateTime()) {
12236
- if ((position < 3 && Number(el.value) > 31 && Number(el.value) < 40) ||
12237
- (position === 5 && Number(el.value.slice(3, 5)) > 12)) {
12238
- position = position + 2;
12239
- }
12240
- }
12241
- if (this._maskService.maskExpression === "Hh:m0:s0" /* MaskExpression.HOURS_MINUTES_SECONDS */ &&
12242
- this.apm()) {
12243
- if (this._justPasted() && el.value.slice(0, 2) === "00" /* MaskExpression.DOUBLE_ZERO */) {
12244
- el.value = el.value.slice(1, 2) + el.value.slice(2, el.value.length);
12245
- }
12246
- el.value =
12247
- el.value === "00" /* MaskExpression.DOUBLE_ZERO */
12248
- ? "0" /* MaskExpression.NUMBER_ZERO */
12249
- : el.value;
12250
- }
12251
- this._maskService.applyValueChanges(position, this._justPasted(), this._code() === "Backspace" /* MaskExpression.BACKSPACE */ ||
12252
- this._code() === "Delete" /* MaskExpression.DELETE */, (shift, _backspaceShift) => {
12253
- this._justPasted.set(false);
12254
- caretShift = shift;
12255
- backspaceShift = _backspaceShift;
12256
- });
12257
- // only set the selection if the element is active
12258
- if (this._getActiveElement() !== el) {
12259
- return;
12260
- }
12261
- if (this._maskService.plusOnePosition) {
12262
- position = position + 1;
12263
- this._maskService.plusOnePosition = false;
12264
- }
12265
- // update position after applyValueChanges to prevent cursor on wrong position when it has an array of maskExpression
12266
- if (this._maskExpressionArray().length) {
12267
- if (this._code() === "Backspace" /* MaskExpression.BACKSPACE */) {
12268
- const specialChartMinusOne = this.specialCharacters().includes(this._maskService.actualValue.slice(position - 1, position));
12269
- const allowFewMaskChangeMask = this._maskService.removeMask(this._inputValue())?.length ===
12270
- this._maskService.removeMask(this._maskService.maskExpression)?.length;
12271
- const specialChartPlusOne = this.specialCharacters().includes(this._maskService.actualValue.slice(position, position + 1));
12272
- if (allowFewMaskChangeMask && !specialChartPlusOne) {
12273
- position = el.selectionStart + 1;
12274
- }
12275
- else {
12276
- position = specialChartMinusOne ? position - 1 : position;
12277
- }
12278
- }
12279
- else {
12280
- position =
12281
- el.selectionStart === 1
12282
- ? el.selectionStart + this._maskService.prefix.length
12283
- : el.selectionStart;
12284
- }
12285
- }
12286
- this._position.set(this._position() === 1 && this._inputValue().length === 1
12287
- ? null
12288
- : this._position());
12289
- let positionToApply = this._position()
12290
- ? this._inputValue().length + position + caretShift
12291
- : position +
12292
- (this._code() === "Backspace" /* MaskExpression.BACKSPACE */ && !backspaceShift
12293
- ? 0
12294
- : caretShift);
12295
- if (positionToApply > this._getActualInputLength()) {
12296
- positionToApply =
12297
- el.value === this._maskService.decimalMarker && el.value.length === 1
12298
- ? this._getActualInputLength() + 1
12299
- : this._getActualInputLength();
12300
- }
12301
- if (positionToApply < 0) {
12302
- positionToApply = 0;
12303
- }
12304
- el.setSelectionRange(positionToApply, positionToApply);
12305
- this._position.set(null);
12306
- }
12307
- else {
12308
- // eslint-disable-next-line no-console
12309
- console.warn('Matcha-mask writeValue work with string | number, your current value:', typeof transformedValue);
12310
- }
12311
- }
12312
- else {
12313
- if (!this._maskValue()) {
12314
- this.onChange(el.value);
12315
- return;
12316
- }
12317
- this._maskService.applyValueChanges(el.value.length, this._justPasted(), this._code() === "Backspace" /* MaskExpression.BACKSPACE */ || this._code() === "Delete" /* MaskExpression.DELETE */);
12318
- }
12319
- }
12320
- // IME starts
12321
- onCompositionStart() {
12322
- this._isComposing.set(true);
12323
- }
12324
- // IME completes
12325
- onCompositionEnd(e) {
12326
- this._isComposing.set(false);
12327
- this._justPasted.set(true);
12328
- this.onInput(e);
12329
- }
12330
- onBlur(e) {
12331
- if (this._maskValue()) {
12332
- const el = e.target;
12333
- if (this._maskService.leadZero &&
12334
- el.value.length > 0 &&
12335
- typeof this._maskService.decimalMarker === 'string') {
12336
- const maskExpression = this._maskService.maskExpression;
12337
- const decimalMarker = this._maskService.decimalMarker;
12338
- const suffix = this._maskService.suffix;
12339
- const precision = Number(this._maskService.maskExpression.slice(maskExpression.length - 1, maskExpression.length));
12340
- if (precision > 0) {
12341
- el.value = suffix ? el.value.split(suffix).join('') : el.value;
12342
- const decimalPart = el.value.split(decimalMarker)[1];
12343
- el.value = el.value.includes(decimalMarker)
12344
- ? el.value +
12345
- "0" /* MaskExpression.NUMBER_ZERO */.repeat(precision - decimalPart.length) +
12346
- suffix
12347
- : el.value +
12348
- decimalMarker +
12349
- "0" /* MaskExpression.NUMBER_ZERO */.repeat(precision) +
12350
- suffix;
12351
- this._maskService.actualValue = el.value;
12352
- }
12353
- }
12354
- this._maskService.clearIfNotMatchFn();
12355
- }
12356
- this._isFocused.set(false);
12357
- this.onTouch();
12358
- }
12359
- onClick(e) {
12360
- if (!this._maskValue()) {
12361
- return;
12362
- }
12363
- const el = e.target;
12364
- const posStart = 0;
12365
- const posEnd = 0;
12366
- if (el !== null &&
12367
- el.selectionStart !== null &&
12368
- el.selectionStart === el.selectionEnd &&
12369
- el.selectionStart > this._maskService.prefix.length &&
12370
- e.keyCode !== 38) {
12371
- if (this._maskService.showMaskTyped && !this.keepCharacterPositions()) {
12372
- // We are showing the mask in the input
12373
- this._maskService.maskIsShown = this._maskService.showMaskInInput();
12374
- if (el.setSelectionRange &&
12375
- this._maskService.prefix + this._maskService.maskIsShown === el.value) {
12376
- // the input ONLY contains the mask, so position the cursor at the start
12377
- el.focus();
12378
- el.setSelectionRange(posStart, posEnd);
12379
- }
12380
- else {
12381
- // the input contains some characters already
12382
- if (el.selectionStart > this._maskService.actualValue.length) {
12383
- // if the user clicked beyond our value's length, position the cursor at the end of our value
12384
- el.setSelectionRange(this._maskService.actualValue.length, this._maskService.actualValue.length);
12385
- }
12386
- }
12387
- }
12388
- }
12389
- const nextValue = el &&
12390
- (el.value === this._maskService.prefix
12391
- ? this._maskService.prefix + this._maskService.maskIsShown
12392
- : el.value);
12393
- /** Fix of cursor position jumping to end in most browsers no matter where cursor is inserted onFocus */
12394
- if (el && el.value !== nextValue) {
12395
- el.value = nextValue;
12396
- }
12397
- /** fix of cursor position with prefix when mouse click occur */
12398
- if (el &&
12399
- el.type !== 'number' &&
12400
- (el.selectionStart || el.selectionEnd) <=
12401
- this._maskService.prefix.length) {
12402
- const specialCharactersAtTheStart = this._maskService.maskExpression.match(new RegExp(`^[${this._maskService.specialCharacters.map((c) => `\\${c}`).join('')}]+`))?.[0].length || 0;
12403
- el.selectionStart = this._maskService.prefix.length + specialCharactersAtTheStart;
12404
- return;
12405
- }
12406
- /** select only inserted text */
12407
- if (el && el.selectionEnd > this._getActualInputLength()) {
12408
- el.selectionEnd = this._getActualInputLength();
12409
- }
12410
- }
12411
- onKeyDown(e) {
12412
- if (!this._maskValue()) {
12413
- return;
12414
- }
12415
- if (this._isComposing()) {
12416
- // User finalize their choice from IME composition, so trigger onInput() for the composed text.
12417
- if (e.key === 'Enter') {
12418
- this.onCompositionEnd(e);
12419
- }
12420
- return;
12421
- }
12422
- this._code.set(e.code ? e.code : e.key);
12423
- const el = e.target;
12424
- this._inputValue.set(el.value);
12425
- this._setMask();
12426
- if (el.type !== 'number') {
12427
- if (e.key === "ArrowUp" /* MaskExpression.ARROW_UP */) {
12428
- e.preventDefault();
12429
- }
12430
- if (e.key === "ArrowLeft" /* MaskExpression.ARROW_LEFT */ ||
12431
- e.key === "Backspace" /* MaskExpression.BACKSPACE */ ||
12432
- e.key === "Delete" /* MaskExpression.DELETE */) {
12433
- if (e.key === "Backspace" /* MaskExpression.BACKSPACE */ && el.value.length === 0) {
12434
- el.selectionStart = el.selectionEnd;
12435
- }
12436
- if (e.key === "Backspace" /* MaskExpression.BACKSPACE */ && el.selectionStart !== 0) {
12437
- const prefixLength = this.prefix().length;
12438
- // If specialChars is false, (shouldn't ever happen) then set to the defaults
12439
- const specialCharacters = this.specialCharacters().length
12440
- ? this.specialCharacters()
12441
- : this._config.specialCharacters;
12442
- if (prefixLength > 1 && el.selectionStart <= prefixLength) {
12443
- el.setSelectionRange(prefixLength, el.selectionEnd);
12444
- }
12445
- else {
12446
- if (this._inputValue().length !== el.selectionStart &&
12447
- el.selectionStart !== 1) {
12448
- while (specialCharacters.includes((this._inputValue()[el.selectionStart - 1] ??
12449
- "" /* MaskExpression.EMPTY_STRING */).toString()) &&
12450
- ((prefixLength >= 1 &&
12451
- el.selectionStart > prefixLength) ||
12452
- prefixLength === 0)) {
12453
- el.setSelectionRange(el.selectionStart - 1, el.selectionEnd);
12454
- }
12455
- }
12456
- }
12457
- }
12458
- this.checkSelectionOnDeletion(el);
12459
- if (this._maskService.prefix.length &&
12460
- el.selectionStart <= this._maskService.prefix.length &&
12461
- el.selectionEnd <= this._maskService.prefix.length) {
12462
- e.preventDefault();
12463
- }
12464
- const cursorStart = el.selectionStart;
12465
- if (e.key === "Backspace" /* MaskExpression.BACKSPACE */ &&
12466
- !el.readOnly &&
12467
- cursorStart === 0 &&
12468
- el.selectionEnd === el.value.length &&
12469
- el.value.length !== 0) {
12470
- this._position.set(this._maskService.prefix ? this._maskService.prefix.length : 0);
12471
- this._maskService.applyMask(this._maskService.prefix, this._maskService.maskExpression, this._position());
12472
- }
12473
- }
12474
- if (!!this.suffix() &&
12475
- this.suffix().length > 1 &&
12476
- this._inputValue().length - this.suffix().length < el.selectionStart) {
12477
- el.setSelectionRange(this._inputValue().length - this.suffix().length, this._inputValue().length);
12478
- }
12479
- else if ((e.code === 'KeyA' && e.ctrlKey) ||
12480
- (e.code === 'KeyA' && e.metaKey) // Cmd + A (Mac)
12481
- ) {
12482
- el.setSelectionRange(0, this._getActualInputLength());
12483
- e.preventDefault();
12484
- }
12485
- this._maskService.selStart = el.selectionStart;
12486
- this._maskService.selEnd = el.selectionEnd;
12487
- }
12488
- }
12489
- /** It writes the value in the input */
12490
- async writeValue(controlValue) {
12491
- let value = controlValue;
12492
- const inputTransformFn = this._maskService.inputTransformFn;
12493
- if (typeof value === 'object' && value !== null && 'value' in value) {
12494
- if ('disable' in value) {
12495
- this.setDisabledState(Boolean(value.disable));
12496
- }
12497
- value = value.value;
12498
- }
12499
- if (value !== null) {
12500
- value = inputTransformFn ? inputTransformFn(value) : value;
12501
- }
12502
- if (typeof value === 'string' ||
12503
- typeof value === 'number' ||
12504
- value === null ||
12505
- typeof value === 'undefined') {
12506
- if (value === null || typeof value === 'undefined' || value === '') {
12507
- this._maskService.currentValue = '';
12508
- this._maskService.previousValue = '';
12509
- }
12510
- let inputValue = value;
12511
- if (typeof inputValue === 'number' ||
12512
- this._maskValue().startsWith("separator" /* MaskExpression.SEPARATOR */)) {
12513
- inputValue = String(inputValue);
12514
- const localeDecimalMarker = this._maskService.currentLocaleDecimalMarker();
12515
- if (!Array.isArray(this._maskService.decimalMarker)) {
12516
- inputValue =
12517
- this._maskService.decimalMarker !== localeDecimalMarker
12518
- ? inputValue.replace(localeDecimalMarker, this._maskService.decimalMarker)
12519
- : inputValue;
12520
- }
12521
- if (this._maskService.leadZero &&
12522
- inputValue &&
12523
- this.mask() &&
12524
- this.dropSpecialCharacters() !== false) {
12525
- inputValue = this._maskService._checkPrecision(this._maskService.maskExpression, inputValue);
12526
- }
12527
- if (this._maskService.decimalMarker === "," /* MaskExpression.COMMA */ ||
12528
- (Array.isArray(this._maskService.decimalMarker) &&
12529
- this._maskService.thousandSeparator === "." /* MaskExpression.DOT */)) {
12530
- inputValue = inputValue
12531
- .toString()
12532
- .replace("." /* MaskExpression.DOT */, "," /* MaskExpression.COMMA */);
12533
- }
12534
- if (this.mask()?.startsWith("separator" /* MaskExpression.SEPARATOR */) && this.leadZero()) {
12535
- requestAnimationFrame(() => {
12536
- this._maskService.applyMask(inputValue?.toString() ?? '', this._maskService.maskExpression);
12537
- });
12538
- }
12539
- this._maskService.isNumberValue = true;
12540
- }
12541
- if (typeof inputValue !== 'string' || value === null || typeof value === 'undefined') {
12542
- inputValue = '';
12543
- }
12544
- this._inputValue.set(inputValue);
12545
- this._setMask();
12546
- if ((inputValue && this._maskService.maskExpression) ||
12547
- (this._maskService.maskExpression &&
12548
- (this._maskService.prefix || this._maskService.showMaskTyped))) {
12549
- // Let the service we know we are writing value so that triggering onChange function won't happen during applyMask
12550
- this._maskService.writingValue = true;
12551
- this._maskService.formElementProperty = [
12552
- 'value',
12553
- this._maskService.applyMask(inputValue, this._maskService.maskExpression),
12554
- ];
12555
- // Let the service know we've finished writing value
12556
- this._maskService.writingValue = false;
12557
- }
12558
- else {
12559
- this._maskService.formElementProperty = ['value', inputValue];
12560
- }
12561
- this._inputValue.set(inputValue);
12562
- }
12563
- else {
12564
- // eslint-disable-next-line no-console
12565
- console.warn('Matcha-mask writeValue work with string | number, your current value:', typeof value);
12566
- }
12567
- }
12568
- registerOnChange(fn) {
12569
- this._maskService.onChange = this.onChange = fn;
12570
- }
12571
- registerOnTouched(fn) {
12572
- this.onTouch = fn;
12573
- }
12574
- _getActiveElement(document = this.document) {
12575
- const shadowRootEl = document?.activeElement?.shadowRoot;
12576
- if (!shadowRootEl?.activeElement) {
12577
- return document.activeElement;
12578
- }
12579
- else {
12580
- return this._getActiveElement(shadowRootEl);
12581
- }
12582
- }
12583
- checkSelectionOnDeletion(el) {
12584
- const prefixLength = this.prefix().length;
12585
- const suffixLength = this.suffix().length;
12586
- const inputValueLength = this._inputValue().length;
12587
- el.selectionStart = Math.min(Math.max(prefixLength, el.selectionStart), inputValueLength - suffixLength);
12588
- el.selectionEnd = Math.min(Math.max(prefixLength, el.selectionEnd), inputValueLength - suffixLength);
12589
- }
12590
- /** It disables the input element */
12591
- setDisabledState(isDisabled) {
12592
- this._maskService.formElementProperty = ['disabled', isDisabled];
12593
- }
12594
- _applyMask() {
12595
- this._maskService.maskExpression = this._maskService._repeatPatternSymbols(this._maskValue() || '');
12596
- this._maskService.formElementProperty = [
12597
- 'value',
12598
- this._maskService.applyMask(this._inputValue(), this._maskService.maskExpression),
12599
- ];
12600
- }
12601
- _validateTime(value) {
12602
- const rowMaskLen = this._maskValue()
12603
- .split("" /* MaskExpression.EMPTY_STRING */)
12604
- .filter((s) => s !== ':').length;
12605
- if (!value) {
12606
- return null; // Don't validate empty values to allow for optional form control
12607
- }
12608
- if ((+(value[value.length - 1] ?? -1) === 0 && value.length < rowMaskLen) ||
12609
- value.length <= rowMaskLen - 2) {
12610
- return this._createValidationError(value);
12611
- }
12612
- return null;
12613
- }
12614
- _getActualInputLength() {
12615
- return (this._maskService.actualValue.length ||
12616
- this._maskService.actualValue.length + this._maskService.prefix.length);
12617
- }
12618
- _createValidationError(actualValue) {
12619
- return {
12620
- mask: {
12621
- requiredMask: this._maskValue(),
12622
- actualValue,
12623
- },
12624
- };
12625
- }
12626
- _setMask() {
12627
- this._maskExpressionArray().some((mask) => {
12628
- const specialChart = mask
12629
- .split("" /* MaskExpression.EMPTY_STRING */)
12630
- .some((char) => this._maskService.specialCharacters.includes(char));
12631
- if ((specialChart &&
12632
- this._inputValue() &&
12633
- this._areAllCharactersInEachStringSame(this._maskExpressionArray())) ||
12634
- mask.includes("{" /* MaskExpression.CURLY_BRACKETS_LEFT */)) {
12635
- const test = this._maskService.removeMask(this._inputValue())?.length <=
12636
- this._maskService.removeMask(mask)?.length;
12637
- if (test) {
12638
- const maskValue = mask.includes("{" /* MaskExpression.CURLY_BRACKETS_LEFT */)
12639
- ? this._maskService._repeatPatternSymbols(mask)
12640
- : mask;
12641
- this._maskValue.set(maskValue);
12642
- this._maskService.maskExpression = maskValue;
12643
- return test;
12644
- }
12645
- else {
12646
- const expression = this._maskExpressionArray()[this._maskExpressionArray().length - 1] ??
12647
- "" /* MaskExpression.EMPTY_STRING */;
12648
- const maskValue = expression.includes("{" /* MaskExpression.CURLY_BRACKETS_LEFT */)
12649
- ? this._maskService._repeatPatternSymbols(expression)
12650
- : expression;
12651
- this._maskValue.set(maskValue);
12652
- this._maskService.maskExpression = maskValue;
12653
- }
12654
- }
12655
- else {
12656
- const cleanMask = this._maskService.removeMask(mask);
12657
- const check = this._maskService
12658
- .removeMask(this._inputValue())
12659
- ?.split("" /* MaskExpression.EMPTY_STRING */)
12660
- .every((character, index) => {
12661
- const indexMask = cleanMask.charAt(index);
12662
- return this._maskService._checkSymbolMask(character, indexMask);
12663
- });
12664
- if (check || this._justPasted()) {
12665
- this._maskValue.set(mask);
12666
- this._maskService.maskExpression = mask;
12667
- return check;
12668
- }
12669
- }
12670
- });
12671
- }
12672
- _areAllCharactersInEachStringSame(array) {
12673
- const specialCharacters = this._maskService.specialCharacters;
12674
- function removeSpecialCharacters(str) {
12675
- const regex = new RegExp(`[${specialCharacters.map((ch) => `\\${ch}`).join('')}]`, 'g');
12676
- return str.replace(regex, '');
12677
- }
12678
- const processedArr = array.map(removeSpecialCharacters);
12679
- return processedArr.every((str) => {
12680
- const uniqueCharacters = new Set(str);
12681
- return uniqueCharacters.size === 1;
12682
- });
12683
- }
12684
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaMaskDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive }); }
12685
- 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: [
12686
- {
12687
- provide: NG_VALUE_ACCESSOR,
12688
- useExisting: forwardRef(() => MatchaMaskDirective),
12689
- multi: true,
12690
- },
12691
- {
12692
- provide: NG_VALIDATORS,
12693
- useExisting: forwardRef(() => MatchaMaskDirective),
12694
- multi: true,
12695
- },
12696
- MatchaMaskService,
12697
- ], exportAs: ["mask", "matchaMask"], usesOnChanges: true, ngImport: i0 }); }
12698
- }
12699
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaMaskDirective, decorators: [{
12700
- type: Directive,
12701
- args: [{
12702
- selector: 'input[mask], textarea[mask]',
12703
- standalone: false,
12704
- providers: [
12705
- {
12706
- provide: NG_VALUE_ACCESSOR,
12707
- useExisting: forwardRef(() => MatchaMaskDirective),
12708
- multi: true,
12709
- },
12710
- {
12711
- provide: NG_VALIDATORS,
12712
- useExisting: forwardRef(() => MatchaMaskDirective),
12713
- multi: true,
12714
- },
12715
- MatchaMaskService,
12716
- ],
12717
- exportAs: 'mask,matchaMask',
12718
- }]
12719
- }], propDecorators: { onPaste: [{
12720
- type: HostListener,
12721
- args: ['paste']
12722
- }], onFocus: [{
12723
- type: HostListener,
12724
- args: ['focus', ['$event']]
12725
- }], onModelChange: [{
12726
- type: HostListener,
12727
- args: ['ngModelChange', ['$event']]
12728
- }], onInput: [{
12729
- type: HostListener,
12730
- args: ['input', ['$event']]
12731
- }], onCompositionStart: [{
12732
- type: HostListener,
12733
- args: ['compositionstart', ['$event']]
12734
- }], onCompositionEnd: [{
12735
- type: HostListener,
12736
- args: ['compositionend', ['$event']]
12737
- }], onBlur: [{
12738
- type: HostListener,
12739
- args: ['blur', ['$event']]
12740
- }], onClick: [{
12741
- type: HostListener,
12742
- args: ['click', ['$event']]
12743
- }], onKeyDown: [{
12744
- type: HostListener,
12745
- args: ['keydown', ['$event']]
12746
- }] } });
12747
-
12748
- class MatchaMaskPipe {
12749
- constructor() {
12750
- this.defaultOptions = inject(MATCHA_MASK_CONFIG);
12751
- this._maskService = inject(MatchaMaskService);
12752
- this._maskExpressionArray = [];
12753
- this.mask = '';
12754
- }
12755
- transform(value, mask, { patterns, ...config } = {}) {
12756
- let processedValue = value;
12757
- const currentConfig = {
12758
- maskExpression: mask,
12759
- ...this.defaultOptions,
12760
- ...config,
12761
- patterns: {
12762
- ...this._maskService.patterns,
12763
- ...patterns,
12764
- },
12765
- };
12766
- Object.entries(currentConfig).forEach(([key, val]) => {
12767
- this._maskService[key] = val;
12768
- });
12769
- if (mask.includes('||')) {
12770
- const maskParts = mask.split('||');
12771
- if (maskParts.length > 1) {
12772
- this._maskExpressionArray = maskParts.sort((a, b) => a.length - b.length);
12773
- this._setMask(`${processedValue}`);
12774
- return this._maskService.applyMask(`${processedValue}`, this.mask);
12775
- }
12776
- else {
12777
- this._maskExpressionArray = [];
12778
- return this._maskService.applyMask(`${processedValue}`, this.mask);
12779
- }
12780
- }
12781
- if (mask.includes("{" /* MaskExpression.CURLY_BRACKETS_LEFT */)) {
12782
- return this._maskService.applyMask(`${processedValue}`, this._maskService._repeatPatternSymbols(mask));
12783
- }
12784
- if (mask.startsWith("separator" /* MaskExpression.SEPARATOR */)) {
12785
- if (config.decimalMarker) {
12786
- this._maskService.decimalMarker = config.decimalMarker;
12787
- }
12788
- if (config.thousandSeparator) {
12789
- this._maskService.thousandSeparator = config.thousandSeparator;
12790
- }
12791
- if (config.leadZero) {
12792
- this._maskService.leadZero = config.leadZero;
12793
- }
12794
- processedValue = String(processedValue);
12795
- const localeDecimalMarker = this._maskService.currentLocaleDecimalMarker();
12796
- if (!Array.isArray(this._maskService.decimalMarker)) {
12797
- processedValue =
12798
- this._maskService.decimalMarker !== localeDecimalMarker
12799
- ? processedValue.replace(localeDecimalMarker, this._maskService.decimalMarker)
12800
- : processedValue;
12801
- }
12802
- if (this._maskService.leadZero &&
12803
- processedValue &&
12804
- this._maskService.dropSpecialCharacters !== false) {
12805
- processedValue = this._maskService._checkPrecision(mask, processedValue);
12806
- }
12807
- if (this._maskService.decimalMarker === "," /* MaskExpression.COMMA */) {
12808
- processedValue = processedValue.replace("." /* MaskExpression.DOT */, "," /* MaskExpression.COMMA */);
12809
- }
12810
- this._maskService.isNumberValue = true;
12811
- }
12812
- if (processedValue === null || typeof processedValue === 'undefined') {
12813
- return this._maskService.applyMask('', mask);
12814
- }
12815
- return this._maskService.applyMask(`${processedValue}`, mask);
12816
- }
12817
- _setMask(value) {
12818
- if (this._maskExpressionArray.length > 0) {
12819
- this._maskExpressionArray.some((mask) => {
12820
- const test = this._maskService.removeMask(value)?.length <=
12821
- this._maskService.removeMask(mask)?.length;
12822
- if (value && test) {
12823
- this.mask = mask;
12824
- return test;
12825
- }
12826
- else {
12827
- this.mask =
12828
- this._maskExpressionArray[this._maskExpressionArray.length - 1] ??
12829
- "" /* MaskExpression.EMPTY_STRING */;
12830
- }
12831
- });
12832
- }
12833
- }
12834
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaMaskPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
12835
- static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.3.0", ngImport: i0, type: MatchaMaskPipe, isStandalone: false, name: "mask" }); }
12836
- }
12837
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaMaskPipe, decorators: [{
12838
- type: Pipe,
12839
- args: [{
12840
- name: 'mask',
12841
- pure: true,
12842
- standalone: false,
12843
- }]
12844
- }] });
12845
-
12846
- const options = {
12847
- specialCharacters: ['/', '(', ')', '.', ':', '-', ' ', '+', ',', '@', '[', ']', '"', "'", '*'],
12848
- patterns: {
12849
- '0': { pattern: /\d/ },
12850
- '9': { pattern: /\d/, optional: true },
12851
- 'A': { pattern: /[a-zA-Z0-9]/ },
12852
- 'S': { pattern: /[a-zA-Z]/ }
12853
- },
12854
- prefix: '',
12855
- suffix: '',
12856
- thousandSeparator: '',
12857
- decimalMarker: '.',
12858
- clearIfNotMatch: false,
12859
- showMaskTyped: false,
12860
- placeHolderCharacter: '_',
12861
- shownMaskExpression: '',
12862
- dropSpecialCharacters: true,
12863
- hiddenInput: false,
12864
- validation: true,
12865
- instantPrefix: false,
12866
- separatorLimit: '',
12867
- apm: false,
12868
- allowNegativeNumbers: false,
12869
- leadZeroDateTime: false,
12870
- leadZero: false,
12871
- triggerOnMaskChange: false,
12872
- keepCharacterPositions: false,
12873
- inputTransformFn: (v) => v,
12874
- outputTransformFn: (v) => v,
12875
- maskFilled: new EventEmitter()
12876
- };
12877
- class MatchaMaskModule {
12878
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaMaskModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
12879
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.0", ngImport: i0, type: MatchaMaskModule, declarations: [MatchaMaskDirective, MatchaMaskPipe], imports: [CommonModule], exports: [MatchaMaskDirective,
12880
- MatchaMaskPipe] }); }
12881
- static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaMaskModule, providers: [
12882
- MatchaMaskService,
12883
- { provide: MATCHA_MASK_CONFIG, useValue: options }
12884
- ], imports: [CommonModule] }); }
12885
- }
12886
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaMaskModule, decorators: [{
12887
- type: NgModule,
12888
- args: [{
12889
- declarations: [MatchaMaskDirective, MatchaMaskPipe],
12890
- imports: [
12891
- CommonModule
12892
- ],
12893
- exports: [
12894
- MatchaMaskDirective,
12895
- MatchaMaskPipe
12896
- ],
12897
- providers: [
12898
- MatchaMaskService,
12899
- { provide: MATCHA_MASK_CONFIG, useValue: options }
12900
- ]
12901
- }]
12902
- }] });
12903
-
12904
11809
  class MatchaComponentsModule {
12905
11810
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaComponentsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
12906
11811
  static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.0", ngImport: i0, type: MatchaComponentsModule, declarations: [MatchaOverflowDraggableComponent], imports: [CommonModule,
@@ -12950,7 +11855,7 @@ class MatchaComponentsModule {
12950
11855
  MatchaPageLayoutModule,
12951
11856
  MatchaDrawerModule,
12952
11857
  MatchaHighlightModule,
12953
- MatchaMaskModule], exports: [MatchaAccordionModule,
11858
+ MatchaMaskCompatibleModule], exports: [MatchaAccordionModule,
12954
11859
  MatchaAutocompleteModule,
12955
11860
  MatchaOptionModule,
12956
11861
  MatchaPanelModule,
@@ -12995,7 +11900,7 @@ class MatchaComponentsModule {
12995
11900
  MatchaAvatarModule,
12996
11901
  MatchaDrawerModule,
12997
11902
  MatchaHighlightModule,
12998
- MatchaMaskModule] }); }
11903
+ MatchaMaskCompatibleModule] }); }
12999
11904
  static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaComponentsModule, imports: [CommonModule,
13000
11905
  FormsModule,
13001
11906
  ReactiveFormsModule,
@@ -13043,7 +11948,7 @@ class MatchaComponentsModule {
13043
11948
  MatchaPageLayoutModule,
13044
11949
  MatchaDrawerModule,
13045
11950
  MatchaHighlightModule,
13046
- MatchaMaskModule, MatchaAccordionModule,
11951
+ MatchaMaskCompatibleModule, MatchaAccordionModule,
13047
11952
  MatchaAutocompleteModule,
13048
11953
  MatchaOptionModule,
13049
11954
  MatchaPanelModule,
@@ -13088,7 +11993,7 @@ class MatchaComponentsModule {
13088
11993
  MatchaAvatarModule,
13089
11994
  MatchaDrawerModule,
13090
11995
  MatchaHighlightModule,
13091
- MatchaMaskModule] }); }
11996
+ MatchaMaskCompatibleModule] }); }
13092
11997
  }
13093
11998
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaComponentsModule, decorators: [{
13094
11999
  type: NgModule,
@@ -13142,7 +12047,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImpor
13142
12047
  MatchaPageLayoutModule,
13143
12048
  MatchaDrawerModule,
13144
12049
  MatchaHighlightModule,
13145
- MatchaMaskModule
12050
+ MatchaMaskCompatibleModule
13146
12051
  ],
13147
12052
  exports: [MatchaAccordionModule,
13148
12053
  MatchaAutocompleteModule,
@@ -13189,53 +12094,1148 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImpor
13189
12094
  MatchaAvatarModule,
13190
12095
  MatchaDrawerModule,
13191
12096
  MatchaHighlightModule,
13192
- MatchaMaskModule
12097
+ MatchaMaskCompatibleModule
12098
+ ],
12099
+ }]
12100
+ }] });
12101
+
12102
+ class MatchaSkeletonModule {
12103
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaSkeletonModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
12104
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.0", ngImport: i0, type: MatchaSkeletonModule, declarations: [MatchaSkeletonComponent], imports: [CommonModule], exports: [MatchaSkeletonComponent] }); }
12105
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaSkeletonModule, imports: [CommonModule] }); }
12106
+ }
12107
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaSkeletonModule, decorators: [{
12108
+ type: NgModule,
12109
+ args: [{
12110
+ declarations: [MatchaSkeletonComponent],
12111
+ imports: [
12112
+ CommonModule
12113
+ ],
12114
+ exports: [MatchaSkeletonComponent],
12115
+ }]
12116
+ }] });
12117
+
12118
+ /**
12119
+ * Módulo para o MatchaBreakpointObserver
12120
+ *
12121
+ * Este módulo fornece o serviço MatchaBreakpointObserver que pode ser usado
12122
+ * em qualquer parte da aplicação para observar breakpoints CSS.
12123
+ *
12124
+ * O serviço é um singleton (providedIn: 'root') e não precisa ser importado
12125
+ * explicitamente, mas este módulo pode ser usado para organização.
12126
+ */
12127
+ class MatchaBreakpointObservableModule {
12128
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaBreakpointObservableModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
12129
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.0", ngImport: i0, type: MatchaBreakpointObservableModule, imports: [CommonModule] }); }
12130
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaBreakpointObservableModule, providers: [
12131
+ // O serviço já é providedIn: 'root', mas incluímos aqui para clareza
12132
+ MatchaBreakpointObserver
12133
+ ], imports: [CommonModule] }); }
12134
+ }
12135
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaBreakpointObservableModule, decorators: [{
12136
+ type: NgModule,
12137
+ args: [{
12138
+ imports: [
12139
+ CommonModule
12140
+ ],
12141
+ providers: [
12142
+ // O serviço já é providedIn: 'root', mas incluímos aqui para clareza
12143
+ MatchaBreakpointObserver
12144
+ ]
12145
+ }]
12146
+ }] });
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,
13193
13055
  ],
13056
+ exportAs: 'mask,matchaMask',
13194
13057
  }]
13195
- }] });
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
+ }] } });
13196
13086
 
13197
- class MatchaSkeletonModule {
13198
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaSkeletonModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
13199
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.0", ngImport: i0, type: MatchaSkeletonModule, declarations: [MatchaSkeletonComponent], imports: [CommonModule], exports: [MatchaSkeletonComponent] }); }
13200
- static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaSkeletonModule, imports: [CommonModule] }); }
13087
+ class MatchaMaskPipe {
13088
+ constructor() {
13089
+ this.defaultOptions = inject(MATCHA_MASK_CONFIG);
13090
+ this._maskService = inject(MatchaMaskService);
13091
+ this._maskExpressionArray = [];
13092
+ this.mask = '';
13093
+ }
13094
+ transform(value, mask, { patterns, ...config } = {}) {
13095
+ let processedValue = value;
13096
+ const currentConfig = {
13097
+ maskExpression: mask,
13098
+ ...this.defaultOptions,
13099
+ ...config,
13100
+ patterns: {
13101
+ ...this._maskService.patterns,
13102
+ ...patterns,
13103
+ },
13104
+ };
13105
+ Object.entries(currentConfig).forEach(([key, val]) => {
13106
+ this._maskService[key] = val;
13107
+ });
13108
+ if (mask.includes('||')) {
13109
+ const maskParts = mask.split('||');
13110
+ if (maskParts.length > 1) {
13111
+ this._maskExpressionArray = maskParts.sort((a, b) => a.length - b.length);
13112
+ this._setMask(`${processedValue}`);
13113
+ return this._maskService.applyMask(`${processedValue}`, this.mask);
13114
+ }
13115
+ else {
13116
+ this._maskExpressionArray = [];
13117
+ return this._maskService.applyMask(`${processedValue}`, this.mask);
13118
+ }
13119
+ }
13120
+ if (mask.includes("{" /* MaskExpression.CURLY_BRACKETS_LEFT */)) {
13121
+ return this._maskService.applyMask(`${processedValue}`, this._maskService._repeatPatternSymbols(mask));
13122
+ }
13123
+ if (mask.startsWith("separator" /* MaskExpression.SEPARATOR */)) {
13124
+ if (config.decimalMarker) {
13125
+ this._maskService.decimalMarker = config.decimalMarker;
13126
+ }
13127
+ if (config.thousandSeparator) {
13128
+ this._maskService.thousandSeparator = config.thousandSeparator;
13129
+ }
13130
+ if (config.leadZero) {
13131
+ this._maskService.leadZero = config.leadZero;
13132
+ }
13133
+ processedValue = String(processedValue);
13134
+ const localeDecimalMarker = this._maskService.currentLocaleDecimalMarker();
13135
+ if (!Array.isArray(this._maskService.decimalMarker)) {
13136
+ processedValue =
13137
+ this._maskService.decimalMarker !== localeDecimalMarker
13138
+ ? processedValue.replace(localeDecimalMarker, this._maskService.decimalMarker)
13139
+ : processedValue;
13140
+ }
13141
+ if (this._maskService.leadZero &&
13142
+ processedValue &&
13143
+ this._maskService.dropSpecialCharacters !== false) {
13144
+ processedValue = this._maskService._checkPrecision(mask, processedValue);
13145
+ }
13146
+ if (this._maskService.decimalMarker === "," /* MaskExpression.COMMA */) {
13147
+ processedValue = processedValue.replace("." /* MaskExpression.DOT */, "," /* MaskExpression.COMMA */);
13148
+ }
13149
+ this._maskService.isNumberValue = true;
13150
+ }
13151
+ if (processedValue === null || typeof processedValue === 'undefined') {
13152
+ return this._maskService.applyMask('', mask);
13153
+ }
13154
+ return this._maskService.applyMask(`${processedValue}`, mask);
13155
+ }
13156
+ _setMask(value) {
13157
+ if (this._maskExpressionArray.length > 0) {
13158
+ this._maskExpressionArray.some((mask) => {
13159
+ const test = this._maskService.removeMask(value)?.length <=
13160
+ this._maskService.removeMask(mask)?.length;
13161
+ if (value && test) {
13162
+ this.mask = mask;
13163
+ return test;
13164
+ }
13165
+ else {
13166
+ this.mask =
13167
+ this._maskExpressionArray[this._maskExpressionArray.length - 1] ??
13168
+ "" /* MaskExpression.EMPTY_STRING */;
13169
+ }
13170
+ });
13171
+ }
13172
+ }
13173
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaMaskPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
13174
+ static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.3.0", ngImport: i0, type: MatchaMaskPipe, isStandalone: false, name: "mask" }); }
13201
13175
  }
13202
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaSkeletonModule, decorators: [{
13203
- type: NgModule,
13176
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaMaskPipe, decorators: [{
13177
+ type: Pipe,
13204
13178
  args: [{
13205
- declarations: [MatchaSkeletonComponent],
13206
- imports: [
13207
- CommonModule
13208
- ],
13209
- exports: [MatchaSkeletonComponent],
13179
+ name: 'mask',
13180
+ pure: true,
13181
+ standalone: false,
13210
13182
  }]
13211
13183
  }] });
13212
13184
 
13213
- /**
13214
- * Módulo para o MatchaBreakpointObserver
13215
- *
13216
- * Este módulo fornece o serviço MatchaBreakpointObserver que pode ser usado
13217
- * em qualquer parte da aplicação para observar breakpoints CSS.
13218
- *
13219
- * O serviço é um singleton (providedIn: 'root') e não precisa ser importado
13220
- * explicitamente, mas este módulo pode ser usado para organização.
13221
- */
13222
- class MatchaBreakpointObservableModule {
13223
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaBreakpointObservableModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
13224
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.0", ngImport: i0, type: MatchaBreakpointObservableModule, imports: [CommonModule] }); }
13225
- static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaBreakpointObservableModule, providers: [
13226
- // O serviço já é providedIn: 'root', mas incluímos aqui para clareza
13227
- MatchaBreakpointObserver
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 }
13228
13223
  ], imports: [CommonModule] }); }
13229
13224
  }
13230
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaBreakpointObservableModule, decorators: [{
13225
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImport: i0, type: MatchaMaskModule, decorators: [{
13231
13226
  type: NgModule,
13232
13227
  args: [{
13228
+ declarations: [MatchaMaskDirective, MatchaMaskPipe],
13233
13229
  imports: [
13234
13230
  CommonModule
13235
13231
  ],
13232
+ exports: [
13233
+ MatchaMaskDirective,
13234
+ MatchaMaskPipe
13235
+ ],
13236
13236
  providers: [
13237
- // O serviço já é providedIn: 'root', mas incluímos aqui para clareza
13238
- MatchaBreakpointObserver
13237
+ MatchaMaskService,
13238
+ { provide: MATCHA_MASK_CONFIG, useValue: options }
13239
13239
  ]
13240
13240
  }]
13241
13241
  }] });