@oslokommune/punkt-elements 18.7.2 → 18.9.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 +39 -0
- package/dist/base-elements/form-attribute.test.d.ts +0 -0
- package/dist/base-elements/input-element.d.ts +3 -2
- package/dist/{checkbox-C6JdANel.js → checkbox-BhyUp6l6.js} +16 -8
- package/dist/{checkbox-CddODhna.cjs → checkbox-DJfH-vTj.cjs} +16 -8
- package/dist/combobox-B9Qo7hbt.cjs +137 -0
- package/dist/{combobox-Cqqokx73.js → combobox-fzSaCPok.js} +8 -1
- package/dist/components/fileupload/fileupload-base.d.ts +2 -0
- package/dist/{datepicker-BzRhOIkG.cjs → datepicker-D6os8IVu.cjs} +2 -2
- package/dist/{datepicker-CtSYgxMs.js → datepicker-DMiZ3BBw.js} +8 -1
- package/dist/docs/components/switch.d.ts +4 -0
- package/dist/{fileupload-PJWEBD88.js → fileupload-C5lxuood.js} +21 -4
- package/dist/{fileupload-3OtW4Xlo.cjs → fileupload-Y4bDkaD9.cjs} +8 -2
- package/dist/{header-CxfDtS3Y.js → header-CCJeadiL.js} +1 -1
- package/dist/{header-D2SD2JLt.cjs → header-CP332MCg.cjs} +1 -1
- package/dist/{input-element-Qb0w3ChW.js → input-element-BWxgs8L-.js} +27 -15
- package/dist/{input-element-DhIEFeuP.cjs → input-element-PN5nWd1A.cjs} +1 -1
- package/dist/pkt-checkbox.cjs +1 -1
- package/dist/pkt-checkbox.js +1 -1
- package/dist/pkt-combobox.cjs +1 -1
- package/dist/pkt-combobox.js +1 -1
- package/dist/pkt-datepicker.cjs +1 -1
- package/dist/pkt-datepicker.js +1 -1
- package/dist/pkt-fileupload.cjs +1 -1
- package/dist/pkt-fileupload.js +1 -1
- package/dist/pkt-header.cjs +1 -1
- package/dist/pkt-header.js +1 -1
- package/dist/pkt-index.cjs +1 -1
- package/dist/pkt-index.js +10 -10
- package/dist/pkt-radiobutton.cjs +1 -1
- package/dist/pkt-radiobutton.js +1 -1
- package/dist/pkt-select.cjs +1 -1
- package/dist/pkt-select.js +1 -1
- package/dist/pkt-textarea.cjs +1 -1
- package/dist/pkt-textarea.js +1 -1
- package/dist/pkt-textinput.cjs +1 -1
- package/dist/pkt-textinput.js +1 -1
- package/dist/pkt-timepicker.cjs +1 -1
- package/dist/pkt-timepicker.js +1 -1
- package/dist/{radiobutton-CdwYbHnx.cjs → radiobutton-CnGhAnjp.cjs} +15 -7
- package/dist/{radiobutton-B2P48MMf.js → radiobutton-DWdn1O48.js} +16 -8
- package/dist/{select-c15YAQbr.js → select-CM-CcWab.js} +1 -1
- package/dist/{select-TAwBNhhf.cjs → select-D761TXmv.cjs} +1 -1
- package/dist/shared-types/fileupload.d.ts +2 -1
- package/dist/{textarea-BHGZhMN4.cjs → textarea-4s_SiG0_.cjs} +1 -1
- package/dist/{textarea-BPQVrOp9.js → textarea-D3SeDZ1r.js} +1 -1
- package/dist/{textinput-DHGUOsIA.js → textinput-Dje0Zcsa.js} +1 -1
- package/dist/{textinput-Cv4tal5W.cjs → textinput-uDRbleIa.cjs} +1 -1
- package/dist/{timepicker-C8DHbOpM.js → timepicker--CrfIU_7.js} +1 -1
- package/dist/{timepicker-BBUYnYzM.cjs → timepicker-auQ5Y6Et.cjs} +1 -1
- package/package.json +2 -2
- package/src/components/checkbox/checkbox.test.ts +1 -1
- package/src/components/checkbox/checkbox.ts +32 -13
- package/src/components/fileupload/fileupload-base.ts +13 -2
- package/src/components/fileupload/fileupload.ts +7 -1
- package/src/components/radiobutton/radiobutton.test.ts +1 -1
- package/src/components/radiobutton/radiobutton.ts +32 -13
- package/dist/combobox-N3NP77le.cjs +0 -137
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-D_mCyFeX.cjs"),t=require("./if-defined-BbUZeoaQ.cjs"),n=require("./element-with-slot-C66Jck5e.cjs"),r=require("./ref-AuNEkS5a.cjs"),i=require("./input-element-
|
|
1
|
+
const e=require("./element-D_mCyFeX.cjs"),t=require("./if-defined-BbUZeoaQ.cjs"),n=require("./element-with-slot-C66Jck5e.cjs"),r=require("./ref-AuNEkS5a.cjs"),i=require("./input-element-PN5nWd1A.cjs"),a=require("./pkt-options-controller-DXAAVcBJ.cjs"),o=require("./input-wrapper-D64Qn-QH.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
|
.strings=${this.strings}
|
|
4
4
|
.size=${this.inputSize}
|
|
@@ -61,6 +61,7 @@ export interface IFilesChangedDetail {
|
|
|
61
61
|
export interface IPktFileUploadBase extends IFormFieldCommonProps<'forms' | 'fileupload'> {
|
|
62
62
|
/** Field name. Used for native input (`form`) or hidden ID inputs (`custom`). */
|
|
63
63
|
name: string;
|
|
64
|
+
form?: string;
|
|
64
65
|
required?: boolean;
|
|
65
66
|
value?: IFileItem[];
|
|
66
67
|
defaultValue?: IFileItem[];
|
|
@@ -93,7 +94,7 @@ export interface IPktFileUploadBase extends IFormFieldCommonProps<'forms' | 'fil
|
|
|
93
94
|
truncateTail?: number;
|
|
94
95
|
}
|
|
95
96
|
/** Documented props for typed component specs — subset of base + docs-only demo props. */
|
|
96
|
-
export type IFileUploadSpecProps = Pick<IPktFileUploadBase, TFormFieldCommonSpecKeys | 'name' | 'required' | 'value' | 'defaultValue' | 'onFilesChanged' | 'uploadStrategy' | 'multiple' | 'itemRenderer' | 'allowedFormats' | 'formatErrorMessage' | 'maxFileSize' | 'onFileValidation' | 'onFileValidate' | 'sizeErrorMessage' | 'addCommentsEnabled' | 'enableImagePreview' | 'extraOperations' | 'fullwidth' | 'onFileUploadRequested' | 'onTransferCancelled' | 'renameFilesEnabled' | 'transfers' | 'truncateTail'> & {
|
|
97
|
+
export type IFileUploadSpecProps = Pick<IPktFileUploadBase, TFormFieldCommonSpecKeys | 'name' | 'form' | 'required' | 'value' | 'defaultValue' | 'onFilesChanged' | 'uploadStrategy' | 'multiple' | 'itemRenderer' | 'allowedFormats' | 'formatErrorMessage' | 'maxFileSize' | 'onFileValidation' | 'onFileValidate' | 'sizeErrorMessage' | 'addCommentsEnabled' | 'enableImagePreview' | 'extraOperations' | 'fullwidth' | 'onFileUploadRequested' | 'onTransferCancelled' | 'renameFilesEnabled' | 'transfers' | 'truncateTail'> & {
|
|
97
98
|
previewUploadIntervalMs?: number;
|
|
98
99
|
previewSimulateUploadError?: boolean;
|
|
99
100
|
previewUploadStatus?: TPreviewUploadStatus;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-D_mCyFeX.cjs"),t=require("./class-map-DupQbnhE.cjs"),n=require("./if-defined-BbUZeoaQ.cjs"),r=require("./directive-helpers-2mcpDDv5.cjs"),i=require("./element-with-slot-C66Jck5e.cjs");require("./icon-BzxBkRyE.cjs");const a=require("./ref-AuNEkS5a.cjs"),o=require("./input-element-
|
|
1
|
+
const e=require("./element-D_mCyFeX.cjs"),t=require("./class-map-DupQbnhE.cjs"),n=require("./if-defined-BbUZeoaQ.cjs"),r=require("./directive-helpers-2mcpDDv5.cjs"),i=require("./element-with-slot-C66Jck5e.cjs");require("./icon-BzxBkRyE.cjs");const a=require("./ref-AuNEkS5a.cjs"),o=require("./input-element-PN5nWd1A.cjs"),s=require("./input-wrapper-D64Qn-QH.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(!r.i(t))throw Error("`live` bindings can only contain a single expression")}render(e){return e}update(t,[n]){if(n===e.g||n===e.h)return n;let i=t.element,a=t.name;if(t.type===e.m.PROPERTY){if(n===i[a])return e.g}else if(t.type===e.m.BOOLEAN_ATTRIBUTE){if(!!n===i.hasAttribute(a))return e.g}else if(t.type===e.m.ATTRIBUTE&&i.getAttribute(a)===n+``)return e.g;return r.r(t),n}}),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 r=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":r&&this.counterMaxLength>0&&this.value.length>this.counterMaxLength}),l=this.ariaLabelledby||`${this.id}-input-label`;return e._`<pkt-input-wrapper
|
|
2
2
|
.strings=${this.strings}
|
|
3
3
|
label=${this.label}
|
|
4
4
|
?counter=${r}
|
|
@@ -5,7 +5,7 @@ import { i as f, r as p } from "./directive-helpers-ChEduoup.js";
|
|
|
5
5
|
import { r as m } from "./element-with-slot-BOuXlWSY.js";
|
|
6
6
|
import "./icon-DkVqRWbC.js";
|
|
7
7
|
import { n as h, t as g } from "./ref-DNowxdYH.js";
|
|
8
|
-
import { t as _ } from "./input-element-
|
|
8
|
+
import { t as _ } from "./input-element-BWxgs8L-.js";
|
|
9
9
|
import { r as v } from "./input-wrapper-Bg06k-cj.js";
|
|
10
10
|
//#region ../../node_modules/lit-html/directives/live.js
|
|
11
11
|
var y = n(class extends c {
|
|
@@ -4,7 +4,7 @@ import { t as s } from "./if-defined-BILLSM7i.js";
|
|
|
4
4
|
import { r as c } from "./element-with-slot-BOuXlWSY.js";
|
|
5
5
|
import "./icon-DkVqRWbC.js";
|
|
6
6
|
import { n as l, t as u } from "./ref-DNowxdYH.js";
|
|
7
|
-
import { t as d } from "./input-element-
|
|
7
|
+
import { t as d } from "./input-element-BWxgs8L-.js";
|
|
8
8
|
import { r as f } from "./input-wrapper-Bg06k-cj.js";
|
|
9
9
|
//#region src/components/textinput/textinput.ts
|
|
10
10
|
var p = class extends d {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-D_mCyFeX.cjs"),t=require("./class-map-DupQbnhE.cjs"),n=require("./if-defined-BbUZeoaQ.cjs"),r=require("./element-with-slot-C66Jck5e.cjs");require("./icon-BzxBkRyE.cjs");const i=require("./ref-AuNEkS5a.cjs"),a=require("./input-element-
|
|
1
|
+
const e=require("./element-D_mCyFeX.cjs"),t=require("./class-map-DupQbnhE.cjs"),n=require("./if-defined-BbUZeoaQ.cjs"),r=require("./element-with-slot-C66Jck5e.cjs");require("./icon-BzxBkRyE.cjs");const i=require("./ref-AuNEkS5a.cjs"),a=require("./input-element-PN5nWd1A.cjs"),o=require("./input-wrapper-D64Qn-QH.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
|
.strings=${this.strings}
|
|
4
4
|
label="${this.label}"
|
|
@@ -5,7 +5,7 @@ import { t as c } from "./format-BTeSVkED.js";
|
|
|
5
5
|
import { r as l } from "./element-with-slot-BOuXlWSY.js";
|
|
6
6
|
import "./icon-DkVqRWbC.js";
|
|
7
7
|
import { n as u, t as d } from "./ref-DNowxdYH.js";
|
|
8
|
-
import { t as f } from "./input-element-
|
|
8
|
+
import { t as f } from "./input-element-BWxgs8L-.js";
|
|
9
9
|
import "./input-wrapper-Bg06k-cj.js";
|
|
10
10
|
//#region ../../shared-utils/timepicker/time-utils.ts
|
|
11
11
|
var p = (e) => /^\d{2}:\d{2}$/.test(e) && parseInt(e.slice(0, 2), 10) <= 23 && parseInt(e.slice(3), 10) <= 59, m = (e) => {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const e=require("./element-D_mCyFeX.cjs"),t=require("./class-map-DupQbnhE.cjs"),n=require("./if-defined-BbUZeoaQ.cjs"),r=require("./format-B8meU8Tm.cjs"),i=require("./element-with-slot-C66Jck5e.cjs");require("./icon-BzxBkRyE.cjs");const a=require("./ref-AuNEkS5a.cjs"),o=require("./input-element-DhIEFeuP.cjs");require("./input-wrapper-D64Qn-QH.cjs");var s=e=>/^\d{2}:\d{2}$/.test(e)&&parseInt(e.slice(0,2),10)<=23&&parseInt(e.slice(3),10)<=59,c=e=>{let[t,n]=e.split(`:`).map(Number);return t*60+n},l=e=>e?Math.max(1,Math.round(e/60)):1,u=(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)},d=e=>{let t=l(e);return Array.from({length:Math.floor(60/t)},(e,n)=>n*t)},f=(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`)}},p=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 n=this.pktStrings.get(`validation`);if(this.required&&!this.value){this.internals.setValidity({valueMissing:!0},n.valueMissing,t),this._setAriaInvalid(!0);return}if(!this.value){this.internals.setValidity({}),this._setAriaInvalid(!1);return}let i=c(this.value),a=l(this.step);if(this.min&&i<c(String(this.min))){this.internals.setValidity({rangeUnderflow:!0},r.t(n.rangeUnderflowMin,{min:String(this.min)}),t),this._setAriaInvalid(!0);return}if(this.max&&i>c(String(this.max))){this.internals.setValidity({rangeOverflow:!0},r.t(n.rangeOverflowMax,{max:String(this.max)}),t),this._setAriaInvalid(!0);return}if(this.step&&i%a!==0){let e=a===60?n.timeStepMismatchHour:a===30?n.timeStepMismatchHalfHour:r.t(n.timeStepMismatch,{step:`${a}, ${a*2}, ${a*3}`});this.internals.setValidity({stepMismatch:!0},e,t),this._setAriaInvalid(!0);return}this.internals.setValidity({}),this._setAriaInvalid(!1)}_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=s(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 l(this.step)}get _hourOptions(){return u(this.min,this.max)}get _minuteOptions(){return d(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=f(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-D_mCyFeX.cjs"),t=require("./class-map-DupQbnhE.cjs"),n=require("./if-defined-BbUZeoaQ.cjs"),r=require("./format-B8meU8Tm.cjs"),i=require("./element-with-slot-C66Jck5e.cjs");require("./icon-BzxBkRyE.cjs");const a=require("./ref-AuNEkS5a.cjs"),o=require("./input-element-PN5nWd1A.cjs");require("./input-wrapper-D64Qn-QH.cjs");var s=e=>/^\d{2}:\d{2}$/.test(e)&&parseInt(e.slice(0,2),10)<=23&&parseInt(e.slice(3),10)<=59,c=e=>{let[t,n]=e.split(`:`).map(Number);return t*60+n},l=e=>e?Math.max(1,Math.round(e/60)):1,u=(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)},d=e=>{let t=l(e);return Array.from({length:Math.floor(60/t)},(e,n)=>n*t)},f=(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`)}},p=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 n=this.pktStrings.get(`validation`);if(this.required&&!this.value){this.internals.setValidity({valueMissing:!0},n.valueMissing,t),this._setAriaInvalid(!0);return}if(!this.value){this.internals.setValidity({}),this._setAriaInvalid(!1);return}let i=c(this.value),a=l(this.step);if(this.min&&i<c(String(this.min))){this.internals.setValidity({rangeUnderflow:!0},r.t(n.rangeUnderflowMin,{min:String(this.min)}),t),this._setAriaInvalid(!0);return}if(this.max&&i>c(String(this.max))){this.internals.setValidity({rangeOverflow:!0},r.t(n.rangeOverflowMax,{max:String(this.max)}),t),this._setAriaInvalid(!0);return}if(this.step&&i%a!==0){let e=a===60?n.timeStepMismatchHour:a===30?n.timeStepMismatchHalfHour:r.t(n.timeStepMismatch,{step:`${a}, ${a*2}, ${a*3}`});this.internals.setValidity({stepMismatch:!0},e,t),this._setAriaInvalid(!0);return}this.internals.setValidity({}),this._setAriaInvalid(!1)}_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=s(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 l(this.step)}get _hourOptions(){return u(this.min,this.max)}get _minuteOptions(){return d(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=f(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": "18.
|
|
3
|
+
"version": "18.9.0",
|
|
4
4
|
"description": "Komponentbiblioteket til Punkt, et designsystem laget av Oslo Origo",
|
|
5
5
|
"homepage": "https://punkt.oslo.kommune.no",
|
|
6
6
|
"author": "Team Designsystem, Oslo Origo",
|
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
"engines": {
|
|
84
84
|
"node": "^22.19.0 || ^24.0.0 || ^26.0.0"
|
|
85
85
|
},
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "a8576c656211eb84b7689fc0b9795e3f10d8e1c8"
|
|
87
87
|
}
|
|
@@ -363,7 +363,7 @@ describe('PktCheckbox', () => {
|
|
|
363
363
|
|
|
364
364
|
const helptext = checkbox.querySelector('.pkt-input-check__input-helptext')
|
|
365
365
|
expect(helptext).toBeInTheDocument()
|
|
366
|
-
expect(helptext?.textContent).toBe('This is help text')
|
|
366
|
+
expect(helptext?.textContent?.trim()).toBe('This is help text')
|
|
367
367
|
})
|
|
368
368
|
|
|
369
369
|
test('does not render helptext when not provided', async () => {
|
|
@@ -115,25 +115,42 @@ export class PktCheckbox extends PktInputElement<Props> {
|
|
|
115
115
|
|
|
116
116
|
const tags = () => {
|
|
117
117
|
return html`
|
|
118
|
-
${
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
118
|
+
${
|
|
119
|
+
this.tagText
|
|
120
|
+
? html`<span class=${tagClasses + ' pkt-tag--gray'}>${this.tagText}</span>`
|
|
121
|
+
: nothing
|
|
122
|
+
}
|
|
123
|
+
${
|
|
124
|
+
this.optionalTag
|
|
125
|
+
? html`<span class=${tagClasses + ' pkt-tag--blue-light'}
|
|
126
|
+
>${this.optionalText ?? formStrings.optional}</span
|
|
127
|
+
>`
|
|
128
|
+
: nothing
|
|
129
|
+
}
|
|
130
|
+
${
|
|
131
|
+
this.requiredTag
|
|
132
|
+
? html`<span class=${tagClasses + ' pkt-tag--beige'}
|
|
133
|
+
>${this.requiredText ?? formStrings.required}</span
|
|
134
|
+
>`
|
|
135
|
+
: nothing
|
|
136
|
+
}
|
|
127
137
|
`
|
|
128
138
|
}
|
|
129
139
|
|
|
140
|
+
const labelId = this.id + '-check-label'
|
|
141
|
+
const helptextId = this.id + '-check-helptext'
|
|
142
|
+
|
|
130
143
|
const labelAndHelptext = () => {
|
|
131
144
|
return html`
|
|
132
145
|
<label class=${labelClasses} for=${this.id + '-internal'}>
|
|
133
|
-
|
|
134
|
-
${
|
|
135
|
-
|
|
136
|
-
|
|
146
|
+
<span id=${labelId}>${this.label} ${tags()}</span>
|
|
147
|
+
${
|
|
148
|
+
this.checkHelptext
|
|
149
|
+
? html`<div id=${helptextId} class="pkt-input-check__input-helptext">
|
|
150
|
+
${this.checkHelptext}
|
|
151
|
+
</div>`
|
|
152
|
+
: nothing
|
|
153
|
+
}
|
|
137
154
|
</label>
|
|
138
155
|
`
|
|
139
156
|
}
|
|
@@ -156,6 +173,8 @@ export class PktCheckbox extends PktInputElement<Props> {
|
|
|
156
173
|
@focus=${this.onFocus}
|
|
157
174
|
?checked=${this.checked}
|
|
158
175
|
role=${this.isSwitch ? 'switch' : 'checkbox'}
|
|
176
|
+
aria-labelledby=${this.label ? labelId : nothing}
|
|
177
|
+
aria-describedby=${this.checkHelptext ? helptextId : nothing}
|
|
159
178
|
/>
|
|
160
179
|
${this.labelPosition === 'right' ? labelAndHelptext() : nothing}
|
|
161
180
|
</div>
|
|
@@ -37,6 +37,7 @@ export abstract class PktFileUploadBase
|
|
|
37
37
|
@property({ type: String }) id: string = `pkt-fileupload-${uuidish()}`
|
|
38
38
|
/** Field name used by native input (`form`) or hidden fileId inputs (`custom`). */
|
|
39
39
|
@property({ type: String }) name: string = 'files'
|
|
40
|
+
@property({ type: String, reflect: true }) form?: string
|
|
40
41
|
/** Optional label shown by `pkt-input-wrapper`. */
|
|
41
42
|
@property({ type: String }) label: string = ''
|
|
42
43
|
/** Optional help text shown under label. */
|
|
@@ -175,7 +176,8 @@ export abstract class PktFileUploadBase
|
|
|
175
176
|
if (
|
|
176
177
|
changedProperties.has('uploadStrategy') ||
|
|
177
178
|
changedProperties.has('required') ||
|
|
178
|
-
changedProperties.has('value')
|
|
179
|
+
changedProperties.has('value') ||
|
|
180
|
+
changedProperties.has('form')
|
|
179
181
|
) {
|
|
180
182
|
this.syncFormSubmitListener()
|
|
181
183
|
}
|
|
@@ -554,8 +556,17 @@ export abstract class PktFileUploadBase
|
|
|
554
556
|
})
|
|
555
557
|
}
|
|
556
558
|
|
|
559
|
+
protected get ownerForm(): HTMLFormElement | null {
|
|
560
|
+
if (this.form !== undefined) {
|
|
561
|
+
if (!this.form) return null
|
|
562
|
+
const owner = this.ownerDocument?.getElementById(this.form)
|
|
563
|
+
return owner instanceof HTMLFormElement ? owner : null
|
|
564
|
+
}
|
|
565
|
+
return this.closest('form')
|
|
566
|
+
}
|
|
567
|
+
|
|
557
568
|
private syncFormSubmitListener() {
|
|
558
|
-
const nextForm = this.
|
|
569
|
+
const nextForm = this.ownerForm
|
|
559
570
|
if (this.connectedForm === nextForm) return
|
|
560
571
|
|
|
561
572
|
this.teardownFormSubmitListener()
|
|
@@ -157,6 +157,7 @@ export class PktFileUpload extends PktFileUploadBase implements IPktFileUpload {
|
|
|
157
157
|
id=${`${this.id}-input`}
|
|
158
158
|
type="file"
|
|
159
159
|
name=${ifDefined(this.uploadStrategy === 'form' ? this.name : undefined)}
|
|
160
|
+
form=${ifDefined(this.form)}
|
|
160
161
|
?multiple=${this.multiple}
|
|
161
162
|
?disabled=${this.disabled}
|
|
162
163
|
?required=${this.required && this.uploadStrategy === 'form'}
|
|
@@ -172,7 +173,12 @@ export class PktFileUpload extends PktFileUploadBase implements IPktFileUpload {
|
|
|
172
173
|
${this.uploadStrategy === 'custom'
|
|
173
174
|
? filesAndTransfers.map(
|
|
174
175
|
(fileItem) =>
|
|
175
|
-
html`<input
|
|
176
|
+
html`<input
|
|
177
|
+
type="hidden"
|
|
178
|
+
name=${this.name}
|
|
179
|
+
value=${fileItem.fileId}
|
|
180
|
+
form=${ifDefined(this.form)}
|
|
181
|
+
/>`,
|
|
176
182
|
)
|
|
177
183
|
: null}
|
|
178
184
|
<div class="pkt-fileupload__drop-zone__placeholder">
|
|
@@ -159,7 +159,7 @@ describe('pkt-radiobutton', () => {
|
|
|
159
159
|
|
|
160
160
|
const helptext = radiobutton.querySelector('.pkt-input-check__input-helptext')
|
|
161
161
|
expect(helptext).toBeInTheDocument()
|
|
162
|
-
expect(helptext?.textContent).toBe('This is helpful information')
|
|
162
|
+
expect(helptext?.textContent?.trim()).toBe('This is helpful information')
|
|
163
163
|
})
|
|
164
164
|
|
|
165
165
|
test('handles error state correctly', async () => {
|
|
@@ -75,25 +75,42 @@ export class PktRadioButton extends PktInputElement<Props> {
|
|
|
75
75
|
|
|
76
76
|
const tags = () => {
|
|
77
77
|
return html`
|
|
78
|
-
${
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
78
|
+
${
|
|
79
|
+
this.tagText
|
|
80
|
+
? html`<span class=${tagClasses + ' pkt-tag--gray'}>${this.tagText}</span>`
|
|
81
|
+
: nothing
|
|
82
|
+
}
|
|
83
|
+
${
|
|
84
|
+
this.optionalTag
|
|
85
|
+
? html`<span class=${tagClasses + ' pkt-tag--blue-light'}
|
|
86
|
+
>${this.optionalText ?? formStrings.optional}</span
|
|
87
|
+
>`
|
|
88
|
+
: nothing
|
|
89
|
+
}
|
|
90
|
+
${
|
|
91
|
+
this.requiredTag
|
|
92
|
+
? html`<span class=${tagClasses + ' pkt-tag--beige'}
|
|
93
|
+
>${this.requiredText ?? formStrings.required}</span
|
|
94
|
+
>`
|
|
95
|
+
: nothing
|
|
96
|
+
}
|
|
87
97
|
`
|
|
88
98
|
}
|
|
89
99
|
|
|
100
|
+
const labelId = this.id + '-check-label'
|
|
101
|
+
const helptextId = this.id + '-check-helptext'
|
|
102
|
+
|
|
90
103
|
const labelAndHelptext = () => {
|
|
91
104
|
return html`
|
|
92
105
|
<label class=${labelClasses} for=${this.id + '-internal'}>
|
|
93
|
-
|
|
94
|
-
${
|
|
95
|
-
|
|
96
|
-
|
|
106
|
+
<span id=${labelId}>${this.label} ${tags()}</span>
|
|
107
|
+
${
|
|
108
|
+
this.checkHelptext
|
|
109
|
+
? html`<div id=${helptextId} class="pkt-input-check__input-helptext">
|
|
110
|
+
${this.checkHelptext}
|
|
111
|
+
</div>`
|
|
112
|
+
: nothing
|
|
113
|
+
}
|
|
97
114
|
</label>
|
|
98
115
|
`
|
|
99
116
|
}
|
|
@@ -114,6 +131,8 @@ export class PktRadioButton extends PktInputElement<Props> {
|
|
|
114
131
|
@blur=${this.onBlur}
|
|
115
132
|
@focus=${this.onFocus}
|
|
116
133
|
?checked=${this.checked}
|
|
134
|
+
aria-labelledby=${this.label ? labelId : nothing}
|
|
135
|
+
aria-describedby=${this.checkHelptext ? helptextId : nothing}
|
|
117
136
|
/>
|
|
118
137
|
${labelAndHelptext()}
|
|
119
138
|
</div>
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
const e=require("./element-D_mCyFeX.cjs"),t=require("./class-map-DupQbnhE.cjs"),n=require("./if-defined-BbUZeoaQ.cjs"),r=require("./format-B8meU8Tm.cjs"),i=require("./element-with-slot-C66Jck5e.cjs");require("./icon-BzxBkRyE.cjs");const a=require("./ref-AuNEkS5a.cjs");require("./tag-CGlxtBOH.cjs");const o=require("./repeat-B3ksuY2F.cjs"),s=require("./listbox-kV4OO1Qa.cjs"),c=require("./input-element-DhIEFeuP.cjs"),l=require("./pkt-options-controller-DXAAVcBJ.cjs");require("./input-wrapper-D64Qn-QH.cjs");var u=(e,t,n)=>{switch(e){case`,`:return n?`addValue`:null;case`Enter`:return`addValue`;case`Tab`:case`ArrowDown`:return t?null:`focusListbox`;case`Escape`:return`closeOptions`;default:return null}},d=(e,t,n,r,i)=>{if(!e)return{action:`none`,value:null};let a=s.i(n,e);return!t.includes(e)&&!a?r?{action:`addUserValue`,value:e}:i?{action:`none`,value:null}:{action:`removeValue`,value:t[0]}:a&&!t.includes(a.value)?{action:`selectOption`,value:a.value}:{action:`none`,value:null}},f=(e,t,n,r,i)=>e.trim().toLowerCase()?{...s.c(e,t,n,r),shouldRemoveValue:!1,shouldResetInput:!1}:{addValueText:null,userInfoMessage:``,shouldRemoveValue:!i&&!!t[0],shouldResetInput:!0},p=(e,t,n)=>{let r=s.i(t,e);return n===`label`&&r?.label?r.label:e},m={markOptionSelected(e,t){if(t){for(let n of e)if(n.value===t){n.selected=!0;break}}},markOptionDeselected(e,t){if(t){for(let n of e)if(n.value===t){n.selected=!1;break}}},markAllSelected(e){for(let t of e)t.selected=!0},markAllDeselected(e){for(let t of e)t.selected=!1},removeUserAddedOptions(e){return e.filter(e=>!e.userAdded)}},h={parseOptionsFromSlot(e){let t=[];return e.forEach(e=>{if(!e.textContent&&!e.getAttribute(`value`))return;let n={value:e.getAttribute(`value`)||e.textContent||``,label:e.textContent||e.getAttribute(`value`)||``};e.getAttribute(`data-prefix`)&&(n.prefix=e.getAttribute(`data-prefix`)||void 0),e.getAttribute(`tagskincolor`)&&(n.tagSkinColor=e.getAttribute(`tagskincolor`)),e.getAttribute(`description`)&&(n.description=e.getAttribute(`description`)||void 0),n.fulltext=s.r(n),t.push(n)}),t}},g={cloneOptions(e){return Array.isArray(e)?e.map(e=>({...e})):[]},syncOptionsWithValues(e,t){let n=[...t];return e.forEach(e=>{e.value&&!e.label&&(e.label=e.value),e.selected&&!n.includes(e.value)&&n.push(e.value),e.fulltext=s.r(e),e.selected=e.selected||n.includes(e.value)}),{options:e,newValues:n}},mergeWithUserAdded(e,t,n){return[...t.filter(e=>e?.userAdded&&n.includes(e.value)).filter(t=>!(Array.isArray(e)?e:[]).some(e=>e.value===t.value)),...e]}},_={name:`pkt-combobox`,react:`PktCombobox`,"css-class":`pkt-combobox`,isElement:!0,isPureReact:!0,props:{name:{type:`string`,name:`Navn`,description:`Navn som brukes i skjema ved innsending`,category:`tech`},id:{type:`string`,name:`ID`,description:`Unik ID for feltet`,category:`tech`},label:{type:`string`,name:`Etikett/label`,description:`Tekst som vises over feltet`,category:`contents`},placeholder:{name:`Hint`,description:`Spesifiserer en kort hint som beskriver forventet verdi av feltet.`,type:`string`,category:`contents`,required:!1},multiple:{type:`boolean`,name:`Flervalg`,default:!1,description:`Mulighet for å velge flere valg`,category:`functionality`},tagPlacement:{attribute:`tag-placement`,type:[`inside`,`outside`],name:`Plassering av tags i flervalg`,description:`Plassering av valgte verdier i feltet ved flervalg`,category:`functionality`,showIf:{multiple:!0}},maxlength:{type:`number`,name:`Maks antall i flervalg`,description:`Maks antall valg dersom flervalg er aktivert`,category:`functionality`,showIf:{multiple:!0}},typeahead:{type:`boolean`,name:`Typeahead`,default:!1,description:`Mulighet for automatisk utfylling av feltet fra listen over valg`,category:`functionality`},includeSearch:{attribute:`include-search`,type:`boolean`,name:`Inkluder søk`,description:`Mulighet for å søke etter valg inni dropdown`,category:`functionality`},allowUserInput:{attribute:`allow-user-input`,type:`boolean`,name:`Brukervalgte verdier`,description:`Mulighet for å skrive inn egne verdier`,category:`functionality`},searchPlaceholder:{attribute:`search-placeholder`,type:`string`,name:`Søke-plassholder`,description:`Plassholdertekst for søkefeltet i dropdown`,category:`contents`,showIf:{includeSearch:!0}},displayValueAs:{attribute:`display-value-as`,type:[`label`,`value`,`prefixAndValue`],name:`Visning av valgt verdi`,description:`Hvordan valgt verdi vises i feltet`,default:`label`,category:`ui`},inputSize:{name:`Størrelse`,description:`Visuell størrelse via input-wrapper. small: kompakt wrapper og felt (42px). xsmall: samme wrapper som small, felt 36px.`,attribute:`input-size`,type:[`small`,`medium`,`xsmall`],default:`medium`,category:`ui`},value:{name:`Verdi`,type:`string`,description:`Valgt verdi. Streng ved enkelt valg, array av strenger ved flervalg.`,category:`tech`},helptext:{type:`string`,name:`Hjelpetekst`,description:`Hjelpetekst som vises over feltet`,category:`contents`},helptextDropdown:{attribute:`helptextdropdown`,type:`string`,name:`Utvidet hjelpetekst`,description:`Hjelpetekst som vises i en lukket boks man kan åpne`,category:`contents`},helptextDropdownButton:{attribute:`helptextdropdownbutton`,type:`string`,name:`Knappetekst for hjelpetekst`,description:`Tekst som vises på knappen for å åpne/lukke utvidet hjelpetekst`,category:`contents`,default:`Les mer`},disabled:{type:`boolean`,name:`Deaktivert`,description:`Feltet er deaktivert`,category:`tech`},hasError:{attribute:`haserror`,type:`boolean`,name:`Feil`,description:`Feltet har en feil`,category:`ui`},errorMessage:{attribute:`errormessage`,type:`string`,name:`Feilmelding`,description:`Tekst som vises under feltet ved feil`,category:`contents`},required:{type:`boolean`,name:`Påkrevd`,description:`Feltet må fylles ut`,category:`tech`},requiredTag:{attribute:`requiredtag`,type:`boolean`,name:`Påkrevd-merking`,description:`Viser en merking som indikerer at feltet er påkrevd`,category:`ui`},requiredText:{attribute:`requiredtext`,type:`string`,name:`Påkrevd-tekst`,description:`Tekst som vises i påkrevd-merkingen`,category:`contents`},optionalTag:{attribute:`optionaltag`,type:`boolean`,name:`Valgfritt-merking`,description:`Viser en merking som indikerer at feltet er valgfritt`,category:`ui`},optionalText:{attribute:`optionaltext`,type:`string`,name:`Valgfritt-tekst`,description:`Tekst som vises i valgfritt-merkingen`,category:`contents`},tagText:{attribute:`tagtext`,type:`string`,name:`Tag-tekst`,description:`Tekst som vises i en tag ved siden av label`,category:`ui`},fullwidth:{type:`boolean`,name:`Full bredde`,description:`Skal feltet ta opp hele bredden?`,category:`ui`},defaultOptions:{attribute:`default-options`,name:`Initielle valg (default options)`,description:`Liste over valg som kan velges, om options sendes inn som array med objekter (denne vil ikke modifiseres ved endring innad i komponenten)`,type:`array`,default:[],previewDefault:[{value:`bfr`,label:`Frogner`},{value:`bgo`,label:`Gamle Oslo`},{value:`bgr`,label:`Grorud`},{value:`bxx`,label:`Andre bydeler`}],items:{type:`object`,properties:{value:{type:`string`,description:`Verdi som sendes ved valg`},label:{type:`string`,description:`Tekst som vises for valget`},prefix:{type:`string`,description:`Tekst som vises før valget`},description:{type:`string`,description:`Beskrivelse av valget`},disabled:{type:`boolean`,description:`Valget er deaktivert`},selected:{type:`boolean`,description:`Valget er valgt`},tagSkinColor:{type:[`blue`,`blue-dark`,`blue-light`,`green`,`red`,`yellow`,`beige`,`gray`,`grey`],description:`Farge på tag`}},required:[`value`]},category:`contents`},options:{name:`Valg`,type:`array`,description:`Liste over valg som kan velges, om options sendes inn som array med objekter`,default:[],items:{type:`object`,properties:{value:{type:`string`,description:`Verdi som sendes ved valg`},label:{type:`string`,description:`Tekst som vises for valget`},prefix:{type:`string`,description:`Tekst som vises før valget`},description:{type:`string`,description:`Beskrivelse av valget`},disabled:{type:`boolean`,description:`Valget er deaktivert`},selected:{type:`boolean`,description:`Valget er valgt`},tagSkinColor:{type:[`blue`,`blue-dark`,`blue-light`,`green`,`red`,`yellow`,`beige`,`gray`,`grey`],description:`Farge på tag`}},required:[`value`]},category:`contents`},inline:{name:`Inline`,type:`boolean`,required:!1,default:!1,description:`Angir om feltet skal flyte med teksten`,category:`ui`},useWrapper:{attribute:`usewrapper`,name:`Bruk wrapper`,type:`boolean`,required:!1,displayAsFalse:!0,default:!0,description:`Indikerer om skjemaelementet skal bruke en wrapper`,category:`ui`},hasFieldset:{attribute:`hasfieldset`,name:`Bruk fieldset`,type:`boolean`,required:!1,default:null,description:`Bruk fieldset og legend i stedet for label. Utledes automatisk når feltet ikke har en input.`,category:`ui`},counter:{name:`Teller`,type:`boolean`,required:!1,default:null,description:`Viser teller under feltet. Slås på av seg selv når det finnes en grense å telle mot; sett til false for å skru den av.`,category:`ui`},defaultValue:{attribute:`defaultvalue`,type:`string | string[]`,name:`Standardverdi`,description:`Verdien feltet får ved oppstart og ved nullstilling av skjemaet`,category:`functionality`}},events:{change:{type:`Event`,description:`Returnerer valgt verdi som streng. Ved flervalg returneres kommaseparerte verdier.`},"value-change":{type:`CustomEvent`,description:`Returnerer valgt verdi. Ved enkeltvalg en streng, ved flervalg en <code>string[]</code>.`},search:{type:`CustomEvent`,description:`Returnerer søketeksten som streng i <code>event.detail</code> når brukeren skriver i søkefeltet`},toggleHelpText:{type:`CustomEvent`,description:`Returnerer <code>event.detail { isOpen: true }</code> eller <code>event.detail { isOpen: false }</code> når hjelpeteksten åpnes eller lukkes`}}},v=class extends c.t{constructor(){super(),this.value=``,this.options=[],this.defaultOptions=[],this.allowUserInput=!1,this.typeahead=!1,this.includeSearch=!1,this.searchPlaceholder=null,this.multiple=!1,this.maxlength=null,this.displayValueAs=_.props.displayValueAs.default,this.tagPlacement=null,this.isOpen=!1,this._options=[],this._value=[],this._isOptionsOpen=!1,this._userInfoMessage=``,this._messageValue=null,this._addValueText=null,this._maxIsReached=!1,this._search=``,this._inputFocus=!1,this._skipInputTab=!1,this._optionsFromSlot=!1,this._lastSlotGeneration=0,this._suppressNextOpen=!1,this.inputRef=a.t(),this.triggerRef=a.t(),this.listboxRef=a.t(),this._pendingDispatchFrom=null,this.optionsController=new l.t(this)}get _hasTextInput(){return this.typeahead||this.allowUserInput}get _selectionDescription(){if(!(!this.multiple||this._value.length===0))return`${this._value.length} valgt`}focusTrigger(){this._hasTextInput?this.inputRef.value?.focus():this.triggerRef.value?.focus()}focusAfterCommit(){this._skipInputTab=!0;let e=this.inputRef.value;e&&e.type!==`hidden`&&e.setAttribute(`tabindex`,`-1`),this.triggerRef.value?.focus()}restoreInputTab(){this._skipInputTab=!1}parseValue(){return this.parseToValues(this.value)}parseToValues(e){return Array.isArray(e)?this.multiple?e:e.length>0?[e[0]]:[]:e&&this.multiple?e.split(`,`):e?[e]:[]}updateMaxReached(){this._maxIsReached=s.l(this._value.length,this.maxlength)}syncPublicValue(){let e=this.multiple?this._value.join(`,`):this._value[0]||``;e!==(Array.isArray(this.value)?this.value.join(`,`):String(this.value||``))&&(this.value=e)}dispatchValueChange(e){let t=this._value;if(e?.join(`,`)!==t.join(`,`)){let e=this.multiple?[...t]:t[0]||``;this.onChange(e)}else t.length===0&&e&&e.length>0&&this.clearInputValue()}onChange(e){this.touched=!0,super.onChange(e)}valueChanged(){}};e.n([e.u({type:String,reflect:!0})],v.prototype,`value`,void 0),e.n([e.u({type:Array})],v.prototype,`options`,void 0),e.n([e.u({type:Array,attribute:`default-options`})],v.prototype,`defaultOptions`,void 0),e.n([e.u({type:Boolean,attribute:`allow-user-input`})],v.prototype,`allowUserInput`,void 0),e.n([e.u({type:Boolean})],v.prototype,`typeahead`,void 0),e.n([e.u({type:Boolean,attribute:`include-search`})],v.prototype,`includeSearch`,void 0),e.n([e.u({type:String,attribute:`search-placeholder`})],v.prototype,`searchPlaceholder`,void 0),e.n([e.u({type:Boolean})],v.prototype,`multiple`,void 0),e.n([e.u({type:Number})],v.prototype,`maxlength`,void 0),e.n([e.u({type:String,attribute:`display-value-as`})],v.prototype,`displayValueAs`,void 0),e.n([e.u({type:String,attribute:`tag-placement`})],v.prototype,`tagPlacement`,void 0),e.n([e.u({type:Boolean,attribute:`open`})],v.prototype,`isOpen`,void 0),e.n([e.l()],v.prototype,`_options`,void 0),e.n([e.l()],v.prototype,`_value`,void 0),e.n([e.l()],v.prototype,`_isOptionsOpen`,void 0),e.n([e.l()],v.prototype,`_userInfoMessage`,void 0),e.n([e.l()],v.prototype,`_messageValue`,void 0),e.n([e.l()],v.prototype,`_addValueText`,void 0),e.n([e.l()],v.prototype,`_maxIsReached`,void 0),e.n([e.l()],v.prototype,`_search`,void 0),e.n([e.l()],v.prototype,`_inputFocus`,void 0),e.n([e.l()],v.prototype,`_skipInputTab`,void 0);var y=class extends v{toggleValue(e){if(this.disabled)return;this.touched=!0,this._userInfoMessage=``,this._addValueText=null;let t=s.i(this.options,e)?.value||null,n=this._value.includes(e||t||``),r=!!t,i=this._options.find(t=>t.value===e)?.disabled||!1,a=!e?.trim(),o=!this.multiple,c=this.multiple,l=s.l(this._value.length,this.maxlength),u=!1,d=!0,f=``,m=null,h=``;i||(!r&&this.allowUserInput&&!a?(this.addNewUserValue(e),f=`valueAdded`,u=c):!r&&!this.allowUserInput?(o&&this._value[0]&&this.removeValue(this._value[0]),d=!1,u=!0,f=`noResults`):n?(this.removeValue(t),u=!0,o&&this._hasTextInput&&this.inputRef.value&&this.inputRef.value.type!==`hidden`&&(this.inputRef.value.value=``)):a&&o?(this.removeAllSelected(),u=!0):o?(this._value[0]&&this.removeSelected(this._value[0]),this.setSelected(t),u=!1,f=`valueSelected`,m=this._hasTextInput?p(t||``,this.options,this.displayValueAs):s.s(s.i(this.options,t),this.displayValueAs)):c&&!l?(this.setSelected(t),u=!0):c&&l?(f=`maxSelected`,d=!1,h=e):(o&&this.removeAllSelected(),f=`noValidValue`,d=!1,u=!0,h=e),this._isOptionsOpen=u,u||window.setTimeout(()=>{this.focusAfterCommit()},0),this._search=h||``,this.resetComboboxInput(d),this._userInfoMessage=f,this._messageValue=m,c&&this.updateMaxReached())}setSelected(e){if(!this._value.includes(e)){if(this.multiple&&s.l(this._value.length,this.maxlength)){this._userInfoMessage=`maxSelected`;return}!this.multiple&&this.removeAllSelected(),this._value=e?[...this._value,e]:this._value,m.markOptionSelected(this._options,e),this.resetComboboxInput(!0)}}removeSelected(e){if(!e)return;this._value=this._value.filter(t=>t!==e);let t=s.i(this.options,e);t&&(m.markOptionDeselected(this.options,e),t.userAdded?(this._options=[...this._options.filter(t=>t.value!==e)],this.options=[...this.options.filter(t=>t.value!==e)]):this._options.some(t=>t.value===e)||(this._options=[...this._options,t]))}addAllOptions(){if(this.multiple){if(this.maxlength&&this._options.length>this.maxlength){this._userInfoMessage=`tooManySelected`;return}this._value=this._options.map(e=>e.value),m.markAllSelected(this._options),this.requestUpdate()}}removeAllSelected(){this._value=[],m.markAllDeselected(this._options),this._options=m.removeUserAddedOptions(this._options),this.requestUpdate()}addValue(){let e=this.inputRef.value?.value.trim()||``;if(this._search=e,e&&this._value.includes(e)){this.resetComboboxInput(!0),this._userInfoMessage=`alreadySelected`;return}this.toggleValue(e)}removeValue(e){this._value=this.multiple?this._value.filter(t=>t!==e):[],this.removeSelected(e)}addNewUserValue(e){if(!e||e.trim()===``)return;if(!this.multiple)this._value[0]&&this.removeSelected(this._value[0]),this._value=[e];else if(!s.i(this.options,e)){if(s.l(this._value.length,this.maxlength))return;this._value=[...this._value,e]}let t={value:e,label:e,userAdded:!0,selected:!0};this.options=[t,...this.options],this._options=[t,...this._options],this.resetComboboxInput(!0),this.multiple||(this._isOptionsOpen=!1,window.setTimeout(()=>{this.focusAfterCommit()},0)),this.requestUpdate()}refreshOptionsFromValue(){let e=g.cloneOptions(this.options);e.forEach(e=>e.selected=this._value.includes(e.value)),this._options=g.syncOptionsWithValues(e,this._value).options}resetComboboxInput(e=!0){this._addValueText=null,this.inputRef.value&&this.inputRef.value.type!==`hidden`&&e&&(this._search=``,this.multiple?this.inputRef.value.value=``:(this.inputRef.value.value=this._value[0]?p(this._value[0],this.options,this.displayValueAs):``,this._userInfoMessage=``)),this.refreshOptionsFromValue()}removeLastValue(e){if(this._value.length===0)return;e.preventDefault();let t=this._value[this._value.length-1];t&&this.removeSelected(t),this.updateMaxReached()}},b=class extends y{handleInput(e){if(e.stopPropagation(),e.stopImmediatePropagation(),this.disabled)return;this.touched=!0;let t=e.target;if(this._search=t.value,this.checkForMatches(),this.typeahead){if(this._search){let{filtered:n,suggestion:r}=s.o(this.options,this._search);this._options=n,e.inputType!==`deleteContentBackward`&&r?.label&&this.inputRef.value&&this.inputRef.value.type!==`hidden`&&(t.value=r.label,window.setTimeout(()=>t.setSelectionRange(this._search.length,t.value.length),0),t.selectionDirection=`backward`)}else this.refreshOptionsFromValue()}}handleFocus(){if(!this.disabled){if(this._skipInputTab=!1,this._suppressNextOpen){this._suppressNextOpen=!1,this._inputFocus=!0,this.requestUpdate();return}!this.multiple&&this._value[0]&&this.inputRef.value&&this.inputRef.value.type!==`hidden`&&(this.inputRef.value.value=p(this._value[0],this.options,this.displayValueAs)),this._inputFocus=!0,this._search=``,this.refreshOptionsFromValue(),this._isOptionsOpen=!0,this.onFocus(),this.requestUpdate()}}handleCloseOptions(){this._isOptionsOpen=!1,this._hasTextInput&&(this._suppressNextOpen=!0),this.focusTrigger()}handleFocusOut(e){if(this.disabled||!this._isOptionsOpen)return;let t=e.relatedTarget;t?.closest(`pkt-combobox`)?.id===this.id||e.target?.classList?.contains(`pkt-combobox__value`)||t===this.inputRef.value||t===this.triggerRef.value||this.closeAndProcessInput()}closeAndProcessInput(){if(this._inputFocus=!1,this._addValueText=null,this._userInfoMessage=``,this._search=``,this.inputRef.value&&this.inputRef.value.type!==`hidden`){let e=this.inputRef.value.value;if(!this.multiple){if(!e)this._value[0]&&this.removeSelected(this._value[0]);else{let t=s.i(this.options,e);t&&t.value!==this._value[0]?(this._value[0]&&this.removeSelected(this._value[0]),this.setSelected(t.value)):!t&&this.allowUserInput&&(this._value[0]&&this.removeSelected(this._value[0]),this.addNewUserValue(e))}}else if(e!==``){let{action:t,value:n}=d(e,this._value,this.options,this.allowUserInput,this.multiple);switch(t){case`addUserValue`:this.addNewUserValue(n);break;case`selectOption`:this.setSelected(n);break;case`removeValue`:this.removeValue(n)}}!this.multiple&&this._value[0]?this.inputRef.value.value=p(this._value[0],this.options,this.displayValueAs):this.inputRef.value.value=``}this._isOptionsOpen=!1,this.onBlur()}handleBlur(){this._inputFocus=!1,this.onBlur()}handleInputClick(e){if(this.disabled){e.preventDefault(),e.stopImmediatePropagation();return}this._hasTextInput?(this.inputRef.value?.focus(),this.requestUpdate()):(e.stopImmediatePropagation(),e.preventDefault(),this._isOptionsOpen=!this._isOptionsOpen,this._isOptionsOpen&&this.listboxRef.value?.focusFirstOrSelectedOption())}handlePlaceholderClick(e){this.disabled||(e.stopPropagation(),this._hasTextInput&&this.inputRef.value?(this.inputRef.value.focus(),this._inputFocus=!0,this.requestUpdate()):(this._isOptionsOpen=!this._isOptionsOpen,this.requestUpdate()))}handleSelectOnlyKeydown(e){if(!this.disabled)switch(e.key){case`Enter`:case` `:case`ArrowDown`:case`ArrowUp`:e.preventDefault(),this._isOptionsOpen?this._isOptionsOpen=!1:(this._isOptionsOpen=!0,this.listboxRef.value?.focusFirstOrSelectedOption());break;case`Escape`:this._isOptionsOpen&&=(e.preventDefault(),!1);break;case`Home`:case`End`:e.preventDefault(),this._isOptionsOpen||=!0,this.listboxRef.value?.focusFirstOrSelectedOption();break;case`ArrowLeft`:this.multiple&&this._value.length>0&&(e.preventDefault(),this.focusTag(this._value.length-1));break;case`Backspace`:case`Delete`:this.multiple&&this._value.length>0&&(e.preventDefault(),this.removeSelected(this._value[this._value.length-1]))}}handleOptionToggled(e){this.toggleValue(e.detail)}handleSearch(e){e.stopPropagation(),this._search=e.detail.toLowerCase(),this.checkForMatches()}handleInputKeydown(e){if(e.key===`Backspace`){let t=!this.inputRef.value?.value;!this._search&&t&&this.multiple&&this._value.length>0&&this.removeLastValue(e);return}if(e.key===`ArrowLeft`&&this.multiple&&this._value.length>0){let t=this.inputRef.value;if(t&&t.selectionStart===0&&!t.value){e.preventDefault(),this.focusTag(this._value.length-1);return}}let t=u(e.key,e.shiftKey,this.multiple);if(t&&!(e.key===`Tab`&&!this._isOptionsOpen)){if(t===`focusListbox`&&e.key===`Tab`&&!this.listboxRef.value?.querySelector(`[role="option"]:not([data-disabled]), [data-type="new-option"]`)){this.closeAndProcessInput();return}switch(e.preventDefault(),t){case`addValue`:this.addValue();break;case`focusListbox`:this.listboxRef.value?.focusFirstOrSelectedOption();break;case`closeOptions`:this._isOptionsOpen=!1}}}handleTagRemove(e){this.removeSelected(e),this._hasTextInput&&this.inputRef.value&&(this._inputFocus=!0,this.inputRef.value.focus(),this.requestUpdate())}getInsideTags(){return Array.from(this.querySelectorAll(`.pkt-combobox__input .pkt-combobox__tag-list pkt-tag`))}focusTag(e){let t=this.getInsideTags();t.forEach((t,n)=>{t.buttonTabindex=n===e?0:-1}),(t[e]?.querySelector(`button`))?.focus()}resetTagTabindices(){this.getInsideTags().forEach(e=>{e.buttonTabindex=-1})}handleTagKeydown(e,t){e.stopPropagation();let n=()=>{this.resetTagTabindices(),this._hasTextInput&&this.inputRef.value?this.inputRef.value.focus():this.triggerRef.value?.focus()};switch(e.key){case`ArrowLeft`:e.preventDefault(),t>0&&this.focusTag(t-1);break;case`ArrowRight`:e.preventDefault(),t<this._value.length-1?this.focusTag(t+1):n();break;case`Backspace`:case`Delete`:e.preventDefault();{let e=this._value[t],r=t>=this._value.length-1?t-1:t;this.removeSelected(e),r>=0?(this.requestUpdate(),this.updateComplete.then(()=>this.focusTag(r))):n()}break;case`Tab`:this.resetTagTabindices();break;case`Escape`:e.preventDefault(),n()}}checkForMatches(){let e=f(this.inputRef.value?.value||this._search||``,this._value,this.options,this.allowUserInput,this.multiple);if(e.shouldRemoveValue&&this.removeValue(this._value[0]),e.shouldResetInput){this.resetComboboxInput(!1);return}this._addValueText=e.addValueText,this._userInfoMessage=e.userInfoMessage}},x=class extends b{constructor(...e){super(...e),this.handleBodyClick=e=>{this._isOptionsOpen&&!this.contains(e.target)&&this.closeAndProcessInput()}}connectedCallback(){if(super.connectedCallback(),document?.body.addEventListener(`click`,this.handleBodyClick),this._options=[],this.defaultOptions&&this.defaultOptions.length){let e=this.options?.filter(e=>e.userAdded)||[];this.options=[...e,...JSON.parse(JSON.stringify(this.defaultOptions))],this._options=g.cloneOptions(this.options)}if(this.optionsController?.nodes&&this.optionsController.nodes.length){let e=h.parseOptionsFromSlot(this.optionsController.nodes);e.length&&(this.options=[...e],this._options=[...e],this._optionsFromSlot=!0,this._lastSlotGeneration=this.optionsController.generation)}}disconnectedCallback(){super.disconnectedCallback(),document?.body.removeEventListener(`click`,this.handleBodyClick)}firstUpdated(e){this.defaultValue!==null&&!this.value&&(this.value=this.defaultValue),super.firstUpdated(e)}willUpdate(e){if(this._optionsFromSlot&&this.optionsController){let e=this.optionsController.generation;if(e!==this._lastSlotGeneration){this._lastSlotGeneration=e;let t=h.parseOptionsFromSlot(this.optionsController.nodes),n=this._options.filter(e=>e.userAdded);this.options=[...n,...t]}}if(super.willUpdate(e),e.has(`isOpen`)&&(this._isOptionsOpen=this.isOpen),e.has(`defaultOptions`)&&this.defaultOptions.length){let e=(Array.isArray(this.options)?this.options:[]).filter(e=>e.userAdded)||[];this.options=[...e,...JSON.parse(JSON.stringify(this.defaultOptions))],this._options=g.cloneOptions(this.options)}let t=e.has(`value`),n=e.has(`_value`);if(t){let e=[...this._value],t=this.parseValue();t.join(`,`)!==this._value.join(`,`)&&(this._value=t,this._options.forEach(e=>e.selected=t.includes(e.value)),this._options=[...this._options]),this._pendingDispatchFrom??=e}else n&&(this._pendingDispatchFrom??=e.get(`_value`)??[]);if(e.has(`defaultValue`)&&this.defaultValue!=null&&!this._value.length){let e=this.parseToValues(this.defaultValue);e.length&&(this._pendingDispatchFrom??=[...this._value],this._value=e,this._options.forEach(t=>t.selected=e.includes(t.value)),this._options=[...this._options])}if(e.has(`options`)){let t=e.get(`options`)||this._options||[],n=g.mergeWithUserAdded(g.cloneOptions(this.options),t,this._value);this._options=n,n.length>this.options.length&&(this.options=n);let r=g.syncOptionsWithValues(this._options,this._value);this._options=r.options,r.newValues.length>this._value.length&&(this._pendingDispatchFrom??=[...this._value],this._value=r.newValues)}(t||n||e.has(`options`)||e.has(`defaultValue`))&&this.updateMaxReached(),this._pendingDispatchFrom&&this.syncPublicValue()}updated(e){if(this._pendingDispatchFrom){let e=this._pendingDispatchFrom;this._pendingDispatchFrom=null,this.dispatchValueChange(e)}if(e.has(`_search`)&&this.dispatchEvent(new CustomEvent(`search`,{detail:this._search,bubbles:!1})),!this._isOptionsOpen&&this._hasTextInput&&this.inputRef.value&&this.inputRef.value.type!==`hidden`){let e=!this.multiple&&this._value[0]?p(this._value[0],this.options,this.displayValueAs):``;this.inputRef.value.value!==e&&(this.inputRef.value.value=e)}this.classList.add(`pkt-combobox-component`),this.classList.toggle(`pkt-combobox-component--fullwidth`,!!this.fullwidth),super.updated(e)}formResetCallback(){this.touched=!1;let e=this.defaultValue||(this.multiple,``);this.value=e,this._value=this.parseValue(),this._options=this._options.filter(e=>!e.userAdded).map(e=>({...e,selected:this._value.includes(e.value)})),this.options=this.options.filter(e=>!e.userAdded).map(e=>({...e,selected:this._value.includes(e.value)})),this._search=``,this._isOptionsOpen=!1,this._userInfoMessage=``,this._addValueText=null,this._inputFocus=!1,this.updateMaxReached(),this.inputRef.value&&this.inputRef.value.type!==`hidden`&&(this.inputRef.value.value=``),this.internals.setFormValue(``),this.internals.ariaInvalid=`false`,this.requestUpdate()}attributeChangedCallback(e,t,n){if(e===`options`){this._options=g.cloneOptions(this.options);let e=g.syncOptionsWithValues(this._options,this._value);this._options=e.options,e.newValues.length>this._value.length&&(this._value=e.newValues),this._search=``}super.attributeChangedCallback(e,t,n)}render(){return e._`
|
|
2
|
-
<pkt-input-wrapper
|
|
3
|
-
.strings=${this.strings}
|
|
4
|
-
.size=${this.inputSize}
|
|
5
|
-
.label=${this.label}
|
|
6
|
-
.helptext=${this.helptext}
|
|
7
|
-
.helptextDropdown=${n.t(this.helptextDropdown)}
|
|
8
|
-
.helptextDropdownButton=${n.t(this.helptextDropdownButton)}
|
|
9
|
-
?fullwidth=${this.fullwidth}
|
|
10
|
-
?counter=${this.effectiveCounter(!!this.multiple&&this.maxlength!=null)}
|
|
11
|
-
.counterCurrent=${this._value.length}
|
|
12
|
-
.counterMaxLength=${this.maxlength??0}
|
|
13
|
-
?hasError=${this.hasError}
|
|
14
|
-
?inline=${this.inline}
|
|
15
|
-
?disabled=${this.disabled}
|
|
16
|
-
.errorMessage=${this.errorMessage}
|
|
17
|
-
?optionalTag=${this.optionalTag}
|
|
18
|
-
.optionalText=${this.optionalText}
|
|
19
|
-
?requiredTag=${this.requiredTag}
|
|
20
|
-
.requiredText=${this.requiredText}
|
|
21
|
-
.tagText=${this.tagText}
|
|
22
|
-
useWrapper=${this.useWrapper}
|
|
23
|
-
.forId=${this._hasTextInput?this.id+`-input`:this.id+`-combobox`}
|
|
24
|
-
?hasFieldset=${this.effectiveHasFieldset(!this._hasTextInput)}
|
|
25
|
-
class="pkt-combobox__wrapper"
|
|
26
|
-
@labelClick=${this.handleInputClick}
|
|
27
|
-
>
|
|
28
|
-
<div class="pkt-contents" slot="helptext">${i.r(this,`helptext`)}</div>
|
|
29
|
-
<div class="pkt-combobox" @focusout=${this.handleFocusOut}>
|
|
30
|
-
<div
|
|
31
|
-
class=${t.t({"pkt-combobox__input":!0,[`pkt-combobox__input--${this.inputSize}`]:!0,"pkt-combobox__input--fullwidth":this.fullwidth,"pkt-combobox__input--open":this._isOptionsOpen,"pkt-combobox__input--error":this.hasError,"pkt-combobox__input--disabled":this.disabled})}
|
|
32
|
-
id=${n.t(this._hasTextInput?void 0:`${this.id}-combobox`)}
|
|
33
|
-
role=${n.t(this._hasTextInput?void 0:`combobox`)}
|
|
34
|
-
aria-expanded=${n.t(this._hasTextInput?void 0:this._isOptionsOpen?`true`:`false`)}
|
|
35
|
-
aria-controls=${n.t(this._hasTextInput?void 0:`${this.id}-listbox`)}
|
|
36
|
-
aria-haspopup=${n.t(this._hasTextInput?void 0:`listbox`)}
|
|
37
|
-
aria-labelledby=${n.t(this._hasTextInput?void 0:`${this.id}-combobox-label`)}
|
|
38
|
-
aria-activedescendant=${n.t(!this._hasTextInput&&this._isOptionsOpen&&this._value[0]&&s.i(this.options,this._value[0])?`${this.id}-listbox-${s.a(this._options,this._value[0])}`:void 0)}
|
|
39
|
-
aria-description=${n.t(this._selectionDescription||void 0)}
|
|
40
|
-
tabindex=${this._hasTextInput||this.disabled?`-1`:`0`}
|
|
41
|
-
@click=${this.handleInputClick}
|
|
42
|
-
@keydown=${this._hasTextInput?e.h:this.handleSelectOnlyKeydown}
|
|
43
|
-
@blur=${this.restoreInputTab}
|
|
44
|
-
${a.n(this.triggerRef)}
|
|
45
|
-
>
|
|
46
|
-
${!this._hasTextInput&&this.placeholder&&(!this._value.length||this.multiple&&this.tagPlacement==`outside`)&&!this._inputFocus?e._`<span class="pkt-combobox__placeholder" @click=${this.handlePlaceholderClick}
|
|
47
|
-
>${this.placeholder}</span
|
|
48
|
-
>`:this.tagPlacement===`outside`?e.h:this.renderSingleOrMultipleValues()}
|
|
49
|
-
${this.renderInputField()}
|
|
50
|
-
<pkt-icon
|
|
51
|
-
class=${t.t({"pkt-combobox__arrow-icon":!0,"pkt-combobox__arrow-icon--open":this._isOptionsOpen})}
|
|
52
|
-
name="chevron-thin-down"
|
|
53
|
-
aria-hidden="true"
|
|
54
|
-
></pkt-icon>
|
|
55
|
-
</div>
|
|
56
|
-
|
|
57
|
-
<pkt-listbox
|
|
58
|
-
id="${this.id}-listbox"
|
|
59
|
-
.options=${this._options}
|
|
60
|
-
.isOpen=${this._isOptionsOpen}
|
|
61
|
-
.searchPlaceholder=${this.searchPlaceholder}
|
|
62
|
-
.label="Liste: ${this.label||``}"
|
|
63
|
-
?disabled=${this.disabled}
|
|
64
|
-
?include-search=${this.includeSearch}
|
|
65
|
-
?is-multi-select=${this.multiple}
|
|
66
|
-
?allow-user-input=${this.allowUserInput&&!this._maxIsReached}
|
|
67
|
-
?max-is-reached=${this._maxIsReached}
|
|
68
|
-
.customUserInput=${n.t(this._addValueText)}
|
|
69
|
-
.userMessage=${this._userInfoMessage?r.t(this.pktStrings.get(`combobox`)[this._userInfoMessage],{value:this._messageValue??``}):``}
|
|
70
|
-
@search=${this.handleSearch}
|
|
71
|
-
@option-toggle=${this.handleOptionToggled}
|
|
72
|
-
@select-all=${this.addAllOptions}
|
|
73
|
-
@close-options=${this.handleCloseOptions}
|
|
74
|
-
@tab-close=${()=>this.closeAndProcessInput()}
|
|
75
|
-
.searchValue=${this._search||null}
|
|
76
|
-
.maxLength=${this.maxlength||0}
|
|
77
|
-
${a.n(this.listboxRef)}
|
|
78
|
-
></pkt-listbox>
|
|
79
|
-
</div>
|
|
80
|
-
|
|
81
|
-
${this.tagPlacement===`outside`&&this.multiple?e._`<div class="pkt-combobox__tags-outside">
|
|
82
|
-
${this.renderSingleOrMultipleValues()}
|
|
83
|
-
</div>`:e.h}
|
|
84
|
-
</pkt-input-wrapper>
|
|
85
|
-
`}renderInputField(){return this.typeahead||this.allowUserInput?e._`
|
|
86
|
-
<div class="pkt-combobox__input-div combobox__input">
|
|
87
|
-
<input
|
|
88
|
-
type="text"
|
|
89
|
-
id="${this.id}-input"
|
|
90
|
-
name=${(this.name||this.id)+`-input`}
|
|
91
|
-
placeholder=${n.t(!this._value.length||this.multiple&&this.tagPlacement===`outside`?this.placeholder:void 0)}
|
|
92
|
-
@input=${this.handleInput}
|
|
93
|
-
@change=${e=>{e.stopPropagation(),e.stopImmediatePropagation()}}
|
|
94
|
-
tabindex=${n.t(this._skipInputTab?`-1`:void 0)}
|
|
95
|
-
@keydown=${this.handleInputKeydown}
|
|
96
|
-
@focus=${this.handleFocus}
|
|
97
|
-
@blur=${this.handleBlur}
|
|
98
|
-
autocomplete="off"
|
|
99
|
-
role="combobox"
|
|
100
|
-
aria-expanded=${this._isOptionsOpen?`true`:`false`}
|
|
101
|
-
aria-label=${n.t(this.label)}
|
|
102
|
-
aria-autocomplete=${this.typeahead?`both`:this.allowUserInput?`list`:`none`}
|
|
103
|
-
aria-controls="${this.id}-listbox"
|
|
104
|
-
aria-activedescendant=${n.t(this._isOptionsOpen&&this._value[0]&&s.i(this.options,this._value[0])?`${this.id}-listbox-${s.a(this._options,this._value[0])}`:void 0)}
|
|
105
|
-
aria-description=${n.t(this._selectionDescription||void 0)}
|
|
106
|
-
${a.n(this.inputRef)}
|
|
107
|
-
/>
|
|
108
|
-
</div>
|
|
109
|
-
`:e._`
|
|
110
|
-
<input
|
|
111
|
-
type="hidden"
|
|
112
|
-
id="${this.id}-input"
|
|
113
|
-
name=${(this.name||this.id)+`-input`}
|
|
114
|
-
.value=${this._value.join(`,`)}
|
|
115
|
-
${a.n(this.inputRef)}
|
|
116
|
-
/>
|
|
117
|
-
`}renderSingleOrMultipleValues(){if(!this.multiple&&this._hasTextInput)return e.h;let t=!this.multiple,n=this.renderValueTag(s.i(this.options,this._value[0])),r=this.tagPlacement===`outside`,i=e._`
|
|
118
|
-
<ul role="list" class="pkt-combobox__tag-list">
|
|
119
|
-
${o.t(this._value,e=>e,(t,n)=>{let i=s.i(this.options,t),a=i?.tagSkinColor;return e._`
|
|
120
|
-
<li
|
|
121
|
-
role="listitem"
|
|
122
|
-
@click=${r?e.h:e=>e.stopPropagation()}
|
|
123
|
-
@mousedown=${r?e.h:e=>e.preventDefault()}
|
|
124
|
-
>
|
|
125
|
-
<pkt-tag
|
|
126
|
-
skin=${a||`blue-dark`}
|
|
127
|
-
?closeTag=${!this.disabled}
|
|
128
|
-
.buttonTabindex=${r?void 0:-1}
|
|
129
|
-
@close=${()=>this.handleTagRemove(t)}
|
|
130
|
-
@keydown=${r?e.h:e=>this.handleTagKeydown(e,n)}
|
|
131
|
-
>
|
|
132
|
-
${this.renderValueTag(i)}
|
|
133
|
-
</pkt-tag>
|
|
134
|
-
</li>
|
|
135
|
-
`})}
|
|
136
|
-
</ul>
|
|
137
|
-
`;return!t&&this._value.length===0?e.h:t?n:i}renderValueTag(t){if(!t)return``;switch(this.displayValueAs){case`prefixAndValue`:return e._`<span class="pkt-combobox__value">${t.prefix||``} ${t.value}</span>`;case`value`:return e._`<span class="pkt-combobox__value">${t.value}</span>`;default:return e._`<span class="pkt-combobox__value">${t.label||t.value}</span>`}}};try{e.d(`pkt-combobox`)(x)}catch{console.warn(`Forsøker å definere <pkt-combobox>, men den er allerede definert`)}var S=x;Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return x}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return S}});
|