Skip to content

Commit 80c0112

Browse files
committed
docs: replace badges and add types description
1 parent 081b078 commit 80c0112

File tree

1 file changed

+22
-3
lines changed

1 file changed

+22
-3
lines changed

README.md

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22

33
[![Latest Stable Version](https://img.shields.io/npm/v/react-vtree.svg)](https://www.npmjs.com/package/react-vtree)
44
[![License](https://img.shields.io/npm/l/react-vtree.svg)](./LICENSE)
5-
[![Build Status](https://img.shields.io/travis/Lodin/react-vtree/master.svg)](https://travis-ci.org/Lodin/react-vtree)
6-
[![Test Coverage](https://img.shields.io/codecov/c/github/Lodin/react-vtree/master.svg)](https://codecov.io/gh/Lodin/react-vtree)
5+
[![CI Status](https://github.com/Lodin/react-vtree/workflows/CI/badge.svg)](https://github.com/Lodin/react-vtree/actions)
6+
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=Lodin_react-vtree&metric=coverage)](https://sonarcloud.io/dashboard?id=Lodin_react-vtree)
7+
[![Bugs](https://sonarcloud.io/api/project_badges/measure?project=Lodin_react-vtree&metric=bugs)](https://sonarcloud.io/dashboard?id=Lodin_react-vtree)
8+
[![Vulnerabilities](https://sonarcloud.io/api/project_badges/measure?project=Lodin_react-vtree&metric=vulnerabilities)](https://sonarcloud.io/dashboard?id=Lodin_react-vtree)
79

810
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.
911

@@ -170,11 +172,19 @@ This method runs the `treeWalker` function again and, basing on the received opt
170172
It receives options object with the following parameters:
171173

172174
- `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+
174176
**NOTE**: If you specify both `useDefaultOpenness` and `opennessState`, `opennessState` will be overridden by `useDefaultOpenness` results.
177+
175178
- `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.
176179
- `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.
177180

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+
178188
### `VariableSizeTree`
179189

180190
#### Example
@@ -308,3 +318,12 @@ This method replaces the `resetAfterIndex` method of `VariableSizeList`, but wor
308318
This method works exactly the same as the `FixedSizeTree`'s one, but receives one additional option:
309319

310320
- `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

Comments
 (0)