@oslokommune/punkt-elements 12.38.1 → 12.39.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 CHANGED
@@ -5,6 +5,41 @@ og skriver commits ca etter [Conventional Commits](https://conventionalcommits.o
5
5
 
6
6
  ---
7
7
 
8
+ ## [12.39.0](https://github.com/oslokommune/punkt/compare/12.38.2...12.39.0) (2025-05-15)
9
+
10
+ ### ⚠ BREAKING CHANGES
11
+ Ingen
12
+
13
+ ### Features
14
+ * Nye muligheter i Modal: Skuff og gjennomsiktig backdrop (Pluss animert åpning/lukking) (#2548).
15
+
16
+
17
+ ### Bug Fixes
18
+ Ingen
19
+
20
+ ### Chores
21
+ Ingen
22
+
23
+ ---
24
+
25
+
26
+ ## [12.38.2](https://github.com/oslokommune/punkt/compare/12.38.1...12.38.2) (2025-05-14)
27
+
28
+ ### ⚠ BREAKING CHANGES
29
+ Ingen
30
+
31
+ ### Features
32
+ Ingen
33
+
34
+ ### Bug Fixes
35
+ Ingen
36
+
37
+ ### Chores
38
+ Ingen
39
+
40
+ ---
41
+
42
+
8
43
  ## [12.38.1](https://github.com/oslokommune/punkt/compare/12.38.0...12.38.1) (2025-05-14)
9
44
 
10
45
  ### ⚠ BREAKING CHANGES
@@ -95,13 +95,13 @@ s([
95
95
  a({ type: String })
96
96
  ], i.prototype, "variant", 2);
97
97
  s([
98
- a({ type: String })
98
+ a({ type: String, reflect: !0 })
99
99
  ], i.prototype, "state", 2);
100
100
  s([
101
101
  a({ type: String, reflect: !0 })
102
102
  ], i.prototype, "type", 2);
103
103
  s([
104
- a({ type: Boolean })
104
+ a({ type: Boolean, reflect: !0 })
105
105
  ], i.prototype, "isLoading", 2);
106
106
  s([
107
107
  a({ type: Boolean, reflect: !0 })
@@ -9,4 +9,4 @@
9
9
  <span class="pkt-btn__text" ${d.n(this.defaultSlot)}></span>
10
10
  ${this.variant==="icons-right-and-left"?i.x`<pkt-icon class="pkt-btn__icon" name=${this.secondIconName}></pkt-icon>`:i.E}
11
11
  </div>
12
- `}updateElementClasses(){const t=new Set,s=this.getAttribute("class");t.add("pkt-btn"),s&&s.split(" ").forEach(n=>t.add(n)),this.size&&t.add(`pkt-btn--${this.size}`),this.skin&&t.add(`pkt-btn--${this.skin}`),this.variant&&t.add(`pkt-btn--${this.variant}`),this.color&&t.add(`pkt-btn--${this.color}`),this.isLoading&&t.add("pkt-btn--active"),this.state&&t.add(`pkt-btn--${this.state}`),this.disabled&&t.add("pkt-btn--disabled"),this.className=[...t].join(" ")}handleClick(t){if(this.disabled||this.isLoading){t.preventDefault(),t.stopImmediatePropagation();return}if(this.type==="submit"&&this.internals.form){this.internals.form.requestSubmit();return}if(this.type==="reset"&&this.internals.form){this.internals.form.reset();return}this.onClick&&typeof this.onClick=="function"&&this.onClick!==this.handleClick&&this.onClick(t),this.dispatchEvent(new CustomEvent("button-click",{bubbles:!0,composed:!0,detail:{originalEvent:t}}))}handleKeydown(t){if(!(this.disabled||this.isLoading)&&(t.key==="Enter"||t.key===" ")){t.preventDefault();const s=t.target;s&&s.click()}}};exports.PktButton.formAssociated=!0;e([i.n({type:String})],exports.PktButton.prototype,"iconName",2);e([i.n({type:String})],exports.PktButton.prototype,"secondIconName",2);e([i.n({type:String})],exports.PktButton.prototype,"mode",2);e([i.n({type:String})],exports.PktButton.prototype,"size",2);e([i.n({type:String})],exports.PktButton.prototype,"color",2);e([i.n({type:String})],exports.PktButton.prototype,"skin",2);e([i.n({type:String})],exports.PktButton.prototype,"variant",2);e([i.n({type:String})],exports.PktButton.prototype,"state",2);e([i.n({type:String,reflect:!0})],exports.PktButton.prototype,"type",2);e([i.n({type:Boolean})],exports.PktButton.prototype,"isLoading",2);e([i.n({type:Boolean,reflect:!0})],exports.PktButton.prototype,"disabled",2);exports.PktButton=e([i.t("pkt-button")],exports.PktButton);
12
+ `}updateElementClasses(){const t=new Set,s=this.getAttribute("class");t.add("pkt-btn"),s&&s.split(" ").forEach(n=>t.add(n)),this.size&&t.add(`pkt-btn--${this.size}`),this.skin&&t.add(`pkt-btn--${this.skin}`),this.variant&&t.add(`pkt-btn--${this.variant}`),this.color&&t.add(`pkt-btn--${this.color}`),this.isLoading&&t.add("pkt-btn--active"),this.state&&t.add(`pkt-btn--${this.state}`),this.disabled&&t.add("pkt-btn--disabled"),this.className=[...t].join(" ")}handleClick(t){if(this.disabled||this.isLoading){t.preventDefault(),t.stopImmediatePropagation();return}if(this.type==="submit"&&this.internals.form){this.internals.form.requestSubmit();return}if(this.type==="reset"&&this.internals.form){this.internals.form.reset();return}this.onClick&&typeof this.onClick=="function"&&this.onClick!==this.handleClick&&this.onClick(t),this.dispatchEvent(new CustomEvent("button-click",{bubbles:!0,composed:!0,detail:{originalEvent:t}}))}handleKeydown(t){if(!(this.disabled||this.isLoading)&&(t.key==="Enter"||t.key===" ")){t.preventDefault();const s=t.target;s&&s.click()}}};exports.PktButton.formAssociated=!0;e([i.n({type:String})],exports.PktButton.prototype,"iconName",2);e([i.n({type:String})],exports.PktButton.prototype,"secondIconName",2);e([i.n({type:String})],exports.PktButton.prototype,"mode",2);e([i.n({type:String})],exports.PktButton.prototype,"size",2);e([i.n({type:String})],exports.PktButton.prototype,"color",2);e([i.n({type:String})],exports.PktButton.prototype,"skin",2);e([i.n({type:String})],exports.PktButton.prototype,"variant",2);e([i.n({type:String,reflect:!0})],exports.PktButton.prototype,"state",2);e([i.n({type:String,reflect:!0})],exports.PktButton.prototype,"type",2);e([i.n({type:Boolean,reflect:!0})],exports.PktButton.prototype,"isLoading",2);e([i.n({type:Boolean,reflect:!0})],exports.PktButton.prototype,"disabled",2);exports.PktButton=e([i.t("pkt-button")],exports.PktButton);
@@ -1,4 +1,4 @@
1
- "use strict";const s=require("./element-BSypUpzA.cjs");require("./button-DEadihVm.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(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}>
1
+ "use strict";const s=require("./element-BSypUpzA.cjs");require("./button-DeAuj8qB.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(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
2
  <pkt-icon name="chevron-right" class="pkt-footer__link-icon"></pkt-icon>
3
3
  ${this.triggerText}
4
4
  </a>`:this.triggerType==="icon"?s.x`<pkt-button
@@ -1,5 +1,5 @@
1
1
  import { P as k, x as l, n as a, a as u } from "./element-DjjF_tEh.js";
2
- import "./button-D1zx8gKd.js";
2
+ import "./button-BOSdkRWa.js";
3
3
  import "./icon-Beoxup8E.js";
4
4
  const h = {
5
5
  i18n: {
package/dist/index.d.ts CHANGED
@@ -266,6 +266,9 @@ declare interface IPktModal {
266
266
  closeOnBackdropClick?: boolean;
267
267
  closeButtonSkin?: 'blue' | 'yellow-filled';
268
268
  size?: TPktSize;
269
+ variant?: 'dialog' | 'drawer';
270
+ drawerPosition?: 'left' | 'right';
271
+ transparentBackdrop?: boolean;
269
272
  }
270
273
 
271
274
  export declare interface IPktProgressbar {
@@ -948,6 +951,9 @@ export declare class PktModal extends PktElement implements IPktModal {
948
951
  closeOnBackdropClick?: boolean;
949
952
  closeButtonSkin?: 'blue' | 'yellow-filled';
950
953
  size?: TPktSize;
954
+ variant?: 'dialog' | 'drawer';
955
+ drawerPosition?: 'left' | 'right';
956
+ transparentBackdrop?: boolean;
951
957
  defaultSlot: Ref<HTMLElement>;
952
958
  dialogRef: Ref<HTMLDialogElement>;
953
959
  _isOpen: boolean;
@@ -1,10 +1,10 @@
1
1
  import { e as c } from "./class-map-KyMqi0fa.js";
2
- import { P as k, E as h, x as p, n as d, a as g } from "./element-DjjF_tEh.js";
2
+ import { P as f, E as u, x as p, n, a as g } from "./element-DjjF_tEh.js";
3
3
  import { r as v } from "./state-BtbpSrdV.js";
4
4
  import { P as _ } from "./pkt-slot-controller-DtDaD9q_.js";
5
- import { e as m, n as f } from "./ref-iIffqQAI.js";
5
+ import { e as m, n as k } from "./ref-iIffqQAI.js";
6
6
  import "./icon-Beoxup8E.js";
7
- const b = {
7
+ const y = {
8
8
  hideCloseButton: {
9
9
  default: !1
10
10
  },
@@ -14,17 +14,17 @@ const b = {
14
14
  size: {
15
15
  default: "medium"
16
16
  }
17
- }, u = {
18
- props: b
17
+ }, h = {
18
+ props: y
19
19
  };
20
- var y = Object.defineProperty, C = Object.getOwnPropertyDescriptor, n = (t, e, o, i) => {
21
- for (var s = i > 1 ? void 0 : i ? C(e, o) : e, r = t.length - 1, a; r >= 0; r--)
22
- (a = t[r]) && (s = (i ? a(e, o, s) : a(s)) || s);
23
- return i && s && y(e, o, s), s;
20
+ var w = Object.defineProperty, b = Object.getOwnPropertyDescriptor, a = (t, e, o, i) => {
21
+ for (var l = i > 1 ? void 0 : i ? b(e, o) : e, r = t.length - 1, d; r >= 0; r--)
22
+ (d = t[r]) && (l = (i ? d(e, o, l) : d(l)) || l);
23
+ return i && l && w(e, o, l), l;
24
24
  };
25
- let l = class extends k {
25
+ let s = class extends f {
26
26
  constructor() {
27
- super(), this.headingText = "", this.removePadding = !1, this.hideCloseButton = u.props.hideCloseButton.default, this.closeOnBackdropClick = u.props.closeOnBackdropClick.default, this.closeButtonSkin = "blue", this.size = u.props.size.default, this.defaultSlot = m(), this.dialogRef = m(), this._isOpen = !1, this.close = (t, e = !1) => {
27
+ super(), this.headingText = "", this.removePadding = !1, this.hideCloseButton = h.props.hideCloseButton.default, this.closeOnBackdropClick = h.props.closeOnBackdropClick.default, this.closeButtonSkin = "blue", this.size = h.props.size.default, this.variant = "dialog", this.drawerPosition = "right", this.transparentBackdrop = !1, this.defaultSlot = m(), this.dialogRef = m(), this._isOpen = !1, this.close = (t, e = !1) => {
28
28
  var i;
29
29
  if (!this._isOpen) return;
30
30
  this._isOpen = !1, document.body.classList.remove("pkt-modal--open");
@@ -45,7 +45,7 @@ let l = class extends k {
45
45
  }, this.slotController = new _(this, this.defaultSlot), this._isOpen = !1;
46
46
  }
47
47
  async connectedCallback() {
48
- super.connectedCallback(), document.addEventListener("keydown", this.handleKeyDown), document.addEventListener("click", this.handleBackdropClick);
48
+ super.connectedCallback(), document.addEventListener("keydown", this.handleKeyDown.bind(this)), document.addEventListener("click", this.handleBackdropClick.bind(this));
49
49
  }
50
50
  disconnectedCallback() {
51
51
  super.disconnectedCallback(), document.removeEventListener("keydown", this.handleKeyDown), document.removeEventListener("click", this.handleBackdropClick);
@@ -60,8 +60,8 @@ let l = class extends k {
60
60
  t.key === "Escape" && this.close(t);
61
61
  }
62
62
  handleBackdropClick(t) {
63
- var e;
64
- this.closeOnBackdropClick && t.target === ((e = this.dialogRef) == null ? void 0 : e.value) && this.close(t);
63
+ var e, o;
64
+ console.log("Event target:", t.target, (e = this.dialogRef) == null ? void 0 : e.value), this.closeOnBackdropClick && t.target === ((o = this.dialogRef) == null ? void 0 : o.value) && this.close(t);
65
65
  }
66
66
  isElementInViewport(t) {
67
67
  const e = t.getBoundingClientRect();
@@ -72,14 +72,18 @@ let l = class extends k {
72
72
  "pkt-modal": !0,
73
73
  "pkt-modal--removePadding": this.removePadding ?? !1,
74
74
  "pkt-modal--noHeadingText": this.headingText === "" || this.headingText === void 0,
75
- [`pkt-modal--${this.size}`]: this.size !== void 0
75
+ "pkt-modal--noShadow": this.closeButtonSkin === "yellow-filled",
76
+ "pkt-modal--transparentBackdrop": this.transparentBackdrop ?? !1,
77
+ [`pkt-modal--${this.size}`]: this.size !== void 0,
78
+ [`pkt-modal__${this.variant}`]: this.variant !== void 0,
79
+ [`pkt-modal__drawer--${this.drawerPosition}`]: this.variant === "drawer"
76
80
  }, e = {
77
81
  "pkt-modal__headingText": !0,
78
82
  "pkt-txt-24": !0
79
83
  }, o = {
80
84
  "pkt-modal__content": !0,
81
85
  "pkt-txt-18-light": !0
82
- }, i = this.closeButtonSkin === "blue", s = {
86
+ }, i = this.closeButtonSkin === "blue", l = {
83
87
  "pkt-modal__closeButton": !0,
84
88
  [`pkt-modal__closeButton--${this.closeButtonSkin}`]: !0
85
89
  }, r = {
@@ -91,62 +95,74 @@ let l = class extends k {
91
95
  return p`
92
96
  <dialog
93
97
  class=${c(t)}
94
- ${f(this.dialogRef)}
98
+ ${k(this.dialogRef)}
95
99
  aria-labelledby="pkt-modal__headingText"
96
100
  aria-describedby="pkt-modal__content"
97
- @close=${(a) => this.close(a, !0)}
101
+ @close=${(d) => this.close(d, !0)}
98
102
  >
99
- <div class="pkt-modal__header">
100
- <div class="pkt-modal__header-background"></div>
101
- ${this.headingText ? p`<h1 id="pkt-modal__headingText" class=${c(e)}>
102
- ${this.headingText}
103
- </h1>` : h}
104
- ${this.hideCloseButton ? h : p`<div class="${c(s)}">
105
- <pkt-button
106
- @click=${(a) => this.close(a)}
107
- class=${c(r)}
108
- aria-label="close"
109
- iconname="close"
110
- variant="icon-only"
111
- >
112
- </pkt-button>
113
- </div>`}
114
- </div>
115
- <div class="pkt-modal__container">
116
- <div
117
- id="pkt-modal__content"
118
- class=${c(o)}
119
- ${f(this.defaultSlot)}
120
- ></div>
103
+ <div class="pkt-modal__wrapper">
104
+ ${this.headingText || !this.hideCloseButton ? p`<div class="pkt-modal__header">
105
+ <div class="pkt-modal__header-background"></div>
106
+ ${this.headingText ? p`<h1 id="pkt-modal__headingText" class=${c(e)}>
107
+ ${this.headingText}
108
+ </h1>` : p`<div class="pkt-modal__headingText"></div>`}
109
+ ${this.hideCloseButton ? u : p`<div class="${c(l)}">
110
+ <pkt-button
111
+ @click=${(d) => this.close(d)}
112
+ class=${c(r)}
113
+ aria-label="close"
114
+ iconname="close"
115
+ variant="icon-only"
116
+ >
117
+ Lukk
118
+ </pkt-button>
119
+ </div>`}
120
+ </div>` : u}
121
+ <div class="pkt-modal__container">
122
+ <div
123
+ id="pkt-modal__content"
124
+ class=${c(o)}
125
+ ${k(this.defaultSlot)}
126
+ ></div>
127
+ </div>
121
128
  </div>
122
129
  </dialog>
123
130
  `;
124
131
  }
125
132
  };
126
- n([
127
- d({ type: String, reflect: !0 })
128
- ], l.prototype, "headingText", 2);
129
- n([
130
- d({ type: Boolean, reflect: !0 })
131
- ], l.prototype, "removePadding", 2);
132
- n([
133
- d({ type: Boolean, reflect: !0 })
134
- ], l.prototype, "hideCloseButton", 2);
135
- n([
136
- d({ type: Boolean, reflect: !0 })
137
- ], l.prototype, "closeOnBackdropClick", 2);
138
- n([
139
- d({ type: String, reflect: !0 })
140
- ], l.prototype, "closeButtonSkin", 2);
141
- n([
142
- d({ type: String, reflect: !0 })
143
- ], l.prototype, "size", 2);
144
- n([
133
+ a([
134
+ n({ type: String })
135
+ ], s.prototype, "headingText", 2);
136
+ a([
137
+ n({ type: Boolean })
138
+ ], s.prototype, "removePadding", 2);
139
+ a([
140
+ n({ type: Boolean })
141
+ ], s.prototype, "hideCloseButton", 2);
142
+ a([
143
+ n({ type: Boolean })
144
+ ], s.prototype, "closeOnBackdropClick", 2);
145
+ a([
146
+ n({ type: String })
147
+ ], s.prototype, "closeButtonSkin", 2);
148
+ a([
149
+ n({ type: String })
150
+ ], s.prototype, "size", 2);
151
+ a([
152
+ n({ type: String })
153
+ ], s.prototype, "variant", 2);
154
+ a([
155
+ n({ type: String })
156
+ ], s.prototype, "drawerPosition", 2);
157
+ a([
158
+ n({ type: Boolean })
159
+ ], s.prototype, "transparentBackdrop", 2);
160
+ a([
145
161
  v()
146
- ], l.prototype, "_isOpen", 2);
147
- l = n([
162
+ ], s.prototype, "_isOpen", 2);
163
+ s = a([
148
164
  g("pkt-modal")
149
- ], l);
165
+ ], s);
150
166
  export {
151
- l as P
167
+ s as P
152
168
  };
@@ -0,0 +1,36 @@
1
+ "use strict";const d=require("./class-map-DCyaICmy.cjs"),i=require("./element-BSypUpzA.cjs"),u=require("./state-B5KCNjEd.cjs"),k=require("./pkt-slot-controller-Da-RgXfS.cjs"),r=require("./ref-BvbyvXRH.cjs");require("./icon-BnKGwYjj.cjs");const m={hideCloseButton:{default:!1},closeOnBackdropClick:{default:!1},size:{default:"medium"}},h={props:m};var v=Object.defineProperty,g=Object.getOwnPropertyDescriptor,l=(c,t,e,o)=>{for(var s=o>1?void 0:o?g(t,e):t,n=c.length-1,a;n>=0;n--)(a=c[n])&&(s=(o?a(t,e,s):a(s))||s);return o&&s&&v(t,e,s),s};exports.PktModal=class extends i.PktElement{constructor(){super(),this.headingText="",this.removePadding=!1,this.hideCloseButton=h.props.hideCloseButton.default,this.closeOnBackdropClick=h.props.closeOnBackdropClick.default,this.closeButtonSkin="blue",this.size=h.props.size.default,this.variant="dialog",this.drawerPosition="right",this.transparentBackdrop=!1,this.defaultSlot=r.e(),this.dialogRef=r.e(),this._isOpen=!1,this.close=(t,e=!1)=>{var s;if(!this._isOpen)return;this._isOpen=!1,document.body.classList.remove("pkt-modal--open");const o=document.activeElement;o&&!this.isElementInViewport(o)&&o.scrollIntoView({behavior:"smooth",block:"nearest"}),this.dispatchEvent(new CustomEvent("close",{detail:{origin:t},bubbles:!0,composed:!0})),e||(s=this.dialogRef.value)==null||s.close(),this.requestUpdate()},this.showModal=(t=null)=>{var o;this._isOpen=!0,(o=this.dialogRef.value)==null||o.showModal();const e=document.querySelector(".pkt-modal");requestAnimationFrame(()=>{var s;this.dialogRef.value&&((s=this.dialogRef.value)==null||s.focus())}),e&&document.body.classList.add("pkt-modal--open"),this.dispatchEvent(new CustomEvent("showModal",{detail:{origin:t},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.bind(this)),document.addEventListener("click",this.handleBackdropClick.bind(this))}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("keydown",this.handleKeyDown),document.removeEventListener("click",this.handleBackdropClick)}async firstUpdated(t){super.firstUpdated(t),this.dialogRef.value&&!window.HTMLDialogElement&&!this.dialogRef.value.showModal&&("document"in window&&"createElement"in document&&(await Promise.resolve().then(()=>require("./dialog-polyfill.esm-CPKZe7AL.cjs")).then(o=>o.default)).registerDialog(this.dialogRef.value),this.dialogRef.value.addEventListener("close",()=>{this.close(new Event("close"),!0)}))}handleKeyDown(t){t.key==="Escape"&&this.close(t)}handleBackdropClick(t){var e,o;console.log("Event target:",t.target,(e=this.dialogRef)==null?void 0:e.value),this.closeOnBackdropClick&&t.target===((o=this.dialogRef)==null?void 0:o.value)&&this.close(t)}isElementInViewport(t){const e=t.getBoundingClientRect();return e.top>=0&&e.left>=0&&e.bottom<=(window.innerHeight||document.documentElement.clientHeight)&&e.right<=(window.innerWidth||document.documentElement.clientWidth)}render(){const t={"pkt-modal":!0,"pkt-modal--removePadding":this.removePadding??!1,"pkt-modal--noHeadingText":this.headingText===""||this.headingText===void 0,"pkt-modal--noShadow":this.closeButtonSkin==="yellow-filled","pkt-modal--transparentBackdrop":this.transparentBackdrop??!1,[`pkt-modal--${this.size}`]:this.size!==void 0,[`pkt-modal__${this.variant}`]:this.variant!==void 0,[`pkt-modal__drawer--${this.drawerPosition}`]:this.variant==="drawer"},e={"pkt-modal__headingText":!0,"pkt-txt-24":!0},o={"pkt-modal__content":!0,"pkt-txt-18-light":!0},s=this.closeButtonSkin==="blue",n={"pkt-modal__closeButton":!0,[`pkt-modal__closeButton--${this.closeButtonSkin}`]:!0},a={"pkt-btn":!0,[`pkt-btn--${s?"tertiary":"primary"}`]:!0,"pkt-btn--icon-only":!0,"pkt-btn--medium":!0};return i.x`
2
+ <dialog
3
+ class=${d.e(t)}
4
+ ${r.n(this.dialogRef)}
5
+ aria-labelledby="pkt-modal__headingText"
6
+ aria-describedby="pkt-modal__content"
7
+ @close=${p=>this.close(p,!0)}
8
+ >
9
+ <div class="pkt-modal__wrapper">
10
+ ${this.headingText||!this.hideCloseButton?i.x`<div class="pkt-modal__header">
11
+ <div class="pkt-modal__header-background"></div>
12
+ ${this.headingText?i.x`<h1 id="pkt-modal__headingText" class=${d.e(e)}>
13
+ ${this.headingText}
14
+ </h1>`:i.x`<div class="pkt-modal__headingText"></div>`}
15
+ ${this.hideCloseButton?i.E:i.x`<div class="${d.e(n)}">
16
+ <pkt-button
17
+ @click=${p=>this.close(p)}
18
+ class=${d.e(a)}
19
+ aria-label="close"
20
+ iconname="close"
21
+ variant="icon-only"
22
+ >
23
+ Lukk
24
+ </pkt-button>
25
+ </div>`}
26
+ </div>`:i.E}
27
+ <div class="pkt-modal__container">
28
+ <div
29
+ id="pkt-modal__content"
30
+ class=${d.e(o)}
31
+ ${r.n(this.defaultSlot)}
32
+ ></div>
33
+ </div>
34
+ </div>
35
+ </dialog>
36
+ `}};l([i.n({type:String})],exports.PktModal.prototype,"headingText",2);l([i.n({type:Boolean})],exports.PktModal.prototype,"removePadding",2);l([i.n({type:Boolean})],exports.PktModal.prototype,"hideCloseButton",2);l([i.n({type:Boolean})],exports.PktModal.prototype,"closeOnBackdropClick",2);l([i.n({type:String})],exports.PktModal.prototype,"closeButtonSkin",2);l([i.n({type:String})],exports.PktModal.prototype,"size",2);l([i.n({type:String})],exports.PktModal.prototype,"variant",2);l([i.n({type:String})],exports.PktModal.prototype,"drawerPosition",2);l([i.n({type:Boolean})],exports.PktModal.prototype,"transparentBackdrop",2);l([u.r()],exports.PktModal.prototype,"_isOpen",2);exports.PktModal=l([i.t("pkt-modal")],exports.PktModal);
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("./button-DEadihVm.cjs"),e=t.PktButton;Object.defineProperty(exports,"PktButton",{enumerable:!0,get:()=>t.PktButton});exports.default=e;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("./button-DeAuj8qB.cjs"),e=t.PktButton;Object.defineProperty(exports,"PktButton",{enumerable:!0,get:()=>t.PktButton});exports.default=e;
@@ -1,4 +1,4 @@
1
- import { P as t } from "./button-D1zx8gKd.js";
1
+ import { P as t } from "./button-BOSdkRWa.js";
2
2
  const a = t;
3
3
  export {
4
4
  t as PktButton,
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./consent-B4r94Z8d.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-B3jbzwS_.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-DDcfVjC6.js";
1
+ import { P as t } from "./consent-B4vlcsFJ.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-C2EPmB0W.cjs"),l=require("./accordionitem-RFwXQC_0.cjs"),d=require("./backlink-HHM21crL.cjs"),b=require("./button-DEadihVm.cjs"),k=require("./calendar-CYY42kN4.cjs"),m=require("./card-Di1MQneh.cjs"),g=require("./combobox-yUrUarU_.cjs"),h=require("./consent-B4r94Z8d.cjs"),f=require("./checkbox-zqd3KVfz.cjs"),t=require("./element-BSypUpzA.cjs"),y=require("./pkt-slot-controller-Da-RgXfS.cjs"),s=require("./ref-BvbyvXRH.cjs"),O=require("./class-map-DCyaICmy.cjs"),j=require("./datepicker-CH5ZmFhf.cjs"),q=require("./helptext-bMgnhZ1R.cjs"),x=require("./heading-BnJhJDMD.cjs"),C=require("./icon-BnKGwYjj.cjs"),v=require("./input-wrapper-B-f_SotM.cjs"),S=require("./link-nesPZCIx.cjs"),$=require("./linkcard-s9yoOq90.cjs"),L=require("./loader-Bk4XPiOY.cjs"),_=require("./messagebox-B0kgftoP.cjs"),A=require("./modal-DZY4gZCQ.cjs"),B=require("./progressbar-DiRfScnB.cjs"),p=require("./radiobutton-CI2xaqAB.cjs"),T=require("./tag-B9kFYxHg.cjs"),I=require("./textarea-DxbylapQ.cjs"),M=require("./textinput-B__c4c1z.cjs"),R=require("./select-BCL790jM.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-C2EPmB0W.cjs"),l=require("./accordionitem-RFwXQC_0.cjs"),d=require("./backlink-HHM21crL.cjs"),b=require("./button-DeAuj8qB.cjs"),k=require("./calendar-CYY42kN4.cjs"),m=require("./card-Di1MQneh.cjs"),g=require("./combobox-yUrUarU_.cjs"),h=require("./consent-B3jbzwS_.cjs"),f=require("./checkbox-zqd3KVfz.cjs"),t=require("./element-BSypUpzA.cjs"),y=require("./pkt-slot-controller-Da-RgXfS.cjs"),s=require("./ref-BvbyvXRH.cjs"),O=require("./class-map-DCyaICmy.cjs"),j=require("./datepicker-CH5ZmFhf.cjs"),q=require("./helptext-bMgnhZ1R.cjs"),x=require("./heading-BnJhJDMD.cjs"),C=require("./icon-BnKGwYjj.cjs"),v=require("./input-wrapper-B-f_SotM.cjs"),S=require("./link-nesPZCIx.cjs"),$=require("./linkcard-s9yoOq90.cjs"),L=require("./loader-Bk4XPiOY.cjs"),_=require("./messagebox-B0kgftoP.cjs"),A=require("./modal-B6VJdIeY.cjs"),B=require("./progressbar-DiRfScnB.cjs"),p=require("./radiobutton-CI2xaqAB.cjs"),T=require("./tag-B9kFYxHg.cjs"),I=require("./textarea-DxbylapQ.cjs"),M=require("./textinput-B__c4c1z.cjs"),R=require("./select-BCL790jM.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
@@ -1,12 +1,12 @@
1
1
  import { P as A } from "./alert-C33z1kBf.js";
2
2
  import { P as B, a as E } from "./accordionitem-vmwqD9rr.js";
3
3
  import { P as O } from "./backlink-hvyJmwrO.js";
4
- import { P as T } from "./button-D1zx8gKd.js";
4
+ import { P as T } from "./button-BOSdkRWa.js";
5
5
  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-CZG7XGlj.js";
8
8
  import { P as K } from "./combobox-B6x7Qukm.js";
9
- import { P as U } from "./consent-DDcfVjC6.js";
9
+ import { P as U } from "./consent-B4vlcsFJ.js";
10
10
  import { P as q } from "./checkbox-Ds1FrhqK.js";
11
11
  import { P as k, t as h, x as P, n, a as c } from "./element-DjjF_tEh.js";
12
12
  import { P as x } from "./pkt-slot-controller-DtDaD9q_.js";
@@ -21,7 +21,7 @@ import { P as ot } from "./link-DCYJhFKJ.js";
21
21
  import { P as at } from "./linkcard-Bt-Qa_SP.js";
22
22
  import { P as it } from "./loader-C9EtX_mK.js";
23
23
  import { P as lt } from "./messagebox-DZDP8XZt.js";
24
- import { P as mt } from "./modal-sbobjlRZ.js";
24
+ import { P as mt } from "./modal-8bEB_CoY.js";
25
25
  import { P as ft } from "./progressbar-BKt_aj7f.js";
26
26
  import { P as ht, P as ct } from "./radiobutton-CYJawqxD.js";
27
27
  import { P as ut } from "./tag-Cu8afZy8.js";
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./modal-DZY4gZCQ.cjs"),t=e.PktModal;Object.defineProperty(exports,"PktModal",{enumerable:!0,get:()=>e.PktModal});exports.default=t;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./modal-B6VJdIeY.cjs"),t=e.PktModal;Object.defineProperty(exports,"PktModal",{enumerable:!0,get:()=>e.PktModal});exports.default=t;
package/dist/pkt-modal.js CHANGED
@@ -1,4 +1,4 @@
1
- import { P as a } from "./modal-sbobjlRZ.js";
1
+ import { P as a } from "./modal-8bEB_CoY.js";
2
2
  const t = a;
3
3
  export {
4
4
  a as PktModal,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oslokommune/punkt-elements",
3
- "version": "12.38.1",
3
+ "version": "12.39.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",
@@ -32,7 +32,7 @@
32
32
  },
33
33
  "devDependencies": {
34
34
  "@oslokommune/punkt-assets": "^12.37.0",
35
- "@oslokommune/punkt-css": "^12.38.0",
35
+ "@oslokommune/punkt-css": "^12.39.0",
36
36
  "sass": "^1.78.0",
37
37
  "typescript": "^5.6.2",
38
38
  "vite": "^5.4.18",
@@ -59,5 +59,5 @@
59
59
  "url": "https://github.com/oslokommune/punkt/issues"
60
60
  },
61
61
  "license": "MIT",
62
- "gitHead": "bbffeef32589486551e5e1eaf611c6740adc85d7"
62
+ "gitHead": "ddb0e674ed86b95519a7a40e5785c05b85047504"
63
63
  }
@@ -66,9 +66,9 @@ export class PktButton extends PktElement<IPktButton> implements IPktButton {
66
66
  @property({ type: String }) color?: TPktButtonColor
67
67
  @property({ type: String }) skin: TPktButtonSkin = 'primary'
68
68
  @property({ type: String }) variant: TPktButtonVariant = 'label-only'
69
- @property({ type: String }) state?: TPktButtonState = 'normal'
69
+ @property({ type: String, reflect: true }) state?: TPktButtonState = 'normal'
70
70
  @property({ type: String, reflect: true }) type: TPktButtonType = 'button'
71
- @property({ type: Boolean }) isLoading: Booleanish = false
71
+ @property({ type: Boolean, reflect: true }) isLoading: Booleanish = false
72
72
  @property({ type: Boolean, reflect: true }) disabled: Booleanish = false
73
73
 
74
74
  // Lifecycle
@@ -16,19 +16,25 @@ export interface IPktModal {
16
16
  closeOnBackdropClick?: boolean
17
17
  closeButtonSkin?: 'blue' | 'yellow-filled'
18
18
  size?: TPktSize
19
+ variant?: 'dialog' | 'drawer'
20
+ drawerPosition?: 'left' | 'right'
21
+ transparentBackdrop?: boolean
19
22
  }
20
23
 
21
24
  @customElement('pkt-modal')
22
25
  export class PktModal extends PktElement implements IPktModal {
23
26
  // Public properties"
24
- @property({ type: String, reflect: true }) headingText?: string = ''
25
- @property({ type: Boolean, reflect: true }) removePadding?: boolean = false
26
- @property({ type: Boolean, reflect: true }) hideCloseButton?: boolean =
27
- specs.props.hideCloseButton.default
28
- @property({ type: Boolean, reflect: true })
27
+ @property({ type: String }) headingText?: string = ''
28
+ @property({ type: Boolean }) removePadding?: boolean = false
29
+ @property({ type: Boolean }) hideCloseButton?: boolean = specs.props.hideCloseButton.default
30
+ @property({ type: Boolean })
29
31
  closeOnBackdropClick?: boolean = specs.props.closeOnBackdropClick.default
30
- @property({ type: String, reflect: true }) closeButtonSkin?: 'blue' | 'yellow-filled' = 'blue'
31
- @property({ type: String, reflect: true }) size?: TPktSize = specs.props.size.default as TPktSize
32
+ @property({ type: String }) closeButtonSkin?: 'blue' | 'yellow-filled' = 'blue'
33
+ @property({ type: String }) size?: TPktSize = specs.props.size.default as TPktSize
34
+ @property({ type: String }) variant?: 'dialog' | 'drawer' = 'dialog'
35
+ @property({ type: String }) drawerPosition?: 'left' | 'right' = 'right'
36
+ @property({ type: Boolean }) transparentBackdrop?: boolean = false
37
+
32
38
  defaultSlot: Ref<HTMLElement> = createRef()
33
39
  dialogRef: Ref<HTMLDialogElement> = createRef()
34
40
 
@@ -42,8 +48,8 @@ export class PktModal extends PktElement implements IPktModal {
42
48
 
43
49
  async connectedCallback(): Promise<void> {
44
50
  super.connectedCallback()
45
- document.addEventListener('keydown', this.handleKeyDown)
46
- document.addEventListener('click', this.handleBackdropClick)
51
+ document.addEventListener('keydown', this.handleKeyDown.bind(this))
52
+ document.addEventListener('click', this.handleBackdropClick.bind(this))
47
53
  }
48
54
 
49
55
  disconnectedCallback(): void {
@@ -73,6 +79,7 @@ export class PktModal extends PktElement implements IPktModal {
73
79
  }
74
80
 
75
81
  private handleBackdropClick(event: MouseEvent) {
82
+ console.log('Event target:', event.target, this.dialogRef?.value)
76
83
  if (this.closeOnBackdropClick && event.target === this.dialogRef?.value) {
77
84
  this.close(event)
78
85
  }
@@ -135,7 +142,11 @@ export class PktModal extends PktElement implements IPktModal {
135
142
  'pkt-modal': true,
136
143
  'pkt-modal--removePadding': this.removePadding ?? false,
137
144
  'pkt-modal--noHeadingText': this.headingText === '' || this.headingText === undefined,
145
+ 'pkt-modal--noShadow': this.closeButtonSkin === 'yellow-filled',
146
+ 'pkt-modal--transparentBackdrop': this.transparentBackdrop ?? false,
138
147
  [`pkt-modal--${this.size}`]: this.size !== undefined,
148
+ [`pkt-modal__${this.variant}`]: this.variant !== undefined,
149
+ [`pkt-modal__drawer--${this.drawerPosition}`]: this.variant === 'drawer',
139
150
  }
140
151
 
141
152
  const headingClasses = {
@@ -169,32 +180,37 @@ export class PktModal extends PktElement implements IPktModal {
169
180
  aria-describedby="pkt-modal__content"
170
181
  @close=${(event: Event) => this.close(event, true)}
171
182
  >
172
- <div class="pkt-modal__header">
173
- <div class="pkt-modal__header-background"></div>
174
- ${this.headingText
175
- ? html`<h1 id="pkt-modal__headingText" class=${classMap(headingClasses)}>
176
- ${this.headingText}
177
- </h1>`
178
- : nothing}
179
- ${!this.hideCloseButton
180
- ? html`<div class="${classMap(closeButtonClasses)}">
181
- <pkt-button
182
- @click=${(event: Event) => this.close(event)}
183
- class=${classMap(buttonClasses)}
184
- aria-label="close"
185
- iconname="close"
186
- variant="icon-only"
187
- >
188
- </pkt-button>
183
+ <div class="pkt-modal__wrapper">
184
+ ${this.headingText || !this.hideCloseButton
185
+ ? html`<div class="pkt-modal__header">
186
+ <div class="pkt-modal__header-background"></div>
187
+ ${this.headingText
188
+ ? html`<h1 id="pkt-modal__headingText" class=${classMap(headingClasses)}>
189
+ ${this.headingText}
190
+ </h1>`
191
+ : html`<div class="pkt-modal__headingText"></div>`}
192
+ ${!this.hideCloseButton
193
+ ? html`<div class="${classMap(closeButtonClasses)}">
194
+ <pkt-button
195
+ @click=${(event: Event) => this.close(event)}
196
+ class=${classMap(buttonClasses)}
197
+ aria-label="close"
198
+ iconname="close"
199
+ variant="icon-only"
200
+ >
201
+ Lukk
202
+ </pkt-button>
203
+ </div>`
204
+ : nothing}
189
205
  </div>`
190
206
  : nothing}
191
- </div>
192
- <div class="pkt-modal__container">
193
- <div
194
- id="pkt-modal__content"
195
- class=${classMap(contentClasses)}
196
- ${ref(this.defaultSlot)}
197
- ></div>
207
+ <div class="pkt-modal__container">
208
+ <div
209
+ id="pkt-modal__content"
210
+ class=${classMap(contentClasses)}
211
+ ${ref(this.defaultSlot)}
212
+ ></div>
213
+ </div>
198
214
  </div>
199
215
  </dialog>
200
216
  `
@@ -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-Da-RgXfS.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,g=Object.getOwnPropertyDescriptor,l=(c,e,t,o)=>{for(var s=o>1?void 0:o?g(e,t):e,n=c.length-1,a;n>=0;n--)(a=c[n])&&(s=(o?a(e,t,s):a(s))||s);return o&&s&&f(e,t,s),s};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 s;if(!this._isOpen)return;this._isOpen=!1,document.body.classList.remove("pkt-modal--open");const o=document.activeElement;o&&!this.isElementInViewport(o)&&o.scrollIntoView({behavior:"smooth",block:"nearest"}),this.dispatchEvent(new CustomEvent("close",{detail:{origin:e},bubbles:!0,composed:!0})),t||(s=this.dialogRef.value)==null||s.close(),this.requestUpdate()},this.showModal=(e=null)=>{var o;this._isOpen=!0,(o=this.dialogRef.value)==null||o.showModal();const t=document.querySelector(".pkt-modal");requestAnimationFrame(()=>{var s;this.dialogRef.value&&((s=this.dialogRef.value)==null||s.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)}async firstUpdated(e){super.firstUpdated(e),this.dialogRef.value&&!window.HTMLDialogElement&&!this.dialogRef.value.showModal&&("document"in window&&"createElement"in document&&(await Promise.resolve().then(()=>require("./dialog-polyfill.esm-CPKZe7AL.cjs")).then(o=>o.default)).registerDialog(this.dialogRef.value),this.dialogRef.value.addEventListener("close",()=>{this.close(new Event("close"),!0)}))}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},o={"pkt-modal__content":!0,"pkt-txt-18-light":!0},s=this.closeButtonSkin==="blue",n={"pkt-modal__closeButton":!0,[`pkt-modal__closeButton--${this.closeButtonSkin}`]:!0},a={"pkt-btn":!0,[`pkt-btn--${s?"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(o)}
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);