ng-smn-ui 4.2.11 → 4.2.13

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.
@@ -4287,6 +4287,7 @@
4287
4287
  });
4288
4288
  };
4289
4289
  UiMaskCnpjNovoDirective.prototype.writeValue = function (rawValue) {
4290
+ var _this = this;
4290
4291
  if (this.control && this.loaded && rawValue) {
4291
4292
  this.control.markAsDirty();
4292
4293
  }
@@ -4295,7 +4296,14 @@
4295
4296
  var value = this.ngModel.toString().toUpperCase();
4296
4297
  var cleanValue = value.replace(/[^0-9A-Z]+/g, '');
4297
4298
  var isNumericOnly = /^[0-9]*$/.test(cleanValue);
4298
- this.ngModel = isNumericOnly ? cleanValue.padStart(14, '0') : cleanValue;
4299
+ var paddedValue = isNumericOnly ? cleanValue.padStart(14, '0') : cleanValue;
4300
+ if (paddedValue !== cleanValue) {
4301
+ this.ngModel = paddedValue;
4302
+ setTimeout(function () { return _this.ngModelChange.emit(_this.ngModel); });
4303
+ }
4304
+ else {
4305
+ this.ngModel = paddedValue;
4306
+ }
4299
4307
  }
4300
4308
  else {
4301
4309
  this.ngModel = '';
@@ -4330,8 +4338,15 @@
4330
4338
  return { parse: true };
4331
4339
  }
4332
4340
  }
4333
- if (this.uiMaskCnpjNovo === true && control.value && !this.cnpjIsValid(control.value)) {
4334
- return { parse: true };
4341
+ if (this.uiMaskCnpjNovo === true && control.value) {
4342
+ var value = control.value.toString().toUpperCase().replace(/[^0-9A-Z]+/g, '');
4343
+ var isNumericOnly = /^[0-9]*$/.test(value);
4344
+ if (isNumericOnly) {
4345
+ value = value.padStart(14, '0');
4346
+ }
4347
+ if (!this.cnpjIsValid(value)) {
4348
+ return { parse: true };
4349
+ }
4335
4350
  }
4336
4351
  this.input = false;
4337
4352
  return null;