/**
 * @fileoverview added by tsickle
 * Generated from: components/splitbutton/splitbutton.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 { Component, Input, ContentChildren, QueryList, ChangeDetectorRef, Output, EventEmitter } from '@angular/core';
import { OverlayAnimation } from '../core/directives/overlay-animation';
import { TlSplitButtonAction } from './parts/splitbutton-action';
export class TlSplitButton {
    /**
     * @param {?} change
     */
    constructor(change) {
        this.change = change;
        this.text = '';
        this.width = '100%';
        this.height = '30px';
        this.disabled = null;
        this.color = 'basic';
        this.click = new EventEmitter();
        this.positionOverlay = 'bottom';
        this.listItems = [];
    }
    /**
     * @return {?}
     */
    ngAfterContentInit() {
        this.listItems = this.actions.map((/**
         * @param {?} item
         * @return {?}
         */
        (item) => item.templateList));
        this.actions.forEach((/**
         * @param {?} item
         * @return {?}
         */
        (item) => item.click.subscribe((/**
         * @return {?}
         */
        () => this.isOpen = false))));
    }
    /**
     * @param {?} $event
     * @return {?}
     */
    onPositionChange($event) {
        this.positionOverlay = $event.connectionPair.originY;
        this.change.detectChanges();
    }
    /**
     * @return {?}
     */
    get disabledActions() {
        return this.actions.filter((/**
         * @param {?} item
         * @return {?}
         */
        (item) => item.disabled)).length === this.actions.length;
    }
    /**
     * @param {?} $event
     * @return {?}
     */
    open($event) {
        this.stopEvent($event);
        if (!this.disabledActions) {
            this.isOpen = !this.isOpen;
        }
    }
    /**
     * @param {?} $event
     * @return {?}
     */
    stopEvent($event) {
        $event.preventDefault();
        $event.stopPropagation();
    }
    /**
     * @param {?} $event
     * @return {?}
     */
    onButtonClick($event) {
        if (!this.disabled) {
            this.click.emit($event);
        }
        this.stopEvent($event);
    }
    /**
     * @return {?}
     */
    onBackdropClick() {
        this.isOpen = false;
        this.change.detectChanges();
    }
}
TlSplitButton.decorators = [
    { type: Component, args: [{
                selector: 'tl-split-button',
                template: "<div class=\"split-wrapper\" [ngClass]=\"color\" (click)=\"onButtonClick($event)\">\n  <div class=\"split-content\" #split>\n    <tl-button cdkOverlayOrigin #trigger=\"cdkOverlayOrigin\"\n               [color]=\"color\"\n               [text]=\"text\"\n               [disabled]=\"disabled\"\n               [width]=\"width\"\n               [height]=\"height\">\n    </tl-button>\n    <div [class.active]=\"isOpen\"\n         (click)=\"open($event)\"\n         [class.disabled]=\"disabledActions\"\n         class=\"split-button-actions\"\n         [ngStyle]=\"{'height': height, 'line-height': height}\">\n      <div class=\"icon-arrow\" [style.transform]=\"isOpen ? 'rotate(180deg)' : 'rotate(0)'\">\n        <tl-icon [lib]=\"'fa'\" [style]=\"'fas'\">chevron-down</tl-icon>\n      </div>\n      <ng-template cdkConnectedOverlay\n                   (backdropClick)=\"onBackdropClick()\"\n                   (positionChange)=\"onPositionChange($event)\"\n                   [cdkConnectedOverlayHasBackdrop]=\"true\"\n                   [cdkConnectedOverlayOrigin]=\"trigger\"\n                   [cdkConnectedOverlayBackdropClass]=\"'cdk-overlay-transparent-backdrop'\"\n                   [cdkConnectedOverlayOpen]=\"isOpen\">\n        <ul @overlay\n            [style.minWidth]=\"split.offsetWidth + 'px'\"\n            [class.margin-top]=\"positionOverlay === 'bottom'\"\n            [class.margin-bottom]=\"positionOverlay === 'top'\"\n            class=\"actions-menu\">\n            <ng-container *ngFor=\"let item of listItems\">\n              <ng-container *ngTemplateOutlet=\"item\"></ng-container>\n            </ng-container>\n        </ul>\n      </ng-template>\n    </div>\n  </div>\n</div>\n",
                animations: [OverlayAnimation],
                styles: [".tl-button{border-radius:3px 0 0 3px}.split-wrapper{display:inline-block;position:relative}.split-wrapper>.split-content{display:flex}.split-wrapper>.split-content>::ng-deep tl-button button{border-bottom-right-radius:0!important;border-top-right-radius:0!important}.split-wrapper>.split-content>.split-button-actions{-moz-user-select:none;-ms-user-select:none;-webkit-user-select:none;border-bottom-right-radius:3px;border-top-right-radius:3px;box-sizing:border-box;cursor:pointer;float:right;margin:0;padding:0;user-select:none}.split-wrapper>.split-content>.split-button-actions tl-icon{padding:0 15px}.split-wrapper>.split-content>.ui-button:hover{cursor:pointer}.icon-arrow{transition:transform .25s ease-in-out}.actions-menu{border-radius:3px;box-shadow:0 0 3px hsla(0,0%,75.7%,.4);box-sizing:border-box;cursor:auto;display:inline;height:auto;left:0;list-style:none;margin:0;overflow:hidden;padding:0;position:relative;z-index:1}.actions-menu.margin-top{margin-top:2px}.actions-menu.margin-bottom{margin-bottom:2px}"]
            }] }
];
/** @nocollapse */
TlSplitButton.ctorParameters = () => [
    { type: ChangeDetectorRef }
];
TlSplitButton.propDecorators = {
    text: [{ type: Input }],
    width: [{ type: Input }],
    height: [{ type: Input }],
    disabled: [{ type: Input }],
    color: [{ type: Input }],
    click: [{ type: Output }],
    actions: [{ type: ContentChildren, args: [TlSplitButtonAction,] }]
};
if (false) {
    /** @type {?} */
    TlSplitButton.prototype.text;
    /** @type {?} */
    TlSplitButton.prototype.width;
    /** @type {?} */
    TlSplitButton.prototype.height;
    /** @type {?} */
    TlSplitButton.prototype.disabled;
    /** @type {?} */
    TlSplitButton.prototype.color;
    /** @type {?} */
    TlSplitButton.prototype.click;
    /** @type {?} */
    TlSplitButton.prototype.actions;
    /** @type {?} */
    TlSplitButton.prototype.isOpen;
    /** @type {?} */
    TlSplitButton.prototype.positionOverlay;
    /** @type {?} */
    TlSplitButton.prototype.listItems;
    /**
     * @type {?}
     * @private
     */
    TlSplitButton.prototype.change;
}
//# sourceMappingURL=data:application/json;base64, 