@tanstack/table-core 8.17.3 → 9.0.0-alpha.0

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.
Files changed (259) hide show
  1. package/dist/cjs/aggregationFns.cjs +98 -0
  2. package/dist/cjs/aggregationFns.cjs.map +1 -0
  3. package/dist/cjs/aggregationFns.d.cts +14 -0
  4. package/dist/cjs/columnHelper.cjs +19 -0
  5. package/dist/cjs/columnHelper.cjs.map +1 -0
  6. package/dist/cjs/columnHelper.d.cts +9 -0
  7. package/dist/cjs/core/cell.cjs +38 -0
  8. package/dist/cjs/core/cell.cjs.map +1 -0
  9. package/dist/cjs/core/cell.d.cts +50 -0
  10. package/dist/cjs/core/column.cjs +81 -0
  11. package/dist/cjs/core/column.cjs.map +1 -0
  12. package/dist/cjs/core/column.d.cts +56 -0
  13. package/dist/cjs/core/headers.cjs +310 -0
  14. package/dist/cjs/core/headers.cjs.map +1 -0
  15. package/dist/cjs/core/headers.d.cts +195 -0
  16. package/dist/cjs/core/row.cjs +93 -0
  17. package/dist/cjs/core/row.cjs.map +1 -0
  18. package/dist/cjs/core/row.d.cts +92 -0
  19. package/dist/cjs/core/table.cjs +228 -0
  20. package/dist/cjs/core/table.cjs.map +1 -0
  21. package/dist/cjs/core/table.d.cts +221 -0
  22. package/dist/cjs/features/ColumnFaceting.cjs +29 -0
  23. package/dist/cjs/features/ColumnFaceting.cjs.map +1 -0
  24. package/dist/cjs/features/ColumnFaceting.d.cts +35 -0
  25. package/dist/cjs/features/ColumnFiltering.cjs +137 -0
  26. package/dist/cjs/features/ColumnFiltering.cjs.map +1 -0
  27. package/dist/cjs/features/ColumnFiltering.d.cts +195 -0
  28. package/dist/cjs/features/ColumnGrouping.cjs +134 -0
  29. package/dist/cjs/features/ColumnGrouping.cjs.map +1 -0
  30. package/dist/cjs/features/ColumnGrouping.d.cts +202 -0
  31. package/dist/cjs/features/ColumnOrdering.cjs +76 -0
  32. package/dist/cjs/features/ColumnOrdering.cjs.map +1 -0
  33. package/dist/cjs/features/ColumnOrdering.d.cts +54 -0
  34. package/dist/cjs/features/ColumnPinning.cjs +145 -0
  35. package/dist/cjs/features/ColumnPinning.cjs.map +1 -0
  36. package/dist/cjs/features/ColumnPinning.d.cts +127 -0
  37. package/dist/cjs/features/ColumnSizing.cjs +308 -0
  38. package/dist/cjs/features/ColumnSizing.cjs.map +1 -0
  39. package/dist/cjs/features/ColumnSizing.d.cts +194 -0
  40. package/dist/cjs/features/ColumnVisibility.cjs +144 -0
  41. package/dist/cjs/features/ColumnVisibility.cjs.map +1 -0
  42. package/dist/cjs/features/ColumnVisibility.d.cts +130 -0
  43. package/dist/cjs/features/GlobalFaceting.cjs +29 -0
  44. package/dist/cjs/features/GlobalFaceting.cjs.map +1 -0
  45. package/dist/cjs/features/GlobalFaceting.d.cts +27 -0
  46. package/dist/cjs/features/GlobalFiltering.cjs +50 -0
  47. package/dist/cjs/features/GlobalFiltering.cjs.map +1 -0
  48. package/dist/cjs/features/GlobalFiltering.d.cts +80 -0
  49. package/dist/cjs/features/RowExpanding.cjs +154 -0
  50. package/dist/cjs/features/RowExpanding.cjs.map +1 -0
  51. package/dist/cjs/features/RowExpanding.d.cts +155 -0
  52. package/dist/cjs/features/RowPagination.cjs +162 -0
  53. package/dist/cjs/features/RowPagination.cjs.map +1 -0
  54. package/dist/cjs/features/RowPagination.d.cts +166 -0
  55. package/dist/cjs/features/RowPinning.cjs +133 -0
  56. package/dist/cjs/features/RowPinning.cjs.map +1 -0
  57. package/dist/cjs/features/RowPinning.d.cts +99 -0
  58. package/dist/cjs/features/RowSelection.cjs +298 -0
  59. package/dist/cjs/features/RowSelection.cjs.map +1 -0
  60. package/dist/cjs/features/RowSelection.d.cts +177 -0
  61. package/dist/cjs/features/RowSorting.cjs +201 -0
  62. package/dist/cjs/features/RowSorting.cjs.map +1 -0
  63. package/dist/cjs/features/RowSorting.d.cts +238 -0
  64. package/dist/cjs/filterFns.cjs +88 -0
  65. package/dist/cjs/filterFns.cjs.map +1 -0
  66. package/dist/cjs/filterFns.d.cts +14 -0
  67. package/{build/lib/index.js → dist/cjs/index.cjs} +36 -49
  68. package/dist/cjs/index.cjs.map +1 -0
  69. package/dist/cjs/index.d.cts +34 -0
  70. package/{build/lib/sortingFns.js → dist/cjs/sortingFns.cjs} +23 -52
  71. package/dist/cjs/sortingFns.cjs.map +1 -0
  72. package/dist/cjs/sortingFns.d.cts +12 -0
  73. package/dist/cjs/types.d.cts +120 -0
  74. package/{build/lib/utils/filterRowsUtils.js → dist/cjs/utils/filterRowsUtils.cjs} +34 -46
  75. package/dist/cjs/utils/filterRowsUtils.cjs.map +1 -0
  76. package/dist/cjs/utils/filterRowsUtils.d.cts +3 -0
  77. package/dist/cjs/utils/getCoreRowModel.cjs +54 -0
  78. package/dist/cjs/utils/getCoreRowModel.cjs.map +1 -0
  79. package/dist/cjs/utils/getCoreRowModel.d.cts +3 -0
  80. package/dist/cjs/utils/getExpandedRowModel.cjs +41 -0
  81. package/dist/cjs/utils/getExpandedRowModel.cjs.map +1 -0
  82. package/dist/cjs/utils/getExpandedRowModel.d.cts +8 -0
  83. package/dist/cjs/utils/getFacetedMinMaxValues.cjs +36 -0
  84. package/dist/cjs/utils/getFacetedMinMaxValues.cjs.map +1 -0
  85. package/dist/cjs/utils/getFacetedMinMaxValues.d.cts +3 -0
  86. package/dist/cjs/utils/getFacetedRowModel.cjs +35 -0
  87. package/dist/cjs/utils/getFacetedRowModel.cjs.map +1 -0
  88. package/dist/cjs/utils/getFacetedRowModel.d.cts +3 -0
  89. package/dist/cjs/utils/getFacetedUniqueValues.cjs +38 -0
  90. package/dist/cjs/utils/getFacetedUniqueValues.cjs.map +1 -0
  91. package/dist/cjs/utils/getFacetedUniqueValues.d.cts +3 -0
  92. package/dist/cjs/utils/getFilteredRowModel.cjs +116 -0
  93. package/dist/cjs/utils/getFilteredRowModel.cjs.map +1 -0
  94. package/dist/cjs/utils/getFilteredRowModel.d.cts +3 -0
  95. package/dist/cjs/utils/getGroupedRowModel.cjs +118 -0
  96. package/dist/cjs/utils/getGroupedRowModel.cjs.map +1 -0
  97. package/dist/cjs/utils/getGroupedRowModel.d.cts +3 -0
  98. package/dist/cjs/utils/getPaginationRowModel.cjs +49 -0
  99. package/dist/cjs/utils/getPaginationRowModel.cjs.map +1 -0
  100. package/dist/cjs/utils/getPaginationRowModel.d.cts +5 -0
  101. package/dist/cjs/utils/getSortedRowModel.cjs +91 -0
  102. package/dist/cjs/utils/getSortedRowModel.cjs.map +1 -0
  103. package/dist/cjs/utils/getSortedRowModel.d.cts +3 -0
  104. package/{build/lib/utils.js → dist/cjs/utils.cjs} +30 -41
  105. package/dist/cjs/utils.cjs.map +1 -0
  106. package/dist/cjs/utils.d.cts +39 -0
  107. package/{build/lib → dist/esm}/aggregationFns.d.ts +2 -1
  108. package/dist/esm/aggregationFns.js +98 -0
  109. package/dist/esm/aggregationFns.js.map +1 -0
  110. package/{build/lib → dist/esm}/columnHelper.d.ts +3 -2
  111. package/dist/esm/columnHelper.js +19 -0
  112. package/{build/lib → dist/esm}/columnHelper.js.map +1 -1
  113. package/{build/lib → dist/esm}/core/cell.d.ts +1 -0
  114. package/dist/esm/core/cell.js +38 -0
  115. package/{build/lib → dist/esm}/core/cell.js.map +1 -1
  116. package/{build/lib → dist/esm}/core/column.d.ts +1 -0
  117. package/dist/esm/core/column.js +81 -0
  118. package/{build/lib → dist/esm}/core/column.js.map +1 -1
  119. package/{build/lib → dist/esm}/core/headers.d.ts +1 -0
  120. package/dist/esm/core/headers.js +310 -0
  121. package/{build/lib → dist/esm}/core/headers.js.map +1 -1
  122. package/{build/lib → dist/esm}/core/row.d.ts +1 -0
  123. package/dist/esm/core/row.js +93 -0
  124. package/{build/lib → dist/esm}/core/row.js.map +1 -1
  125. package/{build/lib → dist/esm}/core/table.d.ts +1 -0
  126. package/dist/esm/core/table.js +228 -0
  127. package/{build/lib → dist/esm}/core/table.js.map +1 -1
  128. package/{build/lib → dist/esm}/features/ColumnFaceting.d.ts +1 -0
  129. package/{build/lib → dist/esm}/features/ColumnFaceting.js +5 -18
  130. package/{build/lib → dist/esm}/features/ColumnFaceting.js.map +1 -1
  131. package/{build/lib → dist/esm}/features/ColumnFiltering.d.ts +1 -0
  132. package/dist/esm/features/ColumnFiltering.js +137 -0
  133. package/{build/lib → dist/esm}/features/ColumnFiltering.js.map +1 -1
  134. package/{build/lib → dist/esm}/features/ColumnGrouping.d.ts +1 -0
  135. package/dist/esm/features/ColumnGrouping.js +134 -0
  136. package/{build/lib → dist/esm}/features/ColumnGrouping.js.map +1 -1
  137. package/{build/lib → dist/esm}/features/ColumnOrdering.d.ts +1 -0
  138. package/dist/esm/features/ColumnOrdering.js +76 -0
  139. package/{build/lib → dist/esm}/features/ColumnOrdering.js.map +1 -1
  140. package/{build/lib → dist/esm}/features/ColumnPinning.d.ts +1 -0
  141. package/dist/esm/features/ColumnPinning.js +145 -0
  142. package/{build/lib → dist/esm}/features/ColumnPinning.js.map +1 -1
  143. package/{build/lib → dist/esm}/features/ColumnSizing.d.ts +2 -1
  144. package/dist/esm/features/ColumnSizing.js +308 -0
  145. package/{build/lib → dist/esm}/features/ColumnSizing.js.map +1 -1
  146. package/{build/lib → dist/esm}/features/ColumnVisibility.d.ts +1 -0
  147. package/dist/esm/features/ColumnVisibility.js +144 -0
  148. package/{build/lib → dist/esm}/features/ColumnVisibility.js.map +1 -1
  149. package/{build/lib → dist/esm}/features/GlobalFaceting.d.ts +1 -0
  150. package/{build/lib → dist/esm}/features/GlobalFaceting.js +8 -21
  151. package/{build/lib → dist/esm}/features/GlobalFaceting.js.map +1 -1
  152. package/{build/lib → dist/esm}/features/GlobalFiltering.d.ts +1 -0
  153. package/dist/esm/features/GlobalFiltering.js +50 -0
  154. package/{build/lib → dist/esm}/features/GlobalFiltering.js.map +1 -1
  155. package/{build/lib → dist/esm}/features/RowExpanding.d.ts +1 -0
  156. package/{build/lib → dist/esm}/features/RowExpanding.js +40 -59
  157. package/{build/lib → dist/esm}/features/RowExpanding.js.map +1 -1
  158. package/{build/lib → dist/esm}/features/RowPagination.d.ts +1 -0
  159. package/dist/esm/features/RowPagination.js +162 -0
  160. package/{build/lib → dist/esm}/features/RowPagination.js.map +1 -1
  161. package/{build/lib → dist/esm}/features/RowPinning.d.ts +1 -0
  162. package/dist/esm/features/RowPinning.js +133 -0
  163. package/{build/lib → dist/esm}/features/RowPinning.js.map +1 -1
  164. package/{build/lib → dist/esm}/features/RowSelection.d.ts +1 -0
  165. package/dist/esm/features/RowSelection.js +298 -0
  166. package/{build/lib → dist/esm}/features/RowSelection.js.map +1 -1
  167. package/{build/lib → dist/esm}/features/RowSorting.d.ts +1 -0
  168. package/dist/esm/features/RowSorting.js +201 -0
  169. package/{build/lib → dist/esm}/features/RowSorting.js.map +1 -1
  170. package/{build/lib → dist/esm}/filterFns.d.ts +2 -1
  171. package/dist/esm/filterFns.js +88 -0
  172. package/dist/esm/filterFns.js.map +1 -0
  173. package/dist/esm/index.d.ts +34 -0
  174. package/dist/esm/index.js +87 -0
  175. package/dist/esm/index.js.map +1 -0
  176. package/{build/lib → dist/esm}/sortingFns.d.ts +2 -1
  177. package/dist/esm/sortingFns.js +91 -0
  178. package/dist/esm/sortingFns.js.map +1 -0
  179. package/{build/lib → dist/esm}/types.d.ts +21 -20
  180. package/{build/lib → dist/esm}/utils/filterRowsUtils.d.ts +1 -0
  181. package/dist/esm/utils/filterRowsUtils.js +99 -0
  182. package/dist/esm/utils/filterRowsUtils.js.map +1 -0
  183. package/{build/lib → dist/esm}/utils/getCoreRowModel.d.ts +1 -0
  184. package/dist/esm/utils/getCoreRowModel.js +54 -0
  185. package/{build/lib → dist/esm}/utils/getCoreRowModel.js.map +1 -1
  186. package/{build/lib → dist/esm}/utils/getExpandedRowModel.d.ts +1 -0
  187. package/dist/esm/utils/getExpandedRowModel.js +41 -0
  188. package/dist/esm/utils/getExpandedRowModel.js.map +1 -0
  189. package/{build/lib → dist/esm}/utils/getFacetedMinMaxValues.d.ts +1 -0
  190. package/dist/esm/utils/getFacetedMinMaxValues.js +36 -0
  191. package/dist/esm/utils/getFacetedMinMaxValues.js.map +1 -0
  192. package/{build/lib → dist/esm}/utils/getFacetedRowModel.d.ts +1 -0
  193. package/dist/esm/utils/getFacetedRowModel.js +35 -0
  194. package/{build/lib → dist/esm}/utils/getFacetedRowModel.js.map +1 -1
  195. package/{build/lib → dist/esm}/utils/getFacetedUniqueValues.d.ts +1 -0
  196. package/dist/esm/utils/getFacetedUniqueValues.js +38 -0
  197. package/dist/esm/utils/getFacetedUniqueValues.js.map +1 -0
  198. package/{build/lib → dist/esm}/utils/getFilteredRowModel.d.ts +1 -0
  199. package/dist/esm/utils/getFilteredRowModel.js +116 -0
  200. package/{build/lib → dist/esm}/utils/getFilteredRowModel.js.map +1 -1
  201. package/{build/lib → dist/esm}/utils/getGroupedRowModel.d.ts +1 -0
  202. package/dist/esm/utils/getGroupedRowModel.js +118 -0
  203. package/{build/lib → dist/esm}/utils/getGroupedRowModel.js.map +1 -1
  204. package/{build/lib → dist/esm}/utils/getPaginationRowModel.d.ts +1 -0
  205. package/dist/esm/utils/getPaginationRowModel.js +49 -0
  206. package/dist/esm/utils/getPaginationRowModel.js.map +1 -0
  207. package/{build/lib → dist/esm}/utils/getSortedRowModel.d.ts +1 -0
  208. package/dist/esm/utils/getSortedRowModel.js +91 -0
  209. package/{build/lib → dist/esm}/utils/getSortedRowModel.js.map +1 -1
  210. package/{build/lib → dist/esm}/utils.d.ts +2 -1
  211. package/dist/esm/utils.js +100 -0
  212. package/{build/lib → dist/esm}/utils.js.map +1 -1
  213. package/package.json +15 -19
  214. package/build/lib/aggregationFns.js +0 -108
  215. package/build/lib/aggregationFns.js.map +0 -1
  216. package/build/lib/columnHelper.js +0 -71
  217. package/build/lib/core/cell.js +0 -42
  218. package/build/lib/core/column.js +0 -80
  219. package/build/lib/core/headers.js +0 -270
  220. package/build/lib/core/row.js +0 -89
  221. package/build/lib/core/table.js +0 -212
  222. package/build/lib/features/ColumnFiltering.js +0 -151
  223. package/build/lib/features/ColumnGrouping.js +0 -142
  224. package/build/lib/features/ColumnOrdering.js +0 -84
  225. package/build/lib/features/ColumnPinning.js +0 -130
  226. package/build/lib/features/ColumnSizing.js +0 -270
  227. package/build/lib/features/ColumnVisibility.js +0 -99
  228. package/build/lib/features/GlobalFiltering.js +0 -63
  229. package/build/lib/features/RowPagination.js +0 -169
  230. package/build/lib/features/RowPinning.js +0 -145
  231. package/build/lib/features/RowSelection.js +0 -391
  232. package/build/lib/features/RowSorting.js +0 -226
  233. package/build/lib/filterFns.js +0 -96
  234. package/build/lib/filterFns.js.map +0 -1
  235. package/build/lib/index.d.ts +0 -34
  236. package/build/lib/index.esm.js +0 -3522
  237. package/build/lib/index.esm.js.map +0 -1
  238. package/build/lib/index.js.map +0 -1
  239. package/build/lib/index.mjs +0 -3522
  240. package/build/lib/index.mjs.map +0 -1
  241. package/build/lib/sortingFns.js.map +0 -1
  242. package/build/lib/utils/filterRowsUtils.js.map +0 -1
  243. package/build/lib/utils/getCoreRowModel.js +0 -65
  244. package/build/lib/utils/getExpandedRowModel.js +0 -46
  245. package/build/lib/utils/getExpandedRowModel.js.map +0 -1
  246. package/build/lib/utils/getFacetedMinMaxValues.js +0 -43
  247. package/build/lib/utils/getFacetedMinMaxValues.js.map +0 -1
  248. package/build/lib/utils/getFacetedRowModel.js +0 -36
  249. package/build/lib/utils/getFacetedUniqueValues.js +0 -39
  250. package/build/lib/utils/getFacetedUniqueValues.js.map +0 -1
  251. package/build/lib/utils/getFilteredRowModel.js +0 -111
  252. package/build/lib/utils/getGroupedRowModel.js +0 -150
  253. package/build/lib/utils/getPaginationRowModel.js +0 -60
  254. package/build/lib/utils/getPaginationRowModel.js.map +0 -1
  255. package/build/lib/utils/getSortedRowModel.js +0 -102
  256. package/build/umd/index.development.js +0 -3578
  257. package/build/umd/index.development.js.map +0 -1
  258. package/build/umd/index.production.js +0 -12
  259. package/build/umd/index.production.js.map +0 -1
@@ -1,145 +0,0 @@
1
- /**
2
- * table-core
3
- *
4
- * Copyright (c) TanStack
5
- *
6
- * This source code is licensed under the MIT license found in the
7
- * LICENSE.md file in the root directory of this source tree.
8
- *
9
- * @license MIT
10
- */
11
- 'use strict';
12
-
13
- var utils = require('../utils.js');
14
-
15
- //
16
-
17
- const getDefaultRowPinningState = () => ({
18
- top: [],
19
- bottom: []
20
- });
21
- const RowPinning = {
22
- getInitialState: state => {
23
- return {
24
- rowPinning: getDefaultRowPinningState(),
25
- ...state
26
- };
27
- },
28
- getDefaultOptions: table => {
29
- return {
30
- onRowPinningChange: utils.makeStateUpdater('rowPinning', table)
31
- };
32
- },
33
- createRow: (row, table) => {
34
- row.pin = (position, includeLeafRows, includeParentRows) => {
35
- const leafRowIds = includeLeafRows ? row.getLeafRows().map(_ref => {
36
- let {
37
- id
38
- } = _ref;
39
- return id;
40
- }) : [];
41
- const parentRowIds = includeParentRows ? row.getParentRows().map(_ref2 => {
42
- let {
43
- id
44
- } = _ref2;
45
- return id;
46
- }) : [];
47
- const rowIds = new Set([...parentRowIds, row.id, ...leafRowIds]);
48
- table.setRowPinning(old => {
49
- var _old$top3, _old$bottom3;
50
- if (position === 'bottom') {
51
- var _old$top, _old$bottom;
52
- return {
53
- top: ((_old$top = old == null ? void 0 : old.top) != null ? _old$top : []).filter(d => !(rowIds != null && rowIds.has(d))),
54
- bottom: [...((_old$bottom = old == null ? void 0 : old.bottom) != null ? _old$bottom : []).filter(d => !(rowIds != null && rowIds.has(d))), ...Array.from(rowIds)]
55
- };
56
- }
57
- if (position === 'top') {
58
- var _old$top2, _old$bottom2;
59
- return {
60
- top: [...((_old$top2 = old == null ? void 0 : old.top) != null ? _old$top2 : []).filter(d => !(rowIds != null && rowIds.has(d))), ...Array.from(rowIds)],
61
- bottom: ((_old$bottom2 = old == null ? void 0 : old.bottom) != null ? _old$bottom2 : []).filter(d => !(rowIds != null && rowIds.has(d)))
62
- };
63
- }
64
- return {
65
- top: ((_old$top3 = old == null ? void 0 : old.top) != null ? _old$top3 : []).filter(d => !(rowIds != null && rowIds.has(d))),
66
- bottom: ((_old$bottom3 = old == null ? void 0 : old.bottom) != null ? _old$bottom3 : []).filter(d => !(rowIds != null && rowIds.has(d)))
67
- };
68
- });
69
- };
70
- row.getCanPin = () => {
71
- var _ref3;
72
- const {
73
- enableRowPinning,
74
- enablePinning
75
- } = table.options;
76
- if (typeof enableRowPinning === 'function') {
77
- return enableRowPinning(row);
78
- }
79
- return (_ref3 = enableRowPinning != null ? enableRowPinning : enablePinning) != null ? _ref3 : true;
80
- };
81
- row.getIsPinned = () => {
82
- const rowIds = [row.id];
83
- const {
84
- top,
85
- bottom
86
- } = table.getState().rowPinning;
87
- const isTop = rowIds.some(d => top == null ? void 0 : top.includes(d));
88
- const isBottom = rowIds.some(d => bottom == null ? void 0 : bottom.includes(d));
89
- return isTop ? 'top' : isBottom ? 'bottom' : false;
90
- };
91
- row.getPinnedIndex = () => {
92
- var _table$_getPinnedRows, _visiblePinnedRowIds$;
93
- const position = row.getIsPinned();
94
- if (!position) return -1;
95
- const visiblePinnedRowIds = (_table$_getPinnedRows = table._getPinnedRows(position)) == null ? void 0 : _table$_getPinnedRows.map(_ref4 => {
96
- let {
97
- id
98
- } = _ref4;
99
- return id;
100
- });
101
- return (_visiblePinnedRowIds$ = visiblePinnedRowIds == null ? void 0 : visiblePinnedRowIds.indexOf(row.id)) != null ? _visiblePinnedRowIds$ : -1;
102
- };
103
- },
104
- createTable: table => {
105
- table.setRowPinning = updater => table.options.onRowPinningChange == null ? void 0 : table.options.onRowPinningChange(updater);
106
- table.resetRowPinning = defaultState => {
107
- var _table$initialState$r, _table$initialState;
108
- return table.setRowPinning(defaultState ? getDefaultRowPinningState() : (_table$initialState$r = (_table$initialState = table.initialState) == null ? void 0 : _table$initialState.rowPinning) != null ? _table$initialState$r : getDefaultRowPinningState());
109
- };
110
- table.getIsSomeRowsPinned = position => {
111
- var _pinningState$positio;
112
- const pinningState = table.getState().rowPinning;
113
- if (!position) {
114
- var _pinningState$top, _pinningState$bottom;
115
- return Boolean(((_pinningState$top = pinningState.top) == null ? void 0 : _pinningState$top.length) || ((_pinningState$bottom = pinningState.bottom) == null ? void 0 : _pinningState$bottom.length));
116
- }
117
- return Boolean((_pinningState$positio = pinningState[position]) == null ? void 0 : _pinningState$positio.length);
118
- };
119
- table._getPinnedRows = utils.memo(position => [table.getRowModel().rows, table.getState().rowPinning[position], position], (visibleRows, pinnedRowIds, position) => {
120
- var _table$options$keepPi;
121
- const rows = ((_table$options$keepPi = table.options.keepPinnedRows) != null ? _table$options$keepPi : true) ?
122
- //get all rows that are pinned even if they would not be otherwise visible
123
- //account for expanded parent rows, but not pagination or filtering
124
- (pinnedRowIds != null ? pinnedRowIds : []).map(rowId => {
125
- const row = table.getRow(rowId, true);
126
- return row.getIsAllParentsExpanded() ? row : null;
127
- }) :
128
- //else get only visible rows that are pinned
129
- (pinnedRowIds != null ? pinnedRowIds : []).map(rowId => visibleRows.find(row => row.id === rowId));
130
- return rows.filter(Boolean).map(d => ({
131
- ...d,
132
- position
133
- }));
134
- }, utils.getMemoOptions(table.options, 'debugRows', '_getPinnedRows'));
135
- table.getTopRows = () => table._getPinnedRows('top');
136
- table.getBottomRows = () => table._getPinnedRows('bottom');
137
- table.getCenterRows = utils.memo(() => [table.getRowModel().rows, table.getState().rowPinning.top, table.getState().rowPinning.bottom], (allRows, top, bottom) => {
138
- const topAndBottom = new Set([...(top != null ? top : []), ...(bottom != null ? bottom : [])]);
139
- return allRows.filter(d => !topAndBottom.has(d.id));
140
- }, utils.getMemoOptions(table.options, 'debugRows', 'getCenterRows'));
141
- }
142
- };
143
-
144
- exports.RowPinning = RowPinning;
145
- //# sourceMappingURL=RowPinning.js.map
@@ -1,391 +0,0 @@
1
- /**
2
- * table-core
3
- *
4
- * Copyright (c) TanStack
5
- *
6
- * This source code is licensed under the MIT license found in the
7
- * LICENSE.md file in the root directory of this source tree.
8
- *
9
- * @license MIT
10
- */
11
- 'use strict';
12
-
13
- var utils = require('../utils.js');
14
-
15
- //
16
-
17
- const RowSelection = {
18
- getInitialState: state => {
19
- return {
20
- rowSelection: {},
21
- ...state
22
- };
23
- },
24
- getDefaultOptions: table => {
25
- return {
26
- onRowSelectionChange: utils.makeStateUpdater('rowSelection', table),
27
- enableRowSelection: true,
28
- enableMultiRowSelection: true,
29
- enableSubRowSelection: true
30
- // enableGroupingRowSelection: false,
31
- // isAdditiveSelectEvent: (e: unknown) => !!e.metaKey,
32
- // isInclusiveSelectEvent: (e: unknown) => !!e.shiftKey,
33
- };
34
- },
35
- createTable: table => {
36
- table.setRowSelection = updater => table.options.onRowSelectionChange == null ? void 0 : table.options.onRowSelectionChange(updater);
37
- table.resetRowSelection = defaultState => {
38
- var _table$initialState$r;
39
- return table.setRowSelection(defaultState ? {} : (_table$initialState$r = table.initialState.rowSelection) != null ? _table$initialState$r : {});
40
- };
41
- table.toggleAllRowsSelected = value => {
42
- table.setRowSelection(old => {
43
- value = typeof value !== 'undefined' ? value : !table.getIsAllRowsSelected();
44
- const rowSelection = {
45
- ...old
46
- };
47
- const preGroupedFlatRows = table.getPreGroupedRowModel().flatRows;
48
-
49
- // We don't use `mutateRowIsSelected` here for performance reasons.
50
- // All of the rows are flat already, so it wouldn't be worth it
51
- if (value) {
52
- preGroupedFlatRows.forEach(row => {
53
- if (!row.getCanSelect()) {
54
- return;
55
- }
56
- rowSelection[row.id] = true;
57
- });
58
- } else {
59
- preGroupedFlatRows.forEach(row => {
60
- delete rowSelection[row.id];
61
- });
62
- }
63
- return rowSelection;
64
- });
65
- };
66
- table.toggleAllPageRowsSelected = value => table.setRowSelection(old => {
67
- const resolvedValue = typeof value !== 'undefined' ? value : !table.getIsAllPageRowsSelected();
68
- const rowSelection = {
69
- ...old
70
- };
71
- table.getRowModel().rows.forEach(row => {
72
- mutateRowIsSelected(rowSelection, row.id, resolvedValue, true, table);
73
- });
74
- return rowSelection;
75
- });
76
-
77
- // addRowSelectionRange: rowId => {
78
- // const {
79
- // rows,
80
- // rowsById,
81
- // options: { selectGroupingRows, selectSubRows },
82
- // } = table
83
-
84
- // const findSelectedRow = (rows: Row[]) => {
85
- // let found
86
- // rows.find(d => {
87
- // if (d.getIsSelected()) {
88
- // found = d
89
- // return true
90
- // }
91
- // const subFound = findSelectedRow(d.subRows || [])
92
- // if (subFound) {
93
- // found = subFound
94
- // return true
95
- // }
96
- // return false
97
- // })
98
- // return found
99
- // }
100
-
101
- // const firstRow = findSelectedRow(rows) || rows[0]
102
- // const lastRow = rowsById[rowId]
103
-
104
- // let include = false
105
- // const selectedRowIds = {}
106
-
107
- // const addRow = (row: Row) => {
108
- // mutateRowIsSelected(selectedRowIds, row.id, true, {
109
- // rowsById,
110
- // selectGroupingRows: selectGroupingRows!,
111
- // selectSubRows: selectSubRows!,
112
- // })
113
- // }
114
-
115
- // table.rows.forEach(row => {
116
- // const isFirstRow = row.id === firstRow.id
117
- // const isLastRow = row.id === lastRow.id
118
-
119
- // if (isFirstRow || isLastRow) {
120
- // if (!include) {
121
- // include = true
122
- // } else if (include) {
123
- // addRow(row)
124
- // include = false
125
- // }
126
- // }
127
-
128
- // if (include) {
129
- // addRow(row)
130
- // }
131
- // })
132
-
133
- // table.setRowSelection(selectedRowIds)
134
- // },
135
- table.getPreSelectedRowModel = () => table.getCoreRowModel();
136
- table.getSelectedRowModel = utils.memo(() => [table.getState().rowSelection, table.getCoreRowModel()], (rowSelection, rowModel) => {
137
- if (!Object.keys(rowSelection).length) {
138
- return {
139
- rows: [],
140
- flatRows: [],
141
- rowsById: {}
142
- };
143
- }
144
- return selectRowsFn(table, rowModel);
145
- }, utils.getMemoOptions(table.options, 'debugTable', 'getSelectedRowModel'));
146
- table.getFilteredSelectedRowModel = utils.memo(() => [table.getState().rowSelection, table.getFilteredRowModel()], (rowSelection, rowModel) => {
147
- if (!Object.keys(rowSelection).length) {
148
- return {
149
- rows: [],
150
- flatRows: [],
151
- rowsById: {}
152
- };
153
- }
154
- return selectRowsFn(table, rowModel);
155
- }, utils.getMemoOptions(table.options, 'debugTable', 'getFilteredSelectedRowModel'));
156
- table.getGroupedSelectedRowModel = utils.memo(() => [table.getState().rowSelection, table.getSortedRowModel()], (rowSelection, rowModel) => {
157
- if (!Object.keys(rowSelection).length) {
158
- return {
159
- rows: [],
160
- flatRows: [],
161
- rowsById: {}
162
- };
163
- }
164
- return selectRowsFn(table, rowModel);
165
- }, utils.getMemoOptions(table.options, 'debugTable', 'getGroupedSelectedRowModel'));
166
-
167
- ///
168
-
169
- // getGroupingRowCanSelect: rowId => {
170
- // const row = table.getRow(rowId)
171
-
172
- // if (!row) {
173
- // throw new Error()
174
- // }
175
-
176
- // if (typeof table.options.enableGroupingRowSelection === 'function') {
177
- // return table.options.enableGroupingRowSelection(row)
178
- // }
179
-
180
- // return table.options.enableGroupingRowSelection ?? false
181
- // },
182
-
183
- table.getIsAllRowsSelected = () => {
184
- const preGroupedFlatRows = table.getFilteredRowModel().flatRows;
185
- const {
186
- rowSelection
187
- } = table.getState();
188
- let isAllRowsSelected = Boolean(preGroupedFlatRows.length && Object.keys(rowSelection).length);
189
- if (isAllRowsSelected) {
190
- if (preGroupedFlatRows.some(row => row.getCanSelect() && !rowSelection[row.id])) {
191
- isAllRowsSelected = false;
192
- }
193
- }
194
- return isAllRowsSelected;
195
- };
196
- table.getIsAllPageRowsSelected = () => {
197
- const paginationFlatRows = table.getPaginationRowModel().flatRows.filter(row => row.getCanSelect());
198
- const {
199
- rowSelection
200
- } = table.getState();
201
- let isAllPageRowsSelected = !!paginationFlatRows.length;
202
- if (isAllPageRowsSelected && paginationFlatRows.some(row => !rowSelection[row.id])) {
203
- isAllPageRowsSelected = false;
204
- }
205
- return isAllPageRowsSelected;
206
- };
207
- table.getIsSomeRowsSelected = () => {
208
- var _table$getState$rowSe;
209
- const totalSelected = Object.keys((_table$getState$rowSe = table.getState().rowSelection) != null ? _table$getState$rowSe : {}).length;
210
- return totalSelected > 0 && totalSelected < table.getFilteredRowModel().flatRows.length;
211
- };
212
- table.getIsSomePageRowsSelected = () => {
213
- const paginationFlatRows = table.getPaginationRowModel().flatRows;
214
- return table.getIsAllPageRowsSelected() ? false : paginationFlatRows.filter(row => row.getCanSelect()).some(d => d.getIsSelected() || d.getIsSomeSelected());
215
- };
216
- table.getToggleAllRowsSelectedHandler = () => {
217
- return e => {
218
- table.toggleAllRowsSelected(e.target.checked);
219
- };
220
- };
221
- table.getToggleAllPageRowsSelectedHandler = () => {
222
- return e => {
223
- table.toggleAllPageRowsSelected(e.target.checked);
224
- };
225
- };
226
- },
227
- createRow: (row, table) => {
228
- row.toggleSelected = (value, opts) => {
229
- const isSelected = row.getIsSelected();
230
- table.setRowSelection(old => {
231
- var _opts$selectChildren;
232
- value = typeof value !== 'undefined' ? value : !isSelected;
233
- if (row.getCanSelect() && isSelected === value) {
234
- return old;
235
- }
236
- const selectedRowIds = {
237
- ...old
238
- };
239
- mutateRowIsSelected(selectedRowIds, row.id, value, (_opts$selectChildren = opts == null ? void 0 : opts.selectChildren) != null ? _opts$selectChildren : true, table);
240
- return selectedRowIds;
241
- });
242
- };
243
- row.getIsSelected = () => {
244
- const {
245
- rowSelection
246
- } = table.getState();
247
- return isRowSelected(row, rowSelection);
248
- };
249
- row.getIsSomeSelected = () => {
250
- const {
251
- rowSelection
252
- } = table.getState();
253
- return isSubRowSelected(row, rowSelection) === 'some';
254
- };
255
- row.getIsAllSubRowsSelected = () => {
256
- const {
257
- rowSelection
258
- } = table.getState();
259
- return isSubRowSelected(row, rowSelection) === 'all';
260
- };
261
- row.getCanSelect = () => {
262
- var _table$options$enable;
263
- if (typeof table.options.enableRowSelection === 'function') {
264
- return table.options.enableRowSelection(row);
265
- }
266
- return (_table$options$enable = table.options.enableRowSelection) != null ? _table$options$enable : true;
267
- };
268
- row.getCanSelectSubRows = () => {
269
- var _table$options$enable2;
270
- if (typeof table.options.enableSubRowSelection === 'function') {
271
- return table.options.enableSubRowSelection(row);
272
- }
273
- return (_table$options$enable2 = table.options.enableSubRowSelection) != null ? _table$options$enable2 : true;
274
- };
275
- row.getCanMultiSelect = () => {
276
- var _table$options$enable3;
277
- if (typeof table.options.enableMultiRowSelection === 'function') {
278
- return table.options.enableMultiRowSelection(row);
279
- }
280
- return (_table$options$enable3 = table.options.enableMultiRowSelection) != null ? _table$options$enable3 : true;
281
- };
282
- row.getToggleSelectedHandler = () => {
283
- const canSelect = row.getCanSelect();
284
- return e => {
285
- var _target;
286
- if (!canSelect) return;
287
- row.toggleSelected((_target = e.target) == null ? void 0 : _target.checked);
288
- };
289
- };
290
- }
291
- };
292
- const mutateRowIsSelected = (selectedRowIds, id, value, includeChildren, table) => {
293
- var _row$subRows;
294
- const row = table.getRow(id, true);
295
-
296
- // const isGrouped = row.getIsGrouped()
297
-
298
- // if ( // TODO: enforce grouping row selection rules
299
- // !isGrouped ||
300
- // (isGrouped && table.options.enableGroupingRowSelection)
301
- // ) {
302
- if (value) {
303
- if (!row.getCanMultiSelect()) {
304
- Object.keys(selectedRowIds).forEach(key => delete selectedRowIds[key]);
305
- }
306
- if (row.getCanSelect()) {
307
- selectedRowIds[id] = true;
308
- }
309
- } else {
310
- delete selectedRowIds[id];
311
- }
312
- // }
313
-
314
- if (includeChildren && (_row$subRows = row.subRows) != null && _row$subRows.length && row.getCanSelectSubRows()) {
315
- row.subRows.forEach(row => mutateRowIsSelected(selectedRowIds, row.id, value, includeChildren, table));
316
- }
317
- };
318
- function selectRowsFn(table, rowModel) {
319
- const rowSelection = table.getState().rowSelection;
320
- const newSelectedFlatRows = [];
321
- const newSelectedRowsById = {};
322
-
323
- // Filters top level and nested rows
324
- const recurseRows = function (rows, depth) {
325
- return rows.map(row => {
326
- var _row$subRows2;
327
- const isSelected = isRowSelected(row, rowSelection);
328
- if (isSelected) {
329
- newSelectedFlatRows.push(row);
330
- newSelectedRowsById[row.id] = row;
331
- }
332
- if ((_row$subRows2 = row.subRows) != null && _row$subRows2.length) {
333
- row = {
334
- ...row,
335
- subRows: recurseRows(row.subRows)
336
- };
337
- }
338
- if (isSelected) {
339
- return row;
340
- }
341
- }).filter(Boolean);
342
- };
343
- return {
344
- rows: recurseRows(rowModel.rows),
345
- flatRows: newSelectedFlatRows,
346
- rowsById: newSelectedRowsById
347
- };
348
- }
349
- function isRowSelected(row, selection) {
350
- var _selection$row$id;
351
- return (_selection$row$id = selection[row.id]) != null ? _selection$row$id : false;
352
- }
353
- function isSubRowSelected(row, selection, table) {
354
- var _row$subRows3;
355
- if (!((_row$subRows3 = row.subRows) != null && _row$subRows3.length)) return false;
356
- let allChildrenSelected = true;
357
- let someSelected = false;
358
- row.subRows.forEach(subRow => {
359
- // Bail out early if we know both of these
360
- if (someSelected && !allChildrenSelected) {
361
- return;
362
- }
363
- if (subRow.getCanSelect()) {
364
- if (isRowSelected(subRow, selection)) {
365
- someSelected = true;
366
- } else {
367
- allChildrenSelected = false;
368
- }
369
- }
370
-
371
- // Check row selection of nested subrows
372
- if (subRow.subRows && subRow.subRows.length) {
373
- const subRowChildrenSelected = isSubRowSelected(subRow, selection);
374
- if (subRowChildrenSelected === 'all') {
375
- someSelected = true;
376
- } else if (subRowChildrenSelected === 'some') {
377
- someSelected = true;
378
- allChildrenSelected = false;
379
- } else {
380
- allChildrenSelected = false;
381
- }
382
- }
383
- });
384
- return allChildrenSelected ? 'all' : someSelected ? 'some' : false;
385
- }
386
-
387
- exports.RowSelection = RowSelection;
388
- exports.isRowSelected = isRowSelected;
389
- exports.isSubRowSelected = isSubRowSelected;
390
- exports.selectRowsFn = selectRowsFn;
391
- //# sourceMappingURL=RowSelection.js.map