contour-ds 1.1.0 → 1.1.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 (50) hide show
  1. package/dist/build-manifest.json +35 -35
  2. package/dist/contour-wc.esm.js +493 -159
  3. package/dist/contour-wc.esm.min.js +1 -1
  4. package/dist/contour-wc.js +493 -159
  5. package/dist/contour-wc.min.js +1 -1
  6. package/dist/contour.components.json +36 -10
  7. package/dist/contour.css +98 -35
  8. package/dist/contour.min.css +1 -1
  9. package/dist/docs/actions.md +1 -1
  10. package/dist/docs/affordances.md +1 -1
  11. package/dist/docs/colour.md +1 -1
  12. package/dist/docs/data.md +1 -1
  13. package/dist/docs/docs.md +1 -1
  14. package/dist/docs/feedback.md +1 -1
  15. package/dist/docs/field.md +1 -1
  16. package/dist/docs/forms.md +1 -1
  17. package/dist/docs/index.json +2 -2
  18. package/dist/docs/install.md +1 -1
  19. package/dist/docs/landing.md +1 -1
  20. package/dist/docs/mapengine.md +1 -1
  21. package/dist/docs/motion.md +1 -1
  22. package/dist/docs/navigation.md +1 -1
  23. package/dist/docs/overlays.md +1 -1
  24. package/dist/docs/overview.md +1 -1
  25. package/dist/docs/patterns.md +1 -1
  26. package/dist/docs/playground.md +1 -1
  27. package/dist/docs/principles.md +1 -1
  28. package/dist/docs/recipes.md +1 -1
  29. package/dist/docs/space.md +1 -1
  30. package/dist/docs/status.md +1 -1
  31. package/dist/docs/surfaces.md +1 -1
  32. package/dist/docs/theming.md +1 -1
  33. package/dist/docs/type.md +1 -1
  34. package/dist/docs/webcomponents.md +1 -1
  35. package/dist/registry/items/contour-core.json +2 -2
  36. package/dist/registry/items/contour-data.json +2 -2
  37. package/dist/registry/items/contour-docs.json +2 -2
  38. package/dist/registry/items/contour-landing.json +2 -2
  39. package/dist/registry/registry.json +8 -8
  40. package/dist/surfaces/contour-core.min.css +1 -1
  41. package/dist/surfaces/contour-data.min.css +1 -1
  42. package/dist/surfaces/contour-docs.min.css +1 -1
  43. package/dist/surfaces/contour-landing.min.css +1 -1
  44. package/dist/wc/core.mjs +6 -3
  45. package/dist/wc/data.mjs +138 -28
  46. package/dist/wc/forms.mjs +119 -61
  47. package/dist/wc/map.mjs +123 -54
  48. package/dist/wc/navigation.mjs +66 -11
  49. package/dist/wc/ui.mjs +41 -2
  50. package/package.json +1 -1
@@ -106,6 +106,8 @@ const CONTOUR_EVENTS = Object.freeze({
106
106
  "contour:layer-duplicate": { payload: ["name"], composed: true },
107
107
  "contour:layer-zoom": { payload: ["name"], composed: true },
108
108
  "contour:layer-projection": { payload: ["name", "projection"], composed: true },
109
+ "contour:layer-remove": { payload: ["name"], composed: true },
110
+ "contour:layer-reorder": { payload: ["layerIds"], composed: true },
109
111
  "contour:layer-toggle": { payload: ["name"], composed: true },
110
112
  "contour:layer-visibility": { payload: ["name", "visible"], composed: true },
111
113
  "contour:legend-toggle": { payload: ["label", "key", "layers", "pressed"], composed: true },
@@ -113,6 +115,7 @@ const CONTOUR_EVENTS = Object.freeze({
113
115
  "contour:map-control": { payload: ["control"], composed: true },
114
116
  "contour:map-attach": { payload: [], composed: true },
115
117
  "contour:map-detach": { payload: [], composed: true },
118
+ "contour:mode-change": { payload: ["mode"], composed: true },
116
119
  "contour:move": { payload: ["direction"], composed: true },
117
120
  "contour:open": { payload: [], composed: true },
118
121
  "contour:page": { payload: ["page"], composed: true },
@@ -175,13 +178,13 @@ function sanitizeHtml(input) {
175
178
  // role, open, aria-label, aria-valuenow, aria-valuemin, aria-valuemax, tabindex
176
179
  // Adding one of those back to this list makes that component recurse.
177
180
  const OBSERVED = [
178
- "accept", "action", "actions", "after", "anchor", "answer", "area", "article", "attribution", "attribution-mark", "autoplay", "axis", "axis-x", "axis-y", "brownout", "brownout-level", "before", "body", "brand", "breakpoint", "cache-key", "canvas", "center", "clearable", "cols", "columns", "color", "command",
179
- "cells", "checked", "chrome", "closable", "colors", "content", "controls", "copyable", "count", "current", "data", "date", "delta", "description", "glyphs", "demo", "density", "desc", "dir", "direction", "disabled", "dismissible", "divider", "do", "dont", "dot",
181
+ "accept", "action", "actions", "after", "allow-duplicate", "allow-remove", "allow-rename", "allow-zoom", "anchor", "answer", "area", "article", "attribution", "attribution-mark", "audit", "autoplay", "axis", "axis-x", "axis-y", "brownout", "brownout-level", "before", "body", "brand", "breakpoint", "breaks", "cache-key", "canvas", "center", "clearable", "cols", "columns", "color", "command",
182
+ "cells", "checked", "chrome", "closable", "classification", "colors", "continuous", "content", "controls", "copyable", "count", "current", "data", "date", "delta", "description", "glyphs", "demo", "density", "desc", "dir", "direction", "disabled", "dismissible", "divider", "do", "dont", "dot", "ends", "high", "input", "layer", "low", "mode", "modes", "n", "opacity", "palette", "polarity", "range", "single",
180
183
  "empty", "error", "exclusive", "format", "heading", "hint", "href", "icon", "illustration", "index", "instrument", "interval", "items", "key", "layers", "level",
181
184
  "label", "lazy", "lede", "legend", "line", "link", "links", "live", "loading", "locale", "loop", "max", "media", "message", "method", "month", "menu", "min", "multiple", "name", "needle", "next", "no", "no-cache", "no-data-message", "nodes", "note", "norm", "normalize",
182
185
  "options", "orientation", "page-size", "pages", "pause", "paused", "pausable", "persist", "placeholder", "playing", "point", "points", "prev", "progress", "prompt", "question", "recent", "required",
183
186
  "quote", "ramp", "refresh", "removable", "reverse", "rings", "retry", "rows", "scale", "selectable", "segments", "show-header", "sparkline", "start", "end", "threshold", "thresholds", "selected", "separator", "series", "shortcut", "side", "size", "skeleton", "sort", "sort-dir", "speed", "status", "step", "submit", "timeout", "trigger", "virtual",
184
- "state", "steps", "subtitle", "summary", "src", "tabs", "tag", "text", "ticks", "title", "type", "unit",
187
+ "state", "steps", "subtitle", "summary", "src", "table", "tabs", "tag", "text", "ticks", "title", "type", "unit",
185
188
  "variant", "values", "viewport", "yes", "zoomable", "x", "y",
186
189
  ];
187
190
  function headingTag(host, fallback = "h3") {
@@ -3787,13 +3790,18 @@ class ContourKpi extends ContourBase {
3787
3790
  const h = this.querySelector(".c-kpi__head");
3788
3791
  if (h) h.remove();
3789
3792
  }
3790
- if (delta) {
3791
- const f = this.ensure(".c-kpi__foot", () => { const el = document.createElement("div"); el.className = "c-kpi__foot"; return el; });
3792
- const d = f.querySelector(".c-delta") || document.createElement("span");
3793
- if (!d.parentNode) f.insertBefore(d, f.firstChild);
3794
- d.className = "c-delta c-delta--" + (this.getAttribute("direction") || "up");
3795
- d.textContent = delta;
3796
- } else {
3793
+ if (delta) {
3794
+ const f = this.ensure(".c-kpi__foot", () => { const el = document.createElement("div"); el.className = "c-kpi__foot"; return el; });
3795
+ const d = f.querySelector(".c-delta") || document.createElement("span");
3796
+ if (!d.parentNode) f.insertBefore(d, f.firstChild);
3797
+ const dir = this.getAttribute("direction") || "up";
3798
+ const polarity = this.getAttribute("polarity") || "neutral";
3799
+ let tone = "neutral";
3800
+ if (polarity === "good") tone = (dir === "up") ? "good" : "bad";
3801
+ else if (polarity === "bad") tone = (dir === "up") ? "bad" : "good";
3802
+ d.className = "c-delta c-delta--" + dir + " c-delta--" + tone;
3803
+ d.textContent = delta;
3804
+ } else {
3797
3805
  const d = this.querySelector(".c-kpi__foot .c-delta");
3798
3806
  if (d) d.remove();
3799
3807
  }
@@ -5727,7 +5735,7 @@ class ContourMetricsFull extends ContourBase {
5727
5735
  }
5728
5736
  define("contour-metrics", ContourMetricsFull);
5729
5737
  class ContourLegend extends ContourBase {
5730
- static get observed() { return ["title", "ramp", "scale", "items", "method", "norm", "selectable", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton", "glyphs", "thresholds", "breaks", "no-data-color"]; }
5738
+ static get observed() { return ["title", "ramp", "scale", "items", "method", "norm", "selectable", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton", "glyphs", "thresholds", "breaks", "no-data-color", "size", "table", "classification", "audit", "continuous", "ends", "caption"]; }
5731
5739
  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" } }; }
5732
5740
  render() {
5733
5741
  this.classList.add("c-legend");
@@ -5767,14 +5775,15 @@ class ContourLegend extends ContourBase {
5767
5775
  if (it && it.color) sw.style.background = it.color;
5768
5776
  item.appendChild(sw);
5769
5777
  // geometry glyph
5770
- const glyphShape = (it && (it.shape || it.marker || it.glyph)) || this.getAttribute("glyphs");
5771
- if (glyphShape) {
5772
- const g = document.createElement("span");
5773
- g.className = "c-legend__glyph";
5774
- g.setAttribute("part", "glyph");
5775
- g.textContent = glyphShape === "circle" ? "●" : glyphShape === "square" ? "■" : glyphShape === "triangle" ? "▲" : glyphShape === "diamond" ? "◆" : glyphShape === "star" ? "★" : String(glyphShape);
5776
- item.appendChild(g);
5777
- }
5778
+ const glyphShape = (it && (it.shape || it.marker || it.glyph)) || this.getAttribute("glyphs");
5779
+ if (glyphShape) {
5780
+ const g = document.createElement("span");
5781
+ g.className = "c-legend__glyph";
5782
+ g.setAttribute("part", "glyph");
5783
+ g.textContent = glyphShape === "circle" ? "●" : glyphShape === "square" ? "■" : glyphShape === "triangle" ? "▲" : glyphShape === "diamond" ? "◆" : glyphShape === "star" ? "★" : String(glyphShape);
5784
+ if (it && it.size != null) g.style.fontSize = (typeof it.size === "number" ? it.size + "px" : String(it.size));
5785
+ item.appendChild(g);
5786
+ }
5778
5787
  // threshold break marker
5779
5788
  if (it && it.break != null) {
5780
5789
  const b = document.createElement("span");
@@ -5782,9 +5791,21 @@ class ContourLegend extends ContourBase {
5782
5791
  b.textContent = String(it.break);
5783
5792
  item.appendChild(b);
5784
5793
  }
5785
- const lbl = document.createElement("span");
5786
- lbl.textContent = label;
5787
- item.appendChild(lbl);
5794
+ const lbl = document.createElement("span");
5795
+ lbl.textContent = label;
5796
+ item.appendChild(lbl);
5797
+ // caption (source-and-method line)
5798
+ const caption = (typeof it === "object" && it) ? (it.caption || it.note || "") : "";
5799
+ if (caption) {
5800
+ const cap = document.createElement("span");
5801
+ cap.className = "c-legend__caption";
5802
+ cap.textContent = caption;
5803
+ item.appendChild(cap);
5804
+ }
5805
+ // threshold mark: outline on swatches that begin at a threshold
5806
+ if (it && (it.threshold || it.break != null)) {
5807
+ sw.style.outline = "2px solid var(--color-border-strong)";
5808
+ }
5788
5809
  list.appendChild(item);
5789
5810
  });
5790
5811
  } catch (e) { /* keep existing */ }
@@ -5796,7 +5817,79 @@ class ContourLegend extends ContourBase {
5796
5817
  renderEmpty(this, "legend");
5797
5818
  }
5798
5819
  }
5799
- const method = this.getAttribute("method");
5820
+ // audit notice
5821
+ const audit = this.getAttribute("audit");
5822
+ if (audit) {
5823
+ const a = this.ensure(".c-legend__audit", () => { const el = document.createElement("div"); el.className = "c-legend__audit"; return el; });
5824
+ a.textContent = audit;
5825
+ } else {
5826
+ const a = this.querySelector(".c-legend__audit");
5827
+ if (a) a.remove();
5828
+ }
5829
+ // continuous variant: ramp with two ends labelled
5830
+ if (this.hasAttribute("continuous")) {
5831
+ const ends = this.getAttribute("ends");
5832
+ let parsedEnds = null;
5833
+ if (ends) { try { parsedEnds = JSON.parse(ends); } catch (e) { parsedEnds = ends.split(","); } }
5834
+ if (Array.isArray(parsedEnds) && parsedEnds.length >= 2) {
5835
+ const r = this.ensure(".c-legend__ramp", () => { const el = document.createElement("div"); el.className = "c-legend__ramp"; return el; });
5836
+ // labels
5837
+ let left = this.querySelector(".c-legend__ramp-label--start");
5838
+ if (!left) { left = document.createElement("span"); left.className = "c-legend__ramp-label c-legend__ramp-label--start"; r.appendChild(left); }
5839
+ left.textContent = parsedEnds[0];
5840
+ let right = this.querySelector(".c-legend__ramp-label--end");
5841
+ if (!right) { right = document.createElement("span"); right.className = "c-legend__ramp-label c-legend__ramp-label--end"; r.appendChild(right); }
5842
+ right.textContent = parsedEnds[parsedEnds.length - 1];
5843
+ }
5844
+ }
5845
+ // size variant: differently-sized glyphs
5846
+ const sizeAttr = this.getAttribute("size");
5847
+ if (sizeAttr) {
5848
+ const sc = this.ensure(".c-legend__size", () => { const el = document.createElement("div"); el.className = "c-legend__size"; return el; });
5849
+ sc.textContent = sizeAttr;
5850
+ } else {
5851
+ const sc = this.querySelector(".c-legend__size");
5852
+ if (sc) sc.remove();
5853
+ }
5854
+ // classification line
5855
+ const classification = this.getAttribute("classification");
5856
+ if (classification) {
5857
+ const c = this.ensure(".c-legend__classification", () => { const el = document.createElement("div"); el.className = "c-legend__classification"; return el; });
5858
+ c.textContent = classification;
5859
+ } else {
5860
+ const c = this.querySelector(".c-legend__classification");
5861
+ if (c) c.remove();
5862
+ }
5863
+ // data table (collapsible)
5864
+ const tableAttr = this.getAttribute("table");
5865
+ if (tableAttr) {
5866
+ let parsed = null;
5867
+ try { parsed = JSON.parse(tableAttr); } catch (e) { parsed = null; }
5868
+ if (Array.isArray(parsed)) {
5869
+ let det = this.querySelector(".c-legend__table-wrap");
5870
+ if (!det) { det = document.createElement("details"); det.className = "c-legend__table-wrap"; this.appendChild(det); }
5871
+ det.innerHTML = "";
5872
+ const sum = document.createElement("summary"); sum.textContent = "Data table"; det.appendChild(sum);
5873
+ const tbl = document.createElement("table"); tbl.className = "c-legend__table";
5874
+ const tbody = document.createElement("tbody");
5875
+ parsed.forEach((row) => {
5876
+ const tr = document.createElement("tr");
5877
+ const cells = Array.isArray(row) ? row : [row.label ?? row.key ?? "", row.value ?? ""];
5878
+ cells.forEach((cell) => { const td = document.createElement("td"); td.textContent = cell; tr.appendChild(td); });
5879
+ tbody.appendChild(tr);
5880
+ });
5881
+ tbl.appendChild(tbody);
5882
+ det.appendChild(tbl);
5883
+ }
5884
+ } else {
5885
+ const det = this.querySelector(".c-legend__table-wrap");
5886
+ if (det) det.remove();
5887
+ }
5888
+ // size variant on glyphs
5889
+ if (items) {
5890
+ // apply size to glyphs already rendered? handled below via re-render not needed
5891
+ }
5892
+ const method = this.getAttribute("method");
5800
5893
  if (method) {
5801
5894
  const m = this.ensure(".c-legend__method", () => { const el = document.createElement("div"); el.className = "c-legend__method"; return el; });
5802
5895
  m.textContent = method;
@@ -5812,14 +5905,34 @@ class ContourLegend extends ContourBase {
5812
5905
  const n = this.querySelector(".c-legend__norm");
5813
5906
  if (n) n.remove();
5814
5907
  }
5815
- const ramp = this.getAttribute("ramp");
5816
- if (ramp) {
5817
- const r = this.ensure(".c-legend__ramp", () => { const el = document.createElement("div"); el.className = "c-legend__ramp"; return el; });
5818
- r.style.background = ramp;
5819
- } else {
5820
- const r = this.querySelector(".c-legend__ramp");
5821
- if (r) r.remove();
5822
- }
5908
+ const ramp = this.getAttribute("ramp");
5909
+ if (ramp) {
5910
+ const r = this.ensure(".c-legend__ramp", () => { const el = document.createElement("div"); el.className = "c-legend__ramp"; return el; });
5911
+ r.style.background = ramp;
5912
+ // ramp routing: equal-width segments with break labels
5913
+ const breaksAttr = this.getAttribute("breaks");
5914
+ if (breaksAttr) {
5915
+ let breaks = null;
5916
+ try { breaks = JSON.parse(breaksAttr); } catch (e) { breaks = breaksAttr.split(",").map((s) => s.trim()); }
5917
+ if (Array.isArray(breaks)) {
5918
+ // remove old segments
5919
+ Array.from(r.querySelectorAll(".c-legend__ramp-segment")).forEach((n) => n.remove());
5920
+ breaks.forEach((b, i) => {
5921
+ const seg = document.createElement("span");
5922
+ seg.className = "c-legend__ramp-segment";
5923
+ seg.style.flex = "1";
5924
+ const lbl = document.createElement("span");
5925
+ lbl.className = "c-legend__ramp-break";
5926
+ lbl.textContent = String(b);
5927
+ seg.appendChild(lbl);
5928
+ r.appendChild(seg);
5929
+ });
5930
+ }
5931
+ }
5932
+ } else {
5933
+ const r = this.querySelector(".c-legend__ramp");
5934
+ if (r) r.remove();
5935
+ }
5823
5936
  const scale = this.getAttribute("scale");
5824
5937
  if (scale) {
5825
5938
  const sc = this.ensure(".c-legend__scale", () => { const el = document.createElement("div"); el.className = "c-legend__scale"; return el; });
@@ -7548,72 +7661,130 @@ class ContourField extends ContourBase {
7548
7661
  };
7549
7662
  define("contour-field", ContourField);
7550
7663
  class ContourRange extends ContourBase {
7551
- static get observed() { return ["min", "max", "value", "label"]; }
7664
+ static get observed() { return ["min", "max", "value", "low", "high", "range", "sparkline", "label"]; }
7552
7665
  static get formAssociated() { return true; }
7553
7666
  static get properties() { return { min: { attribute: "min" }, max: { attribute: "max" }, value: { attribute: "value" }, label: { attribute: "label" } }; }
7554
- render() {
7555
- this.classList.add("c-range");
7556
- const input = this.ensure("input", () => { const el = document.createElement("input"); el.type = "range"; return el; });
7557
- input.type = "range";
7558
- input.className = "c-range";
7559
- input.min = this.getAttribute("min") || "0";
7560
- input.max = this.getAttribute("max") || "100";
7561
- const attrVal = this.getAttribute("value") || "50";
7562
- if (this._rangeUserValue !== null && this._rangeAttrAtDirty === (this.getAttribute("value") || "50")) {
7563
- input.value = this._rangeUserValue;
7564
- } else {
7565
- input.value = attrVal;
7566
- this._rangeUserValue = null;
7567
- this._rangeAttrAtDirty = null;
7568
- }
7569
- const label = this.getAttribute("label");
7570
- if (label) input.setAttribute("aria-label", label);
7571
- else if (!input.hasAttribute("aria-label")) input.setAttribute("aria-label", "Range");
7572
- // Fill the track to the left of the thumb.
7573
- const updateFill = () => {
7574
- const min = Number(input.min) || 0;
7575
- const max = Number(input.max) || 100;
7576
- const val = Number(input.value) || 0;
7577
- const pct = max > min ? ((val - min) / (max - min)) * 100 : 0;
7578
- input.style.setProperty("--fill", pct + "%");
7579
- };
7580
- updateFill();
7581
- if (!input._fillWired) {
7582
- input._fillWired = true;
7583
- input.addEventListener("input", updateFill);
7584
- }
7585
- }
7667
+ render() {
7668
+ this.classList.add("c-range");
7669
+ const min = this.getAttribute("min") || "0";
7670
+ const max = this.getAttribute("max") || "100";
7671
+ const rangeMode = this.hasAttribute("range") || this.hasAttribute("low") || this.hasAttribute("high");
7672
+ // sparkline canvas
7673
+ const spark = this.getAttribute("sparkline");
7674
+ if (spark) {
7675
+ let canvas = this.querySelector(".c-range__sparkline");
7676
+ if (!canvas) { canvas = document.createElement("canvas"); canvas.className = "c-range__sparkline"; canvas.setAttribute("part", "sparkline-canvas"); this.insertBefore(canvas, this.firstChild); }
7677
+ } else {
7678
+ const c = this.querySelector(".c-range__sparkline");
7679
+ if (c) c.remove();
7680
+ }
7681
+ if (rangeMode) {
7682
+ // remove single input if present
7683
+ const single = this.querySelector("input.c-range:not(.c-range__low):not(.c-range__high)");
7684
+ // keep generic input? We'll use two named inputs
7685
+ let lowInput = this.querySelector("input.c-range__low");
7686
+ if (!lowInput) { lowInput = document.createElement("input"); lowInput.type = "range"; lowInput.className = "c-range c-range__low"; this.appendChild(lowInput); }
7687
+ let highInput = this.querySelector("input.c-range__high");
7688
+ if (!highInput) { highInput = document.createElement("input"); highInput.type = "range"; highInput.className = "c-range c-range__high"; this.appendChild(highInput); }
7689
+ lowInput.min = min; lowInput.max = max;
7690
+ highInput.min = min; highInput.max = max;
7691
+ const lowVal = this.getAttribute("low") || min;
7692
+ const highVal = this.getAttribute("high") || max;
7693
+ if (this._rangeUserLow !== null && this._rangeAttrLowAtDirty === (this.getAttribute("low") || min)) lowInput.value = this._rangeUserLow;
7694
+ else { lowInput.value = lowVal; this._rangeUserLow = null; this._rangeAttrLowAtDirty = null; }
7695
+ if (this._rangeUserHigh !== null && this._rangeAttrHighAtDirty === (this.getAttribute("high") || max)) highInput.value = this._rangeUserHigh;
7696
+ else { highInput.value = highVal; this._rangeUserHigh = null; this._rangeAttrHighAtDirty = null; }
7697
+ const label = this.getAttribute("label");
7698
+ if (label) { lowInput.setAttribute("aria-label", label + " low"); highInput.setAttribute("aria-label", label + " high"); }
7699
+ } else {
7700
+ // remove dual inputs
7701
+ Array.from(this.querySelectorAll("input.c-range__low, input.c-range__high")).forEach((n) => n.remove());
7702
+ const input = this.ensure("input.c-range", () => { const el = document.createElement("input"); el.type = "range"; return el; });
7703
+ // ensure class
7704
+ input.className = "c-range";
7705
+ input.type = "range";
7706
+ input.min = min;
7707
+ input.max = max;
7708
+ const attrVal = this.getAttribute("value") || "50";
7709
+ if (this._rangeUserValue !== null && this._rangeAttrAtDirty === (this.getAttribute("value") || "50")) {
7710
+ input.value = this._rangeUserValue;
7711
+ } else {
7712
+ input.value = attrVal;
7713
+ this._rangeUserValue = null;
7714
+ this._rangeAttrAtDirty = null;
7715
+ }
7716
+ const label = this.getAttribute("label");
7717
+ if (label) input.setAttribute("aria-label", label);
7718
+ else if (!input.hasAttribute("aria-label")) input.setAttribute("aria-label", "Range");
7719
+ const updateFill = () => {
7720
+ const mn = Number(input.min) || 0;
7721
+ const mx = Number(input.max) || 100;
7722
+ const val = Number(input.value) || 0;
7723
+ const pct = mx > mn ? ((val - mn) / (mx - mn)) * 100 : 0;
7724
+ input.style.setProperty("--fill", pct + "%");
7725
+ };
7726
+ updateFill();
7727
+ if (!input._fillWired) {
7728
+ input._fillWired = true;
7729
+ input.addEventListener("input", updateFill);
7730
+ }
7731
+ }
7732
+ }
7586
7733
  }
7587
7734
  // patch enhance onto ContourRange
7588
7735
  const _origRangeRender = ContourRange.prototype.render;
7589
- ContourRange.prototype.attributeChangedCallback = function(name, oldValue, newValue) {
7590
- if (name === "value") { this._rangeUserValue = null; this._rangeAttrAtDirty = null; }
7591
- return ContourBase.prototype.attributeChangedCallback.call(this, name, oldValue, newValue);
7592
- };
7593
- ContourRange.prototype.enhance = function() {
7594
- if (this._wiredRange) return;
7595
- this._wiredRange = true;
7596
- const sync = () => {
7597
- const input = this.querySelector("input");
7598
- if (!input || !this._internals) return;
7599
- this._internals.setFormValue(input.value);
7600
- };
7601
- this.addEventListener("input", (e) => {
7602
- const input = this.querySelector("input");
7603
- if (!input || e.target !== input) return;
7604
- this._rangeUserValue = input.value;
7605
- this._rangeAttrAtDirty = this.getAttribute("value") || "50";
7606
- sync();
7607
- this._emitForm("contour:input");
7608
- });
7609
- this.addEventListener("change", (e) => {
7610
- const input = this.querySelector("input");
7611
- if (!input || e.target !== input) return;
7612
- sync();
7613
- this._emitForm("contour:change");
7614
- });
7615
- sync();
7616
- };
7736
+ ContourRange.prototype.attributeChangedCallback = function(name, oldValue, newValue) {
7737
+ if (name === "value") { this._rangeUserValue = null; this._rangeAttrAtDirty = null; }
7738
+ if (name === "low") { this._rangeUserLow = null; this._rangeAttrLowAtDirty = null; }
7739
+ if (name === "high") { this._rangeUserHigh = null; this._rangeAttrHighAtDirty = null; }
7740
+ return ContourBase.prototype.attributeChangedCallback.call(this, name, oldValue, newValue);
7741
+ };
7742
+ ContourRange.prototype.enhance = function() {
7743
+ if (this._wiredRange) return;
7744
+ this._wiredRange = true;
7745
+ const sync = () => {
7746
+ const low = this.querySelector("input.c-range__low");
7747
+ const high = this.querySelector("input.c-range__high");
7748
+ const single = this.querySelector("input.c-range:not(.c-range__low):not(.c-range__high)");
7749
+ if (this._internals) {
7750
+ if (low && high) this._internals.setFormValue(low.value + "," + high.value);
7751
+ else if (single) this._internals.setFormValue(single.value);
7752
+ }
7753
+ };
7754
+ this.addEventListener("input", (e) => {
7755
+ const low = this.querySelector("input.c-range__low");
7756
+ const high = this.querySelector("input.c-range__high");
7757
+ const single = this.querySelector("input.c-range:not(.c-range__low):not(.c-range__high)");
7758
+ if (low && high && (e.target === low || e.target === high)) {
7759
+ this._rangeUserLow = low.value;
7760
+ this._rangeUserHigh = high.value;
7761
+ this._rangeAttrLowAtDirty = this.getAttribute("low") || (this.getAttribute("min") || "0");
7762
+ this._rangeAttrHighAtDirty = this.getAttribute("high") || (this.getAttribute("max") || "100");
7763
+ sync();
7764
+ this._emitForm("contour:input", { low: Number(low.value), high: Number(high.value) });
7765
+ this.dispatchEvent(new CustomEvent("contour:change", { bubbles: true, composed: true, detail: { low: Number(low.value), high: Number(high.value) } }));
7766
+ } else if (single && e.target === single) {
7767
+ this._rangeUserValue = single.value;
7768
+ this._rangeAttrAtDirty = this.getAttribute("value") || "50";
7769
+ sync();
7770
+ this._emitForm("contour:input");
7771
+ }
7772
+ });
7773
+ this.addEventListener("change", (e) => {
7774
+ const low = this.querySelector("input.c-range__low");
7775
+ const high = this.querySelector("input.c-range__high");
7776
+ const single = this.querySelector("input.c-range:not(.c-range__low):not(.c-range__high)");
7777
+ if (low && high && (e.target === low || e.target === high)) {
7778
+ sync();
7779
+ this._emitForm("contour:change", { low: Number(low.value), high: Number(high.value) });
7780
+ this.dispatchEvent(new CustomEvent("contour:change", { bubbles: true, composed: true, detail: { low: Number(low.value), high: Number(high.value) } }));
7781
+ } else if (single && e.target === single) {
7782
+ sync();
7783
+ this._emitForm("contour:change");
7784
+ }
7785
+ });
7786
+ sync();
7787
+ };
7617
7788
  define("contour-range", ContourRange);
7618
7789
  class ContourSwitch extends ContourBase {
7619
7790
  static get observed() { return ["label", "required", "checked"]; }
@@ -8917,7 +9088,7 @@ class ContourCoordinate extends ContourBase {
8917
9088
  }
8918
9089
  define("contour-coordinate", ContourCoordinate);
8919
9090
  class ContourLayerPanel extends ContourBase {
8920
- static get observed() { return ["label", "items", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton"]; }
9091
+ static get observed() { return ["label", "items", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton", "allow-rename", "allow-remove", "allow-duplicate", "allow-zoom"]; }
8921
9092
  static get properties() { return { label: { attribute: "label" }, items: { attribute: "items" }, src: { attribute: "src" } }; }
8922
9093
  render() {
8923
9094
  this.classList.add("c-layer-panel");
@@ -8938,19 +9109,24 @@ class ContourLayerPanel extends ContourBase {
8938
9109
  const authoredLayerItems = Array.from(this.querySelectorAll(":scope > .c-layer-panel__item"));
8939
9110
  // Preserve user-toggled visibility across re-renders (B3-09): a src
8940
9111
  // reload must not re-check a layer the user un-checked.
8941
- const savedVisibility = new Map();
8942
- this.querySelectorAll(".c-layer-panel__item").forEach((el) => {
8943
- const nm = el.querySelector(".c-layer-panel__name");
8944
- const tg = el.querySelector(".c-layer-panel__toggle");
8945
- if (nm && tg) savedVisibility.set(nm.textContent, tg.checked);
8946
- });
9112
+ const savedVisibility = new Map();
9113
+ this.querySelectorAll(".c-layer-panel__item").forEach((el) => {
9114
+ const nm = el.querySelector(".c-layer-panel__name");
9115
+ const tg = el.querySelector(".c-layer-panel__toggle");
9116
+ if (nm && tg) {
9117
+ const v = tg.hasAttribute("aria-pressed") ? tg.getAttribute("aria-pressed") === "true" : !!tg.checked;
9118
+ savedVisibility.set(nm.textContent, v);
9119
+ }
9120
+ });
8947
9121
  let parsed = null;
8948
9122
  if (authoredLayerItems.length) {
8949
- parsed = authoredLayerItems.map((el) => {
8950
- const nm = el.querySelector(".c-layer-panel__name");
8951
- const tg = el.querySelector(".c-layer-panel__toggle");
8952
- return { name: nm ? nm.textContent : "", visible: tg ? tg.checked : true };
8953
- });
9123
+ parsed = authoredLayerItems.map((el) => {
9124
+ const nm = el.querySelector(".c-layer-panel__name");
9125
+ const tg = el.querySelector(".c-layer-panel__toggle");
9126
+ const visible = tg ? (tg.hasAttribute("aria-pressed") ? tg.getAttribute("aria-pressed") === "true" : !!tg.checked) : true;
9127
+ const cap = el.querySelector(".c-layer-panel__caption");
9128
+ return { name: nm ? nm.textContent : "", visible, caption: cap ? cap.textContent : (el.dataset.caption || undefined) };
9129
+ });
8954
9130
  authoredLayerItems.forEach((el) => el.remove());
8955
9131
  } else if (items) {
8956
9132
  try {
@@ -8959,21 +9135,31 @@ class ContourLayerPanel extends ContourBase {
8959
9135
  } catch (e) { /* keep existing */ }
8960
9136
  }
8961
9137
  if (parsed) { parsed.forEach((it) => {
8962
- const name = typeof it === "string" ? it : (it.name || it.label || "");
8963
- const item = document.createElement("div");
8964
- item.className = "c-layer-panel__item" + (it.dragging ? " c-layer-panel__item--dragging" : "");
8965
- const toggle = document.createElement("input");
8966
- toggle.type = "checkbox";
8967
- toggle.className = "c-layer-panel__toggle";
8968
- toggle.setAttribute("aria-label", "Toggle " + (name || "layer"));
8969
- if (savedVisibility.has(name)) toggle.checked = savedVisibility.get(name);
8970
- else if (typeof it === "object" && it.visible !== false) toggle.checked = true;
9138
+ const name = typeof it === "string" ? it : (it.name || it.label || "");
9139
+ const caption = (typeof it === "object" && it) ? (it.caption || it.subtitle || "") : "";
9140
+ const item = document.createElement("div");
9141
+ item.className = "c-layer-panel__item" + (it.dragging ? " c-layer-panel__item--dragging" : "");
9142
+ const toggle = document.createElement("button");
9143
+ toggle.type = "button";
9144
+ toggle.className = "c-layer-panel__toggle";
9145
+ toggle.setAttribute("part", "visibility-toggle");
9146
+ toggle.setAttribute("aria-label", "Toggle " + (name || "layer"));
9147
+ const isVisible = savedVisibility.has(name) ? savedVisibility.get(name) : (typeof it === "object" && it.visible !== false);
9148
+ toggle.setAttribute("aria-pressed", String(!!isVisible));
9149
+ toggle.checked = !!isVisible;
9150
+ toggle.textContent = isVisible ? "●" : "○";
8971
9151
  item.appendChild(toggle);
8972
9152
  const nm = document.createElement("span");
8973
9153
  nm.className = "c-layer-panel__name";
8974
9154
  nm.textContent = name;
8975
9155
  item.appendChild(nm);
8976
- const opacity = document.createElement("input");
9156
+ if (caption) {
9157
+ const cap = document.createElement("span");
9158
+ cap.className = "c-layer-panel__caption";
9159
+ cap.textContent = caption;
9160
+ item.appendChild(cap);
9161
+ }
9162
+ const opacity = document.createElement("input");
8977
9163
  opacity.type = "range";
8978
9164
  opacity.className = "c-layer-panel__opacity";
8979
9165
  opacity.min = "0";
@@ -8982,24 +9168,38 @@ class ContourLayerPanel extends ContourBase {
8982
9168
  opacity.value = (typeof it === "object" && it.opacity != null) ? it.opacity : "100";
8983
9169
  item.appendChild(opacity);
8984
9170
  // rename input (hidden by default, toggled via button)
9171
+ if (this.getAttribute("allow-rename") !== "false") {
8985
9172
  const renameBtn = document.createElement("button");
8986
9173
  renameBtn.type = "button";
8987
9174
  renameBtn.className = "c-layer-panel__rename";
8988
9175
  renameBtn.textContent = "Rename";
8989
9176
  renameBtn.setAttribute("aria-label", "Rename " + (name || "layer"));
8990
9177
  item.appendChild(renameBtn);
9178
+ }
9179
+ if (this.getAttribute("allow-duplicate") !== "false") {
8991
9180
  const dupBtn = document.createElement("button");
8992
9181
  dupBtn.type = "button";
8993
9182
  dupBtn.className = "c-layer-panel__duplicate";
8994
9183
  dupBtn.textContent = "Duplicate";
8995
9184
  dupBtn.setAttribute("aria-label", "Duplicate " + (name || "layer"));
8996
9185
  item.appendChild(dupBtn);
9186
+ }
9187
+ if (this.getAttribute("allow-zoom") !== "false") {
8997
9188
  const zoomBtn = document.createElement("button");
8998
9189
  zoomBtn.type = "button";
8999
9190
  zoomBtn.className = "c-layer-panel__zoom";
9000
9191
  zoomBtn.textContent = "Zoom";
9001
9192
  zoomBtn.setAttribute("aria-label", "Zoom to " + (name || "layer"));
9002
9193
  item.appendChild(zoomBtn);
9194
+ }
9195
+ if (this.getAttribute("allow-remove") !== "false") {
9196
+ const removeBtn = document.createElement("button");
9197
+ removeBtn.type = "button";
9198
+ removeBtn.className = "c-layer-panel__remove";
9199
+ removeBtn.textContent = "✕";
9200
+ removeBtn.setAttribute("aria-label", "Remove " + (name || "layer"));
9201
+ item.appendChild(removeBtn);
9202
+ }
9003
9203
  const projSel = document.createElement("select");
9004
9204
  projSel.className = "c-layer-panel__projection";
9005
9205
  projSel.setAttribute("aria-label", "Projection of " + (name || "layer"));
@@ -9018,39 +9218,79 @@ class ContourLayerPanel extends ContourBase {
9018
9218
  this._wiredLayerPanel = true;
9019
9219
  // The panel's two controls (visibility toggle, opacity range) are rebuilt
9020
9220
  // on every render, so both keep the host-delegated pattern (rule 12).
9021
- this.addEventListener("change", (e) => {
9022
- const item = e.target && e.target.closest ? e.target.closest(".c-layer-panel__item") : null;
9023
- if (!item || !this.contains(item)) return;
9024
- const name = item.querySelector(".c-layer-panel__name")?.textContent || "";
9025
- if (e.target.classList.contains("c-layer-panel__toggle")) {
9026
- this.dispatchEvent(new CustomEvent("contour:layer-visibility", { bubbles: true, composed: true, detail: { name, visible: e.target.checked } }));
9027
- } else if (e.target.classList.contains("c-layer-panel__opacity")) {
9028
- this.dispatchEvent(new CustomEvent("contour:layer-opacity", { bubbles: true, composed: true, detail: { name, opacity: Number(e.target.value) } }));
9029
- } else if (e.target.classList.contains("c-layer-panel__projection")) {
9030
- this.dispatchEvent(new CustomEvent("contour:layer-projection", { bubbles: true, composed: true, detail: { name, projection: e.target.value } }));
9031
- }
9032
- });
9033
- this.addEventListener("click", (e) => {
9034
- const btn = e.target && e.target.closest ? e.target.closest("button") : null;
9035
- if (!btn || !this.contains(btn)) return;
9036
- const item = btn.closest(".c-layer-panel__item");
9037
- if (!item) return;
9038
- const name = item.querySelector(".c-layer-panel__name")?.textContent || "";
9039
- if (btn.classList.contains("c-layer-panel__rename")) {
9040
- const newName = prompt("Rename layer", name);
9041
- const trimmed = newName ? newName.trim() : "";
9042
- if (trimmed && trimmed !== name) {
9043
- const nm = item.querySelector(".c-layer-panel__name");
9044
- if (nm) nm.textContent = trimmed;
9045
- this.dispatchEvent(new CustomEvent("contour:layer-rename", { bubbles: true, composed: true, detail: { name, newName: trimmed } }));
9221
+ this.addEventListener("change", (e) => {
9222
+ const item = e.target && e.target.closest ? e.target.closest(".c-layer-panel__item") : null;
9223
+ if (!item || !this.contains(item)) return;
9224
+ const name = item.querySelector(".c-layer-panel__name")?.textContent || "";
9225
+ if (e.target.classList.contains("c-layer-panel__toggle")) {
9226
+ const now = (typeof e.target.checked === "boolean") ? e.target.checked : (e.target.getAttribute("aria-pressed") !== "true");
9227
+ e.target.checked = now;
9228
+ e.target.setAttribute("aria-pressed", String(now));
9229
+ e.target.textContent = now ? "●" : "○";
9230
+ this.dispatchEvent(new CustomEvent("contour:layer-visibility", { bubbles: true, composed: true, detail: { name, visible: now } }));
9231
+ } else if (e.target.classList.contains("c-layer-panel__opacity")) {
9232
+ this.dispatchEvent(new CustomEvent("contour:layer-opacity", { bubbles: true, composed: true, detail: { name, opacity: Number(e.target.value) } }));
9233
+ } else if (e.target.classList.contains("c-layer-panel__projection")) {
9234
+ this.dispatchEvent(new CustomEvent("contour:layer-projection", { bubbles: true, composed: true, detail: { name, projection: e.target.value } }));
9235
+ }
9236
+ });
9237
+ this.addEventListener("click", (e) => {
9238
+ const btn = e.target && e.target.closest ? e.target.closest("button") : null;
9239
+ if (!btn || !this.contains(btn)) return;
9240
+ const item = btn.closest(".c-layer-panel__item");
9241
+ if (btn.classList.contains("c-layer-panel__toggle")) {
9242
+ if (!item) return;
9243
+ const name = item.querySelector(".c-layer-panel__name")?.textContent || "";
9244
+ const now = btn.getAttribute("aria-pressed") !== "true";
9245
+ btn.setAttribute("aria-pressed", String(now));
9246
+ btn.checked = now;
9247
+ btn.textContent = now ? "●" : "○";
9248
+ this.dispatchEvent(new CustomEvent("contour:layer-visibility", { bubbles: true, composed: true, detail: { name, visible: now } }));
9249
+ return;
9250
+ }
9251
+ if (!item) return;
9252
+ const name = item.querySelector(".c-layer-panel__name")?.textContent || "";
9253
+ if (btn.classList.contains("c-layer-panel__rename")) {
9254
+ const newName = prompt("Rename layer", name);
9255
+ const trimmed = newName ? newName.trim() : "";
9256
+ if (trimmed && trimmed !== name) {
9257
+ const nm = item.querySelector(".c-layer-panel__name");
9258
+ if (nm) nm.textContent = trimmed;
9259
+ this.dispatchEvent(new CustomEvent("contour:layer-rename", { bubbles: true, composed: true, detail: { name, newName: trimmed } }));
9260
+ }
9261
+ } else if (btn.classList.contains("c-layer-panel__duplicate")) {
9262
+ this.dispatchEvent(new CustomEvent("contour:layer-duplicate", { bubbles: true, composed: true, detail: { name } }));
9263
+ } else if (btn.classList.contains("c-layer-panel__zoom")) {
9264
+ this.dispatchEvent(new CustomEvent("contour:layer-zoom", { bubbles: true, composed: true, detail: { name } }));
9265
+ } else if (btn.classList.contains("c-layer-panel__remove")) {
9266
+ this.dispatchEvent(new CustomEvent("contour:layer-remove", { bubbles: true, composed: true, detail: { name } }));
9267
+ }
9268
+ });
9269
+ this.addEventListener("keydown", (e) => {
9270
+ if (e.target && e.target.classList && e.target.classList.contains("c-layer-panel__toggle") && (e.key === "Enter" || e.key === " ")) {
9271
+ e.preventDefault();
9272
+ e.target.click();
9273
+ return;
9046
9274
  }
9047
- } else if (btn.classList.contains("c-layer-panel__duplicate")) {
9048
- this.dispatchEvent(new CustomEvent("contour:layer-duplicate", { bubbles: true, composed: true, detail: { name } }));
9049
- } else if (btn.classList.contains("c-layer-panel__zoom")) {
9050
- this.dispatchEvent(new CustomEvent("contour:layer-zoom", { bubbles: true, composed: true, detail: { name } }));
9051
- }
9052
- });
9053
- }
9275
+ const item = e.target && e.target.closest ? e.target.closest(".c-layer-panel__item") : null;
9276
+ if (!item || !this.contains(item)) return;
9277
+ if (!(e.altKey) || (e.key !== "ArrowUp" && e.key !== "ArrowDown")) return;
9278
+ e.preventDefault();
9279
+ const items = Array.from(this.querySelectorAll(".c-layer-panel__item"));
9280
+ const idx = items.indexOf(item);
9281
+ if (idx < 0) return;
9282
+ const dir = e.key === "ArrowUp" ? -1 : 1;
9283
+ const newIdx = idx + dir;
9284
+ if (newIdx < 0 || newIdx >= items.length) return;
9285
+ item.classList.add("c-layer-panel__item--dragging");
9286
+ if (dir < 0) this.insertBefore(item, items[newIdx]);
9287
+ else this.insertBefore(items[newIdx], item);
9288
+ item.focus();
9289
+ setTimeout(() => item.classList.remove("c-layer-panel__item--dragging"), 200);
9290
+ const layerIds = Array.from(this.querySelectorAll(".c-layer-panel__item")).map((el) => el.querySelector(".c-layer-panel__name")?.textContent || "");
9291
+ this.dispatchEvent(new CustomEvent("contour:layer-reorder", { bubbles: true, composed: true, detail: { layerIds } }));
9292
+ });
9293
+ }
9054
9294
  }
9055
9295
  define("contour-layer-panel", ContourLayerPanel);
9056
9296
  class ContourTimeSlider extends ContourBase {
@@ -10665,7 +10905,7 @@ class ContourTocFull extends ContourBase {
10665
10905
  }
10666
10906
  define("contour-toc", ContourTocFull);
10667
10907
  class ContourFilterBar extends ContourBase {
10668
- static get observed() { return ["label", "divider", "items", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton"]; }
10908
+ static get observed() { return ["label", "divider", "items", "input", "placeholder", "mode", "modes", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton"]; }
10669
10909
  static get properties() { return { label: { attribute: "label" }, divider: { attribute: "divider" }, items: { attribute: "items" }, src: { attribute: "src" } }; }
10670
10910
  render() {
10671
10911
  this.classList.add("c-filter-bar");
@@ -10680,13 +10920,48 @@ class ContourFilterBar extends ContourBase {
10680
10920
  const l = this.querySelector(".c-filter-bar__label");
10681
10921
  if (l) l.remove();
10682
10922
  }
10683
- if (this.hasAttribute("divider")) {
10684
- this.ensure(".c-filter-bar__divider", () => { const el = document.createElement("span"); el.className = "c-filter-bar__divider"; return el; });
10685
- } else {
10686
- const d = this.querySelector(".c-filter-bar__divider");
10687
- if (d) d.remove();
10688
- }
10689
- // Render filter pills from items.
10923
+ if (this.hasAttribute("divider")) {
10924
+ this.ensure(".c-filter-bar__divider", () => { const el = document.createElement("span"); el.className = "c-filter-bar__divider"; return el; });
10925
+ } else {
10926
+ const d = this.querySelector(".c-filter-bar__divider");
10927
+ if (d) d.remove();
10928
+ }
10929
+ // Text input support
10930
+ if (this.hasAttribute("input") || this.hasAttribute("placeholder")) {
10931
+ let inp = this.querySelector(".c-filter-bar__input");
10932
+ if (!inp) { inp = document.createElement("input"); inp.type = "search"; inp.className = "c-filter-bar__input"; this.appendChild(inp); }
10933
+ const ph = this.getAttribute("placeholder");
10934
+ if (ph) inp.setAttribute("placeholder", ph);
10935
+ } else {
10936
+ const inp = this.querySelector(".c-filter-bar__input");
10937
+ if (inp) inp.remove();
10938
+ }
10939
+ // Mode toolbar
10940
+ const modesAttr = this.getAttribute("modes");
10941
+ let modes = null;
10942
+ if (modesAttr) { try { modes = JSON.parse(modesAttr); } catch (e) { modes = modesAttr.split(",").map((s) => s.trim()); } }
10943
+ if (modes || this.hasAttribute("mode")) {
10944
+ let bar = this.querySelector(".c-filter-bar__modes");
10945
+ if (!bar) { bar = document.createElement("div"); bar.className = "c-filter-bar__modes"; this.appendChild(bar); }
10946
+ bar.innerHTML = "";
10947
+ const current = this.getAttribute("mode");
10948
+ const list = Array.isArray(modes) ? modes : ["draw", "erase", "select"];
10949
+ list.forEach((m) => {
10950
+ const name = typeof m === "string" ? m : (m.label || m.value || m);
10951
+ const val = typeof m === "string" ? m : (m.value || m.label || m);
10952
+ const btn = document.createElement("button");
10953
+ btn.type = "button";
10954
+ btn.className = "c-filter-bar__mode";
10955
+ btn.textContent = name;
10956
+ btn.dataset.mode = val;
10957
+ if (current && current === val) btn.setAttribute("aria-pressed", "true");
10958
+ bar.appendChild(btn);
10959
+ });
10960
+ } else {
10961
+ const bar = this.querySelector(".c-filter-bar__modes");
10962
+ if (bar) bar.remove();
10963
+ }
10964
+ // Render filter pills from items.
10690
10965
  Array.from(this.querySelectorAll(".c-filter-pill")).forEach((n) => n.remove());
10691
10966
  const items = remoteData(this, "items");
10692
10967
  let parsed = null;
@@ -10710,9 +10985,29 @@ class ContourFilterBar extends ContourBase {
10710
10985
  }
10711
10986
  if (!parsed && !label) renderEmpty(this, "filter-bar");
10712
10987
  }
10713
- enhance() {
10714
- wireRemovable(this);
10715
- }
10988
+ enhance() {
10989
+ wireRemovable(this);
10990
+ if (this._wiredFilterBar) return;
10991
+ this._wiredFilterBar = true;
10992
+ this.addEventListener("click", (e) => {
10993
+ const btn = e.target && e.target.closest ? e.target.closest(".c-filter-bar__mode") : null;
10994
+ if (!btn || !this.contains(btn)) return;
10995
+ const mode = btn.dataset.mode || btn.textContent.trim();
10996
+ Array.from(this.querySelectorAll(".c-filter-bar__mode")).forEach((b) => b.setAttribute("aria-pressed", String(b === btn)));
10997
+ this.dispatchEvent(new CustomEvent("contour:mode-change", { bubbles: true, composed: true, detail: { mode } }));
10998
+ });
10999
+ // text input
11000
+ const inp = this.querySelector(".c-filter-bar__input");
11001
+ if (inp && !inp._wiredFilterInput) {
11002
+ inp._wiredFilterInput = true;
11003
+ inp.addEventListener("input", () => {
11004
+ this.dispatchEvent(new CustomEvent("contour:input", { bubbles: true, composed: true, detail: { value: inp.value } }));
11005
+ });
11006
+ inp.addEventListener("change", () => {
11007
+ this.dispatchEvent(new CustomEvent("contour:change", { bubbles: true, composed: true, detail: { value: inp.value } }));
11008
+ });
11009
+ }
11010
+ }
10716
11011
  }
10717
11012
  define("contour-filter-bar", ContourFilterBar);
10718
11013
  class ContourCommand extends ContourBase {
@@ -11881,7 +12176,7 @@ class ContourStyleSwitcher extends ContourBase {
11881
12176
  define("contour-style-switcher", ContourStyleSwitcher);
11882
12177
 
11883
12178
  class ContourStylePanel extends ContourBase {
11884
- static get observed() { return ["title", "layers", "classification", "palette", "breaks", "opacity"]; }
12179
+ static get observed() { return ["title", "layers", "layer", "single", "classification", "palette", "breaks", "opacity", "n", "colors"]; }
11885
12180
  static get properties() { return { title: { attribute: "title" }, layers: { attribute: "layers" }, classification: { attribute: "classification" }, palette: { attribute: "palette" }, breaks: { attribute: "breaks" }, opacity: { attribute: "opacity" } }; }
11886
12181
  render() {
11887
12182
  this.classList.add("c-style-panel");
@@ -11890,7 +12185,46 @@ class ContourStylePanel extends ContourBase {
11890
12185
  const t = this.ensure(".c-style-panel__title", () => { const el = document.createElement("div"); el.className = "c-style-panel__title"; return el; });
11891
12186
  t.textContent = title;
11892
12187
  }
11893
- const layers = this.getAttribute("layers");
12188
+ const singleMode = this.hasAttribute("single") || !!this.getAttribute("layer");
12189
+ if (singleMode) {
12190
+ const body = this.ensure(".c-style-panel__body", () => { const el = document.createElement("div"); el.className = "c-style-panel__body"; return el; });
12191
+ body.innerHTML = "";
12192
+ // classification method selector
12193
+ const clsLabel = document.createElement("label"); clsLabel.textContent = "Classification"; body.appendChild(clsLabel);
12194
+ const clsSel = document.createElement("select"); clsSel.className = "c-style-panel__classification";
12195
+ ["equal","quantile","jenks","manual"].forEach((m) => { const o = document.createElement("option"); o.value = m; o.textContent = m; clsSel.appendChild(o); });
12196
+ const cls = this.getAttribute("classification"); if (cls) clsSel.value = cls;
12197
+ body.appendChild(clsSel);
12198
+ // palette picker
12199
+ const pal = document.createElement("input"); pal.type = "text"; pal.className = "c-style-panel__palette"; pal.placeholder = "palette";
12200
+ const palv = this.getAttribute("palette"); if (palv) pal.value = palv;
12201
+ body.appendChild(pal);
12202
+ // n (class count)
12203
+ const nIn = document.createElement("input"); nIn.type = "number"; nIn.className = "c-style-panel__n"; nIn.min = "2"; nIn.max = "12";
12204
+ const nv = this.getAttribute("n"); if (nv) nIn.value = nv; else nIn.value = "5";
12205
+ body.appendChild(nIn);
12206
+ // opacity slider
12207
+ const op = document.createElement("input"); op.type = "range"; op.className = "c-style-panel__opacity"; op.min = "0"; op.max = "100";
12208
+ const ov = this.getAttribute("opacity"); op.value = ov != null ? ov : "100";
12209
+ body.appendChild(op);
12210
+ // breaks editor
12211
+ const breaks = document.createElement("input"); breaks.type = "text"; breaks.className = "c-style-panel__breaks"; breaks.placeholder = "breaks";
12212
+ const bv = this.getAttribute("breaks"); if (bv) breaks.value = bv;
12213
+ body.appendChild(breaks);
12214
+ // color list
12215
+ const colorsAttr = this.getAttribute("colors");
12216
+ let colors = null;
12217
+ if (colorsAttr) { try { colors = JSON.parse(colorsAttr); } catch (e) { colors = colorsAttr.split(",").map((s) => s.trim()); } }
12218
+ if (Array.isArray(colors)) {
12219
+ const list = document.createElement("div"); list.className = "c-style-panel__colors";
12220
+ colors.forEach((c) => {
12221
+ const sw = document.createElement("span"); sw.className = "c-style-panel__color"; sw.style.background = c; list.appendChild(sw);
12222
+ });
12223
+ body.appendChild(list);
12224
+ }
12225
+ return;
12226
+ }
12227
+ const layers = this.getAttribute("layers");
11894
12228
  const body = this.ensure(".c-style-panel__body", () => { const el = document.createElement("div"); el.className = "c-style-panel__body"; return el; });
11895
12229
  // Slotted content support: authored .c-style-panel__row children take
11896
12230
  // precedence over the JSON `layers` attribute.