@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: '8fc540d4b35f12ecc5fd1da8dc79975dcf966742', class: "pn-accordion", "data-transparent": this.transparent }, index.h("slot", { key: '0e93c18e9d013b3ceb9bb4d313dcb833823d1154' })));
}
};
PnAccordion.style = PnAccordionStyle0;
exports.pn_accordion = PnAccordion;
//# sourceMappingURL=pn-accordion.cjs.entry.js.map