@oslokommune/punkt-elements 16.7.3 → 16.7.7
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 +35 -0
- package/dist/accordion-BB1JrONI.cjs +34 -0
- package/dist/accordion-nNH87Y60.js +130 -0
- package/dist/alert-BEEnTiCb.cjs +33 -0
- package/dist/alert-ePJuDtmm.js +171 -0
- package/dist/async-directive-B9P1Qa0k.cjs +1 -0
- package/dist/async-directive-CaQiqjyV.js +55 -0
- package/dist/backlink-Ba03LlbB.cjs +13 -0
- package/dist/backlink-CiwXrQYD.js +38 -0
- package/dist/booleanish-BmcOU-43.js +11 -0
- package/dist/booleanish-jJLlnr6-.cjs +1 -0
- package/dist/breadcrumbs-CD1zib3s.cjs +43 -0
- package/dist/breadcrumbs-CpuVqWhF.js +76 -0
- package/dist/button-BIpd1xJh.js +95 -0
- package/dist/button-D-TOBaJB.cjs +27 -0
- package/dist/calendar-BzEtOJla.js +2031 -0
- package/dist/calendar-E5jJLt8D.cjs +90 -0
- package/dist/card-BYJu1MYm.js +339 -0
- package/dist/card-CUFhMVim.cjs +87 -0
- package/dist/checkbox-BARDb9iV.cjs +31 -0
- package/dist/checkbox-Cspxcvt_.js +111 -0
- package/dist/class-map-C8HuhNzZ.js +27 -0
- package/dist/class-map-CJ-msbHs.cjs +1 -0
- package/dist/classutils-DEL164Ur.js +7 -0
- package/dist/classutils-z8YsPlOf.cjs +1 -0
- package/dist/combobox-BcdLZRDU.js +984 -0
- package/dist/combobox-CGbFTWq_.cjs +135 -0
- package/dist/consent-DeB_5sWH.js +197 -0
- package/dist/consent-hwu7pp3S.cjs +11 -0
- package/dist/datepicker-DpmlsnH_.cjs +273 -0
- package/dist/datepicker-OVd8pmnZ.js +1125 -0
- package/dist/dialog-polyfill.esm-1hPr0gl9.js +280 -0
- package/dist/dialog-polyfill.esm-D3Oinvk0.cjs +1 -0
- package/dist/directive-3THFsVew.js +28 -0
- package/dist/directive-CJ2giQBZ.cjs +1 -0
- package/dist/directive-helpers-D1QSxY17.cjs +1 -0
- package/dist/directive-helpers-Dkv2gKgs.js +25 -0
- package/dist/element-DjtxO-1r.cjs +2 -0
- package/dist/element-cZ85T_aa.js +693 -0
- package/dist/element-with-slot-4J2o3SeU.js +166 -0
- package/dist/element-with-slot-CWoTGA1B.cjs +1 -0
- package/dist/header-DWgPgGfS.cjs +304 -0
- package/dist/header-a6ztVNp3.js +782 -0
- package/dist/heading-BgSWIRii.cjs +1 -0
- package/dist/heading-DiQLPxdf.js +73 -0
- package/dist/helptext-CCBKKLus.js +65 -0
- package/dist/helptext-D-3QfZv5.cjs +24 -0
- package/dist/icon-Co72KtgF.js +86 -0
- package/dist/icon-Dr8sfT2X.cjs +1 -0
- package/dist/if-defined-Cjj8qN-Z.js +5 -0
- package/dist/if-defined-XKOD_t_V.cjs +1 -0
- package/dist/index.d.ts +1 -2
- package/dist/input-element-B1yxcfz4.cjs +1 -0
- package/dist/input-element-Bw1s6NlF.js +643 -0
- package/dist/input-wrapper-BRuVELpK.cjs +54 -0
- package/dist/input-wrapper-CDyHTR1V.js +164 -0
- package/dist/input-wrapper-Dwd-_sKm.cjs +1 -0
- package/dist/input-wrapper-YfTmpSSY.js +117 -0
- package/dist/link-CKAFMz9j.js +89 -0
- package/dist/link-CyTCpI0k.cjs +7 -0
- package/dist/linkcard-B0KOGaGj.js +55 -0
- package/dist/linkcard-BE4-FewK.cjs +13 -0
- package/dist/listbox-DCA2JoPV.cjs +106 -0
- package/dist/listbox-DuBgTFvH.js +397 -0
- package/dist/loader-6kFZUErT.js +66 -0
- package/dist/loader-CX2rsC01.cjs +16 -0
- package/dist/messagebox-Cwlg5sOr.js +110 -0
- package/dist/messagebox-Din9X53b.cjs +13 -0
- package/dist/modal-C_wtsh9m.js +209 -0
- package/dist/modal-DS_wUOIv.cjs +36 -0
- package/dist/pkt-accordion.cjs +1 -1
- package/dist/pkt-accordion.js +2 -7
- package/dist/pkt-alert.cjs +1 -1
- package/dist/pkt-alert.js +2 -5
- package/dist/pkt-backlink.cjs +1 -1
- package/dist/pkt-backlink.js +2 -5
- package/dist/pkt-breadcrumbs.cjs +1 -43
- package/dist/pkt-breadcrumbs.js +2 -81
- package/dist/pkt-button.cjs +1 -1
- package/dist/pkt-button.js +2 -5
- package/dist/pkt-calendar.cjs +1 -1
- package/dist/pkt-calendar.js +2 -5
- package/dist/pkt-card.cjs +1 -1
- package/dist/pkt-card.js +2 -5
- package/dist/pkt-checkbox.cjs +1 -1
- package/dist/pkt-checkbox.js +2 -5
- package/dist/pkt-combobox.cjs +1 -1
- package/dist/pkt-combobox.js +2 -5
- package/dist/pkt-consent.cjs +1 -1
- package/dist/pkt-consent.js +2 -5
- package/dist/pkt-datepicker.cjs +1 -1
- package/dist/pkt-datepicker.js +5 -9
- package/dist/pkt-header.cjs +1 -304
- package/dist/pkt-header.js +2 -861
- package/dist/pkt-heading.cjs +1 -1
- package/dist/pkt-heading.js +2 -5
- package/dist/pkt-helptext.cjs +1 -1
- package/dist/pkt-helptext.js +2 -5
- package/dist/pkt-icon.cjs +1 -1
- package/dist/pkt-icon.js +2 -5
- package/dist/pkt-index.cjs +1 -1
- package/dist/pkt-index.js +30 -66
- package/dist/pkt-input-wrapper.cjs +1 -1
- package/dist/pkt-input-wrapper.js +2 -5
- package/dist/pkt-link.cjs +1 -1
- package/dist/pkt-link.js +2 -5
- package/dist/pkt-linkcard.cjs +1 -1
- package/dist/pkt-linkcard.js +2 -5
- package/dist/pkt-listbox.cjs +1 -1
- package/dist/pkt-listbox.js +2 -5
- package/dist/pkt-loader.cjs +1 -1
- package/dist/pkt-loader.js +2 -5
- package/dist/pkt-messagebox.cjs +1 -1
- package/dist/pkt-messagebox.js +2 -5
- package/dist/pkt-modal.cjs +1 -1
- package/dist/pkt-modal.js +2 -5
- package/dist/pkt-options-controller-CRrI6WMk.js +43 -0
- package/dist/pkt-options-controller-CXUGx134.cjs +1 -0
- package/dist/pkt-progressbar.cjs +1 -1
- package/dist/pkt-progressbar.js +2 -5
- package/dist/pkt-radiobutton.cjs +1 -1
- package/dist/pkt-radiobutton.js +2 -5
- package/dist/pkt-select.cjs +1 -1
- package/dist/pkt-select.js +2 -5
- package/dist/pkt-tabs.cjs +1 -1
- package/dist/pkt-tabs.js +2 -7
- package/dist/pkt-tag.cjs +1 -1
- package/dist/pkt-tag.js +2 -5
- package/dist/pkt-textarea.cjs +1 -1
- package/dist/pkt-textarea.js +2 -5
- package/dist/pkt-textinput.cjs +1 -1
- package/dist/pkt-textinput.js +2 -5
- package/dist/pkt-timepicker.cjs +1 -191
- package/dist/pkt-timepicker.js +2 -560
- package/dist/progressbar-CdXtmOBb.cjs +17 -0
- package/dist/progressbar-Dy9AiYQz.js +113 -0
- package/dist/radiobutton-GOnpUbCW.cjs +31 -0
- package/dist/radiobutton-V_KPbup_.js +84 -0
- package/dist/ref-BaJ0mBT_.cjs +1 -0
- package/dist/ref-RS8Uv6uC.js +30 -0
- package/dist/repeat-Cepr3469.js +57 -0
- package/dist/repeat-CqcDYBxr.cjs +1 -0
- package/dist/select-BSAFd8Wa.js +164 -0
- package/dist/select-C2i8sOk5.cjs +49 -0
- package/dist/tabs-D8nL9rWx.cjs +37 -0
- package/dist/tabs-Y7utmJi9.js +318 -0
- package/dist/tag-DLthw5b4.cjs +27 -0
- package/dist/tag-VwykmuQR.js +179 -0
- package/dist/textarea-D7aGOyDf.cjs +46 -0
- package/dist/textarea-DYOBhJrN.js +115 -0
- package/dist/textinput-BUgntXnM.js +124 -0
- package/dist/textinput-DFh8_9cx.cjs +70 -0
- package/dist/timepicker-BIfE7KKJ.cjs +191 -0
- package/dist/timepicker-DaSwn1FA.js +503 -0
- package/dist/utils-CUqCKGvp.js +7 -0
- package/dist/utils-CjAbIttF.cjs +1 -0
- package/package.json +6 -6
- package/src/components/alert/alert.test.ts +1 -1
- package/src/components/alert/alert.ts +6 -6
- package/src/components/datepicker/datepicker-utils.test.ts +16 -23
- package/dist/accordionitem-_9AiCIvd.cjs +0 -34
- package/dist/accordionitem-dCfSrxh5.js +0 -140
- package/dist/alert-BtOk8yRH.cjs +0 -33
- package/dist/alert-DlY2_grU.js +0 -117
- package/dist/async-directive-CMzWMlZ5.js +0 -65
- package/dist/async-directive-DoMuclel.cjs +0 -5
- package/dist/backlink-Ce5Vldop.js +0 -49
- package/dist/backlink-y3dwjKPC.cjs +0 -13
- package/dist/booleanish-BKVonob4.cjs +0 -1
- package/dist/booleanish-C9R0tdXH.js +0 -11
- package/dist/button-B_TXwNzt.cjs +0 -27
- package/dist/button-BiY-wlKF.js +0 -139
- package/dist/calendar-B2pji2zn.cjs +0 -90
- package/dist/calendar-DhjQDC4C.js +0 -2140
- package/dist/card-BwMNB5Bb.cjs +0 -87
- package/dist/card-CGlmcMSR.js +0 -233
- package/dist/checkbox-BsJZYA26.js +0 -147
- package/dist/checkbox-CTY8f_qn.cjs +0 -31
- package/dist/class-map-CEnykyO_.js +0 -34
- package/dist/class-map-CsENJXf1.cjs +0 -5
- package/dist/classutils-BwNK82ZQ.cjs +0 -1
- package/dist/classutils-RQs1k6D9.js +0 -7
- package/dist/combobox-DSB5WOxg.js +0 -815
- package/dist/combobox-DbICIgKG.cjs +0 -135
- package/dist/consent-DkOQpbsg.cjs +0 -11
- package/dist/consent-SNWV_mMU.js +0 -175
- package/dist/datepicker-BEWl9iz3.cjs +0 -273
- package/dist/datepicker-euHyzXnb.js +0 -1170
- package/dist/dialog-polyfill.esm-CPKZe7AL.cjs +0 -1
- package/dist/dialog-polyfill.esm-CbjBMXAG.js +0 -395
- package/dist/directive-C7oCP5Bh.cjs +0 -5
- package/dist/directive-helpers-BP2WOx60.cjs +0 -5
- package/dist/directive-helpers-rm-28gIj.js +0 -38
- package/dist/directive-oAbCiebi.js +0 -27
- package/dist/element-CPpT3rFQ.js +0 -638
- package/dist/element-gR_VtSiD.cjs +0 -27
- package/dist/element-with-slot-Dqk6-TRR.js +0 -240
- package/dist/element-with-slot-ZX-up7jO.cjs +0 -1
- package/dist/heading-D2tVS6lS.js +0 -103
- package/dist/heading-DrzbgDb6.cjs +0 -1
- package/dist/helptext-BKtU4mas.js +0 -82
- package/dist/helptext-DcRC7wW2.cjs +0 -24
- package/dist/icon-CxQcIa5F.js +0 -105
- package/dist/icon-q81vqPK_.cjs +0 -9
- package/dist/if-defined-B0krMLad.js +0 -10
- package/dist/if-defined-BOW3ODSj.cjs +0 -5
- package/dist/input-element-8nLwuQS4.js +0 -837
- package/dist/input-element-DdVhUvva.cjs +0 -1
- package/dist/input-wrapper-Bs4CRNst.js +0 -181
- package/dist/input-wrapper-Bv9aqqVq.cjs +0 -54
- package/dist/input-wrapper-CDgenrYA.js +0 -6
- package/dist/input-wrapper-EoSAbU-U.cjs +0 -1
- package/dist/link-C0rl-86s.cjs +0 -7
- package/dist/link-Cdqgl60z.js +0 -55
- package/dist/linkcard-Dimu7Rlx.cjs +0 -13
- package/dist/linkcard-Lbq_UhjZ.js +0 -56
- package/dist/listbox-Bia4_tvN.js +0 -440
- package/dist/listbox-La2GZQei.cjs +0 -106
- package/dist/loader-D1ugDXGV.cjs +0 -16
- package/dist/loader-DyN6RGC5.js +0 -95
- package/dist/messagebox-BGMVm2t9.js +0 -71
- package/dist/messagebox-M0yIgCz9.cjs +0 -13
- package/dist/modal-CMO1RtIi.cjs +0 -36
- package/dist/modal-DjPQDE-Z.js +0 -156
- package/dist/pkt-options-controller-5LXbEzuk.cjs +0 -1
- package/dist/pkt-options-controller-B5YalfCb.js +0 -39
- package/dist/progressbar-BqlMzkM_.cjs +0 -21
- package/dist/progressbar-sbHDFC12.js +0 -162
- package/dist/radiobutton-5ZqVVtTT.cjs +0 -31
- package/dist/radiobutton-D8Ai8ETa.js +0 -113
- package/dist/ref-Bg_Swj5w.js +0 -42
- package/dist/ref-CL-Xk9Xm.cjs +0 -5
- package/dist/repeat-BD8TKgJb.js +0 -61
- package/dist/repeat-Cfq8CDlf.cjs +0 -5
- package/dist/select-De-n8on9.js +0 -230
- package/dist/select-dTWibR6_.cjs +0 -49
- package/dist/state-C_1EOo3D.js +0 -12
- package/dist/state-Dg-53wQ8.cjs +0 -5
- package/dist/tabitem-B9-jeV97.js +0 -334
- package/dist/tabitem-BnhzqfW3.cjs +0 -65
- package/dist/tag-CbwO8yvD.cjs +0 -27
- package/dist/tag-D4FI5t3y.js +0 -117
- package/dist/textarea-BmLaKzsc.cjs +0 -50
- package/dist/textarea-CMiSJaYL.js +0 -133
- package/dist/textinput-em9y4yrL.cjs +0 -70
- package/dist/textinput-r8udK0IX.js +0 -152
- package/dist/utils-DznhwRXm.js +0 -8
- package/dist/utils-byXsEz1u.cjs +0 -1
|
@@ -1,135 +0,0 @@
|
|
|
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
|
-
<pkt-input-wrapper
|
|
3
|
-
.label=${this.label}
|
|
4
|
-
.helptext=${this.helptext}
|
|
5
|
-
.helptextDropdown=${d.o(this.helptextDropdown)}
|
|
6
|
-
.helptextDropdownButton=${d.o(this.helptextDropdownButton)}
|
|
7
|
-
?fullwidth=${this.fullwidth}
|
|
8
|
-
?hasError=${this.hasError}
|
|
9
|
-
?inline=${this.inline}
|
|
10
|
-
?disabled=${this.disabled}
|
|
11
|
-
.errorMessage=${this.errorMessage}
|
|
12
|
-
?optionalTag=${this.optionalTag}
|
|
13
|
-
.optionalText=${this.optionalText}
|
|
14
|
-
?requiredTag=${this.requiredTag}
|
|
15
|
-
.requiredText=${this.requiredText}
|
|
16
|
-
.tagText=${this.tagText}
|
|
17
|
-
useWrapper=${this.useWrapper}
|
|
18
|
-
.forId=${this._hasTextInput?this.id+"-input":this.id+"-combobox"}
|
|
19
|
-
?hasFieldset=${!this._hasTextInput}
|
|
20
|
-
class="pkt-combobox__wrapper"
|
|
21
|
-
@labelClick=${this.handleInputClick}
|
|
22
|
-
>
|
|
23
|
-
<div class="pkt-contents" slot="helptext">${w.slotContent(this,"helptext")}</div>
|
|
24
|
-
<div class="pkt-combobox" @focusout=${this.handleFocusOut}>
|
|
25
|
-
<div
|
|
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})}
|
|
27
|
-
id=${d.o(this._hasTextInput?void 0:`${this.id}-combobox`)}
|
|
28
|
-
role=${d.o(this._hasTextInput?void 0:"combobox")}
|
|
29
|
-
aria-expanded=${d.o(this._hasTextInput?void 0:this._isOptionsOpen?"true":"false")}
|
|
30
|
-
aria-controls=${d.o(this._hasTextInput?void 0:`${this.id}-listbox`)}
|
|
31
|
-
aria-haspopup=${d.o(this._hasTextInput?void 0:"listbox")}
|
|
32
|
-
aria-labelledby=${d.o(this._hasTextInput?void 0:`${this.id}-combobox-label`)}
|
|
33
|
-
aria-activedescendant=${d.o(!this._hasTextInput&&this._value[0]&&u.findOptionByValue(this.options,this._value[0])?`${this.id}-listbox-${u.findOptionIndex(this._options,this._value[0])}`:void 0)}
|
|
34
|
-
aria-description=${d.o(this._selectionDescription||void 0)}
|
|
35
|
-
tabindex=${this._hasTextInput||this.disabled?"-1":"0"}
|
|
36
|
-
@click=${this.handleInputClick}
|
|
37
|
-
@keydown=${this._hasTextInput?o.A:this.handleSelectOnlyKeydown}
|
|
38
|
-
${b.n(this.triggerRef)}
|
|
39
|
-
>
|
|
40
|
-
${!this._hasTextInput&&this.placeholder&&(!this._value.length||this.multiple&&this.tagPlacement=="outside")&&!this._inputFocus?o.b`<span class="pkt-combobox__placeholder" @click=${this.handlePlaceholderClick}
|
|
41
|
-
>${this.placeholder}</span
|
|
42
|
-
>`:this.tagPlacement!=="outside"?this.renderSingleOrMultipleValues():o.A}
|
|
43
|
-
${this.renderInputField()}
|
|
44
|
-
<pkt-icon
|
|
45
|
-
class=${V.e({"pkt-combobox__arrow-icon":!0,"pkt-combobox__arrow-icon--open":this._isOptionsOpen})}
|
|
46
|
-
name="chevron-thin-down"
|
|
47
|
-
aria-hidden="true"
|
|
48
|
-
></pkt-icon>
|
|
49
|
-
</div>
|
|
50
|
-
|
|
51
|
-
<pkt-listbox
|
|
52
|
-
id="${this.id}-listbox"
|
|
53
|
-
.options=${this._options}
|
|
54
|
-
.isOpen=${this._isOptionsOpen}
|
|
55
|
-
.searchPlaceholder=${this.searchPlaceholder}
|
|
56
|
-
.label="Liste: ${this.label||""}"
|
|
57
|
-
?include-search=${this.includeSearch}
|
|
58
|
-
?is-multi-select=${this.multiple}
|
|
59
|
-
?allow-user-input=${this.allowUserInput&&!this._maxIsReached}
|
|
60
|
-
?max-is-reached=${this._maxIsReached}
|
|
61
|
-
.customUserInput=${d.o(this._addValueText)}
|
|
62
|
-
.userMessage=${this._userInfoMessage}
|
|
63
|
-
@search=${this.handleSearch}
|
|
64
|
-
@option-toggle=${this.handleOptionToggled}
|
|
65
|
-
@select-all=${this.addAllOptions}
|
|
66
|
-
@close-options=${()=>this._isOptionsOpen=!1}
|
|
67
|
-
@tab-close=${()=>this.closeAndProcessInput()}
|
|
68
|
-
.searchValue=${this._search||null}
|
|
69
|
-
.maxLength=${this.maxlength||0}
|
|
70
|
-
${b.n(this.listboxRef)}
|
|
71
|
-
></pkt-listbox>
|
|
72
|
-
</div>
|
|
73
|
-
|
|
74
|
-
${this.tagPlacement==="outside"&&this.multiple?o.b`<div class="pkt-combobox__tags-outside">
|
|
75
|
-
${this.renderSingleOrMultipleValues()}
|
|
76
|
-
</div>`:o.A}
|
|
77
|
-
</pkt-input-wrapper>
|
|
78
|
-
`}renderInputField(){return this.typeahead||this.allowUserInput?o.b`
|
|
79
|
-
<div class="pkt-combobox__input-div combobox__input">
|
|
80
|
-
<input
|
|
81
|
-
type="text"
|
|
82
|
-
id="${this.id}-input"
|
|
83
|
-
name=${(this.name||this.id)+"-input"}
|
|
84
|
-
placeholder=${d.o(!this._value.length||this.multiple&&this.tagPlacement==="outside"?this.placeholder:void 0)}
|
|
85
|
-
@input=${this.handleInput}
|
|
86
|
-
@change=${t=>{t.stopPropagation(),t.stopImmediatePropagation()}}
|
|
87
|
-
@keydown=${this.handleInputKeydown}
|
|
88
|
-
@focus=${this.handleFocus}
|
|
89
|
-
@blur=${this.handleBlur}
|
|
90
|
-
autocomplete="off"
|
|
91
|
-
role="combobox"
|
|
92
|
-
aria-expanded=${this._isOptionsOpen?"true":"false"}
|
|
93
|
-
aria-label=${d.o(this.label)}
|
|
94
|
-
aria-autocomplete=${this.typeahead?"both":this.allowUserInput?"list":"none"}
|
|
95
|
-
aria-controls="${this.id}-listbox"
|
|
96
|
-
aria-activedescendant=${d.o(this._value[0]&&u.findOptionByValue(this.options,this._value[0])?`${this.id}-listbox-${u.findOptionIndex(this._options,this._value[0])}`:void 0)}
|
|
97
|
-
aria-description=${d.o(this._selectionDescription||void 0)}
|
|
98
|
-
${b.n(this.inputRef)}
|
|
99
|
-
/>
|
|
100
|
-
</div>
|
|
101
|
-
`:o.b`
|
|
102
|
-
<input
|
|
103
|
-
type="hidden"
|
|
104
|
-
id="${this.id}-input"
|
|
105
|
-
name=${(this.name||this.id)+"-input"}
|
|
106
|
-
.value=${this._value.join(",")}
|
|
107
|
-
${b.n(this.inputRef)}
|
|
108
|
-
/>
|
|
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
|
-
<ul role="list" class="pkt-combobox__tag-list">
|
|
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
|
-
<li
|
|
113
|
-
role="listitem"
|
|
114
|
-
@click=${s?o.A:_=>_.stopPropagation()}
|
|
115
|
-
@mousedown=${s?o.A:_=>_.preventDefault()}
|
|
116
|
-
>
|
|
117
|
-
<pkt-tag
|
|
118
|
-
skin=${f||"blue-dark"}
|
|
119
|
-
?closeTag=${!this.disabled}
|
|
120
|
-
.buttonTabindex=${s?void 0:-1}
|
|
121
|
-
@close=${()=>this.handleTagRemove(l)}
|
|
122
|
-
@keydown=${s?o.A:_=>this.handleTagKeydown(_,n)}
|
|
123
|
-
>
|
|
124
|
-
${this.renderValueTag(p)}
|
|
125
|
-
</pkt-tag>
|
|
126
|
-
</li>
|
|
127
|
-
`})}
|
|
128
|
-
</ul>
|
|
129
|
-
`;return t?e:i}renderValueTag(t){if(!t)return"";switch(this.displayValueAs){case"prefixAndValue":return o.b`<span class="pkt-combobox__value" data-focusfix=${this.id}
|
|
130
|
-
>${t.prefix||""} ${t.value}</span
|
|
131
|
-
>`;case"value":return o.b`<span class="pkt-combobox__value" data-focusfix=${this.id}
|
|
132
|
-
>${t.value}</span
|
|
133
|
-
>`;case"label":default:return o.b`<span class="pkt-combobox__value" data-focusfix=${this.id}
|
|
134
|
-
>${t.label||t.value}</span
|
|
135
|
-
>`}}}try{o.t("pkt-combobox")(T)}catch{console.warn("Forsøker å definere <pkt-combobox>, men den er allerede definert")}exports.PktCombobox=T;
|
|
@@ -1,11 +0,0 @@
|
|
|
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;
|
package/dist/consent-SNWV_mMU.js
DELETED
|
@@ -1,175 +0,0 @@
|
|
|
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
|
-
const u = {
|
|
5
|
-
i18n: {
|
|
6
|
-
nb: {
|
|
7
|
-
contentPresentation: {
|
|
8
|
-
title: "Oslo kommune bruker informasjonskapsler",
|
|
9
|
-
description: [
|
|
10
|
-
"For at nettstedet skal fungere og være trygt, bruker Oslo kommune informasjonskapsler. Noen er teknisk nødvendige, mens andre sikrer ulik funksjonalitet.",
|
|
11
|
-
"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."
|
|
12
|
-
],
|
|
13
|
-
buttons: {
|
|
14
|
-
accept: "Godta alle",
|
|
15
|
-
reject: "Kun nødvendige",
|
|
16
|
-
settings: "Innstillinger for informasjonskapsler"
|
|
17
|
-
}
|
|
18
|
-
},
|
|
19
|
-
contentSettings: {
|
|
20
|
-
title: "Innstillinger for informasjonskapsler",
|
|
21
|
-
description: [
|
|
22
|
-
"Her kan du velge hvilke typer informasjonskapsler du vil tillate. Tillatelsen gjelder i 90 dager. Husk at nødvendige informasjonskapsler ikke kan velges bort.",
|
|
23
|
-
"Du kan når som helst endre innstillingene og finne mer informasjon nederst på nettstedet under «Innstillinger for informasjonskapsler» og «Personvern og informasjonskapsler»."
|
|
24
|
-
],
|
|
25
|
-
buttons: {
|
|
26
|
-
back: "Tilbake",
|
|
27
|
-
save: "Lagre innstillinger"
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
|
-
en: {
|
|
32
|
-
contentPresentation: {
|
|
33
|
-
title: "Before you visit Oslo kommune ...",
|
|
34
|
-
description: [
|
|
35
|
-
"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.",
|
|
36
|
-
"To read more about what we use cookies for, go to our privacy declaration which you will find at the bottom of our websites."
|
|
37
|
-
],
|
|
38
|
-
buttons: {
|
|
39
|
-
accept: "Yes, I accept",
|
|
40
|
-
reject: "Only necessary",
|
|
41
|
-
settings: "Go to settings"
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
contentSettings: {
|
|
45
|
-
title: "Her kan du aktivt velge mellom ulike informasjonskapsler",
|
|
46
|
-
description: [
|
|
47
|
-
"For å lese mer om hva vi bruker informasjonskapsler til gå til vår personvernserklering som du finner på våre nettsider"
|
|
48
|
-
],
|
|
49
|
-
buttons: {
|
|
50
|
-
back: "Back",
|
|
51
|
-
save: "Save settings"
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
};
|
|
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
|
-
};
|
|
62
|
-
let d = null;
|
|
63
|
-
function m() {
|
|
64
|
-
return d || (d = new Promise((a, e) => {
|
|
65
|
-
if (document.querySelector("#oslo-consent-script")) {
|
|
66
|
-
a();
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
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
|
-
const o = document.createElement("link");
|
|
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
|
-
}), d);
|
|
74
|
-
}
|
|
75
|
-
class i extends g {
|
|
76
|
-
constructor() {
|
|
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
|
-
}
|
|
79
|
-
connectedCallback() {
|
|
80
|
-
super.connectedCallback(), this.triggerText = this.triggerText || u.i18n[this.i18nLanguage].contentPresentation.buttons.settings;
|
|
81
|
-
}
|
|
82
|
-
disconnectedCallback() {
|
|
83
|
-
var e;
|
|
84
|
-
super.disconnectedCallback(), this._cookieEventHandler && ((e = window.__cookieEvents) == null || e.off("CookieManager.setCookie", this._cookieEventHandler));
|
|
85
|
-
}
|
|
86
|
-
returnJsonOrObject(e) {
|
|
87
|
-
let t;
|
|
88
|
-
try {
|
|
89
|
-
t = JSON.parse(e);
|
|
90
|
-
} catch {
|
|
91
|
-
t = e;
|
|
92
|
-
}
|
|
93
|
-
return t;
|
|
94
|
-
}
|
|
95
|
-
emitCookieConsents(e) {
|
|
96
|
-
const o = this.returnJsonOrObject(e.value).items.reduce((n, c) => (n[c.name] = c.consent, n), {});
|
|
97
|
-
this.dispatchEvent(
|
|
98
|
-
new CustomEvent("toggle-consent", {
|
|
99
|
-
detail: o,
|
|
100
|
-
bubbles: !0,
|
|
101
|
-
cancelable: !1
|
|
102
|
-
})
|
|
103
|
-
);
|
|
104
|
-
}
|
|
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 m(), this.triggerInit();
|
|
107
|
-
}
|
|
108
|
-
triggerInit() {
|
|
109
|
-
window.document.dispatchEvent(
|
|
110
|
-
new Event("CookieBannerReady", {
|
|
111
|
-
bubbles: !0,
|
|
112
|
-
cancelable: !0
|
|
113
|
-
})
|
|
114
|
-
), window.cookieBanner.cookieConsent.validateConsentCookie().then((e) => {
|
|
115
|
-
if (e) {
|
|
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
|
-
}, window.__cookieEvents.on("CookieManager.setCookie", this._cookieEventHandler);
|
|
120
|
-
}
|
|
121
|
-
});
|
|
122
|
-
}
|
|
123
|
-
openModal(e) {
|
|
124
|
-
var t;
|
|
125
|
-
e.preventDefault(), (t = window.cookieBanner) != null && t.cookieConsent || this.triggerInit(), setTimeout(() => window.cookieBanner.openCookieModal());
|
|
126
|
-
}
|
|
127
|
-
render() {
|
|
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
|
-
<pkt-icon name="chevron-right" class="pkt-footer__link-icon"></pkt-icon>
|
|
130
|
-
${this.triggerText}
|
|
131
|
-
</a>` : this.triggerType === "icon" ? l`<pkt-button
|
|
132
|
-
skin="tertiary"
|
|
133
|
-
variant="icon-only"
|
|
134
|
-
iconName="cookie"
|
|
135
|
-
@click=${this.openModal}
|
|
136
|
-
>
|
|
137
|
-
>${this.triggerText}</pkt-button
|
|
138
|
-
>` : l`<pkt-button @click=${this.openModal}>${this.triggerText}</pkt-button>`;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
r([
|
|
142
|
-
s({ type: Boolean })
|
|
143
|
-
], i.prototype, "devMode");
|
|
144
|
-
r([
|
|
145
|
-
s({ type: String })
|
|
146
|
-
], i.prototype, "hotjarId");
|
|
147
|
-
r([
|
|
148
|
-
s({ type: String })
|
|
149
|
-
], i.prototype, "googleAnalyticsId");
|
|
150
|
-
r([
|
|
151
|
-
s({ type: String })
|
|
152
|
-
], i.prototype, "cookieDomain");
|
|
153
|
-
r([
|
|
154
|
-
s({ type: String })
|
|
155
|
-
], i.prototype, "cookieSecure");
|
|
156
|
-
r([
|
|
157
|
-
s({ type: String })
|
|
158
|
-
], i.prototype, "cookieExpiryDays");
|
|
159
|
-
r([
|
|
160
|
-
s({ type: String })
|
|
161
|
-
], i.prototype, "triggerType");
|
|
162
|
-
r([
|
|
163
|
-
s({ type: String })
|
|
164
|
-
], i.prototype, "triggerText");
|
|
165
|
-
r([
|
|
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
|
-
}
|
|
173
|
-
export {
|
|
174
|
-
i as P
|
|
175
|
-
};
|