import { h } from "@stencil/core";
import { trackComponent } from "../../global/utils/tracking";
import { isNestedInIfxComponent } from "../../global/utils/dom-utils";
import { detectFramework } from "../../global/utils/framework-detection";
export class TreeView {
    constructor() {
        this.disableAllItems = false;
        this.expandAllItems = false;
        this.handleSlotRef = (el) => {
            if (el) {
                if (this.disableAllItems) {
                    el.setAttribute('data-disable-all-items', 'true');
                }
                else {
                    el.removeAttribute('data-disable-all-items');
                }
                if (this.expandAllItems) {
                    el.setAttribute('data-expand-all-items', 'true');
                }
                else {
                    el.removeAttribute('data-expand-all-items');
                }
            }
        };
    }
    handleExpandAllItemsChange(newValue) {
        this.ifxTreeViewExpandAllChange.emit(newValue);
    }
    handleDisableAllItemsChange(newValue) {
        this.ifxTreeViewDisableAllChange.emit(newValue);
    }
    async componentDidLoad() {
        if (!isNestedInIfxComponent(this.el)) {
            const framework = detectFramework();
            trackComponent('ifx-tree-view', await framework);
        }
    }
    render() {
        return (h("div", { key: 'a169184b27839fcb6f960eeb4794d5928a00344b', class: `tree-view ${this.disableAllItems ? ' tree-view--disabled' : ''}`, role: "tree", "aria-label": this.ariaLabel }, this.label && this.label.trim() !== '' && h("div", { key: 'ba814b0b23bf8126f84e104f6b2a60a1de289b0b', class: "tree-view__label" }, this.label), h("slot", { key: 'e86880fa26b576d1dc023afa08fbbe5d06501bde', ref: this.handleSlotRef })));
    }
    static get is() { return "ifx-tree-view"; }
    static get encapsulation() { return "shadow"; }
    static get originalStyleUrls() {
        return {
            "$": ["tree-view.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["tree-view.css"]
        };
    }
    static get properties() {
        return {
            "label": {
                "type": "string",
                "attribute": "label",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false
            },
            "disableAllItems": {
                "type": "boolean",
                "attribute": "disable-all-items",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "defaultValue": "false"
            },
            "expandAllItems": {
                "type": "boolean",
                "attribute": "expand-all-items",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "defaultValue": "false"
            },
            "ariaLabel": {
                "type": "string",
                "attribute": "aria-label",
                "mutable": false,
                "complexType": {
                    "original": "string | null",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "getter": false,
                "setter": false,
                "reflect": false
            }
        };
    }
    static get events() {
        return [{
                "method": "ifxTreeViewExpandAllChange",
                "name": "ifxTreeViewExpandAllChange",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                }
            }, {
                "method": "ifxTreeViewDisableAllChange",
                "name": "ifxTreeViewDisableAllChange",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                }
            }];
    }
    static get elementRef() { return "el"; }
    static get watchers() {
        return [{
                "propName": "expandAllItems",
                "methodName": "handleExpandAllItemsChange"
            }, {
                "propName": "disableAllItems",
                "methodName": "handleDisableAllItemsChange"
            }];
    }
}
//# sourceMappingURL=tree-view.js.map
