contour-ds 1.5.0 → 1.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (64) hide show
  1. package/README.md +25 -3
  2. package/dist/build-manifest.json +79 -79
  3. package/dist/contour-wc.esm.js +348 -38
  4. package/dist/contour-wc.esm.min.js +1 -1
  5. package/dist/contour-wc.js +348 -38
  6. package/dist/contour-wc.min.js +1 -1
  7. package/dist/contour.components.json +2280 -204
  8. package/dist/contour.css +1658 -857
  9. package/dist/contour.d.ts +10 -1
  10. package/dist/contour.esm.js +7 -0
  11. package/dist/contour.esm.min.js +1 -1
  12. package/dist/contour.js +7 -0
  13. package/dist/contour.min.css +1 -1
  14. package/dist/contour.min.js +1 -1
  15. package/dist/contour.tokens.json +10 -2
  16. package/dist/docs/actions.md +2 -2
  17. package/dist/docs/affordances.md +4 -2
  18. package/dist/docs/apireference.md +30 -0
  19. package/dist/docs/colour.md +2 -2
  20. package/dist/docs/componentindex.md +2 -2
  21. package/dist/docs/data.md +2 -2
  22. package/dist/docs/docs.md +2 -2
  23. package/dist/docs/feedback.md +2 -2
  24. package/dist/docs/field.md +2 -2
  25. package/dist/docs/forms.md +2 -2
  26. package/dist/docs/index.json +24 -11
  27. package/dist/docs/install.md +2 -2
  28. package/dist/docs/landing.md +2 -2
  29. package/dist/docs/mapengine.md +2 -2
  30. package/dist/docs/motion.md +2 -2
  31. package/dist/docs/navigation.md +2 -2
  32. package/dist/docs/overlays.md +2 -2
  33. package/dist/docs/overview.md +2 -2
  34. package/dist/docs/patterns.md +2 -2
  35. package/dist/docs/playground.md +2 -2
  36. package/dist/docs/principles.md +2 -2
  37. package/dist/docs/recipes.md +2 -2
  38. package/dist/docs/space.md +2 -2
  39. package/dist/docs/status.md +2 -2
  40. package/dist/docs/surfaces.md +2 -2
  41. package/dist/docs/theming.md +2 -2
  42. package/dist/docs/type.md +2 -2
  43. package/dist/docs/webcomponents.md +3 -7
  44. package/dist/registry/items/contour-core.json +2 -2
  45. package/dist/registry/items/contour-data.json +2 -2
  46. package/dist/registry/items/contour-docs.json +2 -2
  47. package/dist/registry/items/contour-landing.json +2 -2
  48. package/dist/registry/registry.json +8 -8
  49. package/dist/surfaces/contour-core.min.css +1 -1
  50. package/dist/surfaces/contour-data.min.css +1 -1
  51. package/dist/surfaces/contour-docs.min.css +1 -1
  52. package/dist/surfaces/contour-landing.min.css +1 -1
  53. package/dist/wc/content.mjs +1 -0
  54. package/dist/wc/core.mjs +33 -3
  55. package/dist/wc/data.mjs +96 -21
  56. package/dist/wc/docs.mjs +117 -0
  57. package/dist/wc/forms.mjs +6 -2
  58. package/dist/wc/index.mjs +25 -1
  59. package/dist/wc/interaction.mjs +3 -1
  60. package/dist/wc/layout.mjs +2 -2
  61. package/dist/wc/map.mjs +21 -0
  62. package/dist/wc/navigation.mjs +2 -1
  63. package/dist/wc/ui.mjs +67 -8
  64. package/package.json +1 -1
@@ -446,6 +446,7 @@ class ContourShowcaseFull extends ContourBase {
446
446
  static get properties() { return { title: { attribute: "title" }, text: { attribute: "text" }, media: { attribute: "media" }, reverse: { attribute: "reverse" }, items: { attribute: "items" }, src: { attribute: "src" } }; }
447
447
  render() {
448
448
  this.classList.add("c-showcase");
449
+ this.setAttribute("role", "list");
449
450
  if (this.hasAttribute("reverse")) this.classList.add("c-showcase--reverse"); else this.classList.remove("c-showcase--reverse");
450
451
  const title = this.getAttribute("title");
451
452
  if (title) this.setAttribute("aria-label", title);
package/dist/wc/core.mjs CHANGED
@@ -114,6 +114,7 @@
114
114
  "contour:btn-group-change": { payload: ["index", "label"], composed: true },
115
115
  "contour:brush-start": { payload: ["end", "start", "value"], composed: true },
116
116
  "contour:brush-end": { payload: ["end", "start", "value"], composed: true },
117
+ "contour:brush": { payload: ["end", "start", "value"], composed: true },
117
118
  "contour:change": { payload: ["checked", "color", "direction", "end", "files", "high", "index", "low", "month", "name", "speed", "start", "unit", "value", "year"], composed: true },
118
119
  "contour:collapse": { payload: ["collapsed"], composed: true },
119
120
  "contour:cluster-toggle": { payload: ["count", "expanded"], composed: true },
@@ -132,7 +133,9 @@
132
133
  "contour:drop": { payload: ["value", "label"], composed: true },
133
134
  "contour:empty-action": { payload: ["state"], composed: true },
134
135
  "contour:filter": { payload: ["query"], composed: true },
135
- "contour:error": { payload: ["src", "message", "name", "status"], composed: true },
136
+ "contour:error": { payload: ["src", "message", "name", "status"], composed: true },
137
+ "contour:export": { payload: ["format"], composed: true },
138
+ "contour:refresh": { payload: [], composed: true },
136
139
  "contour:hide": { payload: [], composed: true },
137
140
  "contour:hover": { payload: ["row"], composed: true },
138
141
  "contour:input": { payload: ["name", "value", "checked"], composed: true },
@@ -232,7 +235,7 @@
232
235
  export const OBSERVED = [
233
236
  "accept", "action", "actions", "active", "after", "allow-duplicate", "allow-remove", "allow-rename", "allow-zoom", "alpha", "anchor", "answer", "area", "article", "attribution", "attribution-mark", "audit", "autoplay", "axis", "axis-x", "axis-y", "brownout", "brownout-level", "before", "body", "brand", "breakpoint", "breaks", "brush", "brush-end", "brush-max", "brush-min", "brush-start", "cache-key", "canvas", "center", "clearable", "cols", "columns", "color", "command",
234
237
  "cells", "checked", "chrome", "debounce", "closable", "collapsed", "collapsible", "classification", "colors", "continuous", "content", "controls", "copyable", "count", "data", "data-table", "date", "delta", "description", "glyphs", "demo", "density", "desc", "dir", "direction", "disabled", "distance", "dismissible", "divider", "do", "dont", "dot", "ends", "high", "input", "layer", "low", "mode", "modes", "n", "opacity", "palette", "polarity", "precision", "range", "single",
235
- "empty", "exclusive", "fallback", "format", "heading", "help", "hint", "href", "icon", "illustration", "instrument", "interval", "items", "key", "layers", "level", "range-end", "range-start",
238
+ "empty", "exclusive", "fallback", "filename", "format", "heading", "help", "hint", "href", "icon", "illustration", "instrument", "interval", "items", "key", "layers", "level", "range-end", "range-start",
236
239
  "label", "lazy", "lede", "legend", "line", "limit", "link", "links", "live", "loading", "locale", "loop", "max", "media", "message", "method", "menu", "min", "multiple", "name", "needle", "next", "no", "no-cache", "no-data-message", "nodes", "note", "norm", "normalize",
237
240
  "options", "orientation", "page-size", "pages", "pause", "paused", "pausable", "persist", "placeholder", "playing", "point", "points", "prev", "presets", "progress", "prompt", "question", "recent", "required",
238
241
  "quote", "ramp", "refresh", "removable", "resolution", "reverse", "rings", "retry", "results", "rows", "scale", "selectable", "segments", "show-header", "sparkline", "threshold", "thresholds", "selected", "separator", "series", "shortcut", "side", "size", "skeleton", "sort", "sort-dir", "speed", "status", "step", "submit", "submitting", "timeout", "trigger", "virtual", "sticky", "cluster-count", "cluster-expanded", "time", "resizable",
@@ -311,7 +314,18 @@
311
314
  return "scaffold";
312
315
  }
313
316
 
314
- // How many times this host has run `render()`, counting the first connect.
317
+ // Brownout helpers (G-16): components read their degraded level from the
318
+ // `brownout` / `brownout-level` attribute and shed non-essential chrome
319
+ // above a threshold. Centralised here so a new component does not
320
+ // re-implement the attribute lookup.
321
+ brownoutLevel() {
322
+ const raw = this.getAttribute("brownout-level") || this.getAttribute("brownout") || "0";
323
+ const n = parseInt(raw, 10);
324
+ return Number.isFinite(n) ? n : 0;
325
+ }
326
+ shed(kind, threshold) {
327
+ return this.brownoutLevel() >= (threshold || 1);
328
+ }
315
329
  // Read-only and diagnostic: it exists so a page can show that `batch()` did
316
330
  // what it claims instead of asking the reader to believe it, and so a test can
317
331
  // assert a re-render happened without watching for a specific node. A consumer
@@ -905,6 +919,22 @@
905
919
  }
906
920
  }
907
921
 
922
+ // Brownout mixin (G-16): opt-in base for components that shed non-essential
923
+ // chrome under degraded conditions. Merges `brownout` / `brownout-level`
924
+ // into the subclass observed list and exposes the helpers already on
925
+ // ContourBase. Usage: `class Foo extends withBrownout(ContourBase) { ... }`.
926
+ export function withBrownout(Base) {
927
+ return class extends Base {
928
+ static get observed() {
929
+ const base = (super.observed && Array.isArray(super.observed)) ? super.observed : [];
930
+ const extra = ["brownout", "brownout-level"];
931
+ return Array.from(new Set(base.concat(extra)));
932
+ }
933
+ brownoutLevel() { return super.brownoutLevel ? super.brownoutLevel() : (parseInt(this.getAttribute("brownout-level") || this.getAttribute("brownout") || "0", 10) || 0); }
934
+ shed(kind, threshold) { return this.brownoutLevel() >= (threshold || 1); }
935
+ };
936
+ }
937
+
908
938
  // Simple component: just adds CSS classes.
909
939
  /** Create a light-DOM component that only applies block and modifier classes. */
910
940
  export const simple = (classes) => class extends ContourBase {
package/dist/wc/data.mjs CHANGED
@@ -258,7 +258,7 @@ class ContourTable extends ContourBase {
258
258
  btn.className = "c-btn c-btn--ghost c-btn--sm";
259
259
  btn.type = "button";
260
260
  btn.textContent = this.getAttribute("retry") || "Retry";
261
- btn.style.marginInlineStart = "var(--space-sm)";
261
+ btn.classList.add("u-ms-sm");
262
262
  btn.dataset.action = "retry";
263
263
  td.appendChild(btn);
264
264
  }
@@ -734,7 +734,7 @@ class ContourChart extends ContourBase {
734
734
  btn.type = "button";
735
735
  btn.textContent = this.getAttribute("retry") || "Retry";
736
736
  btn.dataset.action = "retry";
737
- btn.style.marginBlockStart = "var(--space-sm)";
737
+ btn.classList.add("u-mbs-sm");
738
738
  err.appendChild(btn);
739
739
  }
740
740
  plot.appendChild(err);
@@ -755,7 +755,7 @@ class ContourChart extends ContourBase {
755
755
  sk.style.display = "block";
756
756
  sk.style.inlineSize = "100%";
757
757
  sk.style.blockSize = "0.6rem";
758
- sk.style.marginBlockEnd = "var(--space-2xs)";
758
+ sk.classList.add("u-mbe-2xs");
759
759
  plot.appendChild(sk);
760
760
  }
761
761
  const axis = this.getAttribute("axis");
@@ -1546,7 +1546,7 @@ class ContourGauge extends ContourBase {
1546
1546
  const showHeader = this.getAttribute("show-header") !== "false";
1547
1547
  const description = this.getAttribute("description");
1548
1548
  const noDataMessage = this.getAttribute("no-data-message") || "No readings in view";
1549
- const brownoutLevel = parseInt(this.getAttribute("brownout-level") || this.getAttribute("brownout") || "0", 10) || 0;
1549
+ const brownoutLevel = this.brownoutLevel();
1550
1550
  // empty state
1551
1551
  if (!hasValue) {
1552
1552
  if (heading && showHeader) {
@@ -1580,7 +1580,7 @@ class ContourGauge extends ContourBase {
1580
1580
  }
1581
1581
  }
1582
1582
  // dial (unless brownout >= 3)
1583
- const shedDial = brownoutLevel >= 3;
1583
+ const shedDial = this.shed("dial", 3);
1584
1584
  let dial = this.querySelector(".c-gauge__dial");
1585
1585
  if (shedDial) {
1586
1586
  if (dial) dial.remove();
@@ -1811,6 +1811,7 @@ class ContourBrush extends ContourBase {
1811
1811
  if (eh) eh.style.insetInlineStart = (((ne - mn) / range) * 100) + "%";
1812
1812
  // stash pending values
1813
1813
  this._brushPending = { start: ns, end: ne };
1814
+ this.dispatchEvent(new CustomEvent("contour:brush", { bubbles: true, composed: true, detail: { start: ns, end: ne, value: ns } }));
1814
1815
  });
1815
1816
  this.addEventListener("pointerup", (e) => {
1816
1817
  if (!dragging) return;
@@ -1822,6 +1823,7 @@ class ContourBrush extends ContourBase {
1822
1823
  this._brushPending = null;
1823
1824
  }
1824
1825
  this.dispatchEvent(new CustomEvent("contour:brush-end", { bubbles: true, composed: true, detail: { value: this.getAttribute("end"), start: this.getAttribute("start"), end: this.getAttribute("end") } }));
1826
+ this.dispatchEvent(new CustomEvent("contour:brush", { bubbles: true, composed: true, detail: { start: this.getAttribute("start"), end: this.getAttribute("end"), value: this.getAttribute("end") } }));
1825
1827
  });
1826
1828
  // Keyboard: Enter/Space emits brush-start/brush-end (WC-P1-08).
1827
1829
  if (!this.hasAttribute("tabindex")) this.setAttribute("tabindex", "0");
@@ -1857,7 +1859,7 @@ class ContourStackedBar extends ContourBase {
1857
1859
  segments = authoredSegments.map((el) => ({
1858
1860
  label: el.getAttribute("title") || el.textContent || "",
1859
1861
  value: parseFloat(el.style.inlineSize) || 0,
1860
- color: el.style.background || undefined,
1862
+ color: (el.dataset && el.dataset.color) || el.style.background || undefined,
1861
1863
  }));
1862
1864
  authoredSegments.forEach((el) => el.remove());
1863
1865
  } else {
@@ -1874,6 +1876,7 @@ class ContourStackedBar extends ContourBase {
1874
1876
  el.className = "c-stacked-bar__segment";
1875
1877
  el.style.inlineSize = ((v / denom) * 100) + "%";
1876
1878
  el.style.background = (typeof seg === "object" && seg.color) ? seg.color : "var(--chart-" + ((i % 8) + 1) + ")";
1879
+ el.dataset.color = (typeof seg === "object" && seg.color) ? seg.color : el.style.background;
1877
1880
  el.setAttribute("title", (typeof seg === "object" ? (seg.label || "") : "") + " " + v);
1878
1881
  this.appendChild(el);
1879
1882
  });
@@ -2027,7 +2030,7 @@ class ContourDonut extends ContourBase {
2027
2030
  const lbl = el.querySelector("span:last-child");
2028
2031
  const text = lbl ? lbl.textContent : el.textContent;
2029
2032
  const match = text.match(/—\s*(\d+(?:\.\d+)?)$/);
2030
- items.push({ label: text.replace(/—\s*\d+(?:\.\d+)?$/, "").trim(), value: match ? Number(match[1]) : 0, color: sw ? sw.style.background : undefined });
2033
+ items.push({ label: text.replace(/—\s*\d+(?:\.\d+)?$/, "").trim(), value: match ? Number(match[1]) : 0, color: sw ? (sw.dataset && sw.dataset.color) || sw.style.background : undefined });
2031
2034
  });
2032
2035
  // remove authored items from DOM (they will be regenerated below)
2033
2036
  authoredItems.forEach((el) => el.remove());
@@ -2037,8 +2040,8 @@ class ContourDonut extends ContourBase {
2037
2040
  }
2038
2041
  const values = items.map((it) => (typeof it === "object" ? (it.value || 0) : Number(it) || 0));
2039
2042
  const total = values.reduce((a, b) => a + b, 0) || 1;
2040
- const brownoutLevel = parseInt(this.getAttribute("brownout-level") || this.getAttribute("brownout") || "0", 10) || 0;
2041
- const shedRing = brownoutLevel >= 3;
2043
+ const brownoutLevel = this.brownoutLevel();
2044
+ const shedRing = this.shed("ring", 3);
2042
2045
  if (!shedRing) {
2043
2046
  const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
2044
2047
  svg.setAttribute("class", "c-donut__ring");
@@ -2073,12 +2076,15 @@ class ContourDonut extends ContourBase {
2073
2076
  // text list
2074
2077
  const list = document.createElement("div");
2075
2078
  list.className = "c-donut__list";
2079
+ list.setAttribute("role", "list");
2076
2080
  items.forEach((it, i) => {
2077
2081
  const row = document.createElement("div");
2078
2082
  row.className = "c-donut__item";
2083
+ row.setAttribute("role", "listitem");
2079
2084
  const sw = document.createElement("span");
2080
2085
  sw.className = "c-donut__swatch";
2081
2086
  sw.style.background = (typeof it === "object" && it.color) ? it.color : "var(--chart-" + ((i % 8) + 1) + ")";
2087
+ if (sw.style.background) sw.dataset.color = (typeof it === "object" && it.color) ? it.color : sw.style.background;
2082
2088
  row.appendChild(sw);
2083
2089
  const lbl = document.createElement("span");
2084
2090
  lbl.textContent = (typeof it === "object" ? (it.label || "") : String(it)) + " — " + values[i];
@@ -2259,8 +2265,6 @@ class ContourPivot extends ContourBase {
2259
2265
  const toolbar = document.createElement("div");
2260
2266
  toolbar.className = "c-pivot__toolbar";
2261
2267
  toolbar.style.display = "flex";
2262
- toolbar.style.gap = "0.5rem";
2263
- toolbar.style.marginBlockEnd = "0.5rem";
2264
2268
  const filterInput = document.createElement("input");
2265
2269
  filterInput.type = "search";
2266
2270
  filterInput.className = "c-input c-pivot__filter";
@@ -2297,6 +2301,7 @@ class ContourPivot extends ContourBase {
2297
2301
  const corner = document.createElement("th");
2298
2302
  corner.textContent = "";
2299
2303
  corner.setAttribute("role", "columnheader");
2304
+ corner.setAttribute("aria-label", "Row");
2300
2305
  hr.appendChild(corner);
2301
2306
  visibleCols.forEach((c) => { const th = document.createElement("th"); th.textContent = c; th.setAttribute("role", "columnheader"); th.setAttribute("tabindex", "0"); hr.appendChild(th); });
2302
2307
  thead.appendChild(hr);
@@ -2324,6 +2329,7 @@ class ContourPivot extends ContourBase {
2324
2329
  } else {
2325
2330
  td.textContent = "";
2326
2331
  }
2332
+ if (!td.textContent.trim()) td.setAttribute("aria-label", "Empty");
2327
2333
  tr.appendChild(td);
2328
2334
  });
2329
2335
  tbody.appendChild(tr);
@@ -2488,7 +2494,7 @@ class ContourBivariate extends ContourBase {
2488
2494
  // Palette runs from bottom-left (low/low) to top-right (high/high):
2489
2495
  // reverse the row order so the first palette row sits at the bottom.
2490
2496
  const srcIndex = (size - 1 - r) * size + c;
2491
- if (colors[srcIndex]) cell.style.background = colors[srcIndex];
2497
+ if (colors[srcIndex]) { cell.style.background = colors[srcIndex]; cell.dataset.color = colors[srcIndex]; }
2492
2498
  matrix.appendChild(cell);
2493
2499
  }
2494
2500
  }
@@ -2696,6 +2702,7 @@ class ContourMetricsFull extends ContourBase {
2696
2702
  static get properties() { return { items: { attribute: "items" }, src: { attribute: "src" } }; }
2697
2703
  render() {
2698
2704
  this.classList.add("c-metrics");
2705
+ this.setAttribute("role", "list");
2699
2706
  wireStates(this);
2700
2707
  loadRemote(this, "items");
2701
2708
  if (renderStates(this, "metrics")) return;
@@ -2708,6 +2715,7 @@ class ContourMetricsFull extends ContourBase {
2708
2715
  parsed.forEach((it) => {
2709
2716
  const item = document.createElement("div");
2710
2717
  item.className = "c-metrics__item";
2718
+ item.setAttribute("role", "listitem");
2711
2719
  const v = document.createElement("div");
2712
2720
  v.className = "c-metrics__value";
2713
2721
  v.textContent = (typeof it === "object" && it !== null) ? (it.value ?? it.v ?? "") : String(it);
@@ -2734,6 +2742,12 @@ class ContourLegend extends ContourBase {
2734
2742
  static get properties() { return { title: { attribute: "title" }, ramp: { attribute: "ramp" }, scale: { attribute: "scale" }, items: { attribute: "items" }, method: { attribute: "method" }, norm: { attribute: "norm" }, selectable: { attribute: "selectable", type: Boolean }, src: { attribute: "src" } }; }
2735
2743
  render() {
2736
2744
  this.classList.add("c-legend");
2745
+ const continuous = this.hasAttribute("continuous");
2746
+ if (continuous || this.hasAttribute("selectable")) {
2747
+ this.setAttribute("role", "group");
2748
+ } else {
2749
+ this.setAttribute("role", "list");
2750
+ }
2737
2751
  wireStates(this);
2738
2752
  loadRemote(this, "items");
2739
2753
  if (renderStates(this, "legend")) return;
@@ -2749,7 +2763,7 @@ class ContourLegend extends ContourBase {
2749
2763
  items = JSON.stringify(authoredLegendItems.map((el) => {
2750
2764
  const sw = el.querySelector(".c-legend__swatch");
2751
2765
  const lbl = el.querySelector(".c-legend__label") || el;
2752
- return { label: lbl ? lbl.textContent.trim() : el.textContent.trim(), color: sw ? sw.style.background || undefined : undefined };
2766
+ return { label: lbl ? lbl.textContent.trim() : el.textContent.trim(), color: sw ? (sw.dataset && sw.dataset.color) || sw.style.background || undefined : undefined };
2753
2767
  }));
2754
2768
  authoredLegendItems.forEach((el) => el.remove());
2755
2769
  }
@@ -2765,17 +2779,20 @@ class ContourLegend extends ContourBase {
2765
2779
  try {
2766
2780
  const parsed = JSON.parse(items);
2767
2781
  const list = this.ensure(".c-legend__items", () => { const el = document.createElement("div"); el.className = "c-legend__items"; return el; });
2768
- list.setAttribute("role", selectable ? "group" : "listbox");
2782
+ if (this.hasAttribute("selectable")) {
2783
+ list.setAttribute("role", "group");
2784
+ } else {
2785
+ list.setAttribute("role", "listbox");
2786
+ }
2769
2787
  if (title) list.setAttribute("aria-label", title);
2770
2788
  list.innerHTML = "";
2771
2789
  parsed.forEach((it) => {
2772
2790
  const label = typeof it === "string" ? it : (it.label || String(it));
2773
2791
  const key = typeof it === "string" ? it : (it.key || it.label || String(it));
2774
- const item = document.createElement(selectable ? "button" : "div");
2792
+ const item = document.createElement("div");
2775
2793
  item.className = "c-legend__item";
2776
2794
  item.setAttribute("tabindex", "-1");
2777
2795
  if (selectable) {
2778
- item.type = "button";
2779
2796
  item.setAttribute("role", "button");
2780
2797
  item.setAttribute("aria-pressed", "true");
2781
2798
  item.dataset.key = key;
@@ -2785,7 +2802,7 @@ class ContourLegend extends ContourBase {
2785
2802
  }
2786
2803
  const sw = document.createElement("span");
2787
2804
  sw.className = "c-legend__swatch";
2788
- if (it && it.color) sw.style.background = it.color;
2805
+ if (it && it.color) { sw.style.background = it.color; sw.dataset.color = it.color; }
2789
2806
  item.appendChild(sw);
2790
2807
  // geometry glyph
2791
2808
  const glyphShape = (it && (it.shape || it.marker || it.glyph)) || this.getAttribute("glyphs");
@@ -2858,6 +2875,7 @@ class ContourLegend extends ContourBase {
2858
2875
  const glyph = document.createElement("span");
2859
2876
  glyph.className = "glyph";
2860
2877
  glyph.style.background = ndColor;
2878
+ glyph.dataset.color = ndColor;
2861
2879
  nd.prepend(glyph);
2862
2880
  } else {
2863
2881
  const nd = this.querySelector(".c-legend__no-data");
@@ -2994,10 +3012,19 @@ class ContourLegend extends ContourBase {
2994
3012
  this.addEventListener("click", (e) => {
2995
3013
  const btn = e.target && e.target.closest ? e.target.closest(".c-legend__item") : null;
2996
3014
  if (!btn || !this.contains(btn)) return;
2997
- const pressed = btn.getAttribute("aria-pressed") !== "true";
2998
- btn.setAttribute("aria-pressed", String(pressed));
3015
+ let selected;
3016
+ const isPressed = btn.getAttribute("aria-pressed");
3017
+ if (btn.getAttribute("aria-pressed") !== null) {
3018
+ const pressed = btn.getAttribute("aria-pressed") !== "true";
3019
+ btn.setAttribute("aria-pressed", String(pressed));
3020
+ selected = pressed;
3021
+ } else {
3022
+ const selected2 = btn.getAttribute("aria-selected") !== "true";
3023
+ btn.setAttribute("aria-selected", String(selected2));
3024
+ selected = selected2;
3025
+ }
2999
3026
  this.dispatchEvent(new CustomEvent("contour:legend-toggle", {
3000
- detail: { label: btn.textContent.trim(), key: btn.dataset.key || btn.textContent.trim(), pressed },
3027
+ detail: { label: btn.textContent.trim(), key: btn.dataset.key || btn.textContent.trim(), pressed: selected },
3001
3028
  bubbles: true,
3002
3029
  composed: true,
3003
3030
  }));
@@ -3368,7 +3395,7 @@ class ContourCompare extends ContourBase {
3368
3395
  this.classList.add("c-compare");
3369
3396
  this.setAttribute("role", "group");
3370
3397
  this.setAttribute("aria-label", "Comparison");
3371
- this.style.padding = "var(--space-md)";
3398
+
3372
3399
  wireStates(this);
3373
3400
  loadRemote(this, ["no", "text", "yes"]);
3374
3401
  if (renderStates(this, "compare")) return;
@@ -3631,3 +3658,51 @@ class ContourErrorBoundary extends ContourBase {
3631
3658
  }
3632
3659
  }
3633
3660
  define("contour-error-boundary", ContourErrorBoundary);
3661
+
3662
+ class ContourDataExport extends ContourBase {
3663
+ static get observed() { return ["data", "format", "filename", "label"]; }
3664
+ static get properties() { return { data: { attribute: "data" }, format: { attribute: "format" }, filename: { attribute: "filename" }, label: { attribute: "label" } }; }
3665
+ render() {
3666
+ this.classList.add("c-data-export");
3667
+ const fmt = (this.getAttribute("format") || "json").toLowerCase();
3668
+ const btn = this.ensure(".c-data-export__btn", () => {
3669
+ const b = document.createElement("button");
3670
+ b.className = "c-data-export__btn";
3671
+ b.type = "button";
3672
+ return b;
3673
+ });
3674
+ btn.textContent = this.getAttribute("label") || ("Export " + fmt.toUpperCase());
3675
+ if (btn.parentNode !== this) this.appendChild(btn);
3676
+ }
3677
+ enhance() {
3678
+ if (this._wiredDataExport) return;
3679
+ this._wiredDataExport = true;
3680
+ this.addEventListener("click", (e) => {
3681
+ const btn = e.target && e.target.closest ? e.target.closest(".c-data-export__btn") : null;
3682
+ if (!btn || !this.contains(btn)) return;
3683
+ const fmt = (this.getAttribute("format") || "json").toLowerCase();
3684
+ const raw = this.getAttribute("data") || "[]";
3685
+ let text = raw;
3686
+ if (fmt === "csv") {
3687
+ try {
3688
+ const arr = JSON.parse(raw);
3689
+ if (Array.isArray(arr) && arr.length) {
3690
+ const keys = Object.keys(arr[0]);
3691
+ text = [keys.join(",")].concat(arr.map((r) => keys.map((k) => JSON.stringify(r[k] ?? "")).join(","))).join("\n");
3692
+ }
3693
+ } catch (e) {}
3694
+ }
3695
+ const blob = new Blob([text], { type: fmt === "csv" ? "text/csv" : "application/json" });
3696
+ const url = URL.createObjectURL(blob);
3697
+ const a = document.createElement("a");
3698
+ a.href = url;
3699
+ a.download = this.getAttribute("filename") || ("export." + fmt);
3700
+ document.body.appendChild(a);
3701
+ a.click();
3702
+ a.remove();
3703
+ URL.revokeObjectURL(url);
3704
+ this.dispatchEvent(new CustomEvent("contour:export", { bubbles: true, composed: true, detail: { format: fmt } }));
3705
+ });
3706
+ }
3707
+ }
3708
+ define("contour-data-export", ContourDataExport);
package/dist/wc/docs.mjs CHANGED
@@ -157,3 +157,120 @@ class ContourFileTree extends ContourBase {
157
157
  }
158
158
  }
159
159
  define("contour-file-tree", ContourFileTree);
160
+
161
+ class ContourChangelog extends ContourBase {
162
+ static get observed() { return ["src", "max", "loading", "error"]; }
163
+ static get properties() { return { src: { attribute: "src" }, max: { attribute: "max", type: Number } }; }
164
+ render() {
165
+ this.classList.add("c-changelog");
166
+ const src = this.getAttribute("src");
167
+ if (src) {
168
+ if (this.dataset.loaded === src) return;
169
+ 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; });
171
+ // clear
172
+ Array.from(this.querySelectorAll(".c-changelog__entry, .c-changelog__error")).forEach((n) => n.remove());
173
+ if (!this.querySelector(".c-changelog__loading")) this.appendChild(loading);
174
+ fetch(src).then((r) => {
175
+ if (!r.ok) throw new Error("HTTP " + r.status);
176
+ return r.text();
177
+ }).then((text) => {
178
+ const ld = this.querySelector(".c-changelog__loading");
179
+ if (ld) ld.remove();
180
+ this.dataset.loaded = src;
181
+ const entries = parseChangelog(text);
182
+ const max = parseInt(this.getAttribute("max") || "0", 10);
183
+ const list = (max > 0) ? entries.slice(0, max) : entries;
184
+ if (!list.length) {
185
+ const empty = document.createElement("div");
186
+ empty.className = "c-changelog__empty";
187
+ empty.textContent = "No releases found.";
188
+ this.appendChild(empty);
189
+ return;
190
+ }
191
+ list.forEach((e) => {
192
+ const det = document.createElement("details");
193
+ det.className = "c-changelog__entry";
194
+ const sum = document.createElement("summary");
195
+ sum.className = "c-changelog__summary";
196
+ const ver = document.createElement("span");
197
+ ver.className = "c-changelog__version";
198
+ ver.textContent = e.version;
199
+ sum.appendChild(ver);
200
+ if (e.date) {
201
+ const d = document.createElement("span");
202
+ d.className = "c-changelog__date";
203
+ d.textContent = e.date;
204
+ sum.appendChild(d);
205
+ }
206
+ det.appendChild(sum);
207
+ const body = document.createElement("div");
208
+ body.className = "c-changelog__body";
209
+ body.innerHTML = renderChangelogBody(e.body);
210
+ det.appendChild(body);
211
+ this.appendChild(det);
212
+ });
213
+ }).catch((err) => {
214
+ const ld = this.querySelector(".c-changelog__loading");
215
+ if (ld) ld.remove();
216
+ const er = document.createElement("div");
217
+ er.className = "c-changelog__error";
218
+ er.textContent = "Failed to load changelog: " + (err && err.message ? err.message : err);
219
+ this.appendChild(er);
220
+ });
221
+ }
222
+ }
223
+ }
224
+ define("contour-changelog", ContourChangelog);
225
+
226
+ function parseChangelog(text) {
227
+ const lines = String(text).split(/\r?\n/);
228
+ const entries = [];
229
+ let cur = null;
230
+ for (const line of lines) {
231
+ const m = line.match(/^##\s+\[?([^\]\n]+)\]?\s*[-–—]?\s*(.*)$/);
232
+ if (m && (line.startsWith("## ") )) {
233
+ // only treat as version header if it looks like a version or "Unreleased"
234
+ const ver = m[1].trim();
235
+ const rest = m[2].trim();
236
+ if (/^\d|unreleased/i.test(ver)) {
237
+ if (cur) entries.push(cur);
238
+ cur = { version: ver, date: rest.replace(/^[-–—]\s*/, "").trim(), body: "" };
239
+ continue;
240
+ }
241
+ }
242
+ if (cur) cur.body += line + "\n";
243
+ }
244
+ if (cur) entries.push(cur);
245
+ return entries;
246
+ }
247
+
248
+ function escapeHtml(s) {
249
+ return String(s).replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;");
250
+ }
251
+
252
+ function renderChangelogBody(body) {
253
+ const lines = String(body).trim().split(/\r?\n/);
254
+ const out = [];
255
+ let inList = false;
256
+ for (const raw of lines) {
257
+ const line = raw.trimEnd();
258
+ if (/^###\s+/.test(line)) {
259
+ if (inList) { out.push("</ul>"); inList = false; }
260
+ out.push("<h4>" + escapeHtml(line.replace(/^###\s+/, "")) + "</h4>");
261
+ } else if (/^##\s+/.test(line)) {
262
+ if (inList) { out.push("</ul>"); inList = false; }
263
+ out.push("<h3>" + escapeHtml(line.replace(/^##\s+/, "")) + "</h3>");
264
+ } else if (/^[-*]\s+/.test(line)) {
265
+ if (!inList) { out.push("<ul>"); inList = true; }
266
+ out.push("<li>" + escapeHtml(line.replace(/^[-*]\s+/, "")) + "</li>");
267
+ } else if (line.trim() === "") {
268
+ if (inList) { out.push("</ul>"); inList = false; }
269
+ } else {
270
+ if (inList) { out.push("</ul>"); inList = false; }
271
+ out.push("<p>" + escapeHtml(line) + "</p>");
272
+ }
273
+ }
274
+ if (inList) out.push("</ul>");
275
+ return out.join("");
276
+ }
package/dist/wc/forms.mjs CHANGED
@@ -925,9 +925,13 @@ class ContourInputFull extends ContourBase {
925
925
  input.className = "c-input";
926
926
  input.type = this.getAttribute("type") || "text";
927
927
  input.placeholder = this.getAttribute("placeholder") || "";
928
- const label = this.getAttribute("label");
928
+ let label = this.getAttribute("label");
929
+ if (!label) {
930
+ const field = this.closest("contour-field");
931
+ if (field) label = field.getAttribute("label");
932
+ }
929
933
  if (label) input.setAttribute("aria-label", label);
930
- // else: keep any aria-label set by an ancestor (e.g. contour-field).
934
+ else if (!input.getAttribute("aria-label")) input.setAttribute("aria-label", "Input");
931
935
  if (this.hasAttribute("value")) input.value = this.getAttribute("value");
932
936
  if (this.hasAttribute("required")) input.setAttribute("required", "");
933
937
  else input.removeAttribute("required");
package/dist/wc/index.mjs CHANGED
@@ -5,6 +5,8 @@
5
5
  */
6
6
 
7
7
  import { REGISTERED } from "./core.mjs";
8
+ import { formatValue } from "./core.mjs";
9
+ import { MARKER_SHAPES, markerStyles, assignMarkers } from "./svg.mjs";
8
10
  import "./core.mjs";
9
11
  import "./behaviours.mjs";
10
12
  import "./states.mjs";
@@ -26,9 +28,31 @@ import "./shadow.mjs";
26
28
  // Published version + readiness signal. Fires after every fragment has run, so
27
29
  // a consumer listening for `contour:ready` can assume the full registry exists.
28
30
  /** Published component runtime version. */
29
- export const CONTOUR_VERSION = "1.5.0";
31
+ export const CONTOUR_VERSION = "1.7.0";
30
32
  if (typeof window !== "undefined") {
31
33
  window.ContourVersion = CONTOUR_VERSION;
34
+ if (!window.Contour) {
35
+ window.Contour = {
36
+ format: {
37
+ value: formatValue,
38
+ number: (value, format, locale) => formatValue(value, format, locale),
39
+ time: (value, locale) => {
40
+ try { return new Intl.DateTimeFormat(locale || undefined).format(new Date(value)); } catch (e) { return String(value); }
41
+ },
42
+ locale: (locale) => locale || (typeof navigator !== "undefined" ? navigator.language : "en"),
43
+ },
44
+ markers: {
45
+ shapes: MARKER_SHAPES,
46
+ styles: markerStyles,
47
+ assign: assignMarkers,
48
+ },
49
+ };
50
+ } else {
51
+ // ds.js may have already published window.Contour (frozen); top up
52
+ // non-frozen namespaces only when writable.
53
+ try { if (!window.Contour.format) window.Contour.format = { value: formatValue, number: (v, f, l) => formatValue(v, f, l), time: (v, l) => { try { return new Intl.DateTimeFormat(l || undefined).format(new Date(v)); } catch (e) { return String(v); } }, locale: (l) => l || (typeof navigator !== "undefined" ? navigator.language : "en") }; } catch (e) {}
54
+ try { if (!window.Contour.markers) window.Contour.markers = { shapes: MARKER_SHAPES, styles: markerStyles, assign: assignMarkers }; } catch (e) {}
55
+ }
32
56
  queueMicrotask(() => {
33
57
  try {
34
58
  window.dispatchEvent(new CustomEvent("contour:ready", {
@@ -54,6 +54,7 @@ class ContourShortcutListFull extends ContourBase {
54
54
  static get properties() { return { title: { attribute: "title" } }; }
55
55
  render() {
56
56
  this.classList.add("c-shortcut-list");
57
+ this.setAttribute("role", "list");
57
58
  const title = this.getAttribute("title");
58
59
  if (title) {
59
60
  const t = this.ensure(".c-shortcut-list__title", () => { const el = document.createElement("div"); el.className = "c-shortcut-list__title"; el.style.padding = "var(--space-sm)"; el.style.fontWeight = "var(--weight-semibold)"; return el; });
@@ -67,6 +68,7 @@ class ContourShortcutRowFull extends ContourBase {
67
68
  static get properties() { return { desc: { attribute: "desc" }, key: { attribute: "key" } }; }
68
69
  render() {
69
70
  this.classList.add("c-shortcut-row");
71
+ this.setAttribute("role", "listitem");
70
72
  const key = this.getAttribute("key");
71
73
  const desc = this.getAttribute("desc");
72
74
  if (key) {
@@ -111,7 +113,7 @@ class ContourShortcutPanelFull extends ContourBase {
111
113
  this.classList.add("c-shortcut-overlay");
112
114
  const title = this.getAttribute("title");
113
115
  if (title) {
114
- const t = this.ensure(".c-shortcut-overlay__title", () => { const el = document.createElement("div"); el.className = "c-shortcut-overlay__title"; el.style.padding = "var(--space-sm)"; return el; });
116
+ const t = this.ensure(".c-shortcut-overlay__title", () => { const el = document.createElement("div"); el.className = "c-shortcut-overlay__title"; return el; });
115
117
  t.textContent = title;
116
118
  }
117
119
  if (this.hasAttribute("open")) this.removeAttribute("hidden");
@@ -7,7 +7,7 @@ import { ContourBase, define } from './core.mjs';
7
7
  const header = this.ensure(".c-app__header", () => { const el = document.createElement("header"); el.className = "c-app__header"; return el; });
8
8
  const title = this.getAttribute("title");
9
9
  if (title) {
10
- const t = this.ensure(".c-app__title", () => { const el = document.createElement("div"); el.className = "c-app__title"; el.style.padding = "var(--space-md)"; el.style.fontWeight = "var(--weight-semibold)"; return el; });
10
+ const t = this.ensure(".c-app__title", () => { const el = document.createElement("div"); el.className = "c-app__title"; return el; });
11
11
  t.textContent = title;
12
12
  if (t.parentNode !== header) header.appendChild(t);
13
13
  }
@@ -25,7 +25,7 @@ import { ContourBase, define } from './core.mjs';
25
25
  const main = this.ensure(".c-app-body__main", () => { const el = document.createElement("main"); el.className = "c-app-body__main"; return el; });
26
26
  const title = this.getAttribute("title");
27
27
  if (title) {
28
- const t = this.ensure(".c-app-body__title", () => { const el = document.createElement("div"); el.className = "c-app-body__title"; el.style.padding = "var(--space-md)"; return el; });
28
+ const t = this.ensure(".c-app-body__title", () => { const el = document.createElement("div"); el.className = "c-app-body__title"; return el; });
29
29
  t.textContent = title;
30
30
  if (t.parentNode !== main) main.appendChild(t);
31
31
  }
package/dist/wc/map.mjs CHANGED
@@ -1179,3 +1179,24 @@ class ContourScaleBar extends ContourBase {
1179
1179
  }
1180
1180
  }
1181
1181
  define("contour-scale-bar", ContourScaleBar);
1182
+
1183
+ class ContourSplitMap extends ContourBase {
1184
+ static get observed() { return ["left", "right"]; }
1185
+ static get properties() { return { left: { attribute: "left" }, right: { attribute: "right" } }; }
1186
+ render() {
1187
+ this.classList.add("c-split-map");
1188
+ const left = this.ensure(".c-split-map__pane--left", () => {
1189
+ const e = document.createElement("div");
1190
+ e.className = "c-split-map__pane c-split-map__pane--left";
1191
+ return e;
1192
+ });
1193
+ const right = this.ensure(".c-split-map__pane--right", () => {
1194
+ const e = document.createElement("div");
1195
+ e.className = "c-split-map__pane c-split-map__pane--right";
1196
+ return e;
1197
+ });
1198
+ if (left.parentNode !== this) this.appendChild(left);
1199
+ if (right.parentNode !== this) this.appendChild(right);
1200
+ }
1201
+ }
1202
+ define("contour-split-map", ContourSplitMap);