@react-stately/table 3.0.0-beta.1 → 3.0.0-nightly-4980928d3-240906
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 -619
- package/dist/main.js.map +1 -1
- package/dist/module.js +22 -590
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +142 -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 +1 -1
- package/src/Column.ts +7 -2
- package/src/Row.ts +45 -10
- package/src/TableBody.ts +1 -1
- package/src/TableCollection.ts +99 -15
- package/src/TableColumnLayout.ts +127 -0
- package/src/TableHeader.ts +7 -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,569 +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
|
-
};
|
|
362
|
-
/**
|
|
363
|
-
* A TableHeader is a container for the Column elements in a Table. Columns can be statically defined
|
|
364
|
-
* as children, or generated dynamically using a function based on the data passed to the `columns` prop.
|
|
365
|
-
*/
|
|
366
|
-
// We don't want getCollectionNode to show up in the type definition
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
export let TableHeader = $d2418fd9c90ca8bee81eaa89f5a574$var$TableHeader;
|
|
370
|
-
|
|
371
|
-
function $d42e37bea5d5623bad371e2dcbdc40c5$var$TableBody(props) {
|
|
372
|
-
// eslint-disable-line @typescript-eslint/no-unused-vars
|
|
373
|
-
return null;
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
$d42e37bea5d5623bad371e2dcbdc40c5$var$TableBody.getCollectionNode = function* getCollectionNode(props) {
|
|
377
|
-
let {
|
|
378
|
-
children,
|
|
379
|
-
items
|
|
380
|
-
} = props;
|
|
381
|
-
yield {
|
|
382
|
-
type: 'body',
|
|
383
|
-
hasChildNodes: true,
|
|
384
|
-
props,
|
|
385
|
-
|
|
386
|
-
*childNodes() {
|
|
387
|
-
if (typeof children === 'function') {
|
|
388
|
-
if (!items) {
|
|
389
|
-
throw new Error('props.children was a function but props.items is missing');
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
for (let item of items) {
|
|
393
|
-
yield {
|
|
394
|
-
type: 'item',
|
|
395
|
-
value: item,
|
|
396
|
-
renderer: children
|
|
397
|
-
};
|
|
398
|
-
}
|
|
399
|
-
} else {
|
|
400
|
-
let items = [];
|
|
401
|
-
|
|
402
|
-
_react.Children.forEach(children, item => {
|
|
403
|
-
items.push({
|
|
404
|
-
type: 'item',
|
|
405
|
-
element: item
|
|
406
|
-
});
|
|
407
|
-
});
|
|
408
|
-
|
|
409
|
-
yield* items;
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
|
|
413
|
-
};
|
|
414
|
-
};
|
|
415
|
-
/**
|
|
416
|
-
* A TableBody is a container for the Row elements of a Table. Rows can be statically defined
|
|
417
|
-
* as children, or generated dynamically using a function based on the data passed to the `items` prop.
|
|
418
|
-
*/
|
|
419
|
-
// We don't want getCollectionNode to show up in the type definition
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
export let TableBody = $d42e37bea5d5623bad371e2dcbdc40c5$var$TableBody;
|
|
423
|
-
|
|
424
|
-
function $fe0a8908dd4d1a483485d151a57a1f$var$Column(props) {
|
|
425
|
-
// eslint-disable-line @typescript-eslint/no-unused-vars
|
|
426
|
-
return null;
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
$fe0a8908dd4d1a483485d151a57a1f$var$Column.getCollectionNode = function* getCollectionNode(props, context) {
|
|
430
|
-
let {
|
|
431
|
-
title,
|
|
432
|
-
children,
|
|
433
|
-
childColumns
|
|
434
|
-
} = props;
|
|
435
|
-
let fullNodes = yield {
|
|
436
|
-
type: 'column',
|
|
437
|
-
hasChildNodes: !!childColumns || title && _react.Children.count(children) > 0,
|
|
438
|
-
rendered: title || children,
|
|
439
|
-
props,
|
|
440
|
-
|
|
441
|
-
*childNodes() {
|
|
442
|
-
if (childColumns) {
|
|
443
|
-
for (let child of childColumns) {
|
|
444
|
-
yield {
|
|
445
|
-
type: 'column',
|
|
446
|
-
value: child
|
|
447
|
-
};
|
|
448
|
-
}
|
|
449
|
-
} else if (title) {
|
|
450
|
-
let childColumns = [];
|
|
451
|
-
|
|
452
|
-
_react.Children.forEach(children, child => {
|
|
453
|
-
childColumns.push({
|
|
454
|
-
type: 'column',
|
|
455
|
-
element: child
|
|
456
|
-
});
|
|
457
|
-
});
|
|
458
|
-
|
|
459
|
-
yield* childColumns;
|
|
460
|
-
}
|
|
461
|
-
},
|
|
462
|
-
|
|
463
|
-
shouldInvalidate(newContext) {
|
|
464
|
-
// This is a bit of a hack, but it works.
|
|
465
|
-
// If this method is called, then there's a cached version of this node available.
|
|
466
|
-
// But, we need to keep the list of columns in the new context up to date.
|
|
467
|
-
updateContext(newContext);
|
|
468
|
-
return false;
|
|
469
|
-
}
|
|
470
|
-
|
|
471
|
-
};
|
|
472
|
-
|
|
473
|
-
let updateContext = context => {
|
|
474
|
-
// register leaf columns on the context so that <Row> can access them
|
|
475
|
-
for (let node of fullNodes) {
|
|
476
|
-
if (!node.hasChildNodes) {
|
|
477
|
-
context.columns.push(node);
|
|
478
|
-
}
|
|
479
|
-
}
|
|
480
|
-
};
|
|
481
|
-
|
|
482
|
-
updateContext(context);
|
|
483
|
-
};
|
|
484
|
-
/**
|
|
485
|
-
* A Column represents a field of each item within a Table. Columns may also contain nested
|
|
486
|
-
* Column elements to represent column groups. Nested columns can be statically defined as
|
|
487
|
-
* children, or dynamically generated using a function based on the `childColumns` prop.
|
|
488
|
-
*/
|
|
489
|
-
// We don't want getCollectionNode to show up in the type definition
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
export let Column = $fe0a8908dd4d1a483485d151a57a1f$var$Column;
|
|
493
|
-
|
|
494
|
-
function $a7c409b25db03fac671ec6ef75bead$var$Row(props) {
|
|
495
|
-
// eslint-disable-line @typescript-eslint/no-unused-vars
|
|
496
|
-
return null;
|
|
497
|
-
}
|
|
498
|
-
|
|
499
|
-
$a7c409b25db03fac671ec6ef75bead$var$Row.getCollectionNode = function* getCollectionNode(props, context) {
|
|
500
|
-
let {
|
|
501
|
-
children,
|
|
502
|
-
textValue
|
|
503
|
-
} = props;
|
|
504
|
-
yield {
|
|
505
|
-
type: 'item',
|
|
506
|
-
props: props,
|
|
507
|
-
textValue,
|
|
508
|
-
'aria-label': props['aria-label'],
|
|
509
|
-
hasChildNodes: true,
|
|
510
|
-
|
|
511
|
-
*childNodes() {
|
|
512
|
-
// Process cells first
|
|
513
|
-
if (context.showSelectionCheckboxes && context.selectionMode !== 'none') {
|
|
514
|
-
yield {
|
|
515
|
-
type: 'cell',
|
|
516
|
-
key: 'header',
|
|
517
|
-
// this is combined with the row key by CollectionBuilder
|
|
518
|
-
props: {
|
|
519
|
-
isSelectionCell: true
|
|
520
|
-
}
|
|
521
|
-
};
|
|
522
|
-
}
|
|
523
|
-
|
|
524
|
-
if (typeof children === 'function') {
|
|
525
|
-
for (let column of context.columns) {
|
|
526
|
-
yield {
|
|
527
|
-
type: 'cell',
|
|
528
|
-
element: children(column.key),
|
|
529
|
-
key: column.key // this is combined with the row key by CollectionBuilder
|
|
530
|
-
|
|
531
|
-
};
|
|
532
|
-
}
|
|
533
|
-
} else {
|
|
534
|
-
let cells = [];
|
|
535
|
-
|
|
536
|
-
_react.Children.forEach(children, cell => {
|
|
537
|
-
cells.push({
|
|
538
|
-
type: 'cell',
|
|
539
|
-
element: cell
|
|
540
|
-
});
|
|
541
|
-
});
|
|
542
|
-
|
|
543
|
-
if (cells.length !== context.columns.length) {
|
|
544
|
-
throw new Error("Cell count must match column count. Found " + cells.length + " cells and " + context.columns.length + " columns.");
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
yield* cells;
|
|
548
|
-
}
|
|
549
|
-
},
|
|
550
|
-
|
|
551
|
-
shouldInvalidate(newContext) {
|
|
552
|
-
// Invalidate all rows if the columns changed.
|
|
553
|
-
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;
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
};
|
|
557
|
-
};
|
|
558
|
-
/**
|
|
559
|
-
* A Row represents a single item in a Table and contains Cell elements for each column.
|
|
560
|
-
* Cells can be statically defined as children, or generated dynamically using a function
|
|
561
|
-
* based on the columns defined in the TableHeader.
|
|
562
|
-
*/
|
|
563
|
-
// We don't want getCollectionNode to show up in the type definition
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
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";
|
|
567
12
|
|
|
568
13
|
/*
|
|
569
14
|
* Copyright 2020 Adobe. All rights reserved.
|
|
@@ -575,31 +20,18 @@ export let Row = $a7c409b25db03fac671ec6ef75bead$var$Row;
|
|
|
575
20
|
* the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
|
|
576
21
|
* OF ANY KIND, either express or implied. See the License for the specific language
|
|
577
22
|
* governing permissions and limitations under the License.
|
|
578
|
-
*/
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
23
|
+
*/
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
583
33
|
|
|
584
|
-
$e2fd505f0e5b23b70534674763d176d$var$Cell.getCollectionNode = function* getCollectionNode(props) {
|
|
585
|
-
let {
|
|
586
|
-
children
|
|
587
|
-
} = props;
|
|
588
|
-
let textValue = props.textValue || (typeof children === 'string' ? children : '') || props['aria-label'] || '';
|
|
589
|
-
yield {
|
|
590
|
-
type: 'cell',
|
|
591
|
-
props: props,
|
|
592
|
-
rendered: children,
|
|
593
|
-
textValue,
|
|
594
|
-
'aria-label': props['aria-label'],
|
|
595
|
-
hasChildNodes: false
|
|
596
|
-
};
|
|
597
|
-
};
|
|
598
|
-
/**
|
|
599
|
-
* A Cell represents the value of a single Column within a Table Row.
|
|
600
|
-
*/
|
|
601
|
-
// We don't want getCollectionNode to show up in the type definition
|
|
602
34
|
|
|
603
35
|
|
|
604
|
-
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};
|
|
605
37
|
//# sourceMappingURL=module.js.map
|