contour-ds 1.1.2 → 1.7.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.
- package/README.md +30 -2
- package/dist/agent-rules.json +5 -1
- package/dist/build-manifest.json +94 -93
- package/dist/contour-wc.esm.js +4443 -534
- package/dist/contour-wc.esm.min.js +1 -1
- package/dist/contour-wc.js +4441 -528
- package/dist/contour-wc.min.js +1 -1
- package/dist/contour.components.json +4054 -171
- package/dist/contour.css +1325 -565
- package/dist/contour.d.ts +119 -62
- package/dist/contour.esm.js +23 -0
- package/dist/contour.esm.min.js +1 -1
- package/dist/contour.js +23 -0
- package/dist/contour.min.css +1 -1
- package/dist/contour.min.js +1 -1
- package/dist/contour.tokens.json +47 -2
- package/dist/docs/actions.md +6 -2
- package/dist/docs/affordances.md +19 -3
- package/dist/docs/apireference.md +30 -0
- package/dist/docs/colour.md +2 -2
- package/dist/docs/componentindex.md +39 -0
- package/dist/docs/data.md +38 -3
- package/dist/docs/docs.md +6 -2
- package/dist/docs/feedback.md +13 -3
- package/dist/docs/field.md +7 -2
- package/dist/docs/forms.md +35 -3
- package/dist/docs/index.json +44 -75
- package/dist/docs/install.md +4 -2
- package/dist/docs/landing.md +3 -2
- package/dist/docs/mapengine.md +9 -3
- package/dist/docs/motion.md +5 -2
- package/dist/docs/navigation.md +10 -3
- package/dist/docs/overlays.md +26 -3
- package/dist/docs/overview.md +2 -2
- package/dist/docs/patterns.md +38 -3
- package/dist/docs/playground.md +5 -2
- package/dist/docs/principles.md +2 -2
- package/dist/docs/recipes.md +7 -3
- package/dist/docs/space.md +2 -2
- package/dist/docs/status.md +19 -3
- package/dist/docs/surfaces.md +7 -3
- package/dist/docs/theming.md +5 -2
- package/dist/docs/type.md +2 -2
- package/dist/docs/webcomponents.md +26 -7
- package/dist/map-chrome.mapbox.css +4 -4
- package/dist/map-chrome.maplibre.css +4 -4
- package/dist/registry/items/contour-core.json +2 -2
- package/dist/registry/items/contour-data.json +2 -2
- package/dist/registry/items/contour-docs.json +2 -2
- package/dist/registry/items/contour-landing.json +2 -2
- package/dist/registry/registry.json +8 -8
- package/dist/surfaces/contour-core.min.css +1 -1
- package/dist/surfaces/contour-data.min.css +1 -1
- package/dist/surfaces/contour-docs.min.css +1 -1
- package/dist/surfaces/contour-landing.min.css +1 -1
- package/dist/wc/behaviours.mjs +69 -11
- package/dist/wc/content.mjs +163 -8
- package/dist/wc/core.mjs +177 -36
- package/dist/wc/dashboard.mjs +69 -4
- package/dist/wc/data.mjs +933 -128
- package/dist/wc/docs.mjs +118 -0
- package/dist/wc/feedback.mjs +75 -13
- package/dist/wc/forms.mjs +371 -34
- package/dist/wc/index.mjs +31 -3
- package/dist/wc/interaction.mjs +11 -6
- package/dist/wc/map.mjs +142 -38
- package/dist/wc/misc.mjs +29 -1
- package/dist/wc/navigation.mjs +424 -75
- package/dist/wc/registration.mjs +8 -4
- package/dist/wc/shadow.mjs +29 -12
- package/dist/wc/states.mjs +15 -0
- package/dist/wc/svg.mjs +10 -0
- package/dist/wc/ui.mjs +1767 -129
- package/package.json +39 -6
package/dist/wc/interaction.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ContourBase, define } from './core.mjs';
|
|
1
|
+
import { ContourBase, define, onDispose } from './core.mjs';
|
|
2
2
|
import { wireSegmented } from './behaviours.mjs';
|
|
3
3
|
class ContourPressableFull extends ContourBase {
|
|
4
4
|
static get observed() { return ["disabled"]; }
|
|
@@ -11,7 +11,7 @@ class ContourPressableFull extends ContourBase {
|
|
|
11
11
|
this.setAttribute("tabindex", "-1");
|
|
12
12
|
} else {
|
|
13
13
|
this.removeAttribute("aria-disabled");
|
|
14
|
-
if (!this.hasAttribute("tabindex")) this.setAttribute("tabindex", "0");
|
|
14
|
+
if (!this.hasAttribute("tabindex") || this.getAttribute("tabindex") === "-1") this.setAttribute("tabindex", "0");
|
|
15
15
|
}
|
|
16
16
|
}
|
|
17
17
|
enhance() {
|
|
@@ -27,6 +27,9 @@ class ContourResizeHandleFull extends ContourBase {
|
|
|
27
27
|
render() {
|
|
28
28
|
this.classList.add("c-resize-handle");
|
|
29
29
|
if (!this.hasAttribute("role")) this.setAttribute("role", "separator");
|
|
30
|
+
if (!this.hasAttribute("aria-label")) this.setAttribute("aria-label", "Resize handle");
|
|
31
|
+
if (!this.hasAttribute("tabindex")) this.setAttribute("tabindex", "0");
|
|
32
|
+
if (!this.hasAttribute("aria-orientation")) this.setAttribute("aria-orientation", "horizontal");
|
|
30
33
|
}
|
|
31
34
|
}
|
|
32
35
|
define("contour-resize-handle", ContourResizeHandleFull);
|
|
@@ -121,7 +124,7 @@ class ContourShortcutPanelFull extends ContourBase {
|
|
|
121
124
|
if (this._wiredShortcutOverlay) return;
|
|
122
125
|
this._wiredShortcutOverlay = true;
|
|
123
126
|
// Global registry: "?" (Shift+/) toggles the overlay; Escape closes.
|
|
124
|
-
|
|
127
|
+
const keyHandler = (e) => {
|
|
125
128
|
if (e.key === "?" && !e.metaKey && !e.ctrlKey && !e.altKey) {
|
|
126
129
|
const tag = (e.target && e.target.tagName) || "";
|
|
127
130
|
if (tag === "INPUT" || tag === "TEXTAREA" || (e.target && e.target.isContentEditable)) return;
|
|
@@ -130,7 +133,9 @@ class ContourShortcutPanelFull extends ContourBase {
|
|
|
130
133
|
} else if (e.key === "Escape" && this.hasAttribute("open")) {
|
|
131
134
|
this.hide();
|
|
132
135
|
}
|
|
133
|
-
}
|
|
136
|
+
};
|
|
137
|
+
document.addEventListener("keydown", keyHandler);
|
|
138
|
+
onDispose(this, () => document.removeEventListener("keydown", keyHandler));
|
|
134
139
|
this.addEventListener("click", (e) => {
|
|
135
140
|
if (e.target === this) this.hide();
|
|
136
141
|
});
|
|
@@ -148,7 +153,7 @@ class ContourRowActionFull extends ContourBase {
|
|
|
148
153
|
this.setAttribute("tabindex", "-1");
|
|
149
154
|
} else {
|
|
150
155
|
this.removeAttribute("aria-disabled");
|
|
151
|
-
if (!this.hasAttribute("tabindex")) this.setAttribute("tabindex", "0");
|
|
156
|
+
if (!this.hasAttribute("tabindex") || this.getAttribute("tabindex") === "-1") this.setAttribute("tabindex", "0");
|
|
152
157
|
}
|
|
153
158
|
const label = this.getAttribute("label");
|
|
154
159
|
if (label && !this.hasChildNodes()) this.textContent = label;
|
|
@@ -465,7 +470,7 @@ class ContourBtn extends ContourBase {
|
|
|
465
470
|
this.setAttribute("tabindex", "-1");
|
|
466
471
|
} else {
|
|
467
472
|
this.removeAttribute("aria-disabled");
|
|
468
|
-
if (!this.hasAttribute("tabindex")) this.setAttribute("tabindex", "0");
|
|
473
|
+
if (!this.hasAttribute("tabindex") || this.getAttribute("tabindex") === "-1") this.setAttribute("tabindex", "0");
|
|
469
474
|
}
|
|
470
475
|
const label = this.getAttribute("label");
|
|
471
476
|
if (label && !this.hasChildNodes()) this.textContent = label;
|
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
|
|
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
|
-
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
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", "speeds", "show-loop", "loop-label", "current-time", "time-format", "is-playing"]; }
|
|
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,13 +445,13 @@ 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
456
|
const ct = this.getAttribute("current-time");
|
|
421
457
|
time.textContent = ct ? ct : (this.getAttribute("label") || "");
|
|
@@ -423,7 +459,7 @@ class ContourTimeSlider extends ContourBase {
|
|
|
423
459
|
let speeds = null;
|
|
424
460
|
const speedsAttr = this.getAttribute("speeds");
|
|
425
461
|
if (speedsAttr) { try { speeds = JSON.parse(speedsAttr); } catch (e) { speeds = null; } }
|
|
426
|
-
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; });
|
|
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; });
|
|
427
463
|
speedSel.innerHTML = "";
|
|
428
464
|
const speedList = Array.isArray(speeds) ? speeds : [0.5, 1, 2, 5, 10];
|
|
429
465
|
speedList.forEach((sp) => {
|
|
@@ -448,7 +484,7 @@ class ContourTimeSlider extends ContourBase {
|
|
|
448
484
|
// is-playing reflects on play button
|
|
449
485
|
if (this.hasAttribute("is-playing")) {
|
|
450
486
|
play.setAttribute("data-state", "pause");
|
|
451
|
-
play.setAttribute("aria-label", "Pause");
|
|
487
|
+
play.setAttribute("aria-label", this.getAttribute("pause-label") || "Pause");
|
|
452
488
|
const use = play.querySelector("use");
|
|
453
489
|
if (use) use.setAttribute("href", "#i-pause");
|
|
454
490
|
}
|
|
@@ -479,7 +515,7 @@ class ContourTimeSlider extends ContourBase {
|
|
|
479
515
|
const btn = this.querySelector(".c-time-slider__play");
|
|
480
516
|
if (btn) {
|
|
481
517
|
btn.setAttribute("data-state", "play");
|
|
482
|
-
btn.setAttribute("aria-label", "Play");
|
|
518
|
+
btn.setAttribute("aria-label", this.getAttribute("play-label") || "Play");
|
|
483
519
|
const use = btn.querySelector("use");
|
|
484
520
|
if (use) use.setAttribute("href", "#i-play");
|
|
485
521
|
}
|
|
@@ -490,7 +526,7 @@ class ContourTimeSlider extends ContourBase {
|
|
|
490
526
|
if (btn) {
|
|
491
527
|
const playing = btn.getAttribute("data-state") === "play";
|
|
492
528
|
btn.setAttribute("data-state", playing ? "pause" : "play");
|
|
493
|
-
btn.setAttribute("aria-label", playing ? "Pause" : "Play");
|
|
529
|
+
btn.setAttribute("aria-label", playing ? (this.getAttribute("pause-label") || "Pause") : (this.getAttribute("play-label") || "Play"));
|
|
494
530
|
const use = btn.querySelector("use");
|
|
495
531
|
if (use) use.setAttribute("href", playing ? "#i-pause" : "#i-play");
|
|
496
532
|
if (playing) {
|
|
@@ -533,6 +569,8 @@ class ContourHexbin extends ContourBase {
|
|
|
533
569
|
static get properties() { return { label: { attribute: "label" }, cells: { attribute: "cells" }, src: { attribute: "src" } }; }
|
|
534
570
|
render() {
|
|
535
571
|
this.classList.add("c-hexbin");
|
|
572
|
+
this.setAttribute("role", "img");
|
|
573
|
+
this.setAttribute("aria-label", "Hexbin");
|
|
536
574
|
const label = this.getAttribute("label") || (this._remoteData && this._remoteData.label);
|
|
537
575
|
if (label) {
|
|
538
576
|
const l = this.ensure(".c-hexbin__label", () => { const el = document.createElement("span"); el.className = "c-hexbin__label"; return el; });
|
|
@@ -590,6 +628,8 @@ class ContourFlowMap extends ContourBase {
|
|
|
590
628
|
static get properties() { return { label: { attribute: "label" }, nodes: { attribute: "nodes" }, src: { attribute: "src" } }; }
|
|
591
629
|
render() {
|
|
592
630
|
this.classList.add("c-flow-map");
|
|
631
|
+
this.setAttribute("role", "img");
|
|
632
|
+
this.setAttribute("aria-label", "Flow map");
|
|
593
633
|
const label = this.getAttribute("label") || (this._remoteData && this._remoteData.label);
|
|
594
634
|
if (label) {
|
|
595
635
|
const l = this.ensure(".c-flow-map__label", () => { const el = document.createElement("span"); el.className = "c-flow-map__label"; return el; });
|
|
@@ -644,6 +684,8 @@ class ContourIsochrone extends ContourBase {
|
|
|
644
684
|
static get properties() { return { label: { attribute: "label" }, center: { attribute: "center" }, rings: { attribute: "rings" }, src: { attribute: "src" } }; }
|
|
645
685
|
render() {
|
|
646
686
|
this.classList.add("c-isochrone");
|
|
687
|
+
this.setAttribute("role", "img");
|
|
688
|
+
this.setAttribute("aria-label", "Isochrone");
|
|
647
689
|
const label = this.getAttribute("label") || (this._remoteData && this._remoteData.label);
|
|
648
690
|
if (label) {
|
|
649
691
|
const l = this.ensure(".c-isochrone__label", () => { const el = document.createElement("span"); el.className = "c-isochrone__label"; return el; });
|
|
@@ -705,6 +747,8 @@ class ContourCatchment extends ContourBase {
|
|
|
705
747
|
static get properties() { return { label: { attribute: "label" }, area: { attribute: "area" }, center: { attribute: "center" }, src: { attribute: "src" } }; }
|
|
706
748
|
render() {
|
|
707
749
|
this.classList.add("c-catchment");
|
|
750
|
+
this.setAttribute("role", "img");
|
|
751
|
+
this.setAttribute("aria-label", "Catchment");
|
|
708
752
|
const label = this.getAttribute("label") || (this._remoteData && this._remoteData.label);
|
|
709
753
|
if (label) {
|
|
710
754
|
const l = this.ensure(".c-catchment__label", () => { const el = document.createElement("span"); el.className = "c-catchment__label"; return el; });
|
|
@@ -763,6 +807,12 @@ class ContourCatchment extends ContourBase {
|
|
|
763
807
|
if (!this.hasAttribute("tabindex")) this.setAttribute("tabindex", "0");
|
|
764
808
|
this.addEventListener("focusin", showTip);
|
|
765
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
|
+
});
|
|
766
816
|
}
|
|
767
817
|
}
|
|
768
818
|
define("contour-catchment", ContourCatchment);
|
|
@@ -802,13 +852,20 @@ class ContourCompassFull extends ContourBase {
|
|
|
802
852
|
el.setAttribute("class", "c-compass__needle");
|
|
803
853
|
el.setAttribute("viewBox", "0 0 40 40");
|
|
804
854
|
el.setAttribute("aria-hidden", "true");
|
|
805
|
-
const
|
|
806
|
-
|
|
807
|
-
|
|
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);
|
|
808
863
|
return el;
|
|
809
864
|
});
|
|
810
|
-
const
|
|
811
|
-
if (
|
|
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));
|
|
812
869
|
} else {
|
|
813
870
|
const n = this.querySelector("svg.c-compass__needle, .c-compass__needle");
|
|
814
871
|
if (n) n.remove();
|
|
@@ -829,8 +886,10 @@ class ContourCompassFull extends ContourBase {
|
|
|
829
886
|
if (deg === undefined) return;
|
|
830
887
|
const n = this.querySelector(".c-compass__needle");
|
|
831
888
|
if (n) {
|
|
832
|
-
const
|
|
833
|
-
if (
|
|
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));
|
|
834
893
|
}
|
|
835
894
|
this.dispatchEvent(new CustomEvent("contour:bearing", { bubbles: true, composed: true, detail: { direction: dir, degrees: deg } }));
|
|
836
895
|
};
|
|
@@ -869,9 +928,11 @@ class ContourLayerSwitch extends ContourBase {
|
|
|
869
928
|
capped.forEach((it) => {
|
|
870
929
|
const item = document.createElement("div");
|
|
871
930
|
item.className = "c-layer-switch__item";
|
|
931
|
+
item.setAttribute("role", "group");
|
|
872
932
|
const sw = document.createElement("span");
|
|
873
933
|
sw.className = "c-layer-switch__swatch";
|
|
874
934
|
if (it.color) sw.style.background = it.color;
|
|
935
|
+
sw.setAttribute("aria-hidden", "true");
|
|
875
936
|
item.appendChild(sw);
|
|
876
937
|
const name = document.createElement("span");
|
|
877
938
|
name.className = "c-layer-switch__name";
|
|
@@ -887,6 +948,7 @@ class ContourLayerSwitch extends ContourBase {
|
|
|
887
948
|
toggle.className = "c-layer-switch__toggle";
|
|
888
949
|
toggle.type = "button";
|
|
889
950
|
toggle.setAttribute("aria-label", "Toggle " + (typeof it === "string" ? it : (it.name || it.label || "layer")));
|
|
951
|
+
toggle.setAttribute("aria-pressed", "true");
|
|
890
952
|
toggle.innerHTML = '<svg aria-hidden="true"><use href="#i-check" /></svg>';
|
|
891
953
|
item.appendChild(toggle);
|
|
892
954
|
this.appendChild(item);
|
|
@@ -905,7 +967,14 @@ class ContourLayerSwitch extends ContourBase {
|
|
|
905
967
|
if (!btn || !this.contains(btn)) return;
|
|
906
968
|
const item = btn.closest(".c-layer-switch__item");
|
|
907
969
|
const name = item ? (item.querySelector(".c-layer-switch__name")?.textContent || "") : "";
|
|
908
|
-
|
|
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(); }
|
|
909
978
|
});
|
|
910
979
|
}
|
|
911
980
|
}
|
|
@@ -1058,14 +1127,29 @@ class ContourMapFooter extends ContourBase {
|
|
|
1058
1127
|
}
|
|
1059
1128
|
define("contour-map-footer", ContourMapFooter);
|
|
1060
1129
|
class ContourScaleBar extends ContourBase {
|
|
1061
|
-
static get observed() { return ["label", "value", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton"]; }
|
|
1062
|
-
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" } }; }
|
|
1063
1132
|
render() {
|
|
1064
1133
|
this.classList.add("c-scale-bar");
|
|
1065
1134
|
wireStates(this);
|
|
1066
1135
|
loadRemote(this, ["label", "value"]);
|
|
1067
1136
|
if (renderStates(this, "scale-bar")) return;
|
|
1068
|
-
|
|
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);
|
|
1069
1153
|
if (label) {
|
|
1070
1154
|
const l = this.ensure(".c-scale-bar__label", () => { const el = document.createElement("span"); el.className = "c-scale-bar__label"; return el; });
|
|
1071
1155
|
l.textContent = label;
|
|
@@ -1073,7 +1157,6 @@ class ContourScaleBar extends ContourBase {
|
|
|
1073
1157
|
const l = this.querySelector(".c-scale-bar__label");
|
|
1074
1158
|
if (l) l.remove();
|
|
1075
1159
|
}
|
|
1076
|
-
const value = remoteData(this, "value") || (this._remoteData && this._remoteData.value);
|
|
1077
1160
|
if (!value) {
|
|
1078
1161
|
renderEmpty(this, "scale-bar");
|
|
1079
1162
|
return;
|
|
@@ -1096,3 +1179,24 @@ class ContourScaleBar extends ContourBase {
|
|
|
1096
1179
|
}
|
|
1097
1180
|
}
|
|
1098
1181
|
define("contour-scale-bar", ContourScaleBar);
|
|
1182
|
+
|
|
1183
|
+
class ContourSplitMap extends ContourBase {
|
|
1184
|
+
static get observed() { return ["left", "right"]; }
|
|
1185
|
+
static get properties() { return { left: { attribute: "left" }, right: { attribute: "right" } }; }
|
|
1186
|
+
render() {
|
|
1187
|
+
this.classList.add("c-split-map");
|
|
1188
|
+
const left = this.ensure(".c-split-map__pane--left", () => {
|
|
1189
|
+
const e = document.createElement("div");
|
|
1190
|
+
e.className = "c-split-map__pane c-split-map__pane--left";
|
|
1191
|
+
return e;
|
|
1192
|
+
});
|
|
1193
|
+
const right = this.ensure(".c-split-map__pane--right", () => {
|
|
1194
|
+
const e = document.createElement("div");
|
|
1195
|
+
e.className = "c-split-map__pane c-split-map__pane--right";
|
|
1196
|
+
return e;
|
|
1197
|
+
});
|
|
1198
|
+
if (left.parentNode !== this) this.appendChild(left);
|
|
1199
|
+
if (right.parentNode !== this) this.appendChild(right);
|
|
1200
|
+
}
|
|
1201
|
+
}
|
|
1202
|
+
define("contour-split-map", ContourSplitMap);
|
package/dist/wc/misc.mjs
CHANGED
|
@@ -1,7 +1,35 @@
|
|
|
1
|
-
|
|
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");
|