dap-design-system
Version:
Official design system for the DÁP (dap.gov.hu)
71 lines (70 loc) • 2.64 kB
JavaScript
import { clsx as l } from "../../node_modules/clsx/dist/clsx.js";
import "../../node_modules/@lit/reactive-element/reactive-element.js";
import "../../node_modules/lit-html/lit-html.js";
import "../../node_modules/lit-element/lit-element.js";
import { property as h } from "../../node_modules/@lit/reactive-element/decorators/property.js";
import { queryAssignedElements as p } from "../../node_modules/@lit/reactive-element/decorators/query-assigned-elements.js";
import { html as u } from "../../node_modules/lit-html/static.js";
import { DdsElement as m } from "../../internal/dds-hu-element.js";
import g from "./accordion-group.scss.js";
import { unsafeCSS as f } from "../../node_modules/@lit/reactive-element/css-tag.js";
var v = Object.defineProperty, a = (d, t, o, r) => {
for (var e = void 0, i = d.length - 1, c; i >= 0; i--)
(c = d[i]) && (e = c(t, o, e) || e);
return e && v(t, o, e), e;
};
const s = class s extends m {
constructor() {
super(...arguments), this.autoClose = "true", this.variant = "default", this.boundOnAccordionChange = this.onAccordionChange.bind(this), this.boundOnSlotChange = this.onSlotChange.bind(this);
}
connectedCallback() {
super.connectedCallback(), this.addEventListener("slotchange", this.boundOnSlotChange);
}
disconnectedCallback() {
super.disconnectedCallback(), this.removeEventListener("slotchange", this.boundOnSlotChange), this.accordions.forEach((t) => {
t.removeEventListener("dds-opened", this.boundOnAccordionChange);
});
}
firstUpdated(t) {
this.setupAccordions();
}
onSlotChange() {
this.setupAccordions();
}
setupAccordions() {
this.accordions.forEach((t, o) => {
t.variant = this.variant, t.lastItem = o === this.accordions.length - 1, t.removeEventListener("dds-opened", this.boundOnAccordionChange), t.addEventListener("dds-opened", this.boundOnAccordionChange);
});
}
onAccordionChange(t) {
var r;
const o = (r = t.detail) == null ? void 0 : r.item;
o && this.autoClose === "true" && this.accordions.forEach((e) => {
o !== e && e.removeAttribute("opened");
});
}
render() {
return u`
<div
part="base"
class=${l("accordion-group", `accordion-group--${this.variant}`)}>
<slot></slot>
</div>
`;
}
};
s.tagName = "dap-ds-accordion-group", s.styles = f(g);
let n = s;
a([
p({ selector: "dap-ds-accordion" })
], n.prototype, "accordions");
a([
h({ type: String })
], n.prototype, "autoClose");
a([
h({ type: String })
], n.prototype, "variant");
export {
n as default
};
//# sourceMappingURL=accordion-group.component.js.map