@taprootio/espalier 7.1.1 → 7.3.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 +20 -0
- package/custom-elements.json +11675 -20250
- package/dist/badge/esp-badge.d.ts +7 -0
- package/dist/badge/esp-badge.js +11 -5
- package/dist/breadcrumbs/breadcrumb-separators.d.ts +4 -0
- package/dist/breadcrumbs/breadcrumb-separators.js +1 -0
- package/dist/breadcrumbs/esp-breadcrumb.d.ts +13 -14
- package/dist/breadcrumbs/esp-breadcrumb.js +6 -7
- package/dist/breadcrumbs/esp-breadcrumbs.d.ts +16 -9
- package/dist/breadcrumbs/esp-breadcrumbs.js +9 -6
- package/dist/button/paint-registration.js +1 -0
- package/dist/cli/theme-check.js +2 -2
- package/dist/font-picker/esp-font-picker.d.ts +11 -14
- package/dist/font-picker/esp-font-picker.js +5 -5
- package/dist/footer/esp-footer-link-group.js +1 -1
- package/dist/footer/esp-footer.d.ts +5 -0
- package/dist/footer/esp-footer.js +10 -4
- package/dist/footer/paint-registration.js +1 -0
- package/dist/header/esp-header-button.js +5 -1
- package/dist/header/esp-header.js +12 -8
- package/dist/header/header-geometry-controller.js +1 -1
- package/dist/header/is-tall-header-paint.d.ts +7 -0
- package/dist/header/is-tall-header-paint.js +1 -0
- package/dist/header/paint-registration.js +1 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.js +1 -1
- package/dist/menu/esp-menu-group.js +8 -8
- package/dist/menu/esp-menu-item.js +8 -8
- package/dist/menu/esp-menu.js +10 -6
- package/dist/menu/navigation-focus-outline.js +8 -0
- package/dist/menu/navigation-paint.js +1 -0
- package/dist/menu/paint-registration.js +1 -0
- package/dist/pickers/esp-picker-item.js +1 -1
- package/dist/root/esp-root.d.ts +8 -1
- package/dist/root/esp-root.js +47 -10
- package/dist/root/helpers/compute-semantic-properties.js +1 -1
- package/dist/root/helpers/compute-theme-properties.js +1 -1
- package/dist/root/helpers/data-companion-properties.js +1 -1
- package/dist/root/helpers/lightness-ramp-properties.js +1 -1
- package/dist/shared/blockquote-styles.d.ts +3 -0
- package/dist/shared/blockquote-styles.js +4 -4
- package/dist/shared/color-engine.js +1 -1
- package/dist/shared/component-property-compiler.js +1 -0
- package/dist/shared/component-property-diagnostics.js +1 -0
- package/dist/shared/component-property-normalizer.js +1 -0
- package/dist/shared/component-property-resets.js +1 -0
- package/dist/shared/composed-dom.js +1 -0
- package/dist/shared/configured-brand-color.js +1 -0
- package/dist/shared/configured-brand.js +5 -5
- package/dist/shared/css-named-colors.js +1 -0
- package/dist/shared/document-sprite.js +1 -1
- package/dist/shared/esp-element-base.d.ts +3 -0
- package/dist/shared/esp-element-base.js +3 -3
- package/dist/shared/font-helpers.d.ts +3 -3
- package/dist/shared/font-helpers.js +1 -1
- package/dist/shared/font-plan.d.ts +1 -1
- package/dist/shared/governing-root.d.ts +24 -0
- package/dist/shared/governing-root.js +1 -0
- package/dist/shared/intent-values.js +1 -1
- package/dist/shared/paint-catalog.d.ts +27 -0
- package/dist/shared/paint-catalog.js +1 -0
- package/dist/shared/paint-color.d.ts +25 -0
- package/dist/shared/paint-color.js +1 -0
- package/dist/shared/paint-fit.js +1 -0
- package/dist/shared/paint-identity.js +1 -0
- package/dist/shared/paint-types.d.ts +88 -0
- package/dist/shared/paint-types.js +0 -0
- package/dist/shared/public-token-catalog.generated.js +1 -0
- package/dist/shared/root-event-subscription.d.ts +11 -0
- package/dist/shared/scoped-style-declarations.js +1 -0
- package/dist/shared/semantic-color-names.d.ts +16 -0
- package/dist/shared/semantic-color-names.js +1 -0
- package/dist/shared/settable-component-properties.js +1 -0
- package/dist/shared/theme-core.d.ts +808 -0
- package/dist/shared/theme-core.js +1 -0
- package/dist/shared/theme-fit-report.d.ts +39 -5
- package/dist/shared/theme-fit-report.js +1 -1
- package/dist/shared/theme-mapping-grammar.d.ts +16 -0
- package/dist/shared/theme-mapping-grammar.js +1 -0
- package/dist/shared/theme-properties.d.ts +3 -1
- package/dist/shared/theme-properties.js +1 -1
- package/dist/shared/theme-validation.d.ts +52 -0
- package/dist/shared/theme-validation.js +1 -0
- package/dist/shared/theme.d.ts +6 -899
- package/dist/shared/theme.js +1 -1
- package/dist/shared/token-pairings.d.ts +25 -0
- package/dist/shared/token-pairings.js +1 -0
- package/dist/shared/wcag-contrast.d.ts +14 -0
- package/dist/shared/wcag-contrast.js +1 -0
- package/dist/testing/index.d.ts +7 -0
- package/dist/testing/index.js +1 -0
- package/dist/testing/observe-paint.d.ts +29 -0
- package/dist/testing/observe-paint.iife.js +3 -0
- package/dist/testing/observe-paint.js +3 -0
- package/dist/testing/paint-bands.js +1 -0
- package/dist/testing/paint-coverage.d.ts +14 -0
- package/dist/testing/paint-coverage.js +1 -0
- package/dist/testing/paint-dom.js +1 -0
- package/dist/testing/svg-paint.js +1 -0
- package/espalier.css-data.json +62 -2
- package/espalier.token-manifest.json +5724 -29
- package/package.json +10 -1
package/dist/menu/esp-menu.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var l=function(y,e,t,r){var n=arguments.length,s=n<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(y,e,t,r);else for(var o=y.length-1;o>=0;o--)(i=y[o])&&(s=(n<3?i(s):n>3?i(e,t,s):i(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},C;import{css as L,html as E,nothing as m}from"lit";import{customElement as _,eventOptions as H,property as h,state as S}from"lit/decorators.js";import{classMap as g}from"lit/directives/class-map.js";import{createRef as u,ref as p}from"lit/directives/ref.js";import{styleMap as z}from"lit/directives/style-map.js";import{EspalierElementBase as D}from"../shared/esp-element-base.js";import{ESP_EVENTS as x}from"../shared/events.js";import{getEspBus as I}from"../shared/bus-events.js";import{normalizePath as $,pathStartsWithSegment as N,pathsMatch as k}from"../shared/path-matching.js";import{renderConfiguredBrand as G}from"../shared/configured-brand.js";import{FOCUSABLE_SELECTOR as R,OverlayController as T}from"../shared/overlay-controller.js";import{SwipeRevealController as q}from"./swipe-reveal-controller.js";import"./esp-menu-item.js";import"./esp-menu-group.js";import"../burger/esp-burger.js";import{EspalierMenuItem as b}from"./esp-menu-item.js";import{EspalierMenuGroup as v}from"./esp-menu-group.js";import{COMPACT_VIEWPORT_MEDIA_QUERY as U}from"../shared/responsive.js";import{RafThrottle as A}from"../shared/raf-throttle.js";import{viewportSize as B}from"../shared/viewport.js";import{solveDrawerNestedFit as K}from"./drawer-nested-fit.js";import{collectMenuNodes as P,renderMenuNode as W,MENU_SOURCE_CHANGED as M,MENU_PRESENTATION_CHANGED as j,MENU_LAYOUT_CHANGED as Q,MENU_FIT_PROBE_STYLES as V}from"./menu-presentation.js";const X=new Set(["panel","full-screen"]),Y=new Set(["fade","slide-down","slide-up","slide-left","slide-right"]);let a=C=class extends D{ownsDrawerLock(){return this.isFullScreenDrawer}fullScreenInertAnchor(){return C.inertAnchorFor(this)}static inertAnchorFor(e){let t=e,r=e;for(;;){const n=r.parentElement;if(n){if(n.localName==="esp-page"||n.localName==="esp-root")return r;n===document.body&&(t=r),r=n;continue}const s=r.getRootNode();if(s instanceof ShadowRoot&&s.host instanceof HTMLElement){r=s.host;continue}return t}}constructor(){super(),this.itemsSlot=u(),this.railRef=u(),this.scrimRef=u(),this.drawerRef=u(),this.bus=I(),this.closeTransitionTimer=null,this.drawerGroupOpenOverrides=new Map,this.overlay=new T({host:this,getFocusTrapContainer:()=>this.drawerRef.value??null,getFocusScope:()=>this.fullScreenFocusScope(),getInertAnchor:()=>this.fullScreenInertAnchor(),promote:!1,scrollLock:{preserveScrollPosition:!0}}),this.fullScreenSession=!1,this.openedFullScreen=!1,this.drawerKeydownAttached=!1,this.nestedFitProbe=u(),this.nestedFitCapProbe=u(),this.nestedFitFloorProbe=u(),this.nestedFitPadProbe=u(),this.nestedFitTextProbe=u(),this.nestedFit=null,this.nestedFitMeasured=!1,this.nestedFitIdleHandle=null,this.nestedFitFallback=null,this.nestedFitResize=new A(()=>this.measureNestedFit()),this.nestedFitObserver=null,this.onNestedFitResize=()=>{this.headerNavigationOwned&&this.headerLayout.schedule(),this.drawerPresentation==="full-screen"&&this.nestedFitResize.schedule()},this.onNestedFitFontsLoaded=()=>{this.scheduleNestedFit(!0),this.headerNavigationOwned&&this.headerLayout.schedule()},this.onOverlayOpened=e=>{if(e===this.overlay||!this.drawerOpen)return;const t=this.drawerTrigger;this.drawerTrigger=null,t&&e.redirectFocusRestore(t),this.swipeController.closeForHandoff(),this.onDrawerTransitionEnd()},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.drawerPresentation="panel",this.fullScreenTransition="fade",this.drawerBrand=null,this.liftedCloseControl=null,this.ariaLabel=null,this.autoExpand=!1,this.drawerOpen=!1,this.drawerShown=!1,this.drawerTransitioning=!1,this.drawerTrigger=null,this.headerEndOwner=null,this.promotedItems=new Set,this.observedHeaderRail=null,this.headerLayout=new A(()=>{this.headerNavigationOwned&&this.notifyHeaderLayout()}),this.headerFitObserver=new ResizeObserver(()=>this.headerLayout.schedule()),this.sourceObserver=null,this.onSourceChanged=e=>{const t=e.composedPath()[0];!(t instanceof Element)||!this.contains(t)||t.closest("esp-menu")!==this||(this.headerNavigationOwned||this.drawerOpen||this.drawerTransitioning)&&this.refreshHeaderSources()},this.hasExternalDrawerControl=!1,this.previewCollapseRequested=!1,this.getWidth=()=>{const e=this.railRef.value;return e?Math.max(e.scrollWidth,e.clientWidth):-1},this.onDrawerKeydown=e=>{!this.drawerOpen||!this.openedFullScreen||e.key==="Tab"&&this.overlay.trapFocus(e)},this.onDrawerTransitionEnd=e=>{e&&e.target!==this.drawerRef.value||(this.closeTransitionTimer&&(clearTimeout(this.closeTransitionTimer),this.closeTransitionTimer=null),this.drawerTransitioning=!1,this.drawerOpen||(this.hideDrawerPopover(),this.drawerGroupOpenOverrides.clear()))},this.handleDrawerCloseClick=()=>{this.closeDrawer()},this.swipeController=new q(this,this.side),this.swipeController.enabled=!1}get isFullScreenDrawer(){return X.has(this.drawerPresentation)?this.drawerPresentation==="full-screen":!1}get resolvedFullScreenTransition(){return Y.has(this.fullScreenTransition)?this.fullScreenTransition:"fade"}get sliding(){return this._sliding}set sliding(e){const t=this._sliding;this._sliding=e,this.syncSwipeEnabled(),this.propagateToItems(),this.requestUpdate("sliding",t)}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.previewCollapseRequested)&&this.hasExternalDrawerControl}get headerDrawerActive(){return this.drawerActive||this.drawerOpen||this.drawerTransitioning}get headerNavigationOwned(){return this.mode==="horizontal"&&this.headerEndOwner===this.parentElement&&this.slot==="menu"&&this.isConnected}get headerEndNodes(){return this.headerNavigationOwned?P(this.getAssignedChildren(),void 0,{headerEndOnly:!0}):[]}getHeaderNavigationWidths(){return{main:this.railRef.value?.getBoundingClientRect().width??0}}syncHeaderEndSources(){const e=new Set(this.headerEndNodes.flatMap(t=>t.originalItem?[t.originalItem]:[]));for(const t of this.promotedItems)e.has(t)||t.setHeaderEndPromoted(!1);for(const t of this.getAssignedChildren())t instanceof b&&t.setHeaderEndPromoted(e.has(t));this.promotedItems=e}bindHeaderObservation(){const e=this.headerNavigationOwned?this.railRef.value??null:null;e!==this.observedHeaderRail&&(this.headerFitObserver.disconnect(),this.observedHeaderRail=e,e&&this.headerFitObserver.observe(e,{box:"border-box"})),e&&!this.sourceObserver?(this.sourceObserver=new MutationObserver(t=>{t.some(r=>this.isHeaderSourceMutation(r))&&this.refreshHeaderSources()}),this.sourceObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["header-end","url","appearance","style","class"]})):e||(this.sourceObserver?.disconnect(),this.sourceObserver=null)}isHeaderSourceMutation(e){const t=e.target;return t instanceof Element?t===this?!0:t.closest("esp-menu")!==this?!1:e.type==="attributes"?t.parentElement===this&&(t instanceof b||t instanceof v):t instanceof b||t instanceof v:!1}notifyHeaderPresentation(){this.dispatchEvent(new CustomEvent(j))}notifyHeaderLayout(){this.dispatchEvent(new CustomEvent(Q))}refreshHeaderSources(){this.syncHeaderEndSources(),this.requestUpdate(),this.headerNavigationOwned&&this.headerLayout.schedule()}get railMode(){return this.mode==="horizontal"?"horizontal":"vertical"}connectedCallback(){super.connectedCallback(),this.addEventListener(M,this.onSourceChanged),this.updateComplete.then(()=>{this.isConnected&&(this.propagateToItems(),this.bindHeaderObservation())}),this.getAttribute("slot")==="right"&&(this.side="right"),!this.verticalDrawerQuery&&typeof window<"u"&&"matchMedia"in window&&(this.verticalDrawerQuery=window.matchMedia(U),this._mobileCollapsed=this.verticalDrawerQuery.matches,this.verticalDrawerQuery.addEventListener("change",this.onVerticalDrawerChange)),this.syncSwipeEnabled(),T.addOpenListener(this.onOverlayOpened),window.addEventListener("resize",this.onNestedFitResize),typeof document<"u"&&document.fonts&&(document.fonts.addEventListener("loadingdone",this.onNestedFitFontsLoaded),document.fonts.ready.then(()=>{this.isConnected&&this.onNestedFitFontsLoaded()})),!this.nestedFitObserver&&typeof MutationObserver<"u"&&(this.nestedFitObserver=new MutationObserver(()=>this.scheduleNestedFit(!0)),this.nestedFitObserver.observe(this,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["label"]}))}disconnectedCallback(){this.removeEventListener(M,this.onSourceChanged),this.sourceObserver?.disconnect(),this.sourceObserver=null,this.headerFitObserver.disconnect(),this.headerEndOwner=null,this.observedHeaderRail=null,this.headerLayout.cancel();for(const e of this.promotedItems)e.setHeaderEndPromoted(!1);this.promotedItems.clear(),T.removeOpenListener(this.onOverlayOpened),window.removeEventListener("resize",this.onNestedFitResize),document.fonts?.removeEventListener("loadingdone",this.onNestedFitFontsLoaded),this.nestedFitObserver?.disconnect(),this.nestedFitObserver=null,this.nestedFitResize.cancel(),this.cancelNestedFitIdle(),this.nestedFitMeasured=!1,this.verticalDrawerQuery?.removeEventListener("change",this.onVerticalDrawerChange),this.verticalDrawerQuery=null,this.detachDrawerKeydown(),this.fullScreenSession=!1,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(),this.scheduleNestedFit()}willUpdate(e){super.willUpdate(e),this.syncHeaderEndSources()}updated(e){super.updated(e),this.bindHeaderObservation(),["mode","overflow","headerEndOwner"].some(t=>e.has(t))&&this.notifyHeaderLayout(),["drawerOpen","drawerTransitioning","sliding","ariaLabel"].some(t=>e.has(t))&&this.notifyHeaderPresentation(),(e.has("mode")||e.has("overflow")||e.has("headerEndOwner")||e.has("side")||e.has("hasExternalDrawerControl")||e.has("previewCollapseRequested")||e.has("drawerOpen")||e.has("drawerTransitioning"))&&(this.swipeController.direction=this.drawerSide,this.syncSwipeEnabled(),this.propagateToItems(),!this.drawerActive&&this.drawerOpen&&this.swipeController.close(!0)),e.has("drawerPresentation")&&(this.nestedFitMeasured=!1,this.scheduleNestedFit()),this.drawerOpen&&this.openedFullScreen!==this.isFullScreenDrawer&&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)}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 t of this.getAssignedChildren())t instanceof b?(t.mode=e,t.depth=0,t.touchDevice=this.swipeController.isTouch):t instanceof v&&(t.mode=e,t.depth=0,t.touchDevice=this.swipeController.isTouch,t.scrollPanelEnabled=e==="horizontal"&&(this.headerNavigationOwned||this.overflow==="scroll")&&!this.headerDrawerActive)}handleSlotChange(){this.propagateToItems(),this.refreshHeaderSources(),this.scheduleNestedFit(!0)}scheduleNestedFit(e=!1){if(this.drawerPresentation!=="full-screen"){this.cancelNestedFitIdle(),this.nestedFit!==null&&(this.nestedFit=null);return}if(e&&(this.nestedFitMeasured=!1),e&&this.drawerShown){this.cancelNestedFitIdle(),this.nestedFitResize.schedule();return}if(this.nestedFitIdleHandle!==null||this.nestedFitFallback!==null)return;const t=()=>{this.nestedFitIdleHandle=null,this.nestedFitFallback=null,this.isConnected&&this.measureNestedFit()};typeof requestIdleCallback=="function"?this.nestedFitIdleHandle=requestIdleCallback(t,{timeout:2e3}):this.nestedFitFallback={stage:"frame",handle:requestAnimationFrame(()=>{this.nestedFitFallback={stage:"timeout",handle:window.setTimeout(t,0)}})}}cancelNestedFitIdle(){this.nestedFitIdleHandle!==null&&(cancelIdleCallback(this.nestedFitIdleHandle),this.nestedFitIdleHandle=null),this.nestedFitFallback!==null&&(this.nestedFitFallback.stage==="frame"?cancelAnimationFrame(this.nestedFitFallback.handle):window.clearTimeout(this.nestedFitFallback.handle),this.nestedFitFallback=null)}ensureNestedFitMeasured(){this.nestedFitMeasured||(this.cancelNestedFitIdle(),this.measureNestedFit())}collectNestedLabels(){const e=[];let t=!1;const r=(n,s)=>{for(const i of n){const o=s>0;i instanceof b?o&&e.push(i.label):i instanceof v&&(o&&(e.push(i.label),i.url&&(t=!0)),r(Array.from(i.children),s+1))}};return r(this.getAssignedChildren(),0),{labels:e,linkedGroup:t}}readNestedFitMetrics(e){const t=this.nestedFitCapProbe.value,r=this.nestedFitFloorProbe.value,n=this.nestedFitPadProbe.value,s=this.nestedFitTextProbe.value;if(!t||!r||!n||!s)return null;const i=parseFloat(getComputedStyle(t).fontSize),o=parseFloat(getComputedStyle(r).fontSize),d=getComputedStyle(n),c=parseFloat(d.paddingInlineStart),F=parseFloat(d.paddingInlineEnd);if(![i,o,c,F].every(w=>Number.isFinite(w)))return null;s.replaceChildren(...e.map(w=>{const O=document.createElement("span");return O.textContent=w,O}));const f=Array.from(s.children,w=>w.getBoundingClientRect().width);return s.replaceChildren(),{capPx:i,floorPx:o,paddingPx:c,smallPx:F,widths:f}}measureNestedFit(){if(!this.isConnected||this.drawerPresentation!=="full-screen")return;const{labels:e,linkedGroup:t}=this.collectNestedLabels();if(this.nestedFitMeasured=!0,e.length===0){this.nestedFit!==null&&(this.nestedFit=null);return}const r=this.readNestedFitMetrics(e);if(!r)return;const n=this.drawerRef.value,s=n&&this.drawerShown?n.getBoundingClientRect().width:0,i=s>0?s:B().width,o=t?2*(2*r.smallPx+4.5):0,d=i-2*r.paddingPx-o,c=K({capPx:r.capPx,floorPx:r.floorPx,availablePx:d,widestAtCapPx:Math.max(0,...r.widths)});this.nestedFit&&this.nestedFit.fontSizePx===c.fontSizePx&&this.nestedFit.wrap===c.wrap||(this.nestedFit=c)}onSwipeRevealChanged(e){e!==this.drawerOpen&&(this.drawerOpen=e,e?(this.openedFullScreen=this.isFullScreenDrawer,this.openedFullScreen&&this.ensureNestedFitMeasured(),this.drawerGroupOpenOverrides.clear(),this.bus.publish("close-popovers",{}),this.updateComplete.then(()=>this.showDrawerPopover())):(this.detachDrawerKeydown(),this.fullScreenSession&&(this.fullScreenSession=!1,this.overlay.close()),this.drawerShown=!1,this.drawerTransitioning=!0,this.updateComplete.then(()=>this.startCloseTransition()),requestAnimationFrame(()=>this.restoreDrawerTriggerFocus())),this.dispatchEvent(new CustomEvent(e?x.MENU_DRAWER_OPENED:x.MENU_DRAWER_CLOSED,{bubbles:!0,composed:!0})))}showDrawerPopover(){const e=this.scrimRef.value,t=this.drawerRef.value;if(!(!e||!t||!this.isConnected)){this.swipeController.drawerElement=t;try{this.openedFullScreen||e.showPopover(),t.showPopover()}catch{}this.dispatchEvent(new CustomEvent(x.MENU_DRAWER_PRESENTED,{bubbles:!0,composed:!0})),t.getBoundingClientRect(),requestAnimationFrame(()=>{!this.drawerOpen||!this.isConnected||(this.drawerTransitioning=!0,this.drawerShown=!0,this.openedFullScreen&&(this.fullScreenSession=!0,this.overlay.open(),this.attachDrawerKeydown(),this.updateComplete.then(()=>{this.drawerOpen&&this.overlay.moveFocusInto()})))})}}attachDrawerKeydown(){this.drawerKeydownAttached||(document.addEventListener("keydown",this.onDrawerKeydown),this.drawerKeydownAttached=!0)}detachDrawerKeydown(){this.drawerKeydownAttached&&(document.removeEventListener("keydown",this.onDrawerKeydown),this.drawerKeydownAttached=!1)}fullScreenFocusScope(){const e=this.drawerRef.value;if(!e)return[];const t=i=>i instanceof HTMLElement&&i.getClientRects().length>0,r=[],n=i=>{if(i.matches(R)&&t(i)&&r.push(i),i.shadowRoot)for(const o of i.shadowRoot.querySelectorAll(R))t(o)&&r.push(o)};for(const i of e.querySelectorAll("*"))if(n(i),i instanceof HTMLSlotElement)for(const o of i.assignedElements({flatten:!0})){n(o);for(const d of o.querySelectorAll("*"))n(d)}const s=this.liftedCloseControl;if(s?.isConnected){const i=s.shadowRoot?.querySelector("button")??s;t(i)&&r.push(i)}return r}static drawerTransitionMs(e){const t=getComputedStyle(e),r=o=>o.split(",").map(d=>d.trim()).filter(Boolean).map(d=>{const c=Number.parseFloat(d);return Number.isFinite(c)?d.endsWith("ms")?c:c*1e3:0}),n=r(t.transitionDuration),s=r(t.transitionDelay);let i=0;return n.forEach((o,d)=>{i=Math.max(i,o+(s[d%Math.max(s.length,1)]??0))}),i}startCloseTransition(){const e=this.drawerRef.value;if(!e){this.hideDrawerPopover();return}this.closeTransitionTimer&&clearTimeout(this.closeTransitionTimer);const t=C.drawerTransitionMs(e);if(t===0){this.onDrawerTransitionEnd();return}this.closeTransitionTimer=setTimeout(()=>{this.closeTransitionTimer=null,!this.drawerOpen&&this.drawerTransitioning&&this.onDrawerTransitionEnd()},t+50)}hideDrawerPopover(){const e=this.scrimRef.value,t=this.drawerRef.value;this.swipeController.drawerElement=null,t&&(t.style.cssText="");try{t?.hidePopover()}catch{}try{e?.hidePopover()}catch{}}restoreDrawerTriggerFocus(){const e=this.drawerTrigger;this.drawerTrigger=null,e?.isConnected&&e.focus({preventScroll:!0})}getAutoExpandedGroups(e=!0){const t=new Set;let r=null;for(const s of this.querySelectorAll("esp-menu-item")){const i=s.url||s.getAttribute("url");if(i&&k(i)){r=s;break}}if(!r)for(const s of this.querySelectorAll("esp-menu-group")){const i=s.url||s.getAttribute("url");if(i&&k(i)){r=s;break}}if(!r&&e){for(const s of this.querySelectorAll("esp-menu-group"))s.parentElement===this&&t.add(s);return t}if(!r)return t;r instanceof v&&t.add(r);let n=r.parentElement;for(;n&&n!==this;)n instanceof v&&t.add(n),n=n.parentElement;return t}isHorizontalTopLevelGroup(e){return e.mode==="horizontal"&&e.depth===0}groupUrlPrefixMatches(e){return N(location.pathname,e.urlPrefix)}groupPathMatches(e){if(this.groupUrlPrefixMatches(e))return!0;const t=e.url||e.getAttribute("url");return t?N(location.pathname,$(t)):!1}expandToCurrentPage(){const e=this.getAutoExpandedGroups(),t=this.querySelectorAll("esp-menu-group");for(const r of t)r.open=e.has(r)&&!this.isHorizontalTopLevelGroup(r)}closeHorizontalTopLevelGroups(){for(const e of this.querySelectorAll("esp-menu-group"))this.isHorizontalTopLevelGroup(e)&&(e.open=!1)}getDrawerAutoExpandedGroups(){return this.getAutoExpandedGroups(!1)}collectDrawerNodes(e){const t=this.getDrawerAutoExpandedGroups();return P(e,r=>this.drawerGroupOpenOverrides.get(r)??(r.open||t.has(r)||this.groupPathMatches(r)))}renderDrawerNode(e){return W(e,{mode:"drawer",sourceStyle:!0,fullScreen:this.openedFullScreen,itemClick:t=>this.handleDrawerItemClick(t),groupToggle:(t,r)=>{this.drawerGroupOpenOverrides.set(t,r),this.isHorizontalTopLevelGroup(t)||(t.open=r)}})}handleDrawerLinkClick(e){const t=e.composedPath().find(r=>r instanceof HTMLAnchorElement);!(t instanceof HTMLAnchorElement)||t.target.toLowerCase()!=="_blank"||setTimeout(()=>{e.defaultPrevented||this.closeDrawer()},0)}handleDrawerItemClick(e){e.dispatchEvent(new CustomEvent(x.CLICKED,{detail:{},bubbles:!0,composed:!0})),this.swipeController.close(!0)}render(){const e=this.drawerOpen||this.drawerTransitioning,t=this.headerDrawerActive,r={rail:!0,horizontal:this.railMode==="horizontal",vertical:this.railMode==="vertical",wrap:this.overflow==="wrap",scroll:this.overflow==="scroll","drawer-forced":this.drawerActive},n=e?this.openedFullScreen:this.isFullScreenDrawer,s={drawer:!0,"drawer-left":this.drawerSide==="left","drawer-right":this.drawerSide==="right","full-screen":n,[`transition-${this.resolvedFullScreenTransition}`]:n,transitioning:this.drawerTransitioning,open:this.drawerShown,"nested-wrap":n&&this.nestedFit?.wrap===!0},i={"--_esp-menu-drawer-nested-font-size":n&&this.nestedFit?`${this.nestedFit.fontSizePx}px`:null},o=e?this.collectDrawerNodes(this.getAssignedChildren()):[],d=this.ariaLabel??"Navigation",c={"--_esp-menu-drawer-brand-color":this.drawerBrand?.brandColor||null},F=n&&e?E`<div class=${g({"drawer-chrome":!0,"has-lifted-close":!!this.liftedCloseControl})}>
|
|
1
|
+
var l=function(y,e,t,r){var n=arguments.length,s=n<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(y,e,t,r);else for(var o=y.length-1;o>=0;o--)(i=y[o])&&(s=(n<3?i(s):n>3?i(e,t,s):i(e,t))||s);return n>3&&s&&Object.defineProperty(e,t,s),s},C;import{css as L,html as E,nothing as m}from"lit";import{configuredBrandFocusOutline as _,insetNavigationFocusOutline as H}from"./navigation-focus-outline.js";import{customElement as I,eventOptions as $,property as h,state as S}from"lit/decorators.js";import{classMap as g}from"lit/directives/class-map.js";import{createRef as u,ref as p}from"lit/directives/ref.js";import{styleMap as z}from"lit/directives/style-map.js";import{EspalierElementBase as D}from"../shared/esp-element-base.js";import{ESP_EVENTS as x}from"../shared/events.js";import{getEspBus as G}from"../shared/bus-events.js";import{normalizePath as q,pathStartsWithSegment as N,pathsMatch as k}from"../shared/path-matching.js";import{renderConfiguredBrand as U}from"../shared/configured-brand.js";import{FOCUSABLE_SELECTOR as R,OverlayController as T}from"../shared/overlay-controller.js";import{SwipeRevealController as B}from"./swipe-reveal-controller.js";import"./esp-menu-item.js";import"./esp-menu-group.js";import"../burger/esp-burger.js";import{EspalierMenuItem as b}from"./esp-menu-item.js";import{EspalierMenuGroup as v}from"./esp-menu-group.js";import{COMPACT_VIEWPORT_MEDIA_QUERY as K}from"../shared/responsive.js";import{RafThrottle as A}from"../shared/raf-throttle.js";import{viewportSize as W}from"../shared/viewport.js";import{solveDrawerNestedFit as j}from"./drawer-nested-fit.js";import{collectMenuNodes as P,renderMenuNode as Q,MENU_SOURCE_CHANGED as M,MENU_PRESENTATION_CHANGED as V,MENU_LAYOUT_CHANGED as X,MENU_FIT_PROBE_STYLES as Y}from"./menu-presentation.js";const J=new Set(["panel","full-screen"]),Z=new Set(["fade","slide-down","slide-up","slide-left","slide-right"]);let a=C=class extends D{ownsDrawerLock(){return this.isFullScreenDrawer}fullScreenInertAnchor(){return C.inertAnchorFor(this)}static inertAnchorFor(e){let t=e,r=e;for(;;){const n=r.parentElement;if(n){if(n.localName==="esp-page"||n.localName==="esp-root")return r;n===document.body&&(t=r),r=n;continue}const s=r.getRootNode();if(s instanceof ShadowRoot&&s.host instanceof HTMLElement){r=s.host;continue}return t}}constructor(){super(),this.itemsSlot=u(),this.railRef=u(),this.scrimRef=u(),this.drawerRef=u(),this.bus=G(),this.closeTransitionTimer=null,this.drawerGroupOpenOverrides=new Map,this.overlay=new T({host:this,getFocusTrapContainer:()=>this.drawerRef.value??null,getFocusScope:()=>this.fullScreenFocusScope(),getInertAnchor:()=>this.fullScreenInertAnchor(),promote:!1,scrollLock:{preserveScrollPosition:!0}}),this.fullScreenSession=!1,this.openedFullScreen=!1,this.drawerKeydownAttached=!1,this.nestedFitProbe=u(),this.nestedFitCapProbe=u(),this.nestedFitFloorProbe=u(),this.nestedFitPadProbe=u(),this.nestedFitTextProbe=u(),this.nestedFit=null,this.nestedFitMeasured=!1,this.nestedFitIdleHandle=null,this.nestedFitFallback=null,this.nestedFitResize=new A(()=>this.measureNestedFit()),this.nestedFitObserver=null,this.onNestedFitResize=()=>{this.headerNavigationOwned&&this.headerLayout.schedule(),this.drawerPresentation==="full-screen"&&this.nestedFitResize.schedule()},this.onNestedFitFontsLoaded=()=>{this.scheduleNestedFit(!0),this.headerNavigationOwned&&this.headerLayout.schedule()},this.onOverlayOpened=e=>{if(e===this.overlay||!this.drawerOpen)return;const t=this.drawerTrigger;this.drawerTrigger=null,t&&e.redirectFocusRestore(t),this.swipeController.closeForHandoff(),this.onDrawerTransitionEnd()},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.drawerPresentation="panel",this.fullScreenTransition="fade",this.drawerBrand=null,this.liftedCloseControl=null,this.ariaLabel=null,this.autoExpand=!1,this.drawerOpen=!1,this.drawerShown=!1,this.drawerTransitioning=!1,this.drawerTrigger=null,this.headerEndOwner=null,this.promotedItems=new Set,this.observedHeaderRail=null,this.headerLayout=new A(()=>{this.headerNavigationOwned&&this.notifyHeaderLayout()}),this.headerFitObserver=new ResizeObserver(()=>this.headerLayout.schedule()),this.sourceObserver=null,this.onSourceChanged=e=>{const t=e.composedPath()[0];!(t instanceof Element)||!this.contains(t)||t.closest("esp-menu")!==this||(this.headerNavigationOwned||this.drawerOpen||this.drawerTransitioning)&&this.refreshHeaderSources()},this.hasExternalDrawerControl=!1,this.previewCollapseRequested=!1,this.getWidth=()=>{const e=this.railRef.value;return e?Math.max(e.scrollWidth,e.clientWidth):-1},this.onDrawerKeydown=e=>{!this.drawerOpen||!this.openedFullScreen||e.key==="Tab"&&this.overlay.trapFocus(e)},this.onDrawerTransitionEnd=e=>{e&&e.target!==this.drawerRef.value||(this.closeTransitionTimer&&(clearTimeout(this.closeTransitionTimer),this.closeTransitionTimer=null),this.drawerTransitioning=!1,this.drawerOpen||(this.hideDrawerPopover(),this.drawerGroupOpenOverrides.clear()))},this.handleDrawerCloseClick=()=>{this.closeDrawer()},this.swipeController=new B(this,this.side),this.swipeController.enabled=!1}get isFullScreenDrawer(){return J.has(this.drawerPresentation)?this.drawerPresentation==="full-screen":!1}get resolvedFullScreenTransition(){return Z.has(this.fullScreenTransition)?this.fullScreenTransition:"fade"}get sliding(){return this._sliding}set sliding(e){const t=this._sliding;this._sliding=e,this.syncSwipeEnabled(),this.propagateToItems(),this.requestUpdate("sliding",t)}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.previewCollapseRequested)&&this.hasExternalDrawerControl}get headerDrawerActive(){return this.drawerActive||this.drawerOpen||this.drawerTransitioning}get headerNavigationOwned(){return this.mode==="horizontal"&&this.headerEndOwner===this.parentElement&&this.slot==="menu"&&this.isConnected}get headerEndNodes(){return this.headerNavigationOwned?P(this.getAssignedChildren(),void 0,{headerEndOnly:!0}):[]}getHeaderNavigationWidths(){return{main:this.railRef.value?.getBoundingClientRect().width??0}}syncHeaderEndSources(){const e=new Set(this.headerEndNodes.flatMap(t=>t.originalItem?[t.originalItem]:[]));for(const t of this.promotedItems)e.has(t)||t.setHeaderEndPromoted(!1);for(const t of this.getAssignedChildren())t instanceof b&&t.setHeaderEndPromoted(e.has(t));this.promotedItems=e}bindHeaderObservation(){const e=this.headerNavigationOwned?this.railRef.value??null:null;e!==this.observedHeaderRail&&(this.headerFitObserver.disconnect(),this.observedHeaderRail=e,e&&this.headerFitObserver.observe(e,{box:"border-box"})),e&&!this.sourceObserver?(this.sourceObserver=new MutationObserver(t=>{t.some(r=>this.isHeaderSourceMutation(r))&&this.refreshHeaderSources()}),this.sourceObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["header-end","url","appearance","style","class"]})):e||(this.sourceObserver?.disconnect(),this.sourceObserver=null)}isHeaderSourceMutation(e){const t=e.target;return t instanceof Element?t===this?!0:t.closest("esp-menu")!==this?!1:e.type==="attributes"?t.parentElement===this&&(t instanceof b||t instanceof v):t instanceof b||t instanceof v:!1}notifyHeaderPresentation(){this.dispatchEvent(new CustomEvent(V))}notifyHeaderLayout(){this.dispatchEvent(new CustomEvent(X))}refreshHeaderSources(){this.syncHeaderEndSources(),this.requestUpdate(),this.headerNavigationOwned&&this.headerLayout.schedule()}get railMode(){return this.mode==="horizontal"?"horizontal":"vertical"}connectedCallback(){super.connectedCallback(),this.addEventListener(M,this.onSourceChanged),this.updateComplete.then(()=>{this.isConnected&&(this.propagateToItems(),this.bindHeaderObservation())}),this.getAttribute("slot")==="right"&&(this.side="right"),!this.verticalDrawerQuery&&typeof window<"u"&&"matchMedia"in window&&(this.verticalDrawerQuery=window.matchMedia(K),this._mobileCollapsed=this.verticalDrawerQuery.matches,this.verticalDrawerQuery.addEventListener("change",this.onVerticalDrawerChange)),this.syncSwipeEnabled(),T.addOpenListener(this.onOverlayOpened),window.addEventListener("resize",this.onNestedFitResize),typeof document<"u"&&document.fonts&&(document.fonts.addEventListener("loadingdone",this.onNestedFitFontsLoaded),document.fonts.ready.then(()=>{this.isConnected&&this.onNestedFitFontsLoaded()})),!this.nestedFitObserver&&typeof MutationObserver<"u"&&(this.nestedFitObserver=new MutationObserver(()=>this.scheduleNestedFit(!0)),this.nestedFitObserver.observe(this,{subtree:!0,childList:!0,attributes:!0,attributeFilter:["label"]}))}disconnectedCallback(){this.removeEventListener(M,this.onSourceChanged),this.sourceObserver?.disconnect(),this.sourceObserver=null,this.headerFitObserver.disconnect(),this.headerEndOwner=null,this.observedHeaderRail=null,this.headerLayout.cancel();for(const e of this.promotedItems)e.setHeaderEndPromoted(!1);this.promotedItems.clear(),T.removeOpenListener(this.onOverlayOpened),window.removeEventListener("resize",this.onNestedFitResize),document.fonts?.removeEventListener("loadingdone",this.onNestedFitFontsLoaded),this.nestedFitObserver?.disconnect(),this.nestedFitObserver=null,this.nestedFitResize.cancel(),this.cancelNestedFitIdle(),this.nestedFitMeasured=!1,this.verticalDrawerQuery?.removeEventListener("change",this.onVerticalDrawerChange),this.verticalDrawerQuery=null,this.detachDrawerKeydown(),this.fullScreenSession=!1,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(),this.scheduleNestedFit()}willUpdate(e){super.willUpdate(e),this.syncHeaderEndSources()}updated(e){super.updated(e),this.bindHeaderObservation(),["mode","overflow","headerEndOwner"].some(t=>e.has(t))&&this.notifyHeaderLayout(),["drawerOpen","drawerTransitioning","sliding","ariaLabel"].some(t=>e.has(t))&&this.notifyHeaderPresentation(),(e.has("mode")||e.has("overflow")||e.has("headerEndOwner")||e.has("side")||e.has("hasExternalDrawerControl")||e.has("previewCollapseRequested")||e.has("drawerOpen")||e.has("drawerTransitioning"))&&(this.swipeController.direction=this.drawerSide,this.syncSwipeEnabled(),this.propagateToItems(),!this.drawerActive&&this.drawerOpen&&this.swipeController.close(!0)),e.has("drawerPresentation")&&(this.nestedFitMeasured=!1,this.scheduleNestedFit()),this.drawerOpen&&this.openedFullScreen!==this.isFullScreenDrawer&&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)}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 t of this.getAssignedChildren())t instanceof b?(t.mode=e,t.depth=0,t.touchDevice=this.swipeController.isTouch):t instanceof v&&(t.mode=e,t.depth=0,t.touchDevice=this.swipeController.isTouch,t.scrollPanelEnabled=e==="horizontal"&&(this.headerNavigationOwned||this.overflow==="scroll")&&!this.headerDrawerActive)}handleSlotChange(){this.propagateToItems(),this.refreshHeaderSources(),this.scheduleNestedFit(!0)}scheduleNestedFit(e=!1){if(this.drawerPresentation!=="full-screen"){this.cancelNestedFitIdle(),this.nestedFit!==null&&(this.nestedFit=null);return}if(e&&(this.nestedFitMeasured=!1),e&&this.drawerShown){this.cancelNestedFitIdle(),this.nestedFitResize.schedule();return}if(this.nestedFitIdleHandle!==null||this.nestedFitFallback!==null)return;const t=()=>{this.nestedFitIdleHandle=null,this.nestedFitFallback=null,this.isConnected&&this.measureNestedFit()};typeof requestIdleCallback=="function"?this.nestedFitIdleHandle=requestIdleCallback(t,{timeout:2e3}):this.nestedFitFallback={stage:"frame",handle:requestAnimationFrame(()=>{this.nestedFitFallback={stage:"timeout",handle:window.setTimeout(t,0)}})}}cancelNestedFitIdle(){this.nestedFitIdleHandle!==null&&(cancelIdleCallback(this.nestedFitIdleHandle),this.nestedFitIdleHandle=null),this.nestedFitFallback!==null&&(this.nestedFitFallback.stage==="frame"?cancelAnimationFrame(this.nestedFitFallback.handle):window.clearTimeout(this.nestedFitFallback.handle),this.nestedFitFallback=null)}ensureNestedFitMeasured(){this.nestedFitMeasured||(this.cancelNestedFitIdle(),this.measureNestedFit())}collectNestedLabels(){const e=[];let t=!1;const r=(n,s)=>{for(const i of n){const o=s>0;i instanceof b?o&&e.push(i.label):i instanceof v&&(o&&(e.push(i.label),i.url&&(t=!0)),r(Array.from(i.children),s+1))}};return r(this.getAssignedChildren(),0),{labels:e,linkedGroup:t}}readNestedFitMetrics(e){const t=this.nestedFitCapProbe.value,r=this.nestedFitFloorProbe.value,n=this.nestedFitPadProbe.value,s=this.nestedFitTextProbe.value;if(!t||!r||!n||!s)return null;const i=parseFloat(getComputedStyle(t).fontSize),o=parseFloat(getComputedStyle(r).fontSize),d=getComputedStyle(n),c=parseFloat(d.paddingInlineStart),F=parseFloat(d.paddingInlineEnd);if(![i,o,c,F].every(w=>Number.isFinite(w)))return null;s.replaceChildren(...e.map(w=>{const O=document.createElement("span");return O.textContent=w,O}));const f=Array.from(s.children,w=>w.getBoundingClientRect().width);return s.replaceChildren(),{capPx:i,floorPx:o,paddingPx:c,smallPx:F,widths:f}}measureNestedFit(){if(!this.isConnected||this.drawerPresentation!=="full-screen")return;const{labels:e,linkedGroup:t}=this.collectNestedLabels();if(this.nestedFitMeasured=!0,e.length===0){this.nestedFit!==null&&(this.nestedFit=null);return}const r=this.readNestedFitMetrics(e);if(!r)return;const n=this.drawerRef.value,s=n&&this.drawerShown?n.getBoundingClientRect().width:0,i=s>0?s:W().width,o=t?2*(2*r.smallPx+4.5):0,d=i-2*r.paddingPx-o,c=j({capPx:r.capPx,floorPx:r.floorPx,availablePx:d,widestAtCapPx:Math.max(0,...r.widths)});this.nestedFit&&this.nestedFit.fontSizePx===c.fontSizePx&&this.nestedFit.wrap===c.wrap||(this.nestedFit=c)}onSwipeRevealChanged(e){e!==this.drawerOpen&&(this.drawerOpen=e,e?(this.openedFullScreen=this.isFullScreenDrawer,this.openedFullScreen&&this.ensureNestedFitMeasured(),this.drawerGroupOpenOverrides.clear(),this.bus.publish("close-popovers",{}),this.updateComplete.then(()=>this.showDrawerPopover())):(this.detachDrawerKeydown(),this.fullScreenSession&&(this.fullScreenSession=!1,this.overlay.close()),this.drawerShown=!1,this.drawerTransitioning=!0,this.updateComplete.then(()=>this.startCloseTransition()),requestAnimationFrame(()=>this.restoreDrawerTriggerFocus())),this.dispatchEvent(new CustomEvent(e?x.MENU_DRAWER_OPENED:x.MENU_DRAWER_CLOSED,{bubbles:!0,composed:!0})))}showDrawerPopover(){const e=this.scrimRef.value,t=this.drawerRef.value;if(!(!e||!t||!this.isConnected)){this.swipeController.drawerElement=t;try{this.openedFullScreen||e.showPopover(),t.showPopover()}catch{}this.dispatchEvent(new CustomEvent(x.MENU_DRAWER_PRESENTED,{bubbles:!0,composed:!0})),t.getBoundingClientRect(),requestAnimationFrame(()=>{!this.drawerOpen||!this.isConnected||(this.drawerTransitioning=!0,this.drawerShown=!0,this.openedFullScreen&&(this.fullScreenSession=!0,this.overlay.open(),this.attachDrawerKeydown(),this.updateComplete.then(()=>{this.drawerOpen&&this.overlay.moveFocusInto()})))})}}attachDrawerKeydown(){this.drawerKeydownAttached||(document.addEventListener("keydown",this.onDrawerKeydown),this.drawerKeydownAttached=!0)}detachDrawerKeydown(){this.drawerKeydownAttached&&(document.removeEventListener("keydown",this.onDrawerKeydown),this.drawerKeydownAttached=!1)}fullScreenFocusScope(){const e=this.drawerRef.value;if(!e)return[];const t=i=>i instanceof HTMLElement&&i.getClientRects().length>0,r=[],n=i=>{if(i.matches(R)&&t(i)&&r.push(i),i.shadowRoot)for(const o of i.shadowRoot.querySelectorAll(R))t(o)&&r.push(o)};for(const i of e.querySelectorAll("*"))if(n(i),i instanceof HTMLSlotElement)for(const o of i.assignedElements({flatten:!0})){n(o);for(const d of o.querySelectorAll("*"))n(d)}const s=this.liftedCloseControl;if(s?.isConnected){const i=s.shadowRoot?.querySelector("button")??s;t(i)&&r.push(i)}return r}static drawerTransitionMs(e){const t=getComputedStyle(e),r=o=>o.split(",").map(d=>d.trim()).filter(Boolean).map(d=>{const c=Number.parseFloat(d);return Number.isFinite(c)?d.endsWith("ms")?c:c*1e3:0}),n=r(t.transitionDuration),s=r(t.transitionDelay);let i=0;return n.forEach((o,d)=>{i=Math.max(i,o+(s[d%Math.max(s.length,1)]??0))}),i}startCloseTransition(){const e=this.drawerRef.value;if(!e){this.hideDrawerPopover();return}this.closeTransitionTimer&&clearTimeout(this.closeTransitionTimer);const t=C.drawerTransitionMs(e);if(t===0){this.onDrawerTransitionEnd();return}this.closeTransitionTimer=setTimeout(()=>{this.closeTransitionTimer=null,!this.drawerOpen&&this.drawerTransitioning&&this.onDrawerTransitionEnd()},t+50)}hideDrawerPopover(){const e=this.scrimRef.value,t=this.drawerRef.value;this.swipeController.drawerElement=null,t&&(t.style.cssText="");try{t?.hidePopover()}catch{}try{e?.hidePopover()}catch{}}restoreDrawerTriggerFocus(){const e=this.drawerTrigger;this.drawerTrigger=null,e?.isConnected&&e.focus({preventScroll:!0})}getAutoExpandedGroups(e=!0){const t=new Set;let r=null;for(const s of this.querySelectorAll("esp-menu-item")){const i=s.url||s.getAttribute("url");if(i&&k(i)){r=s;break}}if(!r)for(const s of this.querySelectorAll("esp-menu-group")){const i=s.url||s.getAttribute("url");if(i&&k(i)){r=s;break}}if(!r&&e){for(const s of this.querySelectorAll("esp-menu-group"))s.parentElement===this&&t.add(s);return t}if(!r)return t;r instanceof v&&t.add(r);let n=r.parentElement;for(;n&&n!==this;)n instanceof v&&t.add(n),n=n.parentElement;return t}isHorizontalTopLevelGroup(e){return e.mode==="horizontal"&&e.depth===0}groupUrlPrefixMatches(e){return N(location.pathname,e.urlPrefix)}groupPathMatches(e){if(this.groupUrlPrefixMatches(e))return!0;const t=e.url||e.getAttribute("url");return t?N(location.pathname,q(t)):!1}expandToCurrentPage(){const e=this.getAutoExpandedGroups(),t=this.querySelectorAll("esp-menu-group");for(const r of t)r.open=e.has(r)&&!this.isHorizontalTopLevelGroup(r)}closeHorizontalTopLevelGroups(){for(const e of this.querySelectorAll("esp-menu-group"))this.isHorizontalTopLevelGroup(e)&&(e.open=!1)}getDrawerAutoExpandedGroups(){return this.getAutoExpandedGroups(!1)}collectDrawerNodes(e){const t=this.getDrawerAutoExpandedGroups();return P(e,r=>this.drawerGroupOpenOverrides.get(r)??(r.open||t.has(r)||this.groupPathMatches(r)))}renderDrawerNode(e){return Q(e,{mode:"drawer",sourceStyle:!0,fullScreen:this.openedFullScreen,itemClick:t=>this.handleDrawerItemClick(t),groupToggle:(t,r)=>{this.drawerGroupOpenOverrides.set(t,r),this.isHorizontalTopLevelGroup(t)||(t.open=r)}})}handleDrawerLinkClick(e){const t=e.composedPath().find(r=>r instanceof HTMLAnchorElement);!(t instanceof HTMLAnchorElement)||t.target.toLowerCase()!=="_blank"||setTimeout(()=>{e.defaultPrevented||this.closeDrawer()},0)}handleDrawerItemClick(e){e.dispatchEvent(new CustomEvent(x.CLICKED,{detail:{},bubbles:!0,composed:!0})),this.swipeController.close(!0)}render(){const e=this.drawerOpen||this.drawerTransitioning,t=this.headerDrawerActive,r={rail:!0,horizontal:this.railMode==="horizontal",vertical:this.railMode==="vertical",wrap:this.overflow==="wrap",scroll:this.overflow==="scroll","drawer-forced":this.drawerActive},n=e?this.openedFullScreen:this.isFullScreenDrawer,s={drawer:!0,"drawer-left":this.drawerSide==="left","drawer-right":this.drawerSide==="right","full-screen":n,[`transition-${this.resolvedFullScreenTransition}`]:n,transitioning:this.drawerTransitioning,open:this.drawerShown,"nested-wrap":n&&this.nestedFit?.wrap===!0},i={"--_esp-menu-drawer-nested-font-size":n&&this.nestedFit?`${this.nestedFit.fontSizePx}px`:null},o=e?this.collectDrawerNodes(this.getAssignedChildren()):[],d=this.ariaLabel??"Navigation",c={"--_esp-menu-drawer-brand-color":this.drawerBrand?.brandColor||null},F=n&&e?E`<div class=${g({"drawer-chrome":!0,"has-lifted-close":!!this.liftedCloseControl})}>
|
|
2
2
|
<div class="drawer-brand" style=${z(c)}>
|
|
3
3
|
<slot name="drawer-brand"
|
|
4
|
-
>${this.drawerBrand?
|
|
4
|
+
>${this.drawerBrand?U(this.drawerBrand):m}</slot
|
|
5
5
|
>
|
|
6
6
|
</div>
|
|
7
7
|
${this.liftedCloseControl?m:E`
|
|
@@ -51,7 +51,7 @@ var l=function(y,e,t,r){var n=arguments.length,s=n<3?e:r===null?r=Object.getOwnP
|
|
|
51
51
|
<span class="nested-fit-pad" ${p(this.nestedFitPadProbe)}>​</span>
|
|
52
52
|
<div class="nested-fit-text" ${p(this.nestedFitTextProbe)}></div>
|
|
53
53
|
</div>`:m}
|
|
54
|
-
`}};a.styles=[...D.styles,
|
|
54
|
+
`}};a.styles=[...D.styles,Y,L`
|
|
55
55
|
:host {
|
|
56
56
|
display: block;
|
|
57
57
|
min-width: 0;
|
|
@@ -308,6 +308,10 @@ var l=function(y,e,t,r){var n=arguments.length,s=n<3?e:r===null?r=Object.getOwnP
|
|
|
308
308
|
text-decoration: none;
|
|
309
309
|
}
|
|
310
310
|
|
|
311
|
+
.drawer-brand a.configured-brand:focus-visible {
|
|
312
|
+
${_}
|
|
313
|
+
}
|
|
314
|
+
|
|
311
315
|
.drawer-brand .brand-logo {
|
|
312
316
|
width: auto;
|
|
313
317
|
height: var(--esp-menu-drawer-brand-logo-size, calc(3 * var(--esp-size-medium)));
|
|
@@ -331,8 +335,8 @@ var l=function(y,e,t,r){var n=arguments.length,s=n<3?e:r===null?r=Object.getOwnP
|
|
|
331
335
|
}
|
|
332
336
|
|
|
333
337
|
.drawer-close:focus-visible {
|
|
334
|
-
|
|
335
|
-
outline-
|
|
338
|
+
${H}
|
|
339
|
+
outline-color: var(--esp-color-link);
|
|
336
340
|
}
|
|
337
341
|
|
|
338
342
|
|
|
@@ -435,4 +439,4 @@ var l=function(y,e,t,r){var n=arguments.length,s=n<3?e:r===null?r=Object.getOwnP
|
|
|
435
439
|
transition: none;
|
|
436
440
|
}
|
|
437
441
|
}
|
|
438
|
-
`],l([S()],a.prototype,"nestedFit",void 0),l([h({type:String,reflect:!0})],a.prototype,"mode",void 0),l([h({type:String,reflect:!0})],a.prototype,"overflow",void 0),l([h({type:String,reflect:!0})],a.prototype,"side",void 0),l([h({attribute:"drawer-presentation",type:String,reflect:!0})],a.prototype,"drawerPresentation",void 0),l([h({attribute:"full-screen-transition",type:String,reflect:!0})],a.prototype,"fullScreenTransition",void 0),l([h({attribute:!1})],a.prototype,"drawerBrand",void 0),l([h({attribute:!1})],a.prototype,"liftedCloseControl",void 0),l([h({attribute:"aria-label",type:String})],a.prototype,"ariaLabel",void 0),l([h({type:Boolean,attribute:"auto-expand"})],a.prototype,"autoExpand",void 0),l([h({type:Boolean})],a.prototype,"sliding",null),l([S()],a.prototype,"drawerOpen",void 0),l([S()],a.prototype,"drawerShown",void 0),l([S()],a.prototype,"drawerTransitioning",void 0),l([h({attribute:!1})],a.prototype,"headerEndOwner",void 0),l([h({attribute:!1})],a.prototype,"hasExternalDrawerControl",void 0),l([h({attribute:!1})],a.prototype,"previewCollapseRequested",void 0),l([
|
|
442
|
+
`],l([S()],a.prototype,"nestedFit",void 0),l([h({type:String,reflect:!0})],a.prototype,"mode",void 0),l([h({type:String,reflect:!0})],a.prototype,"overflow",void 0),l([h({type:String,reflect:!0})],a.prototype,"side",void 0),l([h({attribute:"drawer-presentation",type:String,reflect:!0})],a.prototype,"drawerPresentation",void 0),l([h({attribute:"full-screen-transition",type:String,reflect:!0})],a.prototype,"fullScreenTransition",void 0),l([h({attribute:!1})],a.prototype,"drawerBrand",void 0),l([h({attribute:!1})],a.prototype,"liftedCloseControl",void 0),l([h({attribute:"aria-label",type:String})],a.prototype,"ariaLabel",void 0),l([h({type:Boolean,attribute:"auto-expand"})],a.prototype,"autoExpand",void 0),l([h({type:Boolean})],a.prototype,"sliding",null),l([S()],a.prototype,"drawerOpen",void 0),l([S()],a.prototype,"drawerShown",void 0),l([S()],a.prototype,"drawerTransitioning",void 0),l([h({attribute:!1})],a.prototype,"headerEndOwner",void 0),l([h({attribute:!1})],a.prototype,"hasExternalDrawerControl",void 0),l([h({attribute:!1})],a.prototype,"previewCollapseRequested",void 0),l([$({capture:!0})],a.prototype,"handleDrawerLinkClick",null),a=C=l([I("esp-menu")],a);export{a as EspalierMenu};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import{css as o}from"lit";const r=o`
|
|
2
|
+
outline: 2px solid currentColor;
|
|
3
|
+
outline-offset: -2px;
|
|
4
|
+
`,i=o`
|
|
5
|
+
border-radius: var(--esp-size-border-radius);
|
|
6
|
+
outline: 2px solid var(--esp-color-link);
|
|
7
|
+
outline-offset: 3px;
|
|
8
|
+
`;export{i as configuredBrandFocusOutline,r as insetNavigationFocusOutline};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{composedParent as t}from"../shared/composed-dom.js";function o(n,e){for(let r=n;r;r=t(r))if(r.matches(e))return r;return null}function a(n){const e=o(n,"nav.drawer");return e?e.classList.contains("full-screen")?"full-screen":"panel":o(n,".is-horizontal > .group-items")?"inline-panel":"inline"}function u(n,e){return n==="inline"?e:`${n}-${e}`}function c(n){switch(n){case"inline":case"inline-panel":return["inlineNav"];case"panel":case"full-screen":return[`drawer:${n}`]}}const s=["rest","hover","focus","hover-focus"],l=n=>n==="hover"||n==="hover-focus",f=n=>n==="focus"||n==="hover-focus";function p(n,e){return n.ownerDocument.defaultView?.getComputedStyle(n).getPropertyValue(e).trim()||void 0}export{s as PAINT_INTERACTIONS,o as closestPaintElement,p as configuredBrandColor,f as isPaintFocus,l as isPaintHover,c as navigationPaintFlags,a as navigationPaintPlacement,u as navigationPaintState};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{TOKEN_PAIRINGS as M}from"../shared/token-pairings.js";import{PAINT_INTERACTIONS as k,closestPaintElement as d,configuredBrandColor as R,isPaintFocus as b,isPaintHover as P,navigationPaintFlags as H,navigationPaintPlacement as I,navigationPaintState as l}from"./navigation-paint.js";const T=M.linkHover.bg,B="headingsHover",_=["inline","inline-panel","panel","full-screen"];function w(n,e){switch(n){case"inline":return{...e,depth:"top-level"};case"inline-panel":return{...e,depth:"nested"};default:return e}}const q=({element:n,source:e})=>{const r=d(n,".item:not(.button-appearance)"),a=r&&d(r,"esp-menu-item");if(!r||!a||!d(a,"esp-header"))return;const t=r.querySelector(":scope > :is(a, button, [aria-current=page])");if(!t)return;const i=t.matches("[aria-current=page]"),o=I(r),s=o!=="inline"&&r.matches(":hover,:focus-within"),c=g=>i?l(o,s?"current-hover":"current"):l(o,s&&g==="rest"?"row-active":g);if(e==="shadow")return i&&n===r?{element:"nav-current-indicator",owner:t,state:c}:!i&&n===t?{element:"nav-hover-indicator",owner:t,state:c}:void 0;if((e==="fill"||e==="stroke")&&d(n,".icon-area"))return{element:"nav-item-icon",owner:t,state:c};if(e==="outline"&&n===t||e==="text"&&d(n,'[part="menu-text"]'))return{element:t.matches("button")?"nav-item":"nav-link",owner:t,state:c}},F=({element:n,source:e})=>{const r=d(n,".group-header"),a=r&&d(r,"esp-menu-group");if(!r||!a||!d(a,"esp-header"))return;const t=I(r),i=(e==="fill"||e==="stroke")&&d(n,".group-icon");if(i){const u=r.querySelector(".group-toggle");return u?{element:"nav-group-icon",owner:u,state:v=>l(t,i.matches(":hover")?b(v)?"hover-focus":"hover":v)}:void 0}const o=d(n,".group-link, .group-toggle, [aria-current=page]");if(!o)return;const s=o.matches("[aria-current=page]"),c=(t==="panel"||t==="inline-panel")&&r.matches(":hover,:focus-within"),g=u=>s?l(t,c?"current-row-active":"current"):l(t,c&&u==="rest"?"row-active":u);if(e==="shape"&&n.matches(".indicator"))return{element:"nav-group-disclosure",owner:o,state:g};if(e==="text"&&d(n,".group-label-text"))return{element:"nav-group-label",owner:o,state:g};if(e==="outline"&&n===o)return{element:"nav-group-control",owner:o,state:g}},L=({element:n,source:e})=>{const r=d(n,".drawer-brand .configured-brand");if(!r||!d(r,"esp-header"))return;const a=I(r),t=r.matches("a[href]"),i=o=>l(a,t?o:"rest");if(e==="outline"&&n===r&&t)return{element:"drawer-brand-link",owner:r,state:i};if(e==="text"&&d(n,".brand-text"))return{element:"drawer-brand-text",owner:r,state:i,brandColor:R(r,"--_esp-menu-drawer-brand-color")}};function O(n){const e=H(n),r=n==="inline",a=n==="full-screen",t=r?"layer2":"layer1",i=w(n,{kind:"plain",anchor:!0}),o=w(n,{kind:"plain",anchor:!1}),s=[!0,!1].flatMap(u=>{const v=u?"nav-link":"nav-item",A=u?i:o;return(r?k:[...k,"row-active"]).flatMap(p=>{const m=p==="row-active",h=!m&&P(p),N=!m&&b(p),S=h||N||m,C=u&&h?"linkHover":!r&&S?"headingsHover":"text",E=u&&h&&!r&&!a?T:!a&&S?"layer2":t,G=l(n,p),f={element:v,foreground:C,background:E,state:G,kind:"text",flags:e,navigation:A},x={...f,element:"nav-item-icon",kind:"graphic",background:"layer2",navigation:{...A,icon:!0}};if(!N)return[f,x];const y={...f,foreground:"link",kind:"ring"};return r&&h?[f,x,y,{...y,background:B}]:[f,x,y]})}),c={element:"nav-link",foreground:"link",background:a?"layer1":"layer2",state:l(n,"current"),kind:"text",flags:e,navigation:w(n,{kind:"plain",canBeCurrent:!0})},g={...c,element:"nav-item-icon",kind:"graphic",background:"layer2",navigation:{...c.navigation,icon:!0}};return s.push(c,g),r?s.push({element:"nav-hover-indicator",foreground:B,background:"layer2",state:"hover",kind:"graphic",flags:e,navigation:{kind:"plain",depth:"top-level"}},{...c,element:"nav-current-indicator",kind:"graphic",flags:[...e,"headerPaint:standard"]}):s.push({...c,foreground:"headingsHover",state:l(n,"current-hover")},{...g,foreground:"headingsHover",state:l(n,"current-hover")}),s}function z(n){const e=H(n),r=w(n,{kind:"group"}),a=o=>n==="full-screen"?"layer1":n==="inline"||o?"layer2":"layer1",t={element:"nav-group-label",foreground:"link",background:a(!1),state:l(n,"current"),kind:"text",flags:e,navigation:{...r,canBeCurrent:!0}},i=k.flatMap(o=>{const s=b(o),c=a(s||P(o)),g=l(n,o),u={foreground:"text",background:c,state:g,flags:e,navigation:r},v=[{...u,element:"nav-group-label",kind:"text"},{...u,element:"nav-group-disclosure",kind:"graphic"},{...u,element:"nav-group-icon",kind:"graphic",background:"layer2",navigation:{...r,icon:!0}}];return s&&v.push({...u,element:"nav-group-control",foreground:"link",kind:"ring"}),v});if(i.push(t),n==="inline-panel"||n==="panel"){const o=a(!0),s={foreground:"text",background:o,state:l(n,"row-active"),flags:e,navigation:r};i.push({...s,element:"nav-group-label",kind:"text"},{...s,element:"nav-group-disclosure",kind:"graphic"},{...t,background:o,state:l(n,"current-row-active")})}return i}const J={entriesByRole:{header:[..._.flatMap(n=>[...O(n),...z(n)]),...k.flatMap(n=>{const e=l("full-screen",n),r=H("full-screen"),a=b(n),t=P(n),i={element:"drawer-brand-text",foreground:"brand-color",background:t?T:"layer1",state:e,kind:"text",flags:[...r,"brandText",...t||a?["brandLink"]:[]]};return a?[i,{element:"drawer-brand-link",foreground:"link",background:"layer1",state:e,kind:"ring",flags:[...r,"brandLink"]}]:[i]})]},targets:{header:[q,F,L]}};export{J as menuPaintRegistration};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var c=function(e,t,o,n){var s=arguments.length,r=s<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,o):n,l;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(e,t,o,n);else for(var h=e.length-1;h>=0;h--)(l=e[h])&&(r=(s<3?l(r):s>3?l(t,o,r):l(t,o))||r);return s>3&&r&&Object.defineProperty(t,o,r),r};import{LitElement as u,nothing as g,css as f,html as a}from"lit";import{customElement as v,property as p}from"lit/decorators.js";import{ref as m}from"lit/directives/ref.js";import{getIconHrefForHost as y}from"../shared/intent-values.js";import{SlottedIconController as x}from"../shared/slotted-icon-controller.js";import{renderSpriteIcon as b}from"../shared/svgs/render-sprite-icon.js";import{DocumentSpriteController as k}from"../shared/document-sprite.js";const S=["text","icon","styles"],d=new WeakMap;function z(e,t){d.set(e,t)}function P(e){return{text:e.text||e.getAttribute("text")||e.textContent?.trim()||"",icon:e.icon||e.getAttribute("icon")||"",styles:e.styles}}function E(e,t){return e.text===t.text&&(e.icon??"")===(t.icon??"")&&e.styles===t.styles}function H(e){return e.value||e.getAttribute("value")||""}let i=class extends u{constructor(){super(),this.internals=this.attachInternals(),this.iconSlot=new x(this),this.text="",this.icon="",this.value="",this.selected=!1,new k(this
|
|
1
|
+
var c=function(e,t,o,n){var s=arguments.length,r=s<3?t:n===null?n=Object.getOwnPropertyDescriptor(t,o):n,l;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(e,t,o,n);else for(var h=e.length-1;h>=0;h--)(l=e[h])&&(r=(s<3?l(r):s>3?l(t,o,r):l(t,o))||r);return s>3&&r&&Object.defineProperty(t,o,r),r};import{LitElement as u,nothing as g,css as f,html as a}from"lit";import{customElement as v,property as p}from"lit/decorators.js";import{ref as m}from"lit/directives/ref.js";import{getIconHrefForHost as y}from"../shared/intent-values.js";import{SlottedIconController as x}from"../shared/slotted-icon-controller.js";import{renderSpriteIcon as b}from"../shared/svgs/render-sprite-icon.js";import{DocumentSpriteController as k}from"../shared/document-sprite.js";const S=["text","icon","styles"],d=new WeakMap;function z(e,t){d.set(e,t)}function P(e){return{text:e.text||e.getAttribute("text")||e.textContent?.trim()||"",icon:e.icon||e.getAttribute("icon")||"",styles:e.styles}}function E(e,t){return e.text===t.text&&(e.icon??"")===(t.icon??"")&&e.styles===t.styles}function H(e){return e.value||e.getAttribute("value")||""}let i=class extends u{constructor(){super(),this.internals=this.attachInternals(),this.iconSlot=new x(this),this.text="",this.icon="",this.value="",this.selected=!1,new k(this),this.internals.role="option"}connectedCallback(){super.connectedCallback(),this.hasAttribute("role")||this.setAttribute("role","option")}updated(t){super.updated(t),S.some(o=>t.has(o))&&d.get(this)?.pickerItemChanged(this),t.has("selected")&&(this.internals.ariaSelected=String(this.selected),this.setAttribute("aria-selected",String(this.selected)))}renderHighlightedText(){const t=this.highlightRanges;if(!t||t.length===0)return this.text;const o=[...t].sort((r,l)=>r[0]-l[0]),n=[];let s=0;for(const[r,l]of o)r>s&&n.push(a`${this.text.slice(s,r)}`),n.push(a`<mark>${this.text.slice(r,l)}</mark>`),s=l;return s<this.text.length&&n.push(a`${this.text.slice(s)}`),n}render(){const t=y(this.icon,this),o=this.iconSlot.hasSlottedIcon(":scope > *");return a`<div>
|
|
2
2
|
<span class="icon">
|
|
3
3
|
<slot ${m(this.iconSlot.slotRef)} @slotchange=${this.iconSlot.handleSlotChange}></slot>
|
|
4
4
|
${!o&&t?b(t):g}
|
package/dist/root/esp-root.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { LitElement, type PropertyValues } from "lit";
|
|
2
2
|
import { type SchemeEvents, type SeedColorRoot } from "../shared/bus-events.js";
|
|
3
|
-
import {
|
|
3
|
+
import { GoverningRootObserver } from "../shared/governing-root.js";
|
|
4
|
+
import { type EspalierTheme, type PartialTheme } from "../shared/theme-core.js";
|
|
4
5
|
import { type ImageTextureDefinition } from "../shared/image-texture-registry.js";
|
|
5
6
|
export { registerImageTexture, registeredImageTextures, BUILT_IN_IMAGE_TEXTURES, type ImageTextureDefinition, } from "../shared/image-texture-registry.js";
|
|
6
7
|
export type GoogleFontLoadingPolicy = "auto" | "none";
|
|
@@ -65,6 +66,10 @@ export type { SchemeEvents } from "../shared/bus-events.js";
|
|
|
65
66
|
* @slot - Place Espalier components and content here.
|
|
66
67
|
* @cssprop --esp-font-body - Always-emitted family for body and UI text. Defaults to `system-ui, sans-serif` when `fontBody` is omitted or empty.
|
|
67
68
|
* @cssprop --esp-font-headings - Consumer-authored heading family. Emitted only when configured; heading recipes otherwise fall back to `--esp-font-body`.
|
|
69
|
+
* @cssprop --esp-heading-1-color - Color of native light-DOM h1 headings. Defaults to `var(--esp-color-headings)`.
|
|
70
|
+
* @cssprop --esp-heading-2-color - Color of native light-DOM h2 headings. Defaults to `var(--esp-color-headings)`.
|
|
71
|
+
* @cssprop --esp-heading-3-color - Color of native light-DOM h3 headings. Defaults to `var(--esp-color-headings)`.
|
|
72
|
+
* @cssprop --esp-heading-4-color - Color of native light-DOM h4 headings. Defaults to `var(--esp-color-headings)`.
|
|
68
73
|
* @cssprop --esp-font-brand - Consumer-authored brand family. Emitted only when configured; brand recipes otherwise fall back through headings to `--esp-font-body`.
|
|
69
74
|
* @cssprop --esp-font-menu - Consumer-authored navigation family. Emitted only when configured; menu items otherwise fall back to `--esp-font-body`, never to headings.
|
|
70
75
|
* @cssprop --esp-font-weight-menu - Font weight for horizontal navigation menu items. Defaults to `bold`.
|
|
@@ -149,6 +154,7 @@ export declare class EspalierRoot extends LitElement implements SeedColorRoot {
|
|
|
149
154
|
static registerTexture(name: string, definition: ImageTextureDefinition): void;
|
|
150
155
|
/** Snapshot of the registered texture presets, for building pickers. */
|
|
151
156
|
static registeredTextures(): Map<string, Readonly<ImageTextureDefinition>>;
|
|
157
|
+
protected readonly outerRootObserver: GoverningRootObserver;
|
|
152
158
|
/** Unique ID for correlating bus events across multiple roots. */
|
|
153
159
|
correlationId: `${string}-${string}-${string}-${string}-${string}`;
|
|
154
160
|
/**
|
|
@@ -378,6 +384,7 @@ export declare class EspalierRoot extends LitElement implements SeedColorRoot {
|
|
|
378
384
|
* `seedColor` value to change.
|
|
379
385
|
*/
|
|
380
386
|
get seedColor(): string;
|
|
387
|
+
constructor();
|
|
381
388
|
/** Returns the resolved theme for the active scheme. */
|
|
382
389
|
get activeTheme(): EspalierTheme;
|
|
383
390
|
connectedCallback(): void;
|
package/dist/root/esp-root.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var r=function(c,e,t,s){var h=arguments.length,i=h<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,t):s,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(c,e,t,s);else for(var l=c.length-1;l>=0;l--)(d=c[l])&&(i=(h<3?d(i):h>3?d(e,t,i):d(e,t))||i);return h>3&&i&&Object.defineProperty(e,t,i),i},a;import{surfaceLayerAttributes as T}from"../shared/surface-layer.js";import{css as w,html as E,LitElement as C}from"lit";import{customElement as R,property as n,state as x}from"lit/decorators.js";import{getEspBus as m}from"../shared/bus-events.js";import{subscribeToRootEvent as A}from"../shared/root-event-subscription.js";import{DEFAULT_LIGHT_THEME as f,DEFAULT_DARK_THEME as g,encodeTheme as v,parseTheme as u,mergeTheme as y}from"../shared/theme.js";import{extractFamily as p,isLocalFontFamily as L,removeRuntimeGoogleFontLinks as S,syncRuntimeGoogleFontLink as D}from"../shared/font-helpers.js";import{computeThemeProperties as F}from"./helpers/compute-theme-properties.js";import{registerImageTexture as I,registeredImageTextures as W}from"../shared/image-texture-registry.js";import{registerImageTexture as Q,registeredImageTextures as N,BUILT_IN_IMAGE_TEXTURES as q}from"../shared/image-texture-registry.js";const k=1e3;let o=a=class extends C{constructor(){super(...arguments),this.schemeBacker="",this.schemeExplicitlySet=!1,this.resolvingDefaultScheme=!1,this.themeEventsReady=!1,this.systemSchemeQuery=null,this.lastSeedColor="",this.resolvedLightTheme={...f},this.resolvedDarkTheme={...g},this.appliedThemeProperties=new Set,this.documentClickRegistrationActive=!1,this.correlationId=globalThis.crypto?.randomUUID?.()??Math.random().toString(36),this.lightThemeAttr="",this.darkThemeAttr="",this.fontCSSRoot="/css/fonts/",this.fontDefinitionsUrl="",this.googleFontLoading="auto",this.iconSpriteUrl="/assets/icons.svg",this.themePending=!1,this.themeReadyState=!1,this.themeSettleWaiters=[],this.warnedThemeSettleTimeout=!1,this.defaultScheme="light",this.resizeObserver=new ResizeObserver(()=>{m().publish("window-resized",{emWidth:window.innerWidth/parseFloat(getComputedStyle(document.documentElement).fontSize),emHeight:window.innerHeight/parseFloat(getComputedStyle(document.documentElement).fontSize),pxWidth:window.innerWidth,pxHeight:window.innerHeight})}),this.handleSystemSchemeChange=e=>{this.schemeExplicitlySet||this.defaultScheme!=="system"||(this.resolvingDefaultScheme=!0,this.scheme=e.matches?"dark":"light",this.resolvingDefaultScheme=!1)}}static registerTexture(e,t){I(e,t)}static registeredTextures(){return W()}subscribeScoped(e,t){return A(this,e,t)}get virtualViewportWidth(){return this.virtualViewportWidthBacker}set virtualViewportWidth(e){const t=typeof e=="number"&&Number.isFinite(e)&&e>0?e:void 0,s=this.virtualViewportWidthBacker;this.virtualViewportWidthBacker=t,t===void 0?this.hasAttribute("virtual-viewport-width")&&this.removeAttribute("virtual-viewport-width"):this.getAttribute("virtual-viewport-width")!==String(t)&&this.setAttribute("virtual-viewport-width",String(t)),this.requestUpdate("virtualViewportWidth",s)}get lightTheme(){return this.lightThemeAttr?u(this.lightThemeAttr):null}set lightTheme(e){this.lightThemeAttr=e?v(e):""}get darkTheme(){return this.darkThemeAttr?u(this.darkThemeAttr):null}set darkTheme(e){this.darkThemeAttr=e?v(e):""}get themeSettled(){return this.themeReadyState}whenThemeSettled(){return this.themeReadyState?Promise.resolve():new Promise(e=>{this.themeSettleWaiters.push(e)})}get hasAuthorTheme(){return!!(this.scheme==="dark"?this.darkThemeAttr:this.lightThemeAttr)}settleTheme(){if(this.themeSettleTimer!==void 0&&(clearTimeout(this.themeSettleTimer),this.themeSettleTimer=void 0),this.themeReadyState)return;this.themeReadyState=!0;const e=this.themeSettleWaiters;this.themeSettleWaiters=[];for(const t of e)t()}get scheme(){return this.schemeBacker}set scheme(e){const t=e==="dark"?"dark":e==="light"?"light":"",s=this.schemeBacker,h=this.schemeExplicitlySet;this.resolvingDefaultScheme||(this.schemeExplicitlySet=t.length>0);const i=t||this.resolveDefaultScheme();h!==this.schemeExplicitlySet&&this.isConnected&&this.syncSystemSchemeListener(),i!==s&&(this.schemeBacker=i,this.requestUpdate("scheme",s),this.themeEventsReady&&m().publish("scheme-changed",{scheme:i,correlationId:this.correlationId}))}get seedColor(){return this.activeTheme.seedColor}injectGoogleFontLink(e,t,s){const h=`${this.correlationId}-${e}`,i=L(t)?"":t;D({owner:`root:${h}`,family:i,weight:s,enabled:this.googleFontLoading!=="none"})}syncGoogleFontLinks(){this.googleFontLoading==="none"&&this.removeRuntimeGoogleFontLinks();const e=this.activeTheme;this.injectGoogleFontLink("body",p(e.fontBody),e.fontWeightBody),this.injectGoogleFontLink("headings",p(e.fontHeadings),e.fontWeightHeadings),this.injectGoogleFontLink("brand",p(e.fontBrand),e.fontWeightBrand),this.injectGoogleFontLink("menu",p(e.fontMenu),e.fontWeightMenu),this.injectGoogleFontLink("monospace",p(e.fontMonospace),e.fontWeightMonospace)}removeRuntimeGoogleFontLinks(){S(`root:${this.correlationId}-`),S(`picker:${this.correlationId}:`)}get activeTheme(){return this.scheme==="dark"?this.resolvedDarkTheme:this.resolvedLightTheme}resolveThemes(){const e=this.lightThemeAttr?u(this.lightThemeAttr):null;this.resolvedLightTheme=e?y(f,e):{...f};const t=this.darkThemeAttr?u(this.darkThemeAttr):null;this.resolvedDarkTheme=t?y(g,t):{...g}}connectedCallback(){super.connectedCallback(),this.registerDocumentClickBridge(),this.resizeObserver.observe(this),this.hasUpdated&&(this.applyDefaultScheme(),this.syncGoogleFontLinks(),this.hasAuthorTheme||this.startThemeSettleTimer())}willUpdate(e){const t=["lightThemeAttr","darkThemeAttr"];(!this.lastSeedColor||t.some(l=>e.has(l)))&&(this.resolveThemes(),this.themeEventsReady&&m().publish("theme-changed",{correlationId:this.correlationId})),this.hasAuthorTheme&&this.settleTheme();const h=F(this.activeTheme,this.scheme==="dark"?"dark":"light",void 0,{viewportWidth:this.virtualViewportWidth}),i=new Set(Object.keys(h));for(const l of this.appliedThemeProperties)i.has(l)||this.style.removeProperty(l);for(const[l,b]of Object.entries(h))this.style.setProperty(l,b);this.appliedThemeProperties=i;const d=this.activeTheme.seedColor;this.themeEventsReady&&this.lastSeedColor&&this.lastSeedColor!==d&&m().publish("seed-color-changed",{seedColor:d,correlationId:this.correlationId}),this.lastSeedColor=d,this.themeEventsReady&&e.has("iconSpriteUrl")&&m().publish("icon-sprite-url-changed",{iconSpriteUrl:this.iconSpriteUrl,correlationId:this.correlationId}),this.syncGoogleFontLinks()}firstUpdated(){const e=this.activeTheme.stylesheets;if(e.length)for(const t of e){const s=document.createElement("link");s.rel="stylesheet",s.href=t,document.head.appendChild(s)}if(!document.getElementById("esp-root-base-styles")){const t=document.createElement("style");t.id="esp-root-base-styles",t.textContent=a.lightDomStyles,document.head.appendChild(t)}this.applyDefaultScheme(),this.lastSeedColor=this.activeTheme.seedColor,this.themeEventsReady=!0,this.startThemeSettleTimer()}startThemeSettleTimer(){if(this.themeReadyState||this.themeSettleTimer!==void 0)return;this.themeSettleDeadline??=performance.now()+k;const e=Math.max(0,this.themeSettleDeadline-performance.now());if(e===0){this.closeThemeWindow();return}this.themeSettleTimer=setTimeout(()=>this.closeThemeWindow(),e)}closeThemeWindow(){this.themeSettleTimer=void 0,this.themePending&&!this.warnedThemeSettleTimeout&&(this.warnedThemeSettleTimeout=!0,console.warn(`Espalier root: theme-pending was declared but no ${this.scheme} theme arrived within ${k}ms, so the default palette is rendering. Assign ${this.scheme==="dark"?"darkTheme":"lightTheme"} (or remove theme-pending).`)),this.settleTheme()}updated(e){this.toggleAttribute("data-theme-ready",this.themeReadyState),(e.has("defaultScheme")||e.has("scheme"))&&!this.schemeExplicitlySet&&this.applyDefaultScheme()}disconnectedCallback(){this.themeSettleTimer!==void 0&&(clearTimeout(this.themeSettleTimer),this.themeSettleTimer=void 0),this.unregisterDocumentClickBridge(),this.systemSchemeQuery?.removeEventListener("change",this.handleSystemSchemeChange),this.systemSchemeQuery=null,this.resizeObserver.disconnect(),this.removeRuntimeGoogleFontLinks(),super.disconnectedCallback()}registerDocumentClickBridge(){this.documentClickRegistrationActive||(this.documentClickRegistrationActive=!0,a.connectedRootCount+=1,a.connectedRootCount===1&&document.addEventListener("click",a.handleDocumentClick))}unregisterDocumentClickBridge(){this.documentClickRegistrationActive&&(this.documentClickRegistrationActive=!1,a.connectedRootCount=Math.max(0,a.connectedRootCount-1),a.connectedRootCount===0&&document.removeEventListener("click",a.handleDocumentClick))}applyDefaultScheme(){this.schemeExplicitlySet||(this.resolvingDefaultScheme=!0,this.scheme=this.resolveDefaultScheme(),this.resolvingDefaultScheme=!1,this.syncSystemSchemeListener())}resolveDefaultScheme(){return this.defaultScheme==="dark"||this.defaultScheme==="system"&&window.matchMedia?.("(prefers-color-scheme: dark)").matches?"dark":"light"}syncSystemSchemeListener(){if(this.schemeExplicitlySet||this.defaultScheme!=="system"||!window.matchMedia){this.systemSchemeQuery?.removeEventListener("change",this.handleSystemSchemeChange),this.systemSchemeQuery=null;return}this.systemSchemeQuery||(this.systemSchemeQuery=window.matchMedia("(prefers-color-scheme: dark)"),this.systemSchemeQuery.addEventListener("change",this.handleSystemSchemeChange))}render(){return E`<slot></slot>`}};o.connectedRootCount=0,o.handleDocumentClick=c=>{const e=c.composedPath().filter(t=>t instanceof HTMLElement&&t.tagName==="ESP-POPOVER");m().publish("close-popovers",{source:c.target??void 0,skipPopovers:e})},o.lightDomStyles=`
|
|
2
|
-
${
|
|
1
|
+
var i=function(c,e,t,o){var h=arguments.length,r=h<3?e:o===null?o=Object.getOwnPropertyDescriptor(e,t):o,m;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(c,e,t,o);else for(var d=c.length-1;d>=0;d--)(m=c[d])&&(r=(h<3?m(r):h>3?m(e,t,r):m(e,t))||r);return h>3&&r&&Object.defineProperty(e,t,r),r},l;import{surfaceLayerAttributes as x}from"../shared/surface-layer.js";import{css as A,html as L,LitElement as D}from"lit";import{customElement as P,property as n,state as F}from"lit/decorators.js";import{getEspBus as p}from"../shared/bus-events.js";import{GoverningRootObserver as O}from"../shared/governing-root.js";import{getComponentPropertyAnalysis as k}from"../shared/component-property-normalizer.js";import{addComponentPropertyResets as I}from"../shared/component-property-resets.js";import{ScopedStyleDeclarations as z}from"../shared/scoped-style-declarations.js";import{subscribeToRootEvent as W}from"../shared/root-event-subscription.js";import{DEFAULT_LIGHT_THEME as v,DEFAULT_DARK_THEME as y,encodeTheme as T,parseTheme as f,mergeTheme as w}from"../shared/theme-core.js";import{extractFamily as u,isLocalFontFamily as B,removeRuntimeGoogleFontLinks as C,syncRuntimeGoogleFontLink as _}from"../shared/font-helpers.js";import{computeThemeProperties as U}from"./helpers/compute-theme-properties.js";import{registerImageTexture as G,registeredImageTextures as M}from"../shared/image-texture-registry.js";import{registerImageTexture as re,registeredImageTextures as ie,BUILT_IN_IMAGE_TEXTURES as ne}from"../shared/image-texture-registry.js";const E=1e3;let s=l=class extends D{static registerTexture(e,t){G(e,t)}static registeredTextures(){return M()}subscribeScoped(e,t){return W(this,e,t)}get virtualViewportWidth(){return this.virtualViewportWidthBacker}set virtualViewportWidth(e){const t=typeof e=="number"&&Number.isFinite(e)&&e>0?e:void 0,o=this.virtualViewportWidthBacker;this.virtualViewportWidthBacker=t,t===void 0?this.hasAttribute("virtual-viewport-width")&&this.removeAttribute("virtual-viewport-width"):this.getAttribute("virtual-viewport-width")!==String(t)&&this.setAttribute("virtual-viewport-width",String(t)),this.requestUpdate("virtualViewportWidth",o)}get lightTheme(){return this.lightThemeAttr?f(this.lightThemeAttr):null}set lightTheme(e){this.lightThemeAttr=e?T(e):""}get darkTheme(){return this.darkThemeAttr?f(this.darkThemeAttr):null}set darkTheme(e){this.darkThemeAttr=e?T(e):""}get themeSettled(){return this.themeReadyState}whenThemeSettled(){return this.themeReadyState?Promise.resolve():new Promise(e=>{this.themeSettleWaiters.push(e)})}get hasAuthorTheme(){return!!(this.scheme==="dark"?this.darkThemeAttr:this.lightThemeAttr)}settleTheme(){if(this.themeSettleTimer!==void 0&&(clearTimeout(this.themeSettleTimer),this.themeSettleTimer=void 0),this.themeReadyState)return;this.themeReadyState=!0;const e=this.themeSettleWaiters;this.themeSettleWaiters=[];for(const t of e)t()}get scheme(){return this.schemeBacker}set scheme(e){const t=e==="dark"?"dark":e==="light"?"light":"",o=this.schemeBacker,h=this.schemeExplicitlySet;this.resolvingDefaultScheme||(this.schemeExplicitlySet=t.length>0);const r=t||this.resolveDefaultScheme();h!==this.schemeExplicitlySet&&this.isConnected&&this.syncSystemSchemeListener(),r!==o&&(this.schemeBacker=r,this.requestUpdate("scheme",o),this.themeEventsReady&&(this.resolveThemes(),p().publish("scheme-changed",{scheme:r,correlationId:this.correlationId})))}get seedColor(){return this.activeTheme.seedColor}injectGoogleFontLink(e,t,o){const h=`${this.correlationId}-${e}`,r=B(t)?"":t;_({owner:`root:${h}`,family:r,weight:o,enabled:this.googleFontLoading!=="none"})}syncGoogleFontLinks(){this.googleFontLoading==="none"&&this.removeRuntimeGoogleFontLinks();const e=this.activeTheme;this.injectGoogleFontLink("body",u(e.fontBody),e.fontWeightBody),this.injectGoogleFontLink("headings",u(e.fontHeadings),e.fontWeightHeadings),this.injectGoogleFontLink("brand",u(e.fontBrand),e.fontWeightBrand),this.injectGoogleFontLink("menu",u(e.fontMenu),e.fontWeightMenu),this.injectGoogleFontLink("monospace",u(e.fontMonospace),e.fontWeightMonospace)}removeRuntimeGoogleFontLinks(){C(`root:${this.correlationId}-`),C(`picker:${this.correlationId}:`,this.ownerDocument)}constructor(){super(),this.outerRootObserver=new O(this,(t,o)=>{t!==o&&(this.outerComponentCandidates=void 0,this.applyComponentProperties(),t&&this.outerRootObserver.whenReady(this.syncOuterComponentCandidates))}),this.componentDeclarations=new z(this),this.componentProperties={},this.schemeBacker="",this.schemeExplicitlySet=!1,this.resolvingDefaultScheme=!1,this.themeEventsReady=!1,this.systemSchemeQuery=null,this.lastSeedColor="",this.resolvedLightThemeAttr="",this.resolvedDarkThemeAttr="",this.resolvedLightTheme={...v},this.resolvedDarkTheme={...y},this.appliedThemeProperties=new Set,this.documentClickRegistrationActive=!1,this.correlationId=globalThis.crypto?.randomUUID?.()??Math.random().toString(36),this.lightThemeAttr="",this.darkThemeAttr="",this.fontCSSRoot="/css/fonts/",this.fontDefinitionsUrl="",this.googleFontLoading="auto",this.iconSpriteUrl="/assets/icons.svg",this.themePending=!1,this.themeReadyState=!1,this.themeSettleWaiters=[],this.warnedThemeSettleTimeout=!1,this.defaultScheme="light",this.syncOuterComponentCandidates=t=>{const{candidates:o}=k(t.activeTheme);o!==this.outerComponentCandidates&&(this.outerComponentCandidates=o,this.applyComponentProperties())},this.resizeObserver=new ResizeObserver(()=>{p().publish("window-resized",{emWidth:window.innerWidth/parseFloat(getComputedStyle(document.documentElement).fontSize),emHeight:window.innerHeight/parseFloat(getComputedStyle(document.documentElement).fontSize),pxWidth:window.innerWidth,pxHeight:window.innerHeight})}),this.handleSystemSchemeChange=t=>{this.schemeExplicitlySet||this.defaultScheme!=="system"||(this.resolvingDefaultScheme=!0,this.scheme=t.matches?"dark":"light",this.resolvingDefaultScheme=!1)};const e=()=>{const t=this.outerRootObserver.root;t&&this.syncOuterComponentCandidates(t)};this.outerRootObserver.subscribe("scheme-changed",e),this.outerRootObserver.subscribe("theme-changed",e)}applyComponentProperties(){const e={...this.componentProperties};this.outerComponentCandidates&&I(e,this.outerComponentCandidates),this.componentDeclarations.apply(e)}get activeTheme(){return this.scheme==="dark"?this.resolvedDarkTheme:this.resolvedLightTheme}resolveThemes(){if(this.lightThemeAttr!==this.resolvedLightThemeAttr){this.resolvedLightThemeAttr=this.lightThemeAttr;const e=f(this.lightThemeAttr);this.resolvedLightTheme=e?w(v,e):{...v}}if(this.darkThemeAttr!==this.resolvedDarkThemeAttr){this.resolvedDarkThemeAttr=this.darkThemeAttr;const e=f(this.darkThemeAttr);this.resolvedDarkTheme=e?w(y,e):{...y}}}connectedCallback(){super.connectedCallback(),this.outerRootObserver.connect(),this.registerDocumentClickBridge(),this.resizeObserver.observe(this),this.hasUpdated&&(this.applyDefaultScheme(),this.syncGoogleFontLinks(),this.hasAuthorTheme||this.startThemeSettleTimer())}willUpdate(e){const t=["lightThemeAttr","darkThemeAttr"];(!this.lastSeedColor||t.some(a=>e.has(a)))&&(this.resolveThemes(),this.themeEventsReady&&p().publish("theme-changed",{correlationId:this.correlationId})),this.hasAuthorTheme&&this.settleTheme();const h=this.activeTheme,{root:r,candidates:m}=k(h),d=U(h,this.scheme==="dark"?"dark":"light",void 0,{viewportWidth:this.virtualViewportWidth},{surface:r}),S={};for(const a of m)Object.prototype.hasOwnProperty.call(d,a)&&(S[a]=d[a],delete d[a]);this.componentProperties=S,this.applyComponentProperties();const b=new Set(Object.keys(d));for(const a of this.appliedThemeProperties)b.has(a)||this.style.removeProperty(a);for(const[a,R]of Object.entries(d))this.style.setProperty(a,R);this.appliedThemeProperties=b;const g=this.activeTheme.seedColor;this.themeEventsReady&&this.lastSeedColor&&this.lastSeedColor!==g&&p().publish("seed-color-changed",{seedColor:g,correlationId:this.correlationId}),this.lastSeedColor=g,this.themeEventsReady&&e.has("iconSpriteUrl")&&p().publish("icon-sprite-url-changed",{iconSpriteUrl:this.iconSpriteUrl,correlationId:this.correlationId}),this.syncGoogleFontLinks()}firstUpdated(){const e=this.activeTheme.stylesheets;if(e.length)for(const t of e){const o=document.createElement("link");o.rel="stylesheet",o.href=t,document.head.appendChild(o)}if(!document.getElementById("esp-root-base-styles")){const t=document.createElement("style");t.id="esp-root-base-styles",t.textContent=l.lightDomStyles,document.head.appendChild(t)}this.applyDefaultScheme(),this.lastSeedColor=this.activeTheme.seedColor,this.themeEventsReady=!0,this.startThemeSettleTimer()}startThemeSettleTimer(){if(this.themeReadyState||this.themeSettleTimer!==void 0)return;this.themeSettleDeadline??=performance.now()+E;const e=Math.max(0,this.themeSettleDeadline-performance.now());if(e===0){this.closeThemeWindow();return}this.themeSettleTimer=setTimeout(()=>this.closeThemeWindow(),e)}closeThemeWindow(){this.themeSettleTimer=void 0,this.themePending&&!this.warnedThemeSettleTimeout&&(this.warnedThemeSettleTimeout=!0,console.warn(`Espalier root: theme-pending was declared but no ${this.scheme} theme arrived within ${E}ms, so the default palette is rendering. Assign ${this.scheme==="dark"?"darkTheme":"lightTheme"} (or remove theme-pending).`)),this.settleTheme()}updated(e){this.toggleAttribute("data-theme-ready",this.themeReadyState),(e.has("defaultScheme")||e.has("scheme"))&&!this.schemeExplicitlySet&&this.applyDefaultScheme()}disconnectedCallback(){this.outerRootObserver.disconnect(),this.themeSettleTimer!==void 0&&(clearTimeout(this.themeSettleTimer),this.themeSettleTimer=void 0),this.unregisterDocumentClickBridge(),this.systemSchemeQuery?.removeEventListener("change",this.handleSystemSchemeChange),this.systemSchemeQuery=null,this.resizeObserver.disconnect(),this.removeRuntimeGoogleFontLinks(),super.disconnectedCallback()}registerDocumentClickBridge(){this.documentClickRegistrationActive||(this.documentClickRegistrationActive=!0,l.connectedRootCount+=1,l.connectedRootCount===1&&document.addEventListener("click",l.handleDocumentClick))}unregisterDocumentClickBridge(){this.documentClickRegistrationActive&&(this.documentClickRegistrationActive=!1,l.connectedRootCount=Math.max(0,l.connectedRootCount-1),l.connectedRootCount===0&&document.removeEventListener("click",l.handleDocumentClick))}applyDefaultScheme(){this.schemeExplicitlySet||(this.resolvingDefaultScheme=!0,this.scheme=this.resolveDefaultScheme(),this.resolvingDefaultScheme=!1,this.syncSystemSchemeListener())}resolveDefaultScheme(){return this.defaultScheme==="dark"||this.defaultScheme==="system"&&window.matchMedia?.("(prefers-color-scheme: dark)").matches?"dark":"light"}syncSystemSchemeListener(){if(this.schemeExplicitlySet||this.defaultScheme!=="system"||!window.matchMedia){this.systemSchemeQuery?.removeEventListener("change",this.handleSystemSchemeChange),this.systemSchemeQuery=null;return}this.systemSchemeQuery||(this.systemSchemeQuery=window.matchMedia("(prefers-color-scheme: dark)"),this.systemSchemeQuery.addEventListener("change",this.handleSystemSchemeChange))}render(){return L`<slot></slot>`}};s.connectedRootCount=0,s.handleDocumentClick=c=>{const e=c.composedPath().filter(t=>t instanceof HTMLElement&&t.tagName==="ESP-POPOVER");p().publish("close-popovers",{source:c.target??void 0,skipPopovers:e})},s.lightDomStyles=`
|
|
2
|
+
${x("esp-root [surface-layer]").cssText}
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
esp-root {
|
|
@@ -78,15 +78,34 @@ var r=function(c,e,t,s){var h=arguments.length,i=h<3?e:s===null?s=Object.getOwnP
|
|
|
78
78
|
)
|
|
79
79
|
);
|
|
80
80
|
font-weight: var(--esp-font-weight-headings);
|
|
81
|
-
color: var(--esp-color-headings);
|
|
82
81
|
margin: var(--esp-size-small-to-normal) 0 var(--esp-size-tiny-to-small);
|
|
83
82
|
}
|
|
84
83
|
|
|
85
|
-
esp-root h5 {
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
84
|
+
esp-root h5 {
|
|
85
|
+
font-size: var(--esp-type-small);
|
|
86
|
+
line-height: 1.4;
|
|
87
|
+
color: var(--esp-color-headings);
|
|
88
|
+
}
|
|
89
|
+
esp-root h4 {
|
|
90
|
+
font-size: var(--esp-type-medium);
|
|
91
|
+
line-height: 1.3;
|
|
92
|
+
color: var(--esp-heading-4-color, var(--esp-color-headings));
|
|
93
|
+
}
|
|
94
|
+
esp-root h3 {
|
|
95
|
+
font-size: var(--esp-type-big);
|
|
96
|
+
line-height: 1.2;
|
|
97
|
+
color: var(--esp-heading-3-color, var(--esp-color-headings));
|
|
98
|
+
}
|
|
99
|
+
esp-root h2 {
|
|
100
|
+
font-size: var(--esp-type-large);
|
|
101
|
+
line-height: 1.15;
|
|
102
|
+
color: var(--esp-heading-2-color, var(--esp-color-headings));
|
|
103
|
+
}
|
|
104
|
+
esp-root h1 {
|
|
105
|
+
font-size: var(--esp-type-huge);
|
|
106
|
+
line-height: 1.1;
|
|
107
|
+
color: var(--esp-heading-1-color, var(--esp-color-headings));
|
|
108
|
+
}
|
|
90
109
|
|
|
91
110
|
|
|
92
111
|
esp-root pre,
|
|
@@ -140,16 +159,34 @@ var r=function(c,e,t,s){var h=arguments.length,i=h<3?e:s===null?s=Object.getOwnP
|
|
|
140
159
|
color: var(--esp-footer-heading-color, var(--esp-color-headings));
|
|
141
160
|
}
|
|
142
161
|
|
|
162
|
+
esp-root esp-footer h2 {
|
|
163
|
+
font-size: var(--esp-footer-heading-font-size, var(--esp-type-normal));
|
|
164
|
+
}
|
|
165
|
+
|
|
143
166
|
esp-root esp-footer a,
|
|
144
167
|
esp-root esp-footer a:not([class]) {
|
|
145
168
|
color: var(--esp-footer-link-color, var(--esp-color-link));
|
|
146
169
|
}
|
|
147
170
|
|
|
171
|
+
esp-root esp-footer a:not([class]) {
|
|
172
|
+
text-decoration-line: var(--esp-footer-link-decoration, underline);
|
|
173
|
+
text-underline-offset: var(--esp-footer-link-underline-offset, auto);
|
|
174
|
+
text-decoration-thickness: var(--esp-footer-link-underline-thickness, auto);
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
esp-root esp-footer esp-footer-link-group a:not([class]) {
|
|
178
|
+
text-underline-offset: var(--esp-footer-link-underline-offset, 0.18em);
|
|
179
|
+
}
|
|
180
|
+
|
|
148
181
|
esp-root esp-footer a:hover {
|
|
149
182
|
color: var(--esp-footer-link-hover-color, var(--esp-color-link-hover));
|
|
150
183
|
background-color: var(--esp-footer-link-hover-bg, var(--esp-color-link-hover-bg));
|
|
151
184
|
}
|
|
152
185
|
|
|
186
|
+
esp-root esp-footer a:not([class]):hover {
|
|
187
|
+
text-decoration-line: underline;
|
|
188
|
+
}
|
|
189
|
+
|
|
153
190
|
esp-root esp-footer a:focus-visible {
|
|
154
191
|
outline: var(
|
|
155
192
|
--esp-footer-focus-outline,
|
|
@@ -162,7 +199,7 @@ var r=function(c,e,t,s){var h=arguments.length,i=h<3?e:s===null?s=Object.getOwnP
|
|
|
162
199
|
esp-root esp-footer a:not([class]):focus-visible {
|
|
163
200
|
border-radius: var(--esp-size-border-radius);
|
|
164
201
|
}
|
|
165
|
-
`,
|
|
202
|
+
`,s.styles=A`
|
|
166
203
|
:host {
|
|
167
204
|
display: block;
|
|
168
205
|
}
|
|
@@ -171,4 +208,4 @@ var r=function(c,e,t,s){var h=arguments.length,i=h<3?e:s===null?s=Object.getOwnP
|
|
|
171
208
|
:host([theme-pending]:not([data-theme-ready])) {
|
|
172
209
|
visibility: hidden;
|
|
173
210
|
}
|
|
174
|
-
`,
|
|
211
|
+
`,i([n({attribute:!1})],s.prototype,"correlationId",void 0),i([n({attribute:"virtual-viewport-width",noAccessor:!0,converter:{fromAttribute:c=>{const e=c?.trim()??"";return/^[+-]?(?:\d+(?:\.\d*)?|\.\d+)(?:[eE][+-]?\d+)?$/.test(e)?Number(e):void 0}}})],s.prototype,"virtualViewportWidth",null),i([n({attribute:"light-theme"})],s.prototype,"lightThemeAttr",void 0),i([n({attribute:"dark-theme"})],s.prototype,"darkThemeAttr",void 0),i([n({attribute:!1})],s.prototype,"lightTheme",null),i([n({attribute:!1})],s.prototype,"darkTheme",null),i([n({attribute:"font-css-root",type:String})],s.prototype,"fontCSSRoot",void 0),i([n({attribute:"font-definitions-url",type:String})],s.prototype,"fontDefinitionsUrl",void 0),i([n({attribute:"google-font-loading",type:String})],s.prototype,"googleFontLoading",void 0),i([n({attribute:"icon-sprite-url",type:String})],s.prototype,"iconSpriteUrl",void 0),i([n({attribute:"theme-pending",reflect:!0,type:Boolean})],s.prototype,"themePending",void 0),i([F()],s.prototype,"themeReadyState",void 0),i([n({attribute:"default-scheme",type:String,reflect:!0})],s.prototype,"defaultScheme",void 0),i([n({attribute:"scheme",type:String,reflect:!0})],s.prototype,"scheme",null),s=l=i([P("esp-root")],s);export{ne as BUILT_IN_IMAGE_TEXTURES,s as EspalierRoot,re as registerImageTexture,ie as registeredImageTextures};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{deriveSemantic as k,deriveSemanticWithContrast as A,serializeOklch as R}from"../../shared/color-engine.js";import{SEMANTIC_COLOR_NAMES as C,TOKEN_PAIRINGS as L,resolveLightnessReference as M,semanticToCSS as y}from"../../shared/theme.js";import{resolveMappingSource as E}from"./compute-variants.js";function I(o,g,r,t,i,m){return[o.l,o.c,o.h,g,r,t,i.l,i.c,i.h,m].join("|")}function K(o,g,r={}){const t={},i={},m=new Map,h=(e,s)=>{const n=r.effectiveSource?.(e,s)??s,c=E(n,g,o.anchors);return c||r.onUnresolvedSource?.(n),{color:c??g.primary,resolved:c!==null,source:n}};for(const e of C){if(L[e])continue;const s=o.semanticMappings[e],n=o.chroma[e],c=h(e,s.source),a=M(o.lightness,o.tones,s.lightness),u=k(c.color,a,n.min,n.max),l=y(e);i[e]=u,t[l]=R(u),r.trace&&r.trace.push({token:e,property:l,resolved:t[l],source:c.source,lightness:s.lightness,sourceResolved:c.resolved,base:c.color})}for(const e of C){const s=L[e];if(!s)continue;const n=o.semanticMappings[e],c=o.chroma[e],a=h(e,n.source),u=M(o.lightness,o.tones,n.lightness),l=i[s.bg],v=I(a.color,u,c.min,c.max,l,s.targetLc);let f=m.get(v);if(!f){let S;const N=A(a.color,u,c.min,c.max,l,s.targetLc,r.trace&&(O=>{S=O}));f={requested:S,semantic:N},m.set(v,f)}const{requested:x,semantic:d}=f,p=y(e);i[e]=d,t[p]=R(d),r.trace&&r.trace.push({token:e,property:p,resolved:t[p],source:a.source,lightness:n.lightness,sourceResolved:a.resolved,base:a.color,requested:x,contrast:{against:s.bg,background:l,targetLc:s.targetLc}})}return t}export{K as computeSemanticProperties};
|
|
1
|
+
import{deriveSemantic as k,deriveSemanticWithContrast as A,serializeOklch as R}from"../../shared/color-engine.js";import{SEMANTIC_COLOR_NAMES as C,TOKEN_PAIRINGS as L,resolveLightnessReference as M,semanticToCSS as y}from"../../shared/theme-core.js";import{resolveMappingSource as E}from"./compute-variants.js";function I(o,g,r,t,i,m){return[o.l,o.c,o.h,g,r,t,i.l,i.c,i.h,m].join("|")}function K(o,g,r={}){const t={},i={},m=new Map,h=(e,s)=>{const n=r.effectiveSource?.(e,s)??s,c=E(n,g,o.anchors);return c||r.onUnresolvedSource?.(n),{color:c??g.primary,resolved:c!==null,source:n}};for(const e of C){if(L[e])continue;const s=o.semanticMappings[e],n=o.chroma[e],c=h(e,s.source),a=M(o.lightness,o.tones,s.lightness),u=k(c.color,a,n.min,n.max),l=y(e);i[e]=u,t[l]=R(u),r.trace&&r.trace.push({token:e,property:l,resolved:t[l],source:c.source,lightness:s.lightness,sourceResolved:c.resolved,base:c.color})}for(const e of C){const s=L[e];if(!s)continue;const n=o.semanticMappings[e],c=o.chroma[e],a=h(e,n.source),u=M(o.lightness,o.tones,n.lightness),l=i[s.bg],v=I(a.color,u,c.min,c.max,l,s.targetLc);let f=m.get(v);if(!f){let S;const N=A(a.color,u,c.min,c.max,l,s.targetLc,r.trace&&(O=>{S=O}));f={requested:S,semantic:N},m.set(v,f)}const{requested:x,semantic:d}=f,p=y(e);i[e]=d,t[p]=R(d),r.trace&&r.trace.push({token:e,property:p,resolved:t[p],source:a.source,lightness:n.lightness,sourceResolved:a.resolved,base:a.color,requested:x,contrast:{against:s.bg,background:l,targetLc:s.targetLc}})}return t}export{K as computeSemanticProperties};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{parseCssColor as
|
|
1
|
+
import{parseCssColor as m,serializeOklch as b,gamutMapToSRGB as S}from"../../shared/color-engine.js";import{compileComponentProperties as O}from"../../shared/component-property-compiler.js";import{generateScaleProperties as k}from"../../shared/scale-engine.js";import{DATA_SERIES_KEYS as y,DEFAULT_DATA_PALETTE as B,generateDivergingRamp as R,generateSequentialRamp as w}from"../../shared/data-colors.js";import{DEFAULT_BODY_FONT_FAMILY as E,DEFAULT_MONOSPACE_FONT_FAMILY as I,resolveDataColorSource as P}from"../../shared/theme-core.js";import{dataCompanionProperties as $}from"./data-companion-properties.js";import{lightnessRampProperties as M}from"./lightness-ramp-properties.js";import{surfacePolarityProperty as T}from"./surface-polarity-property.js";import{computeVariants as x}from"./compute-variants.js";import{computeSemanticProperties as A}from"./compute-semantic-properties.js";function C(o){return{rootFontSize:o.rootFontSize,typeRatio:o.typeRatio,spaceRatio:o.spaceRatio,borderRadius:o.borderRadius,viewportMin:o.viewportMin,viewportMax:o.viewportMax}}function _(o,g,l){const d={},s=o.dataPalette??B;for(let r=0;r<y.length;r+=1){const a=y[r],i=m(l(s[a],`dataPalette.${a}`))??g;d[`--esp-color-series-${r+1}`]=b(S(i))}return d}function q(o,g,l,d={},s){const r=m(o.seedColor);if(!r)return{};const a={};a["--esp-scheme"]=g,a["--esp-seed-color"]=o.seedColor;const i=x(r,o);for(const[e,n]of Object.entries(i))a[`--esp-color-${e}`]=b(S(n));const f=new Set,p=(e,n)=>{const t=typeof e=="string"?P(e,o.anchors):null;if(t)return t;const c=typeof e=="string"?e:String(e);return f.has(c)||(f.add(c),console.warn(`Espalier theme: ${n} color source "${c}" cannot be resolved \u2014 falling back to the seed. Run validateTheme for the declared data colors.`)),o.seedColor};Object.assign(a,_(o,r,p));for(const[e,n]of Object.entries(o.dataRamps??{}))try{(n.type==="sequential"?w(p(n.source,`dataRamps.${e}.source`),{steps:n.steps,lightnessStart:n.lightnessStart,lightnessEnd:n.lightnessEnd}):R(p(n.start,`dataRamps.${e}.start`),p(n.end,`dataRamps.${e}.end`),{steps:n.steps,neutral:n.neutral===void 0?void 0:p(n.neutral,`dataRamps.${e}.neutral`)})).forEach((c,v)=>{a[`--esp-color-ramp-${e}-${v+1}`]=c})}catch(t){console.warn(`Espalier theme: dataRamps.${e} cannot be generated \u2014 ${t instanceof Error?t.message:String(t)}`)}Object.assign(a,M(o));const u=new Set;return Object.assign(a,A(o,i,{trace:l,onUnresolvedSource:e=>{u.has(e)||(u.add(e),console.warn(`Espalier theme: color source "${e}" cannot be resolved \u2014 falling back to the seed. Run validateTheme for the declared anchors.`))}})),s&&Object.assign(a,O(s.surface,{theme:o,variants:i,semanticProperties:a},s.trace)),Object.assign(a,T(a)),Object.assign(a,$(a)),Object.assign(a,k(C(o),d.viewportWidth)),a["--esp-font-body"]=o.fontBody||E,o.fontHeadings&&(a["--esp-font-headings"]=o.fontHeadings),o.fontBrand&&(a["--esp-font-brand"]=o.fontBrand),o.fontMenu&&(a["--esp-font-menu"]=o.fontMenu),a["--esp-font-monospace"]=o.fontMonospace||I,a["--esp-font-weight-body"]=o.fontWeightBody,a["--esp-font-weight-headings"]=o.fontWeightHeadings,a["--esp-font-weight-brand"]=o.fontWeightBrand,a["--esp-font-weight-menu"]=o.fontWeightMenu,a["--esp-font-weight-monospace"]=o.fontWeightMonospace,o.pageBackgroundImage&&(a["--esp-page-background-image"]=o.pageBackgroundImage),o.pageBackgroundImageOpacity!==void 0&&(a["--esp-page-background-image-opacity"]=o.pageBackgroundImageOpacity.toString()),o.boxBackgroundImage&&(a["--esp-box-background-image"]=o.boxBackgroundImage),o.boxBackgroundImageOpacity!==void 0&&(a["--esp-box-background-image-opacity"]=o.boxBackgroundImageOpacity.toString()),o.vellumOpacity!==void 0&&(a["--esp-vellum-opacity"]=o.vellumOpacity.toString()),o.vellumBackgroundImage&&(a["--esp-vellum-background-image"]=o.vellumBackgroundImage),o.vellumBackgroundImageOpacity!==void 0&&(a["--esp-vellum-background-image-opacity"]=o.vellumBackgroundImageOpacity.toString()),a}export{q as computeThemeProperties,_ as dataSeriesProperties};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{apcaContrast as s,ensureContrast as _,gamutMapToSRGB as i,oklabToOklch as T,oklchToOklab as p,parseOklch as S,serializeOklch as l}from"../../shared/color-engine.js";import{DATA_SERIES_KEYS as f}from"../../shared/data-colors.js";import{TOKEN_PAIRINGS as m}from"../../shared/theme.js";const b=.75,u=.12,E=m.text?.targetLc??75;function I(c,n){const t=_({...c},n,E);if(Math.abs(s(t,n))>=E)return t;const o=i({l:n.l>.5?1:0,c:c.c,h:c.h});return Math.abs(s(o,n))>Math.abs(s(t,n))?o:t}function A(c,n,t){const o=p(c),r=p(n);return T({L:o.L*t+r.L*(1-t),a:o.a*t+r.a*(1-t),b:o.b*t+r.b*(1-t)})}function x(c,n){const t=S(c["--esp-color-background"]??"");if(!t)return{};const o={};for(let r=1;r<=f.length;r+=1){const a=`--esp-color-series-${r}`,e=S(c[a]??n?.[a]??"");e&&(o[`${a}-wash`]=l(i(A(e,t,b))),o[`${a}-tint`]=l(i(A(e,t,u))),o[`${a}-ink`]=l(I(e,t)))}return o}export{u as DATA_TINT_SERIES_SHARE,b as DATA_WASH_SERIES_SHARE,x as dataCompanionProperties};
|
|
1
|
+
import{apcaContrast as s,ensureContrast as _,gamutMapToSRGB as i,oklabToOklch as T,oklchToOklab as p,parseOklch as S,serializeOklch as l}from"../../shared/color-engine.js";import{DATA_SERIES_KEYS as f}from"../../shared/data-colors.js";import{TOKEN_PAIRINGS as m}from"../../shared/theme-core.js";const b=.75,u=.12,E=m.text?.targetLc??75;function I(c,n){const t=_({...c},n,E);if(Math.abs(s(t,n))>=E)return t;const o=i({l:n.l>.5?1:0,c:c.c,h:c.h});return Math.abs(s(o,n))>Math.abs(s(t,n))?o:t}function A(c,n,t){const o=p(c),r=p(n);return T({L:o.L*t+r.L*(1-t),a:o.a*t+r.a*(1-t),b:o.b*t+r.b*(1-t)})}function x(c,n){const t=S(c["--esp-color-background"]??"");if(!t)return{};const o={};for(let r=1;r<=f.length;r+=1){const a=`--esp-color-series-${r}`,e=S(c[a]??n?.[a]??"");e&&(o[`${a}-wash`]=l(i(A(e,t,b))),o[`${a}-tint`]=l(i(A(e,t,u))),o[`${a}-ink`]=l(I(e,t)))}return o}export{u as DATA_TINT_SERIES_SHARE,b as DATA_WASH_SERIES_SHARE,x as dataCompanionProperties};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{LIGHTNESS_KEYS as s}from"../../shared/theme.js";import{lightnessKeyToCSS as e}from"./lightness-key-to-css.js";function p(t){const o={};for(const r of s)o[e(r)]=`${Math.round(t.lightness[r]*100)}%`;return o}export{p as lightnessRampProperties};
|
|
1
|
+
import{LIGHTNESS_KEYS as s}from"../../shared/theme-core.js";import{lightnessKeyToCSS as e}from"./lightness-key-to-css.js";function p(t){const o={};for(const r of s)o[e(r)]=`${Math.round(t.lightness[r]*100)}%`;return o}export{p as lightnessRampProperties};
|
|
@@ -20,6 +20,9 @@ import { type CSSResult } from "lit";
|
|
|
20
20
|
* Base and child rules have zero specificity. A selected light-DOM paragraph
|
|
21
21
|
* receives a color-only bridge over `esp-root`'s native paragraph ink. The
|
|
22
22
|
* consumer keeps ownership of outer block rhythm, prose measure and font family.
|
|
23
|
+
*
|
|
24
|
+
* @cssprop --esp-blockquote-bar-color - Color of the quote's inline-start border. Defaults to `var(--esp-color-border)`.
|
|
25
|
+
* @cssprop --esp-blockquote-glyph-color - Ink of the opening quote mark. Defaults to `var(--esp-blockquote-bar-color, var(--esp-color-border))`.
|
|
23
26
|
*/
|
|
24
27
|
export declare function blockquoteStyles(selector?: string, options?: {
|
|
25
28
|
figureSelector?: string;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{css as
|
|
1
|
+
import{css as o,unsafeCSS as i}from"lit";function h(n="blockquote",s){const a=n.trim();if(!a)throw new RangeError("A blockquote selector must not be empty.");const t=s?.figureSelector?.trim();if(t==="")throw new RangeError("A figure selector must not be empty.");const e=i(a),l=i('url("data:image/svg+xml,%3Csvg%20xmlns%3D%27http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%27%20viewBox%3D%270%200%2032%2032%27%3E%3Cpath%20d%3D%27M3%2025V15C3%208%207%204%2014%203v5c-4%201-6%203-6%206h6v11H3zm15%200V15c0-7%204-11%2011-12v5c-4%201-6%203-6%206h6v11H18z%27%2F%3E%3C%2Fsvg%3E")'),r=i(t??""),p=t===void 0?o``:o`
|
|
2
2
|
:where(${r}) {
|
|
3
3
|
margin-inline: 0;
|
|
4
4
|
min-inline-size: 0;
|
|
@@ -23,11 +23,11 @@ import{css as i,unsafeCSS as o}from"lit";function h(a="blockquote",s){const n=a.
|
|
|
23
23
|
letter-spacing: inherit;
|
|
24
24
|
color: inherit;
|
|
25
25
|
}
|
|
26
|
-
`;return
|
|
26
|
+
`;return o`
|
|
27
27
|
:where(${e}) {
|
|
28
28
|
position: relative;
|
|
29
29
|
background: var(--esp-color-layer-1, var(--esp-color-background));
|
|
30
|
-
border-inline-start: 0.3em solid var(--esp-color-border);
|
|
30
|
+
border-inline-start: 0.3em solid var(--esp-blockquote-bar-color, var(--esp-color-border));
|
|
31
31
|
padding-block: var(--esp-size-small);
|
|
32
32
|
padding-inline-end: var(--esp-size-small);
|
|
33
33
|
padding-inline-start: calc(var(--esp-size-small) + 1.6em + var(--esp-size-tiny));
|
|
@@ -49,7 +49,7 @@ import{css as i,unsafeCSS as o}from"lit";function h(a="blockquote",s){const n=a.
|
|
|
49
49
|
inset-inline-start: var(--esp-size-small);
|
|
50
50
|
width: 1.6em;
|
|
51
51
|
height: 1.6em;
|
|
52
|
-
background: var(--esp-color-border);
|
|
52
|
+
background: var(--esp-blockquote-glyph-color, var(--esp-blockquote-bar-color, var(--esp-color-border)));
|
|
53
53
|
mask-image: ${l};
|
|
54
54
|
mask-size: contain;
|
|
55
55
|
mask-position: center;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
import{CSS_NAMED_COLORS as w}from"./css-named-colors.js";const mt={l:0,c:0,h:0},Mt={l:1,c:0,h:0},B=Math.PI/180,p=1e-4,K=50,_="[+-]?(?:\\d+|\\d*\\.\\d+)(?:[eE][+-]?\\d+)?",h="[\\t\\n\\f\\r ]",U=new RegExp(h+"*,"+h+"*"),z=new RegExp(h+"+");function d(t){return t.replace(/\/\*[\s\S]*?(?:\*\/|$)/g," ").replace(/^[\t\n\f\r ]+|[\t\n\f\r ]+$/g,"")}const P={"":1,deg:1,grad:.9,rad:180/Math.PI,turn:360},Y=.4,j=new RegExp("^oklch\\("+h+"*("+_+")(%?)"+h+"+("+_+")(%?)"+h+"+("+_+")(deg|grad|rad|turn)?"+h+"*\\)$","i");function k(t){const n=t.h*B;return{L:t.l,a:t.c*Math.cos(n),b:t.c*Math.sin(n)}}function q(t){const n=t.L+.3963377774*t.a+.2158037573*t.b,e=t.L-.1055613458*t.a-.0638541728*t.b,r=t.L-.0894841775*t.a-1.291485548*t.b,o=n*n*n,c=e*e*e,s=r*r*r;return{r:4.0767416621*o-3.3077115913*c+.2309699292*s,g:-1.2684380046*o+2.6097574011*c-.3413193965*s,b:-.0041960863*o-.7034186147*c+1.707614701*s}}function A(t){return t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055}function J(t){return{r:A(t.r),g:A(t.g),b:A(t.b)}}function Q(t){return t.r>=-p&&t.r<=1+p&&t.g>=-p&&t.g<=1+p&&t.b>=-p&&t.b<=1+p}function f(t){return Math.max(0,Math.min(1,t))}function Z(t){const n=d(t).match(j);if(!n)return null;let e=parseFloat(n[1]);n[2]==="%"&&(e/=100);let r=parseFloat(n[3]);n[4]==="%"&&(r=r/100*Y);const o=parseFloat(n[5])*P[(n[6]??"").toLowerCase()];return!isFinite(e)||!isFinite(r)||!isFinite(o)?null:{l:Math.max(0,Math.min(1,e)),c:Math.max(0,r),h:(o%360+360)%360}}function gt(t){const n=M(t.l,6),e=M(t.c,6),r=M((t.h%360+360)%360,4);return`oklch(${n} ${e} ${r})`}function R(t){return J(q(k(t)))}function S(t){return Q(R(t))}function x(t){if(t.c<=p||S(t))return{...t};let n=0,e=t.c,r={...t};for(let o=0;o<K;o++){const c=(n+e)/2;if(r={l:t.l,c,h:t.h},S(r)?n=c:e=c,e-n<p)break}return{l:t.l,c:n,h:t.h}}function tt(t,n,e){const r={l:t.l,c:Math.max(n,Math.min(e,t.c)),h:t.h};return x(r)}const L=.022,I=.012,v=.022,F=.57,N=.56,y=1.14,O=.001,b=.027;function D(t){const n=Math.pow(f(t.r),2.4),e=Math.pow(f(t.g),2.4),r=Math.pow(f(t.b),2.4);return .2126729*n+.7151522*e+.072175*r}function $(t,n){const e=R(x(t)),r=R(x(n));let o=D(e),c=D(r);if(o=o>L?o:o+Math.pow(L-o,1.414),c=c>L?c:c+Math.pow(L-c,1.414),Math.abs(c-o)<O)return 0;let s;if(c>o){const u=Math.pow(c,N),l=Math.pow(o,F);if(s=(u-l)*y,s<O)return 0;s=s<b?s-s*v*b:s-v}else{const u=Math.pow(c,N),l=Math.pow(o,F);if(s=(u-l)*y,s>-O)return 0;s=s>-b?s-s*I*b:s+I}return s*100}function nt(t,n,e=60){let r=x({...t}),o=Math.abs($(r,n));if(o>=e)return r;const c=n.l>.5,s=.01,u=c?0:1;for(let l=0;l<100;l++){if(c?r.l=Math.max(u,r.l-s):r.l=Math.min(u,r.l+s),r=x(r),o=Math.abs($(r,n)),o>=e)return r;if(r.l<=0||r.l>=1)break}return r}function xt(t,n){return((t+n)%360+360)%360}function Ct(t,n){const e=k(t),r=k(n),o=e.L-r.L,c=e.a-r.a,s=e.b-r.b;return Math.sqrt(o*o+c*c+s*s)}function rt(t,n,e,r){return tt({l:n,c:t.c,h:t.h},e,r)}function _t(t,n,e,r,o,c=60,s){const u=rt(t,n,e,r);return s?.(u),nt(u,o,c)}function G(t){return t<=.04045?t/12.92:Math.pow((t+.055)/1.055,2.4)}function et(t){return{r:G(t.r),g:G(t.g),b:G(t.b)}}function ot({r:t,g:n,b:e}){const r=Math.cbrt(.4122214708*t+.5363325363*n+.0514459929*e),o=Math.cbrt(.2119034982*t+.6806995451*n+.1073969566*e),c=Math.cbrt(.0883024619*t+.2817188376*n+.6299787005*e);return{L:.2104542553*r+.793617785*o-.0040720468*c,a:1.9779984951*r-2.428592205*o+.4505937099*c,b:.0259040371*r+.7827717662*o-.808675766*c}}function ct(t){return ot(et(t))}function H(t){const n=Math.sqrt(t.a*t.a+t.b*t.b),e=n<1e-12?0:(Math.atan2(t.b,t.a)/B%360+360)%360;return{l:t.L,c:n,h:e}}function st(t){const n=M(t.c,4);return{l:M(t.l,3),c:n,h:n===0?0:M(t.h,1)}}function m(t){return Math.round(f(t)*255)}function ut(t){const n=H(ct(t)),e=t.r===t.g&&t.g===t.b?{l:n.l,c:0,h:0}:n,r=st(e);if(S(r)){const o=R(r);if(m(o.r)===m(t.r)&&m(o.g)===m(t.g)&&m(o.b)===m(t.b))return r}return e}function V(t,n){const e=t.slice(1),r=e.length;if(!/^[0-9a-f]+$/i.test(e)||r!==3&&r!==6&&!(n&&(r===4||r===8)))return null;const o=r<=4?1:2,c=s=>{const u=e.slice(s*o,(s+1)*o);return parseInt(o===1?u.repeat(2):u,16)/255};return{space:"srgb",color:{r:c(0),g:c(1),b:c(2)},alpha:r===4||r===8?c(3):1}}function C(t,n,e){const r=t.match(new RegExp("^"+n+"\\("+h+"*([^)]*?)"+h+"*\\)$","i"));if(!r)return null;const o=r[1],c=o.includes(","),s=o.split("/");if(s.length>2||s.length===2&&(c||!e))return null;const l=d(s[0]).split(c?U:z),i=c&&l.length===4&&e?l.pop():s[1];if(l.length!==3||l.some(g=>g.length===0))return null;const a=i===void 0?1:W(d(i));return a===null?null:{args:l,legacy:c,alpha:a}}const at=new RegExp("^("+_+")([a-z%]*)$","i");function T(t){const n=t.match(at);if(!n)return null;const e=parseFloat(n[1]);return isFinite(e)?{value:e,unit:n[2].toLowerCase()}:null}function W(t){if(t.toLowerCase()==="none")return 0;const n=T(t);return!n||n.unit!==""&&n.unit!=="%"?null:f(n.unit==="%"?n.value/100:n.value)}function lt(t){if(t.unit!==""&&t.unit!=="%")return null;const n=t.unit==="%"?t.value/100:t.value/255;return Math.max(0,Math.min(1,n))}function it(t){const n=P[t.unit];return n===void 0?null:t.value*n}function X(t){return t.unit!==""&&t.unit!=="%"?null:Math.max(0,Math.min(1,t.value/100))}function ht(t,n,e){const r=(t%360+360)%360,o=c=>{const s=(c+r/30)%12,u=n*Math.min(e,1-e);return e-u*Math.max(-1,Math.min(s-3,9-s,1))};return{r:o(0),g:o(8),b:o(4)}}const dt='"#rrggbb", "#rgb", "rgb(\u2026)", "hsl(\u2026)", "oklch(\u2026)"';function Rt(t){const n=pt(t,!1);return n?n.space==="oklch"?n.color:ut(n.color):null}function pt(t,n){const e=d(t);if(e.startsWith("#"))return V(e,n);if(/^oklch\(/i.test(e)){const r=n?C(e,"oklch",!0):null;if(n&&(!r||r.legacy))return null;const o=Z(r?`oklch(${r.args.map(c=>c.toLowerCase()==="none"?"0":c).join(" ")})`:e);return o?{space:"oklch",color:o,alpha:r?.alpha??1}:null}if(/^rgba?\(/i.test(e)){const r=C(e,"rgba?",n);if(!r)return null;const o=r.args.map(T);if(o.some(a=>a===null))return null;const c=o;if(r.legacy&&new Set(c.map(a=>a.unit)).size>1)return null;const s=c.map(lt);if(s.some(a=>a===null))return null;const[u,l,i]=s;return{space:"srgb",color:{r:u,g:l,b:i},alpha:r.alpha}}if(/^hsla?\(/i.test(e)){const r=C(e,"hsla?",n);if(!r)return null;const o=r.args.map(T);if(o.some(g=>g===null))return null;const[c,s,u]=o;if(r.legacy&&(s.unit!=="%"||u.unit!=="%"))return null;const l=it(c),i=X(s),a=X(u);return l===null||i===null||a===null?null:{space:"srgb",color:ht(l,i,a),alpha:r.alpha}}if(n){if(/^oklab\(/i.test(e)){const c=C(e,"oklab",!0);if(!c||c.legacy)return null;const s=c.args.map(a=>T(a.toLowerCase()==="none"?"0":a));if(s.some(a=>!a||a.unit!==""&&a.unit!=="%"))return null;const[u,l,i]=s.map((a,g)=>{const E=a;return E.unit!=="%"?E.value:E.value/100*(g===0?1:.4)});return{space:"oklch",color:H({L:f(u),a:l,b:i}),alpha:c.alpha}}const r=e.toLowerCase();if(Object.prototype.hasOwnProperty.call(w,r))return V(w[r],n);if(r==="transparent")return{space:"srgb",color:{r:0,g:0,b:0},alpha:0};const o=e.match(new RegExp("^color\\("+h+"*srgb"+h+"+","i"));if(o){const c=C(`color(${e.slice(o[0].length)}`,"color",!0);if(!c||c.legacy)return null;const s=c.args.map(W);if(s.some(a=>a===null))return null;const[u,l,i]=s;return{space:"srgb",color:{r:u,g:l,b:i},alpha:c.alpha}}}return null}function M(t,n){const e=Math.pow(10,n);return Math.round(t*e)/e}export{dt as ACCEPTED_COLOR_FORMS,mt as BLACK_INK,Mt as WHITE_INK,$ as apcaContrast,f as clampChannel,tt as clampChromaAndGamutMap,Ct as deltaEOK,rt as deriveSemantic,_t as deriveSemanticWithContrast,nt as ensureContrast,G as gammaToLinear,x as gamutMapToSRGB,S as isInSRGBGamut,ot as linearRgbToOklab,H as oklabToOklch,k as oklchToOklab,R as oklchToSRGB,Rt as parseCssColor,pt as parseCssColorValue,Z as parseOklch,xt as rotateHue,gt as serializeOklch,et as srgbToLinearRGB,ct as srgbToOklab};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{apcaContrast as k,BLACK_INK as I,deriveSemantic as T,ensureContrast as y,parseOklch as O,serializeOklch as h,WHITE_INK as S}from"./color-engine.js";import{SEMANTIC_COLOR_PROPERTIES as _,SETTABLE_COMPONENT_PROPERTIES as N}from"./settable-component-properties.js";import{resolveLightnessReference as j}from"./theme-core.js";import{resolveMappingSource as x}from"./variant-engine.js";function E(e,{theme:i,variants:d,semanticProperties:r}){if(typeof e=="string")return _.has(e)?r[e]:e;const o=x(e.source,d,i.anchors);if(!o)return;const l=j(i.lightness,i.tones,e.lightness);return h(T(o,l,0,o.c))}function M(e,i,d){const r=t=>Math.abs(k(t,i)),o=r(e);if(o>=d)return{resolved:h(e),fromLc:o,toLc:o};let l=h(y(e,i,d)),u=r(O(l));if(u<d)for(const t of[I,S]){const n=r(t);n>u&&(l=h(t),u=n)}return{resolved:l,fromLc:o,toLc:u}}function w(e,i,d,r=N){const o={},l=Object.entries(e.values);if(l.length===0)return o;const u=(t,n,s,c)=>{o[t]=s,d?.push({name:t,context:e.context,authored:n,resolved:s,overridesRoot:n!==null&&(e.winners.get(t)?.overridesRoot??!1),...c})};for(const[t,n]of l){const s=r[t];if(s.pairsWith!==void 0)continue;let c;if(s.syntax==="color"?c=E(n,i):typeof n=="string"&&(c=n),c===void 0)continue;u(t,n,c);const f=s.derives;f&&typeof n=="string"&&Object.prototype.hasOwnProperty.call(f.values,n)&&(o[f.property]=f.values[n])}for(const[t,{pairsWith:n,targetLc:s,fitFallback:c}]of Object.entries(r)){if(n===void 0||s===void 0||c===void 0)continue;const f=e.values[t],g=o[n];if(f===void 0&&g===void 0)continue;const{semanticProperties:m}=i,b=r[n]?.fitFallback??n,p=g??m[b],a=f===void 0?m[c]:E(f,i),v=p===void 0?null:O(p),L=a===void 0?null:O(a);if(p===void 0||a===void 0||!v||!L)continue;const{resolved:C,fromLc:P,toLc:R}=M(L,v,s);u(t,f??null,C,d?{requested:a,adjusted:a!==C,apca:{against:n,againstColor:p,fromLc:P,toLc:R},targetLc:s}:void 0)}return o}export{w as compileComponentProperties};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{PUBLIC_TOKEN_NAMES as a,PUBLIC_TOKEN_PATTERNS as i}from"./public-token-catalog.generated.js";import{isSettableComponentPropertyName as l,PRIVATE_COMPONENT_PROPERTY_PREFIX as c,SETTABLE_COMPONENT_PROPERTIES as u}from"./settable-component-properties.js";import{PUBLIC_TOKEN_NAMES as h,PUBLIC_TOKEN_PATTERNS as C}from"./public-token-catalog.generated.js";const p=new Set(a),f=i.map(e=>new RegExp(e)),m=Object.keys(u);function T(e){return e.startsWith(c)?"private":l(e)?"settable":p.has(e)||f.some(t=>t.test(e))?"not_settable":"unknown"}function P(e,t){let o=Array.from({length:t.length+1},(n,s)=>s);for(let n=0;n<e.length;n+=1){const s=[n+1];for(let r=0;r<t.length;r+=1)s.push(Math.min(o[r+1]+1,s[r]+1,o[r]+ +(e[n]!==t[r])));o=s}return o[t.length]}function _(e,t=m){let o,n=1/0;for(const s of t){const r=P(e,s);(o===void 0||r<n||r===n&&s<o)&&(o=s,n=r)}return o}function d(e){if(!e)return"a JSON object of settable component property names and values";if(e.syntax==="color")return`${e.allowedValues?.join(", ")??"a semantic color token"} or a { source, lightness } mapping`;const t=e.allowedValues?.join(", ");if(e.syntax==="keyword")return`one of ${t}`;const o=`a length from ${e.min}${e.unit} to ${e.max}${e.unit}, or 0`;return t?`${o}, or one of ${t}`:o}export{h as PUBLIC_TOKEN_NAMES,C as PUBLIC_TOKEN_PATTERNS,T as classifyComponentPropertyName,d as describeAcceptedComponentPropertyValue,_ as nearestSettableComponentProperty};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{parseCssColor as P}from"./color-engine.js";import{SEMANTIC_COLOR_PROPERTIES as y,SETTABLE_COMPONENT_PROPERTIES as p}from"./settable-component-properties.js";import{isColorSource as g,isLightnessKey as b,isObjectRecord as u,isThemeSlug as m,isThemeTone as S,toneReferenceName as T}from"./theme-mapping-grammar.js";import{parseAnchorSource as E}from"./variant-engine.js";const C=/[;{}]|!\s*important|(?:var|calc|url)\s*\(/i,R=/^(-?(?:\d+(?:\.\d+)?|\.\d+))(em|rem)$/,h=new WeakMap;function l(e,n){return u(e)&&Object.prototype.hasOwnProperty.call(e,n)?e[n]:void 0}function j(e,n){if(g(e))return!0;if(typeof e!="string")return!1;const t=E(e);if(!t||!m(t.name))return!1;const{name:o,slot:r}=t;if(r!==void 0&&!m(r))return!1;const i=l(n,o),s=typeof i=="string"&&r===void 0?i:l(i,r??"color");return typeof s=="string"&&P(s)!==null}function N(e,n){if(b(e))return!0;const t=T(e);return t!==null&&n.has(t)}function M(e,n,t){if(typeof e=="string")return(n.allowedValues?n.allowedValues.includes(e):y.has(e))?e:void 0;if(!u(e)||Reflect.ownKeys(e).length!==2)return;const o=l(e,"source"),r=l(e,"lightness");if(!(!j(o,t.anchors)||!N(r,t.tones)))return{source:o,lightness:r}}function L(e,n){if(e==="0")return!0;const t=R.exec(e);if(!t||t[0]!==e||t[2]!==n.unit)return!1;const o=Number(t[1]);return Number.isFinite(o)&&o>=n.min&&o<=n.max}function V(e,n,t){if(!(typeof e=="string"&&C.test(e))){if(n.syntax==="color")return M(e,n,t);if(typeof e=="string"&&(n.syntax!=="keyword"&&L(e,n)||n.syntax!=="length"&&n.allowedValues?.includes(e)))return e}}function w(e,n){const t=new Set(n);if(u(e))for(const[o,r]of Object.entries(e))S(o,r)&&t.add(o);return t}function _(e,n,t){const o=new Map,{map:r,context:i}=e;if(r===void 0)return o;if(!u(r))return t.push({context:i,property:null,code:"bad_value"}),o;for(const[s,f]of Object.entries(r)){if(!Object.prototype.hasOwnProperty.call(n,s)){t.push({context:i,property:s,code:"unregistered"}),o.set(s,{valid:!1,authored:f});continue}const c=V(f,n[s],e);c===void 0?(t.push({context:i,property:s,code:"bad_value"}),o.set(s,{valid:!1,authored:f})):o.set(s,{valid:!0,authored:c})}return o}function O(e,n,t,o,r){const i=_(e,n,o),s=new Map(r?.winners),f={...r?.values};for(const[c,a]of i)if(s.set(c,{...a,context:e.context,overridesRoot:a.valid&&(r?.declarations.has(c)??!1)}),a.valid){f[c]=a.authored,t.add(c);const{derives:d}=n[c];d&&typeof a.authored=="string"&&Object.prototype.hasOwnProperty.call(d.values,a.authored)&&t.add(d.property)}else delete f[c];return{context:e.context,supplied:e.map!==void 0||(r?.supplied??!1),declarations:i,winners:s,values:f}}function x(e,n){const t=[],o=new Set,r=e.anchors,i=w(e.tones),s=O({map:e.componentProperties,context:null,anchors:r,tones:i},n,o,t),f=new Map;if(u(e.contexts))for(const[c,a]of Object.entries(e.contexts)){if(!u(a))continue;const d={map:a.componentProperties,context:c,anchors:r,tones:w(a.tones,i)};f.set(c,O(d,n,o,t,s))}for(const[c,{pairsWith:a}]of Object.entries(n))a!==void 0&&Object.prototype.hasOwnProperty.call(n,a)&&o.has(a)&&o.add(c);return{root:s,contexts:f,findings:t,candidates:o}}function K(e,n,t=p){return{...x(e,t),scheme:n}}function W(e){let n=h.get(e);return n||(n=x(e,p),h.set(e,n)),n}export{W as getComponentPropertyAnalysis,K as normalizeComponentProperties};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(o,n){for(const t of n)Object.prototype.hasOwnProperty.call(o,t)||(o[t]="initial")}export{e as addComponentPropertyResets};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function n(t){return t.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in t}function r(t){if(t.assignedSlot)return t.assignedSlot;if(t.parentElement)return t.parentElement;const e=t.parentNode;return e&&n(e)?e.host:null}export{r as composedParent,n as isShadowRoot};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function e(r,o){return r?.trim()||o?.trim()||""}export{e as resolveConfiguredBrandColor};
|