@react-spectrum/card 3.0.0-alpha.3 → 3.0.0-alpha.31

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 (187) hide show
  1. package/dist/ar-AE.main.js +7 -0
  2. package/dist/ar-AE.main.js.map +1 -0
  3. package/dist/ar-AE.mjs +9 -0
  4. package/dist/ar-AE.module.js +9 -0
  5. package/dist/ar-AE.module.js.map +1 -0
  6. package/dist/bg-BG.main.js +7 -0
  7. package/dist/bg-BG.main.js.map +1 -0
  8. package/dist/bg-BG.mjs +9 -0
  9. package/dist/bg-BG.module.js +9 -0
  10. package/dist/bg-BG.module.js.map +1 -0
  11. package/dist/cs-CZ.main.js +7 -0
  12. package/dist/cs-CZ.main.js.map +1 -0
  13. package/dist/cs-CZ.mjs +9 -0
  14. package/dist/cs-CZ.module.js +9 -0
  15. package/dist/cs-CZ.module.js.map +1 -0
  16. package/dist/da-DK.main.js +7 -0
  17. package/dist/da-DK.main.js.map +1 -0
  18. package/dist/da-DK.mjs +9 -0
  19. package/dist/da-DK.module.js +9 -0
  20. package/dist/da-DK.module.js.map +1 -0
  21. package/dist/de-DE.main.js +7 -0
  22. package/dist/de-DE.main.js.map +1 -0
  23. package/dist/de-DE.mjs +9 -0
  24. package/dist/de-DE.module.js +9 -0
  25. package/dist/de-DE.module.js.map +1 -0
  26. package/dist/el-GR.main.js +7 -0
  27. package/dist/el-GR.main.js.map +1 -0
  28. package/dist/el-GR.mjs +9 -0
  29. package/dist/el-GR.module.js +9 -0
  30. package/dist/el-GR.module.js.map +1 -0
  31. package/dist/en-US.main.js +7 -0
  32. package/dist/en-US.main.js.map +1 -0
  33. package/dist/en-US.mjs +9 -0
  34. package/dist/en-US.module.js +9 -0
  35. package/dist/en-US.module.js.map +1 -0
  36. package/dist/es-ES.main.js +7 -0
  37. package/dist/es-ES.main.js.map +1 -0
  38. package/dist/es-ES.mjs +9 -0
  39. package/dist/es-ES.module.js +9 -0
  40. package/dist/es-ES.module.js.map +1 -0
  41. package/dist/et-EE.main.js +7 -0
  42. package/dist/et-EE.main.js.map +1 -0
  43. package/dist/et-EE.mjs +9 -0
  44. package/dist/et-EE.module.js +9 -0
  45. package/dist/et-EE.module.js.map +1 -0
  46. package/dist/fi-FI.main.js +7 -0
  47. package/dist/fi-FI.main.js.map +1 -0
  48. package/dist/fi-FI.mjs +9 -0
  49. package/dist/fi-FI.module.js +9 -0
  50. package/dist/fi-FI.module.js.map +1 -0
  51. package/dist/fr-FR.main.js +7 -0
  52. package/dist/fr-FR.main.js.map +1 -0
  53. package/dist/fr-FR.mjs +9 -0
  54. package/dist/fr-FR.module.js +9 -0
  55. package/dist/fr-FR.module.js.map +1 -0
  56. package/dist/he-IL.main.js +7 -0
  57. package/dist/he-IL.main.js.map +1 -0
  58. package/dist/he-IL.mjs +9 -0
  59. package/dist/he-IL.module.js +9 -0
  60. package/dist/he-IL.module.js.map +1 -0
  61. package/dist/hr-HR.main.js +7 -0
  62. package/dist/hr-HR.main.js.map +1 -0
  63. package/dist/hr-HR.mjs +9 -0
  64. package/dist/hr-HR.module.js +9 -0
  65. package/dist/hr-HR.module.js.map +1 -0
  66. package/dist/hu-HU.main.js +7 -0
  67. package/dist/hu-HU.main.js.map +1 -0
  68. package/dist/hu-HU.mjs +9 -0
  69. package/dist/hu-HU.module.js +9 -0
  70. package/dist/hu-HU.module.js.map +1 -0
  71. package/dist/import.mjs +1479 -0
  72. package/dist/it-IT.main.js +7 -0
  73. package/dist/it-IT.main.js.map +1 -0
  74. package/dist/it-IT.mjs +9 -0
  75. package/dist/it-IT.module.js +9 -0
  76. package/dist/it-IT.module.js.map +1 -0
  77. package/dist/ja-JP.main.js +7 -0
  78. package/dist/ja-JP.main.js.map +1 -0
  79. package/dist/ja-JP.mjs +9 -0
  80. package/dist/ja-JP.module.js +9 -0
  81. package/dist/ja-JP.module.js.map +1 -0
  82. package/dist/ko-KR.main.js +7 -0
  83. package/dist/ko-KR.main.js.map +1 -0
  84. package/dist/ko-KR.mjs +9 -0
  85. package/dist/ko-KR.module.js +9 -0
  86. package/dist/ko-KR.module.js.map +1 -0
  87. package/dist/lt-LT.main.js +7 -0
  88. package/dist/lt-LT.main.js.map +1 -0
  89. package/dist/lt-LT.mjs +9 -0
  90. package/dist/lt-LT.module.js +9 -0
  91. package/dist/lt-LT.module.js.map +1 -0
  92. package/dist/lv-LV.main.js +7 -0
  93. package/dist/lv-LV.main.js.map +1 -0
  94. package/dist/lv-LV.mjs +9 -0
  95. package/dist/lv-LV.module.js +9 -0
  96. package/dist/lv-LV.module.js.map +1 -0
  97. package/dist/main.css +1802 -1
  98. package/dist/main.css.map +1 -0
  99. package/dist/main.js +636 -613
  100. package/dist/main.js.map +1 -1
  101. package/dist/module.js +630 -592
  102. package/dist/module.js.map +1 -1
  103. package/dist/nb-NO.main.js +7 -0
  104. package/dist/nb-NO.main.js.map +1 -0
  105. package/dist/nb-NO.mjs +9 -0
  106. package/dist/nb-NO.module.js +9 -0
  107. package/dist/nb-NO.module.js.map +1 -0
  108. package/dist/nl-NL.main.js +7 -0
  109. package/dist/nl-NL.main.js.map +1 -0
  110. package/dist/nl-NL.mjs +9 -0
  111. package/dist/nl-NL.module.js +9 -0
  112. package/dist/nl-NL.module.js.map +1 -0
  113. package/dist/pl-PL.main.js +7 -0
  114. package/dist/pl-PL.main.js.map +1 -0
  115. package/dist/pl-PL.mjs +9 -0
  116. package/dist/pl-PL.module.js +9 -0
  117. package/dist/pl-PL.module.js.map +1 -0
  118. package/dist/pt-BR.main.js +7 -0
  119. package/dist/pt-BR.main.js.map +1 -0
  120. package/dist/pt-BR.mjs +9 -0
  121. package/dist/pt-BR.module.js +9 -0
  122. package/dist/pt-BR.module.js.map +1 -0
  123. package/dist/pt-PT.main.js +7 -0
  124. package/dist/pt-PT.main.js.map +1 -0
  125. package/dist/pt-PT.mjs +9 -0
  126. package/dist/pt-PT.module.js +9 -0
  127. package/dist/pt-PT.module.js.map +1 -0
  128. package/dist/ro-RO.main.js +7 -0
  129. package/dist/ro-RO.main.js.map +1 -0
  130. package/dist/ro-RO.mjs +9 -0
  131. package/dist/ro-RO.module.js +9 -0
  132. package/dist/ro-RO.module.js.map +1 -0
  133. package/dist/ru-RU.main.js +7 -0
  134. package/dist/ru-RU.main.js.map +1 -0
  135. package/dist/ru-RU.mjs +9 -0
  136. package/dist/ru-RU.module.js +9 -0
  137. package/dist/ru-RU.module.js.map +1 -0
  138. package/dist/sk-SK.main.js +7 -0
  139. package/dist/sk-SK.main.js.map +1 -0
  140. package/dist/sk-SK.mjs +9 -0
  141. package/dist/sk-SK.module.js +9 -0
  142. package/dist/sk-SK.module.js.map +1 -0
  143. package/dist/sl-SI.main.js +7 -0
  144. package/dist/sl-SI.main.js.map +1 -0
  145. package/dist/sl-SI.mjs +9 -0
  146. package/dist/sl-SI.module.js +9 -0
  147. package/dist/sl-SI.module.js.map +1 -0
  148. package/dist/sr-SP.main.js +7 -0
  149. package/dist/sr-SP.main.js.map +1 -0
  150. package/dist/sr-SP.mjs +9 -0
  151. package/dist/sr-SP.module.js +9 -0
  152. package/dist/sr-SP.module.js.map +1 -0
  153. package/dist/sv-SE.main.js +7 -0
  154. package/dist/sv-SE.main.js.map +1 -0
  155. package/dist/sv-SE.mjs +9 -0
  156. package/dist/sv-SE.module.js +9 -0
  157. package/dist/sv-SE.module.js.map +1 -0
  158. package/dist/tr-TR.main.js +7 -0
  159. package/dist/tr-TR.main.js.map +1 -0
  160. package/dist/tr-TR.mjs +9 -0
  161. package/dist/tr-TR.module.js +9 -0
  162. package/dist/tr-TR.module.js.map +1 -0
  163. package/dist/types.d.ts +24 -23
  164. package/dist/types.d.ts.map +1 -1
  165. package/dist/uk-UA.main.js +7 -0
  166. package/dist/uk-UA.main.js.map +1 -0
  167. package/dist/uk-UA.mjs +9 -0
  168. package/dist/uk-UA.module.js +9 -0
  169. package/dist/uk-UA.module.js.map +1 -0
  170. package/dist/zh-CN.main.js +7 -0
  171. package/dist/zh-CN.main.js.map +1 -0
  172. package/dist/zh-CN.mjs +9 -0
  173. package/dist/zh-CN.module.js +9 -0
  174. package/dist/zh-CN.module.js.map +1 -0
  175. package/dist/zh-TW.main.js +7 -0
  176. package/dist/zh-TW.main.js.map +1 -0
  177. package/dist/zh-TW.mjs +9 -0
  178. package/dist/zh-TW.module.js +9 -0
  179. package/dist/zh-TW.module.js.map +1 -0
  180. package/package.json +26 -23
  181. package/src/BaseLayout.tsx +13 -13
  182. package/src/CardBase.tsx +2 -2
  183. package/src/CardView.tsx +26 -8
  184. package/src/GalleryLayout.tsx +1 -0
  185. package/src/GridLayout.tsx +6 -4
  186. package/src/WaterfallLayout.tsx +6 -4
  187. package/src/index.ts +10 -5
package/dist/zh-TW.mjs ADDED
@@ -0,0 +1,9 @@
1
+ var $b7e2865acb74a940$exports = {};
2
+ $b7e2865acb74a940$exports = {
3
+ "loading": `\u{6B63}\u{5728}\u{8F09}\u{5165}\u{2026}`,
4
+ "loadingMore": `\u{6B63}\u{5728}\u{8F09}\u{5165}\u{66F4}\u{591A}\u{2026}`
5
+ };
6
+
7
+
8
+ export {$b7e2865acb74a940$exports as default};
9
+ //# sourceMappingURL=zh-TW.module.js.map
@@ -0,0 +1,9 @@
1
+ var $b7e2865acb74a940$exports = {};
2
+ $b7e2865acb74a940$exports = {
3
+ "loading": `\u{6B63}\u{5728}\u{8F09}\u{5165}\u{2026}`,
4
+ "loadingMore": `\u{6B63}\u{5728}\u{8F09}\u{5165}\u{66F4}\u{591A}\u{2026}`
5
+ };
6
+
7
+
8
+ export {$b7e2865acb74a940$exports as default};
9
+ //# sourceMappingURL=zh-TW.module.js.map
@@ -0,0 +1 @@
1
+ {"mappings":";AAAA,4BAAiB;IAAG,WAAW,CAAC,wCAAK,CAAC;IACpC,eAAe,CAAC,wDAAO,CAAC;AAC1B","sources":["packages/@react-spectrum/card/intl/zh-TW.json"],"sourcesContent":["{\n \"loading\": \"正在載入…\",\n \"loadingMore\": \"正在載入更多…\"\n}\n"],"names":[],"version":3,"file":"zh-TW.module.js.map"}
package/package.json CHANGED
@@ -1,10 +1,15 @@
1
1
  {
2
2
  "name": "@react-spectrum/card",
3
- "version": "3.0.0-alpha.3",
3
+ "version": "3.0.0-alpha.31",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
7
7
  "module": "dist/module.js",
8
+ "exports": {
9
+ "types": "./dist/types.d.ts",
10
+ "import": "./dist/import.mjs",
11
+ "require": "./dist/main.js"
12
+ },
8
13
  "types": "dist/types.d.ts",
9
14
  "source": "src/index.ts",
10
15
  "files": [
@@ -31,36 +36,34 @@
31
36
  "url": "https://github.com/adobe/react-spectrum"
32
37
  },
33
38
  "dependencies": {
34
- "@babel/runtime": "^7.6.2",
35
- "@react-aria/focus": "^3.5.2",
36
- "@react-aria/grid": "^3.2.2",
37
- "@react-aria/i18n": "^3.3.6",
38
- "@react-aria/interactions": "^3.8.1",
39
- "@react-aria/utils": "^3.11.2",
40
- "@react-aria/virtualizer": "^3.3.7",
41
- "@react-spectrum/checkbox": "^3.3.1",
42
- "@react-spectrum/divider": "^3.2.1",
43
- "@react-spectrum/layout": "^3.2.3",
44
- "@react-spectrum/progress": "^3.1.5",
45
- "@react-spectrum/utils": "^3.6.5",
46
- "@react-stately/collections": "^3.3.6",
47
- "@react-stately/grid": "^3.1.2",
48
- "@react-stately/list": "^3.4.3",
49
- "@react-stately/utils": "^3.4.1",
50
- "@react-stately/virtualizer": "^3.1.7",
51
- "@react-types/card": "3.0.0-alpha.3",
52
- "@react-types/provider": "^3.4.1",
53
- "@react-types/shared": "^3.11.1"
39
+ "@react-aria/focus": "^3.16.2",
40
+ "@react-aria/grid": "^3.8.8",
41
+ "@react-aria/i18n": "^3.10.2",
42
+ "@react-aria/interactions": "^3.21.1",
43
+ "@react-aria/utils": "^3.23.2",
44
+ "@react-aria/virtualizer": "^3.9.10",
45
+ "@react-spectrum/checkbox": "^3.9.4",
46
+ "@react-spectrum/progress": "^3.7.5",
47
+ "@react-spectrum/utils": "^3.11.5",
48
+ "@react-stately/collections": "^3.10.5",
49
+ "@react-stately/grid": "^3.8.5",
50
+ "@react-stately/list": "^3.10.3",
51
+ "@react-stately/virtualizer": "^3.6.8",
52
+ "@react-types/card": "3.0.0-alpha.24",
53
+ "@react-types/provider": "^3.7.2",
54
+ "@react-types/shared": "^3.22.1",
55
+ "@swc/helpers": "^0.5.0"
54
56
  },
55
57
  "devDependencies": {
56
58
  "@adobe/spectrum-css-temp": "3.0.0-alpha.1"
57
59
  },
58
60
  "peerDependencies": {
59
61
  "@react-spectrum/provider": "^3.0.0",
60
- "react": "^16.8.0 || ^17.0.0-rc.1"
62
+ "react": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0",
63
+ "react-dom": "^16.8.0 || ^17.0.0-rc.1 || ^18.0.0"
61
64
  },
62
65
  "publishConfig": {
63
66
  "access": "public"
64
67
  },
65
- "gitHead": "404d41859b7d6f56201d7fc01bd9f22ae3512937"
68
+ "gitHead": "de9f84a22583fc741c29b341d14cd35ef4cca161"
66
69
  }
@@ -10,10 +10,10 @@
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
12
 
13
- import {Direction, KeyboardDelegate, Node} from '@react-types/shared';
13
+ import {Direction, Key, KeyboardDelegate, Node} from '@react-types/shared';
14
+ import {getChildNodes, getFirstItem} from '@react-stately/collections';
14
15
  import {GridCollection} from '@react-stately/grid';
15
16
  import {InvalidationContext, Layout, LayoutInfo, Rect, Size} from '@react-stately/virtualizer';
16
- import {Key} from 'react';
17
17
  import {Scale} from '@react-types/provider';
18
18
 
19
19
  export interface BaseLayoutOptions {
@@ -146,7 +146,7 @@ export class BaseLayout<T> extends Layout<Node<T>> implements KeyboardDelegate {
146
146
  let layoutInfo = this.getLayoutInfo(parentRowKey);
147
147
  let rect = new Rect(layoutInfo.rect.x, layoutInfo.rect.maxY + 1, layoutInfo.rect.width, this.virtualizer.visibleRect.height);
148
148
  let closestRow = this.collection.getItem(this._findClosest(layoutInfo.rect, rect)?.key);
149
- return closestRow?.childNodes[0]?.key;
149
+ return getFirstItem(getChildNodes(closestRow, this.collection))?.key;
150
150
  }
151
151
 
152
152
  getKeyAbove(key: Key) {
@@ -155,7 +155,7 @@ export class BaseLayout<T> extends Layout<Node<T>> implements KeyboardDelegate {
155
155
  let layoutInfo = this.getLayoutInfo(parentRowKey);
156
156
  let rect = new Rect(layoutInfo.rect.x, 0, layoutInfo.rect.width, layoutInfo.rect.y - 1);
157
157
  let closestRow = this.collection.getItem(this._findClosest(layoutInfo.rect, rect)?.key);
158
- return closestRow?.childNodes[0]?.key;
158
+ return getFirstItem(getChildNodes(closestRow, this.collection))?.key;
159
159
  }
160
160
 
161
161
  getKeyRightOf(key: Key) {
@@ -167,7 +167,7 @@ export class BaseLayout<T> extends Layout<Node<T>> implements KeyboardDelegate {
167
167
  let item = this.collection.getItem(key);
168
168
  // Don't check if item is disabled because we want to be able to focus disabled items in a grid (double check this)
169
169
  if (item.type === 'item') {
170
- return item.childNodes[0].key;
170
+ return getFirstItem(getChildNodes(item, this.collection))?.key;
171
171
  }
172
172
  key = this.direction === 'rtl' ? this.collection.getKeyBefore(key) : this.collection.getKeyAfter(key);
173
173
  }
@@ -181,7 +181,7 @@ export class BaseLayout<T> extends Layout<Node<T>> implements KeyboardDelegate {
181
181
  let item = this.collection.getItem(key);
182
182
  // Don't check if item is disabled because we want to be able to focus disabled items in a grid (double check this)
183
183
  if (item.type === 'item') {
184
- return item.childNodes[0].key;
184
+ return getFirstItem(getChildNodes(item, this.collection))?.key;
185
185
  }
186
186
 
187
187
  key = this.direction === 'rtl' ? this.collection.getKeyAfter(key) : this.collection.getKeyBefore(key);
@@ -190,12 +190,12 @@ export class BaseLayout<T> extends Layout<Node<T>> implements KeyboardDelegate {
190
190
 
191
191
  getFirstKey() {
192
192
  let firstRow = this.collection.getItem(this.collection.getFirstKey());
193
- return firstRow.childNodes[0].key;
193
+ return getFirstItem(getChildNodes(firstRow, this.collection))?.key;
194
194
  }
195
195
 
196
196
  getLastKey() {
197
197
  let lastRow = this.collection.getItem(this.collection.getLastKey());
198
- return lastRow.childNodes[0].key;
198
+ return getFirstItem(getChildNodes(lastRow, this.collection))?.key;
199
199
  }
200
200
 
201
201
  // TODO: pretty unwieldy because it needs to bounce back and forth between the parent key and the child key
@@ -214,14 +214,14 @@ export class BaseLayout<T> extends Layout<Node<T>> implements KeyboardDelegate {
214
214
 
215
215
  if (layoutInfo && layoutInfo.rect.y > pageY) {
216
216
  while (layoutInfo && layoutInfo.rect.y > pageY) {
217
- let childKey = this.collection.getItem(layoutInfo.key).childNodes[0].key;
217
+ let childKey = getFirstItem(getChildNodes(this.collection.getItem(layoutInfo.key), this.collection))?.key;
218
218
  let keyAbove = this.collection.getItem(this.getKeyAbove(childKey))?.parentKey;
219
219
  layoutInfo = this.getLayoutInfo(keyAbove);
220
220
  }
221
221
  }
222
222
 
223
223
  if (layoutInfo) {
224
- let childKey = this.collection.getItem(layoutInfo.key).childNodes[0].key;
224
+ let childKey = getFirstItem(getChildNodes(this.collection.getItem(layoutInfo.key), this.collection))?.key;
225
225
  return childKey;
226
226
  }
227
227
  }
@@ -243,14 +243,14 @@ export class BaseLayout<T> extends Layout<Node<T>> implements KeyboardDelegate {
243
243
  layoutInfo = this.getLayoutInfo(keyBelow);
244
244
  if (layoutInfo && layoutInfo.rect.y < pageY) {
245
245
  while (layoutInfo && layoutInfo.rect.y < pageY) {
246
- let childKey = this.collection.getItem(layoutInfo.key).childNodes[0].key;
246
+ let childKey = getFirstItem(getChildNodes(this.collection.getItem(layoutInfo.key), this.collection))?.key;
247
247
  let keyBelow = this.collection.getItem(this.getKeyBelow(childKey))?.parentKey;
248
248
  layoutInfo = this.getLayoutInfo(keyBelow);
249
249
  }
250
250
  }
251
251
 
252
252
  if (layoutInfo) {
253
- let childKey = this.collection.getItem(layoutInfo.key).childNodes[0].key;
253
+ let childKey = getFirstItem(getChildNodes(this.collection.getItem(layoutInfo.key), this.collection))?.key;
254
254
  return childKey;
255
255
  }
256
256
  }
@@ -274,7 +274,7 @@ export class BaseLayout<T> extends Layout<Node<T>> implements KeyboardDelegate {
274
274
  if (item.textValue) {
275
275
  let substring = item.textValue.slice(0, search.length);
276
276
  if (this.collator.compare(substring, search) === 0) {
277
- return [...item.childNodes][0].key;
277
+ return getFirstItem(getChildNodes(item, this.collection))?.key;
278
278
  }
279
279
  }
280
280
 
package/src/CardBase.tsx CHANGED
@@ -15,8 +15,7 @@ import {Checkbox} from '@react-spectrum/checkbox';
15
15
  import {classNames, SlotProvider, useDOMRef, useHasChild, useStyleProps} from '@react-spectrum/utils';
16
16
  import {DOMRef, Node} from '@react-types/shared';
17
17
  import {filterDOMProps, mergeProps, useLayoutEffect, useResizeObserver, useSlotId} from '@react-aria/utils';
18
- import {FocusRing} from '@react-aria/focus';
19
- import {getFocusableTreeWalker} from '@react-aria/focus';
18
+ import {FocusRing, getFocusableTreeWalker} from '@react-aria/focus';
20
19
  import React, {HTMLAttributes, useCallback, useMemo, useRef, useState} from 'react';
21
20
  import styles from '@adobe/spectrum-css-temp/components/card/vars.css';
22
21
  import {useCardViewContext} from './CardViewContext';
@@ -93,6 +92,7 @@ function CardBase<T extends object>(props: CardBaseProps<T>, ref: DOMRef<HTMLDiv
93
92
  heading: {UNSAFE_className: classNames(styles, 'spectrum-Card-heading'), ...titleProps},
94
93
  content: {UNSAFE_className: classNames(styles, 'spectrum-Card-content'), ...contentProps},
95
94
  detail: {UNSAFE_className: classNames(styles, 'spectrum-Card-detail')}
95
+ // eslint-disable-next-line react-hooks/exhaustive-deps
96
96
  }), [titleProps, contentProps, height, isQuiet, orientation]);
97
97
 
98
98
  useLayoutEffect(() => {
package/src/CardView.tsx CHANGED
@@ -17,12 +17,13 @@ import {DOMRef, DOMRefValue, Node} from '@react-types/shared';
17
17
  import {GridCollection, useGridState} from '@react-stately/grid';
18
18
  // @ts-ignore
19
19
  import intlMessages from '../intl/*.json';
20
+ import {mergeProps} from '@react-aria/utils';
20
21
  import {ProgressCircle} from '@react-spectrum/progress';
21
- import React, {ReactElement, useCallback, useMemo, useRef} from 'react';
22
+ import React, {ReactElement, ReactNode, useCallback, useMemo, useRef} from 'react';
22
23
  import {ReusableView} from '@react-stately/virtualizer';
23
24
  import {SpectrumCardViewProps} from '@react-types/card';
24
25
  import styles from '@adobe/spectrum-css-temp/components/card/vars.css';
25
- import {useCollator, useLocale, useMessageFormatter} from '@react-aria/i18n';
26
+ import {useCollator, useLocale, useLocalizedStringFormatter} from '@react-aria/i18n';
26
27
  import {useGrid, useGridCell, useGridRow} from '@react-aria/grid';
27
28
  import {useListState} from '@react-stately/list';
28
29
  import {useProvider} from '@react-spectrum/provider';
@@ -46,7 +47,7 @@ function CardView<T extends object>(props: SpectrumCardViewProps<T>, ref: DOMRef
46
47
  let cardViewLayout = useMemo(() => typeof layout === 'function' ? new layout({collator, cardOrientation, scale}) : layout, [layout, collator, cardOrientation, scale]);
47
48
  let layoutType = cardViewLayout.layoutType;
48
49
 
49
- let formatMessage = useMessageFormatter(intlMessages);
50
+ let stringFormatter = useLocalizedStringFormatter(intlMessages, '@react-spectrum/card');
50
51
  let {direction} = useLocale();
51
52
  let {collection} = useListState(props);
52
53
 
@@ -87,12 +88,15 @@ function CardView<T extends object>(props: SpectrumCardViewProps<T>, ref: DOMRef
87
88
  keyboardDelegate: cardViewLayout
88
89
  }, state, domRef);
89
90
 
90
- type View = ReusableView<Node<T>, unknown>;
91
+ type View = ReusableView<Node<T>, ReactNode>;
91
92
  let renderWrapper = (parent: View, reusableView: View) => (
92
93
  <VirtualizerItem
93
94
  key={reusableView.key}
94
- reusableView={reusableView}
95
- parent={parent} />
95
+ layoutInfo={reusableView.layoutInfo}
96
+ virtualizer={reusableView.virtualizer}
97
+ parent={parent?.layoutInfo}>
98
+ {reusableView.rendered}
99
+ </VirtualizerItem>
96
100
  );
97
101
 
98
102
  let focusedKey = state.selectionManager.focusedKey;
@@ -137,7 +141,7 @@ function CardView<T extends object>(props: SpectrumCardViewProps<T>, ref: DOMRef
137
141
  <CenteredWrapper>
138
142
  <ProgressCircle
139
143
  isIndeterminate
140
- aria-label={state.collection.size > 0 ? formatMessage('loadingMore') : formatMessage('loading')} />
144
+ aria-label={state.collection.size > 0 ? stringFormatter.format('loadingMore') : stringFormatter.format('loading')} />
141
145
  </CenteredWrapper>
142
146
  );
143
147
  } else if (type === 'placeholder') {
@@ -185,7 +189,7 @@ function InternalCard(props) {
185
189
  let cellRef = useRef<DOMRefValue<HTMLDivElement>>();
186
190
  let unwrappedRef = useUnwrapDOMRef(cellRef);
187
191
 
188
- let {rowProps} = useGridRow({
192
+ let {rowProps: gridRowProps} = useGridRow({
189
193
  node: item,
190
194
  isVirtualized: true
191
195
  }, state, rowRef);
@@ -195,6 +199,20 @@ function InternalCard(props) {
195
199
  focusMode: 'cell'
196
200
  }, state, unwrappedRef);
197
201
 
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
+
206
+ let onKeyDown = (e) => {
207
+ if (e.key === ' ' && isDisabled) {
208
+ e.preventDefault();
209
+ }
210
+ };
211
+
212
+ let rowProps = mergeProps(
213
+ gridRowProps,
214
+ {onKeyDown}
215
+ );
198
216
 
199
217
  if (layoutType === 'grid' || layoutType === 'gallery') {
200
218
  isQuiet = true;
@@ -109,6 +109,7 @@ export class GalleryLayout<T> extends BaseLayout<T> {
109
109
  if (widths[item[0]][1] > this.minItemSize.width) {
110
110
  // subtract the delta from the width, if it's still greater than the min width
111
111
  // then we have finished, subtract the delta permanently from that width
112
+ // eslint-disable-next-line max-depth
112
113
  if (widths[item[0]][1] - delta > this.minItemSize.width) {
113
114
  widths[item[0]][1] -= delta;
114
115
  delta = 0;
@@ -11,9 +11,9 @@
11
11
  */
12
12
 
13
13
  import {BaseLayout, BaseLayoutOptions} from './BaseLayout';
14
- import {Key} from 'react';
14
+ import {getChildNodes, getFirstItem} from '@react-stately/collections';
15
+ import {Key, Node, Orientation} from '@react-types/shared';
15
16
  import {LayoutInfo, Rect, Size} from '@react-stately/virtualizer';
16
- import {Node, Orientation} from '@react-types/shared';
17
17
 
18
18
  export interface GridLayoutOptions extends BaseLayoutOptions {
19
19
  // /**
@@ -255,7 +255,8 @@ export class GridLayout<T> extends BaseLayout<T> {
255
255
  return null;
256
256
  }
257
257
 
258
- return this.collection.rows[indexRowBelow]?.childNodes[0].key || null;
258
+ let row = this.collection.rows[indexRowBelow];
259
+ return row ? getFirstItem(getChildNodes(row, this.collection))?.key : null;
259
260
  }
260
261
 
261
262
  getKeyAbove(key: Key) {
@@ -269,6 +270,7 @@ export class GridLayout<T> extends BaseLayout<T> {
269
270
  return null;
270
271
  }
271
272
 
272
- return this.collection.rows[indexRowAbove]?.childNodes[0].key || null;
273
+ let row = this.collection.rows[indexRowAbove];
274
+ return row ? getFirstItem(getChildNodes(row, this.collection))?.key : null;
273
275
  }
274
276
  }
@@ -11,9 +11,9 @@
11
11
  */
12
12
 
13
13
  import {BaseLayout, BaseLayoutOptions} from './BaseLayout';
14
+ import {getChildNodes, getFirstItem} from '@react-stately/collections';
14
15
  import {InvalidationContext, LayoutInfo, Rect, Size} from '@react-stately/virtualizer';
15
- import {Key} from 'react';
16
- import {KeyboardDelegate, Node} from '@react-types/shared';
16
+ import {Key, KeyboardDelegate, Node} from '@react-types/shared';
17
17
 
18
18
  export interface WaterfallLayoutOptions extends BaseLayoutOptions {
19
19
  /**
@@ -207,7 +207,8 @@ export class WaterfallLayout<T> extends BaseLayout<T> implements KeyboardDelegat
207
207
  key = this._findClosest(layoutInfo.rect, rect)?.key;
208
208
  }
209
209
 
210
- return this.collection.getItem(key)?.childNodes[0]?.key;
210
+ let item = this.collection.getItem(key);
211
+ return getFirstItem(getChildNodes(item, this.collection))?.key;
211
212
  }
212
213
 
213
214
  getClosestLeft(key: Key) {
@@ -221,7 +222,8 @@ export class WaterfallLayout<T> extends BaseLayout<T> implements KeyboardDelegat
221
222
  key = this._findClosest(layoutInfo.rect, rect)?.key;
222
223
  }
223
224
 
224
- return this.collection.getItem(key)?.childNodes[0]?.key;
225
+ let item = this.collection.getItem(key);
226
+ return getFirstItem(getChildNodes(item, this.collection))?.key;
225
227
  }
226
228
 
227
229
  getKeyRightOf(key: Key) {
package/src/index.ts CHANGED
@@ -12,8 +12,13 @@
12
12
 
13
13
  /// <reference types="css-module-types" />
14
14
 
15
- export * from './CardView';
16
- export * from './GalleryLayout';
17
- export * from './GridLayout';
18
- export * from './WaterfallLayout';
19
- export * from './Card';
15
+ export type {GalleryLayoutOptions} from './GalleryLayout';
16
+ export type {GridLayoutOptions} from './GridLayout';
17
+ export type {WaterfallLayoutOptions} from './WaterfallLayout';
18
+
19
+ export {CardView} from './CardView';
20
+ export {GalleryLayout} from './GalleryLayout';
21
+ export {GridLayout} from './GridLayout';
22
+ export {WaterfallLayout} from './WaterfallLayout';
23
+ export {Card} from './Card';
24
+ export type {SpectrumCardViewProps} from '@react-types/card';