import { Host, h } from "@stencil/core";
export class PdsTableCell {
    constructor() {
        this.handleScroll = () => {
            if (this.tableRef.scrollLeft > 0) {
                this.tableScrolling = true;
            }
            else {
                this.tableScrolling = false;
            }
        };
        this.truncate = undefined;
        this.tableScrolling = false;
    }
    componentWillRender() {
        this.tableRef = this.hostElement.closest('pds-table');
    }
    componentDidLoad() {
        if (this.tableRef && this.tableRef.responsive && this.tableRef.fixedColumn) {
            this.tableRef.addEventListener('scroll', this.handleScroll);
        }
    }
    classNames() {
        const classNames = [];
        if (this.tableRef && this.tableRef.compact) {
            classNames.push('is-compact');
        }
        if (this.truncate) {
            classNames.push('is-truncated');
        }
        if (this.tableRef && this.tableRef.fixedColumn && this.tableScrolling) {
            classNames.push('has-scrolled');
        }
        return classNames.join(' ');
    }
    render() {
        return (h(Host, { key: '91ed20b4338792e6d72834d81d966c154fa2bc6d', class: this.classNames(), role: "gridcell", style: this.tableRef &&
                this.tableRef.fixedColumn &&
                this.tableRef.selectable
                ? { '--fixed-cell-position': '40px' }
                : {} }, h("slot", { key: '40dafc4697ba077a121979b604100107f51e9ff1' })));
    }
    static get is() { return "pds-table-cell"; }
    static get encapsulation() { return "shadow"; }
    static get originalStyleUrls() {
        return {
            "$": ["pds-table-cell.scss"]
        };
    }
    static get styleUrls() {
        return {
            "$": ["pds-table-cell.css"]
        };
    }
    static get properties() {
        return {
            "truncate": {
                "type": "boolean",
                "mutable": false,
                "complexType": {
                    "original": "boolean",
                    "resolved": "boolean",
                    "references": {}
                },
                "required": false,
                "optional": false,
                "docs": {
                    "tags": [],
                    "text": "Truncates content to a max width of 100px and adds an ellipsis."
                },
                "attribute": "truncate",
                "reflect": false
            }
        };
    }
    static get states() {
        return {
            "tableScrolling": {}
        };
    }
    static get elementRef() { return "hostElement"; }
}
//# sourceMappingURL=pds-table-cell.js.map
