@oslokommune/punkt-elements 19.5.2 → 19.7.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.
Files changed (71) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/base-elements/input-element.d.ts +3 -2
  3. package/dist/{checkbox-_NnoYkue.cjs → checkbox-D69leWDh.cjs} +3 -3
  4. package/dist/{checkbox-Bbxt-tVW.js → checkbox-Tq8ESzwH.js} +6 -3
  5. package/dist/combobox-BfdvXLBz.cjs +139 -0
  6. package/dist/{combobox-CjLX_Gfd.js → combobox-CMpYhgln.js} +47 -423
  7. package/dist/components/checkbox/checkbox.d.ts +2 -1
  8. package/dist/components/combobox/combobox-base.d.ts +2 -2
  9. package/dist/components/combobox/combobox.d.ts +9 -26
  10. package/dist/components/input-wrapper/input-wrapper.d.ts +5 -2
  11. package/dist/components/radiobutton/radiobutton.d.ts +2 -0
  12. package/dist/{datepicker-CFCRxFQL.js → datepicker-Bs7Z3EFn.js} +1 -1
  13. package/dist/{datepicker-Bk-m5Zaa.cjs → datepicker-CWHYYj-H.cjs} +1 -1
  14. package/dist/docs/components/radio-checkbox-sizes.d.ts +10 -0
  15. package/dist/{fileupload-B2606SvG.js → fileupload-BQFJx1ok.js} +1 -1
  16. package/dist/{fileupload-COAxc3sX.cjs → fileupload-CMIFZWJ5.cjs} +1 -1
  17. package/dist/{header-BhM7FRoC.cjs → header-C4Uojzoy.cjs} +1 -1
  18. package/dist/{header-BQdc29IO.js → header-Cc1Cy0U3.js} +1 -1
  19. package/dist/{input-wrapper-Bz9GwYrn.js → input-wrapper-BoTugCvh.js} +13 -3
  20. package/dist/{input-wrapper-BBG8EXQ8.cjs → input-wrapper-J3mEKhvR.cjs} +3 -3
  21. package/dist/pkt-checkbox.cjs +1 -1
  22. package/dist/pkt-checkbox.js +1 -1
  23. package/dist/pkt-combobox.cjs +1 -1
  24. package/dist/pkt-combobox.js +1 -1
  25. package/dist/pkt-datepicker.cjs +1 -1
  26. package/dist/pkt-datepicker.js +1 -1
  27. package/dist/pkt-fileupload.cjs +1 -1
  28. package/dist/pkt-fileupload.js +1 -1
  29. package/dist/pkt-header.cjs +1 -1
  30. package/dist/pkt-header.js +1 -1
  31. package/dist/pkt-index.cjs +1 -1
  32. package/dist/pkt-index.js +17 -17
  33. package/dist/pkt-input-wrapper.cjs +1 -1
  34. package/dist/pkt-input-wrapper.js +1 -1
  35. package/dist/pkt-radiobutton.cjs +1 -1
  36. package/dist/pkt-radiobutton.js +1 -1
  37. package/dist/pkt-select.cjs +1 -1
  38. package/dist/pkt-select.js +1 -1
  39. package/dist/pkt-textarea.cjs +1 -1
  40. package/dist/pkt-textarea.js +1 -1
  41. package/dist/pkt-textinput.cjs +1 -1
  42. package/dist/pkt-textinput.js +1 -1
  43. package/dist/pkt-timepicker.cjs +1 -1
  44. package/dist/pkt-timepicker.js +1 -1
  45. package/dist/{radiobutton-C3kEjvHQ.cjs → radiobutton-BPr22VmL.cjs} +3 -3
  46. package/dist/{radiobutton-D9htviZG.js → radiobutton-l_3oGDbb.js} +6 -3
  47. package/dist/{select-BuQxosyi.cjs → select-CZYQ5Dmx.cjs} +1 -1
  48. package/dist/{select-BizHes0n.js → select-DYjKMmHa.js} +1 -1
  49. package/dist/shared-types/checkbox.d.ts +3 -1
  50. package/dist/shared-types/combobox.d.ts +73 -5
  51. package/dist/shared-types/index.d.ts +3 -1
  52. package/dist/shared-types/size.d.ts +3 -2
  53. package/dist/{textarea-CL1yUDVL.js → textarea-C2oaRlfb.js} +1 -1
  54. package/dist/{textarea-BXadsEdL.cjs → textarea-H1Lt2o6K.cjs} +1 -1
  55. package/dist/{textinput-Csil0Zda.js → textinput-C0eu70sH.js} +1 -1
  56. package/dist/{textinput-qi0f5NZH.cjs → textinput-C2Tx-OrN.cjs} +1 -1
  57. package/dist/{timepicker-DNoYMBAL.js → timepicker-B8TwchA2.js} +1 -1
  58. package/dist/{timepicker-CvL2-Siz.cjs → timepicker-DZG_gHIa.cjs} +1 -1
  59. package/package.json +2 -2
  60. package/src/components/checkbox/checkbox.test.ts +26 -0
  61. package/src/components/checkbox/checkbox.ts +3 -2
  62. package/src/components/combobox/combobox-base.ts +14 -8
  63. package/src/components/combobox/combobox-value.ts +2 -2
  64. package/src/components/combobox/combobox.attributes.test.ts +3 -2
  65. package/src/components/combobox/combobox.ts +26 -26
  66. package/src/components/input-wrapper/input-wrapper.test.ts +54 -0
  67. package/src/components/input-wrapper/input-wrapper.ts +12 -2
  68. package/src/components/input-wrapper/wrapper-parity.test.ts +9 -0
  69. package/src/components/radiobutton/radiobutton.test.ts +26 -0
  70. package/src/components/radiobutton/radiobutton.ts +3 -1
  71. package/dist/combobox-BBx87DCG.cjs +0 -139
@@ -1,4 +1,4 @@
1
- const e=require("./element-BOmr9YLv.cjs"),t=require("./class-map-Drv0_anQ.cjs"),n=require("./ref-Emu5PNxk.cjs"),r=require("./input-element-CSfDGslx.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===`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.isDisabled&&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.isDisabled,"pkt-sr-only":this.hideLabel}),o=`pkt-tag pkt-tag--small pkt-tag--thin-text`,s=this.pktStrings.get(`forms`),c=()=>e._`
1
+ const e=require("./element-BOmr9YLv.cjs"),t=require("./class-map-Drv0_anQ.cjs"),n=require("./ref-Emu5PNxk.cjs"),r=require("./input-element-CSfDGslx.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.inputSize=void 0,this.tagText=null,this.optionalTag=!1,this.requiredTag=!1,this._checked=!1}connectedCallback(){super.connectedCallback()}attributeChangedCallback(e,t,n){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.isDisabled&&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.isDisabled,"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
3
  ${this.optionalTag?e._`<span class=${o+` pkt-tag--blue-light`}
4
4
  >${this.optionalText??s.optional}</span
@@ -7,7 +7,7 @@ const e=require("./element-BOmr9YLv.cjs"),t=require("./class-map-Drv0_anQ.cjs"),
7
7
  >${this.requiredText??s.required}</span
8
8
  >`:e.h}
9
9
  `,l=this.id+`-check-label`,u=this.id+`-check-helptext`;return e._`
10
- <div class="pkt-input-check">
10
+ <div class="pkt-input-check${this.inputSize?` pkt-input-check--${this.inputSize}`:``}">
11
11
  <div class=${r}>
12
12
  <input
13
13
  id=${this.id+`-internal`}
@@ -35,4 +35,4 @@ const e=require("./element-BOmr9YLv.cjs"),t=require("./class-map-Drv0_anQ.cjs"),
35
35
  `}
36
36
  </div>
37
37
  </div>
38
- `}handleInput(e){e.stopImmediatePropagation(),this.onInput()}toggleChecked(e=null){e&&e.preventDefault(),e&&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,reflect:!0})],i.prototype,`checked`,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),e.n([e.l()],i.prototype,`_checked`,void 0);try{e.d(`pkt-radiobutton`)(i)}catch{console.warn(`Forsøker å definere <pkt-radiobutton>, 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
+ `}handleInput(e){e.stopImmediatePropagation(),this.onInput()}toggleChecked(e=null){e&&e.preventDefault(),e&&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,reflect:!0})],i.prototype,`checked`,void 0),e.n([e.u({type:String,reflect:!0})],i.prototype,`type`,void 0),e.n([e.u({type:String,attribute:`input-size`})],i.prototype,`inputSize`,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),e.n([e.l()],i.prototype,`_checked`,void 0);try{e.d(`pkt-radiobutton`)(i)}catch{console.warn(`Forsøker å definere <pkt-radiobutton>, 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}});
@@ -5,7 +5,7 @@ import { t as l } from "./input-element-lLzfwdim.js";
5
5
  //#region src/components/radiobutton/radiobutton.ts
6
6
  var u = class extends l {
7
7
  constructor(...e) {
8
- super(...e), this.inputRef = c(), 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;
8
+ super(...e), this.inputRef = c(), this.value = "", this.checkHelptext = null, this.defaultChecked = !1, this.hasTile = !1, this.checked = null, this.type = "radio", this.inputSize = void 0, this.tagText = null, this.optionalTag = !1, this.requiredTag = !1, this._checked = !1;
9
9
  }
10
10
  connectedCallback() {
11
11
  super.connectedCallback();
@@ -35,7 +35,7 @@ var u = class extends l {
35
35
  >` : n}
36
36
  `, u = this.id + "-check-label", d = this.id + "-check-helptext";
37
37
  return e`
38
- <div class="pkt-input-check">
38
+ <div class="pkt-input-check${this.inputSize ? ` pkt-input-check--${this.inputSize}` : ""}">
39
39
  <div class=${t}>
40
40
  <input
41
41
  id=${this.id + "-internal"}
@@ -81,7 +81,10 @@ i([a({
81
81
  })], u.prototype, "checked", void 0), i([a({
82
82
  type: String,
83
83
  reflect: !0
84
- })], u.prototype, "type", void 0), i([a({ type: String })], u.prototype, "tagText", void 0), i([a({ type: Boolean })], u.prototype, "optionalTag", void 0), i([a({ type: String })], u.prototype, "optionalText", void 0), i([a({ type: Boolean })], u.prototype, "requiredTag", void 0), i([a({ type: String })], u.prototype, "requiredText", void 0), i([r()], u.prototype, "_checked", void 0);
84
+ })], u.prototype, "type", void 0), i([a({
85
+ type: String,
86
+ attribute: "input-size"
87
+ })], u.prototype, "inputSize", void 0), i([a({ type: String })], u.prototype, "tagText", void 0), i([a({ type: Boolean })], u.prototype, "optionalTag", void 0), i([a({ type: String })], u.prototype, "optionalText", void 0), i([a({ type: Boolean })], u.prototype, "requiredTag", void 0), i([a({ type: String })], u.prototype, "requiredText", void 0), i([r()], u.prototype, "_checked", void 0);
85
88
  try {
86
89
  t("pkt-radiobutton")(u);
87
90
  } catch {
@@ -1,4 +1,4 @@
1
- const e=require("./element-BOmr9YLv.cjs"),t=require("./element-with-slot-D7sTqOr3.cjs"),n=require("./if-defined-2mkIDgOm.cjs"),r=require("./ref-Emu5PNxk.cjs"),i=require("./input-element-CSfDGslx.cjs"),a=require("./pkt-options-controller-CpEZcomb.cjs"),o=require("./input-wrapper-BBG8EXQ8.cjs");var s=class extends i.t{constructor(...e){super(...e),this._optionsProp=[],this._options=[]}get options(){return this._options.map(e=>({...e,selected:this.isOptionSelected(e)}))}set options(e){this._optionsProp=e,this.requestUpdate(`_optionsProp`,this._options)}isOptionSelected(e){return Array.isArray(this.value)?this.value.includes(e.value):e.value===this.value}findOptionByValue(e){return this._options.find(t=>t.value===e)}getSelectedOptions(){return this._options.filter(e=>this.isOptionSelected(e))}parseOptions(){let e=this._optionsProp.length>0,t=this.optionsController?.nodes?.length&&this.optionsController.nodes.length>0;e?this._options=this._optionsProp:t&&(this._options=this.optionsController.options)}willUpdate(e){super.willUpdate(e),this.parseOptions()}};e.n([e.u({type:Array,attribute:`options`})],s.prototype,`_optionsProp`,void 0),e.n([e.l()],s.prototype,`_options`,void 0);var c=class extends s{constructor(){super(),this.inputRef=r.t(),this.value=``,this.selectedIndex=-1,this.selectedOptions=void 0,this.optionsController=new a.t(this)}connectedCallback(){super.connectedCallback(),this.parseOptions(),this._options.forEach(e=>{e.selected&&!this.value&&(this.value=e.value)})}add(e,t){let n={value:e.value||e.text,label:e.text||e.value,selected:e.selected,disabled:e.disabled};if(t===void 0)this._options.push(n);else if(typeof t==`number`)this._options.splice(t,0,n);else{let e=t.value||t.text,r=this._options.findIndex(t=>t.value===e);r>=0?this._options.splice(r,0,n):this._options.push(n)}e.selected&&(this.value=e.value||e.text,this.selectedIndex=this._options.findIndex(e=>e.value===this.value)),this.requestUpdate()}remove(e){typeof e==`number`&&(this.selectedIndex===e&&(this.value=this._options[0]?.value||``),this._options.splice(e,1),this.requestUpdate())}item(e){return this.inputRef.value?.item(e)}namedItem(e){return this.inputRef.value?.namedItem(e)}showPicker(){this.inputRef.value&&`showPicker`in this.inputRef.value&&this.inputRef.value.showPicker()}attributeChangedCallback(e,t,n){e===`options`&&(this._options=n?JSON.parse(n):[]),e===`value`&&this.value!==t&&(this.selectedIndex=this.touched?this.returnNumberOrNull(this.inputRef.value?.selectedIndex):this._options.findIndex(e=>e.value===n),this.selectedOptions=this.inputRef.value?.selectedOptions,this.valueChanged(n,t)),super.attributeChangedCallback(e,t,n)}update(e){super.update(e),e.has(`_optionsProp`)&&this._optionsProp.length>0&&(this._options=this._optionsProp,this.requestUpdate(`_options`),!this.value&&this._options.length>0&&(this.value=this._options[0].value,this.selectedIndex=0)),e.has(`value`)&&this.value!==e.get(`value`)&&(this.selectedIndex=this.touched?this.returnNumberOrNull(this.inputRef.value?.selectedIndex):this._options.findIndex(e=>e.value===this.value),this.selectedOptions=this.inputRef.value?.selectedOptions,this.valueChanged(this.value,e.get(`value`))),e.has(`id`)&&!this.name&&this.id&&(this.name=this.id)}firstUpdated(e){super.firstUpdated(e),this.classList.add(`pkt-select`),this._optionsProp.length&&(this._options=this._optionsProp),!this.value&&this._options.length>0?(this.value=this._options[0].value,this.selectedIndex=0):this.selectedIndex=this._options.findIndex(e=>e.value===this.value),this.selectedOptions=this.inputRef.value?.selectedOptions}render(){let i=`pkt-input pkt-input--${this.inputSize} ${this.fullwidth?`pkt-input--fullwidth`:``}`;return e._`
1
+ const e=require("./element-BOmr9YLv.cjs"),t=require("./element-with-slot-D7sTqOr3.cjs"),n=require("./if-defined-2mkIDgOm.cjs"),r=require("./ref-Emu5PNxk.cjs"),i=require("./input-element-CSfDGslx.cjs"),a=require("./pkt-options-controller-CpEZcomb.cjs"),o=require("./input-wrapper-J3mEKhvR.cjs");var s=class extends i.t{constructor(...e){super(...e),this._optionsProp=[],this._options=[]}get options(){return this._options.map(e=>({...e,selected:this.isOptionSelected(e)}))}set options(e){this._optionsProp=e,this.requestUpdate(`_optionsProp`,this._options)}isOptionSelected(e){return Array.isArray(this.value)?this.value.includes(e.value):e.value===this.value}findOptionByValue(e){return this._options.find(t=>t.value===e)}getSelectedOptions(){return this._options.filter(e=>this.isOptionSelected(e))}parseOptions(){let e=this._optionsProp.length>0,t=this.optionsController?.nodes?.length&&this.optionsController.nodes.length>0;e?this._options=this._optionsProp:t&&(this._options=this.optionsController.options)}willUpdate(e){super.willUpdate(e),this.parseOptions()}};e.n([e.u({type:Array,attribute:`options`})],s.prototype,`_optionsProp`,void 0),e.n([e.l()],s.prototype,`_options`,void 0);var c=class extends s{constructor(){super(),this.inputRef=r.t(),this.value=``,this.selectedIndex=-1,this.selectedOptions=void 0,this.optionsController=new a.t(this)}connectedCallback(){super.connectedCallback(),this.parseOptions(),this._options.forEach(e=>{e.selected&&!this.value&&(this.value=e.value)})}add(e,t){let n={value:e.value||e.text,label:e.text||e.value,selected:e.selected,disabled:e.disabled};if(t===void 0)this._options.push(n);else if(typeof t==`number`)this._options.splice(t,0,n);else{let e=t.value||t.text,r=this._options.findIndex(t=>t.value===e);r>=0?this._options.splice(r,0,n):this._options.push(n)}e.selected&&(this.value=e.value||e.text,this.selectedIndex=this._options.findIndex(e=>e.value===this.value)),this.requestUpdate()}remove(e){typeof e==`number`&&(this.selectedIndex===e&&(this.value=this._options[0]?.value||``),this._options.splice(e,1),this.requestUpdate())}item(e){return this.inputRef.value?.item(e)}namedItem(e){return this.inputRef.value?.namedItem(e)}showPicker(){this.inputRef.value&&`showPicker`in this.inputRef.value&&this.inputRef.value.showPicker()}attributeChangedCallback(e,t,n){e===`options`&&(this._options=n?JSON.parse(n):[]),e===`value`&&this.value!==t&&(this.selectedIndex=this.touched?this.returnNumberOrNull(this.inputRef.value?.selectedIndex):this._options.findIndex(e=>e.value===n),this.selectedOptions=this.inputRef.value?.selectedOptions,this.valueChanged(n,t)),super.attributeChangedCallback(e,t,n)}update(e){super.update(e),e.has(`_optionsProp`)&&this._optionsProp.length>0&&(this._options=this._optionsProp,this.requestUpdate(`_options`),!this.value&&this._options.length>0&&(this.value=this._options[0].value,this.selectedIndex=0)),e.has(`value`)&&this.value!==e.get(`value`)&&(this.selectedIndex=this.touched?this.returnNumberOrNull(this.inputRef.value?.selectedIndex):this._options.findIndex(e=>e.value===this.value),this.selectedOptions=this.inputRef.value?.selectedOptions,this.valueChanged(this.value,e.get(`value`))),e.has(`id`)&&!this.name&&this.id&&(this.name=this.id)}firstUpdated(e){super.firstUpdated(e),this.classList.add(`pkt-select`),this._optionsProp.length&&(this._options=this._optionsProp),!this.value&&this._options.length>0?(this.value=this._options[0].value,this.selectedIndex=0):this.selectedIndex=this._options.findIndex(e=>e.value===this.value),this.selectedOptions=this.inputRef.value?.selectedOptions}render(){let i=`pkt-input pkt-input--${this.inputSize} ${this.fullwidth?`pkt-input--fullwidth`:``}`;return e._`
2
2
  <pkt-input-wrapper
3
3
  ${t.n(this,[`helptext`])}
4
4
  .strings=${this.strings}
@@ -4,7 +4,7 @@ import { t as o } from "./if-defined-Bebu3LXY.js";
4
4
  import { n as s, t as c } from "./ref-CCSGk4MP.js";
5
5
  import { t as l } from "./input-element-lLzfwdim.js";
6
6
  import { t as u } from "./pkt-options-controller-D7l18Iw0.js";
7
- import { r as d } from "./input-wrapper-Bz9GwYrn.js";
7
+ import { r as d } from "./input-wrapper-BoTugCvh.js";
8
8
  //#region src/base-elements/options-input-element.ts
9
9
  var f = class extends l {
10
10
  constructor(...e) {
@@ -6,6 +6,7 @@
6
6
  */
7
7
  import type { IPktStringsProps } from '../shared-strings';
8
8
  import type { IFormFieldErrorProps, IFormFieldLabelProps, ITagOptionalRequiredProps } from './form-field';
9
+ import type { TPktInputSize } from './size';
9
10
  /** Checkbox label placement — shared runtime source for types, specs, and Preview. */
10
11
  export declare const CHECKBOX_LABEL_POSITIONS: readonly ['right', 'left'];
11
12
  export type TCheckboxLabelPosition = (typeof CHECKBOX_LABEL_POSITIONS)[number];
@@ -28,12 +29,13 @@ export interface IPktCheckboxBase extends IFormFieldLabelProps, Pick<IFormFieldE
28
29
  isSwitch?: boolean;
29
30
  hideLabel?: boolean;
30
31
  labelPosition?: TCheckboxLabelPosition;
32
+ inputSize?: TPktInputSize;
31
33
  }
32
34
  /**
33
35
  * Documented Checkbox props (subset of `IPktCheckboxBase`).
34
36
  * Used for typed component specs in documentation.
35
37
  */
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'>;
38
+ export type ICheckboxSpecProps = Pick<IPktCheckboxBase, 'label' | 'checkHelptext' | 'name' | 'form' | 'value' | 'id' | 'defaultChecked' | 'checked' | 'indeterminate' | 'hasTile' | 'inputSize' | 'disabled' | 'hasError' | 'isSwitch' | 'labelPosition' | 'hideLabel' | 'requiredTag' | 'requiredText' | 'optionalTag' | 'optionalText' | 'tagText'>;
37
39
  /**
38
40
  * Default values for pkt-checkbox. Single source of truth for both frameworks.
39
41
  * `checked` is intentionally absent — React must keep it `undefined` to stay uncontrolled.
@@ -2,14 +2,17 @@
2
2
  * combobox.ts
3
3
  *
4
4
  * Type definitions for the combobox and listbox components.
5
- * Used by both Elements and React implementations
6
- * and by the shared combobox helper functions.
5
+ * Used by both Elements and React implementations,
6
+ * the shared combobox helper functions, and typed component specs.
7
7
  */
8
+ import type { IFormFieldErrorProps, IFormFieldLabelProps, IHelptextProps, ITagOptionalRequiredProps } from './form-field';
9
+ import type { TPktInputSize } from './size';
8
10
  /**
9
11
  * Tag skin colors available for combobox option tags.
10
12
  * Matches the TTagSkin values from the tag component.
11
13
  */
12
- export type TPktComboboxTagSkin = 'blue' | 'blue-dark' | 'blue-light' | 'green' | 'red' | 'yellow' | 'beige' | 'gray' | 'grey';
14
+ export declare const COMBOBOX_TAG_SKINS: readonly ['blue', 'blue-dark', 'blue-light', 'green', 'red', 'yellow', 'beige', 'gray', 'grey'];
15
+ export type TPktComboboxTagSkin = (typeof COMBOBOX_TAG_SKINS)[number];
13
16
  /**
14
17
  * Represents a single option in a combobox or listbox.
15
18
  */
@@ -27,8 +30,73 @@ export interface IPktComboboxOption {
27
30
  /**
28
31
  * How the selected value is displayed in the combobox input.
29
32
  */
30
- export type TPktComboboxDisplayValue = 'label' | 'value' | 'prefixAndValue';
33
+ export declare const COMBOBOX_DISPLAY_VALUES: readonly ['label', 'value', 'prefixAndValue'];
34
+ export type TPktComboboxDisplayValue = (typeof COMBOBOX_DISPLAY_VALUES)[number];
31
35
  /**
32
36
  * Placement of selected value tags in multiple selection mode.
33
37
  */
34
- export type TPktComboboxTagPlacement = 'inside' | 'outside';
38
+ export declare const COMBOBOX_TAG_PLACEMENTS: readonly ['inside', 'outside'];
39
+ export type TPktComboboxTagPlacement = (typeof COMBOBOX_TAG_PLACEMENTS)[number];
40
+ /**
41
+ * Combobox props shared by React, Elements, and typed component specs.
42
+ *
43
+ * @remarks Both frameworks extend this with `Omit<>` and widen a few props:
44
+ * - React widens `helptext`, `helptextDropdown` and `errorMessage` to `ReactNode`.
45
+ * - Elements widens string/number props to `| null` (Lit uses `null` for an unset attribute,
46
+ * see `PktInputElement`) and `useWrapper` to `Booleanish`. Elements omits `form`, which is
47
+ * a getter returning the associated `HTMLFormElement`, not the form id.
48
+ *
49
+ * `hasFieldset` and `counter` are tri-state: `null` means the component derives the value.
50
+ */
51
+ export interface IPktComboboxBase extends IFormFieldLabelProps, IHelptextProps, IFormFieldErrorProps, ITagOptionalRequiredProps {
52
+ id?: string;
53
+ name?: string;
54
+ form?: string;
55
+ ariaDescribedby?: string;
56
+ placeholder?: string;
57
+ required?: boolean;
58
+ value?: string | string[];
59
+ defaultValue?: string | string[];
60
+ options?: IPktComboboxOption[];
61
+ defaultOptions?: IPktComboboxOption[];
62
+ multiple?: boolean;
63
+ maxlength?: number;
64
+ typeahead?: boolean;
65
+ includeSearch?: boolean;
66
+ allowUserInput?: boolean;
67
+ searchPlaceholder?: string;
68
+ displayValueAs?: TPktComboboxDisplayValue;
69
+ tagPlacement?: TPktComboboxTagPlacement;
70
+ inputSize?: TPktInputSize;
71
+ fullwidth?: boolean;
72
+ inline?: boolean;
73
+ useWrapper?: boolean;
74
+ hasFieldset?: boolean | null;
75
+ counter?: boolean | null;
76
+ }
77
+ /**
78
+ * Documented Combobox props (subset of `IPktComboboxBase`).
79
+ * Used for typed component specs in documentation.
80
+ */
81
+ export type IComboboxSpecProps = Pick<IPktComboboxBase, 'name' | 'form' | 'ariaDescribedby' | 'id' | 'label' | 'placeholder' | 'multiple' | 'tagPlacement' | 'maxlength' | 'typeahead' | 'includeSearch' | 'allowUserInput' | 'searchPlaceholder' | 'displayValueAs' | 'inputSize' | 'value' | 'helptext' | 'helptextDropdown' | 'helptextDropdownButton' | 'disabled' | 'hasError' | 'errorMessage' | 'required' | 'requiredTag' | 'requiredText' | 'optionalTag' | 'optionalText' | 'tagText' | 'fullwidth' | 'defaultOptions' | 'options' | 'inline' | 'useWrapper' | 'hasFieldset' | 'counter' | 'defaultValue'>;
82
+ /**
83
+ * Default values for pkt-combobox. Single source of truth for both frameworks.
84
+ * Array defaults (`options`, `defaultOptions`) are intentionally absent — a shared array
85
+ * instance would be mutated across component instances.
86
+ */
87
+ export declare const COMBOBOX_DEFAULTS: {
88
+ readonly multiple: false;
89
+ readonly typeahead: false;
90
+ readonly includeSearch: false;
91
+ readonly allowUserInput: false;
92
+ readonly displayValueAs: 'label';
93
+ readonly inputSize: 'medium';
94
+ readonly disabled: false;
95
+ readonly hasError: false;
96
+ readonly required: false;
97
+ readonly requiredTag: false;
98
+ readonly optionalTag: false;
99
+ readonly fullwidth: false;
100
+ readonly inline: false;
101
+ readonly useWrapper: true;
102
+ };
@@ -20,6 +20,7 @@ export type { TIconSizeClass, IPktIconBase, IIconSpecProps } from './icon';
20
20
  export { LAYOUT_DIRECTIONS } from './layout';
21
21
  export type { TLayout, TVerticalPosition, THorizontalPosition, TPosition, TPositionWithCenter, } from './layout';
22
22
  export type { THTMLButtonType, TSelectionMode } from './form';
23
+ export { INPUT_SIZES } from './size';
23
24
  export type { TPktInputSize, TSize3, TSize5, TSize7 } from './size';
24
25
  export { ACCORDION_SKINS } from './accordion';
25
26
  export type { TAccordionSkin, IPktAccordionBase, IPktAccordionItemBase, IAccordionSpecProps, IAccordionItemSpecProps, IAccordionVisualProps, } from './accordion';
@@ -41,7 +42,8 @@ export { defaultSingleStrings, defaultRangeStrings } from './datepicker';
41
42
  export type { ITimepickerStrings } from './timepicker';
42
43
  export { defaultTimepickerStrings } from './timepicker';
43
44
  export type { TProgressbarRole, TProgressbarSkin, TProgressbarStatusPlacement, TProgressbarStatusType, TProgressbarTitlePosition, } from './progressbar';
44
- export type { IPktComboboxOption, TPktComboboxTagSkin, TPktComboboxDisplayValue, TPktComboboxTagPlacement, } from './combobox';
45
+ export { COMBOBOX_TAG_SKINS, COMBOBOX_DISPLAY_VALUES, COMBOBOX_TAG_PLACEMENTS, COMBOBOX_DEFAULTS, } from './combobox';
46
+ export type { IPktComboboxOption, TPktComboboxTagSkin, TPktComboboxDisplayValue, TPktComboboxTagPlacement, IPktComboboxBase, IComboboxSpecProps, } from './combobox';
45
47
  export type { IPktSelectOption, TSelectOption } from './select';
46
48
  export type { TPktSearchInputAppearance, TPktSearchInputMethod, IPktSearchInputSuggestion, IPktSearchInput, } from './searchinput';
47
49
  export { UPLOAD_STRATEGIES, FILE_UPLOAD_ITEM_RENDERERS, PREVIEW_UPLOAD_STATUS, } from './fileupload';
@@ -17,6 +17,7 @@ export type TSize5 = 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge';
17
17
  */
18
18
  export type TSize7 = 'xxsmall' | 'xsmall' | 'small' | 'medium' | 'large' | 'xlarge' | 'xxlarge';
19
19
  /**
20
- * Sizes used in our input components
20
+ * Sizes used in our input components — shared runtime source for types, specs, and Preview.
21
21
  */
22
- export type TPktInputSize = 'xsmall' | 'small' | 'medium';
22
+ export declare const INPUT_SIZES: readonly ['xsmall', 'small', 'medium'];
23
+ export type TPktInputSize = (typeof INPUT_SIZES)[number];
@@ -6,7 +6,7 @@ import "./icon-JigbxxF7.js";
6
6
  import { t as m } from "./if-defined-Bebu3LXY.js";
7
7
  import { n as h, t as g } from "./ref-CCSGk4MP.js";
8
8
  import { t as _ } from "./input-element-lLzfwdim.js";
9
- import { r as v } from "./input-wrapper-Bz9GwYrn.js";
9
+ import { r as v } from "./input-wrapper-BoTugCvh.js";
10
10
  //#region ../../node_modules/lit-html/directives/live.js
11
11
  var y = n(class extends c {
12
12
  constructor(e) {
@@ -1,4 +1,4 @@
1
- const e=require("./element-BOmr9YLv.cjs"),t=require("./class-map-Drv0_anQ.cjs"),n=require("./directive-helpers-BRrz3Bcj.cjs"),r=require("./element-with-slot-D7sTqOr3.cjs");require("./icon-Dnv6LtPC.cjs");const i=require("./if-defined-2mkIDgOm.cjs"),a=require("./ref-Emu5PNxk.cjs"),o=require("./input-element-CSfDGslx.cjs"),s=require("./input-wrapper-BBG8EXQ8.cjs");var c=e.f(class extends e.p{constructor(t){if(super(t),t.type!==e.m.PROPERTY&&t.type!==e.m.ATTRIBUTE&&t.type!==e.m.BOOLEAN_ATTRIBUTE)throw Error("The `live` directive is not allowed on child or event bindings");if(!n.i(t))throw Error("`live` bindings can only contain a single expression")}render(e){return e}update(t,[r]){if(r===e.g||r===e.h)return r;let i=t.element,a=t.name;if(t.type===e.m.PROPERTY){if(r===i[a])return e.g}else if(t.type===e.m.BOOLEAN_ATTRIBUTE){if(!!r===i.hasAttribute(a))return e.g}else if(t.type===e.m.ATTRIBUTE&&i.getAttribute(a)===r+``)return e.g;return n.r(t),r}}),l=class extends o.t{constructor(...e){super(...e),this.inputRef=a.t(),this.value=``,this.autocomplete=`off`,this.rows=null,this.cols=null,this.counterCurrent=0}attributeChangedCallback(e,t,n){e===`value`&&this.value!==t&&(this.counterCurrent=n?n.length:0),super.attributeChangedCallback(e,t,n)}willUpdate(e){super.willUpdate(e),e.has(`value`)&&(this.counterCurrent=this.value?.length||0),e.has(`id`)&&!this.name&&this.id&&(this.name=this.id)}updated(e){super.updated(e),this.classList.add(`pkt-textinput`,`pkt-textarea`),e.has(`value`)&&this.valueChanged(this.value,e.get(`value`))}render(){let n=this.effectiveCounter(this.counterMaxLength>0),o=t.t({"pkt-input":!0,[`pkt-input--${this.inputSize}`]:!0,"pkt-input--fullwidth":this.fullwidth,"pkt-input--counter-error":n&&this.counterMaxLength>0&&this.value.length>this.counterMaxLength}),l=this.ariaLabelledby||`${this.id}-input-label`;return e._`<pkt-input-wrapper
1
+ const e=require("./element-BOmr9YLv.cjs"),t=require("./class-map-Drv0_anQ.cjs"),n=require("./directive-helpers-BRrz3Bcj.cjs"),r=require("./element-with-slot-D7sTqOr3.cjs");require("./icon-Dnv6LtPC.cjs");const i=require("./if-defined-2mkIDgOm.cjs"),a=require("./ref-Emu5PNxk.cjs"),o=require("./input-element-CSfDGslx.cjs"),s=require("./input-wrapper-J3mEKhvR.cjs");var c=e.f(class extends e.p{constructor(t){if(super(t),t.type!==e.m.PROPERTY&&t.type!==e.m.ATTRIBUTE&&t.type!==e.m.BOOLEAN_ATTRIBUTE)throw Error("The `live` directive is not allowed on child or event bindings");if(!n.i(t))throw Error("`live` bindings can only contain a single expression")}render(e){return e}update(t,[r]){if(r===e.g||r===e.h)return r;let i=t.element,a=t.name;if(t.type===e.m.PROPERTY){if(r===i[a])return e.g}else if(t.type===e.m.BOOLEAN_ATTRIBUTE){if(!!r===i.hasAttribute(a))return e.g}else if(t.type===e.m.ATTRIBUTE&&i.getAttribute(a)===r+``)return e.g;return n.r(t),r}}),l=class extends o.t{constructor(...e){super(...e),this.inputRef=a.t(),this.value=``,this.autocomplete=`off`,this.rows=null,this.cols=null,this.counterCurrent=0}attributeChangedCallback(e,t,n){e===`value`&&this.value!==t&&(this.counterCurrent=n?n.length:0),super.attributeChangedCallback(e,t,n)}willUpdate(e){super.willUpdate(e),e.has(`value`)&&(this.counterCurrent=this.value?.length||0),e.has(`id`)&&!this.name&&this.id&&(this.name=this.id)}updated(e){super.updated(e),this.classList.add(`pkt-textinput`,`pkt-textarea`),e.has(`value`)&&this.valueChanged(this.value,e.get(`value`))}render(){let n=this.effectiveCounter(this.counterMaxLength>0),o=t.t({"pkt-input":!0,[`pkt-input--${this.inputSize}`]:!0,"pkt-input--fullwidth":this.fullwidth,"pkt-input--counter-error":n&&this.counterMaxLength>0&&this.value.length>this.counterMaxLength}),l=this.ariaLabelledby||`${this.id}-input-label`;return e._`<pkt-input-wrapper
2
2
  ${r.n(this,[`helptext`])}
3
3
  .strings=${this.strings}
4
4
  label=${this.label}
@@ -5,7 +5,7 @@ import "./icon-JigbxxF7.js";
5
5
  import { t as c } from "./if-defined-Bebu3LXY.js";
6
6
  import { n as l, t as u } from "./ref-CCSGk4MP.js";
7
7
  import { t as d } from "./input-element-lLzfwdim.js";
8
- import { r as f } from "./input-wrapper-Bz9GwYrn.js";
8
+ import { r as f } from "./input-wrapper-BoTugCvh.js";
9
9
  //#region src/components/textinput/textinput.ts
10
10
  var p = class extends d {
11
11
  constructor(...e) {
@@ -1,4 +1,4 @@
1
- const e=require("./element-BOmr9YLv.cjs"),t=require("./class-map-Drv0_anQ.cjs"),n=require("./element-with-slot-D7sTqOr3.cjs");require("./icon-Dnv6LtPC.cjs");const r=require("./if-defined-2mkIDgOm.cjs"),i=require("./ref-Emu5PNxk.cjs"),a=require("./input-element-CSfDGslx.cjs"),o=require("./input-wrapper-BBG8EXQ8.cjs");var s=class extends a.t{constructor(...e){super(...e),this.inputRef=i.t(),this.value=``,this.type=`text`,this.size=null,this.autocomplete=null,this.iconNameRight=null,this.prefix=null,this.suffix=null,this.omitSearchIcon=!1,this.counterCurrent=0}attributeChangedCallback(e,t,n){e===`value`&&this.value!==t&&(this.counterCurrent=n?n.length:0),super.attributeChangedCallback(e,t,n)}willUpdate(e){super.willUpdate(e),e.has(`value`)&&(this.counterCurrent=this.value?.length||0),e.has(`id`)&&!this.name&&this.id&&(this.name=this.id)}updated(e){super.updated(e),this.classList.add(`pkt-textinput`),e.has(`value`)&&this.valueChanged(this.value,e.get(`value`))}render(){let a=this.type===`search`&&!this.iconNameRight&&!this.omitSearchIcon,s=this.effectiveCounter(this.counterMaxLength>0),c=t.t({"pkt-input":!0,[`pkt-input--${this.inputSize}`]:!0,"pkt-input--fullwidth":this.fullwidth,"pkt-input--counter-error":s&&this.counterMaxLength>0&&this.value.length>this.counterMaxLength}),l=this.ariaLabelledby||`${this.id}-input-label`;return e._`
1
+ const e=require("./element-BOmr9YLv.cjs"),t=require("./class-map-Drv0_anQ.cjs"),n=require("./element-with-slot-D7sTqOr3.cjs");require("./icon-Dnv6LtPC.cjs");const r=require("./if-defined-2mkIDgOm.cjs"),i=require("./ref-Emu5PNxk.cjs"),a=require("./input-element-CSfDGslx.cjs"),o=require("./input-wrapper-J3mEKhvR.cjs");var s=class extends a.t{constructor(...e){super(...e),this.inputRef=i.t(),this.value=``,this.type=`text`,this.size=null,this.autocomplete=null,this.iconNameRight=null,this.prefix=null,this.suffix=null,this.omitSearchIcon=!1,this.counterCurrent=0}attributeChangedCallback(e,t,n){e===`value`&&this.value!==t&&(this.counterCurrent=n?n.length:0),super.attributeChangedCallback(e,t,n)}willUpdate(e){super.willUpdate(e),e.has(`value`)&&(this.counterCurrent=this.value?.length||0),e.has(`id`)&&!this.name&&this.id&&(this.name=this.id)}updated(e){super.updated(e),this.classList.add(`pkt-textinput`),e.has(`value`)&&this.valueChanged(this.value,e.get(`value`))}render(){let a=this.type===`search`&&!this.iconNameRight&&!this.omitSearchIcon,s=this.effectiveCounter(this.counterMaxLength>0),c=t.t({"pkt-input":!0,[`pkt-input--${this.inputSize}`]:!0,"pkt-input--fullwidth":this.fullwidth,"pkt-input--counter-error":s&&this.counterMaxLength>0&&this.value.length>this.counterMaxLength}),l=this.ariaLabelledby||`${this.id}-input-label`;return e._`
2
2
  <pkt-input-wrapper
3
3
  ${n.n(this,[`helptext`])}
4
4
  .strings=${this.strings}
@@ -6,7 +6,7 @@ import "./icon-JigbxxF7.js";
6
6
  import { t as l } from "./if-defined-Bebu3LXY.js";
7
7
  import { n as u, t as d } from "./ref-CCSGk4MP.js";
8
8
  import { t as f } from "./input-element-lLzfwdim.js";
9
- import { r as p } from "./input-wrapper-Bz9GwYrn.js";
9
+ import { r as p } from "./input-wrapper-BoTugCvh.js";
10
10
  //#region ../../shared-utils/timepicker/time-utils.ts
11
11
  var m = (e) => /^\d{2}:\d{2}$/.test(e) && parseInt(e.slice(0, 2), 10) <= 23 && parseInt(e.slice(3), 10) <= 59, h = (e) => {
12
12
  let [t, n] = e.split(":").map(Number);
@@ -1,4 +1,4 @@
1
- const e=require("./element-BOmr9YLv.cjs"),t=require("./class-map-Drv0_anQ.cjs"),n=require("./format-B8meU8Tm.cjs"),r=require("./element-with-slot-D7sTqOr3.cjs");require("./icon-Dnv6LtPC.cjs");const i=require("./if-defined-2mkIDgOm.cjs"),a=require("./ref-Emu5PNxk.cjs"),o=require("./input-element-CSfDGslx.cjs"),s=require("./input-wrapper-BBG8EXQ8.cjs");var c=e=>/^\d{2}:\d{2}$/.test(e)&&parseInt(e.slice(0,2),10)<=23&&parseInt(e.slice(3),10)<=59,l=e=>{let[t,n]=e.split(`:`).map(Number);return t*60+n},u=e=>e?Math.max(1,Math.round(e/60)):1,d=(e,t)=>{let n=e?parseInt(String(e).split(`:`)[0],10):0,r=t?parseInt(String(t).split(`:`)[0],10):23;return Array.from({length:r-n+1},(e,t)=>t+n)},f=e=>{let t=u(e);return Array.from({length:Math.floor(60/t)},(e,n)=>n*t)},p=(e,t,n,r)=>{let i=e===``?n===1?0:23:parseInt(e,10),a=t===``?n===1?0:Math.floor(59/r)*r:parseInt(t,10);return a+=n*r,a>59?(a=0,i=(i+1)%24):a<0&&(a=Math.floor(59/r)*r,i=(i-1+24)%24),{hours:String(i).padStart(2,`0`),minutes:String(a).padStart(2,`0`)}},m=class extends o.t{constructor(...e){super(...e),this.hiddenInputRef=a.t(),this.hoursInputRef=a.t(),this.minutesInputRef=a.t(),this.buttonRef=a.t(),this.value=``,this.hidePicker=!1,this.stepArrows=!1,this._hours=``,this._minutes=``,this._isOpen=!1,this._hoursDigitCount=0,this._hoursFirstDigit=-1,this._minutesDigitCount=0,this._minutesFirstDigit=-1,this._hasFocus=!1,this._outsideClickHandler=e=>{this.contains(e.target)||this._closePopup()},this._handleComponentFocusIn=()=>{this._hasFocus||(this._hasFocus=!0,this.onFocus())},this._handleComponentFocusOut=e=>{this.contains(e.relatedTarget)||(this._hasFocus=!1,this.onBlur())},this._handleHoursKeydown=e=>{let t=e.target;switch(e.key){case`ArrowUp`:{e.preventDefault();let t=this._hours===``?0:parseInt(this._hours,10);this._hours=String((t+1)%24).padStart(2,`0`),this._syncValueFromDisplay(),this.onInput();break}case`ArrowDown`:{e.preventDefault();let t=this._hours===``?0:parseInt(this._hours,10);this._hours=String((t-1+24)%24).padStart(2,`0`),this._syncValueFromDisplay(),this.onInput();break}case`ArrowRight`:e.preventDefault(),this.minutesInputRef.value?.focus();break;case`Backspace`:case`Delete`:this._hoursDigitCount=0,this._hoursFirstDigit=-1;break;case`Tab`:break;case`Enter`:{e.preventDefault();let n=this.internals.form;n?n.requestSubmit():t.blur();break}default:if(/^\d$/.test(e.key)){e.preventDefault();let t=parseInt(e.key,10);if(this._hoursDigitCount===0)this._hoursFirstDigit=t,this._hours=String(t).padStart(2,`0`),this._hoursDigitCount=1,this.onInput(),t>=3&&(this._hoursFirstDigit=-1,this._hoursDigitCount=0,this._syncValueFromDisplay(),this.minutesInputRef.value?.focus());else{let e=this._hoursFirstDigit*10+t;this._hours=e<=23?String(e).padStart(2,`0`):String(t).padStart(2,`0`),this._hoursFirstDigit=-1,this._hoursDigitCount=0,this._syncValueFromDisplay(),this.onInput(),this.minutesInputRef.value?.focus()}}else e.preventDefault()}},this._handleHoursBlur=()=>{this._hours!==``&&(this._hours=String(parseInt(this._hours,10)).padStart(2,`0`)),this._hoursDigitCount=0,this._hoursFirstDigit=-1,this._syncValueFromDisplay()},this._handleMinutesKeydown=e=>{let t=e.target;switch(e.key){case`ArrowUp`:{e.preventDefault();let t=this._minutes===``?0:parseInt(this._minutes,10);this._minutes=String((t+this._minuteStep)%60).padStart(2,`0`),this._syncValueFromDisplay(),this.onInput();break}case`ArrowDown`:{e.preventDefault();let t=this._minutes===``?0:parseInt(this._minutes,10);this._minutes=String((t-this._minuteStep+60)%60).padStart(2,`0`),this._syncValueFromDisplay(),this.onInput();break}case`ArrowLeft`:e.preventDefault(),this.hoursInputRef.value?.focus();break;case`Backspace`:case`Delete`:this._minutesDigitCount=0,this._minutesFirstDigit=-1;break;case`Tab`:break;case`Enter`:{e.preventDefault();let n=this.internals.form;n?n.requestSubmit():t.blur();break}default:if(/^\d$/.test(e.key)){e.preventDefault();let t=parseInt(e.key,10);if(this._minutesDigitCount===0)this._minutesFirstDigit=t,this._minutes=String(t).padStart(2,`0`),this._minutesDigitCount=1,this.onInput(),t>=6&&(this._minutesFirstDigit=-1,this._minutesDigitCount=0,this._syncValueFromDisplay());else{let e=this._minutesFirstDigit*10+t;this._minutes=e<=59?String(e).padStart(2,`0`):String(t).padStart(2,`0`),this._minutesFirstDigit=-1,this._minutesDigitCount=0,this._syncValueFromDisplay(),this.onInput()}}else e.preventDefault()}},this._handleMinutesBlur=()=>{this._minutes!==``&&(this._minutes=String(parseInt(this._minutes,10)).padStart(2,`0`)),this._minutesDigitCount=0,this._minutesFirstDigit=-1,this._syncValueFromDisplay()},this._handlePopupKeydown=e=>{let t=document.activeElement,n=t.closest(`.pkt-timepicker-popup__col`);if(!n)return;let r=Array.from(n.querySelectorAll(`.pkt-timepicker-popup__option`)),i=r.indexOf(t),a=t.dataset.type??``;switch(e.key){case`ArrowDown`:e.preventDefault(),this._focusOptionAndSync(r[Math.min(i+1,r.length-1)],a);break;case`ArrowUp`:e.preventDefault(),this._focusOptionAndSync(r[Math.max(i-1,0)],a);break;case`Home`:e.preventDefault(),this._focusOptionAndSync(r[0],a);break;case`End`:e.preventDefault(),this._focusOptionAndSync(r[r.length-1],a);break;case`ArrowRight`:e.preventDefault(),a===`hour`&&(this._focusOptionAndSync(t,a),this.updateComplete.then(()=>{this._scrollToSelected(),this._focusSelectedOrFirst(`minute`)}));break;case`ArrowLeft`:e.preventDefault(),a===`minute`&&(this._focusOptionAndSync(t,a),this.updateComplete.then(()=>{this._scrollToSelected(),this._focusSelectedOrFirst(`hour`)}));break;case`Enter`:case` `:e.preventDefault(),t.click();break;case`Escape`:e.preventDefault(),this._closePopup(),this.buttonRef.value?.focus()}}}get inputRef(){return this.hiddenInputRef}manageValidity(e){let t=this.hoursInputRef.value;if(!t)return;let r=this.pktStrings.get(`validation`);if(this.required&&!this.value){this.internals.setValidity({valueMissing:!0},r.valueMissing,t),this._setAriaInvalid(!0);return}if(!this.value){this.internals.setValidity({}),this._setAriaInvalid(!1);return}let i=l(this.value),a=u(this.step);if(this.min&&i<l(String(this.min))){this.internals.setValidity({rangeUnderflow:!0},n.t(r.rangeUnderflowMin,{min:String(this.min)}),t),this._setAriaInvalid(!0);return}if(this.max&&i>l(String(this.max))){this.internals.setValidity({rangeOverflow:!0},n.t(r.rangeOverflowMax,{max:String(this.max)}),t),this._setAriaInvalid(!0);return}if(this.step&&i%a!==0){let e=a===60?r.timeStepMismatchHour:a===30?r.timeStepMismatchHalfHour:n.t(r.timeStepMismatch,{step:`${a}, ${a*2}, ${a*3}`});this.internals.setValidity({stepMismatch:!0},e,t),this._setAriaInvalid(!0);return}this.internals.setValidity({}),this._setAriaInvalid(!1)}_describedBy(){return s.r({id:`${this.id}-hours`,hasHelptext:!!this.helptext||this.hasSlotContent(`helptext`),ariaDescribedby:this.ariaDescribedby})}_setAriaInvalid(e){if(!this.touched&&e)return;let t=this.hoursInputRef.value,n=this.minutesInputRef.value;if(e)t?.setAttribute(`aria-invalid`,`true`),n?.setAttribute(`aria-invalid`,`true`);else{if(this.hasError)return;t?.removeAttribute(`aria-invalid`),n?.removeAttribute(`aria-invalid`)}}connectedCallback(){super.connectedCallback(),this.addEventListener(`focusin`,this._handleComponentFocusIn),this.addEventListener(`focusout`,this._handleComponentFocusOut),document.addEventListener(`click`,this._outsideClickHandler)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(`focusin`,this._handleComponentFocusIn),this.removeEventListener(`focusout`,this._handleComponentFocusOut),document.removeEventListener(`click`,this._outsideClickHandler)}willUpdate(e){super.willUpdate(e),e.has(`value`)&&this._syncDisplayFromValue()}updated(e){super.updated(e),this.classList.add(`pkt-timepicker`),this.classList.toggle(`pkt-timepicker--stepper`,this.stepArrows),this.classList.toggle(`pkt-timepicker--fullwidth`,this.fullwidth),this.classList.toggle(`pkt-timepicker--medium`,this.inputSize===`medium`),this.classList.toggle(`pkt-timepicker--small`,this.inputSize===`small`),this.classList.toggle(`pkt-timepicker--xsmall`,this.inputSize===`xsmall`),e.has(`step`)&&this.step!==null&&!this._isValidStep(this.step)&&console.warn(`pkt-timepicker: step="${this.step}" er ikke en gyldig verdi. Step må være et multiplum av 60 (hele minutter) eller nøyaktig 3600 (hel time).`)}formResetCallback(){super.formResetCallback(),this._hours=``,this._minutes=``,this._isOpen=!1}_isValidStep(e){return e===3600||e<3600&&3600%e==0&&e%60==0}_syncDisplayFromValue(){let e=c(this.value)?this.value.split(`:`):null;e?(this._hours=e[0],this._minutes=e[1]):(this._hours=``,this._minutes=``)}_syncValueFromDisplay(){if(this._hours!==``&&this._minutes!==``){let e=`${this._hours}:${this._minutes}`;e!==this.value&&(this.value=e,this.onChange(e))}else this.value!==``&&(this.value=``,this.onChange(``))}get _minuteStep(){return u(this.step)}get _hourOptions(){return d(this.min,this.max)}get _minuteOptions(){return f(this.step)}_openPopup(){this._isOpen=!0,this.updateComplete.then(()=>{this._scrollToSelected(),this._focusSelectedOrFirst(`hour`)})}_closePopup(){this._isOpen=!1,this._syncValueFromDisplay()}_togglePopup(){this._isOpen?this._closePopup():this._openPopup()}_scrollToSelected(){let e=this.querySelector(`.pkt-timepicker-popup`);e&&e.querySelectorAll(`.pkt-timepicker-popup__col`).forEach(e=>{let t=e.querySelector(`.pkt-timepicker-popup__option--selected`);t&&t.scrollIntoView({block:`center`})})}_focusSelectedOrFirst(e){let t=this.querySelector(`.pkt-timepicker-popup`);if(!t)return;let n=t.querySelectorAll(`.pkt-timepicker-popup__col`),r=e===`hour`?n[0]:n[1];if(!r)return;let i=r.querySelector(`.pkt-timepicker-popup__option--selected`),a=r.querySelector(`.pkt-timepicker-popup__option`);(i||a)?.focus()}_handleOptionClick(e,t){let n=String(e).padStart(2,`0`);t===`hour`?(this._hours=n,this.updateComplete.then(()=>this._focusSelectedOrFirst(`minute`))):(this._minutes=n,this._closePopup(),this.buttonRef.value?.focus())}_focusOptionAndSync(e,t){if(!e)return;let n=parseInt(e.dataset.value??`0`,10);t===`hour`?this._hours=String(n).padStart(2,`0`):this._minutes=String(n).padStart(2,`0`),e.focus()}_stepTime(e){let t=p(this._hours,this._minutes,e,this._minuteStep);this._hours=t.hours,this._minutes=t.minutes,this._syncValueFromDisplay()}_renderOption(n,r){let i=String(n).padStart(2,`0`),a=n===(r===`hour`?this._hours===``?NaN:parseInt(this._hours,10):this._minutes===``?NaN:parseInt(this._minutes,10));return e._`
1
+ const e=require("./element-BOmr9YLv.cjs"),t=require("./class-map-Drv0_anQ.cjs"),n=require("./format-B8meU8Tm.cjs"),r=require("./element-with-slot-D7sTqOr3.cjs");require("./icon-Dnv6LtPC.cjs");const i=require("./if-defined-2mkIDgOm.cjs"),a=require("./ref-Emu5PNxk.cjs"),o=require("./input-element-CSfDGslx.cjs"),s=require("./input-wrapper-J3mEKhvR.cjs");var c=e=>/^\d{2}:\d{2}$/.test(e)&&parseInt(e.slice(0,2),10)<=23&&parseInt(e.slice(3),10)<=59,l=e=>{let[t,n]=e.split(`:`).map(Number);return t*60+n},u=e=>e?Math.max(1,Math.round(e/60)):1,d=(e,t)=>{let n=e?parseInt(String(e).split(`:`)[0],10):0,r=t?parseInt(String(t).split(`:`)[0],10):23;return Array.from({length:r-n+1},(e,t)=>t+n)},f=e=>{let t=u(e);return Array.from({length:Math.floor(60/t)},(e,n)=>n*t)},p=(e,t,n,r)=>{let i=e===``?n===1?0:23:parseInt(e,10),a=t===``?n===1?0:Math.floor(59/r)*r:parseInt(t,10);return a+=n*r,a>59?(a=0,i=(i+1)%24):a<0&&(a=Math.floor(59/r)*r,i=(i-1+24)%24),{hours:String(i).padStart(2,`0`),minutes:String(a).padStart(2,`0`)}},m=class extends o.t{constructor(...e){super(...e),this.hiddenInputRef=a.t(),this.hoursInputRef=a.t(),this.minutesInputRef=a.t(),this.buttonRef=a.t(),this.value=``,this.hidePicker=!1,this.stepArrows=!1,this._hours=``,this._minutes=``,this._isOpen=!1,this._hoursDigitCount=0,this._hoursFirstDigit=-1,this._minutesDigitCount=0,this._minutesFirstDigit=-1,this._hasFocus=!1,this._outsideClickHandler=e=>{this.contains(e.target)||this._closePopup()},this._handleComponentFocusIn=()=>{this._hasFocus||(this._hasFocus=!0,this.onFocus())},this._handleComponentFocusOut=e=>{this.contains(e.relatedTarget)||(this._hasFocus=!1,this.onBlur())},this._handleHoursKeydown=e=>{let t=e.target;switch(e.key){case`ArrowUp`:{e.preventDefault();let t=this._hours===``?0:parseInt(this._hours,10);this._hours=String((t+1)%24).padStart(2,`0`),this._syncValueFromDisplay(),this.onInput();break}case`ArrowDown`:{e.preventDefault();let t=this._hours===``?0:parseInt(this._hours,10);this._hours=String((t-1+24)%24).padStart(2,`0`),this._syncValueFromDisplay(),this.onInput();break}case`ArrowRight`:e.preventDefault(),this.minutesInputRef.value?.focus();break;case`Backspace`:case`Delete`:this._hoursDigitCount=0,this._hoursFirstDigit=-1;break;case`Tab`:break;case`Enter`:{e.preventDefault();let n=this.internals.form;n?n.requestSubmit():t.blur();break}default:if(/^\d$/.test(e.key)){e.preventDefault();let t=parseInt(e.key,10);if(this._hoursDigitCount===0)this._hoursFirstDigit=t,this._hours=String(t).padStart(2,`0`),this._hoursDigitCount=1,this.onInput(),t>=3&&(this._hoursFirstDigit=-1,this._hoursDigitCount=0,this._syncValueFromDisplay(),this.minutesInputRef.value?.focus());else{let e=this._hoursFirstDigit*10+t;this._hours=e<=23?String(e).padStart(2,`0`):String(t).padStart(2,`0`),this._hoursFirstDigit=-1,this._hoursDigitCount=0,this._syncValueFromDisplay(),this.onInput(),this.minutesInputRef.value?.focus()}}else e.preventDefault()}},this._handleHoursBlur=()=>{this._hours!==``&&(this._hours=String(parseInt(this._hours,10)).padStart(2,`0`)),this._hoursDigitCount=0,this._hoursFirstDigit=-1,this._syncValueFromDisplay()},this._handleMinutesKeydown=e=>{let t=e.target;switch(e.key){case`ArrowUp`:{e.preventDefault();let t=this._minutes===``?0:parseInt(this._minutes,10);this._minutes=String((t+this._minuteStep)%60).padStart(2,`0`),this._syncValueFromDisplay(),this.onInput();break}case`ArrowDown`:{e.preventDefault();let t=this._minutes===``?0:parseInt(this._minutes,10);this._minutes=String((t-this._minuteStep+60)%60).padStart(2,`0`),this._syncValueFromDisplay(),this.onInput();break}case`ArrowLeft`:e.preventDefault(),this.hoursInputRef.value?.focus();break;case`Backspace`:case`Delete`:this._minutesDigitCount=0,this._minutesFirstDigit=-1;break;case`Tab`:break;case`Enter`:{e.preventDefault();let n=this.internals.form;n?n.requestSubmit():t.blur();break}default:if(/^\d$/.test(e.key)){e.preventDefault();let t=parseInt(e.key,10);if(this._minutesDigitCount===0)this._minutesFirstDigit=t,this._minutes=String(t).padStart(2,`0`),this._minutesDigitCount=1,this.onInput(),t>=6&&(this._minutesFirstDigit=-1,this._minutesDigitCount=0,this._syncValueFromDisplay());else{let e=this._minutesFirstDigit*10+t;this._minutes=e<=59?String(e).padStart(2,`0`):String(t).padStart(2,`0`),this._minutesFirstDigit=-1,this._minutesDigitCount=0,this._syncValueFromDisplay(),this.onInput()}}else e.preventDefault()}},this._handleMinutesBlur=()=>{this._minutes!==``&&(this._minutes=String(parseInt(this._minutes,10)).padStart(2,`0`)),this._minutesDigitCount=0,this._minutesFirstDigit=-1,this._syncValueFromDisplay()},this._handlePopupKeydown=e=>{let t=document.activeElement,n=t.closest(`.pkt-timepicker-popup__col`);if(!n)return;let r=Array.from(n.querySelectorAll(`.pkt-timepicker-popup__option`)),i=r.indexOf(t),a=t.dataset.type??``;switch(e.key){case`ArrowDown`:e.preventDefault(),this._focusOptionAndSync(r[Math.min(i+1,r.length-1)],a);break;case`ArrowUp`:e.preventDefault(),this._focusOptionAndSync(r[Math.max(i-1,0)],a);break;case`Home`:e.preventDefault(),this._focusOptionAndSync(r[0],a);break;case`End`:e.preventDefault(),this._focusOptionAndSync(r[r.length-1],a);break;case`ArrowRight`:e.preventDefault(),a===`hour`&&(this._focusOptionAndSync(t,a),this.updateComplete.then(()=>{this._scrollToSelected(),this._focusSelectedOrFirst(`minute`)}));break;case`ArrowLeft`:e.preventDefault(),a===`minute`&&(this._focusOptionAndSync(t,a),this.updateComplete.then(()=>{this._scrollToSelected(),this._focusSelectedOrFirst(`hour`)}));break;case`Enter`:case` `:e.preventDefault(),t.click();break;case`Escape`:e.preventDefault(),this._closePopup(),this.buttonRef.value?.focus()}}}get inputRef(){return this.hiddenInputRef}manageValidity(e){let t=this.hoursInputRef.value;if(!t)return;let r=this.pktStrings.get(`validation`);if(this.required&&!this.value){this.internals.setValidity({valueMissing:!0},r.valueMissing,t),this._setAriaInvalid(!0);return}if(!this.value){this.internals.setValidity({}),this._setAriaInvalid(!1);return}let i=l(this.value),a=u(this.step);if(this.min&&i<l(String(this.min))){this.internals.setValidity({rangeUnderflow:!0},n.t(r.rangeUnderflowMin,{min:String(this.min)}),t),this._setAriaInvalid(!0);return}if(this.max&&i>l(String(this.max))){this.internals.setValidity({rangeOverflow:!0},n.t(r.rangeOverflowMax,{max:String(this.max)}),t),this._setAriaInvalid(!0);return}if(this.step&&i%a!==0){let e=a===60?r.timeStepMismatchHour:a===30?r.timeStepMismatchHalfHour:n.t(r.timeStepMismatch,{step:`${a}, ${a*2}, ${a*3}`});this.internals.setValidity({stepMismatch:!0},e,t),this._setAriaInvalid(!0);return}this.internals.setValidity({}),this._setAriaInvalid(!1)}_describedBy(){return s.r({id:`${this.id}-hours`,hasHelptext:!!this.helptext||this.hasSlotContent(`helptext`),ariaDescribedby:this.ariaDescribedby})}_setAriaInvalid(e){if(!this.touched&&e)return;let t=this.hoursInputRef.value,n=this.minutesInputRef.value;if(e)t?.setAttribute(`aria-invalid`,`true`),n?.setAttribute(`aria-invalid`,`true`);else{if(this.hasError)return;t?.removeAttribute(`aria-invalid`),n?.removeAttribute(`aria-invalid`)}}connectedCallback(){super.connectedCallback(),this.addEventListener(`focusin`,this._handleComponentFocusIn),this.addEventListener(`focusout`,this._handleComponentFocusOut),document.addEventListener(`click`,this._outsideClickHandler)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener(`focusin`,this._handleComponentFocusIn),this.removeEventListener(`focusout`,this._handleComponentFocusOut),document.removeEventListener(`click`,this._outsideClickHandler)}willUpdate(e){super.willUpdate(e),e.has(`value`)&&this._syncDisplayFromValue()}updated(e){super.updated(e),this.classList.add(`pkt-timepicker`),this.classList.toggle(`pkt-timepicker--stepper`,this.stepArrows),this.classList.toggle(`pkt-timepicker--fullwidth`,this.fullwidth),this.classList.toggle(`pkt-timepicker--medium`,this.inputSize===`medium`),this.classList.toggle(`pkt-timepicker--small`,this.inputSize===`small`),this.classList.toggle(`pkt-timepicker--xsmall`,this.inputSize===`xsmall`),e.has(`step`)&&this.step!==null&&!this._isValidStep(this.step)&&console.warn(`pkt-timepicker: step="${this.step}" er ikke en gyldig verdi. Step må være et multiplum av 60 (hele minutter) eller nøyaktig 3600 (hel time).`)}formResetCallback(){super.formResetCallback(),this._hours=``,this._minutes=``,this._isOpen=!1}_isValidStep(e){return e===3600||e<3600&&3600%e==0&&e%60==0}_syncDisplayFromValue(){let e=c(this.value)?this.value.split(`:`):null;e?(this._hours=e[0],this._minutes=e[1]):(this._hours=``,this._minutes=``)}_syncValueFromDisplay(){if(this._hours!==``&&this._minutes!==``){let e=`${this._hours}:${this._minutes}`;e!==this.value&&(this.value=e,this.onChange(e))}else this.value!==``&&(this.value=``,this.onChange(``))}get _minuteStep(){return u(this.step)}get _hourOptions(){return d(this.min,this.max)}get _minuteOptions(){return f(this.step)}_openPopup(){this._isOpen=!0,this.updateComplete.then(()=>{this._scrollToSelected(),this._focusSelectedOrFirst(`hour`)})}_closePopup(){this._isOpen=!1,this._syncValueFromDisplay()}_togglePopup(){this._isOpen?this._closePopup():this._openPopup()}_scrollToSelected(){let e=this.querySelector(`.pkt-timepicker-popup`);e&&e.querySelectorAll(`.pkt-timepicker-popup__col`).forEach(e=>{let t=e.querySelector(`.pkt-timepicker-popup__option--selected`);t&&t.scrollIntoView({block:`center`})})}_focusSelectedOrFirst(e){let t=this.querySelector(`.pkt-timepicker-popup`);if(!t)return;let n=t.querySelectorAll(`.pkt-timepicker-popup__col`),r=e===`hour`?n[0]:n[1];if(!r)return;let i=r.querySelector(`.pkt-timepicker-popup__option--selected`),a=r.querySelector(`.pkt-timepicker-popup__option`);(i||a)?.focus()}_handleOptionClick(e,t){let n=String(e).padStart(2,`0`);t===`hour`?(this._hours=n,this.updateComplete.then(()=>this._focusSelectedOrFirst(`minute`))):(this._minutes=n,this._closePopup(),this.buttonRef.value?.focus())}_focusOptionAndSync(e,t){if(!e)return;let n=parseInt(e.dataset.value??`0`,10);t===`hour`?this._hours=String(n).padStart(2,`0`):this._minutes=String(n).padStart(2,`0`),e.focus()}_stepTime(e){let t=p(this._hours,this._minutes,e,this._minuteStep);this._hours=t.hours,this._minutes=t.minutes,this._syncValueFromDisplay()}_renderOption(n,r){let i=String(n).padStart(2,`0`),a=n===(r===`hour`?this._hours===``?NaN:parseInt(this._hours,10):this._minutes===``?NaN:parseInt(this._minutes,10));return e._`
2
2
  <button
3
3
  class=${t.t({"pkt-btn":!0,"pkt-btn--tertiary":!0,"pkt-btn--small":!0,"pkt-btn--label-only":!0,"pkt-timepicker-popup__option":!0,"pkt-timepicker-popup__option--selected":a})}
4
4
  type="button"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oslokommune/punkt-elements",
3
- "version": "19.5.2",
3
+ "version": "19.7.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": "519d9c748c2bef3bdb12d5979e115c05a2509f44"
87
+ "gitHead": "f5f319f536d0fcbd3943ed6e191d887112e3c192"
88
88
  }
@@ -679,3 +679,29 @@ describe('PktCheckbox', () => {
679
679
  })
680
680
  })
681
681
  })
682
+
683
+ describe('pkt-checkbox inputSize', () => {
684
+ const root = async (attributes = '') => {
685
+ document.body.innerHTML = `<pkt-checkbox id="s" name="s" label="Valg" ${attributes}></pkt-checkbox>`
686
+ const el = document.querySelector('pkt-checkbox') as HTMLElement & { updateComplete: Promise<unknown> }
687
+ await el.updateComplete
688
+ return el.querySelector('.pkt-input-check') as HTMLElement
689
+ }
690
+
691
+ afterEach(() => {
692
+ document.body.innerHTML = ''
693
+ })
694
+
695
+ test('adds no size class without input-size, so the size is inherited', async () => {
696
+ expect((await root()).className).toBe('pkt-input-check')
697
+ })
698
+
699
+ test('adds the size class for input-size', async () => {
700
+ expect(await root('input-size="small"')).toHaveClass('pkt-input-check--small')
701
+ expect(await root('input-size="xsmall"')).toHaveClass('pkt-input-check--xsmall')
702
+ })
703
+
704
+ test('adds the medium class when medium is set explicitly', async () => {
705
+ expect(await root('input-size="medium"')).toHaveClass('pkt-input-check--medium')
706
+ })
707
+ })
@@ -5,7 +5,7 @@ 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'
8
+ import { CHECKBOX_DEFAULTS, type TCheckboxLabelPosition, type TPktInputSize } from 'shared-types'
9
9
 
10
10
  type Props = ElementProps<
11
11
  PktCheckbox,
@@ -37,6 +37,7 @@ export class PktCheckbox extends PktInputElement<Props> {
37
37
  @property({ type: Boolean, reflect: true }) indeterminate: boolean | 'true' | 'false' | '' =
38
38
  CHECKBOX_DEFAULTS.indeterminate
39
39
  @property({ type: String, reflect: true }) type: string = 'checkbox'
40
+ @property({ type: String, attribute: 'input-size' }) inputSize: TPktInputSize | undefined = undefined
40
41
  @property({ type: String }) tagText: string | null = null
41
42
  @property({ type: Boolean }) optionalTag: boolean = CHECKBOX_DEFAULTS.optionalTag
42
43
  /** @deprecated Bruk `strings={{ forms: { optional: '…' } }}` eller `setPktStrings()`. */
@@ -156,7 +157,7 @@ export class PktCheckbox extends PktInputElement<Props> {
156
157
  }
157
158
 
158
159
  return html`
159
- <div class="pkt-input-check">
160
+ <div class="pkt-input-check${this.inputSize ? ` pkt-input-check--${this.inputSize}` : ''}">
160
161
  <div class=${inputTileClasses}>
161
162
  ${this.labelPosition === 'left' ? labelAndHelptext() : nothing}
162
163
  <input
@@ -3,9 +3,13 @@ import { Ref, createRef } from 'lit/directives/ref.js'
3
3
  import { PktInputElement } from '@/base-elements/input-element'
4
4
  import { PktOptionsSlotController } from '@/controllers/pkt-options-controller'
5
5
  import { isMaxSelectionReached } from 'shared-utils/combobox/option-utils'
6
- import specs from 'componentSpecs/combobox.json'
6
+ import { COMBOBOX_DEFAULTS } from 'shared-types/combobox'
7
7
 
8
- import type { IPktComboboxOption, TPktComboboxTagPlacement } from './combobox-types'
8
+ import type {
9
+ IPktComboboxOption,
10
+ TPktComboboxDisplayValue,
11
+ TPktComboboxTagPlacement,
12
+ } from './combobox-types'
9
13
  import type { IPktStringsProps } from 'shared-strings'
10
14
  import PktListbox from '../listbox'
11
15
  import type { TComboboxMessageKey } from 'shared-utils/combobox'
@@ -24,15 +28,17 @@ export class ComboboxBase extends PktInputElement<IPktStringsProps<'combobox' |
24
28
  @property({ type: String, reflect: true }) value: string | string[] = ''
25
29
  @property({ type: Array }) options: IPktComboboxOption[] = []
26
30
  @property({ type: Array, attribute: 'default-options' }) defaultOptions: IPktComboboxOption[] = []
27
- @property({ type: Boolean, attribute: 'allow-user-input' }) allowUserInput: boolean = false
28
- @property({ type: Boolean }) typeahead: boolean = false
29
- @property({ type: Boolean, attribute: 'include-search' }) includeSearch: boolean = false
31
+ @property({ type: Boolean, attribute: 'allow-user-input' }) allowUserInput: boolean =
32
+ COMBOBOX_DEFAULTS.allowUserInput
33
+ @property({ type: Boolean }) typeahead: boolean = COMBOBOX_DEFAULTS.typeahead
34
+ @property({ type: Boolean, attribute: 'include-search' }) includeSearch: boolean =
35
+ COMBOBOX_DEFAULTS.includeSearch
30
36
  @property({ type: String, attribute: 'search-placeholder' }) searchPlaceholder: string | null =
31
37
  null
32
- @property({ type: Boolean }) multiple: boolean = false
38
+ @property({ type: Boolean }) multiple: boolean = COMBOBOX_DEFAULTS.multiple
33
39
  @property({ type: Number }) maxlength: number | null = null
34
- @property({ type: String, attribute: 'display-value-as' }) displayValueAs: string =
35
- specs.props.displayValueAs.default
40
+ @property({ type: String, attribute: 'display-value-as' })
41
+ displayValueAs: TPktComboboxDisplayValue = COMBOBOX_DEFAULTS.displayValueAs
36
42
  @property({ type: String, attribute: 'tag-placement' })
37
43
  tagPlacement: TPktComboboxTagPlacement | null = null
38
44
  // Internal use only — syncs to _isOptionsOpen in willUpdate(), but does not
@@ -1,4 +1,4 @@
1
- import type { IPktComboboxOption, TPktComboboxDisplayValue } from './combobox-types'
1
+ import type { IPktComboboxOption } from './combobox-types'
2
2
  import {
3
3
  findOptionByValue,
4
4
  getOptionDisplayText,
@@ -87,7 +87,7 @@ export class ComboboxValue extends ComboboxBase {
87
87
  ? getSingleValueForInput(valueFromOptions || '', this.options, this.displayValueAs)
88
88
  : getOptionDisplayText(
89
89
  findOptionByValue(this.options, valueFromOptions),
90
- this.displayValueAs as TPktComboboxDisplayValue,
90
+ this.displayValueAs,
91
91
  )
92
92
  }
93
93
 
@@ -1,6 +1,6 @@
1
1
  import '@testing-library/jest-dom'
2
2
 
3
- import spec from 'componentSpecs/combobox.json'
3
+ import spec from 'componentSpecs/combobox.spec'
4
4
  import './combobox'
5
5
  import { PktCombobox } from './combobox'
6
6
 
@@ -18,6 +18,7 @@ const cases: { attribute: string; property: keyof PktCombobox; set: string; expe
18
18
  { attribute: 'display-value-as', property: 'displayValueAs', set: 'value', expect: 'value' },
19
19
  { attribute: 'search-placeholder', property: 'searchPlaceholder', set: 'x', expect: 'x' },
20
20
  { attribute: 'tag-placement', property: 'tagPlacement', set: 'outside', expect: 'outside' },
21
+ { attribute: 'aria-describedby', property: 'ariaDescribedby', set: 'x', expect: 'x' },
21
22
  { attribute: 'defaultvalue', property: 'defaultValue', set: 'x', expect: 'x' },
22
23
  { attribute: 'errormessage', property: 'errorMessage', set: 'x', expect: 'x' },
23
24
  { attribute: 'helptextdropdown', property: 'helptextDropdown', set: 'x', expect: 'x' },
@@ -71,7 +72,7 @@ describe('PktCombobox attributes', () => {
71
72
  })
72
73
 
73
74
  test('every renamed attribute in the component spec is declared', () => {
74
- const renamed = Object.entries(spec.props)
75
+ const renamed = Object.entries(spec.props ?? {})
75
76
  .filter(([name, prop]) => 'attribute' in prop && prop.attribute !== name)
76
77
  .map(([, prop]) => (prop as { attribute: string }).attribute)
77
78
  // input-size and data-testid come from the shared input wrapper, not combobox
@@ -10,6 +10,7 @@ import type {
10
10
  TPktComboboxTagPlacement,
11
11
  TPktComboboxDisplayValue,
12
12
  } from './combobox-types'
13
+ import type { IPktComboboxBase } from 'shared-types/combobox'
13
14
  import { findOptionByValue, findOptionIndex } from 'shared-utils/combobox/option-utils'
14
15
  import { getSingleValueForInput } from 'shared-utils/combobox/input-utils'
15
16
  import { slotUtils, optionStateUtils } from './combobox-utils'
@@ -29,37 +30,36 @@ import '../listbox'
29
30
  // Re-export types for backward compatibility
30
31
  export type { IPktComboboxOption, TPktComboboxTagPlacement } from './combobox-types'
31
32
 
32
- export interface IPktCombobox extends IPktStringsProps<'combobox' | 'listbox'> {
33
- allowUserInput?: boolean
34
- typeahead?: boolean
35
- disabled?: boolean
36
- displayValueAs?: string
37
- errorMessage?: string
38
- fullwidth?: boolean
39
- hasError?: boolean
33
+ export interface IPktCombobox
34
+ extends
35
+ Omit<
36
+ IPktComboboxBase,
37
+ | 'form'
38
+ | 'ariaDescribedby'
39
+ | 'label'
40
+ | 'helptext'
41
+ | 'helptextDropdown'
42
+ | 'helptextDropdownButton'
43
+ | 'placeholder'
44
+ | 'searchPlaceholder'
45
+ | 'maxlength'
46
+ | 'tagPlacement'
47
+ | 'defaultValue'
48
+ | 'useWrapper'
49
+ >,
50
+ IPktStringsProps<'combobox' | 'listbox'> {
51
+ ariaDescribedby?: string | null
52
+ label?: string | null
40
53
  helptext?: string | null
41
54
  helptextDropdown?: string | null
55
+ /** @deprecated Bruk `strings={{ forms: { readMore: '…' } }}` eller `setPktStrings()`. */
42
56
  helptextDropdownButton?: string | null
43
- id?: string
44
- includeSearch?: boolean
45
- label?: string | null
46
- maxlength?: number | null
47
- minlength?: number | null
48
- multiple?: boolean
49
- name?: string
50
- optionalTag?: boolean
51
- optionalText?: string
52
- options?: IPktComboboxOption[]
53
- defaultOptions?: IPktComboboxOption[]
54
57
  placeholder?: string | null
55
- requiredTag?: boolean
56
- requiredText?: string
57
58
  searchPlaceholder?: string | null
59
+ maxlength?: number | null
60
+ minlength?: number | null
58
61
  tagPlacement?: TPktComboboxTagPlacement | null
59
- tagText?: string | null
60
- value?: string | string[]
61
62
  defaultValue?: string | string[] | null
62
- hasFieldset?: boolean | null
63
63
  useWrapper?: Booleanish
64
64
  isOpen?: boolean
65
65
  }
@@ -72,7 +72,7 @@ export interface IPktCombobox extends IPktStringsProps<'combobox' | 'listbox'> {
72
72
  export interface IPktComboboxAttributes {
73
73
  'allow-user-input'?: boolean
74
74
  'default-options'?: IPktComboboxOption[]
75
- 'display-value-as'?: string
75
+ 'display-value-as'?: TPktComboboxDisplayValue
76
76
  'include-search'?: boolean
77
77
  'search-placeholder'?: string | null
78
78
  'tag-placement'?: TPktComboboxTagPlacement | null
@@ -574,7 +574,7 @@ export class PktCombobox extends ComboboxHandlers implements IPktCombobox {
574
574
 
575
575
  private renderValueTag(option: IPktComboboxOption | null) {
576
576
  if (!option) return ''
577
- const displayAs = this.displayValueAs as TPktComboboxDisplayValue
577
+ const displayAs = this.displayValueAs
578
578
  switch (displayAs) {
579
579
  case 'prefixAndValue':
580
580
  return html`<span class="pkt-combobox__value">${option.prefix || ''} ${option.value}</span>`