pjc-fields 0.0.57 → 0.0.59
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.
- package/fesm2022/pjc-fields.mjs +35 -15
- package/fesm2022/pjc-fields.mjs.map +1 -1
- package/package.json +1 -1
package/fesm2022/pjc-fields.mjs
CHANGED
|
@@ -33,7 +33,9 @@ import { InputNumberModule } from 'primeng/inputnumber';
|
|
|
33
33
|
class PjcValidators {
|
|
34
34
|
static cpf() {
|
|
35
35
|
return (control) => {
|
|
36
|
-
|
|
36
|
+
if (typeof control.value !== 'string')
|
|
37
|
+
return null;
|
|
38
|
+
const value = control.value.replace(/\D/g, '');
|
|
37
39
|
if (!value)
|
|
38
40
|
return null;
|
|
39
41
|
if (value.length !== 11 || /^(\d)\1+$/.test(value)) {
|
|
@@ -63,7 +65,9 @@ class PjcValidators {
|
|
|
63
65
|
*/
|
|
64
66
|
static cnpj() {
|
|
65
67
|
return (control) => {
|
|
66
|
-
|
|
68
|
+
if (typeof control.value !== 'string')
|
|
69
|
+
return null;
|
|
70
|
+
const value = control.value.replace(/\D/g, '');
|
|
67
71
|
if (!value)
|
|
68
72
|
return null;
|
|
69
73
|
// CNPJ deve ter 14 dígitos e não pode ser sequência repetida
|
|
@@ -93,7 +97,9 @@ class PjcValidators {
|
|
|
93
97
|
}
|
|
94
98
|
static cpfCnpj() {
|
|
95
99
|
return (control) => {
|
|
96
|
-
|
|
100
|
+
if (typeof control.value !== 'string')
|
|
101
|
+
return null;
|
|
102
|
+
const value = control.value.replace(/\D/g, '');
|
|
97
103
|
if (!value)
|
|
98
104
|
return null;
|
|
99
105
|
if (value.length <= 11) {
|
|
@@ -106,7 +112,9 @@ class PjcValidators {
|
|
|
106
112
|
}
|
|
107
113
|
static telefone() {
|
|
108
114
|
return (control) => {
|
|
109
|
-
|
|
115
|
+
if (typeof control.value !== 'string')
|
|
116
|
+
return null;
|
|
117
|
+
const digits = control.value.replace(/\D/g, '');
|
|
110
118
|
if (!digits)
|
|
111
119
|
return null;
|
|
112
120
|
// Fixo: DDD (2) + 8 dígitos = 10 | Celular: DDD (2) + 9 dígitos = 11
|
|
@@ -123,7 +131,7 @@ class PjcValidators {
|
|
|
123
131
|
static hora() {
|
|
124
132
|
return (control) => {
|
|
125
133
|
const value = control.value;
|
|
126
|
-
if (!value)
|
|
134
|
+
if (!value || typeof value !== 'string')
|
|
127
135
|
return null;
|
|
128
136
|
const match = value.match(/^(\d{2}):(\d{2})$/);
|
|
129
137
|
if (!match)
|
|
@@ -138,7 +146,9 @@ class PjcValidators {
|
|
|
138
146
|
}
|
|
139
147
|
static placaVeiculo() {
|
|
140
148
|
return (control) => {
|
|
141
|
-
|
|
149
|
+
if (typeof control.value !== 'string')
|
|
150
|
+
return null;
|
|
151
|
+
const value = control.value.toUpperCase().replace('-', '');
|
|
142
152
|
if (!value)
|
|
143
153
|
return null;
|
|
144
154
|
// Regex para Padrão Antigo (AAA9999) e Mercosul (AAA9A99)
|
|
@@ -149,7 +159,7 @@ class PjcValidators {
|
|
|
149
159
|
static email() {
|
|
150
160
|
return (control) => {
|
|
151
161
|
const value = control.value;
|
|
152
|
-
if (!value)
|
|
162
|
+
if (!value || typeof value !== 'string')
|
|
153
163
|
return null;
|
|
154
164
|
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
|
|
155
165
|
return emailRegex.test(value) ? null : { emailInvalido: true };
|
|
@@ -157,7 +167,9 @@ class PjcValidators {
|
|
|
157
167
|
}
|
|
158
168
|
static imei() {
|
|
159
169
|
return (control) => {
|
|
160
|
-
|
|
170
|
+
if (typeof control.value !== 'string')
|
|
171
|
+
return null;
|
|
172
|
+
const digits = control.value.replace(/\D/g, '');
|
|
161
173
|
if (!digits)
|
|
162
174
|
return null;
|
|
163
175
|
if (digits.length !== 15) {
|
|
@@ -185,7 +197,9 @@ class PjcValidators {
|
|
|
185
197
|
}
|
|
186
198
|
static numeroCartao() {
|
|
187
199
|
return (control) => {
|
|
188
|
-
|
|
200
|
+
if (typeof control.value !== 'string')
|
|
201
|
+
return null;
|
|
202
|
+
const digits = control.value.replace(/\D/g, '');
|
|
189
203
|
if (!digits)
|
|
190
204
|
return null;
|
|
191
205
|
if (digits.length < 13 || digits.length > 19) {
|
|
@@ -215,7 +229,9 @@ class PjcValidators {
|
|
|
215
229
|
}
|
|
216
230
|
static renavam() {
|
|
217
231
|
return (control) => {
|
|
218
|
-
|
|
232
|
+
if (typeof control.value !== 'string')
|
|
233
|
+
return null;
|
|
234
|
+
const digits = control.value.replace(/\D/g, '');
|
|
219
235
|
if (!digits)
|
|
220
236
|
return null;
|
|
221
237
|
if (!PjcValidators.validateRenavam(digits)) {
|
|
@@ -242,7 +258,7 @@ class PjcValidators {
|
|
|
242
258
|
static chassi() {
|
|
243
259
|
return (control) => {
|
|
244
260
|
const value = control.value;
|
|
245
|
-
if (!value)
|
|
261
|
+
if (!value || typeof value !== 'string')
|
|
246
262
|
return null;
|
|
247
263
|
const chassiRegex = /^[A-HJ-NPR-Z0-9]{17}$/;
|
|
248
264
|
return chassiRegex.test(value) ? null : { chassiInvalido: true };
|
|
@@ -250,7 +266,9 @@ class PjcValidators {
|
|
|
250
266
|
}
|
|
251
267
|
static cnh() {
|
|
252
268
|
return (control) => {
|
|
253
|
-
|
|
269
|
+
if (typeof control.value !== 'string')
|
|
270
|
+
return null;
|
|
271
|
+
const digits = control.value.replace(/\D/g, '');
|
|
254
272
|
if (!digits)
|
|
255
273
|
return null;
|
|
256
274
|
if (!PjcValidators.validateCnh(digits)) {
|
|
@@ -283,7 +301,9 @@ class PjcValidators {
|
|
|
283
301
|
}
|
|
284
302
|
static cep() {
|
|
285
303
|
return (control) => {
|
|
286
|
-
|
|
304
|
+
if (typeof control.value !== 'string')
|
|
305
|
+
return null;
|
|
306
|
+
const digits = control.value.replace(/\D/g, '');
|
|
287
307
|
if (!digits)
|
|
288
308
|
return null;
|
|
289
309
|
return digits.length === 8 ? null : { cepInvalido: true };
|
|
@@ -1058,7 +1078,7 @@ class PjcCpfCnpjFieldComponent {
|
|
|
1058
1078
|
useExisting: forwardRef(() => PjcCpfCnpjFieldComponent),
|
|
1059
1079
|
multi: true,
|
|
1060
1080
|
},
|
|
1061
|
-
], ngImport: i0, template: "<div class=\"flex flex-col gap-1 w-full\">\n @if (label()) {\n <p-floatlabel [variant]=\"labelVariant()\" class=\"w-full\">\n
|
|
1081
|
+
], ngImport: i0, template: "<div class=\"flex flex-col gap-1 w-full\">\n @if (label()) {\n <p-inputgroup [class.opacity-60]=\"disabled\">\n <p-floatlabel [variant]=\"labelVariant()\" class=\"w-full\">\n <input\n pInputText\n [id]=\"id()\"\n [value]=\"displayValue\"\n (input)=\"onInputChange($event)\"\n (blur)=\"onModelTouched()\"\n [placeholder]=\"placeholder\"\n [disabled]=\"disabled\"\n [readonly]=\"readonly()\"\n [class.ng-invalid]=\"invalid\"\n [class.ng-dirty]=\"invalid\"\n maxlength=\"18\"\n class=\"w-full p-2 outline-none bg-transparent\"\n />\n <label [for]=\"id()\">{{ label() }}</label>\n </p-floatlabel>\n\n @if (showSearchButton()) {\n <p-inputgroup-addon>\n <button\n type=\"button\"\n (click)=\"onSearch()\"\n [disabled]=\"disabled || readonly()\"\n class=\"cursor-pointer bg-transparent border-none text-surface-500 hover:text-surface-700 disabled:text-surface-300 disabled:cursor-not-allowed transition-colors\"\n aria-label=\"Buscar CPF/CNPJ\"\n >\n <i class=\"pi pi-search\"></i>\n </button>\n </p-inputgroup-addon>\n }\n </p-inputgroup>\n } @else {\n <p-inputgroup [class.opacity-60]=\"disabled\">\n <input\n pInputText\n [id]=\"id()\"\n [value]=\"displayValue\"\n (input)=\"onInputChange($event)\"\n (blur)=\"onModelTouched()\"\n [placeholder]=\"placeholder\"\n [disabled]=\"disabled\"\n [class.ng-invalid]=\"invalid\"\n [class.ng-dirty]=\"invalid\"\n maxlength=\"18\"\n class=\"w-full p-2 outline-none bg-transparent border border-surface-300 rounded-md focus:border-primary-500\"\n />\n\n @if (showSearchButton()) {\n <p-inputgroup-addon>\n <button\n type=\"button\"\n (click)=\"onSearch()\"\n [disabled]=\"disabled || readonly()\"\n class=\"cursor-pointer bg-transparent border-none text-surface-500 hover:text-surface-700 disabled:text-surface-300 disabled:cursor-not-allowed transition-colors\"\n aria-label=\"Buscar CPF/CNPJ\"\n >\n <i class=\"pi pi-search\"></i>\n </button>\n </p-inputgroup-addon>\n }\n </p-inputgroup>\n }\n\n @if (errorMessage) {\n <p-message severity=\"error\" variant=\"simple\" size=\"small\">{{ errorMessage }}</p-message>\n }\n\n <ng-content></ng-content>\n</div>\n", dependencies: [{ kind: "ngmodule", type: FormsModule }, { kind: "ngmodule", type: FloatLabelModule }, { kind: "component", type: i3$1.FloatLabel, selector: "p-floatlabel, p-floatLabel, p-float-label", inputs: ["variant"] }, { kind: "ngmodule", type: InputTextModule }, { kind: "directive", type: i1$1.InputText, selector: "[pInputText]", inputs: ["hostName", "ptInputText", "pInputTextPT", "pInputTextUnstyled", "pSize", "variant", "fluid", "invalid"] }, { kind: "ngmodule", type: InputGroupModule }, { kind: "component", type: i3.InputGroup, selector: "p-inputgroup, p-inputGroup, p-input-group", inputs: ["styleClass"] }, { kind: "ngmodule", type: InputGroupAddonModule }, { kind: "component", type: i4.InputGroupAddon, selector: "p-inputgroup-addon, p-inputGroupAddon", inputs: ["style", "styleClass"] }, { kind: "ngmodule", type: MessageModule }, { kind: "component", type: i4$1.Message, selector: "p-message", inputs: ["severity", "text", "escape", "style", "styleClass", "closable", "icon", "closeIcon", "life", "showTransitionOptions", "hideTransitionOptions", "size", "variant", "motionOptions"], outputs: ["onClose"] }], changeDetection: i0.ChangeDetectionStrategy.OnPush });
|
|
1062
1082
|
}
|
|
1063
1083
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImport: i0, type: PjcCpfCnpjFieldComponent, decorators: [{
|
|
1064
1084
|
type: Component,
|
|
@@ -1073,7 +1093,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.4", ngImpor
|
|
|
1073
1093
|
useExisting: forwardRef(() => PjcCpfCnpjFieldComponent),
|
|
1074
1094
|
multi: true,
|
|
1075
1095
|
},
|
|
1076
|
-
], template: "<div class=\"flex flex-col gap-1 w-full\">\n @if (label()) {\n <p-floatlabel [variant]=\"labelVariant()\" class=\"w-full\">\n
|
|
1096
|
+
], template: "<div class=\"flex flex-col gap-1 w-full\">\n @if (label()) {\n <p-inputgroup [class.opacity-60]=\"disabled\">\n <p-floatlabel [variant]=\"labelVariant()\" class=\"w-full\">\n <input\n pInputText\n [id]=\"id()\"\n [value]=\"displayValue\"\n (input)=\"onInputChange($event)\"\n (blur)=\"onModelTouched()\"\n [placeholder]=\"placeholder\"\n [disabled]=\"disabled\"\n [readonly]=\"readonly()\"\n [class.ng-invalid]=\"invalid\"\n [class.ng-dirty]=\"invalid\"\n maxlength=\"18\"\n class=\"w-full p-2 outline-none bg-transparent\"\n />\n <label [for]=\"id()\">{{ label() }}</label>\n </p-floatlabel>\n\n @if (showSearchButton()) {\n <p-inputgroup-addon>\n <button\n type=\"button\"\n (click)=\"onSearch()\"\n [disabled]=\"disabled || readonly()\"\n class=\"cursor-pointer bg-transparent border-none text-surface-500 hover:text-surface-700 disabled:text-surface-300 disabled:cursor-not-allowed transition-colors\"\n aria-label=\"Buscar CPF/CNPJ\"\n >\n <i class=\"pi pi-search\"></i>\n </button>\n </p-inputgroup-addon>\n }\n </p-inputgroup>\n } @else {\n <p-inputgroup [class.opacity-60]=\"disabled\">\n <input\n pInputText\n [id]=\"id()\"\n [value]=\"displayValue\"\n (input)=\"onInputChange($event)\"\n (blur)=\"onModelTouched()\"\n [placeholder]=\"placeholder\"\n [disabled]=\"disabled\"\n [class.ng-invalid]=\"invalid\"\n [class.ng-dirty]=\"invalid\"\n maxlength=\"18\"\n class=\"w-full p-2 outline-none bg-transparent border border-surface-300 rounded-md focus:border-primary-500\"\n />\n\n @if (showSearchButton()) {\n <p-inputgroup-addon>\n <button\n type=\"button\"\n (click)=\"onSearch()\"\n [disabled]=\"disabled || readonly()\"\n class=\"cursor-pointer bg-transparent border-none text-surface-500 hover:text-surface-700 disabled:text-surface-300 disabled:cursor-not-allowed transition-colors\"\n aria-label=\"Buscar CPF/CNPJ\"\n >\n <i class=\"pi pi-search\"></i>\n </button>\n </p-inputgroup-addon>\n }\n </p-inputgroup>\n }\n\n @if (errorMessage) {\n <p-message severity=\"error\" variant=\"simple\" size=\"small\">{{ errorMessage }}</p-message>\n }\n\n <ng-content></ng-content>\n</div>\n" }]
|
|
1077
1097
|
}], propDecorators: { label: [{ type: i0.Input, args: [{ isSignal: true, alias: "label", required: false }] }], id: [{ type: i0.Input, args: [{ isSignal: true, alias: "id", required: false }] }], labelVariant: [{ type: i0.Input, args: [{ isSignal: true, alias: "labelVariant", required: false }] }], readonly: [{ type: i0.Input, args: [{ isSignal: true, alias: "readonly", required: false }] }], showSearchButton: [{ type: i0.Input, args: [{ isSignal: true, alias: "showSearchButton", required: false }] }], erros: [{ type: i0.Input, args: [{ isSignal: true, alias: "erros", required: false }] }], busca: [{ type: i0.Output, args: ["busca"] }] } });
|
|
1078
1098
|
|
|
1079
1099
|
class PjcCpfFieldComponent {
|