@react-spectrum/card 3.0.0-nightly.4695 → 3.0.0-nightly.4700

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,7 +20,7 @@ $parcel$export(module.exports, "BaseLayout", () => $5ee605f09afaa4de$export$6494
20
20
  */
21
21
 
22
22
  class $5ee605f09afaa4de$export$64943d2e59d72a29 extends (0, $kQhHy$reactstatelyvirtualizer.Layout) {
23
- validate(invalidationContext) {
23
+ update(invalidationContext) {
24
24
  var _invalidationContext_layoutOptions, _invalidationContext_layoutOptions1;
25
25
  this.collection = this.virtualizer.collection;
26
26
  this.isLoading = ((_invalidationContext_layoutOptions = invalidationContext.layoutOptions) === null || _invalidationContext_layoutOptions === void 0 ? void 0 : _invalidationContext_layoutOptions.isLoading) || false;
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAwBM,MAAM,kDAAsB,CAAA,GAAA,qCAAK;IAqBtC,SAAS,mBAA+D,EAAE;YAEvD,oCACA;QAFjB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC,UAAU;QAC7C,IAAI,CAAC,SAAS,GAAG,EAAA,qCAAA,oBAAoB,aAAa,cAAjC,yDAAA,mCAAmC,SAAS,KAAI;QACjE,IAAI,CAAC,SAAS,GAAG,EAAA,sCAAA,oBAAoB,aAAa,cAAjC,0DAAA,oCAAmC,SAAS,KAAI;QACjE,IAAI,CAAC,eAAe,CAAC;QAErB,0DAA0D;QAC1D,IAAI,IAAI,CAAC,cAAc,EAAE;YACvB,KAAK,IAAI,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,GACzC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,MAC3B,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;YAI5B,IAAI,CAAC,IAAI,CAAC,SAAS,EACjB,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;YAG1B,IAAI,IAA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AI,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAW,YAAY,GAC/C,QAAO,gBAAA,CAAA,GAAA,2CAAW,EAAE,CAAA,GAAA,4CAAY,EAAE,MAAM,IAAI,CAAC,UAAU,gBAAhD,oCAAA,cAAoD,GAAG;YAElE;YAEA,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC;QACpC;QAEA,OAAO;IACT;IAjPA,YAAY,UAA6B,CAAC,CAAC,CAAE;QAC3C,KAAK;aANP,eAAyB,IAAI;QAO3B,IAAI,CAAC,WAAW,GAAG,IAAI;QACvB,IAAI,CAAC,QAAQ,GAAG,QAAQ,QAAQ;QAChC,IAAI,CAAC,cAAc,GAAG;QACtB,IAAI,CAAC,KAAK,GAAG,QAAQ,KAAK,IAAI;QAC9B,IAAI,CAAC,MAAM,GAAG,QAAQ,MAAM,IAAI;IAClC;AA2OF","sources":["packages/@react-spectrum/card/src/BaseLayout.tsx"],"sourcesContent":["/*\n * Copyright 2021 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 {Direction, Key, KeyboardDelegate, Node} from '@react-types/shared';\nimport {getChildNodes, getFirstItem} from '@react-stately/collections';\nimport {GridCollection} from '@react-stately/grid';\nimport {InvalidationContext, Layout, LayoutInfo, Rect, Size} from '@react-stately/virtualizer';\nimport {Scale} from '@react-types/provider';\n\nexport interface BaseLayoutOptions {\n collator?: Intl.Collator,\n // TODO: is this valid or is scale a spectrum specific thing that should be left out of the layouts?\n scale?: Scale,\n /**\n * The margin around the grid view between the edges and the items.\n * @default 24\n */\n margin?: number\n}\n\ninterface CardViewLayoutOptions {\n isLoading: boolean,\n direction: Direction\n}\n\nexport class BaseLayout<T> extends Layout<Node<T>, CardViewLayoutOptions> implements KeyboardDelegate {\n protected contentSize: Size;\n protected layoutInfos: Map<Key, LayoutInfo>;\n protected collator: Intl.Collator;\n protected lastCollection: GridCollection<T>;\n collection: GridCollection<T>;\n isLoading: boolean;\n disabledKeys: Set<Key> = new Set();\n direction: Direction;\n scale: Scale;\n margin: number;\n\n constructor(options: BaseLayoutOptions = {}) {\n super();\n this.layoutInfos = new Map();\n this.collator = options.collator;\n this.lastCollection = null;\n this.scale = options.scale || 'medium';\n this.margin = options.margin || 24;\n }\n\n validate(invalidationContext: InvalidationContext<CardViewLayoutOptions>) {\n this.collection = this.virtualizer.collection as GridCollection<T>;\n this.isLoading = invalidationContext.layoutOptions?.isLoading || false;\n this.direction = invalidationContext.layoutOptions?.direction || 'ltr';\n this.buildCollection(invalidationContext);\n\n // Remove layout info that doesn't exist in new collection\n if (this.lastCollection) {\n for (let key of this.lastCollection.getKeys()) {\n if (!this.collection.getItem(key)) {\n this.layoutInfos.delete(key);\n }\n }\n\n if (!this.isLoading) {\n this.layoutInfos.delete('loader');\n }\n\n if (this.collection.size > 0) {\n this.layoutInfos.delete('placeholder');\n }\n }\n\n this.lastCollection = this.collection;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n buildCollection(invalidationContext?: InvalidationContext) {}\n\n getContentSize() {\n return this.contentSize;\n }\n\n getLayoutInfo(key: Key) {\n return this.layoutInfos.get(key)!;\n }\n\n getVisibleLayoutInfos(rect: Rect, excludePersistedKeys = false) {\n let res: LayoutInfo[] = [];\n\n for (let layoutInfo of this.layoutInfos.values()) {\n if (this.isVisible(layoutInfo, rect, excludePersistedKeys)) {\n res.push(layoutInfo);\n }\n }\n\n return res;\n }\n\n isVisible(layoutInfo: LayoutInfo, rect: Rect, excludePersistedKeys: boolean) {\n if (layoutInfo.rect.intersects(rect)) {\n return true;\n }\n\n if (!excludePersistedKeys) {\n return this.virtualizer.isPersistedKey(layoutInfo.key);\n }\n\n return false;\n }\n\n _findClosestLayoutInfo(target: Rect, rect: Rect) {\n let layoutInfos = this.getVisibleLayoutInfos(rect, true);\n let best = null;\n let bestDistance = Infinity;\n\n // Calculates distance as the distance between the center of 2 rects.\n for (let cur of layoutInfos) {\n if (cur.type === 'item') {\n let curRect = cur.rect;\n let targetMidX = (target.x + target.maxX) / 2;\n let targetMidY = (target.y + target.maxY) / 2;\n let curMidX = (curRect.x + curRect.maxX) / 2;\n let curMidY = (curRect.y + curRect.maxY) / 2;\n let dist = Math.pow(targetMidX - curMidX, 2) + Math.pow(targetMidY - curMidY, 2);\n if (dist < bestDistance) {\n best = cur;\n bestDistance = dist;\n }\n }\n }\n\n return best;\n }\n\n _findClosest(target: Rect, rect: Rect) {\n let best = this._findClosestLayoutInfo(target, rect);\n return best || null;\n }\n\n getKeyBelow(key: Key) {\n // Expected key is the currently focused cell so we need the parent row key\n let parentRowKey = this.collection.getItem(key).parentKey;\n let layoutInfo = this.getLayoutInfo(parentRowKey);\n let rect = new Rect(layoutInfo.rect.x, layoutInfo.rect.maxY + 1, layoutInfo.rect.width, this.virtualizer.visibleRect.height);\n let closestRow = this.collection.getItem(this._findClosest(layoutInfo.rect, rect)?.key);\n return getFirstItem(getChildNodes(closestRow, this.collection))?.key;\n }\n\n getKeyAbove(key: Key) {\n // Expected key is the currently focused cell so we need the parent row key\n let parentRowKey = this.collection.getItem(key).parentKey;\n let layoutInfo = this.getLayoutInfo(parentRowKey);\n let rect = new Rect(layoutInfo.rect.x, 0, layoutInfo.rect.width, layoutInfo.rect.y - 1);\n let closestRow = this.collection.getItem(this._findClosest(layoutInfo.rect, rect)?.key);\n return getFirstItem(getChildNodes(closestRow, this.collection))?.key;\n }\n\n getKeyRightOf(key: Key) {\n // Expected key is the currently focused cell so we need the parent row key\n let parentRowKey = this.collection.getItem(key).parentKey;\n key = this.direction === 'rtl' ? this.collection.getKeyBefore(parentRowKey) : this.collection.getKeyAfter(parentRowKey);\n\n while (key != null) {\n let item = this.collection.getItem(key);\n // Don't check if item is disabled because we want to be able to focus disabled items in a grid (double check this)\n if (item.type === 'item') {\n return getFirstItem(getChildNodes(item, this.collection))?.key;\n }\n key = this.direction === 'rtl' ? this.collection.getKeyBefore(key) : this.collection.getKeyAfter(key);\n }\n }\n\n getKeyLeftOf(key: Key) {\n // Expected key is the currently focused cell so we need the parent row key\n let parentRowKey = this.collection.getItem(key).parentKey;\n key = this.direction === 'rtl' ? this.collection.getKeyAfter(parentRowKey) : this.collection.getKeyBefore(parentRowKey);\n while (key != null) {\n let item = this.collection.getItem(key);\n // Don't check if item is disabled because we want to be able to focus disabled items in a grid (double check this)\n if (item.type === 'item') {\n return getFirstItem(getChildNodes(item, this.collection))?.key;\n }\n\n key = this.direction === 'rtl' ? this.collection.getKeyAfter(key) : this.collection.getKeyBefore(key);\n }\n }\n\n getFirstKey() {\n let firstRow = this.collection.getItem(this.collection.getFirstKey());\n return getFirstItem(getChildNodes(firstRow, this.collection))?.key;\n }\n\n getLastKey() {\n let lastRow = this.collection.getItem(this.collection.getLastKey());\n return getFirstItem(getChildNodes(lastRow, this.collection))?.key;\n }\n\n // TODO: pretty unwieldy because it needs to bounce back and forth between the parent key and the child key\n // Perhaps have layoutInfo store childKey as well so we don't need to do this? Or maybe make the layoutInfos be the cells instead of the rows?\n getKeyPageAbove(key: Key) {\n // Expected key is the currently focused cell so we need the parent row key\n let parentRowKey = this.collection.getItem(key).parentKey;\n let layoutInfo = this.getLayoutInfo(parentRowKey);\n\n if (layoutInfo) {\n let pageY = Math.max(0, layoutInfo.rect.y + layoutInfo.rect.height - this.virtualizer.visibleRect.height);\n // If the node is so large that it spans multiple page heights, return the key of the item immediately above\n // Otherwise keep going up until we exceed a single page height worth of nodes\n let keyAbove = this.collection.getItem(this.getKeyAbove(key))?.parentKey;\n layoutInfo = this.getLayoutInfo(keyAbove);\n\n if (layoutInfo && layoutInfo.rect.y > pageY) {\n while (layoutInfo && layoutInfo.rect.y > pageY) {\n let childKey = getFirstItem(getChildNodes(this.collection.getItem(layoutInfo.key), this.collection))?.key;\n let keyAbove = this.collection.getItem(this.getKeyAbove(childKey))?.parentKey;\n layoutInfo = this.getLayoutInfo(keyAbove);\n }\n }\n\n if (layoutInfo) {\n let childKey = getFirstItem(getChildNodes(this.collection.getItem(layoutInfo.key), this.collection))?.key;\n return childKey;\n }\n }\n\n return this.getFirstKey();\n }\n\n // TODO: pretty unwieldy because it needs to bounce back and forth between the parent key and the child key\n // Perhaps have layoutInfo store childKey as well so we don't need to do this?\n getKeyPageBelow(key: Key) {\n // Expected key is the currently focused cell so we need the parent row key\n let parentRowKey = this.collection.getItem(key).parentKey;\n let layoutInfo = this.getLayoutInfo(parentRowKey);\n if (layoutInfo) {\n let pageY = Math.min(this.virtualizer.contentSize.height, layoutInfo.rect.y - layoutInfo.rect.height + this.virtualizer.visibleRect.height);\n // If the node is so large that it spans multiple page heights, return the key of the item immediately below\n // Otherwise keep going up until we exceed a single page height worth of nodes\n let keyBelow = this.collection.getItem(this.getKeyBelow(key))?.parentKey;\n layoutInfo = this.getLayoutInfo(keyBelow);\n if (layoutInfo && layoutInfo.rect.y < pageY) {\n while (layoutInfo && layoutInfo.rect.y < pageY) {\n let childKey = getFirstItem(getChildNodes(this.collection.getItem(layoutInfo.key), this.collection))?.key;\n let keyBelow = this.collection.getItem(this.getKeyBelow(childKey))?.parentKey;\n layoutInfo = this.getLayoutInfo(keyBelow);\n }\n }\n\n if (layoutInfo) {\n let childKey = getFirstItem(getChildNodes(this.collection.getItem(layoutInfo.key), this.collection))?.key;\n return childKey;\n }\n }\n\n return this.getLastKey();\n }\n\n getKeyForSearch(search: string, fromKey?: Key) {\n if (!this.collator) {\n return null;\n }\n\n let collection = this.collection;\n let key = fromKey ?? this.getFirstKey();\n\n let startItem = collection.getItem(key);\n key = startItem.parentKey;\n\n while (key != null) {\n let item = collection.getItem(key);\n if (item.textValue) {\n let substring = item.textValue.slice(0, search.length);\n if (this.collator.compare(substring, search) === 0) {\n return getFirstItem(getChildNodes(item, this.collection))?.key;\n }\n }\n\n key = this.collection.getKeyAfter(key);\n }\n\n return null;\n }\n}\n"],"names":[],"version":3,"file":"BaseLayout.main.js.map"}
1
+ {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAwBM,MAAM,kDAAsB,CAAA,GAAA,qCAAK;IAqBtC,OAAO,mBAA+D,EAAE;YAErD,oCACA;QAFjB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC,UAAU;QAC7C,IAAI,CAAC,SAAS,GAAG,EAAA,qCAAA,oBAAoB,aAAa,cAAjC,yDAAA,mCAAmC,SAAS,KAAI;QACjE,IAAI,CAAC,SAAS,GAAG,EAAA,sCAAA,oBAAoB,aAAa,cAAjC,0DAAA,oCAAmC,SAAS,KAAI;QACjE,IAAI,CAAC,eAAe,CAAC;QAErB,0DAA0D;QAC1D,IAAI,IAAI,CAAC,cAAc,EAAE;YACvB,KAAK,IAAI,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,GACzC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,MAC3B,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;YAI5B,IAAI,CAAC,IAAI,CAAC,SAAS,EACjB,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;YAG1B,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,GAAG,GACzB,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;QAE5B;QAEA,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,UAAU;IACvC;IAEA,6DAA6D;IAC7D,gBAAgB,mBAAyC,EAAE,CAAC;IAE5D,iBAAiB;QACf,OAAO,IAAI,CAAC,WAAW;IACzB;IAEA,cAAc,GAAQ,EAAE;QACtB,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC;IAC9B;IAEA,sBAAsB,IAAU,EAAE,uBAAuB,KAAK,EAAE;QAC9D,IAAI,MAAoB,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,GAAG,QAAQ,QAAQ;QAChC,IAAI,CAAC,cAAc,GAAG;QACtB,IAAI,CAAC,KAAK,GAAG,QAAQ,KAAK,IAAI;QAC9B,IAAI,CAAC,MAAM,GAAG,QAAQ,MAAM,IAAI;IAClC;AA2OF","sources":["packages/@react-spectrum/card/src/BaseLayout.tsx"],"sourcesContent":["/*\n * Copyright 2021 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 {Direction, Key, KeyboardDelegate, Node} from '@react-types/shared';\nimport {getChildNodes, getFirstItem} from '@react-stately/collections';\nimport {GridCollection} from '@react-stately/grid';\nimport {InvalidationContext, Layout, LayoutInfo, Rect, Size} from '@react-stately/virtualizer';\nimport {Scale} from '@react-types/provider';\n\nexport interface BaseLayoutOptions {\n collator?: Intl.Collator,\n // TODO: is this valid or is scale a spectrum specific thing that should be left out of the layouts?\n scale?: Scale,\n /**\n * The margin around the grid view between the edges and the items.\n * @default 24\n */\n margin?: number\n}\n\ninterface CardViewLayoutOptions {\n isLoading: boolean,\n direction: Direction\n}\n\nexport class BaseLayout<T> extends Layout<Node<T>, CardViewLayoutOptions> implements KeyboardDelegate {\n protected contentSize: Size;\n protected layoutInfos: Map<Key, LayoutInfo>;\n protected collator: Intl.Collator;\n protected lastCollection: GridCollection<T>;\n collection: GridCollection<T>;\n isLoading: boolean;\n disabledKeys: Set<Key> = new Set();\n direction: Direction;\n scale: Scale;\n margin: number;\n\n constructor(options: BaseLayoutOptions = {}) {\n super();\n this.layoutInfos = new Map();\n this.collator = options.collator;\n this.lastCollection = null;\n this.scale = options.scale || 'medium';\n this.margin = options.margin || 24;\n }\n\n update(invalidationContext: InvalidationContext<CardViewLayoutOptions>) {\n this.collection = this.virtualizer.collection as GridCollection<T>;\n this.isLoading = invalidationContext.layoutOptions?.isLoading || false;\n this.direction = invalidationContext.layoutOptions?.direction || 'ltr';\n this.buildCollection(invalidationContext);\n\n // Remove layout info that doesn't exist in new collection\n if (this.lastCollection) {\n for (let key of this.lastCollection.getKeys()) {\n if (!this.collection.getItem(key)) {\n this.layoutInfos.delete(key);\n }\n }\n\n if (!this.isLoading) {\n this.layoutInfos.delete('loader');\n }\n\n if (this.collection.size > 0) {\n this.layoutInfos.delete('placeholder');\n }\n }\n\n this.lastCollection = this.collection;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n buildCollection(invalidationContext?: InvalidationContext) {}\n\n getContentSize() {\n return this.contentSize;\n }\n\n getLayoutInfo(key: Key) {\n return this.layoutInfos.get(key)!;\n }\n\n getVisibleLayoutInfos(rect: Rect, excludePersistedKeys = false) {\n let res: LayoutInfo[] = [];\n\n for (let layoutInfo of this.layoutInfos.values()) {\n if (this.isVisible(layoutInfo, rect, excludePersistedKeys)) {\n res.push(layoutInfo);\n }\n }\n\n return res;\n }\n\n isVisible(layoutInfo: LayoutInfo, rect: Rect, excludePersistedKeys: boolean) {\n if (layoutInfo.rect.intersects(rect)) {\n return true;\n }\n\n if (!excludePersistedKeys) {\n return this.virtualizer.isPersistedKey(layoutInfo.key);\n }\n\n return false;\n }\n\n _findClosestLayoutInfo(target: Rect, rect: Rect) {\n let layoutInfos = this.getVisibleLayoutInfos(rect, true);\n let best = null;\n let bestDistance = Infinity;\n\n // Calculates distance as the distance between the center of 2 rects.\n for (let cur of layoutInfos) {\n if (cur.type === 'item') {\n let curRect = cur.rect;\n let targetMidX = (target.x + target.maxX) / 2;\n let targetMidY = (target.y + target.maxY) / 2;\n let curMidX = (curRect.x + curRect.maxX) / 2;\n let curMidY = (curRect.y + curRect.maxY) / 2;\n let dist = Math.pow(targetMidX - curMidX, 2) + Math.pow(targetMidY - curMidY, 2);\n if (dist < bestDistance) {\n best = cur;\n bestDistance = dist;\n }\n }\n }\n\n return best;\n }\n\n _findClosest(target: Rect, rect: Rect) {\n let best = this._findClosestLayoutInfo(target, rect);\n return best || null;\n }\n\n getKeyBelow(key: Key) {\n // Expected key is the currently focused cell so we need the parent row key\n let parentRowKey = this.collection.getItem(key).parentKey;\n let layoutInfo = this.getLayoutInfo(parentRowKey);\n let rect = new Rect(layoutInfo.rect.x, layoutInfo.rect.maxY + 1, layoutInfo.rect.width, this.virtualizer.visibleRect.height);\n let closestRow = this.collection.getItem(this._findClosest(layoutInfo.rect, rect)?.key);\n return getFirstItem(getChildNodes(closestRow, this.collection))?.key;\n }\n\n getKeyAbove(key: Key) {\n // Expected key is the currently focused cell so we need the parent row key\n let parentRowKey = this.collection.getItem(key).parentKey;\n let layoutInfo = this.getLayoutInfo(parentRowKey);\n let rect = new Rect(layoutInfo.rect.x, 0, layoutInfo.rect.width, layoutInfo.rect.y - 1);\n let closestRow = this.collection.getItem(this._findClosest(layoutInfo.rect, rect)?.key);\n return getFirstItem(getChildNodes(closestRow, this.collection))?.key;\n }\n\n getKeyRightOf(key: Key) {\n // Expected key is the currently focused cell so we need the parent row key\n let parentRowKey = this.collection.getItem(key).parentKey;\n key = this.direction === 'rtl' ? this.collection.getKeyBefore(parentRowKey) : this.collection.getKeyAfter(parentRowKey);\n\n while (key != null) {\n let item = this.collection.getItem(key);\n // Don't check if item is disabled because we want to be able to focus disabled items in a grid (double check this)\n if (item.type === 'item') {\n return getFirstItem(getChildNodes(item, this.collection))?.key;\n }\n key = this.direction === 'rtl' ? this.collection.getKeyBefore(key) : this.collection.getKeyAfter(key);\n }\n }\n\n getKeyLeftOf(key: Key) {\n // Expected key is the currently focused cell so we need the parent row key\n let parentRowKey = this.collection.getItem(key).parentKey;\n key = this.direction === 'rtl' ? this.collection.getKeyAfter(parentRowKey) : this.collection.getKeyBefore(parentRowKey);\n while (key != null) {\n let item = this.collection.getItem(key);\n // Don't check if item is disabled because we want to be able to focus disabled items in a grid (double check this)\n if (item.type === 'item') {\n return getFirstItem(getChildNodes(item, this.collection))?.key;\n }\n\n key = this.direction === 'rtl' ? this.collection.getKeyAfter(key) : this.collection.getKeyBefore(key);\n }\n }\n\n getFirstKey() {\n let firstRow = this.collection.getItem(this.collection.getFirstKey());\n return getFirstItem(getChildNodes(firstRow, this.collection))?.key;\n }\n\n getLastKey() {\n let lastRow = this.collection.getItem(this.collection.getLastKey());\n return getFirstItem(getChildNodes(lastRow, this.collection))?.key;\n }\n\n // TODO: pretty unwieldy because it needs to bounce back and forth between the parent key and the child key\n // Perhaps have layoutInfo store childKey as well so we don't need to do this? Or maybe make the layoutInfos be the cells instead of the rows?\n getKeyPageAbove(key: Key) {\n // Expected key is the currently focused cell so we need the parent row key\n let parentRowKey = this.collection.getItem(key).parentKey;\n let layoutInfo = this.getLayoutInfo(parentRowKey);\n\n if (layoutInfo) {\n let pageY = Math.max(0, layoutInfo.rect.y + layoutInfo.rect.height - this.virtualizer.visibleRect.height);\n // If the node is so large that it spans multiple page heights, return the key of the item immediately above\n // Otherwise keep going up until we exceed a single page height worth of nodes\n let keyAbove = this.collection.getItem(this.getKeyAbove(key))?.parentKey;\n layoutInfo = this.getLayoutInfo(keyAbove);\n\n if (layoutInfo && layoutInfo.rect.y > pageY) {\n while (layoutInfo && layoutInfo.rect.y > pageY) {\n let childKey = getFirstItem(getChildNodes(this.collection.getItem(layoutInfo.key), this.collection))?.key;\n let keyAbove = this.collection.getItem(this.getKeyAbove(childKey))?.parentKey;\n layoutInfo = this.getLayoutInfo(keyAbove);\n }\n }\n\n if (layoutInfo) {\n let childKey = getFirstItem(getChildNodes(this.collection.getItem(layoutInfo.key), this.collection))?.key;\n return childKey;\n }\n }\n\n return this.getFirstKey();\n }\n\n // TODO: pretty unwieldy because it needs to bounce back and forth between the parent key and the child key\n // Perhaps have layoutInfo store childKey as well so we don't need to do this?\n getKeyPageBelow(key: Key) {\n // Expected key is the currently focused cell so we need the parent row key\n let parentRowKey = this.collection.getItem(key).parentKey;\n let layoutInfo = this.getLayoutInfo(parentRowKey);\n if (layoutInfo) {\n let pageY = Math.min(this.virtualizer.contentSize.height, layoutInfo.rect.y - layoutInfo.rect.height + this.virtualizer.visibleRect.height);\n // If the node is so large that it spans multiple page heights, return the key of the item immediately below\n // Otherwise keep going up until we exceed a single page height worth of nodes\n let keyBelow = this.collection.getItem(this.getKeyBelow(key))?.parentKey;\n layoutInfo = this.getLayoutInfo(keyBelow);\n if (layoutInfo && layoutInfo.rect.y < pageY) {\n while (layoutInfo && layoutInfo.rect.y < pageY) {\n let childKey = getFirstItem(getChildNodes(this.collection.getItem(layoutInfo.key), this.collection))?.key;\n let keyBelow = this.collection.getItem(this.getKeyBelow(childKey))?.parentKey;\n layoutInfo = this.getLayoutInfo(keyBelow);\n }\n }\n\n if (layoutInfo) {\n let childKey = getFirstItem(getChildNodes(this.collection.getItem(layoutInfo.key), this.collection))?.key;\n return childKey;\n }\n }\n\n return this.getLastKey();\n }\n\n getKeyForSearch(search: string, fromKey?: Key) {\n if (!this.collator) {\n return null;\n }\n\n let collection = this.collection;\n let key = fromKey ?? this.getFirstKey();\n\n let startItem = collection.getItem(key);\n key = startItem.parentKey;\n\n while (key != null) {\n let item = collection.getItem(key);\n if (item.textValue) {\n let substring = item.textValue.slice(0, search.length);\n if (this.collator.compare(substring, search) === 0) {\n return getFirstItem(getChildNodes(item, this.collection))?.key;\n }\n }\n\n key = this.collection.getKeyAfter(key);\n }\n\n return null;\n }\n}\n"],"names":[],"version":3,"file":"BaseLayout.main.js.map"}
@@ -14,7 +14,7 @@ import {Rect as $1JdnP$Rect, Layout as $1JdnP$Layout} from "@react-stately/virtu
14
14
  */
15
15
 
16
16
  class $3d424c147206bac9$export$64943d2e59d72a29 extends (0, $1JdnP$Layout) {
17
- validate(invalidationContext) {
17
+ update(invalidationContext) {
18
18
  var _invalidationContext_layoutOptions, _invalidationContext_layoutOptions1;
19
19
  this.collection = this.virtualizer.collection;
20
20
  this.isLoading = ((_invalidationContext_layoutOptions = invalidationContext.layoutOptions) === null || _invalidationContext_layoutOptions === void 0 ? void 0 : _invalidationContext_layoutOptions.isLoading) || false;
@@ -14,7 +14,7 @@ import {Rect as $1JdnP$Rect, Layout as $1JdnP$Layout} from "@react-stately/virtu
14
14
  */
15
15
 
16
16
  class $3d424c147206bac9$export$64943d2e59d72a29 extends (0, $1JdnP$Layout) {
17
- validate(invalidationContext) {
17
+ update(invalidationContext) {
18
18
  var _invalidationContext_layoutOptions, _invalidationContext_layoutOptions1;
19
19
  this.collection = this.virtualizer.collection;
20
20
  this.isLoading = ((_invalidationContext_layoutOptions = invalidationContext.layoutOptions) === null || _invalidationContext_layoutOptions === void 0 ? void 0 : _invalidationContext_layoutOptions.isLoading) || false;
@@ -1 +1 @@
1
- {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAwBM,MAAM,kDAAsB,CAAA,GAAA,aAAK;IAqBtC,SAAS,mBAA+D,EAAE;YAEvD,oCACA;QAFjB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC,UAAU;QAC7C,IAAI,CAAC,SAAS,GAAG,EAAA,qCAAA,oBAAoB,aAAa,cAAjC,yDAAA,mCAAmC,SAAS,KAAI;QACjE,IAAI,CAAC,SAAS,GAAG,EAAA,sCAAA,oBAAoB,aAAa,cAAjC,0DAAA,oCAAmC,SAAS,KAAI;QACjE,IAAI,CAAC,eAAe,CAAC;QAErB,0DAA0D;QAC1D,IAAI,IAAI,CAAC,cAAc,EAAE;YACvB,KAAK,IAAI,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,GACzC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,MAC3B,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;YAI5B,IAAI,CAAC,IAAI,CAAC,SAAS,EACjB,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;YAG1B,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,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OAAO,CAAC,WAAW,YAAY,GAC/C,QAAO,gBAAA,CAAA,GAAA,mBAAW,EAAE,CAAA,GAAA,oBAAY,EAAE,MAAM,IAAI,CAAC,UAAU,gBAAhD,oCAAA,cAAoD,GAAG;YAElE;YAEA,MAAM,IAAI,CAAC,UAAU,CAAC,WAAW,CAAC;QACpC;QAEA,OAAO;IACT;IAjPA,YAAY,UAA6B,CAAC,CAAC,CAAE;QAC3C,KAAK;aANP,eAAyB,IAAI;QAO3B,IAAI,CAAC,WAAW,GAAG,IAAI;QACvB,IAAI,CAAC,QAAQ,GAAG,QAAQ,QAAQ;QAChC,IAAI,CAAC,cAAc,GAAG;QACtB,IAAI,CAAC,KAAK,GAAG,QAAQ,KAAK,IAAI;QAC9B,IAAI,CAAC,MAAM,GAAG,QAAQ,MAAM,IAAI;IAClC;AA2OF","sources":["packages/@react-spectrum/card/src/BaseLayout.tsx"],"sourcesContent":["/*\n * Copyright 2021 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 {Direction, Key, KeyboardDelegate, Node} from '@react-types/shared';\nimport {getChildNodes, getFirstItem} from '@react-stately/collections';\nimport {GridCollection} from '@react-stately/grid';\nimport {InvalidationContext, Layout, LayoutInfo, Rect, Size} from '@react-stately/virtualizer';\nimport {Scale} from '@react-types/provider';\n\nexport interface BaseLayoutOptions {\n collator?: Intl.Collator,\n // TODO: is this valid or is scale a spectrum specific thing that should be left out of the layouts?\n scale?: Scale,\n /**\n * The margin around the grid view between the edges and the items.\n * @default 24\n */\n margin?: number\n}\n\ninterface CardViewLayoutOptions {\n isLoading: boolean,\n direction: Direction\n}\n\nexport class BaseLayout<T> extends Layout<Node<T>, CardViewLayoutOptions> implements KeyboardDelegate {\n protected contentSize: Size;\n protected layoutInfos: Map<Key, LayoutInfo>;\n protected collator: Intl.Collator;\n protected lastCollection: GridCollection<T>;\n collection: GridCollection<T>;\n isLoading: boolean;\n disabledKeys: Set<Key> = new Set();\n direction: Direction;\n scale: Scale;\n margin: number;\n\n constructor(options: BaseLayoutOptions = {}) {\n super();\n this.layoutInfos = new Map();\n this.collator = options.collator;\n this.lastCollection = null;\n this.scale = options.scale || 'medium';\n this.margin = options.margin || 24;\n }\n\n validate(invalidationContext: InvalidationContext<CardViewLayoutOptions>) {\n this.collection = this.virtualizer.collection as GridCollection<T>;\n this.isLoading = invalidationContext.layoutOptions?.isLoading || false;\n this.direction = invalidationContext.layoutOptions?.direction || 'ltr';\n this.buildCollection(invalidationContext);\n\n // Remove layout info that doesn't exist in new collection\n if (this.lastCollection) {\n for (let key of this.lastCollection.getKeys()) {\n if (!this.collection.getItem(key)) {\n this.layoutInfos.delete(key);\n }\n }\n\n if (!this.isLoading) {\n this.layoutInfos.delete('loader');\n }\n\n if (this.collection.size > 0) {\n this.layoutInfos.delete('placeholder');\n }\n }\n\n this.lastCollection = this.collection;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n buildCollection(invalidationContext?: InvalidationContext) {}\n\n getContentSize() {\n return this.contentSize;\n }\n\n getLayoutInfo(key: Key) {\n return this.layoutInfos.get(key)!;\n }\n\n getVisibleLayoutInfos(rect: Rect, excludePersistedKeys = false) {\n let res: LayoutInfo[] = [];\n\n for (let layoutInfo of this.layoutInfos.values()) {\n if (this.isVisible(layoutInfo, rect, excludePersistedKeys)) {\n res.push(layoutInfo);\n }\n }\n\n return res;\n }\n\n isVisible(layoutInfo: LayoutInfo, rect: Rect, excludePersistedKeys: boolean) {\n if (layoutInfo.rect.intersects(rect)) {\n return true;\n }\n\n if (!excludePersistedKeys) {\n return this.virtualizer.isPersistedKey(layoutInfo.key);\n }\n\n return false;\n }\n\n _findClosestLayoutInfo(target: Rect, rect: Rect) {\n let layoutInfos = this.getVisibleLayoutInfos(rect, true);\n let best = null;\n let bestDistance = Infinity;\n\n // Calculates distance as the distance between the center of 2 rects.\n for (let cur of layoutInfos) {\n if (cur.type === 'item') {\n let curRect = cur.rect;\n let targetMidX = (target.x + target.maxX) / 2;\n let targetMidY = (target.y + target.maxY) / 2;\n let curMidX = (curRect.x + curRect.maxX) / 2;\n let curMidY = (curRect.y + curRect.maxY) / 2;\n let dist = Math.pow(targetMidX - curMidX, 2) + Math.pow(targetMidY - curMidY, 2);\n if (dist < bestDistance) {\n best = cur;\n bestDistance = dist;\n }\n }\n }\n\n return best;\n }\n\n _findClosest(target: Rect, rect: Rect) {\n let best = this._findClosestLayoutInfo(target, rect);\n return best || null;\n }\n\n getKeyBelow(key: Key) {\n // Expected key is the currently focused cell so we need the parent row key\n let parentRowKey = this.collection.getItem(key).parentKey;\n let layoutInfo = this.getLayoutInfo(parentRowKey);\n let rect = new Rect(layoutInfo.rect.x, layoutInfo.rect.maxY + 1, layoutInfo.rect.width, this.virtualizer.visibleRect.height);\n let closestRow = this.collection.getItem(this._findClosest(layoutInfo.rect, rect)?.key);\n return getFirstItem(getChildNodes(closestRow, this.collection))?.key;\n }\n\n getKeyAbove(key: Key) {\n // Expected key is the currently focused cell so we need the parent row key\n let parentRowKey = this.collection.getItem(key).parentKey;\n let layoutInfo = this.getLayoutInfo(parentRowKey);\n let rect = new Rect(layoutInfo.rect.x, 0, layoutInfo.rect.width, layoutInfo.rect.y - 1);\n let closestRow = this.collection.getItem(this._findClosest(layoutInfo.rect, rect)?.key);\n return getFirstItem(getChildNodes(closestRow, this.collection))?.key;\n }\n\n getKeyRightOf(key: Key) {\n // Expected key is the currently focused cell so we need the parent row key\n let parentRowKey = this.collection.getItem(key).parentKey;\n key = this.direction === 'rtl' ? this.collection.getKeyBefore(parentRowKey) : this.collection.getKeyAfter(parentRowKey);\n\n while (key != null) {\n let item = this.collection.getItem(key);\n // Don't check if item is disabled because we want to be able to focus disabled items in a grid (double check this)\n if (item.type === 'item') {\n return getFirstItem(getChildNodes(item, this.collection))?.key;\n }\n key = this.direction === 'rtl' ? this.collection.getKeyBefore(key) : this.collection.getKeyAfter(key);\n }\n }\n\n getKeyLeftOf(key: Key) {\n // Expected key is the currently focused cell so we need the parent row key\n let parentRowKey = this.collection.getItem(key).parentKey;\n key = this.direction === 'rtl' ? this.collection.getKeyAfter(parentRowKey) : this.collection.getKeyBefore(parentRowKey);\n while (key != null) {\n let item = this.collection.getItem(key);\n // Don't check if item is disabled because we want to be able to focus disabled items in a grid (double check this)\n if (item.type === 'item') {\n return getFirstItem(getChildNodes(item, this.collection))?.key;\n }\n\n key = this.direction === 'rtl' ? this.collection.getKeyAfter(key) : this.collection.getKeyBefore(key);\n }\n }\n\n getFirstKey() {\n let firstRow = this.collection.getItem(this.collection.getFirstKey());\n return getFirstItem(getChildNodes(firstRow, this.collection))?.key;\n }\n\n getLastKey() {\n let lastRow = this.collection.getItem(this.collection.getLastKey());\n return getFirstItem(getChildNodes(lastRow, this.collection))?.key;\n }\n\n // TODO: pretty unwieldy because it needs to bounce back and forth between the parent key and the child key\n // Perhaps have layoutInfo store childKey as well so we don't need to do this? Or maybe make the layoutInfos be the cells instead of the rows?\n getKeyPageAbove(key: Key) {\n // Expected key is the currently focused cell so we need the parent row key\n let parentRowKey = this.collection.getItem(key).parentKey;\n let layoutInfo = this.getLayoutInfo(parentRowKey);\n\n if (layoutInfo) {\n let pageY = Math.max(0, layoutInfo.rect.y + layoutInfo.rect.height - this.virtualizer.visibleRect.height);\n // If the node is so large that it spans multiple page heights, return the key of the item immediately above\n // Otherwise keep going up until we exceed a single page height worth of nodes\n let keyAbove = this.collection.getItem(this.getKeyAbove(key))?.parentKey;\n layoutInfo = this.getLayoutInfo(keyAbove);\n\n if (layoutInfo && layoutInfo.rect.y > pageY) {\n while (layoutInfo && layoutInfo.rect.y > pageY) {\n let childKey = getFirstItem(getChildNodes(this.collection.getItem(layoutInfo.key), this.collection))?.key;\n let keyAbove = this.collection.getItem(this.getKeyAbove(childKey))?.parentKey;\n layoutInfo = this.getLayoutInfo(keyAbove);\n }\n }\n\n if (layoutInfo) {\n let childKey = getFirstItem(getChildNodes(this.collection.getItem(layoutInfo.key), this.collection))?.key;\n return childKey;\n }\n }\n\n return this.getFirstKey();\n }\n\n // TODO: pretty unwieldy because it needs to bounce back and forth between the parent key and the child key\n // Perhaps have layoutInfo store childKey as well so we don't need to do this?\n getKeyPageBelow(key: Key) {\n // Expected key is the currently focused cell so we need the parent row key\n let parentRowKey = this.collection.getItem(key).parentKey;\n let layoutInfo = this.getLayoutInfo(parentRowKey);\n if (layoutInfo) {\n let pageY = Math.min(this.virtualizer.contentSize.height, layoutInfo.rect.y - layoutInfo.rect.height + this.virtualizer.visibleRect.height);\n // If the node is so large that it spans multiple page heights, return the key of the item immediately below\n // Otherwise keep going up until we exceed a single page height worth of nodes\n let keyBelow = this.collection.getItem(this.getKeyBelow(key))?.parentKey;\n layoutInfo = this.getLayoutInfo(keyBelow);\n if (layoutInfo && layoutInfo.rect.y < pageY) {\n while (layoutInfo && layoutInfo.rect.y < pageY) {\n let childKey = getFirstItem(getChildNodes(this.collection.getItem(layoutInfo.key), this.collection))?.key;\n let keyBelow = this.collection.getItem(this.getKeyBelow(childKey))?.parentKey;\n layoutInfo = this.getLayoutInfo(keyBelow);\n }\n }\n\n if (layoutInfo) {\n let childKey = getFirstItem(getChildNodes(this.collection.getItem(layoutInfo.key), this.collection))?.key;\n return childKey;\n }\n }\n\n return this.getLastKey();\n }\n\n getKeyForSearch(search: string, fromKey?: Key) {\n if (!this.collator) {\n return null;\n }\n\n let collection = this.collection;\n let key = fromKey ?? this.getFirstKey();\n\n let startItem = collection.getItem(key);\n key = startItem.parentKey;\n\n while (key != null) {\n let item = collection.getItem(key);\n if (item.textValue) {\n let substring = item.textValue.slice(0, search.length);\n if (this.collator.compare(substring, search) === 0) {\n return getFirstItem(getChildNodes(item, this.collection))?.key;\n }\n }\n\n key = this.collection.getKeyAfter(key);\n }\n\n return null;\n }\n}\n"],"names":[],"version":3,"file":"BaseLayout.module.js.map"}
1
+ {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAwBM,MAAM,kDAAsB,CAAA,GAAA,aAAK;IAqBtC,OAAO,mBAA+D,EAAE;YAErD,oCACA;QAFjB,IAAI,CAAC,UAAU,GAAG,IAAI,CAAC,WAAW,CAAC,UAAU;QAC7C,IAAI,CAAC,SAAS,GAAG,EAAA,qCAAA,oBAAoB,aAAa,cAAjC,yDAAA,mCAAmC,SAAS,KAAI;QACjE,IAAI,CAAC,SAAS,GAAG,EAAA,sCAAA,oBAAoB,aAAa,cAAjC,0DAAA,oCAAmC,SAAS,KAAI;QACjE,IAAI,CAAC,eAAe,CAAC;QAErB,0DAA0D;QAC1D,IAAI,IAAI,CAAC,cAAc,EAAE;YACvB,KAAK,IAAI,OAAO,IAAI,CAAC,cAAc,CAAC,OAAO,GACzC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,MAC3B,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;YAI5B,IAAI,CAAC,IAAI,CAAC,SAAS,EACjB,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;YAG1B,IAAI,IAAI,CAAC,UAAU,CAAC,IAAI,GAAG,GACzB,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;QAE5B;QAEA,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,UAAU;IACvC;IAEA,6DAA6D;IAC7D,gBAAgB,mBAAyC,EAAE,CAAC;IAE5D,iBAAiB;QACf,OAAO,IAAI,CAAC,WAAW;IACzB;IAEA,cAAc,GAAQ,EAAE;QACtB,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC;IAC9B;IAEA,sBAAsB,IAAU,EAAE,uBAAuB,KAAK,EAAE;QAC9D,IAAI,MAAoB,EAAE;QAE1B,KAAK,IAAI,cAAc,IAAI,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cAAc,GAAG;QACtB,IAAI,CAAC,KAAK,GAAG,QAAQ,KAAK,IAAI;QAC9B,IAAI,CAAC,MAAM,GAAG,QAAQ,MAAM,IAAI;IAClC;AA2OF","sources":["packages/@react-spectrum/card/src/BaseLayout.tsx"],"sourcesContent":["/*\n * Copyright 2021 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 {Direction, Key, KeyboardDelegate, Node} from '@react-types/shared';\nimport {getChildNodes, getFirstItem} from '@react-stately/collections';\nimport {GridCollection} from '@react-stately/grid';\nimport {InvalidationContext, Layout, LayoutInfo, Rect, Size} from '@react-stately/virtualizer';\nimport {Scale} from '@react-types/provider';\n\nexport interface BaseLayoutOptions {\n collator?: Intl.Collator,\n // TODO: is this valid or is scale a spectrum specific thing that should be left out of the layouts?\n scale?: Scale,\n /**\n * The margin around the grid view between the edges and the items.\n * @default 24\n */\n margin?: number\n}\n\ninterface CardViewLayoutOptions {\n isLoading: boolean,\n direction: Direction\n}\n\nexport class BaseLayout<T> extends Layout<Node<T>, CardViewLayoutOptions> implements KeyboardDelegate {\n protected contentSize: Size;\n protected layoutInfos: Map<Key, LayoutInfo>;\n protected collator: Intl.Collator;\n protected lastCollection: GridCollection<T>;\n collection: GridCollection<T>;\n isLoading: boolean;\n disabledKeys: Set<Key> = new Set();\n direction: Direction;\n scale: Scale;\n margin: number;\n\n constructor(options: BaseLayoutOptions = {}) {\n super();\n this.layoutInfos = new Map();\n this.collator = options.collator;\n this.lastCollection = null;\n this.scale = options.scale || 'medium';\n this.margin = options.margin || 24;\n }\n\n update(invalidationContext: InvalidationContext<CardViewLayoutOptions>) {\n this.collection = this.virtualizer.collection as GridCollection<T>;\n this.isLoading = invalidationContext.layoutOptions?.isLoading || false;\n this.direction = invalidationContext.layoutOptions?.direction || 'ltr';\n this.buildCollection(invalidationContext);\n\n // Remove layout info that doesn't exist in new collection\n if (this.lastCollection) {\n for (let key of this.lastCollection.getKeys()) {\n if (!this.collection.getItem(key)) {\n this.layoutInfos.delete(key);\n }\n }\n\n if (!this.isLoading) {\n this.layoutInfos.delete('loader');\n }\n\n if (this.collection.size > 0) {\n this.layoutInfos.delete('placeholder');\n }\n }\n\n this.lastCollection = this.collection;\n }\n\n // eslint-disable-next-line @typescript-eslint/no-unused-vars\n buildCollection(invalidationContext?: InvalidationContext) {}\n\n getContentSize() {\n return this.contentSize;\n }\n\n getLayoutInfo(key: Key) {\n return this.layoutInfos.get(key)!;\n }\n\n getVisibleLayoutInfos(rect: Rect, excludePersistedKeys = false) {\n let res: LayoutInfo[] = [];\n\n for (let layoutInfo of this.layoutInfos.values()) {\n if (this.isVisible(layoutInfo, rect, excludePersistedKeys)) {\n res.push(layoutInfo);\n }\n }\n\n return res;\n }\n\n isVisible(layoutInfo: LayoutInfo, rect: Rect, excludePersistedKeys: boolean) {\n if (layoutInfo.rect.intersects(rect)) {\n return true;\n }\n\n if (!excludePersistedKeys) {\n return this.virtualizer.isPersistedKey(layoutInfo.key);\n }\n\n return false;\n }\n\n _findClosestLayoutInfo(target: Rect, rect: Rect) {\n let layoutInfos = this.getVisibleLayoutInfos(rect, true);\n let best = null;\n let bestDistance = Infinity;\n\n // Calculates distance as the distance between the center of 2 rects.\n for (let cur of layoutInfos) {\n if (cur.type === 'item') {\n let curRect = cur.rect;\n let targetMidX = (target.x + target.maxX) / 2;\n let targetMidY = (target.y + target.maxY) / 2;\n let curMidX = (curRect.x + curRect.maxX) / 2;\n let curMidY = (curRect.y + curRect.maxY) / 2;\n let dist = Math.pow(targetMidX - curMidX, 2) + Math.pow(targetMidY - curMidY, 2);\n if (dist < bestDistance) {\n best = cur;\n bestDistance = dist;\n }\n }\n }\n\n return best;\n }\n\n _findClosest(target: Rect, rect: Rect) {\n let best = this._findClosestLayoutInfo(target, rect);\n return best || null;\n }\n\n getKeyBelow(key: Key) {\n // Expected key is the currently focused cell so we need the parent row key\n let parentRowKey = this.collection.getItem(key).parentKey;\n let layoutInfo = this.getLayoutInfo(parentRowKey);\n let rect = new Rect(layoutInfo.rect.x, layoutInfo.rect.maxY + 1, layoutInfo.rect.width, this.virtualizer.visibleRect.height);\n let closestRow = this.collection.getItem(this._findClosest(layoutInfo.rect, rect)?.key);\n return getFirstItem(getChildNodes(closestRow, this.collection))?.key;\n }\n\n getKeyAbove(key: Key) {\n // Expected key is the currently focused cell so we need the parent row key\n let parentRowKey = this.collection.getItem(key).parentKey;\n let layoutInfo = this.getLayoutInfo(parentRowKey);\n let rect = new Rect(layoutInfo.rect.x, 0, layoutInfo.rect.width, layoutInfo.rect.y - 1);\n let closestRow = this.collection.getItem(this._findClosest(layoutInfo.rect, rect)?.key);\n return getFirstItem(getChildNodes(closestRow, this.collection))?.key;\n }\n\n getKeyRightOf(key: Key) {\n // Expected key is the currently focused cell so we need the parent row key\n let parentRowKey = this.collection.getItem(key).parentKey;\n key = this.direction === 'rtl' ? this.collection.getKeyBefore(parentRowKey) : this.collection.getKeyAfter(parentRowKey);\n\n while (key != null) {\n let item = this.collection.getItem(key);\n // Don't check if item is disabled because we want to be able to focus disabled items in a grid (double check this)\n if (item.type === 'item') {\n return getFirstItem(getChildNodes(item, this.collection))?.key;\n }\n key = this.direction === 'rtl' ? this.collection.getKeyBefore(key) : this.collection.getKeyAfter(key);\n }\n }\n\n getKeyLeftOf(key: Key) {\n // Expected key is the currently focused cell so we need the parent row key\n let parentRowKey = this.collection.getItem(key).parentKey;\n key = this.direction === 'rtl' ? this.collection.getKeyAfter(parentRowKey) : this.collection.getKeyBefore(parentRowKey);\n while (key != null) {\n let item = this.collection.getItem(key);\n // Don't check if item is disabled because we want to be able to focus disabled items in a grid (double check this)\n if (item.type === 'item') {\n return getFirstItem(getChildNodes(item, this.collection))?.key;\n }\n\n key = this.direction === 'rtl' ? this.collection.getKeyAfter(key) : this.collection.getKeyBefore(key);\n }\n }\n\n getFirstKey() {\n let firstRow = this.collection.getItem(this.collection.getFirstKey());\n return getFirstItem(getChildNodes(firstRow, this.collection))?.key;\n }\n\n getLastKey() {\n let lastRow = this.collection.getItem(this.collection.getLastKey());\n return getFirstItem(getChildNodes(lastRow, this.collection))?.key;\n }\n\n // TODO: pretty unwieldy because it needs to bounce back and forth between the parent key and the child key\n // Perhaps have layoutInfo store childKey as well so we don't need to do this? Or maybe make the layoutInfos be the cells instead of the rows?\n getKeyPageAbove(key: Key) {\n // Expected key is the currently focused cell so we need the parent row key\n let parentRowKey = this.collection.getItem(key).parentKey;\n let layoutInfo = this.getLayoutInfo(parentRowKey);\n\n if (layoutInfo) {\n let pageY = Math.max(0, layoutInfo.rect.y + layoutInfo.rect.height - this.virtualizer.visibleRect.height);\n // If the node is so large that it spans multiple page heights, return the key of the item immediately above\n // Otherwise keep going up until we exceed a single page height worth of nodes\n let keyAbove = this.collection.getItem(this.getKeyAbove(key))?.parentKey;\n layoutInfo = this.getLayoutInfo(keyAbove);\n\n if (layoutInfo && layoutInfo.rect.y > pageY) {\n while (layoutInfo && layoutInfo.rect.y > pageY) {\n let childKey = getFirstItem(getChildNodes(this.collection.getItem(layoutInfo.key), this.collection))?.key;\n let keyAbove = this.collection.getItem(this.getKeyAbove(childKey))?.parentKey;\n layoutInfo = this.getLayoutInfo(keyAbove);\n }\n }\n\n if (layoutInfo) {\n let childKey = getFirstItem(getChildNodes(this.collection.getItem(layoutInfo.key), this.collection))?.key;\n return childKey;\n }\n }\n\n return this.getFirstKey();\n }\n\n // TODO: pretty unwieldy because it needs to bounce back and forth between the parent key and the child key\n // Perhaps have layoutInfo store childKey as well so we don't need to do this?\n getKeyPageBelow(key: Key) {\n // Expected key is the currently focused cell so we need the parent row key\n let parentRowKey = this.collection.getItem(key).parentKey;\n let layoutInfo = this.getLayoutInfo(parentRowKey);\n if (layoutInfo) {\n let pageY = Math.min(this.virtualizer.contentSize.height, layoutInfo.rect.y - layoutInfo.rect.height + this.virtualizer.visibleRect.height);\n // If the node is so large that it spans multiple page heights, return the key of the item immediately below\n // Otherwise keep going up until we exceed a single page height worth of nodes\n let keyBelow = this.collection.getItem(this.getKeyBelow(key))?.parentKey;\n layoutInfo = this.getLayoutInfo(keyBelow);\n if (layoutInfo && layoutInfo.rect.y < pageY) {\n while (layoutInfo && layoutInfo.rect.y < pageY) {\n let childKey = getFirstItem(getChildNodes(this.collection.getItem(layoutInfo.key), this.collection))?.key;\n let keyBelow = this.collection.getItem(this.getKeyBelow(childKey))?.parentKey;\n layoutInfo = this.getLayoutInfo(keyBelow);\n }\n }\n\n if (layoutInfo) {\n let childKey = getFirstItem(getChildNodes(this.collection.getItem(layoutInfo.key), this.collection))?.key;\n return childKey;\n }\n }\n\n return this.getLastKey();\n }\n\n getKeyForSearch(search: string, fromKey?: Key) {\n if (!this.collator) {\n return null;\n }\n\n let collection = this.collection;\n let key = fromKey ?? this.getFirstKey();\n\n let startItem = collection.getItem(key);\n key = startItem.parentKey;\n\n while (key != null) {\n let item = collection.getItem(key);\n if (item.textValue) {\n let substring = item.textValue.slice(0, search.length);\n if (this.collator.compare(substring, search) === 0) {\n return getFirstItem(getChildNodes(item, this.collection))?.key;\n }\n }\n\n key = this.collection.getKeyAfter(key);\n }\n\n return null;\n }\n}\n"],"names":[],"version":3,"file":"BaseLayout.module.js.map"}
@@ -117,6 +117,11 @@ function $514a55f6d91f25ef$var$CardView(props, ref) {
117
117
  let focusedKey = state.selectionManager.focusedKey;
118
118
  let focusedItem = gridCollection.getItem(state.selectionManager.focusedKey);
119
119
  if ((focusedItem === null || focusedItem === void 0 ? void 0 : focusedItem.parentKey) != null) focusedKey = focusedItem.parentKey;
120
+ let persistedKeys = (0, $kFdxB$react.useMemo)(()=>focusedKey != null ? new Set([
121
+ focusedKey
122
+ ]) : null, [
123
+ focusedKey
124
+ ]);
120
125
  // TODO: does aria-row count and aria-col count need to be modified? Perhaps aria-col count needs to be omitted
121
126
  return /*#__PURE__*/ (0, ($parcel$interopDefault($kFdxB$react))).createElement((0, $e57ab98cef2f01a5$exports.CardViewContext).Provider, {
122
127
  value: {
@@ -131,7 +136,7 @@ function $514a55f6d91f25ef$var$CardView(props, ref) {
131
136
  ...styleProps,
132
137
  className: (0, $kFdxB$reactspectrumutils.classNames)((0, ($parcel$interopDefault($71570f0038472fa2$exports))), 'spectrum-CardView'),
133
138
  ref: domRef,
134
- focusedKey: focusedKey,
139
+ persistedKeys: persistedKeys,
135
140
  scrollDirection: "vertical",
136
141
  layout: cardViewLayout,
137
142
  collection: gridCollection,
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;AAqBD,SAAS,+BAA2B,KAA+B,EAAE,GAA2B;IAC9F,IAAI,SAAC,KAAK,EAAC,GAAG,CAAA,GAAA,wCAAU;IACxB,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,uCAAY,EAAE;IACjC,IAAI,SAAS,CAAA,GAAA,mCAAQ,EAAE;IACvB,IAAI,WACF,OAAO,oBACP,gBAAgB,UAChB,MAAM,gBACN,YAAY,cACZ,UAAU,mBACV,kBAAkB,YACnB,GAAG;IAEJ,IAAI,WAAW,CAAA,GAAA,gCAAU,EAAE;QAAC,OAAO;QAAU,aAAa;IAAM;IAChE,IAAI,YAAY,iBAAiB,aAAa,iBAAiB;IAC/D,IAAI,iBAAiB,CAAA,GAAA,oBAAM,EAAE,IAAM,OAAO,WAAW,aAAa,IAAI,OAAO;sBAAC;6BAAU;mBAAiB;QAAK,KAAK,QAAQ;QAAC;QAAQ;QAAU;QAAiB;KAAM;IACrK,IAAI,aAAa,eAAe,UAAU;IAE1C,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,8BAAQ;IAC1B,IAAI,c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IACpG,sFAAsF;IACtF,OAAO,cAAc,gBAAgB;IACrC,qBACE,0DAAC;QAAK,GAAG,QAAQ;QAAE,KAAK;QAAQ,WAAW,CAAA,GAAA,oCAAS,EAAE,CAAA,GAAA,mDAAK,GAAG;qBAC5D,0DAAC,CAAA,GAAA,kCAAO;QACN,KAAK;QACL,cAAc;QACd,SAAS;QACT,aAAa;QACb,MAAM;QACN,QAAQ;OACP,KAAK,QAAQ;AAItB;AAEA;;CAEC,GACD,MAAM,0DAAY,CAAA,GAAA,sCAAI,EAAE,UAAU,CAAC","sources":["packages/@react-spectrum/card/src/CardView.tsx"],"sourcesContent":["/*\n * Copyright 2021 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 {CardBase} from './CardBase';\nimport {CardViewContext, useCardViewContext} from './CardViewContext';\nimport {classNames, useDOMRef, useStyleProps, useUnwrapDOMRef} from '@react-spectrum/utils';\nimport {DOMRef, DOMRefValue, Node} from '@react-types/shared';\nimport {GridCollection, useGridState} from '@react-stately/grid';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {mergeProps} from '@react-aria/utils';\nimport {ProgressCircle} from '@react-spectrum/progress';\nimport React, {ReactElement, ReactNode, useCallback, useMemo, useRef} from 'react';\nimport {ReusableView} from '@react-stately/virtualizer';\nimport {SpectrumCardViewProps} from '@react-types/card';\nimport styles from '@adobe/spectrum-css-temp/components/card/vars.css';\nimport {useCollator, useLocale, useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useGrid, useGridCell, useGridRow} from '@react-aria/grid';\nimport {useListState} from '@react-stately/list';\nimport {useProvider} from '@react-spectrum/provider';\nimport {Virtualizer, VirtualizerItem} from '@react-aria/virtualizer';\n\nfunction CardView<T extends object>(props: SpectrumCardViewProps<T>, ref: DOMRef<HTMLDivElement>) {\n let {scale} = useProvider();\n let {styleProps} = useStyleProps(props);\n let domRef = useDOMRef(ref);\n let {\n isQuiet,\n renderEmptyState,\n layout,\n loadingState,\n onLoadMore,\n cardOrientation = 'vertical'\n } = props;\n\n let collator = useCollator({usage: 'search', sensitivity: 'base'});\n let isLoading = loadingState === 'loading' || loadingState === 'loadingMore';\n let cardViewLayout = useMemo(() => typeof layout === 'function' ? new layout({collator, cardOrientation, scale}) : layout, [layout, collator, cardOrientation, scale]);\n let layoutType = cardViewLayout.layoutType;\n\n let {direction} = useLocale();\n let {collection} = useListState(props);\n\n let gridCollection = useMemo(() => new GridCollection<T>({\n columnCount: 1,\n items: [...collection].map(item => ({\n // Makes the Grid row use the keys the user provides to the cards so that selection change via interactions returns the card keys\n ...item,\n hasChildNodes: true,\n childNodes: [{\n key: `cell-${item.key}`,\n type: 'cell',\n value: null,\n level: 0,\n rendered: null,\n textValue: item.textValue,\n hasChildNodes: false,\n childNodes: []\n }]\n }))\n }), [collection]);\n\n let state = useGridState({\n ...props,\n selectionMode: cardOrientation === 'horizontal' && layoutType === 'grid' ? 'none' : props.selectionMode,\n collection: gridCollection,\n focusMode: 'cell'\n });\n\n cardViewLayout.collection = gridCollection;\n cardViewLayout.disabledKeys = state.disabledKeys;\n\n let {gridProps} = useGrid({\n ...props,\n isVirtualized: true,\n keyboardDelegate: cardViewLayout\n }, state, domRef);\n\n type View = ReusableView<Node<T>, ReactNode>;\n let renderWrapper = useCallback((parent: View, reusableView: View) => (\n <VirtualizerItem\n key={reusableView.key}\n layoutInfo={reusableView.layoutInfo}\n virtualizer={reusableView.virtualizer}\n parent={parent?.layoutInfo}>\n {reusableView.rendered}\n </VirtualizerItem>\n ), []);\n\n let focusedKey = state.selectionManager.focusedKey;\n let focusedItem = gridCollection.getItem(state.selectionManager.focusedKey);\n if (focusedItem?.parentKey != null) {\n focusedKey = focusedItem.parentKey;\n }\n\n // TODO: does aria-row count and aria-col count need to be modified? Perhaps aria-col count needs to be omitted\n return (\n <CardViewContext.Provider value={{state, isQuiet, layout: cardViewLayout, cardOrientation, renderEmptyState}}>\n <Virtualizer\n {...gridProps}\n {...styleProps}\n className={classNames(styles, 'spectrum-CardView')}\n ref={domRef}\n focusedKey={focusedKey}\n scrollDirection=\"vertical\"\n layout={cardViewLayout}\n collection={gridCollection}\n isLoading={isLoading}\n onLoadMore={onLoadMore}\n layoutOptions={useMemo(() => ({isLoading, direction}), [isLoading, direction])}\n renderWrapper={renderWrapper}\n style={{\n ...styleProps.style,\n scrollPaddingTop: cardViewLayout.margin || 0\n }}>\n {useCallback((type, item) => {\n if (type === 'item') {\n return (\n <InternalCard item={item} />\n );\n } else if (type === 'loader') {\n return <LoadingState />;\n } else if (type === 'placeholder') {\n return <EmptyState />;\n }\n }, [])}\n </Virtualizer>\n </CardViewContext.Provider>\n\n );\n}\n\nfunction LoadingState() {\n let {state} = useCardViewContext();\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-spectrum/card');\n return (\n <CenteredWrapper>\n <ProgressCircle\n isIndeterminate\n aria-label={state.collection.size > 0 ? stringFormatter.format('loadingMore') : stringFormatter.format('loading')} />\n </CenteredWrapper>\n );\n}\n\nfunction EmptyState() {\n let {renderEmptyState} = useCardViewContext();\n let emptyState = renderEmptyState ? renderEmptyState() : null;\n if (emptyState == null) {\n return null;\n }\n\n return (\n <CenteredWrapper>\n {emptyState}\n </CenteredWrapper>\n );\n}\n\nfunction CenteredWrapper({children}) {\n let {state} = useCardViewContext();\n return (\n <div\n role=\"row\"\n aria-rowindex={state.collection.size + 1}\n className={classNames(styles, 'spectrum-CardView-centeredWrapper')}>\n <div role=\"gridcell\">\n {children}\n </div>\n </div>\n );\n}\n\nfunction InternalCard(props) {\n let {\n item\n } = props;\n let cellNode = [...item.childNodes][0];\n let {state, cardOrientation, isQuiet, layout} = useCardViewContext();\n\n let layoutType = layout.layoutType;\n let rowRef = useRef(undefined);\n let cellRef = useRef<DOMRefValue<HTMLDivElement>>(undefined);\n let unwrappedRef = useUnwrapDOMRef(cellRef);\n\n let {rowProps: gridRowProps} = useGridRow({\n node: item,\n isVirtualized: true\n }, state, rowRef);\n\n let {gridCellProps} = useGridCell({\n node: cellNode,\n focusMode: 'cell'\n }, state, unwrappedRef);\n\n // Prevent space key from scrolling the CardView if triggered on a disabled item or on a Card in a selectionMode=\"none\" CardView.\n let allowsInteraction = state.selectionManager.selectionMode !== 'none';\n let isDisabled = !allowsInteraction || state.disabledKeys.has(item.key);\n\n let onKeyDown = (e) => {\n if (e.key === ' ' && isDisabled) {\n e.preventDefault();\n }\n };\n\n let rowProps = mergeProps(\n gridRowProps,\n {onKeyDown}\n );\n\n if (layoutType === 'grid' || layoutType === 'gallery') {\n isQuiet = true;\n }\n\n if (layoutType !== 'grid') {\n cardOrientation = 'vertical';\n }\n\n // We don't want to focus the checkbox (or any other focusable elements) within the Card\n // when pressing the arrow keys so we delete the key down handler here. Arrow key navigation between\n // the cards in the CardView is handled by useGrid => useSelectableCollection instead.\n delete gridCellProps.onKeyDownCapture;\n return (\n <div {...rowProps} ref={rowRef} className={classNames(styles, 'spectrum-CardView-row')}>\n <CardBase\n ref={cellRef}\n articleProps={gridCellProps}\n isQuiet={isQuiet}\n orientation={cardOrientation}\n item={item}\n layout={layoutType}>\n {item.rendered}\n </CardBase>\n </div>\n );\n}\n\n/**\n * TODO: Add description of component here.\n */\nconst _CardView = React.forwardRef(CardView) as <T>(props: SpectrumCardViewProps<T> & {ref?: DOMRef<HTMLDivElement>}) => ReactElement;\nexport {_CardView as CardView};\n"],"names":[],"version":3,"file":"CardView.main.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;AAqBD,SAAS,+BAA2B,KAA+B,EAAE,GAA2B;IAC9F,IAAI,SAA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AAI,SAAS,CAAA,GAAA,mBAAK,EAAE;IACpB,IAAI,UAAU,CAAA,GAAA,mBAAK,EAA+B;IAClD,IAAI,eAAe,CAAA,GAAA,yCAAc,EAAE;IAEnC,IAAI,EAAC,UAAU,YAAY,EAAC,GAAG,CAAA,GAAA,+BAAS,EAAE;QACxC,MAAM;QACN,eAAe;IACjB,GAAG,OAAO;IAEV,IAAI,iBAAC,aAAa,EAAC,GAAG,CAAA,GAAA,gCAAU,EAAE;QAChC,MAAM;QACN,WAAW;IACb,GAAG,OAAO;IAEV,iIAAiI;IACjI,IAAI,oBAAoB,MAAM,gBAAgB,CAAC,aAAa,KAAK;IACjE,IAAI,aAAa,CAAC,qBAAqB,MAAM,YAAY,CAAC,GAAG,CAAC,KAAK,GAAG;IAEtE,IAAI,YAAY,CAAC;QACf,IAAI,EAAE,GAAG,KAAK,OAAO,YACnB,EAAE,cAAc;IAEpB;IAEA,IAAI,WAAW,CAAA,GAAA,gCAAS,EACtB,cACA;mBAAC;IAAS;IAGZ,IAAI,eAAe,UAAU,eAAe,WAC1C,UAAU;IAGZ,IAAI,eAAe,QACjB,kBAAkB;IAGpB,wFAAwF;IACxF,oGAAoG;IACpG,sFAAsF;IACtF,OAAO,cAAc,gBAAgB;IACrC,qBACE,0DAAC;QAAK,GAAG,QAAQ;QAAE,KAAK;QAAQ,WAAW,CAAA,GAAA,oCAAS,EAAE,CAAA,GAAA,mDAAK,GAAG;qBAC5D,0DAAC,CAAA,GAAA,kCAAO;QACN,KAAK;QACL,cAAc;QACd,SAAS;QACT,aAAa;QACb,MAAM;QACN,QAAQ;OACP,KAAK,QAAQ;AAItB;AAEA;;CAEC,GACD,MAAM,0DAAY,CAAA,GAAA,sCAAI,EAAE,UAAU,CAAC","sources":["packages/@react-spectrum/card/src/CardView.tsx"],"sourcesContent":["/*\n * Copyright 2021 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 {CardBase} from './CardBase';\nimport {CardViewContext, useCardViewContext} from './CardViewContext';\nimport {classNames, useDOMRef, useStyleProps, useUnwrapDOMRef} from '@react-spectrum/utils';\nimport {DOMRef, DOMRefValue, Node} from '@react-types/shared';\nimport {GridCollection, useGridState} from '@react-stately/grid';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {mergeProps} from '@react-aria/utils';\nimport {ProgressCircle} from '@react-spectrum/progress';\nimport React, {ReactElement, ReactNode, useCallback, useMemo, useRef} from 'react';\nimport {ReusableView} from '@react-stately/virtualizer';\nimport {SpectrumCardViewProps} from '@react-types/card';\nimport styles from '@adobe/spectrum-css-temp/components/card/vars.css';\nimport {useCollator, useLocale, useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useGrid, useGridCell, useGridRow} from '@react-aria/grid';\nimport {useListState} from '@react-stately/list';\nimport {useProvider} from '@react-spectrum/provider';\nimport {Virtualizer, VirtualizerItem} from '@react-aria/virtualizer';\n\nfunction CardView<T extends object>(props: SpectrumCardViewProps<T>, ref: DOMRef<HTMLDivElement>) {\n let {scale} = useProvider();\n let {styleProps} = useStyleProps(props);\n let domRef = useDOMRef(ref);\n let {\n isQuiet,\n renderEmptyState,\n layout,\n loadingState,\n onLoadMore,\n cardOrientation = 'vertical'\n } = props;\n\n let collator = useCollator({usage: 'search', sensitivity: 'base'});\n let isLoading = loadingState === 'loading' || loadingState === 'loadingMore';\n let cardViewLayout = useMemo(() => typeof layout === 'function' ? new layout({collator, cardOrientation, scale}) : layout, [layout, collator, cardOrientation, scale]);\n let layoutType = cardViewLayout.layoutType;\n\n let {direction} = useLocale();\n let {collection} = useListState(props);\n\n let gridCollection = useMemo(() => new GridCollection<T>({\n columnCount: 1,\n items: [...collection].map(item => ({\n // Makes the Grid row use the keys the user provides to the cards so that selection change via interactions returns the card keys\n ...item,\n hasChildNodes: true,\n childNodes: [{\n key: `cell-${item.key}`,\n type: 'cell',\n value: null,\n level: 0,\n rendered: null,\n textValue: item.textValue,\n hasChildNodes: false,\n childNodes: []\n }]\n }))\n }), [collection]);\n\n let state = useGridState({\n ...props,\n selectionMode: cardOrientation === 'horizontal' && layoutType === 'grid' ? 'none' : props.selectionMode,\n collection: gridCollection,\n focusMode: 'cell'\n });\n\n cardViewLayout.collection = gridCollection;\n cardViewLayout.disabledKeys = state.disabledKeys;\n\n let {gridProps} = useGrid({\n ...props,\n isVirtualized: true,\n keyboardDelegate: cardViewLayout\n }, state, domRef);\n\n type View = ReusableView<Node<T>, ReactNode>;\n let renderWrapper = useCallback((parent: View, reusableView: View) => (\n <VirtualizerItem\n key={reusableView.key}\n layoutInfo={reusableView.layoutInfo}\n virtualizer={reusableView.virtualizer}\n parent={parent?.layoutInfo}>\n {reusableView.rendered}\n </VirtualizerItem>\n ), []);\n\n let focusedKey = state.selectionManager.focusedKey;\n let focusedItem = gridCollection.getItem(state.selectionManager.focusedKey);\n if (focusedItem?.parentKey != null) {\n focusedKey = focusedItem.parentKey;\n }\n\n let persistedKeys = useMemo(() => focusedKey != null ? new Set([focusedKey]) : null, [focusedKey]);\n\n // TODO: does aria-row count and aria-col count need to be modified? Perhaps aria-col count needs to be omitted\n return (\n <CardViewContext.Provider value={{state, isQuiet, layout: cardViewLayout, cardOrientation, renderEmptyState}}>\n <Virtualizer\n {...gridProps}\n {...styleProps}\n className={classNames(styles, 'spectrum-CardView')}\n ref={domRef}\n persistedKeys={persistedKeys}\n scrollDirection=\"vertical\"\n layout={cardViewLayout}\n collection={gridCollection}\n isLoading={isLoading}\n onLoadMore={onLoadMore}\n layoutOptions={useMemo(() => ({isLoading, direction}), [isLoading, direction])}\n renderWrapper={renderWrapper}\n style={{\n ...styleProps.style,\n scrollPaddingTop: cardViewLayout.margin || 0\n }}>\n {useCallback((type, item) => {\n if (type === 'item') {\n return (\n <InternalCard item={item} />\n );\n } else if (type === 'loader') {\n return <LoadingState />;\n } else if (type === 'placeholder') {\n return <EmptyState />;\n }\n }, [])}\n </Virtualizer>\n </CardViewContext.Provider>\n\n );\n}\n\nfunction LoadingState() {\n let {state} = useCardViewContext();\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-spectrum/card');\n return (\n <CenteredWrapper>\n <ProgressCircle\n isIndeterminate\n aria-label={state.collection.size > 0 ? stringFormatter.format('loadingMore') : stringFormatter.format('loading')} />\n </CenteredWrapper>\n );\n}\n\nfunction EmptyState() {\n let {renderEmptyState} = useCardViewContext();\n let emptyState = renderEmptyState ? renderEmptyState() : null;\n if (emptyState == null) {\n return null;\n }\n\n return (\n <CenteredWrapper>\n {emptyState}\n </CenteredWrapper>\n );\n}\n\nfunction CenteredWrapper({children}) {\n let {state} = useCardViewContext();\n return (\n <div\n role=\"row\"\n aria-rowindex={state.collection.size + 1}\n className={classNames(styles, 'spectrum-CardView-centeredWrapper')}>\n <div role=\"gridcell\">\n {children}\n </div>\n </div>\n );\n}\n\nfunction InternalCard(props) {\n let {\n item\n } = props;\n let cellNode = [...item.childNodes][0];\n let {state, cardOrientation, isQuiet, layout} = useCardViewContext();\n\n let layoutType = layout.layoutType;\n let rowRef = useRef(undefined);\n let cellRef = useRef<DOMRefValue<HTMLDivElement>>(undefined);\n let unwrappedRef = useUnwrapDOMRef(cellRef);\n\n let {rowProps: gridRowProps} = useGridRow({\n node: item,\n isVirtualized: true\n }, state, rowRef);\n\n let {gridCellProps} = useGridCell({\n node: cellNode,\n focusMode: 'cell'\n }, state, unwrappedRef);\n\n // Prevent space key from scrolling the CardView if triggered on a disabled item or on a Card in a selectionMode=\"none\" CardView.\n let allowsInteraction = state.selectionManager.selectionMode !== 'none';\n let isDisabled = !allowsInteraction || state.disabledKeys.has(item.key);\n\n let onKeyDown = (e) => {\n if (e.key === ' ' && isDisabled) {\n e.preventDefault();\n }\n };\n\n let rowProps = mergeProps(\n gridRowProps,\n {onKeyDown}\n );\n\n if (layoutType === 'grid' || layoutType === 'gallery') {\n isQuiet = true;\n }\n\n if (layoutType !== 'grid') {\n cardOrientation = 'vertical';\n }\n\n // We don't want to focus the checkbox (or any other focusable elements) within the Card\n // when pressing the arrow keys so we delete the key down handler here. Arrow key navigation between\n // the cards in the CardView is handled by useGrid => useSelectableCollection instead.\n delete gridCellProps.onKeyDownCapture;\n return (\n <div {...rowProps} ref={rowRef} className={classNames(styles, 'spectrum-CardView-row')}>\n <CardBase\n ref={cellRef}\n articleProps={gridCellProps}\n isQuiet={isQuiet}\n orientation={cardOrientation}\n item={item}\n layout={layoutType}>\n {item.rendered}\n </CardBase>\n </div>\n );\n}\n\n/**\n * TODO: Add description of component here.\n */\nconst _CardView = React.forwardRef(CardView) as <T>(props: SpectrumCardViewProps<T> & {ref?: DOMRef<HTMLDivElement>}) => ReactElement;\nexport {_CardView as CardView};\n"],"names":[],"version":3,"file":"CardView.main.js.map"}
package/dist/CardView.mjs CHANGED
@@ -111,6 +111,11 @@ function $81a52da995c19652$var$CardView(props, ref) {
111
111
  let focusedKey = state.selectionManager.focusedKey;
112
112
  let focusedItem = gridCollection.getItem(state.selectionManager.focusedKey);
113
113
  if ((focusedItem === null || focusedItem === void 0 ? void 0 : focusedItem.parentKey) != null) focusedKey = focusedItem.parentKey;
114
+ let persistedKeys = (0, $iOsT7$useMemo)(()=>focusedKey != null ? new Set([
115
+ focusedKey
116
+ ]) : null, [
117
+ focusedKey
118
+ ]);
114
119
  // TODO: does aria-row count and aria-col count need to be modified? Perhaps aria-col count needs to be omitted
115
120
  return /*#__PURE__*/ (0, $iOsT7$react).createElement((0, $8d180a244893de14$export$64992ac69f286e5c).Provider, {
116
121
  value: {
@@ -125,7 +130,7 @@ function $81a52da995c19652$var$CardView(props, ref) {
125
130
  ...styleProps,
126
131
  className: (0, $iOsT7$classNames)((0, ($parcel$interopDefault($iOsT7$card_vars_cssmodulejs))), 'spectrum-CardView'),
127
132
  ref: domRef,
128
- focusedKey: focusedKey,
133
+ persistedKeys: persistedKeys,
129
134
  scrollDirection: "vertical",
130
135
  layout: cardViewLayout,
131
136
  collection: gridCollection,
@@ -111,6 +111,11 @@ function $81a52da995c19652$var$CardView(props, ref) {
111
111
  let focusedKey = state.selectionManager.focusedKey;
112
112
  let focusedItem = gridCollection.getItem(state.selectionManager.focusedKey);
113
113
  if ((focusedItem === null || focusedItem === void 0 ? void 0 : focusedItem.parentKey) != null) focusedKey = focusedItem.parentKey;
114
+ let persistedKeys = (0, $iOsT7$useMemo)(()=>focusedKey != null ? new Set([
115
+ focusedKey
116
+ ]) : null, [
117
+ focusedKey
118
+ ]);
114
119
  // TODO: does aria-row count and aria-col count need to be modified? Perhaps aria-col count needs to be omitted
115
120
  return /*#__PURE__*/ (0, $iOsT7$react).createElement((0, $8d180a244893de14$export$64992ac69f286e5c).Provider, {
116
121
  value: {
@@ -125,7 +130,7 @@ function $81a52da995c19652$var$CardView(props, ref) {
125
130
  ...styleProps,
126
131
  className: (0, $iOsT7$classNames)((0, ($parcel$interopDefault($iOsT7$card_vars_cssmodulejs))), 'spectrum-CardView'),
127
132
  ref: domRef,
128
- focusedKey: focusedKey,
133
+ persistedKeys: persistedKeys,
129
134
  scrollDirection: "vertical",
130
135
  layout: cardViewLayout,
131
136
  collection: gridCollection,
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;AAqBD,SAAS,+BAA2B,KAA+B,EAAE,GAA2B;IAC9F,IAAI,SAAC,KAAK,EAAC,GAAG,CAAA,GAAA,kBAAU;IACxB,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,oBAAY,EAAE;IACjC,IAAI,SAAS,CAAA,GAAA,gBAAQ,EAAE;IACvB,IAAI,WACF,OAAO,oBACP,gBAAgB,UAChB,MAAM,gBACN,YAAY,cACZ,U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O;IAEV,iIAAiI;IACjI,IAAI,oBAAoB,MAAM,gBAAgB,CAAC,aAAa,KAAK;IACjE,IAAI,aAAa,CAAC,qBAAqB,MAAM,YAAY,CAAC,GAAG,CAAC,KAAK,GAAG;IAEtE,IAAI,YAAY,CAAC;QACf,IAAI,EAAE,GAAG,KAAK,OAAO,YACnB,EAAE,cAAc;IAEpB;IAEA,IAAI,WAAW,CAAA,GAAA,iBAAS,EACtB,cACA;mBAAC;IAAS;IAGZ,IAAI,eAAe,UAAU,eAAe,WAC1C,UAAU;IAGZ,IAAI,eAAe,QACjB,kBAAkB;IAGpB,wFAAwF;IACxF,oGAAoG;IACpG,sFAAsF;IACtF,OAAO,cAAc,gBAAgB;IACrC,qBACE,gCAAC;QAAK,GAAG,QAAQ;QAAE,KAAK;QAAQ,WAAW,CAAA,GAAA,iBAAS,EAAE,CAAA,GAAA,sDAAK,GAAG;qBAC5D,gCAAC,CAAA,GAAA,yCAAO;QACN,KAAK;QACL,cAAc;QACd,SAAS;QACT,aAAa;QACb,MAAM;QACN,QAAQ;OACP,KAAK,QAAQ;AAItB;AAEA;;CAEC,GACD,MAAM,0DAAY,CAAA,GAAA,YAAI,EAAE,UAAU,CAAC","sources":["packages/@react-spectrum/card/src/CardView.tsx"],"sourcesContent":["/*\n * Copyright 2021 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 {CardBase} from './CardBase';\nimport {CardViewContext, useCardViewContext} from './CardViewContext';\nimport {classNames, useDOMRef, useStyleProps, useUnwrapDOMRef} from '@react-spectrum/utils';\nimport {DOMRef, DOMRefValue, Node} from '@react-types/shared';\nimport {GridCollection, useGridState} from '@react-stately/grid';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {mergeProps} from '@react-aria/utils';\nimport {ProgressCircle} from '@react-spectrum/progress';\nimport React, {ReactElement, ReactNode, useCallback, useMemo, useRef} from 'react';\nimport {ReusableView} from '@react-stately/virtualizer';\nimport {SpectrumCardViewProps} from '@react-types/card';\nimport styles from '@adobe/spectrum-css-temp/components/card/vars.css';\nimport {useCollator, useLocale, useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useGrid, useGridCell, useGridRow} from '@react-aria/grid';\nimport {useListState} from '@react-stately/list';\nimport {useProvider} from '@react-spectrum/provider';\nimport {Virtualizer, VirtualizerItem} from '@react-aria/virtualizer';\n\nfunction CardView<T extends object>(props: SpectrumCardViewProps<T>, ref: DOMRef<HTMLDivElement>) {\n let {scale} = useProvider();\n let {styleProps} = useStyleProps(props);\n let domRef = useDOMRef(ref);\n let {\n isQuiet,\n renderEmptyState,\n layout,\n loadingState,\n onLoadMore,\n cardOrientation = 'vertical'\n } = props;\n\n let collator = useCollator({usage: 'search', sensitivity: 'base'});\n let isLoading = loadingState === 'loading' || loadingState === 'loadingMore';\n let cardViewLayout = useMemo(() => typeof layout === 'function' ? new layout({collator, cardOrientation, scale}) : layout, [layout, collator, cardOrientation, scale]);\n let layoutType = cardViewLayout.layoutType;\n\n let {direction} = useLocale();\n let {collection} = useListState(props);\n\n let gridCollection = useMemo(() => new GridCollection<T>({\n columnCount: 1,\n items: [...collection].map(item => ({\n // Makes the Grid row use the keys the user provides to the cards so that selection change via interactions returns the card keys\n ...item,\n hasChildNodes: true,\n childNodes: [{\n key: `cell-${item.key}`,\n type: 'cell',\n value: null,\n level: 0,\n rendered: null,\n textValue: item.textValue,\n hasChildNodes: false,\n childNodes: []\n }]\n }))\n }), [collection]);\n\n let state = useGridState({\n ...props,\n selectionMode: cardOrientation === 'horizontal' && layoutType === 'grid' ? 'none' : props.selectionMode,\n collection: gridCollection,\n focusMode: 'cell'\n });\n\n cardViewLayout.collection = gridCollection;\n cardViewLayout.disabledKeys = state.disabledKeys;\n\n let {gridProps} = useGrid({\n ...props,\n isVirtualized: true,\n keyboardDelegate: cardViewLayout\n }, state, domRef);\n\n type View = ReusableView<Node<T>, ReactNode>;\n let renderWrapper = useCallback((parent: View, reusableView: View) => (\n <VirtualizerItem\n key={reusableView.key}\n layoutInfo={reusableView.layoutInfo}\n virtualizer={reusableView.virtualizer}\n parent={parent?.layoutInfo}>\n {reusableView.rendered}\n </VirtualizerItem>\n ), []);\n\n let focusedKey = state.selectionManager.focusedKey;\n let focusedItem = gridCollection.getItem(state.selectionManager.focusedKey);\n if (focusedItem?.parentKey != null) {\n focusedKey = focusedItem.parentKey;\n }\n\n // TODO: does aria-row count and aria-col count need to be modified? Perhaps aria-col count needs to be omitted\n return (\n <CardViewContext.Provider value={{state, isQuiet, layout: cardViewLayout, cardOrientation, renderEmptyState}}>\n <Virtualizer\n {...gridProps}\n {...styleProps}\n className={classNames(styles, 'spectrum-CardView')}\n ref={domRef}\n focusedKey={focusedKey}\n scrollDirection=\"vertical\"\n layout={cardViewLayout}\n collection={gridCollection}\n isLoading={isLoading}\n onLoadMore={onLoadMore}\n layoutOptions={useMemo(() => ({isLoading, direction}), [isLoading, direction])}\n renderWrapper={renderWrapper}\n style={{\n ...styleProps.style,\n scrollPaddingTop: cardViewLayout.margin || 0\n }}>\n {useCallback((type, item) => {\n if (type === 'item') {\n return (\n <InternalCard item={item} />\n );\n } else if (type === 'loader') {\n return <LoadingState />;\n } else if (type === 'placeholder') {\n return <EmptyState />;\n }\n }, [])}\n </Virtualizer>\n </CardViewContext.Provider>\n\n );\n}\n\nfunction LoadingState() {\n let {state} = useCardViewContext();\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-spectrum/card');\n return (\n <CenteredWrapper>\n <ProgressCircle\n isIndeterminate\n aria-label={state.collection.size > 0 ? stringFormatter.format('loadingMore') : stringFormatter.format('loading')} />\n </CenteredWrapper>\n );\n}\n\nfunction EmptyState() {\n let {renderEmptyState} = useCardViewContext();\n let emptyState = renderEmptyState ? renderEmptyState() : null;\n if (emptyState == null) {\n return null;\n }\n\n return (\n <CenteredWrapper>\n {emptyState}\n </CenteredWrapper>\n );\n}\n\nfunction CenteredWrapper({children}) {\n let {state} = useCardViewContext();\n return (\n <div\n role=\"row\"\n aria-rowindex={state.collection.size + 1}\n className={classNames(styles, 'spectrum-CardView-centeredWrapper')}>\n <div role=\"gridcell\">\n {children}\n </div>\n </div>\n );\n}\n\nfunction InternalCard(props) {\n let {\n item\n } = props;\n let cellNode = [...item.childNodes][0];\n let {state, cardOrientation, isQuiet, layout} = useCardViewContext();\n\n let layoutType = layout.layoutType;\n let rowRef = useRef(undefined);\n let cellRef = useRef<DOMRefValue<HTMLDivElement>>(undefined);\n let unwrappedRef = useUnwrapDOMRef(cellRef);\n\n let {rowProps: gridRowProps} = useGridRow({\n node: item,\n isVirtualized: true\n }, state, rowRef);\n\n let {gridCellProps} = useGridCell({\n node: cellNode,\n focusMode: 'cell'\n }, state, unwrappedRef);\n\n // Prevent space key from scrolling the CardView if triggered on a disabled item or on a Card in a selectionMode=\"none\" CardView.\n let allowsInteraction = state.selectionManager.selectionMode !== 'none';\n let isDisabled = !allowsInteraction || state.disabledKeys.has(item.key);\n\n let onKeyDown = (e) => {\n if (e.key === ' ' && isDisabled) {\n e.preventDefault();\n }\n };\n\n let rowProps = mergeProps(\n gridRowProps,\n {onKeyDown}\n );\n\n if (layoutType === 'grid' || layoutType === 'gallery') {\n isQuiet = true;\n }\n\n if (layoutType !== 'grid') {\n cardOrientation = 'vertical';\n }\n\n // We don't want to focus the checkbox (or any other focusable elements) within the Card\n // when pressing the arrow keys so we delete the key down handler here. Arrow key navigation between\n // the cards in the CardView is handled by useGrid => useSelectableCollection instead.\n delete gridCellProps.onKeyDownCapture;\n return (\n <div {...rowProps} ref={rowRef} className={classNames(styles, 'spectrum-CardView-row')}>\n <CardBase\n ref={cellRef}\n articleProps={gridCellProps}\n isQuiet={isQuiet}\n orientation={cardOrientation}\n item={item}\n layout={layoutType}>\n {item.rendered}\n </CardBase>\n </div>\n );\n}\n\n/**\n * TODO: Add description of component here.\n */\nconst _CardView = React.forwardRef(CardView) as <T>(props: SpectrumCardViewProps<T> & {ref?: DOMRef<HTMLDivElement>}) => ReactElement;\nexport {_CardView as CardView};\n"],"names":[],"version":3,"file":"CardView.module.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;;;;;;;;;;;;AAqBD,SAAS,+BAA2B,KAA+B,EAAE,GAA2B;IAC9F,IAAI,SAAC,KAAK,EAAC,GAAG,CAAA,GAAA,kBAAU;IACxB,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,oBAAY,EAAE;IACjC,IAAI,SAAS,CAAA,GAAA,gBAAQ,EAAE;IACvB,IAAI,WACF,OAAO,oBACP,gBAAgB,UAChB,MAAM,gBACN,YAAY,cACZ,UAAU,mBACV,kBAAkB,YACnB,GAAG;IAEJ,IAAI,WAAW,CAAA,GAAA,kBAAU,EAAE;QAAC,OAAO;QAAU,aAAa;IAAM;IAChE,IAAI,YAAY,iBAAiB,aAAa,iBAAiB;IAC/D,IAAI,iBAAiB,CAAA,GAAA,cAAM,EAAE,IAAM,OAAO,WAAW,aAAa,IAAI,OAAO;sBAAC;6BAAU;mBAAiB;QAAK,KAAK,QAAQ;QAAC;QAAQ;QAAU;QAAiB;KAAM;IACrK,IAAI,aAAa,eAAe,UAAU;IAE1C,IAAI,aAAC,SAAS,EAAC,GAAG,CAAA,GAAA,gBAAQ;IAC1B,IAAI,cAAC,UAAU,EAAC,GAAG,CAAA,GAAA,mBAAW,EAAE;IAEhC,IAAI,iBAAiB,CAAA,GAAA,cAAM,EAAE,IAAM,IAAI,CAAA,GAAA,qBAAa,EAAK;YACvD,aAAa;YACb,OAAO;mBAAI;aAAW,CAAC,GAAG,CAAC,CAAA,OAAS,CAAA;oBAClC,iIAAiI;oB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iBAAS,EAAE,CAAA,GAAA,sDAAK,GAAG;qBAC5D,gCAAC,CAAA,GAAA,yCAAO;QACN,KAAK;QACL,cAAc;QACd,SAAS;QACT,aAAa;QACb,MAAM;QACN,QAAQ;OACP,KAAK,QAAQ;AAItB;AAEA;;CAEC,GACD,MAAM,0DAAY,CAAA,GAAA,YAAI,EAAE,UAAU,CAAC","sources":["packages/@react-spectrum/card/src/CardView.tsx"],"sourcesContent":["/*\n * Copyright 2021 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 {CardBase} from './CardBase';\nimport {CardViewContext, useCardViewContext} from './CardViewContext';\nimport {classNames, useDOMRef, useStyleProps, useUnwrapDOMRef} from '@react-spectrum/utils';\nimport {DOMRef, DOMRefValue, Node} from '@react-types/shared';\nimport {GridCollection, useGridState} from '@react-stately/grid';\n// @ts-ignore\nimport intlMessages from '../intl/*.json';\nimport {mergeProps} from '@react-aria/utils';\nimport {ProgressCircle} from '@react-spectrum/progress';\nimport React, {ReactElement, ReactNode, useCallback, useMemo, useRef} from 'react';\nimport {ReusableView} from '@react-stately/virtualizer';\nimport {SpectrumCardViewProps} from '@react-types/card';\nimport styles from '@adobe/spectrum-css-temp/components/card/vars.css';\nimport {useCollator, useLocale, useLocalizedStringFormatter} from '@react-aria/i18n';\nimport {useGrid, useGridCell, useGridRow} from '@react-aria/grid';\nimport {useListState} from '@react-stately/list';\nimport {useProvider} from '@react-spectrum/provider';\nimport {Virtualizer, VirtualizerItem} from '@react-aria/virtualizer';\n\nfunction CardView<T extends object>(props: SpectrumCardViewProps<T>, ref: DOMRef<HTMLDivElement>) {\n let {scale} = useProvider();\n let {styleProps} = useStyleProps(props);\n let domRef = useDOMRef(ref);\n let {\n isQuiet,\n renderEmptyState,\n layout,\n loadingState,\n onLoadMore,\n cardOrientation = 'vertical'\n } = props;\n\n let collator = useCollator({usage: 'search', sensitivity: 'base'});\n let isLoading = loadingState === 'loading' || loadingState === 'loadingMore';\n let cardViewLayout = useMemo(() => typeof layout === 'function' ? new layout({collator, cardOrientation, scale}) : layout, [layout, collator, cardOrientation, scale]);\n let layoutType = cardViewLayout.layoutType;\n\n let {direction} = useLocale();\n let {collection} = useListState(props);\n\n let gridCollection = useMemo(() => new GridCollection<T>({\n columnCount: 1,\n items: [...collection].map(item => ({\n // Makes the Grid row use the keys the user provides to the cards so that selection change via interactions returns the card keys\n ...item,\n hasChildNodes: true,\n childNodes: [{\n key: `cell-${item.key}`,\n type: 'cell',\n value: null,\n level: 0,\n rendered: null,\n textValue: item.textValue,\n hasChildNodes: false,\n childNodes: []\n }]\n }))\n }), [collection]);\n\n let state = useGridState({\n ...props,\n selectionMode: cardOrientation === 'horizontal' && layoutType === 'grid' ? 'none' : props.selectionMode,\n collection: gridCollection,\n focusMode: 'cell'\n });\n\n cardViewLayout.collection = gridCollection;\n cardViewLayout.disabledKeys = state.disabledKeys;\n\n let {gridProps} = useGrid({\n ...props,\n isVirtualized: true,\n keyboardDelegate: cardViewLayout\n }, state, domRef);\n\n type View = ReusableView<Node<T>, ReactNode>;\n let renderWrapper = useCallback((parent: View, reusableView: View) => (\n <VirtualizerItem\n key={reusableView.key}\n layoutInfo={reusableView.layoutInfo}\n virtualizer={reusableView.virtualizer}\n parent={parent?.layoutInfo}>\n {reusableView.rendered}\n </VirtualizerItem>\n ), []);\n\n let focusedKey = state.selectionManager.focusedKey;\n let focusedItem = gridCollection.getItem(state.selectionManager.focusedKey);\n if (focusedItem?.parentKey != null) {\n focusedKey = focusedItem.parentKey;\n }\n\n let persistedKeys = useMemo(() => focusedKey != null ? new Set([focusedKey]) : null, [focusedKey]);\n\n // TODO: does aria-row count and aria-col count need to be modified? Perhaps aria-col count needs to be omitted\n return (\n <CardViewContext.Provider value={{state, isQuiet, layout: cardViewLayout, cardOrientation, renderEmptyState}}>\n <Virtualizer\n {...gridProps}\n {...styleProps}\n className={classNames(styles, 'spectrum-CardView')}\n ref={domRef}\n persistedKeys={persistedKeys}\n scrollDirection=\"vertical\"\n layout={cardViewLayout}\n collection={gridCollection}\n isLoading={isLoading}\n onLoadMore={onLoadMore}\n layoutOptions={useMemo(() => ({isLoading, direction}), [isLoading, direction])}\n renderWrapper={renderWrapper}\n style={{\n ...styleProps.style,\n scrollPaddingTop: cardViewLayout.margin || 0\n }}>\n {useCallback((type, item) => {\n if (type === 'item') {\n return (\n <InternalCard item={item} />\n );\n } else if (type === 'loader') {\n return <LoadingState />;\n } else if (type === 'placeholder') {\n return <EmptyState />;\n }\n }, [])}\n </Virtualizer>\n </CardViewContext.Provider>\n\n );\n}\n\nfunction LoadingState() {\n let {state} = useCardViewContext();\n let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-spectrum/card');\n return (\n <CenteredWrapper>\n <ProgressCircle\n isIndeterminate\n aria-label={state.collection.size > 0 ? stringFormatter.format('loadingMore') : stringFormatter.format('loading')} />\n </CenteredWrapper>\n );\n}\n\nfunction EmptyState() {\n let {renderEmptyState} = useCardViewContext();\n let emptyState = renderEmptyState ? renderEmptyState() : null;\n if (emptyState == null) {\n return null;\n }\n\n return (\n <CenteredWrapper>\n {emptyState}\n </CenteredWrapper>\n );\n}\n\nfunction CenteredWrapper({children}) {\n let {state} = useCardViewContext();\n return (\n <div\n role=\"row\"\n aria-rowindex={state.collection.size + 1}\n className={classNames(styles, 'spectrum-CardView-centeredWrapper')}>\n <div role=\"gridcell\">\n {children}\n </div>\n </div>\n );\n}\n\nfunction InternalCard(props) {\n let {\n item\n } = props;\n let cellNode = [...item.childNodes][0];\n let {state, cardOrientation, isQuiet, layout} = useCardViewContext();\n\n let layoutType = layout.layoutType;\n let rowRef = useRef(undefined);\n let cellRef = useRef<DOMRefValue<HTMLDivElement>>(undefined);\n let unwrappedRef = useUnwrapDOMRef(cellRef);\n\n let {rowProps: gridRowProps} = useGridRow({\n node: item,\n isVirtualized: true\n }, state, rowRef);\n\n let {gridCellProps} = useGridCell({\n node: cellNode,\n focusMode: 'cell'\n }, state, unwrappedRef);\n\n // Prevent space key from scrolling the CardView if triggered on a disabled item or on a Card in a selectionMode=\"none\" CardView.\n let allowsInteraction = state.selectionManager.selectionMode !== 'none';\n let isDisabled = !allowsInteraction || state.disabledKeys.has(item.key);\n\n let onKeyDown = (e) => {\n if (e.key === ' ' && isDisabled) {\n e.preventDefault();\n }\n };\n\n let rowProps = mergeProps(\n gridRowProps,\n {onKeyDown}\n );\n\n if (layoutType === 'grid' || layoutType === 'gallery') {\n isQuiet = true;\n }\n\n if (layoutType !== 'grid') {\n cardOrientation = 'vertical';\n }\n\n // We don't want to focus the checkbox (or any other focusable elements) within the Card\n // when pressing the arrow keys so we delete the key down handler here. Arrow key navigation between\n // the cards in the CardView is handled by useGrid => useSelectableCollection instead.\n delete gridCellProps.onKeyDownCapture;\n return (\n <div {...rowProps} ref={rowRef} className={classNames(styles, 'spectrum-CardView-row')}>\n <CardBase\n ref={cellRef}\n articleProps={gridCellProps}\n isQuiet={isQuiet}\n orientation={cardOrientation}\n item={item}\n layout={layoutType}>\n {item.rendered}\n </CardBase>\n </div>\n );\n}\n\n/**\n * TODO: Add description of component here.\n */\nconst _CardView = React.forwardRef(CardView) as <T>(props: SpectrumCardViewProps<T> & {ref?: DOMRef<HTMLDivElement>}) => ReactElement;\nexport {_CardView as CardView};\n"],"names":[],"version":3,"file":"CardView.module.js.map"}
package/dist/types.d.ts CHANGED
@@ -29,7 +29,7 @@ declare class BaseLayout<T> extends Layout<Node<T>, CardViewLayoutOptions> imple
29
29
  scale: Scale;
30
30
  margin: number;
31
31
  constructor(options?: BaseLayoutOptions);
32
- validate(invalidationContext: InvalidationContext<CardViewLayoutOptions>): void;
32
+ update(invalidationContext: InvalidationContext<CardViewLayoutOptions>): void;
33
33
  buildCollection(invalidationContext?: InvalidationContext): void;
34
34
  getContentSize(): Size;
35
35
  getLayoutInfo(key: Key): LayoutInfo;
@@ -1 +1 @@
1
- {"mappings":";;;;;;AAkBA;IACE,QAAQ,CAAC,EAAE,KAAK,QAAQ,CAAC;IAEzB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED;IACE,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,SAAS,CAAA;CACrB;AAED,yBAAwB,CAAC,CAAE,SAAQ,OAAO,KAAK,CAAC,CAAC,EAAE,qBAAqB,CAAE,YAAW,gBAAgB;IACnG,SAAS,CAAC,WAAW,EAAE,IAAI,CAAC;IAC5B,SAAS,CAAC,WAAW,EAAE,GAAG,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IAC5C,SAAS,CAAC,QAAQ,EAAE,KAAK,QAAQ,CAAC;IAClC,SAAS,CAAC,cAAc,EAAE,eAAe,CAAC,CAAC,CAAC;IAC5C,UAAU,EAAG,eAAe,CAAC,CAAC,CAAC;IAC/B,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,GAAG,CAAC,GAAG,CAAC,CAAa;IACnC,SAAS,EAAE,SAAS,CAAC;IACrB,KAAK,EAAE,KAAK,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;gBAEH,OAAO,GAAE,iBAAsB;IAS3C,QAAQ,CAAC,mBAAmB,EAAE,oBAAoB,qBAAqB,CAAC;IA2BxE,eAAe,CAAC,mBAAmB,CAAC,EAAE,mBAAmB;IAEzD,cAAc;IAId,aAAa,CAAC,GAAG,EAAE,GAAG;IAItB,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,oBAAoB,UAAQ;IAY9D,SAAS,CAAC,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI,EAAE,oBAAoB,EAAE,OAAO;IAY3E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ACpB;AAGD,6BAA6B,CAAC,CAAE,SAAQ,WAAW,CAAC,CAAE,YAAW,gBAAgB;IAC/E,SAAS,CAAC,WAAW,EAAE,IAAI,CAAC;IAC5B,SAAS,CAAC,WAAW,EAAE,IAAI,CAAC;IAC5B,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC;IACzB,SAAS,CAAC,UAAU,EAAE,MAAM,CAAC;IAC7B,SAAS,CAAC,UAAU,EAAE,MAAM,CAAC;IAC7B,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC;IAC5B,SAAS,CAAC,iBAAiB,EAAE,MAAM,CAAC;gBAExB,OAAO,GAAE,sBAA2B;IAiBhD,IAAI,UAAU,WAEb;IAED,eAAe,CAAC,mBAAmB,EAAE,mBAAmB;IA6FxD,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI;IAmBnC,kBAAkB,CAAC,aAAa,KAAA;IAWhC,eAAe,CAAC,GAAG,EAAE,GAAG;IAmBxB,cAAc,CAAC,GAAG,EAAE,GAAG;IAevB,aAAa,CAAC,GAAG,EAAE,GAAG;IAMtB,YAAY,CAAC,GAAG,EAAE,GAAG;CAKtB;AGMD;;GAEG;AACH,OAAA,MAAM,UAA0C,CAAC,CAAC,EAAE,KAAK,EAAE,sBAAsB,CAAC,CAAC,GAAG;IAAC,GAAG,CAAC,EAAE,OAAO,cAAc,CAAC,CAAA;CAAC,KAAK,YAAY,CAAC;AC3MtI,OAAA,IAAI,MAAgB,0BAA0B,UAAU,iBAAiB,CAAC,GAAG,gBAAgB,iBAAiB,CAAC,GAAG,cAAc,YAAY,cAAc,CAAC,CAAC,CAAC,CAAC;ACtB9J,YAAY,EAAC,qBAAqB,EAAC,MAAM,mBAAmB,CAAC","sources":["packages/@react-spectrum/card/src/packages/@react-spectrum/card/src/BaseLayout.tsx","packages/@react-spectrum/card/src/packages/@react-spectrum/card/src/GalleryLayout.tsx","packages/@react-spectrum/card/src/packages/@react-spectrum/card/src/GridLayout.tsx","packages/@react-spectrum/card/src/packages/@react-spectrum/card/src/WaterfallLayout.tsx","packages/@react-spectrum/card/src/packages/@react-spectrum/card/src/CardViewContext.tsx","packages/@react-spectrum/card/src/packages/@react-spectrum/card/src/CardBase.tsx","packages/@react-spectrum/card/src/packages/@react-spectrum/card/src/CardView.tsx","packages/@react-spectrum/card/src/packages/@react-spectrum/card/src/Card.tsx","packages/@react-spectrum/card/src/packages/@react-spectrum/card/src/index.ts","packages/@react-spectrum/card/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,"/*\n * Copyright 2021 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\n/// <reference types=\"css-module-types\" />\n\nexport type {GalleryLayoutOptions} from './GalleryLayout';\nexport type {GridLayoutOptions} from './GridLayout';\nexport type {WaterfallLayoutOptions} from './WaterfallLayout';\n\nexport {CardView} from './CardView';\nexport {GalleryLayout} from './GalleryLayout';\nexport {GridLayout} from './GridLayout';\nexport {WaterfallLayout} from './WaterfallLayout';\nexport {Card} from './Card';\nexport type {SpectrumCardViewProps} from '@react-types/card';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
1
+ {"mappings":";;;;;;AAkBA;IACE,QAAQ,CAAC,EAAE,KAAK,QAAQ,CAAC;IAEzB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED;IACE,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,SAAS,CAAA;CACrB;AAED,yBAAwB,CAAC,CAAE,SAAQ,OAAO,KAAK,CAAC,CAAC,EAAE,qBAAq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,CAAC,mBAAmB,EAAE,mBAAmB;IA6FxD,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI;IAmBnC,kBAAkB,CAAC,aAAa,KAAA;IAWhC,eAAe,CAAC,GAAG,EAAE,GAAG;IAmBxB,cAAc,CAAC,GAAG,EAAE,GAAG;IAevB,aAAa,CAAC,GAAG,EAAE,GAAG;IAMtB,YAAY,CAAC,GAAG,EAAE,GAAG;CAKtB;AGQD;;GAEG;AACH,OAAA,MAAM,UAA0C,CAAC,CAAC,EAAE,KAAK,EAAE,sBAAsB,CAAC,CAAC,GAAG;IAAC,GAAG,CAAC,EAAE,OAAO,cAAc,CAAC,CAAA;CAAC,KAAK,YAAY,CAAC;AC7MtI,OAAA,IAAI,MAAgB,0BAA0B,UAAU,iBAAiB,CAAC,GAAG,gBAAgB,iBAAiB,CAAC,GAAG,cAAc,YAAY,cAAc,CAAC,CAAC,CAAC,CAAC;ACtB9J,YAAY,EAAC,qBAAqB,EAAC,MAAM,mBAAmB,CAAC","sources":["packages/@react-spectrum/card/src/packages/@react-spectrum/card/src/BaseLayout.tsx","packages/@react-spectrum/card/src/packages/@react-spectrum/card/src/GalleryLayout.tsx","packages/@react-spectrum/card/src/packages/@react-spectrum/card/src/GridLayout.tsx","packages/@react-spectrum/card/src/packages/@react-spectrum/card/src/WaterfallLayout.tsx","packages/@react-spectrum/card/src/packages/@react-spectrum/card/src/CardViewContext.tsx","packages/@react-spectrum/card/src/packages/@react-spectrum/card/src/CardBase.tsx","packages/@react-spectrum/card/src/packages/@react-spectrum/card/src/CardView.tsx","packages/@react-spectrum/card/src/packages/@react-spectrum/card/src/Card.tsx","packages/@react-spectrum/card/src/packages/@react-spectrum/card/src/index.ts","packages/@react-spectrum/card/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,"/*\n * Copyright 2021 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\n/// <reference types=\"css-module-types\" />\n\nexport type {GalleryLayoutOptions} from './GalleryLayout';\nexport type {GridLayoutOptions} from './GridLayout';\nexport type {WaterfallLayoutOptions} from './WaterfallLayout';\n\nexport {CardView} from './CardView';\nexport {GalleryLayout} from './GalleryLayout';\nexport {GridLayout} from './GridLayout';\nexport {WaterfallLayout} from './WaterfallLayout';\nexport {Card} from './Card';\nexport type {SpectrumCardViewProps} from '@react-types/card';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-spectrum/card",
3
- "version": "3.0.0-nightly.4695+2964e9aaf",
3
+ "version": "3.0.0-nightly.4700+81abb2185",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -36,26 +36,26 @@
36
36
  "url": "https://github.com/adobe/react-spectrum"
37
37
  },
38
38
  "dependencies": {
39
- "@react-aria/focus": "3.0.0-nightly.2983+2964e9aaf",
40
- "@react-aria/grid": "3.9.2-nightly.4695+2964e9aaf",
41
- "@react-aria/i18n": "3.0.0-nightly.2983+2964e9aaf",
42
- "@react-aria/interactions": "3.0.0-nightly.2983+2964e9aaf",
43
- "@react-aria/utils": "3.0.0-nightly.2983+2964e9aaf",
44
- "@react-aria/virtualizer": "3.10.2-nightly.4695+2964e9aaf",
45
- "@react-spectrum/checkbox": "3.0.0-nightly.2983+2964e9aaf",
46
- "@react-spectrum/progress": "3.0.0-nightly.2983+2964e9aaf",
47
- "@react-spectrum/utils": "3.0.0-nightly.2983+2964e9aaf",
48
- "@react-stately/collections": "3.0.0-nightly.2983+2964e9aaf",
49
- "@react-stately/grid": "3.8.8-nightly.4695+2964e9aaf",
50
- "@react-stately/list": "3.10.6-nightly.4695+2964e9aaf",
51
- "@react-stately/virtualizer": "3.7.2-nightly.4695+2964e9aaf",
52
- "@react-types/card": "3.0.0-nightly.4695+2964e9aaf",
53
- "@react-types/provider": "3.8.2-nightly.4695+2964e9aaf",
54
- "@react-types/shared": "3.0.0-nightly.2983+2964e9aaf",
39
+ "@react-aria/focus": "3.0.0-nightly.2988+81abb2185",
40
+ "@react-aria/grid": "3.9.2-nightly.4700+81abb2185",
41
+ "@react-aria/i18n": "3.0.0-nightly.2988+81abb2185",
42
+ "@react-aria/interactions": "3.0.0-nightly.2988+81abb2185",
43
+ "@react-aria/utils": "3.0.0-nightly.2988+81abb2185",
44
+ "@react-aria/virtualizer": "3.10.2-nightly.4700+81abb2185",
45
+ "@react-spectrum/checkbox": "3.0.0-nightly.2988+81abb2185",
46
+ "@react-spectrum/progress": "3.0.0-nightly.2988+81abb2185",
47
+ "@react-spectrum/utils": "3.0.0-nightly.2988+81abb2185",
48
+ "@react-stately/collections": "3.0.0-nightly.2988+81abb2185",
49
+ "@react-stately/grid": "3.8.8-nightly.4700+81abb2185",
50
+ "@react-stately/list": "3.10.6-nightly.4700+81abb2185",
51
+ "@react-stately/virtualizer": "3.7.2-nightly.4700+81abb2185",
52
+ "@react-types/card": "3.0.0-nightly.4700+81abb2185",
53
+ "@react-types/provider": "3.8.2-nightly.4700+81abb2185",
54
+ "@react-types/shared": "3.0.0-nightly.2988+81abb2185",
55
55
  "@swc/helpers": "^0.5.0"
56
56
  },
57
57
  "devDependencies": {
58
- "@adobe/spectrum-css-temp": "3.0.0-nightly.2983+2964e9aaf"
58
+ "@adobe/spectrum-css-temp": "3.0.0-nightly.2988+81abb2185"
59
59
  },
60
60
  "peerDependencies": {
61
61
  "@react-spectrum/provider": "^3.0.0",
@@ -65,5 +65,5 @@
65
65
  "publishConfig": {
66
66
  "access": "public"
67
67
  },
68
- "gitHead": "2964e9aafc281888cd65da5bd77512e7f999bd84"
68
+ "gitHead": "81abb2185cb3a9c52a8feaf76a136c64852aea13"
69
69
  }
@@ -53,7 +53,7 @@ export class BaseLayout<T> extends Layout<Node<T>, CardViewLayoutOptions> implem
53
53
  this.margin = options.margin || 24;
54
54
  }
55
55
 
56
- validate(invalidationContext: InvalidationContext<CardViewLayoutOptions>) {
56
+ update(invalidationContext: InvalidationContext<CardViewLayoutOptions>) {
57
57
  this.collection = this.virtualizer.collection as GridCollection<T>;
58
58
  this.isLoading = invalidationContext.layoutOptions?.isLoading || false;
59
59
  this.direction = invalidationContext.layoutOptions?.direction || 'ltr';
package/src/CardView.tsx CHANGED
@@ -102,6 +102,8 @@ function CardView<T extends object>(props: SpectrumCardViewProps<T>, ref: DOMRef
102
102
  focusedKey = focusedItem.parentKey;
103
103
  }
104
104
 
105
+ let persistedKeys = useMemo(() => focusedKey != null ? new Set([focusedKey]) : null, [focusedKey]);
106
+
105
107
  // TODO: does aria-row count and aria-col count need to be modified? Perhaps aria-col count needs to be omitted
106
108
  return (
107
109
  <CardViewContext.Provider value={{state, isQuiet, layout: cardViewLayout, cardOrientation, renderEmptyState}}>
@@ -110,7 +112,7 @@ function CardView<T extends object>(props: SpectrumCardViewProps<T>, ref: DOMRef
110
112
  {...styleProps}
111
113
  className={classNames(styles, 'spectrum-CardView')}
112
114
  ref={domRef}
113
- focusedKey={focusedKey}
115
+ persistedKeys={persistedKeys}
114
116
  scrollDirection="vertical"
115
117
  layout={cardViewLayout}
116
118
  collection={gridCollection}