@taprootio/espalier 4.5.0 → 4.7.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 +7248 -5653
- package/dist/date-picker/esp-date-picker.js +17 -17
- package/dist/flyout/esp-flyout.d.ts +4 -4
- package/dist/flyout/esp-flyout.js +14 -27
- package/dist/form-item/esp-form-item.d.ts +11 -0
- package/dist/form-item/esp-form-item.js +11 -11
- package/dist/header/esp-header.d.ts +4 -1
- package/dist/header/esp-header.js +56 -11
- package/dist/menu/esp-menu-group.d.ts +7 -0
- package/dist/menu/esp-menu-group.js +46 -11
- package/dist/menu/esp-menu-item.d.ts +7 -0
- package/dist/menu/esp-menu-item.js +49 -9
- package/dist/menu/esp-menu.d.ts +74 -0
- package/dist/menu/esp-menu.js +179 -18
- package/dist/menu/swipe-reveal-controller.js +1 -1
- package/dist/page/esp-page.js +1 -1
- package/dist/page/esp-page.styles.js +4 -4
- package/dist/pickers/esp-pick-one.js +14 -11
- package/dist/pickers/esp-pick-some.js +12 -9
- package/dist/pickers/esp-picker-base.d.ts +11 -2
- package/dist/pickers/esp-picker-base.js +82 -26
- package/dist/pickers/esp-picker-menu.d.ts +10 -1
- package/dist/pickers/esp-picker-menu.js +53 -18
- package/dist/root/esp-root.d.ts +2 -0
- package/dist/root/esp-root.js +2 -2
- package/dist/root/helpers/compute-theme-properties.js +1 -1
- package/dist/shared/aria-describedby.js +1 -0
- package/dist/shared/configured-brand.d.ts +33 -0
- package/dist/shared/events.d.ts +4 -0
- package/dist/shared/events.js +1 -1
- package/dist/shared/font-plan.d.ts +13 -3
- package/dist/shared/font-plan.js +5 -5
- package/dist/shared/form-field-description-controller.js +1 -1
- package/dist/shared/overlay-controller.js +1 -1
- package/dist/shared/popover-controller.js +1 -1
- package/dist/shared/responsive.js +1 -0
- package/dist/shared/style-fragments.js +24 -8
- package/dist/shared/theme.d.ts +18 -0
- package/dist/shared/theme.js +1 -1
- package/dist/shared/viewport.d.ts +2 -1
- package/dist/shared/viewport.js +1 -1
- package/dist/tooltip/esp-tooltip.js +3 -3
- package/espalier.css-data.json +52 -0
- package/espalier.token-manifest.json +76 -0
- package/package.json +1 -1
package/dist/root/esp-root.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var r=function(c,e,t,s){var n=arguments.length,i=n<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,t):s,m;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(c,e,t,s);else for(var
|
|
1
|
+
var r=function(c,e,t,s){var n=arguments.length,i=n<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,t):s,m;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(c,e,t,s);else for(var l=c.length-1;l>=0;l--)(m=c[l])&&(i=(n<3?m(i):n>3?m(e,t,i):m(e,t))||i);return n>3&&i&&Object.defineProperty(e,t,i),i},a;import{css as b,html as w,LitElement as E}from"lit";import{customElement as C,property as h,state as R}from"lit/decorators.js";import{getEspBus as d}from"../shared/bus-events.js";import{subscribeToRootEvent as x}from"../shared/root-event-subscription.js";import{DEFAULT_LIGHT_THEME as f,DEFAULT_DARK_THEME as g,encodeTheme as y,parseTheme as u,mergeTheme as v}from"../shared/theme.js";import{extractFamily as p,isLocalFontFamily as L,removeRuntimeGoogleFontLinks as S,syncRuntimeGoogleFontLink as A}from"../shared/font-helpers.js";import{computeThemeProperties as D}from"./helpers/compute-theme-properties.js";import{registerImageTexture as I,registeredImageTextures as F}from"../shared/image-texture-registry.js";import{registerImageTexture as $,registeredImageTextures as Q,BUILT_IN_IMAGE_TEXTURES as q}from"../shared/image-texture-registry.js";const T=1e3;let o=a=class extends E{constructor(){super(...arguments),this.schemeBacker="",this.schemeExplicitlySet=!1,this.resolvingDefaultScheme=!1,this.themeEventsReady=!1,this.systemSchemeQuery=null,this.lastSeedColor="",this.resolvedLightTheme={...f},this.resolvedDarkTheme={...g},this.appliedThemeProperties=new Set,this.documentClickRegistrationActive=!1,this.correlationId=globalThis.crypto?.randomUUID?.()??Math.random().toString(36),this.lightThemeAttr="",this.darkThemeAttr="",this.fontCSSRoot="/css/fonts/",this.fontDefinitionsUrl="",this.googleFontLoading="auto",this.iconSpriteUrl="/assets/icons.svg",this.themePending=!1,this.themeReadyState=!1,this.themeSettleWaiters=[],this.warnedThemeSettleTimeout=!1,this.defaultScheme="light",this.resizeObserver=new ResizeObserver(()=>{d().publish("window-resized",{emWidth:window.innerWidth/parseFloat(getComputedStyle(document.documentElement).fontSize),emHeight:window.innerHeight/parseFloat(getComputedStyle(document.documentElement).fontSize),pxWidth:window.innerWidth,pxHeight:window.innerHeight})}),this.handleSystemSchemeChange=e=>{this.schemeExplicitlySet||this.defaultScheme!=="system"||(this.resolvingDefaultScheme=!0,this.scheme=e.matches?"dark":"light",this.resolvingDefaultScheme=!1)}}static registerTexture(e,t){I(e,t)}static registeredTextures(){return F()}subscribeScoped(e,t){return x(this,e,t)}get lightTheme(){return this.lightThemeAttr?u(this.lightThemeAttr):null}set lightTheme(e){this.lightThemeAttr=e?y(e):""}get darkTheme(){return this.darkThemeAttr?u(this.darkThemeAttr):null}set darkTheme(e){this.darkThemeAttr=e?y(e):""}get themeSettled(){return this.themeReadyState}whenThemeSettled(){return this.themeReadyState?Promise.resolve():new Promise(e=>{this.themeSettleWaiters.push(e)})}get hasAuthorTheme(){return!!(this.scheme==="dark"?this.darkThemeAttr:this.lightThemeAttr)}settleTheme(){if(this.themeSettleTimer!==void 0&&(clearTimeout(this.themeSettleTimer),this.themeSettleTimer=void 0),this.themeReadyState)return;this.themeReadyState=!0;const e=this.themeSettleWaiters;this.themeSettleWaiters=[];for(const t of e)t()}get scheme(){return this.schemeBacker}set scheme(e){const t=e==="dark"?"dark":e==="light"?"light":"",s=this.schemeBacker,n=this.schemeExplicitlySet;this.resolvingDefaultScheme||(this.schemeExplicitlySet=t.length>0);const i=t||this.resolveDefaultScheme();n!==this.schemeExplicitlySet&&this.isConnected&&this.syncSystemSchemeListener(),i!==s&&(this.schemeBacker=i,this.requestUpdate("scheme",s),this.themeEventsReady&&d().publish("scheme-changed",{scheme:i,correlationId:this.correlationId}))}get seedColor(){return this.activeTheme.seedColor}injectGoogleFontLink(e,t,s){const n=`${this.correlationId}-${e}`,i=L(t)?"":t;A({owner:`root:${n}`,family:i,weight:s,enabled:this.googleFontLoading!=="none",attributes:{"data-esp-font":n}})}syncGoogleFontLinks(){this.googleFontLoading==="none"&&this.removeRuntimeGoogleFontLinks();const e=this.activeTheme;this.injectGoogleFontLink("body",p(e.fontBody),e.fontWeightBody),this.injectGoogleFontLink("headings",p(e.fontHeadings),e.fontWeightHeadings),this.injectGoogleFontLink("brand",p(e.fontBrand),e.fontWeightBrand),this.injectGoogleFontLink("menu",p(e.fontMenu),e.fontWeightMenu),this.injectGoogleFontLink("monospace",p(e.fontMonospace),e.fontWeightMonospace)}removeRuntimeGoogleFontLinks(){S(`root:${this.correlationId}-`),S(`picker:${this.correlationId}:`);for(const e of document.head.querySelectorAll(`link[data-esp-font^="${this.correlationId}-"]`))e.remove();for(const e of document.head.querySelectorAll(`link[data-esp-font-picker-root="${CSS.escape(this.correlationId)}"]`))e.remove()}get activeTheme(){return this.scheme==="dark"?this.resolvedDarkTheme:this.resolvedLightTheme}resolveThemes(){const e=this.lightThemeAttr?u(this.lightThemeAttr):null;this.resolvedLightTheme=e?v(f,e):{...f};const t=this.darkThemeAttr?u(this.darkThemeAttr):null;this.resolvedDarkTheme=t?v(g,t):{...g}}connectedCallback(){super.connectedCallback(),this.registerDocumentClickBridge(),this.resizeObserver.observe(this),this.hasUpdated&&(this.applyDefaultScheme(),this.syncGoogleFontLinks(),this.hasAuthorTheme||this.startThemeSettleTimer())}willUpdate(e){const t=["lightThemeAttr","darkThemeAttr"];(!this.lastSeedColor||t.some(l=>e.has(l)))&&(this.resolveThemes(),this.themeEventsReady&&d().publish("theme-changed",{correlationId:this.correlationId})),this.hasAuthorTheme&&this.settleTheme();const n=D(this.activeTheme,this.scheme==="dark"?"dark":"light"),i=new Set(Object.keys(n));for(const l of this.appliedThemeProperties)i.has(l)||this.style.removeProperty(l);for(const[l,k]of Object.entries(n))this.style.setProperty(l,k);this.appliedThemeProperties=i;const m=this.activeTheme.seedColor;this.themeEventsReady&&this.lastSeedColor&&this.lastSeedColor!==m&&d().publish("seed-color-changed",{seedColor:m,correlationId:this.correlationId}),this.lastSeedColor=m,this.themeEventsReady&&e.has("iconSpriteUrl")&&d().publish("icon-sprite-url-changed",{iconSpriteUrl:this.iconSpriteUrl,correlationId:this.correlationId}),this.syncGoogleFontLinks()}firstUpdated(){const e=this.activeTheme.stylesheets;if(e.length)for(const t of e){const s=document.createElement("link");s.rel="stylesheet",s.href=t,document.head.appendChild(s)}if(!document.getElementById("esp-root-base-styles")){const t=document.createElement("style");t.id="esp-root-base-styles",t.textContent=a.lightDomStyles,document.head.appendChild(t)}this.applyDefaultScheme(),this.lastSeedColor=this.activeTheme.seedColor,this.themeEventsReady=!0,this.startThemeSettleTimer()}startThemeSettleTimer(){if(this.themeReadyState||this.themeSettleTimer!==void 0)return;this.themeSettleDeadline??=performance.now()+T;const e=Math.max(0,this.themeSettleDeadline-performance.now());if(e===0){this.closeThemeWindow();return}this.themeSettleTimer=setTimeout(()=>this.closeThemeWindow(),e)}closeThemeWindow(){this.themeSettleTimer=void 0,this.themePending&&!this.warnedThemeSettleTimeout&&(this.warnedThemeSettleTimeout=!0,console.warn(`Espalier root: theme-pending was declared but no ${this.scheme} theme arrived within ${T}ms, so the default palette is rendering. Assign ${this.scheme==="dark"?"darkTheme":"lightTheme"} (or remove theme-pending).`)),this.settleTheme()}updated(e){this.toggleAttribute("data-theme-ready",this.themeReadyState),(e.has("defaultScheme")||e.has("scheme"))&&!this.schemeExplicitlySet&&this.applyDefaultScheme()}disconnectedCallback(){this.themeSettleTimer!==void 0&&(clearTimeout(this.themeSettleTimer),this.themeSettleTimer=void 0),this.unregisterDocumentClickBridge(),this.systemSchemeQuery?.removeEventListener("change",this.handleSystemSchemeChange),this.systemSchemeQuery=null,this.resizeObserver.disconnect(),this.removeRuntimeGoogleFontLinks(),super.disconnectedCallback()}registerDocumentClickBridge(){this.documentClickRegistrationActive||(this.documentClickRegistrationActive=!0,a.connectedRootCount+=1,a.connectedRootCount===1&&document.addEventListener("click",a.handleDocumentClick))}unregisterDocumentClickBridge(){this.documentClickRegistrationActive&&(this.documentClickRegistrationActive=!1,a.connectedRootCount=Math.max(0,a.connectedRootCount-1),a.connectedRootCount===0&&document.removeEventListener("click",a.handleDocumentClick))}applyDefaultScheme(){this.schemeExplicitlySet||(this.resolvingDefaultScheme=!0,this.scheme=this.resolveDefaultScheme(),this.resolvingDefaultScheme=!1,this.syncSystemSchemeListener())}resolveDefaultScheme(){return this.defaultScheme==="dark"||this.defaultScheme==="system"&&window.matchMedia?.("(prefers-color-scheme: dark)").matches?"dark":"light"}syncSystemSchemeListener(){if(this.schemeExplicitlySet||this.defaultScheme!=="system"||!window.matchMedia){this.systemSchemeQuery?.removeEventListener("change",this.handleSystemSchemeChange),this.systemSchemeQuery=null;return}this.systemSchemeQuery||(this.systemSchemeQuery=window.matchMedia("(prefers-color-scheme: dark)"),this.systemSchemeQuery.addEventListener("change",this.handleSystemSchemeChange))}render(){return w`<slot></slot>`}};o.connectedRootCount=0,o.handleDocumentClick=c=>{const e=c.composedPath().filter(t=>t instanceof HTMLElement&&t.tagName==="ESP-POPOVER");d().publish("close-popovers",{source:c.target??void 0,skipPopovers:e})},o.lightDomStyles=`
|
|
2
2
|
|
|
3
3
|
esp-root {
|
|
4
4
|
font-family: var(--_esp-font-body-effective, var(--esp-font-body, system-ui, sans-serif));
|
|
@@ -136,4 +136,4 @@ var r=function(c,e,t,s){var n=arguments.length,i=n<3?e:s===null?s=Object.getOwnP
|
|
|
136
136
|
:host([theme-pending]:not([data-theme-ready])) {
|
|
137
137
|
visibility: hidden;
|
|
138
138
|
}
|
|
139
|
-
`,r([
|
|
139
|
+
`,r([h({attribute:!1})],o.prototype,"correlationId",void 0),r([h({attribute:"light-theme"})],o.prototype,"lightThemeAttr",void 0),r([h({attribute:"dark-theme"})],o.prototype,"darkThemeAttr",void 0),r([h({attribute:!1})],o.prototype,"lightTheme",null),r([h({attribute:!1})],o.prototype,"darkTheme",null),r([h({attribute:"font-css-root",type:String})],o.prototype,"fontCSSRoot",void 0),r([h({attribute:"font-definitions-url",type:String})],o.prototype,"fontDefinitionsUrl",void 0),r([h({attribute:"google-font-loading",type:String})],o.prototype,"googleFontLoading",void 0),r([h({attribute:"icon-sprite-url",type:String})],o.prototype,"iconSpriteUrl",void 0),r([h({attribute:"theme-pending",reflect:!0,type:Boolean})],o.prototype,"themePending",void 0),r([R()],o.prototype,"themeReadyState",void 0),r([h({attribute:"default-scheme",type:String,reflect:!0})],o.prototype,"defaultScheme",void 0),r([h({attribute:"scheme",type:String,reflect:!0})],o.prototype,"scheme",null),o=a=r([C("esp-root")],o);export{q as BUILT_IN_IMAGE_TEXTURES,o as EspalierRoot,$ as registerImageTexture,Q as registeredImageTextures};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{parseCssColor as f,serializeOklch as u,gamutMapToSRGB as m}from"../../shared/color-engine.js";import{generateScaleProperties as y}from"../../shared/scale-engine.js";import{DATA_SERIES_KEYS as b,DEFAULT_DATA_PALETTE as k,generateDivergingRamp as v,generateSequentialRamp as O}from"../../shared/data-colors.js";import{DEFAULT_BODY_FONT_FAMILY as B,DEFAULT_MONOSPACE_FONT_FAMILY as R,resolveDataColorSource as
|
|
1
|
+
import{parseCssColor as f,serializeOklch as u,gamutMapToSRGB as m}from"../../shared/color-engine.js";import{generateScaleProperties as y}from"../../shared/scale-engine.js";import{DATA_SERIES_KEYS as b,DEFAULT_DATA_PALETTE as k,generateDivergingRamp as v,generateSequentialRamp as O}from"../../shared/data-colors.js";import{DEFAULT_BODY_FONT_FAMILY as B,DEFAULT_MONOSPACE_FONT_FAMILY as R,resolveDataColorSource as w}from"../../shared/theme.js";import{dataCompanionProperties as E}from"./data-companion-properties.js";import{lightnessRampProperties as I}from"./lightness-ramp-properties.js";import{computeVariants as $}from"./compute-variants.js";import{computeSemanticProperties as M}from"./compute-semantic-properties.js";function T(o){return{rootFontSize:o.rootFontSize,typeRatio:o.typeRatio,spaceRatio:o.spaceRatio,borderRadius:o.borderRadius,viewportMin:o.viewportMin,viewportMax:o.viewportMax}}function x(o,d,g){const i={},a=o.dataPalette??k;for(let t=0;t<b.length;t+=1){const p=b[t],r=f(g(a[p],`dataPalette.${p}`))??d;i[`--esp-color-series-${t+1}`]=u(m(r))}return i}function W(o,d,g){const i=f(o.seedColor);if(!i)return{};const a={};a["--esp-scheme"]=d,a["--esp-seed-color"]=o.seedColor;const t=$(i,o);for(const[e,n]of Object.entries(t))a[`--esp-color-${e}`]=u(m(n));const p=new Set,r=(e,n)=>{const s=typeof e=="string"?w(e,o.anchors):null;if(s)return s;const c=typeof e=="string"?e:String(e);return p.has(c)||(p.add(c),console.warn(`Espalier theme: ${n} color source "${c}" cannot be resolved \u2014 falling back to the seed. Run validateTheme for the declared data colors.`)),o.seedColor};Object.assign(a,x(o,i,r));for(const[e,n]of Object.entries(o.dataRamps??{}))try{(n.type==="sequential"?O(r(n.source,`dataRamps.${e}.source`),{steps:n.steps,lightnessStart:n.lightnessStart,lightnessEnd:n.lightnessEnd}):v(r(n.start,`dataRamps.${e}.start`),r(n.end,`dataRamps.${e}.end`),{steps:n.steps,neutral:n.neutral===void 0?void 0:r(n.neutral,`dataRamps.${e}.neutral`)})).forEach((c,S)=>{a[`--esp-color-ramp-${e}-${S+1}`]=c})}catch(s){console.warn(`Espalier theme: dataRamps.${e} cannot be generated \u2014 ${s instanceof Error?s.message:String(s)}`)}Object.assign(a,I(o));const l=new Set;return Object.assign(a,M(o,t,{trace:g,onUnresolvedSource:e=>{l.has(e)||(l.add(e),console.warn(`Espalier theme: color source "${e}" cannot be resolved \u2014 falling back to the seed. Run validateTheme for the declared anchors.`))}})),Object.assign(a,E(a)),Object.assign(a,y(T(o))),a["--esp-font-body"]=o.fontBody||B,o.fontHeadings&&(a["--esp-font-headings"]=o.fontHeadings),o.fontBrand&&(a["--esp-font-brand"]=o.fontBrand),o.fontMenu&&(a["--esp-font-menu"]=o.fontMenu),a["--esp-font-monospace"]=o.fontMonospace||R,a["--esp-font-weight-body"]=o.fontWeightBody,a["--esp-font-weight-headings"]=o.fontWeightHeadings,a["--esp-font-weight-brand"]=o.fontWeightBrand,a["--esp-font-weight-menu"]=o.fontWeightMenu,a["--esp-font-weight-monospace"]=o.fontWeightMonospace,o.pageBackgroundImage&&(a["--esp-page-background-image"]=o.pageBackgroundImage),o.pageBackgroundImageOpacity!==void 0&&(a["--esp-page-background-image-opacity"]=o.pageBackgroundImageOpacity.toString()),o.boxBackgroundImage&&(a["--esp-box-background-image"]=o.boxBackgroundImage),o.boxBackgroundImageOpacity!==void 0&&(a["--esp-box-background-image-opacity"]=o.boxBackgroundImageOpacity.toString()),o.vellumOpacity!==void 0&&(a["--esp-vellum-opacity"]=o.vellumOpacity.toString()),o.vellumBackgroundImage&&(a["--esp-vellum-background-image"]=o.vellumBackgroundImage),o.vellumBackgroundImageOpacity!==void 0&&(a["--esp-vellum-background-image-opacity"]=o.vellumBackgroundImageOpacity.toString()),a}export{W as computeThemeProperties,x as dataSeriesProperties};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function d(e){return(e.getAttribute("aria-describedby")??"").split(/\s+/).filter(Boolean)}function c(e,i,s={}){const t=[...i].filter(Boolean),r=s.deduplicate?[...new Set(t)]:t;r.length>0?e.setAttribute("aria-describedby",r.join(" ")):e.removeAttribute("aria-describedby")}function a(e,i){const s=new Set(i.remove??[]),t=[...i.add??[]],r=new Set(t),n=d(e).filter(o=>!s.has(o)||r.has(o));for(const o of t)n.includes(o)||n.push(o);c(e,n)}export{d as describedByTokens,c as setDescribedByTokens,a as syncDescribedByTokens};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { nothing } from "lit";
|
|
2
|
+
export interface ConfiguredBrandOptions {
|
|
3
|
+
brandLogo: string;
|
|
4
|
+
brandText: string;
|
|
5
|
+
brandHref: string;
|
|
6
|
+
brandAlt: string;
|
|
7
|
+
}
|
|
8
|
+
export interface ConfiguredBrandConfiguration {
|
|
9
|
+
scheme: "light" | "dark" | "";
|
|
10
|
+
brandLogo: string;
|
|
11
|
+
brandColor: string;
|
|
12
|
+
lightBrandLogo: string;
|
|
13
|
+
darkBrandLogo: string;
|
|
14
|
+
lightBrandColor: string;
|
|
15
|
+
darkBrandColor: string;
|
|
16
|
+
}
|
|
17
|
+
export interface ResolvedConfiguredBrand {
|
|
18
|
+
brandLogo: string;
|
|
19
|
+
brandColor: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Resolve the configured-brand logo and color for the active scheme.
|
|
23
|
+
* Non-empty scheme values take precedence over generic values. Empty
|
|
24
|
+
* scheme values are treated as absent so generic configuration and the
|
|
25
|
+
* consuming component's CSS-token defaults remain available.
|
|
26
|
+
*/
|
|
27
|
+
export declare function resolveConfiguredBrand({ scheme, brandLogo, brandColor, lightBrandLogo, darkBrandLogo, lightBrandColor, darkBrandColor, }: ConfiguredBrandConfiguration): ResolvedConfiguredBrand;
|
|
28
|
+
/**
|
|
29
|
+
* Render the shared configured-brand fallback used by header and footer.
|
|
30
|
+
* Plain anchors and images are intentional: a brand identity should not gain
|
|
31
|
+
* the interaction chrome of Espalier's application-navigation controls.
|
|
32
|
+
*/
|
|
33
|
+
export declare function renderConfiguredBrand({ brandLogo, brandText, brandHref, brandAlt, }: ConfiguredBrandOptions): typeof nothing | import("lit-html").TemplateResult<1>;
|
package/dist/shared/events.d.ts
CHANGED
|
@@ -98,9 +98,11 @@ export declare const ESP_EVENTS: {
|
|
|
98
98
|
readonly MENU_GROUP_TOGGLE: "esp-menu-group-toggle";
|
|
99
99
|
readonly MENU_DRAWER_OPENED: "esp-menu-drawer-opened";
|
|
100
100
|
readonly MENU_DRAWER_CLOSED: "esp-menu-drawer-closed";
|
|
101
|
+
readonly MENU_DRAWER_PRESENTED: "esp-menu-drawer-presented";
|
|
101
102
|
readonly PAGE_WORKSPACE_RESIZE: "esp-page-workspace-resize";
|
|
102
103
|
readonly PICKER_MENU_SELECTION_CHANGED: "esp-picker-menu-selection-changed";
|
|
103
104
|
readonly PICKER_MENU_CLOSE_REQUESTED: "esp-picker-menu-close-requested";
|
|
105
|
+
readonly PICKER_MENU_DISMISS_REQUESTED: "esp-picker-menu-dismiss-requested";
|
|
104
106
|
readonly PICKER_MENU_RANGE_CHANGED: "esp-picker-menu-range-changed";
|
|
105
107
|
readonly POPOVER_OPENED: "esp-popover-opened";
|
|
106
108
|
readonly POPOVER_CLOSED: "esp-popover-closed";
|
|
@@ -314,6 +316,7 @@ export interface EspalierDialogEventMap {
|
|
|
314
316
|
export interface EspalierMenuEventMap {
|
|
315
317
|
[ESP_EVENTS.MENU_DRAWER_OPENED]: CustomEvent<void>;
|
|
316
318
|
[ESP_EVENTS.MENU_DRAWER_CLOSED]: CustomEvent<void>;
|
|
319
|
+
[ESP_EVENTS.MENU_DRAWER_PRESENTED]: CustomEvent<void>;
|
|
317
320
|
}
|
|
318
321
|
/** Events fired by `<esp-menu-group>`. */
|
|
319
322
|
export interface EspalierMenuGroupEventMap {
|
|
@@ -414,6 +417,7 @@ export interface EspalierBurgerEventMap {
|
|
|
414
417
|
export interface EspalierPickerMenuEventMap {
|
|
415
418
|
[ESP_EVENTS.PICKER_MENU_SELECTION_CHANGED]: CustomEvent<PickerItem[]>;
|
|
416
419
|
[ESP_EVENTS.PICKER_MENU_CLOSE_REQUESTED]: CustomEvent<PickerItem[]>;
|
|
420
|
+
[ESP_EVENTS.PICKER_MENU_DISMISS_REQUESTED]: CustomEvent<void>;
|
|
417
421
|
[ESP_EVENTS.PICKER_MENU_RANGE_CHANGED]: CustomEvent<{
|
|
418
422
|
first: number;
|
|
419
423
|
last: number;
|
package/dist/shared/events.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{VALIDITY_CHANGED_EVENT as r}from"./validation.js";import{VALIDITY_CHANGED_EVENT as e}from"./validation.js";const
|
|
1
|
+
import{VALIDITY_CHANGED_EVENT as r}from"./validation.js";import{VALIDITY_CHANGED_EVENT as e}from"./validation.js";const s={VALUE_CHANGED:"esp-value-changed",VALIDITY_CHANGED:e,CLICKED:"esp-clicked",ACTION_MENU_SELECT:"esp-action-menu-select",BURGER_OPENED:"esp-burger-opened",BURGER_CLOSED:"esp-burger-closed",DETAILS_TOGGLE:"esp-details-toggle",DETAILS_GROUP_CHANGE:"esp-details-group-change",DIALOG_OPENED:"esp-dialog-opened",DIALOG_CLOSING:"esp-dialog-closing",DIALOG_CLOSED:"esp-dialog-closed",FILE_UPLOAD_FILES_SELECTED:"esp-file-upload-files-selected",FLYOUT_OPENED:"esp-flyout-opened",FLYOUT_CLOSED:"esp-flyout-closed",FLYOUT_STATE_CHANGED:"esp-flyout-state-changed",FOCUS_PICKER_CHANGED:"esp-focus-picker-changed",FORM_DIALOG_CLOSE_REQUESTED:"esp-form-dialog-close-requested",FORM_SUBMIT:"esp-form-submit",FORM_SUBMIT_RESPONSE:"esp-form-submit-response",FORM_SUBMIT_ERROR:"esp-form-submit-error",GRID_EVENT:"esp-grid-event",GRID_LOAD_START:"esp-grid-load-start",GRID_LOAD_SUCCESS:"esp-grid-load-success",GRID_LOAD_ERROR:"esp-grid-load-error",GRID_ITEMS_CHANGED:"esp-grid-items-changed",HEADER_THEME_TOGGLE:"esp-header-theme-toggle",IMAGE_UPLOAD_FILE_SELECTED:"esp-image-upload-file-selected",IMAGE_UPLOAD_FILE_REMOVED:"esp-image-upload-file-removed",IMAGE_UPLOAD_FILES_REJECTED:"esp-image-upload-files-rejected",IMAGE_UPLOAD_RETRY:"esp-image-upload-retry",IMAGE_UPLOAD_IMAGES_REORDERED:"esp-image-upload-images-reordered",INFO_DESTROY:"esp-info-destroy",INPUT_ICON_CLICKED:"esp-input-icon-clicked",LIGHTBOX_CHANGED:"esp-lightbox-changed",MENU_GROUP_TOGGLE:"esp-menu-group-toggle",MENU_DRAWER_OPENED:"esp-menu-drawer-opened",MENU_DRAWER_CLOSED:"esp-menu-drawer-closed",MENU_DRAWER_PRESENTED:"esp-menu-drawer-presented",PAGE_WORKSPACE_RESIZE:"esp-page-workspace-resize",PICKER_MENU_SELECTION_CHANGED:"esp-picker-menu-selection-changed",PICKER_MENU_CLOSE_REQUESTED:"esp-picker-menu-close-requested",PICKER_MENU_DISMISS_REQUESTED:"esp-picker-menu-dismiss-requested",PICKER_MENU_RANGE_CHANGED:"esp-picker-menu-range-changed",POPOVER_OPENED:"esp-popover-opened",POPOVER_CLOSED:"esp-popover-closed",SEARCH_REQUESTED:"esp-search-requested",SEARCH_RESULT_SELECTED:"esp-search-result-selected",SEARCH_CLOSED:"esp-search-closed",TAB_GROUP_CHANGED:"esp-tab-group-changed",TREE_SELECT:"esp-tree-select",TREE_TOGGLE:"esp-tree-toggle",TREE_GRAFT_REQUEST:"esp-tree-graft-request",TREE_GRAFT:"esp-tree-graft",TREE_EDIT:"esp-tree-edit",TREE_DELETE:"esp-tree-delete",TREE_MOVE_UP:"esp-tree-move-up",TREE_MOVE_DOWN:"esp-tree-move-down",TREE_CUT:"esp-tree-cut",TREE_PASTE_CHILD:"esp-tree-paste-child",TREE_GRAFT_INPUT:"esp-tree-graft-input"};export{s as ESP_EVENTS,r as VALIDITY_CHANGED_EVENT};
|
|
@@ -6,8 +6,18 @@
|
|
|
6
6
|
* resulting CSS in the document head before `<esp-root>` can paint.
|
|
7
7
|
*/
|
|
8
8
|
import type { EspalierTheme } from "./theme.js";
|
|
9
|
-
export type FontPlanTheme = Pick<EspalierTheme, "fontBody" | "fontHeadings" | "fontBrand" | "fontMonospace" | "fontWeightBody" | "fontWeightHeadings" | "fontWeightBrand" | "fontWeightMonospace">;
|
|
10
|
-
export type FontPlanSlot = "body" | "headings" | "brand" | "monospace";
|
|
9
|
+
export type FontPlanTheme = Pick<EspalierTheme, "fontBody" | "fontHeadings" | "fontBrand" | "fontMenu" | "fontMonospace" | "fontWeightBody" | "fontWeightHeadings" | "fontWeightBrand" | "fontWeightMenu" | "fontWeightMonospace">;
|
|
10
|
+
export type FontPlanSlot = "body" | "headings" | "brand" | "menu" | "monospace";
|
|
11
|
+
/**
|
|
12
|
+
* Per-scheme effective stacks. The `menu` slot is present only when the
|
|
13
|
+
* theme configures `fontMenu`: an unset menu font resolves to the body slot
|
|
14
|
+
* at use time, so planning it separately would request the body family at
|
|
15
|
+
* the menu weight for every site and change compiled output that had no
|
|
16
|
+
* menu font at all.
|
|
17
|
+
*/
|
|
18
|
+
export type FontPlanStacks = Record<Exclude<FontPlanSlot, "menu">, string> & {
|
|
19
|
+
menu?: string;
|
|
20
|
+
};
|
|
11
21
|
export type FontPlanScheme = "light" | "dark";
|
|
12
22
|
export type FontPlanStyle = "normal" | "italic";
|
|
13
23
|
export type FontFaceRequest = {
|
|
@@ -68,7 +78,7 @@ export type CompiledFontPlan = {
|
|
|
68
78
|
/** Catalog families that lacked the requested weight/style profile. */
|
|
69
79
|
missingProfiles: FontPlanProfileMiss[];
|
|
70
80
|
/** Scheme/slot stacks represented by the emitted private effective tokens. */
|
|
71
|
-
effectiveStacks: Record<FontPlanScheme,
|
|
81
|
+
effectiveStacks: Record<FontPlanScheme, FontPlanStacks>;
|
|
72
82
|
/** UTF-8 byte size of `css`, convenient for static-site budget checks. */
|
|
73
83
|
byteLength: number;
|
|
74
84
|
};
|
package/dist/shared/font-plan.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import{extractFamily as R,normalizeFontFaceWeight as
|
|
2
|
-
${
|
|
3
|
-
normal`,
|
|
4
|
-
${
|
|
5
|
-
${
|
|
1
|
+
import{extractFamily as R,normalizeFontFaceWeight as U}from"./font-helpers.js";const N="U+0000-024F,U+1E00-1EFF,U+2000-206F,U+20AC,U+2122,U+2191,U+2193,U+2212,U+2215,U+FEFF,U+FFFD",b=["body","headings","brand","menu","monospace"],W={"sans-serif":[0,1],display:[0,1],handwriting:[0,1],"not-display":[0,1],serif:[2],monospace:[3]};function E(t){let e="";for(const n of t){const s=n.codePointAt(0)??0;n==="\\"?e+="\\\\":n==='"'?e+='\\"':n==="<"?e+="\\3c ":s<=31||s===127?e+=`\\${s.toString(16)} `:e+=n}return`"${e}"`}function z(t){return`url(${E(t)}) format("woff2")`}function x(t){for(const o of t){const $=o.codePointAt(0)??0;if(o===";"||o==="{"||o==="}"||o==="<"||$<=31||$===127)throw new Error("Font stack contains characters that cannot be embedded in inline CSS")}if(t.includes("/*")||t.includes("*/"))throw new Error("Font stack contains characters that cannot be embedded in inline CSS");const e=[];let n="",s="",i=!1,a=0;for(const o of t){if(i){n+=o,i=!1;continue}if(o==="\\"){n+=o,i=!0;continue}if(s){n+=o,o===s&&(s="");continue}if(o==='"'||o==="'"){n+=o,s=o;continue}if(o==="("&&(a+=1),o===")"&&(a=Math.max(0,a-1)),o===","&&a===0){n.trim()&&e.push(n.trim()),n="";continue}n+=o}if(i||s||a!==0)throw new Error("Font stack contains an unterminated escape, quote, or function");return n.trim()&&e.push(n.trim()),e}function I(t){return U(t)}function _(t,e){return`${t}${e==="italic"?"i":""}`}function q(t,e,n="normal"){return`${encodeURIComponent(t)}~${e}~${n==="italic"?"i":"n"}`}function j(t,e){return t.family.localeCompare(e.family,"en")||t.weight-e.weight||t.style.localeCompare(e.style,"en")}function C(t,e){let n=2166136261;for(const s of`${t}:${e}`)n^=s.charCodeAt(0),n=Math.imul(n,16777619);return`ef${(n>>>0).toString(36)}`}function B(t){return W[t]??[]}function J(t,e,n,s="normal"){const i=U(e);if(!t.trim()||i===null)return[];const a=q(t.trim(),i,s);return B(n).map(o=>C(a,o))}function O(t,e){if(!Number.isInteger(t)||t<0||!Number.isInteger(e)||e<=0)throw new Error("Font fallback catalog contains an invalid encoded percentage");const n=Math.floor(t/e),s=String(t%e).padStart(String(e).length-1,"0").replace(/0+$/,"");return`${n}${s?`.${s}`:""}%`}function F(t,e,n,s){n!==null&&t.push(`${e}:${O(n,s)};`)}function P(t,e){const n=x(t);return n.length===0||e.length===0?t:[n[0],...e,...n.slice(1)].join(",")}function T(t){const e=t.fontBody,n=t.fontHeadings||e,s=t.fontBrand||n,i=t.fontMonospace,a={body:[e,t.fontWeightBody],headings:[n,t.fontWeightHeadings],brand:[s,t.fontWeightBrand],monospace:[i,t.fontWeightMonospace]};return t.fontMenu&&(a.menu=[t.fontMenu,t.fontWeightMenu]),a}function M(t,e,n,s,i){const a={},o={},$=T(e);for(const f of b){const u=$[f];if(!u)continue;const[h,y]=u;a[f]=h,x(h);const r=R(h),k=n.profiles[r];if(!k)continue;const c=I(y);if(c===null){const S=`${r}
|
|
2
|
+
${y}
|
|
3
|
+
normal`,m=i.get(S)??{family:r,weight:null,style:"normal",schemes:[],slots:[]};m.schemes.includes(t)||m.schemes.push(t),m.slots.includes(f)||m.slots.push(f),i.set(S,m);continue}const l="normal",g=k[_(c,l)];if(!g){const S=`${r}
|
|
4
|
+
${c}
|
|
5
|
+
${l}`,m=i.get(S)??{family:r,weight:c,style:l,schemes:[],slots:[]};m.schemes.includes(t)||m.schemes.push(t),m.slots.includes(f)||m.slots.push(f),i.set(S,m);continue}const d=q(r,c,l),w=s.get(d)??{request:{key:d,family:r,weight:c,style:l},profile:g,schemes:new Set,slots:new Set};w.schemes.add(t),w.slots.add(f),s.set(d,w),o[f]=w}return{stacks:a,uses:o}}function L(t){const e=t.trim();if(!/^U\+[0-9A-F?]{1,6}(?:-[0-9A-F]{1,6})?(?:\s*,\s*U\+[0-9A-F?]{1,6}(?:-[0-9A-F]{1,6})?)*$/i.test(e))throw new Error(`Invalid font source unicode-range "${t}"`);return e.replace(/\s+/g,"")}function D(t){return t?Array.isArray(t)?t:[t]:[]}function G(t,e){return e.map(n=>{if(!n.url.trim())throw new Error(`Empty WOFF2 source for ${t.key}`);const s=n.unicodeRange?`unicode-range:${L(n.unicodeRange)};`:"";return`@font-face{font-family:${E(t.family)};src:${z(n.url)};font-style:${t.style};font-weight:${t.weight};font-display:swap;${s}}`}).join("")}function K(t,e,n){const[s,i,a,o,$,f]=e,u=n.bases[s],h=u?.[1]?.[i];if(!u||!h||h.length===0)throw new Error(`Font fallback catalog is missing base ${s} ${i}`);const y=C(t.key,s),r=[`@font-face{font-family:${y};src:${h.map(k=>`local(${E(k)})`).join(",")};`,`font-style:${t.style};font-weight:${t.weight};`];return F(r,"size-adjust",a,n.metadata.percentScale),F(r,"ascent-override",o,n.metadata.percentScale),F(r,"descent-override",$,n.metadata.percentScale),F(r,"line-gap-override",f,n.metadata.percentScale),r.push(`unicode-range:${N};}`),{alias:y,css:r.join("")}}function A(t,e){const n=b.flatMap(s=>{const i=e[s];return i===void 0?[]:[`--_esp-font-${s}-effective:${i};`]}).join("");return`${t}{${n}}`}function v(t){if(t===void 0||t.trim()==="")return"esp-root";const e=t.trim();if(!/^#[A-Za-z_][A-Za-z0-9_-]*$/.test(e))throw new Error('rootSelector must be a unique id selector such as "#site-shell"');return e}function V(t){const{catalog:e}=t;if(e.version!==1||e.metadata?.subset!=="latin"||!/^10+$/.test(String(e.metadata?.percentScale)))throw new Error(`Unsupported font fallback catalog metadata: version ${String(e.version)}, subset ${String(e.metadata?.subset)}, percentScale ${String(e.metadata?.percentScale)}`);const n=new Map,s=v(t.rootSelector),i=new Map,a={light:M("light",t.lightTheme,e,n,i),dark:M("dark",t.darkTheme,e,n,i)},o=[...n.values()].sort((c,l)=>j(c.request,l.request)),$=o.map(({request:c})=>c),f=[],u=[],h=new Map,y=new Map;for(const c of o){const l=D(t.sources?.[c.request.key]);l.length===0?f.push(c.request):u.push(G(c.request,l));const g=[];for(const d of c.profile){const p=K(c.request,d,e),w=y.get(p.alias);if(w&&w!==`${c.request.key}:${d[0]}`)throw new Error(`Generated fallback family collision for ${p.alias}`);y.set(p.alias,`${c.request.key}:${d[0]}`),g.push(p.alias),u.push(p.css)}h.set(c.request.key,g)}const r={light:{},dark:{}};for(const c of["light","dark"]){const l=a[c];for(const g of b){const d=l.stacks[g];if(d===void 0)continue;const p=l.uses[g];r[c][g]=p?P(d,h.get(p.request.key)??[]):d}}(r.light.menu!==void 0||r.dark.menu!==void 0)&&(r.light.menu??=r.light.body,r.dark.menu??=r.dark.body),u.push(A(s,r.light)),JSON.stringify(r.dark)!==JSON.stringify(r.light)&&(u.push(A(`${s}[scheme=dark],${s}[default-scheme=dark]:not([scheme])`,r.dark)),u.push(`@media(prefers-color-scheme:dark){${A(`${s}[default-scheme=system]:not([scheme])`,r.dark)}}`));const k=u.join("");return{css:k,requests:$,missingSources:f,missingProfiles:[...i.values()],effectiveStacks:r,byteLength:new TextEncoder().encode(k).byteLength}}export{V as compileFontPlan,q as fontFaceRequestKey,J as fontFallbackAliases,B as fontFallbackBaseIndexes};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
let s=0;class
|
|
1
|
+
import{syncDescribedByTokens as i}from"./aria-describedby.js";let s=0;class o{constructor(t){this.options=t,this.descriptionId=`esp-form-field-description-${++s}`,this.description=null,this.descriptionElement=null,this.formItemLabel=null,this.appliedLabel=null,this.target=null,t.host.addController(this)}hostConnected(){this.sync()}hostUpdated(){this.sync()}hostDisconnected(){this.removeDescriptionToken(this.target),this.removeAppliedLabel(this.target),this.descriptionElement?.remove(),this.descriptionElement=null,this.target=null}setDescription(t){this.description=t,this.sync()}setLabel(t){const e=t?.trim()??"";this.formItemLabel=e.length>0?e:null,this.sync()}sync(){const t=this.options.getTarget()??null;this.target&&this.target!==t&&(this.removeDescriptionToken(this.target),this.removeAppliedLabel(this.target)),this.target=t,this.syncDescription(),this.syncLabel()}syncDescription(){if(!this.target||this.description===null){this.removeDescriptionToken(this.target),this.descriptionElement?.remove(),this.descriptionElement=null;return}const t=this.target.getRootNode();if(t instanceof ShadowRoot){if(!this.descriptionElement||this.descriptionElement.getRootNode()!==t){this.descriptionElement?.remove();const e=document.createElement("span");e.id=this.descriptionId,e.hidden=!0,e.toggleAttribute("data-esp-form-item-description",!0),t.appendChild(e),this.descriptionElement=e}this.descriptionElement.textContent=this.description,this.addDescriptionToken(this.target)}}syncLabel(){if(!this.target){this.appliedLabel=null;return}if(this.formItemLabel===null){this.removeAppliedLabel(this.target);return}const t=this.target.getAttribute("aria-label");t!==null&&t!==this.appliedLabel||(t!==this.formItemLabel&&this.target.setAttribute("aria-label",this.formItemLabel),this.appliedLabel=this.formItemLabel)}removeAppliedLabel(t){t&&this.appliedLabel!==null&&t.getAttribute("aria-label")===this.appliedLabel&&t.removeAttribute("aria-label"),this.appliedLabel=null}addDescriptionToken(t){i(t,{add:[this.descriptionId]})}removeDescriptionToken(t){t&&i(t,{remove:[this.descriptionId]})}}export{o as FormFieldDescriptionController};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const c=['a[href]:not([disabled]):not([tabindex="-1"])','button:not([disabled]):not([tabindex="-1"])','input:not([disabled]):not([tabindex="-1"])','select:not([disabled]):not([tabindex="-1"])','textarea:not([disabled]):not([tabindex="-1"])','[tabindex]:not([tabindex="-1"]):not([disabled])'].join(", "),l="[autofocus]:not([disabled])";class o{static lock(){o.
|
|
1
|
+
const c=['a[href]:not([disabled]):not([tabindex="-1"])','button:not([disabled]):not([tabindex="-1"])','input:not([disabled]):not([tabindex="-1"])','select:not([disabled]):not([tabindex="-1"])','textarea:not([disabled]):not([tabindex="-1"])','[tabindex]:not([tabindex="-1"]):not([disabled])'].join(", "),l="[autofocus]:not([disabled])";class o{static lock(t,e={}){const s=e.preserveScrollPosition===!0,n=o.owners.get(t);n===!0||n===s||(o.owners.size===0&&(o.snapshot={x:window.scrollX,y:window.scrollY,html:o.capture(document.documentElement,["overflow","overflow-x","overflow-y","overscroll-behavior","overscroll-behavior-x","overscroll-behavior-y"]),body:o.capture(document.body,["overflow","overflow-x","overflow-y","overscroll-behavior","overscroll-behavior-x","overscroll-behavior-y","position","top","left","width"])}),o.owners.set(t,s),o.applyCurrentTreatment())}static unlock(t){if(!(!o.owners.delete(t)||!o.snapshot)){if(o.owners.size===0){o.restoreSnapshot(),o.snapshot=null;return}o.applyCurrentTreatment()}}static capture(t,e){return e.map(s=>({name:s,value:t.style.getPropertyValue(s),priority:t.style.getPropertyPriority(s)}))}static restore(t,e){for(const{name:s}of e)t.style.removeProperty(s);for(const{name:s,value:n,priority:i}of e)n&&t.style.setProperty(s,n,i)}static applyCurrentTreatment(){const t=o.snapshot;if(!t)return;const e=[...o.owners.values()].some(Boolean);!e&&o.positionFrozen&&(o.restore(document.documentElement,t.html),o.restore(document.body,t.body),o.restoreViewport(t),o.positionFrozen=!1),document.body.style.overflow="hidden",e&&(o.positionFrozen||(t.x=window.scrollX,t.y=window.scrollY),document.documentElement.style.overflow="hidden",document.documentElement.style.overscrollBehavior="contain",document.body.style.overscrollBehavior="contain",document.body.style.position="fixed",document.body.style.top=`${-t.y}px`,document.body.style.left=`${-t.x}px`,document.body.style.width="100%",o.positionFrozen=!0)}static restoreSnapshot(){const t=o.snapshot;t&&(o.restore(document.documentElement,t.html),o.restore(document.body,t.body),o.positionFrozen&&o.restoreViewport(t),o.positionFrozen=!1)}static restoreViewport(t){window.scrollTo?.({top:t.y,left:t.x,behavior:"instant"})}static _reset(){o.restoreSnapshot(),o.owners.clear(),o.snapshot=null,o.positionFrozen=!1}}o.owners=new Map,o.snapshot=null,o.positionFrozen=!1;function f(){o._reset()}class r{static lock(t){const e=r._counts.get(t);return e!==void 0?(r._counts.set(t,e+1),!0):t.inert?!1:(r._counts.set(t,1),t.inert=!0,!0)}static unlock(t){const e=r._counts.get(t)??0;if(e<=0)return;const s=e-1;s===0?(t.inert=!1,r._counts.delete(t)):r._counts.set(t,s)}static _reset(){r._counts.clear()}}r._counts=new Map;function d(){r._reset()}class u{get isPromoting(){return this._promoting}constructor(t){this._isOpen=!1,this._previouslyFocused=null,this._inertElements=[],this._promoted=!1,this._pendingReactivation=!1,this._dropZone=null,this._promoting=!1,this._host=t.host,this._opts=t,t.host.addController(this)}static addOpenListener(t){u.openListeners.add(t)}static removeOpenListener(t){u.openListeners.delete(t)}redirectFocusRestore(t){this._isOpen&&(this._previouslyFocused=t)}get isOpen(){return this._isOpen}open(){if(!this._isOpen){this._pendingReactivation?this._pendingReactivation=!1:this._previouslyFocused=document.activeElement??null,this._isOpen=!0;for(const t of u.openListeners)t(this);o.lock(this,this._opts.scrollLock),this._opts.promote!==!1&&this._promoteToDropZone(),this._setInert(!0)}}close(){if(this._pendingReactivation=!1,!this._isOpen){this._previouslyFocused?.focus(),this._previouslyFocused=null;return}this._isOpen=!1,o.unlock(this),this._setInert(!1),this._previouslyFocused?.focus(),this._previouslyFocused=null}trapFocus(t){const e=this.getFocusableElements();if(e.length===0)return;const s=e[0],n=e[e.length-1],i=this._getDeepActiveElement();t.shiftKey?(i===s||this._isOrContains(s,i))&&(t.preventDefault(),n.focus()):(i===n||this._isOrContains(n,i))&&(t.preventDefault(),s.focus())}moveFocusInto(){const t=this._getAutofocusElement();if(t&&(t.focus(),this._autofocusLanded(t)))return;const e=this.getFocusableElements();if(e.length>0){e[0].focus();return}const s=this._opts.getFocusFallback?.();if(s){s.focus();return}this._opts.getFocusTrapContainer()?.focus()}_getAutofocusElement(){return this._getMatchingElements(l)[0]??null}getFocusableElements(){return this._getMatchingElements(c)}_getMatchingElements(t){if(t===c&&this._opts.getFocusScope)return this._opts.getFocusScope();const e=this._opts.getFocusTrapContainer();if(!e)return[];const s=[];for(const n of Array.from(e.querySelectorAll("*")))if(n instanceof HTMLElement){if(n.matches(t)&&s.push(n),n.shadowRoot){const i=n.shadowRoot.querySelectorAll(t);s.push(...Array.from(i))}if(n instanceof HTMLSlotElement)for(const i of n.assignedElements({flatten:!0})){if(!(i instanceof HTMLElement))continue;i.matches(t)&&s.push(i);const a=i.querySelectorAll(t);if(s.push(...Array.from(a)),i.shadowRoot){const h=i.shadowRoot.querySelectorAll(t);s.push(...Array.from(h))}}}for(const n of Array.from(this._host.children)){if(!(n instanceof HTMLElement))continue;n.matches(t)&&(s.includes(n)||s.push(n));const i=n.querySelectorAll(t);for(const a of Array.from(i))s.includes(a)||s.push(a);if(n.shadowRoot){const a=n.shadowRoot.querySelectorAll(t);for(const h of Array.from(a))s.includes(h)||s.push(h)}}return s}hostConnected(){}hostDisconnected(){this._promoting||this._isOpen&&(this._setInert(!1),o.unlock(this),this._isOpen=!1,this._pendingReactivation=!0)}_setInert(t){if(t){this._inertElements=[];const e=this._resolveInertAnchor(),s=e.parentElement??document.body;for(const n of s.children)n instanceof HTMLElement&&n!==e&&r.lock(n)&&this._inertElements.push(n)}else{for(const e of this._inertElements)r.unlock(e);this._inertElements=[]}}_resolveInertAnchor(){if(this._dropZone)return this._dropZone;const t=this._opts.getInertAnchor?.();if(t)return t;let e=this._host;for(;!e.parentElement;){const s=e.getRootNode();if(s instanceof ShadowRoot&&s.host instanceof HTMLElement)e=s.host;else break}return e}_getDeepActiveElement(){let t=document.activeElement;for(;t?.shadowRoot?.activeElement;)t=t.shadowRoot.activeElement;return t}_isOrContains(t,e){return e?t===e?!0:t.contains(e):!1}_autofocusLanded(t){const e=this._getActiveElementChain(),s=e[0];return e.some(n=>this._isOrContains(t,n)?!0:n!==s&&n instanceof HTMLElement&&this._isOrContains(n,t))}_getActiveElementChain(){const t=[];let e=document.activeElement;for(;e;){t.push(e);const s=e.shadowRoot?.activeElement??null;if(!s||s===e)break;e=s}return t}_promoteToDropZone(){if(this._promoted&&this._dropZone){this._promoting=!0;try{this._dropZone.appendChild(this._host)}finally{this._promoting=!1}return}const t=this._host,e=t.closest("esp-page");if(e){if(customElements.get("esp-page")){this._tryPromote(e);return}customElements.whenDefined("esp-page").then(()=>{if(!this._isOpen||!t.isConnected)return;const s=t.closest("esp-page");this._tryPromote(s)&&(this._setInert(!1),this._setInert(!0))})}}_tryPromote(t){if(!t||this._promoted)return!1;const e=t.AddDialog;if(typeof e=="function"){this._promoting=!0;try{e.call(t,this._host)}finally{this._promoting=!1}return this._promoted=!0,this._dropZone=this._host.parentElement,!0}return!1}}u.openListeners=new Set;export{c as FOCUSABLE_SELECTOR,u as OverlayController,o as ScrollLock,d as _resetInertLock,f as _resetScrollLock};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{getEspBus as c}from"./bus-events.js";import{RafThrottle as h}from"./raf-throttle.js";function p(r){const t=[],s=new Set;let e=r;for(;e&&!s.has(e);){s.add(e);const i=e["linked-popover"];if(i){e=i;continue}const o=e.closest("esp-popover");if(o){t.includes(o)||t.push(o),e=o.parentElement||o.getRootNode()?.host;continue}const n=e.getRootNode();e=n instanceof ShadowRoot?n.host:void 0}return t}class d{constructor(t){this.bus=c(),this.positionFrame=new h(()=>this.runPositionUpdate()),this.positionResizeObserver=null,this.handleClosePopovers=s=>{if(!this.opts.isOpen())return;const e=this.opts.host;if(this.opts.closeStrategy==="source-identity"){if(!s.source||s.source===e||s.source instanceof Node&&(e.contains(s.source)||e.shadowRoot?.contains(s.source)))return}else if(s.skipPopovers?.includes(e))return;this.opts.onShouldClose()},this.onScrollOrResize=()=>this.positionFrame.schedule(),this.onDocumentClick=s=>{const e=this.opts.host,i=s.composedPath();if(i.includes(e))return;const o=this.opts.getInsideElements?.()??[];for(const n of o)if(n&&i.includes(n))return;this.opts.isOpen()&&this.opts.onOutsideClick?.()},this.opts=t,t.host.addController(this)}hostConnected(){this.bus.subscribe("close-popovers",this.handleClosePopovers)}hostDisconnected(){this.bus.unsubscribe("close-popovers",this.handleClosePopovers),this.stopTracking(),this.stopOutsideClick()}runPositionUpdate(){if(this.opts.isOpen()){if(this.opts.shouldContinueTracking&&!this.opts.shouldContinueTracking()){this.opts.onShouldClose();return}this.opts.onPositionUpdate?.()}}startTracking(){
|
|
1
|
+
import{getEspBus as c}from"./bus-events.js";import{RafThrottle as h}from"./raf-throttle.js";function p(r){const t=[],s=new Set;let e=r;for(;e&&!s.has(e);){s.add(e);const i=e["linked-popover"];if(i){e=i;continue}const o=e.closest("esp-popover");if(o){t.includes(o)||t.push(o),e=o.parentElement||o.getRootNode()?.host;continue}const n=e.getRootNode();e=n instanceof ShadowRoot?n.host:void 0}return t}class d{constructor(t){this.bus=c(),this.positionFrame=new h(()=>this.runPositionUpdate()),this.positionResizeObserver=null,this.trackingPosition=!1,this.handleClosePopovers=s=>{if(!this.opts.isOpen())return;const e=this.opts.host;if(this.opts.closeStrategy==="source-identity"){if(!s.source||s.source===e||s.source instanceof Node&&(e.contains(s.source)||e.shadowRoot?.contains(s.source)))return}else if(s.skipPopovers?.includes(e))return;this.opts.onShouldClose()},this.onScrollOrResize=()=>this.positionFrame.schedule(),this.onDocumentClick=s=>{const e=this.opts.host,i=s.composedPath();if(i.includes(e))return;const o=this.opts.getInsideElements?.()??[];for(const n of o)if(n&&i.includes(n))return;this.opts.isOpen()&&this.opts.onOutsideClick?.()},this.opts=t,t.host.addController(this)}hostConnected(){this.bus.subscribe("close-popovers",this.handleClosePopovers)}hostDisconnected(){this.bus.unsubscribe("close-popovers",this.handleClosePopovers),this.stopTracking(),this.stopOutsideClick()}runPositionUpdate(){if(this.opts.isOpen()){if(this.opts.shouldContinueTracking&&!this.opts.shouldContinueTracking()){this.opts.onShouldClose();return}this.opts.onPositionUpdate?.()}}startTracking(){this.opts.onPositionUpdate&&(this.trackingPosition=!0,window.addEventListener("scroll",this.onScrollOrResize,{capture:!0,passive:!0}),window.addEventListener("resize",this.onScrollOrResize,{passive:!0}),this.refreshPositionElements())}refreshPositionElements(){if(this.positionResizeObserver?.disconnect(),this.positionResizeObserver=null,!this.trackingPosition||!this.opts.getPositionElements||typeof ResizeObserver>"u")return;const t=new Set(this.opts.getPositionElements().filter(Boolean));if(t.size!==0){this.positionResizeObserver=new ResizeObserver(this.onScrollOrResize);for(const s of t)this.positionResizeObserver.observe(s)}}stopTracking(){this.trackingPosition=!1,window.removeEventListener("scroll",this.onScrollOrResize,{capture:!0}),window.removeEventListener("resize",this.onScrollOrResize),this.positionResizeObserver?.disconnect(),this.positionResizeObserver=null,this.positionFrame.cancel()}startOutsideClick(){this.opts.onOutsideClick&&document.addEventListener("click",this.onDocumentClick,!0)}stopOutsideClick(){document.removeEventListener("click",this.onDocumentClick,!0)}publishCloseOthers(t=[]){this.bus.publish("close-popovers",{source:this.opts.host,...t.length>0?{skipPopovers:t}:{}})}}export{d as PopoverController,p as findContainingPopovers};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e="(max-width: 50em)";function t(){return typeof window>"u"||!window.matchMedia?!1:window.matchMedia(e).matches}export{e as COMPACT_VIEWPORT_MEDIA_QUERY,t as compactViewportMatches};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{css as
|
|
1
|
+
import{css as n,unsafeCSS as e}from"lit";const i=n`
|
|
2
2
|
:host([align]) {
|
|
3
3
|
text-align: inherit;
|
|
4
4
|
}
|
|
5
|
-
`,
|
|
5
|
+
`,a=n`
|
|
6
6
|
.sr-only {
|
|
7
7
|
position: absolute;
|
|
8
8
|
width: 1px;
|
|
@@ -14,17 +14,33 @@ import{css as o,unsafeCSS as e}from"lit";const a=o`
|
|
|
14
14
|
white-space: nowrap;
|
|
15
15
|
border: 0;
|
|
16
16
|
}
|
|
17
|
-
`;function
|
|
18
|
-
${e(
|
|
17
|
+
`;function l(r){const o=r.includes(":host")||r.includes("[disabled]")?r:`:host([disabled]) ${r}`;return n`
|
|
18
|
+
${e(o)} {
|
|
19
19
|
opacity: 0.5;
|
|
20
20
|
cursor: not-allowed;
|
|
21
21
|
}
|
|
22
|
-
`}function p(r,
|
|
22
|
+
`}function p(r,o,t="0 0 3px",s=""){return n`
|
|
23
23
|
${e(r)} {
|
|
24
24
|
box-shadow: ${e(s)} ${e(t)}
|
|
25
|
-
var(${e(
|
|
25
|
+
var(${e(o)}, var(--esp-color-shadow));
|
|
26
26
|
}
|
|
27
|
-
`}
|
|
27
|
+
`}function d(r,o="var(--esp-size-normal-to-medium)"){return[n`
|
|
28
|
+
${e(r)} {
|
|
29
|
+
display: inline-flex;
|
|
30
|
+
align-items: center;
|
|
31
|
+
justify-content: center;
|
|
32
|
+
border: 0;
|
|
33
|
+
background: transparent;
|
|
34
|
+
color: var(--esp-color-text);
|
|
35
|
+
cursor: pointer;
|
|
36
|
+
padding: var(--esp-size-tiny);
|
|
37
|
+
|
|
38
|
+
svg {
|
|
39
|
+
inline-size: ${e(o)};
|
|
40
|
+
block-size: ${e(o)};
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
`]}const h=n`
|
|
28
44
|
.intent-neutral {
|
|
29
45
|
--_esp-intent-background: var(--esp-color-layer-2);
|
|
30
46
|
--_esp-intent-border-color: var(--esp-color-border);
|
|
@@ -54,4 +70,4 @@ import{css as o,unsafeCSS as e}from"lit";const a=o`
|
|
|
54
70
|
--_esp-intent-border-color: oklch(from var(--esp-color-info) var(--esp-l-border) c h);
|
|
55
71
|
--_esp-intent-color: oklch(from var(--esp-color-info) var(--esp-l-text) c h);
|
|
56
72
|
}
|
|
57
|
-
`;export{
|
|
73
|
+
`;export{i as alignAttributeTextInheritance,l as disabledControl,p as focusRing,h as intentSurfaceTokens,d as quietCloseButton,a as srOnly};
|
package/dist/shared/theme.d.ts
CHANGED
|
@@ -336,6 +336,14 @@ export interface EspalierTheme {
|
|
|
336
336
|
* @default ""
|
|
337
337
|
*/
|
|
338
338
|
fontBrand: string;
|
|
339
|
+
/**
|
|
340
|
+
* CSS `font-family` for navigation menu items and group labels. When empty,
|
|
341
|
+
* menu recipes fall back to {@link fontBody} — never to headings — so a
|
|
342
|
+
* theme that sets only a heading face keeps its navigation unchanged.
|
|
343
|
+
*
|
|
344
|
+
* @default ""
|
|
345
|
+
*/
|
|
346
|
+
fontMenu: string;
|
|
339
347
|
/**
|
|
340
348
|
* CSS `font-family` for code / monospace text. Empty and omitted overrides
|
|
341
349
|
* resolve to the built-in monospace family.
|
|
@@ -376,6 +384,16 @@ export interface EspalierTheme {
|
|
|
376
384
|
* @default "bold"
|
|
377
385
|
*/
|
|
378
386
|
fontWeightBrand: string;
|
|
387
|
+
/**
|
|
388
|
+
* CSS `font-weight` for horizontal navigation menu items.
|
|
389
|
+
*
|
|
390
|
+
* Accepts the same values as {@link fontWeightBody}.
|
|
391
|
+
*
|
|
392
|
+
* Emitted as `--esp-font-weight-menu`.
|
|
393
|
+
*
|
|
394
|
+
* @default "bold"
|
|
395
|
+
*/
|
|
396
|
+
fontWeightMenu: string;
|
|
379
397
|
/**
|
|
380
398
|
* CSS `font-weight` for code / monospace text.
|
|
381
399
|
*
|