@jvsoft/utils 1.0.0-alpha.10 → 1.0.0-alpha.12

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.
@@ -7,8 +7,7 @@ import CryptoJS from 'crypto-js';
7
7
  import { formatDate } from '@angular/common';
8
8
  import { saveAs } from 'file-saver';
9
9
  import { Validators, FormGroup, FormControl, FormArray } from '@angular/forms';
10
- import { ReactiveFormConfig } from '@rxweb/reactive-form-validators';
11
- import moment from 'moment';
10
+ import { format, differenceInSeconds } from 'date-fns';
12
11
  import swal from 'sweetalert2';
13
12
  import { jwtDecode } from 'jwt-decode';
14
13
 
@@ -1114,15 +1113,6 @@ function getFormValidationErrors(form) {
1114
1113
  function mensajesErrorFormControl(control) {
1115
1114
  if (!control || !control.errors || !control.touched)
1116
1115
  return '';
1117
- ReactiveFormConfig.set({
1118
- // RxwebValidators
1119
- validationMessage: {
1120
- required: 'Es requerido',
1121
- numeric: 'Debe ser numérico valido',
1122
- // minLength: 'minimum length is {{1}}',
1123
- // maxLength: 'allowed max length is {{1}}',
1124
- },
1125
- });
1126
1116
  const errorMessages = {
1127
1117
  required: 'Es requerido',
1128
1118
  numeric: 'Debe ser numérico válido',
@@ -1238,7 +1228,7 @@ function transformarFechasPorNombreDeCampo(formValue) {
1238
1228
  }
1239
1229
  if (value instanceof Date) {
1240
1230
  if (/^d[A-Za-z]+/.test(key)) {
1241
- retData[key] = moment(value).format('YYYY-MM-DD');
1231
+ retData[key] = format(value, 'yyyy-MM-dd');
1242
1232
  }
1243
1233
  else {
1244
1234
  retData[key] = new Date(Date.UTC(value.getFullYear(), value.getMonth(), value.getDate(), value.getHours(), value.getMinutes(), value.getSeconds()));
@@ -1518,7 +1508,7 @@ function jwtTokenExpiracion(key = dataSessionStorageKey.tokenStringKey) {
1518
1508
  }
1519
1509
  }
1520
1510
  function jwtTokenExpiracionFaltante() {
1521
- return Math.abs(moment().diff(jwtTokenExpiracion(), 'seconds'));
1511
+ return Math.abs(differenceInSeconds(new Date(), jwtTokenExpiracion()));
1522
1512
  }
1523
1513
  function setCambiarPwd(accion = true) {
1524
1514
  localStorage.setItem(dataSessionStorageKey.changePasswordKey, (accion ? 1 : 0).toString());
@@ -1716,6 +1706,21 @@ function obtenerHostDesdeUrl(url, options) {
1716
1706
  }
1717
1707
  /** @deprecated Alias compatible (deprecated) — preferir usar `obtenerHostDesdeUrl`. */
1718
1708
  const extraerDominio = (url, options) => obtenerHostDesdeUrl(url, options);
1709
+ /**
1710
+ * Genera un hash numérico simple a partir de una cadena (versión ligera de shorthash2).
1711
+ * Útil para generar identificadores únicos deterministas basados en contenido.
1712
+ * @param str Cadena a hashear
1713
+ * @returns Hash alfanumérico en base 36
1714
+ */
1715
+ function simpleHash(str) {
1716
+ let hash = 0;
1717
+ for (let i = 0; i < str.length; i++) {
1718
+ const char = str.charCodeAt(i);
1719
+ hash = ((hash << 5) - hash) + char;
1720
+ hash = hash & hash; // Convertir a entero de 32 bits
1721
+ }
1722
+ return Math.abs(hash).toString(36);
1723
+ }
1719
1724
 
1720
1725
  function verificarRUC(ruc) {
1721
1726
  const f = [5, 4, 3, 2, 7, 6, 5, 4, 3, 2];
@@ -1740,5 +1745,5 @@ function verificarRUC(ruc) {
1740
1745
  * Generated bundle index. Do not edit.
1741
1746
  */
1742
1747
 
1743
- export { b64Decode, b64Encode, buscarPorCampo, changeSelect, changeSelectApi, changeSelectData, changeSelectDataApi, changeSelectReformateado, convertirBytes, decodeBase64Object, decodeBase64String, decodeBase64ToBlob, deepClone, deepMerge, delLocalStorage, desencriptar, devError, devGroup, devGroupEnd, devLog, devTable, devTime, devTimeEnd, devWarn, downLoadFileStream, eliminarColumnaPorIndex, eliminarDuplicados, eliminarElementos, encodeBase64File, encodeBase64Object, encodeBase64String, encriptar, esNumero, esPromise, establecerQuitarRequired, extraerDominio, filtrarDatosLocal, formatearFecha, formatearFechaCadena, formatearFechaFormato, generateRandomString, getBrowserName, getCambiarPwd, getDataArchivoFromPath, getFormValidationErrors, getLocalStorage, getUniqueValues, getUniqueValuesByProperty, getValueByPath, groupBy, inicializarVariablesSessionStorage, isEmail, isProduction, jwtToken, jwtTokenData, jwtTokenExpiracion, jwtTokenExpiracionFaltante, localStorageKeys, markAsTouchedWithoutEmitEvent, maskEmail, mensajeAlerta, mensajeConfirmacion, mensajeTimer, mensajeToast, mensajesDeError, mensajesErrorFormControl, mostrarValorEnBusqueda, nestGroupsBy, numberToWords, objectPropertiesBoolean, objectPropertiesToType, obtenerHostDesdeUrl, obtenerMimeType, obtenerUltimoOrden, ordenarArray, ordenarPorPropiedad, ordenarPorPropiedades, roundToDecimal, sanitizarNombreArchivo, seleccionarTextoInput, setCambiarPwd, setControlDesdeLista, setJwtTokenData, setLocalStorage, setProductionMode, sumarObjetos, sumarPropiedades, toFormData, transformarFechasPorNombreDeCampo, verificarRUC };
1748
+ export { b64Decode, b64Encode, buscarPorCampo, changeSelect, changeSelectApi, changeSelectData, changeSelectDataApi, changeSelectReformateado, convertirBytes, decodeBase64Object, decodeBase64String, decodeBase64ToBlob, deepClone, deepMerge, delLocalStorage, desencriptar, devError, devGroup, devGroupEnd, devLog, devTable, devTime, devTimeEnd, devWarn, downLoadFileStream, eliminarColumnaPorIndex, eliminarDuplicados, eliminarElementos, encodeBase64File, encodeBase64Object, encodeBase64String, encriptar, esNumero, esPromise, establecerQuitarRequired, extraerDominio, filtrarDatosLocal, formatearFecha, formatearFechaCadena, formatearFechaFormato, generateRandomString, getBrowserName, getCambiarPwd, getDataArchivoFromPath, getFormValidationErrors, getLocalStorage, getUniqueValues, getUniqueValuesByProperty, getValueByPath, groupBy, inicializarVariablesSessionStorage, isEmail, isProduction, jwtToken, jwtTokenData, jwtTokenExpiracion, jwtTokenExpiracionFaltante, localStorageKeys, markAsTouchedWithoutEmitEvent, maskEmail, mensajeAlerta, mensajeConfirmacion, mensajeTimer, mensajeToast, mensajesDeError, mensajesErrorFormControl, mostrarValorEnBusqueda, nestGroupsBy, numberToWords, objectPropertiesBoolean, objectPropertiesToType, obtenerHostDesdeUrl, obtenerMimeType, obtenerUltimoOrden, ordenarArray, ordenarPorPropiedad, ordenarPorPropiedades, roundToDecimal, sanitizarNombreArchivo, seleccionarTextoInput, setCambiarPwd, setControlDesdeLista, setJwtTokenData, setLocalStorage, setProductionMode, simpleHash, sumarObjetos, sumarPropiedades, toFormData, transformarFechasPorNombreDeCampo, verificarRUC };
1744
1749
  //# sourceMappingURL=jvsoft-utils-functions.mjs.map