@taprootio/espalier 6.10.0 → 6.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/custom-elements.json +13361 -12999
- package/dist/header/esp-header.d.ts +29 -2
- package/dist/header/esp-header.js +137 -25
- package/dist/menu/esp-menu-group.d.ts +2 -2
- package/dist/menu/esp-menu-group.js +51 -39
- package/dist/menu/esp-menu-item.d.ts +15 -0
- package/dist/menu/esp-menu-item.js +30 -8
- package/dist/menu/esp-menu.d.ts +3 -2
- package/dist/menu/esp-menu.js +68 -51
- package/dist/menu/menu-presentation.js +36 -0
- package/dist/radio-button/esp-radio-button-group.d.ts +4 -1
- package/dist/radio-button/esp-radio-button-group.js +5 -5
- package/dist/radio-button/esp-radio-button.d.ts +3 -1
- package/dist/radio-button/esp-radio-button.js +6 -6
- package/dist/shared/popover-controller.js +1 -1
- package/dist/tree/esp-tree.d.ts +2 -0
- package/dist/tree/esp-tree.js +13 -13
- package/package.json +1 -1
|
@@ -130,6 +130,31 @@ export interface EspThemeToggleEventDetail {
|
|
|
130
130
|
* </esp-header>
|
|
131
131
|
* ```
|
|
132
132
|
*
|
|
133
|
+
* To place a link beside the header controls, set `header-end` on a direct
|
|
134
|
+
* linked `esp-menu-item` in the primary horizontal menu. Keep the full tree in
|
|
135
|
+
* that menu: inline end links precede the action slot, while auto and forced
|
|
136
|
+
* drawers combine every item in its original order. Nested items, groups and
|
|
137
|
+
* items without a URL retain their ordinary presentation. Explicit Inline
|
|
138
|
+
* keeps both navigation regions reachable and overrides the minimal layout.
|
|
139
|
+
* Every owned primary horizontal menu stays on one nonwrapping row, including
|
|
140
|
+
* menus without end links. Its viewport scrolls when constrained; standalone
|
|
141
|
+
* menus retain their own overflow choices.
|
|
142
|
+
*
|
|
143
|
+
* Put shared navigation styling on the header or a common ancestor. Promoted
|
|
144
|
+
* links inherit that context and forward menu/item inline public presentation
|
|
145
|
+
* tokens and explicit typography. Source-only stylesheet selectors, local
|
|
146
|
+
* context/intent zones and non-public variables are not forwarded. Unmarked
|
|
147
|
+
* links keep their native source styling.
|
|
148
|
+
*
|
|
149
|
+
* ```html
|
|
150
|
+
* <esp-header brand-text="Example" menu-display="auto">
|
|
151
|
+
* <esp-menu slot="menu" mode="horizontal">
|
|
152
|
+
* <esp-menu-item label="Join the waitlist" url="/waitlist"></esp-menu-item>
|
|
153
|
+
* <esp-menu-item header-end label="Sign in" url="/sign-in"></esp-menu-item>
|
|
154
|
+
* </esp-menu>
|
|
155
|
+
* </esp-header>
|
|
156
|
+
* ```
|
|
157
|
+
*
|
|
133
158
|
* Published-site headers can be configured without custom brand
|
|
134
159
|
* markup. Pair `layout`, `menu-display`, `theme-toggle`, and
|
|
135
160
|
* `scroll-behavior` with `esp-page header-position` when the shell
|
|
@@ -252,7 +277,8 @@ export declare class EspalierHeader extends EspalierElementBase {
|
|
|
252
277
|
* and centers the navigation on the bar between two equal columns.
|
|
253
278
|
* - `extended` puts navigation on a second row on wide screens.
|
|
254
279
|
* - `extended-centered` centers the brand and second-row navigation.
|
|
255
|
-
* - `minimal` keeps only brand/actions inline and uses the drawer menu
|
|
280
|
+
* - `minimal` keeps only brand/actions inline and uses the drawer menu unless
|
|
281
|
+
* `menu-display="inline"` explicitly requests standard inline geometry.
|
|
256
282
|
*
|
|
257
283
|
* ```html
|
|
258
284
|
* <div style="display: grid; gap: var(--esp-size-padding);">
|
|
@@ -359,7 +385,8 @@ export declare class EspalierHeader extends EspalierElementBase {
|
|
|
359
385
|
/**
|
|
360
386
|
* Navigation display intent. `auto` tries inline navigation before
|
|
361
387
|
* using a drawer, `drawer` always uses the burger/drawer pattern,
|
|
362
|
-
* and `inline`
|
|
388
|
+
* and `inline` keeps the primary horizontal navigation on one scrolling row
|
|
389
|
+
* without creating a burger. Explicit `inline` overrides the minimal layout.
|
|
363
390
|
* @default "auto"
|
|
364
391
|
*/
|
|
365
392
|
menuDisplay: HeaderMenuDisplay;
|
|
@@ -1,41 +1,58 @@
|
|
|
1
|
-
var a=function(h,e,t,o){var r=arguments.length,i=r<3?e:o===null?o=Object.getOwnPropertyDescriptor(e,t):o,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(h,e,t,o);else for(var d=h.length-1;d>=0;d--)(n=h[d])&&(i=(r<3?n(i):r>3?n(e,t,i):n(e,t))||i);return r>3&&i&&Object.defineProperty(e,t,i),i};import{paintedSurface as k}from"../shared/surface-layer.js";import{css as A,html as x,nothing as T}from"lit";import{customElement as _,property as l,state as c}from"lit/decorators.js";import{classMap as O}from"lit/directives/class-map.js";import{styleMap as R}from"lit/directives/style-map.js";import"../burger/esp-burger.js";import{createRef as C,ref as D}from"lit/directives/ref.js";import{EspalierMenu as p}from"../menu/esp-menu.js";import{RafThrottle as E}from"../shared/raf-throttle.js";import{viewportSize as z}from"../shared/viewport.js";import{CONFIGURED_BRAND_LOGO_ASPECT_RATIO as H,configuredBrandLogoGeometry as P,renderConfiguredBrand as j,resolveConfiguredBrand as M}from"../shared/configured-brand.js";import{EspalierElementBase as L}from"../shared/esp-element-base.js";import{ESP_EVENTS as V}from"../shared/events.js";const N="(max-width: 36rem)";function u(h,e){const t=new Set(h);return{allowedValues:t,converter:{fromAttribute(r){return r??e},toAttribute(r){return t.has(r)?r:e}},defaultValue:e}}const q=["standard","centered-brand","centered-menu","extended","extended-centered","minimal"],U=["start","center","end"],$=["truncate","wrap","nowrap"],F=["auto","inline","drawer"],W=["hidden","visible"],g=u(q,"standard"),b=u(U,"start"),f=u($,"truncate"),v=u(F,"auto"),w=u(W,"hidden");let s=class extends L{constructor(){super(...arguments),this.menuOpen=!1,this.menuTooLarge=!1,this.mobileMenu=!1,this.scrolled=!1,this.hiddenByScroll=!1,this.scrollProgress=0,this.showBurger=!1,this.layout=g.defaultValue,this.brandText="",this.brandLogo="",this.lightBrandLogo="",this.darkBrandLogo="",this.brandHref="",this.brandAlt="",this.brandColor="",this.lightBrandColor="",this.darkBrandColor="",this.brandAlign=b.defaultValue,this.brandWrap=f.defaultValue,this.menuDisplay=v.defaultValue,this.themeToggle=w.defaultValue,this.scrollBehavior="none",this.scrollThreshold=16,this.dockOffset=0,this.drawerTarget="",this.previewCollapseRequested=!1,this.fullBleedContent=!1,this.menuContainer=C(),this.menuButton=C(),this.menu=void 0,this.externalDrawerTarget=null,this.lastScrollY=0,this.lastInlineMenuWidth=0,this.mobileMenuQuery=null,this.menuDrawerListenersAttached=!1,this.observingMenuContainer=!1,this.scrollListenersAttached=!1,this.scrollFrame=new E(()=>this.runScrollStateUpdate()),this.resizeObserver=new ResizeObserver(()=>this.syncMenuLayout()),this.menuChildObserver=null,this.updateScrollState=()=>this.scrollFrame.schedule(),this.handleMobileMenuQueryChange=e=>{this.mobileMenu=e.matches,this.syncMenuLayout(),this.syncExternalDrawerControl()},this.toggleTheme=()=>{const e=this.getThemeRoot();if(!e)return;e.scheme=e.scheme==="dark"?"light":"dark";const t=e.scheme==="dark"?"dark":"light";this.dispatchEvent(new CustomEvent(V.HEADER_THEME_TOGGLE,{detail:{scheme:t},bubbles:!0,composed:!0}))},this.handleMenuToggleClicked=()=>{if(this.menuOpen){this.closeNav();return}this.openNav()},this.onMenuDrawerOpened=()=>{this.menuOpen=!0,document.body.classList.add("menu-open"),this.burger&&(this.burger.menuOpen=!0)},this.onMenuDrawerClosed=()=>{this.menuOpen=!1,document.body.classList.remove("menu-open"),this.burger&&(this.burger.menuOpen=!1),this.demoteMenuToggle()},this.onMenuDrawerPresented=e=>{e.target!==this.menu||!this.menu?.isFullScreenDrawer||this.promoteMenuToggle()},this.menuTogglePromoted=!1,this.promotedToggleFrame=new E(()=>this.positionPromotedToggle()),this.handlePromotedViewportResize=()=>this.promotedToggleFrame.schedule(),this.lastDrawerBrandKey="",this.inertedHeaderChrome=[]}syncMenuLayout(){if(!this.menuContainer.value||!this.menu||!this.menu.getWidth)return;this.positionPromotedToggle();const e=this.menu.getWidth();e>0&&(this.lastInlineMenuWidth=e);const t=this.lastInlineMenuWidth||e,o=this.getExternalDrawerTarget(),r=this.menuDisplay!=="inline",i=this.showBurger||this.menuDisplay==="drawer"||this.layout==="minimal"||this.previewCollapseRequested,n=r&&this.menuDisplay==="auto",d=n?this.layout==="centered-menu"?this.centeredMenuCapacity():this.menuContainer.value.clientWidth:0;this.menuTooLarge=n&&t>d,this.menu.sliding=r&&!o&&this.hasDrawerableContent()&&(this.menuTooLarge||i||this.mobileMenu)}centeredMenuCapacity(){const e=this.menuContainer.value?.parentElement;if(!(e instanceof HTMLElement))return 0;const t=d=>d?d.getBoundingClientRect().width:0,o=getComputedStyle(e),r=e.clientWidth-(Number.parseFloat(o.paddingLeft)||0)-(Number.parseFloat(o.paddingRight)||0),i=e.querySelector(":scope > section.brand"),n=e.querySelector(":scope > section.buttons");return r-t(i)-t(n)+t(n?.querySelector("esp-header-button.menu-toggle"))}menuHasContent(){return!!(this.menu??this.querySelector(':scope > [slot="menu"]'))?.querySelector("esp-menu-item, esp-menu-group")}hasDrawerableContent(){return this.showBurger||!!this.getExternalDrawerTarget()||this.menuHasContent()}getExternalDrawerTarget(){if(!this.drawerTarget)return null;const e=document.getElementById(this.drawerTarget);return e===this.menu?null:e&&"openDrawer"in e&&typeof e.openDrawer=="function"&&"closeDrawer"in e&&typeof e.closeDrawer=="function"?e:null}getBurgerFocusTarget(){const t=this.shadowRoot?.querySelector("esp-header-button.menu-toggle")?.shadowRoot?.querySelector("button"),o=this.menuButton.value?.shadowRoot?.querySelector("button");return t??o??null}getScrollTokens(){const e=this.scrollBehavior.split(/\s+/).map(t=>t.trim().toLowerCase()).filter(Boolean);return new Set(e.filter(t=>t!=="none"))}getEffectiveScrollThreshold(){return Number.isFinite(this.scrollThreshold)?Math.max(0,this.scrollThreshold):0}clearScrollState(){this.scrolled=!1,this.hiddenByScroll=!1,this.scrollProgress=0}runScrollStateUpdate(){const e=this.getScrollTokens();if(!e.size){this.clearScrollState();return}const t=Math.max(0,window.scrollY||document.documentElement.scrollTop||0),o=this.getEffectiveScrollThreshold(),r=Number.isFinite(this.dockOffset)?Math.max(0,this.dockOffset):o,i=t>(e.has("dock")?r:o),n=t>this.lastScrollY,d=e.has("reveal")&&n&&t>o&&!this.menuOpen;if(this.scrolled=i,this.hiddenByScroll=d,e.has("progress")){const m=document.documentElement,y=Math.max(1,m.scrollHeight-window.innerHeight);this.scrollProgress=Math.min(1,t/y)}else this.scrollProgress=0;this.lastScrollY=t}cancelScrollUpdate(){this.scrollFrame.cancel()}syncScrollListeners(){const e=this.getScrollTokens().size>0;if(e&&!this.scrollListenersAttached?(window.addEventListener("scroll",this.updateScrollState,{passive:!0}),window.addEventListener("resize",this.updateScrollState,{passive:!0}),this.scrollListenersAttached=!0):!e&&this.scrollListenersAttached&&this.removeScrollListeners(),e){this.updateScrollState();return}this.cancelScrollUpdate(),this.clearScrollState()}removeScrollListeners(){this.scrollListenersAttached&&(window.removeEventListener("scroll",this.updateScrollState),window.removeEventListener("resize",this.updateScrollState),this.scrollListenersAttached=!1)}addMenuDrawerListeners(){!this.menu||this.menuDrawerListenersAttached||(this.menu.addEventListener("esp-menu-drawer-opened",this.onMenuDrawerOpened),this.menu.addEventListener("esp-menu-drawer-presented",this.onMenuDrawerPresented),this.menu.addEventListener("esp-menu-drawer-closed",this.onMenuDrawerClosed),this.menuDrawerListenersAttached=!0)}removeMenuDrawerListeners(){!this.menu||!this.menuDrawerListenersAttached||(this.menu.removeEventListener("esp-menu-drawer-opened",this.onMenuDrawerOpened),this.menu.removeEventListener("esp-menu-drawer-presented",this.onMenuDrawerPresented),this.menu.removeEventListener("esp-menu-drawer-closed",this.onMenuDrawerClosed),this.menuDrawerListenersAttached=!1)}observeMenuContainer(){if(!this.menuContainer.value||this.observingMenuContainer)return;this.resizeObserver.observe(this.menuContainer.value);const e=this.menuContainer.value.parentElement;if(e){this.resizeObserver.observe(e);for(const t of e.querySelectorAll(":scope > section.brand, :scope > section.buttons"))this.resizeObserver.observe(t)}this.observingMenuContainer=!0}disconnectResizeObserver(){this.observingMenuContainer&&(this.resizeObserver.disconnect(),this.observingMenuContainer=!1)}observeMenuChildren(){!this.menu||this.menuChildObserver||(this.menuChildObserver=new MutationObserver(()=>{this.syncMenuLayout(),this.requestUpdate()}),this.menuChildObserver.observe(this.menu,{childList:!0,subtree:!0}))}syncMobileMenuQuery(){if("matchMedia"in window){if(!this.mobileMenuQuery){this.mobileMenuQuery=window.matchMedia(N),this.mobileMenu=this.mobileMenuQuery.matches,this.mobileMenuQuery.addEventListener("change",this.handleMobileMenuQueryChange);return}this.mobileMenu=this.mobileMenuQuery.matches}}getThemeRoot(){return this.traverseToClosest("esp-root")}syncExternalDrawerTarget(){const e=this.getExternalDrawerTarget(),t=e===this.menu?null:e;t!==this.externalDrawerTarget&&(this.externalDrawerTarget?.removeEventListener("esp-menu-drawer-opened",this.onMenuDrawerOpened),this.externalDrawerTarget?.removeEventListener("esp-menu-drawer-closed",this.onMenuDrawerClosed),this.externalDrawerTarget instanceof p&&(this.externalDrawerTarget.hasExternalDrawerControl=!1),this.externalDrawerTarget=t,this.externalDrawerTarget?.addEventListener("esp-menu-drawer-opened",this.onMenuDrawerOpened),this.externalDrawerTarget?.addEventListener("esp-menu-drawer-closed",this.onMenuDrawerClosed)),this.syncExternalDrawerControl()}burgerVisibleForTarget(){if(this.menuDisplay==="inline")return!1;const e=this.showBurger||this.menuDisplay==="drawer"||this.layout==="minimal"||this.previewCollapseRequested;return this.menuTooLarge||this.mobileMenu||e}syncExternalDrawerControl(){this.externalDrawerTarget instanceof p&&(this.externalDrawerTarget.hasExternalDrawerControl=this.burgerVisibleForTarget())}openNav(){const e=this.getBurgerFocusTarget(),t=this.getExternalDrawerTarget();if(this.burger&&(this.burger.menuOpen=!0),t){this.menuOpen=!0,t.openDrawer(e),document.body.classList.add("menu-open");return}if(this.menu){this.menu.sliding=!0,this.menuOpen=!0,this.menu.isFullScreenDrawer&&this.canPromoteMenuToggle()&&(this.menu.liftedCloseControl=this.getMenuToggleElement()),this.menu.openDrawer(e),document.body.classList.add("menu-open");return}this.burger&&(this.burger.menuOpen=!1)}closeNav(){this.menuOpen=!1,this.burger&&(this.burger.menuOpen=!1),this.demoteMenuToggle();const e=this.getExternalDrawerTarget();if(e){e.closeDrawer(),document.body.classList.remove("menu-open");return}this.menu&&(this.menu.closeDrawer(),document.body.classList.remove("menu-open"))}getMenuToggleElement(){return this.shadowRoot?.querySelector("esp-header-button.menu-toggle")??null}canPromoteMenuToggle(){const e=this.getMenuToggleElement();return!!e&&typeof e?.showPopover=="function"}setHeaderChromeInert(e){if(!e){for(const n of this.inertedHeaderChrome)n.inert=!1;this.inertedHeaderChrome=[];return}const t=this.menuContainer.value?.parentElement,o=this.getMenuToggleElement();if(!t||!o)return;const r=[];for(const n of t.querySelectorAll(":scope > section.brand, :scope > section.topbar"))r.push(n);const i=t.querySelector(":scope > section.buttons");for(const n of i?.children??[])if(!(!(n instanceof HTMLElement)||n===o)){if(n instanceof HTMLSlotElement){for(const d of n.assignedElements())d instanceof HTMLElement&&r.push(d);continue}r.push(n)}for(const n of r)n.inert||(n.inert=!0,this.inertedHeaderChrome.push(n))}promoteMenuToggle(){const e=this.getMenuToggleElement();if(!e||this.menuTogglePromoted||typeof e.showPopover!="function")return;const t=e.getBoundingClientRect();e.setAttribute("popover","manual"),Object.assign(e.style,{position:"fixed",inset:"auto",margin:"0",padding:"0",border:"0",background:"transparent",overflow:"visible"}),this.setPromotedTogglePosition(e,t.left,t.top,t.width,t.height);try{e.showPopover()}catch{e.removeAttribute("popover"),e.removeAttribute("style"),this.menu&&(this.menu.liftedCloseControl=null);return}this.menuTogglePromoted=!0,window.addEventListener("resize",this.handlePromotedViewportResize),this.menu&&(this.menu.liftedCloseControl=e),this.setHeaderChromeInert(!0)}positionPromotedToggle(){if(!this.menuTogglePromoted)return;const e=this.getMenuToggleElement(),t=this.shadowRoot?.querySelector("section.buttons");if(!e||!t)return;const o=t.getBoundingClientRect(),r=e.getBoundingClientRect(),i=getComputedStyle(t).direction==="rtl";this.setPromotedTogglePosition(e,i?o.left:o.right-r.width,o.top+(o.height-r.height)/2,r.width,r.height)}setPromotedTogglePosition(e,t,o,r,i){const n=z();e.style.left=`${Math.max(0,Math.min(t,n.width-r))}px`,e.style.top=`${Math.max(0,Math.min(o,n.height-i))}px`}demoteMenuToggle(){if(window.removeEventListener("resize",this.handlePromotedViewportResize),this.promotedToggleFrame.cancel(),this.menu?.liftedCloseControl&&(this.menu.liftedCloseControl=null),!this.menuTogglePromoted)return;this.menuTogglePromoted=!1,this.setHeaderChromeInert(!1);const e=this.getMenuToggleElement();if(e){try{e.hidePopover()}catch{}e.removeAttribute("popover"),e.removeAttribute("style")}}syncDrawerBrand(){if(!this.menu)return;const e=M({scheme:this.scheme,brandLogo:this.brandLogo,brandColor:this.brandColor,lightBrandLogo:this.lightBrandLogo,darkBrandLogo:this.darkBrandLogo,lightBrandColor:this.lightBrandColor,darkBrandColor:this.darkBrandColor}),t=e.brandLogo||this.brandText?{brandLogo:e.brandLogo,brandText:this.brandText,brandHref:this.brandHref,brandAlt:this.brandAlt,brandColor:e.brandColor}:null,o=JSON.stringify(t);o!==this.lastDrawerBrandKey&&(this.lastDrawerBrandKey=o,this.menu.drawerBrand=t)}get burger(){return this.menuButton.value??void 0}willUpdate(e){super.willUpdate(e),e.has("layout")&&!g.allowedValues.has(this.layout)&&(this.layout=g.defaultValue),e.has("brandAlign")&&!b.allowedValues.has(this.brandAlign)&&(this.brandAlign=b.defaultValue),e.has("brandWrap")&&!f.allowedValues.has(this.brandWrap)&&(this.brandWrap=f.defaultValue),e.has("menuDisplay")&&!v.allowedValues.has(this.menuDisplay)&&(this.menuDisplay=v.defaultValue),e.has("themeToggle")&&!w.allowedValues.has(this.themeToggle)&&(this.themeToggle=w.defaultValue)}firstUpdated(e){if(super.firstUpdated(e),!this.menuContainer.value)return;const r=(this.menuContainer.value.firstElementChild?.assignedElements()??[])[0];r instanceof p?(this.menu=r,this.addMenuDrawerListeners(),this.observeMenuChildren(),this.syncDrawerBrand()):r&&console.warn("<esp-header>: the menu slot expects an <esp-menu> element, received",r),this.observeMenuContainer(),this.syncExternalDrawerTarget(),this.syncMobileMenuQuery(),this.syncScrollListeners(),this.syncMenuLayout()}updated(e){super.updated(e),this.syncDrawerBrand(),(e.has("showBurger")||e.has("drawerTarget")||e.has("menuDisplay")||e.has("layout")||e.has("previewCollapseRequested"))&&(this.syncExternalDrawerTarget(),this.syncMenuLayout()),(e.has("mobileMenu")||e.has("menuTooLarge"))&&this.syncExternalDrawerControl(),e.has("scrollBehavior")?this.syncScrollListeners():(e.has("scrollThreshold")||e.has("dockOffset"))&&this.updateScrollState()}connectedCallback(){super.connectedCallback(),this.syncScrollListeners(),this.syncMobileMenuQuery(),this.addMenuDrawerListeners(),this.syncExternalDrawerTarget(),this.observeMenuContainer(),this.observeMenuChildren()}disconnectedCallback(){this.removeMenuDrawerListeners(),this.externalDrawerTarget?.removeEventListener("esp-menu-drawer-opened",this.onMenuDrawerOpened),this.externalDrawerTarget?.removeEventListener("esp-menu-drawer-closed",this.onMenuDrawerClosed),this.externalDrawerTarget instanceof p&&(this.externalDrawerTarget.hasExternalDrawerControl=!1),this.externalDrawerTarget=null,this.mobileMenuQuery?.removeEventListener("change",this.handleMobileMenuQueryChange),this.mobileMenuQuery=null,this.removeScrollListeners(),this.cancelScrollUpdate(),this.disconnectResizeObserver(),this.menuChildObserver?.disconnect(),this.menuChildObserver=null,this.demoteMenuToggle(),super.disconnectedCallback()}render(){const{menuOpen:e,menuTooLarge:t,mobileMenu:o}=this,r=this.menuDisplay!=="inline",i=r&&(this.showBurger||this.menuDisplay==="drawer"||this.layout==="minimal"||this.previewCollapseRequested),n=this.getScrollTokens(),d=n.has("progress"),m=M({scheme:this.scheme,brandLogo:this.brandLogo,brandColor:this.brandColor,lightBrandLogo:this.lightBrandLogo,darkBrandLogo:this.darkBrandLogo,lightBrandColor:this.lightBrandColor,darkBrandColor:this.darkBrandColor}),y={"--_esp-header-brand-color":m.brandColor||null,"--_esp-header-scroll-progress":String(this.scrollProgress)},S={"menu-open":e,"too-wide":r&&this.hasDrawerableContent()&&(t||o||i),[`layout-${this.layout}`]:!0,"is-scrolled":this.scrolled,"hide-on-scroll":this.hiddenByScroll,"scroll-compact":n.has("compact"),"scroll-elevate":n.has("elevate"),"scroll-transparent":n.has("transparent")||n.has("transparent-to-solid"),"scroll-collapse-topbar":n.has("collapse-topbar")},B=this.scheme==="dark"?"light":"dark";return x`
|
|
2
|
-
|
|
1
|
+
var a=function(v,e,t,n){var r=arguments.length,i=r<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,o;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(v,e,t,n);else for(var h=v.length-1;h>=0;h--)(o=v[h])&&(i=(r<3?o(i):r>3?o(e,t,i):o(e,t))||i);return r>3&&i&&Object.defineProperty(e,t,i),i};import{paintedSurface as j}from"../shared/surface-layer.js";import{css as I,html as E,nothing as p}from"lit";import{customElement as V,property as l,state as f}from"lit/decorators.js";import{classMap as H}from"lit/directives/class-map.js";import{styleMap as G}from"lit/directives/style-map.js";import"../burger/esp-burger.js";import{createRef as _,ref as k}from"lit/directives/ref.js";import{MENU_PRESENTATION_CHANGED as T,MENU_LAYOUT_CHANGED as P,MENU_FIT_PROBE_STYLES as Q,menuPresentationStyle as Y,renderMenuNode as K}from"../menu/menu-presentation.js";import{EspalierMenu as M}from"../menu/esp-menu.js";import{RafThrottle as N}from"../shared/raf-throttle.js";import{viewportSize as J}from"../shared/viewport.js";import{CONFIGURED_BRAND_LOGO_ASPECT_RATIO as X,configuredBrandLogoGeometry as Z,renderConfiguredBrand as F,resolveConfiguredBrand as $}from"../shared/configured-brand.js";import{EspalierElementBase as q}from"../shared/esp-element-base.js";import{ESP_EVENTS as ee}from"../shared/events.js";const te="(max-width: 36rem)";function C(v,e){const t=new Set(v);return{allowedValues:t,converter:{fromAttribute(r){return r??e},toAttribute(r){return t.has(r)?r:e}},defaultValue:e}}const ne=["standard","centered-brand","centered-menu","extended","extended-centered","minimal"],re=["start","center","end"],oe=["truncate","wrap","nowrap"],se=["auto","inline","drawer"],ie=["hidden","visible"],L=C(ne,"standard"),D=C(re,"start"),S=C(oe,"truncate"),B=C(se,"auto"),O=C(ie,"hidden");let s=class extends q{constructor(){super(...arguments),this.menuOpen=!1,this.navigationConstrained=!1,this.menuTooLarge=!1,this.mobileMenu=!1,this.scrolled=!1,this.hiddenByScroll=!1,this.scrollProgress=0,this.showBurger=!1,this.layout=L.defaultValue,this.brandText="",this.brandLogo="",this.lightBrandLogo="",this.darkBrandLogo="",this.brandHref="",this.brandAlt="",this.brandColor="",this.lightBrandColor="",this.darkBrandColor="",this.brandAlign=D.defaultValue,this.brandWrap=S.defaultValue,this.menuDisplay=B.defaultValue,this.themeToggle=O.defaultValue,this.scrollBehavior="none",this.scrollThreshold=16,this.dockOffset=0,this.drawerTarget="",this.previewCollapseRequested=!1,this.fullBleedContent=!1,this.menuContainer=_(),this.menuButton=_(),this.menu=void 0,this.externalDrawerTarget=null,this.lastScrollY=0,this.lastInlineMenuWidth=0,this.mobileMenuQuery=null,this.menuDrawerListenersAttached=!1,this.observingMenuContainer=!1,this.scrollListenersAttached=!1,this.scrollFrame=new N(()=>this.runScrollStateUpdate()),this.resizeObserver=new ResizeObserver(()=>this.syncMenuLayout()),this.menuChildObserver=null,this.endProbe=_(),this.observedEndProbe=null,this.endProbeObserver=null,this.invalidMenuSlot=null,this.actionsWidth=0,this.syncPrimaryMenu=()=>{const n=(this.menuContainer.value?.querySelector('slot[name="menu"]')?.assignedElements()??[])[0],r=n instanceof M&&n.parentElement===this?n:void 0,i=n&&!r?n:null;i&&i!==this.invalidMenuSlot&&console.warn("<esp-header>: the menu slot expects an <esp-menu> element, received",i),this.invalidMenuSlot=i,r!==this.menu&&(this.demoteMenuToggle(),this.removeMenuDrawerListeners(),this.menu?.removeEventListener(T,this.onPrimaryPresentationChanged),this.menu?.removeEventListener(P,this.onPrimaryLayoutChanged),this.menu&&(this.menu.headerEndOwner=null,this.menu.sliding=!1),this.menuChildObserver?.disconnect(),this.menuChildObserver=null,this.menu=r,this.lastInlineMenuWidth=0,this.lastDrawerBrandKey="",this.addMenuDrawerListeners(),this.menu?.addEventListener(T,this.onPrimaryPresentationChanged),this.observeMenuChildren(),this.syncDrawerBrand(),this.requestUpdate()),this.menu?.addEventListener(T,this.onPrimaryPresentationChanged),this.menu?.addEventListener(P,this.onPrimaryLayoutChanged),this.menu&&(this.menu.headerEndOwner=this.menu.mode==="horizontal"?this:null),this.syncExternalDrawerTarget(),this.syncMenuLayout()},this.onPrimaryPresentationChanged=()=>{this.menu?.headerDrawerActive&&this.returnEndFocusToBurger(),this.requestUpdate()},this.onPrimaryLayoutChanged=()=>{if(!this.menu)return;const e=this.menu.mode==="horizontal"&&this.menu.parentElement===this?this:null;this.menu.headerEndOwner!==e&&(this.menu.headerEndOwner=e),this.menu.headerDrawerActive&&this.returnEndFocusToBurger(),this.observeMenuChildren(),this.requestUpdate(),this.syncMenuLayout()},this.updateScrollState=()=>this.scrollFrame.schedule(),this.handleMobileMenuQueryChange=e=>{this.mobileMenu=e.matches,this.syncMenuLayout(),this.syncExternalDrawerControl()},this.toggleTheme=()=>{const e=this.getThemeRoot();if(!e)return;e.scheme=e.scheme==="dark"?"light":"dark";const t=e.scheme==="dark"?"dark":"light";this.dispatchEvent(new CustomEvent(ee.HEADER_THEME_TOGGLE,{detail:{scheme:t},bubbles:!0,composed:!0}))},this.handleMenuToggleClicked=()=>{if(this.menuOpen){this.closeNav();return}this.openNav()},this.onMenuDrawerOpened=()=>{this.menuOpen=!0,document.body.classList.add("menu-open"),this.burger&&(this.burger.menuOpen=!0)},this.onMenuDrawerClosed=()=>{this.menuOpen=!1,document.body.classList.remove("menu-open"),this.burger&&(this.burger.menuOpen=!1),this.demoteMenuToggle()},this.onMenuDrawerPresented=e=>{e.target!==this.menu||!this.menu?.isFullScreenDrawer||this.promoteMenuToggle()},this.menuTogglePromoted=!1,this.promotedToggleFrame=new N(()=>this.positionPromotedToggle()),this.handlePromotedViewportResize=()=>this.promotedToggleFrame.schedule(),this.lastDrawerBrandKey="",this.inertedHeaderChrome=[]}get usesIntrinsicNavigation(){return!!this.menu?.headerNavigationOwned}syncEndProbeObserver(){const e=this.endProbe.value??null;e!==this.observedEndProbe&&(this.endProbeObserver?.disconnect(),this.observedEndProbe=e,e&&(this.endProbeObserver??=new ResizeObserver(()=>this.syncMenuLayout()),this.endProbeObserver.observe(e,{box:"border-box"})),this.syncMenuLayout())}returnEndFocusToBurger(){const e=this.shadowRoot?.querySelector(".header-end"),t=this.shadowRoot?.activeElement;t&&e?.contains(t)&&this.updateComplete.then(()=>this.getBurgerFocusTarget()?.focus({preventScroll:!0}))}readHeaderEndFit(){const e=this.menuContainer.value?.parentElement;if(!e||!this.menu)return null;const t=getComputedStyle(e),n=e.clientWidth-(parseFloat(t.paddingLeft)||0)-(parseFloat(t.paddingRight)||0),r=parseFloat(t.columnGap)||0,i=e.querySelector(":scope > .brand"),o=i?.querySelector("slot"),h=e.querySelector(".brand-fit-probe"),d=o?.assignedElements().length?Math.max(i?.scrollWidth??0,i?.getBoundingClientRect().width??0):h?.getBoundingClientRect().width??0,c=e.querySelector(":scope > .buttons"),u=Array.from(c?.children??[]).flatMap(m=>m.matches(".header-end, .header-end-measurement, .menu-toggle")?[]:m instanceof HTMLSlotElement?m.assignedElements():[m]).filter(m=>getComputedStyle(m).display!=="none");let w=u.reduce((m,R)=>{const z=getComputedStyle(R);return m+R.getBoundingClientRect().width+(parseFloat(z.marginLeft)||0)+(parseFloat(z.marginRight)||0)},0);const g=this.endProbe.value?.getBoundingClientRect().width??0,x=c&&parseFloat(getComputedStyle(c).columnGap)||0;w+=x*Math.max(0,u.length-1+(g>0?1:0));const b=this.menu.getHeaderNavigationWidths().main,y=g+w,U=this.layout==="extended"?b>n||d+y+r>n:this.layout==="extended-centered"?b>n||d+2*y+2*r>n:this.layout==="centered-brand"?d+2*Math.max(b,y)+2*r>n:d+b+y+2*r>n,A=this.getExternalDrawerTarget()?c?.querySelector(".menu-toggle"):null,W=w+(A&&getComputedStyle(A).display!=="none"?A.getBoundingClientRect().width+(u.length||g?x:0):0);return{width:n,brandWidth:d,main:b,endWidth:g,actions:w,actionFloor:W,gap:r,tooWide:U}}syncMenuLayout(){if(!this.menuContainer.value||!this.menu||!this.menu.getWidth)return;this.positionPromotedToggle();const e=this.menu.getWidth();e>0&&(this.lastInlineMenuWidth=e);const t=this.lastInlineMenuWidth||e,n=this.getExternalDrawerTarget(),r=this.menuDisplay!=="inline",i=this.showBurger||this.menuDisplay==="drawer"||this.layout==="minimal"||this.previewCollapseRequested,o=r&&this.menuDisplay==="auto",h=o?this.layout==="centered-menu"?this.centeredMenuCapacity():this.menuContainer.value.clientWidth:0,d=this.usesIntrinsicNavigation?this.readHeaderEndFit():null;d&&this.actionsWidth!==d.actionFloor&&(this.actionsWidth=d.actionFloor,this.requestUpdate()),this.menuTooLarge=o&&(d?d.tooWide:t>h);const c=r&&!n&&this.hasDrawerableContent()&&(this.menuTooLarge||i||this.mobileMenu);c&&this.returnEndFocusToBurger(),this.menu.sliding=c,this.navigationConstrained=d?.tooWide??!1}centeredMenuCapacity(){const e=this.menuContainer.value?.parentElement;if(!(e instanceof HTMLElement))return 0;const t=h=>h?h.getBoundingClientRect().width:0,n=getComputedStyle(e),r=e.clientWidth-(Number.parseFloat(n.paddingLeft)||0)-(Number.parseFloat(n.paddingRight)||0),i=e.querySelector(":scope > section.brand"),o=e.querySelector(":scope > section.buttons");return r-t(i)-t(o)+t(o?.querySelector("esp-header-button.menu-toggle"))}menuHasContent(){return!!(this.menu??this.querySelector(':scope > [slot="menu"]'))?.querySelector("esp-menu-item, esp-menu-group")}hasDrawerableContent(){return this.showBurger||!!this.getExternalDrawerTarget()||this.menuHasContent()}getExternalDrawerTarget(){if(!this.drawerTarget)return null;const e=document.getElementById(this.drawerTarget);return e===this.menu?null:e&&"openDrawer"in e&&typeof e.openDrawer=="function"&&"closeDrawer"in e&&typeof e.closeDrawer=="function"?e:null}getBurgerFocusTarget(){const t=this.shadowRoot?.querySelector("esp-header-button.menu-toggle")?.shadowRoot?.querySelector("button"),n=this.menuButton.value?.shadowRoot?.querySelector("button");return t??n??null}getScrollTokens(){const e=this.scrollBehavior.split(/\s+/).map(t=>t.trim().toLowerCase()).filter(Boolean);return new Set(e.filter(t=>t!=="none"))}getEffectiveScrollThreshold(){return Number.isFinite(this.scrollThreshold)?Math.max(0,this.scrollThreshold):0}clearScrollState(){this.scrolled=!1,this.hiddenByScroll=!1,this.scrollProgress=0}runScrollStateUpdate(){const e=this.getScrollTokens();if(!e.size){this.clearScrollState();return}const t=Math.max(0,window.scrollY||document.documentElement.scrollTop||0),n=this.getEffectiveScrollThreshold(),r=Number.isFinite(this.dockOffset)?Math.max(0,this.dockOffset):n,i=t>(e.has("dock")?r:n),o=t>this.lastScrollY,h=e.has("reveal")&&o&&t>n&&!this.menuOpen;if(this.scrolled=i,this.hiddenByScroll=h,e.has("progress")){const d=document.documentElement,c=Math.max(1,d.scrollHeight-window.innerHeight);this.scrollProgress=Math.min(1,t/c)}else this.scrollProgress=0;this.lastScrollY=t}cancelScrollUpdate(){this.scrollFrame.cancel()}syncScrollListeners(){const e=this.getScrollTokens().size>0;if(e&&!this.scrollListenersAttached?(window.addEventListener("scroll",this.updateScrollState,{passive:!0}),window.addEventListener("resize",this.updateScrollState,{passive:!0}),this.scrollListenersAttached=!0):!e&&this.scrollListenersAttached&&this.removeScrollListeners(),e){this.updateScrollState();return}this.cancelScrollUpdate(),this.clearScrollState()}removeScrollListeners(){this.scrollListenersAttached&&(window.removeEventListener("scroll",this.updateScrollState),window.removeEventListener("resize",this.updateScrollState),this.scrollListenersAttached=!1)}addMenuDrawerListeners(){!this.menu||this.menuDrawerListenersAttached||(this.menu.addEventListener("esp-menu-drawer-opened",this.onMenuDrawerOpened),this.menu.addEventListener("esp-menu-drawer-presented",this.onMenuDrawerPresented),this.menu.addEventListener("esp-menu-drawer-closed",this.onMenuDrawerClosed),this.menuDrawerListenersAttached=!0)}removeMenuDrawerListeners(){!this.menu||!this.menuDrawerListenersAttached||(this.menu.removeEventListener("esp-menu-drawer-opened",this.onMenuDrawerOpened),this.menu.removeEventListener("esp-menu-drawer-presented",this.onMenuDrawerPresented),this.menu.removeEventListener("esp-menu-drawer-closed",this.onMenuDrawerClosed),this.menuDrawerListenersAttached=!1)}observeMenuContainer(){if(!this.menuContainer.value||this.observingMenuContainer)return;this.resizeObserver.observe(this.menuContainer.value);const e=this.menuContainer.value.parentElement;if(e){this.resizeObserver.observe(e);for(const t of e.querySelectorAll(":scope > section.brand, :scope > section.buttons, :scope > .brand-fit-probe"))this.resizeObserver.observe(t)}this.observingMenuContainer=!0}disconnectResizeObserver(){this.observingMenuContainer&&(this.resizeObserver.disconnect(),this.observingMenuContainer=!1)}observeMenuChildren(){if(this.usesIntrinsicNavigation){this.menuChildObserver?.disconnect(),this.menuChildObserver=null;return}!this.menu||this.menuChildObserver||(this.menuChildObserver=new MutationObserver(()=>{this.syncMenuLayout(),this.requestUpdate()}),this.menuChildObserver.observe(this.menu,{childList:!0,subtree:!0}))}syncMobileMenuQuery(){if("matchMedia"in window){if(!this.mobileMenuQuery){this.mobileMenuQuery=window.matchMedia(te),this.mobileMenu=this.mobileMenuQuery.matches,this.mobileMenuQuery.addEventListener("change",this.handleMobileMenuQueryChange);return}this.mobileMenu=this.mobileMenuQuery.matches}}getThemeRoot(){return this.traverseToClosest("esp-root")}syncExternalDrawerTarget(){const e=this.getExternalDrawerTarget(),t=e===this.menu?null:e;t!==this.externalDrawerTarget&&(this.externalDrawerTarget?.removeEventListener("esp-menu-drawer-opened",this.onMenuDrawerOpened),this.externalDrawerTarget?.removeEventListener("esp-menu-drawer-closed",this.onMenuDrawerClosed),this.externalDrawerTarget instanceof M&&(this.externalDrawerTarget.hasExternalDrawerControl=!1),this.externalDrawerTarget=t,this.externalDrawerTarget?.addEventListener("esp-menu-drawer-opened",this.onMenuDrawerOpened),this.externalDrawerTarget?.addEventListener("esp-menu-drawer-closed",this.onMenuDrawerClosed)),this.syncExternalDrawerControl()}burgerVisibleForTarget(){if(this.menuDisplay==="inline")return!1;const e=this.showBurger||this.menuDisplay==="drawer"||this.layout==="minimal"||this.previewCollapseRequested;return this.menuTooLarge||this.mobileMenu||e}syncExternalDrawerControl(){this.externalDrawerTarget instanceof M&&(this.externalDrawerTarget.hasExternalDrawerControl=this.burgerVisibleForTarget())}openNav(){const e=this.getBurgerFocusTarget(),t=this.getExternalDrawerTarget();if(this.burger&&(this.burger.menuOpen=!0),t){this.menuOpen=!0,t.openDrawer(e),document.body.classList.add("menu-open");return}if(this.menu){this.menu.sliding=!0,this.menuOpen=!0,this.menu.isFullScreenDrawer&&this.canPromoteMenuToggle()&&(this.menu.liftedCloseControl=this.getMenuToggleElement()),this.menu.openDrawer(e),document.body.classList.add("menu-open");return}this.burger&&(this.burger.menuOpen=!1)}closeNav(){this.menuOpen=!1,this.burger&&(this.burger.menuOpen=!1),this.demoteMenuToggle();const e=this.getExternalDrawerTarget();if(e){e.closeDrawer(),document.body.classList.remove("menu-open");return}this.menu&&(this.menu.closeDrawer(),document.body.classList.remove("menu-open"))}getMenuToggleElement(){return this.shadowRoot?.querySelector("esp-header-button.menu-toggle")??null}canPromoteMenuToggle(){const e=this.getMenuToggleElement();return!!e&&typeof e?.showPopover=="function"}setHeaderChromeInert(e){if(!e){for(const o of this.inertedHeaderChrome)o.inert=!1;this.inertedHeaderChrome=[];return}const t=this.menuContainer.value?.parentElement,n=this.getMenuToggleElement();if(!t||!n)return;const r=[];for(const o of t.querySelectorAll(":scope > section.brand, :scope > section.topbar"))r.push(o);const i=t.querySelector(":scope > section.buttons");for(const o of i?.children??[])if(!(!(o instanceof HTMLElement)||o===n)){if(o instanceof HTMLSlotElement){for(const h of o.assignedElements())h instanceof HTMLElement&&r.push(h);continue}r.push(o)}for(const o of r)o.inert||(o.inert=!0,this.inertedHeaderChrome.push(o))}promoteMenuToggle(){const e=this.getMenuToggleElement();if(!e||this.menuTogglePromoted||typeof e.showPopover!="function")return;const t=e.getBoundingClientRect();e.setAttribute("popover","manual"),Object.assign(e.style,{position:"fixed",inset:"auto",margin:"0",padding:"0",border:"0",background:"transparent",overflow:"visible"}),this.setPromotedTogglePosition(e,t.left,t.top,t.width,t.height);try{e.showPopover()}catch{e.removeAttribute("popover"),e.removeAttribute("style"),this.menu&&(this.menu.liftedCloseControl=null);return}this.menuTogglePromoted=!0,window.addEventListener("resize",this.handlePromotedViewportResize),this.menu&&(this.menu.liftedCloseControl=e),this.setHeaderChromeInert(!0)}positionPromotedToggle(){if(!this.menuTogglePromoted)return;const e=this.getMenuToggleElement(),t=this.shadowRoot?.querySelector("section.buttons");if(!e||!t)return;const n=t.getBoundingClientRect(),r=e.getBoundingClientRect(),i=getComputedStyle(t).direction==="rtl";this.setPromotedTogglePosition(e,i?n.left:n.right-r.width,n.top+(n.height-r.height)/2,r.width,r.height)}setPromotedTogglePosition(e,t,n,r,i){const o=J();e.style.left=`${Math.max(0,Math.min(t,o.width-r))}px`,e.style.top=`${Math.max(0,Math.min(n,o.height-i))}px`}demoteMenuToggle(){if(window.removeEventListener("resize",this.handlePromotedViewportResize),this.promotedToggleFrame.cancel(),this.menu?.liftedCloseControl&&(this.menu.liftedCloseControl=null),!this.menuTogglePromoted)return;this.menuTogglePromoted=!1,this.setHeaderChromeInert(!1);const e=this.getMenuToggleElement();if(e){try{e.hidePopover()}catch{}e.removeAttribute("popover"),e.removeAttribute("style")}}syncDrawerBrand(){if(!this.menu)return;const e=$({scheme:this.scheme,brandLogo:this.brandLogo,brandColor:this.brandColor,lightBrandLogo:this.lightBrandLogo,darkBrandLogo:this.darkBrandLogo,lightBrandColor:this.lightBrandColor,darkBrandColor:this.darkBrandColor}),t=e.brandLogo||this.brandText?{brandLogo:e.brandLogo,brandText:this.brandText,brandHref:this.brandHref,brandAlt:this.brandAlt,brandColor:e.brandColor}:null,n=JSON.stringify(t);n!==this.lastDrawerBrandKey&&(this.lastDrawerBrandKey=n,this.menu.drawerBrand=t)}get burger(){return this.menuButton.value??void 0}willUpdate(e){super.willUpdate(e),e.has("layout")&&!L.allowedValues.has(this.layout)&&(this.layout=L.defaultValue),e.has("brandAlign")&&!D.allowedValues.has(this.brandAlign)&&(this.brandAlign=D.defaultValue),e.has("brandWrap")&&!S.allowedValues.has(this.brandWrap)&&(this.brandWrap=S.defaultValue),e.has("menuDisplay")&&!B.allowedValues.has(this.menuDisplay)&&(this.menuDisplay=B.defaultValue),e.has("themeToggle")&&!O.allowedValues.has(this.themeToggle)&&(this.themeToggle=O.defaultValue)}firstUpdated(e){super.firstUpdated(e),this.menuContainer.value&&(this.syncPrimaryMenu(),this.observeMenuContainer(),this.syncExternalDrawerTarget(),this.syncMobileMenuQuery(),this.syncScrollListeners(),this.syncMenuLayout())}updated(e){super.updated(e),this.syncDrawerBrand(),this.syncEndProbeObserver(),this.observeMenuChildren(),(e.has("showBurger")||e.has("drawerTarget")||e.has("menuDisplay")||e.has("layout")||e.has("previewCollapseRequested"))&&(this.syncExternalDrawerTarget(),this.syncMenuLayout()),(e.has("mobileMenu")||e.has("menuTooLarge"))&&this.syncExternalDrawerControl(),e.has("scrollBehavior")?this.syncScrollListeners():(e.has("scrollThreshold")||e.has("dockOffset"))&&this.updateScrollState()}connectedCallback(){super.connectedCallback(),this.syncScrollListeners(),this.syncMobileMenuQuery(),this.addMenuDrawerListeners(),this.syncExternalDrawerTarget(),this.observeMenuContainer(),this.hasUpdated&&this.syncPrimaryMenu(),this.observeMenuChildren()}disconnectedCallback(){this.menu?.removeEventListener(T,this.onPrimaryPresentationChanged),this.menu?.removeEventListener(P,this.onPrimaryLayoutChanged),this.menu&&(this.menu.headerEndOwner=null),this.removeMenuDrawerListeners(),this.externalDrawerTarget?.removeEventListener("esp-menu-drawer-opened",this.onMenuDrawerOpened),this.externalDrawerTarget?.removeEventListener("esp-menu-drawer-closed",this.onMenuDrawerClosed),this.externalDrawerTarget instanceof M&&(this.externalDrawerTarget.hasExternalDrawerControl=!1),this.externalDrawerTarget=null,this.mobileMenuQuery?.removeEventListener("change",this.handleMobileMenuQueryChange),this.mobileMenuQuery=null,this.removeScrollListeners(),this.cancelScrollUpdate(),this.disconnectResizeObserver(),this.endProbeObserver?.disconnect(),this.observedEndProbe=null,this.menuChildObserver?.disconnect(),this.menuChildObserver=null,this.demoteMenuToggle(),super.disconnectedCallback()}renderHeaderEnd(e,t,n){return E`<nav
|
|
2
|
+
class=${H({"header-end":!t,"header-end-probe":t})}
|
|
3
|
+
${t?k(this.endProbe):p}
|
|
4
|
+
aria-label=${t?p:`${this.menu?.ariaLabel??"Navigation"} links`}
|
|
5
|
+
aria-hidden=${t?"true":p}
|
|
6
|
+
?hidden=${n}
|
|
7
|
+
?inert=${t||n}
|
|
8
|
+
style=${Y(this.menu)}
|
|
9
|
+
>
|
|
10
|
+
${e.map(r=>K(r,{mode:"horizontal",sourceStyle:!0}))}
|
|
11
|
+
</nav>`}render(){const{menuOpen:e,menuTooLarge:t,mobileMenu:n}=this,r=this.menuDisplay!=="inline",i=r&&(this.showBurger||this.menuDisplay==="drawer"||this.layout==="minimal"||this.previewCollapseRequested),o=this.getScrollTokens(),h=o.has("progress"),d=$({scheme:this.scheme,brandLogo:this.brandLogo,brandColor:this.brandColor,lightBrandLogo:this.lightBrandLogo,darkBrandLogo:this.darkBrandLogo,lightBrandColor:this.lightBrandColor,darkBrandColor:this.darkBrandColor}),c={"--_esp-header-brand-color":d.brandColor||null,"--_esp-header-scroll-progress":String(this.scrollProgress),"--_esp-header-actions-width":`${this.actionsWidth}px`},u=this.menu?.headerEndNodes??[],w=!u.length||!!this.menu?.headerDrawerActive,g=!!this.menu?.headerDrawerActive,x=this.menuDisplay==="inline"||this.usesIntrinsicNavigation&&!g&&!!this.getExternalDrawerTarget(),b={"primary-drawer":g,"has-header-end":u.length>0,"explicit-inline":x,"navigation-constrained":this.navigationConstrained,"menu-open":e,"too-wide":r&&this.hasDrawerableContent()&&(t||n||i),[`layout-${this.layout==="minimal"&&x?"standard":this.layout}`]:!0,"is-scrolled":this.scrolled,"hide-on-scroll":this.hiddenByScroll,"scroll-compact":o.has("compact"),"scroll-elevate":o.has("elevate"),"scroll-transparent":o.has("transparent")||o.has("transparent-to-solid"),"scroll-collapse-topbar":o.has("collapse-topbar")},y=this.scheme==="dark"?"light":"dark";return E`
|
|
12
|
+
<header class=${H(b)} style=${G(c)}>
|
|
3
13
|
<section class="topbar">
|
|
4
14
|
<slot name="topbar"></slot>
|
|
5
15
|
</section>
|
|
6
16
|
|
|
7
17
|
<section class="brand">
|
|
8
18
|
<slot name="brand"
|
|
9
|
-
>${
|
|
19
|
+
>${F({brandLogo:d.brandLogo,brandText:this.brandText,brandHref:this.brandHref,brandAlt:this.brandAlt})}</slot
|
|
10
20
|
>
|
|
11
21
|
</section>
|
|
12
22
|
|
|
13
|
-
<section ${
|
|
14
|
-
<slot name="menu"></slot>
|
|
23
|
+
<section ${k(this.menuContainer)} class="menu-container">
|
|
24
|
+
<slot name="menu" @slotchange=${this.syncPrimaryMenu}></slot>
|
|
15
25
|
</section>
|
|
16
26
|
|
|
17
27
|
<section class="buttons">
|
|
28
|
+
${this.renderHeaderEnd(u,!1,w)}
|
|
29
|
+
${this.usesIntrinsicNavigation&&u.length?E`<div class="header-end-measurement menu-fit-probes" aria-hidden="true" inert>
|
|
30
|
+
${this.renderHeaderEnd(u,!0,!1)}
|
|
31
|
+
</div>`:p}
|
|
18
32
|
<slot name="buttons"></slot>
|
|
19
|
-
${this.themeToggle==="visible"?
|
|
33
|
+
${this.themeToggle==="visible"?E`<esp-header-button
|
|
20
34
|
class="theme-toggle"
|
|
21
35
|
icon=${this.scheme==="dark"?"sun":"moon"}
|
|
22
|
-
aria-label=${`Switch to ${
|
|
36
|
+
aria-label=${`Switch to ${y} mode`}
|
|
23
37
|
@esp-clicked=${this.toggleTheme}
|
|
24
|
-
></esp-header-button>`:
|
|
38
|
+
></esp-header-button>`:p}
|
|
25
39
|
|
|
26
40
|
<esp-header-button
|
|
27
41
|
class="menu-toggle"
|
|
28
42
|
aria-label=${e?"Close navigation":"Open navigation"}
|
|
29
|
-
aria-controls=${this.drawerTarget||
|
|
43
|
+
aria-controls=${this.drawerTarget||p}
|
|
30
44
|
aria-expanded=${e?"true":"false"}
|
|
31
45
|
@esp-clicked=${this.handleMenuToggleClicked}
|
|
32
46
|
>
|
|
33
|
-
<esp-burger ${
|
|
47
|
+
<esp-burger ${k(this.menuButton)} presentation-only></esp-burger>
|
|
34
48
|
</esp-header-button>
|
|
35
49
|
</section>
|
|
36
|
-
|
|
50
|
+
<div class="brand-fit-probe" aria-hidden="true" inert>
|
|
51
|
+
${this.usesIntrinsicNavigation?F({brandLogo:d.brandLogo,brandText:this.brandText,brandHref:this.brandHref,brandAlt:this.brandAlt}):p}
|
|
52
|
+
</div>
|
|
53
|
+
${h?E`<div class="scroll-progress" aria-hidden="true"></div>`:p}
|
|
37
54
|
</header>
|
|
38
|
-
`}};s.styles=[...
|
|
55
|
+
`}};s.styles=[...q.styles,Q,j(2,"header"),Z,I`
|
|
39
56
|
:host {
|
|
40
57
|
--_esp-header-current-height: var(--esp-header-height, calc(4.5 * var(--esp-size-small)));
|
|
41
58
|
|
|
@@ -100,6 +117,14 @@ var a=function(h,e,t,o){var r=arguments.length,i=r<3?e:o===null?o=Object.getOwnP
|
|
|
100
117
|
grid-row: 2;
|
|
101
118
|
}
|
|
102
119
|
|
|
120
|
+
.brand-fit-probe {
|
|
121
|
+
position: absolute;
|
|
122
|
+
visibility: hidden;
|
|
123
|
+
pointer-events: none;
|
|
124
|
+
width: max-content;
|
|
125
|
+
padding-inline: var(--esp-header-brand-padding-inline, var(--esp-size-small));
|
|
126
|
+
}
|
|
127
|
+
|
|
103
128
|
section.brand {
|
|
104
129
|
display: grid;
|
|
105
130
|
min-width: 0;
|
|
@@ -177,7 +202,7 @@ var a=function(h,e,t,o){var r=arguments.length,i=r<3?e:o===null?o=Object.getOwnP
|
|
|
177
202
|
.brand-logo {
|
|
178
203
|
|
|
179
204
|
aspect-ratio: auto
|
|
180
|
-
var(--esp-header-brand-logo-aspect-ratio, ${
|
|
205
|
+
var(--esp-header-brand-logo-aspect-ratio, ${X});
|
|
181
206
|
width: auto;
|
|
182
207
|
height: var(
|
|
183
208
|
--esp-header-brand-logo-size,
|
|
@@ -202,6 +227,87 @@ var a=function(h,e,t,o){var r=arguments.length,i=r<3?e:o===null?o=Object.getOwnP
|
|
|
202
227
|
color: inherit;
|
|
203
228
|
}
|
|
204
229
|
|
|
230
|
+
.header-end,
|
|
231
|
+
.header-end-probe {
|
|
232
|
+
display: flex;
|
|
233
|
+
align-items: stretch;
|
|
234
|
+
--esp-header-height: var(--_esp-header-current-height);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
.header-end {
|
|
238
|
+
flex: 0 1 auto;
|
|
239
|
+
min-width: 0;
|
|
240
|
+
overflow-x: auto;
|
|
241
|
+
scrollbar-width: thin;
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
.header-end[hidden] {
|
|
245
|
+
display: none;
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
.header-end-probe {
|
|
249
|
+
position: absolute;
|
|
250
|
+
inline-size: max-content;
|
|
251
|
+
max-inline-size: none;
|
|
252
|
+
flex-wrap: nowrap;
|
|
253
|
+
visibility: hidden;
|
|
254
|
+
pointer-events: none;
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
.header-end > esp-menu-item,
|
|
258
|
+
.header-end-probe > esp-menu-item {
|
|
259
|
+
flex: none;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
section.buttons > :not(.header-end),
|
|
263
|
+
section.buttons ::slotted(*) {
|
|
264
|
+
flex: none;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
&.has-header-end {
|
|
268
|
+
grid-template-columns:
|
|
269
|
+
minmax(0, max-content) minmax(0, 1fr)
|
|
270
|
+
minmax(var(--_esp-header-actions-width, 0px), max-content);
|
|
271
|
+
|
|
272
|
+
section.buttons {
|
|
273
|
+
min-width: 0;
|
|
274
|
+
max-width: 100%;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
&.has-header-end.layout-centered-brand,
|
|
279
|
+
&.has-header-end.layout-extended-centered {
|
|
280
|
+
grid-template-columns: minmax(0, 1fr) minmax(0, max-content) minmax(0, 1fr);
|
|
281
|
+
}
|
|
282
|
+
|
|
283
|
+
&.has-header-end.layout-centered-menu {
|
|
284
|
+
grid-template-columns:
|
|
285
|
+
minmax(max-content, 1fr) minmax(0, max-content)
|
|
286
|
+
minmax(max-content, 1fr);
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
&.has-header-end.layout-extended,
|
|
290
|
+
&.has-header-end.layout-minimal {
|
|
291
|
+
grid-template-columns: minmax(0, 1fr) minmax(
|
|
292
|
+
var(--_esp-header-actions-width, 0px),
|
|
293
|
+
max-content
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
&.has-header-end.explicit-inline.navigation-constrained {
|
|
298
|
+
grid-template-columns:
|
|
299
|
+
minmax(0, 1fr) minmax(0, 1fr)
|
|
300
|
+
minmax(var(--_esp-header-actions-width, 0px), 1fr);
|
|
301
|
+
|
|
302
|
+
section.buttons {
|
|
303
|
+
justify-self: stretch;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
&.has-header-end.explicit-inline.navigation-constrained.layout-extended {
|
|
308
|
+
grid-template-columns: minmax(0, 1fr) minmax(var(--_esp-header-actions-width, 0px), 1fr);
|
|
309
|
+
}
|
|
310
|
+
|
|
205
311
|
esp-header-button.menu-toggle {
|
|
206
312
|
display: none;
|
|
207
313
|
}
|
|
@@ -408,12 +514,15 @@ var a=function(h,e,t,o){var r=arguments.length,i=r<3?e:o===null?o=Object.getOwnP
|
|
|
408
514
|
padding-inline: 0;
|
|
409
515
|
}
|
|
410
516
|
|
|
411
|
-
|
|
517
|
+
|
|
518
|
+
:host([brand-align="center"]) header section.brand,
|
|
519
|
+
:host([brand-align="center"]) header:not(.explicit-inline) section.brand {
|
|
412
520
|
justify-content: center;
|
|
413
521
|
text-align: center;
|
|
414
522
|
}
|
|
415
523
|
|
|
416
|
-
:host([brand-align="end"]) header section.brand
|
|
524
|
+
:host([brand-align="end"]) header section.brand,
|
|
525
|
+
:host([brand-align="end"]) header:not(.explicit-inline) section.brand {
|
|
417
526
|
justify-content: end;
|
|
418
527
|
text-align: end;
|
|
419
528
|
}
|
|
@@ -443,12 +552,13 @@ var a=function(h,e,t,o){var r=arguments.length,i=r<3?e:o===null?o=Object.getOwnP
|
|
|
443
552
|
}
|
|
444
553
|
|
|
445
554
|
@media (max-width: 36rem) {
|
|
446
|
-
header,
|
|
447
|
-
header.
|
|
448
|
-
header.layout-centered-
|
|
449
|
-
header.layout-
|
|
450
|
-
header.layout-extended-
|
|
451
|
-
header.layout-
|
|
555
|
+
header.has-header-end:not(.explicit-inline),
|
|
556
|
+
header:not(.explicit-inline),
|
|
557
|
+
header.layout-centered-brand:not(.explicit-inline),
|
|
558
|
+
header.layout-centered-menu:not(.explicit-inline),
|
|
559
|
+
header.layout-extended:not(.explicit-inline),
|
|
560
|
+
header.layout-extended-centered:not(.explicit-inline),
|
|
561
|
+
header.layout-minimal:not(.explicit-inline) {
|
|
452
562
|
grid-template-columns: minmax(0, 1fr) max-content;
|
|
453
563
|
grid-template-rows: min-content var(--_esp-header-current-height);
|
|
454
564
|
|
|
@@ -472,13 +582,15 @@ var a=function(h,e,t,o){var r=arguments.length,i=r<3?e:o===null?o=Object.getOwnP
|
|
|
472
582
|
}
|
|
473
583
|
|
|
474
584
|
|
|
475
|
-
:host([brand-align="center"])
|
|
476
|
-
|
|
585
|
+
:host([brand-align="center"])
|
|
586
|
+
header.layout-centered-menu:not(.explicit-inline)
|
|
587
|
+
section.brand,
|
|
588
|
+
:host([brand-align="end"]) header.layout-centered-menu:not(.explicit-inline) section.brand {
|
|
477
589
|
justify-self: stretch;
|
|
478
590
|
}
|
|
479
591
|
|
|
480
592
|
|
|
481
|
-
header.
|
|
593
|
+
header.primary-drawer section.menu-container,
|
|
482
594
|
header.layout-minimal section.menu-container {
|
|
483
595
|
display: block;
|
|
484
596
|
position: absolute;
|
|
@@ -496,4 +608,4 @@ var a=function(h,e,t,o){var r=arguments.length,i=r<3?e:o===null?o=Object.getOwnP
|
|
|
496
608
|
transition: none;
|
|
497
609
|
}
|
|
498
610
|
}
|
|
499
|
-
`],a([
|
|
611
|
+
`],a([f()],s.prototype,"menuOpen",void 0),a([f()],s.prototype,"navigationConstrained",void 0),a([f()],s.prototype,"menuTooLarge",void 0),a([f()],s.prototype,"mobileMenu",void 0),a([f()],s.prototype,"scrolled",void 0),a([f()],s.prototype,"hiddenByScroll",void 0),a([f()],s.prototype,"scrollProgress",void 0),a([l({attribute:"show-burger",type:Boolean})],s.prototype,"showBurger",void 0),a([l({converter:L.converter,reflect:!0})],s.prototype,"layout",void 0),a([l({attribute:"brand-text",type:String})],s.prototype,"brandText",void 0),a([l({attribute:"brand-logo",type:String})],s.prototype,"brandLogo",void 0),a([l({attribute:"light-brand-logo",type:String})],s.prototype,"lightBrandLogo",void 0),a([l({attribute:"dark-brand-logo",type:String})],s.prototype,"darkBrandLogo",void 0),a([l({attribute:"brand-href",type:String})],s.prototype,"brandHref",void 0),a([l({attribute:"brand-alt",type:String})],s.prototype,"brandAlt",void 0),a([l({attribute:"brand-color",type:String})],s.prototype,"brandColor",void 0),a([l({attribute:"light-brand-color",type:String})],s.prototype,"lightBrandColor",void 0),a([l({attribute:"dark-brand-color",type:String})],s.prototype,"darkBrandColor",void 0),a([l({attribute:"brand-align",converter:D.converter,reflect:!0})],s.prototype,"brandAlign",void 0),a([l({attribute:"brand-wrap",converter:S.converter,reflect:!0})],s.prototype,"brandWrap",void 0),a([l({attribute:"menu-display",converter:B.converter,reflect:!0})],s.prototype,"menuDisplay",void 0),a([l({attribute:"theme-toggle",converter:O.converter,reflect:!0})],s.prototype,"themeToggle",void 0),a([l({attribute:"scroll-behavior",type:String})],s.prototype,"scrollBehavior",void 0),a([l({attribute:"scroll-threshold",type:Number})],s.prototype,"scrollThreshold",void 0),a([l({attribute:"dock-offset",type:Number})],s.prototype,"dockOffset",void 0),a([l({attribute:"drawer-target",type:String})],s.prototype,"drawerTarget",void 0),a([l({attribute:!1})],s.prototype,"previewCollapseRequested",void 0),a([l({attribute:"full-bleed-content",type:Boolean,reflect:!0})],s.prototype,"fullBleedContent",void 0),s=a([V("esp-header")],s);export{s as EspalierHeader};
|
|
@@ -80,8 +80,7 @@ export declare class EspalierMenuGroup extends EspalierElementBase {
|
|
|
80
80
|
touchDevice: boolean;
|
|
81
81
|
/**
|
|
82
82
|
* Set by `esp-menu` for groups rendered in its full-screen drawer: the
|
|
83
|
-
* label
|
|
84
|
-
* inline end, so a linked group reads like the centered items around it.
|
|
83
|
+
* label and adjacent disclosure control center together across the row.
|
|
85
84
|
*/
|
|
86
85
|
fullScreenPresentation: boolean;
|
|
87
86
|
/**
|
|
@@ -91,6 +90,7 @@ export declare class EspalierMenuGroup extends EspalierElementBase {
|
|
|
91
90
|
urlPrefix: string;
|
|
92
91
|
connectedCallback(): void;
|
|
93
92
|
disconnectedCallback(): void;
|
|
93
|
+
protected willUpdate(changedProperties: PropertyValues): void;
|
|
94
94
|
protected firstUpdated(_changedProperties: PropertyValues): void;
|
|
95
95
|
protected updated(changedProperties: PropertyValues): void;
|
|
96
96
|
protected render(): TemplateResult<1>;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
var
|
|
1
|
+
var i=function(d,e,t,r){var a=arguments.length,n=a<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,h;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(d,e,t,r);else for(var l=d.length-1;l>=0;l--)(h=d[l])&&(n=(a<3?h(n):a>3?h(e,t,n):h(e,t))||n);return a>3&&n&&Object.defineProperty(e,t,n),n},g;import{MENU_SOURCE_CHANGED as w}from"./menu-presentation.js";import{css as x,html as p,nothing as c}from"lit";import{customElement as P,property as s,state as k}from"lit/decorators.js";import{classMap as S}from"lit/directives/class-map.js";import{createRef as m,ref as u}from"lit/directives/ref.js";import{EspalierElementBase as f}from"../shared/esp-element-base.js";import{ESP_EVENTS as z}from"../shared/events.js";import{getIconHrefForHost as E}from"../shared/intent-values.js";import{pathStartsWithSegment as v,pathsMatch as C}from"../shared/path-matching.js";import{SlottedIconController as L}from"../shared/slotted-icon-controller.js";import{renderSpriteIcon as $}from"../shared/svgs/render-sprite-icon.js";import{DEFAULT_NEW_TAB_LABEL as T,renderNewTabCue as D}from"../shared/new-tab-cue.js";import{PopoverController as U}from"../shared/popover-controller.js";import{viewportSize as B}from"../shared/viewport.js";import{srOnly as O}from"../shared/style-fragments.js";import{EspalierMenuItem as _}from"./esp-menu-item.js";let o=g=class extends f{constructor(){super(...arguments),this.itemsSlot=m(),this.toggleButton=m(),this.panel=m(),this.scrollPanelPresented=!1,this.panelPosition=new U({host:this,closeStrategy:"source-identity",isOpen:()=>this.scrollPanelPresented&&this.open,onShouldClose:()=>{},onPositionUpdate:()=>this.positionScrollPanel(),getPositionElements:()=>[this.toggleButton.value,this.panel.value,this.parentElement],trackShadowScroll:!0}),this.iconSlot=new L(this),this.openedByUrlPrefix=!1,this.dismissedUrlPrefix=!1,this.label="",this.url="",this.target="",this.rel="",this.newTabLabel=T,this.icon="",this.open=!1,this.mode="vertical",this.depth=0,this.scrollPanelEnabled=!1,this.touchDevice=!1,this.fullScreenPresentation=!1,this.active=!1,this.urlPrefix="",this.globalListenersActive=!1,this.handleDocumentClick=e=>{this.open&&(e.composedPath().includes(this)||this.setOpen(!1))},this.handleDocumentKeydown=e=>{!this.open||e.key!=="Escape"||(e.preventDefault(),this.setOpen(!1),this.toggleButton.value?.focus())}}connectedCallback(){super.connectedCallback(),this.checkActive()}disconnectedCallback(){const e=this.scrollPanelEnabled||this.scrollPanelPresented;this.closeScrollPanel(),e&&(this.scrollPanelEnabled=!1,this.open=!1),super.disconnectedCallback(),this.removeGlobalDismissListeners()}willUpdate(e){super.willUpdate(e),!this.usesScrollPanel&&(this.scrollPanelPresented||e.get("scrollPanelEnabled")===!0)&&(this.closeScrollPanel(),this.setOpen(!1))}firstUpdated(e){super.firstUpdated(e),this.propagateToChildren()}updated(e){super.updated(e),["label","url","target","rel","newTabLabel","icon","open"].some(t=>e.has(t))&&this.dispatchEvent(new CustomEvent(w,{bubbles:!0,composed:!0})),(e.has("mode")||e.has("depth")||e.has("touchDevice"))&&this.propagateToChildren(),(e.has("mode")||e.has("depth")||e.has("urlPrefix"))&&this.syncUrlPrefixExpansion(),e.has("url")&&this.checkActive(),e.has("open")&&!this.open&&(this.openedByUrlPrefix=!1),this.syncScrollPanel(),(e.has("open")||e.has("mode")||e.has("depth"))&&(this.open&&this.isHorizontalTopLevel?this.addGlobalDismissListeners():this.removeGlobalDismissListeners())}checkActive(){if(!this.url){this.active=!1;return}this.active=C(this.url)}get isHorizontalTopLevel(){return this.mode==="horizontal"&&this.depth===0}get usesScrollPanel(){return this.scrollPanelEnabled&&this.isHorizontalTopLevel}syncScrollPanel(){if(!this.open||!this.usesScrollPanel||!this.isConnected){this.closeScrollPanel();return}const e=this.panel.value;if(!(!e||this.scrollPanelPresented)){try{e.showPopover()}catch{this.setOpen(!1);return}this.scrollPanelPresented=!0,this.positionScrollPanel(),this.panelPosition.startTracking()}}closeScrollPanel(){if(this.panelPosition.stopTracking(),!this.scrollPanelPresented)return;this.scrollPanelPresented=!1;const e=this.panel.value;try{e?.hidePopover()}catch{}e?.style.removeProperty("left"),e?.style.removeProperty("top"),e?.style.removeProperty("max-height")}positionScrollPanel(){const e=this.panel.value,t=this.toggleButton.value;if(!this.scrollPanelPresented||!e||!t)return;const r=t.getBoundingClientRect(),a=B(),n=Math.max(0,a.height-r.bottom),h=Math.max(0,r.top);e.style.maxHeight=`min(70vh, 36rem, ${Math.max(h,n)}px)`;const l=e.getBoundingClientRect(),b=getComputedStyle(this).direction==="rtl"?r.right-l.width:r.left,y=l.height<=n||n>=h?r.bottom:r.top-l.height;e.style.left=`${Math.max(0,Math.min(b,a.width-l.width))}px`,e.style.top=`${Math.max(0,Math.min(y,a.height-l.height))}px`}get childMode(){return this.mode==="horizontal"?"vertical":this.mode}syncUrlPrefixExpansion(){const e=v(location.pathname,this.urlPrefix);if(e||(this.dismissedUrlPrefix=!1),e&&!this.dismissedUrlPrefix&&!this.isHorizontalTopLevel){this.open||(this.open=!0,this.openedByUrlPrefix=!0);return}this.openedByUrlPrefix&&(this.open=!1,this.openedByUrlPrefix=!1)}getChildren(){return this.itemsSlot.value?Array.from(this.itemsSlot.value.assignedElements()):[]}propagateToChildren(){for(const e of this.getChildren())e instanceof _?(e.mode=this.childMode,e.depth=this.depth+1,e.touchDevice=this.touchDevice):e instanceof g&&(e.mode=this.childMode,e.depth=this.depth+1,e.touchDevice=this.touchDevice)}handleSlotChange(){this.propagateToChildren()}setOpen(e){this.open!==e&&(this.openedByUrlPrefix=!1,this.dismissedUrlPrefix=!e&&v(location.pathname,this.urlPrefix),this.open=e,this.dispatchEvent(new CustomEvent(z.MENU_GROUP_TOGGLE,{detail:{open:this.open},bubbles:!0,composed:!0})))}handleHeaderClick(e){this.mode==="drawer"&&!e.composedPath().some(t=>t instanceof HTMLElement&&t.classList.contains("group-icon"))||this.toggleOpen()}handleLinkClick(e){e.stopPropagation()}handleToggleClick(e){e.stopPropagation(),this.toggleOpen()}toggleOpen(){this.setOpen(!this.open)}handleGroupKeydown(e){e.key==="Escape"&&this.open&&(e.preventDefault(),e.stopPropagation(),this.setOpen(!1),this.toggleButton.value?.focus())}addGlobalDismissListeners(){this.globalListenersActive||(document.addEventListener("click",this.handleDocumentClick,!0),document.addEventListener("keydown",this.handleDocumentKeydown),this.globalListenersActive=!0)}removeGlobalDismissListeners(){this.globalListenersActive&&(document.removeEventListener("click",this.handleDocumentClick,!0),document.removeEventListener("keydown",this.handleDocumentKeydown),this.globalListenersActive=!1)}renderIcon(){const e=E(this.icon,this),t=this.iconSlot.hasSlottedIcon();return p`
|
|
2
2
|
<slot
|
|
3
3
|
name="icon"
|
|
4
|
-
${
|
|
4
|
+
${u(this.iconSlot.slotRef)}
|
|
5
5
|
@slotchange=${this.iconSlot.handleSlotChange}
|
|
6
6
|
></slot>
|
|
7
|
-
${!
|
|
8
|
-
`}renderToggle(e){return
|
|
9
|
-
${
|
|
7
|
+
${!t&&e?$(e):c}
|
|
8
|
+
`}renderToggle(e){return p`<button
|
|
9
|
+
${u(this.toggleButton)}
|
|
10
10
|
class="group-toggle"
|
|
11
11
|
type="button"
|
|
12
12
|
aria-expanded=${this.open?"true":"false"}
|
|
@@ -14,38 +14,40 @@ var o=function(l,e,i,a){var p=arguments.length,s=p<3?e:a===null?a=Object.getOwnP
|
|
|
14
14
|
@click=${this.handleToggleClick}
|
|
15
15
|
>
|
|
16
16
|
${e}<span class="indicator" aria-hidden="true"></span>
|
|
17
|
-
</button>`}render(){const e={group:!0,"is-horizontal":this.isHorizontalTopLevel,"is-vertical":!this.isHorizontalTopLevel,"is-nested":this.depth>0,"is-drawer":this.mode==="drawer","is-open":this.open,"is-active":this.active,"has-icon":this.icon.length>0||this.iconSlot.hasSlottedIcon()},
|
|
18
|
-
<span class="current-page" aria-current="page">${
|
|
19
|
-
${this.renderToggle(
|
|
20
|
-
`:
|
|
17
|
+
</button>`}render(){const e={group:!0,"is-horizontal":this.isHorizontalTopLevel,"is-vertical":!this.isHorizontalTopLevel,"is-nested":this.depth>0,"is-drawer":this.mode==="drawer","is-open":this.open,"is-active":this.active,"has-icon":this.icon.length>0||this.iconSlot.hasSlottedIcon()},t=p`<span class="group-label-text" part="menu-text">${this.label}</span>`,r=this.url?this.active?p`
|
|
18
|
+
<span class="current-page" aria-current="page">${t}</span>
|
|
19
|
+
${this.renderToggle(p`<span class="sr-only">Toggle ${this.label}</span>`)}
|
|
20
|
+
`:p`
|
|
21
21
|
<a
|
|
22
22
|
class="group-link"
|
|
23
23
|
href=${this.url}
|
|
24
|
-
target=${this.target||
|
|
25
|
-
rel=${this.rel||
|
|
24
|
+
target=${this.target||c}
|
|
25
|
+
rel=${this.rel||c}
|
|
26
26
|
@click=${this.handleLinkClick}
|
|
27
|
-
>${
|
|
27
|
+
>${t}${D(this.target,this.newTabLabel)}</a
|
|
28
28
|
>
|
|
29
|
-
${this.renderToggle(
|
|
30
|
-
`:this.renderToggle(
|
|
31
|
-
<div class=${
|
|
29
|
+
${this.renderToggle(p`<span class="sr-only">Toggle ${this.label}</span>`)}
|
|
30
|
+
`:this.renderToggle(t);return p`
|
|
31
|
+
<div class=${S(e)} @keydown=${this.handleGroupKeydown}>
|
|
32
32
|
<div class="group-header" @click=${this.handleHeaderClick}>
|
|
33
|
-
<span class="group-label">${
|
|
33
|
+
<span class="group-label">${r}</span>
|
|
34
34
|
<span class="group-icon" aria-hidden="true">${this.renderIcon()}</span>
|
|
35
35
|
</div>
|
|
36
36
|
<div
|
|
37
37
|
id="group-items"
|
|
38
|
+
${u(this.panel)}
|
|
38
39
|
class="group-items"
|
|
40
|
+
popover=${this.usesScrollPanel?"manual":c}
|
|
39
41
|
?hidden=${this.isHorizontalTopLevel&&!this.open}
|
|
40
42
|
?inert=${!this.open}
|
|
41
|
-
aria-hidden=${this.open?
|
|
43
|
+
aria-hidden=${this.open?c:"true"}
|
|
42
44
|
>
|
|
43
45
|
<div class="group-items-inner">
|
|
44
|
-
<slot ${
|
|
46
|
+
<slot ${u(this.itemsSlot)} @slotchange=${this.handleSlotChange}></slot>
|
|
45
47
|
</div>
|
|
46
48
|
</div>
|
|
47
49
|
</div>
|
|
48
|
-
`}};
|
|
50
|
+
`}};o.styles=[...f.styles,O,x`
|
|
49
51
|
:host {
|
|
50
52
|
display: block;
|
|
51
53
|
position: relative;
|
|
@@ -153,32 +155,30 @@ var o=function(l,e,i,a){var p=arguments.length,s=p<3?e:a===null?a=Object.getOwnP
|
|
|
153
155
|
text-decoration: underline;
|
|
154
156
|
}
|
|
155
157
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
158
|
+
.is-drawer .group-label > .group-toggle:only-child,
|
|
159
|
+
.is-drawer .group-link + .group-toggle,
|
|
160
|
+
.is-drawer .current-page + .group-toggle {
|
|
161
|
+
flex: 0 0 auto;
|
|
162
|
+
width: auto;
|
|
159
163
|
}
|
|
160
164
|
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
165
|
+
.is-drawer .group-label > .group-toggle:only-child {
|
|
166
|
+
flex-shrink: 1;
|
|
167
|
+
max-width: 100%;
|
|
164
168
|
}
|
|
165
169
|
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
+
.is-drawer .group-items-inner {
|
|
171
|
+
min-width: 0;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
:host([full-screen-presentation]) .group-label {
|
|
170
176
|
justify-content: center;
|
|
171
|
-
padding: var(--esp-menu-item-padding, var(--esp-size-small) var(--esp-size-padding));
|
|
172
177
|
}
|
|
173
178
|
|
|
174
|
-
:host([full-screen-presentation]) .group-link
|
|
175
|
-
:host([full-screen-presentation]) .current-page
|
|
176
|
-
|
|
177
|
-
inset-block: 0;
|
|
178
|
-
inset-inline-end: 0;
|
|
179
|
-
flex: none;
|
|
180
|
-
width: auto;
|
|
181
|
-
padding-inline: var(--esp-size-small);
|
|
179
|
+
:host([full-screen-presentation]) .group-link,
|
|
180
|
+
:host([full-screen-presentation]) .current-page {
|
|
181
|
+
padding-inline-start: var(--esp-size-normal);
|
|
182
182
|
}
|
|
183
183
|
|
|
184
184
|
.group-toggle:focus-visible,
|
|
@@ -277,6 +277,18 @@ var o=function(l,e,i,a){var p=arguments.length,s=p<3?e:a===null?a=Object.getOwnP
|
|
|
277
277
|
box-shadow: var(--esp-menu-group-panel-shadow, 0 4px 12px var(--esp-color-shadow));
|
|
278
278
|
}
|
|
279
279
|
|
|
280
|
+
.is-horizontal > .group-items[popover] {
|
|
281
|
+
position: fixed;
|
|
282
|
+
inset: auto;
|
|
283
|
+
margin: 0;
|
|
284
|
+
padding: 0;
|
|
285
|
+
box-sizing: border-box;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
.is-horizontal > .group-items[popover]:not(:popover-open) {
|
|
289
|
+
display: none;
|
|
290
|
+
}
|
|
291
|
+
|
|
280
292
|
.is-horizontal > .group-items[hidden] {
|
|
281
293
|
display: none;
|
|
282
294
|
}
|
|
@@ -292,4 +304,4 @@ var o=function(l,e,i,a){var p=arguments.length,s=p<3?e:a===null?a=Object.getOwnP
|
|
|
292
304
|
transition: none;
|
|
293
305
|
}
|
|
294
306
|
}
|
|
295
|
-
`],
|
|
307
|
+
`],i([s({type:String})],o.prototype,"label",void 0),i([s({type:String})],o.prototype,"url",void 0),i([s({type:String})],o.prototype,"target",void 0),i([s({type:String})],o.prototype,"rel",void 0),i([s({type:String,attribute:"new-tab-label"})],o.prototype,"newTabLabel",void 0),i([s({type:String})],o.prototype,"icon",void 0),i([s({type:Boolean,reflect:!0})],o.prototype,"open",void 0),i([s({attribute:!1,type:String})],o.prototype,"mode",void 0),i([s({attribute:!1,type:Number})],o.prototype,"depth",void 0),i([s({attribute:!1})],o.prototype,"scrollPanelEnabled",void 0),i([s({attribute:!1,type:Boolean})],o.prototype,"touchDevice",void 0),i([s({attribute:"full-screen-presentation",type:Boolean,reflect:!0})],o.prototype,"fullScreenPresentation",void 0),i([k()],o.prototype,"active",void 0),i([s({type:String,attribute:"url-prefix"})],o.prototype,"urlPrefix",void 0),o=g=i([P("esp-menu-group")],o);export{o as EspalierMenuGroup};
|
|
@@ -74,6 +74,20 @@ export declare class EspalierMenuItem extends EspalierElementBase {
|
|
|
74
74
|
newTabLabel: string;
|
|
75
75
|
/** Optional icon name from the configured Espalier SVG sprite. */
|
|
76
76
|
icon: string;
|
|
77
|
+
/**
|
|
78
|
+
* Prefer logical inline end before the header controls. Only direct links
|
|
79
|
+
* in an owning header's primary horizontal menu are promoted. Standalone,
|
|
80
|
+
* nested and button items remain ordinary menu content. Collapsed links
|
|
81
|
+
* return to the same drawer in their original source order.
|
|
82
|
+
* Put shared navigation tokens and context on the header or a common ancestor.
|
|
83
|
+
* Menu/item inline public presentation tokens and explicit typography are
|
|
84
|
+
* forwarded; their variables
|
|
85
|
+
* must resolve through that shared chain or the forwarded public tokens.
|
|
86
|
+
* Source-only selectors, stylesheet typography, context/intent zones and
|
|
87
|
+
* non-public variables local to the menu/item are not forwarded.
|
|
88
|
+
* @default false
|
|
89
|
+
*/
|
|
90
|
+
headerEnd: boolean;
|
|
77
91
|
/** Render mode supplied by the parent `esp-menu` or `esp-menu-group`. */
|
|
78
92
|
mode: EspalierMenuMode;
|
|
79
93
|
/** Nesting depth supplied by the parent. */
|
|
@@ -84,6 +98,7 @@ export declare class EspalierMenuItem extends EspalierElementBase {
|
|
|
84
98
|
*/
|
|
85
99
|
touchDevice: boolean;
|
|
86
100
|
connectedCallback(): void;
|
|
101
|
+
disconnectedCallback(): void;
|
|
87
102
|
protected updated(changedProperties: PropertyValues): void;
|
|
88
103
|
protected render(): import("lit-html").TemplateResult<1>;
|
|
89
104
|
static styles: import("lit").CSSResult[];
|