import { Host, h } from "@stencil/core";
import { cls, isEmpty } from "../../utils/helpers";
export class XDatatableFilterItem {
    constructor() {
        this.value = undefined;
        this.selected = undefined;
    }
    /**
     * On click in item
     */
    handleClick() {
        this.selected = !this.selected;
        this.el.closest('x-datatable-filter').dispatchEvent(new Event('changed'));
    }
    /**
     * On component will load action
     */
    connectedCallback() {
        if (isEmpty(this.value)) {
            this.value = this.el.innerText.trim();
        }
    }
    /**
     * Render element
     */
    render() {
        return h(Host, { key: 'c1693b18b3f985f168d4f979b6d57d207260c5e3', class: cls({ selected: this.selected }) }, h("slot", { key: '9e4f28dbfebafe30b51b6818f45383112aa5c64e' }), " ", this.selected && h("x-icon", { key: 'e358fa01d79847c6558c8aa140c8c5bd17175d26', name: "check" }));
    }
    static get is() { return "x-datatable-filter-item"; }
    static get originalStyleUrls() {
        return {
            "$": ["style.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["style.css"]
        };
    }
    static get properties() {
        return {
            "value": {
                "type": "string",
                "mutable": true,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Filter item value"
                },
                "attribute": "value",
                "reflect": true
            },
            "selected": {
                "type": "boolean",
                "mutable": true,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Filter is selected"
                },
                "attribute": "selected",
                "reflect": true
            }
        };
    }
    static get elementRef() { return "el"; }
    static get listeners() {
        return [{
                "name": "click",
                "method": "handleClick",
                "target": undefined,
                "capture": false,
                "passive": false
            }];
    }
}
