@c80/ui 1.0.44 → 1.0.45

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 (78) hide show
  1. package/c80-ui.d.ts +5 -0
  2. package/esm2022/c80-ui.js +5 -0
  3. package/esm2022/c80-ui.js.map +1 -0
  4. package/esm2022/index.js +6 -0
  5. package/esm2022/index.js.map +1 -0
  6. package/esm2022/lib/card-level/card-level.component.js +56 -0
  7. package/esm2022/lib/card-level/card-level.component.js.map +1 -0
  8. package/esm2022/lib/card-level/card-level.interface.js +2 -0
  9. package/esm2022/lib/card-level/card-level.interface.js.map +1 -0
  10. package/esm2022/lib/card-level/index.js +3 -0
  11. package/esm2022/lib/card-level/index.js.map +1 -0
  12. package/esm2022/lib/icon/icon.component.js +48 -0
  13. package/esm2022/lib/icon/icon.component.js.map +1 -0
  14. package/esm2022/lib/icon/icon.constants.js +237 -0
  15. package/esm2022/lib/icon/icon.constants.js.map +1 -0
  16. package/esm2022/lib/icon/icon.types.js +2 -0
  17. package/esm2022/lib/icon/icon.types.js.map +1 -0
  18. package/esm2022/lib/icon/icon.utils.js +4 -0
  19. package/esm2022/lib/icon/icon.utils.js.map +1 -0
  20. package/esm2022/lib/icon/index.js +4 -0
  21. package/esm2022/lib/icon/index.js.map +1 -0
  22. package/esm2022/lib/modal/index.js +3 -0
  23. package/esm2022/lib/modal/index.js.map +1 -0
  24. package/esm2022/lib/modal/modal.component.js +86 -0
  25. package/esm2022/lib/modal/modal.component.js.map +1 -0
  26. package/esm2022/lib/modal/modal.service.js +83 -0
  27. package/esm2022/lib/modal/modal.service.js.map +1 -0
  28. package/esm2022/lib/stat-card/index.js +2 -0
  29. package/esm2022/lib/stat-card/index.js.map +1 -0
  30. package/esm2022/lib/stat-card/stat-card.component.js +13 -0
  31. package/esm2022/lib/stat-card/stat-card.component.js.map +1 -0
  32. package/esm2022/lib/table/index.js +9 -0
  33. package/esm2022/lib/table/index.js.map +1 -0
  34. package/esm2022/lib/table/table-column-visibility.service.js +105 -0
  35. package/esm2022/lib/table/table-column-visibility.service.js.map +1 -0
  36. package/esm2022/lib/table/table-crud-state.service.js +115 -0
  37. package/esm2022/lib/table/table-crud-state.service.js.map +1 -0
  38. package/esm2022/lib/table/table-data-converter.service.js +145 -0
  39. package/esm2022/lib/table/table-data-converter.service.js.map +1 -0
  40. package/esm2022/lib/table/table-data-utils.service.js +193 -0
  41. package/esm2022/lib/table/table-data-utils.service.js.map +1 -0
  42. package/esm2022/lib/table/table-selection.service.js +121 -0
  43. package/esm2022/lib/table/table-selection.service.js.map +1 -0
  44. package/esm2022/lib/table/table.component.js +413 -0
  45. package/esm2022/lib/table/table.component.js.map +1 -0
  46. package/esm2022/lib/table/table.types.js +5 -0
  47. package/esm2022/lib/table/table.types.js.map +1 -0
  48. package/esm2022/lib/table/table.utils.js +107 -0
  49. package/esm2022/lib/table/table.utils.js.map +1 -0
  50. package/lib/icon/icon.component.d.ts +2 -2
  51. package/lib/modal/index.d.ts +2 -3
  52. package/lib/stat-card/stat-card.component.d.ts +2 -2
  53. package/lib/table/table.component.d.ts +10 -13
  54. package/package.json +7 -9
  55. package/esm2022/c80-ui.mjs +0 -5
  56. package/esm2022/index.mjs +0 -6
  57. package/esm2022/lib/card-level/card-level.component.mjs +0 -57
  58. package/esm2022/lib/card-level/card-level.interface.mjs +0 -2
  59. package/esm2022/lib/card-level/index.mjs +0 -3
  60. package/esm2022/lib/icon/icon.component.mjs +0 -49
  61. package/esm2022/lib/icon/icon.constants.mjs +0 -237
  62. package/esm2022/lib/icon/icon.types.mjs +0 -2
  63. package/esm2022/lib/icon/icon.utils.mjs +0 -4
  64. package/esm2022/lib/icon/index.mjs +0 -4
  65. package/esm2022/lib/modal/index.mjs +0 -3
  66. package/esm2022/lib/modal/modal.component.mjs +0 -86
  67. package/esm2022/lib/modal/modal.service.mjs +0 -83
  68. package/esm2022/lib/stat-card/index.mjs +0 -2
  69. package/esm2022/lib/stat-card/stat-card.component.mjs +0 -16
  70. package/esm2022/lib/table/index.mjs +0 -9
  71. package/esm2022/lib/table/table-column-visibility.service.mjs +0 -105
  72. package/esm2022/lib/table/table-crud-state.service.mjs +0 -115
  73. package/esm2022/lib/table/table-data-converter.service.mjs +0 -145
  74. package/esm2022/lib/table/table-data-utils.service.mjs +0 -193
  75. package/esm2022/lib/table/table-selection.service.mjs +0 -121
  76. package/esm2022/lib/table/table.component.mjs +0 -432
  77. package/esm2022/lib/table/table.types.mjs +0 -5
  78. package/esm2022/lib/table/table.utils.mjs +0 -107
@@ -0,0 +1,413 @@
1
+ import { Component, input, signal, computed, output, inject, } from '@angular/core';
2
+ import { C80IconComponent } from '../icon';
3
+ import { TableColumnVisibilityService } from './table-column-visibility.service';
4
+ import { TableDataUtilsService } from './table-data-utils.service';
5
+ import { TableDataConverterService } from './table-data-converter.service';
6
+ import { TableSelectionService } from './table-selection.service';
7
+ import { TableCrudStateService } from './table-crud-state.service';
8
+ import { C80ModalComponent, ModalService } from '../modal';
9
+ import { booleanAttribute, getErrorMessage, getInputValue, trackById, shouldShowAction, getActionTooltip, } from './table.utils';
10
+ import * as i0 from "@angular/core";
11
+ /**
12
+ * C80TableComponent - Componente de tabla avanzado con funcionalidades CRUD
13
+ *
14
+ * COMPORTAMIENTO DE VISIBILIDAD DE COLUMNAS:
15
+ * ========================================
16
+ *
17
+ * 1. PRIORIDAD MÁXIMA - visible: false
18
+ * - La columna se oculta SIEMPRE, sin excepciones
19
+ * - Ni en modo creación ni en modo edición se muestra
20
+ *
21
+ * 2. OCULTACIÓN AUTOMÁTICA - hideIfAllValuesAreNull: true
22
+ * - La columna se oculta solo si TODOS los valores actuales están vacíos
23
+ * - Valores considerados vacíos: null, undefined, '', [], {}
24
+ * - Valores NO vacíos: 0, false (son valores válidos)
25
+ * - EXCEPCIONES IMPORTANTES:
26
+ * * En modo creación (creating=true) estas columnas SÍ se muestran
27
+ * * En modo edición de una fila específica se muestran SOLO si esa fila tiene valor
28
+ *
29
+ * 3. POR DEFECTO - Columnas normales
30
+ * - Se muestran siempre (visualización, creación y edición)
31
+ *
32
+ * VALORES POR DEFECTO EN CREACIÓN:
33
+ * ===============================
34
+ *
35
+ * - Propiedad `default?: unknown` permite definir valores por defecto para modo creación
36
+ * - Solo se aplica cuando se inicia el modo creación (startCreate)
37
+ * - Puede ser cualquier tipo: string, number, boolean, etc.
38
+ * - Si no se especifica `default`, se usa cadena vacía ('')
39
+ *
40
+ * VALORES DINÁMICOS EN CREACIÓN Y EDICIÓN:
41
+ * =======================================
42
+ *
43
+ * - Input `inputValues$?: Observable<Partial<T>>` permite actualizar valores dinámicamente
44
+ * - Solo se aplica durante modo creación (creating=true) o edición (editing!=null)
45
+ * - Los valores se aplican automáticamente cuando el Observable emite
46
+ * - Permite cambios múltiples durante el mismo modo de creación/edición
47
+ * - Los nuevos valores sobrescriben los existentes (spread operator)
48
+ *
49
+ * TIPOS DE DATOS SOPORTADOS:
50
+ * =========================
51
+ *
52
+ * - 'string': Texto normal (default)
53
+ * - 'number': Números decimales (preserva decimales: 5.3 → 5.3)
54
+ * - 'integer': Números enteros (convierte a entero: 5.3 → 5)
55
+ * - 'boolean': Verdadero/Falso (checkbox)
56
+ * - 'password': Texto oculto (input type="password")
57
+ * - 'enum': Lista de opciones predefinidas (select)
58
+ *
59
+ * SISTEMA DE ACCIONES UNIFICADO (customActions):
60
+ * =============================================
61
+ *
62
+ * Input: `customActions: CustomTableAction[]` - Array de acciones dinámicas
63
+ * Output: `(actionClick)` - Evento unificado que emite { action: string, row: T }
64
+ *
65
+ * ACCIONES CRUD PREDEFINIDAS (TABLE_CRUD_ACTIONS):
66
+ * ------------------------------------------------
67
+ * - CREATE: Solo aparece como botón "+" en header (no en filas)
68
+ * - UPDATE: Activa modo edición (muestra inputs), botón "✓" guarda cambios
69
+ * - DELETE: Muestra confirmación y emite evento delete
70
+ * - CANCEL: Muestra confirmación y emite evento cancel (opcional)
71
+ *
72
+ * ACCIONES PERSONALIZADAS (Custom Actions):
73
+ * -----------------------------------------
74
+ * Interfaz: { name: string, icon: IconType, condition?: (row) => boolean, tooltip?: string }
75
+ * - name: ID único de la acción
76
+ * - icon: Icono del botón (ej: 'settings', 'upload', 'refresh')
77
+ * - condition: Función opcional para mostrar/ocultar según estado de fila
78
+ * - tooltip: Texto al hacer hover (default: name)
79
+ *
80
+ * MANEJO EN COMPONENTE:
81
+ * --------------------
82
+ * ```typescript
83
+ * // 1. Definir acciones en constants:
84
+ * export const ENTITY_TABLE_ACTIONS: CustomTableAction[] = [
85
+ * TABLE_CRUD_ACTIONS.CREATE,
86
+ * TABLE_CRUD_ACTIONS.UPDATE,
87
+ * { name: 'custom-action', icon: 'settings', tooltip: 'Configurar' },
88
+ * TABLE_CRUD_ACTIONS.DELETE
89
+ * ];
90
+ *
91
+ * // 2. En el componente:
92
+ * readonly tableActions = ENTITY_TABLE_ACTIONS;
93
+ *
94
+ * handleAction({ action, row }) {
95
+ * const entity = row as unknown as EntityType;
96
+ * switch (action) {
97
+ * case 'create': this.onCreate(row); break;
98
+ * case 'update': this.onUpdate(entity); break;
99
+ * case 'delete': this.onDelete(entity.id); break;
100
+ * case 'custom-action': this.onCustom(entity); break;
101
+ * }
102
+ * }
103
+ * ```
104
+ *
105
+ * ACCIONES CON CONDICIÓN:
106
+ * ----------------------
107
+ * ```typescript
108
+ * {
109
+ * name: 'enable',
110
+ * icon: 'toggleOn',
111
+ * tooltip: 'Habilitar',
112
+ * condition: (row) => row['enabled'] === false
113
+ * }
114
+ * ```
115
+ *
116
+ * CONSTANTES REUTILIZABLES:
117
+ * ------------------------
118
+ * - TABLE_CRUD_ACTIONS: Objeto con CREATE, UPDATE, DELETE, CANCEL
119
+ * - BASIC_CRUD_ACTIONS: Array con [CREATE, UPDATE, DELETE]
120
+ * Importar desde: `@shared` o `@shared/constants`
121
+ *
122
+ * EJEMPLOS COMPLETOS:
123
+ * ------------------
124
+ * - { accessor: 'id', visible: false } → NUNCA se muestra
125
+ * - { accessor: 'motorPos', hideIfAllValuesAreNull: true, default: 0, type: 'integer' } → Entero (5.7 → 5)
126
+ * - { accessor: 'weight', type: 'number', default: 2.5 } → Decimal preservado (5.7 → 5.7)
127
+ * - { accessor: 'status', default: 'active' } → Se autorellena con 'active' en creación
128
+ * - { accessor: 'name' } → Siempre visible, sin valor por defecto (cadena vacía)
129
+ * - inputValues$ emite { motorPos: 5, weight: 2.3 } → actualiza inputs dinámicamente
130
+ * - customActions con CREATE → Muestra botón "+" en header
131
+ * - customActions con UPDATE → Botón "edit" activa modo edición
132
+ * - customActions con custom → Botón personalizado emite evento
133
+ */ export class C80TableComponent {
134
+ // Servicios inyectados
135
+ modalService = inject(ModalService);
136
+ visibilityService = inject(TableColumnVisibilityService);
137
+ dataUtils = inject(TableDataUtilsService);
138
+ dataConverter = inject(TableDataConverterService);
139
+ selectionService = inject(TableSelectionService);
140
+ crudService = inject(TableCrudStateService);
141
+ // Inputs
142
+ data$ = input.required(...(ngDevMode ? [{ debugName: "data$" }] : []));
143
+ columns = input([], ...(ngDevMode ? [{ debugName: "columns" }] : []));
144
+ inputValues$ = input(...(ngDevMode ? [undefined, { debugName: "inputValues$" }] : [])); // Observable para actualizar valores de inputs dinámicamente en creación/edición
145
+ customActions = input([], ...(ngDevMode ? [{ debugName: "customActions" }] : [])); // Acciones personalizadas dinámicas
146
+ size = input(0, ...(ngDevMode ? [{ debugName: "size" }] : [])); // Tamaño de la tabla (0 = sin límite, > 0 aplica max-height)
147
+ multiple = input(true, ...(ngDevMode ? [{ debugName: "multiple" }] : [])); // Permite selección múltiple por defecto
148
+ searchable = input(false, ...(ngDevMode ? [{ debugName: "searchable", transform: booleanAttribute }] : [{ transform: booleanAttribute }])); // Si es true, muestra barra de búsqueda
149
+ allowSelection = input(false, ...(ngDevMode ? [{ debugName: "allowSelection", transform: booleanAttribute }] : [{ transform: booleanAttribute }])); // Si es true, permite selección de filas
150
+ noConfirm = input(false, ...(ngDevMode ? [{ debugName: "noConfirm", transform: booleanAttribute }] : [{ transform: booleanAttribute }])); // Si es true, no muestra confirmaciones modales
151
+ // Outputs - Acciones unificadas (Angular 18+ output API)
152
+ actionClick = output(); // Output unificado para TODAS las acciones (CRUD + custom)
153
+ // Outputs - Utilidades
154
+ searchTerm = output();
155
+ errorEvent = output();
156
+ selectable = output();
157
+ // Estado principal
158
+ data = signal([], ...(ngDevMode ? [{ debugName: "data" }] : []));
159
+ searchValue = signal('', ...(ngDevMode ? [{ debugName: "searchValue" }] : []));
160
+ // Estado de selección (delegado a servicio)
161
+ selectionState = this.selectionService.createSelectionState();
162
+ selectedItems = this.selectionState.selectedItems;
163
+ selectAllChecked = this.selectionState.selectAllChecked;
164
+ selectAllIndeterminate = this.selectionState.selectAllIndeterminate;
165
+ // Estado CRUD (delegado a servicio)
166
+ crudState = this.crudService.createCrudState();
167
+ creating = this.crudState.creating;
168
+ newRow = this.crudState.newRow;
169
+ editing = this.crudState.editing;
170
+ editRow = this.crudState.editRow;
171
+ // Keys visibles computed automáticamente
172
+ keys = computed(() => this.visibilityService.updateVisibleKeys(this.columns(), this.data(), this.creating(), this.editing()), ...(ngDevMode ? [{ debugName: "keys" }] : []));
173
+ // Computed - Detecta acciones CRUD y custom
174
+ hasAnyActions = computed(() => this.customActions().length > 0, ...(ngDevMode ? [{ debugName: "hasAnyActions" }] : []));
175
+ hasCrudCreate = computed(() => this.customActions().some(a => a.name === 'create'), ...(ngDevMode ? [{ debugName: "hasCrudCreate" }] : []));
176
+ hasCrudUpdate = computed(() => this.customActions().some(a => a.name === 'update'), ...(ngDevMode ? [{ debugName: "hasCrudUpdate" }] : []));
177
+ hasCrudDelete = computed(() => this.customActions().some(a => a.name === 'delete'), ...(ngDevMode ? [{ debugName: "hasCrudDelete" }] : []));
178
+ hasCrudCancel = computed(() => this.customActions().some(a => a.name === 'cancel'), ...(ngDevMode ? [{ debugName: "hasCrudCancel" }] : []));
179
+ // Table max height computed
180
+ tableMaxHeight = computed(() => this.dataUtils.getTableMaxHeight(this.size()), ...(ngDevMode ? [{ debugName: "tableMaxHeight" }] : []));
181
+ dataSub;
182
+ inputValuesSub;
183
+ /**
184
+ * Maneja input de creación/edición de forma unificada
185
+ */
186
+ handleInput(event, key, col, isEdit) {
187
+ const updateFn = isEdit
188
+ ? this.crudState.updateEditRow.bind(this.crudState)
189
+ : this.crudState.updateNewRow.bind(this.crudState);
190
+ const value = getInputValue(event, col);
191
+ if (value !== undefined) {
192
+ updateFn(key, value);
193
+ }
194
+ }
195
+ /**
196
+ * Maneja confirmación modal de forma genérica
197
+ */
198
+ async handleConfirmAction(title, message, confirmText, action) {
199
+ if (this.noConfirm()) {
200
+ action();
201
+ return;
202
+ }
203
+ const confirmed = await this.modalService.confirm(title, message, confirmText, 'Cancelar');
204
+ if (confirmed) {
205
+ action();
206
+ }
207
+ }
208
+ ngOnInit() {
209
+ const data$ = this.data$();
210
+ if (!data$)
211
+ return;
212
+ this.dataSub = data$.subscribe({
213
+ next: (items) => {
214
+ this.dataUtils.applySorting(items, this.columns());
215
+ this.data.set(items);
216
+ this.preserveSelection();
217
+ },
218
+ error: (err) => this.errorEvent.emit(getErrorMessage(err)),
219
+ });
220
+ // Suscribirse a inputValues$ para actualizar valores dinámicamente en creación/edición
221
+ const inputValues$ = this.inputValues$();
222
+ if (inputValues$) {
223
+ this.inputValuesSub = inputValues$.subscribe({
224
+ next: (partialValues) => {
225
+ this.crudState.applyInputValues(partialValues);
226
+ },
227
+ error: (err) => console.warn('Error en inputValues$:', getErrorMessage(err)),
228
+ });
229
+ }
230
+ }
231
+ ngOnDestroy() {
232
+ this.dataSub?.unsubscribe();
233
+ this.inputValuesSub?.unsubscribe();
234
+ // Close any open modal when component is destroyed
235
+ this.modalService.closeModal();
236
+ }
237
+ onInput(event, key, col) {
238
+ this.handleInput(event, key, col, false);
239
+ }
240
+ onEditInput(event, key, col) {
241
+ this.handleInput(event, key, col, true);
242
+ }
243
+ async onDelete(row) {
244
+ await this.handleConfirmAction('Confirmar eliminación', '¿Está seguro de que desea eliminar este elemento? Esta acción no se puede deshacer.', 'Eliminar', () => this.actionClick.emit({ action: 'delete', row }));
245
+ }
246
+ async onCancel(row) {
247
+ await this.handleConfirmAction('Confirmar cancelación', '¿Está seguro de que desea cancelar este elemento?', 'Cancelar elemento', () => this.actionClick.emit({ action: 'cancel', row }));
248
+ }
249
+ startCreate() {
250
+ this.crudState.startCreate(this.columns(), this.data());
251
+ }
252
+ cancelCreate() {
253
+ this.crudState.cancelCreate();
254
+ }
255
+ saveCreate() {
256
+ const current = this.newRow();
257
+ if (current) {
258
+ const convertedRow = this.convertRowTypes(current);
259
+ this.actionClick.emit({ action: 'create', row: convertedRow });
260
+ this.cancelCreate();
261
+ }
262
+ }
263
+ onEdit(row) {
264
+ this.crudState.startEdit(row, this.columns(), this.data());
265
+ }
266
+ cancelEdit() {
267
+ this.crudState.cancelEdit();
268
+ }
269
+ saveEdit(row) {
270
+ const changes = this.editRow();
271
+ if (changes) {
272
+ const convertedChanges = this.convertRowTypes(changes);
273
+ const updatedRow = { ...row, ...convertedChanges };
274
+ this.actionClick.emit({ action: 'update', row: updatedRow });
275
+ this.cancelEdit();
276
+ }
277
+ }
278
+ /**
279
+ * Convierte todos los valores de una fila según los tipos definidos en las columnas
280
+ * Asegura que los datos emitidos tengan el tipo correcto (integer, number, boolean, etc.)
281
+ */
282
+ convertRowTypes(row) {
283
+ const converted = {};
284
+ const columnsMap = new Map(this.columns().map(col => [col.accessor, col]));
285
+ for (const [key, value] of Object.entries(row)) {
286
+ const col = columnsMap.get(key);
287
+ if (col) {
288
+ converted[key] = this.dataConverter.convertCellValue(value, col);
289
+ }
290
+ else {
291
+ converted[key] = value;
292
+ }
293
+ }
294
+ return converted;
295
+ }
296
+ /**
297
+ * TrackBy function for ngFor to avoid DOM re-creation (NG0956 warning).
298
+ */
299
+ trackById = (trackById);
300
+ /**
301
+ * Verifica si una acción personalizada debe mostrarse para una fila específica
302
+ */
303
+ shouldShowAction = (shouldShowAction);
304
+ /**
305
+ * Obtiene el tooltip de una acción
306
+ */
307
+ getActionTooltip = getActionTooltip;
308
+ /**
309
+ * Maneja el click en una acción personalizada dinámica
310
+ * UPDATE activa el modo edición, otras acciones emiten directamente
311
+ * Si la acción tiene configuración de confirmación, muestra modal antes de ejecutar
312
+ */
313
+ onDynamicAction(action, row) {
314
+ if (action.name === 'update') {
315
+ this.onEdit(row);
316
+ return;
317
+ }
318
+ if (action.name === 'delete') {
319
+ void this.onDelete(row);
320
+ return;
321
+ }
322
+ if (action.name === 'cancel') {
323
+ void this.onCancel(row);
324
+ return;
325
+ }
326
+ // Si la acción tiene confirmación configurada, mostrar modal
327
+ if (action.confirmation) {
328
+ void this.handleActionWithConfirmation(action, row);
329
+ return;
330
+ }
331
+ // Sin confirmación, emitir directamente
332
+ this.actionClick.emit({ action: action.name, row });
333
+ }
334
+ /**
335
+ * Maneja acciones que requieren confirmación del usuario
336
+ */
337
+ async handleActionWithConfirmation(action, row) {
338
+ if (!action.confirmation)
339
+ return;
340
+ const confirmed = await this.modalService.confirm(action.confirmation.title, action.confirmation.message, action.confirmation.confirmText || 'Confirmar', action.confirmation.cancelText || 'Cancelar');
341
+ if (confirmed) {
342
+ this.actionClick.emit({ action: action.name, row });
343
+ }
344
+ }
345
+ /**
346
+ * Handles search input changes with debouncing
347
+ */
348
+ onSearchInput(event) {
349
+ const target = event.target;
350
+ const value = target.value;
351
+ this.searchValue.set(value);
352
+ this.searchTerm.emit(value);
353
+ }
354
+ /**
355
+ * Clears the search input
356
+ */
357
+ clearSearch() {
358
+ this.searchValue.set('');
359
+ this.searchTerm.emit('');
360
+ }
361
+ // Referencias readonly a métodos de servicios (evita wrappers innecesarios)
362
+ getCellValue = this.dataUtils.getCellValue.bind(this.dataUtils);
363
+ getDisplayValue = this.dataUtils.getDisplayValue.bind(this.dataUtils);
364
+ getEnumDisplayValue = this.dataUtils.getEnumDisplayValue.bind(this.dataUtils);
365
+ getEnumOptions = this.dataUtils.getEnumOptions.bind(this.dataUtils);
366
+ getCellColor = this.dataUtils.getCellColor.bind(this.dataUtils);
367
+ /**
368
+ * Selection methods
369
+ */
370
+ clearSelection() {
371
+ this.selectionState.clearSelection();
372
+ this.selectionService.emitSelection(this.selectionState, this.data(), this.selectable);
373
+ }
374
+ /**
375
+ * Mantiene la selección existente después de actualizar los datos,
376
+ * eliminando solo los IDs que ya no existen en los nuevos datos
377
+ */
378
+ preserveSelection() {
379
+ this.selectionState.preserveSelection(this.data());
380
+ this.selectionService.emitSelection(this.selectionState, this.data(), this.selectable);
381
+ }
382
+ toggleSelectAll() {
383
+ this.selectionState.toggleSelectAll(this.data());
384
+ this.selectionService.emitSelection(this.selectionState, this.data(), this.selectable);
385
+ }
386
+ toggleItemSelection(item) {
387
+ this.selectionState.toggleItemSelection(item, this.multiple());
388
+ this.selectionService.emitSelection(this.selectionState, this.data(), this.selectable);
389
+ }
390
+ isItemSelected(item) {
391
+ return this.selectionState.isItemSelected(item);
392
+ }
393
+ // Métodos de visibilidad delegados a servicio
394
+ isColumnVisible(column) {
395
+ return this.visibilityService.isColumnVisible(column, this.data(), {
396
+ creating: this.creating(),
397
+ row: this.newRow() ?? undefined
398
+ });
399
+ }
400
+ isColumnVisibleInHeader(column) {
401
+ return this.visibilityService.isColumnVisibleInHeader(column, this.data(), this.creating(), this.editing());
402
+ }
403
+ isColumnVisibleForRow(column, row) {
404
+ return this.visibilityService.isColumnVisibleForRow(column, row, this.data(), this.editing());
405
+ }
406
+ static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: C80TableComponent, deps: [], target: i0.ɵɵFactoryTarget.Component });
407
+ static ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "17.0.0", version: "20.3.9", type: C80TableComponent, isStandalone: true, selector: "c80-table", inputs: { data$: { classPropertyName: "data$", publicName: "data$", isSignal: true, isRequired: true, transformFunction: null }, columns: { classPropertyName: "columns", publicName: "columns", isSignal: true, isRequired: false, transformFunction: null }, inputValues$: { classPropertyName: "inputValues$", publicName: "inputValues$", isSignal: true, isRequired: false, transformFunction: null }, customActions: { classPropertyName: "customActions", publicName: "customActions", isSignal: true, isRequired: false, transformFunction: null }, size: { classPropertyName: "size", publicName: "size", isSignal: true, isRequired: false, transformFunction: null }, multiple: { classPropertyName: "multiple", publicName: "multiple", isSignal: true, isRequired: false, transformFunction: null }, searchable: { classPropertyName: "searchable", publicName: "searchable", isSignal: true, isRequired: false, transformFunction: null }, allowSelection: { classPropertyName: "allowSelection", publicName: "allowSelection", isSignal: true, isRequired: false, transformFunction: null }, noConfirm: { classPropertyName: "noConfirm", publicName: "noConfirm", isSignal: true, isRequired: false, transformFunction: null } }, outputs: { actionClick: "actionClick", searchTerm: "searchTerm", errorEvent: "errorEvent", selectable: "selectable" }, ngImport: i0, template: "<div class=\"table-responsive\" [style.max-height]=\"tableMaxHeight()\" [style.overflow-y]=\"size() > 0 ? 'auto' : 'visible'\">\n <!-- Search Bar -->\n @if (searchable()) {\n <div class=\"search-container\">\n <div class=\"search-input-wrapper\">\n <div class=\"input-group\">\n <span class=\"input-group-text\">\n <c80-icon icon=\"search\" [size]=\".8\"></c80-icon>\n </span>\n <input type=\"text\" class=\"form-control search-input\" placeholder=\"Buscar...\" [value]=\"searchValue()\" (input)=\"onSearchInput($event)\" aria-label=\"Buscar en la tabla\" />\n @if (searchValue()) {\n <button class=\"btn btn-outline-secondary btn-borrar\" type=\"button\" (click)=\"clearSearch()\" title=\"Limpiar b\u00FAsqueda\">\n <c80-icon icon=\"cancel\" [size]=\".7\"></c80-icon>\n </button>\n }\n </div>\n </div>\n </div>\n }\n\n <table class=\"table table-bordered table-hover align-middle\">\n <thead class=\"thead table-light sticky-header\">\n <tr>\n @if (allowSelection() && data().length !== 0) {\n <th class=\"text-center selection-column\">\n @if (multiple()) {\n <input type=\"checkbox\" [checked]=\"selectAllChecked()\" [indeterminate]=\"selectAllIndeterminate()\" (change)=\"toggleSelectAll()\" aria-label=\"Seleccionar todo\" />\n }\n </th>\n }\n @for (col of columns(); track col) {\n @if (isColumnVisibleInHeader(col)) {\n @if (col.type === 'boolean') {\n <th class=\"text-center boolean-column\">{{ col.label }}</th>\n }\n @else if (col.type === 'number' || col.type === 'integer') {\n <th class=\"text-center number-column\">{{ col.label }}</th>\n }\n @else {\n <th>{{ col.label }}</th>\n }\n }\n }\n @if (hasAnyActions()) {\n <th class=\"table-actions-header\">\n <div class=\"actions-wrapper\">\n <span>Actions</span>\n @if (hasCrudCreate()) {\n <c80-icon button icon=\"add\" [disabled]=\"creating()\" title=\"Agregar\" [size]=\".6\" (iconClick)=\"startCreate()\"></c80-icon>\n }\n </div>\n </th>\n }\n </tr>\n </thead>\n <tbody>\n @for (row of data(); track trackById(i, row); let i = $index) {\n <tr>\n @if (allowSelection() && data().length !== 0) {\n <td class=\"text-center selection-column\">\n <input type=\"checkbox\" [checked]=\"isItemSelected(row)\" (change)=\"toggleItemSelection(row)\" [attr.aria-label]=\"'Seleccionar fila ' + (i + 1)\" />\n </td>\n }\n @for (col of columns(); track col) {\n @if (isColumnVisibleForRow(col, row)) {\n @if (col.type === 'boolean') {\n <td class=\"text-center boolean-column\">\n @if (editing() === row['id'] && !col.readOnly) {\n <input type=\"checkbox\" [checked]=\"!!editRow()?.[col.accessor]\" (change)=\"onEditInput($event, col.accessor, col)\" [attr.aria-label]=\"col.label\" />\n }\n @else {\n @if (getCellValue(row, col.accessor) === true) {\n <c80-icon icon=\"check\" [size]=\".7\"></c80-icon>\n <br />\n }\n @else if (getCellValue(row, col.accessor) === false) {\n <c80-icon icon=\"cancel\" [size]=\".7\"></c80-icon>\n <br />\n }\n }\n </td>\n }\n @else if (col.type === 'number' || col.type === 'integer') {\n <td class=\"text-center number-column\">\n @if (editing() === row['id'] && !col.readOnly) {\n <input class=\"form-control form-control-sm\" type=\"number\" [value]=\"editRow()?.[col.accessor] ?? ''\" [placeholder]=\"col.label\" [min]=\"col.min\" [max]=\"col.max\" [step]=\"col.type === 'integer' ? '1' : 'any'\"\n (input)=\"onEditInput($event, col.accessor, col)\" />\n }\n @else {\n <span [style.color]=\"getCellColor(getCellValue(row, col.accessor), col)\">{{ getDisplayValue(getCellValue(row,\n col.accessor), col) }}</span>\n }\n </td>\n }\n @else {\n <td>\n @if (editing() === row['id'] && !col.readOnly) {\n @if (col.type === 'enum') {\n <select class=\"form-control form-control-sm\" [value]=\"editRow()?.[col.accessor] ?? ''\" (change)=\"onEditInput($event, col.accessor, col)\">\n <option value=\"\">{{ col.label }}</option>\n @for (option of getEnumOptions(col); track option.value) {\n <option [value]=\"option.value\">{{ option.label }}</option>\n }\n </select>\n }\n @else {\n <input class=\"form-control form-control-sm\" [type]=\"col.type === 'password' ? 'password' : 'text'\" [value]=\"editRow()?.[col.accessor] ?? ''\" [placeholder]=\"col.label\" (input)=\"onEditInput($event, col.accessor, col)\" />\n }\n }\n @else {\n @if (col.type === 'password') {\n <span [style.color]=\"getCellColor(getCellValue(row, col.accessor), col)\">******</span>\n }\n @else if (col.type === 'enum') {\n <span [style.color]=\"getCellColor(getCellValue(row, col.accessor), col)\">{{\n getEnumDisplayValue(getCellValue(row, col.accessor), col)\n }}</span>\n }\n @else if (getCellValue(row, col.accessor) === true) {\n <c80-icon icon=\"check\" [size]=\".7\"></c80-icon>\n }\n @else if (getCellValue(row, col.accessor) === false) {\n <c80-icon icon=\"cancel\" [size]=\".7\"></c80-icon>\n }\n @else {\n <span [style.color]=\"getCellColor(getCellValue(row, col.accessor), col)\">{{ getDisplayValue(getCellValue(row,\n col.accessor), col) }}</span>\n }\n }\n </td>\n }\n }\n }\n @if (hasAnyActions()) {\n <td class=\"text-center actions-cell\">\n <div class=\"actions-container\">\n @if (editing() === row['id']) {\n <!-- Modo edici\u00F3n: mostrar guardar y cancelar -->\n @if (hasCrudUpdate()) {\n <c80-icon button icon=\"check\" title=\"Guardar\" (iconClick)=\"saveEdit(row)\" [size]=\".7\"></c80-icon>\n }\n <c80-icon button icon=\"cancel\" color=\"warn\" title=\"Cancelar\" (iconClick)=\"cancelEdit()\" [size]=\".7\"></c80-icon>\n }\n @else {\n @for (action of customActions(); track action.name) {\n @if (shouldShowAction(action, row)) {\n <c80-icon button [icon]=\"action.icon\" [customColor]=\"action.color\" [color]=\"action.name === 'delete' ? 'warn' : 'primary'\" [title]=\"getActionTooltip(action)\" (iconClick)=\"onDynamicAction(action, row)\" [size]=\".7\"></c80-icon>\n }\n }\n }\n </div>\n </td>\n }\n </tr>\n }\n @if (creating() && hasCrudCreate()) {\n <tr>\n @if (allowSelection() && data().length !== 0) {\n <td class=\"text-center selection-column\">\n <!-- Empty cell for alignment -->\n </td>\n }\n @for (col of columns(); track col) {\n @if (isColumnVisible(col)) {\n @if (col.type === 'boolean') {\n <td class=\"text-center\">\n @if (!col.readOnly) {\n <input type=\"checkbox\" [checked]=\"!!newRow()?.[col.accessor]\" (change)=\"onInput($event, col.accessor, col)\" [attr.aria-label]=\"col.label\" />\n }\n @else {\n <!-- ReadOnly boolean column in create mode shows empty -->\n <span class=\"text-muted\">-</span>\n }\n </td>\n } @else if (col.type === 'number' || col.type === 'integer') {\n <td class=\"text-center number-column\">\n @if (!col.readOnly) {\n <input class=\"form-control form-control-sm\" type=\"number\" [value]=\"newRow()?.[col.accessor] ?? ''\" [placeholder]=\"col.label\" [min]=\"col.min\" [max]=\"col.max\" [step]=\"col.type === 'integer' ? '1' : 'any'\"\n (input)=\"onInput($event, col.accessor, col)\" />\n }\n @else {\n <!-- ReadOnly number column in create mode shows empty -->\n <span class=\"text-muted\">-</span>\n }\n </td>\n } @else {\n <td>\n @if (!col.readOnly) {\n @if (col.type === 'enum') {\n <select class=\"form-control form-control-sm\" [value]=\"newRow()?.[col.accessor] ?? ''\" (change)=\"onInput($event, col.accessor, col)\">\n <option value=\"\">{{ col.label }}</option>\n @for (option of getEnumOptions(col); track option.value) {\n <option [value]=\"option.value\">{{ option.label }}</option>\n }\n </select>\n }\n @else {\n <input class=\"form-control form-control-sm\" type=\"text\" [value]=\"newRow()?.[col.accessor] ?? ''\" [placeholder]=\"col.label\" (input)=\"onInput($event, col.accessor, col)\" />\n }\n }\n @else {\n <!-- ReadOnly column in create mode shows empty -->\n <span class=\"text-muted\">-</span>\n }\n </td>\n }\n }\n }\n <td class=\"text-center actions-cell\">\n <div class=\"actions-container\">\n @if (hasCrudCreate()) {\n <c80-icon button icon=\"check\" title=\"Guardar\" (iconClick)=\"saveCreate()\" [size]=\".7\"></c80-icon>\n }\n <c80-icon button icon=\"cancel\" color=\"warn\" title=\"Cancelar\" (iconClick)=\"cancelCreate()\" [size]=\".7\"></c80-icon>\n </div>\n </td>\n </tr>\n }\n </tbody>\n </table>\n @if (data().length === 0 && !creating()) {\n <div class=\"text-center text-muted py-3 small\">\n No hay datos para mostrar.\n </div>\n }\n</div>\n\n<c80-modal></c80-modal>", styles: ["@charset \"UTF-8\";input[type=checkbox]{width:1.3rem!important;height:1.3rem!important;accent-color:rgba(226,0,0,.7647058824);background:#fff;margin:0 .25rem;vertical-align:middle;cursor:pointer}.table-responsive{width:100%;overflow-x:auto}.table-responsive .search-container{margin-bottom:-.06rem}.table-responsive .search-container .search-input-wrapper .input-group .btn-borrar{border-bottom-right-radius:0;border-color:#dee2e6}.table-responsive .search-container .search-input-wrapper .input-group .input-group-text{background-color:#f8f9fa;border-color:#dee2e6;border-bottom-left-radius:0;color:#495057;width:56px}.table-responsive .search-container .search-input-wrapper .input-group .input-group-text c80-icon{display:flex;align-items:center;justify-content:center;padding-bottom:.2rem}.table-responsive .search-container .search-input-wrapper .input-group .search-input{border-color:#dee2e6;border-bottom-right-radius:0;font-size:.95rem;outline:none!important}.table-responsive .search-container .search-input-wrapper .input-group .search-input:focus{outline:none!important}.table-responsive .search-container .search-input-wrapper .input-group .search-input::placeholder{color:#999;font-style:italic}.table-responsive .table{min-width:0px;margin-bottom:.5rem}.table-responsive .table .sticky-header{position:sticky;top:0;z-index:10;background-color:#f8f9fa!important}.table-responsive .table .sticky-header .table-actions-header{display:table-cell;vertical-align:middle;padding:.2rem .6rem!important;background-color:#f8f9fa!important}.table-responsive .table .sticky-header .actions-wrapper{display:flex;align-items:center;justify-content:center;gap:.5rem;height:100%}.table-responsive .table .sticky-header th{max-height:31px!important;vertical-align:middle!important;padding:.2rem .6rem!important;font-size:small!important;background-color:#f8f9fa!important;border-bottom:2px solid #dee2e6}.table-responsive .table tbody td{height:35px!important;min-height:35px!important;max-height:35px!important;vertical-align:middle!important;padding:.2rem .8rem!important;font-size:small}.table-responsive .table tbody tr{height:35px!important;min-height:35px!important;max-height:35px!important;cursor:pointer}.table-responsive .table tbody tr:hover{background-color:#f5f5f5}.table-responsive .table tbody input{border:1px solid rgba(34,0,255,.37);height:100%!important;font-size:smaller!important}.table-responsive .table tbody input[type=text],.table-responsive .table tbody input:not([type]){width:100%!important}.table-responsive .table tbody input[type=number]{min-width:80px!important;width:80px!important;text-align:center}.table-responsive .table thead th.boolean-column,.table-responsive .table tbody td.boolean-column,.table-responsive .table thead th.selection-column,.table-responsive .table tbody td.selection-column,.table-responsive .table thead th.table-actions-header,.table-responsive .table tbody td.table-actions-header{width:1%;white-space:nowrap}.table-responsive .table thead th.number-column,.table-responsive .table tbody td.number-column{width:1%;white-space:nowrap;text-align:center}.table-responsive .table thead th.number-column input[type=number],.table-responsive .table tbody td.number-column input[type=number]{min-width:80px!important;width:80px!important;text-align:center}.table-responsive .table .actions-cell{white-space:nowrap;padding:0!important}.table-responsive .table .actions-container{display:flex;flex-direction:row;justify-content:center;align-items:center;width:100%;height:100%}\n"], dependencies: [{ kind: "component", type: C80IconComponent, selector: "c80-icon", inputs: ["icon", "color", "customColor", "disabled", "size", "button", "border", "type", "textLeft", "textRight"], outputs: ["iconClick"] }, { kind: "component", type: C80ModalComponent, selector: "c80-modal" }] });
408
+ }
409
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: C80TableComponent, decorators: [{
410
+ type: Component,
411
+ args: [{ selector: 'c80-table', standalone: true, imports: [C80IconComponent, C80ModalComponent], template: "<div class=\"table-responsive\" [style.max-height]=\"tableMaxHeight()\" [style.overflow-y]=\"size() > 0 ? 'auto' : 'visible'\">\n <!-- Search Bar -->\n @if (searchable()) {\n <div class=\"search-container\">\n <div class=\"search-input-wrapper\">\n <div class=\"input-group\">\n <span class=\"input-group-text\">\n <c80-icon icon=\"search\" [size]=\".8\"></c80-icon>\n </span>\n <input type=\"text\" class=\"form-control search-input\" placeholder=\"Buscar...\" [value]=\"searchValue()\" (input)=\"onSearchInput($event)\" aria-label=\"Buscar en la tabla\" />\n @if (searchValue()) {\n <button class=\"btn btn-outline-secondary btn-borrar\" type=\"button\" (click)=\"clearSearch()\" title=\"Limpiar b\u00FAsqueda\">\n <c80-icon icon=\"cancel\" [size]=\".7\"></c80-icon>\n </button>\n }\n </div>\n </div>\n </div>\n }\n\n <table class=\"table table-bordered table-hover align-middle\">\n <thead class=\"thead table-light sticky-header\">\n <tr>\n @if (allowSelection() && data().length !== 0) {\n <th class=\"text-center selection-column\">\n @if (multiple()) {\n <input type=\"checkbox\" [checked]=\"selectAllChecked()\" [indeterminate]=\"selectAllIndeterminate()\" (change)=\"toggleSelectAll()\" aria-label=\"Seleccionar todo\" />\n }\n </th>\n }\n @for (col of columns(); track col) {\n @if (isColumnVisibleInHeader(col)) {\n @if (col.type === 'boolean') {\n <th class=\"text-center boolean-column\">{{ col.label }}</th>\n }\n @else if (col.type === 'number' || col.type === 'integer') {\n <th class=\"text-center number-column\">{{ col.label }}</th>\n }\n @else {\n <th>{{ col.label }}</th>\n }\n }\n }\n @if (hasAnyActions()) {\n <th class=\"table-actions-header\">\n <div class=\"actions-wrapper\">\n <span>Actions</span>\n @if (hasCrudCreate()) {\n <c80-icon button icon=\"add\" [disabled]=\"creating()\" title=\"Agregar\" [size]=\".6\" (iconClick)=\"startCreate()\"></c80-icon>\n }\n </div>\n </th>\n }\n </tr>\n </thead>\n <tbody>\n @for (row of data(); track trackById(i, row); let i = $index) {\n <tr>\n @if (allowSelection() && data().length !== 0) {\n <td class=\"text-center selection-column\">\n <input type=\"checkbox\" [checked]=\"isItemSelected(row)\" (change)=\"toggleItemSelection(row)\" [attr.aria-label]=\"'Seleccionar fila ' + (i + 1)\" />\n </td>\n }\n @for (col of columns(); track col) {\n @if (isColumnVisibleForRow(col, row)) {\n @if (col.type === 'boolean') {\n <td class=\"text-center boolean-column\">\n @if (editing() === row['id'] && !col.readOnly) {\n <input type=\"checkbox\" [checked]=\"!!editRow()?.[col.accessor]\" (change)=\"onEditInput($event, col.accessor, col)\" [attr.aria-label]=\"col.label\" />\n }\n @else {\n @if (getCellValue(row, col.accessor) === true) {\n <c80-icon icon=\"check\" [size]=\".7\"></c80-icon>\n <br />\n }\n @else if (getCellValue(row, col.accessor) === false) {\n <c80-icon icon=\"cancel\" [size]=\".7\"></c80-icon>\n <br />\n }\n }\n </td>\n }\n @else if (col.type === 'number' || col.type === 'integer') {\n <td class=\"text-center number-column\">\n @if (editing() === row['id'] && !col.readOnly) {\n <input class=\"form-control form-control-sm\" type=\"number\" [value]=\"editRow()?.[col.accessor] ?? ''\" [placeholder]=\"col.label\" [min]=\"col.min\" [max]=\"col.max\" [step]=\"col.type === 'integer' ? '1' : 'any'\"\n (input)=\"onEditInput($event, col.accessor, col)\" />\n }\n @else {\n <span [style.color]=\"getCellColor(getCellValue(row, col.accessor), col)\">{{ getDisplayValue(getCellValue(row,\n col.accessor), col) }}</span>\n }\n </td>\n }\n @else {\n <td>\n @if (editing() === row['id'] && !col.readOnly) {\n @if (col.type === 'enum') {\n <select class=\"form-control form-control-sm\" [value]=\"editRow()?.[col.accessor] ?? ''\" (change)=\"onEditInput($event, col.accessor, col)\">\n <option value=\"\">{{ col.label }}</option>\n @for (option of getEnumOptions(col); track option.value) {\n <option [value]=\"option.value\">{{ option.label }}</option>\n }\n </select>\n }\n @else {\n <input class=\"form-control form-control-sm\" [type]=\"col.type === 'password' ? 'password' : 'text'\" [value]=\"editRow()?.[col.accessor] ?? ''\" [placeholder]=\"col.label\" (input)=\"onEditInput($event, col.accessor, col)\" />\n }\n }\n @else {\n @if (col.type === 'password') {\n <span [style.color]=\"getCellColor(getCellValue(row, col.accessor), col)\">******</span>\n }\n @else if (col.type === 'enum') {\n <span [style.color]=\"getCellColor(getCellValue(row, col.accessor), col)\">{{\n getEnumDisplayValue(getCellValue(row, col.accessor), col)\n }}</span>\n }\n @else if (getCellValue(row, col.accessor) === true) {\n <c80-icon icon=\"check\" [size]=\".7\"></c80-icon>\n }\n @else if (getCellValue(row, col.accessor) === false) {\n <c80-icon icon=\"cancel\" [size]=\".7\"></c80-icon>\n }\n @else {\n <span [style.color]=\"getCellColor(getCellValue(row, col.accessor), col)\">{{ getDisplayValue(getCellValue(row,\n col.accessor), col) }}</span>\n }\n }\n </td>\n }\n }\n }\n @if (hasAnyActions()) {\n <td class=\"text-center actions-cell\">\n <div class=\"actions-container\">\n @if (editing() === row['id']) {\n <!-- Modo edici\u00F3n: mostrar guardar y cancelar -->\n @if (hasCrudUpdate()) {\n <c80-icon button icon=\"check\" title=\"Guardar\" (iconClick)=\"saveEdit(row)\" [size]=\".7\"></c80-icon>\n }\n <c80-icon button icon=\"cancel\" color=\"warn\" title=\"Cancelar\" (iconClick)=\"cancelEdit()\" [size]=\".7\"></c80-icon>\n }\n @else {\n @for (action of customActions(); track action.name) {\n @if (shouldShowAction(action, row)) {\n <c80-icon button [icon]=\"action.icon\" [customColor]=\"action.color\" [color]=\"action.name === 'delete' ? 'warn' : 'primary'\" [title]=\"getActionTooltip(action)\" (iconClick)=\"onDynamicAction(action, row)\" [size]=\".7\"></c80-icon>\n }\n }\n }\n </div>\n </td>\n }\n </tr>\n }\n @if (creating() && hasCrudCreate()) {\n <tr>\n @if (allowSelection() && data().length !== 0) {\n <td class=\"text-center selection-column\">\n <!-- Empty cell for alignment -->\n </td>\n }\n @for (col of columns(); track col) {\n @if (isColumnVisible(col)) {\n @if (col.type === 'boolean') {\n <td class=\"text-center\">\n @if (!col.readOnly) {\n <input type=\"checkbox\" [checked]=\"!!newRow()?.[col.accessor]\" (change)=\"onInput($event, col.accessor, col)\" [attr.aria-label]=\"col.label\" />\n }\n @else {\n <!-- ReadOnly boolean column in create mode shows empty -->\n <span class=\"text-muted\">-</span>\n }\n </td>\n } @else if (col.type === 'number' || col.type === 'integer') {\n <td class=\"text-center number-column\">\n @if (!col.readOnly) {\n <input class=\"form-control form-control-sm\" type=\"number\" [value]=\"newRow()?.[col.accessor] ?? ''\" [placeholder]=\"col.label\" [min]=\"col.min\" [max]=\"col.max\" [step]=\"col.type === 'integer' ? '1' : 'any'\"\n (input)=\"onInput($event, col.accessor, col)\" />\n }\n @else {\n <!-- ReadOnly number column in create mode shows empty -->\n <span class=\"text-muted\">-</span>\n }\n </td>\n } @else {\n <td>\n @if (!col.readOnly) {\n @if (col.type === 'enum') {\n <select class=\"form-control form-control-sm\" [value]=\"newRow()?.[col.accessor] ?? ''\" (change)=\"onInput($event, col.accessor, col)\">\n <option value=\"\">{{ col.label }}</option>\n @for (option of getEnumOptions(col); track option.value) {\n <option [value]=\"option.value\">{{ option.label }}</option>\n }\n </select>\n }\n @else {\n <input class=\"form-control form-control-sm\" type=\"text\" [value]=\"newRow()?.[col.accessor] ?? ''\" [placeholder]=\"col.label\" (input)=\"onInput($event, col.accessor, col)\" />\n }\n }\n @else {\n <!-- ReadOnly column in create mode shows empty -->\n <span class=\"text-muted\">-</span>\n }\n </td>\n }\n }\n }\n <td class=\"text-center actions-cell\">\n <div class=\"actions-container\">\n @if (hasCrudCreate()) {\n <c80-icon button icon=\"check\" title=\"Guardar\" (iconClick)=\"saveCreate()\" [size]=\".7\"></c80-icon>\n }\n <c80-icon button icon=\"cancel\" color=\"warn\" title=\"Cancelar\" (iconClick)=\"cancelCreate()\" [size]=\".7\"></c80-icon>\n </div>\n </td>\n </tr>\n }\n </tbody>\n </table>\n @if (data().length === 0 && !creating()) {\n <div class=\"text-center text-muted py-3 small\">\n No hay datos para mostrar.\n </div>\n }\n</div>\n\n<c80-modal></c80-modal>", styles: ["@charset \"UTF-8\";input[type=checkbox]{width:1.3rem!important;height:1.3rem!important;accent-color:rgba(226,0,0,.7647058824);background:#fff;margin:0 .25rem;vertical-align:middle;cursor:pointer}.table-responsive{width:100%;overflow-x:auto}.table-responsive .search-container{margin-bottom:-.06rem}.table-responsive .search-container .search-input-wrapper .input-group .btn-borrar{border-bottom-right-radius:0;border-color:#dee2e6}.table-responsive .search-container .search-input-wrapper .input-group .input-group-text{background-color:#f8f9fa;border-color:#dee2e6;border-bottom-left-radius:0;color:#495057;width:56px}.table-responsive .search-container .search-input-wrapper .input-group .input-group-text c80-icon{display:flex;align-items:center;justify-content:center;padding-bottom:.2rem}.table-responsive .search-container .search-input-wrapper .input-group .search-input{border-color:#dee2e6;border-bottom-right-radius:0;font-size:.95rem;outline:none!important}.table-responsive .search-container .search-input-wrapper .input-group .search-input:focus{outline:none!important}.table-responsive .search-container .search-input-wrapper .input-group .search-input::placeholder{color:#999;font-style:italic}.table-responsive .table{min-width:0px;margin-bottom:.5rem}.table-responsive .table .sticky-header{position:sticky;top:0;z-index:10;background-color:#f8f9fa!important}.table-responsive .table .sticky-header .table-actions-header{display:table-cell;vertical-align:middle;padding:.2rem .6rem!important;background-color:#f8f9fa!important}.table-responsive .table .sticky-header .actions-wrapper{display:flex;align-items:center;justify-content:center;gap:.5rem;height:100%}.table-responsive .table .sticky-header th{max-height:31px!important;vertical-align:middle!important;padding:.2rem .6rem!important;font-size:small!important;background-color:#f8f9fa!important;border-bottom:2px solid #dee2e6}.table-responsive .table tbody td{height:35px!important;min-height:35px!important;max-height:35px!important;vertical-align:middle!important;padding:.2rem .8rem!important;font-size:small}.table-responsive .table tbody tr{height:35px!important;min-height:35px!important;max-height:35px!important;cursor:pointer}.table-responsive .table tbody tr:hover{background-color:#f5f5f5}.table-responsive .table tbody input{border:1px solid rgba(34,0,255,.37);height:100%!important;font-size:smaller!important}.table-responsive .table tbody input[type=text],.table-responsive .table tbody input:not([type]){width:100%!important}.table-responsive .table tbody input[type=number]{min-width:80px!important;width:80px!important;text-align:center}.table-responsive .table thead th.boolean-column,.table-responsive .table tbody td.boolean-column,.table-responsive .table thead th.selection-column,.table-responsive .table tbody td.selection-column,.table-responsive .table thead th.table-actions-header,.table-responsive .table tbody td.table-actions-header{width:1%;white-space:nowrap}.table-responsive .table thead th.number-column,.table-responsive .table tbody td.number-column{width:1%;white-space:nowrap;text-align:center}.table-responsive .table thead th.number-column input[type=number],.table-responsive .table tbody td.number-column input[type=number]{min-width:80px!important;width:80px!important;text-align:center}.table-responsive .table .actions-cell{white-space:nowrap;padding:0!important}.table-responsive .table .actions-container{display:flex;flex-direction:row;justify-content:center;align-items:center;width:100%;height:100%}\n"] }]
412
+ }], propDecorators: { data$: [{ type: i0.Input, args: [{ isSignal: true, alias: "data$", required: true }] }], columns: [{ type: i0.Input, args: [{ isSignal: true, alias: "columns", required: false }] }], inputValues$: [{ type: i0.Input, args: [{ isSignal: true, alias: "inputValues$", required: false }] }], customActions: [{ type: i0.Input, args: [{ isSignal: true, alias: "customActions", required: false }] }], size: [{ type: i0.Input, args: [{ isSignal: true, alias: "size", required: false }] }], multiple: [{ type: i0.Input, args: [{ isSignal: true, alias: "multiple", required: false }] }], searchable: [{ type: i0.Input, args: [{ isSignal: true, alias: "searchable", required: false }] }], allowSelection: [{ type: i0.Input, args: [{ isSignal: true, alias: "allowSelection", required: false }] }], noConfirm: [{ type: i0.Input, args: [{ isSignal: true, alias: "noConfirm", required: false }] }], actionClick: [{ type: i0.Output, args: ["actionClick"] }], searchTerm: [{ type: i0.Output, args: ["searchTerm"] }], errorEvent: [{ type: i0.Output, args: ["errorEvent"] }], selectable: [{ type: i0.Output, args: ["selectable"] }] } });
413
+ //# sourceMappingURL=table.component.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table.component.js","sourceRoot":"","sources":["../../../../../libs/ui/src/lib/table/table.component.ts","../../../../../libs/ui/src/lib/table/table.component.html"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,KAAK,EACL,MAAM,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AAI,CAAC,OAAO,EAAE,CACf,CAAC;IACJ,CAAC;IAED,qBAAqB,CAAC,MAAsB,EAAE,GAAM;QAClD,OAAO,IAAI,CAAC,iBAAiB,CAAC,qBAAqB,CACjD,MAAM,EACN,GAAG,EACH,IAAI,CAAC,IAAI,EAAE,EACX,IAAI,CAAC,OAAO,EAAE,CACf,CAAC;IACJ,CAAC;uGA1XU,iBAAiB;2FAAjB,iBAAiB,82CC9J9B,ixTAmOuB,ogHDzEX,gBAAgB,gMAAE,iBAAiB;;2FAIlC,iBAAiB;kBAR1B,SAAS;+BAED,WAAW,cACT,IAAI,WACP,CAAC,gBAAgB,EAAE,iBAAiB,CAAC","sourcesContent":["import {\n Component,\n input,\n signal,\n computed,\n output,\n OnInit,\n OnDestroy,\n inject,\n} from '@angular/core';\nimport { Observable, Subscription } from 'rxjs';\nimport { C80IconComponent } from '../icon';\nimport { TableColumnVisibilityService } from './table-column-visibility.service';\nimport { TableDataUtilsService } from './table-data-utils.service';\nimport { TableDataConverterService } from './table-data-converter.service';\nimport { TableSelectionService } from './table-selection.service';\nimport { TableCrudStateService } from './table-crud-state.service';\nimport { C80TableColDef, CustomTableAction } from './table.types';\nimport { C80ModalComponent, ModalService } from '../modal';\nimport {\n booleanAttribute,\n getErrorMessage,\n getInputValue,\n trackById,\n shouldShowAction,\n getActionTooltip,\n} from './table.utils';\n\n/**\n * C80TableComponent - Componente de tabla avanzado con funcionalidades CRUD\n *\n * COMPORTAMIENTO DE VISIBILIDAD DE COLUMNAS:\n * ========================================\n *\n * 1. PRIORIDAD MÁXIMA - visible: false\n * - La columna se oculta SIEMPRE, sin excepciones\n * - Ni en modo creación ni en modo edición se muestra\n *\n * 2. OCULTACIÓN AUTOMÁTICA - hideIfAllValuesAreNull: true\n * - La columna se oculta solo si TODOS los valores actuales están vacíos\n * - Valores considerados vacíos: null, undefined, '', [], {}\n * - Valores NO vacíos: 0, false (son valores válidos)\n * - EXCEPCIONES IMPORTANTES:\n * * En modo creación (creating=true) estas columnas SÍ se muestran\n * * En modo edición de una fila específica se muestran SOLO si esa fila tiene valor\n *\n * 3. POR DEFECTO - Columnas normales\n * - Se muestran siempre (visualización, creación y edición)\n *\n * VALORES POR DEFECTO EN CREACIÓN:\n * ===============================\n *\n * - Propiedad `default?: unknown` permite definir valores por defecto para modo creación\n * - Solo se aplica cuando se inicia el modo creación (startCreate)\n * - Puede ser cualquier tipo: string, number, boolean, etc.\n * - Si no se especifica `default`, se usa cadena vacía ('')\n *\n * VALORES DINÁMICOS EN CREACIÓN Y EDICIÓN:\n * =======================================\n *\n * - Input `inputValues$?: Observable<Partial<T>>` permite actualizar valores dinámicamente\n * - Solo se aplica durante modo creación (creating=true) o edición (editing!=null)\n * - Los valores se aplican automáticamente cuando el Observable emite\n * - Permite cambios múltiples durante el mismo modo de creación/edición\n * - Los nuevos valores sobrescriben los existentes (spread operator)\n *\n * TIPOS DE DATOS SOPORTADOS:\n * =========================\n *\n * - 'string': Texto normal (default)\n * - 'number': Números decimales (preserva decimales: 5.3 → 5.3)\n * - 'integer': Números enteros (convierte a entero: 5.3 → 5)\n * - 'boolean': Verdadero/Falso (checkbox)\n * - 'password': Texto oculto (input type=\"password\")\n * - 'enum': Lista de opciones predefinidas (select)\n *\n * SISTEMA DE ACCIONES UNIFICADO (customActions):\n * =============================================\n *\n * Input: `customActions: CustomTableAction[]` - Array de acciones dinámicas\n * Output: `(actionClick)` - Evento unificado que emite { action: string, row: T }\n *\n * ACCIONES CRUD PREDEFINIDAS (TABLE_CRUD_ACTIONS):\n * ------------------------------------------------\n * - CREATE: Solo aparece como botón \"+\" en header (no en filas)\n * - UPDATE: Activa modo edición (muestra inputs), botón \"✓\" guarda cambios\n * - DELETE: Muestra confirmación y emite evento delete\n * - CANCEL: Muestra confirmación y emite evento cancel (opcional)\n *\n * ACCIONES PERSONALIZADAS (Custom Actions):\n * -----------------------------------------\n * Interfaz: { name: string, icon: IconType, condition?: (row) => boolean, tooltip?: string }\n * - name: ID único de la acción\n * - icon: Icono del botón (ej: 'settings', 'upload', 'refresh')\n * - condition: Función opcional para mostrar/ocultar según estado de fila\n * - tooltip: Texto al hacer hover (default: name)\n *\n * MANEJO EN COMPONENTE:\n * --------------------\n * ```typescript\n * // 1. Definir acciones en constants:\n * export const ENTITY_TABLE_ACTIONS: CustomTableAction[] = [\n * TABLE_CRUD_ACTIONS.CREATE,\n * TABLE_CRUD_ACTIONS.UPDATE,\n * { name: 'custom-action', icon: 'settings', tooltip: 'Configurar' },\n * TABLE_CRUD_ACTIONS.DELETE\n * ];\n *\n * // 2. En el componente:\n * readonly tableActions = ENTITY_TABLE_ACTIONS;\n *\n * handleAction({ action, row }) {\n * const entity = row as unknown as EntityType;\n * switch (action) {\n * case 'create': this.onCreate(row); break;\n * case 'update': this.onUpdate(entity); break;\n * case 'delete': this.onDelete(entity.id); break;\n * case 'custom-action': this.onCustom(entity); break;\n * }\n * }\n * ```\n *\n * ACCIONES CON CONDICIÓN:\n * ----------------------\n * ```typescript\n * {\n * name: 'enable',\n * icon: 'toggleOn',\n * tooltip: 'Habilitar',\n * condition: (row) => row['enabled'] === false\n * }\n * ```\n *\n * CONSTANTES REUTILIZABLES:\n * ------------------------\n * - TABLE_CRUD_ACTIONS: Objeto con CREATE, UPDATE, DELETE, CANCEL\n * - BASIC_CRUD_ACTIONS: Array con [CREATE, UPDATE, DELETE]\n * Importar desde: `@shared` o `@shared/constants`\n *\n * EJEMPLOS COMPLETOS:\n * ------------------\n * - { accessor: 'id', visible: false } → NUNCA se muestra\n * - { accessor: 'motorPos', hideIfAllValuesAreNull: true, default: 0, type: 'integer' } → Entero (5.7 → 5)\n * - { accessor: 'weight', type: 'number', default: 2.5 } → Decimal preservado (5.7 → 5.7)\n * - { accessor: 'status', default: 'active' } → Se autorellena con 'active' en creación\n * - { accessor: 'name' } → Siempre visible, sin valor por defecto (cadena vacía)\n * - inputValues$ emite { motorPos: 5, weight: 2.3 } → actualiza inputs dinámicamente\n * - customActions con CREATE → Muestra botón \"+\" en header\n * - customActions con UPDATE → Botón \"edit\" activa modo edición\n * - customActions con custom → Botón personalizado emite evento\n */@Component({\n // eslint-disable-next-line @angular-eslint/component-selector\n selector: 'c80-table',\n standalone: true,\n imports: [C80IconComponent, C80ModalComponent],\n templateUrl: './table.component.html',\n styleUrl: './table.component.scss',\n})\nexport class C80TableComponent<T extends Record<string, unknown>> implements OnInit, OnDestroy {\n // Servicios inyectados\n private readonly modalService = inject(ModalService);\n private readonly visibilityService = inject(TableColumnVisibilityService);\n private readonly dataUtils = inject(TableDataUtilsService);\n private readonly dataConverter = inject(TableDataConverterService);\n private readonly selectionService = inject(TableSelectionService);\n private readonly crudService = inject(TableCrudStateService);\n\n // Inputs\n readonly data$ = input.required<Observable<T[]>>();\n readonly columns = input<C80TableColDef[]>([]);\n readonly inputValues$ = input<Observable<Partial<T>>>(); // Observable para actualizar valores de inputs dinámicamente en creación/edición\n readonly customActions = input<CustomTableAction[]>([]); // Acciones personalizadas dinámicas\n readonly size = input(0); // Tamaño de la tabla (0 = sin límite, > 0 aplica max-height)\n readonly multiple = input(true); // Permite selección múltiple por defecto\n readonly searchable = input(false, { transform: booleanAttribute }); // Si es true, muestra barra de búsqueda\n readonly allowSelection = input(false, { transform: booleanAttribute }); // Si es true, permite selección de filas\n readonly noConfirm = input(false, { transform: booleanAttribute }); // Si es true, no muestra confirmaciones modales\n\n // Outputs - Acciones unificadas (Angular 18+ output API)\n readonly actionClick = output<{ action: string; row: T }>(); // Output unificado para TODAS las acciones (CRUD + custom)\n\n // Outputs - Utilidades\n readonly searchTerm = output<string>();\n readonly errorEvent = output<string>();\n readonly selectable = output<T[]>();\n\n // Estado principal\n readonly data = signal<T[]>([]);\n readonly searchValue = signal<string>('');\n\n // Estado de selección (delegado a servicio)\n private readonly selectionState = this.selectionService.createSelectionState<T>();\n readonly selectedItems = this.selectionState.selectedItems;\n readonly selectAllChecked = this.selectionState.selectAllChecked;\n readonly selectAllIndeterminate = this.selectionState.selectAllIndeterminate;\n\n // Estado CRUD (delegado a servicio)\n private readonly crudState = this.crudService.createCrudState<T>();\n readonly creating = this.crudState.creating;\n readonly newRow = this.crudState.newRow;\n readonly editing = this.crudState.editing;\n readonly editRow = this.crudState.editRow;\n\n // Keys visibles computed automáticamente\n readonly keys = computed(() =>\n this.visibilityService.updateVisibleKeys(\n this.columns(),\n this.data(),\n this.creating(),\n this.editing()\n )\n );\n\n // Computed - Detecta acciones CRUD y custom\n readonly hasAnyActions = computed(() => this.customActions().length > 0);\n readonly hasCrudCreate = computed(() => this.customActions().some(a => a.name === 'create'));\n readonly hasCrudUpdate = computed(() => this.customActions().some(a => a.name === 'update'));\n readonly hasCrudDelete = computed(() => this.customActions().some(a => a.name === 'delete'));\n readonly hasCrudCancel = computed(() => this.customActions().some(a => a.name === 'cancel'));\n\n // Table max height computed\n readonly tableMaxHeight = computed(() =>\n this.dataUtils.getTableMaxHeight(this.size())\n );\n\n private dataSub?: Subscription;\n private inputValuesSub?: Subscription;\n\n /**\n * Maneja input de creación/edición de forma unificada\n */\n private handleInput(\n event: Event,\n key: string,\n col: C80TableColDef | undefined,\n isEdit: boolean\n ): void {\n const updateFn = isEdit\n ? this.crudState.updateEditRow.bind(this.crudState)\n : this.crudState.updateNewRow.bind(this.crudState);\n\n const value = getInputValue(event, col);\n if (value !== undefined) {\n updateFn(key, value);\n }\n }\n\n /**\n * Maneja confirmación modal de forma genérica\n */\n private async handleConfirmAction(\n title: string,\n message: string,\n confirmText: string,\n action: () => void\n ): Promise<void> {\n if (this.noConfirm()) {\n action();\n return;\n }\n\n const confirmed = await this.modalService.confirm(\n title,\n message,\n confirmText,\n 'Cancelar'\n );\n\n if (confirmed) {\n action();\n }\n }\n\n\n\n ngOnInit() {\n const data$ = this.data$();\n if (!data$) return;\n this.dataSub = data$.subscribe({\n next: (items) => {\n this.dataUtils.applySorting(items, this.columns());\n this.data.set(items);\n this.preserveSelection();\n },\n error: (err: unknown) =>\n this.errorEvent.emit(getErrorMessage(err)),\n });\n\n // Suscribirse a inputValues$ para actualizar valores dinámicamente en creación/edición\n const inputValues$ = this.inputValues$();\n if (inputValues$) {\n this.inputValuesSub = inputValues$.subscribe({\n next: (partialValues) => {\n this.crudState.applyInputValues(partialValues);\n },\n error: (err: unknown) =>\n console.warn('Error en inputValues$:', getErrorMessage(err)),\n });\n }\n }\n\n ngOnDestroy() {\n this.dataSub?.unsubscribe();\n this.inputValuesSub?.unsubscribe();\n\n // Close any open modal when component is destroyed\n this.modalService.closeModal();\n }\n\n onInput(event: Event, key: string, col?: C80TableColDef): void {\n this.handleInput(event, key, col, false);\n }\n\n onEditInput(event: Event, key: string, col?: C80TableColDef): void {\n this.handleInput(event, key, col, true);\n }\n\n async onDelete(row: T): Promise<void> {\n await this.handleConfirmAction(\n 'Confirmar eliminación',\n '¿Está seguro de que desea eliminar este elemento? Esta acción no se puede deshacer.',\n 'Eliminar',\n () => this.actionClick.emit({ action: 'delete', row })\n );\n }\n\n async onCancel(row: T): Promise<void> {\n await this.handleConfirmAction(\n 'Confirmar cancelación',\n '¿Está seguro de que desea cancelar este elemento?',\n 'Cancelar elemento',\n () => this.actionClick.emit({ action: 'cancel', row })\n );\n }\n\n startCreate(): void {\n this.crudState.startCreate(this.columns(), this.data());\n }\n\n cancelCreate(): void {\n this.crudState.cancelCreate();\n }\n\n saveCreate(): void {\n const current = this.newRow();\n if (current) {\n const convertedRow = this.convertRowTypes(current);\n this.actionClick.emit({ action: 'create', row: convertedRow as T });\n this.cancelCreate();\n }\n }\n\n onEdit(row: T): void {\n this.crudState.startEdit(row, this.columns(), this.data());\n }\n\n cancelEdit(): void {\n this.crudState.cancelEdit();\n }\n\n saveEdit(row: T): void {\n const changes = this.editRow();\n if (changes) {\n const convertedChanges = this.convertRowTypes(changes);\n const updatedRow = { ...row, ...convertedChanges } as T;\n this.actionClick.emit({ action: 'update', row: updatedRow });\n this.cancelEdit();\n }\n }\n\n /**\n * Convierte todos los valores de una fila según los tipos definidos en las columnas\n * Asegura que los datos emitidos tengan el tipo correcto (integer, number, boolean, etc.)\n */\n private convertRowTypes(row: Partial<T>): Partial<T> {\n const converted: Record<string, unknown> = {};\n const columnsMap = new Map(this.columns().map(col => [col.accessor, col]));\n\n for (const [key, value] of Object.entries(row)) {\n const col = columnsMap.get(key);\n if (col) {\n converted[key] = this.dataConverter.convertCellValue(value, col);\n } else {\n converted[key] = value;\n }\n }\n\n return converted as Partial<T>;\n }\n\n /**\n * TrackBy function for ngFor to avoid DOM re-creation (NG0956 warning).\n */\n readonly trackById = trackById<T>;\n\n /**\n * Verifica si una acción personalizada debe mostrarse para una fila específica\n */\n readonly shouldShowAction = shouldShowAction<T>;\n\n /**\n * Obtiene el tooltip de una acción\n */\n readonly getActionTooltip = getActionTooltip;\n\n /**\n * Maneja el click en una acción personalizada dinámica\n * UPDATE activa el modo edición, otras acciones emiten directamente\n * Si la acción tiene configuración de confirmación, muestra modal antes de ejecutar\n */\n onDynamicAction(action: CustomTableAction, row: T): void {\n if (action.name === 'update') {\n this.onEdit(row);\n return;\n }\n\n if (action.name === 'delete') {\n void this.onDelete(row);\n return;\n }\n\n if (action.name === 'cancel') {\n void this.onCancel(row);\n return;\n }\n\n // Si la acción tiene confirmación configurada, mostrar modal\n if (action.confirmation) {\n void this.handleActionWithConfirmation(action, row);\n return;\n }\n\n // Sin confirmación, emitir directamente\n this.actionClick.emit({ action: action.name, row });\n }\n\n /**\n * Maneja acciones que requieren confirmación del usuario\n */\n private async handleActionWithConfirmation(action: CustomTableAction, row: T): Promise<void> {\n if (!action.confirmation) return;\n\n const confirmed = await this.modalService.confirm(\n action.confirmation.title,\n action.confirmation.message,\n action.confirmation.confirmText || 'Confirmar',\n action.confirmation.cancelText || 'Cancelar'\n );\n\n if (confirmed) {\n this.actionClick.emit({ action: action.name, row });\n }\n }\n\n /**\n * Handles search input changes with debouncing\n */\n onSearchInput(event: Event): void {\n const target = event.target as HTMLInputElement;\n const value = target.value;\n this.searchValue.set(value);\n this.searchTerm.emit(value);\n }\n\n /**\n * Clears the search input\n */\n clearSearch(): void {\n this.searchValue.set('');\n this.searchTerm.emit('');\n }\n\n // Referencias readonly a métodos de servicios (evita wrappers innecesarios)\n readonly getCellValue = this.dataUtils.getCellValue.bind(this.dataUtils);\n readonly getDisplayValue = this.dataUtils.getDisplayValue.bind(this.dataUtils);\n readonly getEnumDisplayValue = this.dataUtils.getEnumDisplayValue.bind(this.dataUtils);\n readonly getEnumOptions = this.dataUtils.getEnumOptions.bind(this.dataUtils);\n readonly getCellColor = this.dataUtils.getCellColor.bind(this.dataUtils);\n\n /**\n * Selection methods\n */\n clearSelection(): void {\n this.selectionState.clearSelection();\n this.selectionService.emitSelection(this.selectionState as never, this.data(), this.selectable);\n }\n\n /**\n * Mantiene la selección existente después de actualizar los datos,\n * eliminando solo los IDs que ya no existen en los nuevos datos\n */\n private preserveSelection(): void {\n this.selectionState.preserveSelection(this.data());\n this.selectionService.emitSelection(this.selectionState as never, this.data(), this.selectable);\n }\n\n toggleSelectAll(): void {\n this.selectionState.toggleSelectAll(this.data());\n this.selectionService.emitSelection(this.selectionState as never, this.data(), this.selectable);\n }\n\n toggleItemSelection(item: T): void {\n this.selectionState.toggleItemSelection(item, this.multiple());\n this.selectionService.emitSelection(this.selectionState as never, this.data(), this.selectable);\n }\n\n isItemSelected(item: T): boolean {\n return this.selectionState.isItemSelected(item);\n }\n\n\n\n // Métodos de visibilidad delegados a servicio\n isColumnVisible(column: C80TableColDef): boolean {\n return this.visibilityService.isColumnVisible(column, this.data(), {\n creating: this.creating(),\n row: this.newRow() ?? undefined\n });\n }\n\n isColumnVisibleInHeader(column: C80TableColDef): boolean {\n return this.visibilityService.isColumnVisibleInHeader(\n column,\n this.data(),\n this.creating(),\n this.editing()\n );\n }\n\n isColumnVisibleForRow(column: C80TableColDef, row: T): boolean {\n return this.visibilityService.isColumnVisibleForRow(\n column,\n row,\n this.data(),\n this.editing()\n );\n }\n}\n","<div class=\"table-responsive\" [style.max-height]=\"tableMaxHeight()\" [style.overflow-y]=\"size() > 0 ? 'auto' : 'visible'\">\n <!-- Search Bar -->\n @if (searchable()) {\n <div class=\"search-container\">\n <div class=\"search-input-wrapper\">\n <div class=\"input-group\">\n <span class=\"input-group-text\">\n <c80-icon icon=\"search\" [size]=\".8\"></c80-icon>\n </span>\n <input type=\"text\" class=\"form-control search-input\" placeholder=\"Buscar...\" [value]=\"searchValue()\" (input)=\"onSearchInput($event)\" aria-label=\"Buscar en la tabla\" />\n @if (searchValue()) {\n <button class=\"btn btn-outline-secondary btn-borrar\" type=\"button\" (click)=\"clearSearch()\" title=\"Limpiar búsqueda\">\n <c80-icon icon=\"cancel\" [size]=\".7\"></c80-icon>\n </button>\n }\n </div>\n </div>\n </div>\n }\n\n <table class=\"table table-bordered table-hover align-middle\">\n <thead class=\"thead table-light sticky-header\">\n <tr>\n @if (allowSelection() && data().length !== 0) {\n <th class=\"text-center selection-column\">\n @if (multiple()) {\n <input type=\"checkbox\" [checked]=\"selectAllChecked()\" [indeterminate]=\"selectAllIndeterminate()\" (change)=\"toggleSelectAll()\" aria-label=\"Seleccionar todo\" />\n }\n </th>\n }\n @for (col of columns(); track col) {\n @if (isColumnVisibleInHeader(col)) {\n @if (col.type === 'boolean') {\n <th class=\"text-center boolean-column\">{{ col.label }}</th>\n }\n @else if (col.type === 'number' || col.type === 'integer') {\n <th class=\"text-center number-column\">{{ col.label }}</th>\n }\n @else {\n <th>{{ col.label }}</th>\n }\n }\n }\n @if (hasAnyActions()) {\n <th class=\"table-actions-header\">\n <div class=\"actions-wrapper\">\n <span>Actions</span>\n @if (hasCrudCreate()) {\n <c80-icon button icon=\"add\" [disabled]=\"creating()\" title=\"Agregar\" [size]=\".6\" (iconClick)=\"startCreate()\"></c80-icon>\n }\n </div>\n </th>\n }\n </tr>\n </thead>\n <tbody>\n @for (row of data(); track trackById(i, row); let i = $index) {\n <tr>\n @if (allowSelection() && data().length !== 0) {\n <td class=\"text-center selection-column\">\n <input type=\"checkbox\" [checked]=\"isItemSelected(row)\" (change)=\"toggleItemSelection(row)\" [attr.aria-label]=\"'Seleccionar fila ' + (i + 1)\" />\n </td>\n }\n @for (col of columns(); track col) {\n @if (isColumnVisibleForRow(col, row)) {\n @if (col.type === 'boolean') {\n <td class=\"text-center boolean-column\">\n @if (editing() === row['id'] && !col.readOnly) {\n <input type=\"checkbox\" [checked]=\"!!editRow()?.[col.accessor]\" (change)=\"onEditInput($event, col.accessor, col)\" [attr.aria-label]=\"col.label\" />\n }\n @else {\n @if (getCellValue(row, col.accessor) === true) {\n <c80-icon icon=\"check\" [size]=\".7\"></c80-icon>\n <br />\n }\n @else if (getCellValue(row, col.accessor) === false) {\n <c80-icon icon=\"cancel\" [size]=\".7\"></c80-icon>\n <br />\n }\n }\n </td>\n }\n @else if (col.type === 'number' || col.type === 'integer') {\n <td class=\"text-center number-column\">\n @if (editing() === row['id'] && !col.readOnly) {\n <input class=\"form-control form-control-sm\" type=\"number\" [value]=\"editRow()?.[col.accessor] ?? ''\" [placeholder]=\"col.label\" [min]=\"col.min\" [max]=\"col.max\" [step]=\"col.type === 'integer' ? '1' : 'any'\"\n (input)=\"onEditInput($event, col.accessor, col)\" />\n }\n @else {\n <span [style.color]=\"getCellColor(getCellValue(row, col.accessor), col)\">{{ getDisplayValue(getCellValue(row,\n col.accessor), col) }}</span>\n }\n </td>\n }\n @else {\n <td>\n @if (editing() === row['id'] && !col.readOnly) {\n @if (col.type === 'enum') {\n <select class=\"form-control form-control-sm\" [value]=\"editRow()?.[col.accessor] ?? ''\" (change)=\"onEditInput($event, col.accessor, col)\">\n <option value=\"\">{{ col.label }}</option>\n @for (option of getEnumOptions(col); track option.value) {\n <option [value]=\"option.value\">{{ option.label }}</option>\n }\n </select>\n }\n @else {\n <input class=\"form-control form-control-sm\" [type]=\"col.type === 'password' ? 'password' : 'text'\" [value]=\"editRow()?.[col.accessor] ?? ''\" [placeholder]=\"col.label\" (input)=\"onEditInput($event, col.accessor, col)\" />\n }\n }\n @else {\n @if (col.type === 'password') {\n <span [style.color]=\"getCellColor(getCellValue(row, col.accessor), col)\">******</span>\n }\n @else if (col.type === 'enum') {\n <span [style.color]=\"getCellColor(getCellValue(row, col.accessor), col)\">{{\n getEnumDisplayValue(getCellValue(row, col.accessor), col)\n }}</span>\n }\n @else if (getCellValue(row, col.accessor) === true) {\n <c80-icon icon=\"check\" [size]=\".7\"></c80-icon>\n }\n @else if (getCellValue(row, col.accessor) === false) {\n <c80-icon icon=\"cancel\" [size]=\".7\"></c80-icon>\n }\n @else {\n <span [style.color]=\"getCellColor(getCellValue(row, col.accessor), col)\">{{ getDisplayValue(getCellValue(row,\n col.accessor), col) }}</span>\n }\n }\n </td>\n }\n }\n }\n @if (hasAnyActions()) {\n <td class=\"text-center actions-cell\">\n <div class=\"actions-container\">\n @if (editing() === row['id']) {\n <!-- Modo edición: mostrar guardar y cancelar -->\n @if (hasCrudUpdate()) {\n <c80-icon button icon=\"check\" title=\"Guardar\" (iconClick)=\"saveEdit(row)\" [size]=\".7\"></c80-icon>\n }\n <c80-icon button icon=\"cancel\" color=\"warn\" title=\"Cancelar\" (iconClick)=\"cancelEdit()\" [size]=\".7\"></c80-icon>\n }\n @else {\n @for (action of customActions(); track action.name) {\n @if (shouldShowAction(action, row)) {\n <c80-icon button [icon]=\"action.icon\" [customColor]=\"action.color\" [color]=\"action.name === 'delete' ? 'warn' : 'primary'\" [title]=\"getActionTooltip(action)\" (iconClick)=\"onDynamicAction(action, row)\" [size]=\".7\"></c80-icon>\n }\n }\n }\n </div>\n </td>\n }\n </tr>\n }\n @if (creating() && hasCrudCreate()) {\n <tr>\n @if (allowSelection() && data().length !== 0) {\n <td class=\"text-center selection-column\">\n <!-- Empty cell for alignment -->\n </td>\n }\n @for (col of columns(); track col) {\n @if (isColumnVisible(col)) {\n @if (col.type === 'boolean') {\n <td class=\"text-center\">\n @if (!col.readOnly) {\n <input type=\"checkbox\" [checked]=\"!!newRow()?.[col.accessor]\" (change)=\"onInput($event, col.accessor, col)\" [attr.aria-label]=\"col.label\" />\n }\n @else {\n <!-- ReadOnly boolean column in create mode shows empty -->\n <span class=\"text-muted\">-</span>\n }\n </td>\n } @else if (col.type === 'number' || col.type === 'integer') {\n <td class=\"text-center number-column\">\n @if (!col.readOnly) {\n <input class=\"form-control form-control-sm\" type=\"number\" [value]=\"newRow()?.[col.accessor] ?? ''\" [placeholder]=\"col.label\" [min]=\"col.min\" [max]=\"col.max\" [step]=\"col.type === 'integer' ? '1' : 'any'\"\n (input)=\"onInput($event, col.accessor, col)\" />\n }\n @else {\n <!-- ReadOnly number column in create mode shows empty -->\n <span class=\"text-muted\">-</span>\n }\n </td>\n } @else {\n <td>\n @if (!col.readOnly) {\n @if (col.type === 'enum') {\n <select class=\"form-control form-control-sm\" [value]=\"newRow()?.[col.accessor] ?? ''\" (change)=\"onInput($event, col.accessor, col)\">\n <option value=\"\">{{ col.label }}</option>\n @for (option of getEnumOptions(col); track option.value) {\n <option [value]=\"option.value\">{{ option.label }}</option>\n }\n </select>\n }\n @else {\n <input class=\"form-control form-control-sm\" type=\"text\" [value]=\"newRow()?.[col.accessor] ?? ''\" [placeholder]=\"col.label\" (input)=\"onInput($event, col.accessor, col)\" />\n }\n }\n @else {\n <!-- ReadOnly column in create mode shows empty -->\n <span class=\"text-muted\">-</span>\n }\n </td>\n }\n }\n }\n <td class=\"text-center actions-cell\">\n <div class=\"actions-container\">\n @if (hasCrudCreate()) {\n <c80-icon button icon=\"check\" title=\"Guardar\" (iconClick)=\"saveCreate()\" [size]=\".7\"></c80-icon>\n }\n <c80-icon button icon=\"cancel\" color=\"warn\" title=\"Cancelar\" (iconClick)=\"cancelCreate()\" [size]=\".7\"></c80-icon>\n </div>\n </td>\n </tr>\n }\n </tbody>\n </table>\n @if (data().length === 0 && !creating()) {\n <div class=\"text-center text-muted py-3 small\">\n No hay datos para mostrar.\n </div>\n }\n</div>\n\n<c80-modal></c80-modal>"]}
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Tipos comunes para las tablas C80
3
+ */
4
+ export {};
5
+ //# sourceMappingURL=table.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table.types.js","sourceRoot":"","sources":["../../../../../libs/ui/src/lib/table/table.types.ts"],"names":[],"mappings":"AAAA;;GAEG","sourcesContent":["/**\n * Tipos comunes para las tablas C80\n */\n\nimport type { IconType } from '../icon';\n\nexport interface C80TableColDef {\n accessor: string;\n label: string;\n visible?: boolean; // Si no se especifica, se asume true. Si es false, la columna se oculta SIEMPRE (máxima prioridad)\n type?: 'string' | 'number' | 'integer' | 'boolean' | 'password' | 'enum' | 'date'; // Tipo de dato para la columna\n order?: 'ASC' | 'DESC'; // Ordenamiento de la columna\n readOnly?: boolean; // Si no se especifica, se asume false\n enum?: Record<string | number, string>; // Opciones del enum para type 'enum'\n color?: Record<string | number, string>; // Colores CSS basados en el valor de la celda\n hideIfAllValuesAreNull?: boolean; // Si es true, oculta la columna cuando todos los valores están vacíos (default: false).\n // Solo aplica si visible !== false. EXCEPCIÓN: En modo creación Y edición siempre se muestra.\n default?: unknown; // Valor por defecto para usar en modo creación. Puede ser string, number, boolean, etc.\n min?: number; // Valor mínimo permitido para columnas numéricas\n max?: number; // Valor máximo permitido para columnas numéricas\n}\n\n/**\n * Configuración de confirmación para acciones de tabla\n */\nexport interface ActionConfirmation {\n title: string; // Título del modal de confirmación\n message: string; // Mensaje del modal (puede incluir template con {propertyName})\n confirmText?: string; // Texto del botón de confirmar (default: \"Confirmar\")\n cancelText?: string; // Texto del botón de cancelar (default: \"Cancelar\")\n}\n\n/**\n * Definición de acción personalizada para tabla\n * Permite agregar acciones dinámicas sin modificar el componente\n */\nexport interface CustomTableAction {\n name: string;\n icon: IconType;\n color?: string;\n condition?: <T extends Record<string, unknown>>(row: T) => boolean;\n tooltip?: string;\n confirmation?: ActionConfirmation;\n}\n"]}