@jvsoft/utils 0.0.13-alpha.4 → 0.0.13-alpha.6
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/classes/data-model.d.ts +25 -0
- package/fesm2022/jvsoft-utils-src-functions.mjs +1450 -0
- package/fesm2022/jvsoft-utils-src-functions.mjs.map +1 -0
- package/fesm2022/jvsoft-utils-src-interfaces.mjs +6 -0
- package/fesm2022/jvsoft-utils-src-interfaces.mjs.map +1 -0
- package/fesm2022/jvsoft-utils-src-pipes.mjs +290 -0
- package/fesm2022/jvsoft-utils-src-pipes.mjs.map +1 -0
- package/fesm2022/jvsoft-utils.mjs +1867 -0
- package/fesm2022/jvsoft-utils.mjs.map +1 -0
- package/functions/base64.d.ts +26 -0
- package/functions/browser.d.ts +1 -0
- package/functions/crypto-js.d.ts +2 -0
- package/functions/date.d.ts +3 -0
- package/functions/email.d.ts +2 -0
- package/functions/file.d.ts +10 -0
- package/functions/forms.d.ts +23 -0
- package/functions/http-client.d.ts +2 -0
- package/functions/index.d.ts +1 -0
- package/functions/local-storage.d.ts +29 -0
- package/functions/mat-form-controls/autocomplete.d.ts +51 -0
- package/functions/mat-form-controls/index.d.ts +2 -0
- package/functions/number.d.ts +2 -0
- package/functions/object-transformation.d.ts +2 -0
- package/functions/objects-arrays.d.ts +147 -0
- package/functions/public-api.d.ts +16 -0
- package/functions/string.d.ts +23 -0
- package/functions/sweetalert.d.ts +5 -0
- package/functions/utiles.d.ts +1 -0
- package/index.d.ts +5 -0
- package/{src/interfaces/datos.ts → interfaces/datos.d.ts} +1 -2
- package/interfaces/index.d.ts +1 -0
- package/interfaces/public-api.d.ts +1 -0
- package/package.json +28 -12
- package/pipes/data-en-lista.pipe.d.ts +8 -0
- package/pipes/date-diff-string.pipe.d.ts +17 -0
- package/pipes/filtro.pipe.d.ts +18 -0
- package/pipes/form-control-is-required.pipe.d.ts +9 -0
- package/pipes/index.d.ts +1 -0
- package/pipes/json-parse.pipe.d.ts +7 -0
- package/pipes/no-sanitize.pipe.d.ts +10 -0
- package/pipes/public-api.d.ts +8 -0
- package/pipes/tipo-valor-funcion.pipe.d.ts +9 -0
- package/pipes/zero-fill.pipe.d.ts +8 -0
- package/public-api.d.ts +4 -0
- package/src/functions/base64.d.ts +26 -0
- package/src/functions/browser.d.ts +1 -0
- package/src/functions/crypto-js.d.ts +2 -0
- package/src/functions/date.d.ts +3 -0
- package/src/functions/email.d.ts +2 -0
- package/src/functions/file.d.ts +10 -0
- package/src/functions/forms.d.ts +23 -0
- package/src/functions/http-client.d.ts +2 -0
- package/src/functions/index.d.ts +5 -0
- package/src/functions/local-storage.d.ts +29 -0
- package/src/functions/mat-form-controls/autocomplete.d.ts +51 -0
- package/src/functions/mat-form-controls/index.d.ts +2 -0
- package/src/functions/number.d.ts +2 -0
- package/src/functions/object-transformation.d.ts +2 -0
- package/src/functions/objects-arrays.d.ts +147 -0
- package/src/functions/public-api.d.ts +16 -0
- package/src/functions/string.d.ts +23 -0
- package/src/functions/sweetalert.d.ts +5 -0
- package/src/functions/utiles.d.ts +1 -0
- package/src/interfaces/datos.d.ts +4 -0
- package/src/interfaces/index.d.ts +5 -0
- package/src/interfaces/public-api.d.ts +1 -0
- package/src/pipes/data-en-lista.pipe.d.ts +8 -0
- package/src/pipes/date-diff-string.pipe.d.ts +17 -0
- package/src/pipes/filtro.pipe.d.ts +18 -0
- package/src/pipes/form-control-is-required.pipe.d.ts +9 -0
- package/src/pipes/index.d.ts +5 -0
- package/src/pipes/json-parse.pipe.d.ts +7 -0
- package/src/pipes/no-sanitize.pipe.d.ts +10 -0
- package/src/pipes/public-api.d.ts +8 -0
- package/src/pipes/tipo-valor-funcion.pipe.d.ts +9 -0
- package/src/pipes/zero-fill.pipe.d.ts +8 -0
- package/CHANGELOG.md +0 -25
- package/ng-package.json +0 -7
- package/src/classes/data-model.ts +0 -150
- package/src/functions/base64.ts +0 -8
- package/src/functions/browser.ts +0 -20
- package/src/functions/crypto-js.ts +0 -29
- package/src/functions/date.ts +0 -23
- package/src/functions/email.ts +0 -17
- package/src/functions/file.ts +0 -138
- package/src/functions/forms.ts +0 -251
- package/src/functions/http-client.ts +0 -110
- package/src/functions/index.ts +0 -1
- package/src/functions/local-storage.ts +0 -102
- package/src/functions/mat-form-controls/autocomplete.ts +0 -205
- package/src/functions/mat-form-controls/index.ts +0 -6
- package/src/functions/ng-package.json +0 -5
- package/src/functions/number.ts +0 -85
- package/src/functions/object-transformation.ts +0 -37
- package/src/functions/objects-arrays.ts +0 -321
- package/src/functions/public-api.ts +0 -19
- package/src/functions/string.ts +0 -68
- package/src/functions/sweetalert.ts +0 -95
- package/src/functions/utiles.ts +0 -20
- package/src/interfaces/index.ts +0 -1
- package/src/interfaces/ng-package.json +0 -5
- package/src/interfaces/otros.ts +0 -0
- package/src/interfaces/public-api.ts +0 -3
- package/src/interfaces/routes.ts +0 -42
- package/src/pipes/data-en-lista.pipe.ts +0 -40
- package/src/pipes/date-diff-string.pipe.ts +0 -117
- package/src/pipes/filtro.pipe.ts +0 -64
- package/src/pipes/form-control-is-required.pipe.ts +0 -17
- package/src/pipes/index.ts +0 -1
- package/src/pipes/json-parse.pipe.ts +0 -18
- package/src/pipes/ng-package.json +0 -5
- package/src/pipes/no-sanitize.pipe.ts +0 -12
- package/src/pipes/public-api.ts +0 -10
- package/src/pipes/tipo-valor-funcion.pipe.ts +0 -23
- package/src/pipes/zero-fill.pipe.ts +0 -19
- package/src/public-api.ts +0 -12
- package/tsconfig.lib.json +0 -18
- package/tsconfig.lib.prod.json +0 -11
- package/tsconfig.spec.json +0 -15
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Realiza una fusión profunda entre dos objetos, sin modificar el original.
|
|
3
|
+
* Si el valor en target no es un objeto, lo reemplaza directamente.
|
|
4
|
+
*
|
|
5
|
+
* @param source - Objeto fuente que se clonará y fusionará.
|
|
6
|
+
* @param target - Objeto destino cuyos valores se fusionarán.
|
|
7
|
+
* @returns Un nuevo objeto con la fusión profunda.
|
|
8
|
+
*/
|
|
9
|
+
export declare function deepMerge(source: any, target: any): any;
|
|
10
|
+
/**
|
|
11
|
+
* Realiza una clonación profunda de un objeto, manejando funciones, fechas y arrays.
|
|
12
|
+
*
|
|
13
|
+
* @param obj - Objeto a clonar.
|
|
14
|
+
* @returns Una copia profunda del objeto.
|
|
15
|
+
*/
|
|
16
|
+
export declare function deepClone(obj: any): any;
|
|
17
|
+
/**
|
|
18
|
+
* Busca un elemento en un array o jerarquía de objetos según un campo y valor especificado.
|
|
19
|
+
*
|
|
20
|
+
* @param datosFn - Objeto con los parámetros de búsqueda: items, campo, valor y opcionalmente campoHijo.
|
|
21
|
+
* @returns El elemento encontrado o undefined si no existe.
|
|
22
|
+
*/
|
|
23
|
+
export declare function buscarPorCampo<T>(datosFn: {
|
|
24
|
+
items: T[];
|
|
25
|
+
campo: keyof T;
|
|
26
|
+
valor: any;
|
|
27
|
+
campoHijo?: string;
|
|
28
|
+
}): T | undefined;
|
|
29
|
+
/**
|
|
30
|
+
* Suma los valores de las propiedades especificadas de un objeto.
|
|
31
|
+
*
|
|
32
|
+
* @param item - Objeto con las propiedades a sumar.
|
|
33
|
+
* @param campos - Array de nombres de las propiedades a sumar.
|
|
34
|
+
* @returns La suma de los valores de las propiedades.
|
|
35
|
+
*/
|
|
36
|
+
export declare function sumarPropiedades(item: Record<string, any>, campos: string[]): number;
|
|
37
|
+
/**
|
|
38
|
+
* Verifica si el valor proporcionado es un número válido.
|
|
39
|
+
*
|
|
40
|
+
* @param value - Valor a verificar.
|
|
41
|
+
* @returns true si es un número, false en caso contrario.
|
|
42
|
+
*/
|
|
43
|
+
export declare function esNumero(value: any): boolean;
|
|
44
|
+
/**
|
|
45
|
+
* Suma los valores de las propiedades especificadas en un array de objetos.
|
|
46
|
+
*
|
|
47
|
+
* @param arrayObjetos - Array de objetos a procesar.
|
|
48
|
+
* @param campos - Array de nombres de las propiedades a sumar.
|
|
49
|
+
* @returns Objeto con la suma de cada propiedad.
|
|
50
|
+
*/
|
|
51
|
+
export declare function sumarObjetos(arrayObjetos: any[], campos: string[]): Record<string, number>;
|
|
52
|
+
/**
|
|
53
|
+
* Obtiene los valores únicos de un array.
|
|
54
|
+
*
|
|
55
|
+
* @param array - Array de valores.
|
|
56
|
+
* @returns Array con los valores únicos.
|
|
57
|
+
*/
|
|
58
|
+
export declare function getUniqueValues(array: any[]): any[];
|
|
59
|
+
/**
|
|
60
|
+
* Obtiene los objetos únicos de un array según una propiedad específica.
|
|
61
|
+
*
|
|
62
|
+
* @param objetos - Array de objetos.
|
|
63
|
+
* @param campo - Nombre de la propiedad para determinar unicidad.
|
|
64
|
+
* @returns Array de objetos únicos por la propiedad.
|
|
65
|
+
*/
|
|
66
|
+
export declare function getUniqueValuesByProperty<T>(objetos: T[], campo: string): T[];
|
|
67
|
+
/**
|
|
68
|
+
* Ordena un array de valores numéricos o alfabéticos.
|
|
69
|
+
*
|
|
70
|
+
* @param array - Array a ordenar.
|
|
71
|
+
* @param numeros - Si es true, ordena como números.
|
|
72
|
+
* @param sentido - 'ASC' para ascendente, 'DESC' para descendente.
|
|
73
|
+
* @returns Array ordenado.
|
|
74
|
+
*/
|
|
75
|
+
export declare function ordenarArray(array: any[], numeros?: boolean, sentido?: 'ASC' | 'DESC'): any[];
|
|
76
|
+
/**
|
|
77
|
+
* Ordena un array de objetos por una propiedad específica.
|
|
78
|
+
*
|
|
79
|
+
* @param objData - Array de objetos a ordenar.
|
|
80
|
+
* @param propiedad - Propiedad por la que se ordena.
|
|
81
|
+
* @param numeros - (Obsoleto) Si es true, ordena como números.
|
|
82
|
+
* @returns Array ordenado.
|
|
83
|
+
*/
|
|
84
|
+
export declare function ordenarPorPropiedad(objData: any, propiedad: string, /**@deprecated*/ numeros?: boolean): {
|
|
85
|
+
[x: string]: {};
|
|
86
|
+
}[];
|
|
87
|
+
/**
|
|
88
|
+
* Ordena un array de objetos por varias propiedades y direcciones.
|
|
89
|
+
*
|
|
90
|
+
* @param arr - Array de objetos a ordenar.
|
|
91
|
+
* @param options - Opciones con propiedades y direcciones de orden.
|
|
92
|
+
* @returns Array ordenado.
|
|
93
|
+
*/
|
|
94
|
+
export declare function ordenarPorPropiedades<T>(arr: T[], options: {
|
|
95
|
+
propiedades: (keyof T)[];
|
|
96
|
+
direcciones?: ('asc' | 'desc' | '')[];
|
|
97
|
+
}): T[];
|
|
98
|
+
/**
|
|
99
|
+
* Agrupa los elementos de un array según una clave o función de clave.
|
|
100
|
+
*
|
|
101
|
+
* @param array - Array de objetos a agrupar.
|
|
102
|
+
* @param key - Propiedad o función para agrupar.
|
|
103
|
+
* @returns Objeto con los grupos por clave.
|
|
104
|
+
*/
|
|
105
|
+
export declare function groupBy<T extends Record<string, any>, K extends keyof T>(array: T[], key: K | ((obj: T) => string)): Record<string, T[]>;
|
|
106
|
+
/**
|
|
107
|
+
* Agrupa y anida los elementos de un array según una lista de propiedades.
|
|
108
|
+
*
|
|
109
|
+
* @param arr - Array de objetos a agrupar.
|
|
110
|
+
* @param properties - Propiedades para agrupar de forma anidada.
|
|
111
|
+
* @returns Objeto anidado por los grupos de propiedades.
|
|
112
|
+
*/
|
|
113
|
+
export declare function nestGroupsBy(arr: any, properties: any): any;
|
|
114
|
+
/**
|
|
115
|
+
* Retorna el valor máximo del campo especificado (incluso anidado) en un arreglo de objetos.
|
|
116
|
+
*
|
|
117
|
+
* @param data - Lista de objetos a procesar.
|
|
118
|
+
* @param campo - Nombre del campo a evaluar, puede ser anidado (ej. "campo.orden").
|
|
119
|
+
* @param incrementar - Si es true, retorna el valor máximo + 1. Por defecto es true.
|
|
120
|
+
* @returns El valor máximo encontrado, posiblemente incrementado.
|
|
121
|
+
*/
|
|
122
|
+
export declare function obtenerUltimoOrden(data: any[], campo: string, incrementar?: boolean): number;
|
|
123
|
+
/**
|
|
124
|
+
* Elimina una o varias columnas específicas (por índice) de una tabla representada como array de arrays.
|
|
125
|
+
*
|
|
126
|
+
* @param data - Array de filas (cada fila debe ser un array).
|
|
127
|
+
* @param columnIndex - Índice o lista de índices de las columnas a eliminar.
|
|
128
|
+
* @returns Nuevo array con las columnas eliminadas.
|
|
129
|
+
*/
|
|
130
|
+
export declare function eliminarColumnaPorIndex<T extends unknown[][]>(data: T, columnIndex: number | number[]): T;
|
|
131
|
+
/**
|
|
132
|
+
* Elimina elementos duplicados de un array de objetos según claves específicas.
|
|
133
|
+
*
|
|
134
|
+
* @param array - Array de objetos.
|
|
135
|
+
* @param claves - Claves para determinar unicidad. Si no se especifica, compara todo el objeto.
|
|
136
|
+
* @returns Array sin duplicados.
|
|
137
|
+
*/
|
|
138
|
+
export declare function eliminarDuplicados<T extends object>(array: T[], claves?: (keyof T)[]): T[];
|
|
139
|
+
/**
|
|
140
|
+
* Elimina elementos de un array origen que estén presentes en otro array, según claves específicas.
|
|
141
|
+
*
|
|
142
|
+
* @param origen - Array original.
|
|
143
|
+
* @param elementosAEliminar - Elementos a eliminar del array origen.
|
|
144
|
+
* @param claves - Claves para comparar los objetos. Si no se especifica, compara todo el objeto.
|
|
145
|
+
* @returns Array filtrado sin los elementos eliminados.
|
|
146
|
+
*/
|
|
147
|
+
export declare function eliminarElementos<T extends object>(origen: T[], elementosAEliminar: T[], claves?: (keyof T)[]): T[];
|
|
@@ -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,23 @@
|
|
|
1
|
+
export declare function generateRandomString(length: number): string;
|
|
2
|
+
/**
|
|
3
|
+
* Obtiene el host (hostname) de una URL o cadena host[:port].
|
|
4
|
+
* Opcionalmente puede devolver también el puerto si está presente.
|
|
5
|
+
*
|
|
6
|
+
* - Acepta inputs como:
|
|
7
|
+
* 'https://example.com/path', 'example.com:3000', 'localhost', 'http://[::1]:4200'
|
|
8
|
+
* - Usa la API URL cuando es posible (más robusta) y cae a un regex de respaldo.
|
|
9
|
+
*
|
|
10
|
+
* @param url Cadena que representa una URL o host
|
|
11
|
+
* @param options
|
|
12
|
+
* @param options.includePort Si es true, incluye":puerto" cuando exista (por defecto false)
|
|
13
|
+
* @param options.includeProtocol Incluye "http://" o "https://" según corresponda (por defecto false)
|
|
14
|
+
*/
|
|
15
|
+
export declare function obtenerHostDesdeUrl(url: string | null | undefined, options?: {
|
|
16
|
+
includePort?: boolean;
|
|
17
|
+
includeProtocol?: boolean;
|
|
18
|
+
}): string | null;
|
|
19
|
+
/** @deprecated Alias compatible (deprecated) — preferir usar `obtenerHostDesdeUrl`. */
|
|
20
|
+
export declare const extraerDominio: (url: string | null | undefined, options?: {
|
|
21
|
+
includePort?: boolean;
|
|
22
|
+
includeProtocol?: boolean;
|
|
23
|
+
}) => string | null;
|
|
@@ -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 @@
|
|
|
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,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,25 +0,0 @@
|
|
|
1
|
-
# @jvsoft/utils
|
|
2
|
-
|
|
3
|
-
## 0.0.13-alpha.3
|
|
4
|
-
|
|
5
|
-
### Patch Changes
|
|
6
|
-
|
|
7
|
-
- 9c95f84: Prueba01
|
|
8
|
-
|
|
9
|
-
## 0.0.13-alpha.2
|
|
10
|
-
|
|
11
|
-
### Patch Changes
|
|
12
|
-
|
|
13
|
-
- 5d82a0d: Otro Fix - Espero el ultimo
|
|
14
|
-
|
|
15
|
-
## 0.0.13-alpha.1
|
|
16
|
-
|
|
17
|
-
### Patch Changes
|
|
18
|
-
|
|
19
|
-
- Fix Error
|
|
20
|
-
|
|
21
|
-
## 0.0.10-alpha.0
|
|
22
|
-
|
|
23
|
-
### Patch Changes
|
|
24
|
-
|
|
25
|
-
- FIX ERROR
|
package/ng-package.json
DELETED
|
@@ -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
|
-
}
|
package/src/functions/base64.ts
DELETED
package/src/functions/browser.ts
DELETED
|
@@ -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
|
-
}
|
package/src/functions/date.ts
DELETED
|
@@ -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
|
-
}
|
package/src/functions/email.ts
DELETED
|
@@ -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
|
-
}
|