@react-stately/layout 3.13.10-nightly.4670 → 3.13.10-nightly.4673
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ListLayout.main.js +2 -1
- package/dist/ListLayout.main.js.map +1 -1
- package/dist/ListLayout.mjs +2 -1
- package/dist/ListLayout.module.js +2 -1
- package/dist/ListLayout.module.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/package.json +8 -8
- package/src/ListLayout.ts +5 -2
package/dist/ListLayout.main.js
CHANGED
|
@@ -180,7 +180,7 @@ class $fe69e47e38ed0ac4$export$cacbb3924155d68e extends (0, $iId4j$reactstatelyv
|
|
|
180
180
|
buildSection(node, x, y) {
|
|
181
181
|
let width = this.virtualizer.visibleRect.width;
|
|
182
182
|
let header = null;
|
|
183
|
-
if (node.rendered) {
|
|
183
|
+
if (node.rendered || this.forceSectionHeaders) {
|
|
184
184
|
let headerNode = this.buildHeader(node, x, y);
|
|
185
185
|
header = headerNode.layoutInfo;
|
|
186
186
|
header.key += ':header';
|
|
@@ -434,6 +434,7 @@ class $fe69e47e38ed0ac4$export$cacbb3924155d68e extends (0, $iId4j$reactstatelyv
|
|
|
434
434
|
this.estimatedRowHeight = options.estimatedRowHeight;
|
|
435
435
|
this.headingHeight = options.headingHeight;
|
|
436
436
|
this.estimatedHeadingHeight = options.estimatedHeadingHeight;
|
|
437
|
+
this.forceSectionHeaders = options.forceSectionHeaders;
|
|
437
438
|
this.padding = options.padding || 0;
|
|
438
439
|
this.indentationForItem = options.indentationForItem;
|
|
439
440
|
this.collator = options.collator;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAkCD,MAAM,uCAAiB;AAYhB,MAAM,kDAAsB,CAAA,GAAA,qCAAK;IAkDtC,cAAc,GAAQ,EAAE;QACtB,IAAI,CAAC,gBAAgB,CAAC;QACtB,OAAO,IA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Q,SAAS;QAClC,IAAI,CAAC,kBAAkB,GAAG,QAAQ,kBAAkB;QACpD,IAAI,CAAC,aAAa,GAAG,QAAQ,aAAa;QAC1C,IAAI,CAAC,sBAAsB,GAAG,QAAQ,sBAAsB;QAC5D,IAAI,CAAC,OAAO,GAAG,QAAQ,OAAO,IAAI;QAClC,IAAI,CAAC,kBAAkB,GAAG,QAAQ,kBAAkB;QACpD,IAAI,CAAC,QAAQ,GAAG,QAAQ,QAAQ;QAChC,IAAI,CAAC,YAAY,GAAG,QAAQ,YAAY;QACxC,IAAI,CAAC,iBAAiB,GAAG,QAAQ,iBAAiB;QAClD,IAAI,CAAC,WAAW,GAAG,IAAI;QACvB,IAAI,CAAC,WAAW,GAAG,IAAI;QACvB,IAAI,CAAC,SAAS,GAAG,EAAE;QACnB,IAAI,CAAC,SAAS,GAAG;QACjB,IAAI,CAAC,cAAc,GAAG;QACtB,IAAI,CAAC,qBAAqB,GAAG,QAAQ,qBAAqB;QAC1D,IAAI,CAAC,aAAa,GAAG,IAAI,CAAA,GAAA,mCAAG;QAC5B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAA,GAAA,mCAAG;QACxB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAA,GAAA,mCAAG;IAC5B;AAygBF","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, Key, KeyboardDelegate, Node} from '@react-types/shared';\nimport {getChildNodes} from '@react-stately/collections';\nimport {InvalidationContext, Layout, LayoutInfo, Point, Rect, Size} from '@react-stately/virtualizer';\n\nexport type ListLayoutOptions<T> = {\n /** The height of a row in px. */\n rowHeight?: number,\n estimatedRowHeight?: number,\n headingHeight?: number,\n estimatedHeadingHeight?: number,\n padding?: number,\n indentationForItem?: (collection: Collection<Node<T>>, key: Key) => number,\n collator?: Intl.Collator,\n loaderHeight?: number,\n placeholderHeight?: number,\n allowDisabledKeyFocus?: boolean\n};\n\n// A wrapper around LayoutInfo that supports hierarchy\nexport interface LayoutNode {\n node?: Node<unknown>,\n layoutInfo: LayoutInfo,\n header?: LayoutInfo,\n children?: LayoutNode[],\n validRect: Rect,\n index?: number\n}\n\ninterface ListLayoutProps {\n isLoading?: boolean\n}\n\nconst DEFAULT_HEIGHT = 48;\n\n/**\n * The ListLayout class is an implementation of a collection view {@link Layout}\n * it is used for creating lists and lists with indented sub-lists.\n *\n * To configure a ListLayout, you can use the properties to define the\n * layouts and/or use the method for defining indentation.\n * The {@link ListKeyboardDelegate} extends the existing collection view\n * delegate with an additional method to do this (it uses the same delegate object as\n * the collection view itself).\n */\nexport class ListLayout<T> extends Layout<Node<T>, ListLayoutProps> implements KeyboardDelegate, DropTargetDelegate {\n protected rowHeight: number;\n protected estimatedRowHeight: number;\n protected headingHeight: number;\n protected estimatedHeadingHeight: number;\n protected padding: number;\n protected indentationForItem?: (collection: Collection<Node<T>>, key: Key) => number;\n protected layoutInfos: Map<Key, LayoutInfo>;\n protected layoutNodes: Map<Key, LayoutNode>;\n protected contentSize: Size;\n collection: Collection<Node<T>>;\n disabledKeys: Set<Key> = new Set();\n allowDisabledKeyFocus: boolean = false;\n isLoading: boolean;\n protected lastWidth: number;\n protected lastCollection: Collection<Node<T>>;\n protected rootNodes: LayoutNode[];\n protected collator: Intl.Collator;\n protected invalidateEverything: boolean;\n protected loaderHeight: number;\n protected placeholderHeight: number;\n protected lastValidRect: Rect;\n protected validRect: 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<T> = {}) {\n super();\n this.rowHeight = options.rowHeight;\n this.estimatedRowHeight = options.estimatedRowHeight;\n this.headingHeight = options.headingHeight;\n this.estimatedHeadingHeight = options.estimatedHeadingHeight;\n this.padding = options.padding || 0;\n this.indentationForItem = options.indentationForItem;\n this.collator = options.collator;\n this.loaderHeight = options.loaderHeight;\n this.placeholderHeight = options.placeholderHeight;\n this.layoutInfos = new Map();\n this.layoutNodes = new Map();\n this.rootNodes = [];\n this.lastWidth = 0;\n this.lastCollection = null;\n this.allowDisabledKeyFocus = options.allowDisabledKeyFocus;\n this.lastValidRect = new Rect();\n this.validRect = new Rect();\n this.contentSize = new Size();\n }\n\n getLayoutInfo(key: Key) {\n this.ensureLayoutInfo(key);\n return this.layoutInfos.get(key)!;\n }\n\n getVisibleLayoutInfos(rect: Rect) {\n // Adjust rect to keep number of visible rows consistent.\n // (only if height > 1 for getDropTargetFromPoint)\n if (rect.height > 1) {\n let rowHeight = (this.rowHeight ?? this.estimatedRowHeight);\n rect.y = Math.floor(rect.y / rowHeight) * rowHeight;\n rect.height = Math.ceil(rect.height / rowHeight) * rowHeight;\n }\n\n // If layout hasn't yet been done for the requested rect, union the\n // new rect with the existing valid rect, and recompute.\n this.layoutIfNeeded(rect);\n\n let res: LayoutInfo[] = [];\n\n let addNodes = (nodes: LayoutNode[]) => {\n for (let node of nodes) {\n if (this.isVisible(node, rect)) {\n res.push(node.layoutInfo);\n if (node.header) {\n res.push(node.header);\n }\n\n if (node.children) {\n addNodes(node.children);\n }\n }\n }\n };\n\n addNodes(this.rootNodes);\n return res;\n }\n\n layoutIfNeeded(rect: Rect) {\n if (!this.lastCollection) {\n return;\n }\n\n if (!this.validRect.containsRect(rect)) {\n this.lastValidRect = this.validRect;\n this.validRect = this.validRect.union(rect);\n this.rootNodes = this.buildCollection();\n } else {\n // Ensure all of the persisted keys are available.\n for (let key of this.virtualizer.persistedKeys) {\n if (this.ensureLayoutInfo(key)) {\n break;\n }\n }\n }\n }\n\n 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.layoutInfos.has(key) && this.validRect.area < this.contentSize.area && this.lastCollection) {\n this.lastValidRect = this.validRect;\n this.validRect = new Rect(0, 0, Infinity, Infinity);\n this.rootNodes = this.buildCollection();\n this.validRect = new Rect(0, 0, this.contentSize.width, this.contentSize.height);\n return true;\n }\n\n return false;\n }\n\n isVisible(node: LayoutNode, rect: Rect) {\n return node.layoutInfo.rect.intersects(rect) || node.layoutInfo.isSticky || this.virtualizer.isPersistedKey(node.layoutInfo.key);\n }\n\n protected shouldInvalidateEverything(invalidationContext: InvalidationContext<ListLayoutProps>) {\n // Invalidate cache if the size of the collection changed.\n // In this case, we need to recalculate the entire layout.\n return invalidationContext.sizeChanged;\n }\n\n validate(invalidationContext: InvalidationContext<ListLayoutProps>) {\n this.collection = this.virtualizer.collection;\n this.isLoading = invalidationContext.layoutOptions?.isLoading || false;\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.lastValidRect = this.validRect;\n this.validRect = this.virtualizer.visibleRect.copy();\n }\n\n this.rootNodes = this.buildCollection();\n\n // Remove deleted layout nodes\n if (this.lastCollection && this.collection !== this.lastCollection) {\n for (let key of this.lastCollection.getKeys()) {\n if (!this.collection.getItem(key)) {\n let layoutNode = this.layoutNodes.get(key);\n if (layoutNode) {\n this.layoutInfos.delete(layoutNode.layoutInfo.key);\n this.layoutInfos.delete(layoutNode.header?.key);\n this.layoutNodes.delete(key);\n }\n }\n }\n }\n\n this.lastWidth = this.virtualizer.visibleRect.width;\n this.lastCollection = this.collection;\n this.invalidateEverything = false;\n }\n\n buildCollection(): LayoutNode[] {\n let y = this.padding;\n let skipped = 0;\n let nodes = [];\n for (let node of this.collection) {\n let rowHeight = (this.rowHeight ?? this.estimatedRowHeight);\n\n // Skip rows before the valid rectangle unless they are already cached.\n if (node.type === 'item' && y + rowHeight < this.validRect.y && !this.isValid(node, y)) {\n y += rowHeight;\n skipped++;\n continue;\n }\n\n let layoutNode = this.buildChild(node, 0, y);\n y = layoutNode.layoutInfo.rect.maxY;\n nodes.push(layoutNode);\n\n if (node.type === 'item' && y > this.validRect.maxY) {\n y += (this.collection.size - (nodes.length + skipped)) * rowHeight;\n break;\n }\n }\n\n if (this.isLoading) {\n let rect = new Rect(0, y, this.virtualizer.visibleRect.width,\n this.loaderHeight ?? this.virtualizer.visibleRect.height);\n let loader = new LayoutInfo('loader', 'loader', rect);\n this.layoutInfos.set('loader', loader);\n nodes.push({layoutInfo: loader});\n y = loader.rect.maxY;\n }\n\n if (nodes.length === 0) {\n let rect = new Rect(0, y, this.virtualizer.visibleRect.width,\n this.placeholderHeight ?? this.virtualizer.visibleRect.height);\n let placeholder = new LayoutInfo('placeholder', 'placeholder', rect);\n this.layoutInfos.set('placeholder', placeholder);\n nodes.push({layoutInfo: placeholder});\n y = placeholder.rect.maxY;\n }\n\n this.contentSize = new Size(this.virtualizer.visibleRect.width, y + this.padding);\n return nodes;\n }\n\n isValid(node: Node<T>, y: number) {\n let cached = this.layoutNodes.get(node.key);\n return (\n !this.invalidateEverything &&\n cached &&\n cached.node === node &&\n y === (cached.header || cached.layoutInfo).rect.y &&\n cached.layoutInfo.rect.intersects(this.lastValidRect) &&\n cached.validRect.containsRect(cached.layoutInfo.rect.intersection(this.validRect))\n );\n }\n\n buildChild(node: Node<T>, x: number, y: number): 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 layoutNode.node = node;\n\n layoutNode.layoutInfo.parentKey = node.parentKey ?? null;\n this.layoutInfos.set(layoutNode.layoutInfo.key, layoutNode.layoutInfo);\n if (layoutNode.header) {\n this.layoutInfos.set(layoutNode.header.key, layoutNode.header);\n }\n\n this.layoutNodes.set(node.key, layoutNode);\n return layoutNode;\n }\n\n 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.buildHeader(node, x, y);\n }\n }\n\n buildSection(node: Node<T>, x: number, y: number): LayoutNode {\n let width = this.virtualizer.visibleRect.width;\n let header = null;\n if (node.rendered) {\n let headerNode = this.buildHeader(node, x, y);\n header = headerNode.layoutInfo;\n header.key += ':header';\n header.parentKey = node.key;\n y += header.rect.height;\n }\n\n let rect = new Rect(0, y, width, 0);\n let layoutInfo = new LayoutInfo(node.type, node.key, rect);\n\n let startY = y;\n let skipped = 0;\n let children = [];\n for (let child of getChildNodes(node, this.collection)) {\n let rowHeight = (this.rowHeight ?? this.estimatedRowHeight);\n\n // Skip rows before the valid rectangle unless they are already cached.\n if (y + rowHeight < this.validRect.y && !this.isValid(node, y)) {\n y += rowHeight;\n skipped++;\n continue;\n }\n\n let layoutNode = this.buildChild(child, x, y);\n y = layoutNode.layoutInfo.rect.maxY;\n children.push(layoutNode);\n\n if (y > this.validRect.maxY) {\n // Estimate the remaining height for rows that we don't need to layout right now.\n y += ([...getChildNodes(node, this.collection)].length - (children.length + skipped)) * rowHeight;\n break;\n }\n }\n\n rect.height = y - startY;\n\n return {\n header,\n layoutInfo,\n children,\n validRect: layoutInfo.rect.intersection(this.validRect)\n };\n }\n\n buildHeader(node: Node<T>, x: number, y: number): LayoutNode {\n let width = this.virtualizer.visibleRect.width;\n let rectHeight = this.headingHeight;\n let isEstimated = false;\n\n // If no explicit height is available, use an estimated height.\n if (rectHeight == null) {\n // If a previous version of this layout info exists, reuse its height.\n // Mark as estimated if the size of the overall collection view changed,\n // or the content of the item changed.\n let previousLayoutNode = this.layoutNodes.get(node.key);\n let previousLayoutInfo = previousLayoutNode?.header || previousLayoutNode?.layoutInfo;\n if (previousLayoutInfo) {\n let curNode = this.collection.getItem(node.key);\n let lastNode = this.lastCollection ? this.lastCollection.getItem(node.key) : null;\n rectHeight = previousLayoutInfo.rect.height;\n isEstimated = width !== this.lastWidth || curNode !== lastNode || previousLayoutInfo.estimatedSize;\n } else {\n rectHeight = (node.rendered ? this.estimatedHeadingHeight : 0);\n isEstimated = true;\n }\n }\n\n if (rectHeight == null) {\n rectHeight = DEFAULT_HEIGHT;\n }\n\n let headerRect = new Rect(0, y, width, rectHeight);\n let header = new LayoutInfo('header', node.key, headerRect);\n header.estimatedSize = isEstimated;\n return {\n layoutInfo: header,\n children: [],\n validRect: header.rect.intersection(this.validRect)\n };\n }\n\n buildItem(node: Node<T>, x: number, y: number): LayoutNode {\n let width = this.virtualizer.visibleRect.width;\n let rectHeight = this.rowHeight;\n let isEstimated = false;\n\n // If no explicit height is available, use an estimated height.\n if (rectHeight == null) {\n // If a previous version of this layout info exists, reuse its height.\n // Mark as estimated if the size of the overall collection view changed,\n // or the content of the item changed.\n let previousLayoutNode = this.layoutNodes.get(node.key);\n if (previousLayoutNode) {\n rectHeight = previousLayoutNode.layoutInfo.rect.height;\n isEstimated = width !== this.lastWidth || node !== previousLayoutNode.node || previousLayoutNode.layoutInfo.estimatedSize;\n } else {\n rectHeight = this.estimatedRowHeight;\n isEstimated = true;\n }\n }\n\n if (rectHeight == null) {\n rectHeight = DEFAULT_HEIGHT;\n }\n\n if (typeof this.indentationForItem === 'function') {\n x += this.indentationForItem(this.collection, node.key) || 0;\n }\n\n let rect = new Rect(x, y, width - x, rectHeight);\n let layoutInfo = new LayoutInfo(node.type, node.key, rect);\n // allow overflow so the focus ring/selection ring can extend outside to overlap with the adjacent items borders\n layoutInfo.allowOverflow = true;\n layoutInfo.estimatedSize = isEstimated;\n return {\n layoutInfo,\n validRect: layoutInfo.rect\n };\n }\n\n updateItemSize(key: Key, size: Size) {\n let layoutInfo = this.layoutInfos.get(key);\n // If no layoutInfo, item has been deleted/removed.\n if (!layoutInfo) {\n return false;\n }\n\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 this.layoutInfos.set(key, newLayoutInfo);\n\n // Invalidate layout for this layout node and all parents\n this.updateLayoutNode(key, layoutInfo, newLayoutInfo);\n\n let node = this.collection.getItem(layoutInfo.parentKey);\n while (node) {\n this.updateLayoutNode(node.key, layoutInfo, newLayoutInfo);\n node = this.collection.getItem(node.parentKey);\n }\n\n return true;\n }\n\n return false;\n }\n\n updateLayoutNode(key: Key, oldLayoutInfo: LayoutInfo, newLayoutInfo: LayoutInfo) {\n let n = this.layoutNodes.get(key);\n if (n) {\n // Invalidate by reseting validRect.\n n.validRect = new Rect();\n\n // Replace layout info in LayoutNode\n if (n.header === oldLayoutInfo) {\n n.header = newLayoutInfo;\n } else if (n.layoutInfo === oldLayoutInfo) {\n n.layoutInfo = newLayoutInfo;\n }\n }\n }\n\n getContentSize() {\n return this.contentSize;\n }\n\n getKeyAbove(key: Key): Key | null {\n let collection = this.collection;\n\n key = collection.getKeyBefore(key);\n while (key != null) {\n let item = collection.getItem(key);\n if (item.type === 'item' && (this.allowDisabledKeyFocus || !this.disabledKeys.has(item.key))) {\n return key;\n }\n\n key = collection.getKeyBefore(key);\n }\n }\n\n getKeyBelow(key: Key): Key | null {\n let collection = this.collection;\n\n key = collection.getKeyAfter(key);\n while (key != null) {\n let item = collection.getItem(key);\n if (item.type === 'item' && (this.allowDisabledKeyFocus || !this.disabledKeys.has(item.key))) {\n return key;\n }\n\n key = collection.getKeyAfter(key);\n }\n }\n\n getKeyPageAbove(key: Key): Key | null {\n let layoutInfo = this.getLayoutInfo(key);\n\n if (layoutInfo) {\n let pageY = Math.max(0, layoutInfo.rect.y + layoutInfo.rect.height - this.virtualizer.visibleRect.height);\n while (layoutInfo && layoutInfo.rect.y > pageY) {\n let keyAbove = this.getKeyAbove(layoutInfo.key);\n layoutInfo = this.getLayoutInfo(keyAbove);\n }\n\n if (layoutInfo) {\n return layoutInfo.key;\n }\n }\n\n return this.getFirstKey();\n }\n\n getKeyPageBelow(key: Key): Key | null {\n let layoutInfo = this.getLayoutInfo(key != null ? key : this.getFirstKey());\n\n if (layoutInfo) {\n let pageY = Math.min(this.virtualizer.contentSize.height, layoutInfo.rect.y - layoutInfo.rect.height + this.virtualizer.visibleRect.height);\n while (layoutInfo && layoutInfo.rect.y < pageY) {\n let keyBelow = this.getKeyBelow(layoutInfo.key);\n layoutInfo = this.getLayoutInfo(keyBelow);\n }\n\n if (layoutInfo) {\n return layoutInfo.key;\n }\n }\n\n return this.getLastKey();\n }\n\n getFirstKey(): Key | null {\n let collection = this.collection;\n let key = collection.getFirstKey();\n while (key != null) {\n let item = collection.getItem(key);\n if (item.type === 'item' && (this.allowDisabledKeyFocus || !this.disabledKeys.has(item.key))) {\n return key;\n }\n\n key = collection.getKeyAfter(key);\n }\n }\n\n getLastKey(): Key | null {\n let collection = this.collection;\n let key = collection.getLastKey();\n while (key != null) {\n let item = collection.getItem(key);\n if (item.type === 'item' && (this.allowDisabledKeyFocus || !this.disabledKeys.has(item.key))) {\n return key;\n }\n\n key = collection.getKeyBefore(key);\n }\n }\n\n getKeyForSearch(search: string, fromKey?: Key): Key | null {\n if (!this.collator) {\n return null;\n }\n\n let collection = this.collection;\n let key = fromKey || this.getFirstKey();\n while (key != null) {\n let item = collection.getItem(key);\n let substring = item.textValue.slice(0, search.length);\n if (item.textValue && this.collator.compare(substring, search) === 0) {\n return key;\n }\n\n key = this.getKeyBelow(key);\n }\n\n return null;\n }\n\n getDropTargetFromPoint(x: number, y: number, isValidDropTarget: (target: DropTarget) => boolean): DropTarget {\n x += this.virtualizer.visibleRect.x;\n y += this.virtualizer.visibleRect.y;\n\n let key = this.virtualizer.keyAtPoint(new Point(x, y));\n if (key == null || this.collection.size === 0) {\n return {type: 'root'};\n }\n\n let layoutInfo = this.getLayoutInfo(key);\n let rect = layoutInfo.rect;\n let target: DropTarget = {\n type: 'item',\n key: layoutInfo.key,\n dropPosition: 'on'\n };\n\n // If dropping on the item isn't accepted, try the target before or after depending on the y position.\n // Otherwise, if dropping on the item is accepted, still try the before/after positions if within 10px\n // of the top or bottom of the item.\n if (!isValidDropTarget(target)) {\n if (y <= rect.y + rect.height / 2 && isValidDropTarget({...target, dropPosition: 'before'})) {\n target.dropPosition = 'before';\n } else if (isValidDropTarget({...target, dropPosition: 'after'})) {\n target.dropPosition = 'after';\n }\n } else if (y <= rect.y + 10 && isValidDropTarget({...target, dropPosition: 'before'})) {\n target.dropPosition = 'before';\n } else if (y >= rect.maxY - 10 && isValidDropTarget({...target, dropPosition: 'after'})) {\n target.dropPosition = 'after';\n }\n\n return target;\n }\n}\n"],"names":[],"version":3,"file":"ListLayout.main.js.map"}
|
|
1
|
+
{"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAmCD,MAAM,uCAAiB;AAYhB,MAAM,kDAAsB,CAAA,GAAA,qCAAK;IAoDtC,cAAc,GAAQ,EAAE;QACtB,IAAI,CAAC,gBAAgB,CAAC;QACtB,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC;IAC9B;IAEA,sBAAsB,IAAU,EAAE;QAChC,yDAAyD;QACzD,kDAAkD;QAClD,IAAI,KAAK,MAAM,GAAG,GAAG;gBACF;YAAjB,IAAI,YAAa,CAAA,kBAAA,IAAI,CAAC,SAAS,cAAd,6BAAA,kBAAkB,IAAI,CAAC,kBAAkB;YAC1D,KAAK,CAAC,GAAG,KAAK,KAAK,CAAC,KAAK,CAAC,GAAG,aAAa;YAC1C,KAAK,MAAM,GAAG,KAAK,IAAI,CAAC,KAAK,MAAM,GAAG,aAAa;QACrD;QAEA,mEAAmE;QACnE,wDAAwD;QACxD,IAAI,CAAC,cAAc,CAAC;QAEpB,IAAI,MAAoB,EAAE;QAE1B,IAAI,WAAW,CAAC;YACd,KAAK,IAAI,QAAQ,MACf,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,OAAO;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AAS,GAAG,EAAE;QACnB,IAAI,CAAC,SAAS,GAAG;QACjB,IAAI,CAAC,cAAc,GAAG;QACtB,IAAI,CAAC,qBAAqB,GAAG,QAAQ,qBAAqB;QAC1D,IAAI,CAAC,aAAa,GAAG,IAAI,CAAA,GAAA,mCAAG;QAC5B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAA,GAAA,mCAAG;QACxB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAA,GAAA,mCAAG;IAC5B;AAygBF","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, Key, KeyboardDelegate, Node} from '@react-types/shared';\nimport {getChildNodes} from '@react-stately/collections';\nimport {InvalidationContext, Layout, LayoutInfo, Point, Rect, Size} from '@react-stately/virtualizer';\n\nexport type ListLayoutOptions<T> = {\n /** The height of a row in px. */\n rowHeight?: number,\n estimatedRowHeight?: number,\n headingHeight?: number,\n estimatedHeadingHeight?: number,\n padding?: number,\n indentationForItem?: (collection: Collection<Node<T>>, key: Key) => number,\n collator?: Intl.Collator,\n loaderHeight?: number,\n placeholderHeight?: number,\n allowDisabledKeyFocus?: boolean,\n forceSectionHeaders?: boolean\n};\n\n// A wrapper around LayoutInfo that supports hierarchy\nexport interface LayoutNode {\n node?: Node<unknown>,\n layoutInfo: LayoutInfo,\n header?: LayoutInfo,\n children?: LayoutNode[],\n validRect: Rect,\n index?: number\n}\n\ninterface ListLayoutProps {\n isLoading?: boolean\n}\n\nconst DEFAULT_HEIGHT = 48;\n\n/**\n * The ListLayout class is an implementation of a collection view {@link Layout}\n * it is used for creating lists and lists with indented sub-lists.\n *\n * To configure a ListLayout, you can use the properties to define the\n * layouts and/or use the method for defining indentation.\n * The {@link ListKeyboardDelegate} extends the existing collection view\n * delegate with an additional method to do this (it uses the same delegate object as\n * the collection view itself).\n */\nexport class ListLayout<T> extends Layout<Node<T>, ListLayoutProps> implements KeyboardDelegate, DropTargetDelegate {\n protected rowHeight: number;\n protected estimatedRowHeight: number;\n protected headingHeight: number;\n protected estimatedHeadingHeight: number;\n protected forceSectionHeaders: boolean;\n protected padding: number;\n protected indentationForItem?: (collection: Collection<Node<T>>, key: Key) => number;\n protected layoutInfos: Map<Key, LayoutInfo>;\n protected layoutNodes: Map<Key, LayoutNode>;\n protected contentSize: Size;\n collection: Collection<Node<T>>;\n disabledKeys: Set<Key> = new Set();\n allowDisabledKeyFocus: boolean = false;\n isLoading: boolean;\n protected lastWidth: number;\n protected lastCollection: Collection<Node<T>>;\n protected rootNodes: LayoutNode[];\n protected collator: Intl.Collator;\n protected invalidateEverything: boolean;\n protected loaderHeight: number;\n protected placeholderHeight: number;\n protected lastValidRect: Rect;\n protected validRect: 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<T> = {}) {\n super();\n this.rowHeight = options.rowHeight;\n this.estimatedRowHeight = options.estimatedRowHeight;\n this.headingHeight = options.headingHeight;\n this.estimatedHeadingHeight = options.estimatedHeadingHeight;\n this.forceSectionHeaders = options.forceSectionHeaders;\n this.padding = options.padding || 0;\n this.indentationForItem = options.indentationForItem;\n this.collator = options.collator;\n this.loaderHeight = options.loaderHeight;\n this.placeholderHeight = options.placeholderHeight;\n this.layoutInfos = new Map();\n this.layoutNodes = new Map();\n this.rootNodes = [];\n this.lastWidth = 0;\n this.lastCollection = null;\n this.allowDisabledKeyFocus = options.allowDisabledKeyFocus;\n this.lastValidRect = new Rect();\n this.validRect = new Rect();\n this.contentSize = new Size();\n }\n\n getLayoutInfo(key: Key) {\n this.ensureLayoutInfo(key);\n return this.layoutInfos.get(key)!;\n }\n\n getVisibleLayoutInfos(rect: Rect) {\n // Adjust rect to keep number of visible rows consistent.\n // (only if height > 1 for getDropTargetFromPoint)\n if (rect.height > 1) {\n let rowHeight = (this.rowHeight ?? this.estimatedRowHeight);\n rect.y = Math.floor(rect.y / rowHeight) * rowHeight;\n rect.height = Math.ceil(rect.height / rowHeight) * rowHeight;\n }\n\n // If layout hasn't yet been done for the requested rect, union the\n // new rect with the existing valid rect, and recompute.\n this.layoutIfNeeded(rect);\n\n let res: LayoutInfo[] = [];\n\n let addNodes = (nodes: LayoutNode[]) => {\n for (let node of nodes) {\n if (this.isVisible(node, rect)) {\n res.push(node.layoutInfo);\n if (node.header) {\n res.push(node.header);\n }\n\n if (node.children) {\n addNodes(node.children);\n }\n }\n }\n };\n\n addNodes(this.rootNodes);\n return res;\n }\n\n layoutIfNeeded(rect: Rect) {\n if (!this.lastCollection) {\n return;\n }\n\n if (!this.validRect.containsRect(rect)) {\n this.lastValidRect = this.validRect;\n this.validRect = this.validRect.union(rect);\n this.rootNodes = this.buildCollection();\n } else {\n // Ensure all of the persisted keys are available.\n for (let key of this.virtualizer.persistedKeys) {\n if (this.ensureLayoutInfo(key)) {\n break;\n }\n }\n }\n }\n\n 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.layoutInfos.has(key) && this.validRect.area < this.contentSize.area && this.lastCollection) {\n this.lastValidRect = this.validRect;\n this.validRect = new Rect(0, 0, Infinity, Infinity);\n this.rootNodes = this.buildCollection();\n this.validRect = new Rect(0, 0, this.contentSize.width, this.contentSize.height);\n return true;\n }\n\n return false;\n }\n\n isVisible(node: LayoutNode, rect: Rect) {\n return node.layoutInfo.rect.intersects(rect) || node.layoutInfo.isSticky || this.virtualizer.isPersistedKey(node.layoutInfo.key);\n }\n\n protected shouldInvalidateEverything(invalidationContext: InvalidationContext<ListLayoutProps>) {\n // Invalidate cache if the size of the collection changed.\n // In this case, we need to recalculate the entire layout.\n return invalidationContext.sizeChanged;\n }\n\n validate(invalidationContext: InvalidationContext<ListLayoutProps>) {\n this.collection = this.virtualizer.collection;\n this.isLoading = invalidationContext.layoutOptions?.isLoading || false;\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.lastValidRect = this.validRect;\n this.validRect = this.virtualizer.visibleRect.copy();\n }\n\n this.rootNodes = this.buildCollection();\n\n // Remove deleted layout nodes\n if (this.lastCollection && this.collection !== this.lastCollection) {\n for (let key of this.lastCollection.getKeys()) {\n if (!this.collection.getItem(key)) {\n let layoutNode = this.layoutNodes.get(key);\n if (layoutNode) {\n this.layoutInfos.delete(layoutNode.layoutInfo.key);\n this.layoutInfos.delete(layoutNode.header?.key);\n this.layoutNodes.delete(key);\n }\n }\n }\n }\n\n this.lastWidth = this.virtualizer.visibleRect.width;\n this.lastCollection = this.collection;\n this.invalidateEverything = false;\n }\n\n buildCollection(): LayoutNode[] {\n let y = this.padding;\n let skipped = 0;\n let nodes = [];\n for (let node of this.collection) {\n let rowHeight = (this.rowHeight ?? this.estimatedRowHeight);\n\n // Skip rows before the valid rectangle unless they are already cached.\n if (node.type === 'item' && y + rowHeight < this.validRect.y && !this.isValid(node, y)) {\n y += rowHeight;\n skipped++;\n continue;\n }\n\n let layoutNode = this.buildChild(node, 0, y);\n y = layoutNode.layoutInfo.rect.maxY;\n nodes.push(layoutNode);\n\n if (node.type === 'item' && y > this.validRect.maxY) {\n y += (this.collection.size - (nodes.length + skipped)) * rowHeight;\n break;\n }\n }\n\n if (this.isLoading) {\n let rect = new Rect(0, y, this.virtualizer.visibleRect.width,\n this.loaderHeight ?? this.virtualizer.visibleRect.height);\n let loader = new LayoutInfo('loader', 'loader', rect);\n this.layoutInfos.set('loader', loader);\n nodes.push({layoutInfo: loader});\n y = loader.rect.maxY;\n }\n\n if (nodes.length === 0) {\n let rect = new Rect(0, y, this.virtualizer.visibleRect.width,\n this.placeholderHeight ?? this.virtualizer.visibleRect.height);\n let placeholder = new LayoutInfo('placeholder', 'placeholder', rect);\n this.layoutInfos.set('placeholder', placeholder);\n nodes.push({layoutInfo: placeholder});\n y = placeholder.rect.maxY;\n }\n\n this.contentSize = new Size(this.virtualizer.visibleRect.width, y + this.padding);\n return nodes;\n }\n\n isValid(node: Node<T>, y: number) {\n let cached = this.layoutNodes.get(node.key);\n return (\n !this.invalidateEverything &&\n cached &&\n cached.node === node &&\n y === (cached.header || cached.layoutInfo).rect.y &&\n cached.layoutInfo.rect.intersects(this.lastValidRect) &&\n cached.validRect.containsRect(cached.layoutInfo.rect.intersection(this.validRect))\n );\n }\n\n buildChild(node: Node<T>, x: number, y: number): 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 layoutNode.node = node;\n\n layoutNode.layoutInfo.parentKey = node.parentKey ?? null;\n this.layoutInfos.set(layoutNode.layoutInfo.key, layoutNode.layoutInfo);\n if (layoutNode.header) {\n this.layoutInfos.set(layoutNode.header.key, layoutNode.header);\n }\n\n this.layoutNodes.set(node.key, layoutNode);\n return layoutNode;\n }\n\n 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.buildHeader(node, x, y);\n }\n }\n\n buildSection(node: Node<T>, x: number, y: number): LayoutNode {\n let width = this.virtualizer.visibleRect.width;\n let header = null;\n if (node.rendered || this.forceSectionHeaders) {\n let headerNode = this.buildHeader(node, x, y);\n header = headerNode.layoutInfo;\n header.key += ':header';\n header.parentKey = node.key;\n y += header.rect.height;\n }\n\n let rect = new Rect(0, y, width, 0);\n let layoutInfo = new LayoutInfo(node.type, node.key, rect);\n\n let startY = y;\n let skipped = 0;\n let children = [];\n for (let child of getChildNodes(node, this.collection)) {\n let rowHeight = (this.rowHeight ?? this.estimatedRowHeight);\n\n // Skip rows before the valid rectangle unless they are already cached.\n if (y + rowHeight < this.validRect.y && !this.isValid(node, y)) {\n y += rowHeight;\n skipped++;\n continue;\n }\n\n let layoutNode = this.buildChild(child, x, y);\n y = layoutNode.layoutInfo.rect.maxY;\n children.push(layoutNode);\n\n if (y > this.validRect.maxY) {\n // Estimate the remaining height for rows that we don't need to layout right now.\n y += ([...getChildNodes(node, this.collection)].length - (children.length + skipped)) * rowHeight;\n break;\n }\n }\n\n rect.height = y - startY;\n\n return {\n header,\n layoutInfo,\n children,\n validRect: layoutInfo.rect.intersection(this.validRect)\n };\n }\n\n buildHeader(node: Node<T>, x: number, y: number): LayoutNode {\n let width = this.virtualizer.visibleRect.width;\n let rectHeight = this.headingHeight;\n let isEstimated = false;\n\n // If no explicit height is available, use an estimated height.\n if (rectHeight == null) {\n // If a previous version of this layout info exists, reuse its height.\n // Mark as estimated if the size of the overall collection view changed,\n // or the content of the item changed.\n let previousLayoutNode = this.layoutNodes.get(node.key);\n let previousLayoutInfo = previousLayoutNode?.header || previousLayoutNode?.layoutInfo;\n if (previousLayoutInfo) {\n let curNode = this.collection.getItem(node.key);\n let lastNode = this.lastCollection ? this.lastCollection.getItem(node.key) : null;\n rectHeight = previousLayoutInfo.rect.height;\n isEstimated = width !== this.lastWidth || curNode !== lastNode || previousLayoutInfo.estimatedSize;\n } else {\n rectHeight = (node.rendered ? this.estimatedHeadingHeight : 0);\n isEstimated = true;\n }\n }\n\n if (rectHeight == null) {\n rectHeight = DEFAULT_HEIGHT;\n }\n\n let headerRect = new Rect(0, y, width, rectHeight);\n let header = new LayoutInfo('header', node.key, headerRect);\n header.estimatedSize = isEstimated;\n return {\n layoutInfo: header,\n children: [],\n validRect: header.rect.intersection(this.validRect)\n };\n }\n\n buildItem(node: Node<T>, x: number, y: number): LayoutNode {\n let width = this.virtualizer.visibleRect.width;\n let rectHeight = this.rowHeight;\n let isEstimated = false;\n\n // If no explicit height is available, use an estimated height.\n if (rectHeight == null) {\n // If a previous version of this layout info exists, reuse its height.\n // Mark as estimated if the size of the overall collection view changed,\n // or the content of the item changed.\n let previousLayoutNode = this.layoutNodes.get(node.key);\n if (previousLayoutNode) {\n rectHeight = previousLayoutNode.layoutInfo.rect.height;\n isEstimated = width !== this.lastWidth || node !== previousLayoutNode.node || previousLayoutNode.layoutInfo.estimatedSize;\n } else {\n rectHeight = this.estimatedRowHeight;\n isEstimated = true;\n }\n }\n\n if (rectHeight == null) {\n rectHeight = DEFAULT_HEIGHT;\n }\n\n if (typeof this.indentationForItem === 'function') {\n x += this.indentationForItem(this.collection, node.key) || 0;\n }\n\n let rect = new Rect(x, y, width - x, rectHeight);\n let layoutInfo = new LayoutInfo(node.type, node.key, rect);\n // allow overflow so the focus ring/selection ring can extend outside to overlap with the adjacent items borders\n layoutInfo.allowOverflow = true;\n layoutInfo.estimatedSize = isEstimated;\n return {\n layoutInfo,\n validRect: layoutInfo.rect\n };\n }\n\n updateItemSize(key: Key, size: Size) {\n let layoutInfo = this.layoutInfos.get(key);\n // If no layoutInfo, item has been deleted/removed.\n if (!layoutInfo) {\n return false;\n }\n\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 this.layoutInfos.set(key, newLayoutInfo);\n\n // Invalidate layout for this layout node and all parents\n this.updateLayoutNode(key, layoutInfo, newLayoutInfo);\n\n let node = this.collection.getItem(layoutInfo.parentKey);\n while (node) {\n this.updateLayoutNode(node.key, layoutInfo, newLayoutInfo);\n node = this.collection.getItem(node.parentKey);\n }\n\n return true;\n }\n\n return false;\n }\n\n updateLayoutNode(key: Key, oldLayoutInfo: LayoutInfo, newLayoutInfo: LayoutInfo) {\n let n = this.layoutNodes.get(key);\n if (n) {\n // Invalidate by reseting validRect.\n n.validRect = new Rect();\n\n // Replace layout info in LayoutNode\n if (n.header === oldLayoutInfo) {\n n.header = newLayoutInfo;\n } else if (n.layoutInfo === oldLayoutInfo) {\n n.layoutInfo = newLayoutInfo;\n }\n }\n }\n\n getContentSize() {\n return this.contentSize;\n }\n\n getKeyAbove(key: Key): Key | null {\n let collection = this.collection;\n\n key = collection.getKeyBefore(key);\n while (key != null) {\n let item = collection.getItem(key);\n if (item.type === 'item' && (this.allowDisabledKeyFocus || !this.disabledKeys.has(item.key))) {\n return key;\n }\n\n key = collection.getKeyBefore(key);\n }\n }\n\n getKeyBelow(key: Key): Key | null {\n let collection = this.collection;\n\n key = collection.getKeyAfter(key);\n while (key != null) {\n let item = collection.getItem(key);\n if (item.type === 'item' && (this.allowDisabledKeyFocus || !this.disabledKeys.has(item.key))) {\n return key;\n }\n\n key = collection.getKeyAfter(key);\n }\n }\n\n getKeyPageAbove(key: Key): Key | null {\n let layoutInfo = this.getLayoutInfo(key);\n\n if (layoutInfo) {\n let pageY = Math.max(0, layoutInfo.rect.y + layoutInfo.rect.height - this.virtualizer.visibleRect.height);\n while (layoutInfo && layoutInfo.rect.y > pageY) {\n let keyAbove = this.getKeyAbove(layoutInfo.key);\n layoutInfo = this.getLayoutInfo(keyAbove);\n }\n\n if (layoutInfo) {\n return layoutInfo.key;\n }\n }\n\n return this.getFirstKey();\n }\n\n getKeyPageBelow(key: Key): Key | null {\n let layoutInfo = this.getLayoutInfo(key != null ? key : this.getFirstKey());\n\n if (layoutInfo) {\n let pageY = Math.min(this.virtualizer.contentSize.height, layoutInfo.rect.y - layoutInfo.rect.height + this.virtualizer.visibleRect.height);\n while (layoutInfo && layoutInfo.rect.y < pageY) {\n let keyBelow = this.getKeyBelow(layoutInfo.key);\n layoutInfo = this.getLayoutInfo(keyBelow);\n }\n\n if (layoutInfo) {\n return layoutInfo.key;\n }\n }\n\n return this.getLastKey();\n }\n\n getFirstKey(): Key | null {\n let collection = this.collection;\n let key = collection.getFirstKey();\n while (key != null) {\n let item = collection.getItem(key);\n if (item.type === 'item' && (this.allowDisabledKeyFocus || !this.disabledKeys.has(item.key))) {\n return key;\n }\n\n key = collection.getKeyAfter(key);\n }\n }\n\n getLastKey(): Key | null {\n let collection = this.collection;\n let key = collection.getLastKey();\n while (key != null) {\n let item = collection.getItem(key);\n if (item.type === 'item' && (this.allowDisabledKeyFocus || !this.disabledKeys.has(item.key))) {\n return key;\n }\n\n key = collection.getKeyBefore(key);\n }\n }\n\n getKeyForSearch(search: string, fromKey?: Key): Key | null {\n if (!this.collator) {\n return null;\n }\n\n let collection = this.collection;\n let key = fromKey || this.getFirstKey();\n while (key != null) {\n let item = collection.getItem(key);\n let substring = item.textValue.slice(0, search.length);\n if (item.textValue && this.collator.compare(substring, search) === 0) {\n return key;\n }\n\n key = this.getKeyBelow(key);\n }\n\n return null;\n }\n\n getDropTargetFromPoint(x: number, y: number, isValidDropTarget: (target: DropTarget) => boolean): DropTarget {\n x += this.virtualizer.visibleRect.x;\n y += this.virtualizer.visibleRect.y;\n\n let key = this.virtualizer.keyAtPoint(new Point(x, y));\n if (key == null || this.collection.size === 0) {\n return {type: 'root'};\n }\n\n let layoutInfo = this.getLayoutInfo(key);\n let rect = layoutInfo.rect;\n let target: DropTarget = {\n type: 'item',\n key: layoutInfo.key,\n dropPosition: 'on'\n };\n\n // If dropping on the item isn't accepted, try the target before or after depending on the y position.\n // Otherwise, if dropping on the item is accepted, still try the before/after positions if within 10px\n // of the top or bottom of the item.\n if (!isValidDropTarget(target)) {\n if (y <= rect.y + rect.height / 2 && isValidDropTarget({...target, dropPosition: 'before'})) {\n target.dropPosition = 'before';\n } else if (isValidDropTarget({...target, dropPosition: 'after'})) {\n target.dropPosition = 'after';\n }\n } else if (y <= rect.y + 10 && isValidDropTarget({...target, dropPosition: 'before'})) {\n target.dropPosition = 'before';\n } else if (y >= rect.maxY - 10 && isValidDropTarget({...target, dropPosition: 'after'})) {\n target.dropPosition = 'after';\n }\n\n return target;\n }\n}\n"],"names":[],"version":3,"file":"ListLayout.main.js.map"}
|
package/dist/ListLayout.mjs
CHANGED
|
@@ -174,7 +174,7 @@ class $61ef60fc9b1041f4$export$cacbb3924155d68e extends (0, $img26$Layout) {
|
|
|
174
174
|
buildSection(node, x, y) {
|
|
175
175
|
let width = this.virtualizer.visibleRect.width;
|
|
176
176
|
let header = null;
|
|
177
|
-
if (node.rendered) {
|
|
177
|
+
if (node.rendered || this.forceSectionHeaders) {
|
|
178
178
|
let headerNode = this.buildHeader(node, x, y);
|
|
179
179
|
header = headerNode.layoutInfo;
|
|
180
180
|
header.key += ':header';
|
|
@@ -428,6 +428,7 @@ class $61ef60fc9b1041f4$export$cacbb3924155d68e extends (0, $img26$Layout) {
|
|
|
428
428
|
this.estimatedRowHeight = options.estimatedRowHeight;
|
|
429
429
|
this.headingHeight = options.headingHeight;
|
|
430
430
|
this.estimatedHeadingHeight = options.estimatedHeadingHeight;
|
|
431
|
+
this.forceSectionHeaders = options.forceSectionHeaders;
|
|
431
432
|
this.padding = options.padding || 0;
|
|
432
433
|
this.indentationForItem = options.indentationForItem;
|
|
433
434
|
this.collator = options.collator;
|
|
@@ -174,7 +174,7 @@ class $61ef60fc9b1041f4$export$cacbb3924155d68e extends (0, $img26$Layout) {
|
|
|
174
174
|
buildSection(node, x, y) {
|
|
175
175
|
let width = this.virtualizer.visibleRect.width;
|
|
176
176
|
let header = null;
|
|
177
|
-
if (node.rendered) {
|
|
177
|
+
if (node.rendered || this.forceSectionHeaders) {
|
|
178
178
|
let headerNode = this.buildHeader(node, x, y);
|
|
179
179
|
header = headerNode.layoutInfo;
|
|
180
180
|
header.key += ':header';
|
|
@@ -428,6 +428,7 @@ class $61ef60fc9b1041f4$export$cacbb3924155d68e extends (0, $img26$Layout) {
|
|
|
428
428
|
this.estimatedRowHeight = options.estimatedRowHeight;
|
|
429
429
|
this.headingHeight = options.headingHeight;
|
|
430
430
|
this.estimatedHeadingHeight = options.estimatedHeadingHeight;
|
|
431
|
+
this.forceSectionHeaders = options.forceSectionHeaders;
|
|
431
432
|
this.padding = options.padding || 0;
|
|
432
433
|
this.indentationForItem = options.indentationForItem;
|
|
433
434
|
this.collator = options.collator;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAkCD,MAAM,uCAAiB;AAYhB,MAAM,kDAAsB,CAAA,GAAA,aAAK;IAkDtC,cAAc,GAAQ,EAAE;QACtB,IAAI,CAAC,gBAAgB,CAAC;QACtB,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC;IAC9B;IAEA,sBAAsB,IAAU,EAAE;QAChC,yDAAyD;QACzD,kDAAkD;QAClD,IAAI,KAAK,MAAM,GAAG,GAAG;gBACF;YAAjB,IAAI,YAAa,CAAA,kBAAA,IAAI,CAAC,SAAS,cAAd,6BAAA,kBAAkB,IAAI,CAAC,kBAAkB;YAC1D,KAAK,CAAC,GAAG,KAAK,KAAK,CAAC,KAAK,CAAC,GAAG,aAAa;YAC1C,KAAK,MAAM,GAAG,KAAK,IAAI,CAAC,KAAK,MAAM,GAAG,aAAa;QACrD;QAEA,mEAAmE;QACnE,wDAAwD;QACxD,IAAI,CAAC,cAAc,CAAC;QAEpB,IAAI,MAAoB,EAAE;QAE1B,IAAI,WAAW,CAAC;YACd,KAAK,IAAI,QAAQ,MACf,IAAI,IAAI,CAAC,SAAS,CAAC,MAAM,OAAO;gBAC9B,IAAI,IAAI,CAAC,KAAK,UAAU;gBACxB,IAAI,KAAK,MAAM,EACb,IAAI,IAAI,CAAC,KAAK,MAAM;gBAGtB,IAAI,KAAK,QAAQ,EACf,SAAS,KAAK,QAAQ;YAE1B;QAEJ;QAEA,SAAS,IAAI,CAAC,SAAS;QACvB,OAAO;IACT;IAEA,eAAe,IAAU,EAAE;QACzB,IAAI,CAAC,IAAI,CAAC,cAAc,EACtB;QAGF,IAAI,CAAC,IA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licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport {Collection, DropTarget, DropTargetDelegate, Key, KeyboardDelegate, Node} from '@react-types/shared';\nimport {getChildNodes} from '@react-stately/collections';\nimport {InvalidationContext, Layout, LayoutInfo, Point, Rect, Size} from '@react-stately/virtualizer';\n\nexport type ListLayoutOptions<T> = {\n /** The height of a row in px. */\n rowHeight?: number,\n estimatedRowHeight?: number,\n headingHeight?: number,\n estimatedHeadingHeight?: number,\n padding?: number,\n indentationForItem?: (collection: Collection<Node<T>>, key: Key) => number,\n collator?: Intl.Collator,\n loaderHeight?: number,\n placeholderHeight?: number,\n allowDisabledKeyFocus?: boolean\n};\n\n// A wrapper around LayoutInfo that supports hierarchy\nexport interface LayoutNode {\n node?: Node<unknown>,\n layoutInfo: LayoutInfo,\n header?: LayoutInfo,\n children?: LayoutNode[],\n validRect: Rect,\n index?: number\n}\n\ninterface ListLayoutProps {\n isLoading?: boolean\n}\n\nconst DEFAULT_HEIGHT = 48;\n\n/**\n * The ListLayout class is an implementation of a collection view {@link Layout}\n * it is used for creating lists and lists with indented sub-lists.\n *\n * To configure a ListLayout, you can use the properties to define the\n * layouts and/or use the method for defining indentation.\n * The {@link ListKeyboardDelegate} extends the existing collection view\n * delegate with an additional method to do this (it uses the same delegate object as\n * the collection view itself).\n */\nexport class ListLayout<T> extends Layout<Node<T>, ListLayoutProps> implements KeyboardDelegate, DropTargetDelegate {\n protected rowHeight: number;\n protected estimatedRowHeight: number;\n protected headingHeight: number;\n protected estimatedHeadingHeight: number;\n protected padding: number;\n protected indentationForItem?: (collection: Collection<Node<T>>, key: Key) => number;\n protected layoutInfos: Map<Key, LayoutInfo>;\n protected layoutNodes: Map<Key, LayoutNode>;\n protected contentSize: Size;\n collection: Collection<Node<T>>;\n disabledKeys: Set<Key> = new Set();\n allowDisabledKeyFocus: boolean = false;\n isLoading: boolean;\n protected lastWidth: number;\n protected lastCollection: Collection<Node<T>>;\n protected rootNodes: LayoutNode[];\n protected collator: Intl.Collator;\n protected invalidateEverything: boolean;\n protected loaderHeight: number;\n protected placeholderHeight: number;\n protected lastValidRect: Rect;\n protected validRect: 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<T> = {}) {\n super();\n this.rowHeight = options.rowHeight;\n this.estimatedRowHeight = options.estimatedRowHeight;\n this.headingHeight = options.headingHeight;\n this.estimatedHeadingHeight = options.estimatedHeadingHeight;\n this.padding = options.padding || 0;\n this.indentationForItem = options.indentationForItem;\n this.collator = options.collator;\n this.loaderHeight = options.loaderHeight;\n this.placeholderHeight = options.placeholderHeight;\n this.layoutInfos = new Map();\n this.layoutNodes = new Map();\n this.rootNodes = [];\n this.lastWidth = 0;\n this.lastCollection = null;\n this.allowDisabledKeyFocus = options.allowDisabledKeyFocus;\n this.lastValidRect = new Rect();\n this.validRect = new Rect();\n this.contentSize = new Size();\n }\n\n getLayoutInfo(key: Key) {\n this.ensureLayoutInfo(key);\n return this.layoutInfos.get(key)!;\n }\n\n getVisibleLayoutInfos(rect: Rect) {\n // Adjust rect to keep number of visible rows consistent.\n // (only if height > 1 for getDropTargetFromPoint)\n if (rect.height > 1) {\n let rowHeight = (this.rowHeight ?? this.estimatedRowHeight);\n rect.y = Math.floor(rect.y / rowHeight) * rowHeight;\n rect.height = Math.ceil(rect.height / rowHeight) * rowHeight;\n }\n\n // If layout hasn't yet been done for the requested rect, union the\n // new rect with the existing valid rect, and recompute.\n this.layoutIfNeeded(rect);\n\n let res: LayoutInfo[] = [];\n\n let addNodes = (nodes: LayoutNode[]) => {\n for (let node of nodes) {\n if (this.isVisible(node, rect)) {\n res.push(node.layoutInfo);\n if (node.header) {\n res.push(node.header);\n }\n\n if (node.children) {\n addNodes(node.children);\n }\n }\n }\n };\n\n addNodes(this.rootNodes);\n return res;\n }\n\n layoutIfNeeded(rect: Rect) {\n if (!this.lastCollection) {\n return;\n }\n\n if (!this.validRect.containsRect(rect)) {\n this.lastValidRect = this.validRect;\n this.validRect = this.validRect.union(rect);\n this.rootNodes = this.buildCollection();\n } else {\n // Ensure all of the persisted keys are available.\n for (let key of this.virtualizer.persistedKeys) {\n if (this.ensureLayoutInfo(key)) {\n break;\n }\n }\n }\n }\n\n 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.layoutInfos.has(key) && this.validRect.area < this.contentSize.area && this.lastCollection) {\n this.lastValidRect = this.validRect;\n this.validRect = new Rect(0, 0, Infinity, Infinity);\n this.rootNodes = this.buildCollection();\n this.validRect = new Rect(0, 0, this.contentSize.width, this.contentSize.height);\n return true;\n }\n\n return false;\n }\n\n isVisible(node: LayoutNode, rect: Rect) {\n return node.layoutInfo.rect.intersects(rect) || node.layoutInfo.isSticky || this.virtualizer.isPersistedKey(node.layoutInfo.key);\n }\n\n protected shouldInvalidateEverything(invalidationContext: InvalidationContext<ListLayoutProps>) {\n // Invalidate cache if the size of the collection changed.\n // In this case, we need to recalculate the entire layout.\n return invalidationContext.sizeChanged;\n }\n\n validate(invalidationContext: InvalidationContext<ListLayoutProps>) {\n this.collection = this.virtualizer.collection;\n this.isLoading = invalidationContext.layoutOptions?.isLoading || false;\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.lastValidRect = this.validRect;\n this.validRect = this.virtualizer.visibleRect.copy();\n }\n\n this.rootNodes = this.buildCollection();\n\n // Remove deleted layout nodes\n if (this.lastCollection && this.collection !== this.lastCollection) {\n for (let key of this.lastCollection.getKeys()) {\n if (!this.collection.getItem(key)) {\n let layoutNode = this.layoutNodes.get(key);\n if (layoutNode) {\n this.layoutInfos.delete(layoutNode.layoutInfo.key);\n this.layoutInfos.delete(layoutNode.header?.key);\n this.layoutNodes.delete(key);\n }\n }\n }\n }\n\n this.lastWidth = this.virtualizer.visibleRect.width;\n this.lastCollection = this.collection;\n this.invalidateEverything = false;\n }\n\n buildCollection(): LayoutNode[] {\n let y = this.padding;\n let skipped = 0;\n let nodes = [];\n for (let node of this.collection) {\n let rowHeight = (this.rowHeight ?? this.estimatedRowHeight);\n\n // Skip rows before the valid rectangle unless they are already cached.\n if (node.type === 'item' && y + rowHeight < this.validRect.y && !this.isValid(node, y)) {\n y += rowHeight;\n skipped++;\n continue;\n }\n\n let layoutNode = this.buildChild(node, 0, y);\n y = layoutNode.layoutInfo.rect.maxY;\n nodes.push(layoutNode);\n\n if (node.type === 'item' && y > this.validRect.maxY) {\n y += (this.collection.size - (nodes.length + skipped)) * rowHeight;\n break;\n }\n }\n\n if (this.isLoading) {\n let rect = new Rect(0, y, this.virtualizer.visibleRect.width,\n this.loaderHeight ?? this.virtualizer.visibleRect.height);\n let loader = new LayoutInfo('loader', 'loader', rect);\n this.layoutInfos.set('loader', loader);\n nodes.push({layoutInfo: loader});\n y = loader.rect.maxY;\n }\n\n if (nodes.length === 0) {\n let rect = new Rect(0, y, this.virtualizer.visibleRect.width,\n this.placeholderHeight ?? this.virtualizer.visibleRect.height);\n let placeholder = new LayoutInfo('placeholder', 'placeholder', rect);\n this.layoutInfos.set('placeholder', placeholder);\n nodes.push({layoutInfo: placeholder});\n y = placeholder.rect.maxY;\n }\n\n this.contentSize = new Size(this.virtualizer.visibleRect.width, y + this.padding);\n return nodes;\n }\n\n isValid(node: Node<T>, y: number) {\n let cached = this.layoutNodes.get(node.key);\n return (\n !this.invalidateEverything &&\n cached &&\n cached.node === node &&\n y === (cached.header || cached.layoutInfo).rect.y &&\n cached.layoutInfo.rect.intersects(this.lastValidRect) &&\n cached.validRect.containsRect(cached.layoutInfo.rect.intersection(this.validRect))\n );\n }\n\n buildChild(node: Node<T>, x: number, y: number): 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 layoutNode.node = node;\n\n layoutNode.layoutInfo.parentKey = node.parentKey ?? null;\n this.layoutInfos.set(layoutNode.layoutInfo.key, layoutNode.layoutInfo);\n if (layoutNode.header) {\n this.layoutInfos.set(layoutNode.header.key, layoutNode.header);\n }\n\n this.layoutNodes.set(node.key, layoutNode);\n return layoutNode;\n }\n\n 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.buildHeader(node, x, y);\n }\n }\n\n buildSection(node: Node<T>, x: number, y: number): LayoutNode {\n let width = this.virtualizer.visibleRect.width;\n let header = null;\n if (node.rendered) {\n let headerNode = this.buildHeader(node, x, y);\n header = headerNode.layoutInfo;\n header.key += ':header';\n header.parentKey = node.key;\n y += header.rect.height;\n }\n\n let rect = new Rect(0, y, width, 0);\n let layoutInfo = new LayoutInfo(node.type, node.key, rect);\n\n let startY = y;\n let skipped = 0;\n let children = [];\n for (let child of getChildNodes(node, this.collection)) {\n let rowHeight = (this.rowHeight ?? this.estimatedRowHeight);\n\n // Skip rows before the valid rectangle unless they are already cached.\n if (y + rowHeight < this.validRect.y && !this.isValid(node, y)) {\n y += rowHeight;\n skipped++;\n continue;\n }\n\n let layoutNode = this.buildChild(child, x, y);\n y = layoutNode.layoutInfo.rect.maxY;\n children.push(layoutNode);\n\n if (y > this.validRect.maxY) {\n // Estimate the remaining height for rows that we don't need to layout right now.\n y += ([...getChildNodes(node, this.collection)].length - (children.length + skipped)) * rowHeight;\n break;\n }\n }\n\n rect.height = y - startY;\n\n return {\n header,\n layoutInfo,\n children,\n validRect: layoutInfo.rect.intersection(this.validRect)\n };\n }\n\n buildHeader(node: Node<T>, x: number, y: number): LayoutNode {\n let width = this.virtualizer.visibleRect.width;\n let rectHeight = this.headingHeight;\n let isEstimated = false;\n\n // If no explicit height is available, use an estimated height.\n if (rectHeight == null) {\n // If a previous version of this layout info exists, reuse its height.\n // Mark as estimated if the size of the overall collection view changed,\n // or the content of the item changed.\n let previousLayoutNode = this.layoutNodes.get(node.key);\n let previousLayoutInfo = previousLayoutNode?.header || previousLayoutNode?.layoutInfo;\n if (previousLayoutInfo) {\n let curNode = this.collection.getItem(node.key);\n let lastNode = this.lastCollection ? this.lastCollection.getItem(node.key) : null;\n rectHeight = previousLayoutInfo.rect.height;\n isEstimated = width !== this.lastWidth || curNode !== lastNode || previousLayoutInfo.estimatedSize;\n } else {\n rectHeight = (node.rendered ? this.estimatedHeadingHeight : 0);\n isEstimated = true;\n }\n }\n\n if (rectHeight == null) {\n rectHeight = DEFAULT_HEIGHT;\n }\n\n let headerRect = new Rect(0, y, width, rectHeight);\n let header = new LayoutInfo('header', node.key, headerRect);\n header.estimatedSize = isEstimated;\n return {\n layoutInfo: header,\n children: [],\n validRect: header.rect.intersection(this.validRect)\n };\n }\n\n buildItem(node: Node<T>, x: number, y: number): LayoutNode {\n let width = this.virtualizer.visibleRect.width;\n let rectHeight = this.rowHeight;\n let isEstimated = false;\n\n // If no explicit height is available, use an estimated height.\n if (rectHeight == null) {\n // If a previous version of this layout info exists, reuse its height.\n // Mark as estimated if the size of the overall collection view changed,\n // or the content of the item changed.\n let previousLayoutNode = this.layoutNodes.get(node.key);\n if (previousLayoutNode) {\n rectHeight = previousLayoutNode.layoutInfo.rect.height;\n isEstimated = width !== this.lastWidth || node !== previousLayoutNode.node || previousLayoutNode.layoutInfo.estimatedSize;\n } else {\n rectHeight = this.estimatedRowHeight;\n isEstimated = true;\n }\n }\n\n if (rectHeight == null) {\n rectHeight = DEFAULT_HEIGHT;\n }\n\n if (typeof this.indentationForItem === 'function') {\n x += this.indentationForItem(this.collection, node.key) || 0;\n }\n\n let rect = new Rect(x, y, width - x, rectHeight);\n let layoutInfo = new LayoutInfo(node.type, node.key, rect);\n // allow overflow so the focus ring/selection ring can extend outside to overlap with the adjacent items borders\n layoutInfo.allowOverflow = true;\n layoutInfo.estimatedSize = isEstimated;\n return {\n layoutInfo,\n validRect: layoutInfo.rect\n };\n }\n\n updateItemSize(key: Key, size: Size) {\n let layoutInfo = this.layoutInfos.get(key);\n // If no layoutInfo, item has been deleted/removed.\n if (!layoutInfo) {\n return false;\n }\n\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 this.layoutInfos.set(key, newLayoutInfo);\n\n // Invalidate layout for this layout node and all parents\n this.updateLayoutNode(key, layoutInfo, newLayoutInfo);\n\n let node = this.collection.getItem(layoutInfo.parentKey);\n while (node) {\n this.updateLayoutNode(node.key, layoutInfo, newLayoutInfo);\n node = this.collection.getItem(node.parentKey);\n }\n\n return true;\n }\n\n return false;\n }\n\n updateLayoutNode(key: Key, oldLayoutInfo: LayoutInfo, newLayoutInfo: LayoutInfo) {\n let n = this.layoutNodes.get(key);\n if (n) {\n // Invalidate by reseting validRect.\n n.validRect = new Rect();\n\n // Replace layout info in LayoutNode\n if (n.header === oldLayoutInfo) {\n n.header = newLayoutInfo;\n } else if (n.layoutInfo === oldLayoutInfo) {\n n.layoutInfo = newLayoutInfo;\n }\n }\n }\n\n getContentSize() {\n return this.contentSize;\n }\n\n getKeyAbove(key: Key): Key | null {\n let collection = this.collection;\n\n key = collection.getKeyBefore(key);\n while (key != null) {\n let item = collection.getItem(key);\n if (item.type === 'item' && (this.allowDisabledKeyFocus || !this.disabledKeys.has(item.key))) {\n return key;\n }\n\n key = collection.getKeyBefore(key);\n }\n }\n\n getKeyBelow(key: Key): Key | null {\n let collection = this.collection;\n\n key = collection.getKeyAfter(key);\n while (key != null) {\n let item = collection.getItem(key);\n if (item.type === 'item' && (this.allowDisabledKeyFocus || !this.disabledKeys.has(item.key))) {\n return key;\n }\n\n key = collection.getKeyAfter(key);\n }\n }\n\n getKeyPageAbove(key: Key): Key | null {\n let layoutInfo = this.getLayoutInfo(key);\n\n if (layoutInfo) {\n let pageY = Math.max(0, layoutInfo.rect.y + layoutInfo.rect.height - this.virtualizer.visibleRect.height);\n while (layoutInfo && layoutInfo.rect.y > pageY) {\n let keyAbove = this.getKeyAbove(layoutInfo.key);\n layoutInfo = this.getLayoutInfo(keyAbove);\n }\n\n if (layoutInfo) {\n return layoutInfo.key;\n }\n }\n\n return this.getFirstKey();\n }\n\n getKeyPageBelow(key: Key): Key | null {\n let layoutInfo = this.getLayoutInfo(key != null ? key : this.getFirstKey());\n\n if (layoutInfo) {\n let pageY = Math.min(this.virtualizer.contentSize.height, layoutInfo.rect.y - layoutInfo.rect.height + this.virtualizer.visibleRect.height);\n while (layoutInfo && layoutInfo.rect.y < pageY) {\n let keyBelow = this.getKeyBelow(layoutInfo.key);\n layoutInfo = this.getLayoutInfo(keyBelow);\n }\n\n if (layoutInfo) {\n return layoutInfo.key;\n }\n }\n\n return this.getLastKey();\n }\n\n getFirstKey(): Key | null {\n let collection = this.collection;\n let key = collection.getFirstKey();\n while (key != null) {\n let item = collection.getItem(key);\n if (item.type === 'item' && (this.allowDisabledKeyFocus || !this.disabledKeys.has(item.key))) {\n return key;\n }\n\n key = collection.getKeyAfter(key);\n }\n }\n\n getLastKey(): Key | null {\n let collection = this.collection;\n let key = collection.getLastKey();\n while (key != null) {\n let item = collection.getItem(key);\n if (item.type === 'item' && (this.allowDisabledKeyFocus || !this.disabledKeys.has(item.key))) {\n return key;\n }\n\n key = collection.getKeyBefore(key);\n }\n }\n\n getKeyForSearch(search: string, fromKey?: Key): Key | null {\n if (!this.collator) {\n return null;\n }\n\n let collection = this.collection;\n let key = fromKey || this.getFirstKey();\n while (key != null) {\n let item = collection.getItem(key);\n let substring = item.textValue.slice(0, search.length);\n if (item.textValue && this.collator.compare(substring, search) === 0) {\n return key;\n }\n\n key = this.getKeyBelow(key);\n }\n\n return null;\n }\n\n getDropTargetFromPoint(x: number, y: number, isValidDropTarget: (target: DropTarget) => boolean): DropTarget {\n x += this.virtualizer.visibleRect.x;\n y += this.virtualizer.visibleRect.y;\n\n let key = this.virtualizer.keyAtPoint(new Point(x, y));\n if (key == null || this.collection.size === 0) {\n return {type: 'root'};\n }\n\n let layoutInfo = this.getLayoutInfo(key);\n let rect = layoutInfo.rect;\n let target: DropTarget = {\n type: 'item',\n key: layoutInfo.key,\n dropPosition: 'on'\n };\n\n // If dropping on the item isn't accepted, try the target before or after depending on the y position.\n // Otherwise, if dropping on the item is accepted, still try the before/after positions if within 10px\n // of the top or bottom of the item.\n if (!isValidDropTarget(target)) {\n if (y <= rect.y + rect.height / 2 && isValidDropTarget({...target, dropPosition: 'before'})) {\n target.dropPosition = 'before';\n } else if (isValidDropTarget({...target, dropPosition: 'after'})) {\n target.dropPosition = 'after';\n }\n } else if (y <= rect.y + 10 && isValidDropTarget({...target, dropPosition: 'before'})) {\n target.dropPosition = 'before';\n } else if (y >= rect.maxY - 10 && isValidDropTarget({...target, dropPosition: 'after'})) {\n target.dropPosition = 'after';\n }\n\n return target;\n }\n}\n"],"names":[],"version":3,"file":"ListLayout.module.js.map"}
|
|
1
|
+
{"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAmCD,MAAM,uCAAiB;AAYhB,MAAM,kDAAsB,CAAA,GAAA,aAAK;IAoDtC,cAAc,GAAQ,EAAE;QACtB,IAAI,CAAC,gBAAgB,CAAC;QACtB,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC;IAC9B;IAEA,sBAAsB,IAAU,EAAE;QAChC,yDAAyD;QACzD,kDAAkD;QAClD,IAAI,KAAK,MAAM,GAAG,GAAG;gBACF;YAAjB,IAAI,YAAa,CAAA,kBAAA,IAAI,CAAC,SAAS,cAAd,6B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G,QAAQ,mBAAmB;QACtD,IAAI,CAAC,OAAO,GAAG,QAAQ,OAAO,IAAI;QAClC,IAAI,CAAC,kBAAkB,GAAG,QAAQ,kBAAkB;QACpD,IAAI,CAAC,QAAQ,GAAG,QAAQ,QAAQ;QAChC,IAAI,CAAC,YAAY,GAAG,QAAQ,YAAY;QACxC,IAAI,CAAC,iBAAiB,GAAG,QAAQ,iBAAiB;QAClD,IAAI,CAAC,WAAW,GAAG,IAAI;QACvB,IAAI,CAAC,WAAW,GAAG,IAAI;QACvB,IAAI,CAAC,SAAS,GAAG,EAAE;QACnB,IAAI,CAAC,SAAS,GAAG;QACjB,IAAI,CAAC,cAAc,GAAG;QACtB,IAAI,CAAC,qBAAqB,GAAG,QAAQ,qBAAqB;QAC1D,IAAI,CAAC,aAAa,GAAG,IAAI,CAAA,GAAA,WAAG;QAC5B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAA,GAAA,WAAG;QACxB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAA,GAAA,WAAG;IAC5B;AAygBF","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, Key, KeyboardDelegate, Node} from '@react-types/shared';\nimport {getChildNodes} from '@react-stately/collections';\nimport {InvalidationContext, Layout, LayoutInfo, Point, Rect, Size} from '@react-stately/virtualizer';\n\nexport type ListLayoutOptions<T> = {\n /** The height of a row in px. */\n rowHeight?: number,\n estimatedRowHeight?: number,\n headingHeight?: number,\n estimatedHeadingHeight?: number,\n padding?: number,\n indentationForItem?: (collection: Collection<Node<T>>, key: Key) => number,\n collator?: Intl.Collator,\n loaderHeight?: number,\n placeholderHeight?: number,\n allowDisabledKeyFocus?: boolean,\n forceSectionHeaders?: boolean\n};\n\n// A wrapper around LayoutInfo that supports hierarchy\nexport interface LayoutNode {\n node?: Node<unknown>,\n layoutInfo: LayoutInfo,\n header?: LayoutInfo,\n children?: LayoutNode[],\n validRect: Rect,\n index?: number\n}\n\ninterface ListLayoutProps {\n isLoading?: boolean\n}\n\nconst DEFAULT_HEIGHT = 48;\n\n/**\n * The ListLayout class is an implementation of a collection view {@link Layout}\n * it is used for creating lists and lists with indented sub-lists.\n *\n * To configure a ListLayout, you can use the properties to define the\n * layouts and/or use the method for defining indentation.\n * The {@link ListKeyboardDelegate} extends the existing collection view\n * delegate with an additional method to do this (it uses the same delegate object as\n * the collection view itself).\n */\nexport class ListLayout<T> extends Layout<Node<T>, ListLayoutProps> implements KeyboardDelegate, DropTargetDelegate {\n protected rowHeight: number;\n protected estimatedRowHeight: number;\n protected headingHeight: number;\n protected estimatedHeadingHeight: number;\n protected forceSectionHeaders: boolean;\n protected padding: number;\n protected indentationForItem?: (collection: Collection<Node<T>>, key: Key) => number;\n protected layoutInfos: Map<Key, LayoutInfo>;\n protected layoutNodes: Map<Key, LayoutNode>;\n protected contentSize: Size;\n collection: Collection<Node<T>>;\n disabledKeys: Set<Key> = new Set();\n allowDisabledKeyFocus: boolean = false;\n isLoading: boolean;\n protected lastWidth: number;\n protected lastCollection: Collection<Node<T>>;\n protected rootNodes: LayoutNode[];\n protected collator: Intl.Collator;\n protected invalidateEverything: boolean;\n protected loaderHeight: number;\n protected placeholderHeight: number;\n protected lastValidRect: Rect;\n protected validRect: 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<T> = {}) {\n super();\n this.rowHeight = options.rowHeight;\n this.estimatedRowHeight = options.estimatedRowHeight;\n this.headingHeight = options.headingHeight;\n this.estimatedHeadingHeight = options.estimatedHeadingHeight;\n this.forceSectionHeaders = options.forceSectionHeaders;\n this.padding = options.padding || 0;\n this.indentationForItem = options.indentationForItem;\n this.collator = options.collator;\n this.loaderHeight = options.loaderHeight;\n this.placeholderHeight = options.placeholderHeight;\n this.layoutInfos = new Map();\n this.layoutNodes = new Map();\n this.rootNodes = [];\n this.lastWidth = 0;\n this.lastCollection = null;\n this.allowDisabledKeyFocus = options.allowDisabledKeyFocus;\n this.lastValidRect = new Rect();\n this.validRect = new Rect();\n this.contentSize = new Size();\n }\n\n getLayoutInfo(key: Key) {\n this.ensureLayoutInfo(key);\n return this.layoutInfos.get(key)!;\n }\n\n getVisibleLayoutInfos(rect: Rect) {\n // Adjust rect to keep number of visible rows consistent.\n // (only if height > 1 for getDropTargetFromPoint)\n if (rect.height > 1) {\n let rowHeight = (this.rowHeight ?? this.estimatedRowHeight);\n rect.y = Math.floor(rect.y / rowHeight) * rowHeight;\n rect.height = Math.ceil(rect.height / rowHeight) * rowHeight;\n }\n\n // If layout hasn't yet been done for the requested rect, union the\n // new rect with the existing valid rect, and recompute.\n this.layoutIfNeeded(rect);\n\n let res: LayoutInfo[] = [];\n\n let addNodes = (nodes: LayoutNode[]) => {\n for (let node of nodes) {\n if (this.isVisible(node, rect)) {\n res.push(node.layoutInfo);\n if (node.header) {\n res.push(node.header);\n }\n\n if (node.children) {\n addNodes(node.children);\n }\n }\n }\n };\n\n addNodes(this.rootNodes);\n return res;\n }\n\n layoutIfNeeded(rect: Rect) {\n if (!this.lastCollection) {\n return;\n }\n\n if (!this.validRect.containsRect(rect)) {\n this.lastValidRect = this.validRect;\n this.validRect = this.validRect.union(rect);\n this.rootNodes = this.buildCollection();\n } else {\n // Ensure all of the persisted keys are available.\n for (let key of this.virtualizer.persistedKeys) {\n if (this.ensureLayoutInfo(key)) {\n break;\n }\n }\n }\n }\n\n 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.layoutInfos.has(key) && this.validRect.area < this.contentSize.area && this.lastCollection) {\n this.lastValidRect = this.validRect;\n this.validRect = new Rect(0, 0, Infinity, Infinity);\n this.rootNodes = this.buildCollection();\n this.validRect = new Rect(0, 0, this.contentSize.width, this.contentSize.height);\n return true;\n }\n\n return false;\n }\n\n isVisible(node: LayoutNode, rect: Rect) {\n return node.layoutInfo.rect.intersects(rect) || node.layoutInfo.isSticky || this.virtualizer.isPersistedKey(node.layoutInfo.key);\n }\n\n protected shouldInvalidateEverything(invalidationContext: InvalidationContext<ListLayoutProps>) {\n // Invalidate cache if the size of the collection changed.\n // In this case, we need to recalculate the entire layout.\n return invalidationContext.sizeChanged;\n }\n\n validate(invalidationContext: InvalidationContext<ListLayoutProps>) {\n this.collection = this.virtualizer.collection;\n this.isLoading = invalidationContext.layoutOptions?.isLoading || false;\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.lastValidRect = this.validRect;\n this.validRect = this.virtualizer.visibleRect.copy();\n }\n\n this.rootNodes = this.buildCollection();\n\n // Remove deleted layout nodes\n if (this.lastCollection && this.collection !== this.lastCollection) {\n for (let key of this.lastCollection.getKeys()) {\n if (!this.collection.getItem(key)) {\n let layoutNode = this.layoutNodes.get(key);\n if (layoutNode) {\n this.layoutInfos.delete(layoutNode.layoutInfo.key);\n this.layoutInfos.delete(layoutNode.header?.key);\n this.layoutNodes.delete(key);\n }\n }\n }\n }\n\n this.lastWidth = this.virtualizer.visibleRect.width;\n this.lastCollection = this.collection;\n this.invalidateEverything = false;\n }\n\n buildCollection(): LayoutNode[] {\n let y = this.padding;\n let skipped = 0;\n let nodes = [];\n for (let node of this.collection) {\n let rowHeight = (this.rowHeight ?? this.estimatedRowHeight);\n\n // Skip rows before the valid rectangle unless they are already cached.\n if (node.type === 'item' && y + rowHeight < this.validRect.y && !this.isValid(node, y)) {\n y += rowHeight;\n skipped++;\n continue;\n }\n\n let layoutNode = this.buildChild(node, 0, y);\n y = layoutNode.layoutInfo.rect.maxY;\n nodes.push(layoutNode);\n\n if (node.type === 'item' && y > this.validRect.maxY) {\n y += (this.collection.size - (nodes.length + skipped)) * rowHeight;\n break;\n }\n }\n\n if (this.isLoading) {\n let rect = new Rect(0, y, this.virtualizer.visibleRect.width,\n this.loaderHeight ?? this.virtualizer.visibleRect.height);\n let loader = new LayoutInfo('loader', 'loader', rect);\n this.layoutInfos.set('loader', loader);\n nodes.push({layoutInfo: loader});\n y = loader.rect.maxY;\n }\n\n if (nodes.length === 0) {\n let rect = new Rect(0, y, this.virtualizer.visibleRect.width,\n this.placeholderHeight ?? this.virtualizer.visibleRect.height);\n let placeholder = new LayoutInfo('placeholder', 'placeholder', rect);\n this.layoutInfos.set('placeholder', placeholder);\n nodes.push({layoutInfo: placeholder});\n y = placeholder.rect.maxY;\n }\n\n this.contentSize = new Size(this.virtualizer.visibleRect.width, y + this.padding);\n return nodes;\n }\n\n isValid(node: Node<T>, y: number) {\n let cached = this.layoutNodes.get(node.key);\n return (\n !this.invalidateEverything &&\n cached &&\n cached.node === node &&\n y === (cached.header || cached.layoutInfo).rect.y &&\n cached.layoutInfo.rect.intersects(this.lastValidRect) &&\n cached.validRect.containsRect(cached.layoutInfo.rect.intersection(this.validRect))\n );\n }\n\n buildChild(node: Node<T>, x: number, y: number): 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 layoutNode.node = node;\n\n layoutNode.layoutInfo.parentKey = node.parentKey ?? null;\n this.layoutInfos.set(layoutNode.layoutInfo.key, layoutNode.layoutInfo);\n if (layoutNode.header) {\n this.layoutInfos.set(layoutNode.header.key, layoutNode.header);\n }\n\n this.layoutNodes.set(node.key, layoutNode);\n return layoutNode;\n }\n\n 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.buildHeader(node, x, y);\n }\n }\n\n buildSection(node: Node<T>, x: number, y: number): LayoutNode {\n let width = this.virtualizer.visibleRect.width;\n let header = null;\n if (node.rendered || this.forceSectionHeaders) {\n let headerNode = this.buildHeader(node, x, y);\n header = headerNode.layoutInfo;\n header.key += ':header';\n header.parentKey = node.key;\n y += header.rect.height;\n }\n\n let rect = new Rect(0, y, width, 0);\n let layoutInfo = new LayoutInfo(node.type, node.key, rect);\n\n let startY = y;\n let skipped = 0;\n let children = [];\n for (let child of getChildNodes(node, this.collection)) {\n let rowHeight = (this.rowHeight ?? this.estimatedRowHeight);\n\n // Skip rows before the valid rectangle unless they are already cached.\n if (y + rowHeight < this.validRect.y && !this.isValid(node, y)) {\n y += rowHeight;\n skipped++;\n continue;\n }\n\n let layoutNode = this.buildChild(child, x, y);\n y = layoutNode.layoutInfo.rect.maxY;\n children.push(layoutNode);\n\n if (y > this.validRect.maxY) {\n // Estimate the remaining height for rows that we don't need to layout right now.\n y += ([...getChildNodes(node, this.collection)].length - (children.length + skipped)) * rowHeight;\n break;\n }\n }\n\n rect.height = y - startY;\n\n return {\n header,\n layoutInfo,\n children,\n validRect: layoutInfo.rect.intersection(this.validRect)\n };\n }\n\n buildHeader(node: Node<T>, x: number, y: number): LayoutNode {\n let width = this.virtualizer.visibleRect.width;\n let rectHeight = this.headingHeight;\n let isEstimated = false;\n\n // If no explicit height is available, use an estimated height.\n if (rectHeight == null) {\n // If a previous version of this layout info exists, reuse its height.\n // Mark as estimated if the size of the overall collection view changed,\n // or the content of the item changed.\n let previousLayoutNode = this.layoutNodes.get(node.key);\n let previousLayoutInfo = previousLayoutNode?.header || previousLayoutNode?.layoutInfo;\n if (previousLayoutInfo) {\n let curNode = this.collection.getItem(node.key);\n let lastNode = this.lastCollection ? this.lastCollection.getItem(node.key) : null;\n rectHeight = previousLayoutInfo.rect.height;\n isEstimated = width !== this.lastWidth || curNode !== lastNode || previousLayoutInfo.estimatedSize;\n } else {\n rectHeight = (node.rendered ? this.estimatedHeadingHeight : 0);\n isEstimated = true;\n }\n }\n\n if (rectHeight == null) {\n rectHeight = DEFAULT_HEIGHT;\n }\n\n let headerRect = new Rect(0, y, width, rectHeight);\n let header = new LayoutInfo('header', node.key, headerRect);\n header.estimatedSize = isEstimated;\n return {\n layoutInfo: header,\n children: [],\n validRect: header.rect.intersection(this.validRect)\n };\n }\n\n buildItem(node: Node<T>, x: number, y: number): LayoutNode {\n let width = this.virtualizer.visibleRect.width;\n let rectHeight = this.rowHeight;\n let isEstimated = false;\n\n // If no explicit height is available, use an estimated height.\n if (rectHeight == null) {\n // If a previous version of this layout info exists, reuse its height.\n // Mark as estimated if the size of the overall collection view changed,\n // or the content of the item changed.\n let previousLayoutNode = this.layoutNodes.get(node.key);\n if (previousLayoutNode) {\n rectHeight = previousLayoutNode.layoutInfo.rect.height;\n isEstimated = width !== this.lastWidth || node !== previousLayoutNode.node || previousLayoutNode.layoutInfo.estimatedSize;\n } else {\n rectHeight = this.estimatedRowHeight;\n isEstimated = true;\n }\n }\n\n if (rectHeight == null) {\n rectHeight = DEFAULT_HEIGHT;\n }\n\n if (typeof this.indentationForItem === 'function') {\n x += this.indentationForItem(this.collection, node.key) || 0;\n }\n\n let rect = new Rect(x, y, width - x, rectHeight);\n let layoutInfo = new LayoutInfo(node.type, node.key, rect);\n // allow overflow so the focus ring/selection ring can extend outside to overlap with the adjacent items borders\n layoutInfo.allowOverflow = true;\n layoutInfo.estimatedSize = isEstimated;\n return {\n layoutInfo,\n validRect: layoutInfo.rect\n };\n }\n\n updateItemSize(key: Key, size: Size) {\n let layoutInfo = this.layoutInfos.get(key);\n // If no layoutInfo, item has been deleted/removed.\n if (!layoutInfo) {\n return false;\n }\n\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 this.layoutInfos.set(key, newLayoutInfo);\n\n // Invalidate layout for this layout node and all parents\n this.updateLayoutNode(key, layoutInfo, newLayoutInfo);\n\n let node = this.collection.getItem(layoutInfo.parentKey);\n while (node) {\n this.updateLayoutNode(node.key, layoutInfo, newLayoutInfo);\n node = this.collection.getItem(node.parentKey);\n }\n\n return true;\n }\n\n return false;\n }\n\n updateLayoutNode(key: Key, oldLayoutInfo: LayoutInfo, newLayoutInfo: LayoutInfo) {\n let n = this.layoutNodes.get(key);\n if (n) {\n // Invalidate by reseting validRect.\n n.validRect = new Rect();\n\n // Replace layout info in LayoutNode\n if (n.header === oldLayoutInfo) {\n n.header = newLayoutInfo;\n } else if (n.layoutInfo === oldLayoutInfo) {\n n.layoutInfo = newLayoutInfo;\n }\n }\n }\n\n getContentSize() {\n return this.contentSize;\n }\n\n getKeyAbove(key: Key): Key | null {\n let collection = this.collection;\n\n key = collection.getKeyBefore(key);\n while (key != null) {\n let item = collection.getItem(key);\n if (item.type === 'item' && (this.allowDisabledKeyFocus || !this.disabledKeys.has(item.key))) {\n return key;\n }\n\n key = collection.getKeyBefore(key);\n }\n }\n\n getKeyBelow(key: Key): Key | null {\n let collection = this.collection;\n\n key = collection.getKeyAfter(key);\n while (key != null) {\n let item = collection.getItem(key);\n if (item.type === 'item' && (this.allowDisabledKeyFocus || !this.disabledKeys.has(item.key))) {\n return key;\n }\n\n key = collection.getKeyAfter(key);\n }\n }\n\n getKeyPageAbove(key: Key): Key | null {\n let layoutInfo = this.getLayoutInfo(key);\n\n if (layoutInfo) {\n let pageY = Math.max(0, layoutInfo.rect.y + layoutInfo.rect.height - this.virtualizer.visibleRect.height);\n while (layoutInfo && layoutInfo.rect.y > pageY) {\n let keyAbove = this.getKeyAbove(layoutInfo.key);\n layoutInfo = this.getLayoutInfo(keyAbove);\n }\n\n if (layoutInfo) {\n return layoutInfo.key;\n }\n }\n\n return this.getFirstKey();\n }\n\n getKeyPageBelow(key: Key): Key | null {\n let layoutInfo = this.getLayoutInfo(key != null ? key : this.getFirstKey());\n\n if (layoutInfo) {\n let pageY = Math.min(this.virtualizer.contentSize.height, layoutInfo.rect.y - layoutInfo.rect.height + this.virtualizer.visibleRect.height);\n while (layoutInfo && layoutInfo.rect.y < pageY) {\n let keyBelow = this.getKeyBelow(layoutInfo.key);\n layoutInfo = this.getLayoutInfo(keyBelow);\n }\n\n if (layoutInfo) {\n return layoutInfo.key;\n }\n }\n\n return this.getLastKey();\n }\n\n getFirstKey(): Key | null {\n let collection = this.collection;\n let key = collection.getFirstKey();\n while (key != null) {\n let item = collection.getItem(key);\n if (item.type === 'item' && (this.allowDisabledKeyFocus || !this.disabledKeys.has(item.key))) {\n return key;\n }\n\n key = collection.getKeyAfter(key);\n }\n }\n\n getLastKey(): Key | null {\n let collection = this.collection;\n let key = collection.getLastKey();\n while (key != null) {\n let item = collection.getItem(key);\n if (item.type === 'item' && (this.allowDisabledKeyFocus || !this.disabledKeys.has(item.key))) {\n return key;\n }\n\n key = collection.getKeyBefore(key);\n }\n }\n\n getKeyForSearch(search: string, fromKey?: Key): Key | null {\n if (!this.collator) {\n return null;\n }\n\n let collection = this.collection;\n let key = fromKey || this.getFirstKey();\n while (key != null) {\n let item = collection.getItem(key);\n let substring = item.textValue.slice(0, search.length);\n if (item.textValue && this.collator.compare(substring, search) === 0) {\n return key;\n }\n\n key = this.getKeyBelow(key);\n }\n\n return null;\n }\n\n getDropTargetFromPoint(x: number, y: number, isValidDropTarget: (target: DropTarget) => boolean): DropTarget {\n x += this.virtualizer.visibleRect.x;\n y += this.virtualizer.visibleRect.y;\n\n let key = this.virtualizer.keyAtPoint(new Point(x, y));\n if (key == null || this.collection.size === 0) {\n return {type: 'root'};\n }\n\n let layoutInfo = this.getLayoutInfo(key);\n let rect = layoutInfo.rect;\n let target: DropTarget = {\n type: 'item',\n key: layoutInfo.key,\n dropPosition: 'on'\n };\n\n // If dropping on the item isn't accepted, try the target before or after depending on the y position.\n // Otherwise, if dropping on the item is accepted, still try the before/after positions if within 10px\n // of the top or bottom of the item.\n if (!isValidDropTarget(target)) {\n if (y <= rect.y + rect.height / 2 && isValidDropTarget({...target, dropPosition: 'before'})) {\n target.dropPosition = 'before';\n } else if (isValidDropTarget({...target, dropPosition: 'after'})) {\n target.dropPosition = 'after';\n }\n } else if (y <= rect.y + 10 && isValidDropTarget({...target, dropPosition: 'before'})) {\n target.dropPosition = 'before';\n } else if (y >= rect.maxY - 10 && isValidDropTarget({...target, dropPosition: 'after'})) {\n target.dropPosition = 'after';\n }\n\n return target;\n }\n}\n"],"names":[],"version":3,"file":"ListLayout.module.js.map"}
|
package/dist/types.d.ts
CHANGED
|
@@ -15,6 +15,7 @@ export type ListLayoutOptions<T> = {
|
|
|
15
15
|
loaderHeight?: number;
|
|
16
16
|
placeholderHeight?: number;
|
|
17
17
|
allowDisabledKeyFocus?: boolean;
|
|
18
|
+
forceSectionHeaders?: boolean;
|
|
18
19
|
};
|
|
19
20
|
export interface LayoutNode {
|
|
20
21
|
node?: Node<unknown>;
|
|
@@ -42,6 +43,7 @@ export class ListLayout<T> extends Layout<Node<T>, ListLayoutProps> implements K
|
|
|
42
43
|
protected estimatedRowHeight: number;
|
|
43
44
|
protected headingHeight: number;
|
|
44
45
|
protected estimatedHeadingHeight: number;
|
|
46
|
+
protected forceSectionHeaders: boolean;
|
|
45
47
|
protected padding: number;
|
|
46
48
|
protected indentationForItem?: (collection: Collection<Node<T>>, key: Key) => number;
|
|
47
49
|
protected layoutInfos: Map<Key, LayoutInfo>;
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;AAgBA,8BAA8B,CAAC,IAAI;IACjC,iCAAiC;IACjC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,sBAA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UAAU;IAiEhC,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,UAAU;IAgB9D,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,UAAU;IAsC7D,SAAS,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,GAAG,UAAU;IAe9D,qBAAqB,CAAC,IAAI,EAAE,IAAI;IA4BhC,qBAAqB,CAAC,GAAG,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI;IA4FrE,YAAY,CAAC,KAAK,EAAE,UAAU,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,GAAG,GAAG,GAAG;IAmB/D,qBAAqB;IAsDrB,sBAAsB,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,iBAAiB,EAAE,CAAC,MAAM,EAAE,UAAU,KAAK,OAAO,GAAG,UAAU;CAkD7G","sources":["packages/@react-stately/layout/src/packages/@react-stately/layout/src/ListLayout.ts","packages/@react-stately/layout/src/packages/@react-stately/layout/src/TableLayout.ts","packages/@react-stately/layout/src/packages/@react-stately/layout/src/index.ts","packages/@react-stately/layout/src/index.ts"],"sourcesContent":[null,null,null,"/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\nexport type {ListLayoutOptions, LayoutNode} from './ListLayout';\nexport {ListLayout} from './ListLayout';\nexport {TableLayout} from './TableLayout';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-stately/layout",
|
|
3
|
-
"version": "3.13.10-nightly.
|
|
3
|
+
"version": "3.13.10-nightly.4673+278e5167f",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -22,12 +22,12 @@
|
|
|
22
22
|
"url": "https://github.com/adobe/react-spectrum"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@react-stately/collections": "3.0.0-nightly.
|
|
26
|
-
"@react-stately/table": "3.11.9-nightly.
|
|
27
|
-
"@react-stately/virtualizer": "3.7.2-nightly.
|
|
28
|
-
"@react-types/grid": "3.2.7-nightly.
|
|
29
|
-
"@react-types/shared": "3.0.0-nightly.
|
|
30
|
-
"@react-types/table": "3.9.6-nightly.
|
|
25
|
+
"@react-stately/collections": "3.0.0-nightly.2961+278e5167f",
|
|
26
|
+
"@react-stately/table": "3.11.9-nightly.4673+278e5167f",
|
|
27
|
+
"@react-stately/virtualizer": "3.7.2-nightly.4673+278e5167f",
|
|
28
|
+
"@react-types/grid": "3.2.7-nightly.4673+278e5167f",
|
|
29
|
+
"@react-types/shared": "3.0.0-nightly.2961+278e5167f",
|
|
30
|
+
"@react-types/table": "3.9.6-nightly.4673+278e5167f",
|
|
31
31
|
"@swc/helpers": "^0.5.0"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
@@ -36,5 +36,5 @@
|
|
|
36
36
|
"publishConfig": {
|
|
37
37
|
"access": "public"
|
|
38
38
|
},
|
|
39
|
-
"gitHead": "
|
|
39
|
+
"gitHead": "278e5167ffc85569c00ac32a17c595ba4c861c63"
|
|
40
40
|
}
|
package/src/ListLayout.ts
CHANGED
|
@@ -25,7 +25,8 @@ export type ListLayoutOptions<T> = {
|
|
|
25
25
|
collator?: Intl.Collator,
|
|
26
26
|
loaderHeight?: number,
|
|
27
27
|
placeholderHeight?: number,
|
|
28
|
-
allowDisabledKeyFocus?: boolean
|
|
28
|
+
allowDisabledKeyFocus?: boolean,
|
|
29
|
+
forceSectionHeaders?: boolean
|
|
29
30
|
};
|
|
30
31
|
|
|
31
32
|
// A wrapper around LayoutInfo that supports hierarchy
|
|
@@ -59,6 +60,7 @@ export class ListLayout<T> extends Layout<Node<T>, ListLayoutProps> implements K
|
|
|
59
60
|
protected estimatedRowHeight: number;
|
|
60
61
|
protected headingHeight: number;
|
|
61
62
|
protected estimatedHeadingHeight: number;
|
|
63
|
+
protected forceSectionHeaders: boolean;
|
|
62
64
|
protected padding: number;
|
|
63
65
|
protected indentationForItem?: (collection: Collection<Node<T>>, key: Key) => number;
|
|
64
66
|
protected layoutInfos: Map<Key, LayoutInfo>;
|
|
@@ -88,6 +90,7 @@ export class ListLayout<T> extends Layout<Node<T>, ListLayoutProps> implements K
|
|
|
88
90
|
this.estimatedRowHeight = options.estimatedRowHeight;
|
|
89
91
|
this.headingHeight = options.headingHeight;
|
|
90
92
|
this.estimatedHeadingHeight = options.estimatedHeadingHeight;
|
|
93
|
+
this.forceSectionHeaders = options.forceSectionHeaders;
|
|
91
94
|
this.padding = options.padding || 0;
|
|
92
95
|
this.indentationForItem = options.indentationForItem;
|
|
93
96
|
this.collator = options.collator;
|
|
@@ -310,7 +313,7 @@ export class ListLayout<T> extends Layout<Node<T>, ListLayoutProps> implements K
|
|
|
310
313
|
buildSection(node: Node<T>, x: number, y: number): LayoutNode {
|
|
311
314
|
let width = this.virtualizer.visibleRect.width;
|
|
312
315
|
let header = null;
|
|
313
|
-
if (node.rendered) {
|
|
316
|
+
if (node.rendered || this.forceSectionHeaders) {
|
|
314
317
|
let headerNode = this.buildHeader(node, x, y);
|
|
315
318
|
header = headerNode.layoutInfo;
|
|
316
319
|
header.key += ':header';
|