@react-stately/layout 4.2.2 → 4.3.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.
- package/dist/GridLayout.main.js +17 -4
- package/dist/GridLayout.main.js.map +1 -1
- package/dist/GridLayout.mjs +17 -4
- package/dist/GridLayout.module.js +17 -4
- package/dist/GridLayout.module.js.map +1 -1
- package/dist/ListLayout.main.js +24 -5
- package/dist/ListLayout.main.js.map +1 -1
- package/dist/ListLayout.mjs +24 -5
- package/dist/ListLayout.module.js +24 -5
- package/dist/ListLayout.module.js.map +1 -1
- package/dist/TableLayout.main.js +26 -4
- package/dist/TableLayout.main.js.map +1 -1
- package/dist/TableLayout.mjs +27 -5
- package/dist/TableLayout.module.js +27 -5
- package/dist/TableLayout.module.js.map +1 -1
- package/dist/WaterfallLayout.main.js +30 -18
- package/dist/WaterfallLayout.main.js.map +1 -1
- package/dist/WaterfallLayout.mjs +30 -18
- package/dist/WaterfallLayout.module.js +30 -18
- package/dist/WaterfallLayout.module.js.map +1 -1
- package/dist/types.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/GridLayout.ts +21 -4
- package/src/ListLayout.ts +30 -8
- package/src/TableLayout.ts +35 -5
- package/src/WaterfallLayout.ts +16 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAqDD,MAAM,uCAAiB;AAOhB,MAAM,kDAAuE,CAAA,GAAA,qCAAK;IA0CvF,0CAA0C;IAC1C,IAAc,aAAkC;QAC9C,OAAO,IAAI,CAAC,WAAW,CAAE,UAAU;IACrC;IAEA,cAAc,GAAQ,EAAqB;YAElC;QADP,IAAI,CAAC,gBAAgB,CAAC;QACtB,OAAO,EAAA,wBAAA,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,kBAArB,4CAAA,sBAA2B,UAAU,KAAI;IAClD;IAEA,sBAAsB,IAAU,EAAgB;QAC9C,yDAAyD;QACzD,kDAAkD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,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,GAAG,GAAG,QAAQ,GAAG,IAAI;QAC1B,IAAI,CAAC,OAAO,GAAG,QAAQ,OAAO,IAAI;QAClC,IAAI,CAAC,WAAW,GAAG,IAAI;QACvB,IAAI,CAAC,SAAS,GAAG,EAAE;QACnB,IAAI,CAAC,cAAc,GAAG;QACtB,IAAI,CAAC,oBAAoB,GAAG;QAC5B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAA,GAAA,mCAAG;QACxB,IAAI,CAAC,aAAa,GAAG,IAAI,CAAA,GAAA,mCAAG;QAC5B,IAAI,CAAC,WAAW,GAAG,IAAI,CAAA,GAAA,mCAAG;IAC5B;AAgdF","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, Rect, Size} from '@react-stately/virtualizer';\n\nexport interface ListLayoutOptions {\n /**\n * The fixed height of a row in px.\n * @default 48\n */\n rowHeight?: number,\n /** The estimated height of a row, when row heights are variable. */\n estimatedRowHeight?: number,\n /**\n * The fixed height of a section header in px.\n * @default 48\n */\n headingHeight?: number,\n /** The estimated height of a section header, when the height is variable. */\n estimatedHeadingHeight?: number,\n /** \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 * @default 48\n */\n loaderHeight?: number,\n /**\n * The thickness of the drop indicator.\n * @default 2\n */\n dropIndicatorThickness?: number,\n /**\n * The gap between items.\n * @default 0\n */\n gap?: number,\n /**\n * The padding around the list.\n * @default 0\n */\n padding?: 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 * ListLayout is a virtualizer Layout implementation\n * that arranges its items in a vertical stack. It supports both fixed\n * and variable height items.\n */\nexport class ListLayout<T, O extends ListLayoutOptions = ListLayoutOptions> 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 gap: number;\n protected padding: number;\n protected layoutNodes: Map<Key, LayoutNode>;\n protected contentSize: Size;\n protected lastCollection: Collection<Node<T>> | null;\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.gap = options.gap || 0;\n this.padding = options.padding || 0;\n this.layoutNodes = new Map();\n this.rootNodes = [];\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): LayoutInfo | null {\n this.ensureLayoutInfo(key);\n return this.layoutNodes.get(key)?.layoutInfo || null;\n }\n\n getVisibleLayoutInfos(rect: Rect): LayoutInfo[] {\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) + this.gap;\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): void {\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): boolean {\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>): boolean {\n // Invalidate cache if the size of the collection changed.\n // In this case, we need to recalculate the entire layout.\n // Also invalidate if fixed sizes/gaps change.\n let options = invalidationContext.layoutOptions;\n return invalidationContext.sizeChanged\n || this.rowHeight !== (options?.rowHeight ?? this.rowHeight)\n || this.headingHeight !== (options?.headingHeight ?? this.headingHeight)\n || this.loaderHeight !== (options?.loaderHeight ?? this.loaderHeight)\n || this.gap !== (options?.gap ?? this.gap)\n || this.padding !== (options?.padding ?? this.padding);\n }\n\n shouldInvalidateLayoutOptions(newOptions: O, oldOptions: O): boolean {\n return newOptions.rowHeight !== oldOptions.rowHeight\n || newOptions.estimatedRowHeight !== oldOptions.estimatedRowHeight\n || newOptions.headingHeight !== oldOptions.headingHeight\n || newOptions.estimatedHeadingHeight !== oldOptions.estimatedHeadingHeight\n || newOptions.loaderHeight !== oldOptions.loaderHeight\n || newOptions.dropIndicatorThickness !== oldOptions.dropIndicatorThickness\n || newOptions.gap !== oldOptions.gap\n || newOptions.padding !== oldOptions.padding;\n }\n\n update(invalidationContext: InvalidationContext<O>): void {\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 let options = invalidationContext.layoutOptions;\n this.rowHeight = options?.rowHeight ?? this.rowHeight;\n this.estimatedRowHeight = options?.estimatedRowHeight ?? this.estimatedRowHeight;\n this.headingHeight = options?.headingHeight ?? this.headingHeight;\n this.estimatedHeadingHeight = options?.estimatedHeadingHeight ?? this.estimatedHeadingHeight;\n this.loaderHeight = options?.loaderHeight ?? this.loaderHeight;\n this.dropIndicatorThickness = options?.dropIndicatorThickness ?? this.dropIndicatorThickness;\n this.gap = options?.gap ?? this.gap;\n this.padding = options?.padding ?? this.padding;\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.lastCollection = collection;\n this.invalidateEverything = false;\n this.validRect = this.requestedRect.copy();\n }\n\n protected buildCollection(y = this.padding): 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) + this.gap;\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, this.padding, y, null);\n y = layoutNode.layoutInfo.rect.maxY + this.gap;\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 y -= this.gap;\n y += this.padding;\n this.contentSize = new Size(this.virtualizer!.visibleRect.width, y);\n return nodes;\n }\n\n protected isValid(node: Node<T>, y: number): boolean {\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, this.padding, 0);\n let layoutInfo = new LayoutInfo('loader', node.key, rect);\n rect.width = this.virtualizer!.contentSize.width - this.padding - x;\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 - this.padding;\n let rect = new Rect(x, y, width - x, 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) + this.gap;\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 + this.gap;\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 y -= this.gap;\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 - this.padding;\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 !== previousLayoutInfo.rect.width || 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(x, y, width - x, 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 - this.padding - x;\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 !== previousLayoutNode.layoutInfo.rect.width || 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, 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): boolean {\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(): Size {\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 // Find the closest item within on either side of the point using the gap width.\n let searchRect = new Rect(x, Math.max(0, y - this.gap), 1, this.gap * 2);\n let candidates = this.getVisibleLayoutInfos(searchRect);\n let key: Key | null = null;\n let minDistance = Infinity;\n for (let candidate of candidates) {\n // Ignore items outside the search rect, e.g. persisted keys.\n if (!candidate.rect.intersects(searchRect)) {\n continue;\n }\n\n let yDist = Math.abs(candidate.rect.y - y);\n let maxYDist = Math.abs(candidate.rect.maxY - y);\n let dist = Math.min(yDist, maxYDist);\n if (dist < minDistance) {\n minDistance = dist;\n key = candidate.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 = 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.main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAqDD,MAAM,uCAAiB;AAOhB,MAAM,kDAAuE,CAAA,GAAA,qCAAK;IA0CvF,0CAA0C;IAC1C,IAAc,aAAkC;QAC9C,OAAO,IAAI,CAAC,WAAW,CAAE,UAAU;IACrC;IAEA,cAAc,GAAQ,EAAqB;YAElC;QADP,IAAI,CAAC,gBAAgB,CAAC;QACtB,OAAO,EAAA,wBAAA,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,kBAArB,4CAAA,sBAA2B,UAAU,KAAI;IAClD;IAEA,sBAAsB,IAAU,EAAgB;QAC9C,yDAAyD;QACzD,kDAAkD;QAClD,IAAI,KAAK,MAAM,GAAG,GAAG;gBACF,iBAAA;YAAjB,IAAI,YAAY,AAAC,CAAA,CAAA,OAAA,CAAA,kBAAA,IAAI,CAAC,SAAS,cAAd,6BAAA,kBAAkB,IAAI,CAAC,kBAAkB,cAAzC,kBAAA,OAA6C,oCAAa,IAAK,IAAI,CAAC,GAAG;YACxF,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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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, Rect, Size} from '@react-stately/virtualizer';\n\nexport interface ListLayoutOptions {\n /**\n * The fixed height of a row in px.\n * @default 48\n */\n rowHeight?: number,\n /** The estimated height of a row, when row heights are variable. */\n estimatedRowHeight?: number,\n /**\n * The fixed height of a section header in px.\n * @default 48\n */\n headingHeight?: number,\n /** The estimated height of a section header, when the height is variable. */\n estimatedHeadingHeight?: number,\n /**\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 * @default 48\n */\n loaderHeight?: number,\n /**\n * The thickness of the drop indicator.\n * @default 2\n */\n dropIndicatorThickness?: number,\n /**\n * The gap between items.\n * @default 0\n */\n gap?: number,\n /**\n * The padding around the list.\n * @default 0\n */\n padding?: 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 * ListLayout is a virtualizer Layout implementation\n * that arranges its items in a vertical stack. It supports both fixed\n * and variable height items.\n */\nexport class ListLayout<T, O extends ListLayoutOptions = ListLayoutOptions> 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 gap: number;\n protected padding: number;\n protected layoutNodes: Map<Key, LayoutNode>;\n protected contentSize: Size;\n protected lastCollection: Collection<Node<T>> | null;\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.gap = options.gap || 0;\n this.padding = options.padding || 0;\n this.layoutNodes = new Map();\n this.rootNodes = [];\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): LayoutInfo | null {\n this.ensureLayoutInfo(key);\n return this.layoutNodes.get(key)?.layoutInfo || null;\n }\n\n getVisibleLayoutInfos(rect: Rect): LayoutInfo[] {\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) + this.gap;\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): void {\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): boolean {\n return node.layoutInfo.rect.intersects(rect) || node.layoutInfo.isSticky || node.layoutInfo.type === 'header' || node.layoutInfo.type === 'loader' || this.virtualizer!.isPersistedKey(node.layoutInfo.key);\n }\n\n protected shouldInvalidateEverything(invalidationContext: InvalidationContext<O>): boolean {\n // Invalidate cache if the size of the collection changed.\n // In this case, we need to recalculate the entire layout.\n // Also invalidate if fixed sizes/gaps change.\n let options = invalidationContext.layoutOptions;\n return invalidationContext.sizeChanged\n || this.rowHeight !== (options?.rowHeight ?? this.rowHeight)\n || this.headingHeight !== (options?.headingHeight ?? this.headingHeight)\n || this.loaderHeight !== (options?.loaderHeight ?? this.loaderHeight)\n || this.gap !== (options?.gap ?? this.gap)\n || this.padding !== (options?.padding ?? this.padding);\n }\n\n shouldInvalidateLayoutOptions(newOptions: O, oldOptions: O): boolean {\n return newOptions.rowHeight !== oldOptions.rowHeight\n || newOptions.estimatedRowHeight !== oldOptions.estimatedRowHeight\n || newOptions.headingHeight !== oldOptions.headingHeight\n || newOptions.estimatedHeadingHeight !== oldOptions.estimatedHeadingHeight\n || newOptions.loaderHeight !== oldOptions.loaderHeight\n || newOptions.dropIndicatorThickness !== oldOptions.dropIndicatorThickness\n || newOptions.gap !== oldOptions.gap\n || newOptions.padding !== oldOptions.padding;\n }\n\n update(invalidationContext: InvalidationContext<O>): void {\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 let options = invalidationContext.layoutOptions;\n this.rowHeight = options?.rowHeight ?? this.rowHeight;\n this.estimatedRowHeight = options?.estimatedRowHeight ?? this.estimatedRowHeight;\n this.headingHeight = options?.headingHeight ?? this.headingHeight;\n this.estimatedHeadingHeight = options?.estimatedHeadingHeight ?? this.estimatedHeadingHeight;\n this.loaderHeight = options?.loaderHeight ?? this.loaderHeight;\n this.dropIndicatorThickness = options?.dropIndicatorThickness ?? this.dropIndicatorThickness;\n this.gap = options?.gap ?? this.gap;\n this.padding = options?.padding ?? this.padding;\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.lastCollection = collection;\n this.invalidateEverything = false;\n this.validRect = this.requestedRect.copy();\n }\n\n protected buildCollection(y = this.padding): LayoutNode[] {\n let collection = this.virtualizer!.collection;\n let skipped = 0;\n let nodes: LayoutNode[] = [];\n let isEmptyOrLoading = collection?.size === 0 || (collection.size === 1 && collection.getItem(collection.getFirstKey()!)!.type === 'loader');\n if (isEmptyOrLoading) {\n y = 0;\n }\n\n for (let node of collection) {\n let rowHeight = (this.rowHeight ?? this.estimatedRowHeight ?? DEFAULT_HEIGHT) + this.gap;\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, this.padding, y, null);\n y = layoutNode.layoutInfo.rect.maxY + this.gap;\n nodes.push(layoutNode);\n if (node.type === 'item' && y > this.requestedRect.maxY) {\n let itemsAfterRect = collection.size - (nodes.length + skipped);\n let lastNode = collection.getItem(collection.getLastKey()!);\n if (lastNode?.type === 'loader') {\n itemsAfterRect--;\n }\n\n y += itemsAfterRect * rowHeight;\n\n // Always add the loader sentinel if present. This assumes the loader is the last option/row\n // will need to refactor when handling multi section loading\n if (lastNode?.type === 'loader' && nodes.at(-1)?.layoutInfo.type !== 'loader') {\n let loader = this.buildChild(lastNode, this.padding, y, null);\n nodes.push(loader);\n y = loader.layoutInfo.rect.maxY;\n }\n break;\n }\n }\n\n y -= this.gap;\n y += isEmptyOrLoading ? 0 : this.padding;\n this.contentSize = new Size(this.virtualizer!.visibleRect.width, y);\n return nodes;\n }\n\n protected isValid(node: Node<T>, y: number): boolean {\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 layoutNode.layoutInfo.allowOverflow = true;\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 case 'separator':\n return this.buildItem(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, this.padding, 0);\n let layoutInfo = new LayoutInfo('loader', node.key, rect);\n rect.width = this.virtualizer!.contentSize.width - this.padding - x;\n // Note that if the user provides isLoading to their sentinel during a case where they only want to render the emptyState, this will reserve\n // room for the loader alongside rendering the emptyState\n rect.height = node.props.isLoading ? this.loaderHeight ?? this.rowHeight ?? this.estimatedRowHeight ?? DEFAULT_HEIGHT : 0;\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 - this.padding;\n let rect = new Rect(x, y, width - x, 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) + this.gap;\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 + this.gap;\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 y -= this.gap;\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 - this.padding;\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 !== previousLayoutInfo.rect.width || 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(x, y, width - x, 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 - this.padding - x;\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 !== previousLayoutNode.layoutInfo.rect.width || 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, 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): boolean {\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(): Size {\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 // Find the closest item within on either side of the point using the gap width.\n let searchRect = new Rect(x, Math.max(0, y - this.gap), 1, Math.max(1, this.gap * 2));\n let candidates = this.getVisibleLayoutInfos(searchRect);\n let key: Key | null = null;\n let minDistance = Infinity;\n for (let candidate of candidates) {\n // Ignore items outside the search rect, e.g. persisted keys.\n if (!candidate.rect.intersects(searchRect)) {\n continue;\n }\n\n let yDist = Math.abs(candidate.rect.y - y);\n let maxYDist = Math.abs(candidate.rect.maxY - y);\n let dist = Math.min(yDist, maxYDist);\n if (dist < minDistance) {\n minDistance = dist;\n key = candidate.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 = 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.main.js.map"}
|
package/dist/ListLayout.mjs
CHANGED
|
@@ -70,7 +70,7 @@ class $61ef60fc9b1041f4$export$cacbb3924155d68e extends (0, $img26$Layout) {
|
|
|
70
70
|
return false;
|
|
71
71
|
}
|
|
72
72
|
isVisible(node, rect) {
|
|
73
|
-
return node.layoutInfo.rect.intersects(rect) || node.layoutInfo.isSticky || node.layoutInfo.type === 'header' || this.virtualizer.isPersistedKey(node.layoutInfo.key);
|
|
73
|
+
return node.layoutInfo.rect.intersects(rect) || node.layoutInfo.isSticky || node.layoutInfo.type === 'header' || node.layoutInfo.type === 'loader' || this.virtualizer.isPersistedKey(node.layoutInfo.key);
|
|
74
74
|
}
|
|
75
75
|
shouldInvalidateEverything(invalidationContext) {
|
|
76
76
|
// Invalidate cache if the size of the collection changed.
|
|
@@ -125,6 +125,8 @@ class $61ef60fc9b1041f4$export$cacbb3924155d68e extends (0, $img26$Layout) {
|
|
|
125
125
|
let collection = this.virtualizer.collection;
|
|
126
126
|
let skipped = 0;
|
|
127
127
|
let nodes = [];
|
|
128
|
+
let isEmptyOrLoading = (collection === null || collection === void 0 ? void 0 : collection.size) === 0 || collection.size === 1 && collection.getItem(collection.getFirstKey()).type === 'loader';
|
|
129
|
+
if (isEmptyOrLoading) y = 0;
|
|
128
130
|
for (let node of collection){
|
|
129
131
|
var _this_rowHeight, _ref;
|
|
130
132
|
let rowHeight = ((_ref = (_this_rowHeight = this.rowHeight) !== null && _this_rowHeight !== void 0 ? _this_rowHeight : this.estimatedRowHeight) !== null && _ref !== void 0 ? _ref : $61ef60fc9b1041f4$var$DEFAULT_HEIGHT) + this.gap;
|
|
@@ -138,12 +140,23 @@ class $61ef60fc9b1041f4$export$cacbb3924155d68e extends (0, $img26$Layout) {
|
|
|
138
140
|
y = layoutNode.layoutInfo.rect.maxY + this.gap;
|
|
139
141
|
nodes.push(layoutNode);
|
|
140
142
|
if (node.type === 'item' && y > this.requestedRect.maxY) {
|
|
141
|
-
|
|
143
|
+
var _nodes_at;
|
|
144
|
+
let itemsAfterRect = collection.size - (nodes.length + skipped);
|
|
145
|
+
let lastNode = collection.getItem(collection.getLastKey());
|
|
146
|
+
if ((lastNode === null || lastNode === void 0 ? void 0 : lastNode.type) === 'loader') itemsAfterRect--;
|
|
147
|
+
y += itemsAfterRect * rowHeight;
|
|
148
|
+
// Always add the loader sentinel if present. This assumes the loader is the last option/row
|
|
149
|
+
// will need to refactor when handling multi section loading
|
|
150
|
+
if ((lastNode === null || lastNode === void 0 ? void 0 : lastNode.type) === 'loader' && ((_nodes_at = nodes.at(-1)) === null || _nodes_at === void 0 ? void 0 : _nodes_at.layoutInfo.type) !== 'loader') {
|
|
151
|
+
let loader = this.buildChild(lastNode, this.padding, y, null);
|
|
152
|
+
nodes.push(loader);
|
|
153
|
+
y = loader.layoutInfo.rect.maxY;
|
|
154
|
+
}
|
|
142
155
|
break;
|
|
143
156
|
}
|
|
144
157
|
}
|
|
145
158
|
y -= this.gap;
|
|
146
|
-
y += this.padding;
|
|
159
|
+
y += isEmptyOrLoading ? 0 : this.padding;
|
|
147
160
|
this.contentSize = new (0, $img26$Size)(this.virtualizer.visibleRect.width, y);
|
|
148
161
|
return nodes;
|
|
149
162
|
}
|
|
@@ -155,6 +168,7 @@ class $61ef60fc9b1041f4$export$cacbb3924155d68e extends (0, $img26$Layout) {
|
|
|
155
168
|
if (this.isValid(node, y)) return this.layoutNodes.get(node.key);
|
|
156
169
|
let layoutNode = this.buildNode(node, x, y);
|
|
157
170
|
layoutNode.layoutInfo.parentKey = parentKey !== null && parentKey !== void 0 ? parentKey : null;
|
|
171
|
+
layoutNode.layoutInfo.allowOverflow = true;
|
|
158
172
|
this.layoutNodes.set(node.key, layoutNode);
|
|
159
173
|
return layoutNode;
|
|
160
174
|
}
|
|
@@ -168,6 +182,8 @@ class $61ef60fc9b1041f4$export$cacbb3924155d68e extends (0, $img26$Layout) {
|
|
|
168
182
|
return this.buildSectionHeader(node, x, y);
|
|
169
183
|
case 'loader':
|
|
170
184
|
return this.buildLoader(node, x, y);
|
|
185
|
+
case 'separator':
|
|
186
|
+
return this.buildItem(node, x, y);
|
|
171
187
|
default:
|
|
172
188
|
throw new Error('Unsupported node type: ' + node.type);
|
|
173
189
|
}
|
|
@@ -176,7 +192,10 @@ class $61ef60fc9b1041f4$export$cacbb3924155d68e extends (0, $img26$Layout) {
|
|
|
176
192
|
let rect = new (0, $img26$Rect)(x, y, this.padding, 0);
|
|
177
193
|
let layoutInfo = new (0, $img26$LayoutInfo)('loader', node.key, rect);
|
|
178
194
|
rect.width = this.virtualizer.contentSize.width - this.padding - x;
|
|
179
|
-
|
|
195
|
+
var _this_loaderHeight, _ref, _ref1;
|
|
196
|
+
// Note that if the user provides isLoading to their sentinel during a case where they only want to render the emptyState, this will reserve
|
|
197
|
+
// room for the loader alongside rendering the emptyState
|
|
198
|
+
rect.height = node.props.isLoading ? (_ref1 = (_ref = (_this_loaderHeight = this.loaderHeight) !== null && _this_loaderHeight !== void 0 ? _this_loaderHeight : this.rowHeight) !== null && _ref !== void 0 ? _ref : this.estimatedRowHeight) !== null && _ref1 !== void 0 ? _ref1 : $61ef60fc9b1041f4$var$DEFAULT_HEIGHT : 0;
|
|
180
199
|
return {
|
|
181
200
|
layoutInfo: layoutInfo,
|
|
182
201
|
validRect: rect.intersection(this.requestedRect)
|
|
@@ -324,7 +343,7 @@ class $61ef60fc9b1041f4$export$cacbb3924155d68e extends (0, $img26$Layout) {
|
|
|
324
343
|
x += this.virtualizer.visibleRect.x;
|
|
325
344
|
y += this.virtualizer.visibleRect.y;
|
|
326
345
|
// Find the closest item within on either side of the point using the gap width.
|
|
327
|
-
let searchRect = new (0, $img26$Rect)(x, Math.max(0, y - this.gap), 1, this.gap * 2);
|
|
346
|
+
let searchRect = new (0, $img26$Rect)(x, Math.max(0, y - this.gap), 1, Math.max(1, this.gap * 2));
|
|
328
347
|
let candidates = this.getVisibleLayoutInfos(searchRect);
|
|
329
348
|
let key = null;
|
|
330
349
|
let minDistance = Infinity;
|
|
@@ -70,7 +70,7 @@ class $61ef60fc9b1041f4$export$cacbb3924155d68e extends (0, $img26$Layout) {
|
|
|
70
70
|
return false;
|
|
71
71
|
}
|
|
72
72
|
isVisible(node, rect) {
|
|
73
|
-
return node.layoutInfo.rect.intersects(rect) || node.layoutInfo.isSticky || node.layoutInfo.type === 'header' || this.virtualizer.isPersistedKey(node.layoutInfo.key);
|
|
73
|
+
return node.layoutInfo.rect.intersects(rect) || node.layoutInfo.isSticky || node.layoutInfo.type === 'header' || node.layoutInfo.type === 'loader' || this.virtualizer.isPersistedKey(node.layoutInfo.key);
|
|
74
74
|
}
|
|
75
75
|
shouldInvalidateEverything(invalidationContext) {
|
|
76
76
|
// Invalidate cache if the size of the collection changed.
|
|
@@ -125,6 +125,8 @@ class $61ef60fc9b1041f4$export$cacbb3924155d68e extends (0, $img26$Layout) {
|
|
|
125
125
|
let collection = this.virtualizer.collection;
|
|
126
126
|
let skipped = 0;
|
|
127
127
|
let nodes = [];
|
|
128
|
+
let isEmptyOrLoading = (collection === null || collection === void 0 ? void 0 : collection.size) === 0 || collection.size === 1 && collection.getItem(collection.getFirstKey()).type === 'loader';
|
|
129
|
+
if (isEmptyOrLoading) y = 0;
|
|
128
130
|
for (let node of collection){
|
|
129
131
|
var _this_rowHeight, _ref;
|
|
130
132
|
let rowHeight = ((_ref = (_this_rowHeight = this.rowHeight) !== null && _this_rowHeight !== void 0 ? _this_rowHeight : this.estimatedRowHeight) !== null && _ref !== void 0 ? _ref : $61ef60fc9b1041f4$var$DEFAULT_HEIGHT) + this.gap;
|
|
@@ -138,12 +140,23 @@ class $61ef60fc9b1041f4$export$cacbb3924155d68e extends (0, $img26$Layout) {
|
|
|
138
140
|
y = layoutNode.layoutInfo.rect.maxY + this.gap;
|
|
139
141
|
nodes.push(layoutNode);
|
|
140
142
|
if (node.type === 'item' && y > this.requestedRect.maxY) {
|
|
141
|
-
|
|
143
|
+
var _nodes_at;
|
|
144
|
+
let itemsAfterRect = collection.size - (nodes.length + skipped);
|
|
145
|
+
let lastNode = collection.getItem(collection.getLastKey());
|
|
146
|
+
if ((lastNode === null || lastNode === void 0 ? void 0 : lastNode.type) === 'loader') itemsAfterRect--;
|
|
147
|
+
y += itemsAfterRect * rowHeight;
|
|
148
|
+
// Always add the loader sentinel if present. This assumes the loader is the last option/row
|
|
149
|
+
// will need to refactor when handling multi section loading
|
|
150
|
+
if ((lastNode === null || lastNode === void 0 ? void 0 : lastNode.type) === 'loader' && ((_nodes_at = nodes.at(-1)) === null || _nodes_at === void 0 ? void 0 : _nodes_at.layoutInfo.type) !== 'loader') {
|
|
151
|
+
let loader = this.buildChild(lastNode, this.padding, y, null);
|
|
152
|
+
nodes.push(loader);
|
|
153
|
+
y = loader.layoutInfo.rect.maxY;
|
|
154
|
+
}
|
|
142
155
|
break;
|
|
143
156
|
}
|
|
144
157
|
}
|
|
145
158
|
y -= this.gap;
|
|
146
|
-
y += this.padding;
|
|
159
|
+
y += isEmptyOrLoading ? 0 : this.padding;
|
|
147
160
|
this.contentSize = new (0, $img26$Size)(this.virtualizer.visibleRect.width, y);
|
|
148
161
|
return nodes;
|
|
149
162
|
}
|
|
@@ -155,6 +168,7 @@ class $61ef60fc9b1041f4$export$cacbb3924155d68e extends (0, $img26$Layout) {
|
|
|
155
168
|
if (this.isValid(node, y)) return this.layoutNodes.get(node.key);
|
|
156
169
|
let layoutNode = this.buildNode(node, x, y);
|
|
157
170
|
layoutNode.layoutInfo.parentKey = parentKey !== null && parentKey !== void 0 ? parentKey : null;
|
|
171
|
+
layoutNode.layoutInfo.allowOverflow = true;
|
|
158
172
|
this.layoutNodes.set(node.key, layoutNode);
|
|
159
173
|
return layoutNode;
|
|
160
174
|
}
|
|
@@ -168,6 +182,8 @@ class $61ef60fc9b1041f4$export$cacbb3924155d68e extends (0, $img26$Layout) {
|
|
|
168
182
|
return this.buildSectionHeader(node, x, y);
|
|
169
183
|
case 'loader':
|
|
170
184
|
return this.buildLoader(node, x, y);
|
|
185
|
+
case 'separator':
|
|
186
|
+
return this.buildItem(node, x, y);
|
|
171
187
|
default:
|
|
172
188
|
throw new Error('Unsupported node type: ' + node.type);
|
|
173
189
|
}
|
|
@@ -176,7 +192,10 @@ class $61ef60fc9b1041f4$export$cacbb3924155d68e extends (0, $img26$Layout) {
|
|
|
176
192
|
let rect = new (0, $img26$Rect)(x, y, this.padding, 0);
|
|
177
193
|
let layoutInfo = new (0, $img26$LayoutInfo)('loader', node.key, rect);
|
|
178
194
|
rect.width = this.virtualizer.contentSize.width - this.padding - x;
|
|
179
|
-
|
|
195
|
+
var _this_loaderHeight, _ref, _ref1;
|
|
196
|
+
// Note that if the user provides isLoading to their sentinel during a case where they only want to render the emptyState, this will reserve
|
|
197
|
+
// room for the loader alongside rendering the emptyState
|
|
198
|
+
rect.height = node.props.isLoading ? (_ref1 = (_ref = (_this_loaderHeight = this.loaderHeight) !== null && _this_loaderHeight !== void 0 ? _this_loaderHeight : this.rowHeight) !== null && _ref !== void 0 ? _ref : this.estimatedRowHeight) !== null && _ref1 !== void 0 ? _ref1 : $61ef60fc9b1041f4$var$DEFAULT_HEIGHT : 0;
|
|
180
199
|
return {
|
|
181
200
|
layoutInfo: layoutInfo,
|
|
182
201
|
validRect: rect.intersection(this.requestedRect)
|
|
@@ -324,7 +343,7 @@ class $61ef60fc9b1041f4$export$cacbb3924155d68e extends (0, $img26$Layout) {
|
|
|
324
343
|
x += this.virtualizer.visibleRect.x;
|
|
325
344
|
y += this.virtualizer.visibleRect.y;
|
|
326
345
|
// Find the closest item within on either side of the point using the gap width.
|
|
327
|
-
let searchRect = new (0, $img26$Rect)(x, Math.max(0, y - this.gap), 1, this.gap * 2);
|
|
346
|
+
let searchRect = new (0, $img26$Rect)(x, Math.max(0, y - this.gap), 1, Math.max(1, this.gap * 2));
|
|
328
347
|
let candidates = this.getVisibleLayoutInfos(searchRect);
|
|
329
348
|
let key = null;
|
|
330
349
|
let minDistance = Infinity;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAqDD,MAAM,uCAAiB;AAOhB,MAAM,kDAAuE,CAAA,GAAA,aAAK;IA0CvF,0CAA0C;IAC1C,IAAc,aAAkC;QAC9C,OAAO,IAAI,CAAC,WAAW,CAAE,UAAU;IACrC;IAEA,cAAc,GAAQ,EAAqB;YAElC;QADP,IAAI,CAAC,gBAAgB,CAAC;QACtB,OAAO,EAAA,wBAAA,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,kBAArB,4CAAA,sBAA2B,UAAU,KAAI;IAClD;IAEA,sBAAsB,IAAU,EAAgB;QAC9C,yDAAyD;QACzD,kDAAkD;QAClD,IAAI,KAAK,MAAM,GAAG,GAAG;gBACF,iBAAA;YAAjB,IAAI,YAAY,AAAC,CAAA,CAAA,OAAA,CAAA,kBAAA,IAAI,CAAC,SAAS,cAAd,6BAAA,kBAAkB,IAAI,CAAC,kBAAkB,cAAzC,kBAAA,OAA6C,oCAAa,IAAK,IAAI,CAAC,GAAG;YACxF,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,S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B;AAgdF","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, Rect, Size} from '@react-stately/virtualizer';\n\nexport interface ListLayoutOptions {\n /**\n * The fixed height of a row in px.\n * @default 48\n */\n rowHeight?: number,\n /** The estimated height of a row, when row heights are variable. */\n estimatedRowHeight?: number,\n /**\n * The fixed height of a section header in px.\n * @default 48\n */\n headingHeight?: number,\n /** The estimated height of a section header, when the height is variable. */\n estimatedHeadingHeight?: number,\n /** \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 * @default 48\n */\n loaderHeight?: number,\n /**\n * The thickness of the drop indicator.\n * @default 2\n */\n dropIndicatorThickness?: number,\n /**\n * The gap between items.\n * @default 0\n */\n gap?: number,\n /**\n * The padding around the list.\n * @default 0\n */\n padding?: 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 * ListLayout is a virtualizer Layout implementation\n * that arranges its items in a vertical stack. It supports both fixed\n * and variable height items.\n */\nexport class ListLayout<T, O extends ListLayoutOptions = ListLayoutOptions> 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 gap: number;\n protected padding: number;\n protected layoutNodes: Map<Key, LayoutNode>;\n protected contentSize: Size;\n protected lastCollection: Collection<Node<T>> | null;\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.gap = options.gap || 0;\n this.padding = options.padding || 0;\n this.layoutNodes = new Map();\n this.rootNodes = [];\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): LayoutInfo | null {\n this.ensureLayoutInfo(key);\n return this.layoutNodes.get(key)?.layoutInfo || null;\n }\n\n getVisibleLayoutInfos(rect: Rect): LayoutInfo[] {\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) + this.gap;\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): void {\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): boolean {\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>): boolean {\n // Invalidate cache if the size of the collection changed.\n // In this case, we need to recalculate the entire layout.\n // Also invalidate if fixed sizes/gaps change.\n let options = invalidationContext.layoutOptions;\n return invalidationContext.sizeChanged\n || this.rowHeight !== (options?.rowHeight ?? this.rowHeight)\n || this.headingHeight !== (options?.headingHeight ?? this.headingHeight)\n || this.loaderHeight !== (options?.loaderHeight ?? this.loaderHeight)\n || this.gap !== (options?.gap ?? this.gap)\n || this.padding !== (options?.padding ?? this.padding);\n }\n\n shouldInvalidateLayoutOptions(newOptions: O, oldOptions: O): boolean {\n return newOptions.rowHeight !== oldOptions.rowHeight\n || newOptions.estimatedRowHeight !== oldOptions.estimatedRowHeight\n || newOptions.headingHeight !== oldOptions.headingHeight\n || newOptions.estimatedHeadingHeight !== oldOptions.estimatedHeadingHeight\n || newOptions.loaderHeight !== oldOptions.loaderHeight\n || newOptions.dropIndicatorThickness !== oldOptions.dropIndicatorThickness\n || newOptions.gap !== oldOptions.gap\n || newOptions.padding !== oldOptions.padding;\n }\n\n update(invalidationContext: InvalidationContext<O>): void {\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 let options = invalidationContext.layoutOptions;\n this.rowHeight = options?.rowHeight ?? this.rowHeight;\n this.estimatedRowHeight = options?.estimatedRowHeight ?? this.estimatedRowHeight;\n this.headingHeight = options?.headingHeight ?? this.headingHeight;\n this.estimatedHeadingHeight = options?.estimatedHeadingHeight ?? this.estimatedHeadingHeight;\n this.loaderHeight = options?.loaderHeight ?? this.loaderHeight;\n this.dropIndicatorThickness = options?.dropIndicatorThickness ?? this.dropIndicatorThickness;\n this.gap = options?.gap ?? this.gap;\n this.padding = options?.padding ?? this.padding;\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.lastCollection = collection;\n this.invalidateEverything = false;\n this.validRect = this.requestedRect.copy();\n }\n\n protected buildCollection(y = this.padding): 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) + this.gap;\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, this.padding, y, null);\n y = layoutNode.layoutInfo.rect.maxY + this.gap;\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 y -= this.gap;\n y += this.padding;\n this.contentSize = new Size(this.virtualizer!.visibleRect.width, y);\n return nodes;\n }\n\n protected isValid(node: Node<T>, y: number): boolean {\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, this.padding, 0);\n let layoutInfo = new LayoutInfo('loader', node.key, rect);\n rect.width = this.virtualizer!.contentSize.width - this.padding - x;\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 - this.padding;\n let rect = new Rect(x, y, width - x, 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) + this.gap;\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 + this.gap;\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 y -= this.gap;\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 - this.padding;\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 !== previousLayoutInfo.rect.width || 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(x, y, width - x, 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 - this.padding - x;\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 !== previousLayoutNode.layoutInfo.rect.width || 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, 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): boolean {\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(): Size {\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 // Find the closest item within on either side of the point using the gap width.\n let searchRect = new Rect(x, Math.max(0, y - this.gap), 1, this.gap * 2);\n let candidates = this.getVisibleLayoutInfos(searchRect);\n let key: Key | null = null;\n let minDistance = Infinity;\n for (let candidate of candidates) {\n // Ignore items outside the search rect, e.g. persisted keys.\n if (!candidate.rect.intersects(searchRect)) {\n continue;\n }\n\n let yDist = Math.abs(candidate.rect.y - y);\n let maxYDist = Math.abs(candidate.rect.maxY - y);\n let dist = Math.min(yDist, maxYDist);\n if (dist < minDistance) {\n minDistance = dist;\n key = candidate.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 = 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;;AAqDD,MAAM,uCAAiB;AAOhB,MAAM,kDAAuE,CAAA,GAAA,aAAK;IA0CvF,0CAA0C;IAC1C,IAAc,aAAkC;QAC9C,OAAO,IAAI,CAAC,WAAW,CAAE,UAAU;IACrC;IAEA,cAAc,GAAQ,EAAqB;YAElC;QADP,IAAI,CAAC,gBAAgB,CAAC;QACtB,OAAO,EA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,QAAQ,YAAY,cAApB,mCAAA,wBAAwB;QAC5C,IAAI,CAAC,sBAAsB,GAAG,QAAQ,sBAAsB,IAAI;QAChE,IAAI,CAAC,GAAG,GAAG,QAAQ,GAAG,IAAI;QAC1B,IAAI,CAAC,OAAO,GAAG,QAAQ,OAAO,IAAI;QAClC,IAAI,CAAC,WAAW,GAAG,IAAI;QACvB,IAAI,CAAC,SAAS,GAAG,EAAE;QACnB,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;AAseF","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, Rect, Size} from '@react-stately/virtualizer';\n\nexport interface ListLayoutOptions {\n /**\n * The fixed height of a row in px.\n * @default 48\n */\n rowHeight?: number,\n /** The estimated height of a row, when row heights are variable. */\n estimatedRowHeight?: number,\n /**\n * The fixed height of a section header in px.\n * @default 48\n */\n headingHeight?: number,\n /** The estimated height of a section header, when the height is variable. */\n estimatedHeadingHeight?: number,\n /**\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 * @default 48\n */\n loaderHeight?: number,\n /**\n * The thickness of the drop indicator.\n * @default 2\n */\n dropIndicatorThickness?: number,\n /**\n * The gap between items.\n * @default 0\n */\n gap?: number,\n /**\n * The padding around the list.\n * @default 0\n */\n padding?: 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 * ListLayout is a virtualizer Layout implementation\n * that arranges its items in a vertical stack. It supports both fixed\n * and variable height items.\n */\nexport class ListLayout<T, O extends ListLayoutOptions = ListLayoutOptions> 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 gap: number;\n protected padding: number;\n protected layoutNodes: Map<Key, LayoutNode>;\n protected contentSize: Size;\n protected lastCollection: Collection<Node<T>> | null;\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.gap = options.gap || 0;\n this.padding = options.padding || 0;\n this.layoutNodes = new Map();\n this.rootNodes = [];\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): LayoutInfo | null {\n this.ensureLayoutInfo(key);\n return this.layoutNodes.get(key)?.layoutInfo || null;\n }\n\n getVisibleLayoutInfos(rect: Rect): LayoutInfo[] {\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) + this.gap;\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): void {\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): boolean {\n return node.layoutInfo.rect.intersects(rect) || node.layoutInfo.isSticky || node.layoutInfo.type === 'header' || node.layoutInfo.type === 'loader' || this.virtualizer!.isPersistedKey(node.layoutInfo.key);\n }\n\n protected shouldInvalidateEverything(invalidationContext: InvalidationContext<O>): boolean {\n // Invalidate cache if the size of the collection changed.\n // In this case, we need to recalculate the entire layout.\n // Also invalidate if fixed sizes/gaps change.\n let options = invalidationContext.layoutOptions;\n return invalidationContext.sizeChanged\n || this.rowHeight !== (options?.rowHeight ?? this.rowHeight)\n || this.headingHeight !== (options?.headingHeight ?? this.headingHeight)\n || this.loaderHeight !== (options?.loaderHeight ?? this.loaderHeight)\n || this.gap !== (options?.gap ?? this.gap)\n || this.padding !== (options?.padding ?? this.padding);\n }\n\n shouldInvalidateLayoutOptions(newOptions: O, oldOptions: O): boolean {\n return newOptions.rowHeight !== oldOptions.rowHeight\n || newOptions.estimatedRowHeight !== oldOptions.estimatedRowHeight\n || newOptions.headingHeight !== oldOptions.headingHeight\n || newOptions.estimatedHeadingHeight !== oldOptions.estimatedHeadingHeight\n || newOptions.loaderHeight !== oldOptions.loaderHeight\n || newOptions.dropIndicatorThickness !== oldOptions.dropIndicatorThickness\n || newOptions.gap !== oldOptions.gap\n || newOptions.padding !== oldOptions.padding;\n }\n\n update(invalidationContext: InvalidationContext<O>): void {\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 let options = invalidationContext.layoutOptions;\n this.rowHeight = options?.rowHeight ?? this.rowHeight;\n this.estimatedRowHeight = options?.estimatedRowHeight ?? this.estimatedRowHeight;\n this.headingHeight = options?.headingHeight ?? this.headingHeight;\n this.estimatedHeadingHeight = options?.estimatedHeadingHeight ?? this.estimatedHeadingHeight;\n this.loaderHeight = options?.loaderHeight ?? this.loaderHeight;\n this.dropIndicatorThickness = options?.dropIndicatorThickness ?? this.dropIndicatorThickness;\n this.gap = options?.gap ?? this.gap;\n this.padding = options?.padding ?? this.padding;\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.lastCollection = collection;\n this.invalidateEverything = false;\n this.validRect = this.requestedRect.copy();\n }\n\n protected buildCollection(y = this.padding): LayoutNode[] {\n let collection = this.virtualizer!.collection;\n let skipped = 0;\n let nodes: LayoutNode[] = [];\n let isEmptyOrLoading = collection?.size === 0 || (collection.size === 1 && collection.getItem(collection.getFirstKey()!)!.type === 'loader');\n if (isEmptyOrLoading) {\n y = 0;\n }\n\n for (let node of collection) {\n let rowHeight = (this.rowHeight ?? this.estimatedRowHeight ?? DEFAULT_HEIGHT) + this.gap;\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, this.padding, y, null);\n y = layoutNode.layoutInfo.rect.maxY + this.gap;\n nodes.push(layoutNode);\n if (node.type === 'item' && y > this.requestedRect.maxY) {\n let itemsAfterRect = collection.size - (nodes.length + skipped);\n let lastNode = collection.getItem(collection.getLastKey()!);\n if (lastNode?.type === 'loader') {\n itemsAfterRect--;\n }\n\n y += itemsAfterRect * rowHeight;\n\n // Always add the loader sentinel if present. This assumes the loader is the last option/row\n // will need to refactor when handling multi section loading\n if (lastNode?.type === 'loader' && nodes.at(-1)?.layoutInfo.type !== 'loader') {\n let loader = this.buildChild(lastNode, this.padding, y, null);\n nodes.push(loader);\n y = loader.layoutInfo.rect.maxY;\n }\n break;\n }\n }\n\n y -= this.gap;\n y += isEmptyOrLoading ? 0 : this.padding;\n this.contentSize = new Size(this.virtualizer!.visibleRect.width, y);\n return nodes;\n }\n\n protected isValid(node: Node<T>, y: number): boolean {\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 layoutNode.layoutInfo.allowOverflow = true;\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 case 'separator':\n return this.buildItem(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, this.padding, 0);\n let layoutInfo = new LayoutInfo('loader', node.key, rect);\n rect.width = this.virtualizer!.contentSize.width - this.padding - x;\n // Note that if the user provides isLoading to their sentinel during a case where they only want to render the emptyState, this will reserve\n // room for the loader alongside rendering the emptyState\n rect.height = node.props.isLoading ? this.loaderHeight ?? this.rowHeight ?? this.estimatedRowHeight ?? DEFAULT_HEIGHT : 0;\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 - this.padding;\n let rect = new Rect(x, y, width - x, 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) + this.gap;\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 + this.gap;\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 y -= this.gap;\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 - this.padding;\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 !== previousLayoutInfo.rect.width || 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(x, y, width - x, 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 - this.padding - x;\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 !== previousLayoutNode.layoutInfo.rect.width || 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, 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): boolean {\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(): Size {\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 // Find the closest item within on either side of the point using the gap width.\n let searchRect = new Rect(x, Math.max(0, y - this.gap), 1, Math.max(1, this.gap * 2));\n let candidates = this.getVisibleLayoutInfos(searchRect);\n let key: Key | null = null;\n let minDistance = Infinity;\n for (let candidate of candidates) {\n // Ignore items outside the search rect, e.g. persisted keys.\n if (!candidate.rect.intersects(searchRect)) {\n continue;\n }\n\n let yDist = Math.abs(candidate.rect.y - y);\n let maxYDist = Math.abs(candidate.rect.maxY - y);\n let dist = Math.min(yDist, maxYDist);\n if (dist < minDistance) {\n minDistance = dist;\n key = candidate.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 = 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"}
|
package/dist/TableLayout.main.js
CHANGED
|
@@ -53,8 +53,10 @@ class $67c493497dcda343$export$62444c3c724b1b20 extends (0, $fe69e47e38ed0ac4$ex
|
|
|
53
53
|
super.update(invalidationContext);
|
|
54
54
|
}
|
|
55
55
|
buildCollection() {
|
|
56
|
+
var _collection_head;
|
|
56
57
|
this.stickyColumnIndices = [];
|
|
57
58
|
let collection = this.virtualizer.collection;
|
|
59
|
+
if (((_collection_head = collection.head) === null || _collection_head === void 0 ? void 0 : _collection_head.key) === -1) return [];
|
|
58
60
|
for (let column of collection.columns)// The selection cell and any other sticky columns always need to be visible.
|
|
59
61
|
// In addition, row headers need to be in the DOM for accessibility labeling.
|
|
60
62
|
if (this.isStickyColumn(column) || collection.rowHeaderColumnKeys.has(column.key)) this.stickyColumnIndices.push(column.index);
|
|
@@ -198,7 +200,8 @@ class $67c493497dcda343$export$62444c3c724b1b20 extends (0, $fe69e47e38ed0ac4$ex
|
|
|
198
200
|
let width = 0;
|
|
199
201
|
let children = [];
|
|
200
202
|
let rowHeight = this.getEstimatedRowHeight() + this.gap;
|
|
201
|
-
|
|
203
|
+
let childNodes = (0, $9lycG$reactstatelycollections.getChildNodes)(collection.body, collection);
|
|
204
|
+
for (let node of childNodes){
|
|
202
205
|
// Skip rows before the valid rectangle unless they are already cached.
|
|
203
206
|
if (y + rowHeight < this.requestedRect.y && !this.isValid(node, y)) {
|
|
204
207
|
y += rowHeight;
|
|
@@ -212,12 +215,28 @@ class $67c493497dcda343$export$62444c3c724b1b20 extends (0, $fe69e47e38ed0ac4$ex
|
|
|
212
215
|
width = Math.max(width, layoutNode.layoutInfo.rect.width);
|
|
213
216
|
children.push(layoutNode);
|
|
214
217
|
if (y > this.requestedRect.maxY) {
|
|
218
|
+
var _children_at;
|
|
219
|
+
let rowsAfterRect = collection.size - (children.length + skipped);
|
|
220
|
+
let lastNode = (0, $9lycG$reactstatelycollections.getLastItem)(childNodes);
|
|
221
|
+
if ((lastNode === null || lastNode === void 0 ? void 0 : lastNode.type) === 'loader') rowsAfterRect--;
|
|
215
222
|
// Estimate the remaining height for rows that we don't need to layout right now.
|
|
216
|
-
y +=
|
|
223
|
+
y += rowsAfterRect * rowHeight;
|
|
224
|
+
// Always add the loader sentinel if present. This assumes the loader is the last row in the body,
|
|
225
|
+
// will need to refactor when handling multi section loading
|
|
226
|
+
if ((lastNode === null || lastNode === void 0 ? void 0 : lastNode.type) === 'loader' && ((_children_at = children.at(-1)) === null || _children_at === void 0 ? void 0 : _children_at.layoutInfo.type) !== 'loader') {
|
|
227
|
+
let loader = this.buildChild(lastNode, this.padding, y, layoutInfo.key);
|
|
228
|
+
loader.layoutInfo.parentKey = layoutInfo.key;
|
|
229
|
+
loader.index = collection.size;
|
|
230
|
+
width = Math.max(width, loader.layoutInfo.rect.width);
|
|
231
|
+
children.push(loader);
|
|
232
|
+
y = loader.layoutInfo.rect.maxY;
|
|
233
|
+
}
|
|
217
234
|
break;
|
|
218
235
|
}
|
|
219
236
|
}
|
|
220
|
-
if
|
|
237
|
+
// Make sure that the table body gets a height if empty or performing initial load
|
|
238
|
+
let isEmptyOrLoading = (collection === null || collection === void 0 ? void 0 : collection.size) === 0 || collection.size === 1 && collection.getItem(collection.getFirstKey()).type === 'loader';
|
|
239
|
+
if (isEmptyOrLoading) y = this.virtualizer.visibleRect.maxY;
|
|
221
240
|
else y -= this.gap;
|
|
222
241
|
rect.width = width;
|
|
223
242
|
rect.height = y - startY;
|
|
@@ -352,6 +371,9 @@ class $67c493497dcda343$export$62444c3c724b1b20 extends (0, $fe69e47e38ed0ac4$ex
|
|
|
352
371
|
this.addVisibleLayoutInfos(res, node.children[idx], rect);
|
|
353
372
|
}
|
|
354
373
|
}
|
|
374
|
+
// Always include loading sentinel even when virtualized, we assume it is always the last child for now
|
|
375
|
+
let lastRow = node.children.at(-1);
|
|
376
|
+
if ((lastRow === null || lastRow === void 0 ? void 0 : lastRow.layoutInfo.type) === 'loader') res.push(lastRow.layoutInfo);
|
|
355
377
|
break;
|
|
356
378
|
}
|
|
357
379
|
case 'headerrow':
|
|
@@ -426,7 +448,7 @@ class $67c493497dcda343$export$62444c3c724b1b20 extends (0, $fe69e47e38ed0ac4$ex
|
|
|
426
448
|
x += this.virtualizer.visibleRect.x;
|
|
427
449
|
y += this.virtualizer.visibleRect.y;
|
|
428
450
|
// Find the closest item within on either side of the point using the gap width.
|
|
429
|
-
let searchRect = new (0, $9lycG$reactstatelyvirtualizer.Rect)(x, Math.max(0, y - this.gap), 1, this.gap * 2);
|
|
451
|
+
let searchRect = new (0, $9lycG$reactstatelyvirtualizer.Rect)(x, Math.max(0, y - this.gap), 1, Math.max(1, this.gap * 2));
|
|
430
452
|
let candidates = this.getVisibleLayoutInfos(searchRect);
|
|
431
453
|
let key = null;
|
|
432
454
|
let minDistance = Infinity;
|