@tanstack/table-core 9.0.0-alpha.0 → 9.0.0-alpha.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/aggregationFns.cjs +4 -8
- package/dist/cjs/aggregationFns.cjs.map +1 -1
- package/dist/cjs/core/cell.cjs +3 -3
- package/dist/cjs/core/cell.cjs.map +1 -1
- package/dist/cjs/core/cell.d.cts +1 -1
- package/dist/cjs/core/column.cjs +3 -3
- package/dist/cjs/core/column.cjs.map +1 -1
- package/dist/cjs/core/column.d.cts +1 -1
- package/dist/cjs/core/headers.cjs +5 -5
- package/dist/cjs/core/headers.cjs.map +1 -1
- package/dist/cjs/core/row.cjs +5 -6
- package/dist/cjs/core/row.cjs.map +1 -1
- package/dist/cjs/core/row.d.cts +1 -1
- package/dist/cjs/core/table.cjs +11 -7
- package/dist/cjs/core/table.cjs.map +1 -1
- package/dist/cjs/core/table.d.cts +9 -1
- package/dist/cjs/features/ColumnFaceting.cjs +1 -1
- package/dist/cjs/features/ColumnFaceting.cjs.map +1 -1
- package/dist/cjs/features/ColumnFiltering.cjs +6 -6
- package/dist/cjs/features/ColumnFiltering.cjs.map +1 -1
- package/dist/cjs/features/ColumnGrouping.cjs +8 -9
- package/dist/cjs/features/ColumnGrouping.cjs.map +1 -1
- package/dist/cjs/features/ColumnOrdering.cjs +4 -4
- package/dist/cjs/features/ColumnOrdering.cjs.map +1 -1
- package/dist/cjs/features/ColumnPinning.cjs +5 -5
- package/dist/cjs/features/ColumnPinning.cjs.map +1 -1
- package/dist/cjs/features/ColumnSizing.cjs +7 -8
- package/dist/cjs/features/ColumnSizing.cjs.map +1 -1
- package/dist/cjs/features/ColumnVisibility.cjs +5 -5
- package/dist/cjs/features/ColumnVisibility.cjs.map +1 -1
- package/dist/cjs/features/GlobalFaceting.cjs +1 -1
- package/dist/cjs/features/GlobalFaceting.cjs.map +1 -1
- package/dist/cjs/features/GlobalFiltering.cjs +4 -4
- package/dist/cjs/features/GlobalFiltering.cjs.map +1 -1
- package/dist/cjs/features/RowExpanding.cjs +6 -8
- package/dist/cjs/features/RowExpanding.cjs.map +1 -1
- package/dist/cjs/features/RowPagination.cjs +4 -5
- package/dist/cjs/features/RowPagination.cjs.map +1 -1
- package/dist/cjs/features/RowPinning.cjs +5 -6
- package/dist/cjs/features/RowPinning.cjs.map +1 -1
- package/dist/cjs/features/RowSelection.cjs +6 -8
- package/dist/cjs/features/RowSelection.cjs.map +1 -1
- package/dist/cjs/features/RowSorting.cjs +6 -7
- package/dist/cjs/features/RowSorting.cjs.map +1 -1
- package/dist/cjs/index.cjs +5 -4
- package/dist/cjs/index.cjs.map +1 -1
- package/dist/cjs/types.d.cts +8 -8
- package/dist/cjs/utils/filterRowsUtils.cjs +2 -2
- package/dist/cjs/utils/filterRowsUtils.cjs.map +1 -1
- package/dist/cjs/utils/getCoreRowModel.cjs +1 -1
- package/dist/cjs/utils/getCoreRowModel.cjs.map +1 -1
- package/dist/cjs/utils/getFacetedMinMaxValues.cjs +1 -2
- package/dist/cjs/utils/getFacetedMinMaxValues.cjs.map +1 -1
- package/dist/cjs/utils/getFacetedUniqueValues.cjs +1 -2
- package/dist/cjs/utils/getFacetedUniqueValues.cjs.map +1 -1
- package/dist/cjs/utils/getGroupedRowModel.cjs +1 -1
- package/dist/cjs/utils/getGroupedRowModel.cjs.map +1 -1
- package/dist/cjs/utils/getSortedRowModel.cjs +3 -6
- package/dist/cjs/utils/getSortedRowModel.cjs.map +1 -1
- package/dist/cjs/utils.cjs +2 -4
- package/dist/cjs/utils.cjs.map +1 -1
- package/dist/esm/aggregationFns.js +4 -8
- package/dist/esm/aggregationFns.js.map +1 -1
- package/dist/esm/core/cell.d.ts +1 -1
- package/dist/esm/core/cell.js +3 -3
- package/dist/esm/core/cell.js.map +1 -1
- package/dist/esm/core/column.d.ts +1 -1
- package/dist/esm/core/column.js +3 -3
- package/dist/esm/core/column.js.map +1 -1
- package/dist/esm/core/headers.js +5 -5
- package/dist/esm/core/headers.js.map +1 -1
- package/dist/esm/core/row.d.ts +1 -1
- package/dist/esm/core/row.js +6 -7
- package/dist/esm/core/row.js.map +1 -1
- package/dist/esm/core/table.d.ts +9 -1
- package/dist/esm/core/table.js +12 -8
- package/dist/esm/core/table.js.map +1 -1
- package/dist/esm/features/ColumnFaceting.js +1 -1
- package/dist/esm/features/ColumnFaceting.js.map +1 -1
- package/dist/esm/features/ColumnFiltering.js +6 -6
- package/dist/esm/features/ColumnFiltering.js.map +1 -1
- package/dist/esm/features/ColumnGrouping.js +8 -9
- package/dist/esm/features/ColumnGrouping.js.map +1 -1
- package/dist/esm/features/ColumnOrdering.js +4 -4
- package/dist/esm/features/ColumnOrdering.js.map +1 -1
- package/dist/esm/features/ColumnPinning.js +5 -5
- package/dist/esm/features/ColumnPinning.js.map +1 -1
- package/dist/esm/features/ColumnSizing.js +7 -8
- package/dist/esm/features/ColumnSizing.js.map +1 -1
- package/dist/esm/features/ColumnVisibility.js +5 -5
- package/dist/esm/features/ColumnVisibility.js.map +1 -1
- package/dist/esm/features/GlobalFaceting.js +1 -1
- package/dist/esm/features/GlobalFaceting.js.map +1 -1
- package/dist/esm/features/GlobalFiltering.js +4 -4
- package/dist/esm/features/GlobalFiltering.js.map +1 -1
- package/dist/esm/features/RowExpanding.js +6 -8
- package/dist/esm/features/RowExpanding.js.map +1 -1
- package/dist/esm/features/RowPagination.js +4 -5
- package/dist/esm/features/RowPagination.js.map +1 -1
- package/dist/esm/features/RowPinning.js +5 -6
- package/dist/esm/features/RowPinning.js.map +1 -1
- package/dist/esm/features/RowSelection.js +6 -8
- package/dist/esm/features/RowSelection.js.map +1 -1
- package/dist/esm/features/RowSorting.js +6 -7
- package/dist/esm/features/RowSorting.js.map +1 -1
- package/dist/esm/index.js +10 -9
- package/dist/esm/types.d.ts +8 -8
- package/dist/esm/utils/filterRowsUtils.js +3 -3
- package/dist/esm/utils/filterRowsUtils.js.map +1 -1
- package/dist/esm/utils/getCoreRowModel.js +2 -2
- package/dist/esm/utils/getCoreRowModel.js.map +1 -1
- package/dist/esm/utils/getFacetedMinMaxValues.js +1 -2
- package/dist/esm/utils/getFacetedMinMaxValues.js.map +1 -1
- package/dist/esm/utils/getFacetedUniqueValues.js +1 -2
- package/dist/esm/utils/getFacetedUniqueValues.js.map +1 -1
- package/dist/esm/utils/getGroupedRowModel.js +2 -2
- package/dist/esm/utils/getGroupedRowModel.js.map +1 -1
- package/dist/esm/utils/getSortedRowModel.js +3 -6
- package/dist/esm/utils/getSortedRowModel.js.map +1 -1
- package/dist/esm/utils.js +2 -4
- package/dist/esm/utils.js.map +1 -1
- package/package.json +1 -1
- package/src/core/cell.ts +2 -2
- package/src/core/column.ts +2 -2
- package/src/core/headers.ts +5 -5
- package/src/core/row.ts +4 -4
- package/src/core/table.ts +43 -7
- package/src/features/ColumnFaceting.ts +1 -1
- package/src/features/ColumnFiltering.ts +6 -6
- package/src/features/ColumnGrouping.ts +7 -7
- package/src/features/ColumnOrdering.ts +4 -4
- package/src/features/ColumnPinning.ts +5 -5
- package/src/features/ColumnSizing.ts +6 -6
- package/src/features/ColumnVisibility.ts +5 -5
- package/src/features/GlobalFaceting.ts +1 -1
- package/src/features/GlobalFiltering.ts +4 -4
- package/src/features/RowExpanding.ts +4 -4
- package/src/features/RowPagination.ts +3 -3
- package/src/features/RowPinning.ts +4 -4
- package/src/features/RowSelection.ts +4 -4
- package/src/features/RowSorting.ts +5 -5
- package/src/types.ts +8 -8
- package/src/utils/filterRowsUtils.ts +3 -3
- package/src/utils/getCoreRowModel.ts +2 -2
- package/src/utils/getGroupedRowModel.ts +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cell.js","sources":["../../../src/core/cell.ts"],"sourcesContent":["import { RowData, Cell, Column, Row, Table } from '../types'\nimport { Getter, getMemoOptions, memo } from '../utils'\n\nexport interface CellContext<TData extends RowData, TValue> {\n cell: Cell<TData, TValue>\n column: Column<TData, TValue>\n getValue: Getter<TValue>\n renderValue: Getter<TValue | null>\n row: Row<TData>\n table: Table<TData>\n}\n\nexport interface CoreCell<TData extends RowData, TValue> {\n /**\n * The associated Column object for the cell.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/cell#column)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/cells)\n */\n column: Column<TData, TValue>\n /**\n * Returns the rendering context (or props) for cell-based components like cells and aggregated cells. Use these props with your framework's `flexRender` utility to render these using the template of your choice:\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/cell#getcontext)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/cells)\n */\n getContext: () => CellContext<TData, TValue>\n /**\n * Returns the value for the cell, accessed via the associated column's accessor key or accessor function.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/cell#getvalue)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/cells)\n */\n getValue: CellContext<TData, TValue>['getValue']\n /**\n * The unique ID for the cell across the entire table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/cell#id)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/cells)\n */\n id: string\n /**\n * Renders the value for a cell the same as `getValue`, but will return the `renderFallbackValue` if no value is found.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/cell#rendervalue)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/cells)\n */\n renderValue: CellContext<TData, TValue>['renderValue']\n /**\n * The associated Row object for the cell.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/cell#row)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/cells)\n */\n row: Row<TData>\n}\n\nexport function
|
|
1
|
+
{"version":3,"file":"cell.js","sources":["../../../src/core/cell.ts"],"sourcesContent":["import { RowData, Cell, Column, Row, Table } from '../types'\nimport { Getter, getMemoOptions, memo } from '../utils'\n\nexport interface CellContext<TData extends RowData, TValue> {\n cell: Cell<TData, TValue>\n column: Column<TData, TValue>\n getValue: Getter<TValue>\n renderValue: Getter<TValue | null>\n row: Row<TData>\n table: Table<TData>\n}\n\nexport interface CoreCell<TData extends RowData, TValue> {\n /**\n * The associated Column object for the cell.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/cell#column)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/cells)\n */\n column: Column<TData, TValue>\n /**\n * Returns the rendering context (or props) for cell-based components like cells and aggregated cells. Use these props with your framework's `flexRender` utility to render these using the template of your choice:\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/cell#getcontext)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/cells)\n */\n getContext: () => CellContext<TData, TValue>\n /**\n * Returns the value for the cell, accessed via the associated column's accessor key or accessor function.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/cell#getvalue)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/cells)\n */\n getValue: CellContext<TData, TValue>['getValue']\n /**\n * The unique ID for the cell across the entire table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/cell#id)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/cells)\n */\n id: string\n /**\n * Renders the value for a cell the same as `getValue`, but will return the `renderFallbackValue` if no value is found.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/cell#rendervalue)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/cells)\n */\n renderValue: CellContext<TData, TValue>['renderValue']\n /**\n * The associated Row object for the cell.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/cell#row)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/cells)\n */\n row: Row<TData>\n}\n\nexport function _createCell<TData extends RowData, TValue>(\n table: Table<TData>,\n row: Row<TData>,\n column: Column<TData, TValue>,\n columnId: string\n): Cell<TData, TValue> {\n const getRenderValue = () =>\n cell.getValue() ?? table.options.renderFallbackValue\n\n const cell: CoreCell<TData, TValue> = {\n id: `${row.id}_${column.id}`,\n row,\n column,\n getValue: () => row.getValue(columnId),\n renderValue: getRenderValue,\n getContext: memo(\n () => [table, column, row, cell],\n (table, column, row, cell) => ({\n table,\n column,\n row,\n cell: cell as Cell<TData, TValue>,\n getValue: cell.getValue,\n renderValue: cell.renderValue,\n }),\n getMemoOptions(table.options, 'debugCells', 'cell.getContext')\n ),\n }\n\n table._features.forEach(feature => {\n feature._createCell?.(\n cell as Cell<TData, TValue>,\n column,\n row as Row<TData>,\n table\n )\n }, {})\n\n return cell as Cell<TData, TValue>\n}\n"],"names":["table","column","row","cell"],"mappings":";AAmDO,SAAS,YACd,OACA,KACA,QACA,UACqB;AACrB,QAAM,iBAAiB,MACrB,KAAK,SAAS,KAAK,MAAM,QAAQ;AAEnC,QAAM,OAAgC;AAAA,IACpC,IAAI,GAAG,IAAI,EAAE,IAAI,OAAO,EAAE;AAAA,IAC1B;AAAA,IACA;AAAA,IACA,UAAU,MAAM,IAAI,SAAS,QAAQ;AAAA,IACrC,aAAa;AAAA,IACb,YAAY;AAAA,MACV,MAAM,CAAC,OAAO,QAAQ,KAAK,IAAI;AAAA,MAC/B,CAACA,QAAOC,SAAQC,MAAKC,WAAU;AAAA,QAC7B,OAAAH;AAAAA,QACA,QAAAC;AAAAA,QACA,KAAAC;AAAAA,QACA,MAAMC;AAAAA,QACN,UAAUA,MAAK;AAAA,QACf,aAAaA,MAAK;AAAA,MAAA;AAAA,MAEpB,eAAe,MAAM,SAAS,cAAc,iBAAiB;AAAA,IAC/D;AAAA,EAAA;AAGI,QAAA,UAAU,QAAQ,CAAW,YAAA;;AACzB,kBAAA,gBAAA;AAAA;AAAA,MACN;AAAA,MACA;AAAA,MACA;AAAA,MACA;AAAA;AAAA,EAEJ,GAAG,CAAE,CAAA;AAEE,SAAA;AACT;"}
|
|
@@ -53,4 +53,4 @@ export interface CoreColumn<TData extends RowData, TValue> {
|
|
|
53
53
|
*/
|
|
54
54
|
parent?: Column<TData, TValue>;
|
|
55
55
|
}
|
|
56
|
-
export declare function
|
|
56
|
+
export declare function _createColumn<TData extends RowData, TValue>(table: Table<TData>, columnDef: ColumnDef<TData, TValue>, depth: number, parent?: Column<TData, TValue>): Column<TData, TValue>;
|
package/dist/esm/core/column.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { memo, getMemoOptions } from "../utils.js";
|
|
2
|
-
function
|
|
2
|
+
function _createColumn(table, columnDef, depth, parent) {
|
|
3
3
|
var _a;
|
|
4
4
|
const defaultColumn = table._getDefaultColumnDef();
|
|
5
5
|
const resolvedColumnDef = {
|
|
@@ -71,11 +71,11 @@ function createColumn(table, columnDef, depth, parent) {
|
|
|
71
71
|
)
|
|
72
72
|
};
|
|
73
73
|
for (const feature of table._features) {
|
|
74
|
-
(_a = feature.
|
|
74
|
+
(_a = feature._createColumn) == null ? void 0 : _a.call(feature, column, table);
|
|
75
75
|
}
|
|
76
76
|
return column;
|
|
77
77
|
}
|
|
78
78
|
export {
|
|
79
|
-
|
|
79
|
+
_createColumn
|
|
80
80
|
};
|
|
81
81
|
//# sourceMappingURL=column.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"column.js","sources":["../../../src/core/column.ts"],"sourcesContent":["import {\n Column,\n Table,\n AccessorFn,\n ColumnDef,\n RowData,\n ColumnDefResolved,\n} from '../types'\nimport { getMemoOptions, memo } from '../utils'\n\nexport interface CoreColumn<TData extends RowData, TValue> {\n /**\n * The resolved accessor function to use when extracting the value for the column from each row. Will only be defined if the column def has a valid accessor key or function defined.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/column#accessorfn)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-defs)\n */\n accessorFn?: AccessorFn<TData, TValue>\n /**\n * The original column def used to create the column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/column#columndef)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-defs)\n */\n columnDef: ColumnDef<TData, TValue>\n /**\n * The child column (if the column is a group column). Will be an empty array if the column is not a group column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/column#columns)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-defs)\n */\n columns: Column<TData, TValue>[]\n /**\n * The depth of the column (if grouped) relative to the root column def array.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/column#depth)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-defs)\n */\n depth: number\n /**\n * Returns the flattened array of this column and all child/grand-child columns for this column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/column#getflatcolumns)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-defs)\n */\n getFlatColumns: () => Column<TData, TValue>[]\n /**\n * Returns an array of all leaf-node columns for this column. If a column has no children, it is considered the only leaf-node column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/column#getleafcolumns)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-defs)\n */\n getLeafColumns: () => Column<TData, TValue>[]\n /**\n * The resolved unique identifier for the column resolved in this priority:\n - A manual `id` property from the column def\n - The accessor key from the column def\n - The header string from the column def\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/column#id)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-defs)\n */\n id: string\n /**\n * The parent column for this column. Will be undefined if this is a root column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/column#parent)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-defs)\n */\n parent?: Column<TData, TValue>\n}\n\nexport function
|
|
1
|
+
{"version":3,"file":"column.js","sources":["../../../src/core/column.ts"],"sourcesContent":["import {\n Column,\n Table,\n AccessorFn,\n ColumnDef,\n RowData,\n ColumnDefResolved,\n} from '../types'\nimport { getMemoOptions, memo } from '../utils'\n\nexport interface CoreColumn<TData extends RowData, TValue> {\n /**\n * The resolved accessor function to use when extracting the value for the column from each row. Will only be defined if the column def has a valid accessor key or function defined.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/column#accessorfn)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-defs)\n */\n accessorFn?: AccessorFn<TData, TValue>\n /**\n * The original column def used to create the column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/column#columndef)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-defs)\n */\n columnDef: ColumnDef<TData, TValue>\n /**\n * The child column (if the column is a group column). Will be an empty array if the column is not a group column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/column#columns)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-defs)\n */\n columns: Column<TData, TValue>[]\n /**\n * The depth of the column (if grouped) relative to the root column def array.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/column#depth)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-defs)\n */\n depth: number\n /**\n * Returns the flattened array of this column and all child/grand-child columns for this column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/column#getflatcolumns)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-defs)\n */\n getFlatColumns: () => Column<TData, TValue>[]\n /**\n * Returns an array of all leaf-node columns for this column. If a column has no children, it is considered the only leaf-node column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/column#getleafcolumns)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-defs)\n */\n getLeafColumns: () => Column<TData, TValue>[]\n /**\n * The resolved unique identifier for the column resolved in this priority:\n - A manual `id` property from the column def\n - The accessor key from the column def\n - The header string from the column def\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/column#id)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-defs)\n */\n id: string\n /**\n * The parent column for this column. Will be undefined if this is a root column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/column#parent)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/column-defs)\n */\n parent?: Column<TData, TValue>\n}\n\nexport function _createColumn<TData extends RowData, TValue>(\n table: Table<TData>,\n columnDef: ColumnDef<TData, TValue>,\n depth: number,\n parent?: Column<TData, TValue>\n): Column<TData, TValue> {\n const defaultColumn = table._getDefaultColumnDef()\n\n const resolvedColumnDef = {\n ...defaultColumn,\n ...columnDef,\n } as ColumnDefResolved<TData>\n\n const accessorKey = resolvedColumnDef.accessorKey\n\n let id =\n resolvedColumnDef.id ??\n (accessorKey ? accessorKey.replace('.', '_') : undefined) ??\n (typeof resolvedColumnDef.header === 'string'\n ? resolvedColumnDef.header\n : undefined)\n\n let accessorFn: AccessorFn<TData> | undefined\n\n if (resolvedColumnDef.accessorFn) {\n accessorFn = resolvedColumnDef.accessorFn\n } else if (accessorKey) {\n // Support deep accessor keys\n if (accessorKey.includes('.')) {\n accessorFn = (originalRow: TData) => {\n let result = originalRow as Record<string, any>\n\n for (const key of accessorKey.split('.')) {\n result = result?.[key]\n if (process.env.NODE_ENV !== 'production' && result === undefined) {\n console.warn(\n `\"${key}\" in deeply nested key \"${accessorKey}\" returned undefined.`\n )\n }\n }\n\n return result\n }\n } else {\n accessorFn = (originalRow: TData) =>\n (originalRow as any)[resolvedColumnDef.accessorKey]\n }\n }\n\n if (!id) {\n if (process.env.NODE_ENV !== 'production') {\n throw new Error(\n resolvedColumnDef.accessorFn\n ? `Columns require an id when using an accessorFn`\n : `Columns require an id when using a non-string header`\n )\n }\n throw new Error()\n }\n\n let column: CoreColumn<TData, any> = {\n id: `${String(id)}`,\n accessorFn,\n parent: parent as any,\n depth,\n columnDef: resolvedColumnDef as ColumnDef<TData, any>,\n columns: [],\n getFlatColumns: memo(\n () => [true],\n () => {\n return [\n column as Column<TData, TValue>,\n ...column.columns?.flatMap(d => d.getFlatColumns()),\n ]\n },\n getMemoOptions(table.options, 'debugColumns', 'column.getFlatColumns')\n ),\n getLeafColumns: memo(\n () => [table._getOrderColumnsFn()],\n orderColumns => {\n if (column.columns?.length) {\n let leafColumns = column.columns.flatMap(column =>\n column.getLeafColumns()\n )\n\n return orderColumns(leafColumns)\n }\n\n return [column as Column<TData, TValue>]\n },\n getMemoOptions(table.options, 'debugColumns', 'column.getLeafColumns')\n ),\n }\n\n for (const feature of table._features) {\n feature._createColumn?.(column as Column<TData, TValue>, table)\n }\n\n // Yes, we have to convert table to unknown, because we know more than the compiler here.\n return column as Column<TData, TValue>\n}\n"],"names":["_a","column"],"mappings":";AAgEO,SAAS,cACd,OACA,WACA,OACA,QACuB;;AACjB,QAAA,gBAAgB,MAAM;AAE5B,QAAM,oBAAoB;AAAA,IACxB,GAAG;AAAA,IACH,GAAG;AAAA,EAAA;AAGL,QAAM,cAAc,kBAAkB;AAEtC,MAAI,KACF,kBAAkB,OACjB,cAAc,YAAY,QAAQ,KAAK,GAAG,IAAI,YAC9C,OAAO,kBAAkB,WAAW,WACjC,kBAAkB,SAClB;AAEF,MAAA;AAEJ,MAAI,kBAAkB,YAAY;AAChC,iBAAa,kBAAkB;AAAA,aACtB,aAAa;AAElB,QAAA,YAAY,SAAS,GAAG,GAAG;AAC7B,mBAAa,CAAC,gBAAuB;AACnC,YAAI,SAAS;AAEb,mBAAW,OAAO,YAAY,MAAM,GAAG,GAAG;AACxC,mBAAS,iCAAS;AAClB,cAAI,QAAQ,IAAI,aAAa,gBAAgB,WAAW,QAAW;AACzD,oBAAA;AAAA,cACN,IAAI,GAAG,2BAA2B,WAAW;AAAA,YAAA;AAAA,UAEjD;AAAA,QACF;AAEO,eAAA;AAAA,MAAA;AAAA,IACT,OACK;AACL,mBAAa,CAAC,gBACX,YAAoB,kBAAkB,WAAW;AAAA,IACtD;AAAA,EACF;AAEA,MAAI,CAAC,IAAI;AACH,QAAA,QAAQ,IAAI,aAAa,cAAc;AACzC,YAAM,IAAI;AAAA,QACR,kBAAkB,aACd,mDACA;AAAA,MAAA;AAAA,IAER;AACA,UAAM,IAAI,MAAM;AAAA,EAClB;AAEA,MAAI,SAAiC;AAAA,IACnC,IAAI,GAAG,OAAO,EAAE,CAAC;AAAA,IACjB;AAAA,IACA;AAAA,IACA;AAAA,IACA,WAAW;AAAA,IACX,SAAS,CAAC;AAAA,IACV,gBAAgB;AAAA,MACd,MAAM,CAAC,IAAI;AAAA,MACX,MAAM;;AACG,eAAA;AAAA,UACL;AAAA,UACA,IAAGA,MAAA,OAAO,YAAP,gBAAAA,IAAgB,QAAQ,CAAK,MAAA,EAAE;QAAgB;AAAA,MAEtD;AAAA,MACA,eAAe,MAAM,SAAS,gBAAgB,uBAAuB;AAAA,IACvE;AAAA,IACA,gBAAgB;AAAA,MACd,MAAM,CAAC,MAAM,oBAAoB;AAAA,MACjC,CAAgB,iBAAA;;AACV,aAAAA,MAAA,OAAO,YAAP,gBAAAA,IAAgB,QAAQ;AACtB,cAAA,cAAc,OAAO,QAAQ;AAAA,YAAQ,CAAAC,YACvCA,QAAO,eAAe;AAAA,UAAA;AAGxB,iBAAO,aAAa,WAAW;AAAA,QACjC;AAEA,eAAO,CAAC,MAA+B;AAAA,MACzC;AAAA,MACA,eAAe,MAAM,SAAS,gBAAgB,uBAAuB;AAAA,IACvE;AAAA,EAAA;AAGS,aAAA,WAAW,MAAM,WAAW;AAC7B,kBAAA,kBAAA,iCAAgB,QAAiC;AAAA,EAC3D;AAGO,SAAA;AACT;"}
|
package/dist/esm/core/headers.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { memo, getMemoOptions } from "../utils.js";
|
|
2
2
|
const debug = "debugHeaders";
|
|
3
|
-
function
|
|
3
|
+
function _createHeader(table, column, options) {
|
|
4
4
|
const id = options.id ?? column.id;
|
|
5
5
|
let header = {
|
|
6
6
|
id,
|
|
@@ -32,12 +32,12 @@ function createHeader(table, column, options) {
|
|
|
32
32
|
};
|
|
33
33
|
table._features.forEach((feature) => {
|
|
34
34
|
var _a;
|
|
35
|
-
(_a = feature.
|
|
35
|
+
(_a = feature._createHeader) == null ? void 0 : _a.call(feature, header, table);
|
|
36
36
|
});
|
|
37
37
|
return header;
|
|
38
38
|
}
|
|
39
39
|
const Headers = {
|
|
40
|
-
|
|
40
|
+
_createTable: (table) => {
|
|
41
41
|
table.getHeaderGroups = memo(
|
|
42
42
|
() => [
|
|
43
43
|
table.getAllColumns(),
|
|
@@ -248,7 +248,7 @@ function buildHeaderGroups(allColumns, columnsToGroup, table, headerFamily) {
|
|
|
248
248
|
if (latestPendingParentHeader && (latestPendingParentHeader == null ? void 0 : latestPendingParentHeader.column) === column) {
|
|
249
249
|
latestPendingParentHeader.subHeaders.push(headerToGroup);
|
|
250
250
|
} else {
|
|
251
|
-
const header =
|
|
251
|
+
const header = _createHeader(table, column, {
|
|
252
252
|
id: [headerFamily, depth, column.id, headerToGroup == null ? void 0 : headerToGroup.id].filter(Boolean).join("_"),
|
|
253
253
|
isPlaceholder,
|
|
254
254
|
placeholderId: isPlaceholder ? `${pendingParentHeaders.filter((d) => d.column === column).length}` : void 0,
|
|
@@ -267,7 +267,7 @@ function buildHeaderGroups(allColumns, columnsToGroup, table, headerFamily) {
|
|
|
267
267
|
}
|
|
268
268
|
};
|
|
269
269
|
const bottomHeaders = columnsToGroup.map(
|
|
270
|
-
(column, index) =>
|
|
270
|
+
(column, index) => _createHeader(table, column, {
|
|
271
271
|
depth: maxDepth,
|
|
272
272
|
index
|
|
273
273
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"headers.js","sources":["../../../src/core/headers.ts"],"sourcesContent":["import {\n RowData,\n Column,\n Header,\n HeaderGroup,\n Table,\n TableFeature,\n} from '../types'\nimport { getMemoOptions, memo } from '../utils'\n\nconst debug = 'debugHeaders'\n\nexport interface CoreHeaderGroup<TData extends RowData> {\n depth: number\n headers: Header<TData, unknown>[]\n id: string\n}\n\nexport interface HeaderContext<TData, TValue> {\n /**\n * An instance of a column.\n */\n column: Column<TData, TValue>\n /**\n * An instance of a header.\n */\n header: Header<TData, TValue>\n /**\n * The table instance.\n */\n table: Table<TData>\n}\n\nexport interface CoreHeader<TData extends RowData, TValue> {\n /**\n * The col-span for the header.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/header#colspan)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n colSpan: number\n /**\n * The header's associated column object.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/header#column)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n column: Column<TData, TValue>\n /**\n * The depth of the header, zero-indexed based.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/header#depth)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n depth: number\n /**\n * Returns the rendering context (or props) for column-based components like headers, footers and filters.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/header#getcontext)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getContext: () => HeaderContext<TData, TValue>\n /**\n * Returns the leaf headers hierarchically nested under this header.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/header#getleafheaders)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getLeafHeaders: () => Header<TData, unknown>[]\n /**\n * The header's associated header group object.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/header#headergroup)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n headerGroup: HeaderGroup<TData>\n /**\n * The unique identifier for the header.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/header#id)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n id: string\n /**\n * The index for the header within the header group.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/header#index)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n index: number\n /**\n * A boolean denoting if the header is a placeholder header.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/header#isplaceholder)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n isPlaceholder: boolean\n /**\n * If the header is a placeholder header, this will be a unique header ID that does not conflict with any other headers across the table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/header#placeholderid)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n placeholderId?: string\n /**\n * The row-span for the header.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/header#rowspan)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n rowSpan: number\n /**\n * The header's hierarchical sub/child headers. Will be empty if the header's associated column is a leaf-column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/header#subheaders)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n subHeaders: Header<TData, TValue>[]\n}\n\nexport interface HeadersInstance<TData extends RowData> {\n /**\n * Returns all header groups for the table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getheadergroups)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getHeaderGroups: () => HeaderGroup<TData>[]\n /**\n * If pinning, returns the header groups for the left pinned columns.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getleftheadergroups)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getLeftHeaderGroups: () => HeaderGroup<TData>[]\n /**\n * If pinning, returns the header groups for columns that are not pinned.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getcenterheadergroups)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getCenterHeaderGroups: () => HeaderGroup<TData>[]\n /**\n * If pinning, returns the header groups for the right pinned columns.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getrightheadergroups)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getRightHeaderGroups: () => HeaderGroup<TData>[]\n\n /**\n * Returns the footer groups for the table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getfootergroups)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getFooterGroups: () => HeaderGroup<TData>[]\n /**\n * If pinning, returns the footer groups for the left pinned columns.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getleftfootergroups)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getLeftFooterGroups: () => HeaderGroup<TData>[]\n /**\n * If pinning, returns the footer groups for columns that are not pinned.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getcenterfootergroups)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getCenterFooterGroups: () => HeaderGroup<TData>[]\n /**\n * If pinning, returns the footer groups for the right pinned columns.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getrightfootergroups)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getRightFooterGroups: () => HeaderGroup<TData>[]\n\n /**\n * Returns headers for all columns in the table, including parent headers.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getflatheaders)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getFlatHeaders: () => Header<TData, unknown>[]\n /**\n * If pinning, returns headers for all left pinned columns in the table, including parent headers.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getleftflatheaders)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getLeftFlatHeaders: () => Header<TData, unknown>[]\n /**\n * If pinning, returns headers for all columns that are not pinned, including parent headers.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getcenterflatheaders)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getCenterFlatHeaders: () => Header<TData, unknown>[]\n /**\n * If pinning, returns headers for all right pinned columns in the table, including parent headers.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getrightflatheaders)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getRightFlatHeaders: () => Header<TData, unknown>[]\n\n /**\n * Returns headers for all leaf columns in the table, (not including parent headers).\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getleafheaders)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getLeafHeaders: () => Header<TData, unknown>[]\n /**\n * If pinning, returns headers for all left pinned leaf columns in the table, (not including parent headers).\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getleftleafheaders)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getLeftLeafHeaders: () => Header<TData, unknown>[]\n /**\n * If pinning, returns headers for all columns that are not pinned, (not including parent headers).\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getcenterleafheaders)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getCenterLeafHeaders: () => Header<TData, unknown>[]\n /**\n * If pinning, returns headers for all right pinned leaf columns in the table, (not including parent headers).\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getrightleafheaders)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getRightLeafHeaders: () => Header<TData, unknown>[]\n}\n\n//\n\nfunction createHeader<TData extends RowData, TValue>(\n table: Table<TData>,\n column: Column<TData, TValue>,\n options: {\n id?: string\n isPlaceholder?: boolean\n placeholderId?: string\n index: number\n depth: number\n }\n): Header<TData, TValue> {\n const id = options.id ?? column.id\n\n let header: CoreHeader<TData, TValue> = {\n id,\n column,\n index: options.index,\n isPlaceholder: !!options.isPlaceholder,\n placeholderId: options.placeholderId,\n depth: options.depth,\n subHeaders: [],\n colSpan: 0,\n rowSpan: 0,\n headerGroup: null!,\n getLeafHeaders: (): Header<TData, unknown>[] => {\n const leafHeaders: Header<TData, unknown>[] = []\n\n const recurseHeader = (h: CoreHeader<TData, any>) => {\n if (h.subHeaders && h.subHeaders.length) {\n h.subHeaders.map(recurseHeader)\n }\n leafHeaders.push(h as Header<TData, unknown>)\n }\n\n recurseHeader(header)\n\n return leafHeaders\n },\n getContext: () => ({\n table,\n header: header as Header<TData, TValue>,\n column,\n }),\n }\n\n table._features.forEach(feature => {\n feature.createHeader?.(header as Header<TData, TValue>, table)\n })\n\n return header as Header<TData, TValue>\n}\n\nexport const Headers: TableFeature = {\n createTable: <TData extends RowData>(table: Table<TData>): void => {\n // Header Groups\n\n table.getHeaderGroups = memo(\n () => [\n table.getAllColumns(),\n table.getVisibleLeafColumns(),\n table.getState().columnPinning.left,\n table.getState().columnPinning.right,\n ],\n (allColumns, leafColumns, left, right) => {\n const leftColumns =\n left\n ?.map(columnId => leafColumns.find(d => d.id === columnId)!)\n .filter(Boolean) ?? []\n\n const rightColumns =\n right\n ?.map(columnId => leafColumns.find(d => d.id === columnId)!)\n .filter(Boolean) ?? []\n\n const centerColumns = leafColumns.filter(\n column => !left?.includes(column.id) && !right?.includes(column.id)\n )\n\n const headerGroups = buildHeaderGroups(\n allColumns,\n [...leftColumns, ...centerColumns, ...rightColumns],\n table\n )\n\n return headerGroups\n },\n getMemoOptions(table.options, debug, 'getHeaderGroups')\n )\n\n table.getCenterHeaderGroups = memo(\n () => [\n table.getAllColumns(),\n table.getVisibleLeafColumns(),\n table.getState().columnPinning.left,\n table.getState().columnPinning.right,\n ],\n (allColumns, leafColumns, left, right) => {\n leafColumns = leafColumns.filter(\n column => !left?.includes(column.id) && !right?.includes(column.id)\n )\n return buildHeaderGroups(allColumns, leafColumns, table, 'center')\n },\n getMemoOptions(table.options, debug, 'getCenterHeaderGroups')\n )\n\n table.getLeftHeaderGroups = memo(\n () => [\n table.getAllColumns(),\n table.getVisibleLeafColumns(),\n table.getState().columnPinning.left,\n ],\n (allColumns, leafColumns, left) => {\n const orderedLeafColumns =\n left\n ?.map(columnId => leafColumns.find(d => d.id === columnId)!)\n .filter(Boolean) ?? []\n\n return buildHeaderGroups(allColumns, orderedLeafColumns, table, 'left')\n },\n getMemoOptions(table.options, debug, 'getLeftHeaderGroups')\n )\n\n table.getRightHeaderGroups = memo(\n () => [\n table.getAllColumns(),\n table.getVisibleLeafColumns(),\n table.getState().columnPinning.right,\n ],\n (allColumns, leafColumns, right) => {\n const orderedLeafColumns =\n right\n ?.map(columnId => leafColumns.find(d => d.id === columnId)!)\n .filter(Boolean) ?? []\n\n return buildHeaderGroups(allColumns, orderedLeafColumns, table, 'right')\n },\n getMemoOptions(table.options, debug, 'getRightHeaderGroups')\n )\n\n // Footer Groups\n\n table.getFooterGroups = memo(\n () => [table.getHeaderGroups()],\n headerGroups => {\n return [...headerGroups].reverse()\n },\n getMemoOptions(table.options, debug, 'getFooterGroups')\n )\n\n table.getLeftFooterGroups = memo(\n () => [table.getLeftHeaderGroups()],\n headerGroups => {\n return [...headerGroups].reverse()\n },\n getMemoOptions(table.options, debug, 'getLeftFooterGroups')\n )\n\n table.getCenterFooterGroups = memo(\n () => [table.getCenterHeaderGroups()],\n headerGroups => {\n return [...headerGroups].reverse()\n },\n getMemoOptions(table.options, debug, 'getCenterFooterGroups')\n )\n\n table.getRightFooterGroups = memo(\n () => [table.getRightHeaderGroups()],\n headerGroups => {\n return [...headerGroups].reverse()\n },\n getMemoOptions(table.options, debug, 'getRightFooterGroups')\n )\n\n // Flat Headers\n\n table.getFlatHeaders = memo(\n () => [table.getHeaderGroups()],\n headerGroups => {\n return headerGroups\n .map(headerGroup => {\n return headerGroup.headers\n })\n .flat()\n },\n getMemoOptions(table.options, debug, 'getFlatHeaders')\n )\n\n table.getLeftFlatHeaders = memo(\n () => [table.getLeftHeaderGroups()],\n left => {\n return left\n .map(headerGroup => {\n return headerGroup.headers\n })\n .flat()\n },\n getMemoOptions(table.options, debug, 'getLeftFlatHeaders')\n )\n\n table.getCenterFlatHeaders = memo(\n () => [table.getCenterHeaderGroups()],\n left => {\n return left\n .map(headerGroup => {\n return headerGroup.headers\n })\n .flat()\n },\n getMemoOptions(table.options, debug, 'getCenterFlatHeaders')\n )\n\n table.getRightFlatHeaders = memo(\n () => [table.getRightHeaderGroups()],\n left => {\n return left\n .map(headerGroup => {\n return headerGroup.headers\n })\n .flat()\n },\n getMemoOptions(table.options, debug, 'getRightFlatHeaders')\n )\n\n // Leaf Headers\n\n table.getCenterLeafHeaders = memo(\n () => [table.getCenterFlatHeaders()],\n flatHeaders => {\n return flatHeaders.filter(header => !header.subHeaders?.length)\n },\n getMemoOptions(table.options, debug, 'getCenterLeafHeaders')\n )\n\n table.getLeftLeafHeaders = memo(\n () => [table.getLeftFlatHeaders()],\n flatHeaders => {\n return flatHeaders.filter(header => !header.subHeaders?.length)\n },\n getMemoOptions(table.options, debug, 'getLeftLeafHeaders')\n )\n\n table.getRightLeafHeaders = memo(\n () => [table.getRightFlatHeaders()],\n flatHeaders => {\n return flatHeaders.filter(header => !header.subHeaders?.length)\n },\n getMemoOptions(table.options, debug, 'getRightLeafHeaders')\n )\n\n table.getLeafHeaders = memo(\n () => [\n table.getLeftHeaderGroups(),\n table.getCenterHeaderGroups(),\n table.getRightHeaderGroups(),\n ],\n (left, center, right) => {\n return [\n ...(left[0]?.headers ?? []),\n ...(center[0]?.headers ?? []),\n ...(right[0]?.headers ?? []),\n ]\n .map(header => {\n return header.getLeafHeaders()\n })\n .flat()\n },\n getMemoOptions(table.options, debug, 'getLeafHeaders')\n )\n },\n}\n\nexport function buildHeaderGroups<TData extends RowData>(\n allColumns: Column<TData, unknown>[],\n columnsToGroup: Column<TData, unknown>[],\n table: Table<TData>,\n headerFamily?: 'center' | 'left' | 'right'\n) {\n // Find the max depth of the columns:\n // build the leaf column row\n // build each buffer row going up\n // placeholder for non-existent level\n // real column for existing level\n\n let maxDepth = 0\n\n const findMaxDepth = (columns: Column<TData, unknown>[], depth = 1) => {\n maxDepth = Math.max(maxDepth, depth)\n\n columns\n .filter(column => column.getIsVisible())\n .forEach(column => {\n if (column.columns?.length) {\n findMaxDepth(column.columns, depth + 1)\n }\n }, 0)\n }\n\n findMaxDepth(allColumns)\n\n let headerGroups: HeaderGroup<TData>[] = []\n\n const createHeaderGroup = (\n headersToGroup: Header<TData, unknown>[],\n depth: number\n ) => {\n // The header group we are creating\n const headerGroup: HeaderGroup<TData> = {\n depth,\n id: [headerFamily, `${depth}`].filter(Boolean).join('_'),\n headers: [],\n }\n\n // The parent columns we're going to scan next\n const pendingParentHeaders: Header<TData, unknown>[] = []\n\n // Scan each column for parents\n headersToGroup.forEach(headerToGroup => {\n // What is the latest (last) parent column?\n\n const latestPendingParentHeader = [...pendingParentHeaders].reverse()[0]\n\n const isLeafHeader = headerToGroup.column.depth === headerGroup.depth\n\n let column: Column<TData, unknown>\n let isPlaceholder = false\n\n if (isLeafHeader && headerToGroup.column.parent) {\n // The parent header is new\n column = headerToGroup.column.parent\n } else {\n // The parent header is repeated\n column = headerToGroup.column\n isPlaceholder = true\n }\n\n if (\n latestPendingParentHeader &&\n latestPendingParentHeader?.column === column\n ) {\n // This column is repeated. Add it as a sub header to the next batch\n latestPendingParentHeader.subHeaders.push(headerToGroup)\n } else {\n // This is a new header. Let's create it\n const header = createHeader(table, column, {\n id: [headerFamily, depth, column.id, headerToGroup?.id]\n .filter(Boolean)\n .join('_'),\n isPlaceholder,\n placeholderId: isPlaceholder\n ? `${pendingParentHeaders.filter(d => d.column === column).length}`\n : undefined,\n depth,\n index: pendingParentHeaders.length,\n })\n\n // Add the headerToGroup as a subHeader of the new header\n header.subHeaders.push(headerToGroup)\n // Add the new header to the pendingParentHeaders to get grouped\n // in the next batch\n pendingParentHeaders.push(header)\n }\n\n headerGroup.headers.push(headerToGroup)\n headerToGroup.headerGroup = headerGroup\n })\n\n headerGroups.push(headerGroup)\n\n if (depth > 0) {\n createHeaderGroup(pendingParentHeaders, depth - 1)\n }\n }\n\n const bottomHeaders = columnsToGroup.map((column, index) =>\n createHeader(table, column, {\n depth: maxDepth,\n index,\n })\n )\n\n createHeaderGroup(bottomHeaders, maxDepth - 1)\n\n headerGroups.reverse()\n\n // headerGroups = headerGroups.filter(headerGroup => {\n // return !headerGroup.headers.every(header => header.isPlaceholder)\n // })\n\n const recurseHeadersForSpans = (\n headers: Header<TData, unknown>[]\n ): { colSpan: number; rowSpan: number }[] => {\n const filteredHeaders = headers.filter(header =>\n header.column.getIsVisible()\n )\n\n return filteredHeaders.map(header => {\n let colSpan = 0\n let rowSpan = 0\n let childRowSpans = [0]\n\n if (header.subHeaders && header.subHeaders.length) {\n childRowSpans = []\n\n recurseHeadersForSpans(header.subHeaders).forEach(\n ({ colSpan: childColSpan, rowSpan: childRowSpan }) => {\n colSpan += childColSpan\n childRowSpans.push(childRowSpan)\n }\n )\n } else {\n colSpan = 1\n }\n\n const minChildRowSpan = Math.min(...childRowSpans)\n rowSpan = rowSpan + minChildRowSpan\n\n header.colSpan = colSpan\n header.rowSpan = rowSpan\n\n return { colSpan, rowSpan }\n })\n }\n\n recurseHeadersForSpans(headerGroups[0]?.headers ?? [])\n\n return headerGroups\n}\n"],"names":["_a"],"mappings":";AAUA,MAAM,QAAQ;AA0Md,SAAS,aACP,OACA,QACA,SAOuB;AACjB,QAAA,KAAK,QAAQ,MAAM,OAAO;AAEhC,MAAI,SAAoC;AAAA,IACtC;AAAA,IACA;AAAA,IACA,OAAO,QAAQ;AAAA,IACf,eAAe,CAAC,CAAC,QAAQ;AAAA,IACzB,eAAe,QAAQ;AAAA,IACvB,OAAO,QAAQ;AAAA,IACf,YAAY,CAAC;AAAA,IACb,SAAS;AAAA,IACT,SAAS;AAAA,IACT,aAAa;AAAA,IACb,gBAAgB,MAAgC;AAC9C,YAAM,cAAwC,CAAA;AAExC,YAAA,gBAAgB,CAAC,MAA8B;AACnD,YAAI,EAAE,cAAc,EAAE,WAAW,QAAQ;AACrC,YAAA,WAAW,IAAI,aAAa;AAAA,QAChC;AACA,oBAAY,KAAK,CAA2B;AAAA,MAAA;AAG9C,oBAAc,MAAM;AAEb,aAAA;AAAA,IACT;AAAA,IACA,YAAY,OAAO;AAAA,MACjB;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,EACF;AAGI,QAAA,UAAU,QAAQ,CAAW,YAAA;;AACzB,kBAAA,iBAAA,iCAAe,QAAiC;AAAA,EAAK,CAC9D;AAEM,SAAA;AACT;AAEO,MAAM,UAAwB;AAAA,EACnC,aAAa,CAAwB,UAA8B;AAGjE,UAAM,kBAAkB;AAAA,MACtB,MAAM;AAAA,QACJ,MAAM,cAAc;AAAA,QACpB,MAAM,sBAAsB;AAAA,QAC5B,MAAM,WAAW,cAAc;AAAA,QAC/B,MAAM,WAAW,cAAc;AAAA,MACjC;AAAA,MACA,CAAC,YAAY,aAAa,MAAM,UAA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nD;AAAA,EAAA;AAGF,QAAM,gBAAgB,eAAe;AAAA,IAAI,CAAC,QAAQ,UAChD,aAAa,OAAO,QAAQ;AAAA,MAC1B,OAAO;AAAA,MACP;AAAA,IAAA,CACD;AAAA,EAAA;AAGe,oBAAA,eAAe,WAAW,CAAC;AAE7C,eAAa,QAAQ;AAMf,QAAA,yBAAyB,CAC7B,YAC2C;AAC3C,UAAM,kBAAkB,QAAQ;AAAA,MAAO,CAAA,WACrC,OAAO,OAAO,aAAa;AAAA,IAAA;AAGtB,WAAA,gBAAgB,IAAI,CAAU,WAAA;AACnC,UAAI,UAAU;AACd,UAAI,UAAU;AACV,UAAA,gBAAgB,CAAC,CAAC;AAEtB,UAAI,OAAO,cAAc,OAAO,WAAW,QAAQ;AACjD,wBAAgB,CAAA;AAEO,+BAAA,OAAO,UAAU,EAAE;AAAA,UACxC,CAAC,EAAE,SAAS,cAAc,SAAS,mBAAmB;AACzC,uBAAA;AACX,0BAAc,KAAK,YAAY;AAAA,UACjC;AAAA,QAAA;AAAA,MACF,OACK;AACK,kBAAA;AAAA,MACZ;AAEA,YAAM,kBAAkB,KAAK,IAAI,GAAG,aAAa;AACjD,gBAAU,UAAU;AAEpB,aAAO,UAAU;AACjB,aAAO,UAAU;AAEV,aAAA,EAAE,SAAS;IAAQ,CAC3B;AAAA,EAAA;AAGH,2BAAuB,kBAAa,CAAC,MAAd,mBAAiB,YAAW,CAAE,CAAA;AAE9C,SAAA;AACT;"}
|
|
1
|
+
{"version":3,"file":"headers.js","sources":["../../../src/core/headers.ts"],"sourcesContent":["import {\n RowData,\n Column,\n Header,\n HeaderGroup,\n Table,\n TableFeature,\n} from '../types'\nimport { getMemoOptions, memo } from '../utils'\n\nconst debug = 'debugHeaders'\n\nexport interface CoreHeaderGroup<TData extends RowData> {\n depth: number\n headers: Header<TData, unknown>[]\n id: string\n}\n\nexport interface HeaderContext<TData, TValue> {\n /**\n * An instance of a column.\n */\n column: Column<TData, TValue>\n /**\n * An instance of a header.\n */\n header: Header<TData, TValue>\n /**\n * The table instance.\n */\n table: Table<TData>\n}\n\nexport interface CoreHeader<TData extends RowData, TValue> {\n /**\n * The col-span for the header.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/header#colspan)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n colSpan: number\n /**\n * The header's associated column object.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/header#column)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n column: Column<TData, TValue>\n /**\n * The depth of the header, zero-indexed based.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/header#depth)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n depth: number\n /**\n * Returns the rendering context (or props) for column-based components like headers, footers and filters.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/header#getcontext)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getContext: () => HeaderContext<TData, TValue>\n /**\n * Returns the leaf headers hierarchically nested under this header.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/header#getleafheaders)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getLeafHeaders: () => Header<TData, unknown>[]\n /**\n * The header's associated header group object.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/header#headergroup)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n headerGroup: HeaderGroup<TData>\n /**\n * The unique identifier for the header.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/header#id)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n id: string\n /**\n * The index for the header within the header group.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/header#index)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n index: number\n /**\n * A boolean denoting if the header is a placeholder header.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/header#isplaceholder)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n isPlaceholder: boolean\n /**\n * If the header is a placeholder header, this will be a unique header ID that does not conflict with any other headers across the table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/header#placeholderid)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n placeholderId?: string\n /**\n * The row-span for the header.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/header#rowspan)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n rowSpan: number\n /**\n * The header's hierarchical sub/child headers. Will be empty if the header's associated column is a leaf-column.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/header#subheaders)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n subHeaders: Header<TData, TValue>[]\n}\n\nexport interface HeadersInstance<TData extends RowData> {\n /**\n * Returns all header groups for the table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getheadergroups)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getHeaderGroups: () => HeaderGroup<TData>[]\n /**\n * If pinning, returns the header groups for the left pinned columns.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getleftheadergroups)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getLeftHeaderGroups: () => HeaderGroup<TData>[]\n /**\n * If pinning, returns the header groups for columns that are not pinned.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getcenterheadergroups)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getCenterHeaderGroups: () => HeaderGroup<TData>[]\n /**\n * If pinning, returns the header groups for the right pinned columns.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getrightheadergroups)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getRightHeaderGroups: () => HeaderGroup<TData>[]\n\n /**\n * Returns the footer groups for the table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getfootergroups)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getFooterGroups: () => HeaderGroup<TData>[]\n /**\n * If pinning, returns the footer groups for the left pinned columns.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getleftfootergroups)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getLeftFooterGroups: () => HeaderGroup<TData>[]\n /**\n * If pinning, returns the footer groups for columns that are not pinned.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getcenterfootergroups)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getCenterFooterGroups: () => HeaderGroup<TData>[]\n /**\n * If pinning, returns the footer groups for the right pinned columns.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getrightfootergroups)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getRightFooterGroups: () => HeaderGroup<TData>[]\n\n /**\n * Returns headers for all columns in the table, including parent headers.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getflatheaders)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getFlatHeaders: () => Header<TData, unknown>[]\n /**\n * If pinning, returns headers for all left pinned columns in the table, including parent headers.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getleftflatheaders)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getLeftFlatHeaders: () => Header<TData, unknown>[]\n /**\n * If pinning, returns headers for all columns that are not pinned, including parent headers.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getcenterflatheaders)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getCenterFlatHeaders: () => Header<TData, unknown>[]\n /**\n * If pinning, returns headers for all right pinned columns in the table, including parent headers.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getrightflatheaders)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getRightFlatHeaders: () => Header<TData, unknown>[]\n\n /**\n * Returns headers for all leaf columns in the table, (not including parent headers).\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getleafheaders)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getLeafHeaders: () => Header<TData, unknown>[]\n /**\n * If pinning, returns headers for all left pinned leaf columns in the table, (not including parent headers).\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getleftleafheaders)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getLeftLeafHeaders: () => Header<TData, unknown>[]\n /**\n * If pinning, returns headers for all columns that are not pinned, (not including parent headers).\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getcenterleafheaders)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getCenterLeafHeaders: () => Header<TData, unknown>[]\n /**\n * If pinning, returns headers for all right pinned leaf columns in the table, (not including parent headers).\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/headers#getrightleafheaders)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/headers)\n */\n getRightLeafHeaders: () => Header<TData, unknown>[]\n}\n\n//\n\nfunction _createHeader<TData extends RowData, TValue>(\n table: Table<TData>,\n column: Column<TData, TValue>,\n options: {\n id?: string\n isPlaceholder?: boolean\n placeholderId?: string\n index: number\n depth: number\n }\n): Header<TData, TValue> {\n const id = options.id ?? column.id\n\n let header: CoreHeader<TData, TValue> = {\n id,\n column,\n index: options.index,\n isPlaceholder: !!options.isPlaceholder,\n placeholderId: options.placeholderId,\n depth: options.depth,\n subHeaders: [],\n colSpan: 0,\n rowSpan: 0,\n headerGroup: null!,\n getLeafHeaders: (): Header<TData, unknown>[] => {\n const leafHeaders: Header<TData, unknown>[] = []\n\n const recurseHeader = (h: CoreHeader<TData, any>) => {\n if (h.subHeaders && h.subHeaders.length) {\n h.subHeaders.map(recurseHeader)\n }\n leafHeaders.push(h as Header<TData, unknown>)\n }\n\n recurseHeader(header)\n\n return leafHeaders\n },\n getContext: () => ({\n table,\n header: header as Header<TData, TValue>,\n column,\n }),\n }\n\n table._features.forEach(feature => {\n feature._createHeader?.(header as Header<TData, TValue>, table)\n })\n\n return header as Header<TData, TValue>\n}\n\nexport const Headers: TableFeature = {\n _createTable: <TData extends RowData>(table: Table<TData>): void => {\n // Header Groups\n\n table.getHeaderGroups = memo(\n () => [\n table.getAllColumns(),\n table.getVisibleLeafColumns(),\n table.getState().columnPinning.left,\n table.getState().columnPinning.right,\n ],\n (allColumns, leafColumns, left, right) => {\n const leftColumns =\n left\n ?.map(columnId => leafColumns.find(d => d.id === columnId)!)\n .filter(Boolean) ?? []\n\n const rightColumns =\n right\n ?.map(columnId => leafColumns.find(d => d.id === columnId)!)\n .filter(Boolean) ?? []\n\n const centerColumns = leafColumns.filter(\n column => !left?.includes(column.id) && !right?.includes(column.id)\n )\n\n const headerGroups = buildHeaderGroups(\n allColumns,\n [...leftColumns, ...centerColumns, ...rightColumns],\n table\n )\n\n return headerGroups\n },\n getMemoOptions(table.options, debug, 'getHeaderGroups')\n )\n\n table.getCenterHeaderGroups = memo(\n () => [\n table.getAllColumns(),\n table.getVisibleLeafColumns(),\n table.getState().columnPinning.left,\n table.getState().columnPinning.right,\n ],\n (allColumns, leafColumns, left, right) => {\n leafColumns = leafColumns.filter(\n column => !left?.includes(column.id) && !right?.includes(column.id)\n )\n return buildHeaderGroups(allColumns, leafColumns, table, 'center')\n },\n getMemoOptions(table.options, debug, 'getCenterHeaderGroups')\n )\n\n table.getLeftHeaderGroups = memo(\n () => [\n table.getAllColumns(),\n table.getVisibleLeafColumns(),\n table.getState().columnPinning.left,\n ],\n (allColumns, leafColumns, left) => {\n const orderedLeafColumns =\n left\n ?.map(columnId => leafColumns.find(d => d.id === columnId)!)\n .filter(Boolean) ?? []\n\n return buildHeaderGroups(allColumns, orderedLeafColumns, table, 'left')\n },\n getMemoOptions(table.options, debug, 'getLeftHeaderGroups')\n )\n\n table.getRightHeaderGroups = memo(\n () => [\n table.getAllColumns(),\n table.getVisibleLeafColumns(),\n table.getState().columnPinning.right,\n ],\n (allColumns, leafColumns, right) => {\n const orderedLeafColumns =\n right\n ?.map(columnId => leafColumns.find(d => d.id === columnId)!)\n .filter(Boolean) ?? []\n\n return buildHeaderGroups(allColumns, orderedLeafColumns, table, 'right')\n },\n getMemoOptions(table.options, debug, 'getRightHeaderGroups')\n )\n\n // Footer Groups\n\n table.getFooterGroups = memo(\n () => [table.getHeaderGroups()],\n headerGroups => {\n return [...headerGroups].reverse()\n },\n getMemoOptions(table.options, debug, 'getFooterGroups')\n )\n\n table.getLeftFooterGroups = memo(\n () => [table.getLeftHeaderGroups()],\n headerGroups => {\n return [...headerGroups].reverse()\n },\n getMemoOptions(table.options, debug, 'getLeftFooterGroups')\n )\n\n table.getCenterFooterGroups = memo(\n () => [table.getCenterHeaderGroups()],\n headerGroups => {\n return [...headerGroups].reverse()\n },\n getMemoOptions(table.options, debug, 'getCenterFooterGroups')\n )\n\n table.getRightFooterGroups = memo(\n () => [table.getRightHeaderGroups()],\n headerGroups => {\n return [...headerGroups].reverse()\n },\n getMemoOptions(table.options, debug, 'getRightFooterGroups')\n )\n\n // Flat Headers\n\n table.getFlatHeaders = memo(\n () => [table.getHeaderGroups()],\n headerGroups => {\n return headerGroups\n .map(headerGroup => {\n return headerGroup.headers\n })\n .flat()\n },\n getMemoOptions(table.options, debug, 'getFlatHeaders')\n )\n\n table.getLeftFlatHeaders = memo(\n () => [table.getLeftHeaderGroups()],\n left => {\n return left\n .map(headerGroup => {\n return headerGroup.headers\n })\n .flat()\n },\n getMemoOptions(table.options, debug, 'getLeftFlatHeaders')\n )\n\n table.getCenterFlatHeaders = memo(\n () => [table.getCenterHeaderGroups()],\n left => {\n return left\n .map(headerGroup => {\n return headerGroup.headers\n })\n .flat()\n },\n getMemoOptions(table.options, debug, 'getCenterFlatHeaders')\n )\n\n table.getRightFlatHeaders = memo(\n () => [table.getRightHeaderGroups()],\n left => {\n return left\n .map(headerGroup => {\n return headerGroup.headers\n })\n .flat()\n },\n getMemoOptions(table.options, debug, 'getRightFlatHeaders')\n )\n\n // Leaf Headers\n\n table.getCenterLeafHeaders = memo(\n () => [table.getCenterFlatHeaders()],\n flatHeaders => {\n return flatHeaders.filter(header => !header.subHeaders?.length)\n },\n getMemoOptions(table.options, debug, 'getCenterLeafHeaders')\n )\n\n table.getLeftLeafHeaders = memo(\n () => [table.getLeftFlatHeaders()],\n flatHeaders => {\n return flatHeaders.filter(header => !header.subHeaders?.length)\n },\n getMemoOptions(table.options, debug, 'getLeftLeafHeaders')\n )\n\n table.getRightLeafHeaders = memo(\n () => [table.getRightFlatHeaders()],\n flatHeaders => {\n return flatHeaders.filter(header => !header.subHeaders?.length)\n },\n getMemoOptions(table.options, debug, 'getRightLeafHeaders')\n )\n\n table.getLeafHeaders = memo(\n () => [\n table.getLeftHeaderGroups(),\n table.getCenterHeaderGroups(),\n table.getRightHeaderGroups(),\n ],\n (left, center, right) => {\n return [\n ...(left[0]?.headers ?? []),\n ...(center[0]?.headers ?? []),\n ...(right[0]?.headers ?? []),\n ]\n .map(header => {\n return header.getLeafHeaders()\n })\n .flat()\n },\n getMemoOptions(table.options, debug, 'getLeafHeaders')\n )\n },\n}\n\nexport function buildHeaderGroups<TData extends RowData>(\n allColumns: Column<TData, unknown>[],\n columnsToGroup: Column<TData, unknown>[],\n table: Table<TData>,\n headerFamily?: 'center' | 'left' | 'right'\n) {\n // Find the max depth of the columns:\n // build the leaf column row\n // build each buffer row going up\n // placeholder for non-existent level\n // real column for existing level\n\n let maxDepth = 0\n\n const findMaxDepth = (columns: Column<TData, unknown>[], depth = 1) => {\n maxDepth = Math.max(maxDepth, depth)\n\n columns\n .filter(column => column.getIsVisible())\n .forEach(column => {\n if (column.columns?.length) {\n findMaxDepth(column.columns, depth + 1)\n }\n }, 0)\n }\n\n findMaxDepth(allColumns)\n\n let headerGroups: HeaderGroup<TData>[] = []\n\n const createHeaderGroup = (\n headersToGroup: Header<TData, unknown>[],\n depth: number\n ) => {\n // The header group we are creating\n const headerGroup: HeaderGroup<TData> = {\n depth,\n id: [headerFamily, `${depth}`].filter(Boolean).join('_'),\n headers: [],\n }\n\n // The parent columns we're going to scan next\n const pendingParentHeaders: Header<TData, unknown>[] = []\n\n // Scan each column for parents\n headersToGroup.forEach(headerToGroup => {\n // What is the latest (last) parent column?\n\n const latestPendingParentHeader = [...pendingParentHeaders].reverse()[0]\n\n const isLeafHeader = headerToGroup.column.depth === headerGroup.depth\n\n let column: Column<TData, unknown>\n let isPlaceholder = false\n\n if (isLeafHeader && headerToGroup.column.parent) {\n // The parent header is new\n column = headerToGroup.column.parent\n } else {\n // The parent header is repeated\n column = headerToGroup.column\n isPlaceholder = true\n }\n\n if (\n latestPendingParentHeader &&\n latestPendingParentHeader?.column === column\n ) {\n // This column is repeated. Add it as a sub header to the next batch\n latestPendingParentHeader.subHeaders.push(headerToGroup)\n } else {\n // This is a new header. Let's create it\n const header = _createHeader(table, column, {\n id: [headerFamily, depth, column.id, headerToGroup?.id]\n .filter(Boolean)\n .join('_'),\n isPlaceholder,\n placeholderId: isPlaceholder\n ? `${pendingParentHeaders.filter(d => d.column === column).length}`\n : undefined,\n depth,\n index: pendingParentHeaders.length,\n })\n\n // Add the headerToGroup as a subHeader of the new header\n header.subHeaders.push(headerToGroup)\n // Add the new header to the pendingParentHeaders to get grouped\n // in the next batch\n pendingParentHeaders.push(header)\n }\n\n headerGroup.headers.push(headerToGroup)\n headerToGroup.headerGroup = headerGroup\n })\n\n headerGroups.push(headerGroup)\n\n if (depth > 0) {\n createHeaderGroup(pendingParentHeaders, depth - 1)\n }\n }\n\n const bottomHeaders = columnsToGroup.map((column, index) =>\n _createHeader(table, column, {\n depth: maxDepth,\n index,\n })\n )\n\n createHeaderGroup(bottomHeaders, maxDepth - 1)\n\n headerGroups.reverse()\n\n // headerGroups = headerGroups.filter(headerGroup => {\n // return !headerGroup.headers.every(header => header.isPlaceholder)\n // })\n\n const recurseHeadersForSpans = (\n headers: Header<TData, unknown>[]\n ): { colSpan: number; rowSpan: number }[] => {\n const filteredHeaders = headers.filter(header =>\n header.column.getIsVisible()\n )\n\n return filteredHeaders.map(header => {\n let colSpan = 0\n let rowSpan = 0\n let childRowSpans = [0]\n\n if (header.subHeaders && header.subHeaders.length) {\n childRowSpans = []\n\n recurseHeadersForSpans(header.subHeaders).forEach(\n ({ colSpan: childColSpan, rowSpan: childRowSpan }) => {\n colSpan += childColSpan\n childRowSpans.push(childRowSpan)\n }\n )\n } else {\n colSpan = 1\n }\n\n const minChildRowSpan = Math.min(...childRowSpans)\n rowSpan = rowSpan + minChildRowSpan\n\n header.colSpan = colSpan\n header.rowSpan = rowSpan\n\n return { colSpan, rowSpan }\n })\n }\n\n recurseHeadersForSpans(headerGroups[0]?.headers ?? [])\n\n return headerGroups\n}\n"],"names":["_a"],"mappings":";AAUA,MAAM,QAAQ;AA0Md,SAAS,cACP,OACA,QACA,SAOuB;AACjB,QAAA,KAAK,QAAQ,MAAM,OAAO;AAEhC,MAAI,SAAoC;AAAA,IACtC;AAAA,IACA;AAAA,IACA,OAAO,QAAQ;AAAA,IACf,eAAe,CAAC,CAAC,QAAQ;AAAA,IACzB,eAAe,QAAQ;AAAA,IACvB,OAAO,QAAQ;AAAA,IACf,YAAY,CAAC;AAAA,IACb,SAAS;AAAA,IACT,SAAS;AAAA,IACT,aAAa;AAAA,IACb,gBAAgB,MAAgC;AAC9C,YAAM,cAAwC,CAAA;AAExC,YAAA,gBAAgB,CAAC,MAA8B;AACnD,YAAI,EAAE,cAAc,EAAE,WAAW,QAAQ;AACrC,YAAA,WAAW,IAAI,aAAa;AAAA,QAChC;AACA,oBAAY,KAAK,CAA2B;AAAA,MAAA;AAG9C,oBAAc,MAAM;AAEb,aAAA;AAAA,IACT;AAAA,IACA,YAAY,OAAO;AAAA,MACjB;AAAA,MACA;AAAA,MACA;AAAA,IAAA;AAAA,EACF;AAGI,QAAA,UAAU,QAAQ,CAAW,YAAA;;AACzB,kBAAA,kBAAA,iCAAgB,QAAiC;AAAA,EAA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 +89,4 @@ export interface CoreRow<TData extends RowData> {
|
|
|
89
89
|
*/
|
|
90
90
|
subRows: Row<TData>[];
|
|
91
91
|
}
|
|
92
|
-
export declare const
|
|
92
|
+
export declare const _createRow: <TData extends unknown>(table: Table<TData>, id: string, original: TData, rowIndex: number, depth: number, subRows?: Row<TData>[], parentId?: string) => Row<TData>;
|
package/dist/esm/core/row.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { flattenBy, memo, getMemoOptions } from "../utils.js";
|
|
2
|
-
import {
|
|
3
|
-
const
|
|
2
|
+
import { _createCell } from "./cell.js";
|
|
3
|
+
const _createRow = (table, id, original, rowIndex, depth, subRows, parentId) => {
|
|
4
4
|
var _a;
|
|
5
5
|
let row = {
|
|
6
6
|
id,
|
|
@@ -51,8 +51,7 @@ const createRow = (table, id, original, rowIndex, depth, subRows, parentId) => {
|
|
|
51
51
|
let currentRow = row;
|
|
52
52
|
while (true) {
|
|
53
53
|
const parentRow = currentRow.getParentRow();
|
|
54
|
-
if (!parentRow)
|
|
55
|
-
break;
|
|
54
|
+
if (!parentRow) break;
|
|
56
55
|
parentRows.push(parentRow);
|
|
57
56
|
currentRow = parentRow;
|
|
58
57
|
}
|
|
@@ -62,7 +61,7 @@ const createRow = (table, id, original, rowIndex, depth, subRows, parentId) => {
|
|
|
62
61
|
() => [table.getAllLeafColumns()],
|
|
63
62
|
(leafColumns) => {
|
|
64
63
|
return leafColumns.map((column) => {
|
|
65
|
-
return
|
|
64
|
+
return _createCell(table, row, column, column.id);
|
|
66
65
|
});
|
|
67
66
|
},
|
|
68
67
|
getMemoOptions(table.options, "debugRows", "getAllCells")
|
|
@@ -83,11 +82,11 @@ const createRow = (table, id, original, rowIndex, depth, subRows, parentId) => {
|
|
|
83
82
|
};
|
|
84
83
|
for (let i = 0; i < table._features.length; i++) {
|
|
85
84
|
const feature = table._features[i];
|
|
86
|
-
(_a = feature == null ? void 0 : feature.
|
|
85
|
+
(_a = feature == null ? void 0 : feature._createRow) == null ? void 0 : _a.call(feature, row, table);
|
|
87
86
|
}
|
|
88
87
|
return row;
|
|
89
88
|
};
|
|
90
89
|
export {
|
|
91
|
-
|
|
90
|
+
_createRow
|
|
92
91
|
};
|
|
93
92
|
//# sourceMappingURL=row.js.map
|
package/dist/esm/core/row.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"row.js","sources":["../../../src/core/row.ts"],"sourcesContent":["import { RowData, Cell, Row, Table } from '../types'\nimport { flattenBy, getMemoOptions, memo } from '../utils'\nimport {
|
|
1
|
+
{"version":3,"file":"row.js","sources":["../../../src/core/row.ts"],"sourcesContent":["import { RowData, Cell, Row, Table } from '../types'\nimport { flattenBy, getMemoOptions, memo } from '../utils'\nimport { _createCell } from './cell'\n\nexport interface CoreRow<TData extends RowData> {\n _getAllCellsByColumnId: () => Record<string, Cell<TData, unknown>>\n _uniqueValuesCache: Record<string, unknown>\n _valuesCache: Record<string, unknown>\n /**\n * The depth of the row (if nested or grouped) relative to the root row array.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#depth)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n depth: number\n /**\n * Returns all of the cells for the row.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#getallcells)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n getAllCells: () => Cell<TData, unknown>[]\n /**\n * Returns the leaf rows for the row, not including any parent rows.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#getleafrows)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n getLeafRows: () => Row<TData>[]\n /**\n * Returns the parent row for the row, if it exists.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#getparentrow)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n getParentRow: () => Row<TData> | undefined\n /**\n * Returns the parent rows for the row, all the way up to a root row.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#getparentrows)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n getParentRows: () => Row<TData>[]\n /**\n * Returns a unique array of values from the row for a given columnId.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#getuniquevalues)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n getUniqueValues: <TValue>(columnId: string) => TValue[]\n /**\n * Returns the value from the row for a given columnId.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#getvalue)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n getValue: <TValue>(columnId: string) => TValue\n /**\n * The resolved unique identifier for the row resolved via the `options.getRowId` option. Defaults to the row's index (or relative index if it is a subRow).\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#id)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n id: string\n /**\n * The index of the row within its parent array (or the root data array).\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#index)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n index: number\n /**\n * The original row object provided to the table. If the row is a grouped row, the original row object will be the first original in the group.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#original)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n original: TData\n /**\n * An array of the original subRows as returned by the `options.getSubRows` option.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#originalsubrows)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n originalSubRows?: TData[]\n /**\n * If nested, this row's parent row id.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#parentid)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n parentId?: string\n /**\n * Renders the value for the row in a given columnId the same as `getValue`, but will return the `renderFallbackValue` if no value is found.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#rendervalue)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n renderValue: <TValue>(columnId: string) => TValue\n /**\n * An array of subRows for the row as returned and created by the `options.getSubRows` option.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/core/row#subrows)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/rows)\n */\n subRows: Row<TData>[]\n}\n\nexport const _createRow = <TData extends RowData>(\n table: Table<TData>,\n id: string,\n original: TData,\n rowIndex: number,\n depth: number,\n subRows?: Row<TData>[],\n parentId?: string\n): Row<TData> => {\n let row: CoreRow<TData> = {\n id,\n index: rowIndex,\n original,\n depth,\n parentId,\n _valuesCache: {},\n _uniqueValuesCache: {},\n getValue: columnId => {\n if (row._valuesCache.hasOwnProperty(columnId)) {\n return row._valuesCache[columnId]\n }\n\n const column = table.getColumn(columnId)\n\n if (!column?.accessorFn) {\n return undefined\n }\n\n row._valuesCache[columnId] = column.accessorFn(\n row.original as TData,\n rowIndex\n )\n\n return row._valuesCache[columnId] as any\n },\n getUniqueValues: columnId => {\n if (row._uniqueValuesCache.hasOwnProperty(columnId)) {\n return row._uniqueValuesCache[columnId]\n }\n\n const column = table.getColumn(columnId)\n\n if (!column?.accessorFn) {\n return undefined\n }\n\n if (!column.columnDef.getUniqueValues) {\n row._uniqueValuesCache[columnId] = [row.getValue(columnId)]\n return row._uniqueValuesCache[columnId]\n }\n\n row._uniqueValuesCache[columnId] = column.columnDef.getUniqueValues(\n row.original as TData,\n rowIndex\n )\n\n return row._uniqueValuesCache[columnId] as any\n },\n renderValue: columnId =>\n row.getValue(columnId) ?? table.options.renderFallbackValue,\n subRows: subRows ?? [],\n getLeafRows: () => flattenBy(row.subRows, d => d.subRows),\n getParentRow: () =>\n row.parentId ? table.getRow(row.parentId, true) : undefined,\n getParentRows: () => {\n let parentRows: Row<TData>[] = []\n let currentRow = row\n while (true) {\n const parentRow = currentRow.getParentRow()\n if (!parentRow) break\n parentRows.push(parentRow)\n currentRow = parentRow\n }\n return parentRows.reverse()\n },\n getAllCells: memo(\n () => [table.getAllLeafColumns()],\n leafColumns => {\n return leafColumns.map(column => {\n return _createCell(table, row as Row<TData>, column, column.id)\n })\n },\n getMemoOptions(table.options, 'debugRows', 'getAllCells')\n ),\n\n _getAllCellsByColumnId: memo(\n () => [row.getAllCells()],\n allCells => {\n return allCells.reduce(\n (acc, cell) => {\n acc[cell.column.id] = cell\n return acc\n },\n {} as Record<string, Cell<TData, unknown>>\n )\n },\n getMemoOptions(table.options, 'debugRows', 'getAllCellsByColumnId')\n ),\n }\n\n for (let i = 0; i < table._features.length; i++) {\n const feature = table._features[i]\n feature?._createRow?.(row as Row<TData>, table)\n }\n\n return row as Row<TData>\n}\n"],"names":[],"mappings":";;AA8Fa,MAAA,aAAa,CACxB,OACA,IACA,UACA,UACA,OACA,SACA,aACe;;AACf,MAAI,MAAsB;AAAA,IACxB;AAAA,IACA,OAAO;AAAA,IACP;AAAA,IACA;AAAA,IACA;AAAA,IACA,cAAc,CAAC;AAAA,IACf,oBAAoB,CAAC;AAAA,IACrB,UAAU,CAAY,aAAA;AACpB,UAAI,IAAI,aAAa,eAAe,QAAQ,GAAG;AACtC,eAAA,IAAI,aAAa,QAAQ;AAAA,MAClC;AAEM,YAAA,SAAS,MAAM,UAAU,QAAQ;AAEnC,UAAA,EAAC,iCAAQ,aAAY;AAChB,eAAA;AAAA,MACT;AAEI,UAAA,aAAa,QAAQ,IAAI,OAAO;AAAA,QAClC,IAAI;AAAA,QACJ;AAAA,MAAA;AAGK,aAAA,IAAI,aAAa,QAAQ;AAAA,IAClC;AAAA,IACA,iBAAiB,CAAY,aAAA;AAC3B,UAAI,IAAI,mBAAmB,eAAe,QAAQ,GAAG;AAC5C,eAAA,IAAI,mBAAmB,QAAQ;AAAA,MACxC;AAEM,YAAA,SAAS,MAAM,UAAU,QAAQ;AAEnC,UAAA,EAAC,iCAAQ,aAAY;AAChB,eAAA;AAAA,MACT;AAEI,UAAA,CAAC,OAAO,UAAU,iBAAiB;AACrC,YAAI,mBAAmB,QAAQ,IAAI,CAAC,IAAI,SAAS,QAAQ,C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,UAAA,UAAU,MAAM,UAAU,CAAC;AACxB,6CAAA,eAAA,iCAAa,KAAmB;AAAA,EAC3C;AAEO,SAAA;AACT;"}
|
package/dist/esm/core/table.d.ts
CHANGED
|
@@ -131,6 +131,14 @@ export interface CoreOptions<TData extends RowData> {
|
|
|
131
131
|
*/
|
|
132
132
|
state: Partial<TableState>;
|
|
133
133
|
}
|
|
134
|
+
export declare function tableOptions<TData extends RowData = any>(options: Omit<TableOptions<TData>, 'columns'>): Omit<TableOptions<TData>, 'columns'>;
|
|
135
|
+
export declare function tableOptions<TData extends RowData = any>(options: Omit<TableOptions<TData>, 'data'>): Omit<TableOptions<TData>, 'data'>;
|
|
136
|
+
export declare function tableOptions<TData extends RowData = any>(options: Omit<TableOptions<TData>, 'getCoreRowModel'>): Omit<TableOptions<TData>, 'getCoreRowModel'>;
|
|
137
|
+
export declare function tableOptions<TData extends RowData = any>(options: Omit<TableOptions<TData>, 'data' | 'columns'>): Omit<TableOptions<TData>, 'data' | 'columns'>;
|
|
138
|
+
export declare function tableOptions<TData extends RowData = any>(options: Omit<TableOptions<TData>, 'getCoreRowModel' | 'columns'>): Omit<TableOptions<TData>, 'getCoreRowModel' | 'columns'>;
|
|
139
|
+
export declare function tableOptions<TData extends RowData = any>(options: Omit<TableOptions<TData>, 'data' | 'getCoreRowModel'>): Omit<TableOptions<TData>, 'data' | 'getCoreRowModel'>;
|
|
140
|
+
export declare function tableOptions<TData extends RowData = any>(options: Omit<TableOptions<TData>, 'data' | 'columns' | 'getCoreRowModel'>): Omit<TableOptions<TData>, 'data' | 'columns' | 'getCoreRowModel'>;
|
|
141
|
+
export declare function tableOptions<TData extends RowData = any>(options: TableOptions<TData>): TableOptions<TData>;
|
|
134
142
|
export interface CoreInstance<TData extends RowData> {
|
|
135
143
|
_features: readonly TableFeature[];
|
|
136
144
|
_getAllFlatColumnsById: () => Record<string, Column<TData, unknown>>;
|
|
@@ -218,4 +226,4 @@ export interface CoreInstance<TData extends RowData> {
|
|
|
218
226
|
*/
|
|
219
227
|
setState: (updater: Updater<TableState>) => void;
|
|
220
228
|
}
|
|
221
|
-
export declare function
|
|
229
|
+
export declare function _createTable<TData extends RowData>(options: TableOptionsResolved<TData>): Table<TData>;
|
package/dist/esm/core/table.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { functionalUpdate, memo, getMemoOptions } from "../utils.js";
|
|
2
|
-
import {
|
|
2
|
+
import { _createColumn } from "./column.js";
|
|
3
3
|
import { Headers } from "./headers.js";
|
|
4
4
|
import { ColumnFaceting } from "../features/ColumnFaceting.js";
|
|
5
5
|
import { ColumnFiltering } from "../features/ColumnFiltering.js";
|
|
@@ -35,7 +35,10 @@ const builtInFeatures = [
|
|
|
35
35
|
RowSelection,
|
|
36
36
|
ColumnSizing
|
|
37
37
|
];
|
|
38
|
-
function
|
|
38
|
+
function tableOptions(options) {
|
|
39
|
+
return options;
|
|
40
|
+
}
|
|
41
|
+
function _createTable(options) {
|
|
39
42
|
var _a;
|
|
40
43
|
if (process.env.NODE_ENV !== "production" && (options.debugAll || options.debugTable)) {
|
|
41
44
|
console.info("Creating Table Instance...");
|
|
@@ -44,7 +47,7 @@ function createTable(options) {
|
|
|
44
47
|
let table = { _features };
|
|
45
48
|
const defaultOptions = table._features.reduce((obj, feature) => {
|
|
46
49
|
var _a2;
|
|
47
|
-
return Object.assign(obj, (_a2 = feature.
|
|
50
|
+
return Object.assign(obj, (_a2 = feature._getDefaultOptions) == null ? void 0 : _a2.call(feature, table));
|
|
48
51
|
}, {});
|
|
49
52
|
const mergeOptions = (options2) => {
|
|
50
53
|
if (table.options.mergeOptions) {
|
|
@@ -62,7 +65,7 @@ function createTable(options) {
|
|
|
62
65
|
};
|
|
63
66
|
table._features.forEach((feature) => {
|
|
64
67
|
var _a2;
|
|
65
|
-
initialState = ((_a2 = feature.
|
|
68
|
+
initialState = ((_a2 = feature._getInitialState) == null ? void 0 : _a2.call(feature, initialState)) ?? initialState;
|
|
66
69
|
});
|
|
67
70
|
const queued = [];
|
|
68
71
|
let queuedTimeout = false;
|
|
@@ -154,7 +157,7 @@ function createTable(options) {
|
|
|
154
157
|
},
|
|
155
158
|
...table._features.reduce((obj, feature) => {
|
|
156
159
|
var _a2;
|
|
157
|
-
return Object.assign(obj, (_a2 = feature.
|
|
160
|
+
return Object.assign(obj, (_a2 = feature._getDefaultColumnDef) == null ? void 0 : _a2.call(feature));
|
|
158
161
|
}, {}),
|
|
159
162
|
...defaultColumn
|
|
160
163
|
};
|
|
@@ -167,7 +170,7 @@ function createTable(options) {
|
|
|
167
170
|
(columnDefs) => {
|
|
168
171
|
const recurseColumns = (columnDefs2, parent, depth = 0) => {
|
|
169
172
|
return columnDefs2.map((columnDef) => {
|
|
170
|
-
const column =
|
|
173
|
+
const column = _createColumn(table, columnDef, depth, parent);
|
|
171
174
|
const groupingColumnDef = columnDef;
|
|
172
175
|
column.columns = groupingColumnDef.columns ? recurseColumns(groupingColumnDef.columns, column, depth + 1) : [];
|
|
173
176
|
return column;
|
|
@@ -218,11 +221,12 @@ function createTable(options) {
|
|
|
218
221
|
Object.assign(table, coreInstance);
|
|
219
222
|
for (let index = 0; index < table._features.length; index++) {
|
|
220
223
|
const feature = table._features[index];
|
|
221
|
-
(_a = feature == null ? void 0 : feature.
|
|
224
|
+
(_a = feature == null ? void 0 : feature._createTable) == null ? void 0 : _a.call(feature, table);
|
|
222
225
|
}
|
|
223
226
|
return table;
|
|
224
227
|
}
|
|
225
228
|
export {
|
|
226
|
-
|
|
229
|
+
_createTable,
|
|
230
|
+
tableOptions
|
|
227
231
|
};
|
|
228
232
|
//# sourceMappingURL=table.js.map
|