contour-ds 1.1.0 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/build-manifest.json +35 -35
- package/dist/contour-wc.esm.js +493 -159
- package/dist/contour-wc.esm.min.js +1 -1
- package/dist/contour-wc.js +493 -159
- package/dist/contour-wc.min.js +1 -1
- package/dist/contour.components.json +36 -10
- package/dist/contour.css +98 -35
- package/dist/contour.min.css +1 -1
- 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 +2 -2
- 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 +6 -3
- package/dist/wc/data.mjs +138 -28
- package/dist/wc/forms.mjs +119 -61
- package/dist/wc/map.mjs +123 -54
- package/dist/wc/navigation.mjs +66 -11
- package/dist/wc/ui.mjs +41 -2
- package/package.json +1 -1
package/dist/contour-wc.esm.js
CHANGED
|
@@ -105,6 +105,8 @@
|
|
|
105
105
|
"contour:layer-duplicate": { payload: ["name"], composed: true },
|
|
106
106
|
"contour:layer-zoom": { payload: ["name"], composed: true },
|
|
107
107
|
"contour:layer-projection": { payload: ["name", "projection"], composed: true },
|
|
108
|
+
"contour:layer-remove": { payload: ["name"], composed: true },
|
|
109
|
+
"contour:layer-reorder": { payload: ["layerIds"], composed: true },
|
|
108
110
|
"contour:layer-toggle": { payload: ["name"], composed: true },
|
|
109
111
|
"contour:layer-visibility": { payload: ["name", "visible"], composed: true },
|
|
110
112
|
"contour:legend-toggle": { payload: ["label", "key", "layers", "pressed"], composed: true },
|
|
@@ -112,6 +114,7 @@
|
|
|
112
114
|
"contour:map-control": { payload: ["control"], composed: true },
|
|
113
115
|
"contour:map-attach": { payload: [], composed: true },
|
|
114
116
|
"contour:map-detach": { payload: [], composed: true },
|
|
117
|
+
"contour:mode-change": { payload: ["mode"], composed: true },
|
|
115
118
|
"contour:move": { payload: ["direction"], composed: true },
|
|
116
119
|
"contour:open": { payload: [], composed: true },
|
|
117
120
|
"contour:page": { payload: ["page"], composed: true },
|
|
@@ -174,13 +177,13 @@
|
|
|
174
177
|
// role, open, aria-label, aria-valuenow, aria-valuemin, aria-valuemax, tabindex
|
|
175
178
|
// Adding one of those back to this list makes that component recurse.
|
|
176
179
|
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",
|
|
180
|
+
"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",
|
|
181
|
+
"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
182
|
"empty", "error", "exclusive", "format", "heading", "hint", "href", "icon", "illustration", "index", "instrument", "interval", "items", "key", "layers", "level",
|
|
180
183
|
"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
184
|
"options", "orientation", "page-size", "pages", "pause", "paused", "pausable", "persist", "placeholder", "playing", "point", "points", "prev", "progress", "prompt", "question", "recent", "required",
|
|
182
185
|
"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",
|
|
186
|
+
"state", "steps", "subtitle", "summary", "src", "table", "tabs", "tag", "text", "ticks", "title", "type", "unit",
|
|
184
187
|
"variant", "values", "viewport", "yes", "zoomable", "x", "y",
|
|
185
188
|
];
|
|
186
189
|
|
|
@@ -3789,13 +3792,18 @@ class ContourKpi extends ContourBase {
|
|
|
3789
3792
|
const h = this.querySelector(".c-kpi__head");
|
|
3790
3793
|
if (h) h.remove();
|
|
3791
3794
|
}
|
|
3792
|
-
|
|
3793
|
-
|
|
3794
|
-
|
|
3795
|
-
|
|
3796
|
-
|
|
3797
|
-
|
|
3798
|
-
|
|
3795
|
+
if (delta) {
|
|
3796
|
+
const f = this.ensure(".c-kpi__foot", () => { const el = document.createElement("div"); el.className = "c-kpi__foot"; return el; });
|
|
3797
|
+
const d = f.querySelector(".c-delta") || document.createElement("span");
|
|
3798
|
+
if (!d.parentNode) f.insertBefore(d, f.firstChild);
|
|
3799
|
+
const dir = this.getAttribute("direction") || "up";
|
|
3800
|
+
const polarity = this.getAttribute("polarity") || "neutral";
|
|
3801
|
+
let tone = "neutral";
|
|
3802
|
+
if (polarity === "good") tone = (dir === "up") ? "good" : "bad";
|
|
3803
|
+
else if (polarity === "bad") tone = (dir === "up") ? "bad" : "good";
|
|
3804
|
+
d.className = "c-delta c-delta--" + dir + " c-delta--" + tone;
|
|
3805
|
+
d.textContent = delta;
|
|
3806
|
+
} else {
|
|
3799
3807
|
const d = this.querySelector(".c-kpi__foot .c-delta");
|
|
3800
3808
|
if (d) d.remove();
|
|
3801
3809
|
}
|
|
@@ -5729,7 +5737,7 @@ class ContourMetricsFull extends ContourBase {
|
|
|
5729
5737
|
}
|
|
5730
5738
|
define("contour-metrics", ContourMetricsFull);
|
|
5731
5739
|
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"]; }
|
|
5740
|
+
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
5741
|
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
5742
|
render() {
|
|
5735
5743
|
this.classList.add("c-legend");
|
|
@@ -5769,14 +5777,15 @@ class ContourLegend extends ContourBase {
|
|
|
5769
5777
|
if (it && it.color) sw.style.background = it.color;
|
|
5770
5778
|
item.appendChild(sw);
|
|
5771
5779
|
// geometry glyph
|
|
5772
|
-
|
|
5773
|
-
|
|
5774
|
-
|
|
5775
|
-
|
|
5776
|
-
|
|
5777
|
-
|
|
5778
|
-
|
|
5779
|
-
|
|
5780
|
+
const glyphShape = (it && (it.shape || it.marker || it.glyph)) || this.getAttribute("glyphs");
|
|
5781
|
+
if (glyphShape) {
|
|
5782
|
+
const g = document.createElement("span");
|
|
5783
|
+
g.className = "c-legend__glyph";
|
|
5784
|
+
g.setAttribute("part", "glyph");
|
|
5785
|
+
g.textContent = glyphShape === "circle" ? "●" : glyphShape === "square" ? "■" : glyphShape === "triangle" ? "▲" : glyphShape === "diamond" ? "◆" : glyphShape === "star" ? "★" : String(glyphShape);
|
|
5786
|
+
if (it && it.size != null) g.style.fontSize = (typeof it.size === "number" ? it.size + "px" : String(it.size));
|
|
5787
|
+
item.appendChild(g);
|
|
5788
|
+
}
|
|
5780
5789
|
// threshold break marker
|
|
5781
5790
|
if (it && it.break != null) {
|
|
5782
5791
|
const b = document.createElement("span");
|
|
@@ -5784,9 +5793,21 @@ class ContourLegend extends ContourBase {
|
|
|
5784
5793
|
b.textContent = String(it.break);
|
|
5785
5794
|
item.appendChild(b);
|
|
5786
5795
|
}
|
|
5787
|
-
|
|
5788
|
-
|
|
5789
|
-
|
|
5796
|
+
const lbl = document.createElement("span");
|
|
5797
|
+
lbl.textContent = label;
|
|
5798
|
+
item.appendChild(lbl);
|
|
5799
|
+
// caption (source-and-method line)
|
|
5800
|
+
const caption = (typeof it === "object" && it) ? (it.caption || it.note || "") : "";
|
|
5801
|
+
if (caption) {
|
|
5802
|
+
const cap = document.createElement("span");
|
|
5803
|
+
cap.className = "c-legend__caption";
|
|
5804
|
+
cap.textContent = caption;
|
|
5805
|
+
item.appendChild(cap);
|
|
5806
|
+
}
|
|
5807
|
+
// threshold mark: outline on swatches that begin at a threshold
|
|
5808
|
+
if (it && (it.threshold || it.break != null)) {
|
|
5809
|
+
sw.style.outline = "2px solid var(--color-border-strong)";
|
|
5810
|
+
}
|
|
5790
5811
|
list.appendChild(item);
|
|
5791
5812
|
});
|
|
5792
5813
|
} catch (e) { /* keep existing */ }
|
|
@@ -5798,7 +5819,79 @@ class ContourLegend extends ContourBase {
|
|
|
5798
5819
|
renderEmpty(this, "legend");
|
|
5799
5820
|
}
|
|
5800
5821
|
}
|
|
5801
|
-
|
|
5822
|
+
// audit notice
|
|
5823
|
+
const audit = this.getAttribute("audit");
|
|
5824
|
+
if (audit) {
|
|
5825
|
+
const a = this.ensure(".c-legend__audit", () => { const el = document.createElement("div"); el.className = "c-legend__audit"; return el; });
|
|
5826
|
+
a.textContent = audit;
|
|
5827
|
+
} else {
|
|
5828
|
+
const a = this.querySelector(".c-legend__audit");
|
|
5829
|
+
if (a) a.remove();
|
|
5830
|
+
}
|
|
5831
|
+
// continuous variant: ramp with two ends labelled
|
|
5832
|
+
if (this.hasAttribute("continuous")) {
|
|
5833
|
+
const ends = this.getAttribute("ends");
|
|
5834
|
+
let parsedEnds = null;
|
|
5835
|
+
if (ends) { try { parsedEnds = JSON.parse(ends); } catch (e) { parsedEnds = ends.split(","); } }
|
|
5836
|
+
if (Array.isArray(parsedEnds) && parsedEnds.length >= 2) {
|
|
5837
|
+
const r = this.ensure(".c-legend__ramp", () => { const el = document.createElement("div"); el.className = "c-legend__ramp"; return el; });
|
|
5838
|
+
// labels
|
|
5839
|
+
let left = this.querySelector(".c-legend__ramp-label--start");
|
|
5840
|
+
if (!left) { left = document.createElement("span"); left.className = "c-legend__ramp-label c-legend__ramp-label--start"; r.appendChild(left); }
|
|
5841
|
+
left.textContent = parsedEnds[0];
|
|
5842
|
+
let right = this.querySelector(".c-legend__ramp-label--end");
|
|
5843
|
+
if (!right) { right = document.createElement("span"); right.className = "c-legend__ramp-label c-legend__ramp-label--end"; r.appendChild(right); }
|
|
5844
|
+
right.textContent = parsedEnds[parsedEnds.length - 1];
|
|
5845
|
+
}
|
|
5846
|
+
}
|
|
5847
|
+
// size variant: differently-sized glyphs
|
|
5848
|
+
const sizeAttr = this.getAttribute("size");
|
|
5849
|
+
if (sizeAttr) {
|
|
5850
|
+
const sc = this.ensure(".c-legend__size", () => { const el = document.createElement("div"); el.className = "c-legend__size"; return el; });
|
|
5851
|
+
sc.textContent = sizeAttr;
|
|
5852
|
+
} else {
|
|
5853
|
+
const sc = this.querySelector(".c-legend__size");
|
|
5854
|
+
if (sc) sc.remove();
|
|
5855
|
+
}
|
|
5856
|
+
// classification line
|
|
5857
|
+
const classification = this.getAttribute("classification");
|
|
5858
|
+
if (classification) {
|
|
5859
|
+
const c = this.ensure(".c-legend__classification", () => { const el = document.createElement("div"); el.className = "c-legend__classification"; return el; });
|
|
5860
|
+
c.textContent = classification;
|
|
5861
|
+
} else {
|
|
5862
|
+
const c = this.querySelector(".c-legend__classification");
|
|
5863
|
+
if (c) c.remove();
|
|
5864
|
+
}
|
|
5865
|
+
// data table (collapsible)
|
|
5866
|
+
const tableAttr = this.getAttribute("table");
|
|
5867
|
+
if (tableAttr) {
|
|
5868
|
+
let parsed = null;
|
|
5869
|
+
try { parsed = JSON.parse(tableAttr); } catch (e) { parsed = null; }
|
|
5870
|
+
if (Array.isArray(parsed)) {
|
|
5871
|
+
let det = this.querySelector(".c-legend__table-wrap");
|
|
5872
|
+
if (!det) { det = document.createElement("details"); det.className = "c-legend__table-wrap"; this.appendChild(det); }
|
|
5873
|
+
det.innerHTML = "";
|
|
5874
|
+
const sum = document.createElement("summary"); sum.textContent = "Data table"; det.appendChild(sum);
|
|
5875
|
+
const tbl = document.createElement("table"); tbl.className = "c-legend__table";
|
|
5876
|
+
const tbody = document.createElement("tbody");
|
|
5877
|
+
parsed.forEach((row) => {
|
|
5878
|
+
const tr = document.createElement("tr");
|
|
5879
|
+
const cells = Array.isArray(row) ? row : [row.label ?? row.key ?? "", row.value ?? ""];
|
|
5880
|
+
cells.forEach((cell) => { const td = document.createElement("td"); td.textContent = cell; tr.appendChild(td); });
|
|
5881
|
+
tbody.appendChild(tr);
|
|
5882
|
+
});
|
|
5883
|
+
tbl.appendChild(tbody);
|
|
5884
|
+
det.appendChild(tbl);
|
|
5885
|
+
}
|
|
5886
|
+
} else {
|
|
5887
|
+
const det = this.querySelector(".c-legend__table-wrap");
|
|
5888
|
+
if (det) det.remove();
|
|
5889
|
+
}
|
|
5890
|
+
// size variant on glyphs
|
|
5891
|
+
if (items) {
|
|
5892
|
+
// apply size to glyphs already rendered? handled below via re-render not needed
|
|
5893
|
+
}
|
|
5894
|
+
const method = this.getAttribute("method");
|
|
5802
5895
|
if (method) {
|
|
5803
5896
|
const m = this.ensure(".c-legend__method", () => { const el = document.createElement("div"); el.className = "c-legend__method"; return el; });
|
|
5804
5897
|
m.textContent = method;
|
|
@@ -5814,14 +5907,34 @@ class ContourLegend extends ContourBase {
|
|
|
5814
5907
|
const n = this.querySelector(".c-legend__norm");
|
|
5815
5908
|
if (n) n.remove();
|
|
5816
5909
|
}
|
|
5817
|
-
|
|
5818
|
-
|
|
5819
|
-
|
|
5820
|
-
|
|
5821
|
-
|
|
5822
|
-
|
|
5823
|
-
|
|
5824
|
-
|
|
5910
|
+
const ramp = this.getAttribute("ramp");
|
|
5911
|
+
if (ramp) {
|
|
5912
|
+
const r = this.ensure(".c-legend__ramp", () => { const el = document.createElement("div"); el.className = "c-legend__ramp"; return el; });
|
|
5913
|
+
r.style.background = ramp;
|
|
5914
|
+
// ramp routing: equal-width segments with break labels
|
|
5915
|
+
const breaksAttr = this.getAttribute("breaks");
|
|
5916
|
+
if (breaksAttr) {
|
|
5917
|
+
let breaks = null;
|
|
5918
|
+
try { breaks = JSON.parse(breaksAttr); } catch (e) { breaks = breaksAttr.split(",").map((s) => s.trim()); }
|
|
5919
|
+
if (Array.isArray(breaks)) {
|
|
5920
|
+
// remove old segments
|
|
5921
|
+
Array.from(r.querySelectorAll(".c-legend__ramp-segment")).forEach((n) => n.remove());
|
|
5922
|
+
breaks.forEach((b, i) => {
|
|
5923
|
+
const seg = document.createElement("span");
|
|
5924
|
+
seg.className = "c-legend__ramp-segment";
|
|
5925
|
+
seg.style.flex = "1";
|
|
5926
|
+
const lbl = document.createElement("span");
|
|
5927
|
+
lbl.className = "c-legend__ramp-break";
|
|
5928
|
+
lbl.textContent = String(b);
|
|
5929
|
+
seg.appendChild(lbl);
|
|
5930
|
+
r.appendChild(seg);
|
|
5931
|
+
});
|
|
5932
|
+
}
|
|
5933
|
+
}
|
|
5934
|
+
} else {
|
|
5935
|
+
const r = this.querySelector(".c-legend__ramp");
|
|
5936
|
+
if (r) r.remove();
|
|
5937
|
+
}
|
|
5825
5938
|
const scale = this.getAttribute("scale");
|
|
5826
5939
|
if (scale) {
|
|
5827
5940
|
const sc = this.ensure(".c-legend__scale", () => { const el = document.createElement("div"); el.className = "c-legend__scale"; return el; });
|
|
@@ -7550,72 +7663,130 @@ class ContourField extends ContourBase {
|
|
|
7550
7663
|
};
|
|
7551
7664
|
define("contour-field", ContourField);
|
|
7552
7665
|
class ContourRange extends ContourBase {
|
|
7553
|
-
static get observed() { return ["min", "max", "value", "label"]; }
|
|
7666
|
+
static get observed() { return ["min", "max", "value", "low", "high", "range", "sparkline", "label"]; }
|
|
7554
7667
|
static get formAssociated() { return true; }
|
|
7555
7668
|
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
|
-
|
|
7669
|
+
render() {
|
|
7670
|
+
this.classList.add("c-range");
|
|
7671
|
+
const min = this.getAttribute("min") || "0";
|
|
7672
|
+
const max = this.getAttribute("max") || "100";
|
|
7673
|
+
const rangeMode = this.hasAttribute("range") || this.hasAttribute("low") || this.hasAttribute("high");
|
|
7674
|
+
// sparkline canvas
|
|
7675
|
+
const spark = this.getAttribute("sparkline");
|
|
7676
|
+
if (spark) {
|
|
7677
|
+
let canvas = this.querySelector(".c-range__sparkline");
|
|
7678
|
+
if (!canvas) { canvas = document.createElement("canvas"); canvas.className = "c-range__sparkline"; canvas.setAttribute("part", "sparkline-canvas"); this.insertBefore(canvas, this.firstChild); }
|
|
7679
|
+
} else {
|
|
7680
|
+
const c = this.querySelector(".c-range__sparkline");
|
|
7681
|
+
if (c) c.remove();
|
|
7682
|
+
}
|
|
7683
|
+
if (rangeMode) {
|
|
7684
|
+
// remove single input if present
|
|
7685
|
+
const single = this.querySelector("input.c-range:not(.c-range__low):not(.c-range__high)");
|
|
7686
|
+
// keep generic input? We'll use two named inputs
|
|
7687
|
+
let lowInput = this.querySelector("input.c-range__low");
|
|
7688
|
+
if (!lowInput) { lowInput = document.createElement("input"); lowInput.type = "range"; lowInput.className = "c-range c-range__low"; this.appendChild(lowInput); }
|
|
7689
|
+
let highInput = this.querySelector("input.c-range__high");
|
|
7690
|
+
if (!highInput) { highInput = document.createElement("input"); highInput.type = "range"; highInput.className = "c-range c-range__high"; this.appendChild(highInput); }
|
|
7691
|
+
lowInput.min = min; lowInput.max = max;
|
|
7692
|
+
highInput.min = min; highInput.max = max;
|
|
7693
|
+
const lowVal = this.getAttribute("low") || min;
|
|
7694
|
+
const highVal = this.getAttribute("high") || max;
|
|
7695
|
+
if (this._rangeUserLow !== null && this._rangeAttrLowAtDirty === (this.getAttribute("low") || min)) lowInput.value = this._rangeUserLow;
|
|
7696
|
+
else { lowInput.value = lowVal; this._rangeUserLow = null; this._rangeAttrLowAtDirty = null; }
|
|
7697
|
+
if (this._rangeUserHigh !== null && this._rangeAttrHighAtDirty === (this.getAttribute("high") || max)) highInput.value = this._rangeUserHigh;
|
|
7698
|
+
else { highInput.value = highVal; this._rangeUserHigh = null; this._rangeAttrHighAtDirty = null; }
|
|
7699
|
+
const label = this.getAttribute("label");
|
|
7700
|
+
if (label) { lowInput.setAttribute("aria-label", label + " low"); highInput.setAttribute("aria-label", label + " high"); }
|
|
7701
|
+
} else {
|
|
7702
|
+
// remove dual inputs
|
|
7703
|
+
Array.from(this.querySelectorAll("input.c-range__low, input.c-range__high")).forEach((n) => n.remove());
|
|
7704
|
+
const input = this.ensure("input.c-range", () => { const el = document.createElement("input"); el.type = "range"; return el; });
|
|
7705
|
+
// ensure class
|
|
7706
|
+
input.className = "c-range";
|
|
7707
|
+
input.type = "range";
|
|
7708
|
+
input.min = min;
|
|
7709
|
+
input.max = max;
|
|
7710
|
+
const attrVal = this.getAttribute("value") || "50";
|
|
7711
|
+
if (this._rangeUserValue !== null && this._rangeAttrAtDirty === (this.getAttribute("value") || "50")) {
|
|
7712
|
+
input.value = this._rangeUserValue;
|
|
7713
|
+
} else {
|
|
7714
|
+
input.value = attrVal;
|
|
7715
|
+
this._rangeUserValue = null;
|
|
7716
|
+
this._rangeAttrAtDirty = null;
|
|
7717
|
+
}
|
|
7718
|
+
const label = this.getAttribute("label");
|
|
7719
|
+
if (label) input.setAttribute("aria-label", label);
|
|
7720
|
+
else if (!input.hasAttribute("aria-label")) input.setAttribute("aria-label", "Range");
|
|
7721
|
+
const updateFill = () => {
|
|
7722
|
+
const mn = Number(input.min) || 0;
|
|
7723
|
+
const mx = Number(input.max) || 100;
|
|
7724
|
+
const val = Number(input.value) || 0;
|
|
7725
|
+
const pct = mx > mn ? ((val - mn) / (mx - mn)) * 100 : 0;
|
|
7726
|
+
input.style.setProperty("--fill", pct + "%");
|
|
7727
|
+
};
|
|
7728
|
+
updateFill();
|
|
7729
|
+
if (!input._fillWired) {
|
|
7730
|
+
input._fillWired = true;
|
|
7731
|
+
input.addEventListener("input", updateFill);
|
|
7732
|
+
}
|
|
7733
|
+
}
|
|
7734
|
+
}
|
|
7588
7735
|
}
|
|
7589
7736
|
// patch enhance onto ContourRange
|
|
7590
7737
|
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
|
-
|
|
7738
|
+
ContourRange.prototype.attributeChangedCallback = function(name, oldValue, newValue) {
|
|
7739
|
+
if (name === "value") { this._rangeUserValue = null; this._rangeAttrAtDirty = null; }
|
|
7740
|
+
if (name === "low") { this._rangeUserLow = null; this._rangeAttrLowAtDirty = null; }
|
|
7741
|
+
if (name === "high") { this._rangeUserHigh = null; this._rangeAttrHighAtDirty = null; }
|
|
7742
|
+
return ContourBase.prototype.attributeChangedCallback.call(this, name, oldValue, newValue);
|
|
7743
|
+
};
|
|
7744
|
+
ContourRange.prototype.enhance = function() {
|
|
7745
|
+
if (this._wiredRange) return;
|
|
7746
|
+
this._wiredRange = true;
|
|
7747
|
+
const sync = () => {
|
|
7748
|
+
const low = this.querySelector("input.c-range__low");
|
|
7749
|
+
const high = this.querySelector("input.c-range__high");
|
|
7750
|
+
const single = this.querySelector("input.c-range:not(.c-range__low):not(.c-range__high)");
|
|
7751
|
+
if (this._internals) {
|
|
7752
|
+
if (low && high) this._internals.setFormValue(low.value + "," + high.value);
|
|
7753
|
+
else if (single) this._internals.setFormValue(single.value);
|
|
7754
|
+
}
|
|
7755
|
+
};
|
|
7756
|
+
this.addEventListener("input", (e) => {
|
|
7757
|
+
const low = this.querySelector("input.c-range__low");
|
|
7758
|
+
const high = this.querySelector("input.c-range__high");
|
|
7759
|
+
const single = this.querySelector("input.c-range:not(.c-range__low):not(.c-range__high)");
|
|
7760
|
+
if (low && high && (e.target === low || e.target === high)) {
|
|
7761
|
+
this._rangeUserLow = low.value;
|
|
7762
|
+
this._rangeUserHigh = high.value;
|
|
7763
|
+
this._rangeAttrLowAtDirty = this.getAttribute("low") || (this.getAttribute("min") || "0");
|
|
7764
|
+
this._rangeAttrHighAtDirty = this.getAttribute("high") || (this.getAttribute("max") || "100");
|
|
7765
|
+
sync();
|
|
7766
|
+
this._emitForm("contour:input", { low: Number(low.value), high: Number(high.value) });
|
|
7767
|
+
this.dispatchEvent(new CustomEvent("contour:change", { bubbles: true, composed: true, detail: { low: Number(low.value), high: Number(high.value) } }));
|
|
7768
|
+
} else if (single && e.target === single) {
|
|
7769
|
+
this._rangeUserValue = single.value;
|
|
7770
|
+
this._rangeAttrAtDirty = this.getAttribute("value") || "50";
|
|
7771
|
+
sync();
|
|
7772
|
+
this._emitForm("contour:input");
|
|
7773
|
+
}
|
|
7774
|
+
});
|
|
7775
|
+
this.addEventListener("change", (e) => {
|
|
7776
|
+
const low = this.querySelector("input.c-range__low");
|
|
7777
|
+
const high = this.querySelector("input.c-range__high");
|
|
7778
|
+
const single = this.querySelector("input.c-range:not(.c-range__low):not(.c-range__high)");
|
|
7779
|
+
if (low && high && (e.target === low || e.target === high)) {
|
|
7780
|
+
sync();
|
|
7781
|
+
this._emitForm("contour:change", { low: Number(low.value), high: Number(high.value) });
|
|
7782
|
+
this.dispatchEvent(new CustomEvent("contour:change", { bubbles: true, composed: true, detail: { low: Number(low.value), high: Number(high.value) } }));
|
|
7783
|
+
} else if (single && e.target === single) {
|
|
7784
|
+
sync();
|
|
7785
|
+
this._emitForm("contour:change");
|
|
7786
|
+
}
|
|
7787
|
+
});
|
|
7788
|
+
sync();
|
|
7789
|
+
};
|
|
7619
7790
|
define("contour-range", ContourRange);
|
|
7620
7791
|
class ContourSwitch extends ContourBase {
|
|
7621
7792
|
static get observed() { return ["label", "required", "checked"]; }
|
|
@@ -8919,7 +9090,7 @@ class ContourCoordinate extends ContourBase {
|
|
|
8919
9090
|
}
|
|
8920
9091
|
define("contour-coordinate", ContourCoordinate);
|
|
8921
9092
|
class ContourLayerPanel extends ContourBase {
|
|
8922
|
-
static get observed() { return ["label", "items", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton"]; }
|
|
9093
|
+
static get observed() { return ["label", "items", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton", "allow-rename", "allow-remove", "allow-duplicate", "allow-zoom"]; }
|
|
8923
9094
|
static get properties() { return { label: { attribute: "label" }, items: { attribute: "items" }, src: { attribute: "src" } }; }
|
|
8924
9095
|
render() {
|
|
8925
9096
|
this.classList.add("c-layer-panel");
|
|
@@ -8940,19 +9111,24 @@ class ContourLayerPanel extends ContourBase {
|
|
|
8940
9111
|
const authoredLayerItems = Array.from(this.querySelectorAll(":scope > .c-layer-panel__item"));
|
|
8941
9112
|
// Preserve user-toggled visibility across re-renders (B3-09): a src
|
|
8942
9113
|
// reload must not re-check a layer the user un-checked.
|
|
8943
|
-
|
|
8944
|
-
|
|
8945
|
-
|
|
8946
|
-
|
|
8947
|
-
|
|
8948
|
-
|
|
9114
|
+
const savedVisibility = new Map();
|
|
9115
|
+
this.querySelectorAll(".c-layer-panel__item").forEach((el) => {
|
|
9116
|
+
const nm = el.querySelector(".c-layer-panel__name");
|
|
9117
|
+
const tg = el.querySelector(".c-layer-panel__toggle");
|
|
9118
|
+
if (nm && tg) {
|
|
9119
|
+
const v = tg.hasAttribute("aria-pressed") ? tg.getAttribute("aria-pressed") === "true" : !!tg.checked;
|
|
9120
|
+
savedVisibility.set(nm.textContent, v);
|
|
9121
|
+
}
|
|
9122
|
+
});
|
|
8949
9123
|
let parsed = null;
|
|
8950
9124
|
if (authoredLayerItems.length) {
|
|
8951
|
-
|
|
8952
|
-
|
|
8953
|
-
|
|
8954
|
-
|
|
8955
|
-
|
|
9125
|
+
parsed = authoredLayerItems.map((el) => {
|
|
9126
|
+
const nm = el.querySelector(".c-layer-panel__name");
|
|
9127
|
+
const tg = el.querySelector(".c-layer-panel__toggle");
|
|
9128
|
+
const visible = tg ? (tg.hasAttribute("aria-pressed") ? tg.getAttribute("aria-pressed") === "true" : !!tg.checked) : true;
|
|
9129
|
+
const cap = el.querySelector(".c-layer-panel__caption");
|
|
9130
|
+
return { name: nm ? nm.textContent : "", visible, caption: cap ? cap.textContent : (el.dataset.caption || undefined) };
|
|
9131
|
+
});
|
|
8956
9132
|
authoredLayerItems.forEach((el) => el.remove());
|
|
8957
9133
|
} else if (items) {
|
|
8958
9134
|
try {
|
|
@@ -8961,21 +9137,31 @@ class ContourLayerPanel extends ContourBase {
|
|
|
8961
9137
|
} catch (e) { /* keep existing */ }
|
|
8962
9138
|
}
|
|
8963
9139
|
if (parsed) { parsed.forEach((it) => {
|
|
8964
|
-
|
|
8965
|
-
|
|
8966
|
-
|
|
8967
|
-
|
|
8968
|
-
|
|
8969
|
-
|
|
8970
|
-
|
|
8971
|
-
|
|
8972
|
-
|
|
9140
|
+
const name = typeof it === "string" ? it : (it.name || it.label || "");
|
|
9141
|
+
const caption = (typeof it === "object" && it) ? (it.caption || it.subtitle || "") : "";
|
|
9142
|
+
const item = document.createElement("div");
|
|
9143
|
+
item.className = "c-layer-panel__item" + (it.dragging ? " c-layer-panel__item--dragging" : "");
|
|
9144
|
+
const toggle = document.createElement("button");
|
|
9145
|
+
toggle.type = "button";
|
|
9146
|
+
toggle.className = "c-layer-panel__toggle";
|
|
9147
|
+
toggle.setAttribute("part", "visibility-toggle");
|
|
9148
|
+
toggle.setAttribute("aria-label", "Toggle " + (name || "layer"));
|
|
9149
|
+
const isVisible = savedVisibility.has(name) ? savedVisibility.get(name) : (typeof it === "object" && it.visible !== false);
|
|
9150
|
+
toggle.setAttribute("aria-pressed", String(!!isVisible));
|
|
9151
|
+
toggle.checked = !!isVisible;
|
|
9152
|
+
toggle.textContent = isVisible ? "●" : "○";
|
|
8973
9153
|
item.appendChild(toggle);
|
|
8974
9154
|
const nm = document.createElement("span");
|
|
8975
9155
|
nm.className = "c-layer-panel__name";
|
|
8976
9156
|
nm.textContent = name;
|
|
8977
9157
|
item.appendChild(nm);
|
|
8978
|
-
|
|
9158
|
+
if (caption) {
|
|
9159
|
+
const cap = document.createElement("span");
|
|
9160
|
+
cap.className = "c-layer-panel__caption";
|
|
9161
|
+
cap.textContent = caption;
|
|
9162
|
+
item.appendChild(cap);
|
|
9163
|
+
}
|
|
9164
|
+
const opacity = document.createElement("input");
|
|
8979
9165
|
opacity.type = "range";
|
|
8980
9166
|
opacity.className = "c-layer-panel__opacity";
|
|
8981
9167
|
opacity.min = "0";
|
|
@@ -8984,24 +9170,38 @@ class ContourLayerPanel extends ContourBase {
|
|
|
8984
9170
|
opacity.value = (typeof it === "object" && it.opacity != null) ? it.opacity : "100";
|
|
8985
9171
|
item.appendChild(opacity);
|
|
8986
9172
|
// rename input (hidden by default, toggled via button)
|
|
9173
|
+
if (this.getAttribute("allow-rename") !== "false") {
|
|
8987
9174
|
const renameBtn = document.createElement("button");
|
|
8988
9175
|
renameBtn.type = "button";
|
|
8989
9176
|
renameBtn.className = "c-layer-panel__rename";
|
|
8990
9177
|
renameBtn.textContent = "Rename";
|
|
8991
9178
|
renameBtn.setAttribute("aria-label", "Rename " + (name || "layer"));
|
|
8992
9179
|
item.appendChild(renameBtn);
|
|
9180
|
+
}
|
|
9181
|
+
if (this.getAttribute("allow-duplicate") !== "false") {
|
|
8993
9182
|
const dupBtn = document.createElement("button");
|
|
8994
9183
|
dupBtn.type = "button";
|
|
8995
9184
|
dupBtn.className = "c-layer-panel__duplicate";
|
|
8996
9185
|
dupBtn.textContent = "Duplicate";
|
|
8997
9186
|
dupBtn.setAttribute("aria-label", "Duplicate " + (name || "layer"));
|
|
8998
9187
|
item.appendChild(dupBtn);
|
|
9188
|
+
}
|
|
9189
|
+
if (this.getAttribute("allow-zoom") !== "false") {
|
|
8999
9190
|
const zoomBtn = document.createElement("button");
|
|
9000
9191
|
zoomBtn.type = "button";
|
|
9001
9192
|
zoomBtn.className = "c-layer-panel__zoom";
|
|
9002
9193
|
zoomBtn.textContent = "Zoom";
|
|
9003
9194
|
zoomBtn.setAttribute("aria-label", "Zoom to " + (name || "layer"));
|
|
9004
9195
|
item.appendChild(zoomBtn);
|
|
9196
|
+
}
|
|
9197
|
+
if (this.getAttribute("allow-remove") !== "false") {
|
|
9198
|
+
const removeBtn = document.createElement("button");
|
|
9199
|
+
removeBtn.type = "button";
|
|
9200
|
+
removeBtn.className = "c-layer-panel__remove";
|
|
9201
|
+
removeBtn.textContent = "✕";
|
|
9202
|
+
removeBtn.setAttribute("aria-label", "Remove " + (name || "layer"));
|
|
9203
|
+
item.appendChild(removeBtn);
|
|
9204
|
+
}
|
|
9005
9205
|
const projSel = document.createElement("select");
|
|
9006
9206
|
projSel.className = "c-layer-panel__projection";
|
|
9007
9207
|
projSel.setAttribute("aria-label", "Projection of " + (name || "layer"));
|
|
@@ -9020,39 +9220,79 @@ class ContourLayerPanel extends ContourBase {
|
|
|
9020
9220
|
this._wiredLayerPanel = true;
|
|
9021
9221
|
// The panel's two controls (visibility toggle, opacity range) are rebuilt
|
|
9022
9222
|
// 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
|
-
|
|
9223
|
+
this.addEventListener("change", (e) => {
|
|
9224
|
+
const item = e.target && e.target.closest ? e.target.closest(".c-layer-panel__item") : null;
|
|
9225
|
+
if (!item || !this.contains(item)) return;
|
|
9226
|
+
const name = item.querySelector(".c-layer-panel__name")?.textContent || "";
|
|
9227
|
+
if (e.target.classList.contains("c-layer-panel__toggle")) {
|
|
9228
|
+
const now = (typeof e.target.checked === "boolean") ? e.target.checked : (e.target.getAttribute("aria-pressed") !== "true");
|
|
9229
|
+
e.target.checked = now;
|
|
9230
|
+
e.target.setAttribute("aria-pressed", String(now));
|
|
9231
|
+
e.target.textContent = now ? "●" : "○";
|
|
9232
|
+
this.dispatchEvent(new CustomEvent("contour:layer-visibility", { bubbles: true, composed: true, detail: { name, visible: now } }));
|
|
9233
|
+
} else if (e.target.classList.contains("c-layer-panel__opacity")) {
|
|
9234
|
+
this.dispatchEvent(new CustomEvent("contour:layer-opacity", { bubbles: true, composed: true, detail: { name, opacity: Number(e.target.value) } }));
|
|
9235
|
+
} else if (e.target.classList.contains("c-layer-panel__projection")) {
|
|
9236
|
+
this.dispatchEvent(new CustomEvent("contour:layer-projection", { bubbles: true, composed: true, detail: { name, projection: e.target.value } }));
|
|
9237
|
+
}
|
|
9238
|
+
});
|
|
9239
|
+
this.addEventListener("click", (e) => {
|
|
9240
|
+
const btn = e.target && e.target.closest ? e.target.closest("button") : null;
|
|
9241
|
+
if (!btn || !this.contains(btn)) return;
|
|
9242
|
+
const item = btn.closest(".c-layer-panel__item");
|
|
9243
|
+
if (btn.classList.contains("c-layer-panel__toggle")) {
|
|
9244
|
+
if (!item) return;
|
|
9245
|
+
const name = item.querySelector(".c-layer-panel__name")?.textContent || "";
|
|
9246
|
+
const now = btn.getAttribute("aria-pressed") !== "true";
|
|
9247
|
+
btn.setAttribute("aria-pressed", String(now));
|
|
9248
|
+
btn.checked = now;
|
|
9249
|
+
btn.textContent = now ? "●" : "○";
|
|
9250
|
+
this.dispatchEvent(new CustomEvent("contour:layer-visibility", { bubbles: true, composed: true, detail: { name, visible: now } }));
|
|
9251
|
+
return;
|
|
9252
|
+
}
|
|
9253
|
+
if (!item) return;
|
|
9254
|
+
const name = item.querySelector(".c-layer-panel__name")?.textContent || "";
|
|
9255
|
+
if (btn.classList.contains("c-layer-panel__rename")) {
|
|
9256
|
+
const newName = prompt("Rename layer", name);
|
|
9257
|
+
const trimmed = newName ? newName.trim() : "";
|
|
9258
|
+
if (trimmed && trimmed !== name) {
|
|
9259
|
+
const nm = item.querySelector(".c-layer-panel__name");
|
|
9260
|
+
if (nm) nm.textContent = trimmed;
|
|
9261
|
+
this.dispatchEvent(new CustomEvent("contour:layer-rename", { bubbles: true, composed: true, detail: { name, newName: trimmed } }));
|
|
9262
|
+
}
|
|
9263
|
+
} else if (btn.classList.contains("c-layer-panel__duplicate")) {
|
|
9264
|
+
this.dispatchEvent(new CustomEvent("contour:layer-duplicate", { bubbles: true, composed: true, detail: { name } }));
|
|
9265
|
+
} else if (btn.classList.contains("c-layer-panel__zoom")) {
|
|
9266
|
+
this.dispatchEvent(new CustomEvent("contour:layer-zoom", { bubbles: true, composed: true, detail: { name } }));
|
|
9267
|
+
} else if (btn.classList.contains("c-layer-panel__remove")) {
|
|
9268
|
+
this.dispatchEvent(new CustomEvent("contour:layer-remove", { bubbles: true, composed: true, detail: { name } }));
|
|
9269
|
+
}
|
|
9270
|
+
});
|
|
9271
|
+
this.addEventListener("keydown", (e) => {
|
|
9272
|
+
if (e.target && e.target.classList && e.target.classList.contains("c-layer-panel__toggle") && (e.key === "Enter" || e.key === " ")) {
|
|
9273
|
+
e.preventDefault();
|
|
9274
|
+
e.target.click();
|
|
9275
|
+
return;
|
|
9048
9276
|
}
|
|
9049
|
-
|
|
9050
|
-
|
|
9051
|
-
|
|
9052
|
-
|
|
9053
|
-
|
|
9054
|
-
|
|
9055
|
-
|
|
9277
|
+
const item = e.target && e.target.closest ? e.target.closest(".c-layer-panel__item") : null;
|
|
9278
|
+
if (!item || !this.contains(item)) return;
|
|
9279
|
+
if (!(e.altKey) || (e.key !== "ArrowUp" && e.key !== "ArrowDown")) return;
|
|
9280
|
+
e.preventDefault();
|
|
9281
|
+
const items = Array.from(this.querySelectorAll(".c-layer-panel__item"));
|
|
9282
|
+
const idx = items.indexOf(item);
|
|
9283
|
+
if (idx < 0) return;
|
|
9284
|
+
const dir = e.key === "ArrowUp" ? -1 : 1;
|
|
9285
|
+
const newIdx = idx + dir;
|
|
9286
|
+
if (newIdx < 0 || newIdx >= items.length) return;
|
|
9287
|
+
item.classList.add("c-layer-panel__item--dragging");
|
|
9288
|
+
if (dir < 0) this.insertBefore(item, items[newIdx]);
|
|
9289
|
+
else this.insertBefore(items[newIdx], item);
|
|
9290
|
+
item.focus();
|
|
9291
|
+
setTimeout(() => item.classList.remove("c-layer-panel__item--dragging"), 200);
|
|
9292
|
+
const layerIds = Array.from(this.querySelectorAll(".c-layer-panel__item")).map((el) => el.querySelector(".c-layer-panel__name")?.textContent || "");
|
|
9293
|
+
this.dispatchEvent(new CustomEvent("contour:layer-reorder", { bubbles: true, composed: true, detail: { layerIds } }));
|
|
9294
|
+
});
|
|
9295
|
+
}
|
|
9056
9296
|
}
|
|
9057
9297
|
define("contour-layer-panel", ContourLayerPanel);
|
|
9058
9298
|
class ContourTimeSlider extends ContourBase {
|
|
@@ -10667,7 +10907,7 @@ class ContourTocFull extends ContourBase {
|
|
|
10667
10907
|
}
|
|
10668
10908
|
define("contour-toc", ContourTocFull);
|
|
10669
10909
|
class ContourFilterBar extends ContourBase {
|
|
10670
|
-
static get observed() { return ["label", "divider", "items", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton"]; }
|
|
10910
|
+
static get observed() { return ["label", "divider", "items", "input", "placeholder", "mode", "modes", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton"]; }
|
|
10671
10911
|
static get properties() { return { label: { attribute: "label" }, divider: { attribute: "divider" }, items: { attribute: "items" }, src: { attribute: "src" } }; }
|
|
10672
10912
|
render() {
|
|
10673
10913
|
this.classList.add("c-filter-bar");
|
|
@@ -10682,13 +10922,48 @@ class ContourFilterBar extends ContourBase {
|
|
|
10682
10922
|
const l = this.querySelector(".c-filter-bar__label");
|
|
10683
10923
|
if (l) l.remove();
|
|
10684
10924
|
}
|
|
10685
|
-
|
|
10686
|
-
|
|
10687
|
-
|
|
10688
|
-
|
|
10689
|
-
|
|
10690
|
-
|
|
10691
|
-
|
|
10925
|
+
if (this.hasAttribute("divider")) {
|
|
10926
|
+
this.ensure(".c-filter-bar__divider", () => { const el = document.createElement("span"); el.className = "c-filter-bar__divider"; return el; });
|
|
10927
|
+
} else {
|
|
10928
|
+
const d = this.querySelector(".c-filter-bar__divider");
|
|
10929
|
+
if (d) d.remove();
|
|
10930
|
+
}
|
|
10931
|
+
// Text input support
|
|
10932
|
+
if (this.hasAttribute("input") || this.hasAttribute("placeholder")) {
|
|
10933
|
+
let inp = this.querySelector(".c-filter-bar__input");
|
|
10934
|
+
if (!inp) { inp = document.createElement("input"); inp.type = "search"; inp.className = "c-filter-bar__input"; this.appendChild(inp); }
|
|
10935
|
+
const ph = this.getAttribute("placeholder");
|
|
10936
|
+
if (ph) inp.setAttribute("placeholder", ph);
|
|
10937
|
+
} else {
|
|
10938
|
+
const inp = this.querySelector(".c-filter-bar__input");
|
|
10939
|
+
if (inp) inp.remove();
|
|
10940
|
+
}
|
|
10941
|
+
// Mode toolbar
|
|
10942
|
+
const modesAttr = this.getAttribute("modes");
|
|
10943
|
+
let modes = null;
|
|
10944
|
+
if (modesAttr) { try { modes = JSON.parse(modesAttr); } catch (e) { modes = modesAttr.split(",").map((s) => s.trim()); } }
|
|
10945
|
+
if (modes || this.hasAttribute("mode")) {
|
|
10946
|
+
let bar = this.querySelector(".c-filter-bar__modes");
|
|
10947
|
+
if (!bar) { bar = document.createElement("div"); bar.className = "c-filter-bar__modes"; this.appendChild(bar); }
|
|
10948
|
+
bar.innerHTML = "";
|
|
10949
|
+
const current = this.getAttribute("mode");
|
|
10950
|
+
const list = Array.isArray(modes) ? modes : ["draw", "erase", "select"];
|
|
10951
|
+
list.forEach((m) => {
|
|
10952
|
+
const name = typeof m === "string" ? m : (m.label || m.value || m);
|
|
10953
|
+
const val = typeof m === "string" ? m : (m.value || m.label || m);
|
|
10954
|
+
const btn = document.createElement("button");
|
|
10955
|
+
btn.type = "button";
|
|
10956
|
+
btn.className = "c-filter-bar__mode";
|
|
10957
|
+
btn.textContent = name;
|
|
10958
|
+
btn.dataset.mode = val;
|
|
10959
|
+
if (current && current === val) btn.setAttribute("aria-pressed", "true");
|
|
10960
|
+
bar.appendChild(btn);
|
|
10961
|
+
});
|
|
10962
|
+
} else {
|
|
10963
|
+
const bar = this.querySelector(".c-filter-bar__modes");
|
|
10964
|
+
if (bar) bar.remove();
|
|
10965
|
+
}
|
|
10966
|
+
// Render filter pills from items.
|
|
10692
10967
|
Array.from(this.querySelectorAll(".c-filter-pill")).forEach((n) => n.remove());
|
|
10693
10968
|
const items = remoteData(this, "items");
|
|
10694
10969
|
let parsed = null;
|
|
@@ -10712,9 +10987,29 @@ class ContourFilterBar extends ContourBase {
|
|
|
10712
10987
|
}
|
|
10713
10988
|
if (!parsed && !label) renderEmpty(this, "filter-bar");
|
|
10714
10989
|
}
|
|
10715
|
-
|
|
10716
|
-
|
|
10717
|
-
|
|
10990
|
+
enhance() {
|
|
10991
|
+
wireRemovable(this);
|
|
10992
|
+
if (this._wiredFilterBar) return;
|
|
10993
|
+
this._wiredFilterBar = true;
|
|
10994
|
+
this.addEventListener("click", (e) => {
|
|
10995
|
+
const btn = e.target && e.target.closest ? e.target.closest(".c-filter-bar__mode") : null;
|
|
10996
|
+
if (!btn || !this.contains(btn)) return;
|
|
10997
|
+
const mode = btn.dataset.mode || btn.textContent.trim();
|
|
10998
|
+
Array.from(this.querySelectorAll(".c-filter-bar__mode")).forEach((b) => b.setAttribute("aria-pressed", String(b === btn)));
|
|
10999
|
+
this.dispatchEvent(new CustomEvent("contour:mode-change", { bubbles: true, composed: true, detail: { mode } }));
|
|
11000
|
+
});
|
|
11001
|
+
// text input
|
|
11002
|
+
const inp = this.querySelector(".c-filter-bar__input");
|
|
11003
|
+
if (inp && !inp._wiredFilterInput) {
|
|
11004
|
+
inp._wiredFilterInput = true;
|
|
11005
|
+
inp.addEventListener("input", () => {
|
|
11006
|
+
this.dispatchEvent(new CustomEvent("contour:input", { bubbles: true, composed: true, detail: { value: inp.value } }));
|
|
11007
|
+
});
|
|
11008
|
+
inp.addEventListener("change", () => {
|
|
11009
|
+
this.dispatchEvent(new CustomEvent("contour:change", { bubbles: true, composed: true, detail: { value: inp.value } }));
|
|
11010
|
+
});
|
|
11011
|
+
}
|
|
11012
|
+
}
|
|
10718
11013
|
}
|
|
10719
11014
|
define("contour-filter-bar", ContourFilterBar);
|
|
10720
11015
|
class ContourCommand extends ContourBase {
|
|
@@ -11883,7 +12178,7 @@ class ContourStyleSwitcher extends ContourBase {
|
|
|
11883
12178
|
define("contour-style-switcher", ContourStyleSwitcher);
|
|
11884
12179
|
|
|
11885
12180
|
class ContourStylePanel extends ContourBase {
|
|
11886
|
-
static get observed() { return ["title", "layers", "classification", "palette", "breaks", "opacity"]; }
|
|
12181
|
+
static get observed() { return ["title", "layers", "layer", "single", "classification", "palette", "breaks", "opacity", "n", "colors"]; }
|
|
11887
12182
|
static get properties() { return { title: { attribute: "title" }, layers: { attribute: "layers" }, classification: { attribute: "classification" }, palette: { attribute: "palette" }, breaks: { attribute: "breaks" }, opacity: { attribute: "opacity" } }; }
|
|
11888
12183
|
render() {
|
|
11889
12184
|
this.classList.add("c-style-panel");
|
|
@@ -11892,7 +12187,46 @@ class ContourStylePanel extends ContourBase {
|
|
|
11892
12187
|
const t = this.ensure(".c-style-panel__title", () => { const el = document.createElement("div"); el.className = "c-style-panel__title"; return el; });
|
|
11893
12188
|
t.textContent = title;
|
|
11894
12189
|
}
|
|
11895
|
-
|
|
12190
|
+
const singleMode = this.hasAttribute("single") || !!this.getAttribute("layer");
|
|
12191
|
+
if (singleMode) {
|
|
12192
|
+
const body = this.ensure(".c-style-panel__body", () => { const el = document.createElement("div"); el.className = "c-style-panel__body"; return el; });
|
|
12193
|
+
body.innerHTML = "";
|
|
12194
|
+
// classification method selector
|
|
12195
|
+
const clsLabel = document.createElement("label"); clsLabel.textContent = "Classification"; body.appendChild(clsLabel);
|
|
12196
|
+
const clsSel = document.createElement("select"); clsSel.className = "c-style-panel__classification";
|
|
12197
|
+
["equal","quantile","jenks","manual"].forEach((m) => { const o = document.createElement("option"); o.value = m; o.textContent = m; clsSel.appendChild(o); });
|
|
12198
|
+
const cls = this.getAttribute("classification"); if (cls) clsSel.value = cls;
|
|
12199
|
+
body.appendChild(clsSel);
|
|
12200
|
+
// palette picker
|
|
12201
|
+
const pal = document.createElement("input"); pal.type = "text"; pal.className = "c-style-panel__palette"; pal.placeholder = "palette";
|
|
12202
|
+
const palv = this.getAttribute("palette"); if (palv) pal.value = palv;
|
|
12203
|
+
body.appendChild(pal);
|
|
12204
|
+
// n (class count)
|
|
12205
|
+
const nIn = document.createElement("input"); nIn.type = "number"; nIn.className = "c-style-panel__n"; nIn.min = "2"; nIn.max = "12";
|
|
12206
|
+
const nv = this.getAttribute("n"); if (nv) nIn.value = nv; else nIn.value = "5";
|
|
12207
|
+
body.appendChild(nIn);
|
|
12208
|
+
// opacity slider
|
|
12209
|
+
const op = document.createElement("input"); op.type = "range"; op.className = "c-style-panel__opacity"; op.min = "0"; op.max = "100";
|
|
12210
|
+
const ov = this.getAttribute("opacity"); op.value = ov != null ? ov : "100";
|
|
12211
|
+
body.appendChild(op);
|
|
12212
|
+
// breaks editor
|
|
12213
|
+
const breaks = document.createElement("input"); breaks.type = "text"; breaks.className = "c-style-panel__breaks"; breaks.placeholder = "breaks";
|
|
12214
|
+
const bv = this.getAttribute("breaks"); if (bv) breaks.value = bv;
|
|
12215
|
+
body.appendChild(breaks);
|
|
12216
|
+
// color list
|
|
12217
|
+
const colorsAttr = this.getAttribute("colors");
|
|
12218
|
+
let colors = null;
|
|
12219
|
+
if (colorsAttr) { try { colors = JSON.parse(colorsAttr); } catch (e) { colors = colorsAttr.split(",").map((s) => s.trim()); } }
|
|
12220
|
+
if (Array.isArray(colors)) {
|
|
12221
|
+
const list = document.createElement("div"); list.className = "c-style-panel__colors";
|
|
12222
|
+
colors.forEach((c) => {
|
|
12223
|
+
const sw = document.createElement("span"); sw.className = "c-style-panel__color"; sw.style.background = c; list.appendChild(sw);
|
|
12224
|
+
});
|
|
12225
|
+
body.appendChild(list);
|
|
12226
|
+
}
|
|
12227
|
+
return;
|
|
12228
|
+
}
|
|
12229
|
+
const layers = this.getAttribute("layers");
|
|
11896
12230
|
const body = this.ensure(".c-style-panel__body", () => { const el = document.createElement("div"); el.className = "c-style-panel__body"; return el; });
|
|
11897
12231
|
// Slotted content support: authored .c-style-panel__row children take
|
|
11898
12232
|
// precedence over the JSON `layers` attribute.
|