@taprootio/espalier 7.1.1 → 7.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +20 -0
- package/custom-elements.json +11675 -20250
- package/dist/badge/esp-badge.d.ts +7 -0
- package/dist/badge/esp-badge.js +11 -5
- package/dist/breadcrumbs/breadcrumb-separators.d.ts +4 -0
- package/dist/breadcrumbs/breadcrumb-separators.js +1 -0
- package/dist/breadcrumbs/esp-breadcrumb.d.ts +13 -14
- package/dist/breadcrumbs/esp-breadcrumb.js +6 -7
- package/dist/breadcrumbs/esp-breadcrumbs.d.ts +16 -9
- package/dist/breadcrumbs/esp-breadcrumbs.js +9 -6
- package/dist/button/paint-registration.js +1 -0
- package/dist/cli/theme-check.js +2 -2
- package/dist/font-picker/esp-font-picker.d.ts +11 -14
- package/dist/font-picker/esp-font-picker.js +5 -5
- package/dist/footer/esp-footer-link-group.js +1 -1
- package/dist/footer/esp-footer.d.ts +5 -0
- package/dist/footer/esp-footer.js +10 -4
- package/dist/footer/paint-registration.js +1 -0
- package/dist/header/esp-header-button.js +5 -1
- package/dist/header/esp-header.js +12 -8
- package/dist/header/header-geometry-controller.js +1 -1
- package/dist/header/is-tall-header-paint.d.ts +7 -0
- package/dist/header/is-tall-header-paint.js +1 -0
- package/dist/header/paint-registration.js +1 -0
- package/dist/index.d.ts +4 -2
- package/dist/index.js +1 -1
- package/dist/menu/esp-menu-group.js +8 -8
- package/dist/menu/esp-menu-item.js +8 -8
- package/dist/menu/esp-menu.js +10 -6
- package/dist/menu/navigation-focus-outline.js +8 -0
- package/dist/menu/navigation-paint.js +1 -0
- package/dist/menu/paint-registration.js +1 -0
- package/dist/pickers/esp-picker-item.js +1 -1
- package/dist/root/esp-root.d.ts +8 -1
- package/dist/root/esp-root.js +47 -10
- package/dist/root/helpers/compute-semantic-properties.js +1 -1
- package/dist/root/helpers/compute-theme-properties.js +1 -1
- package/dist/root/helpers/data-companion-properties.js +1 -1
- package/dist/root/helpers/lightness-ramp-properties.js +1 -1
- package/dist/shared/blockquote-styles.d.ts +3 -0
- package/dist/shared/blockquote-styles.js +4 -4
- package/dist/shared/color-engine.js +1 -1
- package/dist/shared/component-property-compiler.js +1 -0
- package/dist/shared/component-property-diagnostics.js +1 -0
- package/dist/shared/component-property-normalizer.js +1 -0
- package/dist/shared/component-property-resets.js +1 -0
- package/dist/shared/composed-dom.js +1 -0
- package/dist/shared/configured-brand-color.js +1 -0
- package/dist/shared/configured-brand.js +5 -5
- package/dist/shared/css-named-colors.js +1 -0
- package/dist/shared/document-sprite.js +1 -1
- package/dist/shared/esp-element-base.d.ts +3 -0
- package/dist/shared/esp-element-base.js +3 -3
- package/dist/shared/font-helpers.d.ts +3 -3
- package/dist/shared/font-helpers.js +1 -1
- package/dist/shared/font-plan.d.ts +1 -1
- package/dist/shared/governing-root.d.ts +24 -0
- package/dist/shared/governing-root.js +1 -0
- package/dist/shared/intent-values.js +1 -1
- package/dist/shared/paint-catalog.d.ts +27 -0
- package/dist/shared/paint-catalog.js +1 -0
- package/dist/shared/paint-color.d.ts +25 -0
- package/dist/shared/paint-color.js +1 -0
- package/dist/shared/paint-fit.js +1 -0
- package/dist/shared/paint-identity.js +1 -0
- package/dist/shared/paint-types.d.ts +88 -0
- package/dist/shared/paint-types.js +0 -0
- package/dist/shared/public-token-catalog.generated.js +1 -0
- package/dist/shared/root-event-subscription.d.ts +11 -0
- package/dist/shared/scoped-style-declarations.js +1 -0
- package/dist/shared/semantic-color-names.d.ts +16 -0
- package/dist/shared/semantic-color-names.js +1 -0
- package/dist/shared/settable-component-properties.js +1 -0
- package/dist/shared/theme-core.d.ts +808 -0
- package/dist/shared/theme-core.js +1 -0
- package/dist/shared/theme-fit-report.d.ts +39 -5
- package/dist/shared/theme-fit-report.js +1 -1
- package/dist/shared/theme-mapping-grammar.d.ts +16 -0
- package/dist/shared/theme-mapping-grammar.js +1 -0
- package/dist/shared/theme-properties.d.ts +3 -1
- package/dist/shared/theme-properties.js +1 -1
- package/dist/shared/theme-validation.d.ts +52 -0
- package/dist/shared/theme-validation.js +1 -0
- package/dist/shared/theme.d.ts +6 -899
- package/dist/shared/theme.js +1 -1
- package/dist/shared/token-pairings.d.ts +25 -0
- package/dist/shared/token-pairings.js +1 -0
- package/dist/shared/wcag-contrast.d.ts +14 -0
- package/dist/shared/wcag-contrast.js +1 -0
- package/dist/testing/index.d.ts +7 -0
- package/dist/testing/index.js +1 -0
- package/dist/testing/observe-paint.d.ts +29 -0
- package/dist/testing/observe-paint.iife.js +3 -0
- package/dist/testing/observe-paint.js +3 -0
- package/dist/testing/paint-bands.js +1 -0
- package/dist/testing/paint-coverage.d.ts +14 -0
- package/dist/testing/paint-coverage.js +1 -0
- package/dist/testing/paint-dom.js +1 -0
- package/dist/testing/svg-paint.js +1 -0
- package/espalier.css-data.json +62 -2
- package/espalier.token-manifest.json +5724 -29
- package/package.json +10 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import{css as g,html as
|
|
1
|
+
import{css as g,html as n,nothing as c}from"lit";import{resolveConfiguredBrandColor as i}from"./configured-brand-color.js";function m({scheme:o,brandLogo:r,brandColor:e,lightBrandLogo:a,darkBrandLogo:t,lightBrandColor:d,darkBrandColor:s}){return{brandLogo:(o==="dark"?t:a)||r,brandColor:i(o==="dark"?s:d,e)}}const B=g`3 / 1`,C=g`
|
|
2
2
|
.brand-logo {
|
|
3
3
|
overflow-wrap: anywhere;
|
|
4
4
|
}
|
|
5
|
-
`;function
|
|
6
|
-
${o&&t?
|
|
7
|
-
${n
|
|
8
|
-
`;return
|
|
5
|
+
`;function $({brandLogo:o,brandText:r,brandHref:e,brandAlt:a,reserveLogoSpace:t=!1}){if(!o&&!r)return c;const s=o?n`<img class="brand-logo" src=${o} alt=${a||(r?"":"Site logo")} />`:c,l=n`
|
|
6
|
+
${o&&t?n`<span class="brand-logo-reservation">${s}</span>`:s}
|
|
7
|
+
${r?n`<span class="brand-text">${r}</span>`:c}
|
|
8
|
+
`;return e?n`<a class="configured-brand" href=${e}>${l}</a>`:n`<span class="configured-brand">${l}</span>`}export{B as CONFIGURED_BRAND_LOGO_ASPECT_RATIO,C as configuredBrandLogoGeometry,$ as renderConfiguredBrand,m as resolveConfiguredBrand};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=Object.freeze({aliceblue:"#f0f8ff",antiquewhite:"#faebd7",aqua:"#00ffff",aquamarine:"#7fffd4",azure:"#f0ffff",beige:"#f5f5dc",bisque:"#ffe4c4",black:"#000000",blanchedalmond:"#ffebcd",blue:"#0000ff",blueviolet:"#8a2be2",brown:"#a52a2a",burlywood:"#deb887",cadetblue:"#5f9ea0",chartreuse:"#7fff00",chocolate:"#d2691e",coral:"#ff7f50",cornflowerblue:"#6495ed",cornsilk:"#fff8dc",crimson:"#dc143c",cyan:"#00ffff",darkblue:"#00008b",darkcyan:"#008b8b",darkgoldenrod:"#b8860b",darkgray:"#a9a9a9",darkgreen:"#006400",darkgrey:"#a9a9a9",darkkhaki:"#bdb76b",darkmagenta:"#8b008b",darkolivegreen:"#556b2f",darkorange:"#ff8c00",darkorchid:"#9932cc",darkred:"#8b0000",darksalmon:"#e9967a",darkseagreen:"#8fbc8f",darkslateblue:"#483d8b",darkslategray:"#2f4f4f",darkslategrey:"#2f4f4f",darkturquoise:"#00ced1",darkviolet:"#9400d3",deeppink:"#ff1493",deepskyblue:"#00bfff",dimgray:"#696969",dimgrey:"#696969",dodgerblue:"#1e90ff",firebrick:"#b22222",floralwhite:"#fffaf0",forestgreen:"#228b22",fuchsia:"#ff00ff",gainsboro:"#dcdcdc",ghostwhite:"#f8f8ff",gold:"#ffd700",goldenrod:"#daa520",gray:"#808080",green:"#008000",greenyellow:"#adff2f",grey:"#808080",honeydew:"#f0fff0",hotpink:"#ff69b4",indianred:"#cd5c5c",indigo:"#4b0082",ivory:"#fffff0",khaki:"#f0e68c",lavender:"#e6e6fa",lavenderblush:"#fff0f5",lawngreen:"#7cfc00",lemonchiffon:"#fffacd",lightblue:"#add8e6",lightcoral:"#f08080",lightcyan:"#e0ffff",lightgoldenrodyellow:"#fafad2",lightgray:"#d3d3d3",lightgreen:"#90ee90",lightgrey:"#d3d3d3",lightpink:"#ffb6c1",lightsalmon:"#ffa07a",lightseagreen:"#20b2aa",lightskyblue:"#87cefa",lightslategray:"#778899",lightslategrey:"#778899",lightsteelblue:"#b0c4de",lightyellow:"#ffffe0",lime:"#00ff00",limegreen:"#32cd32",linen:"#faf0e6",magenta:"#ff00ff",maroon:"#800000",mediumaquamarine:"#66cdaa",mediumblue:"#0000cd",mediumorchid:"#ba55d3",mediumpurple:"#9370db",mediumseagreen:"#3cb371",mediumslateblue:"#7b68ee",mediumspringgreen:"#00fa9a",mediumturquoise:"#48d1cc",mediumvioletred:"#c71585",midnightblue:"#191970",mintcream:"#f5fffa",mistyrose:"#ffe4e1",moccasin:"#ffe4b5",navajowhite:"#ffdead",navy:"#000080",oldlace:"#fdf5e6",olive:"#808000",olivedrab:"#6b8e23",orange:"#ffa500",orangered:"#ff4500",orchid:"#da70d6",palegoldenrod:"#eee8aa",palegreen:"#98fb98",paleturquoise:"#afeeee",palevioletred:"#db7093",papayawhip:"#ffefd5",peachpuff:"#ffdab9",peru:"#cd853f",pink:"#ffc0cb",plum:"#dda0dd",powderblue:"#b0e0e6",purple:"#800080",rebeccapurple:"#663399",red:"#ff0000",rosybrown:"#bc8f8f",royalblue:"#4169e1",saddlebrown:"#8b4513",salmon:"#fa8072",sandybrown:"#f4a460",seagreen:"#2e8b57",seashell:"#fff5ee",sienna:"#a0522d",silver:"#c0c0c0",skyblue:"#87ceeb",slateblue:"#6a5acd",slategray:"#708090",slategrey:"#708090",snow:"#fffafa",springgreen:"#00ff7f",steelblue:"#4682b4",tan:"#d2b48c",teal:"#008080",thistle:"#d8bfd8",tomato:"#ff6347",turquoise:"#40e0d0",violet:"#ee82ee",wheat:"#f5deb3",white:"#ffffff",whitesmoke:"#f5f5f5",yellow:"#ffff00",yellowgreen:"#9acd32"});export{e as CSS_NAMED_COLORS};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{classifyIconSpriteValue as
|
|
1
|
+
import{classifyIconSpriteValue as W}from"./intent-values.js";import{GoverningRootObserver as D}from"./governing-root.js";const E="data-esp-adopted-icons",A="http://www.w3.org/2000/svg",N=new Set;function Q(){N.clear()}function C(e,t){N.has(e)||(N.add(e),console.warn(t))}const y=new Map,g=new WeakMap;function P(e,t){const n=g.get(t);if(n===e)return;n&&$(n,t),g.set(t,e);let o=y.get(e);if(!o){const s=new Set,c=new MutationObserver(a=>{if(a.some(f=>f.target===e||e.contains(f.target)||[...f.removedNodes].some(i=>i===e||i.contains(e))||[...f.addedNodes].some(i=>i===e||i.contains(e))))for(const f of s)f.requestUpdate()});c.observe(e,{attributes:!0,characterData:!0,childList:!0,subtree:!0});const u=e.ownerDocument?.documentElement;u&&c.observe(u,{childList:!0,subtree:!0}),o={hosts:s,observer:c},y.set(e,o)}o.hosts.add(t)}function $(e,t){const n=y.get(e);n&&(n.hosts.delete(t),n.hosts.size===0&&(n.observer.disconnect(),y.delete(e)))}function w(e){const t=g.get(e);t&&($(t,e),g.delete(e)),U(e)}const O=new WeakMap,v=new WeakMap;function V(e,t,n){const o=v.get(n);o&&(o.document!==e||o.spriteId!==t)&&U(n);let s=O.get(e);s||(s=new Map,O.set(e,s));let c=s.get(t);if(!c){const u=new Set,a=new MutationObserver(()=>{if(e.getElementById(t)){a.disconnect(),s.delete(t);for(const p of u)v.delete(p),p.requestUpdate()}});a.observe(e.documentElement,{childList:!0,subtree:!0}),c={hosts:u,observer:a},s.set(t,c)}c.hosts.add(n),v.set(n,{document:e,spriteId:t})}function U(e){const t=v.get(e);if(!t)return;v.delete(e);const n=O.get(t.document),o=n?.get(t.spriteId);o&&(o.hosts.delete(e),o.hosts.size===0&&(o.observer.disconnect(),n.delete(t.spriteId)))}function z(e,t,n){if(!t)return;const o=W(e?e.iconSpriteUrl:null);let s=t.querySelector(`svg[${E}]`);if(o.kind!=="document"){s?.remove(),n&&w(n);return}const c=new Set;for(const i of t.querySelectorAll("use")){if(s&&s.contains(i))continue;const l=_(i);l&&c.add(l)}if(c.size===0&&!s){n&&w(n);return}const u=e?.ownerDocument??document,a=u.getElementById(o.spriteId);if(!a){if(C(o.spriteId,`Espalier icons: icon-sprite-url references "#${o.spriteId}" but no element with that id is in the document. Inline the sprite before setting icon-sprite-url (or set it again after), and icons will render.`),s?.remove(),n){const i=g.get(n);i&&($(i,n),g.delete(n)),V(u,o.spriteId,n)}return}if(n&&U(n),a.namespaceURI!==A||a.localName!=="svg"){C(o.spriteId,`Espalier icons: icon-sprite-url references "#${o.spriteId}", but that element is a <${a.localName}>, not an inline SVG sprite. Icons stay empty until the id names an <svg> containing <symbol>s.`),s?.remove(),n&&w(n);return}n&&P(a,n);{const i=new Set,l=[...c];for(;l.length>0;){const r=l.pop();if(i.has(r))continue;i.add(r);const d=M(a,r);if(d)for(const m of X(d))i.has(m)||(c.add(m),l.push(m))}}s&&s.getAttribute(E)!==o.spriteId&&(s.remove(),s=null);const p=new Map,f=i=>{const l=M(a,i);return l?{clone:j(l,a,o.spriteId,p)?l.cloneNode(!0):null,source:l}:{clone:null,source:null}};if(s){for(const i of[...s.children]){const l=i.getAttribute("id")??"",{clone:r,source:d}=c.has(l)?f(l):{clone:null,source:null};!r||!d?i.remove():i.isEqualNode(d)||s.replaceChild(r,i)}s.children.length===0&&c.size===0&&(s.remove(),s=null)}for(const i of c){if(s?.querySelector(`#${R(i)}`))continue;const{clone:l}=f(i);if(l){if(!s){s=t.ownerDocument.createElementNS(A,"svg"),s.setAttribute(E,o.spriteId),s.setAttribute("aria-hidden","true");const r=s.style;r.position="absolute",r.width="0",r.height="0",r.overflow="hidden",t.appendChild(s)}s.appendChild(l)}}}const q="http://www.w3.org/1999/xlink",B=new Set(["a","animate","animatemotion","animatetransform","discard","foreignobject","script","set","style"]),F=["href","xlink:href"],G=/url\(/giu,H=/url\(\s*(?:"#([^"\\]*)"|'#([^'\\]*)'|#([^\s)"'\\]*))\s*\)/giu;function I(e){let t=!1;const n=e.replace(/(%[0-9A-Fa-f]{2})+/gu,o=>{try{return decodeURIComponent(o)}catch{return t=!0,o}});return t?null:n}function L(e){const t=[...e.matchAll(G)].length,n=[];for(const o of e.matchAll(H)){const s=o[1]??o[2]??o[3]??"";if(s.length===0)continue;const c=I(s);c!==null&&n.push(c)}return{ids:n,ok:n.length===t}}function _(e){const t=x(e);return t===null?null:I(t)}function x(e){if(e.localName!=="use")return null;const t=e.getAttribute("href")??e.getAttribute("xlink:href")??e.getAttributeNS(q,"href");if(!t)return null;const n=t.trim();return n.startsWith("#")&&n.length>1?n.slice(1):null}function j(e,t,n,o){const s=o.get(e);if(s!==void 0)return s;const c=new Map,u=[],a=new Map,p=r=>(a.has(r)||a.set(r,M(t,r)),a.get(r)??null),f=[e];for(;f.length>0;){const r=f.pop();if(c.has(r))continue;const d=o.get(r);if(d!==void 0){c.set(r,{dependencies:[],localOk:d,missing:[]}),u.push(r);continue}const m=K(r,n),b=[],S=[];for(const T of m.dependencyIds){const k=p(T);k?(b.push(k),f.push(k)):S.push(T)}c.set(r,{dependencies:b,localOk:m.ok,missing:S}),u.push(r)}const i=new Set;for(const r of u){const d=c.get(r);(!d.localOk||d.missing.length>0)&&i.add(r)}let l=!0;for(;l;){l=!1;for(const r of u)i.has(r)||c.get(r).dependencies.some(d=>i.has(d))&&(i.add(r),l=!0)}for(const r of u){const d=c.get(r),m=!i.has(r);if(!m&&d.localOk){const b=d.missing[0]??d.dependencies.find(S=>i.has(S))?.getAttribute("id")??"?";h(r,n,d.missing.length>0?`composes or paints through #${b}, which is not in the sprite`:`composes or paints through the refused member #${b}`)}o.set(r,m)}return o.get(e)}function K(e,t){const n=[],o=[e,...e.querySelectorAll("*")];for(const s of o){if(s.namespaceURI!==A)return h(e,t,`contains the non-SVG element <${s.localName}>`),{dependencyIds:n,ok:!1};if(B.has(s.localName.toLowerCase()))return h(e,t,`contains <${s.localName}>`),{dependencyIds:n,ok:!1};let c=s.getAttributeNS(q,"href")!==null;for(const p of s.getAttributeNames()){const f=p.toLowerCase();if(f.startsWith("on"))return h(e,t,`carries the event-handler attribute ${p}`),{dependencyIds:n,ok:!1};if(F.includes(f)&&(c=!0),f==="src")return h(e,t,"carries a src attribute"),{dependencyIds:n,ok:!1};if(f==="style")return h(e,t,"carries an inline style attribute \u2014 use presentation attributes"),{dependencyIds:n,ok:!1};const i=s.getAttribute(p)??"";if(i.includes("\\"))return h(e,t,`carries a CSS escape sequence in ${p}`),{dependencyIds:n,ok:!1};const l=L(i);if(!l.ok)return h(e,t,`carries an unparseable or external url() reference in ${p}`),{dependencyIds:n,ok:!1};n.push(...l.ids)}const u=x(s),a=u===null?null:I(u);if(u!==null&&a===null)return h(e,t,`composes <use href="#${u}">, an undecodable fragment the browser resolves to nothing`),{dependencyIds:n,ok:!1};if(c&&a===null)return h(e,t,"carries an href outside a local-fragment <use> reference"),{dependencyIds:n,ok:!1};a!==null&&n.push(a)}return{dependencyIds:n,ok:!0}}function h(e,t,n){const o=e.getAttribute("id")??"(unnamed)";C(`${t}#${o}`,`Espalier icons: symbol "${o}" in "#${t}" ${n} and was not adopted \u2014 sprite symbols must be passive SVG (shapes, paths, local <use> composition).`)}function M(e,t){if(!t)return null;const o=e.querySelector(`symbol#${R(t)}`)??e.querySelector(`#${R(t)}`);return o&&o.namespaceURI===A?o:null}function X(e){const t=new Set,n=[e,...e.querySelectorAll("*")];for(const o of n){const s=_(o);s&&t.add(s);for(const c of o.getAttributeNames())for(const u of L(o.getAttribute(c)??"").ids)t.add(u)}return t}function R(e){const t=globalThis.CSS?.escape;return t?t(e):e.replace(/[^A-Za-z0-9_-]/gu,"\\$&")}class Y{constructor(t,n){this.host=t,this.sharedRootObserver=n,this.rootObserver=n??new D(t,(o,s)=>{o!==s&&(w(t),t.requestUpdate())}),n||this.rootObserver.subscribe("icon-sprite-url-changed",()=>t.requestUpdate()),t.addController(this)}hostConnected(){this.sharedRootObserver||this.rootObserver.connect()}hostDisconnected(){this.sharedRootObserver||this.rootObserver.disconnect(),w(this.host)}hostUpdated(){const t=this.rootObserver.refresh();z(t,this.host.shadowRoot,this.host)}}export{Y as DocumentSpriteController,z as adoptDocumentSpriteSymbols,I as decodeFragmentId,Q as resetWarnedMissingSprites};
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { LitElement, type PropertyValues } from "lit";
|
|
2
2
|
import { type SeedColorRoot } from "./bus-events.js";
|
|
3
|
+
import { type EspalierRoot } from "../root/esp-root.js";
|
|
3
4
|
import { type EspalierIntentVariant } from "./intent-values.js";
|
|
4
5
|
/**
|
|
5
6
|
* Shared base class for Espalier elements.
|
|
@@ -69,6 +70,8 @@ export declare class EspalierElementBase extends LitElement implements SeedColor
|
|
|
69
70
|
connectedCallback(): void;
|
|
70
71
|
disconnectedCallback(): void;
|
|
71
72
|
protected firstUpdated(_changedProperties: PropertyValues): void;
|
|
73
|
+
/** Called when this host gains, loses or changes its nearest root. */
|
|
74
|
+
protected governingRootChanged(_root: EspalierRoot | null): void;
|
|
72
75
|
constructor();
|
|
73
76
|
/**
|
|
74
77
|
* Traverse up the DOM tree to find the closest element that
|
|
@@ -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 Y}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,{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, ${Y(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,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};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { type PaintColor } from "./paint-color.js";
|
|
2
|
+
import type { PaintColorEnvironment, PaintDerivation, PaintDerivations, PaintEntriesByRole, PaintEntry, PaintKind, PaintNavigationFact, PaintRegistration, PaintSchemeFeatures, PaintTarget, PaintTargetsByRole } from "./paint-types.js";
|
|
3
|
+
export declare const PAINT_TOKEN_IDS: readonly string[];
|
|
4
|
+
export declare const BRAND_PAINT_ID = "brand-color";
|
|
5
|
+
export declare function paintTokenProperty(identifier: string): string | undefined;
|
|
6
|
+
export declare function isPaintName(value: unknown): value is string;
|
|
7
|
+
export declare function isPaintRole(value: unknown): value is string;
|
|
8
|
+
export declare function isPaintKind(value: unknown): value is PaintKind;
|
|
9
|
+
export declare function isPaintFlags(value: unknown): value is readonly string[];
|
|
10
|
+
export declare function isPaintNavigationFact(value: unknown): value is PaintNavigationFact;
|
|
11
|
+
export declare function validatePaintEntries(entriesByRole: unknown, derivations?: PaintDerivations): asserts entriesByRole is PaintEntriesByRole;
|
|
12
|
+
interface PaintCatalog {
|
|
13
|
+
entriesByRole: PaintEntriesByRole;
|
|
14
|
+
targets: PaintTargetsByRole;
|
|
15
|
+
derivations: PaintDerivations;
|
|
16
|
+
}
|
|
17
|
+
/** Assemble component registrations without giving any role special treatment. */
|
|
18
|
+
export declare function createPaintCatalog(registrations: readonly PaintRegistration[]): PaintCatalog;
|
|
19
|
+
export declare const PAINT_CATALOG: Readonly<Record<string, readonly PaintEntry[]>>;
|
|
20
|
+
export declare const PAINT_TARGETS: Readonly<Record<string, readonly PaintTarget[]>>;
|
|
21
|
+
export declare const PAINT_DERIVATIONS: Readonly<Record<string, PaintDerivation>>;
|
|
22
|
+
/** Select rendered entries and resolve brand ink using the active scheme's configured override. */
|
|
23
|
+
export declare function enabledPaintEntries(role: string, features: PaintSchemeFeatures, entriesByRole?: PaintEntriesByRole, { brandColor }?: {
|
|
24
|
+
brandColor?: string;
|
|
25
|
+
}): readonly PaintEntry[];
|
|
26
|
+
export declare function resolvePaintColor(identifier: string, environment: PaintColorEnvironment, derivations?: PaintDerivations): PaintColor | null;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{buttonPaintRegistration as y}from"../button/paint-registration.js";import{footerPaintRegistration as w}from"../footer/paint-registration.js";import{headerPaintRegistration as T}from"../header/paint-registration.js";import{menuPaintRegistration as j}from"../menu/paint-registration.js";import{resolveConfiguredBrandColor as v}from"./configured-brand-color.js";import{parsePaintColor as x}from"./paint-color.js";import{COLOR_SOURCES as A,SEMANTIC_COLOR_NAMES as E,isObjectRecord as p,semanticToCSS as R}from"./theme.js";const u=new Map([...E.map(t=>[t,R(t)]),...A.map(t=>[t,`--esp-color-${t}`])]),U=Object.freeze([...u.keys()]),l="brand-color";function f(t,e){return Object.prototype.hasOwnProperty.call(t,e)}function V(t){return u.get(t)}function c(t){return typeof t=="string"&&t.trim()!==""}function N(t){return c(t)&&t===t.trim()}function C(t){return t==="text"||t==="graphic"||t==="ring"}function $(t){return Array.isArray(t)&&Array.from(t).every(c)}const g={depth:t=>t==="top-level"||t==="nested",kind:t=>t==="button"||t==="plain"||t==="group",anchor:t=>typeof t=="boolean",canBeCurrent:t=>typeof t=="boolean",icon:t=>t===void 0||typeof t=="boolean"};function H(t){return p(t)&&Object.entries(g).every(([e,n])=>n(t[e]))}const k={element:!0,foreground:!0,background:!0,state:!0,kind:!0,flags:!0,navigation:!0,indicator:!0,paintOpacity:!0};function S(t){return p(t)&&Object.entries(t).every(([e,n])=>f(g,e)&&g[e](n))}function I(t,e,n){if(!p(t)||!Object.keys(t).every(o=>f(k,o))||!c(t.element)||!c(t.state)||!C(t.kind)||!$(t.flags))throw new TypeError(`${e} is not a paint entry.`);for(const o of["foreground","background"]){const r=t[o];if(!c(r)||!(u.has(r)||f(n,r)||o==="foreground"&&r===l))throw new TypeError(`${e} has an unknown ${o} paint identifier "${String(r)}".`)}if(t.paintOpacity!==void 0&&(typeof t.paintOpacity!="number"||!Number.isFinite(t.paintOpacity)||t.paintOpacity<0||t.paintOpacity>1))throw new TypeError(`${e} has an invalid paint opacity.`);if(t.navigation!==void 0&&!S(t.navigation))throw new TypeError(`${e} has an invalid navigation predicate.`);if(t.indicator!==void 0&&(t.indicator!=="blurred-shadow"||t.kind==="text"))throw new TypeError(`${e} has an invalid indicator.`)}function _(t,e=O){if(!p(t))throw new TypeError("Paint entries must be grouped by role.");for(const[n,o]of Object.entries(t)){if(!N(n)||!Array.isArray(o))throw new TypeError(`Paint entries for role "${n}" must be an array on a nonempty role without outer whitespace.`);for(let r=0;r<o.length;r+=1)I(o[r],`Paint entry for "${n}" at index ${r}`,e)}}function z(t){const e=Object.create(null),n=Object.create(null),o=Object.create(null);for(const r of t)for(const[i,a]of Object.entries(r.derivations??{})){if(!c(i)||i===l||u.has(i)||i in o)throw new TypeError(`Paint derivation "${i}" must have a unique identifier.`);o[i]=a}for(const r of t){_(r.entriesByRole,o);for(const[i,a]of Object.entries(r.entriesByRole))(e[i]??=[]).push(...a);for(const[i,a]of Object.entries(r.targets))(n[i]??=[]).push(...a)}for(const r of Object.values(e))Object.freeze(r);for(const r of Object.values(n))Object.freeze(r);return{entriesByRole:Object.freeze(e),targets:Object.freeze(n),derivations:Object.freeze(o)}}const b=z([T,w,j,y]),B=b.entriesByRole,J=b.targets,O=b.derivations;function Q(t,e,n=B,{brandColor:o}={}){const r=f(n,t)?n[t]:[],i=new Set(e.flags),a=r.filter(s=>{if(!s.flags.every(d=>i.has(d)))return!1;if(s.navigation===void 0)return!0;const m=Object.entries(s.navigation);return e.navigation.some(d=>m.every(([P,h])=>d[P]===h))});return v(o)?a:a.map(s=>s.foreground===l?{...s,foreground:"headings"}:s)}function W(t,e,n=O){if(f(n,t))return n[t](e);const o=e.readColor(t);return o?x(o):null}export{l as BRAND_PAINT_ID,B as PAINT_CATALOG,O as PAINT_DERIVATIONS,J as PAINT_TARGETS,U as PAINT_TOKEN_IDS,z as createPaintCatalog,Q as enabledPaintEntries,$ as isPaintFlags,C as isPaintKind,c as isPaintName,H as isPaintNavigationFact,N as isPaintRole,V as paintTokenProperty,W as resolvePaintColor,_ as validatePaintEntries};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { PaintKind } from "./paint-types.js";
|
|
2
|
+
/** Gamma-encoded sRGB and alpha, with all channels in 0–1. */
|
|
3
|
+
export interface PaintColor {
|
|
4
|
+
r: number;
|
|
5
|
+
g: number;
|
|
6
|
+
b: number;
|
|
7
|
+
alpha: number;
|
|
8
|
+
}
|
|
9
|
+
/** Parse absolute CSS paint, retaining its declared alpha. */
|
|
10
|
+
export declare function parsePaintColor(value: string): PaintColor | null;
|
|
11
|
+
/** Change the lightness channel of a relative OKLCH color. */
|
|
12
|
+
export declare function derivePaintLightness(value: string | undefined, lightness: (original: number) => number): PaintColor | null;
|
|
13
|
+
/** Composite foreground over background using CSS source-over alpha. */
|
|
14
|
+
export declare function compositePaint(foreground: PaintColor, background: PaintColor): PaintColor;
|
|
15
|
+
export declare const MIN_SHADOW_INDICATOR_BLUR = 3;
|
|
16
|
+
export declare const MAX_SHADOW_INDICATOR_BLUR = 4;
|
|
17
|
+
export declare const SHADOW_INDICATOR_SAMPLE_OFFSET = 0.1;
|
|
18
|
+
export declare const SHADOW_INDICATOR_MARGIN_SIGMAS = 4;
|
|
19
|
+
export declare function supportsShadowIndicatorBlur(blur: number): boolean;
|
|
20
|
+
/** Lower coverage estimate at the supported straight edge. Hard bands use full alpha. */
|
|
21
|
+
export declare function shadowIndicatorAlpha(shadow: {
|
|
22
|
+
alpha: number;
|
|
23
|
+
blur: number;
|
|
24
|
+
}): number;
|
|
25
|
+
export declare function paintRequiredRatio(kind: PaintKind): 3 | 4.5;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{clampChannel as l,gamutMapToSRGB as n,oklabToOklch as A,oklchToSRGB as e,parseCssColorValue as c,srgbToOklab as _}from"./color-engine.js";import{AA_NON_TEXT_RATIO as I,AA_TEXT_RATIO as O}from"./wcag-contrast.js";function b(t){const a=c(t,!0);if(!a)return null;const r=a.space==="oklch"?e(n(a.color)):a.color;return{r:l(r.r),g:l(r.g),b:l(r.b),alpha:a.alpha}}function M(t,a){const r=t&&c(t,!0);if(!r)return null;const p=r.space==="oklch"?r.color:A(_(r.color)),o=e(n({...p,l:l(a(p.l))}));return{r:l(o.r),g:l(o.g),b:l(o.b),alpha:r.alpha}}function C(t,a){if(t.alpha===0)return a;if(t.alpha===1||a.alpha===0)return t;const r=a.alpha*(1-t.alpha),p=t.alpha+r;return{r:(t.r*t.alpha+a.r*r)/p,g:(t.g*t.alpha+a.g*r)/p,b:(t.b*t.alpha+a.b*r)/p,alpha:p}}const s=3,R=4,T=.1,h=4;function u(t){return t>=s&&t<=R}const i=1/Math.sqrt(2*Math.PI),x=i*Math.exp(-(h**2)/2)/h,S=.5-T/(s/2)*i-3*x-.05;function E(t){if(t.blur===0)return t.alpha;if(!u(t.blur))throw new RangeError(`Unsupported shadow indicator blur ${t.blur}px. Expected 3\u20134px.`);return t.alpha*S}function m(t){return t==="text"?O:I}export{R as MAX_SHADOW_INDICATOR_BLUR,s as MIN_SHADOW_INDICATOR_BLUR,h as SHADOW_INDICATOR_MARGIN_SIGMAS,T as SHADOW_INDICATOR_SAMPLE_OFFSET,C as compositePaint,M as derivePaintLightness,m as paintRequiredRatio,b as parsePaintColor,E as shadowIndicatorAlpha,u as supportsShadowIndicatorBlur};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{resolveConfiguredBrandColor as N}from"./configured-brand-color.js";import{BRAND_PAINT_ID as k,PAINT_CATALOG as B,PAINT_DERIVATIONS as q,enabledPaintEntries as O,isPaintFlags as D,isPaintName as j,isPaintNavigationFact as x,isPaintRole as M,paintTokenProperty as L,resolvePaintColor as S,validatePaintEntries as F}from"./paint-catalog.js";import{compositePaint as W,MIN_SHADOW_INDICATOR_BLUR as H,paintRequiredRatio as G,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 K}from"./settable-component-properties.js";import{isObjectRecord as p,semanticToCSS as Q}from"./theme-core.js";import{wcagRatio as X}from"./wcag-contrast.js";const Y=["light","dark"],Z=new Set(Object.entries(K).flatMap(([t,{derives:e}])=>e?[t,e.property]:[t]));function rr(t){return p(t)&&D(t.flags)&&Array.isArray(t.navigation)&&Array.from(t.navigation).every(x)}function tr(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)||!M(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&&!j(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)||!Y.every(r=>rr(i[r])))throw new TypeError(`Paint surface "${o}" requires light and dark feature facts.`)}}function er(t,e,a,o,l,s){const{role:i}=t,r=t.context??null,c=a.get(null),h=a.get(r);if(!c||!h)throw new Error(`Paint surface "${i}" requests undefined ${e} context "${r}".`);const d=N(t.brandColors?.[e],t.brandColors?.generic),P=n=>n==="--_esp-context-shadow"?r===null?void 0:h[Q("shadow")]:J.has(n)||Z.has(n)||n.startsWith("--esp-l-")||n==="--_esp-surface-polarity"?h[n]:c[n],E={scheme:e,context:r,readProperty:P,readColor:n=>{if(n===k)return d?.startsWith("--esp-color-")?P(d):d;const f=L(n);return f&&P(f)}},T=t.features[e],g={brandColor:d},b=[...O(i,T,o.entriesByRole,g),...O(i,T,l,g)],I=[...V(b).values()].map(n=>{const{element:f,foreground:w,background:m,kind:R,state:A}=n,y=S(w,E,o.derivations),u=S(m,E,o.derivations);if(!y||!u||u.alpha!==1)throw new Error(`Paint surface "${i}" (${e}) cannot resolve "${f}" ${A}: ${w} on opaque ${m}.`);const $=y.alpha*(n.paintOpacity??1),v=U({alpha:$,blur:n.indicator==="blurred-shadow"?H:0}),_=W({...y,alpha:v},u),C={element:f,foreground:w,background:m,state:A,kind:R,ratio:X(_,u),required:G(R)};return s?.(e,z({role:i,...n}),C),C});return{role:i,context:r,pairs:I}}function fr(t,e,a={},o={entriesByRole:B,derivations:q},l){tr(e),F(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=>er(c,r,t[r],o,a,l));return{light:i("light"),dark:i("dark")}}export{fr as measurePaintSurfaces};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function i(t){return JSON.stringify([t.role,t.element,t.state,t.kind,t.foreground,t.background,t.indicator,t.paintOpacity??1])}function d(t){const n=new Map;for(const e of t){const o=i(e);n.has(o)||n.set(o,e)}return n}export{d as firstPaintByIdentity,i as paintIdentity};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import type { PaintColor } from "./paint-color.js";
|
|
2
|
+
export type PaintScheme = "light" | "dark";
|
|
3
|
+
export type PaintKind = "text" | "graphic" | "ring";
|
|
4
|
+
export interface PaintNavigationFact {
|
|
5
|
+
depth: "top-level" | "nested";
|
|
6
|
+
kind: "button" | "plain" | "group";
|
|
7
|
+
anchor: boolean;
|
|
8
|
+
canBeCurrent: boolean;
|
|
9
|
+
icon?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface PaintSchemeFeatures {
|
|
12
|
+
flags: readonly string[];
|
|
13
|
+
navigation: readonly PaintNavigationFact[];
|
|
14
|
+
}
|
|
15
|
+
export interface PaintEntry {
|
|
16
|
+
element: string;
|
|
17
|
+
foreground: string;
|
|
18
|
+
background: string;
|
|
19
|
+
state: string;
|
|
20
|
+
kind: PaintKind;
|
|
21
|
+
flags: readonly string[];
|
|
22
|
+
navigation?: Partial<PaintNavigationFact>;
|
|
23
|
+
indicator?: "blurred-shadow";
|
|
24
|
+
/** Paint coverage applied outside the declared color, such as SVG stroke-opacity. Defaults to 1. */
|
|
25
|
+
paintOpacity?: number;
|
|
26
|
+
}
|
|
27
|
+
export interface PaintFitSurface {
|
|
28
|
+
role: string;
|
|
29
|
+
/** A null or omitted context selects the root theme. */
|
|
30
|
+
context?: string | null;
|
|
31
|
+
brandColors?: {
|
|
32
|
+
light?: string;
|
|
33
|
+
dark?: string;
|
|
34
|
+
generic?: string;
|
|
35
|
+
};
|
|
36
|
+
features: Record<PaintScheme, PaintSchemeFeatures>;
|
|
37
|
+
}
|
|
38
|
+
export interface PaintFitPair {
|
|
39
|
+
element: string;
|
|
40
|
+
foreground: string;
|
|
41
|
+
background: string;
|
|
42
|
+
state: string;
|
|
43
|
+
kind: PaintKind;
|
|
44
|
+
ratio: number;
|
|
45
|
+
required: 3 | 4.5;
|
|
46
|
+
}
|
|
47
|
+
export interface PaintFitSurfaceReport {
|
|
48
|
+
role: string;
|
|
49
|
+
context: string | null;
|
|
50
|
+
pairs: PaintFitPair[];
|
|
51
|
+
}
|
|
52
|
+
export type PaintFitReport = Record<PaintScheme, PaintFitSurfaceReport[]>;
|
|
53
|
+
export interface PaintColorEnvironment {
|
|
54
|
+
scheme: PaintScheme;
|
|
55
|
+
context: string | null;
|
|
56
|
+
readColor(identifier: string): string | undefined;
|
|
57
|
+
readProperty(property: string): string | undefined;
|
|
58
|
+
}
|
|
59
|
+
export type PaintDerivation = (environment: PaintColorEnvironment) => PaintColor | null;
|
|
60
|
+
export type PaintInteraction = "rest" | "hover" | "focus" | "hover-focus";
|
|
61
|
+
export interface PaintCandidate {
|
|
62
|
+
element: Element;
|
|
63
|
+
kind: PaintKind;
|
|
64
|
+
source: "text" | "fill" | "stroke" | "shape" | "outline" | "shadow";
|
|
65
|
+
text?: Text;
|
|
66
|
+
indicator?: "blurred-shadow";
|
|
67
|
+
}
|
|
68
|
+
export interface PaintAttribution {
|
|
69
|
+
element: string;
|
|
70
|
+
owner: Element;
|
|
71
|
+
state?: (interaction: PaintInteraction) => string;
|
|
72
|
+
brandColor?: string;
|
|
73
|
+
foregroundDerivations?: readonly string[];
|
|
74
|
+
backgroundDerivations?: readonly string[];
|
|
75
|
+
/** Semantic identifiers that are equivalent to a named foreground derivation here. */
|
|
76
|
+
foregroundAliases?: readonly string[];
|
|
77
|
+
/** Semantic identifiers that are equivalent to a named background derivation here. */
|
|
78
|
+
backgroundAliases?: readonly string[];
|
|
79
|
+
}
|
|
80
|
+
export type PaintTarget = (candidate: PaintCandidate) => PaintAttribution | undefined;
|
|
81
|
+
export type PaintEntriesByRole = Readonly<Record<string, readonly PaintEntry[]>>;
|
|
82
|
+
export type PaintTargetsByRole = Readonly<Record<string, readonly PaintTarget[]>>;
|
|
83
|
+
export type PaintDerivations = Readonly<Record<string, PaintDerivation>>;
|
|
84
|
+
export interface PaintRegistration {
|
|
85
|
+
entriesByRole: PaintEntriesByRole;
|
|
86
|
+
targets: PaintTargetsByRole;
|
|
87
|
+
derivations?: PaintDerivations;
|
|
88
|
+
}
|
|
File without changes
|
|
@@ -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-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-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 h,semanticToCSS as g}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"}),w=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-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-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(w,a)}const O="--_esp-",c=/^--esp-[a-z0-9-]+$/,y=/^--_esp-[a-z0-9-]+$/,k=/^[a-z][a-z0-9-]*$/,l=new Set(h.map(g));function u(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 E(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 m=e.syntax==="length"||e.syntax==="length | keyword",p=e.syntax==="keyword"||e.syntax==="length | keyword";if(m&&(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(p&&(!e.allowedValues?.length||!e.allowedValues.every(o=>k.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(u(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.`);u(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:b}=e.derives,d=Object.keys(b);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)&&!y.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,w as SETTABLE_COMPONENT_PROPERTIES,E as assertRegistryInvariants,x as isSettableComponentPropertyName};
|