You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
476 B
21 lines
476 B
export interface Item {
|
|
id?: string;
|
|
parentId?: string | null;
|
|
[key: string]: any;
|
|
}
|
|
export interface TreeItem {
|
|
id?: string;
|
|
parentId?: string | null;
|
|
[key: string]: Item | any;
|
|
children: TreeItem[];
|
|
}
|
|
export interface Config {
|
|
id: string;
|
|
parentId: string;
|
|
dataField: string | null;
|
|
}
|
|
/**
|
|
* Unflattens an array to a tree with runtime O(n)
|
|
*/
|
|
export default function arrayToTree(items: Item[], config?: Partial<Config>): TreeItem[];
|