1 | (function (global, factory) {
|
2 | typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/common'), require('primeng/api'), require('primeng/utils'), require('primeng/dom')) :
|
3 | typeof define === 'function' && define.amd ? define('primeng/tree', ['exports', '@angular/core', '@angular/common', 'primeng/api', 'primeng/utils', 'primeng/dom'], factory) :
|
4 | (global = global || self, factory((global.primeng = global.primeng || {}, global.primeng.tree = {}), global.ng.core, global.ng.common, global.primeng.api, global.primeng.utils, global.primeng.dom));
|
5 | }(this, (function (exports, core, common, api, utils, dom) { 'use strict';
|
6 |
|
7 | var __assign = (this && this.__assign) || function () {
|
8 | __assign = Object.assign || function(t) {
|
9 | for (var s, i = 1, n = arguments.length; i < n; i++) {
|
10 | s = arguments[i];
|
11 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
12 | t[p] = s[p];
|
13 | }
|
14 | return t;
|
15 | };
|
16 | return __assign.apply(this, arguments);
|
17 | };
|
18 | var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
19 | var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
20 | if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
21 | else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
22 | return c > 3 && r && Object.defineProperty(target, key, r), r;
|
23 | };
|
24 | var __param = (this && this.__param) || function (paramIndex, decorator) {
|
25 | return function (target, key) { decorator(target, key, paramIndex); }
|
26 | };
|
27 | var __read = (this && this.__read) || function (o, n) {
|
28 | var m = typeof Symbol === "function" && o[Symbol.iterator];
|
29 | if (!m) return o;
|
30 | var i = m.call(o), r, ar = [], e;
|
31 | try {
|
32 | while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
33 | }
|
34 | catch (error) { e = { error: error }; }
|
35 | finally {
|
36 | try {
|
37 | if (r && !r.done && (m = i["return"])) m.call(i);
|
38 | }
|
39 | finally { if (e) throw e.error; }
|
40 | }
|
41 | return ar;
|
42 | };
|
43 | var __spread = (this && this.__spread) || function () {
|
44 | for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i]));
|
45 | return ar;
|
46 | };
|
47 | var __values = (this && this.__values) || function(o) {
|
48 | var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
49 | if (m) return m.call(o);
|
50 | if (o && typeof o.length === "number") return {
|
51 | next: function () {
|
52 | if (o && i >= o.length) o = void 0;
|
53 | return { value: o && o[i++], done: !o };
|
54 | }
|
55 | };
|
56 | throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
57 | };
|
58 | var UITreeNode = (function () {
|
59 | function UITreeNode(tree) {
|
60 | this.tree = tree;
|
61 | }
|
62 | UITreeNode_1 = UITreeNode;
|
63 | UITreeNode.prototype.ngOnInit = function () {
|
64 | this.node.parent = this.parentNode;
|
65 | if (this.parentNode) {
|
66 | this.tree.syncNodeOption(this.node, this.tree.value, 'parent', this.tree.getNodeWithKey(this.parentNode.key, this.tree.value));
|
67 | }
|
68 | };
|
69 | UITreeNode.prototype.getIcon = function () {
|
70 | var icon;
|
71 | if (this.node.icon)
|
72 | icon = this.node.icon;
|
73 | else
|
74 | icon = this.node.expanded && this.node.children && this.node.children.length ? this.node.expandedIcon : this.node.collapsedIcon;
|
75 | return UITreeNode_1.ICON_CLASS + ' ' + icon;
|
76 | };
|
77 | UITreeNode.prototype.isLeaf = function () {
|
78 | return this.tree.isNodeLeaf(this.node);
|
79 | };
|
80 | UITreeNode.prototype.toggle = function (event) {
|
81 | if (this.node.expanded)
|
82 | this.collapse(event);
|
83 | else
|
84 | this.expand(event);
|
85 | };
|
86 | UITreeNode.prototype.expand = function (event) {
|
87 | this.node.expanded = true;
|
88 | this.tree.onNodeExpand.emit({ originalEvent: event, node: this.node });
|
89 | };
|
90 | UITreeNode.prototype.collapse = function (event) {
|
91 | this.node.expanded = false;
|
92 | this.tree.onNodeCollapse.emit({ originalEvent: event, node: this.node });
|
93 | };
|
94 | UITreeNode.prototype.onNodeClick = function (event) {
|
95 | this.tree.onNodeClick(event, this.node);
|
96 | };
|
97 | UITreeNode.prototype.onNodeKeydown = function (event) {
|
98 | if (event.which === 13) {
|
99 | this.tree.onNodeClick(event, this.node);
|
100 | }
|
101 | };
|
102 | UITreeNode.prototype.onNodeTouchEnd = function () {
|
103 | this.tree.onNodeTouchEnd();
|
104 | };
|
105 | UITreeNode.prototype.onNodeRightClick = function (event) {
|
106 | this.tree.onNodeRightClick(event, this.node);
|
107 | };
|
108 | UITreeNode.prototype.isSelected = function () {
|
109 | return this.tree.isSelected(this.node);
|
110 | };
|
111 | UITreeNode.prototype.onDropPoint = function (event, position) {
|
112 | var _this = this;
|
113 | event.preventDefault();
|
114 | var dragNode = this.tree.dragNode;
|
115 | var dragNodeIndex = this.tree.dragNodeIndex;
|
116 | var dragNodeScope = this.tree.dragNodeScope;
|
117 | var isValidDropPointIndex = this.tree.dragNodeTree === this.tree ? (position === 1 || dragNodeIndex !== this.index - 1) : true;
|
118 | if (this.tree.allowDrop(dragNode, this.node, dragNodeScope) && isValidDropPointIndex) {
|
119 | if (this.tree.validateDrop) {
|
120 | this.tree.onNodeDrop.emit({
|
121 | originalEvent: event,
|
122 | dragNode: dragNode,
|
123 | dropNode: this.node,
|
124 | dropIndex: this.index,
|
125 | accept: function () {
|
126 | _this.processPointDrop(dragNode, dragNodeIndex, position);
|
127 | }
|
128 | });
|
129 | }
|
130 | else {
|
131 | this.processPointDrop(dragNode, dragNodeIndex, position);
|
132 | this.tree.onNodeDrop.emit({
|
133 | originalEvent: event,
|
134 | dragNode: dragNode,
|
135 | dropNode: this.node,
|
136 | dropIndex: this.index
|
137 | });
|
138 | }
|
139 | }
|
140 | this.draghoverPrev = false;
|
141 | this.draghoverNext = false;
|
142 | };
|
143 | UITreeNode.prototype.processPointDrop = function (dragNode, dragNodeIndex, position) {
|
144 | var newNodeList = this.node.parent ? this.node.parent.children : this.tree.value;
|
145 | this.tree.dragNodeSubNodes.splice(dragNodeIndex, 1);
|
146 | var dropIndex = this.index;
|
147 | if (position < 0) {
|
148 | dropIndex = (this.tree.dragNodeSubNodes === newNodeList) ? ((this.tree.dragNodeIndex > this.index) ? this.index : this.index - 1) : this.index;
|
149 | newNodeList.splice(dropIndex, 0, dragNode);
|
150 | }
|
151 | else {
|
152 | dropIndex = newNodeList.length;
|
153 | newNodeList.push(dragNode);
|
154 | }
|
155 | this.tree.dragDropService.stopDrag({
|
156 | node: dragNode,
|
157 | subNodes: this.node.parent ? this.node.parent.children : this.tree.value,
|
158 | index: dragNodeIndex
|
159 | });
|
160 | };
|
161 | UITreeNode.prototype.onDropPointDragOver = function (event) {
|
162 | event.dataTransfer.dropEffect = 'move';
|
163 | event.preventDefault();
|
164 | };
|
165 | UITreeNode.prototype.onDropPointDragEnter = function (event, position) {
|
166 | if (this.tree.allowDrop(this.tree.dragNode, this.node, this.tree.dragNodeScope)) {
|
167 | if (position < 0)
|
168 | this.draghoverPrev = true;
|
169 | else
|
170 | this.draghoverNext = true;
|
171 | }
|
172 | };
|
173 | UITreeNode.prototype.onDropPointDragLeave = function (event) {
|
174 | this.draghoverPrev = false;
|
175 | this.draghoverNext = false;
|
176 | };
|
177 | UITreeNode.prototype.onDragStart = function (event) {
|
178 | if (this.tree.draggableNodes && this.node.draggable !== false) {
|
179 | event.dataTransfer.setData("text", "data");
|
180 | this.tree.dragDropService.startDrag({
|
181 | tree: this,
|
182 | node: this.node,
|
183 | subNodes: this.node.parent ? this.node.parent.children : this.tree.value,
|
184 | index: this.index,
|
185 | scope: this.tree.draggableScope
|
186 | });
|
187 | }
|
188 | else {
|
189 | event.preventDefault();
|
190 | }
|
191 | };
|
192 | UITreeNode.prototype.onDragStop = function (event) {
|
193 | this.tree.dragDropService.stopDrag({
|
194 | node: this.node,
|
195 | subNodes: this.node.parent ? this.node.parent.children : this.tree.value,
|
196 | index: this.index
|
197 | });
|
198 | };
|
199 | UITreeNode.prototype.onDropNodeDragOver = function (event) {
|
200 | event.dataTransfer.dropEffect = 'move';
|
201 | if (this.tree.droppableNodes) {
|
202 | event.preventDefault();
|
203 | event.stopPropagation();
|
204 | }
|
205 | };
|
206 | UITreeNode.prototype.onDropNode = function (event) {
|
207 | var _this = this;
|
208 | if (this.tree.droppableNodes && this.node.droppable !== false) {
|
209 | event.preventDefault();
|
210 | event.stopPropagation();
|
211 | var dragNode_1 = this.tree.dragNode;
|
212 | if (this.tree.allowDrop(dragNode_1, this.node, this.tree.dragNodeScope)) {
|
213 | if (this.tree.validateDrop) {
|
214 | this.tree.onNodeDrop.emit({
|
215 | originalEvent: event,
|
216 | dragNode: dragNode_1,
|
217 | dropNode: this.node,
|
218 | index: this.index,
|
219 | accept: function () {
|
220 | _this.processNodeDrop(dragNode_1);
|
221 | }
|
222 | });
|
223 | }
|
224 | else {
|
225 | this.processNodeDrop(dragNode_1);
|
226 | this.tree.onNodeDrop.emit({
|
227 | originalEvent: event,
|
228 | dragNode: dragNode_1,
|
229 | dropNode: this.node,
|
230 | index: this.index
|
231 | });
|
232 | }
|
233 | }
|
234 | }
|
235 | this.draghoverNode = false;
|
236 | };
|
237 | UITreeNode.prototype.processNodeDrop = function (dragNode) {
|
238 | var dragNodeIndex = this.tree.dragNodeIndex;
|
239 | this.tree.dragNodeSubNodes.splice(dragNodeIndex, 1);
|
240 | if (this.node.children)
|
241 | this.node.children.push(dragNode);
|
242 | else
|
243 | this.node.children = [dragNode];
|
244 | this.tree.dragDropService.stopDrag({
|
245 | node: dragNode,
|
246 | subNodes: this.node.parent ? this.node.parent.children : this.tree.value,
|
247 | index: this.tree.dragNodeIndex
|
248 | });
|
249 | };
|
250 | UITreeNode.prototype.onDropNodeDragEnter = function (event) {
|
251 | if (this.tree.droppableNodes && this.node.droppable !== false && this.tree.allowDrop(this.tree.dragNode, this.node, this.tree.dragNodeScope)) {
|
252 | this.draghoverNode = true;
|
253 | }
|
254 | };
|
255 | UITreeNode.prototype.onDropNodeDragLeave = function (event) {
|
256 | if (this.tree.droppableNodes) {
|
257 | var rect = event.currentTarget.getBoundingClientRect();
|
258 | if (event.x > rect.left + rect.width || event.x < rect.left || event.y >= Math.floor(rect.top + rect.height) || event.y < rect.top) {
|
259 | this.draghoverNode = false;
|
260 | }
|
261 | }
|
262 | };
|
263 | UITreeNode.prototype.onKeyDown = function (event) {
|
264 | var nodeElement = event.target.parentElement.parentElement;
|
265 | if (nodeElement.nodeName !== 'P-TREENODE') {
|
266 | return;
|
267 | }
|
268 | switch (event.which) {
|
269 |
|
270 | case 40:
|
271 | var listElement = (this.tree.droppableNodes) ? nodeElement.children[1].children[1] : nodeElement.children[0].children[1];
|
272 | if (listElement && listElement.children.length > 0) {
|
273 | this.focusNode(listElement.children[0]);
|
274 | }
|
275 | else {
|
276 | var nextNodeElement = nodeElement.nextElementSibling;
|
277 | if (nextNodeElement) {
|
278 | this.focusNode(nextNodeElement);
|
279 | }
|
280 | else {
|
281 | var nextSiblingAncestor = this.findNextSiblingOfAncestor(nodeElement);
|
282 | if (nextSiblingAncestor) {
|
283 | this.focusNode(nextSiblingAncestor);
|
284 | }
|
285 | }
|
286 | }
|
287 | event.preventDefault();
|
288 | break;
|
289 |
|
290 | case 38:
|
291 | if (nodeElement.previousElementSibling) {
|
292 | this.focusNode(this.findLastVisibleDescendant(nodeElement.previousElementSibling));
|
293 | }
|
294 | else {
|
295 | var parentNodeElement = this.getParentNodeElement(nodeElement);
|
296 | if (parentNodeElement) {
|
297 | this.focusNode(parentNodeElement);
|
298 | }
|
299 | }
|
300 | event.preventDefault();
|
301 | break;
|
302 |
|
303 | case 39:
|
304 | if (!this.node.expanded && !this.tree.isNodeLeaf(this.node)) {
|
305 | this.expand(event);
|
306 | }
|
307 | event.preventDefault();
|
308 | break;
|
309 |
|
310 | case 37:
|
311 | if (this.node.expanded) {
|
312 | this.collapse(event);
|
313 | }
|
314 | else {
|
315 | var parentNodeElement = this.getParentNodeElement(nodeElement);
|
316 | if (parentNodeElement) {
|
317 | this.focusNode(parentNodeElement);
|
318 | }
|
319 | }
|
320 | event.preventDefault();
|
321 | break;
|
322 |
|
323 | case 13:
|
324 | this.tree.onNodeClick(event, this.node);
|
325 | event.preventDefault();
|
326 | break;
|
327 | default:
|
328 |
|
329 | break;
|
330 | }
|
331 | };
|
332 | UITreeNode.prototype.findNextSiblingOfAncestor = function (nodeElement) {
|
333 | var parentNodeElement = this.getParentNodeElement(nodeElement);
|
334 | if (parentNodeElement) {
|
335 | if (parentNodeElement.nextElementSibling)
|
336 | return parentNodeElement.nextElementSibling;
|
337 | else
|
338 | return this.findNextSiblingOfAncestor(parentNodeElement);
|
339 | }
|
340 | else {
|
341 | return null;
|
342 | }
|
343 | };
|
344 | UITreeNode.prototype.findLastVisibleDescendant = function (nodeElement) {
|
345 | var listElement = Array.from(nodeElement.children).find(function (el) { return dom.DomHandler.hasClass(el, 'ui-treenode'); });
|
346 | var childrenListElement = listElement.children[1];
|
347 | if (childrenListElement && childrenListElement.children.length > 0) {
|
348 | var lastChildElement = childrenListElement.children[childrenListElement.children.length - 1];
|
349 | return this.findLastVisibleDescendant(lastChildElement);
|
350 | }
|
351 | else {
|
352 | return nodeElement;
|
353 | }
|
354 | };
|
355 | UITreeNode.prototype.getParentNodeElement = function (nodeElement) {
|
356 | var parentNodeElement = nodeElement.parentElement.parentElement.parentElement;
|
357 | return parentNodeElement.tagName === 'P-TREENODE' ? parentNodeElement : null;
|
358 | };
|
359 | UITreeNode.prototype.focusNode = function (element) {
|
360 | if (this.tree.droppableNodes)
|
361 | element.children[1].children[0].focus();
|
362 | else
|
363 | element.children[0].children[0].focus();
|
364 | };
|
365 | var UITreeNode_1;
|
366 | UITreeNode.ICON_CLASS = 'ui-treenode-icon ';
|
367 | UITreeNode.ctorParameters = function () { return [
|
368 | { type: undefined, decorators: [{ type: core.Inject, args: [core.forwardRef(function () { return Tree; }),] }] }
|
369 | ]; };
|
370 | __decorate([
|
371 | core.Input()
|
372 | ], UITreeNode.prototype, "node", void 0);
|
373 | __decorate([
|
374 | core.Input()
|
375 | ], UITreeNode.prototype, "parentNode", void 0);
|
376 | __decorate([
|
377 | core.Input()
|
378 | ], UITreeNode.prototype, "root", void 0);
|
379 | __decorate([
|
380 | core.Input()
|
381 | ], UITreeNode.prototype, "index", void 0);
|
382 | __decorate([
|
383 | core.Input()
|
384 | ], UITreeNode.prototype, "firstChild", void 0);
|
385 | __decorate([
|
386 | core.Input()
|
387 | ], UITreeNode.prototype, "lastChild", void 0);
|
388 | UITreeNode = UITreeNode_1 = __decorate([
|
389 | core.Component({
|
390 | selector: 'p-treeNode',
|
391 | template: "\n <ng-template [ngIf]=\"node\">\n <li *ngIf=\"tree.droppableNodes\" class=\"ui-treenode-droppoint\" [ngClass]=\"{'ui-treenode-droppoint-active ui-state-highlight':draghoverPrev}\"\n (drop)=\"onDropPoint($event,-1)\" (dragover)=\"onDropPointDragOver($event)\" (dragenter)=\"onDropPointDragEnter($event,-1)\" (dragleave)=\"onDropPointDragLeave($event)\"></li>\n <li *ngIf=\"!tree.horizontal\" role=\"treeitem\" [ngClass]=\"['ui-treenode',node.styleClass||'', isLeaf() ? 'ui-treenode-leaf': '']\">\n <div class=\"ui-treenode-content\" (click)=\"onNodeClick($event)\" (contextmenu)=\"onNodeRightClick($event)\" (touchend)=\"onNodeTouchEnd()\"\n (drop)=\"onDropNode($event)\" (dragover)=\"onDropNodeDragOver($event)\" (dragenter)=\"onDropNodeDragEnter($event)\" (dragleave)=\"onDropNodeDragLeave($event)\"\n [draggable]=\"tree.draggableNodes\" (dragstart)=\"onDragStart($event)\" (dragend)=\"onDragStop($event)\" [attr.tabindex]=\"0\"\n [ngClass]=\"{'ui-treenode-selectable':tree.selectionMode && node.selectable !== false,'ui-treenode-dragover':draghoverNode, 'ui-treenode-content-selected':isSelected()}\"\n (keydown)=\"onKeyDown($event)\" [attr.aria-posinset]=\"this.index + 1\" [attr.aria-expanded]=\"this.node.expanded\" [attr.aria-selected]=\"isSelected()\" [attr.aria-label]=\"node.label\">\n <span class=\"ui-tree-toggler pi pi-fw ui-unselectable-text\" [ngClass]=\"{'pi-caret-right':!node.expanded,'pi-caret-down':node.expanded}\"\n (click)=\"toggle($event)\"></span\n ><div class=\"ui-chkbox\" *ngIf=\"tree.selectionMode == 'checkbox'\" [attr.aria-checked]=\"isSelected()\"><div class=\"ui-chkbox-box ui-widget ui-corner-all ui-state-default\" [ngClass]=\"{'ui-state-disabled': node.selectable === false}\">\n <span class=\"ui-chkbox-icon ui-clickable pi\"\n [ngClass]=\"{'pi-check':isSelected(),'pi-minus':node.partialSelected}\"></span></div></div\n ><span [class]=\"getIcon()\" *ngIf=\"node.icon||node.expandedIcon||node.collapsedIcon\"></span\n ><span class=\"ui-treenode-label ui-corner-all\"\n [ngClass]=\"{'ui-state-highlight':isSelected()}\">\n <span *ngIf=\"!tree.getTemplateForNode(node)\">{{node.label}}</span>\n <span *ngIf=\"tree.getTemplateForNode(node)\">\n <ng-container *ngTemplateOutlet=\"tree.getTemplateForNode(node); context: {$implicit: node}\"></ng-container>\n </span>\n </span>\n </div>\n <ul class=\"ui-treenode-children\" style=\"display: none;\" *ngIf=\"node.children && node.expanded\" [style.display]=\"node.expanded ? 'block' : 'none'\" role=\"group\">\n <p-treeNode *ngFor=\"let childNode of node.children;let firstChild=first;let lastChild=last; let index=index; trackBy: tree.nodeTrackBy\" [node]=\"childNode\" [parentNode]=\"node\"\n [firstChild]=\"firstChild\" [lastChild]=\"lastChild\" [index]=\"index\"></p-treeNode>\n </ul>\n </li>\n <li *ngIf=\"tree.droppableNodes&&lastChild\" class=\"ui-treenode-droppoint\" [ngClass]=\"{'ui-treenode-droppoint-active ui-state-highlight':draghoverNext}\"\n (drop)=\"onDropPoint($event,1)\" (dragover)=\"onDropPointDragOver($event)\" (dragenter)=\"onDropPointDragEnter($event,1)\" (dragleave)=\"onDropPointDragLeave($event)\"></li>\n <table *ngIf=\"tree.horizontal\" [class]=\"node.styleClass\">\n <tbody>\n <tr>\n <td class=\"ui-treenode-connector\" *ngIf=\"!root\">\n <table class=\"ui-treenode-connector-table\">\n <tbody>\n <tr>\n <td [ngClass]=\"{'ui-treenode-connector-line':!firstChild}\"></td>\n </tr>\n <tr>\n <td [ngClass]=\"{'ui-treenode-connector-line':!lastChild}\"></td>\n </tr>\n </tbody>\n </table>\n </td>\n <td class=\"ui-treenode\" [ngClass]=\"{'ui-treenode-collapsed':!node.expanded}\">\n <div class=\"ui-treenode-content ui-state-default ui-corner-all\" tabindex=\"0\"\n [ngClass]=\"{'ui-treenode-selectable':tree.selectionMode,'ui-state-highlight':isSelected()}\" (click)=\"onNodeClick($event)\" (contextmenu)=\"onNodeRightClick($event)\"\n (touchend)=\"onNodeTouchEnd()\" (keydown)=\"onNodeKeydown($event)\">\n <span class=\"ui-tree-toggler pi pi-fw ui-unselectable-text\" [ngClass]=\"{'pi-plus':!node.expanded,'pi-minus':node.expanded}\" *ngIf=\"!isLeaf()\"\n (click)=\"toggle($event)\"></span\n ><span [class]=\"getIcon()\" *ngIf=\"node.icon||node.expandedIcon||node.collapsedIcon\"></span\n ><span class=\"ui-treenode-label ui-corner-all\">\n <span *ngIf=\"!tree.getTemplateForNode(node)\">{{node.label}}</span>\n <span *ngIf=\"tree.getTemplateForNode(node)\">\n <ng-container *ngTemplateOutlet=\"tree.getTemplateForNode(node); context: {$implicit: node}\"></ng-container>\n </span>\n </span>\n </div>\n </td>\n <td class=\"ui-treenode-children-container\" *ngIf=\"node.children && node.expanded\" [style.display]=\"node.expanded ? 'table-cell' : 'none'\">\n <div class=\"ui-treenode-children\">\n <p-treeNode *ngFor=\"let childNode of node.children;let firstChild=first;let lastChild=last; trackBy: tree.nodeTrackBy\" [node]=\"childNode\"\n [firstChild]=\"firstChild\" [lastChild]=\"lastChild\"></p-treeNode>\n </div>\n </td>\n </tr>\n </tbody>\n </table>\n </ng-template>\n "
|
392 | }),
|
393 | __param(0, core.Inject(core.forwardRef(function () { return Tree; })))
|
394 | ], UITreeNode);
|
395 | return UITreeNode;
|
396 | }());
|
397 | var Tree = (function () {
|
398 | function Tree(el, dragDropService) {
|
399 | this.el = el;
|
400 | this.dragDropService = dragDropService;
|
401 | this.selectionChange = new core.EventEmitter();
|
402 | this.onNodeSelect = new core.EventEmitter();
|
403 | this.onNodeUnselect = new core.EventEmitter();
|
404 | this.onNodeExpand = new core.EventEmitter();
|
405 | this.onNodeCollapse = new core.EventEmitter();
|
406 | this.onNodeContextMenuSelect = new core.EventEmitter();
|
407 | this.onNodeDrop = new core.EventEmitter();
|
408 | this.layout = 'vertical';
|
409 | this.metaKeySelection = true;
|
410 | this.propagateSelectionUp = true;
|
411 | this.propagateSelectionDown = true;
|
412 | this.loadingIcon = 'pi pi-spinner';
|
413 | this.emptyMessage = 'No records found';
|
414 | this.filterBy = 'label';
|
415 | this.filterMode = 'lenient';
|
416 | this.onFilter = new core.EventEmitter();
|
417 | this.nodeTrackBy = function (index, item) { return item; };
|
418 | }
|
419 | Tree.prototype.ngOnInit = function () {
|
420 | var _this = this;
|
421 | if (this.droppableNodes) {
|
422 | this.dragStartSubscription = this.dragDropService.dragStart$.subscribe(function (event) {
|
423 | _this.dragNodeTree = event.tree;
|
424 | _this.dragNode = event.node;
|
425 | _this.dragNodeSubNodes = event.subNodes;
|
426 | _this.dragNodeIndex = event.index;
|
427 | _this.dragNodeScope = event.scope;
|
428 | });
|
429 | this.dragStopSubscription = this.dragDropService.dragStop$.subscribe(function (event) {
|
430 | _this.dragNodeTree = null;
|
431 | _this.dragNode = null;
|
432 | _this.dragNodeSubNodes = null;
|
433 | _this.dragNodeIndex = null;
|
434 | _this.dragNodeScope = null;
|
435 | _this.dragHover = false;
|
436 | });
|
437 | }
|
438 | };
|
439 | Object.defineProperty(Tree.prototype, "horizontal", {
|
440 | get: function () {
|
441 | return this.layout == 'horizontal';
|
442 | },
|
443 | enumerable: true,
|
444 | configurable: true
|
445 | });
|
446 | Tree.prototype.ngAfterContentInit = function () {
|
447 | var _this = this;
|
448 | if (this.templates.length) {
|
449 | this.templateMap = {};
|
450 | }
|
451 | this.templates.forEach(function (item) {
|
452 | _this.templateMap[item.name] = item.template;
|
453 | });
|
454 | };
|
455 | Tree.prototype.onNodeClick = function (event, node) {
|
456 | var eventTarget = event.target;
|
457 | if (dom.DomHandler.hasClass(eventTarget, 'ui-tree-toggler')) {
|
458 | return;
|
459 | }
|
460 | else if (this.selectionMode) {
|
461 | if (node.selectable === false) {
|
462 | return;
|
463 | }
|
464 | if (this.hasFilteredNodes()) {
|
465 | node = this.getNodeWithKey(node.key, this.value);
|
466 | if (!node) {
|
467 | return;
|
468 | }
|
469 | }
|
470 | var index_1 = this.findIndexInSelection(node);
|
471 | var selected = (index_1 >= 0);
|
472 | if (this.isCheckboxSelectionMode()) {
|
473 | if (selected) {
|
474 | if (this.propagateSelectionDown)
|
475 | this.propagateDown(node, false);
|
476 | else
|
477 | this.selection = this.selection.filter(function (val, i) { return i != index_1; });
|
478 | if (this.propagateSelectionUp && node.parent) {
|
479 | this.propagateUp(node.parent, false);
|
480 | }
|
481 | this.selectionChange.emit(this.selection);
|
482 | this.onNodeUnselect.emit({ originalEvent: event, node: node });
|
483 | }
|
484 | else {
|
485 | if (this.propagateSelectionDown)
|
486 | this.propagateDown(node, true);
|
487 | else
|
488 | this.selection = __spread(this.selection || [], [node]);
|
489 | if (this.propagateSelectionUp && node.parent) {
|
490 | this.propagateUp(node.parent, true);
|
491 | }
|
492 | this.selectionChange.emit(this.selection);
|
493 | this.onNodeSelect.emit({ originalEvent: event, node: node });
|
494 | }
|
495 | }
|
496 | else {
|
497 | var metaSelection = this.nodeTouched ? false : this.metaKeySelection;
|
498 | if (metaSelection) {
|
499 | var metaKey = (event.metaKey || event.ctrlKey);
|
500 | if (selected && metaKey) {
|
501 | if (this.isSingleSelectionMode()) {
|
502 | this.selectionChange.emit(null);
|
503 | }
|
504 | else {
|
505 | this.selection = this.selection.filter(function (val, i) { return i != index_1; });
|
506 | this.selectionChange.emit(this.selection);
|
507 | }
|
508 | this.onNodeUnselect.emit({ originalEvent: event, node: node });
|
509 | }
|
510 | else {
|
511 | if (this.isSingleSelectionMode()) {
|
512 | this.selectionChange.emit(node);
|
513 | }
|
514 | else if (this.isMultipleSelectionMode()) {
|
515 | this.selection = (!metaKey) ? [] : this.selection || [];
|
516 | this.selection = __spread(this.selection, [node]);
|
517 | this.selectionChange.emit(this.selection);
|
518 | }
|
519 | this.onNodeSelect.emit({ originalEvent: event, node: node });
|
520 | }
|
521 | }
|
522 | else {
|
523 | if (this.isSingleSelectionMode()) {
|
524 | if (selected) {
|
525 | this.selection = null;
|
526 | this.onNodeUnselect.emit({ originalEvent: event, node: node });
|
527 | }
|
528 | else {
|
529 | this.selection = node;
|
530 | this.onNodeSelect.emit({ originalEvent: event, node: node });
|
531 | }
|
532 | }
|
533 | else {
|
534 | if (selected) {
|
535 | this.selection = this.selection.filter(function (val, i) { return i != index_1; });
|
536 | this.onNodeUnselect.emit({ originalEvent: event, node: node });
|
537 | }
|
538 | else {
|
539 | this.selection = __spread(this.selection || [], [node]);
|
540 | this.onNodeSelect.emit({ originalEvent: event, node: node });
|
541 | }
|
542 | }
|
543 | this.selectionChange.emit(this.selection);
|
544 | }
|
545 | }
|
546 | }
|
547 | this.nodeTouched = false;
|
548 | };
|
549 | Tree.prototype.onNodeTouchEnd = function () {
|
550 | this.nodeTouched = true;
|
551 | };
|
552 | Tree.prototype.onNodeRightClick = function (event, node) {
|
553 | if (this.contextMenu) {
|
554 | var eventTarget = event.target;
|
555 | if (eventTarget.className && eventTarget.className.indexOf('ui-tree-toggler') === 0) {
|
556 | return;
|
557 | }
|
558 | else {
|
559 | var index = this.findIndexInSelection(node);
|
560 | var selected = (index >= 0);
|
561 | if (!selected) {
|
562 | if (this.isSingleSelectionMode())
|
563 | this.selectionChange.emit(node);
|
564 | else
|
565 | this.selectionChange.emit([node]);
|
566 | }
|
567 | this.contextMenu.show(event);
|
568 | this.onNodeContextMenuSelect.emit({ originalEvent: event, node: node });
|
569 | }
|
570 | }
|
571 | };
|
572 | Tree.prototype.findIndexInSelection = function (node) {
|
573 | var index = -1;
|
574 | if (this.selectionMode && this.selection) {
|
575 | if (this.isSingleSelectionMode()) {
|
576 | var areNodesEqual = (this.selection.key && this.selection.key === node.key) || this.selection == node;
|
577 | index = areNodesEqual ? 0 : -1;
|
578 | }
|
579 | else {
|
580 | for (var i = 0; i < this.selection.length; i++) {
|
581 | var selectedNode = this.selection[i];
|
582 | var areNodesEqual = (selectedNode.key && selectedNode.key === node.key) || selectedNode == node;
|
583 | if (areNodesEqual) {
|
584 | index = i;
|
585 | break;
|
586 | }
|
587 | }
|
588 | }
|
589 | }
|
590 | return index;
|
591 | };
|
592 | Tree.prototype.syncNodeOption = function (node, parentNodes, option, value) {
|
593 |
|
594 | var _node = this.hasFilteredNodes() ? this.getNodeWithKey(node.key, parentNodes) : null;
|
595 | if (_node) {
|
596 | _node[option] = value || node[option];
|
597 | }
|
598 | };
|
599 | Tree.prototype.hasFilteredNodes = function () {
|
600 | return this.filter && this.filteredNodes && this.filteredNodes.length;
|
601 | };
|
602 | Tree.prototype.getNodeWithKey = function (key, nodes) {
|
603 | var e_1, _a;
|
604 | try {
|
605 | for (var nodes_1 = __values(nodes), nodes_1_1 = nodes_1.next(); !nodes_1_1.done; nodes_1_1 = nodes_1.next()) {
|
606 | var node = nodes_1_1.value;
|
607 | if (node.key === key) {
|
608 | return node;
|
609 | }
|
610 | if (node.children) {
|
611 | var matchedNode = this.getNodeWithKey(key, node.children);
|
612 | if (matchedNode) {
|
613 | return matchedNode;
|
614 | }
|
615 | }
|
616 | }
|
617 | }
|
618 | catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
619 | finally {
|
620 | try {
|
621 | if (nodes_1_1 && !nodes_1_1.done && (_a = nodes_1.return)) _a.call(nodes_1);
|
622 | }
|
623 | finally { if (e_1) throw e_1.error; }
|
624 | }
|
625 | };
|
626 | Tree.prototype.propagateUp = function (node, select) {
|
627 | var e_2, _a;
|
628 | if (node.children && node.children.length) {
|
629 | var selectedCount = 0;
|
630 | var childPartialSelected = false;
|
631 | try {
|
632 | for (var _b = __values(node.children), _c = _b.next(); !_c.done; _c = _b.next()) {
|
633 | var child = _c.value;
|
634 | if (this.isSelected(child)) {
|
635 | selectedCount++;
|
636 | }
|
637 | else if (child.partialSelected) {
|
638 | childPartialSelected = true;
|
639 | }
|
640 | }
|
641 | }
|
642 | catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
643 | finally {
|
644 | try {
|
645 | if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
646 | }
|
647 | finally { if (e_2) throw e_2.error; }
|
648 | }
|
649 | if (select && selectedCount == node.children.length) {
|
650 | this.selection = __spread(this.selection || [], [node]);
|
651 | node.partialSelected = false;
|
652 | }
|
653 | else {
|
654 | if (!select) {
|
655 | var index_2 = this.findIndexInSelection(node);
|
656 | if (index_2 >= 0) {
|
657 | this.selection = this.selection.filter(function (val, i) { return i != index_2; });
|
658 | }
|
659 | }
|
660 | if (childPartialSelected || selectedCount > 0 && selectedCount != node.children.length)
|
661 | node.partialSelected = true;
|
662 | else
|
663 | node.partialSelected = false;
|
664 | }
|
665 | this.syncNodeOption(node, this.filteredNodes, 'partialSelected');
|
666 | }
|
667 | var parent = node.parent;
|
668 | if (parent) {
|
669 | this.propagateUp(parent, select);
|
670 | }
|
671 | };
|
672 | Tree.prototype.propagateDown = function (node, select) {
|
673 | var e_3, _a;
|
674 | var index = this.findIndexInSelection(node);
|
675 | if (select && index == -1) {
|
676 | this.selection = __spread(this.selection || [], [node]);
|
677 | }
|
678 | else if (!select && index > -1) {
|
679 | this.selection = this.selection.filter(function (val, i) { return i != index; });
|
680 | }
|
681 | node.partialSelected = false;
|
682 | this.syncNodeOption(node, this.filteredNodes, 'partialSelected');
|
683 | if (node.children && node.children.length) {
|
684 | try {
|
685 | for (var _b = __values(node.children), _c = _b.next(); !_c.done; _c = _b.next()) {
|
686 | var child = _c.value;
|
687 | this.propagateDown(child, select);
|
688 | }
|
689 | }
|
690 | catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
691 | finally {
|
692 | try {
|
693 | if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
694 | }
|
695 | finally { if (e_3) throw e_3.error; }
|
696 | }
|
697 | }
|
698 | };
|
699 | Tree.prototype.isSelected = function (node) {
|
700 | return this.findIndexInSelection(node) != -1;
|
701 | };
|
702 | Tree.prototype.isSingleSelectionMode = function () {
|
703 | return this.selectionMode && this.selectionMode == 'single';
|
704 | };
|
705 | Tree.prototype.isMultipleSelectionMode = function () {
|
706 | return this.selectionMode && this.selectionMode == 'multiple';
|
707 | };
|
708 | Tree.prototype.isCheckboxSelectionMode = function () {
|
709 | return this.selectionMode && this.selectionMode == 'checkbox';
|
710 | };
|
711 | Tree.prototype.isNodeLeaf = function (node) {
|
712 | return node.leaf == false ? false : !(node.children && node.children.length);
|
713 | };
|
714 | Tree.prototype.getRootNode = function () {
|
715 | return this.filteredNodes ? this.filteredNodes : this.value;
|
716 | };
|
717 | Tree.prototype.getTemplateForNode = function (node) {
|
718 | if (this.templateMap)
|
719 | return node.type ? this.templateMap[node.type] : this.templateMap['default'];
|
720 | else
|
721 | return null;
|
722 | };
|
723 | Tree.prototype.onDragOver = function (event) {
|
724 | if (this.droppableNodes && (!this.value || this.value.length === 0)) {
|
725 | event.dataTransfer.dropEffect = 'move';
|
726 | event.preventDefault();
|
727 | }
|
728 | };
|
729 | Tree.prototype.onDrop = function (event) {
|
730 | if (this.droppableNodes && (!this.value || this.value.length === 0)) {
|
731 | event.preventDefault();
|
732 | var dragNode = this.dragNode;
|
733 | if (this.allowDrop(dragNode, null, this.dragNodeScope)) {
|
734 | var dragNodeIndex = this.dragNodeIndex;
|
735 | this.dragNodeSubNodes.splice(dragNodeIndex, 1);
|
736 | this.value = this.value || [];
|
737 | this.value.push(dragNode);
|
738 | this.dragDropService.stopDrag({
|
739 | node: dragNode
|
740 | });
|
741 | }
|
742 | }
|
743 | };
|
744 | Tree.prototype.onDragEnter = function (event) {
|
745 | if (this.droppableNodes && this.allowDrop(this.dragNode, null, this.dragNodeScope)) {
|
746 | this.dragHover = true;
|
747 | }
|
748 | };
|
749 | Tree.prototype.onDragLeave = function (event) {
|
750 | if (this.droppableNodes) {
|
751 | var rect = event.currentTarget.getBoundingClientRect();
|
752 | if (event.x > rect.left + rect.width || event.x < rect.left || event.y > rect.top + rect.height || event.y < rect.top) {
|
753 | this.dragHover = false;
|
754 | }
|
755 | }
|
756 | };
|
757 | Tree.prototype.allowDrop = function (dragNode, dropNode, dragNodeScope) {
|
758 | if (!dragNode) {
|
759 |
|
760 | return false;
|
761 | }
|
762 | else if (this.isValidDragScope(dragNodeScope)) {
|
763 | var allow = true;
|
764 | if (dropNode) {
|
765 | if (dragNode === dropNode) {
|
766 | allow = false;
|
767 | }
|
768 | else {
|
769 | var parent_1 = dropNode.parent;
|
770 | while (parent_1 != null) {
|
771 | if (parent_1 === dragNode) {
|
772 | allow = false;
|
773 | break;
|
774 | }
|
775 | parent_1 = parent_1.parent;
|
776 | }
|
777 | }
|
778 | }
|
779 | return allow;
|
780 | }
|
781 | else {
|
782 | return false;
|
783 | }
|
784 | };
|
785 | Tree.prototype.isValidDragScope = function (dragScope) {
|
786 | var e_4, _a, e_5, _b;
|
787 | var dropScope = this.droppableScope;
|
788 | if (dropScope) {
|
789 | if (typeof dropScope === 'string') {
|
790 | if (typeof dragScope === 'string')
|
791 | return dropScope === dragScope;
|
792 | else if (dragScope instanceof Array)
|
793 | return dragScope.indexOf(dropScope) != -1;
|
794 | }
|
795 | else if (dropScope instanceof Array) {
|
796 | if (typeof dragScope === 'string') {
|
797 | return dropScope.indexOf(dragScope) != -1;
|
798 | }
|
799 | else if (dragScope instanceof Array) {
|
800 | try {
|
801 | for (var dropScope_1 = __values(dropScope), dropScope_1_1 = dropScope_1.next(); !dropScope_1_1.done; dropScope_1_1 = dropScope_1.next()) {
|
802 | var s = dropScope_1_1.value;
|
803 | try {
|
804 | for (var dragScope_1 = (e_5 = void 0, __values(dragScope)), dragScope_1_1 = dragScope_1.next(); !dragScope_1_1.done; dragScope_1_1 = dragScope_1.next()) {
|
805 | var ds = dragScope_1_1.value;
|
806 | if (s === ds) {
|
807 | return true;
|
808 | }
|
809 | }
|
810 | }
|
811 | catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
812 | finally {
|
813 | try {
|
814 | if (dragScope_1_1 && !dragScope_1_1.done && (_b = dragScope_1.return)) _b.call(dragScope_1);
|
815 | }
|
816 | finally { if (e_5) throw e_5.error; }
|
817 | }
|
818 | }
|
819 | }
|
820 | catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
821 | finally {
|
822 | try {
|
823 | if (dropScope_1_1 && !dropScope_1_1.done && (_a = dropScope_1.return)) _a.call(dropScope_1);
|
824 | }
|
825 | finally { if (e_4) throw e_4.error; }
|
826 | }
|
827 | }
|
828 | }
|
829 | return false;
|
830 | }
|
831 | else {
|
832 | return true;
|
833 | }
|
834 | };
|
835 | Tree.prototype._filter = function (event) {
|
836 | var e_6, _a;
|
837 | var filterValue = event.target.value;
|
838 | if (filterValue === '') {
|
839 | this.filteredNodes = null;
|
840 | }
|
841 | else {
|
842 | this.filteredNodes = [];
|
843 | var searchFields = this.filterBy.split(',');
|
844 | var filterText = utils.ObjectUtils.removeAccents(filterValue).toLocaleLowerCase(this.filterLocale);
|
845 | var isStrictMode = this.filterMode === 'strict';
|
846 | try {
|
847 | for (var _b = __values(this.value), _c = _b.next(); !_c.done; _c = _b.next()) {
|
848 | var node = _c.value;
|
849 | var copyNode = __assign({}, node);
|
850 | var paramsWithoutNode = { searchFields: searchFields, filterText: filterText, isStrictMode: isStrictMode };
|
851 | if ((isStrictMode && (this.findFilteredNodes(copyNode, paramsWithoutNode) || this.isFilterMatched(copyNode, paramsWithoutNode))) ||
|
852 | (!isStrictMode && (this.isFilterMatched(copyNode, paramsWithoutNode) || this.findFilteredNodes(copyNode, paramsWithoutNode)))) {
|
853 | this.filteredNodes.push(copyNode);
|
854 | }
|
855 | }
|
856 | }
|
857 | catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
858 | finally {
|
859 | try {
|
860 | if (_c && !_c.done && (_a = _b.return)) _a.call(_b);
|
861 | }
|
862 | finally { if (e_6) throw e_6.error; }
|
863 | }
|
864 | }
|
865 | this.onFilter.emit({
|
866 | filter: filterValue,
|
867 | filteredValue: this.filteredNodes
|
868 | });
|
869 | };
|
870 | Tree.prototype.findFilteredNodes = function (node, paramsWithoutNode) {
|
871 | var e_7, _a;
|
872 | if (node) {
|
873 | var matched = false;
|
874 | if (node.children) {
|
875 | var childNodes = __spread(node.children);
|
876 | node.children = [];
|
877 | try {
|
878 | for (var childNodes_1 = __values(childNodes), childNodes_1_1 = childNodes_1.next(); !childNodes_1_1.done; childNodes_1_1 = childNodes_1.next()) {
|
879 | var childNode = childNodes_1_1.value;
|
880 | var copyChildNode = __assign({}, childNode);
|
881 | if (this.isFilterMatched(copyChildNode, paramsWithoutNode)) {
|
882 | matched = true;
|
883 | node.children.push(copyChildNode);
|
884 | }
|
885 | }
|
886 | }
|
887 | catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
888 | finally {
|
889 | try {
|
890 | if (childNodes_1_1 && !childNodes_1_1.done && (_a = childNodes_1.return)) _a.call(childNodes_1);
|
891 | }
|
892 | finally { if (e_7) throw e_7.error; }
|
893 | }
|
894 | }
|
895 | if (matched) {
|
896 | node.expanded = true;
|
897 | return true;
|
898 | }
|
899 | }
|
900 | };
|
901 | Tree.prototype.isFilterMatched = function (node, _a) {
|
902 | var e_8, _b;
|
903 | var searchFields = _a.searchFields, filterText = _a.filterText, isStrictMode = _a.isStrictMode;
|
904 | var matched = false;
|
905 | try {
|
906 | for (var searchFields_1 = __values(searchFields), searchFields_1_1 = searchFields_1.next(); !searchFields_1_1.done; searchFields_1_1 = searchFields_1.next()) {
|
907 | var field = searchFields_1_1.value;
|
908 | var fieldValue = utils.ObjectUtils.removeAccents(String(utils.ObjectUtils.resolveFieldData(node, field))).toLocaleLowerCase(this.filterLocale);
|
909 | if (fieldValue.indexOf(filterText) > -1) {
|
910 | matched = true;
|
911 | }
|
912 | }
|
913 | }
|
914 | catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
915 | finally {
|
916 | try {
|
917 | if (searchFields_1_1 && !searchFields_1_1.done && (_b = searchFields_1.return)) _b.call(searchFields_1);
|
918 | }
|
919 | finally { if (e_8) throw e_8.error; }
|
920 | }
|
921 | if (!matched || (isStrictMode && !this.isNodeLeaf(node))) {
|
922 | matched = this.findFilteredNodes(node, { searchFields: searchFields, filterText: filterText, isStrictMode: isStrictMode }) || matched;
|
923 | }
|
924 | return matched;
|
925 | };
|
926 | Tree.prototype.getBlockableElement = function () {
|
927 | return this.el.nativeElement.children[0];
|
928 | };
|
929 | Tree.prototype.ngOnDestroy = function () {
|
930 | if (this.dragStartSubscription) {
|
931 | this.dragStartSubscription.unsubscribe();
|
932 | }
|
933 | if (this.dragStopSubscription) {
|
934 | this.dragStopSubscription.unsubscribe();
|
935 | }
|
936 | };
|
937 | Tree.ctorParameters = function () { return [
|
938 | { type: core.ElementRef },
|
939 | { type: api.TreeDragDropService, decorators: [{ type: core.Optional }] }
|
940 | ]; };
|
941 | __decorate([
|
942 | core.Input()
|
943 | ], Tree.prototype, "value", void 0);
|
944 | __decorate([
|
945 | core.Input()
|
946 | ], Tree.prototype, "selectionMode", void 0);
|
947 | __decorate([
|
948 | core.Input()
|
949 | ], Tree.prototype, "selection", void 0);
|
950 | __decorate([
|
951 | core.Output()
|
952 | ], Tree.prototype, "selectionChange", void 0);
|
953 | __decorate([
|
954 | core.Output()
|
955 | ], Tree.prototype, "onNodeSelect", void 0);
|
956 | __decorate([
|
957 | core.Output()
|
958 | ], Tree.prototype, "onNodeUnselect", void 0);
|
959 | __decorate([
|
960 | core.Output()
|
961 | ], Tree.prototype, "onNodeExpand", void 0);
|
962 | __decorate([
|
963 | core.Output()
|
964 | ], Tree.prototype, "onNodeCollapse", void 0);
|
965 | __decorate([
|
966 | core.Output()
|
967 | ], Tree.prototype, "onNodeContextMenuSelect", void 0);
|
968 | __decorate([
|
969 | core.Output()
|
970 | ], Tree.prototype, "onNodeDrop", void 0);
|
971 | __decorate([
|
972 | core.Input()
|
973 | ], Tree.prototype, "style", void 0);
|
974 | __decorate([
|
975 | core.Input()
|
976 | ], Tree.prototype, "styleClass", void 0);
|
977 | __decorate([
|
978 | core.Input()
|
979 | ], Tree.prototype, "contextMenu", void 0);
|
980 | __decorate([
|
981 | core.Input()
|
982 | ], Tree.prototype, "layout", void 0);
|
983 | __decorate([
|
984 | core.Input()
|
985 | ], Tree.prototype, "draggableScope", void 0);
|
986 | __decorate([
|
987 | core.Input()
|
988 | ], Tree.prototype, "droppableScope", void 0);
|
989 | __decorate([
|
990 | core.Input()
|
991 | ], Tree.prototype, "draggableNodes", void 0);
|
992 | __decorate([
|
993 | core.Input()
|
994 | ], Tree.prototype, "droppableNodes", void 0);
|
995 | __decorate([
|
996 | core.Input()
|
997 | ], Tree.prototype, "metaKeySelection", void 0);
|
998 | __decorate([
|
999 | core.Input()
|
1000 | ], Tree.prototype, "propagateSelectionUp", void 0);
|
1001 | __decorate([
|
1002 | core.Input()
|
1003 | ], Tree.prototype, "propagateSelectionDown", void 0);
|
1004 | __decorate([
|
1005 | core.Input()
|
1006 | ], Tree.prototype, "loading", void 0);
|
1007 | __decorate([
|
1008 | core.Input()
|
1009 | ], Tree.prototype, "loadingIcon", void 0);
|
1010 | __decorate([
|
1011 | core.Input()
|
1012 | ], Tree.prototype, "emptyMessage", void 0);
|
1013 | __decorate([
|
1014 | core.Input()
|
1015 | ], Tree.prototype, "ariaLabel", void 0);
|
1016 | __decorate([
|
1017 | core.Input()
|
1018 | ], Tree.prototype, "ariaLabelledBy", void 0);
|
1019 | __decorate([
|
1020 | core.Input()
|
1021 | ], Tree.prototype, "validateDrop", void 0);
|
1022 | __decorate([
|
1023 | core.Input()
|
1024 | ], Tree.prototype, "filter", void 0);
|
1025 | __decorate([
|
1026 | core.Input()
|
1027 | ], Tree.prototype, "filterBy", void 0);
|
1028 | __decorate([
|
1029 | core.Input()
|
1030 | ], Tree.prototype, "filterMode", void 0);
|
1031 | __decorate([
|
1032 | core.Input()
|
1033 | ], Tree.prototype, "filterPlaceholder", void 0);
|
1034 | __decorate([
|
1035 | core.Input()
|
1036 | ], Tree.prototype, "filterLocale", void 0);
|
1037 | __decorate([
|
1038 | core.Output()
|
1039 | ], Tree.prototype, "onFilter", void 0);
|
1040 | __decorate([
|
1041 | core.Input()
|
1042 | ], Tree.prototype, "nodeTrackBy", void 0);
|
1043 | __decorate([
|
1044 | core.ContentChildren(api.PrimeTemplate)
|
1045 | ], Tree.prototype, "templates", void 0);
|
1046 | Tree = __decorate([
|
1047 | core.Component({
|
1048 | selector: 'p-tree',
|
1049 | template: "\n <div [ngClass]=\"{'ui-tree ui-widget ui-widget-content ui-corner-all':true,'ui-tree-selectable':selectionMode,'ui-treenode-dragover':dragHover,'ui-tree-loading': loading}\" [ngStyle]=\"style\" [class]=\"styleClass\" *ngIf=\"!horizontal\"\n (drop)=\"onDrop($event)\" (dragover)=\"onDragOver($event)\" (dragenter)=\"onDragEnter($event)\" (dragleave)=\"onDragLeave($event)\">\n <div class=\"ui-tree-loading-mask ui-widget-overlay\" *ngIf=\"loading\"></div>\n <div class=\"ui-tree-loading-content\" *ngIf=\"loading\">\n <i [class]=\"'ui-tree-loading-icon pi-spin ' + loadingIcon\"></i>\n </div>\n <div *ngIf=\"filter\" class=\"ui-tree-filter-container\">\n <input #filter type=\"text\" autocomplete=\"off\" class=\"ui-tree-filter ui-inputtext ui-widget ui-state-default ui-corner-all\" [attr.placeholder]=\"filterPlaceholder\"\n (keydown.enter)=\"$event.preventDefault()\" (input)=\"_filter($event)\">\n <span class=\"ui-tree-filter-icon pi pi-search\"></span>\n </div>\n <ul class=\"ui-tree-container\" *ngIf=\"getRootNode()\" role=\"tree\" [attr.aria-label]=\"ariaLabel\" [attr.aria-labelledby]=\"ariaLabelledBy\">\n <p-treeNode *ngFor=\"let node of getRootNode(); let firstChild=first;let lastChild=last; let index=index; trackBy: nodeTrackBy\" [node]=\"node\"\n [firstChild]=\"firstChild\" [lastChild]=\"lastChild\" [index]=\"index\"></p-treeNode>\n </ul>\n <div class=\"ui-tree-empty-message\" *ngIf=\"!loading && (value == null || value.length === 0)\">{{emptyMessage}}</div>\n </div>\n <div [ngClass]=\"{'ui-tree ui-tree-horizontal ui-widget ui-widget-content ui-corner-all':true,'ui-tree-selectable':selectionMode}\" [ngStyle]=\"style\" [class]=\"styleClass\" *ngIf=\"horizontal\">\n <div class=\"ui-tree-loading ui-widget-overlay\" *ngIf=\"loading\"></div>\n <div class=\"ui-tree-loading-content\" *ngIf=\"loading\">\n <i [class]=\"'ui-tree-loading-icon pi-spin ' + loadingIcon\"></i>\n </div>\n <table *ngIf=\"value&&value[0]\">\n <p-treeNode [node]=\"value[0]\" [root]=\"true\"></p-treeNode>\n </table>\n <div class=\"ui-tree-empty-message\" *ngIf=\"!loading && (value == null || value.length === 0)\">{{emptyMessage}}</div>\n </div>\n ",
|
1050 | changeDetection: core.ChangeDetectionStrategy.Default
|
1051 | }),
|
1052 | __param(1, core.Optional())
|
1053 | ], Tree);
|
1054 | return Tree;
|
1055 | }());
|
1056 | var TreeModule = (function () {
|
1057 | function TreeModule() {
|
1058 | }
|
1059 | TreeModule = __decorate([
|
1060 | core.NgModule({
|
1061 | imports: [common.CommonModule],
|
1062 | exports: [Tree, api.SharedModule],
|
1063 | declarations: [Tree, UITreeNode]
|
1064 | })
|
1065 | ], TreeModule);
|
1066 | return TreeModule;
|
1067 | }());
|
1068 |
|
1069 | exports.Tree = Tree;
|
1070 | exports.TreeModule = TreeModule;
|
1071 | exports.UITreeNode = UITreeNode;
|
1072 |
|
1073 | Object.defineProperty(exports, '__esModule', { value: true });
|
1074 |
|
1075 | })));
|
1076 |
|