Commit graph

12 commits

Author SHA1 Message Date
7d4d4190b8 refactor(advanced_table): Extraer result.zig y state_helpers.zig de state.zig
- Extraer AdvancedTableResult a result.zig (73 LOC)
- Extraer funciones de map shifting a state_helpers.zig (141 LOC con tests)
- Reducir state.zig de 1235 LOC a 1123 LOC
- Añadir swapMapEntries para operaciones de move row
- Mantener re-exports para compatibilidad
2025-12-29 10:23:41 +01:00
fa5854fa21 refactor(table_core): Modularizar en 10 archivos (<300 LOC cada uno)
BREAKING: table_core.zig ahora es carpeta table_core/

Módulos creados:
- types.zig: Enums, structs, constantes
- state.zig: CellEditState, NavigationState
- datasource.zig: TableDataSource interface
- row_buffer.zig: Excel-style commit logic
- keyboard.zig: Manejo de teclado
- navigation.zig: Tab, sorting, double-click
- rendering.zig: Funciones de dibujo
- scrollbars.zig: Scrollbars vertical/horizontal
- utils.zig: blendColor, startsWithIgnoreCase
- table_core.zig: Hub de re-exports

Beneficios:
- 2115 LOC → 10 archivos de ~100-270 LOC
- Debugging focalizado por módulo
- Imports actualizados en 7 archivos de widgets
2025-12-29 01:41:59 +01:00
454803fe03 feat(advanced_table): Unify Excel-style editing with VirtualAdvancedTable
- Add row_edit_buffer to AdvancedTableState
- Connect edit_buffer to rendering via drawRowsWithDataSource
- Use DRY planTabNavigation for Tab navigation + auto-commit
- Add Excel-style result fields: row_committed, row_changes, etc.
- Both widgets now share identical commit-on-row-change behavior
2025-12-28 01:59:31 +01:00
253c9b2449 refactor(tables): FASE 5 - Embeber NavigationState en AdvancedTableState y VirtualAdvancedTableState
- Añadido nav: table_core.NavigationState en ambos estados
- Eliminados campos duplicados (scroll_row, scroll_x, active_col, double_click)
- Actualizado todas las referencias a usar nav.*
- Conservado scroll_offset_pixels en Virtual (específico smooth scroll)
2025-12-27 19:47:43 +01:00
37e3b61aca refactor(states): Embed CellEditState in AdvancedTableState and VirtualAdvancedTableState
FASE 2 del refactor de tablas:
- AdvancedTableState: Embed cell_edit, delegate editing methods
- VirtualAdvancedTableState: Embed cell_edit, replace editing_cell/edit_buffer
- Update advanced_table.zig to use isEditing() and cell_edit.*
- Update virtual_advanced_table.zig to use getEditingCell()
- Update cell_editor.zig to use cell_edit.*

Reduces code duplication, centralizes editing logic in table_core
2025-12-27 16:45:58 +01:00
27b69cfcde refactor(table_core): Move Tab navigation logic to shared module (Norma #7 DRY)
ANTES: calculateNextCell/calculatePrevCell duplicados en:
  - AdvancedTableState
  - VirtualAdvancedTableState

AHORA: Lógica común en table_core.zig:
  - calculateNextCell() - calcula siguiente celda (Tab)
  - calculatePrevCell() - calcula celda anterior (Shift+Tab)
  - toggleSort() - alterna ordenación de columna
  - TabNavigateResult, CellPosition, SortDirection, SortToggleResult

Ambos widgets usan table_core, adaptando el resultado a su modelo:
  - AdvancedTable: selected_row/selected_col (índices)
  - VirtualAdvancedTable: selected_id + active_col (ID + columna)

Tests añadidos para calculateNextCell, calculatePrevCell, toggleSort
2025-12-27 01:49:56 +01:00
c2f0fbb19d refactor(tables): Add tabToNextCell/tabToPrevCell to both AdvancedTable and VirtualAdvancedTable
Norma #6: Abstract to library level
- Tab navigation with wrap now in library, not application
- AdvancedTableState.tabToNextCell/tabToPrevCell for in-memory data
- VirtualAdvancedTableState.tabToNextCell/tabToPrevCell for paginated data
- DRY: same logic available in both table widgets
2025-12-27 01:28:32 +01:00
47fc5b28f7 refactor(tables): Add table_core.zig with shared rendering functions
- New module: table_core.zig with common table rendering logic
- drawCellActiveIndicator(): visual indicator for selected cell  
- detectDoubleClick(): timing-based double-click detection
- handleEditingKeyboard(): common keyboard handling for editing
- blendColor(), startsWithIgnoreCase(): utilities

VirtualAdvancedTable now uses table_core:
- Active cell indicator in drawRows (visible highlight on selected cell)
- Double-click detection in handleMouseClick
- Added state fields: last_click_time, last_click_row, last_click_col

AdvancedTable changes:
- Improved cell active indicator (alpha 0.35, double border)
- Added double-click fields to state
- Space starts editing with empty value
- Alphanumeric keys start editing in editable cells
2025-12-26 17:53:16 +01:00
7f8870d890 fix(advanced_table): Use std.mem.swap for Row sorting + doc warnings
- Replace manual temp variable swap with std.mem.swap (more explicit)
- Add documentation warning about pointer invalidation after sort/setRows
- Row contains StringHashMap with internal pointers - swap is safe but
  pointers obtained via getRow() are invalidated after mutations

Based on INFORME_AUDITORIA_PROFUNDA_20251225.md §1.2
2025-12-25 23:04:01 +01:00
af1bb76aab feat(advanced_table): Multi-select, search, sorting, keyboard fixes
Bugs corregidos:
- Bug 1: Navegación teclado - cambio de keyPressed() a navKeyPressed()
- Bug 2: Sorting real - implementado sortRows() con bubble sort estable

Funcionalidades añadidas de Table:
- Multi-row selection (bit array 1024 rows, Ctrl+click, Shift+click, Ctrl+A)
- Incremental search (type-to-search con timeout 1000ms)
- Cell validation tracking (256 celdas con mensajes de error)

Nuevas funciones en AdvancedTableState:
- isRowSelected, addRowToSelection, removeRowFromSelection
- toggleRowSelection, clearRowSelection, selectAllRows
- selectRowRange, getSelectedRowCount, getSelectedRows, selectSingleRow
- addSearchChar, getSearchTerm, clearSearch, startsWithIgnoreCase
- hasCellError, addCellError, clearCellError, clearAllCellErrors
- hasAnyCellErrors, getLastValidationMessage

Cambios en types.zig:
- CellValue.compare() para ordenación
- allow_multi_select en TableConfig

Tests: 379 passing

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-17 18:34:34 +01:00
6287231cee feat: AdvancedTable Fases 7-8 - Lookup & Callbacks
Fase 7 - Lookup & Auto-fill:
- performLookupAndAutoFill() en commitEdit
- Busca en DataStore.lookup() al editar columna lookup
- Auto-rellena columnas según auto_fill_columns mapping
- Indicador visual "?" en header para columnas lookup
- Campo lookup_success en AdvancedTableResult

Fase 8 - Callbacks + Debounce:
- invokeCallbacks() con sistema de debounce (150ms default)
- on_row_selected: al cambiar selección
- on_cell_changed: al confirmar edición
- on_active_row_changed: al cambiar de fila (para paneles detalle)
- Campos last_callback_time_ms, last_notified_row en state

Tests: 373/373 (+3 nuevos)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-17 17:26:53 +01:00
83049a99be feat: AdvancedTable widget - Fases 1-6 IMPLEMENTADO (pendiente aprobacion)
Widget AdvancedTable portado de Go (simifactu-fyne) a Zig.
2,526 LOC en 4 archivos, 370 tests pasan.

Archivos:
- types.zig (369 LOC): CellValue, ColumnType, RowState, TableColors
- schema.zig (373 LOC): ColumnDef, TableSchema, DataStore interface
- state.zig (762 LOC): Selection, editing, dirty tracking, snapshots
- advanced_table.zig (1,022 LOC): Widget, rendering, keyboard

Fases implementadas:
1. Core (types, schema, state)
2. Navigation (arrows, Tab, PgUp/Dn, Home/End, Ctrl+Home/End)
3. Cell Editing (F2/Enter start, Escape cancel, text input)
4. Sorting (header click, visual indicators)
5. Auto-CRUD (CREATE/UPDATE/DELETE detection on row change)
6. Row Operations (Ctrl+N insert, Ctrl+Delete remove)

Fases diferidas (7-8): Lookup & Auto-fill, Callbacks avanzados

ESTADO: Compilado y tests pasan. NO probado en uso real.
REQUIERE: Aprobacion antes de tag de version.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-17 11:25:48 +01:00