UNPKG

@oslokommune/punkt-elements

Version:

Komponentbiblioteket til Punkt, et designsystem laget av Oslo Origo

28 lines (27 loc) 1.1 kB
import { u as e } from "./element-cZ85T_aa.js"; import { n as t, r as n, t as r } from "./directive-3THFsVew.js"; //#region ../../node_modules/lit-html/directives/class-map.js var i = r(class extends t { constructor(e) { if (super(e), e.type !== n.ATTRIBUTE || e.name !== "class" || e.strings?.length > 2) throw Error("`classMap()` can only be used in the `class` attribute and must be the only part in the attribute."); } render(e) { return " " + Object.keys(e).filter((t) => e[t]).join(" ") + " "; } update(t, [n]) { if (this.st === void 0) { this.st = /* @__PURE__ */ new Set(), t.strings !== void 0 && (this.nt = new Set(t.strings.join(" ").split(/\s/).filter((e) => e !== ""))); for (let e in n) n[e] && !this.nt?.has(e) && this.st.add(e); return this.render(n); } let r = t.element.classList; for (let e of this.st) e in n || (r.remove(e), this.st.delete(e)); for (let e in n) { let t = !!n[e]; t === this.st.has(e) || this.nt?.has(e) || (t ? (r.add(e), this.st.add(e)) : (r.remove(e), this.st.delete(e))); } return e; } }); //#endregion export { i as t };