@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,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
@@ -1 +0,0 @@
1
- {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAaD,MAAM,8CAAwB,uBAAuB,KAAK,MAAM,GAAG,QAAQ,CAAC,IAAI,KAAK,CAAC;AACtF,IAAI,mDAA6B,uBAAuB,KAAK,MAAM,GAAG,QAAQ,CA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C,KAAK,GAAG,EAAE;oBAC3B,IAAI,CAAC,KAAK,aAAa,EAAE;wBACvB,QAAQ,IAAI,CAAC;wBAEb,IAAI,KAAK,KAAK,CAAC,WAAW,EACxB,oBAAoB,GAAG,CAAC,KAAK,GAAG;oBAEpC;oBACA;gBACF,KAAK;oBACH,KAAK,IAAI,CAAC;oBACV,QAAQ,4BAA4B;YACxC;YACA,KAAK,IAAI,SAAS,KAAK,UAAU,CAC/B,MAAM;QAEV;QAEA,KAAK,IAAI,QAAQ,MACf,MAAM;QAGR,IAAI,aAAa,0CAAgB,cAAc;QAC/C,WAAW,OAAO,CAAC,CAAC,KAAK,IAAM,KAAK,MAAM,CAAC,GAAG,GAAG;QAEjD,KAAK,CAAC;YACJ,aAAa,QAAQ,MAAM;YAC3B,OAAO;YACP,WAAW,CAAA;gBACT,KAAK,MAAM,GAAG,OAAO,CAAC,KAAK,KAAK,CAAC;gBACjC,OAAO;YACT;QACF,SAtFF,QAAgB;QAuFd,IAAI,CAAC,OAAO,GAAG;QACf,IAAI,CAAC,mBAAmB,GAAG;QAC3B,IAAI,CAAC,IAAI,GAAG;QACZ,IAAI,CAAC,UAAU,GAAG;QAClB,IAAI,CAAC,KAAK,GAAG;eAAI,KAAM,UAAU;SAAC,CAAC,MAAM;QAEzC,8CAA8C;QAC9C,IAAI,IAAI,CAAC,mBAAmB,CAAC,IAAI,KAAK,GAAG;YACvC,IAAI,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAA;oBAAW,eAAmC;uBAApC,GAAC,gBAAA,OAAO,KAAK,cAAZ,oCAAA,cAAc,gBAAgB,KAAI,GAAC,iBAAA,OAAO,KAAK,cAAZ,qCAAA,eAAc,eAAe;;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.module.js.map"}
@@ -1,113 +0,0 @@
1
- var $9e5f6a0caf75716e$exports = require("./TableUtils.main.js");
2
-
3
-
4
- function $parcel$export(e, n, v, s) {
5
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
6
- }
7
-
8
- $parcel$export(module.exports, "TableColumnLayout", () => $2240a72410c17d51$export$7ff77a162970b30e);
9
- /*
10
- * Copyright 2022 Adobe. All rights reserved.
11
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
12
- * you may not use this file except in compliance with the License. You may obtain a copy
13
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
14
- *
15
- * Unless required by applicable law or agreed to in writing, software distributed under
16
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
17
- * OF ANY KIND, either express or implied. See the License for the specific language
18
- * governing permissions and limitations under the License.
19
- */
20
- class $2240a72410c17d51$export$7ff77a162970b30e {
21
- /** Takes an array of columns and splits it into 2 maps of columns with controlled and columns with uncontrolled widths. */ splitColumnsIntoControlledAndUncontrolled(columns) {
22
- return columns.reduce((acc, col)=>{
23
- if (col.props.width != null) acc[0].set(col.key, col);
24
- else acc[1].set(col.key, col);
25
- return acc;
26
- }, [
27
- new Map(),
28
- new Map()
29
- ]);
30
- }
31
- /** Takes uncontrolled and controlled widths and joins them into a single Map. */ recombineColumns(columns, uncontrolledWidths, uncontrolledColumns, controlledColumns) {
32
- return new Map(columns.map((col)=>{
33
- if (uncontrolledColumns.has(col.key)) return [
34
- col.key,
35
- uncontrolledWidths.get(col.key)
36
- ];
37
- else return [
38
- col.key,
39
- controlledColumns.get(col.key).props.width
40
- ];
41
- }));
42
- }
43
- /** Used to make an initial Map of the uncontrolled widths based on default widths. */ getInitialUncontrolledWidths(uncontrolledColumns) {
44
- return new Map(Array.from(uncontrolledColumns).map(([key, col])=>{
45
- var _this_getDefaultWidth, _this;
46
- var _col_props_defaultWidth, _ref;
47
- return [
48
- key,
49
- (_ref = (_col_props_defaultWidth = col.props.defaultWidth) !== null && _col_props_defaultWidth !== void 0 ? _col_props_defaultWidth : (_this_getDefaultWidth = (_this = this).getDefaultWidth) === null || _this_getDefaultWidth === void 0 ? void 0 : _this_getDefaultWidth.call(_this, col)) !== null && _ref !== void 0 ? _ref : '1fr'
50
- ];
51
- }));
52
- }
53
- getColumnWidth(key) {
54
- var _this_columnWidths_get;
55
- return (_this_columnWidths_get = this.columnWidths.get(key)) !== null && _this_columnWidths_get !== void 0 ? _this_columnWidths_get : 0;
56
- }
57
- getColumnMinWidth(key) {
58
- var _this_columnMinWidths_get;
59
- return (_this_columnMinWidths_get = this.columnMinWidths.get(key)) !== null && _this_columnMinWidths_get !== void 0 ? _this_columnMinWidths_get : 0;
60
- }
61
- getColumnMaxWidth(key) {
62
- var _this_columnMaxWidths_get;
63
- return (_this_columnMaxWidths_get = this.columnMaxWidths.get(key)) !== null && _this_columnMaxWidths_get !== void 0 ? _this_columnMaxWidths_get : 0;
64
- }
65
- resizeColumnWidth(collection, uncontrolledWidths, col, width) {
66
- let prevColumnWidths = this.columnWidths;
67
- let freeze = true;
68
- let newWidths = new Map();
69
- width = Math.max(this.getColumnMinWidth(col), Math.min(this.getColumnMaxWidth(col), Math.floor(width)));
70
- collection.columns.forEach((column)=>{
71
- var _prevColumnWidths_get, _column_props_width;
72
- if (column.key === col) {
73
- newWidths.set(column.key, width);
74
- freeze = false;
75
- } else if (freeze) // freeze columns to the left to their previous pixel value
76
- newWidths.set(column.key, (_prevColumnWidths_get = prevColumnWidths.get(column.key)) !== null && _prevColumnWidths_get !== void 0 ? _prevColumnWidths_get : 0);
77
- else newWidths.set(column.key, (_column_props_width = column.props.width) !== null && _column_props_width !== void 0 ? _column_props_width : uncontrolledWidths.get(column.key));
78
- });
79
- return newWidths;
80
- }
81
- buildColumnWidths(tableWidth, collection, widths) {
82
- this.columnWidths = new Map();
83
- this.columnMinWidths = new Map();
84
- this.columnMaxWidths = new Map();
85
- // initial layout or table/window resizing
86
- let columnWidths = (0, $9e5f6a0caf75716e$exports.calculateColumnSizes)(tableWidth, collection.columns.map((col)=>({
87
- ...col.props,
88
- key: col.key
89
- })), widths, (i)=>this.getDefaultWidth(collection.columns[i]), (i)=>this.getDefaultMinWidth(collection.columns[i]));
90
- // columns going in will be the same order as the columns coming out
91
- columnWidths.forEach((width, index)=>{
92
- let key = collection.columns[index].key;
93
- let column = collection.columns[index];
94
- this.columnWidths.set(key, width);
95
- var _column_props_minWidth;
96
- this.columnMinWidths.set(key, (0, $9e5f6a0caf75716e$exports.getMinWidth)((_column_props_minWidth = column.props.minWidth) !== null && _column_props_minWidth !== void 0 ? _column_props_minWidth : this.getDefaultMinWidth(column), tableWidth));
97
- this.columnMaxWidths.set(key, (0, $9e5f6a0caf75716e$exports.getMaxWidth)(column.props.maxWidth, tableWidth));
98
- });
99
- return this.columnWidths;
100
- }
101
- constructor(options){
102
- this.columnWidths = new Map();
103
- this.columnMinWidths = new Map();
104
- this.columnMaxWidths = new Map();
105
- var _options_getDefaultWidth;
106
- this.getDefaultWidth = (_options_getDefaultWidth = options === null || options === void 0 ? void 0 : options.getDefaultWidth) !== null && _options_getDefaultWidth !== void 0 ? _options_getDefaultWidth : ()=>'1fr';
107
- var _options_getDefaultMinWidth;
108
- this.getDefaultMinWidth = (_options_getDefaultMinWidth = options === null || options === void 0 ? void 0 : options.getDefaultMinWidth) !== null && _options_getDefaultMinWidth !== void 0 ? _options_getDefaultMinWidth : ()=>75;
109
- }
110
- }
111
-
112
-
113
- //# sourceMappingURL=TableColumnLayout.main.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;AAgBM,MAAM;IAYX,yHAAyH,GACzH,0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,GAAG;YAAA,CAAA,IAC1D,QACA,CAAC,IAAM,IAAI,CAAC,eAAe,CAAC,WAAW,OAAO,CAAC,EAAE,GACjD,CAAC,IAAM,IAAI,CAAC,kBAAkB,CAAC,WAAW,OAAO,CAAC,EAAE;QAGtD,oEAAoE;QACpE,aAAa,OAAO,CAAC,CAAC,OAAO;YAC3B,IAAI,MAAM,WAAW,OAAO,CAAC,MAAM,CAAC,GAAG;YACvC,IAAI,SAAS,WAAW,OAAO,CAAC,MAAM;YACtC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,KAAK;gBACe;YAA1C,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,KAAK,CAAA,GAAA,qCAAU,EAAE,CAAA,yBAAA,OAAO,KAAK,CAAC,QAAQ,cAArB,oCAAA,yBAAyB,IAAI,CAAC,kBAAkB,CAAC,SAAS;YACpG,IAAI,CAAC,eAAe,CAAC,GAAG,CAAC,KAAK,CAAA,GAAA,qCAAU,EAAE,OAAO,KAAK,CAAC,QAAQ,EAAE;QACnE;QACA,OAAO,IAAI,CAAC,YAAY;IAC1B;IA5FA,YAAY,OAAoC,CAAE;aAJlD,eAAiC,IAAI;aACrC,kBAAoC,IAAI;aACxC,kBAAoC,IAAI;YAGf;QAAvB,IAAI,CAAC,eAAe,GAAG,CAAA,2BAAA,oBAAA,8BAAA,QAAS,eAAe,cAAxB,sCAAA,2BAA6B,IAAM;YAChC;QAA1B,IAAI,CAAC,kBAAkB,GAAG,CAAA,8BAAA,oBAAA,8BAAA,QAAS,kBAAkB,cAA3B,yCAAA,8BAAgC,IAAM;IAClE;AA0FF","sources":["packages/@react-stately/table/src/TableColumnLayout.ts"],"sourcesContent":["/*\n * Copyright 2022 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 {\n calculateColumnSizes,\n getMaxWidth,\n getMinWidth\n} from './TableUtils';\nimport {ColumnSize, TableCollection} from '@react-types/table';\nimport {GridNode} from '@react-types/grid';\nimport {Key} from '@react-types/shared';\n\nexport interface TableColumnLayoutOptions<T> {\n getDefaultWidth?: (column: GridNode<T>) => ColumnSize | null | undefined,\n getDefaultMinWidth?: (column: GridNode<T>) => ColumnSize | null | undefined\n}\n\nexport class TableColumnLayout<T> {\n getDefaultWidth: (column: GridNode<T>) => ColumnSize | null | undefined;\n getDefaultMinWidth: (column: GridNode<T>) => ColumnSize | null | undefined;\n columnWidths: Map<Key, number> = new Map();\n columnMinWidths: Map<Key, number> = new Map();\n columnMaxWidths: Map<Key, number> = new Map();\n\n constructor(options: TableColumnLayoutOptions<T>) {\n this.getDefaultWidth = options?.getDefaultWidth ?? (() => '1fr');\n this.getDefaultMinWidth = options?.getDefaultMinWidth ?? (() => 75);\n }\n\n /** Takes an array of columns and splits it into 2 maps of columns with controlled and columns with uncontrolled widths. */\n splitColumnsIntoControlledAndUncontrolled(columns: Array<GridNode<T>>): [Map<Key, GridNode<T>>, Map<Key, GridNode<T>>] {\n return columns.reduce((acc, col) => {\n if (col.props.width != null) {\n acc[0].set(col.key, col);\n } else {\n acc[1].set(col.key, col);\n }\n return acc;\n }, [new Map(), new Map()]);\n }\n\n /** Takes uncontrolled and controlled widths and joins them into a single Map. */\n recombineColumns(columns: Array<GridNode<T>>, uncontrolledWidths: Map<Key, ColumnSize>, uncontrolledColumns: Map<Key, GridNode<T>>, controlledColumns: Map<Key, GridNode<T>>): Map<Key, ColumnSize> {\n return new Map(columns.map(col => {\n if (uncontrolledColumns.has(col.key)) {\n return [col.key, uncontrolledWidths.get(col.key)];\n } else {\n return [col.key, controlledColumns.get(col.key)!.props.width];\n }\n }));\n }\n\n /** Used to make an initial Map of the uncontrolled widths based on default widths. */\n getInitialUncontrolledWidths(uncontrolledColumns: Map<Key, GridNode<T>>): Map<Key, ColumnSize> {\n return new Map(Array.from(uncontrolledColumns).map(([key, col]) =>\n [key, col.props.defaultWidth ?? this.getDefaultWidth?.(col) ?? '1fr']\n ));\n }\n\n getColumnWidth(key: Key): number {\n return this.columnWidths.get(key) ?? 0;\n }\n\n getColumnMinWidth(key: Key): number {\n return this.columnMinWidths.get(key) ?? 0;\n }\n\n getColumnMaxWidth(key: Key): number {\n return this.columnMaxWidths.get(key) ?? 0;\n }\n\n resizeColumnWidth(collection: TableCollection<T>, uncontrolledWidths: Map<Key, ColumnSize>, col: Key, width: number): Map<Key, ColumnSize> {\n let prevColumnWidths = this.columnWidths;\n let freeze = true;\n let newWidths = new Map<Key, ColumnSize>();\n\n width = Math.max(this.getColumnMinWidth(col), Math.min(this.getColumnMaxWidth(col), Math.floor(width)));\n\n collection.columns.forEach(column => {\n if (column.key === col) {\n newWidths.set(column.key, width);\n freeze = false;\n } else if (freeze) {\n // freeze columns to the left to their previous pixel value\n newWidths.set(column.key, prevColumnWidths.get(column.key) ?? 0);\n } else {\n newWidths.set(column.key, column.props.width ?? uncontrolledWidths.get(column.key));\n }\n });\n\n return newWidths;\n }\n\n buildColumnWidths(tableWidth: number, collection: TableCollection<T>, widths: Map<Key, ColumnSize>): Map<Key, number> {\n this.columnWidths = new Map();\n this.columnMinWidths = new Map();\n this.columnMaxWidths = new Map();\n\n // initial layout or table/window resizing\n let columnWidths = calculateColumnSizes(\n tableWidth,\n collection.columns.map(col => ({...col.props, key: col.key})),\n widths,\n (i) => this.getDefaultWidth(collection.columns[i]),\n (i) => this.getDefaultMinWidth(collection.columns[i])\n );\n\n // columns going in will be the same order as the columns coming out\n columnWidths.forEach((width, index) => {\n let key = collection.columns[index].key;\n let column = collection.columns[index];\n this.columnWidths.set(key, width);\n this.columnMinWidths.set(key, getMinWidth(column.props.minWidth ?? this.getDefaultMinWidth(column), tableWidth));\n this.columnMaxWidths.set(key, getMaxWidth(column.props.maxWidth, tableWidth));\n });\n return this.columnWidths;\n }\n}\n"],"names":[],"version":3,"file":"TableColumnLayout.main.js.map"}
@@ -1,108 +0,0 @@
1
- import {calculateColumnSizes as $6818b1c4fc67028d$export$55d50dc687385491, getMaxWidth as $6818b1c4fc67028d$export$59185c62a7544aa0, getMinWidth as $6818b1c4fc67028d$export$f556054ce4358701} from "./TableUtils.mjs";
2
-
3
- /*
4
- * Copyright 2022 Adobe. All rights reserved.
5
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License. You may obtain a copy
7
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
8
- *
9
- * Unless required by applicable law or agreed to in writing, software distributed under
10
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
11
- * OF ANY KIND, either express or implied. See the License for the specific language
12
- * governing permissions and limitations under the License.
13
- */
14
- class $a9e7ae544a4e41dd$export$7ff77a162970b30e {
15
- /** Takes an array of columns and splits it into 2 maps of columns with controlled and columns with uncontrolled widths. */ splitColumnsIntoControlledAndUncontrolled(columns) {
16
- return columns.reduce((acc, col)=>{
17
- if (col.props.width != null) acc[0].set(col.key, col);
18
- else acc[1].set(col.key, col);
19
- return acc;
20
- }, [
21
- new Map(),
22
- new Map()
23
- ]);
24
- }
25
- /** Takes uncontrolled and controlled widths and joins them into a single Map. */ recombineColumns(columns, uncontrolledWidths, uncontrolledColumns, controlledColumns) {
26
- return new Map(columns.map((col)=>{
27
- if (uncontrolledColumns.has(col.key)) return [
28
- col.key,
29
- uncontrolledWidths.get(col.key)
30
- ];
31
- else return [
32
- col.key,
33
- controlledColumns.get(col.key).props.width
34
- ];
35
- }));
36
- }
37
- /** Used to make an initial Map of the uncontrolled widths based on default widths. */ getInitialUncontrolledWidths(uncontrolledColumns) {
38
- return new Map(Array.from(uncontrolledColumns).map(([key, col])=>{
39
- var _this_getDefaultWidth, _this;
40
- var _col_props_defaultWidth, _ref;
41
- return [
42
- key,
43
- (_ref = (_col_props_defaultWidth = col.props.defaultWidth) !== null && _col_props_defaultWidth !== void 0 ? _col_props_defaultWidth : (_this_getDefaultWidth = (_this = this).getDefaultWidth) === null || _this_getDefaultWidth === void 0 ? void 0 : _this_getDefaultWidth.call(_this, col)) !== null && _ref !== void 0 ? _ref : '1fr'
44
- ];
45
- }));
46
- }
47
- getColumnWidth(key) {
48
- var _this_columnWidths_get;
49
- return (_this_columnWidths_get = this.columnWidths.get(key)) !== null && _this_columnWidths_get !== void 0 ? _this_columnWidths_get : 0;
50
- }
51
- getColumnMinWidth(key) {
52
- var _this_columnMinWidths_get;
53
- return (_this_columnMinWidths_get = this.columnMinWidths.get(key)) !== null && _this_columnMinWidths_get !== void 0 ? _this_columnMinWidths_get : 0;
54
- }
55
- getColumnMaxWidth(key) {
56
- var _this_columnMaxWidths_get;
57
- return (_this_columnMaxWidths_get = this.columnMaxWidths.get(key)) !== null && _this_columnMaxWidths_get !== void 0 ? _this_columnMaxWidths_get : 0;
58
- }
59
- resizeColumnWidth(collection, uncontrolledWidths, col, width) {
60
- let prevColumnWidths = this.columnWidths;
61
- let freeze = true;
62
- let newWidths = new Map();
63
- width = Math.max(this.getColumnMinWidth(col), Math.min(this.getColumnMaxWidth(col), Math.floor(width)));
64
- collection.columns.forEach((column)=>{
65
- var _prevColumnWidths_get, _column_props_width;
66
- if (column.key === col) {
67
- newWidths.set(column.key, width);
68
- freeze = false;
69
- } else if (freeze) // freeze columns to the left to their previous pixel value
70
- newWidths.set(column.key, (_prevColumnWidths_get = prevColumnWidths.get(column.key)) !== null && _prevColumnWidths_get !== void 0 ? _prevColumnWidths_get : 0);
71
- else newWidths.set(column.key, (_column_props_width = column.props.width) !== null && _column_props_width !== void 0 ? _column_props_width : uncontrolledWidths.get(column.key));
72
- });
73
- return newWidths;
74
- }
75
- buildColumnWidths(tableWidth, collection, widths) {
76
- this.columnWidths = new Map();
77
- this.columnMinWidths = new Map();
78
- this.columnMaxWidths = new Map();
79
- // initial layout or table/window resizing
80
- let columnWidths = (0, $6818b1c4fc67028d$export$55d50dc687385491)(tableWidth, collection.columns.map((col)=>({
81
- ...col.props,
82
- key: col.key
83
- })), widths, (i)=>this.getDefaultWidth(collection.columns[i]), (i)=>this.getDefaultMinWidth(collection.columns[i]));
84
- // columns going in will be the same order as the columns coming out
85
- columnWidths.forEach((width, index)=>{
86
- let key = collection.columns[index].key;
87
- let column = collection.columns[index];
88
- this.columnWidths.set(key, width);
89
- var _column_props_minWidth;
90
- this.columnMinWidths.set(key, (0, $6818b1c4fc67028d$export$f556054ce4358701)((_column_props_minWidth = column.props.minWidth) !== null && _column_props_minWidth !== void 0 ? _column_props_minWidth : this.getDefaultMinWidth(column), tableWidth));
91
- this.columnMaxWidths.set(key, (0, $6818b1c4fc67028d$export$59185c62a7544aa0)(column.props.maxWidth, tableWidth));
92
- });
93
- return this.columnWidths;
94
- }
95
- constructor(options){
96
- this.columnWidths = new Map();
97
- this.columnMinWidths = new Map();
98
- this.columnMaxWidths = new Map();
99
- var _options_getDefaultWidth;
100
- this.getDefaultWidth = (_options_getDefaultWidth = options === null || options === void 0 ? void 0 : options.getDefaultWidth) !== null && _options_getDefaultWidth !== void 0 ? _options_getDefaultWidth : ()=>'1fr';
101
- var _options_getDefaultMinWidth;
102
- this.getDefaultMinWidth = (_options_getDefaultMinWidth = options === null || options === void 0 ? void 0 : options.getDefaultMinWidth) !== null && _options_getDefaultMinWidth !== void 0 ? _options_getDefaultMinWidth : ()=>75;
103
- }
104
- }
105
-
106
-
107
- export {$a9e7ae544a4e41dd$export$7ff77a162970b30e as TableColumnLayout};
108
- //# sourceMappingURL=TableColumnLayout.module.js.map