@react-stately/table 3.0.0-beta.0 → 3.0.0-nightly-641446f65-240905
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Cell.main.js +38 -0
- package/dist/Cell.main.js.map +1 -0
- package/dist/Cell.mjs +33 -0
- package/dist/Cell.module.js +33 -0
- package/dist/Cell.module.js.map +1 -0
- package/dist/Column.main.js +75 -0
- package/dist/Column.main.js.map +1 -0
- package/dist/Column.mjs +66 -0
- package/dist/Column.module.js +66 -0
- package/dist/Column.module.js.map +1 -0
- package/dist/Row.main.js +97 -0
- package/dist/Row.main.js.map +1 -0
- package/dist/Row.mjs +88 -0
- package/dist/Row.module.js +88 -0
- package/dist/Row.module.js.map +1 -0
- package/dist/TableBody.main.js +61 -0
- package/dist/TableBody.main.js.map +1 -0
- package/dist/TableBody.mjs +52 -0
- package/dist/TableBody.module.js +52 -0
- package/dist/TableBody.module.js.map +1 -0
- package/dist/TableCollection.main.js +288 -0
- package/dist/TableCollection.main.js.map +1 -0
- package/dist/TableCollection.mjs +282 -0
- package/dist/TableCollection.module.js +282 -0
- package/dist/TableCollection.module.js.map +1 -0
- package/dist/TableColumnLayout.main.js +113 -0
- package/dist/TableColumnLayout.main.js.map +1 -0
- package/dist/TableColumnLayout.mjs +108 -0
- package/dist/TableColumnLayout.module.js +108 -0
- package/dist/TableColumnLayout.module.js.map +1 -0
- package/dist/TableHeader.main.js +56 -0
- package/dist/TableHeader.main.js.map +1 -0
- package/dist/TableHeader.mjs +47 -0
- package/dist/TableHeader.module.js +47 -0
- package/dist/TableHeader.module.js.map +1 -0
- package/dist/TableUtils.main.js +182 -0
- package/dist/TableUtils.main.js.map +1 -0
- package/dist/TableUtils.mjs +175 -0
- package/dist/TableUtils.module.js +175 -0
- package/dist/TableUtils.module.js.map +1 -0
- package/dist/import.mjs +37 -0
- package/dist/main.js +39 -593
- package/dist/main.js.map +1 -1
- package/dist/module.js +22 -564
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +163 -9
- package/dist/types.d.ts.map +1 -1
- package/dist/useTableColumnResizeState.main.js +109 -0
- package/dist/useTableColumnResizeState.main.js.map +1 -0
- package/dist/useTableColumnResizeState.mjs +104 -0
- package/dist/useTableColumnResizeState.module.js +104 -0
- package/dist/useTableColumnResizeState.module.js.map +1 -0
- package/dist/useTableState.main.js +71 -0
- package/dist/useTableState.main.js.map +1 -0
- package/dist/useTableState.mjs +66 -0
- package/dist/useTableState.module.js +66 -0
- package/dist/useTableState.module.js.map +1 -0
- package/dist/useTreeGridState.main.js +207 -0
- package/dist/useTreeGridState.main.js.map +1 -0
- package/dist/useTreeGridState.mjs +202 -0
- package/dist/useTreeGridState.module.js +202 -0
- package/dist/useTreeGridState.module.js.map +1 -0
- package/package.json +18 -10
- package/src/Cell.ts +4 -1
- package/src/Column.ts +12 -2
- package/src/Row.ts +50 -10
- package/src/TableBody.ts +6 -2
- package/src/TableCollection.ts +99 -15
- package/src/TableColumnLayout.ts +127 -0
- package/src/TableHeader.ts +11 -2
- package/src/TableUtils.ts +253 -0
- package/src/index.ts +15 -6
- package/src/useTableColumnResizeState.ts +147 -0
- package/src/useTableState.ts +43 -16
- package/src/useTreeGridState.ts +277 -0
- package/LICENSE +0 -201
package/dist/module.js
CHANGED
|
@@ -1,547 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
for (let column of columnNodes) {
|
|
14
|
-
let parentKey = column.parentKey;
|
|
15
|
-
let col = [column];
|
|
16
|
-
|
|
17
|
-
while (parentKey) {
|
|
18
|
-
let parent = keyMap.get(parentKey); // If we've already seen this parent, than it is shared
|
|
19
|
-
// with a previous column. If the current column is taller
|
|
20
|
-
// than the previous column, than we need to shift the parent
|
|
21
|
-
// in the previous column so it's level with the current column.
|
|
22
|
-
|
|
23
|
-
if (seen.has(parent)) {
|
|
24
|
-
parent.colspan++;
|
|
25
|
-
let {
|
|
26
|
-
column,
|
|
27
|
-
index
|
|
28
|
-
} = seen.get(parent);
|
|
29
|
-
|
|
30
|
-
if (index > col.length) {
|
|
31
|
-
break;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
for (let i = index; i < col.length; i++) {
|
|
35
|
-
column.splice(i, 0, null);
|
|
36
|
-
} // Adjust shifted indices
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
for (let i = col.length; i < column.length; i++) {
|
|
40
|
-
if (column[i] && seen.has(column[i])) {
|
|
41
|
-
seen.get(column[i]).index = i;
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
} else {
|
|
45
|
-
parent.colspan = 1;
|
|
46
|
-
col.push(parent);
|
|
47
|
-
seen.set(parent, {
|
|
48
|
-
column: col,
|
|
49
|
-
index: col.length - 1
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
parentKey = parent.parentKey;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
columns.push(col);
|
|
57
|
-
column.index = columns.length - 1;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
let maxLength = Math.max(...columns.map(c => c.length));
|
|
61
|
-
let headerRows = Array(maxLength).fill(0).map(() => []); // Convert columns into rows.
|
|
62
|
-
|
|
63
|
-
let colIndex = 0;
|
|
64
|
-
|
|
65
|
-
for (let column of columns) {
|
|
66
|
-
let i = maxLength - 1;
|
|
67
|
-
|
|
68
|
-
for (let item of column) {
|
|
69
|
-
if (item) {
|
|
70
|
-
// Fill the space up until the current column with a placeholder
|
|
71
|
-
let row = headerRows[i];
|
|
72
|
-
let rowLength = row.reduce((p, c) => p + c.colspan, 0);
|
|
73
|
-
|
|
74
|
-
if (rowLength < colIndex) {
|
|
75
|
-
let placeholder = {
|
|
76
|
-
type: 'placeholder',
|
|
77
|
-
key: 'placeholder-' + item.key,
|
|
78
|
-
colspan: colIndex - rowLength,
|
|
79
|
-
index: rowLength,
|
|
80
|
-
value: null,
|
|
81
|
-
rendered: null,
|
|
82
|
-
level: i,
|
|
83
|
-
hasChildNodes: false,
|
|
84
|
-
childNodes: [],
|
|
85
|
-
textValue: null
|
|
86
|
-
};
|
|
87
|
-
|
|
88
|
-
if (row.length > 0) {
|
|
89
|
-
row[row.length - 1].nextKey = placeholder.key;
|
|
90
|
-
placeholder.prevKey = row[row.length - 1].key;
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
row.push(placeholder);
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
if (row.length > 0) {
|
|
97
|
-
row[row.length - 1].nextKey = item.key;
|
|
98
|
-
item.prevKey = row[row.length - 1].key;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
item.level = i;
|
|
102
|
-
item.index = colIndex;
|
|
103
|
-
row.push(item);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
i--;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
colIndex++;
|
|
110
|
-
} // Add placeholders at the end of each row that is shorter than the maximum
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
let i = 0;
|
|
114
|
-
|
|
115
|
-
for (let row of headerRows) {
|
|
116
|
-
let rowLength = row.reduce((p, c) => p + c.colspan, 0);
|
|
117
|
-
|
|
118
|
-
if (rowLength < columnNodes.length) {
|
|
119
|
-
let placeholder = {
|
|
120
|
-
type: 'placeholder',
|
|
121
|
-
key: 'placeholder-' + row[row.length - 1].key,
|
|
122
|
-
colspan: columnNodes.length - rowLength,
|
|
123
|
-
index: rowLength,
|
|
124
|
-
value: null,
|
|
125
|
-
rendered: null,
|
|
126
|
-
level: i,
|
|
127
|
-
hasChildNodes: false,
|
|
128
|
-
childNodes: [],
|
|
129
|
-
textValue: null,
|
|
130
|
-
prevKey: row[row.length - 1].key
|
|
131
|
-
};
|
|
132
|
-
row.push(placeholder);
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
i++;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
return headerRows.map((childNodes, index) => {
|
|
139
|
-
let row = {
|
|
140
|
-
type: 'headerrow',
|
|
141
|
-
key: 'headerrow-' + index,
|
|
142
|
-
index,
|
|
143
|
-
value: null,
|
|
144
|
-
rendered: null,
|
|
145
|
-
level: 0,
|
|
146
|
-
hasChildNodes: true,
|
|
147
|
-
childNodes,
|
|
148
|
-
textValue: null
|
|
149
|
-
};
|
|
150
|
-
return row;
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
$d7f61bffc1886b961473c48c52f8fd$var$_Symbol$iterator = Symbol.iterator;
|
|
155
|
-
|
|
156
|
-
class $d7f61bffc1886b961473c48c52f8fd$export$TableCollection extends GridCollection {
|
|
157
|
-
constructor(nodes, prev, opts) {
|
|
158
|
-
let rowHeaderColumnKeys = new Set();
|
|
159
|
-
let body;
|
|
160
|
-
let columns = []; // Add cell for selection checkboxes if needed.
|
|
161
|
-
|
|
162
|
-
if (opts != null && opts.showSelectionCheckboxes) {
|
|
163
|
-
let rowHeaderColumn = {
|
|
164
|
-
type: 'column',
|
|
165
|
-
key: $d7f61bffc1886b961473c48c52f8fd$var$ROW_HEADER_COLUMN_KEY,
|
|
166
|
-
value: null,
|
|
167
|
-
textValue: '',
|
|
168
|
-
level: 0,
|
|
169
|
-
index: 0,
|
|
170
|
-
hasChildNodes: false,
|
|
171
|
-
rendered: null,
|
|
172
|
-
childNodes: [],
|
|
173
|
-
props: {
|
|
174
|
-
isSelectionCell: true
|
|
175
|
-
}
|
|
176
|
-
};
|
|
177
|
-
columns.unshift(rowHeaderColumn);
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
let rows = [];
|
|
181
|
-
let columnKeyMap = new Map();
|
|
182
|
-
|
|
183
|
-
let visit = node => {
|
|
184
|
-
switch (node.type) {
|
|
185
|
-
case 'body':
|
|
186
|
-
body = node;
|
|
187
|
-
break;
|
|
188
|
-
|
|
189
|
-
case 'column':
|
|
190
|
-
columnKeyMap.set(node.key, node);
|
|
191
|
-
|
|
192
|
-
if (!node.hasChildNodes) {
|
|
193
|
-
columns.push(node);
|
|
194
|
-
|
|
195
|
-
if (node.props.isRowHeader) {
|
|
196
|
-
rowHeaderColumnKeys.add(node.key);
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
break;
|
|
201
|
-
|
|
202
|
-
case 'item':
|
|
203
|
-
rows.push(node);
|
|
204
|
-
return;
|
|
205
|
-
// do not go into childNodes
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
for (let child of node.childNodes) {
|
|
209
|
-
visit(child);
|
|
210
|
-
}
|
|
211
|
-
};
|
|
212
|
-
|
|
213
|
-
for (let node of nodes) {
|
|
214
|
-
visit(node);
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
let headerRows = $d7f61bffc1886b961473c48c52f8fd$var$buildHeaderRows(columnKeyMap, columns);
|
|
218
|
-
headerRows.forEach((row, i) => rows.splice(i, 0, row));
|
|
219
|
-
super({
|
|
220
|
-
columnCount: columns.length,
|
|
221
|
-
items: rows,
|
|
222
|
-
visitNode: node => {
|
|
223
|
-
node.column = columns[node.index];
|
|
224
|
-
return node;
|
|
225
|
-
}
|
|
226
|
-
});
|
|
227
|
-
this.headerRows = void 0;
|
|
228
|
-
this.columns = void 0;
|
|
229
|
-
this.rowHeaderColumnKeys = void 0;
|
|
230
|
-
this.body = void 0;
|
|
231
|
-
this.columns = columns;
|
|
232
|
-
this.rowHeaderColumnKeys = rowHeaderColumnKeys;
|
|
233
|
-
this.body = body;
|
|
234
|
-
this.headerRows = headerRows; // Default row header column to the first one.
|
|
235
|
-
|
|
236
|
-
if (this.rowHeaderColumnKeys.size === 0) {
|
|
237
|
-
this.rowHeaderColumnKeys.add(this.columns[opts != null && opts.showSelectionCheckboxes ? 1 : 0].key);
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
*[$d7f61bffc1886b961473c48c52f8fd$var$_Symbol$iterator]() {
|
|
242
|
-
yield* this.body.childNodes;
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
get size() {
|
|
246
|
-
return [...this.body.childNodes].length;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
getKeys() {
|
|
250
|
-
return this.keyMap.keys();
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
getKeyBefore(key) {
|
|
254
|
-
let node = this.keyMap.get(key);
|
|
255
|
-
return node ? node.prevKey : null;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
getKeyAfter(key) {
|
|
259
|
-
let node = this.keyMap.get(key);
|
|
260
|
-
return node ? node.nextKey : null;
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
getFirstKey() {
|
|
264
|
-
var _;
|
|
265
|
-
|
|
266
|
-
return (_ = [...this.body.childNodes][0]) == null ? void 0 : _.key;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
getLastKey() {
|
|
270
|
-
var _rows;
|
|
271
|
-
|
|
272
|
-
let rows = [...this.body.childNodes];
|
|
273
|
-
return (_rows = rows[rows.length - 1]) == null ? void 0 : _rows.key;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
getItem(key) {
|
|
277
|
-
return this.keyMap.get(key);
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
const $ed569ec24a699f43593e019ef637b788$var$OPPOSITE_SORT_DIRECTION = {
|
|
283
|
-
ascending: 'descending',
|
|
284
|
-
descending: 'ascending'
|
|
285
|
-
};
|
|
286
|
-
/**
|
|
287
|
-
* Provides state management for a table component. Handles building a collection
|
|
288
|
-
* of columns and rows from props. In addition, it tracks row selection and manages sort order changes.
|
|
289
|
-
*/
|
|
290
|
-
|
|
291
|
-
export function useTableState(props) {
|
|
292
|
-
let {
|
|
293
|
-
selectionMode = 'none'
|
|
294
|
-
} = props;
|
|
295
|
-
let context = useMemo(() => ({
|
|
296
|
-
showSelectionCheckboxes: props.showSelectionCheckboxes && selectionMode !== 'none',
|
|
297
|
-
selectionMode,
|
|
298
|
-
columns: []
|
|
299
|
-
}), [props.children, props.showSelectionCheckboxes, selectionMode]);
|
|
300
|
-
let collection = useCollection(props, (nodes, prev) => new $d7f61bffc1886b961473c48c52f8fd$export$TableCollection(nodes, prev, context), context);
|
|
301
|
-
let {
|
|
302
|
-
disabledKeys,
|
|
303
|
-
selectionManager
|
|
304
|
-
} = useGridState(_babelRuntimeHelpersEsmExtends({}, props, {
|
|
305
|
-
collection
|
|
306
|
-
}));
|
|
307
|
-
return {
|
|
308
|
-
collection,
|
|
309
|
-
disabledKeys,
|
|
310
|
-
selectionManager,
|
|
311
|
-
showSelectionCheckboxes: props.showSelectionCheckboxes || false,
|
|
312
|
-
sortDescriptor: props.sortDescriptor,
|
|
313
|
-
|
|
314
|
-
sort(columnKey) {
|
|
315
|
-
var _props$sortDescriptor;
|
|
316
|
-
|
|
317
|
-
props.onSortChange({
|
|
318
|
-
column: columnKey,
|
|
319
|
-
direction: ((_props$sortDescriptor = props.sortDescriptor) == null ? void 0 : _props$sortDescriptor.column) === columnKey ? $ed569ec24a699f43593e019ef637b788$var$OPPOSITE_SORT_DIRECTION[props.sortDescriptor.direction] : 'ascending'
|
|
320
|
-
});
|
|
321
|
-
}
|
|
322
|
-
|
|
323
|
-
};
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
function $d2418fd9c90ca8bee81eaa89f5a574$var$TableHeader(props) {
|
|
327
|
-
// eslint-disable-line @typescript-eslint/no-unused-vars
|
|
328
|
-
return null;
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
$d2418fd9c90ca8bee81eaa89f5a574$var$TableHeader.getCollectionNode = function* getCollectionNode(props) {
|
|
332
|
-
let {
|
|
333
|
-
children,
|
|
334
|
-
columns
|
|
335
|
-
} = props;
|
|
336
|
-
|
|
337
|
-
if (typeof children === 'function') {
|
|
338
|
-
if (!columns) {
|
|
339
|
-
throw new Error('props.children was a function but props.columns is missing');
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
for (let column of columns) {
|
|
343
|
-
yield {
|
|
344
|
-
type: 'column',
|
|
345
|
-
value: column,
|
|
346
|
-
renderer: children
|
|
347
|
-
};
|
|
348
|
-
}
|
|
349
|
-
} else {
|
|
350
|
-
let columns = [];
|
|
351
|
-
|
|
352
|
-
_react.Children.forEach(children, column => {
|
|
353
|
-
columns.push({
|
|
354
|
-
type: 'column',
|
|
355
|
-
element: column
|
|
356
|
-
});
|
|
357
|
-
});
|
|
358
|
-
|
|
359
|
-
yield* columns;
|
|
360
|
-
}
|
|
361
|
-
}; // We don't want getCollectionNode to show up in the type definition
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
export let TableHeader = $d2418fd9c90ca8bee81eaa89f5a574$var$TableHeader;
|
|
365
|
-
|
|
366
|
-
function $d42e37bea5d5623bad371e2dcbdc40c5$var$TableBody(props) {
|
|
367
|
-
// eslint-disable-line @typescript-eslint/no-unused-vars
|
|
368
|
-
return null;
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
$d42e37bea5d5623bad371e2dcbdc40c5$var$TableBody.getCollectionNode = function* getCollectionNode(props) {
|
|
372
|
-
let {
|
|
373
|
-
children,
|
|
374
|
-
items
|
|
375
|
-
} = props;
|
|
376
|
-
yield {
|
|
377
|
-
type: 'body',
|
|
378
|
-
hasChildNodes: true,
|
|
379
|
-
props,
|
|
380
|
-
|
|
381
|
-
*childNodes() {
|
|
382
|
-
if (typeof children === 'function') {
|
|
383
|
-
if (!items) {
|
|
384
|
-
throw new Error('props.children was a function but props.items is missing');
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
for (let item of items) {
|
|
388
|
-
yield {
|
|
389
|
-
type: 'item',
|
|
390
|
-
value: item,
|
|
391
|
-
renderer: children
|
|
392
|
-
};
|
|
393
|
-
}
|
|
394
|
-
} else {
|
|
395
|
-
let items = [];
|
|
396
|
-
|
|
397
|
-
_react.Children.forEach(children, item => {
|
|
398
|
-
items.push({
|
|
399
|
-
type: 'item',
|
|
400
|
-
element: item
|
|
401
|
-
});
|
|
402
|
-
});
|
|
403
|
-
|
|
404
|
-
yield* items;
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
};
|
|
409
|
-
}; // We don't want getCollectionNode to show up in the type definition
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
export let TableBody = $d42e37bea5d5623bad371e2dcbdc40c5$var$TableBody;
|
|
413
|
-
|
|
414
|
-
function $fe0a8908dd4d1a483485d151a57a1f$var$Column(props) {
|
|
415
|
-
// eslint-disable-line @typescript-eslint/no-unused-vars
|
|
416
|
-
return null;
|
|
417
|
-
}
|
|
418
|
-
|
|
419
|
-
$fe0a8908dd4d1a483485d151a57a1f$var$Column.getCollectionNode = function* getCollectionNode(props, context) {
|
|
420
|
-
let {
|
|
421
|
-
title,
|
|
422
|
-
children,
|
|
423
|
-
childColumns
|
|
424
|
-
} = props;
|
|
425
|
-
let fullNodes = yield {
|
|
426
|
-
type: 'column',
|
|
427
|
-
hasChildNodes: !!childColumns || title && _react.Children.count(children) > 0,
|
|
428
|
-
rendered: title || children,
|
|
429
|
-
props,
|
|
430
|
-
|
|
431
|
-
*childNodes() {
|
|
432
|
-
if (childColumns) {
|
|
433
|
-
for (let child of childColumns) {
|
|
434
|
-
yield {
|
|
435
|
-
type: 'column',
|
|
436
|
-
value: child
|
|
437
|
-
};
|
|
438
|
-
}
|
|
439
|
-
} else if (title) {
|
|
440
|
-
let childColumns = [];
|
|
441
|
-
|
|
442
|
-
_react.Children.forEach(children, child => {
|
|
443
|
-
childColumns.push({
|
|
444
|
-
type: 'column',
|
|
445
|
-
element: child
|
|
446
|
-
});
|
|
447
|
-
});
|
|
448
|
-
|
|
449
|
-
yield* childColumns;
|
|
450
|
-
}
|
|
451
|
-
},
|
|
452
|
-
|
|
453
|
-
shouldInvalidate(newContext) {
|
|
454
|
-
// This is a bit of a hack, but it works.
|
|
455
|
-
// If this method is called, then there's a cached version of this node available.
|
|
456
|
-
// But, we need to keep the list of columns in the new context up to date.
|
|
457
|
-
updateContext(newContext);
|
|
458
|
-
return false;
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
};
|
|
462
|
-
|
|
463
|
-
let updateContext = context => {
|
|
464
|
-
// register leaf columns on the context so that <Row> can access them
|
|
465
|
-
for (let node of fullNodes) {
|
|
466
|
-
if (!node.hasChildNodes) {
|
|
467
|
-
context.columns.push(node);
|
|
468
|
-
}
|
|
469
|
-
}
|
|
470
|
-
};
|
|
471
|
-
|
|
472
|
-
updateContext(context);
|
|
473
|
-
}; // We don't want getCollectionNode to show up in the type definition
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
export let Column = $fe0a8908dd4d1a483485d151a57a1f$var$Column;
|
|
477
|
-
|
|
478
|
-
function $a7c409b25db03fac671ec6ef75bead$var$Row(props) {
|
|
479
|
-
// eslint-disable-line @typescript-eslint/no-unused-vars
|
|
480
|
-
return null;
|
|
481
|
-
}
|
|
482
|
-
|
|
483
|
-
$a7c409b25db03fac671ec6ef75bead$var$Row.getCollectionNode = function* getCollectionNode(props, context) {
|
|
484
|
-
let {
|
|
485
|
-
children,
|
|
486
|
-
textValue
|
|
487
|
-
} = props;
|
|
488
|
-
yield {
|
|
489
|
-
type: 'item',
|
|
490
|
-
props: props,
|
|
491
|
-
textValue,
|
|
492
|
-
'aria-label': props['aria-label'],
|
|
493
|
-
hasChildNodes: true,
|
|
494
|
-
|
|
495
|
-
*childNodes() {
|
|
496
|
-
// Process cells first
|
|
497
|
-
if (context.showSelectionCheckboxes && context.selectionMode !== 'none') {
|
|
498
|
-
yield {
|
|
499
|
-
type: 'cell',
|
|
500
|
-
key: 'header',
|
|
501
|
-
// this is combined with the row key by CollectionBuilder
|
|
502
|
-
props: {
|
|
503
|
-
isSelectionCell: true
|
|
504
|
-
}
|
|
505
|
-
};
|
|
506
|
-
}
|
|
507
|
-
|
|
508
|
-
if (typeof children === 'function') {
|
|
509
|
-
for (let column of context.columns) {
|
|
510
|
-
yield {
|
|
511
|
-
type: 'cell',
|
|
512
|
-
element: children(column.key),
|
|
513
|
-
key: column.key // this is combined with the row key by CollectionBuilder
|
|
514
|
-
|
|
515
|
-
};
|
|
516
|
-
}
|
|
517
|
-
} else {
|
|
518
|
-
let cells = [];
|
|
519
|
-
|
|
520
|
-
_react.Children.forEach(children, cell => {
|
|
521
|
-
cells.push({
|
|
522
|
-
type: 'cell',
|
|
523
|
-
element: cell
|
|
524
|
-
});
|
|
525
|
-
});
|
|
526
|
-
|
|
527
|
-
if (cells.length !== context.columns.length) {
|
|
528
|
-
throw new Error("Cell count must match column count. Found " + cells.length + " cells and " + context.columns.length + " columns.");
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
yield* cells;
|
|
532
|
-
}
|
|
533
|
-
},
|
|
534
|
-
|
|
535
|
-
shouldInvalidate(newContext) {
|
|
536
|
-
// Invalidate all rows if the columns changed.
|
|
537
|
-
return newContext.columns.length !== context.columns.length || newContext.columns.some((c, i) => c.key !== context.columns[i].key) || newContext.showSelectionCheckboxes !== context.showSelectionCheckboxes || newContext.selectionMode !== context.selectionMode;
|
|
538
|
-
}
|
|
539
|
-
|
|
540
|
-
};
|
|
541
|
-
}; // We don't want getCollectionNode to show up in the type definition
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
export let Row = $a7c409b25db03fac671ec6ef75bead$var$Row;
|
|
1
|
+
import {useTableColumnResizeState as $292bc4e09cd0eb62$export$cb895dcf85db1319} from "./useTableColumnResizeState.module.js";
|
|
2
|
+
import {useTableState as $4a0dd036d492cee4$export$907bcc6c48325fd6} from "./useTableState.module.js";
|
|
3
|
+
import {TableHeader as $312ae3b56a94a86e$export$f850895b287ef28e} from "./TableHeader.module.js";
|
|
4
|
+
import {TableBody as $4ae5314bf50db1a3$export$76ccd210b9029917} from "./TableBody.module.js";
|
|
5
|
+
import {Column as $1cd244557c2f97d5$export$816b5d811295e6bc} from "./Column.module.js";
|
|
6
|
+
import {Row as $70d70eb16ea48428$export$b59bdbef9ce70de2} from "./Row.module.js";
|
|
7
|
+
import {Cell as $941d1d9a6a28982a$export$f6f0c3fe4ec306ea} from "./Cell.module.js";
|
|
8
|
+
import {buildHeaderRows as $788781baa30117fa$export$7c127db850d4e81e, TableCollection as $788781baa30117fa$export$596e1b2e2cf93690} from "./TableCollection.module.js";
|
|
9
|
+
import {TableColumnLayout as $a9e7ae544a4e41dd$export$7ff77a162970b30e} from "./TableColumnLayout.module.js";
|
|
10
|
+
import {UNSTABLE_useTreeGridState as $ee65a0057fd99531$export$34dfa8a1622185a4} from "./useTreeGridState.module.js";
|
|
11
|
+
import {Section as $6555104ff085bef4$re_export$Section} from "@react-stately/collections";
|
|
545
12
|
|
|
546
13
|
/*
|
|
547
14
|
* Copyright 2020 Adobe. All rights reserved.
|
|
@@ -553,27 +20,18 @@ export let Row = $a7c409b25db03fac671ec6ef75bead$var$Row;
|
|
|
553
20
|
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
554
21
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
555
22
|
* governing permissions and limitations under the License.
|
|
556
|
-
*/
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
561
33
|
|
|
562
|
-
$e2fd505f0e5b23b70534674763d176d$var$Cell.getCollectionNode = function* getCollectionNode(props) {
|
|
563
|
-
let {
|
|
564
|
-
children
|
|
565
|
-
} = props;
|
|
566
|
-
let textValue = props.textValue || (typeof children === 'string' ? children : '') || props['aria-label'] || '';
|
|
567
|
-
yield {
|
|
568
|
-
type: 'cell',
|
|
569
|
-
props: props,
|
|
570
|
-
rendered: children,
|
|
571
|
-
textValue,
|
|
572
|
-
'aria-label': props['aria-label'],
|
|
573
|
-
hasChildNodes: false
|
|
574
|
-
};
|
|
575
|
-
}; // We don't want getCollectionNode to show up in the type definition
|
|
576
34
|
|
|
577
35
|
|
|
578
|
-
export
|
|
36
|
+
export {$292bc4e09cd0eb62$export$cb895dcf85db1319 as useTableColumnResizeState, $4a0dd036d492cee4$export$907bcc6c48325fd6 as useTableState, $312ae3b56a94a86e$export$f850895b287ef28e as TableHeader, $4ae5314bf50db1a3$export$76ccd210b9029917 as TableBody, $1cd244557c2f97d5$export$816b5d811295e6bc as Column, $70d70eb16ea48428$export$b59bdbef9ce70de2 as Row, $941d1d9a6a28982a$export$f6f0c3fe4ec306ea as Cell, $6555104ff085bef4$re_export$Section as Section, $788781baa30117fa$export$596e1b2e2cf93690 as TableCollection, $788781baa30117fa$export$7c127db850d4e81e as buildHeaderRows, $a9e7ae544a4e41dd$export$7ff77a162970b30e as TableColumnLayout, $ee65a0057fd99531$export$34dfa8a1622185a4 as UNSTABLE_useTreeGridState};
|
|
579
37
|
//# sourceMappingURL=module.js.map
|