UNPKG

@tanstack/table-core

Version:

Headless UI for building powerful tables & datagrids for TS/JS.

52 lines (50 loc) 2.17 kB
import { assignPrototypeAPIs, assignTableAPIs } from "../../utils.js"; import { row_getAllCells, row_getAllCellsByColumnId, row_getDisplayIndex, row_getLeafRows, row_getParentRow, row_getParentRows, row_getUniqueValues, row_getValue, row_renderValue, table_getMaxSubRowDepth, table_getRow, table_getRowId, table_getRowsInDisplayOrder } from "./coreRowsFeature.utils.js"; //#region src/core/rows/coreRowsFeature.ts /** * Core feature that creates row APIs for values, cells, and tree traversal. */ const coreRowsFeature = { assignRowPrototype: (prototype, table) => { assignPrototypeAPIs("coreRowsFeature", prototype, table, { row_getDisplayIndex: { fn: (row) => row_getDisplayIndex(row) }, row_getAllCellsByColumnId: { fn: (row) => row_getAllCellsByColumnId(row), memoDeps: (row) => [row.getAllCells()] }, row_getAllCells: { fn: (row) => row_getAllCells(row), memoDeps: (row) => [row.table.getAllLeafColumns()] }, row_getLeafRows: { fn: (row) => row_getLeafRows(row), memoDeps: (row) => [row.subRows] }, row_getParentRow: { fn: (row) => row_getParentRow(row) }, row_getParentRows: { fn: (row) => row_getParentRows(row) }, row_getUniqueValues: { fn: (row, columnId) => row_getUniqueValues(row, columnId) }, row_getValue: { fn: (row, columnId) => row_getValue(row, columnId) }, row_renderValue: { fn: (row, columnId) => row_renderValue(row, columnId) } }); }, constructTableAPIs: (table) => { assignTableAPIs("coreRowsFeature", table, { table_getRowsInDisplayOrder: { fn: () => table_getRowsInDisplayOrder(table), memoDeps: () => [ table.getPrePaginatedRowModel().rows, table.options.paginateExpandedRows, table.options.paginateExpandedRows === false ? table.atoms.expanded?.get() : void 0 ] }, table_getRowId: { fn: (originalRow, index, parent) => table_getRowId(originalRow, table, index, parent) }, table_getRow: { fn: (id, searchAll) => table_getRow(table, id, searchAll) }, table_getMaxSubRowDepth: { fn: () => table_getMaxSubRowDepth(table), memoDeps: () => [table.getCoreRowModel()] } }); } }; //#endregion export { coreRowsFeature };