@jvsoft/utils 0.0.13-alpha.1 → 0.0.13-alpha.2

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.
Files changed (119) hide show
  1. package/classes/data-model.d.ts +25 -0
  2. package/fesm2022/jvsoft-utils-src-functions.mjs +1109 -0
  3. package/fesm2022/jvsoft-utils-src-functions.mjs.map +1 -0
  4. package/fesm2022/jvsoft-utils-src-interfaces.mjs +6 -0
  5. package/fesm2022/jvsoft-utils-src-interfaces.mjs.map +1 -0
  6. package/fesm2022/jvsoft-utils-src-pipes.mjs +290 -0
  7. package/fesm2022/jvsoft-utils-src-pipes.mjs.map +1 -0
  8. package/fesm2022/jvsoft-utils.mjs +1526 -0
  9. package/fesm2022/jvsoft-utils.mjs.map +1 -0
  10. package/functions/base64.d.ts +2 -0
  11. package/functions/browser.d.ts +1 -0
  12. package/functions/crypto-js.d.ts +2 -0
  13. package/functions/date.d.ts +3 -0
  14. package/functions/email.d.ts +2 -0
  15. package/functions/file.d.ts +10 -0
  16. package/functions/forms.d.ts +10 -0
  17. package/functions/http-client.d.ts +2 -0
  18. package/functions/index.d.ts +1 -0
  19. package/functions/local-storage.d.ts +29 -0
  20. package/functions/mat-form-controls/autocomplete.d.ts +21 -0
  21. package/functions/mat-form-controls/index.d.ts +2 -0
  22. package/functions/number.d.ts +1 -0
  23. package/functions/object-transformation.d.ts +2 -0
  24. package/functions/objects-arrays.d.ts +37 -0
  25. package/functions/public-api.d.ts +16 -0
  26. package/functions/string.d.ts +1 -0
  27. package/functions/sweetalert.d.ts +5 -0
  28. package/functions/utiles.d.ts +1 -0
  29. package/index.d.ts +5 -0
  30. package/{src/interfaces/datos.ts → interfaces/datos.d.ts} +1 -2
  31. package/interfaces/index.d.ts +1 -0
  32. package/interfaces/public-api.d.ts +1 -0
  33. package/package.json +25 -2
  34. package/pipes/data-en-lista.pipe.d.ts +8 -0
  35. package/pipes/date-diff-string.pipe.d.ts +17 -0
  36. package/pipes/filtro.pipe.d.ts +18 -0
  37. package/pipes/form-control-is-required.pipe.d.ts +9 -0
  38. package/pipes/index.d.ts +1 -0
  39. package/pipes/json-parse.pipe.d.ts +7 -0
  40. package/pipes/no-sanitize.pipe.d.ts +10 -0
  41. package/pipes/public-api.d.ts +8 -0
  42. package/pipes/tipo-valor-funcion.pipe.d.ts +9 -0
  43. package/pipes/zero-fill.pipe.d.ts +8 -0
  44. package/public-api.d.ts +4 -0
  45. package/src/functions/base64.d.ts +2 -0
  46. package/src/functions/browser.d.ts +1 -0
  47. package/src/functions/crypto-js.d.ts +2 -0
  48. package/src/functions/date.d.ts +3 -0
  49. package/src/functions/email.d.ts +2 -0
  50. package/src/functions/file.d.ts +10 -0
  51. package/src/functions/forms.d.ts +10 -0
  52. package/src/functions/http-client.d.ts +2 -0
  53. package/src/functions/index.d.ts +5 -0
  54. package/src/functions/local-storage.d.ts +29 -0
  55. package/src/functions/mat-form-controls/autocomplete.d.ts +21 -0
  56. package/src/functions/mat-form-controls/index.d.ts +2 -0
  57. package/src/functions/number.d.ts +1 -0
  58. package/src/functions/object-transformation.d.ts +2 -0
  59. package/src/functions/objects-arrays.d.ts +37 -0
  60. package/src/functions/public-api.d.ts +16 -0
  61. package/src/functions/string.d.ts +1 -0
  62. package/src/functions/sweetalert.d.ts +5 -0
  63. package/src/functions/utiles.d.ts +1 -0
  64. package/src/interfaces/datos.d.ts +4 -0
  65. package/src/interfaces/index.d.ts +5 -0
  66. package/src/interfaces/public-api.d.ts +1 -0
  67. package/src/pipes/data-en-lista.pipe.d.ts +8 -0
  68. package/src/pipes/date-diff-string.pipe.d.ts +17 -0
  69. package/src/pipes/filtro.pipe.d.ts +18 -0
  70. package/src/pipes/form-control-is-required.pipe.d.ts +9 -0
  71. package/src/pipes/index.d.ts +5 -0
  72. package/src/pipes/json-parse.pipe.d.ts +7 -0
  73. package/src/pipes/no-sanitize.pipe.d.ts +10 -0
  74. package/src/pipes/public-api.d.ts +8 -0
  75. package/src/pipes/tipo-valor-funcion.pipe.d.ts +9 -0
  76. package/src/pipes/zero-fill.pipe.d.ts +8 -0
  77. package/CHANGELOG.md +0 -13
  78. package/ng-package.json +0 -7
  79. package/src/classes/data-model.ts +0 -150
  80. package/src/functions/base64.ts +0 -8
  81. package/src/functions/browser.ts +0 -20
  82. package/src/functions/crypto-js.ts +0 -29
  83. package/src/functions/date.ts +0 -23
  84. package/src/functions/email.ts +0 -17
  85. package/src/functions/file.ts +0 -138
  86. package/src/functions/forms.ts +0 -145
  87. package/src/functions/http-client.ts +0 -110
  88. package/src/functions/index.ts +0 -1
  89. package/src/functions/local-storage.ts +0 -102
  90. package/src/functions/mat-form-controls/autocomplete.ts +0 -275
  91. package/src/functions/mat-form-controls/index.ts +0 -6
  92. package/src/functions/ng-package.json +0 -5
  93. package/src/functions/number.ts +0 -3
  94. package/src/functions/object-transformation.ts +0 -37
  95. package/src/functions/objects-arrays.ts +0 -243
  96. package/src/functions/public-api.ts +0 -19
  97. package/src/functions/string.ts +0 -9
  98. package/src/functions/sweetalert.ts +0 -95
  99. package/src/functions/utiles.ts +0 -20
  100. package/src/interfaces/index.ts +0 -1
  101. package/src/interfaces/ng-package.json +0 -5
  102. package/src/interfaces/otros.ts +0 -0
  103. package/src/interfaces/public-api.ts +0 -3
  104. package/src/interfaces/routes.ts +0 -42
  105. package/src/pipes/data-en-lista.pipe.ts +0 -40
  106. package/src/pipes/date-diff-string.pipe.ts +0 -117
  107. package/src/pipes/filtro.pipe.ts +0 -64
  108. package/src/pipes/form-control-is-required.pipe.ts +0 -17
  109. package/src/pipes/index.ts +0 -1
  110. package/src/pipes/json-parse.pipe.ts +0 -18
  111. package/src/pipes/ng-package.json +0 -5
  112. package/src/pipes/no-sanitize.pipe.ts +0 -12
  113. package/src/pipes/public-api.ts +0 -10
  114. package/src/pipes/tipo-valor-funcion.pipe.ts +0 -23
  115. package/src/pipes/zero-fill.pipe.ts +0 -19
  116. package/src/public-api.ts +0 -12
  117. package/tsconfig.lib.json +0 -17
  118. package/tsconfig.lib.prod.json +0 -11
  119. package/tsconfig.spec.json +0 -15
@@ -0,0 +1,8 @@
1
+ export * from './data-en-lista.pipe';
2
+ export * from './date-diff-string.pipe';
3
+ export * from './filtro.pipe';
4
+ export * from './form-control-is-required.pipe';
5
+ export * from './json-parse.pipe';
6
+ export * from './no-sanitize.pipe';
7
+ export * from './tipo-valor-funcion.pipe';
8
+ export * from './zero-fill.pipe';
@@ -0,0 +1,9 @@
1
+ import { PipeTransform } from '@angular/core';
2
+ import * as i0 from "@angular/core";
3
+ export type TipoValorFuncion<T> = T | ((...param: any) => T);
4
+ export declare class TipoValorFuncionPipe implements PipeTransform {
5
+ transform<T>(datoParam: TipoValorFuncion<T>, defaultValue?: T, ...param: any[]): T | undefined;
6
+ static ɵfac: i0.ɵɵFactoryDeclaration<TipoValorFuncionPipe, never>;
7
+ static ɵpipe: i0.ɵɵPipeDeclaration<TipoValorFuncionPipe, "tipoValorFuncion", true>;
8
+ }
9
+ export declare function tipoValorFuncion<T>(datoParam: TipoValorFuncion<T>, defaultValue?: T, ...param: any[]): T | undefined;
@@ -0,0 +1,8 @@
1
+ import { PipeTransform } from '@angular/core';
2
+ import * as i0 from "@angular/core";
3
+ export declare class ZeroFillPipe implements PipeTransform {
4
+ transform(value: unknown, digitos: number, ...args: unknown[]): string;
5
+ static ɵfac: i0.ɵɵFactoryDeclaration<ZeroFillPipe, never>;
6
+ static ɵpipe: i0.ɵɵPipeDeclaration<ZeroFillPipe, "zeroFill", true>;
7
+ }
8
+ export declare function zeroFill(value: unknown, digitos: number, ...args: unknown[]): string;
@@ -0,0 +1,4 @@
1
+ export * from './classes/data-model';
2
+ export * from './functions';
3
+ export * from './pipes';
4
+ export * from './interfaces';
@@ -0,0 +1,2 @@
1
+ export declare function b64Encode(val: string): string;
2
+ export declare function b64Decode(val: string): string;
@@ -0,0 +1 @@
1
+ export declare function getBrowserName(): "edge" | "opera" | "chrome" | "ie" | "firefox" | "safari" | "other";
@@ -0,0 +1,2 @@
1
+ export declare function encriptar(text: string): string;
2
+ export declare function desencriptar(ciphertext: string): string;
@@ -0,0 +1,3 @@
1
+ export declare function formatearFechaFormato(val: string, format?: string): string;
2
+ export declare function formatearFecha(val: string, hora?: string): string | Date;
3
+ export declare function formatearFechaCadena(fecha: string): Date;
@@ -0,0 +1,2 @@
1
+ export declare function maskEmail(email: string): string;
2
+ export declare function isEmail(email: string): boolean;
@@ -0,0 +1,10 @@
1
+ export declare function obtenerMimeType(nombreArchivo: string): string | null;
2
+ export declare function sanitizarNombreArchivo(nombre: string, reemplazo?: string): string;
3
+ export declare function getDataArchivoFromPath(value: string, conTimeStamp?: boolean): {
4
+ nombre: string;
5
+ extension?: string;
6
+ d?: any;
7
+ fechaSubida: any;
8
+ };
9
+ export declare function convertirBytes(valor: number, unidadSalida?: string | null, incluirUnidad?: boolean): string | number | null;
10
+ export declare function downLoadFileStream(data: any, type: string, nombreArchivo?: string): void;
@@ -0,0 +1,10 @@
1
+ import { AbstractControl, FormGroup } from '@angular/forms';
2
+ export declare function establecerQuitarRequired(formulario: FormGroup, establecer?: any[], quitar?: any[], camposDisabled?: string[] | 'todos'): void;
3
+ export declare function getFormValidationErrors(form: FormGroup): {
4
+ control: string;
5
+ error: string;
6
+ value: any;
7
+ }[];
8
+ export declare function mensajesErrorFormControl(control: AbstractControl | null): string;
9
+ export declare function toFormData<T extends Record<string, any>>(formValue: T): FormData;
10
+ export declare function markAsTouchedWithoutEmitEvent(control: AbstractControl): void;
@@ -0,0 +1,2 @@
1
+ import { HttpErrorResponse } from '@angular/common/http';
2
+ export declare function mensajesDeError(error: HttpErrorResponse, toast?: boolean): void;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Generated bundle index. Do not edit.
3
+ */
4
+ /// <amd-module name="@jvsoft/utils/src/functions" />
5
+ export * from './public-api';
@@ -0,0 +1,29 @@
1
+ export interface JwtTokenResponse {
2
+ access_token: string;
3
+ expires_in: number;
4
+ token_type: string;
5
+ user: any;
6
+ }
7
+ export interface DataSessionStorage {
8
+ tokenStringKey?: string;
9
+ changePasswordKey?: string;
10
+ logoUrl?: string;
11
+ logoLogin?: string;
12
+ backgroundLogin?: string;
13
+ favicon?: string;
14
+ darkMode?: string;
15
+ serverTimestamp?: string;
16
+ apiDataKey?: string;
17
+ }
18
+ export declare let localStorageKeys: DataSessionStorage;
19
+ export declare function inicializarVariablesSessionStorage(datSesion: DataSessionStorage): void;
20
+ export declare function setJwtTokenData(data: string): void;
21
+ export declare function jwtTokenData(key?: string): JwtTokenResponse | null;
22
+ export declare function jwtToken(key?: string): string;
23
+ export declare function jwtTokenExpiracion(key?: string): number | null;
24
+ export declare function jwtTokenExpiracionFaltante(): number;
25
+ export declare function setCambiarPwd(accion?: boolean): void;
26
+ export declare function getCambiarPwd(): boolean | null;
27
+ export declare function delLocalStorage(keyElim?: string[]): void;
28
+ export declare function getLocalStorage(key: string | undefined): string | null;
29
+ export declare function setLocalStorage(key: string, value?: string): void;
@@ -0,0 +1,21 @@
1
+ import { AbstractControl } from '@angular/forms';
2
+ export declare function mostrarValorEnBusqueda(campos: any, idxSel: any): string;
3
+ export declare function changeSelectData(objThis: any, dataFiltro: {
4
+ formControl: AbstractControl;
5
+ data: any[];
6
+ campoBuscar: string | string[];
7
+ variableResultado: string;
8
+ }): void;
9
+ export declare function changeSelect(control: any, formControl: AbstractControl, tipo: any, campoBuscar: any, campoFiltro?: null): void;
10
+ export declare function changeSelectDataApi(objThis: any, dataFiltro: {
11
+ tipoReq: string;
12
+ campoId?: string;
13
+ minLength?: number;
14
+ dataExtra?: any;
15
+ dataExtraVariable?: any;
16
+ anonimo?: boolean;
17
+ queryService: any;
18
+ formControl: AbstractControl;
19
+ variableResultado?: string;
20
+ }): void;
21
+ export declare function changeSelectApi(control: any, queryService: any, formControl: AbstractControl, tipo: any, dataExtra?: {}, dataExtraVariable?: any[] | null, minLength?: number, anonimo?: boolean): void;
@@ -0,0 +1,2 @@
1
+ export * from './autocomplete';
2
+ export declare function seleccionarTextoInput(event: any): void;
@@ -0,0 +1 @@
1
+ export declare function roundToDecimal(number: number, decimal: number): number;
@@ -0,0 +1,2 @@
1
+ export declare function objectPropertiesToType(formFields: Record<string, any>): Record<string, any>;
2
+ export declare function objectPropertiesBoolean(formFields: Record<string, any>, retorno?: 'boolean' | 'bit'): Record<string, any>;
@@ -0,0 +1,37 @@
1
+ export declare function deepMerge(source: any, target: any): any;
2
+ export declare function deepClone(obj: any): any;
3
+ /**
4
+ * Busca un elemento en un array o jerarquía de objetos según un campo y valor especificado.
5
+ *
6
+ * @returns El elemento encontrado o undefined si no existe.
7
+ */
8
+ export declare function buscarPorCampo<T>(datosFn: {
9
+ items: T[];
10
+ campo: keyof T;
11
+ valor: any;
12
+ campoHijo?: string;
13
+ }): T | undefined;
14
+ export declare function sumarPropiedades(item: Record<string, any>, campos: string[]): number;
15
+ export declare function esNumero(value: any): boolean;
16
+ export declare function sumarObjetos(arrayObjetos: any[], campos: string[]): Record<string, number>;
17
+ export declare function getUniqueValues(array: any[]): any[];
18
+ export declare function getUniqueValuesByProperty<T>(objetos: T[], campo: string): T[];
19
+ export declare function ordenarArray(array: any[], numeros?: boolean, sentido?: 'ASC' | 'DESC'): any[];
20
+ export declare function ordenarPorPropiedad(objData: any, propiedad: string, /**@deprecated*/ numeros?: boolean): {
21
+ [x: string]: {};
22
+ }[];
23
+ export declare function ordenarPorPropiedades<T>(arr: T[], options: {
24
+ propiedades: (keyof T)[];
25
+ direcciones?: ('asc' | 'desc' | '')[];
26
+ }): T[];
27
+ export declare function groupBy<T extends Record<string, any>, K extends keyof T>(array: T[], key: K | ((obj: T) => string)): Record<string, T[]>;
28
+ export declare function nestGroupsBy(arr: any, properties: any): any;
29
+ /**
30
+ * Retorna el valor máximo del campo especificado (incluso anidado) en un arreglo de objetos.
31
+ *
32
+ * @param data - Lista de objetos a procesar.
33
+ * @param campo - Nombre del campo a evaluar, puede ser anidado (ej. "campo.orden").
34
+ * @param incrementar - Si es true, retorna el valor máximo + 1. Por defecto es true.
35
+ * @returns El valor máximo encontrado, posiblemente incrementado.
36
+ */
37
+ export declare function obtenerUltimoOrden(data: any[], campo: string, incrementar?: boolean): number;
@@ -0,0 +1,16 @@
1
+ export * from './mat-form-controls';
2
+ export * from './base64';
3
+ export * from './browser';
4
+ export * from './crypto-js';
5
+ export * from './date';
6
+ export * from './email';
7
+ export * from './file';
8
+ export * from './forms';
9
+ export * from './http-client';
10
+ export * from './local-storage';
11
+ export * from './number';
12
+ export * from './object-transformation';
13
+ export * from './objects-arrays';
14
+ export * from './string';
15
+ export * from './sweetalert';
16
+ export * from './utiles';
@@ -0,0 +1 @@
1
+ export declare function generateRandomString(length: number): string;
@@ -0,0 +1,5 @@
1
+ import { SweetAlertOptions, SweetAlertResult } from 'sweetalert2';
2
+ export declare function mensajeAlerta(tipo: 'success' | 'error' | 'info' | 'warning' | 'question', titulo: string, mensaje: string, opciones?: SweetAlertOptions): Promise<SweetAlertResult<any>>;
3
+ export declare function mensajeTimer(tipo: 'success' | 'error' | 'info' | 'warning' | 'question', titulo: string, mensaje: string, milisegundos?: number, showLoading?: boolean, opciones?: SweetAlertOptions): Promise<SweetAlertResult<any>>;
4
+ export declare function mensajeConfirmacion(tipo: 'success' | 'error' | 'info' | 'warning' | 'question', titulo: any, mensaje: any, opciones?: SweetAlertOptions): Promise<SweetAlertResult<Awaited<any>>>;
5
+ export declare function mensajeToast(tipo: 'success' | 'error' | 'info' | 'warning' | 'question', titulo: string, mensaje: string, opciones?: SweetAlertOptions): Promise<SweetAlertResult<any>>;
@@ -0,0 +1 @@
1
+ export declare function verificarRUC(ruc: string): boolean;
@@ -0,0 +1,4 @@
1
+ import { BehaviorSubject } from 'rxjs';
2
+ export interface DataServidor {
3
+ [key: string]: BehaviorSubject<any>;
4
+ }
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Generated bundle index. Do not edit.
3
+ */
4
+ /// <amd-module name="@jvsoft/utils/src/interfaces" />
5
+ export * from './public-api';
@@ -0,0 +1 @@
1
+ export * from './datos';
@@ -0,0 +1,8 @@
1
+ import { PipeTransform } from '@angular/core';
2
+ import * as i0 from "@angular/core";
3
+ export declare class DataEnListaPipe implements PipeTransform {
4
+ transform(coleccion: object[], idBuscar: string | string[], dato: any): any;
5
+ static ɵfac: i0.ɵɵFactoryDeclaration<DataEnListaPipe, never>;
6
+ static ɵpipe: i0.ɵɵPipeDeclaration<DataEnListaPipe, "dataEnLista", true>;
7
+ }
8
+ export declare function dataEnLista(coleccion: object[], idBuscar: string | string[], dato: any): any;
@@ -0,0 +1,17 @@
1
+ import { PipeTransform } from '@angular/core';
2
+ import * as i0 from "@angular/core";
3
+ export declare class DateDiffStringPipe implements PipeTransform {
4
+ transform(startingDate: Date, endingDate: Date): any;
5
+ separarMilisegundos(milisegundos: any): {
6
+ years: number;
7
+ months: number;
8
+ weeks: number;
9
+ days: number;
10
+ hours: number;
11
+ minutes: number;
12
+ seconds: number;
13
+ };
14
+ static ɵfac: i0.ɵɵFactoryDeclaration<DateDiffStringPipe, never>;
15
+ static ɵpipe: i0.ɵɵPipeDeclaration<DateDiffStringPipe, "dateDiffString", true>;
16
+ }
17
+ export declare function dateDiffString(startingDate: Date, endingDate: Date): any;
@@ -0,0 +1,18 @@
1
+ import { PipeTransform } from '@angular/core';
2
+ import * as i0 from "@angular/core";
3
+ interface OpcionesBusqueda {
4
+ texto: string;
5
+ longitudMinima?: number;
6
+ campo?: string | string[];
7
+ mostrarObligado?: MostrarObligado;
8
+ }
9
+ interface MostrarObligado {
10
+ campo: string;
11
+ items: any[];
12
+ }
13
+ export declare class FiltroPipe implements PipeTransform {
14
+ transform(items: any[], opcionesBusqueda: OpcionesBusqueda): any[];
15
+ static ɵfac: i0.ɵɵFactoryDeclaration<FiltroPipe, never>;
16
+ static ɵpipe: i0.ɵɵPipeDeclaration<FiltroPipe, "filtro", true>;
17
+ }
18
+ export {};
@@ -0,0 +1,9 @@
1
+ import { PipeTransform } from '@angular/core';
2
+ import { AbstractControl } from '@angular/forms';
3
+ import * as i0 from "@angular/core";
4
+ export declare class FormControlIsRequiredPipe implements PipeTransform {
5
+ transform(formControl: AbstractControl, ...args: unknown[]): any;
6
+ static ɵfac: i0.ɵɵFactoryDeclaration<FormControlIsRequiredPipe, never>;
7
+ static ɵpipe: i0.ɵɵPipeDeclaration<FormControlIsRequiredPipe, "formControlIsRequired", true>;
8
+ }
9
+ export declare function formControlIsRequired(formControl: AbstractControl): any;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Generated bundle index. Do not edit.
3
+ */
4
+ /// <amd-module name="@jvsoft/utils/src/pipes" />
5
+ export * from './public-api';
@@ -0,0 +1,7 @@
1
+ import { PipeTransform } from '@angular/core';
2
+ import * as i0 from "@angular/core";
3
+ export declare class JsonParsePipe implements PipeTransform {
4
+ transform(value: string, ...args: unknown[]): any;
5
+ static ɵfac: i0.ɵɵFactoryDeclaration<JsonParsePipe, never>;
6
+ static ɵpipe: i0.ɵɵPipeDeclaration<JsonParsePipe, "jsonParse", true>;
7
+ }
@@ -0,0 +1,10 @@
1
+ import { PipeTransform } from '@angular/core';
2
+ import { DomSanitizer, SafeHtml } from '@angular/platform-browser';
3
+ import * as i0 from "@angular/core";
4
+ export declare class NoSanitizePipe implements PipeTransform {
5
+ private domSanitizer;
6
+ constructor(domSanitizer: DomSanitizer);
7
+ transform(html: string): SafeHtml;
8
+ static ɵfac: i0.ɵɵFactoryDeclaration<NoSanitizePipe, never>;
9
+ static ɵpipe: i0.ɵɵPipeDeclaration<NoSanitizePipe, "noSanitize", true>;
10
+ }
@@ -0,0 +1,8 @@
1
+ export * from './data-en-lista.pipe';
2
+ export * from './date-diff-string.pipe';
3
+ export * from './filtro.pipe';
4
+ export * from './form-control-is-required.pipe';
5
+ export * from './json-parse.pipe';
6
+ export * from './no-sanitize.pipe';
7
+ export * from './tipo-valor-funcion.pipe';
8
+ export * from './zero-fill.pipe';
@@ -0,0 +1,9 @@
1
+ import { PipeTransform } from '@angular/core';
2
+ import * as i0 from "@angular/core";
3
+ export type TipoValorFuncion<T> = T | ((...param: any) => T);
4
+ export declare class TipoValorFuncionPipe implements PipeTransform {
5
+ transform<T>(datoParam: TipoValorFuncion<T>, defaultValue?: T, ...param: any[]): T | undefined;
6
+ static ɵfac: i0.ɵɵFactoryDeclaration<TipoValorFuncionPipe, never>;
7
+ static ɵpipe: i0.ɵɵPipeDeclaration<TipoValorFuncionPipe, "tipoValorFuncion", true>;
8
+ }
9
+ export declare function tipoValorFuncion<T>(datoParam: TipoValorFuncion<T>, defaultValue?: T, ...param: any[]): T | undefined;
@@ -0,0 +1,8 @@
1
+ import { PipeTransform } from '@angular/core';
2
+ import * as i0 from "@angular/core";
3
+ export declare class ZeroFillPipe implements PipeTransform {
4
+ transform(value: unknown, digitos: number, ...args: unknown[]): string;
5
+ static ɵfac: i0.ɵɵFactoryDeclaration<ZeroFillPipe, never>;
6
+ static ɵpipe: i0.ɵɵPipeDeclaration<ZeroFillPipe, "zeroFill", true>;
7
+ }
8
+ export declare function zeroFill(value: unknown, digitos: number, ...args: unknown[]): string;
package/CHANGELOG.md DELETED
@@ -1,13 +0,0 @@
1
- # @jvsoft/utils
2
-
3
- ## 0.0.13-alpha.1
4
-
5
- ### Patch Changes
6
-
7
- - Fix Error
8
-
9
- ## 0.0.10-alpha.0
10
-
11
- ### Patch Changes
12
-
13
- - FIX ERROR
package/ng-package.json DELETED
@@ -1,7 +0,0 @@
1
- {
2
- "$schema": "../../node_modules/ng-packagr/ng-package.schema.json",
3
- "dest": "../../dist/utils",
4
- "lib": {
5
- "entryFile": "src/public-api.ts"
6
- }
7
- }
@@ -1,150 +0,0 @@
1
- import {AbstractControl, FormControl, FormControlOptions, FormGroup, ValidationErrors, ValidatorFn, Validators} from '@angular/forms';
2
- import {esNumero} from '../functions';
3
-
4
- export class DataModel {
5
- public modelosChk: { [key: string]: boolean | any } = {}; // Usar any para valores dinámicos
6
-
7
- public checkbox: ForCheckboxModel;
8
-
9
- constructor() {
10
- this.checkbox = new ForCheckboxModel(this);
11
- }
12
-
13
- generarId(row: any, campoValor: string[] | string, separador = '') {
14
- if (typeof campoValor == 'string') {
15
- campoValor = [campoValor];
16
- }
17
- return campoValor.map(data => row[data]).join(separador);
18
- }
19
-
20
- // Agrega controles al objeto modelosChk
21
- agregarControles(lista: any[], idLista: string, limpiar = true, campoValor: string[] | string | null = null, campoValorSeparador = '') {
22
-
23
- if (limpiar) {
24
- this.modelosChk = {};
25
- }
26
-
27
- const asignarValor = (dat: any, idLista: string, campoValor: string, key?: string) => {
28
- if (!key) {
29
- key = dat[idLista] + (campoValor.includes('.') ? '':`.${campoValor}`);
30
- }
31
- const mat = campoValor.match(/^([in])[A-Z][a-zA-Z]+/);
32
- if (mat) {
33
- this.modelosChk[key] = dat[campoValor] * 1;
34
- }
35
- else {
36
- this.modelosChk[key] = dat[campoValor];
37
- }
38
- }
39
-
40
-
41
- lista.forEach(dat => {
42
- if (campoValor === null) {
43
- // Caso 1: Sin campoValor, se asigna false
44
- this.modelosChk[dat[idLista]] = false;
45
- }
46
- else if (typeof campoValor === 'string') {
47
- // Caso 2: campoValor es un string
48
- asignarValor(dat, idLista, campoValor, dat[idLista]);
49
- }
50
- else if (campoValorSeparador) {
51
- const idStr = this.generarId(dat, campoValor, campoValorSeparador);
52
- // Caso 2: campoValor es un string
53
- asignarValor(dat, idLista, '.', idStr);
54
- }
55
- else {
56
- // Caso 3: campoValor es un array de strings
57
- campoValor.forEach(data => asignarValor(dat, idLista, data));
58
- }
59
- });
60
- }
61
-
62
- // Establece el estado de un índice
63
- setState(idx: string, state: boolean) {
64
- this.modelosChk[idx] = state;
65
- }
66
-
67
- // Obtiene el estado de un índice
68
- getState(idx: string): boolean | any {
69
- return this.modelosChk[idx];
70
- }
71
-
72
- getDataMultiple(idx: string) {
73
- const camposMod = Object.keys(this.modelosChk).filter(key => key.split('.')[0] == idx);
74
- const vRet: any = {};
75
- camposMod.forEach(key => {
76
- vRet[key.split('.')[1]] = this.modelosChk[key];
77
- });
78
- return vRet;
79
- }
80
-
81
- // Genera una lista basada en el estado de los índices
82
- generarLista(tipoRetorno: 'array' | 'object' | null = null, esCampoNumerico = false): string | object | any[] {
83
- const strLista: string[] = [];
84
- const objLista: { [key: string]: boolean | any } = {};
85
- Object.keys(this.modelosChk).forEach(key => {
86
- if ((esCampoNumerico && esNumero(this.modelosChk[key])) ||
87
- (this.modelosChk[key])
88
- ) {
89
- strLista.push(key);
90
- objLista[key] = this.modelosChk[key];
91
- }
92
- });
93
- if (tipoRetorno === 'array') {
94
- return strLista;
95
- }
96
- if (tipoRetorno === 'object') {
97
- return objLista;
98
- }
99
- return strLista.join(',');
100
- }
101
-
102
- generarFormGroupFromModelosChk(tipo?: string): FormGroup {
103
- const formGroupObj: { [key: string]: FormControl } = {};
104
- let validadores: ValidatorFn | ((control: AbstractControl) => ValidationErrors | null)[] | FormControlOptions | null | undefined = []
105
- if (tipo == 'number') {
106
- validadores = [
107
- Validators.required,
108
- Validators.min(1)
109
- ]
110
- }
111
- Object.keys(this.modelosChk).forEach(key => {
112
- formGroupObj[key] = new FormControl(this.modelosChk[key], validadores);
113
- });
114
- return new FormGroup(formGroupObj);
115
-
116
- // return this.formBuilder.group(formGroupObj);
117
- }
118
- }
119
-
120
- class ForCheckboxModel {
121
- private modeloCheck: DataModel;
122
-
123
- constructor(modeloCheck: DataModel) {
124
- this.modeloCheck = modeloCheck;
125
- }
126
-
127
- get cantidadActivos() {
128
- return Object.values(this.modeloCheck.modelosChk).filter(Boolean).length;
129
- }
130
-
131
- get existenActivados() {
132
- return this.cantidadActivos > 0;
133
- }
134
-
135
- get todosActivos() {
136
- const total = Object.keys(this.modeloCheck.modelosChk).length;
137
- const activos = this.cantidadActivos;
138
- return activos > 0 && total === activos;
139
- }
140
-
141
- get algunosActivos() {
142
- const total = Object.keys(this.modeloCheck.modelosChk).length;
143
- const activos = this.cantidadActivos;
144
- return activos > 0 && total !== activos;
145
- }
146
-
147
- establecerTodos(activo: boolean) {
148
- Object.keys(this.modeloCheck.modelosChk).forEach(idx => this.modeloCheck.modelosChk[idx] = activo);
149
- }
150
- }
@@ -1,8 +0,0 @@
1
- import {Buffer} from 'buffer';
2
-
3
- export function b64Encode(val: string) {
4
- return Buffer.from(val, 'binary').toString('base64');
5
- }
6
- export function b64Decode(val: string) {
7
- return Buffer.from(val, 'base64').toString('binary');
8
- }
@@ -1,20 +0,0 @@
1
-
2
- export function getBrowserName() {
3
- const agent = window.navigator.userAgent.toLowerCase();
4
- switch (true) {
5
- case agent.indexOf('edge') > -1:
6
- return 'edge';
7
- case agent.indexOf('opr') > -1 && !!(<any>window).opr:
8
- return 'opera';
9
- case agent.indexOf('chrome') > -1 && !!(<any>window).chrome:
10
- return 'chrome';
11
- case agent.indexOf('trident') > -1:
12
- return 'ie';
13
- case agent.indexOf('firefox') > -1:
14
- return 'firefox';
15
- case agent.indexOf('safari') > -1:
16
- return 'safari';
17
- default:
18
- return 'other';
19
- }
20
- }
@@ -1,29 +0,0 @@
1
- // import * as CryptoJS from 'crypto-js';
2
- import CryptoJS from 'crypto-js';
3
- // var CryptoJS = require("crypto-js");
4
-
5
-
6
- // Clave secreta (debe ser de 16, 24 o 32 caracteres)
7
-
8
- const secretKey = CryptoJS.enc.Utf8.parse('JVSoftSecret@20615178350');
9
- const iv = CryptoJS.enc.Utf8.parse('AnSalHuaJVSoft07'); // Debe ser de 16 bytes
10
-
11
- // Función para encriptar texto
12
- export function encriptar(text: string): string {
13
- const encrypted = CryptoJS.AES.encrypt(text, secretKey, {
14
- iv: iv,
15
- mode: CryptoJS.mode.CBC,
16
- padding: CryptoJS.pad.Pkcs7,
17
- });
18
- return encrypted.toString(); // Texto cifrado en Base64
19
- }
20
-
21
- // Función para desencriptar texto
22
- export function desencriptar(ciphertext: string): string {
23
- const decrypted = CryptoJS.AES.decrypt(ciphertext, secretKey, {
24
- iv: iv,
25
- mode: CryptoJS.mode.CBC,
26
- padding: CryptoJS.pad.Pkcs7,
27
- });
28
- return decrypted.toString(CryptoJS.enc.Utf8);
29
- }
@@ -1,23 +0,0 @@
1
- import {formatDate} from '@angular/common';
2
-
3
- export function formatearFechaFormato(val: string, format: string = 'dd/MM/yyyy') {
4
- return val ? formatDate(val, format, 'es-PE'):'';
5
- }
6
-
7
- export function formatearFecha(val: string, hora = '00:00:00') {
8
- if (val) {
9
- if (val.length <= 10) {
10
- val = val + ' ' + hora;
11
- }
12
- return new Date(val);
13
- }
14
- return val;
15
- }
16
-
17
- export function formatearFechaCadena(fecha: string): Date {
18
- const year = parseInt(fecha.substring(0, 4), 10);
19
- const month = parseInt(fecha.substring(4, 6), 10) - 1;
20
- const day = parseInt(fecha.substring(6, 8), 10);
21
-
22
- return new Date(year, month, day);
23
- }
@@ -1,17 +0,0 @@
1
- export function maskEmail(email: string): string {
2
- const [user, domain] = email.split("@");
3
-
4
- if (user.length <= 2) {
5
- return `${user[0]}***@${domain}`; // 🔹 Si el usuario es muy corto, no se oculta nada
6
- }
7
-
8
- if (user.length <= 4) {
9
- return `${user[0]}***${user.slice(-1)}@${domain}`; // 🔹 Muestra 1 al inicio y 1 al final
10
- }
11
-
12
- return `${user.slice(0, 2)}***${user.slice(-2)}@${domain}`; // 🔹 Muestra 2 al inicio y 2 al final
13
- }
14
-
15
- export function isEmail(email: string): boolean {
16
- return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(email);
17
- }