@oslokommune/punkt-elements 12.5.2 → 12.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +31 -11
- package/dist/pkt-alert.cjs +6 -6
- package/dist/pkt-alert.js +99 -40
- package/dist/pkt-index.cjs +1 -1
- package/dist/pkt-index.js +20 -18
- package/dist/pkt-messagebox.cjs +3 -3
- package/dist/pkt-messagebox.js +83 -38
- package/dist/pkt-tag.cjs +13 -13
- package/dist/pkt-tag.js +33 -31
- package/package.json +2 -2
- package/src/components/alert/index.ts +31 -29
- package/src/components/index.ts +1 -0
- package/src/components/messagebox/index.ts +25 -22
- package/src/components/tag/index.ts +21 -21
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { LitElement } from 'lit';
|
|
2
|
-
import { nothing } from 'lit';
|
|
3
2
|
import { PropertyValues } from 'lit';
|
|
4
3
|
import { ReactiveController } from 'lit';
|
|
5
4
|
import { ReactiveControllerHost } from 'lit';
|
|
@@ -7,6 +6,10 @@ import { Ref } from 'lit/directives/ref.js';
|
|
|
7
6
|
import { StaticValue } from 'lit-html/static';
|
|
8
7
|
import { TemplateResult } from 'lit-html';
|
|
9
8
|
|
|
9
|
+
declare type AlertAriaLive = 'off' | 'polite' | 'assertive';
|
|
10
|
+
|
|
11
|
+
declare type AlertSkin = 'error' | 'success' | 'warning' | 'info';
|
|
12
|
+
|
|
10
13
|
declare type ICardSkin = 'outlined' | 'gray' | 'beige' | 'green' | 'blue';
|
|
11
14
|
|
|
12
15
|
declare type IDirection = 'portrait' | 'landscape';
|
|
@@ -14,13 +17,29 @@ declare type IDirection = 'portrait' | 'landscape';
|
|
|
14
17
|
declare interface IPktTag {
|
|
15
18
|
closeTag?: boolean;
|
|
16
19
|
size?: TagSize;
|
|
17
|
-
skin?:
|
|
20
|
+
skin?: TagSkin;
|
|
18
21
|
textStyle?: string;
|
|
19
22
|
iconName?: string;
|
|
20
|
-
type?:
|
|
23
|
+
type?: TagType;
|
|
21
24
|
ariaLabel?: string;
|
|
22
25
|
}
|
|
23
26
|
|
|
27
|
+
declare type MessageboxSkin = 'error' | 'success' | 'warning' | 'info';
|
|
28
|
+
|
|
29
|
+
export declare class PktAlert extends PktElement {
|
|
30
|
+
defaultSlot: Ref<HTMLElement>;
|
|
31
|
+
constructor();
|
|
32
|
+
compact: boolean;
|
|
33
|
+
title: string;
|
|
34
|
+
skin: AlertSkin;
|
|
35
|
+
ariaLive: AlertAriaLive;
|
|
36
|
+
closeAlert: boolean;
|
|
37
|
+
date: string | null;
|
|
38
|
+
_isClosed: boolean;
|
|
39
|
+
private close;
|
|
40
|
+
render(): TemplateResult<1>;
|
|
41
|
+
}
|
|
42
|
+
|
|
24
43
|
export declare class PktCalendar extends PktElement {
|
|
25
44
|
/**
|
|
26
45
|
* Element attributes
|
|
@@ -355,11 +374,10 @@ export declare class PktMessagebox extends PktElement {
|
|
|
355
374
|
closable: boolean;
|
|
356
375
|
compact: boolean;
|
|
357
376
|
title: string;
|
|
358
|
-
skin:
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
render(): TemplateResult<1> | typeof nothing;
|
|
377
|
+
skin: MessageboxSkin;
|
|
378
|
+
_isClosed: boolean;
|
|
379
|
+
private close;
|
|
380
|
+
render(): TemplateResult<1>;
|
|
363
381
|
}
|
|
364
382
|
|
|
365
383
|
declare class PktSlotController implements ReactiveController {
|
|
@@ -384,7 +402,7 @@ export declare class PktTag extends PktElement {
|
|
|
384
402
|
skin: TagSkin;
|
|
385
403
|
textStyle: string;
|
|
386
404
|
iconName: string | undefined;
|
|
387
|
-
type:
|
|
405
|
+
type: TagType;
|
|
388
406
|
ariaLabel: string;
|
|
389
407
|
/**
|
|
390
408
|
* Element state
|
|
@@ -394,11 +412,13 @@ export declare class PktTag extends PktElement {
|
|
|
394
412
|
* Element functions
|
|
395
413
|
*/
|
|
396
414
|
private close;
|
|
397
|
-
render(): TemplateResult<1
|
|
415
|
+
render(): TemplateResult<1>;
|
|
398
416
|
}
|
|
399
417
|
|
|
400
418
|
declare type TagSize = 'small' | 'medium' | 'large';
|
|
401
419
|
|
|
402
|
-
declare type TagSkin = 'blue' | 'green' | 'red' | 'yellow';
|
|
420
|
+
declare type TagSkin = 'blue' | 'green' | 'red' | 'yellow' | 'beige' | 'blue-light' | 'gray' | 'grey';
|
|
421
|
+
|
|
422
|
+
declare type TagType = 'button' | 'reset' | 'submit';
|
|
403
423
|
|
|
404
424
|
export { }
|
package/dist/pkt-alert.cjs
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-DSyh6tUw.cjs"),
|
|
2
|
-
<div class=${
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-DSyh6tUw.cjs"),c=require("./ref-C3InMDfU.cjs"),d=require("./class-map-Ch54kkX5.cjs"),k=require("./directive-DtixNHDT.cjs");require("./index-Bpc07w_P.cjs");const u="pkt-alert",f=!0,m={onClose:{description:"React: Klikk-event for 'Lukk'-knappen"},close:{description:"Vue: Klikk-event for 'Lukk'-knappen"}},v={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}},h={default:{description:"Innholdet i meldingen"}},l={name:u,"css-class":"pkt-alert","dark-mode":!0,isElement:f,events:m,props:v,slots:h};var y=Object.defineProperty,_=Object.getOwnPropertyDescriptor,s=(n,e,o,r)=>{for(var i=r>1?void 0:r?_(e,o):e,a=n.length-1,p;a>=0;a--)(p=n[a])&&(i=(r?p(e,o,i):p(i))||i);return r&&i&&y(e,o,i),i};exports.PktAlert=class extends t.PktElement{constructor(){super(),this.defaultSlot=c.e(),this.compact=l.props.compact.default,this.title="",this.skin=l.props.skin.default,this.ariaLive=l.props.ariaLive.default,this.closeAlert=l.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.slotController=new c.PktSlotController(this,this.defaultSlot),this._isClosed=!1}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)} aria-live=${this.ariaLive}>
|
|
3
3
|
<pkt-icon
|
|
4
4
|
class="pkt-alert__icon"
|
|
5
5
|
name=${this.skin==="info"?"alert-information":`alert-${this.skin}`}
|
|
6
6
|
></pkt-icon>
|
|
7
7
|
|
|
8
|
-
${this.
|
|
8
|
+
${this.closeAlert?t.x`
|
|
9
9
|
<div class="pkt-alert__close">
|
|
10
10
|
<button
|
|
11
11
|
type="button"
|
|
12
12
|
class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only"
|
|
13
13
|
tabindex="0"
|
|
14
14
|
aria-label="close"
|
|
15
|
-
@click=${this.
|
|
15
|
+
@click=${this.close}
|
|
16
16
|
>
|
|
17
17
|
<pkt-icon name="close" class="pkt-btn__icon" aria-hidden="true"></pkt-icon>
|
|
18
18
|
</button>
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
`:t.E}
|
|
21
21
|
${this.title?t.x`<div class="pkt-alert__title">${this.title}</div>`:t.E}
|
|
22
22
|
|
|
23
|
-
<div class="pkt-alert__text" ${
|
|
23
|
+
<div class="pkt-alert__text" ${c.n(this.defaultSlot)}></div>
|
|
24
24
|
|
|
25
25
|
${this.date?t.x`<div class="pkt-alert__date">Sist oppdatert: ${this.date}</div>`:t.E}
|
|
26
26
|
</div>
|
|
27
|
-
|
|
27
|
+
`}};s([t.n({type:Boolean,reflect:!1})],exports.PktAlert.prototype,"compact",2);s([t.n({type:String,reflect:!0})],exports.PktAlert.prototype,"title",2);s([t.n({type:String,reflect:!0})],exports.PktAlert.prototype,"skin",2);s([t.n({type:String,reflect:!0})],exports.PktAlert.prototype,"ariaLive",2);s([t.n({type:Boolean,reflect:!0})],exports.PktAlert.prototype,"closeAlert",2);s([t.n({type:String,reflect:!0})],exports.PktAlert.prototype,"date",2);s([t.r()],exports.PktAlert.prototype,"_isClosed",2);exports.PktAlert=s([k.t("pkt-alert")],exports.PktAlert);
|
package/dist/pkt-alert.js
CHANGED
|
@@ -1,85 +1,144 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { e as
|
|
3
|
-
import { e as
|
|
4
|
-
import { t as
|
|
1
|
+
import { r as m, P as u, x as n, E as k, n as o } from "./index-CsTujnXs.js";
|
|
2
|
+
import { e as f, P as v, n as h } from "./ref-By_W8A-f.js";
|
|
3
|
+
import { e as y } from "./class-map-DunDFQn7.js";
|
|
4
|
+
import { t as _ } from "./directive-Cxhakbpr.js";
|
|
5
5
|
import "./index-CyqOyy_9.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
const b = "pkt-alert", g = !0, $ = {
|
|
7
|
+
onClose: {
|
|
8
|
+
description: "React: Klikk-event for 'Lukk'-knappen"
|
|
9
|
+
},
|
|
10
|
+
close: {
|
|
11
|
+
description: "Vue: Klikk-event for 'Lukk'-knappen"
|
|
12
|
+
}
|
|
13
|
+
}, C = {
|
|
14
|
+
title: {
|
|
15
|
+
name: "Tittel",
|
|
16
|
+
description: "Tittelen som vises øverst i på meldingen",
|
|
17
|
+
type: "string"
|
|
18
|
+
},
|
|
19
|
+
skin: {
|
|
20
|
+
name: "Utseende",
|
|
21
|
+
description: "Hvordan type melding er dette?",
|
|
22
|
+
type: [
|
|
23
|
+
"info",
|
|
24
|
+
"success",
|
|
25
|
+
"warning",
|
|
26
|
+
"error"
|
|
27
|
+
],
|
|
28
|
+
default: "info"
|
|
29
|
+
},
|
|
30
|
+
date: {
|
|
31
|
+
name: "Sist oppdatert",
|
|
32
|
+
description: "Dato som vises nederst i på meldingen",
|
|
33
|
+
type: "string"
|
|
34
|
+
},
|
|
35
|
+
ariaLive: {
|
|
36
|
+
name: "aria-live",
|
|
37
|
+
description: "Hvordan skal skjermleseren lese opp meldingen?",
|
|
38
|
+
type: [
|
|
39
|
+
"off",
|
|
40
|
+
"polite",
|
|
41
|
+
"assertive"
|
|
42
|
+
],
|
|
43
|
+
default: "polite"
|
|
44
|
+
},
|
|
45
|
+
compact: {
|
|
46
|
+
name: "Kompakt",
|
|
47
|
+
description: "Gjør meldingen mindre",
|
|
48
|
+
type: "boolean",
|
|
49
|
+
default: !1
|
|
50
|
+
},
|
|
51
|
+
closeAlert: {
|
|
52
|
+
name: "Vis 'Lukk'-knapp",
|
|
53
|
+
description: "Viser 'Lukk'-knappen",
|
|
54
|
+
type: "boolean",
|
|
55
|
+
default: !1
|
|
56
|
+
}
|
|
57
|
+
}, S = {
|
|
58
|
+
default: {
|
|
59
|
+
description: "Innholdet i meldingen"
|
|
60
|
+
}
|
|
61
|
+
}, a = {
|
|
62
|
+
name: b,
|
|
63
|
+
"css-class": "pkt-alert",
|
|
64
|
+
"dark-mode": !0,
|
|
65
|
+
isElement: g,
|
|
66
|
+
events: $,
|
|
67
|
+
props: C,
|
|
68
|
+
slots: S
|
|
10
69
|
};
|
|
11
|
-
|
|
70
|
+
var L = Object.defineProperty, P = Object.getOwnPropertyDescriptor, e = (i, r, p, l) => {
|
|
71
|
+
for (var s = l > 1 ? void 0 : l ? P(r, p) : r, c = i.length - 1, d; c >= 0; c--)
|
|
72
|
+
(d = i[c]) && (s = (l ? d(r, p, s) : d(s)) || s);
|
|
73
|
+
return l && s && L(r, p, s), s;
|
|
74
|
+
};
|
|
75
|
+
let t = class extends u {
|
|
12
76
|
constructor() {
|
|
13
|
-
super(), this.defaultSlot =
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
77
|
+
super(), this.defaultSlot = f(), this.compact = a.props.compact.default, this.title = "", this.skin = a.props.skin.default, this.ariaLive = a.props.ariaLive.default, this.closeAlert = a.props.closeAlert.default, this.date = null, this._isClosed = !1, this.close = (i) => {
|
|
78
|
+
this._isClosed = !0, this.dispatchEvent(
|
|
79
|
+
new CustomEvent("close", { detail: { origin: i }, bubbles: !0, composed: !0 })
|
|
80
|
+
);
|
|
81
|
+
}, this.slotController = new v(this, this.defaultSlot), this._isClosed = !1;
|
|
17
82
|
}
|
|
18
83
|
render() {
|
|
19
|
-
const
|
|
84
|
+
const i = {
|
|
20
85
|
"pkt-alert": !0,
|
|
21
86
|
"pkt-alert--compact": this.compact,
|
|
22
87
|
[`pkt-alert--${this.skin}`]: this.skin,
|
|
23
|
-
"pkt-
|
|
88
|
+
"pkt-hide": this._isClosed
|
|
24
89
|
};
|
|
25
|
-
return
|
|
26
|
-
<div class=${
|
|
90
|
+
return n`
|
|
91
|
+
<div class=${y(i)} aria-live=${this.ariaLive}>
|
|
27
92
|
<pkt-icon
|
|
28
93
|
class="pkt-alert__icon"
|
|
29
94
|
name=${this.skin === "info" ? "alert-information" : `alert-${this.skin}`}
|
|
30
95
|
></pkt-icon>
|
|
31
96
|
|
|
32
|
-
${this.
|
|
97
|
+
${this.closeAlert ? n`
|
|
33
98
|
<div class="pkt-alert__close">
|
|
34
99
|
<button
|
|
35
100
|
type="button"
|
|
36
101
|
class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only"
|
|
37
102
|
tabindex="0"
|
|
38
103
|
aria-label="close"
|
|
39
|
-
@click=${this.
|
|
104
|
+
@click=${this.close}
|
|
40
105
|
>
|
|
41
106
|
<pkt-icon name="close" class="pkt-btn__icon" aria-hidden="true"></pkt-icon>
|
|
42
107
|
</button>
|
|
43
108
|
</div>
|
|
44
|
-
` :
|
|
45
|
-
${this.title ?
|
|
109
|
+
` : k}
|
|
110
|
+
${this.title ? n`<div class="pkt-alert__title">${this.title}</div>` : k}
|
|
46
111
|
|
|
47
|
-
<div class="pkt-alert__text" ${
|
|
112
|
+
<div class="pkt-alert__text" ${h(this.defaultSlot)}></div>
|
|
48
113
|
|
|
49
|
-
${this.date ?
|
|
114
|
+
${this.date ? n`<div class="pkt-alert__date">Sist oppdatert: ${this.date}</div>` : k}
|
|
50
115
|
</div>
|
|
51
|
-
|
|
116
|
+
`;
|
|
52
117
|
}
|
|
53
118
|
};
|
|
54
119
|
e([
|
|
55
|
-
|
|
56
|
-
], t.prototype, "closable", 2);
|
|
57
|
-
e([
|
|
58
|
-
s({ type: Boolean, reflect: !0 })
|
|
120
|
+
o({ type: Boolean, reflect: !1 })
|
|
59
121
|
], t.prototype, "compact", 2);
|
|
60
122
|
e([
|
|
61
|
-
|
|
123
|
+
o({ type: String, reflect: !0 })
|
|
62
124
|
], t.prototype, "title", 2);
|
|
63
125
|
e([
|
|
64
|
-
|
|
126
|
+
o({ type: String, reflect: !0 })
|
|
65
127
|
], t.prototype, "skin", 2);
|
|
66
128
|
e([
|
|
67
|
-
|
|
68
|
-
], t.prototype, "isDisplayed", 2);
|
|
69
|
-
e([
|
|
70
|
-
s({ type: Function, reflect: !0 })
|
|
71
|
-
], t.prototype, "onClose", 2);
|
|
72
|
-
e([
|
|
73
|
-
s({ type: String, reflect: !0 })
|
|
129
|
+
o({ type: String, reflect: !0 })
|
|
74
130
|
], t.prototype, "ariaLive", 2);
|
|
75
131
|
e([
|
|
76
|
-
|
|
132
|
+
o({ type: Boolean, reflect: !0 })
|
|
77
133
|
], t.prototype, "closeAlert", 2);
|
|
78
134
|
e([
|
|
79
|
-
|
|
135
|
+
o({ type: String, reflect: !0 })
|
|
80
136
|
], t.prototype, "date", 2);
|
|
137
|
+
e([
|
|
138
|
+
m()
|
|
139
|
+
], t.prototype, "_isClosed", 2);
|
|
81
140
|
t = e([
|
|
82
|
-
|
|
141
|
+
_("pkt-alert")
|
|
83
142
|
], t);
|
|
84
143
|
export {
|
|
85
144
|
t as PktAlert
|
package/dist/pkt-index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-BNOnscrA.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./pkt-alert.cjs"),t=require("./index-BNOnscrA.cjs"),r=require("./pkt-card.cjs"),n=require("./pkt-component-template.cjs"),o=require("./pkt-datepicker.cjs"),u=require("./index-Bpc07w_P.cjs"),a=require("./pkt-input-wrapper.cjs"),c=require("./pkt-link.cjs"),i=require("./pkt-messagebox.cjs"),P=require("./pkt-tag.cjs");Object.defineProperty(exports,"PktAlert",{enumerable:!0,get:()=>e.PktAlert});Object.defineProperty(exports,"PktCalendar",{enumerable:!0,get:()=>t.PktCalendar});Object.defineProperty(exports,"PktCard",{enumerable:!0,get:()=>r.PktCard});Object.defineProperty(exports,"PktComponent",{enumerable:!0,get:()=>n.PktComponent});Object.defineProperty(exports,"PktDatepicker",{enumerable:!0,get:()=>o.PktDatepicker});Object.defineProperty(exports,"PktIcon",{enumerable:!0,get:()=>u.PktIcon});Object.defineProperty(exports,"PktInputWrapper",{enumerable:!0,get:()=>a.PktInputWrapper});Object.defineProperty(exports,"PktLink",{enumerable:!0,get:()=>c.PktLink});Object.defineProperty(exports,"PktMessagebox",{enumerable:!0,get:()=>i.PktMessagebox});Object.defineProperty(exports,"PktTag",{enumerable:!0,get:()=>P.PktTag});
|
package/dist/pkt-index.js
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
1
|
+
import { PktAlert as t } from "./pkt-alert.js";
|
|
2
|
+
import { P as p } from "./index-BI6-RUqp.js";
|
|
3
|
+
import { PktCard as P } from "./pkt-card.js";
|
|
4
|
+
import { PktComponent as x } from "./pkt-component-template.js";
|
|
5
|
+
import { PktDatepicker as a } from "./pkt-datepicker.js";
|
|
6
|
+
import { P as s } from "./index-CyqOyy_9.js";
|
|
7
|
+
import { PktInputWrapper as c } from "./pkt-input-wrapper.js";
|
|
8
|
+
import { PktLink as g } from "./pkt-link.js";
|
|
9
|
+
import { PktMessagebox as l } from "./pkt-messagebox.js";
|
|
10
|
+
import { PktTag as b } from "./pkt-tag.js";
|
|
10
11
|
export {
|
|
11
|
-
t as
|
|
12
|
-
p as
|
|
13
|
-
P as
|
|
14
|
-
x as
|
|
15
|
-
|
|
16
|
-
s as
|
|
17
|
-
c as
|
|
18
|
-
g as
|
|
19
|
-
|
|
12
|
+
t as PktAlert,
|
|
13
|
+
p as PktCalendar,
|
|
14
|
+
P as PktCard,
|
|
15
|
+
x as PktComponent,
|
|
16
|
+
a as PktDatepicker,
|
|
17
|
+
s as PktIcon,
|
|
18
|
+
c as PktInputWrapper,
|
|
19
|
+
g as PktLink,
|
|
20
|
+
l as PktMessagebox,
|
|
21
|
+
b as PktTag
|
|
20
22
|
};
|
package/dist/pkt-messagebox.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-DSyh6tUw.cjs"),c=require("./ref-C3InMDfU.cjs"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-DSyh6tUw.cjs"),c=require("./ref-C3InMDfU.cjs"),b=require("./class-map-Ch54kkX5.cjs"),k=require("./directive-DtixNHDT.cjs");require("./index-Bpc07w_P.cjs");const d="pkt-messagebox",u=!0,g={onClose:{description:"React: Event som trigges når meldingsboksen lukkes"},"on-close":{description:"Vue: Event som trigges når meldingsboksen lukkes"}},m={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}},h={default:{description:"Innholdet i meldingsboksen"}},p={name:d,"css-class":"pkt-messagebox",isElement:u,events:g,props:m,slots:h};var f=Object.defineProperty,x=Object.getOwnPropertyDescriptor,o=(i,t,n,l)=>{for(var s=l>1?void 0:l?x(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&&f(t,n,s),s};exports.PktMessagebox=class extends e.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=t=>{this._isClosed=!0,this.dispatchEvent(new CustomEvent("close",{detail:{origin:t},bubbles:!0}))},this.slotController=new c.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=${b.e(t)}>
|
|
2
2
|
${this.closable?e.x`<div class="pkt-messagebox__close">
|
|
3
3
|
<button
|
|
4
|
-
@click=${this.
|
|
4
|
+
@click=${this.close}
|
|
5
5
|
class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only"
|
|
6
6
|
>
|
|
7
7
|
<pkt-icon name="close" class="pkt-link__icon"></pkt-icon>
|
|
@@ -9,4 +9,4 @@
|
|
|
9
9
|
</div>`:e.E}
|
|
10
10
|
${this.title?e.x`<div class="pkt-messagebox__title">${this.title}</div>`:e.E}
|
|
11
11
|
<div class="pkt-messagebox__text" ${c.n(this.defaultSlot)}></div>
|
|
12
|
-
</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([e.r()],exports.PktMessagebox.prototype,"_isClosed",2);exports.PktMessagebox=o([k.t("pkt-messagebox")],exports.PktMessagebox);
|
package/dist/pkt-messagebox.js
CHANGED
|
@@ -1,61 +1,106 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { e as
|
|
3
|
-
import { e as
|
|
4
|
-
import { t as
|
|
1
|
+
import { r as b, P as k, x as c, E as d, n } from "./index-CsTujnXs.js";
|
|
2
|
+
import { e as u, P as g, n as f } from "./ref-By_W8A-f.js";
|
|
3
|
+
import { e as h } from "./class-map-DunDFQn7.js";
|
|
4
|
+
import { t as v } from "./directive-Cxhakbpr.js";
|
|
5
5
|
import "./index-CyqOyy_9.js";
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
6
|
+
const _ = "pkt-messagebox", x = !0, y = {
|
|
7
|
+
onClose: {
|
|
8
|
+
description: "React: Event som trigges når meldingsboksen lukkes"
|
|
9
|
+
},
|
|
10
|
+
"on-close": {
|
|
11
|
+
description: "Vue: Event som trigges når meldingsboksen lukkes"
|
|
12
|
+
}
|
|
13
|
+
}, C = {
|
|
14
|
+
title: {
|
|
15
|
+
name: "Tittel",
|
|
16
|
+
description: "Tittelen på meldingsboksen",
|
|
17
|
+
type: "string"
|
|
18
|
+
},
|
|
19
|
+
skin: {
|
|
20
|
+
name: "Utseende",
|
|
21
|
+
description: "Velg farge på meldingsboksen",
|
|
22
|
+
type: [
|
|
23
|
+
"beige",
|
|
24
|
+
"blue",
|
|
25
|
+
"red",
|
|
26
|
+
"green"
|
|
27
|
+
],
|
|
28
|
+
default: "beige"
|
|
29
|
+
},
|
|
30
|
+
compact: {
|
|
31
|
+
name: "Kompakt",
|
|
32
|
+
description: "Gjør meldingsboksen mindre",
|
|
33
|
+
type: "boolean",
|
|
34
|
+
default: !1
|
|
35
|
+
},
|
|
36
|
+
closable: {
|
|
37
|
+
name: "Kan lukkes",
|
|
38
|
+
description: "Viser lukkeknapp",
|
|
39
|
+
type: "boolean",
|
|
40
|
+
default: !1
|
|
41
|
+
}
|
|
42
|
+
}, P = {
|
|
43
|
+
default: {
|
|
44
|
+
description: "Innholdet i meldingsboksen"
|
|
45
|
+
}
|
|
46
|
+
}, m = {
|
|
47
|
+
name: _,
|
|
48
|
+
"css-class": "pkt-messagebox",
|
|
49
|
+
isElement: x,
|
|
50
|
+
events: y,
|
|
51
|
+
props: C,
|
|
52
|
+
slots: P
|
|
10
53
|
};
|
|
11
|
-
|
|
54
|
+
var $ = Object.defineProperty, E = Object.getOwnPropertyDescriptor, o = (s, l, p, i) => {
|
|
55
|
+
for (var e = i > 1 ? void 0 : i ? E(l, p) : l, r = s.length - 1, a; r >= 0; r--)
|
|
56
|
+
(a = s[r]) && (e = (i ? a(l, p, e) : a(e)) || e);
|
|
57
|
+
return i && e && $(l, p, e), e;
|
|
58
|
+
};
|
|
59
|
+
let t = class extends k {
|
|
12
60
|
constructor() {
|
|
13
|
-
super(), this.defaultSlot =
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
this.isDisplayed = !1, this.onClose && this.onClose();
|
|
61
|
+
super(), this.defaultSlot = u(), this.closable = m.props.closable.default, this.compact = m.props.compact.default, this.title = "", this.skin = m.props.skin.default, this._isClosed = !1, this.close = (s) => {
|
|
62
|
+
this._isClosed = !0, this.dispatchEvent(new CustomEvent("close", { detail: { origin: s }, bubbles: !0 }));
|
|
63
|
+
}, this.slotController = new g(this, this.defaultSlot), this._isClosed = !1;
|
|
17
64
|
}
|
|
18
65
|
render() {
|
|
19
|
-
const
|
|
66
|
+
const s = {
|
|
20
67
|
"pkt-messagebox": !0,
|
|
21
68
|
"pkt-messagebox--compact": this.compact,
|
|
22
69
|
[`pkt-messagebox--${this.skin}`]: this.skin,
|
|
23
|
-
"pkt-messagebox--closable": this.closable
|
|
70
|
+
"pkt-messagebox--closable": this.closable,
|
|
71
|
+
"pkt-hide": this._isClosed
|
|
24
72
|
};
|
|
25
|
-
return
|
|
26
|
-
${this.closable ?
|
|
73
|
+
return c`<div class=${h(s)}>
|
|
74
|
+
${this.closable ? c`<div class="pkt-messagebox__close">
|
|
27
75
|
<button
|
|
28
|
-
@click=${this.
|
|
76
|
+
@click=${this.close}
|
|
29
77
|
class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only"
|
|
30
78
|
>
|
|
31
79
|
<pkt-icon name="close" class="pkt-link__icon"></pkt-icon>
|
|
32
80
|
</button>
|
|
33
|
-
</div>` :
|
|
34
|
-
${this.title ?
|
|
35
|
-
<div class="pkt-messagebox__text" ${
|
|
36
|
-
</div
|
|
81
|
+
</div>` : d}
|
|
82
|
+
${this.title ? c`<div class="pkt-messagebox__title">${this.title}</div>` : d}
|
|
83
|
+
<div class="pkt-messagebox__text" ${f(this.defaultSlot)}></div>
|
|
84
|
+
</div>`;
|
|
37
85
|
}
|
|
38
86
|
};
|
|
39
|
-
|
|
40
|
-
|
|
87
|
+
o([
|
|
88
|
+
n({ type: Boolean, reflect: !0 })
|
|
41
89
|
], t.prototype, "closable", 2);
|
|
42
|
-
|
|
43
|
-
|
|
90
|
+
o([
|
|
91
|
+
n({ type: Boolean, reflect: !0 })
|
|
44
92
|
], t.prototype, "compact", 2);
|
|
45
|
-
|
|
46
|
-
|
|
93
|
+
o([
|
|
94
|
+
n({ type: String, reflect: !0 })
|
|
47
95
|
], t.prototype, "title", 2);
|
|
48
|
-
|
|
49
|
-
|
|
96
|
+
o([
|
|
97
|
+
n({ type: String, reflect: !0 })
|
|
50
98
|
], t.prototype, "skin", 2);
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
], t.prototype, "
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
], t.prototype, "onClose", 2);
|
|
57
|
-
t = s([
|
|
58
|
-
y("pkt-messagebox")
|
|
99
|
+
o([
|
|
100
|
+
b()
|
|
101
|
+
], t.prototype, "_isClosed", 2);
|
|
102
|
+
t = o([
|
|
103
|
+
v("pkt-messagebox")
|
|
59
104
|
], t);
|
|
60
105
|
export {
|
|
61
106
|
t as PktMessagebox
|
package/dist/pkt-tag.cjs
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./class-map-Ch54kkX5.cjs"),g=require("./directive-DtixNHDT.cjs"),t=require("./index-DSyh6tUw.cjs"),o=require("./ref-C3InMDfU.cjs");require("./index-Bpc07w_P.cjs");const h="pkt-tag",f={closeTag:{type:"boolean",required:!1,default:!1},size:{required:!1,default:"medium",type:["small","medium","large"]},iconName:{type:"string",required:!1},skin:{required:!1,default:"blue",type:["blue","green","red","beige","yellow","gray","blue-light"]},textStyle:{required:!1,default:"normal-text",type:["thin-text","normal-text"]},type:{required:!1,default:"button",type:["button","submit","reset"]},ariaLabel:{type:"string",required:!1,default:"close"}},
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("./class-map-Ch54kkX5.cjs"),g=require("./directive-DtixNHDT.cjs"),t=require("./index-DSyh6tUw.cjs"),o=require("./ref-C3InMDfU.cjs");require("./index-Bpc07w_P.cjs");const h="pkt-tag",f=!0,k={closeTag:{type:"boolean",required:!1,default:!1},size:{required:!1,default:"medium",type:["small","medium","large"]},iconName:{type:"string",required:!1},skin:{required:!1,default:"blue",type:["blue","green","red","beige","yellow","gray","blue-light"]},textStyle:{required:!1,default:"normal-text",type:["thin-text","normal-text"]},type:{required:!1,default:"button",type:["button","submit","reset"]},ariaLabel:{type:"string",required:!1,default:"close"}},d={default:{description:"Teksten til tag"}},a={name:h,"css-class":"pkt-tag",isElement:f,props:k,slots:d};var y=Object.defineProperty,b=Object.getOwnPropertyDescriptor,e=(n,s,l,r)=>{for(var i=r>1?void 0:r?b(s,l):s,p=n.length-1,c;p>=0;p--)(c=n[p])&&(i=(r?c(s,l,i):c(i))||i);return r&&i&&y(s,l,i),i};exports.PktTag=class extends t.PktElement{constructor(){super(),this.defaultSlot=o.e(),this.closeTag=a.props.closeTag.default,this.size=a.props.size.default,this.skin=a.props.skin.default,this.textStyle=a.props.textStyle.default,this.iconName=void 0,this.type=a.props.type.default,this.ariaLabel=a.props.ariaLabel.default,this._isClosed=!1,this.close=s=>{this._isClosed=!0,this.dispatchEvent(new CustomEvent("onClose",{detail:{origin:s},bubbles:!0,composed:!0}))},this.slotController=new o.PktSlotController(this,this.defaultSlot),this._isClosed=!1}render(){const s={"pkt-tag":!0,[`pkt-tag--${this.size}`]:!!this.size,[`pkt-tag--${this.skin}`]:!!this.skin,[`pkt-tag--${this.textStyle}`]:!!this.textStyle},l={"pkt-tag":!0,"pkt-btn":!0,"pkt-btn--tertiary":!0,[`pkt-tag--${this.size}`]:!!this.size,[`pkt-tag--${this.skin}`]:!!this.skin,[`pkt-tag--${this.textStyle}`]:!!this.textStyle,"pkt-btn--icons-right-and-left":this.closeTag&&!!this.iconName,"pkt-hide":this._isClosed};return this.closeTag?t.x`
|
|
2
|
+
<button
|
|
3
|
+
class=${u.e(l)}
|
|
4
|
+
type=${this.type}
|
|
5
|
+
aria-label=${this.ariaLabel}
|
|
6
|
+
@click=${this.close}
|
|
7
|
+
>
|
|
8
|
+
${this.iconName&&t.x`<pkt-icon class="pkt-tag__icon" name=${this.iconName}></pkt-icon>`}
|
|
9
|
+
<span ${o.n(this.defaultSlot)}></span>
|
|
10
|
+
<pkt-icon class="pkt-tag__close-btn" name="close"></pkt-icon>
|
|
11
|
+
</button>
|
|
12
|
+
`:t.x`
|
|
13
13
|
<span class=${u.e(s)}>
|
|
14
14
|
${this.iconName&&t.x` <pkt-icon class="pkt-tag__icon" name=${this.iconName}></pkt-icon> `}
|
|
15
|
-
<span ${o.n(this.defaultSlot)}
|
|
15
|
+
<span ${o.n(this.defaultSlot)}></span>
|
|
16
16
|
</span>
|
|
17
17
|
`}};e([t.n({type:Boolean,reflect:!0})],exports.PktTag.prototype,"closeTag",2);e([t.n({type:String,reflect:!0})],exports.PktTag.prototype,"size",2);e([t.n({type:String,reflect:!0})],exports.PktTag.prototype,"skin",2);e([t.n({type:String,reflect:!0})],exports.PktTag.prototype,"textStyle",2);e([t.n({type:String,reflect:!0})],exports.PktTag.prototype,"iconName",2);e([t.n({type:String,reflect:!0})],exports.PktTag.prototype,"type",2);e([t.n({type:String,reflect:!0})],exports.PktTag.prototype,"ariaLabel",2);e([t.r()],exports.PktTag.prototype,"_isClosed",2);exports.PktTag=e([g.t("pkt-tag")],exports.PktTag);
|
package/dist/pkt-tag.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { e as h } from "./class-map-DunDFQn7.js";
|
|
2
|
-
import { t as
|
|
3
|
-
import { r as
|
|
4
|
-
import { e as
|
|
2
|
+
import { t as d } from "./directive-Cxhakbpr.js";
|
|
3
|
+
import { r as y, P as g, x as p, n as i } from "./index-CsTujnXs.js";
|
|
4
|
+
import { e as m, P as k, n as f } from "./ref-By_W8A-f.js";
|
|
5
5
|
import "./index-CyqOyy_9.js";
|
|
6
|
-
const
|
|
6
|
+
const b = "pkt-tag", S = !0, $ = {
|
|
7
7
|
closeTag: {
|
|
8
8
|
type: "boolean",
|
|
9
9
|
required: !1,
|
|
@@ -62,58 +62,60 @@ const S = "pkt-tag", $ = {
|
|
|
62
62
|
description: "Teksten til tag"
|
|
63
63
|
}
|
|
64
64
|
}, r = {
|
|
65
|
-
name:
|
|
65
|
+
name: b,
|
|
66
66
|
"css-class": "pkt-tag",
|
|
67
|
+
isElement: S,
|
|
67
68
|
props: $,
|
|
68
69
|
slots: _
|
|
69
70
|
};
|
|
70
|
-
var x = Object.defineProperty, C = Object.getOwnPropertyDescriptor, e = (
|
|
71
|
-
for (var s = o > 1 ? void 0 : o ? C(
|
|
72
|
-
(u =
|
|
73
|
-
return o && s && x(
|
|
71
|
+
var x = Object.defineProperty, C = Object.getOwnPropertyDescriptor, e = (l, a, n, o) => {
|
|
72
|
+
for (var s = o > 1 ? void 0 : o ? C(a, n) : a, c = l.length - 1, u; c >= 0; c--)
|
|
73
|
+
(u = l[c]) && (s = (o ? u(a, n, s) : u(s)) || s);
|
|
74
|
+
return o && s && x(a, n, s), s;
|
|
74
75
|
};
|
|
75
76
|
let t = class extends g {
|
|
76
77
|
constructor() {
|
|
77
|
-
super(), this.defaultSlot =
|
|
78
|
+
super(), this.defaultSlot = m(), this.closeTag = r.props.closeTag.default, this.size = r.props.size.default, this.skin = r.props.skin.default, this.textStyle = r.props.textStyle.default, this.iconName = void 0, this.type = r.props.type.default, this.ariaLabel = r.props.ariaLabel.default, this._isClosed = !1, this.close = (l) => {
|
|
78
79
|
this._isClosed = !0, this.dispatchEvent(
|
|
79
80
|
new CustomEvent("onClose", {
|
|
80
|
-
detail: { origin:
|
|
81
|
+
detail: { origin: l },
|
|
81
82
|
bubbles: !0,
|
|
82
83
|
composed: !0
|
|
83
84
|
})
|
|
84
85
|
);
|
|
85
|
-
}, this.slotController = new
|
|
86
|
+
}, this.slotController = new k(this, this.defaultSlot), this._isClosed = !1;
|
|
86
87
|
}
|
|
87
88
|
render() {
|
|
88
|
-
const
|
|
89
|
+
const l = {
|
|
89
90
|
"pkt-tag": !0,
|
|
90
91
|
[`pkt-tag--${this.size}`]: !!this.size,
|
|
91
92
|
[`pkt-tag--${this.skin}`]: !!this.skin,
|
|
92
93
|
[`pkt-tag--${this.textStyle}`]: !!this.textStyle
|
|
93
|
-
},
|
|
94
|
+
}, a = {
|
|
94
95
|
"pkt-tag": !0,
|
|
95
96
|
"pkt-btn": !0,
|
|
96
97
|
"pkt-btn--tertiary": !0,
|
|
97
98
|
[`pkt-tag--${this.size}`]: !!this.size,
|
|
98
99
|
[`pkt-tag--${this.skin}`]: !!this.skin,
|
|
99
100
|
[`pkt-tag--${this.textStyle}`]: !!this.textStyle,
|
|
100
|
-
"pkt-btn--icons-right-and-left": this.closeTag && !!this.iconName
|
|
101
|
+
"pkt-btn--icons-right-and-left": this.closeTag && !!this.iconName,
|
|
102
|
+
"pkt-hide": this._isClosed
|
|
101
103
|
};
|
|
102
|
-
return this.closeTag ?
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
<span class=${h(
|
|
104
|
+
return this.closeTag ? p`
|
|
105
|
+
<button
|
|
106
|
+
class=${h(a)}
|
|
107
|
+
type=${this.type}
|
|
108
|
+
aria-label=${this.ariaLabel}
|
|
109
|
+
@click=${this.close}
|
|
110
|
+
>
|
|
111
|
+
${this.iconName && p`<pkt-icon class="pkt-tag__icon" name=${this.iconName}></pkt-icon>`}
|
|
112
|
+
<span ${f(this.defaultSlot)}></span>
|
|
113
|
+
<pkt-icon class="pkt-tag__close-btn" name="close"></pkt-icon>
|
|
114
|
+
</button>
|
|
115
|
+
` : p`
|
|
116
|
+
<span class=${h(l)}>
|
|
115
117
|
${this.iconName && p` <pkt-icon class="pkt-tag__icon" name=${this.iconName}></pkt-icon> `}
|
|
116
|
-
<span ${f(this.defaultSlot)}
|
|
118
|
+
<span ${f(this.defaultSlot)}></span>
|
|
117
119
|
</span>
|
|
118
120
|
`;
|
|
119
121
|
}
|
|
@@ -140,10 +142,10 @@ e([
|
|
|
140
142
|
i({ type: String, reflect: !0 })
|
|
141
143
|
], t.prototype, "ariaLabel", 2);
|
|
142
144
|
e([
|
|
143
|
-
|
|
145
|
+
y()
|
|
144
146
|
], t.prototype, "_isClosed", 2);
|
|
145
147
|
t = e([
|
|
146
|
-
|
|
148
|
+
d("pkt-tag")
|
|
147
149
|
], t);
|
|
148
150
|
export {
|
|
149
151
|
t as PktTag
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslokommune/punkt-elements",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.6.0",
|
|
4
4
|
"description": "Komponentbiblioteket til Punkt, et designsystem laget av Oslo Origo",
|
|
5
5
|
"homepage": "https://punkt.oslo.kommune.no",
|
|
6
6
|
"author": "Team Designsystem, Oslo Origo",
|
|
@@ -55,5 +55,5 @@
|
|
|
55
55
|
"url": "https://github.com/oslokommune/punkt/issues"
|
|
56
56
|
},
|
|
57
57
|
"license": "MIT",
|
|
58
|
-
"gitHead": "
|
|
58
|
+
"gitHead": "881984611d2b5537131ae1b8c6b30b367d4ba64c"
|
|
59
59
|
}
|
|
@@ -3,9 +3,21 @@ import { PktSlotController } from '@/controllers/pkt-slot-controller'
|
|
|
3
3
|
import { ref, createRef, Ref } from 'lit/directives/ref.js'
|
|
4
4
|
import { html, nothing } from 'lit'
|
|
5
5
|
import { classMap } from 'lit/directives/class-map.js'
|
|
6
|
-
import { customElement, property } from 'lit/decorators.js'
|
|
6
|
+
import { customElement, property, state } from 'lit/decorators.js'
|
|
7
|
+
import specs from 'componentSpecs/alert.json'
|
|
8
|
+
|
|
7
9
|
import '../icon'
|
|
8
10
|
|
|
11
|
+
type AlertSkin = 'error' | 'success' | 'warning' | 'info'
|
|
12
|
+
type AlertAriaLive = 'off' | 'polite' | 'assertive'
|
|
13
|
+
export interface IPktAlert {
|
|
14
|
+
skin?: AlertSkin
|
|
15
|
+
closeAlert?: boolean
|
|
16
|
+
title?: string
|
|
17
|
+
date?: string
|
|
18
|
+
ariaLive?: AlertAriaLive
|
|
19
|
+
compact?: boolean
|
|
20
|
+
}
|
|
9
21
|
@customElement('pkt-alert')
|
|
10
22
|
export class PktAlert extends PktElement {
|
|
11
23
|
defaultSlot: Ref<HTMLElement> = createRef()
|
|
@@ -13,32 +25,24 @@ export class PktAlert extends PktElement {
|
|
|
13
25
|
constructor() {
|
|
14
26
|
super()
|
|
15
27
|
this.slotController = new PktSlotController(this, this.defaultSlot)
|
|
28
|
+
this._isClosed = false
|
|
16
29
|
}
|
|
17
30
|
|
|
18
|
-
@property({ type: Boolean, reflect:
|
|
19
|
-
|
|
20
|
-
@property({ type:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
@property({ type: String, reflect: true })
|
|
25
|
-
skin: 'error' | 'success' | 'warning' | 'info' = 'info'
|
|
26
|
-
@property({ type: Boolean, reflect: true })
|
|
27
|
-
isDisplayed = true
|
|
28
|
-
@property({ type: Function, reflect: true })
|
|
29
|
-
onClose?: () => void
|
|
30
|
-
@property({ type: String, reflect: true })
|
|
31
|
-
ariaLive: 'off' | 'polite' | 'assertive' = 'polite'
|
|
32
|
-
@property({ type: Boolean, reflect: true })
|
|
33
|
-
closeAlert = false
|
|
34
|
-
@property({ type: String, reflect: true })
|
|
35
|
-
date = ''
|
|
31
|
+
@property({ type: Boolean, reflect: false }) compact = specs.props.compact.default
|
|
32
|
+
@property({ type: String, reflect: true }) title: string = ''
|
|
33
|
+
@property({ type: String, reflect: true }) skin: AlertSkin = specs.props.skin.default as AlertSkin
|
|
34
|
+
@property({ type: String, reflect: true }) ariaLive: AlertAriaLive = specs.props.ariaLive
|
|
35
|
+
.default as AlertAriaLive
|
|
36
|
+
@property({ type: Boolean, reflect: true }) closeAlert = specs.props.closeAlert.default
|
|
37
|
+
@property({ type: String, reflect: true }) date: string | null = null
|
|
36
38
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
@state() _isClosed: boolean = false
|
|
40
|
+
|
|
41
|
+
private close = (event: MouseEvent) => {
|
|
42
|
+
this._isClosed = true
|
|
43
|
+
this.dispatchEvent(
|
|
44
|
+
new CustomEvent('close', { detail: { origin: event }, bubbles: true, composed: true }),
|
|
45
|
+
)
|
|
42
46
|
}
|
|
43
47
|
|
|
44
48
|
render() {
|
|
@@ -46,11 +50,9 @@ export class PktAlert extends PktElement {
|
|
|
46
50
|
'pkt-alert': true,
|
|
47
51
|
'pkt-alert--compact': this.compact,
|
|
48
52
|
[`pkt-alert--${this.skin}`]: this.skin,
|
|
49
|
-
'pkt-
|
|
53
|
+
'pkt-hide': this._isClosed,
|
|
50
54
|
}
|
|
51
55
|
|
|
52
|
-
if (!this.isDisplayed) return nothing
|
|
53
|
-
|
|
54
56
|
return html`
|
|
55
57
|
<div class=${classMap(classes)} aria-live=${this.ariaLive}>
|
|
56
58
|
<pkt-icon
|
|
@@ -58,7 +60,7 @@ export class PktAlert extends PktElement {
|
|
|
58
60
|
name=${this.skin === 'info' ? 'alert-information' : `alert-${this.skin}`}
|
|
59
61
|
></pkt-icon>
|
|
60
62
|
|
|
61
|
-
${this.
|
|
63
|
+
${this.closeAlert
|
|
62
64
|
? html`
|
|
63
65
|
<div class="pkt-alert__close">
|
|
64
66
|
<button
|
|
@@ -66,7 +68,7 @@ export class PktAlert extends PktElement {
|
|
|
66
68
|
class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only"
|
|
67
69
|
tabindex="0"
|
|
68
70
|
aria-label="close"
|
|
69
|
-
@click=${this.
|
|
71
|
+
@click=${this.close}
|
|
70
72
|
>
|
|
71
73
|
<pkt-icon name="close" class="pkt-btn__icon" aria-hidden="true"></pkt-icon>
|
|
72
74
|
</button>
|
package/src/components/index.ts
CHANGED
|
@@ -3,9 +3,20 @@ import { PktSlotController } from '../../controllers/pkt-slot-controller'
|
|
|
3
3
|
import { ref, createRef, Ref } from 'lit/directives/ref.js'
|
|
4
4
|
import { html, nothing } from 'lit'
|
|
5
5
|
import { classMap } from 'lit/directives/class-map.js'
|
|
6
|
-
import { customElement, property } from 'lit/decorators.js'
|
|
6
|
+
import { customElement, property, state } from 'lit/decorators.js'
|
|
7
|
+
import specs from 'componentSpecs/messagebox.json'
|
|
8
|
+
|
|
7
9
|
import '../icon'
|
|
8
10
|
|
|
11
|
+
type MessageboxSkin = 'error' | 'success' | 'warning' | 'info'
|
|
12
|
+
|
|
13
|
+
export interface IPktMessagebox {
|
|
14
|
+
skin?: MessageboxSkin
|
|
15
|
+
title?: string
|
|
16
|
+
compact?: boolean
|
|
17
|
+
closable?: boolean
|
|
18
|
+
}
|
|
19
|
+
|
|
9
20
|
@customElement('pkt-messagebox')
|
|
10
21
|
export class PktMessagebox extends PktElement {
|
|
11
22
|
defaultSlot: Ref<HTMLElement> = createRef()
|
|
@@ -13,26 +24,19 @@ export class PktMessagebox extends PktElement {
|
|
|
13
24
|
constructor() {
|
|
14
25
|
super()
|
|
15
26
|
this.slotController = new PktSlotController(this, this.defaultSlot)
|
|
27
|
+
this._isClosed = false
|
|
16
28
|
}
|
|
17
29
|
|
|
18
|
-
@property({ type: Boolean, reflect: true })
|
|
19
|
-
|
|
20
|
-
@property({ type:
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
@property({ type: Function, reflect: true })
|
|
29
|
-
onClose?: () => void
|
|
30
|
-
|
|
31
|
-
handleClose() {
|
|
32
|
-
this.isDisplayed = false
|
|
33
|
-
if (this.onClose) {
|
|
34
|
-
this.onClose()
|
|
35
|
-
}
|
|
30
|
+
@property({ type: Boolean, reflect: true }) closable = specs.props.closable.default
|
|
31
|
+
@property({ type: Boolean, reflect: true }) compact = specs.props.compact.default
|
|
32
|
+
@property({ type: String, reflect: true }) title = ''
|
|
33
|
+
@property({ type: String, reflect: true }) skin = specs.props.skin.default as MessageboxSkin
|
|
34
|
+
|
|
35
|
+
@state() _isClosed: boolean = false
|
|
36
|
+
|
|
37
|
+
private close = (event: MouseEvent) => {
|
|
38
|
+
this._isClosed = true
|
|
39
|
+
this.dispatchEvent(new CustomEvent('close', { detail: { origin: event }, bubbles: true }))
|
|
36
40
|
}
|
|
37
41
|
|
|
38
42
|
render() {
|
|
@@ -41,15 +45,14 @@ export class PktMessagebox extends PktElement {
|
|
|
41
45
|
'pkt-messagebox--compact': this.compact,
|
|
42
46
|
[`pkt-messagebox--${this.skin}`]: this.skin,
|
|
43
47
|
'pkt-messagebox--closable': this.closable,
|
|
48
|
+
'pkt-hide': this._isClosed,
|
|
44
49
|
}
|
|
45
50
|
|
|
46
|
-
if (!this.isDisplayed) return nothing
|
|
47
|
-
|
|
48
51
|
return html`<div class=${classMap(classes)}>
|
|
49
52
|
${this.closable
|
|
50
53
|
? html`<div class="pkt-messagebox__close">
|
|
51
54
|
<button
|
|
52
|
-
@click=${this.
|
|
55
|
+
@click=${this.close}
|
|
53
56
|
class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only"
|
|
54
57
|
>
|
|
55
58
|
<pkt-icon name="close" class="pkt-link__icon"></pkt-icon>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { classMap } from 'lit/directives/class-map.js'
|
|
2
2
|
import { customElement, property, state } from 'lit/decorators.js'
|
|
3
|
-
import { html
|
|
3
|
+
import { html } from 'lit'
|
|
4
4
|
import { PktElement } from '../element'
|
|
5
5
|
import { PktSlotController } from '@/controllers/pkt-slot-controller'
|
|
6
6
|
import { ref } from 'lit/directives/ref.js'
|
|
@@ -10,15 +10,16 @@ import specs from 'componentSpecs/tag.json'
|
|
|
10
10
|
import '../icon'
|
|
11
11
|
|
|
12
12
|
type TagSize = 'small' | 'medium' | 'large'
|
|
13
|
-
type TagSkin = 'blue' | 'green' | 'red' | 'yellow'
|
|
13
|
+
type TagSkin = 'blue' | 'green' | 'red' | 'yellow' | 'beige' | 'blue-light' | 'gray' | 'grey'
|
|
14
|
+
type TagType = 'button' | 'reset' | 'submit'
|
|
14
15
|
|
|
15
16
|
export interface IPktTag {
|
|
16
17
|
closeTag?: boolean
|
|
17
18
|
size?: TagSize
|
|
18
|
-
skin?:
|
|
19
|
+
skin?: TagSkin
|
|
19
20
|
textStyle?: string
|
|
20
21
|
iconName?: string
|
|
21
|
-
type?:
|
|
22
|
+
type?: TagType
|
|
22
23
|
ariaLabel?: string
|
|
23
24
|
}
|
|
24
25
|
|
|
@@ -41,7 +42,7 @@ export class PktTag extends PktElement {
|
|
|
41
42
|
@property({ type: String, reflect: true }) skin: TagSkin = specs.props.skin.default as TagSkin
|
|
42
43
|
@property({ type: String, reflect: true }) textStyle: string = specs.props.textStyle.default
|
|
43
44
|
@property({ type: String, reflect: true }) iconName: string | undefined = undefined
|
|
44
|
-
@property({ type: String, reflect: true }) type:
|
|
45
|
+
@property({ type: String, reflect: true }) type: TagType = specs.props.type.default as TagType
|
|
45
46
|
@property({ type: String, reflect: true }) ariaLabel: string = specs.props.ariaLabel.default
|
|
46
47
|
|
|
47
48
|
/**
|
|
@@ -79,30 +80,29 @@ export class PktTag extends PktElement {
|
|
|
79
80
|
[`pkt-tag--${this.skin}`]: !!this.skin,
|
|
80
81
|
[`pkt-tag--${this.textStyle}`]: !!this.textStyle,
|
|
81
82
|
'pkt-btn--icons-right-and-left': this.closeTag && !!this.iconName,
|
|
83
|
+
'pkt-hide': this._isClosed,
|
|
82
84
|
}
|
|
83
85
|
|
|
84
86
|
if (this.closeTag) {
|
|
85
|
-
return
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
`
|
|
99
|
-
: nothing
|
|
87
|
+
return html`
|
|
88
|
+
<button
|
|
89
|
+
class=${classMap(btnClasses)}
|
|
90
|
+
type=${this.type}
|
|
91
|
+
aria-label=${this.ariaLabel}
|
|
92
|
+
@click=${this.close}
|
|
93
|
+
>
|
|
94
|
+
${this.iconName &&
|
|
95
|
+
html`<pkt-icon class="pkt-tag__icon" name=${this.iconName}></pkt-icon>`}
|
|
96
|
+
<span ${ref(this.defaultSlot)}></span>
|
|
97
|
+
<pkt-icon class="pkt-tag__close-btn" name="close"></pkt-icon>
|
|
98
|
+
</button>
|
|
99
|
+
`
|
|
100
100
|
} else {
|
|
101
101
|
return html`
|
|
102
102
|
<span class=${classMap(classes)}>
|
|
103
103
|
${this.iconName &&
|
|
104
104
|
html` <pkt-icon class="pkt-tag__icon" name=${this.iconName}></pkt-icon> `}
|
|
105
|
-
<span ${ref(this.defaultSlot)}
|
|
105
|
+
<span ${ref(this.defaultSlot)}></span>
|
|
106
106
|
</span>
|
|
107
107
|
`
|
|
108
108
|
}
|