@oslokommune/punkt-elements 19.3.1 → 19.4.0
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 +5 -0
- package/dist/components/checkbox/checkbox.d.ts +1 -1
- package/dist/components/consent/consent.d.ts +6 -38
- package/dist/{consent-BBxZkgCO.js → consent-CbJG04C1.js} +19 -15
- package/dist/{consent-BjYaCbef.cjs → consent-DxpJLExu.cjs} +2 -2
- package/dist/{footer-D_d5kq44.js → footer-CBkKAuvh.js} +1 -1
- package/dist/{footer-BGj1uWwC.cjs → footer-DOp_9VdY.cjs} +1 -1
- package/dist/pkt-consent.cjs +1 -1
- package/dist/pkt-consent.js +1 -1
- package/dist/pkt-footer.cjs +1 -1
- package/dist/pkt-footer.js +1 -1
- package/dist/pkt-index.cjs +1 -1
- package/dist/pkt-index.js +2 -2
- package/dist/shared-types/consent.d.ts +69 -0
- package/dist/shared-types/index.d.ts +2 -0
- package/package.json +2 -2
- package/src/components/checkbox/checkbox.ts +1 -3
- package/src/components/consent/consent.test.ts +14 -0
- package/src/components/consent/consent.ts +28 -54
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,11 @@ og skriver commits ca etter [Conventional Commits](https://conventionalcommits.o
|
|
|
5
5
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
+
## [19.4.0](https://github.com/oslokommune/punkt/compare/19.3.1...19.4.0) (2026-09-29)
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
|
|
8
13
|
## [19.3.1](https://github.com/oslokommune/punkt/compare/19.3.0...19.3.1) (2026-09-29)
|
|
9
14
|
|
|
10
15
|
### Bug Fixes
|
|
@@ -3,7 +3,6 @@ import { Ref } from 'lit/directives/ref.js';
|
|
|
3
3
|
import { PropertyValues } from 'lit';
|
|
4
4
|
import { ElementProps } from '../../types/typeUtils';
|
|
5
5
|
import { TCheckboxLabelPosition } from '../../shared-types';
|
|
6
|
-
export type { TCheckboxLabelPosition };
|
|
7
6
|
type Props = ElementProps<PktCheckbox, 'checkHelptext' | 'defaultChecked' | 'hasTile' | 'isSwitch' | 'labelPosition' | 'hideLabel' | 'tagText' | 'optionalTag' | 'optionalText' | 'requiredTag' | 'requiredText'>;
|
|
8
7
|
export declare class PktCheckbox extends PktInputElement<Props> {
|
|
9
8
|
inputRef: Ref<HTMLInputElement>;
|
|
@@ -35,3 +34,4 @@ export declare class PktCheckbox extends PktInputElement<Props> {
|
|
|
35
34
|
private handleChange;
|
|
36
35
|
private toggleChecked;
|
|
37
36
|
}
|
|
37
|
+
export {};
|
|
@@ -1,27 +1,7 @@
|
|
|
1
1
|
import { PropertyValues } from 'lit';
|
|
2
2
|
import { PktElement } from '../../base-elements/element';
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
consent: boolean;
|
|
6
|
-
}
|
|
7
|
-
interface ConsentValue {
|
|
8
|
-
items: ConsentItem[];
|
|
9
|
-
}
|
|
10
|
-
interface CookieConsentEvent {
|
|
11
|
-
value: string | ConsentValue;
|
|
12
|
-
}
|
|
13
|
-
type CookieEventHandler = (consent: CookieConsentEvent) => void;
|
|
14
|
-
interface CookieEvents {
|
|
15
|
-
on(eventName: string, handler: CookieEventHandler): void;
|
|
16
|
-
off(eventName: string, handler: CookieEventHandler): void;
|
|
17
|
-
}
|
|
18
|
-
interface CookieBannerApi {
|
|
19
|
-
cookieConsent: {
|
|
20
|
-
validateConsentCookie(): Promise<boolean>;
|
|
21
|
-
getConsentCookie(): string | ConsentValue;
|
|
22
|
-
};
|
|
23
|
-
openCookieModal(): void;
|
|
24
|
-
}
|
|
3
|
+
import { ICookieBannerApi, ICookieConsentEvent, ICookieEvents, IPktConsentBase, TPktConsentTriggerType } from '../../shared-types';
|
|
4
|
+
export type { TPktConsentTriggerType };
|
|
25
5
|
declare global {
|
|
26
6
|
interface Window {
|
|
27
7
|
cookieBanner_devMode?: boolean;
|
|
@@ -30,22 +10,11 @@ declare global {
|
|
|
30
10
|
cookieBanner_cookieExpiryDays?: string | null;
|
|
31
11
|
cookieBanner_googleAnalyticsId?: string | null;
|
|
32
12
|
cookieBanner_hotjarId?: string | null;
|
|
33
|
-
cookieBanner?:
|
|
34
|
-
__cookieEvents?:
|
|
13
|
+
cookieBanner?: ICookieBannerApi;
|
|
14
|
+
__cookieEvents?: ICookieEvents;
|
|
35
15
|
}
|
|
36
16
|
}
|
|
37
|
-
export type
|
|
38
|
-
export interface IPktConsent {
|
|
39
|
-
devMode?: boolean;
|
|
40
|
-
cookieDomain?: string | null;
|
|
41
|
-
cookieSecure?: string | null;
|
|
42
|
-
cookieExpiryDays?: string | null;
|
|
43
|
-
hotjarId?: string | null;
|
|
44
|
-
googleAnalyticsId?: string | null;
|
|
45
|
-
i18nLanguage?: string;
|
|
46
|
-
triggerType?: TPktConsentTriggerType | null;
|
|
47
|
-
triggerText?: string | null;
|
|
48
|
-
}
|
|
17
|
+
export type IPktConsent = IPktConsentBase;
|
|
49
18
|
export declare class PktConsent extends PktElement<IPktConsent> implements IPktConsent {
|
|
50
19
|
private _cookieEventHandler?;
|
|
51
20
|
devMode: boolean;
|
|
@@ -65,10 +34,9 @@ export declare class PktConsent extends PktElement<IPktConsent> implements IPktC
|
|
|
65
34
|
* Exposed for backwards compatibility — tests still rely on it.
|
|
66
35
|
*/
|
|
67
36
|
returnJsonOrObject<T>(obj: T | string): T;
|
|
68
|
-
emitCookieConsents(consent:
|
|
37
|
+
emitCookieConsents(consent: ICookieConsentEvent): void;
|
|
69
38
|
protected firstUpdated(_changedProperties: PropertyValues): Promise<void>;
|
|
70
39
|
triggerInit(): void;
|
|
71
40
|
openModal(e: Event): void;
|
|
72
41
|
render(): import('lit-html').TemplateResult<1>;
|
|
73
42
|
}
|
|
74
|
-
export {};
|
|
@@ -110,9 +110,13 @@ var a = {
|
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
112
|
]
|
|
113
|
-
}, o =
|
|
114
|
-
|
|
115
|
-
|
|
113
|
+
}, o = {
|
|
114
|
+
devMode: !1,
|
|
115
|
+
i18nLanguage: "nb",
|
|
116
|
+
triggerType: "button"
|
|
117
|
+
}, s = null;
|
|
118
|
+
function c() {
|
|
119
|
+
return s || (s = new Promise((e, t) => {
|
|
116
120
|
if (document.querySelector("#oslo-consent-script")) {
|
|
117
121
|
e();
|
|
118
122
|
return;
|
|
@@ -121,39 +125,39 @@ function s() {
|
|
|
121
125
|
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);
|
|
122
126
|
let r = document.createElement("link");
|
|
123
127
|
r.href = "https://cdn.web.oslo.kommune.no/cb/cb-v1.1.0.css", r.type = "text/css", r.rel = "stylesheet", r.id = "oslo-consent-styles", document.head.appendChild(r);
|
|
124
|
-
}),
|
|
128
|
+
}), s);
|
|
125
129
|
}
|
|
126
|
-
var
|
|
130
|
+
var l = (e) => {
|
|
127
131
|
if (typeof e != "string") return e;
|
|
128
132
|
try {
|
|
129
133
|
return JSON.parse(e);
|
|
130
134
|
} catch {
|
|
131
135
|
return e;
|
|
132
136
|
}
|
|
133
|
-
},
|
|
137
|
+
}, u = (e) => l(e.value).items.reduce((e, t) => (e[t.name] = t.consent, e), {}), d = class extends r {
|
|
134
138
|
constructor(...e) {
|
|
135
|
-
super(...e), this.devMode =
|
|
139
|
+
super(...e), this.devMode = o.devMode, this.hotjarId = null, this.googleAnalyticsId = null, this.cookieDomain = null, this.cookieSecure = null, this.cookieExpiryDays = null, this.triggerType = o.triggerType, this.triggerText = null, this.i18nLanguage = o.i18nLanguage;
|
|
136
140
|
}
|
|
137
141
|
connectedCallback() {
|
|
138
142
|
super.connectedCallback();
|
|
139
|
-
let e = this.i18nLanguage;
|
|
143
|
+
let e = Object.hasOwn(a.i18n, this.i18nLanguage) ? this.i18nLanguage : "nb";
|
|
140
144
|
this.triggerText = this.triggerText || a.i18n[e].contentPresentation.buttons.settings;
|
|
141
145
|
}
|
|
142
146
|
disconnectedCallback() {
|
|
143
147
|
super.disconnectedCallback(), this._cookieEventHandler && window.__cookieEvents?.off("CookieManager.setCookie", this._cookieEventHandler);
|
|
144
148
|
}
|
|
145
149
|
returnJsonOrObject(e) {
|
|
146
|
-
return
|
|
150
|
+
return l(e);
|
|
147
151
|
}
|
|
148
152
|
emitCookieConsents(e) {
|
|
149
153
|
this.dispatchEvent(new CustomEvent("toggle-consent", {
|
|
150
|
-
detail:
|
|
154
|
+
detail: u(e),
|
|
151
155
|
bubbles: !0,
|
|
152
156
|
cancelable: !1
|
|
153
157
|
}));
|
|
154
158
|
}
|
|
155
159
|
async firstUpdated(e) {
|
|
156
|
-
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
|
|
160
|
+
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 c(), this.triggerInit();
|
|
157
161
|
}
|
|
158
162
|
triggerInit() {
|
|
159
163
|
window.document.dispatchEvent(new Event("CookieBannerReady", {
|
|
@@ -191,14 +195,14 @@ var c = (e) => {
|
|
|
191
195
|
>`;
|
|
192
196
|
}
|
|
193
197
|
};
|
|
194
|
-
n([i({ type: Boolean })],
|
|
198
|
+
n([i({ type: Boolean })], d.prototype, "devMode", void 0), n([i({ type: String })], d.prototype, "hotjarId", void 0), n([i({ type: String })], d.prototype, "googleAnalyticsId", void 0), n([i({ type: String })], d.prototype, "cookieDomain", void 0), n([i({ type: String })], d.prototype, "cookieSecure", void 0), n([i({ type: String })], d.prototype, "cookieExpiryDays", void 0), n([i({ type: String })], d.prototype, "triggerType", void 0), n([i({ type: String })], d.prototype, "triggerText", void 0), n([i({ type: String })], d.prototype, "i18nLanguage", void 0);
|
|
195
199
|
try {
|
|
196
|
-
t("pkt-consent")(
|
|
200
|
+
t("pkt-consent")(d);
|
|
197
201
|
} catch {
|
|
198
202
|
console.warn("Forsøker å definere <pkt-consent>, men den er allerede definert");
|
|
199
203
|
}
|
|
200
204
|
//#endregion
|
|
201
205
|
//#region src/components/consent/index.ts
|
|
202
|
-
var
|
|
206
|
+
var f = d;
|
|
203
207
|
//#endregion
|
|
204
|
-
export {
|
|
208
|
+
export { d as n, f as t };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-BOmr9YLv.cjs");require("./button-CmNrMH-c.cjs");var t={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`}}}},cookies:[{name:`statistics`,defaultValue:null,i18n:{nb:{title:`Statistikk og analyse`,description:`Jeg godtar at Oslo kommune bruker informasjonskapsler til å innhente data om statistikk og brukeradferd.`,buttons:{yes:`Ja`,no:`Nei`}},en:{title:`Statistics and analytics`,description:`Select your preference for statistics and analytics`,buttons:{yes:`Yes`,no:`No`}}}},{name:`survey`,defaultValue:null,i18n:{nb:{title:`Skriftlige tilbakemeldinger`,description:`Jeg godtar at Oslo kommune bruker informasjonskapsler til å vise responsfelt og registrere tilbakemeldinger.`,buttons:{yes:`Ja`,no:`Nei`}},en:{title:`Survey`,description:`Select your preference for survey`,buttons:{yes:`Yes`,no:`No`}}}},{name:`functional`,defaultValue:!0,i18n:{nb:{title:`Funksjonelle informasjonskapsler`,description:`Jeg godtar at Oslo kommune bruker informasjonskapsler for å gjøre ulike funksjoner på nettstedet mulige (for eksempel skjemaer og barnehagevelger).`,buttons:{yes:`Ja`,no:`Nei`}},en:{title:`Functional cookies`,description:`For the website to function optimally, we recommend that you accept these cookies`,buttons:{yes:`Yes`,no:`No`}}}}]},n=null;function
|
|
1
|
+
const e=require("./element-BOmr9YLv.cjs");require("./button-CmNrMH-c.cjs");var t={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`}}}},cookies:[{name:`statistics`,defaultValue:null,i18n:{nb:{title:`Statistikk og analyse`,description:`Jeg godtar at Oslo kommune bruker informasjonskapsler til å innhente data om statistikk og brukeradferd.`,buttons:{yes:`Ja`,no:`Nei`}},en:{title:`Statistics and analytics`,description:`Select your preference for statistics and analytics`,buttons:{yes:`Yes`,no:`No`}}}},{name:`survey`,defaultValue:null,i18n:{nb:{title:`Skriftlige tilbakemeldinger`,description:`Jeg godtar at Oslo kommune bruker informasjonskapsler til å vise responsfelt og registrere tilbakemeldinger.`,buttons:{yes:`Ja`,no:`Nei`}},en:{title:`Survey`,description:`Select your preference for survey`,buttons:{yes:`Yes`,no:`No`}}}},{name:`functional`,defaultValue:!0,i18n:{nb:{title:`Funksjonelle informasjonskapsler`,description:`Jeg godtar at Oslo kommune bruker informasjonskapsler for å gjøre ulike funksjoner på nettstedet mulige (for eksempel skjemaer og barnehagevelger).`,buttons:{yes:`Ja`,no:`Nei`}},en:{title:`Functional cookies`,description:`For the website to function optimally, we recommend that you accept these cookies`,buttons:{yes:`Yes`,no:`No`}}}}]},n={devMode:!1,i18nLanguage:`nb`,triggerType:`button`},r=null;function i(){return r||(r=new Promise((e,t)=>{if(document.querySelector(`#oslo-consent-script`)){e();return}let 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);let r=document.createElement(`link`);r.href=`https://cdn.web.oslo.kommune.no/cb/cb-v1.1.0.css`,r.type=`text/css`,r.rel=`stylesheet`,r.id=`oslo-consent-styles`,document.head.appendChild(r)}),r)}var a=e=>{if(typeof e!=`string`)return e;try{return JSON.parse(e)}catch{return e}},o=e=>a(e.value).items.reduce((e,t)=>(e[t.name]=t.consent,e),{}),s=class extends e.t{constructor(...e){super(...e),this.devMode=n.devMode,this.hotjarId=null,this.googleAnalyticsId=null,this.cookieDomain=null,this.cookieSecure=null,this.cookieExpiryDays=null,this.triggerType=n.triggerType,this.triggerText=null,this.i18nLanguage=n.i18nLanguage}connectedCallback(){super.connectedCallback();let e=Object.hasOwn(t.i18n,this.i18nLanguage)?this.i18nLanguage:`nb`;this.triggerText=this.triggerText||t.i18n[e].contentPresentation.buttons.settings}disconnectedCallback(){super.disconnectedCallback(),this._cookieEventHandler&&window.__cookieEvents?.off(`CookieManager.setCookie`,this._cookieEventHandler)}returnJsonOrObject(e){return a(e)}emitCookieConsents(e){this.dispatchEvent(new CustomEvent(`toggle-consent`,{detail:o(e),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 i(),this.triggerInit()}triggerInit(){window.document.dispatchEvent(new Event(`CookieBannerReady`,{bubbles:!0,cancelable:!0}));let e=window.cookieBanner,t=window.__cookieEvents;!e||!t||e.cookieConsent.validateConsentCookie().then(n=>{if(!n)return;let r=e.cookieConsent.getConsentCookie();window.setTimeout(()=>this.emitCookieConsents({value:r}),0),this._cookieEventHandler&&t.off(`CookieManager.setCookie`,this._cookieEventHandler),this._cookieEventHandler=e=>this.emitCookieConsents(e),t.on(`CookieManager.setCookie`,this._cookieEventHandler)})}openModal(e){e.preventDefault(),window.cookieBanner?.cookieConsent||this.triggerInit(),setTimeout(()=>window.cookieBanner?.openCookieModal())}render(){return this.triggerType===`link`?e._`<a href="#" class="pkt-link" aria-haspopup="dialog" @click=${this.openModal}
|
|
2
2
|
>${this.triggerText}</a
|
|
3
3
|
>`:this.triggerType===`footerlink`?e._`<a
|
|
4
4
|
href="#"
|
|
@@ -15,4 +15,4 @@ const e=require("./element-BOmr9YLv.cjs");require("./button-CmNrMH-c.cjs");var t
|
|
|
15
15
|
>${this.triggerText}</pkt-button
|
|
16
16
|
>`:e._`<pkt-button aria-haspopup="dialog" @click=${this.openModal}
|
|
17
17
|
>${this.triggerText}</pkt-button
|
|
18
|
-
>`}};e.n([e.u({type:Boolean})],
|
|
18
|
+
>`}};e.n([e.u({type:Boolean})],s.prototype,`devMode`,void 0),e.n([e.u({type:String})],s.prototype,`hotjarId`,void 0),e.n([e.u({type:String})],s.prototype,`googleAnalyticsId`,void 0),e.n([e.u({type:String})],s.prototype,`cookieDomain`,void 0),e.n([e.u({type:String})],s.prototype,`cookieSecure`,void 0),e.n([e.u({type:String})],s.prototype,`cookieExpiryDays`,void 0),e.n([e.u({type:String})],s.prototype,`triggerType`,void 0),e.n([e.u({type:String})],s.prototype,`triggerText`,void 0),e.n([e.u({type:String})],s.prototype,`i18nLanguage`,void 0);try{e.d(`pkt-consent`)(s)}catch{console.warn(`Forsøker å definere <pkt-consent>, men den er allerede definert`)}var c=s;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return c}});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { _ as e, d as t, h as n, l as r, n as i, t as a, u as o } from "./element-mwwC2Rra.js";
|
|
2
2
|
import { t as s } from "./if-defined-Bebu3LXY.js";
|
|
3
|
-
import "./consent-
|
|
3
|
+
import "./consent-CbJG04C1.js";
|
|
4
4
|
import { t as c } from "./booleanish-OQJTYSrw.js";
|
|
5
5
|
import { n as l, r as u, t as d } from "./fetch-header-footer-data-Pc32etrk.js";
|
|
6
6
|
import "./icon-DmRyYNlY.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-BOmr9YLv.cjs"),t=require("./if-defined-2mkIDgOm.cjs");require("./consent-
|
|
1
|
+
const e=require("./element-BOmr9YLv.cjs"),t=require("./if-defined-2mkIDgOm.cjs");require("./consent-DxpJLExu.cjs");const n=require("./booleanish-BF8l4scU.cjs"),r=require("./fetch-header-footer-data-CUKV0biS.cjs");require("./icon-CoBsgGUR.cjs");var i=`oslo.kommune.no`,a=/\.(?:co|com|org|net|gov|edu|ac|kommune)\.[a-z]{2}$/i;function o(e){let t=e.toLowerCase().replace(/\.$/,``),n=t.split(`.`);return n.length<=2?t:n.slice(a.test(t)?-3:-2).join(`.`)}function s(e){if(!e)return;let t;try{t=new URL(e)}catch{return}if(t.protocol===`http:`||t.protocol===`https:`)return o(t.hostname.toLowerCase().replace(/\.$/,``))}function c(e,t=i){if(!e)return;let n;try{n=new URL(e)}catch{return}if(n.protocol!==`http:`&&n.protocol!==`https:`)return;let r=n.hostname.toLowerCase().replace(/\.$/,``),a=t.toLowerCase();if(!(r===a||r.endsWith(`.${a}`)))return o(r)}var l=`#cb-trigger`,u=class extends e.t{constructor(...e){super(...e),this.locale=`nb-NO`,this.skipGlobal=!1,this.openLinksInNewTab=!1,this.includeConsent=!1,this.hotjarId=null,this.googleAnalyticsId=null,this.devMode=!1,this.cookieDomain=null,this.cookieSecure=null,this.cookieExpiryDays=null}connectedCallback(){super.connectedCallback(),!this.data&&!this.skipGlobal&&this.loadData()}disconnectedCallback(){super.disconnectedCallback(),this.abortController?.abort()}updated(e){super.updated(e),e.has(`dataUrl`)&&e.get(`dataUrl`)!==void 0&&!this.data&&this.loadData()}async loadData(){this.abortController?.abort(),this.abortController=new AbortController;try{this.fetchedData=await r.t(this.dataUrl,this.abortController.signal)}catch(e){if(e.name===`AbortError`)return;console.warn(`Failed to fetch header/footer data:`,e),this.dispatchEvent(new CustomEvent(`data-error`,{detail:{error:e},bubbles:!0,composed:!0}))}}get globalFooterData(){return r.n(this.data??this.fetchedData,this.locale)?.footer}linkTarget(e){return e.openInNewTab||this.openLinksInNewTab?{target:`_blank`,rel:`noopener noreferrer`}:{target:`_self`}}renderLinkDomain(t,n=`pkt-footer__link-domain`){if(!t.external)return e.h;let r=s(t.href);return r?e._` <span class=${n}>(${r})</span>`:e.h}renderCustomLink(n){let{target:r,rel:i}=this.linkTarget(n);return e._`
|
|
2
2
|
<a href=${n.href} target=${r} rel=${t.t(i)}
|
|
3
3
|
>${n.text}${this.renderLinkDomain(n)}</a
|
|
4
4
|
>
|
package/dist/pkt-consent.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./consent-
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./consent-DxpJLExu.cjs");exports.PktConsent=e.n,exports.default=e.t;
|
package/dist/pkt-consent.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as e, t } from "./consent-
|
|
1
|
+
import { n as e, t } from "./consent-CbJG04C1.js";
|
|
2
2
|
export { e as PktConsent, t as default };
|
package/dist/pkt-footer.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./footer-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./footer-DOp_9VdY.cjs");exports.PktFooter=e.n,exports.PktFooterSimple=e.t;
|
package/dist/pkt-footer.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as e, t } from "./footer-
|
|
1
|
+
import { n as e, t } from "./footer-CBkKAuvh.js";
|
|
2
2
|
export { e as PktFooter, t as PktFooterSimple };
|
package/dist/pkt-index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./element-BOmr9YLv.cjs"),t=require("./consent-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./element-BOmr9YLv.cjs"),t=require("./consent-DxpJLExu.cjs"),n=require("./alert-D1bQjZ7C.cjs"),r=require("./header-Cs4t2XMM.cjs"),i=require("./card-DW1uklP6.cjs"),a=require("./checkbox-C0zLtnCI.cjs"),o=require("./calendar-D-Ow5DAp.cjs"),s=require("./icon-CoBsgGUR.cjs"),c=require("./button-CmNrMH-c.cjs"),l=require("./accordion-CZ0O4c0_.cjs"),u=require("./backlink-Bw6IcRIo.cjs"),d=require("./breadcrumbs-C10K1XLP.cjs"),f=require("./tag-HTYKd-iG.cjs"),p=require("./combobox-BgduqUpf.cjs"),m=require("./input-wrapper-CSPPa4uc.cjs"),h=require("./helptext-DYgeTMtA.cjs"),g=require("./fileupload-4wgr4iAi.cjs"),_=require("./modal-DaerHpVi.cjs"),v=require("./progressbar-BrVlAcQI.cjs"),y=require("./datepicker-53rj_Qqx.cjs"),b=require("./footer-DOp_9VdY.cjs"),x=require("./link-EMsHusF7.cjs"),S=require("./textinput-Czz2affL.cjs"),C=require("./searchinput-7-VVdkss.cjs"),w=require("./header-menu-BnqZagI6.cjs"),T=require("./heading-u9Arof4p.cjs"),E=require("./linkcard-CWeR6t2a.cjs"),D=require("./loader-SJ6NauNT.cjs"),O=require("./messagebox-D5GYIdjE.cjs"),k=require("./radiobutton-Cv1BlwLV.cjs"),A=require("./tabs-Dw9E06fL.cjs"),j=require("./textarea-pA_xv8lI.cjs"),M=require("./select---PCiwmy.cjs"),N=require("./timepicker-BwDZkSpo.cjs");exports.PktAccordion=l.r,exports.PktAccordionItem=l.n,exports.PktAlert=n.n,exports.PktBackLink=u.n,exports.PktBreadcrumbs=d.t,exports.PktButton=c.n,exports.PktCalendar=o.n,exports.PktCard=i.n,exports.PktCheckbox=a.n,exports.PktCombobox=p.n,exports.PktConsent=t.n,exports.PktDateTags=y.a,exports.PktDatepicker=y.t,Object.defineProperty(exports,"PktFileUpload",{enumerable:!0,get:function(){return g.n}}),exports.PktFooter=b.n,exports.PktFooterSimple=b.t,exports.PktHeader=r.t,exports.PktHeaderGlobal=r.n,exports.PktHeaderMenu=w.n,exports.PktHeaderService=r.r,exports.PktHeaderUserMenu=r.i,exports.PktHeading=T.n,exports.PktHelptext=h.n,exports.PktIcon=s.n,exports.PktInputWrapper=m.n,exports.PktLink=x.n,exports.PktLinkCard=E.n,exports.PktLoader=D.n,exports.PktMessagebox=O.n,exports.PktModal=_.n,exports.PktProgressbar=v.n,exports.PktRadioButton=k.n,exports.PktRadiobutton=k.n,exports.PktSearchInput=C.n,exports.PktSelect=M.n,exports.PktTabItem=A.n,exports.PktTabs=A.r,exports.PktTag=f.n,exports.PktTextarea=j.n,exports.PktTextinput=S.n,exports.PktTimepicker=N.t,exports.getPktStrings=e.r,exports.pktStringsNb=e.s,exports.resetPktStrings=e.i,exports.setPktStrings=e.a,exports.subscribePktStrings=e.o;
|
package/dist/pkt-index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { a as e, i as t, o as n, r, s as i } from "./element-mwwC2Rra.js";
|
|
2
|
-
import { n as a } from "./consent-
|
|
2
|
+
import { n as a } from "./consent-CbJG04C1.js";
|
|
3
3
|
import { n as o } from "./alert-BhvjSA5X.js";
|
|
4
4
|
import { i as s, n as c, r as l, t as u } from "./header-CF-Re0nT.js";
|
|
5
5
|
import { n as d } from "./card-D2YYPZr5.js";
|
|
@@ -18,7 +18,7 @@ import { n as w } from "./fileupload-BxfBFhFt.js";
|
|
|
18
18
|
import { n as T } from "./modal-CJqe6y-V.js";
|
|
19
19
|
import { n as E } from "./progressbar-Bd0DjiAb.js";
|
|
20
20
|
import { a as D, t as O } from "./datepicker-BLBimRTT.js";
|
|
21
|
-
import { n as k, t as A } from "./footer-
|
|
21
|
+
import { n as k, t as A } from "./footer-CBkKAuvh.js";
|
|
22
22
|
import { n as j } from "./link-DcxVUj8s.js";
|
|
23
23
|
import { n as M } from "./textinput-Dpj1X5yr.js";
|
|
24
24
|
import { n as N } from "./searchinput-CgzigmiI.js";
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* consent.ts
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for pkt-consent.
|
|
5
|
+
* Used by React, Elements, and typed component specs.
|
|
6
|
+
*/
|
|
7
|
+
/** Consent trigger variants — shared runtime source for types, specs, and Preview. */
|
|
8
|
+
export declare const CONSENT_TRIGGER_TYPES: readonly ['button', 'link', 'footerlink', 'icon'];
|
|
9
|
+
export type TPktConsentTriggerType = (typeof CONSENT_TRIGGER_TYPES)[number];
|
|
10
|
+
/**
|
|
11
|
+
* Trigger variants offered in Preview/docs. `footerlink` is left out because it is
|
|
12
|
+
* styled for the footer, where PktFooter and PktFooterSimple set it themselves.
|
|
13
|
+
*/
|
|
14
|
+
export declare const CONSENT_TRIGGER_TYPE_OPTIONS: readonly ["button", "link", "icon"];
|
|
15
|
+
/** One cookie category in the consent cookie. */
|
|
16
|
+
export interface IConsentItem {
|
|
17
|
+
name: string;
|
|
18
|
+
consent: boolean;
|
|
19
|
+
}
|
|
20
|
+
/** Parsed consent cookie. */
|
|
21
|
+
export interface IConsentValue {
|
|
22
|
+
items: IConsentItem[];
|
|
23
|
+
}
|
|
24
|
+
/** Payload from the cookie banner's `CookieManager.setCookie` event. */
|
|
25
|
+
export interface ICookieConsentEvent {
|
|
26
|
+
value: string | IConsentValue;
|
|
27
|
+
}
|
|
28
|
+
/** Detail of the `toggle-consent` event: cookie category name → consent given. */
|
|
29
|
+
export type TConsentDetailsMap = Record<string, boolean>;
|
|
30
|
+
export type TCookieEventHandler = (consent: ICookieConsentEvent) => void;
|
|
31
|
+
/** `window.__cookieEvents` exposed by the cookie banner script. */
|
|
32
|
+
export interface ICookieEvents {
|
|
33
|
+
on(eventName: string, handler: TCookieEventHandler): void;
|
|
34
|
+
off(eventName: string, handler: TCookieEventHandler): void;
|
|
35
|
+
}
|
|
36
|
+
/** `window.cookieBanner` exposed by the cookie banner script. */
|
|
37
|
+
export interface ICookieBannerApi {
|
|
38
|
+
cookieConsent: {
|
|
39
|
+
validateConsentCookie(): Promise<boolean>;
|
|
40
|
+
getConsentCookie(): string | IConsentValue;
|
|
41
|
+
};
|
|
42
|
+
openCookieModal(): void;
|
|
43
|
+
}
|
|
44
|
+
/** Consent props shared by React and Elements. */
|
|
45
|
+
export interface IPktConsentBase {
|
|
46
|
+
devMode?: boolean;
|
|
47
|
+
cookieDomain?: string | null;
|
|
48
|
+
cookieSecure?: string | null;
|
|
49
|
+
cookieExpiryDays?: string | null;
|
|
50
|
+
hotjarId?: string | null;
|
|
51
|
+
googleAnalyticsId?: string | null;
|
|
52
|
+
i18nLanguage?: string;
|
|
53
|
+
triggerType?: TPktConsentTriggerType | null;
|
|
54
|
+
triggerText?: string | null;
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Documented Consent props (subset of `IPktConsentBase`).
|
|
58
|
+
* Used for typed component specs in documentation.
|
|
59
|
+
*/
|
|
60
|
+
export type IConsentSpecProps = Pick<IPktConsentBase, 'devMode' | 'cookieDomain' | 'cookieSecure' | 'cookieExpiryDays' | 'hotjarId' | 'googleAnalyticsId' | 'i18nLanguage' | 'triggerType' | 'triggerText'>;
|
|
61
|
+
/**
|
|
62
|
+
* Default values for pkt-consent. Single source of truth for both frameworks.
|
|
63
|
+
* `triggerText` is absent — it falls back to the `consentStrings` text for `i18nLanguage`.
|
|
64
|
+
*/
|
|
65
|
+
export declare const CONSENT_DEFAULTS: {
|
|
66
|
+
readonly devMode: false;
|
|
67
|
+
readonly i18nLanguage: 'nb';
|
|
68
|
+
readonly triggerType: 'button';
|
|
69
|
+
};
|
|
@@ -13,6 +13,8 @@ export { CARD_SKINS, CARD_PADDINGS, CARD_IMAGE_SHAPES, CARD_IMAGE_ASPECTS, CARD_
|
|
|
13
13
|
export type { TCardSkin, TCardPadding, TCardImageShape, TCardImageAspect, TCardTagPosition, ICardTag, ICardImage, IPktCardBase, ICardSpecProps, } from './card';
|
|
14
14
|
export { CHECKBOX_LABEL_POSITIONS, CHECKBOX_DEFAULTS } from './checkbox';
|
|
15
15
|
export type { TCheckboxLabelPosition, IPktCheckboxBase, ICheckboxSpecProps } from './checkbox';
|
|
16
|
+
export { CONSENT_TRIGGER_TYPES, CONSENT_TRIGGER_TYPE_OPTIONS, CONSENT_DEFAULTS } from './consent';
|
|
17
|
+
export type { TPktConsentTriggerType, IConsentItem, IConsentValue, ICookieConsentEvent, TConsentDetailsMap, TCookieEventHandler, ICookieEvents, ICookieBannerApi, IPktConsentBase, IConsentSpecProps, } from './consent';
|
|
16
18
|
export { LAYOUT_DIRECTIONS } from './layout';
|
|
17
19
|
export type { TLayout, TVerticalPosition, THorizontalPosition, TPosition, TPositionWithCenter, } from './layout';
|
|
18
20
|
export type { THTMLButtonType, TSelectionMode } from './form';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslokommune/punkt-elements",
|
|
3
|
-
"version": "19.
|
|
3
|
+
"version": "19.4.0",
|
|
4
4
|
"description": "Komponentbiblioteket til Punkt, designsystem for Oslo kommune",
|
|
5
5
|
"homepage": "https://punkt.oslo.kommune.no",
|
|
6
6
|
"author": "Team Designsystem, Oslo kommune",
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
"engines": {
|
|
85
85
|
"node": "^22.19.0 || ^24.0.0 || ^26.0.0"
|
|
86
86
|
},
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "74057ff529f28056e96199ce2b2def5aee6ef9bf"
|
|
88
88
|
}
|
|
@@ -5,9 +5,7 @@ import { Ref, createRef, ref } from 'lit/directives/ref.js'
|
|
|
5
5
|
import { html, nothing, PropertyValues } from 'lit'
|
|
6
6
|
import { classMap } from 'lit/directives/class-map.js'
|
|
7
7
|
import { ElementProps } from '@/types/typeUtils'
|
|
8
|
-
import { CHECKBOX_DEFAULTS,
|
|
9
|
-
|
|
10
|
-
export type { TCheckboxLabelPosition }
|
|
8
|
+
import { CHECKBOX_DEFAULTS,type TCheckboxLabelPosition } from 'shared-types'
|
|
11
9
|
|
|
12
10
|
type Props = ElementProps<
|
|
13
11
|
PktCheckbox,
|
|
@@ -158,6 +158,20 @@ describe('PktConsent', () => {
|
|
|
158
158
|
|
|
159
159
|
expect(consent.i18nLanguage).toBe('en')
|
|
160
160
|
})
|
|
161
|
+
|
|
162
|
+
test.each(['sv', 'constructor'])(
|
|
163
|
+
'falls back to bokmål trigger text when i18nLanguage is "%s"',
|
|
164
|
+
async (language) => {
|
|
165
|
+
const { consent } = await createConsentTest({
|
|
166
|
+
i18nLanguage: language,
|
|
167
|
+
})
|
|
168
|
+
|
|
169
|
+
await consent.updateComplete
|
|
170
|
+
|
|
171
|
+
const button = consent.querySelector('pkt-button')
|
|
172
|
+
expect(button?.textContent?.trim()).toBe('Innstillinger for informasjonskapsler')
|
|
173
|
+
},
|
|
174
|
+
)
|
|
161
175
|
})
|
|
162
176
|
|
|
163
177
|
describe('Trigger types', () => {
|
|
@@ -2,37 +2,20 @@ 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 {
|
|
6
|
+
CONSENT_DEFAULTS,
|
|
7
|
+
type IConsentValue,
|
|
8
|
+
type ICookieBannerApi,
|
|
9
|
+
type ICookieConsentEvent,
|
|
10
|
+
type ICookieEvents,
|
|
11
|
+
type IPktConsentBase,
|
|
12
|
+
type TConsentDetailsMap,
|
|
13
|
+
type TCookieEventHandler,
|
|
14
|
+
type TPktConsentTriggerType,
|
|
15
|
+
} from 'shared-types'
|
|
5
16
|
import '../button'
|
|
6
17
|
|
|
7
|
-
|
|
8
|
-
name: string
|
|
9
|
-
consent: boolean
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
interface ConsentValue {
|
|
13
|
-
items: ConsentItem[]
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
interface CookieConsentEvent {
|
|
17
|
-
value: string | ConsentValue
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
type ConsentDetailsMap = Record<string, boolean>
|
|
21
|
-
|
|
22
|
-
type CookieEventHandler = (consent: CookieConsentEvent) => void
|
|
23
|
-
|
|
24
|
-
interface CookieEvents {
|
|
25
|
-
on(eventName: string, handler: CookieEventHandler): void
|
|
26
|
-
off(eventName: string, handler: CookieEventHandler): void
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
interface CookieBannerApi {
|
|
30
|
-
cookieConsent: {
|
|
31
|
-
validateConsentCookie(): Promise<boolean>
|
|
32
|
-
getConsentCookie(): string | ConsentValue
|
|
33
|
-
}
|
|
34
|
-
openCookieModal(): void
|
|
35
|
-
}
|
|
18
|
+
export type { TPktConsentTriggerType }
|
|
36
19
|
|
|
37
20
|
declare global {
|
|
38
21
|
interface Window {
|
|
@@ -42,8 +25,8 @@ declare global {
|
|
|
42
25
|
cookieBanner_cookieExpiryDays?: string | null
|
|
43
26
|
cookieBanner_googleAnalyticsId?: string | null
|
|
44
27
|
cookieBanner_hotjarId?: string | null
|
|
45
|
-
cookieBanner?:
|
|
46
|
-
__cookieEvents?:
|
|
28
|
+
cookieBanner?: ICookieBannerApi
|
|
29
|
+
__cookieEvents?: ICookieEvents
|
|
47
30
|
}
|
|
48
31
|
}
|
|
49
32
|
|
|
@@ -84,32 +67,20 @@ const parseJsonOrPassThrough = <T>(value: T | string): T => {
|
|
|
84
67
|
}
|
|
85
68
|
}
|
|
86
69
|
|
|
87
|
-
const toConsentDetails = (consent:
|
|
88
|
-
const parsed = parseJsonOrPassThrough<
|
|
89
|
-
return parsed.items.reduce<
|
|
70
|
+
const toConsentDetails = (consent: ICookieConsentEvent): TConsentDetailsMap => {
|
|
71
|
+
const parsed = parseJsonOrPassThrough<IConsentValue>(consent.value)
|
|
72
|
+
return parsed.items.reduce<TConsentDetailsMap>((acc, item) => {
|
|
90
73
|
acc[item.name] = item.consent
|
|
91
74
|
return acc
|
|
92
75
|
}, {})
|
|
93
76
|
}
|
|
94
77
|
|
|
95
|
-
export type
|
|
96
|
-
|
|
97
|
-
export interface IPktConsent {
|
|
98
|
-
devMode?: boolean
|
|
99
|
-
cookieDomain?: string | null
|
|
100
|
-
cookieSecure?: string | null
|
|
101
|
-
cookieExpiryDays?: string | null
|
|
102
|
-
hotjarId?: string | null
|
|
103
|
-
googleAnalyticsId?: string | null
|
|
104
|
-
i18nLanguage?: string
|
|
105
|
-
triggerType?: TPktConsentTriggerType | null
|
|
106
|
-
triggerText?: string | null
|
|
107
|
-
}
|
|
78
|
+
export type IPktConsent = IPktConsentBase
|
|
108
79
|
|
|
109
80
|
export class PktConsent extends PktElement<IPktConsent> implements IPktConsent {
|
|
110
|
-
private _cookieEventHandler?:
|
|
81
|
+
private _cookieEventHandler?: TCookieEventHandler
|
|
111
82
|
|
|
112
|
-
@property({ type: Boolean }) devMode: boolean =
|
|
83
|
+
@property({ type: Boolean }) devMode: boolean = CONSENT_DEFAULTS.devMode
|
|
113
84
|
|
|
114
85
|
@property({ type: String }) hotjarId: string | null = null
|
|
115
86
|
@property({ type: String }) googleAnalyticsId: string | null = null
|
|
@@ -117,13 +88,16 @@ export class PktConsent extends PktElement<IPktConsent> implements IPktConsent {
|
|
|
117
88
|
@property({ type: String }) cookieSecure: string | null = null
|
|
118
89
|
@property({ type: String }) cookieExpiryDays: string | null = null
|
|
119
90
|
|
|
120
|
-
@property({ type: String }) triggerType: TPktConsentTriggerType | null =
|
|
91
|
+
@property({ type: String }) triggerType: TPktConsentTriggerType | null =
|
|
92
|
+
CONSENT_DEFAULTS.triggerType
|
|
121
93
|
@property({ type: String }) triggerText: string | null = null
|
|
122
|
-
@property({ type: String }) i18nLanguage: string =
|
|
94
|
+
@property({ type: String }) i18nLanguage: string = CONSENT_DEFAULTS.i18nLanguage
|
|
123
95
|
|
|
124
96
|
connectedCallback(): void {
|
|
125
97
|
super.connectedCallback()
|
|
126
|
-
const language =
|
|
98
|
+
const language = (
|
|
99
|
+
Object.hasOwn(consentStrings.i18n, this.i18nLanguage) ? this.i18nLanguage : 'nb'
|
|
100
|
+
) as keyof typeof consentStrings.i18n
|
|
127
101
|
this.triggerText =
|
|
128
102
|
this.triggerText || consentStrings.i18n[language].contentPresentation.buttons.settings
|
|
129
103
|
}
|
|
@@ -144,9 +118,9 @@ export class PktConsent extends PktElement<IPktConsent> implements IPktConsent {
|
|
|
144
118
|
return parseJsonOrPassThrough(obj)
|
|
145
119
|
}
|
|
146
120
|
|
|
147
|
-
emitCookieConsents(consent:
|
|
121
|
+
emitCookieConsents(consent: ICookieConsentEvent): void {
|
|
148
122
|
this.dispatchEvent(
|
|
149
|
-
new CustomEvent<
|
|
123
|
+
new CustomEvent<TConsentDetailsMap>('toggle-consent', {
|
|
150
124
|
detail: toConsentDetails(consent),
|
|
151
125
|
bubbles: true,
|
|
152
126
|
cancelable: false,
|