@oslokommune/punkt-elements 12.36.2 → 12.37.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 +18 -0
- package/dist/consent-Baktq_-1.js +161 -0
- package/dist/consent-jXR0vKAu.cjs +11 -0
- package/dist/consent.d.ts +1 -0
- package/dist/index.d.ts +23 -1
- package/dist/{modal-B-varrJT.js → modal-DIwagdAc.js} +1 -1
- package/dist/modal-OC0efchb.cjs +33 -0
- package/dist/pkt-consent.cjs +1 -0
- package/dist/pkt-consent.js +6 -0
- package/dist/pkt-index.cjs +3 -3
- package/dist/pkt-index.js +40 -38
- package/dist/pkt-modal.cjs +1 -1
- package/dist/pkt-modal.js +1 -1
- package/package.json +5 -4
- package/src/components/consent/consent.ts +146 -0
- package/src/components/consent/index.ts +6 -0
- package/src/components/consent/strings.ts +125 -0
- package/src/components/index.ts +3 -0
- package/src/components/modal/modal.ts +1 -1
- package/dist/modal-cPcTJriW.cjs +0 -33
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,24 @@ og skriver commits ca etter [Conventional Commits](https://conventionalcommits.o
|
|
|
5
5
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
+
## [12.37.0](https://github.com/oslokommune/punkt/compare/12.36.2...12.37.0) (2025-05-05)
|
|
9
|
+
|
|
10
|
+
### ⚠ BREAKING CHANGES
|
|
11
|
+
Ingen
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
* Ny komponent Consent - innstillinger for informasjonskapsler (#2467).
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
Ingen
|
|
19
|
+
|
|
20
|
+
### Chores
|
|
21
|
+
Ingen
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
25
|
+
|
|
8
26
|
## [12.36.2](https://github.com/oslokommune/punkt/compare/12.36.1...12.36.2) (2025-04-30)
|
|
9
27
|
|
|
10
28
|
### ⚠ BREAKING CHANGES
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
import { P as k, x as l, n as a, a as h } from "./element-DjjF_tEh.js";
|
|
2
|
+
import "./button-B6uRE7uT.js";
|
|
3
|
+
import "./icon-Beoxup8E.js";
|
|
4
|
+
const u = {
|
|
5
|
+
i18n: {
|
|
6
|
+
nb: {
|
|
7
|
+
contentPresentation: {
|
|
8
|
+
title: "Oslo kommune bruker informasjonskapsler",
|
|
9
|
+
description: [
|
|
10
|
+
"For at nettstedet skal fungere og være trygt, bruker Oslo kommune informasjonskapsler. Noen er teknisk nødvendige, mens andre sikrer ulik funksjonalitet.",
|
|
11
|
+
"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."
|
|
12
|
+
],
|
|
13
|
+
buttons: {
|
|
14
|
+
accept: "Godta alle",
|
|
15
|
+
reject: "Kun nødvendige",
|
|
16
|
+
settings: "Innstillinger for informasjonskapsler"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
contentSettings: {
|
|
20
|
+
title: "Innstillinger for informasjonskapsler",
|
|
21
|
+
description: [
|
|
22
|
+
"Her kan du velge hvilke typer informasjonskapsler du vil tillate. Tillatelsen gjelder i 90 dager. Husk at nødvendige informasjonskapsler ikke kan velges bort.",
|
|
23
|
+
"Du kan når som helst endre innstillingene og finne mer informasjon nederst på nettstedet under «Innstillinger for informasjonskapsler» og «Personvern og informasjonskapsler»."
|
|
24
|
+
],
|
|
25
|
+
buttons: {
|
|
26
|
+
back: "Tilbake",
|
|
27
|
+
save: "Lagre innstillinger"
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
en: {
|
|
32
|
+
contentPresentation: {
|
|
33
|
+
title: "Before you visit Oslo kommune ...",
|
|
34
|
+
description: [
|
|
35
|
+
"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.",
|
|
36
|
+
"To read more about what we use cookies for, go to our privacy declaration which you will find at the bottom of our websites."
|
|
37
|
+
],
|
|
38
|
+
buttons: {
|
|
39
|
+
accept: "Yes, I accept",
|
|
40
|
+
reject: "Only necessary",
|
|
41
|
+
settings: "Go to settings"
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
contentSettings: {
|
|
45
|
+
title: "Her kan du aktivt velge mellom ulike informasjonskapsler",
|
|
46
|
+
description: [
|
|
47
|
+
"For å lese mer om hva vi bruker informasjonskapsler til gå til vår personvernserklering som du finner på våre nettsider"
|
|
48
|
+
],
|
|
49
|
+
buttons: {
|
|
50
|
+
back: "Back",
|
|
51
|
+
save: "Save settings"
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
}, g = globalThis, p = g.__cookieEvents || {
|
|
57
|
+
events: {},
|
|
58
|
+
on(e, n) {
|
|
59
|
+
this.events[e] || (this.events[e] = []), this.events[e].push(n);
|
|
60
|
+
},
|
|
61
|
+
off(e, n) {
|
|
62
|
+
this.events[e] && (this.events[e] = this.events[e].filter((t) => t !== n));
|
|
63
|
+
},
|
|
64
|
+
once(e, n) {
|
|
65
|
+
const t = (s) => {
|
|
66
|
+
this.off(e, t), n(s);
|
|
67
|
+
};
|
|
68
|
+
this.on(e, t);
|
|
69
|
+
},
|
|
70
|
+
emit(e, n) {
|
|
71
|
+
this.events[e] && this.events[e].forEach((t) => t(n));
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
g.__cookieEvents = p;
|
|
75
|
+
const m = p;
|
|
76
|
+
var f = Object.defineProperty, v = Object.getOwnPropertyDescriptor, r = (e, n, t, s) => {
|
|
77
|
+
for (var o = s > 1 ? void 0 : s ? v(n, t) : n, c = e.length - 1, d; c >= 0; c--)
|
|
78
|
+
(d = e[c]) && (o = (s ? d(n, t, o) : d(o)) || o);
|
|
79
|
+
return s && o && f(n, t, o), o;
|
|
80
|
+
};
|
|
81
|
+
let i = class extends k {
|
|
82
|
+
constructor() {
|
|
83
|
+
super(), this.hotjarId = null, this.googleAnalyticsId = null, this.triggerType = "button", this.triggerText = null, this.i18nLanguage = "nb";
|
|
84
|
+
}
|
|
85
|
+
connectedCallback() {
|
|
86
|
+
super.connectedCallback(), this.triggerText = this.triggerText || u.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
|
+
});
|
|
89
|
+
}
|
|
90
|
+
emitCookieConsents(e) {
|
|
91
|
+
const t = JSON.parse(e.value).items.reduce((s, o) => (s[o.name] = o.consent, s), {});
|
|
92
|
+
this.dispatchEvent(
|
|
93
|
+
new CustomEvent("toggle-consent", {
|
|
94
|
+
detail: t,
|
|
95
|
+
bubbles: !0,
|
|
96
|
+
composed: !0
|
|
97
|
+
})
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
firstUpdated(e) {
|
|
101
|
+
if (!document.querySelector("#oslo-consent-script") && window.location.hostname !== "localhost") {
|
|
102
|
+
window.googleAnalyticsId = this.googleAnalyticsId, window.hotjarId = this.hotjarId;
|
|
103
|
+
const n = document.createElement("script");
|
|
104
|
+
n.src = "https://cdn.web.oslo.kommune.no/cb/cb-v1.0.0.js", n.id = "oslo-consent-script", n.onload = () => {
|
|
105
|
+
this.triggerInit();
|
|
106
|
+
}, document.head.appendChild(n);
|
|
107
|
+
const t = document.createElement("link");
|
|
108
|
+
t.href = "https://cdn.web.oslo.kommune.no/cb/cb-v1.0.0.css", t.type = "text/css", t.rel = "stylesheet", t.id = "oslo-consent-styles", document.head.appendChild(t);
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
triggerInit() {
|
|
112
|
+
window.document.dispatchEvent(
|
|
113
|
+
new Event("DOMContentLoaded", {
|
|
114
|
+
bubbles: !0,
|
|
115
|
+
cancelable: !0
|
|
116
|
+
})
|
|
117
|
+
), window.cookieBanner.cookieConsent.validateConsentCookie().then((e) => {
|
|
118
|
+
if (e) {
|
|
119
|
+
const t = { value: window.cookieBanner.cookieConsent.getConsentCookie().items };
|
|
120
|
+
this.emitCookieConsents(t);
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
openModal(e) {
|
|
125
|
+
e.preventDefault(), window.cookieBanner.cookieConsent || this.triggerInit(), setTimeout(() => window.cookieBanner.openCookieModal());
|
|
126
|
+
}
|
|
127
|
+
render() {
|
|
128
|
+
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}>
|
|
129
|
+
<pkt-icon name="chevron-right" class="pkt-footer__link-icon"></pkt-icon>
|
|
130
|
+
${this.triggerText}
|
|
131
|
+
</a>` : this.triggerType === "icon" ? l`<pkt-button
|
|
132
|
+
skin="tertiary"
|
|
133
|
+
variant="icon-only"
|
|
134
|
+
iconName="cookie"
|
|
135
|
+
@click=${this.openModal}
|
|
136
|
+
>
|
|
137
|
+
>${this.triggerText}</pkt-button
|
|
138
|
+
>` : l`<pkt-button @click=${this.openModal}>${this.triggerText}</pkt-button>`;
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
r([
|
|
142
|
+
a({ type: String })
|
|
143
|
+
], i.prototype, "hotjarId", 2);
|
|
144
|
+
r([
|
|
145
|
+
a({ type: String })
|
|
146
|
+
], i.prototype, "googleAnalyticsId", 2);
|
|
147
|
+
r([
|
|
148
|
+
a({ type: String })
|
|
149
|
+
], i.prototype, "triggerType", 2);
|
|
150
|
+
r([
|
|
151
|
+
a({ type: String })
|
|
152
|
+
], i.prototype, "triggerText", 2);
|
|
153
|
+
r([
|
|
154
|
+
a({ type: String })
|
|
155
|
+
], i.prototype, "i18nLanguage", 2);
|
|
156
|
+
i = r([
|
|
157
|
+
h("pkt-consent")
|
|
158
|
+
], i);
|
|
159
|
+
export {
|
|
160
|
+
i as P
|
|
161
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";const s=require("./element-BSypUpzA.cjs");require("./button-BNdVIhUp.cjs");require("./icon-BnKGwYjj.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(t,e){this.events[t]||(this.events[t]=[]),this.events[t].push(e)},off(t,e){this.events[t]&&(this.events[t]=this.events[t].filter(n=>n!==e))},once(t,e){const n=o=>{this.off(t,n),e(o)};this.on(t,n)},emit(t,e){this.events[t]&&this.events[t].forEach(n=>n(e))}};c.__cookieEvents=d;const k=d;var p=Object.defineProperty,u=Object.getOwnPropertyDescriptor,a=(t,e,n,o)=>{for(var i=o>1?void 0:o?u(e,n):e,r=t.length-1,l;r>=0;r--)(l=t[r])&&(i=(o?l(e,n,i):l(i))||i);return o&&i&&p(e,n,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)})}emitCookieConsents(e){const o=JSON.parse(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!=="localhost"){window.googleAnalyticsId=this.googleAnalyticsId,window.hotjarId=this.hotjarId;const n=document.createElement("script");n.src="https://cdn.web.oslo.kommune.no/cb/cb-v1.0.0.js",n.id="oslo-consent-script",n.onload=()=>{this.triggerInit()},document.head.appendChild(n);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().items};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);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { }
|
package/dist/index.d.ts
CHANGED
|
@@ -156,6 +156,13 @@ export declare interface IPktComboboxOption {
|
|
|
156
156
|
value: string;
|
|
157
157
|
}
|
|
158
158
|
|
|
159
|
+
export declare interface IPktConsent {
|
|
160
|
+
hotjarId?: string | null;
|
|
161
|
+
googleAnalyticsId?: string | null;
|
|
162
|
+
triggerType?: 'button' | 'link' | 'footerlink' | 'icon' | null;
|
|
163
|
+
triggerText?: string | null;
|
|
164
|
+
}
|
|
165
|
+
|
|
159
166
|
export declare interface IPktHeading {
|
|
160
167
|
size?: TPktHeadingSize;
|
|
161
168
|
level?: TPktHeadingLevel;
|
|
@@ -552,6 +559,21 @@ export declare class PktComponent extends PktElement {
|
|
|
552
559
|
private handleGreeting;
|
|
553
560
|
}
|
|
554
561
|
|
|
562
|
+
export declare class PktConsent extends PktElement<IPktConsent> implements IPktConsent {
|
|
563
|
+
hotjarId: string | null;
|
|
564
|
+
googleAnalyticsId: string | null;
|
|
565
|
+
triggerType: 'button' | 'link' | 'footerlink' | 'icon' | null;
|
|
566
|
+
triggerText: string | null;
|
|
567
|
+
i18nLanguage: string;
|
|
568
|
+
constructor();
|
|
569
|
+
connectedCallback(): void;
|
|
570
|
+
emitCookieConsents(consent: any): void;
|
|
571
|
+
protected firstUpdated(_changedProperties: PropertyValues): void;
|
|
572
|
+
triggerInit(): void;
|
|
573
|
+
openModal(e: Event): void;
|
|
574
|
+
render(): TemplateResult<1>;
|
|
575
|
+
}
|
|
576
|
+
|
|
555
577
|
export declare class PktDatepicker extends PktInputElement {
|
|
556
578
|
/**
|
|
557
579
|
* Element attributes and properties
|
|
@@ -889,7 +911,7 @@ export declare class PktModal extends PktElement implements IPktModal {
|
|
|
889
911
|
private handleBackdropClick;
|
|
890
912
|
private isElementInViewport;
|
|
891
913
|
close: (event: Event, bypassNativeClose?: boolean) => void;
|
|
892
|
-
showModal: (event
|
|
914
|
+
showModal: (event?: Event | null) => void;
|
|
893
915
|
render(): TemplateResult<1>;
|
|
894
916
|
}
|
|
895
917
|
|
|
@@ -32,7 +32,7 @@ let l = class extends f {
|
|
|
32
32
|
o && !this.isElementInViewport(o) && o.scrollIntoView({ behavior: "smooth", block: "nearest" }), this.dispatchEvent(
|
|
33
33
|
new CustomEvent("close", { detail: { origin: t }, bubbles: !0, composed: !0 })
|
|
34
34
|
), e || (s = this.dialogRef.value) == null || s.close(), this.requestUpdate();
|
|
35
|
-
}, this.showModal = (t) => {
|
|
35
|
+
}, this.showModal = (t = null) => {
|
|
36
36
|
var o;
|
|
37
37
|
this._isOpen = !0, (o = this.dialogRef.value) == null || o.showModal();
|
|
38
38
|
const e = document.querySelector(".pkt-modal");
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";const d=require("./class-map-DCyaICmy.cjs"),l=require("./element-BSypUpzA.cjs"),h=require("./state-B5KCNjEd.cjs"),k=require("./pkt-slot-controller-plQxXRvV.cjs"),r=require("./ref-BvbyvXRH.cjs");require("./icon-BnKGwYjj.cjs");const m={hideCloseButton:{default:!1},closeOnBackdropClick:{default:!1},size:{default:"medium"}},p={props:m};var f=Object.defineProperty,v=Object.getOwnPropertyDescriptor,i=(c,e,t,s)=>{for(var o=s>1?void 0:s?v(e,t):e,n=c.length-1,a;n>=0;n--)(a=c[n])&&(o=(s?a(e,t,o):a(o))||o);return s&&o&&f(e,t,o),o};exports.PktModal=class extends l.PktElement{constructor(){super(),this.headingText="",this.removePadding=!1,this.hideCloseButton=p.props.hideCloseButton.default,this.closeOnBackdropClick=p.props.closeOnBackdropClick.default,this.closeButtonSkin="blue",this.size=p.props.size.default,this.defaultSlot=r.e(),this.dialogRef=r.e(),this._isOpen=!1,this.close=(e,t=!1)=>{var o;if(!this._isOpen)return;this._isOpen=!1,document.body.classList.remove("pkt-modal--open");const s=document.activeElement;s&&!this.isElementInViewport(s)&&s.scrollIntoView({behavior:"smooth",block:"nearest"}),this.dispatchEvent(new CustomEvent("close",{detail:{origin:e},bubbles:!0,composed:!0})),t||(o=this.dialogRef.value)==null||o.close(),this.requestUpdate()},this.showModal=(e=null)=>{var s;this._isOpen=!0,(s=this.dialogRef.value)==null||s.showModal();const t=document.querySelector(".pkt-modal");requestAnimationFrame(()=>{var o;this.dialogRef.value&&((o=this.dialogRef.value)==null||o.focus())}),t&&document.body.classList.add("pkt-modal--open"),this.dispatchEvent(new CustomEvent("showModal",{detail:{origin:e},bubbles:!0,composed:!0})),this.requestUpdate()},this.slotController=new k.PktSlotController(this,this.defaultSlot),this._isOpen=!1}async connectedCallback(){super.connectedCallback(),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("click",this.handleBackdropClick)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("click",this.handleBackdropClick)}handleKeyDown(e){e.key==="Escape"&&this.close(e)}handleBackdropClick(e){var t;this.closeOnBackdropClick&&e.target===((t=this.dialogRef)==null?void 0:t.value)&&this.close(e)}isElementInViewport(e){const t=e.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth)}render(){const e={"pkt-modal":!0,"pkt-modal--removePadding":this.removePadding??!1,"pkt-modal--noHeadingText":this.headingText===""||this.headingText===void 0,[`pkt-modal--${this.size}`]:this.size!==void 0},t={"pkt-modal__headingText":!0,"pkt-txt-24":!0},s={"pkt-modal__content":!0,"pkt-txt-18-light":!0},o=this.closeButtonSkin==="blue",n={"pkt-modal__closeButton":!0,[`pkt-modal__closeButton--${this.closeButtonSkin}`]:!0},a={"pkt-btn":!0,[`pkt-btn--${o?"tertiary":"primary"}`]:!0,"pkt-btn--icon-only":!0,"pkt-btn--medium":!0};return l.x`
|
|
2
|
+
<dialog
|
|
3
|
+
class=${d.e(e)}
|
|
4
|
+
${r.n(this.dialogRef)}
|
|
5
|
+
aria-labelledby="pkt-modal__headingText"
|
|
6
|
+
aria-describedby="pkt-modal__content"
|
|
7
|
+
@close=${u=>this.close(u,!0)}
|
|
8
|
+
>
|
|
9
|
+
<div class="pkt-modal__header">
|
|
10
|
+
<div class="pkt-modal__header-background"></div>
|
|
11
|
+
${this.headingText?l.x`<h1 id="pkt-modal__headingText" class=${d.e(t)}>
|
|
12
|
+
${this.headingText}
|
|
13
|
+
</h1>`:l.E}
|
|
14
|
+
${this.hideCloseButton?l.E:l.x`<div class="${d.e(n)}">
|
|
15
|
+
<pkt-button
|
|
16
|
+
@click=${u=>this.close(u)}
|
|
17
|
+
class=${d.e(a)}
|
|
18
|
+
aria-label="close"
|
|
19
|
+
iconname="close"
|
|
20
|
+
variant="icon-only"
|
|
21
|
+
>
|
|
22
|
+
</pkt-button>
|
|
23
|
+
</div>`}
|
|
24
|
+
</div>
|
|
25
|
+
<div class="pkt-modal__container">
|
|
26
|
+
<div
|
|
27
|
+
id="pkt-modal__content"
|
|
28
|
+
class=${d.e(s)}
|
|
29
|
+
${r.n(this.defaultSlot)}
|
|
30
|
+
></div>
|
|
31
|
+
</div>
|
|
32
|
+
</dialog>
|
|
33
|
+
`}};i([l.n({type:String,reflect:!0})],exports.PktModal.prototype,"headingText",2);i([l.n({type:Boolean,reflect:!0})],exports.PktModal.prototype,"removePadding",2);i([l.n({type:Boolean,reflect:!0})],exports.PktModal.prototype,"hideCloseButton",2);i([l.n({type:Boolean,reflect:!0})],exports.PktModal.prototype,"closeOnBackdropClick",2);i([l.n({type:String,reflect:!0})],exports.PktModal.prototype,"closeButtonSkin",2);i([l.n({type:String,reflect:!0})],exports.PktModal.prototype,"size",2);i([h.r()],exports.PktModal.prototype,"_isOpen",2);exports.PktModal=i([l.t("pkt-modal")],exports.PktModal);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./consent-jXR0vKAu.cjs"),t=e.PktConsent;Object.defineProperty(exports,"PktConsent",{enumerable:!0,get:()=>e.PktConsent});exports.default=t;
|
package/dist/pkt-index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
<div class="${
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("./alert-DWIElKEZ.cjs"),l=require("./accordionitem-cvsySqgK.cjs"),d=require("./backlink-HHM21crL.cjs"),b=require("./button-BNdVIhUp.cjs"),k=require("./calendar-CYY42kN4.cjs"),m=require("./card-BDcr3PII.cjs"),g=require("./combobox-D9NKnao2.cjs"),h=require("./consent-jXR0vKAu.cjs"),f=require("./checkbox-CqatE-eX.cjs"),t=require("./element-BSypUpzA.cjs"),y=require("./pkt-slot-controller-plQxXRvV.cjs"),s=require("./ref-BvbyvXRH.cjs"),O=require("./class-map-DCyaICmy.cjs"),j=require("./datepicker-cR9MtXOh.cjs"),q=require("./helptext-CCnYxYA9.cjs"),x=require("./heading-CP3NaeWE.cjs"),C=require("./icon-BnKGwYjj.cjs"),v=require("./input-wrapper-Cn929YTV.cjs"),S=require("./link-CnibgS3c.cjs"),$=require("./linkcard-DPGX1kb1.cjs"),L=require("./loader-BN4q8pSl.cjs"),_=require("./messagebox-BWJr42m9.cjs"),A=require("./modal-OC0efchb.cjs"),B=require("./progressbar-DiRfScnB.cjs"),p=require("./radiobutton-CIW0FvT8.cjs"),T=require("./tag-CgkUxA5D.cjs"),I=require("./textarea-qX4Inr1X.cjs"),M=require("./textinput-BlsgLNwW.cjs"),R=require("./select-BJziJVde.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
|
+
<div class="${O.e(e)}">
|
|
3
3
|
<h1 class="pkt-txt-28">${this.string}</h1>
|
|
4
4
|
|
|
5
5
|
<h2 class="pkt-txt-22">Innhold fra attributter og funksjoner</h2>
|
|
@@ -26,4 +26,4 @@
|
|
|
26
26
|
<ul>
|
|
27
27
|
${e.map(r=>t.x`<li>${r}</li>`)}
|
|
28
28
|
</ul>
|
|
29
|
-
`}doStuff(e){return e.reverse()}handleGreeting(){this.dispatchEvent(new CustomEvent("pkt-greeting",{detail:"Hei på deg!"}))}};o([t.n({type:String})],exports.PktComponent.prototype,"string",2);o([t.n({converter:
|
|
29
|
+
`}doStuff(e){return e.reverse()}handleGreeting(){this.dispatchEvent(new CustomEvent("pkt-greeting",{detail:"Hei på deg!"}))}};o([t.n({type:String})],exports.PktComponent.prototype,"string",2);o([t.n({converter:k.csvToArray})],exports.PktComponent.prototype,"strings",2);o([t.n({type:Boolean})],exports.PktComponent.prototype,"darkmode",2);o([t.n({type:Array})],exports.PktComponent.prototype,"_list",2);exports.PktComponent=o([t.t("pkt-component")],exports.PktComponent);Object.defineProperty(exports,"PktAlert",{enumerable:!0,get:()=>P.PktAlert});exports.PktAccordion=l.PktAccordion;exports.PktAccordionItem=l.PktAccordionItem;Object.defineProperty(exports,"PktBackLink",{enumerable:!0,get:()=>d.PktBackLink});Object.defineProperty(exports,"PktButton",{enumerable:!0,get:()=>b.PktButton});Object.defineProperty(exports,"PktCalendar",{enumerable:!0,get:()=>k.PktCalendar});Object.defineProperty(exports,"PktCard",{enumerable:!0,get:()=>m.PktCard});Object.defineProperty(exports,"PktCombobox",{enumerable:!0,get:()=>g.PktCombobox});Object.defineProperty(exports,"PktConsent",{enumerable:!0,get:()=>h.PktConsent});Object.defineProperty(exports,"PktCheckbox",{enumerable:!0,get:()=>f.PktCheckbox});Object.defineProperty(exports,"PktDatepicker",{enumerable:!0,get:()=>j.PktDatepicker});Object.defineProperty(exports,"PktHelptext",{enumerable:!0,get:()=>q.PktHelptext});Object.defineProperty(exports,"PktHeading",{enumerable:!0,get:()=>x.PktHeading});Object.defineProperty(exports,"PktIcon",{enumerable:!0,get:()=>C.PktIcon});Object.defineProperty(exports,"PktInputWrapper",{enumerable:!0,get:()=>v.PktInputWrapper});Object.defineProperty(exports,"PktLink",{enumerable:!0,get:()=>S.PktLink});Object.defineProperty(exports,"PktLinkCard",{enumerable:!0,get:()=>$.PktLinkCard});Object.defineProperty(exports,"PktLoader",{enumerable:!0,get:()=>L.PktLoader});Object.defineProperty(exports,"PktMessagebox",{enumerable:!0,get:()=>_.PktMessagebox});Object.defineProperty(exports,"PktModal",{enumerable:!0,get:()=>A.PktModal});Object.defineProperty(exports,"PktProgressbar",{enumerable:!0,get:()=>B.PktProgressbar});Object.defineProperty(exports,"PktRadioButton",{enumerable:!0,get:()=>p.PktRadioButton});Object.defineProperty(exports,"PktRadiobutton",{enumerable:!0,get:()=>p.PktRadioButton});Object.defineProperty(exports,"PktTag",{enumerable:!0,get:()=>T.PktTag});Object.defineProperty(exports,"PktTextarea",{enumerable:!0,get:()=>I.PktTextarea});Object.defineProperty(exports,"PktTextinput",{enumerable:!0,get:()=>M.PktTextinput});Object.defineProperty(exports,"PktSelect",{enumerable:!0,get:()=>R.PktSelect});
|
package/dist/pkt-index.js
CHANGED
|
@@ -6,33 +6,34 @@ import { c as f } from "./calendar-KDcOWD6V.js";
|
|
|
6
6
|
import { P as D } from "./calendar-KDcOWD6V.js";
|
|
7
7
|
import { P as G } from "./card-B5zTEmH1.js";
|
|
8
8
|
import { P as K } from "./combobox-CELUAZxF.js";
|
|
9
|
-
import { P as U } from "./
|
|
10
|
-
import { P as
|
|
9
|
+
import { P as U } from "./consent-Baktq_-1.js";
|
|
10
|
+
import { P as q } from "./checkbox-CyYfA2fu.js";
|
|
11
|
+
import { P as k, t as h, x as P, n, a as c } from "./element-DjjF_tEh.js";
|
|
11
12
|
import { P as x } from "./pkt-slot-controller-DFrc5O93.js";
|
|
12
13
|
import { e as m, n as d } from "./ref-iIffqQAI.js";
|
|
13
14
|
import { e as u } from "./class-map-KyMqi0fa.js";
|
|
14
|
-
import { P as
|
|
15
|
-
import { P as
|
|
16
|
-
import { P as
|
|
17
|
-
import { P as
|
|
18
|
-
import { P as
|
|
19
|
-
import { P as
|
|
20
|
-
import { P as
|
|
21
|
-
import { P as
|
|
22
|
-
import { P as
|
|
23
|
-
import { P as
|
|
24
|
-
import { P as
|
|
25
|
-
import { P as
|
|
26
|
-
import { P as
|
|
27
|
-
import { P as
|
|
28
|
-
import { P as
|
|
29
|
-
import { P as
|
|
15
|
+
import { P as F } from "./datepicker-CpkTwszH.js";
|
|
16
|
+
import { P as Q } from "./helptext-BLHAJ1aC.js";
|
|
17
|
+
import { P as X } from "./heading-BkC05ohM.js";
|
|
18
|
+
import { P as Z } from "./icon-Beoxup8E.js";
|
|
19
|
+
import { P as et } from "./input-wrapper-CeeNYbDA.js";
|
|
20
|
+
import { P as ot } from "./link-BYI8VNGd.js";
|
|
21
|
+
import { P as at } from "./linkcard--zuuAt_v.js";
|
|
22
|
+
import { P as it } from "./loader-DgIiyYBl.js";
|
|
23
|
+
import { P as lt } from "./messagebox-cme5VbUM.js";
|
|
24
|
+
import { P as mt } from "./modal-DIwagdAc.js";
|
|
25
|
+
import { P as ft } from "./progressbar-BKt_aj7f.js";
|
|
26
|
+
import { P as ht, P as ct } from "./radiobutton-DtHuz7qn.js";
|
|
27
|
+
import { P as ut } from "./tag-CGnj4c1Z.js";
|
|
28
|
+
import { P as vt } from "./textarea-CiA4IzMs.js";
|
|
29
|
+
import { P as bt } from "./textinput-CrxjZNEq.js";
|
|
30
|
+
import { P as $t } from "./select-DbRLz-7l.js";
|
|
30
31
|
var g = Object.defineProperty, v = Object.getOwnPropertyDescriptor, s = (t, e, i, a) => {
|
|
31
32
|
for (var r = a > 1 ? void 0 : a ? v(e, i) : e, p = t.length - 1, l; p >= 0; p--)
|
|
32
33
|
(l = t[p]) && (r = (a ? l(e, i, r) : l(r)) || r);
|
|
33
34
|
return a && r && g(e, i, r), r;
|
|
34
35
|
};
|
|
35
|
-
let o = class extends
|
|
36
|
+
let o = class extends k {
|
|
36
37
|
constructor() {
|
|
37
38
|
super(), this.string = "", this.strings = [], this.darkmode = !1, this._list = [], this.defaultSlot = m(), this.namedSlot = m(), this.slotController = new x(this, this.defaultSlot, this.namedSlot);
|
|
38
39
|
}
|
|
@@ -74,7 +75,7 @@ let o = class extends h {
|
|
|
74
75
|
|
|
75
76
|
<h2 class="pkt-txt-22">Knapp som emitter en event</h2>
|
|
76
77
|
<button type="button" @click=${() => this.handleGreeting()}>
|
|
77
|
-
Si ${
|
|
78
|
+
Si ${h.example.hi}
|
|
78
79
|
</button>
|
|
79
80
|
</div>
|
|
80
81
|
`;
|
|
@@ -126,24 +127,25 @@ export {
|
|
|
126
127
|
T as PktButton,
|
|
127
128
|
D as PktCalendar,
|
|
128
129
|
G as PktCard,
|
|
129
|
-
|
|
130
|
+
q as PktCheckbox,
|
|
130
131
|
K as PktCombobox,
|
|
131
132
|
o as PktComponent,
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
Z as
|
|
137
|
-
et as
|
|
138
|
-
ot as
|
|
139
|
-
at as
|
|
140
|
-
it as
|
|
141
|
-
lt as
|
|
142
|
-
mt as
|
|
143
|
-
ft as
|
|
144
|
-
ht as
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
ut as
|
|
148
|
-
vt as
|
|
133
|
+
U as PktConsent,
|
|
134
|
+
F as PktDatepicker,
|
|
135
|
+
X as PktHeading,
|
|
136
|
+
Q as PktHelptext,
|
|
137
|
+
Z as PktIcon,
|
|
138
|
+
et as PktInputWrapper,
|
|
139
|
+
ot as PktLink,
|
|
140
|
+
at as PktLinkCard,
|
|
141
|
+
it as PktLoader,
|
|
142
|
+
lt as PktMessagebox,
|
|
143
|
+
mt as PktModal,
|
|
144
|
+
ft as PktProgressbar,
|
|
145
|
+
ht as PktRadioButton,
|
|
146
|
+
ct as PktRadiobutton,
|
|
147
|
+
$t as PktSelect,
|
|
148
|
+
ut as PktTag,
|
|
149
|
+
vt as PktTextarea,
|
|
150
|
+
bt as PktTextinput
|
|
149
151
|
};
|
package/dist/pkt-modal.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./modal-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./modal-OC0efchb.cjs"),t=e.PktModal;Object.defineProperty(exports,"PktModal",{enumerable:!0,get:()=>e.PktModal});exports.default=t;
|
package/dist/pkt-modal.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslokommune/punkt-elements",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.37.0",
|
|
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,14 +23,15 @@
|
|
|
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",
|
|
26
27
|
"date-fns": "^4.1.0",
|
|
27
28
|
"lit": "^3.3.0",
|
|
28
29
|
"react-dom": ">=18.2.22",
|
|
29
30
|
"urlpattern-polyfill": "^10.0.0"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|
|
32
|
-
"@oslokommune/punkt-assets": "^12.
|
|
33
|
-
"@oslokommune/punkt-css": "^12.
|
|
33
|
+
"@oslokommune/punkt-assets": "^12.37.0",
|
|
34
|
+
"@oslokommune/punkt-css": "^12.37.0",
|
|
34
35
|
"sass": "^1.78.0",
|
|
35
36
|
"typescript": "^5.6.2",
|
|
36
37
|
"vite": "^5.4.18",
|
|
@@ -57,5 +58,5 @@
|
|
|
57
58
|
"url": "https://github.com/oslokommune/punkt/issues"
|
|
58
59
|
},
|
|
59
60
|
"license": "MIT",
|
|
60
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "119c31d1536757ed597224baa05966cf8bca5ecc"
|
|
61
62
|
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { customElement, property } from 'lit/decorators.js'
|
|
2
|
+
import { html, PropertyValues } from 'lit'
|
|
3
|
+
import { PktElement } from '@/base-elements/element'
|
|
4
|
+
import { consentStrings } from './strings'
|
|
5
|
+
import { CookieEvents } from '@oslokommune/cookie-manager'
|
|
6
|
+
import '../button'
|
|
7
|
+
import '../icon'
|
|
8
|
+
|
|
9
|
+
// Extend the Window interface to include googleAnalyticsId
|
|
10
|
+
declare global {
|
|
11
|
+
interface Window {
|
|
12
|
+
googleAnalyticsId?: string | null
|
|
13
|
+
hotjarId?: string | null
|
|
14
|
+
cookieBanner?: any
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export interface IPktConsent {
|
|
19
|
+
hotjarId?: string | null
|
|
20
|
+
googleAnalyticsId?: string | null
|
|
21
|
+
triggerType?: 'button' | 'link' | 'footerlink' | 'icon' | null
|
|
22
|
+
triggerText?: string | null
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@customElement('pkt-consent')
|
|
26
|
+
export class PktConsent extends PktElement<IPktConsent> implements IPktConsent {
|
|
27
|
+
@property({ type: String }) hotjarId: string | null = null
|
|
28
|
+
@property({ type: String }) googleAnalyticsId: string | null = null
|
|
29
|
+
@property({ type: String }) triggerType: 'button' | 'link' | 'footerlink' | 'icon' | null =
|
|
30
|
+
'button'
|
|
31
|
+
@property({ type: String }) triggerText: string | null = null
|
|
32
|
+
@property({ type: String }) i18nLanguage: string = 'nb'
|
|
33
|
+
|
|
34
|
+
constructor() {
|
|
35
|
+
super()
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
connectedCallback() {
|
|
39
|
+
super.connectedCallback()
|
|
40
|
+
this.triggerText =
|
|
41
|
+
this.triggerText ||
|
|
42
|
+
consentStrings.i18n[this.i18nLanguage as keyof typeof consentStrings.i18n].contentPresentation
|
|
43
|
+
.buttons.settings
|
|
44
|
+
|
|
45
|
+
if (this.googleAnalyticsId) {
|
|
46
|
+
window.googleAnalyticsId = this.googleAnalyticsId
|
|
47
|
+
}
|
|
48
|
+
if (this.hotjarId) {
|
|
49
|
+
window.hotjarId = this.hotjarId
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
CookieEvents.on('CookieManager.setCookie', (consent: any) => {
|
|
53
|
+
this.emitCookieConsents(consent)
|
|
54
|
+
})
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
emitCookieConsents(consent: any) {
|
|
58
|
+
const consents = JSON.parse(consent.value)
|
|
59
|
+
|
|
60
|
+
const consentDetails = consents.items.reduce((acc: any, item: any) => {
|
|
61
|
+
acc[item.name] = item.consent
|
|
62
|
+
return acc
|
|
63
|
+
}, {})
|
|
64
|
+
this.dispatchEvent(
|
|
65
|
+
new CustomEvent('toggle-consent', {
|
|
66
|
+
detail: consentDetails,
|
|
67
|
+
bubbles: true,
|
|
68
|
+
composed: true,
|
|
69
|
+
}),
|
|
70
|
+
)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
protected firstUpdated(_changedProperties: PropertyValues): void {
|
|
74
|
+
if (
|
|
75
|
+
!document.querySelector('#oslo-consent-script') &&
|
|
76
|
+
window.location.hostname !== 'localhost'
|
|
77
|
+
) {
|
|
78
|
+
window.googleAnalyticsId = this.googleAnalyticsId
|
|
79
|
+
window.hotjarId = this.hotjarId
|
|
80
|
+
|
|
81
|
+
const script = document.createElement('script')
|
|
82
|
+
script.src = 'https://cdn.web.oslo.kommune.no/cb/cb-v1.0.0.js'
|
|
83
|
+
script.id = 'oslo-consent-script'
|
|
84
|
+
script.onload = () => {
|
|
85
|
+
this.triggerInit()
|
|
86
|
+
}
|
|
87
|
+
document.head.appendChild(script)
|
|
88
|
+
|
|
89
|
+
const styles = document.createElement('link')
|
|
90
|
+
styles.href = 'https://cdn.web.oslo.kommune.no/cb/cb-v1.0.0.css'
|
|
91
|
+
styles.type = 'text/css'
|
|
92
|
+
styles.rel = 'stylesheet'
|
|
93
|
+
styles.id = 'oslo-consent-styles'
|
|
94
|
+
document.head.appendChild(styles)
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
triggerInit() {
|
|
99
|
+
// Slight hack since we can't access the right methods to do this “properly”
|
|
100
|
+
window.document.dispatchEvent(
|
|
101
|
+
new Event('DOMContentLoaded', {
|
|
102
|
+
bubbles: true,
|
|
103
|
+
cancelable: true,
|
|
104
|
+
}),
|
|
105
|
+
)
|
|
106
|
+
|
|
107
|
+
window.cookieBanner.cookieConsent.validateConsentCookie().then((response: boolean) => {
|
|
108
|
+
if (response) {
|
|
109
|
+
const cookie = window.cookieBanner.cookieConsent.getConsentCookie()
|
|
110
|
+
const consents = { value: cookie.items }
|
|
111
|
+
this.emitCookieConsents(consents)
|
|
112
|
+
}
|
|
113
|
+
})
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
openModal(e: Event) {
|
|
117
|
+
e.preventDefault()
|
|
118
|
+
if (!window.cookieBanner.cookieConsent) {
|
|
119
|
+
this.triggerInit()
|
|
120
|
+
}
|
|
121
|
+
setTimeout(() => window.cookieBanner.openCookieModal())
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
render() {
|
|
125
|
+
if (this.triggerType === 'link') {
|
|
126
|
+
return html`<a href="#" class="pkt-link" @click=${this.openModal}>${this.triggerText}</a>`
|
|
127
|
+
}
|
|
128
|
+
if (this.triggerType === 'footerlink') {
|
|
129
|
+
return html`<a href="#" class="pkt-footer__link" @click=${this.openModal}>
|
|
130
|
+
<pkt-icon name="chevron-right" class="pkt-footer__link-icon"></pkt-icon>
|
|
131
|
+
${this.triggerText}
|
|
132
|
+
</a>`
|
|
133
|
+
}
|
|
134
|
+
if (this.triggerType === 'icon') {
|
|
135
|
+
return html`<pkt-button
|
|
136
|
+
skin="tertiary"
|
|
137
|
+
variant="icon-only"
|
|
138
|
+
iconName="cookie"
|
|
139
|
+
@click=${this.openModal}
|
|
140
|
+
>
|
|
141
|
+
>${this.triggerText}</pkt-button
|
|
142
|
+
>`
|
|
143
|
+
}
|
|
144
|
+
return html`<pkt-button @click=${this.openModal}>${this.triggerText}</pkt-button>`
|
|
145
|
+
}
|
|
146
|
+
}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
export const consentStrings = {
|
|
2
|
+
i18n: {
|
|
3
|
+
nb: {
|
|
4
|
+
contentPresentation: {
|
|
5
|
+
title: 'Oslo kommune bruker informasjonskapsler',
|
|
6
|
+
description: [
|
|
7
|
+
'For at nettstedet skal fungere og være trygt, bruker Oslo kommune informasjonskapsler. Noen er teknisk nødvendige, mens andre sikrer ulik funksjonalitet.',
|
|
8
|
+
'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.',
|
|
9
|
+
],
|
|
10
|
+
buttons: {
|
|
11
|
+
accept: 'Godta alle',
|
|
12
|
+
reject: 'Kun nødvendige',
|
|
13
|
+
settings: 'Innstillinger for informasjonskapsler',
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
contentSettings: {
|
|
17
|
+
title: 'Innstillinger for informasjonskapsler',
|
|
18
|
+
description: [
|
|
19
|
+
'Her kan du velge hvilke typer informasjonskapsler du vil tillate. Tillatelsen gjelder i 90 dager. Husk at nødvendige informasjonskapsler ikke kan velges bort.',
|
|
20
|
+
'Du kan når som helst endre innstillingene og finne mer informasjon nederst på nettstedet under «Innstillinger for informasjonskapsler» og «Personvern og informasjonskapsler».',
|
|
21
|
+
],
|
|
22
|
+
buttons: {
|
|
23
|
+
back: 'Tilbake',
|
|
24
|
+
save: 'Lagre innstillinger',
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
en: {
|
|
29
|
+
contentPresentation: {
|
|
30
|
+
title: 'Before you visit Oslo kommune ...',
|
|
31
|
+
description: [
|
|
32
|
+
'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.',
|
|
33
|
+
'To read more about what we use cookies for, go to our privacy declaration which you will find at the bottom of our websites.',
|
|
34
|
+
],
|
|
35
|
+
buttons: {
|
|
36
|
+
accept: 'Yes, I accept',
|
|
37
|
+
reject: 'Only necessary',
|
|
38
|
+
settings: 'Go to settings',
|
|
39
|
+
},
|
|
40
|
+
},
|
|
41
|
+
contentSettings: {
|
|
42
|
+
title: 'Her kan du aktivt velge mellom ulike informasjonskapsler',
|
|
43
|
+
description: [
|
|
44
|
+
'For å lese mer om hva vi bruker informasjonskapsler til gå til vår personvernserklering som du finner på våre nettsider',
|
|
45
|
+
],
|
|
46
|
+
buttons: {
|
|
47
|
+
back: 'Back',
|
|
48
|
+
save: 'Save settings',
|
|
49
|
+
},
|
|
50
|
+
},
|
|
51
|
+
},
|
|
52
|
+
},
|
|
53
|
+
cookies: [
|
|
54
|
+
{
|
|
55
|
+
name: 'statistics',
|
|
56
|
+
defaultValue: null,
|
|
57
|
+
i18n: {
|
|
58
|
+
nb: {
|
|
59
|
+
title: 'Statistikk og analyse',
|
|
60
|
+
description:
|
|
61
|
+
'Jeg godtar at Oslo kommune bruker informasjonskapsler til å innhente data om statistikk og brukeradferd.',
|
|
62
|
+
buttons: {
|
|
63
|
+
yes: 'Ja',
|
|
64
|
+
no: 'Nei',
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
en: {
|
|
68
|
+
title: 'Statistics and analytics',
|
|
69
|
+
description: 'Select your preference for statistics and analytics',
|
|
70
|
+
buttons: {
|
|
71
|
+
yes: 'Yes',
|
|
72
|
+
no: 'No',
|
|
73
|
+
},
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
name: 'survey',
|
|
79
|
+
defaultValue: null,
|
|
80
|
+
i18n: {
|
|
81
|
+
nb: {
|
|
82
|
+
title: 'Skriftlige tilbakemeldinger',
|
|
83
|
+
description:
|
|
84
|
+
'Jeg godtar at Oslo kommune bruker informasjonskapsler til å vise responsfelt og registrere tilbakemeldinger.',
|
|
85
|
+
buttons: {
|
|
86
|
+
yes: 'Ja',
|
|
87
|
+
no: 'Nei',
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
en: {
|
|
91
|
+
title: 'Survey',
|
|
92
|
+
description: 'Select your preference for survey',
|
|
93
|
+
buttons: {
|
|
94
|
+
yes: 'Yes',
|
|
95
|
+
no: 'No',
|
|
96
|
+
},
|
|
97
|
+
},
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
name: 'functional',
|
|
102
|
+
defaultValue: true,
|
|
103
|
+
i18n: {
|
|
104
|
+
nb: {
|
|
105
|
+
title: 'Funksjonelle informasjonskapsler',
|
|
106
|
+
description:
|
|
107
|
+
'Jeg godtar at Oslo kommune bruker informasjonskapsler for å gjøre ulike funksjoner på nettstedet mulige (for eksempel skjemaer og barnehagevelger).',
|
|
108
|
+
buttons: {
|
|
109
|
+
yes: 'Ja',
|
|
110
|
+
no: 'Nei',
|
|
111
|
+
},
|
|
112
|
+
},
|
|
113
|
+
en: {
|
|
114
|
+
title: 'Functional cookies',
|
|
115
|
+
description:
|
|
116
|
+
'For the website to function optimally, we recommend that you accept these cookies',
|
|
117
|
+
buttons: {
|
|
118
|
+
yes: 'Yes',
|
|
119
|
+
no: 'No',
|
|
120
|
+
},
|
|
121
|
+
},
|
|
122
|
+
},
|
|
123
|
+
},
|
|
124
|
+
],
|
|
125
|
+
}
|
package/src/components/index.ts
CHANGED
|
@@ -6,6 +6,7 @@ export { PktButton } from '@/components/button'
|
|
|
6
6
|
export { PktCalendar } from '@/components/calendar'
|
|
7
7
|
export { PktCard } from '@/components/card'
|
|
8
8
|
export { PktCombobox } from './combobox'
|
|
9
|
+
export { PktConsent } from './consent'
|
|
9
10
|
export { PktCheckbox } from '@/components/checkbox'
|
|
10
11
|
export { PktComponent } from '../base-elements/component-template.js'
|
|
11
12
|
export { PktDatepicker } from '@/components/datepicker/datepicker.js'
|
|
@@ -65,3 +66,5 @@ export type { TSelectOption } from '@/components/select'
|
|
|
65
66
|
export type { IPktBackLink } from '@/components/backlink'
|
|
66
67
|
|
|
67
68
|
export type { IPktLoader, TPktLoaderVariant } from '@/components/loader'
|
|
69
|
+
|
|
70
|
+
export type { IPktConsent } from '@/components/consent'
|
|
@@ -97,7 +97,7 @@ export class PktModal extends PktElement implements IPktModal {
|
|
|
97
97
|
this.requestUpdate()
|
|
98
98
|
}
|
|
99
99
|
|
|
100
|
-
public showModal = (event: Event) => {
|
|
100
|
+
public showModal = (event: Event | null = null) => {
|
|
101
101
|
this._isOpen = true
|
|
102
102
|
this.dialogRef.value?.showModal()
|
|
103
103
|
const modal = document.querySelector('.pkt-modal')
|
package/dist/modal-cPcTJriW.cjs
DELETED
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
"use strict";const d=require("./class-map-DCyaICmy.cjs"),i=require("./element-BSypUpzA.cjs"),h=require("./state-B5KCNjEd.cjs"),k=require("./pkt-slot-controller-plQxXRvV.cjs"),r=require("./ref-BvbyvXRH.cjs");require("./icon-BnKGwYjj.cjs");const m={hideCloseButton:{default:!1},closeOnBackdropClick:{default:!1},size:{default:"medium"}},p={props:m};var f=Object.defineProperty,v=Object.getOwnPropertyDescriptor,l=(c,e,t,s)=>{for(var o=s>1?void 0:s?v(e,t):e,n=c.length-1,a;n>=0;n--)(a=c[n])&&(o=(s?a(e,t,o):a(o))||o);return s&&o&&f(e,t,o),o};exports.PktModal=class extends i.PktElement{constructor(){super(),this.headingText="",this.removePadding=!1,this.hideCloseButton=p.props.hideCloseButton.default,this.closeOnBackdropClick=p.props.closeOnBackdropClick.default,this.closeButtonSkin="blue",this.size=p.props.size.default,this.defaultSlot=r.e(),this.dialogRef=r.e(),this._isOpen=!1,this.close=(e,t=!1)=>{var o;if(!this._isOpen)return;this._isOpen=!1,document.body.classList.remove("pkt-modal--open");const s=document.activeElement;s&&!this.isElementInViewport(s)&&s.scrollIntoView({behavior:"smooth",block:"nearest"}),this.dispatchEvent(new CustomEvent("close",{detail:{origin:e},bubbles:!0,composed:!0})),t||(o=this.dialogRef.value)==null||o.close(),this.requestUpdate()},this.showModal=e=>{var s;this._isOpen=!0,(s=this.dialogRef.value)==null||s.showModal();const t=document.querySelector(".pkt-modal");requestAnimationFrame(()=>{var o;this.dialogRef.value&&((o=this.dialogRef.value)==null||o.focus())}),t&&document.body.classList.add("pkt-modal--open"),this.dispatchEvent(new CustomEvent("showModal",{detail:{origin:e},bubbles:!0,composed:!0})),this.requestUpdate()},this.slotController=new k.PktSlotController(this,this.defaultSlot),this._isOpen=!1}async connectedCallback(){super.connectedCallback(),document.addEventListener("keydown",this.handleKeyDown),document.addEventListener("click",this.handleBackdropClick)}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("click",this.handleBackdropClick)}handleKeyDown(e){e.key==="Escape"&&this.close(e)}handleBackdropClick(e){var t;this.closeOnBackdropClick&&e.target===((t=this.dialogRef)==null?void 0:t.value)&&this.close(e)}isElementInViewport(e){const t=e.getBoundingClientRect();return t.top>=0&&t.left>=0&&t.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&t.right<=(window.innerWidth||document.documentElement.clientWidth)}render(){const e={"pkt-modal":!0,"pkt-modal--removePadding":this.removePadding??!1,"pkt-modal--noHeadingText":this.headingText===""||this.headingText===void 0,[`pkt-modal--${this.size}`]:this.size!==void 0},t={"pkt-modal__headingText":!0,"pkt-txt-24":!0},s={"pkt-modal__content":!0,"pkt-txt-18-light":!0},o=this.closeButtonSkin==="blue",n={"pkt-modal__closeButton":!0,[`pkt-modal__closeButton--${this.closeButtonSkin}`]:!0},a={"pkt-btn":!0,[`pkt-btn--${o?"tertiary":"primary"}`]:!0,"pkt-btn--icon-only":!0,"pkt-btn--medium":!0};return i.x`
|
|
2
|
-
<dialog
|
|
3
|
-
class=${d.e(e)}
|
|
4
|
-
${r.n(this.dialogRef)}
|
|
5
|
-
aria-labelledby="pkt-modal__headingText"
|
|
6
|
-
aria-describedby="pkt-modal__content"
|
|
7
|
-
@close=${u=>this.close(u,!0)}
|
|
8
|
-
>
|
|
9
|
-
<div class="pkt-modal__header">
|
|
10
|
-
<div class="pkt-modal__header-background"></div>
|
|
11
|
-
${this.headingText?i.x`<h1 id="pkt-modal__headingText" class=${d.e(t)}>
|
|
12
|
-
${this.headingText}
|
|
13
|
-
</h1>`:i.E}
|
|
14
|
-
${this.hideCloseButton?i.E:i.x`<div class="${d.e(n)}">
|
|
15
|
-
<pkt-button
|
|
16
|
-
@click=${u=>this.close(u)}
|
|
17
|
-
class=${d.e(a)}
|
|
18
|
-
aria-label="close"
|
|
19
|
-
iconname="close"
|
|
20
|
-
variant="icon-only"
|
|
21
|
-
>
|
|
22
|
-
</pkt-button>
|
|
23
|
-
</div>`}
|
|
24
|
-
</div>
|
|
25
|
-
<div class="pkt-modal__container">
|
|
26
|
-
<div
|
|
27
|
-
id="pkt-modal__content"
|
|
28
|
-
class=${d.e(s)}
|
|
29
|
-
${r.n(this.defaultSlot)}
|
|
30
|
-
></div>
|
|
31
|
-
</div>
|
|
32
|
-
</dialog>
|
|
33
|
-
`}};l([i.n({type:String,reflect:!0})],exports.PktModal.prototype,"headingText",2);l([i.n({type:Boolean,reflect:!0})],exports.PktModal.prototype,"removePadding",2);l([i.n({type:Boolean,reflect:!0})],exports.PktModal.prototype,"hideCloseButton",2);l([i.n({type:Boolean,reflect:!0})],exports.PktModal.prototype,"closeOnBackdropClick",2);l([i.n({type:String,reflect:!0})],exports.PktModal.prototype,"closeButtonSkin",2);l([i.n({type:String,reflect:!0})],exports.PktModal.prototype,"size",2);l([h.r()],exports.PktModal.prototype,"_isOpen",2);exports.PktModal=l([i.t("pkt-modal")],exports.PktModal);
|