import { h } from "@stencil/core";
export class SpwTableBody {
    constructor() {
        /** Si `true`, applique un style zébré aux lignes du tableau (à appliquer sur spw-table-body) */
        this.isZebra = false;
    }
    componentDidLoad() {
        this.updateZebraStyles();
        this.setupSlotListener();
    }
    setupSlotListener() {
        var _a;
        const slot = (_a = this.el.shadowRoot) === null || _a === void 0 ? void 0 : _a.querySelector('slot');
        if (slot) {
            slot.addEventListener('slotchange', () => {
                this.updateZebraStyles();
            });
        }
    }
    async updateZebraStyles() {
        if (!this.isZebra)
            return;
        const slot = this.el.shadowRoot.querySelector('slot');
        if (!slot)
            return;
        const slottedNodes = slot.assignedElements({ flatten: true });
        let rowIndex = 0;
        slottedNodes.forEach(el => {
            if (el.tagName.toLowerCase() === 'spw-table-row') {
                el.setAttribute('data-row-style', rowIndex % 2 === 0 ? 'even' : 'odd');
                rowIndex++;
            }
        });
    }
    render() {
        return (h("tbody", { key: 'c1ad96fdf8c9434261fdde389b622783007e412d', part: "tbody" }, h("slot", { key: 'd02437370fd0fce984282efdb12383dfe6af06b6' })));
    }
    static get is() { return "spw-table-body"; }
    static get encapsulation() { return "shadow"; }
    static get originalStyleUrls() {
        return {
            "$": ["spw-table-body.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["spw-table-body.css"]
        };
    }
    static get properties() {
        return {
            "isZebra": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Si `true`, applique un style z\u00E9br\u00E9 aux lignes du tableau (\u00E0 appliquer sur spw-table-body)"
                },
                "getter": false,
                "setter": false,
                "reflect": true,
                "attribute": "is-zebra",
                "defaultValue": "false"
            }
        };
    }
    static get methods() {
        return {
            "updateZebraStyles": {
                "complexType": {
                    "signature": "() => Promise<void>",
                    "parameters": [],
                    "references": {
                        "Promise": {
                            "location": "global",
                            "id": "global::Promise"
                        }
                    },
                    "return": "Promise<void>"
                },
                "docs": {
                    "text": "",
                    "tags": []
                }
            }
        };
    }
    static get elementRef() { return "el"; }
}
