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.
@@ -3910,6 +3910,269 @@ UiMaskCnpjDirective = UiMaskCnpjDirective_1 = __decorate([
3910
3910
  __metadata("design:paramtypes", [ElementRef, UiCnpjPipe])
3911
3911
  ], UiMaskCnpjDirective);
3912
3912
 
3913
+ let UiCnpjNovoPipe = class UiCnpjNovoPipe {
3914
+ transform(value, mask) {
3915
+ if (!value) {
3916
+ return '';
3917
+ }
3918
+ value = value.toString().toUpperCase().replace(/[^0-9A-Z]+/g, '');
3919
+ if (!mask) {
3920
+ const isNumericOnly = /^[0-9]*$/.test(value);
3921
+ if (isNumericOnly) {
3922
+ value = value.padStart(14, '0');
3923
+ }
3924
+ }
3925
+ value = value.toString().toUpperCase().replace(/[^0-9A-Z]+/g, '');
3926
+ if (value.length > 2) {
3927
+ value = value.substring(0, 2) + '.' + value.substring(2);
3928
+ }
3929
+ if (value.length > 6) {
3930
+ value = value.substring(0, 6) + '.' + value.substring(6);
3931
+ }
3932
+ if (value.length > 10) {
3933
+ value = value.substring(0, 10) + '/' + value.substring(10);
3934
+ }
3935
+ if (value.length > 15) {
3936
+ value = value.substring(0, 15) + '-' + value.substring(15);
3937
+ }
3938
+ if (value.length > 18) {
3939
+ value = value.substring(0, 18);
3940
+ }
3941
+ return value;
3942
+ }
3943
+ };
3944
+ UiCnpjNovoPipe = __decorate([
3945
+ Pipe({
3946
+ name: 'uiCnpjNovo'
3947
+ })
3948
+ ], UiCnpjNovoPipe);
3949
+
3950
+ var UiMaskCnpjNovoDirective_1;
3951
+ let UiMaskCnpjNovoDirective = UiMaskCnpjNovoDirective_1 = class UiMaskCnpjNovoDirective {
3952
+ constructor(elementRef, cnpjPipe) {
3953
+ this.elementRef = elementRef;
3954
+ this.cnpjPipe = cnpjPipe;
3955
+ this.symbolsPositions = [2, 6, 10, 15, 18];
3956
+ this.padOnPaste = true;
3957
+ this.ngModelChange = new EventEmitter();
3958
+ }
3959
+ ngOnChanges(changes) {
3960
+ if (!changes.ngModel.firstChange && (changes.ngModel.currentValue === null || changes.ngModel.currentValue === undefined)) {
3961
+ this.elementRef.nativeElement.value = '';
3962
+ }
3963
+ }
3964
+ ngAfterViewInit() {
3965
+ setTimeout(() => {
3966
+ this.loaded = true;
3967
+ });
3968
+ }
3969
+ writeValue(rawValue) {
3970
+ if (this.control && this.loaded && rawValue) {
3971
+ this.control.markAsDirty();
3972
+ }
3973
+ if (!this.input) {
3974
+ if (this.ngModel) {
3975
+ const value = this.ngModel.toString().toUpperCase();
3976
+ const cleanValue = value.replace(/[^0-9A-Z]+/g, '');
3977
+ const isNumericOnly = /^[0-9]*$/.test(cleanValue);
3978
+ const paddedValue = isNumericOnly ? cleanValue.padStart(14, '0') : cleanValue;
3979
+ if (paddedValue !== cleanValue) {
3980
+ this.ngModel = paddedValue;
3981
+ setTimeout(() => this.ngModelChange.emit(this.ngModel));
3982
+ }
3983
+ else {
3984
+ this.ngModel = paddedValue;
3985
+ }
3986
+ }
3987
+ else {
3988
+ this.ngModel = '';
3989
+ }
3990
+ this.elementRef.nativeElement.value = this.cnpjPipe.transform(this.ngModel, true);
3991
+ }
3992
+ this.input = false;
3993
+ }
3994
+ renderViaInput(rawValue) {
3995
+ if (rawValue) {
3996
+ this.control.markAsDirty();
3997
+ }
3998
+ this.ngModel = this.format(rawValue);
3999
+ this.ngModelChange.emit(this.ngModel);
4000
+ this.elementRef.nativeElement.value = this.cnpjPipe.transform(this.elementRef.nativeElement.value, true);
4001
+ }
4002
+ registerOnChange(fn) {
4003
+ this.onChange = fn;
4004
+ }
4005
+ registerOnTouched(fn) {
4006
+ this.onTouched = fn;
4007
+ }
4008
+ format(value) {
4009
+ // Aceita números e letras (A-Z), normaliza para maiúsculas
4010
+ value = value.toString().toUpperCase().replace(/[^0-9A-Z]+/g, '');
4011
+ return value.substring(0, 14);
4012
+ }
4013
+ validate(control) {
4014
+ this.control = control;
4015
+ if (this.input) {
4016
+ if (control.value && this.format(control.value).length < 14) {
4017
+ return { parse: true };
4018
+ }
4019
+ }
4020
+ if (this.uiMaskCnpjNovo === true && control.value) {
4021
+ let value = control.value.toString().toUpperCase().replace(/[^0-9A-Z]+/g, '');
4022
+ const isNumericOnly = /^[0-9]*$/.test(value);
4023
+ if (isNumericOnly) {
4024
+ value = value.padStart(14, '0');
4025
+ }
4026
+ if (!this.cnpjIsValid(value)) {
4027
+ return { parse: true };
4028
+ }
4029
+ }
4030
+ this.input = false;
4031
+ return null;
4032
+ }
4033
+ setDisabledState(isDisabled) {
4034
+ const method = isDisabled ? 'setAttribute' : 'removeAttribute';
4035
+ this.elementRef.nativeElement[method]('disabled', 'disabled');
4036
+ }
4037
+ /**
4038
+ * Converte um caractere para seu valor numérico.
4039
+ * Usa código ASCII - 48 para todos os caracteres:
4040
+ * - Dígitos 0-9 retornam 0-9
4041
+ * - Letras A-Z retornam 17-42 (A=17, B=18, ..., Z=42)
4042
+ * Referência: https://www.gov.br/receitafederal/pt-br/centrais-de-conteudo/publicacoes/perguntas-e-respostas/cnpj/cnpj-alfanumerico.pdf
4043
+ */
4044
+ charToValue(char) {
4045
+ return char.toUpperCase().charCodeAt(0) - 48;
4046
+ }
4047
+ /**
4048
+ * Valida CNPJ alfanumérico conforme especificação.
4049
+ * Suporta tanto CNPJs numéricos tradicionais quanto os novos alfanuméricos.
4050
+ * A conversão usa ASCII - 48 para todos os caracteres (A=17, B=18, ..., Z=42).
4051
+ */
4052
+ cnpjIsValid(cnpj) {
4053
+ if (!cnpj || cnpj.length !== 14) {
4054
+ return false;
4055
+ }
4056
+ // Normaliza para maiúsculas
4057
+ cnpj = cnpj.toUpperCase();
4058
+ // Verifica se contém apenas caracteres válidos (0-9 e A-Z)
4059
+ if (!/^[0-9A-Z]{14}$/.test(cnpj)) {
4060
+ return false;
4061
+ }
4062
+ // Verifica CNPJs com todos os caracteres iguais
4063
+ if (/^(.)\1{13}$/.test(cnpj)) {
4064
+ return false;
4065
+ }
4066
+ const base = cnpj.substring(0, 12);
4067
+ const digits = cnpj.substring(12);
4068
+ // Calcula o primeiro dígito verificador
4069
+ let sum = 0;
4070
+ let pos = 5;
4071
+ for (let i = 0; i < 12; i++) {
4072
+ sum += this.charToValue(base.charAt(i)) * pos--;
4073
+ if (pos < 2) {
4074
+ pos = 9;
4075
+ }
4076
+ }
4077
+ let result = sum % 11 < 2 ? 0 : 11 - (sum % 11);
4078
+ if (result !== this.charToValue(digits.charAt(0))) {
4079
+ return false;
4080
+ }
4081
+ // Calcula o segundo dígito verificador
4082
+ const baseWithFirstDigit = base + digits.charAt(0);
4083
+ sum = 0;
4084
+ pos = 6;
4085
+ for (let i = 0; i < 13; i++) {
4086
+ sum += this.charToValue(baseWithFirstDigit.charAt(i)) * pos--;
4087
+ if (pos < 2) {
4088
+ pos = 9;
4089
+ }
4090
+ }
4091
+ result = sum % 11 < 2 ? 0 : 11 - (sum % 11);
4092
+ return result === this.charToValue(digits.charAt(1));
4093
+ }
4094
+ onKeydown() {
4095
+ this.beforeSelIndex = UiElement.caretPosition.get(this.elementRef.nativeElement);
4096
+ }
4097
+ onInput($event) {
4098
+ const afterSelIndex = UiElement.caretPosition.get(this.elementRef.nativeElement);
4099
+ const rawValue = this.elementRef.nativeElement.value;
4100
+ this.input = this.format(rawValue) !== this.ngModel;
4101
+ this.renderViaInput(rawValue);
4102
+ UiElement.caretPosition.set(this.elementRef.nativeElement, this.beforeSelIndex, afterSelIndex, this.symbolsPositions);
4103
+ }
4104
+ padLeft(event) {
4105
+ if (this.padOnPaste) {
4106
+ event.preventDefault();
4107
+ let data;
4108
+ if (window['clipboardData']) {
4109
+ data = window['clipboardData'];
4110
+ }
4111
+ else if (event.clipboardData && event.clipboardData.getData) {
4112
+ data = event.clipboardData;
4113
+ }
4114
+ // Aceita números e letras, normaliza para maiúsculas
4115
+ const text = data.getData('text').toString().toUpperCase().replace(/[^0-9A-Z]+/g, '');
4116
+ // Só faz padStart se for CNPJ numérico puro (retrocompatibilidade)
4117
+ const isNumericOnly = /^[0-9]*$/.test(text);
4118
+ this.renderViaInput(isNumericOnly ? text.padStart(14, '0') : text);
4119
+ }
4120
+ }
4121
+ };
4122
+ UiMaskCnpjNovoDirective.ctorParameters = () => [
4123
+ { type: ElementRef },
4124
+ { type: UiCnpjNovoPipe }
4125
+ ];
4126
+ __decorate([
4127
+ Input(),
4128
+ __metadata("design:type", Object)
4129
+ ], UiMaskCnpjNovoDirective.prototype, "ngModel", void 0);
4130
+ __decorate([
4131
+ Input(),
4132
+ __metadata("design:type", Boolean)
4133
+ ], UiMaskCnpjNovoDirective.prototype, "padOnPaste", void 0);
4134
+ __decorate([
4135
+ Input('uiMaskCnpjNovo'),
4136
+ __metadata("design:type", Object)
4137
+ ], UiMaskCnpjNovoDirective.prototype, "uiMaskCnpjNovo", void 0);
4138
+ __decorate([
4139
+ Output(),
4140
+ __metadata("design:type", EventEmitter)
4141
+ ], UiMaskCnpjNovoDirective.prototype, "ngModelChange", void 0);
4142
+ __decorate([
4143
+ HostListener('keydown'),
4144
+ __metadata("design:type", Function),
4145
+ __metadata("design:paramtypes", []),
4146
+ __metadata("design:returntype", void 0)
4147
+ ], UiMaskCnpjNovoDirective.prototype, "onKeydown", null);
4148
+ __decorate([
4149
+ HostListener('input', ['$event']),
4150
+ __metadata("design:type", Function),
4151
+ __metadata("design:paramtypes", [Object]),
4152
+ __metadata("design:returntype", void 0)
4153
+ ], UiMaskCnpjNovoDirective.prototype, "onInput", null);
4154
+ __decorate([
4155
+ HostListener('paste', ['$event']),
4156
+ __metadata("design:type", Function),
4157
+ __metadata("design:paramtypes", [Object]),
4158
+ __metadata("design:returntype", void 0)
4159
+ ], UiMaskCnpjNovoDirective.prototype, "padLeft", null);
4160
+ UiMaskCnpjNovoDirective = UiMaskCnpjNovoDirective_1 = __decorate([
4161
+ Directive({
4162
+ selector: '[uiMaskCnpjNovo][ngModel]',
4163
+ providers: [{
4164
+ provide: NG_VALUE_ACCESSOR,
4165
+ useExisting: forwardRef(() => UiMaskCnpjNovoDirective_1),
4166
+ multi: true
4167
+ }, {
4168
+ provide: NG_VALIDATORS,
4169
+ useExisting: forwardRef(() => UiMaskCnpjNovoDirective_1),
4170
+ multi: true
4171
+ }, UiCnpjNovoPipe]
4172
+ }),
4173
+ __metadata("design:paramtypes", [ElementRef, UiCnpjNovoPipe])
4174
+ ], UiMaskCnpjNovoDirective);
4175
+
3913
4176
  let UiCepPipe = class UiCepPipe {
3914
4177
  transform(value, args) {
3915
4178
  if (!value) {
@@ -10277,6 +10540,8 @@ const lib = [
10277
10540
  UiCpfPipe,
10278
10541
  UiMaskCnpjDirective,
10279
10542
  UiCnpjPipe,
10543
+ UiMaskCnpjNovoDirective,
10544
+ UiCnpjNovoPipe,
10280
10545
  UiMaskCepDirective,
10281
10546
  UiCepPipe,
10282
10547
  UiMaskCepNovoDirective,
@@ -10377,5 +10642,5 @@ SMNUIModule = __decorate([
10377
10642
  * Generated bundle index. Do not edit.
10378
10643
  */
10379
10644
 
10380
- 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 };
10645
+ 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 };
10381
10646
  //# sourceMappingURL=ng-smn-ui.js.map