@jvsoft/utils 0.0.13-alpha.0 → 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 +27 -7
  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 -19
  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
@@ -1,95 +0,0 @@
1
- import swal, {SweetAlertOptions, SweetAlertResult} from 'sweetalert2';
2
-
3
- export function mensajeAlerta(tipo: 'success' | 'error' | 'info' | 'warning' | 'question', titulo: string, mensaje: string, opciones?: SweetAlertOptions) {
4
- opciones = {
5
- ...{
6
- heightAuto: false,
7
- title: titulo,
8
- html: mensaje,
9
- icon: tipo,
10
- confirmButtonText: 'Aceptar',
11
- // customClass: {
12
- // confirmButton: 'btn btn-lg btn-outline-success mx-2',
13
- // cancelButton: 'btn btn-lg btn-outline-dark mx-2'
14
- // },
15
- // buttonsStyling: false
16
- },
17
- ...opciones
18
- };
19
- return swal.fire(opciones);
20
- }
21
-
22
- export function mensajeTimer(tipo: 'success' | 'error' | 'info' | 'warning' | 'question', titulo: string, mensaje: string, milisegundos = 3000, showLoading = true, opciones?: SweetAlertOptions) {
23
- let timerInterval: any;
24
- opciones = {
25
- ...{
26
- heightAuto: false,
27
- title: titulo,
28
- html: mensaje + '<br> Se cerrará en <strong> X </strong> segundos.',
29
- icon: tipo,
30
- timer: milisegundos,
31
- showCancelButton: false,
32
- showConfirmButton: false,
33
- willOpen: () => {
34
- if (showLoading) {
35
- swal.showLoading();
36
- }
37
- timerInterval = setInterval(() => {
38
- const impr = Math.ceil(((swal.getTimerLeft() ?? 1)/ 1000));
39
- if (swal.getHtmlContainer()) {
40
- // @ts-ignore
41
- swal.getHtmlContainer().querySelector('strong').textContent = String(impr);
42
- }
43
- }, 100);
44
- },
45
- willClose: () => {
46
- clearInterval(timerInterval);
47
- }
48
- },
49
- ...opciones
50
- };
51
- return swal.fire(opciones);
52
- }
53
-
54
- // @ts-ignore
55
- export function mensajeConfirmacion(tipo: 'success' | 'error' | 'info' | 'warning' | 'question', titulo, mensaje, opciones?: SweetAlertOptions): Promise<SweetAlertResult<Awaited<any>>> {
56
- opciones = {
57
- ...{
58
- heightAuto: false,
59
- title: titulo,
60
- html: mensaje,
61
- icon: tipo,
62
- showCancelButton: true,
63
- // confirmButtonColor: '#3f51b5',
64
- // cancelButtonColor: '#ffffff',
65
- confirmButtonText: 'Confirmar',
66
- cancelButtonText: 'Cancelar',
67
- reverseButtons: true,
68
- // customClass: {
69
- // confirmButton: 'btn btn-lg btn-outline-success mx-2',
70
- // cancelButton: 'btn btn-lg btn-outline-dark mx-2'
71
- // },
72
- // buttonsStyling: false
73
- },
74
- ...opciones
75
- };
76
- return swal.fire(opciones);
77
- }
78
- export function mensajeToast(tipo: 'success' | 'error' | 'info' | 'warning' | 'question', titulo: string, mensaje: string, opciones?: SweetAlertOptions) {
79
- opciones = {
80
- ...{
81
- heightAuto: false,
82
- title: titulo,
83
- html: mensaje,
84
- icon: tipo,
85
- confirmButtonText: 'Aceptar',
86
- toast: true,
87
- position: 'top-end',
88
- showConfirmButton: false,
89
- timer: 3000,
90
- timerProgressBar: true,
91
- },
92
- ...opciones
93
- };
94
- return swal.fire(opciones);
95
- }
@@ -1,20 +0,0 @@
1
- import {mensajeAlerta} from './sweetalert';
2
-
3
- export function verificarRUC(ruc: string) {
4
- const f = [5, 4, 3, 2, 7, 6, 5, 4, 3, 2];
5
- const rucArray = ruc.split('');
6
- const nArray = f.map((item, idx) => {
7
- return item * parseFloat(rucArray[idx]);
8
- });
9
- const suma = nArray.reduce((a, b) => a + b, 0);
10
- const residuo = suma % 11;
11
- const residuo2 = 11 - residuo;
12
- // @residuo=CONVERT(Integer,Right(CONVERT(VarChar,@residuo),1))
13
- const residuo3 = residuo2.toString().charAt(residuo2.toString().length - 1);
14
- const ultimoCaracter = ruc.toString().charAt(ruc.toString().length - 1);
15
- if (residuo3 == ultimoCaracter) {
16
- return true;
17
- }
18
- mensajeAlerta('error', 'Datos No válidos', ' El número de RUC no es válido');
19
- return false;
20
- }
@@ -1 +0,0 @@
1
- export * from './public-api'
@@ -1,5 +0,0 @@
1
- {
2
- "lib": {
3
- "entryFile": "public-api.ts"
4
- }
5
- }
File without changes
@@ -1,3 +0,0 @@
1
- export * from './datos';
2
- // export * from './otros';
3
-
@@ -1,42 +0,0 @@
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[];
@@ -1,40 +0,0 @@
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
- }
@@ -1,117 +0,0 @@
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
- }
@@ -1,64 +0,0 @@
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
- }
@@ -1,17 +0,0 @@
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
- }
@@ -1 +0,0 @@
1
- export * from './public-api'
@@ -1,18 +0,0 @@
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
- }
@@ -1,5 +0,0 @@
1
- {
2
- "lib": {
3
- "entryFile": "public-api.ts"
4
- }
5
- }
@@ -1,12 +0,0 @@
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
- }
@@ -1,10 +0,0 @@
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
-
@@ -1,23 +0,0 @@
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
- }
@@ -1,19 +0,0 @@
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
- }
package/src/public-api.ts DELETED
@@ -1,12 +0,0 @@
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';
package/tsconfig.lib.json DELETED
@@ -1,17 +0,0 @@
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
- "declaration": true,
9
- "declarationMap": true,
10
- "sourceMap": true,
11
- "inlineSources": true,
12
- "types": []
13
- },
14
- "exclude": [
15
- "**/*.spec.ts"
16
- ]
17
- }
@@ -1,11 +0,0 @@
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
- }
@@ -1,15 +0,0 @@
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
- }