import { h } from "@stencil/core";
export class DgaAccordion {
    constructor() {
        this.title = '';
        this.content = '';
        this.size = 'lg';
        this.iconAlignment = 'Trailing';
        this.flush = false;
        this.disabled = false;
        this.defaultExpanded = false;
        this.extraClass = '';
        this.isOpen = false;
        this.bodyElement = null;
    }
    handleAccordionClick(e) {
        e.preventDefault();
        if (this.disabled)
            return;
        this.isOpen ? this.collapseAccordion() : this.openAccordion();
    }
    openAccordion() {
        this.isOpen = true;
        if (this.bodyElement) {
            this.bodyElement.style.maxHeight = this.bodyElement.scrollHeight + 'px';
        }
    }
    collapseAccordion() {
        this.isOpen = false;
        if (this.bodyElement) {
            this.bodyElement.style.maxHeight = null;
        }
    }
    componentDidRender() {
        if (this.isOpen && this.bodyElement) {
            this.bodyElement.style.maxHeight = this.bodyElement.scrollHeight + 24 + 'px';
        }
        else if (this.bodyElement) {
            this.bodyElement.style.maxHeight = null;
        }
        if (this.defaultExpanded) {
            this.isOpen = this.defaultExpanded;
        }
    }
    render() {
        return (h("div", { key: 'ac5e87360549e69caf8c474ffed12214a8cd5990', class: `dga-accordion-item dga-accordion-item--${this.size} 
          ${this.iconAlignment === 'Leading' ? 'dga-accordion-item--icon-leading' : ''}
          ${this.flush ? 'dga-accordion-item--flush' : ''} 
          ${this.disabled ? 'disabled' : ''} ${this.extraClass} ${this.isOpen ? 'active' : ''}` }, h("a", { key: '51bffeaa74562b96a3b0847e10b84b5fdf030fe6', href: "#", onClick: e => this.handleAccordionClick(e), onKeyDown: e => (e.code === 'Space' ? this.handleAccordionClick(e) : null), class: "dga-accordion-item__header" }, this.iconAlignment === 'Leading' && (h("div", { key: '887c9f7359529b3b549962a389955a8bb22f9256', class: "dga-accordion-item__arrow" }, h("i", { key: '6fccc9fa75ad4484f63342f0d3c69e0d584f7895', class: "hgi-stroke hgi-arrow-down-01", style: { fontSize: '16px' } }))), h("div", { key: '5a76539262426c22e4af8439c652c89a10dadde9', class: "dga-accordion-item__title" }, this.title), this.iconAlignment === 'Trailing' && (h("div", { key: 'fc28eb3d4f46e4fe6964d2b5bae815a7b455a638', class: "dga-accordion-item__arrow" }, h("i", { key: 'beac26f4f872b58f4aa2406debd459e0e0bd7a6f', class: "hgi-stroke hgi-arrow-down-01", style: { fontSize: '16px' } })))), h("div", { key: '5f28b0c24da507d731f2bc7fdbc66b3723f856e1', ref: el => (this.bodyElement = el), class: "dga-accordion-item__body" }, this.content)));
    }
    static get is() { return "dga-accordion"; }
    static get encapsulation() { return "shadow"; }
    static get originalStyleUrls() {
        return {
            "$": ["dga-accordion.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["dga-accordion.css"]
        };
    }
    static get properties() {
        return {
            "title": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "attribute": "title",
                "reflect": false,
                "defaultValue": "''"
            },
            "content": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "attribute": "content",
                "reflect": false,
                "defaultValue": "''"
            },
            "size": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "'lg' | 'md' | 'sm'",
                    "resolved": "\"lg\" | \"md\" | \"sm\"",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "attribute": "size",
                "reflect": false,
                "defaultValue": "'lg'"
            },
            "iconAlignment": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "'Leading' | 'Trailing'",
                    "resolved": "\"Leading\" | \"Trailing\"",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "attribute": "icon-alignment",
                "reflect": false,
                "defaultValue": "'Trailing'"
            },
            "flush": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "attribute": "flush",
                "reflect": false,
                "defaultValue": "false"
            },
            "disabled": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "attribute": "disabled",
                "reflect": false,
                "defaultValue": "false"
            },
            "defaultExpanded": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "attribute": "default-expanded",
                "reflect": false,
                "defaultValue": "false"
            },
            "extraClass": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "attribute": "extra-class",
                "reflect": false,
                "defaultValue": "''"
            }
        };
    }
    static get states() {
        return {
            "isOpen": {}
        };
    }
    static get elementRef() { return "el"; }
}
//# sourceMappingURL=dga-accordion.js.map
