contour-ds 1.1.1 → 1.1.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 (52) hide show
  1. package/README.md +1 -1
  2. package/dist/build-manifest.json +37 -37
  3. package/dist/contour-wc.esm.js +315 -39
  4. package/dist/contour-wc.esm.min.js +1 -1
  5. package/dist/contour-wc.js +315 -39
  6. package/dist/contour-wc.min.js +1 -1
  7. package/dist/contour.components.json +38 -18
  8. package/dist/contour.css +15 -1
  9. package/dist/contour.d.ts +1 -0
  10. package/dist/contour.min.css +1 -1
  11. package/dist/contour.themes.json +4 -1
  12. package/dist/contour.tokens.json +3 -0
  13. package/dist/docs/actions.md +1 -1
  14. package/dist/docs/affordances.md +1 -1
  15. package/dist/docs/colour.md +1 -1
  16. package/dist/docs/data.md +1 -1
  17. package/dist/docs/docs.md +1 -1
  18. package/dist/docs/feedback.md +1 -1
  19. package/dist/docs/field.md +1 -1
  20. package/dist/docs/forms.md +1 -1
  21. package/dist/docs/index.json +3 -3
  22. package/dist/docs/install.md +1 -1
  23. package/dist/docs/landing.md +1 -1
  24. package/dist/docs/mapengine.md +1 -1
  25. package/dist/docs/motion.md +1 -1
  26. package/dist/docs/navigation.md +1 -1
  27. package/dist/docs/overlays.md +1 -1
  28. package/dist/docs/overview.md +1 -1
  29. package/dist/docs/patterns.md +1 -1
  30. package/dist/docs/playground.md +1 -1
  31. package/dist/docs/principles.md +1 -1
  32. package/dist/docs/recipes.md +1 -1
  33. package/dist/docs/space.md +1 -1
  34. package/dist/docs/status.md +1 -1
  35. package/dist/docs/surfaces.md +1 -1
  36. package/dist/docs/theming.md +1 -1
  37. package/dist/docs/type.md +1 -1
  38. package/dist/docs/webcomponents.md +1 -1
  39. package/dist/registry/items/contour-core.json +2 -2
  40. package/dist/registry/items/contour-data.json +2 -2
  41. package/dist/registry/items/contour-docs.json +2 -2
  42. package/dist/registry/items/contour-landing.json +2 -2
  43. package/dist/registry/registry.json +8 -8
  44. package/dist/surfaces/contour-core.min.css +1 -1
  45. package/dist/surfaces/contour-data.min.css +1 -1
  46. package/dist/surfaces/contour-docs.min.css +1 -1
  47. package/dist/surfaces/contour-landing.min.css +1 -1
  48. package/dist/wc/core.mjs +7 -0
  49. package/dist/wc/data.mjs +164 -8
  50. package/dist/wc/map.mjs +67 -15
  51. package/dist/wc/ui.mjs +77 -16
  52. package/package.json +1 -1
@@ -87,6 +87,7 @@ const CONTOUR_EVENTS = Object.freeze({
87
87
  "contour:brush-start": { payload: ["value"], composed: true },
88
88
  "contour:brush-end": { payload: ["value"], composed: true },
89
89
  "contour:change": { payload: ["name", "value", "checked"], composed: true },
90
+ "contour:clear": { payload: [], composed: true },
90
91
  "contour:close": { payload: [], composed: true },
91
92
  "contour:copy": { payload: ["text"], composed: true },
92
93
  "contour:dash-action": { payload: ["label"], composed: true },
@@ -123,7 +124,12 @@ const CONTOUR_EVENTS = Object.freeze({
123
124
  "contour:remove": { payload: ["label", "key", "layers", "value"], composed: true },
124
125
  "contour:range-change": { payload: ["value"], composed: true },
125
126
  "contour:retry": { payload: ["src"], composed: true },
127
+ "contour:loop-change": { payload: ["loop"], composed: true },
128
+ "contour:pause": { payload: [], composed: true },
129
+ "contour:play": { payload: [], composed: true },
130
+ "contour:seek": { payload: ["progress", "value"], composed: true },
126
131
  "contour:select": { payload: ["series", "index", "label", "value"], composed: true },
132
+ "contour:speed-change": { payload: ["speed"], composed: true },
127
133
  "contour:showcase-activate": { payload: ["title"], composed: true },
128
134
  "contour:step-activate": { payload: ["index", "title"], composed: true },
129
135
  "contour:step-change": { payload: ["index", "title"], composed: true },
@@ -186,6 +192,7 @@ const OBSERVED = [
186
192
  "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",
187
193
  "state", "steps", "subtitle", "summary", "src", "table", "tabs", "tag", "text", "ticks", "title", "type", "unit",
188
194
  "variant", "values", "viewport", "yes", "zoomable", "x", "y",
195
+ "caption", "current-time", "is-playing", "loop-label", "no-data-color", "property", "show-loop", "show-thumb", "show-thumb-caption", "speeds",
189
196
  ];
190
197
  function headingTag(host, fallback = "h3") {
191
198
  const v = host && host.getAttribute ? host.getAttribute("heading") : null;
@@ -5537,8 +5544,8 @@ class ContourInstrument extends ContourBase {
5537
5544
  }
5538
5545
  define("contour-instrument", ContourInstrument);
5539
5546
  class ContourBivariate extends ContourBase {
5540
- static get observed() { return ["size", "axis-x", "axis-y", "colors"]; }
5541
- static get properties() { return { size: { attribute: "size" }, axisX: { attribute: "axis-x" }, axisY: { attribute: "axis-y" }, colors: { attribute: "colors" } }; }
5547
+ static get observed() { return ["size", "axis-x", "axis-y", "colors", "selected"]; }
5548
+ static get properties() { return { size: { attribute: "size" }, axisX: { attribute: "axis-x" }, axisY: { attribute: "axis-y" }, colors: { attribute: "colors" }, selected: { attribute: "selected" } }; }
5542
5549
  render() {
5543
5550
  this.classList.add("c-bivariate");
5544
5551
  const size = Math.min(12, Math.max(1, parseInt(this.getAttribute("size") || "3", 10) || 3));
@@ -5556,6 +5563,9 @@ class ContourBivariate extends ContourBase {
5556
5563
  for (let c = 0; c < size; c++) {
5557
5564
  const cell = document.createElement("div");
5558
5565
  cell.className = "c-bivariate__cell";
5566
+ cell.setAttribute("role", "button");
5567
+ cell.setAttribute("tabindex", "0");
5568
+ cell.setAttribute("aria-label", "Cell " + c + "," + r);
5559
5569
  // Palette runs from bottom-left (low/low) to top-right (high/high):
5560
5570
  // reverse the row order so the first palette row sits at the bottom.
5561
5571
  const srcIndex = (size - 1 - r) * size + c;
@@ -5563,6 +5573,24 @@ class ContourBivariate extends ContourBase {
5563
5573
  matrix.appendChild(cell);
5564
5574
  }
5565
5575
  }
5576
+ // selected highlight
5577
+ const sel = this.getAttribute("selected");
5578
+ if (sel) {
5579
+ const parts = sel.split(",");
5580
+ const sr = parseInt(parts[0], 10);
5581
+ const sc = parseInt(parts[1], 10);
5582
+ const cells = Array.from(matrix.querySelectorAll(".c-bivariate__cell"));
5583
+ cells.forEach((cell, i) => {
5584
+ const rr = Math.floor(i / size);
5585
+ const cc = i % size;
5586
+ // matrix is row-major in DOM? cells appended row by row r then c, so index = r*size+c
5587
+ if (rr === sr && cc === sc) cell.setAttribute("data-selected", "");
5588
+ else cell.removeAttribute("data-selected");
5589
+ });
5590
+ }
5591
+ // aria-live region
5592
+ let live = this.querySelector(".c-bivariate__live");
5593
+ if (!live) { live = document.createElement("div"); live.className = "c-bivariate__live"; live.setAttribute("aria-live", "polite"); live.style.position = "absolute"; live.style.width = "1px"; live.style.height = "1px"; live.style.overflow = "hidden"; live.style.clip = "rect(0,0,0,0)"; this.appendChild(live); }
5566
5594
  }
5567
5595
  const axisX = this.getAttribute("axis-x");
5568
5596
  if (axisX) {
@@ -5581,11 +5609,47 @@ class ContourBivariate extends ContourBase {
5581
5609
  if (ay) ay.remove();
5582
5610
  }
5583
5611
  }
5612
+ enhance() {
5613
+ if (this._wiredBivariate) return;
5614
+ this._wiredBivariate = true;
5615
+ const selectCell = (cell) => {
5616
+ const matrix = this.querySelector(".c-bivariate__matrix");
5617
+ const cells = Array.from(matrix ? matrix.querySelectorAll(".c-bivariate__cell") : []);
5618
+ const idx = cells.indexOf(cell);
5619
+ if (idx < 0) return;
5620
+ const size = Math.min(12, Math.max(1, parseInt(this.getAttribute("size") || "3", 10) || 3));
5621
+ const row = Math.floor(idx / size);
5622
+ const col = idx % size;
5623
+ cells.forEach((cell, i) => {
5624
+ const rr = Math.floor(i / size);
5625
+ const cc = i % size;
5626
+ if (rr === row && cc === col) cell.setAttribute("data-selected", "");
5627
+ else cell.removeAttribute("data-selected");
5628
+ });
5629
+ this.dispatchEvent(new CustomEvent("contour:select", { detail: { row, col }, bubbles: true, composed: true }));
5630
+ };
5631
+ this.addEventListener("click", (e) => {
5632
+ const cell = e.target && e.target.closest ? e.target.closest(".c-bivariate__cell") : null;
5633
+ if (cell && this.contains(cell)) selectCell(cell);
5634
+ });
5635
+ this.addEventListener("keydown", (e) => {
5636
+ const cell = e.target && e.target.closest ? e.target.closest(".c-bivariate__cell") : null;
5637
+ if (!cell || !this.contains(cell)) return;
5638
+ if (e.key === "Enter" || e.key === " ") {
5639
+ e.preventDefault();
5640
+ selectCell(cell);
5641
+ }
5642
+ });
5643
+ }
5644
+ clear() {
5645
+ this.removeAttribute("selected");
5646
+ this.dispatchEvent(new CustomEvent("contour:clear", { bubbles: true, composed: true }));
5647
+ }
5584
5648
  }
5585
5649
  define("contour-bivariate", ContourBivariate);
5586
5650
  class ContourBivariateLegend extends ContourBase {
5587
- static get observed() { return ["size", "axis-x", "axis-y", "colors"]; }
5588
- static get properties() { return { size: { attribute: "size" }, axisX: { attribute: "axis-x" }, axisY: { attribute: "axis-y" }, colors: { attribute: "colors" } }; }
5651
+ static get observed() { return ["size", "axis-x", "axis-y", "colors", "selected"]; }
5652
+ static get properties() { return { size: { attribute: "size" }, axisX: { attribute: "axis-x" }, axisY: { attribute: "axis-y" }, colors: { attribute: "colors" }, selected: { attribute: "selected" } }; }
5589
5653
  render() {
5590
5654
  this.classList.add("c-bivariate-legend");
5591
5655
  const size = Math.min(8, Math.max(1, parseInt(this.getAttribute("size") || "3", 10) || 3));
@@ -5601,10 +5665,18 @@ class ContourBivariateLegend extends ContourBase {
5601
5665
  for (let i = 0; i < size * size; i++) {
5602
5666
  const cell = document.createElement("div");
5603
5667
  cell.className = "c-bivariate-legend__cell";
5668
+ cell.setAttribute("role", "button");
5669
+ cell.setAttribute("tabindex", "0");
5670
+ const x = i % size;
5671
+ const y = Math.floor(i / size);
5672
+ cell.setAttribute("aria-label", "Cell " + x + "," + y);
5604
5673
  if (colors[i]) cell.style.background = colors[i];
5605
5674
  else cell.style.background = "var(--chart-" + ((i % 8) + 1) + ")";
5606
5675
  matrix.appendChild(cell);
5607
5676
  }
5677
+ // aria-live
5678
+ let live = this.querySelector(".c-bivariate-legend__live");
5679
+ if (!live) { live = document.createElement("div"); live.className = "c-bivariate-legend__live"; live.setAttribute("aria-live", "polite"); live.style.position = "absolute"; live.style.width = "1px"; live.style.height = "1px"; live.style.overflow = "hidden"; live.style.clip = "rect(0,0,0,0)"; this.appendChild(live); }
5608
5680
  }
5609
5681
  const axisX = this.getAttribute("axis-x");
5610
5682
  const ax = this.querySelector(".c-bivariate-legend__axis--x");
@@ -5623,7 +5695,36 @@ class ContourBivariateLegend extends ContourBase {
5623
5695
  ay.remove();
5624
5696
  }
5625
5697
  }
5626
- enhance() {}
5698
+ enhance() {
5699
+ if (this._wiredBivLegend) return;
5700
+ this._wiredBivLegend = true;
5701
+ const selectCell = (cell) => {
5702
+ const matrix = this.querySelector(".c-bivariate-legend__matrix");
5703
+ const cells = Array.from(matrix ? matrix.querySelectorAll(".c-bivariate-legend__cell") : []);
5704
+ const idx = cells.indexOf(cell);
5705
+ if (idx < 0) return;
5706
+ const size = Math.min(8, Math.max(1, parseInt(this.getAttribute("size") || "3", 10) || 3));
5707
+ const row = Math.floor(idx / size);
5708
+ const col = idx % size;
5709
+ cells.forEach((cell, i) => {
5710
+ const rr = Math.floor(i / size);
5711
+ const cc = i % size;
5712
+ if (rr === row && cc === col) cell.setAttribute("data-selected", "");
5713
+ else cell.removeAttribute("data-selected");
5714
+ });
5715
+ this.dispatchEvent(new CustomEvent("contour:select", { detail: { row, col }, bubbles: true, composed: true }));
5716
+ };
5717
+ this.addEventListener("click", (e) => {
5718
+ const cell = e.target && e.target.closest ? e.target.closest(".c-bivariate-legend__cell") : null;
5719
+ if (cell && this.contains(cell)) selectCell(cell);
5720
+ });
5721
+ this.addEventListener("keydown", (e) => {
5722
+ const cell = e.target && e.target.closest ? e.target.closest(".c-bivariate-legend__cell") : null;
5723
+ if (!cell || !this.contains(cell)) return;
5724
+ if (e.key === "Enter" || e.key === " ") { e.preventDefault(); selectCell(cell); }
5725
+ });
5726
+ }
5727
+ clear() { this.removeAttribute("selected"); this.dispatchEvent(new CustomEvent("contour:clear", { bubbles: true, composed: true })); }
5627
5728
  }
5628
5729
  define("contour-bivariate-legend", ContourBivariateLegend);
5629
5730
  class ContourSurvey extends ContourBase {
@@ -5758,13 +5859,18 @@ class ContourLegend extends ContourBase {
5758
5859
  if (items) {
5759
5860
  try {
5760
5861
  const parsed = JSON.parse(items);
5761
- const list = this.ensure(".c-legend__items", () => { const el = document.createElement("div"); el.className = "c-legend__items"; return el; });
5862
+ const list = this.ensure(".c-legend__items", () => { const el = document.createElement("div"); el.className = "c-legend__items"; el.setAttribute("role", "listbox"); return el; });
5863
+ list.setAttribute("role", "listbox");
5864
+ if (title) list.setAttribute("aria-label", title);
5762
5865
  list.innerHTML = "";
5763
5866
  parsed.forEach((it) => {
5764
5867
  const label = typeof it === "string" ? it : (it.label || String(it));
5765
5868
  const key = typeof it === "string" ? it : (it.key || it.label || String(it));
5766
5869
  const item = document.createElement(selectable ? "button" : "div");
5767
5870
  item.className = "c-legend__item";
5871
+ item.setAttribute("role", "option");
5872
+ item.setAttribute("aria-selected", "false");
5873
+ item.setAttribute("tabindex", "-1");
5768
5874
  if (selectable) {
5769
5875
  item.type = "button";
5770
5876
  item.setAttribute("aria-pressed", "true");
@@ -5817,6 +5923,39 @@ class ContourLegend extends ContourBase {
5817
5923
  renderEmpty(this, "legend");
5818
5924
  }
5819
5925
  }
5926
+ // caption as option description (aria-describedby), not part of name
5927
+ const caption = this.getAttribute("caption");
5928
+ let captionEl = this.querySelector(".c-legend__caption");
5929
+ if (caption) {
5930
+ if (!captionEl) { captionEl = document.createElement("span"); captionEl.className = "c-legend__caption"; this.appendChild(captionEl); }
5931
+ captionEl.id = captionEl.id || ("legend-caption-" + Math.random().toString(36).slice(2));
5932
+ captionEl.textContent = caption;
5933
+ captionEl.style.position = "absolute"; captionEl.style.width = "1px"; captionEl.style.height = "1px"; captionEl.style.overflow = "hidden"; captionEl.style.clip = "rect(0,0,0,0)";
5934
+ } else if (captionEl) {
5935
+ captionEl.remove();
5936
+ }
5937
+ // single tab stop: first option
5938
+ const _items = this.querySelector(".c-legend__items");
5939
+ if (_items) {
5940
+ const opts = Array.from(_items.querySelectorAll(".c-legend__item"));
5941
+ opts.forEach((o, i) => o.setAttribute("tabindex", i === 0 ? "0" : "-1"));
5942
+ if (captionEl) opts.forEach((o) => o.setAttribute("aria-describedby", captionEl.id));
5943
+ }
5944
+ // no-data entry from palette / no-data-color
5945
+ const ndColor = this.getAttribute("no-data-color");
5946
+ if (ndColor) {
5947
+ let nd = this.querySelector(".c-legend__no-data");
5948
+ if (!nd) { nd = document.createElement("div"); nd.className = "c-legend__no-data"; this.appendChild(nd); }
5949
+ nd.setAttribute("part", "no-data");
5950
+ nd.textContent = "No data";
5951
+ const glyph = document.createElement("span");
5952
+ glyph.className = "glyph";
5953
+ glyph.style.background = ndColor;
5954
+ nd.prepend(glyph);
5955
+ } else {
5956
+ const nd = this.querySelector(".c-legend__no-data");
5957
+ if (nd) nd.remove();
5958
+ }
5820
5959
  // audit notice
5821
5960
  const audit = this.getAttribute("audit");
5822
5961
  if (audit) {
@@ -5950,6 +6089,7 @@ class ContourLegend extends ContourBase {
5950
6089
  if (!btn || !this.contains(btn)) return;
5951
6090
  const pressed = btn.getAttribute("aria-pressed") !== "true";
5952
6091
  btn.setAttribute("aria-pressed", String(pressed));
6092
+ btn.setAttribute("aria-selected", String(pressed));
5953
6093
  this.dispatchEvent(new CustomEvent("contour:legend-toggle", {
5954
6094
  detail: { label: btn.textContent.trim(), key: btn.dataset.key || btn.textContent.trim(), pressed },
5955
6095
  bubbles: true,
@@ -5982,11 +6122,34 @@ class ContourLegend extends ContourBase {
5982
6122
  if (e.key === "ArrowDown" || e.key === "ArrowRight") {
5983
6123
  e.preventDefault();
5984
6124
  const next = items[(idx + 1) % items.length];
5985
- if (next) next.focus();
6125
+ if (next) { next.focus(); items.forEach((o,i)=>o.setAttribute("tabindex", o===next?"0":"-1")); }
5986
6126
  } else if (e.key === "ArrowUp" || e.key === "ArrowLeft") {
5987
6127
  e.preventDefault();
5988
6128
  const prev = items[(idx - 1 + items.length) % items.length];
5989
- if (prev) prev.focus();
6129
+ if (prev) { prev.focus(); items.forEach((o)=>o.setAttribute("tabindex", o===prev?"0":"-1")); }
6130
+ } else if (e.key === "Home") {
6131
+ if (items.length > 4) { e.preventDefault(); items[0].focus(); items.forEach((o,i)=>o.setAttribute("tabindex", i===0?"0":"-1")); }
6132
+ } else if (e.key === "End") {
6133
+ if (items.length > 4) { e.preventDefault(); const last = items[items.length-1]; last.focus(); items.forEach((o)=>o.setAttribute("tabindex", o===last?"0":"-1")); }
6134
+ } else if (e.key === "Escape") {
6135
+ // clear selection
6136
+ items.forEach((o) => o.setAttribute("aria-selected", "false"));
6137
+ this.dispatchEvent(new CustomEvent("contour:clear", { bubbles: true, composed: true }));
6138
+ } else if (e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey) {
6139
+ // type-ahead
6140
+ if (items.length > 7) {
6141
+ const start = idx >= 0 ? idx + 1 : 0;
6142
+ for (let i = 0; i < items.length; i++) {
6143
+ const ii = (start + i) % items.length;
6144
+ const txt = (items[ii].textContent || "").trim().toLowerCase();
6145
+ if (txt.startsWith(e.key.toLowerCase())) {
6146
+ e.preventDefault();
6147
+ items[ii].focus();
6148
+ items.forEach((o,j)=>o.setAttribute("tabindex", j===ii?"0":"-1"));
6149
+ break;
6150
+ }
6151
+ }
6152
+ }
5990
6153
  } else if (e.key === "Enter" || e.key === " ") {
5991
6154
  e.preventDefault();
5992
6155
  if (document.activeElement && document.activeElement.classList.contains("c-legend__item")) {
@@ -9294,7 +9457,7 @@ class ContourLayerPanel extends ContourBase {
9294
9457
  }
9295
9458
  define("contour-layer-panel", ContourLayerPanel);
9296
9459
  class ContourTimeSlider extends ContourBase {
9297
- static get observed() { return ["label", "value", "loop", "speed"]; }
9460
+ static get observed() { return ["label", "value", "loop", "speed", "speeds", "show-loop", "loop-label", "current-time", "time-format", "is-playing"]; }
9298
9461
  static get properties() { return { label: { attribute: "label" }, value: { attribute: "value" }, src: { attribute: "src" } }; }
9299
9462
  render() {
9300
9463
  this.classList.add("c-time-slider");
@@ -9320,7 +9483,41 @@ class ContourTimeSlider extends ContourBase {
9320
9483
  }
9321
9484
  track.setAttribute("aria-label", this.getAttribute("label") || "Time");
9322
9485
  const time = this.ensure(".c-time-slider__time", () => { const el = document.createElement("span"); el.className = "c-time-slider__time"; return el; });
9323
- time.textContent = this.getAttribute("label") || "";
9486
+ const ct = this.getAttribute("current-time");
9487
+ time.textContent = ct ? ct : (this.getAttribute("label") || "");
9488
+ // speed selector
9489
+ let speeds = null;
9490
+ const speedsAttr = this.getAttribute("speeds");
9491
+ if (speedsAttr) { try { speeds = JSON.parse(speedsAttr); } catch (e) { speeds = null; } }
9492
+ const speedSel = this.ensure(".c-time-slider__speed", () => { const el = document.createElement("select"); el.className = "c-time-slider__speed"; el.setAttribute("aria-label", "Speed"); return el; });
9493
+ speedSel.innerHTML = "";
9494
+ const speedList = Array.isArray(speeds) ? speeds : [0.5, 1, 2, 5, 10];
9495
+ speedList.forEach((sp) => {
9496
+ const opt = document.createElement("option");
9497
+ opt.value = String(sp);
9498
+ opt.textContent = String(sp);
9499
+ if (String(sp) === (this.getAttribute("speed") || "")) opt.selected = true;
9500
+ speedSel.appendChild(opt);
9501
+ });
9502
+ const speedAttr = this.getAttribute("speed");
9503
+ if (speedAttr) speedSel.value = speedAttr;
9504
+ // loop toggle
9505
+ const showLoop = this.hasAttribute("show-loop");
9506
+ if (showLoop) {
9507
+ const loopBtn = this.ensure(".c-time-slider__loop", () => { const el = document.createElement("button"); el.className = "c-time-slider__loop"; el.type = "button"; el.setAttribute("aria-label", this.getAttribute("loop-label") || "Loop"); return el; });
9508
+ loopBtn.setAttribute("aria-pressed", this.hasAttribute("loop") ? "true" : "false");
9509
+ loopBtn.textContent = this.getAttribute("loop-label") || "Loop";
9510
+ } else {
9511
+ const lb = this.querySelector(".c-time-slider__loop");
9512
+ if (lb) lb.remove();
9513
+ }
9514
+ // is-playing reflects on play button
9515
+ if (this.hasAttribute("is-playing")) {
9516
+ play.setAttribute("data-state", "pause");
9517
+ play.setAttribute("aria-label", "Pause");
9518
+ const use = play.querySelector("use");
9519
+ if (use) use.setAttribute("href", "#i-pause");
9520
+ }
9324
9521
  }
9325
9522
  enhance() {
9326
9523
  if (this._wiredTimeSlider) return;
@@ -9356,20 +9553,38 @@ class ContourTimeSlider extends ContourBase {
9356
9553
  };
9357
9554
  this.addEventListener("click", (e) => {
9358
9555
  const btn = e.target && e.target.closest ? e.target.closest(".c-time-slider__play") : null;
9359
- if (!btn) return;
9360
- const playing = btn.getAttribute("data-state") === "play";
9361
- btn.setAttribute("data-state", playing ? "pause" : "play");
9362
- btn.setAttribute("aria-label", playing ? "Pause" : "Play");
9363
- const use = btn.querySelector("use");
9364
- if (use) use.setAttribute("href", playing ? "#i-pause" : "#i-play");
9365
- if (playing) {
9366
- stop();
9367
- const speed = parseFloat(this.getAttribute("speed") || "1") || 1;
9368
- const delay = Math.max(100, 1000 / speed);
9369
- timer = setInterval(step, delay);
9370
- } else {
9371
- stop();
9556
+ if (btn) {
9557
+ const playing = btn.getAttribute("data-state") === "play";
9558
+ btn.setAttribute("data-state", playing ? "pause" : "play");
9559
+ btn.setAttribute("aria-label", playing ? "Pause" : "Play");
9560
+ const use = btn.querySelector("use");
9561
+ if (use) use.setAttribute("href", playing ? "#i-pause" : "#i-play");
9562
+ if (playing) {
9563
+ stop();
9564
+ const speed = parseFloat(this.getAttribute("speed") || "1") || 1;
9565
+ const delay = Math.max(100, 1000 / speed);
9566
+ timer = setInterval(step, delay);
9567
+ this.dispatchEvent(new CustomEvent("contour:play", { bubbles: true, composed: true }));
9568
+ } else {
9569
+ stop();
9570
+ this.dispatchEvent(new CustomEvent("contour:pause", { bubbles: true, composed: true }));
9571
+ }
9572
+ return;
9372
9573
  }
9574
+ const loopBtn = e.target && e.target.closest ? e.target.closest(".c-time-slider__loop") : null;
9575
+ if (loopBtn) {
9576
+ const next = loopBtn.getAttribute("aria-pressed") !== "true";
9577
+ loopBtn.setAttribute("aria-pressed", String(next));
9578
+ this.toggleAttribute("loop", next);
9579
+ this.dispatchEvent(new CustomEvent("contour:loop-change", { detail: { loop: next }, bubbles: true, composed: true }));
9580
+ }
9581
+ });
9582
+ // speed select change (delegated)
9583
+ this.addEventListener("change", (e) => {
9584
+ const sel = e.target && e.target.closest ? e.target.closest(".c-time-slider__speed") : null;
9585
+ if (!sel) return;
9586
+ const speed = Number(sel.value);
9587
+ this.dispatchEvent(new CustomEvent("contour:speed-change", { detail: { speed }, bubbles: true, composed: true }));
9373
9588
  });
9374
9589
  onDispose(this, stop);
9375
9590
  }
@@ -12046,8 +12261,8 @@ class ContourMapPopup extends ContourBase {
12046
12261
  define("contour-map-popup", ContourMapPopup);
12047
12262
 
12048
12263
  class ContourAnimationControls extends ContourBase {
12049
- static get observed() { return ["playing", "speed"]; }
12050
- static get properties() { return { playing: { attribute: "playing", type: Boolean }, speed: { attribute: "speed" } }; }
12264
+ static get observed() { return ["playing", "speed", "progress", "min", "max", "caption", "show-thumb", "show-thumb-caption"]; }
12265
+ static get properties() { return { playing: { attribute: "playing", type: Boolean }, speed: { attribute: "speed" }, progress: { attribute: "progress" }, min: { attribute: "min" }, max: { attribute: "max" } }; }
12051
12266
  render() {
12052
12267
  this.classList.add("c-animation-controls");
12053
12268
  const playBtn = this.ensure(".c-animation-controls__play", () => { const el = document.createElement("button"); el.className = "c-btn c-btn--sm c-animation-controls__play"; el.type = "button"; return el; });
@@ -12056,6 +12271,26 @@ class ContourAnimationControls extends ContourBase {
12056
12271
  const speed = this.getAttribute("speed") || "1x";
12057
12272
  const speedBtn = this.ensure(".c-animation-controls__speed", () => { const el = document.createElement("button"); el.className = "c-btn c-btn--sm c-animation-controls__speed"; el.type = "button"; return el; });
12058
12273
  speedBtn.textContent = speed;
12274
+ // scrubber
12275
+ const scrubber = this.ensure(".c-animation-controls__scrubber", () => { const el = document.createElement("input"); el.className = "c-animation-controls__scrubber"; el.type = "range"; return el; });
12276
+ if (this.getAttribute("show-thumb") === "false") scrubber.classList.remove("c-animation-controls__scrubber--thumb");
12277
+ else scrubber.classList.add("c-animation-controls__scrubber--thumb");
12278
+ scrubber.min = this.getAttribute("min") || "0";
12279
+ scrubber.max = this.getAttribute("max") || "100";
12280
+ scrubber.value = this.getAttribute("progress") || "0";
12281
+ const caption = this.getAttribute("caption");
12282
+ if (caption) scrubber.setAttribute("aria-label", caption);
12283
+ else if (!scrubber.getAttribute("aria-label")) scrubber.setAttribute("aria-label", "Playhead");
12284
+ // caption display
12285
+ const showCaption = this.hasAttribute("show-thumb-caption") || this.hasAttribute("show-thumb");
12286
+ if (caption && showCaption) {
12287
+ const cap = this.ensure(".c-animation-controls__caption", () => { const el = document.createElement("span"); el.className = "c-animation-controls__caption"; return el; });
12288
+ cap.textContent = caption;
12289
+ } else {
12290
+ const cap = this.querySelector(".c-animation-controls__caption");
12291
+ if (cap) cap.remove();
12292
+ }
12293
+ // showThumb: hide thumb via attribute? keep default
12059
12294
  }
12060
12295
  enhance() {
12061
12296
  if (this._wiredAnimControls) return;
@@ -12070,6 +12305,13 @@ class ContourAnimationControls extends ContourBase {
12070
12305
  this.dispatchEvent(new CustomEvent("contour:change", { bubbles: true, composed: true, detail: { speed: speed.textContent } }));
12071
12306
  }
12072
12307
  });
12308
+ this.addEventListener("input", (e) => {
12309
+ const scrubber = e.target && e.target.closest ? e.target.closest(".c-animation-controls__scrubber") : null;
12310
+ if (scrubber && this.contains(scrubber)) {
12311
+ const v = Number(scrubber.value);
12312
+ this.dispatchEvent(new CustomEvent("contour:seek", { bubbles: true, composed: true, detail: { progress: v, value: v } }));
12313
+ }
12314
+ });
12073
12315
  }
12074
12316
  }
12075
12317
  define("contour-animation-controls", ContourAnimationControls);
@@ -12176,7 +12418,7 @@ class ContourStyleSwitcher extends ContourBase {
12176
12418
  define("contour-style-switcher", ContourStyleSwitcher);
12177
12419
 
12178
12420
  class ContourStylePanel extends ContourBase {
12179
- static get observed() { return ["title", "layers", "layer", "single", "classification", "palette", "breaks", "opacity", "n", "colors"]; }
12421
+ static get observed() { return ["title", "layers", "layer", "single", "classification", "palette", "breaks", "opacity", "n", "colors", "property"]; }
12180
12422
  static get properties() { return { title: { attribute: "title" }, layers: { attribute: "layers" }, classification: { attribute: "classification" }, palette: { attribute: "palette" }, breaks: { attribute: "breaks" }, opacity: { attribute: "opacity" } }; }
12181
12423
  render() {
12182
12424
  this.classList.add("c-style-panel");
@@ -12189,39 +12431,64 @@ class ContourStylePanel extends ContourBase {
12189
12431
  if (singleMode) {
12190
12432
  const body = this.ensure(".c-style-panel__body", () => { const el = document.createElement("div"); el.className = "c-style-panel__body"; return el; });
12191
12433
  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";
12434
+ // property field
12435
+ const propLabel = document.createElement("label"); propLabel.textContent = "Colour field"; propLabel.setAttribute("for", "property"); body.appendChild(propLabel);
12436
+ const propIn = document.createElement("input"); propIn.type = "text"; propIn.id = "property"; propIn.className = "c-style-panel__property c-input"; propIn.setAttribute("aria-label", "Colour field");
12437
+ const pv = this.getAttribute("property"); if (pv) propIn.value = pv;
12438
+ body.appendChild(propIn);
12439
+ // classification method selector (policy)
12440
+ const clsLabel = document.createElement("label"); clsLabel.textContent = "Classification"; clsLabel.setAttribute("for", "policy"); body.appendChild(clsLabel);
12441
+ const clsSel = document.createElement("select"); clsSel.id = "policy"; clsSel.className = "c-style-panel__classification c-input"; clsSel.setAttribute("aria-label", "Classification method");
12195
12442
  ["equal","quantile","jenks","manual"].forEach((m) => { const o = document.createElement("option"); o.value = m; o.textContent = m; clsSel.appendChild(o); });
12196
12443
  const cls = this.getAttribute("classification"); if (cls) clsSel.value = cls;
12197
12444
  body.appendChild(clsSel);
12198
12445
  // palette picker
12199
- const pal = document.createElement("input"); pal.type = "text"; pal.className = "c-style-panel__palette"; pal.placeholder = "palette";
12446
+ const palLabel = document.createElement("label"); palLabel.textContent = "Palette"; palLabel.setAttribute("for", "palette"); body.appendChild(palLabel);
12447
+ const pal = document.createElement("input"); pal.type = "text"; pal.id = "palette"; pal.className = "c-style-panel__palette c-input"; pal.placeholder = "palette"; pal.setAttribute("aria-label", "Palette");
12200
12448
  const palv = this.getAttribute("palette"); if (palv) pal.value = palv;
12201
12449
  body.appendChild(pal);
12202
12450
  // n (class count)
12203
- const nIn = document.createElement("input"); nIn.type = "number"; nIn.className = "c-style-panel__n"; nIn.min = "2"; nIn.max = "12";
12451
+ const nLabel = document.createElement("label"); nLabel.textContent = "Classes"; nLabel.setAttribute("for", "n"); body.appendChild(nLabel);
12452
+ const nIn = document.createElement("input"); nIn.type = "number"; nIn.id = "n"; nIn.className = "c-style-panel__n c-input"; nIn.min = "2"; nIn.max = "12"; nIn.setAttribute("aria-label", "Class count");
12204
12453
  const nv = this.getAttribute("n"); if (nv) nIn.value = nv; else nIn.value = "5";
12205
12454
  body.appendChild(nIn);
12206
12455
  // opacity slider
12207
12456
  const op = document.createElement("input"); op.type = "range"; op.className = "c-style-panel__opacity"; op.min = "0"; op.max = "100";
12208
12457
  const ov = this.getAttribute("opacity"); op.value = ov != null ? ov : "100";
12209
12458
  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
12459
+ // breaks as .break elements per class
12460
+ const breaksAttr = this.getAttribute("breaks");
12461
+ let breaksArr = null;
12462
+ if (breaksAttr) { try { breaksArr = JSON.parse(breaksAttr); } catch (e) { breaksArr = breaksAttr.split(",").map((s) => s.trim()); } }
12463
+ if (Array.isArray(breaksArr) && breaksArr.length) {
12464
+ const breaksWrap = document.createElement("div"); breaksWrap.className = "c-style-panel__breaks breaks";
12465
+ breaksArr.forEach((b, i) => {
12466
+ const br = document.createElement("div"); br.className = "break";
12467
+ br.textContent = String(b);
12468
+ breaksWrap.appendChild(br);
12469
+ });
12470
+ body.appendChild(breaksWrap);
12471
+ }
12472
+ // color swatches
12215
12473
  const colorsAttr = this.getAttribute("colors");
12216
12474
  let colors = null;
12217
12475
  if (colorsAttr) { try { colors = JSON.parse(colorsAttr); } catch (e) { colors = colorsAttr.split(",").map((s) => s.trim()); } }
12218
12476
  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);
12477
+ const list = document.createElement("div"); list.className = "c-style-panel__colors colours";
12478
+ colors.forEach((c, i) => {
12479
+ const sw = document.createElement("input"); sw.type = "color"; sw.className = "c-style-panel__color c-input"; sw.setAttribute("aria-label", "Colour for class " + (i + 1));
12480
+ sw.value = c;
12481
+ sw.addEventListener("input", () => { sw.setAttribute("data-edited", "true"); });
12482
+ list.appendChild(sw);
12222
12483
  });
12223
12484
  body.appendChild(list);
12224
12485
  }
12486
+ // Apply/Revert buttons
12487
+ const actions = document.createElement("div"); actions.className = "c-style-panel__actions actions";
12488
+ const applyBtn = document.createElement("button"); applyBtn.type = "button"; applyBtn.className = "c-btn primary"; applyBtn.textContent = "Apply";
12489
+ const revertBtn = document.createElement("button"); revertBtn.type = "button"; revertBtn.className = "c-btn"; revertBtn.textContent = "Revert";
12490
+ actions.appendChild(applyBtn); actions.appendChild(revertBtn);
12491
+ body.appendChild(actions);
12225
12492
  return;
12226
12493
  }
12227
12494
  const layers = this.getAttribute("layers");
@@ -12315,6 +12582,15 @@ class ContourStylePanel extends ContourBase {
12315
12582
  this.dispatchEvent(new CustomEvent("contour:style-resolved", { detail: { value: t.value, layer: name, property: t.classList.contains("c-style-panel__palette") ? "palette" : "breaks" }, bubbles: true, composed: true }));
12316
12583
  }
12317
12584
  });
12585
+ this.addEventListener("click", (e) => {
12586
+ const t = e.target && e.target.closest ? e.target.closest("button") : null;
12587
+ if (!t || !this.contains(t)) return;
12588
+ if (t.textContent.trim() === "Apply") {
12589
+ this.dispatchEvent(new CustomEvent("contour:style-resolved", { detail: { applied: true }, bubbles: true, composed: true }));
12590
+ } else if (t.textContent.trim() === "Revert") {
12591
+ this.dispatchEvent(new CustomEvent("contour:style-resolved", { detail: { applied: false }, bubbles: true, composed: true }));
12592
+ }
12593
+ });
12318
12594
  }
12319
12595
  }
12320
12596
  define("contour-style-panel", ContourStylePanel);