|
2 | 2 |
|
3 | 3 | [](https://www.npmjs.com/package/react-vtree) |
4 | 4 | [](./LICENSE) |
5 | | -[](https://travis-ci.org/Lodin/react-vtree) |
6 | | -[](https://codecov.io/gh/Lodin/react-vtree) |
| 5 | +[](https://github.com/Lodin/react-vtree/actions) |
| 6 | +[](https://sonarcloud.io/dashboard?id=Lodin_react-vtree) |
| 7 | +[](https://sonarcloud.io/dashboard?id=Lodin_react-vtree) |
| 8 | +[](https://sonarcloud.io/dashboard?id=Lodin_react-vtree) |
7 | 9 |
|
8 | 10 | This package provides a lightweight and flexible solution for rendering large tree structures. It is built on top of the [react-window](https://github.com/bvaughn/react-window) library. |
9 | 11 |
|
@@ -170,11 +172,19 @@ This method runs the `treeWalker` function again and, basing on the received opt |
170 | 172 | It receives options object with the following parameters: |
171 | 173 |
|
172 | 174 | - `opennessState: Record<string, boolean>` - nodes whose IDs are specified as keys of this object will be opened or closed according to boolean values. If the value is `true`, node will be opened; otherwise, it will be closed. This object can be used for changing nodes' openness programmatically without re-creating the `treeWalker` generator. |
173 | | - |
| 175 | + |
174 | 176 | **NOTE**: If you specify both `useDefaultOpenness` and `opennessState`, `opennessState` will be overridden by `useDefaultOpenness` results. |
| 177 | + |
175 | 178 | - `refreshNodes: boolean` - if this parameter is `true`, `treeWalker` will receive `refresh` option, and the component will expect the data object yielded. If this parameter is either `false` or not provided, the component will expect string id. |
176 | 179 | - `useDefaultOpenness: boolean` - if this parameter is `true`, openness state of all nodes will be reset to `isOpenByDefault`. Nodes updated during the tree walking will use the new `isOpenByDefault` value. |
177 | 180 |
|
| 181 | +#### Types |
| 182 | + |
| 183 | +- `FixedSizeNodeData` - object the `treeWalker` generator function yields for each new node. By default, it contains only `id` and `isOpenByDefault` fields, but you can add any number of additional fields; they will be sent directly to the Node component. To describe that data, you have to create a new type that extends the `FixedSizeNodeData` type. |
| 184 | +- `FixedSizeNodeComponentProps<T extends FixedSizeNodeData>` - props that `Node` component receives. They are described in the Props [children](#children) section. |
| 185 | +- `FixedSizeTreeProps<T extends FixedSizeNodeData>` - props that `FixedSizeTree` component receives. Described in the [Props](#props) section. |
| 186 | +- `FixedSizeTreeState<T extends FixedSizeNodeData>` - state that `FixedSizeTree` component has. |
| 187 | + |
178 | 188 | ### `VariableSizeTree` |
179 | 189 |
|
180 | 190 | #### Example |
@@ -308,3 +318,12 @@ This method replaces the `resetAfterIndex` method of `VariableSizeList`, but wor |
308 | 318 | This method works exactly the same as the `FixedSizeTree`'s one, but receives one additional option: |
309 | 319 |
|
310 | 320 | - `useDefaultHeight: boolean` - if this parameter is `true`, the height of all nodes will be reset to `defaultHeight`. Nodes updated during the tree walking will use the new `defaultHeight` value. |
| 321 | + |
| 322 | +#### Types |
| 323 | + |
| 324 | +All types in this section are the extended variants of [`FixedSizeTree` types](#types). |
| 325 | + |
| 326 | +- `VariableSizeNodeData` |
| 327 | +- `VariableSizeNodeComponentProps<T extends VariableSizeNodeData>`. |
| 328 | +- `VariableSizeTreeProps<T extends VariableSizeNodeData>`. |
| 329 | +- `VariableSizeTreeState<T extends VariableSizeNodeData>`. |
0 commit comments