import { ChangeDetectorRef, Component, ElementRef, EventEmitter, forwardRef, HostBinding, Inject, Input, NgZone, Output } from '@angular/core';
import { DATA_TABLE_ROW } from './data-table-row.token';
import { DATA_TABLE } from './data-table.token';
import { ForceUpdateReason } from './force-update-reason.model';
import * as i0 from "@angular/core";
import * as i1 from "@angular/common";
import * as i2 from "@angular/forms";
import * as i3 from "ng-devui/checkbox";
import * as i4 from "ng-devui/tooltip";
import * as i5 from "./data-table-cell.component";
export class DataTableRowComponent {
    constructor(dt, changeDetectorRef, rowRef, ngZone) {
        this.dt = dt;
        this.changeDetectorRef = changeDetectorRef;
        this.rowRef = rowRef;
        this.ngZone = ngZone;
        this.fontWeight = 'normal';
        this.verticalAlign = 'middle';
        this.detailChange = new EventEmitter();
        this.forceUpdateEvent = new EventEmitter();
        this.clickCount = 0; // 记录点击次数
    }
    ngOnInit() {
        this.ngZone.runOutsideAngular(() => {
            this.rowRef.nativeElement.addEventListener('mouseup', this.onRowClick.bind(this));
            this.rowRef.nativeElement.addEventListener('dblclick', this.onRowDBClick.bind(this));
            if (this.generalRowHoveredData) {
                this.rowRef.nativeElement.addEventListener('mouseenter', this.onRowMouseEnter.bind(this));
                this.rowRef.nativeElement.addEventListener('mouseleave', this.onRowMouseLeave.bind(this));
            }
        });
    }
    forceUpdate() {
        this.changeDetectorRef.markForCheck();
        this.forceUpdateEvent.emit(ForceUpdateReason.RowUpdate);
    }
    onRowClick($event) {
        this.clickCount++;
        if (this.clickCount === 1) {
            this.timeoutId = setTimeout(() => {
                if (this.clickCount === 1) {
                    this.dt.onRowClick({
                        rowIndex: this.rowIndex, nestedIndex: this.nestedIndex, rowItem: this.rowItem, rowComponent: this, event: $event
                    });
                }
                this.clickCount = 0;
                clearTimeout(this.timeoutId);
            }, this.timeout);
        }
    }
    onRowDBClick($event) {
        this.dt.onRowDBClick({ rowIndex: this.rowIndex, nestedIndex: this.nestedIndex, rowItem: this.rowItem, rowComponent: this });
    }
    onRowMouseEnter($event) {
        this.ngZone.run(() => {
            this.rowItem.$hovered = true;
        });
    }
    onRowMouseLeave($event) {
        this.ngZone.run(() => {
            this.rowItem.$hovered = false;
        });
    }
    onRowCheckChange($event, rowIndex, nestedIndex, rowItem) {
        rowItem.$checked = $event;
        rowItem.$halfChecked = false;
        this.dt.setRowCheckStatus({ rowItem, rowIndex, nestedIndex, checked: $event });
    }
    toggle() {
        if (this.rowItem['$isDetailOpen'] === undefined) {
            this.rowItem['$isDetailOpen'] = !!this.rowItem.$expandConfig?.expand;
        }
        this.rowItem['$isDetailOpen'] = !this.rowItem['$isDetailOpen'];
        if (this.rowItem.$expandConfig) {
            this.rowItem.$expandConfig.expand = !this.rowItem.$expandConfig.expand;
        }
        this.detailChange.emit({ state: this.rowItem['$isDetailOpen'], index: this.rowIndex });
        this.dt.onDetailToggle({ state: this.rowItem['$isDetailOpen'], index: this.rowIndex });
    }
    trackByFn(index, item) {
        return index;
    }
}
DataTableRowComponent.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "14.2.0", ngImport: i0, type: DataTableRowComponent, deps: [{ token: DATA_TABLE }, { token: i0.ChangeDetectorRef }, { token: i0.ElementRef }, { token: i0.NgZone }], target: i0.ɵɵFactoryTarget.Component });
DataTableRowComponent.ɵcmp = i0.ɵɵngDeclareComponent({ minVersion: "14.0.0", version: "14.2.0", type: DataTableRowComponent, selector: "d-data-table-row, [dDataTableRow]", inputs: { rowItem: "rowItem", selectable: "selectable", checkable: "checkable", showExpandToggle: "showExpandToggle", rowIndex: "rowIndex", allChecked: "allChecked", columns: "columns", editModel: "editModel", editRowItem: "editRowItem", resizeable: "resizeable", timeout: "timeout", tableLevel: "tableLevel", nestedIndex: "nestedIndex", generalRowHoveredData: "generalRowHoveredData" }, outputs: { detailChange: "detailChange" }, host: { properties: { "style.font-weight": "this.fontWeight", "style.vertical-align": "this.verticalAlign" } }, providers: [{
            provide: DATA_TABLE_ROW,
            useExisting: forwardRef(() => DataTableRowComponent)
        }], ngImport: i0, template: "<td *ngIf=\"showExpandToggle\" class=\"devui-detail-cell\" [ngClass]=\"{ 'devui-sticky-left-cell': columns[0]?.fixedLeft }\" [style.left]=\"0\">\n  <div *ngIf=\"rowItem.detail || rowItem?.$expandConfig\" (click)=\"toggle()\">\n    <span [style.vertical-align]=\"'middle'\" *ngIf=\"!rowItem['$isDetailOpen'] && !rowItem.$expandConfig?.expand\">\n      <svg\n        class=\"svg-icon-arrow\"\n        width=\"16px\"\n        height=\"16px\"\n        viewBox=\"0 0 16 16\"\n        version=\"1.1\"\n        xmlns=\"http://www.w3.org/2000/svg\"\n        xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n      >\n        <g stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\">\n          <polygon points=\"4.5 5 8 8.76923077 11.5 5 13 6.61538462 8 12 3 6.61538462\"></polygon>\n        </g>\n      </svg>\n    </span>\n    <span [style.vertical-align]=\"'middle'\" *ngIf=\"(rowItem && rowItem['$isDetailOpen']) || rowItem.$expandConfig?.expand\">\n      <svg\n        class=\"svg-icon-arrow\"\n        width=\"16px\"\n        height=\"16px\"\n        viewBox=\"0 0 16 16\"\n        version=\"1.1\"\n        xmlns=\"http://www.w3.org/2000/svg\"\n        xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n      >\n        <g stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\">\n          <polygon points=\"11.5 12 8 8.23076923 4.5 12 3 10.3846154 8 5 13 10.3846154\"></polygon>\n        </g>\n      </svg>\n    </span>\n  </div>\n</td>\n<td\n  *ngIf=\"checkable\"\n  class=\"devui-checkable-cell\"\n  [ngClass]=\"{ 'devui-sticky-left-cell': columns[0]?.fixedLeft }\"\n  [style.left]=\"showExpandToggle && columns[0]?.fixedLeft ? '36px' : '0'\"\n>\n  <d-checkbox\n    [ngModelOptions]=\"{ standalone: true }\"\n    (ngModelChange)=\"onRowCheckChange($event, rowIndex, nestedIndex, rowItem)\"\n    [ngModel]=\"rowItem.$checked\"\n    [halfchecked]=\"rowItem.$halfChecked\"\n    [disabled]=\"rowItem.$checkDisabled || rowItem.$disabled\"\n    dTooltip\n    [content]=\"rowItem.$checkBoxTips\"\n    [position]=\"['top', 'right', 'bottom', 'left']\"\n    [showAnimation]=\"false\"\n  >\n  </d-checkbox>\n</td>\n<ng-container *ngFor=\"let column of columns; let colIndex = index; trackBy: trackByFn\">\n  <td\n    dDataTableCell\n    [rowIndex]=\"rowIndex\"\n    [colIndex]=\"colIndex\"\n    [column]=\"column\"\n    [rowItem]=\"rowItem\"\n    [editModel]=\"rowItem.$$editModel || editModel\"\n    [isEditRow]=\"rowItem.$$edit\"\n    [timeout]=\"timeout\"\n    [tableLevel]=\"tableLevel\"\n    class=\"{{ column.cellClass ? column.cellClass : '' }}\"\n    [ngClass]=\"{\n      'devui-sticky-left-cell': column.fixedLeft,\n      'devui-sticky-right-cell': column.fixedRight,\n      'devui-last-sticky-left-cell': column.fixedLeft && !columns[colIndex + 1]?.fixedLeft,\n      'devui-first-sticky-right-cell': column.fixedRight && !columns[colIndex - 1]?.fixedRight\n    }\"\n    [style.left]=\"column.fixedLeft ? column.fixedLeft : null\"\n    [style.right]=\"column.fixedRight ? column.fixedRight : null\"\n  ></td>\n</ng-container>\n", styles: ["svg.svg-icon-arrow>g>polygon{fill:#71757f;fill:var(--devui-icon-text, #71757f)}:host ::ng-deep d-button button.d-btn.d-btn-icon{padding:0!important}:host ::ng-deep .cell-modify{position:absolute;right:0;cursor:pointer}:host ::ng-deep .cell-modify>svg{vertical-align:middle}:host ::ng-deep .cell-modify:hover>svg>g>g{fill:#71757f;fill:var(--devui-icon-text, #71757f)}:host ::ng-deep .cell-placeholder{display:inline-block;height:16px}:host ::ng-deep .cell-container{position:relative;height:24px}:host ::ng-deep .cell-container-inner{position:absolute;max-width:100%;width:100%}:host ::ng-deep .cell-container-inner.modify-holder{padding-right:20px}:host ::ng-deep .cell-container-inner.modify-holder .cell-modify{display:none;cursor:pointer;position:absolute;right:0}:host ::ng-deep .cell-container-inner.modify-holder .cell-modify>svg{vertical-align:middle}:host ::ng-deep .cell-container-inner.modify-holder .cell-modify>svg>g{fill:#71757f;fill:var(--devui-icon-text, #71757f)}:host ::ng-deep .cell-container-inner.modify-holder .cell-modify:hover>svg>g{fill:#252b3a;fill:var(--devui-icon-fill-active-hover, #252b3a)}:host ::ng-deep .cell-container-inner.modify-holder:hover .cell-modify{display:inline}:host ::ng-deep .not-break{white-space:nowrap;text-overflow:ellipsis;overflow:hidden;word-spacing:normal;word-wrap:normal}:host ::ng-deep .cell-editable{cursor:pointer;margin-left:-5px;padding-left:5px;min-height:20px}:host ::ng-deep .cell-editable:hover{background:#f2f2f3;background:var(--devui-list-item-hover-bg, #f2f2f3)}\n"], dependencies: [{ kind: "directive", type: i1.NgClass, selector: "[ngClass]", inputs: ["class", "ngClass"] }, { kind: "directive", type: i1.NgForOf, selector: "[ngFor][ngForOf]", inputs: ["ngForOf", "ngForTrackBy", "ngForTemplate"] }, { kind: "directive", type: i1.NgIf, selector: "[ngIf]", inputs: ["ngIf", "ngIfThen", "ngIfElse"] }, { kind: "directive", type: i2.NgControlStatus, selector: "[formControlName],[ngModel],[formControl]" }, { kind: "directive", type: i2.NgModel, selector: "[ngModel]:not([formControlName]):not([formControl])", inputs: ["name", "disabled", "ngModel", "ngModelOptions"], outputs: ["ngModelChange"], exportAs: ["ngModel"] }, { kind: "component", type: i3.CheckBoxComponent, selector: "d-checkbox", inputs: ["name", "label", "cssClass", "color", "disabled", "isShowTitle", "title", "labelTemplate", "halfchecked", "showAnimation", "beforeChange"], outputs: ["change"] }, { kind: "directive", type: i4.TooltipDirective, selector: "[dTooltip]", inputs: ["content", "position", "showAnimation", "showAnimate", "mouseEnterDelay", "mouseLeaveDelay"], exportAs: ["dTooltip"] }, { kind: "component", type: i5.DataTableCellComponent, selector: "d-data-table-cell,[dDataTableCell]", inputs: ["rowIndex", "colIndex", "column", "rowItem", "editModel", "isEditRow", "timeout", "tableLevel"] }] });
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "14.2.0", ngImport: i0, type: DataTableRowComponent, decorators: [{
            type: Component,
            args: [{ selector: 'd-data-table-row, [dDataTableRow]', preserveWhitespaces: false, providers: [{
                            provide: DATA_TABLE_ROW,
                            useExisting: forwardRef(() => DataTableRowComponent)
                        }], template: "<td *ngIf=\"showExpandToggle\" class=\"devui-detail-cell\" [ngClass]=\"{ 'devui-sticky-left-cell': columns[0]?.fixedLeft }\" [style.left]=\"0\">\n  <div *ngIf=\"rowItem.detail || rowItem?.$expandConfig\" (click)=\"toggle()\">\n    <span [style.vertical-align]=\"'middle'\" *ngIf=\"!rowItem['$isDetailOpen'] && !rowItem.$expandConfig?.expand\">\n      <svg\n        class=\"svg-icon-arrow\"\n        width=\"16px\"\n        height=\"16px\"\n        viewBox=\"0 0 16 16\"\n        version=\"1.1\"\n        xmlns=\"http://www.w3.org/2000/svg\"\n        xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n      >\n        <g stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\">\n          <polygon points=\"4.5 5 8 8.76923077 11.5 5 13 6.61538462 8 12 3 6.61538462\"></polygon>\n        </g>\n      </svg>\n    </span>\n    <span [style.vertical-align]=\"'middle'\" *ngIf=\"(rowItem && rowItem['$isDetailOpen']) || rowItem.$expandConfig?.expand\">\n      <svg\n        class=\"svg-icon-arrow\"\n        width=\"16px\"\n        height=\"16px\"\n        viewBox=\"0 0 16 16\"\n        version=\"1.1\"\n        xmlns=\"http://www.w3.org/2000/svg\"\n        xmlns:xlink=\"http://www.w3.org/1999/xlink\"\n      >\n        <g stroke=\"none\" stroke-width=\"1\" fill=\"none\" fill-rule=\"evenodd\">\n          <polygon points=\"11.5 12 8 8.23076923 4.5 12 3 10.3846154 8 5 13 10.3846154\"></polygon>\n        </g>\n      </svg>\n    </span>\n  </div>\n</td>\n<td\n  *ngIf=\"checkable\"\n  class=\"devui-checkable-cell\"\n  [ngClass]=\"{ 'devui-sticky-left-cell': columns[0]?.fixedLeft }\"\n  [style.left]=\"showExpandToggle && columns[0]?.fixedLeft ? '36px' : '0'\"\n>\n  <d-checkbox\n    [ngModelOptions]=\"{ standalone: true }\"\n    (ngModelChange)=\"onRowCheckChange($event, rowIndex, nestedIndex, rowItem)\"\n    [ngModel]=\"rowItem.$checked\"\n    [halfchecked]=\"rowItem.$halfChecked\"\n    [disabled]=\"rowItem.$checkDisabled || rowItem.$disabled\"\n    dTooltip\n    [content]=\"rowItem.$checkBoxTips\"\n    [position]=\"['top', 'right', 'bottom', 'left']\"\n    [showAnimation]=\"false\"\n  >\n  </d-checkbox>\n</td>\n<ng-container *ngFor=\"let column of columns; let colIndex = index; trackBy: trackByFn\">\n  <td\n    dDataTableCell\n    [rowIndex]=\"rowIndex\"\n    [colIndex]=\"colIndex\"\n    [column]=\"column\"\n    [rowItem]=\"rowItem\"\n    [editModel]=\"rowItem.$$editModel || editModel\"\n    [isEditRow]=\"rowItem.$$edit\"\n    [timeout]=\"timeout\"\n    [tableLevel]=\"tableLevel\"\n    class=\"{{ column.cellClass ? column.cellClass : '' }}\"\n    [ngClass]=\"{\n      'devui-sticky-left-cell': column.fixedLeft,\n      'devui-sticky-right-cell': column.fixedRight,\n      'devui-last-sticky-left-cell': column.fixedLeft && !columns[colIndex + 1]?.fixedLeft,\n      'devui-first-sticky-right-cell': column.fixedRight && !columns[colIndex - 1]?.fixedRight\n    }\"\n    [style.left]=\"column.fixedLeft ? column.fixedLeft : null\"\n    [style.right]=\"column.fixedRight ? column.fixedRight : null\"\n  ></td>\n</ng-container>\n", styles: ["svg.svg-icon-arrow>g>polygon{fill:#71757f;fill:var(--devui-icon-text, #71757f)}:host ::ng-deep d-button button.d-btn.d-btn-icon{padding:0!important}:host ::ng-deep .cell-modify{position:absolute;right:0;cursor:pointer}:host ::ng-deep .cell-modify>svg{vertical-align:middle}:host ::ng-deep .cell-modify:hover>svg>g>g{fill:#71757f;fill:var(--devui-icon-text, #71757f)}:host ::ng-deep .cell-placeholder{display:inline-block;height:16px}:host ::ng-deep .cell-container{position:relative;height:24px}:host ::ng-deep .cell-container-inner{position:absolute;max-width:100%;width:100%}:host ::ng-deep .cell-container-inner.modify-holder{padding-right:20px}:host ::ng-deep .cell-container-inner.modify-holder .cell-modify{display:none;cursor:pointer;position:absolute;right:0}:host ::ng-deep .cell-container-inner.modify-holder .cell-modify>svg{vertical-align:middle}:host ::ng-deep .cell-container-inner.modify-holder .cell-modify>svg>g{fill:#71757f;fill:var(--devui-icon-text, #71757f)}:host ::ng-deep .cell-container-inner.modify-holder .cell-modify:hover>svg>g{fill:#252b3a;fill:var(--devui-icon-fill-active-hover, #252b3a)}:host ::ng-deep .cell-container-inner.modify-holder:hover .cell-modify{display:inline}:host ::ng-deep .not-break{white-space:nowrap;text-overflow:ellipsis;overflow:hidden;word-spacing:normal;word-wrap:normal}:host ::ng-deep .cell-editable{cursor:pointer;margin-left:-5px;padding-left:5px;min-height:20px}:host ::ng-deep .cell-editable:hover{background:#f2f2f3;background:var(--devui-list-item-hover-bg, #f2f2f3)}\n"] }]
        }], ctorParameters: function () { return [{ type: undefined, decorators: [{
                    type: Inject,
                    args: [DATA_TABLE]
                }] }, { type: i0.ChangeDetectorRef }, { type: i0.ElementRef }, { type: i0.NgZone }]; }, propDecorators: { rowItem: [{
                type: Input
            }], fontWeight: [{
                type: HostBinding,
                args: ['style.font-weight']
            }], verticalAlign: [{
                type: HostBinding,
                args: ['style.vertical-align']
            }], selectable: [{
                type: Input
            }], checkable: [{
                type: Input
            }], showExpandToggle: [{
                type: Input
            }], rowIndex: [{
                type: Input
            }], allChecked: [{
                type: Input
            }], columns: [{
                type: Input
            }], editModel: [{
                type: Input
            }], editRowItem: [{
                type: Input
            }], resizeable: [{
                type: Input
            }], timeout: [{
                type: Input
            }], tableLevel: [{
                type: Input
            }], nestedIndex: [{
                type: Input
            }], generalRowHoveredData: [{
                type: Input
            }], detailChange: [{
                type: Output
            }] } });
//# sourceMappingURL=data:application/json;base64, 