@taprootio/espalier 2.0.2 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -144,6 +144,8 @@ type HeaderThemeToggle = "hidden" | "visible";
144
144
  * @cssprop --esp-header-height - The height of the header bar. Defaults to `calc(4.5 * var(--esp-size-small))`.
145
145
  * @cssprop --esp-header-color - The text/icon color inherited by header controls. Defaults to `var(--esp-color-text)`.
146
146
  * @cssprop --esp-header-z-index - The z-index of the header host. Defaults to `20`.
147
+ * @cssprop --esp-header-content-max-width - Surface-alignment contract set by `esp-page`: the maximum width the bar content is constrained to (the bar background stays full-bleed). Defaults to `100%` (no constraint). `esp-page` sets this to its resolved content cap.
148
+ * @cssprop --esp-header-content-lead - Surface-alignment contract set by `esp-page`: the fraction of the leftover width placed before the content, aligning it (`0` = start, `0.5` = center, `1` = end). Defaults to `0`.
147
149
  * @cssprop --esp-header-compact-height - The height of compact scroll-reactive headers. Defaults to `max(44px, calc(3.5 * var(--esp-size-small)))`.
148
150
  * @cssprop --esp-header-extended-menu-height - The second-row menu height for extended layouts. Defaults to `calc(3.5 * var(--esp-size-small))`.
149
151
  * @cssprop --esp-header-extended-menu-border - The border between the primary row and second-row menu in extended layouts. Defaults to `1px solid var(--esp-color-border)`.
@@ -306,6 +308,15 @@ export declare class EspalierHeader extends EspalierElementBase {
306
308
  * menu slotted into the header.
307
309
  */
308
310
  drawerTarget: string;
311
+ /**
312
+ * Opt out of surface alignment. When an `esp-header` is slotted into an
313
+ * `esp-page`, it constrains its bar content to the page's content
314
+ * surface by default (the bar background stays full-bleed). Set this to
315
+ * let the content span the full width instead, as it did before the
316
+ * page grew alignment modes. Standalone headers (outside `esp-page`) are
317
+ * already full-bleed and unaffected.
318
+ */
319
+ fullBleedContent: boolean;
309
320
  /**
310
321
  * The burger element inside the header. External code can use
311
322
  * this to programmatically reset the burger's visual state
@@ -1,8 +1,8 @@
1
- var n=function(p,e,t,o){var s=arguments.length,a=s<3?e:o===null?o=Object.getOwnPropertyDescriptor(e,t):o,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(p,e,t,o);else for(var h=p.length-1;h>=0;h--)(i=p[h])&&(a=(s<3?i(a):s>3?i(e,t,a):i(e,t))||a);return s>3&&a&&Object.defineProperty(e,t,a),a};import{css as y,html as d,nothing as c}from"lit";import{customElement as x,property as l,state as u}from"lit/decorators.js";import{classMap as M}from"lit/directives/class-map.js";import{styleMap as S}from"lit/directives/style-map.js";import"../burger/esp-burger.js";import{createRef as b,ref as v}from"lit/directives/ref.js";import{EspalierMenu as T}from"./esp-menu.js";import{EspalierElementBase as f}from"../shared/esp-element-base.js";const D="(max-width: 36rem)";let r=class extends f{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="standard",this.brandText="",this.brandLogo="",this.brandHref="",this.brandAlt="",this.brandColor="",this.brandAlign="start",this.brandWrap="truncate",this.menuDisplay="auto",this.themeToggle="hidden",this.scrollBehavior="none",this.scrollThreshold=16,this.dockOffset=0,this.drawerTarget="",this.menuContainer=b(),this.menuButton=b(),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.scrollRafId=null,this.resizeObserver=new ResizeObserver(()=>this.syncMenuLayout()),this.updateScrollState=()=>{this.scrollRafId===null&&(this.scrollRafId=requestAnimationFrame(()=>{this.scrollRafId=null,this.runScrollStateUpdate()}))},this.handleMobileMenuQueryChange=e=>{this.mobileMenu=e.matches,this.syncMenuLayout()},this.toggleTheme=()=>{const e=this.getThemeRoot();e&&(e.scheme=e.scheme==="dark"?"light":"dark")},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)}}syncMenuLayout(){if(!this.menuContainer.value||!this.menu||!this.menu.getWidth)return;const e=this.menuContainer.value.clientWidth,t=this.menu.getWidth();t>0&&(this.lastInlineMenuWidth=t);const o=this.lastInlineMenuWidth||t,s=this.getExternalDrawerTarget(),a=this.menuDisplay!=="inline",i=this.showBurger||this.menuDisplay==="drawer"||this.layout==="minimal";this.menuTooLarge=a&&this.menuDisplay==="auto"&&o>e,this.menu.sliding=a&&!s&&(this.menuTooLarge||i||this.mobileMenu)}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(),s=Number.isFinite(this.dockOffset)?Math.max(0,this.dockOffset):o,a=t>(e.has("dock")?s:o),i=t>this.lastScrollY,h=e.has("reveal")&&i&&t>o&&!this.menuOpen;if(this.scrolled=a,this.hiddenByScroll=h,e.has("progress")){const m=document.documentElement,g=Math.max(1,m.scrollHeight-window.innerHeight);this.scrollProgress=Math.min(1,t/g)}else this.scrollProgress=0;this.lastScrollY=t}cancelScrollUpdate(){this.scrollRafId!==null&&(cancelAnimationFrame(this.scrollRafId),this.scrollRafId=null)}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("drawer-opened",this.onMenuDrawerOpened),this.menu.addEventListener("drawer-closed",this.onMenuDrawerClosed),this.menuDrawerListenersAttached=!0)}removeMenuDrawerListeners(){!this.menu||!this.menuDrawerListenersAttached||(this.menu.removeEventListener("drawer-opened",this.onMenuDrawerOpened),this.menu.removeEventListener("drawer-closed",this.onMenuDrawerClosed),this.menuDrawerListenersAttached=!1)}observeMenuContainer(){!this.menuContainer.value||this.observingMenuContainer||(this.resizeObserver.observe(this.menuContainer.value),this.observingMenuContainer=!0)}disconnectResizeObserver(){this.observingMenuContainer&&(this.resizeObserver.disconnect(),this.observingMenuContainer=!1)}syncMobileMenuQuery(){if("matchMedia"in window){if(!this.mobileMenuQuery){this.mobileMenuQuery=window.matchMedia(D),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("drawer-opened",this.onMenuDrawerOpened),this.externalDrawerTarget?.removeEventListener("drawer-closed",this.onMenuDrawerClosed),this.externalDrawerTarget=t,this.externalDrawerTarget?.addEventListener("drawer-opened",this.onMenuDrawerOpened),this.externalDrawerTarget?.addEventListener("drawer-closed",this.onMenuDrawerClosed))}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.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);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"))}get burger(){return this.menuButton.value??void 0}firstUpdated(e){if(super.firstUpdated(e),!this.menuContainer.value)return;const s=(this.menuContainer.value.firstElementChild?.assignedElements()??[])[0];s instanceof T?(this.menu=s,this.addMenuDrawerListeners()):s&&console.warn("<esp-header>: the menu slot expects an <esp-menu> element, received",s),this.observeMenuContainer(),this.syncExternalDrawerTarget(),this.syncMobileMenuQuery(),this.syncScrollListeners(),this.syncMenuLayout()}updated(e){super.updated(e),(e.has("showBurger")||e.has("drawerTarget")||e.has("menuDisplay")||e.has("layout"))&&(this.syncExternalDrawerTarget(),this.syncMenuLayout()),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()}disconnectedCallback(){this.removeMenuDrawerListeners(),this.externalDrawerTarget?.removeEventListener("drawer-opened",this.onMenuDrawerOpened),this.externalDrawerTarget?.removeEventListener("drawer-closed",this.onMenuDrawerClosed),this.externalDrawerTarget=null,this.mobileMenuQuery?.removeEventListener("change",this.handleMobileMenuQueryChange),this.mobileMenuQuery=null,this.removeScrollListeners(),this.cancelScrollUpdate(),this.disconnectResizeObserver(),super.disconnectedCallback()}renderConfiguredBrand(){if(!this.brandLogo&&!this.brandText)return c;const e=this.brandAlt||(this.brandText?"":"Site logo"),t=d`
1
+ var n=function(p,e,t,o){var s=arguments.length,i=s<3?e:o===null?o=Object.getOwnPropertyDescriptor(e,t):o,l;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(p,e,t,o);else for(var h=p.length-1;h>=0;h--)(l=p[h])&&(i=(s<3?l(i):s>3?l(e,t,i):l(e,t))||i);return s>3&&i&&Object.defineProperty(e,t,i),i};import{css as x,html as d,nothing as c}from"lit";import{customElement as D,property as a,state as u}from"lit/decorators.js";import{classMap as M}from"lit/directives/class-map.js";import{styleMap as T}from"lit/directives/style-map.js";import"../burger/esp-burger.js";import{createRef as f,ref as v}from"lit/directives/ref.js";import{EspalierMenu as m}from"./esp-menu.js";import{EspalierElementBase as w}from"../shared/esp-element-base.js";const S="(max-width: 36rem)";let r=class extends w{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="standard",this.brandText="",this.brandLogo="",this.brandHref="",this.brandAlt="",this.brandColor="",this.brandAlign="start",this.brandWrap="truncate",this.menuDisplay="auto",this.themeToggle="hidden",this.scrollBehavior="none",this.scrollThreshold=16,this.dockOffset=0,this.drawerTarget="",this.fullBleedContent=!1,this.menuContainer=f(),this.menuButton=f(),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.scrollRafId=null,this.resizeObserver=new ResizeObserver(()=>this.syncMenuLayout()),this.menuChildObserver=null,this.updateScrollState=()=>{this.scrollRafId===null&&(this.scrollRafId=requestAnimationFrame(()=>{this.scrollRafId=null,this.runScrollStateUpdate()}))},this.handleMobileMenuQueryChange=e=>{this.mobileMenu=e.matches,this.syncMenuLayout(),this.syncExternalDrawerControl()},this.toggleTheme=()=>{const e=this.getThemeRoot();e&&(e.scheme=e.scheme==="dark"?"light":"dark")},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)}}syncMenuLayout(){if(!this.menuContainer.value||!this.menu||!this.menu.getWidth)return;const e=this.menuContainer.value.clientWidth,t=this.menu.getWidth();t>0&&(this.lastInlineMenuWidth=t);const o=this.lastInlineMenuWidth||t,s=this.getExternalDrawerTarget(),i=this.menuDisplay!=="inline",l=this.showBurger||this.menuDisplay==="drawer"||this.layout==="minimal";this.menuTooLarge=i&&this.menuDisplay==="auto"&&o>e,this.menu.sliding=i&&!s&&this.hasDrawerableContent()&&(this.menuTooLarge||l||this.mobileMenu)}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(),s=Number.isFinite(this.dockOffset)?Math.max(0,this.dockOffset):o,i=t>(e.has("dock")?s:o),l=t>this.lastScrollY,h=e.has("reveal")&&l&&t>o&&!this.menuOpen;if(this.scrolled=i,this.hiddenByScroll=h,e.has("progress")){const g=document.documentElement,b=Math.max(1,g.scrollHeight-window.innerHeight);this.scrollProgress=Math.min(1,t/b)}else this.scrollProgress=0;this.lastScrollY=t}cancelScrollUpdate(){this.scrollRafId!==null&&(cancelAnimationFrame(this.scrollRafId),this.scrollRafId=null)}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("drawer-opened",this.onMenuDrawerOpened),this.menu.addEventListener("drawer-closed",this.onMenuDrawerClosed),this.menuDrawerListenersAttached=!0)}removeMenuDrawerListeners(){!this.menu||!this.menuDrawerListenersAttached||(this.menu.removeEventListener("drawer-opened",this.onMenuDrawerOpened),this.menu.removeEventListener("drawer-closed",this.onMenuDrawerClosed),this.menuDrawerListenersAttached=!1)}observeMenuContainer(){!this.menuContainer.value||this.observingMenuContainer||(this.resizeObserver.observe(this.menuContainer.value),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(S),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("drawer-opened",this.onMenuDrawerOpened),this.externalDrawerTarget?.removeEventListener("drawer-closed",this.onMenuDrawerClosed),this.externalDrawerTarget instanceof m&&(this.externalDrawerTarget.hasExternalDrawerControl=!1),this.externalDrawerTarget=t,this.externalDrawerTarget?.addEventListener("drawer-opened",this.onMenuDrawerOpened),this.externalDrawerTarget?.addEventListener("drawer-closed",this.onMenuDrawerClosed)),this.syncExternalDrawerControl()}burgerVisibleForTarget(){if(this.menuDisplay==="inline")return!1;const e=this.showBurger||this.menuDisplay==="drawer"||this.layout==="minimal";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.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);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"))}get burger(){return this.menuButton.value??void 0}firstUpdated(e){if(super.firstUpdated(e),!this.menuContainer.value)return;const s=(this.menuContainer.value.firstElementChild?.assignedElements()??[])[0];s instanceof m?(this.menu=s,this.addMenuDrawerListeners(),this.observeMenuChildren()):s&&console.warn("<esp-header>: the menu slot expects an <esp-menu> element, received",s),this.observeMenuContainer(),this.syncExternalDrawerTarget(),this.syncMobileMenuQuery(),this.syncScrollListeners(),this.syncMenuLayout()}updated(e){super.updated(e),(e.has("showBurger")||e.has("drawerTarget")||e.has("menuDisplay")||e.has("layout"))&&(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("drawer-opened",this.onMenuDrawerOpened),this.externalDrawerTarget?.removeEventListener("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.menuChildObserver?.disconnect(),this.menuChildObserver=null,super.disconnectedCallback()}renderConfiguredBrand(){if(!this.brandLogo&&!this.brandText)return c;const e=this.brandAlt||(this.brandText?"":"Site logo"),t=d`
2
2
  ${this.brandLogo?d`<img class="brand-logo" src=${this.brandLogo} alt=${e} />`:c}
3
3
  ${this.brandText?d`<span class="brand-text">${this.brandText}</span>`:c}
4
- `;return this.brandHref?d`<a class="configured-brand" href=${this.brandHref}>${t}</a>`:d`<span class="configured-brand">${t}</span>`}render(){const{menuOpen:e,menuTooLarge:t,mobileMenu:o}=this,s=this.menuDisplay!=="inline",a=s&&(this.showBurger||this.menuDisplay==="drawer"||this.layout==="minimal"),i=this.getScrollTokens(),h=i.has("progress"),m={"--_esp-header-brand-color":this.brandColor||null,"--_esp-header-scroll-progress":String(this.scrollProgress)},g={"menu-open":e,"too-wide":s&&(t||o||a),[`layout-${this.layout}`]:!0,"is-scrolled":this.scrolled,"hide-on-scroll":this.hiddenByScroll,"scroll-compact":i.has("compact"),"scroll-elevate":i.has("elevate"),"scroll-transparent":i.has("transparent")||i.has("transparent-to-solid"),"scroll-collapse-topbar":i.has("collapse-topbar")},w=this.scheme==="dark"?"light":"dark";return d`
5
- <header class=${M(g)} style=${S(m)}>
4
+ `;return this.brandHref?d`<a class="configured-brand" href=${this.brandHref}>${t}</a>`:d`<span class="configured-brand">${t}</span>`}render(){const{menuOpen:e,menuTooLarge:t,mobileMenu:o}=this,s=this.menuDisplay!=="inline",i=s&&(this.showBurger||this.menuDisplay==="drawer"||this.layout==="minimal"),l=this.getScrollTokens(),h=l.has("progress"),g={"--_esp-header-brand-color":this.brandColor||null,"--_esp-header-scroll-progress":String(this.scrollProgress)},b={"menu-open":e,"too-wide":s&&this.hasDrawerableContent()&&(t||o||i),[`layout-${this.layout}`]:!0,"is-scrolled":this.scrolled,"hide-on-scroll":this.hiddenByScroll,"scroll-compact":l.has("compact"),"scroll-elevate":l.has("elevate"),"scroll-transparent":l.has("transparent")||l.has("transparent-to-solid"),"scroll-collapse-topbar":l.has("collapse-topbar")},y=this.scheme==="dark"?"light":"dark";return d`
5
+ <header class=${M(b)} style=${T(g)}>
6
6
  <section class="topbar">
7
7
  <slot name="topbar"></slot>
8
8
  </section>
@@ -20,7 +20,7 @@ var n=function(p,e,t,o){var s=arguments.length,a=s<3?e:o===null?o=Object.getOwnP
20
20
  ${this.themeToggle==="visible"?d`<esp-header-button
21
21
  class="theme-toggle"
22
22
  icon=${this.scheme==="dark"?"sun":"moon"}
23
- aria-label=${`Switch to ${w} mode`}
23
+ aria-label=${`Switch to ${y} mode`}
24
24
  @clicked=${this.toggleTheme}
25
25
  ></esp-header-button>`:c}
26
26
  <esp-header-button
@@ -36,7 +36,7 @@ var n=function(p,e,t,o){var s=arguments.length,a=s<3?e:o===null?o=Object.getOwnP
36
36
  </section>
37
37
  ${h?d`<div class="scroll-progress" aria-hidden="true"></div>`:c}
38
38
  </header>
39
- `}};r.styles=[...f.styles,y`
39
+ `}};r.styles=[...w.styles,x`
40
40
  :host {
41
41
  --_esp-header-current-height: var(--esp-header-height, calc(4.5 * var(--esp-size-small)));
42
42
 
@@ -51,6 +51,14 @@ var n=function(p,e,t,o){var s=arguments.length,a=s<3?e:o===null?o=Object.getOwnP
51
51
  var(--esp-header-brand-color, var(--esp-color-headings))
52
52
  );
53
53
 
54
+
55
+ --_esp-header-content-surplus: max(
56
+ 0px,
57
+ calc(100% - var(--esp-header-content-max-width, 100%))
58
+ );
59
+ padding-inline: calc(var(--_esp-header-content-surplus) * var(--esp-header-content-lead, 0))
60
+ calc(var(--_esp-header-content-surplus) * (1 - var(--esp-header-content-lead, 0)));
61
+
54
62
  display: grid;
55
63
  grid-template-columns: minmax(0, max-content) minmax(0, 1fr) max-content;
56
64
  grid-template-rows: min-content var(--_esp-header-current-height);
@@ -349,6 +357,11 @@ var n=function(p,e,t,o){var s=arguments.length,a=s<3?e:o===null?o=Object.getOwnP
349
357
  }
350
358
  }
351
359
 
360
+
361
+ :host([full-bleed-content]) header {
362
+ padding-inline: 0;
363
+ }
364
+
352
365
  :host([brand-align="center"]) header section.brand {
353
366
  justify-content: center;
354
367
  text-align: center;
@@ -418,4 +431,4 @@ var n=function(p,e,t,o){var s=arguments.length,a=s<3?e:o===null?o=Object.getOwnP
418
431
  transition: none;
419
432
  }
420
433
  }
421
- `],n([u()],r.prototype,"menuOpen",void 0),n([u()],r.prototype,"menuTooLarge",void 0),n([u()],r.prototype,"mobileMenu",void 0),n([u()],r.prototype,"scrolled",void 0),n([u()],r.prototype,"hiddenByScroll",void 0),n([u()],r.prototype,"scrollProgress",void 0),n([l({attribute:"show-burger",type:Boolean})],r.prototype,"showBurger",void 0),n([l({type:String,reflect:!0})],r.prototype,"layout",void 0),n([l({attribute:"brand-text",type:String})],r.prototype,"brandText",void 0),n([l({attribute:"brand-logo",type:String})],r.prototype,"brandLogo",void 0),n([l({attribute:"brand-href",type:String})],r.prototype,"brandHref",void 0),n([l({attribute:"brand-alt",type:String})],r.prototype,"brandAlt",void 0),n([l({attribute:"brand-color",type:String})],r.prototype,"brandColor",void 0),n([l({attribute:"brand-align",type:String,reflect:!0})],r.prototype,"brandAlign",void 0),n([l({attribute:"brand-wrap",type:String,reflect:!0})],r.prototype,"brandWrap",void 0),n([l({attribute:"menu-display",type:String,reflect:!0})],r.prototype,"menuDisplay",void 0),n([l({attribute:"theme-toggle",type:String,reflect:!0})],r.prototype,"themeToggle",void 0),n([l({attribute:"scroll-behavior",type:String})],r.prototype,"scrollBehavior",void 0),n([l({attribute:"scroll-threshold",type:Number})],r.prototype,"scrollThreshold",void 0),n([l({attribute:"dock-offset",type:Number})],r.prototype,"dockOffset",void 0),n([l({attribute:"drawer-target",type:String})],r.prototype,"drawerTarget",void 0),r=n([x("esp-header")],r);export{r as EspalierHeader};
434
+ `],n([u()],r.prototype,"menuOpen",void 0),n([u()],r.prototype,"menuTooLarge",void 0),n([u()],r.prototype,"mobileMenu",void 0),n([u()],r.prototype,"scrolled",void 0),n([u()],r.prototype,"hiddenByScroll",void 0),n([u()],r.prototype,"scrollProgress",void 0),n([a({attribute:"show-burger",type:Boolean})],r.prototype,"showBurger",void 0),n([a({type:String,reflect:!0})],r.prototype,"layout",void 0),n([a({attribute:"brand-text",type:String})],r.prototype,"brandText",void 0),n([a({attribute:"brand-logo",type:String})],r.prototype,"brandLogo",void 0),n([a({attribute:"brand-href",type:String})],r.prototype,"brandHref",void 0),n([a({attribute:"brand-alt",type:String})],r.prototype,"brandAlt",void 0),n([a({attribute:"brand-color",type:String})],r.prototype,"brandColor",void 0),n([a({attribute:"brand-align",type:String,reflect:!0})],r.prototype,"brandAlign",void 0),n([a({attribute:"brand-wrap",type:String,reflect:!0})],r.prototype,"brandWrap",void 0),n([a({attribute:"menu-display",type:String,reflect:!0})],r.prototype,"menuDisplay",void 0),n([a({attribute:"theme-toggle",type:String,reflect:!0})],r.prototype,"themeToggle",void 0),n([a({attribute:"scroll-behavior",type:String})],r.prototype,"scrollBehavior",void 0),n([a({attribute:"scroll-threshold",type:Number})],r.prototype,"scrollThreshold",void 0),n([a({attribute:"dock-offset",type:Number})],r.prototype,"dockOffset",void 0),n([a({attribute:"drawer-target",type:String})],r.prototype,"drawerTarget",void 0),n([a({attribute:"full-bleed-content",type:Boolean,reflect:!0})],r.prototype,"fullBleedContent",void 0),r=n([D("esp-header")],r);export{r as EspalierHeader};
@@ -75,6 +75,7 @@ export declare class EspalierMenu extends EspalierElementBase {
75
75
  get collapsed(): boolean;
76
76
  set collapsed(value: boolean);
77
77
  connectedCallback(): void;
78
+ disconnectedCallback(): void;
78
79
  protected firstUpdated(props: PropertyValues): void;
79
80
  protected updated(changedProperties: PropertyValues): void;
80
81
  /**
@@ -1,4 +1,4 @@
1
- var a=function(h,e,r,o){var t=arguments.length,i=t<3?e:o===null?o=Object.getOwnPropertyDescriptor(e,r):o,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(h,e,r,o);else for(var l=h.length-1;l>=0;l--)(s=h[l])&&(i=(t<3?s(i):t>3?s(e,r,i):s(e,r))||i);return t>3&&i&&Object.defineProperty(e,r,i),i};import{css as E,html as w,nothing as m}from"lit";import{customElement as C,property as p,state as g}from"lit/decorators.js";import{classMap as f}from"lit/directives/class-map.js";import{unsafeHTML as v}from"lit/directives/unsafe-html.js";import{createRef as d,ref as c}from"lit/directives/ref.js";import{EspalierElementBase as b}from"../shared/esp-element-base.js";import{getEspBus as D}from"../shared/bus-events.js";import{normalizePath as S,pathStartsWithSegment as T,pathsMatch as y}from"../shared/path-matching.js";import{SwipeRevealController as O}from"./swipe-reveal-controller.js";import"./esp-menu-item.js";import"./esp-menu-group.js";import{EspalierMenuItem as x}from"./esp-menu-item.js";import{EspalierMenuGroup as u}from"./esp-menu-group.js";let n=class extends b{constructor(){super(),this.itemsSlot=d(),this.railRef=d(),this.scrimRef=d(),this.drawerRef=d(),this.bus=D(),this.closeTransitionTimer=null,this.drawerGroupOpenOverrides=new Map,this._sliding=!1,this.mode="horizontal",this.overflow="auto",this.side="left",this.ariaLabel=null,this.autoExpand=!1,this.drawerOpen=!1,this.drawerTransitioning=!1,this.drawerTrigger=null,this.getWidth=()=>{const e=this.railRef.value;return e?Math.max(e.scrollWidth,e.clientWidth):-1},this.onDrawerTransitionEnd=()=>{this.closeTransitionTimer&&(clearTimeout(this.closeTransitionTimer),this.closeTransitionTimer=null),this.drawerTransitioning=!1,this.drawerOpen||(this.hideDrawerPopover(),this.drawerGroupOpenOverrides.clear())},this.swipeController=new O(this,this.side),this.swipeController.enabled=!1}get sliding(){return this._sliding}set sliding(e){const r=this._sliding;this._sliding=e,this.syncSwipeEnabled(),this.propagateToItems(),this.requestUpdate("sliding",r)}get collapsed(){return this.drawerActive}set collapsed(e){e?this.mode="drawer":this.mode==="drawer"&&(this.mode="vertical")}get drawerSide(){return this.overflow==="right-drawer"?"right":this.overflow==="left-drawer"?"left":this.side}get drawerActive(){return this.mode==="drawer"||this._sliding||this.overflow==="left-drawer"||this.overflow==="right-drawer"}get railMode(){return this.mode==="horizontal"?"horizontal":"vertical"}connectedCallback(){super.connectedCallback(),this.getAttribute("slot")==="right"&&(this.side="right"),this.syncSwipeEnabled()}firstUpdated(e){super.firstUpdated(e),this.propagateToItems()}updated(e){super.updated(e),(e.has("mode")||e.has("overflow")||e.has("side"))&&(this.swipeController.direction=this.drawerSide,this.syncSwipeEnabled(),this.propagateToItems(),!this.drawerActive&&this.drawerOpen&&this.swipeController.close(!0)),this.autoExpand&&(e.has("autoExpand")||e.has("mode")&&this.mode!=="horizontal")?this.expandToCurrentPage():this.mode==="horizontal"&&e.has("mode")&&this.closeHorizontalTopLevelGroups()}openDrawer(e){this.drawerActive&&(e?this.drawerTrigger=e:this.drawerOpen||(this.drawerTrigger=null),this.swipeController.open())}closeDrawer(){this.swipeController.close(!0)}toggleDrawer(e){this.drawerOpen?this.closeDrawer():this.openDrawer(e)}toggleOpened(){this.toggleDrawer()}get isDrawerOpen(){return this.drawerOpen}syncSwipeEnabled(){this.swipeController.direction=this.drawerSide,this.swipeController.enabled=this.drawerActive}getAssignedChildren(){return this.itemsSlot.value?.assignedElements()??[]}propagateToItems(){const e=this.railMode;for(const r of this.getAssignedChildren())r instanceof x?(r.mode=e,r.depth=0,r.touchDevice=this.swipeController.isTouch):r instanceof u&&(r.mode=e,r.depth=0,r.touchDevice=this.swipeController.isTouch)}handleSlotChange(){this.propagateToItems()}onSwipeRevealChanged(e){e!==this.drawerOpen&&(this.drawerOpen=e,e?(this.drawerGroupOpenOverrides.clear(),this.bus.publish("close-popovers",{}),this.updateComplete.then(()=>this.showDrawerPopover())):(this.drawerTransitioning=!0,this.updateComplete.then(()=>this.startCloseTransition()),requestAnimationFrame(()=>this.restoreDrawerTriggerFocus())),this.dispatchEvent(new CustomEvent(e?"drawer-opened":"drawer-closed",{bubbles:!0,composed:!0})))}showDrawerPopover(){const e=this.scrimRef.value,r=this.drawerRef.value;if(!(!e||!r)){this.swipeController.drawerElement=r;try{e.showPopover(),r.showPopover()}catch{}r.getBoundingClientRect(),requestAnimationFrame(()=>{this.drawerTransitioning=!0,this.requestUpdate()})}}startCloseTransition(){if(!this.drawerRef.value){this.hideDrawerPopover();return}this.closeTransitionTimer&&clearTimeout(this.closeTransitionTimer),this.closeTransitionTimer=setTimeout(()=>{this.closeTransitionTimer=null,!this.drawerOpen&&this.drawerTransitioning&&this.onDrawerTransitionEnd()},400)}hideDrawerPopover(){const e=this.scrimRef.value,r=this.drawerRef.value;this.swipeController.drawerElement=null,r&&(r.style.cssText="");try{r?.hidePopover()}catch{}try{e?.hidePopover()}catch{}}restoreDrawerTriggerFocus(){const e=this.drawerTrigger;this.drawerTrigger=null,e?.isConnected&&e.focus({preventScroll:!0})}getAutoExpandedGroups(e=!0){const r=new Set;let o=null;for(const i of this.querySelectorAll("esp-menu-item")){const s=i.url||i.getAttribute("url");if(s&&y(s)){o=i;break}}if(!o)for(const i of this.querySelectorAll("esp-menu-group")){const s=i.url||i.getAttribute("url");if(s&&y(s)){o=i;break}}if(!o&&e){for(const i of this.querySelectorAll("esp-menu-group"))i.parentElement===this&&r.add(i);return r}if(!o)return r;o instanceof u&&r.add(o);let t=o.parentElement;for(;t&&t!==this;)t instanceof u&&r.add(t),t=t.parentElement;return r}isHorizontalTopLevelGroup(e){return e.mode==="horizontal"&&e.depth===0}groupUrlPrefixMatches(e){return T(location.pathname,e.urlPrefix)}groupPathMatches(e){if(this.groupUrlPrefixMatches(e))return!0;const r=e.url||e.getAttribute("url");return r?T(location.pathname,S(r)):!1}expandToCurrentPage(){const e=this.getAutoExpandedGroups(),r=this.querySelectorAll("esp-menu-group");for(const o of r)o.open=e.has(o)&&!this.isHorizontalTopLevelGroup(o)}closeHorizontalTopLevelGroups(){for(const e of this.querySelectorAll("esp-menu-group"))this.isHorizontalTopLevelGroup(e)&&(e.open=!1)}getDrawerAutoExpandedGroups(){return this.getAutoExpandedGroups(!1)}collectDrawerNodes(e,r=this.getDrawerAutoExpandedGroups()){const o=[];for(const t of e)if(t instanceof x){const i=t.querySelector(":scope > svg, :scope > img");o.push({kind:"item",label:t.label,url:t.url,open:!1,icon:t.icon,iconHtml:i?.outerHTML||"",children:[],originalItem:t,originalGroup:null})}else if(t instanceof u){const i=t.querySelector(':scope > [slot="icon"]'),s=r.has(t)||this.groupPathMatches(t),l=this.drawerGroupOpenOverrides.get(t)??(t.open||s);o.push({kind:"group",label:t.label,url:t.url||"",open:l,icon:t.icon,iconHtml:i?.outerHTML||"",children:this.collectDrawerNodes(Array.from(t.children),r),originalItem:null,originalGroup:t})}return o}renderDrawerNode(e){return e.kind==="item"?w`<esp-menu-item
1
+ var n=function(p,e,r,o){var t=arguments.length,i=t<3?e:o===null?o=Object.getOwnPropertyDescriptor(e,r):o,s;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(p,e,r,o);else for(var h=p.length-1;h>=0;h--)(s=p[h])&&(i=(t<3?s(i):t>3?s(e,r,i):s(e,r))||i);return t>3&&i&&Object.defineProperty(e,r,i),i};import{css as x,html as w,nothing as f}from"lit";import{customElement as E,property as l,state as g}from"lit/decorators.js";import{classMap as m}from"lit/directives/class-map.js";import{unsafeHTML as v}from"lit/directives/unsafe-html.js";import{createRef as d,ref as c}from"lit/directives/ref.js";import{EspalierElementBase as b}from"../shared/esp-element-base.js";import{getEspBus as D}from"../shared/bus-events.js";import{normalizePath as S,pathStartsWithSegment as y,pathsMatch as T}from"../shared/path-matching.js";import{SwipeRevealController as A}from"./swipe-reveal-controller.js";import"./esp-menu-item.js";import"./esp-menu-group.js";import{EspalierMenuItem as C}from"./esp-menu-item.js";import{EspalierMenuGroup as u}from"./esp-menu-group.js";const O="(max-width: 50em)";let a=class extends b{constructor(){super(),this.itemsSlot=d(),this.railRef=d(),this.scrimRef=d(),this.drawerRef=d(),this.bus=D(),this.closeTransitionTimer=null,this.drawerGroupOpenOverrides=new Map,this._sliding=!1,this._mobileCollapsed=!1,this.verticalDrawerQuery=null,this.onVerticalDrawerChange=e=>this.setMobileCollapsed(e.matches),this.mode="horizontal",this.overflow="auto",this.side="left",this.ariaLabel=null,this.autoExpand=!1,this.drawerOpen=!1,this.drawerTransitioning=!1,this.drawerTrigger=null,this.hasExternalDrawerControl=!1,this.getWidth=()=>{const e=this.railRef.value;return e?Math.max(e.scrollWidth,e.clientWidth):-1},this.onDrawerTransitionEnd=()=>{this.closeTransitionTimer&&(clearTimeout(this.closeTransitionTimer),this.closeTransitionTimer=null),this.drawerTransitioning=!1,this.drawerOpen||(this.hideDrawerPopover(),this.drawerGroupOpenOverrides.clear())},this.swipeController=new A(this,this.side),this.swipeController.enabled=!1}get sliding(){return this._sliding}set sliding(e){const r=this._sliding;this._sliding=e,this.syncSwipeEnabled(),this.propagateToItems(),this.requestUpdate("sliding",r)}get collapsed(){return this.drawerActive}set collapsed(e){e?this.mode="drawer":this.mode==="drawer"&&(this.mode="vertical")}get drawerSide(){return this.overflow==="right-drawer"?"right":this.overflow==="left-drawer"?"left":this.side}get drawerActive(){return this.mode==="drawer"||this._sliding||this.overflow==="left-drawer"||this.overflow==="right-drawer"||this.mode==="vertical"&&this._mobileCollapsed&&this.hasExternalDrawerControl}get railMode(){return this.mode==="horizontal"?"horizontal":"vertical"}connectedCallback(){super.connectedCallback(),this.getAttribute("slot")==="right"&&(this.side="right"),!this.verticalDrawerQuery&&typeof window<"u"&&"matchMedia"in window&&(this.verticalDrawerQuery=window.matchMedia(O),this._mobileCollapsed=this.verticalDrawerQuery.matches,this.verticalDrawerQuery.addEventListener("change",this.onVerticalDrawerChange)),this.syncSwipeEnabled()}disconnectedCallback(){this.verticalDrawerQuery?.removeEventListener("change",this.onVerticalDrawerChange),this.verticalDrawerQuery=null,super.disconnectedCallback()}setMobileCollapsed(e){e!==this._mobileCollapsed&&(this._mobileCollapsed=e,this.mode==="vertical"&&this.applyMobileCollapse())}applyMobileCollapse(){this.swipeController.direction=this.drawerSide,this.syncSwipeEnabled(),this.propagateToItems(),this.requestUpdate(),!this.drawerActive&&this.drawerOpen&&this.swipeController.close(!0)}firstUpdated(e){super.firstUpdated(e),this.propagateToItems()}updated(e){super.updated(e),(e.has("mode")||e.has("overflow")||e.has("side")||e.has("hasExternalDrawerControl"))&&(this.swipeController.direction=this.drawerSide,this.syncSwipeEnabled(),this.propagateToItems(),!this.drawerActive&&this.drawerOpen&&this.swipeController.close(!0)),this.autoExpand&&(e.has("autoExpand")||e.has("mode")&&this.mode!=="horizontal")?this.expandToCurrentPage():this.mode==="horizontal"&&e.has("mode")&&this.closeHorizontalTopLevelGroups()}openDrawer(e){this.drawerActive&&(e?this.drawerTrigger=e:this.drawerOpen||(this.drawerTrigger=null),this.swipeController.open())}closeDrawer(){this.swipeController.close(!0)}toggleDrawer(e){this.drawerOpen?this.closeDrawer():this.openDrawer(e)}toggleOpened(){this.toggleDrawer()}get isDrawerOpen(){return this.drawerOpen}syncSwipeEnabled(){this.swipeController.direction=this.drawerSide,this.swipeController.enabled=this.drawerActive}getAssignedChildren(){return this.itemsSlot.value?.assignedElements()??[]}propagateToItems(){const e=this.railMode;for(const r of this.getAssignedChildren())r instanceof C?(r.mode=e,r.depth=0,r.touchDevice=this.swipeController.isTouch):r instanceof u&&(r.mode=e,r.depth=0,r.touchDevice=this.swipeController.isTouch)}handleSlotChange(){this.propagateToItems()}onSwipeRevealChanged(e){e!==this.drawerOpen&&(this.drawerOpen=e,e?(this.drawerGroupOpenOverrides.clear(),this.bus.publish("close-popovers",{}),this.updateComplete.then(()=>this.showDrawerPopover())):(this.drawerTransitioning=!0,this.updateComplete.then(()=>this.startCloseTransition()),requestAnimationFrame(()=>this.restoreDrawerTriggerFocus())),this.dispatchEvent(new CustomEvent(e?"drawer-opened":"drawer-closed",{bubbles:!0,composed:!0})))}showDrawerPopover(){const e=this.scrimRef.value,r=this.drawerRef.value;if(!(!e||!r)){this.swipeController.drawerElement=r;try{e.showPopover(),r.showPopover()}catch{}r.getBoundingClientRect(),requestAnimationFrame(()=>{this.drawerTransitioning=!0,this.requestUpdate()})}}startCloseTransition(){if(!this.drawerRef.value){this.hideDrawerPopover();return}this.closeTransitionTimer&&clearTimeout(this.closeTransitionTimer),this.closeTransitionTimer=setTimeout(()=>{this.closeTransitionTimer=null,!this.drawerOpen&&this.drawerTransitioning&&this.onDrawerTransitionEnd()},400)}hideDrawerPopover(){const e=this.scrimRef.value,r=this.drawerRef.value;this.swipeController.drawerElement=null,r&&(r.style.cssText="");try{r?.hidePopover()}catch{}try{e?.hidePopover()}catch{}}restoreDrawerTriggerFocus(){const e=this.drawerTrigger;this.drawerTrigger=null,e?.isConnected&&e.focus({preventScroll:!0})}getAutoExpandedGroups(e=!0){const r=new Set;let o=null;for(const i of this.querySelectorAll("esp-menu-item")){const s=i.url||i.getAttribute("url");if(s&&T(s)){o=i;break}}if(!o)for(const i of this.querySelectorAll("esp-menu-group")){const s=i.url||i.getAttribute("url");if(s&&T(s)){o=i;break}}if(!o&&e){for(const i of this.querySelectorAll("esp-menu-group"))i.parentElement===this&&r.add(i);return r}if(!o)return r;o instanceof u&&r.add(o);let t=o.parentElement;for(;t&&t!==this;)t instanceof u&&r.add(t),t=t.parentElement;return r}isHorizontalTopLevelGroup(e){return e.mode==="horizontal"&&e.depth===0}groupUrlPrefixMatches(e){return y(location.pathname,e.urlPrefix)}groupPathMatches(e){if(this.groupUrlPrefixMatches(e))return!0;const r=e.url||e.getAttribute("url");return r?y(location.pathname,S(r)):!1}expandToCurrentPage(){const e=this.getAutoExpandedGroups(),r=this.querySelectorAll("esp-menu-group");for(const o of r)o.open=e.has(o)&&!this.isHorizontalTopLevelGroup(o)}closeHorizontalTopLevelGroups(){for(const e of this.querySelectorAll("esp-menu-group"))this.isHorizontalTopLevelGroup(e)&&(e.open=!1)}getDrawerAutoExpandedGroups(){return this.getAutoExpandedGroups(!1)}collectDrawerNodes(e,r=this.getDrawerAutoExpandedGroups()){const o=[];for(const t of e)if(t instanceof C){const i=t.querySelector(":scope > svg, :scope > img");o.push({kind:"item",label:t.label,url:t.url,open:!1,icon:t.icon,iconHtml:i?.outerHTML||"",children:[],originalItem:t,originalGroup:null})}else if(t instanceof u){const i=t.querySelector(':scope > [slot="icon"]'),s=r.has(t)||this.groupPathMatches(t),h=this.drawerGroupOpenOverrides.get(t)??(t.open||s);o.push({kind:"group",label:t.label,url:t.url||"",open:h,icon:t.icon,iconHtml:i?.outerHTML||"",children:this.collectDrawerNodes(Array.from(t.children),r),originalItem:null,originalGroup:t})}return o}renderDrawerNode(e){return e.kind==="item"?w`<esp-menu-item
2
2
  label=${e.label}
3
3
  .url=${e.url}
4
4
  .icon=${e.icon}
@@ -13,12 +13,12 @@ var a=function(h,e,r,o){var t=arguments.length,i=t<3?e:o===null?o=Object.getOwnP
13
13
  ?open=${e.open}
14
14
  @esp-group-toggle=${r=>{e.originalGroup&&(this.drawerGroupOpenOverrides.set(e.originalGroup,r.detail.open),this.isHorizontalTopLevelGroup(e.originalGroup)||(e.originalGroup.open=r.detail.open))}}
15
15
  >
16
- ${e.iconHtml?v(e.iconHtml):m}
16
+ ${e.iconHtml?v(e.iconHtml):f}
17
17
  ${e.children.map(r=>this.renderDrawerNode(r))}
18
- </esp-menu-group>`}handleDrawerItemClick(e){e.dispatchEvent(new CustomEvent("clicked",{detail:{},bubbles:!0,composed:!0})),this.swipeController.close(!0)}render(){const e=this.drawerOpen||this.drawerTransitioning,r=this.drawerActive&&(this.mode==="drawer"||this._sliding||this.overflow==="left-drawer"||this.overflow==="right-drawer"),o={rail:!0,horizontal:this.railMode==="horizontal",vertical:this.railMode==="vertical",wrap:this.overflow==="wrap",scroll:this.overflow==="scroll","drawer-forced":this.drawerActive},t={drawer:!0,"drawer-left":this.drawerSide==="left","drawer-right":this.drawerSide==="right",transitioning:this.drawerTransitioning,open:this.drawerOpen},i=e?this.collectDrawerNodes(this.getAssignedChildren()):[],s=this.ariaLabel??"Navigation";return w`
18
+ </esp-menu-group>`}handleDrawerItemClick(e){e.dispatchEvent(new CustomEvent("clicked",{detail:{},bubbles:!0,composed:!0})),this.swipeController.close(!0)}render(){const e=this.drawerOpen||this.drawerTransitioning,r=this.drawerActive,o={rail:!0,horizontal:this.railMode==="horizontal",vertical:this.railMode==="vertical",wrap:this.overflow==="wrap",scroll:this.overflow==="scroll","drawer-forced":this.drawerActive},t={drawer:!0,"drawer-left":this.drawerSide==="left","drawer-right":this.drawerSide==="right",transitioning:this.drawerTransitioning,open:this.drawerOpen},i=e?this.collectDrawerNodes(this.getAssignedChildren()):[],s=this.ariaLabel??"Navigation";return w`
19
19
  <nav
20
20
  ${c(this.railRef)}
21
- class=${f(o)}
21
+ class=${m(o)}
22
22
  aria-label=${s}
23
23
  ?hidden=${r}
24
24
  >
@@ -26,19 +26,19 @@ var a=function(h,e,r,o){var t=arguments.length,i=t<3?e:o===null?o=Object.getOwnP
26
26
  </nav>
27
27
  <div
28
28
  ${c(this.scrimRef)}
29
- class=${f({scrim:!0,open:this.drawerOpen,transitioning:this.drawerTransitioning})}
29
+ class=${m({scrim:!0,open:this.drawerOpen,transitioning:this.drawerTransitioning})}
30
30
  popover="manual"
31
31
  ></div>
32
32
  <nav
33
33
  ${c(this.drawerRef)}
34
- class=${f(t)}
34
+ class=${m(t)}
35
35
  aria-label=${s}
36
36
  popover="manual"
37
37
  @transitionend=${this.onDrawerTransitionEnd}
38
38
  >
39
- ${e?i.map(l=>this.renderDrawerNode(l)):m}
39
+ ${e?i.map(h=>this.renderDrawerNode(h)):f}
40
40
  </nav>
41
- `}};n.styles=[...b.styles,E`
41
+ `}};a.styles=[...b.styles,x`
42
42
  :host {
43
43
  display: block;
44
44
  min-width: 0;
@@ -168,4 +168,4 @@ var a=function(h,e,r,o){var t=arguments.length,i=t<3?e:o===null?o=Object.getOwnP
168
168
  transition: none;
169
169
  }
170
170
  }
171
- `],a([p({type:String,reflect:!0})],n.prototype,"mode",void 0),a([p({type:String,reflect:!0})],n.prototype,"overflow",void 0),a([p({type:String,reflect:!0})],n.prototype,"side",void 0),a([p({attribute:"aria-label",type:String})],n.prototype,"ariaLabel",void 0),a([p({type:Boolean,attribute:"auto-expand"})],n.prototype,"autoExpand",void 0),a([p({type:Boolean})],n.prototype,"sliding",null),a([p({type:Boolean})],n.prototype,"collapsed",null),a([g()],n.prototype,"drawerOpen",void 0),a([g()],n.prototype,"drawerTransitioning",void 0),n=a([C("esp-menu")],n);export{n as EspalierMenu};
171
+ `],n([l({type:String,reflect:!0})],a.prototype,"mode",void 0),n([l({type:String,reflect:!0})],a.prototype,"overflow",void 0),n([l({type:String,reflect:!0})],a.prototype,"side",void 0),n([l({attribute:"aria-label",type:String})],a.prototype,"ariaLabel",void 0),n([l({type:Boolean,attribute:"auto-expand"})],a.prototype,"autoExpand",void 0),n([l({type:Boolean})],a.prototype,"sliding",null),n([l({type:Boolean})],a.prototype,"collapsed",null),n([g()],a.prototype,"drawerOpen",void 0),n([g()],a.prototype,"drawerTransitioning",void 0),n([l({attribute:!1})],a.prototype,"hasExternalDrawerControl",void 0),a=n([E("esp-menu")],a);export{a as EspalierMenu};
@@ -1 +1 @@
1
- const h=10,a=.1,c=10,l=24,u=400,d=800;let o=null;class f{constructor(t,e="left"){this._isOpen=!1,this._isTouch=!1,this._enabled=!0,this._drawerElement=null,this.startX=0,this.startY=0,this.gestureStarted=!1,this.committed=!1,this.tracking=!1,this.pointerMediaQuery=null,this.horizontalScrollTarget=null,this.lastViewportWidth=0,this.lastViewportHeight=0,this.lastTouchEndTime=0,this.openedAt=0,this.closedViaTap=!1,this.onTouchStart=i=>this.handleTouchStart(i),this.onTouchMove=i=>this.handleTouchMove(i),this.onTouchEnd=i=>this.handleTouchEnd(i),this.onKeyDown=i=>this.handleKeyDown(i),this.onResize=()=>this.handleResize(),this.onDocumentClick=i=>this.handleDocumentClick(i),this.onMediaChange=i=>this.handleMediaChange(i),this.savedScrollY=0,this.isScrollLocked=!1,this.inertElements=[],(this.host=t).addController(this),this._direction=e}get isOpen(){return this._isOpen}get isTouch(){return this._isTouch}get direction(){return this._direction}set direction(t){this._direction=t}set drawerElement(t){this._drawerElement=t}get enabled(){return this._enabled}set enabled(t){this._enabled=t,!t&&this._isOpen&&this.close(!0)}open(){this._isOpen||this._enabled&&(o&&o!==this||(this._isOpen=!0,o=this,this.openedAt=Date.now(),this.lockScroll(!0),this.host.onSwipeRevealChanged(!0)))}close(t=!1){this._isOpen&&(!t&&Date.now()-this.openedAt<400||(this._isOpen=!1,o===this&&(o=null),this.lockScroll(!1),this.host.onSwipeRevealChanged(!1)))}toggle(){this._isOpen?this.close(!0):this.open()}hostConnected(){this.pointerMediaQuery=window.matchMedia("(pointer: coarse)"),this._isTouch=this.pointerMediaQuery.matches,this.lastViewportWidth=window.innerWidth,this.lastViewportHeight=window.innerHeight,this.pointerMediaQuery.addEventListener("change",this.onMediaChange),this._isTouch&&this.attachTouchListeners(),this.attachClickListener(),this.attachDismissListeners()}hostDisconnected(){this.detachTouchListeners(),this.stopTracking(),this.detachClickListener(),this.detachDismissListeners(),this.pointerMediaQuery?.removeEventListener("change",this.onMediaChange),this.pointerMediaQuery=null,this.lockScroll(!1),o===this&&(o=null)}attachTouchListeners(){document.addEventListener("touchstart",this.onTouchStart,{passive:!0}),document.addEventListener("touchend",this.onTouchEnd,{passive:!0}),document.addEventListener("touchcancel",this.onTouchEnd,{passive:!0})}detachTouchListeners(){document.removeEventListener("touchstart",this.onTouchStart),document.removeEventListener("touchend",this.onTouchEnd),document.removeEventListener("touchcancel",this.onTouchEnd)}startTracking(){this.tracking||(this.tracking=!0,document.addEventListener("touchmove",this.onTouchMove,{passive:!1}))}stopTracking(){this.tracking&&(this.tracking=!1,document.removeEventListener("touchmove",this.onTouchMove))}attachClickListener(){document.addEventListener("click",this.onDocumentClick,!0)}detachClickListener(){document.removeEventListener("click",this.onDocumentClick,!0)}attachDismissListeners(){document.addEventListener("keydown",this.onKeyDown),window.addEventListener("resize",this.onResize)}detachDismissListeners(){document.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("resize",this.onResize)}handleMediaChange(t){this._isTouch=t.matches,t.matches?this.attachTouchListeners():(this._isOpen&&this.close(!0),this.detachTouchListeners(),this.stopTracking()),this.host.requestUpdate()}isHorizontalDragControl(t){for(const e of t.composedPath())if(e instanceof HTMLElement){if(e===document.body||e===document.documentElement)break;if(e instanceof HTMLInputElement&&e.type==="range")return!0}return!1}isInsideDatePickerCalendar(t){for(const e of t.composedPath())if(e instanceof HTMLElement){if(e===document.body||e===document.documentElement)break;if(e.classList.contains("picker-popover")){const i=e.getRootNode();if(i instanceof ShadowRoot&&i.host?.tagName==="ESP-DATE-PICKER")return!0}}return!1}hasNoSwipeAncestor(t){for(const e of t.composedPath())if(e instanceof HTMLElement){if(e===document.body||e===document.documentElement)break;if(e.hasAttribute("data-no-swipe"))return!0}return!1}findHorizontallyScrollable(t){const e=t.composedPath();for(const i of e){if(!(i instanceof HTMLElement))continue;if(i===document.body||i===document.documentElement)break;if(i.scrollWidth<=i.clientWidth)continue;const n=getComputedStyle(i).overflowX;if(n==="auto"||n==="scroll"||n==="-webkit-marquee")return i}return null}canScrollInDirection(t,e){return e>0?t.scrollLeft>0:t.scrollLeft+t.clientWidth<t.scrollWidth-1}isPointInDrawer(t,e){if(!this._drawerElement)return!1;const i=this._drawerElement.getBoundingClientRect();return t>=i.left&&t<=i.right&&e>=i.top&&e<=i.bottom}handleTouchStart(t){if(!this._enabled||t.touches.length!==1)return;(this.committed||this.gestureStarted||this.tracking)&&this.resetGesture();const e=t.touches[0];this.isPointInDrawer(e.clientX,e.clientY)||this.isHorizontalDragControl(t)||this.isInsideDatePickerCalendar(t)||this.hasNoSwipeAncestor(t)||(this.horizontalScrollTarget=this._isOpen?null:this.findHorizontallyScrollable(t),this.startX=e.clientX,this.startY=e.clientY,this.gestureStarted=!1,this.committed=!1,this.startTracking())}handleTouchMove(t){if(t.touches.length!==1||this.committed||this.startX===0&&this.startY===0)return;this._isOpen&&t.cancelable&&t.preventDefault();const e=t.touches[0],i=e.clientX-this.startX,s=e.clientY-this.startY;if(!this.gestureStarted){if(Math.abs(i)<10&&Math.abs(s)<10)return;if(Math.abs(s)>Math.abs(i)){this.resetGesture();return}if(this._direction==="left"){if(!this._isOpen&&i<0){this.resetGesture();return}if(this._isOpen&&i>0){this.resetGesture();return}}else{if(!this._isOpen&&i>0){this.resetGesture();return}if(this._isOpen&&i<0){this.resetGesture();return}}if(this.horizontalScrollTarget&&this.canScrollInDirection(this.horizontalScrollTarget,i)){this.resetGesture();return}this.gestureStarted=!0}t.cancelable&&t.preventDefault();const n=window.innerWidth*.1;Math.abs(i)>=n&&(this.committed=!0,this._isOpen?this.close():this.open())}handleTouchEnd(t){if(this.lastTouchEndTime=Date.now(),this._isOpen&&this.tracking&&!this.committed&&t.changedTouches.length===1){const e=t.changedTouches[0],i=e.clientX-this.startX,s=e.clientY-this.startY;Math.abs(i)<10&&Math.abs(s)<10&&(this.closedViaTap=!0,setTimeout(()=>{this.closedViaTap=!1},400),this.close())}this.resetGesture()}handleDocumentClick(t){if(this.closedViaTap){this.closedViaTap=!1,t.stopImmediatePropagation(),t.preventDefault();return}this._isOpen&&(Date.now()-this.openedAt<800||Date.now()-this.lastTouchEndTime<400||this.isPointInDrawer(t.clientX,t.clientY)||(t.stopImmediatePropagation(),this.close()))}resetGesture(){this.startX=0,this.startY=0,this.gestureStarted=!1,this.committed=!1,this.horizontalScrollTarget=null,this.stopTracking()}handleKeyDown(t){t.key==="Escape"&&this._isOpen&&this.close(!0)}handleResize(){const t=Math.abs(window.innerWidth-this.lastViewportWidth),e=Math.abs(window.innerHeight-this.lastViewportHeight);this.lastViewportWidth=window.innerWidth,this.lastViewportHeight=window.innerHeight,!(this._isOpen&&Date.now()-this.openedAt<800)&&(t<24&&e<24||this._isOpen&&this.close(!0))}lockScroll(t){if(t&&this.isScrollLocked||!t&&!this.isScrollLocked)return;this.isScrollLocked=t;const{style:e}=document.body;t?(this.savedScrollY=window.scrollY,e.position="fixed",e.top=`-${this.savedScrollY}px`,e.left="0",e.right="0",this.setPageContentInert(!0)):(e.position="",e.top="",e.left="",e.right="",window.scrollTo(0,this.savedScrollY),requestAnimationFrame(()=>{this.setPageContentInert(!1),window.dispatchEvent(new Event("resize"))}))}getPageRegionFromSlot(t){return t.closest(".esp-page-top, .esp-page-main, .esp-page-left, .esp-page-right, footer")}getContainingPageRegionFromLightDom(){const t=this.host.closest("esp-page");if(!t?.shadowRoot)return null;let e=this.host;for(;e?.parentElement&&e.parentElement!==t;)e=e.parentElement;if(!e||e.parentElement!==t)return null;const i=e.getAttribute("slot")??"",s=Array.from(t.shadowRoot.querySelectorAll("slot")).find(n=>n.name===i);return s?this.getPageRegionFromSlot(s):null}getContainingPageRegion(){const t=this.getContainingPageRegionFromLightDom();if(t)return t;let e=this.host;for(;e;){if(e instanceof HTMLElement&&e.assignedSlot){const s=this.getPageRegionFromSlot(e.assignedSlot);if(s)return s;const n=e.assignedSlot.getRootNode();if(n instanceof ShadowRoot){e=n.host;continue}}if(e.parentElement){e=e.parentElement;continue}const i=e.getRootNode();e=i instanceof ShadowRoot?i.host:null}return null}setPageContentInert(t){if(t){this.inertElements=[];const e=this.getContainingPageRegion();if(!e)return;const i=e.parentElement;if(!i)return;for(const s of i.children)s instanceof HTMLElement&&s!==e&&(s.inert||(s.inert=!0,this.inertElements.push(s)))}else{for(const e of this.inertElements)e.inert=!1;this.inertElements=[]}}}export{f as SwipeRevealController};
1
+ const h=10,a=.25,l=.25,c=10,d=24,u=400,f=800;let o=null;class g{constructor(e,t="left"){this._isOpen=!1,this._isTouch=!1,this._enabled=!0,this._drawerElement=null,this.startX=0,this.startY=0,this.gestureStarted=!1,this.committed=!1,this.gestureStartedInDrawer=!1,this.tracking=!1,this.pointerMediaQuery=null,this.horizontalScrollTarget=null,this.lastViewportWidth=0,this.lastViewportHeight=0,this.lastTouchEndTime=0,this.openedAt=0,this.closedViaTap=!1,this.onTouchStart=i=>this.handleTouchStart(i),this.onTouchMove=i=>this.handleTouchMove(i),this.onTouchEnd=i=>this.handleTouchEnd(i),this.onKeyDown=i=>this.handleKeyDown(i),this.onResize=()=>this.handleResize(),this.onDocumentClick=i=>this.handleDocumentClick(i),this.onMediaChange=i=>this.handleMediaChange(i),this.savedScrollY=0,this.isScrollLocked=!1,this.inertElements=[],(this.host=e).addController(this),this._direction=t}get isOpen(){return this._isOpen}get isTouch(){return this._isTouch}get direction(){return this._direction}set direction(e){this._direction=e}set drawerElement(e){this._drawerElement=e}get enabled(){return this._enabled}set enabled(e){this._enabled=e,!e&&this._isOpen&&this.close(!0)}open(){this._isOpen||this._enabled&&(o&&o!==this||(this._isOpen=!0,o=this,this.openedAt=Date.now(),this.lockScroll(!0),this.host.onSwipeRevealChanged(!0)))}close(e=!1){this._isOpen&&(!e&&Date.now()-this.openedAt<400||(this._isOpen=!1,o===this&&(o=null),this.lockScroll(!1),this.host.onSwipeRevealChanged(!1)))}toggle(){this._isOpen?this.close(!0):this.open()}hostConnected(){this.pointerMediaQuery=window.matchMedia("(pointer: coarse)"),this._isTouch=this.pointerMediaQuery.matches,this.lastViewportWidth=window.innerWidth,this.lastViewportHeight=window.innerHeight,this.pointerMediaQuery.addEventListener("change",this.onMediaChange),this._isTouch&&this.attachTouchListeners(),this.attachClickListener(),this.attachDismissListeners()}hostDisconnected(){this.detachTouchListeners(),this.stopTracking(),this.detachClickListener(),this.detachDismissListeners(),this.pointerMediaQuery?.removeEventListener("change",this.onMediaChange),this.pointerMediaQuery=null,this.lockScroll(!1),o===this&&(o=null)}attachTouchListeners(){document.addEventListener("touchstart",this.onTouchStart,{passive:!0}),document.addEventListener("touchend",this.onTouchEnd,{passive:!0}),document.addEventListener("touchcancel",this.onTouchEnd,{passive:!0})}detachTouchListeners(){document.removeEventListener("touchstart",this.onTouchStart),document.removeEventListener("touchend",this.onTouchEnd),document.removeEventListener("touchcancel",this.onTouchEnd)}startTracking(){this.tracking||(this.tracking=!0,document.addEventListener("touchmove",this.onTouchMove,{passive:!1}))}stopTracking(){this.tracking&&(this.tracking=!1,document.removeEventListener("touchmove",this.onTouchMove))}attachClickListener(){document.addEventListener("click",this.onDocumentClick,!0)}detachClickListener(){document.removeEventListener("click",this.onDocumentClick,!0)}attachDismissListeners(){document.addEventListener("keydown",this.onKeyDown),window.addEventListener("resize",this.onResize)}detachDismissListeners(){document.removeEventListener("keydown",this.onKeyDown),window.removeEventListener("resize",this.onResize)}handleMediaChange(e){this._isTouch=e.matches,e.matches?this.attachTouchListeners():(this._isOpen&&this.close(!0),this.detachTouchListeners(),this.stopTracking()),this.host.requestUpdate()}isHorizontalDragControl(e){for(const t of e.composedPath())if(t instanceof HTMLElement){if(t===document.body||t===document.documentElement)break;if(t instanceof HTMLInputElement&&t.type==="range")return!0}return!1}isInsideDatePickerCalendar(e){for(const t of e.composedPath())if(t instanceof HTMLElement){if(t===document.body||t===document.documentElement)break;if(t.classList.contains("picker-popover")){const i=t.getRootNode();if(i instanceof ShadowRoot&&i.host?.tagName==="ESP-DATE-PICKER")return!0}}return!1}hasNoSwipeAncestor(e){for(const t of e.composedPath())if(t instanceof HTMLElement){if(t===document.body||t===document.documentElement)break;if(t.hasAttribute("data-no-swipe"))return!0}return!1}findHorizontallyScrollable(e){const t=e.composedPath();for(const i of t){if(!(i instanceof HTMLElement))continue;if(i===document.body||i===document.documentElement)break;if(i.scrollWidth<=i.clientWidth)continue;const n=getComputedStyle(i).overflowX;if(n==="auto"||n==="scroll"||n==="-webkit-marquee")return i}return null}canScrollInDirection(e,t){return t>0?e.scrollLeft>0:e.scrollLeft+e.clientWidth<e.scrollWidth-1}isPointInDrawer(e,t){if(!this._drawerElement)return!1;const i=this._drawerElement.getBoundingClientRect();return e>=i.left&&e<=i.right&&t>=i.top&&t<=i.bottom}handleTouchStart(e){if(!this._enabled||e.touches.length!==1)return;(this.committed||this.gestureStarted||this.tracking)&&this.resetGesture();const t=e.touches[0];if(this.isPointInDrawer(t.clientX,t.clientY)){if(!this._isOpen)return;this.gestureStartedInDrawer=!0,this.horizontalScrollTarget=null,this.startX=t.clientX,this.startY=t.clientY,this.gestureStarted=!1,this.committed=!1,this.startTracking();return}this.isHorizontalDragControl(e)||this.isInsideDatePickerCalendar(e)||this.hasNoSwipeAncestor(e)||!this._isOpen&&!this.isWithinOpenEdge(t.clientX)||(this.horizontalScrollTarget=this._isOpen?null:this.findHorizontallyScrollable(e),this.gestureStartedInDrawer=!1,this.startX=t.clientX,this.startY=t.clientY,this.gestureStarted=!1,this.committed=!1,this.startTracking())}isWithinOpenEdge(e){const t=window.innerWidth*.25;return this._direction==="left"?e<=t:e>=window.innerWidth-t}handleTouchMove(e){if(e.touches.length!==1||this.committed||this.startX===0&&this.startY===0)return;this._isOpen&&!this.gestureStartedInDrawer&&e.cancelable&&e.preventDefault();const t=e.touches[0],i=t.clientX-this.startX,s=t.clientY-this.startY;if(!this.gestureStarted){if(Math.abs(i)<10&&Math.abs(s)<10)return;if(Math.abs(s)>Math.abs(i)){this.resetGesture();return}if(this._direction==="left"){if(!this._isOpen&&i<0){this.resetGesture();return}if(this._isOpen&&i>0){this.resetGesture();return}}else{if(!this._isOpen&&i>0){this.resetGesture();return}if(this._isOpen&&i<0){this.resetGesture();return}}if(this.horizontalScrollTarget&&this.canScrollInDirection(this.horizontalScrollTarget,i)){this.resetGesture();return}this.gestureStarted=!0}e.cancelable&&e.preventDefault();const n=window.innerWidth*.25;Math.abs(i)>=n&&(this.committed=!0,this._isOpen?this.close():this.open())}handleTouchEnd(e){if(this.lastTouchEndTime=Date.now(),this._isOpen&&this.tracking&&!this.committed&&!this.gestureStartedInDrawer&&e.changedTouches.length===1){const t=e.changedTouches[0],i=t.clientX-this.startX,s=t.clientY-this.startY;Math.abs(i)<10&&Math.abs(s)<10&&(this.closedViaTap=!0,setTimeout(()=>{this.closedViaTap=!1},400),this.close())}this.resetGesture()}handleDocumentClick(e){if(this.closedViaTap){this.closedViaTap=!1,e.stopImmediatePropagation(),e.preventDefault();return}this._isOpen&&(Date.now()-this.openedAt<800||Date.now()-this.lastTouchEndTime<400||this.isPointInDrawer(e.clientX,e.clientY)||(e.stopImmediatePropagation(),this.close()))}resetGesture(){this.startX=0,this.startY=0,this.gestureStarted=!1,this.committed=!1,this.gestureStartedInDrawer=!1,this.horizontalScrollTarget=null,this.stopTracking()}handleKeyDown(e){e.key==="Escape"&&this._isOpen&&this.close(!0)}handleResize(){const e=Math.abs(window.innerWidth-this.lastViewportWidth),t=Math.abs(window.innerHeight-this.lastViewportHeight);this.lastViewportWidth=window.innerWidth,this.lastViewportHeight=window.innerHeight,!(this._isOpen&&Date.now()-this.openedAt<800)&&(e<24&&t<24||this._isOpen&&this.close(!0))}lockScroll(e){if(e&&this.isScrollLocked||!e&&!this.isScrollLocked)return;this.isScrollLocked=e;const{style:t}=document.body;e?(this.savedScrollY=window.scrollY,t.position="fixed",t.top=`-${this.savedScrollY}px`,t.left="0",t.right="0",this.setPageContentInert(!0)):(t.position="",t.top="",t.left="",t.right="",window.scrollTo(0,this.savedScrollY),requestAnimationFrame(()=>{this.setPageContentInert(!1),window.dispatchEvent(new Event("resize"))}))}getPageRegionFromSlot(e){return e.closest(".esp-page-top, .esp-page-main, .esp-page-left, .esp-page-right, footer")}getContainingPageRegionFromLightDom(){const e=this.host.closest("esp-page");if(!e?.shadowRoot)return null;let t=this.host;for(;t?.parentElement&&t.parentElement!==e;)t=t.parentElement;if(!t||t.parentElement!==e)return null;const i=t.getAttribute("slot")??"",s=Array.from(e.shadowRoot.querySelectorAll("slot")).find(n=>n.name===i);return s?this.getPageRegionFromSlot(s):null}getContainingPageRegion(){const e=this.getContainingPageRegionFromLightDom();if(e)return e;let t=this.host;for(;t;){if(t instanceof HTMLElement&&t.assignedSlot){const s=this.getPageRegionFromSlot(t.assignedSlot);if(s)return s;const n=t.assignedSlot.getRootNode();if(n instanceof ShadowRoot){t=n.host;continue}}if(t.parentElement){t=t.parentElement;continue}const i=t.getRootNode();t=i instanceof ShadowRoot?i.host:null}return null}setPageContentInert(e){if(e){this.inertElements=[];const t=this.getContainingPageRegion();if(!t)return;const i=t.parentElement;if(!i)return;for(const s of i.children)s instanceof HTMLElement&&s!==t&&(s.inert||(s.inert=!0,this.inertElements.push(s)))}else{for(const t of this.inertElements)t.inert=!1;this.inertElements=[]}}}export{g as SwipeRevealController};
@@ -96,15 +96,33 @@ type HeaderPosition = "normal" | "sticky" | "fixed";
96
96
  * </esp-page>
97
97
  * ```
98
98
  *
99
- * @cssprop --esp-page-background - The background color of the page.
100
- * Defaults to `var(--esp-color-background)`.
99
+ * @cssprop --esp-page-background - The background color of the page. Fills
100
+ * both the surface and the canvas gutters; the canvas tokens paint over it
101
+ * in the gutters only. Defaults to `var(--esp-color-background)`.
101
102
  * @cssprop --esp-page-max-width - The maximum width of the main content
102
103
  * well. Set automatically by the `kind` attribute: `1536px` (wide),
103
- * `768px` (narrow), or `none` (full).
104
+ * `768px` (narrow), or `none` (full). This cap now sizes the main grid
105
+ * track; surplus width beyond it becomes the canvas gutters.
104
106
  * @cssprop --esp-page-background-image - The background image to
105
107
  * display behind page content. Defaults to `none`.
106
108
  * @cssprop --esp-page-background-image-opacity - The opacity of the
107
109
  * background image layer. Defaults to `1`.
110
+ * @cssprop --esp-page-canvas-background - The background color of the
111
+ * canvas gutters (the outer regions revealed when the viewport exceeds
112
+ * the cap). Defaults to `transparent`, so gutters match the page until
113
+ * styled and narrow viewports are unaffected.
114
+ * @cssprop --esp-page-canvas-background-image - A background image for the
115
+ * canvas gutters, mirroring the page background-image knob. Defaults to
116
+ * `none`.
117
+ * @cssprop --esp-page-canvas-background-image-opacity - The opacity of the
118
+ * canvas gutter image layer. Defaults to `1`.
119
+ * @cssprop --esp-page-surface-shadow - The box shadow drawn on the left
120
+ * and right edges of the content surface. On by default; casts into the
121
+ * gutters and is clipped away when the surface fills the viewport, so it
122
+ * only shows above the cap. Set to `none` to remove it.
123
+ * @cssprop --esp-page-surface-border - An optional border on the inline
124
+ * edges of the surface, for themes preferring a hairline over a shadow.
125
+ * Defaults to `none` (e.g. `1px solid var(--esp-color-border)`).
108
126
  * @cssprop --esp-page-fixed-header-offset - Offset reserved for fixed
109
127
  * headers. Defaults to `var(--esp-header-height)`.
110
128
  * @cssprop --esp-page-sticky-header-top - Top inset for sticky headers.
@@ -112,6 +130,9 @@ type HeaderPosition = "normal" | "sticky" | "fixed";
112
130
  * @cssprop --esp-page-header-z-index - Z-index for fixed/sticky header
113
131
  * regions. Defaults to `20`.
114
132
  *
133
+ * @csspart canvas - The two canvas gutter regions flanking the surface.
134
+ * @csspart surface - The surface backdrop carrying the edge shadow/border.
135
+ *
115
136
  * ```html
116
137
  * <style>
117
138
  * esp-page.with-background {
@@ -130,6 +151,29 @@ type HeaderPosition = "normal" | "sticky" | "fixed";
130
151
  * </esp-page>
131
152
  * ```
132
153
  *
154
+ * Use `align` to place the surface within the page once it hits its cap,
155
+ * and the canvas tokens to style the gutters. A low `--esp-page-max-width`
156
+ * is set here only so the gutters are visible inside the narrow demo
157
+ * frame; the surface edge shadow is on by default.
158
+ *
159
+ * ```html
160
+ * <style>
161
+ * esp-page.align-demo {
162
+ * --esp-page-max-width: 520px;
163
+ * --esp-page-canvas-background: var(--esp-color-layer-1);
164
+ * }
165
+ * </style>
166
+ * <esp-page class="docs align-demo" align="center">
167
+ * <div slot="header" style="background-color: red;">header</div>
168
+ * <div slot="sidebar" style="background-color: green;">sidebar</div>
169
+ * <div slot="right" style="background-color: purple;">right</div>
170
+ * <div slot="footer" style="background-color: blue;">footer</div>
171
+ * <div style="background-color: black; overflow: hidden;">
172
+ * content
173
+ * </div>
174
+ * </esp-page>
175
+ * ```
176
+ *
133
177
  * @docPageTitle Page
134
178
  * @docUrl /components/page
135
179
  * @menuGroup Structure
@@ -153,6 +197,38 @@ export declare class EspalierPage extends EspalierElementBase {
153
197
  * maps or design tools.
154
198
  */
155
199
  kind: "wide" | "narrow" | "full";
200
+ /**
201
+ * Horizontal alignment of the content **surface** (left aside + main
202
+ * well + right aside) within the page once the viewport is wider than
203
+ * the content cap. The surplus width becomes styleable **canvas**
204
+ * gutters on the outer edges, weighted by this attribute.
205
+ *
206
+ * - `start` (default) — the surface hugs the leading edge; all spare
207
+ * width collects in the trailing gutter. This reproduces today's
208
+ * layout.
209
+ * - `center` — spare width is split evenly into both gutters, centering
210
+ * the surface.
211
+ * - `end` — the surface hugs the trailing edge; spare width collects in
212
+ * the leading gutter.
213
+ *
214
+ * Has no effect when `kind="full"` (no cap means no gutters) or on
215
+ * viewports narrower than the cap (the surface already fills the width).
216
+ */
217
+ align: "start" | "center" | "end";
218
+ /**
219
+ * When set, the header and footer sit **on** the content surface —
220
+ * the same width as the left aside + main well + right aside — instead
221
+ * of spanning the full viewport. Combined with a styled canvas this
222
+ * frames the whole page as one contained band floating on the canvas,
223
+ * with a single continuous surface edge shadow running from the header
224
+ * through the content to the footer.
225
+ *
226
+ * Below the cap there are no gutters, so a contained page renders
227
+ * identically to the default full-bleed chrome. Designed for
228
+ * `header-position="normal"` or `"sticky"`; a fixed header cannot be
229
+ * banded to the surface.
230
+ */
231
+ contained: boolean;
156
232
  /**
157
233
  * Header positioning behavior for the `header` slot.
158
234
  *
@@ -1,5 +1,8 @@
1
- var n=function(s,e,i,o){var r=arguments.length,t=r<3?e:o===null?o=Object.getOwnPropertyDescriptor(e,i):o,p;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")t=Reflect.decorate(s,e,i,o);else for(var d=s.length-1;d>=0;d--)(p=s[d])&&(t=(r<3?p(t):r>3?p(e,i,t):p(e,i))||t);return r>3&&t&&Object.defineProperty(e,i,t),t};import{css as c,html as f}from"lit";import{customElement as m,property as l}from"lit/decorators.js";import{classMap as u}from"lit/directives/class-map.js";import{createRef as v,ref as x}from"lit/directives/ref.js";import{EspalierElementBase as g}from"../shared/esp-element-base.js";import{BiDirectionalStickyController as h}from"./bi-directional-sticky-controller.js";import{getEspBus as y}from"../shared/bus-events.js";import"../toaster/esp-toaster.js";let a=class extends g{constructor(){super(),this.dialogZone=v(),this.kind="wide",this.headerPosition="normal",this.fixedMenus=!1,new h(this,".esp-page-left > .sticky-wrapper"),new h(this,".esp-page-right > .sticky-wrapper")}AddDialog(e){this.dialogZone.value?.appendChild(e)}updated(e){super.updated(e),(e.has("fixedMenus")||e.has("headerPosition"))&&y().publish("fixed-menus-changed",{fixed:this.fixedMenus||this.headerPosition==="fixed"})}render(){const e=this.fixedMenus||this.headerPosition==="fixed",i=!e&&this.headerPosition==="sticky";return f`
2
- <div part="wrapper" class="esp-page ${u({"fixed-menus":e,"fixed-header":e,"sticky-header":i})}">
1
+ var o=function(i,e,s,r){var d=arguments.length,a=d<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,s):r,p;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")a=Reflect.decorate(i,e,s,r);else for(var l=i.length-1;l>=0;l--)(p=i[l])&&(a=(d<3?p(a):d>3?p(e,s,a):p(e,s))||a);return d>3&&a&&Object.defineProperty(e,s,a),a};import{css as g,html as f}from"lit";import{customElement as u,property as n}from"lit/decorators.js";import{classMap as m}from"lit/directives/class-map.js";import{createRef as v,ref as w}from"lit/directives/ref.js";import{EspalierElementBase as h}from"../shared/esp-element-base.js";import{BiDirectionalStickyController as c}from"./bi-directional-sticky-controller.js";import{getEspBus as b}from"../shared/bus-events.js";import"../toaster/esp-toaster.js";let t=class extends h{constructor(){super(),this.dialogZone=v(),this.kind="wide",this.align="start",this.contained=!1,this.headerPosition="normal",this.fixedMenus=!1,new c(this,".esp-page-left > .sticky-wrapper"),new c(this,".esp-page-right > .sticky-wrapper")}AddDialog(e){this.dialogZone.value?.appendChild(e)}updated(e){super.updated(e),(e.has("fixedMenus")||e.has("headerPosition"))&&b().publish("fixed-menus-changed",{fixed:this.fixedMenus||this.headerPosition==="fixed"})}render(){const e=this.fixedMenus||this.headerPosition==="fixed",s=!e&&this.headerPosition==="sticky";return f`
2
+ <div part="wrapper" class="esp-page ${m({"fixed-menus":e,"fixed-header":e,"sticky-header":s})}">
3
+ <div part="canvas" class="esp-page-canvas esp-page-canvas--left" aria-hidden="true"></div>
4
+ <div part="canvas" class="esp-page-canvas esp-page-canvas--right" aria-hidden="true"></div>
5
+ <div part="surface" class="esp-page-surface" aria-hidden="true"></div>
3
6
  <div class="esp-page-top">
4
7
  <slot name="header"></slot>
5
8
  </div>
@@ -19,12 +22,17 @@ var n=function(s,e,i,o){var r=arguments.length,t=r<3?e:o===null?o=Object.getOwnP
19
22
  <footer>
20
23
  <slot name="footer"></slot>
21
24
  </footer>
22
- <div id="dialog-drop-zone" ${x(this.dialogZone)}></div>
25
+ <div id="dialog-drop-zone" ${w(this.dialogZone)}></div>
23
26
  <esp-toaster></esp-toaster>
24
27
  </div>
25
- `}};a.styles=[...g.styles,c`
28
+ `}};t.styles=[...h.styles,g`
26
29
  :host {
27
30
  --_esp-page-resolved-max-width: var(--esp-page-max-width, 1536px);
31
+
32
+ --_esp-page-main-track: minmax(0, var(--_esp-page-resolved-max-width));
33
+
34
+ --_esp-page-gutter-left: 0;
35
+ --_esp-page-gutter-right: 1fr;
28
36
  --_esp-page-fixed-header-offset: var(
29
37
  --esp-page-fixed-header-offset,
30
38
  var(--esp-header-height, calc(4.5 * var(--esp-size-small)))
@@ -37,8 +45,53 @@ var n=function(s,e,i,o){var r=arguments.length,t=r<3?e:o===null?o=Object.getOwnP
37
45
  --_esp-page-resolved-max-width: var(--esp-page-max-width, 768px);
38
46
  }
39
47
 
48
+ :host([align="center"]) {
49
+ --_esp-page-gutter-left: 1fr;
50
+ --_esp-page-gutter-right: 1fr;
51
+ }
52
+
53
+ :host([align="end"]) {
54
+ --_esp-page-gutter-left: 1fr;
55
+ --_esp-page-gutter-right: 0;
56
+ }
57
+
58
+
40
59
  :host([kind="full"]) {
41
60
  --_esp-page-resolved-max-width: var(--esp-page-max-width, none);
61
+ --_esp-page-main-track: 1fr;
62
+ --_esp-page-gutter-left: 0;
63
+ --_esp-page-gutter-right: 0;
64
+ }
65
+
66
+
67
+ slot[name="header"]::slotted(esp-header) {
68
+ --esp-header-content-max-width: var(--_esp-page-resolved-max-width);
69
+ --esp-header-content-lead: 0;
70
+ }
71
+
72
+ :host([align="center"]) slot[name="header"]::slotted(esp-header) {
73
+ --esp-header-content-lead: 0.5;
74
+ }
75
+
76
+ :host([align="end"]) slot[name="header"]::slotted(esp-header) {
77
+ --esp-header-content-lead: 1;
78
+ }
79
+
80
+
81
+ :host([kind="full"]) slot[name="header"]::slotted(esp-header) {
82
+ --esp-header-content-max-width: 100%;
83
+ }
84
+
85
+
86
+ :host([contained]) .esp-page > div.esp-page-top,
87
+ :host([contained]) .esp-page > footer {
88
+ grid-column: surface;
89
+ }
90
+
91
+
92
+ :host([contained]) slot[name="header"]::slotted(esp-header) {
93
+ --esp-header-content-max-width: 100%;
94
+ --esp-header-shadow: none;
42
95
  }
43
96
 
44
97
  :host([kind="narrow"]) .esp-page > div.esp-page-main {
@@ -57,10 +110,12 @@ var n=function(s,e,i,o){var r=arguments.length,t=r<3?e:o===null?o=Object.getOwnP
57
110
  min-height: 100vh;
58
111
  display: grid;
59
112
  grid-template-columns:
60
- [full-start left-start] min-content
61
- [left-end main-start] 1fr
113
+ [full-start canvas-left-start] var(--_esp-page-gutter-left)
114
+ [canvas-left-end surface-start left-start] min-content
115
+ [left-end main-start] var(--_esp-page-main-track)
62
116
  [main-end right-start] min-content
63
- [right-end full-end];
117
+ [right-end surface-end canvas-right-start] var(--_esp-page-gutter-right)
118
+ [canvas-right-end full-end];
64
119
  grid-template-rows:
65
120
  [top-start] min-content
66
121
  [top-end content-start] 1fr
@@ -92,6 +147,8 @@ var n=function(s,e,i,o){var r=arguments.length,t=r<3?e:o===null?o=Object.getOwnP
92
147
  grid-column: full;
93
148
  grid-row: top;
94
149
  position: relative;
150
+
151
+ contain: inline-size;
95
152
  }
96
153
 
97
154
 
@@ -113,7 +170,7 @@ var n=function(s,e,i,o){var r=arguments.length,t=r<3?e:o===null?o=Object.getOwnP
113
170
  grid-row: content;
114
171
  position: relative;
115
172
  overflow: hidden;
116
- max-width: var(--_esp-page-resolved-max-width);
173
+
117
174
  contain: inline-size;
118
175
  }
119
176
 
@@ -122,6 +179,48 @@ var n=function(s,e,i,o){var r=arguments.length,t=r<3?e:o===null?o=Object.getOwnP
122
179
  }
123
180
 
124
181
 
182
+ > .esp-page-canvas {
183
+
184
+ grid-row: top-start / footer-end;
185
+ z-index: 1;
186
+ position: relative;
187
+ pointer-events: none;
188
+ background-color: var(--esp-page-canvas-background, transparent);
189
+
190
+
191
+ &::before {
192
+ content: "";
193
+ position: absolute;
194
+ inset: 0;
195
+ background-image: var(--esp-page-canvas-background-image, none);
196
+ opacity: var(--esp-page-canvas-background-image-opacity, 1);
197
+ }
198
+ }
199
+
200
+ > .esp-page-canvas--left {
201
+ grid-column: canvas-left;
202
+ }
203
+
204
+ > .esp-page-canvas--right {
205
+ grid-column: canvas-right;
206
+ }
207
+
208
+
209
+ > .esp-page-surface {
210
+ grid-column: surface;
211
+
212
+ grid-row: top-start / footer-end;
213
+ z-index: 2;
214
+ pointer-events: none;
215
+ box-shadow: var(
216
+ --esp-page-surface-shadow,
217
+ -0.75rem 0 1.5rem -0.75rem var(--esp-color-shadow),
218
+ 0.75rem 0 1.5rem -0.75rem var(--esp-color-shadow)
219
+ );
220
+ border-inline: var(--esp-page-surface-border, none);
221
+ }
222
+
223
+
125
224
  .sticky-wrapper {
126
225
  will-change: top;
127
226
  display: block;
@@ -135,6 +234,8 @@ var n=function(s,e,i,o){var r=arguments.length,t=r<3?e:o===null?o=Object.getOwnP
135
234
  grid-row: footer;
136
235
  z-index: 10;
137
236
  background: var(--esp-page-background, var(--esp-color-background));
237
+
238
+ contain: inline-size;
138
239
  }
139
240
 
140
241
  &.sticky-header {
@@ -166,7 +267,9 @@ var n=function(s,e,i,o){var r=arguments.length,t=r<3?e:o===null?o=Object.getOwnP
166
267
 
167
268
  > div.esp-page-main,
168
269
  > aside.esp-page-left,
169
- > aside.esp-page-right {
270
+ > aside.esp-page-right,
271
+ > .esp-page-surface,
272
+ > .esp-page-canvas {
170
273
  margin-top: var(--_esp-page-fixed-header-offset);
171
274
  }
172
275
  }
@@ -194,4 +297,4 @@ var n=function(s,e,i,o){var r=arguments.length,t=r<3?e:o===null?o=Object.getOwnP
194
297
  .esp-page:has(esp-dialog[is-open="true"]) {
195
298
  overflow: hidden;
196
299
  }
197
- `],n([l({reflect:!0})],a.prototype,"kind",void 0),n([l({attribute:"header-position",reflect:!0})],a.prototype,"headerPosition",void 0),n([l({attribute:"fixed-menus",type:Boolean,reflect:!0})],a.prototype,"fixedMenus",void 0),a=n([m("esp-page")],a);export{a as EspalierPage};
300
+ `],o([n({reflect:!0})],t.prototype,"kind",void 0),o([n({reflect:!0})],t.prototype,"align",void 0),o([n({type:Boolean,reflect:!0})],t.prototype,"contained",void 0),o([n({attribute:"header-position",reflect:!0})],t.prototype,"headerPosition",void 0),o([n({attribute:"fixed-menus",type:Boolean,reflect:!0})],t.prototype,"fixedMenus",void 0),t=o([u("esp-page")],t);export{t as EspalierPage};