@oslokommune/punkt-react 13.5.10 → 13.5.11
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/dist/punkt-react.es.js +1465 -1449
- package/dist/punkt-react.umd.js +16 -3
- package/package.json +4 -4
package/dist/punkt-react.umd.js
CHANGED
|
@@ -856,7 +856,9 @@ You might need to use a local HTTP server (instead of file://): https://reactjs.
|
|
|
856
856
|
tabindex="-1"
|
|
857
857
|
@click=${this.handleInputClick}
|
|
858
858
|
>
|
|
859
|
-
${this.placeholder&&(!this._value.length||this.multiple&&this.tagPlacement=="outside")&&!this._inputFocus?Se`<span class="pkt-combobox__placeholder"
|
|
859
|
+
${this.placeholder&&(!this._value.length||this.multiple&&this.tagPlacement=="outside")&&!this._inputFocus?Se`<span class="pkt-combobox__placeholder" @click=${this.handlePlaceholderClick}
|
|
860
|
+
>${this.placeholder}</span
|
|
861
|
+
>`:this.tagPlacement!=="outside"?this.renderSingleOrMultipleValues():Ke}
|
|
860
862
|
${this.renderInputField()}
|
|
861
863
|
<div
|
|
862
864
|
class="pkt-btn pkt-btn--tertiary pkt-combobox__arrow"
|
|
@@ -878,7 +880,12 @@ You might need to use a local HTTP server (instead of file://): https://reactjs.
|
|
|
878
880
|
name="chevron-thin-down"
|
|
879
881
|
></pkt-icon>
|
|
880
882
|
</div>
|
|
881
|
-
<div
|
|
883
|
+
<div
|
|
884
|
+
${fn(this.focusRef)}
|
|
885
|
+
tabindex="-1"
|
|
886
|
+
@keydown=${this.handleArrowClick}
|
|
887
|
+
class="pkt-contents"
|
|
888
|
+
></div>
|
|
882
889
|
</div>
|
|
883
890
|
|
|
884
891
|
<pkt-listbox
|
|
@@ -943,7 +950,13 @@ You might need to use a local HTTP server (instead of file://): https://reactjs.
|
|
|
943
950
|
>
|
|
944
951
|
${this.renderValueTag(f)}
|
|
945
952
|
</pkt-tag>
|
|
946
|
-
`});return t?a:o}renderValueTag(t){if(!t)return"";switch(this.displayValueAs){case"prefixAndValue":return Se`<span data-focusfix=${this.id}>${t.prefix||""} ${t.value}</span>`;case"value":return Se`<span data-focusfix=${this.id}>${t.value}</span>`;case"label":default:return Se`<span data-focusfix=${this.id}>${t.label||t.value}</span>`}}handleInput(t){if(t.stopPropagation(),t.stopImmediatePropagation(),this.disabled)return;this.touched=!0;const a=t.target;if(this._search=a.value,this.checkForMatches(),this.typeahead)if(this._search){if(this._options=this.options.filter(o=>{var u;return(u=o.fulltext)==null?void 0:u.toLowerCase().includes(this._search.toLowerCase())}),t.inputType!=="deleteContentBackward"){const o=this._options.filter(u=>{var d;return!u.selected&&((d=u.label)==null?void 0:d.toLowerCase().startsWith(this._search.toLowerCase()))});if(o.length>0&&this.inputRef.value&&this.inputRef.value.type!=="hidden"){const u=o[0];u!=null&&u.label&&(a.value=u.label,window.setTimeout(()=>a.setSelectionRange(this._search.length,a.value.length),0),a.selectionDirection="backward")}}}else this._options=[...this.options]}handleFocus(){if(!this.disabled){if(!this.multiple&&this._value[0]&&this.inputRef.value&&this.inputRef.value.type!=="hidden"){const t=this.findValueInOptions(this._value[0]);this._editingSingleValue=!0,this.inputRef.value.value=this.displayValueAs==="label"&&t!=null&&t.label?t.label:this._value[0]}this._inputFocus=!0,this._search="",this._options=[...this.options],this._isOptionsOpen=!0,this.onFocus(),this.requestUpdate()}}handleFocusOut(t){var a,o,u,d,f;if(!this.disabled&&((o=(a=t.relatedTarget)==null?void 0:a.closest("pkt-combobox"))==null?void 0:o.id)!==this.id&&((d=(u=t.relatedTarget)==null?void 0:u.closest("pkt-combobox"))==null?void 0:d.id)!==this.id&&((f=t.target)==null?void 0:f.getAttribute("data-focusfix"))!==this.id&&t.relatedTarget!==this.focusRef.value&&t.relatedTarget!==this.inputRef.value&&t.relatedTarget!==this.arrowRef.value&&this._isOptionsOpen){if(this._inputFocus=!1,this._addValueText=null,this._userInfoMessage="",this._search="",this.inputRef.value&&this.inputRef.value.type!=="hidden"&&this.inputRef.value.value!==""){const y=this.inputRef.value.value,E=this.findValueInOptions(y);!this._value.includes(y)&&!E?this.allowUserInput?this.addNewUserValue(y):this.multiple||this.removeValue(this._value[0]):E&&!this._value.includes(E.value)&&this.setSelected(E.value),this.inputRef.value.value=""}this._isOptionsOpen=!1,this.onBlur()}}handleBlur(){this._inputFocus=!1,this._editingSingleValue=!1,this.onBlur()}handleInputClick(t){var a,o;this.disabled||(t.currentTarget&&t.currentTarget!==this.arrowRef.value&&((a=this.inputRef.value)==null?void 0:a.type)!=="hidden"?(o=this.inputRef.value)==null||o.focus():this.handleArrowClick(t))}handleArrowClick(t){var a,o;this.disabled||t instanceof KeyboardEvent&&t.key&&t.key!=="Enter"&&t.key!==" "&&t.key!=="ArrowDown"||(t.stopImmediatePropagation(),t.preventDefault(),this._isOptionsOpen=!this._isOptionsOpen,this._isOptionsOpen?(a=this.listboxRef.value)==null||a.focusFirstOrSelectedOption():(o=this.arrowRef.value)==null||o.focus())}handleOptionToggled(t){this.toggleValue(t.detail)}handleSearch(t){t.stopPropagation(),this._search=t.detail.toLowerCase()}handleInputKeydown(t){var a,o,u;switch(t.key){case",":this.multiple&&(t.preventDefault(),this.addValue());break;case"Enter":t.preventDefault(),this.addValue();break;case"Backspace":!this._search&&((a=this.inputRef.value)==null?void 0:a.type)==="hidden"&&this.removeLastValue(t);break;case"Tab":case"ArrowDown":t.shiftKey||((o=this.listboxRef.value)==null||o.focusFirstOrSelectedOption(),t.preventDefault());break;case"Escape":this._isOptionsOpen=!1,(u=this.arrowRef.value)==null||u.focus(),t.preventDefault();break}}handleTagRemove(t){this.removeSelected(t)}blurInput(){this.inputRef.value&&this.inputRef.value.matches(":focus")&&this.inputRef.value.blur()}checkForMatches(){var t;const a=((t=this.inputRef.value)==null?void 0:t.value)||this._search||"",o=a.trim().toLowerCase()||"";if(!o){!this.multiple&&this._value[0]&&this.removeValue(this._value[0]),this.resetComboboxInput(!1);return}const u=this._value.find(y=>y.toLowerCase()===o),d=this._options.filter(y=>{var E;return((E=y.label)==null?void 0:E.toLowerCase().includes(o))??!1}),f=d.find(y=>{var E;return((E=y.label)==null?void 0:E.toLowerCase())===o||y.value.toLowerCase()===o});switch(!0){case((d.length===0||!f)&&this.allowUserInput):this._addValueText=a,this._userInfoMessage="";break;case(d.length===0&&!this.allowUserInput):this._addValueText=null,this._userInfoMessage="Ingen match i søket";break;case!!u:this._addValueText=null,this._userInfoMessage="Verdien er allerede valgt";break;case d.length>1:this._addValueText=null,this._userInfoMessage="";break;default:this._addValueText=null,this._userInfoMessage=""}}findValueInOptions(t){return this.options.find(a=>a.value===t||a.label===t)||null}findIndexInOptions(t){return this._options.findIndex(a=>a.value===t||a.label===t)}isMaxItemsReached(){const t=this.maxlength!==null&&this._value.length>=this.maxlength;return t?this._maxIsReached=!0:this._maxIsReached=!1,t}toggleValue(t){var a,o;if(this.disabled)return;this.touched=!0,this._userInfoMessage="",this._addValueText=null;const u=((a=this.findValueInOptions(t))==null?void 0:a.value)||null,d=this._value.includes(t||u||""),f=!!u,y=((o=this._options.find($=>$.value===t))==null?void 0:o.disabled)||!1,E=!(t!=null&&t.trim()),_=!this.multiple,D=this.multiple,x=this.isMaxItemsReached();let N=!1,L=!0,P="",j="";y||(!f&&this.allowUserInput&&!E?(this.addNewUserValue(t),P="Ny verdi lagt til",N=!D):!f&&!this.allowUserInput?(_&&this._value[0]&&this.removeValue(this._value[0]),L=!1,N=!0,P="Ingen treff i søket"):d?(this.removeValue(u),N=!0):E&&_?(this.removeAllSelected(),N=!0):_?(this._value[0]&&this.removeSelected(this._value[0]),this.setSelected(u),N=!1,this.inputRef.value&&this.inputRef.value.type!=="hidden"&&(this.inputRef.value.value="",this.inputRef.value.blur())):D&&!x?(this.setSelected(u),N=!0):D&&x?(this._userInfoMessage="Maks antall valg nådd",L=!1,j=t):(_&&this.removeAllSelected(),this._userInfoMessage="Ingen gyldig verdi valgt",L=!1,N=!0,j=t),this._isOptionsOpen=N,N||window.setTimeout(()=>{var $;($=this.focusRef.value)==null||$.focus()},0),this._userInfoMessage=P,this._search=j||"",this.resetComboboxInput(L),D&&this.isMaxItemsReached())}setSelected(t){if(!this._value.includes(t)){if(this.multiple&&this.isMaxItemsReached()){this._userInfoMessage="Maks antall valg nådd";return}!this.multiple&&this.removeAllSelected(),this._value=t?[...this._value,t]:this._value,this._options=this._options.map(a=>(a.value===t&&(a.selected=!0),a)),this.resetComboboxInput(!0)}}removeSelected(t){if(!t)return;this._value=this._value.filter(o=>o!==t);const a=this.findValueInOptions(t);a?(a.selected=!1,a.userAdded?(this._options=[...this._options.filter(o=>o.value!==t)],this.options=[...this.options.filter(o=>o.value!==t)]):this._options=[...this._options,a]):!t&&!this.multiple&&(this._options=this._options.map(o=>(o.selected=!1,o)))}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),this._options=this._options.map(t=>(t.selected=!0,t)),this.requestUpdate()}}removeAllSelected(){this._value=[],this._options=this._options.map(t=>(t.selected=!1,t)),this._options=this._options.filter(t=>!t.userAdded),this.requestUpdate()}addValue(){var t;const a=((t=this.inputRef.value)==null?void 0:t.value.trim())||"";this._search=a,this.toggleValue(a)}removeValue(t){this._value=this.multiple?this._value.filter(a=>a!==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],this._isOptionsOpen=!1,this.blurInput();else if(!this.findValueInOptions(t)){if(this.isMaxItemsReached())return;this._value=[...this._value,t]}const a={value:t,label:t,userAdded:!0};this.options=[a,...this.options],this._options=[a,...this._options],this.setSelected(t),this.requestUpdate()}resetComboboxInput(t=!0){if(this._addValueText=null,this.inputRef.value&&this.inputRef.value.type!=="hidden"&&t)if(this._search="",this.multiple)this.inputRef.value.value="";else{const a=this.findValueInOptions(this._value[0]);window.setTimeout(()=>{!this.inputRef.value||this.inputRef.value.type==="hidden"||(this.inputRef.value.value=this.displayValueAs==="label"&&a!=null&&a.label?a.label:this._value[0]||"")},0),this._userInfoMessage=""}this._options=[...this.options]}removeLastValue(t){if(this._value.length===0)return;t.preventDefault();const a=this._value[this._value.length-1];a&&this.removeSelected(a),this.isMaxItemsReached()}};ra([G({type:String,reflect:!0})],qr.prototype,"value",2),ra([G({type:Array})],qr.prototype,"options",2),ra([G({type:Array})],qr.prototype,"defaultOptions",2),ra([G({type:Boolean})],qr.prototype,"allowUserInput",2),ra([G({type:Boolean})],qr.prototype,"typeahead",2),ra([G({type:Boolean})],qr.prototype,"includeSearch",2),ra([G({type:String})],qr.prototype,"searchPlaceholder",2),ra([G({type:Boolean})],qr.prototype,"multiple",2),ra([G({type:Number})],qr.prototype,"maxlength",2),ra([G({type:String})],qr.prototype,"displayValueAs",2),ra([G({type:String})],qr.prototype,"tagPlacement",2),ra([Fn()],qr.prototype,"_options",2),ra([Fn()],qr.prototype,"_isOptionsOpen",2),ra([Fn()],qr.prototype,"_value",2),ra([Fn()],qr.prototype,"_userInfoMessage",2),ra([Fn()],qr.prototype,"_addValueText",2),ra([Fn()],qr.prototype,"_maxIsReached",2),ra([Fn()],qr.prototype,"_search",2),ra([Fn()],qr.prototype,"_inputFocus",2),ra([Fn()],qr.prototype,"_editingSingleValue",2),qr=ra([hr("pkt-combobox")],qr);const _H={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 CH=Object.defineProperty,DH=Object.getOwnPropertyDescriptor,yu=(e,t,a,o)=>{for(var u=o>1?void 0:o?DH(t,a):t,d=e.length-1,f;d>=0;d--)(f=e[d])&&(u=(o?f(t,a,u):f(u))||u);return o&&u&&CH(t,a,u),u};let Mk=null;function TH(){return Mk||(Mk=new Promise((e,t)=>{if(document.querySelector("#oslo-consent-script")){e();return}const a=document.createElement("script");a.src="https://cdn.web.oslo.kommune.no/cb/cb-v1.1.0.js",a.id="oslo-consent-script",a.onload=()=>e(),a.onerror=t,document.head.appendChild(a);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)}),Mk)}let Fs=class extends pa{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||_H.i18n[this.i18nLanguage].contentPresentation.buttons.settings}disconnectedCallback(){var t;super.disconnectedCallback(),this._cookieEventHandler&&((t=window.__cookieEvents)==null||t.off("CookieManager.setCookie",this._cookieEventHandler))}returnJsonOrObject(t){let a;try{a=JSON.parse(t)}catch{a=t}return a}emitCookieConsents(t){const a=this.returnJsonOrObject(t.value).items.reduce((o,u)=>(o[u.name]=u.consent,o),{});this.dispatchEvent(new CustomEvent("toggle-consent",{detail:a,bubbles:!0,cancelable:!1}))}async firstUpdated(t){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 TH(),this.triggerInit()}triggerInit(){window.document.dispatchEvent(new Event("CookieBannerReady",{bubbles:!0,cancelable:!0})),window.cookieBanner.cookieConsent.validateConsentCookie().then(t=>{if(t){const a={value:window.cookieBanner.cookieConsent.getConsentCookie()};window.setTimeout(()=>this.emitCookieConsents(a),0),this._cookieEventHandler&&window.__cookieEvents.off("CookieManager.setCookie",this._cookieEventHandler),this._cookieEventHandler=o=>{this.emitCookieConsents(o)},window.__cookieEvents.on("CookieManager.setCookie",this._cookieEventHandler)}})}openModal(t){var a;t.preventDefault(),(a=window.cookieBanner)!=null&&a.cookieConsent||this.triggerInit(),setTimeout(()=>window.cookieBanner.openCookieModal())}render(){return this.triggerType==="link"?Se`<a href="#" class="pkt-link" @click=${this.openModal}>${this.triggerText}</a>`:this.triggerType==="footerlink"?Se`<a href="#" class="pkt-footer__link" @click=${this.openModal}>
|
|
953
|
+
`});return t?a:o}renderValueTag(t){if(!t)return"";switch(this.displayValueAs){case"prefixAndValue":return Se`<span class="pkt-combobox__value" data-focusfix=${this.id}
|
|
954
|
+
>${t.prefix||""} ${t.value}</span
|
|
955
|
+
>`;case"value":return Se`<span class="pkt-combobox__value" data-focusfix=${this.id}
|
|
956
|
+
>${t.value}</span
|
|
957
|
+
>`;case"label":default:return Se`<span class="pkt-combobox__value" data-focusfix=${this.id}
|
|
958
|
+
>${t.label||t.value}</span
|
|
959
|
+
>`}}handleInput(t){if(t.stopPropagation(),t.stopImmediatePropagation(),this.disabled)return;this.touched=!0;const a=t.target;if(this._search=a.value,this.checkForMatches(),this.typeahead)if(this._search){if(this._options=this.options.filter(o=>{var u;return(u=o.fulltext)==null?void 0:u.toLowerCase().includes(this._search.toLowerCase())}),t.inputType!=="deleteContentBackward"){const o=this._options.filter(u=>{var d;return!u.selected&&((d=u.label)==null?void 0:d.toLowerCase().startsWith(this._search.toLowerCase()))});if(o.length>0&&this.inputRef.value&&this.inputRef.value.type!=="hidden"){const u=o[0];u!=null&&u.label&&(a.value=u.label,window.setTimeout(()=>a.setSelectionRange(this._search.length,a.value.length),0),a.selectionDirection="backward")}}}else this._options=[...this.options]}handleFocus(){if(!this.disabled){if(!this.multiple&&this._value[0]&&this.inputRef.value&&this.inputRef.value.type!=="hidden"){const t=this.findValueInOptions(this._value[0]);this._editingSingleValue=!0,this.inputRef.value.value=this.displayValueAs==="label"&&t!=null&&t.label?t.label:this._value[0]}this._inputFocus=!0,this._search="",this._options=[...this.options],this._isOptionsOpen=!0,this.onFocus(),this.requestUpdate()}}handleFocusOut(t){var a,o,u,d,f;if(!this.disabled&&((o=(a=t.relatedTarget)==null?void 0:a.closest("pkt-combobox"))==null?void 0:o.id)!==this.id&&((d=(u=t.relatedTarget)==null?void 0:u.closest("pkt-combobox"))==null?void 0:d.id)!==this.id&&((f=t.target)==null?void 0:f.getAttribute("data-focusfix"))!==this.id&&t.relatedTarget!==this.focusRef.value&&t.relatedTarget!==this.inputRef.value&&t.relatedTarget!==this.arrowRef.value&&this._isOptionsOpen){if(this._inputFocus=!1,this._addValueText=null,this._userInfoMessage="",this._search="",this.inputRef.value&&this.inputRef.value.type!=="hidden"&&this.inputRef.value.value!==""){const y=this.inputRef.value.value,E=this.findValueInOptions(y);!this._value.includes(y)&&!E?this.allowUserInput?this.addNewUserValue(y):this.multiple||this.removeValue(this._value[0]):E&&!this._value.includes(E.value)&&this.setSelected(E.value),this.inputRef.value.value=""}this._isOptionsOpen=!1,this.onBlur()}}handleBlur(){this._inputFocus=!1,this._editingSingleValue=!1,this.onBlur()}handleInputClick(t){var a,o;this.disabled||(t.currentTarget&&t.currentTarget!==this.arrowRef.value&&((a=this.inputRef.value)==null?void 0:a.type)!=="hidden"?((o=this.inputRef.value)==null||o.focus(),this.requestUpdate()):this.handleArrowClick(t))}handlePlaceholderClick(t){this.disabled||(t.stopPropagation(),this.inputRef.value&&this.inputRef.value.type!=="hidden"&&(this.inputRef.value.focus(),this._inputFocus=!0,this.requestUpdate()))}handleArrowClick(t){var a,o;this.disabled||t instanceof KeyboardEvent&&t.key&&t.key!=="Enter"&&t.key!==" "&&t.key!=="ArrowDown"||(t.stopImmediatePropagation(),t.preventDefault(),this._isOptionsOpen=!this._isOptionsOpen,this._isOptionsOpen?(a=this.listboxRef.value)==null||a.focusFirstOrSelectedOption():(o=this.arrowRef.value)==null||o.focus())}handleOptionToggled(t){this.toggleValue(t.detail)}handleSearch(t){t.stopPropagation(),this._search=t.detail.toLowerCase()}handleInputKeydown(t){var a,o,u;switch(t.key){case",":this.multiple&&(t.preventDefault(),this.addValue());break;case"Enter":t.preventDefault(),this.addValue();break;case"Backspace":!this._search&&((a=this.inputRef.value)==null?void 0:a.type)==="hidden"&&this.removeLastValue(t);break;case"Tab":case"ArrowDown":t.shiftKey||((o=this.listboxRef.value)==null||o.focusFirstOrSelectedOption(),t.preventDefault());break;case"Escape":this._isOptionsOpen=!1,(u=this.arrowRef.value)==null||u.focus(),t.preventDefault();break}}handleTagRemove(t){this.removeSelected(t)}blurInput(){this.inputRef.value&&this.inputRef.value.matches(":focus")&&this.inputRef.value.blur()}checkForMatches(){var t;const a=((t=this.inputRef.value)==null?void 0:t.value)||this._search||"",o=a.trim().toLowerCase()||"";if(!o){!this.multiple&&this._value[0]&&this.removeValue(this._value[0]),this.resetComboboxInput(!1);return}const u=this._value.find(y=>y.toLowerCase()===o),d=this._options.filter(y=>{var E;return((E=y.label)==null?void 0:E.toLowerCase().includes(o))??!1}),f=d.find(y=>{var E;return((E=y.label)==null?void 0:E.toLowerCase())===o||y.value.toLowerCase()===o});switch(!0){case((d.length===0||!f)&&this.allowUserInput):this._addValueText=a,this._userInfoMessage="";break;case(d.length===0&&!this.allowUserInput):this._addValueText=null,this._userInfoMessage="Ingen match i søket";break;case!!u:this._addValueText=null,this._userInfoMessage="Verdien er allerede valgt";break;case d.length>1:this._addValueText=null,this._userInfoMessage="";break;default:this._addValueText=null,this._userInfoMessage=""}}findValueInOptions(t){return this.options.find(a=>a.value===t||a.label===t)||null}findIndexInOptions(t){return this._options.findIndex(a=>a.value===t||a.label===t)}isMaxItemsReached(){const t=this.maxlength!==null&&this._value.length>=this.maxlength;return t?this._maxIsReached=!0:this._maxIsReached=!1,t}toggleValue(t){var a,o;if(this.disabled)return;this.touched=!0,this._userInfoMessage="",this._addValueText=null;const u=((a=this.findValueInOptions(t))==null?void 0:a.value)||null,d=this._value.includes(t||u||""),f=!!u,y=((o=this._options.find($=>$.value===t))==null?void 0:o.disabled)||!1,E=!(t!=null&&t.trim()),_=!this.multiple,D=this.multiple,x=this.isMaxItemsReached();let N=!1,L=!0,P="",j="";y||(!f&&this.allowUserInput&&!E?(this.addNewUserValue(t),P="Ny verdi lagt til",N=!D):!f&&!this.allowUserInput?(_&&this._value[0]&&this.removeValue(this._value[0]),L=!1,N=!0,P="Ingen treff i søket"):d?(this.removeValue(u),N=!0):E&&_?(this.removeAllSelected(),N=!0):_?(this._value[0]&&this.removeSelected(this._value[0]),this.setSelected(u),N=!1,this.inputRef.value&&this.inputRef.value.type!=="hidden"&&(this.inputRef.value.value="",this.inputRef.value.blur())):D&&!x?(this.setSelected(u),N=!0):D&&x?(this._userInfoMessage="Maks antall valg nådd",L=!1,j=t):(_&&this.removeAllSelected(),this._userInfoMessage="Ingen gyldig verdi valgt",L=!1,N=!0,j=t),this._isOptionsOpen=N,N||window.setTimeout(()=>{var $;($=this.focusRef.value)==null||$.focus()},0),this._userInfoMessage=P,this._search=j||"",this.resetComboboxInput(L),D&&this.isMaxItemsReached())}setSelected(t){if(!this._value.includes(t)){if(this.multiple&&this.isMaxItemsReached()){this._userInfoMessage="Maks antall valg nådd";return}!this.multiple&&this.removeAllSelected(),this._value=t?[...this._value,t]:this._value,this._options=this._options.map(a=>(a.value===t&&(a.selected=!0),a)),this.resetComboboxInput(!0)}}removeSelected(t){if(!t)return;this._value=this._value.filter(o=>o!==t);const a=this.findValueInOptions(t);a?(a.selected=!1,a.userAdded?(this._options=[...this._options.filter(o=>o.value!==t)],this.options=[...this.options.filter(o=>o.value!==t)]):this._options=[...this._options,a]):!t&&!this.multiple&&(this._options=this._options.map(o=>(o.selected=!1,o)))}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),this._options=this._options.map(t=>(t.selected=!0,t)),this.requestUpdate()}}removeAllSelected(){this._value=[],this._options=this._options.map(t=>(t.selected=!1,t)),this._options=this._options.filter(t=>!t.userAdded),this.requestUpdate()}addValue(){var t;const a=((t=this.inputRef.value)==null?void 0:t.value.trim())||"";this._search=a,this.toggleValue(a)}removeValue(t){this._value=this.multiple?this._value.filter(a=>a!==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],this._isOptionsOpen=!1,this.blurInput();else if(!this.findValueInOptions(t)){if(this.isMaxItemsReached())return;this._value=[...this._value,t]}const a={value:t,label:t,userAdded:!0};this.options=[a,...this.options],this._options=[a,...this._options],this.setSelected(t),this.requestUpdate()}resetComboboxInput(t=!0){if(this._addValueText=null,this.inputRef.value&&this.inputRef.value.type!=="hidden"&&t)if(this._search="",this.multiple)this.inputRef.value.value="";else{const a=this.findValueInOptions(this._value[0]);window.setTimeout(()=>{!this.inputRef.value||this.inputRef.value.type==="hidden"||(this.inputRef.value.value=this.displayValueAs==="label"&&a!=null&&a.label?a.label:this._value[0]||"")},0),this._userInfoMessage=""}this._options=[...this.options]}removeLastValue(t){if(this._value.length===0)return;t.preventDefault();const a=this._value[this._value.length-1];a&&this.removeSelected(a),this.isMaxItemsReached()}};ra([G({type:String,reflect:!0})],qr.prototype,"value",2),ra([G({type:Array})],qr.prototype,"options",2),ra([G({type:Array})],qr.prototype,"defaultOptions",2),ra([G({type:Boolean})],qr.prototype,"allowUserInput",2),ra([G({type:Boolean})],qr.prototype,"typeahead",2),ra([G({type:Boolean})],qr.prototype,"includeSearch",2),ra([G({type:String})],qr.prototype,"searchPlaceholder",2),ra([G({type:Boolean})],qr.prototype,"multiple",2),ra([G({type:Number})],qr.prototype,"maxlength",2),ra([G({type:String})],qr.prototype,"displayValueAs",2),ra([G({type:String})],qr.prototype,"tagPlacement",2),ra([Fn()],qr.prototype,"_options",2),ra([Fn()],qr.prototype,"_isOptionsOpen",2),ra([Fn()],qr.prototype,"_value",2),ra([Fn()],qr.prototype,"_userInfoMessage",2),ra([Fn()],qr.prototype,"_addValueText",2),ra([Fn()],qr.prototype,"_maxIsReached",2),ra([Fn()],qr.prototype,"_search",2),ra([Fn()],qr.prototype,"_inputFocus",2),ra([Fn()],qr.prototype,"_editingSingleValue",2),qr=ra([hr("pkt-combobox")],qr);const _H={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 CH=Object.defineProperty,DH=Object.getOwnPropertyDescriptor,yu=(e,t,a,o)=>{for(var u=o>1?void 0:o?DH(t,a):t,d=e.length-1,f;d>=0;d--)(f=e[d])&&(u=(o?f(t,a,u):f(u))||u);return o&&u&&CH(t,a,u),u};let Mk=null;function TH(){return Mk||(Mk=new Promise((e,t)=>{if(document.querySelector("#oslo-consent-script")){e();return}const a=document.createElement("script");a.src="https://cdn.web.oslo.kommune.no/cb/cb-v1.1.0.js",a.id="oslo-consent-script",a.onload=()=>e(),a.onerror=t,document.head.appendChild(a);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)}),Mk)}let Fs=class extends pa{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||_H.i18n[this.i18nLanguage].contentPresentation.buttons.settings}disconnectedCallback(){var t;super.disconnectedCallback(),this._cookieEventHandler&&((t=window.__cookieEvents)==null||t.off("CookieManager.setCookie",this._cookieEventHandler))}returnJsonOrObject(t){let a;try{a=JSON.parse(t)}catch{a=t}return a}emitCookieConsents(t){const a=this.returnJsonOrObject(t.value).items.reduce((o,u)=>(o[u.name]=u.consent,o),{});this.dispatchEvent(new CustomEvent("toggle-consent",{detail:a,bubbles:!0,cancelable:!1}))}async firstUpdated(t){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 TH(),this.triggerInit()}triggerInit(){window.document.dispatchEvent(new Event("CookieBannerReady",{bubbles:!0,cancelable:!0})),window.cookieBanner.cookieConsent.validateConsentCookie().then(t=>{if(t){const a={value:window.cookieBanner.cookieConsent.getConsentCookie()};window.setTimeout(()=>this.emitCookieConsents(a),0),this._cookieEventHandler&&window.__cookieEvents.off("CookieManager.setCookie",this._cookieEventHandler),this._cookieEventHandler=o=>{this.emitCookieConsents(o)},window.__cookieEvents.on("CookieManager.setCookie",this._cookieEventHandler)}})}openModal(t){var a;t.preventDefault(),(a=window.cookieBanner)!=null&&a.cookieConsent||this.triggerInit(),setTimeout(()=>window.cookieBanner.openCookieModal())}render(){return this.triggerType==="link"?Se`<a href="#" class="pkt-link" @click=${this.openModal}>${this.triggerText}</a>`:this.triggerType==="footerlink"?Se`<a href="#" class="pkt-footer__link" @click=${this.openModal}>
|
|
947
960
|
<pkt-icon name="chevron-right" class="pkt-footer__link-icon"></pkt-icon>
|
|
948
961
|
${this.triggerText}
|
|
949
962
|
</a>`:this.triggerType==="icon"?Se`<pkt-button
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@oslokommune/punkt-react",
|
|
3
|
-
"version": "13.5.
|
|
3
|
+
"version": "13.5.11",
|
|
4
4
|
"description": "React komponentbibliotek til Punkt, et designsystem laget av Oslo Origo",
|
|
5
5
|
"homepage": "https://punkt.oslo.kommune.no",
|
|
6
6
|
"author": "Team Designsystem, Oslo Origo",
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@lit-labs/ssr-dom-shim": "^1.2.1",
|
|
40
40
|
"@lit/react": "^1.0.7",
|
|
41
|
-
"@oslokommune/punkt-elements": "^13.5.
|
|
41
|
+
"@oslokommune/punkt-elements": "^13.5.11",
|
|
42
42
|
"prettier": "^3.3.3",
|
|
43
43
|
"react-element-to-jsx-string": "^15.0.0",
|
|
44
44
|
"react-hook-form": "^7.53.0",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"devDependencies": {
|
|
48
48
|
"@babel/plugin-transform-private-property-in-object": "^7.25.9",
|
|
49
49
|
"@oslokommune/punkt-assets": "^13.3.1",
|
|
50
|
-
"@oslokommune/punkt-css": "^13.5.
|
|
50
|
+
"@oslokommune/punkt-css": "^13.5.11",
|
|
51
51
|
"@testing-library/jest-dom": "^6.5.0",
|
|
52
52
|
"@testing-library/react": "^16.0.1",
|
|
53
53
|
"@testing-library/user-event": "^14.5.2",
|
|
@@ -110,5 +110,5 @@
|
|
|
110
110
|
"url": "https://github.com/oslokommune/punkt/issues"
|
|
111
111
|
},
|
|
112
112
|
"license": "MIT",
|
|
113
|
-
"gitHead": "
|
|
113
|
+
"gitHead": "09ba8de9047136b06b520d7208b31a1743bcf1d7"
|
|
114
114
|
}
|