matcha-components 20.116.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.
@@ -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: v106 - CURRENCYMODE FIX BACKEND VALUES - ' + 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);