@react-spectrum/card 3.0.0-alpha.41 → 3.0.0-alpha.42
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/BaseLayout.main.js.map +1 -1
- package/dist/BaseLayout.module.js.map +1 -1
- package/dist/CardBase.main.js +1 -1
- package/dist/CardBase.mjs +1 -1
- package/dist/CardBase.module.js +1 -1
- package/dist/CardView.main.js +1 -1
- package/dist/CardView.mjs +1 -1
- package/dist/CardView.module.js +1 -1
- package/dist/CardViewContext.main.js.map +1 -1
- package/dist/CardViewContext.module.js.map +1 -1
- package/dist/GalleryLayout.main.js.map +1 -1
- package/dist/GalleryLayout.module.js.map +1 -1
- package/dist/GridLayout.main.js.map +1 -1
- package/dist/GridLayout.module.js.map +1 -1
- package/dist/WaterfallLayout.main.js.map +1 -1
- package/dist/WaterfallLayout.module.js.map +1 -1
- package/dist/{vars.02438011.css → card.370c5606.css} +1 -1
- package/dist/{vars.02438011.css.map → card.370c5606.css.map} +1 -1
- package/dist/types.d.ts +22 -22
- package/dist/types.d.ts.map +1 -1
- package/package.json +18 -18
- package/src/BaseLayout.tsx +17 -17
- package/src/CardViewContext.tsx +9 -2
- package/src/GalleryLayout.tsx +3 -3
- package/src/GridLayout.tsx +5 -5
- package/src/WaterfallLayout.tsx +8 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;AAAA,cAAc;AACd;;;;;;;;;;CAUC;;;AA4CD,MAAM,wCAAkB;IACtB,GAAG;QACD,aAAa;QACb,aAAa;YACX,YAAY,IAAI,CAAA,GAAA,WAAG,EAAE,IAAI;QAC3B;QACA,aAAa,IAAI,CAAA,GAAA,WAAG,EAAE,UAAU;QAChC,QAAQ;QACR,UAAU,IAAI,CAAA,GAAA,WAAG,EAAE,GAAG;QACtB,YAAY;QACZ,aAAa;IACf;IACA,GAAG;QACD,aAAa;YACX,YAAY;gBACV,UAAU;gBACV,SAAS;YACX;YACA,cAAc;gBACZ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/GridLayout.tsx"],"sourcesContent":["// @ts-nocheck\n/*\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 {BaseLayout, BaseLayoutOptions} from './BaseLayout';\nimport {getChildNodes, getFirstItem} from '@react-stately/collections';\nimport {Key, Node, Orientation} from '@react-types/shared';\nimport {LayoutInfo, Rect, Size} from '@react-stately/virtualizer';\n\nexport interface GridLayoutOptions extends BaseLayoutOptions {\n // /**\n // * The card size in the grid.\n // */\n // cardSize?: 'S' | 'M' | 'L',\n /**\n * The minimum item size.\n * @default 208 x 208 for horizontal card orientation. 102 x 102 for vertical card orientation.\n */\n minItemSize?: Size,\n /**\n * The maximum item size.\n * @default Infinity\n */\n maxItemSize?: Size,\n /**\n * The minimum space required between items.\n * @default 18 x 18\n */\n minSpace?: Size,\n /**\n * The maximum number of columns.\n * @default Infinity\n */\n maxColumns?: number,\n /**\n * The additional padding along the card's main axis. Affects the sizing of the content area following the card image.\n * @default 95\n */\n itemPadding?: number,\n /**\n * The orientation of the cards withn the grid.\n * @default vertical\n */\n cardOrientation?: Orientation\n}\n\nconst DEFAULT_OPTIONS = {\n S: {\n itemPadding: 20,\n minItemSize: {\n 'vertical': new Size(96, 96)\n },\n maxItemSize: new Size(Infinity, Infinity),\n margin: 8,\n minSpace: new Size(6, 6),\n maxColumns: Infinity,\n dropSpacing: 50\n },\n L: {\n itemPadding: {\n 'vertical': {\n 'medium': 78,\n 'large': 98\n },\n 'horizontal': {\n 'medium': 150,\n 'large': 170\n }\n },\n minItemSize: {\n 'vertical': new Size(208, 208),\n 'horizontal': new Size(102, 102)\n },\n maxItemSize: new Size(Infinity, Infinity),\n margin: 24,\n minSpace: new Size(18, 18),\n maxColumns: Infinity,\n dropSpacing: 100\n }\n};\n\nexport class GridLayout<T> extends BaseLayout<T> {\n protected minItemSize: Size;\n protected maxItemSize: Size;\n protected minSpace: Size;\n protected maxColumns: number;\n itemPadding: number;\n cardOrientation: Orientation;\n protected itemSize: Size;\n protected numColumns: number;\n protected numRows: number;\n protected horizontalSpacing: number;\n\n constructor(options: GridLayoutOptions = {}) {\n super(options);\n let cardSize = 'L';\n this.cardOrientation = options.cardOrientation || 'vertical';\n this.minItemSize = options.minItemSize || DEFAULT_OPTIONS[cardSize].minItemSize[this.cardOrientation];\n this.maxItemSize = options.maxItemSize || DEFAULT_OPTIONS[cardSize].maxItemSize;\n this.margin = options.margin != null ? options.margin : DEFAULT_OPTIONS[cardSize].margin;\n this.minSpace = options.minSpace || DEFAULT_OPTIONS[cardSize].minSpace;\n this.maxColumns = options.maxColumns || DEFAULT_OPTIONS[cardSize].maxColumns;\n this.itemPadding = options.itemPadding != null ? options.itemPadding : DEFAULT_OPTIONS[cardSize].itemPadding[this.cardOrientation][this.scale];\n this.itemSize = null;\n this.numColumns = 0;\n this.numRows = 0;\n this.horizontalSpacing = 0;\n }\n\n get layoutType() {\n return 'grid';\n }\n\n getIndexAtPoint(x, y, allowInsertingAtEnd = false) {\n let itemHeight = this.itemSize.height + this.minSpace.height;\n let itemWidth = this.itemSize.width + this.horizontalSpacing;\n return Math.max(0,\n Math.min(\n this.collection.size - (allowInsertingAtEnd ? 0 : 1),\n Math.floor(y / itemHeight) * this.numColumns + Math.floor((x - this.horizontalSpacing) / itemWidth)\n )\n );\n }\n\n buildCollection() {\n let visibleWidth = this.virtualizer.visibleRect.width;\n let visibleHeight = this.virtualizer.visibleRect.height;\n let horizontalItemPadding = this.cardOrientation === 'horizontal' ? this.itemPadding : 0;\n let verticalItemPadding = this.cardOrientation === 'vertical' ? this.itemPadding : 0;\n let minCardWidth = this.minItemSize.width + horizontalItemPadding;\n\n // Compute the number of rows and columns needed to display the content\n let availableWidth = visibleWidth - this.margin * 2;\n let columns = Math.floor((availableWidth + this.minSpace.width) / (minCardWidth + this.minSpace.width));\n this.numColumns = Math.max(1, Math.min(this.maxColumns, columns));\n this.numRows = Math.ceil(this.collection.size / this.numColumns);\n\n // Compute the available width (minus the space between items)\n let width = availableWidth - (this.minSpace.width * Math.max(0, this.numColumns - 1));\n\n // Compute the item width based on the space available\n let itemWidth = Math.floor(width / this.numColumns);\n itemWidth = Math.max(minCardWidth, Math.min(this.maxItemSize.width, itemWidth));\n // Compute the item height, which is proportional to the item width\n let t = ((itemWidth - minCardWidth) / minCardWidth);\n let itemHeight = Math.floor(this.minItemSize.height + this.minItemSize.height * t);\n itemHeight = Math.max(this.minItemSize.height, Math.min(this.maxItemSize.height, itemHeight)) + verticalItemPadding;\n this.itemSize = new Size(itemWidth, itemHeight);\n\n // Compute the horizontal spacing and content height\n this.horizontalSpacing = this.numColumns < 2 ? 0 : Math.floor((availableWidth - this.numColumns * this.itemSize.width) / (this.numColumns - 1));\n\n let y = this.margin;\n let index = 0;\n for (let node of this.collection) {\n let layoutInfo = this.buildChild(node, y, index);\n y = layoutInfo.rect.maxY;\n index++;\n }\n\n if (this.isLoading) {\n let loaderY = y;\n let loaderHeight = 60;\n // If there aren't any items, make loader take all avaliable room and remove margin from y calculation\n // so it doesn't scroll\n if (this.collection.size === 0) {\n loaderY = 0;\n loaderHeight = visibleHeight || 60;\n }\n\n let rect = new Rect(0, loaderY, visibleWidth, loaderHeight);\n let loader = new LayoutInfo('loader', 'loader', rect);\n this.layoutInfos.set('loader', loader);\n y = loader.rect.maxY;\n }\n\n if (this.collection.size === 0 && !this.isLoading) {\n let rect = new Rect(0, 0, visibleWidth, visibleHeight);\n let placeholder = new LayoutInfo('placeholder', 'placeholder', rect);\n this.layoutInfos.set('placeholder', placeholder);\n y = placeholder.rect.maxY;\n }\n\n this.contentSize = new Size(visibleWidth, y);\n }\n\n buildChild(node: Node<T>, y: number, index: number): LayoutInfo {\n let row = Math.floor(index / this.numColumns);\n let column = index % this.numColumns;\n let x = this.margin + column * (this.itemSize.width + this.horizontalSpacing);\n y = this.margin + row * (this.itemSize.height + this.minSpace.height);\n\n let rect = new Rect(x, y, this.itemSize.width, this.itemSize.height);\n // TODO: Perhaps have it so that the child key for each row is stored with the layoutInfo?\n let layoutInfo = new LayoutInfo(node.type, node.key, rect);\n layoutInfo.allowOverflow = true;\n this.layoutInfos.set(node.key, layoutInfo);\n return layoutInfo;\n }\n\n // Since the collection doesn't represent the visual layout, need to calculate what row and column the current key is in,\n // then return the key that occupies the row + column below. This can be done by figuring out how many cards exist per column then dividing the\n // collection contents by that number (which will give us the row distribution)\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 indexRowBelow;\n let index = this.collection.rows.findIndex(card => card.key === parentRowKey);\n if (index !== -1) {\n indexRowBelow = index + this.numColumns;\n } else {\n return null;\n }\n\n let row = this.collection.rows[indexRowBelow];\n return row ? getFirstItem(getChildNodes(row, this.collection))?.key : null;\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 indexRowAbove;\n let index = this.collection.rows.findIndex(card => card.key === parentRowKey);\n if (index !== -1) {\n indexRowAbove = index - this.numColumns;\n } else {\n return null;\n }\n\n let row = this.collection.rows[indexRowAbove];\n return row ? getFirstItem(getChildNodes(row, this.collection))?.key : null;\n }\n}\n"],"names":[],"version":3,"file":"GridLayout.module.js.map"}
|
|
1
|
+
{"mappings":";;;;AAAA,cAAc;AACd;;;;;;;;;;CAUC;;;AA4CD,MAAM,wCAAkB;IACtB,GAAG;QACD,aAAa;QACb,aAAa;YACX,YAAY,IAAI,CAAA,GAAA,WAAG,EAAE,IAAI;QAC3B;QACA,aAAa,IAAI,CAAA,GAAA,WAAG,EAAE,UAAU;QAChC,QAAQ;QACR,UAAU,I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I,CAAC,QAAQ,GAAG;QAChB,IAAI,CAAC,UAAU,GAAG;QAClB,IAAI,CAAC,OAAO,GAAG;QACf,IAAI,CAAC,iBAAiB,GAAG;IAC3B;AA6HF","sources":["packages/@react-spectrum/card/src/GridLayout.tsx"],"sourcesContent":["// @ts-nocheck\n/*\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 {BaseLayout, BaseLayoutOptions} from './BaseLayout';\nimport {getChildNodes, getFirstItem} from '@react-stately/collections';\nimport {Key, Node, Orientation} from '@react-types/shared';\nimport {LayoutInfo, Rect, Size} from '@react-stately/virtualizer';\n\nexport interface GridLayoutOptions extends BaseLayoutOptions {\n // /**\n // * The card size in the grid.\n // */\n // cardSize?: 'S' | 'M' | 'L',\n /**\n * The minimum item size.\n * @default 208 x 208 for horizontal card orientation. 102 x 102 for vertical card orientation.\n */\n minItemSize?: Size,\n /**\n * The maximum item size.\n * @default Infinity\n */\n maxItemSize?: Size,\n /**\n * The minimum space required between items.\n * @default 18 x 18\n */\n minSpace?: Size,\n /**\n * The maximum number of columns.\n * @default Infinity\n */\n maxColumns?: number,\n /**\n * The additional padding along the card's main axis. Affects the sizing of the content area following the card image.\n * @default 95\n */\n itemPadding?: number,\n /**\n * The orientation of the cards withn the grid.\n * @default vertical\n */\n cardOrientation?: Orientation\n}\n\nconst DEFAULT_OPTIONS = {\n S: {\n itemPadding: 20,\n minItemSize: {\n 'vertical': new Size(96, 96)\n },\n maxItemSize: new Size(Infinity, Infinity),\n margin: 8,\n minSpace: new Size(6, 6),\n maxColumns: Infinity,\n dropSpacing: 50\n },\n L: {\n itemPadding: {\n 'vertical': {\n 'medium': 78,\n 'large': 98\n },\n 'horizontal': {\n 'medium': 150,\n 'large': 170\n }\n },\n minItemSize: {\n 'vertical': new Size(208, 208),\n 'horizontal': new Size(102, 102)\n },\n maxItemSize: new Size(Infinity, Infinity),\n margin: 24,\n minSpace: new Size(18, 18),\n maxColumns: Infinity,\n dropSpacing: 100\n }\n};\n\nexport class GridLayout<T> extends BaseLayout<T> {\n protected minItemSize: Size;\n protected maxItemSize: Size;\n protected minSpace: Size;\n protected maxColumns: number;\n itemPadding: number;\n cardOrientation: Orientation;\n protected itemSize: Size;\n protected numColumns: number;\n protected numRows: number;\n protected horizontalSpacing: number;\n\n constructor(options: GridLayoutOptions = {}) {\n super(options);\n let cardSize = 'L';\n this.cardOrientation = options.cardOrientation || 'vertical';\n this.minItemSize = options.minItemSize || DEFAULT_OPTIONS[cardSize].minItemSize[this.cardOrientation];\n this.maxItemSize = options.maxItemSize || DEFAULT_OPTIONS[cardSize].maxItemSize;\n this.margin = options.margin != null ? options.margin : DEFAULT_OPTIONS[cardSize].margin;\n this.minSpace = options.minSpace || DEFAULT_OPTIONS[cardSize].minSpace;\n this.maxColumns = options.maxColumns || DEFAULT_OPTIONS[cardSize].maxColumns;\n this.itemPadding = options.itemPadding != null ? options.itemPadding : DEFAULT_OPTIONS[cardSize].itemPadding[this.cardOrientation][this.scale];\n this.itemSize = null;\n this.numColumns = 0;\n this.numRows = 0;\n this.horizontalSpacing = 0;\n }\n\n get layoutType(): string {\n return 'grid';\n }\n\n getIndexAtPoint(x: number, y: number, allowInsertingAtEnd = false): number {\n let itemHeight = this.itemSize.height + this.minSpace.height;\n let itemWidth = this.itemSize.width + this.horizontalSpacing;\n return Math.max(0,\n Math.min(\n this.collection.size - (allowInsertingAtEnd ? 0 : 1),\n Math.floor(y / itemHeight) * this.numColumns + Math.floor((x - this.horizontalSpacing) / itemWidth)\n )\n );\n }\n\n buildCollection(): void {\n let visibleWidth = this.virtualizer.visibleRect.width;\n let visibleHeight = this.virtualizer.visibleRect.height;\n let horizontalItemPadding = this.cardOrientation === 'horizontal' ? this.itemPadding : 0;\n let verticalItemPadding = this.cardOrientation === 'vertical' ? this.itemPadding : 0;\n let minCardWidth = this.minItemSize.width + horizontalItemPadding;\n\n // Compute the number of rows and columns needed to display the content\n let availableWidth = visibleWidth - this.margin * 2;\n let columns = Math.floor((availableWidth + this.minSpace.width) / (minCardWidth + this.minSpace.width));\n this.numColumns = Math.max(1, Math.min(this.maxColumns, columns));\n this.numRows = Math.ceil(this.collection.size / this.numColumns);\n\n // Compute the available width (minus the space between items)\n let width = availableWidth - (this.minSpace.width * Math.max(0, this.numColumns - 1));\n\n // Compute the item width based on the space available\n let itemWidth = Math.floor(width / this.numColumns);\n itemWidth = Math.max(minCardWidth, Math.min(this.maxItemSize.width, itemWidth));\n // Compute the item height, which is proportional to the item width\n let t = ((itemWidth - minCardWidth) / minCardWidth);\n let itemHeight = Math.floor(this.minItemSize.height + this.minItemSize.height * t);\n itemHeight = Math.max(this.minItemSize.height, Math.min(this.maxItemSize.height, itemHeight)) + verticalItemPadding;\n this.itemSize = new Size(itemWidth, itemHeight);\n\n // Compute the horizontal spacing and content height\n this.horizontalSpacing = this.numColumns < 2 ? 0 : Math.floor((availableWidth - this.numColumns * this.itemSize.width) / (this.numColumns - 1));\n\n let y = this.margin;\n let index = 0;\n for (let node of this.collection) {\n let layoutInfo = this.buildChild(node, y, index);\n y = layoutInfo.rect.maxY;\n index++;\n }\n\n if (this.isLoading) {\n let loaderY = y;\n let loaderHeight = 60;\n // If there aren't any items, make loader take all avaliable room and remove margin from y calculation\n // so it doesn't scroll\n if (this.collection.size === 0) {\n loaderY = 0;\n loaderHeight = visibleHeight || 60;\n }\n\n let rect = new Rect(0, loaderY, visibleWidth, loaderHeight);\n let loader = new LayoutInfo('loader', 'loader', rect);\n this.layoutInfos.set('loader', loader);\n y = loader.rect.maxY;\n }\n\n if (this.collection.size === 0 && !this.isLoading) {\n let rect = new Rect(0, 0, visibleWidth, visibleHeight);\n let placeholder = new LayoutInfo('placeholder', 'placeholder', rect);\n this.layoutInfos.set('placeholder', placeholder);\n y = placeholder.rect.maxY;\n }\n\n this.contentSize = new Size(visibleWidth, y);\n }\n\n buildChild(node: Node<T>, y: number, index: number): LayoutInfo {\n let row = Math.floor(index / this.numColumns);\n let column = index % this.numColumns;\n let x = this.margin + column * (this.itemSize.width + this.horizontalSpacing);\n y = this.margin + row * (this.itemSize.height + this.minSpace.height);\n\n let rect = new Rect(x, y, this.itemSize.width, this.itemSize.height);\n // TODO: Perhaps have it so that the child key for each row is stored with the layoutInfo?\n let layoutInfo = new LayoutInfo(node.type, node.key, rect);\n layoutInfo.allowOverflow = true;\n this.layoutInfos.set(node.key, layoutInfo);\n return layoutInfo;\n }\n\n // Since the collection doesn't represent the visual layout, need to calculate what row and column the current key is in,\n // then return the key that occupies the row + column below. This can be done by figuring out how many cards exist per column then dividing the\n // collection contents by that number (which will give us the row distribution)\n getKeyBelow(key: Key): Node<T> | undefined | null {\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 indexRowBelow;\n let index = this.collection.rows.findIndex(card => card.key === parentRowKey);\n if (index !== -1) {\n indexRowBelow = index + this.numColumns;\n } else {\n return null;\n }\n\n let row = this.collection.rows[indexRowBelow];\n return row ? getFirstItem(getChildNodes(row, this.collection))?.key : null;\n }\n\n getKeyAbove(key: Key): Node<T> | undefined | null {\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 indexRowAbove;\n let index = this.collection.rows.findIndex(card => card.key === parentRowKey);\n if (index !== -1) {\n indexRowAbove = index - this.numColumns;\n } else {\n return null;\n }\n\n let row = this.collection.rows[indexRowAbove];\n return row ? getFirstItem(getChildNodes(row, this.collection))?.key : null;\n }\n}\n"],"names":[],"version":3,"file":"GridLayout.module.js.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;;;;;AA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BAAhD,oCAAA,cAAoD,GAAG;IAChE;IAEA,cAAc,GAAQ,EAAE;QACtB,2EAA2E;QAC3E,IAAI,eAAe,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,SAAS;QACzD,OAAO,IAAI,CAAC,SAAS,KAAK,QAAS,IAAI,CAAC,cAAc,CAAC,gBAAgB,IAAI,CAAC,eAAe,CAAC;IAC9F;IAEA,aAAa,GAAQ,EAAE;QACrB,2EAA2E;QAC3E,IAAI,eAAe,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,KAAK,SAAS;QACzD,OAAO,IAAI,CAAC,SAAS,KAAK,QAAS,IAAI,CAAC,eAAe,CAAC,gBAAgB,IAAI,CAAC,cAAc,CAAC;IAC9F;IA5LA,YAAY,UAAkC,CAAC,CAAC,CAAE;QAChD,+GAA+G;QAC/G,uCAAuC;QACvC,KAAK,CAAC;QACN,IAAI,CAAC,WAAW,GAAG,QAAQ,WAAW,IAAI,IAAI,CAAA,GAAA,mCAAG,EAAE,KAAK;QACxD,IAAI,CAAC,WAAW,GAAG,QAAQ,WAAW,IAAI,IAAI,CAAA,GAAA,mCAAG,EAAE,UAAU;QAC7D,IAAI,CAAC,MAAM,GAAG,QAAQ,MAAM,IAAI,OAAO,QAAQ,MAAM,GAAG;QACxD,IAAI,CAAC,QAAQ,GAAG,QAAQ,QAAQ,IAAI,IAAI,CAAA,GAAA,mCAAG,EAAE,IAAI;QACjD,IAAI,CAAC,UAAU,GAAG,QAAQ,UAAU,IAAI;QAExC,IAAI,CAAC,SAAS,GAAG;QACjB,IAAI,CAAC,UAAU,GAAG;QAElB,IAAI,CAAC,cAAc,GAAG;QACtB,IAAI,CAAC,QAAQ,GAAG,QAAQ,QAAQ;IAClC;AA8KF","sources":["packages/@react-spectrum/card/src/WaterfallLayout.tsx"],"sourcesContent":["// @ts-nocheck\n/*\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 {BaseLayout, BaseLayoutOptions} from './BaseLayout';\nimport {getChildNodes, getFirstItem} from '@react-stately/collections';\nimport {InvalidationContext, LayoutInfo, Rect, Size} from '@react-stately/virtualizer';\nimport {Key, KeyboardDelegate} from '@react-types/shared';\n\nexport interface WaterfallLayoutOptions extends BaseLayoutOptions {\n /**\n * The minimum item size.\n * @default 240 x 136\n */\n minItemSize?: Size,\n /**\n * The maximum item size.\n * @default Infinity\n */\n maxItemSize?: Size,\n /**\n * The minimum space required between items.\n * @default 18 x 18\n */\n minSpace?: Size,\n /**\n * The maximum number of columns.\n * @default Infinity\n */\n maxColumns?: number\n}\n\n// TODO: this didn't have any options that varied with card size, should it have?\nexport class WaterfallLayout<T> extends BaseLayout<T> implements KeyboardDelegate {\n protected minItemSize: Size;\n protected maxItemSize: Size;\n protected minSpace: Size;\n protected maxColumns: number;\n protected numColumns: number;\n protected itemWidth: number;\n protected horizontalSpacing: number;\n\n constructor(options: WaterfallLayoutOptions = {}) {\n // TODO: WaterfallLayout doesn't use card size in v2, but perhaps it should support it? Perhaps it would modify\n // minItemSize defaults or other things\n super(options);\n this.minItemSize = options.minItemSize || new Size(240, 136);\n this.maxItemSize = options.maxItemSize || new Size(Infinity, Infinity);\n this.margin = options.margin != null ? options.margin : 24;\n this.minSpace = options.minSpace || new Size(18, 18);\n this.maxColumns = options.maxColumns || Infinity;\n\n this.itemWidth = 0;\n this.numColumns = 0;\n\n this.lastCollection = null;\n this.collator = options.collator;\n }\n\n get layoutType() {\n return 'waterfall';\n }\n\n buildCollection(invalidationContext: InvalidationContext) {\n // Compute the number of columns needed to display the content\n let visibleWidth = this.virtualizer.visibleRect.width;\n let availableWidth = visibleWidth - this.margin * 2;\n let columns = Math.floor((availableWidth + this.minSpace.width) / (this.minItemSize.width + this.minSpace.width));\n this.numColumns = Math.max(1, Math.min(this.maxColumns, columns));\n\n\n // Compute the available width (minus the space between items)\n let width = availableWidth - (this.minSpace.width * (this.numColumns - 1));\n\n // Compute the item width based on the space available\n let itemWidth = Math.round(width / this.numColumns);\n itemWidth = Math.max(this.minItemSize.width, Math.min(this.maxItemSize.width, itemWidth));\n this.itemWidth = itemWidth;\n\n // Compute the horizontal spacing\n // if only one column, we cannot divide by zero, so set it to 1\n let horizontalSpacing = Math.round((availableWidth - this.numColumns * itemWidth) / Math.max(1, this.numColumns - 1));\n this.horizontalSpacing = horizontalSpacing;\n\n // Setup an array of column heights\n let columnHeights = Array(this.numColumns).fill(this.margin);\n for (let node of this.collection) {\n let key = node.key;\n // Compute the height of the item. Use the existing height if available,\n // otherwise call the delegate to estimate the size.\n let oldLayoutInfo = this.layoutInfos.get(key);\n let height;\n let estimatedSize = true;\n if (oldLayoutInfo) {\n height = oldLayoutInfo.rect.height;\n estimatedSize = invalidationContext.sizeChanged || oldLayoutInfo.estimatedSize;\n } else if (node.props.width && node.props.height) {\n let nodeWidth = node.props.width;\n let nodeHeight = node.props.height;\n let scaledHeight = Math.round(nodeHeight * ((itemWidth) / nodeWidth));\n height = Math.max(this.minItemSize.height, Math.min(this.maxItemSize.height, scaledHeight));\n } else {\n height = itemWidth;\n }\n\n // Figure out which column to place the item in, and compute its position.\n let column = this.getNextColumnIndex(columnHeights);\n let x = this.margin + column * (itemWidth + horizontalSpacing);\n let y = columnHeights[column];\n\n let rect = new Rect(x, y, itemWidth, height);\n let layoutInfo = new LayoutInfo(node.type, key, rect);\n layoutInfo.estimatedSize = estimatedSize;\n layoutInfo.allowOverflow = true;\n this.layoutInfos.set(key, layoutInfo);\n\n // TODO: From v2 figure out this bit, when does this get called and what to replace this.collectionView._transaction with?\n // Removing it from v2 doesn't seem to do anything?\n // if (layoutInfo.estimatedSize && !invalidationContext.contentChanged && !this.collectionView._transaction) {\n // this.updateItemSize(new IndexPath(section, i));\n // }\n\n columnHeights[column] += layoutInfo.rect.height + this.minSpace.height;\n }\n\n // Reset all columns to the maximum for the next section\n let maxHeight = Math.max.apply(Math, columnHeights) - this.minSpace.height + this.margin;\n columnHeights.fill(maxHeight);\n let y = columnHeights[0];\n\n if (this.isLoading) {\n let loaderY = y;\n let loaderHeight = 60;\n // If there aren't any items, make loader take all avaliable room and remove margin from y calculation\n // so it doesn't scroll\n if (this.collection.size === 0) {\n loaderY = 0;\n loaderHeight = this.virtualizer.visibleRect.height || 60;\n }\n\n let rect = new Rect(0, loaderY, this.virtualizer.visibleRect.width, loaderHeight);\n let loader = new LayoutInfo('loader', 'loader', rect);\n this.layoutInfos.set('loader', loader);\n y = loader.rect.maxY;\n }\n\n if (this.collection.size === 0 && !this.isLoading) {\n let rect = new Rect(0, 0, this.virtualizer.visibleRect.width, this.virtualizer.visibleRect.height);\n let placeholder = new LayoutInfo('placeholder', 'placeholder', rect);\n this.layoutInfos.set('placeholder', placeholder);\n y = placeholder.rect.maxY;\n }\n\n this.contentSize = new Size(this.virtualizer.visibleRect.width, y);\n }\n\n updateItemSize(key: Key, size: Size) {\n let layoutInfo = this.layoutInfos.get(key);\n if (!size || !layoutInfo) {\n return false;\n }\n\n if (size.height !== layoutInfo.rect.height) {\n // TODO: also not sure about copying layout info vs mutating it. Listlayout does the below\n // but I feel that is because it actually maintained a layoutNode map cache which this doesn't have\n let newLayoutInfo = layoutInfo.copy();\n newLayoutInfo.rect.height = size.height < 600 ? size.height : 600;\n newLayoutInfo.estimatedSize = false;\n this.layoutInfos.set(key, newLayoutInfo);\n return true;\n }\n\n return false;\n }\n\n getNextColumnIndex(columnHeights) {\n let minIndex = 0;\n for (let i = 0; i < columnHeights.length; i++) {\n if (columnHeights[i] < columnHeights[minIndex]) {\n minIndex = i;\n }\n }\n\n return minIndex;\n }\n\n getClosestRight(key: Key) {\n let layoutInfo = this.getLayoutInfo(key);\n // Refactored from v2. Current strategy is to find the closest card in the adjacent column.\n // This prevent the issue where it was possible that the closest layoutInfo would be two columns over due to the middle card being exceptionally tall\n // and thus the top corner to top corner distance was massive.\n\n // First look for a card to the immediate right of the current card. If we can't find any, look for the nearest card in the entire column to the right of the card\n let rect = new Rect(layoutInfo.rect.maxX + 1, layoutInfo.rect.y, layoutInfo.rect.width + this.horizontalSpacing, layoutInfo.rect.height);\n key = this._findClosest(layoutInfo.rect, rect)?.key;\n\n if (!key) {\n rect = new Rect(layoutInfo.rect.maxX + 1, 0, layoutInfo.rect.width + this.horizontalSpacing, this.virtualizer.contentSize.height);\n key = this._findClosest(layoutInfo.rect, rect)?.key;\n }\n\n let item = this.collection.getItem(key);\n return getFirstItem(getChildNodes(item, this.collection))?.key;\n }\n\n getClosestLeft(key: Key) {\n let layoutInfo = this.getLayoutInfo(key);\n // First look for a card to the immediate left of the current card. If we can't find any, look for the nearest card in the entire column to the left of the card\n let rect = new Rect(layoutInfo.rect.x - layoutInfo.rect.width - this.horizontalSpacing - 1, layoutInfo.rect.y, layoutInfo.rect.width + this.horizontalSpacing, layoutInfo.rect.height);\n key = this._findClosest(layoutInfo.rect, rect)?.key;\n\n if (!key) {\n rect = new Rect(layoutInfo.rect.x - layoutInfo.rect.width - this.horizontalSpacing - 1, 0, layoutInfo.rect.width + this.horizontalSpacing, this.virtualizer.contentSize.height);\n key = this._findClosest(layoutInfo.rect, rect)?.key;\n }\n\n let item = this.collection.getItem(key);\n return getFirstItem(getChildNodes(item, 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 return this.direction === 'rtl' ? this.getClosestLeft(parentRowKey) : this.getClosestRight(parentRowKey);\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 return this.direction === 'rtl' ? this.getClosestRight(parentRowKey) : this.getClos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"sourcesContent":["// @ts-nocheck\n/*\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 {BaseLayout, BaseLayoutOptions} from './BaseLayout';\nimport {getChildNodes, getFirstItem} from '@react-stately/collections';\nimport {InvalidationContext, LayoutInfo, Rect, Size} from '@react-stately/virtualizer';\nimport {Key, KeyboardDelegate} from '@react-types/shared';\n\nexport interface WaterfallLayoutOptions extends BaseLayoutOptions {\n /**\n * The minimum item size.\n * @default 240 x 136\n */\n minItemSize?: Size,\n /**\n * The maximum item size.\n * @default Infinity\n */\n maxItemSize?: Size,\n /**\n * The minimum space required between items.\n * @default 18 x 18\n */\n minSpace?: Size,\n /**\n * The maximum number of columns.\n * @default Infinity\n */\n maxColumns?: number\n}\n\n// TODO: this didn't have any options that varied with card size, should it have?\nexport class WaterfallLayout<T> extends BaseLayout<T> implements KeyboardDelegate {\n protected minItemSize: Size;\n protected maxItemSize: Size;\n protected minSpace: Size;\n protected maxColumns: number;\n protected numColumns: number;\n protected itemWidth: number;\n protected horizontalSpacing: number;\n\n constructor(options: WaterfallLayoutOptions = {}) {\n // TODO: WaterfallLayout doesn't use card size in v2, but perhaps it should support it? Perhaps it would modify\n // minItemSize defaults or other things\n super(options);\n this.minItemSize = options.minItemSize || new Size(240, 136);\n this.maxItemSize = options.maxItemSize || new Size(Infinity, Infinity);\n this.margin = options.margin != null ? options.margin : 24;\n this.minSpace = options.minSpace || new Size(18, 18);\n this.maxColumns = options.maxColumns || Infinity;\n\n this.itemWidth = 0;\n this.numColumns = 0;\n\n this.lastCollection = null;\n this.collator = options.collator;\n }\n\n get layoutType(): string {\n return 'waterfall';\n }\n\n buildCollection(invalidationContext: InvalidationContext): void {\n // Compute the number of columns needed to display the content\n let visibleWidth = this.virtualizer.visibleRect.width;\n let availableWidth = visibleWidth - this.margin * 2;\n let columns = Math.floor((availableWidth + this.minSpace.width) / (this.minItemSize.width + this.minSpace.width));\n this.numColumns = Math.max(1, Math.min(this.maxColumns, columns));\n\n\n // Compute the available width (minus the space between items)\n let width = availableWidth - (this.minSpace.width * (this.numColumns - 1));\n\n // Compute the item width based on the space available\n let itemWidth = Math.round(width / this.numColumns);\n itemWidth = Math.max(this.minItemSize.width, Math.min(this.maxItemSize.width, itemWidth));\n this.itemWidth = itemWidth;\n\n // Compute the horizontal spacing\n // if only one column, we cannot divide by zero, so set it to 1\n let horizontalSpacing = Math.round((availableWidth - this.numColumns * itemWidth) / Math.max(1, this.numColumns - 1));\n this.horizontalSpacing = horizontalSpacing;\n\n // Setup an array of column heights\n let columnHeights = Array(this.numColumns).fill(this.margin);\n for (let node of this.collection) {\n let key = node.key;\n // Compute the height of the item. Use the existing height if available,\n // otherwise call the delegate to estimate the size.\n let oldLayoutInfo = this.layoutInfos.get(key);\n let height;\n let estimatedSize = true;\n if (oldLayoutInfo) {\n height = oldLayoutInfo.rect.height;\n estimatedSize = invalidationContext.sizeChanged || oldLayoutInfo.estimatedSize;\n } else if (node.props.width && node.props.height) {\n let nodeWidth = node.props.width;\n let nodeHeight = node.props.height;\n let scaledHeight = Math.round(nodeHeight * ((itemWidth) / nodeWidth));\n height = Math.max(this.minItemSize.height, Math.min(this.maxItemSize.height, scaledHeight));\n } else {\n height = itemWidth;\n }\n\n // Figure out which column to place the item in, and compute its position.\n let column = this.getNextColumnIndex(columnHeights);\n let x = this.margin + column * (itemWidth + horizontalSpacing);\n let y = columnHeights[column];\n\n let rect = new Rect(x, y, itemWidth, height);\n let layoutInfo = new LayoutInfo(node.type, key, rect);\n layoutInfo.estimatedSize = estimatedSize;\n layoutInfo.allowOverflow = true;\n this.layoutInfos.set(key, layoutInfo);\n\n // TODO: From v2 figure out this bit, when does this get called and what to replace this.collectionView._transaction with?\n // Removing it from v2 doesn't seem to do anything?\n // if (layoutInfo.estimatedSize && !invalidationContext.contentChanged && !this.collectionView._transaction) {\n // this.updateItemSize(new IndexPath(section, i));\n // }\n\n columnHeights[column] += layoutInfo.rect.height + this.minSpace.height;\n }\n\n // Reset all columns to the maximum for the next section\n let maxHeight = Math.max.apply(Math, columnHeights) - this.minSpace.height + this.margin;\n columnHeights.fill(maxHeight);\n let y = columnHeights[0];\n\n if (this.isLoading) {\n let loaderY = y;\n let loaderHeight = 60;\n // If there aren't any items, make loader take all avaliable room and remove margin from y calculation\n // so it doesn't scroll\n if (this.collection.size === 0) {\n loaderY = 0;\n loaderHeight = this.virtualizer.visibleRect.height || 60;\n }\n\n let rect = new Rect(0, loaderY, this.virtualizer.visibleRect.width, loaderHeight);\n let loader = new LayoutInfo('loader', 'loader', rect);\n this.layoutInfos.set('loader', loader);\n y = loader.rect.maxY;\n }\n\n if (this.collection.size === 0 && !this.isLoading) {\n let rect = new Rect(0, 0, this.virtualizer.visibleRect.width, this.virtualizer.visibleRect.height);\n let placeholder = new LayoutInfo('placeholder', 'placeholder', rect);\n this.layoutInfos.set('placeholder', placeholder);\n y = placeholder.rect.maxY;\n }\n\n this.contentSize = new Size(this.virtualizer.visibleRect.width, y);\n }\n\n updateItemSize(key: Key, size: Size): number {\n let layoutInfo = this.layoutInfos.get(key);\n if (!size || !layoutInfo) {\n return false;\n }\n\n if (size.height !== layoutInfo.rect.height) {\n // TODO: also not sure about copying layout info vs mutating it. Listlayout does the below\n // but I feel that is because it actually maintained a layoutNode map cache which this doesn't have\n let newLayoutInfo = layoutInfo.copy();\n newLayoutInfo.rect.height = size.height < 600 ? size.height : 600;\n newLayoutInfo.estimatedSize = false;\n this.layoutInfos.set(key, newLayoutInfo);\n return true;\n }\n\n return false;\n }\n\n getNextColumnIndex(columnHeights: number[]): number {\n let minIndex = 0;\n for (let i = 0; i < columnHeights.length; i++) {\n if (columnHeights[i] < columnHeights[minIndex]) {\n minIndex = i;\n }\n }\n\n return minIndex;\n }\n\n getClosestRight(key: Key): Node<T> | undefined {\n let layoutInfo = this.getLayoutInfo(key);\n // Refactored from v2. Current strategy is to find the closest card in the adjacent column.\n // This prevent the issue where it was possible that the closest layoutInfo would be two columns over due to the middle card being exceptionally tall\n // and thus the top corner to top corner distance was massive.\n\n // First look for a card to the immediate right of the current card. If we can't find any, look for the nearest card in the entire column to the right of the card\n let rect = new Rect(layoutInfo.rect.maxX + 1, layoutInfo.rect.y, layoutInfo.rect.width + this.horizontalSpacing, layoutInfo.rect.height);\n key = this._findClosest(layoutInfo.rect, rect)?.key;\n\n if (!key) {\n rect = new Rect(layoutInfo.rect.maxX + 1, 0, layoutInfo.rect.width + this.horizontalSpacing, this.virtualizer.contentSize.height);\n key = this._findClosest(layoutInfo.rect, rect)?.key;\n }\n\n let item = this.collection.getItem(key);\n return getFirstItem(getChildNodes(item, this.collection))?.key;\n }\n\n getClosestLeft(key: Key): Node<T> | undefined {\n let layoutInfo = this.getLayoutInfo(key);\n // First look for a card to the immediate left of the current card. If we can't find any, look for the nearest card in the entire column to the left of the card\n let rect = new Rect(layoutInfo.rect.x - layoutInfo.rect.width - this.horizontalSpacing - 1, layoutInfo.rect.y, layoutInfo.rect.width + this.horizontalSpacing, layoutInfo.rect.height);\n key = this._findClosest(layoutInfo.rect, rect)?.key;\n\n if (!key) {\n rect = new Rect(layoutInfo.rect.x - layoutInfo.rect.width - this.horizontalSpacing - 1, 0, layoutInfo.rect.width + this.horizontalSpacing, this.virtualizer.contentSize.height);\n key = this._findClosest(layoutInfo.rect, rect)?.key;\n }\n\n let item = this.collection.getItem(key);\n return getFirstItem(getChildNodes(item, this.collection))?.key;\n }\n\n getKeyRightOf(key: Key): Node<T> | undefined {\n // Expected key is the currently focused cell so we need the parent row key\n let parentRowKey = this.collection.getItem(key).parentKey;\n return this.direction === 'rtl' ? this.getClosestLeft(parentRowKey) : this.getClosestRight(parentRowKey);\n }\n\n getKeyLeftOf(key: Key): Node<T> | undefined {\n // Expected key is the currently focused cell so we need the parent row key\n let parentRowKey = this.collection.getItem(key).parentKey;\n return this.direction === 'rtl' ? this.getClosestRight(parentRowKey) : this.getClosestLeft(parentRowKey);\n }\n}\n"],"names":[],"version":3,"file":"WaterfallLayout.main.js.map"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;AAAA,cAAc;AACd;;;;;;;;;;CAUC;;;AA+BM,MAAM,kDAA2B,CAAA,GAAA,yCAAS;IA0B/C,IAAI,aAAa;QACf,OAAO;IACT;IAEA,gBAAgB,mBAAwC,EAAE;QACxD,8DAA8D;QAC9D,IAAI,eAAe,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,KAAK;QACrD,IAAI,iBAAiB,eAAe,IAAI,CAAC,MAAM,GAAG;QAClD,IAAI,UAAU,KAAK,KAAK,CAAC,AAAC,CAAA,iBAAiB,IAAI,CAAC,QAAQ,CAAC,KAAK,AAAD,IAAM,CAAA,IAAI,CAAC,WAAW,CAAC,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,AAAD;QAC9G,IAAI,CAAC,UAAU,GAAG,KAAK,GAAG,CAAC,GAAG,KAAK,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE;QAGxD,8DAA8D;QAC9D,IAAI,QAAQ,iBAAkB,IAAI,CAAC,QAAQ,CAAC,KAAK,GAAI,CAAA,IAAI,CAAC,UAAU,GAAG,CAAA;QAEvE,sDAAsD;QACtD,IAAI,YAAY,KAAK,KAAK,CAAC,QAAQ,IAAI,CAAC,UAAU;QAClD,YAAY,KAAK,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE;QAC9E,IAAI,CAAC,SAAS,GAAG;QAEjB,iCAAiC;QACjC,+DAA+D;QAC/D,IAAI,oBAAoB,KAAK,KAAK,CA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IAAI,CAAC,UAAU,GAAG;QAElB,IAAI,CAAC,cAAc,GAAG;QACtB,IAAI,CAAC,QAAQ,GAAG,QAAQ,QAAQ;IAClC;AA8KF","sources":["packages/@react-spectrum/card/src/WaterfallLayout.tsx"],"sourcesContent":["// @ts-nocheck\n/*\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 {BaseLayout, BaseLayoutOptions} from './BaseLayout';\nimport {getChildNodes, getFirstItem} from '@react-stately/collections';\nimport {InvalidationContext, LayoutInfo, Rect, Size} from '@react-stately/virtualizer';\nimport {Key, KeyboardDelegate} from '@react-types/shared';\n\nexport interface WaterfallLayoutOptions extends BaseLayoutOptions {\n /**\n * The minimum item size.\n * @default 240 x 136\n */\n minItemSize?: Size,\n /**\n * The maximum item size.\n * @default Infinity\n */\n maxItemSize?: Size,\n /**\n * The minimum space required between items.\n * @default 18 x 18\n */\n minSpace?: Size,\n /**\n * The maximum number of columns.\n * @default Infinity\n */\n maxColumns?: number\n}\n\n// TODO: this didn't have any options that varied with card size, should it have?\nexport class WaterfallLayout<T> extends BaseLayout<T> implements KeyboardDelegate {\n protected minItemSize: Size;\n protected maxItemSize: Size;\n protected minSpace: Size;\n protected maxColumns: number;\n protected numColumns: number;\n protected itemWidth: number;\n protected horizontalSpacing: number;\n\n constructor(options: WaterfallLayoutOptions = {}) {\n // TODO: WaterfallLayout doesn't use card size in v2, but perhaps it should support it? Perhaps it would modify\n // minItemSize defaults or other things\n super(options);\n this.minItemSize = options.minItemSize || new Size(240, 136);\n this.maxItemSize = options.maxItemSize || new Size(Infinity, Infinity);\n this.margin = options.margin != null ? options.margin : 24;\n this.minSpace = options.minSpace || new Size(18, 18);\n this.maxColumns = options.maxColumns || Infinity;\n\n this.itemWidth = 0;\n this.numColumns = 0;\n\n this.lastCollection = null;\n this.collator = options.collator;\n }\n\n get layoutType() {\n return 'waterfall';\n }\n\n buildCollection(invalidationContext: InvalidationContext) {\n // Compute the number of columns needed to display the content\n let visibleWidth = this.virtualizer.visibleRect.width;\n let availableWidth = visibleWidth - this.margin * 2;\n let columns = Math.floor((availableWidth + this.minSpace.width) / (this.minItemSize.width + this.minSpace.width));\n this.numColumns = Math.max(1, Math.min(this.maxColumns, columns));\n\n\n // Compute the available width (minus the space between items)\n let width = availableWidth - (this.minSpace.width * (this.numColumns - 1));\n\n // Compute the item width based on the space available\n let itemWidth = Math.round(width / this.numColumns);\n itemWidth = Math.max(this.minItemSize.width, Math.min(this.maxItemSize.width, itemWidth));\n this.itemWidth = itemWidth;\n\n // Compute the horizontal spacing\n // if only one column, we cannot divide by zero, so set it to 1\n let horizontalSpacing = Math.round((availableWidth - this.numColumns * itemWidth) / Math.max(1, this.numColumns - 1));\n this.horizontalSpacing = horizontalSpacing;\n\n // Setup an array of column heights\n let columnHeights = Array(this.numColumns).fill(this.margin);\n for (let node of this.collection) {\n let key = node.key;\n // Compute the height of the item. Use the existing height if available,\n // otherwise call the delegate to estimate the size.\n let oldLayoutInfo = this.layoutInfos.get(key);\n let height;\n let estimatedSize = true;\n if (oldLayoutInfo) {\n height = oldLayoutInfo.rect.height;\n estimatedSize = invalidationContext.sizeChanged || oldLayoutInfo.estimatedSize;\n } else if (node.props.width && node.props.height) {\n let nodeWidth = node.props.width;\n let nodeHeight = node.props.height;\n let scaledHeight = Math.round(nodeHeight * ((itemWidth) / nodeWidth));\n height = Math.max(this.minItemSize.height, Math.min(this.maxItemSize.height, scaledHeight));\n } else {\n height = itemWidth;\n }\n\n // Figure out which column to place the item in, and compute its position.\n let column = this.getNextColumnIndex(columnHeights);\n let x = this.margin + column * (itemWidth + horizontalSpacing);\n let y = columnHeights[column];\n\n let rect = new Rect(x, y, itemWidth, height);\n let layoutInfo = new LayoutInfo(node.type, key, rect);\n layoutInfo.estimatedSize = estimatedSize;\n layoutInfo.allowOverflow = true;\n this.layoutInfos.set(key, layoutInfo);\n\n // TODO: From v2 figure out this bit, when does this get called and what to replace this.collectionView._transaction with?\n // Removing it from v2 doesn't seem to do anything?\n // if (layoutInfo.estimatedSize && !invalidationContext.contentChanged && !this.collectionView._transaction) {\n // this.updateItemSize(new IndexPath(section, i));\n // }\n\n columnHeights[column] += layoutInfo.rect.height + this.minSpace.height;\n }\n\n // Reset all columns to the maximum for the next section\n let maxHeight = Math.max.apply(Math, columnHeights) - this.minSpace.height + this.margin;\n columnHeights.fill(maxHeight);\n let y = columnHeights[0];\n\n if (this.isLoading) {\n let loaderY = y;\n let loaderHeight = 60;\n // If there aren't any items, make loader take all avaliable room and remove margin from y calculation\n // so it doesn't scroll\n if (this.collection.size === 0) {\n loaderY = 0;\n loaderHeight = this.virtualizer.visibleRect.height || 60;\n }\n\n let rect = new Rect(0, loaderY, this.virtualizer.visibleRect.width, loaderHeight);\n let loader = new LayoutInfo('loader', 'loader', rect);\n this.layoutInfos.set('loader', loader);\n y = loader.rect.maxY;\n }\n\n if (this.collection.size === 0 && !this.isLoading) {\n let rect = new Rect(0, 0, this.virtualizer.visibleRect.width, this.virtualizer.visibleRect.height);\n let placeholder = new LayoutInfo('placeholder', 'placeholder', rect);\n this.layoutInfos.set('placeholder', placeholder);\n y = placeholder.rect.maxY;\n }\n\n this.contentSize = new Size(this.virtualizer.visibleRect.width, y);\n }\n\n updateItemSize(key: Key, size: Size) {\n let layoutInfo = this.layoutInfos.get(key);\n if (!size || !layoutInfo) {\n return false;\n }\n\n if (size.height !== layoutInfo.rect.height) {\n // TODO: also not sure about copying layout info vs mutating it. Listlayout does the below\n // but I feel that is because it actually maintained a layoutNode map cache which this doesn't have\n let newLayoutInfo = layoutInfo.copy();\n newLayoutInfo.rect.height = size.height < 600 ? size.height : 600;\n newLayoutInfo.estimatedSize = false;\n this.layoutInfos.set(key, newLayoutInfo);\n return true;\n }\n\n return false;\n }\n\n getNextColumnIndex(columnHeights) {\n let minIndex = 0;\n for (let i = 0; i < columnHeights.length; i++) {\n if (columnHeights[i] < columnHeights[minIndex]) {\n minIndex = i;\n }\n }\n\n return minIndex;\n }\n\n getClosestRight(key: Key) {\n let layoutInfo = this.getLayoutInfo(key);\n // Refactored from v2. Current strategy is to find the closest card in the adjacent column.\n // This prevent the issue where it was possible that the closest layoutInfo would be two columns over due to the middle card being exceptionally tall\n // and thus the top corner to top corner distance was massive.\n\n // First look for a card to the immediate right of the current card. If we can't find any, look for the nearest card in the entire column to the right of the card\n let rect = new Rect(layoutInfo.rect.maxX + 1, layoutInfo.rect.y, layoutInfo.rect.width + this.horizontalSpacing, layoutInfo.rect.height);\n key = this._findClosest(layoutInfo.rect, rect)?.key;\n\n if (!key) {\n rect = new Rect(layoutInfo.rect.maxX + 1, 0, layoutInfo.rect.width + this.horizontalSpacing, this.virtualizer.contentSize.height);\n key = this._findClosest(layoutInfo.rect, rect)?.key;\n }\n\n let item = this.collection.getItem(key);\n return getFirstItem(getChildNodes(item, this.collection))?.key;\n }\n\n getClosestLeft(key: Key) {\n let layoutInfo = this.getLayoutInfo(key);\n // First look for a card to the immediate left of the current card. If we can't find any, look for the nearest card in the entire column to the left of the card\n let rect = new Rect(layoutInfo.rect.x - layoutInfo.rect.width - this.horizontalSpacing - 1, layoutInfo.rect.y, layoutInfo.rect.width + this.horizontalSpacing, layoutInfo.rect.height);\n key = this._findClosest(layoutInfo.rect, rect)?.key;\n\n if (!key) {\n rect = new Rect(layoutInfo.rect.x - layoutInfo.rect.width - this.horizontalSpacing - 1, 0, layoutInfo.rect.width + this.horizontalSpacing, this.virtualizer.contentSize.height);\n key = this._findClosest(layoutInfo.rect, rect)?.key;\n }\n\n let item = this.collection.getItem(key);\n return getFirstItem(getChildNodes(item, 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 return this.direction === 'rtl' ? this.getClosestLeft(parentRowKey) : this.getClosestRight(parentRowKey);\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 return this.direction === 'rtl' ? this.getClosestRight(parentRowKey) : this.getClosestLeft(parentRowKey);\n }\n}\n"],"names":[],"version":3,"file":"WaterfallLayout.module.js.map"}
|
|
1
|
+
{"mappings":";;;;AAAA,cAAc;AACd;;;;;;;;;;CAUC;;;AA+BM,MAAM,kDAA2B,CAAA,GAAA,yCAAS;IA0B/C,IAAI,aAAqB;QACvB,OAAO;IACT;IAEA,gBAAgB,mBAAwC,EAAQ;QAC9D,8DAA8D;QAC9D,IAAI,eAAe,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,KAAK;QACrD,IAAI,iBAAiB,eAAe,IAAI,CAAC,MAAM,GAAG;QAClD,IAAI,UAAU,KAAK,KAAK,CAAC,AAAC,CAAA,iBAAiB,IAAI,CAAC,QAAQ,CAAC,KAAK,AAAD,IAAM,CAAA,IAAI,CAAC,WAAW,CAAC,KAAK,GAAG,IAAI,CAAC,QAAQ,CAAC,KAAK,AAAD;QAC9G,IAAI,CAAC,UAAU,GAAG,KAAK,GAAG,CAAC,GAAG,KAAK,GAAG,CAAC,IAAI,CAAC,UAAU,EAAE;QAGxD,8DAA8D;QAC9D,IAAI,QAAQ,iBAAkB,IAAI,CAAC,QAAQ,CAAC,KAAK,GAAI,CAAA,IAAI,CAAC,UAAU,GAAG,CAAA;QAEvE,sDAAsD;QACtD,IAAI,YAAY,KAAK,KAAK,CAAC,QAAQ,IAAI,CAAC,UAAU;QAClD,YAAY,KAAK,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,KAAK,GAAG,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE;QAC9E,IAAI,CA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AAI;QACjD,IAAI,CAAC,UAAU,GAAG,QAAQ,UAAU,IAAI;QAExC,IAAI,CAAC,SAAS,GAAG;QACjB,IAAI,CAAC,UAAU,GAAG;QAElB,IAAI,CAAC,cAAc,GAAG;QACtB,IAAI,CAAC,QAAQ,GAAG,QAAQ,QAAQ;IAClC;AA8KF","sources":["packages/@react-spectrum/card/src/WaterfallLayout.tsx"],"sourcesContent":["// @ts-nocheck\n/*\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 {BaseLayout, BaseLayoutOptions} from './BaseLayout';\nimport {getChildNodes, getFirstItem} from '@react-stately/collections';\nimport {InvalidationContext, LayoutInfo, Rect, Size} from '@react-stately/virtualizer';\nimport {Key, KeyboardDelegate} from '@react-types/shared';\n\nexport interface WaterfallLayoutOptions extends BaseLayoutOptions {\n /**\n * The minimum item size.\n * @default 240 x 136\n */\n minItemSize?: Size,\n /**\n * The maximum item size.\n * @default Infinity\n */\n maxItemSize?: Size,\n /**\n * The minimum space required between items.\n * @default 18 x 18\n */\n minSpace?: Size,\n /**\n * The maximum number of columns.\n * @default Infinity\n */\n maxColumns?: number\n}\n\n// TODO: this didn't have any options that varied with card size, should it have?\nexport class WaterfallLayout<T> extends BaseLayout<T> implements KeyboardDelegate {\n protected minItemSize: Size;\n protected maxItemSize: Size;\n protected minSpace: Size;\n protected maxColumns: number;\n protected numColumns: number;\n protected itemWidth: number;\n protected horizontalSpacing: number;\n\n constructor(options: WaterfallLayoutOptions = {}) {\n // TODO: WaterfallLayout doesn't use card size in v2, but perhaps it should support it? Perhaps it would modify\n // minItemSize defaults or other things\n super(options);\n this.minItemSize = options.minItemSize || new Size(240, 136);\n this.maxItemSize = options.maxItemSize || new Size(Infinity, Infinity);\n this.margin = options.margin != null ? options.margin : 24;\n this.minSpace = options.minSpace || new Size(18, 18);\n this.maxColumns = options.maxColumns || Infinity;\n\n this.itemWidth = 0;\n this.numColumns = 0;\n\n this.lastCollection = null;\n this.collator = options.collator;\n }\n\n get layoutType(): string {\n return 'waterfall';\n }\n\n buildCollection(invalidationContext: InvalidationContext): void {\n // Compute the number of columns needed to display the content\n let visibleWidth = this.virtualizer.visibleRect.width;\n let availableWidth = visibleWidth - this.margin * 2;\n let columns = Math.floor((availableWidth + this.minSpace.width) / (this.minItemSize.width + this.minSpace.width));\n this.numColumns = Math.max(1, Math.min(this.maxColumns, columns));\n\n\n // Compute the available width (minus the space between items)\n let width = availableWidth - (this.minSpace.width * (this.numColumns - 1));\n\n // Compute the item width based on the space available\n let itemWidth = Math.round(width / this.numColumns);\n itemWidth = Math.max(this.minItemSize.width, Math.min(this.maxItemSize.width, itemWidth));\n this.itemWidth = itemWidth;\n\n // Compute the horizontal spacing\n // if only one column, we cannot divide by zero, so set it to 1\n let horizontalSpacing = Math.round((availableWidth - this.numColumns * itemWidth) / Math.max(1, this.numColumns - 1));\n this.horizontalSpacing = horizontalSpacing;\n\n // Setup an array of column heights\n let columnHeights = Array(this.numColumns).fill(this.margin);\n for (let node of this.collection) {\n let key = node.key;\n // Compute the height of the item. Use the existing height if available,\n // otherwise call the delegate to estimate the size.\n let oldLayoutInfo = this.layoutInfos.get(key);\n let height;\n let estimatedSize = true;\n if (oldLayoutInfo) {\n height = oldLayoutInfo.rect.height;\n estimatedSize = invalidationContext.sizeChanged || oldLayoutInfo.estimatedSize;\n } else if (node.props.width && node.props.height) {\n let nodeWidth = node.props.width;\n let nodeHeight = node.props.height;\n let scaledHeight = Math.round(nodeHeight * ((itemWidth) / nodeWidth));\n height = Math.max(this.minItemSize.height, Math.min(this.maxItemSize.height, scaledHeight));\n } else {\n height = itemWidth;\n }\n\n // Figure out which column to place the item in, and compute its position.\n let column = this.getNextColumnIndex(columnHeights);\n let x = this.margin + column * (itemWidth + horizontalSpacing);\n let y = columnHeights[column];\n\n let rect = new Rect(x, y, itemWidth, height);\n let layoutInfo = new LayoutInfo(node.type, key, rect);\n layoutInfo.estimatedSize = estimatedSize;\n layoutInfo.allowOverflow = true;\n this.layoutInfos.set(key, layoutInfo);\n\n // TODO: From v2 figure out this bit, when does this get called and what to replace this.collectionView._transaction with?\n // Removing it from v2 doesn't seem to do anything?\n // if (layoutInfo.estimatedSize && !invalidationContext.contentChanged && !this.collectionView._transaction) {\n // this.updateItemSize(new IndexPath(section, i));\n // }\n\n columnHeights[column] += layoutInfo.rect.height + this.minSpace.height;\n }\n\n // Reset all columns to the maximum for the next section\n let maxHeight = Math.max.apply(Math, columnHeights) - this.minSpace.height + this.margin;\n columnHeights.fill(maxHeight);\n let y = columnHeights[0];\n\n if (this.isLoading) {\n let loaderY = y;\n let loaderHeight = 60;\n // If there aren't any items, make loader take all avaliable room and remove margin from y calculation\n // so it doesn't scroll\n if (this.collection.size === 0) {\n loaderY = 0;\n loaderHeight = this.virtualizer.visibleRect.height || 60;\n }\n\n let rect = new Rect(0, loaderY, this.virtualizer.visibleRect.width, loaderHeight);\n let loader = new LayoutInfo('loader', 'loader', rect);\n this.layoutInfos.set('loader', loader);\n y = loader.rect.maxY;\n }\n\n if (this.collection.size === 0 && !this.isLoading) {\n let rect = new Rect(0, 0, this.virtualizer.visibleRect.width, this.virtualizer.visibleRect.height);\n let placeholder = new LayoutInfo('placeholder', 'placeholder', rect);\n this.layoutInfos.set('placeholder', placeholder);\n y = placeholder.rect.maxY;\n }\n\n this.contentSize = new Size(this.virtualizer.visibleRect.width, y);\n }\n\n updateItemSize(key: Key, size: Size): number {\n let layoutInfo = this.layoutInfos.get(key);\n if (!size || !layoutInfo) {\n return false;\n }\n\n if (size.height !== layoutInfo.rect.height) {\n // TODO: also not sure about copying layout info vs mutating it. Listlayout does the below\n // but I feel that is because it actually maintained a layoutNode map cache which this doesn't have\n let newLayoutInfo = layoutInfo.copy();\n newLayoutInfo.rect.height = size.height < 600 ? size.height : 600;\n newLayoutInfo.estimatedSize = false;\n this.layoutInfos.set(key, newLayoutInfo);\n return true;\n }\n\n return false;\n }\n\n getNextColumnIndex(columnHeights: number[]): number {\n let minIndex = 0;\n for (let i = 0; i < columnHeights.length; i++) {\n if (columnHeights[i] < columnHeights[minIndex]) {\n minIndex = i;\n }\n }\n\n return minIndex;\n }\n\n getClosestRight(key: Key): Node<T> | undefined {\n let layoutInfo = this.getLayoutInfo(key);\n // Refactored from v2. Current strategy is to find the closest card in the adjacent column.\n // This prevent the issue where it was possible that the closest layoutInfo would be two columns over due to the middle card being exceptionally tall\n // and thus the top corner to top corner distance was massive.\n\n // First look for a card to the immediate right of the current card. If we can't find any, look for the nearest card in the entire column to the right of the card\n let rect = new Rect(layoutInfo.rect.maxX + 1, layoutInfo.rect.y, layoutInfo.rect.width + this.horizontalSpacing, layoutInfo.rect.height);\n key = this._findClosest(layoutInfo.rect, rect)?.key;\n\n if (!key) {\n rect = new Rect(layoutInfo.rect.maxX + 1, 0, layoutInfo.rect.width + this.horizontalSpacing, this.virtualizer.contentSize.height);\n key = this._findClosest(layoutInfo.rect, rect)?.key;\n }\n\n let item = this.collection.getItem(key);\n return getFirstItem(getChildNodes(item, this.collection))?.key;\n }\n\n getClosestLeft(key: Key): Node<T> | undefined {\n let layoutInfo = this.getLayoutInfo(key);\n // First look for a card to the immediate left of the current card. If we can't find any, look for the nearest card in the entire column to the left of the card\n let rect = new Rect(layoutInfo.rect.x - layoutInfo.rect.width - this.horizontalSpacing - 1, layoutInfo.rect.y, layoutInfo.rect.width + this.horizontalSpacing, layoutInfo.rect.height);\n key = this._findClosest(layoutInfo.rect, rect)?.key;\n\n if (!key) {\n rect = new Rect(layoutInfo.rect.x - layoutInfo.rect.width - this.horizontalSpacing - 1, 0, layoutInfo.rect.width + this.horizontalSpacing, this.virtualizer.contentSize.height);\n key = this._findClosest(layoutInfo.rect, rect)?.key;\n }\n\n let item = this.collection.getItem(key);\n return getFirstItem(getChildNodes(item, this.collection))?.key;\n }\n\n getKeyRightOf(key: Key): Node<T> | undefined {\n // Expected key is the currently focused cell so we need the parent row key\n let parentRowKey = this.collection.getItem(key).parentKey;\n return this.direction === 'rtl' ? this.getClosestLeft(parentRowKey) : this.getClosestRight(parentRowKey);\n }\n\n getKeyLeftOf(key: Key): Node<T> | undefined {\n // Expected key is the currently focused cell so we need the parent row key\n let parentRowKey = this.collection.getItem(key).parentKey;\n return this.direction === 'rtl' ? this.getClosestRight(parentRowKey) : this.getClosestLeft(parentRowKey);\n }\n}\n"],"names":[],"version":3,"file":"WaterfallLayout.module.js.map"}
|
|
@@ -1668,4 +1668,4 @@
|
|
|
1668
1668
|
.NOE1la_spectrum-Card--horizontal .NOE1la_spectrum-Card-image, .NOE1la_spectrum-Card--horizontal .NOE1la_spectrum-Card-illustration {
|
|
1669
1669
|
border-inline-end-color: var(--spectrum-card-coverphoto-border-color, var(--spectrum-global-color-gray-200));
|
|
1670
1670
|
}
|
|
1671
|
-
/*# sourceMappingURL=
|
|
1671
|
+
/*# sourceMappingURL=card.370c5606.css.map */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":"AA4DA;;;;;AAIE;;;;AAIA;;;;AAIA;;;;AAIA;;;;AAIA;;;;AAIA;;;;AAQA;;;;AAIA;;;;AAKF;;;;;;;;AAOE;;;;;;;;;;;AAqBE;;;;;AAQF;;;;AAKE;;;;;AAOJ;EACE;;;;EAIE;;;;;AAwFJ;;;;;;;;;;AASE;;;;AAIA;;;;AAGA;;;;;;;;;;AAAA;;;;AAAA;;;;AAAA;;;;AAAA;;;;AAUA;;;;AAaE;;;;;;AASJ;;;;AAKE;;;;AAMF;;;;AAEE;;;;;AAMF;;;;AAEE;;;;;AAMF;;;;;AAKA;;;;;AAKA;;;;;AAKA;;;;;;AAMA;;;;AAQA;;;;;;;AACE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kBA;;;;;AAMA;;;;AAGA;;;;;;;;AAOA;;;;AAIA;;;;;;;;;AAeF;;;;AAGE;;;;;;;;AAOA;;;;;AAoBA;;;;;;AAMC;;;;AAID;;;;AAcF;;;;AAIA;;;;AAiBA;;;;;AAIE;;;;AAEE;;;;AAOA;;;;AAQF;;;;AAEE;;;;AAQF;;;;AAEE;;;;AAKF;;;;AAEE;;;;AAKF;;;;AAEE;;;;;AAIA;;;;AAEE;;;;;AAMJ;;;;AAGA;;;;;AAME;;;;;AAMF;;;;AAcA;;;;AASF;;;;;AAKM;;;;;AAUA;;;;AAsBA;;;;AAgBA;;;;AAME;;;;AAQJ;;;;;AAwBF;;;;;;AAQF;;;;;AAGE;;;;AAGI;;;;AASA;;;;AASJ;;;;AAGI;;;;AASJ;;;;AAGI;;;;AAMJ;;;;AAGI;;;;AAMJ;;;;AAGI;;;;;AAKF;;;;AAGI;;;;;AASJ;;;;;AAMF","sources":["packages/@adobe/spectrum-css-temp/components/card/vars.css"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n@import './index.css';\n@import './skin.css';\n"],"names":[],"version":3,"file":"
|
|
1
|
+
{"mappings":"AA4DA;;;;;AAIE;;;;AAIA;;;;AAIA;;;;AAIA;;;;AAIA;;;;AAIA;;;;AAQA;;;;AAIA;;;;AAKF;;;;;;;;AAOE;;;;;;;;;;;AAqBE;;;;;AAQF;;;;AAKE;;;;;AAOJ;EACE;;;;EAIE;;;;;AAwFJ;;;;;;;;;;AASE;;;;AAIA;;;;AAGA;;;;;;;;;;AAAA;;;;AAAA;;;;A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AACE;;;;AAMA;;;;AAWA;;;;;;;;;;;;AAYE;;;;;;;;AAgBF;;;;;;;;AAAA;;;;;AAAA;;;;;AAAA;;;;;AAAA;;;;;AAAA;;;;;;;;AAAA;;;;;AAAA;;;;;AAAA;;;;;AAAA;;;;;AAkBA;;;;;AAMA;;;;AAGA;;;;;;;;AAOA;;;;AAIA;;;;;;;;;AAeF;;;;AAGE;;;;;;;;AAOA;;;;;AAoBA;;;;;;AAMC;;;;AAID;;;;AAcF;;;;AAIA;;;;AAiBA;;;;;AAIE;;;;AAEE;;;;AAOA;;;;AAQF;;;;AAEE;;;;AAQF;;;;AAEE;;;;AAKF;;;;AAEE;;;;AAKF;;;;AAEE;;;;;AAIA;;;;AAEE;;;;;AAMJ;;;;AAGA;;;;;AAME;;;;;AAMF;;;;AAcA;;;;AASF;;;;;AAKM;;;;;AAUA;;;;AAsBA;;;;AAgBA;;;;AAME;;;;AAQJ;;;;;AAwBF;;;;;;AAQF;;;;;AAGE;;;;AAGI;;;;AASA;;;;AASJ;;;;AAGI;;;;AASJ;;;;AAGI;;;;AAMJ;;;;AAGI;;;;AAMJ;;;;AAGI;;;;;AAKF;;;;AAGI;;;;;AASJ;;;;;AAMF","sources":["packages/@adobe/spectrum-css-temp/components/card/vars.css"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n@import './index.css';\n@import './skin.css';\n"],"names":[],"version":3,"file":"card.370c5606.css.map"}
|
package/dist/types.d.ts
CHANGED
|
@@ -31,21 +31,21 @@ declare class BaseLayout<T> extends Layout<Node<T>, CardViewLayoutOptions> imple
|
|
|
31
31
|
constructor(options?: BaseLayoutOptions);
|
|
32
32
|
update(invalidationContext: InvalidationContext<CardViewLayoutOptions>): void;
|
|
33
33
|
buildCollection(invalidationContext?: InvalidationContext): void;
|
|
34
|
-
getContentSize():
|
|
34
|
+
getContentSize(): number;
|
|
35
35
|
getLayoutInfo(key: Key): LayoutInfo;
|
|
36
36
|
getVisibleLayoutInfos(rect: Rect, excludePersistedKeys?: boolean): LayoutInfo[];
|
|
37
37
|
isVisible(layoutInfo: LayoutInfo, rect: Rect, excludePersistedKeys: boolean): boolean;
|
|
38
|
-
_findClosestLayoutInfo(target: Rect, rect: Rect): null;
|
|
39
|
-
_findClosest(target: Rect, rect: Rect): null;
|
|
40
|
-
getKeyBelow(key: Key):
|
|
41
|
-
getKeyAbove(key: Key):
|
|
42
|
-
getKeyRightOf(key: Key):
|
|
43
|
-
getKeyLeftOf(key: Key):
|
|
44
|
-
getFirstKey():
|
|
45
|
-
getLastKey():
|
|
46
|
-
getKeyPageAbove(key: Key):
|
|
47
|
-
getKeyPageBelow(key: Key):
|
|
48
|
-
getKeyForSearch(search: string, fromKey?: Key):
|
|
38
|
+
_findClosestLayoutInfo(target: Rect, rect: Rect): LayoutInfo | null;
|
|
39
|
+
_findClosest(target: Rect, rect: Rect): LayoutInfo | null;
|
|
40
|
+
getKeyBelow(key: Key): Node<T> | undefined;
|
|
41
|
+
getKeyAbove(key: Key): Node<T> | undefined;
|
|
42
|
+
getKeyRightOf(key: Key): Node<T> | undefined;
|
|
43
|
+
getKeyLeftOf(key: Key): Node<T> | undefined;
|
|
44
|
+
getFirstKey(): Node<T> | undefined;
|
|
45
|
+
getLastKey(): Node<T> | undefined;
|
|
46
|
+
getKeyPageAbove(key: Key): Node<T> | undefined;
|
|
47
|
+
getKeyPageBelow(key: Key): Node<T> | undefined;
|
|
48
|
+
getKeyForSearch(search: string, fromKey?: Key): Node<T> | undefined | null;
|
|
49
49
|
}
|
|
50
50
|
export interface GalleryLayoutOptions extends BaseLayoutOptions {
|
|
51
51
|
/**
|
|
@@ -88,7 +88,7 @@ export class GalleryLayout<T> extends BaseLayout<T> {
|
|
|
88
88
|
* the widest in the row until it can't give anymore, then move to the second widest and so forth.
|
|
89
89
|
* Do this until all assets meet the min-width.
|
|
90
90
|
* */
|
|
91
|
-
_distributeWidths(widths:
|
|
91
|
+
_distributeWidths(widths: number[]): boolean;
|
|
92
92
|
buildCollection(): void;
|
|
93
93
|
}
|
|
94
94
|
export interface GridLayoutOptions extends BaseLayoutOptions {
|
|
@@ -136,11 +136,11 @@ export class GridLayout<T> extends BaseLayout<T> {
|
|
|
136
136
|
protected horizontalSpacing: number;
|
|
137
137
|
constructor(options?: GridLayoutOptions);
|
|
138
138
|
get layoutType(): string;
|
|
139
|
-
getIndexAtPoint(x:
|
|
139
|
+
getIndexAtPoint(x: number, y: number, allowInsertingAtEnd?: boolean): number;
|
|
140
140
|
buildCollection(): void;
|
|
141
141
|
buildChild(node: Node<T>, y: number, index: number): LayoutInfo;
|
|
142
|
-
getKeyBelow(key: Key):
|
|
143
|
-
getKeyAbove(key: Key):
|
|
142
|
+
getKeyBelow(key: Key): Node<T> | undefined | null;
|
|
143
|
+
getKeyAbove(key: Key): Node<T> | undefined | null;
|
|
144
144
|
}
|
|
145
145
|
export interface WaterfallLayoutOptions extends BaseLayoutOptions {
|
|
146
146
|
/**
|
|
@@ -175,12 +175,12 @@ export class WaterfallLayout<T> extends BaseLayout<T> implements KeyboardDelegat
|
|
|
175
175
|
constructor(options?: WaterfallLayoutOptions);
|
|
176
176
|
get layoutType(): string;
|
|
177
177
|
buildCollection(invalidationContext: InvalidationContext): void;
|
|
178
|
-
updateItemSize(key: Key, size: Size):
|
|
179
|
-
getNextColumnIndex(columnHeights:
|
|
180
|
-
getClosestRight(key: Key):
|
|
181
|
-
getClosestLeft(key: Key):
|
|
182
|
-
getKeyRightOf(key: Key):
|
|
183
|
-
getKeyLeftOf(key: Key):
|
|
178
|
+
updateItemSize(key: Key, size: Size): number;
|
|
179
|
+
getNextColumnIndex(columnHeights: number[]): number;
|
|
180
|
+
getClosestRight(key: Key): Node<T> | undefined;
|
|
181
|
+
getClosestLeft(key: Key): Node<T> | undefined;
|
|
182
|
+
getKeyRightOf(key: Key): Node<T> | undefined;
|
|
183
|
+
getKeyLeftOf(key: Key): Node<T> | undefined;
|
|
184
184
|
}
|
|
185
185
|
/**
|
|
186
186
|
* TODO: Add description of component here.
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"mappings":";;;;;;AAmBA;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,MAAM,CAAC,mBAAmB,EAAE,oBAAoB,qBAAqB,CAAC;
|
|
1
|
+
{"mappings":";;;;;;AAmBA;IACE,QAAQ,CAAC,EAAE,KAAK,QAAQ,CAA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AAC,GAAG,SAAS;IAe7C,aAAa,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,SAAS;IAM5C,YAAY,CAAC,GAAG,EAAE,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,GAAG,SAAS;CAK5C;AGhND;;GAEG;AACH,OAAO,MAAM,UA8GP,CAAC,CAAC,EAAE,KAAK,EAAE,sBAAsB,CAAC,CAAC,GAAG;IAAC,GAAG,CAAC,EAAE,OAAO,cAAc,CAAC,CAAA;CAAC,KAAK,YAAY,CAAC;ACnG5F,OAAA,IAAI,MAAgB,0BAA0B,UAAU,iBAAiB,CAAC,GAAG,gBAAgB,iBAAiB,CAAC,GAAG,cAAc,YAAY,cAAc,CAAC,CAAC,CAAC,CAAC;ACvB9J,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-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.42",
|
|
4
4
|
"description": "Spectrum UI components in React",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -36,22 +36,22 @@
|
|
|
36
36
|
"url": "https://github.com/adobe/react-spectrum"
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
|
-
"@react-aria/focus": "^3.20.
|
|
40
|
-
"@react-aria/grid": "^3.
|
|
41
|
-
"@react-aria/i18n": "^3.12.
|
|
42
|
-
"@react-aria/interactions": "^3.
|
|
43
|
-
"@react-aria/utils": "^3.28.
|
|
44
|
-
"@react-aria/virtualizer": "^4.1.
|
|
45
|
-
"@react-spectrum/checkbox": "^3.9.
|
|
46
|
-
"@react-spectrum/progress": "^3.7.
|
|
47
|
-
"@react-spectrum/utils": "^3.12.
|
|
48
|
-
"@react-stately/collections": "^3.12.
|
|
49
|
-
"@react-stately/grid": "^3.11.
|
|
50
|
-
"@react-stately/list": "^3.12.
|
|
51
|
-
"@react-stately/virtualizer": "^4.3.
|
|
52
|
-
"@react-types/card": "3.0.0-alpha.
|
|
53
|
-
"@react-types/provider": "^3.8.
|
|
54
|
-
"@react-types/shared": "^3.
|
|
39
|
+
"@react-aria/focus": "^3.20.2",
|
|
40
|
+
"@react-aria/grid": "^3.13.0",
|
|
41
|
+
"@react-aria/i18n": "^3.12.8",
|
|
42
|
+
"@react-aria/interactions": "^3.25.0",
|
|
43
|
+
"@react-aria/utils": "^3.28.2",
|
|
44
|
+
"@react-aria/virtualizer": "^4.1.4",
|
|
45
|
+
"@react-spectrum/checkbox": "^3.9.15",
|
|
46
|
+
"@react-spectrum/progress": "^3.7.15",
|
|
47
|
+
"@react-spectrum/utils": "^3.12.4",
|
|
48
|
+
"@react-stately/collections": "^3.12.3",
|
|
49
|
+
"@react-stately/grid": "^3.11.1",
|
|
50
|
+
"@react-stately/list": "^3.12.1",
|
|
51
|
+
"@react-stately/virtualizer": "^4.3.2",
|
|
52
|
+
"@react-types/card": "3.0.0-alpha.35",
|
|
53
|
+
"@react-types/provider": "^3.8.8",
|
|
54
|
+
"@react-types/shared": "^3.29.0",
|
|
55
55
|
"@swc/helpers": "^0.5.0"
|
|
56
56
|
},
|
|
57
57
|
"devDependencies": {
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
"publishConfig": {
|
|
66
66
|
"access": "public"
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "9b66d270572f482948afee95622a85cdf68ed408"
|
|
69
69
|
}
|
package/src/BaseLayout.tsx
CHANGED
|
@@ -54,7 +54,7 @@ export class BaseLayout<T> extends Layout<Node<T>, CardViewLayoutOptions> implem
|
|
|
54
54
|
this.margin = options.margin || 24;
|
|
55
55
|
}
|
|
56
56
|
|
|
57
|
-
update(invalidationContext: InvalidationContext<CardViewLayoutOptions>) {
|
|
57
|
+
update(invalidationContext: InvalidationContext<CardViewLayoutOptions>): void {
|
|
58
58
|
this.collection = this.virtualizer.collection as GridCollection<T>;
|
|
59
59
|
this.isLoading = invalidationContext.layoutOptions?.isLoading || false;
|
|
60
60
|
this.direction = invalidationContext.layoutOptions?.direction || 'ltr';
|
|
@@ -81,17 +81,17 @@ export class BaseLayout<T> extends Layout<Node<T>, CardViewLayoutOptions> implem
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
84
|
-
buildCollection(invalidationContext?: InvalidationContext) {}
|
|
84
|
+
buildCollection(invalidationContext?: InvalidationContext): void {}
|
|
85
85
|
|
|
86
|
-
getContentSize() {
|
|
86
|
+
getContentSize(): number {
|
|
87
87
|
return this.contentSize;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
getLayoutInfo(key: Key) {
|
|
90
|
+
getLayoutInfo(key: Key): LayoutInfo {
|
|
91
91
|
return this.layoutInfos.get(key)!;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
getVisibleLayoutInfos(rect: Rect, excludePersistedKeys = false) {
|
|
94
|
+
getVisibleLayoutInfos(rect: Rect, excludePersistedKeys = false): LayoutInfo[] {
|
|
95
95
|
let res: LayoutInfo[] = [];
|
|
96
96
|
|
|
97
97
|
for (let layoutInfo of this.layoutInfos.values()) {
|
|
@@ -103,7 +103,7 @@ export class BaseLayout<T> extends Layout<Node<T>, CardViewLayoutOptions> implem
|
|
|
103
103
|
return res;
|
|
104
104
|
}
|
|
105
105
|
|
|
106
|
-
isVisible(layoutInfo: LayoutInfo, rect: Rect, excludePersistedKeys: boolean) {
|
|
106
|
+
isVisible(layoutInfo: LayoutInfo, rect: Rect, excludePersistedKeys: boolean): boolean {
|
|
107
107
|
if (layoutInfo.rect.intersects(rect)) {
|
|
108
108
|
return true;
|
|
109
109
|
}
|
|
@@ -115,7 +115,7 @@ export class BaseLayout<T> extends Layout<Node<T>, CardViewLayoutOptions> implem
|
|
|
115
115
|
return false;
|
|
116
116
|
}
|
|
117
117
|
|
|
118
|
-
_findClosestLayoutInfo(target: Rect, rect: Rect) {
|
|
118
|
+
_findClosestLayoutInfo(target: Rect, rect: Rect): LayoutInfo | null {
|
|
119
119
|
let layoutInfos = this.getVisibleLayoutInfos(rect, true);
|
|
120
120
|
let best = null;
|
|
121
121
|
let bestDistance = Infinity;
|
|
@@ -139,12 +139,12 @@ export class BaseLayout<T> extends Layout<Node<T>, CardViewLayoutOptions> implem
|
|
|
139
139
|
return best;
|
|
140
140
|
}
|
|
141
141
|
|
|
142
|
-
_findClosest(target: Rect, rect: Rect) {
|
|
142
|
+
_findClosest(target: Rect, rect: Rect): LayoutInfo | null {
|
|
143
143
|
let best = this._findClosestLayoutInfo(target, rect);
|
|
144
144
|
return best || null;
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
-
getKeyBelow(key: Key) {
|
|
147
|
+
getKeyBelow(key: Key): Node<T> | undefined {
|
|
148
148
|
// Expected key is the currently focused cell so we need the parent row key
|
|
149
149
|
let parentRowKey = this.collection.getItem(key).parentKey;
|
|
150
150
|
let layoutInfo = this.getLayoutInfo(parentRowKey);
|
|
@@ -153,7 +153,7 @@ export class BaseLayout<T> extends Layout<Node<T>, CardViewLayoutOptions> implem
|
|
|
153
153
|
return getFirstItem(getChildNodes(closestRow, this.collection))?.key;
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
-
getKeyAbove(key: Key) {
|
|
156
|
+
getKeyAbove(key: Key): Node<T> | undefined {
|
|
157
157
|
// Expected key is the currently focused cell so we need the parent row key
|
|
158
158
|
let parentRowKey = this.collection.getItem(key).parentKey;
|
|
159
159
|
let layoutInfo = this.getLayoutInfo(parentRowKey);
|
|
@@ -162,7 +162,7 @@ export class BaseLayout<T> extends Layout<Node<T>, CardViewLayoutOptions> implem
|
|
|
162
162
|
return getFirstItem(getChildNodes(closestRow, this.collection))?.key;
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
-
getKeyRightOf(key: Key) {
|
|
165
|
+
getKeyRightOf(key: Key): Node<T> | undefined {
|
|
166
166
|
// Expected key is the currently focused cell so we need the parent row key
|
|
167
167
|
let parentRowKey = this.collection.getItem(key).parentKey;
|
|
168
168
|
key = this.direction === 'rtl' ? this.collection.getKeyBefore(parentRowKey) : this.collection.getKeyAfter(parentRowKey);
|
|
@@ -177,7 +177,7 @@ export class BaseLayout<T> extends Layout<Node<T>, CardViewLayoutOptions> implem
|
|
|
177
177
|
}
|
|
178
178
|
}
|
|
179
179
|
|
|
180
|
-
getKeyLeftOf(key: Key) {
|
|
180
|
+
getKeyLeftOf(key: Key): Node<T> | undefined {
|
|
181
181
|
// Expected key is the currently focused cell so we need the parent row key
|
|
182
182
|
let parentRowKey = this.collection.getItem(key).parentKey;
|
|
183
183
|
key = this.direction === 'rtl' ? this.collection.getKeyAfter(parentRowKey) : this.collection.getKeyBefore(parentRowKey);
|
|
@@ -192,19 +192,19 @@ export class BaseLayout<T> extends Layout<Node<T>, CardViewLayoutOptions> implem
|
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
194
|
|
|
195
|
-
getFirstKey() {
|
|
195
|
+
getFirstKey(): Node<T> | undefined {
|
|
196
196
|
let firstRow = this.collection.getItem(this.collection.getFirstKey());
|
|
197
197
|
return getFirstItem(getChildNodes(firstRow, this.collection))?.key;
|
|
198
198
|
}
|
|
199
199
|
|
|
200
|
-
getLastKey() {
|
|
200
|
+
getLastKey(): Node<T> | undefined {
|
|
201
201
|
let lastRow = this.collection.getItem(this.collection.getLastKey());
|
|
202
202
|
return getFirstItem(getChildNodes(lastRow, this.collection))?.key;
|
|
203
203
|
}
|
|
204
204
|
|
|
205
205
|
// TODO: pretty unwieldy because it needs to bounce back and forth between the parent key and the child key
|
|
206
206
|
// 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?
|
|
207
|
-
getKeyPageAbove(key: Key) {
|
|
207
|
+
getKeyPageAbove(key: Key): Node<T> | undefined {
|
|
208
208
|
// Expected key is the currently focused cell so we need the parent row key
|
|
209
209
|
let parentRowKey = this.collection.getItem(key).parentKey;
|
|
210
210
|
let layoutInfo = this.getLayoutInfo(parentRowKey);
|
|
@@ -235,7 +235,7 @@ export class BaseLayout<T> extends Layout<Node<T>, CardViewLayoutOptions> implem
|
|
|
235
235
|
|
|
236
236
|
// TODO: pretty unwieldy because it needs to bounce back and forth between the parent key and the child key
|
|
237
237
|
// Perhaps have layoutInfo store childKey as well so we don't need to do this?
|
|
238
|
-
getKeyPageBelow(key: Key) {
|
|
238
|
+
getKeyPageBelow(key: Key): Node<T> | undefined {
|
|
239
239
|
// Expected key is the currently focused cell so we need the parent row key
|
|
240
240
|
let parentRowKey = this.collection.getItem(key).parentKey;
|
|
241
241
|
let layoutInfo = this.getLayoutInfo(parentRowKey);
|
|
@@ -262,7 +262,7 @@ export class BaseLayout<T> extends Layout<Node<T>, CardViewLayoutOptions> implem
|
|
|
262
262
|
return this.getLastKey();
|
|
263
263
|
}
|
|
264
264
|
|
|
265
|
-
getKeyForSearch(search: string, fromKey?: Key) {
|
|
265
|
+
getKeyForSearch(search: string, fromKey?: Key): Node<T> | undefined | null {
|
|
266
266
|
if (!this.collator) {
|
|
267
267
|
return null;
|
|
268
268
|
}
|
package/src/CardViewContext.tsx
CHANGED
|
@@ -13,8 +13,15 @@
|
|
|
13
13
|
|
|
14
14
|
import React, {useContext} from 'react';
|
|
15
15
|
|
|
16
|
-
export
|
|
16
|
+
export interface CardViewContextValue {
|
|
17
|
+
state: 'idle' | 'loading' | 'error',
|
|
18
|
+
isQuiet: boolean,
|
|
19
|
+
layout: 'grid' | 'gallery' | 'waterfall',
|
|
20
|
+
cardOrientation: 'horizontal' | 'vertical',
|
|
21
|
+
renderEmptyState: () => React.ReactNode
|
|
22
|
+
}
|
|
23
|
+
export const CardViewContext = React.createContext<CardViewContextValue>(null);
|
|
17
24
|
|
|
18
|
-
export function useCardViewContext() {
|
|
25
|
+
export function useCardViewContext(): CardViewContextValue | null {
|
|
19
26
|
return useContext(CardViewContext);
|
|
20
27
|
}
|
package/src/GalleryLayout.tsx
CHANGED
|
@@ -87,7 +87,7 @@ export class GalleryLayout<T> extends BaseLayout<T> {
|
|
|
87
87
|
this.margin = options.margin != null ? options.margin : DEFAULT_OPTIONS[cardSize].margin;
|
|
88
88
|
}
|
|
89
89
|
|
|
90
|
-
get layoutType() {
|
|
90
|
+
get layoutType(): string {
|
|
91
91
|
return 'gallery';
|
|
92
92
|
}
|
|
93
93
|
|
|
@@ -96,7 +96,7 @@ export class GalleryLayout<T> extends BaseLayout<T> {
|
|
|
96
96
|
* the widest in the row until it can't give anymore, then move to the second widest and so forth.
|
|
97
97
|
* Do this until all assets meet the min-width.
|
|
98
98
|
* */
|
|
99
|
-
_distributeWidths(widths) {
|
|
99
|
+
_distributeWidths(widths: number[]): boolean {
|
|
100
100
|
// create a copy of the widths array and sort it largest to smallest
|
|
101
101
|
let sortedWidths = widths.concat().sort((a, b) => a[1] > b[1] ? -1 : 1);
|
|
102
102
|
for (let width of widths) {
|
|
@@ -134,7 +134,7 @@ export class GalleryLayout<T> extends BaseLayout<T> {
|
|
|
134
134
|
return true;
|
|
135
135
|
}
|
|
136
136
|
|
|
137
|
-
buildCollection() {
|
|
137
|
+
buildCollection(): void {
|
|
138
138
|
let visibleWidth = this.virtualizer.visibleRect.width;
|
|
139
139
|
let visibleHeight = this.virtualizer.visibleRect.height;
|
|
140
140
|
let y = this.margin;
|