import { __decorate } from "tslib";
import { attr, observable } from '@ni/fast-element';
import { DesignSystem, FoundationElement } from '@ni/fast-foundation';
import { TableColumnAlignment, TableColumnSortDirection } from '../../types';
import { styles } from './styles';
import { template } from './template';
/**
 * A styled header that is used within the nimble-table.
 * @internal
 */
export class TableHeader extends FoundationElement {
    constructor() {
        super(...arguments);
        this.sortDirection = TableColumnSortDirection.none;
        this.firstSortedColumn = false;
        this.indicatorsHidden = false;
        this.alignment = TableColumnAlignment.left;
        this.isGrouped = false;
    }
    sortDirectionChanged(_prev, _next) {
        this.updateAriaSort();
    }
    firstSortedColumnChanged(_prev, _next) {
        this.updateAriaSort();
    }
    updateAriaSort() {
        if (!this.firstSortedColumn
            || this.sortDirection === TableColumnSortDirection.none) {
            this.ariaSort = null;
        }
        else if (this.sortDirection === TableColumnSortDirection.ascending) {
            this.ariaSort = 'ascending';
        }
        else {
            this.ariaSort = 'descending';
        }
    }
}
__decorate([
    attr({ attribute: 'sort-direction' })
], TableHeader.prototype, "sortDirection", void 0);
__decorate([
    attr({ attribute: 'first-sorted-column', mode: 'boolean' })
], TableHeader.prototype, "firstSortedColumn", void 0);
__decorate([
    attr({ attribute: 'indicators-hidden', mode: 'boolean' })
], TableHeader.prototype, "indicatorsHidden", void 0);
__decorate([
    observable
], TableHeader.prototype, "alignment", void 0);
__decorate([
    observable
], TableHeader.prototype, "isGrouped", void 0);
const nimbleTableHeader = TableHeader.compose({
    baseName: 'table-header',
    template,
    styles
});
DesignSystem.getOrCreate().withPrefix('nimble').register(nimbleTableHeader());
export const tableHeaderTag = 'nimble-table-header';
//# sourceMappingURL=index.js.map