forked from valor-software/ng2-tree
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtree.types.ts
More file actions
68 lines (57 loc) · 1.78 KB
/
tree.types.ts
File metadata and controls
68 lines (57 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import * as _ from 'lodash';
export class FoldingType {
public static Expanded: FoldingType = new FoldingType('node-expanded');
public static Collapsed: FoldingType = new FoldingType('node-collapsed');
public static Leaf: FoldingType = new FoldingType('node-leaf');
public constructor(private _cssClass: string) {
}
public get cssClass(): string {
return this._cssClass;
}
}
export type ChildrenLoadingFunction = (callback: (children: TreeModel[]) => void) => void;
export interface TreeModel {
value: string | RenamableNode;
children?: TreeModel[];
loadChildren?: ChildrenLoadingFunction;
settings?: TreeModelSettings;
_status?: TreeStatus;
_foldingType?: FoldingType;
}
export class TreeModelSettings {
/**
* "static" property when set to true makes it impossible to drag'n'drop tree or call a menu on it.
* @name TreeModelSettings#static
* @type boolean
* @default false
*/
public static?: boolean;
public static merge(sourceA: TreeModel, sourceB: TreeModel): TreeModelSettings {
return _.defaults({}, _.get(sourceA, 'settings'), _.get(sourceB, 'settings'), {static: false});
}
}
export interface Ng2TreeSettings {
/**
* Indicates root visibility in the tree. When true - root is invisible.
* @name Ng2TreeSettings#rootIsVisible
* @type boolean
*/
rootIsVisible?: boolean;
}
export enum TreeStatus {
New,
Modified,
IsBeingRenamed
}
export interface RenamableNode {
/**
* Set new value of the renamable node. Implementation of this method is up to user.
* @param {string} name - A new value of the node.
*/
setName(name: string): void;
/**
* Get string representation of the node. Implementation of this method is up to user.
* @returns {string} - A node string representation.
*/
toString(): string;
}