@oslokommune/punkt-elements 12.37.3 → 12.37.5
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 +34 -0
- package/dist/{button-sf_Yzx3X.js → button-D39TTsjJ.js} +44 -38
- package/dist/button-ZkEpUrbJ.cjs +12 -0
- package/dist/{consent-CTX9zf81.js → consent-CJ2e2TSV.js} +1 -1
- package/dist/{consent-BNY1XvpV.cjs → consent-D9VqpDkR.cjs} +1 -1
- package/dist/index.d.ts +8 -4
- package/dist/{modal-4aQZVxGl.cjs → modal-DZY4gZCQ.cjs} +1 -1
- package/dist/{modal-m--Sfj_1.js → modal-sbobjlRZ.js} +12 -12
- package/dist/pkt-button.cjs +1 -1
- package/dist/pkt-button.js +1 -1
- package/dist/pkt-consent.cjs +1 -1
- package/dist/pkt-consent.js +1 -1
- package/dist/pkt-index.cjs +1 -1
- package/dist/pkt-index.js +3 -3
- package/dist/pkt-modal.cjs +1 -1
- package/dist/pkt-modal.js +1 -1
- package/package.json +2 -2
- package/src/components/button/button.ts +35 -5
- package/src/components/modal/modal.ts +1 -1
- package/dist/button-jdMbbn-e.cjs +0 -12
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,40 @@ og skriver commits ca etter [Conventional Commits](https://conventionalcommits.o
|
|
|
5
5
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
+
## [12.37.5](https://github.com/oslokommune/punkt/compare/12.37.4...12.37.5) (2025-05-12)
|
|
9
|
+
|
|
10
|
+
### ⚠ BREAKING CHANGES
|
|
11
|
+
Ingen
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
Ingen
|
|
15
|
+
|
|
16
|
+
### Bug Fixes
|
|
17
|
+
Ingen
|
|
18
|
+
|
|
19
|
+
### Chores
|
|
20
|
+
Ingen
|
|
21
|
+
|
|
22
|
+
---
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
## [12.37.4](https://github.com/oslokommune/punkt/compare/12.37.3...12.37.4) (2025-05-12)
|
|
26
|
+
|
|
27
|
+
### ⚠ BREAKING CHANGES
|
|
28
|
+
Ingen
|
|
29
|
+
|
|
30
|
+
### Features
|
|
31
|
+
Ingen
|
|
32
|
+
|
|
33
|
+
### Bug Fixes
|
|
34
|
+
Ingen
|
|
35
|
+
|
|
36
|
+
### Chores
|
|
37
|
+
Ingen
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
41
|
+
|
|
8
42
|
## [12.37.3](https://github.com/oslokommune/punkt/compare/12.37.2...12.37.3) (2025-05-09)
|
|
9
43
|
|
|
10
44
|
### ⚠ BREAKING CHANGES
|
|
@@ -1,21 +1,27 @@
|
|
|
1
|
-
import { n as
|
|
2
|
-
import { P as
|
|
3
|
-
import { e as
|
|
4
|
-
var
|
|
5
|
-
for (var
|
|
6
|
-
(h = t[d]) && (
|
|
7
|
-
return o &&
|
|
1
|
+
import { n as a, P as b, E as p, x as l, a as c } from "./element-DjjF_tEh.js";
|
|
2
|
+
import { P as f } from "./pkt-slot-controller-DtDaD9q_.js";
|
|
3
|
+
import { e as u, n as k } from "./ref-iIffqQAI.js";
|
|
4
|
+
var y = Object.defineProperty, m = Object.getOwnPropertyDescriptor, s = (t, e, n, o) => {
|
|
5
|
+
for (var r = o > 1 ? void 0 : o ? m(e, n) : e, d = t.length - 1, h; d >= 0; d--)
|
|
6
|
+
(h = t[d]) && (r = (o ? h(e, n, r) : h(r)) || r);
|
|
7
|
+
return o && r && y(e, n, r), r;
|
|
8
8
|
};
|
|
9
|
-
let i = class extends
|
|
9
|
+
let i = class extends b {
|
|
10
10
|
constructor() {
|
|
11
|
-
super(), this.internals = this.attachInternals(), this.defaultSlot =
|
|
11
|
+
super(), this.internals = this.attachInternals(), this.defaultSlot = u(), this.iconName = "user", this.secondIconName = "user", this.mode = "light", this.size = "medium", this.skin = "primary", this.variant = "label-only", this.state = "normal", this.type = "button", this.isLoading = !1, this.disabled = !1, this.slotController = new f(this, this.defaultSlot), this.addEventListener("click", this.handleClick), this.addEventListener("keydown", this.handleKeydown);
|
|
12
12
|
}
|
|
13
13
|
// Lifecycle
|
|
14
14
|
disconnectedCallback() {
|
|
15
15
|
super.disconnectedCallback(), this.removeEventListener("click", this.handleClick), this.removeEventListener("keydown", this.handleKeydown);
|
|
16
16
|
}
|
|
17
|
+
attributeChangedCallback(t, e, n) {
|
|
18
|
+
super.attributeChangedCallback(t, e, n), t === "disabled" && n === "false" && (this.disabled = !1), (t === "isloading" || t === "isLoading") && n === "false" && (this.isLoading = !1);
|
|
19
|
+
}
|
|
20
|
+
firstUpdated(t) {
|
|
21
|
+
super.firstUpdated(t), this.disabled === "false" && (this.disabled = !1), this.isLoading === "false" && (this.isLoading = !1);
|
|
22
|
+
}
|
|
17
23
|
updated(t) {
|
|
18
|
-
super.updated(t), this.setAttribute("role", "button"), this.internals.role = "button", this.disabled ? (this.getAttribute("tabindex") !== "-1" && this.setAttribute("tabindex", "-1"), this.getAttribute("aria-disabled") !== "true" && this.setAttribute("aria-disabled", "true")) : (this.getAttribute("tabindex") !== "0" && this.setAttribute("tabindex", "0"), this.getAttribute("aria-disabled") !== "false" && this.removeAttribute("aria-disabled")), this.isLoading ? this.getAttribute("aria-busy") !== "true" && this.setAttribute("aria-busy", "true") : this.hasAttribute("aria-busy") && this.removeAttribute("aria-busy"), this.updateElementClasses();
|
|
24
|
+
super.updated(t), this.setAttribute("role", "button"), this.internals.role = "button", this.disabled === "false" && (this.disabled = !1), this.isLoading === "false" && (this.isLoading = !1), this.disabled ? (this.getAttribute("tabindex") !== "-1" && this.setAttribute("tabindex", "-1"), this.getAttribute("aria-disabled") !== "true" && this.setAttribute("aria-disabled", "true")) : (this.getAttribute("tabindex") !== "0" && this.setAttribute("tabindex", "0"), this.getAttribute("aria-disabled") !== "false" && this.removeAttribute("aria-disabled")), this.isLoading ? this.getAttribute("aria-busy") !== "true" && this.setAttribute("aria-busy", "true") : this.hasAttribute("aria-busy") && this.removeAttribute("aria-busy"), this.updateElementClasses();
|
|
19
25
|
}
|
|
20
26
|
// Render
|
|
21
27
|
render() {
|
|
@@ -34,8 +40,8 @@ let i = class extends c {
|
|
|
34
40
|
}
|
|
35
41
|
// Methods
|
|
36
42
|
updateElementClasses() {
|
|
37
|
-
const t = /* @__PURE__ */ new Set(),
|
|
38
|
-
t.add("pkt-btn"),
|
|
43
|
+
const t = /* @__PURE__ */ new Set(), e = this.getAttribute("class");
|
|
44
|
+
t.add("pkt-btn"), e && e.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(" ");
|
|
39
45
|
}
|
|
40
46
|
handleClick(t) {
|
|
41
47
|
if (this.disabled || this.isLoading) {
|
|
@@ -61,47 +67,47 @@ let i = class extends c {
|
|
|
61
67
|
handleKeydown(t) {
|
|
62
68
|
if (!(this.disabled || this.isLoading) && (t.key === "Enter" || t.key === " ")) {
|
|
63
69
|
t.preventDefault();
|
|
64
|
-
const
|
|
65
|
-
|
|
70
|
+
const e = t.target;
|
|
71
|
+
e && e.click();
|
|
66
72
|
}
|
|
67
73
|
}
|
|
68
74
|
};
|
|
69
75
|
i.formAssociated = !0;
|
|
70
|
-
|
|
71
|
-
|
|
76
|
+
s([
|
|
77
|
+
a({ type: String })
|
|
72
78
|
], i.prototype, "iconName", 2);
|
|
73
|
-
|
|
74
|
-
|
|
79
|
+
s([
|
|
80
|
+
a({ type: String })
|
|
75
81
|
], i.prototype, "secondIconName", 2);
|
|
76
|
-
|
|
77
|
-
|
|
82
|
+
s([
|
|
83
|
+
a({ type: String })
|
|
78
84
|
], i.prototype, "mode", 2);
|
|
79
|
-
|
|
80
|
-
|
|
85
|
+
s([
|
|
86
|
+
a({ type: String })
|
|
81
87
|
], i.prototype, "size", 2);
|
|
82
|
-
|
|
83
|
-
|
|
88
|
+
s([
|
|
89
|
+
a({ type: String })
|
|
84
90
|
], i.prototype, "color", 2);
|
|
85
|
-
|
|
86
|
-
|
|
91
|
+
s([
|
|
92
|
+
a({ type: String })
|
|
87
93
|
], i.prototype, "skin", 2);
|
|
88
|
-
|
|
89
|
-
|
|
94
|
+
s([
|
|
95
|
+
a({ type: String })
|
|
90
96
|
], i.prototype, "variant", 2);
|
|
91
|
-
|
|
92
|
-
|
|
97
|
+
s([
|
|
98
|
+
a({ type: String })
|
|
93
99
|
], i.prototype, "state", 2);
|
|
94
|
-
|
|
95
|
-
|
|
100
|
+
s([
|
|
101
|
+
a({ type: String, reflect: !0 })
|
|
96
102
|
], i.prototype, "type", 2);
|
|
97
|
-
|
|
98
|
-
|
|
103
|
+
s([
|
|
104
|
+
a({ type: Boolean })
|
|
99
105
|
], i.prototype, "isLoading", 2);
|
|
100
|
-
|
|
101
|
-
|
|
106
|
+
s([
|
|
107
|
+
a({ type: Boolean })
|
|
102
108
|
], i.prototype, "disabled", 2);
|
|
103
|
-
i =
|
|
104
|
-
|
|
109
|
+
i = s([
|
|
110
|
+
c("pkt-button")
|
|
105
111
|
], i);
|
|
106
112
|
export {
|
|
107
113
|
i as P
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";const i=require("./element-BSypUpzA.cjs"),h=require("./pkt-slot-controller-Da-RgXfS.cjs"),d=require("./ref-BvbyvXRH.cjs");var p=Object.defineProperty,u=Object.getOwnPropertyDescriptor,e=(o,t,s,n)=>{for(var a=n>1?void 0:n?u(t,s):t,r=o.length-1,l;r>=0;r--)(l=o[r])&&(a=(n?l(t,s,a):l(a))||a);return n&&a&&p(t,s,a),a};exports.PktButton=class extends i.PktElement{constructor(){super(),this.internals=this.attachInternals(),this.defaultSlot=d.e(),this.iconName="user",this.secondIconName="user",this.mode="light",this.size="medium",this.skin="primary",this.variant="label-only",this.state="normal",this.type="button",this.isLoading=!1,this.disabled=!1,this.slotController=new h.PktSlotController(this,this.defaultSlot),this.addEventListener("click",this.handleClick),this.addEventListener("keydown",this.handleKeydown)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("click",this.handleClick),this.removeEventListener("keydown",this.handleKeydown)}attributeChangedCallback(t,s,n){super.attributeChangedCallback(t,s,n),t==="disabled"&&n==="false"&&(this.disabled=!1),(t==="isloading"||t==="isLoading")&&n==="false"&&(this.isLoading=!1)}firstUpdated(t){super.firstUpdated(t),this.disabled==="false"&&(this.disabled=!1),this.isLoading==="false"&&(this.isLoading=!1)}updated(t){super.updated(t),this.setAttribute("role","button"),this.internals.role="button",this.disabled==="false"&&(this.disabled=!1),this.isLoading==="false"&&(this.isLoading=!1),this.disabled?(this.getAttribute("tabindex")!=="-1"&&this.setAttribute("tabindex","-1"),this.getAttribute("aria-disabled")!=="true"&&this.setAttribute("aria-disabled","true")):(this.getAttribute("tabindex")!=="0"&&this.setAttribute("tabindex","0"),this.getAttribute("aria-disabled")!=="false"&&this.removeAttribute("aria-disabled")),this.isLoading?this.getAttribute("aria-busy")!=="true"&&this.setAttribute("aria-busy","true"):this.hasAttribute("aria-busy")&&this.removeAttribute("aria-busy"),this.updateElementClasses()}render(){return i.x`
|
|
2
|
+
<div class="pkt-contents">
|
|
3
|
+
${this.isLoading?i.x`<pkt-icon
|
|
4
|
+
class="pkt-btn__icon pkt-btn__spinner"
|
|
5
|
+
name="spinner-blue"
|
|
6
|
+
path="https://punkt-cdn.oslo.kommune.no/latest/animations/"
|
|
7
|
+
></pkt-icon>`:i.E}
|
|
8
|
+
${this.variant!=="label-only"?i.x`<pkt-icon class="pkt-btn__icon pkt-icon" name=${this.iconName}></pkt-icon>`:i.E}
|
|
9
|
+
<span class="pkt-btn__text" ${d.n(this.defaultSlot)}></span>
|
|
10
|
+
${this.variant==="icons-right-and-left"?i.x`<pkt-icon class="pkt-btn__icon" name=${this.secondIconName}></pkt-icon>`:i.E}
|
|
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})],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-
|
|
1
|
+
"use strict";const s=require("./element-BSypUpzA.cjs");require("./button-ZkEpUrbJ.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.toLowerCase().includes("oslo.kommune.no")){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
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
|
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ import { Ref } from 'lit/directives/ref.js';
|
|
|
8
8
|
import { TemplateResult } from 'lit-html';
|
|
9
9
|
import { TZDate } from '@date-fns/tz';
|
|
10
10
|
|
|
11
|
+
declare type Booleanish = boolean | 'true' | 'false';
|
|
12
|
+
|
|
11
13
|
/**
|
|
12
14
|
* We define all props as optional. Native HTML attributes are optional by default,
|
|
13
15
|
* but the TS definition require either null or value. This way we can support showing a value as optional
|
|
@@ -111,8 +113,8 @@ export declare interface IPktButton {
|
|
|
111
113
|
variant?: TPktButtonVariant;
|
|
112
114
|
state?: TPktButtonState;
|
|
113
115
|
type?: TPktButtonType;
|
|
114
|
-
isLoading?:
|
|
115
|
-
disabled?:
|
|
116
|
+
isLoading?: Booleanish;
|
|
117
|
+
disabled?: Booleanish;
|
|
116
118
|
}
|
|
117
119
|
|
|
118
120
|
export declare interface IPktCombobox {
|
|
@@ -334,9 +336,11 @@ export declare class PktButton extends PktElement<IPktButton> implements IPktBut
|
|
|
334
336
|
variant: TPktButtonVariant;
|
|
335
337
|
state?: TPktButtonState;
|
|
336
338
|
type: TPktButtonType;
|
|
337
|
-
isLoading:
|
|
338
|
-
disabled:
|
|
339
|
+
isLoading: Booleanish;
|
|
340
|
+
disabled: Booleanish;
|
|
339
341
|
disconnectedCallback(): void;
|
|
342
|
+
attributeChangedCallback(name: string, _old: string | null, value: string | null): void;
|
|
343
|
+
protected firstUpdated(_changedProperties: PropertyValues): void;
|
|
340
344
|
protected updated(_changedProperties: PropertyValues): void;
|
|
341
345
|
render(): TemplateResult<1>;
|
|
342
346
|
private updateElementClasses;
|
|
@@ -1,4 +1,4 @@
|
|
|
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,
|
|
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
2
|
<dialog
|
|
3
3
|
class=${d.e(e)}
|
|
4
4
|
${r.n(this.dialogRef)}
|
|
@@ -17,28 +17,28 @@ const b = {
|
|
|
17
17
|
}, u = {
|
|
18
18
|
props: b
|
|
19
19
|
};
|
|
20
|
-
var y = Object.defineProperty, C = Object.getOwnPropertyDescriptor, n = (t, e, o,
|
|
21
|
-
for (var
|
|
22
|
-
(a = t[r]) && (
|
|
23
|
-
return
|
|
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;
|
|
24
24
|
};
|
|
25
25
|
let l = class extends k {
|
|
26
26
|
constructor() {
|
|
27
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) => {
|
|
28
|
-
var
|
|
28
|
+
var i;
|
|
29
29
|
if (!this._isOpen) return;
|
|
30
30
|
this._isOpen = !1, document.body.classList.remove("pkt-modal--open");
|
|
31
31
|
const o = document.activeElement;
|
|
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
|
-
), e || (
|
|
34
|
+
), e || (i = this.dialogRef.value) == null || i.close(), this.requestUpdate();
|
|
35
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");
|
|
39
39
|
requestAnimationFrame(() => {
|
|
40
|
-
var
|
|
41
|
-
this.dialogRef.value && ((
|
|
40
|
+
var i;
|
|
41
|
+
this.dialogRef.value && ((i = this.dialogRef.value) == null || i.focus());
|
|
42
42
|
}), e && document.body.classList.add("pkt-modal--open"), this.dispatchEvent(
|
|
43
43
|
new CustomEvent("showModal", { detail: { origin: t }, bubbles: !0, composed: !0 })
|
|
44
44
|
), this.requestUpdate();
|
|
@@ -51,7 +51,7 @@ let l = class extends k {
|
|
|
51
51
|
super.disconnectedCallback(), document.removeEventListener("keydown", this.handleKeyDown), document.removeEventListener("click", this.handleBackdropClick);
|
|
52
52
|
}
|
|
53
53
|
async firstUpdated(t) {
|
|
54
|
-
super.firstUpdated(t), this.dialogRef.value && ("document" in window && "createElement" in document && (await import("./dialog-polyfill.esm-CbjBMXAG.js").then((o) => o.default)).registerDialog(this.dialogRef.value), this.dialogRef.value.addEventListener("close", () => {
|
|
54
|
+
super.firstUpdated(t), this.dialogRef.value && !window.HTMLDialogElement && !this.dialogRef.value.showModal && ("document" in window && "createElement" in document && (await import("./dialog-polyfill.esm-CbjBMXAG.js").then((o) => o.default)).registerDialog(this.dialogRef.value), this.dialogRef.value.addEventListener("close", () => {
|
|
55
55
|
this.close(new Event("close"), !0);
|
|
56
56
|
}));
|
|
57
57
|
}
|
|
@@ -79,12 +79,12 @@ let l = class extends k {
|
|
|
79
79
|
}, o = {
|
|
80
80
|
"pkt-modal__content": !0,
|
|
81
81
|
"pkt-txt-18-light": !0
|
|
82
|
-
},
|
|
82
|
+
}, i = this.closeButtonSkin === "blue", s = {
|
|
83
83
|
"pkt-modal__closeButton": !0,
|
|
84
84
|
[`pkt-modal__closeButton--${this.closeButtonSkin}`]: !0
|
|
85
85
|
}, r = {
|
|
86
86
|
"pkt-btn": !0,
|
|
87
|
-
[`pkt-btn--${
|
|
87
|
+
[`pkt-btn--${i ? "tertiary" : "primary"}`]: !0,
|
|
88
88
|
"pkt-btn--icon-only": !0,
|
|
89
89
|
"pkt-btn--medium": !0
|
|
90
90
|
};
|
|
@@ -101,7 +101,7 @@ let l = class extends k {
|
|
|
101
101
|
${this.headingText ? p`<h1 id="pkt-modal__headingText" class=${c(e)}>
|
|
102
102
|
${this.headingText}
|
|
103
103
|
</h1>` : h}
|
|
104
|
-
${this.hideCloseButton ? h : p`<div class="${c(
|
|
104
|
+
${this.hideCloseButton ? h : p`<div class="${c(s)}">
|
|
105
105
|
<pkt-button
|
|
106
106
|
@click=${(a) => this.close(a)}
|
|
107
107
|
class=${c(r)}
|
package/dist/pkt-button.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("./button-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("./button-ZkEpUrbJ.cjs"),e=t.PktButton;Object.defineProperty(exports,"PktButton",{enumerable:!0,get:()=>t.PktButton});exports.default=e;
|
package/dist/pkt-button.js
CHANGED
package/dist/pkt-consent.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./consent-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./consent-D9VqpDkR.cjs"),t=e.PktConsent;Object.defineProperty(exports,"PktConsent",{enumerable:!0,get:()=>e.PktConsent});exports.default=t;
|
package/dist/pkt-consent.js
CHANGED
package/dist/pkt-index.cjs
CHANGED
|
@@ -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-
|
|
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-ZkEpUrbJ.cjs"),k=require("./calendar-CYY42kN4.cjs"),m=require("./card-DH-3qNgp.cjs"),g=require("./combobox-BokBs9Jo.cjs"),h=require("./consent-D9VqpDkR.cjs"),f=require("./checkbox-B7ObRUbU.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-B767w-e9.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-BrDbM3GT.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-DP6RsaQc.cjs"),T=require("./tag-B9kFYxHg.cjs"),I=require("./textarea-DIZf7CVg.cjs"),M=require("./textinput-DMPRHokX.cjs"),R=require("./select-CQs_BAKs.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-
|
|
4
|
+
import { P as T } from "./button-D39TTsjJ.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-Cyww1yKr.js";
|
|
8
8
|
import { P as K } from "./combobox-CnnTPWcA.js";
|
|
9
|
-
import { P as U } from "./consent-
|
|
9
|
+
import { P as U } from "./consent-CJ2e2TSV.js";
|
|
10
10
|
import { P as q } from "./checkbox-DCjl4VM0.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-B748tCGi.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-
|
|
24
|
+
import { P as mt } from "./modal-sbobjlRZ.js";
|
|
25
25
|
import { P as ft } from "./progressbar-BKt_aj7f.js";
|
|
26
26
|
import { P as ht, P as ct } from "./radiobutton-DKHjKH75.js";
|
|
27
27
|
import { P as ut } from "./tag-Cu8afZy8.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-DZY4gZCQ.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.37.
|
|
3
|
+
"version": "12.37.5",
|
|
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",
|
|
@@ -59,5 +59,5 @@
|
|
|
59
59
|
"url": "https://github.com/oslokommune/punkt/issues"
|
|
60
60
|
},
|
|
61
61
|
"license": "MIT",
|
|
62
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "1615cdd90bff58dfa8c9a76cf3a22e88ae77c41c"
|
|
63
63
|
}
|
|
@@ -5,6 +5,7 @@ import { html, nothing, PropertyValues } from 'lit'
|
|
|
5
5
|
import { property, customElement } from 'lit/decorators.js'
|
|
6
6
|
import { createRef, Ref, ref } from 'lit/directives/ref.js'
|
|
7
7
|
|
|
8
|
+
type Booleanish = boolean | 'true' | 'false'
|
|
8
9
|
export type TPktButtonMode = 'light' | 'dark'
|
|
9
10
|
export type TPktButtonSize = 'small' | 'medium' | 'large'
|
|
10
11
|
export type TPktButtonColor =
|
|
@@ -40,8 +41,8 @@ export interface IPktButton {
|
|
|
40
41
|
variant?: TPktButtonVariant
|
|
41
42
|
state?: TPktButtonState
|
|
42
43
|
type?: TPktButtonType
|
|
43
|
-
isLoading?:
|
|
44
|
-
disabled?:
|
|
44
|
+
isLoading?: Booleanish
|
|
45
|
+
disabled?: Booleanish
|
|
45
46
|
}
|
|
46
47
|
@customElement('pkt-button')
|
|
47
48
|
export class PktButton extends PktElement<IPktButton> implements IPktButton {
|
|
@@ -65,10 +66,10 @@ export class PktButton extends PktElement<IPktButton> implements IPktButton {
|
|
|
65
66
|
@property({ type: String }) color?: TPktButtonColor
|
|
66
67
|
@property({ type: String }) skin: TPktButtonSkin = 'primary'
|
|
67
68
|
@property({ type: String }) variant: TPktButtonVariant = 'label-only'
|
|
68
|
-
@property({ type: String
|
|
69
|
+
@property({ type: String }) state?: TPktButtonState = 'normal'
|
|
69
70
|
@property({ type: String, reflect: true }) type: TPktButtonType = 'button'
|
|
70
|
-
@property({ type: Boolean
|
|
71
|
-
@property({ type: Boolean
|
|
71
|
+
@property({ type: Boolean }) isLoading: Booleanish = false
|
|
72
|
+
@property({ type: Boolean }) disabled: Booleanish = false
|
|
72
73
|
|
|
73
74
|
// Lifecycle
|
|
74
75
|
|
|
@@ -78,12 +79,41 @@ export class PktButton extends PktElement<IPktButton> implements IPktButton {
|
|
|
78
79
|
this.removeEventListener('keydown', this.handleKeydown as EventListener)
|
|
79
80
|
}
|
|
80
81
|
|
|
82
|
+
attributeChangedCallback(name: string, _old: string | null, value: string | null): void {
|
|
83
|
+
super.attributeChangedCallback(name, _old, value)
|
|
84
|
+
// Convert strings to booleans
|
|
85
|
+
if (name === 'disabled' && value === 'false') {
|
|
86
|
+
this.disabled = false
|
|
87
|
+
}
|
|
88
|
+
if ((name === 'isloading' || name === 'isLoading') && value === 'false') {
|
|
89
|
+
this.isLoading = false
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
protected firstUpdated(_changedProperties: PropertyValues): void {
|
|
94
|
+
super.firstUpdated(_changedProperties)
|
|
95
|
+
|
|
96
|
+
if (this.disabled === 'false') {
|
|
97
|
+
this.disabled = false
|
|
98
|
+
}
|
|
99
|
+
if (this.isLoading === 'false') {
|
|
100
|
+
this.isLoading = false
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
|
|
81
104
|
protected updated(_changedProperties: PropertyValues): void {
|
|
82
105
|
super.updated(_changedProperties)
|
|
83
106
|
|
|
84
107
|
this.setAttribute('role', 'button')
|
|
85
108
|
this.internals.role = 'button'
|
|
86
109
|
|
|
110
|
+
if (this.disabled === 'false') {
|
|
111
|
+
this.disabled = false
|
|
112
|
+
}
|
|
113
|
+
if (this.isLoading === 'false') {
|
|
114
|
+
this.isLoading = false
|
|
115
|
+
}
|
|
116
|
+
|
|
87
117
|
if (this.disabled) {
|
|
88
118
|
if (this.getAttribute('tabindex') !== '-1') {
|
|
89
119
|
this.setAttribute('tabindex', '-1')
|
|
@@ -54,7 +54,7 @@ export class PktModal extends PktElement implements IPktModal {
|
|
|
54
54
|
|
|
55
55
|
protected async firstUpdated(_changedProperties: PropertyValues): Promise<void> {
|
|
56
56
|
super.firstUpdated(_changedProperties)
|
|
57
|
-
if (this.dialogRef.value) {
|
|
57
|
+
if (this.dialogRef.value && !window.HTMLDialogElement && !this.dialogRef.value.showModal) {
|
|
58
58
|
if ('document' in window && 'createElement' in document) {
|
|
59
59
|
const dialogPolyfill = await import('dialog-polyfill').then((module) => module.default)
|
|
60
60
|
dialogPolyfill.registerDialog(this.dialogRef.value)
|
package/dist/button-jdMbbn-e.cjs
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";const e=require("./element-BSypUpzA.cjs"),h=require("./pkt-slot-controller-Da-RgXfS.cjs"),d=require("./ref-BvbyvXRH.cjs");var p=Object.defineProperty,u=Object.getOwnPropertyDescriptor,i=(r,t,s,o)=>{for(var n=o>1?void 0:o?u(t,s):t,a=r.length-1,l;a>=0;a--)(l=r[a])&&(n=(o?l(t,s,n):l(n))||n);return o&&n&&p(t,s,n),n};exports.PktButton=class extends e.PktElement{constructor(){super(),this.internals=this.attachInternals(),this.defaultSlot=d.e(),this.iconName="user",this.secondIconName="user",this.mode="light",this.size="medium",this.skin="primary",this.variant="label-only",this.state="normal",this.type="button",this.isLoading=!1,this.disabled=!1,this.slotController=new h.PktSlotController(this,this.defaultSlot),this.addEventListener("click",this.handleClick),this.addEventListener("keydown",this.handleKeydown)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("click",this.handleClick),this.removeEventListener("keydown",this.handleKeydown)}updated(t){super.updated(t),this.setAttribute("role","button"),this.internals.role="button",this.disabled?(this.getAttribute("tabindex")!=="-1"&&this.setAttribute("tabindex","-1"),this.getAttribute("aria-disabled")!=="true"&&this.setAttribute("aria-disabled","true")):(this.getAttribute("tabindex")!=="0"&&this.setAttribute("tabindex","0"),this.getAttribute("aria-disabled")!=="false"&&this.removeAttribute("aria-disabled")),this.isLoading?this.getAttribute("aria-busy")!=="true"&&this.setAttribute("aria-busy","true"):this.hasAttribute("aria-busy")&&this.removeAttribute("aria-busy"),this.updateElementClasses()}render(){return e.x`
|
|
2
|
-
<div class="pkt-contents">
|
|
3
|
-
${this.isLoading?e.x`<pkt-icon
|
|
4
|
-
class="pkt-btn__icon pkt-btn__spinner"
|
|
5
|
-
name="spinner-blue"
|
|
6
|
-
path="https://punkt-cdn.oslo.kommune.no/latest/animations/"
|
|
7
|
-
></pkt-icon>`:e.E}
|
|
8
|
-
${this.variant!=="label-only"?e.x`<pkt-icon class="pkt-btn__icon pkt-icon" name=${this.iconName}></pkt-icon>`:e.E}
|
|
9
|
-
<span class="pkt-btn__text" ${d.n(this.defaultSlot)}></span>
|
|
10
|
-
${this.variant==="icons-right-and-left"?e.x`<pkt-icon class="pkt-btn__icon" name=${this.secondIconName}></pkt-icon>`:e.E}
|
|
11
|
-
</div>
|
|
12
|
-
`}updateElementClasses(){const t=new Set,s=this.getAttribute("class");t.add("pkt-btn"),s&&s.split(" ").forEach(o=>t.add(o)),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;i([e.n({type:String})],exports.PktButton.prototype,"iconName",2);i([e.n({type:String})],exports.PktButton.prototype,"secondIconName",2);i([e.n({type:String})],exports.PktButton.prototype,"mode",2);i([e.n({type:String})],exports.PktButton.prototype,"size",2);i([e.n({type:String})],exports.PktButton.prototype,"color",2);i([e.n({type:String})],exports.PktButton.prototype,"skin",2);i([e.n({type:String})],exports.PktButton.prototype,"variant",2);i([e.n({type:String,reflect:!0})],exports.PktButton.prototype,"state",2);i([e.n({type:String,reflect:!0})],exports.PktButton.prototype,"type",2);i([e.n({type:Boolean,reflect:!0})],exports.PktButton.prototype,"isLoading",2);i([e.n({type:Boolean,reflect:!0})],exports.PktButton.prototype,"disabled",2);exports.PktButton=i([e.t("pkt-button")],exports.PktButton);
|