Skip to content

Commit 9285000

Browse files
committed
fix waterfall layout options
1 parent 4feaebc commit 9285000

File tree

4 files changed

+32
-4
lines changed

4 files changed

+32
-4
lines changed

packages/@react-stately/layout/src/WaterfallLayout.ts

+29-2
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,36 @@
1111
*/
1212

1313
import {DropTarget, DropTargetDelegate, Key, LayoutDelegate, Node} from '@react-types/shared';
14-
import {GridLayoutOptions} from './GridLayout';
1514
import {InvalidationContext, Layout, LayoutInfo, Point, Rect, Size} from '@react-stately/virtualizer';
1615

16+
export interface WaterfallLayoutOptions {
17+
/**
18+
* The minimum item size.
19+
* @default 200 x 200
20+
*/
21+
minItemSize?: Size,
22+
/**
23+
* The maximum item size.
24+
* @default Infinity
25+
*/
26+
maxItemSize?: Size,
27+
/**
28+
* The minimum space required between items.
29+
* @default 18 x 18
30+
*/
31+
minSpace?: Size,
32+
/**
33+
* The maximum number of columns.
34+
* @default Infinity
35+
*/
36+
maxColumns?: number,
37+
/**
38+
* The thickness of the drop indicator.
39+
* @default 2
40+
*/
41+
dropIndicatorThickness?: number
42+
}
43+
1744
class WaterfallLayoutInfo extends LayoutInfo {
1845
column = 0;
1946

@@ -32,7 +59,7 @@ const DEFAULT_OPTIONS = {
3259
dropIndicatorThickness: 2
3360
};
3461

35-
export class WaterfallLayout<T extends object, O extends GridLayoutOptions = GridLayoutOptions> extends Layout<Node<T>, O> implements LayoutDelegate, DropTargetDelegate {
62+
export class WaterfallLayout<T extends object, O extends WaterfallLayoutOptions = WaterfallLayoutOptions> extends Layout<Node<T>, O> implements LayoutDelegate, DropTargetDelegate {
3663
private contentSize: Size = new Size();
3764
private layoutInfos: Map<Key, WaterfallLayoutInfo> = new Map();
3865
protected numColumns = 0;

packages/@react-stately/layout/src/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
export type {GridLayoutOptions} from './GridLayout';
1313
export type {ListLayoutOptions, LayoutNode} from './ListLayout';
1414
export type {TableLayoutProps} from './TableLayout';
15+
export type {WaterfallLayoutOptions} from './WaterfallLayout';
1516
export {GridLayout} from './GridLayout';
1617
export {ListLayout} from './ListLayout';
1718
export {TableLayout} from './TableLayout';

packages/react-aria-components/docs/Virtualizer.mdx

+1-1
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ function Example() {
277277
`WaterfallLayout` arranges variable height items in a column layout. The columns are sized between a minimum and maximum size depending on the width of the container. It supports the following options:
278278

279279
<TypeContext.Provider value={docs.links}>
280-
<InterfaceType {...docs.exports.GridLayoutOptions} />
280+
<InterfaceType {...docs.exports.WaterfallLayoutOptions} />
281281
</TypeContext.Provider>
282282

283283
```tsx import

packages/react-aria-components/src/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,4 +149,4 @@ export type {DirectoryDropItem, DraggableCollectionEndEvent, DraggableCollection
149149
export type {Key, Selection, SortDescriptor, SortDirection, SelectionMode} from 'react-stately';
150150
export type {ValidationResult, RouterConfig} from '@react-types/shared';
151151
export type {Color, ColorSpace, ColorFormat} from '@react-types/color';
152-
export type {ListLayoutOptions, GridLayoutOptions} from '@react-stately/layout';
152+
export type {ListLayoutOptions, GridLayoutOptions, WaterfallLayoutOptions} from '@react-stately/layout';

0 commit comments

Comments
 (0)