matcha-components 20.93.0 → 20.95.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.
|
@@ -5941,8 +5941,9 @@ class MatchaMaskService extends MatchaMaskApplierService {
|
|
|
5941
5941
|
(this.previousValue === this.currentValue && justPasted);
|
|
5942
5942
|
}
|
|
5943
5943
|
// Propagate the input value back to the Angular model
|
|
5944
|
+
// Sempre emitir quando currencyMode está ativo para garantir que o valor limpo seja enviado
|
|
5944
5945
|
// eslint-disable-next-line no-unused-expressions,@typescript-eslint/no-unused-expressions
|
|
5945
|
-
this._emitValue ? this.formControlResult(result) : '';
|
|
5946
|
+
(this._emitValue || this.currencyMode) ? this.formControlResult(result) : '';
|
|
5946
5947
|
// Handle hidden input and showMaskTyped
|
|
5947
5948
|
if (!this.showMaskTyped || (this.showMaskTyped && this.hiddenInput)) {
|
|
5948
5949
|
if (this.hiddenInput) {
|
|
@@ -6215,15 +6216,47 @@ class MatchaMaskService extends MatchaMaskApplierService {
|
|
|
6215
6216
|
: (v) => v;
|
|
6216
6217
|
this.writingValue = false;
|
|
6217
6218
|
this.maskChanged = false;
|
|
6219
|
+
// DEBUG: Log para verificar o fluxo de processamento
|
|
6220
|
+
console.log('=== formControlResult DEBUG ===');
|
|
6221
|
+
console.log('inputValue:', inputValue);
|
|
6222
|
+
console.log('dropSpecialCharacters:', this.dropSpecialCharacters);
|
|
6223
|
+
console.log('prefix:', this.prefix);
|
|
6224
|
+
console.log('isNumberValue:', this.isNumberValue);
|
|
6218
6225
|
if (Array.isArray(this.dropSpecialCharacters)) {
|
|
6219
|
-
this.
|
|
6226
|
+
const afterRemovePrefix = this._removePrefix(inputValue);
|
|
6227
|
+
const afterRemoveSuffix = this._removeSuffix(afterRemovePrefix);
|
|
6228
|
+
const afterRemoveMask = this._removeMask(afterRemoveSuffix, this.dropSpecialCharacters);
|
|
6229
|
+
const afterCheckSymbols = this._checkSymbols(afterRemoveMask);
|
|
6230
|
+
const afterToNumber = this._toNumber(afterCheckSymbols);
|
|
6231
|
+
const finalValue = outputTransformFn(afterToNumber);
|
|
6232
|
+
console.log('Array path - afterRemovePrefix:', afterRemovePrefix);
|
|
6233
|
+
console.log('Array path - afterRemoveSuffix:', afterRemoveSuffix);
|
|
6234
|
+
console.log('Array path - afterRemoveMask:', afterRemoveMask);
|
|
6235
|
+
console.log('Array path - afterCheckSymbols:', afterCheckSymbols);
|
|
6236
|
+
console.log('Array path - afterToNumber:', afterToNumber);
|
|
6237
|
+
console.log('Array path - finalValue:', finalValue);
|
|
6238
|
+
this.onChange(finalValue);
|
|
6220
6239
|
}
|
|
6221
6240
|
else if (this.dropSpecialCharacters ||
|
|
6222
6241
|
(!this.dropSpecialCharacters && this.prefix === inputValue)) {
|
|
6223
|
-
this.
|
|
6242
|
+
const afterRemovePrefix = this._removePrefix(inputValue);
|
|
6243
|
+
const afterRemoveSuffix = this._removeSuffix(afterRemovePrefix);
|
|
6244
|
+
const afterCheckSymbols = this._checkSymbols(afterRemoveSuffix);
|
|
6245
|
+
const afterToNumber = this._toNumber(afterCheckSymbols);
|
|
6246
|
+
const finalValue = outputTransformFn(afterToNumber);
|
|
6247
|
+
console.log('Boolean path - afterRemovePrefix:', afterRemovePrefix);
|
|
6248
|
+
console.log('Boolean path - afterRemoveSuffix:', afterRemoveSuffix);
|
|
6249
|
+
console.log('Boolean path - afterCheckSymbols:', afterCheckSymbols);
|
|
6250
|
+
console.log('Boolean path - afterToNumber:', afterToNumber);
|
|
6251
|
+
console.log('Boolean path - finalValue:', finalValue, 'type:', typeof finalValue);
|
|
6252
|
+
this.onChange(finalValue);
|
|
6224
6253
|
}
|
|
6225
6254
|
else {
|
|
6226
|
-
this.
|
|
6255
|
+
const afterToNumber = this._toNumber(inputValue);
|
|
6256
|
+
const finalValue = outputTransformFn(afterToNumber);
|
|
6257
|
+
console.log('Else path - afterToNumber:', afterToNumber);
|
|
6258
|
+
console.log('Else path - finalValue:', finalValue);
|
|
6259
|
+
this.onChange(finalValue);
|
|
6227
6260
|
}
|
|
6228
6261
|
}
|
|
6229
6262
|
_toNumber(value) {
|
|
@@ -6699,19 +6732,14 @@ class MatchaMaskCompatibleDirective {
|
|
|
6699
6732
|
const stringValue = typeof value === 'number' ? value.toString() : (value || '');
|
|
6700
6733
|
this._inputValue = stringValue;
|
|
6701
6734
|
// Aplicar máscara se definida
|
|
6735
|
+
// O applyMask internamente chama formControlResult que já cuida de:
|
|
6736
|
+
// 1. Remover prefixo/sufixo
|
|
6737
|
+
// 2. Remover separadores especiais
|
|
6738
|
+
// 3. Converter para número
|
|
6739
|
+
// 4. Chamar onChange com o valor limpo
|
|
6702
6740
|
if (this._mask && this._mask.trim() !== '') {
|
|
6703
|
-
|
|
6704
|
-
|
|
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
|
-
}
|
|
6741
|
+
this._maskService.applyMask(stringValue, this._mask);
|
|
6742
|
+
// NÃO chamar onChange aqui - formControlResult já fez isso com o valor limpo
|
|
6715
6743
|
}
|
|
6716
6744
|
else {
|
|
6717
6745
|
this._maskService.onChange(stringValue);
|
|
@@ -6728,8 +6756,9 @@ class MatchaMaskCompatibleDirective {
|
|
|
6728
6756
|
const maskedValue = this._maskService.applyMask(value, this._mask);
|
|
6729
6757
|
if (maskedValue !== value) {
|
|
6730
6758
|
target.value = maskedValue;
|
|
6731
|
-
this._maskService.onChange(maskedValue);
|
|
6732
6759
|
}
|
|
6760
|
+
// NÃO chamar onChange aqui - o formControlResult no applyMask já cuida disso
|
|
6761
|
+
// com o valor limpo (sem prefixo, sem separadores, convertido para número)
|
|
6733
6762
|
}
|
|
6734
6763
|
else {
|
|
6735
6764
|
this._maskService.onChange(value);
|
|
@@ -6783,37 +6812,14 @@ class MatchaMaskCompatibleDirective {
|
|
|
6783
6812
|
}
|
|
6784
6813
|
this._inputValue = inputValue;
|
|
6785
6814
|
// Aplicar máscara se definida
|
|
6815
|
+
// O applyMask formata o valor para exibição E chama formControlResult
|
|
6816
|
+
// que envia o valor limpo (número) para o FormControl via onChange
|
|
6786
6817
|
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
|
-
}
|
|
6818
|
+
this._maskService.applyMask(inputValue, this._mask);
|
|
6819
|
+
// NÃO chamar onChange aqui - formControlResult já fez isso com o valor limpo
|
|
6816
6820
|
}
|
|
6821
|
+
// Sem máscara, não precisa fazer nada - o valor já está no FormControl
|
|
6822
|
+
this._maskService.writingValue = false;
|
|
6817
6823
|
}
|
|
6818
6824
|
registerOnChange(fn) {
|
|
6819
6825
|
this.onChange = fn;
|