UNPKG

954 BTypeScriptView Raw
1import { TableColumnProp } from '../types/table-column.type';
2export declare type OptionalValueGetter = (row: any) => any | undefined;
3export declare function optionalGetterForProp(prop: TableColumnProp): OptionalValueGetter;
4/**
5 * This functions rearrange items by their parents
6 * Also sets the level value to each of the items
7 *
8 * Note: Expecting each item has a property called parentId
9 * Note: This algorithm will fail if a list has two or more items with same ID
10 * NOTE: This algorithm will fail if there is a deadlock of relationship
11 *
12 * For example,
13 *
14 * Input
15 *
16 * id -> parent
17 * 1 -> 0
18 * 2 -> 0
19 * 3 -> 1
20 * 4 -> 1
21 * 5 -> 2
22 * 7 -> 8
23 * 6 -> 3
24 *
25 *
26 * Output
27 * id -> level
28 * 1 -> 0
29 * --3 -> 1
30 * ----6 -> 2
31 * --4 -> 1
32 * 2 -> 0
33 * --5 -> 1
34 * 7 -> 8
35 *
36 *
37 * @param rows
38 *
39 */
40export declare function groupRowsByParents(rows: any[], from?: OptionalValueGetter, to?: OptionalValueGetter): any[];