@react-stately/layout 3.13.10-nightly.4695 → 3.13.10-nightly.4700

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/src/GridLayout.ts CHANGED
@@ -61,7 +61,7 @@ export class GridLayout<T, O = any> extends Layout<Node<T>, O> implements DropTa
61
61
  this.dropIndicatorThickness = options.dropIndicatorThickness || 2;
62
62
  }
63
63
 
64
- validate(): void {
64
+ update(): void {
65
65
  let visibleWidth = this.virtualizer.visibleRect.width;
66
66
 
67
67
  // The max item width is always the entire viewport.
@@ -83,7 +83,7 @@ export class GridLayout<T, O = any> extends Layout<Node<T>, O> implements DropTa
83
83
  itemWidth = Math.max(this.minItemSize.width, Math.min(maxItemWidth, itemWidth));
84
84
 
85
85
  // Compute the item height, which is proportional to the item width
86
- let t = ((itemWidth - this.minItemSize.width) / (maxItemWidth - this.minItemSize.width));
86
+ let t = ((itemWidth - this.minItemSize.width) / Math.max(1, maxItemWidth - this.minItemSize.width));
87
87
  let itemHeight = this.minItemSize.height + Math.floor((maxItemHeight - this.minItemSize.height) * t);
88
88
  itemHeight = Math.max(this.minItemSize.height, Math.min(maxItemHeight, itemHeight));
89
89
  this.itemSize = new Size(itemWidth, itemHeight);
package/src/ListLayout.ts CHANGED
@@ -128,12 +128,12 @@ export class ListLayout<T, O = any> extends Layout<Node<T>, O> implements DropTa
128
128
  if (!this.requestedRect.containsRect(rect)) {
129
129
  this.requestedRect = this.requestedRect.union(rect);
130
130
  this.rootNodes = this.buildCollection();
131
- } else {
132
- // Ensure all of the persisted keys are available.
133
- for (let key of this.virtualizer.persistedKeys) {
134
- if (this.ensureLayoutInfo(key)) {
135
- break;
136
- }
131
+ }
132
+
133
+ // Ensure all of the persisted keys are available.
134
+ for (let key of this.virtualizer.persistedKeys) {
135
+ if (this.ensureLayoutInfo(key)) {
136
+ return;
137
137
  }
138
138
  }
139
139
  }
@@ -162,7 +162,7 @@ export class ListLayout<T, O = any> extends Layout<Node<T>, O> implements DropTa
162
162
  return invalidationContext.sizeChanged;
163
163
  }
164
164
 
165
- validate(invalidationContext: InvalidationContext<O>) {
165
+ update(invalidationContext: InvalidationContext<O>) {
166
166
  this.collection = this.virtualizer.collection;
167
167
 
168
168
  // Reset valid rect if we will have to invalidate everything.
@@ -170,6 +170,7 @@ export class ListLayout<T, O = any> extends Layout<Node<T>, O> implements DropTa
170
170
  this.invalidateEverything = this.shouldInvalidateEverything(invalidationContext);
171
171
  if (this.invalidateEverything) {
172
172
  this.requestedRect = this.virtualizer.visibleRect.copy();
173
+ this.layoutNodes.clear();
173
174
  }
174
175
 
175
176
  this.rootNodes = this.buildCollection();
@@ -46,7 +46,7 @@ export class TableLayout<T, O extends TableLayoutProps = TableLayoutProps> exten
46
46
  );
47
47
  }
48
48
 
49
- validate(invalidationContext: InvalidationContext<O>): void {
49
+ update(invalidationContext: InvalidationContext<O>): void {
50
50
  let newCollection = this.virtualizer.collection as TableCollection<T>;
51
51
 
52
52
  // If columnWidths were provided via layoutOptions, update those.
@@ -62,7 +62,7 @@ export class TableLayout<T, O extends TableLayoutProps = TableLayoutProps> exten
62
62
  invalidationContext.sizeChanged = true;
63
63
  }
64
64
 
65
- super.validate(invalidationContext);
65
+ super.update(invalidationContext);
66
66
  }
67
67
 
68
68
  protected buildCollection(): LayoutNode[] {
@@ -227,7 +227,7 @@ export class TableLayout<T, O extends TableLayoutProps = TableLayoutProps> exten
227
227
  let width = 0;
228
228
  let children: LayoutNode[] = [];
229
229
  let rowHeight = this.getEstimatedRowHeight();
230
- for (let [i, node] of [...getChildNodes(this.collection.body, this.collection)].entries()) {
230
+ for (let node of getChildNodes(this.collection.body, this.collection)) {
231
231
  // Skip rows before the valid rectangle unless they are already cached.
232
232
  if (y + rowHeight < this.requestedRect.y && !this.isValid(node, y)) {
233
233
  y += rowHeight;
@@ -237,7 +237,7 @@ export class TableLayout<T, O extends TableLayoutProps = TableLayoutProps> exten
237
237
 
238
238
  let layoutNode = this.buildChild(node, 0, y, layoutInfo.key);
239
239
  layoutNode.layoutInfo.parentKey = layoutInfo.key;
240
- layoutNode.index = i;
240
+ layoutNode.index = children.length;
241
241
  y = layoutNode.layoutInfo.rect.maxY;
242
242
  width = Math.max(width, layoutNode.layoutInfo.rect.width);
243
243
  children.push(layoutNode);
@@ -285,7 +285,7 @@ export class TableLayout<T, O extends TableLayoutProps = TableLayoutProps> exten
285
285
 
286
286
  let children: LayoutNode[] = [];
287
287
  let height = 0;
288
- for (let [i, child] of [...getChildNodes(node, this.collection)].entries()) {
288
+ for (let child of getChildNodes(node, this.collection)) {
289
289
  if (child.type === 'cell') {
290
290
  if (x > this.requestedRect.maxX) {
291
291
  // Adjust existing cached layoutInfo to ensure that it is out of view.
@@ -299,7 +299,7 @@ export class TableLayout<T, O extends TableLayoutProps = TableLayoutProps> exten
299
299
  let layoutNode = this.buildChild(child, x, y, layoutInfo.key);
300
300
  x = layoutNode.layoutInfo.rect.maxX;
301
301
  height = Math.max(height, layoutNode.layoutInfo.rect.height);
302
- layoutNode.index = i;
302
+ layoutNode.index = children.length;
303
303
  children.push(layoutNode);
304
304
  }
305
305
  }