import { __decorate, __extends } from "tslib";
import { ChangeDetectionStrategy, Component, HostBinding, forwardRef, ElementRef, ViewChildren, ViewChild, TemplateRef } from '@angular/core';
import { IgxRowDirective } from '../row.directive';
import { IgxHierarchicalGridCellComponent } from './hierarchical-cell.component';
var IgxHierarchicalRowComponent = /** @class */ (function (_super) {
    __extends(IgxHierarchicalRowComponent, _super);
    function IgxHierarchicalRowComponent() {
        var _this = _super !== null && _super.apply(this, arguments) || this;
        /**
         * @hidden
         */
        _this.tabindex = 0;
        /**
         * @hidden
         * @internal
         */
        _this.select = function () {
            _this.grid.selectRows([_this.rowID]);
        };
        /**
         * @hidden
         * @internal
         */
        _this.deselect = function () {
            _this.grid.deselectRows([_this.rowID]);
        };
        return _this;
    }
    IgxHierarchicalRowComponent_1 = IgxHierarchicalRowComponent;
    Object.defineProperty(IgxHierarchicalRowComponent.prototype, "viewIndex", {
        get: function () {
            return this.index + this.grid.page * this.grid.perPage;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(IgxHierarchicalRowComponent.prototype, "expanded", {
        /**
     * Returns whether the row is expanded.
     * ```typescript
     * const RowExpanded = this.grid1.rowList.first.expanded;
     * ```
     */
        get: function () {
            return this.gridAPI.get_row_expansion_state(this.rowData);
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(IgxHierarchicalRowComponent.prototype, "hasChildren", {
        get: function () {
            return !!this.grid.childLayoutKeys.length;
        },
        enumerable: true,
        configurable: true
    });
    Object.defineProperty(IgxHierarchicalRowComponent.prototype, "highlighted", {
        /**
         * @hidden
         */
        get: function () {
            return this.grid && this.grid.highlightedRowID === this.rowID;
        },
        enumerable: true,
        configurable: true
    });
    /**
    * @hidden
    */
    IgxHierarchicalRowComponent.prototype.expanderClick = function (event) {
        event.stopPropagation();
        this.toggle();
    };
    /**
     * Toggles the hierarchical row.
     * ```typescript
     * this.grid1.rowList.first.toggle()
     * ```
     */
    IgxHierarchicalRowComponent.prototype.toggle = function () {
        if (this.added) {
            return;
        }
        var grid = this.gridAPI.grid;
        this.endEdit(grid.rootGrid);
        this.gridAPI.set_row_expansion_state(this.rowID, !this.expanded);
        grid.cdr.detectChanges();
    };
    Object.defineProperty(IgxHierarchicalRowComponent.prototype, "iconTemplate", {
        /**
        * @hidden
        */
        get: function () {
            var expandable = true;
            if (this.grid.hasChildrenKey) {
                expandable = this.rowData[this.grid.hasChildrenKey];
            }
            if (!expandable) {
                return this.defaultEmptyTemplate;
            }
            if (this.expanded) {
                return this.grid.rowExpandedIndicatorTemplate || this.defaultExpandedTemplate;
            }
            else {
                return this.grid.rowCollapsedIndicatorTemplate || this.defaultCollapsedTemplate;
            }
        },
        enumerable: true,
        configurable: true
    });
    IgxHierarchicalRowComponent.prototype.endEdit = function (grid) {
        if (grid.crudService.inEditMode) {
            grid.endEdit();
        }
        grid.hgridAPI.getChildGrids(true).forEach(function (g) {
            if (g.crudService.inEditMode) {
                g.endEdit();
            }
        });
    };
    var IgxHierarchicalRowComponent_1;
    __decorate([
        ViewChildren(forwardRef(function () { return IgxHierarchicalGridCellComponent; }), { read: IgxHierarchicalGridCellComponent })
    ], IgxHierarchicalRowComponent.prototype, "cells", void 0);
    __decorate([
        ViewChild('expander', { read: ElementRef })
    ], IgxHierarchicalRowComponent.prototype, "expander", void 0);
    __decorate([
        ViewChild('defaultExpandedTemplate', { read: TemplateRef, static: true })
    ], IgxHierarchicalRowComponent.prototype, "defaultExpandedTemplate", void 0);
    __decorate([
        ViewChild('defaultEmptyTemplate', { read: TemplateRef, static: true })
    ], IgxHierarchicalRowComponent.prototype, "defaultEmptyTemplate", void 0);
    __decorate([
        ViewChild('defaultCollapsedTemplate', { read: TemplateRef, static: true })
    ], IgxHierarchicalRowComponent.prototype, "defaultCollapsedTemplate", void 0);
    __decorate([
        HostBinding('attr.tabindex')
    ], IgxHierarchicalRowComponent.prototype, "tabindex", void 0);
    __decorate([
        HostBinding('class.igx-grid__tr--expanded')
    ], IgxHierarchicalRowComponent.prototype, "expanded", null);
    __decorate([
        HostBinding('class.igx-grid__tr--highlighted')
    ], IgxHierarchicalRowComponent.prototype, "highlighted", null);
    IgxHierarchicalRowComponent = IgxHierarchicalRowComponent_1 = __decorate([
        Component({
            changeDetection: ChangeDetectionStrategy.OnPush,
            preserveWhitespaces: false,
            selector: 'igx-hierarchical-grid-row',
            template: "<div (click)=\"expanderClick($event)\" class=\"igx-grid__hierarchical-expander\" [tabIndex]=\"tabindex\" *ngIf=\"hasChildren\" #expander>\n        <ng-container *ngTemplateOutlet=\"iconTemplate; context: { $implicit: this }\">\n        </ng-container>\n</div>\n<ng-template #defaultExpandedTemplate>\n        <igx-icon [isActive]='!added' fontSet=\"material\">expand_more</igx-icon>\n    </ng-template>\n\n<ng-template #defaultCollapsedTemplate>\n        <igx-icon [isActive]='!added' fontSet=\"material\">chevron_right</igx-icon>\n </ng-template>\n\n <ng-template #defaultEmptyTemplate>\n    <igx-icon fontSet=\"material\"></igx-icon>\n</ng-template>\n\n<ng-container *ngIf=\"rowDraggable\">\n    <div [class]=\"resolveDragIndicatorClasses\" [igxRowDrag]=\"this\" (click)=\"$event.stopPropagation()\" [ghostTemplate]=\"this.grid.getDragGhostCustomTemplate()\">\n            <ng-container *ngTemplateOutlet=\"this.grid.dragIndicatorIconTemplate ? this.grid.dragIndicatorIconTemplate : this.grid.dragIndicatorIconBase\"></ng-container>\n    </div>\n</ng-container>\n<ng-container *ngIf=\"showRowSelectors\">\n    <div class=\"igx-grid__cbx-selection\" (click)=\"onRowSelectorClick($event)\">\n        <ng-template *ngTemplateOutlet=\"\n            this.grid.rowSelectorTemplate ? this.grid.rowSelectorTemplate : rowSelectorBaseTemplate;\n            context: { $implicit: {\n                            index: viewIndex,\n                            rowID: rowID,\n                            selected: selected,\n                            select: select,\n                            deselect: deselect }}\">\n        </ng-template>\n    </div>\n</ng-container>\n\n<ng-container *ngIf=\"pinnedColumns.length > 0\">\n    <igx-hierarchical-grid-cell *ngFor=\"let col of pinnedColumns | igxNotGrouped\"\n        class=\"igx-grid__td igx-grid__td--fw igx-grid__td--pinned\"\n        [class.igx-grid__td--number]=\"col.dataType === 'number'\"\n        [ngClass]=\"col.cellClasses | igxCellStyleClasses:rowData[col.field]:rowData:col.field:viewIndex\"\n        [ngStyle]=\"col.cellStyles | igxCellStyles:rowData[col.field]:rowData:col.field:viewIndex\"\n        [editMode]=\"col.editable && crudService.isInEditMode(index, col.index)\"\n        [column]=\"col\"\n        [formatter]=\"col.formatter\"\n        [row]=\"this\"\n        [lastPinned]=\"col.isLastPinned\"\n        [style.min-height.px]=\"grid.rowHeight || 32\"\n        [rowData]=\"rowData\"\n        [style.min-width]=\"col.width\"\n        [style.max-width]=\"col.width\"\n        [style.flex-basis]=\"col.width\"\n        [width]=\"col.getCellWidth()\"\n        [visibleColumnIndex]=\"col.visibleIndex\"\n        [value]=\"rowData[col.field]\"\n        [cellTemplate]=\"col.bodyTemplate\"\n        [lastSearchInfo]=\"grid.lastSearchInfo\"\n        [cellSelectionMode]=\"grid.cellSelection\">\n    </igx-hierarchical-grid-cell>\n</ng-container>\n\n<ng-template igxGridFor let-col [igxGridForOf]=\"unpinnedColumns | igxNotGrouped\" [igxForScrollContainer]=\"grid.parentVirtDir\" let-colIndex=\"index\" [igxForSizePropName]='\"calcPixelWidth\"' [igxForScrollOrientation]=\"'horizontal'\" [igxForContainerSize]='grid.unpinnedWidth' [igxForTrackBy]='grid.trackColumnChanges' #igxDirRef>\n    <igx-hierarchical-grid-cell\n        class=\"igx-grid__td igx-grid__td--fw\"\n        [class.igx-grid__td--number]=\"col.dataType === 'number'\"\n        [ngClass]=\"col.cellClasses | igxCellStyleClasses:rowData[col.field]:rowData:col.field:viewIndex\"\n        [ngStyle]=\"col.cellStyles | igxCellStyles:rowData[col.field]:rowData:col.field:viewIndex\"\n        [editMode]=\"col.editable && crudService.isInEditMode(index, col.index)\"\n        [column]=\"col\"\n        [formatter]=\"col.formatter\"\n        [row]=\"this\"\n        [style.min-height.px]=\"grid.rowHeight || 32\"\n        [rowData]=\"rowData\"\n        [style.min-width]=\"col.width\"\n        [style.max-width]=\"col.width\"\n        [style.flex-basis]=\"col.width\"\n        [width]=\"col.getCellWidth()\"\n        [visibleColumnIndex]=\"col.visibleIndex\"\n        [value]=\"rowData[col.field]\"\n        [cellTemplate]=\"col.bodyTemplate\"\n        [lastSearchInfo]=\"grid.lastSearchInfo\"\n        [cellSelectionMode]=\"grid.cellSelection\">\n    </igx-hierarchical-grid-cell>\n</ng-template>\n\n<ng-template #rowSelectorBaseTemplate>\n    <div class=\"igx-grid__cbx-padding\">\n        <igx-checkbox\n            [readonly]=\"true\"\n            [checked]=\"selected\"\n            disableRipple=\"true\"\n            [disabled]=\"deleted\"\n            [disableTransitions]=\"grid.disableTransitions\"\n            [aria-label]=\"rowCheckboxAriaLabel\">\n        </igx-checkbox>\n    </div>\n</ng-template>\n",
            providers: [{ provide: IgxRowDirective, useExisting: forwardRef(function () { return IgxHierarchicalRowComponent_1; }) }]
        })
    ], IgxHierarchicalRowComponent);
    return IgxHierarchicalRowComponent;
}(IgxRowDirective));
export { IgxHierarchicalRowComponent };
//# sourceMappingURL=data:application/json;base64, 