scb-wc-test 0.1.142 → 0.1.143
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/mvc/components/scb-header/scb-header-tab.js +2 -2
- package/mvc/components/scb-header/scb-header.js +33 -16
- package/mvc/components/scb-menu/scb-menu.js +4 -4
- package/package.json +2 -2
- package/scb-header/scb-header-tab.d.ts +1 -0
- package/scb-header/scb-header-tab.js +19 -16
- package/scb-header/scb-header.d.ts +1 -0
- package/scb-header/scb-header.js +112 -94
- package/scb-menu/scb-menu.d.ts +3 -0
- package/scb-menu/scb-menu.js +72 -45
- package/scb-wc-test.bundle.js +278 -261
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as c,n as u,i as d,x as p,t as _}from"../../vendor/vendor.js";(function(){try{var a=typeof globalThis<"u"?globalThis:window;if(!a.__scb_ce_guard_installed__){a.__scb_ce_guard_installed__=!0;var r=customElements.define.bind(customElements);customElements.define=function(t,n,e){try{customElements.get(t)||r(t,n,e)}catch(i){var s=String(i||"");if(s.indexOf("already been used")===-1&&s.indexOf("NotSupportedError")===-1)throw i}}}}catch{}})();var f=Object.defineProperty,b=Object.getOwnPropertyDescriptor,l=(a,r,t,n)=>{for(var e=n>1?void 0:n?b(r,t):r,s=a.length-1,i;s>=0;s--)(i=a[s])&&(e=(n?i(r,t,e):i(e))||e);return n&&e&&f(r,t,e),e};let o=class extends d{constructor(){super(...arguments),this.label="",this.href="",this.menuId=""}render(){return p`<slot></slot>`}};o.styles=c`
|
|
2
2
|
:host {
|
|
3
3
|
display: none !important;
|
|
4
4
|
}
|
|
5
|
-
`;l([
|
|
5
|
+
`;l([u({type:String})],o.prototype,"label",2);l([u({type:String})],o.prototype,"href",2);l([u({type:String,attribute:"menu-id"})],o.prototype,"menuId",2);o=l([_("scb-header-tab")],o);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as w,n as h,r as g,i as x,x as d,E as u,t as S}from"../../vendor/vendor.js";import"../../vendor/vendor-material.js";import"../scb-grid/scb-grid-item.js";import"../scb-grid/scb-grid.js";import"../scb-link/scb-link.js";import"../scb-icon-button/scb-icon-button.js";import"../scb-button/scb-button.js";import"../scb-search/scb-search.js";import"../scb-drawer/scb-drawer.js";import"../scb-grid/scb-stack.js";import"../../vendor/preload-helper.js";import"../scb-list/scb-list.js";import"../scb-list/scb-list-item.js";import"../scb-divider/scb-divider.js";(function(){try{var e=typeof globalThis<"u"?globalThis:window;if(!e.__scb_ce_guard_installed__){e.__scb_ce_guard_installed__=!0;var t=customElements.define.bind(customElements);customElements.define=function(s,n,i){try{customElements.get(s)||t(s,n,i)}catch(c){var o=String(c||"");if(o.indexOf("already been used")===-1&&o.indexOf("NotSupportedError")===-1)throw c}}}}catch{}})();var C=Object.defineProperty,k=Object.getOwnPropertyDescriptor,a=(e,t,s,n)=>{for(var i=n>1?void 0:n?k(t,s):t,o=e.length-1,c;o>=0;o--)(c=e[o])&&(i=(n?c(t,s,i):c(i))||i);return n&&i&&C(t,s,i),i};const v={fromAttribute:e=>e==null?!0:!/^(false|0|off|no)$/i.test(e),toAttribute:e=>String(!!e)};let r=class extends x{constructor(){super(...arguments),this.maxWidth="1440px",this.logoText="",this.logoHref="/",this.banner=!1,this.tabs=[],this.activeTab=0,this.utilityItems=[],this.showDrawer=!0,this.showSearch=!0,this.includeUtilityInDrawer=!1,this.drawerOverlay=!0,this.searchText="",this._drawerId="main-drawer",this._drawerExpanded=!1,this._searchId="header-search",this._slotTabs=[],this._slotUtils=[],this._slotMenu=[],this._measureScheduled=!1,this._scheduleMeasure=()=>{this._measureScheduled||(this._measureScheduled=!0,requestAnimationFrame(()=>{this._measureScheduled=!1,this._measure()}))},this._onWindowResize=()=>{this._scheduleMeasure()},this._onDrawerSelect=e=>{this.dispatchEvent(new CustomEvent("drawer-select",{detail:e.detail,bubbles:!0,composed:!0})),this._closeDrawerNow()},this._collapsed=!1,this._unlockAtWidth=0,this._hideLogoText=!1,this._logoTextUnlockAt=0,this._harvestPending=!1,this._harvest=()=>{const e=this._slotEl;if(!e)return;const t=e.assignedElements({flatten:!0}),s=[],n=[],i=[];let o=-1;const c=l=>({label:l.getAttribute("label")??"",href:l.getAttribute("href")??void 0,icon:l.getAttribute("icon")??void 0});for(const l of t){const p=l.tagName.toLowerCase();if(p==="scb-header-tab"){const _=l.getAttribute("label")??"",b=l.getAttribute("href"),m=b&&b.trim()!==""?b:void 0;(l.hasAttribute("selected")||l.getAttribute("selected")==="true"||l.getAttribute("active")==="true"||l.getAttribute("aria-current")==="page")&&o===-1&&(o=s.length),s.push({label:_,href:m});continue}if(p==="scb-header-utility"){n.push({label:l.getAttribute("label")??"",href:l.getAttribute("href")??"#",target:l.getAttribute("target")??void 0});continue}if(p==="scb-header-drawer-group"){const _={label:l.getAttribute("label")??"",icon:l.getAttribute("icon")??void 0,children:[]};l.querySelectorAll("scb-header-drawer-item").forEach(m=>_.children.push(c(m))),i.push(_);continue}p==="scb-header-drawer-item"&&i.push(c(l))}this._slotTabs=s,this._slotUtils=n,this._slotMenu=i,!this.hasAttribute("active-tab")&&o>=0&&(this.activeTab=o),queueMicrotask(()=>{this.updateComplete.then(()=>{this._scheduleMeasure()})})},this._measure=()=>{const e=this._top,t=this._logoGroup;if(!e||!t)return;const s=window.innerWidth,n=e.clientWidth,i=this._overflows(this._util),o=this._overflows(this._tabsNav),c=s<this.BP_MD||i||o;this._collapsed?!c&&n>=this._unlockAtWidth&&this._setCollapsed(!1):c&&(this._unlockAtWidth=n+this._HYST,this._setCollapsed(!0));let l=!1;if(this.showSearch&&s>=this.BP_SM&&s<this.BP_MD&&this._searchWrap){const b=getComputedStyle(this._searchWrap),m=Math.max(this._num(b.minWidth,this._tokenPx("--scb-header-search-min",320)),this._tokenPx("--scb-header-search-min",320)),f=this._num(getComputedStyle(e).gap,this._tokenPx("--spacing-7",24)),y=this.showDrawer&&(s<this.BP_MD||this._collapsed)?this._menuBtn?.getBoundingClientRect().width||this._tokenPx("--icon-size-large",48):0;l=t.getBoundingClientRect().width+f+m+f+y+8>n+.5}this._setHideSearch(l);let p=!1;if(this.showDrawer&&(s<this.BP_MD||this._collapsed)&&!this._visible(this._util)&&!this._visible(this._searchWrap)){const b=this._num(getComputedStyle(e).gap,this._tokenPx("--spacing-7",24)),m=this._menuBtn?.getBoundingClientRect().width||this._tokenPx("--icon-size-large",48),f=(this._logoGroup?.getBoundingClientRect().width||0)+b+m;this._hideLogoText?p=!(n>=this._logoTextUnlockAt):f>n+.5&&(p=!0,this._logoTextUnlockAt=n+this._HYST)}else p=!1,this._logoTextUnlockAt=0;this._setHideLogoText(p)},this._onMenuClick=async e=>{e.preventDefault(),e.stopPropagation(),this.showDrawer&&(this.dispatchEvent(new CustomEvent("menu-click",{bubbles:!0,composed:!0})),await r._nextFrame(),await r._nextFrame(),this._openDrawerNow())},this._onSearchClick=e=>{const t=this._searchEl;if(t?.submit&&typeof t.submit=="function"){t.submit();return}const s=t?.value??"";this.searchText=s,this.dispatchEvent(new CustomEvent("search-click",{detail:{value:s},bubbles:!0,composed:!0})),t?.focus?.()},this._onTabClick=e=>{const t=e.currentTarget;if(!t)return;const s=t.tagName.toLowerCase()==="a";if(s&&(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey))return;const n=t.getAttribute("data-index"),i=n!=null?Number(n):0;this.activeTab=i;const l=((this._slotTabs.length?this._slotTabs:this.tabs)[i]??{}).href??"",p=new CustomEvent("tab-change",{detail:{index:i,href:l},bubbles:!0,composed:!0,cancelable:!0});!this.dispatchEvent(p)&&s&&e.preventDefault()},this._onTabsKeydown=e=>{const t=e.key;if(t!=="ArrowLeft"&&t!=="ArrowRight"&&t!=="Home"&&t!=="End")return;const s=Array.from(this.renderRoot.querySelectorAll(".tab-link"));if(!s.length)return;const n=e.target;let i=s.indexOf(n??s[0]);i===-1&&(i=0),t==="ArrowRight"?i=(i+1)%s.length:t==="ArrowLeft"?i=(i-1+s.length)%s.length:t==="Home"?i=0:t==="End"&&(i=s.length-1),e.preventDefault();const o=s[i];o.focus();const c=o.getAttribute("data-index"),l=c!=null?Number(c):i;this.activeTab=l},this._onSearchInput=e=>{this.searchText=e.detail?.value??"",this.dispatchEvent(new CustomEvent("search-input",{detail:{value:this.searchText},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("search-text-change",{detail:{value:this.searchText},bubbles:!0,composed:!0}))},this._onSearchSubmit=e=>{this.searchText=e.detail?.value??"",this.dispatchEvent(new CustomEvent("search-change",{detail:{value:this.searchText,active:e.detail?.active},bubbles:!0,composed:!0}))},this._onSearchClear=()=>{this.searchText="",this.dispatchEvent(new CustomEvent("search-text-change",{detail:{value:""},bubbles:!0,composed:!0}))}}get _HYST(){return this._tokenPx("--spacing-11",64)}get BP_SM(){return this._tokenPx("--bp-sm",r.BP_SM_DEFAULT)}get BP_MD(){return this._tokenPx("--bp-md",r.BP_MD_DEFAULT)}_scheduleHarvest(){this._harvestPending||(this._harvestPending=!0,queueMicrotask(()=>{this._harvestPending=!1,this._harvest()}))}get _slotEl(){return this.shadowRoot?.querySelector("slot#data-slot")??null}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();const e=new MutationObserver(t=>{this._scheduleHarvest()});this._slotMo=e,e.observe(this,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["label","href","icon","target","selected","aria-current","active"]})}_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"))}_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}firstUpdated(){this.updateComplete.then(()=>{this._harvest(),this._attachSlotObservers()});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??"480px"),e.has("searchMin")&&this.style.setProperty("--scb-header-search-min",this.searchMin??"320px"),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("utilityItems")||e.has("tabs")||e.has("logoText")||e.has("activeTab")||e.has("_slotTabs")||e.has("_slotUtils")||e.has("_slotMenu")||e.has("showDrawer")||e.has("showSearch")||e.has("searchMax")||e.has("searchMin"))&&this.updateComplete.then(()=>{this._scheduleMeasure()})}disconnectedCallback(){this._ro?.disconnect(),this._slotMo?.disconnect(),window.removeEventListener("resize",this._onWindowResize),super.disconnectedCallback()}_openDrawerNow(){const e=this.renderRoot.querySelector(`#${this._drawerId}`);e&&(e.open=!0,e.setAttribute("open",""),e.show?.(),e.openDrawer?.(),this._drawerExpanded=!0,this._syncMenuBtnAria(),this.dispatchEvent(new CustomEvent("drawer-open",{bubbles:!0,composed:!0})))}_closeDrawerNow(){const e=this.renderRoot.querySelector(`#${this._drawerId}`);e&&(e.open=!1),this._drawerExpanded=!1,this._syncMenuBtnAria(),this.dispatchEvent(new CustomEvent("drawer-close",{bubbles:!0,composed:!0}))}_syncMenuBtnAria(){const e=this.renderRoot.querySelector(".menu-trigger");e&&e.setAttribute("aria-expanded",String(this._drawerExpanded))}_renderDrawerNodes(e){return!e||e.length===0?d``:d`${e.map(t=>{const s=Array.isArray(t.children)&&t.children.length>0;return d`
|
|
1
|
+
import{a as x,n as h,r as m,i as S,x as d,E as u,t as C}from"../../vendor/vendor.js";import"../../vendor/vendor-material.js";import"../scb-grid/scb-grid-item.js";import"../scb-grid/scb-grid.js";import"../scb-link/scb-link.js";import"../scb-icon-button/scb-icon-button.js";import"../scb-button/scb-button.js";import"../scb-search/scb-search.js";import"../scb-drawer/scb-drawer.js";import"../scb-grid/scb-stack.js";import"../../vendor/preload-helper.js";import"../scb-list/scb-list.js";import"../scb-list/scb-list-item.js";import"../scb-divider/scb-divider.js";(function(){try{var e=typeof globalThis<"u"?globalThis:window;if(!e.__scb_ce_guard_installed__){e.__scb_ce_guard_installed__=!0;var t=customElements.define.bind(customElements);customElements.define=function(s,n,a){try{customElements.get(s)||t(s,n,a)}catch(c){var i=String(c||"");if(i.indexOf("already been used")===-1&&i.indexOf("NotSupportedError")===-1)throw c}}}}catch{}})();var k=Object.defineProperty,$=Object.getOwnPropertyDescriptor,o=(e,t,s,n)=>{for(var a=n>1?void 0:n?$(t,s):t,i=e.length-1,c;i>=0;i--)(c=e[i])&&(a=(n?c(t,s,a):c(a))||a);return n&&a&&k(t,s,a),a};const v={fromAttribute:e=>e==null?!0:!/^(false|0|off|no)$/i.test(e),toAttribute:e=>String(!!e)};let r=class extends S{constructor(){super(...arguments),this.maxWidth="1440px",this.logoText="",this.logoHref="/",this.banner=!1,this.tabs=[],this.activeTab=0,this.utilityItems=[],this.showDrawer=!0,this.showSearch=!0,this.includeUtilityInDrawer=!1,this.drawerOverlay=!0,this.searchText="",this._drawerId="main-drawer",this._drawerExpanded=!1,this._searchId="header-search",this._slotTabs=[],this._slotUtils=[],this._slotMenu=[],this._measureScheduled=!1,this._scheduleMeasure=()=>{this._measureScheduled||(this._measureScheduled=!0,requestAnimationFrame(()=>{this._measureScheduled=!1,this._measure()}))},this._onWindowResize=()=>{this._scheduleMeasure()},this._onDrawerSelect=e=>{this.dispatchEvent(new CustomEvent("drawer-select",{detail:e.detail,bubbles:!0,composed:!0})),this._closeDrawerNow()},this._collapsed=!1,this._unlockAtWidth=0,this._hideLogoText=!1,this._logoTextUnlockAt=0,this._harvestPending=!1,this._harvest=()=>{const e=this._slotEl;if(!e)return;const t=e.assignedElements({flatten:!0}),s=[],n=[],a=[];let i=-1;const c=l=>({label:l.getAttribute("label")??"",href:l.getAttribute("href")??void 0,icon:l.getAttribute("icon")??void 0});for(const l of t){const p=l.tagName.toLowerCase();if(p==="scb-header-tab"){const _=l.getAttribute("label")??"",b=l.getAttribute("href"),f=b&&b.trim()!==""?b:void 0,g=l.getAttribute("menu-id"),y=g&&g.trim()!==""?g:void 0;(l.hasAttribute("selected")||l.getAttribute("selected")==="true"||l.getAttribute("active")==="true"||l.getAttribute("aria-current")==="page")&&i===-1&&(i=s.length),s.push({label:_,href:f,menuId:y});continue}if(p==="scb-header-utility"){n.push({label:l.getAttribute("label")??"",href:l.getAttribute("href")??"#",target:l.getAttribute("target")??void 0});continue}if(p==="scb-header-drawer-group"){const _={label:l.getAttribute("label")??"",icon:l.getAttribute("icon")??void 0,children:[]};l.querySelectorAll("scb-header-drawer-item").forEach(f=>_.children.push(c(f))),a.push(_);continue}p==="scb-header-drawer-item"&&a.push(c(l))}this._slotTabs=s,this._slotUtils=n,this._slotMenu=a,!this.hasAttribute("active-tab")&&i>=0&&(this.activeTab=i),queueMicrotask(()=>{this.updateComplete.then(()=>{this._scheduleMeasure()})})},this._measure=()=>{const e=this._top,t=this._logoGroup;if(!e||!t)return;const s=window.innerWidth,n=e.clientWidth,a=this._overflows(this._util),i=this._overflows(this._tabsNav),c=s<this.BP_MD||a||i;this._collapsed?!c&&n>=this._unlockAtWidth&&this._setCollapsed(!1):c&&(this._unlockAtWidth=n+this._HYST,this._setCollapsed(!0));let l=!1;if(this.showSearch&&s>=this.BP_SM&&s<this.BP_MD&&this._searchWrap){const b=getComputedStyle(this._searchWrap),f=Math.max(this._num(b.minWidth,this._tokenPx("--scb-header-search-min",320)),this._tokenPx("--scb-header-search-min",320)),g=this._num(getComputedStyle(e).gap,this._tokenPx("--spacing-7",24)),y=this.showDrawer&&(s<this.BP_MD||this._collapsed)?this._menuBtn?.getBoundingClientRect().width||this._tokenPx("--icon-size-large",48):0;l=t.getBoundingClientRect().width+g+f+g+y+8>n+.5}this._setHideSearch(l);let p=!1;if(this.showDrawer&&(s<this.BP_MD||this._collapsed)&&!this._visible(this._util)&&!this._visible(this._searchWrap)){const b=this._num(getComputedStyle(e).gap,this._tokenPx("--spacing-7",24)),f=this._menuBtn?.getBoundingClientRect().width||this._tokenPx("--icon-size-large",48),g=(this._logoGroup?.getBoundingClientRect().width||0)+b+f;this._hideLogoText?p=!(n>=this._logoTextUnlockAt):g>n+.5&&(p=!0,this._logoTextUnlockAt=n+this._HYST)}else p=!1,this._logoTextUnlockAt=0;this._setHideLogoText(p)},this._onMenuClick=async e=>{e.preventDefault(),e.stopPropagation(),this.showDrawer&&(this.dispatchEvent(new CustomEvent("menu-click",{bubbles:!0,composed:!0})),await r._nextFrame(),await r._nextFrame(),this._openDrawerNow())},this._onSearchClick=e=>{const t=this._searchEl;if(t?.submit&&typeof t.submit=="function"){t.submit();return}const s=t?.value??"";this.searchText=s,this.dispatchEvent(new CustomEvent("search-click",{detail:{value:s},bubbles:!0,composed:!0})),t?.focus?.()},this._onTabClick=e=>{const t=e.currentTarget;if(!t)return;const s=t.tagName.toLowerCase()==="a";if(s&&(e.defaultPrevented||e.button!==0||e.metaKey||e.ctrlKey||e.shiftKey||e.altKey))return;const n=t.getAttribute("data-index"),a=n!=null?Number(n):0;this.activeTab=a;const c=(this._slotTabs.length?this._slotTabs:this.tabs)[a]??{},l=c.href??"",p=c.menuId??"",_=new CustomEvent("tab-change",{detail:{index:a,href:l,menuId:p},bubbles:!0,composed:!0,cancelable:!0});!this.dispatchEvent(_)&&s&&e.preventDefault()},this._onTabsKeydown=e=>{const t=e.key;if(t!=="ArrowLeft"&&t!=="ArrowRight"&&t!=="Home"&&t!=="End")return;const s=Array.from(this.renderRoot.querySelectorAll(".tab-link"));if(!s.length)return;const n=e.target;let a=s.indexOf(n??s[0]);a===-1&&(a=0),t==="ArrowRight"?a=(a+1)%s.length:t==="ArrowLeft"?a=(a-1+s.length)%s.length:t==="Home"?a=0:t==="End"&&(a=s.length-1),e.preventDefault();const i=s[a];i.focus();const c=i.getAttribute("data-index"),l=c!=null?Number(c):a;this.activeTab=l},this._onSearchInput=e=>{this.searchText=e.detail?.value??"",this.dispatchEvent(new CustomEvent("search-input",{detail:{value:this.searchText},bubbles:!0,composed:!0})),this.dispatchEvent(new CustomEvent("search-text-change",{detail:{value:this.searchText},bubbles:!0,composed:!0}))},this._onSearchSubmit=e=>{this.searchText=e.detail?.value??"",this.dispatchEvent(new CustomEvent("search-change",{detail:{value:this.searchText,active:e.detail?.active},bubbles:!0,composed:!0}))},this._onSearchClear=()=>{this.searchText="",this.dispatchEvent(new CustomEvent("search-text-change",{detail:{value:""},bubbles:!0,composed:!0}))}}get _HYST(){return this._tokenPx("--spacing-11",64)}get BP_SM(){return this._tokenPx("--bp-sm",r.BP_SM_DEFAULT)}get BP_MD(){return this._tokenPx("--bp-md",r.BP_MD_DEFAULT)}_scheduleHarvest(){this._harvestPending||(this._harvestPending=!0,queueMicrotask(()=>{this._harvestPending=!1,this._harvest()}))}get _slotEl(){return this.shadowRoot?.querySelector("slot#data-slot")??null}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();const e=new MutationObserver(t=>{this._scheduleHarvest()});this._slotMo=e,e.observe(this,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["label","href","menu-id","icon","target","selected","aria-current","active"]})}_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"))}_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}firstUpdated(){this.updateComplete.then(()=>{this._harvest(),this._attachSlotObservers()});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??"480px"),e.has("searchMin")&&this.style.setProperty("--scb-header-search-min",this.searchMin??"320px"),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("utilityItems")||e.has("tabs")||e.has("logoText")||e.has("activeTab")||e.has("_slotTabs")||e.has("_slotUtils")||e.has("_slotMenu")||e.has("showDrawer")||e.has("showSearch")||e.has("searchMax")||e.has("searchMin"))&&this.updateComplete.then(()=>{this._scheduleMeasure()})}disconnectedCallback(){this._ro?.disconnect(),this._slotMo?.disconnect(),window.removeEventListener("resize",this._onWindowResize),super.disconnectedCallback()}_openDrawerNow(){const e=this.renderRoot.querySelector(`#${this._drawerId}`);e&&(e.open=!0,e.setAttribute("open",""),e.show?.(),e.openDrawer?.(),this._drawerExpanded=!0,this._syncMenuBtnAria(),this.dispatchEvent(new CustomEvent("drawer-open",{bubbles:!0,composed:!0})))}_closeDrawerNow(){const e=this.renderRoot.querySelector(`#${this._drawerId}`);e&&(e.open=!1),this._drawerExpanded=!1,this._syncMenuBtnAria(),this.dispatchEvent(new CustomEvent("drawer-close",{bubbles:!0,composed:!0}))}_syncMenuBtnAria(){const e=this.renderRoot.querySelector(".menu-trigger");e&&e.setAttribute("aria-expanded",String(this._drawerExpanded))}_renderDrawerNodes(e){return!e||e.length===0?d``:d`${e.map(t=>{const s=Array.isArray(t.children)&&t.children.length>0;return d`
|
|
2
2
|
<scb-drawer-item
|
|
3
3
|
label=${t.label}
|
|
4
4
|
?selected=${!1}
|
|
@@ -17,7 +17,7 @@ import{a as w,n as h,r as g,i as x,x as d,E as u,t as S}from"../../vendor/vendor
|
|
|
17
17
|
</scb-sub-drawer>
|
|
18
18
|
`:u}
|
|
19
19
|
</scb-drawer-item>
|
|
20
|
-
`})}`}_syncFlags(e,t){this.toggleAttribute("data-no-utility",e),this.toggleAttribute("data-no-search",t)}render(){const e=this._slotTabs.length?this._slotTabs:this.tabs,t=this._slotUtils.length?this._slotUtils:this.utilityItems,s=this._slotMenu.length?this._slotMenu:this.menuData??[];this._syncFlags(t.length===0,!this.showSearch);const n=this.searchHeight&&this.searchHeight.trim()?`--scb-search-height:${this.searchHeight.trim()}`:u,
|
|
20
|
+
`})}`}_syncFlags(e,t){this.toggleAttribute("data-no-utility",e),this.toggleAttribute("data-no-search",t)}render(){const e=this._slotTabs.length?this._slotTabs:this.tabs,t=this._slotUtils.length?this._slotUtils:this.utilityItems,s=this._slotMenu.length?this._slotMenu:this.menuData??[];this._syncFlags(t.length===0,!this.showSearch);const n=this.searchHeight&&this.searchHeight.trim()?`--scb-search-height:${this.searchHeight.trim()}`:u,a=e.length>0;return d`
|
|
21
21
|
<slot
|
|
22
22
|
id="data-slot"
|
|
23
23
|
@slotchange=${()=>{this._harvest(),this._attachSlotObservers()}}
|
|
@@ -56,11 +56,11 @@ import{a as w,n as h,r as g,i as x,x as d,E as u,t as S}from"../../vendor/vendor
|
|
|
56
56
|
|
|
57
57
|
<div class="actions">
|
|
58
58
|
<nav class="utility" aria-label="Funktionslänkar">
|
|
59
|
-
${t.map(
|
|
59
|
+
${t.map(i=>d`
|
|
60
60
|
<scb-link
|
|
61
|
-
.href=${
|
|
62
|
-
.target=${
|
|
63
|
-
>${
|
|
61
|
+
.href=${i.href}
|
|
62
|
+
.target=${i.target??void 0}
|
|
63
|
+
>${i.label}</scb-link
|
|
64
64
|
>
|
|
65
65
|
`)}
|
|
66
66
|
</nav>
|
|
@@ -108,23 +108,40 @@ import{a as w,n as h,r as g,i as x,x as d,E as u,t as S}from"../../vendor/vendor
|
|
|
108
108
|
col-span-medium="8"
|
|
109
109
|
col-span-expanded="12"
|
|
110
110
|
>
|
|
111
|
-
${
|
|
111
|
+
${a?d`
|
|
112
112
|
<div class="tabs-inset">
|
|
113
113
|
<nav
|
|
114
114
|
class="tabs-nav"
|
|
115
115
|
aria-label="Huvudnavigering"
|
|
116
116
|
@keydown=${this._onTabsKeydown}
|
|
117
117
|
>
|
|
118
|
-
${e.map((
|
|
118
|
+
${e.map((i,c)=>i.menuId?d`
|
|
119
|
+
<div class="tab-wrap">
|
|
120
|
+
<button
|
|
121
|
+
type="button"
|
|
122
|
+
class="tab-link"
|
|
123
|
+
data-index=${c}
|
|
124
|
+
aria-controls=${i.menuId}
|
|
125
|
+
aria-haspopup="menu"
|
|
126
|
+
aria-expanded="false"
|
|
127
|
+
data-menu-toggle=${i.menuId}
|
|
128
|
+
aria-current=${c===this.activeTab?"page":u}
|
|
129
|
+
@click=${this._onTabClick}
|
|
130
|
+
>
|
|
131
|
+
${i.label}
|
|
132
|
+
</button>
|
|
133
|
+
<md-focus-ring></md-focus-ring>
|
|
134
|
+
</div>
|
|
135
|
+
`:i.href?d`
|
|
119
136
|
<div class="tab-wrap">
|
|
120
137
|
<a
|
|
121
138
|
class="tab-link"
|
|
122
|
-
href=${
|
|
139
|
+
href=${i.href}
|
|
123
140
|
data-index=${c}
|
|
124
141
|
aria-current=${c===this.activeTab?"page":u}
|
|
125
142
|
@click=${this._onTabClick}
|
|
126
143
|
>
|
|
127
|
-
${
|
|
144
|
+
${i.label}
|
|
128
145
|
</a>
|
|
129
146
|
<md-focus-ring></md-focus-ring>
|
|
130
147
|
</div>
|
|
@@ -137,7 +154,7 @@ import{a as w,n as h,r as g,i as x,x as d,E as u,t as S}from"../../vendor/vendor
|
|
|
137
154
|
aria-current=${c===this.activeTab?"page":u}
|
|
138
155
|
@click=${this._onTabClick}
|
|
139
156
|
>
|
|
140
|
-
${
|
|
157
|
+
${i.label}
|
|
141
158
|
</button>
|
|
142
159
|
<md-focus-ring></md-focus-ring>
|
|
143
160
|
</div>
|
|
@@ -179,10 +196,10 @@ import{a as w,n as h,r as g,i as x,x as d,E as u,t as S}from"../../vendor/vendor
|
|
|
179
196
|
|
|
180
197
|
${this.includeUtilityInDrawer&&(t?.length??0)>0?d`
|
|
181
198
|
<scb-drawer-section label=''></scb-drawer-section>
|
|
182
|
-
${t.map(
|
|
199
|
+
${t.map(i=>d`
|
|
183
200
|
<scb-drawer-item
|
|
184
|
-
label=${
|
|
185
|
-
item-href=${
|
|
201
|
+
label=${i.label}
|
|
202
|
+
item-href=${i.href}
|
|
186
203
|
></scb-drawer-item>
|
|
187
204
|
`)}
|
|
188
205
|
`:u}
|
|
@@ -222,7 +239,7 @@ import{a as w,n as h,r as g,i as x,x as d,E as u,t as S}from"../../vendor/vendor
|
|
|
222
239
|
</clipPath>
|
|
223
240
|
</defs>
|
|
224
241
|
</svg>
|
|
225
|
-
`}};r._JSON_ARRAY={fromAttribute:e=>{if(e==null||e==="")return[];try{const t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}},toAttribute:e=>e==null?null:JSON.stringify(e)};r.BP_SM_DEFAULT=600;r.BP_MD_DEFAULT=840;r.styles=
|
|
242
|
+
`}};r._JSON_ARRAY={fromAttribute:e=>{if(e==null||e==="")return[];try{const t=JSON.parse(e);return Array.isArray(t)?t:[]}catch{return[]}},toAttribute:e=>e==null?null:JSON.stringify(e)};r.BP_SM_DEFAULT=600;r.BP_MD_DEFAULT=840;r.styles=x`
|
|
226
243
|
:host {
|
|
227
244
|
display: block;
|
|
228
245
|
background: var(--scb-header-background, transparent);
|
|
@@ -486,4 +503,4 @@ import{a as w,n as h,r as g,i as x,x as d,E as u,t as S}from"../../vendor/vendor
|
|
|
486
503
|
:host([data-hide-logo-text]) .logo-text {
|
|
487
504
|
display: none;
|
|
488
505
|
}
|
|
489
|
-
`;r._nextFrame=()=>new Promise(e=>requestAnimationFrame(()=>e()));
|
|
506
|
+
`;r._nextFrame=()=>new Promise(e=>requestAnimationFrame(()=>e()));o([h({type:String,attribute:"max-width"})],r.prototype,"maxWidth",2);o([h({type:String,attribute:"logo-text"})],r.prototype,"logoText",2);o([h({type:String,attribute:"logo-href"})],r.prototype,"logoHref",2);o([h({type:Boolean,reflect:!0})],r.prototype,"banner",2);o([h({type:String,attribute:"banner-label"})],r.prototype,"bannerLabel",2);o([h({attribute:"tabs",converter:r._JSON_ARRAY})],r.prototype,"tabs",2);o([h({type:Number,attribute:"active-tab"})],r.prototype,"activeTab",2);o([h({attribute:"utility-items",converter:r._JSON_ARRAY})],r.prototype,"utilityItems",2);o([h({type:String,attribute:"search-placeholder"})],r.prototype,"searchPlaceholder",2);o([h({type:String,attribute:"drawer-label"})],r.prototype,"drawerLabel",2);o([h({type:String,attribute:"drawer-sub-label"})],r.prototype,"drawerSubLabel",2);o([h({type:String,attribute:"drawer-section-label"})],r.prototype,"drawerSectionLabel",2);o([h({type:String,attribute:"drawer-search-placeholder"})],r.prototype,"drawerSearchPlaceholder",2);o([h({attribute:"menu-data",converter:r._JSON_ARRAY})],r.prototype,"menuData",2);o([h({attribute:"show-drawer",reflect:!0,converter:v})],r.prototype,"showDrawer",2);o([h({attribute:"show-search",reflect:!0,converter:v})],r.prototype,"showSearch",2);o([h({attribute:"include-utility-in-drawer",reflect:!0,converter:v})],r.prototype,"includeUtilityInDrawer",2);o([h({attribute:"drawer-overlay",reflect:!0,converter:v})],r.prototype,"drawerOverlay",2);o([h({type:String,attribute:"search-max"})],r.prototype,"searchMax",2);o([h({type:String,attribute:"search-min"})],r.prototype,"searchMin",2);o([h({type:String,attribute:"search-height"})],r.prototype,"searchHeight",2);o([h({type:String,attribute:"search-text",reflect:!0})],r.prototype,"searchText",2);o([m()],r.prototype,"_drawerId",2);o([m()],r.prototype,"_drawerExpanded",2);o([m()],r.prototype,"_searchId",2);o([m()],r.prototype,"_slotTabs",2);o([m()],r.prototype,"_slotUtils",2);o([m()],r.prototype,"_slotMenu",2);o([m()],r.prototype,"_collapsed",2);o([m()],r.prototype,"_hideLogoText",2);r=o([C("scb-header")],r);
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import{a as
|
|
1
|
+
import{a as f,n as m,i as b,x as v,t as E}from"../../vendor/vendor.js";import"./scb-menu-item.js";import"./scb-sub-menu.js";import"../scb-divider/scb-divider.js";import"../../vendor/vendor-material.js";(function(){try{var t=typeof globalThis<"u"?globalThis:window;if(!t.__scb_ce_guard_installed__){t.__scb_ce_guard_installed__=!0;var i=customElements.define.bind(customElements);customElements.define=function(e,s,o){try{customElements.get(e)||i(e,s,o)}catch(n){var r=String(n||"");if(r.indexOf("already been used")===-1&&r.indexOf("NotSupportedError")===-1)throw n}}}}catch{}})();var w=Object.defineProperty,y=Object.getOwnPropertyDescriptor,u=(t,i,e,s)=>{for(var o=s>1?void 0:s?y(i,e):i,r=t.length-1,n;r>=0;r--)(n=t[r])&&(o=(s?n(i,e,o):n(o))||o);return s&&o&&w(i,e,o),o};let c=class extends b{constructor(){super(...arguments),this.open=!1,this.inSb=!1,this.__lastTriggerEl=null,this.__onViewportChange=()=>{this.open&&this.__positionToTrigger()},this.__onDocumentClick=t=>{const i=this.__getActionFromEvent(t);if(i){i==="open"&&(this.__setOpen(!0),this.dispatchEvent(new CustomEvent("open",{bubbles:!0,composed:!0}))),i==="close"&&(this.__setOpen(!1),this.dispatchEvent(new CustomEvent("close",{bubbles:!0,composed:!0}))),i==="toggle"&&(this.__setOpen(!this.open),this.dispatchEvent(new CustomEvent("toggle",{bubbles:!0,composed:!0}))),t.stopPropagation();return}if(!this.inSb&&this.open&&!this.isClickInScbMenu(t)){this.__setOpen(!1);return}},this.__onDocumentKeydown=t=>{if(this.open&&t.key==="Escape"){this.__setOpen(!1);return}}}render(){return v`
|
|
2
2
|
<div
|
|
3
3
|
role="menu"
|
|
4
4
|
class="scb-menu-panel${this.open?" open":""}"
|
|
5
5
|
>
|
|
6
6
|
<slot></slot>
|
|
7
7
|
</div>
|
|
8
|
-
`}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this.__onDocumentClick,!1),document.addEventListener("keydown",this.__onDocumentKeydown,!0)}disconnectedCallback(){document.removeEventListener("click",this.__onDocumentClick,!1),document.removeEventListener("keydown",this.__onDocumentKeydown,!0),super.disconnectedCallback()}__setOpen(t){this.open=t}__getActionFromEvent(t){if(!this.id)return null;const
|
|
8
|
+
`}connectedCallback(){super.connectedCallback(),document.addEventListener("click",this.__onDocumentClick,!1),document.addEventListener("keydown",this.__onDocumentKeydown,!0),window.addEventListener("resize",this.__onViewportChange,{passive:!0}),window.addEventListener("scroll",this.__onViewportChange,{passive:!0,capture:!0})}disconnectedCallback(){document.removeEventListener("click",this.__onDocumentClick,!1),document.removeEventListener("keydown",this.__onDocumentKeydown,!0),window.removeEventListener("resize",this.__onViewportChange),window.removeEventListener("scroll",this.__onViewportChange,!0),super.disconnectedCallback()}__setOpen(t){this.open=t}__getActionFromEvent(t){if(!this.id)return null;const i=t.composedPath();for(const e of i)if(e instanceof Element){if(e.getAttribute("data-menu-open")===this.id)return this.__lastTriggerEl=e,"open";if(e.getAttribute("data-menu-close")===this.id)return this.__lastTriggerEl=e,"close";if(e.getAttribute("data-menu-toggle")===this.id)return this.__lastTriggerEl=e,"toggle";if(e.getAttribute("aria-controls")===this.id)return this.__lastTriggerEl=e,"toggle"}return null}isClickInScbMenu(t){return t.composedPath().some(e=>e instanceof Element&&(e.tagName==="SCB-MENU"||e.tagName==="SCB-SUB-MENU"))}updated(t){t.has("open")&&(this.__applyOpenSideEffects(),this.open?this.dispatchEvent(new CustomEvent("open",{bubbles:!0,composed:!0})):this.dispatchEvent(new CustomEvent("close",{bubbles:!0,composed:!0})))}__applyOpenSideEffects(){this.__updateTriggersExpanded(),this.open?this.__positionToTrigger():this.__restoreFocusToTrigger()}__positionToTrigger(){if(!this.open||!this.__lastTriggerEl)return;const t=this.__lastTriggerEl,i=this.shadowRoot?.querySelector(".scb-menu-panel");i&&requestAnimationFrame(()=>{if(!this.open)return;const e=t.getBoundingClientRect(),s=i.getBoundingClientRect(),o=window.innerWidth,r=window.innerHeight,n=8,p=4;let a=e.left,l=e.bottom+p;const h=s.width,d=s.height;a+h>o-n&&(a=Math.max(n,o-n-h)),a<n&&(a=n);let _="top";if(l+d>r-n){const g=e.top-p-d;g>=n&&(l=g,_="bottom")}this.style.position="fixed",this.style.left=`${Math.round(a)}px`,this.style.top=`${Math.round(l)}px`,this.style.setProperty("--scb-menu-transform-origin",_)})}__restoreFocusToTrigger(){this.__lastTriggerEl&&requestAnimationFrame(()=>{this.__lastTriggerEl?.focus?.()})}__updateTriggersExpanded(){if(!this.id)return;const t=String(this.open),i=s=>{s.getAttribute("aria-controls")===this.id&&s.setAttribute("aria-expanded",t)};this.__lastTriggerEl&&i(this.__lastTriggerEl),document.querySelectorAll(`[aria-controls="${this.id}"], [data-menu-open="${this.id}"], [data-menu-close="${this.id}"], [data-menu-toggle="${this.id}"]`).forEach(i)}};c.styles=f`
|
|
9
9
|
:host {
|
|
10
10
|
position: absolute;
|
|
11
11
|
display: block;
|
|
@@ -25,7 +25,7 @@ import{a as u,n as l,i as p,x as d,t as h}from"../../vendor/vendor.js";import"./
|
|
|
25
25
|
opacity: 0;
|
|
26
26
|
max-height: 0;
|
|
27
27
|
transform: scaleY(0.8);
|
|
28
|
-
transform-origin: top;
|
|
28
|
+
transform-origin: var(--scb-menu-transform-origin, top);
|
|
29
29
|
transition:
|
|
30
30
|
opacity 0.25s cubic-bezier(0.23, 1, 0.32, 1),
|
|
31
31
|
transform 0.32s cubic-bezier(0.23, 1, 0.32, 1);
|
|
@@ -43,4 +43,4 @@ import{a as u,n as l,i as p,x as d,t as h}from"../../vendor/vendor.js";import"./
|
|
|
43
43
|
opacity 0.25s cubic-bezier(0.23, 1, 0.32, 1),
|
|
44
44
|
transform 0.32s cubic-bezier(0.23, 1, 0.32, 1);
|
|
45
45
|
}
|
|
46
|
-
`;
|
|
46
|
+
`;u([m({type:Boolean,reflect:!0})],c.prototype,"open",2);u([m({type:Boolean,attribute:!1})],c.prototype,"inSb",2);c=u([E("scb-menu")],c);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "scb-wc-test",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.143",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"module": "index.js",
|
|
@@ -365,5 +365,5 @@
|
|
|
365
365
|
},
|
|
366
366
|
"./mvc/*": "./mvc/*"
|
|
367
367
|
},
|
|
368
|
-
"buildHash": "
|
|
368
|
+
"buildHash": "EBCE4DBE9E07D49B0968D6B07598A59100964767487AC429CE773A08005F70AE"
|
|
369
369
|
}
|
|
@@ -1,31 +1,34 @@
|
|
|
1
|
-
import { css as
|
|
2
|
-
import { property as
|
|
3
|
-
var
|
|
4
|
-
for (var e = s > 1 ? void 0 : s ?
|
|
5
|
-
(l =
|
|
6
|
-
return s && e &&
|
|
1
|
+
import { css as a, LitElement as u, html as b } from "lit";
|
|
2
|
+
import { property as i, customElement as c } from "lit/decorators.js";
|
|
3
|
+
var f = Object.defineProperty, h = Object.getOwnPropertyDescriptor, o = (m, r, p, s) => {
|
|
4
|
+
for (var e = s > 1 ? void 0 : s ? h(r, p) : r, n = m.length - 1, l; n >= 0; n--)
|
|
5
|
+
(l = m[n]) && (e = (s ? l(r, p, e) : l(e)) || e);
|
|
6
|
+
return s && e && f(r, p, e), e;
|
|
7
7
|
};
|
|
8
|
-
let t = class extends
|
|
8
|
+
let t = class extends u {
|
|
9
9
|
constructor() {
|
|
10
|
-
super(...arguments), this.label = "", this.href = "";
|
|
10
|
+
super(...arguments), this.label = "", this.href = "", this.menuId = "";
|
|
11
11
|
}
|
|
12
12
|
render() {
|
|
13
|
-
return
|
|
13
|
+
return b`<slot></slot>`;
|
|
14
14
|
}
|
|
15
15
|
};
|
|
16
|
-
t.styles =
|
|
16
|
+
t.styles = a`
|
|
17
17
|
:host {
|
|
18
18
|
display: none !important;
|
|
19
19
|
}
|
|
20
20
|
`;
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
o([
|
|
22
|
+
i({ type: String })
|
|
23
23
|
], t.prototype, "label", 2);
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
o([
|
|
25
|
+
i({ type: String })
|
|
26
26
|
], t.prototype, "href", 2);
|
|
27
|
-
|
|
28
|
-
|
|
27
|
+
o([
|
|
28
|
+
i({ type: String, attribute: "menu-id" })
|
|
29
|
+
], t.prototype, "menuId", 2);
|
|
30
|
+
t = o([
|
|
31
|
+
c("scb-header-tab")
|
|
29
32
|
], t);
|
|
30
33
|
export {
|
|
31
34
|
t as ScbHeaderTab
|