@oslokommune/punkt-elements 19.2.0 → 19.3.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 CHANGED
@@ -5,6 +5,11 @@ og skriver commits ca etter [Conventional Commits](https://conventionalcommits.o
5
5
 
6
6
  ---
7
7
 
8
+ ## [19.3.0](https://github.com/oslokommune/punkt/compare/19.2.0...19.3.0) (2026-09-29)
9
+
10
+ ---
11
+
12
+
8
13
  ## [19.2.0](https://github.com/oslokommune/punkt/compare/19.1.0...19.2.0) (2026-09-28)
9
14
 
10
15
  ---
@@ -2,10 +2,21 @@ import { _ as e, d as t, h as n, n as r, u as i } from "./element-CqC-sGuC.js";
2
2
  import { t as a } from "./class-map-D5GHsely.js";
3
3
  import { n as o, t as s } from "./ref-37-yxmc4.js";
4
4
  import { t as c } from "./input-element-BTzuDh4h.js";
5
- //#region src/components/checkbox/checkbox.ts
6
- var l = class extends c {
5
+ //#region ../../shared-types/checkbox.ts
6
+ var l = {
7
+ defaultChecked: !1,
8
+ indeterminate: !1,
9
+ hasTile: !1,
10
+ disabled: !1,
11
+ hasError: !1,
12
+ isSwitch: !1,
13
+ hideLabel: !1,
14
+ labelPosition: "right",
15
+ requiredTag: !1,
16
+ optionalTag: !1
17
+ }, u = class extends c {
7
18
  constructor(...e) {
8
- super(...e), this.inputRef = s(), 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;
19
+ super(...e), this.inputRef = s(), this.value = "", this.checkHelptext = null, this.defaultChecked = l.defaultChecked, this.hasTile = l.hasTile, this.isSwitch = l.isSwitch, this.labelPosition = l.labelPosition, this.hideLabel = l.hideLabel, this.checked = null, this.indeterminate = l.indeterminate, this.type = "checkbox", this.tagText = null, this.optionalTag = l.optionalTag, this.requiredTag = l.requiredTag;
9
20
  }
10
21
  connectedCallback() {
11
22
  super.connectedCallback();
@@ -104,23 +115,23 @@ var l = class extends c {
104
115
  r([i({
105
116
  type: String,
106
117
  reflect: !0
107
- })], l.prototype, "value", void 0), r([i({ type: String })], l.prototype, "checkHelptext", void 0), r([i({ type: Boolean })], l.prototype, "defaultChecked", void 0), r([i({ type: Boolean })], l.prototype, "hasTile", void 0), r([i({ type: Boolean })], l.prototype, "isSwitch", void 0), r([i({ type: String })], l.prototype, "labelPosition", void 0), r([i({ type: Boolean })], l.prototype, "hideLabel", void 0), r([i({
118
+ })], u.prototype, "value", void 0), r([i({ type: String })], u.prototype, "checkHelptext", void 0), r([i({ type: Boolean })], u.prototype, "defaultChecked", void 0), r([i({ type: Boolean })], u.prototype, "hasTile", void 0), r([i({ type: Boolean })], u.prototype, "isSwitch", void 0), r([i({ type: String })], u.prototype, "labelPosition", void 0), r([i({ type: Boolean })], u.prototype, "hideLabel", void 0), r([i({
108
119
  type: Boolean,
109
120
  reflect: !0
110
- })], l.prototype, "checked", void 0), r([i({
121
+ })], u.prototype, "checked", void 0), r([i({
111
122
  type: Boolean,
112
123
  reflect: !0
113
- })], l.prototype, "indeterminate", void 0), r([i({
124
+ })], u.prototype, "indeterminate", void 0), r([i({
114
125
  type: String,
115
126
  reflect: !0
116
- })], l.prototype, "type", void 0), r([i({ type: String })], l.prototype, "tagText", void 0), r([i({ type: Boolean })], l.prototype, "optionalTag", void 0), r([i({ type: String })], l.prototype, "optionalText", void 0), r([i({ type: Boolean })], l.prototype, "requiredTag", void 0), r([i({ type: String })], l.prototype, "requiredText", void 0);
127
+ })], u.prototype, "type", void 0), r([i({ type: String })], u.prototype, "tagText", void 0), r([i({ type: Boolean })], u.prototype, "optionalTag", void 0), r([i({ type: String })], u.prototype, "optionalText", void 0), r([i({ type: Boolean })], u.prototype, "requiredTag", void 0), r([i({ type: String })], u.prototype, "requiredText", void 0);
117
128
  try {
118
- t("pkt-checkbox")(l);
129
+ t("pkt-checkbox")(u);
119
130
  } catch {
120
131
  console.warn("Forsøker å definere <pkt-checkbox>, men den er allerede definert");
121
132
  }
122
133
  //#endregion
123
134
  //#region src/components/checkbox/index.ts
124
- var u = l;
135
+ var d = u;
125
136
  //#endregion
126
- export { l as n, u as t };
137
+ export { u as n, d as t };
@@ -0,0 +1,40 @@
1
+ const e=require("./element-CewjrA4g.cjs"),t=require("./class-map-B0FX3YsK.cjs"),n=require("./ref-HT6KRjxp.cjs"),r=require("./input-element-BdIWsDl-.cjs");var i={defaultChecked:!1,indeterminate:!1,hasTile:!1,disabled:!1,hasError:!1,isSwitch:!1,hideLabel:!1,labelPosition:`right`,requiredTag:!1,optionalTag:!1},a=class extends r.t{constructor(...e){super(...e),this.inputRef=n.t(),this.value=``,this.checkHelptext=null,this.defaultChecked=i.defaultChecked,this.hasTile=i.hasTile,this.isSwitch=i.isSwitch,this.labelPosition=i.labelPosition,this.hideLabel=i.hideLabel,this.checked=null,this.indeterminate=i.indeterminate,this.type=`checkbox`,this.tagText=null,this.optionalTag=i.optionalTag,this.requiredTag=i.requiredTag}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
+ ${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`,d=()=>e._`
10
+ <label class=${a} for=${this.id+`-internal`}>
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}
15
+ </label>
16
+ `;return e._`
17
+ <div class="pkt-input-check">
18
+ <div class=${r}>
19
+ ${this.labelPosition===`left`?d():e.h}
20
+ <input
21
+ id=${this.id+`-internal`}
22
+ class=${i}
23
+ type="checkbox"
24
+ ?disabled=${this.disabled}
25
+ name=${this.name+`-internal`}
26
+ ${n.n(this.inputRef)}
27
+ @change=${this.handleChange}
28
+ @input=${this.handleInput}
29
+ @click=${this.handleClick}
30
+ @blur=${this.onBlur}
31
+ @focus=${this.onFocus}
32
+ ?checked=${this.checked}
33
+ role=${this.isSwitch?`switch`:`checkbox`}
34
+ aria-labelledby=${this.label?l:e.h}
35
+ aria-describedby=${this.checkHelptext?u:e.h}
36
+ />
37
+ ${this.labelPosition===`right`?d():e.h}
38
+ </div>
39
+ </div>
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})],a.prototype,`value`,void 0),e.n([e.u({type:String})],a.prototype,`checkHelptext`,void 0),e.n([e.u({type:Boolean})],a.prototype,`defaultChecked`,void 0),e.n([e.u({type:Boolean})],a.prototype,`hasTile`,void 0),e.n([e.u({type:Boolean})],a.prototype,`isSwitch`,void 0),e.n([e.u({type:String})],a.prototype,`labelPosition`,void 0),e.n([e.u({type:Boolean})],a.prototype,`hideLabel`,void 0),e.n([e.u({type:Boolean,reflect:!0})],a.prototype,`checked`,void 0),e.n([e.u({type:Boolean,reflect:!0})],a.prototype,`indeterminate`,void 0),e.n([e.u({type:String,reflect:!0})],a.prototype,`type`,void 0),e.n([e.u({type:String})],a.prototype,`tagText`,void 0),e.n([e.u({type:Boolean})],a.prototype,`optionalTag`,void 0),e.n([e.u({type:String})],a.prototype,`optionalText`,void 0),e.n([e.u({type:Boolean})],a.prototype,`requiredTag`,void 0),e.n([e.u({type:String})],a.prototype,`requiredText`,void 0);try{e.d(`pkt-checkbox`)(a)}catch{console.warn(`Forsøker å definere <pkt-checkbox>, men den er allerede definert`)}var o=a;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return o}});
@@ -2,6 +2,8 @@ import { PktInputElement } from '../../base-elements/input-element';
2
2
  import { Ref } from 'lit/directives/ref.js';
3
3
  import { PropertyValues } from 'lit';
4
4
  import { ElementProps } from '../../types/typeUtils';
5
+ import { TCheckboxLabelPosition } from '../../shared-types';
6
+ export type { TCheckboxLabelPosition };
5
7
  type Props = ElementProps<PktCheckbox, 'checkHelptext' | 'defaultChecked' | 'hasTile' | 'isSwitch' | 'labelPosition' | 'hideLabel' | 'tagText' | 'optionalTag' | 'optionalText' | 'requiredTag' | 'requiredText'>;
6
8
  export declare class PktCheckbox extends PktInputElement<Props> {
7
9
  inputRef: Ref<HTMLInputElement>;
@@ -10,7 +12,7 @@ export declare class PktCheckbox extends PktInputElement<Props> {
10
12
  defaultChecked: boolean;
11
13
  hasTile: boolean;
12
14
  isSwitch: boolean;
13
- labelPosition: 'right' | 'left';
15
+ labelPosition: TCheckboxLabelPosition;
14
16
  hideLabel: boolean;
15
17
  checked: boolean | string | null;
16
18
  indeterminate: boolean | 'true' | 'false' | '';
@@ -33,4 +35,3 @@ export declare class PktCheckbox extends PktInputElement<Props> {
33
35
  private handleChange;
34
36
  private toggleChecked;
35
37
  }
36
- export {};
@@ -1 +1 @@
1
- Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./checkbox-DlzVGBum.cjs");exports.PktCheckbox=e.n,exports.default=e.t;
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./checkbox-B2G_B_bg.cjs");exports.PktCheckbox=e.n,exports.default=e.t;
@@ -1,2 +1,2 @@
1
- import { n as e, t } from "./checkbox-CTf4GatI.js";
1
+ import { n as e, t } from "./checkbox-B-ejHbFP.js";
2
2
  export { e as PktCheckbox, t as default };
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./element-CewjrA4g.cjs"),t=require("./consent-Cle1hkPg.cjs"),n=require("./alert-DsGNGcgd.cjs"),r=require("./header-wdEiBTI9.cjs"),i=require("./card-B-RKnu_C.cjs"),a=require("./calendar-CtfdBqJN.cjs"),o=require("./icon-Clz68-Kz.cjs"),s=require("./button-CCR4eyt_.cjs"),c=require("./accordion-BLMbI8SQ.cjs"),l=require("./backlink-DM220m4q.cjs"),u=require("./breadcrumbs-BUmbj-hP.cjs"),d=require("./tag-CQEyjF32.cjs"),f=require("./combobox-nqNZDvBR.cjs"),p=require("./input-wrapper-BmPdpY4N.cjs"),m=require("./helptext-DQe6GO75.cjs"),h=require("./checkbox-DlzVGBum.cjs"),g=require("./fileupload-DDLvQaSS.cjs"),_=require("./modal-i3Qxv38H.cjs"),v=require("./progressbar-CJFGbev-.cjs"),y=require("./datepicker-DvO3w0eM.cjs"),b=require("./footer-CupUAe8d.cjs"),x=require("./link-1JEWpEDG.cjs"),S=require("./textinput-CSrBua2N.cjs"),C=require("./searchinput-D1cJ73Ki.cjs"),w=require("./header-menu-DGywRJCx.cjs"),T=require("./heading-BDdX4JiM.cjs"),E=require("./linkcard-DXOkeQUy.cjs"),D=require("./loader-BA__N62k.cjs"),O=require("./messagebox-D2xvSYWI.cjs"),k=require("./radiobutton-BQRtv7PK.cjs"),A=require("./tabs-95BpwB6j.cjs"),j=require("./textarea-BLVuKEng.cjs"),M=require("./select-CDoA2rpC.cjs"),N=require("./timepicker-Iq1-vWRn.cjs");exports.PktAccordion=c.r,exports.PktAccordionItem=c.n,exports.PktAlert=n.n,exports.PktBackLink=l.n,exports.PktBreadcrumbs=u.t,exports.PktButton=s.n,exports.PktCalendar=a.n,exports.PktCard=i.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=r.t,exports.PktHeaderGlobal=r.n,exports.PktHeaderMenu=w.n,exports.PktHeaderService=r.r,exports.PktHeaderUserMenu=r.i,exports.PktHeading=T.n,exports.PktHelptext=m.n,exports.PktIcon=o.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=d.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;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./element-CewjrA4g.cjs"),t=require("./consent-Cle1hkPg.cjs"),n=require("./alert-DsGNGcgd.cjs"),r=require("./header-wdEiBTI9.cjs"),i=require("./card-B-RKnu_C.cjs"),a=require("./checkbox-B2G_B_bg.cjs"),o=require("./calendar-CtfdBqJN.cjs"),s=require("./icon-Clz68-Kz.cjs"),c=require("./button-CCR4eyt_.cjs"),l=require("./accordion-BLMbI8SQ.cjs"),u=require("./backlink-DM220m4q.cjs"),d=require("./breadcrumbs-BUmbj-hP.cjs"),f=require("./tag-CQEyjF32.cjs"),p=require("./combobox-nqNZDvBR.cjs"),m=require("./input-wrapper-BmPdpY4N.cjs"),h=require("./helptext-DQe6GO75.cjs"),g=require("./fileupload-DDLvQaSS.cjs"),_=require("./modal-i3Qxv38H.cjs"),v=require("./progressbar-CJFGbev-.cjs"),y=require("./datepicker-DvO3w0eM.cjs"),b=require("./footer-CupUAe8d.cjs"),x=require("./link-1JEWpEDG.cjs"),S=require("./textinput-CSrBua2N.cjs"),C=require("./searchinput-D1cJ73Ki.cjs"),w=require("./header-menu-DGywRJCx.cjs"),T=require("./heading-BDdX4JiM.cjs"),E=require("./linkcard-DXOkeQUy.cjs"),D=require("./loader-BA__N62k.cjs"),O=require("./messagebox-D2xvSYWI.cjs"),k=require("./radiobutton-BQRtv7PK.cjs"),A=require("./tabs-95BpwB6j.cjs"),j=require("./textarea-BLVuKEng.cjs"),M=require("./select-CDoA2rpC.cjs"),N=require("./timepicker-Iq1-vWRn.cjs");exports.PktAccordion=l.r,exports.PktAccordionItem=l.n,exports.PktAlert=n.n,exports.PktBackLink=u.n,exports.PktBreadcrumbs=d.t,exports.PktButton=c.n,exports.PktCalendar=o.n,exports.PktCard=i.n,exports.PktCheckbox=a.n,exports.PktCombobox=p.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=r.t,exports.PktHeaderGlobal=r.n,exports.PktHeaderMenu=w.n,exports.PktHeaderService=r.r,exports.PktHeaderUserMenu=r.i,exports.PktHeading=T.n,exports.PktHelptext=h.n,exports.PktIcon=s.n,exports.PktInputWrapper=m.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=f.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
@@ -3,17 +3,17 @@ import { n as a } from "./consent-BeoP4rOa.js";
3
3
  import { n as o } from "./alert-vIaasUjb.js";
4
4
  import { i as s, n as c, r as l, t as u } from "./header-BxgtAiNM.js";
5
5
  import { n as d } from "./card-27RxxKxW.js";
6
- import { n as f } from "./calendar-DWSW_GeN.js";
7
- import { n as p } from "./icon-B2v30QUk.js";
8
- import { n as m } from "./button-BUl8uWWh.js";
9
- import { n as h, r as g } from "./accordion-Bwka5Mxo.js";
10
- import { n as _ } from "./backlink-BjJwDjuP.js";
11
- import { t as v } from "./breadcrumbs-B1pDtQy8.js";
12
- import { n as y } from "./tag-DoUC99hn.js";
13
- import { n as b } from "./combobox-DHL_CGYv.js";
14
- import { n as x } from "./input-wrapper-B5GdwzAM.js";
15
- import { n as S } from "./helptext-BQkrYsoV.js";
16
- import { n as C } from "./checkbox-CTf4GatI.js";
6
+ import { n as f } from "./checkbox-B-ejHbFP.js";
7
+ import { n as p } from "./calendar-DWSW_GeN.js";
8
+ import { n as m } from "./icon-B2v30QUk.js";
9
+ import { n as h } from "./button-BUl8uWWh.js";
10
+ import { n as g, r as _ } from "./accordion-Bwka5Mxo.js";
11
+ import { n as v } from "./backlink-BjJwDjuP.js";
12
+ import { t as y } from "./breadcrumbs-B1pDtQy8.js";
13
+ import { n as b } from "./tag-DoUC99hn.js";
14
+ import { n as x } from "./combobox-DHL_CGYv.js";
15
+ import { n as S } from "./input-wrapper-B5GdwzAM.js";
16
+ import { n as C } from "./helptext-BQkrYsoV.js";
17
17
  import { n as w } from "./fileupload-DbtTD1aU.js";
18
18
  import { n as T } from "./modal-D5tGq-nN.js";
19
19
  import { n as E } from "./progressbar-4WyR4T72.js";
@@ -32,4 +32,4 @@ import { n as B, r as V } from "./tabs-DexV26qJ.js";
32
32
  import { n as H } from "./textarea-sulH-Yk7.js";
33
33
  import { n as U } from "./select-BhK8veJn.js";
34
34
  import { t as W } from "./timepicker-BaDGjuOR.js";
35
- export { g as PktAccordion, h as PktAccordionItem, o as PktAlert, _ as PktBackLink, v as PktBreadcrumbs, m as PktButton, f as PktCalendar, d as PktCard, C as PktCheckbox, b as PktCombobox, a as PktConsent, D as PktDateTags, O as PktDatepicker, w as PktFileUpload, k as PktFooter, A as PktFooterSimple, u as PktHeader, c as PktHeaderGlobal, P as PktHeaderMenu, l as PktHeaderService, s as PktHeaderUserMenu, F as PktHeading, S as PktHelptext, p as PktIcon, x as PktInputWrapper, j as PktLink, I as PktLinkCard, L as PktLoader, R as PktMessagebox, T as PktModal, E as PktProgressbar, z as PktRadioButton, z as PktRadiobutton, N as PktSearchInput, U as PktSelect, B as PktTabItem, V as PktTabs, y as PktTag, H as PktTextarea, M as PktTextinput, W as PktTimepicker, r as getPktStrings, i as pktStringsNb, t as resetPktStrings, e as setPktStrings, n as subscribePktStrings };
35
+ export { _ as PktAccordion, g as PktAccordionItem, o as PktAlert, v as PktBackLink, y as PktBreadcrumbs, h as PktButton, p as PktCalendar, d as PktCard, f as PktCheckbox, x as PktCombobox, a as PktConsent, D as PktDateTags, O as PktDatepicker, w as PktFileUpload, k as PktFooter, A as PktFooterSimple, u as PktHeader, c as PktHeaderGlobal, P as PktHeaderMenu, l as PktHeaderService, s as PktHeaderUserMenu, F as PktHeading, C as PktHelptext, m as PktIcon, S as PktInputWrapper, j as PktLink, I as PktLinkCard, L as PktLoader, R as PktMessagebox, T as PktModal, E as PktProgressbar, z as PktRadioButton, z as PktRadiobutton, N as PktSearchInput, U as PktSelect, B as PktTabItem, V as PktTabs, b as PktTag, H as PktTextarea, M as PktTextinput, W as PktTimepicker, r as getPktStrings, i as pktStringsNb, t as resetPktStrings, e as setPktStrings, n as subscribePktStrings };
@@ -0,0 +1,52 @@
1
+ /**
2
+ * checkbox.ts
3
+ *
4
+ * Type definitions for pkt-checkbox.
5
+ * Used by React, Elements, and typed component specs.
6
+ */
7
+ import type { IPktStringsProps } from '../shared-strings';
8
+ import type { IFormFieldErrorProps, IFormFieldLabelProps, ITagOptionalRequiredProps } from './form-field';
9
+ /** Checkbox label placement — shared runtime source for types, specs, and Preview. */
10
+ export declare const CHECKBOX_LABEL_POSITIONS: readonly ['right', 'left'];
11
+ export type TCheckboxLabelPosition = (typeof CHECKBOX_LABEL_POSITIONS)[number];
12
+ /**
13
+ * Checkbox props shared by React and Elements.
14
+ *
15
+ * @remarks React requires `id` and widens `checkHelptext` to `ReactNode`.
16
+ * Elements accepts booleanish strings for `checked`/`indeterminate`.
17
+ */
18
+ export interface IPktCheckboxBase extends IFormFieldLabelProps, Pick<IFormFieldErrorProps, 'disabled' | 'hasError'>, ITagOptionalRequiredProps, IPktStringsProps<'forms'> {
19
+ id?: string;
20
+ name?: string;
21
+ form?: string;
22
+ value?: string;
23
+ checkHelptext?: string;
24
+ defaultChecked?: boolean;
25
+ checked?: boolean;
26
+ indeterminate?: boolean;
27
+ hasTile?: boolean;
28
+ isSwitch?: boolean;
29
+ hideLabel?: boolean;
30
+ labelPosition?: TCheckboxLabelPosition;
31
+ }
32
+ /**
33
+ * Documented Checkbox props (subset of `IPktCheckboxBase`).
34
+ * Used for typed component specs in documentation.
35
+ */
36
+ export type ICheckboxSpecProps = Pick<IPktCheckboxBase, 'label' | 'checkHelptext' | 'name' | 'form' | 'value' | 'id' | 'defaultChecked' | 'checked' | 'indeterminate' | 'hasTile' | 'disabled' | 'hasError' | 'isSwitch' | 'labelPosition' | 'hideLabel' | 'requiredTag' | 'requiredText' | 'optionalTag' | 'optionalText' | 'tagText'>;
37
+ /**
38
+ * Default values for pkt-checkbox. Single source of truth for both frameworks.
39
+ * `checked` is intentionally absent — React must keep it `undefined` to stay uncontrolled.
40
+ */
41
+ export declare const CHECKBOX_DEFAULTS: {
42
+ readonly defaultChecked: false;
43
+ readonly indeterminate: false;
44
+ readonly hasTile: false;
45
+ readonly disabled: false;
46
+ readonly hasError: false;
47
+ readonly isSwitch: false;
48
+ readonly hideLabel: false;
49
+ readonly labelPosition: 'right';
50
+ readonly requiredTag: false;
51
+ readonly optionalTag: false;
52
+ };
@@ -11,6 +11,8 @@ export type { IPktFooterLink, IPktFooterColumn, IPktFooterSocialLink, IPktFooter
11
11
  export { DEFAULT_FOOTER_PERSONVERN_URL, DEFAULT_FOOTER_TILGJENGELIGHET_URL } from './footer';
12
12
  export { CARD_SKINS, CARD_PADDINGS, CARD_IMAGE_SHAPES, CARD_IMAGE_ASPECTS, CARD_TAG_POSITIONS, CARD_TAG_SKIN_OPTIONS, CARD_DEFAULTS } from './card';
13
13
  export type { TCardSkin, TCardPadding, TCardImageShape, TCardImageAspect, TCardTagPosition, ICardTag, ICardImage, IPktCardBase, ICardSpecProps, } from './card';
14
+ export { CHECKBOX_LABEL_POSITIONS, CHECKBOX_DEFAULTS } from './checkbox';
15
+ export type { TCheckboxLabelPosition, IPktCheckboxBase, ICheckboxSpecProps } from './checkbox';
14
16
  export { LAYOUT_DIRECTIONS } from './layout';
15
17
  export type { TLayout, TVerticalPosition, THorizontalPosition, TPosition, TPositionWithCenter, } from './layout';
16
18
  export type { THTMLButtonType, TSelectionMode } from './form';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oslokommune/punkt-elements",
3
- "version": "19.2.0",
3
+ "version": "19.3.0",
4
4
  "description": "Komponentbiblioteket til Punkt, designsystem for Oslo kommune",
5
5
  "homepage": "https://punkt.oslo.kommune.no",
6
6
  "author": "Team Designsystem, Oslo kommune",
@@ -84,5 +84,5 @@
84
84
  "engines": {
85
85
  "node": "^22.19.0 || ^24.0.0 || ^26.0.0"
86
86
  },
87
- "gitHead": "9ffef14fdbc5993d24cba60a16324095834103f5"
87
+ "gitHead": "bad204d129d7788ce278eb48ba697806a86babe4"
88
88
  }
@@ -5,6 +5,9 @@ import { Ref, createRef, ref } from 'lit/directives/ref.js'
5
5
  import { html, nothing, PropertyValues } from 'lit'
6
6
  import { classMap } from 'lit/directives/class-map.js'
7
7
  import { ElementProps } from '@/types/typeUtils'
8
+ import { CHECKBOX_DEFAULTS, type TCheckboxLabelPosition } from 'shared-types'
9
+
10
+ export type { TCheckboxLabelPosition }
8
11
 
9
12
  type Props = ElementProps<
10
13
  PktCheckbox,
@@ -26,19 +29,21 @@ export class PktCheckbox extends PktInputElement<Props> {
26
29
 
27
30
  @property({ type: String, reflect: true }) value: string = ''
28
31
  @property({ type: String }) checkHelptext: string | null = null
29
- @property({ type: Boolean }) defaultChecked: boolean = false
30
- @property({ type: Boolean }) hasTile: boolean = false
31
- @property({ type: Boolean }) isSwitch: boolean = false
32
- @property({ type: String }) labelPosition: 'right' | 'left' = 'right'
33
- @property({ type: Boolean }) hideLabel: boolean = false
32
+ @property({ type: Boolean }) defaultChecked: boolean = CHECKBOX_DEFAULTS.defaultChecked
33
+ @property({ type: Boolean }) hasTile: boolean = CHECKBOX_DEFAULTS.hasTile
34
+ @property({ type: Boolean }) isSwitch: boolean = CHECKBOX_DEFAULTS.isSwitch
35
+ @property({ type: String }) labelPosition: TCheckboxLabelPosition =
36
+ CHECKBOX_DEFAULTS.labelPosition
37
+ @property({ type: Boolean }) hideLabel: boolean = CHECKBOX_DEFAULTS.hideLabel
34
38
  @property({ type: Boolean, reflect: true }) checked: boolean | string | null = null
35
- @property({ type: Boolean, reflect: true }) indeterminate: boolean | 'true' | 'false' | '' = false
39
+ @property({ type: Boolean, reflect: true }) indeterminate: boolean | 'true' | 'false' | '' =
40
+ CHECKBOX_DEFAULTS.indeterminate
36
41
  @property({ type: String, reflect: true }) type: string = 'checkbox'
37
42
  @property({ type: String }) tagText: string | null = null
38
- @property({ type: Boolean }) optionalTag: boolean = false
43
+ @property({ type: Boolean }) optionalTag: boolean = CHECKBOX_DEFAULTS.optionalTag
39
44
  /** @deprecated Bruk `strings={{ forms: { optional: '…' } }}` eller `setPktStrings()`. */
40
45
  @property({ type: String }) optionalText?: string
41
- @property({ type: Boolean }) requiredTag: boolean = false
46
+ @property({ type: Boolean }) requiredTag: boolean = CHECKBOX_DEFAULTS.requiredTag
42
47
  /** @deprecated Bruk `strings={{ forms: { required: '…' } }}` eller `setPktStrings()`. */
43
48
  @property({ type: String }) requiredText?: string
44
49
 
@@ -1,40 +0,0 @@
1
- const e=require("./element-CewjrA4g.cjs"),t=require("./class-map-B0FX3YsK.cjs"),n=require("./ref-HT6KRjxp.cjs"),r=require("./input-element-BdIWsDl-.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
- ${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`,d=()=>e._`
10
- <label class=${a} for=${this.id+`-internal`}>
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}
15
- </label>
16
- `;return e._`
17
- <div class="pkt-input-check">
18
- <div class=${r}>
19
- ${this.labelPosition===`left`?d():e.h}
20
- <input
21
- id=${this.id+`-internal`}
22
- class=${i}
23
- type="checkbox"
24
- ?disabled=${this.disabled}
25
- name=${this.name+`-internal`}
26
- ${n.n(this.inputRef)}
27
- @change=${this.handleChange}
28
- @input=${this.handleInput}
29
- @click=${this.handleClick}
30
- @blur=${this.onBlur}
31
- @focus=${this.onFocus}
32
- ?checked=${this.checked}
33
- role=${this.isSwitch?`switch`:`checkbox`}
34
- aria-labelledby=${this.label?l:e.h}
35
- aria-describedby=${this.checkHelptext?u:e.h}
36
- />
37
- ${this.labelPosition===`right`?d():e.h}
38
- </div>
39
- </div>
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}});