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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/types.d.ts CHANGED
@@ -1,15 +1,9 @@
1
- import { DOMRef, Direction, KeyboardDelegate, Node, Orientation, DOMRefValue, ItemProps } from "@react-types/shared";
2
- import React, { ReactElement, Key } from "react";
3
- import { SpectrumCardViewProps, SpectrumCardProps } from "@react-types/card";
1
+ import { Direction, Key, KeyboardDelegate, Node, Orientation, DOMRef, DOMRefValue, ItemProps } from "@react-types/shared";
4
2
  import { GridCollection } from "@react-stately/grid";
5
3
  import { InvalidationContext, Layout, LayoutInfo, Rect, Size } from "@react-stately/virtualizer";
6
4
  import { Scale } from "@react-types/provider";
7
- /**
8
- * TODO: Add description of component here.
9
- */
10
- export const CardView: <T>(props: SpectrumCardViewProps<T> & {
11
- ref?: DOMRef<HTMLDivElement>;
12
- }) => ReactElement;
5
+ import React, { ReactElement } from "react";
6
+ import { SpectrumCardViewProps, SpectrumCardProps } from "@react-types/card";
13
7
  interface BaseLayoutOptions {
14
8
  collator?: Intl.Collator;
15
9
  scale?: Scale;
@@ -41,14 +35,14 @@ declare class BaseLayout<T> extends Layout<Node<T>> implements KeyboardDelegate
41
35
  getFinalLayoutInfo(layoutInfo: LayoutInfo): LayoutInfo;
42
36
  _findClosestLayoutInfo(target: Rect, rect: Rect): any;
43
37
  _findClosest(target: Rect, rect: Rect): any;
44
- getKeyBelow(key: Key): any;
45
- getKeyAbove(key: Key): any;
46
- getKeyRightOf(key: Key): any;
47
- getKeyLeftOf(key: Key): any;
48
- getFirstKey(): any;
49
- getLastKey(): any;
50
- getKeyPageAbove(key: Key): any;
51
- getKeyPageBelow(key: Key): any;
38
+ getKeyBelow(key: Key): Key;
39
+ getKeyAbove(key: Key): Key;
40
+ getKeyRightOf(key: Key): Key;
41
+ getKeyLeftOf(key: Key): Key;
42
+ getFirstKey(): Key;
43
+ getLastKey(): Key;
44
+ getKeyPageAbove(key: Key): Key;
45
+ getKeyPageBelow(key: Key): Key;
52
46
  getKeyForSearch(search: string, fromKey?: Key): Key;
53
47
  }
54
48
  export interface GalleryLayoutOptions extends BaseLayoutOptions {
@@ -144,8 +138,8 @@ export class GridLayout<T> extends BaseLayout<T> {
144
138
  getVisibleLayoutInfos(rect: any): LayoutInfo[];
145
139
  buildCollection(): void;
146
140
  buildChild(node: Node<T>, y: number, index: number): LayoutInfo;
147
- getKeyBelow(key: Key): any;
148
- getKeyAbove(key: Key): any;
141
+ getKeyBelow(key: Key): Key;
142
+ getKeyAbove(key: Key): Key;
149
143
  }
150
144
  export interface WaterfallLayoutOptions extends BaseLayoutOptions {
151
145
  /**
@@ -182,11 +176,18 @@ export class WaterfallLayout<T> extends BaseLayout<T> implements KeyboardDelegat
182
176
  buildCollection(invalidationContext: InvalidationContext<Node<T>, unknown>): void;
183
177
  updateItemSize(key: Key, size: Size): boolean;
184
178
  getNextColumnIndex(columnHeights: any): number;
185
- getClosestRight(key: Key): any;
186
- getClosestLeft(key: Key): any;
187
- getKeyRightOf(key: Key): any;
188
- getKeyLeftOf(key: Key): any;
179
+ getClosestRight(key: Key): Key;
180
+ getClosestLeft(key: Key): Key;
181
+ getKeyRightOf(key: Key): Key;
182
+ getKeyLeftOf(key: Key): Key;
189
183
  }
184
+ /**
185
+ * TODO: Add description of component here.
186
+ */
187
+ export const CardView: <T>(props: SpectrumCardViewProps<T> & {
188
+ ref?: DOMRef<HTMLDivElement>;
189
+ }) => ReactElement;
190
190
  export let Card: React.ForwardRefExoticComponent<ItemProps<SpectrumCardProps> & SpectrumCardProps & React.RefAttributes<DOMRefValue<HTMLDivElement>>>;
191
+ export type { SpectrumCardViewProps } from '@react-types/card';
191
192
 
192
193
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"mappings":";;;;;;AEiOA;;GAEG;AACH,OAAA,MAAM;UAAuF,OAAO,cAAc,CAAC;MAAM,YAAY,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,SAAS,CAAC,WAAW,EAAE,IAAI,CAAC;IAC5B,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC;IACzB,SAAS,CAAC,UAAU,EAAE,MAAM,CAAC;IAC7B,SAAS,CAAC,UAAU,EAAE,MAAM,CAAC;IAC7B,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC;IAC5B,SAAS,CAAC,iBAAiB,EAAE,MAAM,CAAC;gBAExB,OAAO,GAAE,sBAA2B;IAiBhD,IAAI,UAAU,WAEb;IAED,eAAe,CAAC,mBAAmB,EAAE,oBAAoB,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC;IA6F1E,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI;IAmBnC,kBAAkB,CAAC,aAAa,KAAA;IAWhC,eAAe,CAAC,GAAG,EAAE,GAAG;IAkBxB,cAAc,CAAC,GAAG,EAAE,GAAG;IAcvB,aAAa,CAAC,GAAG,EAAE,GAAG;IAMtB,YAAY,CAAC,GAAG,EAAE,GAAG;CAKtB;AChMD,OAAA,IAAI,0IAAyJ,CAAC","sources":["packages/@react-spectrum/card/src/packages/@react-spectrum/card/src/CardViewContext.tsx","packages/@react-spectrum/card/src/packages/@react-spectrum/card/src/CardBase.tsx","packages/@react-spectrum/card/src/packages/@react-spectrum/card/src/CardView.tsx","packages/@react-spectrum/card/src/packages/@react-spectrum/card/src/BaseLayout.tsx","packages/@react-spectrum/card/src/packages/@react-spectrum/card/src/GalleryLayout.tsx","packages/@react-spectrum/card/src/packages/@react-spectrum/card/src/GridLayout.tsx","packages/@react-spectrum/card/src/packages/@react-spectrum/card/src/WaterfallLayout.tsx","packages/@react-spectrum/card/src/packages/@react-spectrum/card/src/Card.tsx","packages/@react-spectrum/card/src/packages/@react-spectrum/card/src/index.ts","packages/@react-spectrum/card/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,"/*\n * Copyright 2021 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n/// <reference types=\"css-module-types\" />\n\nexport * from './CardView';\nexport * from './GalleryLayout';\nexport * from './GridLayout';\nexport * from './WaterfallLayout';\nexport * from './Card';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
1
+ {"mappings":";;;;;;AAkBA;IACE,QAAQ,CAAC,EAAE,KAAK,QAAQ,CAAC;IAEzB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAA;CAChB;AAED,yBAAwB,CAAC,CAAE,SAAQ,OAAO,KAAK,CAAC,CAAC,CAAE,YAAW,gBAAgB;IAC5E,SAAS,CAAC,WAAW,EAAE,IAAI,CAAC;IAC5B,SAAS,CAAC,WAAW,EAAE,GAAG,CAAC,GAAG,EAAE,UAAU,CAAC,CAAC;IAC5C,SAAS,CAAC,QAAQ,EAAE,KAAK,QAAQ,CAAC;IAClC,SAAS,CAAC,cAAc,EAAE,eAAe,CAAC,CAAC,CAAC;IAC5C,UAAU,EAAG,eAAe,CAAC,CAAC,CAAC;IAC/B,SAAS,EAAE,OAAO,CAAC;IACnB,YAAY,EAAE,GAAG,CAAC,GAAG,CAAC,CAAa;IACnC,SAAS,EAAE,SAAS,CAAC;IACrB,KAAK,EAAE,KAAK,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;gBAEH,OAAO,GAAE,iBAAsB;IAS3C,QAAQ,CAAC,mBAAmB,EAAE,oBAAoB,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC;IAyBnE,eAAe,CAAC,mBAAmB,CAAC,EAAE,oBAAoB,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC;IAE3E,c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ages/@react-spectrum/card/src/packages/@react-spectrum/card/src/GalleryLayout.tsx","packages/@react-spectrum/card/src/packages/@react-spectrum/card/src/GridLayout.tsx","packages/@react-spectrum/card/src/packages/@react-spectrum/card/src/WaterfallLayout.tsx","packages/@react-spectrum/card/src/packages/@react-spectrum/card/src/CardViewContext.tsx","packages/@react-spectrum/card/src/packages/@react-spectrum/card/src/CardBase.tsx","packages/@react-spectrum/card/src/packages/@react-spectrum/card/src/CardView.tsx","packages/@react-spectrum/card/src/packages/@react-spectrum/card/src/Card.tsx","packages/@react-spectrum/card/src/packages/@react-spectrum/card/src/index.ts","packages/@react-spectrum/card/src/index.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,"/*\n * Copyright 2021 Adobe. All rights reserved.\n * This file is licensed to you under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License. You may obtain a copy\n * of the License at http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software distributed under\n * the License is distributed on an \"AS IS\" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS\n * OF ANY KIND, either express or implied. See the License for the specific language\n * governing permissions and limitations under the License.\n */\n\n/// <reference types=\"css-module-types\" />\n\nexport type {GalleryLayoutOptions} from './GalleryLayout';\nexport type {GridLayoutOptions} from './GridLayout';\nexport type {WaterfallLayoutOptions} from './WaterfallLayout';\n\nexport {CardView} from './CardView';\nexport {GalleryLayout} from './GalleryLayout';\nexport {GridLayout} from './GridLayout';\nexport {WaterfallLayout} from './WaterfallLayout';\nexport {Card} from './Card';\nexport type {SpectrumCardViewProps} from '@react-types/card';\n"],"names":[],"version":3,"file":"types.d.ts.map"}
package/package.json CHANGED
@@ -1,10 +1,15 @@
1
1
  {
2
2
  "name": "@react-spectrum/card",
3
- "version": "3.0.0-alpha.3",
3
+ "version": "3.0.0-alpha.30",
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.1",
40
+ "@react-aria/grid": "^3.8.7",
41
+ "@react-aria/i18n": "^3.10.1",
42
+ "@react-aria/interactions": "^3.21.0",
43
+ "@react-aria/utils": "^3.23.1",
44
+ "@react-aria/virtualizer": "^3.9.9",
45
+ "@react-spectrum/checkbox": "^3.9.3",
46
+ "@react-spectrum/progress": "^3.7.4",
47
+ "@react-spectrum/utils": "^3.11.4",
48
+ "@react-stately/collections": "^3.10.4",
49
+ "@react-stately/grid": "^3.8.4",
50
+ "@react-stately/list": "^3.10.2",
51
+ "@react-stately/virtualizer": "^3.6.7",
52
+ "@react-types/card": "3.0.0-alpha.23",
53
+ "@react-types/provider": "^3.7.1",
54
+ "@react-types/shared": "^3.22.0",
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": "f040ff62678e6a31375b96c05396df0bae660350"
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';