@react-stately/layout 3.13.10-nightly.4674 → 3.13.10-nightly.4683
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 +33 -108
- package/dist/ListLayout.main.js.map +1 -1
- package/dist/ListLayout.mjs +33 -108
- package/dist/ListLayout.module.js +33 -108
- package/dist/ListLayout.module.js.map +1 -1
- package/dist/TableLayout.main.js +63 -99
- package/dist/TableLayout.main.js.map +1 -1
- package/dist/TableLayout.mjs +63 -99
- package/dist/TableLayout.module.js +63 -99
- package/dist/TableLayout.module.js.map +1 -1
- package/dist/main.js.map +1 -1
- package/dist/module.js.map +1 -1
- package/dist/types.d.ts +30 -70
- package/dist/types.d.ts.map +1 -1
- package/package.json +9 -9
- package/src/ListLayout.ts +59 -166
- package/src/TableLayout.ts +86 -130
- package/src/index.ts +2 -1
package/dist/ListLayout.mjs
CHANGED
|
@@ -44,9 +44,8 @@ class $61ef60fc9b1041f4$export$cacbb3924155d68e extends (0, $img26$Layout) {
|
|
|
44
44
|
}
|
|
45
45
|
layoutIfNeeded(rect) {
|
|
46
46
|
if (!this.lastCollection) return;
|
|
47
|
-
if (!this.
|
|
48
|
-
this.
|
|
49
|
-
this.validRect = this.validRect.union(rect);
|
|
47
|
+
if (!this.requestedRect.containsRect(rect)) {
|
|
48
|
+
this.requestedRect = this.requestedRect.union(rect);
|
|
50
49
|
this.rootNodes = this.buildCollection();
|
|
51
50
|
} else // Ensure all of the persisted keys are available.
|
|
52
51
|
for (let key of this.virtualizer.persistedKeys){
|
|
@@ -57,11 +56,10 @@ class $61ef60fc9b1041f4$export$cacbb3924155d68e extends (0, $img26$Layout) {
|
|
|
57
56
|
// If the layout info wasn't found, it might be outside the bounds of the area that we've
|
|
58
57
|
// computed layout for so far. This can happen when accessing a random key, e.g pressing Home/End.
|
|
59
58
|
// Compute the full layout and try again.
|
|
60
|
-
if (!this.layoutInfos.has(key) && this.
|
|
61
|
-
this.
|
|
62
|
-
this.validRect = new (0, $img26$Rect)(0, 0, Infinity, Infinity);
|
|
59
|
+
if (!this.layoutInfos.has(key) && this.requestedRect.area < this.contentSize.area && this.lastCollection) {
|
|
60
|
+
this.requestedRect = new (0, $img26$Rect)(0, 0, Infinity, Infinity);
|
|
63
61
|
this.rootNodes = this.buildCollection();
|
|
64
|
-
this.
|
|
62
|
+
this.requestedRect = new (0, $img26$Rect)(0, 0, this.contentSize.width, this.contentSize.height);
|
|
65
63
|
return true;
|
|
66
64
|
}
|
|
67
65
|
return false;
|
|
@@ -81,10 +79,7 @@ class $61ef60fc9b1041f4$export$cacbb3924155d68e extends (0, $img26$Layout) {
|
|
|
81
79
|
// Reset valid rect if we will have to invalidate everything.
|
|
82
80
|
// Otherwise we can reuse cached layout infos outside the current visible rect.
|
|
83
81
|
this.invalidateEverything = this.shouldInvalidateEverything(invalidationContext);
|
|
84
|
-
if (this.invalidateEverything)
|
|
85
|
-
this.lastValidRect = this.validRect;
|
|
86
|
-
this.validRect = this.virtualizer.visibleRect.copy();
|
|
87
|
-
}
|
|
82
|
+
if (this.invalidateEverything) this.requestedRect = this.virtualizer.visibleRect.copy();
|
|
88
83
|
this.rootNodes = this.buildCollection();
|
|
89
84
|
// Remove deleted layout nodes
|
|
90
85
|
if (this.lastCollection && this.collection !== this.lastCollection) {
|
|
@@ -101,6 +96,7 @@ class $61ef60fc9b1041f4$export$cacbb3924155d68e extends (0, $img26$Layout) {
|
|
|
101
96
|
this.lastWidth = this.virtualizer.visibleRect.width;
|
|
102
97
|
this.lastCollection = this.collection;
|
|
103
98
|
this.invalidateEverything = false;
|
|
99
|
+
this.validRect = this.requestedRect.copy();
|
|
104
100
|
}
|
|
105
101
|
buildCollection() {
|
|
106
102
|
let y = this.padding;
|
|
@@ -110,15 +106,15 @@ class $61ef60fc9b1041f4$export$cacbb3924155d68e extends (0, $img26$Layout) {
|
|
|
110
106
|
var _this_rowHeight;
|
|
111
107
|
let rowHeight = (_this_rowHeight = this.rowHeight) !== null && _this_rowHeight !== void 0 ? _this_rowHeight : this.estimatedRowHeight;
|
|
112
108
|
// Skip rows before the valid rectangle unless they are already cached.
|
|
113
|
-
if (node.type === 'item' && y + rowHeight < this.
|
|
109
|
+
if (node.type === 'item' && y + rowHeight < this.requestedRect.y && !this.isValid(node, y)) {
|
|
114
110
|
y += rowHeight;
|
|
115
111
|
skipped++;
|
|
116
112
|
continue;
|
|
117
113
|
}
|
|
118
|
-
let layoutNode = this.buildChild(node, 0, y);
|
|
114
|
+
let layoutNode = this.buildChild(node, 0, y, null);
|
|
119
115
|
y = layoutNode.layoutInfo.rect.maxY;
|
|
120
116
|
nodes.push(layoutNode);
|
|
121
|
-
if (node.type === 'item' && y > this.
|
|
117
|
+
if (node.type === 'item' && y > this.requestedRect.maxY) {
|
|
122
118
|
y += (this.collection.size - (nodes.length + skipped)) * rowHeight;
|
|
123
119
|
break;
|
|
124
120
|
}
|
|
@@ -133,7 +129,7 @@ class $61ef60fc9b1041f4$export$cacbb3924155d68e extends (0, $img26$Layout) {
|
|
|
133
129
|
});
|
|
134
130
|
y = loader.rect.maxY;
|
|
135
131
|
}
|
|
136
|
-
if (nodes.length === 0) {
|
|
132
|
+
if (nodes.length === 0 && this.enableEmptyState) {
|
|
137
133
|
var _this_placeholderHeight;
|
|
138
134
|
let rect = new (0, $img26$Rect)(0, y, this.virtualizer.visibleRect.width, (_this_placeholderHeight = this.placeholderHeight) !== null && _this_placeholderHeight !== void 0 ? _this_placeholderHeight : this.virtualizer.visibleRect.height);
|
|
139
135
|
let placeholder = new (0, $img26$LayoutInfo)('placeholder', 'placeholder', rect);
|
|
@@ -148,14 +144,13 @@ class $61ef60fc9b1041f4$export$cacbb3924155d68e extends (0, $img26$Layout) {
|
|
|
148
144
|
}
|
|
149
145
|
isValid(node, y) {
|
|
150
146
|
let cached = this.layoutNodes.get(node.key);
|
|
151
|
-
return !this.invalidateEverything && cached && cached.node === node && y === (cached.header || cached.layoutInfo).rect.y && cached.layoutInfo.rect.intersects(this.
|
|
147
|
+
return !this.invalidateEverything && cached && cached.node === node && y === (cached.header || cached.layoutInfo).rect.y && cached.layoutInfo.rect.intersects(this.validRect) && cached.validRect.containsRect(cached.layoutInfo.rect.intersection(this.requestedRect));
|
|
152
148
|
}
|
|
153
|
-
buildChild(node, x, y) {
|
|
149
|
+
buildChild(node, x, y, parentKey) {
|
|
154
150
|
if (this.isValid(node, y)) return this.layoutNodes.get(node.key);
|
|
155
151
|
let layoutNode = this.buildNode(node, x, y);
|
|
156
152
|
layoutNode.node = node;
|
|
157
|
-
|
|
158
|
-
layoutNode.layoutInfo.parentKey = (_node_parentKey = node.parentKey) !== null && _node_parentKey !== void 0 ? _node_parentKey : null;
|
|
153
|
+
layoutNode.layoutInfo.parentKey = parentKey !== null && parentKey !== void 0 ? parentKey : null;
|
|
159
154
|
this.layoutInfos.set(layoutNode.layoutInfo.key, layoutNode.layoutInfo);
|
|
160
155
|
if (layoutNode.header) this.layoutInfos.set(layoutNode.header.key, layoutNode.header);
|
|
161
156
|
this.layoutNodes.set(node.key, layoutNode);
|
|
@@ -168,14 +163,14 @@ class $61ef60fc9b1041f4$export$cacbb3924155d68e extends (0, $img26$Layout) {
|
|
|
168
163
|
case 'item':
|
|
169
164
|
return this.buildItem(node, x, y);
|
|
170
165
|
case 'header':
|
|
171
|
-
return this.
|
|
166
|
+
return this.buildSectionHeader(node, x, y);
|
|
172
167
|
}
|
|
173
168
|
}
|
|
174
169
|
buildSection(node, x, y) {
|
|
175
170
|
let width = this.virtualizer.visibleRect.width;
|
|
176
171
|
let header = null;
|
|
177
172
|
if (node.rendered || this.forceSectionHeaders) {
|
|
178
|
-
let headerNode = this.
|
|
173
|
+
let headerNode = this.buildSectionHeader(node, x, y);
|
|
179
174
|
header = headerNode.layoutInfo;
|
|
180
175
|
header.key += ':header';
|
|
181
176
|
header.parentKey = node.key;
|
|
@@ -190,15 +185,15 @@ class $61ef60fc9b1041f4$export$cacbb3924155d68e extends (0, $img26$Layout) {
|
|
|
190
185
|
var _this_rowHeight;
|
|
191
186
|
let rowHeight = (_this_rowHeight = this.rowHeight) !== null && _this_rowHeight !== void 0 ? _this_rowHeight : this.estimatedRowHeight;
|
|
192
187
|
// Skip rows before the valid rectangle unless they are already cached.
|
|
193
|
-
if (y + rowHeight < this.
|
|
188
|
+
if (y + rowHeight < this.requestedRect.y && !this.isValid(node, y)) {
|
|
194
189
|
y += rowHeight;
|
|
195
190
|
skipped++;
|
|
196
191
|
continue;
|
|
197
192
|
}
|
|
198
|
-
let layoutNode = this.buildChild(child, x, y);
|
|
193
|
+
let layoutNode = this.buildChild(child, x, y, layoutInfo.key);
|
|
199
194
|
y = layoutNode.layoutInfo.rect.maxY;
|
|
200
195
|
children.push(layoutNode);
|
|
201
|
-
if (y > this.
|
|
196
|
+
if (y > this.requestedRect.maxY) {
|
|
202
197
|
// Estimate the remaining height for rows that we don't need to layout right now.
|
|
203
198
|
y += ([
|
|
204
199
|
...(0, $img26$getChildNodes)(node, this.collection)
|
|
@@ -211,17 +206,17 @@ class $61ef60fc9b1041f4$export$cacbb3924155d68e extends (0, $img26$Layout) {
|
|
|
211
206
|
header: header,
|
|
212
207
|
layoutInfo: layoutInfo,
|
|
213
208
|
children: children,
|
|
214
|
-
validRect: layoutInfo.rect.intersection(this.
|
|
209
|
+
validRect: layoutInfo.rect.intersection(this.requestedRect)
|
|
215
210
|
};
|
|
216
211
|
}
|
|
217
|
-
|
|
212
|
+
buildSectionHeader(node, x, y) {
|
|
218
213
|
let width = this.virtualizer.visibleRect.width;
|
|
219
214
|
let rectHeight = this.headingHeight;
|
|
220
215
|
let isEstimated = false;
|
|
221
216
|
// If no explicit height is available, use an estimated height.
|
|
222
217
|
if (rectHeight == null) {
|
|
223
218
|
// If a previous version of this layout info exists, reuse its height.
|
|
224
|
-
// Mark as estimated if the size of the overall
|
|
219
|
+
// Mark as estimated if the size of the overall virtualizer changed,
|
|
225
220
|
// or the content of the item changed.
|
|
226
221
|
let previousLayoutNode = this.layoutNodes.get(node.key);
|
|
227
222
|
let previousLayoutInfo = (previousLayoutNode === null || previousLayoutNode === void 0 ? void 0 : previousLayoutNode.header) || (previousLayoutNode === null || previousLayoutNode === void 0 ? void 0 : previousLayoutNode.layoutInfo);
|
|
@@ -242,7 +237,7 @@ class $61ef60fc9b1041f4$export$cacbb3924155d68e extends (0, $img26$Layout) {
|
|
|
242
237
|
return {
|
|
243
238
|
layoutInfo: header,
|
|
244
239
|
children: [],
|
|
245
|
-
validRect: header.rect.intersection(this.
|
|
240
|
+
validRect: header.rect.intersection(this.requestedRect)
|
|
246
241
|
};
|
|
247
242
|
}
|
|
248
243
|
buildItem(node, x, y) {
|
|
@@ -252,7 +247,7 @@ class $61ef60fc9b1041f4$export$cacbb3924155d68e extends (0, $img26$Layout) {
|
|
|
252
247
|
// If no explicit height is available, use an estimated height.
|
|
253
248
|
if (rectHeight == null) {
|
|
254
249
|
// If a previous version of this layout info exists, reuse its height.
|
|
255
|
-
// Mark as estimated if the size of the overall
|
|
250
|
+
// Mark as estimated if the size of the overall virtualizer changed,
|
|
256
251
|
// or the content of the item changed.
|
|
257
252
|
let previousLayoutNode = this.layoutNodes.get(node.key);
|
|
258
253
|
if (previousLayoutNode) {
|
|
@@ -285,6 +280,11 @@ class $61ef60fc9b1041f4$export$cacbb3924155d68e extends (0, $img26$Layout) {
|
|
|
285
280
|
let newLayoutInfo = layoutInfo.copy();
|
|
286
281
|
newLayoutInfo.rect.height = size.height;
|
|
287
282
|
this.layoutInfos.set(key, newLayoutInfo);
|
|
283
|
+
// Items after this layoutInfo will need to be repositioned to account for the new height.
|
|
284
|
+
// Adjust the validRect so that only items above remain valid.
|
|
285
|
+
this.validRect.height = Math.min(this.validRect.height, layoutInfo.rect.y - this.validRect.y);
|
|
286
|
+
// The requestedRect also needs to be adjusted to account for the height difference.
|
|
287
|
+
this.requestedRect.height += newLayoutInfo.rect.height - layoutInfo.rect.height;
|
|
288
288
|
// Invalidate layout for this layout node and all parents
|
|
289
289
|
this.updateLayoutNode(key, layoutInfo, newLayoutInfo);
|
|
290
290
|
let node = this.collection.getItem(layoutInfo.parentKey);
|
|
@@ -299,8 +299,8 @@ class $61ef60fc9b1041f4$export$cacbb3924155d68e extends (0, $img26$Layout) {
|
|
|
299
299
|
updateLayoutNode(key, oldLayoutInfo, newLayoutInfo) {
|
|
300
300
|
let n = this.layoutNodes.get(key);
|
|
301
301
|
if (n) {
|
|
302
|
-
// Invalidate by
|
|
303
|
-
n.validRect =
|
|
302
|
+
// Invalidate by intersecting the validRect of this node with the overall validRect.
|
|
303
|
+
n.validRect = n.validRect.intersection(this.validRect);
|
|
304
304
|
// Replace layout info in LayoutNode
|
|
305
305
|
if (n.header === oldLayoutInfo) n.header = newLayoutInfo;
|
|
306
306
|
else if (n.layoutInfo === oldLayoutInfo) n.layoutInfo = newLayoutInfo;
|
|
@@ -309,78 +309,6 @@ class $61ef60fc9b1041f4$export$cacbb3924155d68e extends (0, $img26$Layout) {
|
|
|
309
309
|
getContentSize() {
|
|
310
310
|
return this.contentSize;
|
|
311
311
|
}
|
|
312
|
-
getKeyAbove(key) {
|
|
313
|
-
let collection = this.collection;
|
|
314
|
-
key = collection.getKeyBefore(key);
|
|
315
|
-
while(key != null){
|
|
316
|
-
let item = collection.getItem(key);
|
|
317
|
-
if (item.type === 'item' && (this.allowDisabledKeyFocus || !this.disabledKeys.has(item.key))) return key;
|
|
318
|
-
key = collection.getKeyBefore(key);
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
getKeyBelow(key) {
|
|
322
|
-
let collection = this.collection;
|
|
323
|
-
key = collection.getKeyAfter(key);
|
|
324
|
-
while(key != null){
|
|
325
|
-
let item = collection.getItem(key);
|
|
326
|
-
if (item.type === 'item' && (this.allowDisabledKeyFocus || !this.disabledKeys.has(item.key))) return key;
|
|
327
|
-
key = collection.getKeyAfter(key);
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
getKeyPageAbove(key) {
|
|
331
|
-
let layoutInfo = this.getLayoutInfo(key);
|
|
332
|
-
if (layoutInfo) {
|
|
333
|
-
let pageY = Math.max(0, layoutInfo.rect.y + layoutInfo.rect.height - this.virtualizer.visibleRect.height);
|
|
334
|
-
while(layoutInfo && layoutInfo.rect.y > pageY){
|
|
335
|
-
let keyAbove = this.getKeyAbove(layoutInfo.key);
|
|
336
|
-
layoutInfo = this.getLayoutInfo(keyAbove);
|
|
337
|
-
}
|
|
338
|
-
if (layoutInfo) return layoutInfo.key;
|
|
339
|
-
}
|
|
340
|
-
return this.getFirstKey();
|
|
341
|
-
}
|
|
342
|
-
getKeyPageBelow(key) {
|
|
343
|
-
let layoutInfo = this.getLayoutInfo(key != null ? key : this.getFirstKey());
|
|
344
|
-
if (layoutInfo) {
|
|
345
|
-
let pageY = Math.min(this.virtualizer.contentSize.height, layoutInfo.rect.y - layoutInfo.rect.height + this.virtualizer.visibleRect.height);
|
|
346
|
-
while(layoutInfo && layoutInfo.rect.y < pageY){
|
|
347
|
-
let keyBelow = this.getKeyBelow(layoutInfo.key);
|
|
348
|
-
layoutInfo = this.getLayoutInfo(keyBelow);
|
|
349
|
-
}
|
|
350
|
-
if (layoutInfo) return layoutInfo.key;
|
|
351
|
-
}
|
|
352
|
-
return this.getLastKey();
|
|
353
|
-
}
|
|
354
|
-
getFirstKey() {
|
|
355
|
-
let collection = this.collection;
|
|
356
|
-
let key = collection.getFirstKey();
|
|
357
|
-
while(key != null){
|
|
358
|
-
let item = collection.getItem(key);
|
|
359
|
-
if (item.type === 'item' && (this.allowDisabledKeyFocus || !this.disabledKeys.has(item.key))) return key;
|
|
360
|
-
key = collection.getKeyAfter(key);
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
getLastKey() {
|
|
364
|
-
let collection = this.collection;
|
|
365
|
-
let key = collection.getLastKey();
|
|
366
|
-
while(key != null){
|
|
367
|
-
let item = collection.getItem(key);
|
|
368
|
-
if (item.type === 'item' && (this.allowDisabledKeyFocus || !this.disabledKeys.has(item.key))) return key;
|
|
369
|
-
key = collection.getKeyBefore(key);
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
getKeyForSearch(search, fromKey) {
|
|
373
|
-
if (!this.collator) return null;
|
|
374
|
-
let collection = this.collection;
|
|
375
|
-
let key = fromKey || this.getFirstKey();
|
|
376
|
-
while(key != null){
|
|
377
|
-
let item = collection.getItem(key);
|
|
378
|
-
let substring = item.textValue.slice(0, search.length);
|
|
379
|
-
if (item.textValue && this.collator.compare(substring, search) === 0) return key;
|
|
380
|
-
key = this.getKeyBelow(key);
|
|
381
|
-
}
|
|
382
|
-
return null;
|
|
383
|
-
}
|
|
384
312
|
getDropTargetFromPoint(x, y, isValidDropTarget) {
|
|
385
313
|
x += this.virtualizer.visibleRect.x;
|
|
386
314
|
y += this.virtualizer.visibleRect.y;
|
|
@@ -422,8 +350,6 @@ class $61ef60fc9b1041f4$export$cacbb3924155d68e extends (0, $img26$Layout) {
|
|
|
422
350
|
* of the options that can be provided.
|
|
423
351
|
*/ constructor(options = {}){
|
|
424
352
|
super();
|
|
425
|
-
this.disabledKeys = new Set();
|
|
426
|
-
this.allowDisabledKeyFocus = false;
|
|
427
353
|
this.rowHeight = options.rowHeight;
|
|
428
354
|
this.estimatedRowHeight = options.estimatedRowHeight;
|
|
429
355
|
this.headingHeight = options.headingHeight;
|
|
@@ -431,17 +357,16 @@ class $61ef60fc9b1041f4$export$cacbb3924155d68e extends (0, $img26$Layout) {
|
|
|
431
357
|
this.forceSectionHeaders = options.forceSectionHeaders;
|
|
432
358
|
this.padding = options.padding || 0;
|
|
433
359
|
this.indentationForItem = options.indentationForItem;
|
|
434
|
-
this.collator = options.collator;
|
|
435
360
|
this.loaderHeight = options.loaderHeight;
|
|
436
361
|
this.placeholderHeight = options.placeholderHeight;
|
|
362
|
+
this.enableEmptyState = options.enableEmptyState || false;
|
|
437
363
|
this.layoutInfos = new Map();
|
|
438
364
|
this.layoutNodes = new Map();
|
|
439
365
|
this.rootNodes = [];
|
|
440
366
|
this.lastWidth = 0;
|
|
441
367
|
this.lastCollection = null;
|
|
442
|
-
this.allowDisabledKeyFocus = options.allowDisabledKeyFocus;
|
|
443
|
-
this.lastValidRect = new (0, $img26$Rect)();
|
|
444
368
|
this.validRect = new (0, $img26$Rect)();
|
|
369
|
+
this.requestedRect = new (0, $img26$Rect)();
|
|
445
370
|
this.contentSize = new (0, $img26$Size)();
|
|
446
371
|
}
|
|
447
372
|
}
|
|
@@ -44,9 +44,8 @@ class $61ef60fc9b1041f4$export$cacbb3924155d68e extends (0, $img26$Layout) {
|
|
|
44
44
|
}
|
|
45
45
|
layoutIfNeeded(rect) {
|
|
46
46
|
if (!this.lastCollection) return;
|
|
47
|
-
if (!this.
|
|
48
|
-
this.
|
|
49
|
-
this.validRect = this.validRect.union(rect);
|
|
47
|
+
if (!this.requestedRect.containsRect(rect)) {
|
|
48
|
+
this.requestedRect = this.requestedRect.union(rect);
|
|
50
49
|
this.rootNodes = this.buildCollection();
|
|
51
50
|
} else // Ensure all of the persisted keys are available.
|
|
52
51
|
for (let key of this.virtualizer.persistedKeys){
|
|
@@ -57,11 +56,10 @@ class $61ef60fc9b1041f4$export$cacbb3924155d68e extends (0, $img26$Layout) {
|
|
|
57
56
|
// If the layout info wasn't found, it might be outside the bounds of the area that we've
|
|
58
57
|
// computed layout for so far. This can happen when accessing a random key, e.g pressing Home/End.
|
|
59
58
|
// Compute the full layout and try again.
|
|
60
|
-
if (!this.layoutInfos.has(key) && this.
|
|
61
|
-
this.
|
|
62
|
-
this.validRect = new (0, $img26$Rect)(0, 0, Infinity, Infinity);
|
|
59
|
+
if (!this.layoutInfos.has(key) && this.requestedRect.area < this.contentSize.area && this.lastCollection) {
|
|
60
|
+
this.requestedRect = new (0, $img26$Rect)(0, 0, Infinity, Infinity);
|
|
63
61
|
this.rootNodes = this.buildCollection();
|
|
64
|
-
this.
|
|
62
|
+
this.requestedRect = new (0, $img26$Rect)(0, 0, this.contentSize.width, this.contentSize.height);
|
|
65
63
|
return true;
|
|
66
64
|
}
|
|
67
65
|
return false;
|
|
@@ -81,10 +79,7 @@ class $61ef60fc9b1041f4$export$cacbb3924155d68e extends (0, $img26$Layout) {
|
|
|
81
79
|
// Reset valid rect if we will have to invalidate everything.
|
|
82
80
|
// Otherwise we can reuse cached layout infos outside the current visible rect.
|
|
83
81
|
this.invalidateEverything = this.shouldInvalidateEverything(invalidationContext);
|
|
84
|
-
if (this.invalidateEverything)
|
|
85
|
-
this.lastValidRect = this.validRect;
|
|
86
|
-
this.validRect = this.virtualizer.visibleRect.copy();
|
|
87
|
-
}
|
|
82
|
+
if (this.invalidateEverything) this.requestedRect = this.virtualizer.visibleRect.copy();
|
|
88
83
|
this.rootNodes = this.buildCollection();
|
|
89
84
|
// Remove deleted layout nodes
|
|
90
85
|
if (this.lastCollection && this.collection !== this.lastCollection) {
|
|
@@ -101,6 +96,7 @@ class $61ef60fc9b1041f4$export$cacbb3924155d68e extends (0, $img26$Layout) {
|
|
|
101
96
|
this.lastWidth = this.virtualizer.visibleRect.width;
|
|
102
97
|
this.lastCollection = this.collection;
|
|
103
98
|
this.invalidateEverything = false;
|
|
99
|
+
this.validRect = this.requestedRect.copy();
|
|
104
100
|
}
|
|
105
101
|
buildCollection() {
|
|
106
102
|
let y = this.padding;
|
|
@@ -110,15 +106,15 @@ class $61ef60fc9b1041f4$export$cacbb3924155d68e extends (0, $img26$Layout) {
|
|
|
110
106
|
var _this_rowHeight;
|
|
111
107
|
let rowHeight = (_this_rowHeight = this.rowHeight) !== null && _this_rowHeight !== void 0 ? _this_rowHeight : this.estimatedRowHeight;
|
|
112
108
|
// Skip rows before the valid rectangle unless they are already cached.
|
|
113
|
-
if (node.type === 'item' && y + rowHeight < this.
|
|
109
|
+
if (node.type === 'item' && y + rowHeight < this.requestedRect.y && !this.isValid(node, y)) {
|
|
114
110
|
y += rowHeight;
|
|
115
111
|
skipped++;
|
|
116
112
|
continue;
|
|
117
113
|
}
|
|
118
|
-
let layoutNode = this.buildChild(node, 0, y);
|
|
114
|
+
let layoutNode = this.buildChild(node, 0, y, null);
|
|
119
115
|
y = layoutNode.layoutInfo.rect.maxY;
|
|
120
116
|
nodes.push(layoutNode);
|
|
121
|
-
if (node.type === 'item' && y > this.
|
|
117
|
+
if (node.type === 'item' && y > this.requestedRect.maxY) {
|
|
122
118
|
y += (this.collection.size - (nodes.length + skipped)) * rowHeight;
|
|
123
119
|
break;
|
|
124
120
|
}
|
|
@@ -133,7 +129,7 @@ class $61ef60fc9b1041f4$export$cacbb3924155d68e extends (0, $img26$Layout) {
|
|
|
133
129
|
});
|
|
134
130
|
y = loader.rect.maxY;
|
|
135
131
|
}
|
|
136
|
-
if (nodes.length === 0) {
|
|
132
|
+
if (nodes.length === 0 && this.enableEmptyState) {
|
|
137
133
|
var _this_placeholderHeight;
|
|
138
134
|
let rect = new (0, $img26$Rect)(0, y, this.virtualizer.visibleRect.width, (_this_placeholderHeight = this.placeholderHeight) !== null && _this_placeholderHeight !== void 0 ? _this_placeholderHeight : this.virtualizer.visibleRect.height);
|
|
139
135
|
let placeholder = new (0, $img26$LayoutInfo)('placeholder', 'placeholder', rect);
|
|
@@ -148,14 +144,13 @@ class $61ef60fc9b1041f4$export$cacbb3924155d68e extends (0, $img26$Layout) {
|
|
|
148
144
|
}
|
|
149
145
|
isValid(node, y) {
|
|
150
146
|
let cached = this.layoutNodes.get(node.key);
|
|
151
|
-
return !this.invalidateEverything && cached && cached.node === node && y === (cached.header || cached.layoutInfo).rect.y && cached.layoutInfo.rect.intersects(this.
|
|
147
|
+
return !this.invalidateEverything && cached && cached.node === node && y === (cached.header || cached.layoutInfo).rect.y && cached.layoutInfo.rect.intersects(this.validRect) && cached.validRect.containsRect(cached.layoutInfo.rect.intersection(this.requestedRect));
|
|
152
148
|
}
|
|
153
|
-
buildChild(node, x, y) {
|
|
149
|
+
buildChild(node, x, y, parentKey) {
|
|
154
150
|
if (this.isValid(node, y)) return this.layoutNodes.get(node.key);
|
|
155
151
|
let layoutNode = this.buildNode(node, x, y);
|
|
156
152
|
layoutNode.node = node;
|
|
157
|
-
|
|
158
|
-
layoutNode.layoutInfo.parentKey = (_node_parentKey = node.parentKey) !== null && _node_parentKey !== void 0 ? _node_parentKey : null;
|
|
153
|
+
layoutNode.layoutInfo.parentKey = parentKey !== null && parentKey !== void 0 ? parentKey : null;
|
|
159
154
|
this.layoutInfos.set(layoutNode.layoutInfo.key, layoutNode.layoutInfo);
|
|
160
155
|
if (layoutNode.header) this.layoutInfos.set(layoutNode.header.key, layoutNode.header);
|
|
161
156
|
this.layoutNodes.set(node.key, layoutNode);
|
|
@@ -168,14 +163,14 @@ class $61ef60fc9b1041f4$export$cacbb3924155d68e extends (0, $img26$Layout) {
|
|
|
168
163
|
case 'item':
|
|
169
164
|
return this.buildItem(node, x, y);
|
|
170
165
|
case 'header':
|
|
171
|
-
return this.
|
|
166
|
+
return this.buildSectionHeader(node, x, y);
|
|
172
167
|
}
|
|
173
168
|
}
|
|
174
169
|
buildSection(node, x, y) {
|
|
175
170
|
let width = this.virtualizer.visibleRect.width;
|
|
176
171
|
let header = null;
|
|
177
172
|
if (node.rendered || this.forceSectionHeaders) {
|
|
178
|
-
let headerNode = this.
|
|
173
|
+
let headerNode = this.buildSectionHeader(node, x, y);
|
|
179
174
|
header = headerNode.layoutInfo;
|
|
180
175
|
header.key += ':header';
|
|
181
176
|
header.parentKey = node.key;
|
|
@@ -190,15 +185,15 @@ class $61ef60fc9b1041f4$export$cacbb3924155d68e extends (0, $img26$Layout) {
|
|
|
190
185
|
var _this_rowHeight;
|
|
191
186
|
let rowHeight = (_this_rowHeight = this.rowHeight) !== null && _this_rowHeight !== void 0 ? _this_rowHeight : this.estimatedRowHeight;
|
|
192
187
|
// Skip rows before the valid rectangle unless they are already cached.
|
|
193
|
-
if (y + rowHeight < this.
|
|
188
|
+
if (y + rowHeight < this.requestedRect.y && !this.isValid(node, y)) {
|
|
194
189
|
y += rowHeight;
|
|
195
190
|
skipped++;
|
|
196
191
|
continue;
|
|
197
192
|
}
|
|
198
|
-
let layoutNode = this.buildChild(child, x, y);
|
|
193
|
+
let layoutNode = this.buildChild(child, x, y, layoutInfo.key);
|
|
199
194
|
y = layoutNode.layoutInfo.rect.maxY;
|
|
200
195
|
children.push(layoutNode);
|
|
201
|
-
if (y > this.
|
|
196
|
+
if (y > this.requestedRect.maxY) {
|
|
202
197
|
// Estimate the remaining height for rows that we don't need to layout right now.
|
|
203
198
|
y += ([
|
|
204
199
|
...(0, $img26$getChildNodes)(node, this.collection)
|
|
@@ -211,17 +206,17 @@ class $61ef60fc9b1041f4$export$cacbb3924155d68e extends (0, $img26$Layout) {
|
|
|
211
206
|
header: header,
|
|
212
207
|
layoutInfo: layoutInfo,
|
|
213
208
|
children: children,
|
|
214
|
-
validRect: layoutInfo.rect.intersection(this.
|
|
209
|
+
validRect: layoutInfo.rect.intersection(this.requestedRect)
|
|
215
210
|
};
|
|
216
211
|
}
|
|
217
|
-
|
|
212
|
+
buildSectionHeader(node, x, y) {
|
|
218
213
|
let width = this.virtualizer.visibleRect.width;
|
|
219
214
|
let rectHeight = this.headingHeight;
|
|
220
215
|
let isEstimated = false;
|
|
221
216
|
// If no explicit height is available, use an estimated height.
|
|
222
217
|
if (rectHeight == null) {
|
|
223
218
|
// If a previous version of this layout info exists, reuse its height.
|
|
224
|
-
// Mark as estimated if the size of the overall
|
|
219
|
+
// Mark as estimated if the size of the overall virtualizer changed,
|
|
225
220
|
// or the content of the item changed.
|
|
226
221
|
let previousLayoutNode = this.layoutNodes.get(node.key);
|
|
227
222
|
let previousLayoutInfo = (previousLayoutNode === null || previousLayoutNode === void 0 ? void 0 : previousLayoutNode.header) || (previousLayoutNode === null || previousLayoutNode === void 0 ? void 0 : previousLayoutNode.layoutInfo);
|
|
@@ -242,7 +237,7 @@ class $61ef60fc9b1041f4$export$cacbb3924155d68e extends (0, $img26$Layout) {
|
|
|
242
237
|
return {
|
|
243
238
|
layoutInfo: header,
|
|
244
239
|
children: [],
|
|
245
|
-
validRect: header.rect.intersection(this.
|
|
240
|
+
validRect: header.rect.intersection(this.requestedRect)
|
|
246
241
|
};
|
|
247
242
|
}
|
|
248
243
|
buildItem(node, x, y) {
|
|
@@ -252,7 +247,7 @@ class $61ef60fc9b1041f4$export$cacbb3924155d68e extends (0, $img26$Layout) {
|
|
|
252
247
|
// If no explicit height is available, use an estimated height.
|
|
253
248
|
if (rectHeight == null) {
|
|
254
249
|
// If a previous version of this layout info exists, reuse its height.
|
|
255
|
-
// Mark as estimated if the size of the overall
|
|
250
|
+
// Mark as estimated if the size of the overall virtualizer changed,
|
|
256
251
|
// or the content of the item changed.
|
|
257
252
|
let previousLayoutNode = this.layoutNodes.get(node.key);
|
|
258
253
|
if (previousLayoutNode) {
|
|
@@ -285,6 +280,11 @@ class $61ef60fc9b1041f4$export$cacbb3924155d68e extends (0, $img26$Layout) {
|
|
|
285
280
|
let newLayoutInfo = layoutInfo.copy();
|
|
286
281
|
newLayoutInfo.rect.height = size.height;
|
|
287
282
|
this.layoutInfos.set(key, newLayoutInfo);
|
|
283
|
+
// Items after this layoutInfo will need to be repositioned to account for the new height.
|
|
284
|
+
// Adjust the validRect so that only items above remain valid.
|
|
285
|
+
this.validRect.height = Math.min(this.validRect.height, layoutInfo.rect.y - this.validRect.y);
|
|
286
|
+
// The requestedRect also needs to be adjusted to account for the height difference.
|
|
287
|
+
this.requestedRect.height += newLayoutInfo.rect.height - layoutInfo.rect.height;
|
|
288
288
|
// Invalidate layout for this layout node and all parents
|
|
289
289
|
this.updateLayoutNode(key, layoutInfo, newLayoutInfo);
|
|
290
290
|
let node = this.collection.getItem(layoutInfo.parentKey);
|
|
@@ -299,8 +299,8 @@ class $61ef60fc9b1041f4$export$cacbb3924155d68e extends (0, $img26$Layout) {
|
|
|
299
299
|
updateLayoutNode(key, oldLayoutInfo, newLayoutInfo) {
|
|
300
300
|
let n = this.layoutNodes.get(key);
|
|
301
301
|
if (n) {
|
|
302
|
-
// Invalidate by
|
|
303
|
-
n.validRect =
|
|
302
|
+
// Invalidate by intersecting the validRect of this node with the overall validRect.
|
|
303
|
+
n.validRect = n.validRect.intersection(this.validRect);
|
|
304
304
|
// Replace layout info in LayoutNode
|
|
305
305
|
if (n.header === oldLayoutInfo) n.header = newLayoutInfo;
|
|
306
306
|
else if (n.layoutInfo === oldLayoutInfo) n.layoutInfo = newLayoutInfo;
|
|
@@ -309,78 +309,6 @@ class $61ef60fc9b1041f4$export$cacbb3924155d68e extends (0, $img26$Layout) {
|
|
|
309
309
|
getContentSize() {
|
|
310
310
|
return this.contentSize;
|
|
311
311
|
}
|
|
312
|
-
getKeyAbove(key) {
|
|
313
|
-
let collection = this.collection;
|
|
314
|
-
key = collection.getKeyBefore(key);
|
|
315
|
-
while(key != null){
|
|
316
|
-
let item = collection.getItem(key);
|
|
317
|
-
if (item.type === 'item' && (this.allowDisabledKeyFocus || !this.disabledKeys.has(item.key))) return key;
|
|
318
|
-
key = collection.getKeyBefore(key);
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
getKeyBelow(key) {
|
|
322
|
-
let collection = this.collection;
|
|
323
|
-
key = collection.getKeyAfter(key);
|
|
324
|
-
while(key != null){
|
|
325
|
-
let item = collection.getItem(key);
|
|
326
|
-
if (item.type === 'item' && (this.allowDisabledKeyFocus || !this.disabledKeys.has(item.key))) return key;
|
|
327
|
-
key = collection.getKeyAfter(key);
|
|
328
|
-
}
|
|
329
|
-
}
|
|
330
|
-
getKeyPageAbove(key) {
|
|
331
|
-
let layoutInfo = this.getLayoutInfo(key);
|
|
332
|
-
if (layoutInfo) {
|
|
333
|
-
let pageY = Math.max(0, layoutInfo.rect.y + layoutInfo.rect.height - this.virtualizer.visibleRect.height);
|
|
334
|
-
while(layoutInfo && layoutInfo.rect.y > pageY){
|
|
335
|
-
let keyAbove = this.getKeyAbove(layoutInfo.key);
|
|
336
|
-
layoutInfo = this.getLayoutInfo(keyAbove);
|
|
337
|
-
}
|
|
338
|
-
if (layoutInfo) return layoutInfo.key;
|
|
339
|
-
}
|
|
340
|
-
return this.getFirstKey();
|
|
341
|
-
}
|
|
342
|
-
getKeyPageBelow(key) {
|
|
343
|
-
let layoutInfo = this.getLayoutInfo(key != null ? key : this.getFirstKey());
|
|
344
|
-
if (layoutInfo) {
|
|
345
|
-
let pageY = Math.min(this.virtualizer.contentSize.height, layoutInfo.rect.y - layoutInfo.rect.height + this.virtualizer.visibleRect.height);
|
|
346
|
-
while(layoutInfo && layoutInfo.rect.y < pageY){
|
|
347
|
-
let keyBelow = this.getKeyBelow(layoutInfo.key);
|
|
348
|
-
layoutInfo = this.getLayoutInfo(keyBelow);
|
|
349
|
-
}
|
|
350
|
-
if (layoutInfo) return layoutInfo.key;
|
|
351
|
-
}
|
|
352
|
-
return this.getLastKey();
|
|
353
|
-
}
|
|
354
|
-
getFirstKey() {
|
|
355
|
-
let collection = this.collection;
|
|
356
|
-
let key = collection.getFirstKey();
|
|
357
|
-
while(key != null){
|
|
358
|
-
let item = collection.getItem(key);
|
|
359
|
-
if (item.type === 'item' && (this.allowDisabledKeyFocus || !this.disabledKeys.has(item.key))) return key;
|
|
360
|
-
key = collection.getKeyAfter(key);
|
|
361
|
-
}
|
|
362
|
-
}
|
|
363
|
-
getLastKey() {
|
|
364
|
-
let collection = this.collection;
|
|
365
|
-
let key = collection.getLastKey();
|
|
366
|
-
while(key != null){
|
|
367
|
-
let item = collection.getItem(key);
|
|
368
|
-
if (item.type === 'item' && (this.allowDisabledKeyFocus || !this.disabledKeys.has(item.key))) return key;
|
|
369
|
-
key = collection.getKeyBefore(key);
|
|
370
|
-
}
|
|
371
|
-
}
|
|
372
|
-
getKeyForSearch(search, fromKey) {
|
|
373
|
-
if (!this.collator) return null;
|
|
374
|
-
let collection = this.collection;
|
|
375
|
-
let key = fromKey || this.getFirstKey();
|
|
376
|
-
while(key != null){
|
|
377
|
-
let item = collection.getItem(key);
|
|
378
|
-
let substring = item.textValue.slice(0, search.length);
|
|
379
|
-
if (item.textValue && this.collator.compare(substring, search) === 0) return key;
|
|
380
|
-
key = this.getKeyBelow(key);
|
|
381
|
-
}
|
|
382
|
-
return null;
|
|
383
|
-
}
|
|
384
312
|
getDropTargetFromPoint(x, y, isValidDropTarget) {
|
|
385
313
|
x += this.virtualizer.visibleRect.x;
|
|
386
314
|
y += this.virtualizer.visibleRect.y;
|
|
@@ -422,8 +350,6 @@ class $61ef60fc9b1041f4$export$cacbb3924155d68e extends (0, $img26$Layout) {
|
|
|
422
350
|
* of the options that can be provided.
|
|
423
351
|
*/ constructor(options = {}){
|
|
424
352
|
super();
|
|
425
|
-
this.disabledKeys = new Set();
|
|
426
|
-
this.allowDisabledKeyFocus = false;
|
|
427
353
|
this.rowHeight = options.rowHeight;
|
|
428
354
|
this.estimatedRowHeight = options.estimatedRowHeight;
|
|
429
355
|
this.headingHeight = options.headingHeight;
|
|
@@ -431,17 +357,16 @@ class $61ef60fc9b1041f4$export$cacbb3924155d68e extends (0, $img26$Layout) {
|
|
|
431
357
|
this.forceSectionHeaders = options.forceSectionHeaders;
|
|
432
358
|
this.padding = options.padding || 0;
|
|
433
359
|
this.indentationForItem = options.indentationForItem;
|
|
434
|
-
this.collator = options.collator;
|
|
435
360
|
this.loaderHeight = options.loaderHeight;
|
|
436
361
|
this.placeholderHeight = options.placeholderHeight;
|
|
362
|
+
this.enableEmptyState = options.enableEmptyState || false;
|
|
437
363
|
this.layoutInfos = new Map();
|
|
438
364
|
this.layoutNodes = new Map();
|
|
439
365
|
this.rootNodes = [];
|
|
440
366
|
this.lastWidth = 0;
|
|
441
367
|
this.lastCollection = null;
|
|
442
|
-
this.allowDisabledKeyFocus = options.allowDisabledKeyFocus;
|
|
443
|
-
this.lastValidRect = new (0, $img26$Rect)();
|
|
444
368
|
this.validRect = new (0, $img26$Rect)();
|
|
369
|
+
this.requestedRect = new (0, $img26$Rect)();
|
|
445
370
|
this.contentSize = new (0, $img26$Size)();
|
|
446
371
|
}
|
|
447
372
|
}
|