@tanstack/table-core 8.19.2 → 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 +94 -0
- package/dist/cjs/aggregationFns.cjs.map +1 -0
- package/dist/cjs/aggregationFns.d.cts +14 -0
- package/dist/cjs/columnHelper.cjs +19 -0
- package/dist/cjs/columnHelper.cjs.map +1 -0
- package/dist/cjs/columnHelper.d.cts +9 -0
- package/dist/cjs/core/cell.cjs +38 -0
- package/dist/cjs/core/cell.cjs.map +1 -0
- package/dist/cjs/core/cell.d.cts +50 -0
- package/dist/cjs/core/column.cjs +81 -0
- package/dist/cjs/core/column.cjs.map +1 -0
- package/dist/cjs/core/column.d.cts +56 -0
- package/dist/cjs/core/headers.cjs +310 -0
- package/dist/cjs/core/headers.cjs.map +1 -0
- package/dist/cjs/core/headers.d.cts +195 -0
- package/dist/cjs/core/row.cjs +92 -0
- package/dist/cjs/core/row.cjs.map +1 -0
- package/dist/cjs/core/row.d.cts +92 -0
- package/dist/cjs/core/table.cjs +232 -0
- package/dist/cjs/core/table.cjs.map +1 -0
- package/dist/cjs/core/table.d.cts +229 -0
- package/dist/cjs/features/ColumnFaceting.cjs +29 -0
- package/dist/cjs/features/ColumnFaceting.cjs.map +1 -0
- package/dist/cjs/features/ColumnFaceting.d.cts +35 -0
- package/dist/cjs/features/ColumnFiltering.cjs +137 -0
- package/dist/cjs/features/ColumnFiltering.cjs.map +1 -0
- package/dist/cjs/features/ColumnFiltering.d.cts +195 -0
- package/dist/cjs/features/ColumnGrouping.cjs +133 -0
- package/dist/cjs/features/ColumnGrouping.cjs.map +1 -0
- package/dist/cjs/features/ColumnGrouping.d.cts +202 -0
- package/dist/cjs/features/ColumnOrdering.cjs +76 -0
- package/dist/cjs/features/ColumnOrdering.cjs.map +1 -0
- package/dist/cjs/features/ColumnOrdering.d.cts +54 -0
- package/dist/cjs/features/ColumnPinning.cjs +145 -0
- package/dist/cjs/features/ColumnPinning.cjs.map +1 -0
- package/dist/cjs/features/ColumnPinning.d.cts +127 -0
- package/dist/cjs/features/ColumnSizing.cjs +307 -0
- package/dist/cjs/features/ColumnSizing.cjs.map +1 -0
- package/dist/cjs/features/ColumnSizing.d.cts +194 -0
- package/dist/cjs/features/ColumnVisibility.cjs +144 -0
- package/dist/cjs/features/ColumnVisibility.cjs.map +1 -0
- package/dist/cjs/features/ColumnVisibility.d.cts +130 -0
- package/dist/cjs/features/GlobalFaceting.cjs +29 -0
- package/dist/cjs/features/GlobalFaceting.cjs.map +1 -0
- package/dist/cjs/features/GlobalFaceting.d.cts +27 -0
- package/dist/cjs/features/GlobalFiltering.cjs +50 -0
- package/dist/cjs/features/GlobalFiltering.cjs.map +1 -0
- package/dist/cjs/features/GlobalFiltering.d.cts +80 -0
- package/dist/cjs/features/RowExpanding.cjs +152 -0
- package/dist/cjs/features/RowExpanding.cjs.map +1 -0
- package/dist/cjs/features/RowExpanding.d.cts +155 -0
- package/dist/cjs/features/RowPagination.cjs +161 -0
- package/dist/cjs/features/RowPagination.cjs.map +1 -0
- package/dist/cjs/features/RowPagination.d.cts +166 -0
- package/dist/cjs/features/RowPinning.cjs +132 -0
- package/dist/cjs/features/RowPinning.cjs.map +1 -0
- package/dist/cjs/features/RowPinning.d.cts +99 -0
- package/dist/cjs/features/RowSelection.cjs +296 -0
- package/dist/cjs/features/RowSelection.cjs.map +1 -0
- package/dist/cjs/features/RowSelection.d.cts +177 -0
- package/dist/cjs/features/RowSorting.cjs +200 -0
- package/dist/cjs/features/RowSorting.cjs.map +1 -0
- package/dist/cjs/features/RowSorting.d.cts +238 -0
- package/dist/cjs/filterFns.cjs +88 -0
- package/dist/cjs/filterFns.cjs.map +1 -0
- package/dist/cjs/filterFns.d.cts +14 -0
- package/{build/lib/index.js → dist/cjs/index.cjs} +41 -53
- package/dist/cjs/index.cjs.map +1 -0
- package/dist/cjs/index.d.cts +34 -0
- package/{build/lib/sortingFns.js → dist/cjs/sortingFns.cjs} +23 -52
- package/dist/cjs/sortingFns.cjs.map +1 -0
- package/dist/cjs/sortingFns.d.cts +12 -0
- package/dist/cjs/types.d.cts +120 -0
- package/{build/lib/utils/filterRowsUtils.js → dist/cjs/utils/filterRowsUtils.cjs} +34 -46
- package/dist/cjs/utils/filterRowsUtils.cjs.map +1 -0
- package/dist/cjs/utils/filterRowsUtils.d.cts +3 -0
- package/dist/cjs/utils/getCoreRowModel.cjs +54 -0
- package/dist/cjs/utils/getCoreRowModel.cjs.map +1 -0
- package/dist/cjs/utils/getCoreRowModel.d.cts +3 -0
- package/dist/cjs/utils/getExpandedRowModel.cjs +41 -0
- package/dist/cjs/utils/getExpandedRowModel.cjs.map +1 -0
- package/dist/cjs/utils/getExpandedRowModel.d.cts +8 -0
- package/dist/cjs/utils/getFacetedMinMaxValues.cjs +35 -0
- package/dist/cjs/utils/getFacetedMinMaxValues.cjs.map +1 -0
- package/dist/cjs/utils/getFacetedMinMaxValues.d.cts +3 -0
- package/dist/cjs/utils/getFacetedRowModel.cjs +35 -0
- package/dist/cjs/utils/getFacetedRowModel.cjs.map +1 -0
- package/dist/cjs/utils/getFacetedRowModel.d.cts +3 -0
- package/dist/cjs/utils/getFacetedUniqueValues.cjs +37 -0
- package/dist/cjs/utils/getFacetedUniqueValues.cjs.map +1 -0
- package/dist/cjs/utils/getFacetedUniqueValues.d.cts +3 -0
- package/dist/cjs/utils/getFilteredRowModel.cjs +116 -0
- package/dist/cjs/utils/getFilteredRowModel.cjs.map +1 -0
- package/dist/cjs/utils/getFilteredRowModel.d.cts +3 -0
- package/dist/cjs/utils/getGroupedRowModel.cjs +118 -0
- package/dist/cjs/utils/getGroupedRowModel.cjs.map +1 -0
- package/dist/cjs/utils/getGroupedRowModel.d.cts +3 -0
- package/dist/cjs/utils/getPaginationRowModel.cjs +49 -0
- package/dist/cjs/utils/getPaginationRowModel.cjs.map +1 -0
- package/dist/cjs/utils/getPaginationRowModel.d.cts +5 -0
- package/dist/cjs/utils/getSortedRowModel.cjs +88 -0
- package/dist/cjs/utils/getSortedRowModel.cjs.map +1 -0
- package/dist/cjs/utils/getSortedRowModel.d.cts +3 -0
- package/{build/lib/utils.js → dist/cjs/utils.cjs} +26 -39
- package/dist/cjs/utils.cjs.map +1 -0
- package/dist/cjs/utils.d.cts +39 -0
- package/{build/lib → dist/esm}/aggregationFns.d.ts +2 -1
- package/dist/esm/aggregationFns.js +94 -0
- package/dist/esm/aggregationFns.js.map +1 -0
- package/{build/lib → dist/esm}/columnHelper.d.ts +3 -2
- package/dist/esm/columnHelper.js +19 -0
- package/{build/lib → dist/esm}/columnHelper.js.map +1 -1
- package/{build/lib → dist/esm}/core/cell.d.ts +2 -1
- package/dist/esm/core/cell.js +38 -0
- package/dist/esm/core/cell.js.map +1 -0
- package/{build/lib → dist/esm}/core/column.d.ts +2 -1
- package/dist/esm/core/column.js +81 -0
- package/dist/esm/core/column.js.map +1 -0
- package/{build/lib → dist/esm}/core/headers.d.ts +1 -0
- package/dist/esm/core/headers.js +310 -0
- package/dist/esm/core/headers.js.map +1 -0
- package/{build/lib → dist/esm}/core/row.d.ts +2 -1
- package/dist/esm/core/row.js +92 -0
- package/dist/esm/core/row.js.map +1 -0
- package/{build/lib → dist/esm}/core/table.d.ts +10 -1
- package/dist/esm/core/table.js +232 -0
- package/dist/esm/core/table.js.map +1 -0
- package/{build/lib → dist/esm}/features/ColumnFaceting.d.ts +1 -0
- package/{build/lib → dist/esm}/features/ColumnFaceting.js +6 -19
- package/{build/lib → dist/esm}/features/ColumnFaceting.js.map +1 -1
- package/{build/lib → dist/esm}/features/ColumnFiltering.d.ts +1 -0
- package/dist/esm/features/ColumnFiltering.js +137 -0
- package/dist/esm/features/ColumnFiltering.js.map +1 -0
- package/{build/lib → dist/esm}/features/ColumnGrouping.d.ts +1 -0
- package/dist/esm/features/ColumnGrouping.js +133 -0
- package/dist/esm/features/ColumnGrouping.js.map +1 -0
- package/{build/lib → dist/esm}/features/ColumnOrdering.d.ts +1 -0
- package/dist/esm/features/ColumnOrdering.js +76 -0
- package/dist/esm/features/ColumnOrdering.js.map +1 -0
- package/{build/lib → dist/esm}/features/ColumnPinning.d.ts +1 -0
- package/dist/esm/features/ColumnPinning.js +145 -0
- package/dist/esm/features/ColumnPinning.js.map +1 -0
- package/{build/lib → dist/esm}/features/ColumnSizing.d.ts +2 -1
- package/dist/esm/features/ColumnSizing.js +307 -0
- package/dist/esm/features/ColumnSizing.js.map +1 -0
- package/{build/lib → dist/esm}/features/ColumnVisibility.d.ts +1 -0
- package/dist/esm/features/ColumnVisibility.js +144 -0
- package/dist/esm/features/ColumnVisibility.js.map +1 -0
- package/{build/lib → dist/esm}/features/GlobalFaceting.d.ts +1 -0
- package/{build/lib → dist/esm}/features/GlobalFaceting.js +8 -21
- package/dist/esm/features/GlobalFaceting.js.map +1 -0
- package/{build/lib → dist/esm}/features/GlobalFiltering.d.ts +1 -0
- package/dist/esm/features/GlobalFiltering.js +50 -0
- package/dist/esm/features/GlobalFiltering.js.map +1 -0
- package/{build/lib → dist/esm}/features/RowExpanding.d.ts +1 -0
- package/{build/lib → dist/esm}/features/RowExpanding.js +37 -58
- package/dist/esm/features/RowExpanding.js.map +1 -0
- package/{build/lib → dist/esm}/features/RowPagination.d.ts +1 -0
- package/dist/esm/features/RowPagination.js +161 -0
- package/dist/esm/features/RowPagination.js.map +1 -0
- package/{build/lib → dist/esm}/features/RowPinning.d.ts +1 -0
- package/dist/esm/features/RowPinning.js +132 -0
- package/dist/esm/features/RowPinning.js.map +1 -0
- package/{build/lib → dist/esm}/features/RowSelection.d.ts +1 -0
- package/dist/esm/features/RowSelection.js +296 -0
- package/dist/esm/features/RowSelection.js.map +1 -0
- package/{build/lib → dist/esm}/features/RowSorting.d.ts +1 -0
- package/dist/esm/features/RowSorting.js +200 -0
- package/dist/esm/features/RowSorting.js.map +1 -0
- package/{build/lib → dist/esm}/filterFns.d.ts +2 -1
- package/dist/esm/filterFns.js +88 -0
- package/dist/esm/filterFns.js.map +1 -0
- package/dist/esm/index.d.ts +34 -0
- package/dist/esm/index.js +88 -0
- package/dist/esm/index.js.map +1 -0
- package/{build/lib → dist/esm}/sortingFns.d.ts +2 -1
- package/dist/esm/sortingFns.js +91 -0
- package/dist/esm/sortingFns.js.map +1 -0
- package/{build/lib → dist/esm}/types.d.ts +29 -28
- package/{build/lib → dist/esm}/utils/filterRowsUtils.d.ts +1 -0
- package/dist/esm/utils/filterRowsUtils.js +99 -0
- package/dist/esm/utils/filterRowsUtils.js.map +1 -0
- package/{build/lib → dist/esm}/utils/getCoreRowModel.d.ts +1 -0
- package/dist/esm/utils/getCoreRowModel.js +54 -0
- package/dist/esm/utils/getCoreRowModel.js.map +1 -0
- package/{build/lib → dist/esm}/utils/getExpandedRowModel.d.ts +1 -0
- package/dist/esm/utils/getExpandedRowModel.js +41 -0
- package/dist/esm/utils/getExpandedRowModel.js.map +1 -0
- package/{build/lib → dist/esm}/utils/getFacetedMinMaxValues.d.ts +1 -0
- package/dist/esm/utils/getFacetedMinMaxValues.js +35 -0
- package/dist/esm/utils/getFacetedMinMaxValues.js.map +1 -0
- package/{build/lib → dist/esm}/utils/getFacetedRowModel.d.ts +1 -0
- package/dist/esm/utils/getFacetedRowModel.js +35 -0
- package/{build/lib → dist/esm}/utils/getFacetedRowModel.js.map +1 -1
- package/{build/lib → dist/esm}/utils/getFacetedUniqueValues.d.ts +1 -0
- package/dist/esm/utils/getFacetedUniqueValues.js +37 -0
- package/dist/esm/utils/getFacetedUniqueValues.js.map +1 -0
- package/{build/lib → dist/esm}/utils/getFilteredRowModel.d.ts +1 -0
- package/dist/esm/utils/getFilteredRowModel.js +116 -0
- package/{build/lib → dist/esm}/utils/getFilteredRowModel.js.map +1 -1
- package/{build/lib → dist/esm}/utils/getGroupedRowModel.d.ts +1 -0
- package/dist/esm/utils/getGroupedRowModel.js +118 -0
- package/dist/esm/utils/getGroupedRowModel.js.map +1 -0
- package/{build/lib → dist/esm}/utils/getPaginationRowModel.d.ts +1 -0
- package/dist/esm/utils/getPaginationRowModel.js +49 -0
- package/dist/esm/utils/getPaginationRowModel.js.map +1 -0
- package/{build/lib → dist/esm}/utils/getSortedRowModel.d.ts +1 -0
- package/dist/esm/utils/getSortedRowModel.js +88 -0
- package/{build/lib → dist/esm}/utils/getSortedRowModel.js.map +1 -1
- package/{build/lib → dist/esm}/utils.d.ts +2 -1
- package/dist/esm/utils.js +98 -0
- package/{build/lib → dist/esm}/utils.js.map +1 -1
- package/package.json +14 -10
- package/src/core/cell.ts +2 -2
- package/src/core/column.ts +2 -2
- package/src/core/headers.ts +5 -5
- package/src/core/row.ts +4 -4
- package/src/core/table.ts +43 -7
- package/src/features/ColumnFaceting.ts +1 -1
- package/src/features/ColumnFiltering.ts +6 -6
- package/src/features/ColumnGrouping.ts +7 -7
- package/src/features/ColumnOrdering.ts +4 -4
- package/src/features/ColumnPinning.ts +5 -5
- package/src/features/ColumnSizing.ts +6 -6
- package/src/features/ColumnVisibility.ts +5 -5
- package/src/features/GlobalFaceting.ts +1 -1
- package/src/features/GlobalFiltering.ts +4 -4
- package/src/features/RowExpanding.ts +4 -4
- package/src/features/RowPagination.ts +3 -3
- package/src/features/RowPinning.ts +4 -4
- package/src/features/RowSelection.ts +4 -4
- package/src/features/RowSorting.ts +5 -5
- package/src/types.ts +8 -8
- package/src/utils/filterRowsUtils.ts +3 -3
- package/src/utils/getCoreRowModel.ts +2 -2
- package/src/utils/getGroupedRowModel.ts +2 -2
- package/build/lib/aggregationFns.js +0 -108
- package/build/lib/aggregationFns.js.map +0 -1
- package/build/lib/columnHelper.js +0 -71
- package/build/lib/core/cell.js +0 -42
- package/build/lib/core/cell.js.map +0 -1
- package/build/lib/core/column.js +0 -80
- package/build/lib/core/column.js.map +0 -1
- package/build/lib/core/headers.js +0 -270
- package/build/lib/core/headers.js.map +0 -1
- package/build/lib/core/row.js +0 -89
- package/build/lib/core/row.js.map +0 -1
- package/build/lib/core/table.js +0 -212
- package/build/lib/core/table.js.map +0 -1
- package/build/lib/features/ColumnFiltering.js +0 -151
- package/build/lib/features/ColumnFiltering.js.map +0 -1
- package/build/lib/features/ColumnGrouping.js +0 -142
- package/build/lib/features/ColumnGrouping.js.map +0 -1
- package/build/lib/features/ColumnOrdering.js +0 -84
- package/build/lib/features/ColumnOrdering.js.map +0 -1
- package/build/lib/features/ColumnPinning.js +0 -130
- package/build/lib/features/ColumnPinning.js.map +0 -1
- package/build/lib/features/ColumnSizing.js +0 -270
- package/build/lib/features/ColumnSizing.js.map +0 -1
- package/build/lib/features/ColumnVisibility.js +0 -99
- package/build/lib/features/ColumnVisibility.js.map +0 -1
- package/build/lib/features/GlobalFaceting.js.map +0 -1
- package/build/lib/features/GlobalFiltering.js +0 -63
- package/build/lib/features/GlobalFiltering.js.map +0 -1
- package/build/lib/features/RowExpanding.js.map +0 -1
- package/build/lib/features/RowPagination.js +0 -169
- package/build/lib/features/RowPagination.js.map +0 -1
- package/build/lib/features/RowPinning.js +0 -145
- package/build/lib/features/RowPinning.js.map +0 -1
- package/build/lib/features/RowSelection.js +0 -391
- package/build/lib/features/RowSelection.js.map +0 -1
- package/build/lib/features/RowSorting.js +0 -226
- package/build/lib/features/RowSorting.js.map +0 -1
- package/build/lib/filterFns.js +0 -96
- package/build/lib/filterFns.js.map +0 -1
- package/build/lib/index.d.ts +0 -34
- package/build/lib/index.esm.js +0 -3522
- package/build/lib/index.esm.js.map +0 -1
- package/build/lib/index.js.map +0 -1
- package/build/lib/index.mjs +0 -3522
- package/build/lib/index.mjs.map +0 -1
- package/build/lib/sortingFns.js.map +0 -1
- package/build/lib/utils/filterRowsUtils.js.map +0 -1
- package/build/lib/utils/getCoreRowModel.js +0 -65
- package/build/lib/utils/getCoreRowModel.js.map +0 -1
- package/build/lib/utils/getExpandedRowModel.js +0 -46
- package/build/lib/utils/getExpandedRowModel.js.map +0 -1
- package/build/lib/utils/getFacetedMinMaxValues.js +0 -43
- package/build/lib/utils/getFacetedMinMaxValues.js.map +0 -1
- package/build/lib/utils/getFacetedRowModel.js +0 -36
- package/build/lib/utils/getFacetedUniqueValues.js +0 -39
- package/build/lib/utils/getFacetedUniqueValues.js.map +0 -1
- package/build/lib/utils/getFilteredRowModel.js +0 -111
- package/build/lib/utils/getGroupedRowModel.js +0 -150
- package/build/lib/utils/getGroupedRowModel.js.map +0 -1
- package/build/lib/utils/getPaginationRowModel.js +0 -60
- package/build/lib/utils/getPaginationRowModel.js.map +0 -1
- package/build/lib/utils/getSortedRowModel.js +0 -102
- package/build/umd/index.development.js +0 -3578
- package/build/umd/index.development.js.map +0 -1
- package/build/umd/index.production.js +0 -12
- package/build/umd/index.production.js.map +0 -1
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { makeStateUpdater, memo, getMemoOptions } from "../utils.js";
|
|
2
|
+
const getDefaultRowPinningState = () => ({
|
|
3
|
+
top: [],
|
|
4
|
+
bottom: []
|
|
5
|
+
});
|
|
6
|
+
const RowPinning = {
|
|
7
|
+
_getInitialState: (state) => {
|
|
8
|
+
return {
|
|
9
|
+
rowPinning: getDefaultRowPinningState(),
|
|
10
|
+
...state
|
|
11
|
+
};
|
|
12
|
+
},
|
|
13
|
+
_getDefaultOptions: (table) => {
|
|
14
|
+
return {
|
|
15
|
+
onRowPinningChange: makeStateUpdater("rowPinning", table)
|
|
16
|
+
};
|
|
17
|
+
},
|
|
18
|
+
_createRow: (row, table) => {
|
|
19
|
+
row.pin = (position, includeLeafRows, includeParentRows) => {
|
|
20
|
+
const leafRowIds = includeLeafRows ? row.getLeafRows().map(({ id }) => id) : [];
|
|
21
|
+
const parentRowIds = includeParentRows ? row.getParentRows().map(({ id }) => id) : [];
|
|
22
|
+
const rowIds = /* @__PURE__ */ new Set([...parentRowIds, row.id, ...leafRowIds]);
|
|
23
|
+
table.setRowPinning((old) => {
|
|
24
|
+
if (position === "bottom") {
|
|
25
|
+
return {
|
|
26
|
+
top: ((old == null ? void 0 : old.top) ?? []).filter((d) => !(rowIds == null ? void 0 : rowIds.has(d))),
|
|
27
|
+
bottom: [
|
|
28
|
+
...((old == null ? void 0 : old.bottom) ?? []).filter((d) => !(rowIds == null ? void 0 : rowIds.has(d))),
|
|
29
|
+
...Array.from(rowIds)
|
|
30
|
+
]
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
if (position === "top") {
|
|
34
|
+
return {
|
|
35
|
+
top: [
|
|
36
|
+
...((old == null ? void 0 : old.top) ?? []).filter((d) => !(rowIds == null ? void 0 : rowIds.has(d))),
|
|
37
|
+
...Array.from(rowIds)
|
|
38
|
+
],
|
|
39
|
+
bottom: ((old == null ? void 0 : old.bottom) ?? []).filter((d) => !(rowIds == null ? void 0 : rowIds.has(d)))
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
return {
|
|
43
|
+
top: ((old == null ? void 0 : old.top) ?? []).filter((d) => !(rowIds == null ? void 0 : rowIds.has(d))),
|
|
44
|
+
bottom: ((old == null ? void 0 : old.bottom) ?? []).filter((d) => !(rowIds == null ? void 0 : rowIds.has(d)))
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
row.getCanPin = () => {
|
|
49
|
+
const { enableRowPinning, enablePinning } = table.options;
|
|
50
|
+
if (typeof enableRowPinning === "function") {
|
|
51
|
+
return enableRowPinning(row);
|
|
52
|
+
}
|
|
53
|
+
return enableRowPinning ?? enablePinning ?? true;
|
|
54
|
+
};
|
|
55
|
+
row.getIsPinned = () => {
|
|
56
|
+
const rowIds = [row.id];
|
|
57
|
+
const { top, bottom } = table.getState().rowPinning;
|
|
58
|
+
const isTop = rowIds.some((d) => top == null ? void 0 : top.includes(d));
|
|
59
|
+
const isBottom = rowIds.some((d) => bottom == null ? void 0 : bottom.includes(d));
|
|
60
|
+
return isTop ? "top" : isBottom ? "bottom" : false;
|
|
61
|
+
};
|
|
62
|
+
row.getPinnedIndex = () => {
|
|
63
|
+
var _a;
|
|
64
|
+
const position = row.getIsPinned();
|
|
65
|
+
if (!position) return -1;
|
|
66
|
+
const visiblePinnedRowIds = (_a = position === "top" ? table.getTopRows() : table.getBottomRows()) == null ? void 0 : _a.map(({ id }) => id);
|
|
67
|
+
return (visiblePinnedRowIds == null ? void 0 : visiblePinnedRowIds.indexOf(row.id)) ?? -1;
|
|
68
|
+
};
|
|
69
|
+
},
|
|
70
|
+
_createTable: (table) => {
|
|
71
|
+
table.setRowPinning = (updater) => {
|
|
72
|
+
var _a, _b;
|
|
73
|
+
return (_b = (_a = table.options).onRowPinningChange) == null ? void 0 : _b.call(_a, updater);
|
|
74
|
+
};
|
|
75
|
+
table.resetRowPinning = (defaultState) => {
|
|
76
|
+
var _a;
|
|
77
|
+
return table.setRowPinning(
|
|
78
|
+
defaultState ? getDefaultRowPinningState() : ((_a = table.initialState) == null ? void 0 : _a.rowPinning) ?? getDefaultRowPinningState()
|
|
79
|
+
);
|
|
80
|
+
};
|
|
81
|
+
table.getIsSomeRowsPinned = (position) => {
|
|
82
|
+
var _a, _b, _c;
|
|
83
|
+
const pinningState = table.getState().rowPinning;
|
|
84
|
+
if (!position) {
|
|
85
|
+
return Boolean(((_a = pinningState.top) == null ? void 0 : _a.length) || ((_b = pinningState.bottom) == null ? void 0 : _b.length));
|
|
86
|
+
}
|
|
87
|
+
return Boolean((_c = pinningState[position]) == null ? void 0 : _c.length);
|
|
88
|
+
};
|
|
89
|
+
table._getPinnedRows = (visibleRows, pinnedRowIds, position) => {
|
|
90
|
+
const rows = table.options.keepPinnedRows ?? true ? (
|
|
91
|
+
//get all rows that are pinned even if they would not be otherwise visible
|
|
92
|
+
//account for expanded parent rows, but not pagination or filtering
|
|
93
|
+
(pinnedRowIds ?? []).map((rowId) => {
|
|
94
|
+
const row = table.getRow(rowId, true);
|
|
95
|
+
return row.getIsAllParentsExpanded() ? row : null;
|
|
96
|
+
})
|
|
97
|
+
) : (
|
|
98
|
+
//else get only visible rows that are pinned
|
|
99
|
+
(pinnedRowIds ?? []).map(
|
|
100
|
+
(rowId) => visibleRows.find((row) => row.id === rowId)
|
|
101
|
+
)
|
|
102
|
+
);
|
|
103
|
+
return rows.filter(Boolean).map((d) => ({ ...d, position }));
|
|
104
|
+
};
|
|
105
|
+
table.getTopRows = memo(
|
|
106
|
+
() => [table.getRowModel().rows, table.getState().rowPinning.top],
|
|
107
|
+
(allRows, topPinnedRowIds) => table._getPinnedRows(allRows, topPinnedRowIds, "top"),
|
|
108
|
+
getMemoOptions(table.options, "debugRows", "getTopRows")
|
|
109
|
+
);
|
|
110
|
+
table.getBottomRows = memo(
|
|
111
|
+
() => [table.getRowModel().rows, table.getState().rowPinning.bottom],
|
|
112
|
+
(allRows, bottomPinnedRowIds) => table._getPinnedRows(allRows, bottomPinnedRowIds, "bottom"),
|
|
113
|
+
getMemoOptions(table.options, "debugRows", "getBottomRows")
|
|
114
|
+
);
|
|
115
|
+
table.getCenterRows = memo(
|
|
116
|
+
() => [
|
|
117
|
+
table.getRowModel().rows,
|
|
118
|
+
table.getState().rowPinning.top,
|
|
119
|
+
table.getState().rowPinning.bottom
|
|
120
|
+
],
|
|
121
|
+
(allRows, top, bottom) => {
|
|
122
|
+
const topAndBottom = /* @__PURE__ */ new Set([...top ?? [], ...bottom ?? []]);
|
|
123
|
+
return allRows.filter((d) => !topAndBottom.has(d.id));
|
|
124
|
+
},
|
|
125
|
+
getMemoOptions(table.options, "debugRows", "getCenterRows")
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
export {
|
|
130
|
+
RowPinning
|
|
131
|
+
};
|
|
132
|
+
//# sourceMappingURL=RowPinning.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RowPinning.js","sources":["../../../src/features/RowPinning.ts"],"sourcesContent":["import {\n OnChangeFn,\n Updater,\n Table,\n Row,\n RowData,\n TableFeature,\n} from '../types'\nimport { getMemoOptions, makeStateUpdater, memo } from '../utils'\n\nexport type RowPinningPosition = false | 'top' | 'bottom'\n\nexport interface RowPinningState {\n bottom?: string[]\n top?: string[]\n}\n\nexport interface RowPinningTableState {\n rowPinning: RowPinningState\n}\n\nexport interface RowPinningOptions<TData extends RowData> {\n /**\n * Enables/disables row pinning for the table. Defaults to `true`.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#enablerowpinning)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-pinning)\n */\n enableRowPinning?: boolean | ((row: Row<TData>) => boolean)\n /**\n * When `false`, pinned rows will not be visible if they are filtered or paginated out of the table. When `true`, pinned rows will always be visible regardless of filtering or pagination. Defaults to `true`.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#keeppinnedrows)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-pinning)\n */\n keepPinnedRows?: boolean\n /**\n * If provided, this function will be called with an `updaterFn` when `state.rowPinning` changes. This overrides the default internal state management, so you will also need to supply `state.rowPinning` from your own managed state.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#onrowpinningchange)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/onrowpinningchange)\n */\n onRowPinningChange?: OnChangeFn<RowPinningState>\n}\n\nexport interface RowPinningDefaultOptions {\n onRowPinningChange: OnChangeFn<RowPinningState>\n}\n\nexport interface RowPinningRow {\n /**\n * Returns whether or not the row can be pinned.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#getcanpin-1)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-pinning)\n */\n getCanPin: () => boolean\n /**\n * Returns the pinned position of the row. (`'top'`, `'bottom'` or `false`)\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#getispinned-1)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-pinning)\n */\n getIsPinned: () => RowPinningPosition\n /**\n * Returns the numeric pinned index of the row within a pinned row group.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#getpinnedindex-1)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-pinning)\n */\n getPinnedIndex: () => number\n /**\n * Pins a row to the `'top'` or `'bottom'`, or unpins the row to the center if `false` is passed.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#pin-1)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-pinning)\n */\n pin: (\n position: RowPinningPosition,\n includeLeafRows?: boolean,\n includeParentRows?: boolean\n ) => void\n}\n\nexport interface RowPinningInstance<TData extends RowData> {\n _getPinnedRows: (\n visiblePinnedRows: Array<Row<TData>>,\n pinnedRowIds: Array<string> | undefined,\n position: 'top' | 'bottom'\n ) => Row<TData>[]\n /**\n * Returns all bottom pinned rows.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#getbottomrows)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-pinning)\n */\n getBottomRows: () => Row<TData>[]\n /**\n * Returns all rows that are not pinned to the top or bottom.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#getcenterrows)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-pinning)\n */\n getCenterRows: () => Row<TData>[]\n /**\n * Returns whether or not any rows are pinned. Optionally specify to only check for pinned rows in either the `top` or `bottom` position.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#getissomerowspinned)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-pinning)\n */\n getIsSomeRowsPinned: (position?: RowPinningPosition) => boolean\n /**\n * Returns all top pinned rows.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#gettoprows)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-pinning)\n */\n getTopRows: () => Row<TData>[]\n /**\n * Resets the **rowPinning** state to `initialState.rowPinning`, or `true` can be passed to force a default blank state reset to `{ top: [], bottom: [], }`.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#resetrowpinning)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-pinning)\n */\n resetRowPinning: (defaultState?: boolean) => void\n /**\n * Sets or updates the `state.rowPinning` state.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-pinning#setrowpinning)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-pinning)\n */\n setRowPinning: (updater: Updater<RowPinningState>) => void\n}\n\n//\n\nconst getDefaultRowPinningState = (): RowPinningState => ({\n top: [],\n bottom: [],\n})\n\nexport const RowPinning: TableFeature = {\n _getInitialState: (state): RowPinningTableState => {\n return {\n rowPinning: getDefaultRowPinningState(),\n ...state,\n }\n },\n\n _getDefaultOptions: <TData extends RowData>(\n table: Table<TData>\n ): RowPinningDefaultOptions => {\n return {\n onRowPinningChange: makeStateUpdater('rowPinning', table),\n }\n },\n\n _createRow: <TData extends RowData>(\n row: Row<TData>,\n table: Table<TData>\n ): void => {\n row.pin = (position, includeLeafRows, includeParentRows) => {\n const leafRowIds = includeLeafRows\n ? row.getLeafRows().map(({ id }) => id)\n : []\n const parentRowIds = includeParentRows\n ? row.getParentRows().map(({ id }) => id)\n : []\n const rowIds = new Set([...parentRowIds, row.id, ...leafRowIds])\n\n table.setRowPinning(old => {\n if (position === 'bottom') {\n return {\n top: (old?.top ?? []).filter(d => !rowIds?.has(d)),\n bottom: [\n ...(old?.bottom ?? []).filter(d => !rowIds?.has(d)),\n ...Array.from(rowIds),\n ],\n }\n }\n\n if (position === 'top') {\n return {\n top: [\n ...(old?.top ?? []).filter(d => !rowIds?.has(d)),\n ...Array.from(rowIds),\n ],\n bottom: (old?.bottom ?? []).filter(d => !rowIds?.has(d)),\n }\n }\n\n return {\n top: (old?.top ?? []).filter(d => !rowIds?.has(d)),\n bottom: (old?.bottom ?? []).filter(d => !rowIds?.has(d)),\n }\n })\n }\n row.getCanPin = () => {\n const { enableRowPinning, enablePinning } = table.options\n if (typeof enableRowPinning === 'function') {\n return enableRowPinning(row)\n }\n return enableRowPinning ?? enablePinning ?? true\n }\n row.getIsPinned = () => {\n const rowIds = [row.id]\n\n const { top, bottom } = table.getState().rowPinning\n\n const isTop = rowIds.some(d => top?.includes(d))\n const isBottom = rowIds.some(d => bottom?.includes(d))\n\n return isTop ? 'top' : isBottom ? 'bottom' : false\n }\n row.getPinnedIndex = () => {\n const position = row.getIsPinned()\n if (!position) return -1\n\n const visiblePinnedRowIds = (\n position === 'top' ? table.getTopRows() : table.getBottomRows()\n )?.map(({ id }) => id)\n\n return visiblePinnedRowIds?.indexOf(row.id) ?? -1\n }\n },\n\n _createTable: <TData extends RowData>(table: Table<TData>): void => {\n table.setRowPinning = updater => table.options.onRowPinningChange?.(updater)\n\n table.resetRowPinning = defaultState =>\n table.setRowPinning(\n defaultState\n ? getDefaultRowPinningState()\n : table.initialState?.rowPinning ?? getDefaultRowPinningState()\n )\n\n table.getIsSomeRowsPinned = position => {\n const pinningState = table.getState().rowPinning\n\n if (!position) {\n return Boolean(pinningState.top?.length || pinningState.bottom?.length)\n }\n return Boolean(pinningState[position]?.length)\n }\n\n table._getPinnedRows = (visibleRows, pinnedRowIds, position) => {\n const rows =\n table.options.keepPinnedRows ?? true\n ? //get all rows that are pinned even if they would not be otherwise visible\n //account for expanded parent rows, but not pagination or filtering\n (pinnedRowIds ?? []).map(rowId => {\n const row = table.getRow(rowId, true)\n return row.getIsAllParentsExpanded() ? row : null\n })\n : //else get only visible rows that are pinned\n (pinnedRowIds ?? []).map(\n rowId => visibleRows.find(row => row.id === rowId)!\n )\n\n return rows.filter(Boolean).map(d => ({ ...d, position })) as Row<TData>[]\n }\n\n table.getTopRows = memo(\n () => [table.getRowModel().rows, table.getState().rowPinning.top],\n (allRows, topPinnedRowIds) =>\n table._getPinnedRows(allRows, topPinnedRowIds, 'top'),\n getMemoOptions(table.options, 'debugRows', 'getTopRows')\n )\n\n table.getBottomRows = memo(\n () => [table.getRowModel().rows, table.getState().rowPinning.bottom],\n (allRows, bottomPinnedRowIds) =>\n table._getPinnedRows(allRows, bottomPinnedRowIds, 'bottom'),\n getMemoOptions(table.options, 'debugRows', 'getBottomRows')\n )\n\n table.getCenterRows = memo(\n () => [\n table.getRowModel().rows,\n table.getState().rowPinning.top,\n table.getState().rowPinning.bottom,\n ],\n (allRows, top, bottom) => {\n const topAndBottom = new Set([...(top ?? []), ...(bottom ?? [])])\n return allRows.filter(d => !topAndBottom.has(d.id))\n },\n getMemoOptions(table.options, 'debugRows', 'getCenterRows')\n )\n },\n}\n"],"names":[],"mappings":";AA2HA,MAAM,4BAA4B,OAAwB;AAAA,EACxD,KAAK,CAAC;AAAA,EACN,QAAQ,CAAC;AACX;AAEO,MAAM,aAA2B;AAAA,EACtC,kBAAkB,CAAC,UAAgC;AAC1C,WAAA;AAAA,MACL,YAAY,0BAA0B;AAAA,MACtC,GAAG;AAAA,IAAA;AAAA,EAEP;AAAA,EAEA,oBAAoB,CAClB,UAC6B;AACtB,WAAA;AAAA,MACL,oBAAoB,iBAAiB,cAAc,KAAK;AAAA,IAAA;AAAA,EAE5D;AAAA,EAEA,YAAY,CACV,KACA,UACS;AACT,QAAI,MAAM,CAAC,UAAU,iBAAiB,sBAAsB;AAC1D,YAAM,aAAa,kBACf,IAAI,YAAc,EAAA,IAAI,CAAC,EAAE,GAAG,MAAM,EAAE,IACpC,CAAA;AACJ,YAAM,eAAe,oBACjB,IAAI,cAAgB,EAAA,IAAI,CAAC,EAAE,GAAG,MAAM,EAAE,IACtC,CAAA;AACE,YAAA,SAAa,oBAAA,IAAI,CAAC,GAAG,cAAc,IAAI,IAAI,GAAG,UAAU,CAAC;AAE/D,YAAM,cAAc,CAAO,QAAA;AACzB,YAAI,aAAa,UAAU;AAClB,iBAAA;AAAA,YACL,OAAM,2BAAK,QAAO,IAAI,OAAO,CAAA,MAAK,EAAC,iCAAQ,IAAI,GAAE;AAAA,YACjD,QAAQ;AAAA,cACN,KAAI,2BAAK,WAAU,CAAA,GAAI,OAAO,CAAA,MAAK,EAAC,iCAAQ,IAAI,GAAE;AAAA,cAClD,GAAG,MAAM,KAAK,MAAM;AAAA,YACtB;AAAA,UAAA;AAAA,QAEJ;AAEA,YAAI,aAAa,OAAO;A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uBACR,MAAM,eAAe,SAAS,oBAAoB,QAAQ;AAAA,MAC5D,eAAe,MAAM,SAAS,aAAa,eAAe;AAAA,IAAA;AAG5D,UAAM,gBAAgB;AAAA,MACpB,MAAM;AAAA,QACJ,MAAM,cAAc;AAAA,QACpB,MAAM,WAAW,WAAW;AAAA,QAC5B,MAAM,WAAW,WAAW;AAAA,MAC9B;AAAA,MACA,CAAC,SAAS,KAAK,WAAW;AACxB,cAAM,eAAe,oBAAI,IAAI,CAAC,GAAI,OAAO,CAAA,GAAK,GAAI,UAAU,CAAG,CAAA,CAAC;AACzD,eAAA,QAAQ,OAAO,CAAK,MAAA,CAAC,aAAa,IAAI,EAAE,EAAE,CAAC;AAAA,MACpD;AAAA,MACA,eAAe,MAAM,SAAS,aAAa,eAAe;AAAA,IAAA;AAAA,EAE9D;AACF;"}
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import { makeStateUpdater, memo, getMemoOptions } from "../utils.js";
|
|
2
|
+
const RowSelection = {
|
|
3
|
+
_getInitialState: (state) => {
|
|
4
|
+
return {
|
|
5
|
+
rowSelection: {},
|
|
6
|
+
...state
|
|
7
|
+
};
|
|
8
|
+
},
|
|
9
|
+
_getDefaultOptions: (table) => {
|
|
10
|
+
return {
|
|
11
|
+
onRowSelectionChange: makeStateUpdater("rowSelection", table),
|
|
12
|
+
enableRowSelection: true,
|
|
13
|
+
enableMultiRowSelection: true,
|
|
14
|
+
enableSubRowSelection: true
|
|
15
|
+
// enableGroupingRowSelection: false,
|
|
16
|
+
// isAdditiveSelectEvent: (e: unknown) => !!e.metaKey,
|
|
17
|
+
// isInclusiveSelectEvent: (e: unknown) => !!e.shiftKey,
|
|
18
|
+
};
|
|
19
|
+
},
|
|
20
|
+
_createTable: (table) => {
|
|
21
|
+
table.setRowSelection = (updater) => {
|
|
22
|
+
var _a, _b;
|
|
23
|
+
return (_b = (_a = table.options).onRowSelectionChange) == null ? void 0 : _b.call(_a, updater);
|
|
24
|
+
};
|
|
25
|
+
table.resetRowSelection = (defaultState) => table.setRowSelection(
|
|
26
|
+
defaultState ? {} : table.initialState.rowSelection ?? {}
|
|
27
|
+
);
|
|
28
|
+
table.toggleAllRowsSelected = (value) => {
|
|
29
|
+
table.setRowSelection((old) => {
|
|
30
|
+
value = typeof value !== "undefined" ? value : !table.getIsAllRowsSelected();
|
|
31
|
+
const rowSelection = { ...old };
|
|
32
|
+
const preGroupedFlatRows = table.getPreGroupedRowModel().flatRows;
|
|
33
|
+
if (value) {
|
|
34
|
+
preGroupedFlatRows.forEach((row) => {
|
|
35
|
+
if (!row.getCanSelect()) {
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
rowSelection[row.id] = true;
|
|
39
|
+
});
|
|
40
|
+
} else {
|
|
41
|
+
preGroupedFlatRows.forEach((row) => {
|
|
42
|
+
delete rowSelection[row.id];
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
return rowSelection;
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
table.toggleAllPageRowsSelected = (value) => table.setRowSelection((old) => {
|
|
49
|
+
const resolvedValue = typeof value !== "undefined" ? value : !table.getIsAllPageRowsSelected();
|
|
50
|
+
const rowSelection = { ...old };
|
|
51
|
+
table.getRowModel().rows.forEach((row) => {
|
|
52
|
+
mutateRowIsSelected(rowSelection, row.id, resolvedValue, true, table);
|
|
53
|
+
});
|
|
54
|
+
return rowSelection;
|
|
55
|
+
});
|
|
56
|
+
table.getPreSelectedRowModel = () => table.getCoreRowModel();
|
|
57
|
+
table.getSelectedRowModel = memo(
|
|
58
|
+
() => [table.getState().rowSelection, table.getCoreRowModel()],
|
|
59
|
+
(rowSelection, rowModel) => {
|
|
60
|
+
if (!Object.keys(rowSelection).length) {
|
|
61
|
+
return {
|
|
62
|
+
rows: [],
|
|
63
|
+
flatRows: [],
|
|
64
|
+
rowsById: {}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
return selectRowsFn(table, rowModel);
|
|
68
|
+
},
|
|
69
|
+
getMemoOptions(table.options, "debugTable", "getSelectedRowModel")
|
|
70
|
+
);
|
|
71
|
+
table.getFilteredSelectedRowModel = memo(
|
|
72
|
+
() => [table.getState().rowSelection, table.getFilteredRowModel()],
|
|
73
|
+
(rowSelection, rowModel) => {
|
|
74
|
+
if (!Object.keys(rowSelection).length) {
|
|
75
|
+
return {
|
|
76
|
+
rows: [],
|
|
77
|
+
flatRows: [],
|
|
78
|
+
rowsById: {}
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
return selectRowsFn(table, rowModel);
|
|
82
|
+
},
|
|
83
|
+
getMemoOptions(table.options, "debugTable", "getFilteredSelectedRowModel")
|
|
84
|
+
);
|
|
85
|
+
table.getGroupedSelectedRowModel = memo(
|
|
86
|
+
() => [table.getState().rowSelection, table.getSortedRowModel()],
|
|
87
|
+
(rowSelection, rowModel) => {
|
|
88
|
+
if (!Object.keys(rowSelection).length) {
|
|
89
|
+
return {
|
|
90
|
+
rows: [],
|
|
91
|
+
flatRows: [],
|
|
92
|
+
rowsById: {}
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
return selectRowsFn(table, rowModel);
|
|
96
|
+
},
|
|
97
|
+
getMemoOptions(table.options, "debugTable", "getGroupedSelectedRowModel")
|
|
98
|
+
);
|
|
99
|
+
table.getIsAllRowsSelected = () => {
|
|
100
|
+
const preGroupedFlatRows = table.getFilteredRowModel().flatRows;
|
|
101
|
+
const { rowSelection } = table.getState();
|
|
102
|
+
let isAllRowsSelected = Boolean(
|
|
103
|
+
preGroupedFlatRows.length && Object.keys(rowSelection).length
|
|
104
|
+
);
|
|
105
|
+
if (isAllRowsSelected) {
|
|
106
|
+
if (preGroupedFlatRows.some(
|
|
107
|
+
(row) => row.getCanSelect() && !rowSelection[row.id]
|
|
108
|
+
)) {
|
|
109
|
+
isAllRowsSelected = false;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return isAllRowsSelected;
|
|
113
|
+
};
|
|
114
|
+
table.getIsAllPageRowsSelected = () => {
|
|
115
|
+
const paginationFlatRows = table.getPaginationRowModel().flatRows.filter((row) => row.getCanSelect());
|
|
116
|
+
const { rowSelection } = table.getState();
|
|
117
|
+
let isAllPageRowsSelected = !!paginationFlatRows.length;
|
|
118
|
+
if (isAllPageRowsSelected && paginationFlatRows.some((row) => !rowSelection[row.id])) {
|
|
119
|
+
isAllPageRowsSelected = false;
|
|
120
|
+
}
|
|
121
|
+
return isAllPageRowsSelected;
|
|
122
|
+
};
|
|
123
|
+
table.getIsSomeRowsSelected = () => {
|
|
124
|
+
const totalSelected = Object.keys(
|
|
125
|
+
table.getState().rowSelection ?? {}
|
|
126
|
+
).length;
|
|
127
|
+
return totalSelected > 0 && totalSelected < table.getFilteredRowModel().flatRows.length;
|
|
128
|
+
};
|
|
129
|
+
table.getIsSomePageRowsSelected = () => {
|
|
130
|
+
const paginationFlatRows = table.getPaginationRowModel().flatRows;
|
|
131
|
+
return table.getIsAllPageRowsSelected() ? false : paginationFlatRows.filter((row) => row.getCanSelect()).some((d) => d.getIsSelected() || d.getIsSomeSelected());
|
|
132
|
+
};
|
|
133
|
+
table.getToggleAllRowsSelectedHandler = () => {
|
|
134
|
+
return (e) => {
|
|
135
|
+
table.toggleAllRowsSelected(
|
|
136
|
+
e.target.checked
|
|
137
|
+
);
|
|
138
|
+
};
|
|
139
|
+
};
|
|
140
|
+
table.getToggleAllPageRowsSelectedHandler = () => {
|
|
141
|
+
return (e) => {
|
|
142
|
+
table.toggleAllPageRowsSelected(
|
|
143
|
+
e.target.checked
|
|
144
|
+
);
|
|
145
|
+
};
|
|
146
|
+
};
|
|
147
|
+
},
|
|
148
|
+
_createRow: (row, table) => {
|
|
149
|
+
row.toggleSelected = (value, opts) => {
|
|
150
|
+
const isSelected = row.getIsSelected();
|
|
151
|
+
table.setRowSelection((old) => {
|
|
152
|
+
value = typeof value !== "undefined" ? value : !isSelected;
|
|
153
|
+
if (row.getCanSelect() && isSelected === value) {
|
|
154
|
+
return old;
|
|
155
|
+
}
|
|
156
|
+
const selectedRowIds = { ...old };
|
|
157
|
+
mutateRowIsSelected(
|
|
158
|
+
selectedRowIds,
|
|
159
|
+
row.id,
|
|
160
|
+
value,
|
|
161
|
+
(opts == null ? void 0 : opts.selectChildren) ?? true,
|
|
162
|
+
table
|
|
163
|
+
);
|
|
164
|
+
return selectedRowIds;
|
|
165
|
+
});
|
|
166
|
+
};
|
|
167
|
+
row.getIsSelected = () => {
|
|
168
|
+
const { rowSelection } = table.getState();
|
|
169
|
+
return isRowSelected(row, rowSelection);
|
|
170
|
+
};
|
|
171
|
+
row.getIsSomeSelected = () => {
|
|
172
|
+
const { rowSelection } = table.getState();
|
|
173
|
+
return isSubRowSelected(row, rowSelection) === "some";
|
|
174
|
+
};
|
|
175
|
+
row.getIsAllSubRowsSelected = () => {
|
|
176
|
+
const { rowSelection } = table.getState();
|
|
177
|
+
return isSubRowSelected(row, rowSelection) === "all";
|
|
178
|
+
};
|
|
179
|
+
row.getCanSelect = () => {
|
|
180
|
+
if (typeof table.options.enableRowSelection === "function") {
|
|
181
|
+
return table.options.enableRowSelection(row);
|
|
182
|
+
}
|
|
183
|
+
return table.options.enableRowSelection ?? true;
|
|
184
|
+
};
|
|
185
|
+
row.getCanSelectSubRows = () => {
|
|
186
|
+
if (typeof table.options.enableSubRowSelection === "function") {
|
|
187
|
+
return table.options.enableSubRowSelection(row);
|
|
188
|
+
}
|
|
189
|
+
return table.options.enableSubRowSelection ?? true;
|
|
190
|
+
};
|
|
191
|
+
row.getCanMultiSelect = () => {
|
|
192
|
+
if (typeof table.options.enableMultiRowSelection === "function") {
|
|
193
|
+
return table.options.enableMultiRowSelection(row);
|
|
194
|
+
}
|
|
195
|
+
return table.options.enableMultiRowSelection ?? true;
|
|
196
|
+
};
|
|
197
|
+
row.getToggleSelectedHandler = () => {
|
|
198
|
+
const canSelect = row.getCanSelect();
|
|
199
|
+
return (e) => {
|
|
200
|
+
var _a;
|
|
201
|
+
if (!canSelect) return;
|
|
202
|
+
row.toggleSelected(
|
|
203
|
+
(_a = e.target) == null ? void 0 : _a.checked
|
|
204
|
+
);
|
|
205
|
+
};
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
};
|
|
209
|
+
const mutateRowIsSelected = (selectedRowIds, id, value, includeChildren, table) => {
|
|
210
|
+
var _a;
|
|
211
|
+
const row = table.getRow(id, true);
|
|
212
|
+
if (value) {
|
|
213
|
+
if (!row.getCanMultiSelect()) {
|
|
214
|
+
Object.keys(selectedRowIds).forEach((key) => delete selectedRowIds[key]);
|
|
215
|
+
}
|
|
216
|
+
if (row.getCanSelect()) {
|
|
217
|
+
selectedRowIds[id] = true;
|
|
218
|
+
}
|
|
219
|
+
} else {
|
|
220
|
+
delete selectedRowIds[id];
|
|
221
|
+
}
|
|
222
|
+
if (includeChildren && ((_a = row.subRows) == null ? void 0 : _a.length) && row.getCanSelectSubRows()) {
|
|
223
|
+
row.subRows.forEach(
|
|
224
|
+
(row2) => mutateRowIsSelected(selectedRowIds, row2.id, value, includeChildren, table)
|
|
225
|
+
);
|
|
226
|
+
}
|
|
227
|
+
};
|
|
228
|
+
function selectRowsFn(table, rowModel) {
|
|
229
|
+
const rowSelection = table.getState().rowSelection;
|
|
230
|
+
const newSelectedFlatRows = [];
|
|
231
|
+
const newSelectedRowsById = {};
|
|
232
|
+
const recurseRows = (rows, depth = 0) => {
|
|
233
|
+
return rows.map((row) => {
|
|
234
|
+
var _a;
|
|
235
|
+
const isSelected = isRowSelected(row, rowSelection);
|
|
236
|
+
if (isSelected) {
|
|
237
|
+
newSelectedFlatRows.push(row);
|
|
238
|
+
newSelectedRowsById[row.id] = row;
|
|
239
|
+
}
|
|
240
|
+
if ((_a = row.subRows) == null ? void 0 : _a.length) {
|
|
241
|
+
row = {
|
|
242
|
+
...row,
|
|
243
|
+
subRows: recurseRows(row.subRows, depth + 1)
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
if (isSelected) {
|
|
247
|
+
return row;
|
|
248
|
+
}
|
|
249
|
+
}).filter(Boolean);
|
|
250
|
+
};
|
|
251
|
+
return {
|
|
252
|
+
rows: recurseRows(rowModel.rows),
|
|
253
|
+
flatRows: newSelectedFlatRows,
|
|
254
|
+
rowsById: newSelectedRowsById
|
|
255
|
+
};
|
|
256
|
+
}
|
|
257
|
+
function isRowSelected(row, selection) {
|
|
258
|
+
return selection[row.id] ?? false;
|
|
259
|
+
}
|
|
260
|
+
function isSubRowSelected(row, selection, table) {
|
|
261
|
+
var _a;
|
|
262
|
+
if (!((_a = row.subRows) == null ? void 0 : _a.length)) return false;
|
|
263
|
+
let allChildrenSelected = true;
|
|
264
|
+
let someSelected = false;
|
|
265
|
+
row.subRows.forEach((subRow) => {
|
|
266
|
+
if (someSelected && !allChildrenSelected) {
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
if (subRow.getCanSelect()) {
|
|
270
|
+
if (isRowSelected(subRow, selection)) {
|
|
271
|
+
someSelected = true;
|
|
272
|
+
} else {
|
|
273
|
+
allChildrenSelected = false;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
if (subRow.subRows && subRow.subRows.length) {
|
|
277
|
+
const subRowChildrenSelected = isSubRowSelected(subRow, selection);
|
|
278
|
+
if (subRowChildrenSelected === "all") {
|
|
279
|
+
someSelected = true;
|
|
280
|
+
} else if (subRowChildrenSelected === "some") {
|
|
281
|
+
someSelected = true;
|
|
282
|
+
allChildrenSelected = false;
|
|
283
|
+
} else {
|
|
284
|
+
allChildrenSelected = false;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
});
|
|
288
|
+
return allChildrenSelected ? "all" : someSelected ? "some" : false;
|
|
289
|
+
}
|
|
290
|
+
export {
|
|
291
|
+
RowSelection,
|
|
292
|
+
isRowSelected,
|
|
293
|
+
isSubRowSelected,
|
|
294
|
+
selectRowsFn
|
|
295
|
+
};
|
|
296
|
+
//# sourceMappingURL=RowSelection.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RowSelection.js","sources":["../../../src/features/RowSelection.ts"],"sourcesContent":["import {\n OnChangeFn,\n Table,\n Row,\n RowModel,\n Updater,\n RowData,\n TableFeature,\n} from '../types'\nimport { getMemoOptions, makeStateUpdater, memo } from '../utils'\n\nexport type RowSelectionState = Record<string, boolean>\n\nexport interface RowSelectionTableState {\n rowSelection: RowSelectionState\n}\n\nexport interface RowSelectionOptions<TData extends RowData> {\n /**\n * - Enables/disables multiple row selection for all rows in the table OR\n * - A function that given a row, returns whether to enable/disable multiple row selection for that row's children/grandchildren\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#enablemultirowselection)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n enableMultiRowSelection?: boolean | ((row: Row<TData>) => boolean)\n /**\n * - Enables/disables row selection for all rows in the table OR\n * - A function that given a row, returns whether to enable/disable row selection for that row\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#enablerowselection)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n enableRowSelection?: boolean | ((row: Row<TData>) => boolean)\n /**\n * Enables/disables automatic sub-row selection when a parent row is selected, or a function that enables/disables automatic sub-row selection for each row.\n * (Use in combination with expanding or grouping features)\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#enablesubrowselection)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n enableSubRowSelection?: boolean | ((row: Row<TData>) => boolean)\n /**\n * If provided, this function will be called with an `updaterFn` when `state.rowSelection` changes. This overrides the default internal state management, so you will need to persist the state change either fully or partially outside of the table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#onrowselectionchange)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n onRowSelectionChange?: OnChangeFn<RowSelectionState>\n // enableGroupingRowSelection?:\n // | boolean\n // | ((\n // row: Row<TData>\n // ) => boolean)\n // isAdditiveSelectEvent?: (e: unknown) => boolean\n // isInclusiveSelectEvent?: (e: unknown) => boolean\n // selectRowsFn?: (\n // table: Table<TData>,\n // rowModel: RowModel<TData>\n // ) => RowModel<TData>\n}\n\nexport interface RowSelectionRow {\n /**\n * Returns whether or not the row can multi-select.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getcanmultiselect)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n getCanMultiSelect: () => boolean\n /**\n * Returns whether or not the row can be selected.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getcanselect)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n getCanSelect: () => boolean\n /**\n * Returns whether or not the row can select sub rows automatically when the parent row is selected.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getcanselectsubrows)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n getCanSelectSubRows: () => boolean\n /**\n * Returns whether or not all of the row's sub rows are selected.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getisallsubrowsselected)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n getIsAllSubRowsSelected: () => boolean\n /**\n * Returns whether or not the row is selected.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getisselected)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n getIsSelected: () => boolean\n /**\n * Returns whether or not some of the row's sub rows are selected.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getissomeselected)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n getIsSomeSelected: () => boolean\n /**\n * Returns a handler that can be used to toggle the row.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#gettoggleselectedhandler)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n getToggleSelectedHandler: () => (event: unknown) => void\n /**\n * Selects/deselects the row.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#toggleselected)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n toggleSelected: (value?: boolean, opts?: { selectChildren?: boolean }) => void\n}\n\nexport interface RowSelectionInstance<TData extends RowData> {\n /**\n * Returns the row model of all rows that are selected after filtering has been applied.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getfilteredselectedrowmodel)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n getFilteredSelectedRowModel: () => RowModel<TData>\n /**\n * Returns the row model of all rows that are selected after grouping has been applied.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getgroupedselectedrowmodel)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n getGroupedSelectedRowModel: () => RowModel<TData>\n /**\n * Returns whether or not all rows on the current page are selected.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getisallpagerowsselected)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n getIsAllPageRowsSelected: () => boolean\n /**\n * Returns whether or not all rows in the table are selected.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getisallrowsselected)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n getIsAllRowsSelected: () => boolean\n /**\n * Returns whether or not any rows on the current page are selected.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getissomepagerowsselected)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n getIsSomePageRowsSelected: () => boolean\n /**\n * Returns whether or not any rows in the table are selected.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getissomerowsselected)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n getIsSomeRowsSelected: () => boolean\n /**\n * Returns the core row model of all rows before row selection has been applied.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getpreselectedrowmodel)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n getPreSelectedRowModel: () => RowModel<TData>\n /**\n * Returns the row model of all rows that are selected.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#getselectedrowmodel)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n getSelectedRowModel: () => RowModel<TData>\n /**\n * Returns a handler that can be used to toggle all rows on the current page.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#gettoggleallpagerowsselectedhandler)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n getToggleAllPageRowsSelectedHandler: () => (event: unknown) => void\n /**\n * Returns a handler that can be used to toggle all rows in the table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#gettoggleallrowsselectedhandler)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n getToggleAllRowsSelectedHandler: () => (event: unknown) => void\n /**\n * Resets the **rowSelection** state to the `initialState.rowSelection`, or `true` can be passed to force a default blank state reset to `{}`.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#resetrowselection)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n resetRowSelection: (defaultState?: boolean) => void\n /**\n * Sets or updates the `state.rowSelection` state.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#setrowselection)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n setRowSelection: (updater: Updater<RowSelectionState>) => void\n /**\n * Selects/deselects all rows on the current page.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#toggleallpagerowsselected)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n toggleAllPageRowsSelected: (value?: boolean) => void\n /**\n * Selects/deselects all rows in the table.\n * @link [API Docs](https://tanstack.com/table/v8/docs/api/features/row-selection#toggleallrowsselected)\n * @link [Guide](https://tanstack.com/table/v8/docs/guide/row-selection)\n */\n toggleAllRowsSelected: (value?: boolean) => void\n}\n\n//\n\nexport const RowSelection: TableFeature = {\n _getInitialState: (state): RowSelectionTableState => {\n return {\n rowSelection: {},\n ...state,\n }\n },\n\n _getDefaultOptions: <TData extends RowData>(\n table: Table<TData>\n ): RowSelectionOptions<TData> => {\n return {\n onRowSelectionChange: makeStateUpdater('rowSelection', table),\n enableRowSelection: true,\n enableMultiRowSelection: true,\n enableSubRowSelection: true,\n // enableGroupingRowSelection: false,\n // isAdditiveSelectEvent: (e: unknown) => !!e.metaKey,\n // isInclusiveSelectEvent: (e: unknown) => !!e.shiftKey,\n }\n },\n\n _createTable: <TData extends RowData>(table: Table<TData>): void => {\n table.setRowSelection = updater =>\n table.options.onRowSelectionChange?.(updater)\n table.resetRowSelection = defaultState =>\n table.setRowSelection(\n defaultState ? {} : table.initialState.rowSelection ?? {}\n )\n table.toggleAllRowsSelected = value => {\n table.setRowSelection(old => {\n value =\n typeof value !== 'undefined' ? value : !table.getIsAllRowsSelected()\n\n const rowSelection = { ...old }\n\n const preGroupedFlatRows = table.getPreGroupedRowModel().flatRows\n\n // We don't use `mutateRowIsSelected` here for performance reasons.\n // All of the rows are flat already, so it wouldn't be worth it\n if (value) {\n preGroupedFlatRows.forEach(row => {\n if (!row.getCanSelect()) {\n return\n }\n rowSelection[row.id] = true\n })\n } else {\n preGroupedFlatRows.forEach(row => {\n delete rowSelection[row.id]\n })\n }\n\n return rowSelection\n })\n }\n table.toggleAllPageRowsSelected = value =>\n table.setRowSelection(old => {\n const resolvedValue =\n typeof value !== 'undefined'\n ? value\n : !table.getIsAllPageRowsSelected()\n\n const rowSelection: RowSelectionState = { ...old }\n\n table.getRowModel().rows.forEach(row => {\n mutateRowIsSelected(rowSelection, row.id, resolvedValue, true, table)\n })\n\n return rowSelection\n })\n\n // addRowSelectionRange: rowId => {\n // const {\n // rows,\n // rowsById,\n // options: { selectGroupingRows, selectSubRows },\n // } = table\n\n // const findSelectedRow = (rows: Row[]) => {\n // let found\n // rows.find(d => {\n // if (d.getIsSelected()) {\n // found = d\n // return true\n // }\n // const subFound = findSelectedRow(d.subRows || [])\n // if (subFound) {\n // found = subFound\n // return true\n // }\n // return false\n // })\n // return found\n // }\n\n // const firstRow = findSelectedRow(rows) || rows[0]\n // const lastRow = rowsById[rowId]\n\n // let include = false\n // const selectedRowIds = {}\n\n // const addRow = (row: Row) => {\n // mutateRowIsSelected(selectedRowIds, row.id, true, {\n // rowsById,\n // selectGroupingRows: selectGroupingRows!,\n // selectSubRows: selectSubRows!,\n // })\n // }\n\n // table.rows.forEach(row => {\n // const isFirstRow = row.id === firstRow.id\n // const isLastRow = row.id === lastRow.id\n\n // if (isFirstRow || isLastRow) {\n // if (!include) {\n // include = true\n // } else if (include) {\n // addRow(row)\n // include = false\n // }\n // }\n\n // if (include) {\n // addRow(row)\n // }\n // })\n\n // table.setRowSelection(selectedRowIds)\n // },\n table.getPreSelectedRowModel = () => table.getCoreRowModel()\n table.getSelectedRowModel = memo(\n () => [table.getState().rowSelection, table.getCoreRowModel()],\n (rowSelection, rowModel) => {\n if (!Object.keys(rowSelection).length) {\n return {\n rows: [],\n flatRows: [],\n rowsById: {},\n }\n }\n\n return selectRowsFn(table, rowModel)\n },\n getMemoOptions(table.options, 'debugTable', 'getSelectedRowModel')\n )\n\n table.getFilteredSelectedRowModel = memo(\n () => [table.getState().rowSelection, table.getFilteredRowModel()],\n (rowSelection, rowModel) => {\n if (!Object.keys(rowSelection).length) {\n return {\n rows: [],\n flatRows: [],\n rowsById: {},\n }\n }\n\n return selectRowsFn(table, rowModel)\n },\n getMemoOptions(table.options, 'debugTable', 'getFilteredSelectedRowModel')\n )\n\n table.getGroupedSelectedRowModel = memo(\n () => [table.getState().rowSelection, table.getSortedRowModel()],\n (rowSelection, rowModel) => {\n if (!Object.keys(rowSelection).length) {\n return {\n rows: [],\n flatRows: [],\n rowsById: {},\n }\n }\n\n return selectRowsFn(table, rowModel)\n },\n getMemoOptions(table.options, 'debugTable', 'getGroupedSelectedRowModel')\n )\n\n ///\n\n // getGroupingRowCanSelect: rowId => {\n // const row = table.getRow(rowId)\n\n // if (!row) {\n // throw new Error()\n // }\n\n // if (typeof table.options.enableGroupingRowSelection === 'function') {\n // return table.options.enableGroupingRowSelection(row)\n // }\n\n // return table.options.enableGroupingRowSelection ?? false\n // },\n\n table.getIsAllRowsSelected = () => {\n const preGroupedFlatRows = table.getFilteredRowModel().flatRows\n const { rowSelection } = table.getState()\n\n let isAllRowsSelected = Boolean(\n preGroupedFlatRows.length && Object.keys(rowSelection).length\n )\n\n if (isAllRowsSelected) {\n if (\n preGroupedFlatRows.some(\n row => row.getCanSelect() && !rowSelection[row.id]\n )\n ) {\n isAllRowsSelected = false\n }\n }\n\n return isAllRowsSelected\n }\n\n table.getIsAllPageRowsSelected = () => {\n const paginationFlatRows = table\n .getPaginationRowModel()\n .flatRows.filter(row => row.getCanSelect())\n const { rowSelection } = table.getState()\n\n let isAllPageRowsSelected = !!paginationFlatRows.length\n\n if (\n isAllPageRowsSelected &&\n paginationFlatRows.some(row => !rowSelection[row.id])\n ) {\n isAllPageRowsSelected = false\n }\n\n return isAllPageRowsSelected\n }\n\n table.getIsSomeRowsSelected = () => {\n const totalSelected = Object.keys(\n table.getState().rowSelection ?? {}\n ).length\n return (\n totalSelected > 0 &&\n totalSelected < table.getFilteredRowModel().flatRows.length\n )\n }\n\n table.getIsSomePageRowsSelected = () => {\n const paginationFlatRows = table.getPaginationRowModel().flatRows\n return table.getIsAllPageRowsSelected()\n ? false\n : paginationFlatRows\n .filter(row => row.getCanSelect())\n .some(d => d.getIsSelected() || d.getIsSomeSelected())\n }\n\n table.getToggleAllRowsSelectedHandler = () => {\n return (e: unknown) => {\n table.toggleAllRowsSelected(\n ((e as MouseEvent).target as HTMLInputElement).checked\n )\n }\n }\n\n table.getToggleAllPageRowsSelectedHandler = () => {\n return (e: unknown) => {\n table.toggleAllPageRowsSelected(\n ((e as MouseEvent).target as HTMLInputElement).checked\n )\n }\n }\n },\n\n _createRow: <TData extends RowData>(\n row: Row<TData>,\n table: Table<TData>\n ): void => {\n row.toggleSelected = (value, opts) => {\n const isSelected = row.getIsSelected()\n\n table.setRowSelection(old => {\n value = typeof value !== 'undefined' ? value : !isSelected\n\n if (row.getCanSelect() && isSelected === value) {\n return old\n }\n\n const selectedRowIds = { ...old }\n\n mutateRowIsSelected(\n selectedRowIds,\n row.id,\n value,\n opts?.selectChildren ?? true,\n table\n )\n\n return selectedRowIds\n })\n }\n row.getIsSelected = () => {\n const { rowSelection } = table.getState()\n return isRowSelected(row, rowSelection)\n }\n\n row.getIsSomeSelected = () => {\n const { rowSelection } = table.getState()\n return isSubRowSelected(row, rowSelection, table) === 'some'\n }\n\n row.getIsAllSubRowsSelected = () => {\n const { rowSelection } = table.getState()\n return isSubRowSelected(row, rowSelection, table) === 'all'\n }\n\n row.getCanSelect = () => {\n if (typeof table.options.enableRowSelection === 'function') {\n return table.options.enableRowSelection(row)\n }\n\n return table.options.enableRowSelection ?? true\n }\n\n row.getCanSelectSubRows = () => {\n if (typeof table.options.enableSubRowSelection === 'function') {\n return table.options.enableSubRowSelection(row)\n }\n\n return table.options.enableSubRowSelection ?? true\n }\n\n row.getCanMultiSelect = () => {\n if (typeof table.options.enableMultiRowSelection === 'function') {\n return table.options.enableMultiRowSelection(row)\n }\n\n return table.options.enableMultiRowSelection ?? true\n }\n row.getToggleSelectedHandler = () => {\n const canSelect = row.getCanSelect()\n\n return (e: unknown) => {\n if (!canSelect) return\n row.toggleSelected(\n ((e as MouseEvent).target as HTMLInputElement)?.checked\n )\n }\n }\n },\n}\n\nconst mutateRowIsSelected = <TData extends RowData>(\n selectedRowIds: Record<string, boolean>,\n id: string,\n value: boolean,\n includeChildren: boolean,\n table: Table<TData>\n) => {\n const row = table.getRow(id, true)\n\n // const isGrouped = row.getIsGrouped()\n\n // if ( // TODO: enforce grouping row selection rules\n // !isGrouped ||\n // (isGrouped && table.options.enableGroupingRowSelection)\n // ) {\n if (value) {\n if (!row.getCanMultiSelect()) {\n Object.keys(selectedRowIds).forEach(key => delete selectedRowIds[key])\n }\n if (row.getCanSelect()) {\n selectedRowIds[id] = true\n }\n } else {\n delete selectedRowIds[id]\n }\n // }\n\n if (includeChildren && row.subRows?.length && row.getCanSelectSubRows()) {\n row.subRows.forEach(row =>\n mutateRowIsSelected(selectedRowIds, row.id, value, includeChildren, table)\n )\n }\n}\n\nexport function selectRowsFn<TData extends RowData>(\n table: Table<TData>,\n rowModel: RowModel<TData>\n): RowModel<TData> {\n const rowSelection = table.getState().rowSelection\n\n const newSelectedFlatRows: Row<TData>[] = []\n const newSelectedRowsById: Record<string, Row<TData>> = {}\n\n // Filters top level and nested rows\n const recurseRows = (rows: Row<TData>[], depth = 0): Row<TData>[] => {\n return rows\n .map(row => {\n const isSelected = isRowSelected(row, rowSelection)\n\n if (isSelected) {\n newSelectedFlatRows.push(row)\n newSelectedRowsById[row.id] = row\n }\n\n if (row.subRows?.length) {\n row = {\n ...row,\n subRows: recurseRows(row.subRows, depth + 1),\n }\n }\n\n if (isSelected) {\n return row\n }\n })\n .filter(Boolean) as Row<TData>[]\n }\n\n return {\n rows: recurseRows(rowModel.rows),\n flatRows: newSelectedFlatRows,\n rowsById: newSelectedRowsById,\n }\n}\n\nexport function isRowSelected<TData extends RowData>(\n row: Row<TData>,\n selection: Record<string, boolean>\n): boolean {\n return selection[row.id] ?? false\n}\n\nexport function isSubRowSelected<TData extends RowData>(\n row: Row<TData>,\n selection: Record<string, boolean>,\n table: Table<TData>\n): boolean | 'some' | 'all' {\n if (!row.subRows?.length) return false\n\n let allChildrenSelected = true\n let someSelected = false\n\n row.subRows.forEach(subRow => {\n // Bail out early if we know both of these\n if (someSelected && !allChildrenSelected) {\n return\n }\n\n if (subRow.getCanSelect()) {\n if (isRowSelected(subRow, selection)) {\n someSelected = true\n } else {\n allChildrenSelected = false\n }\n }\n\n // Check row selection of nested subrows\n if (subRow.subRows && subRow.subRows.length) {\n const subRowChildrenSelected = isSubRowSelected(subRow, selection, table)\n if (subRowChildrenSelected === 'all') {\n someSelected = true\n } else if (subRowChildrenSelected === 'some') {\n someSelected = true\n allChildrenSelected = false\n } else {\n allChildrenSelected = false\n }\n }\n })\n\n return allChildrenSelected ? 'all' : someSelected ? 'some' : false\n}\n"],"names":["row"],"mappings":";AAsMO,MAAM,eAA6B;AAAA,EACxC,kBAAkB,CAAC,UAAkC;AAC5C,WAAA;AAAA,MACL,cAAc,CAAC;AAAA,MACf,GAAG;AAAA,IAAA;AAAA,EAEP;AAAA,EAEA,oBAAoB,CAClB,UAC+B;AACxB,WAAA;AAAA,MACL,sBAAsB,iBAAiB,gBAAgB,KAAK;AAAA,MAC5D,oBAAoB;AAAA,MACpB,yBAAyB;AAAA,MACzB,uBAAuB;AAAA;AAAA;AAAA;AAAA,IAAA;AAAA,EAK3B;AAAA,EAEA,cAAc,CAAwB,UAA8B;AAClE,UAAM,kBAAkB,CAAA,YAAA;;AACtB,+BAAM,SAAQ,yBAAd,4BAAqC;AAAA;AACjC,UAAA,oBAAoB,kBACxB,MAAM;AAAA,MACJ,eAAe,CAAA,IAAK,MAAM,aAAa,gBAAgB,CAAC;AAAA,IAAA;AAE5D,UAAM,wBAAwB,CAAS,UAAA;AACrC,YAAM,gBAAgB,CAAO,QAAA;AAC3B,gBACE,OAAO,UAAU,cAAc,QAAQ,CAAC,MAAM;AAE1C,cAAA,eAAe,EAAE,GAAG;AAEpB,cAAA,qBAAqB,MAAM,sBAAA,EAAwB;AAIzD,YAAI,OAAO;AACT,6BAAmB,QAAQ,CAAO,QAAA;AAC5B,gBAAA,CAAC,IAAI,gBAAgB;AACvB;AAAA,YACF;AACa,yBAAA,IAAI,EAAE,IAAI;AAAA,UAAA,CACxB;AAAA,QAAA,OACI;AACL,6BAAmB,QAAQ,CAAO,QAAA;AACzB,mBAAA,aAAa,IAAI,EAAE;AAAA,UAAA,CAC3B;AAAA,QACH;AAEO,eAAA;AAAA,MAAA,CACR;AAAA,IAAA;AAEH,UAAM,4BAA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AAe,SAAS;AAC/D;"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { RowModel } from '..';
|
|
2
2
|
import { BuiltInSortingFn } from '../sortingFns';
|
|
3
3
|
import { OnChangeFn, Table, Row, Updater, RowData, SortingFns, TableFeature } from '../types';
|
|
4
|
+
|
|
4
5
|
export type SortDirection = 'asc' | 'desc';
|
|
5
6
|
export interface ColumnSort {
|
|
6
7
|
desc: boolean;
|