/* Copyright 2026 Marimo. All rights reserved. */ "use no memo"; import type { Cell, Column, InitialTableState, Row, RowData, Table, TableFeature, } from "@tanstack/react-table"; import { getStableRowId } from "../utils"; import type { CellStyleState, CellStylingTableState } from "./types"; function getRowId(row: Row): string { return getStableRowId(row) ?? row.id; } export const CellStylingFeature: TableFeature = { getInitialState: (state?: InitialTableState): CellStylingTableState => { return { ...state, cellStyling: {} as CellStyleState, }; }, createCell: ( cell: Cell, column: Column, row: Row, table: Table, ) => { cell.getUserStyling = () => { const state = table.getState().cellStyling; const rowId = getRowId(row); return state?.[rowId]?.[column.id] || {}; }; }, };