@react-spectrum/card 3.0.0-alpha.53 → 3.0.0-alpha.55

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 (240) hide show
  1. package/dist/import.mjs +6 -6
  2. package/dist/main.js +10 -10
  3. package/dist/main.js.map +1 -1
  4. package/dist/module.js +6 -6
  5. package/dist/module.js.map +1 -1
  6. package/dist/types/src/index.d.ts +9 -0
  7. package/package.json +22 -46
  8. package/src/index.ts +13 -9
  9. package/dist/BaseLayout.main.js +0 -213
  10. package/dist/BaseLayout.main.js.map +0 -1
  11. package/dist/BaseLayout.mjs +0 -208
  12. package/dist/BaseLayout.module.js +0 -208
  13. package/dist/BaseLayout.module.js.map +0 -1
  14. package/dist/Card.main.js +0 -52
  15. package/dist/Card.main.js.map +0 -1
  16. package/dist/Card.mjs +0 -43
  17. package/dist/Card.module.js +0 -43
  18. package/dist/Card.module.js.map +0 -1
  19. package/dist/CardBase.main.js +0 -205
  20. package/dist/CardBase.main.js.map +0 -1
  21. package/dist/CardBase.mjs +0 -200
  22. package/dist/CardBase.module.js +0 -200
  23. package/dist/CardBase.module.js.map +0 -1
  24. package/dist/CardView.main.js +0 -238
  25. package/dist/CardView.main.js.map +0 -1
  26. package/dist/CardView.mjs +0 -233
  27. package/dist/CardView.module.js +0 -233
  28. package/dist/CardView.module.js.map +0 -1
  29. package/dist/CardViewContext.main.js +0 -32
  30. package/dist/CardViewContext.main.js.map +0 -1
  31. package/dist/CardViewContext.mjs +0 -22
  32. package/dist/CardViewContext.module.js +0 -22
  33. package/dist/CardViewContext.module.js.map +0 -1
  34. package/dist/GalleryLayout.main.js +0 -230
  35. package/dist/GalleryLayout.main.js.map +0 -1
  36. package/dist/GalleryLayout.mjs +0 -225
  37. package/dist/GalleryLayout.module.js +0 -225
  38. package/dist/GalleryLayout.module.js.map +0 -1
  39. package/dist/GridLayout.main.js +0 -175
  40. package/dist/GridLayout.main.js.map +0 -1
  41. package/dist/GridLayout.mjs +0 -170
  42. package/dist/GridLayout.module.js +0 -170
  43. package/dist/GridLayout.module.js.map +0 -1
  44. package/dist/WaterfallLayout.main.js +0 -182
  45. package/dist/WaterfallLayout.main.js.map +0 -1
  46. package/dist/WaterfallLayout.mjs +0 -177
  47. package/dist/WaterfallLayout.module.js +0 -177
  48. package/dist/WaterfallLayout.module.js.map +0 -1
  49. package/dist/ar-AE.main.js +0 -7
  50. package/dist/ar-AE.main.js.map +0 -1
  51. package/dist/ar-AE.mjs +0 -9
  52. package/dist/ar-AE.module.js +0 -9
  53. package/dist/ar-AE.module.js.map +0 -1
  54. package/dist/bg-BG.main.js +0 -7
  55. package/dist/bg-BG.main.js.map +0 -1
  56. package/dist/bg-BG.mjs +0 -9
  57. package/dist/bg-BG.module.js +0 -9
  58. package/dist/bg-BG.module.js.map +0 -1
  59. package/dist/card.4d5d6544.css +0 -1671
  60. package/dist/card.4d5d6544.css.map +0 -1
  61. package/dist/card_vars_css.main.js +0 -116
  62. package/dist/card_vars_css.main.js.map +0 -1
  63. package/dist/card_vars_css.mjs +0 -118
  64. package/dist/card_vars_css.module.js +0 -118
  65. package/dist/card_vars_css.module.js.map +0 -1
  66. package/dist/cs-CZ.main.js +0 -7
  67. package/dist/cs-CZ.main.js.map +0 -1
  68. package/dist/cs-CZ.mjs +0 -9
  69. package/dist/cs-CZ.module.js +0 -9
  70. package/dist/cs-CZ.module.js.map +0 -1
  71. package/dist/da-DK.main.js +0 -7
  72. package/dist/da-DK.main.js.map +0 -1
  73. package/dist/da-DK.mjs +0 -9
  74. package/dist/da-DK.module.js +0 -9
  75. package/dist/da-DK.module.js.map +0 -1
  76. package/dist/de-DE.main.js +0 -7
  77. package/dist/de-DE.main.js.map +0 -1
  78. package/dist/de-DE.mjs +0 -9
  79. package/dist/de-DE.module.js +0 -9
  80. package/dist/de-DE.module.js.map +0 -1
  81. package/dist/el-GR.main.js +0 -7
  82. package/dist/el-GR.main.js.map +0 -1
  83. package/dist/el-GR.mjs +0 -9
  84. package/dist/el-GR.module.js +0 -9
  85. package/dist/el-GR.module.js.map +0 -1
  86. package/dist/en-US.main.js +0 -7
  87. package/dist/en-US.main.js.map +0 -1
  88. package/dist/en-US.mjs +0 -9
  89. package/dist/en-US.module.js +0 -9
  90. package/dist/en-US.module.js.map +0 -1
  91. package/dist/es-ES.main.js +0 -7
  92. package/dist/es-ES.main.js.map +0 -1
  93. package/dist/es-ES.mjs +0 -9
  94. package/dist/es-ES.module.js +0 -9
  95. package/dist/es-ES.module.js.map +0 -1
  96. package/dist/et-EE.main.js +0 -7
  97. package/dist/et-EE.main.js.map +0 -1
  98. package/dist/et-EE.mjs +0 -9
  99. package/dist/et-EE.module.js +0 -9
  100. package/dist/et-EE.module.js.map +0 -1
  101. package/dist/fi-FI.main.js +0 -7
  102. package/dist/fi-FI.main.js.map +0 -1
  103. package/dist/fi-FI.mjs +0 -9
  104. package/dist/fi-FI.module.js +0 -9
  105. package/dist/fi-FI.module.js.map +0 -1
  106. package/dist/fr-FR.main.js +0 -7
  107. package/dist/fr-FR.main.js.map +0 -1
  108. package/dist/fr-FR.mjs +0 -9
  109. package/dist/fr-FR.module.js +0 -9
  110. package/dist/fr-FR.module.js.map +0 -1
  111. package/dist/he-IL.main.js +0 -7
  112. package/dist/he-IL.main.js.map +0 -1
  113. package/dist/he-IL.mjs +0 -9
  114. package/dist/he-IL.module.js +0 -9
  115. package/dist/he-IL.module.js.map +0 -1
  116. package/dist/hr-HR.main.js +0 -7
  117. package/dist/hr-HR.main.js.map +0 -1
  118. package/dist/hr-HR.mjs +0 -9
  119. package/dist/hr-HR.module.js +0 -9
  120. package/dist/hr-HR.module.js.map +0 -1
  121. package/dist/hu-HU.main.js +0 -7
  122. package/dist/hu-HU.main.js.map +0 -1
  123. package/dist/hu-HU.mjs +0 -9
  124. package/dist/hu-HU.module.js +0 -9
  125. package/dist/hu-HU.module.js.map +0 -1
  126. package/dist/intlStrings.main.js +0 -108
  127. package/dist/intlStrings.main.js.map +0 -1
  128. package/dist/intlStrings.mjs +0 -110
  129. package/dist/intlStrings.module.js +0 -110
  130. package/dist/intlStrings.module.js.map +0 -1
  131. package/dist/it-IT.main.js +0 -7
  132. package/dist/it-IT.main.js.map +0 -1
  133. package/dist/it-IT.mjs +0 -9
  134. package/dist/it-IT.module.js +0 -9
  135. package/dist/it-IT.module.js.map +0 -1
  136. package/dist/ja-JP.main.js +0 -7
  137. package/dist/ja-JP.main.js.map +0 -1
  138. package/dist/ja-JP.mjs +0 -9
  139. package/dist/ja-JP.module.js +0 -9
  140. package/dist/ja-JP.module.js.map +0 -1
  141. package/dist/ko-KR.main.js +0 -7
  142. package/dist/ko-KR.main.js.map +0 -1
  143. package/dist/ko-KR.mjs +0 -9
  144. package/dist/ko-KR.module.js +0 -9
  145. package/dist/ko-KR.module.js.map +0 -1
  146. package/dist/lt-LT.main.js +0 -7
  147. package/dist/lt-LT.main.js.map +0 -1
  148. package/dist/lt-LT.mjs +0 -9
  149. package/dist/lt-LT.module.js +0 -9
  150. package/dist/lt-LT.module.js.map +0 -1
  151. package/dist/lv-LV.main.js +0 -7
  152. package/dist/lv-LV.main.js.map +0 -1
  153. package/dist/lv-LV.mjs +0 -9
  154. package/dist/lv-LV.module.js +0 -9
  155. package/dist/lv-LV.module.js.map +0 -1
  156. package/dist/nb-NO.main.js +0 -7
  157. package/dist/nb-NO.main.js.map +0 -1
  158. package/dist/nb-NO.mjs +0 -9
  159. package/dist/nb-NO.module.js +0 -9
  160. package/dist/nb-NO.module.js.map +0 -1
  161. package/dist/nl-NL.main.js +0 -7
  162. package/dist/nl-NL.main.js.map +0 -1
  163. package/dist/nl-NL.mjs +0 -9
  164. package/dist/nl-NL.module.js +0 -9
  165. package/dist/nl-NL.module.js.map +0 -1
  166. package/dist/pl-PL.main.js +0 -7
  167. package/dist/pl-PL.main.js.map +0 -1
  168. package/dist/pl-PL.mjs +0 -9
  169. package/dist/pl-PL.module.js +0 -9
  170. package/dist/pl-PL.module.js.map +0 -1
  171. package/dist/pt-BR.main.js +0 -7
  172. package/dist/pt-BR.main.js.map +0 -1
  173. package/dist/pt-BR.mjs +0 -9
  174. package/dist/pt-BR.module.js +0 -9
  175. package/dist/pt-BR.module.js.map +0 -1
  176. package/dist/pt-PT.main.js +0 -7
  177. package/dist/pt-PT.main.js.map +0 -1
  178. package/dist/pt-PT.mjs +0 -9
  179. package/dist/pt-PT.module.js +0 -9
  180. package/dist/pt-PT.module.js.map +0 -1
  181. package/dist/ro-RO.main.js +0 -7
  182. package/dist/ro-RO.main.js.map +0 -1
  183. package/dist/ro-RO.mjs +0 -9
  184. package/dist/ro-RO.module.js +0 -9
  185. package/dist/ro-RO.module.js.map +0 -1
  186. package/dist/ru-RU.main.js +0 -7
  187. package/dist/ru-RU.main.js.map +0 -1
  188. package/dist/ru-RU.mjs +0 -9
  189. package/dist/ru-RU.module.js +0 -9
  190. package/dist/ru-RU.module.js.map +0 -1
  191. package/dist/sk-SK.main.js +0 -7
  192. package/dist/sk-SK.main.js.map +0 -1
  193. package/dist/sk-SK.mjs +0 -9
  194. package/dist/sk-SK.module.js +0 -9
  195. package/dist/sk-SK.module.js.map +0 -1
  196. package/dist/sl-SI.main.js +0 -7
  197. package/dist/sl-SI.main.js.map +0 -1
  198. package/dist/sl-SI.mjs +0 -9
  199. package/dist/sl-SI.module.js +0 -9
  200. package/dist/sl-SI.module.js.map +0 -1
  201. package/dist/sr-SP.main.js +0 -7
  202. package/dist/sr-SP.main.js.map +0 -1
  203. package/dist/sr-SP.mjs +0 -9
  204. package/dist/sr-SP.module.js +0 -9
  205. package/dist/sr-SP.module.js.map +0 -1
  206. package/dist/sv-SE.main.js +0 -7
  207. package/dist/sv-SE.main.js.map +0 -1
  208. package/dist/sv-SE.mjs +0 -9
  209. package/dist/sv-SE.module.js +0 -9
  210. package/dist/sv-SE.module.js.map +0 -1
  211. package/dist/tr-TR.main.js +0 -7
  212. package/dist/tr-TR.main.js.map +0 -1
  213. package/dist/tr-TR.mjs +0 -9
  214. package/dist/tr-TR.module.js +0 -9
  215. package/dist/tr-TR.module.js.map +0 -1
  216. package/dist/types.d.ts +0 -194
  217. package/dist/types.d.ts.map +0 -1
  218. package/dist/uk-UA.main.js +0 -7
  219. package/dist/uk-UA.main.js.map +0 -1
  220. package/dist/uk-UA.mjs +0 -9
  221. package/dist/uk-UA.module.js +0 -9
  222. package/dist/uk-UA.module.js.map +0 -1
  223. package/dist/zh-CN.main.js +0 -7
  224. package/dist/zh-CN.main.js.map +0 -1
  225. package/dist/zh-CN.mjs +0 -9
  226. package/dist/zh-CN.module.js +0 -9
  227. package/dist/zh-CN.module.js.map +0 -1
  228. package/dist/zh-TW.main.js +0 -7
  229. package/dist/zh-TW.main.js.map +0 -1
  230. package/dist/zh-TW.mjs +0 -9
  231. package/dist/zh-TW.module.js +0 -9
  232. package/dist/zh-TW.module.js.map +0 -1
  233. package/src/BaseLayout.tsx +0 -290
  234. package/src/Card.tsx +0 -48
  235. package/src/CardBase.tsx +0 -188
  236. package/src/CardView.tsx +0 -250
  237. package/src/CardViewContext.tsx +0 -27
  238. package/src/GalleryLayout.tsx +0 -321
  239. package/src/GridLayout.tsx +0 -242
  240. package/src/WaterfallLayout.tsx +0 -241
@@ -1,233 +0,0 @@
1
- import {CardBase as $643dd8fa80926f94$export$7a6ccaf429ad93a8} from "./CardBase.module.js";
2
- import {CardViewContext as $8d180a244893de14$export$64992ac69f286e5c, useCardViewContext as $8d180a244893de14$export$fea0b38586ec8f13} from "./CardViewContext.module.js";
3
- import $iOsT7$intlStringsmodulejs from "./intlStrings.module.js";
4
- import "./card.4d5d6544.css";
5
- import $iOsT7$card_vars_cssmodulejs from "./card_vars_css.module.js";
6
- import {useStyleProps as $iOsT7$useStyleProps, useDOMRef as $iOsT7$useDOMRef, classNames as $iOsT7$classNames, useUnwrapDOMRef as $iOsT7$useUnwrapDOMRef} from "@react-spectrum/utils";
7
- import {GridCollection as $iOsT7$GridCollection, useGridState as $iOsT7$useGridState} from "@react-stately/grid";
8
- import {mergeProps as $iOsT7$mergeProps} from "@react-aria/utils";
9
- import {ProgressCircle as $iOsT7$ProgressCircle} from "@react-spectrum/progress";
10
- import $iOsT7$react, {useMemo as $iOsT7$useMemo, useCallback as $iOsT7$useCallback, useRef as $iOsT7$useRef} from "react";
11
- import {useCollator as $iOsT7$useCollator, useLocale as $iOsT7$useLocale, useLocalizedStringFormatter as $iOsT7$useLocalizedStringFormatter} from "@react-aria/i18n";
12
- import {useGrid as $iOsT7$useGrid, useGridRow as $iOsT7$useGridRow, useGridCell as $iOsT7$useGridCell} from "@react-aria/grid";
13
- import {useListState as $iOsT7$useListState} from "@react-stately/list";
14
- import {useProvider as $iOsT7$useProvider} from "@react-spectrum/provider";
15
- import {VirtualizerItem as $iOsT7$VirtualizerItem, Virtualizer as $iOsT7$Virtualizer} from "@react-aria/virtualizer";
16
-
17
-
18
- function $parcel$interopDefault(a) {
19
- return a && a.__esModule ? a.default : a;
20
- }
21
- // @ts-nocheck
22
- /*
23
- * Copyright 2021 Adobe. All rights reserved.
24
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
25
- * you may not use this file except in compliance with the License. You may obtain a copy
26
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
27
- *
28
- * Unless required by applicable law or agreed to in writing, software distributed under
29
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
30
- * OF ANY KIND, either express or implied. See the License for the specific language
31
- * governing permissions and limitations under the License.
32
- */
33
-
34
-
35
-
36
-
37
-
38
-
39
-
40
-
41
-
42
-
43
-
44
-
45
-
46
- const $81a52da995c19652$export$7e52c821f7b6f422 = /*#__PURE__*/ (0, $iOsT7$react).forwardRef(function CardView(props, ref) {
47
- let { scale: scale } = (0, $iOsT7$useProvider)();
48
- let { styleProps: styleProps } = (0, $iOsT7$useStyleProps)(props);
49
- let domRef = (0, $iOsT7$useDOMRef)(ref);
50
- let { isQuiet: isQuiet, renderEmptyState: renderEmptyState, layout: layout, loadingState: loadingState, onLoadMore: onLoadMore, cardOrientation: cardOrientation = 'vertical' } = props;
51
- let collator = (0, $iOsT7$useCollator)({
52
- usage: 'search',
53
- sensitivity: 'base'
54
- });
55
- let isLoading = loadingState === 'loading' || loadingState === 'loadingMore';
56
- let cardViewLayout = (0, $iOsT7$useMemo)(()=>typeof layout === 'function' ? new layout({
57
- collator: collator,
58
- cardOrientation: cardOrientation,
59
- scale: scale
60
- }) : layout, [
61
- layout,
62
- collator,
63
- cardOrientation,
64
- scale
65
- ]);
66
- let layoutType = cardViewLayout.layoutType;
67
- let { direction: direction } = (0, $iOsT7$useLocale)();
68
- let { collection: collection } = (0, $iOsT7$useListState)(props);
69
- let gridCollection = (0, $iOsT7$useMemo)(()=>new (0, $iOsT7$GridCollection)({
70
- columnCount: 1,
71
- items: [
72
- ...collection
73
- ].map((item)=>({
74
- // Makes the Grid row use the keys the user provides to the cards so that selection change via interactions returns the card keys
75
- ...item,
76
- hasChildNodes: true,
77
- childNodes: [
78
- {
79
- key: `cell-${item.key}`,
80
- type: 'cell',
81
- value: null,
82
- level: 0,
83
- rendered: null,
84
- textValue: item.textValue,
85
- hasChildNodes: false,
86
- childNodes: []
87
- }
88
- ]
89
- }))
90
- }), [
91
- collection
92
- ]);
93
- let state = (0, $iOsT7$useGridState)({
94
- ...props,
95
- selectionMode: cardOrientation === 'horizontal' && layoutType === 'grid' ? 'none' : props.selectionMode,
96
- collection: gridCollection,
97
- focusMode: 'cell'
98
- });
99
- cardViewLayout.collection = gridCollection;
100
- cardViewLayout.disabledKeys = state.disabledKeys;
101
- let { gridProps: gridProps } = (0, $iOsT7$useGrid)({
102
- ...props,
103
- isVirtualized: true,
104
- keyboardDelegate: cardViewLayout
105
- }, state, domRef);
106
- let renderWrapper = (0, $iOsT7$useCallback)((parent, reusableView)=>/*#__PURE__*/ (0, $iOsT7$react).createElement((0, $iOsT7$VirtualizerItem), {
107
- key: reusableView.key,
108
- layoutInfo: reusableView.layoutInfo,
109
- virtualizer: reusableView.virtualizer,
110
- parent: parent === null || parent === void 0 ? void 0 : parent.layoutInfo
111
- }, reusableView.rendered), []);
112
- let focusedKey = state.selectionManager.focusedKey;
113
- let focusedItem = gridCollection.getItem(state.selectionManager.focusedKey);
114
- if ((focusedItem === null || focusedItem === void 0 ? void 0 : focusedItem.parentKey) != null) focusedKey = focusedItem.parentKey;
115
- let persistedKeys = (0, $iOsT7$useMemo)(()=>focusedKey != null ? new Set([
116
- focusedKey
117
- ]) : null, [
118
- focusedKey
119
- ]);
120
- // TODO: does aria-row count and aria-col count need to be modified? Perhaps aria-col count needs to be omitted
121
- return /*#__PURE__*/ (0, $iOsT7$react).createElement((0, $8d180a244893de14$export$64992ac69f286e5c).Provider, {
122
- value: {
123
- state: state,
124
- isQuiet: isQuiet,
125
- layout: cardViewLayout,
126
- cardOrientation: cardOrientation,
127
- renderEmptyState: renderEmptyState
128
- }
129
- }, /*#__PURE__*/ (0, $iOsT7$react).createElement((0, $iOsT7$Virtualizer), {
130
- ...gridProps,
131
- ...styleProps,
132
- className: (0, $iOsT7$classNames)((0, ($parcel$interopDefault($iOsT7$card_vars_cssmodulejs))), 'spectrum-CardView'),
133
- ref: domRef,
134
- persistedKeys: persistedKeys,
135
- scrollDirection: "vertical",
136
- layout: cardViewLayout,
137
- collection: gridCollection,
138
- isLoading: isLoading,
139
- onLoadMore: onLoadMore,
140
- layoutOptions: (0, $iOsT7$useMemo)(()=>({
141
- isLoading: isLoading,
142
- direction: direction
143
- }), [
144
- isLoading,
145
- direction
146
- ]),
147
- renderWrapper: renderWrapper,
148
- style: {
149
- ...styleProps.style,
150
- scrollPaddingTop: cardViewLayout.margin || 0
151
- }
152
- }, (0, $iOsT7$useCallback)((type, item)=>{
153
- if (type === 'item') return /*#__PURE__*/ (0, $iOsT7$react).createElement($81a52da995c19652$var$InternalCard, {
154
- item: item
155
- });
156
- else if (type === 'loader') return /*#__PURE__*/ (0, $iOsT7$react).createElement($81a52da995c19652$var$LoadingState, null);
157
- else if (type === 'placeholder') return /*#__PURE__*/ (0, $iOsT7$react).createElement($81a52da995c19652$var$EmptyState, null);
158
- }, [])));
159
- });
160
- function $81a52da995c19652$var$LoadingState() {
161
- let { state: state } = (0, $8d180a244893de14$export$fea0b38586ec8f13)();
162
- let stringFormatter = (0, $iOsT7$useLocalizedStringFormatter)((0, ($parcel$interopDefault($iOsT7$intlStringsmodulejs))), '@react-spectrum/card');
163
- return /*#__PURE__*/ (0, $iOsT7$react).createElement($81a52da995c19652$var$CenteredWrapper, null, /*#__PURE__*/ (0, $iOsT7$react).createElement((0, $iOsT7$ProgressCircle), {
164
- isIndeterminate: true,
165
- "aria-label": state.collection.size > 0 ? stringFormatter.format('loadingMore') : stringFormatter.format('loading')
166
- }));
167
- }
168
- function $81a52da995c19652$var$EmptyState() {
169
- let { renderEmptyState: renderEmptyState } = (0, $8d180a244893de14$export$fea0b38586ec8f13)();
170
- let emptyState = renderEmptyState ? renderEmptyState() : null;
171
- if (emptyState == null) return null;
172
- return /*#__PURE__*/ (0, $iOsT7$react).createElement($81a52da995c19652$var$CenteredWrapper, null, emptyState);
173
- }
174
- function $81a52da995c19652$var$CenteredWrapper({ children: children }) {
175
- let { state: state } = (0, $8d180a244893de14$export$fea0b38586ec8f13)();
176
- return /*#__PURE__*/ (0, $iOsT7$react).createElement("div", {
177
- role: "row",
178
- "aria-rowindex": state.collection.size + 1,
179
- className: (0, $iOsT7$classNames)((0, ($parcel$interopDefault($iOsT7$card_vars_cssmodulejs))), 'spectrum-CardView-centeredWrapper')
180
- }, /*#__PURE__*/ (0, $iOsT7$react).createElement("div", {
181
- role: "gridcell"
182
- }, children));
183
- }
184
- function $81a52da995c19652$var$InternalCard(props) {
185
- let { item: item } = props;
186
- let cellNode = [
187
- ...item.childNodes
188
- ][0];
189
- let { state: state, cardOrientation: cardOrientation, isQuiet: isQuiet, layout: layout } = (0, $8d180a244893de14$export$fea0b38586ec8f13)();
190
- let layoutType = layout.layoutType;
191
- let rowRef = (0, $iOsT7$useRef)(undefined);
192
- let cellRef = (0, $iOsT7$useRef)(undefined);
193
- let unwrappedRef = (0, $iOsT7$useUnwrapDOMRef)(cellRef);
194
- let { rowProps: gridRowProps } = (0, $iOsT7$useGridRow)({
195
- node: item,
196
- isVirtualized: true
197
- }, state, rowRef);
198
- let { gridCellProps: gridCellProps } = (0, $iOsT7$useGridCell)({
199
- node: cellNode,
200
- focusMode: 'cell'
201
- }, state, unwrappedRef);
202
- // Prevent space key from scrolling the CardView if triggered on a disabled item or on a Card in a selectionMode="none" CardView.
203
- let allowsInteraction = state.selectionManager.selectionMode !== 'none';
204
- let isDisabled = !allowsInteraction || state.disabledKeys.has(item.key);
205
- let onKeyDown = (e)=>{
206
- if (e.key === ' ' && isDisabled) e.preventDefault();
207
- };
208
- let rowProps = (0, $iOsT7$mergeProps)(gridRowProps, {
209
- onKeyDown: onKeyDown
210
- });
211
- if (layoutType === 'grid' || layoutType === 'gallery') isQuiet = true;
212
- if (layoutType !== 'grid') cardOrientation = 'vertical';
213
- // We don't want to focus the checkbox (or any other focusable elements) within the Card
214
- // when pressing the arrow keys so we delete the key down handler here. Arrow key navigation between
215
- // the cards in the CardView is handled by useGrid => useSelectableCollection instead.
216
- delete gridCellProps.onKeyDownCapture;
217
- return /*#__PURE__*/ (0, $iOsT7$react).createElement("div", {
218
- ...rowProps,
219
- ref: rowRef,
220
- className: (0, $iOsT7$classNames)((0, ($parcel$interopDefault($iOsT7$card_vars_cssmodulejs))), 'spectrum-CardView-row')
221
- }, /*#__PURE__*/ (0, $iOsT7$react).createElement((0, $643dd8fa80926f94$export$7a6ccaf429ad93a8), {
222
- ref: cellRef,
223
- articleProps: gridCellProps,
224
- isQuiet: isQuiet,
225
- orientation: cardOrientation,
226
- item: item,
227
- layout: layoutType
228
- }, item.rendered));
229
- }
230
-
231
-
232
- export {$81a52da995c19652$export$7e52c821f7b6f422 as CardView};
233
- //# sourceMappingURL=CardView.module.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;;;;;;;;;;;;;AAA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ights 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"}
@@ -1,32 +0,0 @@
1
- var $g0nMI$react = require("react");
2
-
3
-
4
- function $parcel$interopDefault(a) {
5
- return a && a.__esModule ? a.default : a;
6
- }
7
-
8
- function $parcel$export(e, n, v, s) {
9
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
10
- }
11
-
12
- $parcel$export(module.exports, "CardViewContext", () => $e57ab98cef2f01a5$export$64992ac69f286e5c);
13
- $parcel$export(module.exports, "useCardViewContext", () => $e57ab98cef2f01a5$export$fea0b38586ec8f13);
14
- // @ts-nocheck
15
- /*
16
- * Copyright 2020 Adobe. All rights reserved.
17
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
18
- * you may not use this file except in compliance with the License. You may obtain a copy
19
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
20
- *
21
- * Unless required by applicable law or agreed to in writing, software distributed under
22
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
23
- * OF ANY KIND, either express or implied. See the License for the specific language
24
- * governing permissions and limitations under the License.
25
- */
26
- const $e57ab98cef2f01a5$export$64992ac69f286e5c = /*#__PURE__*/ (0, ($parcel$interopDefault($g0nMI$react))).createContext(null);
27
- function $e57ab98cef2f01a5$export$fea0b38586ec8f13() {
28
- return (0, $g0nMI$react.useContext)($e57ab98cef2f01a5$export$64992ac69f286e5c);
29
- }
30
-
31
-
32
- //# sourceMappingURL=CardViewContext.main.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;;;;;;AAAA,cAAc;AACd;;;;;;;;;;CAUC;AAWM,MAAM,0DAAkB,CAAA,GAAA,sCAAI,EAAE,aAAa,CAAuB;AAElE,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 interface CardViewContextValue {\n state: 'idle' | 'loading' | 'error',\n isQuiet: boolean,\n layout: 'grid' | 'gallery' | 'waterfall',\n cardOrientation: 'horizontal' | 'vertical',\n renderEmptyState: () => React.ReactNode\n}\nexport const CardViewContext = React.createContext<CardViewContextValue>(null);\n\nexport function useCardViewContext(): CardViewContextValue | null {\n return useContext(CardViewContext);\n}\n"],"names":[],"version":3,"file":"CardViewContext.main.js.map"}
@@ -1,22 +0,0 @@
1
- import $ip66o$react, {useContext as $ip66o$useContext} from "react";
2
-
3
- // @ts-nocheck
4
- /*
5
- * Copyright 2020 Adobe. All rights reserved.
6
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License. You may obtain a copy
8
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software distributed under
11
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
12
- * OF ANY KIND, either express or implied. See the License for the specific language
13
- * governing permissions and limitations under the License.
14
- */
15
- const $8d180a244893de14$export$64992ac69f286e5c = /*#__PURE__*/ (0, $ip66o$react).createContext(null);
16
- function $8d180a244893de14$export$fea0b38586ec8f13() {
17
- return (0, $ip66o$useContext)($8d180a244893de14$export$64992ac69f286e5c);
18
- }
19
-
20
-
21
- export {$8d180a244893de14$export$64992ac69f286e5c as CardViewContext, $8d180a244893de14$export$fea0b38586ec8f13 as useCardViewContext};
22
- //# sourceMappingURL=CardViewContext.module.js.map
@@ -1,22 +0,0 @@
1
- import $ip66o$react, {useContext as $ip66o$useContext} from "react";
2
-
3
- // @ts-nocheck
4
- /*
5
- * Copyright 2020 Adobe. All rights reserved.
6
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License. You may obtain a copy
8
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
9
- *
10
- * Unless required by applicable law or agreed to in writing, software distributed under
11
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
12
- * OF ANY KIND, either express or implied. See the License for the specific language
13
- * governing permissions and limitations under the License.
14
- */
15
- const $8d180a244893de14$export$64992ac69f286e5c = /*#__PURE__*/ (0, $ip66o$react).createContext(null);
16
- function $8d180a244893de14$export$fea0b38586ec8f13() {
17
- return (0, $ip66o$useContext)($8d180a244893de14$export$64992ac69f286e5c);
18
- }
19
-
20
-
21
- export {$8d180a244893de14$export$64992ac69f286e5c as CardViewContext, $8d180a244893de14$export$fea0b38586ec8f13 as useCardViewContext};
22
- //# sourceMappingURL=CardViewContext.module.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;AAAA,cAAc;AACd;;;;;;;;;;CAUC;AAWM,MAAM,0DAAkB,CAAA,GAAA,YAAI,EAAE,aAAa,CAAuB;AAElE,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 interface CardViewContextValue {\n state: 'idle' | 'loading' | 'error',\n isQuiet: boolean,\n layout: 'grid' | 'gallery' | 'waterfall',\n cardOrientation: 'horizontal' | 'vertical',\n renderEmptyState: () => React.ReactNode\n}\nexport const CardViewContext = React.createContext<CardViewContextValue>(null);\n\nexport function useCardViewContext(): CardViewContextValue | null {\n return useContext(CardViewContext);\n}\n"],"names":[],"version":3,"file":"CardViewContext.module.js.map"}
@@ -1,230 +0,0 @@
1
- var $5ee605f09afaa4de$exports = require("./BaseLayout.main.js");
2
- var $lJHSi$reactstatelyvirtualizer = require("@react-stately/virtualizer");
3
-
4
-
5
- function $parcel$export(e, n, v, s) {
6
- Object.defineProperty(e, n, {get: v, set: s, enumerable: true, configurable: true});
7
- }
8
-
9
- $parcel$export(module.exports, "GalleryLayout", () => $8019a3d2c7d098ea$export$8e52095834484b61);
10
- // @ts-nocheck
11
- /*
12
- * Copyright 2021 Adobe. All rights reserved.
13
- * This file is licensed to you under the Apache License, Version 2.0 (the "License");
14
- * you may not use this file except in compliance with the License. You may obtain a copy
15
- * of the License at http://www.apache.org/licenses/LICENSE-2.0
16
- *
17
- * Unless required by applicable law or agreed to in writing, software distributed under
18
- * the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
19
- * OF ANY KIND, either express or implied. See the License for the specific language
20
- * governing permissions and limitations under the License.
21
- */
22
-
23
- const $8019a3d2c7d098ea$var$DEFAULT_OPTIONS = {
24
- S: {
25
- idealRowHeight: 112,
26
- minItemSize: new (0, $lJHSi$reactstatelyvirtualizer.Size)(96, 96),
27
- itemSpacing: new (0, $lJHSi$reactstatelyvirtualizer.Size)(8, 16),
28
- itemPadding: 24,
29
- dropSpacing: 50,
30
- margin: 8
31
- },
32
- L: {
33
- idealRowHeight: 208,
34
- minItemSize: new (0, $lJHSi$reactstatelyvirtualizer.Size)(136, 136),
35
- itemSpacing: new (0, $lJHSi$reactstatelyvirtualizer.Size)(18, 18),
36
- itemPadding: {
37
- 'medium': 78,
38
- 'large': 99
39
- },
40
- dropSpacing: 100,
41
- margin: 24
42
- }
43
- };
44
- class $8019a3d2c7d098ea$export$8e52095834484b61 extends (0, $5ee605f09afaa4de$exports.BaseLayout) {
45
- get layoutType() {
46
- return 'gallery';
47
- }
48
- /**
49
- * Takes a row of widths and if there are any widths smaller than the min-width, leech width starting from
50
- * the widest in the row until it can't give anymore, then move to the second widest and so forth.
51
- * Do this until all assets meet the min-width.
52
- * */ _distributeWidths(widths) {
53
- // create a copy of the widths array and sort it largest to smallest
54
- let sortedWidths = widths.concat().sort((a, b)=>a[1] > b[1] ? -1 : 1);
55
- for (let width of widths)// for each width, if it's smaller than the min width
56
- if (width[1] < this.minItemSize.width) {
57
- // then figure out how much smaller
58
- let delta = this.minItemSize.width - width[1];
59
- for (let item of sortedWidths)// go from the largest width in the row to the smallest
60
- // if the width is greater than the min width
61
- if (widths[item[0]][1] > this.minItemSize.width) {
62
- // subtract the delta from the width, if it's still greater than the min width
63
- // then we have finished, subtract the delta permanently from that width
64
- // eslint-disable-next-line max-depth
65
- if (widths[item[0]][1] - delta > this.minItemSize.width) {
66
- widths[item[0]][1] -= delta;
67
- delta = 0;
68
- break;
69
- } else {
70
- // otherwise, we take as much as we can from the current width and then move on to
71
- // the next largest and take some width from it
72
- let maxChange = widths[item[0]][1] - this.minItemSize.width;
73
- delta -= maxChange;
74
- widths[item[0]][1] -= maxChange;
75
- }
76
- }
77
- if (delta > 0) return false;
78
- // force the width to be the min width that we just rebalanced for
79
- width[1] = this.minItemSize.width;
80
- }
81
- return true;
82
- }
83
- buildCollection() {
84
- let visibleWidth = this.virtualizer.visibleRect.width;
85
- let visibleHeight = this.virtualizer.visibleRect.height;
86
- let y = this.margin;
87
- let availableWidth = visibleWidth - this.margin * 2;
88
- // If available width is not greater than 0, skip node layout calculations
89
- if (availableWidth > 0) {
90
- // Compute aspect ratios for all of the items, and the total width if all items were on in a single row.
91
- let ratios = [];
92
- let totalWidth = 0;
93
- let minRatio = this.minItemSize.width / this.minItemSize.height;
94
- let maxRatio = availableWidth / this.minItemSize.height;
95
- for (let node of this.collection){
96
- let ratio = node.props.width / node.props.height;
97
- if (ratio < minRatio) ratio = minRatio;
98
- else if (ratio > maxRatio && ratio !== minRatio) ratio = maxRatio;
99
- let itemWidth = ratio * this.minItemSize.height;
100
- ratios.push(ratio);
101
- totalWidth += itemWidth;
102
- }
103
- totalWidth += this.itemSpacing.width * (this.collection.size - 1);
104
- // Determine how many rows we'll need, and partition the items into rows
105
- // using the aspect ratios as weights.
106
- let rows = Math.max(1, Math.ceil(totalWidth / availableWidth));
107
- // if the available width can't hold two items, then every item will get its own row
108
- // this leads to a faster run through linear partition and more dependable output for small row widths
109
- if (availableWidth <= this.minItemSize.width * 2 + this.itemPadding * 2) rows = this.collection.size;
110
- let weightedRatios = ratios.map((ratio)=>ratio < this.threshold ? ratio + 0.5 * (1 / ratio) : ratio);
111
- let partition = $8019a3d2c7d098ea$var$linearPartition(weightedRatios, rows);
112
- let index = 0;
113
- for (let row of partition){
114
- // Compute the total weight for this row
115
- let totalWeight = 0;
116
- for(let j = index; j < index + row.length; j++)totalWeight += ratios[j];
117
- // Determine the row height based on the total available width and weight of this row.
118
- let bestRowHeight = (availableWidth - (row.length - 1) * this.itemSpacing.width) / totalWeight;
119
- // if this is the last row and the row height is >2x the ideal row height, then cap to the ideal height
120
- // probably doing this because if the last row has one extremely tall image, then the row becomes huge
121
- // though that can happen anywhere if a row has lots of tall images... so i'm not sure why this one matters
122
- if (row === partition[partition.length - 1] && bestRowHeight > this.idealRowHeight * 2) bestRowHeight = this.idealRowHeight;
123
- let itemHeight = Math.round(bestRowHeight) + this.itemPadding;
124
- let x = this.margin;
125
- // if any items are going to end up too small, add a bit of width to them and subtract it from wider objects
126
- let widths = [];
127
- for(let j = index; j < index + row.length; j++){
128
- let width = Math.round(bestRowHeight * ratios[j]);
129
- widths.push([
130
- j - index,
131
- width
132
- ]);
133
- }
134
- this._distributeWidths(widths);
135
- // Create items for this row.
136
- for(let j = index; j < index + row.length; j++){
137
- let node = this.collection.rows[j];
138
- let itemWidth = Math.max(widths[j - index][1], this.minItemSize.width);
139
- let rect = new (0, $lJHSi$reactstatelyvirtualizer.Rect)(x, y, itemWidth, itemHeight);
140
- let layoutInfo = new (0, $lJHSi$reactstatelyvirtualizer.LayoutInfo)(node.type, node.key, rect);
141
- layoutInfo.allowOverflow = true;
142
- this.layoutInfos.set(node.key, layoutInfo);
143
- x += itemWidth + this.itemSpacing.width;
144
- }
145
- y += itemHeight + this.itemSpacing.height;
146
- index += row.length;
147
- }
148
- if (this.isLoading) {
149
- let loaderY = y;
150
- let loaderHeight = 60;
151
- // If there aren't any items, make loader take all available room and remove margin from y calculation
152
- // so it doesn't scroll
153
- if (this.collection.size === 0) {
154
- loaderY = 0;
155
- loaderHeight = visibleHeight || 60;
156
- }
157
- let rect = new (0, $lJHSi$reactstatelyvirtualizer.Rect)(0, loaderY, visibleWidth, loaderHeight);
158
- let loader = new (0, $lJHSi$reactstatelyvirtualizer.LayoutInfo)('loader', 'loader', rect);
159
- this.layoutInfos.set('loader', loader);
160
- y = loader.rect.maxY;
161
- }
162
- if (this.collection.size === 0 && !this.isLoading) {
163
- let rect = new (0, $lJHSi$reactstatelyvirtualizer.Rect)(0, 0, visibleWidth, visibleHeight);
164
- let placeholder = new (0, $lJHSi$reactstatelyvirtualizer.LayoutInfo)('placeholder', 'placeholder', rect);
165
- this.layoutInfos.set('placeholder', placeholder);
166
- y = placeholder.rect.maxY;
167
- }
168
- }
169
- this.contentSize = new (0, $lJHSi$reactstatelyvirtualizer.Size)(visibleWidth, y);
170
- }
171
- constructor(options = {}){
172
- super(options);
173
- let cardSize = 'L';
174
- this.idealRowHeight = options.idealRowHeight || $8019a3d2c7d098ea$var$DEFAULT_OPTIONS[cardSize].idealRowHeight;
175
- this.itemSpacing = options.itemSpacing || $8019a3d2c7d098ea$var$DEFAULT_OPTIONS[cardSize].itemSpacing;
176
- this.itemPadding = options.itemPadding != null ? options.itemPadding : $8019a3d2c7d098ea$var$DEFAULT_OPTIONS[cardSize].itemPadding[this.scale];
177
- this.minItemSize = options.minItemSize || $8019a3d2c7d098ea$var$DEFAULT_OPTIONS[cardSize].minItemSize;
178
- this.threshold = options.threshold || 1;
179
- this.margin = options.margin != null ? options.margin : $8019a3d2c7d098ea$var$DEFAULT_OPTIONS[cardSize].margin;
180
- }
181
- }
182
- // https://www8.cs.umu.se/kurser/TDBA77/VT06/algorithms/BOOK/BOOK2/NODE45.HTM
183
- function $8019a3d2c7d098ea$var$linearPartition(seq, k) {
184
- let n = seq.length;
185
- if (k <= 0) return [];
186
- if (k >= n) return seq.map((x)=>[
187
- x
188
- ]);
189
- if (n === 1) return [
190
- seq
191
- ];
192
- let table = Array(n).fill(0).map(()=>Array(k).fill(0));
193
- let solution = Array(n - 1).fill(0).map(()=>Array(k - 1).fill(0));
194
- for(let i = 0; i < n; i++)table[i][0] = seq[i] + (i > 0 ? table[i - 1][0] : 0);
195
- for(let i = 0; i < k; i++)table[0][i] = seq[0];
196
- for(let i = 1; i < n; i++)for(let j = 1; j < k; j++){
197
- let currentMin = 0;
198
- let minX = Infinity;
199
- for(let x = 0; x < i; x++){
200
- let c1 = table[x][j - 1];
201
- let c2 = table[i][0] - table[x][0];
202
- let cost = Math.max(c1, c2);
203
- if (!x || cost < currentMin) {
204
- currentMin = cost;
205
- minX = x;
206
- }
207
- }
208
- table[i][j] = currentMin;
209
- solution[i - 1][j - 1] = minX;
210
- }
211
- n = n - 1;
212
- k = k - 2;
213
- let result = [];
214
- while(k >= 0){
215
- if (n >= 1) {
216
- let row = [];
217
- for(let i = solution[n - 1][k] + 1; i < n + 1; i++)row.push(seq[i]);
218
- result.unshift(row);
219
- n = solution[n - 1][k];
220
- }
221
- k--;
222
- }
223
- let row = [];
224
- for(let i = 0; i < n + 1; i++)row.push(seq[i]);
225
- result.unshift(row);
226
- return result;
227
- }
228
-
229
-
230
- //# sourceMappingURL=GalleryLayout.main.js.map
@@ -1 +0,0 @@
1
- {"mappings":";;;;;;;;;AAAA,cAAc;AACd;;;;;;;;;;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,aAAqB;QACvB,OAAO;IACT;IAEA;;;;KAIG,GACH,kBAAkB,MAAgB,EAAW;QAC3C,oEAAoE;QACpE,IAAI,eAAe,OAAO,MAAM,GAAG,IAAI,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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(): string {\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: number[]): boolean {\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(): void {\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"}