import { Component, EventEmitter, Input, Output } from '@angular/core';
import { I18nService } from 'ng-devui/i18n';
import { UnitRole } from '../gantt.model';
import * as i0 from "@angular/core";
import * as i1 from "ng-devui/i18n";
import * as i2 from "@angular/common";
import * as i3 from "ng-devui/button";
import * as i4 from "ng-devui/dropdown";
export class GanttToolsComponent {
    constructor(i18n) {
        this.i18n = i18n;
        this.isFullScreen = false;
        this.goToday = new EventEmitter();
        this.reduceUnit = new EventEmitter();
        this.increaseUnit = new EventEmitter();
        this.switchView = new EventEmitter();
        this.unitRole = UnitRole;
        this._currentUnit = '';
        this.views = [
            {
                label: 'Day',
                value: 'day'
            },
            {
                label: 'Week',
                value: 'week'
            },
            {
                label: 'Month',
                value: 'month'
            }
        ];
    }
    set currentUnit(val) {
        this._currentUnit = val;
        const data = this.views.filter(i => i.value === val);
    }
    get currentUnit() {
        return this._currentUnit;
    }
    get currentUnitLabel() {
        return this._currentLabel || (this.views.length > 0 ? this.views[0].label : '');
    }
    ;
    ngOnInit() {
        this.i18nText = this.i18n.getI18nText().gantt;
        this.i18nLocale = this.i18n.getI18nText().locale;
        this.i18nSubscription = this.i18n.langChange().subscribe((data) => {
            this.i18nText = data.gantt;
            this.i18nLocale = data.locale;
            this.views = [
                {
                    label: this.i18nText?.day,
                    value: 'day'
                },
                {
                    label: this.i18nText?.week,
                    value: 'week'
                },
                {
                    label: this.i18nText?.month,
                    value: 'month'
                }
            ];
        });
    }
    avtionHandle(type) {
        switch (type) {
            case 'today':
                this.goToday.emit();
                break;
            case 'reduce':
                this.reduceUnit.emit();
                break;
            case 'increase':
                this.increaseUnit.emit();
                break;
        }
    }
    selectView(menu) {
        this._currentLabel = menu.label;
        this.switchView.emit(menu.value);
    }
}
GanttToolsComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.0", ngImport: i0, type: GanttToolsComponent, deps: [{ token: i1.I18nService }], target: i0.ɵɵFactoryTarget.Component });
GanttToolsComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.0", type: GanttToolsComponent, selector: "d-gantt-tools", inputs: { currentUnit: "currentUnit", isFullScreen: "isFullScreen" }, outputs: { goToday: "goToday", reduceUnit: "reduceUnit", increaseUnit: "increaseUnit", switchView: "switchView" }, ngImport: i0, template: "<div class=\"tools-container\" [style.position]=\"isFullScreen ? 'fixed' : 'absolute'\">\n  <d-button bsStyle=\"text\" (click)=\"avtionHandle('today')\" class=\"tool\">{{ i18nText.today }}</d-button>\n  <div class=\"tool\">\n    <span dDropDown [trigger]=\"'click'\" appendToBody class=\"switch-view\">\n      <span dDropDownToggle class=\"devui-dropdown-origin\">{{ currentUnitLabel }} <span class=\"icon-chevron-down\"></span></span>\n      <ul dDropDownMenu class=\"devui-dropdown-menu devui-scrollbar\" role=\"menu\">\n        <li role=\"menuItem\" *ngFor=\"let menu of views\" (click)=\"selectView(menu)\">\n          <a class=\"devui-dropdown-item\">{{ menu.label }}</a>\n        </li>\n      </ul>\n    </span>\n  </div>\n  <d-button\n    bsStyle=\"text\"\n    (click)=\"avtionHandle('reduce')\"\n    class=\"tool\"\n    [ngClass]=\"{ disabled: unitRole[this.currentUnit] === unitRole.day }\"\n    [disabled]=\"unitRole[this.currentUnit] === unitRole.day\"\n  >\n    <i class=\"icon icon-minus\"></i>\n  </d-button>\n  <d-button\n    bsStyle=\"text\"\n    (click)=\"avtionHandle('increase')\"\n    class=\"tool\"\n    [ngClass]=\"{ disabled: unitRole[this.currentUnit] === unitRole.month }\"\n    [disabled]=\"unitRole[this.currentUnit] === unitRole.month\"\n  >\n    <i class=\"icon icon-add\"></i>\n  </d-button>\n  <ng-content></ng-content>\n</div>\n", styles: [".devui-font-size-base{font-size:12px;font-size:var(--devui-font-size, 12px)}.devui-font-base{font-size:12px;font-size:var(--devui-font-size, 12px);font-weight:400;line-height:1.5}.devui-font-size-modal-title{font-size:18px;font-size:var(--devui-font-size-modal-title, 18px)}.devui-font-modal-title{font-size:18px;font-size:var(--devui-font-size-modal-title, 18px);font-weight:700;line-height:1.5}.devui-font-size-page-title{font-size:16px;font-size:var(--devui-font-size-page-title, 16px)}.devui-font-page-title{font-size:16px;font-size:var(--devui-font-size-page-title, 16px);font-weight:700;line-height:1.5}.devui-font-size-secondary-title{font-size:14px;font-size:var(--devui-font-size-card-title, 14px)}.devui-font-secondary-title{font-size:14px;font-size:var(--devui-font-size-card-title, 14px);font-weight:700;line-height:1.5}.tools-container{position:absolute;top:70px;right:20px;z-index:10}.tool{display:inline-flex;align-items:center;justify-content:center;height:32px;margin-left:12px;background-color:#fff;background-color:var(--devui-base-bg, #ffffff);box-shadow:0 1px 4px #5170ff66;box-shadow:var(--devui-shadow-length-base, 0 1px 4px 0) #5170ff66;cursor:pointer}.tool.disabled{opacity:.5}.tool span{border:0!important}.tool .switch-view{padding:0 8px}.tool .switch-view:hover{color:#526ecc!important;color:var(--devui-link, #526ecc)!important}.devui-dropdown-menu{top:10px!important;left:-6px!important}:host ::ng-deep .devui-dropdown-origin{border:0}:host ::ng-deep .devui-dropdown-origin:hover{color:#526ecc!important;color:var(--devui-link, #526ecc)!important}:host ::ng-deep .devui-btn{height:32px!important;color:#252b3a!important;color:var(--devui-text, #252b3a)!important;padding:0 8px!important}:host ::ng-deep .devui-btn:hover{color:#526ecc!important;color:var(--devui-link, #526ecc)!important}\n"], dependencies: [{ kind: "directive", type: i2.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i2.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "component", type: i3.ButtonComponent, selector: "d-button", inputs: ["id", "type", "bsStyle", "shape", "bsSize", "bsPosition", "bordered", "icon", "disabled", "showLoading", "width", "autofocus", "loadingTemplateRef"], outputs: ["btnClick"] }, { kind: "directive", type: i4.DropDownDirective, selector: "[dDropDown]", inputs: ["isOpen", "disabled", "showAnimation", "trigger", "closeScope", "closeOnMouseLeaveMenu"], outputs: ["toggleEvent"], exportAs: ["d-dropdown"] }, { kind: "directive", type: i4.DropDownMenuDirective, selector: "[dDropDownMenu]", exportAs: ["d-dropdown-menu"] }, { kind: "directive", type: i4.DropDownToggleDirective, selector: "[dDropDownToggle]", inputs: ["toggleOnFocus", "autoFocus"], exportAs: ["d-dropdown-toggle"] }, { kind: "component", type: i4.DropDownAppendToBodyComponent, selector: "[dDropDown][appendToBody]", inputs: ["alignOrigin", "appendToBodyDirections"] }] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.0", ngImport: i0, type: GanttToolsComponent, decorators: [{
            type: Component,
            args: [{ selector: 'd-gantt-tools', template: "<div class=\"tools-container\" [style.position]=\"isFullScreen ? 'fixed' : 'absolute'\">\n  <d-button bsStyle=\"text\" (click)=\"avtionHandle('today')\" class=\"tool\">{{ i18nText.today }}</d-button>\n  <div class=\"tool\">\n    <span dDropDown [trigger]=\"'click'\" appendToBody class=\"switch-view\">\n      <span dDropDownToggle class=\"devui-dropdown-origin\">{{ currentUnitLabel }} <span class=\"icon-chevron-down\"></span></span>\n      <ul dDropDownMenu class=\"devui-dropdown-menu devui-scrollbar\" role=\"menu\">\n        <li role=\"menuItem\" *ngFor=\"let menu of views\" (click)=\"selectView(menu)\">\n          <a class=\"devui-dropdown-item\">{{ menu.label }}</a>\n        </li>\n      </ul>\n    </span>\n  </div>\n  <d-button\n    bsStyle=\"text\"\n    (click)=\"avtionHandle('reduce')\"\n    class=\"tool\"\n    [ngClass]=\"{ disabled: unitRole[this.currentUnit] === unitRole.day }\"\n    [disabled]=\"unitRole[this.currentUnit] === unitRole.day\"\n  >\n    <i class=\"icon icon-minus\"></i>\n  </d-button>\n  <d-button\n    bsStyle=\"text\"\n    (click)=\"avtionHandle('increase')\"\n    class=\"tool\"\n    [ngClass]=\"{ disabled: unitRole[this.currentUnit] === unitRole.month }\"\n    [disabled]=\"unitRole[this.currentUnit] === unitRole.month\"\n  >\n    <i class=\"icon icon-add\"></i>\n  </d-button>\n  <ng-content></ng-content>\n</div>\n", styles: [".devui-font-size-base{font-size:12px;font-size:var(--devui-font-size, 12px)}.devui-font-base{font-size:12px;font-size:var(--devui-font-size, 12px);font-weight:400;line-height:1.5}.devui-font-size-modal-title{font-size:18px;font-size:var(--devui-font-size-modal-title, 18px)}.devui-font-modal-title{font-size:18px;font-size:var(--devui-font-size-modal-title, 18px);font-weight:700;line-height:1.5}.devui-font-size-page-title{font-size:16px;font-size:var(--devui-font-size-page-title, 16px)}.devui-font-page-title{font-size:16px;font-size:var(--devui-font-size-page-title, 16px);font-weight:700;line-height:1.5}.devui-font-size-secondary-title{font-size:14px;font-size:var(--devui-font-size-card-title, 14px)}.devui-font-secondary-title{font-size:14px;font-size:var(--devui-font-size-card-title, 14px);font-weight:700;line-height:1.5}.tools-container{position:absolute;top:70px;right:20px;z-index:10}.tool{display:inline-flex;align-items:center;justify-content:center;height:32px;margin-left:12px;background-color:#fff;background-color:var(--devui-base-bg, #ffffff);box-shadow:0 1px 4px #5170ff66;box-shadow:var(--devui-shadow-length-base, 0 1px 4px 0) #5170ff66;cursor:pointer}.tool.disabled{opacity:.5}.tool span{border:0!important}.tool .switch-view{padding:0 8px}.tool .switch-view:hover{color:#526ecc!important;color:var(--devui-link, #526ecc)!important}.devui-dropdown-menu{top:10px!important;left:-6px!important}:host ::ng-deep .devui-dropdown-origin{border:0}:host ::ng-deep .devui-dropdown-origin:hover{color:#526ecc!important;color:var(--devui-link, #526ecc)!important}:host ::ng-deep .devui-btn{height:32px!important;color:#252b3a!important;color:var(--devui-text, #252b3a)!important;padding:0 8px!important}:host ::ng-deep .devui-btn:hover{color:#526ecc!important;color:var(--devui-link, #526ecc)!important}\n"] }]
        }], ctorParameters: function () { return [{ type: i1.I18nService }]; }, propDecorators: { currentUnit: [{
                type: Input,
                args: ['currentUnit']
            }], isFullScreen: [{
                type: Input
            }], goToday: [{
                type: Output
            }], reduceUnit: [{
                type: Output
            }], increaseUnit: [{
                type: Output
            }], switchView: [{
                type: Output
            }] } });
//# sourceMappingURL=data:application/json;base64, 