scb-wc 0.1.71 → 0.1.73
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/README.md +15 -10
- package/bin/scb-wc.mjs +39 -7
- package/blazor/ScbBlazorInteropBase.cs +9 -0
- package/mvc/components/scb-dropdown/scb-dropdown.js +1 -1
- package/mvc/components/scb-header/scb-header.js +65 -66
- package/mvc/components/scb-list/scb-list.js +1 -1
- package/mvc/components/scb-search/scb-search.js +6 -5
- package/mvc/scb-wc-selfhost.css +3 -6
- package/package.json +2 -2
- package/scb-components/scb-header/scb-header.d.ts +6 -3
- package/scb-components/scb-search/scb-search.d.ts +6 -0
- package/scb-header/scb-header.js +51 -37
- package/scb-search/scb-search.js +41 -22
- package/scb-wc-selfhost.css +3 -6
- package/scb-wc.bundle.js +231 -232
- package/fonts/material-symbols-outlined/files/material-symbols-outlined-latin-wght-normal.woff2 +0 -0
- package/mvc/fonts/material-symbols-outlined/files/material-symbols-outlined-latin-wght-normal.woff2 +0 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["../scb-drawer/scb-drawer.js","../../vendor/decorate.js","../../vendor/vendor.js","../../vendor/vendor-lit.js","../scb-divider/scb-divider.js","../../vendor/assertClassBrand.js","../scb-menu/scb-menu.js","../scb-menu/scb-menu-item.js","../../vendor/preload-helper.js","../../vendor/scb-chevron.js","../scb-menu/scb-menu-section.js","../scb-menu/scb-sub-menu.js"])))=>i.map(i=>d[i]);
|
|
2
|
-
import"../../vendor/vendor-material.js";import{_ as E,b as P,g as I,h as c,m as S,v,y as
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["../scb-drawer/scb-drawer.js","../../vendor/decorate.js","../../vendor/vendor.js","../../vendor/vendor-lit.js","../scb-divider/scb-divider.js","../../vendor/assertClassBrand.js","../scb-menu/scb-menu.js","../scb-menu/scb-menu-item.js","../../vendor/preload-helper.js","../../vendor/scb-chevron.js","../scb-menu/scb-menu-section.js","../scb-menu/scb-sub-menu.js","../scb-dropdown/scb-dropdown.js","../../vendor/vendor-material.js","../scb-button/scb-button.js","../scb-options-menu/scb-options-menu.js","../scb-options-menu/scb-options-menu-item.js","../scb-options-menu/scb-options-sub-menu.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import"../../vendor/vendor-material.js";import{_ as E,b as P,g as I,h as c,m as S,v as _,y as m}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import{t as l}from"../../vendor/decorate.js";import"../scb-button/scb-button.js";import{t as T}from"../../vendor/preload-helper.js";import"../scb-icon-button/scb-icon-button.js";import"../scb-search/scb-search.js";import"../scb-grid/scb-grid-item.js";import"../scb-grid/scb-grid.js";import"../scb-skeleton/scb-skeleton.js";(function(){try{var p=typeof globalThis<"u"?globalThis:window;if(!p.__scb_ce_guard_installed__){p.__scb_ce_guard_installed__=!0;var e=customElements.define.bind(customElements);customElements.define=function(t,s,r){try{customElements.get(t)||e(t,s,r)}catch(a){var i=String(a||"");if(i.indexOf("already been used")===-1&&i.indexOf("NotSupportedError")===-1)throw a}}}}catch{}})();var k,C,z=0,D=()=>{if(typeof window>"u"||typeof document>"u"||!("customElements"in window)||document.head.querySelector("style[data-scb-header-pre-upgrade]"))return;const p=document.createElement("style");p.setAttribute("data-scb-header-pre-upgrade",""),p.textContent=`
|
|
3
3
|
scb-header:not(:defined),
|
|
4
4
|
scb-header[data-upgrading] {
|
|
5
5
|
display: block;
|
|
@@ -50,20 +50,23 @@ import"../../vendor/vendor-material.js";import{_ as E,b as P,g as I,h as c,m as
|
|
|
50
50
|
);
|
|
51
51
|
}
|
|
52
52
|
}
|
|
53
|
-
`,document.head.appendChild(b);const e=l=>{const u=String(l??"").trim();if(u)return/^\d+$/.test(u)?`var(--spacing-${Math.max(0,Math.min(14,parseInt(u,10)))})`:u},t=l=>{const u=String(l??"").trim();if(!u)return!1;try{const p=JSON.parse(u);return Array.isArray(p)&&p.length>0}catch{return!1}},s=l=>l!=null&&!/^(false|0|off|no)$/i.test(l.trim()),r=l=>{for(const u of Array.from(l.children)){const p=u.tagName.toLowerCase();if(p==="scb-header-tab"||p==="scb-dropdown")return!0}return!1},i=l=>{r(l)||t(l.getAttribute("tabs"))||s(l.getAttribute("reserve-tabs"))||s(l.getAttribute("layout-pending"))?l.setAttribute("data-pre-has-tabs",""):l.removeAttribute("data-pre-has-tabs");const u=e(l.getAttribute("spacing")),p=e(l.getAttribute("spacing-top"))??u,y=e(l.getAttribute("spacing-bottom"))??u;p?l.style.setProperty("--scb-header-spacing-block-start",p):l.style.removeProperty("--scb-header-spacing-block-start"),y?l.style.setProperty("--scb-header-spacing-block-end",y):l.style.removeProperty("--scb-header-spacing-block-end");const _=(l.getAttribute("logo-width")??"").trim();_?l.style.setProperty("--scb-header-pre-logo-w",_):l.style.removeProperty("--scb-header-pre-logo-w");const h=(l.getAttribute("logo-height")??"").trim();h?l.style.setProperty("--scb-header-pre-logo-img-h",h):l.style.removeProperty("--scb-header-pre-logo-img-h");const w=(l.getAttribute("search-height")??"").trim();w?l.style.setProperty("--scb-header-pre-control-size",w):l.style.removeProperty("--scb-header-pre-control-size")};document.querySelectorAll("scb-header").forEach(i);const d=new MutationObserver(l=>{for(const u of l){if(u.type==="attributes"){const p=u.target;p instanceof HTMLElement&&p.tagName.toLowerCase()==="scb-header"&&i(p);continue}if(u.type==="childList"){const p=[...Array.from(u.addedNodes),...Array.from(u.removedNodes)];for(const y of p){if(!(y instanceof HTMLElement))continue;if(y.tagName.toLowerCase()==="scb-header"){i(y);continue}const _=y.closest?.("scb-header");_&&i(_)}}}});d.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["tabs","spacing","spacing-top","spacing-bottom","logo-width","logo-height","logo-aspect-ratio","logo-alt","logotype-text","search-height","reserve-tabs","layout-pending"]}),customElements.whenDefined("scb-header").then(()=>{d.disconnect()})};N();var T={fromAttribute:b=>b==null?!0:!/^(false|0|off|no)$/i.test(b),toAttribute:b=>String(!!b)},k={fromAttribute:b=>b==null?!1:!/^(false|0|off|no)$/i.test(b),toAttribute:b=>b?"":null},D={fromAttribute:b=>b==="small"||b==="large"?b:"medium",toAttribute:b=>{const e=String(b??"");return e==="small"||e==="large"?e:null}},o=(A=class extends E{constructor(){super(),this.maxWidth="1440px",this.spacing=void 0,this.spacingTop=void 0,this.spacingBottom=void 0,this.size="medium",this.logoText="",this.logotypeText="",this.logoAlt="",this.logoHref="/",this.logoSrc="",this.logoWidth="",this.logoHeight="",this.logoAspectRatio="",this.logoInvertDm=!1,this.banner=!1,this.tabs=[],this.activeTab=null,this.reserveTabs=!1,this.layoutPending=!1,this.utilityItems=[],this.searchButtonLabel="Sök",this.menuButtonLabel="Meny",this.deferDrawer=!1,this.showDrawer=!0,this.alwaysShowMenuButton=!1,this.showSearch=!0,this.includeUtilityInMenu=!1,this.drawerOverlay=!0,this.searchText="",this._drawerId="main-drawer",this._menuExpanded=!1,this._searchId="header-search",this._drawerReady=!1,this._mobileSearchOpen=!1,this._initialUpgradeComplete=!1,this._slotNavItems=[],this._slotUtils=[],this._slotMenu=[],this._measureScheduled=!1,this._scheduleMeasure=()=>{this.layoutPending||this._measureScheduled||(this._measureScheduled=!0,requestAnimationFrame(()=>{this._measureScheduled=!1,this._measure()}))},this._onWindowResize=()=>{window.innerWidth>=this.BP_SM&&this._mobileSearchOpen&&this._setMobileSearchOpen(!1),this._scheduleMeasure()},this._onMenuSelect=t=>{const s=t.detail;this.dispatchEvent(new CustomEvent("scb-menu-select",{detail:s,bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("scbmenuselect",{detail:s,bubbles:!0,composed:!0}));const r=s?.item,i=typeof s?.href=="string"?s.href:typeof s?.itemHref=="string"?s.itemHref:typeof s?.item_href=="string"?s.item_href:"",a=r?r.getAttribute("item-href")??r.getAttribute("href")??"":"";String(i||a||"").trim()&&this._closeDrawerNow()},this._collapsed=!1,this._unlockAtWidth=0,this._hideLogoText=!1,this._logoTextUnlockAt=0,this._slotWatchers=[],this._harvestPending=!1,this._harvest=(t={})=>{const s=Array.from(this.children),r=[],i=[],a=[];let d=-1;const l=h=>({label:h.getAttribute("label")??"",href:h.getAttribute("href")??void 0,icon:h.getAttribute("icon")??void 0}),u=h=>{h.hasAttribute("role")&&h.removeAttribute("role"),h.getAttribute("aria-hidden")!=="true"&&h.setAttribute("aria-hidden","true")};for(const h of s){const w=h.tagName.toLowerCase();if(w==="scb-header-tab"){const m=h.getAttribute("label")??"",x=h.getAttribute("href"),f=x&&x.trim()!==""?x:void 0;(h.hasAttribute("selected")||h.getAttribute("selected")==="true"||h.getAttribute("active")==="true"||h.getAttribute("aria-current")==="page")&&d===-1&&(d=r.length),r.push({kind:"tab",label:m,href:f});continue}if(w==="scb-badge"){const m=h.querySelector("scb-dropdown");if(m){const x=m.getAttribute("label")??"";(m.hasAttribute("selected")||m.getAttribute("selected")==="true"||m.getAttribute("active")==="true"||m.getAttribute("aria-current")==="page")&&d===-1&&(d=r.length);const f=`scb-header-tab-${r.length}`;h.getAttribute("slot")!==f&&h.setAttribute("slot",f),m.hasAttribute("slot")&&m.removeAttribute("slot"),m.hasAttribute("as-tab")||m.setAttribute("as-tab",""),r.push({kind:"dropdown",slotName:f,label:x});continue}}if(w==="scb-dropdown"){const m=h.getAttribute("label")??"";(h.hasAttribute("selected")||h.getAttribute("selected")==="true"||h.getAttribute("active")==="true"||h.getAttribute("aria-current")==="page")&&d===-1&&(d=r.length);const x=`scb-header-tab-${r.length}`;h.getAttribute("slot")!==x&&h.setAttribute("slot",x),h.hasAttribute("as-tab")||h.setAttribute("as-tab",""),r.push({kind:"dropdown",slotName:x,label:m});continue}if(w==="scb-header-utility"){u(h),i.push({label:h.getAttribute("label")??"",href:h.getAttribute("href")??"#",target:h.getAttribute("target")??void 0});continue}if(w==="scb-header-menu-group"){const m={label:h.getAttribute("label")??"",icon:h.getAttribute("icon")??void 0,children:[]};h.querySelectorAll("scb-header-menu-item").forEach(x=>m.children.push(l(x))),a.push(m);continue}w==="scb-header-menu-item"&&a.push(l(h))}const p=!this._sameNavItems(this._slotNavItems,r),y=!this._sameUtilityItems(this._slotUtils,i),_=!this._sameMenuNodes(this._slotMenu,a);p&&(this._slotNavItems=r),y&&(this._slotUtils=i),_&&(this._slotMenu=a),!this.hasAttribute("active-tab")&&d>=0&&this.activeTab!==d&&(this.activeTab=d),(t.scheduleMeasure??!0)&&queueMicrotask(()=>{this.updateComplete.then(()=>{this._scheduleMeasure()})})},this._measure=()=>{if(this.layoutPending)return;const t=this._top,s=this._logoGroup;if(!t||!s)return;const r=window.innerWidth,i=t.clientWidth,a=this._overflows(this._util),d=this._tabsOverflows(),l=r<this.BP_MD||a||d;this._collapsed?!l&&i>=this._unlockAtWidth&&this._setCollapsed(!1):l&&(this._unlockAtWidth=i+this._HYST,this._setCollapsed(!0));let u=!1;if(this.showSearch&&r>=this.BP_SM&&r<this.BP_MD&&this._searchWrap){const y=getComputedStyle(this._searchWrap),_=Math.max(this._num(y.minWidth,this._tokenPx("--scb-header-search-min",250)),this._tokenPx("--scb-header-search-min",250)),h=this._num(getComputedStyle(t).gap,this._tokenPx("--spacing-7",24)),w=this.showDrawer&&(this.alwaysShowMenuButton||r<this.BP_MD||this._collapsed)?this._menuBtn?.getBoundingClientRect().width||this._tokenPx("--icon-size-extra-extra-large",48):0;u=s.getBoundingClientRect().width+h+_+h+w+8>i+.5}this._setHideSearch(u);let p=!1;if(this.showDrawer&&(this.alwaysShowMenuButton||r<this.BP_MD||this._collapsed)&&!this._visible(this._util)&&!this._visible(this._searchWrap)){const y=this._num(getComputedStyle(t).gap,this._tokenPx("--spacing-7",24)),_=this._menuBtn?.getBoundingClientRect().width||this._tokenPx("--icon-size-extra-extra-large",48),h=(this._logoGroup?.getBoundingClientRect().width||0)+y+_;this._hideLogoText?p=!(i>=this._logoTextUnlockAt):h>i+.5&&(p=!0,this._logoTextUnlockAt=i+this._HYST)}else p=!1,this._logoTextUnlockAt=0;this._setHideLogoText(p)},this._onDrawerOpened=()=>{this._menuExpanded=!0,this._syncMenuBtnAria(),this.dispatchEvent(new CustomEvent("drawer-open",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("draweropen",{bubbles:!0,composed:!0}))},this._onDrawerClosed=()=>{this._menuExpanded=!1,this._syncMenuBtnAria(),this.dispatchEvent(new CustomEvent("drawer-close",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("drawerclose",{bubbles:!0,composed:!0}))},this._onMenuClick=async t=>{this.showDrawer&&(this._setMobileSearchOpen(!1),this.dispatchEvent(new CustomEvent("menu-click",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("menuclick",{bubbles:!0,composed:!0})),!this._drawerReady&&(t.stopPropagation(),await this._ensureDrawerReady(),await this.updateComplete,this._openDrawerNow()))},this._onSearchClick=t=>{const s=this._searchEl;if(s?.submit&&typeof s.submit=="function"){s.submit();return}const r=s?.value??"";this.searchText=r,this.dispatchEvent(new CustomEvent("search-click",{detail:{value:r},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("searchclick",{detail:{value:r},bubbles:!0,composed:!0})),s?.focus?.()},this._onMobileSearchToggle=()=>{const t=!this._mobileSearchOpen;this._setMobileSearchOpen(t),t&&this.updateComplete.then(()=>{this.renderRoot.querySelector(".mobile-search-panel scb-search")?.focus?.()})},this._onTabClick=t=>{const s=t.currentTarget;if(!s)return;const r=s.tagName.toLowerCase()==="a";if(r&&(t.defaultPrevented||t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey))return;const i=s.getAttribute("data-index"),a=i!=null?Number(i):0,d=this._getNavItems()[a];if(d?.kind==="dropdown")return;this.activeTab=a;const l=d?.kind==="tab"?d.href??"":"",u=new CustomEvent("tab-change",{detail:{index:a,href:l},bubbles:!0,composed:!0,cancelable:!0}),p=new CustomEvent("tabchange",{detail:{index:a,href:l},bubbles:!0,composed:!0,cancelable:!0});!(this.dispatchEvent(u)&&this.dispatchEvent(p))&&r&&t.preventDefault()},this._onDropdownTabActivate=t=>{const s=t.detail?.dataIndex,r=typeof s=="number"?s:typeof s=="string"?Number(s):this._readTabIndexFromEvent(t);if(r==null||!Number.isFinite(r))return;const i=this._getNavItems();r<0||r>=i.length||i[r]?.kind==="dropdown"&&(this.activeTab=r,this.dispatchEvent(new CustomEvent("tab-change",{detail:{index:r,href:""},bubbles:!0,composed:!0,cancelable:!0})),this.dispatchEvent(new CustomEvent("tabchange",{detail:{index:r,href:""},bubbles:!0,composed:!0,cancelable:!0})))},this._onTabsKeydown=t=>{const s=t.key;if(s!=="ArrowLeft"&&s!=="ArrowRight"&&s!=="Home"&&s!=="End")return;const r=this._getNavItems();if(!r.length)return;const i=this._readTabIndexFromEvent(t);if(i==null)return;let a=Math.max(0,Math.min(r.length-1,i));s==="ArrowRight"?a=(a+1)%r.length:s==="ArrowLeft"?a=(a-1+r.length)%r.length:s==="Home"?a=0:s==="End"&&(a=r.length-1),t.preventDefault(),this._focusTabAtIndex(a)},this._onSearchInput=t=>{this.searchText=t.detail?.value??"",this.dispatchEvent(new CustomEvent("search-input",{detail:{value:this.searchText},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("searchinput",{detail:{value:this.searchText},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("search-text-change",{detail:{value:this.searchText},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("searchtextchange",{detail:{value:this.searchText},bubbles:!0,composed:!0}))},this._onSearchSubmit=t=>{this.searchText=t.detail?.value??"",this.dispatchEvent(new CustomEvent("search-change",{detail:{value:this.searchText,active:t.detail?.active},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("searchchange",{detail:{value:this.searchText,active:t.detail?.active},bubbles:!0,composed:!0}))},this._onSearchClear=()=>{this.searchText="",this.dispatchEvent(new CustomEvent("search-text-change",{detail:{value:""},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("searchtextchange",{detail:{value:""},bubbles:!0,composed:!0}))};const e=++z;this._drawerId=`scb-header-drawer-${e}`,this._searchId=`scb-header-search-${e}`}requestLayout(){this.layoutPending||(this.setAttribute("data-layout-settling",""),this.updateComplete.then(()=>{this.isConnected&&(this._measure(),this.removeAttribute("data-layout-settling"))}))}get _HYST(){return this._tokenPx("--spacing-11",64)}get BP_SM(){return this._tokenPx("--bp-sm",$.BP_SM_DEFAULT)}get BP_MD(){return this._tokenPx("--bp-md",$.BP_MD_DEFAULT)}_scheduleHarvest(){this._harvestPending||(this._harvestPending=!0,queueMicrotask(()=>{this._harvestPending=!1,this._harvest()}))}get _top(){return this.renderRoot.querySelector(".top-row")}get _util(){return this.renderRoot.querySelector(".utility")}get _logoGroup(){return this.renderRoot.querySelector(".logo-wrap")||this.renderRoot.querySelector(".logo-group")}get _searchWrap(){return this.renderRoot.querySelector(".search")}get _menuBtn(){return this.renderRoot.querySelector(".menu-trigger")}get _searchEl(){return this.renderRoot.querySelector(`#${this._searchId}`)}get _tabsNav(){return this.renderRoot.querySelector(".tabs-nav")}_attachSlotObservers(){this._slotMo?.disconnect(),this._slotWatchers.forEach(i=>i.disconnect()),this._slotWatchers=[];const e=["label","href","icon","target","selected","aria-current","active","role"],t=i=>{const a=new MutationObserver(d=>{this._scheduleHarvest()});this._slotWatchers.push(a),a.observe(i,{attributes:!0,attributeFilter:e})},s=()=>{this._slotWatchers.forEach(a=>a.disconnect()),this._slotWatchers=[];const i=Array.from(this.children);for(const a of i){const d=a.tagName.toLowerCase();if((d==="scb-header-tab"||d==="scb-dropdown"||d==="scb-header-utility"||d==="scb-header-menu-item"||d==="scb-header-menu-group"||d==="scb-badge")&&t(a),d==="scb-badge"){const l=a,u=new MutationObserver(y=>{s(),this._scheduleHarvest()});this._slotWatchers.push(u),u.observe(l,{childList:!0});const p=l.querySelector("scb-dropdown");p&&t(p);continue}if(d==="scb-header-menu-group"){const l=a,u=new MutationObserver(p=>{s(),this._scheduleHarvest()});this._slotWatchers.push(u),u.observe(l,{childList:!0,subtree:!0}),l.querySelectorAll("scb-header-menu-item").forEach(p=>t(p))}}},r=new MutationObserver(i=>{let a=!1;for(const d of i)if(d.type==="childList"){a=!0;break}a&&s(),this._scheduleHarvest()});this._slotMo=r,r.observe(this,{childList:!0}),s()}_sameNavItems(e,t){if(e.length!==t.length)return!1;for(let s=0;s<e.length;s+=1){const r=e[s],i=t[s];if(!r||!i||r.kind!==i.kind||r.label!==i.label)return!1;if(r.kind==="tab"&&i.kind==="tab"){if((r.href??"")!==(i.href??""))return!1}else if(r.kind==="dropdown"&&i.kind==="dropdown"&&r.slotName!==i.slotName)return!1}return!0}_sameUtilityItems(e,t){if(e.length!==t.length)return!1;for(let s=0;s<e.length;s+=1){const r=e[s],i=t[s];if(!r||!i||r.label!==i.label||r.href!==i.href||(r.target??"")!==(i.target??""))return!1}return!0}_sameMenuNodes(e,t){if(e.length!==t.length)return!1;for(let s=0;s<e.length;s+=1){const r=e[s],i=t[s];if(!r||!i||r.label!==i.label||(r.href??"")!==(i.href??"")||(r.icon??"")!==(i.icon??"")||!this._sameMenuNodes(r.children??[],i.children??[]))return!1}return!0}_setCollapsed(e){this._collapsed!==e&&(this._collapsed=e,e?this.setAttribute("data-collapsed",""):this.removeAttribute("data-collapsed"))}_setHideSearch(e){e?this.setAttribute("data-hide-search",""):this.removeAttribute("data-hide-search")}_setHideLogoText(e){this._hideLogoText!==e&&(this._hideLogoText=e,e?this.setAttribute("data-hide-logo-text",""):this.removeAttribute("data-hide-logo-text"))}_setMobileSearchOpen(e){this._mobileSearchOpen!==e&&(this._mobileSearchOpen=e,this.toggleAttribute("data-mobile-search-open",e))}_num(e,t){const s=Number.parseFloat(String(e??"").trim());return Number.isFinite(s)?s:t}_tokenPx(e,t){const s=getComputedStyle(this);return this._num(s.getPropertyValue(e),t)}_visible(e){return e?getComputedStyle(e).display!=="none":!1}_overflows(e){return!e||!this._visible(e)?!1:e.scrollWidth>e.clientWidth+1}_tabsOverflows(){const e=this._tabsNav;if(!e||!this._visible(e))return!1;const t=Array.from(e.querySelectorAll(".tab-wrap"));if(t.length===0)return!1;const s=e.getBoundingClientRect();let r=s.left;for(const i of t){const a=i.getBoundingClientRect();a.width<=0||a.right>r&&(r=a.right)}return r-s.left>s.width+1}connectedCallback(){super.connectedCallback(),this._initialUpgradeComplete||this.setAttribute("data-upgrading",""),this._harvest({scheduleMeasure:!1}),this._attachSlotObservers()}_finishInitialUpgrade(){this._initialUpgradeComplete||(this._initialUpgradeComplete=!0,requestAnimationFrame(()=>{this.isConnected&&(this._measure(),this.removeAttribute("data-upgrading"))}))}firstUpdated(){this.showDrawer&&!this.deferDrawer&&this._ensureDrawerReady(),this.updateComplete.then(()=>{this._harvest({scheduleMeasure:!1}),this._attachSlotObservers(),this._syncDropdownTabs(),this._finishInitialUpgrade()});const e=this._top;e&&(this._ro=new ResizeObserver(()=>this._scheduleMeasure()),this._ro.observe(e)),window.addEventListener("resize",this._onWindowResize,{passive:!0})}updated(e){e.has("searchMax")&&this.style.setProperty("--scb-header-search-max",this.searchMax??"380px"),e.has("searchMin")&&this.style.setProperty("--scb-header-search-min",this.searchMin??"250px"),e.has("searchHeight")&&(this.searchHeight&&this.searchHeight.trim()?this.style.setProperty("--scb-search-height",this.searchHeight.trim()):this.style.removeProperty("--scb-search-height")),(e.has("logoWidth")||e.has("logoHeight")||e.has("logoAspectRatio"))&&this._applyLogoSizing(),(e.has("spacing")||e.has("spacingTop")||e.has("spacingBottom"))&&this._applySpacing(),(e.has("utilityItems")||e.has("tabs")||e.has("logoText")||e.has("logotypeText")||e.has("logoSrc")||e.has("logoWidth")||e.has("logoHeight")||e.has("logoAspectRatio")||e.has("activeTab")||e.has("_slotNavItems")||e.has("_slotUtils")||e.has("_slotMenu")||e.has("showDrawer")||e.has("alwaysShowMenuButton")||e.has("showSearch")||e.has("layoutPending")||e.has("searchMax")||e.has("searchMin")||e.has("size"))&&this.updateComplete.then(()=>{this._scheduleMeasure()}),(e.has("showDrawer")||e.has("deferDrawer"))&&this.showDrawer&&!this.deferDrawer&&this._ensureDrawerReady(),e.has("showSearch")&&!this.showSearch&&this._setMobileSearchOpen(!1),e.has("layoutPending")&&!this.layoutPending&&this.requestLayout(),(e.has("activeTab")||e.has("_slotNavItems")||e.has("tabs")||e.has("size"))&&this.updateComplete.then(()=>{this._syncDropdownTabs()})}disconnectedCallback(){this._ro?.disconnect(),this._slotMo?.disconnect(),this._slotWatchers.forEach(e=>e.disconnect()),this._slotWatchers=[],window.removeEventListener("resize",this._onWindowResize),super.disconnectedCallback()}_mapSpacingToken(e){if(!e)return;const t=String(e).trim();if(t)return/^\d+$/.test(t)?`var(--spacing-${Math.max(0,Math.min(14,parseInt(t,10)))})`:t}_applySpacing(){const e=this._mapSpacingToken(this.spacing),t=this._mapSpacingToken(this.spacingTop)??e,s=this._mapSpacingToken(this.spacingBottom)??e;t?this.style.setProperty("--scb-header-spacing-block-start",t):this.style.removeProperty("--scb-header-spacing-block-start"),s?this.style.setProperty("--scb-header-spacing-block-end",s):this.style.removeProperty("--scb-header-spacing-block-end")}_applyLogoSizing(){const e=(this.logoWidth??"").trim(),t=(this.logoHeight??"").trim(),s=(this.logoAspectRatio??"").trim();e?this.style.setProperty("--scb-header-logo-img-w",e):this.style.removeProperty("--scb-header-logo-img-w"),t?this.style.setProperty("--scb-header-logo-img-h",t):e?this.style.setProperty("--scb-header-logo-img-h","auto"):this.style.removeProperty("--scb-header-logo-img-h"),s?this.style.setProperty("--scb-header-logo-img-aspect-ratio",s):this.style.removeProperty("--scb-header-logo-img-aspect-ratio")}_closeDrawerNow(){const e=this.renderRoot.querySelector(`#${this._drawerId}`);e&&(e.open=!1)}_openDrawerNow(){const e=this.renderRoot.querySelector(`#${this._drawerId}`);e&&(e.open=!0)}async _ensureDrawerReady(){this._drawerReady||(this._drawerImportPromise??(this._drawerImportPromise=Promise.all([M(()=>import("../scb-drawer/scb-drawer.js"),__vite__mapDeps([0,1,2,3,4,5]),import.meta.url),M(()=>import("../scb-menu/scb-menu.js"),__vite__mapDeps([6,5,1,2,3,4,7,8,9,10,11]),import.meta.url)]).then(()=>{})),await this._drawerImportPromise,this._drawerReady=!0)}_syncMenuBtnAria(){this.renderRoot.querySelectorAll(".menu-trigger").forEach(e=>{e.setAttribute("aria-expanded",String(this._menuExpanded))})}_getNavItems(){return this._slotNavItems.length?this._slotNavItems:(this.tabs??[]).map(e=>({kind:"tab",...e}))}_getDropdownForSlot(e){const t=this.querySelector(`[slot="${e}"]`);return t?t.tagName.toLowerCase()==="scb-dropdown"?t:t.querySelector("scb-dropdown"):null}_syncDropdownTabs(){this._getNavItems().forEach((e,t)=>{if(e.kind!=="dropdown")return;const s=this._getDropdownForSlot(e.slotName);if(!s)return;const r=String(t);s.getAttribute("data-index")!==r&&s.setAttribute("data-index",r),s.hasAttribute("as-tab")||s.setAttribute("as-tab","");const i=this.size,a=s;a?.size!==i&&(a.size=i),t===this.activeTab?s.getAttribute("aria-current")!=="page"&&s.setAttribute("aria-current","page"):s.hasAttribute("aria-current")&&s.removeAttribute("aria-current")})}_readTabIndexFromEvent(e){const t=e.composedPath?e.composedPath():[];for(const s of t){if(!(s instanceof HTMLElement))continue;const r=s.getAttribute("data-index");if(r==null)continue;const i=Number(r);if(Number.isFinite(i))return i}return null}_focusTabAtIndex(e){const t=this._getNavItems()[e];if(t){if(t.kind==="dropdown"){this._getDropdownForSlot(t.slotName)?.focus?.();return}this.renderRoot.querySelector(`.tab-link[data-index="${e}"]`)?.focus?.()}}_renderMenuNodes(e){return!e||e.length===0?g``:g`${e.map(t=>this._renderMenuNode(t))}`}_renderMenuNode(e){const t=Array.isArray(e.children)&&e.children.length>0,s=(e.href??"").trim(),r=(e.icon??"").trim();return g`
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
item-href=${s
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
53
|
+
`,document.head.appendChild(p);const e=n=>{const u=String(n??"").trim();if(u)return/^\d+$/.test(u)?`var(--spacing-${Math.max(0,Math.min(14,parseInt(u,10)))})`:u},t=n=>{const u=String(n??"").trim();if(!u)return!1;try{const b=JSON.parse(u);return Array.isArray(b)&&b.length>0}catch{return!1}},s=n=>n!=null&&!/^(false|0|off|no)$/i.test(n.trim()),r=n=>{for(const u of Array.from(n.children)){const b=u.tagName.toLowerCase();if(b==="scb-header-tab"||b==="scb-dropdown")return!0}return!1},i=n=>{r(n)||t(n.getAttribute("tabs"))||s(n.getAttribute("reserve-tabs"))||s(n.getAttribute("layout-pending"))?n.setAttribute("data-pre-has-tabs",""):n.removeAttribute("data-pre-has-tabs");const u=e(n.getAttribute("spacing")),b=e(n.getAttribute("spacing-top"))??u,v=e(n.getAttribute("spacing-bottom"))??u;b?n.style.setProperty("--scb-header-spacing-block-start",b):n.style.removeProperty("--scb-header-spacing-block-start"),v?n.style.setProperty("--scb-header-spacing-block-end",v):n.style.removeProperty("--scb-header-spacing-block-end");const y=(n.getAttribute("logo-width")??"").trim();y?n.style.setProperty("--scb-header-pre-logo-w",y):n.style.removeProperty("--scb-header-pre-logo-w");const w=(n.getAttribute("logo-height")??"").trim();w?n.style.setProperty("--scb-header-pre-logo-img-h",w):n.style.removeProperty("--scb-header-pre-logo-img-h");const h=(n.getAttribute("search-height")??"").trim();h?n.style.setProperty("--scb-header-pre-control-size",h):n.style.removeProperty("--scb-header-pre-control-size")};document.querySelectorAll("scb-header").forEach(i);const d=new MutationObserver(n=>{for(const u of n){if(u.type==="attributes"){const b=u.target;b instanceof HTMLElement&&b.tagName.toLowerCase()==="scb-header"&&i(b);continue}if(u.type==="childList"){const b=[...Array.from(u.addedNodes),...Array.from(u.removedNodes)];for(const v of b){if(!(v instanceof HTMLElement))continue;if(v.tagName.toLowerCase()==="scb-header"){i(v);continue}const y=v.closest?.("scb-header");y&&i(y)}}}});d.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["tabs","spacing","spacing-top","spacing-bottom","logo-width","logo-height","logo-aspect-ratio","logo-alt","logotype-text","search-height","reserve-tabs","layout-pending"]}),customElements.whenDefined("scb-header").then(()=>{d.disconnect()})};D();var M={fromAttribute:p=>p==null?!0:!/^(false|0|off|no)$/i.test(p),toAttribute:p=>String(!!p)},$={fromAttribute:p=>p==null?!1:!/^(false|0|off|no)$/i.test(p),toAttribute:p=>p?"":null},N={fromAttribute:p=>p==="small"||p==="large"?p:"medium",toAttribute:p=>{const e=String(p??"");return e==="small"||e==="large"?e:null}},o=(k=class extends E{constructor(){super(),this.maxWidth="1440px",this.size="medium",this.logoText="",this.logotypeText="",this.logoAlt="",this.logoHref="/",this.logoSrc="",this.logoWidth="",this.logoHeight="",this.logoAspectRatio="",this.logoInvertDm=!1,this.banner=!1,this.tabs=[],this.activeTab=null,this.reserveTabs=!1,this.layoutPending=!1,this.utilityItems=[],this.searchButtonLabel="Sök",this.menuButtonLabel="Meny",this.deferDrawer=!1,this.showDrawer=!0,this.alwaysShowMenuButton=!1,this.showSearch=!0,this.includeUtilityInMenu=!1,this.drawerOverlay=!0,this.searchText="",this._drawerId="main-drawer",this._menuExpanded=!1,this._searchId="header-search",this._drawerReady=!1,this._mobileSearchOpen=!1,this._initialUpgradeComplete=!1,this._slotNavItems=[],this._slotUtils=[],this._slotMenu=[],this._measureScheduled=!1,this._scheduleMeasure=()=>{this.layoutPending||this._measureScheduled||(this._measureScheduled=!0,requestAnimationFrame(()=>{this._measureScheduled=!1,this._measure()}))},this._onWindowResize=()=>{window.innerWidth>=this.BP_SM&&this._mobileSearchOpen&&this._setMobileSearchOpen(!1),this._scheduleMeasure()},this._onMenuSelect=t=>{const s=t.detail;this.dispatchEvent(new CustomEvent("scb-menu-select",{detail:s,bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("scbmenuselect",{detail:s,bubbles:!0,composed:!0}));const r=s?.item,i=typeof s?.href=="string"?s.href:typeof s?.itemHref=="string"?s.itemHref:typeof s?.item_href=="string"?s.item_href:"",a=r?r.getAttribute("item-href")??r.getAttribute("href")??"":"";String(i||a||"").trim()&&this._closeDrawerNow()},this._collapsed=!1,this._unlockAtWidth=0,this._hideLogoText=!1,this._logoTextUnlockAt=0,this._slotWatchers=[],this._harvestPending=!1,this._harvest=(t={})=>{const s=Array.from(this.children),r=[],i=[],a=[];let d=-1,n=!1;const u=h=>({label:h.getAttribute("label")??"",href:h.getAttribute("href")??void 0,icon:h.getAttribute("icon")??void 0}),b=h=>{h.hasAttribute("role")&&h.removeAttribute("role"),h.getAttribute("aria-hidden")!=="true"&&h.setAttribute("aria-hidden","true")};for(const h of s){const A=h.tagName.toLowerCase();if(A==="scb-header-tab"){const f=h.getAttribute("label")??"",g=h.getAttribute("href"),x=g&&g.trim()!==""?g:void 0;(h.hasAttribute("selected")||h.getAttribute("selected")==="true"||h.getAttribute("active")==="true"||h.getAttribute("aria-current")==="page")&&d===-1&&(d=r.length),r.push({kind:"tab",label:f,href:x});continue}if(A==="scb-badge"){const f=h.querySelector("scb-dropdown");if(f){n=!0;const g=f.getAttribute("label")??"";(f.hasAttribute("selected")||f.getAttribute("selected")==="true"||f.getAttribute("active")==="true"||f.getAttribute("aria-current")==="page")&&d===-1&&(d=r.length);const x=`scb-header-tab-${r.length}`;h.getAttribute("slot")!==x&&h.setAttribute("slot",x),f.hasAttribute("slot")&&f.removeAttribute("slot"),f.hasAttribute("as-tab")||f.setAttribute("as-tab",""),r.push({kind:"dropdown",slotName:x,label:g});continue}}if(A==="scb-dropdown"){n=!0;const f=h.getAttribute("label")??"";(h.hasAttribute("selected")||h.getAttribute("selected")==="true"||h.getAttribute("active")==="true"||h.getAttribute("aria-current")==="page")&&d===-1&&(d=r.length);const g=`scb-header-tab-${r.length}`;h.getAttribute("slot")!==g&&h.setAttribute("slot",g),h.hasAttribute("as-tab")||h.setAttribute("as-tab",""),r.push({kind:"dropdown",slotName:g,label:f});continue}if(A==="scb-header-utility"){b(h),i.push({label:h.getAttribute("label")??"",href:h.getAttribute("href")??"#",target:h.getAttribute("target")??void 0});continue}if(A==="scb-header-menu-group"){const f={label:h.getAttribute("label")??"",icon:h.getAttribute("icon")??void 0,children:[]};h.querySelectorAll("scb-header-menu-item").forEach(g=>f.children.push(u(g))),a.push(f);continue}A==="scb-header-menu-item"&&a.push(u(h))}const v=!this._sameNavItems(this._slotNavItems,r),y=!this._sameUtilityItems(this._slotUtils,i),w=!this._sameMenuNodes(this._slotMenu,a);v&&(this._slotNavItems=r),y&&(this._slotUtils=i),w&&(this._slotMenu=a),n&&this._ensureDropdownReady(),!this.hasAttribute("active-tab")&&d>=0&&this.activeTab!==d&&(this.activeTab=d),(t.scheduleMeasure??!0)&&queueMicrotask(()=>{this.updateComplete.then(()=>{this._scheduleMeasure()})})},this._measure=()=>{if(this.layoutPending)return;const t=this._top,s=this._logoGroup;if(!t||!s)return;const r=window.innerWidth,i=t.clientWidth,a=this._overflows(this._util),d=this._tabsOverflows(),n=r<this.BP_MD||a||d;this._collapsed?!n&&i>=this._unlockAtWidth&&this._setCollapsed(!1):n&&(this._unlockAtWidth=i+this._HYST,this._setCollapsed(!0));let u=!1;if(this.showSearch&&r>=this.BP_SM&&r<this.BP_MD&&this._searchWrap){const v=getComputedStyle(this._searchWrap),y=Math.max(this._num(v.minWidth,this._tokenPx("--scb-header-search-min",250)),this._tokenPx("--scb-header-search-min",250)),w=this._num(getComputedStyle(t).gap,this._tokenPx("--spacing-7",24)),h=this.showDrawer&&(this.alwaysShowMenuButton||r<this.BP_MD||this._collapsed)?this._menuBtn?.getBoundingClientRect().width||this._tokenPx("--icon-size-extra-extra-large",48):0;u=s.getBoundingClientRect().width+w+y+w+h+8>i+.5}this._setHideSearch(u);let b=!1;if(this.showDrawer&&(this.alwaysShowMenuButton||r<this.BP_MD||this._collapsed)&&!this._visible(this._util)&&!this._visible(this._searchWrap)){const v=this._num(getComputedStyle(t).gap,this._tokenPx("--spacing-7",24)),y=this._menuBtn?.getBoundingClientRect().width||this._tokenPx("--icon-size-extra-extra-large",48),w=(this._logoGroup?.getBoundingClientRect().width||0)+v+y;this._hideLogoText?b=!(i>=this._logoTextUnlockAt):w>i+.5&&(b=!0,this._logoTextUnlockAt=i+this._HYST)}else b=!1,this._logoTextUnlockAt=0;this._setHideLogoText(b)},this._onDrawerOpened=()=>{this._menuExpanded=!0,this._syncMenuBtnAria(),this.dispatchEvent(new CustomEvent("drawer-open",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("draweropen",{bubbles:!0,composed:!0}))},this._onDrawerClosed=()=>{this._menuExpanded=!1,this._syncMenuBtnAria(),this.dispatchEvent(new CustomEvent("drawer-close",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("drawerclose",{bubbles:!0,composed:!0}))},this._onMenuClick=async t=>{this.showDrawer&&(this._setMobileSearchOpen(!1),this.dispatchEvent(new CustomEvent("menu-click",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("menuclick",{bubbles:!0,composed:!0})),!this._drawerReady&&(t.stopPropagation(),await this._ensureDrawerReady(),await this.updateComplete,this._openDrawerNow()))},this._onSearchClick=t=>{const s=this._searchEl;if(s?.submit&&typeof s.submit=="function"){s.submit();return}const r=s?.value??"";this.searchText=r,this.dispatchEvent(new CustomEvent("search-click",{detail:{value:r},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("searchclick",{detail:{value:r},bubbles:!0,composed:!0})),s?.focus?.()},this._onMobileSearchToggle=()=>{const t=!this._mobileSearchOpen;this._setMobileSearchOpen(t),t&&this.updateComplete.then(()=>{this.renderRoot.querySelector(".mobile-search-panel scb-search")?.focus?.()})},this._onTabClick=t=>{const s=t.currentTarget;if(!s)return;const r=s.tagName.toLowerCase()==="a";if(r&&(t.defaultPrevented||t.button!==0||t.metaKey||t.ctrlKey||t.shiftKey||t.altKey))return;const i=s.getAttribute("data-index"),a=i!=null?Number(i):0,d=this._getNavItems()[a];if(d?.kind==="dropdown")return;this.activeTab=a;const n=d?.kind==="tab"?d.href??"":"",u=new CustomEvent("tab-change",{detail:{index:a,href:n},bubbles:!0,composed:!0,cancelable:!0}),b=new CustomEvent("tabchange",{detail:{index:a,href:n},bubbles:!0,composed:!0,cancelable:!0});!(this.dispatchEvent(u)&&this.dispatchEvent(b))&&r&&t.preventDefault()},this._onDropdownTabActivate=t=>{const s=t.detail?.dataIndex,r=typeof s=="number"?s:typeof s=="string"?Number(s):this._readTabIndexFromEvent(t);if(r==null||!Number.isFinite(r))return;const i=this._getNavItems();r<0||r>=i.length||i[r]?.kind==="dropdown"&&(this.activeTab=r,this.dispatchEvent(new CustomEvent("tab-change",{detail:{index:r,href:""},bubbles:!0,composed:!0,cancelable:!0})),this.dispatchEvent(new CustomEvent("tabchange",{detail:{index:r,href:""},bubbles:!0,composed:!0,cancelable:!0})))},this._onTabsKeydown=t=>{const s=t.key;if(s!=="ArrowLeft"&&s!=="ArrowRight"&&s!=="Home"&&s!=="End")return;const r=this._getNavItems();if(!r.length)return;const i=this._readTabIndexFromEvent(t);if(i==null)return;let a=Math.max(0,Math.min(r.length-1,i));s==="ArrowRight"?a=(a+1)%r.length:s==="ArrowLeft"?a=(a-1+r.length)%r.length:s==="Home"?a=0:s==="End"&&(a=r.length-1),t.preventDefault(),this._focusTabAtIndex(a)},this._onSearchInput=t=>{this.searchText=t.detail?.value??"",this.dispatchEvent(new CustomEvent("search-input",{detail:{value:this.searchText},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("searchinput",{detail:{value:this.searchText},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("search-text-change",{detail:{value:this.searchText},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("searchtextchange",{detail:{value:this.searchText},bubbles:!0,composed:!0}))},this._onSearchSubmit=t=>{this.searchText=t.detail?.value??"",this.dispatchEvent(new CustomEvent("search-change",{detail:{value:this.searchText,active:t.detail?.active},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("searchchange",{detail:{value:this.searchText,active:t.detail?.active},bubbles:!0,composed:!0}))},this._onSearchClear=()=>{this.searchText="",this.dispatchEvent(new CustomEvent("search-text-change",{detail:{value:""},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("searchtextchange",{detail:{value:""},bubbles:!0,composed:!0}))};const e=++z;this._drawerId=`scb-header-drawer-${e}`,this._searchId=`scb-header-search-${e}`}requestLayout(){this.layoutPending||(this.setAttribute("data-layout-settling",""),this.updateComplete.then(()=>{this.isConnected&&(this._measure(),this.removeAttribute("data-layout-settling"))}))}get _HYST(){return this._tokenPx("--spacing-11",64)}get BP_SM(){return this._tokenPx("--bp-sm",C.BP_SM_DEFAULT)}get BP_MD(){return this._tokenPx("--bp-md",C.BP_MD_DEFAULT)}_scheduleHarvest(){this._harvestPending||(this._harvestPending=!0,queueMicrotask(()=>{this._harvestPending=!1,this._harvest()}))}get _top(){return this.renderRoot.querySelector(".top-row")}get _util(){return this.renderRoot.querySelector(".utility")}get _logoGroup(){return this.renderRoot.querySelector(".logo-wrap")||this.renderRoot.querySelector(".logo-group")}get _searchWrap(){return this.renderRoot.querySelector(".search")}get _menuBtn(){return this.renderRoot.querySelector(".menu-trigger")}get _searchEl(){return this.renderRoot.querySelector(`#${this._searchId}`)}get _tabsNav(){return this.renderRoot.querySelector(".tabs-nav")}_attachSlotObservers(){this._slotMo?.disconnect(),this._slotWatchers.forEach(i=>i.disconnect()),this._slotWatchers=[];const e=["label","href","icon","target","selected","aria-current","active","role"],t=i=>{const a=new MutationObserver(d=>{this._scheduleHarvest()});this._slotWatchers.push(a),a.observe(i,{attributes:!0,attributeFilter:e})},s=()=>{this._slotWatchers.forEach(a=>a.disconnect()),this._slotWatchers=[];const i=Array.from(this.children);for(const a of i){const d=a.tagName.toLowerCase();if((d==="scb-header-tab"||d==="scb-dropdown"||d==="scb-header-utility"||d==="scb-header-menu-item"||d==="scb-header-menu-group"||d==="scb-badge")&&t(a),d==="scb-badge"){const n=a,u=new MutationObserver(v=>{s(),this._scheduleHarvest()});this._slotWatchers.push(u),u.observe(n,{childList:!0});const b=n.querySelector("scb-dropdown");b&&t(b);continue}if(d==="scb-header-menu-group"){const n=a,u=new MutationObserver(b=>{s(),this._scheduleHarvest()});this._slotWatchers.push(u),u.observe(n,{childList:!0,subtree:!0}),n.querySelectorAll("scb-header-menu-item").forEach(b=>t(b))}}},r=new MutationObserver(i=>{let a=!1;for(const d of i)if(d.type==="childList"){a=!0;break}a&&s(),this._scheduleHarvest()});this._slotMo=r,r.observe(this,{childList:!0}),s()}_sameNavItems(e,t){if(e.length!==t.length)return!1;for(let s=0;s<e.length;s+=1){const r=e[s],i=t[s];if(!r||!i||r.kind!==i.kind||r.label!==i.label)return!1;if(r.kind==="tab"&&i.kind==="tab"){if((r.href??"")!==(i.href??""))return!1}else if(r.kind==="dropdown"&&i.kind==="dropdown"&&r.slotName!==i.slotName)return!1}return!0}_sameUtilityItems(e,t){if(e.length!==t.length)return!1;for(let s=0;s<e.length;s+=1){const r=e[s],i=t[s];if(!r||!i||r.label!==i.label||r.href!==i.href||(r.target??"")!==(i.target??""))return!1}return!0}_sameMenuNodes(e,t){if(e.length!==t.length)return!1;for(let s=0;s<e.length;s+=1){const r=e[s],i=t[s];if(!r||!i||r.label!==i.label||(r.href??"")!==(i.href??"")||(r.icon??"")!==(i.icon??"")||!this._sameMenuNodes(r.children??[],i.children??[]))return!1}return!0}_setCollapsed(e){this._collapsed!==e&&(this._collapsed=e,e?this.setAttribute("data-collapsed",""):this.removeAttribute("data-collapsed"))}_setHideSearch(e){e?this.setAttribute("data-hide-search",""):this.removeAttribute("data-hide-search")}_setHideLogoText(e){this._hideLogoText!==e&&(this._hideLogoText=e,e?this.setAttribute("data-hide-logo-text",""):this.removeAttribute("data-hide-logo-text"))}_setMobileSearchOpen(e){this._mobileSearchOpen!==e&&(this._mobileSearchOpen=e,this.toggleAttribute("data-mobile-search-open",e))}_num(e,t){const s=Number.parseFloat(String(e??"").trim());return Number.isFinite(s)?s:t}_tokenPx(e,t){const s=getComputedStyle(this);return this._num(s.getPropertyValue(e),t)}_visible(e){return e?getComputedStyle(e).display!=="none":!1}_overflows(e){return!e||!this._visible(e)?!1:e.scrollWidth>e.clientWidth+1}_tabsOverflows(){const e=this._tabsNav;if(!e||!this._visible(e))return!1;const t=Array.from(e.querySelectorAll(".tab-wrap"));if(t.length===0)return!1;const s=e.getBoundingClientRect();let r=s.left;for(const i of t){const a=i.getBoundingClientRect();a.width<=0||a.right>r&&(r=a.right)}return r-s.left>s.width+1}connectedCallback(){super.connectedCallback(),this._initialUpgradeComplete||this.setAttribute("data-upgrading",""),this._harvest({scheduleMeasure:!1}),this._attachSlotObservers()}_finishInitialUpgrade(){this._initialUpgradeComplete||(this._initialUpgradeComplete=!0,requestAnimationFrame(()=>{this.isConnected&&(this._measure(),this.removeAttribute("data-upgrading"))}))}firstUpdated(){this._syncLandmarkAttributes(),this.showDrawer&&!this.deferDrawer&&this._ensureDrawerReady(),this.updateComplete.then(()=>{this._harvest({scheduleMeasure:!1}),this._attachSlotObservers(),this._syncDropdownTabs(),this._finishInitialUpgrade()});const e=this._top;e&&(this._ro=new ResizeObserver(()=>this._scheduleMeasure()),this._ro.observe(e)),window.addEventListener("resize",this._onWindowResize,{passive:!0})}updated(e){e.has("searchMax")&&this.style.setProperty("--scb-header-search-max",this.searchMax??"380px"),e.has("searchMin")&&this.style.setProperty("--scb-header-search-min",this.searchMin??"250px"),e.has("searchHeight")&&(this.searchHeight&&this.searchHeight.trim()?this.style.setProperty("--scb-search-height",this.searchHeight.trim()):this.style.removeProperty("--scb-search-height")),(e.has("logoWidth")||e.has("logoHeight")||e.has("logoAspectRatio"))&&this._applyLogoSizing(),(e.has("spacing")||e.has("spacingTop")||e.has("spacingBottom"))&&this._applySpacing(),(e.has("banner")||e.has("bannerLabel"))&&this._syncLandmarkAttributes(),(e.has("utilityItems")||e.has("tabs")||e.has("logoText")||e.has("logotypeText")||e.has("logoSrc")||e.has("logoWidth")||e.has("logoHeight")||e.has("logoAspectRatio")||e.has("activeTab")||e.has("_slotNavItems")||e.has("_slotUtils")||e.has("_slotMenu")||e.has("showDrawer")||e.has("alwaysShowMenuButton")||e.has("showSearch")||e.has("layoutPending")||e.has("searchMax")||e.has("searchMin")||e.has("size"))&&this.updateComplete.then(()=>{this._scheduleMeasure()}),(e.has("showDrawer")||e.has("deferDrawer"))&&this.showDrawer&&!this.deferDrawer&&this._ensureDrawerReady(),e.has("showSearch")&&!this.showSearch&&this._setMobileSearchOpen(!1),e.has("layoutPending")&&!this.layoutPending&&this.requestLayout(),(e.has("activeTab")||e.has("_slotNavItems")||e.has("tabs")||e.has("size"))&&this.updateComplete.then(()=>{this._syncDropdownTabs()})}disconnectedCallback(){this._ro?.disconnect(),this._slotMo?.disconnect(),this._slotWatchers.forEach(e=>e.disconnect()),this._slotWatchers=[],window.removeEventListener("resize",this._onWindowResize),super.disconnectedCallback()}_mapSpacingToken(e){if(!e)return;const t=String(e).trim();if(t)return/^\d+$/.test(t)?`var(--spacing-${Math.max(0,Math.min(14,parseInt(t,10)))})`:t}_applySpacing(){const e=this._mapSpacingToken(this.spacing),t=this._mapSpacingToken(this.spacingTop)??e,s=this._mapSpacingToken(this.spacingBottom)??e;t?this.style.setProperty("--scb-header-spacing-block-start",t):this.style.removeProperty("--scb-header-spacing-block-start"),s?this.style.setProperty("--scb-header-spacing-block-end",s):this.style.removeProperty("--scb-header-spacing-block-end")}_syncLandmarkAttributes(){const e=this.renderRoot.querySelector(".header-landmark");if(!e)return;if(!this.banner){e.removeAttribute("role"),e.removeAttribute("aria-label");return}e.setAttribute("role","banner");const t=(this.bannerLabel??"").trim();t?e.setAttribute("aria-label",t):e.removeAttribute("aria-label")}_applyLogoSizing(){const e=(this.logoWidth??"").trim(),t=(this.logoHeight??"").trim(),s=(this.logoAspectRatio??"").trim();e?this.style.setProperty("--scb-header-logo-img-w",e):this.style.removeProperty("--scb-header-logo-img-w"),t?this.style.setProperty("--scb-header-logo-img-h",t):e?this.style.setProperty("--scb-header-logo-img-h","auto"):this.style.removeProperty("--scb-header-logo-img-h"),s?this.style.setProperty("--scb-header-logo-img-aspect-ratio",s):this.style.removeProperty("--scb-header-logo-img-aspect-ratio")}_closeDrawerNow(){const e=this.renderRoot.querySelector(`#${this._drawerId}`);e&&(e.open=!1)}_openDrawerNow(){const e=this.renderRoot.querySelector(`#${this._drawerId}`);e&&(e.open=!0)}async _ensureDrawerReady(){this._drawerReady||(this._drawerImportPromise??(this._drawerImportPromise=Promise.all([T(()=>import("../scb-drawer/scb-drawer.js"),__vite__mapDeps([0,1,2,3,4,5]),import.meta.url),T(()=>import("../scb-menu/scb-menu.js"),__vite__mapDeps([6,5,1,2,3,4,7,8,9,10,11]),import.meta.url)]).then(()=>{})),await this._drawerImportPromise,this._drawerReady=!0)}async _ensureDropdownReady(){customElements.get("scb-dropdown")||(this._dropdownImportPromise??(this._dropdownImportPromise=T(()=>import("../scb-dropdown/scb-dropdown.js").then(()=>{}),__vite__mapDeps([12,1,13,2,3,14,5,9,15,16,4,17]),import.meta.url)),await this._dropdownImportPromise)}_syncMenuBtnAria(){this.renderRoot.querySelectorAll(".menu-trigger").forEach(e=>{e.setAttribute("aria-expanded",String(this._menuExpanded))})}_getNavItems(){return this._slotNavItems.length?this._slotNavItems:(this.tabs??[]).map(e=>({kind:"tab",...e}))}_getDropdownForSlot(e){const t=this.querySelector(`[slot="${e}"]`);return t?t.tagName.toLowerCase()==="scb-dropdown"?t:t.querySelector("scb-dropdown"):null}_syncDropdownTabs(){this._getNavItems().forEach((e,t)=>{if(e.kind!=="dropdown")return;const s=this._getDropdownForSlot(e.slotName);if(!s)return;const r=String(t);s.getAttribute("data-index")!==r&&s.setAttribute("data-index",r),s.hasAttribute("as-tab")||s.setAttribute("as-tab","");const i=this.size,a=s;a?.size!==i&&(a.size=i),t===this.activeTab?s.getAttribute("aria-current")!=="page"&&s.setAttribute("aria-current","page"):s.hasAttribute("aria-current")&&s.removeAttribute("aria-current")})}_readTabIndexFromEvent(e){const t=e.composedPath?e.composedPath():[];for(const s of t){if(!(s instanceof HTMLElement))continue;const r=s.getAttribute("data-index");if(r==null)continue;const i=Number(r);if(Number.isFinite(i))return i}return null}_focusTabAtIndex(e){const t=this._getNavItems()[e];if(t){if(t.kind==="dropdown"){this._getDropdownForSlot(t.slotName)?.focus?.();return}this.renderRoot.querySelector(`.tab-link[data-index="${e}"]`)?.focus?.()}}_renderMenuNodes(e){return!e||e.length===0?m``:m`${e.map(t=>this._renderMenuNode(t))}`}_renderMenuNode(e){const t=Array.isArray(e.children)&&e.children.length>0,s=(e.href??"").trim(),r=(e.icon??"").trim(),i=t?m`
|
|
54
|
+
<scb-sub-menu label=${e.label}>
|
|
55
|
+
${e.children.map(a=>this._renderMenuNode(a))}
|
|
56
|
+
</scb-sub-menu>
|
|
57
|
+
`:_;return r&&s?m`
|
|
58
|
+
<scb-menu-item label=${e.label} ?selected=${!1} leading-icon=${r} item-href=${s}>
|
|
59
|
+
${i}
|
|
60
|
+
</scb-menu-item>
|
|
61
|
+
`:r?m`
|
|
62
|
+
<scb-menu-item label=${e.label} ?selected=${!1} leading-icon=${r}>
|
|
63
|
+
${i}
|
|
64
|
+
</scb-menu-item>
|
|
65
|
+
`:s?m`
|
|
66
|
+
<scb-menu-item label=${e.label} ?selected=${!1} item-href=${s}>
|
|
67
|
+
${i}
|
|
68
|
+
</scb-menu-item>
|
|
69
|
+
`:m`<scb-menu-item label=${e.label} ?selected=${!1}>${i}</scb-menu-item>`}_syncFlags(e,t){this.toggleAttribute("data-no-utility",e),this.toggleAttribute("data-no-search",t)}_renderMenuButton(e="",t=!1){const s=e?`menu-trigger ${e}`:"menu-trigger",r=(this.menuButtonLabel??"").trim()||"Meny",i=this._menuExpanded?"true":"false";return t?m`
|
|
67
70
|
<scb-icon-button
|
|
68
71
|
class=${s}
|
|
69
72
|
icon="menu"
|
|
@@ -71,11 +74,11 @@ import"../../vendor/vendor-material.js";import{_ as E,b as P,g as I,h as c,m as
|
|
|
71
74
|
aria-label=${r}
|
|
72
75
|
aria-controls=${this._drawerId}
|
|
73
76
|
aria-haspopup="dialog"
|
|
74
|
-
aria-expanded=${
|
|
77
|
+
aria-expanded=${i}
|
|
75
78
|
title="Öppna meny"
|
|
76
79
|
@click=${this._onMenuClick}
|
|
77
80
|
></scb-icon-button>
|
|
78
|
-
`:
|
|
81
|
+
`:m`
|
|
79
82
|
<scb-button
|
|
80
83
|
class=${s}
|
|
81
84
|
variant="text"
|
|
@@ -85,22 +88,18 @@ import"../../vendor/vendor-material.js";import{_ as E,b as P,g as I,h as c,m as
|
|
|
85
88
|
.size=${this.size}
|
|
86
89
|
aria-controls=${this._drawerId}
|
|
87
90
|
aria-haspopup="dialog"
|
|
88
|
-
aria-expanded=${
|
|
91
|
+
aria-expanded=${i}
|
|
89
92
|
title="Öppna meny"
|
|
90
93
|
@click=${this._onMenuClick}
|
|
91
94
|
></scb-button>
|
|
92
|
-
`}render(){const e=this._getNavItems(),t=this._slotUtils.length?this._slotUtils:this.utilityItems,s=this._slotMenu.length?this._slotMenu:this.menuData??[],r=this.logoText||this.logotypeText,i=this.logoAlt||r||"Gå till startsidan",a=this.querySelector('[slot="drawer-menu"]')!==null;this._syncFlags(t.length===0,!this.showSearch);const d=this.searchHeight&&this.searchHeight.trim()?`--scb-search-height:${this.searchHeight.trim()}`:
|
|
95
|
+
`}render(){const e=this._getNavItems(),t=this._slotUtils.length?this._slotUtils:this.utilityItems,s=this._slotMenu.length?this._slotMenu:this.menuData??[],r=this.logoText||this.logotypeText,i=this.logoAlt||r||"Gå till startsidan",a=this.querySelector('[slot="drawer-menu"]')!==null;this._syncFlags(t.length===0,!this.showSearch);const d=this.searchHeight&&this.searchHeight.trim()?`--scb-search-height:${this.searchHeight.trim()}`:"",n=e.length>0||this.reserveTabs||this.layoutPending,u=(this.reserveTabs||this.layoutPending)&&(this.layoutPending||e.length===0),b=this.showDrawer&&(!this.deferDrawer||this._drawerReady),v=typeof window<"u"&&window.innerWidth>=this.BP_MD,y=this.showDrawer&&(v?this.alwaysShowMenuButton||this._collapsed:!0),w=y&&!v,h=y&&v,A=(this.searchButtonLabel??"").trim()||"Sök",f=this.showSearch&&!this._mobileSearchOpen;return m`
|
|
93
96
|
<slot
|
|
94
97
|
id="data-slot"
|
|
95
98
|
@slotchange=${()=>{this._harvest(),this._attachSlotObservers()}}
|
|
96
99
|
hidden
|
|
97
100
|
></slot>
|
|
98
101
|
|
|
99
|
-
<div
|
|
100
|
-
class="header-landmark"
|
|
101
|
-
role=${this.banner?"banner":v}
|
|
102
|
-
aria-label=${this.banner&&this.bannerLabel?this.bannerLabel:v}
|
|
103
|
-
>
|
|
102
|
+
<div class="header-landmark">
|
|
104
103
|
<scb-grid
|
|
105
104
|
cols-compact="4"
|
|
106
105
|
cols-medium="8"
|
|
@@ -128,17 +127,17 @@ import"../../vendor/vendor-material.js";import{_ as E,b as P,g as I,h as c,m as
|
|
|
128
127
|
|
|
129
128
|
<div class="actions">
|
|
130
129
|
<nav class="utility" aria-label="Funktionslänkar">
|
|
131
|
-
${t.map(
|
|
130
|
+
${t.map(g=>m`
|
|
132
131
|
<scb-button
|
|
133
132
|
variant="text"
|
|
134
|
-
.href=${
|
|
135
|
-
.target=${
|
|
136
|
-
label=${
|
|
133
|
+
.href=${g.href}
|
|
134
|
+
.target=${g.target??""}
|
|
135
|
+
label=${g.label}
|
|
137
136
|
></scb-button>
|
|
138
137
|
`)}
|
|
139
138
|
</nav>
|
|
140
139
|
|
|
141
|
-
${this.showSearch?
|
|
140
|
+
${this.showSearch?m`
|
|
142
141
|
<div class="search" style=${d}>
|
|
143
142
|
<scb-search
|
|
144
143
|
id=${this._searchId}
|
|
@@ -152,13 +151,13 @@ import"../../vendor/vendor-material.js";import{_ as E,b as P,g as I,h as c,m as
|
|
|
152
151
|
></scb-search>
|
|
153
152
|
<scb-button
|
|
154
153
|
variant="filled-tonal"
|
|
155
|
-
label=${
|
|
154
|
+
label=${A}
|
|
156
155
|
.size=${this.size}
|
|
157
156
|
@click=${this._onSearchClick}
|
|
158
157
|
></scb-button>
|
|
159
158
|
</div>
|
|
160
|
-
`:
|
|
161
|
-
${
|
|
159
|
+
`:_}
|
|
160
|
+
${f?m`
|
|
162
161
|
<scb-icon-button
|
|
163
162
|
class="mobile-search-trigger"
|
|
164
163
|
variant="filled-tonal"
|
|
@@ -166,11 +165,11 @@ import"../../vendor/vendor-material.js";import{_ as E,b as P,g as I,h as c,m as
|
|
|
166
165
|
.size=${this.size}
|
|
167
166
|
@click=${this._onMobileSearchToggle}
|
|
168
167
|
></scb-icon-button>
|
|
169
|
-
`:
|
|
170
|
-
${
|
|
168
|
+
`:_}
|
|
169
|
+
${w?this._renderMenuButton("",!0):_}
|
|
171
170
|
</div>
|
|
172
171
|
|
|
173
|
-
${this.showSearch&&this._mobileSearchOpen?
|
|
172
|
+
${this.showSearch&&this._mobileSearchOpen?m`
|
|
174
173
|
<div class="mobile-search-panel" style=${d}>
|
|
175
174
|
<scb-search
|
|
176
175
|
.size=${this.size}
|
|
@@ -188,7 +187,7 @@ import"../../vendor/vendor-material.js";import{_ as E,b as P,g as I,h as c,m as
|
|
|
188
187
|
@click=${this._onMobileSearchToggle}
|
|
189
188
|
></scb-icon-button>
|
|
190
189
|
</div>
|
|
191
|
-
`:
|
|
190
|
+
`:_}
|
|
192
191
|
|
|
193
192
|
</div>
|
|
194
193
|
</scb-grid-item>
|
|
@@ -198,14 +197,14 @@ import"../../vendor/vendor-material.js";import{_ as E,b as P,g as I,h as c,m as
|
|
|
198
197
|
col-span-medium="8"
|
|
199
198
|
col-span-expanded="12"
|
|
200
199
|
>
|
|
201
|
-
<div class=${
|
|
202
|
-
${
|
|
200
|
+
<div class=${n||h?"tabs-row":"tabs-row tabs-row--empty"}>
|
|
201
|
+
${n?u?m`
|
|
203
202
|
<div class="tabs-inset">
|
|
204
203
|
<div class="tabs-nav tabs-nav--skeleton" aria-hidden="true">
|
|
205
204
|
${this._renderTabSkeletons()}
|
|
206
205
|
</div>
|
|
207
206
|
</div>
|
|
208
|
-
`:e.length?
|
|
207
|
+
`:e.length?m`
|
|
209
208
|
<div class="tabs-inset">
|
|
210
209
|
<nav
|
|
211
210
|
class="tabs-nav"
|
|
@@ -213,49 +212,49 @@ import"../../vendor/vendor-material.js";import{_ as E,b as P,g as I,h as c,m as
|
|
|
213
212
|
@keydown=${this._onTabsKeydown}
|
|
214
213
|
@scb-dropdown-tab-activate=${this._onDropdownTabActivate}
|
|
215
214
|
>
|
|
216
|
-
${e.map((
|
|
215
|
+
${e.map((g,x)=>g.kind==="dropdown"?m`
|
|
217
216
|
<div class="tab-wrap">
|
|
218
|
-
<slot name=${
|
|
217
|
+
<slot name=${g.slotName}></slot>
|
|
219
218
|
</div>
|
|
220
|
-
`:
|
|
219
|
+
`:g.href?m`
|
|
221
220
|
<div class="tab-wrap">
|
|
222
221
|
<a
|
|
223
222
|
class="tab-link"
|
|
224
|
-
href=${
|
|
225
|
-
data-index=${
|
|
226
|
-
aria-current=${
|
|
223
|
+
href=${g.href}
|
|
224
|
+
data-index=${x}
|
|
225
|
+
aria-current=${x===this.activeTab?"page":"false"}
|
|
227
226
|
@click=${this._onTabClick}
|
|
228
227
|
>
|
|
229
|
-
${
|
|
228
|
+
${g.label}
|
|
230
229
|
</a>
|
|
231
230
|
<md-focus-ring></md-focus-ring>
|
|
232
231
|
</div>
|
|
233
|
-
`:
|
|
232
|
+
`:m`
|
|
234
233
|
<div class="tab-wrap">
|
|
235
234
|
<button
|
|
236
235
|
type="button"
|
|
237
236
|
class="tab-link"
|
|
238
|
-
data-index=${
|
|
239
|
-
aria-current=${
|
|
237
|
+
data-index=${x}
|
|
238
|
+
aria-current=${x===this.activeTab?"page":"false"}
|
|
240
239
|
@click=${this._onTabClick}
|
|
241
240
|
>
|
|
242
|
-
${
|
|
241
|
+
${g.label}
|
|
243
242
|
</button>
|
|
244
243
|
<md-focus-ring></md-focus-ring>
|
|
245
244
|
</div>
|
|
246
245
|
`)}
|
|
247
246
|
</nav>
|
|
248
247
|
</div>
|
|
249
|
-
`:
|
|
248
|
+
`:_:_}
|
|
250
249
|
|
|
251
|
-
${
|
|
250
|
+
${h?this._renderMenuButton("menu-trigger--tabs-right"):_}
|
|
252
251
|
</div>
|
|
253
252
|
</scb-grid-item>
|
|
254
253
|
</scb-grid>
|
|
255
254
|
<div class="divider" role="presentation"></div>
|
|
256
255
|
</div>
|
|
257
256
|
|
|
258
|
-
${
|
|
257
|
+
${b?m`
|
|
259
258
|
<scb-drawer
|
|
260
259
|
id=${this._drawerId}
|
|
261
260
|
floating
|
|
@@ -270,7 +269,7 @@ import"../../vendor/vendor-material.js";import{_ as E,b as P,g as I,h as c,m as
|
|
|
270
269
|
>
|
|
271
270
|
<slot name="drawer-menu"></slot>
|
|
272
271
|
|
|
273
|
-
${a?
|
|
272
|
+
${a?_:m`
|
|
274
273
|
<scb-menu
|
|
275
274
|
.label=${this.menuLabel??""}
|
|
276
275
|
.subLabel=${this.menuSubLabel??""}
|
|
@@ -280,28 +279,28 @@ import"../../vendor/vendor-material.js";import{_ as E,b as P,g as I,h as c,m as
|
|
|
280
279
|
.supportingText=${this.menuSearchPlaceholder??""}
|
|
281
280
|
></scb-search>
|
|
282
281
|
|
|
283
|
-
${this.menuSectionLabel?
|
|
282
|
+
${this.menuSectionLabel?m`
|
|
284
283
|
<scb-menu-section
|
|
285
284
|
.label=${this.menuSectionLabel}
|
|
286
285
|
></scb-menu-section>
|
|
287
|
-
`:
|
|
286
|
+
`:_}
|
|
288
287
|
|
|
289
288
|
${this._renderMenuNodes(s)}
|
|
290
289
|
|
|
291
|
-
${this.includeUtilityInMenu&&(t?.length??0)>0?
|
|
290
|
+
${this.includeUtilityInMenu&&(t?.length??0)>0?m`
|
|
292
291
|
<scb-menu-section label=''></scb-menu-section>
|
|
293
|
-
${t.map(
|
|
292
|
+
${t.map(g=>m`
|
|
294
293
|
<scb-menu-item
|
|
295
|
-
label=${
|
|
296
|
-
item-href=${
|
|
294
|
+
label=${g.label}
|
|
295
|
+
item-href=${g.href}
|
|
297
296
|
></scb-menu-item>
|
|
298
297
|
`)}
|
|
299
|
-
`:
|
|
298
|
+
`:_}
|
|
300
299
|
</scb-menu>
|
|
301
300
|
`}
|
|
302
301
|
</scb-drawer>
|
|
303
|
-
`:
|
|
304
|
-
`}_renderTabSkeletons(){const e=["96px","72px","88px","64px"],t=(this.reserveTabsWidths??"").split(/[\s,]+/).map(a=>a.trim()).filter(Boolean).map(a=>/^\d+(?:\.\d+)?$/.test(a)?`${a}px`:a),s=t.length>0?t:e,r=Number(this.reserveTabsCount),i=Number.isFinite(r)&&r>0?Math.floor(r):t.length>0?t.length:e.length;return
|
|
302
|
+
`:_}
|
|
303
|
+
`}_renderTabSkeletons(){const e=["96px","72px","88px","64px"],t=(this.reserveTabsWidths??"").split(/[\s,]+/).map(a=>a.trim()).filter(Boolean).map(a=>/^\d+(?:\.\d+)?$/.test(a)?`${a}px`:a),s=t.length>0?t:e,r=Number(this.reserveTabsCount),i=Number.isFinite(r)&&r>0?Math.floor(r):t.length>0?t.length:e.length;return m`${Array.from({length:i},(a,d)=>s[d%s.length]).map(a=>m`<scb-skeleton variant="rounded" width=${a} height="16px"></scb-skeleton>`)}`}_renderLogo(){const e=(this.logoSrc??"").trim();return e?m`<img class="logo" src=${e} alt="" aria-hidden="true" />`:m`
|
|
305
304
|
<svg
|
|
306
305
|
class="logo"
|
|
307
306
|
viewBox="0 0 48 54"
|
|
@@ -335,7 +334,7 @@ import"../../vendor/vendor-material.js";import{_ as E,b as P,g as I,h as c,m as
|
|
|
335
334
|
</clipPath>
|
|
336
335
|
</defs>
|
|
337
336
|
</svg>
|
|
338
|
-
`}}
|
|
337
|
+
`}},C=k,k._JSON_ARRAY={fromAttribute:p=>{if(p==null||p==="")return[];try{const e=JSON.parse(p);return Array.isArray(e)?e:[]}catch{return[]}},toAttribute:p=>p==null?null:JSON.stringify(p)},k.BP_SM_DEFAULT=600,k.BP_MD_DEFAULT=840,k.styles=P`
|
|
339
338
|
:host {
|
|
340
339
|
display: block;
|
|
341
340
|
margin-block-start: var(--scb-header-spacing-block-start, 0);
|
|
@@ -803,4 +802,4 @@ import"../../vendor/vendor-material.js";import{_ as E,b as P,g as I,h as c,m as
|
|
|
803
802
|
:host([data-hide-logo-text]) .logo-text {
|
|
804
803
|
display: none;
|
|
805
804
|
}
|
|
806
|
-
`,
|
|
805
|
+
`,k);l([c({type:String,attribute:"max-width"})],o.prototype,"maxWidth",void 0);l([c({type:String,reflect:!0})],o.prototype,"spacing",void 0);l([c({type:String,attribute:"spacing-top",reflect:!0})],o.prototype,"spacingTop",void 0);l([c({type:String,attribute:"spacing-bottom",reflect:!0})],o.prototype,"spacingBottom",void 0);l([c({type:String,reflect:!0,converter:N})],o.prototype,"size",void 0);l([c({type:String,attribute:"logo-text"})],o.prototype,"logoText",void 0);l([c({type:String,attribute:"logotype-text"})],o.prototype,"logotypeText",void 0);l([c({type:String,attribute:"logo-alt"})],o.prototype,"logoAlt",void 0);l([c({type:String,attribute:"logo-href"})],o.prototype,"logoHref",void 0);l([c({type:String,attribute:"logo-src"})],o.prototype,"logoSrc",void 0);l([c({type:String,attribute:"logo-width"})],o.prototype,"logoWidth",void 0);l([c({type:String,attribute:"logo-height"})],o.prototype,"logoHeight",void 0);l([c({type:String,attribute:"logo-aspect-ratio"})],o.prototype,"logoAspectRatio",void 0);l([c({type:Boolean,attribute:"logo-invert-dm",reflect:!0,converter:$})],o.prototype,"logoInvertDm",void 0);l([c({type:Boolean,reflect:!0})],o.prototype,"banner",void 0);l([c({type:String,attribute:"banner-label"})],o.prototype,"bannerLabel",void 0);l([c({type:Array,attribute:"tabs",converter:o._JSON_ARRAY})],o.prototype,"tabs",void 0);l([c({type:Number,attribute:"active-tab"})],o.prototype,"activeTab",void 0);l([c({type:Boolean,attribute:"reserve-tabs",reflect:!0,converter:$})],o.prototype,"reserveTabs",void 0);l([c({type:Number,attribute:"reserve-tabs-count"})],o.prototype,"reserveTabsCount",void 0);l([c({type:String,attribute:"reserve-tabs-widths"})],o.prototype,"reserveTabsWidths",void 0);l([c({type:Boolean,attribute:"layout-pending",reflect:!0,converter:$})],o.prototype,"layoutPending",void 0);l([c({type:Array,attribute:"utility-items",converter:o._JSON_ARRAY})],o.prototype,"utilityItems",void 0);l([c({type:String,attribute:"search-placeholder"})],o.prototype,"searchPlaceholder",void 0);l([c({type:String,attribute:"search-button-label"})],o.prototype,"searchButtonLabel",void 0);l([c({type:String,attribute:"menu-label"})],o.prototype,"menuLabel",void 0);l([c({type:String,attribute:"menu-button-label"})],o.prototype,"menuButtonLabel",void 0);l([c({type:String,attribute:"menu-sub-label"})],o.prototype,"menuSubLabel",void 0);l([c({type:String,attribute:"menu-section-label"})],o.prototype,"menuSectionLabel",void 0);l([c({type:String,attribute:"menu-search-placeholder"})],o.prototype,"menuSearchPlaceholder",void 0);l([c({type:Array,attribute:"menu-data",converter:o._JSON_ARRAY})],o.prototype,"menuData",void 0);l([c({type:Boolean,attribute:"defer-drawer",reflect:!0,converter:$})],o.prototype,"deferDrawer",void 0);l([c({type:Boolean,attribute:"show-drawer",reflect:!0,converter:M})],o.prototype,"showDrawer",void 0);l([c({type:Boolean,attribute:"always-show-menu-button",reflect:!0,converter:$})],o.prototype,"alwaysShowMenuButton",void 0);l([c({type:Boolean,attribute:"show-search",reflect:!0,converter:M})],o.prototype,"showSearch",void 0);l([c({type:Boolean,attribute:"include-utility-in-menu",reflect:!0,converter:$})],o.prototype,"includeUtilityInMenu",void 0);l([c({type:Boolean,attribute:"drawer-overlay",reflect:!0,converter:M})],o.prototype,"drawerOverlay",void 0);l([c({type:String,attribute:"search-max"})],o.prototype,"searchMax",void 0);l([c({type:String,attribute:"search-min"})],o.prototype,"searchMin",void 0);l([c({type:String,attribute:"search-height"})],o.prototype,"searchHeight",void 0);l([c({type:String,attribute:"search-text",reflect:!0})],o.prototype,"searchText",void 0);l([S()],o.prototype,"_drawerId",void 0);l([S()],o.prototype,"_menuExpanded",void 0);l([S()],o.prototype,"_searchId",void 0);l([S()],o.prototype,"_drawerReady",void 0);l([S()],o.prototype,"_mobileSearchOpen",void 0);l([S()],o.prototype,"_slotNavItems",void 0);l([S()],o.prototype,"_slotUtils",void 0);l([S()],o.prototype,"_slotMenu",void 0);l([S()],o.prototype,"_collapsed",void 0);l([S()],o.prototype,"_hideLogoText",void 0);o=C=l([I("scb-header")],o);
|
|
@@ -23,4 +23,4 @@ import{_ as u,b as f,g as b,h as o,p as _,y as v}from"../../vendor/vendor.js";im
|
|
|
23
23
|
:host([no-divider]) ::slotted(scb-list-item) {
|
|
24
24
|
--stroke-border: 0px;
|
|
25
25
|
}
|
|
26
|
-
`],d);a([o({type:Boolean,attribute:"no-divider",reflect:!0})],n.prototype,"noDivider",void 0);a([o({type:String,reflect:!0})],n.prototype,"spacing",void 0);a([o({type:String,reflect:!0,attribute:"spacing-top"})],n.prototype,"spacingTop",void 0);a([o({type:String,reflect:!0,attribute:"spacing-bottom"})],n.prototype,"spacingBottom",void 0);a([o({type:String,reflect:!0,attribute:"spacing-left"})],n.prototype,"spacingLeft",void 0);a([o({type:String,reflect:!0,attribute:"spacing-right"})],n.prototype,"spacingRight",void 0);a([_("slot")],n.prototype,"_slotEl",void 0);n=a([b("scb-list")],n);
|
|
26
|
+
`],d);a([o({type:Boolean,attribute:"no-divider",reflect:!0})],n.prototype,"noDivider",void 0);a([o({type:String,reflect:!0})],n.prototype,"spacing",void 0);a([o({type:String,reflect:!0,attribute:"spacing-top"})],n.prototype,"spacingTop",void 0);a([o({type:String,reflect:!0,attribute:"spacing-bottom"})],n.prototype,"spacingBottom",void 0);a([o({type:String,reflect:!0,attribute:"spacing-left"})],n.prototype,"spacingLeft",void 0);a([o({type:String,reflect:!0,attribute:"spacing-right"})],n.prototype,"spacingRight",void 0);a([_("slot")],n.prototype,"_slotEl",void 0);n=a([b("scb-list")],n);export{n as ScbList};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
const __vite__mapDeps=(i,m=__vite__mapDeps,d=(m.f||(m.f=["../scb-list/scb-list.js","../../vendor/classPrivateFieldGet2.js","../../vendor/assertClassBrand.js","../../vendor/decorate.js","../../vendor/preload-helper.js","../../vendor/vendor.js","../../vendor/vendor-lit.js","../scb-list/scb-list-item.js","../../vendor/vendor-material.js"])))=>i.map(i=>d[i]);
|
|
2
|
+
import"../../vendor/vendor-material.js";import{_ as x,b as S,g as w,h as o,m as A,v,y as h}from"../../vendor/vendor.js";import"../../vendor/vendor-lit.js";import{t as a}from"../../vendor/decorate.js";import{t as k}from"../../vendor/preload-helper.js";(function(){try{var u=typeof globalThis<"u"?globalThis:window;if(!u.__scb_ce_guard_installed__){u.__scb_ce_guard_installed__=!0;var t=customElements.define.bind(customElements);customElements.define=function(e,s,r){try{customElements.get(e)||t(e,s,r)}catch(l){var i=String(l||"");if(i.indexOf("already been used")===-1&&i.indexOf("NotSupportedError")===-1)throw l}}}}catch{}})();var d,E=0,n=(d=class extends x{async _ensureListDepsLoaded(){this._listDepsLoaded||(this._listDepsPromise??(this._listDepsPromise=k(()=>import("../scb-list/scb-list.js").then(()=>{this._listDepsLoaded=!0}),__vite__mapDeps([0,1,2,3,4,5,6,7,8]),import.meta.url)),await this._listDepsPromise)}_ensureListDepsWhenNeeded(){const t=(this.value??"").trim().length>0;!this._inputFocused||!t||!this._hasSuggestions||this._ensureListDepsLoaded().then(()=>this.requestUpdate())}constructor(){super(),this._internals=null,this.supportingText="",this.value="",this.name="",this.disabled=!1,this.required=!1,this.autocomplete=!1,this.spacing=void 0,this.spacingTop=void 0,this.spacingBottom=void 0,this.spacingLeft=void 0,this.spacingRight=void 0,this.size="large",this.fullScreen=!1,this._inputFocused=!1,this._visibleSuggestions=0,this._listDepsLoaded=!1,this._activeIndex=-1,this._listboxId=`scb-search-listbox-${++E}`,this._kbMode=!1,this._valueOnFocus="",this._lastChangeValue="",this._kbShouldShowRing=!1,this._onGlobalKeydown=t=>{t.key==="Tab"&&(this._kbShouldShowRing=!0,this._inputFocused&&this._updateInputRingVisibility())},this._onGlobalPointerDown=()=>{this._kbShouldShowRing=!1,this._inputFocused&&this._updateInputRingVisibility()},this._form=null,this._formResetHandler=null,this._formSubmitHandler=null,this._initialValue="",this._customValidationMessage="",this._listScrollHandler=()=>{const t=this._getActiveItem();this._kbMode&&t&&this._positionOptionRing(t)},"attachInternals"in this&&(this._internals=this.attachInternals())}_syncDensityForSize(){this.size==="small"?this.setAttribute("data-density","-4"):this.size==="medium"?this.setAttribute("data-density","-2"):this.removeAttribute("data-density")}connectedCallback(){super.connectedCallback(),this._syncDensityForSize(),this._onWindowResize=this._onWindowResize.bind(this),window.addEventListener("resize",this._onWindowResize,{passive:!0}),window.addEventListener("keydown",this._onGlobalKeydown,!0),window.addEventListener("pointerdown",this._onGlobalPointerDown,!0),this._initialValue=this.value??"",this._lastChangeValue=this.value??"",this._form=this.closest("form"),this._form&&(this._formSubmitHandler=t=>{this.reportValidity()||(t.preventDefault(),t.stopPropagation())},this._form.addEventListener("submit",this._formSubmitHandler,!0),this._formResetHandler=()=>{this.value=this._initialValue;const t=this._inputEl();t&&(t.value=this._initialValue),this._lastChangeValue=this._initialValue,this._syncFormValue(),this._filterSuggestions(this.value),this._activeIndex=-1,this._kbMode=!1,this._updateComboboxA11y()},this._form.addEventListener("reset",this._formResetHandler,!0)),this._syncFormValue(),this._syncValidity()}disconnectedCallback(){const t=this._inputEl();t&&this._boundNativeKeydown&&t.removeEventListener("keydown",this._boundNativeKeydown,!0),this._detachListScrollListener(),window.removeEventListener("resize",this._onWindowResize),window.removeEventListener("keydown",this._onGlobalKeydown,!0),window.removeEventListener("pointerdown",this._onGlobalPointerDown,!0),this._form&&this._formResetHandler&&this._form.removeEventListener("reset",this._formResetHandler,!0),this._form&&this._formSubmitHandler&&this._form.removeEventListener("submit",this._formSubmitHandler,!0),super.disconnectedCallback()}firstUpdated(){this._ensureListboxA11y(),this._updateComboboxA11y();const t=this._inputEl();t&&(this._boundNativeKeydown=e=>this._handleKey(e),t.addEventListener("keydown",this._boundNativeKeydown,!0),t.disabled=this.disabled),this.applySpacing()}updated(t){if(super.updated(t),t.has("size")&&this._syncDensityForSize(),this._ensureListboxA11y(),this._updateComboboxA11y(),this._attachListScrollListener(),(t.has("value")||t.has("disabled"))&&this._syncFormValue(),(t.has("value")||t.has("disabled")||t.has("required"))&&this._syncValidity(),t.has("disabled")){this.toggleAttribute("aria-disabled",this.disabled);const e=this._inputEl();e&&(e.disabled=this.disabled)}(t.has("spacing")||t.has("spacingTop")||t.has("spacingBottom")||t.has("spacingLeft")||t.has("spacingRight"))&&this.applySpacing()}render(){const t=(this.value??"").trim().length>0,e=this._inputFocused&&t&&this._hasSuggestions&&this._listDepsLoaded;return h`
|
|
2
3
|
<div class="ripple-wrapper">
|
|
3
4
|
<md-icon class="leading">${t?"arrow_back":"search"}</md-icon>
|
|
4
5
|
|
|
@@ -27,7 +28,7 @@ import"../../vendor/vendor-material.js";import{_ as x,b as S,g as w,h as o,v as
|
|
|
27
28
|
aria-label="Rensa sökfält"
|
|
28
29
|
>
|
|
29
30
|
<md-icon>close</md-icon>
|
|
30
|
-
</button>`:this.trailingIcon?h`<span class="trailing"><md-icon>${this.trailingIcon}</md-icon></span>`:
|
|
31
|
+
</button>`:this.trailingIcon?h`<span class="trailing"><md-icon>${this.trailingIcon}</md-icon></span>`:v}
|
|
31
32
|
|
|
32
33
|
<md-ripple></md-ripple>
|
|
33
34
|
<md-focus-ring class="input-ring"></md-focus-ring>
|
|
@@ -40,8 +41,8 @@ import"../../vendor/vendor-material.js";import{_ as x,b as S,g as w,h as o,v as
|
|
|
40
41
|
<slot @slotchange=${this._onSlotChange}></slot>
|
|
41
42
|
</scb-list>
|
|
42
43
|
<md-focus-ring id="optionRing" class="option-ring"></md-focus-ring>
|
|
43
|
-
`:
|
|
44
|
-
`}formDisabledCallback(t){this.disabled=t}_getValidationMessage(){return this._customValidationMessage?this._customValidationMessage:this.required&&!(this.value??"").trim()?"Fyll i det här fältet.":""}_syncValidity(){const t=this._inputEl(),e=this.disabled?"":this._getValidationMessage();t&&(t.setCustomValidity(e),t.setAttribute("aria-invalid",e?"true":"false")),this._internals&&(e?this._internals.setValidity({valueMissing:!0},e,t??void 0):this._internals.setValidity({})),this.toggleAttribute("aria-invalid",!!e)}checkValidity(){return!this._getValidationMessage()}reportValidity(){this._syncValidity();const t=this._inputEl();return t?t.reportValidity():this._internals?this._internals.reportValidity():this.checkValidity()}setCustomValidity(t){this._customValidationMessage=t,this._syncValidity()}get validity(){return this._internals?.validity}get validationMessage(){return this._internals?.validationMessage??this._getValidationMessage()}get willValidate(){return this._internals?.willValidate??!0}submit(){const t=this._getActiveItem(),e={value:this.value};t&&(e.active=this._itemPayload(t)),this._dispatchSubmit(e)}get _hasSuggestions(){return this._visibleSuggestions>=0?this._visibleSuggestions>0:Array.from(this.getElementsByTagName("scb-list-item")).some(t=>!t.hasAttribute("hidden")&&t.style.display!=="none")}_onSlotChange(){this._filterSuggestions(this.value)}_onInput(t){t.stopPropagation();const e=t.target;this.value=e.value,this._syncFormValue(),this._filterSuggestions(this.value),this._activeIndex=-1,this._kbMode=!1,this._updateComboboxA11y();const s={value:this.value};this.dispatchEvent(new CustomEvent("scb-search-input",{detail:s,bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("scbsearchinput",{detail:s,bubbles:!0,composed:!0})),this._dispatchStandardInput()}_onNativeChange(t){t.stopPropagation()}_onFocus(){this.disabled||(this._valueOnFocus=this.value??"",this._inputFocused=!0,this._updateInputRingVisibility(),this._filterSuggestions(this.value),this._updateComboboxA11y(),this.requestUpdate())}_onBlur(){setTimeout(()=>{this._inputFocused=!1,this._activeIndex=-1,this._kbMode=!1,this._updateInputRingVisibility(),this._updateComboboxA11y(),this._hideOptionRing(),this._valueOnFocus!==(this.value??"")&&this._dispatchStandardChangeIfNeeded(),this.requestUpdate()},100)}_updateInputRingVisibility(){const t=this.renderRoot?.querySelector(".ripple-wrapper");t&&(this._inputFocused&&this._kbShouldShowRing?t.setAttribute("data-kb-focus","true"):t.removeAttribute("data-kb-focus"))}_handleKey(t){if(this.disabled||!this._inputEl())return;const e=this._getVisibleItems(),s=(this.value??"").trim().length>0,r=this._inputFocused&&s&&e.length>0,i=t.key,l=t.keyCode,p=i==="ArrowDown"||i==="Down"||l===40,b=i==="ArrowUp"||i==="Up"||l===38,g=i==="Home"||l===36,m=i==="End"||l===35,f=i==="Enter"||l===13,y=i==="Escape"||i==="Esc"||l===27;if(p){if(!r)return;t.preventDefault(),this._kbMode=!0,this._moveActive(e,1);return}if(b){if(!r)return;t.preventDefault(),this._kbMode=!0,this._moveActive(e,-1);return}if(g){if(!r)return;t.preventDefault(),this._kbMode=!0,this._activeIndex=e.length?0:-1,this._updateComboboxA11y(),this._scrollActiveIntoView();return}if(m){if(!r)return;t.preventDefault(),this._kbMode=!0,this._activeIndex=e.length?e.length-1:-1,this._updateComboboxA11y(),this._scrollActiveIntoView();return}if(f){if(!r){const c=this._internals?.form??this._form??this.closest("form");c?(t.preventDefault(),this.reportValidity()&&c.requestSubmit()):this.submit();return}t.preventDefault();const
|
|
44
|
+
`:v}
|
|
45
|
+
`}formDisabledCallback(t){this.disabled=t}_getValidationMessage(){return this._customValidationMessage?this._customValidationMessage:this.required&&!(this.value??"").trim()?"Fyll i det här fältet.":""}_syncValidity(){const t=this._inputEl(),e=this.disabled?"":this._getValidationMessage();t&&(t.setCustomValidity(e),t.setAttribute("aria-invalid",e?"true":"false")),this._internals&&(e?this._internals.setValidity({valueMissing:!0},e,t??void 0):this._internals.setValidity({})),this.toggleAttribute("aria-invalid",!!e)}checkValidity(){return!this._getValidationMessage()}reportValidity(){this._syncValidity();const t=this._inputEl();return t?t.reportValidity():this._internals?this._internals.reportValidity():this.checkValidity()}setCustomValidity(t){this._customValidationMessage=t,this._syncValidity()}get validity(){return this._internals?.validity}get validationMessage(){return this._internals?.validationMessage??this._getValidationMessage()}get willValidate(){return this._internals?.willValidate??!0}submit(){const t=this._getActiveItem(),e={value:this.value};t&&(e.active=this._itemPayload(t)),this._dispatchSubmit(e)}focus(t){const e=this._inputEl();if(e){e.focus(t);return}this.updateComplete.then(()=>this._inputEl()?.focus(t))}blur(){this._inputEl()?.blur()}get _hasSuggestions(){return this._visibleSuggestions>=0?this._visibleSuggestions>0:Array.from(this.getElementsByTagName("scb-list-item")).some(t=>!t.hasAttribute("hidden")&&t.style.display!=="none")}_onSlotChange(){this._filterSuggestions(this.value),this._ensureListDepsWhenNeeded()}_onInput(t){t.stopPropagation();const e=t.target;this.value=e.value,this._syncFormValue(),this._filterSuggestions(this.value),this._ensureListDepsWhenNeeded(),this._activeIndex=-1,this._kbMode=!1,this._updateComboboxA11y();const s={value:this.value};this.dispatchEvent(new CustomEvent("scb-search-input",{detail:s,bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("scbsearchinput",{detail:s,bubbles:!0,composed:!0})),this._dispatchStandardInput()}_onNativeChange(t){t.stopPropagation()}_onFocus(){this.disabled||(this._valueOnFocus=this.value??"",this._inputFocused=!0,this._updateInputRingVisibility(),this._filterSuggestions(this.value),this._ensureListDepsWhenNeeded(),this._updateComboboxA11y(),this.requestUpdate())}_onBlur(){setTimeout(()=>{this._inputFocused=!1,this._activeIndex=-1,this._kbMode=!1,this._updateInputRingVisibility(),this._updateComboboxA11y(),this._hideOptionRing(),this._valueOnFocus!==(this.value??"")&&this._dispatchStandardChangeIfNeeded(),this.requestUpdate()},100)}_updateInputRingVisibility(){const t=this.renderRoot?.querySelector(".ripple-wrapper");t&&(this._inputFocused&&this._kbShouldShowRing?t.setAttribute("data-kb-focus","true"):t.removeAttribute("data-kb-focus"))}_handleKey(t){if(this.disabled||!this._inputEl())return;const e=this._getVisibleItems(),s=(this.value??"").trim().length>0,r=this._inputFocused&&s&&e.length>0,i=t.key,l=t.keyCode,p=i==="ArrowDown"||i==="Down"||l===40,b=i==="ArrowUp"||i==="Up"||l===38,g=i==="Home"||l===36,m=i==="End"||l===35,f=i==="Enter"||l===13,y=i==="Escape"||i==="Esc"||l===27;if(p){if(!r)return;t.preventDefault(),this._kbMode=!0,this._moveActive(e,1);return}if(b){if(!r)return;t.preventDefault(),this._kbMode=!0,this._moveActive(e,-1);return}if(g){if(!r)return;t.preventDefault(),this._kbMode=!0,this._activeIndex=e.length?0:-1,this._updateComboboxA11y(),this._scrollActiveIntoView();return}if(m){if(!r)return;t.preventDefault(),this._kbMode=!0,this._activeIndex=e.length?e.length-1:-1,this._updateComboboxA11y(),this._scrollActiveIntoView();return}if(f){if(!r){const c=this._internals?.form??this._form??this.closest("form");c?(t.preventDefault(),this.reportValidity()&&c.requestSubmit()):this.submit();return}t.preventDefault();const _=this._getActiveItem();if(_){const c=_.getAttribute("label")||"";this.value=c,this._syncFormValue(),this._dispatchStandardInput(),this._dispatchSubmit({value:this.value,active:this._itemPayload(_)}),this._visibleSuggestions=0,this._activeIndex=-1,this._kbMode=!1,this._hideOptionRing(),this.requestUpdate()}else this.submit();return}if(y){t.preventDefault(),this._clearInput();return}}_clearInput(){if(this.disabled)return;this.value="",this._activeIndex=-1,this._kbMode=!1;const t=this._inputEl();t&&(t.value="",t.focus()),this._filterSuggestions(""),this._updateComboboxA11y(),this._hideOptionRing(),this._syncFormValue(),this._dispatchStandardInput(),this.dispatchEvent(new CustomEvent("scb-search-clear",{bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("scbsearchclear",{bubbles:!0,composed:!0})),this._dispatchStandardChangeIfNeeded()}_filterSuggestions(t){const e=(t??"").trim().toLowerCase(),s=Array.from(this.querySelectorAll("scb-list-item"));let r=0;for(const i of s){const l=`${(i.getAttribute("label")||"").toLowerCase()} ${(i.getAttribute("supporting-text")||"").toLowerCase()}`.trim();e!==""&&l.includes(e)?(i.removeAttribute("hidden"),r++):i.setAttribute("hidden",""),this._ensureOptionA11y(i)}this._visibleSuggestions=r,this._activeIndex>=r&&(this._activeIndex=-1),this._updateComboboxA11y(),this.requestUpdate()}_inputEl(){return this.renderRoot?.querySelector("#searchInput")??null}_listEl(){return this.renderRoot?.querySelector("scb-list.suggestion-list")??null}_ringEl(){return this.renderRoot?.querySelector("#optionRing")??null}_getVisibleItems(){return Array.from(this.querySelectorAll("scb-list-item")).filter(t=>!t.hasAttribute("hidden")&&t.style.display!=="none")}_getActiveItem(){const t=this._getVisibleItems();return this._activeIndex<0||this._activeIndex>=t.length?null:t[this._activeIndex]??null}_moveActive(t,e){if(!t.length){this._activeIndex=-1,this._updateComboboxA11y(),this._hideOptionRing();return}let s=this._activeIndex+e;this._activeIndex===-1?s=e>0?0:t.length-1:(s<0&&(s=0),s>=t.length&&(s=t.length-1)),this._activeIndex=s,this._updateComboboxA11y(),this._scrollActiveIntoView()}_scrollActiveIntoView(){const t=this._getActiveItem();t&&t.scrollIntoView({block:"nearest"})}_itemPayload(t){return{label:t.getAttribute("label")||"",supportingText:t.getAttribute("supporting-text")||"",href:t.getAttribute("href")||"",type:t.getAttribute("type")||"",id:t.id||""}}_ensureListboxA11y(){const t=this._listEl();t&&(t.id||(t.id=this._listboxId),t.setAttribute("role","listbox"),t.setAttribute("aria-label","Sökförslag")),Array.from(this.querySelectorAll("scb-list-item")).forEach(e=>this._ensureOptionA11y(e))}_ensureOptionA11y(t){t.id||(t.id=`${this._listboxId}-opt-${Math.random().toString(36).slice(2,8)}`),t.setAttribute("role","option"),t.setAttribute("tabindex","-1")}_updateComboboxA11y(){const t=this._inputEl();if(!t)return;const e=this._getVisibleItems(),s=(this.value??"").trim().length>0,r=this._inputFocused&&s&&e.length>0;t.setAttribute("role","combobox"),t.setAttribute("aria-autocomplete","list"),t.setAttribute("aria-controls",this._listboxId),t.setAttribute("aria-expanded",String(r));const i=r?this._getActiveItem():null;i?.id?t.setAttribute("aria-activedescendant",i.id):t.removeAttribute("aria-activedescendant"),this._kbMode&&i&&r?this._positionOptionRing(i):this._hideOptionRing()}_positionOptionRing(t){const e=this._ringEl(),s=this._listEl();if(!e||!s)return;const r=this.getBoundingClientRect(),i=t.getBoundingClientRect(),l=i.top-r.top,p=i.left-r.left,b=i.width,g=i.height;e.style.top=`${l}px`,e.style.left=`${p}px`,e.style.width=`${b}px`,e.style.height=`${g}px`,e.setAttribute("data-show","true")}_hideOptionRing(){const t=this._ringEl();t&&t.removeAttribute("data-show")}_onWindowResize(){const t=this._getActiveItem();this._kbMode&&t&&this._positionOptionRing(t)}_attachListScrollListener(){const t=this._listEl();!t||this._listWithHandler===t||(this._detachListScrollListener(),t.addEventListener("scroll",this._listScrollHandler,{passive:!0}),this._listWithHandler=t)}_detachListScrollListener(){this._listWithHandler&&(this._listWithHandler.removeEventListener("scroll",this._listScrollHandler),this._listWithHandler=void 0)}_dispatchStandardInput(){this.dispatchEvent(new Event("input",{bubbles:!0,composed:!0}))}_dispatchStandardChangeIfNeeded(){const t=this.value??"";t!==this._lastChangeValue&&(this._lastChangeValue=t,this.dispatchEvent(new Event("change",{bubbles:!0,composed:!0})))}_dispatchSubmit(t){this.dispatchEvent(new CustomEvent("scb-search-submit",{detail:t,bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("scbsearchsubmit",{detail:t,bubbles:!0,composed:!0})),this._dispatchStandardChangeIfNeeded()}mapSpacingToken(t){if(!t)return;const e=String(t).trim();if(e)return/^\d+$/.test(e)?`var(--spacing-${Math.max(0,Math.min(14,parseInt(e,10)))})`:e}applySpacing(){const t=this.mapSpacingToken(this.spacing),e=this.mapSpacingToken(this.spacingTop)??t,s=this.mapSpacingToken(this.spacingBottom)??t,r=this.mapSpacingToken(this.spacingLeft),i=this.mapSpacingToken(this.spacingRight);e?this.style.setProperty("--scb-search-spacing-block-start",e):this.style.removeProperty("--scb-search-spacing-block-start"),s?this.style.setProperty("--scb-search-spacing-block-end",s):this.style.removeProperty("--scb-search-spacing-block-end"),r?this.style.setProperty("--scb-search-spacing-inline-start",r):this.style.removeProperty("--scb-search-spacing-inline-start"),i?this.style.setProperty("--scb-search-spacing-inline-end",i):this.style.removeProperty("--scb-search-spacing-inline-end")}_syncFormValue(){if(!this._internals)return;const t=this.disabled?null:this.value;this._internals.setFormValue(t)}},d.formAssociated=!0,d.styles=S`
|
|
45
46
|
:host {
|
|
46
47
|
display: flex;
|
|
47
48
|
flex-direction: column;
|
|
@@ -289,4 +290,4 @@ import"../../vendor/vendor-material.js";import{_ as x,b as S,g as w,h as o,v as
|
|
|
289
290
|
color: var(--md-sys-color-on-surface);
|
|
290
291
|
}
|
|
291
292
|
}
|
|
292
|
-
`,d);a([o({type:String,attribute:"trailing-icon"})],n.prototype,"trailingIcon",void 0);a([o({type:String,attribute:"supporting-text"})],n.prototype,"supportingText",void 0);a([o({type:String})],n.prototype,"value",void 0);a([o({type:String,reflect:!0})],n.prototype,"name",void 0);a([o({type:Boolean,reflect:!0})],n.prototype,"disabled",void 0);a([o({type:Boolean,reflect:!0})],n.prototype,"required",void 0);a([o({type:Boolean,reflect:!0})],n.prototype,"autocomplete",void 0);a([o({type:String,reflect:!0})],n.prototype,"spacing",void 0);a([o({type:String,attribute:"spacing-top",reflect:!0})],n.prototype,"spacingTop",void 0);a([o({type:String,attribute:"spacing-bottom",reflect:!0})],n.prototype,"spacingBottom",void 0);a([o({type:String,attribute:"spacing-left",reflect:!0})],n.prototype,"spacingLeft",void 0);a([o({type:String,attribute:"spacing-right",reflect:!0})],n.prototype,"spacingRight",void 0);a([o({type:String,reflect:!0})],n.prototype,"size",void 0);a([o({type:Boolean,attribute:"full-screen",reflect:!0})],n.prototype,"fullScreen",void 0);n=a([w("scb-search")],n);
|
|
293
|
+
`,d);a([o({type:String,attribute:"trailing-icon"})],n.prototype,"trailingIcon",void 0);a([o({type:String,attribute:"supporting-text"})],n.prototype,"supportingText",void 0);a([o({type:String})],n.prototype,"value",void 0);a([o({type:String,reflect:!0})],n.prototype,"name",void 0);a([o({type:Boolean,reflect:!0})],n.prototype,"disabled",void 0);a([o({type:Boolean,reflect:!0})],n.prototype,"required",void 0);a([o({type:Boolean,reflect:!0})],n.prototype,"autocomplete",void 0);a([o({type:String,reflect:!0})],n.prototype,"spacing",void 0);a([o({type:String,attribute:"spacing-top",reflect:!0})],n.prototype,"spacingTop",void 0);a([o({type:String,attribute:"spacing-bottom",reflect:!0})],n.prototype,"spacingBottom",void 0);a([o({type:String,attribute:"spacing-left",reflect:!0})],n.prototype,"spacingLeft",void 0);a([o({type:String,attribute:"spacing-right",reflect:!0})],n.prototype,"spacingRight",void 0);a([o({type:String,reflect:!0})],n.prototype,"size",void 0);a([o({type:Boolean,attribute:"full-screen",reflect:!0})],n.prototype,"fullScreen",void 0);a([A()],n.prototype,"_listDepsLoaded",void 0);n=a([w("scb-search")],n);
|