import { h } from "@stencil/core";
export class SpwTableHeader {
    constructor() {
        /** Définit un style visuel qui met en avant la cellule (à appliquer sur spw-table-cell ou spw-table-header) */
        this.isHighlighted = false;
        /** Définit un alignement de texte pour la cellule (à appliquer sur spw-table-cell ou spw-table-header) */
        this.textAlign = 'left';
        /** Définit un alignement vertical pour la cellule (à appliquer sur spw-table-cell ou spw-table-header) */
        this.verticalAlign = 'top';
        /** Définit le padding pour la cellule (à appliquer sur spw-table-cell ou spw-table-header) */
        this.padding = 'medium';
        /** Définit si la colonne est triable (à appliquer sur spw-table-header) */
        this.sortable = false;
        /** Définit si la colonne est triée ou non (à appliquer sur spw-table-header) */
        this.isSorted = false;
        /** Rend la cellule sticky lors du défilement horizontal  (à appliquer sur spw-table-header ou spw-table-cell) */
        this.sticky = false;
        /** Position du sticky : 'start' (left: 0) ou 'end' (right: 0)  (à appliquer sur spw-table-header ou spw-table-cell) */
        this.stickyPosition = 'start';
        /** Décalage en pixels pour le sticky (utile pour empiler plusieurs colonnes sticky)  (à appliquer sur spw-table-header ou spw-table-cell) */
        this.stickyOffset = 0;
        this.handleClick = (event) => {
            if (event.target.closest('[slot="filters"]')) {
                event.stopPropagation();
                return;
            }
            if (this.sortable) {
                this.spwHeaderClick.emit(this.columnId);
            }
        };
    }
    get elementClass() {
        return {
            'spw-table-header': true,
            'spw-table-header--sortable': this.sortable,
            'spw-table-header--is-sorted': this.isSorted,
            'spw-table-header--has-tooltip': !!(this.tooltipTitle || this.tooltipText),
            [`spw-table-header--padding-${this.padding}`]: true,
            [`spw-table-header--text-align-${this.textAlign}`]: true,
            [`spw-table-header--vertical-align-${this.verticalAlign}`]: true,
            'spw-table-header--sticky': this.sticky,
            [`spw-table-header--sticky-${this.stickyPosition}`]: this.sticky,
        };
    }
    render() {
        const attrs = {
            'aria-sort': this.isSorted ? this.sortDirection : 'none',
            'onClick': this.handleClick,
            'class': this.elementClass,
            'colSpan': this.colspan,
            'headers': this.headers,
            'part': 'cell',
            'rowSpan': this.rowspan,
        };
        if (this.sticky) {
            const stickyStyles = {
                position: 'sticky',
                zIndex: '60',
            };
            if (this.stickyPosition === 'start') {
                stickyStyles.left = `${this.stickyOffset}px`;
            }
            else {
                stickyStyles.right = `${this.stickyOffset}px`;
            }
            attrs.style = stickyStyles;
        }
        return (h("th", Object.assign({ key: 'f9d040dd58d8739e60d70bb53a477d3f0da25c72' }, attrs), h("div", { key: 'b1e0ab131f026740b669cd37e493d79d8ef46ad1', class: {
                'spw-table-header__content': true,
                'spw-table-header__content--is-sorted': this.isSorted,
            } }, h("slot", { key: 'eec3daf6a29e815971d4e82265e54bd2f966fbcb' }), h("div", { key: '0b3ee697ce5ab7d29aded245f3b879561e237bc6', class: "spw-table-header__icons" }, h("slot", { key: 'c5ac4935be906a8b6f52d2bf48d153e4ce91c2ad', name: "filters" }), (this.tooltipTitle || this.tooltipText) && (h("spw-tooltip", { key: '27ec14c3d6853005a17e42a32e593cb4a19c978e', "tooltip-title": this.tooltipTitle, "tooltip-text": this.tooltipText }, h("spw-icon", { key: '6998539763d4144d4e0275089f73ae734a2f04c3', variant: "fa-regular", icon: "fa-circle-question" }))), this.sortable && (h("spw-icon", { key: '31169ff6d560ca8ef0329b07ed9330d021c497be', class: "spw-table-header__sort-icon", icon: this.isSorted ? (this.sortDirection === 'asc' ? 'fa-arrow-up-short-wide' : 'fa-arrow-down-wide-short') : 'fa-arrow-up-arrow-down' }))))));
    }
    static get is() { return "spw-table-header"; }
    static get encapsulation() { return "shadow"; }
    static get originalStyleUrls() {
        return {
            "$": ["spw-table-header.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["spw-table-header.css"]
        };
    }
    static get properties() {
        return {
            "colspan": {
                "type": "number",
                "mutable": false,
                "complexType": {
                    "original": "HTMLTableCellElement['colSpan']",
                    "resolved": "number",
                    "references": {
                        "HTMLTableCellElement": {
                            "location": "global",
                            "id": "global::HTMLTableCellElement"
                        }
                    }
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "D\u00E9finit un colspan pour la cellule (\u00E0 appliquer sur spw-table-cell ou spw-table-header)"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "colspan"
            },
            "headers": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "HTMLTableCellElement['headers']",
                    "resolved": "string",
                    "references": {
                        "HTMLTableCellElement": {
                            "location": "global",
                            "id": "global::HTMLTableCellElement"
                        }
                    }
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "D\u00E9finit un header relationnel pour la cellule, \u00E0 des fins d'accessibilit\u00E9 (\u00E0 appliquer sur spw-table-cell ou spw-table-header)"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "headers"
            },
            "rowspan": {
                "type": "number",
                "mutable": false,
                "complexType": {
                    "original": "HTMLTableCellElement['rowSpan']",
                    "resolved": "number",
                    "references": {
                        "HTMLTableCellElement": {
                            "location": "global",
                            "id": "global::HTMLTableCellElement"
                        }
                    }
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "D\u00E9finit un rowspan pour la cellule (\u00E0 appliquer sur spw-table-cell ou spw-table-header)"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "rowspan"
            },
            "isHighlighted": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "D\u00E9finit un style visuel qui met en avant la cellule (\u00E0 appliquer sur spw-table-cell ou spw-table-header)"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "is-highlighted",
                "defaultValue": "false"
            },
            "textAlign": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "'center' | 'left' | 'right'",
                    "resolved": "\"center\" | \"left\" | \"right\"",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "D\u00E9finit un alignement de texte pour la cellule (\u00E0 appliquer sur spw-table-cell ou spw-table-header)"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "text-align",
                "defaultValue": "'left'"
            },
            "verticalAlign": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "'top' | 'bottom' | 'middle'",
                    "resolved": "\"bottom\" | \"middle\" | \"top\"",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "D\u00E9finit un alignement vertical pour la cellule (\u00E0 appliquer sur spw-table-cell ou spw-table-header)"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "vertical-align",
                "defaultValue": "'top'"
            },
            "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 la cellule (\u00E0 appliquer sur spw-table-cell ou spw-table-header)"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "padding",
                "defaultValue": "'medium'"
            },
            "columnId": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "D\u00E9finit id pour la colonne (en cas de tri) (\u00E0 appliquer sur spw-table-header)"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "column-id"
            },
            "sortable": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "D\u00E9finit si la colonne est triable (\u00E0 appliquer sur spw-table-header)"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "sortable",
                "defaultValue": "false"
            },
            "sortDirection": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "'asc' | 'desc'",
                    "resolved": "\"asc\" | \"desc\"",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "D\u00E9finit la direction pour le tri sur la colonne (ascendant ou descendant) (\u00E0 appliquer sur spw-table-header)"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "sort-direction"
            },
            "isSorted": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "D\u00E9finit si la colonne est tri\u00E9e ou non (\u00E0 appliquer sur spw-table-header)"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "is-sorted",
                "defaultValue": "false"
            },
            "tooltipTitle": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "D\u00E9finit un titre pour le tooltip (\u00E0 appliquer sur spw-table-header)"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "tooltip-title"
            },
            "tooltipText": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "D\u00E9finit un contenu pour le tooltip (\u00E0 appliquer sur spw-table-header)"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "tooltip-text"
            },
            "sticky": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Rend la cellule sticky lors du d\u00E9filement horizontal  (\u00E0 appliquer sur spw-table-header ou spw-table-cell)"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "sticky",
                "defaultValue": "false"
            },
            "stickyPosition": {
                "type": "string",
                "mutable": false,
                "complexType": {
                    "original": "'start' | 'end'",
                    "resolved": "\"end\" | \"start\"",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "Position du sticky : 'start' (left: 0) ou 'end' (right: 0)  (\u00E0 appliquer sur spw-table-header ou spw-table-cell)"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "sticky-position",
                "defaultValue": "'start'"
            },
            "stickyOffset": {
                "type": "number",
                "mutable": false,
                "complexType": {
                    "original": "number",
                    "resolved": "number",
                    "references": {}
                },
                "required": false,
                "optional": true,
                "docs": {
                    "tags": [],
                    "text": "D\u00E9calage en pixels pour le sticky (utile pour empiler plusieurs colonnes sticky)  (\u00E0 appliquer sur spw-table-header ou spw-table-cell)"
                },
                "getter": false,
                "setter": false,
                "reflect": false,
                "attribute": "sticky-offset",
                "defaultValue": "0"
            }
        };
    }
    static get events() {
        return [{
                "method": "spwHeaderClick",
                "name": "spwHeaderClick",
                "bubbles": true,
                "cancelable": true,
                "composed": true,
                "docs": {
                    "tags": [],
                    "text": ""
                },
                "complexType": {
                    "original": "string",
                    "resolved": "string",
                    "references": {}
                }
            }];
    }
}
