@oslokommune/punkt-elements 12.21.5 → 12.22.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/dist/index.d.ts +2 -0
- package/dist/{modal-qKsbHYy3.js → modal-CYv8Qk0Y.js} +62 -35
- package/dist/modal-gLMGJSSY.cjs +32 -0
- package/dist/pkt-index.cjs +1 -1
- package/dist/pkt-index.js +1 -1
- package/dist/pkt-modal.cjs +1 -1
- package/dist/pkt-modal.js +1 -1
- package/package.json +4 -4
- package/src/components/modal/modal.ts +34 -9
- package/dist/modal-C6b9Q1fe.cjs +0 -30
package/dist/index.d.ts
CHANGED
|
@@ -20,6 +20,7 @@ declare interface IPktModal {
|
|
|
20
20
|
removePadding?: boolean;
|
|
21
21
|
hideCloseButton?: boolean;
|
|
22
22
|
closeOnBackdropClick?: boolean;
|
|
23
|
+
closeButtonSkin?: 'blue' | 'yellow-filled';
|
|
23
24
|
size?: TPktSize;
|
|
24
25
|
}
|
|
25
26
|
|
|
@@ -443,6 +444,7 @@ export declare class PktModal extends PktElement implements IPktModal {
|
|
|
443
444
|
removePadding?: boolean;
|
|
444
445
|
hideCloseButton?: boolean;
|
|
445
446
|
closeOnBackdropClick?: boolean;
|
|
447
|
+
closeButtonSkin?: 'blue' | 'yellow-filled';
|
|
446
448
|
size?: TPktSize;
|
|
447
449
|
defaultSlot: Ref<HTMLElement>;
|
|
448
450
|
dialogRef: Ref<HTMLDialogElement>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { e as c } from "./class-map-CQzsZCwS.js";
|
|
2
|
-
import { P as
|
|
2
|
+
import { P as f, x as p, E as m, n as a, t as g } from "./element-BKrU5soj.js";
|
|
3
3
|
import { r as v } from "./state-C36ZmZgt.js";
|
|
4
4
|
import { P as b } from "./pkt-slot-controller-DhwCJd_0.js";
|
|
5
|
-
import { e as k, n as
|
|
5
|
+
import { e as k, n as h } from "./ref-D5qG7OFB.js";
|
|
6
6
|
import "./icon-Bsb0MB2h.js";
|
|
7
7
|
const y = "pkt-modal", _ = !0, C = {
|
|
8
8
|
"background-click": {
|
|
@@ -11,7 +11,7 @@ const y = "pkt-modal", _ = !0, C = {
|
|
|
11
11
|
close: {
|
|
12
12
|
description: "Event som trigges når meldingsboksen lukkes"
|
|
13
13
|
}
|
|
14
|
-
},
|
|
14
|
+
}, B = {
|
|
15
15
|
headingText: {
|
|
16
16
|
name: "Heading text",
|
|
17
17
|
description: "Heading tekst på modalen",
|
|
@@ -29,6 +29,15 @@ const y = "pkt-modal", _ = !0, C = {
|
|
|
29
29
|
type: "boolean",
|
|
30
30
|
default: !1
|
|
31
31
|
},
|
|
32
|
+
closeButtonSkin: {
|
|
33
|
+
name: "Stil på lukkeknappen",
|
|
34
|
+
description: "Stil på lukkeknappen",
|
|
35
|
+
type: [
|
|
36
|
+
"blue",
|
|
37
|
+
"yellow-filled"
|
|
38
|
+
],
|
|
39
|
+
default: "blue"
|
|
40
|
+
},
|
|
32
41
|
size: {
|
|
33
42
|
name: "Størrelse",
|
|
34
43
|
description: "Størrelsen på modalen",
|
|
@@ -39,26 +48,26 @@ const y = "pkt-modal", _ = !0, C = {
|
|
|
39
48
|
],
|
|
40
49
|
default: "medium"
|
|
41
50
|
}
|
|
42
|
-
},
|
|
51
|
+
}, E = {
|
|
43
52
|
default: {
|
|
44
53
|
description: "Innholdet i meldingen. Her tilbyr vi støtteklasser for å style 1-3 knapper i modalen."
|
|
45
54
|
}
|
|
46
|
-
},
|
|
55
|
+
}, u = {
|
|
47
56
|
name: y,
|
|
48
57
|
"css-class": "pkt-modal",
|
|
49
58
|
isElements: _,
|
|
50
59
|
events: C,
|
|
51
|
-
props:
|
|
52
|
-
slots:
|
|
60
|
+
props: B,
|
|
61
|
+
slots: E
|
|
53
62
|
};
|
|
54
|
-
var
|
|
55
|
-
for (var s =
|
|
56
|
-
(r = e[d]) && (s = (
|
|
57
|
-
return
|
|
63
|
+
var w = Object.defineProperty, S = Object.getOwnPropertyDescriptor, l = (e, t, o, n) => {
|
|
64
|
+
for (var s = n > 1 ? void 0 : n ? S(t, o) : t, d = e.length - 1, r; d >= 0; d--)
|
|
65
|
+
(r = e[d]) && (s = (n ? r(t, o, s) : r(s)) || s);
|
|
66
|
+
return n && s && w(t, o, s), s;
|
|
58
67
|
};
|
|
59
|
-
let
|
|
68
|
+
let i = class extends f {
|
|
60
69
|
constructor() {
|
|
61
|
-
super(), this.headingText = "", this.removePadding = !1, this.hideCloseButton =
|
|
70
|
+
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 = k(), this.dialogRef = k(), this._isOpen = !1, this.close = (e, t = !1) => {
|
|
62
71
|
var s;
|
|
63
72
|
this._isOpen = !1, t || (s = this.dialogRef.value) == null || s.close();
|
|
64
73
|
const o = document.activeElement;
|
|
@@ -67,7 +76,12 @@ let n = class extends g {
|
|
|
67
76
|
), document.querySelector(".pkt-modal") && document.body.classList.remove("pkt-modal--open"), this.requestUpdate();
|
|
68
77
|
}, this.showModal = (e) => {
|
|
69
78
|
var o;
|
|
70
|
-
this._isOpen = !0, (o = this.dialogRef.value) == null || o.showModal()
|
|
79
|
+
this._isOpen = !0, (o = this.dialogRef.value) == null || o.showModal();
|
|
80
|
+
const t = document.querySelector(".pkt-modal");
|
|
81
|
+
requestAnimationFrame(() => {
|
|
82
|
+
var n;
|
|
83
|
+
this.dialogRef.value && ((n = this.dialogRef.value) == null || n.focus());
|
|
84
|
+
}), t && document.body.classList.add("pkt-modal--open"), this.dispatchEvent(
|
|
71
85
|
new CustomEvent("showModal", { detail: { origin: e }, bubbles: !0, composed: !0 })
|
|
72
86
|
), this.requestUpdate();
|
|
73
87
|
}, this.slotController = new b(this, this.defaultSlot), this._isOpen = !1;
|
|
@@ -104,60 +118,73 @@ let n = class extends g {
|
|
|
104
118
|
}, o = {
|
|
105
119
|
"pkt-modal__content": !0,
|
|
106
120
|
"pkt-txt-18-light": !0
|
|
121
|
+
}, n = this.closeButtonSkin === "blue", s = {
|
|
122
|
+
"pkt-modal__closeButton": !0,
|
|
123
|
+
[`pkt-modal__closeButton--${this.closeButtonSkin}`]: !0
|
|
124
|
+
}, d = {
|
|
125
|
+
"pkt-btn": !0,
|
|
126
|
+
[`pkt-btn--${n ? "tertiary" : "primary"}`]: !0,
|
|
127
|
+
"pkt-btn--icon-only": !0,
|
|
128
|
+
"pkt-btn--medium": !0
|
|
107
129
|
};
|
|
108
130
|
return p`
|
|
109
131
|
<dialog
|
|
110
132
|
class=${c(e)}
|
|
111
133
|
aria-modal=${this._isOpen}
|
|
112
|
-
${
|
|
134
|
+
${h(this.dialogRef)}
|
|
113
135
|
aria-labelledby="pkt-modal__headingText"
|
|
114
136
|
aria-describedby="pkt-modal__content"
|
|
115
|
-
autofocus
|
|
116
137
|
>
|
|
117
138
|
<div class="pkt-modal__header">
|
|
139
|
+
<div class="pkt-modal__header-background"></div>
|
|
118
140
|
${this.headingText ? p`<h1 id="pkt-modal__headingText" class=${c(t)}>
|
|
119
141
|
${this.headingText}
|
|
120
|
-
</h1>` :
|
|
121
|
-
${this.hideCloseButton ?
|
|
142
|
+
</h1>` : m}
|
|
143
|
+
${this.hideCloseButton ? m : p`<div class="${c(s)}">
|
|
122
144
|
<button
|
|
123
|
-
@click=${(
|
|
124
|
-
class
|
|
145
|
+
@click=${(r) => this.close(r)}
|
|
146
|
+
class=${c(d)}
|
|
125
147
|
aria-label="close"
|
|
126
148
|
>
|
|
127
149
|
<pkt-icon name="close" class="pkt-link__icon"></pkt-icon>
|
|
128
150
|
</button>
|
|
129
151
|
</div>`}
|
|
130
152
|
</div>
|
|
131
|
-
<div
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
153
|
+
<div class="pkt-modal__container">
|
|
154
|
+
<div
|
|
155
|
+
id="pkt-modal__content"
|
|
156
|
+
class=${c(o)}
|
|
157
|
+
${h(this.defaultSlot)}
|
|
158
|
+
></div>
|
|
159
|
+
</div>
|
|
136
160
|
</dialog>
|
|
137
161
|
`;
|
|
138
162
|
}
|
|
139
163
|
};
|
|
140
164
|
l([
|
|
141
165
|
a({ type: String, reflect: !0 })
|
|
142
|
-
],
|
|
166
|
+
], i.prototype, "headingText", 2);
|
|
143
167
|
l([
|
|
144
168
|
a({ type: Boolean, reflect: !0 })
|
|
145
|
-
],
|
|
169
|
+
], i.prototype, "removePadding", 2);
|
|
146
170
|
l([
|
|
147
171
|
a({ type: Boolean, reflect: !0 })
|
|
148
|
-
],
|
|
172
|
+
], i.prototype, "hideCloseButton", 2);
|
|
149
173
|
l([
|
|
150
174
|
a({ type: Boolean, reflect: !0 })
|
|
151
|
-
],
|
|
175
|
+
], i.prototype, "closeOnBackdropClick", 2);
|
|
176
|
+
l([
|
|
177
|
+
a({ type: String, reflect: !0 })
|
|
178
|
+
], i.prototype, "closeButtonSkin", 2);
|
|
152
179
|
l([
|
|
153
180
|
a({ type: String, reflect: !0 })
|
|
154
|
-
],
|
|
181
|
+
], i.prototype, "size", 2);
|
|
155
182
|
l([
|
|
156
183
|
v()
|
|
157
|
-
],
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
],
|
|
184
|
+
], i.prototype, "_isOpen", 2);
|
|
185
|
+
i = l([
|
|
186
|
+
g("pkt-modal")
|
|
187
|
+
], i);
|
|
161
188
|
export {
|
|
162
|
-
|
|
189
|
+
i as P
|
|
163
190
|
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";const d=require("./class-map-aeZWY44S.cjs"),s=require("./element-B0UgldHm.cjs"),k=require("./state-CG-binsl.cjs"),m=require("./pkt-slot-controller-BEDVscvU.cjs"),r=require("./ref-DDYBJ4EB.cjs");require("./icon-PWn7rnfg.cjs");const h="pkt-modal",g=!0,f={"background-click":{description:"Event som trigges når bakgrunnen trykkes på"},close:{description:"Event som trigges når meldingsboksen lukkes"}},v={headingText:{name:"Heading text",description:"Heading tekst på modalen",type:"string"},hideCloseButton:{name:"Gjem 'Lukk'-knapp",description:"Gjemmer lukkeknappen. Dersom denne er satt til true, vil ikke lukkeknappen vises, og dermed er det viktig at man tilbyr en annen måte som f.eks. en knapp for å lukke modalen på.",type:"boolean",default:!1},closeOnBackdropClick:{name:"Lukk modalen når bakgrunnen trykkes på",description:"Lukk modalen når bakgrunnen trykkes på",type:"boolean",default:!1},closeButtonSkin:{name:"Stil på lukkeknappen",description:"Stil på lukkeknappen",type:["blue","yellow-filled"],default:"blue"},size:{name:"Størrelse",description:"Størrelsen på modalen",type:["small","medium","large"],default:"medium"}},b={default:{description:"Innholdet i meldingen. Her tilbyr vi støtteklasser for å style 1-3 knapper i modalen."}},p={name:h,"css-class":"pkt-modal",isElements:g,events:f,props:v,slots:b};var y=Object.defineProperty,_=Object.getOwnPropertyDescriptor,l=(c,e,t,o)=>{for(var n=o>1?void 0:o?_(e,t):e,i=c.length-1,a;i>=0;i--)(a=c[i])&&(n=(o?a(e,t,n):a(n))||n);return o&&n&&y(e,t,n),n};exports.PktModal=class extends s.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 i;this._isOpen=!1,t||(i=this.dialogRef.value)==null||i.close();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})),document.querySelector(".pkt-modal")&&document.body.classList.remove("pkt-modal--open"),this.requestUpdate()},this.showModal=e=>{var o;this._isOpen=!0,(o=this.dialogRef.value)==null||o.showModal();const t=document.querySelector(".pkt-modal");requestAnimationFrame(()=>{var n;this.dialogRef.value&&((n=this.dialogRef.value)==null||n.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 m.PktSlotController(this,this.defaultSlot),this._isOpen=!1}async connectedCallback(){var e;super.connectedCallback(),document.addEventListener("keydown",this.handleKeyDown.bind(this)),document.addEventListener("click",this.handleBackdropClick.bind(this)),(e=this.dialogRef.value)==null||e.addEventListener("submit",t=>this.close(t,!0))}disconnectedCallback(){var e;super.disconnectedCallback(),document.removeEventListener("keydown",this.handleKeyDown.bind(this)),document.removeEventListener("click",this.handleBackdropClick.bind(this)),(e=this.dialogRef.value)==null||e.removeEventListener("submit",t=>this.close(t,!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},n=this.closeButtonSkin==="blue",i={"pkt-modal__closeButton":!0,[`pkt-modal__closeButton--${this.closeButtonSkin}`]:!0},a={"pkt-btn":!0,[`pkt-btn--${n?"tertiary":"primary"}`]:!0,"pkt-btn--icon-only":!0,"pkt-btn--medium":!0};return s.x`
|
|
2
|
+
<dialog
|
|
3
|
+
class=${d.e(e)}
|
|
4
|
+
aria-modal=${this._isOpen}
|
|
5
|
+
${r.n(this.dialogRef)}
|
|
6
|
+
aria-labelledby="pkt-modal__headingText"
|
|
7
|
+
aria-describedby="pkt-modal__content"
|
|
8
|
+
>
|
|
9
|
+
<div class="pkt-modal__header">
|
|
10
|
+
<div class="pkt-modal__header-background"></div>
|
|
11
|
+
${this.headingText?s.x`<h1 id="pkt-modal__headingText" class=${d.e(t)}>
|
|
12
|
+
${this.headingText}
|
|
13
|
+
</h1>`:s.E}
|
|
14
|
+
${this.hideCloseButton?s.E:s.x`<div class="${d.e(i)}">
|
|
15
|
+
<button
|
|
16
|
+
@click=${u=>this.close(u)}
|
|
17
|
+
class=${d.e(a)}
|
|
18
|
+
aria-label="close"
|
|
19
|
+
>
|
|
20
|
+
<pkt-icon name="close" class="pkt-link__icon"></pkt-icon>
|
|
21
|
+
</button>
|
|
22
|
+
</div>`}
|
|
23
|
+
</div>
|
|
24
|
+
<div class="pkt-modal__container">
|
|
25
|
+
<div
|
|
26
|
+
id="pkt-modal__content"
|
|
27
|
+
class=${d.e(o)}
|
|
28
|
+
${r.n(this.defaultSlot)}
|
|
29
|
+
></div>
|
|
30
|
+
</div>
|
|
31
|
+
</dialog>
|
|
32
|
+
`}};l([s.n({type:String,reflect:!0})],exports.PktModal.prototype,"headingText",2);l([s.n({type:Boolean,reflect:!0})],exports.PktModal.prototype,"removePadding",2);l([s.n({type:Boolean,reflect:!0})],exports.PktModal.prototype,"hideCloseButton",2);l([s.n({type:Boolean,reflect:!0})],exports.PktModal.prototype,"closeOnBackdropClick",2);l([s.n({type:String,reflect:!0})],exports.PktModal.prototype,"closeButtonSkin",2);l([s.n({type:String,reflect:!0})],exports.PktModal.prototype,"size",2);l([k.r()],exports.PktModal.prototype,"_isOpen",2);exports.PktModal=l([s.t("pkt-modal")],exports.PktModal);
|
package/dist/pkt-index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./alert-3DZNN48_.cjs"),p=require("./calendar-CPEJ1enc.cjs"),d=require("./card-TZKEU1Th.cjs"),t=require("./element-B0UgldHm.cjs"),P=require("./pkt-slot-controller-BEDVscvU.cjs"),i=require("./ref-DDYBJ4EB.cjs"),k=require("./class-map-aeZWY44S.cjs"),b=require("./datepicker-DjflnHO9.cjs"),g=require("./helptext-XPScYIkx.cjs"),m=require("./icon-PWn7rnfg.cjs"),h=require("./input-wrapper-nvacN4EY.cjs"),f=require("./link-BnL83t0x.cjs"),y=require("./linkcard-RyOjvpmF.cjs"),v=require("./messagebox-CuM1y2P_.cjs"),x=require("./modal-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("./alert-3DZNN48_.cjs"),p=require("./calendar-CPEJ1enc.cjs"),d=require("./card-TZKEU1Th.cjs"),t=require("./element-B0UgldHm.cjs"),P=require("./pkt-slot-controller-BEDVscvU.cjs"),i=require("./ref-DDYBJ4EB.cjs"),k=require("./class-map-aeZWY44S.cjs"),b=require("./datepicker-DjflnHO9.cjs"),g=require("./helptext-XPScYIkx.cjs"),m=require("./icon-PWn7rnfg.cjs"),h=require("./input-wrapper-nvacN4EY.cjs"),f=require("./link-BnL83t0x.cjs"),y=require("./linkcard-RyOjvpmF.cjs"),v=require("./messagebox-CuM1y2P_.cjs"),x=require("./modal-gLMGJSSY.cjs"),C=require("./progressbar-CkaLjQYa.cjs"),O=require("./radiobutton-HmicLshI.cjs"),j=require("./tag-B0Jd6dQF.cjs"),q=require("./textarea-D7uvC79V.cjs"),S=require("./textinput-C9pkRR6S.cjs"),$=require("./select-B19JEWYw.cjs");var _=Object.defineProperty,T=Object.getOwnPropertyDescriptor,o=(a,e,r,s)=>{for(var n=s>1?void 0:s?T(e,r):e,l=a.length-1,u;l>=0;l--)(u=a[l])&&(n=(s?u(e,r,n):u(n))||n);return s&&n&&_(e,r,n),n};exports.PktComponent=class extends t.PktElement{constructor(){super(),this.string="",this.strings=[],this.darkmode=!1,this._list=[],this.defaultSlot=i.e(),this.namedSlot=i.e(),this.slotController=new P.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="${k.e(e)}">
|
|
3
3
|
<h1 class="pkt-txt-28">${this.string}</h1>
|
|
4
4
|
|
package/dist/pkt-index.js
CHANGED
|
@@ -13,7 +13,7 @@ import { P as M } from "./input-wrapper-CWvzXs6X.js";
|
|
|
13
13
|
import { P as N } from "./link-B3PDtnXT.js";
|
|
14
14
|
import { P as W } from "./linkcard-C4q7HCwY.js";
|
|
15
15
|
import { P as z } from "./messagebox-BDfhozc3.js";
|
|
16
|
-
import { P as J } from "./modal-
|
|
16
|
+
import { P as J } from "./modal-CYv8Qk0Y.js";
|
|
17
17
|
import { P as V } from "./progressbar-DETyIwXf.js";
|
|
18
18
|
import { P as Y } from "./radiobutton-BhQCBJ0I.js";
|
|
19
19
|
import { P as tt } from "./tag-x6f6U6ob.js";
|
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-gLMGJSSY.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.22.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",
|
|
@@ -29,8 +29,8 @@
|
|
|
29
29
|
"urlpattern-polyfill": "^10.0.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@oslokommune/punkt-assets": "^12.21.
|
|
33
|
-
"@oslokommune/punkt-css": "^12.
|
|
32
|
+
"@oslokommune/punkt-assets": "^12.21.6",
|
|
33
|
+
"@oslokommune/punkt-css": "^12.22.0",
|
|
34
34
|
"sass": "^1.78.0",
|
|
35
35
|
"typescript": "^5.6.2",
|
|
36
36
|
"vite": "^5.4.4",
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"url": "https://github.com/oslokommune/punkt/issues"
|
|
58
58
|
},
|
|
59
59
|
"license": "MIT",
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "33ada1308d3f9b91fe54079e2f43e1370aed6a98"
|
|
61
61
|
}
|
|
@@ -9,11 +9,13 @@ import { TPktSize } from '@/types/size'
|
|
|
9
9
|
import specs from 'componentSpecs/modal.json'
|
|
10
10
|
import '@/components/icon'
|
|
11
11
|
|
|
12
|
+
// TODO: Exchange <button> here with <pkt-button> when it is available in pkt-elements
|
|
12
13
|
export interface IPktModal {
|
|
13
14
|
headingText?: string
|
|
14
15
|
removePadding?: boolean
|
|
15
16
|
hideCloseButton?: boolean
|
|
16
17
|
closeOnBackdropClick?: boolean
|
|
18
|
+
closeButtonSkin?: 'blue' | 'yellow-filled'
|
|
17
19
|
size?: TPktSize
|
|
18
20
|
}
|
|
19
21
|
|
|
@@ -26,8 +28,8 @@ export class PktModal extends PktElement implements IPktModal {
|
|
|
26
28
|
specs.props.hideCloseButton.default
|
|
27
29
|
@property({ type: Boolean, reflect: true })
|
|
28
30
|
closeOnBackdropClick?: boolean = specs.props.closeOnBackdropClick.default
|
|
31
|
+
@property({ type: String, reflect: true }) closeButtonSkin?: 'blue' | 'yellow-filled' = 'blue'
|
|
29
32
|
@property({ type: String, reflect: true }) size?: TPktSize = specs.props.size.default as TPktSize
|
|
30
|
-
|
|
31
33
|
defaultSlot: Ref<HTMLElement> = createRef()
|
|
32
34
|
dialogRef: Ref<HTMLDialogElement> = createRef()
|
|
33
35
|
|
|
@@ -102,6 +104,14 @@ export class PktModal extends PktElement implements IPktModal {
|
|
|
102
104
|
this._isOpen = true
|
|
103
105
|
this.dialogRef.value?.showModal()
|
|
104
106
|
const modal = document.querySelector('.pkt-modal')
|
|
107
|
+
|
|
108
|
+
// Prevent the first focusable child from being auto-focused
|
|
109
|
+
requestAnimationFrame(() => {
|
|
110
|
+
if (this.dialogRef.value) {
|
|
111
|
+
this.dialogRef.value?.focus()
|
|
112
|
+
}
|
|
113
|
+
})
|
|
114
|
+
|
|
105
115
|
if (modal) {
|
|
106
116
|
document.body.classList.add('pkt-modal--open')
|
|
107
117
|
}
|
|
@@ -129,6 +139,19 @@ export class PktModal extends PktElement implements IPktModal {
|
|
|
129
139
|
'pkt-txt-18-light': true,
|
|
130
140
|
}
|
|
131
141
|
|
|
142
|
+
const isCloseButtonSkinDefault = this.closeButtonSkin === 'blue'
|
|
143
|
+
const closeButtonClasses = {
|
|
144
|
+
'pkt-modal__closeButton': true,
|
|
145
|
+
[`pkt-modal__closeButton--${this.closeButtonSkin}`]: true,
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const buttonClasses = {
|
|
149
|
+
'pkt-btn': true,
|
|
150
|
+
[`pkt-btn--${isCloseButtonSkinDefault ? 'tertiary' : 'primary'}`]: true,
|
|
151
|
+
'pkt-btn--icon-only': true,
|
|
152
|
+
'pkt-btn--medium': true,
|
|
153
|
+
}
|
|
154
|
+
|
|
132
155
|
return html`
|
|
133
156
|
<dialog
|
|
134
157
|
class=${classMap(classes)}
|
|
@@ -136,19 +159,19 @@ export class PktModal extends PktElement implements IPktModal {
|
|
|
136
159
|
${ref(this.dialogRef)}
|
|
137
160
|
aria-labelledby="pkt-modal__headingText"
|
|
138
161
|
aria-describedby="pkt-modal__content"
|
|
139
|
-
autofocus
|
|
140
162
|
>
|
|
141
163
|
<div class="pkt-modal__header">
|
|
164
|
+
<div class="pkt-modal__header-background"></div>
|
|
142
165
|
${this.headingText
|
|
143
166
|
? html`<h1 id="pkt-modal__headingText" class=${classMap(headingClasses)}>
|
|
144
167
|
${this.headingText}
|
|
145
168
|
</h1>`
|
|
146
169
|
: nothing}
|
|
147
170
|
${!this.hideCloseButton
|
|
148
|
-
? html`<div class="
|
|
171
|
+
? html`<div class="${classMap(closeButtonClasses)}">
|
|
149
172
|
<button
|
|
150
173
|
@click=${(event: Event) => this.close(event)}
|
|
151
|
-
class
|
|
174
|
+
class=${classMap(buttonClasses)}
|
|
152
175
|
aria-label="close"
|
|
153
176
|
>
|
|
154
177
|
<pkt-icon name="close" class="pkt-link__icon"></pkt-icon>
|
|
@@ -156,11 +179,13 @@ export class PktModal extends PktElement implements IPktModal {
|
|
|
156
179
|
</div>`
|
|
157
180
|
: nothing}
|
|
158
181
|
</div>
|
|
159
|
-
<div
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
182
|
+
<div class="pkt-modal__container">
|
|
183
|
+
<div
|
|
184
|
+
id="pkt-modal__content"
|
|
185
|
+
class=${classMap(contentClasses)}
|
|
186
|
+
${ref(this.defaultSlot)}
|
|
187
|
+
></div>
|
|
188
|
+
</div>
|
|
164
189
|
</dialog>
|
|
165
190
|
`
|
|
166
191
|
}
|
package/dist/modal-C6b9Q1fe.cjs
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";const c=require("./class-map-aeZWY44S.cjs"),n=require("./element-B0UgldHm.cjs"),k=require("./state-CG-binsl.cjs"),u=require("./pkt-slot-controller-BEDVscvU.cjs"),a=require("./ref-DDYBJ4EB.cjs");require("./icon-PWn7rnfg.cjs");const m="pkt-modal",h=!0,g={"background-click":{description:"Event som trigges når bakgrunnen trykkes på"},close:{description:"Event som trigges når meldingsboksen lukkes"}},f={headingText:{name:"Heading text",description:"Heading tekst på modalen",type:"string"},hideCloseButton:{name:"Gjem 'Lukk'-knapp",description:"Gjemmer lukkeknappen. Dersom denne er satt til true, vil ikke lukkeknappen vises, og dermed er det viktig at man tilbyr en annen måte som f.eks. en knapp for å lukke modalen på.",type:"boolean",default:!1},closeOnBackdropClick:{name:"Lukk modalen når bakgrunnen trykkes på",description:"Lukk modalen når bakgrunnen trykkes på",type:"boolean",default:!1},size:{name:"Størrelse",description:"Størrelsen på modalen",type:["small","medium","large"],default:"medium"}},v={default:{description:"Innholdet i meldingen. Her tilbyr vi støtteklasser for å style 1-3 knapper i modalen."}},p={name:m,"css-class":"pkt-modal",isElements:h,events:g,props:f,slots:v};var b=Object.defineProperty,y=Object.getOwnPropertyDescriptor,i=(d,e,t,o)=>{for(var s=o>1?void 0:o?y(e,t):e,l=d.length-1,r;l>=0;l--)(r=d[l])&&(s=(o?r(e,t,s):r(s))||s);return o&&s&&b(e,t,s),s};exports.PktModal=class extends n.PktElement{constructor(){super(),this.headingText="",this.removePadding=!1,this.hideCloseButton=p.props.hideCloseButton.default,this.closeOnBackdropClick=p.props.closeOnBackdropClick.default,this.size=p.props.size.default,this.defaultSlot=a.e(),this.dialogRef=a.e(),this._isOpen=!1,this.close=(e,t=!1)=>{var l;this._isOpen=!1,t||(l=this.dialogRef.value)==null||l.close();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})),document.querySelector(".pkt-modal")&&document.body.classList.remove("pkt-modal--open"),this.requestUpdate()},this.showModal=e=>{var o;this._isOpen=!0,(o=this.dialogRef.value)==null||o.showModal(),document.querySelector(".pkt-modal")&&document.body.classList.add("pkt-modal--open"),this.dispatchEvent(new CustomEvent("showModal",{detail:{origin:e},bubbles:!0,composed:!0})),this.requestUpdate()},this.slotController=new u.PktSlotController(this,this.defaultSlot),this._isOpen=!1}async connectedCallback(){var e;super.connectedCallback(),document.addEventListener("keydown",this.handleKeyDown.bind(this)),document.addEventListener("click",this.handleBackdropClick.bind(this)),(e=this.dialogRef.value)==null||e.addEventListener("submit",t=>this.close(t,!0))}disconnectedCallback(){var e;super.disconnectedCallback(),document.removeEventListener("keydown",this.handleKeyDown.bind(this)),document.removeEventListener("click",this.handleBackdropClick.bind(this)),(e=this.dialogRef.value)==null||e.removeEventListener("submit",t=>this.close(t,!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};return n.x`
|
|
2
|
-
<dialog
|
|
3
|
-
class=${c.e(e)}
|
|
4
|
-
aria-modal=${this._isOpen}
|
|
5
|
-
${a.n(this.dialogRef)}
|
|
6
|
-
aria-labelledby="pkt-modal__headingText"
|
|
7
|
-
aria-describedby="pkt-modal__content"
|
|
8
|
-
autofocus
|
|
9
|
-
>
|
|
10
|
-
<div class="pkt-modal__header">
|
|
11
|
-
${this.headingText?n.x`<h1 id="pkt-modal__headingText" class=${c.e(t)}>
|
|
12
|
-
${this.headingText}
|
|
13
|
-
</h1>`:n.E}
|
|
14
|
-
${this.hideCloseButton?n.E:n.x`<div class="pkt-modal__closeButton">
|
|
15
|
-
<button
|
|
16
|
-
@click=${s=>this.close(s)}
|
|
17
|
-
class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only"
|
|
18
|
-
aria-label="close"
|
|
19
|
-
>
|
|
20
|
-
<pkt-icon name="close" class="pkt-link__icon"></pkt-icon>
|
|
21
|
-
</button>
|
|
22
|
-
</div>`}
|
|
23
|
-
</div>
|
|
24
|
-
<div
|
|
25
|
-
id="pkt-modal__content"
|
|
26
|
-
class=${c.e(o)}
|
|
27
|
-
${a.n(this.defaultSlot)}
|
|
28
|
-
></div>
|
|
29
|
-
</dialog>
|
|
30
|
-
`}};i([n.n({type:String,reflect:!0})],exports.PktModal.prototype,"headingText",2);i([n.n({type:Boolean,reflect:!0})],exports.PktModal.prototype,"removePadding",2);i([n.n({type:Boolean,reflect:!0})],exports.PktModal.prototype,"hideCloseButton",2);i([n.n({type:Boolean,reflect:!0})],exports.PktModal.prototype,"closeOnBackdropClick",2);i([n.n({type:String,reflect:!0})],exports.PktModal.prototype,"size",2);i([k.r()],exports.PktModal.prototype,"_isOpen",2);exports.PktModal=i([n.t("pkt-modal")],exports.PktModal);
|