contour-ds 1.7.2 → 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 +181 -104
  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 +6109 -1641
  29. package/dist/contour-wc.esm.min.js +1 -1
  30. package/dist/contour-wc.js +6108 -1641
  31. package/dist/contour-wc.min.js +1 -1
  32. package/dist/contour.code-snippets +4512 -0
  33. package/dist/contour.components.json +2597 -799
  34. package/dist/contour.css +5275 -4050
  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 +23 -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 +263 -63
  88. package/dist/wc/core.mjs +390 -71
  89. package/dist/wc/dashboard.mjs +220 -13
  90. package/dist/wc/data.mjs +1075 -460
  91. package/dist/wc/docs.mjs +105 -12
  92. package/dist/wc/feedback.mjs +63 -14
  93. package/dist/wc/forms.mjs +733 -104
  94. package/dist/wc/index.mjs +9 -2
  95. package/dist/wc/interaction.mjs +182 -28
  96. package/dist/wc/layout.mjs +95 -25
  97. package/dist/wc/map.mjs +185 -118
  98. package/dist/wc/misc.mjs +124 -24
  99. package/dist/wc/navigation.mjs +384 -115
  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 +1988 -476
  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,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).
@@ -87,7 +87,7 @@ class ContourDashToolbar extends ContourBase {
87
87
  btn.textContent = typeof a === "string" ? a : (a.label || a);
88
88
  wrap.appendChild(btn);
89
89
  });
90
- } catch (e) { /* keep existing */ }
90
+ } catch (e) { warnBadJson(this, "attribute", e); }
91
91
  } else {
92
92
  const w = this.querySelector(".c-dash-toolbar__actions");
93
93
  if (w) w.remove();
@@ -118,34 +118,39 @@ class ContourDashToolbar extends ContourBase {
118
118
  }
119
119
  define("contour-dash-toolbar", ContourDashToolbar);
120
120
  class ContourDashKpiRow extends ContourBase {
121
- static get observed() { return ["items"]; }
121
+ static get observed() { return ["items", "title"]; }
122
122
  static get properties() { return { items: { attribute: "items" } }; }
123
123
  render() {
124
124
  this.classList.add("c-dash-kpi-row");
125
- this.setAttribute("role", "group");
125
+ if (!this.hasAttribute("role")) this.setAttribute("role", "group");
126
+ if (!this.hasAttribute("aria-label")) this.setAttribute("aria-label", this.getAttribute("title") || "KPI row");
126
127
  // Drop previously generated kpis so re-render doesn't stack.
127
128
  Array.from(this.querySelectorAll("contour-kpi")).forEach((n) => n.remove());
128
129
  const items = this.getAttribute("items");
129
130
  let parsed = null;
130
131
  if (items) { try { parsed = JSON.parse(items); } catch (e) { parsed = null; } }
131
132
  if (Array.isArray(parsed) && parsed.length) {
132
- parsed.forEach((it) => {
133
+ // The row is a projection of the KPI API, not a two-attribute subset: a
134
+ // dashboard cannot read delta/direction/note/unit through the row if the
135
+ // row drops them here.
136
+ const passthrough = ["value", "label", "delta", "direction", "note", "unit", "format", "variant", "thresholds", "threshold", "sparkline", "polarity", "locale"];
137
+ parsed.forEach((it, i) => {
133
138
  const k = document.createElement("contour-kpi");
134
139
  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));
140
+ for (const key of passthrough) {
141
+ if (it[key] !== undefined && it[key] !== null) k.setAttribute(key, String(it[key]));
142
+ }
137
143
  } else {
138
144
  k.setAttribute("value", String(it));
139
145
  }
146
+ // One tab stop for the row; arrow keys rove. The keydown handler below
147
+ // needs a tabbable item or document.activeElement is never in the list.
148
+ k.setAttribute("tabindex", i === 0 ? "0" : "-1");
140
149
  this.appendChild(k);
141
150
  });
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
151
  }
152
+ // No placeholder: an empty row renders the author's own children or
153
+ // nothing. A generated "KPI 0" is invented data.
149
154
  }
150
155
  enhance() {
151
156
  if (this._wiredDashKpiRow) return;
@@ -158,6 +163,21 @@ class ContourDashKpiRow extends ContourBase {
158
163
  this.dispatchEvent(new CustomEvent("contour:select", { bubbles: true, composed: true, detail: { index: idx } }));
159
164
  }
160
165
  });
166
+ this.addEventListener("keydown", (e) => {
167
+ const kpis = Array.from(this.querySelectorAll("contour-kpi"));
168
+ if (!kpis.length) return;
169
+ navKey(e, kpis, {
170
+ wrap: true,
171
+ homeEnd: true,
172
+ onNavigate: (i) => {
173
+ kpis.forEach((k, j) => k.setAttribute("tabindex", j === i ? "0" : "-1"));
174
+ this.dispatchEvent(new CustomEvent("contour:select", { bubbles: true, composed: true, detail: { index: i } }));
175
+ },
176
+ onKey: (key, i) => {
177
+ if (key === "Enter" || key === " ") this.dispatchEvent(new CustomEvent("contour:select", { bubbles: true, composed: true, detail: { index: i } }));
178
+ },
179
+ });
180
+ });
161
181
  }
162
182
  }
163
183
  define("contour-dash-kpi-row", ContourDashKpiRow);
@@ -185,3 +205,190 @@ class ContourDashFreshness extends ContourBase {
185
205
  }
186
206
  }
187
207
  define("contour-dash-freshness", ContourDashFreshness);
208
+ class ContourSavedView extends ContourBase {
209
+ static get observed() { return ["name", "updated", "source", "active"]; }
210
+ static get properties() { return { name: { attribute: "name" }, updated: { attribute: "updated" }, source: { attribute: "source" }, active: { attribute: "active", type: Boolean } }; }
211
+ render() {
212
+ this.classList.add("c-saved-view");
213
+ this.setAttribute("role", "region");
214
+ if (this.getAttribute("name")) this.setAttribute("aria-label", this.getAttribute("name"));
215
+ if (this.hasAttribute("active")) {
216
+ this.classList.add("c-saved-view--active");
217
+ } else {
218
+ this.classList.remove("c-saved-view--active");
219
+ }
220
+ const thumb = this.ensure(".c-saved-view__thumb", () => { const el = document.createElement("div"); el.className = "c-saved-view__thumb"; el.setAttribute("aria-hidden", "true"); return el; });
221
+ if (thumb.parentNode !== this) this.appendChild(thumb);
222
+ const name = this.ensure(".c-saved-view__name", () => { const el = document.createElement("div"); el.className = "c-saved-view__name"; return el; });
223
+ name.textContent = this.getAttribute("name") || "Saved view";
224
+ let meta = this.querySelector(".c-saved-view__meta");
225
+ if (!meta) { meta = document.createElement("div"); meta.className = "c-saved-view__meta"; this.appendChild(meta); }
226
+ const updated = this.getAttribute("updated");
227
+ const source = this.getAttribute("source");
228
+ meta.replaceChildren();
229
+ if (updated) {
230
+ const wrap = document.createElement("span");
231
+ wrap.textContent = `Updated ${updated}`;
232
+ meta.appendChild(wrap);
233
+ }
234
+ if (source) {
235
+ if (meta.childNodes.length) meta.appendChild(document.createTextNode(" · "));
236
+ const wrap = document.createElement("span");
237
+ wrap.textContent = `${labelText(this, "source", "Source")}: ${source}`;
238
+ meta.appendChild(wrap);
239
+ }
240
+ let actions = this.querySelector(".c-saved-view__actions");
241
+ if (!actions) { actions = document.createElement("div"); actions.className = "c-saved-view__actions"; this.appendChild(actions); }
242
+ // The controls are matched by `data-*` in enhance(), not by their words:
243
+ // a localised `labels` value changes the text, and an equality test on
244
+ // "Apply" then left the button inert (the activity-feed defect, R18-80).
245
+ 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; })();
246
+ applyLabel(apply, this, "apply", "Apply");
247
+ 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; })();
248
+ applyLabel(remove, this, "remove", "Remove");
249
+ }
250
+ enhance() {
251
+ if (this._wiredSavedView) return;
252
+ this._wiredSavedView = true;
253
+ this.addEventListener("click", (e) => {
254
+ const btn = e.target && e.target.closest ? e.target.closest("button") : null;
255
+ if (!btn || !this.contains(btn)) return;
256
+ if (btn.hasAttribute("data-saved-view-apply")) {
257
+ this.dispatchEvent(new CustomEvent("contour:apply", { bubbles: true, composed: true, detail: { name: this.getAttribute("name") } }));
258
+ } else if (btn.hasAttribute("data-saved-view-remove")) {
259
+ this.dispatchEvent(new CustomEvent("contour:remove", { bubbles: true, composed: true, detail: { name: this.getAttribute("name") } }));
260
+ }
261
+ });
262
+ }
263
+ }
264
+ define("contour-saved-view", ContourSavedView);
265
+ class ContourProvenance extends ContourBase {
266
+ static get observed() { return ["source", "confidence", "resolution", "coverage", "warning", "methodology"]; }
267
+ static get properties() { return { source: { attribute: "source" }, confidence: { attribute: "confidence" }, resolution: { attribute: "resolution" }, coverage: { attribute: "coverage" }, warning: { attribute: "warning" }, methodology: { attribute: "methodology" } }; }
268
+ render() {
269
+ this.classList.add("c-provenance");
270
+ this.setAttribute("role", "group");
271
+ this.setAttribute("aria-label", labelText(this, "provenance", "Data provenance"));
272
+ const source = this.getAttribute("source");
273
+ if (source) {
274
+ const s = this.ensure(".c-provenance__source", () => { const el = document.createElement("span"); el.className = "c-provenance__source"; return el; });
275
+ const b = document.createElement("b");
276
+ b.textContent = labelText(this, "source", "Source") + ":";
277
+ s.replaceChildren(b, document.createTextNode(" " + source));
278
+ } else {
279
+ const s = this.querySelector(".c-provenance__source");
280
+ if (s) s.remove();
281
+ }
282
+ const confidence = this.getAttribute("confidence");
283
+ if (confidence) {
284
+ const c = this.ensure(".c-provenance__confidence", () => { const el = document.createElement("span"); el.className = "c-provenance__confidence"; return el; });
285
+ c.className = `c-provenance__confidence c-provenance__confidence--${confidence}`;
286
+ c.textContent = `Confidence: ${confidence}`;
287
+ } else {
288
+ const c = this.querySelector(".c-provenance__confidence");
289
+ if (c) c.remove();
290
+ }
291
+ const resolution = this.getAttribute("resolution");
292
+ if (resolution) {
293
+ const r = this.ensure(".c-provenance__resolution", () => { const el = document.createElement("span"); el.className = "c-provenance__resolution"; return el; });
294
+ r.textContent = `Resolution: ${resolution}`;
295
+ } else {
296
+ const r = this.querySelector(".c-provenance__resolution");
297
+ if (r) r.remove();
298
+ }
299
+ const coverage = this.getAttribute("coverage");
300
+ if (coverage) {
301
+ const c = this.ensure(".c-provenance__coverage", () => { const el = document.createElement("span"); el.className = "c-provenance__coverage"; return el; });
302
+ c.textContent = `Coverage: ${coverage}`;
303
+ } else {
304
+ const c = this.querySelector(".c-provenance__coverage");
305
+ if (c) c.remove();
306
+ }
307
+ const methodology = this.getAttribute("methodology");
308
+ if (methodology) {
309
+ const m = this.ensure(".c-provenance__methodology", () => { const el = document.createElement("span"); el.className = "c-provenance__methodology"; return el; });
310
+ m.textContent = `Methodology: ${methodology}`;
311
+ } else {
312
+ const m = this.querySelector(".c-provenance__methodology");
313
+ if (m) m.remove();
314
+ }
315
+ const warning = this.getAttribute("warning");
316
+ if (warning) {
317
+ const w = this.ensure(".c-provenance__warning", () => { const el = document.createElement("span"); el.className = "c-provenance__warning"; return el; });
318
+ w.textContent = `Warning: ${warning}`;
319
+ } else {
320
+ const w = this.querySelector(".c-provenance__warning");
321
+ if (w) w.remove();
322
+ }
323
+ }
324
+ }
325
+ define("contour-provenance", ContourProvenance);
326
+ class ContourFeatureInspector extends ContourBase {
327
+ static get observed() { return ["title", "open", "data", "actions"]; }
328
+ static get properties() { return { title: { attribute: "title" }, open: { attribute: "open", type: Boolean }, data: { attribute: "data" } }; }
329
+ render() {
330
+ this.classList.add("c-feature-inspector");
331
+ if (!this.hasAttribute("role")) this.setAttribute("role", "region");
332
+ if (this.getAttribute("title")) this.setAttribute("aria-label", this.getAttribute("title"));
333
+ if (this.hasAttribute("open")) this.setAttribute("open", "");
334
+ else this.removeAttribute("open");
335
+ const head = this.ensure(".c-feature-inspector__head", () => { const el = document.createElement("div"); el.className = "c-feature-inspector__head"; return el; });
336
+ const title = this.ensure(".c-feature-inspector__title", () => { const el = document.createElement("span"); el.className = "c-feature-inspector__title"; return el; });
337
+ title.textContent = this.getAttribute("title") || "Feature inspector";
338
+ const body = this.ensure(".c-feature-inspector__body", () => { const el = document.createElement("div"); el.className = "c-feature-inspector__body"; return el; });
339
+ const fields = this.querySelectorAll(".c-feature-inspector__field");
340
+ fields.forEach((f) => f.remove());
341
+ const data = this.getAttribute("data");
342
+ if (data) {
343
+ try {
344
+ const parsed = JSON.parse(data);
345
+ for (const [k, v] of Object.entries(parsed)) {
346
+ const field = document.createElement("div");
347
+ field.className = "c-feature-inspector__field";
348
+ const label = document.createElement("span");
349
+ label.className = "c-feature-inspector__label";
350
+ label.textContent = k;
351
+ const value = document.createElement("span");
352
+ value.className = "c-feature-inspector__value";
353
+ value.textContent = String(v);
354
+ field.appendChild(label);
355
+ field.appendChild(value);
356
+ body.appendChild(field);
357
+ }
358
+ } catch (e) { warnBadJson(this, "attribute", e); }
359
+ }
360
+ const actions = this.ensure(".c-feature-inspector__actions", () => { const el = document.createElement("div"); el.className = "c-feature-inspector__actions"; return el; });
361
+ // The actions container used to be created and left empty, so the
362
+ // `contour:inspect-action` event it forwards could never fire from the
363
+ // component's own UI. `actions` (a JSON array of labels or {label,value})
364
+ // fills it; authored buttons still work.
365
+ Array.from(actions.querySelectorAll("[data-inspect-action]")).forEach((n) => n.remove());
366
+ const actionsAttr = this.getAttribute("actions");
367
+ if (actionsAttr) {
368
+ try {
369
+ const list = JSON.parse(actionsAttr);
370
+ if (Array.isArray(list)) {
371
+ list.forEach((it) => {
372
+ const btn = document.createElement("button");
373
+ btn.type = "button";
374
+ btn.className = "c-btn c-btn--sm c-feature-inspector__action";
375
+ btn.setAttribute("data-inspect-action", "");
376
+ btn.textContent = typeof it === "string" ? it : (it && (it.label || it.action)) || "";
377
+ if (it && typeof it === "object" && it.value !== undefined) btn.setAttribute("data-action", String(it.value));
378
+ actions.appendChild(btn);
379
+ });
380
+ }
381
+ } catch (e) { warnBadJson(this, "attribute", e); }
382
+ }
383
+ }
384
+ enhance() {
385
+ if (this._wiredFeatureInspector) return;
386
+ this._wiredFeatureInspector = true;
387
+ this.addEventListener("click", (e) => {
388
+ const btn = e.target && e.target.closest ? e.target.closest("button") : null;
389
+ if (!btn || !this.contains(btn)) return;
390
+ this.dispatchEvent(new CustomEvent("contour:inspect-action", { bubbles: true, composed: true, detail: { label: btn.textContent } }));
391
+ });
392
+ }
393
+ }
394
+ define("contour-feature-inspector", ContourFeatureInspector);