import { h, } from "@stencil/core";
import { isNestedInIfxComponent } from "../..//shared/utils/dom-utils";
import { detectFramework } from "../..//shared/utils/framework-detection";
import { trackComponent } from "../../shared/utils/tracking";
export class TreeView {
    el;
    /** Optional label displayed for the tree view. */
    label;
    /** If true, disables all items in the tree view. */
    disableAllItems = false;
    /** If true, expands all items in the tree view. */
    expandAllItems = false;
    /** Accessible label for the tree view container. */
    ariaLabelText;
    /** Fired when the “expand all items” state changes. */
    ifxTreeViewExpandAllChange;
    /** Fired when the “disable all items” state changes. */
    ifxTreeViewDisableAllChange;
    handleExpandAllItemsChange(newValue) {
        this.ifxTreeViewExpandAllChange.emit(newValue);
    }
    handleDisableAllItemsChange(newValue) {
        this.ifxTreeViewDisableAllChange.emit(newValue);
    }
    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");
            }
        }
    };
    async componentDidLoad() {
        if (!isNestedInIfxComponent(this.el)) {
            const framework = detectFramework();
            trackComponent("ifx-tree-view", await framework);
        }
    }
    render() {
        return (h("div", { key: 'd5930a9e3d87902a0d03d7ce0912c1a3a4ae6172', class: `tree-view ${this.disableAllItems ? " tree-view--disabled" : ""}`, role: "tree", "aria-label": this.ariaLabelText }, this.label && this.label.trim() !== "" && (h("div", { key: 'b504f190ecad24579c98a2e188e8162d43e2bf0c', class: "tree-view__label" }, this.label)), h("slot", { key: '9dd1005f627e2669c797087aa1047fbd7a560213', 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",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Optional label displayed for the tree view."
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "label"
            },
            "disableAllItems": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "If true, disables all items in the tree view."
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "disable-all-items",
                "defaultValue": "false"
            },
            "expandAllItems": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "If true, expands all items in the tree view."
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "expand-all-items",
                "defaultValue": "false"
            },
            "ariaLabelText": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string | null",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Accessible label for the tree view container."
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "aria-label-text"
            }
        };
    }
    static get events() {
        return [{
                "method": "ifxTreeViewExpandAllChange",
                "name": "ifxTreeViewExpandAllChange",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [],
                    "text": "Fired when the \u201Cexpand all items\u201D state changes."
                },
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                }
            }, {
                "method": "ifxTreeViewDisableAllChange",
                "name": "ifxTreeViewDisableAllChange",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [],
                    "text": "Fired when the \u201Cdisable all items\u201D state changes."
                },
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                }
            }];
    }
    static get elementRef() { return "el"; }
    static get watchers() {
        return [{
                "propName": "expandAllItems",
                "methodName": "handleExpandAllItemsChange"
            }, {
                "propName": "disableAllItems",
                "methodName": "handleDisableAllItemsChange"
            }];
    }
}
