@react-spectrum/card 3.0.0-alpha.37 → 3.0.0-alpha.39

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.
Files changed (55) hide show
  1. package/dist/BaseLayout.main.js +2 -2
  2. package/dist/BaseLayout.main.js.map +1 -1
  3. package/dist/BaseLayout.mjs +2 -2
  4. package/dist/BaseLayout.module.js +2 -2
  5. package/dist/BaseLayout.module.js.map +1 -1
  6. package/dist/Card.main.js +1 -0
  7. package/dist/Card.main.js.map +1 -1
  8. package/dist/Card.mjs +1 -0
  9. package/dist/Card.module.js +1 -0
  10. package/dist/Card.module.js.map +1 -1
  11. package/dist/CardBase.main.js +4 -6
  12. package/dist/CardBase.main.js.map +1 -1
  13. package/dist/CardBase.mjs +4 -6
  14. package/dist/CardBase.module.js +4 -6
  15. package/dist/CardBase.module.js.map +1 -1
  16. package/dist/CardView.main.js +4 -6
  17. package/dist/CardView.main.js.map +1 -1
  18. package/dist/CardView.mjs +4 -6
  19. package/dist/CardView.module.js +4 -6
  20. package/dist/CardView.module.js.map +1 -1
  21. package/dist/CardViewContext.main.js +1 -0
  22. package/dist/CardViewContext.main.js.map +1 -1
  23. package/dist/CardViewContext.mjs +1 -0
  24. package/dist/CardViewContext.module.js +1 -0
  25. package/dist/CardViewContext.module.js.map +1 -1
  26. package/dist/GalleryLayout.main.js +1 -0
  27. package/dist/GalleryLayout.main.js.map +1 -1
  28. package/dist/GalleryLayout.mjs +1 -0
  29. package/dist/GalleryLayout.module.js +1 -0
  30. package/dist/GalleryLayout.module.js.map +1 -1
  31. package/dist/GridLayout.main.js +1 -0
  32. package/dist/GridLayout.main.js.map +1 -1
  33. package/dist/GridLayout.mjs +1 -0
  34. package/dist/GridLayout.module.js +1 -0
  35. package/dist/GridLayout.module.js.map +1 -1
  36. package/dist/WaterfallLayout.main.js +1 -0
  37. package/dist/WaterfallLayout.main.js.map +1 -1
  38. package/dist/WaterfallLayout.mjs +1 -0
  39. package/dist/WaterfallLayout.module.js +1 -0
  40. package/dist/WaterfallLayout.module.js.map +1 -1
  41. package/dist/card_vars_css.main.js.map +1 -1
  42. package/dist/card_vars_css.module.js.map +1 -1
  43. package/dist/types.d.ts +17 -17
  44. package/dist/types.d.ts.map +1 -1
  45. package/dist/{vars.081f4c73.css → vars.02438011.css} +3 -3
  46. package/dist/{vars.081f4c73.css.map → vars.02438011.css.map} +1 -1
  47. package/package.json +20 -20
  48. package/src/BaseLayout.tsx +1 -0
  49. package/src/Card.tsx +1 -0
  50. package/src/CardBase.tsx +6 -8
  51. package/src/CardView.tsx +6 -8
  52. package/src/CardViewContext.tsx +1 -0
  53. package/src/GalleryLayout.tsx +1 -0
  54. package/src/GridLayout.tsx +1 -0
  55. package/src/WaterfallLayout.tsx +1 -0
@@ -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,C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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<HTMLDiv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MAAM;QACN,QAAQ;OACP,KAAK,QAAQ;AAItB","sources":["packages/@react-spectrum/card/src/CardView.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 {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\n/**\n * TODO: Add description of component here.\n */\nexport const CardView = React.forwardRef(function 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}) as <T>(props: SpectrumCardViewProps<T> & {ref?: DOMRef<HTMLDivElement>}) => ReactElement;\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"],"names":[],"version":3,"file":"CardView.main.js.map"}
package/dist/CardView.mjs CHANGED
@@ -1,7 +1,7 @@
1
1
  import {CardBase as $643dd8fa80926f94$export$7a6ccaf429ad93a8} from "./CardBase.mjs";
2
2
  import {CardViewContext as $8d180a244893de14$export$64992ac69f286e5c, useCardViewContext as $8d180a244893de14$export$fea0b38586ec8f13} from "./CardViewContext.mjs";
3
3
  import $iOsT7$intlStringsmodulejs from "./intlStrings.mjs";
4
- import "./vars.081f4c73.css";
4
+ import "./vars.02438011.css";
5
5
  import $iOsT7$card_vars_cssmodulejs from "./card_vars_css.mjs";
6
6
  import {useStyleProps as $iOsT7$useStyleProps, useDOMRef as $iOsT7$useDOMRef, classNames as $iOsT7$classNames, useUnwrapDOMRef as $iOsT7$useUnwrapDOMRef} from "@react-spectrum/utils";
7
7
  import {GridCollection as $iOsT7$GridCollection, useGridState as $iOsT7$useGridState} from "@react-stately/grid";
@@ -18,6 +18,7 @@ import {VirtualizerItem as $iOsT7$VirtualizerItem, Virtualizer as $iOsT7$Virtual
18
18
  function $parcel$interopDefault(a) {
19
19
  return a && a.__esModule ? a.default : a;
20
20
  }
21
+ // @ts-nocheck
21
22
  /*
22
23
  * Copyright 2021 Adobe. All rights reserved.
23
24
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -42,7 +43,7 @@ function $parcel$interopDefault(a) {
42
43
 
43
44
 
44
45
 
45
- function $81a52da995c19652$var$CardView(props, ref) {
46
+ const $81a52da995c19652$export$7e52c821f7b6f422 = /*#__PURE__*/ (0, $iOsT7$react).forwardRef(function CardView(props, ref) {
46
47
  let { scale: scale } = (0, $iOsT7$useProvider)();
47
48
  let { styleProps: styleProps } = (0, $iOsT7$useStyleProps)(props);
48
49
  let domRef = (0, $iOsT7$useDOMRef)(ref);
@@ -155,7 +156,7 @@ function $81a52da995c19652$var$CardView(props, ref) {
155
156
  else if (type === 'loader') return /*#__PURE__*/ (0, $iOsT7$react).createElement($81a52da995c19652$var$LoadingState, null);
156
157
  else if (type === 'placeholder') return /*#__PURE__*/ (0, $iOsT7$react).createElement($81a52da995c19652$var$EmptyState, null);
157
158
  }, [])));
158
- }
159
+ });
159
160
  function $81a52da995c19652$var$LoadingState() {
160
161
  let { state: state } = (0, $8d180a244893de14$export$fea0b38586ec8f13)();
161
162
  let stringFormatter = (0, $iOsT7$useLocalizedStringFormatter)((0, ($parcel$interopDefault($iOsT7$intlStringsmodulejs))), '@react-spectrum/card');
@@ -226,9 +227,6 @@ function $81a52da995c19652$var$InternalCard(props) {
226
227
  layout: layoutType
227
228
  }, item.rendered));
228
229
  }
229
- /**
230
- * TODO: Add description of component here.
231
- */ const $81a52da995c19652$export$7e52c821f7b6f422 = /*#__PURE__*/ (0, $iOsT7$react).forwardRef($81a52da995c19652$var$CardView);
232
230
 
233
231
 
234
232
  export {$81a52da995c19652$export$7e52c821f7b6f422 as CardView};
@@ -1,7 +1,7 @@
1
1
  import {CardBase as $643dd8fa80926f94$export$7a6ccaf429ad93a8} from "./CardBase.module.js";
2
2
  import {CardViewContext as $8d180a244893de14$export$64992ac69f286e5c, useCardViewContext as $8d180a244893de14$export$fea0b38586ec8f13} from "./CardViewContext.module.js";
3
3
  import $iOsT7$intlStringsmodulejs from "./intlStrings.module.js";
4
- import "./vars.081f4c73.css";
4
+ import "./vars.02438011.css";
5
5
  import $iOsT7$card_vars_cssmodulejs from "./card_vars_css.module.js";
6
6
  import {useStyleProps as $iOsT7$useStyleProps, useDOMRef as $iOsT7$useDOMRef, classNames as $iOsT7$classNames, useUnwrapDOMRef as $iOsT7$useUnwrapDOMRef} from "@react-spectrum/utils";
7
7
  import {GridCollection as $iOsT7$GridCollection, useGridState as $iOsT7$useGridState} from "@react-stately/grid";
@@ -18,6 +18,7 @@ import {VirtualizerItem as $iOsT7$VirtualizerItem, Virtualizer as $iOsT7$Virtual
18
18
  function $parcel$interopDefault(a) {
19
19
  return a && a.__esModule ? a.default : a;
20
20
  }
21
+ // @ts-nocheck
21
22
  /*
22
23
  * Copyright 2021 Adobe. All rights reserved.
23
24
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -42,7 +43,7 @@ function $parcel$interopDefault(a) {
42
43
 
43
44
 
44
45
 
45
- function $81a52da995c19652$var$CardView(props, ref) {
46
+ const $81a52da995c19652$export$7e52c821f7b6f422 = /*#__PURE__*/ (0, $iOsT7$react).forwardRef(function CardView(props, ref) {
46
47
  let { scale: scale } = (0, $iOsT7$useProvider)();
47
48
  let { styleProps: styleProps } = (0, $iOsT7$useStyleProps)(props);
48
49
  let domRef = (0, $iOsT7$useDOMRef)(ref);
@@ -155,7 +156,7 @@ function $81a52da995c19652$var$CardView(props, ref) {
155
156
  else if (type === 'loader') return /*#__PURE__*/ (0, $iOsT7$react).createElement($81a52da995c19652$var$LoadingState, null);
156
157
  else if (type === 'placeholder') return /*#__PURE__*/ (0, $iOsT7$react).createElement($81a52da995c19652$var$EmptyState, null);
157
158
  }, [])));
158
- }
159
+ });
159
160
  function $81a52da995c19652$var$LoadingState() {
160
161
  let { state: state } = (0, $8d180a244893de14$export$fea0b38586ec8f13)();
161
162
  let stringFormatter = (0, $iOsT7$useLocalizedStringFormatter)((0, ($parcel$interopDefault($iOsT7$intlStringsmodulejs))), '@react-spectrum/card');
@@ -226,9 +227,6 @@ function $81a52da995c19652$var$InternalCard(props) {
226
227
  layout: layoutType
227
228
  }, item.rendered));
228
229
  }
229
- /**
230
- * TODO: Add description of component here.
231
- */ const $81a52da995c19652$export$7e52c821f7b6f422 = /*#__PURE__*/ (0, $iOsT7$react).forwardRef($81a52da995c19652$var$CardView);
232
230
 
233
231
 
234
232
  export {$81a52da995c19652$export$7e52c821f7b6f422 as CardView};
@@ -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,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,Q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AI,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 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"}
1
+ {"mappings":";;;;;;;;;;;;;;;;;;;;AAAA,cAAc;AACd;;;;;;;;;;CAUC;;;;;;;;;;;;;;AAwBM,MAAM,0DAAW,CAAA,GAAA,YAAI,EAAE,UAAU,CAAC,SAAS,SAA2B,KAA+B,EAAE,GAA2B;IACvI,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;oBACjI,GAAG,IAAI;oBACP,eAAe;oBACf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BAC5D,gCAAC,CAAA,GAAA,yCAAO;QACN,KAAK;QACL,cAAc;QACd,SAAS;QACT,aAAa;QACb,MAAM;QACN,QAAQ;OACP,KAAK,QAAQ;AAItB","sources":["packages/@react-spectrum/card/src/CardView.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 {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\n/**\n * TODO: Add description of component here.\n */\nexport const CardView = React.forwardRef(function 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}) as <T>(props: SpectrumCardViewProps<T> & {ref?: DOMRef<HTMLDivElement>}) => ReactElement;\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"],"names":[],"version":3,"file":"CardView.module.js.map"}
@@ -11,6 +11,7 @@ function $parcel$export(e, n, v, s) {
11
11
 
12
12
  $parcel$export(module.exports, "CardViewContext", () => $e57ab98cef2f01a5$export$64992ac69f286e5c);
13
13
  $parcel$export(module.exports, "useCardViewContext", () => $e57ab98cef2f01a5$export$fea0b38586ec8f13);
14
+ // @ts-nocheck
14
15
  /*
15
16
  * Copyright 2020 Adobe. All rights reserved.
16
17
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;;;;AAAA;;;;;;;;;;CAUC;AAIM,MAAM,0DAAkB,CAAA,GAAA,sCAAI,EAAE,aAAa,CAAC;AAE5C,SAAS;IACd,OAAO,CAAA,GAAA,uBAAS,EAAE;AACpB","sources":["packages/@react-spectrum/card/src/CardViewContext.tsx"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport React, {useContext} from 'react';\n\nexport const CardViewContext = React.createContext(null);\n\nexport function useCardViewContext() {\n return useContext(CardViewContext);\n}\n"],"names":[],"version":3,"file":"CardViewContext.main.js.map"}
1
+ {"mappings":";;;;;;;;;;;;;AAAA,cAAc;AACd;;;;;;;;;;CAUC;AAIM,MAAM,0DAAkB,CAAA,GAAA,sCAAI,EAAE,aAAa,CAAC;AAE5C,SAAS;IACd,OAAO,CAAA,GAAA,uBAAS,EAAE;AACpB","sources":["packages/@react-spectrum/card/src/CardViewContext.tsx"],"sourcesContent":["// @ts-nocheck\n/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport React, {useContext} from 'react';\n\nexport const CardViewContext = React.createContext(null);\n\nexport function useCardViewContext() {\n return useContext(CardViewContext);\n}\n"],"names":[],"version":3,"file":"CardViewContext.main.js.map"}
@@ -1,5 +1,6 @@
1
1
  import $ip66o$react, {useContext as $ip66o$useContext} from "react";
2
2
 
3
+ // @ts-nocheck
3
4
  /*
4
5
  * Copyright 2020 Adobe. All rights reserved.
5
6
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -1,5 +1,6 @@
1
1
  import $ip66o$react, {useContext as $ip66o$useContext} from "react";
2
2
 
3
+ // @ts-nocheck
3
4
  /*
4
5
  * Copyright 2020 Adobe. All rights reserved.
5
6
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -1 +1 @@
1
- {"mappings":";;AAAA;;;;;;;;;;CAUC;AAIM,MAAM,0DAAkB,CAAA,GAAA,YAAI,EAAE,aAAa,CAAC;AAE5C,SAAS;IACd,OAAO,CAAA,GAAA,iBAAS,EAAE;AACpB","sources":["packages/@react-spectrum/card/src/CardViewContext.tsx"],"sourcesContent":["/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport React, {useContext} from 'react';\n\nexport const CardViewContext = React.createContext(null);\n\nexport function useCardViewContext() {\n return useContext(CardViewContext);\n}\n"],"names":[],"version":3,"file":"CardViewContext.module.js.map"}
1
+ {"mappings":";;AAAA,cAAc;AACd;;;;;;;;;;CAUC;AAIM,MAAM,0DAAkB,CAAA,GAAA,YAAI,EAAE,aAAa,CAAC;AAE5C,SAAS;IACd,OAAO,CAAA,GAAA,iBAAS,EAAE;AACpB","sources":["packages/@react-spectrum/card/src/CardViewContext.tsx"],"sourcesContent":["// @ts-nocheck\n/*\n * Copyright 2020 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\nimport React, {useContext} from 'react';\n\nexport const CardViewContext = React.createContext(null);\n\nexport function useCardViewContext() {\n return useContext(CardViewContext);\n}\n"],"names":[],"version":3,"file":"CardViewContext.module.js.map"}
@@ -7,6 +7,7 @@ function $parcel$export(e, n, v, s) {
7
7
  }
8
8
 
9
9
  $parcel$export(module.exports, "GalleryLayout", () => $8019a3d2c7d098ea$export$8e52095834484b61);
10
+ // @ts-nocheck
10
11
  /*
11
12
  * Copyright 2021 Adobe. All rights reserved.
12
13
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;AAAA;;;;;;;;;;CAUC;;AAsCD,MAAM,wCAAkB;IACtB,GAAG;QACD,gBAAgB;QAChB,aAAa,IAAI,CAAA,GAAA,mCAAG,EAAE,IAAI;QAC1B,aAAa,IAAI,CAAA,GAAA,mCAAG,EAAE,GAAG;QACzB,aAAa;QACb,aAAa;QACb,QAAQ;IACV;IACA,GAAG;QACD,gBAAgB;QAChB,aAAa,IAAI,CAAA,GAAA,mCAAG,EAAE,KAAK;QAC3B,aAAa,IAAI,CAAA,GAAA,mCAAG,EAAE,IAAI;QAC1B,aAAa;YACX,UAAU;YACV,SAAS;QACX;QACA,aAAa;QACb,QAAQ;IACV;AACF;AAEO,MAAM,kDAAyB,CAAA,GAAA,oCAAS;IAkB7C,IAAI,aAAa;QACf,OAAO;IACT;IAEA;;;;KAIG,GACH,kBAAkB,MAAM,EAAE;QACxB,oEAAoE;QACpE,IAAI,eAAe,OAAO,MAAM,GAAG,IAAI,CAAC,CAAC,GAAG,IAAM,C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AAI,EAAE;YACxB,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC,EAAE,GAAG,KAAK,CAAC,EAAE,CAAC,EAAE;YAClC,IAAI,OAAO,KAAK,GAAG,CAAC,IAAI;YAExB,IAAI,CAAC,KAAK,OAAO,YAAY;gBAC3B,aAAa;gBACb,OAAO;YACT;QACF;QAEA,KAAK,CAAC,EAAE,CAAC,EAAE,GAAG;QACd,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,GAAG;IAC3B;IAGF,IAAI,IAAI;IACR,IAAI,IAAI;IAER,IAAI,SAAS,EAAE;IACf,MAAO,KAAK,EAAG;QACb,IAAI,KAAK,GAAG;YACV,IAAI,MAAM,EAAE;YACZ,IAAK,IAAI,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC,EAAE,GAAG,GAAG,IAAI,IAAI,GAAG,IAC9C,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE;YAGjB,OAAO,OAAO,CAAC;YACf,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC,EAAE;QACxB;QAEA;IACF;IAEA,IAAI,MAAM,EAAE;IACZ,IAAK,IAAI,IAAI,GAAG,IAAI,IAAI,GAAG,IACzB,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE;IAGjB,OAAO,OAAO,CAAC;IAEf,OAAO;AACT","sources":["packages/@react-spectrum/card/src/GalleryLayout.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 {BaseLayout, BaseLayoutOptions} from './BaseLayout';\nimport {LayoutInfo, Rect, Size} from '@react-stately/virtualizer';\n\nexport interface GalleryLayoutOptions extends BaseLayoutOptions {\n // /**\n // * The card size in the grid.\n // */\n // cardSize?: 'S' | 'M' | 'L',\n /**\n * The the default row height. Note this must be larger than the min item height.\n * @default 208\n */\n idealRowHeight?: number,\n /**\n * The spacing between items.\n * @default 18 x 18\n */\n itemSpacing?: Size,\n /**\n * The vertical padding for an item.\n * @default 78\n */\n itemPadding?: number,\n /**\n * Minimum size for a item in the grid.\n * @default 136 x 136\n */\n minItemSize?: Size,\n /**\n * Target for adding extra weight to elements during linear partitioning. Anything with an aspect ratio smaler than this value\n * will be targeted.\n * @type {number}\n */\n threshold?: number\n}\n\nconst DEFAULT_OPTIONS = {\n S: {\n idealRowHeight: 112,\n minItemSize: new Size(96, 96),\n itemSpacing: new Size(8, 16),\n itemPadding: 24,\n dropSpacing: 50,\n margin: 8\n },\n L: {\n idealRowHeight: 208,\n minItemSize: new Size(136, 136),\n itemSpacing: new Size(18, 18),\n itemPadding: {\n 'medium': 78,\n 'large': 99\n },\n dropSpacing: 100,\n margin: 24\n }\n};\n\nexport class GalleryLayout<T> extends BaseLayout<T> {\n protected idealRowHeight: number;\n protected itemSpacing: Size;\n itemPadding: number;\n protected minItemSize: Size;\n protected threshold: number;\n\n constructor(options: GalleryLayoutOptions = {}) {\n super(options);\n let cardSize = 'L';\n this.idealRowHeight = options.idealRowHeight || DEFAULT_OPTIONS[cardSize].idealRowHeight;\n this.itemSpacing = options.itemSpacing || DEFAULT_OPTIONS[cardSize].itemSpacing;\n this.itemPadding = options.itemPadding != null ? options.itemPadding : DEFAULT_OPTIONS[cardSize].itemPadding[this.scale];\n this.minItemSize = options.minItemSize || DEFAULT_OPTIONS[cardSize].minItemSize;\n this.threshold = options.threshold || 1;\n this.margin = options.margin != null ? options.margin : DEFAULT_OPTIONS[cardSize].margin;\n }\n\n get layoutType() {\n return 'gallery';\n }\n\n /**\n * Takes a row of widths and if there are any widths smaller than the min-width, leech width starting from\n * the widest in the row until it can't give anymore, then move to the second widest and so forth.\n * Do this until all assets meet the min-width.\n * */\n _distributeWidths(widths) {\n // create a copy of the widths array and sort it largest to smallest\n let sortedWidths = widths.concat().sort((a, b) => a[1] > b[1] ? -1 : 1);\n for (let width of widths) {\n // for each width, if it's smaller than the min width\n if (width[1] < this.minItemSize.width) {\n // then figure out how much smaller\n let delta = this.minItemSize.width - width[1];\n for (let item of sortedWidths) {\n // go from the largest width in the row to the smallest\n // if the width is greater than the min width\n if (widths[item[0]][1] > this.minItemSize.width) {\n // subtract the delta from the width, if it's still greater than the min width\n // then we have finished, subtract the delta permanently from that width\n // eslint-disable-next-line max-depth\n if (widths[item[0]][1] - delta > this.minItemSize.width) {\n widths[item[0]][1] -= delta;\n delta = 0;\n break;\n } else {\n // otherwise, we take as much as we can from the current width and then move on to\n // the next largest and take some width from it\n let maxChange = widths[item[0]][1] - this.minItemSize.width;\n delta -= maxChange;\n widths[item[0]][1] -= maxChange;\n }\n }\n }\n if (delta > 0) {\n return false;\n }\n // force the width to be the min width that we just rebalanced for\n width[1] = this.minItemSize.width;\n }\n }\n return true;\n }\n\n buildCollection() {\n let visibleWidth = this.virtualizer.visibleRect.width;\n let visibleHeight = this.virtualizer.visibleRect.height;\n let y = this.margin;\n let availableWidth = visibleWidth - this.margin * 2;\n\n // If available width is not greater than 0, skip node layout calculations\n if (availableWidth > 0) {\n // Compute aspect ratios for all of the items, and the total width if all items were on in a single row.\n let ratios = [];\n let totalWidth = 0;\n let minRatio = this.minItemSize.width / this.minItemSize.height;\n let maxRatio = availableWidth / this.minItemSize.height;\n\n for (let node of this.collection) {\n let ratio = node.props.width / node.props.height;\n if (ratio < minRatio) {\n ratio = minRatio;\n } else if (ratio > maxRatio && ratio !== minRatio) {\n ratio = maxRatio;\n }\n\n let itemWidth = ratio * this.minItemSize.height;\n ratios.push(ratio);\n totalWidth += itemWidth;\n }\n\n totalWidth += this.itemSpacing.width * (this.collection.size - 1);\n\n // Determine how many rows we'll need, and partition the items into rows\n // using the aspect ratios as weights.\n let rows = Math.max(1, Math.ceil(totalWidth / availableWidth));\n // if the available width can't hold two items, then every item will get its own row\n // this leads to a faster run through linear partition and more dependable output for small row widths\n if (availableWidth <= (this.minItemSize.width * 2) + (this.itemPadding * 2)) {\n rows = this.collection.size;\n }\n\n let weightedRatios = ratios.map(ratio => ratio < this.threshold ? ratio + (0.5 * (1 / ratio)) : ratio);\n let partition = linearPartition(weightedRatios, rows);\n\n let index = 0;\n for (let row of partition) {\n // Compute the total weight for this row\n let totalWeight = 0;\n for (let j = index; j < index + row.length; j++) {\n totalWeight += ratios[j];\n }\n\n // Determine the row height based on the total available width and weight of this row.\n let bestRowHeight = (availableWidth - (row.length - 1) * this.itemSpacing.width) / totalWeight;\n\n // if this is the last row and the row height is >2x the ideal row height, then cap to the ideal height\n // probably doing this because if the last row has one extremely tall image, then the row becomes huge\n // though that can happen anywhere if a row has lots of tall images... so i'm not sure why this one matters\n if (row === partition[partition.length - 1] && bestRowHeight > this.idealRowHeight * 2) {\n bestRowHeight = this.idealRowHeight;\n }\n let itemHeight = Math.round(bestRowHeight) + this.itemPadding;\n let x = this.margin;\n\n // if any items are going to end up too small, add a bit of width to them and subtract it from wider objects\n let widths = [];\n for (let j = index; j < index + row.length; j++) {\n let width = Math.round(bestRowHeight * ratios[j]);\n widths.push([j - index, width]);\n }\n this._distributeWidths(widths);\n\n // Create items for this row.\n for (let j = index; j < index + row.length; j++) {\n let node = this.collection.rows[j];\n let itemWidth = Math.max(widths[j - index][1], this.minItemSize.width);\n let rect = new Rect(x, y, itemWidth, itemHeight);\n let layoutInfo = new LayoutInfo(node.type, node.key, rect);\n layoutInfo.allowOverflow = true;\n this.layoutInfos.set(node.key, layoutInfo);\n x += itemWidth + this.itemSpacing.width;\n }\n\n y += itemHeight + this.itemSpacing.height;\n index += row.length;\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 available 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\n// https://www8.cs.umu.se/kurser/TDBA77/VT06/algorithms/BOOK/BOOK2/NODE45.HTM\nfunction linearPartition(seq, k) {\n let n = seq.length;\n if (k <= 0) {\n return [];\n }\n\n if (k >= n) {\n return seq.map(x => [x]);\n }\n\n if (n === 1) {\n return [seq];\n }\n\n let table = Array(n).fill(0).map(() => Array(k).fill(0));\n let solution = Array(n - 1).fill(0).map(() => Array(k - 1).fill(0));\n\n for (let i = 0; i < n; i++) {\n table[i][0] = seq[i] + (i > 0 ? table[i - 1][0] : 0);\n }\n\n for (let i = 0; i < k; i++) {\n table[0][i] = seq[0];\n }\n\n for (let i = 1; i < n; i++) {\n for (let j = 1; j < k; j++) {\n let currentMin = 0;\n let minX = Infinity;\n\n for (let x = 0; x < i; x++) {\n let c1 = table[x][j - 1];\n let c2 = table[i][0] - table[x][0];\n let cost = Math.max(c1, c2);\n\n if (!x || cost < currentMin) {\n currentMin = cost;\n minX = x;\n }\n }\n\n table[i][j] = currentMin;\n solution[i - 1][j - 1] = minX;\n }\n }\n\n n = n - 1;\n k = k - 2;\n\n let result = [];\n while (k >= 0) {\n if (n >= 1) {\n let row = [];\n for (let i = solution[n - 1][k] + 1; i < n + 1; i++) {\n row.push(seq[i]);\n }\n\n result.unshift(row);\n n = solution[n - 1][k];\n }\n\n k--;\n }\n\n let row = [];\n for (let i = 0; i < n + 1; i++) {\n row.push(seq[i]);\n }\n\n result.unshift(row);\n\n return result;\n}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AC,GAAG,CAAC,EAAE;YAGjB,OAAO,OAAO,CAAC;YACf,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC,EAAE;QACxB;QAEA;IACF;IAEA,IAAI,MAAM,EAAE;IACZ,IAAK,IAAI,IAAI,GAAG,IAAI,IAAI,GAAG,IACzB,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE;IAGjB,OAAO,OAAO,CAAC;IAEf,OAAO;AACT","sources":["packages/@react-spectrum/card/src/GalleryLayout.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 {LayoutInfo, Rect, Size} from '@react-stately/virtualizer';\n\nexport interface GalleryLayoutOptions extends BaseLayoutOptions {\n // /**\n // * The card size in the grid.\n // */\n // cardSize?: 'S' | 'M' | 'L',\n /**\n * The the default row height. Note this must be larger than the min item height.\n * @default 208\n */\n idealRowHeight?: number,\n /**\n * The spacing between items.\n * @default 18 x 18\n */\n itemSpacing?: Size,\n /**\n * The vertical padding for an item.\n * @default 78\n */\n itemPadding?: number,\n /**\n * Minimum size for a item in the grid.\n * @default 136 x 136\n */\n minItemSize?: Size,\n /**\n * Target for adding extra weight to elements during linear partitioning. Anything with an aspect ratio smaler than this value\n * will be targeted.\n * @type {number}\n */\n threshold?: number\n}\n\nconst DEFAULT_OPTIONS = {\n S: {\n idealRowHeight: 112,\n minItemSize: new Size(96, 96),\n itemSpacing: new Size(8, 16),\n itemPadding: 24,\n dropSpacing: 50,\n margin: 8\n },\n L: {\n idealRowHeight: 208,\n minItemSize: new Size(136, 136),\n itemSpacing: new Size(18, 18),\n itemPadding: {\n 'medium': 78,\n 'large': 99\n },\n dropSpacing: 100,\n margin: 24\n }\n};\n\nexport class GalleryLayout<T> extends BaseLayout<T> {\n protected idealRowHeight: number;\n protected itemSpacing: Size;\n itemPadding: number;\n protected minItemSize: Size;\n protected threshold: number;\n\n constructor(options: GalleryLayoutOptions = {}) {\n super(options);\n let cardSize = 'L';\n this.idealRowHeight = options.idealRowHeight || DEFAULT_OPTIONS[cardSize].idealRowHeight;\n this.itemSpacing = options.itemSpacing || DEFAULT_OPTIONS[cardSize].itemSpacing;\n this.itemPadding = options.itemPadding != null ? options.itemPadding : DEFAULT_OPTIONS[cardSize].itemPadding[this.scale];\n this.minItemSize = options.minItemSize || DEFAULT_OPTIONS[cardSize].minItemSize;\n this.threshold = options.threshold || 1;\n this.margin = options.margin != null ? options.margin : DEFAULT_OPTIONS[cardSize].margin;\n }\n\n get layoutType() {\n return 'gallery';\n }\n\n /**\n * Takes a row of widths and if there are any widths smaller than the min-width, leech width starting from\n * the widest in the row until it can't give anymore, then move to the second widest and so forth.\n * Do this until all assets meet the min-width.\n * */\n _distributeWidths(widths) {\n // create a copy of the widths array and sort it largest to smallest\n let sortedWidths = widths.concat().sort((a, b) => a[1] > b[1] ? -1 : 1);\n for (let width of widths) {\n // for each width, if it's smaller than the min width\n if (width[1] < this.minItemSize.width) {\n // then figure out how much smaller\n let delta = this.minItemSize.width - width[1];\n for (let item of sortedWidths) {\n // go from the largest width in the row to the smallest\n // if the width is greater than the min width\n if (widths[item[0]][1] > this.minItemSize.width) {\n // subtract the delta from the width, if it's still greater than the min width\n // then we have finished, subtract the delta permanently from that width\n // eslint-disable-next-line max-depth\n if (widths[item[0]][1] - delta > this.minItemSize.width) {\n widths[item[0]][1] -= delta;\n delta = 0;\n break;\n } else {\n // otherwise, we take as much as we can from the current width and then move on to\n // the next largest and take some width from it\n let maxChange = widths[item[0]][1] - this.minItemSize.width;\n delta -= maxChange;\n widths[item[0]][1] -= maxChange;\n }\n }\n }\n if (delta > 0) {\n return false;\n }\n // force the width to be the min width that we just rebalanced for\n width[1] = this.minItemSize.width;\n }\n }\n return true;\n }\n\n buildCollection() {\n let visibleWidth = this.virtualizer.visibleRect.width;\n let visibleHeight = this.virtualizer.visibleRect.height;\n let y = this.margin;\n let availableWidth = visibleWidth - this.margin * 2;\n\n // If available width is not greater than 0, skip node layout calculations\n if (availableWidth > 0) {\n // Compute aspect ratios for all of the items, and the total width if all items were on in a single row.\n let ratios = [];\n let totalWidth = 0;\n let minRatio = this.minItemSize.width / this.minItemSize.height;\n let maxRatio = availableWidth / this.minItemSize.height;\n\n for (let node of this.collection) {\n let ratio = node.props.width / node.props.height;\n if (ratio < minRatio) {\n ratio = minRatio;\n } else if (ratio > maxRatio && ratio !== minRatio) {\n ratio = maxRatio;\n }\n\n let itemWidth = ratio * this.minItemSize.height;\n ratios.push(ratio);\n totalWidth += itemWidth;\n }\n\n totalWidth += this.itemSpacing.width * (this.collection.size - 1);\n\n // Determine how many rows we'll need, and partition the items into rows\n // using the aspect ratios as weights.\n let rows = Math.max(1, Math.ceil(totalWidth / availableWidth));\n // if the available width can't hold two items, then every item will get its own row\n // this leads to a faster run through linear partition and more dependable output for small row widths\n if (availableWidth <= (this.minItemSize.width * 2) + (this.itemPadding * 2)) {\n rows = this.collection.size;\n }\n\n let weightedRatios = ratios.map(ratio => ratio < this.threshold ? ratio + (0.5 * (1 / ratio)) : ratio);\n let partition = linearPartition(weightedRatios, rows);\n\n let index = 0;\n for (let row of partition) {\n // Compute the total weight for this row\n let totalWeight = 0;\n for (let j = index; j < index + row.length; j++) {\n totalWeight += ratios[j];\n }\n\n // Determine the row height based on the total available width and weight of this row.\n let bestRowHeight = (availableWidth - (row.length - 1) * this.itemSpacing.width) / totalWeight;\n\n // if this is the last row and the row height is >2x the ideal row height, then cap to the ideal height\n // probably doing this because if the last row has one extremely tall image, then the row becomes huge\n // though that can happen anywhere if a row has lots of tall images... so i'm not sure why this one matters\n if (row === partition[partition.length - 1] && bestRowHeight > this.idealRowHeight * 2) {\n bestRowHeight = this.idealRowHeight;\n }\n let itemHeight = Math.round(bestRowHeight) + this.itemPadding;\n let x = this.margin;\n\n // if any items are going to end up too small, add a bit of width to them and subtract it from wider objects\n let widths = [];\n for (let j = index; j < index + row.length; j++) {\n let width = Math.round(bestRowHeight * ratios[j]);\n widths.push([j - index, width]);\n }\n this._distributeWidths(widths);\n\n // Create items for this row.\n for (let j = index; j < index + row.length; j++) {\n let node = this.collection.rows[j];\n let itemWidth = Math.max(widths[j - index][1], this.minItemSize.width);\n let rect = new Rect(x, y, itemWidth, itemHeight);\n let layoutInfo = new LayoutInfo(node.type, node.key, rect);\n layoutInfo.allowOverflow = true;\n this.layoutInfos.set(node.key, layoutInfo);\n x += itemWidth + this.itemSpacing.width;\n }\n\n y += itemHeight + this.itemSpacing.height;\n index += row.length;\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 available 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\n// https://www8.cs.umu.se/kurser/TDBA77/VT06/algorithms/BOOK/BOOK2/NODE45.HTM\nfunction linearPartition(seq, k) {\n let n = seq.length;\n if (k <= 0) {\n return [];\n }\n\n if (k >= n) {\n return seq.map(x => [x]);\n }\n\n if (n === 1) {\n return [seq];\n }\n\n let table = Array(n).fill(0).map(() => Array(k).fill(0));\n let solution = Array(n - 1).fill(0).map(() => Array(k - 1).fill(0));\n\n for (let i = 0; i < n; i++) {\n table[i][0] = seq[i] + (i > 0 ? table[i - 1][0] : 0);\n }\n\n for (let i = 0; i < k; i++) {\n table[0][i] = seq[0];\n }\n\n for (let i = 1; i < n; i++) {\n for (let j = 1; j < k; j++) {\n let currentMin = 0;\n let minX = Infinity;\n\n for (let x = 0; x < i; x++) {\n let c1 = table[x][j - 1];\n let c2 = table[i][0] - table[x][0];\n let cost = Math.max(c1, c2);\n\n if (!x || cost < currentMin) {\n currentMin = cost;\n minX = x;\n }\n }\n\n table[i][j] = currentMin;\n solution[i - 1][j - 1] = minX;\n }\n }\n\n n = n - 1;\n k = k - 2;\n\n let result = [];\n while (k >= 0) {\n if (n >= 1) {\n let row = [];\n for (let i = solution[n - 1][k] + 1; i < n + 1; i++) {\n row.push(seq[i]);\n }\n\n result.unshift(row);\n n = solution[n - 1][k];\n }\n\n k--;\n }\n\n let row = [];\n for (let i = 0; i < n + 1; i++) {\n row.push(seq[i]);\n }\n\n result.unshift(row);\n\n return result;\n}\n"],"names":[],"version":3,"file":"GalleryLayout.main.js.map"}
@@ -1,6 +1,7 @@
1
1
  import {BaseLayout as $3d424c147206bac9$export$64943d2e59d72a29} from "./BaseLayout.mjs";
2
2
  import {Size as $lQvIB$Size, Rect as $lQvIB$Rect, LayoutInfo as $lQvIB$LayoutInfo} from "@react-stately/virtualizer";
3
3
 
4
+ // @ts-nocheck
4
5
  /*
5
6
  * Copyright 2021 Adobe. All rights reserved.
6
7
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -1,6 +1,7 @@
1
1
  import {BaseLayout as $3d424c147206bac9$export$64943d2e59d72a29} from "./BaseLayout.module.js";
2
2
  import {Size as $lQvIB$Size, Rect as $lQvIB$Rect, LayoutInfo as $lQvIB$LayoutInfo} from "@react-stately/virtualizer";
3
3
 
4
+ // @ts-nocheck
4
5
  /*
5
6
  * Copyright 2021 Adobe. All rights reserved.
6
7
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -1 +1 @@
1
- {"mappings":";;;AAAA;;;;;;;;;;CAUC;;AAsCD,MAAM,wCAAkB;IACtB,GAAG;QACD,gBAAgB;QAChB,aAAa,IAAI,CAAA,GAAA,WAAG,EAAE,IAAI;QAC1B,aAAa,IAAI,CAAA,GAAA,WAAG,EAAE,GAAG;QACzB,aAAa;QACb,aAAa;QACb,QAAQ;IACV;IACA,GAAG;QACD,gBAAgB;QAChB,aAAa,IAAI,CAAA,GAAA,WAAG,EAAE,KAAK;QAC3B,aAAa,IAAI,CAAA,GAAA,WAAG,EAAE,IAAI;QAC1B,aAAa;YACX,UAAU;YACV,SAAS;QACX;QACA,aAAa;QACb,QAAQ;IACV;AACF;AAEO,MAAM,kDAAyB,CAAA,GAAA,yCAAS;IAkB7C,IAAI,aAAa;QACf,OAAO;IACT;IAEA;;;;KAIG,GACH,kBAAkB,MAAM,EAAE;QACxB,oEAAoE;QACpE,IAAI,eAAe,OAAO,MAAM,GAAG,IAAI,CAAC,CAAC,GAAG,IAAM,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,GAAG,KAAK;QACrE,KAAK,IAAI,SAAS,OAChB,qDAAqD;QACrD,IAAI,KAAK,CAAC,EAAE,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE;YACrC,mCAAmC;YACnC,IAAI,QAAQ,IAAI,CAAC,WAAW,CAAC,KAAK,GAAG,KAAK,CAAC,EAAE;YAC7C,KAAK,IAAI,QAAQ,aACf,uDAAuD;YACvD,6CAA6C;YAC7C,IAAI,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,WAAW,CAAC,KAAK;gBAC7C,8EAA8E;gBAC9E,wEAAwE;gBACxE,qCAAqC;gBACrC,IAAI,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,GAAG,QAAQ,IAAI,CAAC,WAAW,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CAAC,GAAG,CAAC,EAAE;YAGjB,OAAO,OAAO,CAAC;YACf,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC,EAAE;QACxB;QAEA;IACF;IAEA,IAAI,MAAM,EAAE;IACZ,IAAK,IAAI,IAAI,GAAG,IAAI,IAAI,GAAG,IACzB,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE;IAGjB,OAAO,OAAO,CAAC;IAEf,OAAO;AACT","sources":["packages/@react-spectrum/card/src/GalleryLayout.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 {BaseLayout, BaseLayoutOptions} from './BaseLayout';\nimport {LayoutInfo, Rect, Size} from '@react-stately/virtualizer';\n\nexport interface GalleryLayoutOptions extends BaseLayoutOptions {\n // /**\n // * The card size in the grid.\n // */\n // cardSize?: 'S' | 'M' | 'L',\n /**\n * The the default row height. Note this must be larger than the min item height.\n * @default 208\n */\n idealRowHeight?: number,\n /**\n * The spacing between items.\n * @default 18 x 18\n */\n itemSpacing?: Size,\n /**\n * The vertical padding for an item.\n * @default 78\n */\n itemPadding?: number,\n /**\n * Minimum size for a item in the grid.\n * @default 136 x 136\n */\n minItemSize?: Size,\n /**\n * Target for adding extra weight to elements during linear partitioning. Anything with an aspect ratio smaler than this value\n * will be targeted.\n * @type {number}\n */\n threshold?: number\n}\n\nconst DEFAULT_OPTIONS = {\n S: {\n idealRowHeight: 112,\n minItemSize: new Size(96, 96),\n itemSpacing: new Size(8, 16),\n itemPadding: 24,\n dropSpacing: 50,\n margin: 8\n },\n L: {\n idealRowHeight: 208,\n minItemSize: new Size(136, 136),\n itemSpacing: new Size(18, 18),\n itemPadding: {\n 'medium': 78,\n 'large': 99\n },\n dropSpacing: 100,\n margin: 24\n }\n};\n\nexport class GalleryLayout<T> extends BaseLayout<T> {\n protected idealRowHeight: number;\n protected itemSpacing: Size;\n itemPadding: number;\n protected minItemSize: Size;\n protected threshold: number;\n\n constructor(options: GalleryLayoutOptions = {}) {\n super(options);\n let cardSize = 'L';\n this.idealRowHeight = options.idealRowHeight || DEFAULT_OPTIONS[cardSize].idealRowHeight;\n this.itemSpacing = options.itemSpacing || DEFAULT_OPTIONS[cardSize].itemSpacing;\n this.itemPadding = options.itemPadding != null ? options.itemPadding : DEFAULT_OPTIONS[cardSize].itemPadding[this.scale];\n this.minItemSize = options.minItemSize || DEFAULT_OPTIONS[cardSize].minItemSize;\n this.threshold = options.threshold || 1;\n this.margin = options.margin != null ? options.margin : DEFAULT_OPTIONS[cardSize].margin;\n }\n\n get layoutType() {\n return 'gallery';\n }\n\n /**\n * Takes a row of widths and if there are any widths smaller than the min-width, leech width starting from\n * the widest in the row until it can't give anymore, then move to the second widest and so forth.\n * Do this until all assets meet the min-width.\n * */\n _distributeWidths(widths) {\n // create a copy of the widths array and sort it largest to smallest\n let sortedWidths = widths.concat().sort((a, b) => a[1] > b[1] ? -1 : 1);\n for (let width of widths) {\n // for each width, if it's smaller than the min width\n if (width[1] < this.minItemSize.width) {\n // then figure out how much smaller\n let delta = this.minItemSize.width - width[1];\n for (let item of sortedWidths) {\n // go from the largest width in the row to the smallest\n // if the width is greater than the min width\n if (widths[item[0]][1] > this.minItemSize.width) {\n // subtract the delta from the width, if it's still greater than the min width\n // then we have finished, subtract the delta permanently from that width\n // eslint-disable-next-line max-depth\n if (widths[item[0]][1] - delta > this.minItemSize.width) {\n widths[item[0]][1] -= delta;\n delta = 0;\n break;\n } else {\n // otherwise, we take as much as we can from the current width and then move on to\n // the next largest and take some width from it\n let maxChange = widths[item[0]][1] - this.minItemSize.width;\n delta -= maxChange;\n widths[item[0]][1] -= maxChange;\n }\n }\n }\n if (delta > 0) {\n return false;\n }\n // force the width to be the min width that we just rebalanced for\n width[1] = this.minItemSize.width;\n }\n }\n return true;\n }\n\n buildCollection() {\n let visibleWidth = this.virtualizer.visibleRect.width;\n let visibleHeight = this.virtualizer.visibleRect.height;\n let y = this.margin;\n let availableWidth = visibleWidth - this.margin * 2;\n\n // If available width is not greater than 0, skip node layout calculations\n if (availableWidth > 0) {\n // Compute aspect ratios for all of the items, and the total width if all items were on in a single row.\n let ratios = [];\n let totalWidth = 0;\n let minRatio = this.minItemSize.width / this.minItemSize.height;\n let maxRatio = availableWidth / this.minItemSize.height;\n\n for (let node of this.collection) {\n let ratio = node.props.width / node.props.height;\n if (ratio < minRatio) {\n ratio = minRatio;\n } else if (ratio > maxRatio && ratio !== minRatio) {\n ratio = maxRatio;\n }\n\n let itemWidth = ratio * this.minItemSize.height;\n ratios.push(ratio);\n totalWidth += itemWidth;\n }\n\n totalWidth += this.itemSpacing.width * (this.collection.size - 1);\n\n // Determine how many rows we'll need, and partition the items into rows\n // using the aspect ratios as weights.\n let rows = Math.max(1, Math.ceil(totalWidth / availableWidth));\n // if the available width can't hold two items, then every item will get its own row\n // this leads to a faster run through linear partition and more dependable output for small row widths\n if (availableWidth <= (this.minItemSize.width * 2) + (this.itemPadding * 2)) {\n rows = this.collection.size;\n }\n\n let weightedRatios = ratios.map(ratio => ratio < this.threshold ? ratio + (0.5 * (1 / ratio)) : ratio);\n let partition = linearPartition(weightedRatios, rows);\n\n let index = 0;\n for (let row of partition) {\n // Compute the total weight for this row\n let totalWeight = 0;\n for (let j = index; j < index + row.length; j++) {\n totalWeight += ratios[j];\n }\n\n // Determine the row height based on the total available width and weight of this row.\n let bestRowHeight = (availableWidth - (row.length - 1) * this.itemSpacing.width) / totalWeight;\n\n // if this is the last row and the row height is >2x the ideal row height, then cap to the ideal height\n // probably doing this because if the last row has one extremely tall image, then the row becomes huge\n // though that can happen anywhere if a row has lots of tall images... so i'm not sure why this one matters\n if (row === partition[partition.length - 1] && bestRowHeight > this.idealRowHeight * 2) {\n bestRowHeight = this.idealRowHeight;\n }\n let itemHeight = Math.round(bestRowHeight) + this.itemPadding;\n let x = this.margin;\n\n // if any items are going to end up too small, add a bit of width to them and subtract it from wider objects\n let widths = [];\n for (let j = index; j < index + row.length; j++) {\n let width = Math.round(bestRowHeight * ratios[j]);\n widths.push([j - index, width]);\n }\n this._distributeWidths(widths);\n\n // Create items for this row.\n for (let j = index; j < index + row.length; j++) {\n let node = this.collection.rows[j];\n let itemWidth = Math.max(widths[j - index][1], this.minItemSize.width);\n let rect = new Rect(x, y, itemWidth, itemHeight);\n let layoutInfo = new LayoutInfo(node.type, node.key, rect);\n layoutInfo.allowOverflow = true;\n this.layoutInfos.set(node.key, layoutInfo);\n x += itemWidth + this.itemSpacing.width;\n }\n\n y += itemHeight + this.itemSpacing.height;\n index += row.length;\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 available 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\n// https://www8.cs.umu.se/kurser/TDBA77/VT06/algorithms/BOOK/BOOK2/NODE45.HTM\nfunction linearPartition(seq, k) {\n let n = seq.length;\n if (k <= 0) {\n return [];\n }\n\n if (k >= n) {\n return seq.map(x => [x]);\n }\n\n if (n === 1) {\n return [seq];\n }\n\n let table = Array(n).fill(0).map(() => Array(k).fill(0));\n let solution = Array(n - 1).fill(0).map(() => Array(k - 1).fill(0));\n\n for (let i = 0; i < n; i++) {\n table[i][0] = seq[i] + (i > 0 ? table[i - 1][0] : 0);\n }\n\n for (let i = 0; i < k; i++) {\n table[0][i] = seq[0];\n }\n\n for (let i = 1; i < n; i++) {\n for (let j = 1; j < k; j++) {\n let currentMin = 0;\n let minX = Infinity;\n\n for (let x = 0; x < i; x++) {\n let c1 = table[x][j - 1];\n let c2 = table[i][0] - table[x][0];\n let cost = Math.max(c1, c2);\n\n if (!x || cost < currentMin) {\n currentMin = cost;\n minX = x;\n }\n }\n\n table[i][j] = currentMin;\n solution[i - 1][j - 1] = minX;\n }\n }\n\n n = n - 1;\n k = k - 2;\n\n let result = [];\n while (k >= 0) {\n if (n >= 1) {\n let row = [];\n for (let i = solution[n - 1][k] + 1; i < n + 1; i++) {\n row.push(seq[i]);\n }\n\n result.unshift(row);\n n = solution[n - 1][k];\n }\n\n k--;\n }\n\n let row = [];\n for (let i = 0; i < n + 1; i++) {\n row.push(seq[i]);\n }\n\n result.unshift(row);\n\n return result;\n}\n"],"names":[],"version":3,"file":"GalleryLayout.module.js.map"}
1
+ {"mappings":";;;AAAA,cAAc;AACd;;;;;;;;;;CAUC;;AAsCD,MAAM,wCAAkB;IACtB,GAAG;QACD,gBAAgB;QAChB,aAAa,IAAI,CAAA,GAAA,WAAG,EAAE,IAAI;QAC1B,aAAa,IAAI,CAAA,GAAA,WAAG,EAAE,GAAG;QACzB,aAAa;QACb,aAAa;QACb,QAAQ;IACV;IACA,GAAG;QACD,gBAAgB;QAChB,aAAa,IAAI,CAAA,GAAA,WAAG,EAAE,KAAK;QAC3B,aAAa,IAAI,CAAA,GAAA,WAAG,EAAE,IAAI;QAC1B,aAAa;YACX,UAAU;YACV,SAAS;QACX;QACA,aAAa;QACb,QAAQ;IACV;AACF;AAEO,MAAM,kDAAyB,CAAA,GAAA,yCAAS;IAkB7C,IAAI,aAAa;QACf,OAAO;IACT;IAEA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a;QACjB,IAAI,OAAO;QAEX,IAAK,IAAI,IAAI,GAAG,IAAI,GAAG,IAAK;YAC1B,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC,IAAI,EAAE;YACxB,IAAI,KAAK,KAAK,CAAC,EAAE,CAAC,EAAE,GAAG,KAAK,CAAC,EAAE,CAAC,EAAE;YAClC,IAAI,OAAO,KAAK,GAAG,CAAC,IAAI;YAExB,IAAI,CAAC,KAAK,OAAO,YAAY;gBAC3B,aAAa;gBACb,OAAO;YACT;QACF;QAEA,KAAK,CAAC,EAAE,CAAC,EAAE,GAAG;QACd,QAAQ,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,GAAG;IAC3B;IAGF,IAAI,IAAI;IACR,IAAI,IAAI;IAER,IAAI,SAAS,EAAE;IACf,MAAO,KAAK,EAAG;QACb,IAAI,KAAK,GAAG;YACV,IAAI,MAAM,EAAE;YACZ,IAAK,IAAI,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC,EAAE,GAAG,GAAG,IAAI,IAAI,GAAG,IAC9C,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE;YAGjB,OAAO,OAAO,CAAC;YACf,IAAI,QAAQ,CAAC,IAAI,EAAE,CAAC,EAAE;QACxB;QAEA;IACF;IAEA,IAAI,MAAM,EAAE;IACZ,IAAK,IAAI,IAAI,GAAG,IAAI,IAAI,GAAG,IACzB,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE;IAGjB,OAAO,OAAO,CAAC;IAEf,OAAO;AACT","sources":["packages/@react-spectrum/card/src/GalleryLayout.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 {LayoutInfo, Rect, Size} from '@react-stately/virtualizer';\n\nexport interface GalleryLayoutOptions extends BaseLayoutOptions {\n // /**\n // * The card size in the grid.\n // */\n // cardSize?: 'S' | 'M' | 'L',\n /**\n * The the default row height. Note this must be larger than the min item height.\n * @default 208\n */\n idealRowHeight?: number,\n /**\n * The spacing between items.\n * @default 18 x 18\n */\n itemSpacing?: Size,\n /**\n * The vertical padding for an item.\n * @default 78\n */\n itemPadding?: number,\n /**\n * Minimum size for a item in the grid.\n * @default 136 x 136\n */\n minItemSize?: Size,\n /**\n * Target for adding extra weight to elements during linear partitioning. Anything with an aspect ratio smaler than this value\n * will be targeted.\n * @type {number}\n */\n threshold?: number\n}\n\nconst DEFAULT_OPTIONS = {\n S: {\n idealRowHeight: 112,\n minItemSize: new Size(96, 96),\n itemSpacing: new Size(8, 16),\n itemPadding: 24,\n dropSpacing: 50,\n margin: 8\n },\n L: {\n idealRowHeight: 208,\n minItemSize: new Size(136, 136),\n itemSpacing: new Size(18, 18),\n itemPadding: {\n 'medium': 78,\n 'large': 99\n },\n dropSpacing: 100,\n margin: 24\n }\n};\n\nexport class GalleryLayout<T> extends BaseLayout<T> {\n protected idealRowHeight: number;\n protected itemSpacing: Size;\n itemPadding: number;\n protected minItemSize: Size;\n protected threshold: number;\n\n constructor(options: GalleryLayoutOptions = {}) {\n super(options);\n let cardSize = 'L';\n this.idealRowHeight = options.idealRowHeight || DEFAULT_OPTIONS[cardSize].idealRowHeight;\n this.itemSpacing = options.itemSpacing || DEFAULT_OPTIONS[cardSize].itemSpacing;\n this.itemPadding = options.itemPadding != null ? options.itemPadding : DEFAULT_OPTIONS[cardSize].itemPadding[this.scale];\n this.minItemSize = options.minItemSize || DEFAULT_OPTIONS[cardSize].minItemSize;\n this.threshold = options.threshold || 1;\n this.margin = options.margin != null ? options.margin : DEFAULT_OPTIONS[cardSize].margin;\n }\n\n get layoutType() {\n return 'gallery';\n }\n\n /**\n * Takes a row of widths and if there are any widths smaller than the min-width, leech width starting from\n * the widest in the row until it can't give anymore, then move to the second widest and so forth.\n * Do this until all assets meet the min-width.\n * */\n _distributeWidths(widths) {\n // create a copy of the widths array and sort it largest to smallest\n let sortedWidths = widths.concat().sort((a, b) => a[1] > b[1] ? -1 : 1);\n for (let width of widths) {\n // for each width, if it's smaller than the min width\n if (width[1] < this.minItemSize.width) {\n // then figure out how much smaller\n let delta = this.minItemSize.width - width[1];\n for (let item of sortedWidths) {\n // go from the largest width in the row to the smallest\n // if the width is greater than the min width\n if (widths[item[0]][1] > this.minItemSize.width) {\n // subtract the delta from the width, if it's still greater than the min width\n // then we have finished, subtract the delta permanently from that width\n // eslint-disable-next-line max-depth\n if (widths[item[0]][1] - delta > this.minItemSize.width) {\n widths[item[0]][1] -= delta;\n delta = 0;\n break;\n } else {\n // otherwise, we take as much as we can from the current width and then move on to\n // the next largest and take some width from it\n let maxChange = widths[item[0]][1] - this.minItemSize.width;\n delta -= maxChange;\n widths[item[0]][1] -= maxChange;\n }\n }\n }\n if (delta > 0) {\n return false;\n }\n // force the width to be the min width that we just rebalanced for\n width[1] = this.minItemSize.width;\n }\n }\n return true;\n }\n\n buildCollection() {\n let visibleWidth = this.virtualizer.visibleRect.width;\n let visibleHeight = this.virtualizer.visibleRect.height;\n let y = this.margin;\n let availableWidth = visibleWidth - this.margin * 2;\n\n // If available width is not greater than 0, skip node layout calculations\n if (availableWidth > 0) {\n // Compute aspect ratios for all of the items, and the total width if all items were on in a single row.\n let ratios = [];\n let totalWidth = 0;\n let minRatio = this.minItemSize.width / this.minItemSize.height;\n let maxRatio = availableWidth / this.minItemSize.height;\n\n for (let node of this.collection) {\n let ratio = node.props.width / node.props.height;\n if (ratio < minRatio) {\n ratio = minRatio;\n } else if (ratio > maxRatio && ratio !== minRatio) {\n ratio = maxRatio;\n }\n\n let itemWidth = ratio * this.minItemSize.height;\n ratios.push(ratio);\n totalWidth += itemWidth;\n }\n\n totalWidth += this.itemSpacing.width * (this.collection.size - 1);\n\n // Determine how many rows we'll need, and partition the items into rows\n // using the aspect ratios as weights.\n let rows = Math.max(1, Math.ceil(totalWidth / availableWidth));\n // if the available width can't hold two items, then every item will get its own row\n // this leads to a faster run through linear partition and more dependable output for small row widths\n if (availableWidth <= (this.minItemSize.width * 2) + (this.itemPadding * 2)) {\n rows = this.collection.size;\n }\n\n let weightedRatios = ratios.map(ratio => ratio < this.threshold ? ratio + (0.5 * (1 / ratio)) : ratio);\n let partition = linearPartition(weightedRatios, rows);\n\n let index = 0;\n for (let row of partition) {\n // Compute the total weight for this row\n let totalWeight = 0;\n for (let j = index; j < index + row.length; j++) {\n totalWeight += ratios[j];\n }\n\n // Determine the row height based on the total available width and weight of this row.\n let bestRowHeight = (availableWidth - (row.length - 1) * this.itemSpacing.width) / totalWeight;\n\n // if this is the last row and the row height is >2x the ideal row height, then cap to the ideal height\n // probably doing this because if the last row has one extremely tall image, then the row becomes huge\n // though that can happen anywhere if a row has lots of tall images... so i'm not sure why this one matters\n if (row === partition[partition.length - 1] && bestRowHeight > this.idealRowHeight * 2) {\n bestRowHeight = this.idealRowHeight;\n }\n let itemHeight = Math.round(bestRowHeight) + this.itemPadding;\n let x = this.margin;\n\n // if any items are going to end up too small, add a bit of width to them and subtract it from wider objects\n let widths = [];\n for (let j = index; j < index + row.length; j++) {\n let width = Math.round(bestRowHeight * ratios[j]);\n widths.push([j - index, width]);\n }\n this._distributeWidths(widths);\n\n // Create items for this row.\n for (let j = index; j < index + row.length; j++) {\n let node = this.collection.rows[j];\n let itemWidth = Math.max(widths[j - index][1], this.minItemSize.width);\n let rect = new Rect(x, y, itemWidth, itemHeight);\n let layoutInfo = new LayoutInfo(node.type, node.key, rect);\n layoutInfo.allowOverflow = true;\n this.layoutInfos.set(node.key, layoutInfo);\n x += itemWidth + this.itemSpacing.width;\n }\n\n y += itemHeight + this.itemSpacing.height;\n index += row.length;\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 available 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\n// https://www8.cs.umu.se/kurser/TDBA77/VT06/algorithms/BOOK/BOOK2/NODE45.HTM\nfunction linearPartition(seq, k) {\n let n = seq.length;\n if (k <= 0) {\n return [];\n }\n\n if (k >= n) {\n return seq.map(x => [x]);\n }\n\n if (n === 1) {\n return [seq];\n }\n\n let table = Array(n).fill(0).map(() => Array(k).fill(0));\n let solution = Array(n - 1).fill(0).map(() => Array(k - 1).fill(0));\n\n for (let i = 0; i < n; i++) {\n table[i][0] = seq[i] + (i > 0 ? table[i - 1][0] : 0);\n }\n\n for (let i = 0; i < k; i++) {\n table[0][i] = seq[0];\n }\n\n for (let i = 1; i < n; i++) {\n for (let j = 1; j < k; j++) {\n let currentMin = 0;\n let minX = Infinity;\n\n for (let x = 0; x < i; x++) {\n let c1 = table[x][j - 1];\n let c2 = table[i][0] - table[x][0];\n let cost = Math.max(c1, c2);\n\n if (!x || cost < currentMin) {\n currentMin = cost;\n minX = x;\n }\n }\n\n table[i][j] = currentMin;\n solution[i - 1][j - 1] = minX;\n }\n }\n\n n = n - 1;\n k = k - 2;\n\n let result = [];\n while (k >= 0) {\n if (n >= 1) {\n let row = [];\n for (let i = solution[n - 1][k] + 1; i < n + 1; i++) {\n row.push(seq[i]);\n }\n\n result.unshift(row);\n n = solution[n - 1][k];\n }\n\n k--;\n }\n\n let row = [];\n for (let i = 0; i < n + 1; i++) {\n row.push(seq[i]);\n }\n\n result.unshift(row);\n\n return result;\n}\n"],"names":[],"version":3,"file":"GalleryLayout.module.js.map"}
@@ -8,6 +8,7 @@ function $parcel$export(e, n, v, s) {
8
8
  }
9
9
 
10
10
  $parcel$export(module.exports, "GridLayout", () => $71b727f94b595b1a$export$7d2b12578154a735);
11
+ // @ts-nocheck
11
12
  /*
12
13
  * Copyright 2021 Adobe. All rights reserved.
13
14
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -1 +1 @@
1
- {"mappings":";;;;;;;;;;AAAA;;;;;;;;;;CAUC;;;AA4CD,MAAM,wCAAkB;IACtB,GAAG;QACD,aAAa;QACb,aAAa;YACX,YAAY,IAAI,CAAA,GAAA,mCAAG,EAAE,IAAI;QAC3B;QACA,aAAa,IAAI,CAAA,GAAA,mCAAG,EAAE,UAAU;QAChC,QAAQ;QACR,UAAU,IAAI,CAAA,GAAA,mCAAG,EAAE,GAAG;QACtB,YAAY;QACZ,aAAa;IACf;IACA,GAAG;QACD,aAAa;YACX,YAAY;gBACV,UAAU;gBACV,SAAS;YACX;YACA,cAAc;gBACZ,UAAU;gBACV,SAAS;YACX;QACF;QACA,aAAa;YACX,YAAY,IAAI,CAAA,GAAA,mCAAG,EAAE,KAAK;YAC1B,cAAc,IAAI,CAAA,GAAA,mCAAG,EAAE,KAAK;QAC9B;QACA,aAAa,IAAI,CAAA,GAAA,mCAAG,EAAE,UAAU;QAChC,QAAQ;QACR,UAAU,IAAI,CAAA,GAAA,mCAAG,EAAE,IAAI;QACvB,YAAY;QACZ,aAAa;IACf;AACF;AAEO,MAAM,kDAAsB,CAAA,GAAA,oCAAS;IA4B1C,IAAI,aAAa;QACf,OAAO;IACT;IAEA,gBAAgB,CAAC,EAAE,CAAC,EAAE,sBAAsB,KAAK,EAAE;QACjD,IAAI,aAAa,IAAI,CAAC,QAA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,IAAI,CAAC,WAAW,GAAG,QAAQ,WAAW,IAAI,qCAAe,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,eAAe,CAAC;QACrG,IAAI,CAAC,WAAW,GAAG,QAAQ,WAAW,IAAI,qCAAe,CAAC,SAAS,CAAC,WAAW;QAC/E,IAAI,CAAC,MAAM,GAAG,QAAQ,MAAM,IAAI,OAAO,QAAQ,MAAM,GAAG,qCAAe,CAAC,SAAS,CAAC,MAAM;QACxF,IAAI,CAAC,QAAQ,GAAG,QAAQ,QAAQ,IAAI,qCAAe,CAAC,SAAS,CAAC,QAAQ;QACtE,IAAI,CAAC,UAAU,GAAG,QAAQ,UAAU,IAAI,qCAAe,CAAC,SAAS,CAAC,UAAU;QAC5E,IAAI,CAAC,WAAW,GAAG,QAAQ,WAAW,IAAI,OAAO,QAAQ,WAAW,GAAG,qCAAe,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;QAC9I,IAAI,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":["/*\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.main.js.map"}
1
+ {"mappings":";;;;;;;;;;AAAA,cAAc;AACd;;;;;;;;;;CAUC;;;AA4CD,MAAM,wCAAkB;IACtB,GAAG;QACD,aAAa;QACb,aAAa;YACX,YAAY,IAAI,CAAA,GAAA,mCAAG,EAAE,IAAI;QAC3B;QACA,aAAa,IAAI,CAAA,GAAA,mCAAG,EAAE,UAAU;QAChC,QAAQ;QACR,UAAU,IAAI,CAAA,GAAA,mCAAG,EAAE,GAAG;QACtB,YAAY;QACZ,aAAa;IACf;IACA,GAAG;QACD,aAAa;YACX,YAAY;gBACV,UAAU;gBACV,SAAS;YACX;YACA,cAAc;gBACZ,UAAU;gBACV,SAAS;YACX;QACF;QACA,aAAa;YACX,YAAY,IAAI,CAAA,GAAA,mCAAG,EAAE,KAAK;YAC1B,cAAc,IAAI,CAAA,GAAA,mCAAG,EAAE,KAAK;QAC9B;QACA,aAAa,IAAI,CAAA,GAAA,mCAAG,EAAE,UAAU;QAChC,QAAQ;QACR,UAAU,IAAI,CAAA,GAAA,mCAAG,EAAE,IAAI;QACvB,YAAY;QACZ,aAAa;IACf;AACF;AAEO,MAAM,kDAAsB,CAAA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AG,GAAG;IACxE;IA1IA,YAAY,UAA6B,CAAC,CAAC,CAAE;QAC3C,KAAK,CAAC;QACN,IAAI,WAAW;QACf,IAAI,CAAC,eAAe,GAAG,QAAQ,eAAe,IAAI;QAClD,IAAI,CAAC,WAAW,GAAG,QAAQ,WAAW,IAAI,qCAAe,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,eAAe,CAAC;QACrG,IAAI,CAAC,WAAW,GAAG,QAAQ,WAAW,IAAI,qCAAe,CAAC,SAAS,CAAC,WAAW;QAC/E,IAAI,CAAC,MAAM,GAAG,QAAQ,MAAM,IAAI,OAAO,QAAQ,MAAM,GAAG,qCAAe,CAAC,SAAS,CAAC,MAAM;QACxF,IAAI,CAAC,QAAQ,GAAG,QAAQ,QAAQ,IAAI,qCAAe,CAAC,SAAS,CAAC,QAAQ;QACtE,IAAI,CAAC,UAAU,GAAG,QAAQ,UAAU,IAAI,qCAAe,CAAC,SAAS,CAAC,UAAU;QAC5E,IAAI,CAAC,WAAW,GAAG,QAAQ,WAAW,IAAI,OAAO,QAAQ,WAAW,GAAG,qCAAe,CAAC,SAAS,CAAC,WAAW,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC;QAC9I,IAAI,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() {\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.main.js.map"}
@@ -2,6 +2,7 @@ import {BaseLayout as $3d424c147206bac9$export$64943d2e59d72a29} from "./BaseLay
2
2
  import {getFirstItem as $QsHQE$getFirstItem, getChildNodes as $QsHQE$getChildNodes} from "@react-stately/collections";
3
3
  import {Size as $QsHQE$Size, Rect as $QsHQE$Rect, LayoutInfo as $QsHQE$LayoutInfo} from "@react-stately/virtualizer";
4
4
 
5
+ // @ts-nocheck
5
6
  /*
6
7
  * Copyright 2021 Adobe. All rights reserved.
7
8
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");
@@ -2,6 +2,7 @@ import {BaseLayout as $3d424c147206bac9$export$64943d2e59d72a29} from "./BaseLay
2
2
  import {getFirstItem as $QsHQE$getFirstItem, getChildNodes as $QsHQE$getChildNodes} from "@react-stately/collections";
3
3
  import {Size as $QsHQE$Size, Rect as $QsHQE$Rect, LayoutInfo as $QsHQE$LayoutInfo} from "@react-stately/virtualizer";
4
4
 
5
+ // @ts-nocheck
5
6
  /*
6
7
  * Copyright 2021 Adobe. All rights reserved.
7
8
  * This file is licensed to you under the Apache License, Version 2.0 (the "License");