import { h } from "@stencil/core";
export class DgaTable {
    constructor() {
        this.data = [
            {
                selected: true,
            },
            {
                selected: true,
            },
        ];
        this.rowDivider = true;
        this.showSelectCheckBox = true;
        this.alternate = true;
        this.cells = [
            {
                propertyName: 'test',
                isFilter: false,
                isSort: false,
                title: 'Test',
                type: 'propertyName',
                colSpan: 1,
            },
            {
                propertyName: 'test',
                isFilter: false,
                isSort: false,
                title: 'Test',
                type: 'propertyName',
                colSpan: 1,
            },
        ];
        this.contained = true;
        this.sortedData = [];
        this.direction = false;
    }
    // private sortData = (sortType: 'up' | 'down' = 'up', sortingProperty: string, index: number) => {
    //   if (sortType === 'up') {
    //     const clonedData = [...this.data.sort((a, b) => (b[sortingProperty] > a[sortingProperty] ? 1 : a[sortingProperty] > b[sortingProperty] ? -1 : 0))];
    //     this.sortedData = clonedData;
    //   } else if (sortType === 'down') {
    //     const clonedData = [...this.data.sort((a, b) => (a[sortingProperty] > b[sortingProperty] ? 1 : b[sortingProperty] > a[sortingProperty] ? -1 : 0))];
    //     this.sortedData = clonedData;
    //   }
    //   this.cells[index].sort = sortType == 'down' ? 'up' : 'down';
    // };
    // private handleSelectedRowChanges = (checked: boolean, index: number) => {
    //   const cloneData = [...this.data];
    //   cloneData[index].selected = checked;
    //   this.sortedData = cloneData;
    //   if (this.getSelectedRows) {
    //     this.getSelectedRows({
    //       selectedRows: cloneData.filter(item => item.selected),
    //       currentSelectedRow: cloneData[index],
    //       currentSelectedRowIndex: index,
    //     });
    //   }
    // };
    // private selectAll = (checked: boolean) => {
    //   const cloneData = [...this.data];
    //   cloneData.forEach(item => (item.selected = checked));
    //   this.sortedData = cloneData;
    //   if (this.getSelectedRows) {
    //     this.getSelectedRows({
    //       selectedRows: cloneData,
    //     });
    //   }
    // };
    componentDidLoad() {
        if (document.dir) {
            if (document.dir === 'rtl')
                this.direction = true;
            else
                this.direction = false;
        }
        else if (document.documentElement.lang) {
            if (document.documentElement.lang === 'ar')
                this.direction = true;
            else
                this.direction = false;
        }
        else
            this.direction = false;
    }
    componentDidUpdate() {
        const cloneData = [
            ...this.data.map(item => {
                item.selected = false;
                return item;
            }),
        ];
        this.sortedData = cloneData;
    }
    render() {
        return (h("div", { key: 'a0d626ebc73490042c4b1c84439f084f674d51ae', class: `table-wrapper ${this.contained ? 'table-contained' : ''}` }, h("table", { key: '733fac20242b538d5e1a14a7cfee10be8eac8816', class: ` azm-table ${this.contained ? 'table-contained' : ''}`, style: { direction: this.direction ? 'rtl' : 'ltr' } }, h("slot", { key: '0bb9672ea940070efa55e66cd0d50b993b645051' }))));
    }
    static get is() { return "dga-table"; }
    static get properties() {
        return {
            "data": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "{ selected: boolean; }[]",
                    "resolved": "{ selected: boolean; }[]",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "defaultValue": "[\n    {\n      selected: true,\n    },\n    {\n      selected: true,\n    },\n  ]"
            },
            "rowDivider": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "attribute": "row-divider",
                "reflect": false,
                "defaultValue": "true"
            },
            "showSelectCheckBox": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "attribute": "show-select-check-box",
                "reflect": false,
                "defaultValue": "true"
            },
            "alternate": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "attribute": "alternate",
                "reflect": false,
                "defaultValue": "true"
            },
            "cells": {
                "type": "unknown",
                "mutable": false,
                "complexType": {
                    "original": "{\n    title: string;\n    isSort: boolean;\n    isFilter: boolean;\n    sort?: 'up' | 'down';\n    propertyName: string;\n    type: 'element' | 'propertyName';\n    El?: HTMLElement;\n    elProperties?: string[];\n    colSpan?: number;\n    // elProperties: { [key: string]: any };\n  }[]",
                    "resolved": "{ title: string; isSort: boolean; isFilter: boolean; sort?: \"up\" | \"down\"; propertyName: string; type: \"element\" | \"propertyName\"; El?: HTMLElement; elProperties?: string[]; colSpan?: number; }[]",
                    "references": {
                        "HTMLElement": {
                            "location": "global",
                            "id": "global::HTMLElement"
                        }
                    }
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "defaultValue": "[\n    {\n      propertyName: 'test',\n      isFilter: false,\n      isSort: false,\n      title: 'Test',\n      type: 'propertyName',\n      colSpan: 1,\n    },\n    {\n      propertyName: 'test',\n      isFilter: false,\n      isSort: false,\n      title: 'Test',\n      type: 'propertyName',\n      colSpan: 1,\n    },\n  ]"
            },
            "contained": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "attribute": "contained",
                "reflect": false,
                "defaultValue": "true"
            },
            "getSelectedRows": {
                "type": "any",
                "mutable": false,
                "complexType": {
                    "original": "any",
                    "resolved": "any",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "attribute": "get-selected-rows",
                "reflect": false
            },
            "pressOnFilter": {
                "type": "any",
                "mutable": false,
                "complexType": {
                    "original": "any",
                    "resolved": "any",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "attribute": "press-on-filter",
                "reflect": false
            }
        };
    }
    static get states() {
        return {
            "sortedData": {},
            "direction": {}
        };
    }
}
//# sourceMappingURL=dga-table.js.map
