@f-ewald/components 1.40.0 → 1.40.2

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 (50) hide show
  1. package/README.md +6 -0
  2. package/custom-elements.json +170 -6
  3. package/dist/breadcrumb-nav.d.ts +20 -2
  4. package/dist/breadcrumb-nav.d.ts.map +1 -1
  5. package/dist/breadcrumb-nav.js +53 -7
  6. package/dist/breadcrumb-nav.js.map +1 -1
  7. package/dist/button-group.d.ts.map +1 -1
  8. package/dist/button-group.js +9 -2
  9. package/dist/button-group.js.map +1 -1
  10. package/dist/confirm-dialog.d.ts.map +1 -1
  11. package/dist/confirm-dialog.js +11 -3
  12. package/dist/confirm-dialog.js.map +1 -1
  13. package/dist/empty-state.d.ts +16 -0
  14. package/dist/empty-state.d.ts.map +1 -1
  15. package/dist/empty-state.js +39 -8
  16. package/dist/empty-state.js.map +1 -1
  17. package/dist/pagination-nav.d.ts.map +1 -1
  18. package/dist/pagination-nav.js +9 -2
  19. package/dist/pagination-nav.js.map +1 -1
  20. package/dist/radio-cards.d.ts.map +1 -1
  21. package/dist/radio-cards.js +9 -2
  22. package/dist/radio-cards.js.map +1 -1
  23. package/dist/skip-link.d.ts +10 -2
  24. package/dist/skip-link.d.ts.map +1 -1
  25. package/dist/skip-link.js +55 -7
  26. package/dist/skip-link.js.map +1 -1
  27. package/dist/spec-list.d.ts +17 -8
  28. package/dist/spec-list.d.ts.map +1 -1
  29. package/dist/spec-list.js +103 -45
  30. package/dist/spec-list.js.map +1 -1
  31. package/dist/tokens.css +1 -1
  32. package/dist/tokens.d.ts.map +1 -1
  33. package/dist/tokens.js +8 -4
  34. package/dist/tokens.js.map +1 -1
  35. package/dist/ui-button.d.ts.map +1 -1
  36. package/dist/ui-button.js +15 -3
  37. package/dist/ui-button.js.map +1 -1
  38. package/dist/vote-control.d.ts.map +1 -1
  39. package/dist/vote-control.js +9 -2
  40. package/dist/vote-control.js.map +1 -1
  41. package/docs/breadcrumb-nav.md +1 -1
  42. package/docs/button-group.md +1 -0
  43. package/docs/design-language.md +21 -0
  44. package/docs/empty-state.md +6 -1
  45. package/docs/pagination-nav.md +1 -0
  46. package/docs/skip-link.md +10 -3
  47. package/docs/spec-list.md +18 -10
  48. package/docs/ui-button.md +1 -0
  49. package/llms.txt +26 -15
  50. package/package.json +1 -1
package/dist/skip-link.js CHANGED
@@ -4,8 +4,8 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
4
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
- import { LitElement, css, html } from "lit";
8
- import { customElement, property } from "lit/decorators.js";
7
+ import { LitElement, css, html, nothing } from "lit";
8
+ import { customElement, property, state } from "lit/decorators.js";
9
9
  import { tokens } from "./tokens.js";
10
10
  /**
11
11
  * "Skip to main content" bypass link — the package's first pure
@@ -13,8 +13,13 @@ import { tokens } from "./tokens.js";
13
13
  * visually hidden (but in the focus order) until it receives keyboard focus,
14
14
  * then pins itself to the top-left of the viewport as a solid, high-contrast
15
15
  * block so a keyboard or screen-reader user can jump straight past repeated
16
- * page chrome to the main content. It needs no JavaScript beyond the element
17
- * upgrade — the anchor's native in-page navigation does the rest.
16
+ * page chrome to the main content.
17
+ *
18
+ * Activating it moves focus into the target as well as scrolling to it: a
19
+ * plain fragment link only moves focus when the target is already focusable,
20
+ * so this applies `tabindex="-1"` to the target on demand rather than making
21
+ * every consumer remember to. Native navigation is never prevented, so the
22
+ * hash still updates.
18
23
  *
19
24
  * Place it as the very first focusable element on the page, before the app
20
25
  * chrome, and point `href` at the `id` of the main content region.
@@ -29,6 +34,8 @@ let SkipLink = class SkipLink extends LitElement {
29
34
  this.href = "#main";
30
35
  /** Fallback link wording used when nothing is slotted. */
31
36
  this.label = "Skip to main content";
37
+ /** Whether the default slot holds real wording, as opposed to the whitespace ordinary formatting leaves behind. */
38
+ this._hasSlotted = false;
32
39
  }
33
40
  static { this.styles = [
34
41
  tokens,
@@ -39,9 +46,16 @@ let SkipLink = class SkipLink extends LitElement {
39
46
  /* Hidden at rest with the shared .sr-only clip technique — never
40
47
  display:none / visibility:hidden, which would pull the link out of
41
48
  the focus order and defeat the entire purpose. Clipped, it stays
42
- focusable, so Tab reaches it and reveals it. */
49
+ focusable, so Tab reaches it and reveals it.
50
+
51
+ Pinned with position: fixed, not absolute. An absolutely positioned
52
+ link resolves its insets against the nearest positioned ancestor, so
53
+ dropping the component inside any position: relative container — which
54
+ app-shell's own .shell is — would park the revealed link at that
55
+ container's corner instead of the viewport's, and an overflow: hidden
56
+ ancestor would clip it away entirely. */
43
57
  .link {
44
- position: absolute;
58
+ position: fixed;
45
59
  width: 1px;
46
60
  height: 1px;
47
61
  margin: -1px;
@@ -119,8 +133,39 @@ let SkipLink = class SkipLink extends LitElement {
119
133
  }
120
134
  `,
121
135
  ]; }
136
+ /**
137
+ * Moves focus to the fragment target, in addition to the native scroll.
138
+ *
139
+ * A plain in-page anchor only moves focus when its target is already
140
+ * focusable, so pointing a skip link at an ordinary `<main id="main">`
141
+ * scrolls the page but strands the keyboard user's focus back at the top —
142
+ * the classic way a skip link silently does nothing. Rather than requiring
143
+ * every consumer to remember `tabindex="-1"`, this applies it to the target
144
+ * on demand. Navigation is never prevented, so the hash still updates.
145
+ */
146
+ #focusTarget() {
147
+ const id = this.href.startsWith("#") ? this.href.slice(1) : "";
148
+ if (!id)
149
+ return;
150
+ const root = this.getRootNode();
151
+ const target = root.getElementById?.(id) ?? document.getElementById(id);
152
+ if (!target)
153
+ return;
154
+ if (!target.hasAttribute("tabindex"))
155
+ target.setAttribute("tabindex", "-1");
156
+ target.focus();
157
+ }
158
+ /** Tracks whether the slot holds substantive wording, so whitespace can't strip the link's accessible name. */
159
+ #onSlotChange(event) {
160
+ const slot = event.target;
161
+ this._hasSlotted = slot
162
+ .assignedNodes({ flatten: true })
163
+ .some((node) => node.nodeType === Node.ELEMENT_NODE || (node.textContent ?? "").trim().length > 0);
164
+ }
122
165
  render() {
123
- return html `<a class="link" href=${this.href}><slot>${this.label}</slot></a>`;
166
+ return html `<a class="link" href=${this.href} @click=${this.#focusTarget}
167
+ ><slot @slotchange=${this.#onSlotChange}></slot>${this._hasSlotted ? nothing : this.label}</a
168
+ >`;
124
169
  }
125
170
  };
126
171
  __decorate([
@@ -129,6 +174,9 @@ __decorate([
129
174
  __decorate([
130
175
  property()
131
176
  ], SkipLink.prototype, "label", void 0);
177
+ __decorate([
178
+ state()
179
+ ], SkipLink.prototype, "_hasSlotted", void 0);
132
180
  SkipLink = __decorate([
133
181
  customElement("skip-link")
134
182
  ], SkipLink);
@@ -1 +1 @@
1
- {"version":3,"file":"skip-link.js","sourceRoot":"","sources":["../src/skip-link.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC;;;;;;;;;;;;;;GAcG;AAEI,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,UAAU;IAAjC;;QA2FL,kFAAkF;QACtE,SAAI,GAAG,OAAO,CAAC;QAE3B,0DAA0D;QAC9C,UAAK,GAAG,sBAAsB,CAAC;IAK7C,CAAC;aAnGiB,WAAM,GAAG;QACvB,MAAM;QACN,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAqFF;KACF,AAxFqB,CAwFpB;IAQO,MAAM;QACb,OAAO,IAAI,CAAA,wBAAwB,IAAI,CAAC,IAAI,UAAU,IAAI,CAAC,KAAK,aAAa,CAAC;IAChF,CAAC;CACF,CAAA;AARa;IAAX,QAAQ,EAAE;sCAAgB;AAGf;IAAX,QAAQ,EAAE;uCAAgC;AA/FhC,QAAQ;IADpB,aAAa,CAAC,WAAW,CAAC;GACd,QAAQ,CAoGpB","sourcesContent":["import { LitElement, css, html } from \"lit\";\nimport { customElement, property } from \"lit/decorators.js\";\nimport { tokens } from \"./tokens.js\";\n\n/**\n * \"Skip to main content\" bypass link — the package's first pure\n * accessibility-utility component. It renders a real `<a>` that stays\n * visually hidden (but in the focus order) until it receives keyboard focus,\n * then pins itself to the top-left of the viewport as a solid, high-contrast\n * block so a keyboard or screen-reader user can jump straight past repeated\n * page chrome to the main content. It needs no JavaScript beyond the element\n * upgrade — the anchor's native in-page navigation does the rest.\n *\n * Place it as the very first focusable element on the page, before the app\n * chrome, and point `href` at the `id` of the main content region.\n *\n * @element skip-link\n * @slot - Optional custom link wording, overriding `label`.\n */\n@customElement(\"skip-link\")\nexport class SkipLink extends LitElement {\n static override styles = [\n tokens,\n css`\n :host {\n display: contents;\n }\n /* Hidden at rest with the shared .sr-only clip technique — never\n display:none / visibility:hidden, which would pull the link out of\n the focus order and defeat the entire purpose. Clipped, it stays\n focusable, so Tab reaches it and reveals it. */\n .link {\n position: absolute;\n width: 1px;\n height: 1px;\n margin: -1px;\n padding: 0;\n overflow: hidden;\n clip: rect(0 0 0 0);\n clip-path: inset(50%);\n white-space: nowrap;\n border: 0;\n top: 0.25rem;\n left: 0.25rem;\n /* Above app-shell's own chrome (.sidebar/.detail/.scrim at 40/40/39)\n so it paints over the top bar when revealed — but a deliberate\n literal below the shared layer stack's base of 100, and it does NOT\n call activateLayer/deactivateLayer. A skip link must never float\n above an open modal-dialog/confirm-dialog/popover-panel/slide-panel\n (all >= 100): that would be a focus escape hatch out of a modal's\n trap, a real bug. 50 sits cleanly in the gap between the shell\n chrome and any real overlay. */\n z-index: 50;\n box-sizing: border-box;\n background: var(--ui-text, #0f172a);\n color: var(--ui-on-accent, #ffffff);\n border-radius: var(--ui-radius-sm, 0.25rem);\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n font-size: var(--ui-font-size-sm, 0.75rem);\n font-weight: var(--ui-font-weight-medium, 500);\n line-height: var(--ui-line-height-tight, 1.25);\n text-decoration: none;\n box-shadow: var(--ui-shadow, 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1));\n }\n /* Both :focus and :focus-visible: the link is only ever reached by\n keyboard, so revealing it on plain focus is correct here. The visible\n padding lives here rather than on .link, because box-sizing:\n border-box would otherwise floor the clipped 1x1 box at the size of\n its own padding box, leaving an invisible 32px hit target parked over\n the page content. */\n .link:focus,\n .link:focus-visible {\n width: auto;\n height: auto;\n margin: 0;\n overflow: visible;\n clip: auto;\n clip-path: none;\n padding-top: 0.5rem;\n padding-right: 1rem;\n padding-bottom: 0.5rem;\n padding-left: 1rem;\n }\n .link:focus-visible {\n outline: none;\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n @media (forced-colors: active) {\n .link {\n background: Canvas;\n color: CanvasText;\n border: 1px solid CanvasText;\n }\n .link:focus-visible {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n }\n `,\n ];\n\n /** The in-page target the link jumps to (the `id` of the main content region). */\n @property() href = \"#main\";\n\n /** Fallback link wording used when nothing is slotted. */\n @property() label = \"Skip to main content\";\n\n override render() {\n return html`<a class=\"link\" href=${this.href}><slot>${this.label}</slot></a>`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"skip-link\": SkipLink;\n }\n}\n"]}
1
+ {"version":3,"file":"skip-link.js","sourceRoot":"","sources":["../src/skip-link.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;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AAK,CAAC,MAAyB,CAAC;QAC7C,IAAI,CAAC,WAAW,GAAG,IAAI;aACpB,aAAa,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;aAChC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,KAAK,IAAI,CAAC,YAAY,IAAI,CAAC,IAAI,CAAC,WAAW,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACvG,CAAC;IAEQ,MAAM;QACb,OAAO,IAAI,CAAA,wBAAwB,IAAI,CAAC,IAAI,WAAW,IAAI,CAAC,YAAY;2BACjD,IAAI,CAAC,aAAa,WAAW,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK;MACzF,CAAC;IACL,CAAC;CACF,CAAA;AAzCa;IAAX,QAAQ,EAAE;sCAAgB;AAGf;IAAX,QAAQ,EAAE;uCAAgC;AAG1B;IAAhB,KAAK,EAAE;6CAA6B;AAzG1B,QAAQ;IADpB,aAAa,CAAC,WAAW,CAAC;GACd,QAAQ,CA4IpB","sourcesContent":["import { LitElement, css, html, nothing } from \"lit\";\nimport { customElement, property, state } from \"lit/decorators.js\";\nimport { tokens } from \"./tokens.js\";\n\n/**\n * \"Skip to main content\" bypass link — the package's first pure\n * accessibility-utility component. It renders a real `<a>` that stays\n * visually hidden (but in the focus order) until it receives keyboard focus,\n * then pins itself to the top-left of the viewport as a solid, high-contrast\n * block so a keyboard or screen-reader user can jump straight past repeated\n * page chrome to the main content.\n *\n * Activating it moves focus into the target as well as scrolling to it: a\n * plain fragment link only moves focus when the target is already focusable,\n * so this applies `tabindex=\"-1\"` to the target on demand rather than making\n * every consumer remember to. Native navigation is never prevented, so the\n * hash still updates.\n *\n * Place it as the very first focusable element on the page, before the app\n * chrome, and point `href` at the `id` of the main content region.\n *\n * @element skip-link\n * @slot - Optional custom link wording, overriding `label`.\n */\n@customElement(\"skip-link\")\nexport class SkipLink extends LitElement {\n static override styles = [\n tokens,\n css`\n :host {\n display: contents;\n }\n /* Hidden at rest with the shared .sr-only clip technique — never\n display:none / visibility:hidden, which would pull the link out of\n the focus order and defeat the entire purpose. Clipped, it stays\n focusable, so Tab reaches it and reveals it.\n\n Pinned with position: fixed, not absolute. An absolutely positioned\n link resolves its insets against the nearest positioned ancestor, so\n dropping the component inside any position: relative container — which\n app-shell's own .shell is — would park the revealed link at that\n container's corner instead of the viewport's, and an overflow: hidden\n ancestor would clip it away entirely. */\n .link {\n position: fixed;\n width: 1px;\n height: 1px;\n margin: -1px;\n padding: 0;\n overflow: hidden;\n clip: rect(0 0 0 0);\n clip-path: inset(50%);\n white-space: nowrap;\n border: 0;\n top: 0.25rem;\n left: 0.25rem;\n /* Above app-shell's own chrome (.sidebar/.detail/.scrim at 40/40/39)\n so it paints over the top bar when revealed — but a deliberate\n literal below the shared layer stack's base of 100, and it does NOT\n call activateLayer/deactivateLayer. A skip link must never float\n above an open modal-dialog/confirm-dialog/popover-panel/slide-panel\n (all >= 100): that would be a focus escape hatch out of a modal's\n trap, a real bug. 50 sits cleanly in the gap between the shell\n chrome and any real overlay. */\n z-index: 50;\n box-sizing: border-box;\n background: var(--ui-text, #0f172a);\n color: var(--ui-on-accent, #ffffff);\n border-radius: var(--ui-radius-sm, 0.25rem);\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n font-size: var(--ui-font-size-sm, 0.75rem);\n font-weight: var(--ui-font-weight-medium, 500);\n line-height: var(--ui-line-height-tight, 1.25);\n text-decoration: none;\n box-shadow: var(--ui-shadow, 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1));\n }\n /* Both :focus and :focus-visible: the link is only ever reached by\n keyboard, so revealing it on plain focus is correct here. The visible\n padding lives here rather than on .link, because box-sizing:\n border-box would otherwise floor the clipped 1x1 box at the size of\n its own padding box, leaving an invisible 32px hit target parked over\n the page content. */\n .link:focus,\n .link:focus-visible {\n width: auto;\n height: auto;\n margin: 0;\n overflow: visible;\n clip: auto;\n clip-path: none;\n padding-top: 0.5rem;\n padding-right: 1rem;\n padding-bottom: 0.5rem;\n padding-left: 1rem;\n }\n .link:focus-visible {\n outline: none;\n box-shadow: var(--ui-focus-ring, 0 0 0 3px rgb(79 70 229 / 0.35));\n }\n @media (forced-colors: active) {\n .link {\n background: Canvas;\n color: CanvasText;\n border: 1px solid CanvasText;\n }\n .link:focus-visible {\n outline: 2px solid CanvasText;\n outline-offset: 2px;\n box-shadow: none;\n }\n }\n `,\n ];\n\n /** The in-page target the link jumps to (the `id` of the main content region). */\n @property() href = \"#main\";\n\n /** Fallback link wording used when nothing is slotted. */\n @property() label = \"Skip to main content\";\n\n /** Whether the default slot holds real wording, as opposed to the whitespace ordinary formatting leaves behind. */\n @state() private _hasSlotted = false;\n\n /**\n * Moves focus to the fragment target, in addition to the native scroll.\n *\n * A plain in-page anchor only moves focus when its target is already\n * focusable, so pointing a skip link at an ordinary `<main id=\"main\">`\n * scrolls the page but strands the keyboard user's focus back at the top —\n * the classic way a skip link silently does nothing. Rather than requiring\n * every consumer to remember `tabindex=\"-1\"`, this applies it to the target\n * on demand. Navigation is never prevented, so the hash still updates.\n */\n #focusTarget(): void {\n const id = this.href.startsWith(\"#\") ? this.href.slice(1) : \"\";\n if (!id) return;\n const root = this.getRootNode() as Document | ShadowRoot;\n const target = root.getElementById?.(id) ?? document.getElementById(id);\n if (!target) return;\n if (!target.hasAttribute(\"tabindex\")) target.setAttribute(\"tabindex\", \"-1\");\n target.focus();\n }\n\n /** Tracks whether the slot holds substantive wording, so whitespace can't strip the link's accessible name. */\n #onSlotChange(event: Event): void {\n const slot = event.target as HTMLSlotElement;\n this._hasSlotted = slot\n .assignedNodes({ flatten: true })\n .some((node) => node.nodeType === Node.ELEMENT_NODE || (node.textContent ?? \"\").trim().length > 0);\n }\n\n override render() {\n return html`<a class=\"link\" href=${this.href} @click=${this.#focusTarget}\n ><slot @slotchange=${this.#onSlotChange}></slot>${this._hasSlotted ? nothing : this.label}</a\n >`;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"skip-link\": SkipLink;\n }\n}\n"]}
@@ -8,19 +8,23 @@ export interface SpecListItem {
8
8
  }
9
9
  /**
10
10
  * A key/value specification sheet — the "spec sheet" block on a product page:
11
- * an uppercase, muted, wide-tracked key column against a value column,
12
- * separated by hairline rules. It describes ONE record's attributes, which is
11
+ * a muted, wide-tracked key column against a value column, separated by
12
+ * hairline rules (and uppercased under themes that set
13
+ * `--ui-label-transform`). It describes ONE record's attributes, which is
13
14
  * what sets it apart from `data-table` (many records, many columns, sorting);
14
15
  * `spec-list` is not tabular and renders a real `<dl>`/`<dt>`/`<dd>` structure.
15
16
  *
16
- * Feed it the `items` array for the plain data path, or slot your own
17
- * `<div><dt>…</dt><dd>…</dd></div>` groups when a value needs a link, a
18
- * `status-pill`, or other markup. Slotted content takes precedence over
19
- * `items`; with neither, nothing is rendered.
17
+ * Feed it the `items` array for the plain data path, or slot bare `<dt>`/`<dd>`
18
+ * pairs when a value needs a link, a `status-pill`, or other markup — slotted
19
+ * pairs inherit the component's own key/value styling, so no page CSS is
20
+ * needed. A `<div>` wrapping a pair is also accepted as a full-width grouping
21
+ * row, but `::slotted()` cannot reach inside it, so those `dt`/`dd` stay the
22
+ * consumer's to style. Slotted content takes precedence over `items`; with
23
+ * neither, nothing is rendered.
20
24
  *
21
25
  * @element spec-list
22
- * @slot - Optional `<div><dt>…</dt><dd>…</dd></div>` groups for values that
23
- * need custom markup; when present, they replace the `items` path.
26
+ * @slot - Optional `<dt>`/`<dd>` pairs for values that need custom markup;
27
+ * when present, they replace the `items` path.
24
28
  */
25
29
  export declare class SpecList extends LitElement {
26
30
  /** The key/value rows for the data-driven path. Ignored when the default slot has content. */
@@ -37,8 +41,13 @@ export declare class SpecList extends LitElement {
37
41
  /** Whether the default slot currently has assigned content. */
38
42
  private _hasSlotted;
39
43
  static styles: import("lit").CSSResult[];
44
+ /** Whether a slot node is real content, ignoring the whitespace ordinary indented markup leaves between children. */
45
+ private static _isContent;
40
46
  /** Tracks whether the default slot has content so slotted markup can take precedence over `items`. */
41
47
  private _onSlotChange;
48
+ connectedCallback(): void;
49
+ /** The rows, defended against a non-array value assigned at runtime by a JS or HTML consumer. */
50
+ private _rows;
42
51
  render(): import("lit-html").TemplateResult<1>;
43
52
  }
44
53
  declare global {
@@ -1 +1 @@
1
- {"version":3,"file":"spec-list.d.ts","sourceRoot":"","sources":["../src/spec-list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAsB,MAAM,KAAK,CAAC;AAIrD,+EAA+E;AAC/E,MAAM,WAAW,YAAY;IAC3B,gEAAgE;IAChE,KAAK,EAAE,MAAM,CAAC;IACd,kDAAkD;IAClD,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;;;;;GAeG;AACH,qBACa,QAAS,SAAQ,UAAU;IACtC,8FAA8F;IACnE,KAAK,EAAE,YAAY,EAAE,CAAM;IAEtD;;;OAGG;IAC0B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAU;IAEjE,wFAAwF;IAC5C,QAAQ,UAAQ;IAE5D,oGAAoG;IACxF,OAAO,SAAM;IAEzB,+DAA+D;IACtD,OAAO,CAAC,WAAW,CAAS;IAErC,OAAgB,MAAM,4BA4EpB;IAEF,sGAAsG;IACtG,OAAO,CAAC,aAAa;IAOZ,MAAM,yCAsBd;CACF;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,WAAW,EAAE,QAAQ,CAAC;KACvB;CACF"}
1
+ {"version":3,"file":"spec-list.d.ts","sourceRoot":"","sources":["../src/spec-list.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAsB,MAAM,KAAK,CAAC;AAIrD,+EAA+E;AAC/E,MAAM,WAAW,YAAY;IAC3B,gEAAgE;IAChE,KAAK,EAAE,MAAM,CAAC;IACd,kDAAkD;IAClD,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;;;;;;;;;;;GAmBG;AACH,qBACa,QAAS,SAAQ,UAAU;IACtC,8FAA8F;IACnE,KAAK,EAAE,YAAY,EAAE,CAAM;IAEtD;;;OAGG;IAC0B,MAAM,EAAE,MAAM,GAAG,SAAS,CAAU;IAEjE,wFAAwF;IAC5C,QAAQ,UAAQ;IAE5D,oGAAoG;IACxF,OAAO,SAAM;IAEzB,+DAA+D;IACtD,OAAO,CAAC,WAAW,CAAS;IAErC,OAAgB,MAAM,4BAsHpB;IAEF,qHAAqH;IACrH,OAAO,CAAC,MAAM,CAAC,UAAU;IAIzB,sGAAsG;IACtG,OAAO,CAAC,aAAa;IAKZ,iBAAiB,IAAI,IAAI,CAOjC;IAED,iGAAiG;IACjG,OAAO,CAAC,KAAK;IAIJ,MAAM,yCAgBd;CACF;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,WAAW,EAAE,QAAQ,CAAC;KACvB;CACF"}
package/dist/spec-list.js CHANGED
@@ -4,24 +4,29 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
4
4
  else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
5
  return c > 3 && r && Object.defineProperty(target, key, r), r;
6
6
  };
7
+ var SpecList_1;
7
8
  import { LitElement, css, html, nothing } from "lit";
8
9
  import { customElement, property, state } from "lit/decorators.js";
9
10
  import { tokens } from "./tokens.js";
10
11
  /**
11
12
  * A key/value specification sheet — the "spec sheet" block on a product page:
12
- * an uppercase, muted, wide-tracked key column against a value column,
13
- * separated by hairline rules. It describes ONE record's attributes, which is
13
+ * a muted, wide-tracked key column against a value column, separated by
14
+ * hairline rules (and uppercased under themes that set
15
+ * `--ui-label-transform`). It describes ONE record's attributes, which is
14
16
  * what sets it apart from `data-table` (many records, many columns, sorting);
15
17
  * `spec-list` is not tabular and renders a real `<dl>`/`<dt>`/`<dd>` structure.
16
18
  *
17
- * Feed it the `items` array for the plain data path, or slot your own
18
- * `<div><dt>…</dt><dd>…</dd></div>` groups when a value needs a link, a
19
- * `status-pill`, or other markup. Slotted content takes precedence over
20
- * `items`; with neither, nothing is rendered.
19
+ * Feed it the `items` array for the plain data path, or slot bare `<dt>`/`<dd>`
20
+ * pairs when a value needs a link, a `status-pill`, or other markup — slotted
21
+ * pairs inherit the component's own key/value styling, so no page CSS is
22
+ * needed. A `<div>` wrapping a pair is also accepted as a full-width grouping
23
+ * row, but `::slotted()` cannot reach inside it, so those `dt`/`dd` stay the
24
+ * consumer's to style. Slotted content takes precedence over `items`; with
25
+ * neither, nothing is rendered.
21
26
  *
22
27
  * @element spec-list
23
- * @slot - Optional `<div><dt>…</dt><dd>…</dd></div>` groups for values that
24
- * need custom markup; when present, they replace the `items` path.
28
+ * @slot - Optional `<dt>`/`<dd>` pairs for values that need custom markup;
29
+ * when present, they replace the `items` path.
25
30
  */
26
31
  let SpecList = class SpecList extends LitElement {
27
32
  constructor() {
@@ -40,6 +45,7 @@ let SpecList = class SpecList extends LitElement {
40
45
  /** Whether the default slot currently has assigned content. */
41
46
  this._hasSlotted = false;
42
47
  }
48
+ static { SpecList_1 = this; }
43
49
  static { this.styles = [
44
50
  tokens,
45
51
  css `
@@ -64,30 +70,25 @@ let SpecList = class SpecList extends LitElement {
64
70
  text-transform: var(--ui-label-transform, none);
65
71
  color: var(--ui-text-muted, #64748b);
66
72
  }
73
+ /* The dl itself is the two-column grid, so a slotted dt/dd pair is a
74
+ direct slottable and can be styled by this stylesheet. Nesting each
75
+ pair in a wrapper element instead would put the dt/dd a level deeper
76
+ than ::slotted() can reach, leaving slotted keys and values entirely
77
+ unstyled — including the dd's 40px UA margin and the min-width: 0 that
78
+ keeps a long value from overflowing the grid column. */
67
79
  .list {
68
80
  margin: 0;
69
- }
70
- .list.empty {
71
- display: none;
72
- }
73
- /* Both the data-driven rows and the slotted div groups are laid out as
74
- the same two-column grid so the two paths line up identically. */
75
- .row,
76
- ::slotted(*) {
77
81
  display: grid;
78
82
  grid-template-columns: 11rem minmax(0, 1fr);
79
- column-gap: 0.75rem;
80
- padding: 0.5rem 0;
81
- }
82
- :host([dividers]) .row,
83
- :host([dividers]) ::slotted(*) {
84
- border-bottom: var(--ui-border-width, 1px) solid var(--ui-border, #e2e8f0);
85
83
  }
86
- :host([dividers]) .row:last-of-type,
87
- :host([dividers]) ::slotted(*:last-of-type) {
88
- border-bottom: none;
84
+ .list.empty {
85
+ display: none;
89
86
  }
90
- .row dt {
87
+ dt,
88
+ ::slotted(dt) {
89
+ /* The column gap is padding on the key rather than column-gap, so a
90
+ divider draws as one unbroken rule across both columns. */
91
+ padding: 0.5rem 0.75rem 0.5rem 0;
91
92
  font-size: var(--ui-font-size-sm, 0.75rem);
92
93
  font-weight: var(--ui-font-weight-medium, 500);
93
94
  letter-spacing: var(--ui-tracking-wide, 0.04em);
@@ -95,38 +96,100 @@ let SpecList = class SpecList extends LitElement {
95
96
  line-height: var(--ui-line-height-normal, 1.5);
96
97
  color: var(--ui-text-muted, #64748b);
97
98
  }
98
- .row dd {
99
+ dd,
100
+ ::slotted(dd) {
99
101
  margin: 0;
100
102
  min-width: 0;
103
+ padding: 0.5rem 0;
101
104
  font-size: var(--ui-font-size, 0.875rem);
102
105
  line-height: var(--ui-line-height-normal, 1.5);
103
106
  color: var(--ui-text, #0f172a);
104
107
  word-break: break-word;
105
108
  }
106
- :host([layout="stacked"]) .row,
107
- :host([layout="stacked"]) ::slotted(*) {
109
+ :host([dividers]) dt,
110
+ :host([dividers]) dd,
111
+ :host([dividers]) ::slotted(dt),
112
+ :host([dividers]) ::slotted(dd) {
113
+ border-bottom: var(--ui-border-width, 1px) solid var(--ui-border, #e2e8f0);
114
+ }
115
+ :host([dividers]) dt:last-of-type,
116
+ :host([dividers]) dd:last-of-type,
117
+ :host([dividers]) ::slotted(dt:last-of-type),
118
+ :host([dividers]) ::slotted(dd:last-of-type) {
119
+ border-bottom: none;
120
+ }
121
+ /* A slotted wrapper element still groups a pair, but this stylesheet
122
+ cannot reach the dt/dd inside it — the consumer styles those. */
123
+ ::slotted(div) {
124
+ grid-column: 1 / -1;
125
+ display: grid;
126
+ grid-template-columns: 11rem minmax(0, 1fr);
127
+ column-gap: 0.75rem;
128
+ padding: 0.5rem 0;
129
+ }
130
+ :host([dividers]) ::slotted(div) {
131
+ border-bottom: var(--ui-border-width, 1px) solid var(--ui-border, #e2e8f0);
132
+ }
133
+ :host([dividers]) ::slotted(div:last-of-type) {
134
+ border-bottom: none;
135
+ }
136
+ /* Stacked: one column, and the rule sits under the value only, since the
137
+ key and value are now two rows of one logical row. */
138
+ :host([layout="stacked"]) .list,
139
+ :host([layout="stacked"]) ::slotted(div) {
108
140
  grid-template-columns: minmax(0, 1fr);
109
- row-gap: 0.25rem;
141
+ }
142
+ :host([layout="stacked"]) dt,
143
+ :host([layout="stacked"]) ::slotted(dt) {
144
+ padding: 0.5rem 0 0;
145
+ border-bottom: none;
146
+ }
147
+ :host([layout="stacked"]) dd,
148
+ :host([layout="stacked"]) ::slotted(dd) {
149
+ padding: 0.25rem 0 0.5rem;
110
150
  }
111
151
  @media (max-width: 48rem) {
112
- :host([layout="auto"]) .row,
113
- :host([layout="auto"]) ::slotted(*) {
152
+ :host([layout="auto"]) .list,
153
+ :host([layout="auto"]) ::slotted(div) {
114
154
  grid-template-columns: minmax(0, 1fr);
115
- row-gap: 0.25rem;
155
+ }
156
+ :host([layout="auto"]) dt,
157
+ :host([layout="auto"]) ::slotted(dt) {
158
+ padding: 0.5rem 0 0;
159
+ border-bottom: none;
160
+ }
161
+ :host([layout="auto"]) dd,
162
+ :host([layout="auto"]) ::slotted(dd) {
163
+ padding: 0.25rem 0 0.5rem;
116
164
  }
117
165
  }
118
166
  `,
119
167
  ]; }
168
+ /** Whether a slot node is real content, ignoring the whitespace ordinary indented markup leaves between children. */
169
+ static _isContent(node) {
170
+ return node.nodeType === Node.ELEMENT_NODE || (node.textContent ?? "").trim().length > 0;
171
+ }
120
172
  /** Tracks whether the default slot has content so slotted markup can take precedence over `items`. */
121
173
  _onSlotChange(event) {
122
174
  const slot = event.target;
123
- this._hasSlotted = slot.assignedNodes({ flatten: true }).some((node) => {
124
- return node.nodeType === Node.ELEMENT_NODE || (node.textContent ?? "").trim().length > 0;
125
- });
175
+ this._hasSlotted = slot.assignedNodes({ flatten: true }).some(SpecList_1._isContent);
176
+ }
177
+ connectedCallback() {
178
+ super.connectedCallback();
179
+ // slotchange only fires after the first render, so without seeding from the
180
+ // light DOM here an element given both items and slotted markup renders
181
+ // both paths for its first update — visible to anything awaiting
182
+ // updateComplete, and contrary to the documented "slot wins" contract.
183
+ this._hasSlotted = Array.from(this.childNodes).some(SpecList_1._isContent);
184
+ }
185
+ /** The rows, defended against a non-array value assigned at runtime by a JS or HTML consumer. */
186
+ _rows() {
187
+ return Array.isArray(this.items) ? this.items.filter((item) => item != null) : [];
126
188
  }
127
189
  render() {
128
- const showItems = !this._hasSlotted && this.items.length > 0;
129
- const empty = !this._hasSlotted && this.items.length === 0;
190
+ const rows = this._rows();
191
+ const showItems = !this._hasSlotted && rows.length > 0;
192
+ const empty = !this._hasSlotted && rows.length === 0;
130
193
  return html `
131
194
  ${this.caption ? html `<div class="caption" id="caption">${this.caption}</div>` : nothing}
132
195
  <dl
@@ -134,12 +197,7 @@ let SpecList = class SpecList extends LitElement {
134
197
  aria-labelledby=${this.caption ? "caption" : nothing}
135
198
  >
136
199
  ${showItems
137
- ? this.items.map((item) => html `
138
- <div class="row">
139
- <dt>${item.label}</dt>
140
- <dd>${item.value}</dd>
141
- </div>
142
- `)
200
+ ? rows.map((item) => html `<dt>${item.label}</dt><dd>${item.value}</dd>`)
143
201
  : nothing}
144
202
  <slot @slotchange=${this._onSlotChange}></slot>
145
203
  </dl>
@@ -161,7 +219,7 @@ __decorate([
161
219
  __decorate([
162
220
  state()
163
221
  ], SpecList.prototype, "_hasSlotted", void 0);
164
- SpecList = __decorate([
222
+ SpecList = SpecList_1 = __decorate([
165
223
  customElement("spec-list")
166
224
  ], SpecList);
167
225
  export { SpecList };
@@ -1 +1 @@
1
- {"version":3,"file":"spec-list.js","sourceRoot":"","sources":["../src/spec-list.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAUrC;;;;;;;;;;;;;;;GAeG;AAEI,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,UAAU;IAAjC;;QACL,8FAA8F;QACnE,UAAK,GAAmB,EAAE,CAAC;QAEtD;;;WAGG;QAC0B,WAAM,GAAuB,MAAM,CAAC;QAEjE,wFAAwF;QAC5C,aAAQ,GAAG,IAAI,CAAC;QAE5D,oGAAoG;QACxF,YAAO,GAAG,EAAE,CAAC;QAEzB,+DAA+D;QAC9C,gBAAW,GAAG,KAAK,CAAC;IA+GvC,CAAC;aA7GiB,WAAM,GAAG;QACvB,MAAM;QACN,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAyEF;KACF,AA5EqB,CA4EpB;IAEF,sGAAsG;IAC9F,aAAa,CAAC,KAAY;QAChC,MAAM,IAAI,GAAG,KAAK,CAAC,MAAyB,CAAC;QAC7C,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,aAAa,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;YACrE,OAAO,IAAI,CAAC,QAAQ,KAA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AAa,CAAC,WAAW,CAAC;GACd,QAAQ,CAgIpB","sourcesContent":["import { LitElement, css, html, nothing } from \"lit\";\nimport { customElement, property, state } from \"lit/decorators.js\";\nimport { tokens } from \"./tokens.js\";\n\n/** One key/value row of a {@link SpecList} in the data-driven `items` path. */\nexport interface SpecListItem {\n /** The attribute name, shown as the muted, wide-tracked key. */\n label: string;\n /** The attribute value, shown against the key. */\n value: string;\n}\n\n/**\n * A key/value specification sheet — the \"spec sheet\" block on a product page:\n * an uppercase, muted, wide-tracked key column against a value column,\n * separated by hairline rules. It describes ONE record's attributes, which is\n * what sets it apart from `data-table` (many records, many columns, sorting);\n * `spec-list` is not tabular and renders a real `<dl>`/`<dt>`/`<dd>` structure.\n *\n * Feed it the `items` array for the plain data path, or slot your own\n * `<div><dt>…</dt><dd>…</dd></div>` groups when a value needs a link, a\n * `status-pill`, or other markup. Slotted content takes precedence over\n * `items`; with neither, nothing is rendered.\n *\n * @element spec-list\n * @slot - Optional `<div><dt>…</dt><dd>…</dd></div>` groups for values that\n * need custom markup; when present, they replace the `items` path.\n */\n@customElement(\"spec-list\")\nexport class SpecList extends LitElement {\n /** The key/value rows for the data-driven path. Ignored when the default slot has content. */\n @property({ type: Array }) items: SpecListItem[] = [];\n\n /**\n * `auto` is the two-column grid that collapses to stacked below `48rem`;\n * `stacked` forces the stacked form at every width.\n */\n @property({ reflect: true }) layout: \"auto\" | \"stacked\" = \"auto\";\n\n /** Whether to draw a hairline rule between rows; `false` for a dense inline listing. */\n @property({ type: Boolean, reflect: true }) dividers = true;\n\n /** Optional accessible caption rendered above the list; no element or reserved space when empty. */\n @property() caption = \"\";\n\n /** Whether the default slot currently has assigned content. */\n @state() private _hasSlotted = false;\n\n static override styles = [\n tokens,\n css`\n :host {\n display: block;\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n }\n .caption {\n margin: 0 0 0.5rem;\n font-size: var(--ui-font-size-sm, 0.75rem);\n font-weight: var(--ui-font-weight-medium, 500);\n letter-spacing: var(--ui-tracking-wide, 0.04em);\n text-transform: var(--ui-label-transform, none);\n color: var(--ui-text-muted, #64748b);\n }\n .list {\n margin: 0;\n }\n .list.empty {\n display: none;\n }\n /* Both the data-driven rows and the slotted div groups are laid out as\n the same two-column grid so the two paths line up identically. */\n .row,\n ::slotted(*) {\n display: grid;\n grid-template-columns: 11rem minmax(0, 1fr);\n column-gap: 0.75rem;\n padding: 0.5rem 0;\n }\n :host([dividers]) .row,\n :host([dividers]) ::slotted(*) {\n border-bottom: var(--ui-border-width, 1px) solid var(--ui-border, #e2e8f0);\n }\n :host([dividers]) .row:last-of-type,\n :host([dividers]) ::slotted(*:last-of-type) {\n border-bottom: none;\n }\n .row dt {\n font-size: var(--ui-font-size-sm, 0.75rem);\n font-weight: var(--ui-font-weight-medium, 500);\n letter-spacing: var(--ui-tracking-wide, 0.04em);\n text-transform: var(--ui-label-transform, none);\n line-height: var(--ui-line-height-normal, 1.5);\n color: var(--ui-text-muted, #64748b);\n }\n .row dd {\n margin: 0;\n min-width: 0;\n font-size: var(--ui-font-size, 0.875rem);\n line-height: var(--ui-line-height-normal, 1.5);\n color: var(--ui-text, #0f172a);\n word-break: break-word;\n }\n :host([layout=\"stacked\"]) .row,\n :host([layout=\"stacked\"]) ::slotted(*) {\n grid-template-columns: minmax(0, 1fr);\n row-gap: 0.25rem;\n }\n @media (max-width: 48rem) {\n :host([layout=\"auto\"]) .row,\n :host([layout=\"auto\"]) ::slotted(*) {\n grid-template-columns: minmax(0, 1fr);\n row-gap: 0.25rem;\n }\n }\n `,\n ];\n\n /** Tracks whether the default slot has content so slotted markup can take precedence over `items`. */\n private _onSlotChange(event: Event): void {\n const slot = event.target as HTMLSlotElement;\n this._hasSlotted = slot.assignedNodes({ flatten: true }).some((node) => {\n return node.nodeType === Node.ELEMENT_NODE || (node.textContent ?? \"\").trim().length > 0;\n });\n }\n\n override render() {\n const showItems = !this._hasSlotted && this.items.length > 0;\n const empty = !this._hasSlotted && this.items.length === 0;\n return html`\n ${this.caption ? html`<div class=\"caption\" id=\"caption\">${this.caption}</div>` : nothing}\n <dl\n class=\"list ${empty ? \"empty\" : \"\"}\"\n aria-labelledby=${this.caption ? \"caption\" : nothing}\n >\n ${showItems\n ? this.items.map(\n (item) => html`\n <div class=\"row\">\n <dt>${item.label}</dt>\n <dd>${item.value}</dd>\n </div>\n `,\n )\n : nothing}\n <slot @slotchange=${this._onSlotChange}></slot>\n </dl>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"spec-list\": SpecList;\n }\n}\n"]}
1
+ {"version":3,"file":"spec-list.js","sourceRoot":"","sources":["../src/spec-list.ts"],"names":[],"mappings":";;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAUrC;;;;;;;;;;;;;;;;;;;GAmBG;AAEI,IAAM,QAAQ,GAAd,MAAM,QAAS,SAAQ,UAAU;IAAjC;;QACL,8FAA8F;QACnE,UAAK,GAAmB,EAAE,CAAC;QAEtD;;;WAGG;QAC0B,WAAM,GAAuB,MAAM,CAAC;QAEjE,wFAAwF;QAC5C,aAAQ,GAAG,IAAI,CAAC;QAE5D,oGAAoG;QACxF,YAAO,GAAG,EAAE,CAAC;QAEzB,+DAA+D;QAC9C,gBAAW,GAAG,KAAK,CAAC;IAoKvC,CAAC;;aAlKiB,WAAM,GAAG;QACvB,MAAM;QACN,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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D,OAAO,IAAI,CAAA;QACP,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAA,qCAAqC,IAAI,CAAC,OAAO,QAAQ,CAAC,CAAC,CAAC,OAAO;;sBAExE,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;0BAChB,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,OAAO;;UAElD,SAAS;YACT,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAA,OAAO,IAAI,CAAC,KAAK,YAAY,IAAI,CAAC,KAAK,OAAO,CAAC;YACxE,CAAC,CAAC,OAAO;4BACS,IAAI,CAAC,aAAa;;KAEzC,CAAC;IACJ,CAAC;CACF,CAAA;AAnL4B;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;uCAA4B;AAMzB;IAA5B,QAAQ,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;wCAAqC;AAGrB;IAA3C,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;0CAAiB;AAGhD;IAAX,QAAQ,EAAE;yCAAc;AAGR;IAAhB,KAAK,EAAE;6CAA6B;AAjB1B,QAAQ;IADpB,aAAa,CAAC,WAAW,CAAC;GACd,QAAQ,CAqLpB","sourcesContent":["import { LitElement, css, html, nothing } from \"lit\";\nimport { customElement, property, state } from \"lit/decorators.js\";\nimport { tokens } from \"./tokens.js\";\n\n/** One key/value row of a {@link SpecList} in the data-driven `items` path. */\nexport interface SpecListItem {\n /** The attribute name, shown as the muted, wide-tracked key. */\n label: string;\n /** The attribute value, shown against the key. */\n value: string;\n}\n\n/**\n * A key/value specification sheet — the \"spec sheet\" block on a product page:\n * a muted, wide-tracked key column against a value column, separated by\n * hairline rules (and uppercased under themes that set\n * `--ui-label-transform`). It describes ONE record's attributes, which is\n * what sets it apart from `data-table` (many records, many columns, sorting);\n * `spec-list` is not tabular and renders a real `<dl>`/`<dt>`/`<dd>` structure.\n *\n * Feed it the `items` array for the plain data path, or slot bare `<dt>`/`<dd>`\n * pairs when a value needs a link, a `status-pill`, or other markup — slotted\n * pairs inherit the component's own key/value styling, so no page CSS is\n * needed. A `<div>` wrapping a pair is also accepted as a full-width grouping\n * row, but `::slotted()` cannot reach inside it, so those `dt`/`dd` stay the\n * consumer's to style. Slotted content takes precedence over `items`; with\n * neither, nothing is rendered.\n *\n * @element spec-list\n * @slot - Optional `<dt>`/`<dd>` pairs for values that need custom markup;\n * when present, they replace the `items` path.\n */\n@customElement(\"spec-list\")\nexport class SpecList extends LitElement {\n /** The key/value rows for the data-driven path. Ignored when the default slot has content. */\n @property({ type: Array }) items: SpecListItem[] = [];\n\n /**\n * `auto` is the two-column grid that collapses to stacked below `48rem`;\n * `stacked` forces the stacked form at every width.\n */\n @property({ reflect: true }) layout: \"auto\" | \"stacked\" = \"auto\";\n\n /** Whether to draw a hairline rule between rows; `false` for a dense inline listing. */\n @property({ type: Boolean, reflect: true }) dividers = true;\n\n /** Optional accessible caption rendered above the list; no element or reserved space when empty. */\n @property() caption = \"\";\n\n /** Whether the default slot currently has assigned content. */\n @state() private _hasSlotted = false;\n\n static override styles = [\n tokens,\n css`\n :host {\n display: block;\n font-family: var(\n --ui-font,\n ui-sans-serif,\n system-ui,\n sans-serif,\n \"Apple Color Emoji\",\n \"Segoe UI Emoji\",\n \"Segoe UI Symbol\",\n \"Noto Color Emoji\"\n );\n }\n .caption {\n margin: 0 0 0.5rem;\n font-size: var(--ui-font-size-sm, 0.75rem);\n font-weight: var(--ui-font-weight-medium, 500);\n letter-spacing: var(--ui-tracking-wide, 0.04em);\n text-transform: var(--ui-label-transform, none);\n color: var(--ui-text-muted, #64748b);\n }\n /* The dl itself is the two-column grid, so a slotted dt/dd pair is a\n direct slottable and can be styled by this stylesheet. Nesting each\n pair in a wrapper element instead would put the dt/dd a level deeper\n than ::slotted() can reach, leaving slotted keys and values entirely\n unstyled — including the dd's 40px UA margin and the min-width: 0 that\n keeps a long value from overflowing the grid column. */\n .list {\n margin: 0;\n display: grid;\n grid-template-columns: 11rem minmax(0, 1fr);\n }\n .list.empty {\n display: none;\n }\n dt,\n ::slotted(dt) {\n /* The column gap is padding on the key rather than column-gap, so a\n divider draws as one unbroken rule across both columns. */\n padding: 0.5rem 0.75rem 0.5rem 0;\n font-size: var(--ui-font-size-sm, 0.75rem);\n font-weight: var(--ui-font-weight-medium, 500);\n letter-spacing: var(--ui-tracking-wide, 0.04em);\n text-transform: var(--ui-label-transform, none);\n line-height: var(--ui-line-height-normal, 1.5);\n color: var(--ui-text-muted, #64748b);\n }\n dd,\n ::slotted(dd) {\n margin: 0;\n min-width: 0;\n padding: 0.5rem 0;\n font-size: var(--ui-font-size, 0.875rem);\n line-height: var(--ui-line-height-normal, 1.5);\n color: var(--ui-text, #0f172a);\n word-break: break-word;\n }\n :host([dividers]) dt,\n :host([dividers]) dd,\n :host([dividers]) ::slotted(dt),\n :host([dividers]) ::slotted(dd) {\n border-bottom: var(--ui-border-width, 1px) solid var(--ui-border, #e2e8f0);\n }\n :host([dividers]) dt:last-of-type,\n :host([dividers]) dd:last-of-type,\n :host([dividers]) ::slotted(dt:last-of-type),\n :host([dividers]) ::slotted(dd:last-of-type) {\n border-bottom: none;\n }\n /* A slotted wrapper element still groups a pair, but this stylesheet\n cannot reach the dt/dd inside it — the consumer styles those. */\n ::slotted(div) {\n grid-column: 1 / -1;\n display: grid;\n grid-template-columns: 11rem minmax(0, 1fr);\n column-gap: 0.75rem;\n padding: 0.5rem 0;\n }\n :host([dividers]) ::slotted(div) {\n border-bottom: var(--ui-border-width, 1px) solid var(--ui-border, #e2e8f0);\n }\n :host([dividers]) ::slotted(div:last-of-type) {\n border-bottom: none;\n }\n /* Stacked: one column, and the rule sits under the value only, since the\n key and value are now two rows of one logical row. */\n :host([layout=\"stacked\"]) .list,\n :host([layout=\"stacked\"]) ::slotted(div) {\n grid-template-columns: minmax(0, 1fr);\n }\n :host([layout=\"stacked\"]) dt,\n :host([layout=\"stacked\"]) ::slotted(dt) {\n padding: 0.5rem 0 0;\n border-bottom: none;\n }\n :host([layout=\"stacked\"]) dd,\n :host([layout=\"stacked\"]) ::slotted(dd) {\n padding: 0.25rem 0 0.5rem;\n }\n @media (max-width: 48rem) {\n :host([layout=\"auto\"]) .list,\n :host([layout=\"auto\"]) ::slotted(div) {\n grid-template-columns: minmax(0, 1fr);\n }\n :host([layout=\"auto\"]) dt,\n :host([layout=\"auto\"]) ::slotted(dt) {\n padding: 0.5rem 0 0;\n border-bottom: none;\n }\n :host([layout=\"auto\"]) dd,\n :host([layout=\"auto\"]) ::slotted(dd) {\n padding: 0.25rem 0 0.5rem;\n }\n }\n `,\n ];\n\n /** Whether a slot node is real content, ignoring the whitespace ordinary indented markup leaves between children. */\n private static _isContent(node: Node): boolean {\n return node.nodeType === Node.ELEMENT_NODE || (node.textContent ?? \"\").trim().length > 0;\n }\n\n /** Tracks whether the default slot has content so slotted markup can take precedence over `items`. */\n private _onSlotChange(event: Event): void {\n const slot = event.target as HTMLSlotElement;\n this._hasSlotted = slot.assignedNodes({ flatten: true }).some(SpecList._isContent);\n }\n\n override connectedCallback(): void {\n super.connectedCallback();\n // slotchange only fires after the first render, so without seeding from the\n // light DOM here an element given both items and slotted markup renders\n // both paths for its first update — visible to anything awaiting\n // updateComplete, and contrary to the documented \"slot wins\" contract.\n this._hasSlotted = Array.from(this.childNodes).some(SpecList._isContent);\n }\n\n /** The rows, defended against a non-array value assigned at runtime by a JS or HTML consumer. */\n private _rows(): SpecListItem[] {\n return Array.isArray(this.items) ? this.items.filter((item) => item != null) : [];\n }\n\n override render() {\n const rows = this._rows();\n const showItems = !this._hasSlotted && rows.length > 0;\n const empty = !this._hasSlotted && rows.length === 0;\n return html`\n ${this.caption ? html`<div class=\"caption\" id=\"caption\">${this.caption}</div>` : nothing}\n <dl\n class=\"list ${empty ? \"empty\" : \"\"}\"\n aria-labelledby=${this.caption ? \"caption\" : nothing}\n >\n ${showItems\n ? rows.map((item) => html`<dt>${item.label}</dt><dd>${item.value}</dd>`)\n : nothing}\n <slot @slotchange=${this._onSlotChange}></slot>\n </dl>\n `;\n }\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n \"spec-list\": SpecList;\n }\n}\n"]}
package/dist/tokens.css CHANGED
@@ -173,7 +173,7 @@
173
173
  --ui-text-muted: #686763;
174
174
  --ui-surface: #ffffff;
175
175
  --ui-surface-muted: #f0f0f0;
176
- --ui-border: #a2a29f;
176
+ --ui-border: #898883;
177
177
  --ui-tooltip: #17160f;
178
178
  --ui-overlay: rgb(23 22 15 / 0.45);
179
179
  --ui-highlight: #dcdcff;
@@ -1 +1 @@
1
- {"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA8K9C,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAqBlD,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAyCtD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAanD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA2DvD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,MAAM,yBAAQ,CAAC"}
1
+ {"version":3,"file":"tokens.d.ts","sourceRoot":"","sources":["../src/tokens.ts"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,eAAO,MAAM,WAAW,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA8K9C,CAAC;AAEF;;;;;;;GAOG;AACH,eAAO,MAAM,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAqBlD,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAyCtD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,eAAO,MAAM,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAanD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgDG;AACH,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CA+DvD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,eAAO,MAAM,MAAM,yBAAQ,CAAC"}
package/dist/tokens.js CHANGED
@@ -355,10 +355,14 @@ export const blueprintTokenValues = {
355
355
  "--ui-text-muted": "#686763",
356
356
  "--ui-surface": "#ffffff",
357
357
  "--ui-surface-muted": "#f0f0f0",
358
- // ~40% ink over white: a rule that is unmistakably drawn at 1.5px without
359
- // going fully black, which at this width would turn every bordered surface
360
- // into a hard box.
361
- "--ui-border": "#a2a29f",
358
+ // ~55% ink over white. Darker than it looks like it needs to be, because a
359
+ // border is often the only thing bounding a white-on-white control, and
360
+ // WCAG 1.4.11 wants 3:1 against both adjacent surfaces for that: this is
361
+ // 3.55:1 on white and 3.12:1 on the muted surface. The lighter ~40% ink
362
+ // (#a2a29f) reads better but only reaches 2.56:1, and 1.5px of extra weight
363
+ // does not buy an exemption. Still short of fully black, which at this width
364
+ // would turn every bordered surface into a hard box.
365
+ "--ui-border": "#898883",
362
366
  "--ui-tooltip": "#17160f",
363
367
  "--ui-overlay": "rgb(23 22 15 / 0.45)",
364
368
  // The "just changed" flash tints toward the accent instead of amber, which