@react-stately/layout 4.0.3 → 4.1.0

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.
@@ -1 +1 @@
1
- {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAgCD,MAAM,uCAAiB;AAUhB,MAAM,kDAA+B,CAAA,GAAA,aAAK;IAwC/C,cAAc,GAAQ,EAAE;YAEf;QADP,IAAI,CAAC,gBAAgB,CAAC;QACtB,OAAO,EAAA,wBAAA,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,kBAArB,4CAAA,sBAA2B,UAAU,KAAI;IAClD;IAEA,sBAAsB,IAAU,EAAE;QAChC,yDAAyD;QACzD,kDAAkD;QAClD,IAAI,KAAK,MAAM,GAAG,GAAG;gBACF;YAAjB,IAAI,YAAa,CAAA,kBAAA,IAAI,CAAC,SAAS,cAAd,6BAAA,kBAAkB,IAAI,CAAC,kBAAkB;YAC1D,KAAK,CAAC,GAAG,KAAK,KAAK,CAAC,KAAK,CAAC,GAAG,aAAa;YAC1C,KAAK,MAAM,GAAG,KAAK,IAAI,CAAC,KAAK,MAAM,GAAG,aAAa;QACrD;QAEA,mEAAmE;QACnE,wDAAwD;QACxD,IAAI,CAAC,cAAc,CAAC;QAEpB,IAAI,MAAoB,EAAE;QAE1B,IAAI,WAAW,CAAC;YACd,KAAK,IAAI,QAAQ,MACf,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,OAAO;gBAC9B,IAAI,IAAI,CAAC,KAAK,UAAU;gBAExB,IAAI,KAAK,QAAQ,EACf,SAAS,KAAK,QAAQ;YAE1B;QAEJ;QAEA,SAAS,IAAI,CAAC,SAAS;QACvB,OAAO;IACT;IAEU,eAAe,IAAU,EAAE;QACnC,IAAI,CAAC,IAAI,CAAC,cAAc,EACtB;QAGF,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,OAAO;YAC1C,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,C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AG;IAC5B;AAiZF","sources":["packages/@react-stately/layout/src/ListLayout.ts"],"sourcesContent":["/*\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 */\n\nimport {Collection, DropTarget, DropTargetDelegate, ItemDropTarget, Key, Node} from '@react-types/shared';\nimport {getChildNodes} from '@react-stately/collections';\nimport {InvalidationContext, Layout, LayoutInfo, Point, Rect, Size} from '@react-stately/virtualizer';\n\nexport interface ListLayoutOptions {\n /** The fixed height of a row in px. */\n rowHeight?: number,\n /** The estimated height of a row, when row heights are variable. */\n estimatedRowHeight?: number,\n /** The fixed height of a section header in px. */\n headingHeight?: number,\n /** The estimated height of a section header, when the height is variable. */\n estimatedHeadingHeight?: number,\n /** The fixed height of a loader element in px. This loader is specifically for\n * \"load more\" elements rendered when loading more rows at the root level or inside nested row/sections.\n */\n loaderHeight?: number,\n /** The thickness of the drop indicator. */\n dropIndicatorThickness?: number\n}\n\n// A wrapper around LayoutInfo that supports hierarchy\nexport interface LayoutNode {\n node?: Node<unknown>,\n layoutInfo: LayoutInfo,\n children?: LayoutNode[],\n validRect: Rect,\n index?: number\n}\n\nconst DEFAULT_HEIGHT = 48;\n\n/**\n * The ListLayout class is an implementation of a virtualizer {@link Layout}.\n * To configure a ListLayout, you can use the properties to define the\n * layouts and/or use the method for defining indentation.\n * The {@link ListKeyboardDelegate} extends the existing virtualizer\n * delegate with an additional method to do this (it uses the same delegate object as\n * the virtualizer itself).\n */\nexport class ListLayout<T, O = any> extends Layout<Node<T>, O> implements DropTargetDelegate {\n protected rowHeight: number;\n protected estimatedRowHeight: number;\n protected headingHeight: number;\n protected estimatedHeadingHeight: number;\n protected loaderHeight: number;\n protected dropIndicatorThickness: number;\n protected layoutNodes: Map<Key, LayoutNode>;\n protected contentSize: Size;\n protected collection: Collection<Node<T>>;\n private lastCollection: Collection<Node<T>>;\n private lastWidth: number;\n protected rootNodes: LayoutNode[];\n private invalidateEverything: boolean;\n /** The rectangle containing currently valid layout infos. */\n protected validRect: Rect;\n /** The rectangle of requested layout infos so far. */\n protected requestedRect: Rect;\n\n /**\n * Creates a new ListLayout with options. See the list of properties below for a description\n * of the options that can be provided.\n */\n constructor(options: ListLayoutOptions = {}) {\n super();\n this.rowHeight = options.rowHeight;\n this.estimatedRowHeight = options.estimatedRowHeight;\n this.headingHeight = options.headingHeight;\n this.estimatedHeadingHeight = options.estimatedHeadingHeight;\n this.loaderHeight = options.loaderHeight;\n this.dropIndicatorThickness = options.dropIndicatorThickness || 2;\n this.layoutNodes = new Map();\n this.rootNodes = [];\n this.lastWidth = 0;\n this.lastCollection = null;\n this.validRect = new Rect();\n this.requestedRect = new Rect();\n this.contentSize = new Size();\n }\n\n getLayoutInfo(key: Key) {\n this.ensureLayoutInfo(key);\n return this.layoutNodes.get(key)?.layoutInfo || null;\n }\n\n getVisibleLayoutInfos(rect: Rect) {\n // Adjust rect to keep number of visible rows consistent.\n // (only if height > 1 for getDropTargetFromPoint)\n if (rect.height > 1) {\n let rowHeight = (this.rowHeight ?? this.estimatedRowHeight);\n rect.y = Math.floor(rect.y / rowHeight) * rowHeight;\n rect.height = Math.ceil(rect.height / rowHeight) * rowHeight;\n }\n\n // If layout hasn't yet been done for the requested rect, union the\n // new rect with the existing valid rect, and recompute.\n this.layoutIfNeeded(rect);\n\n let res: LayoutInfo[] = [];\n\n let addNodes = (nodes: LayoutNode[]) => {\n for (let node of nodes) {\n if (this.isVisible(node, rect)) {\n res.push(node.layoutInfo);\n\n if (node.children) {\n addNodes(node.children);\n }\n }\n }\n };\n\n addNodes(this.rootNodes);\n return res;\n }\n\n protected layoutIfNeeded(rect: Rect) {\n if (!this.lastCollection) {\n return;\n }\n\n if (!this.requestedRect.containsRect(rect)) {\n this.requestedRect = this.requestedRect.union(rect);\n this.rootNodes = this.buildCollection();\n }\n \n // Ensure all of the persisted keys are available.\n for (let key of this.virtualizer.persistedKeys) {\n if (this.ensureLayoutInfo(key)) {\n return;\n }\n }\n }\n\n private ensureLayoutInfo(key: Key) {\n // If the layout info wasn't found, it might be outside the bounds of the area that we've\n // computed layout for so far. This can happen when accessing a random key, e.g pressing Home/End.\n // Compute the full layout and try again.\n if (!this.layoutNodes.has(key) && this.requestedRect.area < this.contentSize.area && this.lastCollection) {\n this.requestedRect = new Rect(0, 0, Infinity, Infinity);\n this.rootNodes = this.buildCollection();\n this.requestedRect = new Rect(0, 0, this.contentSize.width, this.contentSize.height);\n return true;\n }\n\n return false;\n }\n\n protected isVisible(node: LayoutNode, rect: Rect) {\n return node.layoutInfo.rect.intersects(rect) || node.layoutInfo.isSticky || node.layoutInfo.type === 'header' || this.virtualizer.isPersistedKey(node.layoutInfo.key);\n }\n\n protected shouldInvalidateEverything(invalidationContext: InvalidationContext<O>) {\n // Invalidate cache if the size of the collection changed.\n // In this case, we need to recalculate the entire layout.\n return invalidationContext.sizeChanged;\n }\n\n update(invalidationContext: InvalidationContext<O>) {\n this.collection = this.virtualizer.collection;\n\n // Reset valid rect if we will have to invalidate everything.\n // Otherwise we can reuse cached layout infos outside the current visible rect.\n this.invalidateEverything = this.shouldInvalidateEverything(invalidationContext);\n if (this.invalidateEverything) {\n this.requestedRect = this.virtualizer.visibleRect.copy();\n this.layoutNodes.clear();\n }\n\n this.rootNodes = this.buildCollection();\n\n // Remove deleted layout nodes\n if (this.lastCollection && this.collection !== this.lastCollection) {\n for (let key of this.lastCollection.getKeys()) {\n if (!this.collection.getItem(key)) {\n let layoutNode = this.layoutNodes.get(key);\n if (layoutNode) {\n this.layoutNodes.delete(key);\n }\n }\n }\n }\n\n this.lastWidth = this.virtualizer.visibleRect.width;\n this.lastCollection = this.collection;\n this.invalidateEverything = false;\n this.validRect = this.requestedRect.copy();\n }\n\n protected buildCollection(y = 0): LayoutNode[] {\n let skipped = 0;\n let nodes = [];\n for (let node of this.collection) {\n let rowHeight = this.rowHeight ?? this.estimatedRowHeight;\n\n // Skip rows before the valid rectangle unless they are already cached.\n if (node.type === 'item' && y + rowHeight < this.requestedRect.y && !this.isValid(node, y)) {\n y += rowHeight;\n skipped++;\n continue;\n }\n\n let layoutNode = this.buildChild(node, 0, y, null);\n y = layoutNode.layoutInfo.rect.maxY;\n nodes.push(layoutNode);\n\n if (node.type === 'item' && y > this.requestedRect.maxY) {\n y += (this.collection.size - (nodes.length + skipped)) * rowHeight;\n break;\n }\n }\n\n this.contentSize = new Size(this.virtualizer.visibleRect.width, y);\n return nodes;\n }\n\n protected isValid(node: Node<T>, y: number) {\n let cached = this.layoutNodes.get(node.key);\n return (\n !this.invalidateEverything &&\n cached &&\n cached.node === node &&\n y === cached.layoutInfo.rect.y &&\n cached.layoutInfo.rect.intersects(this.validRect) &&\n cached.validRect.containsRect(cached.layoutInfo.rect.intersection(this.requestedRect))\n );\n }\n\n protected buildChild(node: Node<T>, x: number, y: number, parentKey: Key | null): LayoutNode {\n if (this.isValid(node, y)) {\n return this.layoutNodes.get(node.key);\n }\n\n let layoutNode = this.buildNode(node, x, y);\n\n layoutNode.layoutInfo.parentKey = parentKey ?? null;\n this.layoutNodes.set(node.key, layoutNode);\n return layoutNode;\n }\n\n protected buildNode(node: Node<T>, x: number, y: number): LayoutNode {\n switch (node.type) {\n case 'section':\n return this.buildSection(node, x, y);\n case 'item':\n return this.buildItem(node, x, y);\n case 'header':\n return this.buildSectionHeader(node, x, y);\n case 'loader':\n return this.buildLoader(node, x, y);\n }\n }\n\n protected buildLoader(node: Node<T>, x: number, y: number): LayoutNode {\n let rect = new Rect(x, y, 0, 0);\n let layoutInfo = new LayoutInfo('loader', node.key, rect);\n rect.width = this.virtualizer.contentSize.width;\n rect.height = this.loaderHeight || this.rowHeight || this.estimatedRowHeight;\n\n return {\n layoutInfo,\n validRect: rect.intersection(this.requestedRect)\n };\n }\n\n protected buildSection(node: Node<T>, x: number, y: number): LayoutNode {\n let width = this.virtualizer.visibleRect.width;\n let rect = new Rect(0, y, width, 0);\n let layoutInfo = new LayoutInfo(node.type, node.key, rect);\n\n let startY = y;\n let skipped = 0;\n let children = [];\n for (let child of getChildNodes(node, this.collection)) {\n let rowHeight = (this.rowHeight ?? this.estimatedRowHeight);\n\n // Skip rows before the valid rectangle unless they are already cached.\n if (y + rowHeight < this.requestedRect.y && !this.isValid(node, y)) {\n y += rowHeight;\n skipped++;\n continue;\n }\n\n let layoutNode = this.buildChild(child, x, y, layoutInfo.key);\n y = layoutNode.layoutInfo.rect.maxY;\n children.push(layoutNode);\n\n if (y > this.requestedRect.maxY) {\n // Estimate the remaining height for rows that we don't need to layout right now.\n y += ([...getChildNodes(node, this.collection)].length - (children.length + skipped)) * rowHeight;\n break;\n }\n }\n\n rect.height = y - startY;\n\n return {\n layoutInfo,\n children,\n validRect: layoutInfo.rect.intersection(this.requestedRect),\n node\n };\n }\n\n protected buildSectionHeader(node: Node<T>, x: number, y: number): LayoutNode {\n let width = this.virtualizer.visibleRect.width;\n let rectHeight = this.headingHeight;\n let isEstimated = false;\n\n // If no explicit height is available, use an estimated height.\n if (rectHeight == null) {\n // If a previous version of this layout info exists, reuse its height.\n // Mark as estimated if the size of the overall virtualizer changed,\n // or the content of the item changed.\n let previousLayoutNode = this.layoutNodes.get(node.key);\n let previousLayoutInfo = previousLayoutNode?.layoutInfo;\n if (previousLayoutInfo) {\n let curNode = this.collection.getItem(node.key);\n let lastNode = this.lastCollection ? this.lastCollection.getItem(node.key) : null;\n rectHeight = previousLayoutInfo.rect.height;\n isEstimated = width !== this.lastWidth || curNode !== lastNode || previousLayoutInfo.estimatedSize;\n } else {\n rectHeight = (node.rendered ? this.estimatedHeadingHeight : 0);\n isEstimated = true;\n }\n }\n\n if (rectHeight == null) {\n rectHeight = DEFAULT_HEIGHT;\n }\n\n let headerRect = new Rect(0, y, width, rectHeight);\n let header = new LayoutInfo('header', node.key, headerRect);\n header.estimatedSize = isEstimated;\n return {\n layoutInfo: header,\n children: [],\n validRect: header.rect.intersection(this.requestedRect),\n node\n };\n }\n\n protected buildItem(node: Node<T>, x: number, y: number): LayoutNode {\n let width = this.virtualizer.visibleRect.width;\n let rectHeight = this.rowHeight;\n let isEstimated = false;\n\n // If no explicit height is available, use an estimated height.\n if (rectHeight == null) {\n // If a previous version of this layout info exists, reuse its height.\n // Mark as estimated if the size of the overall virtualizer changed,\n // or the content of the item changed.\n let previousLayoutNode = this.layoutNodes.get(node.key);\n if (previousLayoutNode) {\n rectHeight = previousLayoutNode.layoutInfo.rect.height;\n isEstimated = width !== this.lastWidth || node !== previousLayoutNode.node || previousLayoutNode.layoutInfo.estimatedSize;\n } else {\n rectHeight = this.estimatedRowHeight;\n isEstimated = true;\n }\n }\n\n if (rectHeight == null) {\n rectHeight = DEFAULT_HEIGHT;\n }\n\n let rect = new Rect(x, y, width - x, rectHeight);\n let layoutInfo = new LayoutInfo(node.type, node.key, rect);\n layoutInfo.estimatedSize = isEstimated;\n return {\n layoutInfo,\n children: [],\n validRect: layoutInfo.rect,\n node\n };\n }\n\n updateItemSize(key: Key, size: Size) {\n let layoutNode = this.layoutNodes.get(key);\n // If no layoutInfo, item has been deleted/removed.\n if (!layoutNode) {\n return false;\n }\n\n let layoutInfo = layoutNode.layoutInfo;\n layoutInfo.estimatedSize = false;\n if (layoutInfo.rect.height !== size.height) {\n // Copy layout info rather than mutating so that later caches are invalidated.\n let newLayoutInfo = layoutInfo.copy();\n newLayoutInfo.rect.height = size.height;\n layoutNode.layoutInfo = newLayoutInfo;\n\n // Items after this layoutInfo will need to be repositioned to account for the new height.\n // Adjust the validRect so that only items above remain valid.\n this.validRect.height = Math.min(this.validRect.height, layoutInfo.rect.y - this.validRect.y);\n\n // The requestedRect also needs to be adjusted to account for the height difference.\n this.requestedRect.height += newLayoutInfo.rect.height - layoutInfo.rect.height;\n\n // Invalidate layout for this layout node and all parents\n this.updateLayoutNode(key, layoutInfo, newLayoutInfo);\n\n let node = this.collection.getItem(layoutInfo.parentKey);\n while (node) {\n this.updateLayoutNode(node.key, layoutInfo, newLayoutInfo);\n node = this.collection.getItem(node.parentKey);\n }\n\n return true;\n }\n\n return false;\n }\n\n private updateLayoutNode(key: Key, oldLayoutInfo: LayoutInfo, newLayoutInfo: LayoutInfo) {\n let n = this.layoutNodes.get(key);\n if (n) {\n // Invalidate by intersecting the validRect of this node with the overall validRect.\n n.validRect = n.validRect.intersection(this.validRect);\n\n // Replace layout info in LayoutNode\n if (n.layoutInfo === oldLayoutInfo) {\n n.layoutInfo = newLayoutInfo;\n }\n }\n }\n\n getContentSize() {\n return this.contentSize;\n }\n\n getDropTargetFromPoint(x: number, y: number, isValidDropTarget: (target: DropTarget) => boolean): DropTarget {\n x += this.virtualizer.visibleRect.x;\n y += this.virtualizer.visibleRect.y;\n\n let key = this.virtualizer.keyAtPoint(new Point(x, y));\n if (key == null || this.collection.size === 0) {\n return {type: 'root'};\n }\n\n let layoutInfo = this.getLayoutInfo(key);\n let rect = layoutInfo.rect;\n let target: DropTarget = {\n type: 'item',\n key: layoutInfo.key,\n dropPosition: 'on'\n };\n\n // If dropping on the item isn't accepted, try the target before or after depending on the y position.\n // Otherwise, if dropping on the item is accepted, still try the before/after positions if within 10px\n // of the top or bottom of the item.\n if (!isValidDropTarget(target)) {\n if (y <= rect.y + rect.height / 2 && isValidDropTarget({...target, dropPosition: 'before'})) {\n target.dropPosition = 'before';\n } else if (isValidDropTarget({...target, dropPosition: 'after'})) {\n target.dropPosition = 'after';\n }\n } else if (y <= rect.y + 10 && isValidDropTarget({...target, dropPosition: 'before'})) {\n target.dropPosition = 'before';\n } else if (y >= rect.maxY - 10 && isValidDropTarget({...target, dropPosition: 'after'})) {\n target.dropPosition = 'after';\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 (target.dropPosition === 'before') {\n rect = new Rect(layoutInfo.rect.x, layoutInfo.rect.y - this.dropIndicatorThickness / 2, layoutInfo.rect.width, this.dropIndicatorThickness);\n } else if (target.dropPosition === 'after') {\n rect = new Rect(layoutInfo.rect.x, layoutInfo.rect.maxY - this.dropIndicatorThickness / 2, layoutInfo.rect.width, this.dropIndicatorThickness);\n } else {\n rect = layoutInfo.rect;\n }\n\n return new LayoutInfo('dropIndicator', target.key + ':' + target.dropPosition, rect);\n }\n}\n"],"names":[],"version":3,"file":"ListLayout.module.js.map"}
1
+ {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAgCD,MAAM,uCAAiB;AAUhB,MAAM,kDAA+B,CAAA,GAAA,aAAK;IAwC/C,0CAA0C;IAC1C,IAAc,aAAkC;QAC9C,OAAO,IAAI,CAAC,WAAW,CAAE,UAAU;IACrC;IAEA,cAAc,GAAQ,EAAE;YAEf;QADP,IAAI,CAAC,gBAAgB,CAAC;QACtB,OAAO,EAAA,wBAAA,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,kBAArB,4CAAA,sBAA2B,UAAU,KAAI;IAClD;IAEA,sBAAsB,IAAU,EAAE;QAChC,yDAAyD;QACzD,kDAAkD;QAClD,IAAI,KAAK,MAAM,GAAG,GAAG;gBACH,iBAAA;YAAhB,IAAI,YAAY,CAAA,OAAA,CAAA,kBAAA,IAAI,CAAC,SAAS,cAAd,6BAAA,kBAAkB,IAAI,CAAC,kBAAkB,cAAzC,kBAAA,OAA6C;YAC7D,KAAK,CAAC,GAAG,KAAK,KAAK,CAAC,KAAK,CAAC,GAAG,aAAa;YAC1C,KAAK,MAAM,GAAG,KAAK,IAAI,CAAC,KAAK,MAAM,GAAG,aAAa;QACrD;QAEA,mEAAmE;QACnE,wDAAwD;QACxD,IAAI,CAAC,cAAc,CAAC;QAEpB,IAAI,MAAoB,EAAE;QAE1B,IAAI,WAAW,CAAC;YACd,KAAK,IA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,YAAY,UAA6B,CAAC,CAAC,CAAE;QAC3C,KAAK;YACY;QAAjB,IAAI,CAAC,SAAS,GAAG,CAAA,qBAAA,QAAQ,SAAS,cAAjB,gCAAA,qBAAqB;YACZ;QAA1B,IAAI,CAAC,kBAAkB,GAAG,CAAA,8BAAA,QAAQ,kBAAkB,cAA1B,yCAAA,8BAA8B;YACnC;QAArB,IAAI,CAAC,aAAa,GAAG,CAAA,yBAAA,QAAQ,aAAa,cAArB,oCAAA,yBAAyB;YAChB;QAA9B,IAAI,CAAC,sBAAsB,GAAG,CAAA,kCAAA,QAAQ,sBAAsB,cAA9B,6CAAA,kCAAkC;YAC5C;QAApB,IAAI,CAAC,YAAY,GAAG,CAAA,wBAAA,QAAQ,YAAY,cAApB,mCAAA,wBAAwB;QAC5C,IAAI,CAAC,sBAAsB,GAAG,QAAQ,sBAAsB,IAAI;QAChE,IAAI,CAAC,WAAW,GAAG,IAAI;QACvB,IAAI,CAAC,SAAS,GAAG,EAAE;QACnB,IAAI,CAAC,SAAS,GAAG;QACjB,IAAI,CAAC,cAAc,GAAG;QACtB,IAAI,CAAC,oBAAoB,GAAG;QAC5B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAA,GAAA,WAAG;QACxB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAA,GAAA,WAAG;QAC5B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAA,GAAA,WAAG;IAC5B;AA+ZF","sources":["packages/@react-stately/layout/src/ListLayout.ts"],"sourcesContent":["/*\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 */\n\nimport {Collection, DropTarget, DropTargetDelegate, ItemDropTarget, Key, Node} from '@react-types/shared';\nimport {getChildNodes} from '@react-stately/collections';\nimport {InvalidationContext, Layout, LayoutInfo, Point, Rect, Size} from '@react-stately/virtualizer';\n\nexport interface ListLayoutOptions {\n /** The fixed height of a row in px. */\n rowHeight?: number,\n /** The estimated height of a row, when row heights are variable. */\n estimatedRowHeight?: number,\n /** The fixed height of a section header in px. */\n headingHeight?: number,\n /** The estimated height of a section header, when the height is variable. */\n estimatedHeadingHeight?: number,\n /** The fixed height of a loader element in px. This loader is specifically for\n * \"load more\" elements rendered when loading more rows at the root level or inside nested row/sections.\n */\n loaderHeight?: number,\n /** The thickness of the drop indicator. */\n dropIndicatorThickness?: number\n}\n\n// A wrapper around LayoutInfo that supports hierarchy\nexport interface LayoutNode {\n node?: Node<unknown>,\n layoutInfo: LayoutInfo,\n children?: LayoutNode[],\n validRect: Rect,\n index?: number\n}\n\nconst DEFAULT_HEIGHT = 48;\n\n/**\n * The ListLayout class is an implementation of a virtualizer {@link Layout}.\n * To configure a ListLayout, you can use the properties to define the\n * layouts and/or use the method for defining indentation.\n * The {@link ListKeyboardDelegate} extends the existing virtualizer\n * delegate with an additional method to do this (it uses the same delegate object as\n * the virtualizer itself).\n */\nexport class ListLayout<T, O = any> extends Layout<Node<T>, O> implements DropTargetDelegate {\n protected rowHeight: number | null;\n protected estimatedRowHeight: number | null;\n protected headingHeight: number | null;\n protected estimatedHeadingHeight: number | null;\n protected loaderHeight: number | null;\n protected dropIndicatorThickness: number;\n protected layoutNodes: Map<Key, LayoutNode>;\n protected contentSize: Size;\n protected lastCollection: Collection<Node<T>> | null;\n private lastWidth: number;\n protected rootNodes: LayoutNode[];\n private invalidateEverything: boolean;\n /** The rectangle containing currently valid layout infos. */\n protected validRect: Rect;\n /** The rectangle of requested layout infos so far. */\n protected requestedRect: Rect;\n\n /**\n * Creates a new ListLayout with options. See the list of properties below for a description\n * of the options that can be provided.\n */\n constructor(options: ListLayoutOptions = {}) {\n super();\n this.rowHeight = options.rowHeight ?? null;\n this.estimatedRowHeight = options.estimatedRowHeight ?? null;\n this.headingHeight = options.headingHeight ?? null;\n this.estimatedHeadingHeight = options.estimatedHeadingHeight ?? null;\n this.loaderHeight = options.loaderHeight ?? null;\n this.dropIndicatorThickness = options.dropIndicatorThickness || 2;\n this.layoutNodes = new Map();\n this.rootNodes = [];\n this.lastWidth = 0;\n this.lastCollection = null;\n this.invalidateEverything = false;\n this.validRect = new Rect();\n this.requestedRect = new Rect();\n this.contentSize = new Size();\n }\n\n // Backward compatibility for subclassing.\n protected get collection(): Collection<Node<T>> {\n return this.virtualizer!.collection;\n }\n\n getLayoutInfo(key: Key) {\n this.ensureLayoutInfo(key);\n return this.layoutNodes.get(key)?.layoutInfo || null;\n }\n\n getVisibleLayoutInfos(rect: Rect) {\n // Adjust rect to keep number of visible rows consistent.\n // (only if height > 1 for getDropTargetFromPoint)\n if (rect.height > 1) {\n let rowHeight = this.rowHeight ?? this.estimatedRowHeight ?? DEFAULT_HEIGHT;\n rect.y = Math.floor(rect.y / rowHeight) * rowHeight;\n rect.height = Math.ceil(rect.height / rowHeight) * rowHeight;\n }\n\n // If layout hasn't yet been done for the requested rect, union the\n // new rect with the existing valid rect, and recompute.\n this.layoutIfNeeded(rect);\n\n let res: LayoutInfo[] = [];\n\n let addNodes = (nodes: LayoutNode[]) => {\n for (let node of nodes) {\n if (this.isVisible(node, rect)) {\n res.push(node.layoutInfo);\n\n if (node.children) {\n addNodes(node.children);\n }\n }\n }\n };\n\n addNodes(this.rootNodes);\n return res;\n }\n\n protected layoutIfNeeded(rect: Rect) {\n if (!this.lastCollection) {\n return;\n }\n\n if (!this.requestedRect.containsRect(rect)) {\n this.requestedRect = this.requestedRect.union(rect);\n this.rootNodes = this.buildCollection();\n }\n \n // Ensure all of the persisted keys are available.\n for (let key of this.virtualizer!.persistedKeys) {\n if (this.ensureLayoutInfo(key)) {\n return;\n }\n }\n }\n\n private ensureLayoutInfo(key: Key) {\n // If the layout info wasn't found, it might be outside the bounds of the area that we've\n // computed layout for so far. This can happen when accessing a random key, e.g pressing Home/End.\n // Compute the full layout and try again.\n if (!this.layoutNodes.has(key) && this.requestedRect.area < this.contentSize.area && this.lastCollection) {\n this.requestedRect = new Rect(0, 0, Infinity, Infinity);\n this.rootNodes = this.buildCollection();\n this.requestedRect = new Rect(0, 0, this.contentSize.width, this.contentSize.height);\n return true;\n }\n\n return false;\n }\n\n protected isVisible(node: LayoutNode, rect: Rect) {\n return node.layoutInfo.rect.intersects(rect) || node.layoutInfo.isSticky || node.layoutInfo.type === 'header' || this.virtualizer!.isPersistedKey(node.layoutInfo.key);\n }\n\n protected shouldInvalidateEverything(invalidationContext: InvalidationContext<O>) {\n // Invalidate cache if the size of the collection changed.\n // In this case, we need to recalculate the entire layout.\n return invalidationContext.sizeChanged || false;\n }\n\n update(invalidationContext: InvalidationContext<O>) {\n let collection = this.virtualizer!.collection;\n\n // Reset valid rect if we will have to invalidate everything.\n // Otherwise we can reuse cached layout infos outside the current visible rect.\n this.invalidateEverything = this.shouldInvalidateEverything(invalidationContext);\n if (this.invalidateEverything) {\n this.requestedRect = this.virtualizer!.visibleRect.copy();\n this.layoutNodes.clear();\n }\n\n this.rootNodes = this.buildCollection();\n\n // Remove deleted layout nodes\n if (this.lastCollection && collection !== this.lastCollection) {\n for (let key of this.lastCollection.getKeys()) {\n if (!collection.getItem(key)) {\n let layoutNode = this.layoutNodes.get(key);\n if (layoutNode) {\n this.layoutNodes.delete(key);\n }\n }\n }\n }\n\n this.lastWidth = this.virtualizer!.visibleRect.width;\n this.lastCollection = collection;\n this.invalidateEverything = false;\n this.validRect = this.requestedRect.copy();\n }\n\n protected buildCollection(y = 0): LayoutNode[] {\n let collection = this.virtualizer!.collection;\n let skipped = 0;\n let nodes: LayoutNode[] = [];\n for (let node of collection) {\n let rowHeight = this.rowHeight ?? this.estimatedRowHeight ?? DEFAULT_HEIGHT;\n\n // Skip rows before the valid rectangle unless they are already cached.\n if (node.type === 'item' && y + rowHeight < this.requestedRect.y && !this.isValid(node, y)) {\n y += rowHeight;\n skipped++;\n continue;\n }\n\n let layoutNode = this.buildChild(node, 0, y, null);\n y = layoutNode.layoutInfo.rect.maxY;\n nodes.push(layoutNode);\n\n if (node.type === 'item' && y > this.requestedRect.maxY) {\n y += (collection.size - (nodes.length + skipped)) * rowHeight;\n break;\n }\n }\n\n this.contentSize = new Size(this.virtualizer!.visibleRect.width, y);\n return nodes;\n }\n\n protected isValid(node: Node<T>, y: number) {\n let cached = this.layoutNodes.get(node.key);\n return (\n !this.invalidateEverything &&\n cached &&\n cached.node === node &&\n y === cached.layoutInfo.rect.y &&\n cached.layoutInfo.rect.intersects(this.validRect) &&\n cached.validRect.containsRect(cached.layoutInfo.rect.intersection(this.requestedRect))\n );\n }\n\n protected buildChild(node: Node<T>, x: number, y: number, parentKey: Key | null): LayoutNode {\n if (this.isValid(node, y)) {\n return this.layoutNodes.get(node.key)!;\n }\n\n let layoutNode = this.buildNode(node, x, y);\n\n layoutNode.layoutInfo.parentKey = parentKey ?? null;\n this.layoutNodes.set(node.key, layoutNode);\n return layoutNode;\n }\n\n protected buildNode(node: Node<T>, x: number, y: number): LayoutNode {\n switch (node.type) {\n case 'section':\n return this.buildSection(node, x, y);\n case 'item':\n return this.buildItem(node, x, y);\n case 'header':\n return this.buildSectionHeader(node, x, y);\n case 'loader':\n return this.buildLoader(node, x, y);\n default:\n throw new Error('Unsupported node type: ' + node.type);\n }\n }\n\n protected buildLoader(node: Node<T>, x: number, y: number): LayoutNode {\n let rect = new Rect(x, y, 0, 0);\n let layoutInfo = new LayoutInfo('loader', node.key, rect);\n rect.width = this.virtualizer!.contentSize.width;\n rect.height = this.loaderHeight || this.rowHeight || this.estimatedRowHeight || DEFAULT_HEIGHT;\n\n return {\n layoutInfo,\n validRect: rect.intersection(this.requestedRect)\n };\n }\n\n protected buildSection(node: Node<T>, x: number, y: number): LayoutNode {\n let collection = this.virtualizer!.collection;\n let width = this.virtualizer!.visibleRect.width;\n let rect = new Rect(0, y, width, 0);\n let layoutInfo = new LayoutInfo(node.type, node.key, rect);\n\n let startY = y;\n let skipped = 0;\n let children: LayoutNode[] = [];\n for (let child of getChildNodes(node, collection)) {\n let rowHeight = (this.rowHeight ?? this.estimatedRowHeight ?? DEFAULT_HEIGHT);\n\n // Skip rows before the valid rectangle unless they are already cached.\n if (y + rowHeight < this.requestedRect.y && !this.isValid(node, y)) {\n y += rowHeight;\n skipped++;\n continue;\n }\n\n let layoutNode = this.buildChild(child, x, y, layoutInfo.key);\n y = layoutNode.layoutInfo.rect.maxY;\n children.push(layoutNode);\n\n if (y > this.requestedRect.maxY) {\n // Estimate the remaining height for rows that we don't need to layout right now.\n y += ([...getChildNodes(node, collection)].length - (children.length + skipped)) * rowHeight;\n break;\n }\n }\n\n rect.height = y - startY;\n\n return {\n layoutInfo,\n children,\n validRect: layoutInfo.rect.intersection(this.requestedRect),\n node\n };\n }\n\n protected buildSectionHeader(node: Node<T>, x: number, y: number): LayoutNode {\n let width = this.virtualizer!.visibleRect.width;\n let rectHeight = this.headingHeight;\n let isEstimated = false;\n\n // If no explicit height is available, use an estimated height.\n if (rectHeight == null) {\n // If a previous version of this layout info exists, reuse its height.\n // Mark as estimated if the size of the overall virtualizer changed,\n // or the content of the item changed.\n let previousLayoutNode = this.layoutNodes.get(node.key);\n let previousLayoutInfo = previousLayoutNode?.layoutInfo;\n if (previousLayoutInfo) {\n let curNode = this.virtualizer!.collection.getItem(node.key);\n let lastNode = this.lastCollection ? this.lastCollection.getItem(node.key) : null;\n rectHeight = previousLayoutInfo.rect.height;\n isEstimated = width !== this.lastWidth || curNode !== lastNode || previousLayoutInfo.estimatedSize;\n } else {\n rectHeight = (node.rendered ? this.estimatedHeadingHeight : 0);\n isEstimated = true;\n }\n }\n\n if (rectHeight == null) {\n rectHeight = DEFAULT_HEIGHT;\n }\n\n let headerRect = new Rect(0, y, width, rectHeight);\n let header = new LayoutInfo('header', node.key, headerRect);\n header.estimatedSize = isEstimated;\n return {\n layoutInfo: header,\n children: [],\n validRect: header.rect.intersection(this.requestedRect),\n node\n };\n }\n\n protected buildItem(node: Node<T>, x: number, y: number): LayoutNode {\n let width = this.virtualizer!.visibleRect.width;\n let rectHeight = this.rowHeight;\n let isEstimated = false;\n\n // If no explicit height is available, use an estimated height.\n if (rectHeight == null) {\n // If a previous version of this layout info exists, reuse its height.\n // Mark as estimated if the size of the overall virtualizer changed,\n // or the content of the item changed.\n let previousLayoutNode = this.layoutNodes.get(node.key);\n if (previousLayoutNode) {\n rectHeight = previousLayoutNode.layoutInfo.rect.height;\n isEstimated = width !== this.lastWidth || node !== previousLayoutNode.node || previousLayoutNode.layoutInfo.estimatedSize;\n } else {\n rectHeight = this.estimatedRowHeight;\n isEstimated = true;\n }\n }\n\n if (rectHeight == null) {\n rectHeight = DEFAULT_HEIGHT;\n }\n\n let rect = new Rect(x, y, width - x, rectHeight);\n let layoutInfo = new LayoutInfo(node.type, node.key, rect);\n layoutInfo.estimatedSize = isEstimated;\n return {\n layoutInfo,\n children: [],\n validRect: layoutInfo.rect,\n node\n };\n }\n\n updateItemSize(key: Key, size: Size) {\n let layoutNode = this.layoutNodes.get(key);\n // If no layoutInfo, item has been deleted/removed.\n if (!layoutNode) {\n return false;\n }\n\n let collection = this.virtualizer!.collection;\n let layoutInfo = layoutNode.layoutInfo;\n layoutInfo.estimatedSize = false;\n if (layoutInfo.rect.height !== size.height) {\n // Copy layout info rather than mutating so that later caches are invalidated.\n let newLayoutInfo = layoutInfo.copy();\n newLayoutInfo.rect.height = size.height;\n layoutNode.layoutInfo = newLayoutInfo;\n\n // Items after this layoutInfo will need to be repositioned to account for the new height.\n // Adjust the validRect so that only items above remain valid.\n this.validRect.height = Math.min(this.validRect.height, layoutInfo.rect.y - this.validRect.y);\n\n // The requestedRect also needs to be adjusted to account for the height difference.\n this.requestedRect.height += newLayoutInfo.rect.height - layoutInfo.rect.height;\n\n // Invalidate layout for this layout node and all parents\n this.updateLayoutNode(key, layoutInfo, newLayoutInfo);\n\n let node = layoutInfo.parentKey != null ? collection.getItem(layoutInfo.parentKey) : null;\n while (node) {\n this.updateLayoutNode(node.key, layoutInfo, newLayoutInfo);\n node = node.parentKey != null ? collection.getItem(node.parentKey) : null;\n }\n\n return true;\n }\n\n return false;\n }\n\n private updateLayoutNode(key: Key, oldLayoutInfo: LayoutInfo, newLayoutInfo: LayoutInfo) {\n let n = this.layoutNodes.get(key);\n if (n) {\n // Invalidate by intersecting the validRect of this node with the overall validRect.\n n.validRect = n.validRect.intersection(this.validRect);\n\n // Replace layout info in LayoutNode\n if (n.layoutInfo === oldLayoutInfo) {\n n.layoutInfo = newLayoutInfo;\n }\n }\n }\n\n getContentSize() {\n return this.contentSize;\n }\n\n getDropTargetFromPoint(x: number, y: number, isValidDropTarget: (target: DropTarget) => boolean): DropTarget | null {\n x += this.virtualizer!.visibleRect.x;\n y += this.virtualizer!.visibleRect.y;\n\n let key = this.virtualizer!.keyAtPoint(new Point(x, y));\n if (key == null || this.virtualizer!.collection.size === 0) {\n return {type: 'root'};\n }\n\n let layoutInfo = this.getLayoutInfo(key);\n if (!layoutInfo) {\n return null;\n }\n\n let rect = layoutInfo.rect;\n let target: DropTarget = {\n type: 'item',\n key: layoutInfo.key,\n dropPosition: 'on'\n };\n\n // If dropping on the item isn't accepted, try the target before or after depending on the y position.\n // Otherwise, if dropping on the item is accepted, still try the before/after positions if within 10px\n // of the top or bottom of the item.\n if (!isValidDropTarget(target)) {\n if (y <= rect.y + rect.height / 2 && isValidDropTarget({...target, dropPosition: 'before'})) {\n target.dropPosition = 'before';\n } else if (isValidDropTarget({...target, dropPosition: 'after'})) {\n target.dropPosition = 'after';\n }\n } else if (y <= rect.y + 10 && isValidDropTarget({...target, dropPosition: 'before'})) {\n target.dropPosition = 'before';\n } else if (y >= rect.maxY - 10 && isValidDropTarget({...target, dropPosition: 'after'})) {\n target.dropPosition = 'after';\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 (target.dropPosition === 'before') {\n rect = new Rect(layoutInfo.rect.x, layoutInfo.rect.y - this.dropIndicatorThickness / 2, layoutInfo.rect.width, this.dropIndicatorThickness);\n } else if (target.dropPosition === 'after') {\n rect = new Rect(layoutInfo.rect.x, layoutInfo.rect.maxY - this.dropIndicatorThickness / 2, layoutInfo.rect.width, this.dropIndicatorThickness);\n } else {\n rect = layoutInfo.rect;\n }\n\n return new LayoutInfo('dropIndicator', target.key + ':' + target.dropPosition, rect);\n }\n}\n"],"names":[],"version":3,"file":"ListLayout.module.js.map"}
@@ -23,7 +23,12 @@ $parcel$export(module.exports, "TableLayout", () => $67c493497dcda343$export$624
23
23
 
24
24
 
25
25
 
26
+ const $67c493497dcda343$var$DEFAULT_ROW_HEIGHT = 48;
26
27
  class $67c493497dcda343$export$62444c3c724b1b20 extends (0, $fe69e47e38ed0ac4$exports.ListLayout) {
28
+ // Backward compatibility for subclassing.
29
+ get collection() {
30
+ return this.virtualizer.collection;
31
+ }
27
32
  columnsChanged(newCollection, oldCollection) {
28
33
  return !oldCollection || newCollection.columns !== oldCollection.columns && newCollection.columns.length !== oldCollection.columns.length || newCollection.columns.some((c, i)=>c.key !== oldCollection.columns[i].key || c.props.width !== oldCollection.columns[i].props.width || c.props.minWidth !== oldCollection.columns[i].props.minWidth || c.props.maxWidth !== oldCollection.columns[i].props.maxWidth);
29
34
  }
@@ -37,7 +42,7 @@ class $67c493497dcda343$export$62444c3c724b1b20 extends (0, $fe69e47e38ed0ac4$ex
37
42
  this.columnWidths = invalidationContext.layoutOptions.columnWidths;
38
43
  invalidationContext.sizeChanged = true;
39
44
  }
40
- } else if (invalidationContext.sizeChanged || this.columnsChanged(newCollection, this.collection)) {
45
+ } else if (invalidationContext.sizeChanged || this.columnsChanged(newCollection, this.lastCollection)) {
41
46
  let columnLayout = new (0, $9lycG$reactstatelytable.TableColumnLayout)({});
42
47
  this.columnWidths = columnLayout.buildColumnWidths(this.virtualizer.visibleRect.width, newCollection, new Map());
43
48
  invalidationContext.sizeChanged = true;
@@ -46,9 +51,10 @@ class $67c493497dcda343$export$62444c3c724b1b20 extends (0, $fe69e47e38ed0ac4$ex
46
51
  }
47
52
  buildCollection() {
48
53
  this.stickyColumnIndices = [];
49
- for (let column of this.collection.columns)// The selection cell and any other sticky columns always need to be visible.
54
+ let collection = this.virtualizer.collection;
55
+ for (let column of collection.columns)// The selection cell and any other sticky columns always need to be visible.
50
56
  // In addition, row headers need to be in the DOM for accessibility labeling.
51
- if (this.isStickyColumn(column) || this.collection.rowHeaderColumnKeys.has(column.key)) this.stickyColumnIndices.push(column.index);
57
+ if (this.isStickyColumn(column) || collection.rowHeaderColumnKeys.has(column.key)) this.stickyColumnIndices.push(column.index);
52
58
  let header = this.buildTableHeader();
53
59
  this.layoutNodes.set(header.layoutInfo.key, header);
54
60
  let body = this.buildBody(header.layoutInfo.rect.height);
@@ -61,16 +67,17 @@ class $67c493497dcda343$export$62444c3c724b1b20 extends (0, $fe69e47e38ed0ac4$ex
61
67
  ];
62
68
  }
63
69
  buildTableHeader() {
64
- var _this_collection_head;
70
+ var _collection_head;
71
+ let collection = this.virtualizer.collection;
65
72
  let rect = new (0, $9lycG$reactstatelyvirtualizer.Rect)(0, 0, 0, 0);
66
- var _this_collection_head_key;
67
- let layoutInfo = new (0, $9lycG$reactstatelyvirtualizer.LayoutInfo)('header', (_this_collection_head_key = (_this_collection_head = this.collection.head) === null || _this_collection_head === void 0 ? void 0 : _this_collection_head.key) !== null && _this_collection_head_key !== void 0 ? _this_collection_head_key : 'header', rect);
73
+ var _collection_head_key;
74
+ let layoutInfo = new (0, $9lycG$reactstatelyvirtualizer.LayoutInfo)('header', (_collection_head_key = (_collection_head = collection.head) === null || _collection_head === void 0 ? void 0 : _collection_head.key) !== null && _collection_head_key !== void 0 ? _collection_head_key : 'header', rect);
68
75
  layoutInfo.isSticky = true;
69
76
  layoutInfo.zIndex = 1;
70
77
  let y = 0;
71
78
  let width = 0;
72
79
  let children = [];
73
- for (let headerRow of this.collection.headerRows){
80
+ for (let headerRow of collection.headerRows){
74
81
  let layoutNode = this.buildChild(headerRow, 0, y, layoutInfo.key);
75
82
  layoutNode.layoutInfo.parentKey = layoutInfo.key;
76
83
  y = layoutNode.layoutInfo.rect.maxY;
@@ -84,7 +91,7 @@ class $67c493497dcda343$export$62444c3c724b1b20 extends (0, $fe69e47e38ed0ac4$ex
84
91
  layoutInfo: layoutInfo,
85
92
  children: children,
86
93
  validRect: layoutInfo.rect,
87
- node: this.collection.head
94
+ node: collection.head
88
95
  };
89
96
  }
90
97
  buildHeaderRow(headerRow, x, y) {
@@ -92,7 +99,7 @@ class $67c493497dcda343$export$62444c3c724b1b20 extends (0, $fe69e47e38ed0ac4$ex
92
99
  let row = new (0, $9lycG$reactstatelyvirtualizer.LayoutInfo)('headerrow', headerRow.key, rect);
93
100
  let height = 0;
94
101
  let columns = [];
95
- for (let cell of (0, $9lycG$reactstatelycollections.getChildNodes)(headerRow, this.collection)){
102
+ for (let cell of (0, $9lycG$reactstatelycollections.getChildNodes)(headerRow, this.virtualizer.collection)){
96
103
  let layoutNode = this.buildChild(cell, x, y, row.key);
97
104
  layoutNode.layoutInfo.parentKey = row.key;
98
105
  x = layoutNode.layoutInfo.rect.maxX;
@@ -120,14 +127,16 @@ class $67c493497dcda343$export$62444c3c724b1b20 extends (0, $fe69e47e38ed0ac4$ex
120
127
  }
121
128
  // used to get the column widths when rendering to the DOM
122
129
  getRenderedColumnWidth(node) {
130
+ let collection = this.virtualizer.collection;
123
131
  var _node_colspan;
124
132
  let colspan = (_node_colspan = node.colspan) !== null && _node_colspan !== void 0 ? _node_colspan : 1;
125
133
  var _node_colIndex;
126
134
  let colIndex = (_node_colIndex = node.colIndex) !== null && _node_colIndex !== void 0 ? _node_colIndex : node.index;
127
135
  let width = 0;
128
136
  for(let i = colIndex; i < colIndex + colspan; i++){
129
- let column = this.collection.columns[i];
130
- if ((column === null || column === void 0 ? void 0 : column.key) != null) width += this.columnWidths.get(column.key);
137
+ let column = collection.columns[i];
138
+ var _this_columnWidths_get;
139
+ if ((column === null || column === void 0 ? void 0 : column.key) != null) width += (_this_columnWidths_get = this.columnWidths.get(column.key)) !== null && _this_columnWidths_get !== void 0 ? _this_columnWidths_get : 0;
131
140
  }
132
141
  return width;
133
142
  }
@@ -143,7 +152,7 @@ class $67c493497dcda343$export$62444c3c724b1b20 extends (0, $fe69e47e38ed0ac4$ex
143
152
  height = previousLayoutNode.layoutInfo.rect.height;
144
153
  isEstimated = node !== previousLayoutNode.node || width !== previousLayoutNode.layoutInfo.rect.width || previousLayoutNode.layoutInfo.estimatedSize;
145
154
  } else {
146
- height = estimatedHeight;
155
+ height = estimatedHeight !== null && estimatedHeight !== void 0 ? estimatedHeight : $67c493497dcda343$var$DEFAULT_ROW_HEIGHT;
147
156
  isEstimated = true;
148
157
  }
149
158
  }
@@ -153,12 +162,13 @@ class $67c493497dcda343$export$62444c3c724b1b20 extends (0, $fe69e47e38ed0ac4$ex
153
162
  };
154
163
  }
155
164
  getEstimatedRowHeight() {
156
- var _this_rowHeight;
157
- return (_this_rowHeight = this.rowHeight) !== null && _this_rowHeight !== void 0 ? _this_rowHeight : this.estimatedRowHeight;
165
+ var _this_rowHeight, _ref;
166
+ return (_ref = (_this_rowHeight = this.rowHeight) !== null && _this_rowHeight !== void 0 ? _this_rowHeight : this.estimatedRowHeight) !== null && _ref !== void 0 ? _ref : $67c493497dcda343$var$DEFAULT_ROW_HEIGHT;
158
167
  }
159
168
  buildColumn(node, x, y) {
160
169
  let width = this.getRenderedColumnWidth(node);
161
- let { height: height, isEstimated: isEstimated } = this.getEstimatedHeight(node, width, this.headingHeight, this.estimatedHeadingHeight);
170
+ var _this_headingHeight, _this_estimatedHeadingHeight;
171
+ let { height: height, isEstimated: isEstimated } = this.getEstimatedHeight(node, width, (_this_headingHeight = this.headingHeight) !== null && _this_headingHeight !== void 0 ? _this_headingHeight : this.rowHeight, (_this_estimatedHeadingHeight = this.estimatedHeadingHeight) !== null && _this_estimatedHeadingHeight !== void 0 ? _this_estimatedHeadingHeight : this.estimatedRowHeight);
162
172
  let rect = new (0, $9lycG$reactstatelyvirtualizer.Rect)(x, y, width, height);
163
173
  let layoutInfo = new (0, $9lycG$reactstatelyvirtualizer.LayoutInfo)(node.type, node.key, rect);
164
174
  layoutInfo.isSticky = this.isStickyColumn(node);
@@ -177,14 +187,15 @@ class $67c493497dcda343$export$62444c3c724b1b20 extends (0, $fe69e47e38ed0ac4$ex
177
187
  return false;
178
188
  }
179
189
  buildBody(y) {
190
+ let collection = this.virtualizer.collection;
180
191
  let rect = new (0, $9lycG$reactstatelyvirtualizer.Rect)(0, y, 0, 0);
181
- let layoutInfo = new (0, $9lycG$reactstatelyvirtualizer.LayoutInfo)('rowgroup', this.collection.body.key, rect);
192
+ let layoutInfo = new (0, $9lycG$reactstatelyvirtualizer.LayoutInfo)('rowgroup', collection.body.key, rect);
182
193
  let startY = y;
183
194
  let skipped = 0;
184
195
  let width = 0;
185
196
  let children = [];
186
197
  let rowHeight = this.getEstimatedRowHeight();
187
- for (let node of (0, $9lycG$reactstatelycollections.getChildNodes)(this.collection.body, this.collection)){
198
+ for (let node of (0, $9lycG$reactstatelycollections.getChildNodes)(collection.body, collection)){
188
199
  // Skip rows before the valid rectangle unless they are already cached.
189
200
  if (y + rowHeight < this.requestedRect.y && !this.isValid(node, y)) {
190
201
  y += rowHeight;
@@ -199,7 +210,7 @@ class $67c493497dcda343$export$62444c3c724b1b20 extends (0, $fe69e47e38ed0ac4$ex
199
210
  children.push(layoutNode);
200
211
  if (y > this.requestedRect.maxY) {
201
212
  // Estimate the remaining height for rows that we don't need to layout right now.
202
- y += (this.collection.size - (skipped + children.length)) * rowHeight;
213
+ y += (collection.size - (skipped + children.length)) * rowHeight;
203
214
  break;
204
215
  }
205
216
  }
@@ -210,7 +221,7 @@ class $67c493497dcda343$export$62444c3c724b1b20 extends (0, $fe69e47e38ed0ac4$ex
210
221
  layoutInfo: layoutInfo,
211
222
  children: children,
212
223
  validRect: layoutInfo.rect.intersection(this.requestedRect),
213
- node: this.collection.body
224
+ node: collection.body
214
225
  };
215
226
  }
216
227
  buildNode(node, x, y) {
@@ -231,12 +242,13 @@ class $67c493497dcda343$export$62444c3c724b1b20 extends (0, $fe69e47e38ed0ac4$ex
231
242
  }
232
243
  }
233
244
  buildRow(node, x, y) {
234
- var _this_collection_head;
245
+ var _collection_head;
246
+ let collection = this.virtualizer.collection;
235
247
  let rect = new (0, $9lycG$reactstatelyvirtualizer.Rect)(x, y, 0, 0);
236
248
  let layoutInfo = new (0, $9lycG$reactstatelyvirtualizer.LayoutInfo)('row', node.key, rect);
237
249
  let children = [];
238
250
  let height = 0;
239
- for (let child of (0, $9lycG$reactstatelycollections.getChildNodes)(node, this.collection))if (child.type === 'cell') {
251
+ for (let child of (0, $9lycG$reactstatelycollections.getChildNodes)(node, collection))if (child.type === 'cell') {
240
252
  if (x > this.requestedRect.maxX) {
241
253
  // Adjust existing cached layoutInfo to ensure that it is out of view.
242
254
  // This can happen due to column resizing.
@@ -254,8 +266,8 @@ class $67c493497dcda343$export$62444c3c724b1b20 extends (0, $fe69e47e38ed0ac4$ex
254
266
  }
255
267
  }
256
268
  this.setChildHeights(children, height);
257
- var _this_collection_head_key;
258
- rect.width = this.layoutNodes.get((_this_collection_head_key = (_this_collection_head = this.collection.head) === null || _this_collection_head === void 0 ? void 0 : _this_collection_head.key) !== null && _this_collection_head_key !== void 0 ? _this_collection_head_key : 'header').layoutInfo.rect.width;
269
+ var _collection_head_key;
270
+ rect.width = this.layoutNodes.get((_collection_head_key = (_collection_head = collection.head) === null || _collection_head === void 0 ? void 0 : _collection_head.key) !== null && _collection_head_key !== void 0 ? _collection_head_key : 'header').layoutInfo.rect.width;
259
271
  rect.height = height;
260
272
  return {
261
273
  layoutInfo: layoutInfo,
@@ -389,8 +401,8 @@ class $67c493497dcda343$export$62444c3c724b1b20 extends (0, $fe69e47e38ed0ac4$ex
389
401
  let layoutInfo = (_this_layoutNodes_get = this.layoutNodes.get(key)) === null || _this_layoutNodes_get === void 0 ? void 0 : _this_layoutNodes_get.layoutInfo;
390
402
  // Walk up ancestors so parents are also persisted if children are.
391
403
  while(layoutInfo && layoutInfo.parentKey){
392
- var _this_layoutNodes_get1;
393
- let collectionNode = this.collection.getItem(layoutInfo.key);
404
+ var _this_layoutNodes_get1, _this_layoutNodes_get2;
405
+ let collectionNode = this.virtualizer.collection.getItem(layoutInfo.key);
394
406
  let indices = this.persistedIndices.get(layoutInfo.parentKey);
395
407
  if (!indices) {
396
408
  // stickyColumnIndices are always persisted along with any cells from persistedKeys.
@@ -399,9 +411,9 @@ class $67c493497dcda343$export$62444c3c724b1b20 extends (0, $fe69e47e38ed0ac4$ex
399
411
  ] : [];
400
412
  this.persistedIndices.set(layoutInfo.parentKey, indices);
401
413
  }
402
- let index = this.layoutNodes.get(layoutInfo.key).index;
403
- if (!indices.includes(index)) indices.push(index);
404
- layoutInfo = (_this_layoutNodes_get1 = this.layoutNodes.get(layoutInfo.parentKey)) === null || _this_layoutNodes_get1 === void 0 ? void 0 : _this_layoutNodes_get1.layoutInfo;
414
+ let index = (_this_layoutNodes_get1 = this.layoutNodes.get(layoutInfo.key)) === null || _this_layoutNodes_get1 === void 0 ? void 0 : _this_layoutNodes_get1.index;
415
+ if (index != null && !indices.includes(index)) indices.push(index);
416
+ layoutInfo = (_this_layoutNodes_get2 = this.layoutNodes.get(layoutInfo.parentKey)) === null || _this_layoutNodes_get2 === void 0 ? void 0 : _this_layoutNodes_get2.layoutInfo;
405
417
  }
406
418
  }
407
419
  for (let indices of this.persistedIndices.values())indices.sort((a, b)=>a - b);
@@ -410,17 +422,18 @@ class $67c493497dcda343$export$62444c3c724b1b20 extends (0, $fe69e47e38ed0ac4$ex
410
422
  x += this.virtualizer.visibleRect.x;
411
423
  y += this.virtualizer.visibleRect.y;
412
424
  // Custom variation of this.virtualizer.keyAtPoint that ignores body
413
- let key;
425
+ let key = null;
414
426
  let point = new (0, $9lycG$reactstatelyvirtualizer.Point)(x, y);
415
427
  let rectAtPoint = new (0, $9lycG$reactstatelyvirtualizer.Rect)(point.x, point.y, 1, 1);
416
428
  let layoutInfos = this.virtualizer.layout.getVisibleLayoutInfos(rectAtPoint).filter((info)=>info.type === 'row');
417
429
  // Layout may return multiple layout infos in the case of
418
430
  // persisted keys, so find the first one that actually intersects.
419
431
  for (let layoutInfo of layoutInfos)if (layoutInfo.rect.intersects(rectAtPoint)) key = layoutInfo.key;
420
- if (key == null || this.collection.size === 0) return {
432
+ if (key == null || this.virtualizer.collection.size === 0) return {
421
433
  type: 'root'
422
434
  };
423
435
  let layoutInfo = this.getLayoutInfo(key);
436
+ if (!layoutInfo) return null;
424
437
  let rect = layoutInfo.rect;
425
438
  let target = {
426
439
  type: 'item',
@@ -451,13 +464,11 @@ class $67c493497dcda343$export$62444c3c724b1b20 extends (0, $fe69e47e38ed0ac4$ex
451
464
  }
452
465
  getDropTargetLayoutInfo(target) {
453
466
  let layoutInfo = super.getDropTargetLayoutInfo(target);
454
- layoutInfo.parentKey = this.collection.body.key;
467
+ layoutInfo.parentKey = this.virtualizer.collection.body.key;
455
468
  return layoutInfo;
456
469
  }
457
470
  constructor(options){
458
- super(options);
459
- this.lastPersistedKeys = null;
460
- this.persistedIndices = new Map();
471
+ super(options), this.lastCollection = null, this.columnWidths = new Map(), this.lastPersistedKeys = null, this.persistedIndices = new Map();
461
472
  this.stickyColumnIndices = [];
462
473
  }
463
474
  }
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AAcM,MAAM,kDAAsE,CAAA,GAAA,oCAAS;IAYlF,eAAe,aAAiC,EAAE,aAAwC,EAAE;QAClG,OAAO,CAAC,iBACN,cAAc,OAAO,KAAK,cAAc,OAAO,IAC/C,cAAc,OAAO,CAAC,MAAM,KAAK,cAAc,OAAO,CAAC,MAAM,IAC7D,cAAc,OAAO,CAAC,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["/*\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 */\n\nimport {DropTarget, ItemDropTarget, Key} from '@react-types/shared';\nimport {getChildNodes} from '@react-stately/collections';\nimport {GridNode} from '@react-types/grid';\nimport {InvalidationContext, LayoutInfo, Point, Rect, Size} from '@react-stately/virtualizer';\nimport {LayoutNode, ListLayout, ListLayoutOptions} from './ListLayout';\nimport {TableCollection} from '@react-types/table';\nimport {TableColumnLayout} from '@react-stately/table';\n\nexport interface TableLayoutProps {\n columnWidths?: Map<Key, number>\n}\n\nexport class TableLayout<T, O extends TableLayoutProps = TableLayoutProps> extends ListLayout<T, O> {\n protected collection: TableCollection<T>;\n private columnWidths: Map<Key, number>;\n private stickyColumnIndices: number[];\n private lastPersistedKeys: Set<Key> = null;\n private persistedIndices: Map<Key, number[]> = new Map();\n\n constructor(options: ListLayoutOptions) {\n super(options);\n this.stickyColumnIndices = [];\n }\n\n private columnsChanged(newCollection: TableCollection<T>, oldCollection: TableCollection<T> | null) {\n return !oldCollection ||\n newCollection.columns !== oldCollection.columns &&\n newCollection.columns.length !== oldCollection.columns.length ||\n newCollection.columns.some((c, i) =>\n c.key !== oldCollection.columns[i].key ||\n c.props.width !== oldCollection.columns[i].props.width ||\n c.props.minWidth !== oldCollection.columns[i].props.minWidth ||\n c.props.maxWidth !== oldCollection.columns[i].props.maxWidth\n );\n }\n\n update(invalidationContext: InvalidationContext<O>): void {\n let newCollection = this.virtualizer.collection as TableCollection<T>;\n\n // If columnWidths were provided via layoutOptions, update those.\n // Otherwise, calculate column widths ourselves.\n if (invalidationContext.layoutOptions?.columnWidths) {\n if (invalidationContext.layoutOptions.columnWidths !== this.columnWidths) {\n this.columnWidths = invalidationContext.layoutOptions.columnWidths;\n invalidationContext.sizeChanged = true;\n }\n } else if (invalidationContext.sizeChanged || this.columnsChanged(newCollection, this.collection)) {\n let columnLayout = new TableColumnLayout({});\n this.columnWidths = columnLayout.buildColumnWidths(this.virtualizer.visibleRect.width, newCollection, new Map());\n invalidationContext.sizeChanged = true;\n }\n\n super.update(invalidationContext);\n }\n\n protected buildCollection(): LayoutNode[] {\n this.stickyColumnIndices = [];\n\n for (let column of this.collection.columns) {\n // The selection cell and any other sticky columns always need to be visible.\n // In addition, row headers need to be in the DOM for accessibility labeling.\n if (this.isStickyColumn(column) || this.collection.rowHeaderColumnKeys.has(column.key)) {\n this.stickyColumnIndices.push(column.index);\n }\n }\n\n let header = this.buildTableHeader();\n this.layoutNodes.set(header.layoutInfo.key, header);\n let body = this.buildBody(header.layoutInfo.rect.height);\n this.lastPersistedKeys = null;\n\n body.layoutInfo.rect.width = Math.max(header.layoutInfo.rect.width, body.layoutInfo.rect.width);\n this.contentSize = new Size(body.layoutInfo.rect.width, body.layoutInfo.rect.maxY);\n return [\n header,\n body\n ];\n }\n\n protected buildTableHeader(): LayoutNode {\n let rect = new Rect(0, 0, 0, 0);\n let layoutInfo = new LayoutInfo('header', this.collection.head?.key ?? 'header', rect);\n layoutInfo.isSticky = true;\n layoutInfo.zIndex = 1;\n\n let y = 0;\n let width = 0;\n let children: LayoutNode[] = [];\n for (let headerRow of this.collection.headerRows) {\n let layoutNode = this.buildChild(headerRow, 0, y, layoutInfo.key);\n layoutNode.layoutInfo.parentKey = layoutInfo.key;\n y = layoutNode.layoutInfo.rect.maxY;\n width = Math.max(width, layoutNode.layoutInfo.rect.width);\n layoutNode.index = children.length;\n children.push(layoutNode);\n }\n\n rect.width = width;\n rect.height = y;\n\n return {\n layoutInfo,\n children,\n validRect: layoutInfo.rect,\n node: this.collection.head\n };\n }\n\n protected buildHeaderRow(headerRow: GridNode<T>, x: number, y: number): LayoutNode {\n let rect = new Rect(0, y, 0, 0);\n let row = new LayoutInfo('headerrow', headerRow.key, rect);\n\n let height = 0;\n let columns: LayoutNode[] = [];\n for (let cell of getChildNodes(headerRow, this.collection)) {\n let layoutNode = this.buildChild(cell, x, y, row.key);\n layoutNode.layoutInfo.parentKey = row.key;\n x = layoutNode.layoutInfo.rect.maxX;\n height = Math.max(height, layoutNode.layoutInfo.rect.height);\n layoutNode.index = columns.length;\n columns.push(layoutNode);\n }\n for (let [i, layout] of columns.entries()) {\n layout.layoutInfo.zIndex = columns.length - i + 1;\n }\n\n this.setChildHeights(columns, height);\n\n rect.height = height;\n rect.width = x;\n\n return {\n layoutInfo: row,\n children: columns,\n validRect: rect,\n node: headerRow\n };\n }\n\n private setChildHeights(children: LayoutNode[], height: number) {\n for (let child of children) {\n if (child.layoutInfo.rect.height !== height) {\n // Need to copy the layout info before we mutate it.\n child.layoutInfo = child.layoutInfo.copy();\n child.layoutInfo.rect.height = height;\n }\n }\n }\n\n // used to get the column widths when rendering to the DOM\n private getRenderedColumnWidth(node: GridNode<T>) {\n let colspan = node.colspan ?? 1;\n let colIndex = node.colIndex ?? node.index;\n let width = 0;\n for (let i = colIndex; i < colIndex + colspan; i++) {\n let column = this.collection.columns[i];\n if (column?.key != null) {\n width += this.columnWidths.get(column.key);\n }\n }\n\n return width;\n }\n\n private getEstimatedHeight(node: GridNode<T>, width: number, height: number, estimatedHeight: number) {\n let isEstimated = false;\n\n // If no explicit height is available, use an estimated height.\n if (height == null) {\n // If a previous version of this layout info exists, reuse its height.\n // Mark as estimated if the size of the overall collection view changed,\n // or the content of the item changed.\n let previousLayoutNode = this.layoutNodes.get(node.key);\n if (previousLayoutNode) {\n height = previousLayoutNode.layoutInfo.rect.height;\n isEstimated = node !== previousLayoutNode.node || width !== previousLayoutNode.layoutInfo.rect.width || previousLayoutNode.layoutInfo.estimatedSize;\n } else {\n height = estimatedHeight;\n isEstimated = true;\n }\n }\n\n return {height, isEstimated};\n }\n\n protected getEstimatedRowHeight(): number {\n return this.rowHeight ?? this.estimatedRowHeight;\n }\n\n protected buildColumn(node: GridNode<T>, x: number, y: number): LayoutNode {\n let width = this.getRenderedColumnWidth(node);\n let {height, isEstimated} = this.getEstimatedHeight(node, width, this.headingHeight, this.estimatedHeadingHeight);\n let rect = new Rect(x, y, width, height);\n let layoutInfo = new LayoutInfo(node.type, node.key, rect);\n layoutInfo.isSticky = this.isStickyColumn(node);\n layoutInfo.zIndex = layoutInfo.isSticky ? 2 : 1;\n layoutInfo.estimatedSize = isEstimated;\n\n return {\n layoutInfo,\n children: [],\n validRect: layoutInfo.rect,\n node\n };\n }\n\n // For subclasses.\n // eslint-disable-next-line\n protected isStickyColumn(node: GridNode<T>) {\n return false;\n }\n\n protected buildBody(y: number): LayoutNode {\n let rect = new Rect(0, y, 0, 0);\n let layoutInfo = new LayoutInfo('rowgroup', this.collection.body.key, rect);\n\n let startY = y;\n let skipped = 0;\n let width = 0;\n let children: LayoutNode[] = [];\n let rowHeight = this.getEstimatedRowHeight();\n for (let node of getChildNodes(this.collection.body, this.collection)) {\n // Skip rows before the valid rectangle unless they are already cached.\n if (y + rowHeight < this.requestedRect.y && !this.isValid(node, y)) {\n y += rowHeight;\n skipped++;\n continue;\n }\n\n let layoutNode = this.buildChild(node, 0, y, layoutInfo.key);\n layoutNode.layoutInfo.parentKey = layoutInfo.key;\n layoutNode.index = children.length;\n y = layoutNode.layoutInfo.rect.maxY;\n width = Math.max(width, layoutNode.layoutInfo.rect.width);\n children.push(layoutNode);\n\n if (y > this.requestedRect.maxY) {\n // Estimate the remaining height for rows that we don't need to layout right now.\n y += (this.collection.size - (skipped + children.length)) * rowHeight;\n break;\n }\n }\n\n if (children.length === 0) {\n y = this.virtualizer.visibleRect.maxY;\n }\n\n rect.width = width;\n rect.height = y - startY;\n\n return {\n layoutInfo,\n children,\n validRect: layoutInfo.rect.intersection(this.requestedRect),\n node: this.collection.body\n };\n }\n\n protected buildNode(node: GridNode<T>, x: number, y: number): LayoutNode {\n switch (node.type) {\n case 'headerrow':\n return this.buildHeaderRow(node, x, y);\n case 'item':\n return this.buildRow(node, x, y);\n case 'column':\n case 'placeholder':\n return this.buildColumn(node, x, y);\n case 'cell':\n return this.buildCell(node, x, y);\n case 'loader':\n return this.buildLoader(node, x, y);\n default:\n throw new Error('Unknown node type ' + node.type);\n }\n }\n\n protected buildRow(node: GridNode<T>, x: number, y: number): LayoutNode {\n let rect = new Rect(x, y, 0, 0);\n let layoutInfo = new LayoutInfo('row', node.key, rect);\n\n let children: LayoutNode[] = [];\n let height = 0;\n for (let child of getChildNodes(node, this.collection)) {\n if (child.type === 'cell') {\n if (x > this.requestedRect.maxX) {\n // Adjust existing cached layoutInfo to ensure that it is out of view.\n // This can happen due to column resizing.\n let layoutNode = this.layoutNodes.get(child.key);\n if (layoutNode) {\n layoutNode.layoutInfo.rect.x = x;\n x += layoutNode.layoutInfo.rect.width;\n } else {\n break;\n }\n } else {\n let layoutNode = this.buildChild(child, x, y, layoutInfo.key);\n x = layoutNode.layoutInfo.rect.maxX;\n height = Math.max(height, layoutNode.layoutInfo.rect.height);\n layoutNode.index = children.length;\n children.push(layoutNode);\n }\n }\n }\n\n this.setChildHeights(children, height);\n\n rect.width = this.layoutNodes.get(this.collection.head?.key ?? 'header').layoutInfo.rect.width;\n rect.height = height;\n\n return {\n layoutInfo,\n children,\n validRect: rect.intersection(this.requestedRect),\n node\n };\n }\n\n protected buildCell(node: GridNode<T>, x: number, y: number): LayoutNode {\n let width = this.getRenderedColumnWidth(node);\n let {height, isEstimated} = this.getEstimatedHeight(node, width, this.rowHeight, this.estimatedRowHeight);\n let rect = new Rect(x, y, width, height);\n let layoutInfo = new LayoutInfo(node.type, node.key, rect);\n layoutInfo.isSticky = this.isStickyColumn(node);\n layoutInfo.zIndex = layoutInfo.isSticky ? 2 : 1;\n layoutInfo.estimatedSize = isEstimated;\n\n return {\n layoutInfo,\n children: [],\n validRect: rect,\n node\n };\n }\n\n getVisibleLayoutInfos(rect: Rect) {\n // Adjust rect to keep number of visible rows consistent.\n // (only if height > 1 for getDropTargetFromPoint)\n if (rect.height > 1) {\n let rowHeight = this.getEstimatedRowHeight();\n rect.y = Math.floor(rect.y / rowHeight) * rowHeight;\n rect.height = Math.ceil(rect.height / rowHeight) * rowHeight;\n }\n\n // If layout hasn't yet been done for the requested rect, union the\n // new rect with the existing valid rect, and recompute.\n this.layoutIfNeeded(rect);\n\n let res: LayoutInfo[] = [];\n\n this.buildPersistedIndices();\n for (let node of this.rootNodes) {\n res.push(node.layoutInfo);\n this.addVisibleLayoutInfos(res, node, rect);\n }\n\n return res;\n }\n\n private addVisibleLayoutInfos(res: LayoutInfo[], node: LayoutNode, rect: Rect) {\n if (!node.children || node.children.length === 0) {\n return;\n }\n\n switch (node.layoutInfo.type) {\n case 'header': {\n for (let child of node.children) {\n res.push(child.layoutInfo);\n this.addVisibleLayoutInfos(res, child, rect);\n }\n break;\n }\n case 'rowgroup': {\n let firstVisibleRow = this.binarySearch(node.children, rect.topLeft, 'y');\n let lastVisibleRow = this.binarySearch(node.children, rect.bottomRight, 'y');\n\n // Add persisted rows before the visible rows.\n let persistedRowIndices = this.persistedIndices.get(node.layoutInfo.key);\n let persistIndex = 0;\n while (\n persistedRowIndices &&\n persistIndex < persistedRowIndices.length &&\n persistedRowIndices[persistIndex] < firstVisibleRow\n ) {\n let idx = persistedRowIndices[persistIndex];\n if (idx < node.children.length) {\n res.push(node.children[idx].layoutInfo);\n this.addVisibleLayoutInfos(res, node.children[idx], rect);\n }\n persistIndex++;\n }\n\n for (let i = firstVisibleRow; i <= lastVisibleRow; i++) {\n // Skip persisted rows that overlap with visible cells.\n while (persistedRowIndices && persistIndex < persistedRowIndices.length && persistedRowIndices[persistIndex] < i) {\n persistIndex++;\n }\n\n res.push(node.children[i].layoutInfo);\n this.addVisibleLayoutInfos(res, node.children[i], rect);\n }\n\n // Add persisted rows after the visible rows.\n while (persistedRowIndices && persistIndex < persistedRowIndices.length) {\n let idx = persistedRowIndices[persistIndex++];\n if (idx < node.children.length) {\n res.push(node.children[idx].layoutInfo);\n this.addVisibleLayoutInfos(res, node.children[idx], rect);\n }\n }\n break;\n }\n case 'headerrow':\n case 'row': {\n let firstVisibleCell = this.binarySearch(node.children, rect.topLeft, 'x');\n let lastVisibleCell = this.binarySearch(node.children, rect.topRight, 'x');\n let stickyIndex = 0;\n\n // Add persisted/sticky cells before the visible cells.\n let persistedCellIndices = this.persistedIndices.get(node.layoutInfo.key) || this.stickyColumnIndices;\n while (stickyIndex < persistedCellIndices.length && persistedCellIndices[stickyIndex] < firstVisibleCell) {\n let idx = persistedCellIndices[stickyIndex];\n if (idx < node.children.length) {\n res.push(node.children[idx].layoutInfo);\n }\n stickyIndex++;\n }\n\n for (let i = firstVisibleCell; i <= lastVisibleCell; i++) {\n // Skip sticky cells that overlap with visible cells.\n while (stickyIndex < persistedCellIndices.length && persistedCellIndices[stickyIndex] < i) {\n stickyIndex++;\n }\n\n res.push(node.children[i].layoutInfo);\n }\n\n // Add any remaining sticky cells after the visible cells.\n while (stickyIndex < persistedCellIndices.length) {\n let idx = persistedCellIndices[stickyIndex++];\n if (idx < node.children.length) {\n res.push(node.children[idx].layoutInfo);\n }\n }\n break;\n }\n default:\n throw new Error('Unknown node type ' + node.layoutInfo.type);\n }\n }\n\n private binarySearch(items: LayoutNode[], point: Point, axis: 'x' | 'y') {\n let low = 0;\n let high = items.length - 1;\n while (low <= high) {\n let mid = (low + high) >> 1;\n let item = items[mid];\n\n if ((axis === 'x' && item.layoutInfo.rect.maxX <= point.x) || (axis === 'y' && item.layoutInfo.rect.maxY <= point.y)) {\n low = mid + 1;\n } else if ((axis === 'x' && item.layoutInfo.rect.x > point.x) || (axis === 'y' && item.layoutInfo.rect.y > point.y)) {\n high = mid - 1;\n } else {\n return mid;\n }\n }\n\n return Math.max(0, Math.min(items.length - 1, low));\n }\n\n private buildPersistedIndices() {\n if (this.virtualizer.persistedKeys === this.lastPersistedKeys) {\n return;\n }\n\n this.lastPersistedKeys = this.virtualizer.persistedKeys;\n this.persistedIndices.clear();\n\n // Build a map of parentKey => indices of children to persist.\n for (let key of this.virtualizer.persistedKeys) {\n let layoutInfo = this.layoutNodes.get(key)?.layoutInfo;\n\n // Walk up ancestors so parents are also persisted if children are.\n while (layoutInfo && layoutInfo.parentKey) {\n let collectionNode = this.collection.getItem(layoutInfo.key);\n let indices = this.persistedIndices.get(layoutInfo.parentKey);\n if (!indices) {\n // stickyColumnIndices are always persisted along with any cells from persistedKeys.\n indices = collectionNode?.type === 'cell' || collectionNode?.type === 'column' ? [...this.stickyColumnIndices] : [];\n this.persistedIndices.set(layoutInfo.parentKey, indices);\n }\n\n let index = this.layoutNodes.get(layoutInfo.key).index;\n\n if (!indices.includes(index)) {\n indices.push(index);\n }\n\n layoutInfo = this.layoutNodes.get(layoutInfo.parentKey)?.layoutInfo;\n }\n }\n\n for (let indices of this.persistedIndices.values()) {\n indices.sort((a, b) => a - b);\n }\n }\n\n getDropTargetFromPoint(x: number, y: number, isValidDropTarget: (target: DropTarget) => boolean): DropTarget {\n x += this.virtualizer.visibleRect.x;\n y += this.virtualizer.visibleRect.y;\n\n // Custom variation of this.virtualizer.keyAtPoint that ignores body\n let key: Key;\n let point = new Point(x, y);\n let rectAtPoint = new Rect(point.x, point.y, 1, 1);\n let layoutInfos = this.virtualizer.layout.getVisibleLayoutInfos(rectAtPoint).filter(info => info.type === 'row');\n\n // Layout may return multiple layout infos in the case of\n // persisted keys, so find the first one that actually intersects.\n for (let layoutInfo of layoutInfos) {\n if (layoutInfo.rect.intersects(rectAtPoint)) {\n key = layoutInfo.key;\n }\n }\n\n if (key == null || this.collection.size === 0) {\n return {type: 'root'};\n }\n\n let layoutInfo = this.getLayoutInfo(key);\n let rect = layoutInfo.rect;\n let target: DropTarget = {\n type: 'item',\n key: layoutInfo.key,\n dropPosition: 'on'\n };\n\n // If dropping on the item isn't accepted, try the target before or after depending on the y position.\n // Otherwise, if dropping on the item is accepted, still try the before/after positions if within 10px\n // of the top or bottom of the item.\n if (!isValidDropTarget(target)) {\n if (y <= rect.y + rect.height / 2 && isValidDropTarget({...target, dropPosition: 'before'})) {\n target.dropPosition = 'before';\n } else if (isValidDropTarget({...target, dropPosition: 'after'})) {\n target.dropPosition = 'after';\n }\n } else if (y <= rect.y + 10 && isValidDropTarget({...target, dropPosition: 'before'})) {\n target.dropPosition = 'before';\n } else if (y >= rect.maxY - 10 && isValidDropTarget({...target, dropPosition: 'after'})) {\n target.dropPosition = 'after';\n }\n\n return target;\n }\n\n getDropTargetLayoutInfo(target: ItemDropTarget): LayoutInfo {\n let layoutInfo = super.getDropTargetLayoutInfo(target);\n layoutInfo.parentKey = this.collection.body.key;\n return layoutInfo;\n }\n}\n"],"names":[],"version":3,"file":"TableLayout.main.js.map"}
1
+ {"mappings":";;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;AAcD,MAAM,2CAAqB;AAEpB,MAAM,kDAAsE,CAAA,GAAA,oCAAS;IAY1F,0CAA0C;IAC1C,IAAc,aAAiC;QAC7C,OAAO,IAAI,CAAC,WAAW,CAAE,UAAU;IACrC;IAEQ,eAAe,aAAiC,EAAE,aAAwC,EAAE;QAClG,OAAO,CAAC,iBACN,cAAc,OAAO,KAAK,cAAc,OAAO,IAC/C,cAAc,OAAO,CAAC,MAAM,KAAK,cAAc,OAAO,CAAC,MAAM,IAC7D,cAAc,OAAO,CAAC,IAAI,CAAC,CAAC,GAAG,IAC7B,EAAE,GAAG,KAAK,cAAc,OAAO,CAAC,EAAE,CAAC,GAAG,IACtC,EAAE,KAAK,CAAC,KAAK,KAAK,cAAc,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,IACtD,EAAE,KAAK,CAAC,QAAQ,KAAK,cAAc,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ,IAC5D,EAAE,KAAK,CAAC,QAAQ,KAAK,cAAc,OAAO,CAAC,EAAE,CAAC,KAAK,CAAC,QAAQ;IAElE;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E;IAC/B;AAsiBF","sources":["packages/@react-stately/layout/src/TableLayout.ts"],"sourcesContent":["/*\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 */\n\nimport {DropTarget, ItemDropTarget, Key} from '@react-types/shared';\nimport {getChildNodes} from '@react-stately/collections';\nimport {GridNode} from '@react-types/grid';\nimport {InvalidationContext, LayoutInfo, Point, Rect, Size} from '@react-stately/virtualizer';\nimport {LayoutNode, ListLayout, ListLayoutOptions} from './ListLayout';\nimport {TableCollection} from '@react-types/table';\nimport {TableColumnLayout} from '@react-stately/table';\n\nexport interface TableLayoutProps {\n columnWidths?: Map<Key, number>\n}\n\nconst DEFAULT_ROW_HEIGHT = 48;\n\nexport class TableLayout<T, O extends TableLayoutProps = TableLayoutProps> extends ListLayout<T, O> {\n protected lastCollection: TableCollection<T> | null = null;\n private columnWidths: Map<Key, number> = new Map();\n private stickyColumnIndices: number[];\n private lastPersistedKeys: Set<Key> | null = null;\n private persistedIndices: Map<Key, number[]> = new Map();\n\n constructor(options: ListLayoutOptions) {\n super(options);\n this.stickyColumnIndices = [];\n }\n\n // Backward compatibility for subclassing.\n protected get collection(): TableCollection<T> {\n return this.virtualizer!.collection as TableCollection<T>;\n }\n\n private columnsChanged(newCollection: TableCollection<T>, oldCollection: TableCollection<T> | null) {\n return !oldCollection ||\n newCollection.columns !== oldCollection.columns &&\n newCollection.columns.length !== oldCollection.columns.length ||\n newCollection.columns.some((c, i) =>\n c.key !== oldCollection.columns[i].key ||\n c.props.width !== oldCollection.columns[i].props.width ||\n c.props.minWidth !== oldCollection.columns[i].props.minWidth ||\n c.props.maxWidth !== oldCollection.columns[i].props.maxWidth\n );\n }\n\n update(invalidationContext: InvalidationContext<O>): void {\n let newCollection = this.virtualizer!.collection as TableCollection<T>;\n\n // If columnWidths were provided via layoutOptions, update those.\n // Otherwise, calculate column widths ourselves.\n if (invalidationContext.layoutOptions?.columnWidths) {\n if (invalidationContext.layoutOptions.columnWidths !== this.columnWidths) {\n this.columnWidths = invalidationContext.layoutOptions.columnWidths;\n invalidationContext.sizeChanged = true;\n }\n } else if (invalidationContext.sizeChanged || this.columnsChanged(newCollection, this.lastCollection)) {\n let columnLayout = new TableColumnLayout({});\n this.columnWidths = columnLayout.buildColumnWidths(this.virtualizer!.visibleRect.width, newCollection, new Map());\n invalidationContext.sizeChanged = true;\n }\n\n super.update(invalidationContext);\n }\n\n protected buildCollection(): LayoutNode[] {\n this.stickyColumnIndices = [];\n\n let collection = this.virtualizer!.collection as TableCollection<T>;\n for (let column of collection.columns) {\n // The selection cell and any other sticky columns always need to be visible.\n // In addition, row headers need to be in the DOM for accessibility labeling.\n if (this.isStickyColumn(column) || collection.rowHeaderColumnKeys.has(column.key)) {\n this.stickyColumnIndices.push(column.index);\n }\n }\n\n let header = this.buildTableHeader();\n this.layoutNodes.set(header.layoutInfo.key, header);\n let body = this.buildBody(header.layoutInfo.rect.height);\n this.lastPersistedKeys = null;\n\n body.layoutInfo.rect.width = Math.max(header.layoutInfo.rect.width, body.layoutInfo.rect.width);\n this.contentSize = new Size(body.layoutInfo.rect.width, body.layoutInfo.rect.maxY);\n return [\n header,\n body\n ];\n }\n\n protected buildTableHeader(): LayoutNode {\n let collection = this.virtualizer!.collection as TableCollection<T>;\n let rect = new Rect(0, 0, 0, 0);\n let layoutInfo = new LayoutInfo('header', collection.head?.key ?? 'header', rect);\n layoutInfo.isSticky = true;\n layoutInfo.zIndex = 1;\n\n let y = 0;\n let width = 0;\n let children: LayoutNode[] = [];\n for (let headerRow of collection.headerRows) {\n let layoutNode = this.buildChild(headerRow, 0, y, layoutInfo.key);\n layoutNode.layoutInfo.parentKey = layoutInfo.key;\n y = layoutNode.layoutInfo.rect.maxY;\n width = Math.max(width, layoutNode.layoutInfo.rect.width);\n layoutNode.index = children.length;\n children.push(layoutNode);\n }\n\n rect.width = width;\n rect.height = y;\n\n return {\n layoutInfo,\n children,\n validRect: layoutInfo.rect,\n node: collection.head\n };\n }\n\n protected buildHeaderRow(headerRow: GridNode<T>, x: number, y: number): LayoutNode {\n let rect = new Rect(0, y, 0, 0);\n let row = new LayoutInfo('headerrow', headerRow.key, rect);\n\n let height = 0;\n let columns: LayoutNode[] = [];\n for (let cell of getChildNodes(headerRow, this.virtualizer!.collection)) {\n let layoutNode = this.buildChild(cell, x, y, row.key);\n layoutNode.layoutInfo.parentKey = row.key;\n x = layoutNode.layoutInfo.rect.maxX;\n height = Math.max(height, layoutNode.layoutInfo.rect.height);\n layoutNode.index = columns.length;\n columns.push(layoutNode);\n }\n for (let [i, layout] of columns.entries()) {\n layout.layoutInfo.zIndex = columns.length - i + 1;\n }\n\n this.setChildHeights(columns, height);\n\n rect.height = height;\n rect.width = x;\n\n return {\n layoutInfo: row,\n children: columns,\n validRect: rect,\n node: headerRow\n };\n }\n\n private setChildHeights(children: LayoutNode[], height: number) {\n for (let child of children) {\n if (child.layoutInfo.rect.height !== height) {\n // Need to copy the layout info before we mutate it.\n child.layoutInfo = child.layoutInfo.copy();\n child.layoutInfo.rect.height = height;\n }\n }\n }\n\n // used to get the column widths when rendering to the DOM\n private getRenderedColumnWidth(node: GridNode<T>) {\n let collection = this.virtualizer!.collection as TableCollection<T>;\n let colspan = node.colspan ?? 1;\n let colIndex = node.colIndex ?? node.index;\n let width = 0;\n for (let i = colIndex; i < colIndex + colspan; i++) {\n let column = collection.columns[i];\n if (column?.key != null) {\n width += this.columnWidths.get(column.key) ?? 0;\n }\n }\n\n return width;\n }\n\n private getEstimatedHeight(node: GridNode<T>, width: number, height: number | null, estimatedHeight: number | null) {\n let isEstimated = false;\n\n // If no explicit height is available, use an estimated height.\n if (height == null) {\n // If a previous version of this layout info exists, reuse its height.\n // Mark as estimated if the size of the overall collection view changed,\n // or the content of the item changed.\n let previousLayoutNode = this.layoutNodes.get(node.key);\n if (previousLayoutNode) {\n height = previousLayoutNode.layoutInfo.rect.height;\n isEstimated = node !== previousLayoutNode.node || width !== previousLayoutNode.layoutInfo.rect.width || previousLayoutNode.layoutInfo.estimatedSize;\n } else {\n height = estimatedHeight ?? DEFAULT_ROW_HEIGHT;\n isEstimated = true;\n }\n }\n\n return {height, isEstimated};\n }\n\n protected getEstimatedRowHeight(): number {\n return this.rowHeight ?? this.estimatedRowHeight ?? DEFAULT_ROW_HEIGHT;\n }\n\n protected buildColumn(node: GridNode<T>, x: number, y: number): LayoutNode {\n let width = this.getRenderedColumnWidth(node);\n let {height, isEstimated} = this.getEstimatedHeight(node, width, this.headingHeight ?? this.rowHeight, this.estimatedHeadingHeight ?? this.estimatedRowHeight);\n let rect = new Rect(x, y, width, height);\n let layoutInfo = new LayoutInfo(node.type, node.key, rect);\n layoutInfo.isSticky = this.isStickyColumn(node);\n layoutInfo.zIndex = layoutInfo.isSticky ? 2 : 1;\n layoutInfo.estimatedSize = isEstimated;\n\n return {\n layoutInfo,\n children: [],\n validRect: layoutInfo.rect,\n node\n };\n }\n\n // For subclasses.\n // eslint-disable-next-line\n protected isStickyColumn(node: GridNode<T>) {\n return false;\n }\n\n protected buildBody(y: number): LayoutNode {\n let collection = this.virtualizer!.collection as TableCollection<T>;\n let rect = new Rect(0, y, 0, 0);\n let layoutInfo = new LayoutInfo('rowgroup', collection.body.key, rect);\n\n let startY = y;\n let skipped = 0;\n let width = 0;\n let children: LayoutNode[] = [];\n let rowHeight = this.getEstimatedRowHeight();\n for (let node of getChildNodes(collection.body, collection)) {\n // Skip rows before the valid rectangle unless they are already cached.\n if (y + rowHeight < this.requestedRect.y && !this.isValid(node, y)) {\n y += rowHeight;\n skipped++;\n continue;\n }\n\n let layoutNode = this.buildChild(node, 0, y, layoutInfo.key);\n layoutNode.layoutInfo.parentKey = layoutInfo.key;\n layoutNode.index = children.length;\n y = layoutNode.layoutInfo.rect.maxY;\n width = Math.max(width, layoutNode.layoutInfo.rect.width);\n children.push(layoutNode);\n\n if (y > this.requestedRect.maxY) {\n // Estimate the remaining height for rows that we don't need to layout right now.\n y += (collection.size - (skipped + children.length)) * rowHeight;\n break;\n }\n }\n\n if (children.length === 0) {\n y = this.virtualizer!.visibleRect.maxY;\n }\n\n rect.width = width;\n rect.height = y - startY;\n\n return {\n layoutInfo,\n children,\n validRect: layoutInfo.rect.intersection(this.requestedRect),\n node: collection.body\n };\n }\n\n protected buildNode(node: GridNode<T>, x: number, y: number): LayoutNode {\n switch (node.type) {\n case 'headerrow':\n return this.buildHeaderRow(node, x, y);\n case 'item':\n return this.buildRow(node, x, y);\n case 'column':\n case 'placeholder':\n return this.buildColumn(node, x, y);\n case 'cell':\n return this.buildCell(node, x, y);\n case 'loader':\n return this.buildLoader(node, x, y);\n default:\n throw new Error('Unknown node type ' + node.type);\n }\n }\n\n protected buildRow(node: GridNode<T>, x: number, y: number): LayoutNode {\n let collection = this.virtualizer!.collection as TableCollection<T>;\n let rect = new Rect(x, y, 0, 0);\n let layoutInfo = new LayoutInfo('row', node.key, rect);\n\n let children: LayoutNode[] = [];\n let height = 0;\n for (let child of getChildNodes(node, collection)) {\n if (child.type === 'cell') {\n if (x > this.requestedRect.maxX) {\n // Adjust existing cached layoutInfo to ensure that it is out of view.\n // This can happen due to column resizing.\n let layoutNode = this.layoutNodes.get(child.key);\n if (layoutNode) {\n layoutNode.layoutInfo.rect.x = x;\n x += layoutNode.layoutInfo.rect.width;\n } else {\n break;\n }\n } else {\n let layoutNode = this.buildChild(child, x, y, layoutInfo.key);\n x = layoutNode.layoutInfo.rect.maxX;\n height = Math.max(height, layoutNode.layoutInfo.rect.height);\n layoutNode.index = children.length;\n children.push(layoutNode);\n }\n }\n }\n\n this.setChildHeights(children, height);\n\n rect.width = this.layoutNodes.get(collection.head?.key ?? 'header')!.layoutInfo.rect.width;\n rect.height = height;\n\n return {\n layoutInfo,\n children,\n validRect: rect.intersection(this.requestedRect),\n node\n };\n }\n\n protected buildCell(node: GridNode<T>, x: number, y: number): LayoutNode {\n let width = this.getRenderedColumnWidth(node);\n let {height, isEstimated} = this.getEstimatedHeight(node, width, this.rowHeight, this.estimatedRowHeight);\n let rect = new Rect(x, y, width, height);\n let layoutInfo = new LayoutInfo(node.type, node.key, rect);\n layoutInfo.isSticky = this.isStickyColumn(node);\n layoutInfo.zIndex = layoutInfo.isSticky ? 2 : 1;\n layoutInfo.estimatedSize = isEstimated;\n\n return {\n layoutInfo,\n children: [],\n validRect: rect,\n node\n };\n }\n\n getVisibleLayoutInfos(rect: Rect) {\n // Adjust rect to keep number of visible rows consistent.\n // (only if height > 1 for getDropTargetFromPoint)\n if (rect.height > 1) {\n let rowHeight = this.getEstimatedRowHeight();\n rect.y = Math.floor(rect.y / rowHeight) * rowHeight;\n rect.height = Math.ceil(rect.height / rowHeight) * rowHeight;\n }\n\n // If layout hasn't yet been done for the requested rect, union the\n // new rect with the existing valid rect, and recompute.\n this.layoutIfNeeded(rect);\n\n let res: LayoutInfo[] = [];\n\n this.buildPersistedIndices();\n for (let node of this.rootNodes) {\n res.push(node.layoutInfo);\n this.addVisibleLayoutInfos(res, node, rect);\n }\n\n return res;\n }\n\n private addVisibleLayoutInfos(res: LayoutInfo[], node: LayoutNode, rect: Rect) {\n if (!node.children || node.children.length === 0) {\n return;\n }\n\n switch (node.layoutInfo.type) {\n case 'header': {\n for (let child of node.children) {\n res.push(child.layoutInfo);\n this.addVisibleLayoutInfos(res, child, rect);\n }\n break;\n }\n case 'rowgroup': {\n let firstVisibleRow = this.binarySearch(node.children, rect.topLeft, 'y');\n let lastVisibleRow = this.binarySearch(node.children, rect.bottomRight, 'y');\n\n // Add persisted rows before the visible rows.\n let persistedRowIndices = this.persistedIndices.get(node.layoutInfo.key);\n let persistIndex = 0;\n while (\n persistedRowIndices &&\n persistIndex < persistedRowIndices.length &&\n persistedRowIndices[persistIndex] < firstVisibleRow\n ) {\n let idx = persistedRowIndices[persistIndex];\n if (idx < node.children.length) {\n res.push(node.children[idx].layoutInfo);\n this.addVisibleLayoutInfos(res, node.children[idx], rect);\n }\n persistIndex++;\n }\n\n for (let i = firstVisibleRow; i <= lastVisibleRow; i++) {\n // Skip persisted rows that overlap with visible cells.\n while (persistedRowIndices && persistIndex < persistedRowIndices.length && persistedRowIndices[persistIndex] < i) {\n persistIndex++;\n }\n\n res.push(node.children[i].layoutInfo);\n this.addVisibleLayoutInfos(res, node.children[i], rect);\n }\n\n // Add persisted rows after the visible rows.\n while (persistedRowIndices && persistIndex < persistedRowIndices.length) {\n let idx = persistedRowIndices[persistIndex++];\n if (idx < node.children.length) {\n res.push(node.children[idx].layoutInfo);\n this.addVisibleLayoutInfos(res, node.children[idx], rect);\n }\n }\n break;\n }\n case 'headerrow':\n case 'row': {\n let firstVisibleCell = this.binarySearch(node.children, rect.topLeft, 'x');\n let lastVisibleCell = this.binarySearch(node.children, rect.topRight, 'x');\n let stickyIndex = 0;\n\n // Add persisted/sticky cells before the visible cells.\n let persistedCellIndices = this.persistedIndices.get(node.layoutInfo.key) || this.stickyColumnIndices;\n while (stickyIndex < persistedCellIndices.length && persistedCellIndices[stickyIndex] < firstVisibleCell) {\n let idx = persistedCellIndices[stickyIndex];\n if (idx < node.children.length) {\n res.push(node.children[idx].layoutInfo);\n }\n stickyIndex++;\n }\n\n for (let i = firstVisibleCell; i <= lastVisibleCell; i++) {\n // Skip sticky cells that overlap with visible cells.\n while (stickyIndex < persistedCellIndices.length && persistedCellIndices[stickyIndex] < i) {\n stickyIndex++;\n }\n\n res.push(node.children[i].layoutInfo);\n }\n\n // Add any remaining sticky cells after the visible cells.\n while (stickyIndex < persistedCellIndices.length) {\n let idx = persistedCellIndices[stickyIndex++];\n if (idx < node.children.length) {\n res.push(node.children[idx].layoutInfo);\n }\n }\n break;\n }\n default:\n throw new Error('Unknown node type ' + node.layoutInfo.type);\n }\n }\n\n private binarySearch(items: LayoutNode[], point: Point, axis: 'x' | 'y') {\n let low = 0;\n let high = items.length - 1;\n while (low <= high) {\n let mid = (low + high) >> 1;\n let item = items[mid];\n\n if ((axis === 'x' && item.layoutInfo.rect.maxX <= point.x) || (axis === 'y' && item.layoutInfo.rect.maxY <= point.y)) {\n low = mid + 1;\n } else if ((axis === 'x' && item.layoutInfo.rect.x > point.x) || (axis === 'y' && item.layoutInfo.rect.y > point.y)) {\n high = mid - 1;\n } else {\n return mid;\n }\n }\n\n return Math.max(0, Math.min(items.length - 1, low));\n }\n\n private buildPersistedIndices() {\n if (this.virtualizer!.persistedKeys === this.lastPersistedKeys) {\n return;\n }\n\n this.lastPersistedKeys = this.virtualizer!.persistedKeys;\n this.persistedIndices.clear();\n\n // Build a map of parentKey => indices of children to persist.\n for (let key of this.virtualizer!.persistedKeys) {\n let layoutInfo = this.layoutNodes.get(key)?.layoutInfo;\n\n // Walk up ancestors so parents are also persisted if children are.\n while (layoutInfo && layoutInfo.parentKey) {\n let collectionNode = this.virtualizer!.collection.getItem(layoutInfo.key);\n let indices = this.persistedIndices.get(layoutInfo.parentKey);\n if (!indices) {\n // stickyColumnIndices are always persisted along with any cells from persistedKeys.\n indices = collectionNode?.type === 'cell' || collectionNode?.type === 'column' ? [...this.stickyColumnIndices] : [];\n this.persistedIndices.set(layoutInfo.parentKey, indices);\n }\n\n let index = this.layoutNodes.get(layoutInfo.key)?.index;\n if (index != null && !indices.includes(index)) {\n indices.push(index);\n }\n\n layoutInfo = this.layoutNodes.get(layoutInfo.parentKey)?.layoutInfo;\n }\n }\n\n for (let indices of this.persistedIndices.values()) {\n indices.sort((a, b) => a - b);\n }\n }\n\n getDropTargetFromPoint(x: number, y: number, isValidDropTarget: (target: DropTarget) => boolean): DropTarget | null {\n x += this.virtualizer!.visibleRect.x;\n y += this.virtualizer!.visibleRect.y;\n\n // Custom variation of this.virtualizer.keyAtPoint that ignores body\n let key: Key | null = null;\n let point = new Point(x, y);\n let rectAtPoint = new Rect(point.x, point.y, 1, 1);\n let layoutInfos = this.virtualizer!.layout.getVisibleLayoutInfos(rectAtPoint).filter(info => info.type === 'row');\n\n // Layout may return multiple layout infos in the case of\n // persisted keys, so find the first one that actually intersects.\n for (let layoutInfo of layoutInfos) {\n if (layoutInfo.rect.intersects(rectAtPoint)) {\n key = layoutInfo.key;\n }\n }\n\n if (key == null || this.virtualizer!.collection.size === 0) {\n return {type: 'root'};\n }\n\n let layoutInfo = this.getLayoutInfo(key);\n if (!layoutInfo) {\n return null;\n }\n\n let rect = layoutInfo.rect;\n let target: DropTarget = {\n type: 'item',\n key: layoutInfo.key,\n dropPosition: 'on'\n };\n\n // If dropping on the item isn't accepted, try the target before or after depending on the y position.\n // Otherwise, if dropping on the item is accepted, still try the before/after positions if within 10px\n // of the top or bottom of the item.\n if (!isValidDropTarget(target)) {\n if (y <= rect.y + rect.height / 2 && isValidDropTarget({...target, dropPosition: 'before'})) {\n target.dropPosition = 'before';\n } else if (isValidDropTarget({...target, dropPosition: 'after'})) {\n target.dropPosition = 'after';\n }\n } else if (y <= rect.y + 10 && isValidDropTarget({...target, dropPosition: 'before'})) {\n target.dropPosition = 'before';\n } else if (y >= rect.maxY - 10 && isValidDropTarget({...target, dropPosition: 'after'})) {\n target.dropPosition = 'after';\n }\n\n return target;\n }\n\n getDropTargetLayoutInfo(target: ItemDropTarget): LayoutInfo {\n let layoutInfo = super.getDropTargetLayoutInfo(target);\n layoutInfo.parentKey = (this.virtualizer!.collection as TableCollection<T>).body.key;\n return layoutInfo;\n }\n}\n"],"names":[],"version":3,"file":"TableLayout.main.js.map"}