@react-spectrum/card 3.0.0-alpha.0 → 3.0.0-alpha.4

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,16 +1,23 @@
1
- import { DOMRefValue, Direction, KeyboardDelegate, Node } from "@react-types/shared";
2
- import React, { Key } from "react";
3
- import { SpectrumCardViewProps } from "@react-types/card";
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";
4
4
  import { GridCollection } from "@react-stately/grid";
5
5
  import { InvalidationContext, Layout, LayoutInfo, Rect, Size } from "@react-stately/virtualizer";
6
+ import { Scale } from "@react-types/provider";
6
7
  /**
7
8
  * TODO: Add description of component here.
8
9
  */
9
10
  export const CardView: <T>(props: SpectrumCardViewProps<T> & {
10
- ref?: React.Ref<DOMRefValue<HTMLDivElement>>;
11
- }) => React.ReactElement<any, string | ((props: any) => React.ReactElement<any, string | any | (new (props: any) => React.Component<any, any, any>)>) | (new (props: any) => React.Component<any, any, any>)>;
11
+ ref?: DOMRef<HTMLDivElement>;
12
+ }) => ReactElement;
12
13
  interface BaseLayoutOptions {
13
14
  collator?: Intl.Collator;
15
+ scale?: Scale;
16
+ /**
17
+ * The margin around the grid view between the edges and the items.
18
+ * @default 24
19
+ */
20
+ margin?: number;
14
21
  }
15
22
  declare class BaseLayout<T> extends Layout<Node<T>> implements KeyboardDelegate {
16
23
  protected contentSize: Size;
@@ -21,6 +28,8 @@ declare class BaseLayout<T> extends Layout<Node<T>> implements KeyboardDelegate
21
28
  isLoading: boolean;
22
29
  disabledKeys: Set<Key>;
23
30
  direction: Direction;
31
+ scale: Scale;
32
+ margin: number;
24
33
  constructor(options?: BaseLayoutOptions);
25
34
  validate(invalidationContext: InvalidationContext<Node<T>, unknown>): void;
26
35
  buildCollection(invalidationContext?: InvalidationContext<Node<T>, unknown>): void;
@@ -40,7 +49,7 @@ declare class BaseLayout<T> extends Layout<Node<T>> implements KeyboardDelegate
40
49
  getLastKey(): any;
41
50
  getKeyPageAbove(key: Key): any;
42
51
  getKeyPageBelow(key: Key): any;
43
- getKeyForSearch(search: string, fromKey?: Key): string | number;
52
+ getKeyForSearch(search: string, fromKey?: Key): Key;
44
53
  }
45
54
  export interface GalleryLayoutOptions extends BaseLayoutOptions {
46
55
  /**
@@ -55,7 +64,7 @@ export interface GalleryLayoutOptions extends BaseLayoutOptions {
55
64
  itemSpacing?: Size;
56
65
  /**
57
66
  * The vertical padding for an item.
58
- * @default 114
67
+ * @default 78
59
68
  */
60
69
  itemPadding?: number;
61
70
  /**
@@ -69,15 +78,9 @@ export interface GalleryLayoutOptions extends BaseLayoutOptions {
69
78
  * @type {number}
70
79
  */
71
80
  threshold?: number;
72
- /**
73
- * The margin around the grid view between the edges and the items.
74
- * @default 24
75
- */
76
- margin?: number;
77
81
  }
78
82
  export class GalleryLayout<T> extends BaseLayout<T> {
79
83
  protected idealRowHeight: number;
80
- protected margin: number;
81
84
  protected itemSpacing: Size;
82
85
  itemPadding: number;
83
86
  protected minItemSize: Size;
@@ -95,7 +98,7 @@ export class GalleryLayout<T> extends BaseLayout<T> {
95
98
  export interface GridLayoutOptions extends BaseLayoutOptions {
96
99
  /**
97
100
  * The minimum item size.
98
- * @default 208 x 208
101
+ * @default 208 x 208 for horizontal card orientation. 102 x 102 for vertical card orientation.
99
102
  */
100
103
  minItemSize?: Size;
101
104
  /**
@@ -103,11 +106,6 @@ export interface GridLayoutOptions extends BaseLayoutOptions {
103
106
  * @default Infinity
104
107
  */
105
108
  maxItemSize?: Size;
106
- /**
107
- * The margin around the grid view between the edges and the items.
108
- * @default 24
109
- */
110
- margin?: number;
111
109
  /**
112
110
  * The minimum space required between items.
113
111
  * @default 18 x 18
@@ -119,18 +117,23 @@ export interface GridLayoutOptions extends BaseLayoutOptions {
119
117
  */
120
118
  maxColumns?: number;
121
119
  /**
122
- * The vertical padding for an item.
120
+ * The additional padding along the card's main axis. Affects the sizing of the content area following the card image.
123
121
  * @default 95
124
122
  */
125
123
  itemPadding?: number;
124
+ /**
125
+ * The orientation of the cards withn the grid.
126
+ * @default vertical
127
+ */
128
+ cardOrientation?: Orientation;
126
129
  }
127
130
  export class GridLayout<T> extends BaseLayout<T> {
128
131
  protected minItemSize: Size;
129
132
  protected maxItemSize: Size;
130
- protected margin: number;
131
133
  protected minSpace: Size;
132
134
  protected maxColumns: number;
133
135
  itemPadding: number;
136
+ cardOrientation: Orientation;
134
137
  protected itemSize: Size;
135
138
  protected numColumns: number;
136
139
  protected numRows: number;
@@ -155,11 +158,6 @@ export interface WaterfallLayoutOptions extends BaseLayoutOptions {
155
158
  * @default Infinity
156
159
  */
157
160
  maxItemSize?: Size;
158
- /**
159
- * The margin around the grid view between the edges and the items.
160
- * @default 24
161
- */
162
- margin?: number;
163
161
  /**
164
162
  * The minimum space required between items.
165
163
  * @default 18 x 18
@@ -170,19 +168,12 @@ export interface WaterfallLayoutOptions extends BaseLayoutOptions {
170
168
  * @default Infinity
171
169
  */
172
170
  maxColumns?: number;
173
- /**
174
- * The vertical padding for an item.
175
- * @default 56
176
- */
177
- itemPadding?: number;
178
171
  }
179
172
  export class WaterfallLayout<T> extends BaseLayout<T> implements KeyboardDelegate {
180
173
  protected minItemSize: Size;
181
174
  protected maxItemSize: Size;
182
- protected margin: number;
183
175
  protected minSpace: Size;
184
176
  protected maxColumns: number;
185
- itemPadding: number;
186
177
  protected numColumns: number;
187
178
  protected itemWidth: number;
188
179
  protected horizontalSpacing: number;
@@ -196,6 +187,6 @@ export class WaterfallLayout<T> extends BaseLayout<T> implements KeyboardDelegat
196
187
  getKeyRightOf(key: Key): any;
197
188
  getKeyLeftOf(key: Key): any;
198
189
  }
199
- export let Card: <T>(props: any, ref: any) => JSX.Element;
190
+ export let Card: React.ForwardRefExoticComponent<ItemProps<SpectrumCardProps> & Sp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;A;OAGG;IACH,QAAQ,CAAC,EAAE,IAAI,CAAC;IAChB;A;A;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;A;A;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAA;CACrB;AAGD,6BAA6B,CAAC,CAAE,SAAQ,WAAW,CAAC,CAAE,YAAW,gBAAgB;IAC/E,SAAS,CAAC,WAAW,EAAE,IAAI,CAAC;IAC5B,SAAS,CAAC,WAAW,EAAE,IAAI,CAAC;IAC5B,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC;IACzB,SAAS,CAAC,QAAQ,EAAE,IAAI,CAAC;IACzB,SAAS,CAAC,UAAU,EAAE,MAAM,CAAC;IAC7B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,UAAU,EAAE,MAAM,CAAC;IAC7B,SAAS,CAAC,SAAS,EAAE,MAAM,CAAC;IAC5B,SAAS,CAAC,iBAAiB,EAAE,MAAM,CAAC;gBAExB,OAAO,GAAE,sBAA2B;IAmBhD,IAAI,UAAU,WAEb;IAED,eAAe,CAAC,mBAAmB,EAAE,oBAAoB,KAAK,CAAC,CAAC,EAAE,OAAO,CAAC;IA4F1E,cAAc,CAAC,GAAG,EAAE,GAAG,EAAE,IAAI,EAAE,IAAI;IAoBnC,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;AC3MD,OAAA,IAAI,8CAA8C,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"],"sourcesContent":[null,null,null,null,null,null,null,null,null],"names":[],"version":3,"file":"types.d.ts.map"}
1
+ {"mappings":";;;;;;AEiOA;;GAEG;AACH,OAAA,MAAM;UAAuF,OAAO,cAAc,CAAC;MAAM,YAAY,CAAC;AClNtI;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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CAAC,GAAG,EAAE,GAAG;CAarB;AChQD,uCAAwC,SAAQ,iBAAiB;IAC/D;;;OAGG;IACH,WAAW,CAAC,EAAE,IAAI,CAAC;IACnB;;;OAGG;IACH,WAAW,CAAC,EAAE,IAAI,CAAC;IACnB;;;OAGG;IACH,QAAQ,CAAC,EAAE,IAAI,CAAC;IAChB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAGD,6BAA6B,CAAC,CAAE,SAAQ,WAAW,CAAC,CAAE,YAAW,gBAAgB;IAC/E,SAAS,CAAC,WAAW,EAAE,IAAI,CAAC;IAC5B,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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@react-spectrum/card",
3
- "version": "3.0.0-alpha.0",
3
+ "version": "3.0.0-alpha.4",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -32,24 +32,25 @@
32
32
  },
33
33
  "dependencies": {
34
34
  "@babel/runtime": "^7.6.2",
35
- "@react-aria/focus": "^3.4.0",
36
- "@react-aria/grid": "^3.0.0",
37
- "@react-aria/i18n": "^3.3.2",
38
- "@react-aria/interactions": "^3.5.0",
39
- "@react-aria/utils": "^3.0.0",
40
- "@react-aria/virtualizer": "^3.3.4",
41
- "@react-spectrum/checkbox": "^3.2.3",
42
- "@react-spectrum/divider": "^3.1.2",
43
- "@react-spectrum/layout": "^3.2.0",
44
- "@react-spectrum/progress": "^3.1.3",
45
- "@react-spectrum/utils": "^3.0.0",
46
- "@react-stately/collections": "^3.3.4",
47
- "@react-stately/grid": "^3.0.0",
48
- "@react-stately/list": "^3.3.0",
49
- "@react-stately/utils": "^3.2.1",
50
- "@react-stately/virtualizer": "^3.1.5",
51
- "@react-types/card": "3.0.0-alpha.0",
52
- "@react-types/shared": "^3.0.0"
35
+ "@react-aria/focus": "^3.5.2",
36
+ "@react-aria/grid": "^3.2.3",
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"
53
54
  },
54
55
  "devDependencies": {
55
56
  "@adobe/spectrum-css-temp": "3.0.0-alpha.1"
@@ -61,5 +62,5 @@
61
62
  "publishConfig": {
62
63
  "access": "public"
63
64
  },
64
- "gitHead": "9397d0262111f7207cb1ee2cbdda86cd5d180298"
65
+ "gitHead": "b98f0e60590d784afd54140916576021d4c1bfd7"
65
66
  }
@@ -14,9 +14,17 @@ import {Direction, KeyboardDelegate, Node} from '@react-types/shared';
14
14
  import {GridCollection} from '@react-stately/grid';
15
15
  import {InvalidationContext, Layout, LayoutInfo, Rect, Size} from '@react-stately/virtualizer';
16
16
  import {Key} from 'react';
17
+ import {Scale} from '@react-types/provider';
17
18
 
18
19
  export interface BaseLayoutOptions {
19
- collator?: Intl.Collator
20
+ collator?: Intl.Collator,
21
+ // TODO: is this valid or is scale a spectrum specific thing that should be left out of the layouts?
22
+ scale?: Scale,
23
+ /**
24
+ * The margin around the grid view between the edges and the items.
25
+ * @default 24
26
+ */
27
+ margin?: number
20
28
  }
21
29
 
22
30
  export class BaseLayout<T> extends Layout<Node<T>> implements KeyboardDelegate {
@@ -28,12 +36,16 @@ export class BaseLayout<T> extends Layout<Node<T>> implements KeyboardDelegate {
28
36
  isLoading: boolean;
29
37
  disabledKeys: Set<Key> = new Set();
30
38
  direction: Direction;
39
+ scale: Scale;
40
+ margin: number;
31
41
 
32
42
  constructor(options: BaseLayoutOptions = {}) {
33
43
  super();
34
44
  this.layoutInfos = new Map();
35
45
  this.collator = options.collator;
36
46
  this.lastCollection = null;
47
+ this.scale = options.scale || 'medium';
48
+ this.margin = options.margin || 24;
37
49
  }
38
50
 
39
51
  validate(invalidationContext: InvalidationContext<Node<T>, unknown>) {
package/src/Card.tsx CHANGED
@@ -10,14 +10,14 @@
10
10
  * governing permissions and limitations under the License.
11
11
  */
12
12
 
13
-
14
13
  import {CardBase} from './CardBase';
15
- import {DOMRef} from '@react-types/shared';
14
+ import {DOMRef, DOMRefValue, ItemProps} from '@react-types/shared';
16
15
  import {PartialNode} from '@react-stately/collections';
17
- import React, {forwardRef} from 'react';
16
+ import React, {forwardRef, ForwardRefExoticComponent, PropsWithoutRef, RefAttributes} from 'react';
18
17
  import {SpectrumCardProps} from '@react-types/card';
19
18
  import {useCardViewContext} from './CardViewContext';
20
19
 
20
+
21
21
  let Card = forwardRef((props: SpectrumCardProps, ref: DOMRef<HTMLDivElement>) => {
22
22
  let context = useCardViewContext();
23
23
  if (context !== null) {
@@ -29,10 +29,8 @@ let Card = forwardRef((props: SpectrumCardProps, ref: DOMRef<HTMLDivElement>) =>
29
29
  }
30
30
  });
31
31
 
32
- // TODO: Update the typescript for the below and the export
33
32
  // @ts-ignore
34
- // eslint-disable-next-line
35
- Card.getCollectionNode = function* getCollectionNode<T>(props, context: any): Generator<PartialNode<T>> {
33
+ Card.getCollectionNode = function* getCollectionNode<T>(props: any): Generator<PartialNode<T>> {
36
34
  let {children, textValue} = props;
37
35
 
38
36
  yield {
@@ -45,6 +43,5 @@ Card.getCollectionNode = function* getCollectionNode<T>(props, context: any): Ge
45
43
  };
46
44
  };
47
45
 
48
- // eslint-disable-next-line
49
- let _Card = Card as <T>(props, ref) => JSX.Element;
46
+ let _Card = Card as ForwardRefExoticComponent<ItemProps<SpectrumCardProps> & PropsWithoutRef<SpectrumCardProps> & RefAttributes<DOMRefValue<HTMLDivElement>>>;
50
47
  export {_Card as Card};
package/src/CardBase.tsx CHANGED
@@ -13,11 +13,11 @@
13
13
  import {AriaCardProps, SpectrumCardProps} from '@react-types/card';
14
14
  import {Checkbox} from '@react-spectrum/checkbox';
15
15
  import {classNames, SlotProvider, useDOMRef, useHasChild, useStyleProps} from '@react-spectrum/utils';
16
- import {Divider} from '@react-spectrum/divider';
17
16
  import {DOMRef, Node} from '@react-types/shared';
18
- import {filterDOMProps, mergeProps, useLayoutEffect, useSlotId} from '@react-aria/utils';
17
+ import {filterDOMProps, mergeProps, useLayoutEffect, useResizeObserver, useSlotId} from '@react-aria/utils';
19
18
  import {FocusRing} from '@react-aria/focus';
20
- import React, {HTMLAttributes, useMemo, useRef, useState} from 'react';
19
+ import {getFocusableTreeWalker} from '@react-aria/focus';
20
+ import React, {HTMLAttributes, useCallback, useMemo, useRef, useState} from 'react';
21
21
  import styles from '@adobe/spectrum-css-temp/components/card/vars.css';
22
22
  import {useCardViewContext} from './CardViewContext';
23
23
  import {useFocusWithin, useHover} from '@react-aria/interactions';
@@ -30,7 +30,6 @@ interface CardBaseProps<T> extends SpectrumCardProps {
30
30
 
31
31
  function CardBase<T extends object>(props: CardBaseProps<T>, ref: DOMRef<HTMLDivElement>) {
32
32
  props = useProviderProps(props);
33
- // TODO: Don't send in articleProps via context (unless we want to make another context for InternalCard)? Pass it in via props since it will only be provided via CardView's InternalCard
34
33
  let context = useCardViewContext() || {}; // we can call again here, won't change from Card.tsx
35
34
  let {state} = context;
36
35
  let manager = state?.selectionManager;
@@ -39,7 +38,8 @@ function CardBase<T extends object>(props: CardBaseProps<T>, ref: DOMRef<HTMLDiv
39
38
  orientation = 'vertical',
40
39
  articleProps = {},
41
40
  item,
42
- layout
41
+ layout,
42
+ children
43
43
  } = props;
44
44
 
45
45
  let key = item?.key;
@@ -51,6 +51,7 @@ function CardBase<T extends object>(props: CardBaseProps<T>, ref: DOMRef<HTMLDiv
51
51
  let {cardProps, titleProps, contentProps} = useCard(props);
52
52
  let domRef = useDOMRef(ref);
53
53
  let gridRef = useRef<HTMLDivElement>();
54
+ let checkboxRef = useRef(null);
54
55
 
55
56
  // cards are only interactive if there is a selection manager and it allows selection
56
57
  let {hoverProps, isHovered} = useHover({isDisabled: manager === undefined || manager?.selectionMode === 'none' || isDisabled});
@@ -60,8 +61,6 @@ function CardBase<T extends object>(props: CardBaseProps<T>, ref: DOMRef<HTMLDiv
60
61
  isDisabled
61
62
  });
62
63
 
63
- let hasFooter = useHasChild(`.${styles['spectrum-Card-footer']}`, gridRef);
64
-
65
64
  // ToDo: see css for comment about avatar under selector .spectrum-Card--noLayout.spectrum-Card--default
66
65
  let hasPreviewImage = useHasChild(`.${styles['spectrum-Card-image']}`, gridRef);
67
66
  let hasPreviewIllustration = useHasChild(`.${styles['spectrum-Card-illustration']}`, gridRef);
@@ -69,13 +68,16 @@ function CardBase<T extends object>(props: CardBaseProps<T>, ref: DOMRef<HTMLDiv
69
68
 
70
69
  // this is for horizontal cards
71
70
  let [height, setHeight] = useState(NaN);
72
- useLayoutEffect(() => {
71
+ let updateHeight = useCallback(() => {
73
72
  if (orientation !== 'horizontal') {
74
73
  return;
75
74
  }
75
+
76
76
  let cardHeight = gridRef.current.getBoundingClientRect().height;
77
77
  setHeight(cardHeight);
78
- }, [gridRef, setHeight, orientation]);
78
+ }, [orientation, gridRef, setHeight]);
79
+ useResizeObserver({ref: gridRef, onResize: updateHeight});
80
+
79
81
  let aspectRatioEnforce = undefined;
80
82
  if (orientation === 'horizontal' && !isNaN(height)) {
81
83
  aspectRatioEnforce = {
@@ -90,63 +92,22 @@ function CardBase<T extends object>(props: CardBaseProps<T>, ref: DOMRef<HTMLDiv
90
92
  avatar: {UNSAFE_className: classNames(styles, 'spectrum-Card-avatar'), size: 'avatar-size-400'},
91
93
  heading: {UNSAFE_className: classNames(styles, 'spectrum-Card-heading'), ...titleProps},
92
94
  content: {UNSAFE_className: classNames(styles, 'spectrum-Card-content'), ...contentProps},
93
- detail: {UNSAFE_className: classNames(styles, 'spectrum-Card-detail')},
94
- actionmenu: {UNSAFE_className: classNames(styles, 'spectrum-Card-actions'), align: 'end', isQuiet: true},
95
- footer: {UNSAFE_className: classNames(styles, 'spectrum-Card-footer'), isHidden: isQuiet},
96
- divider: {UNSAFE_className: classNames(styles, 'spectrum-Card-divider'), size: 'S'}
95
+ detail: {UNSAFE_className: classNames(styles, 'spectrum-Card-detail')}
97
96
  }), [titleProps, contentProps, height, isQuiet, orientation]);
98
97
 
99
- // This is only for quiet grid cards
100
- let [isCloseToSquare, setIsCloseToSquare] = useState(false);
101
98
  useLayoutEffect(() => {
102
- if (!(layout === 'grid' && isQuiet)) {
103
- return;
104
- }
105
- // ToDo: how to handle illustrations? what if the illustration looks like an image? What about swatches/fonts https://spectrum-contributions.corp.adobe.com/page/asset-card-beta/#File-type
106
- let image = gridRef.current.querySelector(`.${styles['spectrum-Card-image']} img`) as HTMLImageElement;
107
- if (!image) {
108
- return;
109
- }
110
- let measure = () => {
111
- let height = image.naturalHeight;
112
- let width = image.naturalWidth;
113
- /*
114
- * ToDo: Choose between min-padding and plain ratio
115
- * Do we want to just do a ratio measurement when it's close to being a square?
116
- * or do we want to actually figure out min-padding?
117
- * Min Padding would require us to check that the padding is not less than the min in both Vertical and Horizontal
118
- * Unfortunately img contain doesn't actually create padding, which is what this math below can figure out
119
- * Vs the commented out straight ratio check
120
- * */
121
- let imgTagHeight = image.clientHeight;
122
- let imgTagWidth = image.clientWidth;
123
- let ratio = Math.min(imgTagWidth / width, imgTagHeight / height);
124
- let trueHeight = ratio * height;
125
- let trueWidth = ratio * width;
126
- let paddingVertical = imgTagHeight - trueHeight;
127
- let paddingHorizontal = imgTagWidth - trueWidth;
128
- if (paddingVertical < 16 && paddingHorizontal < 16) { // ToDo: does this need to be different per scale?
129
- setIsCloseToSquare(true);
130
- } else {
131
- setIsCloseToSquare(false);
99
+ if (gridRef?.current) {
100
+ let walker = getFocusableTreeWalker(gridRef.current);
101
+ let nextNode = walker.nextNode();
102
+ while (nextNode != null) {
103
+ if (checkboxRef.current && !checkboxRef.current.UNSAFE_getDOMNode().contains(nextNode)) {
104
+ console.warn('Card does not support focusable elements, please contact the team regarding your use case.');
105
+ break;
106
+ }
107
+ nextNode = walker.nextNode();
132
108
  }
133
-
134
- // let ratio = height / width;
135
- // if (ratio > 0.9 && ratio < 1.1) {
136
- // setIsCloseToSquare(true);
137
- // }
138
- };
139
- if (image.complete) {
140
- measure();
141
- } else {
142
- image.addEventListener('load', measure);
143
- return () => {
144
- image.removeEventListener('load', measure);
145
- };
146
109
  }
147
- // ToDo: how to re-run if image src changes?
148
- }, [props.children, setIsCloseToSquare, isQuiet, layout]);
149
-
110
+ }, [children]);
150
111
 
151
112
  return (
152
113
  <FocusRing focusRingClass={classNames(styles, 'focus-ring')}>
@@ -158,7 +119,6 @@ function CardBase<T extends object>(props: CardBaseProps<T>, ref: DOMRef<HTMLDiv
158
119
  'spectrum-Card--default': !isQuiet && orientation !== 'horizontal',
159
120
  'spectrum-Card--isQuiet': isQuiet && orientation !== 'horizontal',
160
121
  'spectrum-Card--horizontal': orientation === 'horizontal',
161
- 'spectrum-Card--closeToSquare': isCloseToSquare,
162
122
  'spectrum-Card--noPreview': !hasPreview,
163
123
  'is-hovered': isHovered,
164
124
  'is-focused': isFocused,
@@ -172,6 +132,7 @@ function CardBase<T extends object>(props: CardBaseProps<T>, ref: DOMRef<HTMLDiv
172
132
  {manager && manager.selectionMode !== 'none' && (
173
133
  <div className={classNames(styles, 'spectrum-Card-checkboxWrapper')}>
174
134
  <Checkbox
135
+ ref={checkboxRef}
175
136
  isDisabled={isDisabled}
176
137
  excludeFromTabOrder
177
138
  isSelected={isSelected}
@@ -182,8 +143,7 @@ function CardBase<T extends object>(props: CardBaseProps<T>, ref: DOMRef<HTMLDiv
182
143
  </div>
183
144
  )}
184
145
  <SlotProvider slots={slots}>
185
- {props.children}
186
- {hasFooter && <Divider />}
146
+ {children}
187
147
  </SlotProvider>
188
148
  <div className={classNames(styles, 'spectrum-Card-decoration')} />
189
149
  </div>
package/src/CardView.tsx CHANGED
@@ -12,16 +12,16 @@
12
12
 
13
13
  import {CardBase} from './CardBase';
14
14
  import {CardViewContext, useCardViewContext} from './CardViewContext';
15
- import cardViewStyles from './cardview.css';
16
15
  import {classNames, useDOMRef, useStyleProps, useUnwrapDOMRef} from '@react-spectrum/utils';
17
16
  import {DOMRef, DOMRefValue, Node} from '@react-types/shared';
18
17
  import {GridCollection, useGridState} from '@react-stately/grid';
19
18
  // @ts-ignore
20
19
  import intlMessages from '../intl/*.json';
21
20
  import {ProgressCircle} from '@react-spectrum/progress';
22
- import React, {ReactElement, useMemo, useRef} from 'react';
21
+ import React, {ReactElement, useCallback, useMemo, useRef} from 'react';
23
22
  import {ReusableView} from '@react-stately/virtualizer';
24
23
  import {SpectrumCardViewProps} from '@react-types/card';
24
+ import styles from '@adobe/spectrum-css-temp/components/card/vars.css';
25
25
  import {useCollator, useLocale, useMessageFormatter} from '@react-aria/i18n';
26
26
  import {useGrid, useGridCell, useGridRow} from '@react-aria/grid';
27
27
  import {useListState} from '@react-stately/list';
@@ -37,21 +37,15 @@ function CardView<T extends object>(props: SpectrumCardViewProps<T>, ref: DOMRef
37
37
  renderEmptyState,
38
38
  layout,
39
39
  loadingState,
40
- onLoadMore
40
+ onLoadMore,
41
+ cardOrientation = 'vertical'
41
42
  } = props;
43
+
42
44
  let collator = useCollator({usage: 'search', sensitivity: 'base'});
43
45
  let isLoading = loadingState === 'loading' || loadingState === 'loadingMore';
44
- let cardViewLayout = useMemo(() => typeof layout === 'function' ? new layout({collator}) : layout, [layout, collator]);
46
+ let cardViewLayout = useMemo(() => typeof layout === 'function' ? new layout({collator, cardOrientation, scale}) : layout, [layout, collator, cardOrientation, scale]);
45
47
  let layoutType = cardViewLayout.layoutType;
46
48
 
47
- if (typeof layout === 'function') {
48
- if (layoutType === 'grid') {
49
- cardViewLayout.itemPadding = scale === 'large' ? 116 : 95;
50
- } else if (layoutType === 'gallery') {
51
- cardViewLayout.itemPadding = scale === 'large' ? 143 : 114;
52
- }
53
- }
54
-
55
49
  let formatMessage = useMessageFormatter(intlMessages);
56
50
  let {direction} = useLocale();
57
51
  let {collection} = useListState(props);
@@ -77,7 +71,9 @@ function CardView<T extends object>(props: SpectrumCardViewProps<T>, ref: DOMRef
77
71
 
78
72
  let state = useGridState({
79
73
  ...props,
80
- collection: gridCollection
74
+ selectionMode: cardOrientation === 'horizontal' && layoutType === 'grid' ? 'none' : props.selectionMode,
75
+ collection: gridCollection,
76
+ focusMode: 'cell'
81
77
  });
82
78
 
83
79
  cardViewLayout.collection = gridCollection;
@@ -94,7 +90,6 @@ function CardView<T extends object>(props: SpectrumCardViewProps<T>, ref: DOMRef
94
90
  type View = ReusableView<Node<T>, unknown>;
95
91
  let renderWrapper = (parent: View, reusableView: View) => (
96
92
  <VirtualizerItem
97
- className={classNames(cardViewStyles, 'react-spectrum-CardView-CardWrapper')}
98
93
  key={reusableView.key}
99
94
  reusableView={reusableView}
100
95
  parent={parent} />
@@ -106,13 +101,22 @@ function CardView<T extends object>(props: SpectrumCardViewProps<T>, ref: DOMRef
106
101
  focusedKey = focusedItem.parentKey;
107
102
  }
108
103
 
104
+ let margin = cardViewLayout.margin || 0;
105
+ let virtualizer = cardViewLayout.virtualizer;
106
+ let scrollToItem = useCallback((key) => {
107
+ virtualizer && virtualizer.scrollToItem(key, {
108
+ duration: 0,
109
+ offsetY: margin
110
+ });
111
+ }, [margin, virtualizer]);
112
+
109
113
  // TODO: does aria-row count and aria-col count need to be modified? Perhaps aria-col count needs to be omitted
110
114
  return (
111
- <CardViewContext.Provider value={{state, isQuiet, layout: cardViewLayout}}>
115
+ <CardViewContext.Provider value={{state, isQuiet, layout: cardViewLayout, cardOrientation}}>
112
116
  <Virtualizer
113
117
  {...gridProps}
114
118
  {...styleProps}
115
- className={classNames(cardViewStyles, 'react-spectrum-CardView')}
119
+ className={classNames(styles, 'spectrum-CardView')}
116
120
  ref={domRef}
117
121
  focusedKey={focusedKey}
118
122
  scrollDirection="vertical"
@@ -120,7 +124,9 @@ function CardView<T extends object>(props: SpectrumCardViewProps<T>, ref: DOMRef
120
124
  collection={gridCollection}
121
125
  isLoading={isLoading}
122
126
  onLoadMore={onLoadMore}
123
- renderWrapper={renderWrapper}>
127
+ renderWrapper={renderWrapper}
128
+ transitionDuration={isLoading ? 160 : 220}
129
+ scrollToItem={scrollToItem}>
124
130
  {(type, item) => {
125
131
  if (type === 'item') {
126
132
  return (
@@ -159,7 +165,7 @@ function CenteredWrapper({children}) {
159
165
  <div
160
166
  role="row"
161
167
  aria-rowindex={state.collection.size + 1}
162
- className={classNames(cardViewStyles, 'react-spectrum-CardView-centeredWrapper')}>
168
+ className={classNames(styles, 'spectrum-CardView-centeredWrapper')}>
163
169
  <div role="gridcell">
164
170
  {children}
165
171
  </div>
@@ -194,8 +200,16 @@ function InternalCard(props) {
194
200
  isQuiet = true;
195
201
  }
196
202
 
203
+ if (layoutType !== 'grid') {
204
+ cardOrientation = 'vertical';
205
+ }
206
+
207
+ // We don't want to focus the checkbox (or any other focusable elements) within the Card
208
+ // when pressing the arrow keys so we delete the key down handler here. Arrow key navigation between
209
+ // the cards in the CardView is handled by useGrid => useSelectableCollection instead.
210
+ delete gridCellProps.onKeyDownCapture;
197
211
  return (
198
- <div {...rowProps} ref={rowRef} style={{height: '100%'}}>
212
+ <div {...rowProps} ref={rowRef} className={classNames(styles, 'spectrum-CardView-row')}>
199
213
  <CardBase
200
214
  ref={cellRef}
201
215
  articleProps={gridCellProps}