matcha-components 20.109.0 → 20.111.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.
|
@@ -5116,12 +5116,28 @@ class MatchaMaskApplierService {
|
|
|
5116
5116
|
}
|
|
5117
5117
|
}
|
|
5118
5118
|
// Modo moeda: dígitos entram pela direita (ex: 1 → 0,01, 12 → 0,12, 123 → 1,23)
|
|
5119
|
-
// IMPORTANTE:
|
|
5120
|
-
// Se
|
|
5121
|
-
|
|
5122
|
-
|
|
5123
|
-
|
|
5124
|
-
|
|
5119
|
+
// IMPORTANTE: Detectar se devemos aplicar currencyMode
|
|
5120
|
+
// - Se não tem vírgula: aplicar (digitação começando)
|
|
5121
|
+
// - Se tem vírgula mas a parte decimal tem precisão diferente: aplicar (digitação em andamento)
|
|
5122
|
+
// - Se tem vírgula e parte decimal com precisão correta E poucos dígitos totais: NÃO aplicar (veio do backend)
|
|
5123
|
+
const actualDecimalMarker = typeof decimalMarker === 'string' ? decimalMarker : ',';
|
|
5124
|
+
const hasDecimalMarker = processedValue.includes(actualDecimalMarker);
|
|
5125
|
+
let shouldApplyCurrencyMode = false;
|
|
5126
|
+
if (this.currencyMode && precision > 0) {
|
|
5127
|
+
if (!hasDecimalMarker) {
|
|
5128
|
+
// Sem vírgula: aplicar currencyMode (digitação começando)
|
|
5129
|
+
shouldApplyCurrencyMode = true;
|
|
5130
|
+
}
|
|
5131
|
+
else {
|
|
5132
|
+
// Com vírgula: verificar se é digitação em andamento ou valor do backend
|
|
5133
|
+
const parts = processedValue.split(actualDecimalMarker);
|
|
5134
|
+
const decimalPart = parts[1] || '';
|
|
5135
|
+
// Se a parte decimal tem mais dígitos que a precisão, é digitação em andamento
|
|
5136
|
+
// Se tem menos, veio do backend (ex: "10,5" com precisão 2)
|
|
5137
|
+
shouldApplyCurrencyMode = decimalPart.length > precision;
|
|
5138
|
+
}
|
|
5139
|
+
}
|
|
5140
|
+
if (shouldApplyCurrencyMode) {
|
|
5125
5141
|
// Extrair apenas dígitos e sinal negativo
|
|
5126
5142
|
const hasMinus = processedValue.startsWith("-" /* MaskExpression.MINUS */) ||
|
|
5127
5143
|
(this.allowNegativeNumbers && processedValue.includes("-" /* MaskExpression.MINUS */));
|
|
@@ -5712,7 +5728,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImpor
|
|
|
5712
5728
|
type: Injectable
|
|
5713
5729
|
}] });
|
|
5714
5730
|
|
|
5715
|
-
console.log('🎯 MATCHA-MASK VERSION:
|
|
5731
|
+
// console.log('🎯 MATCHA-MASK VERSION: v105 - CURRENCYMODE SMART DETECTION v2 - ' + new Date().toISOString());
|
|
5716
5732
|
class MatchaMaskService extends MatchaMaskApplierService {
|
|
5717
5733
|
constructor() {
|
|
5718
5734
|
super(...arguments);
|
|
@@ -6816,10 +6832,8 @@ class MatchaMaskCompatibleDirective {
|
|
|
6816
6832
|
// Implementar lógica de teclado se necessário
|
|
6817
6833
|
}
|
|
6818
6834
|
writeValue(value) {
|
|
6819
|
-
console.log('🔵 writeValue chamado - valor:', value, 'tipo:', typeof value);
|
|
6820
6835
|
// Se já estamos escrevendo, não processar novamente (prevenir loop infinito)
|
|
6821
6836
|
if (this._maskService.writingValue) {
|
|
6822
|
-
console.log('⚠️ writeValue ABORTADO - writingValue já é true');
|
|
6823
6837
|
return;
|
|
6824
6838
|
}
|
|
6825
6839
|
this._maskService.writingValue = true;
|
|
@@ -6831,7 +6845,6 @@ class MatchaMaskCompatibleDirective {
|
|
|
6831
6845
|
}
|
|
6832
6846
|
else if (typeof value === 'number') {
|
|
6833
6847
|
inputValue = value.toString();
|
|
6834
|
-
console.log('🔢 Número convertido para string:', inputValue);
|
|
6835
6848
|
}
|
|
6836
6849
|
else {
|
|
6837
6850
|
inputValue = String(value);
|
|
@@ -6845,26 +6858,18 @@ class MatchaMaskCompatibleDirective {
|
|
|
6845
6858
|
if (actualDecimalMarker === ',') {
|
|
6846
6859
|
// Converter ponto para vírgula para que applyMask processe corretamente
|
|
6847
6860
|
inputValue = inputValue.replace('.', ',');
|
|
6848
|
-
console.log('🔄 Converteu ponto para vírgula:', inputValue);
|
|
6849
6861
|
}
|
|
6850
6862
|
}
|
|
6851
6863
|
this._inputValue = inputValue;
|
|
6852
6864
|
// Aplicar máscara se definida
|
|
6853
6865
|
if (this._mask && this._mask.trim() !== '') {
|
|
6854
|
-
console.log('📝 Chamando applyMask com:', inputValue);
|
|
6855
6866
|
const maskedValue = this._maskService.applyMask(inputValue, this._mask);
|
|
6856
|
-
console.log('📝 applyMask retornou:', maskedValue);
|
|
6857
6867
|
// Atualizar o valor do elemento HTML diretamente usando ElementRef
|
|
6858
6868
|
if (this.elementRef && this.elementRef.nativeElement) {
|
|
6859
6869
|
this.elementRef.nativeElement.value = maskedValue;
|
|
6860
|
-
console.log('✅ Elemento HTML atualizado com:', maskedValue);
|
|
6861
|
-
}
|
|
6862
|
-
else {
|
|
6863
|
-
console.log('⚠️ ElementRef não disponível');
|
|
6864
6870
|
}
|
|
6865
6871
|
}
|
|
6866
6872
|
this._maskService.writingValue = false;
|
|
6867
|
-
console.log('✅ writeValue CONCLUÍDO');
|
|
6868
6873
|
}
|
|
6869
6874
|
registerOnChange(fn) {
|
|
6870
6875
|
this.onChange = fn;
|