feat: smart-tree component added to hoppscotch-ui (#3210)

This commit is contained in:
Anwarul Islam
2023-08-20 21:18:32 +06:00
committed by GitHub
parent d5c887f311
commit d4d1e27ba9
8 changed files with 34 additions and 21 deletions

View File

@@ -0,0 +1,34 @@
import { Ref } from "vue"
/**
* Representation of a tree node in the SmartTreeAdapter.
*/
export type TreeNode<T> = {
id: string
data: T
}
/**
* Representation of children result from a tree node when there will be a loading state.
*/
export type ChildrenResult<T> =
| {
status: "loading"
}
| {
status: "loaded"
data: Array<TreeNode<T>>
}
/**
* A tree adapter that can be used with the SmartTree component.
* @template T The type of data that is stored in the tree.
*/
export interface SmartTreeAdapter<T> {
/**
*
* @param nodeID - id of the node to get children for
* @returns - Ref that contains the children of the node. It is reactive and will be updated when the children are changed.
*/
getChildren: (nodeID: string | null) => Ref<ChildrenResult<T>>
}