|
1 | 1 | import React, {Component, PropTypes} from 'react';
|
| 2 | +import ReactDOM from 'react-dom'; |
2 | 3 | import {storiesOf} from '@kadira/storybook';
|
3 | 4 | import style from './Storybook.scss';
|
4 | 5 | import {SortableContainer, SortableElement, SortableHandle, arrayMove} from '../index';
|
5 |
| -import {VirtualScroll} from 'react-virtualized'; |
| 6 | +import {defaultFlexTableRowRenderer, FlexColumn, FlexTable, VirtualScroll} from 'react-virtualized'; |
6 | 7 | import 'react-virtualized/styles.css';
|
7 | 8 | import Infinite from 'react-infinite';
|
8 | 9 | import range from 'lodash/range';
|
@@ -95,6 +96,50 @@ class VirtualList extends Component {
|
95 | 96 | }
|
96 | 97 | const SortableVirtualList = SortableContainer(VirtualList, {withRef: true});
|
97 | 98 |
|
| 99 | +const SortableFlexTable = SortableContainer(FlexTable, {withRef: true}); |
| 100 | +const SortableRowRenderer = SortableElement(defaultFlexTableRowRenderer); |
| 101 | + |
| 102 | +class FlexTableWrapper extends Component { |
| 103 | + render () { |
| 104 | + const { |
| 105 | + className, |
| 106 | + height, |
| 107 | + itemClass, |
| 108 | + itemHeight, |
| 109 | + items, |
| 110 | + onSortEnd, |
| 111 | + width |
| 112 | + } = this.props |
| 113 | + |
| 114 | + return ( |
| 115 | + <SortableFlexTable |
| 116 | + getContainer={(wrappedInstance) => ReactDOM.findDOMNode(wrappedInstance._grid)} |
| 117 | + gridClassName={className} |
| 118 | + headerHeight={itemHeight} |
| 119 | + height={height} |
| 120 | + onSortEnd={onSortEnd} |
| 121 | + rowClassName={itemClass} |
| 122 | + rowCount={items.length} |
| 123 | + rowGetter={({ index }) => items[index]} |
| 124 | + rowHeight={itemHeight} |
| 125 | + rowRenderer={(props) => <SortableRowRenderer {...props} />} |
| 126 | + width={width} |
| 127 | + > |
| 128 | + <FlexColumn |
| 129 | + label='Index' |
| 130 | + dataKey='value' |
| 131 | + width={100} |
| 132 | + /> |
| 133 | + <FlexColumn |
| 134 | + label='Height' |
| 135 | + dataKey='height' |
| 136 | + width={width - 100} |
| 137 | + /> |
| 138 | + </SortableFlexTable> |
| 139 | + ); |
| 140 | + } |
| 141 | +} |
| 142 | + |
98 | 143 | const SortableInfiniteList = SortableContainer(({className, items, itemClass, sortingIndex, useWindowAsScrollContainer}) => {
|
99 | 144 | return (
|
100 | 145 | <Infinite
|
@@ -224,6 +269,13 @@ storiesOf('React Virtualized', module)
|
224 | 269 | </div>
|
225 | 270 | );
|
226 | 271 | })
|
| 272 | +.add('FlexTable usage', () => { |
| 273 | + return ( |
| 274 | + <div className={style.root}> |
| 275 | + <ListWrapper component={FlexTableWrapper} items={getItems(500, 40)} itemHeight={40} helperClass={style.stylizedHelper} /> |
| 276 | + </div> |
| 277 | + ); |
| 278 | +}) |
227 | 279 |
|
228 | 280 | storiesOf('React Infinite', module)
|
229 | 281 | .add('Basic usage', () => {
|
|
0 commit comments