UNPKG

@postnord/web-components

Version:

PostNord Web Components

62 lines (57 loc) 2.51 kB
/*! * Built with Stencil * By PostNord. */ import { proxyCustomElement, HTMLElement, forceUpdate, h, Host } from '@stencil/core/internal/client'; 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$1 = /*@__PURE__*/ proxyCustomElement(class PnAccordion extends HTMLElement { constructor() { super(); this.__registerHost(); this.single = false; this.transparent = false; } mo; closeEvent = new CustomEvent('rowstate', { detail: false }); get hostElement() { return this; } connectedCallback() { this.mo = new MutationObserver(() => 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 (h(Host, { key: '8fc540d4b35f12ecc5fd1da8dc79975dcf966742', class: "pn-accordion", "data-transparent": this.transparent }, h("slot", { key: '0e93c18e9d013b3ceb9bb4d313dcb833823d1154' }))); } static get style() { return PnAccordionStyle0; } }, [4, "pn-accordion", { "single": [4], "transparent": [4] }, [[0, "togglerow", "handleSingleRow"]]]); function defineCustomElement$1() { if (typeof customElements === "undefined") { return; } const components = ["pn-accordion"]; components.forEach(tagName => { switch (tagName) { case "pn-accordion": if (!customElements.get(tagName)) { customElements.define(tagName, PnAccordion$1); } break; } }); } const PnAccordion = PnAccordion$1; const defineCustomElement = defineCustomElement$1; export { PnAccordion, defineCustomElement }; //# sourceMappingURL=pn-accordion.js.map