@tanstack/table-core 9.0.0-alpha.0 → 9.0.0-alpha.10
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 +31 -32
- package/dist/cjs/features/RowPinning.cjs.map +1 -1
- package/dist/cjs/features/RowPinning.d.cts +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/filterFns.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.d.ts +1 -1
- package/dist/esm/features/RowPinning.js +31 -32
- 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/filterFns.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 +39 -35
- package/src/features/RowSelection.ts +4 -4
- package/src/features/RowSorting.ts +5 -5
- package/src/filterFns.ts +2 -2
- 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
- package/src/utils/getSortedRowModel.ts +2 -2
- package/src/utils.ts +6 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getGroupedRowModel.cjs","sources":["../../../src/utils/getGroupedRowModel.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"getGroupedRowModel.cjs","sources":["../../../src/utils/getGroupedRowModel.ts"],"sourcesContent":["import { _createRow } from '../core/row'\nimport { Table, Row, RowModel, RowData } from '../types'\nimport { flattenBy, getMemoOptions, memo } from '../utils'\n\nexport function getGroupedRowModel<TData extends RowData>(): (\n table: Table<TData>\n) => () => RowModel<TData> {\n return table =>\n memo(\n () => [table.getState().grouping, table.getPreGroupedRowModel()],\n (grouping, rowModel) => {\n if (!rowModel.rows.length || !grouping.length) {\n return rowModel\n }\n\n // Filter the grouping list down to columns that exist\n const existingGrouping = grouping.filter(columnId =>\n table.getColumn(columnId)\n )\n\n const groupedFlatRows: Row<TData>[] = []\n const groupedRowsById: Record<string, Row<TData>> = {}\n // const onlyGroupedFlatRows: Row[] = [];\n // const onlyGroupedRowsById: Record<RowId, Row> = {};\n // const nonGroupedFlatRows: Row[] = [];\n // const nonGroupedRowsById: Record<RowId, Row> = {};\n\n // Recursively group the data\n const groupUpRecursively = (\n rows: Row<TData>[],\n depth = 0,\n parentId?: string\n ) => {\n // Grouping depth has been been met\n // Stop grouping and simply rewrite thd depth and row relationships\n if (depth >= existingGrouping.length) {\n return rows.map(row => {\n row.depth = depth\n\n groupedFlatRows.push(row)\n groupedRowsById[row.id] = row\n\n if (row.subRows) {\n row.subRows = groupUpRecursively(row.subRows, depth + 1, row.id)\n }\n\n return row\n })\n }\n\n const columnId: string = existingGrouping[depth]!\n\n // Group the rows together for this level\n const rowGroupsMap = groupBy(rows, columnId)\n\n // Peform aggregations for each group\n const aggregatedGroupedRows = Array.from(rowGroupsMap.entries()).map(\n ([groupingValue, groupedRows], index) => {\n let id = `${columnId}:${groupingValue}`\n id = parentId ? `${parentId}>${id}` : id\n\n // First, Recurse to group sub rows before aggregation\n const subRows = groupUpRecursively(groupedRows, depth + 1, id)\n\n // Flatten the leaf rows of the rows in this group\n const leafRows = depth\n ? flattenBy(groupedRows, row => row.subRows)\n : groupedRows\n\n const row = _createRow(\n table,\n id,\n leafRows[0]!.original,\n index,\n depth,\n undefined,\n parentId\n )\n\n Object.assign(row, {\n groupingColumnId: columnId,\n groupingValue,\n subRows,\n leafRows,\n getValue: (columnId: string) => {\n // Don't aggregate columns that are in the grouping\n if (existingGrouping.includes(columnId)) {\n if (row._valuesCache.hasOwnProperty(columnId)) {\n return row._valuesCache[columnId]\n }\n\n if (groupedRows[0]) {\n row._valuesCache[columnId] =\n groupedRows[0].getValue(columnId) ?? undefined\n }\n\n return row._valuesCache[columnId]\n }\n\n if (row._groupingValuesCache.hasOwnProperty(columnId)) {\n return row._groupingValuesCache[columnId]\n }\n\n // Aggregate the values\n const column = table.getColumn(columnId)\n const aggregateFn = column?.getAggregationFn()\n\n if (aggregateFn) {\n row._groupingValuesCache[columnId] = aggregateFn(\n columnId,\n leafRows,\n groupedRows\n )\n\n return row._groupingValuesCache[columnId]\n }\n },\n })\n\n subRows.forEach(subRow => {\n groupedFlatRows.push(subRow)\n groupedRowsById[subRow.id] = subRow\n // if (subRow.getIsGrouped?.()) {\n // onlyGroupedFlatRows.push(subRow);\n // onlyGroupedRowsById[subRow.id] = subRow;\n // } else {\n // nonGroupedFlatRows.push(subRow);\n // nonGroupedRowsById[subRow.id] = subRow;\n // }\n })\n\n return row\n }\n )\n\n return aggregatedGroupedRows\n }\n\n const groupedRows = groupUpRecursively(rowModel.rows, 0)\n\n groupedRows.forEach(subRow => {\n groupedFlatRows.push(subRow)\n groupedRowsById[subRow.id] = subRow\n // if (subRow.getIsGrouped?.()) {\n // onlyGroupedFlatRows.push(subRow);\n // onlyGroupedRowsById[subRow.id] = subRow;\n // } else {\n // nonGroupedFlatRows.push(subRow);\n // nonGroupedRowsById[subRow.id] = subRow;\n // }\n })\n\n return {\n rows: groupedRows,\n flatRows: groupedFlatRows,\n rowsById: groupedRowsById,\n }\n },\n getMemoOptions(table.options, 'debugTable', 'getGroupedRowModel', () => {\n table._queue(() => {\n table._autoResetExpanded()\n table._autoResetPageIndex()\n })\n })\n )\n}\n\nfunction groupBy<TData extends RowData>(rows: Row<TData>[], columnId: string) {\n const groupMap = new Map<any, Row<TData>[]>()\n\n return rows.reduce((map, row) => {\n const resKey = `${row.getGroupingValue(columnId)}`\n const previous = map.get(resKey)\n if (!previous) {\n map.set(resKey, [row])\n } else {\n previous.push(row)\n }\n return map\n }, groupMap)\n}\n"],"names":["memo","row","groupedRows","flattenBy","_createRow","columnId","getMemoOptions"],"mappings":";;;;AAIO,SAAS,qBAEW;AACzB,SAAO,CACL,UAAAA,MAAA;AAAA,IACE,MAAM,CAAC,MAAM,SAAA,EAAW,UAAU,MAAM,uBAAuB;AAAA,IAC/D,CAAC,UAAU,aAAa;AACtB,UAAI,CAAC,SAAS,KAAK,UAAU,CAAC,SAAS,QAAQ;AACtC,eAAA;AAAA,MACT;AAGA,YAAM,mBAAmB,SAAS;AAAA,QAAO,CAAA,aACvC,MAAM,UAAU,QAAQ;AAAA,MAAA;AAG1B,YAAM,kBAAgC,CAAA;AACtC,YAAM,kBAA8C,CAAA;AAOpD,YAAM,qBAAqB,CACzB,MACA,QAAQ,GACR,aACG;AAGC,YAAA,SAAS,iBAAiB,QAAQ;AAC7B,iBAAA,KAAK,IAAI,CAAOC,SAAA;AACrB,YAAAA,KAAI,QAAQ;AAEZ,4BAAgB,KAAKA,IAAG;AACR,4BAAAA,KAAI,EAAE,IAAIA;AAE1B,gBAAIA,KAAI,SAAS;AACf,cAAAA,KAAI,UAAU,mBAAmBA,KAAI,SAAS,QAAQ,GAAGA,KAAI,EAAE;AAAA,YACjE;AAEO,mBAAAA;AAAA,UAAA,CACR;AAAA,QACH;AAEM,cAAA,WAAmB,iBAAiB,KAAK;AAGzC,cAAA,eAAe,QAAQ,MAAM,QAAQ;AAG3C,cAAM,wBAAwB,MAAM,KAAK,aAAa,QAAS,CAAA,EAAE;AAAA,UAC/D,CAAC,CAAC,eAAeC,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BAAA,OAAO,EAAE,IAAI;AAAA,YAAA,CAQ9B;AAEM,mBAAAJ;AAAAA,UACT;AAAA,QAAA;AAGK,eAAA;AAAA,MAAA;AAGT,YAAM,cAAc,mBAAmB,SAAS,MAAM,CAAC;AAEvD,kBAAY,QAAQ,CAAU,WAAA;AAC5B,wBAAgB,KAAK,MAAM;AACX,wBAAA,OAAO,EAAE,IAAI;AAAA,MAAA,CAQ9B;AAEM,aAAA;AAAA,QACL,MAAM;AAAA,QACN,UAAU;AAAA,QACV,UAAU;AAAA,MAAA;AAAA,IAEd;AAAA,IACAK,MAAAA,eAAe,MAAM,SAAS,cAAc,sBAAsB,MAAM;AACtE,YAAM,OAAO,MAAM;AACjB,cAAM,mBAAmB;AACzB,cAAM,oBAAoB;AAAA,MAAA,CAC3B;AAAA,IAAA,CACF;AAAA,EAAA;AAEP;AAEA,SAAS,QAA+B,MAAoB,UAAkB;AACtE,QAAA,+BAAe;AAErB,SAAO,KAAK,OAAO,CAAC,KAAKL,SAAQ;AAC/B,UAAM,SAAS,GAAGA,KAAI,iBAAiB,QAAQ,CAAC;AAC1C,UAAA,WAAW,IAAI,IAAI,MAAM;AAC/B,QAAI,CAAC,UAAU;AACb,UAAI,IAAI,QAAQ,CAACA,IAAG,CAAC;AAAA,IAAA,OAChB;AACL,eAAS,KAAKA,IAAG;AAAA,IACnB;AACO,WAAA;AAAA,KACN,QAAQ;AACb;;"}
|
|
@@ -19,8 +19,7 @@ function getSortedRowModel() {
|
|
|
19
19
|
const columnInfoById = {};
|
|
20
20
|
availableSorting.forEach((sortEntry) => {
|
|
21
21
|
const column = table.getColumn(sortEntry.id);
|
|
22
|
-
if (!column)
|
|
23
|
-
return;
|
|
22
|
+
if (!column) return;
|
|
24
23
|
columnInfoById[sortEntry.id] = {
|
|
25
24
|
sortUndefined: column.columnDef.sortUndefined,
|
|
26
25
|
invertSorting: column.columnDef.invertSorting,
|
|
@@ -42,10 +41,8 @@ function getSortedRowModel() {
|
|
|
42
41
|
const aUndefined = aValue === void 0;
|
|
43
42
|
const bUndefined = bValue === void 0;
|
|
44
43
|
if (aUndefined || bUndefined) {
|
|
45
|
-
if (sortUndefined === "first")
|
|
46
|
-
|
|
47
|
-
if (sortUndefined === "last")
|
|
48
|
-
return aUndefined ? 1 : -1;
|
|
44
|
+
if (sortUndefined === "first") return aUndefined ? -1 : 1;
|
|
45
|
+
if (sortUndefined === "last") return aUndefined ? 1 : -1;
|
|
49
46
|
sortInt = aUndefined && bUndefined ? 0 : aUndefined ? sortUndefined : -sortUndefined;
|
|
50
47
|
}
|
|
51
48
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getSortedRowModel.cjs","sources":["../../../src/utils/getSortedRowModel.ts"],"sourcesContent":["import { Table, Row, RowModel, RowData } from '../types'\nimport { SortingFn } from '../features/RowSorting'\nimport { getMemoOptions, memo } from '../utils'\n\nexport function getSortedRowModel<TData extends RowData>(): (\n table: Table<TData>\n) => () => RowModel<TData> {\n return table =>\n memo(\n () => [table.getState().sorting, table.getPreSortedRowModel()],\n (sorting, rowModel) => {\n if (!rowModel.rows.length || !sorting?.length) {\n return rowModel\n }\n\n const sortingState = table.getState().sorting\n\n const sortedFlatRows: Row<TData>[] = []\n\n // Filter out sortings that correspond to non existing columns\n const availableSorting = sortingState.filter(
|
|
1
|
+
{"version":3,"file":"getSortedRowModel.cjs","sources":["../../../src/utils/getSortedRowModel.ts"],"sourcesContent":["import { Table, Row, RowModel, RowData } from '../types'\nimport { SortingFn } from '../features/RowSorting'\nimport { getMemoOptions, memo } from '../utils'\n\nexport function getSortedRowModel<TData extends RowData>(): (\n table: Table<TData>\n) => () => RowModel<TData> {\n return table =>\n memo(\n () => [table.getState().sorting, table.getPreSortedRowModel()],\n (sorting, rowModel) => {\n if (!rowModel.rows.length || !sorting?.length) {\n return rowModel\n }\n\n const sortingState = table.getState().sorting\n\n const sortedFlatRows: Row<TData>[] = []\n\n // Filter out sortings that correspond to non existing columns\n const availableSorting = sortingState.filter(sort =>\n table.getColumn(sort.id)?.getCanSort()\n )\n\n const columnInfoById: Record<\n string,\n {\n sortUndefined?: false | -1 | 1 | 'first' | 'last'\n invertSorting?: boolean\n sortingFn: SortingFn<TData>\n }\n > = {}\n\n availableSorting.forEach(sortEntry => {\n const column = table.getColumn(sortEntry.id)\n if (!column) return\n\n columnInfoById[sortEntry.id] = {\n sortUndefined: column.columnDef.sortUndefined,\n invertSorting: column.columnDef.invertSorting,\n sortingFn: column.getSortingFn(),\n }\n })\n\n const sortData = (rows: Row<TData>[]) => {\n // This will also perform a stable sorting using the row index\n // if needed.\n const sortedData = rows.map(row => ({ ...row }))\n\n sortedData.sort((rowA, rowB) => {\n for (let i = 0; i < availableSorting.length; i += 1) {\n const sortEntry = availableSorting[i]!\n const columnInfo = columnInfoById[sortEntry.id]!\n const sortUndefined = columnInfo.sortUndefined\n const isDesc = sortEntry?.desc ?? false\n\n let sortInt = 0\n\n // All sorting ints should always return in ascending order\n if (sortUndefined) {\n const aValue = rowA.getValue(sortEntry.id)\n const bValue = rowB.getValue(sortEntry.id)\n\n const aUndefined = aValue === undefined\n const bUndefined = bValue === undefined\n\n if (aUndefined || bUndefined) {\n if (sortUndefined === 'first') return aUndefined ? -1 : 1\n if (sortUndefined === 'last') return aUndefined ? 1 : -1\n sortInt =\n aUndefined && bUndefined\n ? 0\n : aUndefined\n ? sortUndefined\n : -sortUndefined\n }\n }\n\n if (sortInt === 0) {\n sortInt = columnInfo.sortingFn(rowA, rowB, sortEntry.id)\n }\n\n // If sorting is non-zero, take care of desc and inversion\n if (sortInt !== 0) {\n if (isDesc) {\n sortInt *= -1\n }\n\n if (columnInfo.invertSorting) {\n sortInt *= -1\n }\n\n return sortInt\n }\n }\n\n return rowA.index - rowB.index\n })\n\n // If there are sub-rows, sort them\n sortedData.forEach(row => {\n sortedFlatRows.push(row)\n if (row.subRows?.length) {\n row.subRows = sortData(row.subRows)\n }\n })\n\n return sortedData\n }\n\n return {\n rows: sortData(rowModel.rows),\n flatRows: sortedFlatRows,\n rowsById: rowModel.rowsById,\n }\n },\n getMemoOptions(table.options, 'debugTable', 'getSortedRowModel', () =>\n table._autoResetPageIndex()\n )\n )\n}\n"],"names":["memo","getMemoOptions"],"mappings":";;;AAIO,SAAS,oBAEW;AACzB,SAAO,CACL,UAAAA,MAAA;AAAA,IACE,MAAM,CAAC,MAAM,SAAA,EAAW,SAAS,MAAM,sBAAsB;AAAA,IAC7D,CAAC,SAAS,aAAa;AACrB,UAAI,CAAC,SAAS,KAAK,UAAU,EAAC,mCAAS,SAAQ;AACtC,eAAA;AAAA,MACT;AAEM,YAAA,eAAe,MAAM,SAAA,EAAW;AAEtC,YAAM,iBAA+B,CAAA;AAGrC,YAAM,mBAAmB,aAAa;AAAA,QAAO,UAC3C;;AAAA,6BAAM,UAAU,KAAK,EAAE,MAAvB,mBAA0B;AAAA;AAAA,MAAW;AAGvC,YAAM,iBAOF,CAAA;AAEJ,uBAAiB,QAAQ,CAAa,cAAA;AACpC,cAAM,SAAS,MAAM,UAAU,UAAU,EAAE;AAC3C,YAAI,CAAC,OAAQ;AAEE,uBAAA,UAAU,EAAE,IAAI;AAAA,UAC7B,eAAe,OAAO,UAAU;AAAA,UAChC,eAAe,OAAO,UAAU;AAAA,UAChC,WAAW,OAAO,aAAa;AAAA,QAAA;AAAA,MACjC,CACD;AAEK,YAAA,WAAW,CAAC,SAAuB;AAGvC,cAAM,aAAa,KAAK,IAAI,UAAQ,EAAE,GAAG,IAAM,EAAA;AAEpC,mBAAA,KAAK,CAAC,MAAM,SAAS;AAC9B,mBAAS,IAAI,GAAG,IAAI,iBAAiB,QAAQ,KAAK,GAAG;AAC7C,kBAAA,YAAY,iBAAiB,CAAC;AAC9B,kBAAA,aAAa,eAAe,UAAU,EAAE;AAC9C,kBAAM,gBAAgB,WAAW;AAC3B,kBAAA,UAAS,uCAAW,SAAQ;AAElC,gBAAI,UAAU;AAGd,gBAAI,eAAe;AACjB,oBAAM,SAAS,KAAK,SAAS,UAAU,EAAE;AACzC,oBAAM,SAAS,KAAK,SAAS,UAAU,EAAE;AAEzC,oBAAM,aAAa,WAAW;AAC9B,oBAAM,aAAa,WAAW;AAE9B,kBAAI,cAAc,YAAY;AAC5B,oBAAI,kBAAkB,QAAgB,QAAA,aAAa,KAAK;AACxD,oBAAI,kBAAkB,OAAe,QAAA,aAAa,IAAI;AACtD,0BACE,cAAc,aACV,IACA,aACE,gBACA,CAAC;AAAA,cACX;AAAA,YACF;AAEA,gBAAI,YAAY,GAAG;AACjB,wBAAU,WAAW,UAAU,MAAM,MAAM,UAAU,EAAE;AAAA,YACzD;AAGA,gBAAI,YAAY,GAAG;AACjB,kBAAI,QAAQ;AACC,2BAAA;AAAA,cACb;AAEA,kBAAI,WAAW,eAAe;AACjB,2BAAA;AAAA,cACb;AAEO,qBAAA;AAAA,YACT;AAAA,UACF;AAEO,iBAAA,KAAK,QAAQ,KAAK;AAAA,QAAA,CAC1B;AAGD,mBAAW,QAAQ,CAAO,QAAA;;AACxB,yBAAe,KAAK,GAAG;AACnB,eAAA,SAAI,YAAJ,mBAAa,QAAQ;AACnB,gBAAA,UAAU,SAAS,IAAI,OAAO;AAAA,UACpC;AAAA,QAAA,CACD;AAEM,eAAA;AAAA,MAAA;AAGF,aAAA;AAAA,QACL,MAAM,SAAS,SAAS,IAAI;AAAA,QAC5B,UAAU;AAAA,QACV,UAAU,SAAS;AAAA,MAAA;AAAA,IAEvB;AAAA,IACAC,MAAA;AAAA,MAAe,MAAM;AAAA,MAAS;AAAA,MAAc;AAAA,MAAqB,MAC/D,MAAM,oBAAoB;AAAA,IAC5B;AAAA,EAAA;AAEN;;"}
|
package/dist/cjs/utils.cjs
CHANGED
|
@@ -41,8 +41,7 @@ function memo(getDeps, fn, opts) {
|
|
|
41
41
|
return (depArgs) => {
|
|
42
42
|
var _a;
|
|
43
43
|
let depTime;
|
|
44
|
-
if (opts.key && opts.debug)
|
|
45
|
-
depTime = Date.now();
|
|
44
|
+
if (opts.key && opts.debug) depTime = Date.now();
|
|
46
45
|
const newDeps = getDeps(depArgs);
|
|
47
46
|
const depsChanged = newDeps.length !== deps.length || newDeps.some((dep, index) => deps[index] !== dep);
|
|
48
47
|
if (!depsChanged) {
|
|
@@ -50,8 +49,7 @@ function memo(getDeps, fn, opts) {
|
|
|
50
49
|
}
|
|
51
50
|
deps = newDeps;
|
|
52
51
|
let resultTime;
|
|
53
|
-
if (opts.key && opts.debug)
|
|
54
|
-
resultTime = Date.now();
|
|
52
|
+
if (opts.key && opts.debug) resultTime = Date.now();
|
|
55
53
|
result = fn(...newDeps);
|
|
56
54
|
(_a = opts == null ? void 0 : opts.onChange) == null ? void 0 : _a.call(opts, result);
|
|
57
55
|
if (opts.key && opts.debug) {
|
package/dist/cjs/utils.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.cjs","sources":["../../src/utils.ts"],"sourcesContent":["import { TableOptionsResolved, TableState, Updater } from './types'\n\nexport type PartialKeys<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>\nexport type RequiredKeys<T, K extends keyof T> = Omit<T, K> &\n Required<Pick<T, K>>\nexport type Overwrite<T, U extends { [TKey in keyof T]?: any }> = Omit<\n T,\n keyof U\n> &\n U\n\nexport type UnionToIntersection<T> = (\n T extends any ? (x: T) => any : never\n) extends (x: infer R) => any\n ? R\n : never\n\nexport type IsAny<T, Y, N> = 1 extends 0 & T ? Y : N\nexport type IsKnown<T, Y, N> = unknown extends T ? N : Y\n\ntype ComputeRange<\n N extends number,\n Result extends Array<unknown> = [],\n> = Result['length'] extends N\n ? Result\n : ComputeRange<N, [...Result, Result['length']]>\ntype Index40 = ComputeRange<40>[number]\n\n// Is this type a tuple?\ntype IsTuple<T> = T extends readonly any[] & { length: infer Length }\n ? Length extends Index40\n ? T\n : never\n : never\n\n// If this type is a tuple, what indices are allowed?\ntype AllowedIndexes<\n Tuple extends ReadonlyArray<any>,\n Keys extends number = never,\n> = Tuple extends readonly []\n ? Keys\n : Tuple extends readonly [infer _, ...infer Tail]\n ? AllowedIndexes<Tail, Keys | Tail['length']>\n : Keys\n\nexport type DeepKeys<T, TDepth extends any[] = []> = TDepth['length'] extends 5\n ? never\n : unknown extends T\n ? string\n : T extends readonly any[] & IsTuple<T>\n ? AllowedIndexes<T> | DeepKeysPrefix<T, AllowedIndexes<T>, TDepth>\n : T extends any[]\n ? DeepKeys<T[number], [...TDepth, any]>\n : T extends Date\n ? never\n : T extends object\n ? (keyof T & string) | DeepKeysPrefix<T, keyof T, TDepth>\n : never\n\ntype DeepKeysPrefix<\n T,\n TPrefix,\n TDepth extends any[],\n> = TPrefix extends keyof T & (number | string)\n ? `${TPrefix}.${DeepKeys<T[TPrefix], [...TDepth, any]> & string}`\n : never\n\nexport type DeepValue<T, TProp>
|
|
1
|
+
{"version":3,"file":"utils.cjs","sources":["../../src/utils.ts"],"sourcesContent":["import { TableOptionsResolved, TableState, Updater } from './types'\n\nexport type PartialKeys<T, K extends keyof T> = Omit<T, K> & Partial<Pick<T, K>>\nexport type RequiredKeys<T, K extends keyof T> = Omit<T, K> &\n Required<Pick<T, K>>\nexport type Overwrite<T, U extends { [TKey in keyof T]?: any }> = Omit<\n T,\n keyof U\n> &\n U\n\nexport type UnionToIntersection<T> = (\n T extends any ? (x: T) => any : never\n) extends (x: infer R) => any\n ? R\n : never\n\nexport type IsAny<T, Y, N> = 1 extends 0 & T ? Y : N\nexport type IsKnown<T, Y, N> = unknown extends T ? N : Y\n\ntype ComputeRange<\n N extends number,\n Result extends Array<unknown> = [],\n> = Result['length'] extends N\n ? Result\n : ComputeRange<N, [...Result, Result['length']]>\ntype Index40 = ComputeRange<40>[number]\n\n// Is this type a tuple?\ntype IsTuple<T> = T extends readonly any[] & { length: infer Length }\n ? Length extends Index40\n ? T\n : never\n : never\n\n// If this type is a tuple, what indices are allowed?\ntype AllowedIndexes<\n Tuple extends ReadonlyArray<any>,\n Keys extends number = never,\n> = Tuple extends readonly []\n ? Keys\n : Tuple extends readonly [infer _, ...infer Tail]\n ? AllowedIndexes<Tail, Keys | Tail['length']>\n : Keys\n\nexport type DeepKeys<T, TDepth extends any[] = []> = TDepth['length'] extends 5\n ? never\n : unknown extends T\n ? string\n : T extends readonly any[] & IsTuple<T>\n ? AllowedIndexes<T> | DeepKeysPrefix<T, AllowedIndexes<T>, TDepth>\n : T extends any[]\n ? DeepKeys<T[number], [...TDepth, any]>\n : T extends Date\n ? never\n : T extends object\n ? (keyof T & string) | DeepKeysPrefix<T, keyof T, TDepth>\n : never\n\ntype DeepKeysPrefix<\n T,\n TPrefix,\n TDepth extends any[],\n> = TPrefix extends keyof T & (number | string)\n ? `${TPrefix}.${DeepKeys<T[TPrefix], [...TDepth, any]> & string}`\n : never\n\nexport type DeepValue<T, TProp> =\n T extends Record<string | number, any>\n ? TProp extends `${infer TBranch}.${infer TDeepProp}`\n ? DeepValue<T[TBranch], TDeepProp>\n : T[TProp & string]\n : never\n\nexport type NoInfer<T> = [T][T extends any ? 0 : never]\n\nexport type Getter<TValue> = <TTValue = TValue>() => NoInfer<TTValue>\n\n///\n\nexport function functionalUpdate<T>(updater: Updater<T>, input: T): T {\n return typeof updater === 'function'\n ? (updater as (input: T) => T)(input)\n : updater\n}\n\nexport function noop() {\n //\n}\n\nexport function makeStateUpdater<K extends keyof TableState>(\n key: K,\n instance: unknown\n) {\n return (updater: Updater<TableState[K]>) => {\n ;(instance as any).setState(<TTableState>(old: TTableState) => {\n return {\n ...old,\n [key]: functionalUpdate(updater, (old as any)[key]),\n }\n })\n }\n}\n\ntype AnyFunction = (...args: any) => any\n\nexport function isFunction<T extends AnyFunction>(d: any): d is T {\n return d instanceof Function\n}\n\nexport function isNumberArray(d: any): d is number[] {\n return Array.isArray(d) && d.every(val => typeof val === 'number')\n}\n\nexport function flattenBy<TNode>(\n arr: TNode[],\n getChildren: (item: TNode) => TNode[]\n) {\n const flat: TNode[] = []\n\n const recurse = (subArr: TNode[]) => {\n subArr.forEach(item => {\n flat.push(item)\n const children = getChildren(item)\n if (children?.length) {\n recurse(children)\n }\n })\n }\n\n recurse(arr)\n\n return flat\n}\n\nexport function memo<TDeps extends readonly any[], TDepArgs, TResult>(\n getDeps: (depArgs?: TDepArgs) => [...TDeps],\n fn: (...args: NoInfer<[...TDeps]>) => TResult,\n opts: {\n key: any\n debug?: () => any\n onChange?: (result: TResult) => void\n }\n): (depArgs?: TDepArgs) => TResult {\n let deps: any[] = []\n let result: TResult | undefined\n\n return depArgs => {\n let depTime: number\n if (opts.key && opts.debug) depTime = Date.now()\n\n const newDeps = getDeps(depArgs)\n\n const depsChanged =\n newDeps.length !== deps.length ||\n newDeps.some((dep: any, index: number) => deps[index] !== dep)\n\n if (!depsChanged) {\n return result!\n }\n\n deps = newDeps\n\n let resultTime: number\n if (opts.key && opts.debug) resultTime = Date.now()\n\n result = fn(...newDeps)\n opts?.onChange?.(result)\n\n if (opts.key && opts.debug) {\n if (opts?.debug()) {\n const depEndTime = Math.round((Date.now() - depTime!) * 100) / 100\n const resultEndTime = Math.round((Date.now() - resultTime!) * 100) / 100\n const resultFpsPercentage = resultEndTime / 16\n\n const pad = (str: number | string, num: number) => {\n str = String(str)\n while (str.length < num) {\n str = ' ' + str\n }\n return str\n }\n\n console.info(\n `%c⏱ ${pad(resultEndTime, 5)} /${pad(depEndTime, 5)} ms`,\n `\n font-size: .6rem;\n font-weight: bold;\n color: hsl(${Math.max(\n 0,\n Math.min(120 - 120 * resultFpsPercentage, 120)\n )}deg 100% 31%);`,\n opts?.key\n )\n }\n }\n\n return result!\n }\n}\n\nexport function getMemoOptions(\n tableOptions: Partial<TableOptionsResolved<any>>,\n debugLevel:\n | 'debugAll'\n | 'debugCells'\n | 'debugTable'\n | 'debugColumns'\n | 'debugRows'\n | 'debugHeaders',\n key: string,\n onChange?: (result: any) => void\n) {\n return {\n debug: () => tableOptions?.debugAll ?? tableOptions[debugLevel],\n key: process.env.NODE_ENV === 'development' && key,\n onChange,\n }\n}\n"],"names":[],"mappings":";;AAg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;AACtB,uCAAM,aAAN,8BAAiB;AAEb,QAAA,KAAK,OAAO,KAAK,OAAO;AACtB,UAAA,6BAAM,SAAS;AACX,cAAA,aAAa,KAAK,OAAO,KAAK,QAAQ,WAAY,GAAG,IAAI;AACzD,cAAA,gBAAgB,KAAK,OAAO,KAAK,QAAQ,cAAe,GAAG,IAAI;AACrE,cAAM,sBAAsB,gBAAgB;AAEtC,cAAA,MAAM,CAAC,KAAsB,QAAgB;AACjD,gBAAM,OAAO,GAAG;AACT,iBAAA,IAAI,SAAS,KAAK;AACvB,kBAAM,MAAM;AAAA,UACd;AACO,iBAAA;AAAA,QAAA;AAGD,gBAAA;AAAA,UACN,OAAO,IAAI,eAAe,CAAC,CAAC,KAAK,IAAI,YAAY,CAAC,CAAC;AAAA,UACnD;AAAA;AAAA;AAAA,yBAGe,KAAK;AAAA,YAChB;AAAA,YACA,KAAK,IAAI,MAAM,MAAM,qBAAqB,GAAG;AAAA,UAC9C,CAAA;AAAA,UACH,6BAAM;AAAA,QAAA;AAAA,MAEV;AAAA,IACF;AAEO,WAAA;AAAA,EAAA;AAEX;AAEO,SAAS,eACd,cACA,YAOA,KACA,UACA;AACO,SAAA;AAAA,IACL,OAAO,OAAM,6CAAc,aAAY,aAAa,UAAU;AAAA,IAC9D,KAAK,QAAQ,IAAI,aAAa,iBAAiB;AAAA,IAC/C;AAAA,EAAA;AAEJ;;;;;;;;;"}
|
|
@@ -32,13 +32,10 @@ const extent = (columnId, _leafRows, childRows) => {
|
|
|
32
32
|
const value = row.getValue(columnId);
|
|
33
33
|
if (value != null) {
|
|
34
34
|
if (min2 === void 0) {
|
|
35
|
-
if (value >= value)
|
|
36
|
-
min2 = max2 = value;
|
|
35
|
+
if (value >= value) min2 = max2 = value;
|
|
37
36
|
} else {
|
|
38
|
-
if (min2 > value)
|
|
39
|
-
|
|
40
|
-
if (max2 < value)
|
|
41
|
-
max2 = value;
|
|
37
|
+
if (min2 > value) min2 = value;
|
|
38
|
+
if (max2 < value) max2 = value;
|
|
42
39
|
}
|
|
43
40
|
}
|
|
44
41
|
});
|
|
@@ -53,8 +50,7 @@ const mean = (columnId, leafRows) => {
|
|
|
53
50
|
++count2, sum2 += value;
|
|
54
51
|
}
|
|
55
52
|
});
|
|
56
|
-
if (count2)
|
|
57
|
-
return sum2 / count2;
|
|
53
|
+
if (count2) return sum2 / count2;
|
|
58
54
|
return;
|
|
59
55
|
};
|
|
60
56
|
const median = (columnId, leafRows) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aggregationFns.js","sources":["../../src/aggregationFns.ts"],"sourcesContent":["import { AggregationFn } from './features/ColumnGrouping'\nimport { isNumberArray } from './utils'\n\nconst sum: AggregationFn<any> = (columnId, _leafRows, childRows) => {\n // It's faster to just add the aggregations together instead of\n // process leaf nodes individually\n return childRows.reduce((sum, next) => {\n const nextValue = next.getValue(columnId)\n return sum + (typeof nextValue === 'number' ? nextValue : 0)\n }, 0)\n}\n\nconst min: AggregationFn<any> = (columnId, _leafRows, childRows) => {\n let min: number | undefined\n\n childRows.forEach(row => {\n const value = row.getValue<number>(columnId)\n\n if (\n value != null &&\n (min! > value || (min === undefined && value >= value))\n ) {\n min = value\n }\n })\n\n return min\n}\n\nconst max: AggregationFn<any> = (columnId, _leafRows, childRows) => {\n let max: number | undefined\n\n childRows.forEach(row => {\n const value = row.getValue<number>(columnId)\n if (\n value != null &&\n (max! < value || (max === undefined && value >= value))\n ) {\n max = value\n }\n })\n\n return max\n}\n\nconst extent: AggregationFn<any> = (columnId, _leafRows, childRows) => {\n let min: number | undefined\n let max: number | undefined\n\n childRows.forEach(row => {\n const value = row.getValue<number>(columnId)\n if (value != null) {\n if (min === undefined) {\n if (value >= value) min = max = value\n } else {\n if (min > value) min = value\n if (max! < value) max = value\n }\n }\n })\n\n return [min, max]\n}\n\nconst mean: AggregationFn<any> = (columnId, leafRows) => {\n let count = 0\n let sum = 0\n\n leafRows.forEach(row => {\n let value = row.getValue<number>(columnId)\n if (value != null && (value = +value) >= value) {\n ++count, (sum += value)\n }\n })\n\n if (count) return sum / count\n\n return\n}\n\nconst median: AggregationFn<any> = (columnId, leafRows) => {\n if (!leafRows.length) {\n return\n }\n\n const values = leafRows.map(row => row.getValue(columnId))\n if (!isNumberArray(values)) {\n return\n }\n if (values.length === 1) {\n return values[0]\n }\n\n const mid = Math.floor(values.length / 2)\n const nums = values.sort((a, b) => a - b)\n return values.length % 2 !== 0 ? nums[mid] : (nums[mid - 1]! + nums[mid]!) / 2\n}\n\nconst unique: AggregationFn<any> = (columnId, leafRows) => {\n return Array.from(new Set(leafRows.map(d => d.getValue(columnId))).values())\n}\n\nconst uniqueCount: AggregationFn<any> = (columnId, leafRows) => {\n return new Set(leafRows.map(d => d.getValue(columnId))).size\n}\n\nconst count: AggregationFn<any> = (_columnId, leafRows) => {\n return leafRows.length\n}\n\nexport const aggregationFns = {\n sum,\n min,\n max,\n extent,\n mean,\n median,\n unique,\n uniqueCount,\n count,\n}\n\nexport type BuiltInAggregationFn = keyof typeof aggregationFns\n"],"names":["sum","min","max","count"],"mappings":";AAGA,MAAM,MAA0B,CAAC,UAAU,WAAW,cAAc;AAGlE,SAAO,UAAU,OAAO,CAACA,MAAK,SAAS;AAC/B,UAAA,YAAY,KAAK,SAAS,QAAQ;AACxC,WAAOA,QAAO,OAAO,cAAc,WAAW,YAAY;AAAA,KACzD,CAAC;AACN;AAEA,MAAM,MAA0B,CAAC,UAAU,WAAW,cAAc;AAC9DC,MAAAA;AAEJ,YAAU,QAAQ,CAAO,QAAA;AACjB,UAAA,QAAQ,IAAI,SAAiB,QAAQ;AAE3C,QACE,SAAS,SACRA,OAAO,SAAUA,SAAQ,UAAa,SAAS,QAChD;AACAA,aAAM;AAAA,IACR;AAAA,EAAA,CACD;AAEMA,SAAAA;AACT;AAEA,MAAM,MAA0B,CAAC,UAAU,WAAW,cAAc;AAC9DC,MAAAA;AAEJ,YAAU,QAAQ,CAAO,QAAA;AACjB,UAAA,QAAQ,IAAI,SAAiB,QAAQ;AAC3C,QACE,SAAS,SACRA,OAAO,SAAUA,SAAQ,UAAa,SAAS,QAChD;AACAA,aAAM;AAAA,IACR;AAAA,EAAA,CACD;AAEMA,SAAAA;AACT;AAEA,MAAM,SAA6B,CAAC,UAAU,WAAW,cAAc;AACjED,MAAAA;AACAC,MAAAA;AAEJ,YAAU,QAAQ,CAAO,QAAA;AACjB,UAAA,QAAQ,IAAI,SAAiB,QAAQ;AAC3C,QAAI,SAAS,MAAM;AACjB,UAAID,SAAQ,QAAW;AACrB,YAAI,SAAS
|
|
1
|
+
{"version":3,"file":"aggregationFns.js","sources":["../../src/aggregationFns.ts"],"sourcesContent":["import { AggregationFn } from './features/ColumnGrouping'\nimport { isNumberArray } from './utils'\n\nconst sum: AggregationFn<any> = (columnId, _leafRows, childRows) => {\n // It's faster to just add the aggregations together instead of\n // process leaf nodes individually\n return childRows.reduce((sum, next) => {\n const nextValue = next.getValue(columnId)\n return sum + (typeof nextValue === 'number' ? nextValue : 0)\n }, 0)\n}\n\nconst min: AggregationFn<any> = (columnId, _leafRows, childRows) => {\n let min: number | undefined\n\n childRows.forEach(row => {\n const value = row.getValue<number>(columnId)\n\n if (\n value != null &&\n (min! > value || (min === undefined && value >= value))\n ) {\n min = value\n }\n })\n\n return min\n}\n\nconst max: AggregationFn<any> = (columnId, _leafRows, childRows) => {\n let max: number | undefined\n\n childRows.forEach(row => {\n const value = row.getValue<number>(columnId)\n if (\n value != null &&\n (max! < value || (max === undefined && value >= value))\n ) {\n max = value\n }\n })\n\n return max\n}\n\nconst extent: AggregationFn<any> = (columnId, _leafRows, childRows) => {\n let min: number | undefined\n let max: number | undefined\n\n childRows.forEach(row => {\n const value = row.getValue<number>(columnId)\n if (value != null) {\n if (min === undefined) {\n if (value >= value) min = max = value\n } else {\n if (min > value) min = value\n if (max! < value) max = value\n }\n }\n })\n\n return [min, max]\n}\n\nconst mean: AggregationFn<any> = (columnId, leafRows) => {\n let count = 0\n let sum = 0\n\n leafRows.forEach(row => {\n let value = row.getValue<number>(columnId)\n if (value != null && (value = +value) >= value) {\n ++count, (sum += value)\n }\n })\n\n if (count) return sum / count\n\n return\n}\n\nconst median: AggregationFn<any> = (columnId, leafRows) => {\n if (!leafRows.length) {\n return\n }\n\n const values = leafRows.map(row => row.getValue(columnId))\n if (!isNumberArray(values)) {\n return\n }\n if (values.length === 1) {\n return values[0]\n }\n\n const mid = Math.floor(values.length / 2)\n const nums = values.sort((a, b) => a - b)\n return values.length % 2 !== 0 ? nums[mid] : (nums[mid - 1]! + nums[mid]!) / 2\n}\n\nconst unique: AggregationFn<any> = (columnId, leafRows) => {\n return Array.from(new Set(leafRows.map(d => d.getValue(columnId))).values())\n}\n\nconst uniqueCount: AggregationFn<any> = (columnId, leafRows) => {\n return new Set(leafRows.map(d => d.getValue(columnId))).size\n}\n\nconst count: AggregationFn<any> = (_columnId, leafRows) => {\n return leafRows.length\n}\n\nexport const aggregationFns = {\n sum,\n min,\n max,\n extent,\n mean,\n median,\n unique,\n uniqueCount,\n count,\n}\n\nexport type BuiltInAggregationFn = keyof typeof aggregationFns\n"],"names":["sum","min","max","count"],"mappings":";AAGA,MAAM,MAA0B,CAAC,UAAU,WAAW,cAAc;AAGlE,SAAO,UAAU,OAAO,CAACA,MAAK,SAAS;AAC/B,UAAA,YAAY,KAAK,SAAS,QAAQ;AACxC,WAAOA,QAAO,OAAO,cAAc,WAAW,YAAY;AAAA,KACzD,CAAC;AACN;AAEA,MAAM,MAA0B,CAAC,UAAU,WAAW,cAAc;AAC9DC,MAAAA;AAEJ,YAAU,QAAQ,CAAO,QAAA;AACjB,UAAA,QAAQ,IAAI,SAAiB,QAAQ;AAE3C,QACE,SAAS,SACRA,OAAO,SAAUA,SAAQ,UAAa,SAAS,QAChD;AACAA,aAAM;AAAA,IACR;AAAA,EAAA,CACD;AAEMA,SAAAA;AACT;AAEA,MAAM,MAA0B,CAAC,UAAU,WAAW,cAAc;AAC9DC,MAAAA;AAEJ,YAAU,QAAQ,CAA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AACxC,SAAO,OAAO,SAAS,MAAM,IAAI,KAAK,GAAG,KAAK,KAAK,MAAM,CAAC,IAAK,KAAK,GAAG,KAAM;AAC/E;AAEA,MAAM,SAA6B,CAAC,UAAU,aAAa;AACzD,SAAO,MAAM,KAAK,IAAI,IAAI,SAAS,IAAI,CAAA,MAAK,EAAE,SAAS,QAAQ,CAAC,CAAC,EAAE,OAAQ,CAAA;AAC7E;AAEA,MAAM,cAAkC,CAAC,UAAU,aAAa;AACvD,SAAA,IAAI,IAAI,SAAS,IAAI,CAAA,MAAK,EAAE,SAAS,QAAQ,CAAC,CAAC,EAAE;AAC1D;AAEA,MAAM,QAA4B,CAAC,WAAW,aAAa;AACzD,SAAO,SAAS;AAClB;AAEO,MAAM,iBAAiB;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;"}
|
package/dist/esm/core/cell.d.ts
CHANGED
|
@@ -47,4 +47,4 @@ export interface CoreCell<TData extends RowData, TValue> {
|
|
|
47
47
|
*/
|
|
48
48
|
row: Row<TData>;
|
|
49
49
|
}
|
|
50
|
-
export declare function
|
|
50
|
+
export declare function _createCell<TData extends RowData, TValue>(table: Table<TData>, row: Row<TData>, column: Column<TData, TValue>, columnId: string): Cell<TData, TValue>;
|
package/dist/esm/core/cell.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { memo, getMemoOptions } from "../utils.js";
|
|
2
|
-
function
|
|
2
|
+
function _createCell(table, row, column, columnId) {
|
|
3
3
|
const getRenderValue = () => cell.getValue() ?? table.options.renderFallbackValue;
|
|
4
4
|
const cell = {
|
|
5
5
|
id: `${row.id}_${column.id}`,
|
|
@@ -22,7 +22,7 @@ function createCell(table, row, column, columnId) {
|
|
|
22
22
|
};
|
|
23
23
|
table._features.forEach((feature) => {
|
|
24
24
|
var _a;
|
|
25
|
-
(_a = feature.
|
|
25
|
+
(_a = feature._createCell) == null ? void 0 : _a.call(
|
|
26
26
|
feature,
|
|
27
27
|
cell,
|
|
28
28
|
column,
|
|
@@ -33,6 +33,6 @@ function createCell(table, row, column, columnId) {
|
|
|
33
33
|
return cell;
|
|
34
34
|
}
|
|
35
35
|
export {
|
|
36
|
-
|
|
36
|
+
_createCell
|
|
37
37
|
};
|
|
38
38
|
//# sourceMappingURL=cell.js.map
|
|
@@ -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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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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AgB,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;"}
|
package/dist/esm/core/row.d.ts
CHANGED
|
@@ -89,4 +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
|