ng-tailwind 6.4.6 → 6.4.8
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.
|
@@ -67,7 +67,7 @@ export declare class NgtDropzoneComponent extends NgtBaseNgModel implements OnIn
|
|
|
67
67
|
ngAfterContentChecked(): void;
|
|
68
68
|
ngOnInit(): void;
|
|
69
69
|
ngOnDestroy(): void;
|
|
70
|
-
imagePreview(
|
|
70
|
+
imagePreview(uploadedResourcesIndex: number): void;
|
|
71
71
|
onImageClick(element: any, index?: any): void;
|
|
72
72
|
onFileClick(url: string, name: string, size: number): void;
|
|
73
73
|
onSelect(event: NgxDropzoneChangeEvent): Promise<void>;
|
|
@@ -115,10 +115,15 @@ export declare class NgtInputComponent extends NgtBaseNgModel implements OnInit,
|
|
|
115
115
|
private validatePhone;
|
|
116
116
|
private uniqueValidator;
|
|
117
117
|
private validatorCNPJ;
|
|
118
|
+
private validatorNumericCNPJ;
|
|
119
|
+
private validatorAlphaNumericCNPJ;
|
|
120
|
+
private getCnpjVerificationDigit;
|
|
121
|
+
private getCnpjCharacterValue;
|
|
118
122
|
private validatorCPF;
|
|
119
123
|
private getNativeValue;
|
|
120
124
|
private getElementTitle;
|
|
121
125
|
private removeMasks;
|
|
126
|
+
private normalizeDocument;
|
|
122
127
|
private hasEmailServiceValidation;
|
|
123
128
|
private hasPasswordValidation;
|
|
124
129
|
private isDisabledByParent;
|
package/fesm2022/ng-tailwind.mjs
CHANGED
|
@@ -2450,15 +2450,23 @@ class NgtInputComponent extends NgtBaseNgModel {
|
|
|
2450
2450
|
removeInputMask(this.element.nativeElement);
|
|
2451
2451
|
return this.clearInput();
|
|
2452
2452
|
}
|
|
2453
|
+
const cnpjMaskPattern = 'XX.XXX.XXX/XXXX-99';
|
|
2454
|
+
const cnpjMaskParameters = {
|
|
2455
|
+
mask: [cnpjMaskPattern],
|
|
2456
|
+
definitions: {
|
|
2457
|
+
X: {
|
|
2458
|
+
validator: '[0-9A-Za-z]',
|
|
2459
|
+
casing: 'upper'
|
|
2460
|
+
}
|
|
2461
|
+
},
|
|
2462
|
+
showMaskOnHover: false
|
|
2463
|
+
};
|
|
2453
2464
|
let masks = {
|
|
2454
2465
|
[InputMaskEnum.CPF]: {
|
|
2455
2466
|
mask: ['999.999.999-99'],
|
|
2456
2467
|
showMaskOnHover: false
|
|
2457
2468
|
},
|
|
2458
|
-
[InputMaskEnum.CNPJ]:
|
|
2459
|
-
mask: ['99.999.999/9999-99'],
|
|
2460
|
-
showMaskOnHover: false
|
|
2461
|
-
},
|
|
2469
|
+
[InputMaskEnum.CNPJ]: cnpjMaskParameters,
|
|
2462
2470
|
[InputMaskEnum.CUIT]: {
|
|
2463
2471
|
mask: ['99-99999999-9'],
|
|
2464
2472
|
clearMaskOnLostFocus: false
|
|
@@ -2468,13 +2476,15 @@ class NgtInputComponent extends NgtBaseNgModel {
|
|
|
2468
2476
|
clearMaskOnLostFocus: false
|
|
2469
2477
|
},
|
|
2470
2478
|
[InputMaskEnum.CPF_CNPJ_RUT]: {
|
|
2471
|
-
mask: ['999.999.999-99', '999999999999',
|
|
2479
|
+
mask: ['999.999.999-99', '999999999999', cnpjMaskPattern],
|
|
2472
2480
|
keepStatic: true,
|
|
2481
|
+
definitions: cnpjMaskParameters.definitions,
|
|
2473
2482
|
showMaskOnHover: false
|
|
2474
2483
|
},
|
|
2475
2484
|
[InputMaskEnum.CPF_CNPJ]: {
|
|
2476
|
-
mask: ['999.999.999-99',
|
|
2485
|
+
mask: ['999.999.999-99', cnpjMaskPattern],
|
|
2477
2486
|
keepStatic: true,
|
|
2487
|
+
definitions: cnpjMaskParameters.definitions,
|
|
2478
2488
|
showMaskOnHover: false
|
|
2479
2489
|
},
|
|
2480
2490
|
[InputMaskEnum.DECIMAL]: {
|
|
@@ -2603,19 +2613,20 @@ class NgtInputComponent extends NgtBaseNgModel {
|
|
|
2603
2613
|
if (!control.value) {
|
|
2604
2614
|
return null;
|
|
2605
2615
|
}
|
|
2606
|
-
|
|
2607
|
-
|
|
2616
|
+
const normalizedDocument = this.removeMasks(control.value);
|
|
2617
|
+
if (normalizedDocument && normalizedDocument.length <= 11) {
|
|
2618
|
+
if (this.validatorCPF(normalizedDocument)) {
|
|
2608
2619
|
return null;
|
|
2609
2620
|
}
|
|
2610
2621
|
else {
|
|
2611
2622
|
return { 'cpf': true };
|
|
2612
2623
|
}
|
|
2613
2624
|
}
|
|
2614
|
-
else if (
|
|
2625
|
+
else if (normalizedDocument && normalizedDocument.length == 12) {
|
|
2615
2626
|
return null;
|
|
2616
2627
|
}
|
|
2617
2628
|
else {
|
|
2618
|
-
if (
|
|
2629
|
+
if (normalizedDocument && this.validatorCNPJ(normalizedDocument)) {
|
|
2619
2630
|
return null;
|
|
2620
2631
|
}
|
|
2621
2632
|
else {
|
|
@@ -2735,7 +2746,16 @@ class NgtInputComponent extends NgtBaseNgModel {
|
|
|
2735
2746
|
};
|
|
2736
2747
|
}
|
|
2737
2748
|
validatorCNPJ(value) {
|
|
2738
|
-
|
|
2749
|
+
const normalizedValue = this.normalizeDocument(value);
|
|
2750
|
+
if (normalizedValue.length != 14) {
|
|
2751
|
+
return false;
|
|
2752
|
+
}
|
|
2753
|
+
return /[A-Z]/.test(normalizedValue)
|
|
2754
|
+
? this.validatorAlphaNumericCNPJ(normalizedValue)
|
|
2755
|
+
: this.validatorNumericCNPJ(normalizedValue);
|
|
2756
|
+
}
|
|
2757
|
+
validatorNumericCNPJ(value) {
|
|
2758
|
+
const b = [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2];
|
|
2739
2759
|
if ((value = value.replace(/[^\d]/g, "")).length != 14) {
|
|
2740
2760
|
return false;
|
|
2741
2761
|
}
|
|
@@ -2743,22 +2763,46 @@ class NgtInputComponent extends NgtBaseNgModel {
|
|
|
2743
2763
|
return false;
|
|
2744
2764
|
}
|
|
2745
2765
|
let n = 0;
|
|
2746
|
-
for (let i = 0; i < 12;
|
|
2747
|
-
;
|
|
2766
|
+
for (let i = 0; i < 12; i++) {
|
|
2767
|
+
n += Number(value[i]) * b[i + 1];
|
|
2748
2768
|
}
|
|
2749
|
-
if (value[12] != (((n %= 11) < 2) ? 0 : 11 - n)) {
|
|
2769
|
+
if (Number(value[12]) != (((n %= 11) < 2) ? 0 : 11 - n)) {
|
|
2750
2770
|
return false;
|
|
2751
2771
|
}
|
|
2752
2772
|
n = 0;
|
|
2753
|
-
for (let i = 0; i <= 12;
|
|
2754
|
-
;
|
|
2773
|
+
for (let i = 0; i <= 12; i++) {
|
|
2774
|
+
n += Number(value[i]) * b[i];
|
|
2755
2775
|
}
|
|
2756
|
-
if (value[13] != (((n %= 11) < 2) ? 0 : 11 - n)) {
|
|
2776
|
+
if (Number(value[13]) != (((n %= 11) < 2) ? 0 : 11 - n)) {
|
|
2757
2777
|
return false;
|
|
2758
2778
|
}
|
|
2759
2779
|
return true;
|
|
2760
2780
|
}
|
|
2761
|
-
|
|
2781
|
+
validatorAlphaNumericCNPJ(value) {
|
|
2782
|
+
if (!/^[A-Z0-9]{12}[0-9]{2}$/.test(value)) {
|
|
2783
|
+
return false;
|
|
2784
|
+
}
|
|
2785
|
+
const firstWeights = [5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2];
|
|
2786
|
+
const firstDigit = this.getCnpjVerificationDigit(value.substring(0, 12), firstWeights);
|
|
2787
|
+
if (firstDigit !== Number(value[12])) {
|
|
2788
|
+
return false;
|
|
2789
|
+
}
|
|
2790
|
+
const secondWeights = [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2];
|
|
2791
|
+
const secondDigit = this.getCnpjVerificationDigit(`${value.substring(0, 12)}${firstDigit}`, secondWeights);
|
|
2792
|
+
return secondDigit === Number(value[13]);
|
|
2793
|
+
}
|
|
2794
|
+
getCnpjVerificationDigit(value, weights) {
|
|
2795
|
+
const weightedTotal = value
|
|
2796
|
+
.split('')
|
|
2797
|
+
.reduce((total, currentValue, index) => total + (this.getCnpjCharacterValue(currentValue) * weights[index]), 0);
|
|
2798
|
+
const modulo = weightedTotal % 11;
|
|
2799
|
+
return modulo < 2 ? 0 : 11 - modulo;
|
|
2800
|
+
}
|
|
2801
|
+
getCnpjCharacterValue(value) {
|
|
2802
|
+
return /^[0-9]$/.test(value)
|
|
2803
|
+
? Number(value)
|
|
2804
|
+
: value.charCodeAt(0) - 48;
|
|
2805
|
+
}
|
|
2762
2806
|
validatorCPF(value) {
|
|
2763
2807
|
let numeros, digitos, soma, i, resultado, digitos_iguais;
|
|
2764
2808
|
digitos_iguais = 1;
|
|
@@ -2810,8 +2854,10 @@ class NgtInputComponent extends NgtBaseNgModel {
|
|
|
2810
2854
|
.replace(',', '.');
|
|
2811
2855
|
}
|
|
2812
2856
|
else if (this.mask == "cnpj-cpf" || this.mask == "cpf" || this.mask == "cnpj" || this.mask == "cnpj-cpf-rut" || this.mask == "cuit") {
|
|
2813
|
-
value = (value
|
|
2814
|
-
|
|
2857
|
+
value = this.normalizeDocument(value);
|
|
2858
|
+
if (this.mask == "cpf" || this.mask == "cuit") {
|
|
2859
|
+
value = value.replace(/[^\d]/g, '');
|
|
2860
|
+
}
|
|
2815
2861
|
}
|
|
2816
2862
|
else if (this.mask == InputMaskEnum.CELLPHONE
|
|
2817
2863
|
|| this.mask == InputMaskEnum.INTERNATIONAL_PHONE) {
|
|
@@ -2825,6 +2871,12 @@ class NgtInputComponent extends NgtBaseNgModel {
|
|
|
2825
2871
|
}
|
|
2826
2872
|
return value;
|
|
2827
2873
|
}
|
|
2874
|
+
normalizeDocument(value) {
|
|
2875
|
+
return (value || '')
|
|
2876
|
+
.toString()
|
|
2877
|
+
.toUpperCase()
|
|
2878
|
+
.replace(/[^A-Z0-9]/g, '');
|
|
2879
|
+
}
|
|
2828
2880
|
hasEmailServiceValidation() {
|
|
2829
2881
|
return typeof this.ngtValidationService?.emailValidation === 'function';
|
|
2830
2882
|
}
|
|
@@ -7926,15 +7978,17 @@ class NgtDropzoneComponent extends NgtBaseNgModel {
|
|
|
7926
7978
|
ngOnDestroy() {
|
|
7927
7979
|
this.destroySubscriptions();
|
|
7928
7980
|
}
|
|
7929
|
-
imagePreview(
|
|
7981
|
+
imagePreview(uploadedResourcesIndex) {
|
|
7930
7982
|
const images = this.uploadedResources.filter((resource) => this.isImage(resource));
|
|
7931
|
-
const imagesDiv = document.createElement(
|
|
7983
|
+
const imagesDiv = document.createElement('div');
|
|
7932
7984
|
images.forEach((image) => {
|
|
7933
|
-
let imageElement = document.createElement(
|
|
7985
|
+
let imageElement = document.createElement('img');
|
|
7934
7986
|
imageElement.src = image.file.url;
|
|
7935
7987
|
imagesDiv.appendChild(imageElement);
|
|
7936
7988
|
});
|
|
7937
|
-
this.
|
|
7989
|
+
const clickedResource = this.uploadedResources[uploadedResourcesIndex];
|
|
7990
|
+
const imageIndexInGallery = images.indexOf(clickedResource);
|
|
7991
|
+
this.onImageClick(imagesDiv, imageIndexInGallery >= 0 ? imageIndexInGallery : 0);
|
|
7938
7992
|
}
|
|
7939
7993
|
onImageClick(element, index) {
|
|
7940
7994
|
if (!this.viewMode) {
|