@react-stately/table 3.15.3 → 3.16.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 (76) hide show
  1. package/dist/import.mjs +6 -18
  2. package/dist/main.js +18 -30
  3. package/dist/main.js.map +1 -1
  4. package/dist/module.js +6 -18
  5. package/dist/module.js.map +1 -1
  6. package/dist/types/src/index.d.ts +9 -0
  7. package/package.json +17 -20
  8. package/src/index.ts +9 -16
  9. package/dist/Cell.main.js +0 -38
  10. package/dist/Cell.main.js.map +0 -1
  11. package/dist/Cell.mjs +0 -33
  12. package/dist/Cell.module.js +0 -33
  13. package/dist/Cell.module.js.map +0 -1
  14. package/dist/Column.main.js +0 -75
  15. package/dist/Column.main.js.map +0 -1
  16. package/dist/Column.mjs +0 -66
  17. package/dist/Column.module.js +0 -66
  18. package/dist/Column.module.js.map +0 -1
  19. package/dist/Row.main.js +0 -102
  20. package/dist/Row.main.js.map +0 -1
  21. package/dist/Row.mjs +0 -93
  22. package/dist/Row.module.js +0 -93
  23. package/dist/Row.module.js.map +0 -1
  24. package/dist/TableBody.main.js +0 -61
  25. package/dist/TableBody.main.js.map +0 -1
  26. package/dist/TableBody.mjs +0 -52
  27. package/dist/TableBody.module.js +0 -52
  28. package/dist/TableBody.module.js.map +0 -1
  29. package/dist/TableCollection.main.js +0 -308
  30. package/dist/TableCollection.main.js.map +0 -1
  31. package/dist/TableCollection.mjs +0 -302
  32. package/dist/TableCollection.module.js +0 -302
  33. package/dist/TableCollection.module.js.map +0 -1
  34. package/dist/TableColumnLayout.main.js +0 -113
  35. package/dist/TableColumnLayout.main.js.map +0 -1
  36. package/dist/TableColumnLayout.mjs +0 -108
  37. package/dist/TableColumnLayout.module.js +0 -108
  38. package/dist/TableColumnLayout.module.js.map +0 -1
  39. package/dist/TableHeader.main.js +0 -56
  40. package/dist/TableHeader.main.js.map +0 -1
  41. package/dist/TableHeader.mjs +0 -47
  42. package/dist/TableHeader.module.js +0 -47
  43. package/dist/TableHeader.module.js.map +0 -1
  44. package/dist/TableUtils.main.js +0 -182
  45. package/dist/TableUtils.main.js.map +0 -1
  46. package/dist/TableUtils.mjs +0 -175
  47. package/dist/TableUtils.module.js +0 -175
  48. package/dist/TableUtils.module.js.map +0 -1
  49. package/dist/types.d.ts +0 -194
  50. package/dist/types.d.ts.map +0 -1
  51. package/dist/useTableColumnResizeState.main.js +0 -109
  52. package/dist/useTableColumnResizeState.main.js.map +0 -1
  53. package/dist/useTableColumnResizeState.mjs +0 -104
  54. package/dist/useTableColumnResizeState.module.js +0 -104
  55. package/dist/useTableColumnResizeState.module.js.map +0 -1
  56. package/dist/useTableState.main.js +0 -86
  57. package/dist/useTableState.main.js.map +0 -1
  58. package/dist/useTableState.mjs +0 -80
  59. package/dist/useTableState.module.js +0 -80
  60. package/dist/useTableState.module.js.map +0 -1
  61. package/dist/useTreeGridState.main.js +0 -207
  62. package/dist/useTreeGridState.main.js.map +0 -1
  63. package/dist/useTreeGridState.mjs +0 -202
  64. package/dist/useTreeGridState.module.js +0 -202
  65. package/dist/useTreeGridState.module.js.map +0 -1
  66. package/src/Cell.ts +0 -40
  67. package/src/Column.ts +0 -83
  68. package/src/Row.ts +0 -121
  69. package/src/TableBody.ts +0 -61
  70. package/src/TableCollection.ts +0 -367
  71. package/src/TableColumnLayout.ts +0 -127
  72. package/src/TableHeader.ts +0 -59
  73. package/src/TableUtils.ts +0 -266
  74. package/src/useTableColumnResizeState.ts +0 -147
  75. package/src/useTableState.ts +0 -124
  76. package/src/useTreeGridState.ts +0 -278
@@ -1,308 +0,0 @@
1
- var $bkA0E$reactstatelycollections = require("@react-stately/collections");
2
- var $bkA0E$reactstatelygrid = require("@react-stately/grid");
3
-
4
-
5
- function $parcel$export(e, n, v, s) {
6
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
7
- }
8
-
9
- $parcel$export(module.exports, "buildHeaderRows", () => $7f5a58334d8866a5$export$7c127db850d4e81e);
10
- $parcel$export(module.exports, "TableCollection", () => $7f5a58334d8866a5$export$596e1b2e2cf93690);
11
- /*
12
- * Copyright 2020 Adobe. All rights reserved.
13
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
14
- * you may not use this file except in compliance with the License. You may obtain a copy
15
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
16
- *
17
- * Unless required by applicable law or agreed to in writing, software distributed under
18
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
19
- * OF ANY KIND, either express or implied. See the License for the specific language
20
- * governing permissions and limitations under the License.
21
- */
22
-
23
- const $7f5a58334d8866a5$var$ROW_HEADER_COLUMN_KEY = 'row-header-column-' + Math.random().toString(36).slice(2);
24
- let $7f5a58334d8866a5$var$ROW_HEADER_COLUMN_KEY_DRAG = 'row-header-column-' + Math.random().toString(36).slice(2);
25
- while($7f5a58334d8866a5$var$ROW_HEADER_COLUMN_KEY === $7f5a58334d8866a5$var$ROW_HEADER_COLUMN_KEY_DRAG)$7f5a58334d8866a5$var$ROW_HEADER_COLUMN_KEY_DRAG = 'row-header-column-' + Math.random().toString(36).slice(2);
26
- function $7f5a58334d8866a5$export$7c127db850d4e81e(keyMap, columnNodes) {
27
- if (columnNodes.length === 0) return [];
28
- let columns = [];
29
- let seen = new Map();
30
- for (let column of columnNodes){
31
- let parentKey = column.parentKey;
32
- let col = [
33
- column
34
- ];
35
- while(parentKey){
36
- let parent = keyMap.get(parentKey);
37
- if (!parent) break;
38
- // If we've already seen this parent, than it is shared
39
- // with a previous column. If the current column is taller
40
- // than the previous column, than we need to shift the parent
41
- // in the previous column so it's level with the current column.
42
- if (seen.has(parent)) {
43
- var _parent;
44
- var _colSpan;
45
- (_colSpan = (_parent = parent).colSpan) !== null && _colSpan !== void 0 ? _colSpan : _parent.colSpan = 0;
46
- parent.colSpan++;
47
- parent.colspan = parent.colSpan;
48
- let { column: column, index: index } = seen.get(parent);
49
- if (index > col.length) break;
50
- for(let i = index; i < col.length; i++)column.splice(i, 0, null);
51
- // Adjust shifted indices
52
- for(let i = col.length; i < column.length; i++)// eslint-disable-next-line max-depth
53
- if (column[i] && seen.has(column[i])) seen.get(column[i]).index = i;
54
- } else {
55
- parent.colSpan = 1;
56
- parent.colspan = 1;
57
- col.push(parent);
58
- seen.set(parent, {
59
- column: col,
60
- index: col.length - 1
61
- });
62
- }
63
- parentKey = parent.parentKey;
64
- }
65
- columns.push(col);
66
- column.index = columns.length - 1;
67
- }
68
- let maxLength = Math.max(...columns.map((c)=>c.length));
69
- let headerRows = Array(maxLength).fill(0).map(()=>[]);
70
- // Convert columns into rows.
71
- let colIndex = 0;
72
- for (let column of columns){
73
- let i = maxLength - 1;
74
- for (let item of column){
75
- if (item) {
76
- // Fill the space up until the current column with a placeholder
77
- let row = headerRows[i];
78
- let rowLength = row.reduce((p, c)=>{
79
- var _c_colSpan;
80
- return p + ((_c_colSpan = c.colSpan) !== null && _c_colSpan !== void 0 ? _c_colSpan : 1);
81
- }, 0);
82
- if (rowLength < colIndex) {
83
- let placeholder = {
84
- type: 'placeholder',
85
- key: 'placeholder-' + item.key,
86
- colspan: colIndex - rowLength,
87
- colSpan: colIndex - rowLength,
88
- index: rowLength,
89
- value: null,
90
- rendered: null,
91
- level: i,
92
- hasChildNodes: false,
93
- childNodes: [],
94
- textValue: ''
95
- };
96
- // eslint-disable-next-line max-depth
97
- if (row.length > 0) {
98
- row[row.length - 1].nextKey = placeholder.key;
99
- placeholder.prevKey = row[row.length - 1].key;
100
- }
101
- row.push(placeholder);
102
- }
103
- if (row.length > 0) {
104
- row[row.length - 1].nextKey = item.key;
105
- item.prevKey = row[row.length - 1].key;
106
- }
107
- item.level = i;
108
- item.colIndex = colIndex;
109
- row.push(item);
110
- }
111
- i--;
112
- }
113
- colIndex++;
114
- }
115
- // Add placeholders at the end of each row that is shorter than the maximum
116
- let i = 0;
117
- for (let row of headerRows){
118
- let rowLength = row.reduce((p, c)=>{
119
- var _c_colSpan;
120
- return p + ((_c_colSpan = c.colSpan) !== null && _c_colSpan !== void 0 ? _c_colSpan : 1);
121
- }, 0);
122
- if (rowLength < columnNodes.length) {
123
- let placeholder = {
124
- type: 'placeholder',
125
- key: 'placeholder-' + row[row.length - 1].key,
126
- colSpan: columnNodes.length - rowLength,
127
- colspan: columnNodes.length - rowLength,
128
- index: rowLength,
129
- value: null,
130
- rendered: null,
131
- level: i,
132
- hasChildNodes: false,
133
- childNodes: [],
134
- textValue: '',
135
- prevKey: row[row.length - 1].key
136
- };
137
- row.push(placeholder);
138
- }
139
- i++;
140
- }
141
- return headerRows.map((childNodes, index)=>{
142
- let row = {
143
- type: 'headerrow',
144
- key: 'headerrow-' + index,
145
- index: index,
146
- value: null,
147
- rendered: null,
148
- level: 0,
149
- hasChildNodes: true,
150
- childNodes: childNodes,
151
- textValue: ''
152
- };
153
- return row;
154
- });
155
- }
156
- class $7f5a58334d8866a5$export$596e1b2e2cf93690 extends (0, $bkA0E$reactstatelygrid.GridCollection) {
157
- *[Symbol.iterator]() {
158
- yield* this.body.childNodes;
159
- }
160
- get size() {
161
- return this._size;
162
- }
163
- getKeys() {
164
- return this.keyMap.keys();
165
- }
166
- getKeyBefore(key) {
167
- let node = this.keyMap.get(key);
168
- var _node_prevKey;
169
- return (_node_prevKey = node === null || node === void 0 ? void 0 : node.prevKey) !== null && _node_prevKey !== void 0 ? _node_prevKey : null;
170
- }
171
- getKeyAfter(key) {
172
- let node = this.keyMap.get(key);
173
- var _node_nextKey;
174
- return (_node_nextKey = node === null || node === void 0 ? void 0 : node.nextKey) !== null && _node_nextKey !== void 0 ? _node_nextKey : null;
175
- }
176
- getFirstKey() {
177
- var _getFirstItem;
178
- var _getFirstItem_key;
179
- return (_getFirstItem_key = (_getFirstItem = (0, $bkA0E$reactstatelycollections.getFirstItem)(this.body.childNodes)) === null || _getFirstItem === void 0 ? void 0 : _getFirstItem.key) !== null && _getFirstItem_key !== void 0 ? _getFirstItem_key : null;
180
- }
181
- getLastKey() {
182
- var _getLastItem;
183
- var _getLastItem_key;
184
- return (_getLastItem_key = (_getLastItem = (0, $bkA0E$reactstatelycollections.getLastItem)(this.body.childNodes)) === null || _getLastItem === void 0 ? void 0 : _getLastItem.key) !== null && _getLastItem_key !== void 0 ? _getLastItem_key : null;
185
- }
186
- getItem(key) {
187
- var _this_keyMap_get;
188
- return (_this_keyMap_get = this.keyMap.get(key)) !== null && _this_keyMap_get !== void 0 ? _this_keyMap_get : null;
189
- }
190
- at(idx) {
191
- const keys = [
192
- ...this.getKeys()
193
- ];
194
- return this.getItem(keys[idx]);
195
- }
196
- getChildren(key) {
197
- if (key === this.body.key) return this.body.childNodes;
198
- return super.getChildren(key);
199
- }
200
- getTextValue(key) {
201
- let row = this.getItem(key);
202
- if (!row) return '';
203
- // If the row has a textValue, use that.
204
- if (row.textValue) return row.textValue;
205
- // Otherwise combine the text of each of the row header columns.
206
- let rowHeaderColumnKeys = this.rowHeaderColumnKeys;
207
- if (rowHeaderColumnKeys) {
208
- let text = [];
209
- for (let cell of row.childNodes){
210
- let column = this.columns[cell.index];
211
- if (rowHeaderColumnKeys.has(column.key) && cell.textValue) text.push(cell.textValue);
212
- if (text.length === rowHeaderColumnKeys.size) break;
213
- }
214
- return text.join(' ');
215
- }
216
- return '';
217
- }
218
- constructor(nodes, prev, opts){
219
- let rowHeaderColumnKeys = new Set();
220
- let body = null;
221
- let columns = [];
222
- // Add cell for selection checkboxes if needed.
223
- if (opts === null || opts === void 0 ? void 0 : opts.showSelectionCheckboxes) {
224
- let rowHeaderColumn = {
225
- type: 'column',
226
- key: $7f5a58334d8866a5$var$ROW_HEADER_COLUMN_KEY,
227
- value: null,
228
- textValue: '',
229
- level: 0,
230
- index: (opts === null || opts === void 0 ? void 0 : opts.showDragButtons) ? 1 : 0,
231
- hasChildNodes: false,
232
- rendered: null,
233
- childNodes: [],
234
- props: {
235
- isSelectionCell: true
236
- }
237
- };
238
- columns.unshift(rowHeaderColumn);
239
- }
240
- // Add cell for drag buttons if needed.
241
- if (opts === null || opts === void 0 ? void 0 : opts.showDragButtons) {
242
- let rowHeaderColumn = {
243
- type: 'column',
244
- key: $7f5a58334d8866a5$var$ROW_HEADER_COLUMN_KEY_DRAG,
245
- value: null,
246
- textValue: '',
247
- level: 0,
248
- index: 0,
249
- hasChildNodes: false,
250
- rendered: null,
251
- childNodes: [],
252
- props: {
253
- isDragButtonCell: true
254
- }
255
- };
256
- columns.unshift(rowHeaderColumn);
257
- }
258
- let rows = [];
259
- let columnKeyMap = new Map();
260
- let visit = (node)=>{
261
- switch(node.type){
262
- case 'body':
263
- body = node;
264
- break;
265
- case 'column':
266
- columnKeyMap.set(node.key, node);
267
- if (!node.hasChildNodes) {
268
- columns.push(node);
269
- if (node.props.isRowHeader) rowHeaderColumnKeys.add(node.key);
270
- }
271
- break;
272
- case 'item':
273
- rows.push(node);
274
- return; // do not go into childNodes
275
- }
276
- for (let child of node.childNodes)visit(child);
277
- };
278
- for (let node of nodes)visit(node);
279
- let headerRows = $7f5a58334d8866a5$export$7c127db850d4e81e(columnKeyMap, columns);
280
- headerRows.forEach((row, i)=>rows.splice(i, 0, row));
281
- super({
282
- columnCount: columns.length,
283
- items: rows,
284
- visitNode: (node)=>{
285
- node.column = columns[node.index];
286
- return node;
287
- }
288
- }), this._size = 0;
289
- this.columns = columns;
290
- this.rowHeaderColumnKeys = rowHeaderColumnKeys;
291
- this.body = body;
292
- this.headerRows = headerRows;
293
- this._size = [
294
- ...body.childNodes
295
- ].length;
296
- // Default row header column to the first one.
297
- if (this.rowHeaderColumnKeys.size === 0) {
298
- let col = this.columns.find((column)=>{
299
- var _column_props, _column_props1;
300
- return !((_column_props = column.props) === null || _column_props === void 0 ? void 0 : _column_props.isDragButtonCell) && !((_column_props1 = column.props) === null || _column_props1 === void 0 ? void 0 : _column_props1.isSelectionCell);
301
- });
302
- if (col) this.rowHeaderColumnKeys.add(col.key);
303
- }
304
- }
305
- }
306
-
307
-
308
- //# sourceMappingURL=TableCollection.main.js.map
@@ -1 +0,0 @@
1
- {"m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;;YACvG,IAAI,KACF,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,IAAI,GAAG;QAExC;IACF;AAgFF","sources":["packages/@react-stately/table/src/TableCollection.ts"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {getFirstItem, getLastItem} from '@react-stately/collections';\nimport {GridCollection} from '@react-stately/grid';\nimport {GridNode} from '@react-types/grid';\nimport {TableCollection as ITableCollection} from '@react-types/table';\nimport {Key} from '@react-types/shared';\n\ninterface GridCollectionOptions {\n showSelectionCheckboxes?: boolean,\n showDragButtons?: boolean\n}\n\nconst ROW_HEADER_COLUMN_KEY = 'row-header-column-' + Math.random().toString(36).slice(2);\nlet ROW_HEADER_COLUMN_KEY_DRAG = 'row-header-column-' + Math.random().toString(36).slice(2);\nwhile (ROW_HEADER_COLUMN_KEY === ROW_HEADER_COLUMN_KEY_DRAG) {\n ROW_HEADER_COLUMN_KEY_DRAG = 'row-header-column-' + Math.random().toString(36).slice(2);\n}\n\n/** @private */\nexport function buildHeaderRows<T>(keyMap: Map<Key, GridNode<T>>, columnNodes: GridNode<T>[]): GridNode<T>[] {\n if (columnNodes.length === 0) {\n return [];\n }\n\n let columns: GridNode<T>[][] = [];\n let seen = new Map();\n for (let column of columnNodes) {\n let parentKey = column.parentKey;\n let col = [column];\n\n while (parentKey) {\n let parent: GridNode<T> | undefined = keyMap.get(parentKey);\n if (!parent) {\n break;\n }\n\n // If we've already seen this parent, than it is shared\n // with a previous column. If the current column is taller\n // than the previous column, than we need to shift the parent\n // in the previous column so it's level with the current column.\n if (seen.has(parent)) {\n parent.colSpan ??= 0;\n parent.colSpan++;\n parent.colspan = parent.colSpan;\n\n let {column, index} = seen.get(parent);\n if (index > col.length) {\n break;\n }\n\n for (let i = index; i < col.length; i++) {\n column.splice(i, 0, null);\n }\n\n // Adjust shifted indices\n for (let i = col.length; i < column.length; i++) {\n // eslint-disable-next-line max-depth\n if (column[i] && seen.has(column[i])) {\n seen.get(column[i]).index = i;\n }\n }\n } else {\n parent.colSpan = 1;\n parent.colspan = 1;\n col.push(parent);\n seen.set(parent, {column: col, index: col.length - 1});\n }\n\n parentKey = parent.parentKey;\n }\n\n columns.push(col);\n column.index = columns.length - 1;\n }\n\n let maxLength = Math.max(...columns.map(c => c.length));\n let headerRows: GridNode<T>[][] = Array(maxLength).fill(0).map(() => []);\n\n // Convert columns into rows.\n let colIndex = 0;\n for (let column of columns) {\n let i = maxLength - 1;\n for (let item of column) {\n if (item) {\n // Fill the space up until the current column with a placeholder\n let row = headerRows[i];\n let rowLength = row.reduce((p, c) => p + (c.colSpan ?? 1), 0);\n if (rowLength < colIndex) {\n let placeholder: GridNode<T> = {\n type: 'placeholder',\n key: 'placeholder-' + item.key,\n colspan: colIndex - rowLength,\n colSpan: colIndex - rowLength,\n index: rowLength,\n value: null,\n rendered: null,\n level: i,\n hasChildNodes: false,\n childNodes: [],\n textValue: ''\n };\n\n // eslint-disable-next-line max-depth\n if (row.length > 0) {\n row[row.length - 1].nextKey = placeholder.key;\n placeholder.prevKey = row[row.length - 1].key;\n }\n\n row.push(placeholder);\n }\n\n if (row.length > 0) {\n row[row.length - 1].nextKey = item.key;\n item.prevKey = row[row.length - 1].key;\n }\n\n item.level = i;\n item.colIndex = colIndex;\n row.push(item);\n }\n\n i--;\n }\n\n colIndex++;\n }\n\n // Add placeholders at the end of each row that is shorter than the maximum\n let i = 0;\n for (let row of headerRows) {\n let rowLength = row.reduce((p, c) => p + (c.colSpan ?? 1), 0);\n if (rowLength < columnNodes.length) {\n let placeholder: GridNode<T> = {\n type: 'placeholder',\n key: 'placeholder-' + row[row.length - 1].key,\n colSpan: columnNodes.length - rowLength,\n colspan: columnNodes.length - rowLength,\n index: rowLength,\n value: null,\n rendered: null,\n level: i,\n hasChildNodes: false,\n childNodes: [],\n textValue: '',\n prevKey: row[row.length - 1].key\n };\n\n row.push(placeholder);\n }\n\n i++;\n }\n\n return headerRows.map((childNodes, index) => {\n let row: GridNode<T> = {\n type: 'headerrow',\n key: 'headerrow-' + index,\n index,\n value: null,\n rendered: null,\n level: 0,\n hasChildNodes: true,\n childNodes,\n textValue: ''\n };\n\n return row;\n });\n}\n\nexport class TableCollection<T> extends GridCollection<T> implements ITableCollection<T> {\n headerRows: GridNode<T>[];\n columns: GridNode<T>[];\n rowHeaderColumnKeys: Set<Key>;\n body: GridNode<T>;\n _size: number = 0;\n\n constructor(nodes: Iterable<GridNode<T>>, prev?: ITableCollection<T> | null, opts?: GridCollectionOptions) {\n let rowHeaderColumnKeys: Set<Key> = new Set();\n let body: GridNode<T> | null = null;\n let columns: GridNode<T>[] = [];\n // Add cell for selection checkboxes if needed.\n if (opts?.showSelectionCheckboxes) {\n let rowHeaderColumn: GridNode<T> = {\n type: 'column',\n key: ROW_HEADER_COLUMN_KEY,\n value: null,\n textValue: '',\n level: 0,\n index: opts?.showDragButtons ? 1 : 0,\n hasChildNodes: false,\n rendered: null,\n childNodes: [],\n props: {\n isSelectionCell: true\n }\n };\n\n columns.unshift(rowHeaderColumn);\n }\n\n // Add cell for drag buttons if needed.\n if (opts?.showDragButtons) {\n let rowHeaderColumn: GridNode<T> = {\n type: 'column',\n key: ROW_HEADER_COLUMN_KEY_DRAG,\n value: null,\n textValue: '',\n level: 0,\n index: 0,\n hasChildNodes: false,\n rendered: null,\n childNodes: [],\n props: {\n isDragButtonCell: true\n }\n };\n\n columns.unshift(rowHeaderColumn);\n }\n\n let rows: GridNode<T>[] = [];\n let columnKeyMap = new Map();\n let visit = (node: GridNode<T>) => {\n switch (node.type) {\n case 'body':\n body = node;\n break;\n case 'column':\n columnKeyMap.set(node.key, node);\n if (!node.hasChildNodes) {\n columns.push(node);\n\n if (node.props.isRowHeader) {\n rowHeaderColumnKeys.add(node.key);\n }\n }\n break;\n case 'item':\n rows.push(node);\n return; // do not go into childNodes\n }\n for (let child of node.childNodes) {\n visit(child);\n }\n };\n\n for (let node of nodes) {\n visit(node);\n }\n\n let headerRows = buildHeaderRows(columnKeyMap, columns) as GridNode<T>[];\n headerRows.forEach((row, i) => rows.splice(i, 0, row));\n\n super({\n columnCount: columns.length,\n items: rows,\n visitNode: node => {\n node.column = columns[node.index];\n return node;\n }\n });\n this.columns = columns;\n this.rowHeaderColumnKeys = rowHeaderColumnKeys;\n this.body = body!;\n this.headerRows = headerRows;\n this._size = [...body!.childNodes].length;\n\n // Default row header column to the first one.\n if (this.rowHeaderColumnKeys.size === 0) {\n let col = this.columns.find(column => !column.props?.isDragButtonCell && !column.props?.isSelectionCell);\n if (col) {\n this.rowHeaderColumnKeys.add(col.key);\n }\n }\n }\n\n *[Symbol.iterator](): IterableIterator<GridNode<T>> {\n yield* this.body.childNodes;\n }\n\n get size(): number {\n return this._size;\n }\n\n getKeys(): IterableIterator<Key> {\n return this.keyMap.keys();\n }\n\n getKeyBefore(key: Key): Key | null {\n let node = this.keyMap.get(key);\n return node?.prevKey ?? null;\n }\n\n getKeyAfter(key: Key): Key | null {\n let node = this.keyMap.get(key);\n return node?.nextKey ?? null;\n }\n\n getFirstKey(): Key | null {\n return getFirstItem(this.body.childNodes)?.key ?? null;\n }\n\n getLastKey(): Key | null {\n return getLastItem(this.body.childNodes)?.key ?? null;\n }\n\n getItem(key: Key): GridNode<T> | null {\n return this.keyMap.get(key) ?? null;\n }\n\n at(idx: number): GridNode<T> | null {\n const keys = [...this.getKeys()];\n return this.getItem(keys[idx]);\n }\n\n getChildren(key: Key): Iterable<GridNode<T>> {\n if (key === this.body.key) {\n return this.body.childNodes;\n }\n\n return super.getChildren(key);\n }\n\n getTextValue(key: Key): string {\n let row = this.getItem(key);\n if (!row) {\n return '';\n }\n\n // If the row has a textValue, use that.\n if (row.textValue) {\n return row.textValue;\n }\n\n // Otherwise combine the text of each of the row header columns.\n let rowHeaderColumnKeys = this.rowHeaderColumnKeys;\n if (rowHeaderColumnKeys) {\n let text: string[] = [];\n for (let cell of row.childNodes) {\n let column = this.columns[cell.index];\n if (rowHeaderColumnKeys.has(column.key) && cell.textValue) {\n text.push(cell.textValue);\n }\n\n if (text.length === rowHeaderColumnKeys.size) {\n break;\n }\n }\n\n return text.join(' ');\n }\n\n return '';\n }\n}\n"],"names":[],"version":3,"file":"TableCollection.main.js.map"}
@@ -1,302 +0,0 @@
1
- import {getFirstItem as $iLnZt$getFirstItem, getLastItem as $iLnZt$getLastItem} from "@react-stately/collections";
2
- import {GridCollection as $iLnZt$GridCollection} from "@react-stately/grid";
3
-
4
- /*
5
- * Copyright 2020 Adobe. All rights reserved.
6
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License. You may obtain a copy
8
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software distributed under
11
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
12
- * OF ANY KIND, either express or implied. See the License for the specific language
13
- * governing permissions and limitations under the License.
14
- */
15
-
16
- const $788781baa30117fa$var$ROW_HEADER_COLUMN_KEY = 'row-header-column-' + Math.random().toString(36).slice(2);
17
- let $788781baa30117fa$var$ROW_HEADER_COLUMN_KEY_DRAG = 'row-header-column-' + Math.random().toString(36).slice(2);
18
- while($788781baa30117fa$var$ROW_HEADER_COLUMN_KEY === $788781baa30117fa$var$ROW_HEADER_COLUMN_KEY_DRAG)$788781baa30117fa$var$ROW_HEADER_COLUMN_KEY_DRAG = 'row-header-column-' + Math.random().toString(36).slice(2);
19
- function $788781baa30117fa$export$7c127db850d4e81e(keyMap, columnNodes) {
20
- if (columnNodes.length === 0) return [];
21
- let columns = [];
22
- let seen = new Map();
23
- for (let column of columnNodes){
24
- let parentKey = column.parentKey;
25
- let col = [
26
- column
27
- ];
28
- while(parentKey){
29
- let parent = keyMap.get(parentKey);
30
- if (!parent) break;
31
- // If we've already seen this parent, than it is shared
32
- // with a previous column. If the current column is taller
33
- // than the previous column, than we need to shift the parent
34
- // in the previous column so it's level with the current column.
35
- if (seen.has(parent)) {
36
- var _parent;
37
- var _colSpan;
38
- (_colSpan = (_parent = parent).colSpan) !== null && _colSpan !== void 0 ? _colSpan : _parent.colSpan = 0;
39
- parent.colSpan++;
40
- parent.colspan = parent.colSpan;
41
- let { column: column, index: index } = seen.get(parent);
42
- if (index > col.length) break;
43
- for(let i = index; i < col.length; i++)column.splice(i, 0, null);
44
- // Adjust shifted indices
45
- for(let i = col.length; i < column.length; i++)// eslint-disable-next-line max-depth
46
- if (column[i] && seen.has(column[i])) seen.get(column[i]).index = i;
47
- } else {
48
- parent.colSpan = 1;
49
- parent.colspan = 1;
50
- col.push(parent);
51
- seen.set(parent, {
52
- column: col,
53
- index: col.length - 1
54
- });
55
- }
56
- parentKey = parent.parentKey;
57
- }
58
- columns.push(col);
59
- column.index = columns.length - 1;
60
- }
61
- let maxLength = Math.max(...columns.map((c)=>c.length));
62
- let headerRows = Array(maxLength).fill(0).map(()=>[]);
63
- // Convert columns into rows.
64
- let colIndex = 0;
65
- for (let column of columns){
66
- let i = maxLength - 1;
67
- for (let item of column){
68
- if (item) {
69
- // Fill the space up until the current column with a placeholder
70
- let row = headerRows[i];
71
- let rowLength = row.reduce((p, c)=>{
72
- var _c_colSpan;
73
- return p + ((_c_colSpan = c.colSpan) !== null && _c_colSpan !== void 0 ? _c_colSpan : 1);
74
- }, 0);
75
- if (rowLength < colIndex) {
76
- let placeholder = {
77
- type: 'placeholder',
78
- key: 'placeholder-' + item.key,
79
- colspan: colIndex - rowLength,
80
- colSpan: colIndex - rowLength,
81
- index: rowLength,
82
- value: null,
83
- rendered: null,
84
- level: i,
85
- hasChildNodes: false,
86
- childNodes: [],
87
- textValue: ''
88
- };
89
- // eslint-disable-next-line max-depth
90
- if (row.length > 0) {
91
- row[row.length - 1].nextKey = placeholder.key;
92
- placeholder.prevKey = row[row.length - 1].key;
93
- }
94
- row.push(placeholder);
95
- }
96
- if (row.length > 0) {
97
- row[row.length - 1].nextKey = item.key;
98
- item.prevKey = row[row.length - 1].key;
99
- }
100
- item.level = i;
101
- item.colIndex = colIndex;
102
- row.push(item);
103
- }
104
- i--;
105
- }
106
- colIndex++;
107
- }
108
- // Add placeholders at the end of each row that is shorter than the maximum
109
- let i = 0;
110
- for (let row of headerRows){
111
- let rowLength = row.reduce((p, c)=>{
112
- var _c_colSpan;
113
- return p + ((_c_colSpan = c.colSpan) !== null && _c_colSpan !== void 0 ? _c_colSpan : 1);
114
- }, 0);
115
- if (rowLength < columnNodes.length) {
116
- let placeholder = {
117
- type: 'placeholder',
118
- key: 'placeholder-' + row[row.length - 1].key,
119
- colSpan: columnNodes.length - rowLength,
120
- colspan: columnNodes.length - rowLength,
121
- index: rowLength,
122
- value: null,
123
- rendered: null,
124
- level: i,
125
- hasChildNodes: false,
126
- childNodes: [],
127
- textValue: '',
128
- prevKey: row[row.length - 1].key
129
- };
130
- row.push(placeholder);
131
- }
132
- i++;
133
- }
134
- return headerRows.map((childNodes, index)=>{
135
- let row = {
136
- type: 'headerrow',
137
- key: 'headerrow-' + index,
138
- index: index,
139
- value: null,
140
- rendered: null,
141
- level: 0,
142
- hasChildNodes: true,
143
- childNodes: childNodes,
144
- textValue: ''
145
- };
146
- return row;
147
- });
148
- }
149
- class $788781baa30117fa$export$596e1b2e2cf93690 extends (0, $iLnZt$GridCollection) {
150
- *[Symbol.iterator]() {
151
- yield* this.body.childNodes;
152
- }
153
- get size() {
154
- return this._size;
155
- }
156
- getKeys() {
157
- return this.keyMap.keys();
158
- }
159
- getKeyBefore(key) {
160
- let node = this.keyMap.get(key);
161
- var _node_prevKey;
162
- return (_node_prevKey = node === null || node === void 0 ? void 0 : node.prevKey) !== null && _node_prevKey !== void 0 ? _node_prevKey : null;
163
- }
164
- getKeyAfter(key) {
165
- let node = this.keyMap.get(key);
166
- var _node_nextKey;
167
- return (_node_nextKey = node === null || node === void 0 ? void 0 : node.nextKey) !== null && _node_nextKey !== void 0 ? _node_nextKey : null;
168
- }
169
- getFirstKey() {
170
- var _getFirstItem;
171
- var _getFirstItem_key;
172
- return (_getFirstItem_key = (_getFirstItem = (0, $iLnZt$getFirstItem)(this.body.childNodes)) === null || _getFirstItem === void 0 ? void 0 : _getFirstItem.key) !== null && _getFirstItem_key !== void 0 ? _getFirstItem_key : null;
173
- }
174
- getLastKey() {
175
- var _getLastItem;
176
- var _getLastItem_key;
177
- return (_getLastItem_key = (_getLastItem = (0, $iLnZt$getLastItem)(this.body.childNodes)) === null || _getLastItem === void 0 ? void 0 : _getLastItem.key) !== null && _getLastItem_key !== void 0 ? _getLastItem_key : null;
178
- }
179
- getItem(key) {
180
- var _this_keyMap_get;
181
- return (_this_keyMap_get = this.keyMap.get(key)) !== null && _this_keyMap_get !== void 0 ? _this_keyMap_get : null;
182
- }
183
- at(idx) {
184
- const keys = [
185
- ...this.getKeys()
186
- ];
187
- return this.getItem(keys[idx]);
188
- }
189
- getChildren(key) {
190
- if (key === this.body.key) return this.body.childNodes;
191
- return super.getChildren(key);
192
- }
193
- getTextValue(key) {
194
- let row = this.getItem(key);
195
- if (!row) return '';
196
- // If the row has a textValue, use that.
197
- if (row.textValue) return row.textValue;
198
- // Otherwise combine the text of each of the row header columns.
199
- let rowHeaderColumnKeys = this.rowHeaderColumnKeys;
200
- if (rowHeaderColumnKeys) {
201
- let text = [];
202
- for (let cell of row.childNodes){
203
- let column = this.columns[cell.index];
204
- if (rowHeaderColumnKeys.has(column.key) && cell.textValue) text.push(cell.textValue);
205
- if (text.length === rowHeaderColumnKeys.size) break;
206
- }
207
- return text.join(' ');
208
- }
209
- return '';
210
- }
211
- constructor(nodes, prev, opts){
212
- let rowHeaderColumnKeys = new Set();
213
- let body = null;
214
- let columns = [];
215
- // Add cell for selection checkboxes if needed.
216
- if (opts === null || opts === void 0 ? void 0 : opts.showSelectionCheckboxes) {
217
- let rowHeaderColumn = {
218
- type: 'column',
219
- key: $788781baa30117fa$var$ROW_HEADER_COLUMN_KEY,
220
- value: null,
221
- textValue: '',
222
- level: 0,
223
- index: (opts === null || opts === void 0 ? void 0 : opts.showDragButtons) ? 1 : 0,
224
- hasChildNodes: false,
225
- rendered: null,
226
- childNodes: [],
227
- props: {
228
- isSelectionCell: true
229
- }
230
- };
231
- columns.unshift(rowHeaderColumn);
232
- }
233
- // Add cell for drag buttons if needed.
234
- if (opts === null || opts === void 0 ? void 0 : opts.showDragButtons) {
235
- let rowHeaderColumn = {
236
- type: 'column',
237
- key: $788781baa30117fa$var$ROW_HEADER_COLUMN_KEY_DRAG,
238
- value: null,
239
- textValue: '',
240
- level: 0,
241
- index: 0,
242
- hasChildNodes: false,
243
- rendered: null,
244
- childNodes: [],
245
- props: {
246
- isDragButtonCell: true
247
- }
248
- };
249
- columns.unshift(rowHeaderColumn);
250
- }
251
- let rows = [];
252
- let columnKeyMap = new Map();
253
- let visit = (node)=>{
254
- switch(node.type){
255
- case 'body':
256
- body = node;
257
- break;
258
- case 'column':
259
- columnKeyMap.set(node.key, node);
260
- if (!node.hasChildNodes) {
261
- columns.push(node);
262
- if (node.props.isRowHeader) rowHeaderColumnKeys.add(node.key);
263
- }
264
- break;
265
- case 'item':
266
- rows.push(node);
267
- return; // do not go into childNodes
268
- }
269
- for (let child of node.childNodes)visit(child);
270
- };
271
- for (let node of nodes)visit(node);
272
- let headerRows = $788781baa30117fa$export$7c127db850d4e81e(columnKeyMap, columns);
273
- headerRows.forEach((row, i)=>rows.splice(i, 0, row));
274
- super({
275
- columnCount: columns.length,
276
- items: rows,
277
- visitNode: (node)=>{
278
- node.column = columns[node.index];
279
- return node;
280
- }
281
- }), this._size = 0;
282
- this.columns = columns;
283
- this.rowHeaderColumnKeys = rowHeaderColumnKeys;
284
- this.body = body;
285
- this.headerRows = headerRows;
286
- this._size = [
287
- ...body.childNodes
288
- ].length;
289
- // Default row header column to the first one.
290
- if (this.rowHeaderColumnKeys.size === 0) {
291
- let col = this.columns.find((column)=>{
292
- var _column_props, _column_props1;
293
- return !((_column_props = column.props) === null || _column_props === void 0 ? void 0 : _column_props.isDragButtonCell) && !((_column_props1 = column.props) === null || _column_props1 === void 0 ? void 0 : _column_props1.isSelectionCell);
294
- });
295
- if (col) this.rowHeaderColumnKeys.add(col.key);
296
- }
297
- }
298
- }
299
-
300
-
301
- export {$788781baa30117fa$export$7c127db850d4e81e as buildHeaderRows, $788781baa30117fa$export$596e1b2e2cf93690 as TableCollection};
302
- //# sourceMappingURL=TableCollection.module.js.map