import * as tslib_1 from "tslib";
import { Component, Input, Output, EventEmitter, ViewEncapsulation, ChangeDetectionStrategy, Inject, forwardRef, TemplateRef } from '@angular/core';
import { TreeComponent } from './tree';
var TreeNodeComponent = /** @class */ (function () {
    function TreeNodeComponent(tree) {
        this.tree = tree;
        /**
         * tree node expand event
         */
        this.onExpandNode = new EventEmitter();
    }
    TreeNodeComponent.prototype.ngOnInit = function () { };
    /**
     * listen tree-node click event
     * @docs-private
     */
    TreeNodeComponent.prototype.onNodeClick = function () {
        this.tree.onNodeClick(this.node);
    };
    /**
     * fold or unfold tree-node event
     * @docs-private
     */
    TreeNodeComponent.prototype.toggle = function (event) {
        event.stopPropagation();
        this.node.isExpanded = !this.node.isExpanded;
        this.onExpandNode.emit(this.node);
    };
    /**
     * tree node expand event
     * @docs-private
     */
    TreeNodeComponent.prototype.expandNode = function (event) {
        this.onExpandNode.emit(event);
    };
    /**
     * judge text length whether is over long or not
     * @docs-private
     */
    TreeNodeComponent.prototype.judgeOverLong = function (event) {
        return event.level ? event.name && event.name.length + event.level >= 10 ? true : false : false;
    };
    tslib_1.__decorate([
        Input(),
        tslib_1.__metadata("design:type", Object)
    ], TreeNodeComponent.prototype, "node", void 0);
    tslib_1.__decorate([
        Input(),
        tslib_1.__metadata("design:type", TemplateRef)
    ], TreeNodeComponent.prototype, "optionTpl", void 0);
    tslib_1.__decorate([
        Output(),
        tslib_1.__metadata("design:type", Object)
    ], TreeNodeComponent.prototype, "onExpandNode", void 0);
    TreeNodeComponent = tslib_1.__decorate([
        Component({
            selector: 'nb-tree-node',
            template: "<li [ngClass]=\"['nb-tree-node', node.styleClass || '']\"><span *ngIf=\"node.children && node.children.length || node.hasChild\" class=\"nb-tree-node-toggle iconfont\" [ngClass]=\"{'icon-down': node.isExpanded, 'icon-right': !node.isExpanded, 'nb-tree-node-show': node.show}\" (click)=\"toggle($event)\"></span><div class=\"nb-tree-content\" [ngClass]=\"{'nb-tree-node-selected': node.isSelected, 'nb-tree-node-unselectable': !node.selectable, 'nb-tree-node-show': node.show}\" (click)=\"onNodeClick()\"><span *ngIf=\"!judgeOverLong(node) && !optionTpl\" class=\"nb-tree-node-name\">{{ node.name }} </span><span *ngIf=\"!judgeOverLong(node) && optionTpl\" class=\"nb-tree-node-name\"><ng-container *ngTemplateOutlet=\"optionTpl;context: {$implicit: node}\"></ng-container></span><span *ngIf=\"judgeOverLong(node) && !optionTpl\" class=\"nb-tree-node-name\" nbTooltip=\"{{node.name}}\" nbTooltipClass=\"customize-classname\" placement=\"bottom-left\" hasArrow>{{ node.name }} </span><span *ngIf=\"judgeOverLong(node) && optionTpl\" class=\"nb-tree-node-name\" nbTooltip=\"{{node.name}}\" nbTooltipClass=\"customize-classname\" placement=\"bottom-left\" hasArrow><ng-container *ngTemplateOutlet=\"optionTpl;context: {$implicit: node}\"></ng-container></span><span *ngIf=\"node.selectable\" class=\"nb-tree-node-selection-candidate-icon iconfont\" [ngClass]=\"{'icon-arrow-right': !node.isSelected, 'icon-check': node.isSelected}\"></span> <span *ngIf=\"node.selectable\" class=\"nb-tree-node-selection-selected-icon iconfont icon-close\"></span></div><ul class=\"nb-tree-node-list\" [style.display]=\"node.isExpanded ? 'block' : 'none'\"><nb-tree-node *ngFor=\"let childNode of node.children\" [node]=\"childNode\" (onExpandNode)=\"expandNode($event)\" [optionTpl]=\"optionTpl\"></nb-tree-node></ul></li>",
            encapsulation: ViewEncapsulation.None,
            changeDetection: ChangeDetectionStrategy.Default,
            preserveWhitespaces: false,
            host: {
                'class': 'nb-widget nb-tree-node'
            }
        }),
        tslib_1.__param(0, Inject(forwardRef(function () { return TreeComponent; }))),
        tslib_1.__metadata("design:paramtypes", [TreeComponent])
    ], TreeNodeComponent);
    return TreeNodeComponent;
}());
export { TreeNodeComponent };
//# sourceMappingURL=tree-node.js.map