import { DesignSystem } from '@ni/fast-foundation';
import { styles } from '../base/styles';
import { template } from '../base/template';
import { TableColumnSortOperation } from '../base/types';
import { tableColumnDurationTextCellViewTag } from './cell-view';
import { lang } from '../../theme-provider';
import { DurationFormatter } from './models/duration-formatter';
import { tableColumnDurationTextGroupHeaderViewTag } from './group-header-view';
import { TableColumnTextBase, mixinTextBase } from '../text-base';
import { ColumnValidator } from '../base/models/column-validator';
/**
 * The table column for displaying a duration value as text.
 */
export class TableColumnDurationText extends mixinTextBase((TableColumnTextBase)) {
    constructor() {
        super(...arguments);
        this.langSubscriber = {
            handleChange: () => {
                this.updateColumnConfig();
            }
        };
    }
    connectedCallback() {
        super.connectedCallback();
        lang.subscribe(this.langSubscriber, this);
        this.updateColumnConfig();
    }
    disconnectedCallback() {
        super.disconnectedCallback();
        lang.unsubscribe(this.langSubscriber, this);
    }
    placeholderChanged() {
        this.updateColumnConfig();
    }
    getColumnInternalsOptions() {
        return {
            cellRecordFieldNames: ['value'],
            cellViewTag: tableColumnDurationTextCellViewTag,
            groupHeaderViewTag: tableColumnDurationTextGroupHeaderViewTag,
            delegatedEvents: [],
            sortOperation: TableColumnSortOperation.basic,
            validator: new ColumnValidator([])
        };
    }
    updateColumnConfig() {
        const formatter = new DurationFormatter(lang.getValueFor(this));
        const columnConfig = {
            formatter,
            placeholder: this.placeholder
        };
        this.columnInternals.columnConfig = columnConfig;
    }
}
const nimbleTableColumnDurationText = TableColumnDurationText.compose({
    baseName: 'table-column-duration-text',
    template,
    styles
});
DesignSystem.getOrCreate()
    .withPrefix('nimble')
    .register(nimbleTableColumnDurationText());
export const tableColumnDurationTextTag = 'nimble-table-column-duration-text';
//# sourceMappingURL=index.js.map