@jvsoft/utils 0.0.13-alpha.2 → 0.0.13-alpha.3
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/fesm2022/jvsoft-utils-src-functions.mjs +260 -2
- package/fesm2022/jvsoft-utils-src-functions.mjs.map +1 -1
- package/fesm2022/jvsoft-utils.mjs +260 -2
- package/fesm2022/jvsoft-utils.mjs.map +1 -1
- package/functions/forms.d.ts +14 -1
- package/functions/number.d.ts +1 -0
- package/functions/objects-arrays.d.ts +10 -0
- package/functions/string.d.ts +22 -0
- package/package.json +6 -6
- package/src/functions/forms.d.ts +14 -1
- package/src/functions/number.d.ts +1 -0
- package/src/functions/objects-arrays.d.ts +10 -0
- package/src/functions/string.d.ts +22 -0
package/functions/forms.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { AbstractControl, FormGroup } from '@angular/forms';
|
|
1
|
+
import { AbstractControl, FormControl, FormGroup } from '@angular/forms';
|
|
2
|
+
import { BehaviorSubject } from 'rxjs';
|
|
2
3
|
export declare function establecerQuitarRequired(formulario: FormGroup, establecer?: any[], quitar?: any[], camposDisabled?: string[] | 'todos'): void;
|
|
3
4
|
export declare function getFormValidationErrors(form: FormGroup): {
|
|
4
5
|
control: string;
|
|
@@ -8,3 +9,15 @@ export declare function getFormValidationErrors(form: FormGroup): {
|
|
|
8
9
|
export declare function mensajesErrorFormControl(control: AbstractControl | null): string;
|
|
9
10
|
export declare function toFormData<T extends Record<string, any>>(formValue: T): FormData;
|
|
10
11
|
export declare function markAsTouchedWithoutEmitEvent(control: AbstractControl): void;
|
|
12
|
+
export interface SetControlDesdeListaConfig<T, V = any> {
|
|
13
|
+
lista$: BehaviorSubject<T[]>;
|
|
14
|
+
formControl?: FormControl<V>;
|
|
15
|
+
formGroup?: FormGroup;
|
|
16
|
+
controlName?: string;
|
|
17
|
+
idProp?: keyof T;
|
|
18
|
+
idValor?: any;
|
|
19
|
+
selector?: (item: T) => V;
|
|
20
|
+
usarPrimeraOpcion?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export declare function setControlDesdeLista<T, V = any>(config: SetControlDesdeListaConfig<T, V>): void;
|
|
23
|
+
export declare function transformarFechasPorNombreDeCampo<T extends Record<string, any>>(formValue: T): T;
|
package/functions/number.d.ts
CHANGED
|
@@ -35,3 +35,13 @@ export declare function nestGroupsBy(arr: any, properties: any): any;
|
|
|
35
35
|
* @returns El valor máximo encontrado, posiblemente incrementado.
|
|
36
36
|
*/
|
|
37
37
|
export declare function obtenerUltimoOrden(data: any[], campo: string, incrementar?: boolean): number;
|
|
38
|
+
/**
|
|
39
|
+
* Elimina una o varias columnas específicas (por índice) de una tabla representada como array de arrays.
|
|
40
|
+
*
|
|
41
|
+
* @param data - Array de filas (cada fila debe ser un array).
|
|
42
|
+
* @param columnIndex - Índice o lista de índices de las columnas a eliminar.
|
|
43
|
+
* @returns Nuevo array con las columnas eliminadas.
|
|
44
|
+
*/
|
|
45
|
+
export declare function eliminarColumnaPorIndex<T extends unknown[][]>(data: T, columnIndex: number | number[]): T;
|
|
46
|
+
export declare function eliminarDuplicados<T extends object>(array: T[], claves?: (keyof T)[]): T[];
|
|
47
|
+
export declare function eliminarElementos<T extends object>(origen: T[], elementosAEliminar: T[], claves?: (keyof T)[]): T[];
|
package/functions/string.d.ts
CHANGED
|
@@ -1 +1,23 @@
|
|
|
1
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;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jvsoft/utils",
|
|
3
|
-
"version": "0.0.13-alpha.
|
|
3
|
+
"version": "0.0.13-alpha.3",
|
|
4
4
|
"description": "JVSOFT Angular Utils",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"tag": "alpha",
|
|
@@ -34,10 +34,6 @@
|
|
|
34
34
|
"types": "./index.d.ts",
|
|
35
35
|
"default": "./fesm2022/jvsoft-utils.mjs"
|
|
36
36
|
},
|
|
37
|
-
"./src/interfaces": {
|
|
38
|
-
"types": "./src/interfaces/index.d.ts",
|
|
39
|
-
"default": "./fesm2022/jvsoft-utils-src-interfaces.mjs"
|
|
40
|
-
},
|
|
41
37
|
"./src/functions": {
|
|
42
38
|
"types": "./src/functions/index.d.ts",
|
|
43
39
|
"default": "./fesm2022/jvsoft-utils-src-functions.mjs"
|
|
@@ -45,6 +41,10 @@
|
|
|
45
41
|
"./src/pipes": {
|
|
46
42
|
"types": "./src/pipes/index.d.ts",
|
|
47
43
|
"default": "./fesm2022/jvsoft-utils-src-pipes.mjs"
|
|
44
|
+
},
|
|
45
|
+
"./src/interfaces": {
|
|
46
|
+
"types": "./src/interfaces/index.d.ts",
|
|
47
|
+
"default": "./fesm2022/jvsoft-utils-src-interfaces.mjs"
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
-
}
|
|
50
|
+
}
|
package/src/functions/forms.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { AbstractControl, FormGroup } from '@angular/forms';
|
|
1
|
+
import { AbstractControl, FormControl, FormGroup } from '@angular/forms';
|
|
2
|
+
import { BehaviorSubject } from 'rxjs';
|
|
2
3
|
export declare function establecerQuitarRequired(formulario: FormGroup, establecer?: any[], quitar?: any[], camposDisabled?: string[] | 'todos'): void;
|
|
3
4
|
export declare function getFormValidationErrors(form: FormGroup): {
|
|
4
5
|
control: string;
|
|
@@ -8,3 +9,15 @@ export declare function getFormValidationErrors(form: FormGroup): {
|
|
|
8
9
|
export declare function mensajesErrorFormControl(control: AbstractControl | null): string;
|
|
9
10
|
export declare function toFormData<T extends Record<string, any>>(formValue: T): FormData;
|
|
10
11
|
export declare function markAsTouchedWithoutEmitEvent(control: AbstractControl): void;
|
|
12
|
+
export interface SetControlDesdeListaConfig<T, V = any> {
|
|
13
|
+
lista$: BehaviorSubject<T[]>;
|
|
14
|
+
formControl?: FormControl<V>;
|
|
15
|
+
formGroup?: FormGroup;
|
|
16
|
+
controlName?: string;
|
|
17
|
+
idProp?: keyof T;
|
|
18
|
+
idValor?: any;
|
|
19
|
+
selector?: (item: T) => V;
|
|
20
|
+
usarPrimeraOpcion?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export declare function setControlDesdeLista<T, V = any>(config: SetControlDesdeListaConfig<T, V>): void;
|
|
23
|
+
export declare function transformarFechasPorNombreDeCampo<T extends Record<string, any>>(formValue: T): T;
|
|
@@ -35,3 +35,13 @@ export declare function nestGroupsBy(arr: any, properties: any): any;
|
|
|
35
35
|
* @returns El valor máximo encontrado, posiblemente incrementado.
|
|
36
36
|
*/
|
|
37
37
|
export declare function obtenerUltimoOrden(data: any[], campo: string, incrementar?: boolean): number;
|
|
38
|
+
/**
|
|
39
|
+
* Elimina una o varias columnas específicas (por índice) de una tabla representada como array de arrays.
|
|
40
|
+
*
|
|
41
|
+
* @param data - Array de filas (cada fila debe ser un array).
|
|
42
|
+
* @param columnIndex - Índice o lista de índices de las columnas a eliminar.
|
|
43
|
+
* @returns Nuevo array con las columnas eliminadas.
|
|
44
|
+
*/
|
|
45
|
+
export declare function eliminarColumnaPorIndex<T extends unknown[][]>(data: T, columnIndex: number | number[]): T;
|
|
46
|
+
export declare function eliminarDuplicados<T extends object>(array: T[], claves?: (keyof T)[]): T[];
|
|
47
|
+
export declare function eliminarElementos<T extends object>(origen: T[], elementosAEliminar: T[], claves?: (keyof T)[]): T[];
|
|
@@ -1 +1,23 @@
|
|
|
1
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;
|