contour-ds 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/build-manifest.json +43 -43
- package/dist/contour-wc.esm.js +794 -184
- package/dist/contour-wc.esm.min.js +1 -1
- package/dist/contour-wc.js +794 -184
- package/dist/contour-wc.min.js +1 -1
- package/dist/contour.components.json +67 -21
- package/dist/contour.css +113 -36
- package/dist/contour.d.ts +1 -0
- package/dist/contour.min.css +1 -1
- package/dist/contour.themes.json +4 -1
- package/dist/contour.tokens.json +3 -0
- package/dist/docs/actions.md +1 -1
- package/dist/docs/affordances.md +1 -1
- package/dist/docs/colour.md +1 -1
- package/dist/docs/data.md +1 -1
- package/dist/docs/docs.md +1 -1
- package/dist/docs/feedback.md +1 -1
- package/dist/docs/field.md +1 -1
- package/dist/docs/forms.md +1 -1
- package/dist/docs/index.json +3 -3
- package/dist/docs/install.md +1 -1
- package/dist/docs/landing.md +1 -1
- package/dist/docs/mapengine.md +1 -1
- package/dist/docs/motion.md +1 -1
- package/dist/docs/navigation.md +1 -1
- package/dist/docs/overlays.md +1 -1
- package/dist/docs/overview.md +1 -1
- package/dist/docs/patterns.md +1 -1
- package/dist/docs/playground.md +1 -1
- package/dist/docs/principles.md +1 -1
- package/dist/docs/recipes.md +1 -1
- package/dist/docs/space.md +1 -1
- package/dist/docs/status.md +1 -1
- package/dist/docs/surfaces.md +1 -1
- package/dist/docs/theming.md +1 -1
- package/dist/docs/type.md +1 -1
- package/dist/docs/webcomponents.md +1 -1
- 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/core.mjs +13 -3
- package/dist/wc/data.mjs +302 -36
- package/dist/wc/forms.mjs +119 -61
- package/dist/wc/map.mjs +190 -69
- package/dist/wc/navigation.mjs +66 -11
- package/dist/wc/ui.mjs +104 -4
- package/package.json +1 -1
package/dist/contour-wc.js
CHANGED
|
@@ -87,6 +87,7 @@ const CONTOUR_EVENTS = Object.freeze({
|
|
|
87
87
|
"contour:brush-start": { payload: ["value"], composed: true },
|
|
88
88
|
"contour:brush-end": { payload: ["value"], composed: true },
|
|
89
89
|
"contour:change": { payload: ["name", "value", "checked"], composed: true },
|
|
90
|
+
"contour:clear": { payload: [], composed: true },
|
|
90
91
|
"contour:close": { payload: [], composed: true },
|
|
91
92
|
"contour:copy": { payload: ["text"], composed: true },
|
|
92
93
|
"contour:dash-action": { payload: ["label"], composed: true },
|
|
@@ -106,6 +107,8 @@ const CONTOUR_EVENTS = Object.freeze({
|
|
|
106
107
|
"contour:layer-duplicate": { payload: ["name"], composed: true },
|
|
107
108
|
"contour:layer-zoom": { payload: ["name"], composed: true },
|
|
108
109
|
"contour:layer-projection": { payload: ["name", "projection"], composed: true },
|
|
110
|
+
"contour:layer-remove": { payload: ["name"], composed: true },
|
|
111
|
+
"contour:layer-reorder": { payload: ["layerIds"], composed: true },
|
|
109
112
|
"contour:layer-toggle": { payload: ["name"], composed: true },
|
|
110
113
|
"contour:layer-visibility": { payload: ["name", "visible"], composed: true },
|
|
111
114
|
"contour:legend-toggle": { payload: ["label", "key", "layers", "pressed"], composed: true },
|
|
@@ -113,6 +116,7 @@ const CONTOUR_EVENTS = Object.freeze({
|
|
|
113
116
|
"contour:map-control": { payload: ["control"], composed: true },
|
|
114
117
|
"contour:map-attach": { payload: [], composed: true },
|
|
115
118
|
"contour:map-detach": { payload: [], composed: true },
|
|
119
|
+
"contour:mode-change": { payload: ["mode"], composed: true },
|
|
116
120
|
"contour:move": { payload: ["direction"], composed: true },
|
|
117
121
|
"contour:open": { payload: [], composed: true },
|
|
118
122
|
"contour:page": { payload: ["page"], composed: true },
|
|
@@ -120,7 +124,12 @@ const CONTOUR_EVENTS = Object.freeze({
|
|
|
120
124
|
"contour:remove": { payload: ["label", "key", "layers", "value"], composed: true },
|
|
121
125
|
"contour:range-change": { payload: ["value"], composed: true },
|
|
122
126
|
"contour:retry": { payload: ["src"], composed: true },
|
|
127
|
+
"contour:loop-change": { payload: ["loop"], composed: true },
|
|
128
|
+
"contour:pause": { payload: [], composed: true },
|
|
129
|
+
"contour:play": { payload: [], composed: true },
|
|
130
|
+
"contour:seek": { payload: ["progress", "value"], composed: true },
|
|
123
131
|
"contour:select": { payload: ["series", "index", "label", "value"], composed: true },
|
|
132
|
+
"contour:speed-change": { payload: ["speed"], composed: true },
|
|
124
133
|
"contour:showcase-activate": { payload: ["title"], composed: true },
|
|
125
134
|
"contour:step-activate": { payload: ["index", "title"], composed: true },
|
|
126
135
|
"contour:step-change": { payload: ["index", "title"], composed: true },
|
|
@@ -175,14 +184,15 @@ function sanitizeHtml(input) {
|
|
|
175
184
|
// role, open, aria-label, aria-valuenow, aria-valuemin, aria-valuemax, tabindex
|
|
176
185
|
// Adding one of those back to this list makes that component recurse.
|
|
177
186
|
const OBSERVED = [
|
|
178
|
-
"accept", "action", "actions", "after", "anchor", "answer", "area", "article", "attribution", "attribution-mark", "autoplay", "axis", "axis-x", "axis-y", "brownout", "brownout-level", "before", "body", "brand", "breakpoint", "cache-key", "canvas", "center", "clearable", "cols", "columns", "color", "command",
|
|
179
|
-
"cells", "checked", "chrome", "closable", "colors", "content", "controls", "copyable", "count", "current", "data", "date", "delta", "description", "glyphs", "demo", "density", "desc", "dir", "direction", "disabled", "dismissible", "divider", "do", "dont", "dot",
|
|
187
|
+
"accept", "action", "actions", "after", "allow-duplicate", "allow-remove", "allow-rename", "allow-zoom", "anchor", "answer", "area", "article", "attribution", "attribution-mark", "audit", "autoplay", "axis", "axis-x", "axis-y", "brownout", "brownout-level", "before", "body", "brand", "breakpoint", "breaks", "cache-key", "canvas", "center", "clearable", "cols", "columns", "color", "command",
|
|
188
|
+
"cells", "checked", "chrome", "closable", "classification", "colors", "continuous", "content", "controls", "copyable", "count", "current", "data", "date", "delta", "description", "glyphs", "demo", "density", "desc", "dir", "direction", "disabled", "dismissible", "divider", "do", "dont", "dot", "ends", "high", "input", "layer", "low", "mode", "modes", "n", "opacity", "palette", "polarity", "range", "single",
|
|
180
189
|
"empty", "error", "exclusive", "format", "heading", "hint", "href", "icon", "illustration", "index", "instrument", "interval", "items", "key", "layers", "level",
|
|
181
190
|
"label", "lazy", "lede", "legend", "line", "link", "links", "live", "loading", "locale", "loop", "max", "media", "message", "method", "month", "menu", "min", "multiple", "name", "needle", "next", "no", "no-cache", "no-data-message", "nodes", "note", "norm", "normalize",
|
|
182
191
|
"options", "orientation", "page-size", "pages", "pause", "paused", "pausable", "persist", "placeholder", "playing", "point", "points", "prev", "progress", "prompt", "question", "recent", "required",
|
|
183
192
|
"quote", "ramp", "refresh", "removable", "reverse", "rings", "retry", "rows", "scale", "selectable", "segments", "show-header", "sparkline", "start", "end", "threshold", "thresholds", "selected", "separator", "series", "shortcut", "side", "size", "skeleton", "sort", "sort-dir", "speed", "status", "step", "submit", "timeout", "trigger", "virtual",
|
|
184
|
-
"state", "steps", "subtitle", "summary", "src", "tabs", "tag", "text", "ticks", "title", "type", "unit",
|
|
193
|
+
"state", "steps", "subtitle", "summary", "src", "table", "tabs", "tag", "text", "ticks", "title", "type", "unit",
|
|
185
194
|
"variant", "values", "viewport", "yes", "zoomable", "x", "y",
|
|
195
|
+
"caption", "current-time", "is-playing", "loop-label", "no-data-color", "property", "show-loop", "show-thumb", "show-thumb-caption", "speeds",
|
|
186
196
|
];
|
|
187
197
|
function headingTag(host, fallback = "h3") {
|
|
188
198
|
const v = host && host.getAttribute ? host.getAttribute("heading") : null;
|
|
@@ -3787,13 +3797,18 @@ class ContourKpi extends ContourBase {
|
|
|
3787
3797
|
const h = this.querySelector(".c-kpi__head");
|
|
3788
3798
|
if (h) h.remove();
|
|
3789
3799
|
}
|
|
3790
|
-
|
|
3791
|
-
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3800
|
+
if (delta) {
|
|
3801
|
+
const f = this.ensure(".c-kpi__foot", () => { const el = document.createElement("div"); el.className = "c-kpi__foot"; return el; });
|
|
3802
|
+
const d = f.querySelector(".c-delta") || document.createElement("span");
|
|
3803
|
+
if (!d.parentNode) f.insertBefore(d, f.firstChild);
|
|
3804
|
+
const dir = this.getAttribute("direction") || "up";
|
|
3805
|
+
const polarity = this.getAttribute("polarity") || "neutral";
|
|
3806
|
+
let tone = "neutral";
|
|
3807
|
+
if (polarity === "good") tone = (dir === "up") ? "good" : "bad";
|
|
3808
|
+
else if (polarity === "bad") tone = (dir === "up") ? "bad" : "good";
|
|
3809
|
+
d.className = "c-delta c-delta--" + dir + " c-delta--" + tone;
|
|
3810
|
+
d.textContent = delta;
|
|
3811
|
+
} else {
|
|
3797
3812
|
const d = this.querySelector(".c-kpi__foot .c-delta");
|
|
3798
3813
|
if (d) d.remove();
|
|
3799
3814
|
}
|
|
@@ -5529,8 +5544,8 @@ class ContourInstrument extends ContourBase {
|
|
|
5529
5544
|
}
|
|
5530
5545
|
define("contour-instrument", ContourInstrument);
|
|
5531
5546
|
class ContourBivariate extends ContourBase {
|
|
5532
|
-
static get observed() { return ["size", "axis-x", "axis-y", "colors"]; }
|
|
5533
|
-
static get properties() { return { size: { attribute: "size" }, axisX: { attribute: "axis-x" }, axisY: { attribute: "axis-y" }, colors: { attribute: "colors" } }; }
|
|
5547
|
+
static get observed() { return ["size", "axis-x", "axis-y", "colors", "selected"]; }
|
|
5548
|
+
static get properties() { return { size: { attribute: "size" }, axisX: { attribute: "axis-x" }, axisY: { attribute: "axis-y" }, colors: { attribute: "colors" }, selected: { attribute: "selected" } }; }
|
|
5534
5549
|
render() {
|
|
5535
5550
|
this.classList.add("c-bivariate");
|
|
5536
5551
|
const size = Math.min(12, Math.max(1, parseInt(this.getAttribute("size") || "3", 10) || 3));
|
|
@@ -5548,6 +5563,9 @@ class ContourBivariate extends ContourBase {
|
|
|
5548
5563
|
for (let c = 0; c < size; c++) {
|
|
5549
5564
|
const cell = document.createElement("div");
|
|
5550
5565
|
cell.className = "c-bivariate__cell";
|
|
5566
|
+
cell.setAttribute("role", "button");
|
|
5567
|
+
cell.setAttribute("tabindex", "0");
|
|
5568
|
+
cell.setAttribute("aria-label", "Cell " + c + "," + r);
|
|
5551
5569
|
// Palette runs from bottom-left (low/low) to top-right (high/high):
|
|
5552
5570
|
// reverse the row order so the first palette row sits at the bottom.
|
|
5553
5571
|
const srcIndex = (size - 1 - r) * size + c;
|
|
@@ -5555,6 +5573,24 @@ class ContourBivariate extends ContourBase {
|
|
|
5555
5573
|
matrix.appendChild(cell);
|
|
5556
5574
|
}
|
|
5557
5575
|
}
|
|
5576
|
+
// selected highlight
|
|
5577
|
+
const sel = this.getAttribute("selected");
|
|
5578
|
+
if (sel) {
|
|
5579
|
+
const parts = sel.split(",");
|
|
5580
|
+
const sr = parseInt(parts[0], 10);
|
|
5581
|
+
const sc = parseInt(parts[1], 10);
|
|
5582
|
+
const cells = Array.from(matrix.querySelectorAll(".c-bivariate__cell"));
|
|
5583
|
+
cells.forEach((cell, i) => {
|
|
5584
|
+
const rr = Math.floor(i / size);
|
|
5585
|
+
const cc = i % size;
|
|
5586
|
+
// matrix is row-major in DOM? cells appended row by row r then c, so index = r*size+c
|
|
5587
|
+
if (rr === sr && cc === sc) cell.setAttribute("data-selected", "");
|
|
5588
|
+
else cell.removeAttribute("data-selected");
|
|
5589
|
+
});
|
|
5590
|
+
}
|
|
5591
|
+
// aria-live region
|
|
5592
|
+
let live = this.querySelector(".c-bivariate__live");
|
|
5593
|
+
if (!live) { live = document.createElement("div"); live.className = "c-bivariate__live"; live.setAttribute("aria-live", "polite"); live.style.position = "absolute"; live.style.width = "1px"; live.style.height = "1px"; live.style.overflow = "hidden"; live.style.clip = "rect(0,0,0,0)"; this.appendChild(live); }
|
|
5558
5594
|
}
|
|
5559
5595
|
const axisX = this.getAttribute("axis-x");
|
|
5560
5596
|
if (axisX) {
|
|
@@ -5573,11 +5609,47 @@ class ContourBivariate extends ContourBase {
|
|
|
5573
5609
|
if (ay) ay.remove();
|
|
5574
5610
|
}
|
|
5575
5611
|
}
|
|
5612
|
+
enhance() {
|
|
5613
|
+
if (this._wiredBivariate) return;
|
|
5614
|
+
this._wiredBivariate = true;
|
|
5615
|
+
const selectCell = (cell) => {
|
|
5616
|
+
const matrix = this.querySelector(".c-bivariate__matrix");
|
|
5617
|
+
const cells = Array.from(matrix ? matrix.querySelectorAll(".c-bivariate__cell") : []);
|
|
5618
|
+
const idx = cells.indexOf(cell);
|
|
5619
|
+
if (idx < 0) return;
|
|
5620
|
+
const size = Math.min(12, Math.max(1, parseInt(this.getAttribute("size") || "3", 10) || 3));
|
|
5621
|
+
const row = Math.floor(idx / size);
|
|
5622
|
+
const col = idx % size;
|
|
5623
|
+
cells.forEach((cell, i) => {
|
|
5624
|
+
const rr = Math.floor(i / size);
|
|
5625
|
+
const cc = i % size;
|
|
5626
|
+
if (rr === row && cc === col) cell.setAttribute("data-selected", "");
|
|
5627
|
+
else cell.removeAttribute("data-selected");
|
|
5628
|
+
});
|
|
5629
|
+
this.dispatchEvent(new CustomEvent("contour:select", { detail: { row, col }, bubbles: true, composed: true }));
|
|
5630
|
+
};
|
|
5631
|
+
this.addEventListener("click", (e) => {
|
|
5632
|
+
const cell = e.target && e.target.closest ? e.target.closest(".c-bivariate__cell") : null;
|
|
5633
|
+
if (cell && this.contains(cell)) selectCell(cell);
|
|
5634
|
+
});
|
|
5635
|
+
this.addEventListener("keydown", (e) => {
|
|
5636
|
+
const cell = e.target && e.target.closest ? e.target.closest(".c-bivariate__cell") : null;
|
|
5637
|
+
if (!cell || !this.contains(cell)) return;
|
|
5638
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
5639
|
+
e.preventDefault();
|
|
5640
|
+
selectCell(cell);
|
|
5641
|
+
}
|
|
5642
|
+
});
|
|
5643
|
+
}
|
|
5644
|
+
clear() {
|
|
5645
|
+
this.removeAttribute("selected");
|
|
5646
|
+
this.dispatchEvent(new CustomEvent("contour:clear", { bubbles: true, composed: true }));
|
|
5647
|
+
}
|
|
5576
5648
|
}
|
|
5577
5649
|
define("contour-bivariate", ContourBivariate);
|
|
5578
5650
|
class ContourBivariateLegend extends ContourBase {
|
|
5579
|
-
static get observed() { return ["size", "axis-x", "axis-y", "colors"]; }
|
|
5580
|
-
static get properties() { return { size: { attribute: "size" }, axisX: { attribute: "axis-x" }, axisY: { attribute: "axis-y" }, colors: { attribute: "colors" } }; }
|
|
5651
|
+
static get observed() { return ["size", "axis-x", "axis-y", "colors", "selected"]; }
|
|
5652
|
+
static get properties() { return { size: { attribute: "size" }, axisX: { attribute: "axis-x" }, axisY: { attribute: "axis-y" }, colors: { attribute: "colors" }, selected: { attribute: "selected" } }; }
|
|
5581
5653
|
render() {
|
|
5582
5654
|
this.classList.add("c-bivariate-legend");
|
|
5583
5655
|
const size = Math.min(8, Math.max(1, parseInt(this.getAttribute("size") || "3", 10) || 3));
|
|
@@ -5593,10 +5665,18 @@ class ContourBivariateLegend extends ContourBase {
|
|
|
5593
5665
|
for (let i = 0; i < size * size; i++) {
|
|
5594
5666
|
const cell = document.createElement("div");
|
|
5595
5667
|
cell.className = "c-bivariate-legend__cell";
|
|
5668
|
+
cell.setAttribute("role", "button");
|
|
5669
|
+
cell.setAttribute("tabindex", "0");
|
|
5670
|
+
const x = i % size;
|
|
5671
|
+
const y = Math.floor(i / size);
|
|
5672
|
+
cell.setAttribute("aria-label", "Cell " + x + "," + y);
|
|
5596
5673
|
if (colors[i]) cell.style.background = colors[i];
|
|
5597
5674
|
else cell.style.background = "var(--chart-" + ((i % 8) + 1) + ")";
|
|
5598
5675
|
matrix.appendChild(cell);
|
|
5599
5676
|
}
|
|
5677
|
+
// aria-live
|
|
5678
|
+
let live = this.querySelector(".c-bivariate-legend__live");
|
|
5679
|
+
if (!live) { live = document.createElement("div"); live.className = "c-bivariate-legend__live"; live.setAttribute("aria-live", "polite"); live.style.position = "absolute"; live.style.width = "1px"; live.style.height = "1px"; live.style.overflow = "hidden"; live.style.clip = "rect(0,0,0,0)"; this.appendChild(live); }
|
|
5600
5680
|
}
|
|
5601
5681
|
const axisX = this.getAttribute("axis-x");
|
|
5602
5682
|
const ax = this.querySelector(".c-bivariate-legend__axis--x");
|
|
@@ -5615,7 +5695,36 @@ class ContourBivariateLegend extends ContourBase {
|
|
|
5615
5695
|
ay.remove();
|
|
5616
5696
|
}
|
|
5617
5697
|
}
|
|
5618
|
-
enhance() {
|
|
5698
|
+
enhance() {
|
|
5699
|
+
if (this._wiredBivLegend) return;
|
|
5700
|
+
this._wiredBivLegend = true;
|
|
5701
|
+
const selectCell = (cell) => {
|
|
5702
|
+
const matrix = this.querySelector(".c-bivariate-legend__matrix");
|
|
5703
|
+
const cells = Array.from(matrix ? matrix.querySelectorAll(".c-bivariate-legend__cell") : []);
|
|
5704
|
+
const idx = cells.indexOf(cell);
|
|
5705
|
+
if (idx < 0) return;
|
|
5706
|
+
const size = Math.min(8, Math.max(1, parseInt(this.getAttribute("size") || "3", 10) || 3));
|
|
5707
|
+
const row = Math.floor(idx / size);
|
|
5708
|
+
const col = idx % size;
|
|
5709
|
+
cells.forEach((cell, i) => {
|
|
5710
|
+
const rr = Math.floor(i / size);
|
|
5711
|
+
const cc = i % size;
|
|
5712
|
+
if (rr === row && cc === col) cell.setAttribute("data-selected", "");
|
|
5713
|
+
else cell.removeAttribute("data-selected");
|
|
5714
|
+
});
|
|
5715
|
+
this.dispatchEvent(new CustomEvent("contour:select", { detail: { row, col }, bubbles: true, composed: true }));
|
|
5716
|
+
};
|
|
5717
|
+
this.addEventListener("click", (e) => {
|
|
5718
|
+
const cell = e.target && e.target.closest ? e.target.closest(".c-bivariate-legend__cell") : null;
|
|
5719
|
+
if (cell && this.contains(cell)) selectCell(cell);
|
|
5720
|
+
});
|
|
5721
|
+
this.addEventListener("keydown", (e) => {
|
|
5722
|
+
const cell = e.target && e.target.closest ? e.target.closest(".c-bivariate-legend__cell") : null;
|
|
5723
|
+
if (!cell || !this.contains(cell)) return;
|
|
5724
|
+
if (e.key === "Enter" || e.key === " ") { e.preventDefault(); selectCell(cell); }
|
|
5725
|
+
});
|
|
5726
|
+
}
|
|
5727
|
+
clear() { this.removeAttribute("selected"); this.dispatchEvent(new CustomEvent("contour:clear", { bubbles: true, composed: true })); }
|
|
5619
5728
|
}
|
|
5620
5729
|
define("contour-bivariate-legend", ContourBivariateLegend);
|
|
5621
5730
|
class ContourSurvey extends ContourBase {
|
|
@@ -5727,7 +5836,7 @@ class ContourMetricsFull extends ContourBase {
|
|
|
5727
5836
|
}
|
|
5728
5837
|
define("contour-metrics", ContourMetricsFull);
|
|
5729
5838
|
class ContourLegend extends ContourBase {
|
|
5730
|
-
static get observed() { return ["title", "ramp", "scale", "items", "method", "norm", "selectable", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton", "glyphs", "thresholds", "breaks", "no-data-color"]; }
|
|
5839
|
+
static get observed() { return ["title", "ramp", "scale", "items", "method", "norm", "selectable", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton", "glyphs", "thresholds", "breaks", "no-data-color", "size", "table", "classification", "audit", "continuous", "ends", "caption"]; }
|
|
5731
5840
|
static get properties() { return { title: { attribute: "title" }, ramp: { attribute: "ramp" }, scale: { attribute: "scale" }, items: { attribute: "items" }, method: { attribute: "method" }, norm: { attribute: "norm" }, selectable: { attribute: "selectable", type: Boolean }, src: { attribute: "src" } }; }
|
|
5732
5841
|
render() {
|
|
5733
5842
|
this.classList.add("c-legend");
|
|
@@ -5750,13 +5859,18 @@ class ContourLegend extends ContourBase {
|
|
|
5750
5859
|
if (items) {
|
|
5751
5860
|
try {
|
|
5752
5861
|
const parsed = JSON.parse(items);
|
|
5753
|
-
const list = this.ensure(".c-legend__items", () => { const el = document.createElement("div"); el.className = "c-legend__items"; return el; });
|
|
5862
|
+
const list = this.ensure(".c-legend__items", () => { const el = document.createElement("div"); el.className = "c-legend__items"; el.setAttribute("role", "listbox"); return el; });
|
|
5863
|
+
list.setAttribute("role", "listbox");
|
|
5864
|
+
if (title) list.setAttribute("aria-label", title);
|
|
5754
5865
|
list.innerHTML = "";
|
|
5755
5866
|
parsed.forEach((it) => {
|
|
5756
5867
|
const label = typeof it === "string" ? it : (it.label || String(it));
|
|
5757
5868
|
const key = typeof it === "string" ? it : (it.key || it.label || String(it));
|
|
5758
5869
|
const item = document.createElement(selectable ? "button" : "div");
|
|
5759
5870
|
item.className = "c-legend__item";
|
|
5871
|
+
item.setAttribute("role", "option");
|
|
5872
|
+
item.setAttribute("aria-selected", "false");
|
|
5873
|
+
item.setAttribute("tabindex", "-1");
|
|
5760
5874
|
if (selectable) {
|
|
5761
5875
|
item.type = "button";
|
|
5762
5876
|
item.setAttribute("aria-pressed", "true");
|
|
@@ -5767,14 +5881,15 @@ class ContourLegend extends ContourBase {
|
|
|
5767
5881
|
if (it && it.color) sw.style.background = it.color;
|
|
5768
5882
|
item.appendChild(sw);
|
|
5769
5883
|
// geometry glyph
|
|
5770
|
-
|
|
5771
|
-
|
|
5772
|
-
|
|
5773
|
-
|
|
5774
|
-
|
|
5775
|
-
|
|
5776
|
-
|
|
5777
|
-
|
|
5884
|
+
const glyphShape = (it && (it.shape || it.marker || it.glyph)) || this.getAttribute("glyphs");
|
|
5885
|
+
if (glyphShape) {
|
|
5886
|
+
const g = document.createElement("span");
|
|
5887
|
+
g.className = "c-legend__glyph";
|
|
5888
|
+
g.setAttribute("part", "glyph");
|
|
5889
|
+
g.textContent = glyphShape === "circle" ? "●" : glyphShape === "square" ? "■" : glyphShape === "triangle" ? "▲" : glyphShape === "diamond" ? "◆" : glyphShape === "star" ? "★" : String(glyphShape);
|
|
5890
|
+
if (it && it.size != null) g.style.fontSize = (typeof it.size === "number" ? it.size + "px" : String(it.size));
|
|
5891
|
+
item.appendChild(g);
|
|
5892
|
+
}
|
|
5778
5893
|
// threshold break marker
|
|
5779
5894
|
if (it && it.break != null) {
|
|
5780
5895
|
const b = document.createElement("span");
|
|
@@ -5782,9 +5897,21 @@ class ContourLegend extends ContourBase {
|
|
|
5782
5897
|
b.textContent = String(it.break);
|
|
5783
5898
|
item.appendChild(b);
|
|
5784
5899
|
}
|
|
5785
|
-
|
|
5786
|
-
|
|
5787
|
-
|
|
5900
|
+
const lbl = document.createElement("span");
|
|
5901
|
+
lbl.textContent = label;
|
|
5902
|
+
item.appendChild(lbl);
|
|
5903
|
+
// caption (source-and-method line)
|
|
5904
|
+
const caption = (typeof it === "object" && it) ? (it.caption || it.note || "") : "";
|
|
5905
|
+
if (caption) {
|
|
5906
|
+
const cap = document.createElement("span");
|
|
5907
|
+
cap.className = "c-legend__caption";
|
|
5908
|
+
cap.textContent = caption;
|
|
5909
|
+
item.appendChild(cap);
|
|
5910
|
+
}
|
|
5911
|
+
// threshold mark: outline on swatches that begin at a threshold
|
|
5912
|
+
if (it && (it.threshold || it.break != null)) {
|
|
5913
|
+
sw.style.outline = "2px solid var(--color-border-strong)";
|
|
5914
|
+
}
|
|
5788
5915
|
list.appendChild(item);
|
|
5789
5916
|
});
|
|
5790
5917
|
} catch (e) { /* keep existing */ }
|
|
@@ -5796,7 +5923,112 @@ class ContourLegend extends ContourBase {
|
|
|
5796
5923
|
renderEmpty(this, "legend");
|
|
5797
5924
|
}
|
|
5798
5925
|
}
|
|
5799
|
-
|
|
5926
|
+
// caption as option description (aria-describedby), not part of name
|
|
5927
|
+
const caption = this.getAttribute("caption");
|
|
5928
|
+
let captionEl = this.querySelector(".c-legend__caption");
|
|
5929
|
+
if (caption) {
|
|
5930
|
+
if (!captionEl) { captionEl = document.createElement("span"); captionEl.className = "c-legend__caption"; this.appendChild(captionEl); }
|
|
5931
|
+
captionEl.id = captionEl.id || ("legend-caption-" + Math.random().toString(36).slice(2));
|
|
5932
|
+
captionEl.textContent = caption;
|
|
5933
|
+
captionEl.style.position = "absolute"; captionEl.style.width = "1px"; captionEl.style.height = "1px"; captionEl.style.overflow = "hidden"; captionEl.style.clip = "rect(0,0,0,0)";
|
|
5934
|
+
} else if (captionEl) {
|
|
5935
|
+
captionEl.remove();
|
|
5936
|
+
}
|
|
5937
|
+
// single tab stop: first option
|
|
5938
|
+
const _items = this.querySelector(".c-legend__items");
|
|
5939
|
+
if (_items) {
|
|
5940
|
+
const opts = Array.from(_items.querySelectorAll(".c-legend__item"));
|
|
5941
|
+
opts.forEach((o, i) => o.setAttribute("tabindex", i === 0 ? "0" : "-1"));
|
|
5942
|
+
if (captionEl) opts.forEach((o) => o.setAttribute("aria-describedby", captionEl.id));
|
|
5943
|
+
}
|
|
5944
|
+
// no-data entry from palette / no-data-color
|
|
5945
|
+
const ndColor = this.getAttribute("no-data-color");
|
|
5946
|
+
if (ndColor) {
|
|
5947
|
+
let nd = this.querySelector(".c-legend__no-data");
|
|
5948
|
+
if (!nd) { nd = document.createElement("div"); nd.className = "c-legend__no-data"; this.appendChild(nd); }
|
|
5949
|
+
nd.setAttribute("part", "no-data");
|
|
5950
|
+
nd.textContent = "No data";
|
|
5951
|
+
const glyph = document.createElement("span");
|
|
5952
|
+
glyph.className = "glyph";
|
|
5953
|
+
glyph.style.background = ndColor;
|
|
5954
|
+
nd.prepend(glyph);
|
|
5955
|
+
} else {
|
|
5956
|
+
const nd = this.querySelector(".c-legend__no-data");
|
|
5957
|
+
if (nd) nd.remove();
|
|
5958
|
+
}
|
|
5959
|
+
// audit notice
|
|
5960
|
+
const audit = this.getAttribute("audit");
|
|
5961
|
+
if (audit) {
|
|
5962
|
+
const a = this.ensure(".c-legend__audit", () => { const el = document.createElement("div"); el.className = "c-legend__audit"; return el; });
|
|
5963
|
+
a.textContent = audit;
|
|
5964
|
+
} else {
|
|
5965
|
+
const a = this.querySelector(".c-legend__audit");
|
|
5966
|
+
if (a) a.remove();
|
|
5967
|
+
}
|
|
5968
|
+
// continuous variant: ramp with two ends labelled
|
|
5969
|
+
if (this.hasAttribute("continuous")) {
|
|
5970
|
+
const ends = this.getAttribute("ends");
|
|
5971
|
+
let parsedEnds = null;
|
|
5972
|
+
if (ends) { try { parsedEnds = JSON.parse(ends); } catch (e) { parsedEnds = ends.split(","); } }
|
|
5973
|
+
if (Array.isArray(parsedEnds) && parsedEnds.length >= 2) {
|
|
5974
|
+
const r = this.ensure(".c-legend__ramp", () => { const el = document.createElement("div"); el.className = "c-legend__ramp"; return el; });
|
|
5975
|
+
// labels
|
|
5976
|
+
let left = this.querySelector(".c-legend__ramp-label--start");
|
|
5977
|
+
if (!left) { left = document.createElement("span"); left.className = "c-legend__ramp-label c-legend__ramp-label--start"; r.appendChild(left); }
|
|
5978
|
+
left.textContent = parsedEnds[0];
|
|
5979
|
+
let right = this.querySelector(".c-legend__ramp-label--end");
|
|
5980
|
+
if (!right) { right = document.createElement("span"); right.className = "c-legend__ramp-label c-legend__ramp-label--end"; r.appendChild(right); }
|
|
5981
|
+
right.textContent = parsedEnds[parsedEnds.length - 1];
|
|
5982
|
+
}
|
|
5983
|
+
}
|
|
5984
|
+
// size variant: differently-sized glyphs
|
|
5985
|
+
const sizeAttr = this.getAttribute("size");
|
|
5986
|
+
if (sizeAttr) {
|
|
5987
|
+
const sc = this.ensure(".c-legend__size", () => { const el = document.createElement("div"); el.className = "c-legend__size"; return el; });
|
|
5988
|
+
sc.textContent = sizeAttr;
|
|
5989
|
+
} else {
|
|
5990
|
+
const sc = this.querySelector(".c-legend__size");
|
|
5991
|
+
if (sc) sc.remove();
|
|
5992
|
+
}
|
|
5993
|
+
// classification line
|
|
5994
|
+
const classification = this.getAttribute("classification");
|
|
5995
|
+
if (classification) {
|
|
5996
|
+
const c = this.ensure(".c-legend__classification", () => { const el = document.createElement("div"); el.className = "c-legend__classification"; return el; });
|
|
5997
|
+
c.textContent = classification;
|
|
5998
|
+
} else {
|
|
5999
|
+
const c = this.querySelector(".c-legend__classification");
|
|
6000
|
+
if (c) c.remove();
|
|
6001
|
+
}
|
|
6002
|
+
// data table (collapsible)
|
|
6003
|
+
const tableAttr = this.getAttribute("table");
|
|
6004
|
+
if (tableAttr) {
|
|
6005
|
+
let parsed = null;
|
|
6006
|
+
try { parsed = JSON.parse(tableAttr); } catch (e) { parsed = null; }
|
|
6007
|
+
if (Array.isArray(parsed)) {
|
|
6008
|
+
let det = this.querySelector(".c-legend__table-wrap");
|
|
6009
|
+
if (!det) { det = document.createElement("details"); det.className = "c-legend__table-wrap"; this.appendChild(det); }
|
|
6010
|
+
det.innerHTML = "";
|
|
6011
|
+
const sum = document.createElement("summary"); sum.textContent = "Data table"; det.appendChild(sum);
|
|
6012
|
+
const tbl = document.createElement("table"); tbl.className = "c-legend__table";
|
|
6013
|
+
const tbody = document.createElement("tbody");
|
|
6014
|
+
parsed.forEach((row) => {
|
|
6015
|
+
const tr = document.createElement("tr");
|
|
6016
|
+
const cells = Array.isArray(row) ? row : [row.label ?? row.key ?? "", row.value ?? ""];
|
|
6017
|
+
cells.forEach((cell) => { const td = document.createElement("td"); td.textContent = cell; tr.appendChild(td); });
|
|
6018
|
+
tbody.appendChild(tr);
|
|
6019
|
+
});
|
|
6020
|
+
tbl.appendChild(tbody);
|
|
6021
|
+
det.appendChild(tbl);
|
|
6022
|
+
}
|
|
6023
|
+
} else {
|
|
6024
|
+
const det = this.querySelector(".c-legend__table-wrap");
|
|
6025
|
+
if (det) det.remove();
|
|
6026
|
+
}
|
|
6027
|
+
// size variant on glyphs
|
|
6028
|
+
if (items) {
|
|
6029
|
+
// apply size to glyphs already rendered? handled below via re-render not needed
|
|
6030
|
+
}
|
|
6031
|
+
const method = this.getAttribute("method");
|
|
5800
6032
|
if (method) {
|
|
5801
6033
|
const m = this.ensure(".c-legend__method", () => { const el = document.createElement("div"); el.className = "c-legend__method"; return el; });
|
|
5802
6034
|
m.textContent = method;
|
|
@@ -5812,14 +6044,34 @@ class ContourLegend extends ContourBase {
|
|
|
5812
6044
|
const n = this.querySelector(".c-legend__norm");
|
|
5813
6045
|
if (n) n.remove();
|
|
5814
6046
|
}
|
|
5815
|
-
|
|
5816
|
-
|
|
5817
|
-
|
|
5818
|
-
|
|
5819
|
-
|
|
5820
|
-
|
|
5821
|
-
|
|
5822
|
-
|
|
6047
|
+
const ramp = this.getAttribute("ramp");
|
|
6048
|
+
if (ramp) {
|
|
6049
|
+
const r = this.ensure(".c-legend__ramp", () => { const el = document.createElement("div"); el.className = "c-legend__ramp"; return el; });
|
|
6050
|
+
r.style.background = ramp;
|
|
6051
|
+
// ramp routing: equal-width segments with break labels
|
|
6052
|
+
const breaksAttr = this.getAttribute("breaks");
|
|
6053
|
+
if (breaksAttr) {
|
|
6054
|
+
let breaks = null;
|
|
6055
|
+
try { breaks = JSON.parse(breaksAttr); } catch (e) { breaks = breaksAttr.split(",").map((s) => s.trim()); }
|
|
6056
|
+
if (Array.isArray(breaks)) {
|
|
6057
|
+
// remove old segments
|
|
6058
|
+
Array.from(r.querySelectorAll(".c-legend__ramp-segment")).forEach((n) => n.remove());
|
|
6059
|
+
breaks.forEach((b, i) => {
|
|
6060
|
+
const seg = document.createElement("span");
|
|
6061
|
+
seg.className = "c-legend__ramp-segment";
|
|
6062
|
+
seg.style.flex = "1";
|
|
6063
|
+
const lbl = document.createElement("span");
|
|
6064
|
+
lbl.className = "c-legend__ramp-break";
|
|
6065
|
+
lbl.textContent = String(b);
|
|
6066
|
+
seg.appendChild(lbl);
|
|
6067
|
+
r.appendChild(seg);
|
|
6068
|
+
});
|
|
6069
|
+
}
|
|
6070
|
+
}
|
|
6071
|
+
} else {
|
|
6072
|
+
const r = this.querySelector(".c-legend__ramp");
|
|
6073
|
+
if (r) r.remove();
|
|
6074
|
+
}
|
|
5823
6075
|
const scale = this.getAttribute("scale");
|
|
5824
6076
|
if (scale) {
|
|
5825
6077
|
const sc = this.ensure(".c-legend__scale", () => { const el = document.createElement("div"); el.className = "c-legend__scale"; return el; });
|
|
@@ -5837,6 +6089,7 @@ class ContourLegend extends ContourBase {
|
|
|
5837
6089
|
if (!btn || !this.contains(btn)) return;
|
|
5838
6090
|
const pressed = btn.getAttribute("aria-pressed") !== "true";
|
|
5839
6091
|
btn.setAttribute("aria-pressed", String(pressed));
|
|
6092
|
+
btn.setAttribute("aria-selected", String(pressed));
|
|
5840
6093
|
this.dispatchEvent(new CustomEvent("contour:legend-toggle", {
|
|
5841
6094
|
detail: { label: btn.textContent.trim(), key: btn.dataset.key || btn.textContent.trim(), pressed },
|
|
5842
6095
|
bubbles: true,
|
|
@@ -5869,11 +6122,34 @@ class ContourLegend extends ContourBase {
|
|
|
5869
6122
|
if (e.key === "ArrowDown" || e.key === "ArrowRight") {
|
|
5870
6123
|
e.preventDefault();
|
|
5871
6124
|
const next = items[(idx + 1) % items.length];
|
|
5872
|
-
if (next) next.focus();
|
|
6125
|
+
if (next) { next.focus(); items.forEach((o,i)=>o.setAttribute("tabindex", o===next?"0":"-1")); }
|
|
5873
6126
|
} else if (e.key === "ArrowUp" || e.key === "ArrowLeft") {
|
|
5874
6127
|
e.preventDefault();
|
|
5875
6128
|
const prev = items[(idx - 1 + items.length) % items.length];
|
|
5876
|
-
if (prev) prev.focus();
|
|
6129
|
+
if (prev) { prev.focus(); items.forEach((o)=>o.setAttribute("tabindex", o===prev?"0":"-1")); }
|
|
6130
|
+
} else if (e.key === "Home") {
|
|
6131
|
+
if (items.length > 4) { e.preventDefault(); items[0].focus(); items.forEach((o,i)=>o.setAttribute("tabindex", i===0?"0":"-1")); }
|
|
6132
|
+
} else if (e.key === "End") {
|
|
6133
|
+
if (items.length > 4) { e.preventDefault(); const last = items[items.length-1]; last.focus(); items.forEach((o)=>o.setAttribute("tabindex", o===last?"0":"-1")); }
|
|
6134
|
+
} else if (e.key === "Escape") {
|
|
6135
|
+
// clear selection
|
|
6136
|
+
items.forEach((o) => o.setAttribute("aria-selected", "false"));
|
|
6137
|
+
this.dispatchEvent(new CustomEvent("contour:clear", { bubbles: true, composed: true }));
|
|
6138
|
+
} else if (e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey) {
|
|
6139
|
+
// type-ahead
|
|
6140
|
+
if (items.length > 7) {
|
|
6141
|
+
const start = idx >= 0 ? idx + 1 : 0;
|
|
6142
|
+
for (let i = 0; i < items.length; i++) {
|
|
6143
|
+
const ii = (start + i) % items.length;
|
|
6144
|
+
const txt = (items[ii].textContent || "").trim().toLowerCase();
|
|
6145
|
+
if (txt.startsWith(e.key.toLowerCase())) {
|
|
6146
|
+
e.preventDefault();
|
|
6147
|
+
items[ii].focus();
|
|
6148
|
+
items.forEach((o,j)=>o.setAttribute("tabindex", j===ii?"0":"-1"));
|
|
6149
|
+
break;
|
|
6150
|
+
}
|
|
6151
|
+
}
|
|
6152
|
+
}
|
|
5877
6153
|
} else if (e.key === "Enter" || e.key === " ") {
|
|
5878
6154
|
e.preventDefault();
|
|
5879
6155
|
if (document.activeElement && document.activeElement.classList.contains("c-legend__item")) {
|
|
@@ -7548,72 +7824,130 @@ class ContourField extends ContourBase {
|
|
|
7548
7824
|
};
|
|
7549
7825
|
define("contour-field", ContourField);
|
|
7550
7826
|
class ContourRange extends ContourBase {
|
|
7551
|
-
static get observed() { return ["min", "max", "value", "label"]; }
|
|
7827
|
+
static get observed() { return ["min", "max", "value", "low", "high", "range", "sparkline", "label"]; }
|
|
7552
7828
|
static get formAssociated() { return true; }
|
|
7553
7829
|
static get properties() { return { min: { attribute: "min" }, max: { attribute: "max" }, value: { attribute: "value" }, label: { attribute: "label" } }; }
|
|
7554
|
-
|
|
7555
|
-
|
|
7556
|
-
|
|
7557
|
-
|
|
7558
|
-
|
|
7559
|
-
|
|
7560
|
-
|
|
7561
|
-
|
|
7562
|
-
|
|
7563
|
-
|
|
7564
|
-
|
|
7565
|
-
|
|
7566
|
-
|
|
7567
|
-
|
|
7568
|
-
|
|
7569
|
-
|
|
7570
|
-
|
|
7571
|
-
|
|
7572
|
-
|
|
7573
|
-
|
|
7574
|
-
|
|
7575
|
-
|
|
7576
|
-
|
|
7577
|
-
|
|
7578
|
-
|
|
7579
|
-
|
|
7580
|
-
|
|
7581
|
-
|
|
7582
|
-
|
|
7583
|
-
|
|
7584
|
-
|
|
7585
|
-
|
|
7830
|
+
render() {
|
|
7831
|
+
this.classList.add("c-range");
|
|
7832
|
+
const min = this.getAttribute("min") || "0";
|
|
7833
|
+
const max = this.getAttribute("max") || "100";
|
|
7834
|
+
const rangeMode = this.hasAttribute("range") || this.hasAttribute("low") || this.hasAttribute("high");
|
|
7835
|
+
// sparkline canvas
|
|
7836
|
+
const spark = this.getAttribute("sparkline");
|
|
7837
|
+
if (spark) {
|
|
7838
|
+
let canvas = this.querySelector(".c-range__sparkline");
|
|
7839
|
+
if (!canvas) { canvas = document.createElement("canvas"); canvas.className = "c-range__sparkline"; canvas.setAttribute("part", "sparkline-canvas"); this.insertBefore(canvas, this.firstChild); }
|
|
7840
|
+
} else {
|
|
7841
|
+
const c = this.querySelector(".c-range__sparkline");
|
|
7842
|
+
if (c) c.remove();
|
|
7843
|
+
}
|
|
7844
|
+
if (rangeMode) {
|
|
7845
|
+
// remove single input if present
|
|
7846
|
+
const single = this.querySelector("input.c-range:not(.c-range__low):not(.c-range__high)");
|
|
7847
|
+
// keep generic input? We'll use two named inputs
|
|
7848
|
+
let lowInput = this.querySelector("input.c-range__low");
|
|
7849
|
+
if (!lowInput) { lowInput = document.createElement("input"); lowInput.type = "range"; lowInput.className = "c-range c-range__low"; this.appendChild(lowInput); }
|
|
7850
|
+
let highInput = this.querySelector("input.c-range__high");
|
|
7851
|
+
if (!highInput) { highInput = document.createElement("input"); highInput.type = "range"; highInput.className = "c-range c-range__high"; this.appendChild(highInput); }
|
|
7852
|
+
lowInput.min = min; lowInput.max = max;
|
|
7853
|
+
highInput.min = min; highInput.max = max;
|
|
7854
|
+
const lowVal = this.getAttribute("low") || min;
|
|
7855
|
+
const highVal = this.getAttribute("high") || max;
|
|
7856
|
+
if (this._rangeUserLow !== null && this._rangeAttrLowAtDirty === (this.getAttribute("low") || min)) lowInput.value = this._rangeUserLow;
|
|
7857
|
+
else { lowInput.value = lowVal; this._rangeUserLow = null; this._rangeAttrLowAtDirty = null; }
|
|
7858
|
+
if (this._rangeUserHigh !== null && this._rangeAttrHighAtDirty === (this.getAttribute("high") || max)) highInput.value = this._rangeUserHigh;
|
|
7859
|
+
else { highInput.value = highVal; this._rangeUserHigh = null; this._rangeAttrHighAtDirty = null; }
|
|
7860
|
+
const label = this.getAttribute("label");
|
|
7861
|
+
if (label) { lowInput.setAttribute("aria-label", label + " low"); highInput.setAttribute("aria-label", label + " high"); }
|
|
7862
|
+
} else {
|
|
7863
|
+
// remove dual inputs
|
|
7864
|
+
Array.from(this.querySelectorAll("input.c-range__low, input.c-range__high")).forEach((n) => n.remove());
|
|
7865
|
+
const input = this.ensure("input.c-range", () => { const el = document.createElement("input"); el.type = "range"; return el; });
|
|
7866
|
+
// ensure class
|
|
7867
|
+
input.className = "c-range";
|
|
7868
|
+
input.type = "range";
|
|
7869
|
+
input.min = min;
|
|
7870
|
+
input.max = max;
|
|
7871
|
+
const attrVal = this.getAttribute("value") || "50";
|
|
7872
|
+
if (this._rangeUserValue !== null && this._rangeAttrAtDirty === (this.getAttribute("value") || "50")) {
|
|
7873
|
+
input.value = this._rangeUserValue;
|
|
7874
|
+
} else {
|
|
7875
|
+
input.value = attrVal;
|
|
7876
|
+
this._rangeUserValue = null;
|
|
7877
|
+
this._rangeAttrAtDirty = null;
|
|
7878
|
+
}
|
|
7879
|
+
const label = this.getAttribute("label");
|
|
7880
|
+
if (label) input.setAttribute("aria-label", label);
|
|
7881
|
+
else if (!input.hasAttribute("aria-label")) input.setAttribute("aria-label", "Range");
|
|
7882
|
+
const updateFill = () => {
|
|
7883
|
+
const mn = Number(input.min) || 0;
|
|
7884
|
+
const mx = Number(input.max) || 100;
|
|
7885
|
+
const val = Number(input.value) || 0;
|
|
7886
|
+
const pct = mx > mn ? ((val - mn) / (mx - mn)) * 100 : 0;
|
|
7887
|
+
input.style.setProperty("--fill", pct + "%");
|
|
7888
|
+
};
|
|
7889
|
+
updateFill();
|
|
7890
|
+
if (!input._fillWired) {
|
|
7891
|
+
input._fillWired = true;
|
|
7892
|
+
input.addEventListener("input", updateFill);
|
|
7893
|
+
}
|
|
7894
|
+
}
|
|
7895
|
+
}
|
|
7586
7896
|
}
|
|
7587
7897
|
// patch enhance onto ContourRange
|
|
7588
7898
|
const _origRangeRender = ContourRange.prototype.render;
|
|
7589
|
-
|
|
7590
|
-
|
|
7591
|
-
|
|
7592
|
-
|
|
7593
|
-
|
|
7594
|
-
|
|
7595
|
-
|
|
7596
|
-
|
|
7597
|
-
|
|
7598
|
-
|
|
7599
|
-
|
|
7600
|
-
|
|
7601
|
-
|
|
7602
|
-
|
|
7603
|
-
|
|
7604
|
-
|
|
7605
|
-
|
|
7606
|
-
|
|
7607
|
-
|
|
7608
|
-
|
|
7609
|
-
|
|
7610
|
-
|
|
7611
|
-
|
|
7612
|
-
|
|
7613
|
-
|
|
7614
|
-
|
|
7615
|
-
|
|
7616
|
-
|
|
7899
|
+
ContourRange.prototype.attributeChangedCallback = function(name, oldValue, newValue) {
|
|
7900
|
+
if (name === "value") { this._rangeUserValue = null; this._rangeAttrAtDirty = null; }
|
|
7901
|
+
if (name === "low") { this._rangeUserLow = null; this._rangeAttrLowAtDirty = null; }
|
|
7902
|
+
if (name === "high") { this._rangeUserHigh = null; this._rangeAttrHighAtDirty = null; }
|
|
7903
|
+
return ContourBase.prototype.attributeChangedCallback.call(this, name, oldValue, newValue);
|
|
7904
|
+
};
|
|
7905
|
+
ContourRange.prototype.enhance = function() {
|
|
7906
|
+
if (this._wiredRange) return;
|
|
7907
|
+
this._wiredRange = true;
|
|
7908
|
+
const sync = () => {
|
|
7909
|
+
const low = this.querySelector("input.c-range__low");
|
|
7910
|
+
const high = this.querySelector("input.c-range__high");
|
|
7911
|
+
const single = this.querySelector("input.c-range:not(.c-range__low):not(.c-range__high)");
|
|
7912
|
+
if (this._internals) {
|
|
7913
|
+
if (low && high) this._internals.setFormValue(low.value + "," + high.value);
|
|
7914
|
+
else if (single) this._internals.setFormValue(single.value);
|
|
7915
|
+
}
|
|
7916
|
+
};
|
|
7917
|
+
this.addEventListener("input", (e) => {
|
|
7918
|
+
const low = this.querySelector("input.c-range__low");
|
|
7919
|
+
const high = this.querySelector("input.c-range__high");
|
|
7920
|
+
const single = this.querySelector("input.c-range:not(.c-range__low):not(.c-range__high)");
|
|
7921
|
+
if (low && high && (e.target === low || e.target === high)) {
|
|
7922
|
+
this._rangeUserLow = low.value;
|
|
7923
|
+
this._rangeUserHigh = high.value;
|
|
7924
|
+
this._rangeAttrLowAtDirty = this.getAttribute("low") || (this.getAttribute("min") || "0");
|
|
7925
|
+
this._rangeAttrHighAtDirty = this.getAttribute("high") || (this.getAttribute("max") || "100");
|
|
7926
|
+
sync();
|
|
7927
|
+
this._emitForm("contour:input", { low: Number(low.value), high: Number(high.value) });
|
|
7928
|
+
this.dispatchEvent(new CustomEvent("contour:change", { bubbles: true, composed: true, detail: { low: Number(low.value), high: Number(high.value) } }));
|
|
7929
|
+
} else if (single && e.target === single) {
|
|
7930
|
+
this._rangeUserValue = single.value;
|
|
7931
|
+
this._rangeAttrAtDirty = this.getAttribute("value") || "50";
|
|
7932
|
+
sync();
|
|
7933
|
+
this._emitForm("contour:input");
|
|
7934
|
+
}
|
|
7935
|
+
});
|
|
7936
|
+
this.addEventListener("change", (e) => {
|
|
7937
|
+
const low = this.querySelector("input.c-range__low");
|
|
7938
|
+
const high = this.querySelector("input.c-range__high");
|
|
7939
|
+
const single = this.querySelector("input.c-range:not(.c-range__low):not(.c-range__high)");
|
|
7940
|
+
if (low && high && (e.target === low || e.target === high)) {
|
|
7941
|
+
sync();
|
|
7942
|
+
this._emitForm("contour:change", { low: Number(low.value), high: Number(high.value) });
|
|
7943
|
+
this.dispatchEvent(new CustomEvent("contour:change", { bubbles: true, composed: true, detail: { low: Number(low.value), high: Number(high.value) } }));
|
|
7944
|
+
} else if (single && e.target === single) {
|
|
7945
|
+
sync();
|
|
7946
|
+
this._emitForm("contour:change");
|
|
7947
|
+
}
|
|
7948
|
+
});
|
|
7949
|
+
sync();
|
|
7950
|
+
};
|
|
7617
7951
|
define("contour-range", ContourRange);
|
|
7618
7952
|
class ContourSwitch extends ContourBase {
|
|
7619
7953
|
static get observed() { return ["label", "required", "checked"]; }
|
|
@@ -8917,7 +9251,7 @@ class ContourCoordinate extends ContourBase {
|
|
|
8917
9251
|
}
|
|
8918
9252
|
define("contour-coordinate", ContourCoordinate);
|
|
8919
9253
|
class ContourLayerPanel extends ContourBase {
|
|
8920
|
-
static get observed() { return ["label", "items", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton"]; }
|
|
9254
|
+
static get observed() { return ["label", "items", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton", "allow-rename", "allow-remove", "allow-duplicate", "allow-zoom"]; }
|
|
8921
9255
|
static get properties() { return { label: { attribute: "label" }, items: { attribute: "items" }, src: { attribute: "src" } }; }
|
|
8922
9256
|
render() {
|
|
8923
9257
|
this.classList.add("c-layer-panel");
|
|
@@ -8938,19 +9272,24 @@ class ContourLayerPanel extends ContourBase {
|
|
|
8938
9272
|
const authoredLayerItems = Array.from(this.querySelectorAll(":scope > .c-layer-panel__item"));
|
|
8939
9273
|
// Preserve user-toggled visibility across re-renders (B3-09): a src
|
|
8940
9274
|
// reload must not re-check a layer the user un-checked.
|
|
8941
|
-
|
|
8942
|
-
|
|
8943
|
-
|
|
8944
|
-
|
|
8945
|
-
|
|
8946
|
-
|
|
9275
|
+
const savedVisibility = new Map();
|
|
9276
|
+
this.querySelectorAll(".c-layer-panel__item").forEach((el) => {
|
|
9277
|
+
const nm = el.querySelector(".c-layer-panel__name");
|
|
9278
|
+
const tg = el.querySelector(".c-layer-panel__toggle");
|
|
9279
|
+
if (nm && tg) {
|
|
9280
|
+
const v = tg.hasAttribute("aria-pressed") ? tg.getAttribute("aria-pressed") === "true" : !!tg.checked;
|
|
9281
|
+
savedVisibility.set(nm.textContent, v);
|
|
9282
|
+
}
|
|
9283
|
+
});
|
|
8947
9284
|
let parsed = null;
|
|
8948
9285
|
if (authoredLayerItems.length) {
|
|
8949
|
-
|
|
8950
|
-
|
|
8951
|
-
|
|
8952
|
-
|
|
8953
|
-
|
|
9286
|
+
parsed = authoredLayerItems.map((el) => {
|
|
9287
|
+
const nm = el.querySelector(".c-layer-panel__name");
|
|
9288
|
+
const tg = el.querySelector(".c-layer-panel__toggle");
|
|
9289
|
+
const visible = tg ? (tg.hasAttribute("aria-pressed") ? tg.getAttribute("aria-pressed") === "true" : !!tg.checked) : true;
|
|
9290
|
+
const cap = el.querySelector(".c-layer-panel__caption");
|
|
9291
|
+
return { name: nm ? nm.textContent : "", visible, caption: cap ? cap.textContent : (el.dataset.caption || undefined) };
|
|
9292
|
+
});
|
|
8954
9293
|
authoredLayerItems.forEach((el) => el.remove());
|
|
8955
9294
|
} else if (items) {
|
|
8956
9295
|
try {
|
|
@@ -8959,21 +9298,31 @@ class ContourLayerPanel extends ContourBase {
|
|
|
8959
9298
|
} catch (e) { /* keep existing */ }
|
|
8960
9299
|
}
|
|
8961
9300
|
if (parsed) { parsed.forEach((it) => {
|
|
8962
|
-
|
|
8963
|
-
|
|
8964
|
-
|
|
8965
|
-
|
|
8966
|
-
|
|
8967
|
-
|
|
8968
|
-
|
|
8969
|
-
|
|
8970
|
-
|
|
9301
|
+
const name = typeof it === "string" ? it : (it.name || it.label || "");
|
|
9302
|
+
const caption = (typeof it === "object" && it) ? (it.caption || it.subtitle || "") : "";
|
|
9303
|
+
const item = document.createElement("div");
|
|
9304
|
+
item.className = "c-layer-panel__item" + (it.dragging ? " c-layer-panel__item--dragging" : "");
|
|
9305
|
+
const toggle = document.createElement("button");
|
|
9306
|
+
toggle.type = "button";
|
|
9307
|
+
toggle.className = "c-layer-panel__toggle";
|
|
9308
|
+
toggle.setAttribute("part", "visibility-toggle");
|
|
9309
|
+
toggle.setAttribute("aria-label", "Toggle " + (name || "layer"));
|
|
9310
|
+
const isVisible = savedVisibility.has(name) ? savedVisibility.get(name) : (typeof it === "object" && it.visible !== false);
|
|
9311
|
+
toggle.setAttribute("aria-pressed", String(!!isVisible));
|
|
9312
|
+
toggle.checked = !!isVisible;
|
|
9313
|
+
toggle.textContent = isVisible ? "●" : "○";
|
|
8971
9314
|
item.appendChild(toggle);
|
|
8972
9315
|
const nm = document.createElement("span");
|
|
8973
9316
|
nm.className = "c-layer-panel__name";
|
|
8974
9317
|
nm.textContent = name;
|
|
8975
9318
|
item.appendChild(nm);
|
|
8976
|
-
|
|
9319
|
+
if (caption) {
|
|
9320
|
+
const cap = document.createElement("span");
|
|
9321
|
+
cap.className = "c-layer-panel__caption";
|
|
9322
|
+
cap.textContent = caption;
|
|
9323
|
+
item.appendChild(cap);
|
|
9324
|
+
}
|
|
9325
|
+
const opacity = document.createElement("input");
|
|
8977
9326
|
opacity.type = "range";
|
|
8978
9327
|
opacity.className = "c-layer-panel__opacity";
|
|
8979
9328
|
opacity.min = "0";
|
|
@@ -8982,24 +9331,38 @@ class ContourLayerPanel extends ContourBase {
|
|
|
8982
9331
|
opacity.value = (typeof it === "object" && it.opacity != null) ? it.opacity : "100";
|
|
8983
9332
|
item.appendChild(opacity);
|
|
8984
9333
|
// rename input (hidden by default, toggled via button)
|
|
9334
|
+
if (this.getAttribute("allow-rename") !== "false") {
|
|
8985
9335
|
const renameBtn = document.createElement("button");
|
|
8986
9336
|
renameBtn.type = "button";
|
|
8987
9337
|
renameBtn.className = "c-layer-panel__rename";
|
|
8988
9338
|
renameBtn.textContent = "Rename";
|
|
8989
9339
|
renameBtn.setAttribute("aria-label", "Rename " + (name || "layer"));
|
|
8990
9340
|
item.appendChild(renameBtn);
|
|
9341
|
+
}
|
|
9342
|
+
if (this.getAttribute("allow-duplicate") !== "false") {
|
|
8991
9343
|
const dupBtn = document.createElement("button");
|
|
8992
9344
|
dupBtn.type = "button";
|
|
8993
9345
|
dupBtn.className = "c-layer-panel__duplicate";
|
|
8994
9346
|
dupBtn.textContent = "Duplicate";
|
|
8995
9347
|
dupBtn.setAttribute("aria-label", "Duplicate " + (name || "layer"));
|
|
8996
9348
|
item.appendChild(dupBtn);
|
|
9349
|
+
}
|
|
9350
|
+
if (this.getAttribute("allow-zoom") !== "false") {
|
|
8997
9351
|
const zoomBtn = document.createElement("button");
|
|
8998
9352
|
zoomBtn.type = "button";
|
|
8999
9353
|
zoomBtn.className = "c-layer-panel__zoom";
|
|
9000
9354
|
zoomBtn.textContent = "Zoom";
|
|
9001
9355
|
zoomBtn.setAttribute("aria-label", "Zoom to " + (name || "layer"));
|
|
9002
9356
|
item.appendChild(zoomBtn);
|
|
9357
|
+
}
|
|
9358
|
+
if (this.getAttribute("allow-remove") !== "false") {
|
|
9359
|
+
const removeBtn = document.createElement("button");
|
|
9360
|
+
removeBtn.type = "button";
|
|
9361
|
+
removeBtn.className = "c-layer-panel__remove";
|
|
9362
|
+
removeBtn.textContent = "✕";
|
|
9363
|
+
removeBtn.setAttribute("aria-label", "Remove " + (name || "layer"));
|
|
9364
|
+
item.appendChild(removeBtn);
|
|
9365
|
+
}
|
|
9003
9366
|
const projSel = document.createElement("select");
|
|
9004
9367
|
projSel.className = "c-layer-panel__projection";
|
|
9005
9368
|
projSel.setAttribute("aria-label", "Projection of " + (name || "layer"));
|
|
@@ -9018,43 +9381,83 @@ class ContourLayerPanel extends ContourBase {
|
|
|
9018
9381
|
this._wiredLayerPanel = true;
|
|
9019
9382
|
// The panel's two controls (visibility toggle, opacity range) are rebuilt
|
|
9020
9383
|
// on every render, so both keep the host-delegated pattern (rule 12).
|
|
9021
|
-
|
|
9022
|
-
|
|
9023
|
-
|
|
9024
|
-
|
|
9025
|
-
|
|
9026
|
-
|
|
9027
|
-
|
|
9028
|
-
|
|
9029
|
-
|
|
9030
|
-
|
|
9031
|
-
|
|
9032
|
-
|
|
9033
|
-
|
|
9034
|
-
|
|
9035
|
-
|
|
9036
|
-
|
|
9037
|
-
|
|
9038
|
-
|
|
9039
|
-
|
|
9040
|
-
|
|
9041
|
-
|
|
9042
|
-
|
|
9043
|
-
|
|
9044
|
-
|
|
9045
|
-
|
|
9384
|
+
this.addEventListener("change", (e) => {
|
|
9385
|
+
const item = e.target && e.target.closest ? e.target.closest(".c-layer-panel__item") : null;
|
|
9386
|
+
if (!item || !this.contains(item)) return;
|
|
9387
|
+
const name = item.querySelector(".c-layer-panel__name")?.textContent || "";
|
|
9388
|
+
if (e.target.classList.contains("c-layer-panel__toggle")) {
|
|
9389
|
+
const now = (typeof e.target.checked === "boolean") ? e.target.checked : (e.target.getAttribute("aria-pressed") !== "true");
|
|
9390
|
+
e.target.checked = now;
|
|
9391
|
+
e.target.setAttribute("aria-pressed", String(now));
|
|
9392
|
+
e.target.textContent = now ? "●" : "○";
|
|
9393
|
+
this.dispatchEvent(new CustomEvent("contour:layer-visibility", { bubbles: true, composed: true, detail: { name, visible: now } }));
|
|
9394
|
+
} else if (e.target.classList.contains("c-layer-panel__opacity")) {
|
|
9395
|
+
this.dispatchEvent(new CustomEvent("contour:layer-opacity", { bubbles: true, composed: true, detail: { name, opacity: Number(e.target.value) } }));
|
|
9396
|
+
} else if (e.target.classList.contains("c-layer-panel__projection")) {
|
|
9397
|
+
this.dispatchEvent(new CustomEvent("contour:layer-projection", { bubbles: true, composed: true, detail: { name, projection: e.target.value } }));
|
|
9398
|
+
}
|
|
9399
|
+
});
|
|
9400
|
+
this.addEventListener("click", (e) => {
|
|
9401
|
+
const btn = e.target && e.target.closest ? e.target.closest("button") : null;
|
|
9402
|
+
if (!btn || !this.contains(btn)) return;
|
|
9403
|
+
const item = btn.closest(".c-layer-panel__item");
|
|
9404
|
+
if (btn.classList.contains("c-layer-panel__toggle")) {
|
|
9405
|
+
if (!item) return;
|
|
9406
|
+
const name = item.querySelector(".c-layer-panel__name")?.textContent || "";
|
|
9407
|
+
const now = btn.getAttribute("aria-pressed") !== "true";
|
|
9408
|
+
btn.setAttribute("aria-pressed", String(now));
|
|
9409
|
+
btn.checked = now;
|
|
9410
|
+
btn.textContent = now ? "●" : "○";
|
|
9411
|
+
this.dispatchEvent(new CustomEvent("contour:layer-visibility", { bubbles: true, composed: true, detail: { name, visible: now } }));
|
|
9412
|
+
return;
|
|
9413
|
+
}
|
|
9414
|
+
if (!item) return;
|
|
9415
|
+
const name = item.querySelector(".c-layer-panel__name")?.textContent || "";
|
|
9416
|
+
if (btn.classList.contains("c-layer-panel__rename")) {
|
|
9417
|
+
const newName = prompt("Rename layer", name);
|
|
9418
|
+
const trimmed = newName ? newName.trim() : "";
|
|
9419
|
+
if (trimmed && trimmed !== name) {
|
|
9420
|
+
const nm = item.querySelector(".c-layer-panel__name");
|
|
9421
|
+
if (nm) nm.textContent = trimmed;
|
|
9422
|
+
this.dispatchEvent(new CustomEvent("contour:layer-rename", { bubbles: true, composed: true, detail: { name, newName: trimmed } }));
|
|
9423
|
+
}
|
|
9424
|
+
} else if (btn.classList.contains("c-layer-panel__duplicate")) {
|
|
9425
|
+
this.dispatchEvent(new CustomEvent("contour:layer-duplicate", { bubbles: true, composed: true, detail: { name } }));
|
|
9426
|
+
} else if (btn.classList.contains("c-layer-panel__zoom")) {
|
|
9427
|
+
this.dispatchEvent(new CustomEvent("contour:layer-zoom", { bubbles: true, composed: true, detail: { name } }));
|
|
9428
|
+
} else if (btn.classList.contains("c-layer-panel__remove")) {
|
|
9429
|
+
this.dispatchEvent(new CustomEvent("contour:layer-remove", { bubbles: true, composed: true, detail: { name } }));
|
|
9430
|
+
}
|
|
9431
|
+
});
|
|
9432
|
+
this.addEventListener("keydown", (e) => {
|
|
9433
|
+
if (e.target && e.target.classList && e.target.classList.contains("c-layer-panel__toggle") && (e.key === "Enter" || e.key === " ")) {
|
|
9434
|
+
e.preventDefault();
|
|
9435
|
+
e.target.click();
|
|
9436
|
+
return;
|
|
9046
9437
|
}
|
|
9047
|
-
|
|
9048
|
-
|
|
9049
|
-
|
|
9050
|
-
|
|
9051
|
-
|
|
9052
|
-
|
|
9053
|
-
|
|
9438
|
+
const item = e.target && e.target.closest ? e.target.closest(".c-layer-panel__item") : null;
|
|
9439
|
+
if (!item || !this.contains(item)) return;
|
|
9440
|
+
if (!(e.altKey) || (e.key !== "ArrowUp" && e.key !== "ArrowDown")) return;
|
|
9441
|
+
e.preventDefault();
|
|
9442
|
+
const items = Array.from(this.querySelectorAll(".c-layer-panel__item"));
|
|
9443
|
+
const idx = items.indexOf(item);
|
|
9444
|
+
if (idx < 0) return;
|
|
9445
|
+
const dir = e.key === "ArrowUp" ? -1 : 1;
|
|
9446
|
+
const newIdx = idx + dir;
|
|
9447
|
+
if (newIdx < 0 || newIdx >= items.length) return;
|
|
9448
|
+
item.classList.add("c-layer-panel__item--dragging");
|
|
9449
|
+
if (dir < 0) this.insertBefore(item, items[newIdx]);
|
|
9450
|
+
else this.insertBefore(items[newIdx], item);
|
|
9451
|
+
item.focus();
|
|
9452
|
+
setTimeout(() => item.classList.remove("c-layer-panel__item--dragging"), 200);
|
|
9453
|
+
const layerIds = Array.from(this.querySelectorAll(".c-layer-panel__item")).map((el) => el.querySelector(".c-layer-panel__name")?.textContent || "");
|
|
9454
|
+
this.dispatchEvent(new CustomEvent("contour:layer-reorder", { bubbles: true, composed: true, detail: { layerIds } }));
|
|
9455
|
+
});
|
|
9456
|
+
}
|
|
9054
9457
|
}
|
|
9055
9458
|
define("contour-layer-panel", ContourLayerPanel);
|
|
9056
9459
|
class ContourTimeSlider extends ContourBase {
|
|
9057
|
-
static get observed() { return ["label", "value", "loop", "speed"]; }
|
|
9460
|
+
static get observed() { return ["label", "value", "loop", "speed", "speeds", "show-loop", "loop-label", "current-time", "time-format", "is-playing"]; }
|
|
9058
9461
|
static get properties() { return { label: { attribute: "label" }, value: { attribute: "value" }, src: { attribute: "src" } }; }
|
|
9059
9462
|
render() {
|
|
9060
9463
|
this.classList.add("c-time-slider");
|
|
@@ -9080,7 +9483,41 @@ class ContourTimeSlider extends ContourBase {
|
|
|
9080
9483
|
}
|
|
9081
9484
|
track.setAttribute("aria-label", this.getAttribute("label") || "Time");
|
|
9082
9485
|
const time = this.ensure(".c-time-slider__time", () => { const el = document.createElement("span"); el.className = "c-time-slider__time"; return el; });
|
|
9083
|
-
|
|
9486
|
+
const ct = this.getAttribute("current-time");
|
|
9487
|
+
time.textContent = ct ? ct : (this.getAttribute("label") || "");
|
|
9488
|
+
// speed selector
|
|
9489
|
+
let speeds = null;
|
|
9490
|
+
const speedsAttr = this.getAttribute("speeds");
|
|
9491
|
+
if (speedsAttr) { try { speeds = JSON.parse(speedsAttr); } catch (e) { speeds = null; } }
|
|
9492
|
+
const speedSel = this.ensure(".c-time-slider__speed", () => { const el = document.createElement("select"); el.className = "c-time-slider__speed"; el.setAttribute("aria-label", "Speed"); return el; });
|
|
9493
|
+
speedSel.innerHTML = "";
|
|
9494
|
+
const speedList = Array.isArray(speeds) ? speeds : [0.5, 1, 2, 5, 10];
|
|
9495
|
+
speedList.forEach((sp) => {
|
|
9496
|
+
const opt = document.createElement("option");
|
|
9497
|
+
opt.value = String(sp);
|
|
9498
|
+
opt.textContent = String(sp);
|
|
9499
|
+
if (String(sp) === (this.getAttribute("speed") || "")) opt.selected = true;
|
|
9500
|
+
speedSel.appendChild(opt);
|
|
9501
|
+
});
|
|
9502
|
+
const speedAttr = this.getAttribute("speed");
|
|
9503
|
+
if (speedAttr) speedSel.value = speedAttr;
|
|
9504
|
+
// loop toggle
|
|
9505
|
+
const showLoop = this.hasAttribute("show-loop");
|
|
9506
|
+
if (showLoop) {
|
|
9507
|
+
const loopBtn = this.ensure(".c-time-slider__loop", () => { const el = document.createElement("button"); el.className = "c-time-slider__loop"; el.type = "button"; el.setAttribute("aria-label", this.getAttribute("loop-label") || "Loop"); return el; });
|
|
9508
|
+
loopBtn.setAttribute("aria-pressed", this.hasAttribute("loop") ? "true" : "false");
|
|
9509
|
+
loopBtn.textContent = this.getAttribute("loop-label") || "Loop";
|
|
9510
|
+
} else {
|
|
9511
|
+
const lb = this.querySelector(".c-time-slider__loop");
|
|
9512
|
+
if (lb) lb.remove();
|
|
9513
|
+
}
|
|
9514
|
+
// is-playing reflects on play button
|
|
9515
|
+
if (this.hasAttribute("is-playing")) {
|
|
9516
|
+
play.setAttribute("data-state", "pause");
|
|
9517
|
+
play.setAttribute("aria-label", "Pause");
|
|
9518
|
+
const use = play.querySelector("use");
|
|
9519
|
+
if (use) use.setAttribute("href", "#i-pause");
|
|
9520
|
+
}
|
|
9084
9521
|
}
|
|
9085
9522
|
enhance() {
|
|
9086
9523
|
if (this._wiredTimeSlider) return;
|
|
@@ -9116,21 +9553,39 @@ class ContourTimeSlider extends ContourBase {
|
|
|
9116
9553
|
};
|
|
9117
9554
|
this.addEventListener("click", (e) => {
|
|
9118
9555
|
const btn = e.target && e.target.closest ? e.target.closest(".c-time-slider__play") : null;
|
|
9119
|
-
if (
|
|
9120
|
-
|
|
9121
|
-
|
|
9122
|
-
|
|
9123
|
-
|
|
9124
|
-
|
|
9125
|
-
|
|
9126
|
-
|
|
9127
|
-
|
|
9128
|
-
|
|
9129
|
-
|
|
9130
|
-
|
|
9131
|
-
|
|
9556
|
+
if (btn) {
|
|
9557
|
+
const playing = btn.getAttribute("data-state") === "play";
|
|
9558
|
+
btn.setAttribute("data-state", playing ? "pause" : "play");
|
|
9559
|
+
btn.setAttribute("aria-label", playing ? "Pause" : "Play");
|
|
9560
|
+
const use = btn.querySelector("use");
|
|
9561
|
+
if (use) use.setAttribute("href", playing ? "#i-pause" : "#i-play");
|
|
9562
|
+
if (playing) {
|
|
9563
|
+
stop();
|
|
9564
|
+
const speed = parseFloat(this.getAttribute("speed") || "1") || 1;
|
|
9565
|
+
const delay = Math.max(100, 1000 / speed);
|
|
9566
|
+
timer = setInterval(step, delay);
|
|
9567
|
+
this.dispatchEvent(new CustomEvent("contour:play", { bubbles: true, composed: true }));
|
|
9568
|
+
} else {
|
|
9569
|
+
stop();
|
|
9570
|
+
this.dispatchEvent(new CustomEvent("contour:pause", { bubbles: true, composed: true }));
|
|
9571
|
+
}
|
|
9572
|
+
return;
|
|
9573
|
+
}
|
|
9574
|
+
const loopBtn = e.target && e.target.closest ? e.target.closest(".c-time-slider__loop") : null;
|
|
9575
|
+
if (loopBtn) {
|
|
9576
|
+
const next = loopBtn.getAttribute("aria-pressed") !== "true";
|
|
9577
|
+
loopBtn.setAttribute("aria-pressed", String(next));
|
|
9578
|
+
this.toggleAttribute("loop", next);
|
|
9579
|
+
this.dispatchEvent(new CustomEvent("contour:loop-change", { detail: { loop: next }, bubbles: true, composed: true }));
|
|
9132
9580
|
}
|
|
9133
9581
|
});
|
|
9582
|
+
// speed select change (delegated)
|
|
9583
|
+
this.addEventListener("change", (e) => {
|
|
9584
|
+
const sel = e.target && e.target.closest ? e.target.closest(".c-time-slider__speed") : null;
|
|
9585
|
+
if (!sel) return;
|
|
9586
|
+
const speed = Number(sel.value);
|
|
9587
|
+
this.dispatchEvent(new CustomEvent("contour:speed-change", { detail: { speed }, bubbles: true, composed: true }));
|
|
9588
|
+
});
|
|
9134
9589
|
onDispose(this, stop);
|
|
9135
9590
|
}
|
|
9136
9591
|
disconnectedCallback() {
|
|
@@ -10665,7 +11120,7 @@ class ContourTocFull extends ContourBase {
|
|
|
10665
11120
|
}
|
|
10666
11121
|
define("contour-toc", ContourTocFull);
|
|
10667
11122
|
class ContourFilterBar extends ContourBase {
|
|
10668
|
-
static get observed() { return ["label", "divider", "items", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton"]; }
|
|
11123
|
+
static get observed() { return ["label", "divider", "items", "input", "placeholder", "mode", "modes", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton"]; }
|
|
10669
11124
|
static get properties() { return { label: { attribute: "label" }, divider: { attribute: "divider" }, items: { attribute: "items" }, src: { attribute: "src" } }; }
|
|
10670
11125
|
render() {
|
|
10671
11126
|
this.classList.add("c-filter-bar");
|
|
@@ -10680,13 +11135,48 @@ class ContourFilterBar extends ContourBase {
|
|
|
10680
11135
|
const l = this.querySelector(".c-filter-bar__label");
|
|
10681
11136
|
if (l) l.remove();
|
|
10682
11137
|
}
|
|
10683
|
-
|
|
10684
|
-
|
|
10685
|
-
|
|
10686
|
-
|
|
10687
|
-
|
|
10688
|
-
|
|
10689
|
-
|
|
11138
|
+
if (this.hasAttribute("divider")) {
|
|
11139
|
+
this.ensure(".c-filter-bar__divider", () => { const el = document.createElement("span"); el.className = "c-filter-bar__divider"; return el; });
|
|
11140
|
+
} else {
|
|
11141
|
+
const d = this.querySelector(".c-filter-bar__divider");
|
|
11142
|
+
if (d) d.remove();
|
|
11143
|
+
}
|
|
11144
|
+
// Text input support
|
|
11145
|
+
if (this.hasAttribute("input") || this.hasAttribute("placeholder")) {
|
|
11146
|
+
let inp = this.querySelector(".c-filter-bar__input");
|
|
11147
|
+
if (!inp) { inp = document.createElement("input"); inp.type = "search"; inp.className = "c-filter-bar__input"; this.appendChild(inp); }
|
|
11148
|
+
const ph = this.getAttribute("placeholder");
|
|
11149
|
+
if (ph) inp.setAttribute("placeholder", ph);
|
|
11150
|
+
} else {
|
|
11151
|
+
const inp = this.querySelector(".c-filter-bar__input");
|
|
11152
|
+
if (inp) inp.remove();
|
|
11153
|
+
}
|
|
11154
|
+
// Mode toolbar
|
|
11155
|
+
const modesAttr = this.getAttribute("modes");
|
|
11156
|
+
let modes = null;
|
|
11157
|
+
if (modesAttr) { try { modes = JSON.parse(modesAttr); } catch (e) { modes = modesAttr.split(",").map((s) => s.trim()); } }
|
|
11158
|
+
if (modes || this.hasAttribute("mode")) {
|
|
11159
|
+
let bar = this.querySelector(".c-filter-bar__modes");
|
|
11160
|
+
if (!bar) { bar = document.createElement("div"); bar.className = "c-filter-bar__modes"; this.appendChild(bar); }
|
|
11161
|
+
bar.innerHTML = "";
|
|
11162
|
+
const current = this.getAttribute("mode");
|
|
11163
|
+
const list = Array.isArray(modes) ? modes : ["draw", "erase", "select"];
|
|
11164
|
+
list.forEach((m) => {
|
|
11165
|
+
const name = typeof m === "string" ? m : (m.label || m.value || m);
|
|
11166
|
+
const val = typeof m === "string" ? m : (m.value || m.label || m);
|
|
11167
|
+
const btn = document.createElement("button");
|
|
11168
|
+
btn.type = "button";
|
|
11169
|
+
btn.className = "c-filter-bar__mode";
|
|
11170
|
+
btn.textContent = name;
|
|
11171
|
+
btn.dataset.mode = val;
|
|
11172
|
+
if (current && current === val) btn.setAttribute("aria-pressed", "true");
|
|
11173
|
+
bar.appendChild(btn);
|
|
11174
|
+
});
|
|
11175
|
+
} else {
|
|
11176
|
+
const bar = this.querySelector(".c-filter-bar__modes");
|
|
11177
|
+
if (bar) bar.remove();
|
|
11178
|
+
}
|
|
11179
|
+
// Render filter pills from items.
|
|
10690
11180
|
Array.from(this.querySelectorAll(".c-filter-pill")).forEach((n) => n.remove());
|
|
10691
11181
|
const items = remoteData(this, "items");
|
|
10692
11182
|
let parsed = null;
|
|
@@ -10710,9 +11200,29 @@ class ContourFilterBar extends ContourBase {
|
|
|
10710
11200
|
}
|
|
10711
11201
|
if (!parsed && !label) renderEmpty(this, "filter-bar");
|
|
10712
11202
|
}
|
|
10713
|
-
|
|
10714
|
-
|
|
10715
|
-
|
|
11203
|
+
enhance() {
|
|
11204
|
+
wireRemovable(this);
|
|
11205
|
+
if (this._wiredFilterBar) return;
|
|
11206
|
+
this._wiredFilterBar = true;
|
|
11207
|
+
this.addEventListener("click", (e) => {
|
|
11208
|
+
const btn = e.target && e.target.closest ? e.target.closest(".c-filter-bar__mode") : null;
|
|
11209
|
+
if (!btn || !this.contains(btn)) return;
|
|
11210
|
+
const mode = btn.dataset.mode || btn.textContent.trim();
|
|
11211
|
+
Array.from(this.querySelectorAll(".c-filter-bar__mode")).forEach((b) => b.setAttribute("aria-pressed", String(b === btn)));
|
|
11212
|
+
this.dispatchEvent(new CustomEvent("contour:mode-change", { bubbles: true, composed: true, detail: { mode } }));
|
|
11213
|
+
});
|
|
11214
|
+
// text input
|
|
11215
|
+
const inp = this.querySelector(".c-filter-bar__input");
|
|
11216
|
+
if (inp && !inp._wiredFilterInput) {
|
|
11217
|
+
inp._wiredFilterInput = true;
|
|
11218
|
+
inp.addEventListener("input", () => {
|
|
11219
|
+
this.dispatchEvent(new CustomEvent("contour:input", { bubbles: true, composed: true, detail: { value: inp.value } }));
|
|
11220
|
+
});
|
|
11221
|
+
inp.addEventListener("change", () => {
|
|
11222
|
+
this.dispatchEvent(new CustomEvent("contour:change", { bubbles: true, composed: true, detail: { value: inp.value } }));
|
|
11223
|
+
});
|
|
11224
|
+
}
|
|
11225
|
+
}
|
|
10716
11226
|
}
|
|
10717
11227
|
define("contour-filter-bar", ContourFilterBar);
|
|
10718
11228
|
class ContourCommand extends ContourBase {
|
|
@@ -11751,8 +12261,8 @@ class ContourMapPopup extends ContourBase {
|
|
|
11751
12261
|
define("contour-map-popup", ContourMapPopup);
|
|
11752
12262
|
|
|
11753
12263
|
class ContourAnimationControls extends ContourBase {
|
|
11754
|
-
static get observed() { return ["playing", "speed"]; }
|
|
11755
|
-
static get properties() { return { playing: { attribute: "playing", type: Boolean }, speed: { attribute: "speed" } }; }
|
|
12264
|
+
static get observed() { return ["playing", "speed", "progress", "min", "max", "caption", "show-thumb", "show-thumb-caption"]; }
|
|
12265
|
+
static get properties() { return { playing: { attribute: "playing", type: Boolean }, speed: { attribute: "speed" }, progress: { attribute: "progress" }, min: { attribute: "min" }, max: { attribute: "max" } }; }
|
|
11756
12266
|
render() {
|
|
11757
12267
|
this.classList.add("c-animation-controls");
|
|
11758
12268
|
const playBtn = this.ensure(".c-animation-controls__play", () => { const el = document.createElement("button"); el.className = "c-btn c-btn--sm c-animation-controls__play"; el.type = "button"; return el; });
|
|
@@ -11761,6 +12271,26 @@ class ContourAnimationControls extends ContourBase {
|
|
|
11761
12271
|
const speed = this.getAttribute("speed") || "1x";
|
|
11762
12272
|
const speedBtn = this.ensure(".c-animation-controls__speed", () => { const el = document.createElement("button"); el.className = "c-btn c-btn--sm c-animation-controls__speed"; el.type = "button"; return el; });
|
|
11763
12273
|
speedBtn.textContent = speed;
|
|
12274
|
+
// scrubber
|
|
12275
|
+
const scrubber = this.ensure(".c-animation-controls__scrubber", () => { const el = document.createElement("input"); el.className = "c-animation-controls__scrubber"; el.type = "range"; return el; });
|
|
12276
|
+
if (this.getAttribute("show-thumb") === "false") scrubber.classList.remove("c-animation-controls__scrubber--thumb");
|
|
12277
|
+
else scrubber.classList.add("c-animation-controls__scrubber--thumb");
|
|
12278
|
+
scrubber.min = this.getAttribute("min") || "0";
|
|
12279
|
+
scrubber.max = this.getAttribute("max") || "100";
|
|
12280
|
+
scrubber.value = this.getAttribute("progress") || "0";
|
|
12281
|
+
const caption = this.getAttribute("caption");
|
|
12282
|
+
if (caption) scrubber.setAttribute("aria-label", caption);
|
|
12283
|
+
else if (!scrubber.getAttribute("aria-label")) scrubber.setAttribute("aria-label", "Playhead");
|
|
12284
|
+
// caption display
|
|
12285
|
+
const showCaption = this.hasAttribute("show-thumb-caption") || this.hasAttribute("show-thumb");
|
|
12286
|
+
if (caption && showCaption) {
|
|
12287
|
+
const cap = this.ensure(".c-animation-controls__caption", () => { const el = document.createElement("span"); el.className = "c-animation-controls__caption"; return el; });
|
|
12288
|
+
cap.textContent = caption;
|
|
12289
|
+
} else {
|
|
12290
|
+
const cap = this.querySelector(".c-animation-controls__caption");
|
|
12291
|
+
if (cap) cap.remove();
|
|
12292
|
+
}
|
|
12293
|
+
// showThumb: hide thumb via attribute? keep default
|
|
11764
12294
|
}
|
|
11765
12295
|
enhance() {
|
|
11766
12296
|
if (this._wiredAnimControls) return;
|
|
@@ -11775,6 +12305,13 @@ class ContourAnimationControls extends ContourBase {
|
|
|
11775
12305
|
this.dispatchEvent(new CustomEvent("contour:change", { bubbles: true, composed: true, detail: { speed: speed.textContent } }));
|
|
11776
12306
|
}
|
|
11777
12307
|
});
|
|
12308
|
+
this.addEventListener("input", (e) => {
|
|
12309
|
+
const scrubber = e.target && e.target.closest ? e.target.closest(".c-animation-controls__scrubber") : null;
|
|
12310
|
+
if (scrubber && this.contains(scrubber)) {
|
|
12311
|
+
const v = Number(scrubber.value);
|
|
12312
|
+
this.dispatchEvent(new CustomEvent("contour:seek", { bubbles: true, composed: true, detail: { progress: v, value: v } }));
|
|
12313
|
+
}
|
|
12314
|
+
});
|
|
11778
12315
|
}
|
|
11779
12316
|
}
|
|
11780
12317
|
define("contour-animation-controls", ContourAnimationControls);
|
|
@@ -11881,7 +12418,7 @@ class ContourStyleSwitcher extends ContourBase {
|
|
|
11881
12418
|
define("contour-style-switcher", ContourStyleSwitcher);
|
|
11882
12419
|
|
|
11883
12420
|
class ContourStylePanel extends ContourBase {
|
|
11884
|
-
static get observed() { return ["title", "layers", "classification", "palette", "breaks", "opacity"]; }
|
|
12421
|
+
static get observed() { return ["title", "layers", "layer", "single", "classification", "palette", "breaks", "opacity", "n", "colors", "property"]; }
|
|
11885
12422
|
static get properties() { return { title: { attribute: "title" }, layers: { attribute: "layers" }, classification: { attribute: "classification" }, palette: { attribute: "palette" }, breaks: { attribute: "breaks" }, opacity: { attribute: "opacity" } }; }
|
|
11886
12423
|
render() {
|
|
11887
12424
|
this.classList.add("c-style-panel");
|
|
@@ -11890,7 +12427,71 @@ class ContourStylePanel extends ContourBase {
|
|
|
11890
12427
|
const t = this.ensure(".c-style-panel__title", () => { const el = document.createElement("div"); el.className = "c-style-panel__title"; return el; });
|
|
11891
12428
|
t.textContent = title;
|
|
11892
12429
|
}
|
|
11893
|
-
|
|
12430
|
+
const singleMode = this.hasAttribute("single") || !!this.getAttribute("layer");
|
|
12431
|
+
if (singleMode) {
|
|
12432
|
+
const body = this.ensure(".c-style-panel__body", () => { const el = document.createElement("div"); el.className = "c-style-panel__body"; return el; });
|
|
12433
|
+
body.innerHTML = "";
|
|
12434
|
+
// property field
|
|
12435
|
+
const propLabel = document.createElement("label"); propLabel.textContent = "Colour field"; propLabel.setAttribute("for", "property"); body.appendChild(propLabel);
|
|
12436
|
+
const propIn = document.createElement("input"); propIn.type = "text"; propIn.id = "property"; propIn.className = "c-style-panel__property c-input"; propIn.setAttribute("aria-label", "Colour field");
|
|
12437
|
+
const pv = this.getAttribute("property"); if (pv) propIn.value = pv;
|
|
12438
|
+
body.appendChild(propIn);
|
|
12439
|
+
// classification method selector (policy)
|
|
12440
|
+
const clsLabel = document.createElement("label"); clsLabel.textContent = "Classification"; clsLabel.setAttribute("for", "policy"); body.appendChild(clsLabel);
|
|
12441
|
+
const clsSel = document.createElement("select"); clsSel.id = "policy"; clsSel.className = "c-style-panel__classification c-input"; clsSel.setAttribute("aria-label", "Classification method");
|
|
12442
|
+
["equal","quantile","jenks","manual"].forEach((m) => { const o = document.createElement("option"); o.value = m; o.textContent = m; clsSel.appendChild(o); });
|
|
12443
|
+
const cls = this.getAttribute("classification"); if (cls) clsSel.value = cls;
|
|
12444
|
+
body.appendChild(clsSel);
|
|
12445
|
+
// palette picker
|
|
12446
|
+
const palLabel = document.createElement("label"); palLabel.textContent = "Palette"; palLabel.setAttribute("for", "palette"); body.appendChild(palLabel);
|
|
12447
|
+
const pal = document.createElement("input"); pal.type = "text"; pal.id = "palette"; pal.className = "c-style-panel__palette c-input"; pal.placeholder = "palette"; pal.setAttribute("aria-label", "Palette");
|
|
12448
|
+
const palv = this.getAttribute("palette"); if (palv) pal.value = palv;
|
|
12449
|
+
body.appendChild(pal);
|
|
12450
|
+
// n (class count)
|
|
12451
|
+
const nLabel = document.createElement("label"); nLabel.textContent = "Classes"; nLabel.setAttribute("for", "n"); body.appendChild(nLabel);
|
|
12452
|
+
const nIn = document.createElement("input"); nIn.type = "number"; nIn.id = "n"; nIn.className = "c-style-panel__n c-input"; nIn.min = "2"; nIn.max = "12"; nIn.setAttribute("aria-label", "Class count");
|
|
12453
|
+
const nv = this.getAttribute("n"); if (nv) nIn.value = nv; else nIn.value = "5";
|
|
12454
|
+
body.appendChild(nIn);
|
|
12455
|
+
// opacity slider
|
|
12456
|
+
const op = document.createElement("input"); op.type = "range"; op.className = "c-style-panel__opacity"; op.min = "0"; op.max = "100";
|
|
12457
|
+
const ov = this.getAttribute("opacity"); op.value = ov != null ? ov : "100";
|
|
12458
|
+
body.appendChild(op);
|
|
12459
|
+
// breaks as .break elements per class
|
|
12460
|
+
const breaksAttr = this.getAttribute("breaks");
|
|
12461
|
+
let breaksArr = null;
|
|
12462
|
+
if (breaksAttr) { try { breaksArr = JSON.parse(breaksAttr); } catch (e) { breaksArr = breaksAttr.split(",").map((s) => s.trim()); } }
|
|
12463
|
+
if (Array.isArray(breaksArr) && breaksArr.length) {
|
|
12464
|
+
const breaksWrap = document.createElement("div"); breaksWrap.className = "c-style-panel__breaks breaks";
|
|
12465
|
+
breaksArr.forEach((b, i) => {
|
|
12466
|
+
const br = document.createElement("div"); br.className = "break";
|
|
12467
|
+
br.textContent = String(b);
|
|
12468
|
+
breaksWrap.appendChild(br);
|
|
12469
|
+
});
|
|
12470
|
+
body.appendChild(breaksWrap);
|
|
12471
|
+
}
|
|
12472
|
+
// color swatches
|
|
12473
|
+
const colorsAttr = this.getAttribute("colors");
|
|
12474
|
+
let colors = null;
|
|
12475
|
+
if (colorsAttr) { try { colors = JSON.parse(colorsAttr); } catch (e) { colors = colorsAttr.split(",").map((s) => s.trim()); } }
|
|
12476
|
+
if (Array.isArray(colors)) {
|
|
12477
|
+
const list = document.createElement("div"); list.className = "c-style-panel__colors colours";
|
|
12478
|
+
colors.forEach((c, i) => {
|
|
12479
|
+
const sw = document.createElement("input"); sw.type = "color"; sw.className = "c-style-panel__color c-input"; sw.setAttribute("aria-label", "Colour for class " + (i + 1));
|
|
12480
|
+
sw.value = c;
|
|
12481
|
+
sw.addEventListener("input", () => { sw.setAttribute("data-edited", "true"); });
|
|
12482
|
+
list.appendChild(sw);
|
|
12483
|
+
});
|
|
12484
|
+
body.appendChild(list);
|
|
12485
|
+
}
|
|
12486
|
+
// Apply/Revert buttons
|
|
12487
|
+
const actions = document.createElement("div"); actions.className = "c-style-panel__actions actions";
|
|
12488
|
+
const applyBtn = document.createElement("button"); applyBtn.type = "button"; applyBtn.className = "c-btn primary"; applyBtn.textContent = "Apply";
|
|
12489
|
+
const revertBtn = document.createElement("button"); revertBtn.type = "button"; revertBtn.className = "c-btn"; revertBtn.textContent = "Revert";
|
|
12490
|
+
actions.appendChild(applyBtn); actions.appendChild(revertBtn);
|
|
12491
|
+
body.appendChild(actions);
|
|
12492
|
+
return;
|
|
12493
|
+
}
|
|
12494
|
+
const layers = this.getAttribute("layers");
|
|
11894
12495
|
const body = this.ensure(".c-style-panel__body", () => { const el = document.createElement("div"); el.className = "c-style-panel__body"; return el; });
|
|
11895
12496
|
// Slotted content support: authored .c-style-panel__row children take
|
|
11896
12497
|
// precedence over the JSON `layers` attribute.
|
|
@@ -11981,6 +12582,15 @@ class ContourStylePanel extends ContourBase {
|
|
|
11981
12582
|
this.dispatchEvent(new CustomEvent("contour:style-resolved", { detail: { value: t.value, layer: name, property: t.classList.contains("c-style-panel__palette") ? "palette" : "breaks" }, bubbles: true, composed: true }));
|
|
11982
12583
|
}
|
|
11983
12584
|
});
|
|
12585
|
+
this.addEventListener("click", (e) => {
|
|
12586
|
+
const t = e.target && e.target.closest ? e.target.closest("button") : null;
|
|
12587
|
+
if (!t || !this.contains(t)) return;
|
|
12588
|
+
if (t.textContent.trim() === "Apply") {
|
|
12589
|
+
this.dispatchEvent(new CustomEvent("contour:style-resolved", { detail: { applied: true }, bubbles: true, composed: true }));
|
|
12590
|
+
} else if (t.textContent.trim() === "Revert") {
|
|
12591
|
+
this.dispatchEvent(new CustomEvent("contour:style-resolved", { detail: { applied: false }, bubbles: true, composed: true }));
|
|
12592
|
+
}
|
|
12593
|
+
});
|
|
11984
12594
|
}
|
|
11985
12595
|
}
|
|
11986
12596
|
define("contour-style-panel", ContourStylePanel);
|