@oslokommune/punkt-react 13.19.0 → 13.19.1

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.
@@ -4836,8 +4836,8 @@ let Y = class extends K {
4836
4836
  })
4837
4837
  );
4838
4838
  }
4839
- handleLabelClick(t) {
4840
- this.disabled && (t.preventDefault(), t.stopImmediatePropagation()), this.dispatchEvent(
4839
+ handleLabelClick() {
4840
+ this.dispatchEvent(
4841
4841
  new CustomEvent("labelClick", {
4842
4842
  bubbles: !0,
4843
4843
  composed: !0,
@@ -5557,7 +5557,11 @@ let Q = class extends P {
5557
5557
  }
5558
5558
  handleInputClick(t) {
5559
5559
  var e, s;
5560
- this.disabled || (t.currentTarget && t.currentTarget !== this.arrowRef.value && ((e = this.inputRef.value) == null ? void 0 : e.type) !== "hidden" ? ((s = this.inputRef.value) == null || s.focus(), this.requestUpdate()) : this.handleArrowClick(t));
5560
+ if (this.disabled) {
5561
+ t.preventDefault(), t.stopImmediatePropagation();
5562
+ return;
5563
+ }
5564
+ t.currentTarget && t.currentTarget !== this.arrowRef.value && ((e = this.inputRef.value) == null ? void 0 : e.type) !== "hidden" ? ((s = this.inputRef.value) == null || s.focus(), this.requestUpdate()) : this.handleArrowClick(t);
5561
5565
  }
5562
5566
  handlePlaceholderClick(t) {
5563
5567
  this.disabled || (t.stopPropagation(), this.inputRef.value && this.inputRef.value.type !== "hidden" && (this.inputRef.value.focus(), this._inputFocus = !0, this.requestUpdate()));
@@ -493,7 +493,7 @@
493
493
  ${d()}
494
494
  `,f=()=>this.hasFieldset?u`<fieldset class="pkt-inputwrapper__fieldset" aria-describedby="${i}">
495
495
  ${p()}
496
- </fieldset>`:u`<div class="pkt-inputwrapper__fieldset">${p()}</div>`;return u`<div class=${M(t)}>${f()}</div> `}toggleDropdown(t){this.dispatchEvent(new CustomEvent("toggleHelpText",{bubbles:!1,detail:{isOpen:t.detail.isOpen}}))}handleLabelClick(t){this.disabled&&(t.preventDefault(),t.stopImmediatePropagation()),this.dispatchEvent(new CustomEvent("labelClick",{bubbles:!0,composed:!0,detail:"label clicked"}))}};J([o({type:String})],X.prototype,"forId",2),J([o({type:String})],X.prototype,"label",2),J([o({type:String})],X.prototype,"helptext",2),J([o({type:String})],X.prototype,"helptextDropdown",2),J([o({type:String})],X.prototype,"helptextDropdownButton",2),J([o({type:Boolean})],X.prototype,"counter",2),J([o({type:Number})],X.prototype,"counterCurrent",2),J([o({type:Number})],X.prototype,"counterMaxLength",2),J([o({type:String})],X.prototype,"counterError",2),J([o({type:String,reflect:!1})],X.prototype,"counterPosition",2),J([o({type:Boolean})],X.prototype,"optionalTag",2),J([o({type:String})],X.prototype,"optionalText",2),J([o({type:Boolean})],X.prototype,"requiredTag",2),J([o({type:String})],X.prototype,"requiredText",2),J([o({type:String})],X.prototype,"tagText",2),J([o({type:Boolean})],X.prototype,"hasError",2),J([o({type:String})],X.prototype,"errorMessage",2),J([o({type:Boolean})],X.prototype,"disabled",2),J([o({type:Boolean})],X.prototype,"inline",2),J([o({type:String})],X.prototype,"ariaDescribedby",2),J([o({type:Boolean})],X.prototype,"hasFieldset",2),J([o({type:String,reflect:!0})],X.prototype,"role",2),J([o({type:Boolean,reflect:!0,converter:$l})],X.prototype,"useWrapper",2),X=J([j("pkt-input-wrapper")],X);var _l=Object.defineProperty,wl=Object.getOwnPropertyDescriptor,yt=(s,t,e,i)=>{for(var a=i>1?void 0:i?wl(t,e):t,n=s.length-1,r;n>=0;n--)(r=s[n])&&(a=(i?r(t,e,a):r(a))||a);return i&&a&&_l(t,e,a),a};let gt=class extends Y{constructor(){super(...arguments),this.id=ke(),this.label=null,this.options=[],this.isOpen=!1,this.disabled=!1,this.includeSearch=!1,this.isMultiSelect=!1,this.allowUserInput=!1,this.maxIsReached=!1,this.customUserInput=null,this.searchPlaceholder=null,this.searchValue=null,this.maxLength=0,this.userMessage=null,this._selectedOptions=0,this._filteredOptions=[]}connectedCallback(){super.connectedCallback(),this.includeSearch&&!this.searchValue&&(this.searchValue=""),this.options.length>0&&this.filterOptions(),this.setAttribute("tabindex","-1"),this.addEventListener("focus",this.focusFirstOrSelectedOption)}updated(t){(t.has("options")||t.has("searchValue"))&&this.filterOptions(),super.updated(t)}attributeChangedCallback(t,e,i){(t==="options"||t==="searchValue"||t==="search-value")&&this.filterOptions(),super.attributeChangedCallback(t,e,i)}render(){return u`
496
+ </fieldset>`:u`<div class="pkt-inputwrapper__fieldset">${p()}</div>`;return u`<div class=${M(t)}>${f()}</div> `}toggleDropdown(t){this.dispatchEvent(new CustomEvent("toggleHelpText",{bubbles:!1,detail:{isOpen:t.detail.isOpen}}))}handleLabelClick(){this.dispatchEvent(new CustomEvent("labelClick",{bubbles:!0,composed:!0,detail:"label clicked"}))}};J([o({type:String})],X.prototype,"forId",2),J([o({type:String})],X.prototype,"label",2),J([o({type:String})],X.prototype,"helptext",2),J([o({type:String})],X.prototype,"helptextDropdown",2),J([o({type:String})],X.prototype,"helptextDropdownButton",2),J([o({type:Boolean})],X.prototype,"counter",2),J([o({type:Number})],X.prototype,"counterCurrent",2),J([o({type:Number})],X.prototype,"counterMaxLength",2),J([o({type:String})],X.prototype,"counterError",2),J([o({type:String,reflect:!1})],X.prototype,"counterPosition",2),J([o({type:Boolean})],X.prototype,"optionalTag",2),J([o({type:String})],X.prototype,"optionalText",2),J([o({type:Boolean})],X.prototype,"requiredTag",2),J([o({type:String})],X.prototype,"requiredText",2),J([o({type:String})],X.prototype,"tagText",2),J([o({type:Boolean})],X.prototype,"hasError",2),J([o({type:String})],X.prototype,"errorMessage",2),J([o({type:Boolean})],X.prototype,"disabled",2),J([o({type:Boolean})],X.prototype,"inline",2),J([o({type:String})],X.prototype,"ariaDescribedby",2),J([o({type:Boolean})],X.prototype,"hasFieldset",2),J([o({type:String,reflect:!0})],X.prototype,"role",2),J([o({type:Boolean,reflect:!0,converter:$l})],X.prototype,"useWrapper",2),X=J([j("pkt-input-wrapper")],X);var _l=Object.defineProperty,wl=Object.getOwnPropertyDescriptor,yt=(s,t,e,i)=>{for(var a=i>1?void 0:i?wl(t,e):t,n=s.length-1,r;n>=0;n--)(r=s[n])&&(a=(i?r(t,e,a):r(a))||a);return i&&a&&_l(t,e,a),a};let gt=class extends Y{constructor(){super(...arguments),this.id=ke(),this.label=null,this.options=[],this.isOpen=!1,this.disabled=!1,this.includeSearch=!1,this.isMultiSelect=!1,this.allowUserInput=!1,this.maxIsReached=!1,this.customUserInput=null,this.searchPlaceholder=null,this.searchValue=null,this.maxLength=0,this.userMessage=null,this._selectedOptions=0,this._filteredOptions=[]}connectedCallback(){super.connectedCallback(),this.includeSearch&&!this.searchValue&&(this.searchValue=""),this.options.length>0&&this.filterOptions(),this.setAttribute("tabindex","-1"),this.addEventListener("focus",this.focusFirstOrSelectedOption)}updated(t){(t.has("options")||t.has("searchValue"))&&this.filterOptions(),super.updated(t)}attributeChangedCallback(t,e,i){(t==="options"||t==="searchValue"||t==="search-value")&&this.filterOptions(),super.attributeChangedCallback(t,e,i)}render(){return u`
497
497
  <div
498
498
  class=${M({"pkt-listbox":!0,"pkt-listbox__open":this.isOpen,"pkt-txt-16-light":!0})}
499
499
  role="listbox"
@@ -715,7 +715,7 @@
715
715
  >${t.value}</span
716
716
  >`;case"label":default:return u`<span class="pkt-combobox__value" data-focusfix=${this.id}
717
717
  >${t.label||t.value}</span
718
- >`}}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){if(this._options=this.options.filter(i=>{var a;return(a=i.fulltext)==null?void 0:a.toLowerCase().includes(this._search.toLowerCase())}),t.inputType!=="deleteContentBackward"){const i=this._options.filter(a=>{var n;return!a.selected&&((n=a.label)==null?void 0:n.toLowerCase().startsWith(this._search.toLowerCase()))});if(i.length>0&&this.inputRef.value&&this.inputRef.value.type!=="hidden"){const a=i[0];a!=null&&a.label&&(e.value=a.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.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 e,i,a,n,r;if(!this.disabled&&((i=(e=t.relatedTarget)==null?void 0:e.closest("pkt-combobox"))==null?void 0:i.id)!==this.id&&((n=(a=t.relatedTarget)==null?void 0:a.closest("pkt-combobox"))==null?void 0:n.id)!==this.id&&((r=t.target)==null?void 0:r.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 h=this.inputRef.value.value,d=this.findValueInOptions(h);!this._value.includes(h)&&!d?this.allowUserInput?this.addNewUserValue(h):this.multiple||this.removeValue(this._value[0]):d&&!this._value.includes(d.value)&&this.setSelected(d.value),this.inputRef.value.value=""}this._isOptionsOpen=!1,this.onBlur()}}handleBlur(){this._inputFocus=!1,this._editingSingleValue=!1,this.onBlur()}handleInputClick(t){var e,i;this.disabled||(t.currentTarget&&t.currentTarget!==this.arrowRef.value&&((e=this.inputRef.value)==null?void 0:e.type)!=="hidden"?((i=this.inputRef.value)==null||i.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 e,i;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?(e=this.listboxRef.value)==null||e.focusFirstOrSelectedOption():(i=this.arrowRef.value)==null||i.focus())}handleOptionToggled(t){this.toggleValue(t.detail)}handleSearch(t){t.stopPropagation(),this._search=t.detail.toLowerCase()}handleInputKeydown(t){var e,i,a;switch(t.key){case",":this.multiple&&(t.preventDefault(),this.addValue());break;case"Enter":t.preventDefault(),this.addValue();break;case"Backspace":!this._search&&((e=this.inputRef.value)==null?void 0:e.type)==="hidden"&&this.removeLastValue(t);break;case"Tab":case"ArrowDown":t.shiftKey||((i=this.listboxRef.value)==null||i.focusFirstOrSelectedOption(),t.preventDefault());break;case"Escape":this._isOptionsOpen=!1,(a=this.arrowRef.value)==null||a.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 e=((t=this.inputRef.value)==null?void 0:t.value)||this._search||"",i=e.trim().toLowerCase()||"";if(!i){!this.multiple&&this._value[0]&&this.removeValue(this._value[0]),this.resetComboboxInput(!1);return}const a=this._value.find(h=>h.toLowerCase()===i),n=this._options.filter(h=>{var d;return((d=h.label)==null?void 0:d.toLowerCase().includes(i))??!1}),r=n.find(h=>{var d;return((d=h.label)==null?void 0:d.toLowerCase())===i||h.value.toLowerCase()===i});switch(!0){case((n.length===0||!r)&&this.allowUserInput):this._addValueText=e,this._userInfoMessage="";break;case(n.length===0&&!this._options.length&&!this.allowUserInput):this._addValueText=null,this._userInfoMessage="Ingen match i søket";break;case!!a:this._addValueText=null,this._userInfoMessage="Verdien er allerede valgt";break;case n.length>1:this._addValueText=null,this._userInfoMessage="";break;default:this._addValueText=null,this._userInfoMessage=""}}findValueInOptions(t){return this.options.find(e=>e.value===t||e.label===t)||null}findIndexInOptions(t){return this._options.findIndex(e=>e.value===t||e.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 e,i;if(this.disabled)return;this.touched=!0,this._userInfoMessage="",this._addValueText=null;const a=((e=this.findValueInOptions(t))==null?void 0:e.value)||null,n=this._value.includes(t||a||""),r=!!a,h=((i=this._options.find(S=>S.value===t))==null?void 0:i.disabled)||!1,d=!(t!=null&&t.trim()),p=!this.multiple,f=this.multiple,g=this.isMaxItemsReached();let y=!1,b=!0,k="",w="";h||(!r&&this.allowUserInput&&!d?(this.addNewUserValue(t),k="Ny verdi lagt til",y=!f):!r&&!this.allowUserInput?(p&&this._value[0]&&this.removeValue(this._value[0]),b=!1,y=!0,k="Ingen treff i søket"):n?(this.removeValue(a),y=!0):d&&p?(this.removeAllSelected(),y=!0):p?(this._value[0]&&this.removeSelected(this._value[0]),this.setSelected(a),y=!1,this.inputRef.value&&this.inputRef.value.type!=="hidden"&&(this.inputRef.value.value="",this.inputRef.value.blur())):f&&!g?(this.setSelected(a),y=!0):f&&g?(this._userInfoMessage="Maks antall valg nådd",b=!1,w=t):(p&&this.removeAllSelected(),this._userInfoMessage="Ingen gyldig verdi valgt",b=!1,y=!0,w=t),this._isOptionsOpen=y,y||window.setTimeout(()=>{var S;(S=this.focusRef.value)==null||S.focus()},0),this._userInfoMessage=k,this._search=w||"",this.resetComboboxInput(b),f&&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(e=>(e.value===t&&(e.selected=!0),e)),this.resetComboboxInput(!0)}}removeSelected(t){if(!t)return;this._value=this._value.filter(i=>i!==t);const e=this.findValueInOptions(t);e?(e.selected=!1,e.userAdded?(this._options=[...this._options.filter(i=>i.value!==t)],this.options=[...this.options.filter(i=>i.value!==t)]):this._options=[...this._options,e]):!t&&!this.multiple&&(this._options=this._options.map(i=>(i.selected=!1,i)))}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 e=((t=this.inputRef.value)==null?void 0:t.value.trim())||"";this._search=e,this.toggleValue(e)}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],this._isOptionsOpen=!1,this.blurInput();else if(!this.findValueInOptions(t)){if(this.isMaxItemsReached())return;this._value=[...this._value,t]}const e={value:t,label:t,userAdded:!0};this.options=[e,...this.options],this._options=[e,...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 e=this.findValueInOptions(this._value[0]);window.setTimeout(()=>{!this.inputRef.value||this.inputRef.value.type==="hidden"||(this.inputRef.value.value=this.displayValueAs==="label"&&e!=null&&e.label?e.label:this._value[0]||"")},0),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.isMaxItemsReached()}};et([o({type:String,reflect:!0})],tt.prototype,"value",2),et([o({type:Array})],tt.prototype,"options",2),et([o({type:Array})],tt.prototype,"defaultOptions",2),et([o({type:Boolean})],tt.prototype,"allowUserInput",2),et([o({type:Boolean})],tt.prototype,"typeahead",2),et([o({type:Boolean})],tt.prototype,"includeSearch",2),et([o({type:String})],tt.prototype,"searchPlaceholder",2),et([o({type:Boolean})],tt.prototype,"multiple",2),et([o({type:Number})],tt.prototype,"maxlength",2),et([o({type:String})],tt.prototype,"displayValueAs",2),et([o({type:String})],tt.prototype,"tagPlacement",2),et([V()],tt.prototype,"_options",2),et([V()],tt.prototype,"_isOptionsOpen",2),et([V()],tt.prototype,"_value",2),et([V()],tt.prototype,"_userInfoMessage",2),et([V()],tt.prototype,"_addValueText",2),et([V()],tt.prototype,"_maxIsReached",2),et([V()],tt.prototype,"_search",2),et([V()],tt.prototype,"_inputFocus",2),et([V()],tt.prototype,"_editingSingleValue",2),tt=et([j("pkt-combobox")],tt);const Nl={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 Al=Object.defineProperty,El=Object.getOwnPropertyDescriptor,ee=(s,t,e,i)=>{for(var a=i>1?void 0:i?El(t,e):t,n=s.length-1,r;n>=0;n--)(r=s[n])&&(a=(i?r(t,e,a):r(a))||a);return i&&a&&Al(t,e,a),a};let Mi=null;function Ml(){return Mi||(Mi=new Promise((s,t)=>{if(document.querySelector("#oslo-consent-script")){s();return}const e=document.createElement("script");e.src="https://cdn.web.oslo.kommune.no/cb/cb-v1.1.0.js",e.id="oslo-consent-script",e.onload=()=>s(),e.onerror=t,document.head.appendChild(e);const i=document.createElement("link");i.href="https://cdn.web.oslo.kommune.no/cb/cb-v1.1.0.css",i.type="text/css",i.rel="stylesheet",i.id="oslo-consent-styles",document.head.appendChild(i)}),Mi)}let Ht=class extends Y{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||Nl.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 e;try{e=JSON.parse(t)}catch{e=t}return e}emitCookieConsents(t){const e=this.returnJsonOrObject(t.value).items.reduce((i,a)=>(i[a.name]=a.consent,i),{});this.dispatchEvent(new CustomEvent("toggle-consent",{detail:e,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 Ml(),this.triggerInit()}triggerInit(){window.document.dispatchEvent(new Event("CookieBannerReady",{bubbles:!0,cancelable:!0})),window.cookieBanner.cookieConsent.validateConsentCookie().then(t=>{if(t){const e={value:window.cookieBanner.cookieConsent.getConsentCookie()};window.setTimeout(()=>this.emitCookieConsents(e),0),this._cookieEventHandler&&window.__cookieEvents.off("CookieManager.setCookie",this._cookieEventHandler),this._cookieEventHandler=i=>{this.emitCookieConsents(i)},window.__cookieEvents.on("CookieManager.setCookie",this._cookieEventHandler)}})}openModal(t){var e;t.preventDefault(),(e=window.cookieBanner)!=null&&e.cookieConsent||this.triggerInit(),setTimeout(()=>window.cookieBanner.openCookieModal())}render(){return this.triggerType==="link"?u`<a href="#" class="pkt-link" @click=${this.openModal}>${this.triggerText}</a>`:this.triggerType==="footerlink"?u`<a href="#" class="pkt-footer__link" @click=${this.openModal}>
718
+ >`}}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){if(this._options=this.options.filter(i=>{var a;return(a=i.fulltext)==null?void 0:a.toLowerCase().includes(this._search.toLowerCase())}),t.inputType!=="deleteContentBackward"){const i=this._options.filter(a=>{var n;return!a.selected&&((n=a.label)==null?void 0:n.toLowerCase().startsWith(this._search.toLowerCase()))});if(i.length>0&&this.inputRef.value&&this.inputRef.value.type!=="hidden"){const a=i[0];a!=null&&a.label&&(e.value=a.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.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 e,i,a,n,r;if(!this.disabled&&((i=(e=t.relatedTarget)==null?void 0:e.closest("pkt-combobox"))==null?void 0:i.id)!==this.id&&((n=(a=t.relatedTarget)==null?void 0:a.closest("pkt-combobox"))==null?void 0:n.id)!==this.id&&((r=t.target)==null?void 0:r.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 h=this.inputRef.value.value,d=this.findValueInOptions(h);!this._value.includes(h)&&!d?this.allowUserInput?this.addNewUserValue(h):this.multiple||this.removeValue(this._value[0]):d&&!this._value.includes(d.value)&&this.setSelected(d.value),this.inputRef.value.value=""}this._isOptionsOpen=!1,this.onBlur()}}handleBlur(){this._inputFocus=!1,this._editingSingleValue=!1,this.onBlur()}handleInputClick(t){var e,i;if(this.disabled){t.preventDefault(),t.stopImmediatePropagation();return}t.currentTarget&&t.currentTarget!==this.arrowRef.value&&((e=this.inputRef.value)==null?void 0:e.type)!=="hidden"?((i=this.inputRef.value)==null||i.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 e,i;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?(e=this.listboxRef.value)==null||e.focusFirstOrSelectedOption():(i=this.arrowRef.value)==null||i.focus())}handleOptionToggled(t){this.toggleValue(t.detail)}handleSearch(t){t.stopPropagation(),this._search=t.detail.toLowerCase()}handleInputKeydown(t){var e,i,a;switch(t.key){case",":this.multiple&&(t.preventDefault(),this.addValue());break;case"Enter":t.preventDefault(),this.addValue();break;case"Backspace":!this._search&&((e=this.inputRef.value)==null?void 0:e.type)==="hidden"&&this.removeLastValue(t);break;case"Tab":case"ArrowDown":t.shiftKey||((i=this.listboxRef.value)==null||i.focusFirstOrSelectedOption(),t.preventDefault());break;case"Escape":this._isOptionsOpen=!1,(a=this.arrowRef.value)==null||a.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 e=((t=this.inputRef.value)==null?void 0:t.value)||this._search||"",i=e.trim().toLowerCase()||"";if(!i){!this.multiple&&this._value[0]&&this.removeValue(this._value[0]),this.resetComboboxInput(!1);return}const a=this._value.find(h=>h.toLowerCase()===i),n=this._options.filter(h=>{var d;return((d=h.label)==null?void 0:d.toLowerCase().includes(i))??!1}),r=n.find(h=>{var d;return((d=h.label)==null?void 0:d.toLowerCase())===i||h.value.toLowerCase()===i});switch(!0){case((n.length===0||!r)&&this.allowUserInput):this._addValueText=e,this._userInfoMessage="";break;case(n.length===0&&!this._options.length&&!this.allowUserInput):this._addValueText=null,this._userInfoMessage="Ingen match i søket";break;case!!a:this._addValueText=null,this._userInfoMessage="Verdien er allerede valgt";break;case n.length>1:this._addValueText=null,this._userInfoMessage="";break;default:this._addValueText=null,this._userInfoMessage=""}}findValueInOptions(t){return this.options.find(e=>e.value===t||e.label===t)||null}findIndexInOptions(t){return this._options.findIndex(e=>e.value===t||e.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 e,i;if(this.disabled)return;this.touched=!0,this._userInfoMessage="",this._addValueText=null;const a=((e=this.findValueInOptions(t))==null?void 0:e.value)||null,n=this._value.includes(t||a||""),r=!!a,h=((i=this._options.find(S=>S.value===t))==null?void 0:i.disabled)||!1,d=!(t!=null&&t.trim()),p=!this.multiple,f=this.multiple,g=this.isMaxItemsReached();let y=!1,b=!0,k="",w="";h||(!r&&this.allowUserInput&&!d?(this.addNewUserValue(t),k="Ny verdi lagt til",y=!f):!r&&!this.allowUserInput?(p&&this._value[0]&&this.removeValue(this._value[0]),b=!1,y=!0,k="Ingen treff i søket"):n?(this.removeValue(a),y=!0):d&&p?(this.removeAllSelected(),y=!0):p?(this._value[0]&&this.removeSelected(this._value[0]),this.setSelected(a),y=!1,this.inputRef.value&&this.inputRef.value.type!=="hidden"&&(this.inputRef.value.value="",this.inputRef.value.blur())):f&&!g?(this.setSelected(a),y=!0):f&&g?(this._userInfoMessage="Maks antall valg nådd",b=!1,w=t):(p&&this.removeAllSelected(),this._userInfoMessage="Ingen gyldig verdi valgt",b=!1,y=!0,w=t),this._isOptionsOpen=y,y||window.setTimeout(()=>{var S;(S=this.focusRef.value)==null||S.focus()},0),this._userInfoMessage=k,this._search=w||"",this.resetComboboxInput(b),f&&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(e=>(e.value===t&&(e.selected=!0),e)),this.resetComboboxInput(!0)}}removeSelected(t){if(!t)return;this._value=this._value.filter(i=>i!==t);const e=this.findValueInOptions(t);e?(e.selected=!1,e.userAdded?(this._options=[...this._options.filter(i=>i.value!==t)],this.options=[...this.options.filter(i=>i.value!==t)]):this._options=[...this._options,e]):!t&&!this.multiple&&(this._options=this._options.map(i=>(i.selected=!1,i)))}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 e=((t=this.inputRef.value)==null?void 0:t.value.trim())||"";this._search=e,this.toggleValue(e)}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],this._isOptionsOpen=!1,this.blurInput();else if(!this.findValueInOptions(t)){if(this.isMaxItemsReached())return;this._value=[...this._value,t]}const e={value:t,label:t,userAdded:!0};this.options=[e,...this.options],this._options=[e,...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 e=this.findValueInOptions(this._value[0]);window.setTimeout(()=>{!this.inputRef.value||this.inputRef.value.type==="hidden"||(this.inputRef.value.value=this.displayValueAs==="label"&&e!=null&&e.label?e.label:this._value[0]||"")},0),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.isMaxItemsReached()}};et([o({type:String,reflect:!0})],tt.prototype,"value",2),et([o({type:Array})],tt.prototype,"options",2),et([o({type:Array})],tt.prototype,"defaultOptions",2),et([o({type:Boolean})],tt.prototype,"allowUserInput",2),et([o({type:Boolean})],tt.prototype,"typeahead",2),et([o({type:Boolean})],tt.prototype,"includeSearch",2),et([o({type:String})],tt.prototype,"searchPlaceholder",2),et([o({type:Boolean})],tt.prototype,"multiple",2),et([o({type:Number})],tt.prototype,"maxlength",2),et([o({type:String})],tt.prototype,"displayValueAs",2),et([o({type:String})],tt.prototype,"tagPlacement",2),et([V()],tt.prototype,"_options",2),et([V()],tt.prototype,"_isOptionsOpen",2),et([V()],tt.prototype,"_value",2),et([V()],tt.prototype,"_userInfoMessage",2),et([V()],tt.prototype,"_addValueText",2),et([V()],tt.prototype,"_maxIsReached",2),et([V()],tt.prototype,"_search",2),et([V()],tt.prototype,"_inputFocus",2),et([V()],tt.prototype,"_editingSingleValue",2),tt=et([j("pkt-combobox")],tt);const Nl={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 Al=Object.defineProperty,El=Object.getOwnPropertyDescriptor,ee=(s,t,e,i)=>{for(var a=i>1?void 0:i?El(t,e):t,n=s.length-1,r;n>=0;n--)(r=s[n])&&(a=(i?r(t,e,a):r(a))||a);return i&&a&&Al(t,e,a),a};let Mi=null;function Ml(){return Mi||(Mi=new Promise((s,t)=>{if(document.querySelector("#oslo-consent-script")){s();return}const e=document.createElement("script");e.src="https://cdn.web.oslo.kommune.no/cb/cb-v1.1.0.js",e.id="oslo-consent-script",e.onload=()=>s(),e.onerror=t,document.head.appendChild(e);const i=document.createElement("link");i.href="https://cdn.web.oslo.kommune.no/cb/cb-v1.1.0.css",i.type="text/css",i.rel="stylesheet",i.id="oslo-consent-styles",document.head.appendChild(i)}),Mi)}let Ht=class extends Y{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||Nl.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 e;try{e=JSON.parse(t)}catch{e=t}return e}emitCookieConsents(t){const e=this.returnJsonOrObject(t.value).items.reduce((i,a)=>(i[a.name]=a.consent,i),{});this.dispatchEvent(new CustomEvent("toggle-consent",{detail:e,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 Ml(),this.triggerInit()}triggerInit(){window.document.dispatchEvent(new Event("CookieBannerReady",{bubbles:!0,cancelable:!0})),window.cookieBanner.cookieConsent.validateConsentCookie().then(t=>{if(t){const e={value:window.cookieBanner.cookieConsent.getConsentCookie()};window.setTimeout(()=>this.emitCookieConsents(e),0),this._cookieEventHandler&&window.__cookieEvents.off("CookieManager.setCookie",this._cookieEventHandler),this._cookieEventHandler=i=>{this.emitCookieConsents(i)},window.__cookieEvents.on("CookieManager.setCookie",this._cookieEventHandler)}})}openModal(t){var e;t.preventDefault(),(e=window.cookieBanner)!=null&&e.cookieConsent||this.triggerInit(),setTimeout(()=>window.cookieBanner.openCookieModal())}render(){return this.triggerType==="link"?u`<a href="#" class="pkt-link" @click=${this.openModal}>${this.triggerText}</a>`:this.triggerType==="footerlink"?u`<a href="#" class="pkt-footer__link" @click=${this.openModal}>
719
719
  <pkt-icon name="chevron-right" class="pkt-footer__link-icon"></pkt-icon>
720
720
  ${this.triggerText}
721
721
  </a>`:this.triggerType==="icon"?u`<pkt-button
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oslokommune/punkt-react",
3
- "version": "13.19.0",
3
+ "version": "13.19.1",
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",
@@ -39,7 +39,7 @@
39
39
  "dependencies": {
40
40
  "@lit-labs/ssr-dom-shim": "^1.2.1",
41
41
  "@lit/react": "^1.0.7",
42
- "@oslokommune/punkt-elements": "^13.19.0",
42
+ "@oslokommune/punkt-elements": "^13.19.1",
43
43
  "classnames": "^2.5.1",
44
44
  "prettier": "^3.3.3",
45
45
  "react-hook-form": "^7.53.0"
@@ -103,5 +103,5 @@
103
103
  "url": "https://github.com/oslokommune/punkt/issues"
104
104
  },
105
105
  "license": "MIT",
106
- "gitHead": "859a6b67324a5b7992ef870bc776560bd454c043"
106
+ "gitHead": "5b4f6001bf615f85b3ea5cac18f4a2f8a14dfbd9"
107
107
  }