@oslokommune/punkt-elements 12.29.1 → 12.29.3
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/alert-CP5oN7df.cjs +27 -0
- package/dist/{alert-C_FCsFfo.js → alert-CugVni4g.js} +14 -11
- package/dist/classutils-BwNK82ZQ.cjs +1 -0
- package/dist/classutils-RQs1k6D9.js +7 -0
- package/dist/index.d.ts +75 -7
- package/dist/loader-ChVEsONa.js +85 -0
- package/dist/loader-DQV1hMM3.cjs +11 -0
- package/dist/loader.d.ts +15 -0
- package/dist/messagebox-BSyLVNas.cjs +12 -0
- package/dist/{messagebox-BgLZ5zul.js → messagebox-Di7LUz4C.js} +29 -23
- package/dist/{modal-CV3LSNHb.cjs → modal-CblCiNUi.cjs} +4 -3
- package/dist/{modal-CnSYSYsQ.js → modal-DZUQb_yG.js} +24 -23
- package/dist/pkt-alert.cjs +1 -1
- package/dist/pkt-alert.js +1 -1
- package/dist/pkt-index.cjs +3 -3
- package/dist/pkt-index.js +23 -21
- package/dist/pkt-loader.cjs +1 -0
- package/dist/pkt-loader.js +6 -0
- package/dist/pkt-messagebox.cjs +1 -1
- package/dist/pkt-messagebox.js +1 -1
- package/dist/pkt-modal.cjs +1 -1
- package/dist/pkt-modal.js +1 -1
- package/package.json +2 -2
- package/src/components/alert/alert.ts +27 -16
- package/src/components/button/button.ts +3 -4
- package/src/components/index.ts +6 -1
- package/src/components/loader/index.ts +5 -0
- package/src/components/loader/loader.ts +125 -0
- package/src/components/messagebox/messagebox.ts +23 -7
- package/src/components/modal/modal.ts +4 -3
- package/dist/alert-Cx7AYawa.cjs +0 -27
- package/dist/messagebox-DJzOyZwE.cjs +0 -12
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";const d=require("./class-map-Dzci3Pfe.cjs"),e=require("./element-r-PeQ419.cjs"),k=require("./state-B77EXPZ9.cjs"),u=require("./pkt-slot-controller-Oc32unDk.cjs"),c=require("./ref-BUWgvhgU.cjs"),h=require("./classutils-BwNK82ZQ.cjs");require("./icon-DcJIqTIY.cjs");const v="pkt-alert",f=!0,m={onClose:{description:"React: Klikk-event for 'Lukk'-knappen"},close:{description:"Vue: Klikk-event for 'Lukk'-knappen"}},b={title:{name:"Tittel",description:"Tittelen som vises øverst i på meldingen",type:"string"},skin:{name:"Utseende",description:"Hvordan type melding er dette?",type:["info","success","warning","error"],default:"info"},date:{name:"Sist oppdatert",description:"Dato som vises nederst i på meldingen",type:"string"},ariaLive:{name:"aria-live",description:"Hvordan skal skjermleseren lese opp meldingen?",type:["off","polite","assertive"],default:"polite"},compact:{name:"Kompakt",description:"Gjør meldingen mindre",type:"boolean",default:!1},closeAlert:{name:"Vis 'Lukk'-knapp",description:"Viser 'Lukk'-knappen",type:"boolean",default:!1}},y={default:{description:"Innholdet i meldingen"}},a={name:v,"css-class":"pkt-alert","dark-mode":!0,isElement:f,events:m,props:b,slots:y};var _=Object.defineProperty,C=Object.getOwnPropertyDescriptor,s=(n,t,r,i)=>{for(var l=i>1?void 0:i?C(t,r):t,o=n.length-1,p;o>=0;o--)(p=n[o])&&(l=(i?p(t,r,l):p(l))||l);return i&&l&&_(t,r,l),l};exports.PktAlert=class extends e.PktElement{constructor(){super(),this.defaultSlot=c.e(),this.compact=a.props.compact.default,this.title="",this.skin=a.props.skin.default,this.ariaLive=a.props.ariaLive.default,this["aria-live"]=null,this.closeAlert=a.props.closeAlert.default,this.date=null,this._isClosed=!1,this.close=t=>{this._isClosed=!0,this.dispatchEvent(new CustomEvent("close",{detail:{origin:t},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("on-close",{detail:{origin:t},bubbles:!0,composed:!0}))},this.slotController=new u.PktSlotController(this,this.defaultSlot),this._isClosed=!1}connectedCallback(){super.connectedCallback(),this["aria-live"]=this.getAttribute("aria-live")||this.ariaLive}attributeChangedCallback(t,r,i){t==="ariaLive"&&(this["aria-live"]=i),super.attributeChangedCallback(t,r,i)}updated(t){super.updated(t),t.has("ariaLive")&&(this["aria-live"]=this.ariaLive),t.has("_isClosed")&&h.updateClassAttribute(this,"pkt-hide",this._isClosed)}render(){const t={"pkt-alert":!0,"pkt-alert--compact":this.compact,[`pkt-alert--${this.skin}`]:this.skin,"pkt-hide":this._isClosed};return e.x`
|
|
2
|
+
<div class=${d.e(t)}>
|
|
3
|
+
<pkt-icon
|
|
4
|
+
class="pkt-alert__icon"
|
|
5
|
+
name=${this.skin==="info"?"alert-information":`alert-${this.skin}`}
|
|
6
|
+
></pkt-icon>
|
|
7
|
+
|
|
8
|
+
${this.closeAlert?e.x`
|
|
9
|
+
<div class="pkt-alert__close">
|
|
10
|
+
<button
|
|
11
|
+
type="button"
|
|
12
|
+
class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only"
|
|
13
|
+
tabindex="0"
|
|
14
|
+
aria-label="close"
|
|
15
|
+
@click=${this.close}
|
|
16
|
+
>
|
|
17
|
+
<pkt-icon name="close" class="pkt-btn__icon" aria-hidden="true"></pkt-icon>
|
|
18
|
+
</button>
|
|
19
|
+
</div>
|
|
20
|
+
`:e.E}
|
|
21
|
+
${this.title?e.x`<div class="pkt-alert__title">${this.title}</div>`:e.E}
|
|
22
|
+
|
|
23
|
+
<div class="pkt-alert__text" ${c.n(this.defaultSlot)}></div>
|
|
24
|
+
|
|
25
|
+
${this.date?e.x`<div class="pkt-alert__date">Sist oppdatert: ${this.date}</div>`:e.E}
|
|
26
|
+
</div>
|
|
27
|
+
`}};s([e.n({type:Boolean,reflect:!1})],exports.PktAlert.prototype,"compact",2);s([e.n({type:String,reflect:!0})],exports.PktAlert.prototype,"title",2);s([e.n({type:String,reflect:!0})],exports.PktAlert.prototype,"skin",2);s([e.n({type:String})],exports.PktAlert.prototype,"ariaLive",2);s([e.n({type:String,reflect:!0})],exports.PktAlert.prototype,"aria-live",2);s([e.n({type:Boolean,reflect:!0})],exports.PktAlert.prototype,"closeAlert",2);s([e.n({type:String,reflect:!0})],exports.PktAlert.prototype,"date",2);s([k.r()],exports.PktAlert.prototype,"_isClosed",2);exports.PktAlert=s([e.t("pkt-alert")],exports.PktAlert);
|
|
@@ -3,15 +3,16 @@ import { P as m, x as n, E as u, n as r, a as h } from "./element-D_ZgQsSr.js";
|
|
|
3
3
|
import { r as f } from "./state-DuS4ffEQ.js";
|
|
4
4
|
import { P as v } from "./pkt-slot-controller-Clbye6cM.js";
|
|
5
5
|
import { e as b, n as y } from "./ref-BSGI8ogR.js";
|
|
6
|
+
import { u as _ } from "./classutils-RQs1k6D9.js";
|
|
6
7
|
import "./icon-BBFK-d-X.js";
|
|
7
|
-
const
|
|
8
|
+
const C = "pkt-alert", g = !0, $ = {
|
|
8
9
|
onClose: {
|
|
9
10
|
description: "React: Klikk-event for 'Lukk'-knappen"
|
|
10
11
|
},
|
|
11
12
|
close: {
|
|
12
13
|
description: "Vue: Klikk-event for 'Lukk'-knappen"
|
|
13
14
|
}
|
|
14
|
-
},
|
|
15
|
+
}, L = {
|
|
15
16
|
title: {
|
|
16
17
|
name: "Tittel",
|
|
17
18
|
description: "Tittelen som vises øverst i på meldingen",
|
|
@@ -55,23 +56,23 @@ const _ = "pkt-alert", g = !0, C = {
|
|
|
55
56
|
type: "boolean",
|
|
56
57
|
default: !1
|
|
57
58
|
}
|
|
58
|
-
},
|
|
59
|
+
}, S = {
|
|
59
60
|
default: {
|
|
60
61
|
description: "Innholdet i meldingen"
|
|
61
62
|
}
|
|
62
63
|
}, p = {
|
|
63
|
-
name:
|
|
64
|
+
name: C,
|
|
64
65
|
"css-class": "pkt-alert",
|
|
65
66
|
"dark-mode": !0,
|
|
66
67
|
isElement: g,
|
|
67
|
-
events:
|
|
68
|
-
props:
|
|
69
|
-
slots:
|
|
68
|
+
events: $,
|
|
69
|
+
props: L,
|
|
70
|
+
slots: S
|
|
70
71
|
};
|
|
71
|
-
var
|
|
72
|
-
for (var s = o > 1 ? void 0 : o ?
|
|
72
|
+
var A = Object.defineProperty, E = Object.getOwnPropertyDescriptor, i = (t, a, l, o) => {
|
|
73
|
+
for (var s = o > 1 ? void 0 : o ? E(a, l) : a, c = t.length - 1, d; c >= 0; c--)
|
|
73
74
|
(d = t[c]) && (s = (o ? d(a, l, s) : d(s)) || s);
|
|
74
|
-
return o && s &&
|
|
75
|
+
return o && s && A(a, l, s), s;
|
|
75
76
|
};
|
|
76
77
|
let e = class extends m {
|
|
77
78
|
constructor() {
|
|
@@ -83,6 +84,7 @@ let e = class extends m {
|
|
|
83
84
|
);
|
|
84
85
|
}, this.slotController = new v(this, this.defaultSlot), this._isClosed = !1;
|
|
85
86
|
}
|
|
87
|
+
// Lifecycle
|
|
86
88
|
connectedCallback() {
|
|
87
89
|
super.connectedCallback(), this["aria-live"] = this.getAttribute("aria-live") || this.ariaLive;
|
|
88
90
|
}
|
|
@@ -90,8 +92,9 @@ let e = class extends m {
|
|
|
90
92
|
t === "ariaLive" && (this["aria-live"] = l), super.attributeChangedCallback(t, a, l);
|
|
91
93
|
}
|
|
92
94
|
updated(t) {
|
|
93
|
-
super.updated(t), t.has("ariaLive") && (this["aria-live"] = this.ariaLive);
|
|
95
|
+
super.updated(t), t.has("ariaLive") && (this["aria-live"] = this.ariaLive), t.has("_isClosed") && _(this, "pkt-hide", this._isClosed);
|
|
94
96
|
}
|
|
97
|
+
// Render
|
|
95
98
|
render() {
|
|
96
99
|
const t = {
|
|
97
100
|
"pkt-alert": !0,
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function a(s,e,i){const r=s.getAttribute("class")||"",t=new Set(r.split(/\s+/).filter(Boolean));i?t.add(e):t.delete(e),s.setAttribute("class",Array.from(t).join(" "))}exports.updateClassAttribute=a;
|
package/dist/index.d.ts
CHANGED
|
@@ -14,6 +14,16 @@ import { TZDate } from '@date-fns/tz';
|
|
|
14
14
|
*/
|
|
15
15
|
declare type ElementProps<Element, PropKeys extends keyof Element> = Partial<Pick<Element, PropKeys>>;
|
|
16
16
|
|
|
17
|
+
declare interface IPktAlert {
|
|
18
|
+
skin?: TAlertSkin;
|
|
19
|
+
closeAlert?: boolean;
|
|
20
|
+
title?: string;
|
|
21
|
+
date?: string | null;
|
|
22
|
+
ariaLive?: TAriaLive | null;
|
|
23
|
+
'aria-live'?: TAriaLive | null;
|
|
24
|
+
compact?: boolean;
|
|
25
|
+
}
|
|
26
|
+
|
|
17
27
|
export declare interface IPktButton {
|
|
18
28
|
iconName?: string;
|
|
19
29
|
secondIconName?: string;
|
|
@@ -37,6 +47,44 @@ declare interface IPktLinkCard {
|
|
|
37
47
|
skin?: TLinkCardSkin;
|
|
38
48
|
}
|
|
39
49
|
|
|
50
|
+
export declare interface IPktLoader {
|
|
51
|
+
/**
|
|
52
|
+
* The `delay` prop controls how much time the loading should be given before the loader is displayed.
|
|
53
|
+
* This is handy for situations where the load time might be so short that loader is not necessary.
|
|
54
|
+
* Delay time is in milliseconds.
|
|
55
|
+
*/
|
|
56
|
+
delay?: number;
|
|
57
|
+
/**
|
|
58
|
+
* The `inline` prop decides whether the loader should be displayed inline or not.
|
|
59
|
+
*/
|
|
60
|
+
inline?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* The boolean 'isLoading' decides whether the loader or the children will be displayed.
|
|
63
|
+
* If set to false, the children will be displayed.
|
|
64
|
+
*/
|
|
65
|
+
isLoading?: boolean;
|
|
66
|
+
/**
|
|
67
|
+
* The message to display when the loader is loading.
|
|
68
|
+
*/
|
|
69
|
+
message?: string | null;
|
|
70
|
+
/**
|
|
71
|
+
* The size of the loader. Default is "medium".
|
|
72
|
+
*/
|
|
73
|
+
size?: TPktSize;
|
|
74
|
+
/**
|
|
75
|
+
* The variant of the loader. Default is "shapes" which is the OSLO wave loader.
|
|
76
|
+
* Other variants are "blue" and "rainbow" which are spinner variants.
|
|
77
|
+
*/
|
|
78
|
+
variant?: TPktLoaderVariant;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
declare interface IPktMessagebox {
|
|
82
|
+
skin?: TMessageboxSkin;
|
|
83
|
+
title?: string;
|
|
84
|
+
compact?: boolean;
|
|
85
|
+
closable?: boolean;
|
|
86
|
+
}
|
|
87
|
+
|
|
40
88
|
declare interface IPktModal {
|
|
41
89
|
headingText?: string;
|
|
42
90
|
removePadding?: boolean;
|
|
@@ -77,22 +125,22 @@ declare interface IPktTag {
|
|
|
77
125
|
ariaLabel?: string;
|
|
78
126
|
}
|
|
79
127
|
|
|
80
|
-
export declare class PktAlert extends PktElement {
|
|
128
|
+
export declare class PktAlert extends PktElement implements IPktAlert {
|
|
81
129
|
defaultSlot: Ref<HTMLElement>;
|
|
82
130
|
constructor();
|
|
83
131
|
compact: boolean;
|
|
84
132
|
title: string;
|
|
85
133
|
skin: TAlertSkin;
|
|
86
134
|
ariaLive: TAriaLive;
|
|
87
|
-
'aria-live': TAriaLive;
|
|
135
|
+
'aria-live': TAriaLive | null;
|
|
88
136
|
closeAlert: boolean;
|
|
89
137
|
date: string | null;
|
|
90
138
|
_isClosed: boolean;
|
|
91
|
-
private close;
|
|
92
139
|
connectedCallback(): void;
|
|
93
140
|
attributeChangedCallback(name: string, _old: string | null, value: string | null): void;
|
|
94
141
|
protected updated(_changedProperties: PropertyValues): void;
|
|
95
142
|
render(): TemplateResult<1>;
|
|
143
|
+
private close;
|
|
96
144
|
}
|
|
97
145
|
|
|
98
146
|
export declare class PktButton extends PktElement<IPktButton> implements IPktButton {
|
|
@@ -113,7 +161,7 @@ export declare class PktButton extends PktElement<IPktButton> implements IPktBut
|
|
|
113
161
|
disabled: boolean;
|
|
114
162
|
connectedCallback(): void;
|
|
115
163
|
disconnectedCallback(): void;
|
|
116
|
-
updated(
|
|
164
|
+
protected updated(_changedProperties: PropertyValues): void;
|
|
117
165
|
render(): TemplateResult<1>;
|
|
118
166
|
private updateElementClasses;
|
|
119
167
|
private handleClick;
|
|
@@ -504,7 +552,24 @@ export declare class PktLinkCard extends PktElement implements IPktLinkCard {
|
|
|
504
552
|
render(): TemplateResult<1>;
|
|
505
553
|
}
|
|
506
554
|
|
|
507
|
-
export declare class
|
|
555
|
+
export declare class PktLoader extends PktElement implements IPktLoader {
|
|
556
|
+
defaultSlot: Ref<HTMLElement>;
|
|
557
|
+
constructor();
|
|
558
|
+
delay: number;
|
|
559
|
+
inline: boolean;
|
|
560
|
+
isLoading: boolean;
|
|
561
|
+
message: string | null;
|
|
562
|
+
size: TPktSize;
|
|
563
|
+
variant: TPktLoaderVariant;
|
|
564
|
+
private _shouldDisplayLoader;
|
|
565
|
+
connectedCallback(): void;
|
|
566
|
+
updated(changedProperties: Map<string, unknown>): void;
|
|
567
|
+
render(): TemplateResult<1>;
|
|
568
|
+
private getVariant;
|
|
569
|
+
private setupLoader;
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
export declare class PktMessagebox extends PktElement implements IPktMessagebox {
|
|
508
573
|
defaultSlot: Ref<HTMLElement>;
|
|
509
574
|
constructor();
|
|
510
575
|
closable: boolean;
|
|
@@ -512,8 +577,9 @@ export declare class PktMessagebox extends PktElement {
|
|
|
512
577
|
title: string;
|
|
513
578
|
skin: TMessageboxSkin;
|
|
514
579
|
_isClosed: boolean;
|
|
515
|
-
|
|
580
|
+
protected updated(_changedProperties: PropertyValues): void;
|
|
516
581
|
render(): TemplateResult<1>;
|
|
582
|
+
private close;
|
|
517
583
|
}
|
|
518
584
|
|
|
519
585
|
export declare class PktModal extends PktElement implements IPktModal {
|
|
@@ -694,7 +760,7 @@ declare type Props_5 = ElementProps<PktTextinput, 'value' | 'type' | 'size' | 'a
|
|
|
694
760
|
|
|
695
761
|
declare type TAlertSkin = 'error' | 'success' | 'warning' | 'info';
|
|
696
762
|
|
|
697
|
-
declare type TAriaLive = 'off' | 'polite' | 'assertive'
|
|
763
|
+
declare type TAriaLive = 'off' | 'polite' | 'assertive';
|
|
698
764
|
|
|
699
765
|
declare type TCardSkin = 'outlined' | 'gray' | 'beige' | 'green' | 'blue';
|
|
700
766
|
|
|
@@ -718,6 +784,8 @@ export declare type TPktButtonType = 'button' | 'submit' | 'reset';
|
|
|
718
784
|
|
|
719
785
|
export declare type TPktButtonVariant = 'label-only' | 'icon-left' | 'icon-right' | 'icon-only' | 'icons-right-and-left';
|
|
720
786
|
|
|
787
|
+
export declare type TPktLoaderVariant = 'blue' | 'rainbow' | 'shapes';
|
|
788
|
+
|
|
721
789
|
declare type TPktSize = 'small' | 'medium' | 'large';
|
|
722
790
|
|
|
723
791
|
export declare type TProgressbarRole = 'progressbar' | 'meter';
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { P as u, x as d, E as y, n as o, a as c } from "./element-D_ZgQsSr.js";
|
|
2
|
+
import { e as h } from "./class-map-BYCG9U47.js";
|
|
3
|
+
import { r as m } from "./state-DuS4ffEQ.js";
|
|
4
|
+
import { e as f, n as v } from "./ref-BSGI8ogR.js";
|
|
5
|
+
import { P as _ } from "./pkt-slot-controller-Clbye6cM.js";
|
|
6
|
+
import "./icon-BBFK-d-X.js";
|
|
7
|
+
var g = Object.defineProperty, L = Object.getOwnPropertyDescriptor, s = (e, a, l, r) => {
|
|
8
|
+
for (var i = r > 1 ? void 0 : r ? L(a, l) : a, p = e.length - 1, n; p >= 0; p--)
|
|
9
|
+
(n = e[p]) && (i = (r ? n(a, l, i) : n(i)) || i);
|
|
10
|
+
return r && i && g(a, l, i), i;
|
|
11
|
+
};
|
|
12
|
+
let t = class extends u {
|
|
13
|
+
constructor() {
|
|
14
|
+
super(), this.defaultSlot = f(), this.delay = 0, this.inline = !1, this.isLoading = !0, this.message = null, this.size = "medium", this.variant = "shapes", this._shouldDisplayLoader = !1, this.slotController = new _(this, this.defaultSlot);
|
|
15
|
+
}
|
|
16
|
+
connectedCallback() {
|
|
17
|
+
super.connectedCallback(), this._shouldDisplayLoader = this.delay === 0, this.delay > 0 && this.setupLoader();
|
|
18
|
+
}
|
|
19
|
+
updated(e) {
|
|
20
|
+
e.has("delay") && this.setupLoader();
|
|
21
|
+
}
|
|
22
|
+
render() {
|
|
23
|
+
const e = h({
|
|
24
|
+
"pkt-loader": !0,
|
|
25
|
+
[`pkt-loader--${this.inline ? "inline" : "box"}`]: !0,
|
|
26
|
+
[`pkt-loader--${this.size}`]: !0
|
|
27
|
+
}), a = h({
|
|
28
|
+
"pkt-contents": !0,
|
|
29
|
+
"pkt-hide": this.isLoading
|
|
30
|
+
});
|
|
31
|
+
return d`<div role="status" aria-live="polite" .aria-busy=${this.isLoading} class=${e}>
|
|
32
|
+
${this.isLoading && this._shouldDisplayLoader ? d`<div class="pkt-loader__spinner">
|
|
33
|
+
<pkt-icon
|
|
34
|
+
name=${this.getVariant(this.variant)}
|
|
35
|
+
path="https://punkt-cdn.oslo.kommune.no/latest/animations/"
|
|
36
|
+
class="pkt-loader__svg pkt-loader__${this.variant}"
|
|
37
|
+
></pkt-icon>
|
|
38
|
+
${this.message && d`<p>${this.message}</p>`}
|
|
39
|
+
</div>` : y}
|
|
40
|
+
<div class=${a} ${v(this.defaultSlot)}></div>
|
|
41
|
+
</div>`;
|
|
42
|
+
}
|
|
43
|
+
getVariant(e) {
|
|
44
|
+
switch (e) {
|
|
45
|
+
case "blue":
|
|
46
|
+
return "spinner-blue";
|
|
47
|
+
case "rainbow":
|
|
48
|
+
return "spinner";
|
|
49
|
+
default:
|
|
50
|
+
return "loader";
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
setupLoader() {
|
|
54
|
+
this.delay > 0 && (this._shouldDisplayLoader = !1, setTimeout(() => {
|
|
55
|
+
this._shouldDisplayLoader = !0, this.requestUpdate();
|
|
56
|
+
}, this.delay));
|
|
57
|
+
}
|
|
58
|
+
};
|
|
59
|
+
s([
|
|
60
|
+
o({ type: Number })
|
|
61
|
+
], t.prototype, "delay", 2);
|
|
62
|
+
s([
|
|
63
|
+
o({ type: Boolean })
|
|
64
|
+
], t.prototype, "inline", 2);
|
|
65
|
+
s([
|
|
66
|
+
o({ type: Boolean })
|
|
67
|
+
], t.prototype, "isLoading", 2);
|
|
68
|
+
s([
|
|
69
|
+
o({ type: String })
|
|
70
|
+
], t.prototype, "message", 2);
|
|
71
|
+
s([
|
|
72
|
+
o({ type: String })
|
|
73
|
+
], t.prototype, "size", 2);
|
|
74
|
+
s([
|
|
75
|
+
o({ type: String })
|
|
76
|
+
], t.prototype, "variant", 2);
|
|
77
|
+
s([
|
|
78
|
+
m()
|
|
79
|
+
], t.prototype, "_shouldDisplayLoader", 2);
|
|
80
|
+
t = s([
|
|
81
|
+
c("pkt-loader")
|
|
82
|
+
], t);
|
|
83
|
+
export {
|
|
84
|
+
t as P
|
|
85
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";const e=require("./element-r-PeQ419.cjs"),d=require("./class-map-Dzci3Pfe.cjs"),u=require("./state-B77EXPZ9.cjs"),p=require("./ref-BUWgvhgU.cjs"),h=require("./pkt-slot-controller-Oc32unDk.cjs");require("./icon-DcJIqTIY.cjs");var c=Object.defineProperty,y=Object.getOwnPropertyDescriptor,s=(o,t,r,i)=>{for(var a=i>1?void 0:i?y(t,r):t,l=o.length-1,n;l>=0;l--)(n=o[l])&&(a=(i?n(t,r,a):n(a))||a);return i&&a&&c(t,r,a),a};exports.PktLoader=class extends e.PktElement{constructor(){super(),this.defaultSlot=p.e(),this.delay=0,this.inline=!1,this.isLoading=!0,this.message=null,this.size="medium",this.variant="shapes",this._shouldDisplayLoader=!1,this.slotController=new h.PktSlotController(this,this.defaultSlot)}connectedCallback(){super.connectedCallback(),this._shouldDisplayLoader=this.delay===0,this.delay>0&&this.setupLoader()}updated(t){t.has("delay")&&this.setupLoader()}render(){const t=d.e({"pkt-loader":!0,[`pkt-loader--${this.inline?"inline":"box"}`]:!0,[`pkt-loader--${this.size}`]:!0}),r=d.e({"pkt-contents":!0,"pkt-hide":this.isLoading});return e.x`<div role="status" aria-live="polite" .aria-busy=${this.isLoading} class=${t}>
|
|
2
|
+
${this.isLoading&&this._shouldDisplayLoader?e.x`<div class="pkt-loader__spinner">
|
|
3
|
+
<pkt-icon
|
|
4
|
+
name=${this.getVariant(this.variant)}
|
|
5
|
+
path="https://punkt-cdn.oslo.kommune.no/latest/animations/"
|
|
6
|
+
class="pkt-loader__svg pkt-loader__${this.variant}"
|
|
7
|
+
></pkt-icon>
|
|
8
|
+
${this.message&&e.x`<p>${this.message}</p>`}
|
|
9
|
+
</div>`:e.E}
|
|
10
|
+
<div class=${r} ${p.n(this.defaultSlot)}></div>
|
|
11
|
+
</div>`}getVariant(t){switch(t){case"blue":return"spinner-blue";case"rainbow":return"spinner";default:return"loader"}}setupLoader(){this.delay>0&&(this._shouldDisplayLoader=!1,setTimeout(()=>{this._shouldDisplayLoader=!0,this.requestUpdate()},this.delay))}};s([e.n({type:Number})],exports.PktLoader.prototype,"delay",2);s([e.n({type:Boolean})],exports.PktLoader.prototype,"inline",2);s([e.n({type:Boolean})],exports.PktLoader.prototype,"isLoading",2);s([e.n({type:String})],exports.PktLoader.prototype,"message",2);s([e.n({type:String})],exports.PktLoader.prototype,"size",2);s([e.n({type:String})],exports.PktLoader.prototype,"variant",2);s([u.r()],exports.PktLoader.prototype,"_shouldDisplayLoader",2);exports.PktLoader=s([e.t("pkt-loader")],exports.PktLoader);
|
package/dist/loader.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";const s=require("./element-r-PeQ419.cjs"),b=require("./pkt-slot-controller-Oc32unDk.cjs"),c=require("./ref-BUWgvhgU.cjs"),d=require("./class-map-Dzci3Pfe.cjs"),k=require("./state-B77EXPZ9.cjs");require("./icon-DcJIqTIY.cjs");const u=require("./classutils-BwNK82ZQ.cjs"),m="pkt-messagebox",g=!0,h={onClose:{description:"React: Event som trigges når meldingsboksen lukkes"},"on-close":{description:"Vue: Event som trigges når meldingsboksen lukkes"}},f={title:{name:"Tittel",description:"Tittelen på meldingsboksen",type:"string"},skin:{name:"Utseende",description:"Velg farge på meldingsboksen",type:["beige","blue","red","green"],default:"beige"},compact:{name:"Kompakt",description:"Gjør meldingsboksen mindre",type:"boolean",default:!1},closable:{name:"Kan lukkes",description:"Viser lukkeknapp",type:"boolean",default:!1}},x={default:{description:"Innholdet i meldingsboksen"}},p={name:m,"css-class":"pkt-messagebox",isElement:g,events:h,props:f,slots:x};var v=Object.defineProperty,_=Object.getOwnPropertyDescriptor,o=(i,e,n,l)=>{for(var t=l>1?void 0:l?_(e,n):e,a=i.length-1,r;a>=0;a--)(r=i[a])&&(t=(l?r(e,n,t):r(t))||t);return l&&t&&v(e,n,t),t};exports.PktMessagebox=class extends s.PktElement{constructor(){super(),this.defaultSlot=c.e(),this.closable=p.props.closable.default,this.compact=p.props.compact.default,this.title="",this.skin=p.props.skin.default,this._isClosed=!1,this.close=e=>{this._isClosed=!0,this.dispatchEvent(new CustomEvent("close",{detail:{origin:e},bubbles:!0})),this.dispatchEvent(new CustomEvent("on-close",{detail:{origin:e},bubbles:!0}))},this.slotController=new b.PktSlotController(this,this.defaultSlot),this._isClosed=!1}updated(e){super.updated(e),e.has("_isClosed")&&u.updateClassAttribute(this,"pkt-hide",this._isClosed)}render(){const e={"pkt-messagebox":!0,"pkt-messagebox--compact":this.compact,[`pkt-messagebox--${this.skin}`]:this.skin,"pkt-messagebox--closable":this.closable,"pkt-hide":this._isClosed};return s.x`<div class=${d.e(e)}>
|
|
2
|
+
${this.closable?s.x`<div class="pkt-messagebox__close">
|
|
3
|
+
<button
|
|
4
|
+
@click=${this.close}
|
|
5
|
+
class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only"
|
|
6
|
+
>
|
|
7
|
+
<pkt-icon name="close" class="pkt-link__icon"></pkt-icon>
|
|
8
|
+
</button>
|
|
9
|
+
</div>`:s.E}
|
|
10
|
+
${this.title?s.x`<div class="pkt-messagebox__title">${this.title}</div>`:s.E}
|
|
11
|
+
<div class="pkt-messagebox__text" ${c.n(this.defaultSlot)}></div>
|
|
12
|
+
</div>`}};o([s.n({type:Boolean,reflect:!0})],exports.PktMessagebox.prototype,"closable",2);o([s.n({type:Boolean,reflect:!0})],exports.PktMessagebox.prototype,"compact",2);o([s.n({type:String,reflect:!0})],exports.PktMessagebox.prototype,"title",2);o([s.n({type:String,reflect:!0})],exports.PktMessagebox.prototype,"skin",2);o([k.r()],exports.PktMessagebox.prototype,"_isClosed",2);exports.PktMessagebox=o([s.t("pkt-messagebox")],exports.PktMessagebox);
|
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
import { P as b, x as c, E as
|
|
2
|
-
import { P as
|
|
3
|
-
import { e as
|
|
4
|
-
import { e as
|
|
1
|
+
import { P as b, x as c, E as m, n, a as u } from "./element-D_ZgQsSr.js";
|
|
2
|
+
import { P as k } from "./pkt-slot-controller-Clbye6cM.js";
|
|
3
|
+
import { e as h, n as f } from "./ref-BSGI8ogR.js";
|
|
4
|
+
import { e as g } from "./class-map-BYCG9U47.js";
|
|
5
5
|
import { r as v } from "./state-DuS4ffEQ.js";
|
|
6
6
|
import "./icon-BBFK-d-X.js";
|
|
7
|
-
|
|
7
|
+
import { u as _ } from "./classutils-RQs1k6D9.js";
|
|
8
|
+
const x = "pkt-messagebox", y = !0, C = {
|
|
8
9
|
onClose: {
|
|
9
10
|
description: "React: Event som trigges når meldingsboksen lukkes"
|
|
10
11
|
},
|
|
11
12
|
"on-close": {
|
|
12
13
|
description: "Vue: Event som trigges når meldingsboksen lukkes"
|
|
13
14
|
}
|
|
14
|
-
},
|
|
15
|
+
}, E = {
|
|
15
16
|
title: {
|
|
16
17
|
name: "Tittel",
|
|
17
18
|
description: "Tittelen på meldingsboksen",
|
|
@@ -40,29 +41,34 @@ const _ = "pkt-messagebox", x = !0, y = {
|
|
|
40
41
|
type: "boolean",
|
|
41
42
|
default: !1
|
|
42
43
|
}
|
|
43
|
-
},
|
|
44
|
+
}, P = {
|
|
44
45
|
default: {
|
|
45
46
|
description: "Innholdet i meldingsboksen"
|
|
46
47
|
}
|
|
47
|
-
},
|
|
48
|
-
name:
|
|
48
|
+
}, d = {
|
|
49
|
+
name: x,
|
|
49
50
|
"css-class": "pkt-messagebox",
|
|
50
|
-
isElement:
|
|
51
|
-
events:
|
|
52
|
-
props:
|
|
53
|
-
slots:
|
|
51
|
+
isElement: y,
|
|
52
|
+
events: C,
|
|
53
|
+
props: E,
|
|
54
|
+
slots: P
|
|
54
55
|
};
|
|
55
|
-
var
|
|
56
|
-
for (var t =
|
|
57
|
-
(
|
|
58
|
-
return
|
|
56
|
+
var $ = Object.defineProperty, S = Object.getOwnPropertyDescriptor, o = (e, i, p, l) => {
|
|
57
|
+
for (var t = l > 1 ? void 0 : l ? S(i, p) : i, a = e.length - 1, r; a >= 0; a--)
|
|
58
|
+
(r = e[a]) && (t = (l ? r(i, p, t) : r(t)) || t);
|
|
59
|
+
return l && t && $(i, p, t), t;
|
|
59
60
|
};
|
|
60
61
|
let s = class extends b {
|
|
61
62
|
constructor() {
|
|
62
|
-
super(), this.defaultSlot =
|
|
63
|
+
super(), this.defaultSlot = h(), this.closable = d.props.closable.default, this.compact = d.props.compact.default, this.title = "", this.skin = d.props.skin.default, this._isClosed = !1, this.close = (e) => {
|
|
63
64
|
this._isClosed = !0, this.dispatchEvent(new CustomEvent("close", { detail: { origin: e }, bubbles: !0 })), this.dispatchEvent(new CustomEvent("on-close", { detail: { origin: e }, bubbles: !0 }));
|
|
64
|
-
}, this.slotController = new
|
|
65
|
+
}, this.slotController = new k(this, this.defaultSlot), this._isClosed = !1;
|
|
66
|
+
}
|
|
67
|
+
// Lifecycle
|
|
68
|
+
updated(e) {
|
|
69
|
+
super.updated(e), e.has("_isClosed") && _(this, "pkt-hide", this._isClosed);
|
|
65
70
|
}
|
|
71
|
+
// Render
|
|
66
72
|
render() {
|
|
67
73
|
const e = {
|
|
68
74
|
"pkt-messagebox": !0,
|
|
@@ -71,7 +77,7 @@ let s = class extends b {
|
|
|
71
77
|
"pkt-messagebox--closable": this.closable,
|
|
72
78
|
"pkt-hide": this._isClosed
|
|
73
79
|
};
|
|
74
|
-
return c`<div class=${
|
|
80
|
+
return c`<div class=${g(e)}>
|
|
75
81
|
${this.closable ? c`<div class="pkt-messagebox__close">
|
|
76
82
|
<button
|
|
77
83
|
@click=${this.close}
|
|
@@ -79,8 +85,8 @@ let s = class extends b {
|
|
|
79
85
|
>
|
|
80
86
|
<pkt-icon name="close" class="pkt-link__icon"></pkt-icon>
|
|
81
87
|
</button>
|
|
82
|
-
</div>` :
|
|
83
|
-
${this.title ? c`<div class="pkt-messagebox__title">${this.title}</div>` :
|
|
88
|
+
</div>` : m}
|
|
89
|
+
${this.title ? c`<div class="pkt-messagebox__title">${this.title}</div>` : m}
|
|
84
90
|
<div class="pkt-messagebox__text" ${f(this.defaultSlot)}></div>
|
|
85
91
|
</div>`;
|
|
86
92
|
}
|
|
@@ -101,7 +107,7 @@ o([
|
|
|
101
107
|
v()
|
|
102
108
|
], s.prototype, "_isClosed", 2);
|
|
103
109
|
s = o([
|
|
104
|
-
|
|
110
|
+
u("pkt-messagebox")
|
|
105
111
|
], s);
|
|
106
112
|
export {
|
|
107
113
|
s as P
|
|
@@ -12,13 +12,14 @@
|
|
|
12
12
|
${this.headingText}
|
|
13
13
|
</h1>`:s.E}
|
|
14
14
|
${this.hideCloseButton?s.E:s.x`<div class="${d.e(i)}">
|
|
15
|
-
<button
|
|
15
|
+
<pkt-button
|
|
16
16
|
@click=${p=>this.close(p)}
|
|
17
17
|
class=${d.e(a)}
|
|
18
18
|
aria-label="close"
|
|
19
|
+
iconname="close"
|
|
20
|
+
variant="icon-only"
|
|
19
21
|
>
|
|
20
|
-
|
|
21
|
-
</button>
|
|
22
|
+
</pkt-button>
|
|
22
23
|
</div>`}
|
|
23
24
|
</div>
|
|
24
25
|
<div class="pkt-modal__container">
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { e as c } from "./class-map-BYCG9U47.js";
|
|
2
|
-
import { P as f, x as p, E as k, n as
|
|
2
|
+
import { P as f, x as p, E as k, n as r, a as g } from "./element-D_ZgQsSr.js";
|
|
3
3
|
import { r as v } from "./state-DuS4ffEQ.js";
|
|
4
4
|
import { P as b } from "./pkt-slot-controller-Clbye6cM.js";
|
|
5
5
|
import { e as m, n as h } from "./ref-BSGI8ogR.js";
|
|
@@ -60,28 +60,28 @@ const y = "pkt-modal", _ = !0, C = {
|
|
|
60
60
|
props: B,
|
|
61
61
|
slots: w
|
|
62
62
|
};
|
|
63
|
-
var E = Object.defineProperty, S = Object.getOwnPropertyDescriptor, l = (t, e, o,
|
|
64
|
-
for (var
|
|
65
|
-
(a = t[
|
|
66
|
-
return
|
|
63
|
+
var E = Object.defineProperty, S = Object.getOwnPropertyDescriptor, l = (t, e, o, n) => {
|
|
64
|
+
for (var s = n > 1 ? void 0 : n ? S(e, o) : e, d = t.length - 1, a; d >= 0; d--)
|
|
65
|
+
(a = t[d]) && (s = (n ? a(e, o, s) : a(s)) || s);
|
|
66
|
+
return n && s && E(e, o, s), s;
|
|
67
67
|
};
|
|
68
68
|
let i = class extends f {
|
|
69
69
|
constructor() {
|
|
70
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 = m(), this.dialogRef = m(), this._isOpen = !1, this.close = (t, e = !1) => {
|
|
71
|
-
var
|
|
71
|
+
var n;
|
|
72
72
|
if (!this._isOpen) return;
|
|
73
73
|
this._isOpen = !1, document.body.classList.remove("pkt-modal--open");
|
|
74
74
|
const o = document.activeElement;
|
|
75
75
|
o && !this.isElementInViewport(o) && o.scrollIntoView({ behavior: "smooth", block: "nearest" }), this.dispatchEvent(
|
|
76
76
|
new CustomEvent("close", { detail: { origin: t }, bubbles: !0, composed: !0 })
|
|
77
|
-
), e || (
|
|
77
|
+
), e || (n = this.dialogRef.value) == null || n.close(), this.requestUpdate();
|
|
78
78
|
}, this.showModal = (t) => {
|
|
79
79
|
var o;
|
|
80
80
|
this._isOpen = !0, (o = this.dialogRef.value) == null || o.showModal();
|
|
81
81
|
const e = document.querySelector(".pkt-modal");
|
|
82
82
|
requestAnimationFrame(() => {
|
|
83
|
-
var
|
|
84
|
-
this.dialogRef.value && ((
|
|
83
|
+
var n;
|
|
84
|
+
this.dialogRef.value && ((n = this.dialogRef.value) == null || n.focus());
|
|
85
85
|
}), e && document.body.classList.add("pkt-modal--open"), this.dispatchEvent(
|
|
86
86
|
new CustomEvent("showModal", { detail: { origin: t }, bubbles: !0, composed: !0 })
|
|
87
87
|
), this.requestUpdate();
|
|
@@ -117,12 +117,12 @@ let i = class extends f {
|
|
|
117
117
|
}, o = {
|
|
118
118
|
"pkt-modal__content": !0,
|
|
119
119
|
"pkt-txt-18-light": !0
|
|
120
|
-
},
|
|
120
|
+
}, n = this.closeButtonSkin === "blue", s = {
|
|
121
121
|
"pkt-modal__closeButton": !0,
|
|
122
122
|
[`pkt-modal__closeButton--${this.closeButtonSkin}`]: !0
|
|
123
|
-
},
|
|
123
|
+
}, d = {
|
|
124
124
|
"pkt-btn": !0,
|
|
125
|
-
[`pkt-btn--${
|
|
125
|
+
[`pkt-btn--${n ? "tertiary" : "primary"}`]: !0,
|
|
126
126
|
"pkt-btn--icon-only": !0,
|
|
127
127
|
"pkt-btn--medium": !0
|
|
128
128
|
};
|
|
@@ -139,14 +139,15 @@ let i = class extends f {
|
|
|
139
139
|
${this.headingText ? p`<h1 id="pkt-modal__headingText" class=${c(e)}>
|
|
140
140
|
${this.headingText}
|
|
141
141
|
</h1>` : k}
|
|
142
|
-
${this.hideCloseButton ? k : p`<div class="${c(
|
|
143
|
-
<button
|
|
142
|
+
${this.hideCloseButton ? k : p`<div class="${c(s)}">
|
|
143
|
+
<pkt-button
|
|
144
144
|
@click=${(a) => this.close(a)}
|
|
145
|
-
class=${c(
|
|
145
|
+
class=${c(d)}
|
|
146
146
|
aria-label="close"
|
|
147
|
+
iconname="close"
|
|
148
|
+
variant="icon-only"
|
|
147
149
|
>
|
|
148
|
-
|
|
149
|
-
</button>
|
|
150
|
+
</pkt-button>
|
|
150
151
|
</div>`}
|
|
151
152
|
</div>
|
|
152
153
|
<div class="pkt-modal__container">
|
|
@@ -161,22 +162,22 @@ let i = class extends f {
|
|
|
161
162
|
}
|
|
162
163
|
};
|
|
163
164
|
l([
|
|
164
|
-
|
|
165
|
+
r({ type: String, reflect: !0 })
|
|
165
166
|
], i.prototype, "headingText", 2);
|
|
166
167
|
l([
|
|
167
|
-
|
|
168
|
+
r({ type: Boolean, reflect: !0 })
|
|
168
169
|
], i.prototype, "removePadding", 2);
|
|
169
170
|
l([
|
|
170
|
-
|
|
171
|
+
r({ type: Boolean, reflect: !0 })
|
|
171
172
|
], i.prototype, "hideCloseButton", 2);
|
|
172
173
|
l([
|
|
173
|
-
|
|
174
|
+
r({ type: Boolean, reflect: !0 })
|
|
174
175
|
], i.prototype, "closeOnBackdropClick", 2);
|
|
175
176
|
l([
|
|
176
|
-
|
|
177
|
+
r({ type: String, reflect: !0 })
|
|
177
178
|
], i.prototype, "closeButtonSkin", 2);
|
|
178
179
|
l([
|
|
179
|
-
|
|
180
|
+
r({ type: String, reflect: !0 })
|
|
180
181
|
], i.prototype, "size", 2);
|
|
181
182
|
l([
|
|
182
183
|
v()
|
package/dist/pkt-alert.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./alert-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./alert-CP5oN7df.cjs"),t=e.PktAlert;Object.defineProperty(exports,"PktAlert",{enumerable:!0,get:()=>e.PktAlert});exports.default=t;
|
package/dist/pkt-alert.js
CHANGED
package/dist/pkt-index.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("./alert-
|
|
2
|
-
<div class="${
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("./alert-CP5oN7df.cjs"),d=require("./button-DPb5WL9h.cjs"),c=require("./calendar-DUkAC9Hx.cjs"),P=require("./card-Bxe-jQD_.cjs"),k=require("./checkbox-CDMUepTW.cjs"),t=require("./element-r-PeQ419.cjs"),b=require("./pkt-slot-controller-Oc32unDk.cjs"),i=require("./ref-BUWgvhgU.cjs"),m=require("./class-map-Dzci3Pfe.cjs"),g=require("./datepicker-D6ifQ2so.cjs"),h=require("./helptext-C0mrdhRi.cjs"),f=require("./icon-DcJIqTIY.cjs"),y=require("./input-wrapper-Dqj4uers.cjs"),x=require("./link-C_bwx1Ml.cjs"),O=require("./linkcard-C6mZOE0R.cjs"),j=require("./loader-DQV1hMM3.cjs"),q=require("./messagebox-BSyLVNas.cjs"),C=require("./modal-CblCiNUi.cjs"),v=require("./progressbar-C_q48_qh.cjs"),S=require("./radiobutton-3e105CXX.cjs"),$=require("./tag-BMyii4Da.cjs"),_=require("./textarea-DxpzI67n.cjs"),L=require("./textinput-BRupcl9v.cjs"),T=require("./select-DJu4Wr1y.cjs");var M=Object.defineProperty,B=Object.getOwnPropertyDescriptor,o=(a,e,r,s)=>{for(var n=s>1?void 0:s?B(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&&M(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 b.PktSlotController(this,this.defaultSlot,this.namedSlot)}connectedCallback(){this.strings.length&&this.strings.forEach(e=>{this._list.push(e.toUpperCase())}),super.connectedCallback()}render(){const e={"pkt-component":!0,"pkt-component--has-list":this.strings.length>0,"pkt-darkmode":this.darkmode};return t.x`
|
|
2
|
+
<div class="${m.e(e)}">
|
|
3
3
|
<h1 class="pkt-txt-28">${this.string}</h1>
|
|
4
4
|
|
|
5
5
|
<h2 class="pkt-txt-22">Innhold fra attributter og funksjoner</h2>
|
|
@@ -26,4 +26,4 @@
|
|
|
26
26
|
<ul>
|
|
27
27
|
${e.map(r=>t.x`<li>${r}</li>`)}
|
|
28
28
|
</ul>
|
|
29
|
-
`}doStuff(e){return e.reverse()}handleGreeting(){this.dispatchEvent(new CustomEvent("pkt-greeting",{detail:"Hei på deg!"}))}};o([t.n({type:String})],exports.PktComponent.prototype,"string",2);o([t.n({converter:c.csvToArray})],exports.PktComponent.prototype,"strings",2);o([t.n({type:Boolean})],exports.PktComponent.prototype,"darkmode",2);o([t.n({type:Array})],exports.PktComponent.prototype,"_list",2);exports.PktComponent=o([t.t("pkt-component")],exports.PktComponent);Object.defineProperty(exports,"PktAlert",{enumerable:!0,get:()=>p.PktAlert});Object.defineProperty(exports,"PktButton",{enumerable:!0,get:()=>d.PktButton});Object.defineProperty(exports,"PktCalendar",{enumerable:!0,get:()=>c.PktCalendar});Object.defineProperty(exports,"PktCard",{enumerable:!0,get:()=>
|
|
29
|
+
`}doStuff(e){return e.reverse()}handleGreeting(){this.dispatchEvent(new CustomEvent("pkt-greeting",{detail:"Hei på deg!"}))}};o([t.n({type:String})],exports.PktComponent.prototype,"string",2);o([t.n({converter:c.csvToArray})],exports.PktComponent.prototype,"strings",2);o([t.n({type:Boolean})],exports.PktComponent.prototype,"darkmode",2);o([t.n({type:Array})],exports.PktComponent.prototype,"_list",2);exports.PktComponent=o([t.t("pkt-component")],exports.PktComponent);Object.defineProperty(exports,"PktAlert",{enumerable:!0,get:()=>p.PktAlert});Object.defineProperty(exports,"PktButton",{enumerable:!0,get:()=>d.PktButton});Object.defineProperty(exports,"PktCalendar",{enumerable:!0,get:()=>c.PktCalendar});Object.defineProperty(exports,"PktCard",{enumerable:!0,get:()=>P.PktCard});Object.defineProperty(exports,"PktCheckbox",{enumerable:!0,get:()=>k.PktCheckbox});Object.defineProperty(exports,"PktDatepicker",{enumerable:!0,get:()=>g.PktDatepicker});Object.defineProperty(exports,"PktHelptext",{enumerable:!0,get:()=>h.PktHelptext});Object.defineProperty(exports,"PktIcon",{enumerable:!0,get:()=>f.PktIcon});Object.defineProperty(exports,"PktInputWrapper",{enumerable:!0,get:()=>y.PktInputWrapper});Object.defineProperty(exports,"PktLink",{enumerable:!0,get:()=>x.PktLink});Object.defineProperty(exports,"PktLinkCard",{enumerable:!0,get:()=>O.PktLinkCard});Object.defineProperty(exports,"PktLoader",{enumerable:!0,get:()=>j.PktLoader});Object.defineProperty(exports,"PktMessagebox",{enumerable:!0,get:()=>q.PktMessagebox});Object.defineProperty(exports,"PktModal",{enumerable:!0,get:()=>C.PktModal});Object.defineProperty(exports,"PktProgressbar",{enumerable:!0,get:()=>v.PktProgressbar});Object.defineProperty(exports,"PktRadioButton",{enumerable:!0,get:()=>S.PktRadioButton});Object.defineProperty(exports,"PktTag",{enumerable:!0,get:()=>$.PktTag});Object.defineProperty(exports,"PktTextarea",{enumerable:!0,get:()=>_.PktTextarea});Object.defineProperty(exports,"PktTextinput",{enumerable:!0,get:()=>L.PktTextinput});Object.defineProperty(exports,"PktSelect",{enumerable:!0,get:()=>T.PktSelect});
|
package/dist/pkt-index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { P as w } from "./alert-
|
|
1
|
+
import { P as w } from "./alert-CugVni4g.js";
|
|
2
2
|
import { P as O } from "./button-BnmFhao8.js";
|
|
3
3
|
import { c as d } from "./calendar-DevhqUoj.js";
|
|
4
4
|
import { P as j } from "./calendar-DevhqUoj.js";
|
|
@@ -6,7 +6,7 @@ import { P as B } from "./card-Db2Ex1cH.js";
|
|
|
6
6
|
import { P as I } from "./checkbox-Dw2CX5zY.js";
|
|
7
7
|
import { P as f, x as m, t as k, n, a as c } from "./element-D_ZgQsSr.js";
|
|
8
8
|
import { P as x } from "./pkt-slot-controller-Clbye6cM.js";
|
|
9
|
-
import { e as
|
|
9
|
+
import { e as P, n as h } from "./ref-BSGI8ogR.js";
|
|
10
10
|
import { e as u } from "./class-map-BYCG9U47.js";
|
|
11
11
|
import { P as G } from "./datepicker-gZ_eVIyS.js";
|
|
12
12
|
import { P as M } from "./helptext-RPq_TKzJ.js";
|
|
@@ -14,14 +14,15 @@ import { P as N } from "./icon-BBFK-d-X.js";
|
|
|
14
14
|
import { P as W } from "./input-wrapper-D-pEAZaj.js";
|
|
15
15
|
import { P as z } from "./link-CDkU7zsB.js";
|
|
16
16
|
import { P as J } from "./linkcard-Dr5iKZrV.js";
|
|
17
|
-
import { P as V } from "./
|
|
18
|
-
import { P as Y } from "./
|
|
19
|
-
import { P as tt } from "./
|
|
20
|
-
import { P as rt } from "./
|
|
21
|
-
import { P as ot } from "./
|
|
22
|
-
import { P as nt } from "./
|
|
23
|
-
import { P as pt } from "./
|
|
24
|
-
import { P as mt } from "./
|
|
17
|
+
import { P as V } from "./loader-ChVEsONa.js";
|
|
18
|
+
import { P as Y } from "./messagebox-Di7LUz4C.js";
|
|
19
|
+
import { P as tt } from "./modal-DZUQb_yG.js";
|
|
20
|
+
import { P as rt } from "./progressbar-CuZj4FWi.js";
|
|
21
|
+
import { P as ot } from "./radiobutton-CcZ2-z8q.js";
|
|
22
|
+
import { P as nt } from "./tag-DVk69673.js";
|
|
23
|
+
import { P as pt } from "./textarea-C8-lnWwu.js";
|
|
24
|
+
import { P as mt } from "./textinput-DRkv93vp.js";
|
|
25
|
+
import { P as ht } from "./select-CnizDIYN.js";
|
|
25
26
|
var g = Object.defineProperty, v = Object.getOwnPropertyDescriptor, o = (t, e, i, a) => {
|
|
26
27
|
for (var r = a > 1 ? void 0 : a ? v(e, i) : e, p = t.length - 1, l; p >= 0; p--)
|
|
27
28
|
(l = t[p]) && (r = (a ? l(e, i, r) : l(r)) || r);
|
|
@@ -29,7 +30,7 @@ var g = Object.defineProperty, v = Object.getOwnPropertyDescriptor, o = (t, e, i
|
|
|
29
30
|
};
|
|
30
31
|
let s = class extends f {
|
|
31
32
|
constructor() {
|
|
32
|
-
super(), this.string = "", this.strings = [], this.darkmode = !1, this._list = [], this.defaultSlot =
|
|
33
|
+
super(), this.string = "", this.strings = [], this.darkmode = !1, this._list = [], this.defaultSlot = P(), this.namedSlot = P(), this.slotController = new x(this, this.defaultSlot, this.namedSlot);
|
|
33
34
|
}
|
|
34
35
|
/**
|
|
35
36
|
* Runs on mount, used to set up various values and whatever you need to run
|
|
@@ -57,11 +58,11 @@ let s = class extends f {
|
|
|
57
58
|
<div>${this.renderList(this.doStuff(this._list))}</div>
|
|
58
59
|
|
|
59
60
|
<h2 class="pkt-txt-22">Slot</h2>
|
|
60
|
-
<div ${
|
|
61
|
+
<div ${h(this.defaultSlot)}>defaultSlotRef</div>
|
|
61
62
|
<h2 class="pkt-txt-22">Named slot</h2>
|
|
62
63
|
<select
|
|
63
64
|
name="named-slot"
|
|
64
|
-
${
|
|
65
|
+
${h(this.namedSlot)}
|
|
65
66
|
@change=${(e) => alert(e.target.value)}
|
|
66
67
|
>
|
|
67
68
|
namedSlotRef
|
|
@@ -126,12 +127,13 @@ export {
|
|
|
126
127
|
W as PktInputWrapper,
|
|
127
128
|
z as PktLink,
|
|
128
129
|
J as PktLinkCard,
|
|
129
|
-
V as
|
|
130
|
-
Y as
|
|
131
|
-
tt as
|
|
132
|
-
rt as
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
nt as
|
|
136
|
-
pt as
|
|
130
|
+
V as PktLoader,
|
|
131
|
+
Y as PktMessagebox,
|
|
132
|
+
tt as PktModal,
|
|
133
|
+
rt as PktProgressbar,
|
|
134
|
+
ot as PktRadioButton,
|
|
135
|
+
ht as PktSelect,
|
|
136
|
+
nt as PktTag,
|
|
137
|
+
pt as PktTextarea,
|
|
138
|
+
mt as PktTextinput
|
|
137
139
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./loader-DQV1hMM3.cjs"),t=e.PktLoader;Object.defineProperty(exports,"PktLoader",{enumerable:!0,get:()=>e.PktLoader});exports.default=t;
|
package/dist/pkt-messagebox.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./messagebox-
|
|
1
|
+
"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./messagebox-BSyLVNas.cjs"),t=e.PktMessagebox;Object.defineProperty(exports,"PktMessagebox",{enumerable:!0,get:()=>e.PktMessagebox});exports.default=t;
|
package/dist/pkt-messagebox.js
CHANGED
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-CblCiNUi.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.29.
|
|
3
|
+
"version": "12.29.3",
|
|
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",
|
|
@@ -57,5 +57,5 @@
|
|
|
57
57
|
"url": "https://github.com/oslokommune/punkt/issues"
|
|
58
58
|
},
|
|
59
59
|
"license": "MIT",
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "59a0d70f10e765285167342a739bbe6b126a9882"
|
|
61
61
|
}
|
|
@@ -5,7 +5,7 @@ import { PktElement } from '@/base-elements/element'
|
|
|
5
5
|
import { PktSlotController } from '@/controllers/pkt-slot-controller'
|
|
6
6
|
import { ref, createRef, Ref } from 'lit/directives/ref.js'
|
|
7
7
|
import { TAriaLive } from '@/types/aria'
|
|
8
|
-
|
|
8
|
+
import { updateClassAttribute } from '@/utils/classutils'
|
|
9
9
|
import specs from 'componentSpecs/alert.json'
|
|
10
10
|
|
|
11
11
|
import '@/components/icon'
|
|
@@ -16,13 +16,13 @@ export interface IPktAlert {
|
|
|
16
16
|
skin?: TAlertSkin
|
|
17
17
|
closeAlert?: boolean
|
|
18
18
|
title?: string
|
|
19
|
-
date?: string
|
|
20
|
-
ariaLive?: TAriaLive
|
|
21
|
-
'aria-live'?: TAriaLive
|
|
19
|
+
date?: string | null
|
|
20
|
+
ariaLive?: TAriaLive | null
|
|
21
|
+
'aria-live'?: TAriaLive | null
|
|
22
22
|
compact?: boolean
|
|
23
23
|
}
|
|
24
24
|
@customElement('pkt-alert')
|
|
25
|
-
export class PktAlert extends PktElement {
|
|
25
|
+
export class PktAlert extends PktElement implements IPktAlert {
|
|
26
26
|
defaultSlot: Ref<HTMLElement> = createRef()
|
|
27
27
|
|
|
28
28
|
constructor() {
|
|
@@ -31,27 +31,20 @@ export class PktAlert extends PktElement {
|
|
|
31
31
|
this._isClosed = false
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
+
// Properties
|
|
35
|
+
|
|
34
36
|
@property({ type: Boolean, reflect: false }) compact = specs.props.compact.default
|
|
35
37
|
@property({ type: String, reflect: true }) title: string = ''
|
|
36
38
|
@property({ type: String, reflect: true }) skin: TAlertSkin = specs.props.skin
|
|
37
39
|
.default as TAlertSkin
|
|
38
40
|
@property({ type: String }) ariaLive: TAriaLive = specs.props.ariaLive.default as TAriaLive
|
|
39
|
-
@property({ type: String, reflect: true }) 'aria-live': TAriaLive = null
|
|
41
|
+
@property({ type: String, reflect: true }) 'aria-live': TAriaLive | null = null
|
|
40
42
|
@property({ type: Boolean, reflect: true }) closeAlert = specs.props.closeAlert.default
|
|
41
43
|
@property({ type: String, reflect: true }) date: string | null = null
|
|
42
44
|
|
|
43
45
|
@state() _isClosed: boolean = false
|
|
44
46
|
|
|
45
|
-
|
|
46
|
-
this._isClosed = true
|
|
47
|
-
this.dispatchEvent(
|
|
48
|
-
new CustomEvent('close', { detail: { origin: event }, bubbles: true, composed: true }),
|
|
49
|
-
)
|
|
50
|
-
// Historical support of old Vue implementations…
|
|
51
|
-
this.dispatchEvent(
|
|
52
|
-
new CustomEvent('on-close', { detail: { origin: event }, bubbles: true, composed: true }),
|
|
53
|
-
)
|
|
54
|
-
}
|
|
47
|
+
// Lifecycle
|
|
55
48
|
|
|
56
49
|
connectedCallback(): void {
|
|
57
50
|
super.connectedCallback()
|
|
@@ -70,8 +63,13 @@ export class PktAlert extends PktElement {
|
|
|
70
63
|
if (_changedProperties.has('ariaLive')) {
|
|
71
64
|
this['aria-live'] = this.ariaLive
|
|
72
65
|
}
|
|
66
|
+
if (_changedProperties.has('_isClosed')) {
|
|
67
|
+
updateClassAttribute(this, 'pkt-hide', this._isClosed)
|
|
68
|
+
}
|
|
73
69
|
}
|
|
74
70
|
|
|
71
|
+
// Render
|
|
72
|
+
|
|
75
73
|
render() {
|
|
76
74
|
const classes = {
|
|
77
75
|
'pkt-alert': true,
|
|
@@ -112,4 +110,17 @@ export class PktAlert extends PktElement {
|
|
|
112
110
|
</div>
|
|
113
111
|
`
|
|
114
112
|
}
|
|
113
|
+
|
|
114
|
+
// Methods
|
|
115
|
+
|
|
116
|
+
private close = (event: MouseEvent) => {
|
|
117
|
+
this._isClosed = true
|
|
118
|
+
this.dispatchEvent(
|
|
119
|
+
new CustomEvent('close', { detail: { origin: event }, bubbles: true, composed: true }),
|
|
120
|
+
)
|
|
121
|
+
// Historical support of old Vue implementations…
|
|
122
|
+
this.dispatchEvent(
|
|
123
|
+
new CustomEvent('on-close', { detail: { origin: event }, bubbles: true, composed: true }),
|
|
124
|
+
)
|
|
125
|
+
}
|
|
115
126
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { PktElement } from '@/base-elements/element'
|
|
2
2
|
import { PktSlotController } from '@/controllers/pkt-slot-controller'
|
|
3
|
-
import { html, nothing } from 'lit'
|
|
3
|
+
import { html, nothing, PropertyValues } from 'lit'
|
|
4
4
|
import { property, customElement } from 'lit/decorators.js'
|
|
5
5
|
import { createRef, Ref, ref } from 'lit/directives/ref.js'
|
|
6
6
|
|
|
@@ -80,8 +80,8 @@ export class PktButton extends PktElement<IPktButton> implements IPktButton {
|
|
|
80
80
|
this.removeEventListener('keydown', this.handleKeydown as EventListener)
|
|
81
81
|
}
|
|
82
82
|
|
|
83
|
-
updated(
|
|
84
|
-
super.updated(
|
|
83
|
+
protected updated(_changedProperties: PropertyValues): void {
|
|
84
|
+
super.updated(_changedProperties)
|
|
85
85
|
|
|
86
86
|
this.setAttribute('role', 'button')
|
|
87
87
|
|
|
@@ -100,7 +100,6 @@ export class PktButton extends PktElement<IPktButton> implements IPktButton {
|
|
|
100
100
|
this.setAttribute('aria-disabled', 'false')
|
|
101
101
|
}
|
|
102
102
|
}
|
|
103
|
-
|
|
104
103
|
if (this.isLoading) {
|
|
105
104
|
if (this.getAttribute('aria-busy') !== 'true') {
|
|
106
105
|
this.setAttribute('aria-busy', 'true')
|
package/src/components/index.ts
CHANGED
|
@@ -11,6 +11,7 @@ export { PktIcon } from '@/components/icon'
|
|
|
11
11
|
export { PktInputWrapper } from '@/components/input-wrapper'
|
|
12
12
|
export { PktLink } from '@/components/link'
|
|
13
13
|
export { PktLinkCard } from '@/components/linkcard'
|
|
14
|
+
export { PktLoader } from '@/components/loader'
|
|
14
15
|
export { PktMessagebox } from '@/components/messagebox'
|
|
15
16
|
export { PktModal } from '@/components/modal'
|
|
16
17
|
export { PktProgressbar } from '@/components/progressbar'
|
|
@@ -20,7 +21,8 @@ export { PktTextarea } from '@/components/textarea'
|
|
|
20
21
|
export { PktTextinput } from '@/components/textinput'
|
|
21
22
|
export { PktSelect } from '@/components/select'
|
|
22
23
|
|
|
23
|
-
// Export types
|
|
24
|
+
// Export component types
|
|
25
|
+
|
|
24
26
|
|
|
25
27
|
export type {
|
|
26
28
|
IPktButton,
|
|
@@ -33,6 +35,7 @@ export type {
|
|
|
33
35
|
TPktButtonType,
|
|
34
36
|
} from '@/components/button'
|
|
35
37
|
|
|
38
|
+
|
|
36
39
|
export type {
|
|
37
40
|
IPktProgressbar,
|
|
38
41
|
TProgressbarRole,
|
|
@@ -45,3 +48,5 @@ export type {
|
|
|
45
48
|
export type { TTagSkin, TTagType } from '@/components/tag'
|
|
46
49
|
|
|
47
50
|
export type { TSelectOption } from '@/components/select'
|
|
51
|
+
|
|
52
|
+
export type { IPktLoader, TPktLoaderVariant } from '@/components/loader'
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { PktElement } from '@/base-elements/element'
|
|
2
|
+
import { classMap } from 'lit/directives/class-map.js'
|
|
3
|
+
import { customElement, property, state } from 'lit/decorators.js'
|
|
4
|
+
import { createRef, ref, Ref } from 'lit/directives/ref.js'
|
|
5
|
+
import { html, nothing } from 'lit'
|
|
6
|
+
import { PktSlotController } from '@/controllers/pkt-slot-controller'
|
|
7
|
+
import { TPktSize } from '@/types/size'
|
|
8
|
+
import '@/components/icon'
|
|
9
|
+
|
|
10
|
+
export type TPktLoaderVariant = 'blue' | 'rainbow' | 'shapes'
|
|
11
|
+
|
|
12
|
+
export interface IPktLoader {
|
|
13
|
+
/**
|
|
14
|
+
* The `delay` prop controls how much time the loading should be given before the loader is displayed.
|
|
15
|
+
* This is handy for situations where the load time might be so short that loader is not necessary.
|
|
16
|
+
* Delay time is in milliseconds.
|
|
17
|
+
*/
|
|
18
|
+
delay?: number
|
|
19
|
+
/**
|
|
20
|
+
* The `inline` prop decides whether the loader should be displayed inline or not.
|
|
21
|
+
*/
|
|
22
|
+
inline?: boolean
|
|
23
|
+
/**
|
|
24
|
+
* The boolean 'isLoading' decides whether the loader or the children will be displayed.
|
|
25
|
+
* If set to false, the children will be displayed.
|
|
26
|
+
*/
|
|
27
|
+
isLoading?: boolean
|
|
28
|
+
/**
|
|
29
|
+
* The message to display when the loader is loading.
|
|
30
|
+
*/
|
|
31
|
+
message?: string | null
|
|
32
|
+
/**
|
|
33
|
+
* The size of the loader. Default is "medium".
|
|
34
|
+
*/
|
|
35
|
+
size?: TPktSize
|
|
36
|
+
/**
|
|
37
|
+
* The variant of the loader. Default is "shapes" which is the OSLO wave loader.
|
|
38
|
+
* Other variants are "blue" and "rainbow" which are spinner variants.
|
|
39
|
+
*/
|
|
40
|
+
variant?: TPktLoaderVariant
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
@customElement('pkt-loader')
|
|
44
|
+
export class PktLoader extends PktElement implements IPktLoader {
|
|
45
|
+
defaultSlot: Ref<HTMLElement> = createRef()
|
|
46
|
+
|
|
47
|
+
constructor() {
|
|
48
|
+
super()
|
|
49
|
+
this.slotController = new PktSlotController(this, this.defaultSlot)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
@property({ type: Number }) delay: number = 0
|
|
53
|
+
@property({ type: Boolean }) inline: boolean = false
|
|
54
|
+
@property({ type: Boolean }) isLoading: boolean = true
|
|
55
|
+
@property({ type: String }) message: string | null = null
|
|
56
|
+
@property({ type: String }) size: TPktSize = 'medium'
|
|
57
|
+
@property({ type: String }) variant: TPktLoaderVariant = 'shapes'
|
|
58
|
+
|
|
59
|
+
@state() private _shouldDisplayLoader: boolean = false
|
|
60
|
+
|
|
61
|
+
connectedCallback() {
|
|
62
|
+
super.connectedCallback()
|
|
63
|
+
this._shouldDisplayLoader = this.delay === 0
|
|
64
|
+
|
|
65
|
+
if (this.delay > 0) {
|
|
66
|
+
this.setupLoader()
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
updated(changedProperties: Map<string, unknown>) {
|
|
71
|
+
if (changedProperties.has('delay')) {
|
|
72
|
+
this.setupLoader()
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
render() {
|
|
77
|
+
const classes = classMap({
|
|
78
|
+
'pkt-loader': true,
|
|
79
|
+
[`pkt-loader--${this.inline ? 'inline' : 'box'}`]: true,
|
|
80
|
+
[`pkt-loader--${this.size}`]: true,
|
|
81
|
+
})
|
|
82
|
+
|
|
83
|
+
const slotClasses = classMap({
|
|
84
|
+
'pkt-contents': true,
|
|
85
|
+
'pkt-hide': this.isLoading,
|
|
86
|
+
})
|
|
87
|
+
|
|
88
|
+
return html`<div role="status" aria-live="polite" .aria-busy=${this.isLoading} class=${classes}>
|
|
89
|
+
${this.isLoading && this._shouldDisplayLoader
|
|
90
|
+
? html`<div class="pkt-loader__spinner">
|
|
91
|
+
<pkt-icon
|
|
92
|
+
name=${this.getVariant(this.variant)}
|
|
93
|
+
path="https://punkt-cdn.oslo.kommune.no/latest/animations/"
|
|
94
|
+
class="pkt-loader__svg pkt-loader__${this.variant}"
|
|
95
|
+
></pkt-icon>
|
|
96
|
+
${this.message && html`<p>${this.message}</p>`}
|
|
97
|
+
</div>`
|
|
98
|
+
: nothing}
|
|
99
|
+
<div class=${slotClasses} ${ref(this.defaultSlot)}></div>
|
|
100
|
+
</div>`
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
private getVariant(variant: TPktLoaderVariant): string {
|
|
104
|
+
switch (variant) {
|
|
105
|
+
case 'blue':
|
|
106
|
+
return 'spinner-blue'
|
|
107
|
+
case 'rainbow':
|
|
108
|
+
return 'spinner'
|
|
109
|
+
default:
|
|
110
|
+
return 'loader'
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
private setupLoader() {
|
|
115
|
+
if (this.delay > 0) {
|
|
116
|
+
this._shouldDisplayLoader = false
|
|
117
|
+
setTimeout(() => {
|
|
118
|
+
this._shouldDisplayLoader = true
|
|
119
|
+
this.requestUpdate()
|
|
120
|
+
}, this.delay)
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
export default PktLoader
|
|
@@ -2,12 +2,13 @@ import { PktElement } from '@/base-elements/element'
|
|
|
2
2
|
import { PktSlotController } from '@/controllers/pkt-slot-controller'
|
|
3
3
|
import { ref } from 'lit/directives/ref.js'
|
|
4
4
|
import { Ref, createRef } from 'lit/directives/ref.js'
|
|
5
|
-
import { html, nothing } from 'lit'
|
|
5
|
+
import { html, nothing, PropertyValues } from 'lit'
|
|
6
6
|
import { classMap } from 'lit/directives/class-map.js'
|
|
7
7
|
import { customElement, property, state } from 'lit/decorators.js'
|
|
8
8
|
import specs from 'componentSpecs/messagebox.json'
|
|
9
9
|
|
|
10
10
|
import '@/components/icon'
|
|
11
|
+
import { updateClassAttribute } from '@/utils/classutils'
|
|
11
12
|
|
|
12
13
|
export type TMessageboxSkin = 'beige' | 'blue' | 'red' | 'green'
|
|
13
14
|
|
|
@@ -19,7 +20,7 @@ export interface IPktMessagebox {
|
|
|
19
20
|
}
|
|
20
21
|
|
|
21
22
|
@customElement('pkt-messagebox')
|
|
22
|
-
export class PktMessagebox extends PktElement {
|
|
23
|
+
export class PktMessagebox extends PktElement implements IPktMessagebox {
|
|
23
24
|
defaultSlot: Ref<HTMLElement> = createRef()
|
|
24
25
|
|
|
25
26
|
constructor() {
|
|
@@ -28,6 +29,8 @@ export class PktMessagebox extends PktElement {
|
|
|
28
29
|
this._isClosed = false
|
|
29
30
|
}
|
|
30
31
|
|
|
32
|
+
// Properties
|
|
33
|
+
|
|
31
34
|
@property({ type: Boolean, reflect: true }) closable = specs.props.closable.default
|
|
32
35
|
@property({ type: Boolean, reflect: true }) compact = specs.props.compact.default
|
|
33
36
|
@property({ type: String, reflect: true }) title = ''
|
|
@@ -35,13 +38,18 @@ export class PktMessagebox extends PktElement {
|
|
|
35
38
|
|
|
36
39
|
@state() _isClosed: boolean = false
|
|
37
40
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
41
|
+
// Lifecycle
|
|
42
|
+
|
|
43
|
+
protected updated(_changedProperties: PropertyValues): void {
|
|
44
|
+
super.updated(_changedProperties)
|
|
45
|
+
|
|
46
|
+
if (_changedProperties.has('_isClosed')) {
|
|
47
|
+
updateClassAttribute(this, 'pkt-hide', this._isClosed)
|
|
48
|
+
}
|
|
43
49
|
}
|
|
44
50
|
|
|
51
|
+
// Render
|
|
52
|
+
|
|
45
53
|
render() {
|
|
46
54
|
const classes = {
|
|
47
55
|
'pkt-messagebox': true,
|
|
@@ -66,4 +74,12 @@ export class PktMessagebox extends PktElement {
|
|
|
66
74
|
<div class="pkt-messagebox__text" ${ref(this.defaultSlot)}></div>
|
|
67
75
|
</div>`
|
|
68
76
|
}
|
|
77
|
+
|
|
78
|
+
// Methods
|
|
79
|
+
private close = (event: MouseEvent) => {
|
|
80
|
+
this._isClosed = true
|
|
81
|
+
this.dispatchEvent(new CustomEvent('close', { detail: { origin: event }, bubbles: true }))
|
|
82
|
+
// Historical support of old Vue implementations…
|
|
83
|
+
this.dispatchEvent(new CustomEvent('on-close', { detail: { origin: event }, bubbles: true }))
|
|
84
|
+
}
|
|
69
85
|
}
|
|
@@ -166,13 +166,14 @@ export class PktModal extends PktElement implements IPktModal {
|
|
|
166
166
|
: nothing}
|
|
167
167
|
${!this.hideCloseButton
|
|
168
168
|
? html`<div class="${classMap(closeButtonClasses)}">
|
|
169
|
-
<button
|
|
169
|
+
<pkt-button
|
|
170
170
|
@click=${(event: Event) => this.close(event)}
|
|
171
171
|
class=${classMap(buttonClasses)}
|
|
172
172
|
aria-label="close"
|
|
173
|
+
iconname="close"
|
|
174
|
+
variant="icon-only"
|
|
173
175
|
>
|
|
174
|
-
|
|
175
|
-
</button>
|
|
176
|
+
</pkt-button>
|
|
176
177
|
</div>`
|
|
177
178
|
: nothing}
|
|
178
179
|
</div>
|
package/dist/alert-Cx7AYawa.cjs
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
"use strict";const d=require("./class-map-Dzci3Pfe.cjs"),t=require("./element-r-PeQ419.cjs"),k=require("./state-B77EXPZ9.cjs"),u=require("./pkt-slot-controller-Oc32unDk.cjs"),c=require("./ref-BUWgvhgU.cjs");require("./icon-DcJIqTIY.cjs");const h="pkt-alert",v=!0,f={onClose:{description:"React: Klikk-event for 'Lukk'-knappen"},close:{description:"Vue: Klikk-event for 'Lukk'-knappen"}},m={title:{name:"Tittel",description:"Tittelen som vises øverst i på meldingen",type:"string"},skin:{name:"Utseende",description:"Hvordan type melding er dette?",type:["info","success","warning","error"],default:"info"},date:{name:"Sist oppdatert",description:"Dato som vises nederst i på meldingen",type:"string"},ariaLive:{name:"aria-live",description:"Hvordan skal skjermleseren lese opp meldingen?",type:["off","polite","assertive"],default:"polite"},compact:{name:"Kompakt",description:"Gjør meldingen mindre",type:"boolean",default:!1},closeAlert:{name:"Vis 'Lukk'-knapp",description:"Viser 'Lukk'-knappen",type:"boolean",default:!1}},b={default:{description:"Innholdet i meldingen"}},n={name:h,"css-class":"pkt-alert","dark-mode":!0,isElement:v,events:f,props:m,slots:b};var y=Object.defineProperty,_=Object.getOwnPropertyDescriptor,i=(a,e,l,s)=>{for(var r=s>1?void 0:s?_(e,l):e,o=a.length-1,p;o>=0;o--)(p=a[o])&&(r=(s?p(e,l,r):p(r))||r);return s&&r&&y(e,l,r),r};exports.PktAlert=class extends t.PktElement{constructor(){super(),this.defaultSlot=c.e(),this.compact=n.props.compact.default,this.title="",this.skin=n.props.skin.default,this.ariaLive=n.props.ariaLive.default,this["aria-live"]=null,this.closeAlert=n.props.closeAlert.default,this.date=null,this._isClosed=!1,this.close=e=>{this._isClosed=!0,this.dispatchEvent(new CustomEvent("close",{detail:{origin:e},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("on-close",{detail:{origin:e},bubbles:!0,composed:!0}))},this.slotController=new u.PktSlotController(this,this.defaultSlot),this._isClosed=!1}connectedCallback(){super.connectedCallback(),this["aria-live"]=this.getAttribute("aria-live")||this.ariaLive}attributeChangedCallback(e,l,s){e==="ariaLive"&&(this["aria-live"]=s),super.attributeChangedCallback(e,l,s)}updated(e){super.updated(e),e.has("ariaLive")&&(this["aria-live"]=this.ariaLive)}render(){const e={"pkt-alert":!0,"pkt-alert--compact":this.compact,[`pkt-alert--${this.skin}`]:this.skin,"pkt-hide":this._isClosed};return t.x`
|
|
2
|
-
<div class=${d.e(e)}>
|
|
3
|
-
<pkt-icon
|
|
4
|
-
class="pkt-alert__icon"
|
|
5
|
-
name=${this.skin==="info"?"alert-information":`alert-${this.skin}`}
|
|
6
|
-
></pkt-icon>
|
|
7
|
-
|
|
8
|
-
${this.closeAlert?t.x`
|
|
9
|
-
<div class="pkt-alert__close">
|
|
10
|
-
<button
|
|
11
|
-
type="button"
|
|
12
|
-
class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only"
|
|
13
|
-
tabindex="0"
|
|
14
|
-
aria-label="close"
|
|
15
|
-
@click=${this.close}
|
|
16
|
-
>
|
|
17
|
-
<pkt-icon name="close" class="pkt-btn__icon" aria-hidden="true"></pkt-icon>
|
|
18
|
-
</button>
|
|
19
|
-
</div>
|
|
20
|
-
`:t.E}
|
|
21
|
-
${this.title?t.x`<div class="pkt-alert__title">${this.title}</div>`:t.E}
|
|
22
|
-
|
|
23
|
-
<div class="pkt-alert__text" ${c.n(this.defaultSlot)}></div>
|
|
24
|
-
|
|
25
|
-
${this.date?t.x`<div class="pkt-alert__date">Sist oppdatert: ${this.date}</div>`:t.E}
|
|
26
|
-
</div>
|
|
27
|
-
`}};i([t.n({type:Boolean,reflect:!1})],exports.PktAlert.prototype,"compact",2);i([t.n({type:String,reflect:!0})],exports.PktAlert.prototype,"title",2);i([t.n({type:String,reflect:!0})],exports.PktAlert.prototype,"skin",2);i([t.n({type:String})],exports.PktAlert.prototype,"ariaLive",2);i([t.n({type:String,reflect:!0})],exports.PktAlert.prototype,"aria-live",2);i([t.n({type:Boolean,reflect:!0})],exports.PktAlert.prototype,"closeAlert",2);i([t.n({type:String,reflect:!0})],exports.PktAlert.prototype,"date",2);i([k.r()],exports.PktAlert.prototype,"_isClosed",2);exports.PktAlert=i([t.t("pkt-alert")],exports.PktAlert);
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
"use strict";const e=require("./element-r-PeQ419.cjs"),b=require("./pkt-slot-controller-Oc32unDk.cjs"),p=require("./ref-BUWgvhgU.cjs"),k=require("./class-map-Dzci3Pfe.cjs"),d=require("./state-B77EXPZ9.cjs");require("./icon-DcJIqTIY.cjs");const u="pkt-messagebox",m=!0,g={onClose:{description:"React: Event som trigges når meldingsboksen lukkes"},"on-close":{description:"Vue: Event som trigges når meldingsboksen lukkes"}},h={title:{name:"Tittel",description:"Tittelen på meldingsboksen",type:"string"},skin:{name:"Utseende",description:"Velg farge på meldingsboksen",type:["beige","blue","red","green"],default:"beige"},compact:{name:"Kompakt",description:"Gjør meldingsboksen mindre",type:"boolean",default:!1},closable:{name:"Kan lukkes",description:"Viser lukkeknapp",type:"boolean",default:!1}},f={default:{description:"Innholdet i meldingsboksen"}},c={name:u,"css-class":"pkt-messagebox",isElement:m,events:g,props:h,slots:f};var x=Object.defineProperty,v=Object.getOwnPropertyDescriptor,o=(i,t,n,l)=>{for(var s=l>1?void 0:l?v(t,n):t,r=i.length-1,a;r>=0;r--)(a=i[r])&&(s=(l?a(t,n,s):a(s))||s);return l&&s&&x(t,n,s),s};exports.PktMessagebox=class extends e.PktElement{constructor(){super(),this.defaultSlot=p.e(),this.closable=c.props.closable.default,this.compact=c.props.compact.default,this.title="",this.skin=c.props.skin.default,this._isClosed=!1,this.close=t=>{this._isClosed=!0,this.dispatchEvent(new CustomEvent("close",{detail:{origin:t},bubbles:!0})),this.dispatchEvent(new CustomEvent("on-close",{detail:{origin:t},bubbles:!0}))},this.slotController=new b.PktSlotController(this,this.defaultSlot),this._isClosed=!1}render(){const t={"pkt-messagebox":!0,"pkt-messagebox--compact":this.compact,[`pkt-messagebox--${this.skin}`]:this.skin,"pkt-messagebox--closable":this.closable,"pkt-hide":this._isClosed};return e.x`<div class=${k.e(t)}>
|
|
2
|
-
${this.closable?e.x`<div class="pkt-messagebox__close">
|
|
3
|
-
<button
|
|
4
|
-
@click=${this.close}
|
|
5
|
-
class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only"
|
|
6
|
-
>
|
|
7
|
-
<pkt-icon name="close" class="pkt-link__icon"></pkt-icon>
|
|
8
|
-
</button>
|
|
9
|
-
</div>`:e.E}
|
|
10
|
-
${this.title?e.x`<div class="pkt-messagebox__title">${this.title}</div>`:e.E}
|
|
11
|
-
<div class="pkt-messagebox__text" ${p.n(this.defaultSlot)}></div>
|
|
12
|
-
</div>`}};o([e.n({type:Boolean,reflect:!0})],exports.PktMessagebox.prototype,"closable",2);o([e.n({type:Boolean,reflect:!0})],exports.PktMessagebox.prototype,"compact",2);o([e.n({type:String,reflect:!0})],exports.PktMessagebox.prototype,"title",2);o([e.n({type:String,reflect:!0})],exports.PktMessagebox.prototype,"skin",2);o([d.r()],exports.PktMessagebox.prototype,"_isClosed",2);exports.PktMessagebox=o([e.t("pkt-messagebox")],exports.PktMessagebox);
|