/**
 * @fileoverview added by tsickle
 * Generated from: components/contextmenu/context-menu.ts
 * @suppress {checkTypes,constantProperty,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
 */
/*
    MIT License

    Copyright (c) 2019 Temainfo Software

    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the "Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
    The above copyright notice and this permission notice shall be included in all
    copies or substantial portions of the Software.
    THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
    SOFTWARE.
*/
import { ChangeDetectorRef, Component, EventEmitter, Output } from '@angular/core';
export class TlContextMenuComponent {
    /**
     * @param {?} changes
     */
    constructor(changes) {
        this.changes = changes;
        this.select = new EventEmitter();
        this.isOpen = false;
        this.positions = [
            {
                originX: 'end',
                originY: 'top',
                overlayX: 'start',
                overlayY: 'top',
            },
            {
                originX: 'end',
                originY: 'bottom',
                overlayX: 'start',
                overlayY: 'bottom',
            }
        ];
    }
    /**
     * @return {?}
     */
    ngOnInit() { }
    /**
     * @param {?} items
     * @param {?} context
     * @return {?}
     */
    init(items, context) {
        this.contextMenu = items;
        this.currentContext = context;
        this.changes.detectChanges();
    }
    /**
     * @param {?} callback
     * @return {?}
     */
    onClickItem(callback) {
        if (callback) {
            this.select.emit();
            return this.currentContext ? callback(this.currentContext) : callback();
        }
    }
    /**
     * @param {?} item
     * @return {?}
     */
    onItemMouseOver(item) {
        var _a;
        if (((_a = item === null || item === void 0 ? void 0 : item.children) === null || _a === void 0 ? void 0 : _a.length) > 0) {
            this.isOpen = !this.isOpen;
        }
    }
}
TlContextMenuComponent.decorators = [
    { type: Component, args: [{
                selector: 'tl-context-menu',
                template: "<div class=\"ui-menu-context-wrapper\">\n  <ul class=\"ui-menu-context\">\n    <ng-template ngFor let-item [ngForOf]=\"contextMenu\">\n      <ng-template\n        [ngTemplateOutlet]=\"templateList\"\n        [ngTemplateOutletContext]=\"{ $implicit: item }\">\n      </ng-template>\n    </ng-template>\n  </ul>\n</div>\n\n<ng-template #templateUL let-children >\n  <ul class=\"ui-menu-context\">\n    <ng-template ngFor let-item [ngForOf]=\"children\">\n      <ng-template\n        [ngTemplateOutlet]=\"templateList\"\n        [ngTemplateOutletContext]=\"{ $implicit: item }\">\n      </ng-template>\n    </ng-template>\n  </ul>\n</ng-template>\n\n<ng-template #templateList let-item>\n  <li class=\"ui-item-context\" (click)=\"onClickItem(item?.callback);\" (mouseenter)=\"onItemMouseOver(item)\"\n      [class.hasChildren]=\"item?.children\"\n      [class.no-icon]=\"!item?.icon || item?.template\"\n      cdkOverlayOrigin #trigger=\"cdkOverlayOrigin\">\n\n    <ng-container *ngIf=\"item?.template; else listDefault\">\n      <ng-container *ngTemplateOutlet=\"item?.template\"></ng-container>\n    </ng-container>\n\n    <ng-template #listDefault>\n      <tl-icon [color]=\"item?.iconColor\" [size]=\"'15px'\" *ngIf=\"item?.icon\">{{ item?.icon }}</tl-icon>\n      <span class=\"ui-item-label\">{{ item?.label }}</span>\n      <tl-icon class=\"ui-item-arrow\" *ngIf=\"item?.children\" [lib]=\"'ion'\" [style]=\"'ios'\" [size]=\"'15px'\">arrow-forward</tl-icon>\n    </ng-template>\n\n    <ng-template cdkConnectedOverlay\n                   [cdkConnectedOverlayOrigin]=\"trigger\"\n                   [cdkConnectedOverlayPositions]=\"positions\"\n                   [cdkConnectedOverlayOpen]=\"isOpen\">\n      <ng-container *ngIf=\"item?.children\" >\n        <ng-container *ngTemplateOutlet=\"templateUL; context: { $implicit: item?.children }\"></ng-container>\n      </ng-container>\n    </ng-template>\n\n\n  </li>\n</ng-template>\n\n\n",
                styles: [".ui-menu-context-wrapper{height:100%;width:100%}.ui-menu-context{align-items:center;display:flex;flex-flow:column;padding:0}.ui-item-context,.ui-menu-context{font-size:10pt;list-style:none;margin:0;opacity:1;z-index:1000}.ui-item-context{-moz-user-select:none;-ms-grid-columns:20px 1fr;-ms-user-select:none;-webkit-user-select:none;box-sizing:border-box;display:-ms-inline-grid;display:inline-grid;grid-template-columns:20px 1fr;padding:10px;text-align:left;user-select:none;width:100%}.ui-item-context:hover{cursor:pointer}.ui-item-context.no-icon{-ms-grid-columns:1fr!important;grid-template-columns:1fr!important}.ui-item-context.hasChildren{-ms-grid-columns:1fr 30px!important;grid-template-columns:1fr 30px!important}.ui-item-context.hasChildren:not(.no-icon){-ms-grid-columns:20px 1fr 30px!important;grid-template-columns:20px 1fr 30px!important}.ui-item-label{white-space:nowrap}.ui-item-arrow{text-align:right}"]
            }] }
];
/** @nocollapse */
TlContextMenuComponent.ctorParameters = () => [
    { type: ChangeDetectorRef }
];
TlContextMenuComponent.propDecorators = {
    select: [{ type: Output }]
};
if (false) {
    /** @type {?} */
    TlContextMenuComponent.prototype.contextMenu;
    /**
     * @type {?}
     * @private
     */
    TlContextMenuComponent.prototype.currentContext;
    /** @type {?} */
    TlContextMenuComponent.prototype.select;
    /** @type {?} */
    TlContextMenuComponent.prototype.isOpen;
    /** @type {?} */
    TlContextMenuComponent.prototype.positions;
    /**
     * @type {?}
     * @private
     */
    TlContextMenuComponent.prototype.changes;
}
//# sourceMappingURL=data:application/json;base64, 