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