1 | import { FoldingType, RenamableNode, TreeModel } from './tree.types';
|
2 | import { NodeMenuItem } from './menu/node-menu.component';
|
3 | import { Observable } from 'rxjs';
|
4 | export declare class Tree {
|
5 | private _children;
|
6 | private _loadChildren;
|
7 | private _childrenLoadingState;
|
8 | private _childrenAsyncOnce;
|
9 | node: TreeModel;
|
10 | parent: Tree;
|
11 | /**
|
12 | * Check that value passed is not empty (it doesn't consist of only whitespace symbols).
|
13 | * @param {string} value - A value that should be checked.
|
14 | * @returns {boolean} - A flag indicating that value is empty or not.
|
15 | * @static
|
16 | */
|
17 | static isValueEmpty(value: string): boolean;
|
18 | /**
|
19 | * Check whether a given value can be considered RenamableNode.
|
20 | * @param {any} value - A value to check.
|
21 | * @returns {boolean} - A flag indicating whether given value is Renamable node or not.
|
22 | * @static
|
23 | */
|
24 | static isRenamable(value: any): value is RenamableNode;
|
25 | private static cloneTreeShallow;
|
26 | private static applyNewValueToRenamable;
|
27 | /**
|
28 | * Build an instance of Tree from an object implementing TreeModel interface.
|
29 | * @param {TreeModel} model - A model that is used to build a tree.
|
30 | * @param {Tree} [parent] - An optional parent if you want to build a tree from the model that should be a child of an existing Tree instance.
|
31 | * @param {boolean} [isBranch] - An option that makes a branch from created tree. Branch can have children.
|
32 | */
|
33 | constructor(node: TreeModel, parent?: Tree, isBranch?: boolean);
|
34 | private buildTreeFromModel;
|
35 | hasDeferredChildren(): boolean;
|
36 | loadingChildrenRequested(): void;
|
37 | /**
|
38 | * Check whether children of the node are being loaded.
|
39 | * Makes sense only for nodes that define `loadChildren` function.
|
40 | * @returns {boolean} A flag indicating that children are being loaded.
|
41 | */
|
42 | childrenAreBeingLoaded(): boolean;
|
43 | /**
|
44 | * Check whether children of the node were loaded.
|
45 | * Makes sense only for nodes that define `loadChildren` function.
|
46 | * @returns {boolean} A flag indicating that children were loaded.
|
47 | */
|
48 | childrenWereLoaded(): boolean;
|
49 | private canLoadChildren;
|
50 | /**
|
51 | * Check whether children of the node should be loaded and not loaded yet.
|
52 | * Makes sense only for nodes that define `loadChildren` function.
|
53 | * @returns {boolean} A flag indicating that children should be loaded for the current node.
|
54 | */
|
55 | childrenShouldBeLoaded(): boolean;
|
56 | /**
|
57 | * Get children of the current tree.
|
58 | * @returns {Tree[]} The children of the current tree.
|
59 | */
|
60 | get children(): Tree[];
|
61 | /**
|
62 | * By getting value from this property you start process of loading node's children using `loadChildren` function.
|
63 | * Once children are loaded `loadChildren` function won't be called anymore and loaded for the first time children are emitted in case of subsequent calls.
|
64 | * @returns {Observable<Tree[]>} An observable which emits children once they are loaded.
|
65 | */
|
66 | get childrenAsync(): Observable<Tree[]>;
|
67 | /**
|
68 | * By calling this method you start process of loading node's children using `loadChildren` function.
|
69 | */
|
70 | reloadChildren(): void;
|
71 | /**
|
72 | * By calling this method you will remove all current children of a treee and create new.
|
73 | */
|
74 | setChildren(children: Array<TreeModel>): void;
|
75 | /**
|
76 | * Create a new node in the current tree.
|
77 | * @param {boolean} isBranch - A flag that indicates whether a new node should be a "Branch". "Leaf" node will be created by default
|
78 | * @param {TreeModel} model - Tree model of the new node which will be inserted. Empty node will be created by default and it will fire edit mode of this node
|
79 | * @returns {Tree} A newly created child node.
|
80 | */
|
81 | createNode(isBranch: boolean, model?: TreeModel): Tree;
|
82 | /**
|
83 | * Get the value of the current node
|
84 | * @returns {(string|RenamableNode)} The value of the node.
|
85 | */
|
86 | get value(): any;
|
87 | set checked(checked: boolean);
|
88 | get checked(): boolean;
|
89 | get checkedChildren(): Tree[];
|
90 | set selectionAllowed(selectionAllowed: boolean);
|
91 | get selectionAllowed(): boolean;
|
92 | hasLoadedChildern(): boolean;
|
93 | loadedChildrenAmount(): number;
|
94 | checkedChildrenAmount(): number;
|
95 | /**
|
96 | * Set the value of the current node
|
97 | * @param {(string|RenamableNode)} value - The new value of the node.
|
98 | */
|
99 | set value(value: any);
|
100 | /**
|
101 | * Add a sibling node for the current node. This won't work if the current node is a root.
|
102 | * @param {Tree} sibling - A node that should become a sibling.
|
103 | * @param [number] position - Position in which sibling will be inserted. By default it will be inserted at the last position in a parent.
|
104 | * @returns {Tree} A newly inserted sibling, or null if you are trying to make a sibling for the root.
|
105 | */
|
106 | addSibling(sibling: Tree, position?: number): Tree;
|
107 | /**
|
108 | * Add a child node for the current node.
|
109 | * @param {Tree} child - A node that should become a child.
|
110 | * @param [number] position - Position in which child will be inserted. By default it will be inserted at the last position in a parent.
|
111 | * @returns {Tree} A newly inserted child.
|
112 | */
|
113 | addChild(child: Tree, position?: number): Tree;
|
114 | private _addChild;
|
115 | /**
|
116 | * Swap position of the current node with the given sibling. If node passed as a parameter is not a sibling - nothing happens.
|
117 | * @param {Tree} sibling - A sibling with which current node shold be swapped.
|
118 | */
|
119 | swapWithSibling(sibling: Tree): void;
|
120 | /**
|
121 | * Get a node's position in its parent.
|
122 | * @returns {number} The position inside a parent.
|
123 | */
|
124 | get positionInParent(): number;
|
125 | /**
|
126 | * Check whether or not this tree is static.
|
127 | * @returns {boolean} A flag indicating whether or not this tree is static.
|
128 | */
|
129 | isStatic(): boolean;
|
130 | /**
|
131 | * Check whether or not this tree has a left menu.
|
132 | * @returns {boolean} A flag indicating whether or not this tree has a left menu.
|
133 | */
|
134 | hasLeftMenu(): boolean;
|
135 | /**
|
136 | * Check whether or not this tree has a right menu.
|
137 | * @returns {boolean} A flag indicating whether or not this tree has a right menu.
|
138 | */
|
139 | hasRightMenu(): boolean;
|
140 | /**
|
141 | * Check whether this tree is "Leaf" or not.
|
142 | * @returns {boolean} A flag indicating whether or not this tree is a "Leaf".
|
143 | */
|
144 | isLeaf(): boolean;
|
145 | /**
|
146 | * Get menu items of the current tree.
|
147 | * @returns {NodeMenuItem[]} The menu items of the current tree.
|
148 | */
|
149 | get menuItems(): NodeMenuItem[];
|
150 | /**
|
151 | * Check whether or not this tree has a custom menu.
|
152 | * @returns {boolean} A flag indicating whether or not this tree has a custom menu.
|
153 | */
|
154 | hasCustomMenu(): boolean;
|
155 | /**
|
156 | * Check whether this tree is "Branch" or not. "Branch" is a node that has children.
|
157 | * @returns {boolean} A flag indicating whether or not this tree is a "Branch".
|
158 | */
|
159 | isBranch(): boolean;
|
160 | /**
|
161 | * Check whether this tree has children.
|
162 | * @returns {boolean} A flag indicating whether or not this tree has children.
|
163 | */
|
164 | hasChildren(): boolean;
|
165 | /**
|
166 | * Check whether this tree is a root or not. The root is the tree (node) that doesn't have parent (or technically its parent is null).
|
167 | * @returns {boolean} A flag indicating whether or not this tree is the root.
|
168 | */
|
169 | isRoot(): boolean;
|
170 | /**
|
171 | * Check whether provided tree is a sibling of the current tree. Sibling trees (nodes) are the trees that have the same parent.
|
172 | * @param {Tree} tree - A tree that should be tested on a siblingness.
|
173 | * @returns {boolean} A flag indicating whether or not provided tree is the sibling of the current one.
|
174 | */
|
175 | hasSibling(tree: Tree): boolean;
|
176 | /**
|
177 | * Check whether provided tree is a child of the current tree.
|
178 | * This method tests that provided tree is a <strong>direct</strong> child of the current tree.
|
179 | * @param {Tree} tree - A tree that should be tested (child candidate).
|
180 | * @returns {boolean} A flag indicating whether provided tree is a child or not.
|
181 | */
|
182 | hasChild(tree: Tree): boolean;
|
183 | /**
|
184 | * Remove given tree from the current tree.
|
185 | * The given tree will be removed only in case it is a direct child of the current tree (@see {@link hasChild}).
|
186 | * @param {Tree} tree - A tree that should be removed.
|
187 | */
|
188 | removeChild(tree: Tree): void;
|
189 | /**
|
190 | * Remove current tree from its parent.
|
191 | */
|
192 | removeItselfFromParent(): void;
|
193 | /**
|
194 | * Switch folding type of the current tree. "Leaf" node cannot switch its folding type cause it doesn't have children, hence nothing to fold.
|
195 | * If node is a "Branch" and it is expanded, then by invoking current method state of the tree should be switched to "collapsed" and vice versa.
|
196 | */
|
197 | switchFoldingType(): void;
|
198 | /**
|
199 | * Check that tree is expanded.
|
200 | * @returns {boolean} A flag indicating whether current tree is expanded. Always returns false for the "Leaf" tree and for an empty tree.
|
201 | */
|
202 | isNodeExpanded(): boolean;
|
203 | /**
|
204 | * Check that tree is collapsed.
|
205 | * @returns {boolean} A flag indicating whether current tree is collapsed. Always returns false for the "Leaf" tree and for an empty tree.
|
206 | */
|
207 | isNodeCollapsed(): boolean;
|
208 | /**
|
209 | * Set a current folding type: expanded, collapsed or leaf.
|
210 | */
|
211 | private _setFoldingType;
|
212 | /**
|
213 | * Get a current folding type: expanded, collapsed or leaf.
|
214 | * @returns {FoldingType} A folding type of the current tree.
|
215 | */
|
216 | get foldingType(): FoldingType;
|
217 | /**
|
218 | * Get a css class for element which displayes folding state - expanded, collapsed or leaf
|
219 | * @returns {string} A string icontaining css class (classes)
|
220 | */
|
221 | get foldingCssClass(): string;
|
222 | private getCssClassesFromSettings;
|
223 | /**
|
224 | * Get a html template to render before every node's name.
|
225 | * @returns {string} A string representing a html template.
|
226 | */
|
227 | get nodeTemplate(): string;
|
228 | private getTemplateFromSettings;
|
229 | /**
|
230 | * Get a html template to render for an element activatin left menu of a node.
|
231 | * @returns {string} A string representing a html template.
|
232 | */
|
233 | get leftMenuTemplate(): string;
|
234 | disableCollapseOnInit(): void;
|
235 | isCollapsedOnInit(): boolean;
|
236 | keepNodesInDOM(): any;
|
237 | /**
|
238 | * Check that current tree is newly created (added by user via menu for example). Tree that was built from the TreeModel is not marked as new.
|
239 | * @returns {boolean} A flag whether the tree is new.
|
240 | */
|
241 | isNew(): boolean;
|
242 | get id(): number | string;
|
243 | set id(id: number | string);
|
244 | /**
|
245 | * Mark current tree as new (@see {@link isNew}).
|
246 | */
|
247 | markAsNew(): void;
|
248 | /**
|
249 | * Check that current tree is being renamed (it is in the process of its value renaming initiated by a user).
|
250 | * @returns {boolean} A flag whether the tree is being renamed.
|
251 | */
|
252 | isBeingRenamed(): boolean;
|
253 | /**
|
254 | * Mark current tree as being renamed (@see {@link isBeingRenamed}).
|
255 | */
|
256 | markAsBeingRenamed(): void;
|
257 | /**
|
258 | * Check that current tree is modified (for example it was renamed).
|
259 | * @returns {boolean} A flag whether the tree is modified.
|
260 | */
|
261 | isModified(): boolean;
|
262 | /**
|
263 | * Mark current tree as modified (@see {@link isModified}).
|
264 | */
|
265 | markAsModified(): void;
|
266 | /**
|
267 | * Makes a clone of an underlying TreeModel instance
|
268 | * @returns {TreeModel} a clone of an underlying TreeModel instance
|
269 | */
|
270 | toTreeModel(): TreeModel;
|
271 | }
|