@hashicorp/design-system-components
Version:
Helios Design System Components
38 lines (35 loc) • 1.3 kB
JavaScript
import Component from '@glimmer/component';
import { assert } from '@ember/debug';
import { HdsTableHorizontalAlignmentValues } from './types.js';
import { precompileTemplate } from '@ember/template-compilation';
import { setComponentTemplate } from '@ember/component';
/**
* Copyright IBM Corp. 2021, 2025
* SPDX-License-Identifier: MPL-2.0
*/
const ALIGNMENTS = Object.values(HdsTableHorizontalAlignmentValues);
const DEFAULT_ALIGN = HdsTableHorizontalAlignmentValues.Left;
class HdsTableTd extends Component {
get align() {
const {
align = DEFAULT_ALIGN
} = this.args;
assert(`@align for "Hds::Table::Td" must be one of the following: ${ALIGNMENTS.join(', ')}; received: ${align}`, ALIGNMENTS.includes(align));
return align;
}
get classNames() {
const classes = ['hds-table__td', 'hds-typography-body-200', 'hds-font-weight-regular'];
// add a class based on the @align argument
if (this.align) {
classes.push(`hds-table__td--align-${this.align}`);
}
return classes.join(' ');
}
static {
setComponentTemplate(precompileTemplate("<td class={{this.classNames}} ...attributes>\n {{yield}}\n</td>", {
strictMode: true
}), this);
}
}
export { ALIGNMENTS, DEFAULT_ALIGN, HdsTableTd as default };
//# sourceMappingURL=td.js.map