contour-ds 1.7.2 → 1.9.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 (150) hide show
  1. package/README.md +244 -326
  2. package/dist/agent-cookbook.json +960 -0
  3. package/dist/agent-examples.json +65 -0
  4. package/dist/agent-map-wiring.json +152 -0
  5. package/dist/agent-rules.json +16 -0
  6. package/dist/build-manifest.json +344 -126
  7. package/dist/contour-wc-content.esm.js +1939 -0
  8. package/dist/contour-wc-content.esm.min.js +1 -0
  9. package/dist/contour-wc-core.esm.js +3724 -0
  10. package/dist/contour-wc-core.esm.min.js +1 -0
  11. package/dist/contour-wc-dashboard.esm.js +6986 -0
  12. package/dist/contour-wc-dashboard.esm.min.js +1 -0
  13. package/dist/contour-wc-data.esm.js +6572 -0
  14. package/dist/contour-wc-data.esm.min.js +1 -0
  15. package/dist/contour-wc-docs.esm.js +976 -0
  16. package/dist/contour-wc-docs.esm.min.js +1 -0
  17. package/dist/contour-wc-feedback.esm.js +1742 -0
  18. package/dist/contour-wc-feedback.esm.min.js +1 -0
  19. package/dist/contour-wc-forms.esm.js +2437 -0
  20. package/dist/contour-wc-forms.esm.min.js +1 -0
  21. package/dist/contour-wc-interaction.esm.js +1343 -0
  22. package/dist/contour-wc-interaction.esm.min.js +1 -0
  23. package/dist/contour-wc-layout.esm.js +845 -0
  24. package/dist/contour-wc-layout.esm.min.js +1 -0
  25. package/dist/contour-wc-map.esm.js +2411 -0
  26. package/dist/contour-wc-map.esm.min.js +1 -0
  27. package/dist/contour-wc-misc.esm.js +945 -0
  28. package/dist/contour-wc-misc.esm.min.js +1 -0
  29. package/dist/contour-wc-navigation.esm.js +2842 -0
  30. package/dist/contour-wc-navigation.esm.min.js +1 -0
  31. package/dist/contour-wc-ui.esm.js +6519 -0
  32. package/dist/contour-wc-ui.esm.min.js +1 -0
  33. package/dist/contour-wc.esm.js +14435 -5723
  34. package/dist/contour-wc.esm.min.js +1 -1
  35. package/dist/contour-wc.js +14436 -5725
  36. package/dist/contour-wc.min.js +1 -1
  37. package/dist/contour.a11y.json +402 -0
  38. package/dist/contour.code-snippets +4534 -0
  39. package/dist/contour.components.json +4870 -1222
  40. package/dist/contour.css +6672 -4711
  41. package/dist/contour.d.ts +753 -1085
  42. package/dist/contour.esm.js +440 -18
  43. package/dist/contour.esm.min.js +1 -1
  44. package/dist/contour.html-data.json +11343 -0
  45. package/dist/contour.js +440 -18
  46. package/dist/contour.min.css +1 -1
  47. package/dist/contour.min.js +1 -1
  48. package/dist/contour.react.d.ts +422 -0
  49. package/dist/contour.single.html +17 -0
  50. package/dist/contour.single.min.css +1 -0
  51. package/dist/contour.themes.json +56 -12
  52. package/dist/contour.tokens.json +1318 -1053
  53. package/dist/contour.vue.d.ts +420 -0
  54. package/dist/contour.web-types.json +11703 -0
  55. package/dist/custom-elements.json +36120 -0
  56. package/dist/docs/actions.md +16 -6
  57. package/dist/docs/affordances.md +21 -85
  58. package/dist/docs/apireference.md +9 -5
  59. package/dist/docs/colour.md +10 -4
  60. package/dist/docs/componentindex.md +9 -22
  61. package/dist/docs/data.md +39 -58
  62. package/dist/docs/docs.md +12 -7
  63. package/dist/docs/feedback.md +30 -12
  64. package/dist/docs/field.md +28 -13
  65. package/dist/docs/forms.md +35 -19
  66. package/dist/docs/index.json +70 -61
  67. package/dist/docs/install.md +12 -7
  68. package/dist/docs/landing.md +7 -4
  69. package/dist/docs/mapengine.md +30 -8
  70. package/dist/docs/motion.md +12 -6
  71. package/dist/docs/navigation.md +31 -7
  72. package/dist/docs/overlays.md +32 -25
  73. package/dist/docs/overview.md +3 -2
  74. package/dist/docs/patterns.md +20 -10
  75. package/dist/docs/playground.md +11 -4
  76. package/dist/docs/principles.md +8 -6
  77. package/dist/docs/recipes.md +117 -13
  78. package/dist/docs/space.md +10 -6
  79. package/dist/docs/status.md +13 -14
  80. package/dist/docs/surfaces.md +17 -22
  81. package/dist/docs/theming.md +18 -32
  82. package/dist/docs/type.md +12 -5
  83. package/dist/docs/webcomponents.md +75 -33
  84. package/dist/hljs.css +1 -20
  85. package/dist/map-chrome.mapbox.css +68 -92
  86. package/dist/map-chrome.maplibre.css +68 -92
  87. package/dist/registry/items/contour-core.json +2 -2
  88. package/dist/registry/items/contour-data.json +2 -2
  89. package/dist/registry/items/contour-docs.json +2 -2
  90. package/dist/registry/items/contour-landing.json +2 -2
  91. package/dist/registry/registry.json +8 -8
  92. package/dist/surfaces/contour-core.min.css +1 -1
  93. package/dist/surfaces/contour-data.min.css +1 -1
  94. package/dist/surfaces/contour-docs.min.css +1 -1
  95. package/dist/surfaces/contour-landing.min.css +1 -1
  96. package/dist/svg/icons.svg +367 -0
  97. package/dist/wc/behaviours.mjs +222 -192
  98. package/dist/wc/content.mjs +486 -142
  99. package/dist/wc/core.mjs +917 -395
  100. package/dist/wc/dashboard.mjs +252 -25
  101. package/dist/wc/data-chart.mjs +1333 -0
  102. package/dist/wc/data-export.mjs +391 -0
  103. package/dist/wc/data-gauge.mjs +779 -0
  104. package/dist/wc/data-geo.mjs +696 -0
  105. package/dist/wc/data-glyphs.mjs +133 -0
  106. package/dist/wc/data-legend.mjs +431 -0
  107. package/dist/wc/data-readout.mjs +227 -0
  108. package/dist/wc/data-series.mjs +1004 -0
  109. package/dist/wc/data-table.mjs +751 -0
  110. package/dist/wc/data.mjs +15 -3707
  111. package/dist/wc/docs.mjs +113 -19
  112. package/dist/wc/feedback.mjs +320 -116
  113. package/dist/wc/forms-controls.mjs +635 -0
  114. package/dist/wc/forms-field.mjs +547 -0
  115. package/dist/wc/forms-groups.mjs +347 -0
  116. package/dist/wc/forms-input.mjs +292 -0
  117. package/dist/wc/forms.mjs +10 -1122
  118. package/dist/wc/glyph.mjs +204 -0
  119. package/dist/wc/index.mjs +16 -7
  120. package/dist/wc/interaction.mjs +322 -75
  121. package/dist/wc/layout.mjs +100 -29
  122. package/dist/wc/map.mjs +888 -285
  123. package/dist/wc/misc.mjs +137 -26
  124. package/dist/wc/navigation-menu.mjs +735 -0
  125. package/dist/wc/navigation-shell.mjs +495 -0
  126. package/dist/wc/navigation-tree.mjs +995 -0
  127. package/dist/wc/navigation.mjs +9 -1636
  128. package/dist/wc/registration.mjs +1 -8
  129. package/dist/wc/shadow.mjs +285 -113
  130. package/dist/wc/states.mjs +75 -78
  131. package/dist/wc/svg.mjs +209 -34
  132. package/dist/wc/ui-atoms.mjs +608 -0
  133. package/dist/wc/ui-data.mjs +1404 -0
  134. package/dist/wc/ui-feedback.mjs +419 -0
  135. package/dist/wc/ui-inputs.mjs +1570 -0
  136. package/dist/wc/ui-menus.mjs +307 -0
  137. package/dist/wc/ui-overlays.mjs +1605 -0
  138. package/integrations/README.md +25 -5
  139. package/integrations/ai/CLAUDE.md +6 -3
  140. package/integrations/ai/COPILOT.md +14 -0
  141. package/integrations/ai/GEMINI.md +14 -0
  142. package/integrations/ai/WINDSURF.md +14 -0
  143. package/integrations/ai/v0-prompt.md +13 -1
  144. package/integrations/frameworks/README.md +235 -0
  145. package/integrations/native/README.md +0 -3
  146. package/integrations/native/style-dictionary.config.json +1 -1
  147. package/integrations/tailwind/contour-theme.css +71 -13
  148. package/integrations/validate-markup.mjs +172 -0
  149. package/package.json +103 -39
  150. package/dist/wc/ui.mjs +0 -3560
package/dist/wc/docs.mjs CHANGED
@@ -1,14 +1,54 @@
1
- import { ContourBase, define, sanitizeHtml, headingTag } from './core.mjs';
1
+ import { setHTML, ContourBase, define, onDispose, sanitizeHtml, headingTag, navKey, safeHref , warnBadJson, labelText } from './core.mjs';
2
2
  import { loadRemote, remoteData, renderStates, renderEmpty, wireStates } from './states.mjs';
3
+
4
+ /* Route matching (CDS-075). The URL is the state for a documentation surface, so
5
+ the sidebar says where the reader is by marking the matching link
6
+ `aria-current="page"` — the shipped CSS already styles that attribute, and a
7
+ reader who cannot see the highlight still hears "current page".
8
+
9
+ Two ways to say where the reader is, in order:
10
+ 1. a `current` attribute on the host, which is what a client-side router
11
+ sets after it navigates (a path, or a bare `#hash`);
12
+ 2. the document's own location, which is what a static docs site has.
13
+
14
+ A bare hash also matches the last path segment, because that is the shape a
15
+ docs URL takes: `/docs/install` is the page `#install` points at. */
16
+ const routeKey = (value) => {
17
+ const raw = String(value == null ? "" : value).trim();
18
+ if (!raw) return "";
19
+ if (raw.startsWith("#")) return "hash:" + raw;
20
+ try {
21
+ const base = typeof location !== "undefined" ? location.href : "http://localhost/";
22
+ const url = new URL(raw, base);
23
+ return "path:" + url.pathname.replace(/\/+$/, "") + url.search;
24
+ } catch (e) {
25
+ return "raw:" + raw;
26
+ }
27
+ };
28
+
29
+ const hereKey = (explicit) => {
30
+ const raw = String(explicit == null ? "" : explicit).trim();
31
+ if (raw) return routeKey(raw);
32
+ if (typeof location === "undefined") return "";
33
+ return "path:" + String(location.pathname || "").replace(/\/+$/, "") + (location.search || "");
34
+ };
35
+
36
+ const hashMatchesHere = (hash) => {
37
+ if (typeof location === "undefined") return false;
38
+ if (location.hash && location.hash === hash) return true;
39
+ const segment = String(location.pathname || "").split("/").filter(Boolean).pop() || "";
40
+ return Boolean(segment) && hash === "#" + segment;
41
+ };
42
+
3
43
  class ContourDocsNav extends ContourBase {
4
- static get observed() { return ["items", "title", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton"]; }
44
+ static get observed() { return ["items", "title", "current", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton", "cache-key", "empty", "no-cache"]; }
5
45
  static get properties() { return { items: { attribute: "items" }, title: { attribute: "title" }, src: { attribute: "src" } }; }
6
46
  render() {
7
47
  this.classList.add("c-docs-nav");
8
48
  this.setAttribute("role", "navigation");
9
49
  const title = this.getAttribute("title");
10
50
  if (title) this.setAttribute("aria-label", title);
11
- else this.setAttribute("aria-label", "Documentation navigation");
51
+ else this.setAttribute("aria-label", labelText(this, "documentation-navigation", "Documentation navigation"));
12
52
  wireStates(this);
13
53
  loadRemote(this, "items");
14
54
  if (renderStates(this, "docs-nav")) return;
@@ -35,7 +75,7 @@ class ContourDocsNav extends ContourBase {
35
75
  (g.links || g.items || []).forEach((l) => {
36
76
  const a = document.createElement("a");
37
77
  a.className = "c-docs-nav__link";
38
- a.href = (typeof l === "string" ? "#" : (l.href || "#"));
78
+ a.href = safeHref(typeof l === "string" ? "#" : (l.href || "#"));
39
79
  const label = typeof l === "string" ? l : (l.label || l);
40
80
  if (typeof l === "object" && l !== null && l.badge) {
41
81
  const b = document.createElement("span");
@@ -47,7 +87,8 @@ class ContourDocsNav extends ContourBase {
47
87
  if (typeof l === "object" && l !== null && l.chevron) {
48
88
  const ch = document.createElement("span");
49
89
  ch.className = "c-docs-nav__chevron";
50
- ch.textContent = l.chevron;
90
+ // R31-152: the submenu caret is the sprite chevron, not a text glyph.
91
+ setHTML(ch, '<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-chevron-right" /></svg>');
51
92
  a.appendChild(ch);
52
93
  }
53
94
  if (typeof l === "object" && l !== null && Array.isArray(l.items)) {
@@ -57,7 +98,7 @@ class ContourDocsNav extends ContourBase {
57
98
  l.items.forEach((nl) => {
58
99
  const na = document.createElement("a");
59
100
  na.className = "c-docs-nav__link";
60
- na.href = (typeof nl === "string" ? "#" : (nl.href || "#"));
101
+ na.href = safeHref(typeof nl === "string" ? "#" : (nl.href || "#"));
61
102
  na.textContent = typeof nl === "string" ? nl : (nl.label || nl);
62
103
  nested.appendChild(na);
63
104
  });
@@ -70,13 +111,32 @@ class ContourDocsNav extends ContourBase {
70
111
  group.appendChild(ul);
71
112
  list.appendChild(group);
72
113
  });
73
- } catch (e) { /* keep existing */ }
114
+ } catch (e) { warnBadJson(this, "attribute", e); }
74
115
  } else if (!items && list) {
75
116
  list.remove();
76
117
  renderEmpty(this, "docs-nav");
77
118
  } else if (!items && !list) {
78
119
  renderEmpty(this, "docs-nav");
79
120
  }
121
+ this.applyCurrent();
122
+ }
123
+ /* Mark the link the reader is on. Idempotent: it clears every other link
124
+ first, so a re-render or a route change cannot leave two "current" items. */
125
+ applyCurrent() {
126
+ const links = Array.from(this.querySelectorAll(".c-docs-nav__link"));
127
+ if (!links.length) return;
128
+ const explicit = this.getAttribute("current");
129
+ const here = hereKey(explicit);
130
+ links.forEach((a) => {
131
+ const href = a.getAttribute("href") || "";
132
+ const key = routeKey(href);
133
+ const hit = Boolean(here) && (
134
+ (key && key === here) ||
135
+ (href.startsWith("#") && !explicit && hashMatchesHere(href))
136
+ );
137
+ if (hit) a.setAttribute("aria-current", "page");
138
+ else a.removeAttribute("aria-current");
139
+ });
80
140
  }
81
141
  enhance() {
82
142
  if (this._wiredDocsNav) return;
@@ -88,6 +148,23 @@ class ContourDocsNav extends ContourBase {
88
148
  this.dispatchEvent(new CustomEvent("contour:docs-nav-select", { bubbles: true, composed: true, detail: { label, href: link.getAttribute("href") } }));
89
149
  }
90
150
  });
151
+ // Keyboard: roving tabindex over docs-nav links, Enter follows the link.
152
+ this.addEventListener("keydown", (e) => {
153
+ const links = Array.from(this.querySelectorAll(".c-docs-nav__link"));
154
+ if (!links.length) return;
155
+ if (!links.some((l) => l.tabIndex === 0)) links.forEach((l, i) => l.tabIndex = i === 0 ? 0 : -1);
156
+ navKey(e, links, { wrap: true, homeEnd: true, onNavigate: (i) => { links.forEach((l, j) => l.tabIndex = j === i ? 0 : -1); }, onKey: (k) => { if (k === "Enter") { const a = document.activeElement; if (a) { e.preventDefault(); a.click(); } } } });
157
+ });
158
+ // Static docs navigate by URL, so highlight follows the URL not the click; a host passing `current` owns state and this is a no-op.
159
+ if (typeof window !== "undefined" && window.addEventListener) {
160
+ const sync = () => this.applyCurrent();
161
+ window.addEventListener("hashchange", sync);
162
+ window.addEventListener("popstate", sync);
163
+ onDispose(this, () => {
164
+ window.removeEventListener("hashchange", sync);
165
+ window.removeEventListener("popstate", sync);
166
+ });
167
+ }
91
168
  }
92
169
  }
93
170
  define("contour-docs-nav", ContourDocsNav);
@@ -99,7 +176,7 @@ class ContourDocsShell extends ContourBase {
99
176
  this.setAttribute("role", "region");
100
177
  const title = this.getAttribute("title");
101
178
  if (title) {
102
- const h = this.ensure(".c-docs-shell__title", () => { const el = document.createElement(headingTag(this, "h1")); el.className = "c-docs-shell__title"; return el; });
179
+ const h = this.ensure(".c-docs-shell__title", () => { const el = document.createElement(headingTag(this, "h2")); el.className = "c-docs-shell__title"; return el; });
103
180
  h.textContent = title;
104
181
  this.setAttribute("aria-label", title);
105
182
  } else {
@@ -117,7 +194,7 @@ class ContourDocsShell extends ContourBase {
117
194
  const article = this.getAttribute("article");
118
195
  if (article) {
119
196
  const a = this.ensure(".c-docs-shell__article", () => { const el = document.createElement("article"); el.className = "c-docs-shell__article"; return el; });
120
- a.innerHTML = sanitizeHtml(article);
197
+ setHTML(a, sanitizeHtml(article));
121
198
  } else {
122
199
  const a = this.querySelector(".c-docs-shell__article");
123
200
  if (a) a.remove();
@@ -140,9 +217,11 @@ class ContourFileTree extends ContourBase {
140
217
  const renderNode = (node, depth) => {
141
218
  const row = document.createElement("div");
142
219
  row.className = "c-file-tree__row" + (node.dir ? " c-file-tree__row--dir" : "") + (node.active ? " c-file-tree__row--active" : "");
143
- row.style.paddingInlineStart = (depth * 1) + "rem";
220
+ row.style.setProperty("--depth", String(depth));
144
221
  const label = document.createElement("span");
145
- label.textContent = node.label || node.name || "";
222
+ // R31-156: a folder/file glyph makes the tree scannable.
223
+ setHTML(label, node.dir ? '<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-folder" /></svg>' : '<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-file" /></svg>');
224
+ label.appendChild(document.createTextNode(" " + (node.label || node.name || "")));
146
225
  row.appendChild(label);
147
226
  this.appendChild(row);
148
227
  if (Array.isArray(node.children)) {
@@ -152,7 +231,7 @@ class ContourFileTree extends ContourBase {
152
231
  // clear generated
153
232
  Array.from(this.querySelectorAll(".c-file-tree__row")).forEach((n) => n.remove());
154
233
  parsed.forEach((n) => renderNode(n, 0));
155
- } catch (e) { /* keep existing */ }
234
+ } catch (e) { warnBadJson(this, "attribute", e); }
156
235
  }
157
236
  }
158
237
  }
@@ -167,14 +246,20 @@ class ContourChangelog extends ContourBase {
167
246
  if (src) {
168
247
  if (this.dataset.loaded === src) return;
169
248
  this.dataset.loaded = "";
170
- const loading = this.ensure(".c-changelog__loading", () => { const el = document.createElement("div"); el.className = "c-changelog__loading"; el.textContent = "Loading…"; return el; });
249
+ const loading = this.ensure(".c-changelog__loading", () => { const el = document.createElement("div"); el.className = "c-changelog__loading"; return el; });
250
+ loading.textContent = labelText(this, "loading", "Loading…");
171
251
  // clear
172
252
  Array.from(this.querySelectorAll(".c-changelog__entry, .c-changelog__error")).forEach((n) => n.remove());
173
253
  if (!this.querySelector(".c-changelog__loading")) this.appendChild(loading);
174
- fetch(src).then((r) => {
254
+ // Abort the in-flight fetch when the host leaves the page, so a slow
255
+ // changelog cannot write into a detached element.
256
+ try { if (this._changelogAbort) this._changelogAbort.abort(); } catch (e) {}
257
+ this._changelogAbort = typeof AbortController !== "undefined" ? new AbortController() : null;
258
+ fetch(src, this._changelogAbort ? { signal: this._changelogAbort.signal } : undefined).then((r) => {
175
259
  if (!r.ok) throw new Error("HTTP " + r.status);
176
260
  return r.text();
177
261
  }).then((text) => {
262
+ if (!this.isConnected) return;
178
263
  const ld = this.querySelector(".c-changelog__loading");
179
264
  if (ld) ld.remove();
180
265
  this.dataset.loaded = src;
@@ -184,7 +269,7 @@ class ContourChangelog extends ContourBase {
184
269
  if (!list.length) {
185
270
  const empty = document.createElement("div");
186
271
  empty.className = "c-changelog__empty";
187
- empty.textContent = "No releases found.";
272
+ empty.textContent = labelText(this, "empty", "No releases found.");
188
273
  this.appendChild(empty);
189
274
  return;
190
275
  }
@@ -206,20 +291,26 @@ class ContourChangelog extends ContourBase {
206
291
  det.appendChild(sum);
207
292
  const body = document.createElement("div");
208
293
  body.className = "c-changelog__body";
209
- body.innerHTML = renderChangelogBody(e.body);
294
+ setHTML(body, renderChangelogBody(e.body));
210
295
  det.appendChild(body);
211
296
  this.appendChild(det);
212
297
  });
213
298
  }).catch((err) => {
299
+ if (!this.isConnected) return;
214
300
  const ld = this.querySelector(".c-changelog__loading");
215
301
  if (ld) ld.remove();
216
302
  const er = document.createElement("div");
217
303
  er.className = "c-changelog__error";
218
- er.textContent = "Failed to load changelog: " + (err && err.message ? err.message : err);
304
+ er.textContent = labelText(this, "load-error", "Failed to load changelog") + ": " + (err && err.message ? err.message : err);
219
305
  this.appendChild(er);
220
306
  });
221
307
  }
222
308
  }
309
+ disconnectedCallback() {
310
+ super.disconnectedCallback();
311
+ try { if (this._changelogAbort) this._changelogAbort.abort(); } catch (e) {}
312
+ this._changelogAbort = null;
313
+ }
223
314
  }
224
315
  define("contour-changelog", ContourChangelog);
225
316
 
@@ -257,10 +348,13 @@ class ContourChangelog extends ContourBase {
257
348
  const line = raw.trimEnd();
258
349
  if (/^###\s+/.test(line)) {
259
350
  if (inList) { out.push("</ul>"); inList = false; }
260
- out.push("<h4>" + escapeHtml(line.replace(/^###\s+/, "")) + "</h4>");
351
+ out.push("<h3>" + escapeHtml(line.replace(/^###\s+/, "")) + "</h3>");
261
352
  } else if (/^##\s+/.test(line)) {
262
353
  if (inList) { out.push("</ul>"); inList = false; }
263
- out.push("<h3>" + escapeHtml(line.replace(/^##\s+/, "")) + "</h3>");
354
+ out.push("<h2>" + escapeHtml(line.replace(/^##\s+/, "")) + "</h2>");
355
+ } else if (/^#\s+/.test(line)) {
356
+ if (inList) { out.push("</ul>"); inList = false; }
357
+ out.push("<h2>" + escapeHtml(line.replace(/^#\s+/, "")) + "</h2>");
264
358
  } else if (/^[-*]\s+/.test(line)) {
265
359
  if (!inList) { out.push("<ul>"); inList = true; }
266
360
  out.push("<li>" + escapeHtml(line.replace(/^[-*]\s+/, "")) + "</li>");