@oslokommune/punkt-elements 18.7.2 → 18.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/dist/{checkbox-CddODhna.cjs → checkbox-CBZEGmqa.cjs} +15 -7
- package/dist/{checkbox-C6JdANel.js → checkbox-COw1Uwnm.js} +15 -7
- package/dist/docs/components/switch.d.ts +4 -0
- package/dist/pkt-checkbox.cjs +1 -1
- package/dist/pkt-checkbox.js +1 -1
- package/dist/pkt-index.cjs +1 -1
- package/dist/pkt-index.js +2 -2
- package/dist/pkt-radiobutton.cjs +1 -1
- package/dist/pkt-radiobutton.js +1 -1
- package/dist/{radiobutton-CdwYbHnx.cjs → radiobutton-BEzjKx1J.cjs} +15 -7
- package/dist/{radiobutton-B2P48MMf.js → radiobutton-Cpwa5ezn.js} +15 -7
- package/package.json +2 -2
- package/src/components/checkbox/checkbox.test.ts +1 -1
- package/src/components/checkbox/checkbox.ts +32 -13
- package/src/components/radiobutton/radiobutton.test.ts +1 -1
- package/src/components/radiobutton/radiobutton.ts +32 -13
package/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,28 @@ og skriver commits ca etter [Conventional Commits](https://conventionalcommits.o
|
|
|
5
5
|
|
|
6
6
|
---
|
|
7
7
|
|
|
8
|
+
## [18.8.0](https://github.com/oslokommune/punkt/compare/18.7.3...18.8.0) (2026-09-16)
|
|
9
|
+
|
|
10
|
+
### ⚠ BREAKING CHANGES
|
|
11
|
+
Ingen
|
|
12
|
+
|
|
13
|
+
### Features
|
|
14
|
+
* Radio, check og switch: Klikkflate, aria-forbedring og testdekning (#3651). - Fikset klikkområdet til alle tre, slik at hele området er klikkbart både med og uten tile
|
|
15
|
+
- Forbedret UU-oppførsel for alle tre, med aria-label og aria-describedby på input som peker til label og hjelpetekst. Bedre enn at label skal inneholde hjelpetekst
|
|
16
|
+
- Oppdaterte alle demo-/testsider med inline-eksempler
|
|
17
|
+
- Betraktelig oppskalering av testdekning i enhetstester, e2e og conformance
|
|
18
|
+
- Endringer i skills som reflekterer alt dette
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
### Bug Fixes
|
|
22
|
+
Ingen
|
|
23
|
+
|
|
24
|
+
### Chores
|
|
25
|
+
Ingen
|
|
26
|
+
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
|
|
8
30
|
## [18.7.2](https://github.com/oslokommune/punkt/compare/18.7.1...18.7.2) (2026-09-14)
|
|
9
31
|
|
|
10
32
|
### ⚠ BREAKING CHANGES
|
|
@@ -1,16 +1,22 @@
|
|
|
1
1
|
const e=require("./element-D_mCyFeX.cjs"),t=require("./class-map-DupQbnhE.cjs"),n=require("./ref-AuNEkS5a.cjs"),r=require("./input-element-DhIEFeuP.cjs");var i=class extends r.t{constructor(...e){super(...e),this.inputRef=n.t(),this.value=``,this.checkHelptext=null,this.defaultChecked=!1,this.hasTile=!1,this.isSwitch=!1,this.labelPosition=`right`,this.hideLabel=!1,this.checked=null,this.indeterminate=!1,this.type=`checkbox`,this.tagText=null,this.optionalTag=!1,this.requiredTag=!1}connectedCallback(){super.connectedCallback()}attributeChangedCallback(e,t,n){e===`defaultChecked`&&!this.checked&&(this.checked=this.defaultChecked),e===`checked`&&(this.checked=this.checked===``||this.checked===`true`||this.checked===!0,this.inputRef.value&&(this.inputRef.value.checked=this.checked)),e===`indeterminate`&&(this.indeterminate=this.indeterminate===``||this.indeterminate===`true`||this.indeterminate===!0,this.inputRef.value&&(this.inputRef.value.indeterminate=this.indeterminate)),super.attributeChangedCallback(e,t,n)}firstUpdated(e){this.inputRef.value&&(this.inputRef.value.indeterminate=this.indeterminate===``||this.indeterminate===`true`||this.indeterminate===!0),super.firstUpdated(e)}willUpdate(e){super.willUpdate(e),e.has(`defaultChecked`)&&!this.checked&&(this.checked=this.defaultChecked)}updated(e){e.has(`checked`)&&this.inputRef.value&&(this.inputRef.value.checked=this.checked===``||this.checked===`true`||this.checked===!0),e.has(`indeterminate`)&&this.inputRef.value&&(this.inputRef.value.indeterminate=this.indeterminate===``||this.indeterminate===`true`||this.indeterminate===!0),super.updated(e)}render(){let r=t.t({"pkt-input-check__input":!0,"pkt-input-check__input--tile":this.hasTile,"pkt-input-check__input--tile-disabled":this.disabled&&this.hasTile}),i=t.t({"pkt-input-check__input-checkbox":!0,"pkt-input-check__input-checkbox--error":this.hasError}),a=t.t({"pkt-input-check__input-label":!0,"pkt-input-check__input-label--disabled":this.disabled,"pkt-input-check__input-label--left":this.labelPosition===`left`,"pkt-input-check__input-label--right":this.labelPosition===`right`,"pkt-sr-only":this.hideLabel}),o=`pkt-tag pkt-tag--small pkt-tag--thin-text`,s=this.pktStrings.get(`forms`),c=()=>e._`
|
|
2
2
|
${this.tagText?e._`<span class=${o+` pkt-tag--gray`}>${this.tagText}</span>`:e.h}
|
|
3
|
-
${this.optionalTag?e._`<span class=${o+` pkt-tag--blue-light`}
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
${this.optionalTag?e._`<span class=${o+` pkt-tag--blue-light`}
|
|
4
|
+
>${this.optionalText??s.optional}</span
|
|
5
|
+
>`:e.h}
|
|
6
|
+
${this.requiredTag?e._`<span class=${o+` pkt-tag--beige`}
|
|
7
|
+
>${this.requiredText??s.required}</span
|
|
8
|
+
>`:e.h}
|
|
9
|
+
`,l=this.id+`-check-label`,u=this.id+`-check-helptext`,d=()=>e._`
|
|
6
10
|
<label class=${a} for=${this.id+`-internal`}>
|
|
7
|
-
|
|
8
|
-
${this.checkHelptext?e._`<div class="pkt-input-check__input-helptext"
|
|
11
|
+
<span id=${l}>${this.label} ${c()}</span>
|
|
12
|
+
${this.checkHelptext?e._`<div id=${u} class="pkt-input-check__input-helptext">
|
|
13
|
+
${this.checkHelptext}
|
|
14
|
+
</div>`:e.h}
|
|
9
15
|
</label>
|
|
10
16
|
`;return e._`
|
|
11
17
|
<div class="pkt-input-check">
|
|
12
18
|
<div class=${r}>
|
|
13
|
-
${this.labelPosition===`left`?
|
|
19
|
+
${this.labelPosition===`left`?d():e.h}
|
|
14
20
|
<input
|
|
15
21
|
id=${this.id+`-internal`}
|
|
16
22
|
class=${i}
|
|
@@ -25,8 +31,10 @@ const e=require("./element-D_mCyFeX.cjs"),t=require("./class-map-DupQbnhE.cjs"),
|
|
|
25
31
|
@focus=${this.onFocus}
|
|
26
32
|
?checked=${this.checked}
|
|
27
33
|
role=${this.isSwitch?`switch`:`checkbox`}
|
|
34
|
+
aria-labelledby=${this.label?l:e.h}
|
|
35
|
+
aria-describedby=${this.checkHelptext?u:e.h}
|
|
28
36
|
/>
|
|
29
|
-
${this.labelPosition===`right`?
|
|
37
|
+
${this.labelPosition===`right`?d():e.h}
|
|
30
38
|
</div>
|
|
31
39
|
</div>
|
|
32
40
|
`}handleInput(e){e.stopImmediatePropagation(),this.onInput()}handleClick(e){if(this.disabled)return e.preventDefault(),e.stopImmediatePropagation(),!1}handleChange(e){if(this.disabled)return e.preventDefault(),e.stopImmediatePropagation(),!1;this.toggleChecked(e)}toggleChecked(e){if(this.disabled){e.preventDefault(),e.stopImmediatePropagation();return}let t=e.target;if(t&&t.disabled){e.preventDefault(),e.stopImmediatePropagation();return}e.stopImmediatePropagation(),this.touched=!0,this.inputRef.value&&(this.checked=this.inputRef.value.matches(`:checked`),this.valueChecked(this.checked))}};e.n([e.u({type:String,reflect:!0})],i.prototype,`value`,void 0),e.n([e.u({type:String})],i.prototype,`checkHelptext`,void 0),e.n([e.u({type:Boolean})],i.prototype,`defaultChecked`,void 0),e.n([e.u({type:Boolean})],i.prototype,`hasTile`,void 0),e.n([e.u({type:Boolean})],i.prototype,`isSwitch`,void 0),e.n([e.u({type:String})],i.prototype,`labelPosition`,void 0),e.n([e.u({type:Boolean})],i.prototype,`hideLabel`,void 0),e.n([e.u({type:Boolean,reflect:!0})],i.prototype,`checked`,void 0),e.n([e.u({type:Boolean,reflect:!0})],i.prototype,`indeterminate`,void 0),e.n([e.u({type:String,reflect:!0})],i.prototype,`type`,void 0),e.n([e.u({type:String})],i.prototype,`tagText`,void 0),e.n([e.u({type:Boolean})],i.prototype,`optionalTag`,void 0),e.n([e.u({type:String})],i.prototype,`optionalText`,void 0),e.n([e.u({type:Boolean})],i.prototype,`requiredTag`,void 0),e.n([e.u({type:String})],i.prototype,`requiredText`,void 0);try{e.d(`pkt-checkbox`)(i)}catch{console.warn(`Forsøker å definere <pkt-checkbox>, men den er allerede definert`)}var a=i;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return i}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return a}});
|
|
@@ -38,18 +38,24 @@ var l = class extends c {
|
|
|
38
38
|
"pkt-sr-only": this.hideLabel
|
|
39
39
|
}), s = "pkt-tag pkt-tag--small pkt-tag--thin-text", c = this.pktStrings.get("forms"), l = () => e`
|
|
40
40
|
${this.tagText ? e`<span class=${s + " pkt-tag--gray"}>${this.tagText}</span>` : n}
|
|
41
|
-
${this.optionalTag ? e`<span class=${s + " pkt-tag--blue-light"}
|
|
42
|
-
|
|
43
|
-
|
|
41
|
+
${this.optionalTag ? e`<span class=${s + " pkt-tag--blue-light"}
|
|
42
|
+
>${this.optionalText ?? c.optional}</span
|
|
43
|
+
>` : n}
|
|
44
|
+
${this.requiredTag ? e`<span class=${s + " pkt-tag--beige"}
|
|
45
|
+
>${this.requiredText ?? c.required}</span
|
|
46
|
+
>` : n}
|
|
47
|
+
`, u = this.id + "-check-label", d = this.id + "-check-helptext", f = () => e`
|
|
44
48
|
<label class=${i} for=${this.id + "-internal"}>
|
|
45
|
-
|
|
46
|
-
${this.checkHelptext ? e`<div class="pkt-input-check__input-helptext"
|
|
49
|
+
<span id=${u}>${this.label} ${l()}</span>
|
|
50
|
+
${this.checkHelptext ? e`<div id=${d} class="pkt-input-check__input-helptext">
|
|
51
|
+
${this.checkHelptext}
|
|
52
|
+
</div>` : n}
|
|
47
53
|
</label>
|
|
48
54
|
`;
|
|
49
55
|
return e`
|
|
50
56
|
<div class="pkt-input-check">
|
|
51
57
|
<div class=${t}>
|
|
52
|
-
${this.labelPosition === "left" ?
|
|
58
|
+
${this.labelPosition === "left" ? f() : n}
|
|
53
59
|
<input
|
|
54
60
|
id=${this.id + "-internal"}
|
|
55
61
|
class=${r}
|
|
@@ -64,8 +70,10 @@ var l = class extends c {
|
|
|
64
70
|
@focus=${this.onFocus}
|
|
65
71
|
?checked=${this.checked}
|
|
66
72
|
role=${this.isSwitch ? "switch" : "checkbox"}
|
|
73
|
+
aria-labelledby=${this.label ? u : n}
|
|
74
|
+
aria-describedby=${this.checkHelptext ? d : n}
|
|
67
75
|
/>
|
|
68
|
-
${this.labelPosition === "right" ?
|
|
76
|
+
${this.labelPosition === "right" ? f() : n}
|
|
69
77
|
</div>
|
|
70
78
|
</div>
|
|
71
79
|
`;
|
package/dist/pkt-checkbox.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./checkbox-
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./checkbox-CBZEGmqa.cjs");exports.PktCheckbox=e.n,exports.default=e.t;
|
package/dist/pkt-checkbox.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as e, t } from "./checkbox-
|
|
1
|
+
import { n as e, t } from "./checkbox-COw1Uwnm.js";
|
|
2
2
|
export { e as PktCheckbox, t as default };
|
package/dist/pkt-index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./element-D_mCyFeX.cjs"),t=require("./consent-DnE6IPEj.cjs"),n=require("./alert-DH3VqNqh.cjs"),r=require("./icon-BzxBkRyE.cjs"),i=require("./button-Cx6Xdp6t.cjs"),a=require("./accordion-CsrLQXEA.cjs"),o=require("./backlink-CDH824db.cjs"),s=require("./breadcrumbs-B37tsIoh.cjs"),c=require("./calendar-CAwIY7x_.cjs"),l=require("./tag-CGlxtBOH.cjs"),u=require("./header-D2SD2JLt.cjs"),d=require("./card-CB72gwBC.cjs"),f=require("./combobox-N3NP77le.cjs"),p=require("./input-wrapper-D64Qn-QH.cjs"),m=require("./helptext-6HsH-I6a.cjs"),h=require("./checkbox-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./element-D_mCyFeX.cjs"),t=require("./consent-DnE6IPEj.cjs"),n=require("./alert-DH3VqNqh.cjs"),r=require("./icon-BzxBkRyE.cjs"),i=require("./button-Cx6Xdp6t.cjs"),a=require("./accordion-CsrLQXEA.cjs"),o=require("./backlink-CDH824db.cjs"),s=require("./breadcrumbs-B37tsIoh.cjs"),c=require("./calendar-CAwIY7x_.cjs"),l=require("./tag-CGlxtBOH.cjs"),u=require("./header-D2SD2JLt.cjs"),d=require("./card-CB72gwBC.cjs"),f=require("./combobox-N3NP77le.cjs"),p=require("./input-wrapper-D64Qn-QH.cjs"),m=require("./helptext-6HsH-I6a.cjs"),h=require("./checkbox-CBZEGmqa.cjs"),g=require("./fileupload-3OtW4Xlo.cjs"),_=require("./modal-DZm_fn3K.cjs"),v=require("./progressbar-DsE4-qaW.cjs"),y=require("./datepicker-BzRhOIkG.cjs"),b=require("./footer-Ca3DM544.cjs"),x=require("./link-Bk7aDZCC.cjs"),S=require("./textinput-Cv4tal5W.cjs"),C=require("./searchinput-vi7twt5b.cjs"),w=require("./header-menu-B9ABa0WW.cjs"),T=require("./heading-4ZHACOeL.cjs"),E=require("./linkcard-rZpQuO1Z.cjs"),D=require("./loader-BAn68gBb.cjs"),O=require("./messagebox-WH2HjT5I.cjs"),k=require("./radiobutton-BEzjKx1J.cjs"),A=require("./tabs-hiTrWsXq.cjs"),j=require("./textarea-BHGZhMN4.cjs"),M=require("./select-TAwBNhhf.cjs"),N=require("./timepicker-BBUYnYzM.cjs");exports.PktAccordion=a.r,exports.PktAccordionItem=a.n,exports.PktAlert=n.n,exports.PktBackLink=o.n,exports.PktBreadcrumbs=s.t,exports.PktButton=i.n,exports.PktCalendar=c.n,exports.PktCard=d.n,exports.PktCheckbox=h.n,exports.PktCombobox=f.n,exports.PktConsent=t.n,exports.PktDateTags=y.a,exports.PktDatepicker=y.t,Object.defineProperty(exports,"PktFileUpload",{enumerable:!0,get:function(){return g.n}}),exports.PktFooter=b.n,exports.PktFooterSimple=b.t,exports.PktHeader=u.t,exports.PktHeaderGlobal=u.n,exports.PktHeaderMenu=w.n,exports.PktHeaderService=u.r,exports.PktHeaderUserMenu=u.i,exports.PktHeading=T.n,exports.PktHelptext=m.n,exports.PktIcon=r.n,exports.PktInputWrapper=p.n,exports.PktLink=x.n,exports.PktLinkCard=E.n,exports.PktLoader=D.n,exports.PktMessagebox=O.n,exports.PktModal=_.n,exports.PktProgressbar=v.n,exports.PktRadioButton=k.n,exports.PktRadiobutton=k.n,exports.PktSearchInput=C.n,exports.PktSelect=M.n,exports.PktTabItem=A.n,exports.PktTabs=A.r,exports.PktTag=l.n,exports.PktTextarea=j.n,exports.PktTextinput=S.n,exports.PktTimepicker=N.t,exports.getPktStrings=e.r,exports.pktStringsNb=e.s,exports.resetPktStrings=e.i,exports.setPktStrings=e.a,exports.subscribePktStrings=e.o;
|
package/dist/pkt-index.js
CHANGED
|
@@ -13,7 +13,7 @@ import { n as y } from "./card-cyZE94EO.js";
|
|
|
13
13
|
import { n as b } from "./combobox-Cqqokx73.js";
|
|
14
14
|
import { n as x } from "./input-wrapper-Bg06k-cj.js";
|
|
15
15
|
import { n as S } from "./helptext-BESB9Vlq.js";
|
|
16
|
-
import { n as C } from "./checkbox-
|
|
16
|
+
import { n as C } from "./checkbox-COw1Uwnm.js";
|
|
17
17
|
import { n as w } from "./fileupload-PJWEBD88.js";
|
|
18
18
|
import { n as T } from "./modal-DdC1_qT3.js";
|
|
19
19
|
import { n as E } from "./progressbar-D1x6MwdY.js";
|
|
@@ -27,7 +27,7 @@ import { n as F } from "./heading-BHWdVbvN.js";
|
|
|
27
27
|
import { n as I } from "./linkcard-Bguo9oCv.js";
|
|
28
28
|
import { n as L } from "./loader-C3gwO0i3.js";
|
|
29
29
|
import { n as R } from "./messagebox-DAE59dMX.js";
|
|
30
|
-
import { n as z } from "./radiobutton-
|
|
30
|
+
import { n as z } from "./radiobutton-Cpwa5ezn.js";
|
|
31
31
|
import { n as B, r as V } from "./tabs-kxsX1ZEf.js";
|
|
32
32
|
import { n as H } from "./textarea-BPQVrOp9.js";
|
|
33
33
|
import { n as U } from "./select-c15YAQbr.js";
|
package/dist/pkt-radiobutton.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./radiobutton-
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./radiobutton-BEzjKx1J.cjs");exports.PktRadioButton=e.n,exports.default=e.t;
|
package/dist/pkt-radiobutton.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as e, t } from "./radiobutton-
|
|
1
|
+
import { n as e, t } from "./radiobutton-Cpwa5ezn.js";
|
|
2
2
|
export { e as PktRadioButton, t as default };
|
|
@@ -1,4 +1,12 @@
|
|
|
1
|
-
const e=require("./element-D_mCyFeX.cjs"),t=require("./class-map-DupQbnhE.cjs"),n=require("./ref-AuNEkS5a.cjs"),r=require("./input-element-DhIEFeuP.cjs");var i=class extends r.t{constructor(...e){super(...e),this.inputRef=n.t(),this.value=``,this.checkHelptext=null,this.defaultChecked=!1,this.hasTile=!1,this.checked=null,this.type=`radio`,this.tagText=null,this.optionalTag=!1,this.requiredTag=!1,this._checked=!1}connectedCallback(){super.connectedCallback()}attributeChangedCallback(e,t,n){e===`defaultChecked`&&(this._checked=this.defaultChecked),e===`checked`&&(this._checked=this.checked===``||this.checked===`true`||this.checked===!0),super.attributeChangedCallback(e,t,n)}render(){let r=t.t({"pkt-input-check__input":!0,"pkt-input-check__input--tile":this.hasTile,"pkt-input-check__input--tile-disabled":this.disabled&&this.hasTile}),i=t.t({"pkt-input-check__input-checkbox":!0,"pkt-input-check__input-checkbox--error":this.hasError}),a=t.t({"pkt-input-check__input-label":!0,"pkt-input-check__input-label--disabled":this.disabled,"pkt-sr-only":this.hideLabel}),o=`pkt-tag pkt-tag--small pkt-tag--thin-text`,s=this.pktStrings.get(`forms`)
|
|
1
|
+
const e=require("./element-D_mCyFeX.cjs"),t=require("./class-map-DupQbnhE.cjs"),n=require("./ref-AuNEkS5a.cjs"),r=require("./input-element-DhIEFeuP.cjs");var i=class extends r.t{constructor(...e){super(...e),this.inputRef=n.t(),this.value=``,this.checkHelptext=null,this.defaultChecked=!1,this.hasTile=!1,this.checked=null,this.type=`radio`,this.tagText=null,this.optionalTag=!1,this.requiredTag=!1,this._checked=!1}connectedCallback(){super.connectedCallback()}attributeChangedCallback(e,t,n){e===`defaultChecked`&&(this._checked=this.defaultChecked),e===`checked`&&(this._checked=this.checked===``||this.checked===`true`||this.checked===!0),super.attributeChangedCallback(e,t,n)}render(){let r=t.t({"pkt-input-check__input":!0,"pkt-input-check__input--tile":this.hasTile,"pkt-input-check__input--tile-disabled":this.disabled&&this.hasTile}),i=t.t({"pkt-input-check__input-checkbox":!0,"pkt-input-check__input-checkbox--error":this.hasError}),a=t.t({"pkt-input-check__input-label":!0,"pkt-input-check__input-label--disabled":this.disabled,"pkt-sr-only":this.hideLabel}),o=`pkt-tag pkt-tag--small pkt-tag--thin-text`,s=this.pktStrings.get(`forms`),c=()=>e._`
|
|
2
|
+
${this.tagText?e._`<span class=${o+` pkt-tag--gray`}>${this.tagText}</span>`:e.h}
|
|
3
|
+
${this.optionalTag?e._`<span class=${o+` pkt-tag--blue-light`}
|
|
4
|
+
>${this.optionalText??s.optional}</span
|
|
5
|
+
>`:e.h}
|
|
6
|
+
${this.requiredTag?e._`<span class=${o+` pkt-tag--beige`}
|
|
7
|
+
>${this.requiredText??s.required}</span
|
|
8
|
+
>`:e.h}
|
|
9
|
+
`,l=this.id+`-check-label`,u=this.id+`-check-helptext`;return e._`
|
|
2
10
|
<div class="pkt-input-check">
|
|
3
11
|
<div class=${r}>
|
|
4
12
|
<input
|
|
@@ -14,15 +22,15 @@ const e=require("./element-D_mCyFeX.cjs"),t=require("./class-map-DupQbnhE.cjs"),
|
|
|
14
22
|
@blur=${this.onBlur}
|
|
15
23
|
@focus=${this.onFocus}
|
|
16
24
|
?checked=${this.checked}
|
|
25
|
+
aria-labelledby=${this.label?l:e.h}
|
|
26
|
+
aria-describedby=${this.checkHelptext?u:e.h}
|
|
17
27
|
/>
|
|
18
28
|
${e._`
|
|
19
29
|
<label class=${a} for=${this.id+`-internal`}>
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
`}
|
|
25
|
-
${this.checkHelptext?e._`<div class="pkt-input-check__input-helptext">${this.checkHelptext}</div>`:e.h}
|
|
30
|
+
<span id=${l}>${this.label} ${c()}</span>
|
|
31
|
+
${this.checkHelptext?e._`<div id=${u} class="pkt-input-check__input-helptext">
|
|
32
|
+
${this.checkHelptext}
|
|
33
|
+
</div>`:e.h}
|
|
26
34
|
</label>
|
|
27
35
|
`}
|
|
28
36
|
</div>
|
|
@@ -25,7 +25,15 @@ var u = class extends l {
|
|
|
25
25
|
"pkt-input-check__input-label": !0,
|
|
26
26
|
"pkt-input-check__input-label--disabled": this.disabled,
|
|
27
27
|
"pkt-sr-only": this.hideLabel
|
|
28
|
-
}), a = "pkt-tag pkt-tag--small pkt-tag--thin-text", c = this.pktStrings.get("forms")
|
|
28
|
+
}), a = "pkt-tag pkt-tag--small pkt-tag--thin-text", c = this.pktStrings.get("forms"), l = () => e`
|
|
29
|
+
${this.tagText ? e`<span class=${a + " pkt-tag--gray"}>${this.tagText}</span>` : n}
|
|
30
|
+
${this.optionalTag ? e`<span class=${a + " pkt-tag--blue-light"}
|
|
31
|
+
>${this.optionalText ?? c.optional}</span
|
|
32
|
+
>` : n}
|
|
33
|
+
${this.requiredTag ? e`<span class=${a + " pkt-tag--beige"}
|
|
34
|
+
>${this.requiredText ?? c.required}</span
|
|
35
|
+
>` : n}
|
|
36
|
+
`, u = this.id + "-check-label", d = this.id + "-check-helptext";
|
|
29
37
|
return e`
|
|
30
38
|
<div class="pkt-input-check">
|
|
31
39
|
<div class=${t}>
|
|
@@ -42,15 +50,15 @@ var u = class extends l {
|
|
|
42
50
|
@blur=${this.onBlur}
|
|
43
51
|
@focus=${this.onFocus}
|
|
44
52
|
?checked=${this.checked}
|
|
53
|
+
aria-labelledby=${this.label ? u : n}
|
|
54
|
+
aria-describedby=${this.checkHelptext ? d : n}
|
|
45
55
|
/>
|
|
46
56
|
${e`
|
|
47
57
|
<label class=${i} for=${this.id + "-internal"}>
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
`}
|
|
53
|
-
${this.checkHelptext ? e`<div class="pkt-input-check__input-helptext">${this.checkHelptext}</div>` : n}
|
|
58
|
+
<span id=${u}>${this.label} ${l()}</span>
|
|
59
|
+
${this.checkHelptext ? e`<div id=${d} class="pkt-input-check__input-helptext">
|
|
60
|
+
${this.checkHelptext}
|
|
61
|
+
</div>` : n}
|
|
54
62
|
</label>
|
|
55
63
|
`}
|
|
56
64
|
</div>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslokommune/punkt-elements",
|
|
3
|
-
"version": "18.
|
|
3
|
+
"version": "18.8.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",
|
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
"engines": {
|
|
84
84
|
"node": "^22.19.0 || ^24.0.0 || ^26.0.0"
|
|
85
85
|
},
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "30be2be7365f440b93da5bad8ca3e883255d647a"
|
|
87
87
|
}
|
|
@@ -363,7 +363,7 @@ describe('PktCheckbox', () => {
|
|
|
363
363
|
|
|
364
364
|
const helptext = checkbox.querySelector('.pkt-input-check__input-helptext')
|
|
365
365
|
expect(helptext).toBeInTheDocument()
|
|
366
|
-
expect(helptext?.textContent).toBe('This is help text')
|
|
366
|
+
expect(helptext?.textContent?.trim()).toBe('This is help text')
|
|
367
367
|
})
|
|
368
368
|
|
|
369
369
|
test('does not render helptext when not provided', async () => {
|
|
@@ -115,25 +115,42 @@ export class PktCheckbox extends PktInputElement<Props> {
|
|
|
115
115
|
|
|
116
116
|
const tags = () => {
|
|
117
117
|
return html`
|
|
118
|
-
${
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
118
|
+
${
|
|
119
|
+
this.tagText
|
|
120
|
+
? html`<span class=${tagClasses + ' pkt-tag--gray'}>${this.tagText}</span>`
|
|
121
|
+
: nothing
|
|
122
|
+
}
|
|
123
|
+
${
|
|
124
|
+
this.optionalTag
|
|
125
|
+
? html`<span class=${tagClasses + ' pkt-tag--blue-light'}
|
|
126
|
+
>${this.optionalText ?? formStrings.optional}</span
|
|
127
|
+
>`
|
|
128
|
+
: nothing
|
|
129
|
+
}
|
|
130
|
+
${
|
|
131
|
+
this.requiredTag
|
|
132
|
+
? html`<span class=${tagClasses + ' pkt-tag--beige'}
|
|
133
|
+
>${this.requiredText ?? formStrings.required}</span
|
|
134
|
+
>`
|
|
135
|
+
: nothing
|
|
136
|
+
}
|
|
127
137
|
`
|
|
128
138
|
}
|
|
129
139
|
|
|
140
|
+
const labelId = this.id + '-check-label'
|
|
141
|
+
const helptextId = this.id + '-check-helptext'
|
|
142
|
+
|
|
130
143
|
const labelAndHelptext = () => {
|
|
131
144
|
return html`
|
|
132
145
|
<label class=${labelClasses} for=${this.id + '-internal'}>
|
|
133
|
-
|
|
134
|
-
${
|
|
135
|
-
|
|
136
|
-
|
|
146
|
+
<span id=${labelId}>${this.label} ${tags()}</span>
|
|
147
|
+
${
|
|
148
|
+
this.checkHelptext
|
|
149
|
+
? html`<div id=${helptextId} class="pkt-input-check__input-helptext">
|
|
150
|
+
${this.checkHelptext}
|
|
151
|
+
</div>`
|
|
152
|
+
: nothing
|
|
153
|
+
}
|
|
137
154
|
</label>
|
|
138
155
|
`
|
|
139
156
|
}
|
|
@@ -156,6 +173,8 @@ export class PktCheckbox extends PktInputElement<Props> {
|
|
|
156
173
|
@focus=${this.onFocus}
|
|
157
174
|
?checked=${this.checked}
|
|
158
175
|
role=${this.isSwitch ? 'switch' : 'checkbox'}
|
|
176
|
+
aria-labelledby=${this.label ? labelId : nothing}
|
|
177
|
+
aria-describedby=${this.checkHelptext ? helptextId : nothing}
|
|
159
178
|
/>
|
|
160
179
|
${this.labelPosition === 'right' ? labelAndHelptext() : nothing}
|
|
161
180
|
</div>
|
|
@@ -159,7 +159,7 @@ describe('pkt-radiobutton', () => {
|
|
|
159
159
|
|
|
160
160
|
const helptext = radiobutton.querySelector('.pkt-input-check__input-helptext')
|
|
161
161
|
expect(helptext).toBeInTheDocument()
|
|
162
|
-
expect(helptext?.textContent).toBe('This is helpful information')
|
|
162
|
+
expect(helptext?.textContent?.trim()).toBe('This is helpful information')
|
|
163
163
|
})
|
|
164
164
|
|
|
165
165
|
test('handles error state correctly', async () => {
|
|
@@ -75,25 +75,42 @@ export class PktRadioButton extends PktInputElement<Props> {
|
|
|
75
75
|
|
|
76
76
|
const tags = () => {
|
|
77
77
|
return html`
|
|
78
|
-
${
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
78
|
+
${
|
|
79
|
+
this.tagText
|
|
80
|
+
? html`<span class=${tagClasses + ' pkt-tag--gray'}>${this.tagText}</span>`
|
|
81
|
+
: nothing
|
|
82
|
+
}
|
|
83
|
+
${
|
|
84
|
+
this.optionalTag
|
|
85
|
+
? html`<span class=${tagClasses + ' pkt-tag--blue-light'}
|
|
86
|
+
>${this.optionalText ?? formStrings.optional}</span
|
|
87
|
+
>`
|
|
88
|
+
: nothing
|
|
89
|
+
}
|
|
90
|
+
${
|
|
91
|
+
this.requiredTag
|
|
92
|
+
? html`<span class=${tagClasses + ' pkt-tag--beige'}
|
|
93
|
+
>${this.requiredText ?? formStrings.required}</span
|
|
94
|
+
>`
|
|
95
|
+
: nothing
|
|
96
|
+
}
|
|
87
97
|
`
|
|
88
98
|
}
|
|
89
99
|
|
|
100
|
+
const labelId = this.id + '-check-label'
|
|
101
|
+
const helptextId = this.id + '-check-helptext'
|
|
102
|
+
|
|
90
103
|
const labelAndHelptext = () => {
|
|
91
104
|
return html`
|
|
92
105
|
<label class=${labelClasses} for=${this.id + '-internal'}>
|
|
93
|
-
|
|
94
|
-
${
|
|
95
|
-
|
|
96
|
-
|
|
106
|
+
<span id=${labelId}>${this.label} ${tags()}</span>
|
|
107
|
+
${
|
|
108
|
+
this.checkHelptext
|
|
109
|
+
? html`<div id=${helptextId} class="pkt-input-check__input-helptext">
|
|
110
|
+
${this.checkHelptext}
|
|
111
|
+
</div>`
|
|
112
|
+
: nothing
|
|
113
|
+
}
|
|
97
114
|
</label>
|
|
98
115
|
`
|
|
99
116
|
}
|
|
@@ -114,6 +131,8 @@ export class PktRadioButton extends PktInputElement<Props> {
|
|
|
114
131
|
@blur=${this.onBlur}
|
|
115
132
|
@focus=${this.onFocus}
|
|
116
133
|
?checked=${this.checked}
|
|
134
|
+
aria-labelledby=${this.label ? labelId : nothing}
|
|
135
|
+
aria-describedby=${this.checkHelptext ? helptextId : nothing}
|
|
117
136
|
/>
|
|
118
137
|
${labelAndHelptext()}
|
|
119
138
|
</div>
|