contour-ds 1.7.2 → 1.8.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 (109) hide show
  1. package/README.md +80 -11
  2. package/dist/agent-rules.json +16 -0
  3. package/dist/build-manifest.json +181 -104
  4. package/dist/contour-wc-content.esm.js +5125 -0
  5. package/dist/contour-wc-content.esm.min.js +1 -0
  6. package/dist/contour-wc-dashboard.esm.js +8654 -0
  7. package/dist/contour-wc-dashboard.esm.min.js +1 -0
  8. package/dist/contour-wc-data.esm.js +8260 -0
  9. package/dist/contour-wc-data.esm.min.js +1 -0
  10. package/dist/contour-wc-docs.esm.js +4305 -0
  11. package/dist/contour-wc-docs.esm.min.js +1 -0
  12. package/dist/contour-wc-feedback.esm.js +4917 -0
  13. package/dist/contour-wc-feedback.esm.min.js +1 -0
  14. package/dist/contour-wc-forms.esm.js +5688 -0
  15. package/dist/contour-wc-forms.esm.min.js +1 -0
  16. package/dist/contour-wc-interaction.esm.js +4580 -0
  17. package/dist/contour-wc-interaction.esm.min.js +1 -0
  18. package/dist/contour-wc-layout.esm.js +4174 -0
  19. package/dist/contour-wc-layout.esm.min.js +1 -0
  20. package/dist/contour-wc-map.esm.js +5205 -0
  21. package/dist/contour-wc-map.esm.min.js +1 -0
  22. package/dist/contour-wc-misc.esm.js +4264 -0
  23. package/dist/contour-wc-misc.esm.min.js +1 -0
  24. package/dist/contour-wc-navigation.esm.js +5844 -0
  25. package/dist/contour-wc-navigation.esm.min.js +1 -0
  26. package/dist/contour-wc-ui.esm.js +9009 -0
  27. package/dist/contour-wc-ui.esm.min.js +1 -0
  28. package/dist/contour-wc.esm.js +6109 -1641
  29. package/dist/contour-wc.esm.min.js +1 -1
  30. package/dist/contour-wc.js +6108 -1641
  31. package/dist/contour-wc.min.js +1 -1
  32. package/dist/contour.code-snippets +4512 -0
  33. package/dist/contour.components.json +2597 -799
  34. package/dist/contour.css +5275 -4050
  35. package/dist/contour.d.ts +560 -1085
  36. package/dist/contour.esm.js +7 -0
  37. package/dist/contour.esm.min.js +1 -1
  38. package/dist/contour.html-data.json +10311 -0
  39. package/dist/contour.js +7 -0
  40. package/dist/contour.min.css +1 -1
  41. package/dist/contour.min.js +1 -1
  42. package/dist/contour.react.d.ts +420 -0
  43. package/dist/contour.single.html +17 -0
  44. package/dist/contour.single.min.css +1 -0
  45. package/dist/contour.tokens.json +940 -902
  46. package/dist/contour.vue.d.ts +418 -0
  47. package/dist/contour.web-types.json +10703 -0
  48. package/dist/custom-elements.json +30708 -0
  49. package/dist/docs/actions.md +3 -2
  50. package/dist/docs/affordances.md +23 -9
  51. package/dist/docs/apireference.md +1 -1
  52. package/dist/docs/colour.md +1 -1
  53. package/dist/docs/componentindex.md +6 -2
  54. package/dist/docs/data.md +7 -2
  55. package/dist/docs/docs.md +9 -2
  56. package/dist/docs/feedback.md +1 -1
  57. package/dist/docs/field.md +1 -1
  58. package/dist/docs/forms.md +1 -1
  59. package/dist/docs/index.json +22 -20
  60. package/dist/docs/install.md +1 -1
  61. package/dist/docs/landing.md +1 -1
  62. package/dist/docs/mapengine.md +19 -2
  63. package/dist/docs/motion.md +1 -1
  64. package/dist/docs/navigation.md +1 -1
  65. package/dist/docs/overlays.md +1 -1
  66. package/dist/docs/overview.md +1 -1
  67. package/dist/docs/patterns.md +2 -2
  68. package/dist/docs/playground.md +22 -2
  69. package/dist/docs/principles.md +1 -1
  70. package/dist/docs/recipes.md +13 -8
  71. package/dist/docs/space.md +1 -1
  72. package/dist/docs/status.md +14 -2
  73. package/dist/docs/surfaces.md +1 -1
  74. package/dist/docs/theming.md +1 -1
  75. package/dist/docs/type.md +1 -1
  76. package/dist/docs/webcomponents.md +17 -3
  77. package/dist/registry/items/contour-core.json +2 -2
  78. package/dist/registry/items/contour-data.json +2 -2
  79. package/dist/registry/items/contour-docs.json +2 -2
  80. package/dist/registry/items/contour-landing.json +2 -2
  81. package/dist/registry/registry.json +8 -8
  82. package/dist/surfaces/contour-core.min.css +1 -1
  83. package/dist/surfaces/contour-data.min.css +1 -1
  84. package/dist/surfaces/contour-docs.min.css +1 -1
  85. package/dist/surfaces/contour-landing.min.css +1 -1
  86. package/dist/wc/behaviours.mjs +45 -57
  87. package/dist/wc/content.mjs +263 -63
  88. package/dist/wc/core.mjs +390 -71
  89. package/dist/wc/dashboard.mjs +220 -13
  90. package/dist/wc/data.mjs +1075 -460
  91. package/dist/wc/docs.mjs +105 -12
  92. package/dist/wc/feedback.mjs +63 -14
  93. package/dist/wc/forms.mjs +733 -104
  94. package/dist/wc/index.mjs +9 -2
  95. package/dist/wc/interaction.mjs +182 -28
  96. package/dist/wc/layout.mjs +95 -25
  97. package/dist/wc/map.mjs +185 -118
  98. package/dist/wc/misc.mjs +124 -24
  99. package/dist/wc/navigation.mjs +384 -115
  100. package/dist/wc/shadow.mjs +94 -18
  101. package/dist/wc/states.mjs +21 -3
  102. package/dist/wc/svg.mjs +104 -0
  103. package/dist/wc/ui.mjs +1988 -476
  104. package/integrations/README.md +2 -0
  105. package/integrations/ai/CLAUDE.md +3 -3
  106. package/integrations/frameworks/README.md +235 -0
  107. package/integrations/native/style-dictionary.config.json +1 -1
  108. package/integrations/tailwind/contour-theme.css +5 -6
  109. package/package.json +53 -24
package/dist/wc/map.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { ContourBase, define, onDispose, formatValue } from './core.mjs';
1
+ import { ContourBase, define, onDispose, formatValue, navKey, isRtl , warnBadJson, labelText } from './core.mjs';
2
2
  import { loadRemote, remoteData, renderStates, renderEmpty, wireStates } from './states.mjs';
3
3
  import { compassNeedle, scaleBarTicks } from './svg.mjs';
4
4
 
@@ -48,25 +48,11 @@ function wireMapItems(host, itemSelector, tooltipClass) {
48
48
  e.preventDefault();
49
49
  const all = items();
50
50
  const index = all.indexOf(item);
51
- if (index < 0) return;
52
- host.dispatchEvent(new CustomEvent("contour:select", { bubbles: true, composed: true, detail: { index, label: item.getAttribute("title") || item.textContent.trim() } }));
51
+ if (index >= 0) host.dispatchEvent(new CustomEvent("contour:select", { bubbles: true, composed: true, detail: { index, label: item.getAttribute("title") || item.textContent.trim() } }));
52
+ } else {
53
+ const all = items();
54
+ navKey(e, all, { wrap: false, homeEnd: true, rtl: isRtl(host), onNavigate: (i) => all.forEach((c, j) => c.setAttribute("tabindex", j === i ? "0" : "-1")) });
53
55
  }
54
- // Roving tabindex keyboard nav.
55
- const all = items();
56
- const idx = all.indexOf(item);
57
- if (idx < 0) return;
58
- let next = -1;
59
- const rtl = (host.getAttribute("dir") || document.documentElement.getAttribute("dir") || "").toLowerCase() === "rtl";
60
- if (e.key === "ArrowDown") next = Math.min(idx + 1, all.length - 1);
61
- else if (e.key === "ArrowUp") next = Math.max(idx - 1, 0);
62
- else if (e.key === "ArrowRight") next = rtl ? Math.max(idx - 1, 0) : Math.min(idx + 1, all.length - 1);
63
- else if (e.key === "ArrowLeft") next = rtl ? Math.min(idx + 1, all.length - 1) : Math.max(idx - 1, 0);
64
- else if (e.key === "Home") next = 0;
65
- else if (e.key === "End") next = all.length - 1;
66
- if (next < 0 || next === idx) return;
67
- e.preventDefault();
68
- all.forEach((c, i) => c.setAttribute("tabindex", i === next ? "0" : "-1"));
69
- try { all[next].focus(); } catch (err) {}
70
56
  });
71
57
  }
72
58
 
@@ -75,8 +61,8 @@ class ContourMinimap extends ContourBase {
75
61
  static get properties() { return { label: { attribute: "label" }, viewport: { attribute: "viewport" }, src: { attribute: "src" } }; }
76
62
  render() {
77
63
  this.classList.add("c-minimap");
78
- this.setAttribute("role", "img");
79
- this.setAttribute("aria-label", "Minimap");
64
+ if (!this.hasAttribute("role")) this.setAttribute("role", "img");
65
+ if (!this.hasAttribute("aria-label")) this.setAttribute("aria-label", this.getAttribute("label") || "Minimap");
80
66
  wireStates(this);
81
67
  loadRemote(this, ["label", "viewport"]);
82
68
  if (renderStates(this, "minimap")) return;
@@ -176,7 +162,7 @@ class ContourCoordinate extends ContourBase {
176
162
  span.textContent = text;
177
163
  // copy button
178
164
  let btn = this.querySelector(".c-coordinate__copy");
179
- if (!btn) { btn = document.createElement("button"); btn.type = "button"; btn.className = "c-coordinate__copy"; btn.textContent = "Copy"; btn.setAttribute("aria-label", "Copy coordinate"); this.appendChild(btn); }
165
+ if (!btn) { btn = document.createElement("button"); btn.type = "button"; btn.className = "c-coordinate__copy"; btn.textContent = labelText(this, "copy", "Copy"); btn.setAttribute("aria-label", labelText(this, "copy-coordinate", "Copy coordinate")); this.appendChild(btn); }
180
166
  btn.onclick = () => {
181
167
  try {
182
168
  if (navigator.clipboard && navigator.clipboard.writeText) {
@@ -249,14 +235,21 @@ class ContourLayerPanel extends ContourBase {
249
235
  try {
250
236
  parsed = JSON.parse(items);
251
237
  Array.from(this.querySelectorAll(".c-layer-panel__item")).forEach((el) => el.remove());
252
- } catch (e) { /* keep existing */ }
238
+ } catch (e) { warnBadJson(this, "attribute", e); }
253
239
  }
254
240
  if (parsed) { parsed.forEach((it) => {
255
241
  const name = typeof it === "string" ? it : (it.name || it.label || "");
256
242
  const caption = (typeof it === "object" && it) ? (it.caption || it.subtitle || "") : "";
257
- const item = document.createElement("div");
258
- item.className = "c-layer-panel__item" + (it.dragging ? " c-layer-panel__item--dragging" : "");
259
- const toggle = document.createElement("button");
243
+ const item = document.createElement("div");
244
+ item.className = "c-layer-panel__item" + (it.dragging ? " c-layer-panel__item--dragging" : "");
245
+ // Drag handle: focusable grip for keyboard reorder (CDS-049).
246
+ const drag = document.createElement("button");
247
+ drag.type = "button";
248
+ drag.className = "c-drag-handle--dots";
249
+ drag.setAttribute("aria-label", "Reorder " + (name || "layer"));
250
+ drag.setAttribute("tabindex", "0");
251
+ item.appendChild(drag);
252
+ const toggle = document.createElement("button");
260
253
  toggle.type = "button";
261
254
  toggle.className = "c-layer-panel__toggle";
262
255
  toggle.setAttribute("part", "visibility-toggle");
@@ -281,7 +274,7 @@ class ContourLayerPanel extends ContourBase {
281
274
  opacity.className = "c-layer-panel__opacity";
282
275
  opacity.min = "0";
283
276
  opacity.max = "100";
284
- opacity.setAttribute("aria-label", "Opacity of " + (name || "layer"));
277
+ opacity.setAttribute("aria-label", labelText(this, "opacity-of", "Opacity of") + " " + (name || "layer"));
285
278
  opacity.value = (typeof it === "object" && it.opacity != null) ? it.opacity : "100";
286
279
  item.appendChild(opacity);
287
280
  // rename input (hidden by default, toggled via button)
@@ -289,24 +282,24 @@ class ContourLayerPanel extends ContourBase {
289
282
  const renameBtn = document.createElement("button");
290
283
  renameBtn.type = "button";
291
284
  renameBtn.className = "c-layer-panel__rename";
292
- renameBtn.textContent = "Rename";
293
- renameBtn.setAttribute("aria-label", "Rename " + (name || "layer"));
285
+ renameBtn.textContent = labelText(this, "rename", "Rename");
286
+ renameBtn.setAttribute("aria-label", labelText(this, "rename", "Rename") + " " + (name || "layer"));
294
287
  item.appendChild(renameBtn);
295
288
  }
296
289
  if (this.getAttribute("allow-duplicate") !== "false") {
297
290
  const dupBtn = document.createElement("button");
298
291
  dupBtn.type = "button";
299
292
  dupBtn.className = "c-layer-panel__duplicate";
300
- dupBtn.textContent = "Duplicate";
301
- dupBtn.setAttribute("aria-label", "Duplicate " + (name || "layer"));
293
+ dupBtn.textContent = labelText(this, "duplicate", "Duplicate");
294
+ dupBtn.setAttribute("aria-label", labelText(this, "duplicate", "Duplicate") + " " + (name || "layer"));
302
295
  item.appendChild(dupBtn);
303
296
  }
304
297
  if (this.getAttribute("allow-zoom") !== "false") {
305
298
  const zoomBtn = document.createElement("button");
306
299
  zoomBtn.type = "button";
307
300
  zoomBtn.className = "c-layer-panel__zoom";
308
- zoomBtn.textContent = "Zoom";
309
- zoomBtn.setAttribute("aria-label", "Zoom to " + (name || "layer"));
301
+ zoomBtn.textContent = labelText(this, "zoom", "Zoom");
302
+ zoomBtn.setAttribute("aria-label", labelText(this, "zoom-to", "Zoom to") + " " + (name || "layer"));
310
303
  item.appendChild(zoomBtn);
311
304
  }
312
305
  if (this.getAttribute("allow-remove") !== "false") {
@@ -314,7 +307,7 @@ class ContourLayerPanel extends ContourBase {
314
307
  removeBtn.type = "button";
315
308
  removeBtn.className = "c-layer-panel__remove";
316
309
  removeBtn.innerHTML = '<svg aria-hidden="true"><use href="#i-minus" /></svg>';
317
- removeBtn.setAttribute("aria-label", "Remove " + (name || "layer"));
310
+ removeBtn.setAttribute("aria-label", labelText(this, "remove", "Remove") + " " + (name || "layer"));
318
311
  item.appendChild(removeBtn);
319
312
  }
320
313
  const projSel = document.createElement("select");
@@ -399,38 +392,44 @@ class ContourLayerPanel extends ContourBase {
399
392
  this.dispatchEvent(new CustomEvent("contour:layer-remove", { bubbles: true, composed: true, detail: { name } }));
400
393
  }
401
394
  });
402
- this.addEventListener("keydown", (e) => {
403
- if (e.target && e.target.classList && e.target.classList.contains("c-layer-panel__toggle") && (e.key === "Enter" || e.key === " ")) {
404
- e.preventDefault();
405
- e.target.click();
406
- return;
407
- }
408
- const item = e.target && e.target.closest ? e.target.closest(".c-layer-panel__item") : null;
409
- if (!item || !this.contains(item)) return;
410
- if (!(e.altKey) || (e.key !== "ArrowUp" && e.key !== "ArrowDown")) return;
411
- e.preventDefault();
412
- const items = Array.from(this.querySelectorAll(".c-layer-panel__item"));
413
- const idx = items.indexOf(item);
414
- if (idx < 0) return;
415
- const dir = e.key === "ArrowUp" ? -1 : 1;
416
- const newIdx = idx + dir;
417
- if (newIdx < 0 || newIdx >= items.length) return;
418
- item.classList.add("c-layer-panel__item--dragging");
419
- if (dir < 0) this.insertBefore(item, items[newIdx]);
420
- else this.insertBefore(items[newIdx], item);
421
- item.focus();
422
- setTimeout(() => item.classList.remove("c-layer-panel__item--dragging"), 200);
423
- const layerIds = Array.from(this.querySelectorAll(".c-layer-panel__item")).map((el) => el.querySelector(".c-layer-panel__name")?.textContent || "");
424
- this.dispatchEvent(new CustomEvent("contour:layer-reorder", { bubbles: true, composed: true, detail: { layerIds } }));
425
- });
395
+ this.addEventListener("keydown", (e) => {
396
+ if (e.target && e.target.classList && e.target.classList.contains("c-layer-panel__toggle") && (e.key === "Enter" || e.key === " ")) {
397
+ e.preventDefault();
398
+ e.target.click();
399
+ return;
400
+ }
401
+ const item = e.target && e.target.closest ? e.target.closest(".c-layer-panel__item") : null;
402
+ if (!item || !this.contains(item)) return;
403
+ const isDrag = e.target && e.target.classList && e.target.classList.contains("c-drag-handle--dots");
404
+ // Drag handle: ArrowUp/ArrowDown reorder without Alt modifier (CDS-049).
405
+ // Item-level: Alt+ArrowUp/ArrowDown as an alternative.
406
+ if ((isDrag && (e.key === "ArrowUp" || e.key === "ArrowDown")) || (e.altKey && (e.key === "ArrowUp" || e.key === "ArrowDown"))) {
407
+ e.preventDefault();
408
+ const items = Array.from(this.querySelectorAll(".c-layer-panel__item"));
409
+ const idx = items.indexOf(item);
410
+ if (idx < 0) return;
411
+ const dir = e.key === "ArrowUp" ? -1 : 1;
412
+ const newIdx = idx + dir;
413
+ if (newIdx < 0 || newIdx >= items.length) return;
414
+ item.classList.add("c-layer-panel__item--dragging");
415
+ if (dir < 0) this.insertBefore(item, items[newIdx]);
416
+ else this.insertBefore(items[newIdx], item);
417
+ (isDrag ? e.target : item).focus();
418
+ setTimeout(() => item.classList.remove("c-layer-panel__item--dragging"), 200);
419
+ const layerIds = Array.from(this.querySelectorAll(".c-layer-panel__item")).map((el) => el.querySelector(".c-layer-panel__name")?.textContent || "");
420
+ this.dispatchEvent(new CustomEvent("contour:layer-reorder", { bubbles: true, composed: true, detail: { layerIds } }));
421
+ }
422
+ });
426
423
  }
427
424
  }
428
425
  define("contour-layer-panel", ContourLayerPanel);
429
426
  class ContourTimeSlider extends ContourBase {
430
- static get observed() { return ["label", "value", "loop", "speed", "speeds", "show-loop", "loop-label", "current-time", "time-format", "is-playing", "play-label", "pause-label", "time-label", "speed-label"]; }
431
- static get properties() { return { label: { attribute: "label" }, value: { attribute: "value" }, distance: { attribute: "distance" }, resolution: { attribute: "resolution" }, latitude: { attribute: "latitude" }, src: { attribute: "src" }, loop: { attribute: "loop", type: Boolean }, speed: { attribute: "speed" }, speeds: { attribute: "speeds" }, showLoop: { attribute: "show-loop", type: Boolean }, loopLabel: { attribute: "loop-label" }, currentTime: { attribute: "current-time" }, timeFormat: { attribute: "time-format" }, isPlaying: { attribute: "is-playing", type: Boolean }, playLabel: { attribute: "play-label" }, pauseLabel: { attribute: "pause-label" }, timeLabel: { attribute: "time-label" }, speedLabel: { attribute: "speed-label" } }; }
427
+ static get observed() { return ["label", "value", "min", "max", "loop", "speed", "speeds", "show-loop", "loop-label", "current-time", "time-format", "is-playing", "play-label", "pause-label", "time-label", "speed-label"]; }
428
+ static get properties() { return { label: { attribute: "label" }, value: { attribute: "value" }, min: { attribute: "min" }, max: { attribute: "max" }, distance: { attribute: "distance" }, resolution: { attribute: "resolution" }, latitude: { attribute: "latitude" }, src: { attribute: "src" }, loop: { attribute: "loop", type: Boolean }, speed: { attribute: "speed" }, speeds: { attribute: "speeds" }, showLoop: { attribute: "show-loop", type: Boolean }, loopLabel: { attribute: "loop-label" }, currentTime: { attribute: "current-time" }, timeFormat: { attribute: "time-format" }, isPlaying: { attribute: "is-playing", type: Boolean }, playLabel: { attribute: "play-label" }, pauseLabel: { attribute: "pause-label" }, timeLabel: { attribute: "time-label" }, speedLabel: { attribute: "speed-label" } }; }
432
429
  render() {
433
430
  this.classList.add("c-time-slider");
431
+ if (!this.hasAttribute("role")) this.setAttribute("role", "group");
432
+ if (!this.hasAttribute("aria-label")) this.setAttribute("aria-label", this.getAttribute("label") || "Time slider");
434
433
  const play = this.ensure(".c-time-slider__play", () => {
435
434
  const el = document.createElement("button");
436
435
  el.className = "c-time-slider__play";
@@ -445,7 +444,11 @@ class ContourTimeSlider extends ContourBase {
445
444
  el.appendChild(svg);
446
445
  return el;
447
446
  });
448
- const track = this.ensure(".c-time-slider__track", () => { const el = document.createElement("input"); el.className = "c-time-slider__track"; el.type = "range"; el.min = "0"; el.max = "100"; el.setAttribute("aria-label", this.getAttribute("time-label") || "Time"); return el; });
447
+ const track = this.ensure(".c-time-slider__track", () => { const el = document.createElement("input"); el.className = "c-time-slider__track"; el.type = "range"; el.min = "0"; el.max = "100"; el.setAttribute("part", "input"); el.setAttribute("aria-label", this.getAttribute("time-label") || "Time"); return el; });
448
+ // min/max are attributes, not factory constants (R20 T-30): the guide's
449
+ // own 17d snippet passes them and they used to be ignored.
450
+ track.min = this.getAttribute("min") || "0";
451
+ track.max = this.getAttribute("max") || "100";
449
452
  const _attrVal = this.getAttribute("value") || "0";
450
453
  if (this._timeSliderAttrLast !== _attrVal) {
451
454
  track.value = _attrVal;
@@ -454,7 +457,9 @@ class ContourTimeSlider extends ContourBase {
454
457
  track.setAttribute("aria-label", this.getAttribute("label") || this.getAttribute("time-label") || "Time");
455
458
  const time = this.ensure(".c-time-slider__time", () => { const el = document.createElement("span"); el.className = "c-time-slider__time"; return el; });
456
459
  const ct = this.getAttribute("current-time");
457
- time.textContent = ct ? ct : (this.getAttribute("label") || "");
460
+ time.textContent = ct ? ct : String(track.value);
461
+ if (ct) track.setAttribute("aria-valuetext", ct);
462
+ else track.removeAttribute("aria-valuetext");
458
463
  // speed selector
459
464
  let speeds = null;
460
465
  const speedsAttr = this.getAttribute("speeds");
@@ -481,64 +486,82 @@ class ContourTimeSlider extends ContourBase {
481
486
  const lb = this.querySelector(".c-time-slider__loop");
482
487
  if (lb) lb.remove();
483
488
  }
484
- // is-playing reflects on play button
485
- if (this.hasAttribute("is-playing")) {
486
- play.setAttribute("data-state", "pause");
487
- play.setAttribute("aria-label", this.getAttribute("pause-label") || "Pause");
488
- const use = play.querySelector("use");
489
- if (use) use.setAttribute("href", "#i-pause");
490
- }
489
+ // is-playing reflects on play button, both directions (R20 T-30).
490
+ const playing = this.hasAttribute("is-playing");
491
+ play.setAttribute("data-state", playing ? "pause" : "play");
492
+ play.setAttribute("aria-label", playing ? (this.getAttribute("pause-label") || "Pause") : (this.getAttribute("play-label") || "Play"));
493
+ const use = play.querySelector("use");
494
+ if (use) use.setAttribute("href", playing ? "#i-pause" : "#i-play");
491
495
  }
492
496
  enhance() {
497
+ // Playback reconciles with the is-playing attribute on EVERY render
498
+ // (R20 T-30): setting the attribute from outside starts the timer and
499
+ // removing it stops — it used to swap only the icon, contradicting the
500
+ // attribute-driven playback prose. The reconciler owns the play/pause
501
+ // events so every path (click, attribute, end-of-track) emits once.
502
+ if (this._timeSliderReconcile) this._timeSliderReconcile();
493
503
  if (this._wiredTimeSlider) return;
494
504
  this._wiredTimeSlider = true;
495
- // Play advances the track one step per second and announces each move as
496
- // contour:time-change, so a dashboard can animate a chart in lockstep.
505
+ // Play advances the track one step per cadence and announces each move
506
+ // as contour:time-change, so a dashboard can animate a chart in lockstep.
497
507
  // The loop stops at max, or on a second click, or when the host leaves
498
508
  // the page (the disposer is registered once, like the loader's).
499
509
  let timer = undefined;
500
510
  const stop = () => { if (timer !== undefined) { clearInterval(timer); timer = undefined; } };
511
+ const syncReadout = () => {
512
+ const track = this.querySelector(".c-time-slider__track");
513
+ if (!track) return;
514
+ const time = this.querySelector(".c-time-slider__time");
515
+ const ct = this.getAttribute("current-time");
516
+ if (time) time.textContent = ct ? ct : String(track.value);
517
+ if (ct) track.setAttribute("aria-valuetext", ct);
518
+ else track.removeAttribute("aria-valuetext");
519
+ };
501
520
  const step = () => {
502
521
  const track = this.querySelector(".c-time-slider__track");
503
522
  if (!track) { stop(); return; }
504
523
  const max = Number(track.max) || 100;
524
+ const min = Number(track.min) || 0;
505
525
  const loop = this.hasAttribute("loop");
506
526
  let next = (Number(track.value) || 0) + 1;
507
- if (next > max) {
508
- if (loop) next = 0;
509
- else next = max;
510
- }
527
+ if (next > max) next = loop ? min : max;
511
528
  track.value = String(next);
529
+ // The playhead writes back so a consumer reading `value` sees it —
530
+ // but not while the user is mid-gesture: the write re-renders, and a
531
+ // rebuilt node would break a track drag or close an open speed popup.
532
+ // The next tick after the gesture ends catches the attribute up.
533
+ const speedSel = this.querySelector(".c-time-slider__speed");
534
+ const interacting = this._timeSliderScrubbing || (speedSel && document.activeElement === speedSel);
535
+ if (!interacting) this.setAttribute("value", String(next));
536
+ syncReadout();
512
537
  this.dispatchEvent(new CustomEvent("contour:time-change", { detail: { value: String(next) }, bubbles: true, composed: true }));
513
538
  if (!loop && next >= max) {
514
539
  stop();
515
- const btn = this.querySelector(".c-time-slider__play");
516
- if (btn) {
517
- btn.setAttribute("data-state", "play");
518
- btn.setAttribute("aria-label", this.getAttribute("play-label") || "Play");
519
- const use = btn.querySelector("use");
520
- if (use) use.setAttribute("href", "#i-play");
521
- }
540
+ this.removeAttribute("is-playing");
541
+ this.dispatchEvent(new CustomEvent("contour:pause", { bubbles: true, composed: true }));
542
+ }
543
+ };
544
+ const start = () => {
545
+ stop();
546
+ const speed = parseFloat(this.getAttribute("speed") || "1") || 1;
547
+ timer = setInterval(step, Math.max(100, 1000 / speed));
548
+ };
549
+ this._timeSliderReconcile = () => {
550
+ const want = this.hasAttribute("is-playing");
551
+ if (want && timer === undefined) {
552
+ start();
553
+ this.dispatchEvent(new CustomEvent("contour:play", { bubbles: true, composed: true }));
554
+ } else if (!want && timer !== undefined) {
555
+ stop();
556
+ this.dispatchEvent(new CustomEvent("contour:pause", { bubbles: true, composed: true }));
522
557
  }
523
558
  };
524
559
  this.addEventListener("click", (e) => {
525
560
  const btn = e.target && e.target.closest ? e.target.closest(".c-time-slider__play") : null;
526
561
  if (btn) {
527
- const playing = btn.getAttribute("data-state") === "play";
528
- btn.setAttribute("data-state", playing ? "pause" : "play");
529
- btn.setAttribute("aria-label", playing ? (this.getAttribute("pause-label") || "Pause") : (this.getAttribute("play-label") || "Play"));
530
- const use = btn.querySelector("use");
531
- if (use) use.setAttribute("href", playing ? "#i-pause" : "#i-play");
532
- if (playing) {
533
- stop();
534
- const speed = parseFloat(this.getAttribute("speed") || "1") || 1;
535
- const delay = Math.max(100, 1000 / speed);
536
- timer = setInterval(step, delay);
537
- this.dispatchEvent(new CustomEvent("contour:play", { bubbles: true, composed: true }));
538
- } else {
539
- stop();
540
- this.dispatchEvent(new CustomEvent("contour:pause", { bubbles: true, composed: true }));
541
- }
562
+ // The attribute is the source of truth: toggling it re-renders the
563
+ // icon and the reconciler starts/stops the timer and emits.
564
+ this.toggleAttribute("is-playing", !this.hasAttribute("is-playing"));
542
565
  return;
543
566
  }
544
567
  const loopBtn = e.target && e.target.closest ? e.target.closest(".c-time-slider__loop") : null;
@@ -549,18 +572,49 @@ class ContourTimeSlider extends ContourBase {
549
572
  this.dispatchEvent(new CustomEvent("contour:loop-change", { detail: { loop: next }, bubbles: true, composed: true }));
550
573
  }
551
574
  });
552
- // speed select change (delegated)
575
+ // Manual scrubbing is a first-class input (R20 T-30): it emits the same
576
+ // contour:time-change playback does and writes the playhead back. The
577
+ // track used to be silent under the user's hand.
578
+ // Track the drag so playhead writeback never rebuilds the node under
579
+ // the user's pointer; the commit (change) writes the value back.
580
+ this.addEventListener("pointerdown", (e) => {
581
+ if (e.target && e.target.closest && e.target.closest(".c-time-slider__track")) this._timeSliderScrubbing = true;
582
+ }, { passive: true });
583
+ const endScrub = () => { this._timeSliderScrubbing = false; };
584
+ this.addEventListener("pointerup", endScrub, { passive: true });
585
+ this.addEventListener("pointercancel", endScrub, { passive: true });
586
+ this.addEventListener("input", (e) => {
587
+ const track = e.target && e.target.closest ? e.target.closest(".c-time-slider__track") : null;
588
+ if (!track) return;
589
+ if (!this._timeSliderScrubbing) this.setAttribute("value", track.value);
590
+ syncReadout();
591
+ this.dispatchEvent(new CustomEvent("contour:time-change", { detail: { value: track.value }, bubbles: true, composed: true }));
592
+ });
553
593
  this.addEventListener("change", (e) => {
554
594
  const sel = e.target && e.target.closest ? e.target.closest(".c-time-slider__speed") : null;
555
- if (!sel) return;
556
- const speed = Number(sel.value);
557
- this.dispatchEvent(new CustomEvent("contour:speed-change", { detail: { speed }, bubbles: true, composed: true }));
595
+ if (sel) {
596
+ const speed = Number(sel.value);
597
+ this.setAttribute("speed", String(speed));
598
+ // A speed change mid-play restarts the interval at the new cadence.
599
+ if (timer !== undefined) start();
600
+ this.dispatchEvent(new CustomEvent("contour:speed-change", { detail: { speed }, bubbles: true, composed: true }));
601
+ return;
602
+ }
603
+ const track = e.target && e.target.closest ? e.target.closest(".c-time-slider__track") : null;
604
+ if (track) {
605
+ this.setAttribute("value", track.value);
606
+ syncReadout();
607
+ }
558
608
  });
559
609
  onDispose(this, stop);
610
+ this._timeSliderReconcile();
560
611
  }
561
612
  disconnectedCallback() {
562
613
  super.disconnectedCallback();
563
614
  this._wiredTimeSlider = false;
615
+ // Drop the stale closure too: a reconnect re-wires, and the old
616
+ // reconciler would start a second timer over the new one.
617
+ this._timeSliderReconcile = null;
564
618
  }
565
619
  }
566
620
  define("contour-time-slider", ContourTimeSlider);
@@ -569,8 +623,9 @@ class ContourHexbin extends ContourBase {
569
623
  static get properties() { return { label: { attribute: "label" }, cells: { attribute: "cells" }, src: { attribute: "src" } }; }
570
624
  render() {
571
625
  this.classList.add("c-hexbin");
572
- this.setAttribute("role", "img");
573
- this.setAttribute("aria-label", "Hexbin");
626
+ // Cells are focusable marks; role=img makes them presentational.
627
+ if (!this.hasAttribute("role")) this.setAttribute("role", "group");
628
+ if (!this.hasAttribute("aria-label")) this.setAttribute("aria-label", this.getAttribute("label") || "Hexbin");
574
629
  const label = this.getAttribute("label") || (this._remoteData && this._remoteData.label);
575
630
  if (label) {
576
631
  const l = this.ensure(".c-hexbin__label", () => { const el = document.createElement("span"); el.className = "c-hexbin__label"; return el; });
@@ -610,7 +665,7 @@ class ContourHexbin extends ContourBase {
610
665
  });
611
666
  const tip = this.ensure(".c-hexbin__tooltip", () => { const el = document.createElement("div"); el.className = "c-hexbin__tooltip"; el.setAttribute("role", "tooltip"); el.setAttribute("hidden", ""); return el; });
612
667
  tip.setAttribute("hidden", "");
613
- } catch (e) { /* keep existing */ }
668
+ } catch (e) { warnBadJson(this, "attribute", e); }
614
669
  } else if (!parsed) {
615
670
  Array.from(this.querySelectorAll(".c-hexbin__cell")).forEach((n) => n.remove());
616
671
  renderEmpty(this, "hexbin");
@@ -628,8 +683,9 @@ class ContourFlowMap extends ContourBase {
628
683
  static get properties() { return { label: { attribute: "label" }, nodes: { attribute: "nodes" }, src: { attribute: "src" } }; }
629
684
  render() {
630
685
  this.classList.add("c-flow-map");
631
- this.setAttribute("role", "img");
632
- this.setAttribute("aria-label", "Flow map");
686
+ // Nodes are focusable marks; role=img makes them presentational.
687
+ if (!this.hasAttribute("role")) this.setAttribute("role", "group");
688
+ if (!this.hasAttribute("aria-label")) this.setAttribute("aria-label", this.getAttribute("label") || "Flow map");
633
689
  const label = this.getAttribute("label") || (this._remoteData && this._remoteData.label);
634
690
  if (label) {
635
691
  const l = this.ensure(".c-flow-map__label", () => { const el = document.createElement("span"); el.className = "c-flow-map__label"; return el; });
@@ -666,7 +722,7 @@ class ContourFlowMap extends ContourBase {
666
722
  });
667
723
  const tip = this.ensure(".c-flow-map__tooltip", () => { const el = document.createElement("div"); el.className = "c-flow-map__tooltip"; el.setAttribute("role", "tooltip"); el.setAttribute("hidden", ""); return el; });
668
724
  tip.setAttribute("hidden", "");
669
- } catch (e) { /* keep existing */ }
725
+ } catch (e) { warnBadJson(this, "attribute", e); }
670
726
  } else if (!parsed) {
671
727
  Array.from(this.querySelectorAll(".c-flow-map__node")).forEach((n) => n.remove());
672
728
  renderEmpty(this, "flow-map");
@@ -684,8 +740,9 @@ class ContourIsochrone extends ContourBase {
684
740
  static get properties() { return { label: { attribute: "label" }, center: { attribute: "center" }, rings: { attribute: "rings" }, src: { attribute: "src" } }; }
685
741
  render() {
686
742
  this.classList.add("c-isochrone");
687
- this.setAttribute("role", "img");
688
- this.setAttribute("aria-label", "Isochrone");
743
+ // Rings are focusable marks; role=img makes them presentational.
744
+ if (!this.hasAttribute("role")) this.setAttribute("role", "group");
745
+ if (!this.hasAttribute("aria-label")) this.setAttribute("aria-label", this.getAttribute("label") || "Isochrone");
689
746
  const label = this.getAttribute("label") || (this._remoteData && this._remoteData.label);
690
747
  if (label) {
691
748
  const l = this.ensure(".c-isochrone__label", () => { const el = document.createElement("span"); el.className = "c-isochrone__label"; return el; });
@@ -722,14 +779,21 @@ class ContourIsochrone extends ContourBase {
722
779
  Array.from(this.querySelectorAll(".c-isochrone__ring")).forEach((n) => n.remove());
723
780
  parsed.forEach((r, i) => {
724
781
  const ring = document.createElement("span");
725
- ring.className = "c-isochrone__ring c-isochrone__ring--" + (r.label || r);
782
+ // A ring may be a string or an object. Concatenating the object put
783
+ // "[object Object]" in the class list and produced two bogus classes
784
+ // for a label containing a space; the modifier is one slug now.
785
+ const raw = typeof r === "string" ? r : (r && (r.label || r.name || r.value || r.min));
786
+ const ringLabel = raw === undefined || raw === null ? "" : String(raw);
787
+ const slug = ringLabel.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "");
788
+ ring.className = "c-isochrone__ring" + (slug ? " c-isochrone__ring--" + slug : "");
726
789
  ring.setAttribute("tabindex", i === 0 ? "0" : "-1");
727
- if (r.label) ring.setAttribute("title", r.label || r);
790
+ ring.setAttribute("aria-label", ringLabel || "Isochrone ring " + (i + 1));
791
+ if (ringLabel) ring.setAttribute("title", ringLabel);
728
792
  this.appendChild(ring);
729
793
  });
730
794
  const tip = this.ensure(".c-isochrone__tooltip", () => { const el = document.createElement("div"); el.className = "c-isochrone__tooltip"; el.setAttribute("role", "tooltip"); el.setAttribute("hidden", ""); return el; });
731
795
  tip.setAttribute("hidden", "");
732
- } catch (e) { /* keep existing */ }
796
+ } catch (e) { warnBadJson(this, "attribute", e); }
733
797
  } else if (!parsed) {
734
798
  Array.from(this.querySelectorAll(".c-isochrone__ring")).forEach((n) => n.remove());
735
799
  renderEmpty(this, "isochrone");
@@ -747,8 +811,8 @@ class ContourCatchment extends ContourBase {
747
811
  static get properties() { return { label: { attribute: "label" }, area: { attribute: "area" }, center: { attribute: "center" }, src: { attribute: "src" } }; }
748
812
  render() {
749
813
  this.classList.add("c-catchment");
750
- this.setAttribute("role", "img");
751
- this.setAttribute("aria-label", "Catchment");
814
+ if (!this.hasAttribute("role")) this.setAttribute("role", "img");
815
+ if (!this.hasAttribute("aria-label")) this.setAttribute("aria-label", this.getAttribute("label") || "Catchment");
752
816
  const label = this.getAttribute("label") || (this._remoteData && this._remoteData.label);
753
817
  if (label) {
754
818
  const l = this.ensure(".c-catchment__label", () => { const el = document.createElement("span"); el.className = "c-catchment__label"; return el; });
@@ -821,6 +885,7 @@ class ContourCompassFull extends ContourBase {
821
885
  static get properties() { return { label: { attribute: "label" }, needle: { attribute: "needle" }, src: { attribute: "src" } }; }
822
886
  render() {
823
887
  this.classList.add("c-compass");
888
+ if (!this.hasAttribute("aria-label")) this.setAttribute("aria-label", this.getAttribute("label") || "Compass");
824
889
  const label = this.getAttribute("label") || (this._remoteData && this._remoteData.label);
825
890
  wireStates(this);
826
891
  loadRemote(this, "needle");
@@ -953,7 +1018,7 @@ class ContourLayerSwitch extends ContourBase {
953
1018
  item.appendChild(toggle);
954
1019
  this.appendChild(item);
955
1020
  });
956
- } catch (e) { /* keep existing */ }
1021
+ } catch (e) { warnBadJson(this, "attribute", e); }
957
1022
  } else if (!items && !authored.length) {
958
1023
  Array.from(this.querySelectorAll(".c-layer-switch__item")).forEach((n) => n.remove());
959
1024
  renderEmpty(this, "layer-switch");
@@ -1016,6 +1081,8 @@ class ContourMapArea extends ContourBase {
1016
1081
  static get properties() { return { attribution: { attribute: "attribution" }, "attribution-mark": { attribute: "attribution-mark" }, scale: { attribute: "scale" }, controls: { attribute: "controls" } }; }
1017
1082
  render() {
1018
1083
  this.classList.add("c-map-area");
1084
+ if (!this.hasAttribute("role")) this.setAttribute("role", "region");
1085
+ if (!this.hasAttribute("aria-label")) this.setAttribute("aria-label", "Map area");
1019
1086
  const attribution = this.getAttribute("attribution");
1020
1087
  if (attribution) {
1021
1088
  const a = this.ensure(".c-map-slot__attribution", () => { const el = document.createElement("div"); el.className = "c-map-slot__attribution"; return el; });
@@ -1053,7 +1120,7 @@ class ContourMapArea extends ContourBase {
1053
1120
  btn.textContent = typeof c === "string" ? c : (c.label || c);
1054
1121
  wrap.appendChild(btn);
1055
1122
  });
1056
- } catch (e) { /* keep existing */ }
1123
+ } catch (e) { warnBadJson(this, "attribute", e); }
1057
1124
  } else {
1058
1125
  const w = this.querySelector(".c-map-slot__controls");
1059
1126
  if (w) w.remove();
@@ -1117,10 +1184,10 @@ class ContourMapFooter extends ContourBase {
1117
1184
  // The footer's own rule is `.c-map-footer > *`, which reaches any direct
1118
1185
  // child, so the brand is a plain span: visible, and inventing no name.
1119
1186
  if (brand) {
1120
- const b = this.ensure("[data-map-footer-brand]", () => { const el = document.createElement("span"); el.setAttribute("data-map-footer-brand", ""); return el; });
1187
+ const b = this.ensure(".c-map-footer__brand", () => { const el = document.createElement("span"); el.className = "c-map-footer__brand"; return el; });
1121
1188
  b.textContent = brand;
1122
1189
  } else {
1123
- const b = this.querySelector("[data-map-footer-brand]");
1190
+ const b = this.querySelector(".c-map-footer__brand");
1124
1191
  if (b) b.remove();
1125
1192
  }
1126
1193
  }