ng-smn-ui 4.2.8 → 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.
@@ -4013,6 +4013,276 @@ var UiMaskCnpjDirective = /** @class */ (function () {
4013
4013
  return UiMaskCnpjDirective;
4014
4014
  }());
4015
4015
 
4016
+ var UiCnpjNovoPipe = /** @class */ (function () {
4017
+ function UiCnpjNovoPipe() {
4018
+ }
4019
+ UiCnpjNovoPipe.prototype.transform = function (value, mask) {
4020
+ if (!value) {
4021
+ return '';
4022
+ }
4023
+ value = value.toString().toUpperCase().replace(/[^0-9A-Z]+/g, '');
4024
+ if (!mask) {
4025
+ var isNumericOnly = /^[0-9]*$/.test(value);
4026
+ if (isNumericOnly) {
4027
+ value = value.padStart(14, '0');
4028
+ }
4029
+ }
4030
+ value = value.toString().toUpperCase().replace(/[^0-9A-Z]+/g, '');
4031
+ if (value.length > 2) {
4032
+ value = value.substring(0, 2) + '.' + value.substring(2);
4033
+ }
4034
+ if (value.length > 6) {
4035
+ value = value.substring(0, 6) + '.' + value.substring(6);
4036
+ }
4037
+ if (value.length > 10) {
4038
+ value = value.substring(0, 10) + '/' + value.substring(10);
4039
+ }
4040
+ if (value.length > 15) {
4041
+ value = value.substring(0, 15) + '-' + value.substring(15);
4042
+ }
4043
+ if (value.length > 18) {
4044
+ value = value.substring(0, 18);
4045
+ }
4046
+ return value;
4047
+ };
4048
+ UiCnpjNovoPipe = __decorate([
4049
+ Pipe({
4050
+ name: 'uiCnpjNovo'
4051
+ })
4052
+ ], UiCnpjNovoPipe);
4053
+ return UiCnpjNovoPipe;
4054
+ }());
4055
+
4056
+ var UiMaskCnpjNovoDirective = /** @class */ (function () {
4057
+ function UiMaskCnpjNovoDirective(elementRef, cnpjPipe) {
4058
+ this.elementRef = elementRef;
4059
+ this.cnpjPipe = cnpjPipe;
4060
+ this.symbolsPositions = [2, 6, 10, 15, 18];
4061
+ this.padOnPaste = true;
4062
+ this.ngModelChange = new EventEmitter();
4063
+ }
4064
+ UiMaskCnpjNovoDirective_1 = UiMaskCnpjNovoDirective;
4065
+ UiMaskCnpjNovoDirective.prototype.ngOnChanges = function (changes) {
4066
+ if (!changes.ngModel.firstChange && (changes.ngModel.currentValue === null || changes.ngModel.currentValue === undefined)) {
4067
+ this.elementRef.nativeElement.value = '';
4068
+ }
4069
+ };
4070
+ UiMaskCnpjNovoDirective.prototype.ngAfterViewInit = function () {
4071
+ var _this = this;
4072
+ setTimeout(function () {
4073
+ _this.loaded = true;
4074
+ });
4075
+ };
4076
+ UiMaskCnpjNovoDirective.prototype.writeValue = function (rawValue) {
4077
+ var _this = this;
4078
+ if (this.control && this.loaded && rawValue) {
4079
+ this.control.markAsDirty();
4080
+ }
4081
+ if (!this.input) {
4082
+ if (this.ngModel) {
4083
+ var value = this.ngModel.toString().toUpperCase();
4084
+ var cleanValue = value.replace(/[^0-9A-Z]+/g, '');
4085
+ var isNumericOnly = /^[0-9]*$/.test(cleanValue);
4086
+ var paddedValue = isNumericOnly ? cleanValue.padStart(14, '0') : cleanValue;
4087
+ if (paddedValue !== cleanValue) {
4088
+ this.ngModel = paddedValue;
4089
+ setTimeout(function () { return _this.ngModelChange.emit(_this.ngModel); });
4090
+ }
4091
+ else {
4092
+ this.ngModel = paddedValue;
4093
+ }
4094
+ }
4095
+ else {
4096
+ this.ngModel = '';
4097
+ }
4098
+ this.elementRef.nativeElement.value = this.cnpjPipe.transform(this.ngModel, true);
4099
+ }
4100
+ this.input = false;
4101
+ };
4102
+ UiMaskCnpjNovoDirective.prototype.renderViaInput = function (rawValue) {
4103
+ if (rawValue) {
4104
+ this.control.markAsDirty();
4105
+ }
4106
+ this.ngModel = this.format(rawValue);
4107
+ this.ngModelChange.emit(this.ngModel);
4108
+ this.elementRef.nativeElement.value = this.cnpjPipe.transform(this.elementRef.nativeElement.value, true);
4109
+ };
4110
+ UiMaskCnpjNovoDirective.prototype.registerOnChange = function (fn) {
4111
+ this.onChange = fn;
4112
+ };
4113
+ UiMaskCnpjNovoDirective.prototype.registerOnTouched = function (fn) {
4114
+ this.onTouched = fn;
4115
+ };
4116
+ UiMaskCnpjNovoDirective.prototype.format = function (value) {
4117
+ // Aceita números e letras (A-Z), normaliza para maiúsculas
4118
+ value = value.toString().toUpperCase().replace(/[^0-9A-Z]+/g, '');
4119
+ return value.substring(0, 14);
4120
+ };
4121
+ UiMaskCnpjNovoDirective.prototype.validate = function (control) {
4122
+ this.control = control;
4123
+ if (this.input) {
4124
+ if (control.value && this.format(control.value).length < 14) {
4125
+ return { parse: true };
4126
+ }
4127
+ }
4128
+ if (this.uiMaskCnpjNovo === true && control.value) {
4129
+ var value = control.value.toString().toUpperCase().replace(/[^0-9A-Z]+/g, '');
4130
+ var isNumericOnly = /^[0-9]*$/.test(value);
4131
+ if (isNumericOnly) {
4132
+ value = value.padStart(14, '0');
4133
+ }
4134
+ if (!this.cnpjIsValid(value)) {
4135
+ return { parse: true };
4136
+ }
4137
+ }
4138
+ this.input = false;
4139
+ return null;
4140
+ };
4141
+ UiMaskCnpjNovoDirective.prototype.setDisabledState = function (isDisabled) {
4142
+ var method = isDisabled ? 'setAttribute' : 'removeAttribute';
4143
+ this.elementRef.nativeElement[method]('disabled', 'disabled');
4144
+ };
4145
+ /**
4146
+ * Converte um caractere para seu valor numérico.
4147
+ * Usa código ASCII - 48 para todos os caracteres:
4148
+ * - Dígitos 0-9 retornam 0-9
4149
+ * - Letras A-Z retornam 17-42 (A=17, B=18, ..., Z=42)
4150
+ * Referência: https://www.gov.br/receitafederal/pt-br/centrais-de-conteudo/publicacoes/perguntas-e-respostas/cnpj/cnpj-alfanumerico.pdf
4151
+ */
4152
+ UiMaskCnpjNovoDirective.prototype.charToValue = function (char) {
4153
+ return char.toUpperCase().charCodeAt(0) - 48;
4154
+ };
4155
+ /**
4156
+ * Valida CNPJ alfanumérico conforme especificação.
4157
+ * Suporta tanto CNPJs numéricos tradicionais quanto os novos alfanuméricos.
4158
+ * A conversão usa ASCII - 48 para todos os caracteres (A=17, B=18, ..., Z=42).
4159
+ */
4160
+ UiMaskCnpjNovoDirective.prototype.cnpjIsValid = function (cnpj) {
4161
+ if (!cnpj || cnpj.length !== 14) {
4162
+ return false;
4163
+ }
4164
+ // Normaliza para maiúsculas
4165
+ cnpj = cnpj.toUpperCase();
4166
+ // Verifica se contém apenas caracteres válidos (0-9 e A-Z)
4167
+ if (!/^[0-9A-Z]{14}$/.test(cnpj)) {
4168
+ return false;
4169
+ }
4170
+ // Verifica CNPJs com todos os caracteres iguais
4171
+ if (/^(.)\1{13}$/.test(cnpj)) {
4172
+ return false;
4173
+ }
4174
+ var base = cnpj.substring(0, 12);
4175
+ var digits = cnpj.substring(12);
4176
+ // Calcula o primeiro dígito verificador
4177
+ var sum = 0;
4178
+ var pos = 5;
4179
+ for (var i = 0; i < 12; i++) {
4180
+ sum += this.charToValue(base.charAt(i)) * pos--;
4181
+ if (pos < 2) {
4182
+ pos = 9;
4183
+ }
4184
+ }
4185
+ var result = sum % 11 < 2 ? 0 : 11 - (sum % 11);
4186
+ if (result !== this.charToValue(digits.charAt(0))) {
4187
+ return false;
4188
+ }
4189
+ // Calcula o segundo dígito verificador
4190
+ var baseWithFirstDigit = base + digits.charAt(0);
4191
+ sum = 0;
4192
+ pos = 6;
4193
+ for (var i = 0; i < 13; i++) {
4194
+ sum += this.charToValue(baseWithFirstDigit.charAt(i)) * pos--;
4195
+ if (pos < 2) {
4196
+ pos = 9;
4197
+ }
4198
+ }
4199
+ result = sum % 11 < 2 ? 0 : 11 - (sum % 11);
4200
+ return result === this.charToValue(digits.charAt(1));
4201
+ };
4202
+ UiMaskCnpjNovoDirective.prototype.onKeydown = function () {
4203
+ this.beforeSelIndex = UiElement.caretPosition.get(this.elementRef.nativeElement);
4204
+ };
4205
+ UiMaskCnpjNovoDirective.prototype.onInput = function ($event) {
4206
+ var afterSelIndex = UiElement.caretPosition.get(this.elementRef.nativeElement);
4207
+ var rawValue = this.elementRef.nativeElement.value;
4208
+ this.input = this.format(rawValue) !== this.ngModel;
4209
+ this.renderViaInput(rawValue);
4210
+ UiElement.caretPosition.set(this.elementRef.nativeElement, this.beforeSelIndex, afterSelIndex, this.symbolsPositions);
4211
+ };
4212
+ UiMaskCnpjNovoDirective.prototype.padLeft = function (event) {
4213
+ if (this.padOnPaste) {
4214
+ event.preventDefault();
4215
+ var data = void 0;
4216
+ if (window['clipboardData']) {
4217
+ data = window['clipboardData'];
4218
+ }
4219
+ else if (event.clipboardData && event.clipboardData.getData) {
4220
+ data = event.clipboardData;
4221
+ }
4222
+ // Aceita números e letras, normaliza para maiúsculas
4223
+ var text = data.getData('text').toString().toUpperCase().replace(/[^0-9A-Z]+/g, '');
4224
+ // Só faz padStart se for CNPJ numérico puro (retrocompatibilidade)
4225
+ var isNumericOnly = /^[0-9]*$/.test(text);
4226
+ this.renderViaInput(isNumericOnly ? text.padStart(14, '0') : text);
4227
+ }
4228
+ };
4229
+ var UiMaskCnpjNovoDirective_1;
4230
+ UiMaskCnpjNovoDirective.ctorParameters = function () { return [
4231
+ { type: ElementRef },
4232
+ { type: UiCnpjNovoPipe }
4233
+ ]; };
4234
+ __decorate([
4235
+ Input(),
4236
+ __metadata("design:type", Object)
4237
+ ], UiMaskCnpjNovoDirective.prototype, "ngModel", void 0);
4238
+ __decorate([
4239
+ Input(),
4240
+ __metadata("design:type", Boolean)
4241
+ ], UiMaskCnpjNovoDirective.prototype, "padOnPaste", void 0);
4242
+ __decorate([
4243
+ Input('uiMaskCnpjNovo'),
4244
+ __metadata("design:type", Object)
4245
+ ], UiMaskCnpjNovoDirective.prototype, "uiMaskCnpjNovo", void 0);
4246
+ __decorate([
4247
+ Output(),
4248
+ __metadata("design:type", EventEmitter)
4249
+ ], UiMaskCnpjNovoDirective.prototype, "ngModelChange", void 0);
4250
+ __decorate([
4251
+ HostListener('keydown'),
4252
+ __metadata("design:type", Function),
4253
+ __metadata("design:paramtypes", []),
4254
+ __metadata("design:returntype", void 0)
4255
+ ], UiMaskCnpjNovoDirective.prototype, "onKeydown", null);
4256
+ __decorate([
4257
+ HostListener('input', ['$event']),
4258
+ __metadata("design:type", Function),
4259
+ __metadata("design:paramtypes", [Object]),
4260
+ __metadata("design:returntype", void 0)
4261
+ ], UiMaskCnpjNovoDirective.prototype, "onInput", null);
4262
+ __decorate([
4263
+ HostListener('paste', ['$event']),
4264
+ __metadata("design:type", Function),
4265
+ __metadata("design:paramtypes", [Object]),
4266
+ __metadata("design:returntype", void 0)
4267
+ ], UiMaskCnpjNovoDirective.prototype, "padLeft", null);
4268
+ UiMaskCnpjNovoDirective = UiMaskCnpjNovoDirective_1 = __decorate([
4269
+ Directive({
4270
+ selector: '[uiMaskCnpjNovo][ngModel]',
4271
+ providers: [{
4272
+ provide: NG_VALUE_ACCESSOR,
4273
+ useExisting: forwardRef(function () { return UiMaskCnpjNovoDirective_1; }),
4274
+ multi: true
4275
+ }, {
4276
+ provide: NG_VALIDATORS,
4277
+ useExisting: forwardRef(function () { return UiMaskCnpjNovoDirective_1; }),
4278
+ multi: true
4279
+ }, UiCnpjNovoPipe]
4280
+ }),
4281
+ __metadata("design:paramtypes", [ElementRef, UiCnpjNovoPipe])
4282
+ ], UiMaskCnpjNovoDirective);
4283
+ return UiMaskCnpjNovoDirective;
4284
+ }());
4285
+
4016
4286
  var UiCepPipe = /** @class */ (function () {
4017
4287
  function UiCepPipe() {
4018
4288
  }
@@ -10569,6 +10839,8 @@ var lib = [
10569
10839
  UiCpfPipe,
10570
10840
  UiMaskCnpjDirective,
10571
10841
  UiCnpjPipe,
10842
+ UiMaskCnpjNovoDirective,
10843
+ UiCnpjNovoPipe,
10572
10844
  UiMaskCepDirective,
10573
10845
  UiCepPipe,
10574
10846
  UiMaskCepNovoDirective,
@@ -10672,5 +10944,5 @@ var SMNUIModule = /** @class */ (function () {
10672
10944
  * Generated bundle index. Do not edit.
10673
10945
  */
10674
10946
 
10675
- export { SMNUIModule, UiCepNovoPipe, UiCepPipe, UiCnpjPipe, UiColor, UiCookie, UiCpfPipe, UiCreditCardPipe, UiCurrencyPipe, UiDatetimeService, UiDialog, UiElement, UiElementRef, UiFilterPipe, UiFloatPipe, UiInfiniteLoadService, UiMaskCreditCard, UiMaskPhoneDirective, UiPhonePipe, UiSnackbar, UiTimePipe, UiToolbarService, UiWindowRef, debounce, unaccent, _isBright as ɵa, _hexToRgb as ɵb, UiSwitchComponent as ɵba, UiToolbarComponent as ɵbb, UiMaskDateDirective as ɵbc, UiTimeAgoPipe as ɵbd, UiListItemDirective as ɵbe, UiMaskCpfDirective as ɵbf, UiMaskCnpjDirective as ɵbg, UiMaskCepDirective as ɵbh, UiMaskCepNovoDirective as ɵbi, UiListComponent as ɵbj, UiListItemsComponent as ɵbk, UiListItemComponent as ɵbl, UiSliderComponent as ɵbm, UiSliderMultiHandleComponent as ɵbn, UiInfiniteLoadDirective as ɵbo, UiAutocompleteDirective as ɵbp, UiAutocompleteComponent as ɵbq, UiMaskIntegerDirective as ɵbr, UiTabsComponent as ɵbs, UiTabsPagesComponent as ɵbt, UiLazyLoadDirective as ɵbu, UiDataTableComponent as ɵbv, UiBottomSheetComponent as ɵbw, UiBottomSheetTriggerDirective as ɵbx, UiInputFileDirective as ɵby, UiEllipsisDirective as ɵbz, _window as ɵc, UiRequiredDirective as ɵca, UiColorPickerComponent as ɵcb, UiColorPickerDirective as ɵcc, UiInputAutosizeDirective as ɵcd, UiClockComponent as ɵce, UiTimePickerDirective as ɵcf, UiTimePickerService as ɵcg, UiTimePickerCallerDirective as ɵch, UiMaskTimeDirective as ɵci, UiMaskCurrencyDirective as ɵcj, UiSelectComponent as ɵck, UiSelectOptionComponent as ɵcl, UiSelectFilterPipe as ɵcm, UiAvatarComponent as ɵcn, UiMaskFloatDirective as ɵco, TooltipDirective as ɵcp, UiChosenComponent as ɵcq, UiChosenOptionComponent as ɵcr, UiChosenGroupComponent as ɵcs, ExpansionPanelComponent as ɵct, UiTabComponent as ɵcu, UiTabContentDirective as ɵcv, UiTabLabelDirective as ɵcw, UiTabGroupComponent as ɵcx, tabFakeAnimation as ɵcy, tabTransform as ɵcz, UiAddCalendarDirective as ɵd, UiTabHeaderComponent as ɵda, UiLabelContentComponent as ɵdb, UiUploadComponent as ɵdc, Upload as ɵdd, enterLeaveViewAnimation as ɵde, UiCalendarComponent as ɵe, UiCalendarContentComponent as ɵf, UiCapitalizePipe as ɵg, UiDataTableOrderByDirective as ɵh, UiDatePickerCallerDirective as ɵi, UiReferencesService as ɵj, UiDatePickerDirective as ɵk, UiDialogComponent as ɵl, UiDialogTriggerDirective as ɵm, UiInputContainerComponent as ɵn, UiInputDirective as ɵo, UiMaxlengthDirective as ɵp, UiMenuComponent as ɵq, UiMenuTriggerDirective as ɵr, UiNavDrawerComponent as ɵs, UiOptionComponent as ɵt, UiProgressRadialComponent as ɵu, UiRippleDirective as ɵv, UiSmartListComponent as ɵw, UiSmartListItemComponent as ɵx, UiSnackbarComponent as ɵy, UiSnackbarContainerComponent as ɵz };
10947
+ export { SMNUIModule, UiCepNovoPipe, UiCepPipe, UiCnpjNovoPipe, UiCnpjPipe, UiColor, UiCookie, UiCpfPipe, UiCreditCardPipe, UiCurrencyPipe, UiDatetimeService, UiDialog, UiElement, UiElementRef, UiFilterPipe, UiFloatPipe, UiInfiniteLoadService, UiMaskCreditCard, UiMaskPhoneDirective, UiPhonePipe, UiSnackbar, UiTimePipe, UiToolbarService, UiWindowRef, debounce, unaccent, _isBright as ɵa, _hexToRgb as ɵb, UiSwitchComponent as ɵba, UiToolbarComponent as ɵbb, UiMaskDateDirective as ɵbc, UiTimeAgoPipe as ɵbd, UiListItemDirective as ɵbe, UiMaskCpfDirective as ɵbf, UiMaskCnpjDirective as ɵbg, UiMaskCnpjNovoDirective as ɵbh, UiMaskCepDirective as ɵbi, UiMaskCepNovoDirective as ɵbj, UiListComponent as ɵbk, UiListItemsComponent as ɵbl, UiListItemComponent as ɵbm, UiSliderComponent as ɵbn, UiSliderMultiHandleComponent as ɵbo, UiInfiniteLoadDirective as ɵbp, UiAutocompleteDirective as ɵbq, UiAutocompleteComponent as ɵbr, UiMaskIntegerDirective as ɵbs, UiTabsComponent as ɵbt, UiTabsPagesComponent as ɵbu, UiLazyLoadDirective as ɵbv, UiDataTableComponent as ɵbw, UiBottomSheetComponent as ɵbx, UiBottomSheetTriggerDirective as ɵby, UiInputFileDirective as ɵbz, _window as ɵc, UiEllipsisDirective as ɵca, UiRequiredDirective as ɵcb, UiColorPickerComponent as ɵcc, UiColorPickerDirective as ɵcd, UiInputAutosizeDirective as ɵce, UiClockComponent as ɵcf, UiTimePickerDirective as ɵcg, UiTimePickerService as ɵch, UiTimePickerCallerDirective as ɵci, UiMaskTimeDirective as ɵcj, UiMaskCurrencyDirective as ɵck, UiSelectComponent as ɵcl, UiSelectOptionComponent as ɵcm, UiSelectFilterPipe as ɵcn, UiAvatarComponent as ɵco, UiMaskFloatDirective as ɵcp, TooltipDirective as ɵcq, UiChosenComponent as ɵcr, UiChosenOptionComponent as ɵcs, UiChosenGroupComponent as ɵct, ExpansionPanelComponent as ɵcu, UiTabComponent as ɵcv, UiTabContentDirective as ɵcw, UiTabLabelDirective as ɵcx, UiTabGroupComponent as ɵcy, tabFakeAnimation as ɵcz, UiAddCalendarDirective as ɵd, tabTransform as ɵda, UiTabHeaderComponent as ɵdb, UiLabelContentComponent as ɵdc, UiUploadComponent as ɵdd, Upload as ɵde, enterLeaveViewAnimation as ɵdf, UiCalendarComponent as ɵe, UiCalendarContentComponent as ɵf, UiCapitalizePipe as ɵg, UiDataTableOrderByDirective as ɵh, UiDatePickerCallerDirective as ɵi, UiReferencesService as ɵj, UiDatePickerDirective as ɵk, UiDialogComponent as ɵl, UiDialogTriggerDirective as ɵm, UiInputContainerComponent as ɵn, UiInputDirective as ɵo, UiMaxlengthDirective as ɵp, UiMenuComponent as ɵq, UiMenuTriggerDirective as ɵr, UiNavDrawerComponent as ɵs, UiOptionComponent as ɵt, UiProgressRadialComponent as ɵu, UiRippleDirective as ɵv, UiSmartListComponent as ɵw, UiSmartListItemComponent as ɵx, UiSnackbarComponent as ɵy, UiSnackbarContainerComponent as ɵz };
10676
10948
  //# sourceMappingURL=ng-smn-ui.js.map