contour-ds 1.5.0 → 1.7.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 (60) hide show
  1. package/README.md +25 -3
  2. package/dist/build-manifest.json +52 -52
  3. package/dist/contour-wc.esm.js +302 -26
  4. package/dist/contour-wc.esm.min.js +1 -1
  5. package/dist/contour-wc.js +302 -26
  6. package/dist/contour-wc.min.js +1 -1
  7. package/dist/contour.components.json +1468 -47
  8. package/dist/contour.css +689 -527
  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 +2 -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/core.mjs +33 -3
  54. package/dist/wc/data.mjs +71 -17
  55. package/dist/wc/docs.mjs +117 -0
  56. package/dist/wc/index.mjs +25 -1
  57. package/dist/wc/map.mjs +21 -0
  58. package/dist/wc/navigation.mjs +1 -1
  59. package/dist/wc/ui.mjs +59 -5
  60. package/package.json +1 -1
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
@@ -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");
@@ -2079,6 +2082,7 @@ class ContourDonut extends ContourBase {
2079
2082
  const sw = document.createElement("span");
2080
2083
  sw.className = "c-donut__swatch";
2081
2084
  sw.style.background = (typeof it === "object" && it.color) ? it.color : "var(--chart-" + ((i % 8) + 1) + ")";
2085
+ if (sw.style.background) sw.dataset.color = (typeof it === "object" && it.color) ? it.color : sw.style.background;
2082
2086
  row.appendChild(sw);
2083
2087
  const lbl = document.createElement("span");
2084
2088
  lbl.textContent = (typeof it === "object" ? (it.label || "") : String(it)) + " — " + values[i];
@@ -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
  }
@@ -2749,7 +2755,7 @@ class ContourLegend extends ContourBase {
2749
2755
  items = JSON.stringify(authoredLegendItems.map((el) => {
2750
2756
  const sw = el.querySelector(".c-legend__swatch");
2751
2757
  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 };
2758
+ return { label: lbl ? lbl.textContent.trim() : el.textContent.trim(), color: sw ? (sw.dataset && sw.dataset.color) || sw.style.background || undefined : undefined };
2753
2759
  }));
2754
2760
  authoredLegendItems.forEach((el) => el.remove());
2755
2761
  }
@@ -2765,19 +2771,18 @@ class ContourLegend extends ContourBase {
2765
2771
  try {
2766
2772
  const parsed = JSON.parse(items);
2767
2773
  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");
2774
+ list.setAttribute("role", "listbox");
2769
2775
  if (title) list.setAttribute("aria-label", title);
2770
2776
  list.innerHTML = "";
2771
2777
  parsed.forEach((it) => {
2772
2778
  const label = typeof it === "string" ? it : (it.label || String(it));
2773
2779
  const key = typeof it === "string" ? it : (it.key || it.label || String(it));
2774
- const item = document.createElement(selectable ? "button" : "div");
2780
+ const item = document.createElement("div");
2775
2781
  item.className = "c-legend__item";
2776
2782
  item.setAttribute("tabindex", "-1");
2777
2783
  if (selectable) {
2778
- item.type = "button";
2779
- item.setAttribute("role", "button");
2780
- item.setAttribute("aria-pressed", "true");
2784
+ item.setAttribute("role", "option");
2785
+ item.setAttribute("aria-selected", "true");
2781
2786
  item.dataset.key = key;
2782
2787
  } else {
2783
2788
  item.setAttribute("role", "option");
@@ -2785,7 +2790,7 @@ class ContourLegend extends ContourBase {
2785
2790
  }
2786
2791
  const sw = document.createElement("span");
2787
2792
  sw.className = "c-legend__swatch";
2788
- if (it && it.color) sw.style.background = it.color;
2793
+ if (it && it.color) { sw.style.background = it.color; sw.dataset.color = it.color; }
2789
2794
  item.appendChild(sw);
2790
2795
  // geometry glyph
2791
2796
  const glyphShape = (it && (it.shape || it.marker || it.glyph)) || this.getAttribute("glyphs");
@@ -2858,6 +2863,7 @@ class ContourLegend extends ContourBase {
2858
2863
  const glyph = document.createElement("span");
2859
2864
  glyph.className = "glyph";
2860
2865
  glyph.style.background = ndColor;
2866
+ glyph.dataset.color = ndColor;
2861
2867
  nd.prepend(glyph);
2862
2868
  } else {
2863
2869
  const nd = this.querySelector(".c-legend__no-data");
@@ -2994,10 +3000,10 @@ class ContourLegend extends ContourBase {
2994
3000
  this.addEventListener("click", (e) => {
2995
3001
  const btn = e.target && e.target.closest ? e.target.closest(".c-legend__item") : null;
2996
3002
  if (!btn || !this.contains(btn)) return;
2997
- const pressed = btn.getAttribute("aria-pressed") !== "true";
2998
- btn.setAttribute("aria-pressed", String(pressed));
3003
+ const selected = btn.getAttribute("aria-selected") !== "true";
3004
+ btn.setAttribute("aria-selected", String(selected));
2999
3005
  this.dispatchEvent(new CustomEvent("contour:legend-toggle", {
3000
- detail: { label: btn.textContent.trim(), key: btn.dataset.key || btn.textContent.trim(), pressed },
3006
+ detail: { label: btn.textContent.trim(), key: btn.dataset.key || btn.textContent.trim(), pressed: selected },
3001
3007
  bubbles: true,
3002
3008
  composed: true,
3003
3009
  }));
@@ -3631,3 +3637,51 @@ class ContourErrorBoundary extends ContourBase {
3631
3637
  }
3632
3638
  }
3633
3639
  define("contour-error-boundary", ContourErrorBoundary);
3640
+
3641
+ class ContourDataExport extends ContourBase {
3642
+ static get observed() { return ["data", "format", "filename", "label"]; }
3643
+ static get properties() { return { data: { attribute: "data" }, format: { attribute: "format" }, filename: { attribute: "filename" }, label: { attribute: "label" } }; }
3644
+ render() {
3645
+ this.classList.add("c-data-export");
3646
+ const fmt = (this.getAttribute("format") || "json").toLowerCase();
3647
+ const btn = this.ensure(".c-data-export__btn", () => {
3648
+ const b = document.createElement("button");
3649
+ b.className = "c-data-export__btn";
3650
+ b.type = "button";
3651
+ return b;
3652
+ });
3653
+ btn.textContent = this.getAttribute("label") || ("Export " + fmt.toUpperCase());
3654
+ if (btn.parentNode !== this) this.appendChild(btn);
3655
+ }
3656
+ enhance() {
3657
+ if (this._wiredDataExport) return;
3658
+ this._wiredDataExport = true;
3659
+ this.addEventListener("click", (e) => {
3660
+ const btn = e.target && e.target.closest ? e.target.closest(".c-data-export__btn") : null;
3661
+ if (!btn || !this.contains(btn)) return;
3662
+ const fmt = (this.getAttribute("format") || "json").toLowerCase();
3663
+ const raw = this.getAttribute("data") || "[]";
3664
+ let text = raw;
3665
+ if (fmt === "csv") {
3666
+ try {
3667
+ const arr = JSON.parse(raw);
3668
+ if (Array.isArray(arr) && arr.length) {
3669
+ const keys = Object.keys(arr[0]);
3670
+ text = [keys.join(",")].concat(arr.map((r) => keys.map((k) => JSON.stringify(r[k] ?? "")).join(","))).join("\n");
3671
+ }
3672
+ } catch (e) {}
3673
+ }
3674
+ const blob = new Blob([text], { type: fmt === "csv" ? "text/csv" : "application/json" });
3675
+ const url = URL.createObjectURL(blob);
3676
+ const a = document.createElement("a");
3677
+ a.href = url;
3678
+ a.download = this.getAttribute("filename") || ("export." + fmt);
3679
+ document.body.appendChild(a);
3680
+ a.click();
3681
+ a.remove();
3682
+ URL.revokeObjectURL(url);
3683
+ this.dispatchEvent(new CustomEvent("contour:export", { bubbles: true, composed: true, detail: { format: fmt } }));
3684
+ });
3685
+ }
3686
+ }
3687
+ 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/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", {
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);
@@ -1032,7 +1032,7 @@ class ContourFilterBar extends ContourBase {
1032
1032
  if (modesAttr) { try { modes = JSON.parse(modesAttr); } catch (e) { modes = modesAttr.split(",").map((s) => s.trim()); } }
1033
1033
  if (modes || this.hasAttribute("mode")) {
1034
1034
  let bar = this.querySelector(".c-filter-bar__modes");
1035
- if (!bar) { bar = document.createElement("div"); bar.className = "c-filter-bar__modes"; bar.setAttribute("role", "toolbar"); this.appendChild(bar); }
1035
+ if (!bar) { bar = document.createElement("div"); bar.className = "c-filter-bar__modes"; bar.setAttribute("role", "toolbar"); bar.setAttribute("aria-label", label || "Filter modes"); this.appendChild(bar); }
1036
1036
  bar.innerHTML = "";
1037
1037
  const current = this.getAttribute("mode");
1038
1038
  const list = Array.isArray(modes) ? modes : ["draw", "erase", "select"];
package/dist/wc/ui.mjs CHANGED
@@ -1092,7 +1092,9 @@ class ContourStylePanel extends ContourBase {
1092
1092
  const breaksWrap = document.createElement("div"); breaksWrap.className = "c-style-panel__breaks";
1093
1093
  breaksArr.forEach((b, i) => {
1094
1094
  const br = document.createElement("div"); br.className = "break";
1095
- br.textContent = String(b);
1095
+ const span = document.createElement("span"); span.textContent = String(b); br.appendChild(span);
1096
+ const inp = document.createElement("input"); inp.type = "number"; inp.className = "c-style-panel__breaks c-input"; inp.setAttribute("aria-label", "Class lower bound"); inp.value = String(b);
1097
+ br.appendChild(inp);
1096
1098
  breaksWrap.appendChild(br);
1097
1099
  });
1098
1100
  body.appendChild(breaksWrap);
@@ -1267,7 +1269,7 @@ class ContourAvatarGroup extends ContourBase {
1267
1269
  av.className = "c-avatar";
1268
1270
  const name = typeof it === "string" ? it : (it.name || it.label || "");
1269
1271
  av.textContent = name.slice(0, 2).toUpperCase();
1270
- if (typeof it === "object" && it.color) av.style.background = it.color;
1272
+ if (typeof it === "object" && it.color) { av.style.background = it.color; av.dataset.color = it.color; }
1271
1273
  this.appendChild(av);
1272
1274
  });
1273
1275
  if (parsed.length > max) {
@@ -1412,6 +1414,7 @@ class ContourPaletteEditor extends ContourBase {
1412
1414
  sw.className = "c-palette-editor__swatch c-swatch";
1413
1415
  sw.type = "button";
1414
1416
  sw.style.background = typeof c === "string" ? c : (c.color || c.value || "");
1417
+ sw.dataset.color = typeof c === "string" ? c : (c.color || c.value || "");
1415
1418
  sw.setAttribute("aria-label", typeof c === "string" ? c : (c.name || c.label || "color"));
1416
1419
  this.appendChild(sw);
1417
1420
  });
@@ -1424,7 +1427,7 @@ class ContourPaletteEditor extends ContourBase {
1424
1427
  this.addEventListener("click", (e) => {
1425
1428
  const sw = e.target && e.target.closest ? e.target.closest(".c-palette-editor__swatch") : null;
1426
1429
  if (sw && this.contains(sw)) {
1427
- this.dispatchEvent(new CustomEvent("contour:change", { bubbles: true, composed: true, detail: { color: sw.style.background } }));
1430
+ this.dispatchEvent(new CustomEvent("contour:change", { bubbles: true, composed: true, detail: { color: (sw.dataset && sw.dataset.color) || sw.style.background } }));
1428
1431
  }
1429
1432
  });
1430
1433
  this.addEventListener("keydown", (e) => {
@@ -1860,8 +1863,8 @@ class ContourColorPicker extends ContourBase {
1860
1863
  btn.type = "button";
1861
1864
  btn.className = "c-color-picker__preset";
1862
1865
  btn.style.background = c;
1863
- btn.setAttribute("aria-label", "Preset " + c);
1864
1866
  btn.dataset.color = c;
1867
+ btn.setAttribute("aria-label", "Preset " + c);
1865
1868
  wrap.appendChild(btn);
1866
1869
  });
1867
1870
  this.appendChild(wrap);
@@ -2218,7 +2221,7 @@ class ContourNotificationCenter extends ContourBase {
2218
2221
  const btn = this.ensure(".c-notification-center__trigger", () => { const el = document.createElement("button"); el.className = "c-btn c-btn--sm c-notification-center__trigger"; el.type = "button"; el.innerHTML = '<span class="c-notification-center__bullet" aria-hidden="true"></span>'; el.setAttribute("aria-haspopup", "dialog"); el.setAttribute("aria-expanded", "false"); return el; });
2219
2222
  const color = this.getAttribute("color");
2220
2223
  const bullet = btn.querySelector(".c-notification-center__bullet");
2221
- if (bullet && color) bullet.style.background = color;
2224
+ if (bullet && color) { bullet.style.background = color; bullet.dataset.color = color; }
2222
2225
  const count = this.getAttribute("count");
2223
2226
  let badge = btn.querySelector(".c-notification-center__badge");
2224
2227
  if (count && Number(count) > 0) {
@@ -3233,6 +3236,7 @@ class ContourDataGrid extends ContourBase {
3233
3236
  td.setAttribute("role", "gridcell");
3234
3237
  td.setAttribute("tabindex", "0");
3235
3238
  td.textContent = r && r[key] != null ? r[key] : "";
3239
+ if (!String(td.textContent).trim()) td.setAttribute("aria-label", "Empty");
3236
3240
  tr.appendChild(td);
3237
3241
  });
3238
3242
  tbody.appendChild(tr);
@@ -3282,6 +3286,7 @@ class ContourDataGrid extends ContourBase {
3282
3286
  td.setAttribute("role", "gridcell");
3283
3287
  td.setAttribute("tabindex", "0");
3284
3288
  td.textContent = r && r[key] != null ? r[key] : "";
3289
+ if (!String(td.textContent).trim()) td.setAttribute("aria-label", "Empty");
3285
3290
  tr.appendChild(td);
3286
3291
  });
3287
3292
  tbody.appendChild(tr);
@@ -3499,3 +3504,52 @@ class ContourTreeGrid extends ContourBase {
3499
3504
  }
3500
3505
  }
3501
3506
  define("contour-tree-grid", ContourTreeGrid);
3507
+
3508
+ class ContourPullToRefresh extends ContourBase {
3509
+ static get observed() { return ["threshold"]; }
3510
+ static get properties() { return { threshold: { attribute: "threshold" } }; }
3511
+ render() {
3512
+ this.classList.add("c-pull-to-refresh");
3513
+ const ind = this.ensure(".c-pull-to-refresh__indicator", () => {
3514
+ const e = document.createElement("div");
3515
+ e.className = "c-pull-to-refresh__indicator";
3516
+ e.textContent = "Pull to refresh";
3517
+ return e;
3518
+ });
3519
+ if (ind.parentNode !== this) this.prepend(ind);
3520
+ }
3521
+ enhance() {
3522
+ if (this._wiredPullToRefresh) return;
3523
+ this._wiredPullToRefresh = true;
3524
+ let startY = 0;
3525
+ let pulling = false;
3526
+ this.addEventListener("touchstart", (e) => {
3527
+ if (this.scrollTop > 0) return;
3528
+ const t = e.touches && e.touches[0];
3529
+ if (t) { startY = t.clientY; pulling = true; }
3530
+ }, { passive: true });
3531
+ this.addEventListener("touchmove", (e) => {
3532
+ if (!pulling) return;
3533
+ const t = e.touches && e.touches[0];
3534
+ if (!t) return;
3535
+ const dy = t.clientY - startY;
3536
+ if (dy > 0 && dy < 120) {
3537
+ this.style.setProperty("--ptr-offset", dy + "px");
3538
+ }
3539
+ }, { passive: true });
3540
+ this.addEventListener("touchend", (e) => {
3541
+ if (!pulling) return;
3542
+ pulling = false;
3543
+ const t = e.changedTouches && e.changedTouches[0];
3544
+ const dy = t ? t.clientY - startY : 0;
3545
+ const thr = Number(this.getAttribute("threshold")) || 60;
3546
+ if (dy >= thr) {
3547
+ this.classList.add("is-refreshing");
3548
+ this.dispatchEvent(new CustomEvent("contour:refresh", { bubbles: true, composed: true }));
3549
+ setTimeout(() => this.classList.remove("is-refreshing"), 800);
3550
+ }
3551
+ this.style.removeProperty("--ptr-offset");
3552
+ }, { passive: true });
3553
+ }
3554
+ }
3555
+ define("contour-pull-to-refresh", ContourPullToRefresh);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "contour-ds",
3
- "version": "1.5.0",
3
+ "version": "1.7.1",
4
4
  "description": "A token-driven design system for spatial interfaces",
5
5
  "license": "MIT",
6
6
  "type": "module",