@hashicorp/design-system-components
Version:
Helios Design System Components
52 lines (49 loc) • 1.79 kB
JavaScript
import Component from '@glimmer/component';
import { assert } from '@ember/debug';
import { hash } from '@ember/helper';
import HdsAccordionItem, { DEFAULT_SIZE, SIZES, DEFAULT_TYPE, TYPES } from './item/index.js';
import { HdsAccordionItemTitleTagValues } 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
*/
class HdsAccordion extends Component {
get size() {
const {
size = DEFAULT_SIZE
} = this.args;
assert(`@size for "Hds::Accordion" must be one of the following: ${SIZES.join(', ')}; received: ${size}`, SIZES.includes(size));
return size;
}
get titleTag() {
return this.args.titleTag ?? HdsAccordionItemTitleTagValues.Div;
}
get type() {
const {
type = DEFAULT_TYPE
} = this.args;
assert(`@type for "Hds::Accordion" must be one of the following: ${TYPES.join(', ')}; received: ${type}`, TYPES.includes(type));
return type;
}
get classNames() {
const classes = ['hds-accordion'];
// add a class based on the @size argument
classes.push(`hds-accordion--size-${this.size}`);
// add a class based on the @type argument
classes.push(`hds-accordion--type-${this.type}`);
return classes.join(' ');
}
static {
setComponentTemplate(precompileTemplate("<div class={{this.classNames}} ...attributes>\n {{yield (hash Item=(component HdsAccordionItem titleTag=this.titleTag size=this.size type=this.type forceState=@forceState))}}\n</div>", {
strictMode: true,
scope: () => ({
hash,
HdsAccordionItem
})
}), this);
}
}
export { HdsAccordion as default };
//# sourceMappingURL=index.js.map