UNPKG

@hashicorp/design-system-components

Version:
46 lines (43 loc) 2.02 kB
import Component from '@glimmer/component'; import { assert } from '@ember/debug'; import HdsTableThSelectable from './th-selectable.js'; import { precompileTemplate } from '@ember/template-compilation'; import { setComponentTemplate } from '@ember/component'; /** * Copyright IBM Corp. 2021, 2025 * SPDX-License-Identifier: MPL-2.0 */ /* * NOTE: There is currently an issue with `WithBoundArgs` or Glint that causes a typing error where @selectionKey is set as always required. * * Until this is fixed, we are holding off on doing a union with the SelectableHdsTableTrArgs */ // Extended interface for selectable rows // export interface SelectableHdsTableTrArgs extends BaseHdsTableTrSignature { // Args: BaseHdsTableTrSignature['Args'] & { // isSelectable: true; // selectionScope?: HdsTableScopeValues.Row; // selectionKey: string; // Now required for selectable rows // }; // } // Union type to combine both possible states // | SelectableHdsTableTrArgs; class HdsTableTr extends Component { get selectionKey() { if (this.args.isSelectable && this.args.selectionScope === 'row') { assert(`@selectionKey must be defined on Table::Tr or B.Tr when @isSelectable is true`, this.args.selectionKey); return this.args.selectionKey; } return undefined; } static { setComponentTemplate(precompileTemplate("<tr class=\"hds-table__tr\" ...attributes>\n {{#if @isSelectable}}\n <HdsTableThSelectable @isSelected={{@isSelected}} @selectionScope={{@selectionScope}} @selectionKey={{this.selectionKey}} @selectionAriaLabelSuffix={{@selectionAriaLabelSuffix}} @sortBySelectedOrder={{@sortBySelectedOrder}} @didInsert={{@didInsert}} @willDestroy={{@willDestroy}} @onClickSortBySelected={{@onClickSortBySelected}} @onSelectionChange={{@onSelectionChange}} />\n {{/if}}\n\n {{yield}}\n</tr>", { strictMode: true, scope: () => ({ HdsTableThSelectable }) }), this); } } export { HdsTableTr as default }; //# sourceMappingURL=tr.js.map