Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ function App() {

return (
<SortableTree
items={treeStructure.items}
onItemsChange={setTreeStructure}
treeStructure={treeStructure}
setTreeStructure={setTreeStructure}
isCollapsible
isRemovable
allowNestedItemAddition
Expand All @@ -56,8 +56,8 @@ function App() {

| Prop | Type | Default | Description |
| ------------------------- | --------------------------------------------------------------- | ----------- | -------------------------------------------------------------------------------------------------------------------- |
| `items` | `TreeItems` | Required | The array of tree items to be rendered. |
| `onItemsChange` | `React.Dispatch<React.SetStateAction<OptimizedTreeStructure>>` | Required | Callback function called when the tree structure changes. |
| `treeStructure` | `OptimizedTreeStructure` | Required | The array of tree items to be rendered. |
| `setTreeStructure` | `React.Dispatch<React.SetStateAction<OptimizedTreeStructure>>` | Required | Callback function called when the tree structure changes. |
| `indentationWidth` | `number` | `undefined` | The indentation width for children elements. |
| `isCollapsible` | `boolean` | `false` | Determines if tree items can be collapsed/expanded. |
| `onLazyLoadChildren` | `(id: UniqueIdentifier, isExpanding: boolean) => Promise<void>` | `undefined` | Callback for lazy loading child items when a parent is expanded. Useful for getting child items from an API endpoint |
Expand Down Expand Up @@ -110,6 +110,15 @@ The `OptimizedTreeStructure` is used internally to improve performance for large
function createOptimizedTreeStructure(items: TreeItems): OptimizedTreeStructure;
```

### getItemById
Retrieves a tree item by its unique identifier.
```typescript
function getItemById(
structure: OptimizedTreeStructure,
id: UniqueIdentifier,
): TreeItem | undefined;
```

### removeItemById

```typescript
Expand Down