@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.
Files changed (71) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/custom-elements.json +36241 -46953
  3. package/dist/badge/esp-badge.d.ts +46 -0
  4. package/dist/badge/esp-badge.js +41 -6
  5. package/dist/breadcrumbs/breadcrumb-separators.d.ts +4 -0
  6. package/dist/breadcrumbs/breadcrumb-separators.js +1 -0
  7. package/dist/breadcrumbs/esp-breadcrumb.d.ts +14 -14
  8. package/dist/breadcrumbs/esp-breadcrumb.js +14 -7
  9. package/dist/breadcrumbs/esp-breadcrumbs.d.ts +16 -9
  10. package/dist/breadcrumbs/esp-breadcrumbs.js +9 -6
  11. package/dist/cli/theme-check.js +2 -2
  12. package/dist/font-picker/esp-font-picker.d.ts +11 -14
  13. package/dist/font-picker/esp-font-picker.js +5 -5
  14. package/dist/footer/esp-footer-link-group.js +12 -9
  15. package/dist/footer/esp-footer.d.ts +8 -3
  16. package/dist/footer/esp-footer.js +20 -12
  17. package/dist/footer/paint-registration.js +1 -1
  18. package/dist/header/esp-header-button.js +3 -3
  19. package/dist/header/esp-header.js +9 -9
  20. package/dist/index.d.ts +3 -2
  21. package/dist/index.js +1 -1
  22. package/dist/pickers/esp-picker-item.js +1 -1
  23. package/dist/root/esp-root.d.ts +8 -1
  24. package/dist/root/esp-root.js +80 -13
  25. package/dist/root/helpers/compute-semantic-properties.js +1 -1
  26. package/dist/root/helpers/compute-theme-properties.js +1 -1
  27. package/dist/root/helpers/data-companion-properties.js +1 -1
  28. package/dist/root/helpers/lightness-ramp-properties.js +1 -1
  29. package/dist/shared/blockquote-styles.d.ts +3 -0
  30. package/dist/shared/blockquote-styles.js +4 -4
  31. package/dist/shared/color-engine.js +1 -1
  32. package/dist/shared/component-property-compiler.js +1 -0
  33. package/dist/shared/component-property-diagnostics.js +1 -0
  34. package/dist/shared/component-property-normalizer.js +1 -0
  35. package/dist/shared/component-property-resets.js +1 -0
  36. package/dist/shared/document-sprite.js +1 -1
  37. package/dist/shared/esp-element-base.d.ts +3 -0
  38. package/dist/shared/esp-element-base.js +3 -3
  39. package/dist/shared/font-helpers.d.ts +3 -3
  40. package/dist/shared/font-helpers.js +1 -1
  41. package/dist/shared/font-plan.d.ts +1 -1
  42. package/dist/shared/footer-ink-styles.js +18 -0
  43. package/dist/shared/footer-ink.js +1 -0
  44. package/dist/shared/governing-root.d.ts +24 -0
  45. package/dist/shared/governing-root.js +1 -0
  46. package/dist/shared/intent-values.js +1 -1
  47. package/dist/shared/paint-catalog.js +1 -1
  48. package/dist/shared/paint-fit.js +1 -1
  49. package/dist/shared/public-token-catalog.generated.js +1 -0
  50. package/dist/shared/root-event-subscription.d.ts +11 -0
  51. package/dist/shared/scoped-style-declarations.js +1 -0
  52. package/dist/shared/semantic-color-names.d.ts +16 -0
  53. package/dist/shared/semantic-color-names.js +1 -0
  54. package/dist/shared/settable-component-properties.js +1 -0
  55. package/dist/shared/theme-core.d.ts +808 -0
  56. package/dist/shared/theme-core.js +1 -0
  57. package/dist/shared/theme-fit-report.d.ts +34 -6
  58. package/dist/shared/theme-fit-report.js +1 -1
  59. package/dist/shared/theme-mapping-grammar.d.ts +16 -0
  60. package/dist/shared/theme-mapping-grammar.js +1 -0
  61. package/dist/shared/theme-properties.d.ts +3 -1
  62. package/dist/shared/theme-properties.js +1 -1
  63. package/dist/shared/theme-validation.d.ts +52 -0
  64. package/dist/shared/theme-validation.js +1 -0
  65. package/dist/shared/theme.d.ts +4 -876
  66. package/dist/shared/theme.js +1 -1
  67. package/dist/shared/token-pairings.d.ts +1 -1
  68. package/dist/testing/observe-paint.iife.js +2 -2
  69. package/espalier.css-data.json +109 -5
  70. package/espalier.token-manifest.json +5914 -32
  71. package/package.json +5 -1
@@ -9,6 +9,16 @@ export type EspalierBadgeSize = "small" | "medium";
9
9
  * constrains them. Leave enough inline space for critical status text
10
10
  * that must remain fully visible.
11
11
  *
12
+ * Put a badge inside an anchor and set `linked` for link styling. A
13
+ * small chain mark identifies the link without relying on color. In the
14
+ * light DOM under `esp-root`, add `data-esp-badge-link` to an anchor that
15
+ * contains only the badge to put the interaction paint and focus ring on it.
16
+ * The anchor owns navigation and keyboard focus.
17
+ *
18
+ * ```html
19
+ * <a href="#badge" data-esp-badge-link><esp-badge linked>Soups</esp-badge></a>
20
+ * ```
21
+ *
12
22
  * ```html
13
23
  * <div style="display: flex; flex-wrap: wrap; gap: var(--esp-size-tiny);">
14
24
  * <esp-badge>Draft</esp-badge>
@@ -23,6 +33,40 @@ export type EspalierBadgeSize = "small" | "medium";
23
33
  * @slot icon - Optional custom icon. When provided, it overrides
24
34
  * the generated SVG from the `icon` attribute.
25
35
  *
36
+ * @cssprop --esp-badge-background - Background of a neutral badge.
37
+ * Defaults to `var(--esp-color-layer-2)`.
38
+ * @cssprop --esp-badge-color - Text color of a neutral badge. Defaults to
39
+ * `var(--esp-color-text)`. The theme fits it against the neutral badge
40
+ * background at APCA Lc 75 when either property is set in the theme.
41
+ * @cssprop --esp-badge-link-background - Resting fill of a linked badge.
42
+ * Defaults to `var(--esp-color-background)`.
43
+ * @cssprop --esp-badge-link-border-color - Resting border of a linked badge.
44
+ * Defaults to `var(--esp-color-link)`.
45
+ * @cssprop --esp-badge-link-color - Resting ink of a linked badge.
46
+ * Defaults to `var(--esp-color-link)`. The theme fits this ink against
47
+ * the resting fill at APCA Lc 75 when either property is set.
48
+ * @cssprop --esp-badge-link-hover-background - Hover fill of a linked badge.
49
+ * Defaults to `var(--esp-color-link-hover-bg)`.
50
+ * @cssprop --esp-badge-link-hover-border-color - Hover border of a linked badge.
51
+ * Defaults to `var(--esp-color-link-hover)`.
52
+ * @cssprop --esp-badge-link-hover-color - Hover ink of a linked badge.
53
+ * Defaults to `var(--esp-color-link-hover)`. The theme fits this ink
54
+ * against the hover fill at APCA Lc 75 when either property is set.
55
+ * @cssprop --esp-badge-link-focus-background - Focus fill of a linked badge.
56
+ * Defaults to `var(--esp-color-link-hover-bg)`.
57
+ * @cssprop --esp-badge-link-focus-border-color - Focus border of a linked badge.
58
+ * Defaults to `var(--esp-color-link-hover)`.
59
+ * @cssprop --esp-badge-link-focus-color - Keyboard focus ink of a linked badge
60
+ * inside the light DOM of `esp-root`.
61
+ * Defaults to `var(--esp-color-link-hover)`.
62
+ * The theme fits this ink against the focus fill at APCA Lc 75 when either
63
+ * property is set.
64
+ * @cssprop --esp-badge-link-focus-ring-color - Color of the outer keyboard
65
+ * focus ring on a badge inside a light-DOM anchor marked `data-esp-badge-link`.
66
+ * Defaults to `var(--esp-color-link)`. Choose a color with at least 3:1
67
+ * contrast against the surface surrounding the badge.
68
+ * @cssprop --esp-badge-border-color - Border color of a neutral badge.
69
+ * Defaults to `var(--esp-color-border)`.
26
70
  * @cssprop --esp-badge-border-radius - Border radius of the badge
27
71
  * shell. Defaults to `999px`.
28
72
  *
@@ -45,6 +89,8 @@ export declare class EspalierBadge extends EspalierElementBase {
45
89
  */
46
90
  get size(): EspalierBadgeSize;
47
91
  set size(value: EspalierBadgeSize | string | null);
92
+ /** Use the linked color set in place of the neutral and intent colors inside a native anchor. */
93
+ linked: boolean;
48
94
  protected render(): import("lit-html").TemplateResult<1>;
49
95
  static styles: import("lit").CSSResult[];
50
96
  }
@@ -1,16 +1,27 @@
1
- var c=function(s,e,t,o){var n=arguments.length,i=n<3?e:o===null?o=Object.getOwnPropertyDescriptor(e,t):o,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")i=Reflect.decorate(s,e,t,o);else for(var l=s.length-1;l>=0;l--)(a=s[l])&&(i=(n<3?a(i):n>3?a(e,t,i):a(e,t))||i);return n>3&&i&&Object.defineProperty(e,t,i),i};import{css as h,html as m,nothing as f}from"lit";import{customElement as g,property as p}from"lit/decorators.js";import{classMap as u}from"lit/directives/class-map.js";import{ref as b}from"lit/directives/ref.js";import{EspalierElementBase as d}from"../shared/esp-element-base.js";import{intentSurfaceTokens as v}from"../shared/style-fragments.js";import{syncNormalizedAttribute as z}from"../shared/attribute-helpers.js";import{getIconHrefForHost as y}from"../shared/intent-values.js";import{SlottedIconController as _}from"../shared/slotted-icon-controller.js";import{renderSpriteIcon as w}from"../shared/svgs/render-sprite-icon.js";function S(s){return s==="medium"?"medium":"small"}let r=class extends d{constructor(){super(...arguments),this.intentEmitsTokens=!1,this.iconSlot=new _(this),this.sizeBacker="small",this.icon=""}get size(){return this.sizeBacker}set size(e){const t=this.sizeBacker;this.sizeBacker=S(e),this.requestUpdate("size",t),z(this,"size",this.sizeBacker)}render(){const e=y(this.icon,this),t=this.iconSlot.hasSlottedIcon(),o=t||e.length>0,n={badge:!0,[`intent-${this.intent}`]:!0,[`size-${this.size}`]:!0,"has-icon":o};return m`
2
- <span part="badge" class=${u(n)}>
1
+ var l=function(s,e,o,i){var a=arguments.length,r=a<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,o):i,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(s,e,o,i);else for(var d=s.length-1;d>=0;d--)(n=s[d])&&(r=(a<3?n(r):a>3?n(e,o,r):n(e,o))||r);return a>3&&r&&Object.defineProperty(e,o,r),r};import{css as b,html as p,nothing as g}from"lit";import{customElement as v,property as c}from"lit/decorators.js";import{classMap as m}from"lit/directives/class-map.js";import{ref as f}from"lit/directives/ref.js";import{EspalierElementBase as h}from"../shared/esp-element-base.js";import{intentSurfaceTokens as u}from"../shared/style-fragments.js";import{syncNormalizedAttribute as k}from"../shared/attribute-helpers.js";import{getIconHrefForHost as y}from"../shared/intent-values.js";import{SlottedIconController as z}from"../shared/slotted-icon-controller.js";import{renderSpriteIcon as _}from"../shared/svgs/render-sprite-icon.js";function w(s){return s==="medium"?"medium":"small"}let t=class extends h{constructor(){super(...arguments),this.intentEmitsTokens=!1,this.iconSlot=new z(this),this.sizeBacker="small",this.icon="",this.linked=!1}get size(){return this.sizeBacker}set size(e){const o=this.sizeBacker;this.sizeBacker=w(e),this.requestUpdate("size",o),k(this,"size",this.sizeBacker)}render(){const e=y(this.icon,this),o=this.iconSlot.hasSlottedIcon(),i=o||e.length>0,a={badge:!0,[`intent-${this.intent}`]:!0,[`size-${this.size}`]:!0,"has-icon":i};return p`
2
+ <span part="badge" class=${m(a)}>
3
3
  <span part="icon" class="icon" aria-hidden="true">
4
4
  <slot
5
5
  name="icon"
6
- ${b(this.iconSlot.slotRef)}
6
+ ${f(this.iconSlot.slotRef)}
7
7
  @slotchange=${this.iconSlot.handleSlotChange}
8
8
  ></slot>
9
- ${!t&&e?w(e):f}
9
+ ${!o&&e?_(e):g}
10
10
  </span>
11
11
  <span part="label" class="label"><slot></slot></span>
12
+ ${this.linked?p`<svg
13
+ class="link-mark"
14
+ aria-hidden="true"
15
+ viewBox="0 0 24 24"
16
+ fill="none"
17
+ stroke="currentColor"
18
+ stroke-width="2"
19
+ stroke-linecap="round"
20
+ >
21
+ <path d="M9 15l6-6M11 6l1-1a5 5 0 0 1 7 7l-1 1M13 18l-1 1a5 5 0 0 1-7-7l1-1"></path>
22
+ </svg>`:g}
12
23
  </span>
13
- `}};r.styles=[...d.styles,v,h`
24
+ `}};t.styles=[...h.styles,u,b`
14
25
  :host {
15
26
  display: inline-flex;
16
27
  max-width: 100%;
@@ -39,6 +50,24 @@ var c=function(s,e,t,o){var n=arguments.length,i=n<3?e:o===null?o=Object.getOwnP
39
50
  white-space: nowrap;
40
51
  }
41
52
 
53
+ .badge.intent-neutral {
54
+ --_esp-badge-background: var(--esp-badge-background, var(--esp-color-layer-2));
55
+ --_esp-badge-border-color: var(--esp-badge-border-color, var(--esp-color-border));
56
+ --_esp-badge-color: var(--esp-badge-color, var(--esp-color-text));
57
+ }
58
+
59
+ :host([linked]) .badge {
60
+ --_esp-badge-background: var(--esp-badge-link-background, var(--esp-color-background));
61
+ --_esp-badge-border-color: var(--esp-badge-link-border-color, var(--esp-color-link));
62
+ --_esp-badge-color: var(--esp-badge-link-color, var(--esp-color-link));
63
+ }
64
+
65
+ :host([linked]:hover) .badge {
66
+ --_esp-badge-background: var(--esp-badge-link-hover-background, var(--esp-color-link-hover-bg));
67
+ --_esp-badge-border-color: var(--esp-badge-link-hover-border-color, var(--esp-color-link-hover));
68
+ --_esp-badge-color: var(--esp-badge-link-hover-color, var(--esp-color-link-hover));
69
+ }
70
+
42
71
  .size-small {
43
72
  gap: calc(var(--esp-size-tiny) / 2);
44
73
  padding: calc(var(--esp-size-tiny) / 2) var(--esp-size-tiny);
@@ -60,6 +89,12 @@ var c=function(s,e,t,o){var n=arguments.length,i=n<3?e:o===null?o=Object.getOwnP
60
89
  height: 1em;
61
90
  }
62
91
 
92
+ .link-mark {
93
+ flex: none;
94
+ width: 1em;
95
+ height: 1em;
96
+ }
97
+
63
98
  .has-icon .icon {
64
99
  display: inline-flex;
65
100
  }
@@ -75,4 +110,4 @@ var c=function(s,e,t,o){var n=arguments.length,i=n<3?e:o===null?o=Object.getOwnP
75
110
  overflow: hidden;
76
111
  text-overflow: ellipsis;
77
112
  }
78
- `],c([p({type:String})],r.prototype,"icon",void 0),c([p({type:String,reflect:!0})],r.prototype,"size",null),r=c([g("esp-badge")],r);export{r as EspalierBadge};
113
+ `],l([c({type:String})],t.prototype,"icon",void 0),l([c({type:String,reflect:!0})],t.prototype,"size",null),l([c({type:Boolean,reflect:!0})],t.prototype,"linked",void 0),t=l([v("esp-badge")],t);export{t as EspalierBadge};
@@ -0,0 +1,4 @@
1
+ export declare const BREADCRUMB_SEPARATOR_STYLES: readonly ["arrow-filled", "chevron", "line-arrow", "slash", "none"];
2
+ export type BreadcrumbSeparatorStyle = (typeof BREADCRUMB_SEPARATOR_STYLES)[number];
3
+ export declare const BREADCRUMB_TRAIL_ENDS: readonly ["arrow-down-filled", "same", "none"];
4
+ export type BreadcrumbTrailEnd = (typeof BREADCRUMB_TRAIL_ENDS)[number];
@@ -0,0 +1 @@
1
+ const e=Object.freeze(["arrow-filled","chevron","line-arrow","slash","none"]),o=Object.freeze(["arrow-down-filled","same","none"]);export{e as BREADCRUMB_SEPARATOR_STYLES,o as BREADCRUMB_TRAIL_ENDS};
@@ -38,13 +38,15 @@ import { LitElement } from "lit";
38
38
  * @cssprop --esp-breadcrumb-hover-background - The background behind a hovered link.
39
39
  * Defaults to `var(--esp-color-link-hover-bg)`.
40
40
  * @cssprop --esp-breadcrumb-current-color - The text color of the current-page crumb, which
41
- * is not a link. Defaults to `--esp-breadcrumb-color` when that is set, then to
42
- * `var(--esp-color-headings)`, keeping the current page distinct from the links beside it.
41
+ * is not a link. Defaults to `var(--esp-breadcrumb-color, var(--esp-color-headings))`, keeping
42
+ * the current page distinct from the links beside it.
43
43
  * @cssprop --esp-breadcrumb-separator-color - The color of the separator icons. Defaults to
44
- * `oklch(from var(--esp-color-link) l c calc(h + 90))`, an accent that takes the link ink's
45
- * scheme-adapted lightness and chroma at a different hue, so the arrows are their own color
46
- * rather than the heading color. Set it on `esp-breadcrumbs` to recolor a whole trail, or on
47
- * one `esp-breadcrumb` to recolor a single arrow.
44
+ * `color-mix(in oklch, var(--esp-breadcrumb-color, var(--esp-color-link)) 70%, transparent)`.
45
+ * Set it on `esp-breadcrumbs` to recolor a whole trail or on one `esp-breadcrumb`
46
+ * to recolor a single icon.
47
+ * @cssprop --esp-breadcrumb-separator-size - Width and height of a separator icon.
48
+ * Defaults to `var(--esp-size-normal-to-medium)`. The settable range is 0.5rem to 2rem.
49
+ * @cssprop --esp-breadcrumb-separator-stroke-width - Built-in line mark weight, from 0.5 to 6 in SVG units. Defaults to `2`.
48
50
  * @docPageTitle Breadcrumb
49
51
  * @docUrl /components/breadcrumbs/breadcrumb
50
52
  * @menuGroup Navigation
@@ -59,17 +61,15 @@ export declare class EspalierBreadcrumb extends LitElement {
59
61
  **/
60
62
  url: string;
61
63
  /**
62
- * Used to override the SVG separator displayed after the
63
- * breadcrumb.
64
- * @type {string}
64
+ * The effective SVG separator. Write SVG markup here to override the trail's choice.
65
+ * @default ""
65
66
  */
66
- separator: string;
67
+ get separator(): string;
68
+ set separator(value: string);
67
69
  /**
68
70
  * Marks this crumb as the end of the trail. The parent
69
- * `esp-breadcrumbs` sets it to pick the down-arrow separator and
70
- * the current-crumb styling. It does not decide link versus label —
71
- * a crumb that carries a `url` stays clickable wherever it sits, so
72
- * a trail can end at its deepest folder.
71
+ * `esp-breadcrumbs` sets it alongside the end separator. A crumb
72
+ * with a `url` stays clickable wherever it sits.
73
73
  * @type {boolean}
74
74
  */
75
75
  isLastElement: boolean;
@@ -1,6 +1,6 @@
1
- var a=function(n,e,o,s){var i=arguments.length,r=i<3?e:s===null?s=Object.getOwnPropertyDescriptor(e,o):s,l;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(n,e,o,s);else for(var p=n.length-1;p>=0;p--)(l=n[p])&&(r=(i<3?l(r):i>3?l(e,o,r):l(e,o))||r);return i>3&&r&&Object.defineProperty(e,o,r),r};import{LitElement as m,css as d,html as h}from"lit";import{customElement as u,property as c}from"lit/decorators.js";import{classMap as b}from"lit/directives/class-map.js";import{unsafeSVG as v}from"lit/directives/unsafe-svg.js";let t=class extends m{constructor(){super(...arguments),this.label="",this.url="",this.separator="",this.isLastElement=!1}_renderLink(){return this.url?h`<a href=${this.url}>${this.label}</a>`:h`<span aria-current="page">${this.label}</span>`}render(){const e={crumb:!0,"is-current":!this.url};return h`<div class=${b(e)}>
1
+ var o=function(s,e,r,i){var n=arguments.length,t=n<3?e:i===null?i=Object.getOwnPropertyDescriptor(e,r):i,l;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")t=Reflect.decorate(s,e,r,i);else for(var c=s.length-1;c>=0;c--)(l=s[c])&&(t=(n<3?l(t):n>3?l(e,r,t):l(e,r))||t);return n>3&&t&&Object.defineProperty(e,r,t),t};import{LitElement as u,css as d,html as h}from"lit";import{customElement as m,property as p}from"lit/decorators.js";import{classMap as b}from"lit/directives/class-map.js";import{unsafeSVG as v}from"lit/directives/unsafe-svg.js";let a=class extends u{constructor(){super(...arguments),this.label="",this.url="",this.automaticSeparator="",this.isLastElement=!1}get separator(){return this.authoredSeparator===void 0?this.automaticSeparator:this.authoredSeparator}set separator(e){const r=this.separator;this.authoredSeparator=e,this.requestUpdate("separator",r)}setAutomaticSeparator(e){const r=this.separator;this.automaticSeparator=e,this.authoredSeparator||(this.authoredSeparator=void 0),this.requestUpdate("separator",r)}_renderLink(){return this.url?h`<a href=${this.url}>${this.label}</a>`:h`<span aria-current="page">${this.label}</span>`}render(){const e={crumb:!0,"is-current":!this.url};return h`<div class=${b(e)}>
2
2
  ${this._renderLink()}${this.separator?v(this.separator):""}
3
- </div>`}};t.styles=d`
3
+ </div>`}};a.styles=d`
4
4
 
5
5
  :host {
6
6
  display: block;
@@ -50,13 +50,20 @@ var a=function(n,e,o,s){var i=arguments.length,r=i<3?e:s===null?s=Object.getOwnP
50
50
  overflow-wrap: anywhere;
51
51
  }
52
52
 
53
-
54
53
  svg {
55
54
  color: var(
56
55
  --esp-breadcrumb-separator-color,
57
- oklch(from var(--esp-color-link) l c calc(h + 90))
56
+ color-mix(in oklch, var(--esp-breadcrumb-color, var(--esp-color-link)) 70%, transparent)
58
57
  );
59
- height: var(--esp-size-normal-to-medium);
60
- width: var(--esp-size-normal-to-medium);
58
+ height: var(--esp-breadcrumb-separator-size, var(--esp-size-normal-to-medium));
59
+ width: var(--esp-breadcrumb-separator-size, var(--esp-size-normal-to-medium));
60
+ }
61
+
62
+ svg[data-built-in-stroke] {
63
+ stroke-width: var(--esp-breadcrumb-separator-stroke-width, 2);
64
+ }
65
+
66
+ :host(:dir(rtl)) svg[data-mirror-rtl] {
67
+ scale: -1 1;
61
68
  }
62
- `,a([c({type:String})],t.prototype,"label",void 0),a([c({type:String})],t.prototype,"url",void 0),a([c({type:String})],t.prototype,"separator",void 0),a([c({attribute:"is-last-element",type:Boolean})],t.prototype,"isLastElement",void 0),t=a([u("esp-breadcrumb")],t);export{t as EspalierBreadcrumb};
69
+ `,o([p({type:String})],a.prototype,"label",void 0),o([p({type:String})],a.prototype,"url",void 0),o([p({type:String,noAccessor:!0})],a.prototype,"separator",null),o([p({attribute:"is-last-element",type:Boolean})],a.prototype,"isLastElement",void 0),a=o([m("esp-breadcrumb")],a);export{a as EspalierBreadcrumb};
@@ -1,10 +1,10 @@
1
1
  import { type PropertyValues } from "lit";
2
2
  import { EspalierElementBase } from "../shared/esp-element-base.js";
3
+ import { type BreadcrumbSeparatorStyle, type BreadcrumbTrailEnd } from "./breadcrumb-separators.js";
3
4
  export * from "./esp-breadcrumb.js";
4
5
  /**
5
- * Used to display breadcrumb navigation. By default, the breadcrumbs
6
- * will be separated by right-arrows, with the final item having a
7
- * down-arrow after it.
6
+ * Displays breadcrumb navigation. By default, a filled right arrow separates
7
+ * crumbs and a filled down arrow follows the final crumb.
8
8
  * [esp-breadcrumb](/components/breadcrumbs/breadcrumb) instances
9
9
  * should be placed in the default slot to build out the navigation.
10
10
  *
@@ -48,7 +48,11 @@ export * from "./esp-breadcrumb.js";
48
48
  * </esp-breadcrumbs>
49
49
  * ```
50
50
  *
51
- * Custom separators can be specified in the `<esp-breadcrumb>`:
51
+ * Set `separator-style` to `arrow-filled`, `chevron`, `line-arrow`, `slash`,
52
+ * or `none`. Set `trail-end` independently to `arrow-down-filled`, `same`
53
+ * (use the between-crumb choice), or `none`. An unrecognized value uses the
54
+ * default for that setting. The `separator` attribute on an individual crumb
55
+ * overrides both settings for that crumb:
52
56
  *
53
57
  * ```html
54
58
  * <esp-breadcrumbs>
@@ -67,10 +71,9 @@ export * from "./esp-breadcrumb.js";
67
71
  * @customElement esp-breadcrumbs
68
72
  * @slot - `<esp-breadcrumb>` items to display.
69
73
  * @cssprop --esp-breadcrumb-separator-color - The color of the separator icons. Defaults to
70
- * `oklch(from var(--esp-color-link) l c calc(h + 90))`, an accent that takes the link ink's
71
- * scheme-adapted lightness and chroma at a different hue, so the arrows are their own color
72
- * rather than the heading color. Set it on `esp-breadcrumbs` to recolor a whole trail, or on
73
- * one `esp-breadcrumb` to recolor a single arrow.
74
+ * `color-mix(in oklch, var(--esp-breadcrumb-color, var(--esp-color-link)) 70%, transparent)`.
75
+ * Set it on `esp-breadcrumbs` to recolor a whole trail or on one `esp-breadcrumb`
76
+ * to recolor a single icon.
74
77
  *
75
78
  * ```html
76
79
  * <style>
@@ -104,7 +107,11 @@ export declare class EspalierBreadcrumbs extends EspalierElementBase {
104
107
  * Removing the attribute returns the name to `Breadcrumb`.
105
108
  */
106
109
  ariaLabel: string | null;
107
- protected firstUpdated(changedProperties: PropertyValues): void;
110
+ /** Separator between crumbs. Defaults to `arrow-filled`. */
111
+ separatorStyle: BreadcrumbSeparatorStyle | null;
112
+ /** Separator after the last crumb. Defaults to `arrow-down-filled`. */
113
+ trailEnd: BreadcrumbTrailEnd | null;
114
+ protected updated(changedProperties: PropertyValues): void;
108
115
  protected render(): import("lit-html").TemplateResult<1>;
109
116
  static styles: import("lit").CSSResult[];
110
117
  }
@@ -1,17 +1,20 @@
1
- var p=function(o,e,t,r){var a=arguments.length,s=a<3?e:r===null?r=Object.getOwnPropertyDescriptor(e,t):r,n;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")s=Reflect.decorate(o,e,t,r);else for(var i=o.length-1;i>=0;i--)(n=o[i])&&(s=(a<3?n(s):a>3?n(e,t,s):n(e,t))||s);return a>3&&s&&Object.defineProperty(e,t,s),s};import{css as h,html as u}from"lit";import{customElement as v,property as d}from"lit/decorators.js";import{EspalierElementBase as m}from"../shared/esp-element-base.js";import{createRef as g,ref as w}from"lit/directives/ref.js";export*from"./esp-breadcrumb.js";const c=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
1
+ var p=function(l,t,a,s){var n=arguments.length,e=n<3?t:s===null?s=Object.getOwnPropertyDescriptor(t,a):s,r;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")e=Reflect.decorate(l,t,a,s);else for(var i=l.length-1;i>=0;i--)(r=l[i])&&(e=(n<3?r(e):n>3?r(t,a,e):r(t,a))||e);return n>3&&e&&Object.defineProperty(t,a,e),e};import{css as v,html as w}from"lit";import{customElement as g,property as d}from"lit/decorators.js";import{EspalierElementBase as h}from"../shared/esp-element-base.js";import{createRef as b,ref as S}from"lit/directives/ref.js";import{BREADCRUMB_SEPARATOR_STYLES as m,BREADCRUMB_TRAIL_ENDS as c}from"./breadcrumb-separators.js";import{EspalierBreadcrumb as y}from"./esp-breadcrumb.js";export*from"./esp-breadcrumb.js";const E=`<svg aria-hidden="true" data-mirror-rtl xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
2
2
  <path stroke="none" d="M0 0h24v24H0z" fill="none" />
3
3
  <path
4
4
  d="M12.089 3.634a2 2 0 0 0 -1.089 1.78l-.001 2.586h-6.999a2 2 0 0 0 -2 2v4l.005 .15a2 2 0 0 0 1.995 1.85l6.999 -.001l.001 2.587a2 2 0 0 0 3.414 1.414l6.586 -6.586a2 2 0 0 0 0 -2.828l-6.586 -6.586a2 2 0 0 0 -2.18 -.434l-.145 .068z" />
5
- </svg>`,f=`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
5
+ </svg>`,x=`<svg aria-hidden="true" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="currentColor">
6
6
  <path stroke="none" d="M0 0h24v24H0z" fill="none" />
7
7
  <path
8
8
  d="M10 2l-.15 .005a2 2 0 0 0 -1.85 1.995v6.999l-2.586 .001a2 2 0 0 0 -1.414 3.414l6.586 6.586a2 2 0 0 0 2.828 0l6.586 -6.586a2 2 0 0 0 .434 -2.18l-.068 -.145a2 2 0 0 0 -1.78 -1.089l-2.586 -.001v-6.999a2 2 0 0 0 -2 -2h-4z"
9
9
  />
10
- </svg>`;let l=class extends m{constructor(){super(...arguments),this.itemsSlot=g(),this.ariaLabel=null}firstUpdated(e){if(super.firstUpdated(e),!this.itemsSlot.value){console.warn("No items slot found for breadcrumbs.");return}this.assignSeparators()}assignSeparators(){const e=this.itemsSlot.value?.assignedElements()??[];for(let t=0;t<e.length;t++){const r=e[t],a=t===e.length-1;r.isLastElement=a;const s=r.separator===c||r.separator===f;r.separator&&!s||(r.separator=a?f:c)}}render(){return u`
10
+ </svg>`;function f(l,t){return`<svg aria-hidden="true" data-built-in-stroke${t?" data-mirror-rtl":""} xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none"
11
+ stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
12
+ <path d="${l}" />
13
+ </svg>`}const B={"arrow-filled":E,chevron:f("M9 6l6 6-6 6",!0),"line-arrow":f("M5 12h14m-6-6 6 6-6 6",!0),slash:f("M15 5l-6 14",!1),none:""};let o=class extends h{constructor(){super(...arguments),this.itemsSlot=b(),this.ariaLabel=null,this.separatorStyle=m[0],this.trailEnd=c[0]}updated(t){super.updated(t),(t.has("separatorStyle")||t.has("trailEnd"))&&this.assignSeparators()}assignSeparators(){const t=this.itemsSlot.value?.assignedElements().filter(r=>r instanceof y)??[],a=m.find(r=>r===this.separatorStyle)??m[0],s=B[a],n={"arrow-down-filled":x,same:s,none:""},e=c.find(r=>r===this.trailEnd)??c[0];for(const[r,i]of t.entries()){const u=r===t.length-1;i.isLastElement=u,i.setAutomaticSeparator(u?n[e]:s)}}render(){return w`
11
14
  <nav aria-label=${this.ariaLabel??"Breadcrumb"}>
12
- <slot ${w(this.itemsSlot)} @slotchange=${this.assignSeparators}></slot>
15
+ <slot ${S(this.itemsSlot)} @slotchange=${this.assignSeparators}></slot>
13
16
  </nav>
14
- `}};l.styles=[...m.styles,h`
17
+ `}};o.styles=[...h.styles,v`
15
18
  nav {
16
19
  display: flex;
17
20
  flex-wrap: wrap;
@@ -19,4 +22,4 @@ var p=function(o,e,t,r){var a=arguments.length,s=a<3?e:r===null?r=Object.getOwnP
19
22
  gap: var(--esp-size-tiny-to-small);
20
23
  font-size: var(--esp-size-small-to-normal);
21
24
  }
22
- `],p([d({attribute:"aria-label",type:String})],l.prototype,"ariaLabel",void 0),l=p([v("esp-breadcrumbs")],l);export{l as EspalierBreadcrumbs};
25
+ `],p([d({attribute:"aria-label",type:String})],o.prototype,"ariaLabel",void 0),p([d({attribute:"separator-style",type:String})],o.prototype,"separatorStyle",void 0),p([d({attribute:"trail-end",type:String})],o.prototype,"trailEnd",void 0),o=p([g("esp-breadcrumbs")],o);export{o as EspalierBreadcrumbs};
@@ -1,2 +1,2 @@
1
- import{encodeTheme as D,isObjectRecord as p,isSemanticColorName as H,validateThemePair as X}from"../shared/theme.js";import{THEME_FIT_ANCHOR_FIELDS as P,THEME_FIT_APCA_FIELDS as R,THEME_FIT_DATA_PALETTE_LINT_FIELDS as C,THEME_FIT_DATA_PALETTE_LINT_IDS as Y,THEME_FIT_EXPLICIT_VALUES as B,THEME_FIT_LINT_FIELDS as M,THEME_FIT_LINT_IDS as Q,THEME_FIT_LINT_SEVERITIES as Z,THEME_FIT_PAIRING_VALUES as v,THEME_FIT_REPORT_FIELDS as A,THEME_FIT_SUITE_FIELDS as k,THEME_FIT_TOKEN_FIELDS as x,themeFitReportSuite as ee}from"../shared/theme-fit-report.js";import{COLOR_VISION_SIMULATIONS as te,DATA_SERIES_KEYS as I,isPaletteCollisionDescription as re}from"../shared/data-colors.js";import{isPaintKind as ne,isPaintName as T}from"../shared/paint-catalog.js";import{paintRequiredRatio as ie}from"../shared/paint-color.js";import{isSafeKey as oe}from"../shared/unsafe-keys.js";const w="usage: espalier theme check <theme.json> [--json] [--expect <fit.json>] [--update-expect <fit.json>]";function Je(e,t){const[r,i,...n]=e;if(r!=="theme"||i!=="check")return t.error(w),2;const s=se(n,t);return s?ae(s,t):2}function se(e,t){const r={file:"",json:!1};for(let i=0;i<e.length;i+=1){const n=e[i];if(n==="--json")r.json=!0;else if(n==="--expect"||n==="--update-expect"){const s=e[i+1];if(s===void 0)return t.error(`${n} requires a file path. ${w}`),null;n==="--expect"?r.expect=s:r.updateExpect=s,i+=1}else if(!n.startsWith("--")&&r.file==="")r.file=n;else return t.error(`Unknown argument "${n}". ${w}`),null}return r.file===""?(t.error(w),null):r.expect!==void 0&&r.updateExpect!==void 0?(t.error(`--expect checks the committed fit tables and --update-expect rewrites them \u2014 pick one. ${w}`),null):r}function ce(e,t){let r;try{r=t.readFile(e)}catch(s){return t.error(`Cannot read ${e}: ${s instanceof Error?s.message:String(s)}`),null}let i;try{i=JSON.parse(r)}catch(s){return t.error(`${e} is not JSON: ${s instanceof Error?s.message:String(s)}`),null}if(typeof i!="object"||i===null||Array.isArray(i))return t.error(`${e} must contain a theme object.`),null;const n=i;if("light"in n||"dark"in n){for(const s of["light","dark"]){const o=n[s];if(o!==void 0&&(typeof o!="object"||o===null||Array.isArray(o)))return t.error(`${e}: "${s}" must be a theme object.`),null}return{light:n.light??{},dark:n.dark??{}}}return{light:n,dark:n}}function ae(e,t){const r=ce(e.file,t);if(!r)return 2;const i=X(D(r.light),D(r.dark));if(!i.valid){for(const c of i.warnings)t.error(`warning: ${c}`);for(const c of i.errors)t.error(`error: ${c}`);return t.error(`${e.file}: ${i.errors.length} validation error(s).`),1}const n=ee(r.light,r.dark);for(const c of i.warnings)Pe(c,n)||t.error(`warning: ${c}`);const s=Ne(n),o=e.json?t.error:t.log;if(e.updateExpect!==void 0){try{t.writeFile(e.updateExpect,`${JSON.stringify(n,null,2)}
2
- `)}catch(c){return t.error(`Cannot write ${e.updateExpect}: ${c instanceof Error?c.message:String(c)}`),2}o(`Wrote fit tables to ${e.updateExpect}.`)}if(e.expect!==void 0){let c;try{c=t.readFile(e.expect)}catch{return t.error(`Expected fit tables not found at ${e.expect} \u2014 create them with --update-expect ${e.expect}.`),2}let a;try{a=JSON.parse(c)}catch{return t.error(`${e.expect} is not JSON.`),2}if(!fe(a))return t.error(`${e.expect} is not a fit-table suite \u2014 regenerate it with --update-expect ${e.expect}.`),2;const f=ye(a,n);if(f.length>0){s>0&&Oe(n,s,t);for(const u of f)t.error(`drift: ${u}`);return t.error(`Fit tables drifted from ${e.expect} (${f.length} difference(s)). Review, then refresh deliberately with --update-expect.`),1}o(`Fit tables match ${e.expect}.`)}return e.json?(t.log(JSON.stringify(n,null,2)),s>0?1:0):(je(n,s,t),s>0?1:0)}function fe(e){if(!p(e)||!k.every(({field:r,kind:i})=>E(e[String(r)],i)))return!1;const t=e;if(!b(t.surfaces))return!1;for(const r of["light","dark"]){const n=t.paletteLints[r].map(h);if(!b(n))return!1;const s=t[r],o=new Set;for(const c of s){if(!$e(c,r)||!t.surfaces.includes(c.surface)||o.has(c.surface))return!1;o.add(c.surface)}}return!0}function V(e){return typeof e=="number"&&Number.isFinite(e)}function ue(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function b(e){return new Set(e).size===e.length}function de(e){return p(e)&&C.every(({field:t,kind:r})=>E(e[String(t)],r))}function pe(e){return p(e)&&M.every(({field:t,kind:r})=>E(e[String(t)],r))}function le(e){return p(e)&&x.every(({field:t,kind:r})=>E(e[String(t)],r))}function E(e,t){switch(t){case"anchor":return e===void 0||U(e,P);case"anchor-record":return p(e)&&Object.keys(e).every(oe)&&Object.values(e).every(r=>typeof r=="string");case"apca":return e===void 0||U(e,R);case"boolean":return typeof e=="boolean";case"data-palette-record":return p(e)?["light","dark"].every(r=>{const i=e[r];return p(i)&&I.every(n=>typeof i[n]=="string")}):!1;case"explicit":return e===void 0||B.includes(e);case"fit-lint-id":return Q.includes(e);case"lint-array":return Array.isArray(e)&&e.every(pe);case"message":case"string":return typeof e=="string";case"number":return V(e);case"paint-record":return e===void 0||me(e);case"pairing":return e===void 0||v.includes(e);case"palette-lint-id":return Y.includes(e);case"palette-lint-record":return p(e)&&["light","dark"].every(r=>Array.isArray(e[r])&&e[r].every(de));case"report-array":return Array.isArray(e);case"scheme":return e==="light"||e==="dark";case"semantic":return H(e);case"semantic-array":return Array.isArray(e)&&e.every(H);case"series-pair":return he(e);case"simulation":return te.includes(e);case"string-array":return ue(e);case"token-array":return Array.isArray(e)&&e.every(le);case"warning":return Z.includes(e);default:{const r=t;return!1}}}function me(e){return p(e)?["light","dark"].every(t=>{const r=e[t];if(!Array.isArray(r))return!1;const i=new Set;for(const n of r){if(!p(n)||!T(n.role)||i.has(n.role)||n.context!==null&&!T(n.context)||!Array.isArray(n.pairs)||!Array.from(n.pairs).every(ge))return!1;i.add(n.role)}return!0}):!1}function ge(e){return p(e)&&T(e.element)&&T(e.foreground)&&T(e.background)&&T(e.state)&&ne(e.kind)&&V(e.ratio)&&e.ratio>=1&&e.ratio<=21&&e.required===ie(e.kind)}function U(e,t){return p(e)&&t.every(({field:r,kind:i})=>E(e[String(r)],i))}function he(e){if(!Array.isArray(e)||e.length!==2)return!1;const t=I.indexOf(e[0]),r=I.indexOf(e[1]);return t>=0&&r>t}function $e(e,t){if(!p(e)||!A.every(({field:i,kind:n})=>E(e[String(i)],n)))return!1;const r=e;return r.scheme!==t?!1:b(r.tokens.map(i=>i.token))&&b(r.adjustedTokens)&&b(r.lints.map(i=>i.id))}function ye({paint:e,...t},{paint:r,...i}){const n=[];for(const o of k)o.compared&&Se(n,o,t,i);return(g(z(t))!==g(z(i))||n.length===0&&g(t)!==g(i))&&n.push("fit tables differ outside compared fields"),n}function Se(e,t,r,i){const{field:n,kind:s}=t;if(s==="string-array"){const o=r[n],c=i[n];K(e,String(n),o,c),F(e,String(n),o,c);return}if(s==="data-palette-record"){const o=r[n],c=i[n];for(const a of["light","dark"])for(const f of I)q(e,`${a}/${String(n)}/${f}`,o[a][f],c[a][f]);return}if(s==="palette-lint-record"){const o=r[n],c=i[n];for(const a of["light","dark"])Le(e,a,String(n),o[a],c[a]),F(e,`${a}/${String(n)}`,o[a].map(h),c[a].map(h));return}if(s==="report-array"&&(n==="light"||n==="dark")){ke(e,n,r[n],i[n]);return}_(e,"fit tables",String(n),r[n],i[n],s)}function ke(e,t,r,i){const n=new Map(r.map(o=>[o.surface,o])),s=new Map(i.map(o=>[o.surface,o]));F(e,`${t}/reports`,r.map(o=>o.surface),i.map(o=>o.surface));for(const o of L(n.keys(),s.keys())){const c=n.get(o),a=s.get(o),f=`${t}/${o}`;if(!c||!a){e.push(`${f}: surface ${c?"removed":"added"}`);continue}Te(e,f,c,a)}}function Te(e,t,r,i){for(const n of A){const{compared:s,field:o,kind:c}=n;if(!(!s||o==="scheme"||o==="surface")){if(c==="anchor-record"){Ae(e,`${t}/${String(o)}`,r[o],i[o]);continue}if(c==="semantic-array"){const a=r[o],f=i[o];K(e,`${t}/${String(o)}`,a,f),F(e,`${t}/${String(o)}`,a,f);continue}if(c==="lint-array"){const a=r[o],f=i[o];_e(e,t,String(o),a,f),F(e,`${t}/${String(o)}`,a.map(u=>u.id),f.map(u=>u.id));continue}if(c==="token-array"){Ee(e,t,String(o),r[o],i[o]);continue}_(e,t,String(o),r[o],i[o],c)}}}function Ee(e,t,r,i,n){const s=new Map(i.map(a=>[a.token,a])),o=new Map(n.map(a=>[a.token,a]));F(e,`${t}/${r}`,i.map(a=>a.token),n.map(a=>a.token));const c=r==="tokens"?t:`${t}/${r}`;for(const a of L(s.keys(),o.keys())){const f=s.get(a),u=o.get(a),S=`${c}/${a}`;if(!f||!u){e.push(`${S}: token ${f?"removed":"added"}`);continue}Fe(e,S,f,u)}}function Fe(e,t,r,i){for(const{compared:n,field:s,kind:o}of x)if(!(!n||s==="token")){if(o==="anchor"){J(e,t,"anchor",r.anchor,i.anchor,P);continue}if(o==="apca"){J(e,t,"apca",r.apca,i.apca,R);continue}_(e,t,String(s),r[s],i[s],o)}}function J(e,t,r,i,n,s){const o=i,c=n;for(const{compared:a,field:f,kind:u}of s)a&&_(e,t,`${r}.${String(f)}`,o?.[f],c?.[f],u)}function _e(e,t,r,i,n){const s=new Map(i.map(c=>[c.id,c])),o=new Map(n.map(c=>[c.id,c]));for(const c of L(s.keys(),o.keys())){const a=s.get(c),f=o.get(c),u=`${t}/${r}/${c}`;if(!a||!f){e.push(`${u}: lint ${a?"removed":"added"}`);continue}for(const{compared:S,field:d,kind:j}of M)if(!(!S||d==="id")){if(j==="semantic-array"){xe(e,u,String(d),a[d],f[d]);continue}_(e,u,String(d),a[d],f[d],j)}}}function Le(e,t,r,i,n){const s=new Map(i.map(c=>[h(c),c])),o=new Map(n.map(c=>[h(c),c]));for(const c of L(s.keys(),o.keys())){const a=s.get(c),f=o.get(c),u=`${t}/${r}/${c}`;if(!a||!f){e.push(`${u}: lint ${a?"removed":"added"}`);continue}for(const{compared:S,field:d,kind:j}of C)!S||d==="id"||d==="series"||d==="simulation"||_(e,u,String(d),a[d],f[d],j)}}function h(e){return`${e.id}/${e.series[0]}+${e.series[1]}/${e.simulation}`}function Ae(e,t,r,i){for(const n of L(Object.keys(r),Object.keys(i)))q(e,`${t}/${n}`,r[n],i[n])}function K(e,t,r,i){const n=new Set(r),s=new Set(i);for(const o of L(n,s))n.has(o)!==s.has(o)&&e.push(`${t}/${o}: ${n.has(o)?"removed":"added"}`)}function F(e,t,r,i){const n=new Set(r),s=new Set(i),o=r.filter(a=>s.has(a)),c=i.filter(a=>n.has(a));o.some((a,f)=>a!==c[f])&&e.push(`${t}: order changed`)}function xe(e,t,r,i,n){const s=Math.max(i.length,n.length);for(let o=0;o<s;o+=1)W(e,t,`${r}[${o}]`,i[o],n[o])}function q(e,t,r,i){r!==i&&e.push(`${t}: ${O(r)} \u2192 ${O(i)}`)}function W(e,t,r,i,n,s){if(!Object.is(i,n)){if(s==="message"){e.push(`${t}: message changed`);return}e.push(`${t}: ${r} ${O(i)} \u2192 ${O(n)}`)}}function Ie(e,t,r,i,n){g(i)!==g(n)&&e.push(`${t}: ${r} changed`)}function _(e,t,r,i,n,s){if(be(s)){W(e,t,r,i,n,s);return}Ie(e,t,r,i,n)}const we={anchor:!1,"anchor-record":!1,apca:!1,boolean:!0,"data-palette-record":!1,explicit:!0,"fit-lint-id":!0,"lint-array":!1,message:!0,number:!0,"paint-record":!1,pairing:!0,"palette-lint-id":!0,"palette-lint-record":!1,"report-array":!1,scheme:!0,semantic:!0,"semantic-array":!1,"series-pair":!1,simulation:!0,string:!0,"string-array":!1,"token-array":!1,warning:!0};function be(e){return we[e]===!0}function O(e){return e===void 0?"(absent)":e===""?'""':String(e)}function L(e,t){return[...new Set([...e,...t])].sort()}function g(e){return Array.isArray(e)?`[${e.map(g).join(",")}]`:p(e)?`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${g(e[t])}`).join(",")}}`:JSON.stringify(e)??"undefined"}function z(e){const t=m(e,$(k)),r=["light","dark"];if(y(k,"dataPalette")){const i=m(e.dataPalette,r);for(const n of r)l(i,n,m(e.dataPalette[n],I));l(t,"dataPalette",i)}if(y(k,"paletteLints")){const i=m(e.paletteLints,r);for(const n of r)l(i,n,G(e.paletteLints[n],h,$(C)));l(t,"paletteLints",i)}for(const i of r){if(!y(k,i))continue;const n=N();for(const s of e[i]){const o=m(s,$(A));if(y(A,"tokens")){const c=N();for(const a of s.tokens){const f=m(a,$(x));a.anchor&&y(x,"anchor")&&l(f,"anchor",m(a.anchor,$(P))),a.apca&&y(x,"apca")&&l(f,"apca",m(a.apca,$(R))),l(c,a.token,f)}l(o,"tokens",c)}y(A,"lints")&&l(o,"lints",G(s.lints,c=>c.id,$(M))),l(n,s.surface,o)}l(t,i,n)}return t}function G(e,t,r){const i=N();for(const n of e)l(i,t(n),m(n,r));return i}function $(e){return e.filter(({compared:t})=>t).map(({field:t})=>t)}function y(e,t){return e.some(r=>r.field===t&&r.compared)}function m(e,t){const r=new Set(t.map(String)),i=N();for(const[n,s]of Object.entries(e))r.has(n)||(i[n]=s);return i}function N(){return Object.create(null)}function l(e,t,r){Object.keys(r).length>0&&(e[t]=r)}function je(e,t,r){for(const i of["light","dark"]){for(const n of e.paletteLints[i])r.log(` ${i} lint(${n.id}): ${n.message}`);for(const n of e[i]){r.log(Re(i,n));for(const s of n.lints)r.log(` lint(${s.id}): ${s.message}`)}}r.log(`Checked ${e.surfaces.length} surface(s) \xD7 2 schemes \u2014 `+(t===0?"no lints.":`${t} lint(s), listed above.`))}function Oe(e,t,r){r.error(`${t} theme lint(s) are standing while fit-table drift is present:`);for(const i of["light","dark"]){for(const n of e.paletteLints[i])r.error(`lint: ${i}/paletteLints/${h(n)}: ${n.message}`);for(const n of e[i])for(const s of n.lints)r.error(`lint: ${i}/${n.surface}/lints/${s.id}: ${s.message}`)}}function Ne(e){return[...e.light,...e.dark].reduce((r,i)=>r+i.lints.length,0)+e.paletteLints.light.length+e.paletteLints.dark.length}function Pe(e,t){return["light","dark"].some(r=>{const i=`${r}: `;if(!e.startsWith(i))return!1;const n=e.slice(i.length);return t.paletteLints[r].some(s=>re(n,s))})}function Re(e,t){const r=t.adjustedTokens.length===0?"contrast enforcement moved nothing":`contrast enforcement moved ${t.adjustedTokens.join(", ")}`,i=t.tokens.filter(s=>s.explicit==="inherited").length,n=i===0?"":`; ${i} inherited explicit pin(s) \u2014 see the fit tables`;return`${e}/${t.surface}: ${t.tokens.length} tokens, ${r}${n}.`}export{Je as runEspalierCli};
1
+ import{encodeTheme as W,isObjectRecord as d,isSemanticColorName as j,parseAnchorSource as ee,validateThemePair as te}from"../shared/theme.js";import{THEME_FIT_ANCHOR_FIELDS as M,THEME_FIT_APCA_FIELDS as D,THEME_FIT_COMPONENT_APCA_FIELDS as H,THEME_FIT_COMPONENT_PROPERTY_FIELDS as R,THEME_FIT_DATA_PALETTE_LINT_FIELDS as K,THEME_FIT_DATA_PALETTE_LINT_IDS as re,THEME_FIT_EXPLICIT_VALUES as ne,THEME_FIT_LINT_FIELDS as V,THEME_FIT_LINT_IDS as oe,THEME_FIT_LINT_SEVERITIES as ie,THEME_FIT_PAIRING_VALUES as se,THEME_FIT_REPORT_FIELDS as A,THEME_FIT_SUITE_FIELDS as L,THEME_FIT_TOKEN_FIELDS as P,themeFitReportSuite as ce}from"../shared/theme-fit-report.js";import{COLOR_VISION_SIMULATIONS as ae,DATA_SERIES_KEYS as w,isPaletteCollisionDescription as fe}from"../shared/data-colors.js";import{isPaintKind as ue,isPaintName as I}from"../shared/paint-catalog.js";import{FOOTER_HEADING_INK as pe,FOOTER_LINK_INK as de}from"../shared/footer-ink.js";import{paintRequiredRatio as me}from"../shared/paint-color.js";import{isSafeKey as le}from"../shared/unsafe-keys.js";import{isSettableComponentPropertyName as C,SETTABLE_COMPONENT_PROPERTIES as ge,SEMANTIC_COLOR_PROPERTIES as he}from"../shared/settable-component-properties.js";import{isColorSource as ye,isLightnessKey as $e,isThemeSlug as z,toneReferenceName as Se}from"../shared/theme-mapping-grammar.js";const O="usage: espalier theme check <theme.json> [--json] [--expect <fit.json>] [--update-expect <fit.json>]";function ct(e,t){const[r,o,...n]=e;if(r!=="theme"||o!=="check")return t.error(O),2;const s=ke(n,t);return s?Ee(s,t):2}function ke(e,t){const r={file:"",json:!1};for(let o=0;o<e.length;o+=1){const n=e[o];if(n==="--json")r.json=!0;else if(n==="--expect"||n==="--update-expect"){const s=e[o+1];if(s===void 0)return t.error(`${n} requires a file path. ${O}`),null;n==="--expect"?r.expect=s:r.updateExpect=s,o+=1}else if(!n.startsWith("--")&&r.file==="")r.file=n;else return t.error(`Unknown argument "${n}". ${O}`),null}return r.file===""?(t.error(O),null):r.expect!==void 0&&r.updateExpect!==void 0?(t.error(`--expect checks the committed fit tables and --update-expect rewrites them \u2014 pick one. ${O}`),null):r}function Te(e,t){let r;try{r=t.readFile(e)}catch(s){return t.error(`Cannot read ${e}: ${s instanceof Error?s.message:String(s)}`),null}let o;try{o=JSON.parse(r)}catch(s){return t.error(`${e} is not JSON: ${s instanceof Error?s.message:String(s)}`),null}if(typeof o!="object"||o===null||Array.isArray(o))return t.error(`${e} must contain a theme object.`),null;const n=o;if("light"in n||"dark"in n){for(const s of["light","dark"]){const i=n[s];if(i!==void 0&&(typeof i!="object"||i===null||Array.isArray(i)))return t.error(`${e}: "${s}" must be a theme object.`),null}return{light:n.light??{},dark:n.dark??{}}}return{light:n,dark:n}}function Ee(e,t){const r=Te(e.file,t);if(!r)return 2;const o=te(W(r.light),W(r.dark));if(!o.valid){for(const c of o.warnings)t.error(`warning: ${c}`);for(const c of o.errors)t.error(`error: ${c}`);return t.error(`${e.file}: ${o.errors.length} validation error(s).`),1}const n=ce(r.light,r.dark);for(const c of o.warnings)Xe(c,n)||t.error(`warning: ${c}`);const s=Be(n),i=e.json?t.error:t.log;if(e.updateExpect!==void 0){try{t.writeFile(e.updateExpect,`${JSON.stringify(n,null,2)}
2
+ `)}catch(c){return t.error(`Cannot write ${e.updateExpect}: ${c instanceof Error?c.message:String(c)}`),2}i(`Wrote fit tables to ${e.updateExpect}.`)}if(e.expect!==void 0){let c;try{c=t.readFile(e.expect)}catch{return t.error(`Expected fit tables not found at ${e.expect} \u2014 create them with --update-expect ${e.expect}.`),2}let a;try{a=JSON.parse(c)}catch{return t.error(`${e.expect} is not JSON.`),2}if(!_e(a))return t.error(`${e.expect} is not a fit-table suite \u2014 regenerate it with --update-expect ${e.expect}.`),2;for(const u of[...a.light,...a.dark])u.componentProperties??=[];const f=Re(a,n);if(f.length>0){s>0&&Ye(n,s,t);for(const u of f)t.error(`drift: ${u}`);return t.error(`Fit tables drifted from ${e.expect} (${f.length} difference(s)). Review, then refresh deliberately with --update-expect.`),1}i(`Fit tables match ${e.expect}.`)}return e.json?(t.log(JSON.stringify(n,null,2)),s>0?1:0):(Ge(n,s,t),s>0?1:0)}function _e(e){if(!d(e)||!L.every(({field:r,kind:o})=>k(e[String(r)],o)))return!1;const t=e;if(!S(t.surfaces))return!1;for(const r of["light","dark"]){const n=t.paletteLints[r].map(T);if(!S(n))return!1;const s=t[r],i=new Set;for(const c of s){if(!Ne(c,r)||!t.surfaces.includes(c.surface)||i.has(c.surface))return!1;i.add(c.surface)}}return!0}function U(e){return typeof e=="number"&&Number.isFinite(e)}function Fe(e){return Array.isArray(e)&&e.every(t=>typeof t=="string")}function S(e){return new Set(e).size===e.length}function Ae(e){return d(e)&&K.every(({field:t,kind:r})=>k(e[String(t)],r))}function Le(e){return d(e)&&V.every(({field:t,kind:r})=>k(e[String(t)],r))}function G(e){return d(e)&&P.every(({field:t,kind:r})=>k(e[String(t)],r))}const Y=new Set(["requested","adjusted","apca","targetLc"]);function Ie(e){if(!d(e)||!C(e.name))return!1;const t=ge[e.name].pairsWith!==void 0;return!t&&(e.authored===null||Object.keys(e).some(r=>Y.has(r)))||t&&(!U(e.targetLc)||e.targetLc<=0)?!1:R.every(({field:r,kind:o})=>!t&&Y.has(r)||k(e[r],o))}function Pe(e){if(e===null||typeof e=="string")return!0;if(!d(e)||Object.keys(e).length!==2)return!1;const{source:t,lightness:r}=e;if(!$e(r)&&Se(r)===null)return!1;if(ye(t))return!0;const o=typeof t=="string"?ee(t):null;return o!==null&&z(o.name)&&(o.slot===void 0||z(o.slot))}function k(e,t){switch(t){case"anchor":return e===void 0||J(e,M);case"anchor-record":return d(e)&&Object.keys(e).every(le)&&Object.values(e).every(r=>typeof r=="string");case"apca":return e===void 0||J(e,D);case"boolean":return typeof e=="boolean";case"component-apca":return J(e,H);case"component-property-array":return e===void 0||Array.isArray(e)&&e.every(Ie);case"component-property-name":return C(e);case"component-property-value":return Pe(e);case"contrast-ground":return typeof e=="string"&&(he.has(e)||C(e));case"data-palette-record":return d(e)?["light","dark"].every(r=>{const o=e[r];return d(o)&&w.every(n=>typeof o[n]=="string")}):!1;case"explicit":return e===void 0||ne.includes(e);case"fit-lint-id":return oe.includes(e);case"fit-lint-token-array":return Array.isArray(e)&&e.every(r=>j(r)||C(r)||r===pe||r===de);case"lint-array":return Array.isArray(e)&&e.every(Le);case"message":case"string":return typeof e=="string";case"number":return U(e);case"optional-token-array":return e===void 0||Array.isArray(e)&&e.every(G);case"paint-record":return e===void 0||we(e);case"pairing":return e===void 0||se.includes(e);case"palette-lint-id":return re.includes(e);case"palette-lint-record":return d(e)&&["light","dark"].every(r=>Array.isArray(e[r])&&e[r].every(Ae));case"report-array":return Array.isArray(e);case"scheme":return e==="light"||e==="dark";case"semantic":return j(e);case"semantic-array":return Array.isArray(e)&&e.every(j);case"series-pair":return xe(e);case"simulation":return ae.includes(e);case"string-array":return Fe(e);case"token-array":return Array.isArray(e)&&e.every(G);case"warning":return ie.includes(e);default:{const r=t;return!1}}}function we(e){return d(e)?["light","dark"].every(t=>{const r=e[t];if(!Array.isArray(r))return!1;const o=new Set;for(const n of r){if(!d(n)||!I(n.role)||o.has(n.role)||n.context!==null&&!I(n.context)||!Array.isArray(n.pairs)||!Array.from(n.pairs).every(Oe))return!1;o.add(n.role)}return!0}):!1}function Oe(e){return d(e)&&I(e.element)&&I(e.foreground)&&I(e.background)&&I(e.state)&&ue(e.kind)&&U(e.ratio)&&e.ratio>=1&&e.ratio<=21&&e.required===me(e.kind)}function J(e,t){return d(e)&&t.every(({field:r,kind:o})=>k(e[String(r)],o))}function xe(e){if(!Array.isArray(e)||e.length!==2)return!1;const t=w.indexOf(e[0]),r=w.indexOf(e[1]);return t>=0&&r>t}function Ne(e,t){if(!d(e)||!A.every(({field:n,kind:s})=>k(e[String(n)],s)))return!1;const r=e;if(r.scheme!==t)return!1;const o=r.componentProperties??[];return o.every(n=>n.surface===r.surface)&&S(o.map(n=>n.name))&&S(r.tokens.map(n=>n.token))&&S((r.footerTokens??[]).map(n=>n.token))&&S(r.adjustedTokens)&&S(r.lints.map(n=>n.id))}function Re({paint:e,...t},{paint:r,...o}){const n=[];for(const i of L)i.compared&&Ce(n,i,t,o);return($(Z(t))!==$(Z(o))||n.length===0&&$(t)!==$(o))&&n.push("fit tables differ outside compared fields"),n}function Ce(e,t,r,o){const{field:n,kind:s}=t;if(s==="string-array"){const i=r[n],c=o[n];B(e,String(n),i,c),E(e,String(n),i,c);return}if(s==="data-palette-record"){const i=r[n],c=o[n];for(const a of["light","dark"])for(const f of w)X(e,`${a}/${String(n)}/${f}`,i[a][f],c[a][f]);return}if(s==="palette-lint-record"){const i=r[n],c=o[n];for(const a of["light","dark"])Ve(e,a,String(n),i[a],c[a]),E(e,`${a}/${String(n)}`,i[a].map(T),c[a].map(T));return}if(s==="report-array"&&(n==="light"||n==="dark")){be(e,n,r[n],o[n]);return}_(e,"fit tables",String(n),r[n],o[n],s)}function be(e,t,r,o){const n=new Map(r.map(i=>[i.surface,i])),s=new Map(o.map(i=>[i.surface,i]));E(e,`${t}/reports`,r.map(i=>i.surface),o.map(i=>i.surface));for(const i of F(n.keys(),s.keys())){const c=n.get(i),a=s.get(i),f=`${t}/${i}`;if(!c||!a){e.push(`${f}: surface ${c?"removed":"added"}`);continue}je(e,f,c,a)}}function je(e,t,r,o){for(const n of A){const{compared:s,field:i,kind:c}=n;if(!(!s||i==="scheme"||i==="surface")){if(c==="anchor-record"){Ue(e,`${t}/${String(i)}`,r[i],o[i]);continue}if(c==="semantic-array"){const a=r[i],f=o[i];B(e,`${t}/${String(i)}`,a,f),E(e,`${t}/${String(i)}`,a,f);continue}if(c==="lint-array"){const a=r[i],f=o[i];Ke(e,t,String(i),a,f),E(e,`${t}/${String(i)}`,a.map(u=>u.id),f.map(u=>u.id));continue}if(c==="component-property-array"){Me(e,`${t}/${String(i)}`,r.componentProperties,o.componentProperties);continue}if(c==="token-array"||c==="optional-token-array"){De(e,t,String(i),r[i]??[],o[i]??[]);continue}_(e,t,String(i),r[i],o[i],c)}}}function Me(e,t,r,o){const n=new Map(r.map(i=>[i.name,i])),s=new Map(o.map(i=>[i.name,i]));E(e,t,[...n.keys()],[...s.keys()]);for(const i of F(n.keys(),s.keys())){const c=n.get(i),a=s.get(i),f=`${t}/${i}`;if(!c||!a){e.push(`${f}: property ${c?"removed":"added"}`);continue}for(const{compared:u,field:l,kind:p}of R)!u||l==="name"||(l==="apca"?q(e,f,l,c.apca,a.apca,H):_(e,f,l,c[l],a[l],p))}}function De(e,t,r,o,n){const s=new Map(o.map(a=>[a.token,a])),i=new Map(n.map(a=>[a.token,a]));E(e,`${t}/${r}`,o.map(a=>a.token),n.map(a=>a.token));const c=r==="tokens"?t:`${t}/${r}`;for(const a of F(s.keys(),i.keys())){const f=s.get(a),u=i.get(a),l=`${c}/${a}`;if(!f||!u){e.push(`${l}: token ${f?"removed":"added"}`);continue}He(e,l,f,u)}}function He(e,t,r,o){for(const{compared:n,field:s,kind:i}of P)if(!(!n||s==="token")){if(i==="anchor"){q(e,t,"anchor",r.anchor,o.anchor,M);continue}if(i==="apca"){q(e,t,"apca",r.apca,o.apca,D);continue}_(e,t,String(s),r[s],o[s],i)}}function q(e,t,r,o,n,s){const i=o,c=n;for(const{compared:a,field:f,kind:u}of s)a&&_(e,t,`${r}.${String(f)}`,i?.[f],c?.[f],u)}function Ke(e,t,r,o,n){const s=new Map(o.map(c=>[c.id,c])),i=new Map(n.map(c=>[c.id,c]));for(const c of F(s.keys(),i.keys())){const a=s.get(c),f=i.get(c),u=`${t}/${r}/${c}`;if(!a||!f){e.push(`${u}: lint ${a?"removed":"added"}`);continue}for(const{compared:l,field:p,kind:N}of V)if(!(!l||p==="id")){if(N==="fit-lint-token-array"){Je(e,u,String(p),a[p],f[p]);continue}_(e,u,String(p),a[p],f[p],N)}}}function Ve(e,t,r,o,n){const s=new Map(o.map(c=>[T(c),c])),i=new Map(n.map(c=>[T(c),c]));for(const c of F(s.keys(),i.keys())){const a=s.get(c),f=i.get(c),u=`${t}/${r}/${c}`;if(!a||!f){e.push(`${u}: lint ${a?"removed":"added"}`);continue}for(const{compared:l,field:p,kind:N}of K)!l||p==="id"||p==="series"||p==="simulation"||_(e,u,String(p),a[p],f[p],N)}}function T(e){return`${e.id}/${e.series[0]}+${e.series[1]}/${e.simulation}`}function Ue(e,t,r,o){for(const n of F(Object.keys(r),Object.keys(o)))X(e,`${t}/${n}`,r[n],o[n])}function B(e,t,r,o){const n=new Set(r),s=new Set(o);for(const i of F(n,s))n.has(i)!==s.has(i)&&e.push(`${t}/${i}: ${n.has(i)?"removed":"added"}`)}function E(e,t,r,o){const n=new Set(r),s=new Set(o),i=r.filter(a=>s.has(a)),c=o.filter(a=>n.has(a));i.some((a,f)=>a!==c[f])&&e.push(`${t}: order changed`)}function Je(e,t,r,o,n){const s=Math.max(o.length,n.length);for(let i=0;i<s;i+=1)Q(e,t,`${r}[${i}]`,o[i],n[i])}function X(e,t,r,o){r!==o&&e.push(`${t}: ${b(r)} \u2192 ${b(o)}`)}function Q(e,t,r,o,n,s){if(!Object.is(o,n)){if(s==="message"){e.push(`${t}: message changed`);return}e.push(`${t}: ${r} ${b(o)} \u2192 ${b(n)}`)}}function qe(e,t,r,o,n){$(o)!==$(n)&&e.push(`${t}: ${r} changed`)}function _(e,t,r,o,n,s){if(ze(s)){Q(e,t,r,o,n,s);return}qe(e,t,r,o,n)}const We={anchor:!1,"anchor-record":!1,apca:!1,boolean:!0,"component-apca":!1,"component-property-array":!1,"component-property-name":!0,"component-property-value":!1,"contrast-ground":!0,"data-palette-record":!1,explicit:!0,"fit-lint-id":!0,"fit-lint-token-array":!1,"lint-array":!1,message:!0,number:!0,"optional-token-array":!1,"paint-record":!1,pairing:!0,"palette-lint-id":!0,"palette-lint-record":!1,"report-array":!1,scheme:!0,semantic:!0,"semantic-array":!1,"series-pair":!1,simulation:!0,string:!0,"string-array":!1,"token-array":!1,warning:!0};function ze(e){return We[e]===!0}function b(e){return e===void 0?"(absent)":e===""?'""':String(e)}function F(e,t){return[...new Set([...e,...t])].sort()}function $(e){return Array.isArray(e)?`[${e.map($).join(",")}]`:d(e)?`{${Object.keys(e).sort().map(t=>`${JSON.stringify(t)}:${$(e[t])}`).join(",")}}`:JSON.stringify(e)??"undefined"}function Z(e){const t=g(e,h(L)),r=["light","dark"];if(y(L,"dataPalette")){const o=g(e.dataPalette,r);for(const n of r)m(o,n,g(e.dataPalette[n],w));m(t,"dataPalette",o)}if(y(L,"paletteLints")){const o=g(e.paletteLints,r);for(const n of r)m(o,n,v(e.paletteLints[n],T,h(K)));m(t,"paletteLints",o)}for(const o of r){if(!y(L,o))continue;const n=x();for(const s of e[o]){const i=g(s,h(A));for(const c of["tokens","footerTokens"]){if(!y(A,c))continue;const a=x();for(const f of s[c]??[]){const u=g(f,h(P));f.anchor&&y(P,"anchor")&&m(u,"anchor",g(f.anchor,h(M))),f.apca&&y(P,"apca")&&m(u,"apca",g(f.apca,h(D))),m(a,f.token,u)}m(i,c,a)}if(y(A,"componentProperties")){const c=x();for(const a of s.componentProperties){const f=g(a,h(R));a.apca&&y(R,"apca")&&m(f,"apca",g(a.apca,h(H))),m(c,a.name,f)}m(i,"componentProperties",c)}y(A,"lints")&&m(i,"lints",v(s.lints,c=>c.id,h(V))),m(n,s.surface,i)}m(t,o,n)}return t}function v(e,t,r){const o=x();for(const n of e)m(o,t(n),g(n,r));return o}function h(e){return e.filter(({compared:t})=>t).map(({field:t})=>t)}function y(e,t){return e.some(r=>r.field===t&&r.compared)}function g(e,t){const r=new Set(t.map(String)),o=x();for(const[n,s]of Object.entries(e))r.has(n)||(o[n]=s);return o}function x(){return Object.create(null)}function m(e,t,r){Object.keys(r).length>0&&(e[t]=r)}function Ge(e,t,r){for(const o of["light","dark"]){for(const n of e.paletteLints[o])r.log(` ${o} lint(${n.id}): ${n.message}`);for(const n of e[o]){r.log(Qe(o,n));for(const s of n.lints)r.log(` lint(${s.id}): ${s.message}`)}}r.log(`Checked ${e.surfaces.length} surface(s) \xD7 2 schemes \u2014 `+(t===0?"no lints.":`${t} lint(s), listed above.`))}function Ye(e,t,r){r.error(`${t} theme lint(s) are standing while fit-table drift is present:`);for(const o of["light","dark"]){for(const n of e.paletteLints[o])r.error(`lint: ${o}/paletteLints/${T(n)}: ${n.message}`);for(const n of e[o])for(const s of n.lints)r.error(`lint: ${o}/${n.surface}/lints/${s.id}: ${s.message}`)}}function Be(e){return[...e.light,...e.dark].reduce((r,o)=>r+o.lints.length,0)+e.paletteLints.light.length+e.paletteLints.dark.length}function Xe(e,t){return["light","dark"].some(r=>{const o=`${r}: `;if(!e.startsWith(o))return!1;const n=e.slice(o.length);return t.paletteLints[r].some(s=>fe(n,s))})}function Qe(e,t){const r=t.adjustedTokens.length===0?"contrast enforcement moved nothing":`contrast enforcement moved ${t.adjustedTokens.join(", ")}`,o=t.tokens.filter(s=>s.explicit==="inherited").length,n=o===0?"":`; ${o} inherited explicit pin(s) \u2014 see the fit tables`;return`${e}/${t.surface}: ${t.tokens.length} tokens, ${r}${n}.`}export{ct as runEspalierCli};
@@ -4,25 +4,20 @@ import { EspalierElementBase } from "../shared/esp-element-base.js";
4
4
  import { type EspalierFormField } from "../form-item/esp-form-item.js";
5
5
  import { type PropertyValues } from "lit";
6
6
  import { type FontCategory, type FontPickerFont, type FontSource, type GoogleFont } from "./font-types.js";
7
+ import type { EspalierRoot } from "../root/esp-root.js";
7
8
  export { DEVICE_DEFAULT_WEIGHTS, SYSTEM_TEXT_WEIGHTS, WEB_SAFE_FONTS, type FontCategory, type FontPickerFont, type FontPickerValueChangedDetail, type FontSource, type GoogleFont, type WebSafeCategory, type WebSafeFont, } from "./font-types.js";
8
9
  /**
9
- * Load the font catalog from the build-generated `font-definitions.json`
10
- * file served alongside the font CSS files. The JSON is fetched from
11
- * `{fontCSSRoot}font-definitions.json` where `fontCSSRoot` comes from
12
- * the nearest `<esp-root>` element's `font-css-root` attribute.
13
- *
14
- * Results are cached at the module level so only one fetch occurs per page.
15
- * A failed request is not cached: it rejects every caller waiting on it,
16
- * and the next call retries.
10
+ * Load the catalog configured on `root`. With no argument, use the first
11
+ * light-DOM root. Callers sharing a catalog URL share its request and result.
12
+ * A failed request rejects all its callers and can be retried.
17
13
  */
18
- export declare const getGoogleFonts: () => Promise<Array<GoogleFont>>;
14
+ export declare const getGoogleFonts: (root?: EspalierRoot) => Promise<Array<GoogleFont>>;
19
15
  /**
20
- * Build the CSS `font-family` value used by picker items.
21
- * Consumers should reference this when setting `styles.fontFamily`
22
- * on picker items to match the preview `@font-face` name.
16
+ * Build the CSS family name used by picker items. Pass the picker's governing
17
+ * root to match its preview face when the page uses multiple font CSS sources.
23
18
  */
24
- export declare const previewFontFamily: (family: string) => string;
25
- export declare const getFontPreviewFamily: (font: FontPickerFont) => string;
19
+ export declare const previewFontFamily: (family: string, root?: EspalierRoot) => string;
20
+ export declare const getFontPreviewFamily: (font: FontPickerFont, root?: EspalierRoot) => string;
26
21
  /**
27
22
  * Font picker component backed by the Google Fonts catalog by default.
28
23
  *
@@ -134,6 +129,8 @@ export declare class EspalierFontPicker extends EspalierElementBase implements E
134
129
  protected getUpdateComplete(): Promise<boolean>;
135
130
  protected firstUpdated(_changedProperties: PropertyValues): void;
136
131
  protected updated(changedProperties: PropertyValues): void;
132
+ disconnectedCallback(): void;
133
+ protected governingRootChanged(root: EspalierRoot | null): void;
137
134
  protected render(): import("lit-html").TemplateResult<1>;
138
135
  }
139
136
  /**
@@ -1,9 +1,9 @@
1
- var h=function(e,t,o,i){var s=arguments.length,n=s<3?t:i===null?i=Object.getOwnPropertyDescriptor(t,o):i,a;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")n=Reflect.decorate(e,t,o,i);else for(var l=e.length-1;l>=0;l--)(a=e[l])&&(n=(s<3?a(n):s>3?a(t,o,n):a(t,o))||n);return s>3&&n&&Object.defineProperty(t,o,n),n};import"../pickers/esp-pick-one.js";import"../tooltip/esp-tooltip.js";import{customElement as x,property as y,state as A}from"lit/decorators.js";import{EspalierElementBase as T}from"../shared/esp-element-base.js";import{html as D}from"lit";import{extractFamily as L,getFallbackFont as N,removeRuntimeGoogleFontLink as B,removeRuntimeGoogleFontLinks as U,syncRuntimeGoogleFontLink as W}from"../shared/font-helpers.js";import{fontFallbackAliases as j}from"../shared/font-plan.js";import{customWebSafeFont as E,matchWebSafeFont as O}from"../shared/font-stacks.js";import{getIconHrefForHost as q}from"../shared/intent-values.js";import{WEB_SAFE_FONTS as I,isSystemPreset as b}from"./font-types.js";import{FormItemRelay as P}from"../shared/form-item-relay.js";import{DEVICE_DEFAULT_WEIGHTS as ut,SYSTEM_TEXT_WEIGHTS as dt,WEB_SAFE_FONTS as ht}from"./font-types.js";let F,m;const M=async()=>{const e=document.getElementsByTagName("esp-root")[0];if(!e)throw new Error("<esp-font-picker> requires an <esp-root> ancestor. Wrap your application in <esp-root> to use the font picker.");const t=e.fontDefinitionsUrl||`${e.fontCSSRoot}font-definitions.json`,o=await fetch(t);if(!o.ok)throw new Error(`Failed to load font definitions from ${t} (${o.status}). Run 'npm run build-fonts' to generate the font catalog.`);return await o.json()},z=async()=>{if(F)return F;if(!m){const e=M().then(t=>(F=t,t),t=>{throw m===e&&(m=void 0),t});m=e}return m},R="esp-preview-",H=e=>`${R}${e}`,g=new Map,v=async e=>{if(g.has(e))return!0;try{const t=document.getElementsByTagName("esp-root")[0];if(!t)return!1;const o=e.replaceAll(" ","-"),i=await fetch(`${t.fontCSSRoot}${o}.css`);if(!i.ok)return!1;let s=await i.text();s=s.replace(/font-family:\s*'([^']+)'/g,(a,l)=>`font-family: '${R}${l}'`);const n=document.createElement("style");return n.textContent=s,n.dataset.font=e,document.head.appendChild(n),g.set(e,n),!0}catch(t){return console.warn(`Failed to load CSS for font ${e}:`,t),!1}},w=e=>{const t=g.get(e);t&&(t.remove(),g.delete(e))},_=e=>e.closest("esp-root"),k=e=>_(e)?.correlationId??"",G=(e,t)=>`picker:${t}:${e}`,S=(e,t)=>{if(!t)return;const o=_(e),i=o?.correlationId??"";if(o?.googleFontLoading==="none"){p(e,t);return}W({owner:G(t,i),family:t,enabled:!0})},p=(e,t)=>{if(!t)return;const o=k(e);Array.from(document.getElementsByTagName("esp-font-picker")).some(s=>k(s)===o&&s.selectedGoogleFamily===t)||B(G(t,o))},d=e=>e.kind!=="web-safe",V="http://www.w3.org/2000/svg",X=(e,t)=>{const o=document.createElement("esp-tooltip");o.setAttribute("text",t==="device"?"Device font, no download":"Google font"),o.setAttribute("trigger-tabindex","-1"),o.setAttribute("style","display: grid; place-self: center;");const i=document.createElementNS(V,"svg");i.setAttribute("aria-hidden","true"),i.setAttribute("style","display: block; width: var(--esp-size-medium); height: var(--esp-size-medium); margin: var(--esp-size-tiny);");const s=document.createElementNS(V,"use");return s.setAttribute("href",q(t==="device"?"device-desktop":"brand-google",e)),i.append(s),o.append(i),o},C=e=>d(e)?e.family:e.stack,K=e=>{if(!d(e))return e.stack;const t=j(e.family,400,e.category);return[`"${e.family}"`,...t,`"${H(e.family)}"`,N(e.category)].join(", ")},$=(e,t)=>e.filter(o=>{switch(t){case"not-display":return o.category!=="display";default:return o.category===t}});let u=class extends T{constructor(){super(...arguments),this.loadedFonts=new Set,this.formItemRelay=new P(()=>this.shadowRoot?.querySelector("esp-pick-one")),this._rangeGeneration=0,this._initGeneration=0,this._fontsReady=Promise.resolve(),this.fonts=[],this.category=null,this.fontSource="google",this.value="",this.placeholder="Choose a font...",this.handleItemsInViewEvent=t=>{t.stopPropagation(),this.handleItemsInView(t.detail)}}focus(){this.shadowRoot?.querySelector("esp-pick-one")?.focus()}setFormItemDescription(t){this.formItemRelay.setDescription(t)}setFormItemLabel(t){this.formItemRelay.setLabel(t)}setFormItemInvalid(t){this.formItemRelay.setInvalid(t)}async getUpdateComplete(){const t=await super.getUpdateComplete();return await this._fontsReady,t}firstUpdated(t){super.firstUpdated(t),this._fontsReady=this.initFonts()}updated(t){super.updated(t),this.formItemRelay.apply();const o=t.has("fontSource")&&t.get("fontSource")!==void 0,i=t.has("category")&&t.get("category")!==void 0;if(o||i){if(o&&this.fontSource==="web-safe"){const s=this.value;for(const n of this.loadedFonts)w(n);this.loadedFonts.clear(),this.value="",s&&p(this,s)}this._fontsReady=this.initFonts()}if(t.has("value")&&this.value&&this.fontSource!=="web-safe"){const s=t.get("value"),n=this.googleFamilyFor(this.value),a=s?this.googleFamilyFor(s)??void 0:void 0;n&&s!==this.value?this.ensureFontLoaded(n,this.value,a):!n&&a&&p(this,a)}}get selectedGoogleFamily(){return this.fontSource==="web-safe"?null:this.googleFamilyFor(this.value)}googleFamilyFor(t){if(!t)return null;const o=this.fonts.filter(d);if(o.some(s=>s.family===t))return t;const i=L(t);return o.some(s=>s.family===i)?i:null}resolveSelection(){const t=this.value;if(!t||this.fonts.length===0)return{font:null,rowValue:t};const o=this.fontSource==="web-safe"?null:this.googleFamilyFor(t);if(o)return{font:this.fonts.find(l=>d(l)&&l.family===o)??null,rowValue:o};if(this.fontSource==="google")return{font:null,rowValue:t};const i=this.fonts.filter(a=>!d(a)),s=O(t,i);if(s)return{font:s,rowValue:s.stack};const n=E(t);return{font:n,rowValue:n?.stack??t}}async ensureFontLoaded(t,o,i){await v(t)&&this.loadedFonts.add(t),this.value===o&&(S(this,t),i&&i!==t&&p(this,i))}async initFonts(){const t=++this._initGeneration,o=this.fontSource,i=this.category?$(I,this.category):I;if(o==="web-safe"){this.fonts=i;return}const s=[...i.filter(b),...i.filter(f=>!b(f))];o==="all"&&(this.fonts=s);let n;try{n=await z()}catch(f){if(o!=="all")throw f;console.warn("esp-font-picker: the Google catalog is unavailable; listing device fonts only.",f);return}if(t!==this._initGeneration||this.fontSource!==o)return;const a=this.category?$(n,this.category):n;this.fonts=o==="all"?[...s,...a]:a;const l=this.value,c=this.googleFamilyFor(l);if(c){if(await v(c)){if(t!==this._initGeneration||this.fontSource!==o||this.value!==l){w(c);return}this.loadedFonts.add(c)}if(t!==this._initGeneration||this.fontSource!==o||this.value!==l)return;S(this,c)}}async handleItemsInView(t){if(this.fontSource==="web-safe")return;const o=++this._rangeGeneration,i=3,s=t.items??[],n=new Set,a=new Set(this.fonts.filter(d).map(r=>r.family)),l=Math.max(0,t.first),c=Math.min(t.last+i,s.length);for(let r=l;r<c;r++)a.has(s[r].value)&&n.add(s[r].value);for(const r of n)this.loadedFonts.has(r)||await v(r)&&this.loadedFonts.add(r);if(o!==this._rangeGeneration)return;const f=new Set(Array.from(document.getElementsByTagName("esp-font-picker")).map(r=>r.selectedGoogleFamily).filter(r=>!!r));for(const r of this.loadedFonts)f.has(r)||n.has(r)||(this.loadedFonts.delete(r),w(r))}render(){const t=this.resolveSelection(),o=this.fontSource==="all",s=[...t.font&&!this.fonts.includes(t.font)?[t.font]:[],...this.fonts].map(n=>({text:n.family,value:C(n),selected:t.font===n,styles:{fontFamily:K(n)},...o?{slotNodes:[X(this,d(n)?"google":"device")]}:{}}));return D`<esp-pick-one
1
+ var m=function(o,e,t,n){var s=arguments.length,r=s<3?e:n===null?n=Object.getOwnPropertyDescriptor(e,t):n,i;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(o,e,t,n);else for(var a=o.length-1;a>=0;a--)(i=o[a])&&(r=(s<3?i(r):s>3?i(e,t,r):i(e,t))||r);return s>3&&r&&Object.defineProperty(e,t,r),r};import"../pickers/esp-pick-one.js";import"../tooltip/esp-tooltip.js";import{customElement as M,property as w,state as T}from"lit/decorators.js";import{EspalierElementBase as W}from"../shared/esp-element-base.js";import{html as U}from"lit";import{extractFamily as B,getFallbackFont as N,removeRuntimeGoogleFontLink as j,removeRuntimeGoogleFontLinks as z,syncRuntimeGoogleFontLink as H}from"../shared/font-helpers.js";import{fontFallbackAliases as X}from"../shared/font-plan.js";import{customWebSafeFont as G,matchWebSafeFont as K}from"../shared/font-stacks.js";import{getIconHrefForHost as Y}from"../shared/intent-values.js";import{WEB_SAFE_FONTS as P,isSystemPreset as $}from"./font-types.js";import{FormItemRelay as J}from"../shared/form-item-relay.js";import{governingRoot as p}from"../shared/governing-root.js";import{DEVICE_DEFAULT_WEIGHTS as ke,SYSTEM_TEXT_WEIGHTS as Re,WEB_SAFE_FONTS as be}from"./font-types.js";const F=new Map,A=o=>o.fontDefinitionsUrl||`${o.fontCSSRoot}font-definitions.json`;function y(o,e){try{const t=new URL(e,o.baseURI).href;return{configuredUrl:e,key:t,url:t}}catch{return{configuredUrl:e,key:`\0${e}`,url:null}}}function k(o){const e=o.ownerDocument;return{document:e,catalog:y(e,A(o)),previews:y(e,o.fontCSSRoot).key}}function R(o,e){return o?.document===e?.document&&o?.previews===e?.previews}const Q=async o=>{const e=await fetch(o);if(!e.ok)throw new Error(`Failed to load font definitions from ${o} (${e.status}). Run 'npm run build-fonts' to generate the font catalog.`);return await e.json()};async function x({configuredUrl:o,url:e}){if(!e)throw new TypeError(`Invalid font catalog URL: ${o}`);let t=F.get(e);return t||(t=Q(e).catch(n=>{throw F.get(e)===t&&F.delete(e),n}),F.set(e,t)),t}const Fe=async(o=document.getElementsByTagName("esp-root")[0])=>{if(!o)throw new Error("<esp-font-picker> requires an <esp-root> ancestor. Wrap your application in <esp-root> to use the font picker.");return x(y(o.ownerDocument,A(o)))},b="esp-preview-",v=new WeakMap,C=o=>{let e=v.get(o);return e||(e={prefixes:new Map,styles:new Map},v.set(o,e)),e},D=o=>{const{prefixes:e}=C(o.ownerDocument),t=y(o.ownerDocument,o.fontCSSRoot).key;let n=e.get(t);return n||(n=e.size?`${b}${e.size}-`:b,e.set(t,n)),n},Z=(o,e)=>`${e?D(e):b}${o}`,ee=(o,e)=>y(o.ownerDocument,`${o.fontCSSRoot}${e.replaceAll(" ","-")}.css`),te=async(o,e,t,n)=>{try{const s=await fetch(e);if(!s.ok)return null;const r=await s.text(),i=o.createElement("style");return i.dataset.font=t,i.textContent=r.replace(/font-family:\s*'([^']+)'/g,(a,f)=>`font-family: '${n}${f}'`),i}catch(s){return console.warn(`Failed to load CSS for font ${t}:`,s),null}},oe=(o,e,{key:t,url:n})=>{const s=o.ownerDocument,r=C(s);let i=r.styles.get(t);return i||(i={users:0,ready:(n?te(s,n,e,D(o)):Promise.resolve(null)).then(c=>v.get(s)!==r||r.styles.get(t)!==i?null:(c&&s.head.append(c),c))},r.styles.set(t,i)),i.users++,{cache:r,key:t,stylesheet:i}},V=({cache:o,key:e,stylesheet:t})=>{--t.users>0||(o.styles.delete(e),t.ready.then(n=>n?.remove()))},S=new WeakMap,d=o=>o.kind!=="web-safe",O="http://www.w3.org/2000/svg",ne=(o,e)=>{const t=document.createElement("esp-tooltip");t.setAttribute("text",e==="device"?"Device font, no download":"Google font"),t.setAttribute("trigger-tabindex","-1"),t.setAttribute("style","display: grid; place-self: center;");const n=document.createElementNS(O,"svg");n.setAttribute("aria-hidden","true"),n.setAttribute("style","display: block; width: var(--esp-size-medium); height: var(--esp-size-medium); margin: var(--esp-size-tiny);");const s=document.createElementNS(O,"use");return s.setAttribute("href",Y(e==="device"?"device-desktop":"brand-google",o)),n.append(s),t.append(n),t},L=o=>d(o)?o.family:o.stack,se=(o,e)=>{if(!d(o))return o.stack;const t=X(o.family,400,o.category);return[`"${o.family}"`,...t,`"${Z(o.family,e)}"`,N(o.category)].join(", ")},q=(o,e)=>o.filter(t=>{switch(e){case"not-display":return t.category!=="display";default:return t.category===e}});let h=class extends W{constructor(){super(...arguments),this.loadedFonts=new Map,this.fontAssets=null,this.formItemRelay=new J(()=>this.shadowRoot?.querySelector("esp-pick-one")),this._rangeGeneration=0,this._initGeneration=0,this._fontsReady=Promise.resolve(),this.fullFontOwner=null,this.fonts=[],this.category=null,this.fontSource="google",this.value="",this.placeholder="Choose a font...",this.handleItemsInViewEvent=e=>{e.stopPropagation(),this.handleItemsInView(e.detail)}}focus(){this.shadowRoot?.querySelector("esp-pick-one")?.focus()}setFormItemDescription(e){this.formItemRelay.setDescription(e)}setFormItemLabel(e){this.formItemRelay.setLabel(e)}setFormItemInvalid(e){this.formItemRelay.setInvalid(e)}async getUpdateComplete(){const e=await super.getUpdateComplete();return await this._fontsReady,e}firstUpdated(e){super.firstUpdated(e),this._fontsReady=this.initFonts()}updated(e){super.updated(e),this.formItemRelay.apply();const t=e.has("fontSource")&&e.get("fontSource")!==void 0,n=e.has("category")&&e.get("category")!==void 0;if((t||n)&&(t&&this.fontSource==="web-safe"&&(this.clearPreviewFonts(),this.value="",this.releaseFullFont()),this._fontsReady=this.initFonts()),e.has("value")){const s=this.selectedGoogleFamily;s?this.ensureFontLoaded(s):this.releaseFullFont()}}disconnectedCallback(){super.disconnectedCallback(),this.releaseFullFont()}governingRootChanged(e){if(!this.hasUpdated)return;if(!e&&!this.isConnected){this._initGeneration++,this.fontAssets=null,this.clearPreviewFonts(),this.releaseFullFont();return}const t=e?k(e):null,n=this.fontAssets?.catalog.key!==t?.catalog.key;n||this.syncSelectedFullFont(e),(n||!R(this.fontAssets,t))&&(this._fontsReady=this.initFonts(e))}clearPreviewFonts(){this._rangeGeneration++;for(const e of this.loadedFonts.values())V(e);this.loadedFonts.clear()}unloadPreviewFont(e){const t=this.loadedFonts.get(e);t&&(this.loadedFonts.delete(e),V(t))}async loadPreviewFont(e,t){const n=ee(e,t);let s=this.loadedFonts.get(t);(!s||s.key!==n.key||s.cache!==C(e.ownerDocument))&&(this.unloadPreviewFont(t),s=oe(e,t,n),this.loadedFonts.set(t,s)),!await s.stylesheet.ready&&this.loadedFonts.get(t)===s&&this.unloadPreviewFont(t)}syncSelectedFullFont(e=p(this)){const t=this.selectedGoogleFamily,n=this.isConnected&&e&&e.googleFontLoading!=="none"&&t?`picker:${e.correlationId}:${t}`:null,s=e?.ownerDocument;if((n!==this.fullFontOwner?.key||s!==this.fullFontOwner?.document)&&this.releaseFullFont(),!n||!t||!s)return;let r=S.get(s);r||(r=new Map,S.set(s,r));let i=r.get(n);i||(i=new Set,r.set(n,i)),i.add(this),this.fullFontOwner={document:s,key:n},H({owner:n,family:t,enabled:!0},s)}releaseFullFont(){if(!this.fullFontOwner)return;const{document:e,key:t}=this.fullFontOwner;this.fullFontOwner=null;const n=S.get(e),s=n?.get(t);s?.delete(this),!s?.size&&(n?.delete(t),j(t,e))}get selectedGoogleFamily(){return this.fontSource==="web-safe"?null:this.googleFamilyFor(this.value)}googleFamilyFor(e){if(!e)return null;const t=this.fonts.filter(d);if(t.some(s=>s.family===e))return e;const n=B(e);return t.some(s=>s.family===n)?n:null}resolveSelection(){const e=this.value;if(!e||this.fonts.length===0)return{font:null,rowValue:e};const t=this.fontSource==="web-safe"?null:this.googleFamilyFor(e);if(t)return{font:this.fonts.find(a=>d(a)&&a.family===t)??null,rowValue:t};if(this.fontSource==="google")return{font:null,rowValue:e};const n=this.fonts.filter(i=>!d(i)),s=K(e,n);if(s)return{font:s,rowValue:s.stack};const r=G(e);return{font:r,rowValue:r?.stack??e}}async ensureFontLoaded(e){const t=this.isConnected?p(this):null;t&&(this.syncSelectedFullFont(t),await this.loadPreviewFont(t,e))}async initFonts(e=this.isConnected?p(this):null){const t=++this._initGeneration,n=this.fontSource,s=this.category,r=s?q(P,s):P,i=n!=="web-safe"&&e?k(e):null,a=this.fontAssets,f=a?.catalog.key!==i?.catalog.key;if((!i||f||!R(a,i))&&this.clearPreviewFonts(),(!i||f||a?.document!==i.document)&&this.releaseFullFont(),this.fontAssets=i,n==="web-safe"){this.fonts=r;return}const c=[...r.filter($),...r.filter(g=>!$(g))];if(n==="all"?this.fonts=c:(!i||f)&&(this.fonts=[]),!i)return;const u=await x(i.catalog).then(g=>({fonts:g}),g=>({error:g})),l=this.isConnected?p(this):null;if(!l||t!==this._initGeneration||this.fontSource!==n||this.category!==s)return;const E=k(l);if(i.catalog.key!==E.catalog.key||!R(i,E))return this.initFonts(l);if("error"in u){if(n!=="all")throw u.error;console.warn("esp-font-picker: the Google catalog is unavailable; listing device fonts only.",u.error);return}const I=s?q(u.fonts,s):u.fonts;this.fonts=n==="all"?[...c,...I]:I;const _=this.selectedGoogleFamily;this.syncSelectedFullFont(l),_&&await this.loadPreviewFont(l,_)}async handleItemsInView(e){const t=p(this);if(this.fontSource==="web-safe"||!t)return;const n=++this._rangeGeneration,s=3,r=e.items??[],i=new Set,a=new Set(this.fonts.filter(d).map(l=>l.family)),f=Math.max(0,e.first),c=Math.min(e.last+s,r.length);for(let l=f;l<c;l++)a.has(r[l].value)&&i.add(r[l].value);for(const l of i){if(n!==this._rangeGeneration)return;await this.loadPreviewFont(t,l)}if(n!==this._rangeGeneration)return;const u=this.selectedGoogleFamily;for(const l of this.loadedFonts.keys())l===u||i.has(l)||this.unloadPreviewFont(l)}render(){const e=this.resolveSelection(),t=this.fontSource==="all",n=p(this),r=[...e.font&&!this.fonts.includes(e.font)?[e.font]:[],...this.fonts].map(i=>({text:i.family,value:L(i),selected:e.font===i,styles:{fontFamily:se(i,n??void 0)},...t?{slotNodes:[ne(this,d(i)?"google":"device")]}:{}}));return U`<esp-pick-one
2
2
  typeahead
3
- .pickerItems=${s}
4
- .value=${t.rowValue}
3
+ .pickerItems=${r}
4
+ .value=${e.rowValue}
5
5
  .placeholder=${this.placeholder}
6
6
  @esp-picker-menu-range-changed=${this.handleItemsInViewEvent}
7
- @esp-value-changed=${async n=>{n.stopPropagation();const a=this.value;if(!n.detail){const r=a?this.googleFamilyFor(a):null;this.value="",r&&p(this,r),this.emitValueChanged(void 0);return}const l=this.fonts.find(r=>C(r)===n.detail.value)??(this.fontSource==="all"?E(n.detail.value)??void 0:void 0),c=n.detail.value;this.value=c,this.emitValueChanged(l);const f=a?this.googleFamilyFor(a):null;if(f&&f!==c&&p(this,f),l&&d(l)){if(await v(c)&&this.loadedFonts.add(c),this.value!==c)return;S(this,c)}}}
7
+ @esp-value-changed=${i=>{if(i.stopPropagation(),!i.detail){this.value="",this.releaseFullFont(),this.emitValueChanged(void 0);return}const a=this.fonts.find(l=>L(l)===i.detail.value)??(this.fontSource==="all"?G(i.detail.value)??void 0:void 0),f=this.selectedGoogleFamily,c=i.detail.value;if(this.value=c,this.emitValueChanged(a),this.value!==c)return;const u=this.selectedGoogleFamily;u!==f&&this.releaseFullFont(),u&&this.ensureFontLoaded(u)}}
8
8
  >
9
- </esp-pick-one>`}};u.clearsFormItemErrorOnChange=!0,h([A()],u.prototype,"fonts",void 0),h([y({attribute:"category",type:String})],u.prototype,"category",void 0),h([y({attribute:"font-source",type:String})],u.prototype,"fontSource",void 0),h([y({type:String})],u.prototype,"value",void 0),h([y({type:String})],u.prototype,"placeholder",void 0),u=h([x("esp-font-picker")],u);const lt=()=>{F=void 0,m=void 0;for(const e of document.head.querySelectorAll("style[data-font]"))e.remove();g.clear(),U("picker:")};export{ut as DEVICE_DEFAULT_WEIGHTS,u as EspalierFontPicker,dt as SYSTEM_TEXT_WEIGHTS,ht as WEB_SAFE_FONTS,K as getFontPreviewFamily,z as getGoogleFonts,H as previewFontFamily,lt as resetFontCache};
9
+ </esp-pick-one>`}};h.clearsFormItemErrorOnChange=!0,m([T()],h.prototype,"fonts",void 0),m([w({attribute:"category",type:String})],h.prototype,"category",void 0),m([w({attribute:"font-source",type:String})],h.prototype,"fontSource",void 0),m([w({type:String})],h.prototype,"value",void 0),m([w({type:String})],h.prototype,"placeholder",void 0),h=m([M("esp-font-picker")],h);const we=()=>{F.clear(),v.delete(document);for(const o of document.head.querySelectorAll("style[data-font]"))o.remove();S.delete(document),z("picker:")};export{ke as DEVICE_DEFAULT_WEIGHTS,h as EspalierFontPicker,Re as SYSTEM_TEXT_WEIGHTS,be as WEB_SAFE_FONTS,se as getFontPreviewFamily,Fe as getGoogleFonts,Z as previewFontFamily,we as resetFontCache};