matcha-components 20.115.0 → 20.117.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.
@@ -5117,13 +5117,13 @@ class MatchaMaskApplierService {
5117
5117
  }
5118
5118
  // Modo moeda: dígitos entram pela direita (ex: 1 → 0,01, 12 → 0,12, 123 → 1,23)
5119
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)
5120
+ // - NÃO aplicar se estamos em writeValue (valor vindo do backend/programático)
5121
+ // - Aplicar apenas durante digitação do usuário (onInput)
5123
5122
  const actualDecimalMarker = typeof decimalMarker === 'string' ? decimalMarker : ',';
5124
5123
  const hasDecimalMarker = processedValue.includes(actualDecimalMarker);
5125
5124
  let shouldApplyCurrencyMode = false;
5126
- if (this.currencyMode && precision > 0) {
5125
+ // NUNCA aplicar currencyMode quando writingValue = true (writeValue do backend)
5126
+ if (this.currencyMode && precision > 0 && !this.writingValue) {
5127
5127
  if (!hasDecimalMarker) {
5128
5128
  // Sem vírgula: aplicar currencyMode (digitação começando)
5129
5129
  shouldApplyCurrencyMode = true;
@@ -5728,7 +5728,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.0", ngImpor
5728
5728
  type: Injectable
5729
5729
  }] });
5730
5730
 
5731
- // console.log('🎯 MATCHA-MASK VERSION: v105 - CURRENCYMODE SMART DETECTION v2 - ' + new Date().toISOString());
5731
+ // console.log('🎯 MATCHA-MASK VERSION: v107 - FIX DECIMAL DISPLAY & BACKSPACE LOOP - ' + new Date().toISOString());
5732
5732
  class MatchaMaskService extends MatchaMaskApplierService {
5733
5733
  constructor() {
5734
5734
  super(...arguments);
@@ -6799,6 +6799,18 @@ class MatchaMaskCompatibleDirective {
6799
6799
  }
6800
6800
  const target = event.target;
6801
6801
  const value = target.value;
6802
+ // Se o usuário está tentando limpar o campo (apenas prefixo/sufixo restante), permitir vazio
6803
+ const prefix = this._maskService.prefix || '';
6804
+ const suffix = this._maskService.suffix || '';
6805
+ const valueWithoutPrefixSuffix = value.replace(prefix, '').replace(suffix, '').trim();
6806
+ // Se ficou vazio ou apenas com separadores/zeros, permitir limpar completamente
6807
+ const onlySymbols = /^[^\d]*$/.test(valueWithoutPrefixSuffix) ||
6808
+ /^0+[,.]?0*$/.test(valueWithoutPrefixSuffix);
6809
+ if (valueWithoutPrefixSuffix === '' || onlySymbols) {
6810
+ target.value = '';
6811
+ this._maskService.onChange('');
6812
+ return;
6813
+ }
6802
6814
  // Aplicar máscara se definida
6803
6815
  if (this._mask && this._mask.trim() !== '') {
6804
6816
  const maskedValue = this._maskService.applyMask(value, this._mask);
@@ -6844,7 +6856,14 @@ class MatchaMaskCompatibleDirective {
6844
6856
  inputValue = '';
6845
6857
  }
6846
6858
  else if (typeof value === 'number') {
6847
- inputValue = value.toString();
6859
+ // Para máscaras de separador, formatar o número com casas decimais
6860
+ if (this._mask && this._mask.trim().startsWith('separator.')) {
6861
+ const precision = parseInt(this._mask.split('.')[1], 10) || 2;
6862
+ inputValue = value.toFixed(precision).replace('.', ',');
6863
+ }
6864
+ else {
6865
+ inputValue = value.toString();
6866
+ }
6848
6867
  }
6849
6868
  else {
6850
6869
  inputValue = String(value);