import { Host, h } from "@stencil/core";
export class SpwTableRow {
    constructor() {
        /** Permet de changer le state du spw-table-row  */
        this.state = 'default';
    }
    componentDidLoad() {
        this.applyPropsToChildren();
        this.setupMutationObserver();
    }
    disconnectedCallback() {
        var _a;
        (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
    }
    setupMutationObserver() {
        this.mutationObserver = new MutationObserver(() => {
            this.applyPropsToChildren();
        });
        this.mutationObserver.observe(this.el, { childList: true, subtree: false });
    }
    slotChanged() {
        this.applyPropsToChildren();
    }
    onStateChange() {
        this.applyPropsToChildren();
    }
    onPaddingChange() {
        this.applyPropsToChildren();
    }
    applyPropsToChildren() {
        requestAnimationFrame(() => {
            const cells = this.el.querySelectorAll('spw-table-cell, spw-table-header');
            const stateClass = `--${this.state}`;
            cells.forEach(cell => {
                cell.classList.remove('--default', '--selected', '--disabled');
                if (this.state !== 'default') {
                    cell.classList.add(stateClass);
                }
                if (this.padding && !cell.hasAttribute('data-has-explicit-padding')) {
                    cell.padding = this.padding;
                }
            });
        });
    }
    get elementClass() {
        return {
            'spw-table-row': true,
            [`spw-table-row--${this.state}`]: true,
        };
    }
    render() {
        return (h(Host, { key: '65672e550b60007a5a067207e5e98391b15e9a1d', part: "row" }, h("tr", { key: 'aa9563a8d33329fedefc97f49dd0fc3cbe54b1a4', class: this.elementClass, part: "row" }, h("slot", { key: '1647fc675ce503dd64551176e9719ed031131fcc' }))));
    }
    static get is() { return "spw-table-row"; }
    static get encapsulation() { return "shadow"; }
    static get originalStyleUrls() {
        return {
            "$": ["spw-table-row.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["spw-table-row.css"]
        };
    }
    static get properties() {
        return {
            "state": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "'default' | 'selected' | 'disabled'",
                    "resolved": "\"default\" | \"disabled\" | \"selected\"",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Permet de changer le state du spw-table-row"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "state",
                "defaultValue": "'default'"
            },
            "padding": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "'small' | 'medium'",
                    "resolved": "\"medium\" | \"small\"",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "D\u00E9finit le padding pour toutes les cellules de la row"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "padding"
            }
        };
    }
    static get elementRef() { return "el"; }
    static get watchers() {
        return [{
                "propName": "state",
                "methodName": "onStateChange"
            }, {
                "propName": "padding",
                "methodName": "onPaddingChange"
            }];
    }
    static get listeners() {
        return [{
                "name": "slotchange",
                "method": "slotChanged",
                "target": undefined,
                "capture": false,
                "passive": false
            }];
    }
}
