import { Component, Input, ViewChild } from '@angular/core';
import { MatTableDataSource } from '@angular/material/table';
import { ZuiExcelService } from '../../../excel';
import { ZuiTableFilterDialogComponent } from '../filter-dialog';
export class ZuiTableOptionComponent {
    constructor(zuiExcelService) {
        this.zuiExcelService = zuiExcelService;
        this.exportItems = [];
        this.action = () => {
            this.optionDialog.open();
        };
    }
    ngOnChanges() {
        // console.log('currentOptions', this.currentOptions)
        if (this.visible) {
            const { config: { export: { excel: { visible: excelVisible = true, transform: excelTransform, fileName, showTime }, csv: { visible: csvVisible = true, transform: csvTransform, fileName: csvFileName, showTime: csvShowTime }, }, }, } = this.currentOptions;
            if (excelVisible) {
                this.exportItems.push({
                    label: 'Export Excel',
                    action: (event) => {
                        console.log('item1', event);
                    },
                });
            }
            if (csvVisible) {
                this.exportItems.push({
                    label: 'Export CSV',
                    action: () => {
                        const columns = this.currentOptions.columns.map(column => ({
                            field: column.field,
                            title: column.title,
                        }));
                        this.zuiExcelService.exportCsv({
                            columns,
                            items: this.dataSource.data,
                            fileName: csvFileName,
                            showTime: csvShowTime,
                        });
                    },
                });
            }
        }
    }
    get visible() {
        var _a, _b, _c;
        return (_c = (_b = (_a = this.currentOptions) === null || _a === void 0 ? void 0 : _a.config) === null || _b === void 0 ? void 0 : _b.option) === null || _c === void 0 ? void 0 : _c.visible;
    }
}
ZuiTableOptionComponent.decorators = [
    { type: Component, args: [{
                selector: 'zui-table-option',
                template: "<zui-button *ngIf=\"visible\" label=\"Option\" prefixIcon=\"settings\" (action)=\"action()\"></zui-button>\n<zui-table-option-dialog #optionDialog></zui-table-option-dialog>\n",
                styles: [".zui-table table{width:100%}.zui-table-set-height{overflow:hidden;display:flex;flex-direction:column}.zui-table-container{flex:1;overflow-y:auto}.zui-table-container-hide-scrollbar{overflow:hidden}.zui-table-container-hide-scrollbar:hover{padding:0}.zui-table-highlight:hover{background-color:var(--hoverHighlightColor)}.zui-table-highlight-checked,.zui-table-highlight-checked:hover{background-color:var(--checkedHighlightColor)}.zui-table-expanded-detail{overflow:hidden}.zui-table-time{color:grey}:host ::ng-deep .zui-table-head{vertical-align:middle;font-weight:700;font-size:15px;padding:0 10px}:host ::ng-deep .zui-table-head.mat-header-cell:first-of-type{padding-left:10px}:host ::ng-deep .zui-table-head.mat-header-cell:last-of-type{padding-right:10px}:host ::ng-deep .zui-table-head-left>div{justify-content:left}:host ::ng-deep .zui-table-head-center>div{justify-content:center}:host ::ng-deep .zui-table-head-right>div{justify-content:right}:host ::ng-deep .zui-table-content{padding:0 10px}:host ::ng-deep .zui-table-content.mat-cell:first-of-type{padding-left:10px}:host ::ng-deep .zui-table-content.mat-cell:last-of-type{padding-right:10px}:host ::ng-deep .zui-table-footer{padding:10px 0;text-align:center}:host ::ng-deep .zui-table-footer.mat-footer-cell:first-of-type{padding-left:10px}:host ::ng-deep .zui-table-footer.mat-footer-cell:last-of-type{padding-right:10px}"]
            },] }
];
ZuiTableOptionComponent.ctorParameters = () => [
    { type: ZuiExcelService }
];
ZuiTableOptionComponent.propDecorators = {
    currentOptions: [{ type: Input }],
    dataSource: [{ type: Input }],
    optionDialog: [{ type: ViewChild, args: ['optionDialog',] }]
};
//# sourceMappingURL=index.component.js.map