matcha-components 20.95.0 → 20.96.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.
@@ -5941,9 +5941,8 @@ class MatchaMaskService extends MatchaMaskApplierService {
5941
5941
  (this.previousValue === this.currentValue && justPasted);
5942
5942
  }
5943
5943
  // Propagate the input value back to the Angular model
5944
- // Sempre emitir quando currencyMode está ativo para garantir que o valor limpo seja enviado
5945
5944
  // eslint-disable-next-line no-unused-expressions,@typescript-eslint/no-unused-expressions
5946
- (this._emitValue || this.currencyMode) ? this.formControlResult(result) : '';
5945
+ this._emitValue ? this.formControlResult(result) : '';
5947
5946
  // Handle hidden input and showMaskTyped
5948
5947
  if (!this.showMaskTyped || (this.showMaskTyped && this.hiddenInput)) {
5949
5948
  if (this.hiddenInput) {
@@ -6216,47 +6215,20 @@ class MatchaMaskService extends MatchaMaskApplierService {
6216
6215
  : (v) => v;
6217
6216
  this.writingValue = false;
6218
6217
  this.maskChanged = false;
6219
- // DEBUG: Log para verificar o fluxo de processamento
6220
- console.log('=== formControlResult DEBUG ===');
6221
- console.log('inputValue:', inputValue);
6222
- console.log('dropSpecialCharacters:', this.dropSpecialCharacters);
6223
- console.log('prefix:', this.prefix);
6224
- console.log('isNumberValue:', this.isNumberValue);
6218
+ // Para máscaras de separador, garantir que isNumberValue é true
6219
+ // Isso assegura a conversão correta para número
6220
+ if (this.maskExpression.startsWith("separator" /* MaskExpression.SEPARATOR */)) {
6221
+ this.isNumberValue = true;
6222
+ }
6225
6223
  if (Array.isArray(this.dropSpecialCharacters)) {
6226
- const afterRemovePrefix = this._removePrefix(inputValue);
6227
- const afterRemoveSuffix = this._removeSuffix(afterRemovePrefix);
6228
- const afterRemoveMask = this._removeMask(afterRemoveSuffix, this.dropSpecialCharacters);
6229
- const afterCheckSymbols = this._checkSymbols(afterRemoveMask);
6230
- const afterToNumber = this._toNumber(afterCheckSymbols);
6231
- const finalValue = outputTransformFn(afterToNumber);
6232
- console.log('Array path - afterRemovePrefix:', afterRemovePrefix);
6233
- console.log('Array path - afterRemoveSuffix:', afterRemoveSuffix);
6234
- console.log('Array path - afterRemoveMask:', afterRemoveMask);
6235
- console.log('Array path - afterCheckSymbols:', afterCheckSymbols);
6236
- console.log('Array path - afterToNumber:', afterToNumber);
6237
- console.log('Array path - finalValue:', finalValue);
6238
- this.onChange(finalValue);
6224
+ this.onChange(outputTransformFn(this._toNumber(this._checkSymbols(this._removeMask(this._removeSuffix(this._removePrefix(inputValue)), this.dropSpecialCharacters)))));
6239
6225
  }
6240
6226
  else if (this.dropSpecialCharacters ||
6241
6227
  (!this.dropSpecialCharacters && this.prefix === inputValue)) {
6242
- const afterRemovePrefix = this._removePrefix(inputValue);
6243
- const afterRemoveSuffix = this._removeSuffix(afterRemovePrefix);
6244
- const afterCheckSymbols = this._checkSymbols(afterRemoveSuffix);
6245
- const afterToNumber = this._toNumber(afterCheckSymbols);
6246
- const finalValue = outputTransformFn(afterToNumber);
6247
- console.log('Boolean path - afterRemovePrefix:', afterRemovePrefix);
6248
- console.log('Boolean path - afterRemoveSuffix:', afterRemoveSuffix);
6249
- console.log('Boolean path - afterCheckSymbols:', afterCheckSymbols);
6250
- console.log('Boolean path - afterToNumber:', afterToNumber);
6251
- console.log('Boolean path - finalValue:', finalValue, 'type:', typeof finalValue);
6252
- this.onChange(finalValue);
6228
+ this.onChange(outputTransformFn(this._toNumber(this._checkSymbols(this._removeSuffix(this._removePrefix(inputValue))))));
6253
6229
  }
6254
6230
  else {
6255
- const afterToNumber = this._toNumber(inputValue);
6256
- const finalValue = outputTransformFn(afterToNumber);
6257
- console.log('Else path - afterToNumber:', afterToNumber);
6258
- console.log('Else path - finalValue:', finalValue);
6259
- this.onChange(finalValue);
6231
+ this.onChange(outputTransformFn(this._toNumber(inputValue)));
6260
6232
  }
6261
6233
  }
6262
6234
  _toNumber(value) {
@@ -6303,13 +6275,17 @@ class MatchaMaskService extends MatchaMaskApplierService {
6303
6275
  ? this.specialCharacters.filter((v) => {
6304
6276
  return this.dropSpecialCharacters.includes(v);
6305
6277
  })
6306
- : this.specialCharacters;
6278
+ : [...this.specialCharacters]; // Criar cópia para não modificar o original
6307
6279
  if (!this.deletedSpecialCharacter &&
6308
6280
  this._checkPatternForSpace() &&
6309
6281
  result.includes(" " /* MaskExpression.WHITE_SPACE */) &&
6310
6282
  this.maskExpression.includes("*" /* MaskExpression.SYMBOL_STAR */)) {
6311
6283
  specialCharacters = specialCharacters.filter((char) => char !== " " /* MaskExpression.WHITE_SPACE */);
6312
6284
  }
6285
+ // Para máscaras de separador, NÃO remover o decimalMarker - ele será convertido para ponto depois
6286
+ if (this.maskExpression.startsWith("separator" /* MaskExpression.SEPARATOR */)) {
6287
+ specialCharacters = specialCharacters.filter((char) => !this._compareOrIncludes(char, this.decimalMarker, null));
6288
+ }
6313
6289
  return this._removeMask(result, specialCharacters);
6314
6290
  }
6315
6291
  _regExpForRemove(specialCharactersForRemove) {
@@ -6725,23 +6701,22 @@ class MatchaMaskCompatibleDirective {
6725
6701
  // Implementar lógica de foco se necessário
6726
6702
  }
6727
6703
  onModelChange(value) {
6704
+ // Ignorar se estamos no meio de uma operação de escrita
6728
6705
  if (this._maskService.writingValue) {
6729
6706
  return;
6730
6707
  }
6731
- // Converter automaticamente número para string (retrocompatível)
6732
- const stringValue = typeof value === 'number' ? value.toString() : (value || '');
6733
- this._inputValue = stringValue;
6734
- // Aplicar máscara se definida
6735
- // O applyMask internamente chama formControlResult que já cuida de:
6736
- // 1. Remover prefixo/sufixo
6737
- // 2. Remover separadores especiais
6738
- // 3. Converter para número
6739
- // 4. Chamar onChange com o valor limpo
6740
- if (this._mask && this._mask.trim() !== '') {
6741
- this._maskService.applyMask(stringValue, this._mask);
6742
- // NÃO chamar onChange aqui - formControlResult já fez isso com o valor limpo
6708
+ // Se o valor é um número, significa que veio do formControlResult (já processado)
6709
+ // Não precisamos reprocessar para evitar loop infinito
6710
+ if (typeof value === 'number') {
6711
+ return;
6743
6712
  }
6744
- else {
6713
+ // Converter para string
6714
+ const stringValue = value || '';
6715
+ this._inputValue = stringValue;
6716
+ // Para máscaras, não chamar applyMask aqui pois isso criaria um loop
6717
+ // O onInput já cuida de aplicar a máscara durante a digitação
6718
+ // O writeValue cuida de formatar valores vindos do backend
6719
+ if (!this._mask || this._mask.trim() === '') {
6745
6720
  this._maskService.onChange(stringValue);
6746
6721
  }
6747
6722
  }