Extract combo editor and table grid
All checks were successful
Deploy Sokko G / deploy (push) Successful in 16s

This commit is contained in:
Shinuwa 2026-08-24 23:01:35 +02:00
parent 9455b31438
commit e512eef232
5 changed files with 360 additions and 217 deletions

View file

@ -2,7 +2,7 @@
import { useEffect, useMemo, useRef, useState } from "react";
import { TextExchangeActions } from "./TextExchangeActions.jsx";
import { cellAddress, columnIndexToName, evaluateTable, parseCellAddress } from "./tableFormulaEngine.js";
import { HeaderLabelInput, TableRow } from "./TableGridParts.jsx";
import { TableGrid } from "./TableGrid.jsx";
import { TableToolbar } from "./TableToolbar.jsx";
import {
DEFAULT_COLUMNS,
@ -410,65 +410,32 @@ export function TableModule({ toolboxId, moduleId, context, textExchangeOpen })
</div>
)}
<TableToolbar rows={data.rows} columns={data.columns} textContent={textContent} onResize={resize} onCopy={copyTsv} />
<div className="table-grid-wrap legacy-scrollbar">
<div
className="table-grid"
style={{
"--table-columns": `${rowHeaderWidth}px ${columnWidths.map((width) => `minmax(${width}px, 1fr)`).join(" ")}`,
"--table-min-width": `${rowHeaderWidth + columnWidths.reduce((total, width) => total + width, 0)}px`
}}
role="grid"
aria-label={textContent.gridLabel || "Tableau"}
>
<span className="table-corner" aria-hidden="true" />
{Array.from({ length: data.columns }, (_, columnIndex) => (
<HeaderLabelInput
className="table-header-cell table-header-input"
key={columnIndex}
value={data.columnLabels?.[columnIndex] || columnIndexToName(columnIndex)}
fallback={columnIndexToName(columnIndex)}
onSave={(value) => setColumnLabel(columnIndex, value)}
aria-label={`${textContent.columnLabel || "Intitulé de colonne"} ${columnIndexToName(columnIndex)}`}
title={`${columnIndexToName(columnIndex)} - ${textContent.columnFormulaTitle || "Référence conservée dans les formules"}`}
/>
))}
{Array.from({ length: data.rows }, (_, rowIndex) => (
<TableRow
key={rowIndex}
rowIndex={rowIndex}
columns={data.columns}
cells={data.cells}
evaluatedCells={evaluatedCells}
editingCell={editingCell}
highlightedCell={highlightedCell}
textContent={textContent}
rowLabel={data.rowLabels?.[rowIndex] || ""}
selection={selection}
movePreview={movePreview}
onRowLabelChange={setRowLabel}
onFocus={(cell) => {
const parsed = parseCellAddress(cell);
if (parsed && !selection) selectCell(parsed.rowIndex, parsed.columnIndex);
}}
onBlur={(cell) => {
if (editingCell === cell) setEditingCell("");
}}
onCellChange={setCellValue}
onFormulaSelectionStart={startFormulaSelection}
onFormulaSelectionExtend={extendFormulaSelection}
onStartMoveSelection={startMovingSelection}
onMoveSelection={updateMovePreview}
onSelectCell={selectCell}
onExtendSelection={extendSelection}
onPasteSelection={pasteSelection}
draggingSelectionRef={draggingSelectionRef}
onCellKeyDown={handleCellKeyDown}
onStartEditing={startEditing}
registerInput={registerInput}
/>
))}
</div>
</div>
<TableGrid
data={data}
textContent={textContent}
evaluatedCells={evaluatedCells}
editingCell={editingCell}
highlightedCell={highlightedCell}
selection={selection}
movePreview={movePreview}
columnWidths={columnWidths}
rowHeaderWidth={rowHeaderWidth}
draggingSelectionRef={draggingSelectionRef}
onColumnLabelChange={setColumnLabel}
onRowLabelChange={setRowLabel}
onCellChange={setCellValue}
onFormulaSelectionStart={startFormulaSelection}
onFormulaSelectionExtend={extendFormulaSelection}
onStartMoveSelection={startMovingSelection}
onMoveSelection={updateMovePreview}
onSelectCell={selectCell}
onExtendSelection={extendSelection}
onPasteSelection={pasteSelection}
onCellKeyDown={handleCellKeyDown}
onStartEditing={startEditing}
onEditingCellClear={() => setEditingCell("")}
registerInput={registerInput}
/>
</div>
);
}