@oslokommune/punkt-elements 12.42.4 → 12.42.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,42 @@ og skriver commits ca etter [Conventional Commits](https://conventionalcommits.o
5
5
 
6
6
  ---
7
7
 
8
+ ## [12.42.6](https://github.com/oslokommune/punkt/compare/12.42.5...12.42.6) (2025-06-18)
9
+
10
+ ### ⚠ BREAKING CHANGES
11
+ Ingen
12
+
13
+ ### Features
14
+ Ingen
15
+
16
+ ### Bug Fixes
17
+ Ingen
18
+
19
+ ### Chores
20
+ Ingen
21
+
22
+ ---
23
+
24
+
25
+ ## [12.42.5](https://github.com/oslokommune/punkt/compare/12.42.4...12.42.5) (2025-06-18)
26
+
27
+ ### ⚠ BREAKING CHANGES
28
+ Ingen
29
+
30
+ ### Features
31
+ Ingen
32
+
33
+ ### Bug Fixes
34
+ * Consent: Oppdater UKE cookie banner og legg til nye features (#2641). Bonus: Kvitte oss med avhengighet til CookieEvents fra CookieManager
35
+ Bonus 2: Kjapp fiks på Safari 15-problemer med Combobox…
36
+
37
+
38
+ ### Chores
39
+ Ingen
40
+
41
+ ---
42
+
43
+
8
44
  ## [12.42.4](https://github.com/oslokommune/punkt/compare/12.42.3...12.42.4) (2025-06-17)
9
45
 
10
46
  ### ⚠ BREAKING CHANGES
@@ -1,4 +1,4 @@
1
- "use strict";const a=require("./element-90YeMNbV.cjs"),c=require("./if-defined-C8eotHpL.cjs"),d=require("./state-D-Recv7U.cjs"),r=require("./ref-B-w1vCo8.cjs"),O=require("./class-map-DWDPOqjO.cjs"),I=require("./repeat-CxQA3AeF.cjs"),$=require("./input-element-CInrWeac.cjs"),y=require("./pkt-options-controller-Ay9ELZTV.cjs"),w=require("./pkt-slot-controller-Da-RgXfS.cjs");require("./input-wrapper-Uw7_cZ4w.cjs");require("./icon-B1_BRNqf.cjs");require("./tag-lU4vz70a.cjs");require("./listbox-AjDNhDsQ.cjs");const C={displayValueAs:{default:"label"}},R={props:C};var V=Object.defineProperty,S=Object.getOwnPropertyDescriptor,o=(b,e,t,i)=>{for(var s=i>1?void 0:i?S(e,t):e,l=b.length-1,n;l>=0;l--)(n=b[l])&&(s=(i?n(e,t,s):n(s))||s);return i&&s&&V(e,t,s),s};exports.PktCombobox=class extends $.PktInputElement{constructor(){super(),this.helptextSlot=r.e(),this.value="",this.options=[],this.defaultOptions=[],this.allowUserInput=!1,this.typeahead=!1,this.includeSearch=!1,this.searchPlaceholder="",this.multiple=!1,this.maxlength=null,this.displayValueAs=R.props.displayValueAs.default,this.tagPlacement=null,this._options=[],this._isOptionsOpen=!1,this._value=[],this._userInfoMessage="",this._addValueText=null,this._maxIsReached=!1,this._search="",this._inputFocus=!1,this._editingSingleValue=!1,this.inputRef=r.e(),this.arrowRef=r.e(),this.listboxRef=r.e(),this.focusRef=r.e(),this.optionTagRef=r.e(),this.optionsController=new y.PktOptionsSlotController(this),this.slotController=new w.PktSlotController(this,this.helptextSlot),this.slotController.skipOptions=!0}connectedCallback(){var e;if(super.connectedCallback(),document&&document.body.addEventListener("click",t=>{this._isOptionsOpen&&!this.contains(t.target)&&this.handleFocusOut(t)}),this._options=[],this.defaultOptions&&this.defaultOptions.length){const t=((e=this.options)==null?void 0:e.filter(i=>i.userAdded))||[];this.options=[...t,...structuredClone(this.defaultOptions)],this._options=[...this.options]}if(this.optionsController.nodes.length){const t=[];this.optionsController.nodes.forEach(i=>{if(!i.textContent&&!i.getAttribute("value"))return null;const s={value:i.getAttribute("value")||i.textContent||"",label:i.textContent||i.getAttribute("value")||""};i.getAttribute("data-prefix")&&(s.prefix=i.getAttribute("data-prefix")||void 0),i.getAttribute("tagskincolor")&&(s.tagSkinColor=i.getAttribute("tagskincolor")),i.getAttribute("description")&&(s.description=i.getAttribute("description")||void 0),s.fulltext=s.value+s.label+(s.prefix||""),t.push(s)}),t.length&&(this.options=[...t],this._options=[...t])}}updated(e){var t;if(e.has("_value")&&this.valueChanged(this._value,e.get("_value")),e.has("value")&&(this._value=Array.isArray(this.value)?this.value:this.value?this.value.split(","):[],!this.multiple&&this._value.length>1&&(this._value=[this._value[0]]),this.isMaxItemsReached()),e.has("defaultOptions")&&this.defaultOptions.length){const i=((t=this.options)==null?void 0:t.filter(s=>s.userAdded))||[];this.options=[...i,...structuredClone(this.defaultOptions)],this._options=[...this.options]}if(e.has("options")&&this.options.length){const s=this._options.filter(l=>l.userAdded).filter(l=>!this.options.some(n=>n.value===l.value));this._options=[...s,...this.options],this._options.forEach(l=>{if(l.value&&!l.label&&(l.label=l.value),l.selected&&!this._value.includes(l.value)){const n=[...this._value];this._value=[...this._value,l.value],this.valueChanged(this._value,n)}l.fulltext=l.value+l.label+(l.prefix||""),l.selected=l.selected||this._value.includes(l.value)})}e.has("_search")&&this.dispatchEvent(new CustomEvent("search",{detail:this._search,bubbles:!1})),super.updated(e)}attributeChangedCallback(e,t,i){e==="value"&&(this._value=Array.isArray(this.value)?this.value:this.value?this.value.split(","):[],!this.multiple&&this._value.length>1&&(this._value=[this._value[0]])),e==="options"&&(this._options=this.options,this._options.forEach(s=>{s.value&&!s.label&&(s.label=s.value),s.selected&&!this._value.includes(s.value)&&(this._value=[...this._value,s.value]),s.fulltext=s.value+s.label+(s.prefix||"")}),this._search=""),super.attributeChangedCallback(e,t,i)}render(){return a.x`
1
+ "use strict";const a=require("./element-90YeMNbV.cjs"),c=require("./if-defined-C8eotHpL.cjs"),d=require("./state-D-Recv7U.cjs"),r=require("./ref-B-w1vCo8.cjs"),O=require("./class-map-DWDPOqjO.cjs"),I=require("./repeat-CxQA3AeF.cjs"),$=require("./input-element-CInrWeac.cjs"),y=require("./pkt-options-controller-ftMgG5DP.cjs"),w=require("./pkt-slot-controller-Da-RgXfS.cjs");require("./input-wrapper-Uw7_cZ4w.cjs");require("./icon-B1_BRNqf.cjs");require("./tag-lU4vz70a.cjs");require("./listbox-AjDNhDsQ.cjs");const C={displayValueAs:{default:"label"}},R={props:C};var V=Object.defineProperty,S=Object.getOwnPropertyDescriptor,o=(b,e,t,i)=>{for(var s=i>1?void 0:i?S(e,t):e,l=b.length-1,n;l>=0;l--)(n=b[l])&&(s=(i?n(e,t,s):n(s))||s);return i&&s&&V(e,t,s),s};exports.PktCombobox=class extends $.PktInputElement{constructor(){super(),this.helptextSlot=r.e(),this.value="",this.options=[],this.defaultOptions=[],this.allowUserInput=!1,this.typeahead=!1,this.includeSearch=!1,this.searchPlaceholder="",this.multiple=!1,this.maxlength=null,this.displayValueAs=R.props.displayValueAs.default,this.tagPlacement=null,this._options=[],this._isOptionsOpen=!1,this._value=[],this._userInfoMessage="",this._addValueText=null,this._maxIsReached=!1,this._search="",this._inputFocus=!1,this._editingSingleValue=!1,this.inputRef=r.e(),this.arrowRef=r.e(),this.listboxRef=r.e(),this.focusRef=r.e(),this.optionTagRef=r.e(),this.optionsController=new y.PktOptionsSlotController(this),this.slotController=new w.PktSlotController(this,this.helptextSlot),this.slotController.skipOptions=!0}connectedCallback(){var e;if(super.connectedCallback(),document&&document.body.addEventListener("click",t=>{this._isOptionsOpen&&!this.contains(t.target)&&this.handleFocusOut(t)}),this._options=[],this.defaultOptions&&this.defaultOptions.length){const t=((e=this.options)==null?void 0:e.filter(i=>i.userAdded))||[];this.options=[...t,...JSON.parse(JSON.stringify(this.defaultOptions))],this._options=[...this.options]}if(this.optionsController.nodes.length){const t=[];this.optionsController.nodes.forEach(i=>{if(!i.textContent&&!i.getAttribute("value"))return null;const s={value:i.getAttribute("value")||i.textContent||"",label:i.textContent||i.getAttribute("value")||""};i.getAttribute("data-prefix")&&(s.prefix=i.getAttribute("data-prefix")||void 0),i.getAttribute("tagskincolor")&&(s.tagSkinColor=i.getAttribute("tagskincolor")),i.getAttribute("description")&&(s.description=i.getAttribute("description")||void 0),s.fulltext=s.value+s.label+(s.prefix||""),t.push(s)}),t.length&&(this.options=[...t],this._options=[...t])}}updated(e){var t;if(e.has("_value")&&this.valueChanged(this._value,e.get("_value")),e.has("value")&&(this._value=Array.isArray(this.value)?this.value:this.value?this.value.split(","):[],!this.multiple&&this._value.length>1&&(this._value=[this._value[0]]),this.isMaxItemsReached()),e.has("defaultOptions")&&this.defaultOptions.length){const i=((t=this.options)==null?void 0:t.filter(s=>s.userAdded))||[];this.options=[...i,...JSON.parse(JSON.stringify(this.defaultOptions))],this._options=[...this.options]}if(e.has("options")&&this.options.length){const s=this._options.filter(l=>l.userAdded).filter(l=>!this.options.some(n=>n.value===l.value));this._options=[...s,...this.options],this._options.forEach(l=>{if(l.value&&!l.label&&(l.label=l.value),l.selected&&!this._value.includes(l.value)){const n=[...this._value];this._value=[...this._value,l.value],this.valueChanged(this._value,n)}l.fulltext=l.value+l.label+(l.prefix||""),l.selected=l.selected||this._value.includes(l.value)})}e.has("_search")&&this.dispatchEvent(new CustomEvent("search",{detail:this._search,bubbles:!1})),super.updated(e)}attributeChangedCallback(e,t,i){e==="value"&&(this._value=Array.isArray(this.value)?this.value:this.value?this.value.split(","):[],!this.multiple&&this._value.length>1&&(this._value=[this._value[0]])),e==="options"&&(this._options=this.options,this._options.forEach(s=>{s.value&&!s.label&&(s.label=s.value),s.selected&&!this._value.includes(s.value)&&(this._value=[...this._value,s.value]),s.fulltext=s.value+s.label+(s.prefix||"")}),this._search=""),super.attributeChangedCallback(e,t,i)}render(){return a.x`
2
2
  <pkt-input-wrapper
3
3
  .label=${this.label}
4
4
  .helptext=${this.helptext}
@@ -5,18 +5,18 @@ import { e as _, n as v } from "./ref-DnSbnXsj.js";
5
5
  import { e as w } from "./class-map-m7ZCZ49w.js";
6
6
  import { c as R } from "./repeat-lUFq9w5d.js";
7
7
  import { P as V } from "./input-element-BEvaQK4g.js";
8
- import { P as C } from "./pkt-options-controller-DepYQBqb.js";
9
- import { P as A } from "./pkt-slot-controller-DtDaD9q_.js";
8
+ import { P as S } from "./pkt-options-controller-C_Yl_3P6.js";
9
+ import { P as C } from "./pkt-slot-controller-DtDaD9q_.js";
10
10
  import "./input-wrapper-DnyRiuHR.js";
11
11
  import "./icon-CO1TLSs5.js";
12
12
  import "./tag-CX-zbR-7.js";
13
13
  import "./listbox-DCWdrjFp.js";
14
- const S = {
14
+ const A = {
15
15
  displayValueAs: {
16
16
  default: "label"
17
17
  }
18
18
  }, T = {
19
- props: S
19
+ props: A
20
20
  };
21
21
  var M = Object.defineProperty, F = Object.getOwnPropertyDescriptor, o = (t, e, i, s) => {
22
22
  for (var l = s > 1 ? void 0 : s ? F(e, i) : e, n = t.length - 1, a; n >= 0; n--)
@@ -25,7 +25,7 @@ var M = Object.defineProperty, F = Object.getOwnPropertyDescriptor, o = (t, e, i
25
25
  };
26
26
  let h = class extends V {
27
27
  constructor() {
28
- super(), this.helptextSlot = _(), this.value = "", this.options = [], this.defaultOptions = [], this.allowUserInput = !1, this.typeahead = !1, this.includeSearch = !1, this.searchPlaceholder = "", this.multiple = !1, this.maxlength = null, this.displayValueAs = T.props.displayValueAs.default, this.tagPlacement = null, this._options = [], this._isOptionsOpen = !1, this._value = [], this._userInfoMessage = "", this._addValueText = null, this._maxIsReached = !1, this._search = "", this._inputFocus = !1, this._editingSingleValue = !1, this.inputRef = _(), this.arrowRef = _(), this.listboxRef = _(), this.focusRef = _(), this.optionTagRef = _(), this.optionsController = new C(this), this.slotController = new A(this, this.helptextSlot), this.slotController.skipOptions = !0;
28
+ super(), this.helptextSlot = _(), this.value = "", this.options = [], this.defaultOptions = [], this.allowUserInput = !1, this.typeahead = !1, this.includeSearch = !1, this.searchPlaceholder = "", this.multiple = !1, this.maxlength = null, this.displayValueAs = T.props.displayValueAs.default, this.tagPlacement = null, this._options = [], this._isOptionsOpen = !1, this._value = [], this._userInfoMessage = "", this._addValueText = null, this._maxIsReached = !1, this._search = "", this._inputFocus = !1, this._editingSingleValue = !1, this.inputRef = _(), this.arrowRef = _(), this.listboxRef = _(), this.focusRef = _(), this.optionTagRef = _(), this.optionsController = new S(this), this.slotController = new C(this, this.helptextSlot), this.slotController.skipOptions = !0;
29
29
  }
30
30
  // Lifecycle methods
31
31
  connectedCallback() {
@@ -34,7 +34,7 @@ let h = class extends V {
34
34
  this._isOptionsOpen && !this.contains(e.target) && this.handleFocusOut(e);
35
35
  }), this._options = [], this.defaultOptions && this.defaultOptions.length) {
36
36
  const e = ((t = this.options) == null ? void 0 : t.filter((i) => i.userAdded)) || [];
37
- this.options = [...e, ...structuredClone(this.defaultOptions)], this._options = [...this.options];
37
+ this.options = [...e, ...JSON.parse(JSON.stringify(this.defaultOptions))], this._options = [...this.options];
38
38
  }
39
39
  if (this.optionsController.nodes.length) {
40
40
  const e = [];
@@ -52,7 +52,7 @@ let h = class extends V {
52
52
  var e;
53
53
  if (t.has("_value") && this.valueChanged(this._value, t.get("_value")), t.has("value") && (this._value = Array.isArray(this.value) ? this.value : this.value ? this.value.split(",") : [], !this.multiple && this._value.length > 1 && (this._value = [this._value[0]]), this.isMaxItemsReached()), t.has("defaultOptions") && this.defaultOptions.length) {
54
54
  const i = ((e = this.options) == null ? void 0 : e.filter((s) => s.userAdded)) || [];
55
- this.options = [...i, ...structuredClone(this.defaultOptions)], this._options = [...this.options];
55
+ this.options = [...i, ...JSON.parse(JSON.stringify(this.defaultOptions))], this._options = [...this.options];
56
56
  }
57
57
  if (t.has("options") && this.options.length) {
58
58
  const s = this._options.filter((l) => l.userAdded).filter(
@@ -371,12 +371,12 @@ let h = class extends V {
371
371
  return t ? this._maxIsReached = !0 : this._maxIsReached = !1, t;
372
372
  }
373
373
  toggleValue(t) {
374
- var I, O;
374
+ var $, I;
375
375
  if (this.disabled) return;
376
376
  this.touched = !0, this._userInfoMessage = "", this._addValueText = null;
377
- const e = ((I = this.findValueInOptions(t)) == null ? void 0 : I.value) || null, i = this._value.includes(t || e || ""), s = !!e, l = ((O = this._options.find((m) => m.value === t)) == null ? void 0 : O.disabled) || !1, n = !(t != null && t.trim()), a = !this.multiple, u = this.multiple, $ = this.isMaxItemsReached();
377
+ const e = (($ = this.findValueInOptions(t)) == null ? void 0 : $.value) || null, i = this._value.includes(t || e || ""), s = !!e, l = ((I = this._options.find((m) => m.value === t)) == null ? void 0 : I.disabled) || !1, n = !(t != null && t.trim()), a = !this.multiple, u = this.multiple, O = this.isMaxItemsReached();
378
378
  let p = !1, b = !0, g = "", x = "";
379
- l || (!s && this.allowUserInput && !n ? (this.addNewUserValue(t), g = "Ny verdi lagt til", p = !u) : !s && !this.allowUserInput ? (a && this._value[0] && this.removeValue(this._value[0]), b = !1, p = !0, g = "Ingen treff i søket") : i ? (this.removeValue(e), p = !0) : n && a ? (this.removeAllSelected(), p = !0) : a ? (this._value[0] && this.removeSelected(this._value[0]), this.setSelected(e), p = !1, this.inputRef.value && this.inputRef.value.type !== "hidden" && (this.inputRef.value.value = "", this.inputRef.value.blur())) : u && !$ ? (this.setSelected(e), p = !0) : u && $ ? (this._userInfoMessage = "Maks antall valg nådd", b = !1, x = t) : (a && this.removeAllSelected(), this._userInfoMessage = "Ingen gyldig verdi valgt", b = !1, p = !0, x = t), this._isOptionsOpen = p, p || window.setTimeout(() => {
379
+ l || (!s && this.allowUserInput && !n ? (this.addNewUserValue(t), g = "Ny verdi lagt til", p = !u) : !s && !this.allowUserInput ? (a && this._value[0] && this.removeValue(this._value[0]), b = !1, p = !0, g = "Ingen treff i søket") : i ? (this.removeValue(e), p = !0) : n && a ? (this.removeAllSelected(), p = !0) : a ? (this._value[0] && this.removeSelected(this._value[0]), this.setSelected(e), p = !1, this.inputRef.value && this.inputRef.value.type !== "hidden" && (this.inputRef.value.value = "", this.inputRef.value.blur())) : u && !O ? (this.setSelected(e), p = !0) : u && O ? (this._userInfoMessage = "Maks antall valg nådd", b = !1, x = t) : (a && this.removeAllSelected(), this._userInfoMessage = "Ingen gyldig verdi valgt", b = !1, p = !0, x = t), this._isOptionsOpen = p, p || window.setTimeout(() => {
380
380
  var m;
381
381
  (m = this.focusRef.value) == null || m.focus();
382
382
  }, 0), this._userInfoMessage = g, this._search = x || "", this.resetComboboxInput(b), u && this.isMaxItemsReached());
@@ -0,0 +1,11 @@
1
+ "use strict";const o=require("./element-90YeMNbV.cjs");require("./button-KzBZ-Bff.cjs");require("./icon-B1_BRNqf.cjs");const k={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 d=Object.defineProperty,p=Object.getOwnPropertyDescriptor,s=(r,e,t,n)=>{for(var i=n>1?void 0:n?p(e,t):e,a=r.length-1,l;a>=0;a--)(l=r[a])&&(i=(n?l(e,t,i):l(i))||i);return n&&i&&d(e,t,i),i};let c=null;function u(){return c||(c=new Promise((r,e)=>{if(document.querySelector("#oslo-consent-script")){r();return}const t=document.createElement("script");t.src="https://cdn.web.oslo.kommune.no/cb/cb-v1.1.0.js",t.id="oslo-consent-script",t.onload=()=>r(),t.onerror=e,document.head.appendChild(t);const n=document.createElement("link");n.href="https://cdn.web.oslo.kommune.no/cb/cb-v1.1.0.css",n.type="text/css",n.rel="stylesheet",n.id="oslo-consent-styles",document.head.appendChild(n)}),c)}exports.PktConsent=class extends o.PktElement{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||k.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((i,a)=>(i[a.name]=a.consent,i),{});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 u(),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=i=>{this.emitCookieConsents(i)},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"?o.x`<a href="#" class="pkt-link" @click=${this.openModal}>${this.triggerText}</a>`:this.triggerType==="footerlink"?o.x`<a href="#" class="pkt-footer__link" @click=${this.openModal}>
2
+ <pkt-icon name="chevron-right" class="pkt-footer__link-icon"></pkt-icon>
3
+ ${this.triggerText}
4
+ </a>`:this.triggerType==="icon"?o.x`<pkt-button
5
+ skin="tertiary"
6
+ variant="icon-only"
7
+ iconName="cookie"
8
+ @click=${this.openModal}
9
+ >
10
+ >${this.triggerText}</pkt-button
11
+ >`:o.x`<pkt-button @click=${this.openModal}>${this.triggerText}</pkt-button>`}};s([o.n({type:Boolean})],exports.PktConsent.prototype,"devMode",2);s([o.n({type:String})],exports.PktConsent.prototype,"hotjarId",2);s([o.n({type:String})],exports.PktConsent.prototype,"googleAnalyticsId",2);s([o.n({type:String})],exports.PktConsent.prototype,"cookieDomain",2);s([o.n({type:String})],exports.PktConsent.prototype,"cookieSecure",2);s([o.n({type:String})],exports.PktConsent.prototype,"cookieExpiryDays",2);s([o.n({type:String})],exports.PktConsent.prototype,"triggerType",2);s([o.n({type:String})],exports.PktConsent.prototype,"triggerText",2);s([o.n({type:String})],exports.PktConsent.prototype,"i18nLanguage",2);exports.PktConsent=s([o.t("pkt-consent")],exports.PktConsent);
@@ -1,7 +1,7 @@
1
- import { P as k, x as l, n as a, a as u } from "./element-gAd63VwC.js";
1
+ import { P as p, x as c, n as a, a as g } from "./element-gAd63VwC.js";
2
2
  import "./button-OLSvT2Im.js";
3
3
  import "./icon-CO1TLSs5.js";
4
- const h = {
4
+ const u = {
5
5
  i18n: {
6
6
  nb: {
7
7
  contentPresentation: {
@@ -53,39 +53,35 @@ const h = {
53
53
  }
54
54
  }
55
55
  }
56
- }, g = globalThis, p = g.__cookieEvents || {
57
- events: {},
58
- on(e, t) {
59
- this.events[e] || (this.events[e] = []), this.events[e].push(t);
60
- },
61
- off(e, t) {
62
- this.events[e] && (this.events[e] = this.events[e].filter((n) => n !== t));
63
- },
64
- once(e, t) {
65
- const n = (s) => {
66
- this.off(e, n), t(s);
67
- };
68
- this.on(e, n);
69
- },
70
- emit(e, t) {
71
- this.events[e] && this.events[e].forEach((n) => n(t));
72
- }
73
56
  };
74
- g.__cookieEvents = p;
75
- const m = p;
76
- var f = Object.defineProperty, v = Object.getOwnPropertyDescriptor, r = (e, t, n, s) => {
77
- for (var o = s > 1 ? void 0 : s ? v(t, n) : t, c = e.length - 1, d; c >= 0; c--)
78
- (d = e[c]) && (o = (s ? d(t, n, o) : d(o)) || o);
79
- return s && o && f(t, n, o), o;
57
+ var h = Object.defineProperty, m = Object.getOwnPropertyDescriptor, r = (e, t, n, o) => {
58
+ for (var s = o > 1 ? void 0 : o ? m(t, n) : t, k = e.length - 1, d; k >= 0; k--)
59
+ (d = e[k]) && (s = (o ? d(t, n, s) : d(s)) || s);
60
+ return o && s && h(t, n, s), s;
80
61
  };
81
- let i = class extends k {
62
+ let l = null;
63
+ function f() {
64
+ return l || (l = new Promise((e, t) => {
65
+ if (document.querySelector("#oslo-consent-script")) {
66
+ e();
67
+ return;
68
+ }
69
+ const n = document.createElement("script");
70
+ 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);
71
+ const o = document.createElement("link");
72
+ 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);
73
+ }), l);
74
+ }
75
+ let i = class extends p {
82
76
  constructor() {
83
- super(), this.hotjarId = null, this.googleAnalyticsId = null, this.triggerType = "button", this.triggerText = null, this.i18nLanguage = "nb";
77
+ 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";
84
78
  }
85
79
  connectedCallback() {
86
- super.connectedCallback(), this.triggerText = this.triggerText || h.i18n[this.i18nLanguage].contentPresentation.buttons.settings, this.googleAnalyticsId && (window.googleAnalyticsId = this.googleAnalyticsId), this.hotjarId && (window.hotjarId = this.hotjarId), m.on("CookieManager.setCookie", (e) => {
87
- this.emitCookieConsents(e);
88
- });
80
+ super.connectedCallback(), this.triggerText = this.triggerText || u.i18n[this.i18nLanguage].contentPresentation.buttons.settings;
81
+ }
82
+ disconnectedCallback() {
83
+ var e;
84
+ super.disconnectedCallback(), this._cookieEventHandler && ((e = window.__cookieEvents) == null || e.off("CookieManager.setCookie", this._cookieEventHandler));
89
85
  }
90
86
  returnJsonOrObject(e) {
91
87
  let t;
@@ -97,62 +93,69 @@ let i = class extends k {
97
93
  return t;
98
94
  }
99
95
  emitCookieConsents(e) {
100
- const n = this.returnJsonOrObject(e.value).items.reduce((s, o) => (s[o.name] = o.consent, s), {});
96
+ const n = this.returnJsonOrObject(e.value).items.reduce((o, s) => (o[s.name] = s.consent, o), {});
101
97
  this.dispatchEvent(
102
98
  new CustomEvent("toggle-consent", {
103
99
  detail: n,
104
100
  bubbles: !0,
105
- composed: !0
101
+ cancelable: !1
106
102
  })
107
103
  );
108
104
  }
109
- firstUpdated(e) {
110
- if (!document.querySelector("#oslo-consent-script") && window.location.hostname.toLowerCase().includes("oslo.kommune.no")) {
111
- window.googleAnalyticsId = this.googleAnalyticsId, window.hotjarId = this.hotjarId;
112
- const t = document.createElement("script");
113
- t.src = "https://cdn.web.oslo.kommune.no/cb/cb-v1.0.0.js", t.id = "oslo-consent-script", t.onload = () => {
114
- this.triggerInit();
115
- }, document.head.appendChild(t);
116
- const n = document.createElement("link");
117
- n.href = "https://cdn.web.oslo.kommune.no/cb/cb-v1.0.0.css", n.type = "text/css", n.rel = "stylesheet", n.id = "oslo-consent-styles", document.head.appendChild(n);
118
- }
105
+ async firstUpdated(e) {
106
+ 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();
119
107
  }
120
108
  triggerInit() {
121
109
  window.document.dispatchEvent(
122
- new Event("DOMContentLoaded", {
110
+ new Event("CookieBannerReady", {
123
111
  bubbles: !0,
124
112
  cancelable: !0
125
113
  })
126
114
  ), window.cookieBanner.cookieConsent.validateConsentCookie().then((e) => {
127
115
  if (e) {
128
116
  const n = { value: window.cookieBanner.cookieConsent.getConsentCookie() };
129
- this.emitCookieConsents(n);
117
+ window.setTimeout(() => this.emitCookieConsents(n), 0), this._cookieEventHandler && window.__cookieEvents.off("CookieManager.setCookie", this._cookieEventHandler), this._cookieEventHandler = (o) => {
118
+ this.emitCookieConsents(o);
119
+ }, window.__cookieEvents.on("CookieManager.setCookie", this._cookieEventHandler);
130
120
  }
131
121
  });
132
122
  }
133
123
  openModal(e) {
134
- e.preventDefault(), window.cookieBanner.cookieConsent || this.triggerInit(), setTimeout(() => window.cookieBanner.openCookieModal());
124
+ var t;
125
+ e.preventDefault(), (t = window.cookieBanner) != null && t.cookieConsent || this.triggerInit(), setTimeout(() => window.cookieBanner.openCookieModal());
135
126
  }
136
127
  render() {
137
- return this.triggerType === "link" ? l`<a href="#" class="pkt-link" @click=${this.openModal}>${this.triggerText}</a>` : this.triggerType === "footerlink" ? l`<a href="#" class="pkt-footer__link" @click=${this.openModal}>
128
+ 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}>
138
129
  <pkt-icon name="chevron-right" class="pkt-footer__link-icon"></pkt-icon>
139
130
  ${this.triggerText}
140
- </a>` : this.triggerType === "icon" ? l`<pkt-button
131
+ </a>` : this.triggerType === "icon" ? c`<pkt-button
141
132
  skin="tertiary"
142
133
  variant="icon-only"
143
134
  iconName="cookie"
144
135
  @click=${this.openModal}
145
136
  >
146
137
  >${this.triggerText}</pkt-button
147
- >` : l`<pkt-button @click=${this.openModal}>${this.triggerText}</pkt-button>`;
138
+ >` : c`<pkt-button @click=${this.openModal}>${this.triggerText}</pkt-button>`;
148
139
  }
149
140
  };
141
+ r([
142
+ a({ type: Boolean })
143
+ ], i.prototype, "devMode", 2);
150
144
  r([
151
145
  a({ type: String })
152
146
  ], i.prototype, "hotjarId", 2);
153
147
  r([
154
148
  a({ type: String })
155
149
  ], i.prototype, "googleAnalyticsId", 2);
150
+ r([
151
+ a({ type: String })
152
+ ], i.prototype, "cookieDomain", 2);
153
+ r([
154
+ a({ type: String })
155
+ ], i.prototype, "cookieSecure", 2);
156
+ r([
157
+ a({ type: String })
158
+ ], i.prototype, "cookieExpiryDays", 2);
156
159
  r([
157
160
  a({ type: String })
158
161
  ], i.prototype, "triggerType", 2);
@@ -163,7 +166,7 @@ r([
163
166
  a({ type: String })
164
167
  ], i.prototype, "i18nLanguage", 2);
165
168
  i = r([
166
- u("pkt-consent")
169
+ g("pkt-consent")
167
170
  ], i);
168
171
  export {
169
172
  i as P
package/dist/index.d.ts CHANGED
@@ -187,8 +187,13 @@ export declare interface IPktComboboxOption {
187
187
  }
188
188
 
189
189
  export declare interface IPktConsent {
190
+ devMode?: boolean;
191
+ cookieDomain?: string | null;
192
+ cookieSecure?: string | null;
193
+ cookieExpiryDays?: string | null;
190
194
  hotjarId?: string | null;
191
195
  googleAnalyticsId?: string | null;
196
+ i18nLanguage?: string;
192
197
  triggerType?: 'button' | 'link' | 'footerlink' | 'icon' | null;
193
198
  triggerText?: string | null;
194
199
  }
@@ -615,16 +620,22 @@ export declare class PktComponent extends PktElement {
615
620
  }
616
621
 
617
622
  export declare class PktConsent extends PktElement<IPktConsent> implements IPktConsent {
623
+ private _cookieEventHandler?;
624
+ devMode: boolean;
618
625
  hotjarId: string | null;
619
626
  googleAnalyticsId: string | null;
627
+ cookieDomain: string | null;
628
+ cookieSecure: string | null;
629
+ cookieExpiryDays: string | null;
620
630
  triggerType: 'button' | 'link' | 'footerlink' | 'icon' | null;
621
631
  triggerText: string | null;
622
632
  i18nLanguage: string;
623
633
  constructor();
624
634
  connectedCallback(): void;
635
+ disconnectedCallback(): void;
625
636
  returnJsonOrObject(obj: any): any;
626
637
  emitCookieConsents(consent: any): void;
627
- protected firstUpdated(_changedProperties: PropertyValues): void;
638
+ protected firstUpdated(_changedProperties: PropertyValues): Promise<void>;
628
639
  triggerInit(): void;
629
640
  openModal(e: Event): void;
630
641
  render(): TemplateResult<1>;
@@ -1234,6 +1245,7 @@ export declare type TSelectOption = {
1234
1245
  label: string;
1235
1246
  selected?: boolean;
1236
1247
  disabled?: boolean;
1248
+ hidden?: boolean;
1237
1249
  };
1238
1250
 
1239
1251
  export declare type TTagSkin = 'blue' | 'blue-dark' | 'blue-light' | 'green' | 'red' | 'yellow' | 'beige' | 'gray' | 'grey';
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./combobox-BxW5wREE.cjs"),o=e.PktCombobox;Object.defineProperty(exports,"PktCombobox",{enumerable:!0,get:()=>e.PktCombobox});exports.default=o;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./combobox-CZJrOopi.cjs"),o=e.PktCombobox;Object.defineProperty(exports,"PktCombobox",{enumerable:!0,get:()=>e.PktCombobox});exports.default=o;
@@ -1,4 +1,4 @@
1
- import { P as o } from "./combobox-C57pmfdV.js";
1
+ import { P as o } from "./combobox-hYeZxIku.js";
2
2
  const b = o;
3
3
  export {
4
4
  o as PktCombobox,
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./consent-D1r9LYda.cjs"),t=e.PktConsent;Object.defineProperty(exports,"PktConsent",{enumerable:!0,get:()=>e.PktConsent});exports.default=t;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./consent-B7w1--m7.cjs"),t=e.PktConsent;Object.defineProperty(exports,"PktConsent",{enumerable:!0,get:()=>e.PktConsent});exports.default=t;
@@ -1,4 +1,4 @@
1
- import { P as t } from "./consent-a09DlJZT.js";
1
+ import { P as t } from "./consent-ChCTj6FB.js";
2
2
  const o = t;
3
3
  export {
4
4
  t as PktConsent,
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("./alert-BY97zZYx.cjs"),l=require("./accordionitem-Dz6jwPpb.cjs"),d=require("./backlink-CcAZfB1d.cjs"),b=require("./button-KzBZ-Bff.cjs"),k=require("./calendar-D4qfcRtv.cjs"),m=require("./card-CmdIb2X9.cjs"),g=require("./combobox-BxW5wREE.cjs"),h=require("./consent-D1r9LYda.cjs"),f=require("./checkbox-CiXWukkL.cjs"),t=require("./element-90YeMNbV.cjs"),y=require("./pkt-slot-controller-Da-RgXfS.cjs"),s=require("./ref-B-w1vCo8.cjs"),O=require("./class-map-DWDPOqjO.cjs"),j=require("./datepicker-CE5oM9D3.cjs"),q=require("./helptext-AqNI_oFG.cjs"),x=require("./heading-CxJ0IqpU.cjs"),C=require("./icon-B1_BRNqf.cjs"),v=require("./input-wrapper-Uw7_cZ4w.cjs"),S=require("./link-BWJrqWi7.cjs"),$=require("./linkcard-0KLDuaGM.cjs"),L=require("./loader--5h6NKGl.cjs"),_=require("./messagebox-IJOkv427.cjs"),A=require("./modal-CBURcXBd.cjs"),B=require("./progressbar-BrXtjUvh.cjs"),p=require("./radiobutton-x10h-JEh.cjs"),T=require("./tag-lU4vz70a.cjs"),I=require("./textarea-DcpZnWkt.cjs"),M=require("./textinput-DcES1ibY.cjs"),R=require("./select-BkwZL7mg.cjs");var H=Object.defineProperty,w=Object.getOwnPropertyDescriptor,o=(a,e,r,i)=>{for(var n=i>1?void 0:i?w(e,r):e,u=a.length-1,c;u>=0;u--)(c=a[u])&&(n=(i?c(e,r,n):c(n))||n);return i&&n&&H(e,r,n),n};exports.PktComponent=class extends t.PktElement{constructor(){super(),this.string="",this.strings=[],this.darkmode=!1,this._list=[],this.defaultSlot=s.e(),this.namedSlot=s.e(),this.slotController=new y.PktSlotController(this,this.defaultSlot,this.namedSlot)}connectedCallback(){this.strings.length&&this.strings.forEach(e=>{this._list.push(e.toUpperCase())}),super.connectedCallback()}render(){const e={"pkt-component":!0,"pkt-component--has-list":this.strings.length>0,"pkt-darkmode":this.darkmode};return t.x`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("./alert-BY97zZYx.cjs"),l=require("./accordionitem-Dz6jwPpb.cjs"),d=require("./backlink-CcAZfB1d.cjs"),b=require("./button-KzBZ-Bff.cjs"),k=require("./calendar-D4qfcRtv.cjs"),m=require("./card-CmdIb2X9.cjs"),g=require("./combobox-CZJrOopi.cjs"),h=require("./consent-B7w1--m7.cjs"),f=require("./checkbox-CiXWukkL.cjs"),t=require("./element-90YeMNbV.cjs"),y=require("./pkt-slot-controller-Da-RgXfS.cjs"),s=require("./ref-B-w1vCo8.cjs"),O=require("./class-map-DWDPOqjO.cjs"),j=require("./datepicker-CE5oM9D3.cjs"),q=require("./helptext-AqNI_oFG.cjs"),x=require("./heading-CxJ0IqpU.cjs"),C=require("./icon-B1_BRNqf.cjs"),v=require("./input-wrapper-Uw7_cZ4w.cjs"),S=require("./link-BWJrqWi7.cjs"),$=require("./linkcard-0KLDuaGM.cjs"),L=require("./loader--5h6NKGl.cjs"),_=require("./messagebox-IJOkv427.cjs"),A=require("./modal-CBURcXBd.cjs"),B=require("./progressbar-BrXtjUvh.cjs"),p=require("./radiobutton-x10h-JEh.cjs"),T=require("./tag-lU4vz70a.cjs"),I=require("./textarea-DcpZnWkt.cjs"),M=require("./textinput-DcES1ibY.cjs"),R=require("./select-BNGnC2U9.cjs");var H=Object.defineProperty,w=Object.getOwnPropertyDescriptor,o=(a,e,r,i)=>{for(var n=i>1?void 0:i?w(e,r):e,u=a.length-1,c;u>=0;u--)(c=a[u])&&(n=(i?c(e,r,n):c(n))||n);return i&&n&&H(e,r,n),n};exports.PktComponent=class extends t.PktElement{constructor(){super(),this.string="",this.strings=[],this.darkmode=!1,this._list=[],this.defaultSlot=s.e(),this.namedSlot=s.e(),this.slotController=new y.PktSlotController(this,this.defaultSlot,this.namedSlot)}connectedCallback(){this.strings.length&&this.strings.forEach(e=>{this._list.push(e.toUpperCase())}),super.connectedCallback()}render(){const e={"pkt-component":!0,"pkt-component--has-list":this.strings.length>0,"pkt-darkmode":this.darkmode};return t.x`
2
2
  <div class="${O.e(e)}">
3
3
  <h1 class="pkt-txt-28">${this.string}</h1>
4
4
 
package/dist/pkt-index.js CHANGED
@@ -5,8 +5,8 @@ import { P as T } from "./button-OLSvT2Im.js";
5
5
  import { c as f } from "./calendar-Df6-FDRW.js";
6
6
  import { P as D } from "./calendar-Df6-FDRW.js";
7
7
  import { P as G } from "./card-BxHlJq4J.js";
8
- import { P as K } from "./combobox-C57pmfdV.js";
9
- import { P as U } from "./consent-a09DlJZT.js";
8
+ import { P as K } from "./combobox-hYeZxIku.js";
9
+ import { P as U } from "./consent-ChCTj6FB.js";
10
10
  import { P as q } from "./checkbox-B67_cfqW.js";
11
11
  import { P as k, t as h, x as P, n, a as c } from "./element-gAd63VwC.js";
12
12
  import { P as x } from "./pkt-slot-controller-DtDaD9q_.js";
@@ -27,7 +27,7 @@ import { P as ht, P as ct } from "./radiobutton-BaIDDCwK.js";
27
27
  import { P as ut } from "./tag-CX-zbR-7.js";
28
28
  import { P as vt } from "./textarea-CctE69uw.js";
29
29
  import { P as bt } from "./textinput-BAPxDvKu.js";
30
- import { P as $t } from "./select-BIej9f9R.js";
30
+ import { P as $t } from "./select-Drl_8-OU.js";
31
31
  var g = Object.defineProperty, v = Object.getOwnPropertyDescriptor, s = (t, e, i, a) => {
32
32
  for (var r = a > 1 ? void 0 : a ? v(e, i) : e, p = t.length - 1, l; p >= 0; p--)
33
33
  (l = t[p]) && (r = (a ? l(e, i, r) : l(r)) || r);
@@ -1,5 +1,5 @@
1
1
  import { i as o } from "./pkt-slot-controller-DtDaD9q_.js";
2
- class a {
2
+ class d {
3
3
  constructor(t) {
4
4
  this.nodes = [], this.options = [], this.host = t, this.host.addController(this), this.nodes = [], this.options = [], this.observer = new MutationObserver((e) => this.handleMutations(e));
5
5
  }
@@ -12,14 +12,15 @@ class a {
12
12
  this.observer.disconnect();
13
13
  }
14
14
  addNode(t) {
15
- (t.nodeName === "OPTION" || t.nodeName === "DATA") && (t.setAttribute("class", "pkt-hide"), t.setAttribute("hidden", "true"), t.setAttribute("data-skip", "true"), this.nodes.push(t));
15
+ (t.nodeName === "OPTION" || t.nodeName === "DATA") && (t.setAttribute("class", "pkt-hide"), t.setAttribute("role", "presentation"), t.setAttribute("aria-hidden", "true"), t.setAttribute("data-skip", "true"), this.nodes.push(t));
16
16
  }
17
17
  createOptions() {
18
18
  this.options = this.nodes.map((t) => ({
19
- value: t.getAttribute("value") || t.textContent || "",
19
+ value: t.hasAttribute("value") ? t.getAttribute("value") ?? "" : t.textContent ?? "",
20
20
  label: t.textContent || t.getAttribute("value") || "",
21
- selected: !!t.getAttribute("selected"),
22
- disabled: !!t.getAttribute("disabled")
21
+ selected: t.hasAttribute("selected"),
22
+ disabled: t.hasAttribute("disabled"),
23
+ hidden: t.hasAttribute("hidden")
23
24
  })), this.host.setAttribute("options", JSON.stringify(this.options));
24
25
  }
25
26
  handleMutations(t) {
@@ -34,5 +35,5 @@ class a {
34
35
  }
35
36
  }
36
37
  export {
37
- a as P
38
+ d as P
38
39
  };
@@ -0,0 +1 @@
1
+ "use strict";const o=require("./pkt-slot-controller-Da-RgXfS.cjs");class h{constructor(t){this.nodes=[],this.options=[],this.host=t,this.host.addController(this),this.nodes=[],this.options=[],this.observer=new MutationObserver(e=>this.handleMutations(e))}hostConnected(){Array.from(this.host.childNodes).forEach(t=>{(t.nodeName==="OPTION"||t.nodeName==="DATA")&&this.addNode(t)}),this.observer.observe(this.host,{childList:!0})}hostDisconnected(){this.observer.disconnect()}addNode(t){(t.nodeName==="OPTION"||t.nodeName==="DATA")&&(t.setAttribute("class","pkt-hide"),t.setAttribute("role","presentation"),t.setAttribute("aria-hidden","true"),t.setAttribute("data-skip","true"),this.nodes.push(t))}createOptions(){this.options=this.nodes.map(t=>({value:t.hasAttribute("value")?t.getAttribute("value")??"":t.textContent??"",label:t.textContent||t.getAttribute("value")||"",selected:t.hasAttribute("selected"),disabled:t.hasAttribute("disabled"),hidden:t.hasAttribute("hidden")})),this.host.setAttribute("options",JSON.stringify(this.options))}handleMutations(t){let e=!1;t.forEach(i=>{i.type==="childList"&&(i.addedNodes.forEach(s=>{o.isOptionElement(s)&&(this.addNode(s),e=!0)}),i.removedNodes.forEach(s=>{o.isOptionElement(s)&&(this.nodes=this.nodes.filter(r=>r!==s),e=!0)}))}),e&&this.createOptions()}}exports.PktOptionsSlotController=h;
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./select-BkwZL7mg.cjs"),t=e.PktSelect;Object.defineProperty(exports,"PktSelect",{enumerable:!0,get:()=>e.PktSelect});exports.default=t;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./select-BNGnC2U9.cjs"),t=e.PktSelect;Object.defineProperty(exports,"PktSelect",{enumerable:!0,get:()=>e.PktSelect});exports.default=t;
@@ -1,4 +1,4 @@
1
- import { P as t } from "./select-BIej9f9R.js";
1
+ import { P as t } from "./select-Drl_8-OU.js";
2
2
  const a = t;
3
3
  export {
4
4
  t as PktSelect,
@@ -1,4 +1,4 @@
1
- "use strict";const r=require("./element-90YeMNbV.cjs"),p=require("./state-D-Recv7U.cjs"),h=require("./ref-B-w1vCo8.cjs"),o=require("./if-defined-C8eotHpL.cjs"),d=require("./input-element-CInrWeac.cjs"),c=require("./pkt-options-controller-Ay9ELZTV.cjs"),v=require("./pkt-slot-controller-Da-RgXfS.cjs");require("./input-wrapper-Uw7_cZ4w.cjs");var f=Object.defineProperty,b=Object.getOwnPropertyDescriptor,a=(u,t,e,s)=>{for(var i=s>1?void 0:s?b(t,e):t,l=u.length-1,n;l>=0;l--)(n=u[l])&&(i=(s?n(t,e,i):n(i))||i);return s&&i&&f(t,e,i),i};exports.PktSelect=class extends d.PktInputElement{constructor(){super(),this.inputRef=h.e(),this.helptextSlot=h.e(),this.options=[],this.value="",this._options=[],this.selectedIndex=-1,this.selectedOptions=void 0,this.optionsController=new c.PktOptionsSlotController(this),this.slotController=new v.PktSlotController(this,this.helptextSlot),this.slotController.skipOptions=!0}connectedCallback(){super.connectedCallback();const t=this.options.length>0,e=this.optionsController.nodes.length&&this.optionsController.nodes.length>0;!t&&e?this.optionsController.nodes.forEach(s=>{const i={value:s.getAttribute("value")||s.textContent||"",label:s.textContent||s.getAttribute("value")||"",disabled:!!s.getAttribute("disabled")};s.getAttribute("selected")&&!this.value&&(this.value=i.value),this._options.push(i)}):(this._options=this.options,this._options.forEach(s=>{s.selected&&!this.value&&(this.value=s.value)}))}add(t,e){var s,i,l;(s=this.inputRef.value)==null||s.add(t,e),this._options.push({value:t.value||t.text,label:t.text||t.value,selected:t.selected,disabled:t.disabled}),t.selected&&(this.value=t.value||t.text,this.selectedIndex=this.returnNumberOrNull((i=this.inputRef.value)==null?void 0:i.selectedIndex),this.selectedOptions=(l=this.inputRef.value)==null?void 0:l.selectedOptions),this.requestUpdate()}remove(t){var e,s;typeof t=="number"&&(this.selectedIndex===t&&(this.value=((e=this._options[0])==null?void 0:e.value)||""),(s=this.inputRef.value)==null||s.remove(t))}item(t){var e;return(e=this.inputRef.value)==null?void 0:e.item(t)}namedItem(t){var e;return(e=this.inputRef.value)==null?void 0:e.namedItem(t)}showPicker(){var t;(t=this.inputRef.value)==null||t.showPicker()}attributeChangedCallback(t,e,s){var i,l;t==="options"&&(this._options=s?JSON.parse(s):[]),t==="value"&&this.value!==e&&(this.selectedIndex=this.touched?this.returnNumberOrNull((i=this.inputRef.value)==null?void 0:i.selectedIndex):this.options.findIndex(n=>n.value===s),this.selectedOptions=(l=this.inputRef.value)==null?void 0:l.selectedOptions,this.valueChanged(s,e)),super.attributeChangedCallback(t,e,s)}update(t){var e,s;super.update(t),t.has("value")&&this.value!==t.get("value")&&(this.selectedIndex=this.touched?this.returnNumberOrNull((e=this.inputRef.value)==null?void 0:e.selectedIndex):this.options.findIndex(i=>i.value===this.value),this.selectedOptions=(s=this.inputRef.value)==null?void 0:s.selectedOptions,this.valueChanged(this.value,t.get("value"))),t.has("id")&&!this.name&&this.id&&(this.name=this.id)}firstUpdated(t){var e;super.firstUpdated(t),this.options.length&&(this._options=this.options),!this.value&&this._options.length>0?(this.value=this._options[0].value,this.selectedIndex=0):this.selectedIndex=this._options.findIndex(s=>s.value===this.value),this.selectedOptions=(e=this.inputRef.value)==null?void 0:e.selectedOptions}render(){const t=`pkt-input ${this.fullwidth?"pkt-input--fullwidth":""}`;return r.x`
1
+ "use strict";const r=require("./element-90YeMNbV.cjs"),p=require("./state-D-Recv7U.cjs"),h=require("./ref-B-w1vCo8.cjs"),o=require("./if-defined-C8eotHpL.cjs"),d=require("./input-element-CInrWeac.cjs"),c=require("./pkt-options-controller-ftMgG5DP.cjs"),v=require("./pkt-slot-controller-Da-RgXfS.cjs");require("./input-wrapper-Uw7_cZ4w.cjs");var f=Object.defineProperty,b=Object.getOwnPropertyDescriptor,a=(u,t,e,s)=>{for(var i=s>1?void 0:s?b(t,e):t,l=u.length-1,n;l>=0;l--)(n=u[l])&&(i=(s?n(t,e,i):n(i))||i);return s&&i&&f(t,e,i),i};exports.PktSelect=class extends d.PktInputElement{constructor(){super(),this.inputRef=h.e(),this.helptextSlot=h.e(),this.options=[],this.value="",this._options=[],this.selectedIndex=-1,this.selectedOptions=void 0,this.optionsController=new c.PktOptionsSlotController(this),this.slotController=new v.PktSlotController(this,this.helptextSlot),this.slotController.skipOptions=!0}connectedCallback(){super.connectedCallback();const t=this.options.length>0,e=this.optionsController.nodes.length&&this.optionsController.nodes.length>0;!t&&e?this.optionsController.nodes.forEach(s=>{const i={value:s.hasAttribute("value")?s.getAttribute("value")??"":s.textContent??"",label:s.textContent||s.getAttribute("value")||"",disabled:s.hasAttribute("disabled"),hidden:s.hasAttribute("hidden")};s.getAttribute("selected")&&!this.value&&(this.value=i.value),this._options.push(i)}):(this._options=this.options,this._options.forEach(s=>{s.selected&&!this.value&&(this.value=s.value)}))}add(t,e){var s,i,l;(s=this.inputRef.value)==null||s.add(t,e),this._options.push({value:t.value||t.text,label:t.text||t.value,selected:t.selected,disabled:t.disabled}),t.selected&&(this.value=t.value||t.text,this.selectedIndex=this.returnNumberOrNull((i=this.inputRef.value)==null?void 0:i.selectedIndex),this.selectedOptions=(l=this.inputRef.value)==null?void 0:l.selectedOptions),this.requestUpdate()}remove(t){var e,s;typeof t=="number"&&(this.selectedIndex===t&&(this.value=((e=this._options[0])==null?void 0:e.value)||""),(s=this.inputRef.value)==null||s.remove(t))}item(t){var e;return(e=this.inputRef.value)==null?void 0:e.item(t)}namedItem(t){var e;return(e=this.inputRef.value)==null?void 0:e.namedItem(t)}showPicker(){var t;(t=this.inputRef.value)==null||t.showPicker()}attributeChangedCallback(t,e,s){var i,l;t==="options"&&(this._options=s?JSON.parse(s):[]),t==="value"&&this.value!==e&&(this.selectedIndex=this.touched?this.returnNumberOrNull((i=this.inputRef.value)==null?void 0:i.selectedIndex):this.options.findIndex(n=>n.value===s),this.selectedOptions=(l=this.inputRef.value)==null?void 0:l.selectedOptions,this.valueChanged(s,e)),super.attributeChangedCallback(t,e,s)}update(t){var e,s;super.update(t),t.has("value")&&this.value!==t.get("value")&&(this.selectedIndex=this.touched?this.returnNumberOrNull((e=this.inputRef.value)==null?void 0:e.selectedIndex):this.options.findIndex(i=>i.value===this.value),this.selectedOptions=(s=this.inputRef.value)==null?void 0:s.selectedOptions,this.valueChanged(this.value,t.get("value"))),t.has("id")&&!this.name&&this.id&&(this.name=this.id)}firstUpdated(t){var e;super.firstUpdated(t),this.options.length&&(this._options=this.options),!this.value&&this._options.length>0?(this.value=this._options[0].value,this.selectedIndex=0):this.selectedIndex=this._options.findIndex(s=>s.value===this.value),this.selectedOptions=(e=this.inputRef.value)==null?void 0:e.selectedOptions}render(){const t=`pkt-input ${this.fullwidth?"pkt-input--fullwidth":""}`;return r.x`
2
2
  <pkt-input-wrapper
3
3
  ?counter=${this.counter}
4
4
  ?disabled=${this.disabled}
@@ -38,6 +38,7 @@
38
38
  value=${e.value}
39
39
  ?selected=${this.value==e.value||e.selected}
40
40
  ?disabled=${e.disabled}
41
+ ?hidden=${e.hidden}
41
42
  >
42
43
  ${e.label}
43
44
  </option>`)}
@@ -3,15 +3,15 @@ import { r as f } from "./state-BxrO4zNJ.js";
3
3
  import { e as u, n as d } from "./ref-DnSbnXsj.js";
4
4
  import { o } from "./if-defined-Cj-3Kdsr.js";
5
5
  import { P as b } from "./input-element-BEvaQK4g.js";
6
- import { P as $ } from "./pkt-options-controller-DepYQBqb.js";
6
+ import { P as $ } from "./pkt-options-controller-C_Yl_3P6.js";
7
7
  import { P as x } from "./pkt-slot-controller-DtDaD9q_.js";
8
8
  import "./input-wrapper-DnyRiuHR.js";
9
- var m = Object.defineProperty, g = Object.getOwnPropertyDescriptor, r = (t, e, s, i) => {
10
- for (var l = i > 1 ? void 0 : i ? g(e, s) : e, n = t.length - 1, h; n >= 0; n--)
11
- (h = t[n]) && (l = (i ? h(e, s, l) : h(l)) || l);
9
+ var m = Object.defineProperty, g = Object.getOwnPropertyDescriptor, a = (t, e, s, i) => {
10
+ for (var l = i > 1 ? void 0 : i ? g(e, s) : e, n = t.length - 1, r; n >= 0; n--)
11
+ (r = t[n]) && (l = (i ? r(e, s, l) : r(l)) || l);
12
12
  return i && l && m(e, s, l), l;
13
13
  };
14
- let a = class extends b {
14
+ let h = class extends b {
15
15
  constructor() {
16
16
  super(), this.inputRef = u(), this.helptextSlot = u(), this.options = [], this.value = "", this._options = [], this.selectedIndex = -1, this.selectedOptions = void 0, this.optionsController = new $(this), this.slotController = new x(this, this.helptextSlot), this.slotController.skipOptions = !0;
17
17
  }
@@ -21,9 +21,10 @@ let a = class extends b {
21
21
  const t = this.options.length > 0, e = this.optionsController.nodes.length && this.optionsController.nodes.length > 0;
22
22
  !t && e ? this.optionsController.nodes.forEach((s) => {
23
23
  const i = {
24
- value: s.getAttribute("value") || s.textContent || "",
24
+ value: s.hasAttribute("value") ? s.getAttribute("value") ?? "" : s.textContent ?? "",
25
25
  label: s.textContent || s.getAttribute("value") || "",
26
- disabled: !!s.getAttribute("disabled")
26
+ disabled: s.hasAttribute("disabled"),
27
+ hidden: s.hasAttribute("hidden")
27
28
  };
28
29
  s.getAttribute("selected") && !this.value && (this.value = i.value), this._options.push(i);
29
30
  }) : (this._options = this.options, this._options.forEach((s) => {
@@ -123,6 +124,7 @@ let a = class extends b {
123
124
  value=${e.value}
124
125
  ?selected=${this.value == e.value || e.selected}
125
126
  ?disabled=${e.disabled}
127
+ ?hidden=${e.hidden}
126
128
  >
127
129
  ${e.label}
128
130
  </option>`
@@ -136,18 +138,18 @@ let a = class extends b {
136
138
  return t == null || isNaN(t) ? null : t;
137
139
  }
138
140
  };
139
- r([
141
+ a([
140
142
  c({ type: Array })
141
- ], a.prototype, "options", 2);
142
- r([
143
+ ], h.prototype, "options", 2);
144
+ a([
143
145
  c({ type: String })
144
- ], a.prototype, "value", 2);
145
- r([
146
+ ], h.prototype, "value", 2);
147
+ a([
146
148
  f()
147
- ], a.prototype, "_options", 2);
148
- a = r([
149
+ ], h.prototype, "_options", 2);
150
+ h = a([
149
151
  v("pkt-select")
150
- ], a);
152
+ ], h);
151
153
  export {
152
- a as P
154
+ h as P
153
155
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oslokommune/punkt-elements",
3
- "version": "12.42.4",
3
+ "version": "12.42.6",
4
4
  "description": "Komponentbiblioteket til Punkt, et designsystem laget av Oslo Origo",
5
5
  "homepage": "https://punkt.oslo.kommune.no",
6
6
  "author": "Team Designsystem, Oslo Origo",
@@ -23,7 +23,6 @@
23
23
  "dependencies": {
24
24
  "@date-fns/tz": "^1.2.0",
25
25
  "@lit-labs/router": "^0.1.3",
26
- "@oslokommune/cookie-manager": "^1.1.0",
27
26
  "date-fns": "^4.1.0",
28
27
  "dialog-polyfill": "^0.5.6",
29
28
  "lit": "^3.3.0",
@@ -32,7 +31,7 @@
32
31
  },
33
32
  "devDependencies": {
34
33
  "@oslokommune/punkt-assets": "^12.39.2",
35
- "@oslokommune/punkt-css": "^12.42.4",
34
+ "@oslokommune/punkt-css": "^12.42.5",
36
35
  "sass": "^1.78.0",
37
36
  "typescript": "^5.6.2",
38
37
  "vite": "^5.4.18",
@@ -59,5 +58,5 @@
59
58
  "url": "https://github.com/oslokommune/punkt/issues"
60
59
  },
61
60
  "license": "MIT",
62
- "gitHead": "c1841153a3aec61d53b50b34c69ca74dd022d1ef"
61
+ "gitHead": "1d82a7a76a25908e1453c48520da98dfeeae19c2"
63
62
  }
@@ -124,7 +124,7 @@ export class PktCombobox extends PktInputElement implements IPktCombobox {
124
124
  // Deep clone defaultOptions into options, preserving userAdded options
125
125
  if (this.defaultOptions && this.defaultOptions.length) {
126
126
  const userAdded = this.options?.filter((opt) => opt.userAdded) || []
127
- this.options = [...userAdded, ...structuredClone(this.defaultOptions)]
127
+ this.options = [...userAdded, ...JSON.parse(JSON.stringify(this.defaultOptions))]
128
128
  this._options = [...this.options]
129
129
  }
130
130
 
@@ -171,7 +171,7 @@ export class PktCombobox extends PktInputElement implements IPktCombobox {
171
171
  // If defaultOptions changed, update options (preserving userAdded)
172
172
  if (changedProperties.has('defaultOptions') && this.defaultOptions.length) {
173
173
  const userAdded = this.options?.filter((opt) => opt.userAdded) || []
174
- this.options = [...userAdded, ...structuredClone(this.defaultOptions)]
174
+ this.options = [...userAdded, ...JSON.parse(JSON.stringify(this.defaultOptions))]
175
175
  this._options = [...this.options]
176
176
  }
177
177
 
@@ -2,30 +2,74 @@ import { customElement, property } from 'lit/decorators.js'
2
2
  import { html, PropertyValues } from 'lit'
3
3
  import { PktElement } from '@/base-elements/element'
4
4
  import { consentStrings } from './strings'
5
- import { CookieEvents } from '@oslokommune/cookie-manager'
6
5
  import '../button'
7
6
  import '../icon'
8
7
 
8
+ let consentScriptPromise: Promise<void> | null = null
9
+
10
+ function loadConsentScript(): Promise<void> {
11
+ if (consentScriptPromise) return consentScriptPromise
12
+
13
+ consentScriptPromise = new Promise((resolve, reject) => {
14
+ if (document.querySelector('#oslo-consent-script')) {
15
+ resolve()
16
+ return
17
+ }
18
+ const script = document.createElement('script')
19
+ script.src = 'https://cdn.web.oslo.kommune.no/cb/cb-v1.1.0.js'
20
+ script.id = 'oslo-consent-script'
21
+ script.onload = () => resolve()
22
+ script.onerror = reject
23
+ document.head.appendChild(script)
24
+
25
+ const styles = document.createElement('link')
26
+ styles.href = 'https://cdn.web.oslo.kommune.no/cb/cb-v1.1.0.css'
27
+ styles.type = 'text/css'
28
+ styles.rel = 'stylesheet'
29
+ styles.id = 'oslo-consent-styles'
30
+ document.head.appendChild(styles)
31
+ })
32
+
33
+ return consentScriptPromise
34
+ }
9
35
  // Extend the Window interface to include googleAnalyticsId
10
36
  declare global {
11
37
  interface Window {
12
- googleAnalyticsId?: string | null
13
- hotjarId?: string | null
38
+ cookieBanner_devMode?: boolean
39
+ cookieBanner_cookieDomain?: string | null
40
+ cookieBanner_cookieSecure?: string | null
41
+ cookieBanner_cookieExpiryDays?: string | null
42
+ cookieBanner_googleAnalyticsId?: string | null
43
+ cookieBanner_hotjarId?: string | null
14
44
  cookieBanner?: any
45
+ __cookieEvents?: any
15
46
  }
16
47
  }
17
48
 
18
49
  export interface IPktConsent {
50
+ devMode?: boolean
51
+ cookieDomain?: string | null
52
+ cookieSecure?: string | null
53
+ cookieExpiryDays?: string | null
19
54
  hotjarId?: string | null
20
55
  googleAnalyticsId?: string | null
56
+ i18nLanguage?: string
21
57
  triggerType?: 'button' | 'link' | 'footerlink' | 'icon' | null
22
58
  triggerText?: string | null
23
59
  }
24
60
 
25
61
  @customElement('pkt-consent')
26
62
  export class PktConsent extends PktElement<IPktConsent> implements IPktConsent {
63
+ private _cookieEventHandler?: (consent: any) => void
64
+
65
+ @property({ type: Boolean }) devMode: boolean = false
66
+
27
67
  @property({ type: String }) hotjarId: string | null = null
28
68
  @property({ type: String }) googleAnalyticsId: string | null = null
69
+ @property({ type: String }) cookieDomain: string | null = null
70
+ @property({ type: String }) cookieSecure: string | null = null
71
+ @property({ type: String }) cookieExpiryDays: string | null = null
72
+
29
73
  @property({ type: String }) triggerType: 'button' | 'link' | 'footerlink' | 'icon' | null =
30
74
  'button'
31
75
  @property({ type: String }) triggerText: string | null = null
@@ -41,17 +85,13 @@ export class PktConsent extends PktElement<IPktConsent> implements IPktConsent {
41
85
  this.triggerText ||
42
86
  consentStrings.i18n[this.i18nLanguage as keyof typeof consentStrings.i18n].contentPresentation
43
87
  .buttons.settings
88
+ }
44
89
 
45
- if (this.googleAnalyticsId) {
46
- window.googleAnalyticsId = this.googleAnalyticsId
90
+ disconnectedCallback() {
91
+ super.disconnectedCallback()
92
+ if (this._cookieEventHandler) {
93
+ window.__cookieEvents?.off('CookieManager.setCookie', this._cookieEventHandler)
47
94
  }
48
- if (this.hotjarId) {
49
- window.hotjarId = this.hotjarId
50
- }
51
-
52
- CookieEvents.on('CookieManager.setCookie', (consent: any) => {
53
- this.emitCookieConsents(consent)
54
- })
55
95
  }
56
96
 
57
97
  returnJsonOrObject(obj: any) {
@@ -71,44 +111,31 @@ export class PktConsent extends PktElement<IPktConsent> implements IPktConsent {
71
111
  acc[item.name] = item.consent
72
112
  return acc
73
113
  }, {})
114
+
74
115
  this.dispatchEvent(
75
116
  new CustomEvent('toggle-consent', {
76
117
  detail: consentDetails,
77
118
  bubbles: true,
78
- composed: true,
119
+ cancelable: false,
79
120
  }),
80
121
  )
81
122
  }
82
123
 
83
- protected firstUpdated(_changedProperties: PropertyValues): void {
84
- if (
85
- !document.querySelector('#oslo-consent-script') &&
86
- window.location.hostname.toLowerCase().includes('oslo.kommune.no')
87
- ) {
88
- window.googleAnalyticsId = this.googleAnalyticsId
89
- window.hotjarId = this.hotjarId
90
-
91
- const script = document.createElement('script')
92
- script.src = 'https://cdn.web.oslo.kommune.no/cb/cb-v1.0.0.js'
93
- script.id = 'oslo-consent-script'
94
- script.onload = () => {
95
- this.triggerInit()
96
- }
97
- document.head.appendChild(script)
98
-
99
- const styles = document.createElement('link')
100
- styles.href = 'https://cdn.web.oslo.kommune.no/cb/cb-v1.0.0.css'
101
- styles.type = 'text/css'
102
- styles.rel = 'stylesheet'
103
- styles.id = 'oslo-consent-styles'
104
- document.head.appendChild(styles)
105
- }
124
+ protected async firstUpdated(_changedProperties: PropertyValues): Promise<void> {
125
+ window.cookieBanner_googleAnalyticsId = this.googleAnalyticsId
126
+ window.cookieBanner_hotjarId = this.hotjarId
127
+ if (this.cookieDomain) window.cookieBanner_cookieDomain = this.cookieDomain
128
+ if (this.cookieSecure) window.cookieBanner_cookieSecure = this.cookieSecure
129
+ if (this.cookieExpiryDays) window.cookieBanner_cookieExpiryDays = this.cookieExpiryDays
130
+ if (this.devMode) window.cookieBanner_devMode = this.devMode
131
+
132
+ await loadConsentScript()
133
+ this.triggerInit()
106
134
  }
107
135
 
108
136
  triggerInit() {
109
- // Slight hack since we can't access the right methods to do this “properly”
110
137
  window.document.dispatchEvent(
111
- new Event('DOMContentLoaded', {
138
+ new Event('CookieBannerReady', {
112
139
  bubbles: true,
113
140
  cancelable: true,
114
141
  }),
@@ -118,14 +145,22 @@ export class PktConsent extends PktElement<IPktConsent> implements IPktConsent {
118
145
  if (response) {
119
146
  const cookie = window.cookieBanner.cookieConsent.getConsentCookie()
120
147
  const consents = { value: cookie }
121
- this.emitCookieConsents(consents)
148
+ window.setTimeout(() => this.emitCookieConsents(consents), 0)
149
+
150
+ if (this._cookieEventHandler) {
151
+ window.__cookieEvents.off('CookieManager.setCookie', this._cookieEventHandler)
152
+ }
153
+ this._cookieEventHandler = (consent: any) => {
154
+ this.emitCookieConsents(consent)
155
+ }
156
+ window.__cookieEvents.on('CookieManager.setCookie', this._cookieEventHandler)
122
157
  }
123
158
  })
124
159
  }
125
160
 
126
161
  openModal(e: Event) {
127
162
  e.preventDefault()
128
- if (!window.cookieBanner.cookieConsent) {
163
+ if (!window.cookieBanner?.cookieConsent) {
129
164
  this.triggerInit()
130
165
  }
131
166
  setTimeout(() => window.cookieBanner.openCookieModal())
@@ -12,6 +12,7 @@ export type TSelectOption = {
12
12
  label: string
13
13
  selected?: boolean
14
14
  disabled?: boolean
15
+ hidden?: boolean
15
16
  }
16
17
 
17
18
  export interface IPktSelect {
@@ -68,9 +69,12 @@ export class PktSelect extends PktInputElement implements IPktSelect {
68
69
  if (!optionsReceivedFromProps && checkIfOptionNodesInSlot) {
69
70
  this.optionsController.nodes.forEach((node: Element) => {
70
71
  const option: TSelectOption = {
71
- value: node.getAttribute('value') || node.textContent || '',
72
+ value: node.hasAttribute('value')
73
+ ? (node.getAttribute('value') ?? '')
74
+ : (node.textContent ?? ''),
72
75
  label: node.textContent || node.getAttribute('value') || '',
73
- disabled: !!node.getAttribute('disabled'),
76
+ disabled: node.hasAttribute('disabled'),
77
+ hidden: node.hasAttribute('hidden'),
74
78
  }
75
79
  if (node.getAttribute('selected') && !this.value) {
76
80
  this.value = option.value
@@ -231,6 +235,7 @@ export class PktSelect extends PktInputElement implements IPktSelect {
231
235
  value=${option.value}
232
236
  ?selected=${this.value == option.value || option.selected}
233
237
  ?disabled=${option.disabled}
238
+ ?hidden=${option.hidden}
234
239
  >
235
240
  ${option.label}
236
241
  </option>`,
@@ -1,11 +0,0 @@
1
- "use strict";const s=require("./element-90YeMNbV.cjs");require("./button-KzBZ-Bff.cjs");require("./icon-B1_BRNqf.cjs");const g={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"}}}}},c=globalThis,d=c.__cookieEvents||{events:{},on(n,e){this.events[n]||(this.events[n]=[]),this.events[n].push(e)},off(n,e){this.events[n]&&(this.events[n]=this.events[n].filter(t=>t!==e))},once(n,e){const t=o=>{this.off(n,t),e(o)};this.on(n,t)},emit(n,e){this.events[n]&&this.events[n].forEach(t=>t(e))}};c.__cookieEvents=d;const k=d;var u=Object.defineProperty,p=Object.getOwnPropertyDescriptor,a=(n,e,t,o)=>{for(var i=o>1?void 0:o?p(e,t):e,r=n.length-1,l;r>=0;r--)(l=n[r])&&(i=(o?l(e,t,i):l(i))||i);return o&&i&&u(e,t,i),i};exports.PktConsent=class extends s.PktElement{constructor(){super(),this.hotjarId=null,this.googleAnalyticsId=null,this.triggerType="button",this.triggerText=null,this.i18nLanguage="nb"}connectedCallback(){super.connectedCallback(),this.triggerText=this.triggerText||g.i18n[this.i18nLanguage].contentPresentation.buttons.settings,this.googleAnalyticsId&&(window.googleAnalyticsId=this.googleAnalyticsId),this.hotjarId&&(window.hotjarId=this.hotjarId),k.on("CookieManager.setCookie",e=>{this.emitCookieConsents(e)})}returnJsonOrObject(e){let t;try{t=JSON.parse(e)}catch{t=e}return t}emitCookieConsents(e){const o=this.returnJsonOrObject(e.value).items.reduce((i,r)=>(i[r.name]=r.consent,i),{});this.dispatchEvent(new CustomEvent("toggle-consent",{detail:o,bubbles:!0,composed:!0}))}firstUpdated(e){if(!document.querySelector("#oslo-consent-script")&&window.location.hostname.toLowerCase().includes("oslo.kommune.no")){window.googleAnalyticsId=this.googleAnalyticsId,window.hotjarId=this.hotjarId;const t=document.createElement("script");t.src="https://cdn.web.oslo.kommune.no/cb/cb-v1.0.0.js",t.id="oslo-consent-script",t.onload=()=>{this.triggerInit()},document.head.appendChild(t);const o=document.createElement("link");o.href="https://cdn.web.oslo.kommune.no/cb/cb-v1.0.0.css",o.type="text/css",o.rel="stylesheet",o.id="oslo-consent-styles",document.head.appendChild(o)}}triggerInit(){window.document.dispatchEvent(new Event("DOMContentLoaded",{bubbles:!0,cancelable:!0})),window.cookieBanner.cookieConsent.validateConsentCookie().then(e=>{if(e){const o={value:window.cookieBanner.cookieConsent.getConsentCookie()};this.emitCookieConsents(o)}})}openModal(e){e.preventDefault(),window.cookieBanner.cookieConsent||this.triggerInit(),setTimeout(()=>window.cookieBanner.openCookieModal())}render(){return this.triggerType==="link"?s.x`<a href="#" class="pkt-link" @click=${this.openModal}>${this.triggerText}</a>`:this.triggerType==="footerlink"?s.x`<a href="#" class="pkt-footer__link" @click=${this.openModal}>
2
- <pkt-icon name="chevron-right" class="pkt-footer__link-icon"></pkt-icon>
3
- ${this.triggerText}
4
- </a>`:this.triggerType==="icon"?s.x`<pkt-button
5
- skin="tertiary"
6
- variant="icon-only"
7
- iconName="cookie"
8
- @click=${this.openModal}
9
- >
10
- >${this.triggerText}</pkt-button
11
- >`:s.x`<pkt-button @click=${this.openModal}>${this.triggerText}</pkt-button>`}};a([s.n({type:String})],exports.PktConsent.prototype,"hotjarId",2);a([s.n({type:String})],exports.PktConsent.prototype,"googleAnalyticsId",2);a([s.n({type:String})],exports.PktConsent.prototype,"triggerType",2);a([s.n({type:String})],exports.PktConsent.prototype,"triggerText",2);a([s.n({type:String})],exports.PktConsent.prototype,"i18nLanguage",2);exports.PktConsent=a([s.t("pkt-consent")],exports.PktConsent);
@@ -1 +0,0 @@
1
- "use strict";const o=require("./pkt-slot-controller-Da-RgXfS.cjs");class h{constructor(t){this.nodes=[],this.options=[],this.host=t,this.host.addController(this),this.nodes=[],this.options=[],this.observer=new MutationObserver(e=>this.handleMutations(e))}hostConnected(){Array.from(this.host.childNodes).forEach(t=>{(t.nodeName==="OPTION"||t.nodeName==="DATA")&&this.addNode(t)}),this.observer.observe(this.host,{childList:!0})}hostDisconnected(){this.observer.disconnect()}addNode(t){(t.nodeName==="OPTION"||t.nodeName==="DATA")&&(t.setAttribute("class","pkt-hide"),t.setAttribute("hidden","true"),t.setAttribute("data-skip","true"),this.nodes.push(t))}createOptions(){this.options=this.nodes.map(t=>({value:t.getAttribute("value")||t.textContent||"",label:t.textContent||t.getAttribute("value")||"",selected:!!t.getAttribute("selected"),disabled:!!t.getAttribute("disabled")})),this.host.setAttribute("options",JSON.stringify(this.options))}handleMutations(t){let e=!1;t.forEach(i=>{i.type==="childList"&&(i.addedNodes.forEach(s=>{o.isOptionElement(s)&&(this.addNode(s),e=!0)}),i.removedNodes.forEach(s=>{o.isOptionElement(s)&&(this.nodes=this.nodes.filter(r=>r!==s),e=!0)}))}),e&&this.createOptions()}}exports.PktOptionsSlotController=h;