@c80/ui 1.0.31 → 1.0.33
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/esm2022/index.mjs +5 -5
- package/esm2022/lib/icon/index.mjs +2 -0
- package/esm2022/lib/stat-card/index.mjs +2 -0
- package/esm2022/lib/table/index.mjs +7 -1
- package/esm2022/lib/table/table-column-visibility.service.mjs +156 -0
- package/esm2022/lib/table/table-crud-state.service.mjs +165 -0
- package/esm2022/lib/table/table-data-converter.service.mjs +149 -0
- package/esm2022/lib/table/table-data-utils.service.mjs +166 -0
- package/esm2022/lib/table/table-selection.service.mjs +151 -0
- package/esm2022/lib/table/table.component.mjs +59 -500
- package/esm2022/lib/table/table.types.mjs +5 -0
- package/index.d.ts +4 -4
- package/lib/icon/index.d.ts +1 -0
- package/lib/stat-card/index.d.ts +1 -0
- package/lib/table/index.d.ts +6 -0
- package/lib/table/table-column-visibility.service.d.ts +71 -0
- package/lib/table/table-crud-state.service.d.ts +44 -0
- package/lib/table/table-data-converter.service.d.ts +50 -0
- package/lib/table/table-data-utils.service.d.ts +70 -0
- package/lib/table/table-selection.service.d.ts +39 -0
- package/lib/table/table.component.d.ts +14 -99
- package/lib/table/table.types.d.ts +16 -0
- package/package.json +1 -1
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tipos comunes para las tablas C80
|
|
3
|
+
*/
|
|
4
|
+
export {};
|
|
5
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGFibGUudHlwZXMuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi9saWJzL3VpL3NyYy9saWIvdGFibGUvdGFibGUudHlwZXMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUE7O0dBRUciLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIFRpcG9zIGNvbXVuZXMgcGFyYSBsYXMgdGFibGFzIEM4MFxuICovXG5cbmV4cG9ydCB0eXBlIElEID0gbnVtYmVyIHwgc3RyaW5nO1xuXG5leHBvcnQgaW50ZXJmYWNlIEM4MFRhYmxlQ29sRGVmIHtcbiAgICBhY2Nlc3Nvcjogc3RyaW5nO1xuICAgIGxhYmVsOiBzdHJpbmc7XG4gICAgdmlzaWJsZT86IGJvb2xlYW47IC8vIFNpIG5vIHNlIGVzcGVjaWZpY2EsIHNlIGFzdW1lIHRydWUuIFNpIGVzIGZhbHNlLCBsYSBjb2x1bW5hIHNlIG9jdWx0YSBTSUVNUFJFIChtw6F4aW1hIHByaW9yaWRhZClcbiAgICB0eXBlPzogJ3N0cmluZycgfCAnbnVtYmVyJyB8ICdpbnRlZ2VyJyB8ICdib29sZWFuJyB8ICdwYXNzd29yZCcgfCAnZW51bSc7IC8vIFRpcG8gZGUgZGF0byBwYXJhIGxhIGNvbHVtbmFcbiAgICBvcmRlcj86ICdBU0MnIHwgJ0RFU0MnOyAvLyBPcmRlbmFtaWVudG8gZGUgbGEgY29sdW1uYVxuICAgIHJlYWRPbmx5PzogYm9vbGVhbjsgLy8gU2kgbm8gc2UgZXNwZWNpZmljYSwgc2UgYXN1bWUgZmFsc2VcbiAgICBlbnVtPzogUmVjb3JkPHN0cmluZyB8IG51bWJlciwgc3RyaW5nPjsgLy8gT3BjaW9uZXMgZGVsIGVudW0gcGFyYSB0eXBlICdlbnVtJ1xuICAgIGNvbG9yPzogUmVjb3JkPHN0cmluZyB8IG51bWJlciwgc3RyaW5nPjsgLy8gQ29sb3JlcyBDU1MgYmFzYWRvcyBlbiBlbCB2YWxvciBkZSBsYSBjZWxkYVxuICAgIGhpZGVJZkFsbFZhbHVlc0FyZU51bGw/OiBib29sZWFuOyAvLyBTaSBlcyB0cnVlLCBvY3VsdGEgbGEgY29sdW1uYSBjdWFuZG8gdG9kb3MgbG9zIHZhbG9yZXMgZXN0w6FuIHZhY8Otb3MgKGRlZmF1bHQ6IGZhbHNlKS5cbiAgICAvLyBTb2xvIGFwbGljYSBzaSB2aXNpYmxlICE9PSBmYWxzZS4gRVhDRVBDScOTTjogRW4gbW9kbyBjcmVhY2nDs24gWSBlZGljacOzbiBzaWVtcHJlIHNlIG11ZXN0cmEuXG4gICAgZGVmYXVsdD86IHVua25vd247IC8vIFZhbG9yIHBvciBkZWZlY3RvIHBhcmEgdXNhciBlbiBtb2RvIGNyZWFjacOzbi4gUHVlZGUgc2VyIHN0cmluZywgbnVtYmVyLCBib29sZWFuLCBldGMuXG59XG4iXX0=
|
package/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * from './lib/table';
|
|
2
|
-
export * from './lib/icon
|
|
3
|
-
export * from './lib/stat-card
|
|
4
|
-
export * from './lib/card-level
|
|
5
|
-
export * from './lib/modal
|
|
2
|
+
export * from './lib/icon';
|
|
3
|
+
export * from './lib/stat-card';
|
|
4
|
+
export * from './lib/card-level';
|
|
5
|
+
export * from './lib/modal';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './icon.component';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './stat-card.component';
|
package/lib/table/index.d.ts
CHANGED
|
@@ -1 +1,7 @@
|
|
|
1
|
+
export * from './table.types';
|
|
1
2
|
export * from './table.component';
|
|
3
|
+
export * from './table-data-converter.service';
|
|
4
|
+
export * from './table-column-visibility.service';
|
|
5
|
+
export * from './table-data-utils.service';
|
|
6
|
+
export * from './table-selection.service';
|
|
7
|
+
export * from './table-crud-state.service';
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { C80TableColDef, ID } from './table.types';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
/**
|
|
4
|
+
* Servicio para gestionar la lógica de visibilidad de columnas en tablas C80
|
|
5
|
+
*
|
|
6
|
+
* Maneja las reglas complejas de visibilidad basadas en:
|
|
7
|
+
* - Configuración explícita (visible: false)
|
|
8
|
+
* - Ocultación automática (hideIfAllValuesAreNull)
|
|
9
|
+
* - Estado de creación y edición
|
|
10
|
+
*/
|
|
11
|
+
export declare class TableColumnVisibilityService {
|
|
12
|
+
private readonly dataConverter;
|
|
13
|
+
/**
|
|
14
|
+
* Actualiza las keys de columnas visibles basándose en el estado actual
|
|
15
|
+
* @param columns - Definiciones de columnas
|
|
16
|
+
* @param data - Datos actuales de la tabla
|
|
17
|
+
* @param creating - Si está en modo creación
|
|
18
|
+
* @param editing - ID de fila en edición (null si no hay edición)
|
|
19
|
+
* @returns Array de accessors de columnas visibles
|
|
20
|
+
*/
|
|
21
|
+
updateVisibleKeys<T extends Record<string, unknown>>(columns: C80TableColDef[], data: T[], creating: boolean, editing: ID | null): string[];
|
|
22
|
+
/**
|
|
23
|
+
* Determina si una columna debe ser visible basándose en su configuración y datos
|
|
24
|
+
* @param column - La definición de la columna
|
|
25
|
+
* @param data - Datos actuales de la tabla
|
|
26
|
+
* @param forceShowInCreation - Si es true, ignora hideIfAllValuesAreNull (usado en modo creación)
|
|
27
|
+
* @returns true si la columna debe ser visible
|
|
28
|
+
*/
|
|
29
|
+
isColumnVisible<T extends Record<string, unknown>>(column: C80TableColDef, data: T[], forceShowInCreation?: boolean): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Determina si una columna debe ser visible en los headers
|
|
32
|
+
* @param column - La definición de la columna
|
|
33
|
+
* @param data - Datos actuales de la tabla
|
|
34
|
+
* @param creating - Si está en modo creación
|
|
35
|
+
* @param editing - ID de fila en edición (null si no hay edición)
|
|
36
|
+
* @returns true si el header debe ser visible
|
|
37
|
+
*/
|
|
38
|
+
isColumnVisibleInHeader<T extends Record<string, unknown>>(column: C80TableColDef, data: T[], creating: boolean, editing: ID | null): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Determina si una columna debe ser visible en una fila específica considerando el modo edición
|
|
41
|
+
* @param column - La definición de la columna
|
|
42
|
+
* @param row - La fila actual
|
|
43
|
+
* @param data - Datos actuales de la tabla
|
|
44
|
+
* @param editing - ID de fila en edición (null si no hay edición)
|
|
45
|
+
* @returns true si la columna debe ser visible para esta fila
|
|
46
|
+
*/
|
|
47
|
+
isColumnVisibleForRow<T extends Record<string, unknown>>(column: C80TableColDef, row: T, data: T[], editing: ID | null): boolean;
|
|
48
|
+
/**
|
|
49
|
+
* Verifica si todos los valores de una columna están vacíos/nulos
|
|
50
|
+
* @param column - La definición de la columna
|
|
51
|
+
* @param data - Datos actuales de la tabla
|
|
52
|
+
* @returns true si todos los valores están vacíos
|
|
53
|
+
*/
|
|
54
|
+
areAllColumnValuesEmpty<T extends Record<string, unknown>>(column: C80TableColDef, data: T[]): boolean;
|
|
55
|
+
/**
|
|
56
|
+
* Obtiene el valor de una celda usando el accessor, soportando notación de punto para propiedades anidadas
|
|
57
|
+
* @param row - La fila de datos
|
|
58
|
+
* @param accessor - El accessor de la columna
|
|
59
|
+
* @returns El valor de la celda
|
|
60
|
+
*/
|
|
61
|
+
private getCellValue;
|
|
62
|
+
/**
|
|
63
|
+
* Obtiene el valor de un objeto usando notación de punto (ej: 'task.name')
|
|
64
|
+
* @param obj - Objeto del cual obtener el valor
|
|
65
|
+
* @param accessor - Ruta de acceso usando notación de punto
|
|
66
|
+
* @returns El valor anidado o undefined
|
|
67
|
+
*/
|
|
68
|
+
private getNestedValue;
|
|
69
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<TableColumnVisibilityService, never>;
|
|
70
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<TableColumnVisibilityService>;
|
|
71
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { EventEmitter } from '@angular/core';
|
|
2
|
+
import { C80TableColDef, ID } from './table.types';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
/**
|
|
5
|
+
* Servicio para gestionar el estado CRUD (Crear, Leer, Actualizar, Eliminar) en tablas C80
|
|
6
|
+
*
|
|
7
|
+
* Maneja:
|
|
8
|
+
* - Estado de creación y edición
|
|
9
|
+
* - Gestión de datos temporales (newRow, editRow)
|
|
10
|
+
* - Aplicación de valores dinámicos
|
|
11
|
+
* - Validación y conversión de datos antes de emisión de eventos
|
|
12
|
+
*/
|
|
13
|
+
export declare class TableCrudStateService {
|
|
14
|
+
private readonly visibilityService;
|
|
15
|
+
private readonly dataConverter;
|
|
16
|
+
/**
|
|
17
|
+
* Inicializa el estado CRUD para una nueva tabla
|
|
18
|
+
* @returns Objeto con signals y métodos para gestión CRUD
|
|
19
|
+
*/
|
|
20
|
+
createCrudState<T extends Record<string, unknown>>(): {
|
|
21
|
+
creating: import("@angular/core").Signal<boolean>;
|
|
22
|
+
newRow: import("@angular/core").Signal<Partial<T> | null>;
|
|
23
|
+
editing: import("@angular/core").Signal<ID | null>;
|
|
24
|
+
editRow: import("@angular/core").Signal<Partial<T> | null>;
|
|
25
|
+
startCreate: (columns: C80TableColDef[], data: T[]) => void;
|
|
26
|
+
cancelCreate: () => void;
|
|
27
|
+
updateNewRow: (key: string, value: unknown) => void;
|
|
28
|
+
saveCreate: (columns: C80TableColDef[], data: T[], createEmitter: EventEmitter<{
|
|
29
|
+
row: Partial<T>;
|
|
30
|
+
done: (result: boolean) => void;
|
|
31
|
+
}>) => void;
|
|
32
|
+
startEdit: (row: T, columns: C80TableColDef[], data: T[]) => void;
|
|
33
|
+
cancelEdit: () => void;
|
|
34
|
+
updateEditRow: (key: string, value: unknown) => void;
|
|
35
|
+
saveEdit: (rowId: ID, columns: C80TableColDef[], data: T[], updateEmitter: EventEmitter<{
|
|
36
|
+
id: ID;
|
|
37
|
+
changes: Partial<T>;
|
|
38
|
+
done: (result: boolean) => void;
|
|
39
|
+
}>) => void;
|
|
40
|
+
applyInputValues: (partialValues: Partial<T>) => void;
|
|
41
|
+
};
|
|
42
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<TableCrudStateService, never>;
|
|
43
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<TableCrudStateService>;
|
|
44
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { C80TableColDef } from './table.types';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
/**
|
|
4
|
+
* Servicio para conversión y validación de tipos de datos en tablas C80
|
|
5
|
+
*
|
|
6
|
+
* Maneja la conversión entre diferentes tipos de datos y la validación de valores vacíos.
|
|
7
|
+
* Soporta los tipos: string, number, integer, boolean, password, enum
|
|
8
|
+
*/
|
|
9
|
+
export declare class TableDataConverterService {
|
|
10
|
+
/**
|
|
11
|
+
* Convierte un valor de celda basándose en el tipo de columna o datos de muestra
|
|
12
|
+
* @param value - Valor a convertir
|
|
13
|
+
* @param col - Definición de la columna
|
|
14
|
+
* @param sampleValue - Valor de muestra para inferir el tipo (opcional)
|
|
15
|
+
* @returns Valor convertido al tipo apropiado
|
|
16
|
+
*/
|
|
17
|
+
convertCellValue(value: unknown, col: C80TableColDef, sampleValue?: unknown): unknown;
|
|
18
|
+
/**
|
|
19
|
+
* Convierte un valor a boolean usando mejores prácticas
|
|
20
|
+
* @param value - Valor a convertir
|
|
21
|
+
* @returns Valor booleano
|
|
22
|
+
*/
|
|
23
|
+
toBoolean(value: unknown): boolean;
|
|
24
|
+
/**
|
|
25
|
+
* Convierte un valor a number usando mejores prácticas
|
|
26
|
+
* @param value - Valor a convertir
|
|
27
|
+
* @returns Número o undefined si no es válido
|
|
28
|
+
*/
|
|
29
|
+
toNumber(value: unknown): number | undefined;
|
|
30
|
+
/**
|
|
31
|
+
* Convierte un valor a integer usando mejores prácticas
|
|
32
|
+
* @param value - Valor a convertir
|
|
33
|
+
* @returns Entero o undefined si no es válido
|
|
34
|
+
*/
|
|
35
|
+
toInteger(value: unknown): number | undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Convierte un valor a string usando mejores prácticas, siempre stringifica objetos
|
|
38
|
+
* @param value - Valor a convertir
|
|
39
|
+
* @returns Cadena de texto
|
|
40
|
+
*/
|
|
41
|
+
toStringValue(value: unknown): string;
|
|
42
|
+
/**
|
|
43
|
+
* Verifica si un valor individual está vacío/nulo
|
|
44
|
+
* @param value - Valor a verificar
|
|
45
|
+
* @returns true si el valor se considera vacío
|
|
46
|
+
*/
|
|
47
|
+
isValueEmpty(value: unknown): boolean;
|
|
48
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<TableDataConverterService, never>;
|
|
49
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<TableDataConverterService>;
|
|
50
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { C80TableColDef } from './table.types';
|
|
2
|
+
import * as i0 from "@angular/core";
|
|
3
|
+
/**
|
|
4
|
+
* Servicio para utilidades de manipulación de datos en tablas C80
|
|
5
|
+
*
|
|
6
|
+
* Proporciona métodos para:
|
|
7
|
+
* - Acceso a valores de celdas (incluyendo propiedades anidadas)
|
|
8
|
+
* - Formateo de valores para display
|
|
9
|
+
* - Gestión de enums y colores
|
|
10
|
+
* - Ordenamiento de datos
|
|
11
|
+
*/
|
|
12
|
+
export declare class TableDataUtilsService {
|
|
13
|
+
/**
|
|
14
|
+
* Obtiene el valor de una celda usando el accessor, soportando notación de punto para propiedades anidadas
|
|
15
|
+
* @param row - La fila de datos
|
|
16
|
+
* @param accessor - El accessor de la columna
|
|
17
|
+
* @returns El valor de la celda
|
|
18
|
+
*/
|
|
19
|
+
getCellValue<T extends Record<string, unknown>>(row: T, accessor: string): unknown;
|
|
20
|
+
/**
|
|
21
|
+
* Obtiene el valor de un objeto usando notación de punto (ej: 'task.name')
|
|
22
|
+
* @param obj - Objeto del cual obtener el valor
|
|
23
|
+
* @param accessor - Ruta de acceso usando notación de punto
|
|
24
|
+
* @returns El valor anidado o undefined
|
|
25
|
+
*/
|
|
26
|
+
getNestedValue(obj: any, accessor: string): unknown;
|
|
27
|
+
/**
|
|
28
|
+
* Devuelve el valor de display para una celda, mostrando '-' para valores falsy excepto 0, false y objetos/arrays vacíos
|
|
29
|
+
* @param value - Valor a formatear
|
|
30
|
+
* @returns Cadena formateada para display
|
|
31
|
+
*/
|
|
32
|
+
getDisplayValue(value: unknown): string;
|
|
33
|
+
/**
|
|
34
|
+
* Obtiene el texto de display para un valor enum
|
|
35
|
+
* @param value - Valor del enum
|
|
36
|
+
* @param col - Definición de la columna
|
|
37
|
+
* @returns Texto formateado del enum
|
|
38
|
+
*/
|
|
39
|
+
getEnumDisplayValue(value: unknown, col: C80TableColDef): string;
|
|
40
|
+
/**
|
|
41
|
+
* Obtiene las opciones del enum como array para dropdowns select
|
|
42
|
+
* @param col - Definición de la columna
|
|
43
|
+
* @returns Array de opciones con value y label
|
|
44
|
+
*/
|
|
45
|
+
getEnumOptions(col: C80TableColDef): {
|
|
46
|
+
value: string | number;
|
|
47
|
+
label: string;
|
|
48
|
+
}[];
|
|
49
|
+
/**
|
|
50
|
+
* Obtiene el color CSS para un valor de celda basado en la configuración de color de la columna
|
|
51
|
+
* @param value - Valor de la celda
|
|
52
|
+
* @param col - Definición de la columna
|
|
53
|
+
* @returns Color CSS o undefined si no hay configuración
|
|
54
|
+
*/
|
|
55
|
+
getCellColor(value: unknown, col: C80TableColDef): string | undefined;
|
|
56
|
+
/**
|
|
57
|
+
* Aplica ordenamiento a los items basándose en las columnas con configuración de orden
|
|
58
|
+
* @param items - Array de items a ordenar (se modifica in-place)
|
|
59
|
+
* @param columns - Definiciones de columnas
|
|
60
|
+
*/
|
|
61
|
+
applySorting<T extends Record<string, unknown>>(items: T[], columns: C80TableColDef[]): void;
|
|
62
|
+
/**
|
|
63
|
+
* Calcula el max-height de la tabla basado en el tamaño
|
|
64
|
+
* @param size - Tamaño configurado (0 = sin límite)
|
|
65
|
+
* @returns String CSS para max-height o undefined si sin límite
|
|
66
|
+
*/
|
|
67
|
+
getTableMaxHeight(size: number): string | undefined;
|
|
68
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<TableDataUtilsService, never>;
|
|
69
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<TableDataUtilsService>;
|
|
70
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { EventEmitter } from '@angular/core';
|
|
2
|
+
import { ID } from './table.types';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
/**
|
|
5
|
+
* Servicio para gestionar la selección de elementos en tablas C80
|
|
6
|
+
*
|
|
7
|
+
* Maneja:
|
|
8
|
+
* - Selección simple y múltiple
|
|
9
|
+
* - Estado de selección completa
|
|
10
|
+
* - Preservación de selección tras actualizaciones de datos
|
|
11
|
+
* - Emisión de eventos de selección
|
|
12
|
+
*/
|
|
13
|
+
export declare class TableSelectionService {
|
|
14
|
+
/**
|
|
15
|
+
* Inicializa el estado de selección para una nueva tabla
|
|
16
|
+
* @returns Objeto con signals y métodos de selección
|
|
17
|
+
*/
|
|
18
|
+
createSelectionState<T extends Record<string, unknown>>(): {
|
|
19
|
+
selectedItems: import("@angular/core").Signal<Set<ID>>;
|
|
20
|
+
selectAllChecked: import("@angular/core").Signal<boolean>;
|
|
21
|
+
selectAllIndeterminate: import("@angular/core").Signal<boolean>;
|
|
22
|
+
clearSelection: () => void;
|
|
23
|
+
toggleSelectAll: (allItems: T[]) => void;
|
|
24
|
+
toggleItemSelection: (item: T, multiple: boolean) => void;
|
|
25
|
+
isItemSelected: (item: T) => boolean;
|
|
26
|
+
preserveSelection: (newData: T[]) => void;
|
|
27
|
+
getSelectedItems: (allData: T[]) => T[];
|
|
28
|
+
updateSelectAllState: (allItems?: T[]) => void;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Emite los elementos seleccionados a través del EventEmitter proporcionado
|
|
32
|
+
* @param selectionState - Estado de selección
|
|
33
|
+
* @param allData - Todos los datos de la tabla
|
|
34
|
+
* @param selectableEmitter - EventEmitter para emitir la selección
|
|
35
|
+
*/
|
|
36
|
+
emitSelection<T extends Record<string, unknown>>(selectionState: ReturnType<typeof this.createSelectionState<T>>, allData: T[], selectableEmitter: EventEmitter<T[]>): void;
|
|
37
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<TableSelectionService, never>;
|
|
38
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<TableSelectionService>;
|
|
39
|
+
}
|
|
@@ -1,19 +1,7 @@
|
|
|
1
1
|
import { EventEmitter, OnInit, OnDestroy } from '@angular/core';
|
|
2
2
|
import { Observable } from 'rxjs';
|
|
3
|
+
import { C80TableColDef, ID } from './table.types';
|
|
3
4
|
import * as i0 from "@angular/core";
|
|
4
|
-
export interface C80TableColDef {
|
|
5
|
-
accessor: string;
|
|
6
|
-
label: string;
|
|
7
|
-
visible?: boolean;
|
|
8
|
-
type?: 'string' | 'number' | 'integer' | 'boolean' | 'password' | 'enum';
|
|
9
|
-
order?: 'ASC' | 'DESC';
|
|
10
|
-
readOnly?: boolean;
|
|
11
|
-
enum?: Record<string | number, string>;
|
|
12
|
-
color?: Record<string | number, string>;
|
|
13
|
-
hideIfAllValuesAreNull?: boolean;
|
|
14
|
-
default?: unknown;
|
|
15
|
-
}
|
|
16
|
-
export type ID = number | string;
|
|
17
5
|
/**
|
|
18
6
|
* C80TableComponent - Componente de tabla avanzado con funcionalidades CRUD
|
|
19
7
|
*
|
|
@@ -71,6 +59,10 @@ export type ID = number | string;
|
|
|
71
59
|
* - inputValues$ emite { motorPos: 5, weight: 2.3 } → actualiza inputs dinámicamente
|
|
72
60
|
*/ export declare class C80TableComponent<T extends Record<string, unknown>> implements OnInit, OnDestroy {
|
|
73
61
|
private readonly modalService;
|
|
62
|
+
private readonly visibilityService;
|
|
63
|
+
private readonly dataUtils;
|
|
64
|
+
private readonly selectionService;
|
|
65
|
+
private readonly crudService;
|
|
74
66
|
data$: Observable<T[]>;
|
|
75
67
|
columns: C80TableColDef[];
|
|
76
68
|
inputValues$?: Observable<Partial<T>>;
|
|
@@ -115,14 +107,16 @@ export type ID = number | string;
|
|
|
115
107
|
selectable: EventEmitter<T[]>;
|
|
116
108
|
readonly data: import("@angular/core").WritableSignal<T[]>;
|
|
117
109
|
readonly keys: import("@angular/core").WritableSignal<string[]>;
|
|
118
|
-
creating: import("@angular/core").WritableSignal<boolean>;
|
|
119
|
-
newRow: import("@angular/core").WritableSignal<Partial<T> | null>;
|
|
120
|
-
readonly editing: import("@angular/core").WritableSignal<ID | null>;
|
|
121
|
-
readonly editRow: import("@angular/core").WritableSignal<Partial<T> | null>;
|
|
122
|
-
readonly selectedItems: import("@angular/core").WritableSignal<Set<ID>>;
|
|
123
|
-
readonly selectAllChecked: import("@angular/core").WritableSignal<boolean>;
|
|
124
|
-
readonly selectAllIndeterminate: import("@angular/core").WritableSignal<boolean>;
|
|
125
110
|
readonly searchValue: import("@angular/core").WritableSignal<string>;
|
|
111
|
+
private readonly selectionState;
|
|
112
|
+
readonly selectedItems: import("@angular/core").Signal<Set<ID>>;
|
|
113
|
+
readonly selectAllChecked: import("@angular/core").Signal<boolean>;
|
|
114
|
+
readonly selectAllIndeterminate: import("@angular/core").Signal<boolean>;
|
|
115
|
+
private readonly crudState;
|
|
116
|
+
readonly creating: import("@angular/core").Signal<boolean>;
|
|
117
|
+
readonly newRow: import("@angular/core").Signal<Partial<T> | null>;
|
|
118
|
+
readonly editing: import("@angular/core").Signal<ID | null>;
|
|
119
|
+
readonly editRow: import("@angular/core").Signal<Partial<T> | null>;
|
|
126
120
|
readonly hasCreateActionListener: import("@angular/core").WritableSignal<boolean>;
|
|
127
121
|
readonly hasUpdateActionListener: import("@angular/core").WritableSignal<boolean>;
|
|
128
122
|
readonly hasDeleteActionListener: import("@angular/core").WritableSignal<boolean>;
|
|
@@ -156,23 +150,6 @@ export type ID = number | string;
|
|
|
156
150
|
cancelCreate(): void;
|
|
157
151
|
updateNewRow(key: string, value: unknown): void;
|
|
158
152
|
saveCreate(): void;
|
|
159
|
-
/**
|
|
160
|
-
* Converts a cell value based on column type or sample data.
|
|
161
|
-
* Handles stringification of objects for string columns.
|
|
162
|
-
*/
|
|
163
|
-
/**
|
|
164
|
-
* Converts a cell value based on column type or sample data.
|
|
165
|
-
* Delegates to type-specific helpers for clarity and maintainability.
|
|
166
|
-
*/
|
|
167
|
-
private convertCellValue;
|
|
168
|
-
/** Converts value to boolean using best practices. */
|
|
169
|
-
private toBoolean;
|
|
170
|
-
/** Converts value to number using best practices. */
|
|
171
|
-
private toNumber;
|
|
172
|
-
/** Converts value to integer using best practices. */
|
|
173
|
-
private toInteger;
|
|
174
|
-
/** Converts value to string using best practices, always stringifies objects. */
|
|
175
|
-
private toStringValue;
|
|
176
153
|
onEdit(row: T): void;
|
|
177
154
|
cancelEdit(): void;
|
|
178
155
|
onEditInput(event: Event, key: string, col?: C80TableColDef): void;
|
|
@@ -209,37 +186,14 @@ export type ID = number | string;
|
|
|
209
186
|
* Clears the search input
|
|
210
187
|
*/
|
|
211
188
|
clearSearch(): void;
|
|
212
|
-
/**
|
|
213
|
-
* Gets the value from an object using dot notation (e.g., 'task.name')
|
|
214
|
-
*/
|
|
215
|
-
private getNestedValue;
|
|
216
|
-
/**
|
|
217
|
-
* Gets the value for a cell using the accessor, supporting dot notation for nested properties
|
|
218
|
-
*/
|
|
219
189
|
getCellValue(row: T, accessor: string): unknown;
|
|
220
|
-
/**
|
|
221
|
-
* Returns the display value for a cell, showing '-' for falsy values except 0, false, and empty objects/arrays
|
|
222
|
-
*/
|
|
223
190
|
getDisplayValue(value: unknown): string;
|
|
224
|
-
/**
|
|
225
|
-
* Gets the display text for an enum value
|
|
226
|
-
*/
|
|
227
191
|
getEnumDisplayValue(value: unknown, col: C80TableColDef): string;
|
|
228
|
-
/**
|
|
229
|
-
* Gets the enum options as an array for select dropdowns
|
|
230
|
-
*/
|
|
231
192
|
getEnumOptions(col: C80TableColDef): {
|
|
232
193
|
value: string | number;
|
|
233
194
|
label: string;
|
|
234
195
|
}[];
|
|
235
|
-
/**
|
|
236
|
-
* Gets the CSS color for a cell value based on the column's color configuration
|
|
237
|
-
*/
|
|
238
196
|
getCellColor(value: unknown, col: C80TableColDef): string | undefined;
|
|
239
|
-
/**
|
|
240
|
-
* Calcula el max-height de la tabla basado en el tamaño
|
|
241
|
-
* Si size es 0, retorna undefined (sin límite de altura)
|
|
242
|
-
*/
|
|
243
197
|
getTableMaxHeight(): string | undefined;
|
|
244
198
|
/**
|
|
245
199
|
* Selection methods
|
|
@@ -253,48 +207,9 @@ export type ID = number | string;
|
|
|
253
207
|
toggleSelectAll(): void;
|
|
254
208
|
toggleItemSelection(item: T): void;
|
|
255
209
|
isItemSelected(item: T): boolean;
|
|
256
|
-
private updateSelectAllState;
|
|
257
|
-
private emitSelection;
|
|
258
|
-
/**
|
|
259
|
-
* Verifica si un valor individual está vacío/nulo
|
|
260
|
-
*/
|
|
261
|
-
private isValueEmpty;
|
|
262
|
-
/**
|
|
263
|
-
* Verifica si todos los valores de una columna están vacíos/nulos
|
|
264
|
-
*/
|
|
265
|
-
private areAllColumnValuesEmpty;
|
|
266
|
-
/**
|
|
267
|
-
* Determina si una columna debe ser visible basándose en su configuración y datos.
|
|
268
|
-
*
|
|
269
|
-
* Orden de prioridad:
|
|
270
|
-
* 1. Si visible === false: SIEMPRE se oculta (máxima prioridad)
|
|
271
|
-
* 2. Si hideIfAllValuesAreNull === true Y todos los valores están vacíos: se oculta
|
|
272
|
-
* EXCEPCIÓN: En modo creación (creating === true), estas columnas se muestran para permitir entrada de datos
|
|
273
|
-
* 3. Por defecto: se muestra
|
|
274
|
-
*
|
|
275
|
-
* @param column - La definición de la columna
|
|
276
|
-
* @param forceShowInCreation - Si es true, ignora hideIfAllValuesAreNull (usado en modo creación)
|
|
277
|
-
*/
|
|
278
210
|
isColumnVisible(column: C80TableColDef, forceShowInCreation?: boolean): boolean;
|
|
279
|
-
/**
|
|
280
|
-
* Determina si una columna debe ser visible en los headers.
|
|
281
|
-
* Los headers se muestran si la columna es visible en cualquiera de estos casos:
|
|
282
|
-
* - Visualización normal
|
|
283
|
-
* - Modo creación
|
|
284
|
-
* - Hay una fila en modo edición y esa fila tiene valor en la columna
|
|
285
|
-
*
|
|
286
|
-
* @param column - La definición de la columna
|
|
287
|
-
*/
|
|
288
211
|
isColumnVisibleInHeader(column: C80TableColDef): boolean;
|
|
289
|
-
/**
|
|
290
|
-
* Determina si una columna debe ser visible en una fila específica considerando el modo edición.
|
|
291
|
-
* En modo edición, las columnas con hideIfAllValuesAreNull se muestran solo si tienen valor.
|
|
292
|
-
*
|
|
293
|
-
* @param column - La definición de la columna
|
|
294
|
-
* @param row - La fila actual
|
|
295
|
-
*/
|
|
296
212
|
isColumnVisibleForRow(column: C80TableColDef, row: T): boolean;
|
|
297
|
-
private applySorting;
|
|
298
213
|
onUpload(row: T): void;
|
|
299
214
|
static ɵfac: i0.ɵɵFactoryDeclaration<C80TableComponent<any>, never>;
|
|
300
215
|
static ɵcmp: i0.ɵɵComponentDeclaration<C80TableComponent<any>, "c80-table", never, { "data$": { "alias": "data$"; "required": false; }; "columns": { "alias": "columns"; "required": false; }; "inputValues$": { "alias": "inputValues$"; "required": false; }; "size": { "alias": "size"; "required": false; }; "multiple": { "alias": "multiple"; "required": false; }; "noConfirm": { "alias": "noConfirm"; "required": false; }; }, { "createAction": "createAction"; "updateAction": "updateAction"; "deleteAction": "deleteAction"; "cancelAction": "cancelAction"; "viewAction": "viewAction"; "uploadAction": "uploadAction"; "getRowButtonAction": "getRowButtonAction"; "moveUpAction": "moveUpAction"; "moveDownAction": "moveDownAction"; "enableAction": "enableAction"; "searchTerm": "searchTerm"; "errorEvent": "errorEvent"; "selectable": "selectable"; }, never, never, true, never>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Tipos comunes para las tablas C80
|
|
3
|
+
*/
|
|
4
|
+
export type ID = number | string;
|
|
5
|
+
export interface C80TableColDef {
|
|
6
|
+
accessor: string;
|
|
7
|
+
label: string;
|
|
8
|
+
visible?: boolean;
|
|
9
|
+
type?: 'string' | 'number' | 'integer' | 'boolean' | 'password' | 'enum';
|
|
10
|
+
order?: 'ASC' | 'DESC';
|
|
11
|
+
readOnly?: boolean;
|
|
12
|
+
enum?: Record<string | number, string>;
|
|
13
|
+
color?: Record<string | number, string>;
|
|
14
|
+
hideIfAllValuesAreNull?: boolean;
|
|
15
|
+
default?: unknown;
|
|
16
|
+
}
|