|
6 | 6 |
|
7 | 7 | import React, { Component, PropTypes } from 'react'; |
8 | 8 | import { AutoSizer, VirtualScroll } from 'react-virtualized'; |
| 9 | +import 'react-virtualized/styles.css'; |
9 | 10 | import TreeNode from './tree-node'; |
10 | 11 | import { |
11 | 12 | walk, |
@@ -172,12 +173,13 @@ class ReactSortableTree extends Component { |
172 | 173 |
|
173 | 174 | render() { |
174 | 175 | const { |
| 176 | + style = {}, |
175 | 177 | rowHeight, |
176 | 178 | } = this.props; |
177 | 179 | const { rows } = this.state; |
178 | 180 |
|
179 | 181 | return ( |
180 | | - <div className={styles.tree}> |
| 182 | + <div className={styles.tree} style={{ height: '100%', ...style }}> |
181 | 183 | <AutoSizer> |
182 | 184 | {({height, width}) => ( |
183 | 185 | <VirtualScroll |
@@ -229,8 +231,16 @@ class ReactSortableTree extends Component { |
229 | 231 | ReactSortableTree.propTypes = { |
230 | 232 | treeData: PropTypes.arrayOf(PropTypes.object).isRequired, |
231 | 233 | changeData: PropTypes.func, |
| 234 | + |
| 235 | + // Callback for move operation. |
| 236 | + // Called as moveNode({ node, path, newParentPath, newChildIndex }) |
232 | 237 | moveNode: PropTypes.func, |
233 | | - rowHeight: PropTypes.oneOfType([ PropTypes.number, PropTypes.func ]), // Used for react-virtualized |
| 238 | + |
| 239 | + // Style applied to the container wrapping the tree (style defaults to {height: '100%'}) |
| 240 | + style: PropTypes.object, |
| 241 | + |
| 242 | + // Height of each node row, used for react-virtualized |
| 243 | + rowHeight: PropTypes.oneOfType([ PropTypes.number, PropTypes.func ]), |
234 | 244 |
|
235 | 245 | scaffoldBlockPxWidth: PropTypes.number, |
236 | 246 |
|
|
0 commit comments