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
@@ -1,4 +1,4 @@
1
- import { ContourBase, define, formatValue } from './core.mjs';
1
+ import { ContourBase, define, formatValue, navKey , warnBadJson, labelText, applyLabel } from './core.mjs';
2
2
 
3
3
  /**
4
4
  * Dashboard state machine (R13-06).
@@ -13,8 +13,12 @@ import { ContourBase, define, formatValue } from './core.mjs';
13
13
  * Components that participate:
14
14
  * - contour-widget-state : renders the state chrome (loading/empty/error)
15
15
  * via its `state` attribute; emits `contour:retry` on retry click.
16
- * - contour-brownout : sheds non-essential chrome at levels 1-3
17
- * (level 3 drops the dial/ring entirely).
16
+ * - contour-brownout : indicates the power level AND sheds its
17
+ * light-DOM children: a child hides at level >= its `data-shed`
18
+ * threshold (default 2) unless marked `data-essential`. The dial/ring
19
+ * shed at level 3 belongs to contour-gauge / contour-donut themselves;
20
+ * the chart family sheds legend/tooltip/gridlines at >= 2 and goes
21
+ * marks-only at >= 3 (R25-03).
18
22
  * - contour-dash-freshness : live region announcing the last-updated value;
19
23
  * consumers set `value` to an ISO timestamp and `format`/`locale`.
20
24
  * - contour-dash-kpi-row : renders one contour-kpi per item; emits
@@ -37,8 +41,9 @@ import { ContourBase, define, formatValue } from './core.mjs';
37
41
  * - contour-dash-freshness : no slots; renders a `.c-dot` + text node.
38
42
  * - contour-widget-state : light-DOM children are the fallback content
39
43
  * shown in the ready state.
40
- * - contour-brownout : light-DOM children are the content that may be
41
- * shed at higher brownout levels.
44
+ * - contour-brownout : light-DOM children are shed at level >= their
45
+ * `data-shed` threshold (default 2); `data-essential` children survive
46
+ * every level. Shedding is display-only and reversible.
42
47
  */
43
48
  class ContourDashShell extends ContourBase {
44
49
  static get observed() { return ["title"]; }
@@ -48,10 +53,9 @@ class ContourDashShell extends ContourBase {
48
53
  this.setAttribute("role", "region");
49
54
  const title = this.getAttribute("title");
50
55
  if (title) {
51
- // `.c-dash-shell` is the grid and owns no title; the guide's title lives
52
- // on the toolbar as `.c-dash-toolbar__title`, so the shell composes that
53
- // block instead of inventing a part of its own.
56
+ // `.c-dash-shell` owns no title; toolbar carries `.c-dash-toolbar__title`.
54
57
  const bar = this.ensure(".c-dash-toolbar", () => { const el = document.createElement("div"); el.className = "c-dash-toolbar"; return el; });
58
+ if (bar.parentNode === this && this.firstChild !== bar) this.prepend(bar);
55
59
  const h = bar.querySelector(".c-dash-toolbar__title") || (() => { const el = document.createElement("span"); el.className = "c-dash-toolbar__title"; bar.appendChild(el); return el; })();
56
60
  h.textContent = title;
57
61
  this.setAttribute("aria-label", title);
@@ -87,7 +91,7 @@ class ContourDashToolbar extends ContourBase {
87
91
  btn.textContent = typeof a === "string" ? a : (a.label || a);
88
92
  wrap.appendChild(btn);
89
93
  });
90
- } catch (e) { /* keep existing */ }
94
+ } catch (e) { warnBadJson(this, "attribute", e); }
91
95
  } else {
92
96
  const w = this.querySelector(".c-dash-toolbar__actions");
93
97
  if (w) w.remove();
@@ -118,34 +122,40 @@ class ContourDashToolbar extends ContourBase {
118
122
  }
119
123
  define("contour-dash-toolbar", ContourDashToolbar);
120
124
  class ContourDashKpiRow extends ContourBase {
121
- static get observed() { return ["items"]; }
125
+ static get observed() { return ["items", "title"]; }
122
126
  static get properties() { return { items: { attribute: "items" } }; }
123
127
  render() {
124
128
  this.classList.add("c-dash-kpi-row");
125
- this.setAttribute("role", "group");
126
- // Drop previously generated kpis so re-render doesn't stack.
127
- Array.from(this.querySelectorAll("contour-kpi")).forEach((n) => n.remove());
129
+ if (!this.hasAttribute("role")) this.setAttribute("role", "group");
130
+ if (!this.hasAttribute("aria-label")) this.setAttribute("aria-label", this.getAttribute("title") || "KPI row");
131
+ // Remove only generated kpis on re-render; authored ones stay.
132
+ Array.from(this.querySelectorAll("contour-kpi[data-contour-generated]")).forEach((n) => n.remove());
128
133
  const items = this.getAttribute("items");
129
134
  let parsed = null;
130
135
  if (items) { try { parsed = JSON.parse(items); } catch (e) { parsed = null; } }
131
136
  if (Array.isArray(parsed) && parsed.length) {
132
- parsed.forEach((it) => {
137
+ // Row projects the full KPI API (delta, direction, note, unit...).
138
+ const passthrough = ["value", "label", "delta", "direction", "note", "unit", "format", "variant", "thresholds", "threshold", "sparkline", "polarity", "locale"];
139
+ parsed.forEach((it, i) => {
133
140
  const k = document.createElement("contour-kpi");
134
141
  if (typeof it === "object" && it !== null) {
135
- if (it.value !== undefined) k.setAttribute("value", String(it.value));
136
- if (it.label !== undefined) k.setAttribute("label", String(it.label));
142
+ for (const key of passthrough) {
143
+ const val = it[key];
144
+ if (val !== undefined && val !== null) {
145
+ // JSON.stringify non-string values so thresholds survive as attributes.
146
+ k.setAttribute(key, typeof val === "string" ? val : JSON.stringify(val));
147
+ }
148
+ }
137
149
  } else {
138
150
  k.setAttribute("value", String(it));
139
151
  }
152
+ // One tab stop; roving keydown needs a tabbable item.
153
+ k.setAttribute("tabindex", i === 0 ? "0" : "-1");
154
+ k.dataset.contourGenerated = "";
140
155
  this.appendChild(k);
141
156
  });
142
- } else if (!this.querySelector("contour-kpi")) {
143
- // Fallback: keep a single placeholder kpi only when no items provided.
144
- const k = document.createElement("contour-kpi");
145
- k.setAttribute("value", "0");
146
- k.setAttribute("label", "KPI");
147
- this.appendChild(k);
148
157
  }
158
+ // Empty row keeps authored children or nothing; no invented KPI.
149
159
  }
150
160
  enhance() {
151
161
  if (this._wiredDashKpiRow) return;
@@ -158,6 +168,21 @@ class ContourDashKpiRow extends ContourBase {
158
168
  this.dispatchEvent(new CustomEvent("contour:select", { bubbles: true, composed: true, detail: { index: idx } }));
159
169
  }
160
170
  });
171
+ this.addEventListener("keydown", (e) => {
172
+ const kpis = Array.from(this.querySelectorAll("contour-kpi"));
173
+ if (!kpis.length) return;
174
+ navKey(e, kpis, {
175
+ wrap: true,
176
+ homeEnd: true,
177
+ onNavigate: (i) => {
178
+ kpis.forEach((k, j) => k.setAttribute("tabindex", j === i ? "0" : "-1"));
179
+ this.dispatchEvent(new CustomEvent("contour:select", { bubbles: true, composed: true, detail: { index: i } }));
180
+ },
181
+ onKey: (key, i) => {
182
+ if (key === "Enter" || key === " ") this.dispatchEvent(new CustomEvent("contour:select", { bubbles: true, composed: true, detail: { index: i } }));
183
+ },
184
+ });
185
+ });
161
186
  }
162
187
  }
163
188
  define("contour-dash-kpi-row", ContourDashKpiRow);
@@ -170,9 +195,7 @@ class ContourDashFreshness extends ContourBase {
170
195
  this.setAttribute("aria-live", "polite");
171
196
  const label = this.getAttribute("label");
172
197
  const value = this.getAttribute("value");
173
- // The block defines no elements of its own: the guide's chip is a live dot
174
- // followed by its text, so the dot is the real `.c-dot` and the words are a
175
- // text node rather than two invented parts.
198
+ // `.c-dot` is the live dot; words are a text node.
176
199
  const dot = this.ensure(".c-dot", () => { const el = document.createElement("span"); el.className = "c-dot c-dot--live c-dot--accent"; el.setAttribute("aria-hidden", "true"); return el; });
177
200
  if (dot.parentNode !== this) this.appendChild(dot);
178
201
  // Reset stale text node reference after base-class cleanup.
@@ -185,3 +208,207 @@ class ContourDashFreshness extends ContourBase {
185
208
  }
186
209
  }
187
210
  define("contour-dash-freshness", ContourDashFreshness);
211
+ class ContourSavedView extends ContourBase {
212
+ static get observed() { return ["name", "updated", "source", "active"]; }
213
+ static get properties() { return { name: { attribute: "name" }, updated: { attribute: "updated" }, source: { attribute: "source" }, active: { attribute: "active", type: Boolean } }; }
214
+ render() {
215
+ this.classList.add("c-saved-view");
216
+ this.setAttribute("role", "region");
217
+ if (this.getAttribute("name")) this.setAttribute("aria-label", this.getAttribute("name"));
218
+ if (this.hasAttribute("active")) {
219
+ this.classList.add("c-saved-view--active");
220
+ } else {
221
+ this.classList.remove("c-saved-view--active");
222
+ }
223
+ // Thumb named, not aria-hidden: name already covers it.
224
+ const thumb = this.ensure(".c-saved-view__thumb", () => {
225
+ const el = document.createElement("div");
226
+ el.className = "c-saved-view__thumb";
227
+ return el;
228
+ });
229
+ // role + aria-label on thumb every render; factory covers generated only.
230
+ thumb.setAttribute("role", "img");
231
+ thumb.setAttribute("aria-label", `${labelText(this, "preview", "Preview")} — ${this.getAttribute("name") || labelText(this, "unnamed", "Saved view")}`);
232
+ if (thumb.parentNode !== this) this.appendChild(thumb);
233
+ const name = this.ensure(".c-saved-view__name", () => { const el = document.createElement("div"); el.className = "c-saved-view__name"; return el; });
234
+ name.textContent = this.getAttribute("name") || "Saved view";
235
+ let meta = this.querySelector(".c-saved-view__meta");
236
+ if (!meta) { meta = document.createElement("div"); meta.className = "c-saved-view__meta"; this.appendChild(meta); }
237
+ const updated = this.getAttribute("updated");
238
+ const source = this.getAttribute("source");
239
+ meta.replaceChildren();
240
+ if (updated) {
241
+ const wrap = document.createElement("span");
242
+ wrap.textContent = `Updated ${updated}`;
243
+ meta.appendChild(wrap);
244
+ }
245
+ if (source) {
246
+ if (meta.childNodes.length) meta.appendChild(document.createTextNode(" · "));
247
+ const wrap = document.createElement("span");
248
+ wrap.textContent = `${labelText(this, "source", "Source")}: ${source}`;
249
+ meta.appendChild(wrap);
250
+ }
251
+ let actions = this.querySelector(".c-saved-view__actions");
252
+ if (!actions) { actions = document.createElement("div"); actions.className = "c-saved-view__actions"; this.appendChild(actions); }
253
+ // Controls matched by data-*, not text (localisation + R18-80 defect).
254
+ const apply = actions.querySelector(".c-saved-view__apply") || (() => { const b = document.createElement("button"); b.type = "button"; b.className = "c-btn c-btn--ghost c-btn--sm"; b.setAttribute("data-saved-view-apply", ""); actions.appendChild(b); return b; })();
255
+ applyLabel(apply, this, "apply", "Apply");
256
+ const remove = actions.querySelector(".c-saved-view__remove") || (() => { const b = document.createElement("button"); b.type = "button"; b.className = "c-btn c-btn--ghost c-btn--sm"; b.setAttribute("data-saved-view-remove", ""); actions.appendChild(b); return b; })();
257
+ applyLabel(remove, this, "remove", "Remove");
258
+ }
259
+ enhance() {
260
+ if (this._wiredSavedView) return;
261
+ this._wiredSavedView = true;
262
+ this.addEventListener("click", (e) => {
263
+ const btn = e.target && e.target.closest ? e.target.closest("button") : null;
264
+ if (!btn || !this.contains(btn)) return;
265
+ if (btn.hasAttribute("data-saved-view-apply")) {
266
+ this.dispatchEvent(new CustomEvent("contour:apply", { bubbles: true, composed: true, detail: { name: this.getAttribute("name") } }));
267
+ } else if (btn.hasAttribute("data-saved-view-remove")) {
268
+ this.dispatchEvent(new CustomEvent("contour:remove", { bubbles: true, composed: true, detail: { name: this.getAttribute("name") } }));
269
+ }
270
+ });
271
+ }
272
+ }
273
+ define("contour-saved-view", ContourSavedView);
274
+ class ContourProvenance extends ContourBase {
275
+ static get observed() { return ["source", "confidence", "resolution", "coverage", "warning", "methodology"]; }
276
+ static get properties() { return { source: { attribute: "source" }, confidence: { attribute: "confidence" }, resolution: { attribute: "resolution" }, coverage: { attribute: "coverage" }, warning: { attribute: "warning" }, methodology: { attribute: "methodology" } }; }
277
+ render() {
278
+ this.classList.add("c-provenance");
279
+ this.setAttribute("role", "group");
280
+ this.setAttribute("aria-label", labelText(this, "provenance", "Data provenance"));
281
+ // Provenance updates silently without a live region; polite one set unless authored.
282
+ if (!this.hasAttribute("aria-live")) this.setAttribute("aria-live", "polite");
283
+ const source = this.getAttribute("source");
284
+ if (source) {
285
+ const s = this.ensure(".c-provenance__source", () => { const el = document.createElement("span"); el.className = "c-provenance__source"; return el; });
286
+ const b = document.createElement("b");
287
+ b.textContent = labelText(this, "source", "Source") + ":";
288
+ s.replaceChildren(b, document.createTextNode(" " + source));
289
+ } else {
290
+ const s = this.querySelector(".c-provenance__source");
291
+ if (s) s.remove();
292
+ }
293
+ const confidence = this.getAttribute("confidence");
294
+ if (confidence) {
295
+ const c = this.ensure(".c-provenance__confidence", () => { const el = document.createElement("span"); el.className = "c-provenance__confidence"; return el; });
296
+ // Only high/medium/low get a modifier; unknown → --unknown (no-rule class dropped, F-CSS23).
297
+ const level = String(confidence).toLowerCase();
298
+ const known = level === "high" || level === "medium" || level === "low";
299
+ c.className = "c-provenance__confidence" + (known ? " c-provenance__confidence--" + level : " c-provenance__confidence--unknown");
300
+ c.textContent = `Confidence: ${confidence}`;
301
+ } else {
302
+ const c = this.querySelector(".c-provenance__confidence");
303
+ if (c) c.remove();
304
+ }
305
+ const resolution = this.getAttribute("resolution");
306
+ if (resolution) {
307
+ const r = this.ensure(".c-provenance__resolution", () => { const el = document.createElement("span"); el.className = "c-provenance__resolution"; return el; });
308
+ r.textContent = `Resolution: ${resolution}`;
309
+ } else {
310
+ const r = this.querySelector(".c-provenance__resolution");
311
+ if (r) r.remove();
312
+ }
313
+ const coverage = this.getAttribute("coverage");
314
+ if (coverage) {
315
+ const c = this.ensure(".c-provenance__coverage", () => { const el = document.createElement("span"); el.className = "c-provenance__coverage"; return el; });
316
+ c.textContent = `Coverage: ${coverage}`;
317
+ } else {
318
+ const c = this.querySelector(".c-provenance__coverage");
319
+ if (c) c.remove();
320
+ }
321
+ const methodology = this.getAttribute("methodology");
322
+ if (methodology) {
323
+ const m = this.ensure(".c-provenance__methodology", () => { const el = document.createElement("span"); el.className = "c-provenance__methodology"; return el; });
324
+ m.textContent = `Methodology: ${methodology}`;
325
+ } else {
326
+ const m = this.querySelector(".c-provenance__methodology");
327
+ if (m) m.remove();
328
+ }
329
+ const warning = this.getAttribute("warning");
330
+ if (warning) {
331
+ const w = this.ensure(".c-provenance__warning", () => { const el = document.createElement("span"); el.className = "c-provenance__warning"; return el; });
332
+ w.textContent = `Warning: ${warning}`;
333
+ } else {
334
+ const w = this.querySelector(".c-provenance__warning");
335
+ if (w) w.remove();
336
+ }
337
+ }
338
+ }
339
+ define("contour-provenance", ContourProvenance);
340
+ class ContourFeatureInspector extends ContourBase {
341
+ static get observed() { return ["title", "open", "data", "actions"]; }
342
+ static get properties() { return { title: { attribute: "title" }, open: { attribute: "open", type: Boolean }, data: { attribute: "data" } }; }
343
+ render() {
344
+ this.classList.add("c-feature-inspector");
345
+ if (!this.hasAttribute("role")) this.setAttribute("role", "region");
346
+ if (this.getAttribute("title")) this.setAttribute("aria-label", this.getAttribute("title"));
347
+ // open="false" closes; presence alone is not open.
348
+ const openAttr = this.getAttribute("open");
349
+ const open = openAttr !== null && openAttr !== "false";
350
+ if (open) this.setAttribute("open", "");
351
+ else this.removeAttribute("open");
352
+ const head = this.ensure(".c-feature-inspector__head", () => { const el = document.createElement("div"); el.className = "c-feature-inspector__head"; return el; });
353
+ const title = this.ensure(".c-feature-inspector__title", () => { const el = document.createElement("span"); el.className = "c-feature-inspector__title"; return el; });
354
+ // resolve the title through labels i18n like other chrome text.
355
+ title.textContent = labelText(this, "title", this.getAttribute("title") || "Feature inspector");
356
+ const body = this.ensure(".c-feature-inspector__body", () => { const el = document.createElement("div"); el.className = "c-feature-inspector__body"; return el; });
357
+ const fields = this.querySelectorAll(".c-feature-inspector__field");
358
+ fields.forEach((f) => f.remove());
359
+ const data = this.getAttribute("data");
360
+ if (data) {
361
+ try {
362
+ const parsed = JSON.parse(data);
363
+ // only plain objects become fields; arrays stay out.
364
+ if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
365
+ for (const [k, v] of Object.entries(parsed)) {
366
+ const field = document.createElement("div");
367
+ field.className = "c-feature-inspector__field";
368
+ const label = document.createElement("span");
369
+ label.className = "c-feature-inspector__label";
370
+ label.textContent = k;
371
+ const value = document.createElement("span");
372
+ value.className = "c-feature-inspector__value";
373
+ value.textContent = String(v);
374
+ field.appendChild(label);
375
+ field.appendChild(value);
376
+ body.appendChild(field);
377
+ }
378
+ }
379
+ } catch (e) { warnBadJson(this, "attribute", e); }
380
+ }
381
+ const actions = this.ensure(".c-feature-inspector__actions", () => { const el = document.createElement("div"); el.className = "c-feature-inspector__actions"; return el; });
382
+ // Empty actions strip could never fire contour:inspect-action; `actions` fills it.
383
+ Array.from(actions.querySelectorAll("[data-inspect-action]")).forEach((n) => n.remove());
384
+ const actionsAttr = this.getAttribute("actions");
385
+ if (actionsAttr) {
386
+ try {
387
+ const list = JSON.parse(actionsAttr);
388
+ if (Array.isArray(list)) {
389
+ list.forEach((it) => {
390
+ const btn = document.createElement("button");
391
+ btn.type = "button";
392
+ btn.className = "c-btn c-btn--sm c-feature-inspector__action";
393
+ btn.setAttribute("data-inspect-action", "");
394
+ btn.textContent = typeof it === "string" ? it : (it && (it.label || it.action)) || "";
395
+ if (it && typeof it === "object" && it.value !== undefined) btn.setAttribute("data-action", String(it.value));
396
+ actions.appendChild(btn);
397
+ });
398
+ }
399
+ } catch (e) { warnBadJson(this, "attribute", e); }
400
+ }
401
+ // hide strip when empty; authored buttons stay (generated nodes only).
402
+ actions.style.display = actions.hasChildNodes() ? "" : "none";
403
+ }
404
+ enhance() {
405
+ if (this._wiredFeatureInspector) return;
406
+ this._wiredFeatureInspector = true;
407
+ this.addEventListener("click", (e) => {
408
+ const btn = e.target && e.target.closest ? e.target.closest("button") : null;
409
+ if (!btn || !this.contains(btn)) return;
410
+ this.dispatchEvent(new CustomEvent("contour:inspect-action", { bubbles: true, composed: true, detail: { label: btn.textContent || "", value: btn.getAttribute("data-action") || "" } }));
411
+ });
412
+ }
413
+ }
414
+ define("contour-feature-inspector", ContourFeatureInspector);