contour-ds 1.7.1 → 1.8.1

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 (109) hide show
  1. package/README.md +80 -11
  2. package/dist/agent-rules.json +16 -0
  3. package/dist/build-manifest.json +184 -107
  4. package/dist/contour-wc-content.esm.js +5125 -0
  5. package/dist/contour-wc-content.esm.min.js +1 -0
  6. package/dist/contour-wc-dashboard.esm.js +8654 -0
  7. package/dist/contour-wc-dashboard.esm.min.js +1 -0
  8. package/dist/contour-wc-data.esm.js +8260 -0
  9. package/dist/contour-wc-data.esm.min.js +1 -0
  10. package/dist/contour-wc-docs.esm.js +4305 -0
  11. package/dist/contour-wc-docs.esm.min.js +1 -0
  12. package/dist/contour-wc-feedback.esm.js +4917 -0
  13. package/dist/contour-wc-feedback.esm.min.js +1 -0
  14. package/dist/contour-wc-forms.esm.js +5688 -0
  15. package/dist/contour-wc-forms.esm.min.js +1 -0
  16. package/dist/contour-wc-interaction.esm.js +4580 -0
  17. package/dist/contour-wc-interaction.esm.min.js +1 -0
  18. package/dist/contour-wc-layout.esm.js +4174 -0
  19. package/dist/contour-wc-layout.esm.min.js +1 -0
  20. package/dist/contour-wc-map.esm.js +5205 -0
  21. package/dist/contour-wc-map.esm.min.js +1 -0
  22. package/dist/contour-wc-misc.esm.js +4264 -0
  23. package/dist/contour-wc-misc.esm.min.js +1 -0
  24. package/dist/contour-wc-navigation.esm.js +5844 -0
  25. package/dist/contour-wc-navigation.esm.min.js +1 -0
  26. package/dist/contour-wc-ui.esm.js +9009 -0
  27. package/dist/contour-wc-ui.esm.min.js +1 -0
  28. package/dist/contour-wc.esm.js +6136 -1634
  29. package/dist/contour-wc.esm.min.js +1 -1
  30. package/dist/contour-wc.js +6135 -1634
  31. package/dist/contour-wc.min.js +1 -1
  32. package/dist/contour.code-snippets +4512 -0
  33. package/dist/contour.components.json +3321 -868
  34. package/dist/contour.css +5863 -3999
  35. package/dist/contour.d.ts +560 -1085
  36. package/dist/contour.esm.js +7 -0
  37. package/dist/contour.esm.min.js +1 -1
  38. package/dist/contour.html-data.json +10311 -0
  39. package/dist/contour.js +7 -0
  40. package/dist/contour.min.css +1 -1
  41. package/dist/contour.min.js +1 -1
  42. package/dist/contour.react.d.ts +420 -0
  43. package/dist/contour.single.html +17 -0
  44. package/dist/contour.single.min.css +1 -0
  45. package/dist/contour.tokens.json +940 -902
  46. package/dist/contour.vue.d.ts +418 -0
  47. package/dist/contour.web-types.json +10703 -0
  48. package/dist/custom-elements.json +30708 -0
  49. package/dist/docs/actions.md +3 -2
  50. package/dist/docs/affordances.md +25 -9
  51. package/dist/docs/apireference.md +1 -1
  52. package/dist/docs/colour.md +1 -1
  53. package/dist/docs/componentindex.md +6 -2
  54. package/dist/docs/data.md +7 -2
  55. package/dist/docs/docs.md +9 -2
  56. package/dist/docs/feedback.md +1 -1
  57. package/dist/docs/field.md +1 -1
  58. package/dist/docs/forms.md +1 -1
  59. package/dist/docs/index.json +22 -20
  60. package/dist/docs/install.md +1 -1
  61. package/dist/docs/landing.md +1 -1
  62. package/dist/docs/mapengine.md +19 -2
  63. package/dist/docs/motion.md +1 -1
  64. package/dist/docs/navigation.md +1 -1
  65. package/dist/docs/overlays.md +1 -1
  66. package/dist/docs/overview.md +1 -1
  67. package/dist/docs/patterns.md +2 -2
  68. package/dist/docs/playground.md +22 -2
  69. package/dist/docs/principles.md +1 -1
  70. package/dist/docs/recipes.md +13 -8
  71. package/dist/docs/space.md +1 -1
  72. package/dist/docs/status.md +14 -2
  73. package/dist/docs/surfaces.md +1 -1
  74. package/dist/docs/theming.md +1 -1
  75. package/dist/docs/type.md +1 -1
  76. package/dist/docs/webcomponents.md +17 -3
  77. package/dist/registry/items/contour-core.json +2 -2
  78. package/dist/registry/items/contour-data.json +2 -2
  79. package/dist/registry/items/contour-docs.json +2 -2
  80. package/dist/registry/items/contour-landing.json +2 -2
  81. package/dist/registry/registry.json +8 -8
  82. package/dist/surfaces/contour-core.min.css +1 -1
  83. package/dist/surfaces/contour-data.min.css +1 -1
  84. package/dist/surfaces/contour-docs.min.css +1 -1
  85. package/dist/surfaces/contour-landing.min.css +1 -1
  86. package/dist/wc/behaviours.mjs +45 -57
  87. package/dist/wc/content.mjs +264 -63
  88. package/dist/wc/core.mjs +390 -71
  89. package/dist/wc/dashboard.mjs +220 -13
  90. package/dist/wc/data.mjs +1094 -458
  91. package/dist/wc/docs.mjs +105 -12
  92. package/dist/wc/feedback.mjs +63 -14
  93. package/dist/wc/forms.mjs +739 -106
  94. package/dist/wc/index.mjs +9 -2
  95. package/dist/wc/interaction.mjs +184 -28
  96. package/dist/wc/layout.mjs +97 -27
  97. package/dist/wc/map.mjs +185 -118
  98. package/dist/wc/misc.mjs +124 -24
  99. package/dist/wc/navigation.mjs +384 -114
  100. package/dist/wc/shadow.mjs +94 -18
  101. package/dist/wc/states.mjs +21 -3
  102. package/dist/wc/svg.mjs +104 -0
  103. package/dist/wc/ui.mjs +1995 -478
  104. package/integrations/README.md +2 -0
  105. package/integrations/ai/CLAUDE.md +3 -3
  106. package/integrations/frameworks/README.md +235 -0
  107. package/integrations/native/style-dictionary.config.json +1 -1
  108. package/integrations/tailwind/contour-theme.css +5 -6
  109. package/package.json +53 -24
@@ -1,6 +1,67 @@
1
- import { ContourBase, define, sanitizeHtml, headingTag, formatValue } from './core.mjs';
1
+ import { ContourBase, define, sanitizeHtml, headingTag, formatValue, navKey, isRtl, safeHref , warnBadJson, labelText } from './core.mjs';
2
2
  import { loadRemote, remoteData, renderStates, renderEmpty, wireStates } from './states.mjs';
3
3
  import { wireCopy } from './behaviours.mjs';
4
+
5
+ /* Line numbers for a code block (CDS-075).
6
+
7
+ The numbers are real elements rather than a CSS counter on `::before`, for two
8
+ reasons: a counter cannot be left out of a selection, and a number that is not
9
+ in the DOM cannot be excluded from the copied text. `.c-code__line-number`
10
+ carries `user-select: none` so a drag does not take it, and `wireCopy` drops it
11
+ before writing to the clipboard, so the copied text is the code and nothing
12
+ else.
13
+
14
+ Splitting walks the top level only. A text node is split on its newlines; an
15
+ element that contains a newline of its own (a multi-line highlighted token) is
16
+ kept whole on the line it starts on, because taking it apart would break the
17
+ markup the highlighter produced. */
18
+ const splitCodeLines = (code) => {
19
+ const lines = [];
20
+ let line = null;
21
+ const add = (n) => {
22
+ if (!line) {
23
+ line = document.createElement("span");
24
+ line.className = "c-code__line";
25
+ lines.push(line);
26
+ }
27
+ line.appendChild(n);
28
+ };
29
+ Array.from(code.childNodes).forEach((n) => {
30
+ if (n.nodeType !== 3) { add(n); return; }
31
+ String(n.textContent || "").split("\n").forEach((p, i) => {
32
+ if (i) line = null;
33
+ if (p) add(document.createTextNode(p));
34
+ });
35
+ });
36
+ const last = lines[lines.length - 1];
37
+ if (last && !last.textContent && lines.length > 1) lines.pop();
38
+ if (!lines.length) return;
39
+ const frag = document.createDocumentFragment();
40
+ lines.forEach((l, i) => {
41
+ const num = document.createElement("span");
42
+ num.className = "c-code__line-number";
43
+ num.setAttribute("aria-hidden", "true");
44
+ num.textContent = String(i + 1);
45
+ l.prepend(num);
46
+ frag.appendChild(l);
47
+ });
48
+ code.textContent = "";
49
+ code.appendChild(frag);
50
+ };
51
+
52
+ const joinCodeLines = (code) => {
53
+ const frag = document.createDocumentFragment();
54
+ Array.from(code.querySelectorAll(".c-code__line")).forEach((l) => {
55
+ Array.from(l.childNodes).forEach((n) => {
56
+ if (n.classList && n.classList.contains("c-code__line-number")) return;
57
+ frag.appendChild(n);
58
+ });
59
+ frag.appendChild(document.createTextNode("\n"));
60
+ });
61
+ code.textContent = "";
62
+ code.appendChild(frag);
63
+ };
64
+
4
65
  class ContourCard extends ContourBase {
5
66
  static get observed() { return ["title", "variant", "heading"]; }
6
67
  static get properties() { return { title: { attribute: "title" }, variant: { attribute: "variant" } }; }
@@ -60,7 +121,11 @@ class ContourSteps extends ContourBase {
60
121
  static get properties() { return { steps: { attribute: "steps" }, current: { attribute: "current", type: Number }, src: { attribute: "src" } }; }
61
122
  render() {
62
123
  this.classList.add("c-steps");
63
- this.setAttribute("role", "list");
124
+ // Native list semantics: an <ol> carries the numbering and the <li> items
125
+ // are list items, rather than a role="list" on a <div> with role="listitem"
126
+ // children recreating what the platform already provides.
127
+ let list = this.querySelector(".c-steps__list");
128
+ if (!list) { list = document.createElement("ol"); list.className = "c-steps__list"; list.setAttribute("aria-label", this.getAttribute("aria-label") || "Steps"); this.appendChild(list); }
64
129
  wireStates(this);
65
130
  loadRemote(this, "steps");
66
131
  if (renderStates(this, "steps")) return;
@@ -68,13 +133,12 @@ class ContourSteps extends ContourBase {
68
133
  const authored = Array.from(this.children).filter((n) => n.classList && n.classList.contains("c-steps__item"));
69
134
  if (steps && !authored.length) {
70
135
  // Drop previously generated items so a re-render cannot stack a second set.
71
- Array.from(this.querySelectorAll(".c-steps__item")).forEach((n) => n.remove());
136
+ Array.from(list.querySelectorAll(".c-steps__item")).forEach((n) => n.remove());
72
137
  try {
73
138
  const parsed = JSON.parse(steps);
74
139
  parsed.forEach((st, i) => {
75
- const item = document.createElement("div");
140
+ const item = document.createElement("li");
76
141
  item.className = "c-steps__item";
77
- item.setAttribute("role", "listitem");
78
142
  item.tabIndex = -1;
79
143
  const title = typeof st === "string" ? st : st.title;
80
144
  const body = typeof st === "string" ? "" : st.body;
@@ -90,9 +154,9 @@ class ContourSteps extends ContourBase {
90
154
  p.textContent = body;
91
155
  item.appendChild(p);
92
156
  }
93
- this.appendChild(item);
157
+ list.appendChild(item);
94
158
  });
95
- } catch (e) { /* keep existing */ }
159
+ } catch (e) { warnBadJson(this, "attribute", e); }
96
160
  } else if (!steps && !authored.length) {
97
161
  renderEmpty(this, "steps");
98
162
  }
@@ -116,34 +180,7 @@ class ContourSteps extends ContourBase {
116
180
  this.addEventListener("keydown", (e) => {
117
181
  const items = Array.from(this.querySelectorAll(".c-steps__item"));
118
182
  if (!items.length) return;
119
- const active = document.activeElement;
120
- const idx = items.indexOf(active);
121
- let next = -1;
122
- const rtl = (this.getAttribute("dir") || document.documentElement.getAttribute("dir") || "").toLowerCase() === "rtl";
123
- if (e.key === "ArrowDown") next = idx < 0 ? 0 : Math.min(items.length - 1, idx + 1);
124
- else if (e.key === "ArrowUp") next = idx < 0 ? 0 : Math.max(0, idx - 1);
125
- else if (e.key === "ArrowRight") next = rtl ? (idx < 0 ? 0 : Math.max(0, idx - 1)) : (idx < 0 ? 0 : Math.min(items.length - 1, idx + 1));
126
- else if (e.key === "ArrowLeft") next = rtl ? (idx < 0 ? 0 : Math.min(items.length - 1, idx + 1)) : (idx < 0 ? 0 : Math.max(0, idx - 1));
127
- else if (e.key === "Home") next = 0;
128
- else if (e.key === "End") next = items.length - 1;
129
- if (next >= 0 && next !== idx) {
130
- e.preventDefault();
131
- items[next].focus();
132
- this._current = next;
133
- items.forEach((it, i) => {
134
- if (i === next) it.setAttribute("aria-current", "step");
135
- else it.removeAttribute("aria-current");
136
- it.tabIndex = i === next ? 0 : -1;
137
- });
138
- if (idx >= 0) items[idx].tabIndex = -1;
139
- const title = items[next].querySelector(".c-steps__title")?.textContent || "";
140
- this.dispatchEvent(new CustomEvent("contour:step-change", { bubbles: true, composed: true, detail: { index: next, title } }));
141
- }
142
- if ((e.key === "Enter" || e.key === " ") && idx >= 0) {
143
- e.preventDefault();
144
- const title = items[idx].querySelector(".c-steps__title")?.textContent || "";
145
- this.dispatchEvent(new CustomEvent("contour:step-activate", { bubbles: true, composed: true, detail: { index: idx, title } }));
146
- }
183
+ navKey(e, items, { wrap: false, homeEnd: true, rtl: isRtl(this), onNavigate: (i) => { this._current = i; items.forEach((it, j) => { it.setAttribute("aria-current", j === i ? "step" : ""); it.tabIndex = j === i ? 0 : -1; }); const title = items[i].querySelector(".c-steps__title")?.textContent || ""; this.dispatchEvent(new CustomEvent("contour:step-change", { bubbles: true, composed: true, detail: { index: i, title } })); }, onKey: () => { if (e.key === "Enter" || e.key === " ") { const idx = items.indexOf(document.activeElement); const title = document.activeElement.querySelector(".c-steps__title")?.textContent || ""; this.dispatchEvent(new CustomEvent("contour:step-activate", { bubbles: true, composed: true, detail: { index: idx, title } })); } } });
147
184
  });
148
185
  this.addEventListener("click", (e) => {
149
186
  const item = e.target && e.target.closest ? e.target.closest(".c-steps__item") : null;
@@ -176,7 +213,7 @@ class ContourLink extends ContourBase {
176
213
  if (prevLink) prevLink.remove();
177
214
  if (href && label) {
178
215
  const a = document.createElement("a");
179
- a.href = href;
216
+ a.href = safeHref(href);
180
217
  a.textContent = label;
181
218
  const ariaLabel = this.getAttribute("aria-label");
182
219
  if (ariaLabel) a.setAttribute("aria-label", ariaLabel);
@@ -220,7 +257,12 @@ class ContourSectionHead extends ContourBase {
220
257
  if (!this.querySelector(".c-icon-badge")) {
221
258
  const badge = document.createElement("div");
222
259
  badge.className = "c-icon-badge";
223
- badge.innerHTML = '<svg aria-hidden="true"><use href="#i-crosshair" /></svg>';
260
+ const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
261
+ svg.setAttribute("aria-hidden", "true");
262
+ const use = document.createElementNS("http://www.w3.org/2000/svg", "use");
263
+ use.setAttribute("href", "#i-crosshair");
264
+ svg.appendChild(use);
265
+ badge.replaceChildren(svg);
224
266
  this.prepend(badge);
225
267
  }
226
268
  // content wrapper
@@ -388,8 +430,8 @@ class ContourInstallFull extends ContourBase {
388
430
  const btn = document.createElement("button");
389
431
  btn.className = "c-btn c-btn--ghost c-btn--sm c-install__copy";
390
432
  btn.type = "button";
391
- btn.setAttribute("aria-label", "Copy command");
392
- btn.textContent = "Copy";
433
+ btn.setAttribute("aria-label", labelText(this, "copy-command", "Copy command"));
434
+ btn.textContent = labelText(this, "copy", "Copy");
393
435
  return btn;
394
436
  });
395
437
  } else {
@@ -422,8 +464,8 @@ class ContourTestimonialFull extends ContourBase {
422
464
  const name = this.getAttribute("name");
423
465
  const role = this.getAttribute("role");
424
466
  if (name) {
425
- const by = this.ensure(".c-testimonial__byline", () => { const el = document.createElement("div"); el.className = "c-testimonial__byline"; return el; });
426
- const n = by.querySelector(".c-testimonial__name") || (() => { const el = document.createElement("span"); el.className = "c-testimonial__name"; by.appendChild(el); return el; })();
467
+ const by = this.ensure(".c-testimonial__byline", () => { const el = document.createElement("figcaption"); el.className = "c-testimonial__byline"; return el; });
468
+ const n = by.querySelector(".c-testimonial__name") || (() => { const el = document.createElement("cite"); el.className = "c-testimonial__name"; by.appendChild(el); return el; })();
427
469
  n.className = "c-testimonial__name";
428
470
  n.textContent = name;
429
471
  if (role) {
@@ -446,6 +488,7 @@ class ContourShowcaseFull extends ContourBase {
446
488
  static get properties() { return { title: { attribute: "title" }, text: { attribute: "text" }, media: { attribute: "media" }, reverse: { attribute: "reverse" }, items: { attribute: "items" }, src: { attribute: "src" } }; }
447
489
  render() {
448
490
  this.classList.add("c-showcase");
491
+ this.setAttribute("role", "list");
449
492
  if (this.hasAttribute("reverse")) this.classList.add("c-showcase--reverse"); else this.classList.remove("c-showcase--reverse");
450
493
  const title = this.getAttribute("title");
451
494
  if (title) this.setAttribute("aria-label", title);
@@ -458,9 +501,22 @@ class ContourShowcaseFull extends ContourBase {
458
501
  const text = this.getAttribute("text");
459
502
  const media = this.getAttribute("media");
460
503
  if (media) {
461
- const m = this.ensure(".c-showcase__media", () => { const el = document.createElement("div"); el.className = "c-showcase__media"; el.setAttribute("role", "img"); return el; });
462
- m.innerHTML = sanitizeHtml(media);
463
- if (title) m.setAttribute("aria-label", title);
504
+ // A figure with a figcaption is the native shape for an illustration
505
+ // with a caption; the old div[role=img] hid the caption from the reader.
506
+ const m = this.ensure(".c-showcase__media", () => { const el = document.createElement("figure"); el.className = "c-showcase__media"; return el; });
507
+ if (/^https?:\/\/|^\/|^\.\/|\.(png|jpg|jpeg|svg|webp|gif|avif)$/i.test(media.trim())) {
508
+ let img = m.querySelector("img");
509
+ if (!img) { img = document.createElement("img"); m.appendChild(img); }
510
+ img.src = media.trim();
511
+ img.alt = title || "";
512
+ } else {
513
+ m.innerHTML = sanitizeHtml(media);
514
+ }
515
+ if (title) {
516
+ let cap = m.querySelector(".c-showcase__caption");
517
+ if (!cap) { cap = document.createElement("figcaption"); cap.className = "c-showcase__caption"; m.appendChild(cap); }
518
+ cap.textContent = title;
519
+ }
464
520
  } else {
465
521
  const m = this.querySelector(".c-showcase__media");
466
522
  if (m) m.remove();
@@ -485,13 +541,13 @@ class ContourShowcaseFull extends ContourBase {
485
541
  try {
486
542
  const parsed = JSON.parse(items);
487
543
  const l = this.ensure(".c-showcase__list", () => { const el = document.createElement("ul"); el.className = "c-showcase__list"; return el; });
488
- l.innerHTML = "";
544
+ l.replaceChildren();
489
545
  parsed.forEach((it) => {
490
546
  const li = document.createElement("li");
491
- li.textContent = typeof it === "string" ? it : it.label;
547
+ li.textContent = typeof it === "string" ? it : (it.label || it.title || "");
492
548
  l.appendChild(li);
493
549
  });
494
- } catch (e) { /* keep existing */ }
550
+ } catch (e) { warnBadJson(this, "attribute", e); }
495
551
  } else if (!items && !authored.length && !title && !text && !media) {
496
552
  renderEmpty(this, "showcase");
497
553
  } else if (!items && ul) {
@@ -508,6 +564,16 @@ class ContourShowcaseFull extends ContourBase {
508
564
  this.dispatchEvent(new CustomEvent("contour:showcase-activate", { bubbles: true, composed: true, detail: { title } }));
509
565
  }
510
566
  });
567
+ this.addEventListener("keydown", (e) => {
568
+ if (e.key === "Enter" || e.key === " ") {
569
+ const media = this.querySelector(".c-showcase__media");
570
+ if (media) {
571
+ e.preventDefault();
572
+ const title = this.getAttribute("title") || "";
573
+ this.dispatchEvent(new CustomEvent("contour:showcase-activate", { bubbles: true, composed: true, detail: { title } }));
574
+ }
575
+ }
576
+ });
511
577
  }
512
578
  }
513
579
  define("contour-showcase", ContourShowcaseFull);
@@ -522,10 +588,40 @@ class ContourPricingFull extends ContourBase {
522
588
  }
523
589
  define("contour-pricing", ContourPricingFull);
524
590
  class ContourRecipeFull extends ContourBase {
525
- static get observed() { return ["title", "body", "canvas", "heading"]; }
526
- static get properties() { return { title: { attribute: "title" }, body: { attribute: "body" }, canvas: { attribute: "canvas" } }; }
591
+ static get observed() { return ["title", "body", "canvas", "heading", "url", "tags", "head", "index"]; }
592
+ static get properties() { return { title: { attribute: "title" }, body: { attribute: "body" }, canvas: { attribute: "canvas" }, url: { attribute: "url" }, tags: { attribute: "tags" }, head: { attribute: "head" }, index: { attribute: "index" } }; }
527
593
  render() {
528
594
  this.classList.add("c-recipe");
595
+ // Frame chrome (browser mockup): opt-in via `url` attribute.
596
+ const url = this.getAttribute("url");
597
+ let frame = this.querySelector(".c-recipe__frame");
598
+ if (url) {
599
+ if (!frame) {
600
+ frame = document.createElement("div");
601
+ frame.className = "c-recipe__frame";
602
+ const bar = document.createElement("div");
603
+ bar.className = "c-recipe__frame-bar";
604
+ for (let i = 0; i < 3; i++) { const dot = document.createElement("span"); dot.className = "c-recipe__frame-dot"; bar.appendChild(dot); }
605
+ const urlEl = document.createElement("span");
606
+ urlEl.className = "c-recipe__frame-url";
607
+ bar.appendChild(urlEl);
608
+ frame.appendChild(bar);
609
+ this.prepend(frame);
610
+ }
611
+ const urlEl = frame.querySelector(".c-recipe__frame-url");
612
+ if (urlEl) urlEl.textContent = url;
613
+ } else if (frame) {
614
+ frame.remove();
615
+ }
616
+ // Head (category/eyebrow above title).
617
+ const head = this.getAttribute("head");
618
+ if (head) {
619
+ const h = this.ensure(".c-recipe__head", () => { const el = document.createElement("div"); el.className = "c-recipe__head"; return el; });
620
+ h.textContent = head;
621
+ } else {
622
+ const h = this.querySelector(".c-recipe__head");
623
+ if (h) h.remove();
624
+ }
529
625
  const title = this.getAttribute("title");
530
626
  if (title) {
531
627
  const t = this.ensure(".c-recipe__title", () => { const el = document.createElement(headingTag(this, "h3")); el.className = "c-recipe__title"; return el; });
@@ -534,6 +630,15 @@ class ContourRecipeFull extends ContourBase {
534
630
  const t = this.querySelector(".c-recipe__title");
535
631
  if (t) t.remove();
536
632
  }
633
+ // Index (recipe number, e.g. "01").
634
+ const index = this.getAttribute("index");
635
+ if (index) {
636
+ const idx = this.ensure(".c-recipe__index", () => { const el = document.createElement("span"); el.className = "c-recipe__index"; return el; });
637
+ idx.textContent = index;
638
+ } else {
639
+ const idx = this.querySelector(".c-recipe__index");
640
+ if (idx) idx.remove();
641
+ }
537
642
  const body = this.getAttribute("body");
538
643
  if (body) {
539
644
  const b = this.ensure(".c-recipe__desc", () => { const el = document.createElement("p"); el.className = "c-recipe__desc"; return el; });
@@ -542,10 +647,31 @@ class ContourRecipeFull extends ContourBase {
542
647
  const b = this.querySelector(".c-recipe__desc");
543
648
  if (b) b.remove();
544
649
  }
650
+ // Tags (comma-separated list).
651
+ const tags = this.getAttribute("tags");
652
+ if (tags) {
653
+ const t = this.ensure(".c-recipe__tags", () => { const el = document.createElement("div"); el.className = "c-recipe__tags"; return el; });
654
+ t.innerHTML = "";
655
+ tags.split(",").map((s) => s.trim()).filter(Boolean).forEach((tag) => {
656
+ const span = document.createElement("span");
657
+ span.textContent = tag;
658
+ t.appendChild(span);
659
+ });
660
+ } else {
661
+ const t = this.querySelector(".c-recipe__tags");
662
+ if (t) t.remove();
663
+ }
545
664
  const canvas = this.getAttribute("canvas");
546
665
  if (canvas) {
547
666
  const c = this.ensure(".c-recipe__canvas", () => { const el = document.createElement("div"); el.className = "c-recipe__canvas"; return el; });
548
- c.innerHTML = sanitizeHtml(canvas);
667
+ if (/^https?:\/\/|^\/|^\.\/|\.(png|jpg|jpeg|svg|webp|gif|avif)$/i.test(canvas.trim())) {
668
+ let img = c.querySelector("img");
669
+ if (!img) { img = document.createElement("img"); c.appendChild(img); }
670
+ img.src = canvas.trim();
671
+ img.alt = "";
672
+ } else {
673
+ c.innerHTML = sanitizeHtml(canvas);
674
+ }
549
675
  } else {
550
676
  const c = this.querySelector(".c-recipe__canvas");
551
677
  if (c) c.remove();
@@ -588,7 +714,12 @@ class ContourLandingFeaturesFull extends ContourBase {
588
714
  if (it.icon) {
589
715
  const ic = document.createElement("span");
590
716
  ic.className = "c-landing-features__icon";
591
- ic.innerHTML = '<svg aria-hidden="true"><use href="#' + String(it.icon).replace(/[^a-zA-Z0-9_-]/g, "") + '" /></svg>';
717
+ const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
718
+ svg.setAttribute("aria-hidden", "true");
719
+ const use = document.createElementNS("http://www.w3.org/2000/svg", "use");
720
+ use.setAttribute("href", "#" + String(it.icon).replace(/[^a-zA-Z0-9_-]/g, ""));
721
+ svg.appendChild(use);
722
+ ic.appendChild(svg);
592
723
  item.appendChild(ic);
593
724
  }
594
725
  if (it.title) {
@@ -605,7 +736,7 @@ class ContourLandingFeaturesFull extends ContourBase {
605
736
  }
606
737
  this.appendChild(item);
607
738
  });
608
- } catch (e) { /* keep existing */ }
739
+ } catch (e) { warnBadJson(this, "attribute", e); }
609
740
  } else if (!items && !authored.length) {
610
741
  this.querySelectorAll(".c-landing-features__item").forEach((el) => el.remove());
611
742
  renderEmpty(this, "landing-features");
@@ -614,13 +745,44 @@ class ContourLandingFeaturesFull extends ContourBase {
614
745
  }
615
746
  define("contour-landing-features", ContourLandingFeaturesFull);
616
747
  class ContourLandingHeroFull extends ContourBase {
617
- static get observed() { return ["actions", "title", "text", "heading"]; }
618
- static get properties() { return { actions: { attribute: "actions" }, title: { attribute: "title" }, text: { attribute: "text" } }; }
748
+ static get observed() { return ["actions", "title", "text", "heading", "preview"]; }
749
+ static get properties() { return { actions: { attribute: "actions" }, title: { attribute: "title" }, text: { attribute: "text" }, preview: { attribute: "preview" } }; }
619
750
  render() {
620
751
  this.classList.add("c-landing-hero");
752
+ // Preview mockup (product screenshot): opt-in via `preview` attribute.
753
+ const preview = this.getAttribute("preview");
754
+ let pv = this.querySelector(".c-landing-hero__preview");
755
+ if (preview) {
756
+ if (!pv) {
757
+ pv = document.createElement("div");
758
+ pv.className = "c-landing-hero__preview";
759
+ const bar = document.createElement("div");
760
+ bar.className = "c-landing-hero__preview-bar";
761
+ for (let i = 0; i < 3; i++) { const dot = document.createElement("span"); dot.className = "c-landing-hero__preview-dot"; bar.appendChild(dot); }
762
+ const body = document.createElement("div");
763
+ body.className = "c-landing-hero__preview-body";
764
+ pv.appendChild(bar);
765
+ pv.appendChild(body);
766
+ this.appendChild(pv);
767
+ }
768
+ const body = pv.querySelector(".c-landing-hero__preview-body");
769
+ if (body) {
770
+ if (/^https?:\/\/|^\/|^\.\/|\.(png|jpg|jpeg|svg|webp|gif|avif)$/i.test(preview.trim())) {
771
+ body.innerHTML = "";
772
+ const img = document.createElement("img");
773
+ img.src = preview.trim();
774
+ img.alt = "";
775
+ body.appendChild(img);
776
+ } else {
777
+ body.innerHTML = sanitizeHtml(preview);
778
+ }
779
+ }
780
+ } else if (pv) {
781
+ pv.remove();
782
+ }
621
783
  const title = this.getAttribute("title");
622
784
  if (title) {
623
- const t = this.ensure(".c-landing-hero__title", () => { const el = document.createElement(headingTag(this, "h1")); el.className = "c-landing-hero__title"; return el; });
785
+ const t = this.ensure(".c-landing-hero__title", () => { const el = document.createElement(headingTag(this, "h2")); el.className = "c-landing-hero__title"; return el; });
624
786
  t.textContent = title;
625
787
  }
626
788
  const text = this.getAttribute("text");
@@ -633,7 +795,24 @@ class ContourLandingHeroFull extends ContourBase {
633
795
  const authored = a ? Array.from(a.children) : [];
634
796
  if (actions && !authored.length) {
635
797
  const el = this.ensure(".c-landing-hero__actions", () => { const e = document.createElement("div"); e.className = "c-landing-hero__actions"; return e; });
636
- el.innerHTML = sanitizeHtml(actions);
798
+ try {
799
+ const parsed = JSON.parse(actions);
800
+ if (Array.isArray(parsed)) {
801
+ el.replaceChildren();
802
+ parsed.forEach((act) => {
803
+ const btn = document.createElement(act.href ? "a" : "button");
804
+ btn.className = "c-btn" + (act.primary ? " c-btn--primary" : "");
805
+ if (act.href) btn.href = safeHref(act.href);
806
+ else btn.type = "button";
807
+ btn.textContent = act.label || act.text || "";
808
+ el.appendChild(btn);
809
+ });
810
+ } else {
811
+ el.innerHTML = sanitizeHtml(actions);
812
+ }
813
+ } catch (_) {
814
+ el.innerHTML = sanitizeHtml(actions);
815
+ }
637
816
  } else if (!actions && a && !authored.length) {
638
817
  a.remove();
639
818
  }
@@ -661,10 +840,12 @@ class ContourProseFull extends ContourBase {
661
840
  }
662
841
  define("contour-prose", ContourProseFull);
663
842
  class ContourPanel extends ContourBase {
664
- static get observed() { return ["title", "subtitle", "status", "heading", "collapsible", "collapsed"]; }
665
- static get properties() { return { title: { attribute: "title" }, subtitle: { attribute: "subtitle" }, status: { attribute: "status" }, collapsible: { attribute: "collapsible", type: Boolean }, collapsed: { attribute: "collapsed", type: Boolean } }; }
843
+ static get observed() { return ["title", "subtitle", "status", "heading", "collapsible", "collapsed", "flush"]; }
844
+ static get properties() { return { title: { attribute: "title" }, subtitle: { attribute: "subtitle" }, status: { attribute: "status" }, collapsible: { attribute: "collapsible", type: Boolean }, collapsed: { attribute: "collapsed", type: Boolean }, flush: { attribute: "flush", type: Boolean } }; }
666
845
  render() {
667
846
  this.classList.add("c-panel");
847
+ if (!this.hasAttribute("role")) this.setAttribute("role", "region");
848
+ if (!this.hasAttribute("aria-label")) this.setAttribute("aria-label", this.getAttribute("title") || "Panel");
668
849
  const title = this.getAttribute("title");
669
850
  const subtitle = this.getAttribute("subtitle");
670
851
  const status = this.getAttribute("status");
@@ -685,6 +866,8 @@ class ContourPanel extends ContourBase {
685
866
  }
686
867
  if (status) {
687
868
  const st = this.ensure(".c-panel__status", () => { const el = document.createElement("span"); el.className = "c-panel__status"; return el; });
869
+ Array.from(st.classList).forEach((c) => { if (c.startsWith("c-panel__status--")) st.classList.remove(c); });
870
+ if (status === "error" || status === "live") st.classList.add("c-panel__status--" + status);
688
871
  st.textContent = status;
689
872
  } else {
690
873
  const st = this.querySelector(".c-panel__status");
@@ -717,6 +900,7 @@ class ContourPanel extends ContourBase {
717
900
  }
718
901
  // Wrap authored content in a body so it picks up the panel's padding.
719
902
  const body = this.ensure(".c-panel__body", () => { const el = document.createElement("div"); el.className = "c-panel__body"; return el; });
903
+ body.classList.toggle("c-panel__body--flush", this.hasAttribute("flush"));
720
904
  const head = this.querySelector(".c-panel__head");
721
905
  Array.from(this.childNodes).forEach((n) => {
722
906
  if (n === body || n === head) return;
@@ -780,14 +964,14 @@ class ContourCta extends ContourBase {
780
964
  wrap.appendChild(btn);
781
965
  });
782
966
  this.appendChild(wrap);
783
- } catch (e) { /* keep existing */ }
967
+ } catch (e) { warnBadJson(this, "attribute", e); }
784
968
  }
785
969
  }
786
970
  }
787
971
  define("contour-cta", ContourCta);
788
972
  class ContourCode extends ContourBase {
789
- static get observed() { return ["title", "copyable"]; }
790
- static get properties() { return { title: { attribute: "title" }, copyable: { attribute: "copyable", type: Boolean } }; }
973
+ static get observed() { return ["title", "copyable", "numbered"]; }
974
+ static get properties() { return { title: { attribute: "title" }, copyable: { attribute: "copyable", type: Boolean }, numbered: { attribute: "numbered", type: Boolean } }; }
791
975
  render() {
792
976
  this.classList.add("c-code");
793
977
  const title = this.getAttribute("title");
@@ -807,7 +991,7 @@ class ContourCode extends ContourBase {
807
991
  const btn = document.createElement("button");
808
992
  btn.className = "c-code__copy";
809
993
  btn.type = "button";
810
- btn.textContent = "Copy";
994
+ btn.textContent = labelText(this, "copy", "Copy");
811
995
  return btn;
812
996
  });
813
997
  } else {
@@ -831,6 +1015,22 @@ class ContourCode extends ContourBase {
831
1015
  if (head && head.parentNode === this && pre.parentNode === this && head.compareDocumentPosition(pre) & Node.DOCUMENT_POSITION_PRECEDING) {
832
1016
  this.insertBefore(pre, head.nextSibling);
833
1017
  }
1018
+ // Line numbers are applied after the code is wrapped, and are idempotent:
1019
+ // the split is guarded by a flag on the <code>, so a re-render cannot
1020
+ // number the same source twice.
1021
+ const numbered = this.hasAttribute("numbered");
1022
+ this.classList.toggle("c-code--numbered", numbered);
1023
+ const codeEl = pre.querySelector("code");
1024
+ if (codeEl) {
1025
+ const split = codeEl.dataset.contourLines === "1";
1026
+ if (numbered && !split) {
1027
+ splitCodeLines(codeEl);
1028
+ codeEl.dataset.contourLines = "1";
1029
+ } else if (!numbered && split) {
1030
+ joinCodeLines(codeEl);
1031
+ delete codeEl.dataset.contourLines;
1032
+ }
1033
+ }
834
1034
  }
835
1035
  enhance() {
836
1036
  // Interaction lives in behaviours.mjs, which the shadow wrappers call too.
@@ -883,7 +1083,7 @@ class ContourAnchor extends ContourBase {
883
1083
  if (prevAnchor) prevAnchor.remove();
884
1084
  if (href && label) {
885
1085
  const a = document.createElement("a");
886
- a.href = href;
1086
+ a.href = safeHref(href);
887
1087
  a.textContent = label;
888
1088
  const ariaLabel = this.getAttribute("aria-label");
889
1089
  if (ariaLabel) a.setAttribute("aria-label", ariaLabel);
@@ -915,6 +1115,7 @@ class ContourGeocoder extends ContourBase {
915
1115
  inp = document.createElement("input");
916
1116
  inp.type = "search";
917
1117
  inp.className = "c-geocoder__input";
1118
+ if (!inp.hasAttribute("aria-label")) inp.setAttribute("aria-label", this.getAttribute("placeholder") || "Search location");
918
1119
  this.appendChild(inp);
919
1120
  }
920
1121
  const ph = this.getAttribute("placeholder");