@senior-agronegocio/angular-components 0.0.50 → 0.0.52
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/bundles/senior-agronegocio-angular-components.umd.js +24 -60
- package/bundles/senior-agronegocio-angular-components.umd.js.map +1 -1
- package/bundles/senior-agronegocio-angular-components.umd.min.js +2 -2
- package/bundles/senior-agronegocio-angular-components.umd.min.js.map +1 -1
- package/common/agro-platform-utils.class.d.ts +1 -1
- package/esm2015/common/agro-platform-utils.class.js +2 -3
- package/esm2015/common/agro-string-utils.class.js +23 -58
- package/esm2015/components/event-control-board/event-control-board.component.js +2 -2
- package/esm5/common/agro-platform-utils.class.js +2 -3
- package/esm5/common/agro-string-utils.class.js +23 -58
- package/esm5/components/event-control-board/event-control-board.component.js +2 -2
- package/fesm2015/senior-agronegocio-angular-components.js +24 -60
- package/fesm2015/senior-agronegocio-angular-components.js.map +1 -1
- package/fesm5/senior-agronegocio-angular-components.js +24 -60
- package/fesm5/senior-agronegocio-angular-components.js.map +1 -1
- package/package.json +1 -1
|
@@ -2166,70 +2166,35 @@ var AgroStringUtils = /** @class */ (function () {
|
|
|
2166
2166
|
return matches ? matches.length : AGRO_NUMBERS.ZERO;
|
|
2167
2167
|
};
|
|
2168
2168
|
AgroStringUtils.validateCPF = function (cpf) {
|
|
2169
|
-
// Remover caracteres não numéricos
|
|
2170
2169
|
cpf = cpf.replace(/\D/g, "");
|
|
2171
|
-
|
|
2172
|
-
if (cpf.length !== AGRO_NUMBERS.ELEVEN) {
|
|
2170
|
+
if (cpf.length !== 11 || /^(\d)\1{10}$/.test(cpf)) {
|
|
2173
2171
|
return false;
|
|
2174
2172
|
}
|
|
2175
|
-
|
|
2176
|
-
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
|
|
2182
|
-
|
|
2183
|
-
|
|
2184
|
-
|
|
2185
|
-
remainder = sum % AGRO_NUMBERS.ELEVEN;
|
|
2186
|
-
if (remainder === AGRO_NUMBERS.TEN || remainder === AGRO_NUMBERS.ELEVEN) {
|
|
2187
|
-
remainder = AGRO_NUMBERS.ZERO;
|
|
2188
|
-
}
|
|
2189
|
-
if (remainder !== parseInt(cpf[AGRO_NUMBERS.NINE])) {
|
|
2190
|
-
return false;
|
|
2191
|
-
}
|
|
2192
|
-
// Calcular o segundo dígito verificador
|
|
2193
|
-
sum = AGRO_NUMBERS.ZERO;
|
|
2194
|
-
for (var i = AGRO_NUMBERS.ONE; i <= AGRO_NUMBERS.TEN; i++) {
|
|
2195
|
-
sum += parseInt(cpf[i - AGRO_NUMBERS.ONE]) * (AGRO_NUMBERS.TWELVE - i);
|
|
2196
|
-
}
|
|
2197
|
-
remainder = sum % AGRO_NUMBERS.ELEVEN;
|
|
2198
|
-
if (remainder === AGRO_NUMBERS.TEN || remainder === AGRO_NUMBERS.ELEVEN) {
|
|
2199
|
-
remainder = AGRO_NUMBERS.ZERO;
|
|
2200
|
-
}
|
|
2201
|
-
if (remainder !== parseInt(cpf[AGRO_NUMBERS.TEN])) {
|
|
2202
|
-
return false;
|
|
2203
|
-
}
|
|
2204
|
-
return true;
|
|
2173
|
+
var calcCheckDigit = function (length) {
|
|
2174
|
+
var sum = 0;
|
|
2175
|
+
for (var i = 0; i < length; i++) {
|
|
2176
|
+
sum += Number(cpf[i]) * (length + 1 - i);
|
|
2177
|
+
}
|
|
2178
|
+
var remainder = sum % 11;
|
|
2179
|
+
return remainder < 2 ? 0 : 11 - remainder;
|
|
2180
|
+
};
|
|
2181
|
+
return (calcCheckDigit(9) === Number(cpf[9]) &&
|
|
2182
|
+
calcCheckDigit(10) === Number(cpf[10]));
|
|
2205
2183
|
};
|
|
2206
2184
|
AgroStringUtils.validateCNPJ = function (cnpj) {
|
|
2207
|
-
// Remove todos os caracteres não numéricos
|
|
2208
2185
|
cnpj = cnpj.replace(/\D/g, "");
|
|
2209
|
-
|
|
2210
|
-
if (cnpj.length !== 14)
|
|
2211
|
-
return false;
|
|
2212
|
-
// Verifica se o CNPJ é uma sequência repetida (ex: 11111111111111, 22222222222222, etc.)
|
|
2213
|
-
if (/^(\d)\1{13}$/.test(cnpj))
|
|
2186
|
+
if (cnpj.length !== 14 || /^(\d)\1{13}$/.test(cnpj))
|
|
2214
2187
|
return false;
|
|
2215
|
-
|
|
2216
|
-
|
|
2217
|
-
|
|
2218
|
-
|
|
2219
|
-
soma
|
|
2220
|
-
|
|
2221
|
-
|
|
2222
|
-
|
|
2223
|
-
|
|
2224
|
-
|
|
2225
|
-
var pesos2 = [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2];
|
|
2226
|
-
for (var i = 0; i < 13; i++) {
|
|
2227
|
-
soma += parseInt(cnpj.charAt(i)) * pesos2[i];
|
|
2228
|
-
}
|
|
2229
|
-
resto = soma % 11;
|
|
2230
|
-
var digito2 = resto < 2 ? 0 : 11 - resto;
|
|
2231
|
-
// Verifica se os dígitos verificadores são válidos
|
|
2232
|
-
return parseInt(cnpj.charAt(12)) === digito1 && parseInt(cnpj.charAt(13)) === digito2;
|
|
2188
|
+
var calcularDigito = function (length) {
|
|
2189
|
+
var pesos = length === 12
|
|
2190
|
+
? [5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2]
|
|
2191
|
+
: [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2];
|
|
2192
|
+
var soma = pesos.reduce(function (acc, peso, i) { return acc + Number(cnpj[i]) * peso; }, 0);
|
|
2193
|
+
var resto = soma % 11;
|
|
2194
|
+
return resto < 2 ? 0 : 11 - resto;
|
|
2195
|
+
};
|
|
2196
|
+
return (calcularDigito(12) === Number(cnpj[12]) &&
|
|
2197
|
+
calcularDigito(13) === Number(cnpj[13]));
|
|
2233
2198
|
};
|
|
2234
2199
|
/**
|
|
2235
2200
|
* Método para aplicar uma máscara em uma string. Considere a máscara com valores 9 para aplicação
|
|
@@ -2330,7 +2295,7 @@ var AgroPlatformUtils = /** @class */ (function () {
|
|
|
2330
2295
|
/**
|
|
2331
2296
|
* Retorna o usuário logado
|
|
2332
2297
|
* Caso contrário, retorna uma instância de Error
|
|
2333
|
-
* @returns string ||
|
|
2298
|
+
* @returns string || null
|
|
2334
2299
|
*/
|
|
2335
2300
|
AgroPlatformUtils.getCurrentUserName = function () {
|
|
2336
2301
|
var _a;
|
|
@@ -2341,7 +2306,6 @@ var AgroPlatformUtils = /** @class */ (function () {
|
|
|
2341
2306
|
return str;
|
|
2342
2307
|
}
|
|
2343
2308
|
}
|
|
2344
|
-
console.error('Cookie: "com.senior.token" não encontrado.');
|
|
2345
2309
|
return null;
|
|
2346
2310
|
};
|
|
2347
2311
|
/**
|
|
@@ -4520,7 +4484,7 @@ var EventControlBoardComponent = /** @class */ (function () {
|
|
|
4520
4484
|
this.ngUnsubscribe.next();
|
|
4521
4485
|
this.ngUnsubscribe.complete();
|
|
4522
4486
|
this.websocketService.disconnect();
|
|
4523
|
-
this.socketConnection
|
|
4487
|
+
this.socketConnection = false;
|
|
4524
4488
|
};
|
|
4525
4489
|
EventControlBoardComponent.prototype.callWebsocket = function () {
|
|
4526
4490
|
var _this = this;
|