'use client'; import { useState } from 'react'; const MAX_ROWS = 6; const MAX_COLUMNS = 8; interface TableInsertPickerProps { readonly onPick: (rows: number, columns: number) => void; readonly getLabel: (rows: number, columns: number) => string; } /** Grid picker for choosing a new table's row and column count. */ export function TableInsertPicker({ onPick, getLabel }: TableInsertPickerProps) { const [size, setSize] = useState({ rows: 1, columns: 1 }); return (
{Array.from({ length: MAX_ROWS }, (_, rowIndex) => Array.from({ length: MAX_COLUMNS }, (_, columnIndex) => { const rows = rowIndex + 1; const columns = columnIndex + 1; const active = rows <= size.rows && columns <= size.columns; const label = getLabel(rows, columns); return (
{getLabel(size.rows, size.columns)}
); }