@jvsoft/utils 0.0.13-alpha.2 → 0.0.13-alpha.4
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/CHANGELOG.md +25 -0
- package/ng-package.json +7 -0
- package/package.json +2 -25
- package/src/classes/data-model.ts +150 -0
- package/src/functions/base64.ts +8 -0
- package/src/functions/browser.ts +20 -0
- package/src/functions/crypto-js.ts +29 -0
- package/src/functions/date.ts +23 -0
- package/src/functions/email.ts +17 -0
- package/src/functions/file.ts +138 -0
- package/src/functions/forms.ts +251 -0
- package/src/functions/http-client.ts +110 -0
- package/src/functions/index.ts +1 -0
- package/src/functions/local-storage.ts +102 -0
- package/src/functions/mat-form-controls/autocomplete.ts +205 -0
- package/src/functions/mat-form-controls/index.ts +6 -0
- package/src/functions/ng-package.json +5 -0
- package/src/functions/number.ts +85 -0
- package/src/functions/object-transformation.ts +37 -0
- package/src/functions/objects-arrays.ts +321 -0
- package/src/functions/public-api.ts +19 -0
- package/src/functions/string.ts +68 -0
- package/src/functions/sweetalert.ts +95 -0
- package/src/functions/utiles.ts +20 -0
- package/{interfaces/datos.d.ts → src/interfaces/datos.ts} +2 -1
- package/src/interfaces/index.ts +1 -0
- package/src/interfaces/ng-package.json +5 -0
- package/src/interfaces/otros.ts +0 -0
- package/src/interfaces/public-api.ts +3 -0
- package/src/interfaces/routes.ts +42 -0
- package/src/pipes/data-en-lista.pipe.ts +40 -0
- package/src/pipes/date-diff-string.pipe.ts +117 -0
- package/src/pipes/filtro.pipe.ts +64 -0
- package/src/pipes/form-control-is-required.pipe.ts +17 -0
- package/src/pipes/index.ts +1 -0
- package/src/pipes/json-parse.pipe.ts +18 -0
- package/src/pipes/ng-package.json +5 -0
- package/src/pipes/no-sanitize.pipe.ts +12 -0
- package/src/pipes/public-api.ts +10 -0
- package/src/pipes/tipo-valor-funcion.pipe.ts +23 -0
- package/src/pipes/zero-fill.pipe.ts +19 -0
- package/src/public-api.ts +12 -0
- package/tsconfig.lib.json +18 -0
- package/tsconfig.lib.prod.json +11 -0
- package/tsconfig.spec.json +15 -0
- package/classes/data-model.d.ts +0 -25
- package/fesm2022/jvsoft-utils-src-functions.mjs +0 -1109
- package/fesm2022/jvsoft-utils-src-functions.mjs.map +0 -1
- package/fesm2022/jvsoft-utils-src-interfaces.mjs +0 -6
- package/fesm2022/jvsoft-utils-src-interfaces.mjs.map +0 -1
- package/fesm2022/jvsoft-utils-src-pipes.mjs +0 -290
- package/fesm2022/jvsoft-utils-src-pipes.mjs.map +0 -1
- package/fesm2022/jvsoft-utils.mjs +0 -1526
- package/fesm2022/jvsoft-utils.mjs.map +0 -1
- package/functions/base64.d.ts +0 -2
- package/functions/browser.d.ts +0 -1
- package/functions/crypto-js.d.ts +0 -2
- package/functions/date.d.ts +0 -3
- package/functions/email.d.ts +0 -2
- package/functions/file.d.ts +0 -10
- package/functions/forms.d.ts +0 -10
- package/functions/http-client.d.ts +0 -2
- package/functions/index.d.ts +0 -1
- package/functions/local-storage.d.ts +0 -29
- package/functions/mat-form-controls/autocomplete.d.ts +0 -21
- package/functions/mat-form-controls/index.d.ts +0 -2
- package/functions/number.d.ts +0 -1
- package/functions/object-transformation.d.ts +0 -2
- package/functions/objects-arrays.d.ts +0 -37
- package/functions/public-api.d.ts +0 -16
- package/functions/string.d.ts +0 -1
- package/functions/sweetalert.d.ts +0 -5
- package/functions/utiles.d.ts +0 -1
- package/index.d.ts +0 -5
- package/interfaces/index.d.ts +0 -1
- package/interfaces/public-api.d.ts +0 -1
- package/pipes/data-en-lista.pipe.d.ts +0 -8
- package/pipes/date-diff-string.pipe.d.ts +0 -17
- package/pipes/filtro.pipe.d.ts +0 -18
- package/pipes/form-control-is-required.pipe.d.ts +0 -9
- package/pipes/index.d.ts +0 -1
- package/pipes/json-parse.pipe.d.ts +0 -7
- package/pipes/no-sanitize.pipe.d.ts +0 -10
- package/pipes/public-api.d.ts +0 -8
- package/pipes/tipo-valor-funcion.pipe.d.ts +0 -9
- package/pipes/zero-fill.pipe.d.ts +0 -8
- package/public-api.d.ts +0 -4
- package/src/functions/base64.d.ts +0 -2
- package/src/functions/browser.d.ts +0 -1
- package/src/functions/crypto-js.d.ts +0 -2
- package/src/functions/date.d.ts +0 -3
- package/src/functions/email.d.ts +0 -2
- package/src/functions/file.d.ts +0 -10
- package/src/functions/forms.d.ts +0 -10
- package/src/functions/http-client.d.ts +0 -2
- package/src/functions/index.d.ts +0 -5
- package/src/functions/local-storage.d.ts +0 -29
- package/src/functions/mat-form-controls/autocomplete.d.ts +0 -21
- package/src/functions/mat-form-controls/index.d.ts +0 -2
- package/src/functions/number.d.ts +0 -1
- package/src/functions/object-transformation.d.ts +0 -2
- package/src/functions/objects-arrays.d.ts +0 -37
- package/src/functions/public-api.d.ts +0 -16
- package/src/functions/string.d.ts +0 -1
- package/src/functions/sweetalert.d.ts +0 -5
- package/src/functions/utiles.d.ts +0 -1
- package/src/interfaces/datos.d.ts +0 -4
- package/src/interfaces/index.d.ts +0 -5
- package/src/interfaces/public-api.d.ts +0 -1
- package/src/pipes/data-en-lista.pipe.d.ts +0 -8
- package/src/pipes/date-diff-string.pipe.d.ts +0 -17
- package/src/pipes/filtro.pipe.d.ts +0 -18
- package/src/pipes/form-control-is-required.pipe.d.ts +0 -9
- package/src/pipes/index.d.ts +0 -5
- package/src/pipes/json-parse.pipe.d.ts +0 -7
- package/src/pipes/no-sanitize.pipe.d.ts +0 -10
- package/src/pipes/public-api.d.ts +0 -8
- package/src/pipes/tipo-valor-funcion.pipe.d.ts +0 -9
- package/src/pipes/zero-fill.pipe.d.ts +0 -8
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import {Route} from '@angular/router';
|
|
2
|
+
import {Type} from '@angular/core';
|
|
3
|
+
|
|
4
|
+
export interface JVSoftRouteData {
|
|
5
|
+
scrollDisabled?: boolean;
|
|
6
|
+
toolbarShadowEnabled?: boolean;
|
|
7
|
+
containerEnabled?: boolean;
|
|
8
|
+
|
|
9
|
+
iMenuId?: number;
|
|
10
|
+
sinReloj?: boolean;
|
|
11
|
+
titulo?: string;
|
|
12
|
+
ignorarDerechos?: boolean,
|
|
13
|
+
derechos?: any;
|
|
14
|
+
|
|
15
|
+
[key: string]: any;
|
|
16
|
+
|
|
17
|
+
// camposFiltro?: CampoFiltro[];
|
|
18
|
+
// parametrosFiltro?: ControlParams[];
|
|
19
|
+
// parametrosFiltro$?: Observable<ControlParams[]>;
|
|
20
|
+
/** Usar junto al guard CanActivate 'activarCondicionDespachoGuard' **/
|
|
21
|
+
activarCondicionDespachoGuardParams?: {
|
|
22
|
+
condicion?(despacho: any): boolean,
|
|
23
|
+
error?: {
|
|
24
|
+
rutaRedireccion?: string,
|
|
25
|
+
mensaje?: string,
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
|
|
29
|
+
headerTemplates?: {
|
|
30
|
+
bajo?: Type<any>;
|
|
31
|
+
medio?: Type<any>;
|
|
32
|
+
botonesCentro: any[];
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
export interface JVSoftRoute extends Route {
|
|
38
|
+
data?: JVSoftRouteData;
|
|
39
|
+
children?: JVSoftRoute[];
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export type JVSoftRoutes = JVSoftRoute[];
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import {Pipe, PipeTransform} from '@angular/core';
|
|
2
|
+
|
|
3
|
+
@Pipe({
|
|
4
|
+
name: 'dataEnLista',
|
|
5
|
+
})
|
|
6
|
+
export class DataEnListaPipe implements PipeTransform {
|
|
7
|
+
|
|
8
|
+
transform(coleccion: object[], idBuscar: string | string[], dato: any): any {
|
|
9
|
+
if (coleccion) {
|
|
10
|
+
if (Array.isArray(idBuscar)) {
|
|
11
|
+
return coleccion.find(item => {
|
|
12
|
+
const arrCoincide: any[] = [];
|
|
13
|
+
idBuscar.forEach((campo: string, idx) => {
|
|
14
|
+
// @ts-ignore
|
|
15
|
+
arrCoincide.push((item[campo] == dato[idx]));
|
|
16
|
+
});
|
|
17
|
+
return arrCoincide.every(e => e === true);
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
// @ts-ignore
|
|
21
|
+
return coleccion.find(item => item[idBuscar] == dato);
|
|
22
|
+
}
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// opcSelec(coleccion, idBuscar, formControl) {
|
|
27
|
+
// if (coleccion) {
|
|
28
|
+
// if (formControl.value == '') {
|
|
29
|
+
// return {cModuloNombre: '', cModuloPadreNombre: 'Todos', iModuloId: ''};
|
|
30
|
+
// }
|
|
31
|
+
// return coleccion.find(item => item[idBuscar] == formControl.value);
|
|
32
|
+
// }
|
|
33
|
+
// return null;
|
|
34
|
+
// }
|
|
35
|
+
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function dataEnLista(coleccion: object[], idBuscar: string | string[], dato: any): any {
|
|
39
|
+
return new DataEnListaPipe().transform(coleccion, idBuscar, dato);
|
|
40
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import {Pipe, PipeTransform} from '@angular/core';
|
|
2
|
+
|
|
3
|
+
@Pipe({
|
|
4
|
+
name: 'dateDiffString',
|
|
5
|
+
pure: true
|
|
6
|
+
})
|
|
7
|
+
export class DateDiffStringPipe implements PipeTransform {
|
|
8
|
+
transform(startingDate: Date, endingDate: Date): any {
|
|
9
|
+
let startDate = new Date(startingDate);
|
|
10
|
+
// user not pass endingDate then set current date as end date.
|
|
11
|
+
if (!endingDate) {
|
|
12
|
+
endingDate = new Date();
|
|
13
|
+
}
|
|
14
|
+
let endDate = new Date(endingDate);
|
|
15
|
+
// chack start date and end date and base on condication alter date.
|
|
16
|
+
if (startDate > endDate) {
|
|
17
|
+
const swap = startDate;
|
|
18
|
+
startDate = endDate;
|
|
19
|
+
endDate = swap;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const disgregado = this.separarMilisegundos(endDate.getTime() - startDate.getTime());
|
|
23
|
+
// console.log(disgregado);
|
|
24
|
+
const formatearATexto = (arrayToFill: string[], campo: any, texto: any, textoPlural = 's') => {
|
|
25
|
+
if (campo > 0) {
|
|
26
|
+
arrayToFill.push( campo + ' ' + texto + (campo > 1 ? textoPlural : '') );
|
|
27
|
+
}
|
|
28
|
+
return arrayToFill;
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
let arrDFinal: any[] = [];
|
|
32
|
+
arrDFinal = formatearATexto(arrDFinal, disgregado.years, 'año');
|
|
33
|
+
arrDFinal = formatearATexto(arrDFinal, disgregado.months, 'mes', 'es');
|
|
34
|
+
arrDFinal = formatearATexto(arrDFinal, disgregado.weeks, 'semana');
|
|
35
|
+
arrDFinal = formatearATexto(arrDFinal, disgregado.days, 'día');
|
|
36
|
+
arrDFinal = formatearATexto(arrDFinal, disgregado.hours, 'hora');
|
|
37
|
+
arrDFinal = formatearATexto(arrDFinal, disgregado.minutes, 'minuto');
|
|
38
|
+
arrDFinal = formatearATexto(arrDFinal, disgregado.seconds, 'segundo');
|
|
39
|
+
if (arrDFinal.length > 3) {
|
|
40
|
+
arrDFinal.splice(3);
|
|
41
|
+
arrDFinal.splice(-1, 0, 'y');
|
|
42
|
+
} else {
|
|
43
|
+
if (arrDFinal.length > 1) {
|
|
44
|
+
arrDFinal.splice(-1, 0, 'y');
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
return arrDFinal.join(' ');
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
separarMilisegundos(milisegundos: any): {
|
|
51
|
+
years: number,
|
|
52
|
+
months: number,
|
|
53
|
+
weeks: number,
|
|
54
|
+
days: number,
|
|
55
|
+
hours: number,
|
|
56
|
+
minutes: number,
|
|
57
|
+
seconds: number,
|
|
58
|
+
} {
|
|
59
|
+
const todoEnSegundos = milisegundos / 1000;
|
|
60
|
+
let secsUsed = 0;
|
|
61
|
+
const years = Math.floor(todoEnSegundos / 31536000);
|
|
62
|
+
if (years > 0) {
|
|
63
|
+
secsUsed += (years * 31536000);
|
|
64
|
+
}
|
|
65
|
+
const months = Math.floor((todoEnSegundos - secsUsed) / 2628288);
|
|
66
|
+
if (months > 0) {
|
|
67
|
+
secsUsed += (months * 2628288);
|
|
68
|
+
}
|
|
69
|
+
const weeks = Math.floor((todoEnSegundos - secsUsed) / 604800);
|
|
70
|
+
if (weeks > 0) {
|
|
71
|
+
secsUsed += (weeks * 604800);
|
|
72
|
+
}
|
|
73
|
+
const days = Math.floor((todoEnSegundos - secsUsed) / 86400);
|
|
74
|
+
if (days > 0) {
|
|
75
|
+
secsUsed += (days * 86400);
|
|
76
|
+
}
|
|
77
|
+
const hours = Math.floor((todoEnSegundos - secsUsed) / 3600);
|
|
78
|
+
if (hours > 0) {
|
|
79
|
+
secsUsed += (hours * 3600);
|
|
80
|
+
}
|
|
81
|
+
const minutes = Math.floor((todoEnSegundos - secsUsed) / 60);
|
|
82
|
+
if (minutes > 0) {
|
|
83
|
+
secsUsed += (minutes * 60);
|
|
84
|
+
}
|
|
85
|
+
const seconds = Math.round(todoEnSegundos - secsUsed);
|
|
86
|
+
|
|
87
|
+
return {
|
|
88
|
+
years,
|
|
89
|
+
months,
|
|
90
|
+
weeks,
|
|
91
|
+
days,
|
|
92
|
+
hours,
|
|
93
|
+
minutes,
|
|
94
|
+
seconds,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/*
|
|
99
|
+
transform(to: Date, from: Date, seconds = true, strict = false): string {
|
|
100
|
+
if (typeof to == 'string') {
|
|
101
|
+
to = new Date(to);
|
|
102
|
+
}
|
|
103
|
+
if (typeof from == 'string') {
|
|
104
|
+
from = new Date(from);
|
|
105
|
+
}
|
|
106
|
+
console.log(typeof to, typeof from);
|
|
107
|
+
console.log(to);
|
|
108
|
+
console.log(from);
|
|
109
|
+
|
|
110
|
+
return strict ? formatDistanceStrict(from, to, {unit: 'minute', locale: es}) : formatDistance(from, to, {includeSeconds: seconds, locale: es});
|
|
111
|
+
}
|
|
112
|
+
*/
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export function dateDiffString(startingDate: Date, endingDate: Date){
|
|
116
|
+
return new DateDiffStringPipe().transform(startingDate, endingDate);
|
|
117
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import {Pipe, PipeTransform} from '@angular/core';
|
|
2
|
+
|
|
3
|
+
interface OpcionesBusqueda {
|
|
4
|
+
texto: string;
|
|
5
|
+
longitudMinima?: number;
|
|
6
|
+
campo?: string | string[];
|
|
7
|
+
mostrarObligado?: MostrarObligado;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
interface MostrarObligado {
|
|
11
|
+
campo: string;
|
|
12
|
+
items: any[];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@Pipe({
|
|
16
|
+
name: 'filtro'
|
|
17
|
+
})
|
|
18
|
+
export class FiltroPipe implements PipeTransform {
|
|
19
|
+
|
|
20
|
+
transform(items: any[], opcionesBusqueda: OpcionesBusqueda): any[] {
|
|
21
|
+
if (!items || !Array.isArray(items)) return [];
|
|
22
|
+
if (!opcionesBusqueda.texto || opcionesBusqueda.texto.length < (opcionesBusqueda.longitudMinima ?? 1)) return items;
|
|
23
|
+
|
|
24
|
+
const normalize = (() => {
|
|
25
|
+
const from = 'ÃÀÁÄÂÈÉËÊÌÍÏÎÒÓÖÔÙÚÜÛãàáäâèéëêìíïîòóöôùúüûÑñÇç';
|
|
26
|
+
const to = 'AAAAAEEEEIIIIOOOOUUUUaaaaaeeeeiiiioooouuuunncc';
|
|
27
|
+
const mapping: Record<string, string> = {};
|
|
28
|
+
|
|
29
|
+
for (let i = 0; i < from.length; i++) {
|
|
30
|
+
mapping[from[i]] = to[i];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return (str: string): string => {
|
|
34
|
+
return str.split('').map(c => mapping[c] || c).join('');
|
|
35
|
+
};
|
|
36
|
+
})();
|
|
37
|
+
|
|
38
|
+
const textoNormalizado = normalize(opcionesBusqueda.texto.toLowerCase());
|
|
39
|
+
|
|
40
|
+
return items.filter(item => {
|
|
41
|
+
// 🔹 Manejo de `mostrarObligado`
|
|
42
|
+
if (opcionesBusqueda.mostrarObligado) {
|
|
43
|
+
const {campo, items: obligados} = opcionesBusqueda.mostrarObligado;
|
|
44
|
+
if (obligados.includes(item[campo])) return true;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// 🔹 Manejo de `campo`
|
|
48
|
+
if (opcionesBusqueda.campo) {
|
|
49
|
+
if (Array.isArray(opcionesBusqueda.campo)) {
|
|
50
|
+
return opcionesBusqueda.campo.some(campo => {
|
|
51
|
+
const valor = item[campo] as string | undefined;
|
|
52
|
+
return valor ? normalize(valor.toLowerCase()).includes(textoNormalizado):false;
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
else {
|
|
56
|
+
const valor = item[opcionesBusqueda.campo] as string | undefined;
|
|
57
|
+
return valor ? normalize(valor.toLowerCase()).includes(textoNormalizado):false;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return false;
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import {Pipe, PipeTransform} from '@angular/core';
|
|
2
|
+
import {AbstractControl, Validators} from '@angular/forms';
|
|
3
|
+
|
|
4
|
+
@Pipe({
|
|
5
|
+
name: 'formControlIsRequired'
|
|
6
|
+
})
|
|
7
|
+
export class FormControlIsRequiredPipe implements PipeTransform {
|
|
8
|
+
|
|
9
|
+
transform(formControl: AbstractControl, ...args: unknown[]): any {
|
|
10
|
+
if (!formControl) { return false; }
|
|
11
|
+
return formControl.hasValidator(Validators.required);
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
}
|
|
15
|
+
export function formControlIsRequired(formControl: AbstractControl) {
|
|
16
|
+
return new FormControlIsRequiredPipe().transform(formControl);
|
|
17
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './public-api'
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Pipe, PipeTransform } from '@angular/core';
|
|
2
|
+
|
|
3
|
+
@Pipe({
|
|
4
|
+
name: 'jsonParse'
|
|
5
|
+
})
|
|
6
|
+
export class JsonParsePipe implements PipeTransform {
|
|
7
|
+
|
|
8
|
+
transform(value: string, ...args: unknown[]): any {
|
|
9
|
+
if (!value) { return []; }
|
|
10
|
+
try {
|
|
11
|
+
return JSON.parse(value);
|
|
12
|
+
} catch (e) {
|
|
13
|
+
console.warn('La cadena "' + value + '" no es JSON');
|
|
14
|
+
return [];
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import {Pipe, PipeTransform} from '@angular/core';
|
|
2
|
+
import {DomSanitizer, SafeHtml} from '@angular/platform-browser';
|
|
3
|
+
|
|
4
|
+
@Pipe({ name: 'noSanitize' })
|
|
5
|
+
export class NoSanitizePipe implements PipeTransform {
|
|
6
|
+
constructor(private domSanitizer: DomSanitizer) {
|
|
7
|
+
|
|
8
|
+
}
|
|
9
|
+
transform(html: string): SafeHtml {
|
|
10
|
+
return this.domSanitizer.bypassSecurityTrustHtml(html);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
|
|
2
|
+
export * from './data-en-lista.pipe';
|
|
3
|
+
export * from './date-diff-string.pipe';
|
|
4
|
+
export * from './filtro.pipe'
|
|
5
|
+
export * from './form-control-is-required.pipe'
|
|
6
|
+
export * from './json-parse.pipe'
|
|
7
|
+
export * from './no-sanitize.pipe'
|
|
8
|
+
export * from './tipo-valor-funcion.pipe'
|
|
9
|
+
export * from './zero-fill.pipe'
|
|
10
|
+
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import {Pipe, PipeTransform} from '@angular/core';
|
|
2
|
+
|
|
3
|
+
export type TipoValorFuncion<T> = T | ((...param: any) => T);
|
|
4
|
+
|
|
5
|
+
@Pipe({
|
|
6
|
+
name: 'tipoValorFuncion',
|
|
7
|
+
standalone: true, // Para usarlo en standalone components
|
|
8
|
+
})
|
|
9
|
+
export class TipoValorFuncionPipe implements PipeTransform {
|
|
10
|
+
transform<T>(datoParam: TipoValorFuncion<T>, defaultValue?: T, ...param: any[]): T | undefined {
|
|
11
|
+
if (datoParam === undefined || datoParam === null) {
|
|
12
|
+
return defaultValue;
|
|
13
|
+
}
|
|
14
|
+
if (typeof datoParam === 'function') {
|
|
15
|
+
return (datoParam as (...args: any) => T)(...param);
|
|
16
|
+
}
|
|
17
|
+
return datoParam;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function tipoValorFuncion<T>(datoParam: TipoValorFuncion<T>, defaultValue?: T, ...param: any[]): T | undefined {
|
|
22
|
+
return new TipoValorFuncionPipe().transform(datoParam, defaultValue, ...param);
|
|
23
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import {Pipe, PipeTransform} from '@angular/core';
|
|
2
|
+
|
|
3
|
+
@Pipe({
|
|
4
|
+
name: 'zeroFill',
|
|
5
|
+
})
|
|
6
|
+
export class ZeroFillPipe implements PipeTransform {
|
|
7
|
+
|
|
8
|
+
transform(value: unknown, digitos: number, ...args: unknown[]) {
|
|
9
|
+
let s = value + '';
|
|
10
|
+
while (s.length < digitos) {
|
|
11
|
+
s = '0' + s;
|
|
12
|
+
}
|
|
13
|
+
return s;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
}
|
|
17
|
+
export function zeroFill(value: unknown, digitos: number, ...args: unknown[]) {
|
|
18
|
+
return new ZeroFillPipe().transform(value, digitos, args);
|
|
19
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Public API Surface of utils
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export * from './classes/data-model';
|
|
6
|
+
export * from './functions';
|
|
7
|
+
export * from './pipes';
|
|
8
|
+
export * from './interfaces';
|
|
9
|
+
// export * from './functions/common.function';
|
|
10
|
+
|
|
11
|
+
// export * from './lib/utils.component';
|
|
12
|
+
// export * from './lib/utils.service';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
|
2
|
+
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
|
3
|
+
{
|
|
4
|
+
"extends": "../../tsconfig.json",
|
|
5
|
+
"compilerOptions": {
|
|
6
|
+
"outDir": "../../out-tsc/lib",
|
|
7
|
+
"rootDir": ".", // ✅ permite que cualquier subcarpeta como "functions/" esté incluida
|
|
8
|
+
"baseUrl": ".",
|
|
9
|
+
"declaration": true,
|
|
10
|
+
"declarationMap": true,
|
|
11
|
+
"sourceMap": true,
|
|
12
|
+
"inlineSources": true,
|
|
13
|
+
"types": []
|
|
14
|
+
},
|
|
15
|
+
"exclude": [
|
|
16
|
+
"**/*.spec.ts"
|
|
17
|
+
]
|
|
18
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
|
2
|
+
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
|
3
|
+
{
|
|
4
|
+
"extends": "./tsconfig.lib.json",
|
|
5
|
+
"compilerOptions": {
|
|
6
|
+
"declarationMap": false
|
|
7
|
+
},
|
|
8
|
+
"angularCompilerOptions": {
|
|
9
|
+
"compilationMode": "partial"
|
|
10
|
+
}
|
|
11
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/* To learn more about Typescript configuration file: https://www.typescriptlang.org/docs/handbook/tsconfig-json.html. */
|
|
2
|
+
/* To learn more about Angular compiler options: https://angular.dev/reference/configs/angular-compiler-options. */
|
|
3
|
+
{
|
|
4
|
+
"extends": "../../tsconfig.json",
|
|
5
|
+
"compilerOptions": {
|
|
6
|
+
"outDir": "../../out-tsc/spec",
|
|
7
|
+
"types": [
|
|
8
|
+
"jasmine"
|
|
9
|
+
]
|
|
10
|
+
},
|
|
11
|
+
"include": [
|
|
12
|
+
"**/*.spec.ts",
|
|
13
|
+
"**/*.d.ts"
|
|
14
|
+
]
|
|
15
|
+
}
|
package/classes/data-model.d.ts
DELETED
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { FormGroup } from '@angular/forms';
|
|
2
|
-
export declare class DataModel {
|
|
3
|
-
modelosChk: {
|
|
4
|
-
[key: string]: boolean | any;
|
|
5
|
-
};
|
|
6
|
-
checkbox: ForCheckboxModel;
|
|
7
|
-
constructor();
|
|
8
|
-
generarId(row: any, campoValor: string[] | string, separador?: string): string;
|
|
9
|
-
agregarControles(lista: any[], idLista: string, limpiar?: boolean, campoValor?: string[] | string | null, campoValorSeparador?: string): void;
|
|
10
|
-
setState(idx: string, state: boolean): void;
|
|
11
|
-
getState(idx: string): boolean | any;
|
|
12
|
-
getDataMultiple(idx: string): any;
|
|
13
|
-
generarLista(tipoRetorno?: 'array' | 'object' | null, esCampoNumerico?: boolean): string | object | any[];
|
|
14
|
-
generarFormGroupFromModelosChk(tipo?: string): FormGroup;
|
|
15
|
-
}
|
|
16
|
-
declare class ForCheckboxModel {
|
|
17
|
-
private modeloCheck;
|
|
18
|
-
constructor(modeloCheck: DataModel);
|
|
19
|
-
get cantidadActivos(): number;
|
|
20
|
-
get existenActivados(): boolean;
|
|
21
|
-
get todosActivos(): boolean;
|
|
22
|
-
get algunosActivos(): boolean;
|
|
23
|
-
establecerTodos(activo: boolean): void;
|
|
24
|
-
}
|
|
25
|
-
export {};
|