@cbpds/web-components
Version:
Web components for the CBP Design System.
56 lines (50 loc) • 1.83 kB
JavaScript
/*!
* CPB Design System web components - built with Stencil
*/
;
Object.defineProperty(exports, '__esModule', { value: true });
const index = require('./index-cd71cbd5.js');
const utils = require('./utils-99c9e716.js');
const cbpAccordionCss = ":root{--cbp-accordion-gap:var(--cbp-space-3x)}cbp-accordion{display:flex;flex-direction:column;gap:var(--cbp-accordion-gap)}";
const CbpAccordionStyle0 = cbpAccordionCss;
const CbpAccordion = class {
constructor(hostRef) {
index.registerInstance(this, hostRef);
this.multiple = undefined;
this.context = undefined;
this.sx = {};
}
init() {
this.items = Array.from(this.host.querySelectorAll('cbp-accordion-item'));
this.items.forEach(item => {
item.addEventListener('accordionItemClick', (e) => {
this.accordionActionHandler(e);
});
});
}
accordionActionHandler({ detail: { host, open } }) {
if (!this.multiple && open) {
this.host.querySelectorAll('cbp-accordion-item').forEach((item) => {
if (item !== host) {
item.open = false;
}
});
}
}
componentWillLoad() {
if (typeof this.sx == 'string') {
this.sx = JSON.parse(this.sx) || {};
}
utils.setCSSProps(this.host, Object.assign({}, this.sx));
}
componentDidLoad() {
this.init();
}
render() {
return (index.h(index.Host, { key: '5acc53f5aff32b43633a3af9baebdb7484c15205' }, index.h("slot", { key: '2e09b474600d1daf11e278b3d8360d6324bbabc4' })));
}
get host() { return index.getElement(this); }
};
CbpAccordion.style = CbpAccordionStyle0;
exports.cbp_accordion = CbpAccordion;
//# sourceMappingURL=cbp-accordion.cjs.entry.js.map