@taprootio/espalier 7.1.0 → 7.2.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 +16 -0
- package/custom-elements.json +14088 -11749
- package/dist/button/esp-button.js +7 -4
- package/dist/button/paint-registration.js +1 -0
- package/dist/cli/theme-check.js +2 -2
- package/dist/footer/paint-registration.js +1 -0
- package/dist/header/esp-header-button.js +6 -2
- package/dist/header/esp-header.js +8 -4
- 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 +2 -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 +13 -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/shared/color-engine.js +1 -1
- 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/esp-element-base.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/theme-fit-report.d.ts +10 -2
- package/dist/shared/theme-fit-report.js +1 -1
- package/dist/shared/theme.d.ts +3 -24
- 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/package.json +6 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
var o=function(d,e,r,s){var p=arguments.length,n=p<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,r):s,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(d,e,r,s);else for(var c=d.length-1;c>=0;c--)(i=d[c])&&(n=(p<3?i(n):p>3?i(e,r,n):i(e,r))||n);return p>3&&n&&Object.defineProperty(e,r,n),n};import{css as g,html as l,nothing as h}from"lit";import{customElement as
|
|
1
|
+
var o=function(d,e,r,s){var p=arguments.length,n=p<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,r):s,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(d,e,r,s);else for(var c=d.length-1;c>=0;c--)(i=d[c])&&(n=(p<3?i(n):p>3?i(e,r,n):i(e,r))||n);return p>3&&n&&Object.defineProperty(e,r,n),n};import{css as g,html as l,nothing as h}from"lit";import{insetNavigationFocusOutline as f}from"./navigation-focus-outline.js";import{customElement as w,property as a,state as u}from"lit/decorators.js";import{classMap as y}from"lit/directives/class-map.js";import{ref as m}from"lit/directives/ref.js";import{getIconHrefForHost as k}from"../shared/intent-values.js";import{EspalierElementBase as v}from"../shared/esp-element-base.js";import{ESP_EVENTS as z}from"../shared/events.js";import{pathsMatch as x}from"../shared/path-matching.js";import{SlottedIconController as $}from"../shared/slotted-icon-controller.js";import{renderSpriteIcon as E}from"../shared/svgs/render-sprite-icon.js";import{DEFAULT_NEW_TAB_LABEL as _,renderNewTabCue as S}from"../shared/new-tab-cue.js";import{srOnly as C}from"../shared/style-fragments.js";import{MENU_SOURCE_CHANGED as H,resolveMenuItemAppearance as b}from"./menu-presentation.js";import"../button/esp-button.js";let t=class extends v{constructor(){super(...arguments),this.iconSlot=new $(this),this.label="",this.url="",this.appearance="link",this.target="",this.rel="",this.newTabLabel=_,this.icon="",this.headerEnd=!1,this.promotedForHeader=!1,this.mode="vertical",this.depth=0,this.touchDevice=!1,this.active=!1}get headerEndPromoted(){return this.promotedForHeader}setHeaderEndPromoted(e){this.promotedForHeader=e,this.toggleAttribute("data-esp-header-end-promoted",e)}connectedCallback(){this.setHeaderEndPromoted(!1),super.connectedCallback(),this.checkActive()}disconnectedCallback(){this.setHeaderEndPromoted(!1),super.disconnectedCallback()}willUpdate(e){super.willUpdate(e),e.has("appearance")&&(this.appearance=b(this.appearance))}updated(e){super.updated(e),["label","url","target","rel","newTabLabel","icon","headerEnd","appearance"].some(r=>e.has(r))&&this.dispatchEvent(new CustomEvent(H,{bubbles:!0,composed:!0})),e.has("url")&&this.checkActive()}checkActive(){if(!this.url){this.active=!1;return}this.active=x(this.url)}handleButtonClick(){this.dispatchEvent(new CustomEvent(z.CLICKED,{detail:{},bubbles:!0,composed:!0}))}render(){const e=k(this.icon,this),r=this.iconSlot.hasSlottedIcon(":scope > :not([slot]), :scope > [slot='']"),s=r||e.length>0,p=b(this.appearance)==="button",n={item:!0,"button-appearance":p,"is-horizontal":this.mode==="horizontal"&&this.depth===0,"is-vertical":this.mode!=="horizontal"||this.depth>0,"is-drawer":this.mode==="drawer","is-nested":this.depth>0,"has-icon":s,"is-active":this.active},i=l`<span part="menu-text">${this.label}</span>`,c=l`<span class="icon-area" aria-hidden=${s?"true":h}>
|
|
2
2
|
<slot ${m(this.iconSlot.slotRef)} @slotchange=${this.iconSlot.handleSlotChange}></slot>
|
|
3
|
-
${!r&&e
|
|
4
|
-
</span>`;return l`<div class=${
|
|
3
|
+
${!r&&e?E(e):h}
|
|
4
|
+
</span>`;return l`<div class=${y(n)} ?hidden=${this.headerEndPromoted}>
|
|
5
5
|
${p?l`<esp-button
|
|
6
6
|
collapsed
|
|
7
7
|
exportparts="label: menu-text"
|
|
@@ -13,9 +13,9 @@ var o=function(d,e,r,s){var p=arguments.length,n=p<3?e:s===null?s=Object.getOwnP
|
|
|
13
13
|
.current=${this.active}
|
|
14
14
|
.icon=${this.icon}
|
|
15
15
|
><slot ${m(this.iconSlot.slotRef)} @slotchange=${this.iconSlot.handleSlotChange}></slot></esp-button>`:this.active?l`<span class="current-page" aria-current="page">${i}${c}</span>`:this.url?l`<a href=${this.url} target=${this.target||h} rel=${this.rel||h}
|
|
16
|
-
>${i}${c}${
|
|
16
|
+
>${i}${c}${S(this.target,this.newTabLabel)}</a
|
|
17
17
|
>`:l`<button type="button" @click=${this.handleButtonClick}>${i}${c}</button>`}
|
|
18
|
-
</div>`}};t.styles=[...v.styles,
|
|
18
|
+
</div>`}};t.styles=[...v.styles,C,g`
|
|
19
19
|
:host {
|
|
20
20
|
display: block;
|
|
21
21
|
}
|
|
@@ -144,8 +144,8 @@ var o=function(d,e,r,s){var p=arguments.length,n=p<3?e:s===null?s=Object.getOwnP
|
|
|
144
144
|
|
|
145
145
|
a:focus-visible,
|
|
146
146
|
button:focus-visible {
|
|
147
|
-
|
|
148
|
-
outline-
|
|
147
|
+
${f}
|
|
148
|
+
outline-color: var(--esp-color-link);
|
|
149
149
|
}
|
|
150
150
|
|
|
151
151
|
[part="menu-text"] {
|
|
@@ -276,4 +276,4 @@ var o=function(d,e,r,s){var p=arguments.length,n=p<3?e:s===null?s=Object.getOwnP
|
|
|
276
276
|
width: var(--esp-menu-item-icon-size, calc(1 * var(--esp-size-font)));
|
|
277
277
|
object-fit: contain;
|
|
278
278
|
}
|
|
279
|
-
`],o([a({type:String})],t.prototype,"label",void 0),o([a({type:String})],t.prototype,"url",void 0),o([a({type:String,reflect:!0})],t.prototype,"appearance",void 0),o([a({type:String})],t.prototype,"target",void 0),o([a({type:String})],t.prototype,"rel",void 0),o([a({type:String,attribute:"new-tab-label"})],t.prototype,"newTabLabel",void 0),o([a({type:String})],t.prototype,"icon",void 0),o([a({type:Boolean,attribute:"header-end",reflect:!0})],t.prototype,"headerEnd",void 0),o([u()],t.prototype,"promotedForHeader",void 0),o([a({attribute:!1,type:String})],t.prototype,"mode",void 0),o([a({attribute:!1,type:Number})],t.prototype,"depth",void 0),o([a({attribute:!1,type:Boolean})],t.prototype,"touchDevice",void 0),o([u()],t.prototype,"active",void 0),t=o([
|
|
279
|
+
`],o([a({type:String})],t.prototype,"label",void 0),o([a({type:String})],t.prototype,"url",void 0),o([a({type:String,reflect:!0})],t.prototype,"appearance",void 0),o([a({type:String})],t.prototype,"target",void 0),o([a({type:String})],t.prototype,"rel",void 0),o([a({type:String,attribute:"new-tab-label"})],t.prototype,"newTabLabel",void 0),o([a({type:String})],t.prototype,"icon",void 0),o([a({type:Boolean,attribute:"header-end",reflect:!0})],t.prototype,"headerEnd",void 0),o([u()],t.prototype,"promotedForHeader",void 0),o([a({attribute:!1,type:String})],t.prototype,"mode",void 0),o([a({attribute:!1,type:Number})],t.prototype,"depth",void 0),o([a({attribute:!1,type:Boolean})],t.prototype,"touchDevice",void 0),o([u()],t.prototype,"active",void 0),t=o([w("esp-menu-item")],t);export{t as EspalierMenuItem};
|
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;
|
|
@@ -148,6 +148,9 @@ var l=function(y,e,t,r){var n=arguments.length,s=n<3?e:r===null?r=Object.getOwnP
|
|
|
148
148
|
|
|
149
149
|
.scrim {
|
|
150
150
|
position: fixed;
|
|
151
|
+
|
|
152
|
+
width: auto;
|
|
153
|
+
height: auto;
|
|
151
154
|
top: var(--esp-menu-top-offset, 0px);
|
|
152
155
|
left: 0;
|
|
153
156
|
right: 0;
|
|
@@ -305,6 +308,10 @@ var l=function(y,e,t,r){var n=arguments.length,s=n<3?e:r===null?r=Object.getOwnP
|
|
|
305
308
|
text-decoration: none;
|
|
306
309
|
}
|
|
307
310
|
|
|
311
|
+
.drawer-brand a.configured-brand:focus-visible {
|
|
312
|
+
${_}
|
|
313
|
+
}
|
|
314
|
+
|
|
308
315
|
.drawer-brand .brand-logo {
|
|
309
316
|
width: auto;
|
|
310
317
|
height: var(--esp-menu-drawer-brand-logo-size, calc(3 * var(--esp-size-medium)));
|
|
@@ -328,8 +335,8 @@ var l=function(y,e,t,r){var n=arguments.length,s=n<3?e:r===null?r=Object.getOwnP
|
|
|
328
335
|
}
|
|
329
336
|
|
|
330
337
|
.drawer-close:focus-visible {
|
|
331
|
-
|
|
332
|
-
outline-
|
|
338
|
+
${H}
|
|
339
|
+
outline-color: var(--esp-color-link);
|
|
333
340
|
}
|
|
334
341
|
|
|
335
342
|
|
|
@@ -432,4 +439,4 @@ var l=function(y,e,t,r){var n=arguments.length,s=n<3?e:r===null?r=Object.getOwnP
|
|
|
432
439
|
transition: none;
|
|
433
440
|
}
|
|
434
441
|
}
|
|
435
|
-
`],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 +1 @@
|
|
|
1
|
-
const
|
|
1
|
+
import{CSS_NAMED_COLORS as w}from"./css-named-colors.js";const B=Math.PI/180,p=1e-4,W=50,d="[+-]?(?:\\d+|\\d*\\.\\d+)(?:[eE][+-]?\\d+)?",h="[\\t\\n\\f\\r ]",z=new RegExp(h+"*,"+h+"*"),Y=new RegExp(h+"+");function _(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},j=.4,q=new RegExp("^oklch\\("+h+"*("+d+")(%?)"+h+"+("+d+")(%?)"+h+"+("+d+")(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 K(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,u=r*r*r;return{r:4.0767416621*o-3.3077115913*c+.2309699292*u,g:-1.2684380046*o+2.6097574011*c-.3413193965*u,b:-.0041960863*o-.7034186147*c+1.707614701*u}}function S(t){return t<=.0031308?12.92*t:1.055*Math.pow(t,1/2.4)-.055}function J(t){return{r:S(t.r),g:S(t.g),b:S(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=_(t).match(q);if(!n)return null;let e=parseFloat(n[1]);n[2]==="%"&&(e/=100);let r=parseFloat(n[3]);n[4]==="%"&&(r=r/100*j);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 mt(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(K(k(t)))}function A(t){return Q(R(t))}function C(t){if(t.c<=p||A(t))return{...t};let n=0,e=t.c,r={...t};for(let o=0;o<W;o++){const c=(n+e)/2;if(r={l:t.l,c,h:t.h},A(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 C(r)}const b=.022,v=.012,F=.022,I=.57,y=.56,D=1.14,O=.001,L=.027;function N(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(C(t)),r=R(C(n));let o=N(e),c=N(r);if(o=o>b?o:o+Math.pow(b-o,1.414),c=c>b?c:c+Math.pow(b-c,1.414),Math.abs(c-o)<O)return 0;let u;if(c>o){const a=Math.pow(c,y),l=Math.pow(o,I);if(u=(a-l)*D,u<O)return 0;u=u<L?u-u*F*L:u-F}else{const a=Math.pow(c,y),l=Math.pow(o,I);if(u=(a-l)*D,u>-O)return 0;u=u>-L?u-u*v*L:u+v}return u*100}function nt(t,n,e=60){let r=C({...t}),o=Math.abs($(r,n));if(o>=e)return r;const c=n.l>.5,u=.01,a=c?0:1;for(let l=0;l<100;l++){if(c?r.l=Math.max(a,r.l-u):r.l=Math.min(a,r.l+u),r=C(r),o=Math.abs($(r,n)),o>=e)return r;if(r.l<=0||r.l>=1)break}return r}function Mt(t,n){return((t+n)%360+360)%360}function gt(t,n){const e=k(t),r=k(n),o=e.L-r.L,c=e.a-r.a,u=e.b-r.b;return Math.sqrt(o*o+c*c+u*u)}function rt(t,n,e,r){return tt({l:n,c:t.c,h:t.h},e,r)}function Ct(t,n,e,r,o,c=60,u){const a=rt(t,n,e,r);return u?.(a),nt(a,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 V(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 ut(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 at(t){const n=V(ct(t)),e=t.r===t.g&&t.g===t.b?{l:n.l,c:0,h:0}:n,r=ut(e);if(A(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 X(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=u=>{const a=e.slice(u*o,(u+1)*o);return parseInt(o===1?a.repeat(2):a,16)/255};return{space:"srgb",color:{r:c(0),g:c(1),b:c(2)},alpha:r===4||r===8?c(3):1}}function x(t,n,e){const r=t.match(new RegExp("^"+n+"\\("+h+"*([^)]*?)"+h+"*\\)$","i"));if(!r)return null;const o=r[1],c=o.includes(","),u=o.split("/");if(u.length>2||u.length===2&&(c||!e))return null;const l=_(u[0]).split(c?z:Y),i=c&&l.length===4&&e?l.pop():u[1];if(l.length!==3||l.some(g=>g.length===0))return null;const s=i===void 0?1:H(_(i));return s===null?null:{args:l,legacy:c,alpha:s}}const st=new RegExp("^("+d+")([a-z%]*)$","i");function T(t){const n=t.match(st);if(!n)return null;const e=parseFloat(n[1]);return isFinite(e)?{value:e,unit:n[2].toLowerCase()}:null}function H(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 U(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 u=(c+r/30)%12,a=n*Math.min(e,1-e);return e-a*Math.max(-1,Math.min(u-3,9-u,1))};return{r:o(0),g:o(8),b:o(4)}}const xt='"#rrggbb", "#rgb", "rgb(\u2026)", "hsl(\u2026)", "oklch(\u2026)"';function dt(t){const n=pt(t,!1);return n?n.space==="oklch"?n.color:at(n.color):null}function pt(t,n){const e=_(t);if(e.startsWith("#"))return X(e,n);if(/^oklch\(/i.test(e)){const r=n?x(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=x(e,"rgba?",n);if(!r)return null;const o=r.args.map(T);if(o.some(s=>s===null))return null;const c=o;if(r.legacy&&new Set(c.map(s=>s.unit)).size>1)return null;const u=c.map(lt);if(u.some(s=>s===null))return null;const[a,l,i]=u;return{space:"srgb",color:{r:a,g:l,b:i},alpha:r.alpha}}if(/^hsla?\(/i.test(e)){const r=x(e,"hsla?",n);if(!r)return null;const o=r.args.map(T);if(o.some(g=>g===null))return null;const[c,u,a]=o;if(r.legacy&&(u.unit!=="%"||a.unit!=="%"))return null;const l=it(c),i=U(u),s=U(a);return l===null||i===null||s===null?null:{space:"srgb",color:ht(l,i,s),alpha:r.alpha}}if(n){if(/^oklab\(/i.test(e)){const c=x(e,"oklab",!0);if(!c||c.legacy)return null;const u=c.args.map(s=>T(s.toLowerCase()==="none"?"0":s));if(u.some(s=>!s||s.unit!==""&&s.unit!=="%"))return null;const[a,l,i]=u.map((s,g)=>{const E=s;return E.unit!=="%"?E.value:E.value/100*(g===0?1:.4)});return{space:"oklch",color:V({L:f(a),a:l,b:i}),alpha:c.alpha}}const r=e.toLowerCase();if(Object.prototype.hasOwnProperty.call(w,r))return X(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=x(`color(${e.slice(o[0].length)}`,"color",!0);if(!c||c.legacy)return null;const u=c.args.map(H);if(u.some(s=>s===null))return null;const[a,l,i]=u;return{space:"srgb",color:{r:a,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{xt as ACCEPTED_COLOR_FORMS,$ as apcaContrast,f as clampChannel,tt as clampChromaAndGamutMap,gt as deltaEOK,rt as deriveSemantic,Ct as deriveSemanticWithContrast,nt as ensureContrast,G as gammaToLinear,C as gamutMapToSRGB,A as isInSRGBGamut,ot as linearRgbToOklab,V as oklabToOklch,k as oklchToOklab,R as oklchToSRGB,dt as parseCssColor,pt as parseCssColorValue,Z as parseOklch,Mt as rotateHue,mt as serializeOklch,et as srgbToLinearRGB,ct as srgbToOklab};
|
|
@@ -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};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{css as g,html as
|
|
1
|
+
import{css as g,html as n,nothing as c}from"lit";import{resolveConfiguredBrandColor as i}from"./configured-brand-color.js";function m({scheme:o,brandLogo:r,brandColor:e,lightBrandLogo:a,darkBrandLogo:t,lightBrandColor:d,darkBrandColor:s}){return{brandLogo:(o==="dark"?t:a)||r,brandColor:i(o==="dark"?s:d,e)}}const B=g`3 / 1`,C=g`
|
|
2
2
|
.brand-logo {
|
|
3
3
|
overflow-wrap: anywhere;
|
|
4
4
|
}
|
|
5
|
-
`;function
|
|
6
|
-
${o&&t?
|
|
7
|
-
${n
|
|
8
|
-
`;return
|
|
5
|
+
`;function $({brandLogo:o,brandText:r,brandHref:e,brandAlt:a,reserveLogoSpace:t=!1}){if(!o&&!r)return c;const s=o?n`<img class="brand-logo" src=${o} alt=${a||(r?"":"Site logo")} />`:c,l=n`
|
|
6
|
+
${o&&t?n`<span class="brand-logo-reservation">${s}</span>`:s}
|
|
7
|
+
${r?n`<span class="brand-text">${r}</span>`:c}
|
|
8
|
+
`;return e?n`<a class="configured-brand" href=${e}>${l}</a>`:n`<span class="configured-brand">${l}</span>`}export{B as CONFIGURED_BRAND_LOGO_ASPECT_RATIO,C as configuredBrandLogoGeometry,$ as renderConfiguredBrand,m as resolveConfiguredBrand};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=Object.freeze({aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"});export{e as CSS_NAMED_COLORS};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var c=function(f,e,t,r){var o=arguments.length,s=o<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(f,e,t,r);else for(var n=f.length-1;n>=0;n--)(a=f[n])&&(s=(o<3?a(s):o>3?a(e,t,s):a(e,t))||s);return o>3&&s&&Object.defineProperty(e,t,s),s};import{css as C,LitElement as S}from"lit";import{property as h,state as w}from"lit/decorators.js";import{subscribeToRootEvent as p}from"./root-event-subscription.js";import{traverseToClosest as b}from"./utilities.js";import{parseCssColor as P,serializeOklch as x,gamutMapToSRGB as E}from"./color-engine.js";import{computeVariants as m}from"../root/helpers/compute-variants.js";import{computeSemanticProperties as v}from"../root/helpers/compute-semantic-properties.js";import{DocumentSpriteController as V}from"./document-sprite.js";import{dataCompanionProperties as
|
|
1
|
+
var c=function(f,e,t,r){var o=arguments.length,s=o<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(f,e,t,r);else for(var n=f.length-1;n>=0;n--)(a=f[n])&&(s=(o<3?a(s):o>3?a(e,t,s):a(e,t))||s);return o>3&&s&&Object.defineProperty(e,t,s),s};import{css as C,LitElement as S}from"lit";import{property as h,state as w}from"lit/decorators.js";import{subscribeToRootEvent as p}from"./root-event-subscription.js";import{traverseToClosest as b}from"./utilities.js";import{parseCssColor as P,serializeOklch as x,gamutMapToSRGB as E}from"./color-engine.js";import{computeVariants as m}from"../root/helpers/compute-variants.js";import{computeSemanticProperties as v}from"../root/helpers/compute-semantic-properties.js";import{DocumentSpriteController as V}from"./document-sprite.js";import{dataCompanionProperties as _}from"../root/helpers/data-companion-properties.js";import{dataSeriesProperties as U}from"../root/helpers/compute-theme-properties.js";import{lightnessRampProperties as I}from"../root/helpers/lightness-ramp-properties.js";import{surfacePolarityProperty as A}from"../root/helpers/surface-polarity-property.js";import{ELEVATION_PROPERTIES as O,TYPE_ROLE_COLOR_PROPERTIES as D}from"./scale-engine.js";import{resolveContextTheme as y,resolveDataColorSource as z,semanticToCSS as N}from"./theme.js";import{alignAttributeTextInheritance as j,focusRing as F}from"./style-fragments.js";import{syncNormalizedAttribute as W}from"./attribute-helpers.js";import{INTENT_VARIANTS as k,normalizeIntentVariant as B}from"./intent-values.js";import{ESP_EVENTS as L}from"./events.js";import{surfaceLayerAttributes as T,surfaceLayerColor as q}from"./surface-layer.js";class i extends S{get seedColor(){return this.seedColorBacker}set seedColor(e){this.seedColorBacker=e}focusResolvedElementAfterUpdate(e,t){const r=()=>{const o=e();return o?(o.focus(t),!0):!1};r()||this.updateComplete.then(()=>{r()})}focusShadowElementAfterUpdate(e,t){this.focusResolvedElementAfterUpdate(()=>this.shadowRoot?.querySelector(e),t)}emitValueChanged(e){this.dispatchEvent(new CustomEvent(L.VALUE_CHANGED,{detail:e,bubbles:!0,composed:!0}))}get intent(){return this.intentBacker}set intent(e){const t=typeof e=="string"?e.trim():"";t!==""&&!k.includes(t)&&!this.warnedUnknownIntents.has(t)&&(this.warnedUnknownIntents.add(t),console.warn(`Espalier intent: "${t}" is not an intent; expected one of ${k.join(", ")}. Treating it as "neutral".`));const r=this.intentBacker,o=B(e);W(this,"intent",o),o!==r&&(this.intentBacker=o,this.requestUpdate("intent",r),this.applyTokensWhenRootReady())}get context(){return this.contextBacker}set context(e){const t=e??"";t!==this.contextBacker&&(this.contextBacker=t,this.applyTokensWhenRootReady(),this.refreshDescendantIntentDerivations())}refreshDescendantIntentDerivations(){const e=new Set,t=o=>{for(const s of Array.from(o.children))r(s)},r=o=>{if(!e.has(o)){if(e.add(o),o instanceof i&&o.applyTokensWhenRootReady(),o.shadowRoot&&t(o.shadowRoot),o instanceof HTMLSlotElement)for(const s of o.assignedElements({flatten:!0}))r(s);t(o)}};t(this),this.shadowRoot&&t(this.shadowRoot)}static flattenedParent(e){return e instanceof Element&&e.assignedSlot?e.assignedSlot:e instanceof ShadowRoot?e.host:e.parentNode}resolveAncestorZoneTheme(e){let t=i.flattenedParent(this);for(;t;){if(t instanceof Element&&t.localName==="esp-root")return null;if(t instanceof i){const r=t.contextBacker.trim();if(r){const o=this.resolveNamedContextTheme(e,r);if(o)return o}}t=i.flattenedParent(t)}return null}connectedCallback(){super.connectedCallback();const e=this.syncRootFromDom(!1);e&&this.subscribeToRootEvents(e)}disconnectedCallback(){super.disconnectedCallback(),this.unsubscribeFromRootEvents(),this.clearScopedTokens(),this.espRoot=null}firstUpdated(e){this.syncRootFromDom(!0),this.applyTokensWhenRootReady()}syncRootFromDom(e){const t=b(this,"esp-root");if(!t){if(this.espRoot&&this.clearScopedTokens(),this.unsubscribeFromRootEvents(),this.espRoot=null,!e)return null;throw new Error("No esp-root ancestor found. Espalier components must be placed inside an <esp-root> element.")}const r=t!==this.espRoot,s=t.scheme==="dark"?"dark":"light",a=this.scheme!==s,n=this.seedColor!==t.seedColor;return this.espRoot=t,r&&this.isConnected&&this.subscribeToRootEvents(t),(r||a||n)&&(this.scheme=s,this.seedColor=t.seedColor,this.applyTokensWhenRootReady()),r&&this.requestUpdate(),t}applyTokensWhenRootReady(){const e=this.espRoot;if(e&&(!e.hasUpdated||e.isUpdatePending)){this.applyTokensAfterInitialRootUpdate(e);return}this.applyScopedColorTokens()}applyTokensAfterInitialRootUpdate(e){if(this.pendingInitialThemeRoot===e)return;this.pendingInitialThemeRoot=e;const t=e.updateComplete;if(!t){this.pendingInitialThemeRoot=null,this.applyScopedColorTokens();return}t.then(()=>{this.pendingInitialThemeRoot===e&&(this.pendingInitialThemeRoot=null),!(!this.isConnected||this.espRoot!==e)&&(this.scheme=e.scheme==="dark"?"dark":"light",this.seedColor=e.seedColor,this.applyScopedColorTokens())})}subscribeToRootEvents(e){this.rootEventSubscriptionsActive&&this.subscribedRoot===e||(this.unsubscribeFromRootEvents(),this.subscribedRoot=e,this.rootEventUnsubscribers=[p(e,"seed-color-changed",this.handleSeedColorChanged),p(e,"scheme-changed",this.handleSchemeChanged),p(e,"theme-changed",this.handleThemeChanged),p(e,"icon-sprite-url-changed",this.handleIconSpriteUrlChanged)],this.rootEventSubscriptionsActive=!0)}unsubscribeFromRootEvents(){if(this.rootEventSubscriptionsActive){for(const e of this.rootEventUnsubscribers)e();this.rootEventUnsubscribers=[],this.subscribedRoot=null,this.rootEventSubscriptionsActive=!1}}constructor(){super(),this.seedColorBacker="oklch(0.7 0.125 216)",this.espRoot=null,this.contextBacker="",this.scopedTokenOriginalValues=new Map,this.warnedUnknownContexts=new Set,this.pendingInitialThemeRoot=null,this.rootEventSubscriptionsActive=!1,this.subscribedRoot=null,this.rootEventUnsubscribers=[],this.intentBacker="neutral",this.intentEmitsTokens=!0,this.warnedUnknownIntents=new Set,this.correlationId=globalThis.crypto?.randomUUID?.()??Math.random().toString(36),this.scheme="light",this.handleSeedColorChanged=e=>{this.syncRootFromDom(!1)&&(this.seedColor=e.seedColor,this.applyScopedColorTokens())},this.handleSchemeChanged=e=>{!this.syncRootFromDom(!1)||this.scheme===e.scheme||(this.scheme=e.scheme,this.applyScopedColorTokens())},this.handleThemeChanged=()=>{this.syncRootFromDom(!1)&&this.applyScopedColorTokens()},this.handleIconSpriteUrlChanged=()=>{this.syncRootFromDom(!1)&&this.requestUpdate()},new V(this,{reactToSpriteChanges:!1})}traverseToClosest(e){return b(this,e)}applyScopedColorTokens(){if(!this.espRoot)return;const e=this.intentEmitsTokens?i.intentColorSources[this.intentBacker]:"";if(!e&&!this.context.trim()){this.clearScopedTokens();return}const t=this.espRoot.activeTheme;if(!t){this.clearScopedTokens();return}const r=this.resolveContextTheme(t),o=r.theme,s=P(o.seedColor);if(!s)return;const a=m(s,o),n={};if(r.applied&&(Object.assign(n,v(o,a)),n["--_esp-context-shadow"]="var(--esp-color-shadow)",Object.assign(n,A(n)),Object.assign(n,I(o)),Object.assign(n,O),Object.assign(n,D),Object.assign(n,_(n,U(o,s,l=>(typeof l=="string"?z(l,o.anchors):null)??o.seedColor)))),e){let l=o;r.applied||(l=this.resolveAncestorZoneTheme(t)??o);const g=l===o?a:m(s,l),R=v(l,g,{effectiveSource:(u,d)=>i.semanticActionTokens.has(u)?e:d});n["--esp-color-primary"]=x(E(g[e]));for(const u of i.semanticActionTokens){const d=N(u);n[d]=R[d]}}this.applyScopedTokenProperties(n)}resolveContextTheme(e){const t=this.context.trim();if(!t)return{applied:!1,theme:e};const r=this.resolveNamedContextTheme(e,t);return r?{applied:!0,theme:r}:(this.warnUnknownContextWhenSettled(t),{applied:!1,theme:e})}warnUnknownContextWhenSettled(e){if(this.warnedUnknownContexts.has(e))return;const t=this.espRoot;if(t&&!t.themeSettled){t.whenThemeSettled().then(()=>{if(!this.isConnected||this.espRoot!==t||this.context.trim()!==e)return;const r=t.activeTheme;r&&y(r,e)||this.warnUnknownContextWhenSettled(e)});return}this.warnedUnknownContexts.add(e),console.warn(`Espalier context: "${e}" is not defined by the active theme; inheriting root tokens.`)}resolveNamedContextTheme(e,t){return y(e,t)}applyScopedTokenProperties(e){for(const t of this.scopedTokenOriginalValues.keys())t in e||this.restoreScopedTokenProperty(t);for(const[t,r]of Object.entries(e))this.setScopedTokenProperty(t,r)}setScopedTokenProperty(e,t){const r=this.scopedTokenOriginalValues.get(e);if(r){const o=this.style.getPropertyValue(e),s=this.style.getPropertyPriority(e);(o!==r.generatedValue||s!==r.generatedPriority)&&(r.originalValue=o.length?o:null,r.originalPriority=s),r.generatedValue=t,r.generatedPriority=""}else{const o=this.style.getPropertyValue(e);this.scopedTokenOriginalValues.set(e,{generatedPriority:"",generatedValue:t,originalPriority:this.style.getPropertyPriority(e),originalValue:o.length?o:null})}this.style.setProperty(e,t)}restoreScopedTokenProperty(e){const t=this.scopedTokenOriginalValues.get(e);if(!t)return;const r=this.style.getPropertyValue(e),o=this.style.getPropertyPriority(e);(r!==t.generatedValue||o!==t.generatedPriority)&&(t.originalValue=r.length?r:null,t.originalPriority=o),t.originalValue===null?this.style.removeProperty(e):this.style.setProperty(e,t.originalValue,t.originalPriority),this.scopedTokenOriginalValues.delete(e)}clearScopedTokens(){for(const e of[...this.scopedTokenOriginalValues.keys()])this.restoreScopedTokenProperty(e)}}i.intentColorSources={danger:"danger",info:"info",neutral:"",success:"success",warning:"warning"},i.semanticActionTokens=new Set(["actionBackground","actionText"]),i.styles=[T(":host"),T("[surface-layer]"),F(".esp-field:focus-within","--esp-field-focus-shadow"),j,C`
|
|
2
2
|
:host {
|
|
3
3
|
|
|
4
4
|
--_esp-font-body-fallback: system-ui, sans-serif;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type PaintColor } from "./paint-color.js";
|
|
2
|
+
import type { PaintColorEnvironment, PaintDerivation, PaintDerivations, PaintEntriesByRole, PaintEntry, PaintKind, PaintNavigationFact, PaintRegistration, PaintSchemeFeatures, PaintTarget, PaintTargetsByRole } from "./paint-types.js";
|
|
3
|
+
export declare const PAINT_TOKEN_IDS: readonly string[];
|
|
4
|
+
export declare const BRAND_PAINT_ID = "brand-color";
|
|
5
|
+
export declare function paintTokenProperty(identifier: string): string | undefined;
|
|
6
|
+
export declare function isPaintName(value: unknown): value is string;
|
|
7
|
+
export declare function isPaintRole(value: unknown): value is string;
|
|
8
|
+
export declare function isPaintKind(value: unknown): value is PaintKind;
|
|
9
|
+
export declare function isPaintFlags(value: unknown): value is readonly string[];
|
|
10
|
+
export declare function isPaintNavigationFact(value: unknown): value is PaintNavigationFact;
|
|
11
|
+
export declare function validatePaintEntries(entriesByRole: unknown, derivations?: PaintDerivations): asserts entriesByRole is PaintEntriesByRole;
|
|
12
|
+
interface PaintCatalog {
|
|
13
|
+
entriesByRole: PaintEntriesByRole;
|
|
14
|
+
targets: PaintTargetsByRole;
|
|
15
|
+
derivations: PaintDerivations;
|
|
16
|
+
}
|
|
17
|
+
/** Assemble component registrations without giving any role special treatment. */
|
|
18
|
+
export declare function createPaintCatalog(registrations: readonly PaintRegistration[]): PaintCatalog;
|
|
19
|
+
export declare const PAINT_CATALOG: Readonly<Record<string, readonly PaintEntry[]>>;
|
|
20
|
+
export declare const PAINT_TARGETS: Readonly<Record<string, readonly PaintTarget[]>>;
|
|
21
|
+
export declare const PAINT_DERIVATIONS: Readonly<Record<string, PaintDerivation>>;
|
|
22
|
+
/** Select rendered entries and resolve brand ink using the active scheme's configured override. */
|
|
23
|
+
export declare function enabledPaintEntries(role: string, features: PaintSchemeFeatures, entriesByRole?: PaintEntriesByRole, { brandColor }?: {
|
|
24
|
+
brandColor?: string;
|
|
25
|
+
}): readonly PaintEntry[];
|
|
26
|
+
export declare function resolvePaintColor(identifier: string, environment: PaintColorEnvironment, derivations?: PaintDerivations): PaintColor | null;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{buttonPaintRegistration as y}from"../button/paint-registration.js";import{footerPaintRegistration as w}from"../footer/paint-registration.js";import{headerPaintRegistration as T}from"../header/paint-registration.js";import{menuPaintRegistration as j}from"../menu/paint-registration.js";import{resolveConfiguredBrandColor as v}from"./configured-brand-color.js";import{parsePaintColor as x}from"./paint-color.js";import{COLOR_SOURCES as A,SEMANTIC_COLOR_NAMES as E,isObjectRecord as p,semanticToCSS as R}from"./theme.js";const u=new Map([...E.map(t=>[t,R(t)]),...A.map(t=>[t,`--esp-color-${t}`])]),U=Object.freeze([...u.keys()]),l="brand-color";function f(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function V(t){return u.get(t)}function c(t){return typeof t=="string"&&t.trim()!==""}function N(t){return c(t)&&t===t.trim()}function C(t){return t==="text"||t==="graphic"||t==="ring"}function $(t){return Array.isArray(t)&&Array.from(t).every(c)}const g={depth:t=>t==="top-level"||t==="nested",kind:t=>t==="button"||t==="plain"||t==="group",anchor:t=>typeof t=="boolean",canBeCurrent:t=>typeof t=="boolean",icon:t=>t===void 0||typeof t=="boolean"};function H(t){return p(t)&&Object.entries(g).every(([e,n])=>n(t[e]))}const k={element:!0,foreground:!0,background:!0,state:!0,kind:!0,flags:!0,navigation:!0,indicator:!0,paintOpacity:!0};function S(t){return p(t)&&Object.entries(t).every(([e,n])=>f(g,e)&&g[e](n))}function I(t,e,n){if(!p(t)||!Object.keys(t).every(o=>f(k,o))||!c(t.element)||!c(t.state)||!C(t.kind)||!$(t.flags))throw new TypeError(`${e} is not a paint entry.`);for(const o of["foreground","background"]){const r=t[o];if(!c(r)||!(u.has(r)||f(n,r)||o==="foreground"&&r===l))throw new TypeError(`${e} has an unknown ${o} paint identifier "${String(r)}".`)}if(t.paintOpacity!==void 0&&(typeof t.paintOpacity!="number"||!Number.isFinite(t.paintOpacity)||t.paintOpacity<0||t.paintOpacity>1))throw new TypeError(`${e} has an invalid paint opacity.`);if(t.navigation!==void 0&&!S(t.navigation))throw new TypeError(`${e} has an invalid navigation predicate.`);if(t.indicator!==void 0&&(t.indicator!=="blurred-shadow"||t.kind==="text"))throw new TypeError(`${e} has an invalid indicator.`)}function _(t,e=O){if(!p(t))throw new TypeError("Paint entries must be grouped by role.");for(const[n,o]of Object.entries(t)){if(!N(n)||!Array.isArray(o))throw new TypeError(`Paint entries for role "${n}" must be an array on a nonempty role without outer whitespace.`);for(let r=0;r<o.length;r+=1)I(o[r],`Paint entry for "${n}" at index ${r}`,e)}}function z(t){const e=Object.create(null),n=Object.create(null),o=Object.create(null);for(const r of t)for(const[i,a]of Object.entries(r.derivations??{})){if(!c(i)||i===l||u.has(i)||i in o)throw new TypeError(`Paint derivation "${i}" must have a unique identifier.`);o[i]=a}for(const r of t){_(r.entriesByRole,o);for(const[i,a]of Object.entries(r.entriesByRole))(e[i]??=[]).push(...a);for(const[i,a]of Object.entries(r.targets))(n[i]??=[]).push(...a)}for(const r of Object.values(e))Object.freeze(r);for(const r of Object.values(n))Object.freeze(r);return{entriesByRole:Object.freeze(e),targets:Object.freeze(n),derivations:Object.freeze(o)}}const b=z([T,w,j,y]),B=b.entriesByRole,J=b.targets,O=b.derivations;function Q(t,e,n=B,{brandColor:o}={}){const r=f(n,t)?n[t]:[],i=new Set(e.flags),a=r.filter(s=>{if(!s.flags.every(d=>i.has(d)))return!1;if(s.navigation===void 0)return!0;const m=Object.entries(s.navigation);return e.navigation.some(d=>m.every(([P,h])=>d[P]===h))});return v(o)?a:a.map(s=>s.foreground===l?{...s,foreground:"headings"}:s)}function W(t,e,n=O){if(f(n,t))return n[t](e);const o=e.readColor(t);return o?x(o):null}export{l as BRAND_PAINT_ID,B as PAINT_CATALOG,O as PAINT_DERIVATIONS,J as PAINT_TARGETS,U as PAINT_TOKEN_IDS,z as createPaintCatalog,Q as enabledPaintEntries,$ as isPaintFlags,C as isPaintKind,c as isPaintName,H as isPaintNavigationFact,N as isPaintRole,V as paintTokenProperty,W as resolvePaintColor,_ as validatePaintEntries};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { PaintKind } from "./paint-types.js";
|
|
2
|
+
/** Gamma-encoded sRGB and alpha, with all channels in 0–1. */
|
|
3
|
+
export interface PaintColor {
|
|
4
|
+
r: number;
|
|
5
|
+
g: number;
|
|
6
|
+
b: number;
|
|
7
|
+
alpha: number;
|
|
8
|
+
}
|
|
9
|
+
/** Parse absolute CSS paint, retaining its declared alpha. */
|
|
10
|
+
export declare function parsePaintColor(value: string): PaintColor | null;
|
|
11
|
+
/** Change the lightness channel of a relative OKLCH color. */
|
|
12
|
+
export declare function derivePaintLightness(value: string | undefined, lightness: (original: number) => number): PaintColor | null;
|
|
13
|
+
/** Composite foreground over background using CSS source-over alpha. */
|
|
14
|
+
export declare function compositePaint(foreground: PaintColor, background: PaintColor): PaintColor;
|
|
15
|
+
export declare const MIN_SHADOW_INDICATOR_BLUR = 3;
|
|
16
|
+
export declare const MAX_SHADOW_INDICATOR_BLUR = 4;
|
|
17
|
+
export declare const SHADOW_INDICATOR_SAMPLE_OFFSET = 0.1;
|
|
18
|
+
export declare const SHADOW_INDICATOR_MARGIN_SIGMAS = 4;
|
|
19
|
+
export declare function supportsShadowIndicatorBlur(blur: number): boolean;
|
|
20
|
+
/** Lower coverage estimate at the supported straight edge. Hard bands use full alpha. */
|
|
21
|
+
export declare function shadowIndicatorAlpha(shadow: {
|
|
22
|
+
alpha: number;
|
|
23
|
+
blur: number;
|
|
24
|
+
}): number;
|
|
25
|
+
export declare function paintRequiredRatio(kind: PaintKind): 3 | 4.5;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{clampChannel as l,gamutMapToSRGB as n,oklabToOklch as A,oklchToSRGB as e,parseCssColorValue as c,srgbToOklab as _}from"./color-engine.js";import{AA_NON_TEXT_RATIO as I,AA_TEXT_RATIO as O}from"./wcag-contrast.js";function b(t){const a=c(t,!0);if(!a)return null;const r=a.space==="oklch"?e(n(a.color)):a.color;return{r:l(r.r),g:l(r.g),b:l(r.b),alpha:a.alpha}}function M(t,a){const r=t&&c(t,!0);if(!r)return null;const p=r.space==="oklch"?r.color:A(_(r.color)),o=e(n({...p,l:l(a(p.l))}));return{r:l(o.r),g:l(o.g),b:l(o.b),alpha:r.alpha}}function C(t,a){if(t.alpha===0)return a;if(t.alpha===1||a.alpha===0)return t;const r=a.alpha*(1-t.alpha),p=t.alpha+r;return{r:(t.r*t.alpha+a.r*r)/p,g:(t.g*t.alpha+a.g*r)/p,b:(t.b*t.alpha+a.b*r)/p,alpha:p}}const s=3,R=4,T=.1,h=4;function u(t){return t>=s&&t<=R}const i=1/Math.sqrt(2*Math.PI),x=i*Math.exp(-(h**2)/2)/h,S=.5-T/(s/2)*i-3*x-.05;function E(t){if(t.blur===0)return t.alpha;if(!u(t.blur))throw new RangeError(`Unsupported shadow indicator blur ${t.blur}px. Expected 3\u20134px.`);return t.alpha*S}function m(t){return t==="text"?O:I}export{R as MAX_SHADOW_INDICATOR_BLUR,s as MIN_SHADOW_INDICATOR_BLUR,h as SHADOW_INDICATOR_MARGIN_SIGMAS,T as SHADOW_INDICATOR_SAMPLE_OFFSET,C as compositePaint,M as derivePaintLightness,m as paintRequiredRatio,b as parsePaintColor,E as shadowIndicatorAlpha,u as supportsShadowIndicatorBlur};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{resolveConfiguredBrandColor as k}from"./configured-brand-color.js";import{BRAND_PAINT_ID as B,PAINT_CATALOG as q,PAINT_DERIVATIONS as D,enabledPaintEntries as v,isPaintFlags as x,isPaintName as j,isPaintNavigationFact as M,isPaintRole as F,paintTokenProperty as L,resolvePaintColor as R,validatePaintEntries as W}from"./paint-catalog.js";import{compositePaint as H,MIN_SHADOW_INDICATOR_BLUR as G,paintRequiredRatio as U,shadowIndicatorAlpha as V}from"./paint-color.js";import{firstPaintByIdentity as z,paintIdentity as J}from"./paint-identity.js";import{SEMANTIC_COLOR_NAMES as K,isObjectRecord as p,semanticToCSS as S}from"./theme.js";import{wcagRatio as Q}from"./wcag-contrast.js";const X=["light","dark"],Y=new Set(K.map(S));function Z(t){return p(t)&&x(t.flags)&&Array.isArray(t.navigation)&&Array.from(t.navigation).every(M)}function rr(t){if(!Array.isArray(t))throw new TypeError("Paint surfaces must be an array.");const o=new Set;for(const a of t){if(!p(a)||!F(a.role))throw new TypeError("Each paint surface requires a nonempty role without outer whitespace.");const{role:e,context:l,brandColors:s,features:i}=a;if(o.has(e))throw new TypeError(`Duplicate paint surface role "${e}".`);if(o.add(e),l!=null&&!j(l))throw new TypeError(`Paint surface "${e}" has an invalid context.`);if(s!==void 0&&(!p(s)||Object.entries(s).some(([r,c])=>!["light","dark","generic"].includes(r)||c!==void 0&&typeof c!="string")))throw new TypeError(`Paint surface "${e}" has invalid brand colors.`);if(!p(i)||!X.every(r=>Z(i[r])))throw new TypeError(`Paint surface "${e}" requires light and dark feature facts.`)}}function tr(t,o,a,e,l,s){const{role:i}=t,r=t.context??null,c=a.get(null),h=a.get(r);if(!c||!h)throw new Error(`Paint surface "${i}" requests undefined ${o} context "${r}".`);const u=k(t.brandColors?.[o],t.brandColors?.generic),w=n=>n==="--_esp-context-shadow"?r===null?void 0:h[S("shadow")]:Y.has(n)||n.startsWith("--esp-l-")||n==="--_esp-surface-polarity"?h[n]:c[n],g={scheme:o,context:r,readProperty:w,readColor:n=>{if(n===B)return u?.startsWith("--esp-color-")?w(u):u;const d=L(n);return d&&w(d)}},A=t.features[o],T={brandColor:u},$=[...v(i,A,e.entriesByRole,T),...v(i,A,l,T)],I=[...z($).values()].map(n=>{const{element:d,foreground:P,background:m,kind:C,state:E}=n,y=R(P,g,e.derivations),f=R(m,g,e.derivations);if(!y||!f||f.alpha!==1)throw new Error(`Paint surface "${i}" (${o}) cannot resolve "${d}" ${E}: ${P} on opaque ${m}.`);const N=y.alpha*(n.paintOpacity??1),O=V({alpha:N,blur:n.indicator==="blurred-shadow"?G:0}),_=H({...y,alpha:O},f),b={element:d,foreground:P,background:m,state:E,kind:C,ratio:Q(_,f),required:U(C)};return s?.(o,J({role:i,...n}),b),b});return{role:i,context:r,pairs:I}}function cr(t,o,a={},e={entriesByRole:q,derivations:D},l){rr(o),W(a,e.derivations);const s=new Set([...Object.entries(e.entriesByRole),...Object.entries(a)].filter(([,r])=>r.length>0).map(([r])=>r));for(const{role:r}of o)if(!s.has(r))throw new TypeError(`Paint surface "${r}" has no registered paint entries.`);const i=r=>o.map(c=>tr(c,r,t[r],e,a,l));return{light:i("light"),dark:i("dark")}}export{cr as measurePaintSurfaces};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function i(t){return JSON.stringify([t.role,t.element,t.state,t.kind,t.foreground,t.background,t.indicator,t.paintOpacity??1])}function d(t){const n=new Map;for(const e of t){const o=i(e);n.has(o)||n.set(o,e)}return n}export{d as firstPaintByIdentity,i as paintIdentity};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { PaintColor } from "./paint-color.js";
|
|
2
|
+
export type PaintScheme = "light" | "dark";
|
|
3
|
+
export type PaintKind = "text" | "graphic" | "ring";
|
|
4
|
+
export interface PaintNavigationFact {
|
|
5
|
+
depth: "top-level" | "nested";
|
|
6
|
+
kind: "button" | "plain" | "group";
|
|
7
|
+
anchor: boolean;
|
|
8
|
+
canBeCurrent: boolean;
|
|
9
|
+
icon?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface PaintSchemeFeatures {
|
|
12
|
+
flags: readonly string[];
|
|
13
|
+
navigation: readonly PaintNavigationFact[];
|
|
14
|
+
}
|
|
15
|
+
export interface PaintEntry {
|
|
16
|
+
element: string;
|
|
17
|
+
foreground: string;
|
|
18
|
+
background: string;
|
|
19
|
+
state: string;
|
|
20
|
+
kind: PaintKind;
|
|
21
|
+
flags: readonly string[];
|
|
22
|
+
navigation?: Partial<PaintNavigationFact>;
|
|
23
|
+
indicator?: "blurred-shadow";
|
|
24
|
+
/** Paint coverage applied outside the declared color, such as SVG stroke-opacity. Defaults to 1. */
|
|
25
|
+
paintOpacity?: number;
|
|
26
|
+
}
|
|
27
|
+
export interface PaintFitSurface {
|
|
28
|
+
role: string;
|
|
29
|
+
/** A null or omitted context selects the root theme. */
|
|
30
|
+
context?: string | null;
|
|
31
|
+
brandColors?: {
|
|
32
|
+
light?: string;
|
|
33
|
+
dark?: string;
|
|
34
|
+
generic?: string;
|
|
35
|
+
};
|
|
36
|
+
features: Record<PaintScheme, PaintSchemeFeatures>;
|
|
37
|
+
}
|
|
38
|
+
export interface PaintFitPair {
|
|
39
|
+
element: string;
|
|
40
|
+
foreground: string;
|
|
41
|
+
background: string;
|
|
42
|
+
state: string;
|
|
43
|
+
kind: PaintKind;
|
|
44
|
+
ratio: number;
|
|
45
|
+
required: 3 | 4.5;
|
|
46
|
+
}
|
|
47
|
+
export interface PaintFitSurfaceReport {
|
|
48
|
+
role: string;
|
|
49
|
+
context: string | null;
|
|
50
|
+
pairs: PaintFitPair[];
|
|
51
|
+
}
|
|
52
|
+
export type PaintFitReport = Record<PaintScheme, PaintFitSurfaceReport[]>;
|
|
53
|
+
export interface PaintColorEnvironment {
|
|
54
|
+
scheme: PaintScheme;
|
|
55
|
+
context: string | null;
|
|
56
|
+
readColor(identifier: string): string | undefined;
|
|
57
|
+
readProperty(property: string): string | undefined;
|
|
58
|
+
}
|
|
59
|
+
export type PaintDerivation = (environment: PaintColorEnvironment) => PaintColor | null;
|
|
60
|
+
export type PaintInteraction = "rest" | "hover" | "focus" | "hover-focus";
|
|
61
|
+
export interface PaintCandidate {
|
|
62
|
+
element: Element;
|
|
63
|
+
kind: PaintKind;
|
|
64
|
+
source: "text" | "fill" | "stroke" | "shape" | "outline" | "shadow";
|
|
65
|
+
text?: Text;
|
|
66
|
+
indicator?: "blurred-shadow";
|
|
67
|
+
}
|
|
68
|
+
export interface PaintAttribution {
|
|
69
|
+
element: string;
|
|
70
|
+
owner: Element;
|
|
71
|
+
state?: (interaction: PaintInteraction) => string;
|
|
72
|
+
brandColor?: string;
|
|
73
|
+
foregroundDerivations?: readonly string[];
|
|
74
|
+
backgroundDerivations?: readonly string[];
|
|
75
|
+
/** Semantic identifiers that are equivalent to a named foreground derivation here. */
|
|
76
|
+
foregroundAliases?: readonly string[];
|
|
77
|
+
/** Semantic identifiers that are equivalent to a named background derivation here. */
|
|
78
|
+
backgroundAliases?: readonly string[];
|
|
79
|
+
}
|
|
80
|
+
export type PaintTarget = (candidate: PaintCandidate) => PaintAttribution | undefined;
|
|
81
|
+
export type PaintEntriesByRole = Readonly<Record<string, readonly PaintEntry[]>>;
|
|
82
|
+
export type PaintTargetsByRole = Readonly<Record<string, readonly PaintTarget[]>>;
|
|
83
|
+
export type PaintDerivations = Readonly<Record<string, PaintDerivation>>;
|
|
84
|
+
export interface PaintRegistration {
|
|
85
|
+
entriesByRole: PaintEntriesByRole;
|
|
86
|
+
targets: PaintTargetsByRole;
|
|
87
|
+
derivations?: PaintDerivations;
|
|
88
|
+
}
|
|
File without changes
|