contour-ds 1.1.1 → 1.5.0

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 (72) hide show
  1. package/README.md +7 -1
  2. package/dist/agent-rules.json +5 -1
  3. package/dist/build-manifest.json +96 -95
  4. package/dist/contour-wc.esm.js +4402 -493
  5. package/dist/contour-wc.esm.min.js +1 -1
  6. package/dist/contour-wc.js +4399 -486
  7. package/dist/contour-wc.min.js +1 -1
  8. package/dist/contour.components.json +2628 -146
  9. package/dist/contour.css +640 -28
  10. package/dist/contour.d.ts +110 -61
  11. package/dist/contour.esm.js +16 -0
  12. package/dist/contour.js +16 -0
  13. package/dist/contour.min.css +1 -1
  14. package/dist/contour.themes.json +4 -1
  15. package/dist/contour.tokens.json +40 -0
  16. package/dist/docs/actions.md +6 -2
  17. package/dist/docs/affordances.md +19 -3
  18. package/dist/docs/colour.md +2 -2
  19. package/dist/docs/componentindex.md +39 -0
  20. package/dist/docs/data.md +38 -3
  21. package/dist/docs/docs.md +6 -2
  22. package/dist/docs/feedback.md +13 -3
  23. package/dist/docs/field.md +7 -2
  24. package/dist/docs/forms.md +35 -3
  25. package/dist/docs/index.json +32 -76
  26. package/dist/docs/install.md +4 -2
  27. package/dist/docs/landing.md +3 -2
  28. package/dist/docs/mapengine.md +9 -3
  29. package/dist/docs/motion.md +5 -2
  30. package/dist/docs/navigation.md +10 -3
  31. package/dist/docs/overlays.md +26 -3
  32. package/dist/docs/overview.md +2 -2
  33. package/dist/docs/patterns.md +38 -3
  34. package/dist/docs/playground.md +5 -2
  35. package/dist/docs/principles.md +2 -2
  36. package/dist/docs/recipes.md +7 -3
  37. package/dist/docs/space.md +2 -2
  38. package/dist/docs/status.md +19 -3
  39. package/dist/docs/surfaces.md +7 -3
  40. package/dist/docs/theming.md +5 -2
  41. package/dist/docs/type.md +2 -2
  42. package/dist/docs/webcomponents.md +26 -3
  43. package/dist/map-chrome.mapbox.css +4 -4
  44. package/dist/map-chrome.maplibre.css +4 -4
  45. package/dist/registry/items/contour-core.json +2 -2
  46. package/dist/registry/items/contour-data.json +2 -2
  47. package/dist/registry/items/contour-docs.json +2 -2
  48. package/dist/registry/items/contour-landing.json +2 -2
  49. package/dist/registry/registry.json +8 -8
  50. package/dist/surfaces/contour-core.min.css +1 -1
  51. package/dist/surfaces/contour-data.min.css +1 -1
  52. package/dist/surfaces/contour-docs.min.css +1 -1
  53. package/dist/surfaces/contour-landing.min.css +1 -1
  54. package/dist/wc/behaviours.mjs +69 -11
  55. package/dist/wc/content.mjs +163 -8
  56. package/dist/wc/core.mjs +151 -33
  57. package/dist/wc/dashboard.mjs +69 -4
  58. package/dist/wc/data.mjs +1011 -104
  59. package/dist/wc/docs.mjs +1 -0
  60. package/dist/wc/feedback.mjs +75 -13
  61. package/dist/wc/forms.mjs +371 -34
  62. package/dist/wc/index.mjs +7 -3
  63. package/dist/wc/interaction.mjs +11 -6
  64. package/dist/wc/map.mjs +184 -49
  65. package/dist/wc/misc.mjs +29 -1
  66. package/dist/wc/navigation.mjs +424 -75
  67. package/dist/wc/registration.mjs +8 -4
  68. package/dist/wc/shadow.mjs +29 -12
  69. package/dist/wc/states.mjs +15 -0
  70. package/dist/wc/svg.mjs +10 -0
  71. package/dist/wc/ui.mjs +1781 -136
  72. package/package.json +39 -6
package/dist/wc/map.mjs CHANGED
@@ -75,6 +75,8 @@ class ContourMinimap extends ContourBase {
75
75
  static get properties() { return { label: { attribute: "label" }, viewport: { attribute: "viewport" }, src: { attribute: "src" } }; }
76
76
  render() {
77
77
  this.classList.add("c-minimap");
78
+ this.setAttribute("role", "img");
79
+ this.setAttribute("aria-label", "Minimap");
78
80
  wireStates(this);
79
81
  loadRemote(this, ["label", "viewport"]);
80
82
  if (renderStates(this, "minimap")) return;
@@ -102,6 +104,7 @@ class ContourMinimap extends ContourBase {
102
104
  enhance() {
103
105
  if (this._wiredMinimap) return;
104
106
  this._wiredMinimap = true;
107
+ if (!this.hasAttribute("tabindex")) this.setAttribute("tabindex", "0");
105
108
  let dragging = false;
106
109
  this.addEventListener("pointerdown", (e) => {
107
110
  const vp = this.querySelector(".c-minimap__viewport");
@@ -114,12 +117,24 @@ class ContourMinimap extends ContourBase {
114
117
  this.dispatchEvent(new CustomEvent("contour:move", { detail: { direction: "drag" }, bubbles: true, composed: true }));
115
118
  });
116
119
  this.addEventListener("pointerup", () => { dragging = false; });
120
+ this.addEventListener("keydown", (e) => {
121
+ let dir = null;
122
+ if (e.key === "ArrowUp") dir = "up";
123
+ else if (e.key === "ArrowDown") dir = "down";
124
+ else if (e.key === "ArrowLeft") dir = "left";
125
+ else if (e.key === "ArrowRight") dir = "right";
126
+ else if (e.key === "Home") dir = "home";
127
+ else if (e.key === "End") dir = "end";
128
+ if (!dir) return;
129
+ e.preventDefault();
130
+ this.dispatchEvent(new CustomEvent("contour:move", { detail: { direction: dir }, bubbles: true, composed: true }));
131
+ });
117
132
  }
118
133
  }
119
134
  define("contour-minimap", ContourMinimap);
120
135
  class ContourCoordinate extends ContourBase {
121
- static get observed() { return ["value", "format", "locale", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton"]; }
122
- static get properties() { return { value: { attribute: "value" }, format: { attribute: "format" }, locale: { attribute: "locale" }, src: { attribute: "src" } }; }
136
+ static get observed() { return ["value", "format", "locale", "precision", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton"]; }
137
+ static get properties() { return { value: { attribute: "value" }, format: { attribute: "format" }, locale: { attribute: "locale" }, precision: { attribute: "precision" }, src: { attribute: "src" } }; }
123
138
  render() {
124
139
  this.classList.add("c-coordinate");
125
140
  wireStates(this);
@@ -136,13 +151,16 @@ class ContourCoordinate extends ContourBase {
136
151
  // simple DMS conversion assuming decimal degrees "lat,lon"
137
152
  const parts = String(value).split(/[,\s]+/).map(Number);
138
153
  if (parts.length >= 2 && Number.isFinite(parts[0]) && Number.isFinite(parts[1])) {
139
- const toDMS = (d) => {
154
+ const prec = parseInt(this.getAttribute("precision") || "1", 10);
155
+ const secDigits = Number.isFinite(prec) && prec >= 0 ? prec : 1;
156
+ const toDMS = (d, axis) => {
140
157
  const deg = Math.floor(Math.abs(d));
141
158
  const min = Math.floor((Math.abs(d) - deg) * 60);
142
159
  const sec = (((Math.abs(d) - deg) * 60) - min) * 60;
143
- return deg + "°" + min + "'" + sec.toFixed(1) + '"' + (d < 0 ? "S" : "N");
160
+ const hemi = axis === "lat" ? (d < 0 ? "S" : "N") : (d < 0 ? "W" : "E");
161
+ return deg + "°" + min + "'" + sec.toFixed(secDigits) + '"' + hemi;
144
162
  };
145
- text = toDMS(parts[0]) + " " + toDMS(parts[1]);
163
+ text = toDMS(parts[0], "lat") + " " + toDMS(parts[1], "lon");
146
164
  }
147
165
  } else if (format === "web-mercator") {
148
166
  const parts = String(value).split(/[,\s]+/).map(Number);
@@ -154,7 +172,7 @@ class ContourCoordinate extends ContourBase {
154
172
  } else {
155
173
  text = formatValue(value, this.getAttribute("format"), this.getAttribute("locale"));
156
174
  }
157
- const span = this.ensure(".c-coordinate__value", () => { const el = document.createElement("span"); el.className = "c-coordinate__value"; return el; });
175
+ const span = this.ensure(".c-coordinate__value", () => { const el = document.createElement("span"); el.className = "c-coordinate__value"; el.setAttribute("role", "status"); el.setAttribute("aria-live", "polite"); return el; });
158
176
  span.textContent = text;
159
177
  // copy button
160
178
  let btn = this.querySelector(".c-coordinate__copy");
@@ -189,6 +207,8 @@ class ContourLayerPanel extends ContourBase {
189
207
  static get properties() { return { label: { attribute: "label" }, items: { attribute: "items" }, src: { attribute: "src" } }; }
190
208
  render() {
191
209
  this.classList.add("c-layer-panel");
210
+ this.setAttribute("role", "group");
211
+ this.setAttribute("aria-label", "Layer panel");
192
212
  wireStates(this);
193
213
  loadRemote(this, "items");
194
214
  if (renderStates(this, "layer-panel")) return;
@@ -244,7 +264,7 @@ class ContourLayerPanel extends ContourBase {
244
264
  const isVisible = savedVisibility.has(name) ? savedVisibility.get(name) : (typeof it === "object" && it.visible !== false);
245
265
  toggle.setAttribute("aria-pressed", String(!!isVisible));
246
266
  toggle.checked = !!isVisible;
247
- toggle.textContent = isVisible ? "●" : "○";
267
+ toggle.innerHTML = isVisible ? '<svg aria-hidden="true"><use href="#i-check" /></svg>' : '<svg aria-hidden="true"><use href="#i-minus" /></svg>';
248
268
  item.appendChild(toggle);
249
269
  const nm = document.createElement("span");
250
270
  nm.className = "c-layer-panel__name";
@@ -293,12 +313,12 @@ class ContourLayerPanel extends ContourBase {
293
313
  const removeBtn = document.createElement("button");
294
314
  removeBtn.type = "button";
295
315
  removeBtn.className = "c-layer-panel__remove";
296
- removeBtn.textContent = "✕";
316
+ removeBtn.innerHTML = '<svg aria-hidden="true"><use href="#i-minus" /></svg>';
297
317
  removeBtn.setAttribute("aria-label", "Remove " + (name || "layer"));
298
318
  item.appendChild(removeBtn);
299
319
  }
300
320
  const projSel = document.createElement("select");
301
- projSel.className = "c-layer-panel__projection";
321
+ projSel.className = "c-select c-layer-panel__projection";
302
322
  projSel.setAttribute("aria-label", "Projection of " + (name || "layer"));
303
323
  ["EPSG:4326","EPSG:3857"].forEach((p) => { const o = document.createElement("option"); o.value = p; o.textContent = p; projSel.appendChild(o); });
304
324
  item.appendChild(projSel);
@@ -323,7 +343,7 @@ class ContourLayerPanel extends ContourBase {
323
343
  const now = (typeof e.target.checked === "boolean") ? e.target.checked : (e.target.getAttribute("aria-pressed") !== "true");
324
344
  e.target.checked = now;
325
345
  e.target.setAttribute("aria-pressed", String(now));
326
- e.target.textContent = now ? "●" : "○";
346
+ e.target.innerHTML = now ? '<svg aria-hidden="true"><use href="#i-check" /></svg>' : '<svg aria-hidden="true"><use href="#i-minus" /></svg>';
327
347
  this.dispatchEvent(new CustomEvent("contour:layer-visibility", { bubbles: true, composed: true, detail: { name, visible: now } }));
328
348
  } else if (e.target.classList.contains("c-layer-panel__opacity")) {
329
349
  this.dispatchEvent(new CustomEvent("contour:layer-opacity", { bubbles: true, composed: true, detail: { name, opacity: Number(e.target.value) } }));
@@ -341,19 +361,35 @@ class ContourLayerPanel extends ContourBase {
341
361
  const now = btn.getAttribute("aria-pressed") !== "true";
342
362
  btn.setAttribute("aria-pressed", String(now));
343
363
  btn.checked = now;
344
- btn.textContent = now ? "●" : "○";
364
+ btn.innerHTML = now ? '<svg aria-hidden="true"><use href="#i-check" /></svg>' : '<svg aria-hidden="true"><use href="#i-minus" /></svg>';
345
365
  this.dispatchEvent(new CustomEvent("contour:layer-visibility", { bubbles: true, composed: true, detail: { name, visible: now } }));
346
366
  return;
347
367
  }
348
368
  if (!item) return;
349
369
  const name = item.querySelector(".c-layer-panel__name")?.textContent || "";
350
370
  if (btn.classList.contains("c-layer-panel__rename")) {
351
- const newName = prompt("Rename layer", name);
352
- const trimmed = newName ? newName.trim() : "";
353
- if (trimmed && trimmed !== name) {
354
- const nm = item.querySelector(".c-layer-panel__name");
355
- if (nm) nm.textContent = trimmed;
356
- this.dispatchEvent(new CustomEvent("contour:layer-rename", { bubbles: true, composed: true, detail: { name, newName: trimmed } }));
371
+ const nm = item.querySelector(".c-layer-panel__name");
372
+ if (nm) {
373
+ const input = document.createElement("input");
374
+ input.type = "text";
375
+ input.className = "c-input c-layer-panel__rename-input";
376
+ input.value = name;
377
+ input.setAttribute("aria-label", "Rename layer");
378
+ nm.replaceWith(input);
379
+ input.focus();
380
+ input.select();
381
+ const commit = () => {
382
+ const trimmed = (input.value || "").trim();
383
+ const span = document.createElement("span");
384
+ span.className = "c-layer-panel__name";
385
+ span.textContent = trimmed || name;
386
+ input.replaceWith(span);
387
+ if (trimmed && trimmed !== name) {
388
+ this.dispatchEvent(new CustomEvent("contour:layer-rename", { bubbles: true, composed: true, detail: { name, newName: trimmed } }));
389
+ }
390
+ };
391
+ input.addEventListener("keydown", (ev) => { if (ev.key === "Enter") { ev.preventDefault(); commit(); } else if (ev.key === "Escape") { ev.preventDefault(); input.value = name; commit(); } });
392
+ input.addEventListener("blur", commit, { once: true });
357
393
  }
358
394
  } else if (btn.classList.contains("c-layer-panel__duplicate")) {
359
395
  this.dispatchEvent(new CustomEvent("contour:layer-duplicate", { bubbles: true, composed: true, detail: { name } }));
@@ -391,15 +427,15 @@ class ContourLayerPanel extends ContourBase {
391
427
  }
392
428
  define("contour-layer-panel", ContourLayerPanel);
393
429
  class ContourTimeSlider extends ContourBase {
394
- static get observed() { return ["label", "value", "loop", "speed"]; }
395
- static get properties() { return { label: { attribute: "label" }, value: { attribute: "value" }, src: { attribute: "src" } }; }
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" } }; }
396
432
  render() {
397
433
  this.classList.add("c-time-slider");
398
434
  const play = this.ensure(".c-time-slider__play", () => {
399
435
  const el = document.createElement("button");
400
436
  el.className = "c-time-slider__play";
401
437
  el.type = "button";
402
- el.setAttribute("aria-label", "Play");
438
+ el.setAttribute("aria-label", this.getAttribute("play-label") || "Play");
403
439
  el.setAttribute("data-state", "play");
404
440
  const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
405
441
  svg.setAttribute("aria-hidden", "true");
@@ -409,15 +445,49 @@ class ContourTimeSlider extends ContourBase {
409
445
  el.appendChild(svg);
410
446
  return el;
411
447
  });
412
- 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", "Time"); return el; });
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; });
413
449
  const _attrVal = this.getAttribute("value") || "0";
414
450
  if (this._timeSliderAttrLast !== _attrVal) {
415
451
  track.value = _attrVal;
416
452
  this._timeSliderAttrLast = _attrVal;
417
453
  }
418
- track.setAttribute("aria-label", this.getAttribute("label") || "Time");
454
+ track.setAttribute("aria-label", this.getAttribute("label") || this.getAttribute("time-label") || "Time");
419
455
  const time = this.ensure(".c-time-slider__time", () => { const el = document.createElement("span"); el.className = "c-time-slider__time"; return el; });
420
- time.textContent = this.getAttribute("label") || "";
456
+ const ct = this.getAttribute("current-time");
457
+ time.textContent = ct ? ct : (this.getAttribute("label") || "");
458
+ // speed selector
459
+ let speeds = null;
460
+ const speedsAttr = this.getAttribute("speeds");
461
+ if (speedsAttr) { try { speeds = JSON.parse(speedsAttr); } catch (e) { speeds = null; } }
462
+ const speedSel = this.ensure(".c-time-slider__speed", () => { const el = document.createElement("select"); el.className = "c-select c-time-slider__speed"; el.setAttribute("aria-label", this.getAttribute("speed-label") || "Speed"); return el; });
463
+ speedSel.innerHTML = "";
464
+ const speedList = Array.isArray(speeds) ? speeds : [0.5, 1, 2, 5, 10];
465
+ speedList.forEach((sp) => {
466
+ const opt = document.createElement("option");
467
+ opt.value = String(sp);
468
+ opt.textContent = String(sp);
469
+ if (String(sp) === (this.getAttribute("speed") || "")) opt.selected = true;
470
+ speedSel.appendChild(opt);
471
+ });
472
+ const speedAttr = this.getAttribute("speed");
473
+ if (speedAttr) speedSel.value = speedAttr;
474
+ // loop toggle
475
+ const showLoop = this.hasAttribute("show-loop");
476
+ if (showLoop) {
477
+ 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; });
478
+ loopBtn.setAttribute("aria-pressed", this.hasAttribute("loop") ? "true" : "false");
479
+ loopBtn.textContent = this.getAttribute("loop-label") || "Loop";
480
+ } else {
481
+ const lb = this.querySelector(".c-time-slider__loop");
482
+ if (lb) lb.remove();
483
+ }
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
+ }
421
491
  }
422
492
  enhance() {
423
493
  if (this._wiredTimeSlider) return;
@@ -445,7 +515,7 @@ class ContourTimeSlider extends ContourBase {
445
515
  const btn = this.querySelector(".c-time-slider__play");
446
516
  if (btn) {
447
517
  btn.setAttribute("data-state", "play");
448
- btn.setAttribute("aria-label", "Play");
518
+ btn.setAttribute("aria-label", this.getAttribute("play-label") || "Play");
449
519
  const use = btn.querySelector("use");
450
520
  if (use) use.setAttribute("href", "#i-play");
451
521
  }
@@ -453,20 +523,38 @@ class ContourTimeSlider extends ContourBase {
453
523
  };
454
524
  this.addEventListener("click", (e) => {
455
525
  const btn = e.target && e.target.closest ? e.target.closest(".c-time-slider__play") : null;
456
- if (!btn) return;
457
- const playing = btn.getAttribute("data-state") === "play";
458
- btn.setAttribute("data-state", playing ? "pause" : "play");
459
- btn.setAttribute("aria-label", playing ? "Pause" : "Play");
460
- const use = btn.querySelector("use");
461
- if (use) use.setAttribute("href", playing ? "#i-pause" : "#i-play");
462
- if (playing) {
463
- stop();
464
- const speed = parseFloat(this.getAttribute("speed") || "1") || 1;
465
- const delay = Math.max(100, 1000 / speed);
466
- timer = setInterval(step, delay);
467
- } else {
468
- stop();
526
+ 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
+ }
542
+ return;
469
543
  }
544
+ const loopBtn = e.target && e.target.closest ? e.target.closest(".c-time-slider__loop") : null;
545
+ if (loopBtn) {
546
+ const next = loopBtn.getAttribute("aria-pressed") !== "true";
547
+ loopBtn.setAttribute("aria-pressed", String(next));
548
+ this.toggleAttribute("loop", next);
549
+ this.dispatchEvent(new CustomEvent("contour:loop-change", { detail: { loop: next }, bubbles: true, composed: true }));
550
+ }
551
+ });
552
+ // speed select change (delegated)
553
+ this.addEventListener("change", (e) => {
554
+ 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 }));
470
558
  });
471
559
  onDispose(this, stop);
472
560
  }
@@ -481,6 +569,8 @@ class ContourHexbin extends ContourBase {
481
569
  static get properties() { return { label: { attribute: "label" }, cells: { attribute: "cells" }, src: { attribute: "src" } }; }
482
570
  render() {
483
571
  this.classList.add("c-hexbin");
572
+ this.setAttribute("role", "img");
573
+ this.setAttribute("aria-label", "Hexbin");
484
574
  const label = this.getAttribute("label") || (this._remoteData && this._remoteData.label);
485
575
  if (label) {
486
576
  const l = this.ensure(".c-hexbin__label", () => { const el = document.createElement("span"); el.className = "c-hexbin__label"; return el; });
@@ -538,6 +628,8 @@ class ContourFlowMap extends ContourBase {
538
628
  static get properties() { return { label: { attribute: "label" }, nodes: { attribute: "nodes" }, src: { attribute: "src" } }; }
539
629
  render() {
540
630
  this.classList.add("c-flow-map");
631
+ this.setAttribute("role", "img");
632
+ this.setAttribute("aria-label", "Flow map");
541
633
  const label = this.getAttribute("label") || (this._remoteData && this._remoteData.label);
542
634
  if (label) {
543
635
  const l = this.ensure(".c-flow-map__label", () => { const el = document.createElement("span"); el.className = "c-flow-map__label"; return el; });
@@ -592,6 +684,8 @@ class ContourIsochrone extends ContourBase {
592
684
  static get properties() { return { label: { attribute: "label" }, center: { attribute: "center" }, rings: { attribute: "rings" }, src: { attribute: "src" } }; }
593
685
  render() {
594
686
  this.classList.add("c-isochrone");
687
+ this.setAttribute("role", "img");
688
+ this.setAttribute("aria-label", "Isochrone");
595
689
  const label = this.getAttribute("label") || (this._remoteData && this._remoteData.label);
596
690
  if (label) {
597
691
  const l = this.ensure(".c-isochrone__label", () => { const el = document.createElement("span"); el.className = "c-isochrone__label"; return el; });
@@ -653,6 +747,8 @@ class ContourCatchment extends ContourBase {
653
747
  static get properties() { return { label: { attribute: "label" }, area: { attribute: "area" }, center: { attribute: "center" }, src: { attribute: "src" } }; }
654
748
  render() {
655
749
  this.classList.add("c-catchment");
750
+ this.setAttribute("role", "img");
751
+ this.setAttribute("aria-label", "Catchment");
656
752
  const label = this.getAttribute("label") || (this._remoteData && this._remoteData.label);
657
753
  if (label) {
658
754
  const l = this.ensure(".c-catchment__label", () => { const el = document.createElement("span"); el.className = "c-catchment__label"; return el; });
@@ -711,6 +807,12 @@ class ContourCatchment extends ContourBase {
711
807
  if (!this.hasAttribute("tabindex")) this.setAttribute("tabindex", "0");
712
808
  this.addEventListener("focusin", showTip);
713
809
  this.addEventListener("focusout", hideTip);
810
+ this.addEventListener("keydown", (e) => {
811
+ if (e.key === "Enter" || e.key === " ") {
812
+ e.preventDefault();
813
+ this.dispatchEvent(new CustomEvent("contour:select", { bubbles: true, composed: true, detail: { area: this.getAttribute("area") } }));
814
+ }
815
+ });
714
816
  }
715
817
  }
716
818
  define("contour-catchment", ContourCatchment);
@@ -750,13 +852,20 @@ class ContourCompassFull extends ContourBase {
750
852
  el.setAttribute("class", "c-compass__needle");
751
853
  el.setAttribute("viewBox", "0 0 40 40");
752
854
  el.setAttribute("aria-hidden", "true");
753
- const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
754
- path.setAttribute("d", compassNeedle(20, 20, 16, deg));
755
- el.appendChild(path);
855
+ const pathN = document.createElementNS("http://www.w3.org/2000/svg", "path");
856
+ pathN.setAttribute("class", "c-compass__needle--n");
857
+ pathN.setAttribute("d", compassNeedle(20, 20, 16, deg));
858
+ el.appendChild(pathN);
859
+ const pathS = document.createElementNS("http://www.w3.org/2000/svg", "path");
860
+ pathS.setAttribute("class", "c-compass__needle--s");
861
+ pathS.setAttribute("d", compassNeedle(20, 20, 16, deg + 180));
862
+ el.appendChild(pathS);
756
863
  return el;
757
864
  });
758
- const path = n.querySelector("path");
759
- if (path) path.setAttribute("d", compassNeedle(20, 20, 16, deg));
865
+ const pathN = n.querySelector(".c-compass__needle--n");
866
+ if (pathN) pathN.setAttribute("d", compassNeedle(20, 20, 16, deg));
867
+ const pathS = n.querySelector(".c-compass__needle--s");
868
+ if (pathS) pathS.setAttribute("d", compassNeedle(20, 20, 16, deg + 180));
760
869
  } else {
761
870
  const n = this.querySelector("svg.c-compass__needle, .c-compass__needle");
762
871
  if (n) n.remove();
@@ -777,8 +886,10 @@ class ContourCompassFull extends ContourBase {
777
886
  if (deg === undefined) return;
778
887
  const n = this.querySelector(".c-compass__needle");
779
888
  if (n) {
780
- const path = n.querySelector("path");
781
- if (path) path.setAttribute("d", compassNeedle(20, 20, 16, deg));
889
+ const pathN = n.querySelector(".c-compass__needle--n");
890
+ if (pathN) pathN.setAttribute("d", compassNeedle(20, 20, 16, deg));
891
+ const pathS = n.querySelector(".c-compass__needle--s");
892
+ if (pathS) pathS.setAttribute("d", compassNeedle(20, 20, 16, deg + 180));
782
893
  }
783
894
  this.dispatchEvent(new CustomEvent("contour:bearing", { bubbles: true, composed: true, detail: { direction: dir, degrees: deg } }));
784
895
  };
@@ -817,9 +928,11 @@ class ContourLayerSwitch extends ContourBase {
817
928
  capped.forEach((it) => {
818
929
  const item = document.createElement("div");
819
930
  item.className = "c-layer-switch__item";
931
+ item.setAttribute("role", "group");
820
932
  const sw = document.createElement("span");
821
933
  sw.className = "c-layer-switch__swatch";
822
934
  if (it.color) sw.style.background = it.color;
935
+ sw.setAttribute("aria-hidden", "true");
823
936
  item.appendChild(sw);
824
937
  const name = document.createElement("span");
825
938
  name.className = "c-layer-switch__name";
@@ -835,6 +948,7 @@ class ContourLayerSwitch extends ContourBase {
835
948
  toggle.className = "c-layer-switch__toggle";
836
949
  toggle.type = "button";
837
950
  toggle.setAttribute("aria-label", "Toggle " + (typeof it === "string" ? it : (it.name || it.label || "layer")));
951
+ toggle.setAttribute("aria-pressed", "true");
838
952
  toggle.innerHTML = '<svg aria-hidden="true"><use href="#i-check" /></svg>';
839
953
  item.appendChild(toggle);
840
954
  this.appendChild(item);
@@ -853,7 +967,14 @@ class ContourLayerSwitch extends ContourBase {
853
967
  if (!btn || !this.contains(btn)) return;
854
968
  const item = btn.closest(".c-layer-switch__item");
855
969
  const name = item ? (item.querySelector(".c-layer-switch__name")?.textContent || "") : "";
856
- this.dispatchEvent(new CustomEvent("contour:layer-toggle", { bubbles: true, composed: true, detail: { name } }));
970
+ const now = btn.getAttribute("aria-pressed") !== "true";
971
+ btn.setAttribute("aria-pressed", String(now));
972
+ this.dispatchEvent(new CustomEvent("contour:layer-toggle", { bubbles: true, composed: true, detail: { name, visible: now } }));
973
+ });
974
+ this.addEventListener("keydown", (e) => {
975
+ const btn = e.target && e.target.closest ? e.target.closest(".c-layer-switch__toggle") : null;
976
+ if (!btn || !this.contains(btn)) return;
977
+ if (e.key === "Enter" || e.key === " ") { e.preventDefault(); btn.click(); }
857
978
  });
858
979
  }
859
980
  }
@@ -1006,14 +1127,29 @@ class ContourMapFooter extends ContourBase {
1006
1127
  }
1007
1128
  define("contour-map-footer", ContourMapFooter);
1008
1129
  class ContourScaleBar extends ContourBase {
1009
- static get observed() { return ["label", "value", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton"]; }
1010
- static get properties() { return { label: { attribute: "label" }, value: { attribute: "value" }, src: { attribute: "src" } }; }
1130
+ static get observed() { return ["label", "value", "distance", "resolution", "latitude", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton"]; }
1131
+ static get properties() { return { label: { attribute: "label" }, value: { attribute: "value" }, distance: { attribute: "distance" }, resolution: { attribute: "resolution" }, latitude: { attribute: "latitude" }, src: { attribute: "src" } }; }
1011
1132
  render() {
1012
1133
  this.classList.add("c-scale-bar");
1013
1134
  wireStates(this);
1014
1135
  loadRemote(this, ["label", "value"]);
1015
1136
  if (renderStates(this, "scale-bar")) return;
1016
- const label = remoteData(this, "label") || (this._remoteData && this._remoteData.label);
1137
+ let value = remoteData(this, "value") || (this._remoteData && this._remoteData.value);
1138
+ // BY-23: derive the bar width from map resolution + latitude when the
1139
+ // author gives a resolution (meters per pixel) instead of a raw pixel
1140
+ // length. A scale bar is a ground distance, so its pixel length is
1141
+ // distance / resolution; latitude is recorded for the Mercator-aware
1142
+ // consumers that read it back.
1143
+ const resolution = parseFloat(this.getAttribute("resolution"));
1144
+ let derivedLabel = null;
1145
+ if (Number.isFinite(resolution) && resolution > 0) {
1146
+ const distance = parseFloat(this.getAttribute("distance")) || 1000;
1147
+ value = String(Math.round(distance / resolution));
1148
+ if (!this.getAttribute("label") && !remoteData(this, "label")) {
1149
+ derivedLabel = distance >= 1000 ? (distance / 1000) + " km" : distance + " m";
1150
+ }
1151
+ }
1152
+ const label = derivedLabel || remoteData(this, "label") || (this._remoteData && this._remoteData.label);
1017
1153
  if (label) {
1018
1154
  const l = this.ensure(".c-scale-bar__label", () => { const el = document.createElement("span"); el.className = "c-scale-bar__label"; return el; });
1019
1155
  l.textContent = label;
@@ -1021,7 +1157,6 @@ class ContourScaleBar extends ContourBase {
1021
1157
  const l = this.querySelector(".c-scale-bar__label");
1022
1158
  if (l) l.remove();
1023
1159
  }
1024
- const value = remoteData(this, "value") || (this._remoteData && this._remoteData.value);
1025
1160
  if (!value) {
1026
1161
  renderEmpty(this, "scale-bar");
1027
1162
  return;
package/dist/wc/misc.mjs CHANGED
@@ -1,7 +1,35 @@
1
- import { ContourBase, define } from './core.mjs';
1
+ class ContourResizeObserver extends ContourBase {
2
+ static get observed() { return ["debounce"]; }
3
+ static get properties() { return { debounce: { attribute: "debounce" } }; }
4
+ render() {
5
+ this.classList.add("c-resize-observer");
6
+ this.setAttribute("aria-hidden", "true");
7
+ }
8
+ enhance() {
9
+ if (this._wiredResizeObserver) return;
10
+ this._wiredResizeObserver = true;
11
+ if (typeof ResizeObserver !== "function") return;
12
+ const debounce = parseInt(this.getAttribute("debounce") || "0", 10) || 0;
13
+ let timer = null;
14
+ const ro = new ResizeObserver((entries) => {
15
+ const fire = () => {
16
+ const e = entries[entries.length - 1];
17
+ const cr = e && e.contentRect ? e.contentRect : this.getBoundingClientRect();
18
+ this.dispatchEvent(new CustomEvent("contour:resize", { bubbles: true, composed: true, detail: { width: cr.width, height: cr.height } }));
19
+ };
20
+ if (debounce > 0) { clearTimeout(timer); timer = setTimeout(fire, debounce); }
21
+ else fire();
22
+ });
23
+ ro.observe(this);
24
+ onDispose(this, () => { ro.disconnect(); clearTimeout(timer); });
25
+ }
26
+ }
27
+ define("contour-resize-observer", ContourResizeObserver);
28
+ import { ContourBase, define, onDispose } from './core.mjs';
2
29
  import { loadRemote, remoteData, remoteRefresh, renderStates, renderEmpty, wireStates } from './states.mjs';
3
30
  class ContourReservedFull extends ContourBase {
4
31
  static get observed() { return ["title"]; }
32
+ static get properties() { return { title: { attribute: "title" } }; }
5
33
  render() {
6
34
  this.classList.add("c-reserved");
7
35
  const title = this.getAttribute("title");