( table: Table<TData>, row: Row<TData>, column: Column<TData, TValue>, columnId: string, )
| 50 | } |
| 51 | |
| 52 | export function createCell<TData extends RowData, TValue>( |
| 53 | table: Table<TData>, |
| 54 | row: Row<TData>, |
| 55 | column: Column<TData, TValue>, |
| 56 | columnId: string, |
| 57 | ): Cell<TData, TValue> { |
| 58 | const getRenderValue = () => |
| 59 | cell.getValue() ?? table.options.renderFallbackValue |
| 60 | |
| 61 | const cell: CoreCell<TData, TValue> = { |
| 62 | id: `${row.id}_${column.id}`, |
| 63 | row, |
| 64 | column, |
| 65 | getValue: () => row.getValue(columnId), |
| 66 | renderValue: getRenderValue, |
| 67 | getContext: memo( |
| 68 | () => [table, column, row, cell], |
| 69 | (table, column, row, cell) => ({ |
| 70 | table, |
| 71 | column, |
| 72 | row, |
| 73 | cell: cell as Cell<TData, TValue>, |
| 74 | getValue: cell.getValue, |
| 75 | renderValue: cell.renderValue, |
| 76 | }), |
| 77 | getMemoOptions(table.options, 'debugCells', 'cell.getContext'), |
| 78 | ), |
| 79 | } |
| 80 | |
| 81 | table._features.forEach((feature) => { |
| 82 | feature.createCell?.( |
| 83 | cell as Cell<TData, TValue>, |
| 84 | column, |
| 85 | row as Row<TData>, |
| 86 | table, |
| 87 | ) |
| 88 | }, {}) |
| 89 | |
| 90 | return cell as Cell<TData, TValue> |
| 91 | } |
no test coverage detected