@react-stately/layout 3.13.10-nightly.4723 → 3.13.10-nightly.4730

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.
@@ -46,9 +46,12 @@ class $1f7773ceb2a3b9a6$export$7d2b12578154a735 extends (0, $7Tzdl$reactstatelyv
46
46
  let firstVisibleItem = this.getIndexAtPoint(rect.x, rect.y);
47
47
  let lastVisibleItem = this.getIndexAtPoint(rect.maxX, rect.maxY);
48
48
  let result = this.layoutInfos.slice(firstVisibleItem, lastVisibleItem + 1);
49
- let persistedIndices = [
50
- ...this.virtualizer.persistedKeys
51
- ].map((key)=>this.virtualizer.collection.getItem(key).index).sort((a, b)=>a - b);
49
+ let persistedIndices = [];
50
+ for (let key of this.virtualizer.persistedKeys){
51
+ let item = this.virtualizer.collection.getItem(key);
52
+ if ((item === null || item === void 0 ? void 0 : item.index) != null) persistedIndices.push(item.index);
53
+ }
54
+ persistedIndices.sort((a, b)=>a - b);
52
55
  let persistedBefore = [];
53
56
  for (let index of persistedIndices){
54
57
  if (index < firstVisibleItem) persistedBefore.push(this.layoutInfos[index]);
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;AAiCM,MAAM,kDAA+B,CAAA,GAAA,qCAAK;IAoB/C,SAAe;QACb,IAAI,eAAe,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,KAAK;QAErD,oDAAoD;QACpD,4EAA4E;QAC5E,IAAI,eAAe,KAAK,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE;QACpD,IAAI,gBAAgB,OAAO,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,IACvD,IAAI,CAAC,WAAW,CAAC,MAAM,GACvB,KAAK,KAAK,CAAC,AAAC,IAAI,CAAC,WAAW,CAAC,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,GAAI;QAEpE,uEAAuE;QACvE,IAAI,UAAU,KAAK,KAAK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licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {DropTarget, DropTargetDelegate, ItemDropTarget, Key, Node} from '@react-types/shared';\nimport {Layout, LayoutInfo, Rect, Size} from '@react-stately/virtualizer';\n\nexport interface GridLayoutOptions {\n /**\n * The minimum item size.\n * @default 200 x 200\n */\n minItemSize?: Size,\n /**\n * The maximum item size.\n * @default Infinity\n */\n maxItemSize?: Size,\n /**\n * The minimum space required between items.\n * @default 18 x 18\n */\n minSpace?: Size,\n /**\n * The maximum number of columns.\n * @default Infinity\n */\n maxColumns?: number,\n /**\n * The thickness of the drop indicator.\n * @default 2\n */\n dropIndicatorThickness?: number\n}\n\nexport class GridLayout<T, O = any> extends Layout<Node<T>, O> implements DropTargetDelegate {\n protected minItemSize: Size;\n protected maxItemSize: Size;\n protected minSpace: Size;\n protected maxColumns: number;\n protected dropIndicatorThickness: number;\n protected itemSize: Size;\n protected numColumns: number;\n protected horizontalSpacing: number;\n protected layoutInfos: LayoutInfo[];\n\n constructor(options: GridLayoutOptions) {\n super();\n this.minItemSize = options.minItemSize || new Size(200, 200);\n this.maxItemSize = options.maxItemSize || new Size(Infinity, Infinity);\n this.minSpace = options.minSpace || new Size(18, 18);\n this.maxColumns = options.maxColumns || Infinity;\n this.dropIndicatorThickness = options.dropIndicatorThickness || 2;\n }\n\n update(): void {\n let visibleWidth = this.virtualizer.visibleRect.width;\n\n // The max item width is always the entire viewport.\n // If the max item height is infinity, scale in proportion to the max width.\n let maxItemWidth = Math.min(this.maxItemSize.width, visibleWidth);\n let maxItemHeight = Number.isFinite(this.maxItemSize.height) \n ? this.maxItemSize.height\n : Math.floor((this.minItemSize.height / this.minItemSize.width) * maxItemWidth);\n\n // Compute the number of rows and columns needed to display the content\n let columns = Math.floor(visibleWidth / (this.minItemSize.width + this.minSpace.width));\n this.numColumns = Math.max(1, Math.min(this.maxColumns, columns));\n\n // Compute the available width (minus the space between items)\n let width = visibleWidth - (this.minSpace.width * Math.max(0, this.numColumns));\n\n // Compute the item width based on the space available\n let itemWidth = Math.floor(width / this.numColumns);\n itemWidth = Math.max(this.minItemSize.width, Math.min(maxItemWidth, itemWidth));\n\n // Compute the item height, which is proportional to the item width\n let t = ((itemWidth - this.minItemSize.width) / Math.max(1, maxItemWidth - this.minItemSize.width));\n let itemHeight = this.minItemSize.height + Math.floor((maxItemHeight - this.minItemSize.height) * t);\n itemHeight = Math.max(this.minItemSize.height, Math.min(maxItemHeight, itemHeight));\n this.itemSize = new Size(itemWidth, itemHeight);\n\n // Compute the horizontal spacing and content height\n this.horizontalSpacing = Math.floor((visibleWidth - this.numColumns * this.itemSize.width) / (this.numColumns + 1));\n\n this.layoutInfos = [];\n for (let node of this.virtualizer.collection) {\n this.layoutInfos.push(this.getLayoutInfoForNode(node));\n }\n }\n\n getVisibleLayoutInfos(rect: Rect): LayoutInfo[] {\n let firstVisibleItem = this.getIndexAtPoint(rect.x, rect.y);\n let lastVisibleItem = this.getIndexAtPoint(rect.maxX, rect.maxY);\n let result = this.layoutInfos.slice(firstVisibleItem, lastVisibleItem + 1);\n let persistedIndices = [...this.virtualizer.persistedKeys].map(key => this.virtualizer.collection.getItem(key).index).sort((a, b) => a - b);\n let persistedBefore = [];\n for (let index of persistedIndices) {\n if (index < firstVisibleItem) {\n persistedBefore.push(this.layoutInfos[index]);\n } else if (index > lastVisibleItem) {\n result.push(this.layoutInfos[index]);\n }\n }\n result.unshift(...persistedBefore);\n return result;\n }\n\n protected getIndexAtPoint(x: number, y: number) {\n let itemHeight = this.itemSize.height + this.minSpace.height;\n let itemWidth = this.itemSize.width + this.horizontalSpacing;\n return Math.max(0,\n Math.min(\n this.virtualizer.collection.size - 1,\n Math.floor(y / itemHeight) * this.numColumns + Math.floor((x - this.horizontalSpacing) / itemWidth)\n )\n );\n }\n\n getLayoutInfo(key: Key): LayoutInfo | null {\n let node = this.virtualizer.collection.getItem(key);\n return node ? this.layoutInfos[node.index] : null;\n }\n\n protected getLayoutInfoForNode(node: Node<T>): LayoutInfo {\n let idx = node.index;\n let row = Math.floor(idx / this.numColumns);\n let column = idx % this.numColumns;\n let x = this.horizontalSpacing + column * (this.itemSize.width + this.horizontalSpacing);\n let y = this.minSpace.height + row * (this.itemSize.height + this.minSpace.height);\n let rect = new Rect(x, y, this.itemSize.width, this.itemSize.height);\n return new LayoutInfo(node.type, node.key, rect);\n }\n\n getContentSize(): Size {\n let numRows = Math.ceil(this.virtualizer.collection.size / this.numColumns);\n let contentHeight = this.minSpace.height + numRows * (this.itemSize.height + this.minSpace.height); \n return new Size(this.virtualizer.visibleRect.width, contentHeight);\n }\n\n getDropTargetFromPoint(x: number, y: number, isValidDropTarget: (target: DropTarget) => boolean): DropTarget {\n if (this.layoutInfos.length === 0) {\n return {type: 'root'};\n }\n\n x += this.virtualizer.visibleRect.x;\n y += this.virtualizer.visibleRect.y;\n let index = this.getIndexAtPoint(x, y);\n\n let layoutInfo = this.layoutInfos[index];\n let target: DropTarget = {\n type: 'item',\n key: layoutInfo.key,\n dropPosition: 'on'\n };\n\n let pos = this.numColumns === 1 ? y : x;\n let layoutInfoPos = this.numColumns === 1 ? layoutInfo.rect.y : layoutInfo.rect.x;\n let size = this.numColumns === 1 ? layoutInfo.rect.height : layoutInfo.rect.width;\n if (isValidDropTarget(target)) {\n // If dropping on the item is accepted, try the before/after positions\n // if within 5px of the start or end of the item.\n if (pos < layoutInfoPos + 5) {\n target.dropPosition = 'before';\n } else if (pos > layoutInfoPos + size - 5) {\n target.dropPosition = 'after';\n }\n } else {\n // If dropping on the item isn't accepted, try the target before or after depending on the position.\n let mid = layoutInfoPos + size / 2;\n if (pos <= mid && isValidDropTarget({...target, dropPosition: 'before'})) {\n target.dropPosition = 'before';\n } else if (pos >= mid && isValidDropTarget({...target, dropPosition: 'after'})) {\n target.dropPosition = 'after';\n }\n }\n\n return target;\n }\n\n getDropTargetLayoutInfo(target: ItemDropTarget): LayoutInfo {\n let layoutInfo = this.getLayoutInfo(target.key);\n let rect: Rect;\n if (this.numColumns === 1) {\n // Flip from vertical to horizontal if only one column is visible.\n rect = new Rect(\n layoutInfo.rect.x,\n target.dropPosition === 'before' \n ? layoutInfo.rect.y - this.minSpace.height / 2 - this.dropIndicatorThickness / 2\n : layoutInfo.rect.maxY + this.minSpace.height / 2 - this.dropIndicatorThickness / 2,\n layoutInfo.rect.width,\n this.dropIndicatorThickness\n );\n } else {\n rect = new Rect(\n target.dropPosition === 'before' \n ? layoutInfo.rect.x - this.horizontalSpacing / 2 - this.dropIndicatorThickness / 2 \n : layoutInfo.rect.maxX + this.horizontalSpacing / 2 - this.dropIndicatorThickness / 2,\n layoutInfo.rect.y,\n this.dropIndicatorThickness,\n layoutInfo.rect.height\n );\n }\n\n return new LayoutInfo('dropIndicator', target.key + ':' + target.dropPosition, rect);\n }\n}\n"],"names":[],"version":3,"file":"GridLayout.main.js.map"}
1
+ {"mappings":";;;;;;;;AAAA;;;;;;;;;;CAUC;AAiCM,MAAM,kDAA+B,CAAA,GAAA,qCAAK;IAoB/C,SAAe;QACb,IAAI,eAAe,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,KAAK;QAErD,oDAAoD;QACpD,4EAA4E;QAC5E,IAAI,eAAe,KAAK,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE;QACpD,IAAI,gBAAgB,OAAO,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,IACvD,IAAI,CAAC,WAAW,CAAC,MAAM,GACvB,KAAK,KAAK,CAAC,AAAC,IAAI,CAAC,WAAW,CAAC,MAAM,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,GAAI;QAEpE,uEAAuE;QACvE,IAAI,UAAU,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,QAAQ,sBAAsB,IAAI;IAClE;AAiKF","sources":["packages/@react-stately/layout/src/GridLayout.ts"],"sourcesContent":["/*\n * Copyright 2024 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {DropTarget, DropTargetDelegate, ItemDropTarget, Key, Node} from '@react-types/shared';\nimport {Layout, LayoutInfo, Rect, Size} from '@react-stately/virtualizer';\n\nexport interface GridLayoutOptions {\n /**\n * The minimum item size.\n * @default 200 x 200\n */\n minItemSize?: Size,\n /**\n * The maximum item size.\n * @default Infinity\n */\n maxItemSize?: Size,\n /**\n * The minimum space required between items.\n * @default 18 x 18\n */\n minSpace?: Size,\n /**\n * The maximum number of columns.\n * @default Infinity\n */\n maxColumns?: number,\n /**\n * The thickness of the drop indicator.\n * @default 2\n */\n dropIndicatorThickness?: number\n}\n\nexport class GridLayout<T, O = any> extends Layout<Node<T>, O> implements DropTargetDelegate {\n protected minItemSize: Size;\n protected maxItemSize: Size;\n protected minSpace: Size;\n protected maxColumns: number;\n protected dropIndicatorThickness: number;\n protected itemSize: Size;\n protected numColumns: number;\n protected horizontalSpacing: number;\n protected layoutInfos: LayoutInfo[];\n\n constructor(options: GridLayoutOptions) {\n super();\n this.minItemSize = options.minItemSize || new Size(200, 200);\n this.maxItemSize = options.maxItemSize || new Size(Infinity, Infinity);\n this.minSpace = options.minSpace || new Size(18, 18);\n this.maxColumns = options.maxColumns || Infinity;\n this.dropIndicatorThickness = options.dropIndicatorThickness || 2;\n }\n\n update(): void {\n let visibleWidth = this.virtualizer.visibleRect.width;\n\n // The max item width is always the entire viewport.\n // If the max item height is infinity, scale in proportion to the max width.\n let maxItemWidth = Math.min(this.maxItemSize.width, visibleWidth);\n let maxItemHeight = Number.isFinite(this.maxItemSize.height) \n ? this.maxItemSize.height\n : Math.floor((this.minItemSize.height / this.minItemSize.width) * maxItemWidth);\n\n // Compute the number of rows and columns needed to display the content\n let columns = Math.floor(visibleWidth / (this.minItemSize.width + this.minSpace.width));\n this.numColumns = Math.max(1, Math.min(this.maxColumns, columns));\n\n // Compute the available width (minus the space between items)\n let width = visibleWidth - (this.minSpace.width * Math.max(0, this.numColumns));\n\n // Compute the item width based on the space available\n let itemWidth = Math.floor(width / this.numColumns);\n itemWidth = Math.max(this.minItemSize.width, Math.min(maxItemWidth, itemWidth));\n\n // Compute the item height, which is proportional to the item width\n let t = ((itemWidth - this.minItemSize.width) / Math.max(1, maxItemWidth - this.minItemSize.width));\n let itemHeight = this.minItemSize.height + Math.floor((maxItemHeight - this.minItemSize.height) * t);\n itemHeight = Math.max(this.minItemSize.height, Math.min(maxItemHeight, itemHeight));\n this.itemSize = new Size(itemWidth, itemHeight);\n\n // Compute the horizontal spacing and content height\n this.horizontalSpacing = Math.floor((visibleWidth - this.numColumns * this.itemSize.width) / (this.numColumns + 1));\n\n this.layoutInfos = [];\n for (let node of this.virtualizer.collection) {\n this.layoutInfos.push(this.getLayoutInfoForNode(node));\n }\n }\n\n getVisibleLayoutInfos(rect: Rect): LayoutInfo[] {\n let firstVisibleItem = this.getIndexAtPoint(rect.x, rect.y);\n let lastVisibleItem = this.getIndexAtPoint(rect.maxX, rect.maxY);\n let result = this.layoutInfos.slice(firstVisibleItem, lastVisibleItem + 1);\n let persistedIndices: number[] = [];\n for (let key of this.virtualizer.persistedKeys) {\n let item = this.virtualizer.collection.getItem(key);\n if (item?.index != null) {\n persistedIndices.push(item.index);\n }\n }\n persistedIndices.sort((a, b) => a - b);\n \n let persistedBefore: LayoutInfo[] = [];\n for (let index of persistedIndices) {\n if (index < firstVisibleItem) {\n persistedBefore.push(this.layoutInfos[index]);\n } else if (index > lastVisibleItem) {\n result.push(this.layoutInfos[index]);\n }\n }\n result.unshift(...persistedBefore);\n return result;\n }\n\n protected getIndexAtPoint(x: number, y: number) {\n let itemHeight = this.itemSize.height + this.minSpace.height;\n let itemWidth = this.itemSize.width + this.horizontalSpacing;\n return Math.max(0,\n Math.min(\n this.virtualizer.collection.size - 1,\n Math.floor(y / itemHeight) * this.numColumns + Math.floor((x - this.horizontalSpacing) / itemWidth)\n )\n );\n }\n\n getLayoutInfo(key: Key): LayoutInfo | null {\n let node = this.virtualizer.collection.getItem(key);\n return node ? this.layoutInfos[node.index] : null;\n }\n\n protected getLayoutInfoForNode(node: Node<T>): LayoutInfo {\n let idx = node.index;\n let row = Math.floor(idx / this.numColumns);\n let column = idx % this.numColumns;\n let x = this.horizontalSpacing + column * (this.itemSize.width + this.horizontalSpacing);\n let y = this.minSpace.height + row * (this.itemSize.height + this.minSpace.height);\n let rect = new Rect(x, y, this.itemSize.width, this.itemSize.height);\n return new LayoutInfo(node.type, node.key, rect);\n }\n\n getContentSize(): Size {\n let numRows = Math.ceil(this.virtualizer.collection.size / this.numColumns);\n let contentHeight = this.minSpace.height + numRows * (this.itemSize.height + this.minSpace.height); \n return new Size(this.virtualizer.visibleRect.width, contentHeight);\n }\n\n getDropTargetFromPoint(x: number, y: number, isValidDropTarget: (target: DropTarget) => boolean): DropTarget {\n if (this.layoutInfos.length === 0) {\n return {type: 'root'};\n }\n\n x += this.virtualizer.visibleRect.x;\n y += this.virtualizer.visibleRect.y;\n let index = this.getIndexAtPoint(x, y);\n\n let layoutInfo = this.layoutInfos[index];\n let target: DropTarget = {\n type: 'item',\n key: layoutInfo.key,\n dropPosition: 'on'\n };\n\n let pos = this.numColumns === 1 ? y : x;\n let layoutInfoPos = this.numColumns === 1 ? layoutInfo.rect.y : layoutInfo.rect.x;\n let size = this.numColumns === 1 ? layoutInfo.rect.height : layoutInfo.rect.width;\n if (isValidDropTarget(target)) {\n // If dropping on the item is accepted, try the before/after positions\n // if within 5px of the start or end of the item.\n if (pos < layoutInfoPos + 5) {\n target.dropPosition = 'before';\n } else if (pos > layoutInfoPos + size - 5) {\n target.dropPosition = 'after';\n }\n } else {\n // If dropping on the item isn't accepted, try the target before or after depending on the position.\n let mid = layoutInfoPos + size / 2;\n if (pos <= mid && isValidDropTarget({...target, dropPosition: 'before'})) {\n target.dropPosition = 'before';\n } else if (pos >= mid && isValidDropTarget({...target, dropPosition: 'after'})) {\n target.dropPosition = 'after';\n }\n }\n\n return target;\n }\n\n getDropTargetLayoutInfo(target: ItemDropTarget): LayoutInfo {\n let layoutInfo = this.getLayoutInfo(target.key);\n let rect: Rect;\n if (this.numColumns === 1) {\n // Flip from vertical to horizontal if only one column is visible.\n rect = new Rect(\n layoutInfo.rect.x,\n target.dropPosition === 'before' \n ? layoutInfo.rect.y - this.minSpace.height / 2 - this.dropIndicatorThickness / 2\n : layoutInfo.rect.maxY + this.minSpace.height / 2 - this.dropIndicatorThickness / 2,\n layoutInfo.rect.width,\n this.dropIndicatorThickness\n );\n } else {\n rect = new Rect(\n target.dropPosition === 'before' \n ? layoutInfo.rect.x - this.horizontalSpacing / 2 - this.dropIndicatorThickness / 2 \n : layoutInfo.rect.maxX + this.horizontalSpacing / 2 - this.dropIndicatorThickness / 2,\n layoutInfo.rect.y,\n this.dropIndicatorThickness,\n layoutInfo.rect.height\n );\n }\n\n return new LayoutInfo('dropIndicator', target.key + ':' + target.dropPosition, rect);\n }\n}\n"],"names":[],"version":3,"file":"GridLayout.main.js.map"}
@@ -40,9 +40,12 @@ class $a58592d295a170a4$export$7d2b12578154a735 extends (0, $ipgKF$Layout) {
40
40
  let firstVisibleItem = this.getIndexAtPoint(rect.x, rect.y);
41
41
  let lastVisibleItem = this.getIndexAtPoint(rect.maxX, rect.maxY);
42
42
  let result = this.layoutInfos.slice(firstVisibleItem, lastVisibleItem + 1);
43
- let persistedIndices = [
44
- ...this.virtualizer.persistedKeys
45
- ].map((key)=>this.virtualizer.collection.getItem(key).index).sort((a, b)=>a - b);
43
+ let persistedIndices = [];
44
+ for (let key of this.virtualizer.persistedKeys){
45
+ let item = this.virtualizer.collection.getItem(key);
46
+ if ((item === null || item === void 0 ? void 0 : item.index) != null) persistedIndices.push(item.index);
47
+ }
48
+ persistedIndices.sort((a, b)=>a - b);
46
49
  let persistedBefore = [];
47
50
  for (let index of persistedIndices){
48
51
  if (index < firstVisibleItem) persistedBefore.push(this.layoutInfos[index]);
@@ -40,9 +40,12 @@ class $a58592d295a170a4$export$7d2b12578154a735 extends (0, $ipgKF$Layout) {
40
40
  let firstVisibleItem = this.getIndexAtPoint(rect.x, rect.y);
41
41
  let lastVisibleItem = this.getIndexAtPoint(rect.maxX, rect.maxY);
42
42
  let result = this.layoutInfos.slice(firstVisibleItem, lastVisibleItem + 1);
43
- let persistedIndices = [
44
- ...this.virtualizer.persistedKeys
45
- ].map((key)=>this.virtualizer.collection.getItem(key).index).sort((a, b)=>a - b);
43
+ let persistedIndices = [];
44
+ for (let key of this.virtualizer.persistedKeys){
45
+ let item = this.virtualizer.collection.getItem(key);
46
+ if ((item === null || item === void 0 ? void 0 : item.index) != null) persistedIndices.push(item.index);
47
+ }
48
+ persistedIndices.sort((a, b)=>a - b);
46
49
  let persistedBefore = [];
47
50
  for (let index of persistedIndices){
48
51
  if (index < firstVisibleItem) persistedBefore.push(this.layoutInfos[index]);
@@ -1 +1 @@
1
- {"mappings":";;AAAA;;;;;;;;;;CAUC;AAiCM,MAAM,kDAA+B,CAAA,GAAA,aAAK;IAoB/C,SAAe;QACb,IAAI,eAAe,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,KAAK;QAErD,oDAAoD;QACpD,4EAA4E;QAC5E,IAAI,eAAe,KAAK,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE;QACpD,IAAI,gBAAgB,OAAO,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,IACvD,IAAI,CAAC,WAAW,CAAC,MAAM,GACvB,KAAK,KAAK,CAAC,AAAC,I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AsB,IAAI;IAClE;AAyJF","sources":["packages/@react-stately/layout/src/GridLayout.ts"],"sourcesContent":["/*\n * Copyright 2024 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {DropTarget, DropTargetDelegate, ItemDropTarget, Key, Node} from '@react-types/shared';\nimport {Layout, LayoutInfo, Rect, Size} from '@react-stately/virtualizer';\n\nexport interface GridLayoutOptions {\n /**\n * The minimum item size.\n * @default 200 x 200\n */\n minItemSize?: Size,\n /**\n * The maximum item size.\n * @default Infinity\n */\n maxItemSize?: Size,\n /**\n * The minimum space required between items.\n * @default 18 x 18\n */\n minSpace?: Size,\n /**\n * The maximum number of columns.\n * @default Infinity\n */\n maxColumns?: number,\n /**\n * The thickness of the drop indicator.\n * @default 2\n */\n dropIndicatorThickness?: number\n}\n\nexport class GridLayout<T, O = any> extends Layout<Node<T>, O> implements DropTargetDelegate {\n protected minItemSize: Size;\n protected maxItemSize: Size;\n protected minSpace: Size;\n protected maxColumns: number;\n protected dropIndicatorThickness: number;\n protected itemSize: Size;\n protected numColumns: number;\n protected horizontalSpacing: number;\n protected layoutInfos: LayoutInfo[];\n\n constructor(options: GridLayoutOptions) {\n super();\n this.minItemSize = options.minItemSize || new Size(200, 200);\n this.maxItemSize = options.maxItemSize || new Size(Infinity, Infinity);\n this.minSpace = options.minSpace || new Size(18, 18);\n this.maxColumns = options.maxColumns || Infinity;\n this.dropIndicatorThickness = options.dropIndicatorThickness || 2;\n }\n\n update(): void {\n let visibleWidth = this.virtualizer.visibleRect.width;\n\n // The max item width is always the entire viewport.\n // If the max item height is infinity, scale in proportion to the max width.\n let maxItemWidth = Math.min(this.maxItemSize.width, visibleWidth);\n let maxItemHeight = Number.isFinite(this.maxItemSize.height) \n ? this.maxItemSize.height\n : Math.floor((this.minItemSize.height / this.minItemSize.width) * maxItemWidth);\n\n // Compute the number of rows and columns needed to display the content\n let columns = Math.floor(visibleWidth / (this.minItemSize.width + this.minSpace.width));\n this.numColumns = Math.max(1, Math.min(this.maxColumns, columns));\n\n // Compute the available width (minus the space between items)\n let width = visibleWidth - (this.minSpace.width * Math.max(0, this.numColumns));\n\n // Compute the item width based on the space available\n let itemWidth = Math.floor(width / this.numColumns);\n itemWidth = Math.max(this.minItemSize.width, Math.min(maxItemWidth, itemWidth));\n\n // Compute the item height, which is proportional to the item width\n let t = ((itemWidth - this.minItemSize.width) / Math.max(1, maxItemWidth - this.minItemSize.width));\n let itemHeight = this.minItemSize.height + Math.floor((maxItemHeight - this.minItemSize.height) * t);\n itemHeight = Math.max(this.minItemSize.height, Math.min(maxItemHeight, itemHeight));\n this.itemSize = new Size(itemWidth, itemHeight);\n\n // Compute the horizontal spacing and content height\n this.horizontalSpacing = Math.floor((visibleWidth - this.numColumns * this.itemSize.width) / (this.numColumns + 1));\n\n this.layoutInfos = [];\n for (let node of this.virtualizer.collection) {\n this.layoutInfos.push(this.getLayoutInfoForNode(node));\n }\n }\n\n getVisibleLayoutInfos(rect: Rect): LayoutInfo[] {\n let firstVisibleItem = this.getIndexAtPoint(rect.x, rect.y);\n let lastVisibleItem = this.getIndexAtPoint(rect.maxX, rect.maxY);\n let result = this.layoutInfos.slice(firstVisibleItem, lastVisibleItem + 1);\n let persistedIndices = [...this.virtualizer.persistedKeys].map(key => this.virtualizer.collection.getItem(key).index).sort((a, b) => a - b);\n let persistedBefore = [];\n for (let index of persistedIndices) {\n if (index < firstVisibleItem) {\n persistedBefore.push(this.layoutInfos[index]);\n } else if (index > lastVisibleItem) {\n result.push(this.layoutInfos[index]);\n }\n }\n result.unshift(...persistedBefore);\n return result;\n }\n\n protected getIndexAtPoint(x: number, y: number) {\n let itemHeight = this.itemSize.height + this.minSpace.height;\n let itemWidth = this.itemSize.width + this.horizontalSpacing;\n return Math.max(0,\n Math.min(\n this.virtualizer.collection.size - 1,\n Math.floor(y / itemHeight) * this.numColumns + Math.floor((x - this.horizontalSpacing) / itemWidth)\n )\n );\n }\n\n getLayoutInfo(key: Key): LayoutInfo | null {\n let node = this.virtualizer.collection.getItem(key);\n return node ? this.layoutInfos[node.index] : null;\n }\n\n protected getLayoutInfoForNode(node: Node<T>): LayoutInfo {\n let idx = node.index;\n let row = Math.floor(idx / this.numColumns);\n let column = idx % this.numColumns;\n let x = this.horizontalSpacing + column * (this.itemSize.width + this.horizontalSpacing);\n let y = this.minSpace.height + row * (this.itemSize.height + this.minSpace.height);\n let rect = new Rect(x, y, this.itemSize.width, this.itemSize.height);\n return new LayoutInfo(node.type, node.key, rect);\n }\n\n getContentSize(): Size {\n let numRows = Math.ceil(this.virtualizer.collection.size / this.numColumns);\n let contentHeight = this.minSpace.height + numRows * (this.itemSize.height + this.minSpace.height); \n return new Size(this.virtualizer.visibleRect.width, contentHeight);\n }\n\n getDropTargetFromPoint(x: number, y: number, isValidDropTarget: (target: DropTarget) => boolean): DropTarget {\n if (this.layoutInfos.length === 0) {\n return {type: 'root'};\n }\n\n x += this.virtualizer.visibleRect.x;\n y += this.virtualizer.visibleRect.y;\n let index = this.getIndexAtPoint(x, y);\n\n let layoutInfo = this.layoutInfos[index];\n let target: DropTarget = {\n type: 'item',\n key: layoutInfo.key,\n dropPosition: 'on'\n };\n\n let pos = this.numColumns === 1 ? y : x;\n let layoutInfoPos = this.numColumns === 1 ? layoutInfo.rect.y : layoutInfo.rect.x;\n let size = this.numColumns === 1 ? layoutInfo.rect.height : layoutInfo.rect.width;\n if (isValidDropTarget(target)) {\n // If dropping on the item is accepted, try the before/after positions\n // if within 5px of the start or end of the item.\n if (pos < layoutInfoPos + 5) {\n target.dropPosition = 'before';\n } else if (pos > layoutInfoPos + size - 5) {\n target.dropPosition = 'after';\n }\n } else {\n // If dropping on the item isn't accepted, try the target before or after depending on the position.\n let mid = layoutInfoPos + size / 2;\n if (pos <= mid && isValidDropTarget({...target, dropPosition: 'before'})) {\n target.dropPosition = 'before';\n } else if (pos >= mid && isValidDropTarget({...target, dropPosition: 'after'})) {\n target.dropPosition = 'after';\n }\n }\n\n return target;\n }\n\n getDropTargetLayoutInfo(target: ItemDropTarget): LayoutInfo {\n let layoutInfo = this.getLayoutInfo(target.key);\n let rect: Rect;\n if (this.numColumns === 1) {\n // Flip from vertical to horizontal if only one column is visible.\n rect = new Rect(\n layoutInfo.rect.x,\n target.dropPosition === 'before' \n ? layoutInfo.rect.y - this.minSpace.height / 2 - this.dropIndicatorThickness / 2\n : layoutInfo.rect.maxY + this.minSpace.height / 2 - this.dropIndicatorThickness / 2,\n layoutInfo.rect.width,\n this.dropIndicatorThickness\n );\n } else {\n rect = new Rect(\n target.dropPosition === 'before' \n ? layoutInfo.rect.x - this.horizontalSpacing / 2 - this.dropIndicatorThickness / 2 \n : layoutInfo.rect.maxX + this.horizontalSpacing / 2 - this.dropIndicatorThickness / 2,\n layoutInfo.rect.y,\n this.dropIndicatorThickness,\n layoutInfo.rect.height\n );\n }\n\n return new LayoutInfo('dropIndicator', target.key + ':' + target.dropPosition, rect);\n }\n}\n"],"names":[],"version":3,"file":"GridLayout.module.js.map"}
1
+ {"mappings":";;AAAA;;;;;;;;;;CAUC;AAiCM,MAAM,kDAA+B,CAAA,GAAA,aAAK;IAoB/C,SAAe;QACb,IAAI,eAAe,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,KAAK;QAErD,oDAAoD;QACpD,4EAA4E;QAC5E,IAAI,eAAe,KAAK,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE;QACpD,IAAI,gBAAgB,OAAO,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,IACvD,IAAI,CAAC,WAAW,CAAC,MAAM,GACvB,KAAK,KAAK,CAAC,AAAC,IAAI,CA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,IAAI;QACjD,IAAI,CAAC,UAAU,GAAG,QAAQ,UAAU,IAAI;QACxC,IAAI,CAAC,sBAAsB,GAAG,QAAQ,sBAAsB,IAAI;IAClE;AAiKF","sources":["packages/@react-stately/layout/src/GridLayout.ts"],"sourcesContent":["/*\n * Copyright 2024 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {DropTarget, DropTargetDelegate, ItemDropTarget, Key, Node} from '@react-types/shared';\nimport {Layout, LayoutInfo, Rect, Size} from '@react-stately/virtualizer';\n\nexport interface GridLayoutOptions {\n /**\n * The minimum item size.\n * @default 200 x 200\n */\n minItemSize?: Size,\n /**\n * The maximum item size.\n * @default Infinity\n */\n maxItemSize?: Size,\n /**\n * The minimum space required between items.\n * @default 18 x 18\n */\n minSpace?: Size,\n /**\n * The maximum number of columns.\n * @default Infinity\n */\n maxColumns?: number,\n /**\n * The thickness of the drop indicator.\n * @default 2\n */\n dropIndicatorThickness?: number\n}\n\nexport class GridLayout<T, O = any> extends Layout<Node<T>, O> implements DropTargetDelegate {\n protected minItemSize: Size;\n protected maxItemSize: Size;\n protected minSpace: Size;\n protected maxColumns: number;\n protected dropIndicatorThickness: number;\n protected itemSize: Size;\n protected numColumns: number;\n protected horizontalSpacing: number;\n protected layoutInfos: LayoutInfo[];\n\n constructor(options: GridLayoutOptions) {\n super();\n this.minItemSize = options.minItemSize || new Size(200, 200);\n this.maxItemSize = options.maxItemSize || new Size(Infinity, Infinity);\n this.minSpace = options.minSpace || new Size(18, 18);\n this.maxColumns = options.maxColumns || Infinity;\n this.dropIndicatorThickness = options.dropIndicatorThickness || 2;\n }\n\n update(): void {\n let visibleWidth = this.virtualizer.visibleRect.width;\n\n // The max item width is always the entire viewport.\n // If the max item height is infinity, scale in proportion to the max width.\n let maxItemWidth = Math.min(this.maxItemSize.width, visibleWidth);\n let maxItemHeight = Number.isFinite(this.maxItemSize.height) \n ? this.maxItemSize.height\n : Math.floor((this.minItemSize.height / this.minItemSize.width) * maxItemWidth);\n\n // Compute the number of rows and columns needed to display the content\n let columns = Math.floor(visibleWidth / (this.minItemSize.width + this.minSpace.width));\n this.numColumns = Math.max(1, Math.min(this.maxColumns, columns));\n\n // Compute the available width (minus the space between items)\n let width = visibleWidth - (this.minSpace.width * Math.max(0, this.numColumns));\n\n // Compute the item width based on the space available\n let itemWidth = Math.floor(width / this.numColumns);\n itemWidth = Math.max(this.minItemSize.width, Math.min(maxItemWidth, itemWidth));\n\n // Compute the item height, which is proportional to the item width\n let t = ((itemWidth - this.minItemSize.width) / Math.max(1, maxItemWidth - this.minItemSize.width));\n let itemHeight = this.minItemSize.height + Math.floor((maxItemHeight - this.minItemSize.height) * t);\n itemHeight = Math.max(this.minItemSize.height, Math.min(maxItemHeight, itemHeight));\n this.itemSize = new Size(itemWidth, itemHeight);\n\n // Compute the horizontal spacing and content height\n this.horizontalSpacing = Math.floor((visibleWidth - this.numColumns * this.itemSize.width) / (this.numColumns + 1));\n\n this.layoutInfos = [];\n for (let node of this.virtualizer.collection) {\n this.layoutInfos.push(this.getLayoutInfoForNode(node));\n }\n }\n\n getVisibleLayoutInfos(rect: Rect): LayoutInfo[] {\n let firstVisibleItem = this.getIndexAtPoint(rect.x, rect.y);\n let lastVisibleItem = this.getIndexAtPoint(rect.maxX, rect.maxY);\n let result = this.layoutInfos.slice(firstVisibleItem, lastVisibleItem + 1);\n let persistedIndices: number[] = [];\n for (let key of this.virtualizer.persistedKeys) {\n let item = this.virtualizer.collection.getItem(key);\n if (item?.index != null) {\n persistedIndices.push(item.index);\n }\n }\n persistedIndices.sort((a, b) => a - b);\n \n let persistedBefore: LayoutInfo[] = [];\n for (let index of persistedIndices) {\n if (index < firstVisibleItem) {\n persistedBefore.push(this.layoutInfos[index]);\n } else if (index > lastVisibleItem) {\n result.push(this.layoutInfos[index]);\n }\n }\n result.unshift(...persistedBefore);\n return result;\n }\n\n protected getIndexAtPoint(x: number, y: number) {\n let itemHeight = this.itemSize.height + this.minSpace.height;\n let itemWidth = this.itemSize.width + this.horizontalSpacing;\n return Math.max(0,\n Math.min(\n this.virtualizer.collection.size - 1,\n Math.floor(y / itemHeight) * this.numColumns + Math.floor((x - this.horizontalSpacing) / itemWidth)\n )\n );\n }\n\n getLayoutInfo(key: Key): LayoutInfo | null {\n let node = this.virtualizer.collection.getItem(key);\n return node ? this.layoutInfos[node.index] : null;\n }\n\n protected getLayoutInfoForNode(node: Node<T>): LayoutInfo {\n let idx = node.index;\n let row = Math.floor(idx / this.numColumns);\n let column = idx % this.numColumns;\n let x = this.horizontalSpacing + column * (this.itemSize.width + this.horizontalSpacing);\n let y = this.minSpace.height + row * (this.itemSize.height + this.minSpace.height);\n let rect = new Rect(x, y, this.itemSize.width, this.itemSize.height);\n return new LayoutInfo(node.type, node.key, rect);\n }\n\n getContentSize(): Size {\n let numRows = Math.ceil(this.virtualizer.collection.size / this.numColumns);\n let contentHeight = this.minSpace.height + numRows * (this.itemSize.height + this.minSpace.height); \n return new Size(this.virtualizer.visibleRect.width, contentHeight);\n }\n\n getDropTargetFromPoint(x: number, y: number, isValidDropTarget: (target: DropTarget) => boolean): DropTarget {\n if (this.layoutInfos.length === 0) {\n return {type: 'root'};\n }\n\n x += this.virtualizer.visibleRect.x;\n y += this.virtualizer.visibleRect.y;\n let index = this.getIndexAtPoint(x, y);\n\n let layoutInfo = this.layoutInfos[index];\n let target: DropTarget = {\n type: 'item',\n key: layoutInfo.key,\n dropPosition: 'on'\n };\n\n let pos = this.numColumns === 1 ? y : x;\n let layoutInfoPos = this.numColumns === 1 ? layoutInfo.rect.y : layoutInfo.rect.x;\n let size = this.numColumns === 1 ? layoutInfo.rect.height : layoutInfo.rect.width;\n if (isValidDropTarget(target)) {\n // If dropping on the item is accepted, try the before/after positions\n // if within 5px of the start or end of the item.\n if (pos < layoutInfoPos + 5) {\n target.dropPosition = 'before';\n } else if (pos > layoutInfoPos + size - 5) {\n target.dropPosition = 'after';\n }\n } else {\n // If dropping on the item isn't accepted, try the target before or after depending on the position.\n let mid = layoutInfoPos + size / 2;\n if (pos <= mid && isValidDropTarget({...target, dropPosition: 'before'})) {\n target.dropPosition = 'before';\n } else if (pos >= mid && isValidDropTarget({...target, dropPosition: 'after'})) {\n target.dropPosition = 'after';\n }\n }\n\n return target;\n }\n\n getDropTargetLayoutInfo(target: ItemDropTarget): LayoutInfo {\n let layoutInfo = this.getLayoutInfo(target.key);\n let rect: Rect;\n if (this.numColumns === 1) {\n // Flip from vertical to horizontal if only one column is visible.\n rect = new Rect(\n layoutInfo.rect.x,\n target.dropPosition === 'before' \n ? layoutInfo.rect.y - this.minSpace.height / 2 - this.dropIndicatorThickness / 2\n : layoutInfo.rect.maxY + this.minSpace.height / 2 - this.dropIndicatorThickness / 2,\n layoutInfo.rect.width,\n this.dropIndicatorThickness\n );\n } else {\n rect = new Rect(\n target.dropPosition === 'before' \n ? layoutInfo.rect.x - this.horizontalSpacing / 2 - this.dropIndicatorThickness / 2 \n : layoutInfo.rect.maxX + this.horizontalSpacing / 2 - this.dropIndicatorThickness / 2,\n layoutInfo.rect.y,\n this.dropIndicatorThickness,\n layoutInfo.rect.height\n );\n }\n\n return new LayoutInfo('dropIndicator', target.key + ':' + target.dropPosition, rect);\n }\n}\n"],"names":[],"version":3,"file":"GridLayout.module.js.map"}
@@ -1 +1 @@
1
- {"mappings":";;;;AAeA;IACE;;;OAGG;IACH,WAAW,CAAC,EAAE,IAAI,CAAC;IACnB;;;OAGG;IACH,WAAW,CAAC,EAAE,IAAI,CAAC;IACnB;;;OAGG;IACH,QAAQ,CAAC,EAAE,IAAI,CAAC;IAChB;;;OAGG;IACH,UAAU,CAAC,EAA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AI,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,UAAU;IAyCvE,SAAS,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,UAAU;IAiBxE,qBAAqB,CAAC,IAAI,EAAE,IAAI;IA4KhC,sBAAsB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,iBAAiB,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,OAAO,GAAG,UAAU;IAgD5G,uBAAuB,CAAC,MAAM,EAAE,cAAc,GAAG,UAAU;CAK5D","sources":["packages/@react-stately/layout/src/packages/@react-stately/layout/src/GridLayout.ts","packages/@react-stately/layout/src/packages/@react-stately/layout/src/ListLayout.ts","packages/@react-stately/layout/src/packages/@react-stately/layout/src/TableLayout.ts","packages/@react-stately/layout/src/packages/@react-stately/layout/src/index.ts","packages/@react-stately/layout/src/index.ts"],"sourcesContent":[null,null,null,null,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nexport type {GridLayoutOptions} from './GridLayout';\nexport type {ListLayoutOptions, LayoutNode} from './ListLayout';\nexport type {TableLayoutProps} from './TableLayout';\nexport {GridLayout} from './GridLayout';\nexport {ListLayout} from './ListLayout';\nexport {TableLayout} from './TableLayout';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
1
+ {"mappings":";;;;AAeA;IACE;;;OAGG;IACH,WAAW,CAAC,EAAE,IAAI,CAAC;IACnB;;;OAG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I,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,UAAU;IAkBxE,SAAS,CAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,UAAU;IAyCvE,SAAS,CAAC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,UAAU;IAiBxE,qBAAqB,CAAC,IAAI,EAAE,IAAI;IA4KhC,sBAAsB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,iBAAiB,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,OAAO,GAAG,UAAU;IAgD5G,uBAAuB,CAAC,MAAM,EAAE,cAAc,GAAG,UAAU;CAK5D","sources":["packages/@react-stately/layout/src/packages/@react-stately/layout/src/GridLayout.ts","packages/@react-stately/layout/src/packages/@react-stately/layout/src/ListLayout.ts","packages/@react-stately/layout/src/packages/@react-stately/layout/src/TableLayout.ts","packages/@react-stately/layout/src/packages/@react-stately/layout/src/index.ts","packages/@react-stately/layout/src/index.ts"],"sourcesContent":[null,null,null,null,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nexport type {GridLayoutOptions} from './GridLayout';\nexport type {ListLayoutOptions, LayoutNode} from './ListLayout';\nexport type {TableLayoutProps} from './TableLayout';\nexport {GridLayout} from './GridLayout';\nexport {ListLayout} from './ListLayout';\nexport {TableLayout} from './TableLayout';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-stately/layout",
3
- "version": "3.13.10-nightly.4723+9b48ec5d5",
3
+ "version": "3.13.10-nightly.4730+927758756",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -22,12 +22,12 @@
22
22
  "url": "https://github.com/adobe/react-spectrum"
23
23
  },
24
24
  "dependencies": {
25
- "@react-stately/collections": "3.0.0-nightly.3011+9b48ec5d5",
26
- "@react-stately/table": "3.11.9-nightly.4723+9b48ec5d5",
27
- "@react-stately/virtualizer": "3.7.2-nightly.4723+9b48ec5d5",
28
- "@react-types/grid": "3.2.7-nightly.4723+9b48ec5d5",
29
- "@react-types/shared": "3.0.0-nightly.3011+9b48ec5d5",
30
- "@react-types/table": "3.9.6-nightly.4723+9b48ec5d5",
25
+ "@react-stately/collections": "3.0.0-nightly.3018+927758756",
26
+ "@react-stately/table": "3.11.9-nightly.4730+927758756",
27
+ "@react-stately/virtualizer": "3.7.2-nightly.4730+927758756",
28
+ "@react-types/grid": "3.2.7-nightly.4730+927758756",
29
+ "@react-types/shared": "3.0.0-nightly.3018+927758756",
30
+ "@react-types/table": "3.9.6-nightly.4730+927758756",
31
31
  "@swc/helpers": "^0.5.0"
32
32
  },
33
33
  "peerDependencies": {
@@ -36,5 +36,5 @@
36
36
  "publishConfig": {
37
37
  "access": "public"
38
38
  },
39
- "gitHead": "9b48ec5d528adeba1a96592945459726def7ba56"
39
+ "gitHead": "92775875627ef8a038a4708b1a7addf11809bf35"
40
40
  }
package/src/GridLayout.ts CHANGED
@@ -101,8 +101,16 @@ export class GridLayout<T, O = any> extends Layout<Node<T>, O> implements DropTa
101
101
  let firstVisibleItem = this.getIndexAtPoint(rect.x, rect.y);
102
102
  let lastVisibleItem = this.getIndexAtPoint(rect.maxX, rect.maxY);
103
103
  let result = this.layoutInfos.slice(firstVisibleItem, lastVisibleItem + 1);
104
- let persistedIndices = [...this.virtualizer.persistedKeys].map(key => this.virtualizer.collection.getItem(key).index).sort((a, b) => a - b);
105
- let persistedBefore = [];
104
+ let persistedIndices: number[] = [];
105
+ for (let key of this.virtualizer.persistedKeys) {
106
+ let item = this.virtualizer.collection.getItem(key);
107
+ if (item?.index != null) {
108
+ persistedIndices.push(item.index);
109
+ }
110
+ }
111
+ persistedIndices.sort((a, b) => a - b);
112
+
113
+ let persistedBefore: LayoutInfo[] = [];
106
114
  for (let index of persistedIndices) {
107
115
  if (index < firstVisibleItem) {
108
116
  persistedBefore.push(this.layoutInfos[index]);