@tanstack/table-core 8.0.0-alpha.9 → 8.0.0-beta.2

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 (186) hide show
  1. package/build/cjs/aggregationFns.js +120 -0
  2. package/build/cjs/aggregationFns.js.map +1 -0
  3. package/build/cjs/core/cell.js +40 -0
  4. package/build/cjs/core/cell.js.map +1 -0
  5. package/build/cjs/core/column.js +88 -0
  6. package/build/cjs/core/column.js.map +1 -0
  7. package/build/cjs/core/headers.js +403 -0
  8. package/build/cjs/core/headers.js.map +1 -0
  9. package/build/cjs/core/instance.js +255 -0
  10. package/build/cjs/core/instance.js.map +1 -0
  11. package/build/cjs/core/row.js +77 -0
  12. package/build/cjs/core/row.js.map +1 -0
  13. package/build/cjs/createTable.js +36 -29
  14. package/build/cjs/createTable.js.map +1 -1
  15. package/build/cjs/features/ColumnSizing.js +157 -189
  16. package/build/cjs/features/ColumnSizing.js.map +1 -1
  17. package/build/cjs/features/Expanding.js +103 -155
  18. package/build/cjs/features/Expanding.js.map +1 -1
  19. package/build/cjs/features/Filters.js +155 -304
  20. package/build/cjs/features/Filters.js.map +1 -1
  21. package/build/cjs/features/Grouping.js +97 -157
  22. package/build/cjs/features/Grouping.js.map +1 -1
  23. package/build/cjs/features/Ordering.js +30 -41
  24. package/build/cjs/features/Ordering.js.map +1 -1
  25. package/build/cjs/features/Pagination.js +102 -105
  26. package/build/cjs/features/Pagination.js.map +1 -1
  27. package/build/cjs/features/Pinning.js +131 -89
  28. package/build/cjs/features/Pinning.js.map +1 -1
  29. package/build/cjs/features/RowSelection.js +138 -267
  30. package/build/cjs/features/RowSelection.js.map +1 -1
  31. package/build/cjs/features/Sorting.js +82 -167
  32. package/build/cjs/features/Sorting.js.map +1 -1
  33. package/build/cjs/features/Visibility.js +69 -115
  34. package/build/cjs/features/Visibility.js.map +1 -1
  35. package/build/cjs/filterFns.js +107 -0
  36. package/build/cjs/filterFns.js.map +1 -0
  37. package/build/cjs/index.js +36 -23
  38. package/build/cjs/index.js.map +1 -1
  39. package/build/cjs/sortingFns.js +124 -0
  40. package/build/cjs/sortingFns.js.map +1 -0
  41. package/build/cjs/utils/filterRowsUtils.js +117 -0
  42. package/build/cjs/utils/filterRowsUtils.js.map +1 -0
  43. package/build/cjs/utils/getCoreRowModel.js +79 -0
  44. package/build/cjs/utils/getCoreRowModel.js.map +1 -0
  45. package/build/cjs/utils/getExpandedRowModel.js +57 -0
  46. package/build/cjs/utils/getExpandedRowModel.js.map +1 -0
  47. package/build/cjs/utils/getFacetedMinMaxValues.js +54 -0
  48. package/build/cjs/utils/getFacetedMinMaxValues.js.map +1 -0
  49. package/build/cjs/utils/getFacetedRowModel.js +50 -0
  50. package/build/cjs/utils/getFacetedRowModel.js.map +1 -0
  51. package/build/cjs/utils/getFacetedUniqueValues.js +48 -0
  52. package/build/cjs/utils/getFacetedUniqueValues.js.map +1 -0
  53. package/build/cjs/utils/getFilteredRowModel.js +139 -0
  54. package/build/cjs/utils/getFilteredRowModel.js.map +1 -0
  55. package/build/cjs/utils/getGroupedRowModel.js +161 -0
  56. package/build/cjs/utils/getGroupedRowModel.js.map +1 -0
  57. package/build/cjs/utils/getPaginationRowModel.js +61 -0
  58. package/build/cjs/utils/getPaginationRowModel.js.map +1 -0
  59. package/build/cjs/utils/getSortedRowModel.js +110 -0
  60. package/build/cjs/utils/getSortedRowModel.js.map +1 -0
  61. package/build/cjs/utils.js +38 -107
  62. package/build/cjs/utils.js.map +1 -1
  63. package/build/esm/index.js +2976 -3853
  64. package/build/esm/index.js.map +1 -1
  65. package/build/stats-html.html +1 -1
  66. package/build/stats-react.json +586 -408
  67. package/build/types/aggregationFns.d.ts +13 -0
  68. package/build/types/core/cell.d.ts +9 -0
  69. package/build/types/core/column.d.ts +40 -0
  70. package/build/types/core/headers.d.ts +46 -0
  71. package/build/types/core/instance.d.ts +57 -0
  72. package/build/types/core/row.d.ts +15 -0
  73. package/build/types/createTable.d.ts +47 -26
  74. package/build/types/features/ColumnSizing.d.ts +32 -44
  75. package/build/types/features/Expanding.d.ts +15 -26
  76. package/build/types/features/Filters.d.ts +64 -63
  77. package/build/types/features/Grouping.d.ts +32 -46
  78. package/build/types/features/Ordering.d.ts +7 -10
  79. package/build/types/features/Pagination.d.ts +16 -15
  80. package/build/types/features/Pinning.d.ts +16 -17
  81. package/build/types/features/RowSelection.d.ts +13 -33
  82. package/build/types/features/Sorting.d.ts +25 -44
  83. package/build/types/features/Visibility.d.ts +16 -25
  84. package/build/types/filterFns.d.ts +13 -0
  85. package/build/types/index.d.ts +16 -10
  86. package/build/types/sortingFns.d.ts +11 -0
  87. package/build/types/types.d.ts +37 -122
  88. package/build/types/utils/filterRowsUtils.d.ts +4 -0
  89. package/build/types/utils/getCoreRowModel.d.ts +2 -0
  90. package/build/types/utils/getExpandedRowModel.d.ts +7 -0
  91. package/build/types/utils/getFacetedMinMaxValues.d.ts +2 -0
  92. package/build/types/utils/getFacetedRowModel.d.ts +2 -0
  93. package/build/types/utils/getFacetedUniqueValues.d.ts +2 -0
  94. package/build/types/utils/getFilteredRowModel.d.ts +2 -0
  95. package/build/types/utils/getGroupedRowModel.d.ts +2 -0
  96. package/build/types/utils/getPaginationRowModel.d.ts +4 -0
  97. package/build/types/utils/getSortedRowModel.d.ts +2 -0
  98. package/build/types/utils.d.ts +7 -11
  99. package/build/umd/index.development.js +3024 -3893
  100. package/build/umd/index.development.js.map +1 -1
  101. package/build/umd/index.production.js +1 -1
  102. package/build/umd/index.production.js.map +1 -1
  103. package/package.json +9 -10
  104. package/src/aggregationFns.ts +123 -0
  105. package/src/core/cell.ts +48 -0
  106. package/src/core/column.ts +147 -0
  107. package/src/core/headers.ts +575 -0
  108. package/src/core/instance.ts +359 -0
  109. package/src/core/row.ts +85 -0
  110. package/src/createTable.ts +188 -0
  111. package/src/features/ColumnSizing.ts +170 -185
  112. package/src/features/Expanding.ts +120 -194
  113. package/src/features/Filters.ts +299 -381
  114. package/src/features/Grouping.ts +158 -220
  115. package/src/features/Ordering.ts +24 -25
  116. package/src/features/Pagination.ts +88 -73
  117. package/src/features/Pinning.ts +186 -63
  118. package/src/features/RowSelection.ts +107 -245
  119. package/src/features/Sorting.ts +125 -225
  120. package/src/features/Visibility.ts +116 -132
  121. package/src/filterFns.ts +135 -0
  122. package/src/index.ts +29 -0
  123. package/src/{sortTypes.ts → sortingFns.ts} +63 -85
  124. package/src/types.ts +62 -168
  125. package/src/utils/filterRowsUtils.ts +112 -0
  126. package/src/utils/getCoreRowModel.ts +84 -0
  127. package/src/utils/getExpandedRowModel.ts +54 -0
  128. package/src/utils/getFacetedMinMaxValues.ts +40 -0
  129. package/src/utils/getFacetedRowModel.ts +50 -0
  130. package/src/utils/getFacetedUniqueValues.ts +37 -0
  131. package/src/utils/getFilteredRowModel.ts +159 -0
  132. package/src/utils/getGroupedRowModel.ts +175 -0
  133. package/src/utils/getPaginationRowModel.ts +48 -0
  134. package/src/utils/getSortedRowModel.ts +116 -0
  135. package/src/utils.ts +126 -0
  136. package/build/cjs/_virtual/_rollupPluginBabelHelpers.js +0 -112
  137. package/build/cjs/_virtual/_rollupPluginBabelHelpers.js.map +0 -1
  138. package/build/cjs/aggregationTypes.js +0 -130
  139. package/build/cjs/aggregationTypes.js.map +0 -1
  140. package/build/cjs/core.js +0 -545
  141. package/build/cjs/core.js.map +0 -1
  142. package/build/cjs/features/Headers.js +0 -630
  143. package/build/cjs/features/Headers.js.map +0 -1
  144. package/build/cjs/filterTypes.js +0 -172
  145. package/build/cjs/filterTypes.js.map +0 -1
  146. package/build/cjs/sortTypes.js +0 -122
  147. package/build/cjs/sortTypes.js.map +0 -1
  148. package/build/cjs/types.js +0 -22
  149. package/build/cjs/types.js.map +0 -1
  150. package/build/cjs/utils/columnFilterRowsFn.js +0 -131
  151. package/build/cjs/utils/columnFilterRowsFn.js.map +0 -1
  152. package/build/cjs/utils/expandRowsFn.js +0 -38
  153. package/build/cjs/utils/expandRowsFn.js.map +0 -1
  154. package/build/cjs/utils/globalFilterRowsFn.js +0 -101
  155. package/build/cjs/utils/globalFilterRowsFn.js.map +0 -1
  156. package/build/cjs/utils/groupRowsFn.js +0 -155
  157. package/build/cjs/utils/groupRowsFn.js.map +0 -1
  158. package/build/cjs/utils/paginateRowsFn.js +0 -44
  159. package/build/cjs/utils/paginateRowsFn.js.map +0 -1
  160. package/build/cjs/utils/sortRowsFn.js +0 -94
  161. package/build/cjs/utils/sortRowsFn.js.map +0 -1
  162. package/build/types/aggregationTypes.d.ts +0 -22
  163. package/build/types/core.d.ts +0 -105
  164. package/build/types/features/Headers.d.ts +0 -43
  165. package/build/types/filterTypes.d.ts +0 -50
  166. package/build/types/sortTypes.d.ts +0 -18
  167. package/build/types/utils/columnFilterRowsFn.d.ts +0 -2
  168. package/build/types/utils/expandRowsFn.d.ts +0 -2
  169. package/build/types/utils/globalFilterRowsFn.d.ts +0 -2
  170. package/build/types/utils/groupRowsFn.d.ts +0 -2
  171. package/build/types/utils/paginateRowsFn.d.ts +0 -2
  172. package/build/types/utils/sortRowsFn.d.ts +0 -2
  173. package/src/.DS_Store +0 -0
  174. package/src/aggregationTypes.ts +0 -115
  175. package/src/core.tsx +0 -763
  176. package/src/createTable.tsx +0 -137
  177. package/src/features/Headers.ts +0 -747
  178. package/src/filterTypes.ts +0 -188
  179. package/src/index.tsx +0 -23
  180. package/src/utils/columnFilterRowsFn.ts +0 -113
  181. package/src/utils/expandRowsFn.ts +0 -30
  182. package/src/utils/globalFilterRowsFn.ts +0 -89
  183. package/src/utils/groupRowsFn.ts +0 -170
  184. package/src/utils/paginateRowsFn.ts +0 -28
  185. package/src/utils/sortRowsFn.ts +0 -95
  186. package/src/utils.tsx +0 -221
@@ -1,630 +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
- Object.defineProperty(exports, '__esModule', { value: true });
14
-
15
- var utils = require('../utils.js');
16
- var ColumnSizing = require('./ColumnSizing.js');
17
-
18
- //
19
- var Headers = {
20
- createRow: function createRow(row, instance) {
21
- return {
22
- _getAllVisibleCells: utils.memo(function () {
23
- return [row.getAllCells().filter(function (cell) {
24
- return cell.column.getIsVisible();
25
- }).map(function (d) {
26
- return d.id;
27
- }).join('_')];
28
- }, function (_) {
29
- return row.getAllCells().filter(function (cell) {
30
- return cell.column.getIsVisible();
31
- });
32
- }, {
33
- key: 'row._getAllVisibleCells',
34
- debug: function debug() {
35
- var _instance$options$deb;
36
-
37
- return (_instance$options$deb = instance.options.debugAll) != null ? _instance$options$deb : instance.options.debugRows;
38
- }
39
- }),
40
- getVisibleCells: utils.memo(function () {
41
- return [row.getLeftVisibleCells(), row.getCenterVisibleCells(), row.getRightVisibleCells()];
42
- }, function (left, center, right) {
43
- return [].concat(left, center, right);
44
- }, {
45
- key: 'row.getVisibleCells',
46
- debug: function debug() {
47
- var _instance$options$deb2;
48
-
49
- return (_instance$options$deb2 = instance.options.debugAll) != null ? _instance$options$deb2 : instance.options.debugRows;
50
- }
51
- }),
52
- getCenterVisibleCells: utils.memo(function () {
53
- return [row._getAllVisibleCells(), instance.getState().columnPinning.left, instance.getState().columnPinning.right];
54
- }, function (allCells, left, right) {
55
- var leftAndRight = [].concat(left != null ? left : [], right != null ? right : []);
56
- return allCells.filter(function (d) {
57
- return !leftAndRight.includes(d.columnId);
58
- });
59
- }, {
60
- key: 'row.getCenterVisibleCells',
61
- debug: function debug() {
62
- var _instance$options$deb3;
63
-
64
- return (_instance$options$deb3 = instance.options.debugAll) != null ? _instance$options$deb3 : instance.options.debugRows;
65
- }
66
- }),
67
- getLeftVisibleCells: utils.memo(function () {
68
- return [row._getAllVisibleCells(), instance.getState().columnPinning.left,,];
69
- }, function (allCells, left) {
70
- var cells = (left != null ? left : []).map(function (columnId) {
71
- return allCells.find(function (cell) {
72
- return cell.columnId === columnId;
73
- });
74
- }).filter(Boolean);
75
- return cells;
76
- }, {
77
- key: 'row.getLeftVisibleCells',
78
- debug: function debug() {
79
- var _instance$options$deb4;
80
-
81
- return (_instance$options$deb4 = instance.options.debugAll) != null ? _instance$options$deb4 : instance.options.debugRows;
82
- }
83
- }),
84
- getRightVisibleCells: utils.memo(function () {
85
- return [row._getAllVisibleCells(), instance.getState().columnPinning.right];
86
- }, function (allCells, right) {
87
- var cells = (right != null ? right : []).map(function (columnId) {
88
- return allCells.find(function (cell) {
89
- return cell.columnId === columnId;
90
- });
91
- }).filter(Boolean);
92
- return cells;
93
- }, {
94
- key: 'row.getRightVisibleCells',
95
- debug: function debug() {
96
- var _instance$options$deb5;
97
-
98
- return (_instance$options$deb5 = instance.options.debugAll) != null ? _instance$options$deb5 : instance.options.debugRows;
99
- }
100
- })
101
- };
102
- },
103
- getInstance: function getInstance(instance) {
104
- return {
105
- createHeader: function createHeader(column, options) {
106
- var _options$id;
107
-
108
- var id = (_options$id = options.id) != null ? _options$id : column.id;
109
- var header = {
110
- id: id,
111
- column: column,
112
- isPlaceholder: options.isPlaceholder,
113
- placeholderId: options.placeholderId,
114
- depth: options.depth,
115
- subHeaders: [],
116
- colSpan: 0,
117
- rowSpan: 0,
118
- getWidth: function getWidth() {
119
- var sum = 0;
120
-
121
- var recurse = function recurse(header) {
122
- if (header.subHeaders.length) {
123
- header.subHeaders.forEach(recurse);
124
- } else {
125
- var _header$column$getWid;
126
-
127
- sum += (_header$column$getWid = header.column.getWidth()) != null ? _header$column$getWid : 0;
128
- }
129
- };
130
-
131
- recurse(header);
132
- return sum;
133
- },
134
- getLeafHeaders: function getLeafHeaders() {
135
- var leafHeaders = [];
136
-
137
- var recurseHeader = function recurseHeader(h) {
138
- if (h.subHeaders && h.subHeaders.length) {
139
- h.subHeaders.map(recurseHeader);
140
- }
141
-
142
- leafHeaders.push(h);
143
- };
144
-
145
- recurseHeader(header);
146
- return leafHeaders;
147
- },
148
- getHeaderProps: function getHeaderProps(userProps) {
149
- return instance.getHeaderProps(header.id, userProps);
150
- },
151
- getFooterProps: function getFooterProps(userProps) {
152
- return instance.getFooterProps(header.id, userProps);
153
- },
154
- renderHeader: function renderHeader() {
155
- return utils.flexRender(column.header, {
156
- instance: instance,
157
- header: header,
158
- column: column
159
- });
160
- },
161
- renderFooter: function renderFooter() {
162
- return utils.flexRender(column.footer, {
163
- instance: instance,
164
- header: header,
165
- column: column
166
- });
167
- }
168
- }; // Yes, we have to convert instance to unknown, because we know more than the compiler here.
169
-
170
- return Object.assign(header, ColumnSizing.ColumnSizing.createHeader(header, instance));
171
- },
172
- // Header Groups
173
- getHeaderGroups: utils.memo(function () {
174
- return [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right];
175
- }, function (allColumns, leafColumns, left, right) {
176
- var leftColumns = leafColumns.filter(function (column) {
177
- return left == null ? void 0 : left.includes(column.id);
178
- });
179
- var rightColumns = leafColumns.filter(function (column) {
180
- return right == null ? void 0 : right.includes(column.id);
181
- });
182
- var centerColumns = leafColumns.filter(function (column) {
183
- return !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id));
184
- });
185
- var headerGroups = buildHeaderGroups(allColumns, [].concat(leftColumns, centerColumns, rightColumns), instance);
186
- return headerGroups;
187
- }, {
188
- key: 'getHeaderGroups',
189
- debug: function debug() {
190
- var _instance$options$deb6;
191
-
192
- return (_instance$options$deb6 = instance.options.debugAll) != null ? _instance$options$deb6 : instance.options.debugHeaders;
193
- }
194
- }),
195
- getCenterHeaderGroups: utils.memo(function () {
196
- return [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left, instance.getState().columnPinning.right];
197
- }, function (allColumns, leafColumns, left, right) {
198
- leafColumns = leafColumns.filter(function (column) {
199
- return !(left != null && left.includes(column.id)) && !(right != null && right.includes(column.id));
200
- });
201
- return buildHeaderGroups(allColumns, leafColumns, instance, 'center');
202
- }, {
203
- key: 'getCenterHeaderGroups',
204
- debug: function debug() {
205
- var _instance$options$deb7;
206
-
207
- return (_instance$options$deb7 = instance.options.debugAll) != null ? _instance$options$deb7 : instance.options.debugHeaders;
208
- }
209
- }),
210
- getLeftHeaderGroups: utils.memo(function () {
211
- return [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.left];
212
- }, function (allColumns, leafColumns, left) {
213
- leafColumns = leafColumns.filter(function (column) {
214
- return left == null ? void 0 : left.includes(column.id);
215
- });
216
- return buildHeaderGroups(allColumns, leafColumns, instance, 'left');
217
- }, {
218
- key: 'getLeftHeaderGroups',
219
- debug: function debug() {
220
- var _instance$options$deb8;
221
-
222
- return (_instance$options$deb8 = instance.options.debugAll) != null ? _instance$options$deb8 : instance.options.debugHeaders;
223
- }
224
- }),
225
- getRightHeaderGroups: utils.memo(function () {
226
- return [instance.getAllColumns(), instance.getVisibleLeafColumns(), instance.getState().columnPinning.right];
227
- }, function (allColumns, leafColumns, right) {
228
- leafColumns = leafColumns.filter(function (column) {
229
- return right == null ? void 0 : right.includes(column.id);
230
- });
231
- return buildHeaderGroups(allColumns, leafColumns, instance, 'right');
232
- }, {
233
- key: 'getRightHeaderGroups',
234
- debug: function debug() {
235
- var _instance$options$deb9;
236
-
237
- return (_instance$options$deb9 = instance.options.debugAll) != null ? _instance$options$deb9 : instance.options.debugHeaders;
238
- }
239
- }),
240
- // Footer Groups
241
- getFooterGroups: utils.memo(function () {
242
- return [instance.getHeaderGroups()];
243
- }, function (headerGroups) {
244
- return [].concat(headerGroups).reverse();
245
- }, {
246
- key: 'getFooterGroups',
247
- debug: function debug() {
248
- var _instance$options$deb10;
249
-
250
- return (_instance$options$deb10 = instance.options.debugAll) != null ? _instance$options$deb10 : instance.options.debugHeaders;
251
- }
252
- }),
253
- getLeftFooterGroups: utils.memo(function () {
254
- return [instance.getLeftHeaderGroups()];
255
- }, function (headerGroups) {
256
- return [].concat(headerGroups).reverse();
257
- }, {
258
- key: 'getLeftFooterGroups',
259
- debug: function debug() {
260
- var _instance$options$deb11;
261
-
262
- return (_instance$options$deb11 = instance.options.debugAll) != null ? _instance$options$deb11 : instance.options.debugHeaders;
263
- }
264
- }),
265
- getCenterFooterGroups: utils.memo(function () {
266
- return [instance.getCenterHeaderGroups()];
267
- }, function (headerGroups) {
268
- return [].concat(headerGroups).reverse();
269
- }, {
270
- key: 'getCenterFooterGroups',
271
- debug: function debug() {
272
- var _instance$options$deb12;
273
-
274
- return (_instance$options$deb12 = instance.options.debugAll) != null ? _instance$options$deb12 : instance.options.debugHeaders;
275
- }
276
- }),
277
- getRightFooterGroups: utils.memo(function () {
278
- return [instance.getRightHeaderGroups()];
279
- }, function (headerGroups) {
280
- return [].concat(headerGroups).reverse();
281
- }, {
282
- key: 'getRightFooterGroups',
283
- debug: function debug() {
284
- var _instance$options$deb13;
285
-
286
- return (_instance$options$deb13 = instance.options.debugAll) != null ? _instance$options$deb13 : instance.options.debugHeaders;
287
- }
288
- }),
289
- // Flat Headers
290
- getFlatHeaders: utils.memo(function () {
291
- return [instance.getHeaderGroups()];
292
- }, function (headerGroups) {
293
- return headerGroups.map(function (headerGroup) {
294
- return headerGroup.headers;
295
- }).flat();
296
- }, {
297
- key: 'getFlatHeaders',
298
- debug: function debug() {
299
- var _instance$options$deb14;
300
-
301
- return (_instance$options$deb14 = instance.options.debugAll) != null ? _instance$options$deb14 : instance.options.debugHeaders;
302
- }
303
- }),
304
- getLeftFlatHeaders: utils.memo(function () {
305
- return [instance.getLeftHeaderGroups()];
306
- }, function (left) {
307
- return left.map(function (headerGroup) {
308
- return headerGroup.headers;
309
- }).flat();
310
- }, {
311
- key: 'getLeftFlatHeaders',
312
- debug: function debug() {
313
- var _instance$options$deb15;
314
-
315
- return (_instance$options$deb15 = instance.options.debugAll) != null ? _instance$options$deb15 : instance.options.debugHeaders;
316
- }
317
- }),
318
- getCenterFlatHeaders: utils.memo(function () {
319
- return [instance.getCenterHeaderGroups()];
320
- }, function (left) {
321
- return left.map(function (headerGroup) {
322
- return headerGroup.headers;
323
- }).flat();
324
- }, {
325
- key: 'getCenterFlatHeaders',
326
- debug: function debug() {
327
- var _instance$options$deb16;
328
-
329
- return (_instance$options$deb16 = instance.options.debugAll) != null ? _instance$options$deb16 : instance.options.debugHeaders;
330
- }
331
- }),
332
- getRightFlatHeaders: utils.memo(function () {
333
- return [instance.getRightHeaderGroups()];
334
- }, function (left) {
335
- return left.map(function (headerGroup) {
336
- return headerGroup.headers;
337
- }).flat();
338
- }, {
339
- key: 'getRightFlatHeaders',
340
- debug: function debug() {
341
- var _instance$options$deb17;
342
-
343
- return (_instance$options$deb17 = instance.options.debugAll) != null ? _instance$options$deb17 : instance.options.debugHeaders;
344
- }
345
- }),
346
- // Leaf Headers
347
- getCenterLeafHeaders: utils.memo(function () {
348
- return [instance.getCenterFlatHeaders()];
349
- }, function (flatHeaders) {
350
- return flatHeaders.filter(function (header) {
351
- var _header$subHeaders;
352
-
353
- return !((_header$subHeaders = header.subHeaders) != null && _header$subHeaders.length);
354
- });
355
- }, {
356
- key: 'getCenterLeafHeaders',
357
- debug: function debug() {
358
- var _instance$options$deb18;
359
-
360
- return (_instance$options$deb18 = instance.options.debugAll) != null ? _instance$options$deb18 : instance.options.debugHeaders;
361
- }
362
- }),
363
- getLeftLeafHeaders: utils.memo(function () {
364
- return [instance.getLeftFlatHeaders()];
365
- }, function (flatHeaders) {
366
- return flatHeaders.filter(function (header) {
367
- var _header$subHeaders2;
368
-
369
- return !((_header$subHeaders2 = header.subHeaders) != null && _header$subHeaders2.length);
370
- });
371
- }, {
372
- key: 'getLeftLeafHeaders',
373
- debug: function debug() {
374
- var _instance$options$deb19;
375
-
376
- return (_instance$options$deb19 = instance.options.debugAll) != null ? _instance$options$deb19 : instance.options.debugHeaders;
377
- }
378
- }),
379
- getRightLeafHeaders: utils.memo(function () {
380
- return [instance.getRightFlatHeaders()];
381
- }, function (flatHeaders) {
382
- return flatHeaders.filter(function (header) {
383
- var _header$subHeaders3;
384
-
385
- return !((_header$subHeaders3 = header.subHeaders) != null && _header$subHeaders3.length);
386
- });
387
- }, {
388
- key: 'getRightLeafHeaders',
389
- debug: function debug() {
390
- var _instance$options$deb20;
391
-
392
- return (_instance$options$deb20 = instance.options.debugAll) != null ? _instance$options$deb20 : instance.options.debugHeaders;
393
- }
394
- }),
395
- getLeafHeaders: utils.memo(function () {
396
- return [instance.getLeftHeaderGroups(), instance.getCenterHeaderGroups(), instance.getRightHeaderGroups()];
397
- }, function (left, center, right) {
398
- var _left$0$headers, _left$, _center$0$headers, _center$, _right$0$headers, _right$;
399
-
400
- return [].concat((_left$0$headers = (_left$ = left[0]) == null ? void 0 : _left$.headers) != null ? _left$0$headers : [], (_center$0$headers = (_center$ = center[0]) == null ? void 0 : _center$.headers) != null ? _center$0$headers : [], (_right$0$headers = (_right$ = right[0]) == null ? void 0 : _right$.headers) != null ? _right$0$headers : []).map(function (header) {
401
- return header.getLeafHeaders();
402
- }).flat();
403
- }, {
404
- key: 'getLeafHeaders',
405
- debug: function debug() {
406
- var _instance$options$deb21;
407
-
408
- return (_instance$options$deb21 = instance.options.debugAll) != null ? _instance$options$deb21 : instance.options.debugHeaders;
409
- }
410
- }),
411
- getHeader: function getHeader(id) {
412
- var header = [].concat(instance.getFlatHeaders(), instance.getCenterFlatHeaders(), instance.getLeftFlatHeaders(), instance.getRightFlatHeaders()).find(function (d) {
413
- return d.id === id;
414
- });
415
-
416
- if (!header) {
417
- if (process.env.NODE_ENV !== 'production') {
418
- console.warn("Could not find header with id: " + id);
419
- }
420
-
421
- throw new Error();
422
- }
423
-
424
- return header;
425
- },
426
- getHeaderGroupProps: function getHeaderGroupProps(id, userProps) {
427
- var headerGroup = instance.getHeaderGroups().find(function (d) {
428
- return d.id === id;
429
- });
430
-
431
- if (!headerGroup) {
432
- return;
433
- }
434
-
435
- return utils.propGetter({
436
- key: headerGroup.id,
437
- role: 'row'
438
- }, userProps);
439
- },
440
- getFooterGroupProps: function getFooterGroupProps(id, userProps) {
441
- var headerGroup = instance.getFooterGroups().find(function (d) {
442
- return d.id === id;
443
- });
444
-
445
- if (!headerGroup) {
446
- return;
447
- }
448
-
449
- var initialProps = {
450
- key: headerGroup.id,
451
- role: 'row'
452
- };
453
- return utils.propGetter(initialProps, userProps);
454
- },
455
- getHeaderProps: function getHeaderProps(id, userProps) {
456
- var header = instance.getHeader(id);
457
-
458
- if (!header) {
459
- throw new Error();
460
- }
461
-
462
- var initialProps = {
463
- key: header.id,
464
- role: 'columnheader',
465
- colSpan: header.colSpan,
466
- rowSpan: header.rowSpan
467
- };
468
- return utils.propGetter(initialProps, userProps);
469
- },
470
- getFooterProps: function getFooterProps(id, userProps) {
471
- var header = instance.getHeader(id);
472
- var initialProps = {
473
- key: header.id,
474
- role: 'columnfooter',
475
- colSpan: header.colSpan,
476
- rowSpan: header.rowSpan
477
- };
478
- return utils.propGetter(initialProps, userProps);
479
- },
480
- getTotalWidth: function getTotalWidth() {
481
- var width = 0;
482
- instance.getVisibleLeafColumns().forEach(function (column) {
483
- var _column$getWidth;
484
-
485
- width += (_column$getWidth = column.getWidth()) != null ? _column$getWidth : 0;
486
- });
487
- return width;
488
- }
489
- };
490
- }
491
- };
492
- function buildHeaderGroups(allColumns, columnsToGroup, instance, headerFamily) {
493
- var _headerGroups$0$heade, _headerGroups$;
494
-
495
- // Find the max depth of the columns:
496
- // build the leaf column row
497
- // build each buffer row going up
498
- // placeholder for non-existent level
499
- // real column for existing level
500
- var maxDepth = 0;
501
-
502
- var findMaxDepth = function findMaxDepth(columns, depth) {
503
- if (depth === void 0) {
504
- depth = 1;
505
- }
506
-
507
- maxDepth = Math.max(maxDepth, depth);
508
- columns.filter(function (column) {
509
- return column.getIsVisible();
510
- }).forEach(function (column) {
511
- var _column$columns;
512
-
513
- if ((_column$columns = column.columns) != null && _column$columns.length) {
514
- findMaxDepth(column.columns, depth + 1);
515
- }
516
- }, 0);
517
- };
518
-
519
- findMaxDepth(allColumns);
520
- var headerGroups = [];
521
-
522
- var createHeaderGroup = function createHeaderGroup(headersToGroup, depth) {
523
- // The header group we are creating
524
- var headerGroup = {
525
- depth: depth,
526
- id: [headerFamily, "" + depth].filter(Boolean).join('_'),
527
- headers: [],
528
- getHeaderGroupProps: function getHeaderGroupProps(getterValue) {
529
- return instance.getHeaderGroupProps("" + depth, getterValue);
530
- },
531
- getFooterGroupProps: function getFooterGroupProps(getterValue) {
532
- return instance.getFooterGroupProps("" + depth, getterValue);
533
- }
534
- }; // The parent columns we're going to scan next
535
-
536
- var parentHeaders = []; // Scan each column for parents
537
-
538
- headersToGroup.forEach(function (headerToGroup) {
539
- // What is the latest (last) parent column?
540
- var latestParentHeader = [].concat(parentHeaders).reverse()[0];
541
- var isLeafHeader = headerToGroup.column.depth === headerGroup.depth;
542
- var column;
543
- var isPlaceholder = false;
544
-
545
- if (isLeafHeader && headerToGroup.column.parent) {
546
- // The parent header is new
547
- column = headerToGroup.column.parent;
548
- } else {
549
- // The parent header is repeated
550
- column = headerToGroup.column;
551
- isPlaceholder = true;
552
- }
553
-
554
- var header = instance.createHeader(column, {
555
- id: [headerFamily, depth, column.id, headerToGroup == null ? void 0 : headerToGroup.id].filter(Boolean).join('_'),
556
- isPlaceholder: isPlaceholder,
557
- placeholderId: isPlaceholder ? "" + parentHeaders.filter(function (d) {
558
- return d.column === column;
559
- }).length : undefined,
560
- depth: depth
561
- });
562
-
563
- if (!latestParentHeader || latestParentHeader.column !== header.column) {
564
- header.subHeaders.push(headerToGroup);
565
- parentHeaders.push(header);
566
- } else {
567
- latestParentHeader.subHeaders.push(headerToGroup);
568
- } // if (!headerToGroup.isPlaceholder) {
569
- // headerToGroup.column.header = headerToGroup;
570
- // }
571
-
572
-
573
- headerGroup.headers.push(headerToGroup);
574
- });
575
- headerGroups.push(headerGroup);
576
-
577
- if (depth > 0) {
578
- createHeaderGroup(parentHeaders, depth - 1);
579
- }
580
- };
581
-
582
- var bottomHeaders = columnsToGroup.map(function (column) {
583
- return instance.createHeader(column, {
584
- depth: maxDepth
585
- });
586
- });
587
- createHeaderGroup(bottomHeaders, maxDepth - 1);
588
- headerGroups.reverse(); // headerGroups = headerGroups.filter(headerGroup => {
589
- // return !headerGroup.headers.every(header => header.isPlaceholder)
590
- // })
591
-
592
- var recurseHeadersForSpans = function recurseHeadersForSpans(headers) {
593
- var filteredHeaders = headers.filter(function (header) {
594
- return header.column.getIsVisible();
595
- });
596
- return filteredHeaders.map(function (header) {
597
- var colSpan = 0;
598
- var rowSpan = 0;
599
- var childRowSpans = [0];
600
-
601
- if (header.subHeaders && header.subHeaders.length) {
602
- childRowSpans = [];
603
- recurseHeadersForSpans(header.subHeaders).forEach(function (_ref) {
604
- var childColSpan = _ref.colSpan,
605
- childRowSpan = _ref.rowSpan;
606
- colSpan += childColSpan;
607
- childRowSpans.push(childRowSpan);
608
- });
609
- } else {
610
- colSpan = 1;
611
- }
612
-
613
- var minChildRowSpan = Math.min.apply(Math, childRowSpans);
614
- rowSpan = rowSpan + minChildRowSpan;
615
- header.colSpan = colSpan > 0 ? colSpan : undefined;
616
- header.rowSpan = rowSpan > 0 ? rowSpan : undefined;
617
- return {
618
- colSpan: colSpan,
619
- rowSpan: rowSpan
620
- };
621
- });
622
- };
623
-
624
- recurseHeadersForSpans((_headerGroups$0$heade = (_headerGroups$ = headerGroups[0]) == null ? void 0 : _headerGroups$.headers) != null ? _headerGroups$0$heade : []);
625
- return headerGroups;
626
- }
627
-
628
- exports.Headers = Headers;
629
- exports.buildHeaderGroups = buildHeaderGroups;
630
- //# sourceMappingURL=Headers.js.map