import { __decorate, __extends } from "tslib";
import Vue from 'vue';
import Component from 'vue-class-component';
import { Emit, Prop } from 'vue-property-decorator';
import { Enums } from '../../../utils/enums/enums';
import { getTotalColumnsLength, MTableGroupHeaderStyle } from '../responsive-table-commons';
var MTableGroupMixin = /** @class */ (function (_super) {
    __extends(MTableGroupMixin, _super);
    function MTableGroupMixin() {
        return _super !== null && _super.apply(this, arguments) || this;
    }
    MTableGroupMixin.prototype.emitOpenAccordion = function (rowsGroup) { };
    MTableGroupMixin.prototype.emitCloseAccordion = function (rowsGroup) { };
    Object.defineProperty(MTableGroupMixin.prototype, "hasHeader", {
        get: function () {
            return Boolean(this.rowsGroup.header && Object.keys(this.rowsGroup.header).length);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MTableGroupMixin.prototype, "hasHeaderTitle", {
        get: function () {
            return this.hasHeader && Boolean(this.rowsGroup.header.title);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MTableGroupMixin.prototype, "hasHeaderWithoutCell", {
        get: function () {
            return this.hasHeader && !this.hasHeaderCell;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MTableGroupMixin.prototype, "hasHeaderCell", {
        get: function () {
            return Boolean(this.hasHeader &&
                this.rowsGroup.header.cells &&
                Object.keys(this.rowsGroup.header.cells).length);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MTableGroupMixin.prototype, "hasEmptyArea", {
        get: function () {
            return Boolean(this.rowsGroup.emptyArea &&
                Object.keys(this.rowsGroup.emptyArea).length);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MTableGroupMixin.prototype, "hasRows", {
        get: function () {
            return Boolean(this.rowsGroup.rows && this.rowsGroup.rows.length);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MTableGroupMixin.prototype, "hasRowsOrEmptyArea", {
        get: function () {
            return Boolean(this.hasRows || this.hasDefaultEmptyArea || this.hasEmptyArea);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MTableGroupMixin.prototype, "hasDefaultEmptyArea", {
        get: function () {
            return Boolean(this.defaultEmptyArea && Object.keys(this.defaultEmptyArea).length);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MTableGroupMixin.prototype, "emptyArea", {
        get: function () {
            if (this.hasEmptyArea) {
                return this.rowsGroup.emptyArea;
            }
            else if (this.hasDefaultEmptyArea) {
                return this.defaultEmptyArea;
            }
            return {};
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MTableGroupMixin.prototype, "hasAccordion", {
        get: function () {
            return Boolean(this.rowsGroup.accordion);
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MTableGroupMixin.prototype, "isAccordionDisabled", {
        get: function () {
            return (this.hasAccordion &&
                Boolean(this.rowsGroup.accordion.disabled));
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MTableGroupMixin.prototype, "isAccordionOpen", {
        get: function () {
            return this.hasAccordion && this.rowsGroup.accordion.open;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MTableGroupMixin.prototype, "hasRowContent", {
        get: function () {
            return this.hasAccordion
                ? this.isAccordionOpen && this.hasRowsOrEmptyArea
                : this.hasRowsOrEmptyArea;
        },
        enumerable: false,
        configurable: true
    });
    Object.defineProperty(MTableGroupMixin.prototype, "totalColumnsLength", {
        get: function () {
            return getTotalColumnsLength(this.columns);
        },
        enumerable: false,
        configurable: true
    });
    __decorate([
        Prop({
            required: true
        })
    ], MTableGroupMixin.prototype, "columns", void 0);
    __decorate([
        Prop({
            required: true
        })
    ], MTableGroupMixin.prototype, "rowsGroup", void 0);
    __decorate([
        Prop({
            default: false
        })
    ], MTableGroupMixin.prototype, "firstColumnFixed", void 0);
    __decorate([
        Prop()
    ], MTableGroupMixin.prototype, "defaultEmptyArea", void 0);
    __decorate([
        Prop({
            default: MTableGroupHeaderStyle.Light,
            validator: function (value) {
                return Enums.toValueArray(MTableGroupHeaderStyle).includes(value);
            }
        })
    ], MTableGroupMixin.prototype, "groupHeaderStyle", void 0);
    __decorate([
        Prop()
    ], MTableGroupMixin.prototype, "groupHeaderClassName", void 0);
    __decorate([
        Emit('open-accordion')
    ], MTableGroupMixin.prototype, "emitOpenAccordion", null);
    __decorate([
        Emit('close-accordion')
    ], MTableGroupMixin.prototype, "emitCloseAccordion", null);
    MTableGroupMixin = __decorate([
        Component
    ], MTableGroupMixin);
    return MTableGroupMixin;
}(Vue));
export { MTableGroupMixin };
//# sourceMappingURL=table-group-mixin.js.map