matcha-components 20.106.0 → 20.108.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.
|
@@ -5707,6 +5707,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImpor
|
|
|
5707
5707
|
type: Injectable
|
|
5708
5708
|
}] });
|
|
5709
5709
|
|
|
5710
|
+
console.log('🎯 MATCHA-MASK VERSION: v102 - ELEMENTREF FIX - ' + new Date().toISOString());
|
|
5710
5711
|
class MatchaMaskService extends MatchaMaskApplierService {
|
|
5711
5712
|
constructor() {
|
|
5712
5713
|
super(...arguments);
|
|
@@ -6484,6 +6485,7 @@ class MatchaMaskCompatibleDirective {
|
|
|
6484
6485
|
this._isComposing = false;
|
|
6485
6486
|
this._maskService = inject(MatchaMaskService, { self: true });
|
|
6486
6487
|
this.document = inject(DOCUMENT);
|
|
6488
|
+
this.elementRef = inject(ElementRef);
|
|
6487
6489
|
this._config = inject(MATCHA_MASK_CONFIG);
|
|
6488
6490
|
// eslint-disable-next-line @typescript-eslint/no-empty-function
|
|
6489
6491
|
this.onChange = (_) => { };
|
|
@@ -6809,8 +6811,10 @@ class MatchaMaskCompatibleDirective {
|
|
|
6809
6811
|
// Implementar lógica de teclado se necessário
|
|
6810
6812
|
}
|
|
6811
6813
|
writeValue(value) {
|
|
6814
|
+
console.log('🔵 writeValue chamado - valor:', value, 'tipo:', typeof value);
|
|
6812
6815
|
// Se já estamos escrevendo, não processar novamente (prevenir loop infinito)
|
|
6813
6816
|
if (this._maskService.writingValue) {
|
|
6817
|
+
console.log('⚠️ writeValue ABORTADO - writingValue já é true');
|
|
6814
6818
|
return;
|
|
6815
6819
|
}
|
|
6816
6820
|
this._maskService.writingValue = true;
|
|
@@ -6822,71 +6826,40 @@ class MatchaMaskCompatibleDirective {
|
|
|
6822
6826
|
}
|
|
6823
6827
|
else if (typeof value === 'number') {
|
|
6824
6828
|
inputValue = value.toString();
|
|
6829
|
+
console.log('🔢 Número convertido para string:', inputValue);
|
|
6825
6830
|
}
|
|
6826
6831
|
else {
|
|
6827
6832
|
inputValue = String(value);
|
|
6828
6833
|
}
|
|
6829
|
-
// Para máscaras de separador
|
|
6830
|
-
//
|
|
6831
|
-
if (this._mask && this._mask.trim().startsWith('separator.')) {
|
|
6832
|
-
const precision = this._maskService.getPrecision(this._mask);
|
|
6834
|
+
// Para máscaras de separador, converter ponto para vírgula antes de processar
|
|
6835
|
+
// Isso permite que valores do backend (ex: 10.5) sejam formatados corretamente
|
|
6836
|
+
if (this._mask && this._mask.trim().startsWith('separator.') && inputValue.includes('.')) {
|
|
6833
6837
|
const decimalMarker = this._maskService.decimalMarker;
|
|
6834
6838
|
const actualDecimalMarker = decimalMarker === ',' ||
|
|
6835
6839
|
(Array.isArray(decimalMarker) && decimalMarker.includes(',')) ? ',' : '.';
|
|
6836
|
-
|
|
6837
|
-
|
|
6838
|
-
|
|
6839
|
-
|
|
6840
|
-
const integerPart = parts[0] || '0';
|
|
6841
|
-
let decimalPart = parts[1] || '';
|
|
6842
|
-
// Ajustar casas decimais conforme precisão
|
|
6843
|
-
if (precision > 0) {
|
|
6844
|
-
decimalPart = decimalPart.padEnd(precision, '0').substring(0, precision);
|
|
6845
|
-
}
|
|
6846
|
-
// Aplicar separador de milhares na parte inteira
|
|
6847
|
-
let formattedInteger = integerPart;
|
|
6848
|
-
const rgx = /(\d+)(\d{3})/;
|
|
6849
|
-
while (this._maskService.thousandSeparator && rgx.test(formattedInteger)) {
|
|
6850
|
-
formattedInteger = formattedInteger.replace(rgx, '$1' + this._maskService.thousandSeparator + '$2');
|
|
6851
|
-
}
|
|
6852
|
-
// Montar valor formatado
|
|
6853
|
-
inputValue = precision > 0
|
|
6854
|
-
? formattedInteger + actualDecimalMarker + decimalPart
|
|
6855
|
-
: formattedInteger;
|
|
6856
|
-
}
|
|
6857
|
-
else if (!inputValue.includes(actualDecimalMarker) && precision > 0) {
|
|
6858
|
-
// Valor sem casas decimais (ex: "10"), adicionar zeros
|
|
6859
|
-
let formattedInteger = inputValue;
|
|
6860
|
-
const rgx = /(\d+)(\d{3})/;
|
|
6861
|
-
while (this._maskService.thousandSeparator && rgx.test(formattedInteger)) {
|
|
6862
|
-
formattedInteger = formattedInteger.replace(rgx, '$1' + this._maskService.thousandSeparator + '$2');
|
|
6863
|
-
}
|
|
6864
|
-
inputValue = formattedInteger + actualDecimalMarker + '0'.repeat(precision);
|
|
6865
|
-
}
|
|
6866
|
-
// Adicionar prefixo se configurado
|
|
6867
|
-
if (this._maskService.prefix && !inputValue.startsWith(this._maskService.prefix)) {
|
|
6868
|
-
inputValue = this._maskService.prefix + inputValue;
|
|
6869
|
-
}
|
|
6870
|
-
// Adicionar sufixo se configurado
|
|
6871
|
-
if (this._maskService.suffix && !inputValue.endsWith(this._maskService.suffix)) {
|
|
6872
|
-
inputValue = inputValue + this._maskService.suffix;
|
|
6840
|
+
if (actualDecimalMarker === ',') {
|
|
6841
|
+
// Converter ponto para vírgula para que applyMask processe corretamente
|
|
6842
|
+
inputValue = inputValue.replace('.', ',');
|
|
6843
|
+
console.log('🔄 Converteu ponto para vírgula:', inputValue);
|
|
6873
6844
|
}
|
|
6874
|
-
this._inputValue = inputValue;
|
|
6875
|
-
this._maskService.currentValue = inputValue;
|
|
6876
|
-
this._maskService.previousValue = inputValue;
|
|
6877
|
-
this._maskService.writingValue = false;
|
|
6878
|
-
return;
|
|
6879
6845
|
}
|
|
6880
6846
|
this._inputValue = inputValue;
|
|
6881
6847
|
// Aplicar máscara se definida
|
|
6882
|
-
// O applyMask formata o valor para exibição E chama formControlResult
|
|
6883
|
-
// que envia o valor limpo (número) para o FormControl via onChange
|
|
6884
6848
|
if (this._mask && this._mask.trim() !== '') {
|
|
6885
|
-
|
|
6886
|
-
|
|
6849
|
+
console.log('📝 Chamando applyMask com:', inputValue);
|
|
6850
|
+
const maskedValue = this._maskService.applyMask(inputValue, this._mask);
|
|
6851
|
+
console.log('📝 applyMask retornou:', maskedValue);
|
|
6852
|
+
// Atualizar o valor do elemento HTML diretamente usando ElementRef
|
|
6853
|
+
if (this.elementRef && this.elementRef.nativeElement) {
|
|
6854
|
+
this.elementRef.nativeElement.value = maskedValue;
|
|
6855
|
+
console.log('✅ Elemento HTML atualizado com:', maskedValue);
|
|
6856
|
+
}
|
|
6857
|
+
else {
|
|
6858
|
+
console.log('⚠️ ElementRef não disponível');
|
|
6859
|
+
}
|
|
6887
6860
|
}
|
|
6888
|
-
// Sem máscara, não precisa fazer nada - o valor já está no FormControl
|
|
6889
6861
|
this._maskService.writingValue = false;
|
|
6862
|
+
console.log('✅ writeValue CONCLUÍDO');
|
|
6890
6863
|
}
|
|
6891
6864
|
registerOnChange(fn) {
|
|
6892
6865
|
this.onChange = fn;
|