UNPKG

primeng

Version:

[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT) [![npm version](https://badge.fury.io/js/primeng.svg)](https://badge.fury.io/js/primeng) [![npm downloads](https://img.shields.io/npm/dm/primeng.sv

785 lines (779 loc) 132 kB
(function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('@angular/core'), require('@angular/cdk/scrolling'), require('@angular/common'), require('primeng/api'), require('primeng/utils'), require('primeng/dom'), require('primeng/ripple')) : typeof define === 'function' && define.amd ? define('primeng/tree', ['exports', '@angular/core', '@angular/cdk/scrolling', '@angular/common', 'primeng/api', 'primeng/utils', 'primeng/dom', 'primeng/ripple'], factory) : (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory((global.primeng = global.primeng || {}, global.primeng.tree = {}), global.ng.core, global.ng.cdk.scrolling, global.ng.common, global.primeng.api, global.primeng.utils, global.primeng.dom, global.primeng.ripple)); }(this, (function (exports, i0, i4, i1, i3, utils, dom, i2) { 'use strict'; function _interopNamespace(e) { if (e && e.__esModule) return e; var n = Object.create(null); if (e) { Object.keys(e).forEach(function (k) { if (k !== 'default') { var d = Object.getOwnPropertyDescriptor(e, k); Object.defineProperty(n, k, d.get ? d : { enumerable: true, get: function () { return e[k]; } }); } }); } n['default'] = e; return Object.freeze(n); } var i0__namespace = /*#__PURE__*/_interopNamespace(i0); var i4__namespace = /*#__PURE__*/_interopNamespace(i4); var i1__namespace = /*#__PURE__*/_interopNamespace(i1); var i3__namespace = /*#__PURE__*/_interopNamespace(i3); var i2__namespace = /*#__PURE__*/_interopNamespace(i2); /*! ***************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */ /* global Reflect, Promise */ var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; function __extends(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); } var __assign = function () { __assign = Object.assign || function __assign(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; function __rest(s, e) { var t = {}; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) t[p] = s[p]; if (s != null && typeof Object.getOwnPropertySymbols === "function") for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) { if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i])) t[p[i]] = s[p[i]]; } return t; } function __decorate(decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 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; return c > 3 && r && Object.defineProperty(target, key, r), r; } function __param(paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); }; } function __metadata(metadataKey, metadataValue) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue); } function __awaiter(thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); } function __generator(thisArg, body) { var _ = { label: 0, sent: function () { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function () { return this; }), g; function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); while (_) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { case 0: case 1: t = op; break; case 4: _.label++; return { value: op[1], done: false }; case 5: _.label++; y = op[1]; op = [0]; continue; case 7: op = _.ops.pop(); _.trys.pop(); continue; default: if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } if (t[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } } var __createBinding = Object.create ? (function (o, m, k, k2) { if (k2 === undefined) k2 = k; Object.defineProperty(o, k2, { enumerable: true, get: function () { return m[k]; } }); }) : (function (o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; }); function __exportStar(m, o) { for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(o, p)) __createBinding(o, m, p); } function __values(o) { var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0; if (m) return m.call(o); if (o && typeof o.length === "number") return { next: function () { if (o && i >= o.length) o = void 0; return { value: o && o[i++], done: !o }; } }; throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined."); } function __read(o, n) { var m = typeof Symbol === "function" && o[Symbol.iterator]; if (!m) return o; var i = m.call(o), r, ar = [], e; try { while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value); } catch (error) { e = { error: error }; } finally { try { if (r && !r.done && (m = i["return"])) m.call(i); } finally { if (e) throw e.error; } } return ar; } /** @deprecated */ function __spread() { for (var ar = [], i = 0; i < arguments.length; i++) ar = ar.concat(__read(arguments[i])); return ar; } /** @deprecated */ function __spreadArrays() { for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length; for (var r = Array(s), k = 0, i = 0; i < il; i++) for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++) r[k] = a[j]; return r; } function __spreadArray(to, from, pack) { if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { if (ar || !(i in from)) { if (!ar) ar = Array.prototype.slice.call(from, 0, i); ar[i] = from[i]; } } return to.concat(ar || from); } function __await(v) { return this instanceof __await ? (this.v = v, this) : new __await(v); } function __asyncGenerator(thisArg, _arguments, generator) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var g = generator.apply(thisArg, _arguments || []), i, q = []; return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i; function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; } function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } } function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); } function fulfill(value) { resume("next", value); } function reject(value) { resume("throw", value); } function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); } } function __asyncDelegator(o) { var i, p; return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i; function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; } } function __asyncValues(o) { if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined."); var m = o[Symbol.asyncIterator], i; return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i); function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; } function settle(resolve, reject, d, v) { Promise.resolve(v).then(function (v) { resolve({ value: v, done: d }); }, reject); } } function __makeTemplateObject(cooked, raw) { if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; } return cooked; } ; var __setModuleDefault = Object.create ? (function (o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function (o, v) { o["default"] = v; }; function __importStar(mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; } function __importDefault(mod) { return (mod && mod.__esModule) ? mod : { default: mod }; } function __classPrivateFieldGet(receiver, state, kind, f) { if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it"); return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver); } function __classPrivateFieldSet(receiver, state, value, kind, f) { if (kind === "m") throw new TypeError("Private method is not writable"); if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter"); if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it"); return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value; } var UITreeNode = /** @class */ (function () { function UITreeNode(tree) { this.tree = tree; } UITreeNode.prototype.ngOnInit = function () { this.node.parent = this.parentNode; if (this.parentNode) { this.tree.syncNodeOption(this.node, this.tree.value, 'parent', this.tree.getNodeWithKey(this.parentNode.key, this.tree.value)); } }; UITreeNode.prototype.getIcon = function () { var icon; if (this.node.icon) icon = this.node.icon; else icon = this.node.expanded && this.node.children && this.node.children.length ? this.node.expandedIcon : this.node.collapsedIcon; return UITreeNode.ICON_CLASS + ' ' + icon; }; UITreeNode.prototype.isLeaf = function () { return this.tree.isNodeLeaf(this.node); }; UITreeNode.prototype.toggle = function (event) { if (this.node.expanded) this.collapse(event); else this.expand(event); }; UITreeNode.prototype.expand = function (event) { this.node.expanded = true; if (this.tree.virtualScroll) { this.tree.updateSerializedValue(); } this.tree.onNodeExpand.emit({ originalEvent: event, node: this.node }); }; UITreeNode.prototype.collapse = function (event) { this.node.expanded = false; if (this.tree.virtualScroll) { this.tree.updateSerializedValue(); } this.tree.onNodeCollapse.emit({ originalEvent: event, node: this.node }); }; UITreeNode.prototype.onNodeClick = function (event) { this.tree.onNodeClick(event, this.node); }; UITreeNode.prototype.onNodeKeydown = function (event) { if (event.which === 13) { this.tree.onNodeClick(event, this.node); } }; UITreeNode.prototype.onNodeTouchEnd = function () { this.tree.onNodeTouchEnd(); }; UITreeNode.prototype.onNodeRightClick = function (event) { this.tree.onNodeRightClick(event, this.node); }; UITreeNode.prototype.isSelected = function () { return this.tree.isSelected(this.node); }; UITreeNode.prototype.onDropPoint = function (event, position) { var _this = this; event.preventDefault(); var dragNode = this.tree.dragNode; var dragNodeIndex = this.tree.dragNodeIndex; var dragNodeScope = this.tree.dragNodeScope; var isValidDropPointIndex = this.tree.dragNodeTree === this.tree ? (position === 1 || dragNodeIndex !== this.index - 1) : true; if (this.tree.allowDrop(dragNode, this.node, dragNodeScope) && isValidDropPointIndex) { var dropParams_1 = Object.assign({}, this.createDropPointEventMetadata(position)); if (this.tree.validateDrop) { this.tree.onNodeDrop.emit({ originalEvent: event, dragNode: dragNode, dropNode: this.node, index: this.index, accept: function () { _this.processPointDrop(dropParams_1); } }); } else { this.processPointDrop(dropParams_1); this.tree.onNodeDrop.emit({ originalEvent: event, dragNode: dragNode, dropNode: this.node, index: this.index }); } } this.draghoverPrev = false; this.draghoverNext = false; }; UITreeNode.prototype.processPointDrop = function (event) { var newNodeList = event.dropNode.parent ? event.dropNode.parent.children : this.tree.value; event.dragNodeSubNodes.splice(event.dragNodeIndex, 1); var dropIndex = this.index; if (event.position < 0) { dropIndex = (event.dragNodeSubNodes === newNodeList) ? ((event.dragNodeIndex > event.index) ? event.index : event.index - 1) : event.index; newNodeList.splice(dropIndex, 0, event.dragNode); } else { dropIndex = newNodeList.length; newNodeList.push(event.dragNode); } this.tree.dragDropService.stopDrag({ node: event.dragNode, subNodes: event.dropNode.parent ? event.dropNode.parent.children : this.tree.value, index: event.dragNodeIndex }); }; UITreeNode.prototype.createDropPointEventMetadata = function (position) { return { dragNode: this.tree.dragNode, dragNodeIndex: this.tree.dragNodeIndex, dragNodeSubNodes: this.tree.dragNodeSubNodes, dropNode: this.node, index: this.index, position: position }; }; UITreeNode.prototype.onDropPointDragOver = function (event) { event.dataTransfer.dropEffect = 'move'; event.preventDefault(); }; UITreeNode.prototype.onDropPointDragEnter = function (event, position) { if (this.tree.allowDrop(this.tree.dragNode, this.node, this.tree.dragNodeScope)) { if (position < 0) this.draghoverPrev = true; else this.draghoverNext = true; } }; UITreeNode.prototype.onDropPointDragLeave = function (event) { this.draghoverPrev = false; this.draghoverNext = false; }; UITreeNode.prototype.onDragStart = function (event) { if (this.tree.draggableNodes && this.node.draggable !== false) { event.dataTransfer.setData("text", "data"); this.tree.dragDropService.startDrag({ tree: this, node: this.node, subNodes: this.node.parent ? this.node.parent.children : this.tree.value, index: this.index, scope: this.tree.draggableScope }); } else { event.preventDefault(); } }; UITreeNode.prototype.onDragStop = function (event) { this.tree.dragDropService.stopDrag({ node: this.node, subNodes: this.node.parent ? this.node.parent.children : this.tree.value, index: this.index }); }; UITreeNode.prototype.onDropNodeDragOver = function (event) { event.dataTransfer.dropEffect = 'move'; if (this.tree.droppableNodes) { event.preventDefault(); event.stopPropagation(); } }; UITreeNode.prototype.onDropNode = function (event) { var _this = this; if (this.tree.droppableNodes && this.node.droppable !== false) { var dragNode = this.tree.dragNode; if (this.tree.allowDrop(dragNode, this.node, this.tree.dragNodeScope)) { var dropParams_2 = Object.assign({}, this.createDropNodeEventMetadata()); if (this.tree.validateDrop) { this.tree.onNodeDrop.emit({ originalEvent: event, dragNode: dragNode, dropNode: this.node, index: this.index, accept: function () { _this.processNodeDrop(dropParams_2); } }); } else { this.processNodeDrop(dropParams_2); this.tree.onNodeDrop.emit({ originalEvent: event, dragNode: dragNode, dropNode: this.node, index: this.index }); } } } event.preventDefault(); event.stopPropagation(); this.draghoverNode = false; }; UITreeNode.prototype.createDropNodeEventMetadata = function () { return { dragNode: this.tree.dragNode, dragNodeIndex: this.tree.dragNodeIndex, dragNodeSubNodes: this.tree.dragNodeSubNodes, dropNode: this.node }; }; UITreeNode.prototype.processNodeDrop = function (event) { var dragNodeIndex = event.dragNodeIndex; event.dragNodeSubNodes.splice(dragNodeIndex, 1); if (event.dropNode.children) event.dropNode.children.push(event.dragNode); else event.dropNode.children = [event.dragNode]; this.tree.dragDropService.stopDrag({ node: event.dragNode, subNodes: event.dropNode.parent ? event.dropNode.parent.children : this.tree.value, index: dragNodeIndex }); }; UITreeNode.prototype.onDropNodeDragEnter = function (event) { if (this.tree.droppableNodes && this.node.droppable !== false && this.tree.allowDrop(this.tree.dragNode, this.node, this.tree.dragNodeScope)) { this.draghoverNode = true; } }; UITreeNode.prototype.onDropNodeDragLeave = function (event) { if (this.tree.droppableNodes) { var rect = event.currentTarget.getBoundingClientRect(); if (event.x > rect.left + rect.width || event.x < rect.left || event.y >= Math.floor(rect.top + rect.height) || event.y < rect.top) { this.draghoverNode = false; } } }; UITreeNode.prototype.onKeyDown = function (event) { var nodeElement = event.target.parentElement.parentElement; if (nodeElement.nodeName !== 'P-TREENODE' || (this.tree.contextMenu && this.tree.contextMenu.containerViewChild.nativeElement.style.display === 'block')) { return; } switch (event.which) { //down arrow case 40: var listElement = (this.tree.droppableNodes) ? nodeElement.children[1].children[1] : nodeElement.children[0].children[1]; if (listElement && listElement.children.length > 0) { this.focusNode(listElement.children[0]); } else { var nextNodeElement = nodeElement.nextElementSibling; if (nextNodeElement) { this.focusNode(nextNodeElement); } else { var nextSiblingAncestor = this.findNextSiblingOfAncestor(nodeElement); if (nextSiblingAncestor) { this.focusNode(nextSiblingAncestor); } } } event.preventDefault(); break; //up arrow case 38: if (nodeElement.previousElementSibling) { this.focusNode(this.findLastVisibleDescendant(nodeElement.previousElementSibling)); } else { var parentNodeElement = this.getParentNodeElement(nodeElement); if (parentNodeElement) { this.focusNode(parentNodeElement); } } event.preventDefault(); break; //right arrow case 39: if (!this.node.expanded && !this.tree.isNodeLeaf(this.node)) { this.expand(event); } event.preventDefault(); break; //left arrow case 37: if (this.node.expanded) { this.collapse(event); } else { var parentNodeElement = this.getParentNodeElement(nodeElement); if (parentNodeElement) { this.focusNode(parentNodeElement); } } event.preventDefault(); break; //enter case 13: this.tree.onNodeClick(event, this.node); event.preventDefault(); break; default: //no op break; } }; UITreeNode.prototype.findNextSiblingOfAncestor = function (nodeElement) { var parentNodeElement = this.getParentNodeElement(nodeElement); if (parentNodeElement) { if (parentNodeElement.nextElementSibling) return parentNodeElement.nextElementSibling; else return this.findNextSiblingOfAncestor(parentNodeElement); } else { return null; } }; UITreeNode.prototype.findLastVisibleDescendant = function (nodeElement) { var listElement = Array.from(nodeElement.children).find(function (el) { return dom.DomHandler.hasClass(el, 'p-treenode'); }); var childrenListElement = listElement.children[1]; if (childrenListElement && childrenListElement.children.length > 0) { var lastChildElement = childrenListElement.children[childrenListElement.children.length - 1]; return this.findLastVisibleDescendant(lastChildElement); } else { return nodeElement; } }; UITreeNode.prototype.getParentNodeElement = function (nodeElement) { var parentNodeElement = nodeElement.parentElement.parentElement.parentElement; return parentNodeElement.tagName === 'P-TREENODE' ? parentNodeElement : null; }; UITreeNode.prototype.focusNode = function (element) { if (this.tree.droppableNodes) element.children[1].children[0].focus(); else element.children[0].children[0].focus(); }; return UITreeNode; }()); UITreeNode.ICON_CLASS = 'p-treenode-icon '; UITreeNode.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.0.4", ngImport: i0__namespace, type: UITreeNode, deps: [{ token: i0.forwardRef(function () { return Tree; }) }], target: i0__namespace.ɵɵFactoryTarget.Component }); UITreeNode.ɵcmp = i0__namespace.ɵɵngDeclareComponent({ minVersion: "12.0.0", version: "12.0.4", type: UITreeNode, selector: "p-treeNode", inputs: { rowNode: "rowNode", node: "node", parentNode: "parentNode", root: "root", index: "index", firstChild: "firstChild", lastChild: "lastChild", level: "level", indentation: "indentation" }, ngImport: i0__namespace, template: "\n <ng-template [ngIf]=\"node\">\n <li *ngIf=\"tree.droppableNodes\" class=\"p-treenode-droppoint\" [ngClass]=\"{'p-treenode-droppoint-active':draghoverPrev}\"\n (drop)=\"onDropPoint($event,-1)\" (dragover)=\"onDropPointDragOver($event)\" (dragenter)=\"onDropPointDragEnter($event,-1)\" (dragleave)=\"onDropPointDragLeave($event)\"></li>\n <li *ngIf=\"!tree.horizontal\" [ngClass]=\"['p-treenode',node.styleClass||'', isLeaf() ? 'p-treenode-leaf': '']\">\n <div class=\"p-treenode-content\" [style.paddingLeft]=\"(level * indentation) + 'rem'\" (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]=\"{'p-treenode-selectable':tree.selectionMode && node.selectable !== false,'p-treenode-dragover':draghoverNode, 'p-highlight':isSelected()}\" role=\"treeitem\"\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 <button type=\"button\" class=\"p-tree-toggler p-link\" (click)=\"toggle($event)\" pRipple tabindex=\"-1\">\n <span class=\"p-tree-toggler-icon pi pi-fw\" [ngClass]=\"{'pi-chevron-right':!node.expanded,'pi-chevron-down':node.expanded}\"></span>\n </button>\n <div class=\"p-checkbox p-component\" [ngClass]=\"{'p-checkbox-disabled': node.selectable === false}\" *ngIf=\"tree.selectionMode == 'checkbox'\" [attr.aria-checked]=\"isSelected()\">\n <div class=\"p-checkbox-box\" [ngClass]=\"{'p-highlight': isSelected(), 'p-indeterminate': node.partialSelected}\">\n <span class=\"p-checkbox-icon pi\" [ngClass]=\"{'pi-check':isSelected(),'pi-minus':node.partialSelected}\"></span>\n </div>\n </div>\n <span [class]=\"getIcon()\" *ngIf=\"node.icon||node.expandedIcon||node.collapsedIcon\"></span>\n <span class=\"p-treenode-label\">\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=\"p-treenode-children\" style=\"display: none;\" *ngIf=\"!tree.virtualScroll && 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.trackBy\" [node]=\"childNode\" [parentNode]=\"node\"\n [firstChild]=\"firstChild\" [lastChild]=\"lastChild\" [index]=\"index\" [style.height.px]=\"tree.virtualNodeHeight\" [level]=\"level + 1\"></p-treeNode>\n </ul>\n </li>\n <li *ngIf=\"tree.droppableNodes&&lastChild\" class=\"p-treenode-droppoint\" [ngClass]=\"{'p-treenode-droppoint-active':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=\"p-treenode-connector\" *ngIf=\"!root\">\n <table class=\"p-treenode-connector-table\">\n <tbody>\n <tr>\n <td [ngClass]=\"{'p-treenode-connector-line':!firstChild}\"></td>\n </tr>\n <tr>\n <td [ngClass]=\"{'p-treenode-connector-line':!lastChild}\"></td>\n </tr>\n </tbody>\n </table>\n </td>\n <td class=\"p-treenode\" [ngClass]=\"{'p-treenode-collapsed':!node.expanded}\">\n <div class=\"p-treenode-content\" tabindex=\"0\" [ngClass]=\"{'p-treenode-selectable':tree.selectionMode,'p-highlight':isSelected()}\" (click)=\"onNodeClick($event)\" (contextmenu)=\"onNodeRightClick($event)\"\n (touchend)=\"onNodeTouchEnd()\" (keydown)=\"onNodeKeydown($event)\">\n <span class=\"p-tree-toggler pi pi-fw\" [ngClass]=\"{'pi-plus':!node.expanded,'pi-minus':node.expanded}\" *ngIf=\"!isLeaf()\" (click)=\"toggle($event)\"></span>\n <span [class]=\"getIcon()\" *ngIf=\"node.icon||node.expandedIcon||node.collapsedIcon\"></span>\n <span class=\"p-treenode-label\">\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=\"p-treenode-children-container\" *ngIf=\"node.children && node.expanded\" [style.display]=\"node.expanded ? 'table-cell' : 'none'\">\n <div class=\"p-treenode-children\">\n <p-treeNode *ngFor=\"let childNode of node.children;let firstChild=first;let lastChild=last; trackBy: tree.trackBy\" [node]=\"childNode\"\n [firstChild]=\"firstChild\" [lastChild]=\"lastChild\"></p-treeNode>\n </div>\n </td>\n </tr>\n </tbody>\n </table>\n </ng-template>\n ", isInline: true, components: [{ type: UITreeNode, selector: "p-treeNode", inputs: ["rowNode", "node", "parentNode", "root", "index", "firstChild", "lastChild", "level", "indentation"] }], directives: [{ type: i1__namespace.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { type: i1__namespace.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { type: i2__namespace.Ripple, selector: "[pRipple]" }, { type: i1__namespace.NgTemplateOutlet, selector: "[ngTemplateOutlet]", inputs: ["ngTemplateOutletContext", "ngTemplateOutlet"] }, { type: i1__namespace.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }], encapsulation: i0__namespace.ViewEncapsulation.None }); i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.0.4", ngImport: i0__namespace, type: UITreeNode, decorators: [{ type: i0.Component, args: [{ selector: 'p-treeNode', template: "\n <ng-template [ngIf]=\"node\">\n <li *ngIf=\"tree.droppableNodes\" class=\"p-treenode-droppoint\" [ngClass]=\"{'p-treenode-droppoint-active':draghoverPrev}\"\n (drop)=\"onDropPoint($event,-1)\" (dragover)=\"onDropPointDragOver($event)\" (dragenter)=\"onDropPointDragEnter($event,-1)\" (dragleave)=\"onDropPointDragLeave($event)\"></li>\n <li *ngIf=\"!tree.horizontal\" [ngClass]=\"['p-treenode',node.styleClass||'', isLeaf() ? 'p-treenode-leaf': '']\">\n <div class=\"p-treenode-content\" [style.paddingLeft]=\"(level * indentation) + 'rem'\" (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]=\"{'p-treenode-selectable':tree.selectionMode && node.selectable !== false,'p-treenode-dragover':draghoverNode, 'p-highlight':isSelected()}\" role=\"treeitem\"\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 <button type=\"button\" class=\"p-tree-toggler p-link\" (click)=\"toggle($event)\" pRipple tabindex=\"-1\">\n <span class=\"p-tree-toggler-icon pi pi-fw\" [ngClass]=\"{'pi-chevron-right':!node.expanded,'pi-chevron-down':node.expanded}\"></span>\n </button>\n <div class=\"p-checkbox p-component\" [ngClass]=\"{'p-checkbox-disabled': node.selectable === false}\" *ngIf=\"tree.selectionMode == 'checkbox'\" [attr.aria-checked]=\"isSelected()\">\n <div class=\"p-checkbox-box\" [ngClass]=\"{'p-highlight': isSelected(), 'p-indeterminate': node.partialSelected}\">\n <span class=\"p-checkbox-icon pi\" [ngClass]=\"{'pi-check':isSelected(),'pi-minus':node.partialSelected}\"></span>\n </div>\n </div>\n <span [class]=\"getIcon()\" *ngIf=\"node.icon||node.expandedIcon||node.collapsedIcon\"></span>\n <span class=\"p-treenode-label\">\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=\"p-treenode-children\" style=\"display: none;\" *ngIf=\"!tree.virtualScroll && 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.trackBy\" [node]=\"childNode\" [parentNode]=\"node\"\n [firstChild]=\"firstChild\" [lastChild]=\"lastChild\" [index]=\"index\" [style.height.px]=\"tree.virtualNodeHeight\" [level]=\"level + 1\"></p-treeNode>\n </ul>\n </li>\n <li *ngIf=\"tree.droppableNodes&&lastChild\" class=\"p-treenode-droppoint\" [ngClass]=\"{'p-treenode-droppoint-active':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=\"p-treenode-connector\" *ngIf=\"!root\">\n <table class=\"p-treenode-connector-table\">\n <tbody>\n <tr>\n <td [ngClass]=\"{'p-treenode-connector-line':!firstChild}\"></td>\n </tr>\n <tr>\n <td [ngClass]=\"{'p-treenode-connector-line':!lastChild}\"></td>\n </tr>\n </tbody>\n </table>\n </td>\n <td class=\"p-treenode\" [ngClass]=\"{'p-treenode-collapsed':!node.expanded}\">\n <div class=\"p-treenode-content\" tabindex=\"0\" [ngClass]=\"{'p-treenode-selectable':tree.selectionMode,'p-highlight':isSelected()}\" (click)=\"onNodeClick($event)\" (contextmenu)=\"onNodeRightClick($event)\"\n (touchend)=\"onNodeTouchEnd()\" (keydown)=\"onNodeKeydown($event)\">\n <span class=\"p-tree-toggler pi pi-fw\" [ngClass]=\"{'pi-plus':!node.expanded,'pi-minus':node.expanded}\" *ngIf=\"!isLeaf()\" (click)=\"toggle($event)\"></span>\n <span [class]=\"getIcon()\" *ngIf=\"node.icon||node.expandedIcon||node.collapsedIcon\"></span>\n <span class=\"p-treenode-label\">\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=\"p-treenode-children-container\" *ngIf=\"node.children && node.expanded\" [style.display]=\"node.expanded ? 'table-cell' : 'none'\">\n <div class=\"p-treenode-children\">\n <p-treeNode *ngFor=\"let childNode of node.children;let firstChild=first;let lastChild=last; trackBy: tree.trackBy\" [node]=\"childNode\"\n [firstChild]=\"firstChild\" [lastChild]=\"lastChild\"></p-treeNode>\n </div>\n </td>\n </tr>\n </tbody>\n </table>\n </ng-template>\n ", encapsulation: i0.ViewEncapsulation.None }] }], ctorParameters: function () { return [{ type: undefined, decorators: [{ type: i0.Inject, args: [i0.forwardRef(function () { return Tree; })] }] }]; }, propDecorators: { rowNode: [{ type: i0.Input }], node: [{ type: i0.Input }], parentNode: [{ type: i0.Input }], root: [{ type: i0.Input }], index: [{ type: i0.Input }], firstChild: [{ type: i0.Input }], lastChild: [{ type: i0.Input }], level: [{ type: i0.Input }], indentation: [{ type: i0.Input }] } }); var Tree = /** @class */ (function () { function Tree(el, dragDropService, config) { this.el = el; this.dragDropService = dragDropService; this.config = config; this.selectionChange = new i0.EventEmitter(); this.onNodeSelect = new i0.EventEmitter(); this.onNodeUnselect = new i0.EventEmitter(); this.onNodeExpand = new i0.EventEmitter(); this.onNodeCollapse = new i0.EventEmitter(); this.onNodeContextMenuSelect = new i0.EventEmitter(); this.onNodeDrop = new i0.EventEmitter(); this.layout = 'vertical'; this.metaKeySelection = true; this.propagateSelectionUp = true; this.propagateSelectionDown = true; this.loadingIcon = 'pi pi-spinner'; this.emptyMessage = ''; this.filterBy = 'label'; this.filterMode = 'lenient'; this.indentation = 1.5; this.trackBy = function (index, item) { return item; }; this.onFilter = new i0.EventEmitter(); } Tree.prototype.ngOnInit = function () { var _this = this; if (this.droppableNodes) { this.dragStartSubscription = this.dragDropService.dragStart$.subscribe(function (event) { _this.dragNodeTree = event.tree; _this.dragNode = event.node; _this.dragNodeSubNodes = event.subNodes; _this.dragNodeIndex = event.index; _this.dragNodeScope = event.scope; }); this.dragStopSubscription = this.dragDropService.dragStop$.subscribe(function (event) { _this.dragNodeTree = null; _this.dragNode = null; _this.dragNodeSubNodes = null; _this.dragNodeIndex = null; _this.dragNodeScope = null; _this.dragHover = false; }); } }; Tree.prototype.ngOnChanges = function (simpleChange) { if (simpleChange.value) { this.updateSerializedValue(); } if (simpleChange.scrollHeight && this.virtualScrollBody) { this.virtualScrollBody.ngOnInit(); } }; Object.defineProperty(Tree.prototype, "horizontal", { get: function () { return this.layout == 'horizontal'; }, enumerable: false, configurable: true }); Object.defineProperty(Tree.prototype, "emptyMessageLabel", { get: function () { return this.emptyMessage || this.config.getTranslation(i3.TranslationKeys.EMPTY_MESSAGE); }, enumerable: false, configurable: true }); Tree.prototype.ngAfterConte