@taprootio/espalier 7.2.0 → 7.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/custom-elements.json +36241 -46953
- package/dist/badge/esp-badge.d.ts +46 -0
- package/dist/badge/esp-badge.js +41 -6
- package/dist/breadcrumbs/breadcrumb-separators.d.ts +4 -0
- package/dist/breadcrumbs/breadcrumb-separators.js +1 -0
- package/dist/breadcrumbs/esp-breadcrumb.d.ts +14 -14
- package/dist/breadcrumbs/esp-breadcrumb.js +14 -7
- package/dist/breadcrumbs/esp-breadcrumbs.d.ts +16 -9
- package/dist/breadcrumbs/esp-breadcrumbs.js +9 -6
- package/dist/cli/theme-check.js +2 -2
- package/dist/font-picker/esp-font-picker.d.ts +11 -14
- package/dist/font-picker/esp-font-picker.js +5 -5
- package/dist/footer/esp-footer-link-group.js +12 -9
- package/dist/footer/esp-footer.d.ts +8 -3
- package/dist/footer/esp-footer.js +20 -12
- package/dist/footer/paint-registration.js +1 -1
- package/dist/header/esp-header-button.js +3 -3
- package/dist/header/esp-header.js +9 -9
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1 -1
- package/dist/pickers/esp-picker-item.js +1 -1
- package/dist/root/esp-root.d.ts +8 -1
- package/dist/root/esp-root.js +80 -13
- package/dist/root/helpers/compute-semantic-properties.js +1 -1
- package/dist/root/helpers/compute-theme-properties.js +1 -1
- package/dist/root/helpers/data-companion-properties.js +1 -1
- package/dist/root/helpers/lightness-ramp-properties.js +1 -1
- package/dist/shared/blockquote-styles.d.ts +3 -0
- package/dist/shared/blockquote-styles.js +4 -4
- package/dist/shared/color-engine.js +1 -1
- package/dist/shared/component-property-compiler.js +1 -0
- package/dist/shared/component-property-diagnostics.js +1 -0
- package/dist/shared/component-property-normalizer.js +1 -0
- package/dist/shared/component-property-resets.js +1 -0
- package/dist/shared/document-sprite.js +1 -1
- package/dist/shared/esp-element-base.d.ts +3 -0
- package/dist/shared/esp-element-base.js +3 -3
- package/dist/shared/font-helpers.d.ts +3 -3
- package/dist/shared/font-helpers.js +1 -1
- package/dist/shared/font-plan.d.ts +1 -1
- package/dist/shared/footer-ink-styles.js +18 -0
- package/dist/shared/footer-ink.js +1 -0
- package/dist/shared/governing-root.d.ts +24 -0
- package/dist/shared/governing-root.js +1 -0
- package/dist/shared/intent-values.js +1 -1
- package/dist/shared/paint-catalog.js +1 -1
- package/dist/shared/paint-fit.js +1 -1
- package/dist/shared/public-token-catalog.generated.js +1 -0
- package/dist/shared/root-event-subscription.d.ts +11 -0
- package/dist/shared/scoped-style-declarations.js +1 -0
- package/dist/shared/semantic-color-names.d.ts +16 -0
- package/dist/shared/semantic-color-names.js +1 -0
- package/dist/shared/settable-component-properties.js +1 -0
- package/dist/shared/theme-core.d.ts +808 -0
- package/dist/shared/theme-core.js +1 -0
- package/dist/shared/theme-fit-report.d.ts +34 -6
- package/dist/shared/theme-fit-report.js +1 -1
- package/dist/shared/theme-mapping-grammar.d.ts +16 -0
- package/dist/shared/theme-mapping-grammar.js +1 -0
- package/dist/shared/theme-properties.d.ts +3 -1
- package/dist/shared/theme-properties.js +1 -1
- package/dist/shared/theme-validation.d.ts +52 -0
- package/dist/shared/theme-validation.js +1 -0
- package/dist/shared/theme.d.ts +4 -876
- package/dist/shared/theme.js +1 -1
- package/dist/shared/token-pairings.d.ts +1 -1
- package/dist/testing/observe-paint.iife.js +2 -2
- package/espalier.css-data.json +109 -5
- package/espalier.token-manifest.json +5914 -32
- package/package.json +5 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var
|
|
1
|
+
var d=function(v,e,t,r){var o=arguments.length,n=o<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,c;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(v,e,t,r);else for(var s=v.length-1;s>=0;s--)(c=v[s])&&(n=(o<3?c(n):o>3?c(e,t,n):c(e,t))||n);return o>3&&n&&Object.defineProperty(e,t,n),n};import{css as R,LitElement as C}from"lit";import{property as u,state as T}from"lit/decorators.js";import{flattenedParent as b,GoverningRootObserver as x}from"./governing-root.js";import{compileComponentProperties as S}from"./component-property-compiler.js";import{getComponentPropertyAnalysis as O}from"./component-property-normalizer.js";import{addComponentPropertyResets as _}from"./component-property-resets.js";import{ScopedStyleDeclarations as P}from"./scoped-style-declarations.js";import{traverseToClosest as E}from"./utilities.js";import{parseCssColor as U,serializeOklch as A,gamutMapToSRGB as z}from"./color-engine.js";import{computeVariants as m}from"../root/helpers/compute-variants.js";import{computeSemanticProperties as g}from"../root/helpers/compute-semantic-properties.js";import{DocumentSpriteController as I}from"./document-sprite.js";import{dataCompanionProperties as N}from"../root/helpers/data-companion-properties.js";import{dataSeriesProperties as j}from"../root/helpers/compute-theme-properties.js";import{lightnessRampProperties as B}from"../root/helpers/lightness-ramp-properties.js";import{surfacePolarityProperty as D}from"../root/helpers/surface-polarity-property.js";import{ELEVATION_PROPERTIES as V,TYPE_ROLE_COLOR_PROPERTIES as L}from"./scale-engine.js";import{resolveContextTheme as y,resolveDataColorSource as M,semanticToCSS as W}from"./theme-core.js";import{alignAttributeTextInheritance as q,focusRing as $}from"./style-fragments.js";import{syncNormalizedAttribute as G}from"./attribute-helpers.js";import{INTENT_VARIANTS as k,normalizeIntentVariant as H}from"./intent-values.js";import{ESP_EVENTS as Z}from"./events.js";import{surfaceLayerAttributes as w,surfaceLayerColor as F}from"./surface-layer.js";class i extends C{get espRoot(){return this.rootObserver.root}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(Z.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=H(e);G(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 n of Array.from(o.children))r(n)},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 n of o.assignedElements({flatten:!0}))r(n);t(o)}};t(this),this.shadowRoot&&t(this.shadowRoot)}resolveAncestorZoneTheme(e){let t=b(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=b(t)}return null}connectedCallback(){super.connectedCallback(),this.rootObserver.connect()}disconnectedCallback(){super.disconnectedCallback(),this.rootObserver.disconnect()}firstUpdated(e){if(this.isConnected&&!this.rootObserver.refresh())throw new Error("No esp-root ancestor found. Espalier components must be placed inside an <esp-root> element.");this.rootObserver.whenReady(this.applyReadyRoot)}governingRootChanged(e){}syncRootMetadata(e){this.scheme=e.scheme==="dark"?"dark":"light",this.seedColor=e.seedColor}applyTokensWhenRootReady(){this.rootObserver.refresh(),this.rootObserver.whenReady(this.applyReadyRoot)}constructor(){super(),this.seedColorBacker="oklch(0.7 0.125 216)",this.rootObserver=new x(this,(e,t)=>{e!==t&&(this.scopedTokens.clear(),this.governingRootChanged(e),this.isConnected&&this.requestUpdate()),e&&(this.syncRootMetadata(e),this.rootObserver.whenReady(this.applyReadyRoot))}),this.contextBacker="",this.scopedTokens=new P(this),this.warnedUnknownContexts=new Set,this.intentBacker="neutral",this.intentEmitsTokens=!0,this.warnedUnknownIntents=new Set,this.correlationId=globalThis.crypto?.randomUUID?.()??Math.random().toString(36),this.scheme="light",this.applyReadyRoot=e=>{this.syncRootMetadata(e),this.applyScopedColorTokens()},this.rootObserver.subscribe("scheme-changed",()=>{const e=this.espRoot;!e||this.scheme===e.scheme||(this.syncRootMetadata(e),this.rootObserver.whenReady(this.applyReadyRoot))}),this.rootObserver.subscribe("seed-color-changed",({seedColor:e})=>{this.seedColor=e,this.applyScopedColorTokens()}),this.rootObserver.subscribe("theme-changed",()=>{const e=this.espRoot;e&&this.syncRootMetadata(e),this.applyScopedColorTokens()}),this.rootObserver.subscribe("icon-sprite-url-changed",()=>this.requestUpdate()),new I(this,this.rootObserver)}traverseToClosest(e){return E(this,e)}applyScopedColorTokens(){if(!this.espRoot)return;const e=this.intentEmitsTokens?i.intentColorSources[this.intentBacker]:"";if(!e&&!this.context.trim()){this.scopedTokens.clear();return}const t=this.espRoot.activeTheme;if(!t){this.scopedTokens.clear();return}const r=this.resolveContextTheme(t),o=r.theme,n=U(o.seedColor);if(!n)return;const c=m(n,o),s={};if(r.applied){Object.assign(s,g(o,c));const{candidates:l,contexts:h}=O(t),p=h.get(r.name);if(p&&l.size>0){const a=S(p,{theme:o,variants:c,semanticProperties:s});_(a,l),Object.assign(s,a)}s["--_esp-context-shadow"]="var(--esp-color-shadow)",Object.assign(s,D(s)),Object.assign(s,B(o)),Object.assign(s,V),Object.assign(s,L),Object.assign(s,N(s,j(o,n,a=>(typeof a=="string"?M(a,o.anchors):null)??o.seedColor)))}if(e){let l=o;r.applied||(l=this.resolveAncestorZoneTheme(t)??o);const h=l===o?c:m(n,l),p=g(l,h,{includeFooterInk:!1,effectiveSource:(a,f)=>i.semanticActionTokens.has(a)?e:f});s["--esp-color-primary"]=A(z(h[e]));for(const a of i.semanticActionTokens){const f=W(a);s[f]=p[f]}}this.scopedTokens.apply(s)}resolveContextTheme(e){const t=this.context.trim();if(!t)return{applied:!1,theme:e};const r=this.resolveNamedContextTheme(e,t);return r?{applied:!0,name:t,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(this.rootObserver.guard(r=>{if(this.context.trim()!==e)return;const o=r.activeTheme;o&&y(o,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)}}i.intentColorSources={danger:"danger",info:"info",neutral:"",success:"success",warning:"warning"},i.semanticActionTokens=new Set(["actionBackground","actionText"]),i.styles=[w(":host"),w("[surface-layer]"),$(".esp-field:focus-within","--esp-field-focus-shadow"),q,R`
|
|
2
2
|
:host {
|
|
3
3
|
|
|
4
4
|
--_esp-font-body-fallback: system-ui, sans-serif;
|
|
@@ -42,7 +42,7 @@ var c=function(f,e,t,r){var o=arguments.length,s=o<3?e:r===null?r=Object.getOwnP
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
.esp-field {
|
|
45
|
-
--_esp-field-resolved-background: var(--esp-field-background, ${
|
|
45
|
+
--_esp-field-resolved-background: var(--esp-field-background, ${F(2)});
|
|
46
46
|
|
|
47
47
|
|
|
48
48
|
--_esp-field-polarity: var(--_esp-surface-polarity, 1);
|
|
@@ -139,4 +139,4 @@ var c=function(f,e,t,r){var o=arguments.length,s=o<3?e:r===null?r=Object.getOwnP
|
|
|
139
139
|
.esp-field:has(textarea:disabled):hover {
|
|
140
140
|
background-color: var(--_esp-field-resolved-background);
|
|
141
141
|
}
|
|
142
|
-
`],
|
|
142
|
+
`],d([T()],i.prototype,"seedColor",null),d([u({attribute:!1})],i.prototype,"correlationId",void 0),d([u({type:String,reflect:!0})],i.prototype,"scheme",void 0),d([u({type:String,attribute:"intent",reflect:!0,useDefault:!0})],i.prototype,"intent",null),d([u({type:String,attribute:"context",reflect:!0})],i.prototype,"context",null);export{i as EspalierElementBase};
|
|
@@ -106,8 +106,8 @@ export declare function googleFontStylesheetUrl(family: string, weight?: string)
|
|
|
106
106
|
* The caller owns only its stable key, so unrelated roots and picker instances
|
|
107
107
|
* cannot replace or clean up one another's links.
|
|
108
108
|
*/
|
|
109
|
-
export declare function syncRuntimeGoogleFontLink(options: RuntimeGoogleFontLinkOptions): HTMLLinkElement | null;
|
|
109
|
+
export declare function syncRuntimeGoogleFontLink(options: RuntimeGoogleFontLinkOptions, doc?: Document): HTMLLinkElement | null;
|
|
110
110
|
/** Remove one shared runtime font link by its exact owner key. */
|
|
111
|
-
export declare function removeRuntimeGoogleFontLink(owner: string): void;
|
|
111
|
+
export declare function removeRuntimeGoogleFontLink(owner: string, doc?: Document): void;
|
|
112
112
|
/** Remove all shared runtime font links whose owner begins with `ownerPrefix`. */
|
|
113
|
-
export declare function removeRuntimeGoogleFontLinks(ownerPrefix: string): void;
|
|
113
|
+
export declare function removeRuntimeGoogleFontLinks(ownerPrefix: string, doc?: Document): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{webSafeFontWeights as
|
|
1
|
+
import{webSafeFontWeights as c}from"./font-stacks.js";const g={100:"100 Thin",200:"200 Extra Light",300:"300 Light",400:"400 Regular",500:"500 Medium",600:"600 Semi Bold",700:"700 Bold",800:"800 Extra Bold",900:"900 Black"},f=e=>e.kind==="web-safe";function p(e){if(!e)return["400"];if(f(e))return c(e);const t=new Set;for(const r of e.variants)r.includes("italic")||t.add(r==="regular"?"400":r);const n=[...t].sort((r,i)=>Number(r)-Number(i));return n.length>0?n:["400"]}function b(e,t){return e?e==="bold"?"700":e==="normal"?"400":e:t}function u(e,t){const n=e===void 0||e===""?t:e;if(n===void 0)return null;if(typeof n=="number")return Number.isInteger(n)&&n>=1&&n<=1e3?n:null;const r=n.trim().toLowerCase();if(r==="normal")return 400;if(r==="bold")return 700;if(!/^\d{1,4}$/.test(r))return null;const i=Number(r);return Number.isInteger(i)&&i>=1&&i<=1e3?i:null}function x(e,t){if(t.length===0)return"400";if(t.includes(e))return e;const n=Number(e);let r=t[0],i=Math.abs(Number(r)-n);for(const o of t){const s=Math.abs(Number(o)-n);s<i&&(r=o,i=s)}return r}function y(e){let t="",n="",r=!1,i=0;for(const s of e.trim()){if(r){t+=s,r=!1;continue}if(s==="\\"){t+=s,r=!0;continue}if(n){t+=s,s===n&&(n="");continue}if(s==='"'||s==="'"){t+=s,n=s;continue}if(s==="("&&(i+=1),s===")"&&(i=Math.max(0,i-1)),s===","&&i===0)break;t+=s}const o=t.trim();return o.length>=2&&(o.startsWith('"')&&o.endsWith('"')||o.startsWith("'")&&o.endsWith("'"))?o.slice(1,-1).replace(/\\([\\"'])/g,"$1"):o}const m=new Set(["serif","sans-serif","monospace","cursive","fantasy","system-ui","ui-serif","ui-sans-serif","ui-monospace","ui-rounded","math","fangsong","-apple-system","blinkmacsystemfont","arial","helvetica","helvetica neue","liberation sans","liberation serif","liberation mono","verdana","tahoma","trebuchet ms","georgia","times new roman","courier new","segoe ui"].map(e=>e.toLowerCase()));function F(e){return m.has(e.trim().toLowerCase())}function W(e){switch(e){case"serif":return"serif";case"monospace":return"monospace";case"handwriting":return"cursive";default:return"sans-serif"}}const a="data-esp-google-font-owner";function d(e,t){const n=u(t,400)??400,r=n!==400?`:wght@${n}`:"";return`https://fonts.googleapis.com/css2?family=${encodeURIComponent(e)}${r}&display=swap`}function l(e,t){return t.head.querySelector(`link[${a}="${CSS.escape(e)}"]`)}function w(e,t=document){const n=l(e.owner,t),r=e.family.trim(),i=String(u(e.weight,400)??400);if(e.enabled===!1||!r)return n?.remove(),null;if(n?.dataset.espFamily===r&&n.dataset.espWeight===i)return n;n?.remove();const o=t.createElement("link");return o.rel="stylesheet",o.href=d(r,i),o.setAttribute(a,e.owner),o.dataset.espFamily=r,o.dataset.espWeight=i,t.head.appendChild(o),o}function L(e,t=document){l(e,t)?.remove()}function k(e,t=document){for(const n of t.head.querySelectorAll(`link[${a}]`))n.getAttribute(a)?.startsWith(e)&&n.remove()}export{a as RUNTIME_GOOGLE_FONT_OWNER_ATTR,g as WEIGHT_LABELS,x as bestAvailableWeight,y as extractFamily,p as extractWeights,W as getFallbackFont,d as googleFontStylesheetUrl,F as isLocalFontFamily,u as normalizeFontFaceWeight,b as normalizeWeight,L as removeRuntimeGoogleFontLink,k as removeRuntimeGoogleFontLinks,w as syncRuntimeGoogleFontLink};
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* the exact requested faces, resolve only those WOFF2 sources, and embed the
|
|
6
6
|
* resulting CSS in the document head before `<esp-root>` can paint.
|
|
7
7
|
*/
|
|
8
|
-
import type { EspalierTheme } from "./theme.js";
|
|
8
|
+
import type { EspalierTheme } from "./theme-core.js";
|
|
9
9
|
export type FontPlanTheme = Pick<EspalierTheme, "fontBody" | "fontHeadings" | "fontBrand" | "fontMenu" | "fontMonospace" | "fontWeightBody" | "fontWeightHeadings" | "fontWeightBrand" | "fontWeightMenu" | "fontWeightMonospace">;
|
|
10
10
|
export type FontPlanSlot = "body" | "headings" | "brand" | "menu" | "monospace";
|
|
11
11
|
/**
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import{css as o}from"lit";const t=o`
|
|
2
|
+
:host {
|
|
3
|
+
--_esp-footer-fit-prefix: ;
|
|
4
|
+
--_esp-footer-ink-mode: fitted;
|
|
5
|
+
}
|
|
6
|
+
:host([surface-layer="1"]),
|
|
7
|
+
:host([surface-layer="3"]),
|
|
8
|
+
:host([surface-layer="4"]) {
|
|
9
|
+
--_esp-footer-fit-prefix: initial;
|
|
10
|
+
--_esp-footer-ink-mode: semantic;
|
|
11
|
+
}
|
|
12
|
+
`,r=o`
|
|
13
|
+
--_esp-footer-local-fitted-heading-color: var(--_esp-footer-fit-prefix)
|
|
14
|
+
var(--_esp-footer-fitted-heading-color);
|
|
15
|
+
`,f=o`
|
|
16
|
+
--_esp-footer-local-fitted-link-color: var(--_esp-footer-fit-prefix)
|
|
17
|
+
var(--_esp-footer-fitted-link-color);
|
|
18
|
+
`;export{r as footerHeadingFit,t as footerInkLayerStyles,f as footerLinkFit};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const o={headings:"--_esp-footer-fitted-heading-color",link:"--_esp-footer-fitted-link-color"},e="--_esp-footer-ink-mode",t="footer-heading-ink",n="footer-link-ink";export{t as FOOTER_HEADING_INK,e as FOOTER_INK_MODE,o as FOOTER_INK_PROPERTIES,n as FOOTER_LINK_INK};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { EspalierRoot } from "../root/esp-root.js";
|
|
2
|
+
import { type RootEventHandler, type RootEventName } from "./root-event-subscription.js";
|
|
3
|
+
/** Follow the ancestry that carries inherited styles across slots and shadow boundaries. */
|
|
4
|
+
export declare function flattenedParent(node: Node): Node | null;
|
|
5
|
+
/** Find the nearest esp-root ancestor, including through assigned slots. */
|
|
6
|
+
export declare function governingRoot(node: Node): EspalierRoot | null;
|
|
7
|
+
type RootCallback = (root: EspalierRoot) => void;
|
|
8
|
+
/**
|
|
9
|
+
* Follow a connected host's root and the slots that can change it without a
|
|
10
|
+
* disconnect. Clients still own what they derive from that root.
|
|
11
|
+
*/
|
|
12
|
+
export declare class GoverningRootObserver {
|
|
13
|
+
constructor(host: Element, placementChanged?: ((root: EspalierRoot | null, previousRoot: EspalierRoot | null) => void) | undefined);
|
|
14
|
+
get root(): EspalierRoot | null;
|
|
15
|
+
connect(): void;
|
|
16
|
+
disconnect(): void;
|
|
17
|
+
refresh(): EspalierRoot | null;
|
|
18
|
+
subscribe<K extends RootEventName>(event: K, handler: RootEventHandler<K>): () => void;
|
|
19
|
+
/** Guard a delayed callback against leaving this particular binding. */
|
|
20
|
+
guard(callback: RootCallback): () => void;
|
|
21
|
+
/** Deliver live root state after its pending Lit update, once per callback. */
|
|
22
|
+
whenReady(callback: RootCallback): void;
|
|
23
|
+
}
|
|
24
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{isShadowRoot as l}from"./composed-dom.js";import{subscribeToRootEvent as f}from"./root-event-subscription.js";function d(n){return n.nodeType===Node.ELEMENT_NODE}function c(n){return d(n)||n.nodeType===Node.TEXT_NODE}function a(n){return c(n)&&n.assignedSlot?n.assignedSlot:l(n)?n.host:n.parentNode}function g(n){for(let t=a(n);t;t=a(t))if(d(t)&&t.localName==="esp-root")return t;return null}class S{constructor(t,e){this.host=t,this.placementChanged=e,this.active=!1,this.path=[],this.slotTargets=new Set,this.binding=null,this.rebindSubscriptions=new Set,this.onSlotChange=()=>{this.refresh()}}get root(){return this.binding?.root??null}connect(){this.active=!0,this.refresh()}disconnect(){this.active=!1,this.refresh()}refresh(){const t=this.active&&this.host.isConnected,e=t?g(this.host):null,o=this.root,i=[],r=new Set;if(t)for(let s=this.host;s&&s!==e;s=a(s))i.push(s),(l(s)||d(s)&&s.localName==="slot")&&r.add(s),d(s)&&s.parentElement?.shadowRoot&&r.add(s.parentElement.shadowRoot);const h=i.length!==this.path.length||i.some((s,u)=>s!==this.path[u]);if(this.path=i,this.syncSlotTargets(r),e!==o){this.binding=e?{root:e,pending:new Set}:null;for(const s of this.rebindSubscriptions)s(this.binding)}return(e!==o||h)&&this.placementChanged?.(e,o),this.root}syncSlotTargets(t){for(const e of this.slotTargets)t.has(e)||e.removeEventListener("slotchange",this.onSlotChange);for(const e of t)this.slotTargets.has(e)||e.addEventListener("slotchange",this.onSlotChange);this.slotTargets=t}subscribe(t,e){let o;const i=r=>{o?.(),o=r?f(r.root,t,h=>{this.refresh(),this.binding===r&&e(h)}):void 0};return this.rebindSubscriptions.add(i),i(this.binding),()=>{this.rebindSubscriptions.delete(i),i(null)}}guard(t){const e=this.binding;return()=>{this.refresh(),e&&this.binding===e&&t(e.root)}}whenReady(t){const e=this.binding;if(!e)return;const{root:o,pending:i}=e;if(o.hasUpdated&&!o.isUpdatePending){t(o);return}if(i.has(t))return;const r=o.updateComplete;if(!r){t(o);return}i.add(t),r.then(this.guard(h=>{i.delete(t),t(h)}))}}export{S as GoverningRootObserver,a as flattenedParent,g as governingRoot};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{governingRoot as c}from"./governing-root.js";const u="/assets/icons.svg",p="0 0 24 24",a=/^[A-Za-z0-9][A-Za-z0-9_-]*$/u,l=100,o=new Set,s=[],d=["neutral","success","warning","danger","info"];function N(n){return d.includes(n)?n:"neutral"}function _(n,e=null){const t=n?.trim()??"";if(!a.test(t))return t.length>0&&f(t)&&console.warn(`Invalid Espalier icon name "${t}". Icon names must start with a letter or number and may only contain letters, numbers, dashes, and underscores.`),"";const r=i(e);switch(r.kind){case"url":return`${r.url}#${t}`;case"document":return`#${t}`;default:return""}}function i(n){const e=n?c(n):null;return I(e?e.iconSpriteUrl:u)}function I(n){const e=(n??"").trim();if(e.startsWith("#")){const r=e.slice(1).trim();return r?{kind:"document",spriteId:r}:{kind:"none"}}const t=e.split("#")[0]?.trim()||"";return t?{kind:"url",url:t}:{kind:"none"}}function g(n){const e=i(n);return e.kind==="url"?e.url:""}function f(n){if(o.has(n))return!1;if(o.add(n),s.push(n),s.length>l){const e=s.shift();e&&o.delete(e)}return!0}function A(){o.clear(),s.length=0}export{u as DEFAULT_ICON_SPRITE_URL,p as DEFAULT_ICON_VIEW_BOX,d as INTENT_VARIANTS,I as classifyIconSpriteValue,_ as getIconHrefForHost,i as getIconSpriteReference,g as getIconSpriteUrl,N as normalizeIntentVariant,A as resetWarnedInvalidIconNames};
|
|
@@ -1 +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{
|
|
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{FOOTER_HEADING_INK as x}from"./footer-ink.js";import{parsePaintColor as E}from"./paint-color.js";import{COLOR_SOURCES as A,SEMANTIC_COLOR_NAMES as N,isObjectRecord as p,semanticToCSS as R}from"./theme.js";const u=new Map([...N.map(t=>[t,R(t)]),...A.map(t=>[t,`--esp-color-${t}`])]),V=Object.freeze([...u.keys()]),l="brand-color";function f(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function J(t){return u.get(t)}function c(t){return typeof t=="string"&&t.trim()!==""}function C(t){return c(t)&&t===t.trim()}function I(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 Q(t){return p(t)&&Object.entries(g).every(([e,n])=>n(t[e]))}const $={element:!0,foreground:!0,background:!0,state:!0,kind:!0,flags:!0,navigation:!0,indicator:!0,paintOpacity:!0};function k(t){return p(t)&&Object.entries(t).every(([e,n])=>f(g,e)&&g[e](n))}function S(t,e,n){if(!p(t)||!Object.keys(t).every(o=>f($,o))||!c(t.element)||!c(t.state)||!I(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&&!k(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 z(t,e=b){if(!p(t))throw new TypeError("Paint entries must be grouped by role.");for(const[n,o]of Object.entries(t)){if(!C(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)S(o[r],`Paint entry for "${n}" at index ${r}`,e)}}function B(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){z(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 O=B([T,w,j,y]),D=O.entriesByRole,W=O.targets,b=O.derivations;function X(t,e,n=D,{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:t==="footer"?x:"headings"}:s)}function Y(t,e,n=b){if(f(n,t))return n[t](e);const o=e.readColor(t);return o?E(o):null}export{l as BRAND_PAINT_ID,D as PAINT_CATALOG,b as PAINT_DERIVATIONS,W as PAINT_TARGETS,V as PAINT_TOKEN_IDS,B as createPaintCatalog,X as enabledPaintEntries,_ as isPaintFlags,I as isPaintKind,c as isPaintName,Q as isPaintNavigationFact,C as isPaintRole,J as paintTokenProperty,Y as resolvePaintColor,z as validatePaintEntries};
|
package/dist/shared/paint-fit.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{resolveConfiguredBrandColor as k}from"./configured-brand-color.js";import{BRAND_PAINT_ID as B,PAINT_CATALOG as
|
|
1
|
+
import{FOOTER_INK_PROPERTIES as N}from"./footer-ink.js";import{resolveConfiguredBrandColor as k}from"./configured-brand-color.js";import{BRAND_PAINT_ID as B,PAINT_CATALOG as j,PAINT_DERIVATIONS as q,enabledPaintEntries as I,isPaintFlags as D,isPaintName as x,isPaintNavigationFact as M,isPaintRole as F,paintTokenProperty as L,resolvePaintColor as S,validatePaintEntries as W}from"./paint-catalog.js";import{compositePaint as H,MIN_SHADOW_INDICATOR_BLUR as G,paintRequiredRatio as K,shadowIndicatorAlpha as U}from"./paint-color.js";import{firstPaintByIdentity as V,paintIdentity as z}from"./paint-identity.js";import{SEMANTIC_COLOR_PROPERTIES as J,SETTABLE_COMPONENT_PROPERTIES as Q}from"./settable-component-properties.js";import{isObjectRecord as p,semanticToCSS as X}from"./theme-core.js";import{wcagRatio as Y}from"./wcag-contrast.js";const Z=["light","dark"],rr=new Set([...Object.values(N),...Object.entries(Q).flatMap(([t,{derives:e}])=>e?[t,e.property]:[t])]);function tr(t){return p(t)&&D(t.flags)&&Array.isArray(t.navigation)&&Array.from(t.navigation).every(M)}function er(t){if(!Array.isArray(t))throw new TypeError("Paint surfaces must be an array.");const e=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:o,context:l,brandColors:s,features:i}=a;if(e.has(o))throw new TypeError(`Duplicate paint surface role "${o}".`);if(e.add(o),l!=null&&!x(l))throw new TypeError(`Paint surface "${o}" 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 "${o}" has invalid brand colors.`);if(!p(i)||!Z.every(r=>tr(i[r])))throw new TypeError(`Paint surface "${o}" requires light and dark feature facts.`)}}function nr(t,e,a,o,l,s){const{role:i}=t,r=t.context??null,c=a.get(null),P=a.get(r);if(!c||!P)throw new Error(`Paint surface "${i}" requests undefined ${e} context "${r}".`);const u=k(t.brandColors?.[e],t.brandColors?.generic),h=n=>n==="--_esp-context-shadow"?r===null?void 0:P[X("shadow")]:J.has(n)||rr.has(n)||n.startsWith("--esp-l-")||n==="--_esp-surface-polarity"?P[n]:c[n],T={scheme:e,context:r,readProperty:h,readColor:n=>{if(n===B)return u?.startsWith("--esp-color-")?h(u):u;const f=L(n);return f&&h(f)}},y=t.features[e],R={brandColor:u},b=[...I(i,y,o.entriesByRole,R),...I(i,y,l,R)],C=[...V(b).values()].map(n=>{const{element:f,foreground:w,background:m,kind:O,state:g}=n,E=S(w,T,o.derivations),d=S(m,T,o.derivations);if(!E||!d||d.alpha!==1)throw new Error(`Paint surface "${i}" (${e}) cannot resolve "${f}" ${g}: ${w} on opaque ${m}.`);const _=E.alpha*(n.paintOpacity??1),v=U({alpha:_,blur:n.indicator==="blurred-shadow"?G:0}),$=H({...E,alpha:v},d),A={element:f,foreground:w,background:m,state:g,kind:O,ratio:Y($,d),required:K(O)};return s?.(e,z({role:i,...n}),A),A});return{role:i,context:r,pairs:C}}function dr(t,e,a={},o={entriesByRole:j,derivations:q},l){er(e),W(a,o.derivations);const s=new Set([...Object.entries(o.entriesByRole),...Object.entries(a)].filter(([,r])=>r.length>0).map(([r])=>r));for(const{role:r}of e)if(!s.has(r))throw new TypeError(`Paint surface "${r}" has no registered paint entries.`);const i=r=>e.map(c=>nr(c,r,t[r],o,a,l));return{light:i("light"),dark:i("dark")}}export{dr as measurePaintSurfaces};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=Object.freeze(["--esp-action-menu-background","--esp-action-menu-border","--esp-action-menu-item-focus-shadow","--esp-action-menu-item-gap","--esp-action-menu-item-hover-background","--esp-action-menu-item-icon-background","--esp-action-menu-item-icon-border-color","--esp-action-menu-item-icon-hover-background","--esp-action-menu-item-padding","--esp-action-menu-min-width","--esp-action-menu-shadow","--esp-avatar-border-radius","--esp-avatar-size","--esp-badge-background","--esp-badge-border-color","--esp-badge-border-radius","--esp-badge-color","--esp-badge-link-background","--esp-badge-link-border-color","--esp-badge-link-color","--esp-badge-link-focus-background","--esp-badge-link-focus-border-color","--esp-badge-link-focus-color","--esp-badge-link-focus-ring-color","--esp-badge-link-hover-background","--esp-badge-link-hover-border-color","--esp-badge-link-hover-color","--esp-blockquote-bar-color","--esp-blockquote-glyph-color","--esp-box-background","--esp-box-background-image","--esp-box-background-image-opacity","--esp-box-background-opacity","--esp-box-shadow","--esp-breadcrumb-color","--esp-breadcrumb-current-color","--esp-breadcrumb-hover-background","--esp-breadcrumb-hover-color","--esp-breadcrumb-separator-color","--esp-breadcrumb-separator-size","--esp-breadcrumb-separator-stroke-width","--esp-button-group-divider","--esp-button-incognito-padding","--esp-button-padding","--esp-card-min","--esp-checkbox-focus-shadow","--esp-checkbox-icon-color","--esp-checkbox-size","--esp-color-action-background","--esp-color-action-text","--esp-color-analogous-left","--esp-color-analogous-right","--esp-color-background","--esp-color-border","--esp-color-box-background","--esp-color-burger","--esp-color-burger-hover","--esp-color-burger-opened","--esp-color-burger-opened-hover","--esp-color-complementary","--esp-color-danger","--esp-color-danger-text","--esp-color-dialog-bg","--esp-color-headings","--esp-color-headings-hover","--esp-color-info","--esp-color-input-caret","--esp-color-input-selection","--esp-color-input-selection-bg","--esp-color-layer-1","--esp-color-layer-2","--esp-color-layer-3","--esp-color-layer-4","--esp-color-link","--esp-color-link-hover","--esp-color-link-hover-bg","--esp-color-picker-bg","--esp-color-picker-bg-alt","--esp-color-picker-bg-alt-hover","--esp-color-picker-bg-hover","--esp-color-primary","--esp-color-series-1","--esp-color-series-1-ink","--esp-color-series-1-tint","--esp-color-series-1-wash","--esp-color-series-2","--esp-color-series-2-ink","--esp-color-series-2-tint","--esp-color-series-2-wash","--esp-color-series-3","--esp-color-series-3-ink","--esp-color-series-3-tint","--esp-color-series-3-wash","--esp-color-series-4","--esp-color-series-4-ink","--esp-color-series-4-tint","--esp-color-series-4-wash","--esp-color-series-5","--esp-color-series-5-ink","--esp-color-series-5-tint","--esp-color-series-5-wash","--esp-color-series-6","--esp-color-series-6-ink","--esp-color-series-6-tint","--esp-color-series-6-wash","--esp-color-series-7","--esp-color-series-7-ink","--esp-color-series-7-tint","--esp-color-series-7-wash","--esp-color-series-8","--esp-color-series-8-ink","--esp-color-series-8-tint","--esp-color-series-8-wash","--esp-color-shadow","--esp-color-split-complementary-left","--esp-color-split-complementary-right","--esp-color-success","--esp-color-text","--esp-color-triadic-left","--esp-color-triadic-right","--esp-color-type-caption","--esp-color-type-label","--esp-color-type-lead","--esp-color-type-overline","--esp-color-warning","--esp-columns-gap","--esp-details-color-background","--esp-details-color-border","--esp-details-color-indicator","--esp-details-color-summary-background","--esp-details-color-summary-background-active","--esp-details-color-summary-hover-background","--esp-details-group-color-border","--esp-details-size-padding","--esp-dialog-bg-opacity","--esp-dialog-inset-block-end","--esp-dialog-inset-block-start","--esp-dialog-inset-inline-end","--esp-dialog-inset-inline-start","--esp-field-background","--esp-field-border-color","--esp-field-border-width","--esp-field-focus-bg","--esp-field-focus-shadow","--esp-field-hover-bg","--esp-field-text-color","--esp-flyout-background","--esp-flyout-border","--esp-flyout-padding","--esp-flyout-radius","--esp-flyout-shadow","--esp-flyout-z-index","--esp-focus-picker-focus-outline","--esp-focus-picker-gap","--esp-focus-picker-marker-border","--esp-focus-picker-marker-color","--esp-focus-picker-marker-shadow","--esp-focus-picker-marker-size","--esp-focus-picker-stage-background","--esp-font-body","--esp-font-brand","--esp-font-headings","--esp-font-menu","--esp-font-monospace","--esp-font-weight-body","--esp-font-weight-brand","--esp-font-weight-headings","--esp-font-weight-menu","--esp-font-weight-monospace","--esp-footer-background","--esp-footer-background-blend-mode","--esp-footer-background-image","--esp-footer-background-image-opacity","--esp-footer-background-position","--esp-footer-background-repeat","--esp-footer-background-size","--esp-footer-border","--esp-footer-brand-logo-aspect-ratio","--esp-footer-brand-logo-max-width","--esp-footer-brand-logo-max-width-compact","--esp-footer-brand-logo-size","--esp-footer-brand-logo-size-compact","--esp-footer-brand-text-size","--esp-footer-brand-text-size-compact","--esp-footer-color","--esp-footer-column-gap","--esp-footer-content-lead","--esp-footer-content-max-width","--esp-footer-current-block-align","--esp-footer-current-inline-align","--esp-footer-current-prose-align","--esp-footer-current-text-align","--esp-footer-dark-brand-logo-aspect-ratio","--esp-footer-focus-outline","--esp-footer-heading-color","--esp-footer-heading-font-size","--esp-footer-heading-size","--esp-footer-light-brand-logo-aspect-ratio","--esp-footer-link-color","--esp-footer-link-decoration","--esp-footer-link-group-gap","--esp-footer-link-hover-bg","--esp-footer-link-hover-color","--esp-footer-link-underline-offset","--esp-footer-link-underline-thickness","--esp-footer-padding-block","--esp-footer-padding-inline","--esp-footer-row-gap","--esp-footer-section-gap","--esp-form-item-error-background","--esp-form-item-error-color","--esp-form-item-error-field-background","--esp-form-item-error-field-border-color","--esp-form-item-error-field-focus-shadow","--esp-form-item-error-field-text-color","--esp-form-item-font","--esp-form-item-font-size","--esp-form-item-hint-color","--esp-form-item-hint-font-size","--esp-form-item-label-color","--esp-form-item-warning-background","--esp-form-item-warning-color","--esp-form-item-warning-field-background","--esp-form-item-warning-field-border-color","--esp-form-item-warning-field-focus-shadow","--esp-form-item-warning-field-text-color","--esp-grid-background","--esp-grid-border-inner","--esp-grid-border-outer","--esp-grid-cell-border-color","--esp-grid-header-active-background","--esp-grid-header-background","--esp-grid-link-color","--esp-grid-link-hover-color","--esp-grid-row-background-even","--esp-grid-row-background-odd","--esp-grid-row-hover-background","--esp-grid-row-hover-border-color","--esp-grid-text-color","--esp-header-background","--esp-header-border","--esp-header-border-width","--esp-header-brand-color","--esp-header-brand-font-family","--esp-header-brand-font-size","--esp-header-brand-font-weight","--esp-header-brand-gap","--esp-header-brand-hover-background","--esp-header-brand-hover-color","--esp-header-brand-hover-decoration","--esp-header-brand-hover-transform","--esp-header-brand-inline-placement","--esp-header-brand-logo-aspect-ratio","--esp-header-brand-logo-max-width","--esp-header-brand-logo-size","--esp-header-brand-max-width","--esp-header-brand-padding-inline","--esp-header-brand-placement","--esp-header-button-background","--esp-header-button-background-hover","--esp-header-button-border-left","--esp-header-button-box-shadow","--esp-header-button-closed-color","--esp-header-button-closed-hover-color","--esp-header-button-color","--esp-header-button-open-color","--esp-header-button-open-hover-color","--esp-header-button-stroke-width","--esp-header-color","--esp-header-compact-brand-logo-aspect-ratio","--esp-header-compact-height","--esp-header-content-lead","--esp-header-content-max-width","--esp-header-extended-menu-border","--esp-header-extended-menu-height","--esp-header-height","--esp-header-progress-background","--esp-header-progress-height","--esp-header-progress-track-background","--esp-header-scrolled-shadow","--esp-header-shadow","--esp-header-topbar-height","--esp-header-transparent-background","--esp-header-transparent-color","--esp-header-z-index","--esp-heading-1-color","--esp-heading-2-color","--esp-heading-3-color","--esp-heading-4-color","--esp-image-banner-block-size","--esp-image-banner-max-block-size","--esp-image-border","--esp-image-border-radius","--esp-image-compact-width","--esp-image-duotone-highlight-color","--esp-image-duotone-shadow-color","--esp-image-object-position","--esp-image-overlay-color","--esp-image-overlay-gap","--esp-image-overlay-measure","--esp-image-overlay-padding","--esp-image-overlay-text-shadow","--esp-image-picker-option-height","--esp-image-picker-option-width","--esp-image-picker-preview-height","--esp-image-preview-border-color","--esp-image-preview-overlay-text","--esp-image-preview-remove-color","--esp-image-scrim-color","--esp-image-scrim-edge-depth","--esp-image-scrim-edge-image","--esp-image-scrim-edge-size","--esp-image-scrim-opacity","--esp-image-static-compact-ratio","--esp-image-static-ratio","--esp-image-texture-blend-mode","--esp-image-texture-color","--esp-image-texture-image","--esp-image-texture-image-opacity","--esp-image-texture-opacity","--esp-image-texture-position","--esp-image-texture-repeat","--esp-image-texture-scale","--esp-image-texture-size","--esp-image-upload-preview-background","--esp-info-color-background","--esp-info-color-border","--esp-info-color-text","--esp-l-accent","--esp-l-border","--esp-l-ink","--esp-l-muted","--esp-l-raised-1","--esp-l-raised-2","--esp-l-raised-3","--esp-l-raised-4","--esp-l-shadow","--esp-l-surface","--esp-l-text","--esp-lightbox-bg","--esp-lightbox-bg-opacity","--esp-measure","--esp-measure-wide","--esp-menu-background","--esp-menu-border-color","--esp-menu-drawer-brand-color","--esp-menu-drawer-brand-logo-size","--esp-menu-drawer-item-font-size","--esp-menu-drawer-nested-item-max-font-size","--esp-menu-drawer-nested-item-min-font-size","--esp-menu-drawer-shadow","--esp-menu-drawer-transition-duration","--esp-menu-drawer-width","--esp-menu-group-background","--esp-menu-group-border-color","--esp-menu-group-color","--esp-menu-group-hover-background","--esp-menu-group-icon-background","--esp-menu-group-icon-min-width","--esp-menu-group-icon-padding","--esp-menu-group-icon-size","--esp-menu-group-indicator-color","--esp-menu-group-panel-background","--esp-menu-group-panel-shadow","--esp-menu-horizontal-justify-content","--esp-menu-item-active-background","--esp-menu-item-active-color","--esp-menu-item-active-font-weight","--esp-menu-item-active-indicator-color","--esp-menu-item-background","--esp-menu-item-border-color","--esp-menu-item-color","--esp-menu-item-font-family","--esp-menu-item-font-size","--esp-menu-item-font-weight","--esp-menu-item-hover-background","--esp-menu-item-hover-color","--esp-menu-item-hover-decoration","--esp-menu-item-hover-indicator-color","--esp-menu-item-icon-background","--esp-menu-item-icon-min-width","--esp-menu-item-icon-padding","--esp-menu-item-icon-size","--esp-menu-item-padding","--esp-menu-item-transition-duration","--esp-menu-scrim-color","--esp-menu-top-offset","--esp-page-background","--esp-page-background-image","--esp-page-background-image-opacity","--esp-page-canvas-background","--esp-page-canvas-background-attachment","--esp-page-canvas-background-image","--esp-page-canvas-background-image-opacity","--esp-page-fixed-header-offset","--esp-page-flyout-default-width","--esp-page-flyout-max-width","--esp-page-flyout-min-width","--esp-page-header-expanded-size","--esp-page-header-z-index","--esp-page-main-background","--esp-page-main-max-width","--esp-page-main-min-width","--esp-page-preview-background","--esp-page-preview-border","--esp-page-preview-default-width","--esp-page-preview-max-width","--esp-page-preview-min-width","--esp-page-preview-shadow","--esp-page-resize-focus-outline","--esp-page-resize-focus-shadow","--esp-page-resize-handle-hit-size","--esp-page-resize-large-step","--esp-page-resize-step","--esp-page-sticky-header-top","--esp-page-surface-border","--esp-page-surface-shadow","--esp-page-visible-header-offset","--esp-page-well-max-width","--esp-progress-border-color","--esp-progress-border-radius","--esp-progress-circle-size","--esp-progress-fill-color","--esp-progress-font-size","--esp-progress-height","--esp-progress-text-color","--esp-radio-button-focus-shadow","--esp-radio-button-icon-color","--esp-radio-button-size","--esp-repeater-background","--esp-repeater-border","--esp-repeater-border-radius","--esp-repeater-content-padding","--esp-repeater-gap","--esp-repeater-grid-column-gap","--esp-repeater-grid-columns","--esp-repeater-grid-row-gap","--esp-repeater-padding","--esp-row-gap","--esp-scheme","--esp-search-active-background","--esp-search-backdrop","--esp-search-border-color","--esp-search-highlight-background","--esp-search-loading-indicator-color","--esp-search-loading-indicator-track-color","--esp-search-max-height","--esp-search-max-width","--esp-search-muted-color","--esp-search-panel-background","--esp-search-panel-shadow","--esp-search-text-color","--esp-search-title-color","--esp-section-background","--esp-section-decoration-color","--esp-section-decoration-image","--esp-section-decoration-opacity","--esp-section-decoration-position","--esp-section-decoration-size","--esp-section-max-width","--esp-section-padding-block","--esp-section-padding-inline","--esp-seed-color","--esp-shadow-1","--esp-shadow-2","--esp-shadow-3","--esp-size-big","--esp-size-big-to-large","--esp-size-border-radius","--esp-size-box-padding","--esp-size-burger-stroke","--esp-size-color-picker-border-width","--esp-size-font","--esp-size-huge","--esp-size-large","--esp-size-large-to-huge","--esp-size-medium","--esp-size-medium-to-big","--esp-size-normal","--esp-size-normal-to-medium","--esp-size-padding","--esp-size-padding-page","--esp-size-section","--esp-size-small","--esp-size-small-to-normal","--esp-size-tiny","--esp-size-tiny-to-small","--esp-slider-focus-shadow","--esp-slider-thumb-border-color","--esp-slider-thumb-color","--esp-slider-thumb-shadow","--esp-slider-thumb-size","--esp-slider-track-border-radius","--esp-slider-track-color","--esp-slider-track-fill-color","--esp-slider-track-height","--esp-stack-gap","--esp-status-indicator-border-radius","--esp-status-indicator-height","--esp-status-indicator-popover-max-width","--esp-status-indicator-width","--esp-switch-focus-shadow","--esp-switch-height","--esp-switch-text-active-color","--esp-switch-text-font-size","--esp-switch-text-highlight-color","--esp-switch-text-inactive-color","--esp-switch-text-padding","--esp-switch-thumb-color","--esp-switch-thumb-size","--esp-switch-track-color","--esp-switch-track-color-on","--esp-switch-width","--esp-tab-color-background","--esp-tab-color-border","--esp-tab-color-button-active","--esp-tab-color-button-hover","--esp-tab-color-strip-background","--esp-tab-color-text","--esp-tab-size-padding","--esp-toaster-gap","--esp-toaster-padding","--esp-toaster-z-index","--esp-tooltip-background","--esp-tooltip-border","--esp-tooltip-border-radius","--esp-tooltip-color","--esp-tooltip-focus-outline","--esp-tooltip-font-size","--esp-tooltip-max-width","--esp-tooltip-padding","--esp-tooltip-shadow","--esp-tree-action-bg","--esp-tree-action-hover-bg","--esp-tree-action-size","--esp-tree-guide-color","--esp-tree-hover-bg","--esp-tree-icon-color","--esp-tree-indent-step","--esp-tree-node-padding","--esp-tree-row-bg","--esp-tree-row-border-color","--esp-tree-selected-bg","--esp-type-big","--esp-type-caption-color","--esp-type-caption-font-size","--esp-type-caption-font-weight","--esp-type-caption-letter-spacing","--esp-type-display-color","--esp-type-display-font-family","--esp-type-display-font-size","--esp-type-display-font-weight","--esp-type-display-letter-spacing","--esp-type-display-line-height","--esp-type-huge","--esp-type-label-color","--esp-type-label-font-size","--esp-type-label-font-weight","--esp-type-label-letter-spacing","--esp-type-large","--esp-type-lead-color","--esp-type-lead-font-size","--esp-type-lead-font-weight","--esp-type-lead-letter-spacing","--esp-type-medium","--esp-type-normal","--esp-type-overline-color","--esp-type-overline-font-size","--esp-type-overline-font-weight","--esp-type-overline-letter-spacing","--esp-type-overline-text-transform","--esp-type-small","--esp-type-tiny","--esp-vellum-background","--esp-vellum-background-image","--esp-vellum-background-image-opacity","--esp-vellum-opacity","--esp-video-accent","--esp-video-border-radius","--esp-video-focus-outline","--esp-video-message-background","--esp-video-message-color","--esp-video-object-fit","--esp-video-play-background","--esp-video-play-color","--esp-video-play-size","--esp-video-surface"]),o=Object.freeze(["^--esp-color-ramp-[a-z][a-z0-9-]*-(?:[1-9]|1[01])$"]);export{e as PUBLIC_TOKEN_NAMES,o as PUBLIC_TOKEN_PATTERNS};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { type SchemeEvents, type SeedColorRoot } from "./bus-events.js";
|
|
2
|
+
export type RootEventName = keyof SchemeEvents;
|
|
3
|
+
export type RootEventHandler<K extends RootEventName> = (payload: SchemeEvents[K]) => void;
|
|
4
|
+
/**
|
|
5
|
+
* Subscribe to one root-scoped theme event and discard payloads published by
|
|
6
|
+
* every other root sharing the global Espalier bus.
|
|
7
|
+
*
|
|
8
|
+
* This is the single filtering primitive behind both `esp-root`'s public
|
|
9
|
+
* subscription API and `EspalierElementBase`'s internal theme coordination.
|
|
10
|
+
*/
|
|
11
|
+
export declare function subscribeToRootEvent<K extends RootEventName>(root: SeedColorRoot, event: K, handler: RootEventHandler<K>): () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
class l{constructor(e){this.host=e,this.originalValues=new Map}apply(e){for(const t of this.originalValues.keys())Object.prototype.hasOwnProperty.call(e,t)||this.restoreScopedTokenProperty(t);for(const[t,r]of Object.entries(e))this.setScopedTokenProperty(t,r)}setScopedTokenProperty(e,t){const r=this.originalValues.get(e);if(r){const o=this.host.style.getPropertyValue(e),i=this.host.style.getPropertyPriority(e);(o!==r.generatedValue||i!==r.generatedPriority)&&(r.originalValue=o.length?o:null,r.originalPriority=i),r.generatedValue=t,r.generatedPriority=""}else{const o=this.host.style.getPropertyValue(e);this.originalValues.set(e,{generatedPriority:"",generatedValue:t,originalPriority:this.host.style.getPropertyPriority(e),originalValue:o.length?o:null})}this.host.style.setProperty(e,t)}restoreScopedTokenProperty(e){const t=this.originalValues.get(e);if(!t)return;const r=this.host.style.getPropertyValue(e),o=this.host.style.getPropertyPriority(e);(r!==t.generatedValue||o!==t.generatedPriority)&&(t.originalValue=r.length?r:null,t.originalPriority=o),t.originalValue===null?this.host.style.removeProperty(e):this.host.style.setProperty(e,t.originalValue,t.originalPriority),this.originalValues.delete(e)}clear(){for(const e of[...this.originalValues.keys()])this.restoreScopedTokenProperty(e)}}export{l as ScopedStyleDeclarations};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** Every semantic color token the system computes. */
|
|
2
|
+
export type SemanticColorName = "background" | "layer1" | "layer2" | "layer3" | "layer4" | "actionBackground" | "actionText" | "border" | "shadow" | "text" | "typeOverline" | "typeLabel" | "typeLead" | "typeCaption" | "dangerText" | "headings" | "headingsHover" | "link" | "linkHover" | "linkHoverBg" | "inputCaret" | "inputSelection" | "inputSelectionBg";
|
|
3
|
+
/** Ordered list of all semantic color token names. */
|
|
4
|
+
export declare const SEMANTIC_COLOR_NAMES: readonly SemanticColorName[];
|
|
5
|
+
/** `true` when `value` is one of the stable semantic color token names. */
|
|
6
|
+
export declare function isSemanticColorName(value: unknown): value is SemanticColorName;
|
|
7
|
+
/**
|
|
8
|
+
* Convert a {@link SemanticColorName} (camelCase) to its CSS
|
|
9
|
+
* custom-property name (kebab-case with `--esp-color-` prefix).
|
|
10
|
+
*
|
|
11
|
+
* ```
|
|
12
|
+
* linkHoverBg → --esp-color-link-hover-bg
|
|
13
|
+
* layer1 → --esp-color-layer-1
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare function semanticToCSS(name: SemanticColorName): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const t=["background","layer1","layer2","layer3","layer4","actionBackground","actionText","border","shadow","text","typeOverline","typeLabel","typeLead","typeCaption","dangerText","headings","headingsHover","link","linkHover","linkHoverBg","inputCaret","inputSelection","inputSelectionBg"];function o(e){return typeof e=="string"&&t.includes(e)}function r(e){return`--esp-color-${e.replace(/([A-Z])/g,"-$1").replace(/(\d)/g,"-$1").toLowerCase()}`}export{t as SEMANTIC_COLOR_NAMES,o as isSemanticColorName,r as semanticToCSS};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{SEMANTIC_COLOR_NAMES as g,semanticToCSS as h}from"./semantic-color-names.js";const s=Object.freeze({component:"esp-root",syntax:"color",default:"var(--esp-color-headings)",pairsWith:"--esp-color-background",targetLc:60,fitFallback:"--esp-color-headings"}),k=Object.freeze({"--esp-badge-background":Object.freeze({component:"esp-badge",syntax:"color",default:"var(--esp-color-layer-2)",fitFallback:"--esp-color-layer-2"}),"--esp-badge-color":Object.freeze({component:"esp-badge",syntax:"color",default:"var(--esp-color-text)",pairsWith:"--esp-badge-background",targetLc:75,fitFallback:"--esp-color-text"}),"--esp-badge-border-color":Object.freeze({component:"esp-badge",syntax:"color",default:"var(--esp-color-border)"}),"--esp-badge-link-background":Object.freeze({component:"esp-badge",syntax:"color",default:"var(--esp-color-background)",fitFallback:"--esp-color-background"}),"--esp-badge-link-border-color":Object.freeze({component:"esp-badge",syntax:"color",default:"var(--esp-color-link)"}),"--esp-badge-link-color":Object.freeze({component:"esp-badge",syntax:"color",default:"var(--esp-color-link)",pairsWith:"--esp-badge-link-background",targetLc:75,fitFallback:"--esp-color-link"}),"--esp-badge-link-hover-background":Object.freeze({component:"esp-badge",syntax:"color",default:"var(--esp-color-link-hover-bg)",fitFallback:"--esp-color-link-hover-bg"}),"--esp-badge-link-hover-border-color":Object.freeze({component:"esp-badge",syntax:"color",default:"var(--esp-color-link-hover)"}),"--esp-badge-link-hover-color":Object.freeze({component:"esp-badge",syntax:"color",default:"var(--esp-color-link-hover)",pairsWith:"--esp-badge-link-hover-background",targetLc:75,fitFallback:"--esp-color-link-hover"}),"--esp-badge-link-focus-background":Object.freeze({component:"esp-badge",syntax:"color",default:"var(--esp-color-link-hover-bg)",fitFallback:"--esp-color-link-hover-bg"}),"--esp-badge-link-focus-border-color":Object.freeze({component:"esp-badge",syntax:"color",default:"var(--esp-color-link-hover)"}),"--esp-badge-link-focus-color":Object.freeze({component:"esp-badge",syntax:"color",default:"var(--esp-color-link-hover)",pairsWith:"--esp-badge-link-focus-background",targetLc:75,fitFallback:"--esp-color-link-hover"}),"--esp-badge-link-focus-ring-color":Object.freeze({component:"esp-badge",syntax:"color",default:"var(--esp-color-link)"}),"--esp-blockquote-bar-color":Object.freeze({syntax:"color",default:"var(--esp-color-border)"}),"--esp-blockquote-glyph-color":Object.freeze({syntax:"color",default:"var(--esp-blockquote-bar-color, var(--esp-color-border))"}),"--esp-breadcrumb-color":Object.freeze({component:"esp-breadcrumb",syntax:"color",default:"var(--esp-color-link)",pairsWith:"--esp-color-background",targetLc:75,fitFallback:"--esp-color-link"}),"--esp-breadcrumb-hover-color":Object.freeze({component:"esp-breadcrumb",syntax:"color",default:"var(--esp-color-link-hover)",pairsWith:"--esp-breadcrumb-hover-background",targetLc:75,fitFallback:"--esp-color-link-hover"}),"--esp-breadcrumb-hover-background":Object.freeze({component:"esp-breadcrumb",syntax:"color",default:"var(--esp-color-link-hover-bg)",fitFallback:"--esp-color-link-hover-bg"}),"--esp-breadcrumb-current-color":Object.freeze({component:"esp-breadcrumb",syntax:"color",default:"var(--esp-breadcrumb-color, var(--esp-color-headings))",pairsWith:"--esp-color-background",targetLc:60,fitFallback:"--esp-color-headings"}),"--esp-breadcrumb-separator-color":Object.freeze({component:"esp-breadcrumb",syntax:"color",default:"color-mix(in oklch, var(--esp-breadcrumb-color, var(--esp-color-link)) 70%, transparent)"}),"--esp-breadcrumb-separator-size":Object.freeze({component:"esp-breadcrumb",syntax:"length",default:"var(--esp-size-normal-to-medium)",unit:"rem",min:.5,max:2}),"--esp-breadcrumb-separator-stroke-width":Object.freeze({component:"esp-breadcrumb",syntax:"number",default:"2",min:.5,max:6}),"--esp-footer-heading-size":Object.freeze({component:"esp-footer",syntax:"keyword",default:"normal",allowedValues:["small","normal","medium","big","large"],derives:{property:"--esp-footer-heading-font-size",values:{small:"var(--esp-type-small)",normal:"var(--esp-type-normal)",medium:"var(--esp-type-medium)",big:"var(--esp-type-big)",large:"var(--esp-type-large)"}}}),"--esp-footer-link-decoration":Object.freeze({component:"esp-footer",syntax:"keyword",default:"underline",allowedValues:["none","underline"]}),"--esp-footer-link-underline-offset":Object.freeze({component:"esp-footer",syntax:"length",default:"0.18em",unit:"em",min:0,max:.5}),"--esp-footer-link-underline-thickness":Object.freeze({component:"esp-footer",syntax:"length | keyword",default:"auto",unit:"em",min:0,max:.2,allowedValues:["auto"]}),"--esp-header-brand-logo-max-width":Object.freeze({component:"esp-header",syntax:"length",default:"12rem",unit:"rem",min:4,max:32}),"--esp-heading-1-color":s,"--esp-heading-2-color":s,"--esp-heading-3-color":s,"--esp-heading-4-color":s});function x(a){return typeof a=="string"&&Object.prototype.hasOwnProperty.call(k,a)}const O="--_esp-",c=/^--esp-[a-z0-9-]+$/,v=/^--_esp-[a-z0-9-]+$/,y=/^[a-z][a-z0-9-]*$/,l=new Set(g.map(h));function b(a,t){if(t.syntax!=="color"||!l.has(t.fitFallback??"")||t.allowedValues?.some(n=>!l.has(n)))throw new Error(`${a} must use an opaque semantic fit fallback and opaque pair values.`)}function z(a,t){const n=new Map(Object.entries(a)),i=new Set;for(const[r,e]of n){if(!c.test(r))throw new Error(`${r} must be a public --esp- property.`);if(t){const o=t.get(r);if(!o)throw new Error(`${r} is missing @cssprop documentation.`);if(e.component===void 0){if(o.category!=="shared-hook")throw new Error(`${r} has no component owner and must be documented as a shared hook.`)}else if(o.category!=="component"||o.component!==e.component)throw new Error(`${r} is documented for ${o.component??o.category}, not ${e.component}.`)}const u=e.syntax==="length"||e.syntax==="length | keyword",p=e.syntax==="keyword"||e.syntax==="length | keyword";if(u&&(e.unit!=="rem"&&e.unit!=="em"||e.min===void 0||e.max===void 0||!Number.isFinite(e.min)||!Number.isFinite(e.max)||e.min>e.max))throw new Error(`${r} must have a supported unit and finite, ordered length bounds.`);if(e.syntax==="number"&&(e.min===void 0||e.max===void 0||!Number.isFinite(e.min)||!Number.isFinite(e.max)||e.min>e.max))throw new Error(`${r} must have finite, ordered number bounds.`);if(p&&(!e.allowedValues?.length||!e.allowedValues.every(o=>y.test(o))))throw new Error(`${r} must declare its allowed keywords.`);if(e.pairsWith!==void 0){if(!(e.targetLc!==void 0&&Number.isFinite(e.targetLc)&&e.targetLc>0))throw new Error(`${r} must have a positive, finite contrast target.`);if(b(r,e),!l.has(e.pairsWith)){const o=n.get(e.pairsWith);if(!o||e.pairsWith===r||e.component===void 0||o.component!==e.component||o.pairsWith!==void 0)throw new Error(`${r} must pair with a semantic color or a same-component unpaired color.`);b(e.pairsWith,o)}}else if(e.targetLc!==void 0)throw new Error(`${r} declares a contrast target without a pair.`);if(e.derives){const{property:o,values:m}=e.derives,d=Object.keys(m);if(!p||!d.length||d.some(f=>!e.allowedValues?.includes(f)))throw new Error(`${r} may derive values only from its allowed keywords.`);if(n.has(o)||i.has(o))throw new Error(`${r} must derive a unique, non-settable output: ${o}.`);if(!c.test(o)&&!v.test(o))throw new Error(`${r} must derive a public --esp- or private --_esp- output.`);if(t&&c.test(o)&&!t.has(o))throw new Error(`${r} derives ${o}, which is missing @cssprop documentation.`);i.add(o)}}}export{O as PRIVATE_COMPONENT_PROPERTY_PREFIX,l as SEMANTIC_COLOR_PROPERTIES,k as SETTABLE_COMPONENT_PROPERTIES,z as assertRegistryInvariants,x as isSettableComponentPropertyName};
|