@oslokommune/punkt-elements 12.28.0 → 12.29.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.
@@ -0,0 +1,107 @@
1
+ import { n as s, P as c, x as l, E as p, a as u } from "./element-D_ZgQsSr.js";
2
+ import { P as b } from "./pkt-slot-controller-Clbye6cM.js";
3
+ import { e as f, n as k } from "./ref-BSGI8ogR.js";
4
+ var m = Object.defineProperty, y = Object.getOwnPropertyDescriptor, i = (t, n, r, o) => {
5
+ for (var a = o > 1 ? void 0 : o ? y(n, r) : n, d = t.length - 1, h; d >= 0; d--)
6
+ (h = t[d]) && (a = (o ? h(n, r, a) : h(a)) || a);
7
+ return o && a && m(n, r, a), a;
8
+ };
9
+ let e = class extends c {
10
+ constructor() {
11
+ super(), this.internals = this.attachInternals(), this.defaultSlot = f(), this.iconName = "user", this.secondIconName = "user", this.mode = "light", this.size = "medium", this.skin = "primary", this.variant = "label-only", this.state = "normal", this.type = "button", this.isLoading = !1, this.disabled = !1, this.slotController = new b(this, this.defaultSlot);
12
+ }
13
+ // Lifecycle
14
+ connectedCallback() {
15
+ super.connectedCallback(), this.addEventListener("click", this.handleClick), this.addEventListener("keydown", this.handleKeydown);
16
+ }
17
+ disconnectedCallback() {
18
+ super.disconnectedCallback(), this.removeEventListener("click", this.handleClick), this.removeEventListener("keydown", this.handleKeydown);
19
+ }
20
+ updated(t) {
21
+ super.updated(t), this.setAttribute("role", "button"), this.disabled ? (this.getAttribute("tabindex") !== "-1" && this.setAttribute("tabindex", "-1"), this.getAttribute("aria-disabled") !== "true" && this.setAttribute("aria-disabled", "true")) : (this.getAttribute("tabindex") !== "0" && this.setAttribute("tabindex", "0"), this.getAttribute("aria-disabled") !== "false" && this.setAttribute("aria-disabled", "false")), this.isLoading ? this.getAttribute("aria-busy") !== "true" && this.setAttribute("aria-busy", "true") : this.hasAttribute("aria-busy") && this.removeAttribute("aria-busy"), this.updateElementClasses();
22
+ }
23
+ // Render
24
+ render() {
25
+ return l`
26
+ <div class="pkt-btn__element-content">
27
+ ${this.isLoading ? l`<pkt-icon
28
+ class="pkt-btn__icon pkt-btn__spinner"
29
+ name="spinner-blue"
30
+ path="https://punkt-cdn.oslo.kommune.no/latest/animations/"
31
+ ></pkt-icon>` : p}
32
+ ${this.variant !== "label-only" ? l`<pkt-icon class="pkt-btn__icon pkt-icon" name=${this.iconName}></pkt-icon>` : p}
33
+ <span class="pkt-btn__text" ${k(this.defaultSlot)}></span>
34
+ ${this.variant === "icons-right-and-left" ? l`<pkt-icon class="pkt-btn__icon" name=${this.secondIconName}></pkt-icon>` : p}
35
+ </div>
36
+ `;
37
+ }
38
+ // Methods
39
+ updateElementClasses() {
40
+ const t = /* @__PURE__ */ new Set(), n = this.getAttribute("class");
41
+ t.add("pkt-btn"), n && n.split(" ").forEach((r) => t.add(r)), this.size && t.add(`pkt-btn--${this.size}`), this.skin && t.add(`pkt-btn--${this.skin}`), this.variant && t.add(`pkt-btn--${this.variant}`), this.color && t.add(`pkt-btn--${this.color}`), this.isLoading && t.add("pkt-btn--active"), this.state && t.add(`pkt-btn--${this.state}`), this.disabled && t.add("pkt-btn--disabled"), this.className = [...t].join(" ");
42
+ }
43
+ handleClick(t) {
44
+ if (this.disabled || this.isLoading) {
45
+ t.preventDefault(), t.stopImmediatePropagation();
46
+ return;
47
+ }
48
+ if (this.type === "submit" && this.internals.form) {
49
+ this.internals.form.requestSubmit();
50
+ return;
51
+ }
52
+ if (this.type === "reset" && this.internals.form) {
53
+ this.internals.form.reset();
54
+ return;
55
+ }
56
+ this.onClick && typeof this.onClick == "function" && this.onClick !== this.handleClick && this.onClick(t), this.dispatchEvent(
57
+ new CustomEvent("button-click", {
58
+ bubbles: !0,
59
+ composed: !0,
60
+ detail: { originalEvent: t }
61
+ })
62
+ );
63
+ }
64
+ handleKeydown(t) {
65
+ this.disabled || this.isLoading || (t.key === "Enter" || t.key === " ") && (t.preventDefault(), this.handleClick(t));
66
+ }
67
+ };
68
+ e.formAssociated = !0;
69
+ i([
70
+ s({ type: String })
71
+ ], e.prototype, "iconName", 2);
72
+ i([
73
+ s({ type: String })
74
+ ], e.prototype, "secondIconName", 2);
75
+ i([
76
+ s({ type: String })
77
+ ], e.prototype, "mode", 2);
78
+ i([
79
+ s({ type: String })
80
+ ], e.prototype, "size", 2);
81
+ i([
82
+ s({ type: String })
83
+ ], e.prototype, "color", 2);
84
+ i([
85
+ s({ type: String })
86
+ ], e.prototype, "skin", 2);
87
+ i([
88
+ s({ type: String })
89
+ ], e.prototype, "variant", 2);
90
+ i([
91
+ s({ type: String, reflect: !0 })
92
+ ], e.prototype, "state", 2);
93
+ i([
94
+ s({ type: String, reflect: !0 })
95
+ ], e.prototype, "type", 2);
96
+ i([
97
+ s({ type: Boolean, reflect: !0 })
98
+ ], e.prototype, "isLoading", 2);
99
+ i([
100
+ s({ type: Boolean, reflect: !0 })
101
+ ], e.prototype, "disabled", 2);
102
+ e = i([
103
+ u("pkt-button")
104
+ ], e);
105
+ export {
106
+ e as P
107
+ };
@@ -0,0 +1,12 @@
1
+ "use strict";const e=require("./element-r-PeQ419.cjs"),h=require("./pkt-slot-controller-Oc32unDk.cjs"),d=require("./ref-BUWgvhgU.cjs");var p=Object.defineProperty,u=Object.getOwnPropertyDescriptor,i=(o,t,n,a)=>{for(var s=a>1?void 0:a?u(t,n):t,r=o.length-1,l;r>=0;r--)(l=o[r])&&(s=(a?l(t,n,s):l(s))||s);return a&&s&&p(t,n,s),s};exports.PktButton=class extends e.PktElement{constructor(){super(),this.internals=this.attachInternals(),this.defaultSlot=d.e(),this.iconName="user",this.secondIconName="user",this.mode="light",this.size="medium",this.skin="primary",this.variant="label-only",this.state="normal",this.type="button",this.isLoading=!1,this.disabled=!1,this.slotController=new h.PktSlotController(this,this.defaultSlot)}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this.handleClick),this.addEventListener("keydown",this.handleKeydown)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("click",this.handleClick),this.removeEventListener("keydown",this.handleKeydown)}updated(t){super.updated(t),this.setAttribute("role","button"),this.disabled?(this.getAttribute("tabindex")!=="-1"&&this.setAttribute("tabindex","-1"),this.getAttribute("aria-disabled")!=="true"&&this.setAttribute("aria-disabled","true")):(this.getAttribute("tabindex")!=="0"&&this.setAttribute("tabindex","0"),this.getAttribute("aria-disabled")!=="false"&&this.setAttribute("aria-disabled","false")),this.isLoading?this.getAttribute("aria-busy")!=="true"&&this.setAttribute("aria-busy","true"):this.hasAttribute("aria-busy")&&this.removeAttribute("aria-busy"),this.updateElementClasses()}render(){return e.x`
2
+ <div class="pkt-btn__element-content">
3
+ ${this.isLoading?e.x`<pkt-icon
4
+ class="pkt-btn__icon pkt-btn__spinner"
5
+ name="spinner-blue"
6
+ path="https://punkt-cdn.oslo.kommune.no/latest/animations/"
7
+ ></pkt-icon>`:e.E}
8
+ ${this.variant!=="label-only"?e.x`<pkt-icon class="pkt-btn__icon pkt-icon" name=${this.iconName}></pkt-icon>`:e.E}
9
+ <span class="pkt-btn__text" ${d.n(this.defaultSlot)}></span>
10
+ ${this.variant==="icons-right-and-left"?e.x`<pkt-icon class="pkt-btn__icon" name=${this.secondIconName}></pkt-icon>`:e.E}
11
+ </div>
12
+ `}updateElementClasses(){const t=new Set,n=this.getAttribute("class");t.add("pkt-btn"),n&&n.split(" ").forEach(a=>t.add(a)),this.size&&t.add(`pkt-btn--${this.size}`),this.skin&&t.add(`pkt-btn--${this.skin}`),this.variant&&t.add(`pkt-btn--${this.variant}`),this.color&&t.add(`pkt-btn--${this.color}`),this.isLoading&&t.add("pkt-btn--active"),this.state&&t.add(`pkt-btn--${this.state}`),this.disabled&&t.add("pkt-btn--disabled"),this.className=[...t].join(" ")}handleClick(t){if(this.disabled||this.isLoading){t.preventDefault(),t.stopImmediatePropagation();return}if(this.type==="submit"&&this.internals.form){this.internals.form.requestSubmit();return}if(this.type==="reset"&&this.internals.form){this.internals.form.reset();return}this.onClick&&typeof this.onClick=="function"&&this.onClick!==this.handleClick&&this.onClick(t),this.dispatchEvent(new CustomEvent("button-click",{bubbles:!0,composed:!0,detail:{originalEvent:t}}))}handleKeydown(t){this.disabled||this.isLoading||(t.key==="Enter"||t.key===" ")&&(t.preventDefault(),this.handleClick(t))}};exports.PktButton.formAssociated=!0;i([e.n({type:String})],exports.PktButton.prototype,"iconName",2);i([e.n({type:String})],exports.PktButton.prototype,"secondIconName",2);i([e.n({type:String})],exports.PktButton.prototype,"mode",2);i([e.n({type:String})],exports.PktButton.prototype,"size",2);i([e.n({type:String})],exports.PktButton.prototype,"color",2);i([e.n({type:String})],exports.PktButton.prototype,"skin",2);i([e.n({type:String})],exports.PktButton.prototype,"variant",2);i([e.n({type:String,reflect:!0})],exports.PktButton.prototype,"state",2);i([e.n({type:String,reflect:!0})],exports.PktButton.prototype,"type",2);i([e.n({type:Boolean,reflect:!0})],exports.PktButton.prototype,"isLoading",2);i([e.n({type:Boolean,reflect:!0})],exports.PktButton.prototype,"disabled",2);exports.PktButton=i([e.t("pkt-button")],exports.PktButton);
@@ -0,0 +1,15 @@
1
+ export { }
2
+
3
+
4
+ declare global {
5
+ interface HTMLElementTagNameMap {
6
+ 'pkt-icon': PktIcon;
7
+ }
8
+ }
9
+
10
+
11
+ declare global {
12
+ interface Window {
13
+ pktTz: string;
14
+ }
15
+ }
package/dist/index.d.ts CHANGED
@@ -14,6 +14,20 @@ import { TZDate } from '@date-fns/tz';
14
14
  */
15
15
  declare type ElementProps<Element, PropKeys extends keyof Element> = Partial<Pick<Element, PropKeys>>;
16
16
 
17
+ export declare interface IPktButton {
18
+ iconName?: string;
19
+ secondIconName?: string;
20
+ mode?: TPktButtonMode;
21
+ size?: TPktButtonSize;
22
+ color?: TPktButtonColor;
23
+ skin?: TPktButtonSkin;
24
+ variant?: TPktButtonVariant;
25
+ state?: TPktButtonState;
26
+ type?: TPktButtonType;
27
+ isLoading?: boolean;
28
+ disabled?: boolean;
29
+ }
30
+
17
31
  declare interface IPktLinkCard {
18
32
  title?: string;
19
33
  href?: string;
@@ -81,6 +95,31 @@ export declare class PktAlert extends PktElement {
81
95
  render(): TemplateResult<1>;
82
96
  }
83
97
 
98
+ export declare class PktButton extends PktElement implements IPktButton {
99
+ static formAssociated: boolean;
100
+ private internals;
101
+ defaultSlot: Ref<HTMLElement>;
102
+ constructor();
103
+ iconName: string;
104
+ secondIconName: string;
105
+ mode?: TPktButtonMode;
106
+ size: TPktButtonSize;
107
+ color?: TPktButtonColor;
108
+ skin: TPktButtonSkin;
109
+ variant: TPktButtonVariant;
110
+ state?: TPktButtonState;
111
+ type: TPktButtonType;
112
+ isLoading: boolean;
113
+ disabled: boolean;
114
+ connectedCallback(): void;
115
+ disconnectedCallback(): void;
116
+ updated(changedProps: Map<string | number | symbol, unknown>): void;
117
+ render(): TemplateResult<1>;
118
+ private updateElementClasses;
119
+ private handleClick;
120
+ private handleKeydown;
121
+ }
122
+
84
123
  export declare class PktCalendar extends PktElement {
85
124
  /**
86
125
  * Element attributes
@@ -665,6 +704,20 @@ declare type TLinkCardSkin = 'normal' | 'blue' | 'beige' | 'green' | 'gray' | 'b
665
704
 
666
705
  declare type TMessageboxSkin = 'beige' | 'blue' | 'red' | 'green';
667
706
 
707
+ export declare type TPktButtonColor = 'blue' | 'blue-outline' | 'green' | 'green-outline' | 'green-dark' | 'green-dark-outline' | 'beige-light' | 'beige-dark-outline' | 'yellow' | 'yellow-outline' | 'red' | 'red-outline';
708
+
709
+ export declare type TPktButtonMode = 'light' | 'dark';
710
+
711
+ export declare type TPktButtonSize = 'small' | 'medium' | 'large';
712
+
713
+ export declare type TPktButtonSkin = 'primary' | 'secondary' | 'tertiary';
714
+
715
+ export declare type TPktButtonState = 'normal' | 'focus' | 'hover' | 'active';
716
+
717
+ export declare type TPktButtonType = 'button' | 'submit' | 'reset';
718
+
719
+ export declare type TPktButtonVariant = 'label-only' | 'icon-left' | 'icon-right' | 'icon-only' | 'icons-right-and-left';
720
+
668
721
  declare type TPktSize = 'small' | 'medium' | 'large';
669
722
 
670
723
  export declare type TProgressbarRole = 'progressbar' | 'meter';
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("./button-DPb5WL9h.cjs"),e=t.PktButton;Object.defineProperty(exports,"PktButton",{enumerable:!0,get:()=>t.PktButton});exports.default=e;
@@ -0,0 +1,6 @@
1
+ import { P as t } from "./button-BnmFhao8.js";
2
+ const a = t;
3
+ export {
4
+ t as PktButton,
5
+ a as default
6
+ };
@@ -1,5 +1,5 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("./alert-Cx7AYawa.cjs"),c=require("./calendar-DUkAC9Hx.cjs"),d=require("./card-Bxe-jQD_.cjs"),k=require("./checkbox-CDMUepTW.cjs"),t=require("./element-r-PeQ419.cjs"),P=require("./pkt-slot-controller-Oc32unDk.cjs"),i=require("./ref-BUWgvhgU.cjs"),b=require("./class-map-Dzci3Pfe.cjs"),h=require("./datepicker-D6ifQ2so.cjs"),m=require("./helptext-C0mrdhRi.cjs"),g=require("./icon-DcJIqTIY.cjs"),f=require("./input-wrapper-Dqj4uers.cjs"),y=require("./link-C_bwx1Ml.cjs"),x=require("./linkcard-C6mZOE0R.cjs"),C=require("./messagebox-DJzOyZwE.cjs"),O=require("./modal-CV3LSNHb.cjs"),j=require("./progressbar-C_q48_qh.cjs"),q=require("./radiobutton-3e105CXX.cjs"),v=require("./tag-BMyii4Da.cjs"),S=require("./textarea-DxpzI67n.cjs"),$=require("./textinput-BRupcl9v.cjs"),_=require("./select-DJu4Wr1y.cjs");var T=Object.defineProperty,L=Object.getOwnPropertyDescriptor,o=(a,e,r,s)=>{for(var n=s>1?void 0:s?L(e,r):e,l=a.length-1,u;l>=0;l--)(u=a[l])&&(n=(s?u(e,r,n):u(n))||n);return s&&n&&T(e,r,n),n};exports.PktComponent=class extends t.PktElement{constructor(){super(),this.string="",this.strings=[],this.darkmode=!1,this._list=[],this.defaultSlot=i.e(),this.namedSlot=i.e(),this.slotController=new P.PktSlotController(this,this.defaultSlot,this.namedSlot)}connectedCallback(){this.strings.length&&this.strings.forEach(e=>{this._list.push(e.toUpperCase())}),super.connectedCallback()}render(){const e={"pkt-component":!0,"pkt-component--has-list":this.strings.length>0,"pkt-darkmode":this.darkmode};return t.x`
2
- <div class="${b.e(e)}">
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p=require("./alert-Cx7AYawa.cjs"),d=require("./button-DPb5WL9h.cjs"),c=require("./calendar-DUkAC9Hx.cjs"),k=require("./card-Bxe-jQD_.cjs"),P=require("./checkbox-CDMUepTW.cjs"),t=require("./element-r-PeQ419.cjs"),b=require("./pkt-slot-controller-Oc32unDk.cjs"),i=require("./ref-BUWgvhgU.cjs"),h=require("./class-map-Dzci3Pfe.cjs"),m=require("./datepicker-D6ifQ2so.cjs"),g=require("./helptext-C0mrdhRi.cjs"),f=require("./icon-DcJIqTIY.cjs"),y=require("./input-wrapper-Dqj4uers.cjs"),x=require("./link-C_bwx1Ml.cjs"),C=require("./linkcard-C6mZOE0R.cjs"),O=require("./messagebox-DJzOyZwE.cjs"),j=require("./modal-CV3LSNHb.cjs"),q=require("./progressbar-C_q48_qh.cjs"),v=require("./radiobutton-3e105CXX.cjs"),S=require("./tag-BMyii4Da.cjs"),$=require("./textarea-DxpzI67n.cjs"),_=require("./textinput-BRupcl9v.cjs"),T=require("./select-DJu4Wr1y.cjs");var L=Object.defineProperty,M=Object.getOwnPropertyDescriptor,o=(a,e,r,s)=>{for(var n=s>1?void 0:s?M(e,r):e,l=a.length-1,u;l>=0;l--)(u=a[l])&&(n=(s?u(e,r,n):u(n))||n);return s&&n&&L(e,r,n),n};exports.PktComponent=class extends t.PktElement{constructor(){super(),this.string="",this.strings=[],this.darkmode=!1,this._list=[],this.defaultSlot=i.e(),this.namedSlot=i.e(),this.slotController=new b.PktSlotController(this,this.defaultSlot,this.namedSlot)}connectedCallback(){this.strings.length&&this.strings.forEach(e=>{this._list.push(e.toUpperCase())}),super.connectedCallback()}render(){const e={"pkt-component":!0,"pkt-component--has-list":this.strings.length>0,"pkt-darkmode":this.darkmode};return t.x`
2
+ <div class="${h.e(e)}">
3
3
  <h1 class="pkt-txt-28">${this.string}</h1>
4
4
 
5
5
  <h2 class="pkt-txt-22">Innhold fra attributter og funksjoner</h2>
@@ -26,4 +26,4 @@
26
26
  <ul>
27
27
  ${e.map(r=>t.x`<li>${r}</li>`)}
28
28
  </ul>
29
- `}doStuff(e){return e.reverse()}handleGreeting(){this.dispatchEvent(new CustomEvent("pkt-greeting",{detail:"Hei på deg!"}))}};o([t.n({type:String})],exports.PktComponent.prototype,"string",2);o([t.n({converter:c.csvToArray})],exports.PktComponent.prototype,"strings",2);o([t.n({type:Boolean})],exports.PktComponent.prototype,"darkmode",2);o([t.n({type:Array})],exports.PktComponent.prototype,"_list",2);exports.PktComponent=o([t.t("pkt-component")],exports.PktComponent);Object.defineProperty(exports,"PktAlert",{enumerable:!0,get:()=>p.PktAlert});Object.defineProperty(exports,"PktCalendar",{enumerable:!0,get:()=>c.PktCalendar});Object.defineProperty(exports,"PktCard",{enumerable:!0,get:()=>d.PktCard});Object.defineProperty(exports,"PktCheckbox",{enumerable:!0,get:()=>k.PktCheckbox});Object.defineProperty(exports,"PktDatepicker",{enumerable:!0,get:()=>h.PktDatepicker});Object.defineProperty(exports,"PktHelptext",{enumerable:!0,get:()=>m.PktHelptext});Object.defineProperty(exports,"PktIcon",{enumerable:!0,get:()=>g.PktIcon});Object.defineProperty(exports,"PktInputWrapper",{enumerable:!0,get:()=>f.PktInputWrapper});Object.defineProperty(exports,"PktLink",{enumerable:!0,get:()=>y.PktLink});Object.defineProperty(exports,"PktLinkCard",{enumerable:!0,get:()=>x.PktLinkCard});Object.defineProperty(exports,"PktMessagebox",{enumerable:!0,get:()=>C.PktMessagebox});Object.defineProperty(exports,"PktModal",{enumerable:!0,get:()=>O.PktModal});Object.defineProperty(exports,"PktProgressbar",{enumerable:!0,get:()=>j.PktProgressbar});Object.defineProperty(exports,"PktRadioButton",{enumerable:!0,get:()=>q.PktRadioButton});Object.defineProperty(exports,"PktTag",{enumerable:!0,get:()=>v.PktTag});Object.defineProperty(exports,"PktTextarea",{enumerable:!0,get:()=>S.PktTextarea});Object.defineProperty(exports,"PktTextinput",{enumerable:!0,get:()=>$.PktTextinput});Object.defineProperty(exports,"PktSelect",{enumerable:!0,get:()=>_.PktSelect});
29
+ `}doStuff(e){return e.reverse()}handleGreeting(){this.dispatchEvent(new CustomEvent("pkt-greeting",{detail:"Hei på deg!"}))}};o([t.n({type:String})],exports.PktComponent.prototype,"string",2);o([t.n({converter:c.csvToArray})],exports.PktComponent.prototype,"strings",2);o([t.n({type:Boolean})],exports.PktComponent.prototype,"darkmode",2);o([t.n({type:Array})],exports.PktComponent.prototype,"_list",2);exports.PktComponent=o([t.t("pkt-component")],exports.PktComponent);Object.defineProperty(exports,"PktAlert",{enumerable:!0,get:()=>p.PktAlert});Object.defineProperty(exports,"PktButton",{enumerable:!0,get:()=>d.PktButton});Object.defineProperty(exports,"PktCalendar",{enumerable:!0,get:()=>c.PktCalendar});Object.defineProperty(exports,"PktCard",{enumerable:!0,get:()=>k.PktCard});Object.defineProperty(exports,"PktCheckbox",{enumerable:!0,get:()=>P.PktCheckbox});Object.defineProperty(exports,"PktDatepicker",{enumerable:!0,get:()=>m.PktDatepicker});Object.defineProperty(exports,"PktHelptext",{enumerable:!0,get:()=>g.PktHelptext});Object.defineProperty(exports,"PktIcon",{enumerable:!0,get:()=>f.PktIcon});Object.defineProperty(exports,"PktInputWrapper",{enumerable:!0,get:()=>y.PktInputWrapper});Object.defineProperty(exports,"PktLink",{enumerable:!0,get:()=>x.PktLink});Object.defineProperty(exports,"PktLinkCard",{enumerable:!0,get:()=>C.PktLinkCard});Object.defineProperty(exports,"PktMessagebox",{enumerable:!0,get:()=>O.PktMessagebox});Object.defineProperty(exports,"PktModal",{enumerable:!0,get:()=>j.PktModal});Object.defineProperty(exports,"PktProgressbar",{enumerable:!0,get:()=>q.PktProgressbar});Object.defineProperty(exports,"PktRadioButton",{enumerable:!0,get:()=>v.PktRadioButton});Object.defineProperty(exports,"PktTag",{enumerable:!0,get:()=>S.PktTag});Object.defineProperty(exports,"PktTextarea",{enumerable:!0,get:()=>$.PktTextarea});Object.defineProperty(exports,"PktTextinput",{enumerable:!0,get:()=>_.PktTextinput});Object.defineProperty(exports,"PktSelect",{enumerable:!0,get:()=>T.PktSelect});
package/dist/pkt-index.js CHANGED
@@ -1,26 +1,27 @@
1
1
  import { P as w } from "./alert-C_FCsFfo.js";
2
+ import { P as O } from "./button-BnmFhao8.js";
2
3
  import { c as d } from "./calendar-DevhqUoj.js";
3
- import { P as O } from "./calendar-DevhqUoj.js";
4
- import { P as j } from "./card-Db2Ex1cH.js";
5
- import { P as D } from "./checkbox-Dw2CX5zY.js";
4
+ import { P as j } from "./calendar-DevhqUoj.js";
5
+ import { P as B } from "./card-Db2Ex1cH.js";
6
+ import { P as I } from "./checkbox-Dw2CX5zY.js";
6
7
  import { P as f, x as m, t as k, n, a as c } from "./element-D_ZgQsSr.js";
7
8
  import { P as x } from "./pkt-slot-controller-Clbye6cM.js";
8
9
  import { e as h, n as P } from "./ref-BSGI8ogR.js";
9
10
  import { e as u } from "./class-map-BYCG9U47.js";
10
- import { P as R } from "./datepicker-gZ_eVIyS.js";
11
- import { P as G } from "./helptext-RPq_TKzJ.js";
12
- import { P as M } from "./icon-BBFK-d-X.js";
13
- import { P as N } from "./input-wrapper-D-pEAZaj.js";
14
- import { P as W } from "./link-CDkU7zsB.js";
15
- import { P as z } from "./linkcard-Dr5iKZrV.js";
16
- import { P as J } from "./messagebox-BgLZ5zul.js";
17
- import { P as V } from "./modal-CnSYSYsQ.js";
18
- import { P as Y } from "./progressbar-CuZj4FWi.js";
19
- import { P as tt } from "./radiobutton-CcZ2-z8q.js";
20
- import { P as rt } from "./tag-DVk69673.js";
21
- import { P as ot } from "./textarea-C8-lnWwu.js";
22
- import { P as nt } from "./textinput-DRkv93vp.js";
23
- import { P as pt } from "./select-CnizDIYN.js";
11
+ import { P as G } from "./datepicker-gZ_eVIyS.js";
12
+ import { P as M } from "./helptext-RPq_TKzJ.js";
13
+ import { P as N } from "./icon-BBFK-d-X.js";
14
+ import { P as W } from "./input-wrapper-D-pEAZaj.js";
15
+ import { P as z } from "./link-CDkU7zsB.js";
16
+ import { P as J } from "./linkcard-Dr5iKZrV.js";
17
+ import { P as V } from "./messagebox-BgLZ5zul.js";
18
+ import { P as Y } from "./modal-CnSYSYsQ.js";
19
+ import { P as tt } from "./progressbar-CuZj4FWi.js";
20
+ import { P as rt } from "./radiobutton-CcZ2-z8q.js";
21
+ import { P as ot } from "./tag-DVk69673.js";
22
+ import { P as nt } from "./textarea-C8-lnWwu.js";
23
+ import { P as pt } from "./textinput-DRkv93vp.js";
24
+ import { P as mt } from "./select-CnizDIYN.js";
24
25
  var g = Object.defineProperty, v = Object.getOwnPropertyDescriptor, o = (t, e, i, a) => {
25
26
  for (var r = a > 1 ? void 0 : a ? v(e, i) : e, p = t.length - 1, l; p >= 0; p--)
26
27
  (l = t[p]) && (r = (a ? l(e, i, r) : l(r)) || r);
@@ -114,22 +115,23 @@ s = o([
114
115
  ], s);
115
116
  export {
116
117
  w as PktAlert,
117
- O as PktCalendar,
118
- j as PktCard,
119
- D as PktCheckbox,
118
+ O as PktButton,
119
+ j as PktCalendar,
120
+ B as PktCard,
121
+ I as PktCheckbox,
120
122
  s as PktComponent,
121
- R as PktDatepicker,
122
- G as PktHelptext,
123
- M as PktIcon,
124
- N as PktInputWrapper,
125
- W as PktLink,
126
- z as PktLinkCard,
127
- J as PktMessagebox,
128
- V as PktModal,
129
- Y as PktProgressbar,
130
- tt as PktRadioButton,
131
- pt as PktSelect,
132
- rt as PktTag,
133
- ot as PktTextarea,
134
- nt as PktTextinput
123
+ G as PktDatepicker,
124
+ M as PktHelptext,
125
+ N as PktIcon,
126
+ W as PktInputWrapper,
127
+ z as PktLink,
128
+ J as PktLinkCard,
129
+ V as PktMessagebox,
130
+ Y as PktModal,
131
+ tt as PktProgressbar,
132
+ rt as PktRadioButton,
133
+ mt as PktSelect,
134
+ ot as PktTag,
135
+ nt as PktTextarea,
136
+ pt as PktTextinput
135
137
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oslokommune/punkt-elements",
3
- "version": "12.28.0",
3
+ "version": "12.29.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",
@@ -30,7 +30,7 @@
30
30
  },
31
31
  "devDependencies": {
32
32
  "@oslokommune/punkt-assets": "^12.27.1",
33
- "@oslokommune/punkt-css": "^12.28.0",
33
+ "@oslokommune/punkt-css": "^12.29.0",
34
34
  "sass": "^1.78.0",
35
35
  "typescript": "^5.6.2",
36
36
  "vite": "^5.4.4",
@@ -57,5 +57,5 @@
57
57
  "url": "https://github.com/oslokommune/punkt/issues"
58
58
  },
59
59
  "license": "MIT",
60
- "gitHead": "3dee4a0c63e59fe126be318bad620cfb9b9a6c6f"
60
+ "gitHead": "2f85764bd3da7652eacddf71afb9ab9f0ff652d4"
61
61
  }
@@ -0,0 +1,200 @@
1
+ import { PktElement } from '@/base-elements/element'
2
+ import { PktSlotController } from '@/controllers/pkt-slot-controller'
3
+ import { html, nothing } from 'lit'
4
+ import { property, customElement } from 'lit/decorators.js'
5
+ import { createRef, Ref, ref } from 'lit/directives/ref.js'
6
+
7
+ export type TPktButtonMode = 'light' | 'dark'
8
+ export type TPktButtonSize = 'small' | 'medium' | 'large'
9
+ export type TPktButtonColor =
10
+ | 'blue'
11
+ | 'blue-outline'
12
+ | 'green'
13
+ | 'green-outline'
14
+ | 'green-dark'
15
+ | 'green-dark-outline'
16
+ | 'beige-light'
17
+ | 'beige-dark-outline'
18
+ | 'yellow'
19
+ | 'yellow-outline'
20
+ | 'red'
21
+ | 'red-outline'
22
+ export type TPktButtonSkin = 'primary' | 'secondary' | 'tertiary'
23
+ export type TPktButtonVariant =
24
+ | 'label-only'
25
+ | 'icon-left'
26
+ | 'icon-right'
27
+ | 'icon-only'
28
+ | 'icons-right-and-left'
29
+ export type TPktButtonState = 'normal' | 'focus' | 'hover' | 'active'
30
+ export type TPktButtonType = 'button' | 'submit' | 'reset'
31
+
32
+ export interface IPktButton {
33
+ iconName?: string
34
+ secondIconName?: string
35
+ mode?: TPktButtonMode
36
+ size?: TPktButtonSize
37
+ color?: TPktButtonColor
38
+ skin?: TPktButtonSkin
39
+ variant?: TPktButtonVariant
40
+ state?: TPktButtonState
41
+ type?: TPktButtonType
42
+ isLoading?: boolean
43
+ disabled?: boolean
44
+ }
45
+ @customElement('pkt-button')
46
+ export class PktButton extends PktElement implements IPktButton {
47
+ static formAssociated = true
48
+ private internals = this.attachInternals()
49
+ defaultSlot: Ref<HTMLElement> = createRef()
50
+
51
+ constructor() {
52
+ super()
53
+ this.slotController = new PktSlotController(this, this.defaultSlot)
54
+ }
55
+
56
+ // Properties
57
+ @property({ type: String }) iconName: string = 'user'
58
+ @property({ type: String }) secondIconName: string = 'user'
59
+ @property({ type: String }) mode?: TPktButtonMode = 'light'
60
+ @property({ type: String }) size: TPktButtonSize = 'medium'
61
+ @property({ type: String }) color?: TPktButtonColor
62
+ @property({ type: String }) skin: TPktButtonSkin = 'primary'
63
+ @property({ type: String }) variant: TPktButtonVariant = 'label-only'
64
+ @property({ type: String, reflect: true }) state?: TPktButtonState = 'normal'
65
+ @property({ type: String, reflect: true }) type: TPktButtonType = 'button'
66
+ @property({ type: Boolean, reflect: true }) isLoading: boolean = false
67
+ @property({ type: Boolean, reflect: true }) disabled: boolean = false
68
+
69
+ // Lifecycle
70
+
71
+ connectedCallback() {
72
+ super.connectedCallback()
73
+ this.addEventListener('click', this.handleClick as EventListener)
74
+ this.addEventListener('keydown', this.handleKeydown as EventListener)
75
+ }
76
+
77
+ disconnectedCallback() {
78
+ super.disconnectedCallback()
79
+ this.removeEventListener('click', this.handleClick as EventListener)
80
+ this.removeEventListener('keydown', this.handleKeydown as EventListener)
81
+ }
82
+
83
+ updated(changedProps: Map<string | number | symbol, unknown>) {
84
+ super.updated(changedProps)
85
+
86
+ this.setAttribute('role', 'button')
87
+
88
+ if (this.disabled) {
89
+ if (this.getAttribute('tabindex') !== '-1') {
90
+ this.setAttribute('tabindex', '-1')
91
+ }
92
+ if (this.getAttribute('aria-disabled') !== 'true') {
93
+ this.setAttribute('aria-disabled', 'true')
94
+ }
95
+ } else {
96
+ if (this.getAttribute('tabindex') !== '0') {
97
+ this.setAttribute('tabindex', '0')
98
+ }
99
+ if (this.getAttribute('aria-disabled') !== 'false') {
100
+ this.setAttribute('aria-disabled', 'false')
101
+ }
102
+ }
103
+
104
+ if (this.isLoading) {
105
+ if (this.getAttribute('aria-busy') !== 'true') {
106
+ this.setAttribute('aria-busy', 'true')
107
+ }
108
+ } else {
109
+ if (this.hasAttribute('aria-busy')) {
110
+ this.removeAttribute('aria-busy')
111
+ }
112
+ }
113
+
114
+ this.updateElementClasses()
115
+ }
116
+
117
+ // Render
118
+
119
+ render() {
120
+ return html`
121
+ <div class="pkt-btn__element-content">
122
+ ${this.isLoading
123
+ ? html`<pkt-icon
124
+ class="pkt-btn__icon pkt-btn__spinner"
125
+ name="spinner-blue"
126
+ path="https://punkt-cdn.oslo.kommune.no/latest/animations/"
127
+ ></pkt-icon>`
128
+ : nothing}
129
+ ${this.variant !== 'label-only'
130
+ ? html`<pkt-icon class="pkt-btn__icon pkt-icon" name=${this.iconName}></pkt-icon>`
131
+ : nothing}
132
+ <span class="pkt-btn__text" ${ref(this.defaultSlot)}></span>
133
+ ${this.variant === 'icons-right-and-left'
134
+ ? html`<pkt-icon class="pkt-btn__icon" name=${this.secondIconName}></pkt-icon>`
135
+ : nothing}
136
+ </div>
137
+ `
138
+ }
139
+
140
+ // Methods
141
+
142
+ private updateElementClasses() {
143
+ const classes = new Set<string>()
144
+ const currentClasses = this.getAttribute('class')
145
+
146
+ classes.add('pkt-btn')
147
+
148
+ if (currentClasses) {
149
+ currentClasses.split(' ').forEach((classname) => classes.add(classname))
150
+ }
151
+ if (this.size) classes.add(`pkt-btn--${this.size}`)
152
+ if (this.skin) classes.add(`pkt-btn--${this.skin}`)
153
+ if (this.variant) classes.add(`pkt-btn--${this.variant}`)
154
+ if (this.color) classes.add(`pkt-btn--${this.color}`)
155
+ if (this.isLoading) classes.add('pkt-btn--active')
156
+ if (this.state) classes.add(`pkt-btn--${this.state}`)
157
+ if (this.disabled) classes.add('pkt-btn--disabled')
158
+
159
+ this.className = [...classes].join(' ')
160
+ }
161
+
162
+ private handleClick(event: MouseEvent) {
163
+ if (this.disabled || this.isLoading) {
164
+ event.preventDefault()
165
+ event.stopImmediatePropagation()
166
+ return
167
+ }
168
+
169
+ if (this.type === 'submit' && this.internals.form) {
170
+ this.internals.form.requestSubmit()
171
+ return
172
+ }
173
+ if (this.type === 'reset' && this.internals.form) {
174
+ this.internals.form.reset()
175
+ return
176
+ }
177
+
178
+ if (this.onClick && typeof this.onClick === 'function' && this.onClick !== this.handleClick) {
179
+ this.onClick(event)
180
+ }
181
+
182
+ this.dispatchEvent(
183
+ new CustomEvent('button-click', {
184
+ bubbles: true,
185
+ composed: true,
186
+ detail: { originalEvent: event },
187
+ }),
188
+ )
189
+ }
190
+
191
+ private handleKeydown(event: KeyboardEvent) {
192
+ if (this.disabled || this.isLoading) return
193
+
194
+ if (event.key === 'Enter' || event.key === ' ') {
195
+ event.preventDefault()
196
+ this.handleClick(event as unknown as MouseEvent)
197
+ }
198
+ }
199
+ }
200
+ export default PktButton
@@ -0,0 +1,15 @@
1
+ import { PktButton } from './button'
2
+
3
+ export type {
4
+ IPktButton,
5
+ TPktButtonMode,
6
+ TPktButtonSize,
7
+ TPktButtonColor,
8
+ TPktButtonSkin,
9
+ TPktButtonVariant,
10
+ TPktButtonState,
11
+ TPktButtonType,
12
+ } from './button'
13
+
14
+ export { PktButton }
15
+ export default PktButton
@@ -1,5 +1,6 @@
1
1
  // Export components
2
2
  export { PktAlert } from '@/components/alert'
3
+ export { PktButton } from '@/components/button'
3
4
  export { PktCalendar } from '@/components/calendar'
4
5
  export { PktCard } from '@/components/card'
5
6
  export { PktCheckbox } from '@/components/checkbox'
@@ -20,6 +21,18 @@ export { PktTextinput } from '@/components/textinput'
20
21
  export { PktSelect } from '@/components/select'
21
22
 
22
23
  // Export types
24
+
25
+ export type {
26
+ IPktButton,
27
+ TPktButtonMode,
28
+ TPktButtonSize,
29
+ TPktButtonColor,
30
+ TPktButtonSkin,
31
+ TPktButtonVariant,
32
+ TPktButtonState,
33
+ TPktButtonType,
34
+ } from '@/components/button'
35
+
23
36
  export type {
24
37
  IPktProgressbar,
25
38
  TProgressbarRole,