@senior-agronegocio/angular-components 0.0.55 → 0.0.57

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.
@@ -1944,23 +1944,19 @@ var AgroStringUtils = /** @class */ (function () {
1944
1944
  var remainder = sum % 11;
1945
1945
  return remainder < 2 ? 0 : 11 - remainder;
1946
1946
  };
1947
- return (calcCheckDigit(9) === Number(cpf[9]) &&
1948
- calcCheckDigit(10) === Number(cpf[10]));
1947
+ return calcCheckDigit(9) === Number(cpf[9]) && calcCheckDigit(10) === Number(cpf[10]);
1949
1948
  };
1950
1949
  AgroStringUtils.validateCNPJ = function (cnpj) {
1951
1950
  cnpj = cnpj.replace(/\D/g, "");
1952
1951
  if (cnpj.length !== 14 || /^(\d)\1{13}$/.test(cnpj))
1953
1952
  return false;
1954
1953
  var calcularDigito = function (length) {
1955
- var pesos = length === 12
1956
- ? [5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2]
1957
- : [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2];
1954
+ var pesos = length === 12 ? [5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2] : [6, 5, 4, 3, 2, 9, 8, 7, 6, 5, 4, 3, 2];
1958
1955
  var soma = pesos.reduce(function (acc, peso, i) { return acc + Number(cnpj[i]) * peso; }, 0);
1959
1956
  var resto = soma % 11;
1960
1957
  return resto < 2 ? 0 : 11 - resto;
1961
1958
  };
1962
- return (calcularDigito(12) === Number(cnpj[12]) &&
1963
- calcularDigito(13) === Number(cnpj[13]));
1959
+ return calcularDigito(12) === Number(cnpj[12]) && calcularDigito(13) === Number(cnpj[13]);
1964
1960
  };
1965
1961
  /**
1966
1962
  * Método para aplicar uma máscara em uma string. Considere a máscara com valores 9 para aplicação
@@ -2029,6 +2025,16 @@ var AgroStringUtils = /** @class */ (function () {
2029
2025
  AgroStringUtils.isValidEmail = function (email) {
2030
2026
  return AGRO_REGEX.isEmail.test(email);
2031
2027
  };
2028
+ /**
2029
+ * Valida se uma string é uma placa de veículo BR válida ou não.
2030
+ * Retorna um booleano para indicar se é uma placa válida ou não.
2031
+ * @param plate - A string a ser verificada
2032
+ */
2033
+ AgroStringUtils.isValidLicensePlate = function (plate) {
2034
+ var oldFormat = /^[A-Z]{3}-?\d{4}$/;
2035
+ var mercosulFormat = /^[A-Z]{3}\d[A-Z]\d{2}$/;
2036
+ return oldFormat.test(plate) || mercosulFormat.test(plate);
2037
+ };
2032
2038
  return AgroStringUtils;
2033
2039
  }());
2034
2040
 
@@ -2074,10 +2080,11 @@ var AgroPlatformUtils = /** @class */ (function () {
2074
2080
  */
2075
2081
  AgroPlatformUtils.getCurrentUserName = function () {
2076
2082
  var _a;
2077
- var cookie = AgroCookieUtils.getCookie('com.senior.token');
2083
+ var cookie = AgroCookieUtils.getCookie('com.senior.token', true);
2078
2084
  if (cookie) {
2079
- var str = (_a = AgroCookieUtils.parseCookieToObject(cookie)) === null || _a === void 0 ? void 0 : _a.fullName;
2085
+ var str = (_a = AgroObjectUtils.fromString(cookie)) === null || _a === void 0 ? void 0 : _a.fullName;
2080
2086
  if (str) {
2087
+ str = str.replace(/\+/g, ' ');
2081
2088
  return str;
2082
2089
  }
2083
2090
  }
@@ -2090,9 +2097,9 @@ var AgroPlatformUtils = /** @class */ (function () {
2090
2097
  */
2091
2098
  AgroPlatformUtils.getCurrentUserEmail = function () {
2092
2099
  var _a;
2093
- var cookie = AgroCookieUtils.getCookie('com.senior.token');
2100
+ var cookie = AgroCookieUtils.getCookie('com.senior.token', true);
2094
2101
  if (cookie) {
2095
- var str = (_a = AgroCookieUtils.parseCookieToObject(cookie)) === null || _a === void 0 ? void 0 : _a.email;
2102
+ var str = (_a = AgroObjectUtils.fromString(cookie)) === null || _a === void 0 ? void 0 : _a.email;
2096
2103
  if (str) {
2097
2104
  return str;
2098
2105
  }
@@ -2690,6 +2697,17 @@ var AgroFormValidator = /** @class */ (function () {
2690
2697
  }
2691
2698
  return AgroStringUtils.validateCNPJ(cnpj) ? null : { cnpjValidator: true };
2692
2699
  };
2700
+ /**
2701
+ * Verifica se a string informada é uma placa de veículo válido.
2702
+ * Se a validação for false, retorna um objeto com a chave licensePlate.
2703
+ */
2704
+ AgroFormValidator.licensePlateValidator = function (control) {
2705
+ var plate = control.value;
2706
+ if (!plate) {
2707
+ return null;
2708
+ }
2709
+ return AgroStringUtils.isValidLicensePlate(plate) ? null : { licensePlate: true };
2710
+ };
2693
2711
  return AgroFormValidator;
2694
2712
  }());
2695
2713