matcha-components 20.98.0 → 20.99.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.
|
@@ -6795,14 +6795,56 @@ class MatchaMaskCompatibleDirective {
|
|
|
6795
6795
|
else {
|
|
6796
6796
|
inputValue = String(value);
|
|
6797
6797
|
}
|
|
6798
|
-
//
|
|
6799
|
-
//
|
|
6800
|
-
if (this._mask && this._mask.trim().startsWith('separator.')
|
|
6801
|
-
|
|
6798
|
+
// Para máscaras de separador (currency), formatar o valor do backend corretamente
|
|
6799
|
+
// Exemplo: backend envia 10.5, devemos exibir "R$ 10,50"
|
|
6800
|
+
if (this._mask && this._mask.trim().startsWith('separator.')) {
|
|
6801
|
+
const precision = this._maskService.getPrecision(this._mask);
|
|
6802
6802
|
const decimalMarker = this._maskService.decimalMarker;
|
|
6803
|
-
|
|
6804
|
-
|
|
6803
|
+
const actualDecimalMarker = decimalMarker === ',' ||
|
|
6804
|
+
(Array.isArray(decimalMarker) && decimalMarker.includes(',')) ? ',' : '.';
|
|
6805
|
+
// Se o valor tem ponto decimal (formato backend), converter para formato de exibição
|
|
6806
|
+
if (inputValue.includes('.')) {
|
|
6807
|
+
// Separar parte inteira e decimal
|
|
6808
|
+
const parts = inputValue.split('.');
|
|
6809
|
+
const integerPart = parts[0] || '0';
|
|
6810
|
+
let decimalPart = parts[1] || '';
|
|
6811
|
+
// Ajustar casas decimais conforme precisão
|
|
6812
|
+
if (precision > 0) {
|
|
6813
|
+
decimalPart = decimalPart.padEnd(precision, '0').substring(0, precision);
|
|
6814
|
+
}
|
|
6815
|
+
// Aplicar separador de milhares na parte inteira
|
|
6816
|
+
let formattedInteger = integerPart;
|
|
6817
|
+
const rgx = /(\d+)(\d{3})/;
|
|
6818
|
+
while (this._maskService.thousandSeparator && rgx.test(formattedInteger)) {
|
|
6819
|
+
formattedInteger = formattedInteger.replace(rgx, '$1' + this._maskService.thousandSeparator + '$2');
|
|
6820
|
+
}
|
|
6821
|
+
// Montar valor formatado
|
|
6822
|
+
inputValue = precision > 0
|
|
6823
|
+
? formattedInteger + actualDecimalMarker + decimalPart
|
|
6824
|
+
: formattedInteger;
|
|
6825
|
+
}
|
|
6826
|
+
else if (!inputValue.includes(actualDecimalMarker) && precision > 0) {
|
|
6827
|
+
// Valor sem casas decimais (ex: "10"), adicionar zeros
|
|
6828
|
+
let formattedInteger = inputValue;
|
|
6829
|
+
const rgx = /(\d+)(\d{3})/;
|
|
6830
|
+
while (this._maskService.thousandSeparator && rgx.test(formattedInteger)) {
|
|
6831
|
+
formattedInteger = formattedInteger.replace(rgx, '$1' + this._maskService.thousandSeparator + '$2');
|
|
6832
|
+
}
|
|
6833
|
+
inputValue = formattedInteger + actualDecimalMarker + '0'.repeat(precision);
|
|
6805
6834
|
}
|
|
6835
|
+
// Adicionar prefixo se configurado
|
|
6836
|
+
if (this._maskService.prefix && !inputValue.startsWith(this._maskService.prefix)) {
|
|
6837
|
+
inputValue = this._maskService.prefix + inputValue;
|
|
6838
|
+
}
|
|
6839
|
+
// Adicionar sufixo se configurado
|
|
6840
|
+
if (this._maskService.suffix && !inputValue.endsWith(this._maskService.suffix)) {
|
|
6841
|
+
inputValue = inputValue + this._maskService.suffix;
|
|
6842
|
+
}
|
|
6843
|
+
this._inputValue = inputValue;
|
|
6844
|
+
this._maskService.currentValue = inputValue;
|
|
6845
|
+
this._maskService.previousValue = inputValue;
|
|
6846
|
+
this._maskService.writingValue = false;
|
|
6847
|
+
return;
|
|
6806
6848
|
}
|
|
6807
6849
|
this._inputValue = inputValue;
|
|
6808
6850
|
// Aplicar máscara se definida
|