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: '374bb3c00e29d1071ca7f24df62d376df569029f', class: cls({ selected: this.selected }) }, h("slot", { key: 'a49f37f5885dac84cd8cca07377ca25c9dcdd849' }), " ", this.selected && h("x-icon", { key: '878e94bc4376ad55ecc85a0187323f0a73392c4c', 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
            }];
    }
}
