@oslokommune/punkt-elements 16.7.1 → 16.7.3
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 +17 -0
- package/dist/accordionitem-_9AiCIvd.cjs +34 -0
- package/dist/{accordionitem-ZlaXvjt5.js → accordionitem-dCfSrxh5.js} +57 -55
- package/dist/alert-BtOk8yRH.cjs +33 -0
- package/dist/{alert-BuAXrnKl.js → alert-DlY2_grU.js} +48 -46
- package/dist/backlink-Ce5Vldop.js +49 -0
- package/dist/backlink-y3dwjKPC.cjs +13 -0
- package/dist/button-B_TXwNzt.cjs +27 -0
- package/dist/{button-DEyvt1LI.js → button-BiY-wlKF.js} +79 -77
- package/dist/calendar-B2pji2zn.cjs +90 -0
- package/dist/{calendar-S63oreVW.js → calendar-DhjQDC4C.js} +689 -687
- package/dist/card-BwMNB5Bb.cjs +87 -0
- package/dist/{card-DDiLfuO4.js → card-CGlmcMSR.js} +99 -97
- package/dist/checkbox-BsJZYA26.js +147 -0
- package/dist/checkbox-CTY8f_qn.cjs +31 -0
- package/dist/{combobox-BmxSecfE.js → combobox-DSB5WOxg.js} +223 -226
- package/dist/{combobox-Hb2V-fPX.cjs → combobox-DbICIgKG.cjs} +4 -4
- package/dist/consent-DkOQpbsg.cjs +11 -0
- package/dist/{consent-iXyx5v6J.js → consent-SNWV_mMU.js} +48 -46
- package/dist/datepicker-BEWl9iz3.cjs +273 -0
- package/dist/{datepicker-CZl7b8Na.js → datepicker-euHyzXnb.js} +341 -329
- package/dist/{heading-CKt7cVn7.js → heading-D2tVS6lS.js} +30 -28
- package/dist/heading-DrzbgDb6.cjs +1 -0
- package/dist/helptext-BKtU4mas.js +82 -0
- package/dist/helptext-DcRC7wW2.cjs +24 -0
- package/dist/icon-CxQcIa5F.js +105 -0
- package/dist/icon-q81vqPK_.cjs +9 -0
- package/dist/input-wrapper-Bs4CRNst.js +181 -0
- package/dist/input-wrapper-Bv9aqqVq.cjs +54 -0
- package/dist/link-C0rl-86s.cjs +7 -0
- package/dist/link-Cdqgl60z.js +55 -0
- package/dist/linkcard-Dimu7Rlx.cjs +13 -0
- package/dist/linkcard-Lbq_UhjZ.js +56 -0
- package/dist/{listbox-BQKDZvZn.js → listbox-Bia4_tvN.js} +131 -129
- package/dist/listbox-La2GZQei.cjs +106 -0
- package/dist/loader-D1ugDXGV.cjs +16 -0
- package/dist/{loader-Ci3CHU8k.js → loader-DyN6RGC5.js} +51 -49
- package/dist/messagebox-BGMVm2t9.js +71 -0
- package/dist/messagebox-M0yIgCz9.cjs +13 -0
- package/dist/modal-CMO1RtIi.cjs +36 -0
- package/dist/{modal-DzGe1g8Z.js → modal-DjPQDE-Z.js} +53 -51
- package/dist/pkt-accordion.cjs +1 -1
- package/dist/pkt-accordion.js +2 -2
- package/dist/pkt-alert.cjs +1 -1
- package/dist/pkt-alert.js +3 -4
- package/dist/pkt-backlink.cjs +1 -1
- package/dist/pkt-backlink.js +2 -3
- package/dist/pkt-breadcrumbs.cjs +11 -11
- package/dist/pkt-breadcrumbs.js +30 -28
- package/dist/pkt-button.cjs +1 -1
- package/dist/pkt-button.js +3 -4
- package/dist/pkt-calendar.cjs +1 -1
- package/dist/pkt-calendar.js +2 -3
- package/dist/pkt-card.cjs +1 -1
- package/dist/pkt-card.js +2 -3
- package/dist/pkt-checkbox.cjs +1 -1
- package/dist/pkt-checkbox.js +3 -4
- package/dist/pkt-combobox.cjs +1 -1
- package/dist/pkt-combobox.js +3 -4
- package/dist/pkt-consent.cjs +1 -1
- package/dist/pkt-consent.js +2 -3
- package/dist/pkt-datepicker.cjs +1 -1
- package/dist/pkt-datepicker.js +7 -8
- package/dist/pkt-header.cjs +35 -35
- package/dist/pkt-header.js +224 -218
- package/dist/pkt-heading.cjs +1 -1
- package/dist/pkt-heading.js +3 -4
- package/dist/pkt-helptext.cjs +1 -1
- package/dist/pkt-helptext.js +3 -4
- package/dist/pkt-icon.cjs +1 -1
- package/dist/pkt-icon.js +3 -4
- package/dist/pkt-index.cjs +1 -1
- package/dist/pkt-index.js +26 -26
- package/dist/pkt-input-wrapper.cjs +1 -1
- package/dist/pkt-input-wrapper.js +2 -3
- package/dist/pkt-link.cjs +1 -1
- package/dist/pkt-link.js +2 -3
- package/dist/pkt-linkcard.cjs +1 -1
- package/dist/pkt-linkcard.js +3 -4
- package/dist/pkt-listbox.cjs +1 -1
- package/dist/pkt-listbox.js +3 -4
- package/dist/pkt-loader.cjs +1 -1
- package/dist/pkt-loader.js +3 -4
- package/dist/pkt-messagebox.cjs +1 -1
- package/dist/pkt-messagebox.js +3 -4
- package/dist/pkt-modal.cjs +1 -1
- package/dist/pkt-modal.js +3 -4
- package/dist/pkt-progressbar.cjs +1 -1
- package/dist/pkt-progressbar.js +2 -3
- package/dist/pkt-radiobutton.cjs +1 -1
- package/dist/pkt-radiobutton.js +3 -4
- package/dist/pkt-select.cjs +1 -1
- package/dist/pkt-select.js +3 -4
- package/dist/pkt-tabs.cjs +1 -1
- package/dist/pkt-tabs.js +2 -2
- package/dist/pkt-tag.cjs +1 -1
- package/dist/pkt-tag.js +3 -4
- package/dist/pkt-textarea.cjs +1 -1
- package/dist/pkt-textarea.js +3 -4
- package/dist/pkt-textinput.cjs +1 -1
- package/dist/pkt-textinput.js +3 -4
- package/dist/pkt-timepicker.cjs +16 -16
- package/dist/pkt-timepicker.js +91 -89
- package/dist/progressbar-BqlMzkM_.cjs +21 -0
- package/dist/{progressbar-By7e0lEI.js → progressbar-sbHDFC12.js} +88 -88
- package/dist/radiobutton-5ZqVVtTT.cjs +31 -0
- package/dist/{radiobutton-6frNG9J_.js → radiobutton-D8Ai8ETa.js} +44 -42
- package/dist/select-De-n8on9.js +230 -0
- package/dist/select-dTWibR6_.cjs +49 -0
- package/dist/tabitem-B9-jeV97.js +334 -0
- package/dist/tabitem-BnhzqfW3.cjs +65 -0
- package/dist/tag-CbwO8yvD.cjs +27 -0
- package/dist/{tag-BuCpqaks.js → tag-D4FI5t3y.js} +42 -40
- package/dist/textarea-BmLaKzsc.cjs +50 -0
- package/dist/{textarea-Bzuymclz.js → textarea-CMiSJaYL.js} +62 -60
- package/dist/textinput-em9y4yrL.cjs +70 -0
- package/dist/{textinput-9lHjs4ce.js → textinput-r8udK0IX.js} +57 -55
- package/package.json +2 -2
- package/src/components/accordion/accordion.ts +6 -1
- package/src/components/accordion/accordionitem.ts +6 -1
- package/src/components/alert/alert.ts +6 -1
- package/src/components/backlink/backlink.ts +6 -1
- package/src/components/breadcrumbs/breadcrumbs.ts +6 -1
- package/src/components/button/button.ts +6 -1
- package/src/components/calendar/calendar.ts +6 -1
- package/src/components/card/card.ts +6 -1
- package/src/components/checkbox/checkbox.ts +6 -1
- package/src/components/combobox/combobox.ts +6 -1
- package/src/components/consent/consent.ts +6 -1
- package/src/components/datepicker/date-tags.ts +6 -1
- package/src/components/datepicker/datepicker-multiple.ts +6 -1
- package/src/components/datepicker/datepicker-popup.ts +6 -1
- package/src/components/datepicker/datepicker-range.ts +6 -1
- package/src/components/datepicker/datepicker-single.ts +6 -1
- package/src/components/datepicker/datepicker.ts +6 -1
- package/src/components/header/header-service.ts +6 -1
- package/src/components/header/header-user-menu.ts +6 -1
- package/src/components/header/header.ts +6 -1
- package/src/components/heading/heading.ts +6 -1
- package/src/components/helptext/helptext.ts +6 -1
- package/src/components/icon/icon.ts +6 -1
- package/src/components/input-wrapper/input-wrapper.ts +6 -1
- package/src/components/link/link.ts +6 -1
- package/src/components/linkcard/linkcard.ts +6 -1
- package/src/components/listbox/listbox.ts +6 -1
- package/src/components/loader/loader.ts +6 -1
- package/src/components/messagebox/messagebox.ts +6 -1
- package/src/components/modal/modal.ts +6 -1
- package/src/components/progressbar/progressbar.ts +6 -1
- package/src/components/radiobutton/radiobutton.ts +6 -1
- package/src/components/select/select.ts +6 -1
- package/src/components/tabs/tabitem.ts +6 -1
- package/src/components/tabs/tabs.ts +6 -1
- package/src/components/tag/tag.ts +6 -1
- package/src/components/textarea/textarea.ts +6 -1
- package/src/components/textinput/textinput.ts +6 -1
- package/src/components/timepicker/timepicker.ts +6 -1
- package/dist/accordionitem-D1Agl1bB.cjs +0 -34
- package/dist/alert-DFkFNTxh.cjs +0 -33
- package/dist/backlink-EiAXUUZP.cjs +0 -13
- package/dist/backlink-V4DAt17e.js +0 -47
- package/dist/button-DYv5Dg4M.cjs +0 -27
- package/dist/calendar-HIE9nxcc.cjs +0 -90
- package/dist/card-CyeH6l1c.cjs +0 -87
- package/dist/checkbox-BLlwTABj.cjs +0 -31
- package/dist/checkbox-ejBUa5qQ.js +0 -145
- package/dist/consent-ruWAEVXW.cjs +0 -11
- package/dist/datepicker-D2H7U6MS.cjs +0 -273
- package/dist/heading-Cvz8m1xL.cjs +0 -1
- package/dist/helptext-5Mzp65-F.cjs +0 -24
- package/dist/helptext-jIoWRcCF.js +0 -80
- package/dist/icon-BlKA8YuW.js +0 -103
- package/dist/icon-Bqj9oBbl.cjs +0 -9
- package/dist/input-wrapper-B0MkQ0IZ.cjs +0 -54
- package/dist/input-wrapper-B2JpK016.js +0 -179
- package/dist/link-R_lNhViF.cjs +0 -7
- package/dist/link-Z_GizclR.js +0 -53
- package/dist/linkcard-BlQvdB1a.js +0 -54
- package/dist/linkcard-C7HbSLlX.cjs +0 -13
- package/dist/listbox-CGgV9MAe.cjs +0 -106
- package/dist/loader-e2gs_1xz.cjs +0 -16
- package/dist/messagebox-Bf-XMlvW.js +0 -69
- package/dist/messagebox-D67w71VX.cjs +0 -13
- package/dist/modal-CyvEkbfQ.cjs +0 -36
- package/dist/progressbar-DsJ2B9Vm.cjs +0 -21
- package/dist/radiobutton-Bv-BZ1Hw.cjs +0 -31
- package/dist/select-CXZt1nHS.js +0 -228
- package/dist/select-WFhS4Vfp.cjs +0 -49
- package/dist/tabitem-CB8wkKmv.js +0 -332
- package/dist/tabitem-DZpspU4Q.cjs +0 -65
- package/dist/tag-X6xdjR0N.cjs +0 -27
- package/dist/textarea-DoeHJ7HR.cjs +0 -50
- package/dist/textinput-BNsLd26i.cjs +0 -70
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const o=require("./element-gR_VtSiD.cjs"),d=require("./if-defined-BOW3ODSj.cjs"),b=require("./ref-CL-Xk9Xm.cjs"),V=require("./class-map-CsENJXf1.cjs"),S=require("./repeat-Cfq8CDlf.cjs"),u=require("./listbox-CGgV9MAe.cjs"),R=require("./element-with-slot-ZX-up7jO.cjs"),v=require("./state-Dg-53wQ8.cjs"),w=require("./input-element-DdVhUvva.cjs"),C=require("./pkt-options-controller-5LXbEzuk.cjs");require("./input-wrapper-B0MkQ0IZ.cjs");require("./icon-Bqj9oBbl.cjs");require("./tag-X6xdjR0N.cjs");const F=(a,t,e)=>{switch(a){case",":return e?"addValue":null;case"Enter":return"addValue";case"Tab":case"ArrowDown":return t?null:"focusListbox";case"Escape":return"closeOptions";default:return null}},M=(a,t,e,s,i)=>{if(!a)return{action:"none",value:null};const l=u.findOptionByValue(e,a);return!t.includes(a)&&!l?s?{action:"addUserValue",value:a}:i?{action:"none",value:null}:{action:"removeValue",value:t[0]}:l&&!t.includes(l.value)?{action:"selectOption",value:l.value}:{action:"none",value:null}},U=(a,t,e,s,i)=>a.trim().toLowerCase()?{...u.getSearchInfoMessage(a,t,e,s),shouldRemoveValue:!1,shouldResetInput:!1}:{addValueText:null,userInfoMessage:"",shouldRemoveValue:!i&&!!t[0],shouldResetInput:!0},O=(a,t,e)=>{const s=u.findOptionByValue(t,a);return e==="label"&&(s!=null&&s.label)?s.label:a},m={markOptionSelected(a,t){if(t){for(const e of a)if(e.value===t){e.selected=!0;break}}},markOptionDeselected(a,t){if(t){for(const e of a)if(e.value===t){e.selected=!1;break}}},markAllSelected(a){for(const t of a)t.selected=!0},markAllDeselected(a){for(const t of a)t.selected=!1},removeUserAddedOptions(a){return a.filter(t=>!t.userAdded)}},A={parseOptionsFromSlot(a){const t=[];return a.forEach(e=>{if(!e.textContent&&!e.getAttribute("value"))return;const s={value:e.getAttribute("value")||e.textContent||"",label:e.textContent||e.getAttribute("value")||""};e.getAttribute("data-prefix")&&(s.prefix=e.getAttribute("data-prefix")||void 0),e.getAttribute("tagskincolor")&&(s.tagSkinColor=e.getAttribute("tagskincolor")),e.getAttribute("description")&&(s.description=e.getAttribute("description")||void 0),s.fulltext=u.buildFulltext(s),t.push(s)}),t}},k={syncOptionsWithValues(a,t){const e=[...t];return a.forEach(s=>{s.value&&!s.label&&(s.label=s.value),s.selected&&!e.includes(s.value)&&e.push(s.value),s.fulltext=u.buildFulltext(s),s.selected=s.selected||e.includes(s.value)}),{options:a,newValues:e}},mergeWithUserAdded(a,t){return[...t.filter(i=>(i==null?void 0:i.userAdded)&&i.selected).filter(i=>!(Array.isArray(a)?a:[]).some(l=>l.value===i.value)),...a]}},D={displayValueAs:{default:"label"}},q={props:D};var P=Object.defineProperty,r=(a,t,e,s)=>{for(var i=void 0,l=a.length-1,n;l>=0;l--)(n=a[l])&&(i=n(t,e,i)||i);return i&&P(t,e,i),i};class h extends w.PktInputElement{constructor(){super(),this.value="",this.options=[],this.defaultOptions=[],this.allowUserInput=!1,this.typeahead=!1,this.includeSearch=!1,this.searchPlaceholder="",this.multiple=!1,this.maxlength=null,this.displayValueAs=q.props.displayValueAs.default,this.tagPlacement=null,this.isOpen=!1,this._options=[],this._value=[],this._isOptionsOpen=!1,this._userInfoMessage="",this._addValueText=null,this._maxIsReached=!1,this._search="",this._inputFocus=!1,this._internalValueSync=!1,this._optionsFromSlot=!1,this._lastSlotGeneration=0,this._suppressNextOpen=!1,this.inputRef=b.e(),this.triggerRef=b.e(),this.listboxRef=b.e(),this.optionsController=new C.PktOptionsSlotController(this)}get _hasTextInput(){return this.typeahead||this.allowUserInput}get _selectionDescription(){if(!(!this.multiple||this._value.length===0))return`${this._value.length} valgt`}focusTrigger(){var t,e;this._hasTextInput?(t=this.inputRef.value)==null||t.focus():(e=this.triggerRef.value)==null||e.focus()}parseValue(){return Array.isArray(this.value)?this.multiple?this.value:this.value.length>0?[this.value[0]]:[]:this.value&&this.multiple?this.value.split(","):this.value?[this.value]:[]}updateMaxReached(){this._maxIsReached=u.isMaxSelectionReached(this._value.length,this.maxlength)}syncValueAndDispatch(t){const e=this._value,s=this.multiple?e.join(","):e[0]||"",i=Array.isArray(this.value)?this.value.join(","):String(this.value||"");if(s!==i&&(this._internalValueSync=!0,this.value=s),(t==null?void 0:t.join(","))!==e.join(",")){const l=this.multiple?[...e]:e[0]||"";this.onChange(l)}else e.length===0&&t&&t.length>0&&this.clearInputValue()}onChange(t){this.touched=!0,super.onChange(t)}valueChanged(){}}r([o.n({type:String,reflect:!0})],h.prototype,"value");r([o.n({type:Array})],h.prototype,"options");r([o.n({type:Array,attribute:"default-options"})],h.prototype,"defaultOptions");r([o.n({type:Boolean,attribute:"allow-user-input"})],h.prototype,"allowUserInput");r([o.n({type:Boolean})],h.prototype,"typeahead");r([o.n({type:Boolean,attribute:"include-search"})],h.prototype,"includeSearch");r([o.n({type:String,attribute:"search-placeholder"})],h.prototype,"searchPlaceholder");r([o.n({type:Boolean})],h.prototype,"multiple");r([o.n({type:Number})],h.prototype,"maxlength");r([o.n({type:String,attribute:"display-value-as"})],h.prototype,"displayValueAs");r([o.n({type:String,attribute:"tag-placement"})],h.prototype,"tagPlacement");r([o.n({type:Boolean,attribute:"open"})],h.prototype,"isOpen");r([v.r()],h.prototype,"_options");r([v.r()],h.prototype,"_value");r([v.r()],h.prototype,"_isOptionsOpen");r([v.r()],h.prototype,"_userInfoMessage");r([v.r()],h.prototype,"_addValueText");r([v.r()],h.prototype,"_maxIsReached");r([v.r()],h.prototype,"_search");r([v.r()],h.prototype,"_inputFocus");class B extends h{toggleValue(t){var $,I;if(this.disabled)return;this.touched=!0,this._userInfoMessage="",this._addValueText=null;const e=(($=u.findOptionByValue(this.options,t))==null?void 0:$.value)||null,s=this._value.includes(t||e||""),i=!!e,l=((I=this._options.find(T=>T.value===t))==null?void 0:I.disabled)||!1,n=!(t!=null&&t.trim()),p=!this.multiple,f=this.multiple,_=u.isMaxSelectionReached(this._value.length,this.maxlength);let c=!1,x=!0,g="",y="";l||(!i&&this.allowUserInput&&!n?(this.addNewUserValue(t),g="Ny verdi lagt til",c=f):!i&&!this.allowUserInput?(p&&this._value[0]&&this.removeValue(this._value[0]),x=!1,c=!0,g="Ingen treff i søket"):s?(this.removeValue(e),c=!0,p&&this._hasTextInput&&this.inputRef.value&&this.inputRef.value.type!=="hidden"&&(this.inputRef.value.value="")):n&&p?(this.removeAllSelected(),c=!0):p?(this._value[0]&&this.removeSelected(this._value[0]),this.setSelected(e),c=!1):f&&!_?(this.setSelected(e),c=!0):f&&_?(g="Maks antall valg nådd",x=!1,y=t):(p&&this.removeAllSelected(),g="Ingen gyldig verdi valgt",x=!1,c=!0,y=t),this._isOptionsOpen=c,c||(p&&this._hasTextInput&&(this._suppressNextOpen=!0),window.setTimeout(()=>{this.focusTrigger()},0)),this._userInfoMessage=g,this._search=y||"",this.resetComboboxInput(x),f&&this.updateMaxReached())}setSelected(t){if(!this._value.includes(t)){if(this.multiple&&u.isMaxSelectionReached(this._value.length,this.maxlength)){this._userInfoMessage="Maks antall valg nådd";return}!this.multiple&&this.removeAllSelected(),this._value=t?[...this._value,t]:this._value,m.markOptionSelected(this._options,t),this.resetComboboxInput(!0)}}removeSelected(t){if(!t)return;this._value=this._value.filter(s=>s!==t);const e=u.findOptionByValue(this.options,t);e&&(m.markOptionDeselected(this.options,t),e.userAdded?(this._options=[...this._options.filter(s=>s.value!==t)],this.options=[...this.options.filter(s=>s.value!==t)]):this._options.some(s=>s.value===t)||(this._options=[...this._options,e]))}addAllOptions(){if(this.multiple){if(this.maxlength&&this._options.length>this.maxlength){this._userInfoMessage="For mange valgt";return}this._value=this._options.map(t=>t.value),m.markAllSelected(this._options),this.requestUpdate()}}removeAllSelected(){this._value=[],m.markAllDeselected(this._options),this._options=m.removeUserAddedOptions(this._options),this.requestUpdate()}addValue(){var e;const t=((e=this.inputRef.value)==null?void 0:e.value.trim())||"";if(this._search=t,t&&this._value.includes(t)){this.resetComboboxInput(!0),this._userInfoMessage="Verdien er allerede valgt";return}this.toggleValue(t)}removeValue(t){this._value=this.multiple?this._value.filter(e=>e!==t):[],this.removeSelected(t)}addNewUserValue(t){if(!t||t.trim()==="")return;if(!this.multiple)this._value[0]&&this.removeSelected(this._value[0]),this._value=[t];else if(!u.findOptionByValue(this.options,t)){if(u.isMaxSelectionReached(this._value.length,this.maxlength))return;this._value=[...this._value,t]}const e={value:t,label:t,userAdded:!0,selected:!0};this.options=[e,...this.options],this._options=[e,...this._options],this.resetComboboxInput(!0),this.multiple||(this._isOptionsOpen=!1,this._hasTextInput&&(this._suppressNextOpen=!0),window.setTimeout(()=>{this.focusTrigger()},0)),this.requestUpdate()}resetComboboxInput(t=!0){this._addValueText=null,this.inputRef.value&&this.inputRef.value.type!=="hidden"&&t&&(this._search="",this.multiple?this.inputRef.value.value="":(this.inputRef.value.value=this._value[0]?O(this._value[0],this.options,this.displayValueAs):"",this._userInfoMessage="")),this._options=[...this.options]}removeLastValue(t){if(this._value.length===0)return;t.preventDefault();const e=this._value[this._value.length-1];e&&this.removeSelected(e),this.updateMaxReached()}}class E extends B{handleInput(t){if(t.stopPropagation(),t.stopImmediatePropagation(),this.disabled)return;this.touched=!0;const e=t.target;if(this._search=e.value,this.checkForMatches(),this.typeahead)if(this._search){const{filtered:s,suggestion:i}=u.findTypeaheadMatches(this.options,this._search);this._options=s,t.inputType!=="deleteContentBackward"&&(i!=null&&i.label)&&this.inputRef.value&&this.inputRef.value.type!=="hidden"&&(e.value=i.label,window.setTimeout(()=>e.setSelectionRange(this._search.length,e.value.length),0),e.selectionDirection="backward")}else this._options=[...this.options]}handleFocus(){if(!this.disabled){if(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=O(this._value[0],this.options,this.displayValueAs)),this._inputFocus=!0,this._search="",this._options=[...this.options],this._isOptionsOpen=!0,this.onFocus(),this.requestUpdate()}}handleFocusOut(t){var i,l;if(this.disabled||!this._isOptionsOpen)return;const e=t.relatedTarget;((i=e==null?void 0:e.closest("pkt-combobox"))==null?void 0:i.id)===this.id||((l=t.target)==null?void 0:l.getAttribute("data-focusfix"))===this.id||e===this.inputRef.value||e===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"){const t=this.inputRef.value.value;if(this.multiple){if(t!==""){const{action:e,value:s}=M(t,this._value,this.options,this.allowUserInput,this.multiple);switch(e){case"addUserValue":this.addNewUserValue(s);break;case"selectOption":this.setSelected(s);break;case"removeValue":this.removeValue(s);break}}}else if(!t)this._value[0]&&this.removeSelected(this._value[0]);else{const e=u.findOptionByValue(this.options,t);e&&e.value!==this._value[0]?(this._value[0]&&this.removeSelected(this._value[0]),this.setSelected(e.value)):!e&&this.allowUserInput&&(this._value[0]&&this.removeSelected(this._value[0]),this.addNewUserValue(t))}!this.multiple&&this._value[0]?this.inputRef.value.value=O(this._value[0],this.options,this.displayValueAs):this.inputRef.value.value=""}this._isOptionsOpen=!1,this.onBlur()}handleBlur(){this._inputFocus=!1,this.onBlur()}handleInputClick(t){var e,s;if(this.disabled){t.preventDefault(),t.stopImmediatePropagation();return}this._hasTextInput?((e=this.inputRef.value)==null||e.focus(),this.requestUpdate()):(t.stopImmediatePropagation(),t.preventDefault(),this._isOptionsOpen=!this._isOptionsOpen,this._isOptionsOpen&&((s=this.listboxRef.value)==null||s.focusFirstOrSelectedOption()))}handlePlaceholderClick(t){this.disabled||(t.stopPropagation(),this._hasTextInput&&this.inputRef.value?(this.inputRef.value.focus(),this._inputFocus=!0,this.requestUpdate()):(this._isOptionsOpen=!this._isOptionsOpen,this.requestUpdate()))}handleSelectOnlyKeydown(t){var e,s;if(!this.disabled)switch(t.key){case"Enter":case" ":case"ArrowDown":case"ArrowUp":t.preventDefault(),this._isOptionsOpen?this._isOptionsOpen=!1:(this._isOptionsOpen=!0,(e=this.listboxRef.value)==null||e.focusFirstOrSelectedOption());break;case"Escape":this._isOptionsOpen&&(t.preventDefault(),this._isOptionsOpen=!1);break;case"Home":case"End":t.preventDefault(),this._isOptionsOpen||(this._isOptionsOpen=!0),(s=this.listboxRef.value)==null||s.focusFirstOrSelectedOption();break;case"ArrowLeft":this.multiple&&this._value.length>0&&(t.preventDefault(),this.focusTag(this._value.length-1));break;case"Backspace":case"Delete":this.multiple&&this._value.length>0&&(t.preventDefault(),this.removeSelected(this._value[this._value.length-1]));break}}handleOptionToggled(t){this.toggleValue(t.detail)}handleSearch(t){t.stopPropagation(),this._search=t.detail.toLowerCase(),this.checkForMatches()}handleInputKeydown(t){var s,i,l;if(t.key==="Backspace"){const n=!((s=this.inputRef.value)!=null&&s.value);!this._search&&n&&this.multiple&&this._value.length>0&&this.removeLastValue(t);return}if(t.key==="ArrowLeft"&&this.multiple&&this._value.length>0){const n=this.inputRef.value;if(n&&n.selectionStart===0&&!n.value){t.preventDefault(),this.focusTag(this._value.length-1);return}}const e=F(t.key,t.shiftKey,this.multiple);if(e&&!(t.key==="Tab"&&!this._isOptionsOpen)){if(e==="focusListbox"&&t.key==="Tab"&&!((i=this.listboxRef.value)==null?void 0:i.querySelector('[role="option"]:not([data-disabled]), [data-type="new-option"]'))){this.closeAndProcessInput();return}switch(t.preventDefault(),e){case"addValue":this.addValue();break;case"focusListbox":(l=this.listboxRef.value)==null||l.focusFirstOrSelectedOption();break;case"closeOptions":this._isOptionsOpen=!1;break}}}handleTagRemove(t){this.removeSelected(t),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(t){var i;const e=this.getInsideTags();e.forEach((l,n)=>{l.buttonTabindex=n===t?0:-1});const s=(i=e[t])==null?void 0:i.querySelector("button");s==null||s.focus()}resetTagTabindices(){this.getInsideTags().forEach(e=>{e.buttonTabindex=-1})}handleTagKeydown(t,e){t.stopPropagation();const s=()=>{var i;this.resetTagTabindices(),this._hasTextInput&&this.inputRef.value?this.inputRef.value.focus():(i=this.triggerRef.value)==null||i.focus()};switch(t.key){case"ArrowLeft":t.preventDefault(),e>0&&this.focusTag(e-1);break;case"ArrowRight":t.preventDefault(),e<this._value.length-1?this.focusTag(e+1):s();break;case"Backspace":case"Delete":t.preventDefault();{const i=this._value[e],l=e>=this._value.length-1?e-1:e;this.removeSelected(i),l>=0?(this.requestUpdate(),this.updateComplete.then(()=>this.focusTag(l))):s()}break;case"Tab":this.resetTagTabindices();break;case"Escape":t.preventDefault(),s();break}}checkForMatches(){var s;const t=((s=this.inputRef.value)==null?void 0:s.value)||this._search||"",e=U(t,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}}var N=Object.getOwnPropertyDescriptor,L=(a,t,e,s)=>{for(var i=s>1?void 0:s?N(t,e):t,l=a.length-1,n;l>=0;l--)(n=a[l])&&(i=n(i)||i);return i};exports.PktCombobox=class extends E{constructor(){super(...arguments),this.handleBodyClick=t=>{this._isOptionsOpen&&!this.contains(t.target)&&this.closeAndProcessInput()}}connectedCallback(){var t,e;if(super.connectedCallback(),document==null||document.body.addEventListener("click",this.handleBodyClick),this._options=[],this.defaultOptions&&this.defaultOptions.length){const s=((t=this.options)==null?void 0:t.filter(i=>i.userAdded))||[];this.options=[...s,...JSON.parse(JSON.stringify(this.defaultOptions))],this._options=Array.isArray(this.options)?[...this.options]:[]}if((e=this.optionsController)!=null&&e.nodes&&this.optionsController.nodes.length){const s=A.parseOptionsFromSlot(this.optionsController.nodes);s.length&&(this.options=[...s],this._options=[...s],this._optionsFromSlot=!0,this._lastSlotGeneration=this.optionsController.generation)}}willUpdate(t){if(this._optionsFromSlot&&this.optionsController){const e=this.optionsController.generation;if(e!==this._lastSlotGeneration){this._lastSlotGeneration=e;const s=A.parseOptionsFromSlot(this.optionsController.nodes),i=this._options.filter(l=>l.userAdded);this.options=[...i,...s]}}super.willUpdate(t)}disconnectedCallback(){super.disconnectedCallback(),document==null||document.body.removeEventListener("click",this.handleBodyClick)}firstUpdated(t){this.defaultValue!==null&&!this.value&&(this.value=this.defaultValue),super.firstUpdated(t)}updated(t){t.has("isOpen")&&(this._isOptionsOpen=this.isOpen);const e=t.has("value"),s=t.has("_value");if(e&&this._internalValueSync)this._internalValueSync=!1,s&&this.syncValueAndDispatch(t.get("_value"));else if(e){const l=[...this._value],n=this.parseValue();n.join(",")!==this._value.join(",")&&(this._value=n),this.updateMaxReached(),this.syncValueAndDispatch(l)}else s&&this.syncValueAndDispatch(t.get("_value"));if(t.has("defaultOptions")&&this.defaultOptions.length){const l=(Array.isArray(this.options)?this.options:[]).filter(n=>n.userAdded)||[];this.options=[...l,...JSON.parse(JSON.stringify(this.defaultOptions))],this._options=Array.isArray(this.options)?[...this.options]:[]}if(t.has("options")){const l=t.get("options")||this._options||[],n=k.mergeWithUserAdded(this.options,l);this._options=n,n.length>this.options.length&&(this.options=n);const p=k.syncOptionsWithValues(this._options,this._value);if(this._options=p.options,p.newValues.length>this._value.length){const f=[...this._value];this._value=p.newValues,this.syncValueAndDispatch(f)}}if(t.has("_search")&&this.dispatchEvent(new CustomEvent("search",{detail:this._search,bubbles:!1})),!this._isOptionsOpen&&!this.multiple&&this._hasTextInput&&this.inputRef.value&&this.inputRef.value.type!=="hidden"){const l=this._value[0]?O(this._value[0],this.options,this.displayValueAs):"";this.inputRef.value.value!==l&&(this.inputRef.value.value=l)}super.updated(t)}formResetCallback(){this.touched=!1;const t=this.defaultValue||(this.multiple,"");this.value=t,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(t,e,s){if(t==="options"){this._options=Array.isArray(this.options)?[...this.options]:[];const i=k.syncOptionsWithValues(this._options,this._value);this._options=i.options,i.newValues.length>this._value.length&&(this._value=i.newValues),this._search=""}super.attributeChangedCallback(t,e,s)}render(){return o.b`
|
|
1
|
+
"use strict";const o=require("./element-gR_VtSiD.cjs"),d=require("./if-defined-BOW3ODSj.cjs"),b=require("./ref-CL-Xk9Xm.cjs"),V=require("./class-map-CsENJXf1.cjs"),R=require("./repeat-Cfq8CDlf.cjs"),u=require("./listbox-La2GZQei.cjs"),w=require("./element-with-slot-ZX-up7jO.cjs"),v=require("./state-Dg-53wQ8.cjs"),C=require("./input-element-DdVhUvva.cjs"),F=require("./pkt-options-controller-5LXbEzuk.cjs");require("./input-wrapper-Bv9aqqVq.cjs");require("./icon-q81vqPK_.cjs");require("./tag-CbwO8yvD.cjs");const M=(a,t,e)=>{switch(a){case",":return e?"addValue":null;case"Enter":return"addValue";case"Tab":case"ArrowDown":return t?null:"focusListbox";case"Escape":return"closeOptions";default:return null}},U=(a,t,e,s,i)=>{if(!a)return{action:"none",value:null};const l=u.findOptionByValue(e,a);return!t.includes(a)&&!l?s?{action:"addUserValue",value:a}:i?{action:"none",value:null}:{action:"removeValue",value:t[0]}:l&&!t.includes(l.value)?{action:"selectOption",value:l.value}:{action:"none",value:null}},D=(a,t,e,s,i)=>a.trim().toLowerCase()?{...u.getSearchInfoMessage(a,t,e,s),shouldRemoveValue:!1,shouldResetInput:!1}:{addValueText:null,userInfoMessage:"",shouldRemoveValue:!i&&!!t[0],shouldResetInput:!0},y=(a,t,e)=>{const s=u.findOptionByValue(t,a);return e==="label"&&(s!=null&&s.label)?s.label:a},m={markOptionSelected(a,t){if(t){for(const e of a)if(e.value===t){e.selected=!0;break}}},markOptionDeselected(a,t){if(t){for(const e of a)if(e.value===t){e.selected=!1;break}}},markAllSelected(a){for(const t of a)t.selected=!0},markAllDeselected(a){for(const t of a)t.selected=!1},removeUserAddedOptions(a){return a.filter(t=>!t.userAdded)}},A={parseOptionsFromSlot(a){const t=[];return a.forEach(e=>{if(!e.textContent&&!e.getAttribute("value"))return;const s={value:e.getAttribute("value")||e.textContent||"",label:e.textContent||e.getAttribute("value")||""};e.getAttribute("data-prefix")&&(s.prefix=e.getAttribute("data-prefix")||void 0),e.getAttribute("tagskincolor")&&(s.tagSkinColor=e.getAttribute("tagskincolor")),e.getAttribute("description")&&(s.description=e.getAttribute("description")||void 0),s.fulltext=u.buildFulltext(s),t.push(s)}),t}},k={syncOptionsWithValues(a,t){const e=[...t];return a.forEach(s=>{s.value&&!s.label&&(s.label=s.value),s.selected&&!e.includes(s.value)&&e.push(s.value),s.fulltext=u.buildFulltext(s),s.selected=s.selected||e.includes(s.value)}),{options:a,newValues:e}},mergeWithUserAdded(a,t){return[...t.filter(i=>(i==null?void 0:i.userAdded)&&i.selected).filter(i=>!(Array.isArray(a)?a:[]).some(l=>l.value===i.value)),...a]}},q={displayValueAs:{default:"label"}},B={props:q};var P=Object.defineProperty,r=(a,t,e,s)=>{for(var i=void 0,l=a.length-1,n;l>=0;l--)(n=a[l])&&(i=n(t,e,i)||i);return i&&P(t,e,i),i};class h extends C.PktInputElement{constructor(){super(),this.value="",this.options=[],this.defaultOptions=[],this.allowUserInput=!1,this.typeahead=!1,this.includeSearch=!1,this.searchPlaceholder="",this.multiple=!1,this.maxlength=null,this.displayValueAs=B.props.displayValueAs.default,this.tagPlacement=null,this.isOpen=!1,this._options=[],this._value=[],this._isOptionsOpen=!1,this._userInfoMessage="",this._addValueText=null,this._maxIsReached=!1,this._search="",this._inputFocus=!1,this._internalValueSync=!1,this._optionsFromSlot=!1,this._lastSlotGeneration=0,this._suppressNextOpen=!1,this.inputRef=b.e(),this.triggerRef=b.e(),this.listboxRef=b.e(),this.optionsController=new F.PktOptionsSlotController(this)}get _hasTextInput(){return this.typeahead||this.allowUserInput}get _selectionDescription(){if(!(!this.multiple||this._value.length===0))return`${this._value.length} valgt`}focusTrigger(){var t,e;this._hasTextInput?(t=this.inputRef.value)==null||t.focus():(e=this.triggerRef.value)==null||e.focus()}parseValue(){return Array.isArray(this.value)?this.multiple?this.value:this.value.length>0?[this.value[0]]:[]:this.value&&this.multiple?this.value.split(","):this.value?[this.value]:[]}updateMaxReached(){this._maxIsReached=u.isMaxSelectionReached(this._value.length,this.maxlength)}syncValueAndDispatch(t){const e=this._value,s=this.multiple?e.join(","):e[0]||"",i=Array.isArray(this.value)?this.value.join(","):String(this.value||"");if(s!==i&&(this._internalValueSync=!0,this.value=s),(t==null?void 0:t.join(","))!==e.join(",")){const l=this.multiple?[...e]:e[0]||"";this.onChange(l)}else e.length===0&&t&&t.length>0&&this.clearInputValue()}onChange(t){this.touched=!0,super.onChange(t)}valueChanged(){}}r([o.n({type:String,reflect:!0})],h.prototype,"value");r([o.n({type:Array})],h.prototype,"options");r([o.n({type:Array,attribute:"default-options"})],h.prototype,"defaultOptions");r([o.n({type:Boolean,attribute:"allow-user-input"})],h.prototype,"allowUserInput");r([o.n({type:Boolean})],h.prototype,"typeahead");r([o.n({type:Boolean,attribute:"include-search"})],h.prototype,"includeSearch");r([o.n({type:String,attribute:"search-placeholder"})],h.prototype,"searchPlaceholder");r([o.n({type:Boolean})],h.prototype,"multiple");r([o.n({type:Number})],h.prototype,"maxlength");r([o.n({type:String,attribute:"display-value-as"})],h.prototype,"displayValueAs");r([o.n({type:String,attribute:"tag-placement"})],h.prototype,"tagPlacement");r([o.n({type:Boolean,attribute:"open"})],h.prototype,"isOpen");r([v.r()],h.prototype,"_options");r([v.r()],h.prototype,"_value");r([v.r()],h.prototype,"_isOptionsOpen");r([v.r()],h.prototype,"_userInfoMessage");r([v.r()],h.prototype,"_addValueText");r([v.r()],h.prototype,"_maxIsReached");r([v.r()],h.prototype,"_search");r([v.r()],h.prototype,"_inputFocus");class E extends h{toggleValue(t){var I,$;if(this.disabled)return;this.touched=!0,this._userInfoMessage="",this._addValueText=null;const e=((I=u.findOptionByValue(this.options,t))==null?void 0:I.value)||null,s=this._value.includes(t||e||""),i=!!e,l=(($=this._options.find(S=>S.value===t))==null?void 0:$.disabled)||!1,n=!(t!=null&&t.trim()),p=!this.multiple,f=this.multiple,_=u.isMaxSelectionReached(this._value.length,this.maxlength);let c=!1,x=!0,g="",O="";l||(!i&&this.allowUserInput&&!n?(this.addNewUserValue(t),g="Ny verdi lagt til",c=f):!i&&!this.allowUserInput?(p&&this._value[0]&&this.removeValue(this._value[0]),x=!1,c=!0,g="Ingen treff i søket"):s?(this.removeValue(e),c=!0,p&&this._hasTextInput&&this.inputRef.value&&this.inputRef.value.type!=="hidden"&&(this.inputRef.value.value="")):n&&p?(this.removeAllSelected(),c=!0):p?(this._value[0]&&this.removeSelected(this._value[0]),this.setSelected(e),c=!1):f&&!_?(this.setSelected(e),c=!0):f&&_?(g="Maks antall valg nådd",x=!1,O=t):(p&&this.removeAllSelected(),g="Ingen gyldig verdi valgt",x=!1,c=!0,O=t),this._isOptionsOpen=c,c||(p&&this._hasTextInput&&(this._suppressNextOpen=!0),window.setTimeout(()=>{this.focusTrigger()},0)),this._userInfoMessage=g,this._search=O||"",this.resetComboboxInput(x),f&&this.updateMaxReached())}setSelected(t){if(!this._value.includes(t)){if(this.multiple&&u.isMaxSelectionReached(this._value.length,this.maxlength)){this._userInfoMessage="Maks antall valg nådd";return}!this.multiple&&this.removeAllSelected(),this._value=t?[...this._value,t]:this._value,m.markOptionSelected(this._options,t),this.resetComboboxInput(!0)}}removeSelected(t){if(!t)return;this._value=this._value.filter(s=>s!==t);const e=u.findOptionByValue(this.options,t);e&&(m.markOptionDeselected(this.options,t),e.userAdded?(this._options=[...this._options.filter(s=>s.value!==t)],this.options=[...this.options.filter(s=>s.value!==t)]):this._options.some(s=>s.value===t)||(this._options=[...this._options,e]))}addAllOptions(){if(this.multiple){if(this.maxlength&&this._options.length>this.maxlength){this._userInfoMessage="For mange valgt";return}this._value=this._options.map(t=>t.value),m.markAllSelected(this._options),this.requestUpdate()}}removeAllSelected(){this._value=[],m.markAllDeselected(this._options),this._options=m.removeUserAddedOptions(this._options),this.requestUpdate()}addValue(){var e;const t=((e=this.inputRef.value)==null?void 0:e.value.trim())||"";if(this._search=t,t&&this._value.includes(t)){this.resetComboboxInput(!0),this._userInfoMessage="Verdien er allerede valgt";return}this.toggleValue(t)}removeValue(t){this._value=this.multiple?this._value.filter(e=>e!==t):[],this.removeSelected(t)}addNewUserValue(t){if(!t||t.trim()==="")return;if(!this.multiple)this._value[0]&&this.removeSelected(this._value[0]),this._value=[t];else if(!u.findOptionByValue(this.options,t)){if(u.isMaxSelectionReached(this._value.length,this.maxlength))return;this._value=[...this._value,t]}const e={value:t,label:t,userAdded:!0,selected:!0};this.options=[e,...this.options],this._options=[e,...this._options],this.resetComboboxInput(!0),this.multiple||(this._isOptionsOpen=!1,this._hasTextInput&&(this._suppressNextOpen=!0),window.setTimeout(()=>{this.focusTrigger()},0)),this.requestUpdate()}resetComboboxInput(t=!0){this._addValueText=null,this.inputRef.value&&this.inputRef.value.type!=="hidden"&&t&&(this._search="",this.multiple?this.inputRef.value.value="":(this.inputRef.value.value=this._value[0]?y(this._value[0],this.options,this.displayValueAs):"",this._userInfoMessage="")),this._options=[...this.options]}removeLastValue(t){if(this._value.length===0)return;t.preventDefault();const e=this._value[this._value.length-1];e&&this.removeSelected(e),this.updateMaxReached()}}class N extends E{handleInput(t){if(t.stopPropagation(),t.stopImmediatePropagation(),this.disabled)return;this.touched=!0;const e=t.target;if(this._search=e.value,this.checkForMatches(),this.typeahead)if(this._search){const{filtered:s,suggestion:i}=u.findTypeaheadMatches(this.options,this._search);this._options=s,t.inputType!=="deleteContentBackward"&&(i!=null&&i.label)&&this.inputRef.value&&this.inputRef.value.type!=="hidden"&&(e.value=i.label,window.setTimeout(()=>e.setSelectionRange(this._search.length,e.value.length),0),e.selectionDirection="backward")}else this._options=[...this.options]}handleFocus(){if(!this.disabled){if(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=y(this._value[0],this.options,this.displayValueAs)),this._inputFocus=!0,this._search="",this._options=[...this.options],this._isOptionsOpen=!0,this.onFocus(),this.requestUpdate()}}handleFocusOut(t){var i,l;if(this.disabled||!this._isOptionsOpen)return;const e=t.relatedTarget;((i=e==null?void 0:e.closest("pkt-combobox"))==null?void 0:i.id)===this.id||((l=t.target)==null?void 0:l.getAttribute("data-focusfix"))===this.id||e===this.inputRef.value||e===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"){const t=this.inputRef.value.value;if(this.multiple){if(t!==""){const{action:e,value:s}=U(t,this._value,this.options,this.allowUserInput,this.multiple);switch(e){case"addUserValue":this.addNewUserValue(s);break;case"selectOption":this.setSelected(s);break;case"removeValue":this.removeValue(s);break}}}else if(!t)this._value[0]&&this.removeSelected(this._value[0]);else{const e=u.findOptionByValue(this.options,t);e&&e.value!==this._value[0]?(this._value[0]&&this.removeSelected(this._value[0]),this.setSelected(e.value)):!e&&this.allowUserInput&&(this._value[0]&&this.removeSelected(this._value[0]),this.addNewUserValue(t))}!this.multiple&&this._value[0]?this.inputRef.value.value=y(this._value[0],this.options,this.displayValueAs):this.inputRef.value.value=""}this._isOptionsOpen=!1,this.onBlur()}handleBlur(){this._inputFocus=!1,this.onBlur()}handleInputClick(t){var e,s;if(this.disabled){t.preventDefault(),t.stopImmediatePropagation();return}this._hasTextInput?((e=this.inputRef.value)==null||e.focus(),this.requestUpdate()):(t.stopImmediatePropagation(),t.preventDefault(),this._isOptionsOpen=!this._isOptionsOpen,this._isOptionsOpen&&((s=this.listboxRef.value)==null||s.focusFirstOrSelectedOption()))}handlePlaceholderClick(t){this.disabled||(t.stopPropagation(),this._hasTextInput&&this.inputRef.value?(this.inputRef.value.focus(),this._inputFocus=!0,this.requestUpdate()):(this._isOptionsOpen=!this._isOptionsOpen,this.requestUpdate()))}handleSelectOnlyKeydown(t){var e,s;if(!this.disabled)switch(t.key){case"Enter":case" ":case"ArrowDown":case"ArrowUp":t.preventDefault(),this._isOptionsOpen?this._isOptionsOpen=!1:(this._isOptionsOpen=!0,(e=this.listboxRef.value)==null||e.focusFirstOrSelectedOption());break;case"Escape":this._isOptionsOpen&&(t.preventDefault(),this._isOptionsOpen=!1);break;case"Home":case"End":t.preventDefault(),this._isOptionsOpen||(this._isOptionsOpen=!0),(s=this.listboxRef.value)==null||s.focusFirstOrSelectedOption();break;case"ArrowLeft":this.multiple&&this._value.length>0&&(t.preventDefault(),this.focusTag(this._value.length-1));break;case"Backspace":case"Delete":this.multiple&&this._value.length>0&&(t.preventDefault(),this.removeSelected(this._value[this._value.length-1]));break}}handleOptionToggled(t){this.toggleValue(t.detail)}handleSearch(t){t.stopPropagation(),this._search=t.detail.toLowerCase(),this.checkForMatches()}handleInputKeydown(t){var s,i,l;if(t.key==="Backspace"){const n=!((s=this.inputRef.value)!=null&&s.value);!this._search&&n&&this.multiple&&this._value.length>0&&this.removeLastValue(t);return}if(t.key==="ArrowLeft"&&this.multiple&&this._value.length>0){const n=this.inputRef.value;if(n&&n.selectionStart===0&&!n.value){t.preventDefault(),this.focusTag(this._value.length-1);return}}const e=M(t.key,t.shiftKey,this.multiple);if(e&&!(t.key==="Tab"&&!this._isOptionsOpen)){if(e==="focusListbox"&&t.key==="Tab"&&!((i=this.listboxRef.value)==null?void 0:i.querySelector('[role="option"]:not([data-disabled]), [data-type="new-option"]'))){this.closeAndProcessInput();return}switch(t.preventDefault(),e){case"addValue":this.addValue();break;case"focusListbox":(l=this.listboxRef.value)==null||l.focusFirstOrSelectedOption();break;case"closeOptions":this._isOptionsOpen=!1;break}}}handleTagRemove(t){this.removeSelected(t),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(t){var i;const e=this.getInsideTags();e.forEach((l,n)=>{l.buttonTabindex=n===t?0:-1});const s=(i=e[t])==null?void 0:i.querySelector("button");s==null||s.focus()}resetTagTabindices(){this.getInsideTags().forEach(e=>{e.buttonTabindex=-1})}handleTagKeydown(t,e){t.stopPropagation();const s=()=>{var i;this.resetTagTabindices(),this._hasTextInput&&this.inputRef.value?this.inputRef.value.focus():(i=this.triggerRef.value)==null||i.focus()};switch(t.key){case"ArrowLeft":t.preventDefault(),e>0&&this.focusTag(e-1);break;case"ArrowRight":t.preventDefault(),e<this._value.length-1?this.focusTag(e+1):s();break;case"Backspace":case"Delete":t.preventDefault();{const i=this._value[e],l=e>=this._value.length-1?e-1:e;this.removeSelected(i),l>=0?(this.requestUpdate(),this.updateComplete.then(()=>this.focusTag(l))):s()}break;case"Tab":this.resetTagTabindices();break;case"Escape":t.preventDefault(),s();break}}checkForMatches(){var s;const t=((s=this.inputRef.value)==null?void 0:s.value)||this._search||"",e=D(t,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}}class T extends N{constructor(){super(...arguments),this.handleBodyClick=t=>{this._isOptionsOpen&&!this.contains(t.target)&&this.closeAndProcessInput()}}connectedCallback(){var t,e;if(super.connectedCallback(),document==null||document.body.addEventListener("click",this.handleBodyClick),this._options=[],this.defaultOptions&&this.defaultOptions.length){const s=((t=this.options)==null?void 0:t.filter(i=>i.userAdded))||[];this.options=[...s,...JSON.parse(JSON.stringify(this.defaultOptions))],this._options=Array.isArray(this.options)?[...this.options]:[]}if((e=this.optionsController)!=null&&e.nodes&&this.optionsController.nodes.length){const s=A.parseOptionsFromSlot(this.optionsController.nodes);s.length&&(this.options=[...s],this._options=[...s],this._optionsFromSlot=!0,this._lastSlotGeneration=this.optionsController.generation)}}willUpdate(t){if(this._optionsFromSlot&&this.optionsController){const e=this.optionsController.generation;if(e!==this._lastSlotGeneration){this._lastSlotGeneration=e;const s=A.parseOptionsFromSlot(this.optionsController.nodes),i=this._options.filter(l=>l.userAdded);this.options=[...i,...s]}}super.willUpdate(t)}disconnectedCallback(){super.disconnectedCallback(),document==null||document.body.removeEventListener("click",this.handleBodyClick)}firstUpdated(t){this.defaultValue!==null&&!this.value&&(this.value=this.defaultValue),super.firstUpdated(t)}updated(t){t.has("isOpen")&&(this._isOptionsOpen=this.isOpen);const e=t.has("value"),s=t.has("_value");if(e&&this._internalValueSync)this._internalValueSync=!1,s&&this.syncValueAndDispatch(t.get("_value"));else if(e){const l=[...this._value],n=this.parseValue();n.join(",")!==this._value.join(",")&&(this._value=n),this.updateMaxReached(),this.syncValueAndDispatch(l)}else s&&this.syncValueAndDispatch(t.get("_value"));if(t.has("defaultOptions")&&this.defaultOptions.length){const l=(Array.isArray(this.options)?this.options:[]).filter(n=>n.userAdded)||[];this.options=[...l,...JSON.parse(JSON.stringify(this.defaultOptions))],this._options=Array.isArray(this.options)?[...this.options]:[]}if(t.has("options")){const l=t.get("options")||this._options||[],n=k.mergeWithUserAdded(this.options,l);this._options=n,n.length>this.options.length&&(this.options=n);const p=k.syncOptionsWithValues(this._options,this._value);if(this._options=p.options,p.newValues.length>this._value.length){const f=[...this._value];this._value=p.newValues,this.syncValueAndDispatch(f)}}if(t.has("_search")&&this.dispatchEvent(new CustomEvent("search",{detail:this._search,bubbles:!1})),!this._isOptionsOpen&&!this.multiple&&this._hasTextInput&&this.inputRef.value&&this.inputRef.value.type!=="hidden"){const l=this._value[0]?y(this._value[0],this.options,this.displayValueAs):"";this.inputRef.value.value!==l&&(this.inputRef.value.value=l)}super.updated(t)}formResetCallback(){this.touched=!1;const t=this.defaultValue||(this.multiple,"");this.value=t,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(t,e,s){if(t==="options"){this._options=Array.isArray(this.options)?[...this.options]:[];const i=k.syncOptionsWithValues(this._options,this._value);this._options=i.options,i.newValues.length>this._value.length&&(this._value=i.newValues),this._search=""}super.attributeChangedCallback(t,e,s)}render(){return o.b`
|
|
2
2
|
<pkt-input-wrapper
|
|
3
3
|
.label=${this.label}
|
|
4
4
|
.helptext=${this.helptext}
|
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
class="pkt-combobox__wrapper"
|
|
21
21
|
@labelClick=${this.handleInputClick}
|
|
22
22
|
>
|
|
23
|
-
<div class="pkt-contents" slot="helptext">${
|
|
23
|
+
<div class="pkt-contents" slot="helptext">${w.slotContent(this,"helptext")}</div>
|
|
24
24
|
<div class="pkt-combobox" @focusout=${this.handleFocusOut}>
|
|
25
25
|
<div
|
|
26
26
|
class=${V.e({"pkt-combobox__input":!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})}
|
|
@@ -108,7 +108,7 @@
|
|
|
108
108
|
/>
|
|
109
109
|
`}renderSingleOrMultipleValues(){if(!this.multiple&&this._hasTextInput)return o.A;const t=!this.multiple,e=this.renderValueTag(u.findOptionByValue(this.options,this._value[0])),s=this.tagPlacement==="outside",i=o.b`
|
|
110
110
|
<ul role="list" class="pkt-combobox__tag-list">
|
|
111
|
-
${
|
|
111
|
+
${R.c(this._value,l=>l,(l,n)=>{const p=u.findOptionByValue(this.options,l),f=p==null?void 0:p.tagSkinColor;return o.b`
|
|
112
112
|
<li
|
|
113
113
|
role="listitem"
|
|
114
114
|
@click=${s?o.A:_=>_.stopPropagation()}
|
|
@@ -132,4 +132,4 @@
|
|
|
132
132
|
>${t.value}</span
|
|
133
133
|
>`;case"label":default:return o.b`<span class="pkt-combobox__value" data-focusfix=${this.id}
|
|
134
134
|
>${t.label||t.value}</span
|
|
135
|
-
>`}}}
|
|
135
|
+
>`}}}try{o.t("pkt-combobox")(T)}catch{console.warn("Forsøker å definere <pkt-combobox>, men den er allerede definert")}exports.PktCombobox=T;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";const n=require("./element-gR_VtSiD.cjs");require("./button-B_TXwNzt.cjs");require("./icon-q81vqPK_.cjs");const k={i18n:{nb:{contentPresentation:{title:"Oslo kommune bruker informasjonskapsler",description:["For at nettstedet skal fungere og være trygt, bruker Oslo kommune informasjonskapsler. Noen er teknisk nødvendige, mens andre sikrer ulik funksjonalitet.","Godtar du alle informasjonskapsler, tillater du også at vi samler inn data om statistikk og brukeradferd. Da hjelper du oss med å lage et bedre nettsted uten at du trenger å dele noe personlig informasjon med oss."],buttons:{accept:"Godta alle",reject:"Kun nødvendige",settings:"Innstillinger for informasjonskapsler"}},contentSettings:{title:"Innstillinger for informasjonskapsler",description:["Her kan du velge hvilke typer informasjonskapsler du vil tillate. Tillatelsen gjelder i 90 dager. Husk at nødvendige informasjonskapsler ikke kan velges bort.","Du kan når som helst endre innstillingene og finne mer informasjon nederst på nettstedet under «Innstillinger for informasjonskapsler» og «Personvern og informasjonskapsler»."],buttons:{back:"Tilbake",save:"Lagre innstillinger"}}},en:{contentPresentation:{title:"Before you visit Oslo kommune ...",description:["This website uses cookies to make improvements. In this context, we need your consent to measure the traffic on the website in relation to statistics and feedback.","To read more about what we use cookies for, go to our privacy declaration which you will find at the bottom of our websites."],buttons:{accept:"Yes, I accept",reject:"Only necessary",settings:"Go to settings"}},contentSettings:{title:"Her kan du aktivt velge mellom ulike informasjonskapsler",description:["For å lese mer om hva vi bruker informasjonskapsler til gå til vår personvernserklering som du finner på våre nettsider"],buttons:{back:"Back",save:"Save settings"}}}}};var p=Object.defineProperty,r=(a,e,t,o)=>{for(var i=void 0,c=a.length-1,d;c>=0;c--)(d=a[c])&&(i=d(e,t,i)||i);return i&&p(e,t,i),i};let l=null;function u(){return l||(l=new Promise((a,e)=>{if(document.querySelector("#oslo-consent-script")){a();return}const t=document.createElement("script");t.src="https://cdn.web.oslo.kommune.no/cb/cb-v1.1.0.js",t.id="oslo-consent-script",t.onload=()=>a(),t.onerror=e,document.head.appendChild(t);const o=document.createElement("link");o.href="https://cdn.web.oslo.kommune.no/cb/cb-v1.1.0.css",o.type="text/css",o.rel="stylesheet",o.id="oslo-consent-styles",document.head.appendChild(o)}),l)}class s extends n.PktElement{constructor(){super(),this.devMode=!1,this.hotjarId=null,this.googleAnalyticsId=null,this.cookieDomain=null,this.cookieSecure=null,this.cookieExpiryDays=null,this.triggerType="button",this.triggerText=null,this.i18nLanguage="nb"}connectedCallback(){super.connectedCallback(),this.triggerText=this.triggerText||k.i18n[this.i18nLanguage].contentPresentation.buttons.settings}disconnectedCallback(){var e;super.disconnectedCallback(),this._cookieEventHandler&&((e=window.__cookieEvents)==null||e.off("CookieManager.setCookie",this._cookieEventHandler))}returnJsonOrObject(e){let t;try{t=JSON.parse(e)}catch{t=e}return t}emitCookieConsents(e){const o=this.returnJsonOrObject(e.value).items.reduce((i,c)=>(i[c.name]=c.consent,i),{});this.dispatchEvent(new CustomEvent("toggle-consent",{detail:o,bubbles:!0,cancelable:!1}))}async firstUpdated(e){window.cookieBanner_googleAnalyticsId=this.googleAnalyticsId,window.cookieBanner_hotjarId=this.hotjarId,this.cookieDomain&&(window.cookieBanner_cookieDomain=this.cookieDomain),this.cookieSecure&&(window.cookieBanner_cookieSecure=this.cookieSecure),this.cookieExpiryDays&&(window.cookieBanner_cookieExpiryDays=this.cookieExpiryDays),this.devMode&&(window.cookieBanner_devMode=this.devMode),await u(),this.triggerInit()}triggerInit(){window.document.dispatchEvent(new Event("CookieBannerReady",{bubbles:!0,cancelable:!0})),window.cookieBanner.cookieConsent.validateConsentCookie().then(e=>{if(e){const o={value:window.cookieBanner.cookieConsent.getConsentCookie()};window.setTimeout(()=>this.emitCookieConsents(o),0),this._cookieEventHandler&&window.__cookieEvents.off("CookieManager.setCookie",this._cookieEventHandler),this._cookieEventHandler=i=>{this.emitCookieConsents(i)},window.__cookieEvents.on("CookieManager.setCookie",this._cookieEventHandler)}})}openModal(e){var t;e.preventDefault(),(t=window.cookieBanner)!=null&&t.cookieConsent||this.triggerInit(),setTimeout(()=>window.cookieBanner.openCookieModal())}render(){return this.triggerType==="link"?n.b`<a href="#" class="pkt-link" @click=${this.openModal}>${this.triggerText}</a>`:this.triggerType==="footerlink"?n.b`<a href="#" class="pkt-footer__link" @click=${this.openModal}>
|
|
2
|
+
<pkt-icon name="chevron-right" class="pkt-footer__link-icon"></pkt-icon>
|
|
3
|
+
${this.triggerText}
|
|
4
|
+
</a>`:this.triggerType==="icon"?n.b`<pkt-button
|
|
5
|
+
skin="tertiary"
|
|
6
|
+
variant="icon-only"
|
|
7
|
+
iconName="cookie"
|
|
8
|
+
@click=${this.openModal}
|
|
9
|
+
>
|
|
10
|
+
>${this.triggerText}</pkt-button
|
|
11
|
+
>`:n.b`<pkt-button @click=${this.openModal}>${this.triggerText}</pkt-button>`}}r([n.n({type:Boolean})],s.prototype,"devMode");r([n.n({type:String})],s.prototype,"hotjarId");r([n.n({type:String})],s.prototype,"googleAnalyticsId");r([n.n({type:String})],s.prototype,"cookieDomain");r([n.n({type:String})],s.prototype,"cookieSecure");r([n.n({type:String})],s.prototype,"cookieExpiryDays");r([n.n({type:String})],s.prototype,"triggerType");r([n.n({type:String})],s.prototype,"triggerText");r([n.n({type:String})],s.prototype,"i18nLanguage");try{n.t("pkt-consent")(s)}catch{console.warn("Forsøker å definere <pkt-consent>, men den er allerede definert")}exports.PktConsent=s;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./button-
|
|
3
|
-
import "./icon-
|
|
1
|
+
import { t as p, P as g, b as l, n as s } from "./element-CPpT3rFQ.js";
|
|
2
|
+
import "./button-BiY-wlKF.js";
|
|
3
|
+
import "./icon-CxQcIa5F.js";
|
|
4
4
|
const u = {
|
|
5
5
|
i18n: {
|
|
6
6
|
nb: {
|
|
@@ -54,25 +54,25 @@ const u = {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
};
|
|
57
|
-
var h = Object.defineProperty,
|
|
58
|
-
for (var
|
|
59
|
-
(
|
|
60
|
-
return
|
|
57
|
+
var h = Object.defineProperty, r = (a, e, t, o) => {
|
|
58
|
+
for (var n = void 0, c = a.length - 1, k; c >= 0; c--)
|
|
59
|
+
(k = a[c]) && (n = k(e, t, n) || n);
|
|
60
|
+
return n && h(e, t, n), n;
|
|
61
61
|
};
|
|
62
|
-
let
|
|
63
|
-
function
|
|
64
|
-
return
|
|
62
|
+
let d = null;
|
|
63
|
+
function m() {
|
|
64
|
+
return d || (d = new Promise((a, e) => {
|
|
65
65
|
if (document.querySelector("#oslo-consent-script")) {
|
|
66
|
-
|
|
66
|
+
a();
|
|
67
67
|
return;
|
|
68
68
|
}
|
|
69
|
-
const
|
|
70
|
-
|
|
69
|
+
const t = document.createElement("script");
|
|
70
|
+
t.src = "https://cdn.web.oslo.kommune.no/cb/cb-v1.1.0.js", t.id = "oslo-consent-script", t.onload = () => a(), t.onerror = e, document.head.appendChild(t);
|
|
71
71
|
const o = document.createElement("link");
|
|
72
72
|
o.href = "https://cdn.web.oslo.kommune.no/cb/cb-v1.1.0.css", o.type = "text/css", o.rel = "stylesheet", o.id = "oslo-consent-styles", document.head.appendChild(o);
|
|
73
|
-
}),
|
|
73
|
+
}), d);
|
|
74
74
|
}
|
|
75
|
-
|
|
75
|
+
class i extends g {
|
|
76
76
|
constructor() {
|
|
77
77
|
super(), this.devMode = !1, this.hotjarId = null, this.googleAnalyticsId = null, this.cookieDomain = null, this.cookieSecure = null, this.cookieExpiryDays = null, this.triggerType = "button", this.triggerText = null, this.i18nLanguage = "nb";
|
|
78
78
|
}
|
|
@@ -93,17 +93,17 @@ let i = class extends p {
|
|
|
93
93
|
return t;
|
|
94
94
|
}
|
|
95
95
|
emitCookieConsents(e) {
|
|
96
|
-
const
|
|
96
|
+
const o = this.returnJsonOrObject(e.value).items.reduce((n, c) => (n[c.name] = c.consent, n), {});
|
|
97
97
|
this.dispatchEvent(
|
|
98
98
|
new CustomEvent("toggle-consent", {
|
|
99
|
-
detail:
|
|
99
|
+
detail: o,
|
|
100
100
|
bubbles: !0,
|
|
101
101
|
cancelable: !1
|
|
102
102
|
})
|
|
103
103
|
);
|
|
104
104
|
}
|
|
105
105
|
async firstUpdated(e) {
|
|
106
|
-
window.cookieBanner_googleAnalyticsId = this.googleAnalyticsId, window.cookieBanner_hotjarId = this.hotjarId, this.cookieDomain && (window.cookieBanner_cookieDomain = this.cookieDomain), this.cookieSecure && (window.cookieBanner_cookieSecure = this.cookieSecure), this.cookieExpiryDays && (window.cookieBanner_cookieExpiryDays = this.cookieExpiryDays), this.devMode && (window.cookieBanner_devMode = this.devMode), await
|
|
106
|
+
window.cookieBanner_googleAnalyticsId = this.googleAnalyticsId, window.cookieBanner_hotjarId = this.hotjarId, this.cookieDomain && (window.cookieBanner_cookieDomain = this.cookieDomain), this.cookieSecure && (window.cookieBanner_cookieSecure = this.cookieSecure), this.cookieExpiryDays && (window.cookieBanner_cookieExpiryDays = this.cookieExpiryDays), this.devMode && (window.cookieBanner_devMode = this.devMode), await m(), this.triggerInit();
|
|
107
107
|
}
|
|
108
108
|
triggerInit() {
|
|
109
109
|
window.document.dispatchEvent(
|
|
@@ -113,9 +113,9 @@ let i = class extends p {
|
|
|
113
113
|
})
|
|
114
114
|
), window.cookieBanner.cookieConsent.validateConsentCookie().then((e) => {
|
|
115
115
|
if (e) {
|
|
116
|
-
const
|
|
117
|
-
window.setTimeout(() => this.emitCookieConsents(
|
|
118
|
-
this.emitCookieConsents(
|
|
116
|
+
const o = { value: window.cookieBanner.cookieConsent.getConsentCookie() };
|
|
117
|
+
window.setTimeout(() => this.emitCookieConsents(o), 0), this._cookieEventHandler && window.__cookieEvents.off("CookieManager.setCookie", this._cookieEventHandler), this._cookieEventHandler = (n) => {
|
|
118
|
+
this.emitCookieConsents(n);
|
|
119
119
|
}, window.__cookieEvents.on("CookieManager.setCookie", this._cookieEventHandler);
|
|
120
120
|
}
|
|
121
121
|
});
|
|
@@ -125,49 +125,51 @@ let i = class extends p {
|
|
|
125
125
|
e.preventDefault(), (t = window.cookieBanner) != null && t.cookieConsent || this.triggerInit(), setTimeout(() => window.cookieBanner.openCookieModal());
|
|
126
126
|
}
|
|
127
127
|
render() {
|
|
128
|
-
return this.triggerType === "link" ?
|
|
128
|
+
return this.triggerType === "link" ? l`<a href="#" class="pkt-link" @click=${this.openModal}>${this.triggerText}</a>` : this.triggerType === "footerlink" ? l`<a href="#" class="pkt-footer__link" @click=${this.openModal}>
|
|
129
129
|
<pkt-icon name="chevron-right" class="pkt-footer__link-icon"></pkt-icon>
|
|
130
130
|
${this.triggerText}
|
|
131
|
-
</a>` : this.triggerType === "icon" ?
|
|
131
|
+
</a>` : this.triggerType === "icon" ? l`<pkt-button
|
|
132
132
|
skin="tertiary"
|
|
133
133
|
variant="icon-only"
|
|
134
134
|
iconName="cookie"
|
|
135
135
|
@click=${this.openModal}
|
|
136
136
|
>
|
|
137
137
|
>${this.triggerText}</pkt-button
|
|
138
|
-
>` :
|
|
138
|
+
>` : l`<pkt-button @click=${this.openModal}>${this.triggerText}</pkt-button>`;
|
|
139
139
|
}
|
|
140
|
-
}
|
|
140
|
+
}
|
|
141
141
|
r([
|
|
142
|
-
|
|
143
|
-
], i.prototype, "devMode"
|
|
142
|
+
s({ type: Boolean })
|
|
143
|
+
], i.prototype, "devMode");
|
|
144
144
|
r([
|
|
145
|
-
|
|
146
|
-
], i.prototype, "hotjarId"
|
|
145
|
+
s({ type: String })
|
|
146
|
+
], i.prototype, "hotjarId");
|
|
147
147
|
r([
|
|
148
|
-
|
|
149
|
-
], i.prototype, "googleAnalyticsId"
|
|
148
|
+
s({ type: String })
|
|
149
|
+
], i.prototype, "googleAnalyticsId");
|
|
150
150
|
r([
|
|
151
|
-
|
|
152
|
-
], i.prototype, "cookieDomain"
|
|
151
|
+
s({ type: String })
|
|
152
|
+
], i.prototype, "cookieDomain");
|
|
153
153
|
r([
|
|
154
|
-
|
|
155
|
-
], i.prototype, "cookieSecure"
|
|
154
|
+
s({ type: String })
|
|
155
|
+
], i.prototype, "cookieSecure");
|
|
156
156
|
r([
|
|
157
|
-
|
|
158
|
-
], i.prototype, "cookieExpiryDays"
|
|
157
|
+
s({ type: String })
|
|
158
|
+
], i.prototype, "cookieExpiryDays");
|
|
159
159
|
r([
|
|
160
|
-
|
|
161
|
-
], i.prototype, "triggerType"
|
|
160
|
+
s({ type: String })
|
|
161
|
+
], i.prototype, "triggerType");
|
|
162
162
|
r([
|
|
163
|
-
|
|
164
|
-
], i.prototype, "triggerText"
|
|
163
|
+
s({ type: String })
|
|
164
|
+
], i.prototype, "triggerText");
|
|
165
165
|
r([
|
|
166
|
-
|
|
167
|
-
], i.prototype, "i18nLanguage"
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
166
|
+
s({ type: String })
|
|
167
|
+
], i.prototype, "i18nLanguage");
|
|
168
|
+
try {
|
|
169
|
+
p("pkt-consent")(i);
|
|
170
|
+
} catch {
|
|
171
|
+
console.warn("Forsøker å definere <pkt-consent>, men den er allerede definert");
|
|
172
|
+
}
|
|
171
173
|
export {
|
|
172
174
|
i as P
|
|
173
175
|
};
|
|
@@ -0,0 +1,273 @@
|
|
|
1
|
+
"use strict";const l=require("./element-gR_VtSiD.cjs"),F=require("./state-Dg-53wQ8.cjs"),u=require("./calendar-B2pji2zn.cjs"),V=require("./input-element-DdVhUvva.cjs"),p=require("./ref-CL-Xk9Xm.cjs");require("./icon-q81vqPK_.cjs");require("./input-wrapper-Bv9aqqVq.cjs");const $=require("./class-map-CsENJXf1.cjs"),j=require("./repeat-Cfq8CDlf.cjs");require("./tag-CbwO8yvD.cjs");const q=require("./utils-byXsEz1u.cjs"),g=require("./if-defined-BOW3ODSj.cjs"),K=require("./element-with-slot-ZX-up7jO.cjs"),L={calendar:{buttonAltText:"Åpne kalender"}},U={calendar:{buttonAltText:"Åpne kalender"},generic:{from:"Fra",to:"Til"}};var N=Object.defineProperty,R=(i,e,t,a)=>{for(var s=void 0,r=i.length-1,n;r>=0;r--)(n=i[r])&&(s=n(e,t,s)||s);return s&&N(e,t,s),s};class k extends l.PktElement{constructor(){super(...arguments),this.dates=[],this.dateformat="dd.MM.yyyy",this.className="pkt-datepicker__tags",this.idBase=q.uuidish()}render(){return this.classes={"pkt-date-tags":!0,[this.className]:!0},l.b`
|
|
2
|
+
<div class=${$.e(this.classes)} aria-live="polite">
|
|
3
|
+
${Array.isArray(this.dates)&&this.dates[0]?j.c(u.sortDateStrings((this.dates??[]).filter(Boolean)),e=>e,e=>{var t;return l.b` <pkt-tag
|
|
4
|
+
id=${this.idBase+e+"-tag"}
|
|
5
|
+
closeTag
|
|
6
|
+
@close=${()=>{this.dispatchEvent(new CustomEvent("date-tag-removed",{detail:e}))}}
|
|
7
|
+
.ariaLabel=${`${(t=this.strings)==null?void 0:t.calendar.deleteDate} ${u.fromISOtoLocal(e,this.dateformat)}`}
|
|
8
|
+
>
|
|
9
|
+
<time datetime=${e}>${u.fromISOtoLocal(e,this.dateformat)}</time>
|
|
10
|
+
</pkt-tag>`}):l.A}
|
|
11
|
+
</div>
|
|
12
|
+
`}}R([l.n({type:Array})],k.prototype,"dates");R([l.n({type:String})],k.prototype,"dateformat");R([l.n({type:String,attribute:"class"})],k.prototype,"className");R([l.n({type:String,attribute:"id-base"})],k.prototype,"idBase");try{l.t("pkt-date-tags")(k)}catch{console.warn("Forsøker å definere <pkt-date-tags>, men den er allerede definert")}const z={dateformat:{default:"dd.MM.yyyy"},weeknumbers:{default:!1},withcontrols:{default:!1},multiple:{default:!1},range:{default:!1}},C={props:z},b=()=>{const i=navigator.userAgent;return!!(/iP(hone|od|ad)/.test(i)||/Macintosh/.test(i)&&"ontouchend"in document)},W=()=>b()?"text":"date",H=i=>!i||i.length!==2?!0:u.isValidDateRange(i[0],i[1]),G=i=>u.sortDateStrings(i),J=(i,e,t,a,s)=>u.filterSelectableDates(i,e,t,a,s),Q=(i,e,t,a,s,r)=>({"pkt-input":!0,"pkt-datepicker__input":!0,"pkt-input--fullwidth":i,"pkt-datepicker--hasrangelabels":e,"pkt-datepicker--multiple":t,"pkt-datepicker--range":a,"ios-readonly-hack":s===!1&&r==="text"}),X=()=>({"pkt-input-icon":!0,"pkt-btn":!0,"pkt-btn--icon-only":!0,"pkt-btn--tertiary":!0,"pkt-datepicker__calendar-button":!0}),Y=i=>({"pkt-input-prefix":i,"pkt-hide":!i}),Z=(i,e,t)=>!e&&!t?Array.isArray(i)?i[0]||"":i:Array.isArray(i)?i.join(","):i,ee=(i,e,t=!1)=>{var o;if(!i||!e)return;const a=((o=e.parentElement)==null?void 0:o.getBoundingClientRect())||e.getBoundingClientRect(),s=t?a.height+30:a.height,r=i.getBoundingClientRect().height;let n=t?"calc(100% - 30px)":"100%";a&&a.top+r>window.innerHeight&&a.top-r>0&&(n=`calc(100% - ${s}px - ${r}px)`),i.style.top=n},te=(i,e,t,a,s,r)=>{const{key:n}=i;n===","&&(i.preventDefault(),r?r(i):s&&s()),(n==="Space"||n===" ")&&(i.preventDefault(),e(i)),n==="Enter"&&(i.preventDefault(),t?t():a?a():s&&s())},se=(i,e)=>{const{key:t}=i;(t==="Enter"||t===" "||t==="Space")&&(i.preventDefault(),e(i))},A={validateRangeOrder:H,sortDates:G,filterSelectableDates:J},ie={getInputType:W},x={submitForm(i){var t;const e=(t=i.internals)==null?void 0:t.form;e&&e.requestSubmit()},submitFormOrFallback(i,e){const t=i==null?void 0:i.form;t?t.requestSubmit():e()},validateDateInput(i,e,t,a,s){var n,o,y,O;const r=i.value;r&&(t&&t>r?e.setValidity({rangeUnderflow:!0},((o=(n=s==null?void 0:s.forms)==null?void 0:n.messages)==null?void 0:o.rangeUnderflow)||"Value is below minimum",i):a&&a<r&&e.setValidity({rangeOverflow:!0},((O=(y=s==null?void 0:s.forms)==null?void 0:y.messages)==null?void 0:O.rangeOverflow)||"Value is above maximum",i))}},T={addToSelected(i,e,t,a){const s=i.target;if(!s.value)return;const r=t?u.newDate(t):null,n=a?u.newDate(a):null,o=u.newDate(s.value.split(",")[0]);o&&!isNaN(o.getTime())&&(!r||o>=r)&&(!n||o<=n)&&e.value&&e.value.handleDateSelect(o),s.value=""},handleCalendarPosition(i,e,t=!1){ee(i.value??null,e.value??null,t)}},P={getInputClasses:Q,getButtonClasses:X,getRangeLabelClasses:Y},I={processDateSelection:Z,updateInputValues(i,e,t,a,s,r){i.value&&(a&&(e!=null&&e.value)?(i.value.value=t[0]??"",e.value.value=t[1]??"",r(i.value),r(e.value)):s||(i.value.value=t.length?t[0]:"",r(i.value)))},processRangeBlur(i,e,t,a,s){var n;const r=i.target;if(r.value){s(r);const o=u.fromISOToDate(r.value);o&&((n=t==null?void 0:t.value)==null||n.handleDateSelect(o))}else e[0]&&a()}},_={handleInputKeydown:te,handleButtonKeydown:se};var ae=Object.defineProperty,f=(i,e,t,a)=>{for(var s=void 0,r=i.length-1,n;r>=0;r--)(n=i[r])&&(s=n(e,t,s)||s);return s&&ae(e,t,s),s};class c extends l.PktElement{constructor(){super(...arguments),this.open=!1,this.multiple=!1,this.range=!1,this.weeknumbers=!1,this.withcontrols=!1,this.maxMultiple=null,this.selected=[],this.earliest=null,this.latest=null,this.excludedates=[],this.excludeweekdays=[],this.currentmonth=null,this.today=null,this._hasBeenOpened=!1,this.popupRef=p.e(),this.calendarRef=p.e(),this.handleDocumentClick=e=>{if(!this.open)return;const t=e.composedPath(),a=this.parentElement,s=this.popupRef.value;!t.includes(this)&&!t.includes(s)&&!(a&&t.includes(a))&&(this.hide(),this.dispatchEvent(new CustomEvent("close",{bubbles:!0,composed:!0})))},this.handleDocumentKeydown=e=>{this.open&&e.key==="Escape"&&(this.hide(),this.dispatchEvent(new CustomEvent("close",{bubbles:!0,composed:!0})))}}firstUpdated(){this.calRef=this.calendarRef}updated(e){super.updated(e),e.has("open")&&(this.open?(this._hasBeenOpened=!0,document.addEventListener("keydown",this.handleDocumentKeydown),document.addEventListener("click",this.handleDocumentClick)):(document.removeEventListener("click",this.handleDocumentClick),document.removeEventListener("keydown",this.handleDocumentKeydown)))}disconnectedCallback(){super.disconnectedCallback(),document.removeEventListener("click",this.handleDocumentClick),document.removeEventListener("keydown",this.handleDocumentKeydown)}show(){var e;this.open=!0,(e=this.calendarRef.value)==null||e.focus()}hide(){this.open=!1}toggle(){this.open?this.hide():this.show()}contains(e){var t;return!!e&&!!((t=this.popupRef.value)!=null&&t.contains(e))}focusOnCurrentDate(){const e=this.calendarRef.value;e&&typeof e.focusOnCurrentDate=="function"&&e.focusOnCurrentDate()}addToSelected(e,t,a){if(this.calendarRef.value&&typeof T.addToSelected=="function")return T.addToSelected(e,this.calendarRef,t,a);const r=e.target;if(!r.value)return;const n=t?u.newDate(t):null,o=a?u.newDate(a):null,y=u.newDate(r.value.split(",")[0]);y&&!isNaN(y.getTime())&&(!n||y>=n)&&(!o||y<=o)&&this.handleDateSelect(y),r.value=""}handleDateSelect(e){const t=this.calendarRef.value;if(t&&typeof t.handleDateSelect=="function")return t.handleDateSelect(e);const a=u.formatISODate(e),r=this.selected.indexOf(a)>=0?this.selected.filter(n=>n!==a):[...this.selected,a];this.selected=r,this.dispatchEvent(new CustomEvent("date-selected",{detail:r,bubbles:!0,composed:!0}))}render(){const e={"pkt-calendar-popup":!0,show:this.open,hide:!this.open};return l.b`
|
|
13
|
+
<div
|
|
14
|
+
class="${$.e(e)}"
|
|
15
|
+
${p.n(this.popupRef)}
|
|
16
|
+
id="date-popup"
|
|
17
|
+
?hidden=${!this.open}
|
|
18
|
+
aria-hidden="${!this.open}"
|
|
19
|
+
>
|
|
20
|
+
${this.open||this._hasBeenOpened?l.b`<pkt-calendar
|
|
21
|
+
${p.n(this.calendarRef)}
|
|
22
|
+
?multiple=${this.multiple}
|
|
23
|
+
?range=${this.range}
|
|
24
|
+
?weeknumbers=${this.weeknumbers}
|
|
25
|
+
?withcontrols=${this.withcontrols}
|
|
26
|
+
.maxMultiple=${this.maxMultiple}
|
|
27
|
+
.selected=${this.selected}
|
|
28
|
+
.earliest=${this.earliest}
|
|
29
|
+
.latest=${this.latest}
|
|
30
|
+
.excludedates=${this.excludedates}
|
|
31
|
+
.excludeweekdays=${this.excludeweekdays}
|
|
32
|
+
.currentmonth=${this.currentmonth}
|
|
33
|
+
.today=${this.today}
|
|
34
|
+
@date-selected=${t=>{this.selected=t.detail,this.dispatchEvent(new CustomEvent("date-selected",{detail:t.detail,bubbles:!0,composed:!0}))}}
|
|
35
|
+
@close=${()=>{this.hide(),this.dispatchEvent(new CustomEvent("close",{bubbles:!0,composed:!0}))}}
|
|
36
|
+
></pkt-calendar>`:l.A}
|
|
37
|
+
</div>
|
|
38
|
+
`}}f([l.n({type:Boolean,reflect:!0})],c.prototype,"open");f([l.n({type:Boolean})],c.prototype,"multiple");f([l.n({type:Boolean})],c.prototype,"range");f([l.n({type:Boolean})],c.prototype,"weeknumbers");f([l.n({type:Boolean})],c.prototype,"withcontrols");f([l.n({type:Number})],c.prototype,"maxMultiple");f([l.n({type:Array})],c.prototype,"selected");f([l.n({type:String})],c.prototype,"earliest");f([l.n({type:String})],c.prototype,"latest");f([l.n({type:Array})],c.prototype,"excludedates");f([l.n({type:Array})],c.prototype,"excludeweekdays");f([l.n({type:String})],c.prototype,"currentmonth");f([l.n({type:String})],c.prototype,"today");f([F.r()],c.prototype,"_hasBeenOpened");try{l.t("pkt-datepicker-popup")(c)}catch{console.warn("Forsøker å definere <pkt-datepicker-popup>, men den er allerede definert")}var ne=Object.defineProperty,m=(i,e,t,a)=>{for(var s=void 0,r=i.length-1,n;r>=0;r--)(n=i[r])&&(s=n(e,t,s)||s);return s&&ne(e,t,s),s};class v extends l.PktElement{constructor(){super(...arguments),this.inputType="date",this.id="",this.readonly=!1,this.disabled=!1,this.inputClasses={},this.inputRef=p.e(),this.btnRef=p.e()}get inputElement(){return this.inputRef.value}get buttonElement(){return this.btnRef.value}get isInputReadonly(){return this.readonly||this.inputType==="text"}dispatchToggleCalendar(e){this.readonly||this.dispatchEvent(new CustomEvent("toggle-calendar",{detail:e,bubbles:!0,composed:!0}))}dispatchInput(e){this.dispatchEvent(new CustomEvent("input-change",{detail:e,bubbles:!0,composed:!0}))}dispatchFocus(){this.dispatchEvent(new CustomEvent("input-focus",{bubbles:!0,composed:!0}))}dispatchBlur(e){this.dispatchEvent(new CustomEvent("input-blur",{detail:e,bubbles:!0,composed:!0}))}dispatchChange(e){this.dispatchEvent(new CustomEvent("input-changed",{detail:e,bubbles:!0,composed:!0}))}renderCalendarButton(){var e;return l.b`
|
|
39
|
+
<button
|
|
40
|
+
class="${$.e(P.getButtonClasses())}"
|
|
41
|
+
type="button"
|
|
42
|
+
@click=${t=>this.dispatchToggleCalendar(t)}
|
|
43
|
+
@keydown=${t=>{const{key:a}=t;(a==="Enter"||a===" "||a==="Space")&&(t.preventDefault(),this.dispatchToggleCalendar(t))}}
|
|
44
|
+
?disabled=${this.disabled}
|
|
45
|
+
${this.btnRef}
|
|
46
|
+
>
|
|
47
|
+
<pkt-icon name="calendar"></pkt-icon>
|
|
48
|
+
<span class="pkt-btn__text">${((e=this.strings.calendar)==null?void 0:e.buttonAltText)||"Åpne kalender"}</span>
|
|
49
|
+
</button>
|
|
50
|
+
`}createRenderRoot(){return this}}m([l.n({type:String})],v.prototype,"inputType");m([l.n({type:String})],v.prototype,"id");m([l.n({type:String})],v.prototype,"min");m([l.n({type:String})],v.prototype,"max");m([l.n({type:String})],v.prototype,"placeholder");m([l.n({type:Boolean})],v.prototype,"readonly");m([l.n({type:Boolean})],v.prototype,"disabled");m([l.n({type:Object})],v.prototype,"inputClasses");m([l.n({type:Object})],v.prototype,"internals");var le=Object.defineProperty,M=(i,e,t,a)=>{for(var s=void 0,r=i.length-1,n;r>=0;r--)(n=i[r])&&(s=n(e,t,s)||s);return s&&le(e,t,s),s};class E extends v{constructor(){super(...arguments),this.value="",this.strings=L}dispatchManageValidity(e){this.dispatchEvent(new CustomEvent("manage-validity",{detail:e,bubbles:!0,composed:!0}))}render(){return l.b`
|
|
51
|
+
<div class="pkt-input__container">
|
|
52
|
+
<input
|
|
53
|
+
class="${$.e(this.inputClasses)}"
|
|
54
|
+
.type=${this.inputType}
|
|
55
|
+
id="${this.id}-input"
|
|
56
|
+
.value=${this.value}
|
|
57
|
+
min=${g.o(this.min)}
|
|
58
|
+
max=${g.o(this.max)}
|
|
59
|
+
placeholder=${g.o(this.placeholder)}
|
|
60
|
+
?readonly=${this.isInputReadonly}
|
|
61
|
+
aria-describedby="${this.id}-helptext"
|
|
62
|
+
@click=${e=>{e.preventDefault(),this.dispatchToggleCalendar(e)}}
|
|
63
|
+
@touchend=${e=>{e.preventDefault(),this.dispatchToggleCalendar(e)}}
|
|
64
|
+
?disabled=${this.disabled}
|
|
65
|
+
@keydown=${e=>_.handleInputKeydown(e,t=>this.dispatchToggleCalendar(t),()=>x.submitFormOrFallback(this.internals,()=>{var t;return(t=this.inputRef.value)==null?void 0:t.blur()}),void 0,()=>{var t;return(t=this.inputRef.value)==null?void 0:t.blur()})}
|
|
66
|
+
@input=${e=>{this.dispatchInput(e),e.stopImmediatePropagation()}}
|
|
67
|
+
@focus=${()=>{this.dispatchFocus(),b()&&this.dispatchToggleCalendar(new Event("focus"))}}
|
|
68
|
+
@blur=${e=>{this.dispatchBlur(e),this.dispatchManageValidity(e.target),this.dispatchEvent(new CustomEvent("value-change",{detail:e.target.value,bubbles:!0,composed:!0}))}}
|
|
69
|
+
@change=${e=>{this.dispatchChange(e),e.stopImmediatePropagation()}}
|
|
70
|
+
${p.n(this.inputRef)}
|
|
71
|
+
/>
|
|
72
|
+
${this.renderCalendarButton()}
|
|
73
|
+
</div>
|
|
74
|
+
`}}M([l.n({type:String})],E.prototype,"value");M([l.n({type:Object})],E.prototype,"strings");try{l.t("pkt-datepicker-single")(E)}catch{console.warn("Forsøker å definere <pkt-datepicker-single>, men den er allerede definert")}var re=Object.defineProperty,S=(i,e,t,a)=>{for(var s=void 0,r=i.length-1,n;r>=0;r--)(n=i[r])&&(s=n(e,t,s)||s);return s&&re(e,t,s),s};class w extends v{constructor(){super(...arguments),this.value=[],this.label="",this.showRangeLabels=!1,this.strings=U,this.inputRefTo=p.e()}get inputElementTo(){return this.inputRefTo.value}render(){var t,a,s,r;const e=P.getRangeLabelClasses(this.showRangeLabels);return l.b`
|
|
75
|
+
<div class="pkt-input__container">
|
|
76
|
+
${this.showRangeLabels?l.b` <div class="pkt-input-prefix">${(t=this.strings.generic)==null?void 0:t.from}</div> `:l.A}
|
|
77
|
+
<input
|
|
78
|
+
class=${$.e(this.inputClasses)}
|
|
79
|
+
.type=${this.inputType}
|
|
80
|
+
id="${this.id}-input"
|
|
81
|
+
aria-label="${this.label} ${((a=this.strings.generic)==null?void 0:a.from)??"Fra"}"
|
|
82
|
+
.value=${this.value[0]??""}
|
|
83
|
+
min=${g.o(this.min)}
|
|
84
|
+
max=${g.o(this.max)}
|
|
85
|
+
placeholder=${g.o(this.placeholder)}
|
|
86
|
+
?readonly=${this.isInputReadonly}
|
|
87
|
+
?disabled=${this.disabled}
|
|
88
|
+
@click=${n=>{n.preventDefault(),this.dispatchToggleCalendar(n)}}
|
|
89
|
+
@touchend=${n=>{n.preventDefault(),this.dispatchToggleCalendar(n)}}
|
|
90
|
+
@keydown=${n=>_.handleInputKeydown(n,o=>this.dispatchToggleCalendar(o),()=>x.submitFormOrFallback(this.internals,()=>{var o;return(o=this.inputRefTo.value)==null?void 0:o.focus()}),()=>{var o;return(o=this.inputRefTo.value)==null?void 0:o.focus()},()=>{var o;return(o=this.inputRef.value)==null?void 0:o.blur()})}
|
|
91
|
+
@input=${n=>{this.dispatchInput(n),n.stopImmediatePropagation()}}
|
|
92
|
+
@focus=${()=>{this.dispatchFocus(),b()&&this.dispatchToggleCalendar(new Event("focus"))}}
|
|
93
|
+
@blur=${n=>{this.dispatchBlur(n),this.dispatchEvent(new CustomEvent("range-blur",{detail:{event:n,values:this.value,inputType:"from"},bubbles:!0,composed:!0}))}}
|
|
94
|
+
@change=${n=>{this.dispatchChange(n),n.stopImmediatePropagation()}}
|
|
95
|
+
${p.n(this.inputRef)}
|
|
96
|
+
/>
|
|
97
|
+
<div class="${$.e(e)}" id="${this.id}-to-label">
|
|
98
|
+
${(s=this.strings.generic)==null?void 0:s.to}
|
|
99
|
+
</div>
|
|
100
|
+
${this.showRangeLabels?l.A:l.b` <div class="pkt-input-separator">–</div> `}
|
|
101
|
+
<input
|
|
102
|
+
class=${$.e(this.inputClasses)}
|
|
103
|
+
.type=${this.inputType}
|
|
104
|
+
id="${this.id}-to"
|
|
105
|
+
aria-label="${this.label} ${((r=this.strings.generic)==null?void 0:r.to)??"Til"}"
|
|
106
|
+
.value=${this.value[1]??""}
|
|
107
|
+
min=${g.o(this.min)}
|
|
108
|
+
max=${g.o(this.max)}
|
|
109
|
+
placeholder=${g.o(this.placeholder)}
|
|
110
|
+
?readonly=${this.isInputReadonly}
|
|
111
|
+
?disabled=${this.disabled}
|
|
112
|
+
@click=${n=>{n.preventDefault(),this.dispatchToggleCalendar(n)}}
|
|
113
|
+
@touchend=${n=>{n.preventDefault(),this.dispatchToggleCalendar(n)}}
|
|
114
|
+
@keydown=${n=>_.handleInputKeydown(n,o=>this.dispatchToggleCalendar(o),()=>x.submitFormOrFallback(this.internals,()=>{var o;return(o=this.inputRefTo.value)==null?void 0:o.blur()}),void 0,()=>{var o;return(o=this.inputRefTo.value)==null?void 0:o.blur()})}
|
|
115
|
+
@input=${n=>{this.dispatchInput(n),n.stopImmediatePropagation()}}
|
|
116
|
+
@focus=${()=>{this.dispatchFocus(),b()&&this.dispatchToggleCalendar(new Event("focus"))}}
|
|
117
|
+
@blur=${n=>{this.dispatchBlur(n),this.dispatchEvent(new CustomEvent("range-blur",{detail:{event:n,values:this.value,inputType:"to"},bubbles:!0,composed:!0}))}}
|
|
118
|
+
@change=${n=>{this.dispatchChange(n),n.stopImmediatePropagation()}}
|
|
119
|
+
${p.n(this.inputRefTo)}
|
|
120
|
+
/>
|
|
121
|
+
${this.renderCalendarButton()}
|
|
122
|
+
</div>
|
|
123
|
+
`}}S([l.n({type:Array})],w.prototype,"value");S([l.n({type:String})],w.prototype,"label");S([l.n({type:Boolean})],w.prototype,"showRangeLabels");S([l.n({type:Object})],w.prototype,"strings");try{l.t("pkt-datepicker-range")(w)}catch{console.warn("Forsøker å definere <pkt-datepicker-range>, men den er allerede definert")}var oe=Object.defineProperty,B=(i,e,t,a)=>{for(var s=void 0,r=i.length-1,n;r>=0;r--)(n=i[r])&&(s=n(e,t,s)||s);return s&&oe(e,t,s),s};class D extends v{constructor(){super(...arguments),this.value=[],this.strings=L}get isInputDisabled(){return this.disabled||this.maxlength!==void 0&&this.maxlength!==null&&this.value.length>=this.maxlength}dispatchAddToSelected(e){this.dispatchEvent(new CustomEvent("add-to-selected",{detail:e,bubbles:!0,composed:!0}))}render(){return l.b`
|
|
124
|
+
<div class="pkt-input__container">
|
|
125
|
+
<input
|
|
126
|
+
class=${$.e(this.inputClasses)}
|
|
127
|
+
.type=${this.inputType}
|
|
128
|
+
id="${this.id}-input"
|
|
129
|
+
min=${g.o(this.min)}
|
|
130
|
+
max=${g.o(this.max)}
|
|
131
|
+
placeholder=${g.o(this.placeholder)}
|
|
132
|
+
?readonly=${this.isInputReadonly}
|
|
133
|
+
?disabled=${this.isInputDisabled}
|
|
134
|
+
@click=${e=>{e.preventDefault(),this.dispatchToggleCalendar(e)}}
|
|
135
|
+
@touchend=${e=>{e.preventDefault(),this.dispatchToggleCalendar(e)}}
|
|
136
|
+
@blur=${e=>{this.dispatchBlur(e),this.dispatchAddToSelected(e)}}
|
|
137
|
+
@input=${e=>{this.dispatchInput(e),e.stopImmediatePropagation()}}
|
|
138
|
+
@focus=${()=>{this.dispatchFocus(),b()&&this.dispatchToggleCalendar(new Event("focus"))}}
|
|
139
|
+
@keydown=${e=>_.handleInputKeydown(e,t=>this.dispatchToggleCalendar(t),()=>x.submitFormOrFallback(this.internals,()=>{var t;return(t=this.inputRef.value)==null?void 0:t.blur()}),void 0,void 0,t=>this.dispatchAddToSelected(t))}
|
|
140
|
+
@change=${e=>{this.dispatchChange(e),e.stopImmediatePropagation()}}
|
|
141
|
+
${p.n(this.inputRef)}
|
|
142
|
+
/>
|
|
143
|
+
${this.renderCalendarButton()}
|
|
144
|
+
</div>
|
|
145
|
+
`}}B([l.n({type:Array})],D.prototype,"value");B([l.n({type:Number})],D.prototype,"maxlength");B([l.n({type:Object})],D.prototype,"strings");try{l.t("pkt-datepicker-multiple")(D)}catch{console.warn("Forsøker å definere <pkt-datepicker-multiple>, men den er allerede definert")}var ue=Object.defineProperty,pe=Object.getOwnPropertyDescriptor,d=(i,e,t,a)=>{for(var s=a>1?void 0:a?pe(e,t):e,r=i.length-1,n;r>=0;r--)(n=i[r])&&(s=(a?n(e,t,s):n(s))||s);return a&&s&&ue(e,t,s),s};class h extends V.PktInputElement{constructor(){super(...arguments),this._valueProperty="",this._valueProcessing=!1,this.datepickerPopupRef=p.e(),this._value=[],this.label="Datovelger",this.dateformat=C.props.dateformat.default,this.multiple=C.props.multiple.default,this.maxlength=null,this.range=C.props.range.default,this.showRangeLabels=!1,this.min=null,this.max=null,this.weeknumbers=C.props.weeknumbers.default,this.withcontrols=C.props.withcontrols.default,this.excludedates=[],this.excludeweekdays=[],this.currentmonth=null,this.today=null,this.calendarOpen=!1,this.timezone="Europe/Oslo",this.inputClasses={},this.calRef=p.e(),this.popupRef=p.e(),this.singleInputRef=p.e(),this.rangeInputRef=p.e(),this.multipleInputRef=p.e(),this.addToSelected=e=>{const t=this.datepickerPopupRef.value;return t&&typeof t.addToSelected=="function"?t.addToSelected(e,this.min,this.max):T.addToSelected(e,this.calRef,this.min,this.max)}}get value(){return this._valueProperty}set value(e){const t=this._valueProperty;this._valueProperty=Array.isArray(e)?e.join(","):e||"",this.valueChanged(this._valueProperty,t),this.requestUpdate("value",t)}get inputType(){return ie.getInputType()}connectedCallback(){super.connectedCallback(),this.timezone&&this.timezone!==window.pktTz&&(window.pktTz=this.timezone)}disconnectedCallback(){super.disconnectedCallback()}onInput(){this.dispatchEvent(new Event("input",{bubbles:!0}))}valueChanged(e,t){if(!(this._valueProcessing||e===t)){this._valueProcessing=!0;try{const a=u.valueToArray(e),s=this.multiple&&a.length>1?A.filterSelectableDates(a,this.min,this.max,this.excludedates,this.excludeweekdays):a;if(this.range&&!A.validateRangeOrder(s)){this._value=[],this._valueProperty="",super.valueChanged("",t);return}this._value=s;const r=u.arrayToCsv(s);if(this._valueProperty!==r&&(this._valueProperty=r),this.range&&s.length<2)return;super.valueChanged(r,t)}finally{this._valueProcessing=!1}}}attributeChangedCallback(e,t,a){e==="value"&&this.value!==t&&this.valueChanged(a,t),e==="excludedates"&&typeof this.excludedates=="string"&&(this.excludedates=u.valueToArray(a||"")),e==="excludeweekdays"&&typeof this.excludeweekdays=="string"&&(this.excludeweekdays=u.valueToArray(a||"")),super.attributeChangedCallback(e,t,a)}updated(e){if(e.has("value")&&(e.has("multiple")||e.has("range"))){const t=Array.isArray(this.value)?this.value.join(","):this.value,a=e.get("value"),s=Array.isArray(a)?a.join(","):a;this.valueChanged(t,s)}e.has("multiple")&&(this.multiple&&!Array.isArray(this._value)?this._value=u.valueToArray(this.value):!this.multiple&&Array.isArray(this._value)&&(this._value=this._value.filter(Boolean)),!this.multiple&&!this.range&&Array.isArray(this._value)&&(this._value=[this._value[0]??""])),super.updated(e)}get inputRef(){return{value:this.currentInputElement}}get inputRefTo(){return{value:this.currentInputElementTo}}get currentInputElement(){var e,t,a;return this.multiple?(e=this.multipleInputRef.value)==null?void 0:e.inputElement:this.range?(t=this.rangeInputRef.value)==null?void 0:t.inputElement:(a=this.singleInputRef.value)==null?void 0:a.inputElement}get currentInputElementTo(){var e;if(this.range)return(e=this.rangeInputRef.value)==null?void 0:e.inputElementTo}get currentButtonElement(){var e,t,a;return this.multiple?(e=this.multipleInputRef.value)==null?void 0:e.buttonElement:this.range?(t=this.rangeInputRef.value)==null?void 0:t.buttonElement:(a=this.singleInputRef.value)==null?void 0:a.buttonElement}get btnRef(){return{value:this.currentButtonElement}}renderInput(){return l.b`
|
|
146
|
+
<pkt-datepicker-single
|
|
147
|
+
.value=${this._value[0]??""}
|
|
148
|
+
.inputType=${this.inputType}
|
|
149
|
+
.id=${this.id}
|
|
150
|
+
.min=${this.min}
|
|
151
|
+
.max=${this.max}
|
|
152
|
+
.placeholder=${this.placeholder}
|
|
153
|
+
.readonly=${this.readonly}
|
|
154
|
+
.disabled=${this.disabled}
|
|
155
|
+
.inputClasses=${this.inputClasses}
|
|
156
|
+
.internals=${this.internals}
|
|
157
|
+
.strings=${this.strings}
|
|
158
|
+
@toggle-calendar=${e=>this.toggleCalendar(e.detail)}
|
|
159
|
+
@input-change=${()=>this.onInput()}
|
|
160
|
+
@input-focus=${()=>this.onFocus()}
|
|
161
|
+
@input-blur=${e=>{var t;(t=this.calRef.value)!=null&&t.contains(e.detail.relatedTarget)||this.onBlur()}}
|
|
162
|
+
@manage-validity=${e=>this.manageValidity(e.detail)}
|
|
163
|
+
@value-change=${e=>{this.value=e.detail}}
|
|
164
|
+
@input-changed=${()=>{this.touched=!0}}
|
|
165
|
+
${p.n(this.singleInputRef)}
|
|
166
|
+
></pkt-datepicker-single>
|
|
167
|
+
`}renderRangeInput(){return l.b`
|
|
168
|
+
<pkt-datepicker-range
|
|
169
|
+
.value=${this._value}
|
|
170
|
+
.inputType=${this.inputType}
|
|
171
|
+
.id=${this.id}
|
|
172
|
+
.label=${this.label}
|
|
173
|
+
.min=${this.min}
|
|
174
|
+
.max=${this.max}
|
|
175
|
+
.placeholder=${this.placeholder}
|
|
176
|
+
.readonly=${this.readonly}
|
|
177
|
+
.disabled=${this.disabled}
|
|
178
|
+
.showRangeLabels=${this.showRangeLabels}
|
|
179
|
+
.inputClasses=${this.inputClasses}
|
|
180
|
+
.internals=${this.internals}
|
|
181
|
+
.strings=${this.strings}
|
|
182
|
+
@toggle-calendar=${e=>this.toggleCalendar(e.detail)}
|
|
183
|
+
@input-change=${()=>this.onInput()}
|
|
184
|
+
@input-focus=${()=>this.onFocus()}
|
|
185
|
+
@input-blur=${e=>{var t;(t=this.calRef.value)!=null&&t.contains(e.detail.relatedTarget)||this.onBlur()}}
|
|
186
|
+
@range-blur=${e=>{const t=this.currentInputElement,a=this.currentInputElementTo;if(t&&a){const s=t.value,r=a.value;if(s&&r&&s>r)a.value="",this._value=[s],this.value=s;else{const n=[s,r].filter(Boolean);n.length>0&&(n[0]!==this._value[0]||n[1]!==this._value[1])&&(this._value=n,this.value=n.join(","))}}I.processRangeBlur(e.detail.event,e.detail.values,this.calRef,()=>this.clearInputValue(),s=>this.manageValidity(s))}}
|
|
187
|
+
@manage-validity=${e=>this.manageValidity(e.detail)}
|
|
188
|
+
@validate-date-input=${e=>{x.validateDateInput(e.detail,this.internals,this.min,this.max,this.strings)}}
|
|
189
|
+
@handle-date-select=${e=>{var a,s;const t=u.fromISOToDate(e.detail);if(t){const r=u.formatISODate(t);this._value[0]!==r&&this._value[1]!==r&&((s=(a=this.calRef)==null?void 0:a.value)==null||s.handleDateSelect(t))}}}
|
|
190
|
+
@input-changed=${()=>{this.touched=!0}}
|
|
191
|
+
${p.n(this.rangeInputRef)}
|
|
192
|
+
></pkt-datepicker-range>
|
|
193
|
+
`}renderMultipleInput(){return l.b`
|
|
194
|
+
<pkt-datepicker-multiple
|
|
195
|
+
.value=${this._value}
|
|
196
|
+
.inputType=${this.inputType}
|
|
197
|
+
.id=${this.id}
|
|
198
|
+
.min=${this.min}
|
|
199
|
+
.max=${this.max}
|
|
200
|
+
.placeholder=${this.placeholder}
|
|
201
|
+
.readonly=${this.readonly}
|
|
202
|
+
.disabled=${this.disabled}
|
|
203
|
+
.maxlength=${this.maxlength}
|
|
204
|
+
.inputClasses=${this.inputClasses}
|
|
205
|
+
.internals=${this.internals}
|
|
206
|
+
.strings=${this.strings}
|
|
207
|
+
@toggle-calendar=${e=>this.toggleCalendar(e.detail)}
|
|
208
|
+
@input-change=${()=>this.onInput()}
|
|
209
|
+
@input-focus=${()=>this.onFocus()}
|
|
210
|
+
@input-blur=${e=>{var t;(t=this.calRef.value)!=null&&t.contains(e.detail.relatedTarget)||this.onBlur()}}
|
|
211
|
+
@add-to-selected=${e=>this.addToSelected(e.detail)}
|
|
212
|
+
@input-changed=${()=>{this.touched=!0}}
|
|
213
|
+
${p.n(this.multipleInputRef)}
|
|
214
|
+
></pkt-datepicker-multiple>
|
|
215
|
+
`}renderCalendar(){return l.b`
|
|
216
|
+
<pkt-datepicker-popup
|
|
217
|
+
class="pkt-contents"
|
|
218
|
+
?open=${this.calendarOpen}
|
|
219
|
+
?multiple=${this.multiple}
|
|
220
|
+
?range=${this.range}
|
|
221
|
+
?weeknumbers=${this.weeknumbers}
|
|
222
|
+
?withcontrols=${this.withcontrols}
|
|
223
|
+
.maxMultiple=${this.maxlength}
|
|
224
|
+
.selected=${this._value}
|
|
225
|
+
.earliest=${this.min}
|
|
226
|
+
.latest=${this.max}
|
|
227
|
+
.excludedates=${Array.isArray(this.excludedates)?this.excludedates:this.excludedates.split(",")}
|
|
228
|
+
.excludeweekdays=${this.excludeweekdays}
|
|
229
|
+
.currentmonth=${this.currentmonth?u.parseISODateString(this.currentmonth):null}
|
|
230
|
+
.today=${this.today}
|
|
231
|
+
@date-selected=${e=>{this.value=I.processDateSelection(e.detail,this.multiple,this.range),this._value=e.detail,I.updateInputValues(this.inputRef,this.inputRefTo,this._value,this.range,this.multiple,t=>this.manageValidity(t))}}
|
|
232
|
+
@close=${()=>{this.onBlur(),this.hideCalendar()}}
|
|
233
|
+
${p.n(this.datepickerPopupRef)}
|
|
234
|
+
></pkt-datepicker-popup>
|
|
235
|
+
`}render(){return this.inputClasses=P.getInputClasses(this.fullwidth,this.showRangeLabels,this.multiple,this.range,this.readonly,this.inputType),l.b`
|
|
236
|
+
<pkt-input-wrapper
|
|
237
|
+
label="${this.label}"
|
|
238
|
+
forId="${this.id}-input"
|
|
239
|
+
?counter=${this.multiple&&!!this.maxlength}
|
|
240
|
+
.counterCurrent=${this.value?this._value.length:0}
|
|
241
|
+
.counterMaxLength=${this.maxlength}
|
|
242
|
+
?disabled=${this.disabled}
|
|
243
|
+
?hasError=${this.hasError}
|
|
244
|
+
?hasFieldset=${this.hasFieldset}
|
|
245
|
+
?inline=${this.inline}
|
|
246
|
+
?required=${this.required}
|
|
247
|
+
?optionalTag=${this.optionalTag}
|
|
248
|
+
?requiredTag=${this.requiredTag}
|
|
249
|
+
useWrapper=${this.useWrapper}
|
|
250
|
+
.optionalText=${this.optionalText}
|
|
251
|
+
.requiredText=${this.requiredText}
|
|
252
|
+
.tagText=${this.tagText}
|
|
253
|
+
.errorMessage=${this.errorMessage}
|
|
254
|
+
.helptext=${this.helptext}
|
|
255
|
+
.helptextDropdown=${this.helptextDropdown}
|
|
256
|
+
.helptextDropdownButton=${this.helptextDropdownButton}
|
|
257
|
+
.ariaDescribedBy=${this.ariaDescribedBy}
|
|
258
|
+
class="pkt-datepicker"
|
|
259
|
+
>
|
|
260
|
+
<div class="pkt-contents" slot="helptext">${K.slotContent(this,"helptext")}</div>
|
|
261
|
+
${this.multiple?l.b`<pkt-date-tags
|
|
262
|
+
.dates=${this._value}
|
|
263
|
+
dateformat=${this.dateformat}
|
|
264
|
+
strings=${this.strings}
|
|
265
|
+
id-base=${this.id}
|
|
266
|
+
@date-tag-removed=${e=>{var s;const t=this.datepickerPopupRef.value,a=u.fromISOToDate(e.detail);t&&a&&typeof t.handleDateSelect=="function"?t.handleDateSelect(a):(s=this.calRef.value)==null||s.handleDateSelect(a)}}
|
|
267
|
+
></pkt-date-tags>`:l.A}
|
|
268
|
+
<div class="pkt-datepicker__inputs ${this.range?"pkt-input__range-inputs":""}">
|
|
269
|
+
${this.range?this.renderRangeInput():this.multiple?this.renderMultipleInput():this.renderInput()}
|
|
270
|
+
</div>
|
|
271
|
+
</pkt-input-wrapper>
|
|
272
|
+
${this.renderCalendar()}
|
|
273
|
+
`}handleCalendarPosition(){const e=this.multiple&&!!this.maxlength;T.handleCalendarPosition(this.popupRef,this.inputRef,e)}async showCalendar(){var t;const e=this.datepickerPopupRef.value;if(this.calendarOpen=!0,e&&typeof e.show=="function"){e.show(),b()&&e.focusOnCurrentDate();return}await q.sleep(20),this.handleCalendarPosition(),b()&&((t=this.calRef.value)==null||t.focusOnCurrentDate())}hideCalendar(){const e=this.datepickerPopupRef.value;if(this.calendarOpen=!1,e&&typeof e.hide=="function")return e.hide()}async toggleCalendar(e){e.preventDefault();const t=this.datepickerPopupRef.value;if(t&&typeof t.toggle=="function"){const a=!!t.open;t.toggle(),this.calendarOpen=!a;return}this.calendarOpen?this.hideCalendar():this.showCalendar()}clearInputValue(){this._value=[],this.value="",this.internals.setFormValue(this.value),this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("value-change",{detail:this._value,bubbles:!0,composed:!0}))}}d([l.n({type:String,reflect:!0})],h.prototype,"value",1);d([l.n({type:String,reflect:!0})],h.prototype,"label",2);d([l.n({type:String})],h.prototype,"dateformat",2);d([l.n({type:Boolean,reflect:!0})],h.prototype,"multiple",2);d([l.n({type:Number,reflect:!0})],h.prototype,"maxlength",2);d([l.n({type:Boolean,reflect:!0})],h.prototype,"range",2);d([l.n({type:Boolean,attribute:"show-range-labels"})],h.prototype,"showRangeLabels",2);d([l.n({type:String,reflect:!0})],h.prototype,"min",2);d([l.n({type:String,reflect:!0})],h.prototype,"max",2);d([l.n({type:Boolean})],h.prototype,"weeknumbers",2);d([l.n({type:Boolean,reflect:!0})],h.prototype,"withcontrols",2);d([l.n({converter:u.converters.csvToArray})],h.prototype,"excludedates",2);d([l.n({converter:u.converters.csvToArray})],h.prototype,"excludeweekdays",2);d([l.n({type:String})],h.prototype,"currentmonth",2);d([l.n({type:String})],h.prototype,"today",2);d([l.n({type:Boolean,reflect:!0,attribute:"calendar-open"})],h.prototype,"calendarOpen",2);d([l.n({type:String})],h.prototype,"timezone",2);d([F.r()],h.prototype,"inputClasses",2);try{l.t("pkt-datepicker")(h)}catch{console.warn("Forsøker å definere <pkt-datepicker>, men den er allerede definert")}exports.PktDateTags=k;exports.PktDatepicker=h;exports.PktDatepickerMultiple=D;exports.PktDatepickerRange=w;exports.PktDatepickerSingle=E;
|