@oslokommune/punkt-elements 12.5.2 → 12.6.1

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 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?: 'blue' | 'green' | 'red' | 'yellow';
20
+ skin?: TagSkin;
18
21
  textStyle?: string;
19
22
  iconName?: string;
20
- type?: string;
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: string;
359
- isDisplayed: boolean;
360
- onClose?: () => void;
361
- handleClose(): void;
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: string;
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> | typeof nothing;
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 { }
@@ -1,18 +1,18 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./index-DSyh6tUw.cjs"),p=require("./ref-C3InMDfU.cjs"),c=require("./class-map-Ch54kkX5.cjs"),k=require("./directive-DtixNHDT.cjs");require("./index-Bpc07w_P.cjs");var h=Object.defineProperty,u=Object.getOwnPropertyDescriptor,e=(s,r,o,i)=>{for(var l=i>1?void 0:i?u(r,o):r,a=s.length-1,n;a>=0;a--)(n=s[a])&&(l=(i?n(r,o,l):n(l))||l);return i&&l&&h(r,o,l),l};exports.PktAlert=class extends t.PktElement{constructor(){super(),this.defaultSlot=p.e(),this.closable=!1,this.compact=!1,this.title="",this.skin="info",this.isDisplayed=!0,this.ariaLive="polite",this.closeAlert=!1,this.date="",this.slotController=new p.PktSlotController(this,this.defaultSlot)}handleClose(){this.isDisplayed=!1,this.onClose&&this.onClose()}render(){const r={"pkt-alert":!0,"pkt-alert--compact":this.compact,[`pkt-alert--${this.skin}`]:this.skin,"pkt-alert--closable":this.closable};return this.isDisplayed?t.x`
2
- <div class=${c.e(r)} aria-live=${this.ariaLive}>
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",m=!0,f={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:m,events:f,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.dispatchEvent(new CustomEvent("on-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.closable?t.x`
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.handleClose}
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" ${p.n(this.defaultSlot)}></div>
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
- `:t.E}};e([t.n({type:Boolean,reflect:!0})],exports.PktAlert.prototype,"closable",2);e([t.n({type:Boolean,reflect:!0})],exports.PktAlert.prototype,"compact",2);e([t.n({type:String,reflect:!0})],exports.PktAlert.prototype,"title",2);e([t.n({type:String,reflect:!0})],exports.PktAlert.prototype,"skin",2);e([t.n({type:Boolean,reflect:!0})],exports.PktAlert.prototype,"isDisplayed",2);e([t.n({type:Function,reflect:!0})],exports.PktAlert.prototype,"onClose",2);e([t.n({type:String,reflect:!0})],exports.PktAlert.prototype,"ariaLive",2);e([t.n({type:Boolean,reflect:!0})],exports.PktAlert.prototype,"closeAlert",2);e([t.n({type:String,reflect:!0})],exports.PktAlert.prototype,"date",2);exports.PktAlert=e([k.t("pkt-alert")],exports.PktAlert);
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,146 @@
1
- import { P as f, E as a, x as p, n as s } from "./index-CsTujnXs.js";
2
- import { e as d, P as u, n as y } from "./ref-By_W8A-f.js";
3
- import { e as k } from "./class-map-DunDFQn7.js";
4
- import { t as v } from "./directive-Cxhakbpr.js";
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 h, n as v } 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
- var m = Object.defineProperty, _ = Object.getOwnPropertyDescriptor, e = (l, r, n, o) => {
7
- for (var i = o > 1 ? void 0 : o ? _(r, n) : r, c = l.length - 1, h; c >= 0; c--)
8
- (h = l[c]) && (i = (o ? h(r, n, i) : h(i)) || i);
9
- return o && i && m(r, n, i), i;
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
- let t = class extends f {
70
+ var L = Object.defineProperty, P = Object.getOwnPropertyDescriptor, e = (s, r, p, l) => {
71
+ for (var i = l > 1 ? void 0 : l ? P(r, p) : r, c = s.length - 1, d; c >= 0; c--)
72
+ (d = s[c]) && (i = (l ? d(r, p, i) : d(i)) || i);
73
+ return l && i && L(r, p, i), i;
74
+ };
75
+ let t = class extends u {
12
76
  constructor() {
13
- super(), this.defaultSlot = d(), this.closable = !1, this.compact = !1, this.title = "", this.skin = "info", this.isDisplayed = !0, this.ariaLive = "polite", this.closeAlert = !1, this.date = "", this.slotController = new u(this, this.defaultSlot);
14
- }
15
- handleClose() {
16
- this.isDisplayed = !1, this.onClose && this.onClose();
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 = (s) => {
78
+ this._isClosed = !0, this.dispatchEvent(
79
+ new CustomEvent("close", { detail: { origin: s }, bubbles: !0, composed: !0 })
80
+ ), this.dispatchEvent(
81
+ new CustomEvent("on-close", { detail: { origin: s }, bubbles: !0, composed: !0 })
82
+ );
83
+ }, this.slotController = new h(this, this.defaultSlot), this._isClosed = !1;
17
84
  }
18
85
  render() {
19
- const l = {
86
+ const s = {
20
87
  "pkt-alert": !0,
21
88
  "pkt-alert--compact": this.compact,
22
89
  [`pkt-alert--${this.skin}`]: this.skin,
23
- "pkt-alert--closable": this.closable
90
+ "pkt-hide": this._isClosed
24
91
  };
25
- return this.isDisplayed ? p`
26
- <div class=${k(l)} aria-live=${this.ariaLive}>
92
+ return n`
93
+ <div class=${y(s)} aria-live=${this.ariaLive}>
27
94
  <pkt-icon
28
95
  class="pkt-alert__icon"
29
96
  name=${this.skin === "info" ? "alert-information" : `alert-${this.skin}`}
30
97
  ></pkt-icon>
31
98
 
32
- ${this.closable ? p`
99
+ ${this.closeAlert ? n`
33
100
  <div class="pkt-alert__close">
34
101
  <button
35
102
  type="button"
36
103
  class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only"
37
104
  tabindex="0"
38
105
  aria-label="close"
39
- @click=${this.handleClose}
106
+ @click=${this.close}
40
107
  >
41
108
  <pkt-icon name="close" class="pkt-btn__icon" aria-hidden="true"></pkt-icon>
42
109
  </button>
43
110
  </div>
44
- ` : a}
45
- ${this.title ? p`<div class="pkt-alert__title">${this.title}</div>` : a}
111
+ ` : k}
112
+ ${this.title ? n`<div class="pkt-alert__title">${this.title}</div>` : k}
46
113
 
47
- <div class="pkt-alert__text" ${y(this.defaultSlot)}></div>
114
+ <div class="pkt-alert__text" ${v(this.defaultSlot)}></div>
48
115
 
49
- ${this.date ? p`<div class="pkt-alert__date">Sist oppdatert: ${this.date}</div>` : a}
116
+ ${this.date ? n`<div class="pkt-alert__date">Sist oppdatert: ${this.date}</div>` : k}
50
117
  </div>
51
- ` : a;
118
+ `;
52
119
  }
53
120
  };
54
121
  e([
55
- s({ type: Boolean, reflect: !0 })
56
- ], t.prototype, "closable", 2);
57
- e([
58
- s({ type: Boolean, reflect: !0 })
122
+ o({ type: Boolean, reflect: !1 })
59
123
  ], t.prototype, "compact", 2);
60
124
  e([
61
- s({ type: String, reflect: !0 })
125
+ o({ type: String, reflect: !0 })
62
126
  ], t.prototype, "title", 2);
63
127
  e([
64
- s({ type: String, reflect: !0 })
128
+ o({ type: String, reflect: !0 })
65
129
  ], t.prototype, "skin", 2);
66
130
  e([
67
- s({ type: Boolean, reflect: !0 })
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 })
131
+ o({ type: String, reflect: !0 })
74
132
  ], t.prototype, "ariaLive", 2);
75
133
  e([
76
- s({ type: Boolean, reflect: !0 })
134
+ o({ type: Boolean, reflect: !0 })
77
135
  ], t.prototype, "closeAlert", 2);
78
136
  e([
79
- s({ type: String, reflect: !0 })
137
+ o({ type: String, reflect: !0 })
80
138
  ], t.prototype, "date", 2);
139
+ e([
140
+ m()
141
+ ], t.prototype, "_isClosed", 2);
81
142
  t = e([
82
- v("pkt-alert")
143
+ _("pkt-alert")
83
144
  ], t);
84
145
  export {
85
146
  t as PktAlert
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./index-BNOnscrA.cjs"),t=require("./pkt-card.cjs"),r=require("./pkt-component-template.cjs"),n=require("./pkt-datepicker.cjs"),o=require("./index-Bpc07w_P.cjs"),a=require("./pkt-input-wrapper.cjs"),u=require("./pkt-link.cjs"),c=require("./pkt-messagebox.cjs"),i=require("./pkt-tag.cjs");Object.defineProperty(exports,"PktCalendar",{enumerable:!0,get:()=>e.PktCalendar});Object.defineProperty(exports,"PktCard",{enumerable:!0,get:()=>t.PktCard});Object.defineProperty(exports,"PktComponent",{enumerable:!0,get:()=>r.PktComponent});Object.defineProperty(exports,"PktDatepicker",{enumerable:!0,get:()=>n.PktDatepicker});Object.defineProperty(exports,"PktIcon",{enumerable:!0,get:()=>o.PktIcon});Object.defineProperty(exports,"PktInputWrapper",{enumerable:!0,get:()=>a.PktInputWrapper});Object.defineProperty(exports,"PktLink",{enumerable:!0,get:()=>u.PktLink});Object.defineProperty(exports,"PktMessagebox",{enumerable:!0,get:()=>c.PktMessagebox});Object.defineProperty(exports,"PktTag",{enumerable:!0,get:()=>i.PktTag});
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 { P as t } from "./index-BI6-RUqp.js";
2
- import { PktCard as p } from "./pkt-card.js";
3
- import { PktComponent as P } from "./pkt-component-template.js";
4
- import { PktDatepicker as x } from "./pkt-datepicker.js";
5
- import { P as f } from "./index-CyqOyy_9.js";
6
- import { PktInputWrapper as s } from "./pkt-input-wrapper.js";
7
- import { PktLink as c } from "./pkt-link.js";
8
- import { PktMessagebox as g } from "./pkt-messagebox.js";
9
- import { PktTag as I } from "./pkt-tag.js";
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 PktCalendar,
12
- p as PktCard,
13
- P as PktComponent,
14
- x as PktDatepicker,
15
- f as PktIcon,
16
- s as PktInputWrapper,
17
- c as PktLink,
18
- g as PktMessagebox,
19
- I as PktTag
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
  };
@@ -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"),p=require("./class-map-Ch54kkX5.cjs"),b=require("./directive-DtixNHDT.cjs");require("./index-Bpc07w_P.cjs");var k=Object.defineProperty,u=Object.getOwnPropertyDescriptor,s=(i,o,r,l)=>{for(var t=l>1?void 0:l?u(o,r):o,a=i.length-1,n;a>=0;a--)(n=i[a])&&(t=(l?n(o,r,t):n(t))||t);return l&&t&&k(o,r,t),t};exports.PktMessagebox=class extends e.PktElement{constructor(){super(),this.defaultSlot=c.e(),this.closable=!1,this.compact=!1,this.title="",this.skin="beige",this.isDisplayed=!0,this.slotController=new c.PktSlotController(this,this.defaultSlot)}handleClose(){this.isDisplayed=!1,this.onClose&&this.onClose()}render(){const o={"pkt-messagebox":!0,"pkt-messagebox--compact":this.compact,[`pkt-messagebox--${this.skin}`]:this.skin,"pkt-messagebox--closable":this.closable};return this.isDisplayed?e.x`<div class=${p.e(o)}>
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"),d=require("./directive-DtixNHDT.cjs");require("./index-Bpc07w_P.cjs");const k="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:k,"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.dispatchEvent(new CustomEvent("on-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.handleClose}
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>`:e.E}};s([e.n({type:Boolean,reflect:!0})],exports.PktMessagebox.prototype,"closable",2);s([e.n({type:Boolean,reflect:!0})],exports.PktMessagebox.prototype,"compact",2);s([e.n({type:String,reflect:!0})],exports.PktMessagebox.prototype,"title",2);s([e.n({type:String,reflect:!0})],exports.PktMessagebox.prototype,"skin",2);s([e.n({type:Boolean,reflect:!0})],exports.PktMessagebox.prototype,"isDisplayed",2);s([e.n({type:Function,reflect:!0})],exports.PktMessagebox.prototype,"onClose",2);exports.PktMessagebox=s([b.t("pkt-messagebox")],exports.PktMessagebox);
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([d.t("pkt-messagebox")],exports.PktMessagebox);
@@ -1,62 +1,107 @@
1
- import { P as m, E as c, x as h, n as o } from "./index-CsTujnXs.js";
2
- import { e as b, P as f, n as u } from "./ref-By_W8A-f.js";
3
- import { e as k } from "./class-map-DunDFQn7.js";
4
- import { t as y } from "./directive-Cxhakbpr.js";
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 h } from "./ref-By_W8A-f.js";
3
+ import { e as f } from "./class-map-DunDFQn7.js";
4
+ import { t as v } from "./directive-Cxhakbpr.js";
5
5
  import "./index-CyqOyy_9.js";
6
- var d = Object.defineProperty, v = Object.getOwnPropertyDescriptor, s = (l, i, p, r) => {
7
- for (var e = r > 1 ? void 0 : r ? v(i, p) : i, a = l.length - 1, n; a >= 0; a--)
8
- (n = l[a]) && (e = (r ? n(i, p, e) : n(e)) || e);
9
- return r && e && d(i, p, e), e;
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
+ }, E = {
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: E
10
53
  };
11
- let t = class extends m {
54
+ var P = Object.defineProperty, $ = Object.getOwnPropertyDescriptor, o = (e, l, p, i) => {
55
+ for (var t = i > 1 ? void 0 : i ? $(l, p) : l, r = e.length - 1, a; r >= 0; r--)
56
+ (a = e[r]) && (t = (i ? a(l, p, t) : a(t)) || t);
57
+ return i && t && P(l, p, t), t;
58
+ };
59
+ let s = class extends k {
12
60
  constructor() {
13
- super(), this.defaultSlot = b(), this.closable = !1, this.compact = !1, this.title = "", this.skin = "beige", this.isDisplayed = !0, this.slotController = new f(this, this.defaultSlot);
14
- }
15
- handleClose() {
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 = (e) => {
62
+ this._isClosed = !0, this.dispatchEvent(new CustomEvent("close", { detail: { origin: e }, bubbles: !0 })), this.dispatchEvent(new CustomEvent("on-close", { detail: { origin: e }, bubbles: !0 }));
63
+ }, this.slotController = new g(this, this.defaultSlot), this._isClosed = !1;
17
64
  }
18
65
  render() {
19
- const l = {
66
+ const e = {
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 this.isDisplayed ? h`<div class=${k(l)}>
26
- ${this.closable ? h`<div class="pkt-messagebox__close">
73
+ return c`<div class=${f(e)}>
74
+ ${this.closable ? c`<div class="pkt-messagebox__close">
27
75
  <button
28
- @click=${this.handleClose}
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>` : c}
34
- ${this.title ? h`<div class="pkt-messagebox__title">${this.title}</div>` : c}
35
- <div class="pkt-messagebox__text" ${u(this.defaultSlot)}></div>
36
- </div>` : c;
81
+ </div>` : d}
82
+ ${this.title ? c`<div class="pkt-messagebox__title">${this.title}</div>` : d}
83
+ <div class="pkt-messagebox__text" ${h(this.defaultSlot)}></div>
84
+ </div>`;
37
85
  }
38
86
  };
39
- s([
40
- o({ type: Boolean, reflect: !0 })
41
- ], t.prototype, "closable", 2);
42
- s([
43
- o({ type: Boolean, reflect: !0 })
44
- ], t.prototype, "compact", 2);
45
- s([
46
- o({ type: String, reflect: !0 })
47
- ], t.prototype, "title", 2);
48
- s([
49
- o({ type: String, reflect: !0 })
50
- ], t.prototype, "skin", 2);
51
- s([
52
- o({ type: Boolean, reflect: !0 })
53
- ], t.prototype, "isDisplayed", 2);
54
- s([
55
- o({ type: Function, reflect: !0 })
56
- ], t.prototype, "onClose", 2);
57
- t = s([
58
- y("pkt-messagebox")
59
- ], t);
87
+ o([
88
+ n({ type: Boolean, reflect: !0 })
89
+ ], s.prototype, "closable", 2);
90
+ o([
91
+ n({ type: Boolean, reflect: !0 })
92
+ ], s.prototype, "compact", 2);
93
+ o([
94
+ n({ type: String, reflect: !0 })
95
+ ], s.prototype, "title", 2);
96
+ o([
97
+ n({ type: String, reflect: !0 })
98
+ ], s.prototype, "skin", 2);
99
+ o([
100
+ b()
101
+ ], s.prototype, "_isClosed", 2);
102
+ s = o([
103
+ v("pkt-messagebox")
104
+ ], s);
60
105
  export {
61
- t as PktMessagebox
106
+ s as PktMessagebox
62
107
  };
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"}},k={default:{description:"Teksten til tag"}},a={name:h,"css-class":"pkt-tag",props:f,slots:k};var d=Object.defineProperty,y=Object.getOwnPropertyDescriptor,e=(n,s,r,l)=>{for(var i=l>1?void 0:l?y(s,r):s,p=n.length-1,c;p>=0;p--)(c=n[p])&&(i=(l?c(s,r,i):c(i))||i);return l&&i&&d(s,r,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},r={"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};return this.closeTag?this._isClosed?t.E:t.x`
2
- <button
3
- class=${u.e(r)}
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
- <span class=${u.e(s)}>
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",d=!0,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"}},k={default:{description:"Teksten til tag"}},a={name:h,"css-class":"pkt-tag",isElement:d,props:f,slots:k};var y=Object.defineProperty,b=Object.getOwnPropertyDescriptor,s=(n,e,l,r)=>{for(var i=r>1?void 0:r?b(e,l):e,p=n.length-1,c;p>=0;p--)(c=n[p])&&(i=(r?c(e,l,i):c(i))||i);return r&&i&&y(e,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=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 o.PktSlotController(this,this.defaultSlot),this._isClosed=!1}render(){const e={"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
+ <span class=${u.e(e)}>
14
14
  ${this.iconName&&t.x` <pkt-icon class="pkt-tag__icon" name=${this.iconName}></pkt-icon> `}
15
- <span ${o.n(this.defaultSlot)}> </span>
15
+ <span ${o.n(this.defaultSlot)}></span>
16
16
  </span>
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);
17
+ `}};s([t.n({type:Boolean,reflect:!0})],exports.PktTag.prototype,"closeTag",2);s([t.n({type:String,reflect:!0})],exports.PktTag.prototype,"size",2);s([t.n({type:String,reflect:!0})],exports.PktTag.prototype,"skin",2);s([t.n({type:String,reflect:!0})],exports.PktTag.prototype,"textStyle",2);s([t.n({type:String,reflect:!0})],exports.PktTag.prototype,"iconName",2);s([t.n({type:String,reflect:!0})],exports.PktTag.prototype,"type",2);s([t.n({type:String,reflect:!0})],exports.PktTag.prototype,"ariaLabel",2);s([t.r()],exports.PktTag.prototype,"_isClosed",2);exports.PktTag=s([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 y } from "./directive-Cxhakbpr.js";
3
- import { r as d, P as g, x as p, E as m, n as i } from "./index-CsTujnXs.js";
4
- import { e as k, P as b, n as f } from "./ref-By_W8A-f.js";
2
+ import { t as d } from "./directive-Cxhakbpr.js";
3
+ import { r as y, P as g, x as p, n as l } 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 S = "pkt-tag", $ = {
6
+ const b = "pkt-tag", S = !0, $ = {
7
7
  closeTag: {
8
8
  type: "boolean",
9
9
  required: !1,
@@ -62,88 +62,88 @@ const S = "pkt-tag", $ = {
62
62
  description: "Teksten til tag"
63
63
  }
64
64
  }, r = {
65
- name: S,
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 = (a, l, n, o) => {
71
- for (var s = o > 1 ? void 0 : o ? C(l, n) : l, c = a.length - 1, u; c >= 0; c--)
72
- (u = a[c]) && (s = (o ? u(l, n, s) : u(s)) || s);
73
- return o && s && x(l, n, s), s;
71
+ var x = Object.defineProperty, C = Object.getOwnPropertyDescriptor, e = (s, o, n, a) => {
72
+ for (var i = a > 1 ? void 0 : a ? C(o, n) : o, c = s.length - 1, u; c >= 0; c--)
73
+ (u = s[c]) && (i = (a ? u(o, n, i) : u(i)) || i);
74
+ return a && i && x(o, n, i), i;
74
75
  };
75
76
  let t = class extends g {
76
77
  constructor() {
77
- super(), this.defaultSlot = k(), 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 = (a) => {
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 = (s) => {
78
79
  this._isClosed = !0, this.dispatchEvent(
79
- new CustomEvent("onClose", {
80
- detail: { origin: a },
81
- bubbles: !0,
82
- composed: !0
83
- })
80
+ new CustomEvent("close", { detail: { origin: s }, bubbles: !0, composed: !0 })
81
+ ), this.dispatchEvent(
82
+ new CustomEvent("on-close", { detail: { origin: s }, bubbles: !0, composed: !0 })
84
83
  );
85
- }, this.slotController = new b(this, this.defaultSlot), this._isClosed = !1;
84
+ }, this.slotController = new k(this, this.defaultSlot), this._isClosed = !1;
86
85
  }
87
86
  render() {
88
- const a = {
87
+ const s = {
89
88
  "pkt-tag": !0,
90
89
  [`pkt-tag--${this.size}`]: !!this.size,
91
90
  [`pkt-tag--${this.skin}`]: !!this.skin,
92
91
  [`pkt-tag--${this.textStyle}`]: !!this.textStyle
93
- }, l = {
92
+ }, o = {
94
93
  "pkt-tag": !0,
95
94
  "pkt-btn": !0,
96
95
  "pkt-btn--tertiary": !0,
97
96
  [`pkt-tag--${this.size}`]: !!this.size,
98
97
  [`pkt-tag--${this.skin}`]: !!this.skin,
99
98
  [`pkt-tag--${this.textStyle}`]: !!this.textStyle,
100
- "pkt-btn--icons-right-and-left": this.closeTag && !!this.iconName
99
+ "pkt-btn--icons-right-and-left": this.closeTag && !!this.iconName,
100
+ "pkt-hide": this._isClosed
101
101
  };
102
- return this.closeTag ? this._isClosed ? m : p`
103
- <button
104
- class=${h(l)}
105
- type=${this.type}
106
- aria-label=${this.ariaLabel}
107
- @click=${this.close}
108
- >
109
- ${this.iconName && p`<pkt-icon class="pkt-tag__icon" name=${this.iconName}></pkt-icon>`}
110
- <span ${f(this.defaultSlot)}></span>
111
- <pkt-icon class="pkt-tag__close-btn" name="close"></pkt-icon>
112
- </button>
113
- ` : p`
114
- <span class=${h(a)}>
102
+ return this.closeTag ? p`
103
+ <button
104
+ class=${h(o)}
105
+ type=${this.type}
106
+ aria-label=${this.ariaLabel}
107
+ @click=${this.close}
108
+ >
109
+ ${this.iconName && p`<pkt-icon class="pkt-tag__icon" name=${this.iconName}></pkt-icon>`}
110
+ <span ${f(this.defaultSlot)}></span>
111
+ <pkt-icon class="pkt-tag__close-btn" name="close"></pkt-icon>
112
+ </button>
113
+ ` : p`
114
+ <span class=${h(s)}>
115
115
  ${this.iconName && p` <pkt-icon class="pkt-tag__icon" name=${this.iconName}></pkt-icon> `}
116
- <span ${f(this.defaultSlot)}> </span>
116
+ <span ${f(this.defaultSlot)}></span>
117
117
  </span>
118
118
  `;
119
119
  }
120
120
  };
121
121
  e([
122
- i({ type: Boolean, reflect: !0 })
122
+ l({ type: Boolean, reflect: !0 })
123
123
  ], t.prototype, "closeTag", 2);
124
124
  e([
125
- i({ type: String, reflect: !0 })
125
+ l({ type: String, reflect: !0 })
126
126
  ], t.prototype, "size", 2);
127
127
  e([
128
- i({ type: String, reflect: !0 })
128
+ l({ type: String, reflect: !0 })
129
129
  ], t.prototype, "skin", 2);
130
130
  e([
131
- i({ type: String, reflect: !0 })
131
+ l({ type: String, reflect: !0 })
132
132
  ], t.prototype, "textStyle", 2);
133
133
  e([
134
- i({ type: String, reflect: !0 })
134
+ l({ type: String, reflect: !0 })
135
135
  ], t.prototype, "iconName", 2);
136
136
  e([
137
- i({ type: String, reflect: !0 })
137
+ l({ type: String, reflect: !0 })
138
138
  ], t.prototype, "type", 2);
139
139
  e([
140
- i({ type: String, reflect: !0 })
140
+ l({ type: String, reflect: !0 })
141
141
  ], t.prototype, "ariaLabel", 2);
142
142
  e([
143
- d()
143
+ y()
144
144
  ], t.prototype, "_isClosed", 2);
145
145
  t = e([
146
- y("pkt-tag")
146
+ d("pkt-tag")
147
147
  ], t);
148
148
  export {
149
149
  t as PktTag
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oslokommune/punkt-elements",
3
- "version": "12.5.2",
3
+ "version": "12.6.1",
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": "424129e45652c610b061e04186913ce42d62ead6"
58
+ "gitHead": "e78bdc25bb42e54f1b52c4f8bda44d8899219ec4"
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,28 @@ 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: true })
19
- closable = false
20
- @property({ type: Boolean, reflect: true })
21
- compact = false
22
- @property({ type: String, reflect: true })
23
- title = ''
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
- private handleClose() {
38
- this.isDisplayed = false
39
- if (this.onClose) {
40
- this.onClose()
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
+ )
46
+ // Historical support of old Vue implementations…
47
+ this.dispatchEvent(
48
+ new CustomEvent('on-close', { detail: { origin: event }, bubbles: true, composed: true }),
49
+ )
42
50
  }
43
51
 
44
52
  render() {
@@ -46,11 +54,9 @@ export class PktAlert extends PktElement {
46
54
  'pkt-alert': true,
47
55
  'pkt-alert--compact': this.compact,
48
56
  [`pkt-alert--${this.skin}`]: this.skin,
49
- 'pkt-alert--closable': this.closable,
57
+ 'pkt-hide': this._isClosed,
50
58
  }
51
59
 
52
- if (!this.isDisplayed) return nothing
53
-
54
60
  return html`
55
61
  <div class=${classMap(classes)} aria-live=${this.ariaLive}>
56
62
  <pkt-icon
@@ -58,7 +64,7 @@ export class PktAlert extends PktElement {
58
64
  name=${this.skin === 'info' ? 'alert-information' : `alert-${this.skin}`}
59
65
  ></pkt-icon>
60
66
 
61
- ${this.closable
67
+ ${this.closeAlert
62
68
  ? html`
63
69
  <div class="pkt-alert__close">
64
70
  <button
@@ -66,7 +72,7 @@ export class PktAlert extends PktElement {
66
72
  class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only"
67
73
  tabindex="0"
68
74
  aria-label="close"
69
- @click=${this.handleClose}
75
+ @click=${this.close}
70
76
  >
71
77
  <pkt-icon name="close" class="pkt-btn__icon" aria-hidden="true"></pkt-icon>
72
78
  </button>
@@ -1,3 +1,4 @@
1
+ export { PktAlert } from './alert'
1
2
  export { PktCalendar } from './calendar'
2
3
  export { PktCard } from './card'
3
4
  export { PktComponent } from './component-template'
@@ -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,21 @@ 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
- closable = false
20
- @property({ type: Boolean, reflect: true })
21
- compact = false
22
- @property({ type: String, reflect: true })
23
- title = ''
24
- @property({ type: String, reflect: true })
25
- skin = 'beige'
26
- @property({ type: Boolean, reflect: true })
27
- isDisplayed = true
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 }))
40
+ // Historical support of old Vue implementations…
41
+ this.dispatchEvent(new CustomEvent('on-close', { detail: { origin: event }, bubbles: true }))
36
42
  }
37
43
 
38
44
  render() {
@@ -41,15 +47,14 @@ export class PktMessagebox extends PktElement {
41
47
  'pkt-messagebox--compact': this.compact,
42
48
  [`pkt-messagebox--${this.skin}`]: this.skin,
43
49
  'pkt-messagebox--closable': this.closable,
50
+ 'pkt-hide': this._isClosed,
44
51
  }
45
52
 
46
- if (!this.isDisplayed) return nothing
47
-
48
53
  return html`<div class=${classMap(classes)}>
49
54
  ${this.closable
50
55
  ? html`<div class="pkt-messagebox__close">
51
56
  <button
52
- @click=${this.handleClose}
57
+ @click=${this.close}
53
58
  class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only"
54
59
  >
55
60
  <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, nothing } from 'lit'
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?: 'blue' | 'green' | 'red' | 'yellow'
19
+ skin?: TagSkin
19
20
  textStyle?: string
20
21
  iconName?: string
21
- type?: string
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: string = specs.props.type.default
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
  /**
@@ -55,11 +56,11 @@ export class PktTag extends PktElement {
55
56
  private close = (event: MouseEvent) => {
56
57
  this._isClosed = true
57
58
  this.dispatchEvent(
58
- new CustomEvent('onClose', {
59
- detail: { origin: event },
60
- bubbles: true,
61
- composed: true,
62
- }),
59
+ new CustomEvent('close', { detail: { origin: event }, bubbles: true, composed: true }),
60
+ )
61
+ // Historical support of old Vue implementations…
62
+ this.dispatchEvent(
63
+ new CustomEvent('on-close', { detail: { origin: event }, bubbles: true, composed: true }),
63
64
  )
64
65
  }
65
66
 
@@ -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 !this._isClosed
86
- ? html`
87
- <button
88
- class=${classMap(btnClasses)}
89
- type=${this.type}
90
- aria-label=${this.ariaLabel}
91
- @click=${this.close}
92
- >
93
- ${this.iconName &&
94
- html`<pkt-icon class="pkt-tag__icon" name=${this.iconName}></pkt-icon>`}
95
- <span ${ref(this.defaultSlot)}></span>
96
- <pkt-icon class="pkt-tag__close-btn" name="close"></pkt-icon>
97
- </button>
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)}> </span>
105
+ <span ${ref(this.defaultSlot)}></span>
106
106
  </span>
107
107
  `
108
108
  }