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