@tanstack/table-core 9.0.0-beta.18 → 9.0.0-beta.19
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/features/row-selection/rowSelectionFeature.cjs +49 -6
- package/dist/features/row-selection/rowSelectionFeature.cjs.map +1 -1
- package/dist/features/row-selection/rowSelectionFeature.js +50 -7
- package/dist/features/row-selection/rowSelectionFeature.js.map +1 -1
- package/dist/features/row-selection/rowSelectionFeature.types.d.cts +11 -3
- package/dist/features/row-selection/rowSelectionFeature.types.d.ts +11 -3
- package/dist/features/row-selection/rowSelectionFeature.utils.cjs +58 -49
- package/dist/features/row-selection/rowSelectionFeature.utils.cjs.map +1 -1
- package/dist/features/row-selection/rowSelectionFeature.utils.d.cts +23 -10
- package/dist/features/row-selection/rowSelectionFeature.utils.d.ts +23 -10
- package/dist/features/row-selection/rowSelectionFeature.utils.js +59 -51
- package/dist/features/row-selection/rowSelectionFeature.utils.js.map +1 -1
- package/dist/static-functions.cjs +1 -0
- package/dist/static-functions.d.cts +2 -2
- package/dist/static-functions.d.ts +2 -2
- package/dist/static-functions.js +2 -2
- package/package.json +1 -1
- package/src/features/row-selection/rowSelectionFeature.ts +24 -2
- package/src/features/row-selection/rowSelectionFeature.types.ts +13 -3
- package/src/features/row-selection/rowSelectionFeature.utils.ts +119 -68
|
@@ -36,8 +36,8 @@ const rowSelectionFeature = {
|
|
|
36
36
|
require_utils.assignTableAPIs("rowSelectionFeature", table, {
|
|
37
37
|
table_setRowSelection: { fn: (updater) => require_rowSelectionFeature_utils.table_setRowSelection(table, updater) },
|
|
38
38
|
table_resetRowSelection: { fn: (defaultState) => require_rowSelectionFeature_utils.table_resetRowSelection(table, defaultState) },
|
|
39
|
-
table_toggleAllRowsSelected: { fn: (value) => require_rowSelectionFeature_utils.table_toggleAllRowsSelected(table, value) },
|
|
40
|
-
table_toggleAllPageRowsSelected: { fn: (value) => require_rowSelectionFeature_utils.table_toggleAllPageRowsSelected(table, value) },
|
|
39
|
+
table_toggleAllRowsSelected: { fn: (value, opts) => require_rowSelectionFeature_utils.table_toggleAllRowsSelected(table, value, opts) },
|
|
40
|
+
table_toggleAllPageRowsSelected: { fn: (value, opts) => require_rowSelectionFeature_utils.table_toggleAllPageRowsSelected(table, value, opts) },
|
|
41
41
|
table_getPreSelectedRowModel: { fn: () => require_rowSelectionFeature_utils.table_getPreSelectedRowModel(table) },
|
|
42
42
|
table_getSelectedRowModel: {
|
|
43
43
|
fn: () => require_rowSelectionFeature_utils.table_getSelectedRowModel(table),
|
|
@@ -60,10 +60,53 @@ const rowSelectionFeature = {
|
|
|
60
60
|
return [(_table$atoms$rowSelec3 = table.atoms.rowSelection) === null || _table$atoms$rowSelec3 === void 0 ? void 0 : _table$atoms$rowSelec3.get(), table.getSortedRowModel()];
|
|
61
61
|
}
|
|
62
62
|
},
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
table_getSelectedRowIds: {
|
|
64
|
+
fn: () => require_rowSelectionFeature_utils.table_getSelectedRowIds(table),
|
|
65
|
+
memoDeps: () => {
|
|
66
|
+
var _table$atoms$rowSelec4;
|
|
67
|
+
return [(_table$atoms$rowSelec4 = table.atoms.rowSelection) === null || _table$atoms$rowSelec4 === void 0 ? void 0 : _table$atoms$rowSelec4.get()];
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
table_getIsAllRowsSelected: {
|
|
71
|
+
fn: () => require_rowSelectionFeature_utils.table_getIsAllRowsSelected(table),
|
|
72
|
+
memoDeps: () => {
|
|
73
|
+
var _table$atoms$rowSelec5;
|
|
74
|
+
return [
|
|
75
|
+
(_table$atoms$rowSelec5 = table.atoms.rowSelection) === null || _table$atoms$rowSelec5 === void 0 ? void 0 : _table$atoms$rowSelec5.get(),
|
|
76
|
+
table.getFilteredRowModel(),
|
|
77
|
+
table.options.enableRowSelection
|
|
78
|
+
];
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
table_getIsAllPageRowsSelected: {
|
|
82
|
+
fn: () => require_rowSelectionFeature_utils.table_getIsAllPageRowsSelected(table),
|
|
83
|
+
memoDeps: () => {
|
|
84
|
+
var _table$atoms$rowSelec6;
|
|
85
|
+
return [
|
|
86
|
+
(_table$atoms$rowSelec6 = table.atoms.rowSelection) === null || _table$atoms$rowSelec6 === void 0 ? void 0 : _table$atoms$rowSelec6.get(),
|
|
87
|
+
table.getPaginatedRowModel(),
|
|
88
|
+
table.options.enableRowSelection
|
|
89
|
+
];
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
table_getIsSomeRowsSelected: {
|
|
93
|
+
fn: () => require_rowSelectionFeature_utils.table_getIsSomeRowsSelected(table),
|
|
94
|
+
memoDeps: () => {
|
|
95
|
+
var _table$atoms$rowSelec7;
|
|
96
|
+
return [(_table$atoms$rowSelec7 = table.atoms.rowSelection) === null || _table$atoms$rowSelec7 === void 0 ? void 0 : _table$atoms$rowSelec7.get()];
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
table_getIsSomePageRowsSelected: {
|
|
100
|
+
fn: () => require_rowSelectionFeature_utils.table_getIsSomePageRowsSelected(table),
|
|
101
|
+
memoDeps: () => {
|
|
102
|
+
var _table$atoms$rowSelec8;
|
|
103
|
+
return [
|
|
104
|
+
(_table$atoms$rowSelec8 = table.atoms.rowSelection) === null || _table$atoms$rowSelec8 === void 0 ? void 0 : _table$atoms$rowSelec8.get(),
|
|
105
|
+
table.getPaginatedRowModel(),
|
|
106
|
+
table.options.enableRowSelection
|
|
107
|
+
];
|
|
108
|
+
}
|
|
109
|
+
},
|
|
67
110
|
table_getToggleAllRowsSelectedHandler: { fn: () => require_rowSelectionFeature_utils.table_getToggleAllRowsSelectedHandler(table) },
|
|
68
111
|
table_getToggleAllPageRowsSelectedHandler: { fn: () => require_rowSelectionFeature_utils.table_getToggleAllPageRowsSelectedHandler(table) }
|
|
69
112
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rowSelectionFeature.cjs","names":["getDefaultRowSelectionState","makeStateUpdater","row_toggleSelected","row_getIsSelected","row_getIsSomeSelected","row_getIsAllSubRowsSelected","row_getCanSelect","row_getCanSelectSubRows","row_getCanMultiSelect","row_getToggleSelectedHandler","table_setRowSelection","table_resetRowSelection","table_toggleAllRowsSelected","table_toggleAllPageRowsSelected","table_getPreSelectedRowModel","table_getSelectedRowModel","table_getFilteredSelectedRowModel","table_getGroupedSelectedRowModel","table_getIsAllRowsSelected","table_getIsAllPageRowsSelected","table_getIsSomeRowsSelected","table_getIsSomePageRowsSelected","table_getToggleAllRowsSelectedHandler","table_getToggleAllPageRowsSelectedHandler"],"sources":["../../../src/features/row-selection/rowSelectionFeature.ts"],"sourcesContent":["import {\n assignPrototypeAPIs,\n assignTableAPIs,\n makeStateUpdater,\n} from '../../utils'\nimport {\n getDefaultRowSelectionState,\n row_getCanMultiSelect,\n row_getCanSelect,\n row_getCanSelectSubRows,\n row_getIsAllSubRowsSelected,\n row_getIsSelected,\n row_getIsSomeSelected,\n row_getToggleSelectedHandler,\n row_toggleSelected,\n table_getFilteredSelectedRowModel,\n table_getGroupedSelectedRowModel,\n table_getIsAllPageRowsSelected,\n table_getIsAllRowsSelected,\n table_getIsSomePageRowsSelected,\n table_getIsSomeRowsSelected,\n table_getPreSelectedRowModel,\n table_getSelectedRowModel,\n table_getToggleAllPageRowsSelectedHandler,\n table_getToggleAllRowsSelectedHandler,\n table_resetRowSelection,\n table_setRowSelection,\n table_toggleAllPageRowsSelected,\n table_toggleAllRowsSelected,\n} from './rowSelectionFeature.utils'\nimport type { TableFeature } from '../../types/TableFeatures'\n\n/**\n * Feature that adds row selection state and APIs for row and page selection.\n */\nexport const rowSelectionFeature: TableFeature = {\n getInitialState: (initialState) => {\n return {\n rowSelection: getDefaultRowSelectionState(),\n ...initialState,\n }\n },\n\n getDefaultTableOptions: (table) => {\n return {\n onRowSelectionChange: makeStateUpdater('rowSelection', table),\n enableRowSelection: true,\n enableMultiRowSelection: true,\n enableSubRowSelection: true,\n }\n },\n\n assignRowPrototype: (prototype, table) => {\n assignPrototypeAPIs('rowSelectionFeature', prototype, table, {\n row_toggleSelected: {\n fn: (row, value, opts) => row_toggleSelected(row, value, opts),\n },\n row_getIsSelected: {\n fn: (row) => row_getIsSelected(row),\n },\n row_getIsSomeSelected: {\n fn: (row) => row_getIsSomeSelected(row),\n },\n row_getIsAllSubRowsSelected: {\n fn: (row) => row_getIsAllSubRowsSelected(row),\n },\n row_getCanSelect: {\n fn: (row) => row_getCanSelect(row),\n },\n row_getCanSelectSubRows: {\n fn: (row) => row_getCanSelectSubRows(row),\n },\n row_getCanMultiSelect: {\n fn: (row) => row_getCanMultiSelect(row),\n },\n row_getToggleSelectedHandler: {\n fn: (row) => row_getToggleSelectedHandler(row),\n },\n })\n },\n\n constructTableAPIs: (table) => {\n assignTableAPIs('rowSelectionFeature', table, {\n table_setRowSelection: {\n fn: (updater) => table_setRowSelection(table, updater),\n },\n table_resetRowSelection: {\n fn: (defaultState) => table_resetRowSelection(table, defaultState),\n },\n table_toggleAllRowsSelected: {\n fn: (value) => table_toggleAllRowsSelected(table, value),\n },\n table_toggleAllPageRowsSelected: {\n fn: (value)
|
|
1
|
+
{"version":3,"file":"rowSelectionFeature.cjs","names":["getDefaultRowSelectionState","makeStateUpdater","row_toggleSelected","row_getIsSelected","row_getIsSomeSelected","row_getIsAllSubRowsSelected","row_getCanSelect","row_getCanSelectSubRows","row_getCanMultiSelect","row_getToggleSelectedHandler","table_setRowSelection","table_resetRowSelection","table_toggleAllRowsSelected","table_toggleAllPageRowsSelected","table_getPreSelectedRowModel","table_getSelectedRowModel","table_getFilteredSelectedRowModel","table_getGroupedSelectedRowModel","table_getSelectedRowIds","table_getIsAllRowsSelected","table_getIsAllPageRowsSelected","table_getIsSomeRowsSelected","table_getIsSomePageRowsSelected","table_getToggleAllRowsSelectedHandler","table_getToggleAllPageRowsSelectedHandler"],"sources":["../../../src/features/row-selection/rowSelectionFeature.ts"],"sourcesContent":["import {\n assignPrototypeAPIs,\n assignTableAPIs,\n makeStateUpdater,\n} from '../../utils'\nimport {\n getDefaultRowSelectionState,\n row_getCanMultiSelect,\n row_getCanSelect,\n row_getCanSelectSubRows,\n row_getIsAllSubRowsSelected,\n row_getIsSelected,\n row_getIsSomeSelected,\n row_getToggleSelectedHandler,\n row_toggleSelected,\n table_getFilteredSelectedRowModel,\n table_getGroupedSelectedRowModel,\n table_getIsAllPageRowsSelected,\n table_getIsAllRowsSelected,\n table_getIsSomePageRowsSelected,\n table_getIsSomeRowsSelected,\n table_getPreSelectedRowModel,\n table_getSelectedRowIds,\n table_getSelectedRowModel,\n table_getToggleAllPageRowsSelectedHandler,\n table_getToggleAllRowsSelectedHandler,\n table_resetRowSelection,\n table_setRowSelection,\n table_toggleAllPageRowsSelected,\n table_toggleAllRowsSelected,\n} from './rowSelectionFeature.utils'\nimport type { TableFeature } from '../../types/TableFeatures'\n\n/**\n * Feature that adds row selection state and APIs for row and page selection.\n */\nexport const rowSelectionFeature: TableFeature = {\n getInitialState: (initialState) => {\n return {\n rowSelection: getDefaultRowSelectionState(),\n ...initialState,\n }\n },\n\n getDefaultTableOptions: (table) => {\n return {\n onRowSelectionChange: makeStateUpdater('rowSelection', table),\n enableRowSelection: true,\n enableMultiRowSelection: true,\n enableSubRowSelection: true,\n }\n },\n\n assignRowPrototype: (prototype, table) => {\n assignPrototypeAPIs('rowSelectionFeature', prototype, table, {\n row_toggleSelected: {\n fn: (row, value, opts) => row_toggleSelected(row, value, opts),\n },\n row_getIsSelected: {\n fn: (row) => row_getIsSelected(row),\n },\n row_getIsSomeSelected: {\n fn: (row) => row_getIsSomeSelected(row),\n },\n row_getIsAllSubRowsSelected: {\n fn: (row) => row_getIsAllSubRowsSelected(row),\n },\n row_getCanSelect: {\n fn: (row) => row_getCanSelect(row),\n },\n row_getCanSelectSubRows: {\n fn: (row) => row_getCanSelectSubRows(row),\n },\n row_getCanMultiSelect: {\n fn: (row) => row_getCanMultiSelect(row),\n },\n row_getToggleSelectedHandler: {\n fn: (row) => row_getToggleSelectedHandler(row),\n },\n })\n },\n\n constructTableAPIs: (table) => {\n assignTableAPIs('rowSelectionFeature', table, {\n table_setRowSelection: {\n fn: (updater) => table_setRowSelection(table, updater),\n },\n table_resetRowSelection: {\n fn: (defaultState) => table_resetRowSelection(table, defaultState),\n },\n table_toggleAllRowsSelected: {\n fn: (value, opts) => table_toggleAllRowsSelected(table, value, opts),\n },\n table_toggleAllPageRowsSelected: {\n fn: (value, opts) =>\n table_toggleAllPageRowsSelected(table, value, opts),\n },\n table_getPreSelectedRowModel: {\n fn: () => table_getPreSelectedRowModel(table),\n },\n table_getSelectedRowModel: {\n fn: () => table_getSelectedRowModel(table),\n memoDeps: () => [\n table.atoms.rowSelection?.get(),\n table.getCoreRowModel(),\n ],\n },\n table_getFilteredSelectedRowModel: {\n fn: () => table_getFilteredSelectedRowModel(table),\n memoDeps: () => [\n table.atoms.rowSelection?.get(),\n table.getFilteredRowModel(),\n ],\n },\n table_getGroupedSelectedRowModel: {\n fn: () => table_getGroupedSelectedRowModel(table),\n memoDeps: () => [\n table.atoms.rowSelection?.get(),\n table.getSortedRowModel(),\n ],\n },\n table_getSelectedRowIds: {\n fn: () => table_getSelectedRowIds(table),\n memoDeps: () => [table.atoms.rowSelection?.get()],\n },\n table_getIsAllRowsSelected: {\n fn: () => table_getIsAllRowsSelected(table),\n memoDeps: () => [\n table.atoms.rowSelection?.get(),\n table.getFilteredRowModel(),\n table.options.enableRowSelection,\n ],\n },\n table_getIsAllPageRowsSelected: {\n fn: () => table_getIsAllPageRowsSelected(table),\n memoDeps: () => [\n table.atoms.rowSelection?.get(),\n table.getPaginatedRowModel(),\n table.options.enableRowSelection,\n ],\n },\n table_getIsSomeRowsSelected: {\n fn: () => table_getIsSomeRowsSelected(table),\n memoDeps: () => [table.atoms.rowSelection?.get()],\n },\n table_getIsSomePageRowsSelected: {\n fn: () => table_getIsSomePageRowsSelected(table),\n memoDeps: () => [\n table.atoms.rowSelection?.get(),\n table.getPaginatedRowModel(),\n table.options.enableRowSelection,\n ],\n },\n table_getToggleAllRowsSelectedHandler: {\n fn: () => table_getToggleAllRowsSelectedHandler(table),\n },\n table_getToggleAllPageRowsSelectedHandler: {\n fn: () => table_getToggleAllPageRowsSelectedHandler(table),\n },\n })\n },\n}\n"],"mappings":";;;;;;;AAoCA,MAAa,sBAAoC;CAC/C,kBAAkB,iBAAiB;EACjC,OAAO;GACL,cAAcA,8DAA4B;GAC1C,GAAG;EACL;CACF;CAEA,yBAAyB,UAAU;EACjC,OAAO;GACL,sBAAsBC,+BAAiB,gBAAgB,KAAK;GAC5D,oBAAoB;GACpB,yBAAyB;GACzB,uBAAuB;EACzB;CACF;CAEA,qBAAqB,WAAW,UAAU;EACxC,kCAAoB,uBAAuB,WAAW,OAAO;GAC3D,oBAAoB,EAClB,KAAK,KAAK,OAAO,SAASC,qDAAmB,KAAK,OAAO,IAAI,EAC/D;GACA,mBAAmB,EACjB,KAAK,QAAQC,oDAAkB,GAAG,EACpC;GACA,uBAAuB,EACrB,KAAK,QAAQC,wDAAsB,GAAG,EACxC;GACA,6BAA6B,EAC3B,KAAK,QAAQC,8DAA4B,GAAG,EAC9C;GACA,kBAAkB,EAChB,KAAK,QAAQC,mDAAiB,GAAG,EACnC;GACA,yBAAyB,EACvB,KAAK,QAAQC,0DAAwB,GAAG,EAC1C;GACA,uBAAuB,EACrB,KAAK,QAAQC,wDAAsB,GAAG,EACxC;GACA,8BAA8B,EAC5B,KAAK,QAAQC,+DAA6B,GAAG,EAC/C;EACF,CAAC;CACH;CAEA,qBAAqB,UAAU;EAC7B,8BAAgB,uBAAuB,OAAO;GAC5C,uBAAuB,EACrB,KAAK,YAAYC,wDAAsB,OAAO,OAAO,EACvD;GACA,yBAAyB,EACvB,KAAK,iBAAiBC,0DAAwB,OAAO,YAAY,EACnE;GACA,6BAA6B,EAC3B,KAAK,OAAO,SAASC,8DAA4B,OAAO,OAAO,IAAI,EACrE;GACA,iCAAiC,EAC/B,KAAK,OAAO,SACVC,kEAAgC,OAAO,OAAO,IAAI,EACtD;GACA,8BAA8B,EAC5B,UAAUC,+DAA6B,KAAK,EAC9C;GACA,2BAA2B;IACzB,UAAUC,4DAA0B,KAAK;IACzC,gBAAgB;;sCACd,MAAM,MAAM,4FAAc,IAAI,GAC9B,MAAM,gBAAgB,CACxB;;GACF;GACA,mCAAmC;IACjC,UAAUC,oEAAkC,KAAK;IACjD,gBAAgB;;uCACd,MAAM,MAAM,8FAAc,IAAI,GAC9B,MAAM,oBAAoB,CAC5B;;GACF;GACA,kCAAkC;IAChC,UAAUC,mEAAiC,KAAK;IAChD,gBAAgB;;uCACd,MAAM,MAAM,8FAAc,IAAI,GAC9B,MAAM,kBAAkB,CAC1B;;GACF;GACA,yBAAyB;IACvB,UAAUC,0DAAwB,KAAK;IACvC,gBAAgB;;uCAAC,MAAM,MAAM,8FAAc,IAAI,CAAC;;GAClD;GACA,4BAA4B;IAC1B,UAAUC,6DAA2B,KAAK;IAC1C,gBAAgB;;;gCACd,MAAM,MAAM,8FAAc,IAAI;MAC9B,MAAM,oBAAoB;MAC1B,MAAM,QAAQ;KAChB;;GACF;GACA,gCAAgC;IAC9B,UAAUC,iEAA+B,KAAK;IAC9C,gBAAgB;;;gCACd,MAAM,MAAM,8FAAc,IAAI;MAC9B,MAAM,qBAAqB;MAC3B,MAAM,QAAQ;KAChB;;GACF;GACA,6BAA6B;IAC3B,UAAUC,8DAA4B,KAAK;IAC3C,gBAAgB;;uCAAC,MAAM,MAAM,8FAAc,IAAI,CAAC;;GAClD;GACA,iCAAiC;IAC/B,UAAUC,kEAAgC,KAAK;IAC/C,gBAAgB;;;gCACd,MAAM,MAAM,8FAAc,IAAI;MAC9B,MAAM,qBAAqB;MAC3B,MAAM,QAAQ;KAChB;;GACF;GACA,uCAAuC,EACrC,UAAUC,wEAAsC,KAAK,EACvD;GACA,2CAA2C,EACzC,UAAUC,4EAA0C,KAAK,EAC3D;EACF,CAAC;CACH;AACF"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { assignPrototypeAPIs, assignTableAPIs, makeStateUpdater } from "../../utils.js";
|
|
2
|
-
import { getDefaultRowSelectionState, row_getCanMultiSelect, row_getCanSelect, row_getCanSelectSubRows, row_getIsAllSubRowsSelected, row_getIsSelected, row_getIsSomeSelected, row_getToggleSelectedHandler, row_toggleSelected, table_getFilteredSelectedRowModel, table_getGroupedSelectedRowModel, table_getIsAllPageRowsSelected, table_getIsAllRowsSelected, table_getIsSomePageRowsSelected, table_getIsSomeRowsSelected, table_getPreSelectedRowModel, table_getSelectedRowModel, table_getToggleAllPageRowsSelectedHandler, table_getToggleAllRowsSelectedHandler, table_resetRowSelection, table_setRowSelection, table_toggleAllPageRowsSelected, table_toggleAllRowsSelected } from "./rowSelectionFeature.utils.js";
|
|
2
|
+
import { getDefaultRowSelectionState, row_getCanMultiSelect, row_getCanSelect, row_getCanSelectSubRows, row_getIsAllSubRowsSelected, row_getIsSelected, row_getIsSomeSelected, row_getToggleSelectedHandler, row_toggleSelected, table_getFilteredSelectedRowModel, table_getGroupedSelectedRowModel, table_getIsAllPageRowsSelected, table_getIsAllRowsSelected, table_getIsSomePageRowsSelected, table_getIsSomeRowsSelected, table_getPreSelectedRowModel, table_getSelectedRowIds, table_getSelectedRowModel, table_getToggleAllPageRowsSelectedHandler, table_getToggleAllRowsSelectedHandler, table_resetRowSelection, table_setRowSelection, table_toggleAllPageRowsSelected, table_toggleAllRowsSelected } from "./rowSelectionFeature.utils.js";
|
|
3
3
|
|
|
4
4
|
//#region src/features/row-selection/rowSelectionFeature.ts
|
|
5
5
|
/**
|
|
@@ -36,8 +36,8 @@ const rowSelectionFeature = {
|
|
|
36
36
|
assignTableAPIs("rowSelectionFeature", table, {
|
|
37
37
|
table_setRowSelection: { fn: (updater) => table_setRowSelection(table, updater) },
|
|
38
38
|
table_resetRowSelection: { fn: (defaultState) => table_resetRowSelection(table, defaultState) },
|
|
39
|
-
table_toggleAllRowsSelected: { fn: (value) => table_toggleAllRowsSelected(table, value) },
|
|
40
|
-
table_toggleAllPageRowsSelected: { fn: (value) => table_toggleAllPageRowsSelected(table, value) },
|
|
39
|
+
table_toggleAllRowsSelected: { fn: (value, opts) => table_toggleAllRowsSelected(table, value, opts) },
|
|
40
|
+
table_toggleAllPageRowsSelected: { fn: (value, opts) => table_toggleAllPageRowsSelected(table, value, opts) },
|
|
41
41
|
table_getPreSelectedRowModel: { fn: () => table_getPreSelectedRowModel(table) },
|
|
42
42
|
table_getSelectedRowModel: {
|
|
43
43
|
fn: () => table_getSelectedRowModel(table),
|
|
@@ -60,10 +60,53 @@ const rowSelectionFeature = {
|
|
|
60
60
|
return [(_table$atoms$rowSelec3 = table.atoms.rowSelection) === null || _table$atoms$rowSelec3 === void 0 ? void 0 : _table$atoms$rowSelec3.get(), table.getSortedRowModel()];
|
|
61
61
|
}
|
|
62
62
|
},
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
63
|
+
table_getSelectedRowIds: {
|
|
64
|
+
fn: () => table_getSelectedRowIds(table),
|
|
65
|
+
memoDeps: () => {
|
|
66
|
+
var _table$atoms$rowSelec4;
|
|
67
|
+
return [(_table$atoms$rowSelec4 = table.atoms.rowSelection) === null || _table$atoms$rowSelec4 === void 0 ? void 0 : _table$atoms$rowSelec4.get()];
|
|
68
|
+
}
|
|
69
|
+
},
|
|
70
|
+
table_getIsAllRowsSelected: {
|
|
71
|
+
fn: () => table_getIsAllRowsSelected(table),
|
|
72
|
+
memoDeps: () => {
|
|
73
|
+
var _table$atoms$rowSelec5;
|
|
74
|
+
return [
|
|
75
|
+
(_table$atoms$rowSelec5 = table.atoms.rowSelection) === null || _table$atoms$rowSelec5 === void 0 ? void 0 : _table$atoms$rowSelec5.get(),
|
|
76
|
+
table.getFilteredRowModel(),
|
|
77
|
+
table.options.enableRowSelection
|
|
78
|
+
];
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
table_getIsAllPageRowsSelected: {
|
|
82
|
+
fn: () => table_getIsAllPageRowsSelected(table),
|
|
83
|
+
memoDeps: () => {
|
|
84
|
+
var _table$atoms$rowSelec6;
|
|
85
|
+
return [
|
|
86
|
+
(_table$atoms$rowSelec6 = table.atoms.rowSelection) === null || _table$atoms$rowSelec6 === void 0 ? void 0 : _table$atoms$rowSelec6.get(),
|
|
87
|
+
table.getPaginatedRowModel(),
|
|
88
|
+
table.options.enableRowSelection
|
|
89
|
+
];
|
|
90
|
+
}
|
|
91
|
+
},
|
|
92
|
+
table_getIsSomeRowsSelected: {
|
|
93
|
+
fn: () => table_getIsSomeRowsSelected(table),
|
|
94
|
+
memoDeps: () => {
|
|
95
|
+
var _table$atoms$rowSelec7;
|
|
96
|
+
return [(_table$atoms$rowSelec7 = table.atoms.rowSelection) === null || _table$atoms$rowSelec7 === void 0 ? void 0 : _table$atoms$rowSelec7.get()];
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
table_getIsSomePageRowsSelected: {
|
|
100
|
+
fn: () => table_getIsSomePageRowsSelected(table),
|
|
101
|
+
memoDeps: () => {
|
|
102
|
+
var _table$atoms$rowSelec8;
|
|
103
|
+
return [
|
|
104
|
+
(_table$atoms$rowSelec8 = table.atoms.rowSelection) === null || _table$atoms$rowSelec8 === void 0 ? void 0 : _table$atoms$rowSelec8.get(),
|
|
105
|
+
table.getPaginatedRowModel(),
|
|
106
|
+
table.options.enableRowSelection
|
|
107
|
+
];
|
|
108
|
+
}
|
|
109
|
+
},
|
|
67
110
|
table_getToggleAllRowsSelectedHandler: { fn: () => table_getToggleAllRowsSelectedHandler(table) },
|
|
68
111
|
table_getToggleAllPageRowsSelectedHandler: { fn: () => table_getToggleAllPageRowsSelectedHandler(table) }
|
|
69
112
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rowSelectionFeature.js","names":[],"sources":["../../../src/features/row-selection/rowSelectionFeature.ts"],"sourcesContent":["import {\n assignPrototypeAPIs,\n assignTableAPIs,\n makeStateUpdater,\n} from '../../utils'\nimport {\n getDefaultRowSelectionState,\n row_getCanMultiSelect,\n row_getCanSelect,\n row_getCanSelectSubRows,\n row_getIsAllSubRowsSelected,\n row_getIsSelected,\n row_getIsSomeSelected,\n row_getToggleSelectedHandler,\n row_toggleSelected,\n table_getFilteredSelectedRowModel,\n table_getGroupedSelectedRowModel,\n table_getIsAllPageRowsSelected,\n table_getIsAllRowsSelected,\n table_getIsSomePageRowsSelected,\n table_getIsSomeRowsSelected,\n table_getPreSelectedRowModel,\n table_getSelectedRowModel,\n table_getToggleAllPageRowsSelectedHandler,\n table_getToggleAllRowsSelectedHandler,\n table_resetRowSelection,\n table_setRowSelection,\n table_toggleAllPageRowsSelected,\n table_toggleAllRowsSelected,\n} from './rowSelectionFeature.utils'\nimport type { TableFeature } from '../../types/TableFeatures'\n\n/**\n * Feature that adds row selection state and APIs for row and page selection.\n */\nexport const rowSelectionFeature: TableFeature = {\n getInitialState: (initialState) => {\n return {\n rowSelection: getDefaultRowSelectionState(),\n ...initialState,\n }\n },\n\n getDefaultTableOptions: (table) => {\n return {\n onRowSelectionChange: makeStateUpdater('rowSelection', table),\n enableRowSelection: true,\n enableMultiRowSelection: true,\n enableSubRowSelection: true,\n }\n },\n\n assignRowPrototype: (prototype, table) => {\n assignPrototypeAPIs('rowSelectionFeature', prototype, table, {\n row_toggleSelected: {\n fn: (row, value, opts) => row_toggleSelected(row, value, opts),\n },\n row_getIsSelected: {\n fn: (row) => row_getIsSelected(row),\n },\n row_getIsSomeSelected: {\n fn: (row) => row_getIsSomeSelected(row),\n },\n row_getIsAllSubRowsSelected: {\n fn: (row) => row_getIsAllSubRowsSelected(row),\n },\n row_getCanSelect: {\n fn: (row) => row_getCanSelect(row),\n },\n row_getCanSelectSubRows: {\n fn: (row) => row_getCanSelectSubRows(row),\n },\n row_getCanMultiSelect: {\n fn: (row) => row_getCanMultiSelect(row),\n },\n row_getToggleSelectedHandler: {\n fn: (row) => row_getToggleSelectedHandler(row),\n },\n })\n },\n\n constructTableAPIs: (table) => {\n assignTableAPIs('rowSelectionFeature', table, {\n table_setRowSelection: {\n fn: (updater) => table_setRowSelection(table, updater),\n },\n table_resetRowSelection: {\n fn: (defaultState) => table_resetRowSelection(table, defaultState),\n },\n table_toggleAllRowsSelected: {\n fn: (value) => table_toggleAllRowsSelected(table, value),\n },\n table_toggleAllPageRowsSelected: {\n fn: (value)
|
|
1
|
+
{"version":3,"file":"rowSelectionFeature.js","names":[],"sources":["../../../src/features/row-selection/rowSelectionFeature.ts"],"sourcesContent":["import {\n assignPrototypeAPIs,\n assignTableAPIs,\n makeStateUpdater,\n} from '../../utils'\nimport {\n getDefaultRowSelectionState,\n row_getCanMultiSelect,\n row_getCanSelect,\n row_getCanSelectSubRows,\n row_getIsAllSubRowsSelected,\n row_getIsSelected,\n row_getIsSomeSelected,\n row_getToggleSelectedHandler,\n row_toggleSelected,\n table_getFilteredSelectedRowModel,\n table_getGroupedSelectedRowModel,\n table_getIsAllPageRowsSelected,\n table_getIsAllRowsSelected,\n table_getIsSomePageRowsSelected,\n table_getIsSomeRowsSelected,\n table_getPreSelectedRowModel,\n table_getSelectedRowIds,\n table_getSelectedRowModel,\n table_getToggleAllPageRowsSelectedHandler,\n table_getToggleAllRowsSelectedHandler,\n table_resetRowSelection,\n table_setRowSelection,\n table_toggleAllPageRowsSelected,\n table_toggleAllRowsSelected,\n} from './rowSelectionFeature.utils'\nimport type { TableFeature } from '../../types/TableFeatures'\n\n/**\n * Feature that adds row selection state and APIs for row and page selection.\n */\nexport const rowSelectionFeature: TableFeature = {\n getInitialState: (initialState) => {\n return {\n rowSelection: getDefaultRowSelectionState(),\n ...initialState,\n }\n },\n\n getDefaultTableOptions: (table) => {\n return {\n onRowSelectionChange: makeStateUpdater('rowSelection', table),\n enableRowSelection: true,\n enableMultiRowSelection: true,\n enableSubRowSelection: true,\n }\n },\n\n assignRowPrototype: (prototype, table) => {\n assignPrototypeAPIs('rowSelectionFeature', prototype, table, {\n row_toggleSelected: {\n fn: (row, value, opts) => row_toggleSelected(row, value, opts),\n },\n row_getIsSelected: {\n fn: (row) => row_getIsSelected(row),\n },\n row_getIsSomeSelected: {\n fn: (row) => row_getIsSomeSelected(row),\n },\n row_getIsAllSubRowsSelected: {\n fn: (row) => row_getIsAllSubRowsSelected(row),\n },\n row_getCanSelect: {\n fn: (row) => row_getCanSelect(row),\n },\n row_getCanSelectSubRows: {\n fn: (row) => row_getCanSelectSubRows(row),\n },\n row_getCanMultiSelect: {\n fn: (row) => row_getCanMultiSelect(row),\n },\n row_getToggleSelectedHandler: {\n fn: (row) => row_getToggleSelectedHandler(row),\n },\n })\n },\n\n constructTableAPIs: (table) => {\n assignTableAPIs('rowSelectionFeature', table, {\n table_setRowSelection: {\n fn: (updater) => table_setRowSelection(table, updater),\n },\n table_resetRowSelection: {\n fn: (defaultState) => table_resetRowSelection(table, defaultState),\n },\n table_toggleAllRowsSelected: {\n fn: (value, opts) => table_toggleAllRowsSelected(table, value, opts),\n },\n table_toggleAllPageRowsSelected: {\n fn: (value, opts) =>\n table_toggleAllPageRowsSelected(table, value, opts),\n },\n table_getPreSelectedRowModel: {\n fn: () => table_getPreSelectedRowModel(table),\n },\n table_getSelectedRowModel: {\n fn: () => table_getSelectedRowModel(table),\n memoDeps: () => [\n table.atoms.rowSelection?.get(),\n table.getCoreRowModel(),\n ],\n },\n table_getFilteredSelectedRowModel: {\n fn: () => table_getFilteredSelectedRowModel(table),\n memoDeps: () => [\n table.atoms.rowSelection?.get(),\n table.getFilteredRowModel(),\n ],\n },\n table_getGroupedSelectedRowModel: {\n fn: () => table_getGroupedSelectedRowModel(table),\n memoDeps: () => [\n table.atoms.rowSelection?.get(),\n table.getSortedRowModel(),\n ],\n },\n table_getSelectedRowIds: {\n fn: () => table_getSelectedRowIds(table),\n memoDeps: () => [table.atoms.rowSelection?.get()],\n },\n table_getIsAllRowsSelected: {\n fn: () => table_getIsAllRowsSelected(table),\n memoDeps: () => [\n table.atoms.rowSelection?.get(),\n table.getFilteredRowModel(),\n table.options.enableRowSelection,\n ],\n },\n table_getIsAllPageRowsSelected: {\n fn: () => table_getIsAllPageRowsSelected(table),\n memoDeps: () => [\n table.atoms.rowSelection?.get(),\n table.getPaginatedRowModel(),\n table.options.enableRowSelection,\n ],\n },\n table_getIsSomeRowsSelected: {\n fn: () => table_getIsSomeRowsSelected(table),\n memoDeps: () => [table.atoms.rowSelection?.get()],\n },\n table_getIsSomePageRowsSelected: {\n fn: () => table_getIsSomePageRowsSelected(table),\n memoDeps: () => [\n table.atoms.rowSelection?.get(),\n table.getPaginatedRowModel(),\n table.options.enableRowSelection,\n ],\n },\n table_getToggleAllRowsSelectedHandler: {\n fn: () => table_getToggleAllRowsSelectedHandler(table),\n },\n table_getToggleAllPageRowsSelectedHandler: {\n fn: () => table_getToggleAllPageRowsSelectedHandler(table),\n },\n })\n },\n}\n"],"mappings":";;;;;;;AAoCA,MAAa,sBAAoC;CAC/C,kBAAkB,iBAAiB;EACjC,OAAO;GACL,cAAc,4BAA4B;GAC1C,GAAG;EACL;CACF;CAEA,yBAAyB,UAAU;EACjC,OAAO;GACL,sBAAsB,iBAAiB,gBAAgB,KAAK;GAC5D,oBAAoB;GACpB,yBAAyB;GACzB,uBAAuB;EACzB;CACF;CAEA,qBAAqB,WAAW,UAAU;EACxC,oBAAoB,uBAAuB,WAAW,OAAO;GAC3D,oBAAoB,EAClB,KAAK,KAAK,OAAO,SAAS,mBAAmB,KAAK,OAAO,IAAI,EAC/D;GACA,mBAAmB,EACjB,KAAK,QAAQ,kBAAkB,GAAG,EACpC;GACA,uBAAuB,EACrB,KAAK,QAAQ,sBAAsB,GAAG,EACxC;GACA,6BAA6B,EAC3B,KAAK,QAAQ,4BAA4B,GAAG,EAC9C;GACA,kBAAkB,EAChB,KAAK,QAAQ,iBAAiB,GAAG,EACnC;GACA,yBAAyB,EACvB,KAAK,QAAQ,wBAAwB,GAAG,EAC1C;GACA,uBAAuB,EACrB,KAAK,QAAQ,sBAAsB,GAAG,EACxC;GACA,8BAA8B,EAC5B,KAAK,QAAQ,6BAA6B,GAAG,EAC/C;EACF,CAAC;CACH;CAEA,qBAAqB,UAAU;EAC7B,gBAAgB,uBAAuB,OAAO;GAC5C,uBAAuB,EACrB,KAAK,YAAY,sBAAsB,OAAO,OAAO,EACvD;GACA,yBAAyB,EACvB,KAAK,iBAAiB,wBAAwB,OAAO,YAAY,EACnE;GACA,6BAA6B,EAC3B,KAAK,OAAO,SAAS,4BAA4B,OAAO,OAAO,IAAI,EACrE;GACA,iCAAiC,EAC/B,KAAK,OAAO,SACV,gCAAgC,OAAO,OAAO,IAAI,EACtD;GACA,8BAA8B,EAC5B,UAAU,6BAA6B,KAAK,EAC9C;GACA,2BAA2B;IACzB,UAAU,0BAA0B,KAAK;IACzC,gBAAgB;;sCACd,MAAM,MAAM,4FAAc,IAAI,GAC9B,MAAM,gBAAgB,CACxB;;GACF;GACA,mCAAmC;IACjC,UAAU,kCAAkC,KAAK;IACjD,gBAAgB;;uCACd,MAAM,MAAM,8FAAc,IAAI,GAC9B,MAAM,oBAAoB,CAC5B;;GACF;GACA,kCAAkC;IAChC,UAAU,iCAAiC,KAAK;IAChD,gBAAgB;;uCACd,MAAM,MAAM,8FAAc,IAAI,GAC9B,MAAM,kBAAkB,CAC1B;;GACF;GACA,yBAAyB;IACvB,UAAU,wBAAwB,KAAK;IACvC,gBAAgB;;uCAAC,MAAM,MAAM,8FAAc,IAAI,CAAC;;GAClD;GACA,4BAA4B;IAC1B,UAAU,2BAA2B,KAAK;IAC1C,gBAAgB;;;gCACd,MAAM,MAAM,8FAAc,IAAI;MAC9B,MAAM,oBAAoB;MAC1B,MAAM,QAAQ;KAChB;;GACF;GACA,gCAAgC;IAC9B,UAAU,+BAA+B,KAAK;IAC9C,gBAAgB;;;gCACd,MAAM,MAAM,8FAAc,IAAI;MAC9B,MAAM,qBAAqB;MAC3B,MAAM,QAAQ;KAChB;;GACF;GACA,6BAA6B;IAC3B,UAAU,4BAA4B,KAAK;IAC3C,gBAAgB;;uCAAC,MAAM,MAAM,8FAAc,IAAI,CAAC;;GAClD;GACA,iCAAiC;IAC/B,UAAU,gCAAgC,KAAK;IAC/C,gBAAgB;;;gCACd,MAAM,MAAM,8FAAc,IAAI;MAC9B,MAAM,qBAAqB;MAC3B,MAAM,QAAQ;KAChB;;GACF;GACA,uCAAuC,EACrC,UAAU,sCAAsC,KAAK,EACvD;GACA,2CAA2C,EACzC,UAAU,0CAA0C,KAAK,EAC3D;EACF,CAAC;CACH;AACF"}
|
|
@@ -4,7 +4,7 @@ import { TableFeatures } from "../../types/TableFeatures.cjs";
|
|
|
4
4
|
import { RowModel } from "../../core/row-models/coreRowModelsFeature.types.cjs";
|
|
5
5
|
|
|
6
6
|
//#region src/features/row-selection/rowSelectionFeature.types.d.ts
|
|
7
|
-
type RowSelectionState = Record<string,
|
|
7
|
+
type RowSelectionState = Record<string, true>;
|
|
8
8
|
interface TableState_RowSelection {
|
|
9
9
|
rowSelection: RowSelectionState;
|
|
10
10
|
}
|
|
@@ -80,6 +80,10 @@ interface Table_RowSelection<in out TFeatures extends TableFeatures, in out TDat
|
|
|
80
80
|
* Builds a selected-row model from rows after grouping.
|
|
81
81
|
*/
|
|
82
82
|
getGroupedSelectedRowModel: () => RowModel<TFeatures, TData>;
|
|
83
|
+
/**
|
|
84
|
+
* Returns the ids of all selected rows.
|
|
85
|
+
*/
|
|
86
|
+
getSelectedRowIds: () => Array<string>;
|
|
83
87
|
/**
|
|
84
88
|
* Checks whether every selectable row on the current page is selected.
|
|
85
89
|
*/
|
|
@@ -125,11 +129,15 @@ interface Table_RowSelection<in out TFeatures extends TableFeatures, in out TDat
|
|
|
125
129
|
/**
|
|
126
130
|
* Selects/deselects all rows on the current page.
|
|
127
131
|
*/
|
|
128
|
-
toggleAllPageRowsSelected: (value?: boolean
|
|
132
|
+
toggleAllPageRowsSelected: (value?: boolean, opts?: {
|
|
133
|
+
deselectAll?: boolean;
|
|
134
|
+
}) => void;
|
|
129
135
|
/**
|
|
130
136
|
* Selects/deselects all rows in the table.
|
|
131
137
|
*/
|
|
132
|
-
toggleAllRowsSelected: (value?: boolean
|
|
138
|
+
toggleAllRowsSelected: (value?: boolean, opts?: {
|
|
139
|
+
deselectAll?: boolean;
|
|
140
|
+
}) => void;
|
|
133
141
|
}
|
|
134
142
|
//#endregion
|
|
135
143
|
export { RowSelectionState, Row_RowSelection, TableOptions_RowSelection, TableState_RowSelection, Table_RowSelection };
|
|
@@ -4,7 +4,7 @@ import { TableFeatures } from "../../types/TableFeatures.js";
|
|
|
4
4
|
import { RowModel } from "../../core/row-models/coreRowModelsFeature.types.js";
|
|
5
5
|
|
|
6
6
|
//#region src/features/row-selection/rowSelectionFeature.types.d.ts
|
|
7
|
-
type RowSelectionState = Record<string,
|
|
7
|
+
type RowSelectionState = Record<string, true>;
|
|
8
8
|
interface TableState_RowSelection {
|
|
9
9
|
rowSelection: RowSelectionState;
|
|
10
10
|
}
|
|
@@ -80,6 +80,10 @@ interface Table_RowSelection<in out TFeatures extends TableFeatures, in out TDat
|
|
|
80
80
|
* Builds a selected-row model from rows after grouping.
|
|
81
81
|
*/
|
|
82
82
|
getGroupedSelectedRowModel: () => RowModel<TFeatures, TData>;
|
|
83
|
+
/**
|
|
84
|
+
* Returns the ids of all selected rows.
|
|
85
|
+
*/
|
|
86
|
+
getSelectedRowIds: () => Array<string>;
|
|
83
87
|
/**
|
|
84
88
|
* Checks whether every selectable row on the current page is selected.
|
|
85
89
|
*/
|
|
@@ -125,11 +129,15 @@ interface Table_RowSelection<in out TFeatures extends TableFeatures, in out TDat
|
|
|
125
129
|
/**
|
|
126
130
|
* Selects/deselects all rows on the current page.
|
|
127
131
|
*/
|
|
128
|
-
toggleAllPageRowsSelected: (value?: boolean
|
|
132
|
+
toggleAllPageRowsSelected: (value?: boolean, opts?: {
|
|
133
|
+
deselectAll?: boolean;
|
|
134
|
+
}) => void;
|
|
129
135
|
/**
|
|
130
136
|
* Selects/deselects all rows in the table.
|
|
131
137
|
*/
|
|
132
|
-
toggleAllRowsSelected: (value?: boolean
|
|
138
|
+
toggleAllRowsSelected: (value?: boolean, opts?: {
|
|
139
|
+
deselectAll?: boolean;
|
|
140
|
+
}) => void;
|
|
133
141
|
}
|
|
134
142
|
//#endregion
|
|
135
143
|
export { RowSelectionState, Row_RowSelection, TableOptions_RowSelection, TableState_RowSelection, Table_RowSelection };
|
|
@@ -56,14 +56,14 @@ function table_resetRowSelection(table, defaultState) {
|
|
|
56
56
|
* table_toggleAllRowsSelected(table)
|
|
57
57
|
* ```
|
|
58
58
|
*/
|
|
59
|
-
function table_toggleAllRowsSelected(table, value) {
|
|
59
|
+
function table_toggleAllRowsSelected(table, value, opts) {
|
|
60
60
|
table_setRowSelection(table, (old) => {
|
|
61
|
-
value = typeof value !== "undefined" ? value : !
|
|
61
|
+
value = typeof value !== "undefined" ? value : !require_utils.callMemoOrStaticFn(table, "getIsAllRowsSelected", table_getIsAllRowsSelected);
|
|
62
|
+
if ((opts === null || opts === void 0 ? void 0 : opts.deselectAll) && !value) return require_utils.makeObjectMap();
|
|
62
63
|
const rowSelection = Object.assign(require_utils.makeObjectMap(), old);
|
|
63
64
|
const preGroupedFlatRows = table.getPreGroupedRowModel().flatRows;
|
|
64
65
|
if (value) preGroupedFlatRows.forEach((row) => {
|
|
65
|
-
if (
|
|
66
|
-
rowSelection[row.id] = true;
|
|
66
|
+
if (row_getCanSelect(row)) rowSelection[row.id] = true;
|
|
67
67
|
});
|
|
68
68
|
else preGroupedFlatRows.forEach((row) => {
|
|
69
69
|
delete rowSelection[row.id];
|
|
@@ -82,9 +82,10 @@ function table_toggleAllRowsSelected(table, value) {
|
|
|
82
82
|
* table_toggleAllPageRowsSelected(table)
|
|
83
83
|
* ```
|
|
84
84
|
*/
|
|
85
|
-
function table_toggleAllPageRowsSelected(table, value) {
|
|
85
|
+
function table_toggleAllPageRowsSelected(table, value, opts) {
|
|
86
86
|
table_setRowSelection(table, (old) => {
|
|
87
|
-
const resolvedValue = typeof value !== "undefined" ? value : !
|
|
87
|
+
const resolvedValue = typeof value !== "undefined" ? value : !require_utils.callMemoOrStaticFn(table, "getIsAllPageRowsSelected", table_getIsAllPageRowsSelected);
|
|
88
|
+
if ((opts === null || opts === void 0 ? void 0 : opts.deselectAll) && !resolvedValue) return require_utils.makeObjectMap();
|
|
88
89
|
const rowSelection = Object.assign(require_utils.makeObjectMap(), old);
|
|
89
90
|
table.getRowModel().rows.forEach((row) => {
|
|
90
91
|
mutateRowIsSelected(rowSelection, row.id, resolvedValue, true, table);
|
|
@@ -118,14 +119,13 @@ function table_getPreSelectedRowModel(table) {
|
|
|
118
119
|
* ```
|
|
119
120
|
*/
|
|
120
121
|
function table_getSelectedRowModel(table) {
|
|
121
|
-
var _table$atoms$rowSelec;
|
|
122
122
|
const rowModel = table.getCoreRowModel();
|
|
123
|
-
if (!
|
|
123
|
+
if (!require_utils.callMemoOrStaticFn(table, "getIsSomeRowsSelected", table_getIsSomeRowsSelected)) return {
|
|
124
124
|
rows: [],
|
|
125
125
|
flatRows: [],
|
|
126
126
|
rowsById: require_utils.makeObjectMap()
|
|
127
127
|
};
|
|
128
|
-
return selectRowsFn(rowModel);
|
|
128
|
+
return selectRowsFn(rowModel, table);
|
|
129
129
|
}
|
|
130
130
|
/**
|
|
131
131
|
* Builds a row model containing selected rows from the filtered row model.
|
|
@@ -139,14 +139,13 @@ function table_getSelectedRowModel(table) {
|
|
|
139
139
|
* ```
|
|
140
140
|
*/
|
|
141
141
|
function table_getFilteredSelectedRowModel(table) {
|
|
142
|
-
var _table$atoms$rowSelec2;
|
|
143
142
|
const rowModel = table.getCoreRowModel();
|
|
144
|
-
if (!
|
|
143
|
+
if (!require_utils.callMemoOrStaticFn(table, "getIsSomeRowsSelected", table_getIsSomeRowsSelected)) return {
|
|
145
144
|
rows: [],
|
|
146
145
|
flatRows: [],
|
|
147
146
|
rowsById: require_utils.makeObjectMap()
|
|
148
147
|
};
|
|
149
|
-
return selectRowsFn(rowModel);
|
|
148
|
+
return selectRowsFn(rowModel, table);
|
|
150
149
|
}
|
|
151
150
|
/**
|
|
152
151
|
* Builds a row model containing selected rows from the grouped row model.
|
|
@@ -160,14 +159,25 @@ function table_getFilteredSelectedRowModel(table) {
|
|
|
160
159
|
* ```
|
|
161
160
|
*/
|
|
162
161
|
function table_getGroupedSelectedRowModel(table) {
|
|
163
|
-
var _table$atoms$rowSelec3;
|
|
164
162
|
const rowModel = table.getCoreRowModel();
|
|
165
|
-
if (!
|
|
163
|
+
if (!require_utils.callMemoOrStaticFn(table, "getIsSomeRowsSelected", table_getIsSomeRowsSelected)) return {
|
|
166
164
|
rows: [],
|
|
167
165
|
flatRows: [],
|
|
168
166
|
rowsById: require_utils.makeObjectMap()
|
|
169
167
|
};
|
|
170
|
-
return selectRowsFn(rowModel);
|
|
168
|
+
return selectRowsFn(rowModel, table);
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Returns the ids of all selected rows.
|
|
172
|
+
*
|
|
173
|
+
* @example
|
|
174
|
+
* ```ts
|
|
175
|
+
* const selectedRowIds = table_getSelectedRowIds(table)
|
|
176
|
+
* ```
|
|
177
|
+
*/
|
|
178
|
+
function table_getSelectedRowIds(table) {
|
|
179
|
+
var _table$atoms$rowSelec;
|
|
180
|
+
return Object.keys(((_table$atoms$rowSelec = table.atoms.rowSelection) === null || _table$atoms$rowSelec === void 0 ? void 0 : _table$atoms$rowSelec.get()) ?? {});
|
|
171
181
|
}
|
|
172
182
|
/**
|
|
173
183
|
* Checks whether every selectable filtered row is selected.
|
|
@@ -181,12 +191,12 @@ function table_getGroupedSelectedRowModel(table) {
|
|
|
181
191
|
* ```
|
|
182
192
|
*/
|
|
183
193
|
function table_getIsAllRowsSelected(table) {
|
|
184
|
-
var _table$atoms$
|
|
194
|
+
var _table$atoms$rowSelec2;
|
|
185
195
|
const preGroupedFlatRows = table.getFilteredRowModel().flatRows;
|
|
186
|
-
const rowSelection = ((_table$atoms$
|
|
196
|
+
const rowSelection = ((_table$atoms$rowSelec2 = table.atoms.rowSelection) === null || _table$atoms$rowSelec2 === void 0 ? void 0 : _table$atoms$rowSelec2.get()) ?? {};
|
|
187
197
|
let isAllRowsSelected = Boolean(preGroupedFlatRows.length && Object.keys(rowSelection).length);
|
|
188
198
|
if (isAllRowsSelected) {
|
|
189
|
-
if (preGroupedFlatRows.some((row) => row_getCanSelect(row) && !
|
|
199
|
+
if (preGroupedFlatRows.some((row) => row_getCanSelect(row) && !isRowSelected(row, rowSelection))) isAllRowsSelected = false;
|
|
190
200
|
}
|
|
191
201
|
return isAllRowsSelected;
|
|
192
202
|
}
|
|
@@ -201,18 +211,17 @@ function table_getIsAllRowsSelected(table) {
|
|
|
201
211
|
* ```
|
|
202
212
|
*/
|
|
203
213
|
function table_getIsAllPageRowsSelected(table) {
|
|
204
|
-
var _table$atoms$
|
|
214
|
+
var _table$atoms$rowSelec3;
|
|
205
215
|
const paginationFlatRows = table.getPaginatedRowModel().flatRows.filter((row) => row_getCanSelect(row));
|
|
206
|
-
const rowSelection = ((_table$atoms$
|
|
216
|
+
const rowSelection = ((_table$atoms$rowSelec3 = table.atoms.rowSelection) === null || _table$atoms$rowSelec3 === void 0 ? void 0 : _table$atoms$rowSelec3.get()) ?? {};
|
|
207
217
|
let isAllPageRowsSelected = !!paginationFlatRows.length;
|
|
208
|
-
if (isAllPageRowsSelected && paginationFlatRows.some((row) => !
|
|
218
|
+
if (isAllPageRowsSelected && paginationFlatRows.some((row) => !isRowSelected(row, rowSelection))) isAllPageRowsSelected = false;
|
|
209
219
|
return isAllPageRowsSelected;
|
|
210
220
|
}
|
|
211
221
|
/**
|
|
212
222
|
* Checks whether selection is partially applied across filtered rows.
|
|
213
223
|
*
|
|
214
|
-
* The result is true when at least one row id is selected
|
|
215
|
-
* selected than the current filtered flat row count.
|
|
224
|
+
* The result is true when at least one row id is selected
|
|
216
225
|
*
|
|
217
226
|
* @example
|
|
218
227
|
* ```ts
|
|
@@ -220,24 +229,18 @@ function table_getIsAllPageRowsSelected(table) {
|
|
|
220
229
|
* ```
|
|
221
230
|
*/
|
|
222
231
|
function table_getIsSomeRowsSelected(table) {
|
|
223
|
-
|
|
224
|
-
const totalSelected = Object.keys(((_table$atoms$rowSelec6 = table.atoms.rowSelection) === null || _table$atoms$rowSelec6 === void 0 ? void 0 : _table$atoms$rowSelec6.get()) ?? {}).length;
|
|
225
|
-
return totalSelected > 0 && totalSelected < table.getFilteredRowModel().flatRows.length;
|
|
232
|
+
return require_utils.callMemoOrStaticFn(table, "getSelectedRowIds", table_getSelectedRowIds).length > 0;
|
|
226
233
|
}
|
|
227
234
|
/**
|
|
228
235
|
* Checks whether the current page has a partial selection.
|
|
229
236
|
*
|
|
230
|
-
* This is false when all selectable page rows are selected. Otherwise it is true
|
|
231
|
-
* if any selectable page row or descendant is selected.
|
|
232
|
-
*
|
|
233
237
|
* @example
|
|
234
238
|
* ```ts
|
|
235
239
|
* const somePageRowsSelected = table_getIsSomePageRowsSelected(table)
|
|
236
240
|
* ```
|
|
237
241
|
*/
|
|
238
242
|
function table_getIsSomePageRowsSelected(table) {
|
|
239
|
-
|
|
240
|
-
return table_getIsAllPageRowsSelected(table) ? false : paginationFlatRows.filter((row) => row_getCanSelect(row)).some((row) => row_getIsSelected(row) || row_getIsSomeSelected(row));
|
|
243
|
+
return table.getPaginatedRowModel().flatRows.filter((row) => row_getCanSelect(row)).some((row) => row_getIsSelected(row) || row_getIsSomeSelected(row));
|
|
241
244
|
}
|
|
242
245
|
/**
|
|
243
246
|
* Creates a checkbox-style handler that selects or deselects all rows.
|
|
@@ -280,6 +283,10 @@ function table_getToggleAllPageRowsSelectedHandler(table) {
|
|
|
280
283
|
* @example
|
|
281
284
|
* ```ts
|
|
282
285
|
* row_toggleSelected(row)
|
|
286
|
+
* row_toggleSelected(row, true)
|
|
287
|
+
* row_toggleSelected(row, false)
|
|
288
|
+
* row_toggleSelected(row, true, { selectChildren: false })
|
|
289
|
+
* row_toggleSelected(row, false, { selectChildren: false })
|
|
283
290
|
* ```
|
|
284
291
|
*/
|
|
285
292
|
function row_toggleSelected(row, value, opts) {
|
|
@@ -287,9 +294,9 @@ function row_toggleSelected(row, value, opts) {
|
|
|
287
294
|
table_setRowSelection(row.table, (old) => {
|
|
288
295
|
value = typeof value !== "undefined" ? value : !isSelected;
|
|
289
296
|
if (row_getCanSelect(row) && isSelected === value) return old;
|
|
290
|
-
const
|
|
291
|
-
mutateRowIsSelected(
|
|
292
|
-
return
|
|
297
|
+
const rowSelection = Object.assign(require_utils.makeObjectMap(), old);
|
|
298
|
+
mutateRowIsSelected(rowSelection, row.id, value, (opts === null || opts === void 0 ? void 0 : opts.selectChildren) ?? true, row.table);
|
|
299
|
+
return rowSelection;
|
|
293
300
|
});
|
|
294
301
|
}
|
|
295
302
|
/**
|
|
@@ -303,7 +310,8 @@ function row_toggleSelected(row, value, opts) {
|
|
|
303
310
|
* ```
|
|
304
311
|
*/
|
|
305
312
|
function row_getIsSelected(row) {
|
|
306
|
-
|
|
313
|
+
var _row$table$atoms$rowS;
|
|
314
|
+
return isRowSelected(row, ((_row$table$atoms$rowS = row.table.atoms.rowSelection) === null || _row$table$atoms$rowS === void 0 ? void 0 : _row$table$atoms$rowS.get()) ?? {});
|
|
307
315
|
}
|
|
308
316
|
/**
|
|
309
317
|
* Checks whether some, but not all, selectable descendants are selected.
|
|
@@ -397,13 +405,13 @@ function row_getToggleSelectedHandler(row) {
|
|
|
397
405
|
row_toggleSelected(row, e.target.checked);
|
|
398
406
|
};
|
|
399
407
|
}
|
|
400
|
-
const mutateRowIsSelected = (
|
|
408
|
+
const mutateRowIsSelected = (rowSelection, rowId, value, includeChildren, table) => {
|
|
401
409
|
const row = table.getRow(rowId, true);
|
|
402
410
|
if (value) {
|
|
403
|
-
if (!row_getCanMultiSelect(row)) Object.keys(
|
|
404
|
-
if (row_getCanSelect(row))
|
|
405
|
-
} else delete
|
|
406
|
-
if (includeChildren && row.subRows.length && row_getCanSelectSubRows(row)) row.subRows.forEach((r) => mutateRowIsSelected(
|
|
411
|
+
if (!row_getCanMultiSelect(row)) Object.keys(rowSelection).forEach((key) => delete rowSelection[key]);
|
|
412
|
+
if (row_getCanSelect(row)) rowSelection[rowId] = true;
|
|
413
|
+
} else delete rowSelection[rowId];
|
|
414
|
+
if (includeChildren && row.subRows.length && row_getCanSelectSubRows(row)) row.subRows.forEach((r) => mutateRowIsSelected(rowSelection, r.id, value, includeChildren, table));
|
|
407
415
|
};
|
|
408
416
|
/**
|
|
409
417
|
* Builds a row model containing rows selected by the current row selection state.
|
|
@@ -416,14 +424,16 @@ const mutateRowIsSelected = (selectedRowIds, rowId, value, includeChildren, tabl
|
|
|
416
424
|
* const selectedRows = selectRowsFn(rowModel)
|
|
417
425
|
* ```
|
|
418
426
|
*/
|
|
419
|
-
function selectRowsFn(rowModel) {
|
|
427
|
+
function selectRowsFn(rowModel, table) {
|
|
428
|
+
var _table$atoms$rowSelec4;
|
|
420
429
|
const newSelectedFlatRows = [];
|
|
421
430
|
const newSelectedRowsById = require_utils.makeObjectMap();
|
|
431
|
+
const rowSelection = ((_table$atoms$rowSelec4 = table.atoms.rowSelection) === null || _table$atoms$rowSelec4 === void 0 ? void 0 : _table$atoms$rowSelec4.get()) ?? {};
|
|
422
432
|
const recurseRows = (rows, depth = 0) => {
|
|
423
433
|
const result = [];
|
|
424
434
|
for (let i = 0; i < rows.length; i++) {
|
|
425
435
|
const row = rows[i];
|
|
426
|
-
const isSelected = isRowSelected(row);
|
|
436
|
+
const isSelected = isRowSelected(row, rowSelection);
|
|
427
437
|
if (isSelected) {
|
|
428
438
|
newSelectedFlatRows.push(row);
|
|
429
439
|
newSelectedRowsById[row.id] = row;
|
|
@@ -454,12 +464,8 @@ function selectRowsFn(rowModel) {
|
|
|
454
464
|
* const selected = isRowSelected(row)
|
|
455
465
|
* ```
|
|
456
466
|
*/
|
|
457
|
-
function isRowSelected(row) {
|
|
458
|
-
|
|
459
|
-
return isRowIdSelected((_row$table$atoms$rowS = row.table.atoms.rowSelection) === null || _row$table$atoms$rowS === void 0 ? void 0 : _row$table$atoms$rowS.get(), row.id);
|
|
460
|
-
}
|
|
461
|
-
function isRowIdSelected(rowSelection, rowId) {
|
|
462
|
-
return !!(rowSelection && require_utils.hasOwn(rowSelection, rowId) && rowSelection[rowId]);
|
|
467
|
+
function isRowSelected(row, rowSelection) {
|
|
468
|
+
return !!(require_utils.hasOwn(rowSelection, row.id) && rowSelection[row.id]);
|
|
463
469
|
}
|
|
464
470
|
/**
|
|
465
471
|
* Returns whether all, some, or none of a row's selectable descendants are selected.
|
|
@@ -472,12 +478,14 @@ function isRowIdSelected(rowSelection, rowId) {
|
|
|
472
478
|
* ```
|
|
473
479
|
*/
|
|
474
480
|
function isSubRowSelected(row) {
|
|
481
|
+
var _row$table$atoms$rowS2;
|
|
475
482
|
if (!row.subRows.length) return false;
|
|
483
|
+
const rowSelection = ((_row$table$atoms$rowS2 = row.table.atoms.rowSelection) === null || _row$table$atoms$rowS2 === void 0 ? void 0 : _row$table$atoms$rowS2.get()) ?? {};
|
|
476
484
|
let allChildrenSelected = true;
|
|
477
485
|
let someSelected = false;
|
|
478
486
|
row.subRows.forEach((subRow) => {
|
|
479
487
|
if (someSelected && !allChildrenSelected) return;
|
|
480
|
-
if (row_getCanSelect(subRow)) if (isRowSelected(subRow)) someSelected = true;
|
|
488
|
+
if (row_getCanSelect(subRow)) if (isRowSelected(subRow, rowSelection)) someSelected = true;
|
|
481
489
|
else allChildrenSelected = false;
|
|
482
490
|
if (subRow.subRows.length) {
|
|
483
491
|
const subRowChildrenSelected = isSubRowSelected(subRow);
|
|
@@ -511,6 +519,7 @@ exports.table_getIsAllRowsSelected = table_getIsAllRowsSelected;
|
|
|
511
519
|
exports.table_getIsSomePageRowsSelected = table_getIsSomePageRowsSelected;
|
|
512
520
|
exports.table_getIsSomeRowsSelected = table_getIsSomeRowsSelected;
|
|
513
521
|
exports.table_getPreSelectedRowModel = table_getPreSelectedRowModel;
|
|
522
|
+
exports.table_getSelectedRowIds = table_getSelectedRowIds;
|
|
514
523
|
exports.table_getSelectedRowModel = table_getSelectedRowModel;
|
|
515
524
|
exports.table_getToggleAllPageRowsSelectedHandler = table_getToggleAllPageRowsSelectedHandler;
|
|
516
525
|
exports.table_getToggleAllRowsSelectedHandler = table_getToggleAllRowsSelectedHandler;
|