@postnord/web-components
Version:
PostNord Web Components
46 lines (40 loc) • 1.91 kB
JavaScript
/*!
* Built with Stencil
* By PostNord.
*/
;
Object.defineProperty(exports, '__esModule', { value: true });
const index = require('./index-ec4ed1cc.js');
const pnAccordionCss = "pn-accordion{position:relative;background-color:#ffffff;display:flex;align-items:stretch;flex-direction:column;gap:0.25em}pn-accordion[data-transparent]{background-color:transparent}pn-accordion>pn-accordion-row+pn-accordion-row:after{content:\"\";position:absolute;top:-0.125em;left:0.25em;width:calc(100% - 0.5em);height:0;border-top:0.0625em solid #d3cecb}";
const PnAccordionStyle0 = pnAccordionCss;
const PnAccordion = class {
constructor(hostRef) {
index.registerInstance(this, hostRef);
this.single = false;
this.transparent = false;
}
mo;
closeEvent = new CustomEvent('rowstate', { detail: false });
get hostElement() { return index.getElement(this); }
connectedCallback() {
this.mo = new MutationObserver(() => index.forceUpdate(this.hostElement));
this.mo.observe(this.hostElement, { childList: true, subtree: true });
}
disconnectedCallback() {
this.mo.disconnect();
}
handleSingleRow({ detail }) {
if (!this.single)
return;
const element = detail.element;
const activeRow = element.closest('pn-accordion-row');
const rows = Array.from(this.hostElement.querySelectorAll('pn-accordion-row'));
rows.forEach(row => !row.isSameNode(activeRow) && row.dispatchEvent(this.closeEvent));
}
render() {
return (index.h(index.Host, { key: 'a782daf7f432139924deab234c2b6eea4ddbaf6b', class: "pn-accordion", "data-transparent": this.transparent }, index.h("slot", { key: '8b8aa06b41b8e7883258bd39a0e95fe95f2af63e' })));
}
};
PnAccordion.style = PnAccordionStyle0;
exports.pn_accordion = PnAccordion;
//# sourceMappingURL=pn-accordion.cjs.entry.js.map