matcha-components 20.94.0 → 20.96.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.
|
@@ -6215,6 +6215,11 @@ class MatchaMaskService extends MatchaMaskApplierService {
|
|
|
6215
6215
|
: (v) => v;
|
|
6216
6216
|
this.writingValue = false;
|
|
6217
6217
|
this.maskChanged = false;
|
|
6218
|
+
// Para máscaras de separador, garantir que isNumberValue é true
|
|
6219
|
+
// Isso assegura a conversão correta para número
|
|
6220
|
+
if (this.maskExpression.startsWith("separator" /* MaskExpression.SEPARATOR */)) {
|
|
6221
|
+
this.isNumberValue = true;
|
|
6222
|
+
}
|
|
6218
6223
|
if (Array.isArray(this.dropSpecialCharacters)) {
|
|
6219
6224
|
this.onChange(outputTransformFn(this._toNumber(this._checkSymbols(this._removeMask(this._removeSuffix(this._removePrefix(inputValue)), this.dropSpecialCharacters)))));
|
|
6220
6225
|
}
|
|
@@ -6270,13 +6275,17 @@ class MatchaMaskService extends MatchaMaskApplierService {
|
|
|
6270
6275
|
? this.specialCharacters.filter((v) => {
|
|
6271
6276
|
return this.dropSpecialCharacters.includes(v);
|
|
6272
6277
|
})
|
|
6273
|
-
: this.specialCharacters;
|
|
6278
|
+
: [...this.specialCharacters]; // Criar cópia para não modificar o original
|
|
6274
6279
|
if (!this.deletedSpecialCharacter &&
|
|
6275
6280
|
this._checkPatternForSpace() &&
|
|
6276
6281
|
result.includes(" " /* MaskExpression.WHITE_SPACE */) &&
|
|
6277
6282
|
this.maskExpression.includes("*" /* MaskExpression.SYMBOL_STAR */)) {
|
|
6278
6283
|
specialCharacters = specialCharacters.filter((char) => char !== " " /* MaskExpression.WHITE_SPACE */);
|
|
6279
6284
|
}
|
|
6285
|
+
// Para máscaras de separador, NÃO remover o decimalMarker - ele será convertido para ponto depois
|
|
6286
|
+
if (this.maskExpression.startsWith("separator" /* MaskExpression.SEPARATOR */)) {
|
|
6287
|
+
specialCharacters = specialCharacters.filter((char) => !this._compareOrIncludes(char, this.decimalMarker, null));
|
|
6288
|
+
}
|
|
6280
6289
|
return this._removeMask(result, specialCharacters);
|
|
6281
6290
|
}
|
|
6282
6291
|
_regExpForRemove(specialCharactersForRemove) {
|
|
@@ -6692,28 +6701,22 @@ class MatchaMaskCompatibleDirective {
|
|
|
6692
6701
|
// Implementar lógica de foco se necessário
|
|
6693
6702
|
}
|
|
6694
6703
|
onModelChange(value) {
|
|
6704
|
+
// Ignorar se estamos no meio de uma operação de escrita
|
|
6695
6705
|
if (this._maskService.writingValue) {
|
|
6696
6706
|
return;
|
|
6697
6707
|
}
|
|
6698
|
-
//
|
|
6699
|
-
|
|
6700
|
-
|
|
6701
|
-
|
|
6702
|
-
if (this._mask && this._mask.trim() !== '') {
|
|
6703
|
-
const maskedValue = this._maskService.applyMask(stringValue, this._mask);
|
|
6704
|
-
if (maskedValue !== stringValue) {
|
|
6705
|
-
this._maskService.writingValue = true;
|
|
6706
|
-
this._maskService.onChange(maskedValue);
|
|
6707
|
-
// Usar setTimeout para garantir que writingValue permaneça true durante o ciclo
|
|
6708
|
-
setTimeout(() => {
|
|
6709
|
-
this._maskService.writingValue = false;
|
|
6710
|
-
}, 0);
|
|
6711
|
-
}
|
|
6712
|
-
else {
|
|
6713
|
-
this._maskService.onChange(stringValue);
|
|
6714
|
-
}
|
|
6708
|
+
// Se o valor é um número, significa que veio do formControlResult (já processado)
|
|
6709
|
+
// Não precisamos reprocessar para evitar loop infinito
|
|
6710
|
+
if (typeof value === 'number') {
|
|
6711
|
+
return;
|
|
6715
6712
|
}
|
|
6716
|
-
|
|
6713
|
+
// Converter para string
|
|
6714
|
+
const stringValue = value || '';
|
|
6715
|
+
this._inputValue = stringValue;
|
|
6716
|
+
// Para máscaras, não chamar applyMask aqui pois isso criaria um loop
|
|
6717
|
+
// O onInput já cuida de aplicar a máscara durante a digitação
|
|
6718
|
+
// O writeValue cuida de formatar valores vindos do backend
|
|
6719
|
+
if (!this._mask || this._mask.trim() === '') {
|
|
6717
6720
|
this._maskService.onChange(stringValue);
|
|
6718
6721
|
}
|
|
6719
6722
|
}
|
|
@@ -6728,8 +6731,9 @@ class MatchaMaskCompatibleDirective {
|
|
|
6728
6731
|
const maskedValue = this._maskService.applyMask(value, this._mask);
|
|
6729
6732
|
if (maskedValue !== value) {
|
|
6730
6733
|
target.value = maskedValue;
|
|
6731
|
-
this._maskService.onChange(maskedValue);
|
|
6732
6734
|
}
|
|
6735
|
+
// NÃO chamar onChange aqui - o formControlResult no applyMask já cuida disso
|
|
6736
|
+
// com o valor limpo (sem prefixo, sem separadores, convertido para número)
|
|
6733
6737
|
}
|
|
6734
6738
|
else {
|
|
6735
6739
|
this._maskService.onChange(value);
|
|
@@ -6783,37 +6787,14 @@ class MatchaMaskCompatibleDirective {
|
|
|
6783
6787
|
}
|
|
6784
6788
|
this._inputValue = inputValue;
|
|
6785
6789
|
// Aplicar máscara se definida
|
|
6790
|
+
// O applyMask formata o valor para exibição E chama formControlResult
|
|
6791
|
+
// que envia o valor limpo (número) para o FormControl via onChange
|
|
6786
6792
|
if (this._mask && this._mask.trim() !== '') {
|
|
6787
|
-
|
|
6788
|
-
//
|
|
6789
|
-
// Isso previne loops quando o valor já está correto
|
|
6790
|
-
const currentValue = this._maskService.currentValue || '';
|
|
6791
|
-
if (maskedValue !== currentValue) {
|
|
6792
|
-
// Usar setTimeout para garantir que writingValue permaneça true durante o ciclo
|
|
6793
|
-
// Isso previne que onModelChange processe durante writeValue
|
|
6794
|
-
setTimeout(() => {
|
|
6795
|
-
this._maskService.onChange(maskedValue);
|
|
6796
|
-
this._maskService.writingValue = false;
|
|
6797
|
-
}, 0);
|
|
6798
|
-
}
|
|
6799
|
-
else {
|
|
6800
|
-
// Se o valor já está correto, não precisa atualizar
|
|
6801
|
-
this._maskService.writingValue = false;
|
|
6802
|
-
}
|
|
6803
|
-
}
|
|
6804
|
-
else {
|
|
6805
|
-
// Sem máscara, apenas atualizar o valor
|
|
6806
|
-
const currentValue = this._maskService.currentValue || '';
|
|
6807
|
-
if (inputValue !== currentValue) {
|
|
6808
|
-
setTimeout(() => {
|
|
6809
|
-
this._maskService.onChange(inputValue);
|
|
6810
|
-
this._maskService.writingValue = false;
|
|
6811
|
-
}, 0);
|
|
6812
|
-
}
|
|
6813
|
-
else {
|
|
6814
|
-
this._maskService.writingValue = false;
|
|
6815
|
-
}
|
|
6793
|
+
this._maskService.applyMask(inputValue, this._mask);
|
|
6794
|
+
// NÃO chamar onChange aqui - formControlResult já fez isso com o valor limpo
|
|
6816
6795
|
}
|
|
6796
|
+
// Sem máscara, não precisa fazer nada - o valor já está no FormControl
|
|
6797
|
+
this._maskService.writingValue = false;
|
|
6817
6798
|
}
|
|
6818
6799
|
registerOnChange(fn) {
|
|
6819
6800
|
this.onChange = fn;
|