@react-stately/layout 3.13.10-nightly.4704 → 3.13.10-nightly.4718
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/ListLayout.main.js +20 -4
- package/dist/ListLayout.main.js.map +1 -1
- package/dist/ListLayout.mjs +20 -4
- package/dist/ListLayout.module.js +20 -4
- package/dist/ListLayout.module.js.map +1 -1
- package/dist/TableLayout.main.js +17 -7
- package/dist/TableLayout.main.js.map +1 -1
- package/dist/TableLayout.mjs +17 -7
- package/dist/TableLayout.module.js +17 -7
- package/dist/TableLayout.module.js.map +1 -1
- package/dist/types.d.ts +6 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/ListLayout.ts +27 -4
- package/src/TableLayout.ts +19 -7
package/src/ListLayout.ts
CHANGED
|
@@ -23,6 +23,10 @@ export interface ListLayoutOptions {
|
|
|
23
23
|
headingHeight?: number,
|
|
24
24
|
/** The estimated height of a section header, when the height is variable. */
|
|
25
25
|
estimatedHeadingHeight?: number,
|
|
26
|
+
/** The fixed height of a loader element in px. This loader is specifically for
|
|
27
|
+
* "load more" elements rendered when loading more rows at the root level or inside nested row/sections.
|
|
28
|
+
*/
|
|
29
|
+
loaderHeight?: number,
|
|
26
30
|
/** The thickness of the drop indicator. */
|
|
27
31
|
dropIndicatorThickness?: number
|
|
28
32
|
}
|
|
@@ -51,6 +55,7 @@ export class ListLayout<T, O = any> extends Layout<Node<T>, O> implements DropTa
|
|
|
51
55
|
protected estimatedRowHeight: number;
|
|
52
56
|
protected headingHeight: number;
|
|
53
57
|
protected estimatedHeadingHeight: number;
|
|
58
|
+
protected loaderHeight: number;
|
|
54
59
|
protected dropIndicatorThickness: number;
|
|
55
60
|
protected layoutNodes: Map<Key, LayoutNode>;
|
|
56
61
|
protected contentSize: Size;
|
|
@@ -74,6 +79,7 @@ export class ListLayout<T, O = any> extends Layout<Node<T>, O> implements DropTa
|
|
|
74
79
|
this.estimatedRowHeight = options.estimatedRowHeight;
|
|
75
80
|
this.headingHeight = options.headingHeight;
|
|
76
81
|
this.estimatedHeadingHeight = options.estimatedHeadingHeight;
|
|
82
|
+
this.loaderHeight = options.loaderHeight;
|
|
77
83
|
this.dropIndicatorThickness = options.dropIndicatorThickness || 2;
|
|
78
84
|
this.layoutNodes = new Map();
|
|
79
85
|
this.rootNodes = [];
|
|
@@ -238,7 +244,6 @@ export class ListLayout<T, O = any> extends Layout<Node<T>, O> implements DropTa
|
|
|
238
244
|
}
|
|
239
245
|
|
|
240
246
|
let layoutNode = this.buildNode(node, x, y);
|
|
241
|
-
layoutNode.node = node;
|
|
242
247
|
|
|
243
248
|
layoutNode.layoutInfo.parentKey = parentKey ?? null;
|
|
244
249
|
this.layoutNodes.set(node.key, layoutNode);
|
|
@@ -253,9 +258,23 @@ export class ListLayout<T, O = any> extends Layout<Node<T>, O> implements DropTa
|
|
|
253
258
|
return this.buildItem(node, x, y);
|
|
254
259
|
case 'header':
|
|
255
260
|
return this.buildSectionHeader(node, x, y);
|
|
261
|
+
case 'loader':
|
|
262
|
+
return this.buildLoader(node, x, y);
|
|
256
263
|
}
|
|
257
264
|
}
|
|
258
265
|
|
|
266
|
+
protected buildLoader(node: Node<T>, x: number, y: number): LayoutNode {
|
|
267
|
+
let rect = new Rect(x, y, 0, 0);
|
|
268
|
+
let layoutInfo = new LayoutInfo('loader', node.key, rect);
|
|
269
|
+
rect.width = this.virtualizer.contentSize.width;
|
|
270
|
+
rect.height = this.loaderHeight || this.rowHeight || this.estimatedRowHeight;
|
|
271
|
+
|
|
272
|
+
return {
|
|
273
|
+
layoutInfo,
|
|
274
|
+
validRect: rect.intersection(this.requestedRect)
|
|
275
|
+
};
|
|
276
|
+
}
|
|
277
|
+
|
|
259
278
|
protected buildSection(node: Node<T>, x: number, y: number): LayoutNode {
|
|
260
279
|
let width = this.virtualizer.visibleRect.width;
|
|
261
280
|
let rect = new Rect(0, y, width, 0);
|
|
@@ -290,7 +309,8 @@ export class ListLayout<T, O = any> extends Layout<Node<T>, O> implements DropTa
|
|
|
290
309
|
return {
|
|
291
310
|
layoutInfo,
|
|
292
311
|
children,
|
|
293
|
-
validRect: layoutInfo.rect.intersection(this.requestedRect)
|
|
312
|
+
validRect: layoutInfo.rect.intersection(this.requestedRect),
|
|
313
|
+
node
|
|
294
314
|
};
|
|
295
315
|
}
|
|
296
316
|
|
|
@@ -327,7 +347,8 @@ export class ListLayout<T, O = any> extends Layout<Node<T>, O> implements DropTa
|
|
|
327
347
|
return {
|
|
328
348
|
layoutInfo: header,
|
|
329
349
|
children: [],
|
|
330
|
-
validRect: header.rect.intersection(this.requestedRect)
|
|
350
|
+
validRect: header.rect.intersection(this.requestedRect),
|
|
351
|
+
node
|
|
331
352
|
};
|
|
332
353
|
}
|
|
333
354
|
|
|
@@ -360,7 +381,9 @@ export class ListLayout<T, O = any> extends Layout<Node<T>, O> implements DropTa
|
|
|
360
381
|
layoutInfo.estimatedSize = isEstimated;
|
|
361
382
|
return {
|
|
362
383
|
layoutInfo,
|
|
363
|
-
|
|
384
|
+
children: [],
|
|
385
|
+
validRect: layoutInfo.rect,
|
|
386
|
+
node
|
|
364
387
|
};
|
|
365
388
|
}
|
|
366
389
|
|
package/src/TableLayout.ts
CHANGED
|
@@ -35,7 +35,7 @@ export class TableLayout<T, O extends TableLayoutProps = TableLayoutProps> exten
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
private columnsChanged(newCollection: TableCollection<T>, oldCollection: TableCollection<T> | null) {
|
|
38
|
-
return !oldCollection ||
|
|
38
|
+
return !oldCollection ||
|
|
39
39
|
newCollection.columns !== oldCollection.columns &&
|
|
40
40
|
newCollection.columns.length !== oldCollection.columns.length ||
|
|
41
41
|
newCollection.columns.some((c, i) =>
|
|
@@ -113,7 +113,8 @@ export class TableLayout<T, O extends TableLayoutProps = TableLayoutProps> exten
|
|
|
113
113
|
return {
|
|
114
114
|
layoutInfo,
|
|
115
115
|
children,
|
|
116
|
-
validRect: layoutInfo.rect
|
|
116
|
+
validRect: layoutInfo.rect,
|
|
117
|
+
node: this.collection.head
|
|
117
118
|
};
|
|
118
119
|
}
|
|
119
120
|
|
|
@@ -143,7 +144,8 @@ export class TableLayout<T, O extends TableLayoutProps = TableLayoutProps> exten
|
|
|
143
144
|
return {
|
|
144
145
|
layoutInfo: row,
|
|
145
146
|
children: columns,
|
|
146
|
-
validRect: rect
|
|
147
|
+
validRect: rect,
|
|
148
|
+
node: headerRow
|
|
147
149
|
};
|
|
148
150
|
}
|
|
149
151
|
|
|
@@ -208,7 +210,9 @@ export class TableLayout<T, O extends TableLayoutProps = TableLayoutProps> exten
|
|
|
208
210
|
|
|
209
211
|
return {
|
|
210
212
|
layoutInfo,
|
|
211
|
-
|
|
213
|
+
children: [],
|
|
214
|
+
validRect: layoutInfo.rect,
|
|
215
|
+
node
|
|
212
216
|
};
|
|
213
217
|
}
|
|
214
218
|
|
|
@@ -259,7 +263,8 @@ export class TableLayout<T, O extends TableLayoutProps = TableLayoutProps> exten
|
|
|
259
263
|
return {
|
|
260
264
|
layoutInfo,
|
|
261
265
|
children,
|
|
262
|
-
validRect: layoutInfo.rect.intersection(this.requestedRect)
|
|
266
|
+
validRect: layoutInfo.rect.intersection(this.requestedRect),
|
|
267
|
+
node: this.collection.body
|
|
263
268
|
};
|
|
264
269
|
}
|
|
265
270
|
|
|
@@ -274,6 +279,8 @@ export class TableLayout<T, O extends TableLayoutProps = TableLayoutProps> exten
|
|
|
274
279
|
return this.buildColumn(node, x, y);
|
|
275
280
|
case 'cell':
|
|
276
281
|
return this.buildCell(node, x, y);
|
|
282
|
+
case 'loader':
|
|
283
|
+
return this.buildLoader(node, x, y);
|
|
277
284
|
default:
|
|
278
285
|
throw new Error('Unknown node type ' + node.type);
|
|
279
286
|
}
|
|
@@ -294,6 +301,8 @@ export class TableLayout<T, O extends TableLayoutProps = TableLayoutProps> exten
|
|
|
294
301
|
if (layoutNode) {
|
|
295
302
|
layoutNode.layoutInfo.rect.x = x;
|
|
296
303
|
x += layoutNode.layoutInfo.rect.width;
|
|
304
|
+
} else {
|
|
305
|
+
break;
|
|
297
306
|
}
|
|
298
307
|
} else {
|
|
299
308
|
let layoutNode = this.buildChild(child, x, y, layoutInfo.key);
|
|
@@ -313,7 +322,8 @@ export class TableLayout<T, O extends TableLayoutProps = TableLayoutProps> exten
|
|
|
313
322
|
return {
|
|
314
323
|
layoutInfo,
|
|
315
324
|
children,
|
|
316
|
-
validRect: rect.intersection(this.requestedRect)
|
|
325
|
+
validRect: rect.intersection(this.requestedRect),
|
|
326
|
+
node
|
|
317
327
|
};
|
|
318
328
|
}
|
|
319
329
|
|
|
@@ -328,7 +338,9 @@ export class TableLayout<T, O extends TableLayoutProps = TableLayoutProps> exten
|
|
|
328
338
|
|
|
329
339
|
return {
|
|
330
340
|
layoutInfo,
|
|
331
|
-
|
|
341
|
+
children: [],
|
|
342
|
+
validRect: rect,
|
|
343
|
+
node
|
|
332
344
|
};
|
|
333
345
|
}
|
|
334
346
|
|