@oslokommune/punkt-elements 13.5.3 → 13.5.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,40 @@ og skriver commits ca etter [Conventional Commits](https://conventionalcommits.o
5
5
 
6
6
  ---
7
7
 
8
+ ## [13.5.5](https://github.com/oslokommune/punkt/compare/13.5.4...13.5.5) (2025-09-09)
9
+
10
+ ### ⚠ BREAKING CHANGES
11
+ Ingen
12
+
13
+ ### Features
14
+ Ingen
15
+
16
+ ### Bug Fixes
17
+ Ingen
18
+
19
+ ### Chores
20
+ Ingen
21
+
22
+ ---
23
+
24
+
25
+ ## [13.5.4](https://github.com/oslokommune/punkt/compare/13.5.3...13.5.4) (2025-09-09)
26
+
27
+ ### ⚠ BREAKING CHANGES
28
+ Ingen
29
+
30
+ ### Features
31
+ Ingen
32
+
33
+ ### Bug Fixes
34
+ Ingen
35
+
36
+ ### Chores
37
+ Ingen
38
+
39
+ ---
40
+
41
+
8
42
  ## [13.5.3](https://github.com/oslokommune/punkt/compare/13.5.2...13.5.3) (2025-09-08)
9
43
 
10
44
  ### ⚠ BREAKING CHANGES
@@ -1,4 +1,9 @@
1
- "use strict";const t=require("./element-6DBpyGQm.cjs"),d=require("./class-map-BBG2gMX4.cjs"),h=require("./state-DPobt-Yz.cjs"),p=require("./ref-iJtiv3o2.cjs"),u=require("./pkt-slot-controller-BzddBp7z.cjs");require("./icon-B_ryAy4Q.cjs");var c=Object.defineProperty,y=Object.getOwnPropertyDescriptor,s=(r,e,a,o)=>{for(var i=o>1?void 0:o?y(e,a):e,n=r.length-1,l;n>=0;n--)(l=r[n])&&(i=(o?l(e,a,i):l(i))||i);return o&&i&&c(e,a,i),i};window.pktAnimationPath=window.pktAnimationPath||"https://punkt-cdn.oslo.kommune.no/latest/animations/";exports.PktLoader=class extends t.PktElement{constructor(){super(),this.defaultSlot=p.e(),this.delay=0,this.inline=!1,this.isLoading=!0,this.message=null,this.size="medium",this.variant="shapes",this.loadingAnimationPath=window.pktAnimationPath,this._shouldDisplayLoader=!1,this.slotController=new u.PktSlotController(this,this.defaultSlot)}connectedCallback(){super.connectedCallback(),this._shouldDisplayLoader=this.delay===0,this.delay>0&&this.setupLoader()}updated(e){e.has("delay")&&this.setupLoader()}render(){const e=d.e({"pkt-loader":!0,[`pkt-loader--${this.inline?"inline":"box"}`]:!0,[`pkt-loader--${this.size}`]:!0}),a=d.e({"pkt-contents":!0,"pkt-hide":this.isLoading});return t.x`<div role="status" aria-live="polite" .aria-busy=${this.isLoading} class=${e}>
1
+ "use strict";const t=require("./element-6DBpyGQm.cjs"),d=require("./class-map-BBG2gMX4.cjs"),h=require("./state-DPobt-Yz.cjs"),p=require("./ref-iJtiv3o2.cjs"),u=require("./pkt-slot-controller-BzddBp7z.cjs");require("./icon-B_ryAy4Q.cjs");var c=Object.defineProperty,y=Object.getOwnPropertyDescriptor,s=(r,e,a,o)=>{for(var i=o>1?void 0:o?y(e,a):e,n=r.length-1,l;n>=0;n--)(l=r[n])&&(i=(o?l(e,a,i):l(i))||i);return o&&i&&c(e,a,i),i};window.pktAnimationPath=window.pktAnimationPath||"https://punkt-cdn.oslo.kommune.no/latest/animations/";exports.PktLoader=class extends t.PktElement{constructor(){super(),this.defaultSlot=p.e(),this.delay=0,this.inline=!1,this.isLoading=!0,this.message=null,this.size="medium",this.variant="shapes",this.loadingAnimationPath=window.pktAnimationPath,this._shouldDisplayLoader=!1,this.slotController=new u.PktSlotController(this,this.defaultSlot)}connectedCallback(){super.connectedCallback(),this._shouldDisplayLoader=this.delay===0,this.delay>0&&this.setupLoader()}updated(e){e.has("delay")&&this.setupLoader()}render(){const e=d.e({"pkt-loader":!0,[`pkt-loader--${this.inline?"inline":"box"}`]:!0,[`pkt-loader--${this.size}`]:!0}),a=d.e({"pkt-contents":!0,"pkt-hide":this.isLoading});return t.x`<div
2
+ role="status"
3
+ aria-live="polite"
4
+ aria-busy=${this.isLoading?"true":"false"}
5
+ class=${e}
6
+ >
2
7
  ${this.isLoading&&this._shouldDisplayLoader?t.x`<div class="pkt-loader__spinner">
3
8
  <pkt-icon
4
9
  name=${this.getVariant(this.variant)}
@@ -29,7 +29,12 @@ let t = class extends u {
29
29
  "pkt-contents": !0,
30
30
  "pkt-hide": this.isLoading
31
31
  });
32
- return d`<div role="status" aria-live="polite" .aria-busy=${this.isLoading} class=${s}>
32
+ return d`<div
33
+ role="status"
34
+ aria-live="polite"
35
+ aria-busy=${this.isLoading ? "true" : "false"}
36
+ class=${s}
37
+ >
33
38
  ${this.isLoading && this._shouldDisplayLoader ? d`<div class="pkt-loader__spinner">
34
39
  <pkt-icon
35
40
  name=${this.getVariant(this.variant)}
@@ -1,4 +1,4 @@
1
- import { P as b, E as u, x as n, n as p, a as m } from "./element-CgEWt74-.js";
1
+ import { P as b, E as d, x as n, n as a, a as m } from "./element-CgEWt74-.js";
2
2
  import { P as h } from "./pkt-slot-controller-BPGj-LC5.js";
3
3
  import { e as f, n as k } from "./ref-BBYSqgeW.js";
4
4
  import { e as _ } from "./class-map-BpTj9gtz.js";
@@ -15,17 +15,17 @@ const x = {
15
15
  closable: {
16
16
  default: !1
17
17
  }
18
- }, d = {
18
+ }, u = {
19
19
  props: x
20
20
  };
21
- var C = Object.defineProperty, y = Object.getOwnPropertyDescriptor, o = (t, l, a, i) => {
22
- for (var s = i > 1 ? void 0 : i ? y(l, a) : l, r = t.length - 1, c; r >= 0; r--)
23
- (c = t[r]) && (s = (i ? c(l, a, s) : c(s)) || s);
24
- return i && s && C(l, a, s), s;
21
+ var C = Object.defineProperty, y = Object.getOwnPropertyDescriptor, o = (t, l, p, i) => {
22
+ for (var s = i > 1 ? void 0 : i ? y(l, p) : l, r = t.length - 1, c; r >= 0; r--)
23
+ (c = t[r]) && (s = (i ? c(l, p, s) : c(s)) || s);
24
+ return i && s && C(l, p, s), s;
25
25
  };
26
26
  let e = class extends b {
27
27
  constructor() {
28
- super(), this.defaultSlot = f(), this.closable = d.props.closable.default, this.compact = d.props.compact.default, this.title = "", this.skin = d.props.skin.default, this._isClosed = !1, this.close = (t) => {
28
+ super(), this.defaultSlot = f(), this.closable = u.props.closable.default, this.compact = u.props.compact.default, this.title = "", this.skin = u.props.skin.default, this._isClosed = !1, this.close = (t) => {
29
29
  this._isClosed = !0, this.dispatchEvent(new CustomEvent("close", { detail: { origin: t }, bubbles: !0 })), this.dispatchEvent(new CustomEvent("on-close", { detail: { origin: t }, bubbles: !0 }));
30
30
  }, this.slotController = new h(this, this.defaultSlot), this._isClosed = !1;
31
31
  }
@@ -47,26 +47,27 @@ let e = class extends b {
47
47
  <button
48
48
  @click=${this.close}
49
49
  class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only"
50
+ aria-label="Lukk"
50
51
  >
51
52
  <pkt-icon name="close" class="pkt-link__icon"></pkt-icon>
52
53
  </button>
53
- </div>` : u}
54
- ${this.title ? n`<div class="pkt-messagebox__title">${this.title}</div>` : u}
54
+ </div>` : d}
55
+ ${this.title ? n`<div class="pkt-messagebox__title">${this.title}</div>` : d}
55
56
  <div class="pkt-messagebox__text" ${k(this.defaultSlot)}></div>
56
57
  </div>`;
57
58
  }
58
59
  };
59
60
  o([
60
- p({ type: Boolean, reflect: !0 })
61
+ a({ type: Boolean, reflect: !0 })
61
62
  ], e.prototype, "closable", 2);
62
63
  o([
63
- p({ type: Boolean, reflect: !0 })
64
+ a({ type: Boolean, reflect: !0 })
64
65
  ], e.prototype, "compact", 2);
65
66
  o([
66
- p({ type: String, reflect: !0 })
67
+ a({ type: String, reflect: !0 })
67
68
  ], e.prototype, "title", 2);
68
69
  o([
69
- p({ type: String, reflect: !0 })
70
+ a({ type: String, reflect: !0 })
70
71
  ], e.prototype, "skin", 2);
71
72
  o([
72
73
  v()
@@ -3,6 +3,7 @@
3
3
  <button
4
4
  @click=${this.close}
5
5
  class="pkt-btn pkt-btn--tertiary pkt-btn--small pkt-btn--icon-only"
6
+ aria-label="Lukk"
6
7
  >
7
8
  <pkt-icon name="close" class="pkt-link__icon"></pkt-icon>
8
9
  </button>
@@ -1,4 +1,4 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("./alert-7rUOhlNi.cjs"),l=require("./accordionitem-Csh7iSVG.cjs"),d=require("./backlink-JbBNi3qg.cjs"),b=require("./button-B8rdtaHB.cjs"),k=require("./calendar-32W9p9uc.cjs"),m=require("./card-DBlFf1ry.cjs"),g=require("./combobox-DjO0RMUB.cjs"),h=require("./consent-hYeFWNFr.cjs"),f=require("./checkbox-Gn7Wtk9h.cjs"),t=require("./element-6DBpyGQm.cjs"),y=require("./pkt-slot-controller-BzddBp7z.cjs"),s=require("./ref-iJtiv3o2.cjs"),O=require("./class-map-BBG2gMX4.cjs"),j=require("./datepicker-CmTrG5GE.cjs"),q=require("./helptext-CzQX6YVE.cjs"),x=require("./heading-CNycsyMj.cjs"),C=require("./icon-B_ryAy4Q.cjs"),v=require("./input-wrapper-CZ-a00V7.cjs"),S=require("./link-Cjl0xwSq.cjs"),$=require("./linkcard-DqIvb54H.cjs"),L=require("./loader-CHPxY9c6.cjs"),_=require("./messagebox-CqUBJs_D.cjs"),A=require("./modal-CRtxhCaP.cjs"),B=require("./progressbar-DhMBXkww.cjs"),p=require("./radiobutton-CdT6v1oq.cjs"),T=require("./tag-Bbs0U_Au.cjs"),I=require("./textarea-CPXsMFUq.cjs"),M=require("./textinput-aNI5kibM.cjs"),R=require("./select-Dkl0KhGW.cjs");var H=Object.defineProperty,w=Object.getOwnPropertyDescriptor,o=(a,e,r,i)=>{for(var n=i>1?void 0:i?w(e,r):e,u=a.length-1,c;u>=0;u--)(c=a[u])&&(n=(i?c(e,r,n):c(n))||n);return i&&n&&H(e,r,n),n};exports.PktComponent=class extends t.PktElement{constructor(){super(),this.string="",this.strings=[],this.darkmode=!1,this._list=[],this.defaultSlot=s.e(),this.namedSlot=s.e(),this.slotController=new y.PktSlotController(this,this.defaultSlot,this.namedSlot)}connectedCallback(){this.strings.length&&this.strings.forEach(e=>{this._list.push(e.toUpperCase())}),super.connectedCallback()}render(){const e={"pkt-component":!0,"pkt-component--has-list":this.strings.length>0,"pkt-darkmode":this.darkmode};return t.x`
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const P=require("./alert-7rUOhlNi.cjs"),l=require("./accordionitem-Csh7iSVG.cjs"),d=require("./backlink-JbBNi3qg.cjs"),b=require("./button-B8rdtaHB.cjs"),k=require("./calendar-32W9p9uc.cjs"),m=require("./card-DBlFf1ry.cjs"),g=require("./combobox-DjO0RMUB.cjs"),h=require("./consent-hYeFWNFr.cjs"),f=require("./checkbox-Gn7Wtk9h.cjs"),t=require("./element-6DBpyGQm.cjs"),y=require("./pkt-slot-controller-BzddBp7z.cjs"),s=require("./ref-iJtiv3o2.cjs"),O=require("./class-map-BBG2gMX4.cjs"),j=require("./datepicker-CmTrG5GE.cjs"),q=require("./helptext-CzQX6YVE.cjs"),x=require("./heading-CNycsyMj.cjs"),C=require("./icon-B_ryAy4Q.cjs"),v=require("./input-wrapper-CZ-a00V7.cjs"),S=require("./link-Cjl0xwSq.cjs"),$=require("./linkcard-DqIvb54H.cjs"),L=require("./loader-DNidjwH-.cjs"),_=require("./messagebox-CjPtPPrW.cjs"),A=require("./modal-CRtxhCaP.cjs"),B=require("./progressbar-DhMBXkww.cjs"),p=require("./radiobutton-CdT6v1oq.cjs"),T=require("./tag-Bbs0U_Au.cjs"),I=require("./textarea-CPXsMFUq.cjs"),M=require("./textinput-aNI5kibM.cjs"),R=require("./select-CD6Zn8YH.cjs");var H=Object.defineProperty,w=Object.getOwnPropertyDescriptor,o=(a,e,r,i)=>{for(var n=i>1?void 0:i?w(e,r):e,u=a.length-1,c;u>=0;u--)(c=a[u])&&(n=(i?c(e,r,n):c(n))||n);return i&&n&&H(e,r,n),n};exports.PktComponent=class extends t.PktElement{constructor(){super(),this.string="",this.strings=[],this.darkmode=!1,this._list=[],this.defaultSlot=s.e(),this.namedSlot=s.e(),this.slotController=new y.PktSlotController(this,this.defaultSlot,this.namedSlot)}connectedCallback(){this.strings.length&&this.strings.forEach(e=>{this._list.push(e.toUpperCase())}),super.connectedCallback()}render(){const e={"pkt-component":!0,"pkt-component--has-list":this.strings.length>0,"pkt-darkmode":this.darkmode};return t.x`
2
2
  <div class="${O.e(e)}">
3
3
  <h1 class="pkt-txt-28">${this.string}</h1>
4
4
 
package/dist/pkt-index.js CHANGED
@@ -19,15 +19,15 @@ import { P as Z } from "./icon-CC1js8eR.js";
19
19
  import { P as et } from "./input-wrapper-Dr__Sxql.js";
20
20
  import { P as ot } from "./link-AIyVfcyH.js";
21
21
  import { P as at } from "./linkcard-9CNlyT0S.js";
22
- import { P as it } from "./loader-Da4IOk_T.js";
23
- import { P as lt } from "./messagebox-DwGdcdm7.js";
22
+ import { P as it } from "./loader-h3d-3D7s.js";
23
+ import { P as lt } from "./messagebox-C8KQgCl_.js";
24
24
  import { P as mt } from "./modal-Zj8yRX3K.js";
25
25
  import { P as ft } from "./progressbar-Dj_mI_A6.js";
26
26
  import { P as ht, P as ct } from "./radiobutton-CWxiIVfA.js";
27
27
  import { P as ut } from "./tag-DyXzTY68.js";
28
28
  import { P as vt } from "./textarea-BZL8Mkm0.js";
29
29
  import { P as bt } from "./textinput-DjPhmmkB.js";
30
- import { P as $t } from "./select-CJS_CIKv.js";
30
+ import { P as $t } from "./select-dcaJHvmR.js";
31
31
  var g = Object.defineProperty, v = Object.getOwnPropertyDescriptor, s = (t, e, i, a) => {
32
32
  for (var r = a > 1 ? void 0 : a ? v(e, i) : e, p = t.length - 1, l; p >= 0; p--)
33
33
  (l = t[p]) && (r = (a ? l(e, i, r) : l(r)) || r);
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./loader-CHPxY9c6.cjs"),t=e.PktLoader;Object.defineProperty(exports,"PktLoader",{enumerable:!0,get:()=>e.PktLoader});exports.default=t;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./loader-DNidjwH-.cjs"),t=e.PktLoader;Object.defineProperty(exports,"PktLoader",{enumerable:!0,get:()=>e.PktLoader});exports.default=t;
@@ -1,4 +1,4 @@
1
- import { P as a } from "./loader-Da4IOk_T.js";
1
+ import { P as a } from "./loader-h3d-3D7s.js";
2
2
  const t = a;
3
3
  export {
4
4
  a as PktLoader,
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./messagebox-CqUBJs_D.cjs"),t=e.PktMessagebox;Object.defineProperty(exports,"PktMessagebox",{enumerable:!0,get:()=>e.PktMessagebox});exports.default=t;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./messagebox-CjPtPPrW.cjs"),t=e.PktMessagebox;Object.defineProperty(exports,"PktMessagebox",{enumerable:!0,get:()=>e.PktMessagebox});exports.default=t;
@@ -1,4 +1,4 @@
1
- import { P as s } from "./messagebox-DwGdcdm7.js";
1
+ import { P as s } from "./messagebox-C8KQgCl_.js";
2
2
  const a = s;
3
3
  export {
4
4
  s as PktMessagebox,
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./select-Dkl0KhGW.cjs"),t=e.PktSelect;Object.defineProperty(exports,"PktSelect",{enumerable:!0,get:()=>e.PktSelect});exports.default=t;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("./select-CD6Zn8YH.cjs"),t=e.PktSelect;Object.defineProperty(exports,"PktSelect",{enumerable:!0,get:()=>e.PktSelect});exports.default=t;
@@ -1,4 +1,4 @@
1
- import { P as t } from "./select-CJS_CIKv.js";
1
+ import { P as t } from "./select-dcaJHvmR.js";
2
2
  const a = t;
3
3
  export {
4
4
  t as PktSelect,
@@ -1,4 +1,4 @@
1
- "use strict";const r=require("./element-6DBpyGQm.cjs"),p=require("./state-DPobt-Yz.cjs"),h=require("./ref-iJtiv3o2.cjs"),l=require("./if-defined-Cni-RHLS.cjs"),d=require("./input-element-C4xJoM-X.cjs"),c=require("./pkt-options-controller-CiuBG6Lt.cjs"),v=require("./pkt-slot-controller-BzddBp7z.cjs");require("./input-wrapper-CZ-a00V7.cjs");var f=Object.defineProperty,b=Object.getOwnPropertyDescriptor,a=(u,t,e,s)=>{for(var i=s>1?void 0:s?b(t,e):t,o=u.length-1,n;o>=0;o--)(n=u[o])&&(i=(s?n(t,e,i):n(i))||i);return s&&i&&f(t,e,i),i};exports.PktSelect=class extends d.PktInputElement{constructor(){super(),this.inputRef=h.e(),this.helptextSlot=h.e(),this.options=[],this.value="",this._options=[],this.selectedIndex=-1,this.selectedOptions=void 0,this.optionsController=new c.PktOptionsSlotController(this),this.slotController=new v.PktSlotController(this,this.helptextSlot),this.slotController.skipOptions=!0}connectedCallback(){super.connectedCallback();const t=this.options.length>0,e=this.optionsController.nodes.length&&this.optionsController.nodes.length>0;!t&&e?this.optionsController.nodes.forEach(s=>{const i={value:s.hasAttribute("value")?s.getAttribute("value")??"":s.textContent??"",label:s.textContent||s.getAttribute("value")||"",disabled:s.hasAttribute("disabled"),selected:s.hasAttribute("selected"),hidden:s.hasAttribute("data-hidden")};s.getAttribute("selected")&&!this.value&&(this.value=i.value),this._options.push(i)}):(this._options=this.options,this._options.forEach(s=>{s.selected&&!this.value&&(this.value=s.value)}))}add(t,e){var s,i,o;(s=this.inputRef.value)==null||s.add(t,e),this._options.push({value:t.value||t.text,label:t.text||t.value,selected:t.selected,disabled:t.disabled}),t.selected&&(this.value=t.value||t.text,this.selectedIndex=this.returnNumberOrNull((i=this.inputRef.value)==null?void 0:i.selectedIndex),this.selectedOptions=(o=this.inputRef.value)==null?void 0:o.selectedOptions),this.requestUpdate()}remove(t){var e,s;typeof t=="number"&&(this.selectedIndex===t&&(this.value=((e=this._options[0])==null?void 0:e.value)||""),(s=this.inputRef.value)==null||s.remove(t))}item(t){var e;return(e=this.inputRef.value)==null?void 0:e.item(t)}namedItem(t){var e;return(e=this.inputRef.value)==null?void 0:e.namedItem(t)}showPicker(){var t;(t=this.inputRef.value)==null||t.showPicker()}attributeChangedCallback(t,e,s){var i,o;t==="options"&&(this._options=s?JSON.parse(s):[]),t==="value"&&this.value!==e&&(this.selectedIndex=this.touched?this.returnNumberOrNull((i=this.inputRef.value)==null?void 0:i.selectedIndex):this.options.findIndex(n=>n.value===s),this.selectedOptions=(o=this.inputRef.value)==null?void 0:o.selectedOptions,this.valueChanged(s,e)),super.attributeChangedCallback(t,e,s)}update(t){var e,s;super.update(t),t.has("value")&&this.value!==t.get("value")&&(this.selectedIndex=this.touched?this.returnNumberOrNull((e=this.inputRef.value)==null?void 0:e.selectedIndex):this.options.findIndex(i=>i.value===this.value),this.selectedOptions=(s=this.inputRef.value)==null?void 0:s.selectedOptions,this.valueChanged(this.value,t.get("value"))),t.has("id")&&!this.name&&this.id&&(this.name=this.id)}firstUpdated(t){var e;super.firstUpdated(t),this.options.length&&(this._options=this.options),!this.value&&this._options.length>0?(this.value=this._options[0].value,this.selectedIndex=0):this.selectedIndex=this._options.findIndex(s=>s.value===this.value),this.selectedOptions=(e=this.inputRef.value)==null?void 0:e.selectedOptions}render(){const t=`pkt-input ${this.fullwidth?"pkt-input--fullwidth":""}`;return r.x`
1
+ "use strict";const h=require("./element-6DBpyGQm.cjs"),p=require("./state-DPobt-Yz.cjs"),r=require("./ref-iJtiv3o2.cjs"),l=require("./if-defined-Cni-RHLS.cjs"),d=require("./input-element-C4xJoM-X.cjs"),c=require("./pkt-options-controller-CiuBG6Lt.cjs"),v=require("./pkt-slot-controller-BzddBp7z.cjs");require("./input-wrapper-CZ-a00V7.cjs");var f=Object.defineProperty,b=Object.getOwnPropertyDescriptor,a=(u,t,e,s)=>{for(var i=s>1?void 0:s?b(t,e):t,o=u.length-1,n;o>=0;o--)(n=u[o])&&(i=(s?n(t,e,i):n(i))||i);return s&&i&&f(t,e,i),i};exports.PktSelect=class extends d.PktInputElement{constructor(){super(),this.inputRef=r.e(),this.helptextSlot=r.e(),this.options=[],this.value="",this._options=[],this.selectedIndex=-1,this.selectedOptions=void 0,this.optionsController=new c.PktOptionsSlotController(this),this.slotController=new v.PktSlotController(this,this.helptextSlot),this.slotController.skipOptions=!0}connectedCallback(){super.connectedCallback();const t=this.options.length>0,e=this.optionsController.nodes.length&&this.optionsController.nodes.length>0;!t&&e?this.optionsController.nodes.forEach(s=>{const i={value:s.hasAttribute("value")?s.getAttribute("value")??"":s.textContent??"",label:s.textContent||s.getAttribute("value")||"",disabled:s.hasAttribute("disabled"),selected:s.hasAttribute("selected"),hidden:s.hasAttribute("data-hidden")};s.getAttribute("selected")&&!this.value&&(this.value=i.value),this._options.push(i)}):(this._options=this.options,this._options.forEach(s=>{s.selected&&!this.value&&(this.value=s.value)}))}add(t,e){var s,i,o;(s=this.inputRef.value)==null||s.add(t,e),this._options.push({value:t.value||t.text,label:t.text||t.value,selected:t.selected,disabled:t.disabled}),t.selected&&(this.value=t.value||t.text,this.selectedIndex=this.returnNumberOrNull((i=this.inputRef.value)==null?void 0:i.selectedIndex),this.selectedOptions=(o=this.inputRef.value)==null?void 0:o.selectedOptions),this.requestUpdate()}remove(t){var e,s;typeof t=="number"&&(this.selectedIndex===t&&(this.value=((e=this._options[0])==null?void 0:e.value)||""),(s=this.inputRef.value)==null||s.remove(t))}item(t){var e;return(e=this.inputRef.value)==null?void 0:e.item(t)}namedItem(t){var e;return(e=this.inputRef.value)==null?void 0:e.namedItem(t)}showPicker(){var t;(t=this.inputRef.value)==null||t.showPicker()}attributeChangedCallback(t,e,s){var i,o;t==="options"&&(this._options=s?JSON.parse(s):[]),t==="value"&&this.value!==e&&(this.selectedIndex=this.touched?this.returnNumberOrNull((i=this.inputRef.value)==null?void 0:i.selectedIndex):this.options.findIndex(n=>n.value===s),this.selectedOptions=(o=this.inputRef.value)==null?void 0:o.selectedOptions,this.valueChanged(s,e)),super.attributeChangedCallback(t,e,s)}update(t){var e,s;super.update(t),t.has("options")&&(this._options=this.options,this.requestUpdate("_options"),!this.value&&this._options.length>0&&(this.value=this._options[0].value,this.selectedIndex=0)),t.has("value")&&this.value!==t.get("value")&&(this.selectedIndex=this.touched?this.returnNumberOrNull((e=this.inputRef.value)==null?void 0:e.selectedIndex):this.options.findIndex(i=>i.value===this.value),this.selectedOptions=(s=this.inputRef.value)==null?void 0:s.selectedOptions,this.valueChanged(this.value,t.get("value"))),t.has("id")&&!this.name&&this.id&&(this.name=this.id)}firstUpdated(t){var e;super.firstUpdated(t),this.options.length&&(this._options=this.options),!this.value&&this._options.length>0?(this.value=this._options[0].value,this.selectedIndex=0):this.selectedIndex=this._options.findIndex(s=>s.value===this.value),this.selectedOptions=(e=this.inputRef.value)==null?void 0:e.selectedOptions}render(){const t=`pkt-input ${this.fullwidth?"pkt-input--fullwidth":""}`;return h.x`
2
2
  <pkt-input-wrapper
3
3
  ?counter=${this.counter}
4
4
  ?disabled=${this.disabled}
@@ -33,17 +33,17 @@
33
33
  @input=${e=>{this.onInput(),e.stopImmediatePropagation()}}
34
34
  @focus=${e=>{this.onFocus(),e.stopImmediatePropagation()}}
35
35
  @blur=${e=>{this.onBlur(),e.stopImmediatePropagation()}}
36
- ${h.n(this.inputRef)}
36
+ ${r.n(this.inputRef)}
37
37
  >
38
- ${this._options.length>0&&this._options.map(e=>r.x`<option
39
- value=${e.value}
40
- ?selected=${this.value==e.value||e.selected}
41
- ?disabled=${e.disabled}
42
- ?hidden=${e.hidden}
43
- >
44
- ${e.label}
45
- </option>`)}
38
+ ${this._options.length>0?this._options.map(e=>h.x`<option
39
+ value=${e.value}
40
+ ?selected=${this.value==e.value||e.selected}
41
+ ?disabled=${e.disabled}
42
+ ?hidden=${e.hidden}
43
+ >
44
+ ${e.label}
45
+ </option>`):""}
46
46
  </select>
47
- <div class="pkt-contents" ${h.n(this.helptextSlot)} name="helptext" slot="helptext"></div>
47
+ <div class="pkt-contents" ${r.n(this.helptextSlot)} name="helptext" slot="helptext"></div>
48
48
  </pkt-input-wrapper>
49
- `}returnNumberOrNull(t){return t==null||isNaN(t)?null:t}};a([r.n({type:Array})],exports.PktSelect.prototype,"options",2);a([r.n({type:String})],exports.PktSelect.prototype,"value",2);a([p.r()],exports.PktSelect.prototype,"_options",2);exports.PktSelect=a([r.t("pkt-select")],exports.PktSelect);
49
+ `}returnNumberOrNull(t){return t==null||isNaN(t)?null:t}};a([h.n({type:Array})],exports.PktSelect.prototype,"options",2);a([h.n({type:String})],exports.PktSelect.prototype,"value",2);a([p.r()],exports.PktSelect.prototype,"_options",2);exports.PktSelect=a([h.t("pkt-select")],exports.PktSelect);
@@ -7,11 +7,11 @@ import { P as $ } from "./pkt-options-controller-CZO1nxZ8.js";
7
7
  import { P as x } from "./pkt-slot-controller-BPGj-LC5.js";
8
8
  import "./input-wrapper-Dr__Sxql.js";
9
9
  var m = Object.defineProperty, g = Object.getOwnPropertyDescriptor, n = (t, e, s, i) => {
10
- for (var l = i > 1 ? void 0 : i ? g(e, s) : e, a = t.length - 1, r; a >= 0; a--)
11
- (r = t[a]) && (l = (i ? r(e, s, l) : r(l)) || l);
10
+ for (var l = i > 1 ? void 0 : i ? g(e, s) : e, h = t.length - 1, r; h >= 0; h--)
11
+ (r = t[h]) && (l = (i ? r(e, s, l) : r(l)) || l);
12
12
  return i && l && m(e, s, l), l;
13
13
  };
14
- let h = class extends b {
14
+ let a = class extends b {
15
15
  constructor() {
16
16
  super(), this.inputRef = u(), this.helptextSlot = u(), this.options = [], this.value = "", this._options = [], this.selectedIndex = -1, this.selectedOptions = void 0, this.optionsController = new $(this), this.slotController = new x(this, this.helptextSlot), this.slotController.skipOptions = !0;
17
17
  }
@@ -64,11 +64,11 @@ let h = class extends b {
64
64
  }
65
65
  attributeChangedCallback(t, e, s) {
66
66
  var i, l;
67
- t === "options" && (this._options = s ? JSON.parse(s) : []), t === "value" && this.value !== e && (this.selectedIndex = this.touched ? this.returnNumberOrNull((i = this.inputRef.value) == null ? void 0 : i.selectedIndex) : this.options.findIndex((a) => a.value === s), this.selectedOptions = (l = this.inputRef.value) == null ? void 0 : l.selectedOptions, this.valueChanged(s, e)), super.attributeChangedCallback(t, e, s);
67
+ t === "options" && (this._options = s ? JSON.parse(s) : []), t === "value" && this.value !== e && (this.selectedIndex = this.touched ? this.returnNumberOrNull((i = this.inputRef.value) == null ? void 0 : i.selectedIndex) : this.options.findIndex((h) => h.value === s), this.selectedOptions = (l = this.inputRef.value) == null ? void 0 : l.selectedOptions, this.valueChanged(s, e)), super.attributeChangedCallback(t, e, s);
68
68
  }
69
69
  update(t) {
70
70
  var e, s;
71
- super.update(t), t.has("value") && this.value !== t.get("value") && (this.selectedIndex = this.touched ? this.returnNumberOrNull((e = this.inputRef.value) == null ? void 0 : e.selectedIndex) : this.options.findIndex((i) => i.value === this.value), this.selectedOptions = (s = this.inputRef.value) == null ? void 0 : s.selectedOptions, this.valueChanged(this.value, t.get("value"))), t.has("id") && !this.name && this.id && (this.name = this.id);
71
+ super.update(t), t.has("options") && (this._options = this.options, this.requestUpdate("_options"), !this.value && this._options.length > 0 && (this.value = this._options[0].value, this.selectedIndex = 0)), t.has("value") && this.value !== t.get("value") && (this.selectedIndex = this.touched ? this.returnNumberOrNull((e = this.inputRef.value) == null ? void 0 : e.selectedIndex) : this.options.findIndex((i) => i.value === this.value), this.selectedOptions = (s = this.inputRef.value) == null ? void 0 : s.selectedOptions, this.valueChanged(this.value, t.get("value"))), t.has("id") && !this.name && this.id && (this.name = this.id);
72
72
  }
73
73
  firstUpdated(t) {
74
74
  var e;
@@ -121,16 +121,16 @@ let h = class extends b {
121
121
  }}
122
122
  ${d(this.inputRef)}
123
123
  >
124
- ${this._options.length > 0 && this._options.map(
124
+ ${this._options.length > 0 ? this._options.map(
125
125
  (e) => p`<option
126
- value=${e.value}
127
- ?selected=${this.value == e.value || e.selected}
128
- ?disabled=${e.disabled}
129
- ?hidden=${e.hidden}
130
- >
131
- ${e.label}
132
- </option>`
133
- )}
126
+ value=${e.value}
127
+ ?selected=${this.value == e.value || e.selected}
128
+ ?disabled=${e.disabled}
129
+ ?hidden=${e.hidden}
130
+ >
131
+ ${e.label}
132
+ </option>`
133
+ ) : ""}
134
134
  </select>
135
135
  <div class="pkt-contents" ${d(this.helptextSlot)} name="helptext" slot="helptext"></div>
136
136
  </pkt-input-wrapper>
@@ -142,16 +142,16 @@ let h = class extends b {
142
142
  };
143
143
  n([
144
144
  c({ type: Array })
145
- ], h.prototype, "options", 2);
145
+ ], a.prototype, "options", 2);
146
146
  n([
147
147
  c({ type: String })
148
- ], h.prototype, "value", 2);
148
+ ], a.prototype, "value", 2);
149
149
  n([
150
150
  f()
151
- ], h.prototype, "_options", 2);
152
- h = n([
151
+ ], a.prototype, "_options", 2);
152
+ a = n([
153
153
  v("pkt-select")
154
- ], h);
154
+ ], a);
155
155
  export {
156
- h as P
156
+ a as P
157
157
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oslokommune/punkt-elements",
3
- "version": "13.5.3",
3
+ "version": "13.5.5",
4
4
  "description": "Komponentbiblioteket til Punkt, et designsystem laget av Oslo Origo",
5
5
  "homepage": "https://punkt.oslo.kommune.no",
6
6
  "author": "Team Designsystem, Oslo Origo",
@@ -73,5 +73,5 @@
73
73
  "url": "https://github.com/oslokommune/punkt/issues"
74
74
  },
75
75
  "license": "MIT",
76
- "gitHead": "6b43945924c71b96b609f1abc7875e139e297233"
76
+ "gitHead": "f65d3c81c0543cc360a34fe346b4e0585deb46ac"
77
77
  }
@@ -0,0 +1,225 @@
1
+ import '@testing-library/jest-dom'
2
+ import { axe, toHaveNoViolations } from 'jest-axe'
3
+ import { fireEvent } from '@testing-library/dom'
4
+ import { createElementTest, BaseTestConfig } from '../../tests/test-framework'
5
+ import { CustomElementFor } from '../../tests/component-registry'
6
+ import { type IPktListbox } from './listbox'
7
+ import './listbox'
8
+
9
+ export interface ListboxTestConfig extends Partial<IPktListbox>, BaseTestConfig {
10
+ label?: string
11
+ id?: string
12
+ }
13
+
14
+ // Use shared framework
15
+ export const createListboxTest = async (config: ListboxTestConfig = {}) => {
16
+ const { container, element } = await createElementTest<
17
+ CustomElementFor<'pkt-listbox'>,
18
+ ListboxTestConfig
19
+ >('pkt-listbox', { ...config, options: undefined })
20
+
21
+ // Set complex properties directly on the element after creation
22
+ if (config.options) {
23
+ element.options = config.options
24
+ await element.updateComplete
25
+ }
26
+
27
+ return {
28
+ container,
29
+ listbox: element,
30
+ }
31
+ }
32
+
33
+ expect.extend(toHaveNoViolations)
34
+
35
+ // Cleanup after each test
36
+ afterEach(() => {
37
+ document.body.innerHTML = ''
38
+ })
39
+
40
+ describe('PktListbox', () => {
41
+ describe('Rendering and basic functionality', () => {
42
+ test('renders without errors', async () => {
43
+ const { listbox } = await createListboxTest()
44
+
45
+ expect(listbox).toBeInTheDocument()
46
+ expect(listbox).toBeTruthy()
47
+ })
48
+
49
+ test('renders with options', async () => {
50
+ const options = [
51
+ { value: 'option1', label: 'Option 1' },
52
+ { value: 'option2', label: 'Option 2' },
53
+ ]
54
+ const { listbox } = await createListboxTest({
55
+ label: 'Test Listbox',
56
+ options,
57
+ })
58
+
59
+ const listboxElement = listbox.querySelector('.pkt-listbox')
60
+ expect(listboxElement).toBeInTheDocument()
61
+
62
+ const optionElements = listbox.querySelectorAll('.pkt-listbox__option')
63
+ expect(optionElements).toHaveLength(2)
64
+ })
65
+ })
66
+
67
+ describe('Properties and attributes', () => {
68
+ test('applies default properties correctly', async () => {
69
+ const { listbox } = await createListboxTest()
70
+
71
+ expect(listbox.isOpen).toBe(false)
72
+ expect(listbox.disabled).toBe(false)
73
+ expect(listbox.includeSearch).toBe(false)
74
+ expect(listbox.isMultiSelect).toBe(false)
75
+ expect(listbox.allowUserInput).toBe(false)
76
+ expect(listbox.maxLength).toBe(0)
77
+ })
78
+
79
+ test('sets properties correctly', async () => {
80
+ const { listbox } = await createListboxTest({
81
+ isOpen: true,
82
+ disabled: true,
83
+ includeSearch: true,
84
+ isMultiSelect: true,
85
+ })
86
+
87
+ expect(listbox.isOpen).toBe(true)
88
+ expect(listbox.disabled).toBe(true)
89
+ expect(listbox.includeSearch).toBe(true)
90
+ expect(listbox.isMultiSelect).toBe(true)
91
+ })
92
+ })
93
+
94
+ describe('Option handling', () => {
95
+ test('renders single select options correctly', async () => {
96
+ const options = [
97
+ { value: 'option1', label: 'Option 1', selected: true },
98
+ { value: 'option2', label: 'Option 2' },
99
+ ]
100
+ const { listbox } = await createListboxTest({ options })
101
+
102
+ const selectedOption = listbox.querySelector('.pkt-listbox__option--selected')
103
+ expect(selectedOption).toBeInTheDocument()
104
+
105
+ const checkIcon = listbox.querySelector('pkt-icon[name="check-big"]')
106
+ expect(checkIcon).toBeInTheDocument()
107
+ })
108
+
109
+ test('renders multi-select options with checkboxes', async () => {
110
+ const options = [
111
+ { value: 'option1', label: 'Option 1', selected: true },
112
+ { value: 'option2', label: 'Option 2' },
113
+ ]
114
+ const { listbox } = await createListboxTest({
115
+ isMultiSelect: true,
116
+ options,
117
+ })
118
+
119
+ const checkboxes = listbox.querySelectorAll('input[type="checkbox"]')
120
+ expect(checkboxes).toHaveLength(2)
121
+ expect(checkboxes[0]).toBeChecked()
122
+ expect(checkboxes[1]).not.toBeChecked()
123
+ })
124
+
125
+ test('handles option click', async () => {
126
+ const options = [
127
+ { value: 'option1', label: 'Option 1' },
128
+ { value: 'option2', label: 'Option 2' },
129
+ ]
130
+ const { listbox } = await createListboxTest({ options })
131
+
132
+ // Listen for the option-toggle event
133
+ let toggledValue: string | null = null
134
+ listbox.addEventListener('option-toggle', (e: any) => {
135
+ toggledValue = e.detail
136
+ })
137
+
138
+ const optionElement = listbox.querySelector('.pkt-listbox__option')
139
+ fireEvent.click(optionElement!)
140
+
141
+ await listbox.updateComplete
142
+ expect(toggledValue).toBe('option1')
143
+ })
144
+ })
145
+
146
+ describe('Search functionality', () => {
147
+ test('renders search when includeSearch is true', async () => {
148
+ const { listbox } = await createListboxTest({ includeSearch: true })
149
+
150
+ const searchInput = listbox.querySelector('[role="searchbox"]')
151
+ expect(searchInput).toBeInTheDocument()
152
+ })
153
+
154
+ test('filters options based on search', async () => {
155
+ const options = [
156
+ { value: 'apple', label: 'Apple' },
157
+ { value: 'banana', label: 'Banana' },
158
+ ]
159
+ const { listbox } = await createListboxTest({
160
+ includeSearch: true,
161
+ options,
162
+ })
163
+
164
+ // Set search value and trigger filtering
165
+ listbox.searchValue = 'app'
166
+ listbox.filterOptions()
167
+ await listbox.updateComplete
168
+
169
+ // Should filter to only show Apple - check filtered options
170
+ const visibleOptions = listbox.querySelectorAll('.pkt-listbox__option')
171
+ expect(visibleOptions).toHaveLength(1)
172
+ expect(visibleOptions[0].textContent?.trim()).toContain('Apple')
173
+ })
174
+ })
175
+
176
+ describe('User input functionality', () => {
177
+ test('renders new option banner when allowUserInput is true', async () => {
178
+ const { listbox } = await createListboxTest({
179
+ allowUserInput: true,
180
+ customUserInput: 'New',
181
+ })
182
+
183
+ const newOptionBanner = listbox.querySelector('.pkt-listbox__banner--new-option')
184
+ expect(newOptionBanner).toBeInTheDocument()
185
+ expect(newOptionBanner?.getAttribute('data-value')).toBe('New')
186
+ // Check that the text contains the basic structure
187
+ expect(newOptionBanner?.textContent).toMatch(/Legg til.*New/)
188
+ })
189
+ })
190
+
191
+ describe('Maximum selection', () => {
192
+ test('shows maximum reached banner', async () => {
193
+ const options = [
194
+ { value: 'option1', label: 'Option 1', selected: true },
195
+ { value: 'option2', label: 'Option 2', selected: true },
196
+ ]
197
+ const { listbox } = await createListboxTest({
198
+ isMultiSelect: true,
199
+ maxLength: 3,
200
+ options,
201
+ })
202
+
203
+ const banner = listbox.querySelector('.pkt-listbox__banner--maximum-reached')
204
+ expect(banner).toBeInTheDocument()
205
+ expect(banner?.textContent).toContain('2 av maks 3')
206
+ })
207
+ })
208
+
209
+ describe('Accessibility', () => {
210
+ test('basic listbox is accessible', async () => {
211
+ const options = [
212
+ { value: 'option1', label: 'Option 1' },
213
+ { value: 'option2', label: 'Option 2' },
214
+ ]
215
+ const { container } = await createListboxTest({
216
+ label: 'Accessible Listbox',
217
+ options,
218
+ })
219
+ await new Promise((resolve) => setTimeout(resolve, 100))
220
+
221
+ const results = await axe(container)
222
+ expect(results).toHaveNoViolations()
223
+ })
224
+ })
225
+ })