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

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,8 +1,9 @@
1
- import { DOMRefValue, Direction, KeyboardDelegate, Node } from "@react-types/shared";
1
+ import { DOMRefValue, Direction, KeyboardDelegate, Node, Orientation } from "@react-types/shared";
2
2
  import React, { Key } from "react";
3
3
  import { SpectrumCardViewProps } 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
  */
@@ -11,6 +12,12 @@ export const CardView: <T>(props: SpectrumCardViewProps<T> & {
11
12
  }) => 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>)>;
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;
@@ -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
@@ -179,7 +177,6 @@ export interface WaterfallLayoutOptions extends BaseLayoutOptions {
179
177
  export class WaterfallLayout<T> extends BaseLayout<T> implements KeyboardDelegate {
180
178
  protected minItemSize: Size;
181
179
  protected maxItemSize: Size;
182
- protected margin: number;
183
180
  protected minSpace: Size;
184
181
  protected maxColumns: number;
185
182
  itemPadding: number;
@@ -1 +1 @@
1
- {"mappings":"A;A;A;A;A;AEmNA;A;GAEG;AACH,OAAA,MAAM;A;6MAA+H,CAAC;ACrMtI;IACE,QAAQ,CAAC,EAAE,KAAK,QAAQ,CAAA;CACzB;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;gBAET,OAAO,GAAE,iBAAsB;IAO3C,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,cAAc;IAId,aAAa,CAAC,GAAG,EAAE,GAAG;IAItB,qBAAqB,CAAC,IAAI,KAAA;IAY1B,SAAS,CAAC,UAAU,EAAE,UAAU,EAAE,IAAI,EAAE,IAAI;IAI5C,oBAAoB,CAAC,UAAU,E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ages/@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":"A;A;A;A;A;A;AE6NA;A;GAEG;AACH,OAAA,MAAM;A;6MAA+H,CAAC;AC9MtI;IACE,QAAQ,CAAC,EAAE,KAAK,QAAQ,CAAC;IAEzB,KAAK,CAAC,EAAE,KAAK,CAAC;IACd;A;A;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,GA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,GAAG;IAcvB,aAAa,CAAC,GAAG,EAAE,GAAG;IAMtB,YAAY,CAAC,GAAG,EAAE,GAAG;CAKtB;ACtMD,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"}
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.1",
4
4
  "description": "Spectrum UI components in React",
5
5
  "license": "Apache-2.0",
6
6
  "main": "dist/main.js",
@@ -33,23 +33,24 @@
33
33
  "dependencies": {
34
34
  "@babel/runtime": "^7.6.2",
35
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",
36
+ "@react-aria/grid": "^3.1.0",
37
+ "@react-aria/i18n": "^3.3.3",
38
+ "@react-aria/interactions": "^3.7.0",
39
+ "@react-aria/utils": "^3.10.0",
40
+ "@react-aria/virtualizer": "^3.3.5",
41
41
  "@react-spectrum/checkbox": "^3.2.3",
42
42
  "@react-spectrum/divider": "^3.1.2",
43
43
  "@react-spectrum/layout": "^3.2.0",
44
44
  "@react-spectrum/progress": "^3.1.3",
45
- "@react-spectrum/utils": "^3.0.0",
45
+ "@react-spectrum/utils": "^3.6.3",
46
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"
47
+ "@react-stately/grid": "^3.1.0",
48
+ "@react-stately/list": "^3.4.0",
49
+ "@react-stately/utils": "^3.3.0",
50
+ "@react-stately/virtualizer": "^3.1.6",
51
+ "@react-types/card": "3.0.0-alpha.1",
52
+ "@react-types/provider": "^3.3.2",
53
+ "@react-types/shared": "^3.10.0"
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": "896eabe5521a0349a675c4773ed7629addd4b8c4"
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/CardBase.tsx CHANGED
@@ -15,9 +15,9 @@ import {Checkbox} from '@react-spectrum/checkbox';
15
15
  import {classNames, SlotProvider, useDOMRef, useHasChild, useStyleProps} from '@react-spectrum/utils';
16
16
  import {Divider} from '@react-spectrum/divider';
17
17
  import {DOMRef, Node} from '@react-types/shared';
18
- import {filterDOMProps, mergeProps, useLayoutEffect, useSlotId} from '@react-aria/utils';
18
+ import {filterDOMProps, mergeProps, useLayoutEffect, useResizeObserver, useSlotId} from '@react-aria/utils';
19
19
  import {FocusRing} from '@react-aria/focus';
20
- import React, {HTMLAttributes, useMemo, useRef, useState} from 'react';
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;
@@ -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 = {
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,12 @@ function InternalCard(props) {
194
200
  isQuiet = true;
195
201
  }
196
202
 
203
+ if (layoutType !== 'grid') {
204
+ cardOrientation = 'vertical';
205
+ }
206
+
197
207
  return (
198
- <div {...rowProps} ref={rowRef} style={{height: '100%'}}>
208
+ <div {...rowProps} ref={rowRef} className={classNames(styles, 'spectrum-CardView-row')}>
199
209
  <CardBase
200
210
  ref={cellRef}
201
211
  articleProps={gridCellProps}
@@ -43,22 +43,14 @@ export interface GalleryLayoutOptions extends BaseLayoutOptions {
43
43
  * will be targeted.
44
44
  * @type {number}
45
45
  */
46
- threshold?: number,
47
- /**
48
- * The margin around the grid view between the edges and the items.
49
- * @default 24
50
- */
51
- margin?: number // TODO: Perhaps should accept Responsive<DimensionValue>
46
+ threshold?: number
52
47
  }
53
48
 
54
- // TODO: copied from V2, update this with the proper spectrum values
55
- // Should these be affected by Scale as well?
56
49
  const DEFAULT_OPTIONS = {
57
50
  S: {
58
51
  idealRowHeight: 112,
59
52
  minItemSize: new Size(96, 96),
60
53
  itemSpacing: new Size(8, 16),
61
- // TODO: will need to update as well
62
54
  itemPadding: 24,
63
55
  dropSpacing: 50,
64
56
  margin: 8
@@ -67,8 +59,10 @@ const DEFAULT_OPTIONS = {
67
59
  idealRowHeight: 208,
68
60
  minItemSize: new Size(136, 136),
69
61
  itemSpacing: new Size(18, 18),
70
- // TODO: updated to work with new v3 cards (there is additional space required for the descriptions if there is a description)
71
- itemPadding: 114,
62
+ itemPadding: {
63
+ 'medium': 114,
64
+ 'large': 143
65
+ },
72
66
  dropSpacing: 100,
73
67
  margin: 24
74
68
  }
@@ -76,7 +70,6 @@ const DEFAULT_OPTIONS = {
76
70
 
77
71
  export class GalleryLayout<T> extends BaseLayout<T> {
78
72
  protected idealRowHeight: number;
79
- protected margin: number;
80
73
  protected itemSpacing: Size;
81
74
  itemPadding: number;
82
75
  protected minItemSize: Size;
@@ -84,11 +77,10 @@ export class GalleryLayout<T> extends BaseLayout<T> {
84
77
 
85
78
  constructor(options: GalleryLayoutOptions = {}) {
86
79
  super(options);
87
- // TODO: restore cardSize option when we support different size cards
88
80
  let cardSize = 'L';
89
81
  this.idealRowHeight = options.idealRowHeight || DEFAULT_OPTIONS[cardSize].idealRowHeight;
90
82
  this.itemSpacing = options.itemSpacing || DEFAULT_OPTIONS[cardSize].itemSpacing;
91
- this.itemPadding = options.itemPadding != null ? options.itemPadding : DEFAULT_OPTIONS[cardSize].itemPadding;
83
+ this.itemPadding = options.itemPadding != null ? options.itemPadding : DEFAULT_OPTIONS[cardSize].itemPadding[this.scale];
92
84
  this.minItemSize = options.minItemSize || DEFAULT_OPTIONS[cardSize].minItemSize;
93
85
  this.threshold = options.threshold || 1;
94
86
  this.margin = options.margin != null ? options.margin : DEFAULT_OPTIONS[cardSize].margin;
@@ -213,6 +205,7 @@ export class GalleryLayout<T> extends BaseLayout<T> {
213
205
  let itemWidth = Math.max(widths[j - index][1], this.minItemSize.width);
214
206
  let rect = new Rect(x, y, itemWidth, itemHeight);
215
207
  let layoutInfo = new LayoutInfo(node.type, node.key, rect);
208
+ layoutInfo.allowOverflow = true;
216
209
  this.layoutInfos.set(node.key, layoutInfo);
217
210
  x += itemWidth + this.itemSpacing.width;
218
211
  }
@@ -13,7 +13,7 @@
13
13
  import {BaseLayout, BaseLayoutOptions} from './BaseLayout';
14
14
  import {Key} from 'react';
15
15
  import {LayoutInfo, Rect, Size} from '@react-stately/virtualizer';
16
- import {Node} from '@react-types/shared';
16
+ import {Node, Orientation} from '@react-types/shared';
17
17
 
18
18
  export interface GridLayoutOptions extends BaseLayoutOptions {
19
19
  // /**
@@ -22,7 +22,7 @@ export interface GridLayoutOptions extends BaseLayoutOptions {
22
22
  // cardSize?: 'S' | 'M' | 'L',
23
23
  /**
24
24
  * The minimum item size.
25
- * @default 208 x 208
25
+ * @default 208 x 208 for horizontal card orientation. 102 x 102 for vertical card orientation.
26
26
  */
27
27
  minItemSize?: Size,
28
28
  /**
@@ -30,11 +30,6 @@ export interface GridLayoutOptions extends BaseLayoutOptions {
30
30
  * @default Infinity
31
31
  */
32
32
  maxItemSize?: Size,
33
- /**
34
- * The margin around the grid view between the edges and the items.
35
- * @default 24
36
- */
37
- margin?: number, // TODO: Perhaps should accept Responsive<DimensionValue>
38
33
  /**
39
34
  * The minimum space required between items.
40
35
  * @default 18 x 18
@@ -46,18 +41,23 @@ export interface GridLayoutOptions extends BaseLayoutOptions {
46
41
  */
47
42
  maxColumns?: number,
48
43
  /**
49
- * The vertical padding for an item.
44
+ * The additional padding along the card's main axis. Affects the sizing of the content area following the card image.
50
45
  * @default 95
51
46
  */
52
- itemPadding?: number
47
+ itemPadding?: number,
48
+ /**
49
+ * The orientation of the cards withn the grid.
50
+ * @default vertical
51
+ */
52
+ cardOrientation?: Orientation
53
53
  }
54
54
 
55
- // TODO: copied from V2, update this with the proper spectrum values
56
- // Should these be affected by Scale as well?
57
55
  const DEFAULT_OPTIONS = {
58
56
  S: {
59
57
  itemPadding: 20,
60
- minItemSize: new Size(96, 96),
58
+ minItemSize: {
59
+ 'vertical': new Size(96, 96)
60
+ },
61
61
  maxItemSize: new Size(Infinity, Infinity),
62
62
  margin: 8,
63
63
  minSpace: new Size(6, 6),
@@ -65,10 +65,20 @@ const DEFAULT_OPTIONS = {
65
65
  dropSpacing: 50
66
66
  },
67
67
  L: {
68
- // TODO: for now bumping this higher since the new cards have more stuff in the content area.
69
- // Will need to ask Spectrum what these values should be. Used to be 52. Do the same for S above
70
- itemPadding: 95,
71
- minItemSize: new Size(208, 208),
68
+ itemPadding: {
69
+ 'vertical': {
70
+ 'medium': 78,
71
+ 'large': 98
72
+ },
73
+ 'horizontal': {
74
+ 'medium': 150,
75
+ 'large': 170
76
+ }
77
+ },
78
+ minItemSize: {
79
+ 'vertical': new Size(208, 208),
80
+ 'horizontal': new Size(102, 102)
81
+ },
72
82
  maxItemSize: new Size(Infinity, Infinity),
73
83
  margin: 24,
74
84
  minSpace: new Size(18, 18),
@@ -80,10 +90,10 @@ const DEFAULT_OPTIONS = {
80
90
  export class GridLayout<T> extends BaseLayout<T> {
81
91
  protected minItemSize: Size;
82
92
  protected maxItemSize: Size;
83
- protected margin: number;
84
93
  protected minSpace: Size;
85
94
  protected maxColumns: number;
86
95
  itemPadding: number;
96
+ cardOrientation: Orientation;
87
97
  protected itemSize: Size;
88
98
  protected numColumns: number;
89
99
  protected numRows: number;
@@ -91,14 +101,14 @@ export class GridLayout<T> extends BaseLayout<T> {
91
101
 
92
102
  constructor(options: GridLayoutOptions = {}) {
93
103
  super(options);
94
- // TODO: restore cardSize option when we support different size cards
95
104
  let cardSize = 'L';
96
- this.minItemSize = options.minItemSize || DEFAULT_OPTIONS[cardSize].minItemSize;
105
+ this.cardOrientation = options.cardOrientation || 'vertical';
106
+ this.minItemSize = options.minItemSize || DEFAULT_OPTIONS[cardSize].minItemSize[this.cardOrientation];
97
107
  this.maxItemSize = options.maxItemSize || DEFAULT_OPTIONS[cardSize].maxItemSize;
98
108
  this.margin = options.margin != null ? options.margin : DEFAULT_OPTIONS[cardSize].margin;
99
109
  this.minSpace = options.minSpace || DEFAULT_OPTIONS[cardSize].minSpace;
100
110
  this.maxColumns = options.maxColumns || DEFAULT_OPTIONS[cardSize].maxColumns;
101
- this.itemPadding = options.itemPadding != null ? options.itemPadding : DEFAULT_OPTIONS[cardSize].itemPadding;
111
+ this.itemPadding = options.itemPadding != null ? options.itemPadding : DEFAULT_OPTIONS[cardSize].itemPadding[this.cardOrientation][this.scale];
102
112
  this.itemSize = null;
103
113
  this.numColumns = 0;
104
114
  this.numRows = 0;
@@ -109,7 +119,6 @@ export class GridLayout<T> extends BaseLayout<T> {
109
119
  return 'grid';
110
120
  }
111
121
 
112
- // TODO: Below functions From V2 Maybe don't need this? Might be a short cut for getting all visible rects since otherwise we'd have to iterate across all nodes
113
122
  getIndexAtPoint(x, y, allowInsertingAtEnd = false) {
114
123
  let itemHeight = this.itemSize.height + this.minSpace.height;
115
124
  let itemWidth = this.itemSize.width + this.horizontalSpacing;
@@ -141,7 +150,7 @@ export class GridLayout<T> extends BaseLayout<T> {
141
150
  for (let index = firstVisibleItem; index <= lastVisibleItem; index++) {
142
151
  let keyFromIndex = this.collection.rows[index].key;
143
152
  let layoutInfo = this.layoutInfos.get(keyFromIndex);
144
- if (this.isVisible(layoutInfo, rect)) {
153
+ if (layoutInfo && this.isVisible(layoutInfo, rect)) {
145
154
  res.push(layoutInfo);
146
155
  }
147
156
  }
@@ -159,10 +168,13 @@ export class GridLayout<T> extends BaseLayout<T> {
159
168
  buildCollection() {
160
169
  let visibleWidth = this.virtualizer.visibleRect.width;
161
170
  let visibleHeight = this.virtualizer.visibleRect.height;
171
+ let horizontalItemPadding = this.cardOrientation === 'horizontal' ? this.itemPadding : 0;
172
+ let verticalItemPadding = this.cardOrientation === 'vertical' ? this.itemPadding : 0;
173
+ let minCardWidth = this.minItemSize.width + horizontalItemPadding;
162
174
 
163
175
  // Compute the number of rows and columns needed to display the content
164
176
  let availableWidth = visibleWidth - this.margin * 2;
165
- let columns = Math.floor((availableWidth + this.minSpace.width) / (this.minItemSize.width + this.minSpace.width));
177
+ let columns = Math.floor((availableWidth + this.minSpace.width) / (minCardWidth + this.minSpace.width));
166
178
  this.numColumns = Math.max(1, Math.min(this.maxColumns, columns));
167
179
  this.numRows = Math.ceil(this.collection.size / this.numColumns);
168
180
 
@@ -171,13 +183,11 @@ export class GridLayout<T> extends BaseLayout<T> {
171
183
 
172
184
  // Compute the item width based on the space available
173
185
  let itemWidth = Math.floor(width / this.numColumns);
174
- itemWidth = Math.max(this.minItemSize.width, Math.min(this.maxItemSize.width, itemWidth));
175
-
186
+ itemWidth = Math.max(minCardWidth, Math.min(this.maxItemSize.width, itemWidth));
176
187
  // Compute the item height, which is proportional to the item width
177
- let t = ((itemWidth - this.minItemSize.width) / this.minItemSize.width);
178
- let itemHeight = this.minItemSize.height + this.minItemSize.height * t;
179
- itemHeight = Math.max(this.minItemSize.height, Math.min(this.maxItemSize.height, itemHeight)) + this.itemPadding;
180
-
188
+ let t = ((itemWidth - minCardWidth) / minCardWidth);
189
+ let itemHeight = Math.floor(this.minItemSize.height + this.minItemSize.height * t);
190
+ itemHeight = Math.max(this.minItemSize.height, Math.min(this.maxItemSize.height, itemHeight)) + verticalItemPadding;
181
191
  this.itemSize = new Size(itemWidth, itemHeight);
182
192
 
183
193
  // Compute the horizontal spacing and content height
@@ -226,6 +236,7 @@ export class GridLayout<T> extends BaseLayout<T> {
226
236
  let rect = new Rect(x, y, this.itemSize.width, this.itemSize.height);
227
237
  // TODO: Perhaps have it so that the child key for each row is stored with the layoutInfo?
228
238
  let layoutInfo = new LayoutInfo(node.type, node.key, rect);
239
+ layoutInfo.allowOverflow = true;
229
240
  this.layoutInfos.set(node.key, layoutInfo);
230
241
  return layoutInfo;
231
242
  }
@@ -26,11 +26,6 @@ export interface WaterfallLayoutOptions extends BaseLayoutOptions {
26
26
  * @default Infinity
27
27
  */
28
28
  maxItemSize?: Size,
29
- /**
30
- * The margin around the grid view between the edges and the items.
31
- * @default 24
32
- */
33
- margin?: number, // TODO: Perhaps should accept Responsive<DimensionValue>
34
29
  /**
35
30
  * The minimum space required between items.
36
31
  * @default 18 x 18
@@ -52,7 +47,6 @@ export interface WaterfallLayoutOptions extends BaseLayoutOptions {
52
47
  export class WaterfallLayout<T> extends BaseLayout<T> implements KeyboardDelegate {
53
48
  protected minItemSize: Size;
54
49
  protected maxItemSize: Size;
55
- protected margin: number;
56
50
  protected minSpace: Size;
57
51
  protected maxColumns: number;
58
52
  itemPadding: number;
@@ -133,6 +127,7 @@ export class WaterfallLayout<T> extends BaseLayout<T> implements KeyboardDelegat
133
127
  let rect = new Rect(x, y, itemWidth, height);
134
128
  let layoutInfo = new LayoutInfo(node.type, key, rect);
135
129
  layoutInfo.estimatedSize = estimatedSize;
130
+ layoutInfo.allowOverflow = true;
136
131
  this.layoutInfos.set(key, layoutInfo);
137
132
 
138
133
  // TODO: From v2 figure out this bit, when does this get called and what to replace this.collectionView._transaction with?