UNPKG

@oslokommune/punkt-elements

Version:

Komponentbiblioteket til Punkt, et designsystem laget av Oslo Origo

174 lines (173 loc) 6.94 kB
import { P as p, x as c, n as a, a as g } from "./element-CgEWt74-.js"; import "./button-DrrEvUy9.js"; import "./icon-CC1js8eR.js"; const u = { i18n: { nb: { contentPresentation: { title: "Oslo kommune bruker informasjonskapsler", description: [ "For at nettstedet skal fungere og være trygt, bruker Oslo kommune informasjonskapsler. Noen er teknisk nødvendige, mens andre sikrer ulik funksjonalitet.", "Godtar du alle informasjonskapsler, tillater du også at vi samler inn data om statistikk og brukeradferd. Da hjelper du oss med å lage et bedre nettsted uten at du trenger å dele noe personlig informasjon med oss." ], buttons: { accept: "Godta alle", reject: "Kun nødvendige", settings: "Innstillinger for informasjonskapsler" } }, contentSettings: { title: "Innstillinger for informasjonskapsler", description: [ "Her kan du velge hvilke typer informasjonskapsler du vil tillate. Tillatelsen gjelder i 90 dager. Husk at nødvendige informasjonskapsler ikke kan velges bort.", "Du kan når som helst endre innstillingene og finne mer informasjon nederst på nettstedet under «Innstillinger for informasjonskapsler» og «Personvern og informasjonskapsler»." ], buttons: { back: "Tilbake", save: "Lagre innstillinger" } } }, en: { contentPresentation: { title: "Before you visit Oslo kommune ...", description: [ "This website uses cookies to make improvements. In this context, we need your consent to measure the traffic on the website in relation to statistics and feedback.", "To read more about what we use cookies for, go to our privacy declaration which you will find at the bottom of our websites." ], buttons: { accept: "Yes, I accept", reject: "Only necessary", settings: "Go to settings" } }, contentSettings: { title: "Her kan du aktivt velge mellom ulike informasjonskapsler", description: [ "For å lese mer om hva vi bruker informasjonskapsler til gå til vår personvernserklering som du finner på våre nettsider" ], buttons: { back: "Back", save: "Save settings" } } } } }; var h = Object.defineProperty, m = Object.getOwnPropertyDescriptor, r = (e, t, n, o) => { for (var s = o > 1 ? void 0 : o ? m(t, n) : t, k = e.length - 1, d; k >= 0; k--) (d = e[k]) && (s = (o ? d(t, n, s) : d(s)) || s); return o && s && h(t, n, s), s; }; let l = null; function f() { return l || (l = new Promise((e, t) => { if (document.querySelector("#oslo-consent-script")) { e(); return; } const n = document.createElement("script"); n.src = "https://cdn.web.oslo.kommune.no/cb/cb-v1.1.0.js", n.id = "oslo-consent-script", n.onload = () => e(), n.onerror = t, document.head.appendChild(n); const o = document.createElement("link"); o.href = "https://cdn.web.oslo.kommune.no/cb/cb-v1.1.0.css", o.type = "text/css", o.rel = "stylesheet", o.id = "oslo-consent-styles", document.head.appendChild(o); }), l); } let i = class extends p { constructor() { super(), this.devMode = !1, this.hotjarId = null, this.googleAnalyticsId = null, this.cookieDomain = null, this.cookieSecure = null, this.cookieExpiryDays = null, this.triggerType = "button", this.triggerText = null, this.i18nLanguage = "nb"; } connectedCallback() { super.connectedCallback(), this.triggerText = this.triggerText || u.i18n[this.i18nLanguage].contentPresentation.buttons.settings; } disconnectedCallback() { var e; super.disconnectedCallback(), this._cookieEventHandler && ((e = window.__cookieEvents) == null || e.off("CookieManager.setCookie", this._cookieEventHandler)); } returnJsonOrObject(e) { let t; try { t = JSON.parse(e); } catch { t = e; } return t; } emitCookieConsents(e) { const n = this.returnJsonOrObject(e.value).items.reduce((o, s) => (o[s.name] = s.consent, o), {}); this.dispatchEvent( new CustomEvent("toggle-consent", { detail: n, bubbles: !0, cancelable: !1 }) ); } async firstUpdated(e) { window.cookieBanner_googleAnalyticsId = this.googleAnalyticsId, window.cookieBanner_hotjarId = this.hotjarId, this.cookieDomain && (window.cookieBanner_cookieDomain = this.cookieDomain), this.cookieSecure && (window.cookieBanner_cookieSecure = this.cookieSecure), this.cookieExpiryDays && (window.cookieBanner_cookieExpiryDays = this.cookieExpiryDays), this.devMode && (window.cookieBanner_devMode = this.devMode), await f(), this.triggerInit(); } triggerInit() { window.document.dispatchEvent( new Event("CookieBannerReady", { bubbles: !0, cancelable: !0 }) ), window.cookieBanner.cookieConsent.validateConsentCookie().then((e) => { if (e) { const n = { value: window.cookieBanner.cookieConsent.getConsentCookie() }; window.setTimeout(() => this.emitCookieConsents(n), 0), this._cookieEventHandler && window.__cookieEvents.off("CookieManager.setCookie", this._cookieEventHandler), this._cookieEventHandler = (o) => { this.emitCookieConsents(o); }, window.__cookieEvents.on("CookieManager.setCookie", this._cookieEventHandler); } }); } openModal(e) { var t; e.preventDefault(), (t = window.cookieBanner) != null && t.cookieConsent || this.triggerInit(), setTimeout(() => window.cookieBanner.openCookieModal()); } render() { return this.triggerType === "link" ? c`<a href="#" class="pkt-link" @click=${this.openModal}>${this.triggerText}</a>` : this.triggerType === "footerlink" ? c`<a href="#" class="pkt-footer__link" @click=${this.openModal}> <pkt-icon name="chevron-right" class="pkt-footer__link-icon"></pkt-icon> ${this.triggerText} </a>` : this.triggerType === "icon" ? c`<pkt-button skin="tertiary" variant="icon-only" iconName="cookie" @click=${this.openModal} > >${this.triggerText}</pkt-button >` : c`<pkt-button @click=${this.openModal}>${this.triggerText}</pkt-button>`; } }; r([ a({ type: Boolean }) ], i.prototype, "devMode", 2); r([ a({ type: String }) ], i.prototype, "hotjarId", 2); r([ a({ type: String }) ], i.prototype, "googleAnalyticsId", 2); r([ a({ type: String }) ], i.prototype, "cookieDomain", 2); r([ a({ type: String }) ], i.prototype, "cookieSecure", 2); r([ a({ type: String }) ], i.prototype, "cookieExpiryDays", 2); r([ a({ type: String }) ], i.prototype, "triggerType", 2); r([ a({ type: String }) ], i.prototype, "triggerText", 2); r([ a({ type: String }) ], i.prototype, "i18nLanguage", 2); i = r([ g("pkt-consent") ], i); export { i as P };