contour-ds 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/build-manifest.json +44 -44
- package/dist/contour-wc.esm.js +1012 -67
- package/dist/contour-wc.esm.min.js +1 -1
- package/dist/contour-wc.js +1012 -67
- package/dist/contour-wc.min.js +1 -1
- package/dist/contour.components.json +403 -16
- package/dist/contour.css +328 -10
- package/dist/contour.d.ts +31 -0
- package/dist/contour.esm.js +12 -0
- package/dist/contour.esm.min.js +1 -1
- package/dist/contour.js +12 -0
- package/dist/contour.min.css +1 -1
- package/dist/contour.min.js +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 +15 -4
- 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 +1 -1
- package/dist/registry/items/contour-data.json +2 -2
- package/dist/registry/items/contour-docs.json +1 -1
- package/dist/registry/items/contour-landing.json +2 -2
- package/dist/registry/registry.json +6 -6
- package/dist/surfaces/contour-data.min.css +1 -1
- package/dist/surfaces/contour-landing.min.css +1 -1
- package/dist/wc/core.mjs +13 -5
- package/dist/wc/data.mjs +687 -26
- package/dist/wc/index.mjs +1 -1
- package/dist/wc/interaction.mjs +3 -2
- package/dist/wc/map.mjs +189 -27
- package/dist/wc/shadow.mjs +29 -1
- package/dist/wc/svg.mjs +16 -1
- package/dist/wc/ui.mjs +77 -8
- package/package.json +1 -1
package/dist/contour-wc.esm.js
CHANGED
|
@@ -77,10 +77,14 @@
|
|
|
77
77
|
"contour:activate": { payload: [], composed: true },
|
|
78
78
|
"contour:add": { payload: ["value"], composed: true },
|
|
79
79
|
"contour:activity-select": { payload: ["index", "text"], composed: true },
|
|
80
|
+
"contour:break-change": { payload: ["value"], composed: true },
|
|
81
|
+
"contour:style-resolved": { payload: ["value"], composed: true },
|
|
80
82
|
"contour:advanced-toggle": { payload: ["title"], composed: true },
|
|
81
83
|
"contour:affordance-activate": { payload: ["name"], composed: true },
|
|
82
84
|
"contour:bearing": { payload: ["direction", "degrees"], composed: true },
|
|
83
85
|
"contour:btn-group-change": { payload: ["index", "label"], composed: true },
|
|
86
|
+
"contour:brush-start": { payload: ["value"], composed: true },
|
|
87
|
+
"contour:brush-end": { payload: ["value"], composed: true },
|
|
84
88
|
"contour:change": { payload: ["name", "value", "checked"], composed: true },
|
|
85
89
|
"contour:close": { payload: [], composed: true },
|
|
86
90
|
"contour:copy": { payload: ["text"], composed: true },
|
|
@@ -97,6 +101,10 @@
|
|
|
97
101
|
"contour:hide": { payload: [], composed: true },
|
|
98
102
|
"contour:input": { payload: ["name", "value", "checked"], composed: true },
|
|
99
103
|
"contour:layer-opacity": { payload: ["name", "opacity"], composed: true },
|
|
104
|
+
"contour:layer-rename": { payload: ["name", "newName"], composed: true },
|
|
105
|
+
"contour:layer-duplicate": { payload: ["name"], composed: true },
|
|
106
|
+
"contour:layer-zoom": { payload: ["name"], composed: true },
|
|
107
|
+
"contour:layer-projection": { payload: ["name", "projection"], composed: true },
|
|
100
108
|
"contour:layer-toggle": { payload: ["name"], composed: true },
|
|
101
109
|
"contour:layer-visibility": { payload: ["name", "visible"], composed: true },
|
|
102
110
|
"contour:legend-toggle": { payload: ["label", "key", "layers", "pressed"], composed: true },
|
|
@@ -166,12 +174,12 @@
|
|
|
166
174
|
// role, open, aria-label, aria-valuenow, aria-valuemin, aria-valuemax, tabindex
|
|
167
175
|
// Adding one of those back to this list makes that component recurse.
|
|
168
176
|
export const OBSERVED = [
|
|
169
|
-
"accept", "action", "actions", "after", "anchor", "answer", "area", "article", "attribution", "attribution-mark", "autoplay", "axis", "axis-x", "axis-y",
|
|
170
|
-
"cells", "checked", "chrome", "closable", "colors", "content", "controls", "copyable", "count", "current", "date", "delta", "demo", "density", "desc", "dir", "direction", "disabled", "dismissible", "divider", "do", "dont", "dot",
|
|
171
|
-
"empty", "error", "exclusive", "format", "heading", "hint", "href", "icon", "illustration", "index", "instrument", "interval", "items", "key", "layers",
|
|
172
|
-
"label", "lazy", "lede", "legend", "line", "link", "links", "live", "loading", "locale",
|
|
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",
|
|
179
|
+
"empty", "error", "exclusive", "format", "heading", "hint", "href", "icon", "illustration", "index", "instrument", "interval", "items", "key", "layers", "level",
|
|
180
|
+
"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",
|
|
173
181
|
"options", "orientation", "page-size", "pages", "pause", "paused", "pausable", "persist", "placeholder", "playing", "point", "points", "prev", "progress", "prompt", "question", "recent", "required",
|
|
174
|
-
"quote", "ramp", "refresh", "removable", "reverse", "rings", "retry", "rows", "scale", "selectable", "start", "end", "selected", "separator", "series", "shortcut", "side", "size", "skeleton", "sort", "sort-dir", "speed", "status", "step", "submit", "timeout", "trigger", "virtual",
|
|
182
|
+
"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",
|
|
175
183
|
"state", "steps", "subtitle", "summary", "src", "tabs", "tag", "text", "ticks", "title", "type", "unit",
|
|
176
184
|
"variant", "values", "viewport", "yes", "zoomable", "x", "y",
|
|
177
185
|
];
|
|
@@ -1099,6 +1107,22 @@ export function scaleBarTicks(value, segments) {
|
|
|
1099
1107
|
}
|
|
1100
1108
|
return out;
|
|
1101
1109
|
}
|
|
1110
|
+
// Marker shape encoding utility (G-13)
|
|
1111
|
+
export const MARKER_SHAPES = ["circle", "square", "triangle", "diamond", "star"];
|
|
1112
|
+
export function markerStyles(shape) {
|
|
1113
|
+
const map = {
|
|
1114
|
+
circle: "border-radius:50%",
|
|
1115
|
+
square: "border-radius:0",
|
|
1116
|
+
triangle: "clip-path:polygon(50% 0%,0% 100%,100% 100%)",
|
|
1117
|
+
diamond: "transform:rotate(45deg)",
|
|
1118
|
+
star: "clip-path:polygon(50% 0%,61% 35%,98% 35%,68% 57%,79% 91%,50% 70%,21% 91%,32% 57%,2% 35%,39% 35%)",
|
|
1119
|
+
};
|
|
1120
|
+
return map[shape] || "";
|
|
1121
|
+
}
|
|
1122
|
+
export function assignMarkers(items) {
|
|
1123
|
+
return (items || []).map((it, i) => ({ ...it, marker: MARKER_SHAPES[i % MARKER_SHAPES.length] }));
|
|
1124
|
+
}
|
|
1125
|
+
|
|
1102
1126
|
/* ============================================================================
|
|
1103
1127
|
CONTOUR — shared behaviour
|
|
1104
1128
|
----------------------------------------------------------------------------
|
|
@@ -3733,9 +3757,9 @@ class ContourReadout extends ContourBase {
|
|
|
3733
3757
|
}
|
|
3734
3758
|
define("contour-readout", ContourReadout);
|
|
3735
3759
|
class ContourKpi extends ContourBase {
|
|
3736
|
-
static get observed() { return ["value", "label", "delta", "direction", "note", "variant", "unit", "format", "locale", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton"]; }
|
|
3760
|
+
static get observed() { return ["value", "label", "delta", "direction", "note", "variant", "unit", "format", "locale", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton", "thresholds", "threshold", "sparkline", "polarity"]; }
|
|
3737
3761
|
static get properties() {
|
|
3738
|
-
return { value: { attribute: "value" }, label: { attribute: "label" }, delta: { attribute: "delta" }, direction: { attribute: "direction" }, note: { attribute: "note" }, variant: { attribute: "variant" }, unit: { attribute: "unit" }, format: { attribute: "format" }, locale: { attribute: "locale" } };
|
|
3762
|
+
return { value: { attribute: "value" }, label: { attribute: "label" }, delta: { attribute: "delta" }, direction: { attribute: "direction" }, note: { attribute: "note" }, variant: { attribute: "variant" }, unit: { attribute: "unit" }, format: { attribute: "format" }, locale: { attribute: "locale" }, thresholds: { attribute: "thresholds" }, threshold: { attribute: "threshold" }, sparkline: { attribute: "sparkline" }, polarity: { attribute: "polarity" } };
|
|
3739
3763
|
}
|
|
3740
3764
|
render() {
|
|
3741
3765
|
this.classList.add("c-kpi");
|
|
@@ -3796,6 +3820,30 @@ class ContourKpi extends ContourBase {
|
|
|
3796
3820
|
if (u) u.remove();
|
|
3797
3821
|
}
|
|
3798
3822
|
}
|
|
3823
|
+
// threshold badge
|
|
3824
|
+
const threshold = this.getAttribute("threshold") || this.getAttribute("thresholds");
|
|
3825
|
+
if (threshold) {
|
|
3826
|
+
const f = this.ensure(".c-kpi__foot", () => { const el = document.createElement("div"); el.className = "c-kpi__foot"; return el; });
|
|
3827
|
+
let badge = f.querySelector(".c-kpi__threshold-badge");
|
|
3828
|
+
if (!badge) { badge = document.createElement("span"); badge.className = "c-kpi__threshold-badge"; f.appendChild(badge); }
|
|
3829
|
+
badge.textContent = threshold;
|
|
3830
|
+
badge.setAttribute("part", "threshold-badge");
|
|
3831
|
+
} else {
|
|
3832
|
+
const b = this.querySelector(".c-kpi__threshold-badge");
|
|
3833
|
+
if (b) b.remove();
|
|
3834
|
+
}
|
|
3835
|
+
// remove orphaned foot container when no children remain
|
|
3836
|
+
const foot = this.querySelector(".c-kpi__foot");
|
|
3837
|
+
if (foot && !foot.querySelector(".c-delta, .c-kpi__note, .c-kpi__threshold-badge")) foot.remove();
|
|
3838
|
+
// sparkline canvas
|
|
3839
|
+
const spark = this.getAttribute("sparkline");
|
|
3840
|
+
if (spark) {
|
|
3841
|
+
let canvas = this.querySelector(".c-kpi__sparkline-canvas");
|
|
3842
|
+
if (!canvas) { canvas = document.createElement("canvas"); canvas.className = "c-kpi__sparkline-canvas"; canvas.setAttribute("part", "sparkline-canvas"); this.appendChild(canvas); }
|
|
3843
|
+
} else {
|
|
3844
|
+
const c = this.querySelector(".c-kpi__sparkline-canvas");
|
|
3845
|
+
if (c) c.remove();
|
|
3846
|
+
}
|
|
3799
3847
|
if (!value && !label) {
|
|
3800
3848
|
renderEmpty(this, "kpi");
|
|
3801
3849
|
}
|
|
@@ -4639,24 +4687,32 @@ const series = this.getAttribute("series");
|
|
|
4639
4687
|
}
|
|
4640
4688
|
define("contour-chart", ContourChart);
|
|
4641
4689
|
class ContourComparison extends ContourBase {
|
|
4642
|
-
static get observed() { return ["divider", "value"]; }
|
|
4643
|
-
static get properties() { return { divider: { attribute: "divider" }, value: { attribute: "value" } }; }
|
|
4690
|
+
static get observed() { return ["divider", "value", "before", "after"]; }
|
|
4691
|
+
static get properties() { return { divider: { attribute: "divider" }, value: { attribute: "value" }, before: { attribute: "before" }, after: { attribute: "after" } }; }
|
|
4644
4692
|
render() {
|
|
4645
4693
|
this.classList.add("c-comparison");
|
|
4646
|
-
this.style.blockSize = "12rem";
|
|
4694
|
+
if (!this.style.blockSize) this.style.blockSize = "12rem";
|
|
4647
4695
|
this.style.setProperty("--comparison-pos", (this.getAttribute("value") || "50") + "%");
|
|
4648
4696
|
// Ensure two panes exist.
|
|
4697
|
+
const beforeLabel = this.getAttribute("before") || "Before";
|
|
4698
|
+
const afterLabel = this.getAttribute("after") || "After";
|
|
4649
4699
|
if (!this.querySelector(".c-comparison__pane--before")) {
|
|
4650
4700
|
const p = document.createElement("div");
|
|
4651
4701
|
p.className = "c-comparison__pane c-comparison__pane--before";
|
|
4652
|
-
p.textContent =
|
|
4702
|
+
p.textContent = beforeLabel;
|
|
4653
4703
|
this.appendChild(p);
|
|
4704
|
+
} else {
|
|
4705
|
+
const p = this.querySelector(".c-comparison__pane--before");
|
|
4706
|
+
if (p) p.textContent = beforeLabel;
|
|
4654
4707
|
}
|
|
4655
4708
|
if (!this.querySelector(".c-comparison__pane:not(.c-comparison__pane--before)")) {
|
|
4656
4709
|
const p = document.createElement("div");
|
|
4657
4710
|
p.className = "c-comparison__pane";
|
|
4658
|
-
p.textContent =
|
|
4711
|
+
p.textContent = afterLabel;
|
|
4659
4712
|
this.appendChild(p);
|
|
4713
|
+
} else {
|
|
4714
|
+
const p = this.querySelector(".c-comparison__pane:not(.c-comparison__pane--before)");
|
|
4715
|
+
if (p) p.textContent = afterLabel;
|
|
4660
4716
|
}
|
|
4661
4717
|
const divider = this.getAttribute("divider");
|
|
4662
4718
|
if (divider !== null) {
|
|
@@ -4930,6 +4986,517 @@ class ContourStat extends ContourBase {
|
|
|
4930
4986
|
}
|
|
4931
4987
|
}
|
|
4932
4988
|
define("contour-stat", ContourStat);
|
|
4989
|
+
class ContourGauge extends ContourBase {
|
|
4990
|
+
static get observed() { return ["value", "min", "max", "heading", "thresholds", "format", "locale", "unit", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton", "brownout", "brownout-level", "no-data-message", "show-header", "description"]; }
|
|
4991
|
+
static get properties() { return { value: { attribute: "value" }, min: { attribute: "min" }, max: { attribute: "max" }, heading: { attribute: "heading" }, thresholds: { attribute: "thresholds" }, format: { attribute: "format" }, locale: { attribute: "locale" }, unit: { attribute: "unit" }, src: { attribute: "src" }, brownout: { attribute: "brownout" } }; }
|
|
4992
|
+
render() {
|
|
4993
|
+
this.classList.add("c-gauge");
|
|
4994
|
+
wireStates(this);
|
|
4995
|
+
loadRemote(this, ["value"]);
|
|
4996
|
+
if (renderStates(this, "gauge")) return;
|
|
4997
|
+
const rawValue = this.getAttribute("value");
|
|
4998
|
+
const num = parseFloat(rawValue);
|
|
4999
|
+
const hasValue = rawValue !== null && rawValue !== "" && Number.isFinite(num);
|
|
5000
|
+
const min = parseFloat(this.getAttribute("min") || "0");
|
|
5001
|
+
const max = parseFloat(this.getAttribute("max") || "100");
|
|
5002
|
+
const heading = this.getAttribute("heading");
|
|
5003
|
+
const showHeader = this.getAttribute("show-header") !== "false";
|
|
5004
|
+
const description = this.getAttribute("description");
|
|
5005
|
+
const noDataMessage = this.getAttribute("no-data-message") || "No readings in view";
|
|
5006
|
+
const brownoutLevel = parseInt(this.getAttribute("brownout-level") || this.getAttribute("brownout") || "0", 10) || 0;
|
|
5007
|
+
// empty state
|
|
5008
|
+
if (!hasValue) {
|
|
5009
|
+
if (heading && showHeader) {
|
|
5010
|
+
const t = this.ensure(".c-gauge__title", () => { const el = document.createElement("div"); el.className = "c-gauge__title"; return el; });
|
|
5011
|
+
t.textContent = heading;
|
|
5012
|
+
}
|
|
5013
|
+
const empty = this.ensure(".c-gauge__empty", () => { const el = document.createElement("div"); el.className = "c-gauge__empty"; el.setAttribute("part", "empty"); return el; });
|
|
5014
|
+
empty.textContent = noDataMessage;
|
|
5015
|
+
// remove dial/value/band if present
|
|
5016
|
+
[".c-gauge__dial", ".c-gauge__value", ".c-gauge__band"].forEach((sel) => { const n = this.querySelector(sel); if (n) n.remove(); });
|
|
5017
|
+
return;
|
|
5018
|
+
}
|
|
5019
|
+
// heading
|
|
5020
|
+
if (heading && showHeader) {
|
|
5021
|
+
const t = this.ensure(".c-gauge__title", () => { const el = document.createElement("div"); el.className = "c-gauge__title"; el.setAttribute("part", "title"); return el; });
|
|
5022
|
+
t.textContent = heading;
|
|
5023
|
+
} else {
|
|
5024
|
+
const t = this.querySelector(".c-gauge__title"); if (t) t.remove();
|
|
5025
|
+
}
|
|
5026
|
+
// thresholds
|
|
5027
|
+
let thresholds = [];
|
|
5028
|
+
const tAttr = this.getAttribute("thresholds");
|
|
5029
|
+
if (tAttr) { try { thresholds = JSON.parse(tAttr); } catch (e) { thresholds = []; } }
|
|
5030
|
+
// band determination
|
|
5031
|
+
let band = null;
|
|
5032
|
+
if (thresholds && thresholds.length) {
|
|
5033
|
+
// thresholds sorted ascending by value
|
|
5034
|
+
const sorted = [...thresholds].sort((a, b) => (a.value || 0) - (b.value || 0));
|
|
5035
|
+
for (let i = sorted.length - 1; i >= 0; i--) {
|
|
5036
|
+
if (num >= (sorted[i].value || 0)) { band = sorted[i]; break; }
|
|
5037
|
+
}
|
|
5038
|
+
}
|
|
5039
|
+
// dial (unless brownout >= 3)
|
|
5040
|
+
const shedDial = brownoutLevel >= 3;
|
|
5041
|
+
let dial = this.querySelector(".c-gauge__dial");
|
|
5042
|
+
if (shedDial) {
|
|
5043
|
+
if (dial) dial.remove();
|
|
5044
|
+
} else {
|
|
5045
|
+
if (!dial) {
|
|
5046
|
+
dial = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
5047
|
+
dial.setAttribute("class", "c-gauge__dial");
|
|
5048
|
+
dial.setAttribute("part", "dial");
|
|
5049
|
+
dial.setAttribute("aria-hidden", "true");
|
|
5050
|
+
dial.setAttribute("viewBox", "0 0 100 100");
|
|
5051
|
+
this.appendChild(dial);
|
|
5052
|
+
}
|
|
5053
|
+
// rebuild dial content
|
|
5054
|
+
dial.innerHTML = "";
|
|
5055
|
+
// track arc (semicircle)
|
|
5056
|
+
const track = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
5057
|
+
track.setAttribute("class", "c-gauge__track");
|
|
5058
|
+
track.setAttribute("d", "M 10 90 A 40 40 0 0 1 90 90");
|
|
5059
|
+
dial.appendChild(track);
|
|
5060
|
+
// zones: each threshold defines a band from its value to the next
|
|
5061
|
+
// threshold's value (or max), drawn as an arc along the track so the
|
|
5062
|
+
// bands no longer stack on top of one another.
|
|
5063
|
+
if (thresholds && thresholds.length) {
|
|
5064
|
+
const sorted = [...thresholds].sort((a, b) => (a.value || 0) - (b.value || 0));
|
|
5065
|
+
const toPoint = (v) => {
|
|
5066
|
+
const pos = (1 - (v - min) / (max - min || 1)) * Math.PI;
|
|
5067
|
+
return { x: 50 + 40 * Math.cos(pos), y: 90 - 40 * Math.sin(pos) };
|
|
5068
|
+
};
|
|
5069
|
+
for (let i = 0; i < sorted.length; i++) {
|
|
5070
|
+
const v1 = sorted[i].value || 0;
|
|
5071
|
+
const v2 = (i + 1 < sorted.length) ? (sorted[i + 1].value || max) : max;
|
|
5072
|
+
const p1 = toPoint(v1);
|
|
5073
|
+
const p2 = toPoint(v2);
|
|
5074
|
+
const z = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
5075
|
+
z.setAttribute("class", "c-gauge__zone");
|
|
5076
|
+
z.setAttribute("stroke", sorted[i].color || "var(--color-primary)");
|
|
5077
|
+
z.setAttribute("d", "M " + p1.x.toFixed(2) + " " + p1.y.toFixed(2) + " A 40 40 0 0 1 " + p2.x.toFixed(2) + " " + p2.y.toFixed(2));
|
|
5078
|
+
dial.appendChild(z);
|
|
5079
|
+
}
|
|
5080
|
+
}
|
|
5081
|
+
// needle
|
|
5082
|
+
const angle = ((num - min) / (max - min || 1)) * 180 - 90;
|
|
5083
|
+
const needle = document.createElementNS("http://www.w3.org/2000/svg", "line");
|
|
5084
|
+
needle.setAttribute("class", "c-gauge__needle needle");
|
|
5085
|
+
needle.setAttribute("x1", "50"); needle.setAttribute("y1", "50");
|
|
5086
|
+
needle.setAttribute("x2", String(50 + 35 * Math.cos(angle * Math.PI / 180)));
|
|
5087
|
+
needle.setAttribute("y2", String(50 + 35 * Math.sin(angle * Math.PI / 180)));
|
|
5088
|
+
dial.appendChild(needle);
|
|
5089
|
+
const hub = document.createElementNS("http://www.w3.org/2000/svg", "circle");
|
|
5090
|
+
hub.setAttribute("class", "c-gauge__hub hub");
|
|
5091
|
+
hub.setAttribute("cx", "50"); hub.setAttribute("cy", "50"); hub.setAttribute("r", "4");
|
|
5092
|
+
dial.appendChild(hub);
|
|
5093
|
+
}
|
|
5094
|
+
// value element (meter)
|
|
5095
|
+
const valueEl = this.ensure(".c-gauge__value", () => { const el = document.createElement("div"); el.className = "c-gauge__value"; el.setAttribute("part", "value"); return el; });
|
|
5096
|
+
valueEl.textContent = formatValue(String(num), this.getAttribute("format"), this.getAttribute("locale")) + (this.getAttribute("unit") ? " " + this.getAttribute("unit") : "");
|
|
5097
|
+
valueEl.setAttribute("role", "meter");
|
|
5098
|
+
valueEl.setAttribute("aria-valuenow", String(num));
|
|
5099
|
+
valueEl.setAttribute("aria-valuemin", String(min));
|
|
5100
|
+
valueEl.setAttribute("aria-valuemax", String(max));
|
|
5101
|
+
if (heading) {
|
|
5102
|
+
// labelledby
|
|
5103
|
+
if (!valueEl.id) valueEl.id = contourId("gauge-value");
|
|
5104
|
+
}
|
|
5105
|
+
if (band) {
|
|
5106
|
+
valueEl.setAttribute("aria-valuetext", num + ", " + (band.label || (">= " + band.value)));
|
|
5107
|
+
} else {
|
|
5108
|
+
valueEl.setAttribute("aria-valuetext", String(num));
|
|
5109
|
+
}
|
|
5110
|
+
// aria-labelledby / aria-label
|
|
5111
|
+
const titleEl = this.querySelector(".c-gauge__title");
|
|
5112
|
+
if (titleEl) {
|
|
5113
|
+
if (!titleEl.id) titleEl.id = contourId("gauge-title");
|
|
5114
|
+
valueEl.setAttribute("aria-labelledby", titleEl.id);
|
|
5115
|
+
valueEl.removeAttribute("aria-label");
|
|
5116
|
+
} else {
|
|
5117
|
+
valueEl.removeAttribute("aria-labelledby");
|
|
5118
|
+
if (heading) valueEl.setAttribute("aria-label", heading);
|
|
5119
|
+
}
|
|
5120
|
+
// band word
|
|
5121
|
+
const bandEl = this.querySelector(".c-gauge__band");
|
|
5122
|
+
if (band) {
|
|
5123
|
+
const b = this.ensure(".c-gauge__band", () => { const el = document.createElement("div"); el.className = "c-gauge__band"; el.setAttribute("part", "band"); return el; });
|
|
5124
|
+
b.textContent = band.label || (">= " + band.value);
|
|
5125
|
+
} else {
|
|
5126
|
+
if (bandEl) bandEl.remove();
|
|
5127
|
+
}
|
|
5128
|
+
// description
|
|
5129
|
+
if (description) {
|
|
5130
|
+
let d = this.querySelector(".c-gauge__desc");
|
|
5131
|
+
if (!d) { d = document.createElement("div"); d.className = "c-gauge__desc"; this.appendChild(d); }
|
|
5132
|
+
d.textContent = description;
|
|
5133
|
+
}
|
|
5134
|
+
}
|
|
5135
|
+
enhance() {}
|
|
5136
|
+
}
|
|
5137
|
+
define("contour-gauge", ContourGauge);
|
|
5138
|
+
class ContourAxis extends ContourBase {
|
|
5139
|
+
static get observed() { return ["orientation", "values", "ticks", "format", "locale", "padding", "min", "max", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton"]; }
|
|
5140
|
+
static get properties() { return { orientation: { attribute: "orientation" }, values: { attribute: "values" }, ticks: { attribute: "ticks" }, format: { attribute: "format" }, locale: { attribute: "locale" }, padding: { attribute: "padding" }, min: { attribute: "min" }, max: { attribute: "max" }, src: { attribute: "src" } }; }
|
|
5141
|
+
render() {
|
|
5142
|
+
this.classList.add("c-axis");
|
|
5143
|
+
const orientation = this.getAttribute("orientation") || "horizontal";
|
|
5144
|
+
this.classList.toggle("c-axis--horizontal", orientation === "horizontal");
|
|
5145
|
+
this.classList.toggle("c-axis--vertical", orientation === "vertical");
|
|
5146
|
+
if (orientation === "horizontal") this.setAttribute("part", "axis-x");
|
|
5147
|
+
else this.setAttribute("part", "axis-y");
|
|
5148
|
+
wireStates(this);
|
|
5149
|
+
loadRemote(this, ["values"]);
|
|
5150
|
+
if (renderStates(this, "axis")) return;
|
|
5151
|
+
// parse values
|
|
5152
|
+
let values = [];
|
|
5153
|
+
const vAttr = this.getAttribute("values");
|
|
5154
|
+
if (vAttr) { try { values = JSON.parse(vAttr); } catch (e) { values = vAttr.split(",").map((x) => x.trim()); } }
|
|
5155
|
+
const ticks = parseInt(this.getAttribute("ticks") || "0", 10) || values.length;
|
|
5156
|
+
// Slotted content support: authored .c-axis__tick children take
|
|
5157
|
+
// precedence over the JSON `values` attribute.
|
|
5158
|
+
const authoredTicks = Array.from(this.querySelectorAll(":scope > .c-axis__tick"));
|
|
5159
|
+
if (authoredTicks.length) {
|
|
5160
|
+
// keep authored ticks, just ensure labels are formatted
|
|
5161
|
+
authoredTicks.forEach((tick) => {
|
|
5162
|
+
const label = tick.querySelector(".c-axis__label");
|
|
5163
|
+
if (label && !label.textContent) label.textContent = tick.textContent;
|
|
5164
|
+
});
|
|
5165
|
+
} else {
|
|
5166
|
+
// clear
|
|
5167
|
+
Array.from(this.querySelectorAll(".c-axis__tick")).forEach((n) => n.remove());
|
|
5168
|
+
const list = values.length ? values : Array.from({ length: ticks }, (_, i) => i);
|
|
5169
|
+
list.forEach((v) => {
|
|
5170
|
+
const tick = document.createElement("span");
|
|
5171
|
+
tick.className = "c-axis__tick";
|
|
5172
|
+
const label = document.createElement("span");
|
|
5173
|
+
label.className = "c-axis__label";
|
|
5174
|
+
label.textContent = formatValue(String(v), this.getAttribute("format"), this.getAttribute("locale"));
|
|
5175
|
+
tick.appendChild(label);
|
|
5176
|
+
this.appendChild(tick);
|
|
5177
|
+
});
|
|
5178
|
+
}
|
|
5179
|
+
}
|
|
5180
|
+
enhance() {}
|
|
5181
|
+
}
|
|
5182
|
+
define("contour-axis", ContourAxis);
|
|
5183
|
+
class ContourBrush extends ContourBase {
|
|
5184
|
+
static get observed() { return ["start", "end", "min", "max", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton"]; }
|
|
5185
|
+
static get properties() { return { start: { attribute: "start" }, end: { attribute: "end" }, min: { attribute: "min" }, max: { attribute: "max" }, src: { attribute: "src" } }; }
|
|
5186
|
+
render() {
|
|
5187
|
+
this.classList.add("c-brush");
|
|
5188
|
+
wireStates(this);
|
|
5189
|
+
loadRemote(this, []);
|
|
5190
|
+
if (renderStates(this, "brush")) return;
|
|
5191
|
+
let sel = this.querySelector(".c-brush__selection");
|
|
5192
|
+
if (!sel) { sel = document.createElement("div"); sel.className = "c-brush__selection"; this.appendChild(sel); }
|
|
5193
|
+
const start = parseFloat(this.getAttribute("start") || "0");
|
|
5194
|
+
const end = parseFloat(this.getAttribute("end") || "100");
|
|
5195
|
+
const min = parseFloat(this.getAttribute("min") || "0");
|
|
5196
|
+
const max = parseFloat(this.getAttribute("max") || "100");
|
|
5197
|
+
const range = max - min || 1;
|
|
5198
|
+
const left = ((start - min) / range) * 100;
|
|
5199
|
+
const width = ((end - start) / range) * 100;
|
|
5200
|
+
sel.style.insetInlineStart = left + "%";
|
|
5201
|
+
sel.style.inlineSize = width + "%";
|
|
5202
|
+
// handles
|
|
5203
|
+
["start","end"].forEach((h) => {
|
|
5204
|
+
let handle = this.querySelector(".c-brush__handle--" + h);
|
|
5205
|
+
if (!handle) { handle = document.createElement("div"); handle.className = "c-brush__handle c-brush__handle--" + h; this.appendChild(handle); }
|
|
5206
|
+
const val = h === "start" ? start : end;
|
|
5207
|
+
handle.style.insetInlineStart = (((val - min) / range) * 100) + "%";
|
|
5208
|
+
});
|
|
5209
|
+
}
|
|
5210
|
+
enhance() {
|
|
5211
|
+
if (this._wiredBrush) return;
|
|
5212
|
+
this._wiredBrush = true;
|
|
5213
|
+
this.addEventListener("pointerdown", (e) => {
|
|
5214
|
+
this.dispatchEvent(new CustomEvent("contour:brush-start", { bubbles: true, composed: true, detail: { value: this.getAttribute("start"), start: this.getAttribute("start"), end: this.getAttribute("end") } }));
|
|
5215
|
+
});
|
|
5216
|
+
this.addEventListener("pointerup", (e) => {
|
|
5217
|
+
this.dispatchEvent(new CustomEvent("contour:brush-end", { bubbles: true, composed: true, detail: { value: this.getAttribute("end"), start: this.getAttribute("start"), end: this.getAttribute("end") } }));
|
|
5218
|
+
});
|
|
5219
|
+
}
|
|
5220
|
+
}
|
|
5221
|
+
define("contour-brush", ContourBrush);
|
|
5222
|
+
class ContourStackedBar extends ContourBase {
|
|
5223
|
+
static get observed() { return ["segments", "values", "colors", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton", "normalize"]; }
|
|
5224
|
+
static get properties() { return { segments: { attribute: "segments" }, values: { attribute: "values" }, colors: { attribute: "colors" }, src: { attribute: "src" }, normalize: { attribute: "normalize" } }; }
|
|
5225
|
+
render() {
|
|
5226
|
+
this.classList.add("c-stacked-bar");
|
|
5227
|
+
wireStates(this);
|
|
5228
|
+
loadRemote(this, ["segments", "values"]);
|
|
5229
|
+
if (renderStates(this, "stacked-bar")) return;
|
|
5230
|
+
Array.from(this.querySelectorAll(".c-stacked-bar__segment")).forEach((n) => n.remove());
|
|
5231
|
+
// Slotted content support: authored .c-stacked-bar__segment children take
|
|
5232
|
+
// precedence over the JSON `segments` attribute.
|
|
5233
|
+
const authoredSegments = Array.from(this.querySelectorAll(":scope > .c-stacked-bar__segment"));
|
|
5234
|
+
let segments = [];
|
|
5235
|
+
if (authoredSegments.length) {
|
|
5236
|
+
segments = authoredSegments.map((el) => ({
|
|
5237
|
+
label: el.getAttribute("title") || el.textContent || "",
|
|
5238
|
+
value: parseFloat(el.style.inlineSize) || 0,
|
|
5239
|
+
color: el.style.background || undefined,
|
|
5240
|
+
}));
|
|
5241
|
+
authoredSegments.forEach((el) => el.remove());
|
|
5242
|
+
} else {
|
|
5243
|
+
const sAttr = this.getAttribute("segments");
|
|
5244
|
+
if (sAttr) { try { segments = JSON.parse(sAttr); } catch (e) { segments = []; } }
|
|
5245
|
+
}
|
|
5246
|
+
const values = segments.map((seg) => (typeof seg === "object" ? (seg.value || 0) : Number(seg) || 0));
|
|
5247
|
+
const total = values.reduce((a, b) => a + b, 0) || 1;
|
|
5248
|
+
const normalize = this.hasAttribute("normalize");
|
|
5249
|
+
const denom = normalize ? total : (parseFloat(this.getAttribute("max") || String(total)) || total);
|
|
5250
|
+
segments.forEach((seg, i) => {
|
|
5251
|
+
const v = values[i];
|
|
5252
|
+
const el = document.createElement("div");
|
|
5253
|
+
el.className = "c-stacked-bar__segment";
|
|
5254
|
+
el.style.inlineSize = ((v / denom) * 100) + "%";
|
|
5255
|
+
el.style.background = (typeof seg === "object" && seg.color) ? seg.color : "var(--chart-" + ((i % 8) + 1) + ")";
|
|
5256
|
+
el.setAttribute("title", (typeof seg === "object" ? (seg.label || "") : "") + " " + v);
|
|
5257
|
+
this.appendChild(el);
|
|
5258
|
+
});
|
|
5259
|
+
if (!segments.length) renderEmpty(this, "stacked-bar");
|
|
5260
|
+
}
|
|
5261
|
+
enhance() {}
|
|
5262
|
+
}
|
|
5263
|
+
define("contour-stacked-bar", ContourStackedBar);
|
|
5264
|
+
class ContourCategory extends ContourBase {
|
|
5265
|
+
static get observed() { return ["items", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton", "search"]; }
|
|
5266
|
+
static get properties() { return { items: { attribute: "items" }, src: { attribute: "src" }, search: { attribute: "search" } }; }
|
|
5267
|
+
render() {
|
|
5268
|
+
this.classList.add("c-category");
|
|
5269
|
+
this.setAttribute("role", "listbox");
|
|
5270
|
+
wireStates(this);
|
|
5271
|
+
loadRemote(this, ["items"]);
|
|
5272
|
+
if (renderStates(this, "category")) return;
|
|
5273
|
+
Array.from(this.querySelectorAll(".c-category__item")).forEach((n) => n.remove());
|
|
5274
|
+
// Slotted content support: authored .c-category__item children take
|
|
5275
|
+
// precedence over the JSON `items` attribute.
|
|
5276
|
+
const authoredItems = Array.from(this.querySelectorAll(":scope > .c-category__item"));
|
|
5277
|
+
let items = [];
|
|
5278
|
+
if (authoredItems.length) {
|
|
5279
|
+
authoredItems.forEach((el) => {
|
|
5280
|
+
const lbl = el.querySelector(".c-category__label");
|
|
5281
|
+
items.push({ label: lbl ? lbl.textContent : el.textContent, value: 0 });
|
|
5282
|
+
});
|
|
5283
|
+
authoredItems.forEach((el) => el.remove());
|
|
5284
|
+
} else {
|
|
5285
|
+
const iAttr = this.getAttribute("items");
|
|
5286
|
+
if (iAttr) { try { items = JSON.parse(iAttr); } catch (e) { items = []; } }
|
|
5287
|
+
}
|
|
5288
|
+
const max = items.reduce((m, it) => Math.max(m, (typeof it === "object" ? (it.value || 0) : Number(it) || 0)), 0) || 1;
|
|
5289
|
+
items.forEach((it, idx) => {
|
|
5290
|
+
const value = (typeof it === "object") ? (it.value || 0) : (Number(it) || 0);
|
|
5291
|
+
const label = (typeof it === "object") ? (it.label || it.name || "") : String(it);
|
|
5292
|
+
const item = document.createElement("div");
|
|
5293
|
+
item.className = "c-category__item";
|
|
5294
|
+
item.setAttribute("role", "option");
|
|
5295
|
+
item.setAttribute("aria-selected", "false");
|
|
5296
|
+
const lbl = document.createElement("span");
|
|
5297
|
+
lbl.className = "c-category__label";
|
|
5298
|
+
lbl.textContent = label;
|
|
5299
|
+
const barWrap = document.createElement("div");
|
|
5300
|
+
barWrap.style.flex = "1";
|
|
5301
|
+
const bar = document.createElement("div");
|
|
5302
|
+
bar.className = "c-category__bar";
|
|
5303
|
+
bar.style.inlineSize = ((value / max) * 100) + "%";
|
|
5304
|
+
barWrap.appendChild(bar);
|
|
5305
|
+
const val = document.createElement("span");
|
|
5306
|
+
val.className = "c-category__value";
|
|
5307
|
+
val.textContent = String(value);
|
|
5308
|
+
item.appendChild(lbl);
|
|
5309
|
+
item.appendChild(barWrap);
|
|
5310
|
+
item.appendChild(val);
|
|
5311
|
+
this.appendChild(item);
|
|
5312
|
+
});
|
|
5313
|
+
if (!items.length) renderEmpty(this, "category");
|
|
5314
|
+
}
|
|
5315
|
+
enhance() {}
|
|
5316
|
+
}
|
|
5317
|
+
define("contour-category", ContourCategory);
|
|
5318
|
+
class ContourDonut extends ContourBase {
|
|
5319
|
+
static get observed() { return ["value", "values", "items", "label", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton", "brownout", "brownout-level"]; }
|
|
5320
|
+
static get properties() { return { value: { attribute: "value" }, values: { attribute: "values" }, items: { attribute: "items" }, label: { attribute: "label" }, src: { attribute: "src" } }; }
|
|
5321
|
+
render() {
|
|
5322
|
+
this.classList.add("c-donut");
|
|
5323
|
+
wireStates(this);
|
|
5324
|
+
loadRemote(this, ["items", "values"]);
|
|
5325
|
+
if (renderStates(this, "donut")) return;
|
|
5326
|
+
Array.from(this.querySelectorAll(".c-donut__ring, .c-donut__center, .c-donut__list, .c-donut__empty")).forEach((n) => n.remove());
|
|
5327
|
+
// Slotted content support: authored .c-donut__item children take precedence
|
|
5328
|
+
// over the JSON `items` attribute, so consumers can compose legend rows
|
|
5329
|
+
// by hand instead of serialising them into an attribute.
|
|
5330
|
+
const authoredItems = Array.from(this.querySelectorAll(":scope > .c-donut__item"));
|
|
5331
|
+
let items = [];
|
|
5332
|
+
if (authoredItems.length) {
|
|
5333
|
+
authoredItems.forEach((el) => {
|
|
5334
|
+
const sw = el.querySelector(".c-donut__swatch");
|
|
5335
|
+
const lbl = el.querySelector("span:last-child");
|
|
5336
|
+
const text = lbl ? lbl.textContent : el.textContent;
|
|
5337
|
+
const match = text.match(/—\s*(\d+(?:\.\d+)?)$/);
|
|
5338
|
+
items.push({ label: text.replace(/—\s*\d+(?:\.\d+)?$/, "").trim(), value: match ? Number(match[1]) : 0, color: sw ? sw.style.background : undefined });
|
|
5339
|
+
});
|
|
5340
|
+
// remove authored items from DOM (they will be regenerated below)
|
|
5341
|
+
authoredItems.forEach((el) => el.remove());
|
|
5342
|
+
} else {
|
|
5343
|
+
const iAttr = this.getAttribute("items");
|
|
5344
|
+
if (iAttr) { try { items = JSON.parse(iAttr); } catch (e) { items = []; } }
|
|
5345
|
+
}
|
|
5346
|
+
const values = items.map((it) => (typeof it === "object" ? (it.value || 0) : Number(it) || 0));
|
|
5347
|
+
const total = values.reduce((a, b) => a + b, 0) || 1;
|
|
5348
|
+
const brownoutLevel = parseInt(this.getAttribute("brownout-level") || this.getAttribute("brownout") || "0", 10) || 0;
|
|
5349
|
+
const shedRing = brownoutLevel >= 3;
|
|
5350
|
+
if (!shedRing) {
|
|
5351
|
+
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
5352
|
+
svg.setAttribute("class", "c-donut__ring");
|
|
5353
|
+
svg.setAttribute("viewBox", "0 0 32 32");
|
|
5354
|
+
let offset = 0;
|
|
5355
|
+
items.forEach((it, i) => {
|
|
5356
|
+
const v = values[i];
|
|
5357
|
+
const pct = v / total;
|
|
5358
|
+
const circle = document.createElementNS("http://www.w3.org/2000/svg", "circle");
|
|
5359
|
+
circle.setAttribute("cx", "16"); circle.setAttribute("cy", "16"); circle.setAttribute("r", "12");
|
|
5360
|
+
circle.setAttribute("fill", "none");
|
|
5361
|
+
circle.setAttribute("stroke", (typeof it === "object" && it.color) ? it.color : "var(--chart-" + ((i % 8) + 1) + ")");
|
|
5362
|
+
circle.setAttribute("stroke-width", "6");
|
|
5363
|
+
const circ = 2 * Math.PI * 12;
|
|
5364
|
+
circle.setAttribute("stroke-dasharray", (pct * circ) + " " + (circ - pct * circ));
|
|
5365
|
+
circle.setAttribute("stroke-dashoffset", String(-offset * circ));
|
|
5366
|
+
circle.setAttribute("transform", "rotate(-90 16 16)");
|
|
5367
|
+
svg.appendChild(circle);
|
|
5368
|
+
offset += pct;
|
|
5369
|
+
});
|
|
5370
|
+
// center hole
|
|
5371
|
+
const hole = document.createElementNS("http://www.w3.org/2000/svg", "circle");
|
|
5372
|
+
hole.setAttribute("cx", "16"); hole.setAttribute("cy", "16"); hole.setAttribute("r", "9");
|
|
5373
|
+
hole.setAttribute("fill", "var(--color-surface-0)");
|
|
5374
|
+
svg.appendChild(hole);
|
|
5375
|
+
this.appendChild(svg);
|
|
5376
|
+
}
|
|
5377
|
+
const center = document.createElement("div");
|
|
5378
|
+
center.className = "c-donut__center";
|
|
5379
|
+
center.textContent = this.getAttribute("value") || String(total);
|
|
5380
|
+
this.appendChild(center);
|
|
5381
|
+
// text list
|
|
5382
|
+
const list = document.createElement("div");
|
|
5383
|
+
list.className = "c-donut__list";
|
|
5384
|
+
items.forEach((it, i) => {
|
|
5385
|
+
const row = document.createElement("div");
|
|
5386
|
+
row.className = "c-donut__item";
|
|
5387
|
+
const sw = document.createElement("span");
|
|
5388
|
+
sw.className = "c-donut__swatch";
|
|
5389
|
+
sw.style.background = (typeof it === "object" && it.color) ? it.color : "var(--chart-" + ((i % 8) + 1) + ")";
|
|
5390
|
+
row.appendChild(sw);
|
|
5391
|
+
const lbl = document.createElement("span");
|
|
5392
|
+
lbl.textContent = (typeof it === "object" ? (it.label || "") : String(it)) + " — " + values[i];
|
|
5393
|
+
row.appendChild(lbl);
|
|
5394
|
+
list.appendChild(row);
|
|
5395
|
+
});
|
|
5396
|
+
this.appendChild(list);
|
|
5397
|
+
if (!items.length) renderEmpty(this, "donut");
|
|
5398
|
+
}
|
|
5399
|
+
enhance() {}
|
|
5400
|
+
}
|
|
5401
|
+
define("contour-donut", ContourDonut);
|
|
5402
|
+
class ContourTimeSeries extends ContourBase {
|
|
5403
|
+
static get observed() { return ["values", "points", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton", "annotations"]; }
|
|
5404
|
+
static get properties() { return { values: { attribute: "values" }, points: { attribute: "points" }, src: { attribute: "src" }, annotations: { attribute: "annotations" } }; }
|
|
5405
|
+
render() {
|
|
5406
|
+
this.classList.add("c-time-series");
|
|
5407
|
+
wireStates(this);
|
|
5408
|
+
loadRemote(this, ["values", "points"]);
|
|
5409
|
+
if (renderStates(this, "time-series")) return;
|
|
5410
|
+
Array.from(this.querySelectorAll(".c-time-series__plot, .c-time-series__axis")).forEach((n) => n.remove());
|
|
5411
|
+
let values = [];
|
|
5412
|
+
const vAttr = this.getAttribute("values");
|
|
5413
|
+
if (vAttr) { try { values = JSON.parse(vAttr); } catch (e) { values = vAttr.split(",").map(Number); } }
|
|
5414
|
+
const max = Math.max(...values, 1);
|
|
5415
|
+
const plot = document.createElement("div");
|
|
5416
|
+
plot.className = "c-time-series__plot";
|
|
5417
|
+
plot.setAttribute("part", "plot");
|
|
5418
|
+
values.forEach((v) => {
|
|
5419
|
+
const bar = document.createElement("div");
|
|
5420
|
+
bar.className = "c-time-series__bar";
|
|
5421
|
+
bar.style.blockSize = ((v / max) * 100) + "%";
|
|
5422
|
+
bar.setAttribute("title", String(v));
|
|
5423
|
+
plot.appendChild(bar);
|
|
5424
|
+
});
|
|
5425
|
+
this.appendChild(plot);
|
|
5426
|
+
if (!values.length) renderEmpty(this, "time-series");
|
|
5427
|
+
}
|
|
5428
|
+
enhance() {}
|
|
5429
|
+
}
|
|
5430
|
+
define("contour-time-series", ContourTimeSeries);
|
|
5431
|
+
class ContourPivot extends ContourBase {
|
|
5432
|
+
static get observed() { return ["rows", "columns", "values", "data", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton"]; }
|
|
5433
|
+
static get properties() { return { rows: { attribute: "rows" }, columns: { attribute: "columns" }, values: { attribute: "values" }, data: { attribute: "data" }, src: { attribute: "src" } }; }
|
|
5434
|
+
render() {
|
|
5435
|
+
this.classList.add("c-pivot");
|
|
5436
|
+
wireStates(this);
|
|
5437
|
+
loadRemote(this, ["data"]);
|
|
5438
|
+
if (renderStates(this, "pivot")) return;
|
|
5439
|
+
Array.from(this.querySelectorAll("table")).forEach((n) => n.remove());
|
|
5440
|
+
let data = [];
|
|
5441
|
+
const dAttr = this.getAttribute("data");
|
|
5442
|
+
if (dAttr) { try { data = JSON.parse(dAttr); } catch (e) { data = []; } }
|
|
5443
|
+
const rows = this.getAttribute("rows") ? this.getAttribute("rows").split(",") : [];
|
|
5444
|
+
const cols = this.getAttribute("columns") ? this.getAttribute("columns").split(",") : [];
|
|
5445
|
+
const table = document.createElement("table");
|
|
5446
|
+
const thead = document.createElement("thead");
|
|
5447
|
+
const hr = document.createElement("tr");
|
|
5448
|
+
const corner = document.createElement("th");
|
|
5449
|
+
corner.textContent = "";
|
|
5450
|
+
hr.appendChild(corner);
|
|
5451
|
+
cols.forEach((c) => { const th = document.createElement("th"); th.textContent = c.trim(); hr.appendChild(th); });
|
|
5452
|
+
thead.appendChild(hr);
|
|
5453
|
+
table.appendChild(thead);
|
|
5454
|
+
const tbody = document.createElement("tbody");
|
|
5455
|
+
rows.forEach((r) => {
|
|
5456
|
+
const tr = document.createElement("tr");
|
|
5457
|
+
const th = document.createElement("th");
|
|
5458
|
+
th.textContent = r.trim();
|
|
5459
|
+
tr.appendChild(th);
|
|
5460
|
+
cols.forEach((c) => {
|
|
5461
|
+
const td = document.createElement("td");
|
|
5462
|
+
const cell = data.find((d) => d.row === r.trim() && d.col === c.trim());
|
|
5463
|
+
td.textContent = cell ? String(cell.value) : "";
|
|
5464
|
+
tr.appendChild(td);
|
|
5465
|
+
});
|
|
5466
|
+
tbody.appendChild(tr);
|
|
5467
|
+
});
|
|
5468
|
+
table.appendChild(tbody);
|
|
5469
|
+
this.appendChild(table);
|
|
5470
|
+
if (!data.length && !rows.length) renderEmpty(this, "pivot");
|
|
5471
|
+
}
|
|
5472
|
+
enhance() {}
|
|
5473
|
+
}
|
|
5474
|
+
define("contour-pivot", ContourPivot);
|
|
5475
|
+
class ContourWidgetState extends ContourBase {
|
|
5476
|
+
static get observed() { return ["loading", "error", "empty", "retry", "src", "lazy", "refresh", "timeout", "skeleton"]; }
|
|
5477
|
+
static get properties() { return { loading: { attribute: "loading" }, error: { attribute: "error" }, empty: { attribute: "empty" }, retry: { attribute: "retry" }, src: { attribute: "src" } }; }
|
|
5478
|
+
render() {
|
|
5479
|
+
this.classList.add("c-widget-state");
|
|
5480
|
+
wireStates(this);
|
|
5481
|
+
loadRemote(this, []);
|
|
5482
|
+
if (renderStates(this, "widget-state")) return;
|
|
5483
|
+
// if no state, render slotted content (already in DOM)
|
|
5484
|
+
}
|
|
5485
|
+
enhance() {}
|
|
5486
|
+
}
|
|
5487
|
+
define("contour-widget-state", ContourWidgetState);
|
|
5488
|
+
class ContourBrownout extends ContourBase {
|
|
5489
|
+
static get observed() { return ["level"]; }
|
|
5490
|
+
static get properties() { return { level: { attribute: "level" } }; }
|
|
5491
|
+
render() {
|
|
5492
|
+
this.classList.add("c-brownout");
|
|
5493
|
+
const level = this.getAttribute("level") || "0";
|
|
5494
|
+
this.dataset.level = level;
|
|
5495
|
+
this.setAttribute("data-level", level);
|
|
5496
|
+
}
|
|
5497
|
+
enhance() {}
|
|
5498
|
+
}
|
|
5499
|
+
define("contour-brownout", ContourBrownout);
|
|
4933
5500
|
class ContourInstrument extends ContourBase {
|
|
4934
5501
|
static get observed() { return ["rows", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton"]; }
|
|
4935
5502
|
static get properties() { return { rows: { attribute: "rows" }, src: { attribute: "src" } }; }
|
|
@@ -4964,21 +5531,31 @@ class ContourInstrument extends ContourBase {
|
|
|
4964
5531
|
}
|
|
4965
5532
|
define("contour-instrument", ContourInstrument);
|
|
4966
5533
|
class ContourBivariate extends ContourBase {
|
|
4967
|
-
static get observed() { return ["size", "axis-x", "axis-y"]; }
|
|
4968
|
-
static get properties() { return { size: { attribute: "size" }, axisX: { attribute: "axis-x" }, axisY: { attribute: "axis-y" } }; }
|
|
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" } }; }
|
|
4969
5536
|
render() {
|
|
4970
5537
|
this.classList.add("c-bivariate");
|
|
4971
5538
|
const size = Math.min(12, Math.max(1, parseInt(this.getAttribute("size") || "3", 10) || 3));
|
|
4972
5539
|
const matrix = this.ensure(".c-bivariate__matrix", () => { const el = document.createElement("div"); el.className = "c-bivariate__matrix"; return el; });
|
|
4973
5540
|
matrix.style.gridTemplateColumns = `repeat(${size}, 1fr)`;
|
|
5541
|
+
matrix.style.gridTemplateRows = `repeat(${size}, 1fr)`;
|
|
4974
5542
|
// Slot composition: authored cells win over the generated grid.
|
|
4975
5543
|
const authored = Array.from(matrix.children).filter((n) => n.classList && n.classList.contains("c-bivariate__cell"));
|
|
4976
5544
|
if (!authored.length) {
|
|
4977
5545
|
matrix.innerHTML = "";
|
|
4978
|
-
|
|
4979
|
-
|
|
4980
|
-
|
|
4981
|
-
|
|
5546
|
+
let colors = [];
|
|
5547
|
+
const cAttr = this.getAttribute("colors");
|
|
5548
|
+
if (cAttr) { try { colors = JSON.parse(cAttr); } catch (e) { colors = []; } }
|
|
5549
|
+
for (let r = 0; r < size; r++) {
|
|
5550
|
+
for (let c = 0; c < size; c++) {
|
|
5551
|
+
const cell = document.createElement("div");
|
|
5552
|
+
cell.className = "c-bivariate__cell";
|
|
5553
|
+
// Palette runs from bottom-left (low/low) to top-right (high/high):
|
|
5554
|
+
// reverse the row order so the first palette row sits at the bottom.
|
|
5555
|
+
const srcIndex = (size - 1 - r) * size + c;
|
|
5556
|
+
if (colors[srcIndex]) cell.style.background = colors[srcIndex];
|
|
5557
|
+
matrix.appendChild(cell);
|
|
5558
|
+
}
|
|
4982
5559
|
}
|
|
4983
5560
|
}
|
|
4984
5561
|
const axisX = this.getAttribute("axis-x");
|
|
@@ -5000,6 +5577,49 @@ class ContourBivariate extends ContourBase {
|
|
|
5000
5577
|
}
|
|
5001
5578
|
}
|
|
5002
5579
|
define("contour-bivariate", ContourBivariate);
|
|
5580
|
+
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" } }; }
|
|
5583
|
+
render() {
|
|
5584
|
+
this.classList.add("c-bivariate-legend");
|
|
5585
|
+
const size = Math.min(8, Math.max(1, parseInt(this.getAttribute("size") || "3", 10) || 3));
|
|
5586
|
+
const matrix = this.ensure(".c-bivariate-legend__matrix", () => { const el = document.createElement("div"); el.className = "c-bivariate-legend__matrix"; return el; });
|
|
5587
|
+
matrix.style.gridTemplateColumns = `repeat(${size}, 1fr)`;
|
|
5588
|
+
// Slotted content support: authored cells win over the generated grid.
|
|
5589
|
+
const authored = Array.from(matrix.children).filter((n) => n.classList && n.classList.contains("c-bivariate-legend__cell"));
|
|
5590
|
+
if (!authored.length) {
|
|
5591
|
+
matrix.innerHTML = "";
|
|
5592
|
+
let colors = [];
|
|
5593
|
+
const cAttr = this.getAttribute("colors");
|
|
5594
|
+
if (cAttr) { try { colors = JSON.parse(cAttr); } catch (e) { colors = []; } }
|
|
5595
|
+
for (let i = 0; i < size * size; i++) {
|
|
5596
|
+
const cell = document.createElement("div");
|
|
5597
|
+
cell.className = "c-bivariate-legend__cell";
|
|
5598
|
+
if (colors[i]) cell.style.background = colors[i];
|
|
5599
|
+
else cell.style.background = "var(--chart-" + ((i % 8) + 1) + ")";
|
|
5600
|
+
matrix.appendChild(cell);
|
|
5601
|
+
}
|
|
5602
|
+
}
|
|
5603
|
+
const axisX = this.getAttribute("axis-x");
|
|
5604
|
+
const ax = this.querySelector(".c-bivariate-legend__axis--x");
|
|
5605
|
+
if (axisX) {
|
|
5606
|
+
const el = ax || this.ensure(".c-bivariate-legend__axis--x", () => { const e = document.createElement("div"); e.className = "c-bivariate-legend__axis c-bivariate-legend__axis--x"; return e; });
|
|
5607
|
+
el.textContent = axisX;
|
|
5608
|
+
} else if (ax) {
|
|
5609
|
+
ax.remove();
|
|
5610
|
+
}
|
|
5611
|
+
const axisY = this.getAttribute("axis-y");
|
|
5612
|
+
const ay = this.querySelector(".c-bivariate-legend__axis--y");
|
|
5613
|
+
if (axisY) {
|
|
5614
|
+
const el = ay || this.ensure(".c-bivariate-legend__axis--y", () => { const e = document.createElement("div"); e.className = "c-bivariate-legend__axis c-bivariate-legend__axis--y"; return e; });
|
|
5615
|
+
el.textContent = axisY;
|
|
5616
|
+
} else if (ay) {
|
|
5617
|
+
ay.remove();
|
|
5618
|
+
}
|
|
5619
|
+
}
|
|
5620
|
+
enhance() {}
|
|
5621
|
+
}
|
|
5622
|
+
define("contour-bivariate-legend", ContourBivariateLegend);
|
|
5003
5623
|
class ContourSurvey extends ContourBase {
|
|
5004
5624
|
static get observed() { return ["date", "instrument", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton"]; }
|
|
5005
5625
|
static get properties() { return { date: { attribute: "date" }, instrument: { attribute: "instrument" }, src: { attribute: "src" } }; }
|
|
@@ -5109,7 +5729,7 @@ class ContourMetricsFull extends ContourBase {
|
|
|
5109
5729
|
}
|
|
5110
5730
|
define("contour-metrics", ContourMetricsFull);
|
|
5111
5731
|
class ContourLegend extends ContourBase {
|
|
5112
|
-
static get observed() { return ["title", "ramp", "scale", "items", "method", "norm", "selectable", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton"]; }
|
|
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"]; }
|
|
5113
5733
|
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" } }; }
|
|
5114
5734
|
render() {
|
|
5115
5735
|
this.classList.add("c-legend");
|
|
@@ -5148,6 +5768,22 @@ class ContourLegend extends ContourBase {
|
|
|
5148
5768
|
sw.className = "c-legend__swatch";
|
|
5149
5769
|
if (it && it.color) sw.style.background = it.color;
|
|
5150
5770
|
item.appendChild(sw);
|
|
5771
|
+
// geometry glyph
|
|
5772
|
+
const glyphShape = (it && (it.shape || it.marker || it.glyph)) || this.getAttribute("glyphs");
|
|
5773
|
+
if (glyphShape) {
|
|
5774
|
+
const g = document.createElement("span");
|
|
5775
|
+
g.className = "c-legend__glyph";
|
|
5776
|
+
g.setAttribute("part", "glyph");
|
|
5777
|
+
g.textContent = glyphShape === "circle" ? "●" : glyphShape === "square" ? "■" : glyphShape === "triangle" ? "▲" : glyphShape === "diamond" ? "◆" : glyphShape === "star" ? "★" : String(glyphShape);
|
|
5778
|
+
item.appendChild(g);
|
|
5779
|
+
}
|
|
5780
|
+
// threshold break marker
|
|
5781
|
+
if (it && it.break != null) {
|
|
5782
|
+
const b = document.createElement("span");
|
|
5783
|
+
b.className = "c-legend__break";
|
|
5784
|
+
b.textContent = String(it.break);
|
|
5785
|
+
item.appendChild(b);
|
|
5786
|
+
}
|
|
5151
5787
|
const lbl = document.createElement("span");
|
|
5152
5788
|
lbl.textContent = label;
|
|
5153
5789
|
item.appendChild(lbl);
|
|
@@ -5198,10 +5834,6 @@ class ContourLegend extends ContourBase {
|
|
|
5198
5834
|
enhance() {
|
|
5199
5835
|
if (this._wiredLegend) return;
|
|
5200
5836
|
this._wiredLegend = true;
|
|
5201
|
-
// Host-delegated (rule 12): the item buttons are rebuilt by every
|
|
5202
|
-
// render, so the handler re-queries per click. The gate-visible name is
|
|
5203
|
-
// `contour:legend-toggle` — the plan's `contour:legend:toggle` carries a
|
|
5204
|
-
// colon inside the name, which the check-wc manifest regex cannot see.
|
|
5205
5837
|
this.addEventListener("click", (e) => {
|
|
5206
5838
|
const btn = e.target && e.target.closest ? e.target.closest(".c-legend__item") : null;
|
|
5207
5839
|
if (!btn || !this.contains(btn)) return;
|
|
@@ -5212,6 +5844,44 @@ class ContourLegend extends ContourBase {
|
|
|
5212
5844
|
bubbles: true,
|
|
5213
5845
|
composed: true,
|
|
5214
5846
|
}));
|
|
5847
|
+
this.dispatchEvent(new CustomEvent("contour:select", {
|
|
5848
|
+
detail: { label: btn.textContent.trim(), key: btn.dataset.key || btn.textContent.trim(), value: btn.dataset.key || btn.textContent.trim() },
|
|
5849
|
+
bubbles: true,
|
|
5850
|
+
composed: true,
|
|
5851
|
+
}));
|
|
5852
|
+
});
|
|
5853
|
+
// emit style-resolved once on enhance
|
|
5854
|
+
try {
|
|
5855
|
+
let parsed = null;
|
|
5856
|
+
try { parsed = JSON.parse(this.getAttribute("items") || "null"); } catch (e) { parsed = this.getAttribute("items"); }
|
|
5857
|
+
this.dispatchEvent(new CustomEvent("contour:style-resolved", { detail: { value: this.getAttribute("items"), items: parsed }, bubbles: true, composed: true }));
|
|
5858
|
+
} catch (e) {}
|
|
5859
|
+
// break-change delegated
|
|
5860
|
+
this.addEventListener("change", (e) => {
|
|
5861
|
+
const t = e.target;
|
|
5862
|
+
if (t && t.classList && t.classList.contains("c-legend__break-input")) {
|
|
5863
|
+
this.dispatchEvent(new CustomEvent("contour:break-change", { detail: { value: t.value }, bubbles: true, composed: true }));
|
|
5864
|
+
}
|
|
5865
|
+
});
|
|
5866
|
+
// keyboard nav (listbox)
|
|
5867
|
+
this.addEventListener("keydown", (e) => {
|
|
5868
|
+
const items = Array.from(this.querySelectorAll(".c-legend__item"));
|
|
5869
|
+
if (!items.length) return;
|
|
5870
|
+
const idx = items.indexOf(document.activeElement);
|
|
5871
|
+
if (e.key === "ArrowDown" || e.key === "ArrowRight") {
|
|
5872
|
+
e.preventDefault();
|
|
5873
|
+
const next = items[(idx + 1) % items.length];
|
|
5874
|
+
if (next) next.focus();
|
|
5875
|
+
} else if (e.key === "ArrowUp" || e.key === "ArrowLeft") {
|
|
5876
|
+
e.preventDefault();
|
|
5877
|
+
const prev = items[(idx - 1 + items.length) % items.length];
|
|
5878
|
+
if (prev) prev.focus();
|
|
5879
|
+
} else if (e.key === "Enter" || e.key === " ") {
|
|
5880
|
+
e.preventDefault();
|
|
5881
|
+
if (document.activeElement && document.activeElement.classList.contains("c-legend__item")) {
|
|
5882
|
+
document.activeElement.click();
|
|
5883
|
+
}
|
|
5884
|
+
}
|
|
5215
5885
|
});
|
|
5216
5886
|
}
|
|
5217
5887
|
}
|
|
@@ -5246,6 +5916,12 @@ class ContourMeasure extends ContourBase {
|
|
|
5246
5916
|
const r = this.querySelector(".c-measure__readout");
|
|
5247
5917
|
if (r) r.remove();
|
|
5248
5918
|
}
|
|
5919
|
+
// unit selector
|
|
5920
|
+
let sel = this.querySelector(".c-measure__unit-select");
|
|
5921
|
+
if (!sel) { sel = document.createElement("select"); sel.className = "c-measure__unit-select"; this.appendChild(sel); }
|
|
5922
|
+
["m","km","mi","ft"].forEach((u) => {
|
|
5923
|
+
if (!sel.querySelector('option[value="' + u + '"]')) { const o = document.createElement("option"); o.value = u; o.textContent = u; sel.appendChild(o); }
|
|
5924
|
+
});
|
|
5249
5925
|
if (rPoint) {
|
|
5250
5926
|
const p = this.ensure(".c-measure__point", () => { const el = document.createElement("span"); el.className = "c-measure__point"; return el; });
|
|
5251
5927
|
p.textContent = rPoint;
|
|
@@ -5325,12 +6001,20 @@ class ContourHeatmap extends ContourBase {
|
|
|
5325
6001
|
wireStates(this);
|
|
5326
6002
|
loadRemote(this, "cells");
|
|
5327
6003
|
if (renderStates(this, "heatmap")) return;
|
|
5328
|
-
|
|
5329
|
-
|
|
5330
|
-
const
|
|
5331
|
-
|
|
5332
|
-
|
|
5333
|
-
|
|
6004
|
+
// Slotted content support: authored .c-heatmap__cell children take
|
|
6005
|
+
// precedence over the generated grid.
|
|
6006
|
+
const authoredCells = Array.from(this.querySelectorAll(":scope > .c-heatmap__cell"));
|
|
6007
|
+
if (authoredCells.length) {
|
|
6008
|
+
const cols = Math.ceil(Math.sqrt(authoredCells.length));
|
|
6009
|
+
this.style.gridTemplateColumns = "repeat(" + cols + ", 1fr)";
|
|
6010
|
+
this.style.inlineSize = "16rem";
|
|
6011
|
+
} else {
|
|
6012
|
+
Array.from(this.querySelectorAll(".c-heatmap__cell")).forEach((n) => n.remove());
|
|
6013
|
+
const count = Math.min(200, Math.max(0, parseInt(this.getAttribute("cells") || this.getAttribute("count") || "0", 10) || 0));
|
|
6014
|
+
const cols = count > 0 ? Math.ceil(Math.sqrt(count)) : 1;
|
|
6015
|
+
this.style.gridTemplateColumns = "repeat(" + cols + ", 1fr)";
|
|
6016
|
+
this.style.inlineSize = "16rem";
|
|
6017
|
+
if (count > 0) {
|
|
5334
6018
|
let values = [];
|
|
5335
6019
|
try { values = JSON.parse(this.getAttribute("values") || "[]"); } catch (e) { values = []; }
|
|
5336
6020
|
for (let i = 0; i < count; i++) {
|
|
@@ -5344,9 +6028,10 @@ class ContourHeatmap extends ContourBase {
|
|
|
5344
6028
|
}
|
|
5345
6029
|
const tip = this.ensure(".c-heatmap__tooltip", () => { const el = document.createElement("div"); el.className = "c-heatmap__tooltip"; el.setAttribute("role", "tooltip"); el.setAttribute("hidden", ""); return el; });
|
|
5346
6030
|
tip.setAttribute("hidden", "");
|
|
5347
|
-
} else {
|
|
6031
|
+
} else if (!authoredCells.length) {
|
|
5348
6032
|
renderEmpty(this, "heatmap");
|
|
5349
6033
|
}
|
|
6034
|
+
}
|
|
5350
6035
|
if (this.hasAttribute("legend")) {
|
|
5351
6036
|
const leg = this.ensure(".c-heatmap__legend", () => {
|
|
5352
6037
|
const el = document.createElement("div");
|
|
@@ -7751,7 +8436,7 @@ class ContourResizable extends ContourBase {
|
|
|
7751
8436
|
this.appendChild(handle);
|
|
7752
8437
|
this.appendChild(p2);
|
|
7753
8438
|
}
|
|
7754
|
-
const v = this.getAttribute("value");
|
|
8439
|
+
const v = this._splitValue || this.getAttribute("value");
|
|
7755
8440
|
if (v) {
|
|
7756
8441
|
const p1 = this.querySelector(".c-resizable__pane");
|
|
7757
8442
|
if (p1) p1.style.flex = `0 0 ${v}%`;
|
|
@@ -7772,7 +8457,7 @@ class ContourResizable extends ContourBase {
|
|
|
7772
8457
|
const frac = span > 0 ? Math.min(0.9, Math.max(0.1, pos / span)) : 0.5;
|
|
7773
8458
|
const p1 = this.querySelector(".c-resizable__pane");
|
|
7774
8459
|
if (p1) p1.style.flex = `0 0 ${Math.round(frac * 100)}%`;
|
|
7775
|
-
this.
|
|
8460
|
+
this._splitValue = String(Math.round(frac * 100));
|
|
7776
8461
|
};
|
|
7777
8462
|
this.addEventListener("pointerdown", (e) => {
|
|
7778
8463
|
const handle = this.querySelector(".c-resize-handle");
|
|
@@ -7789,6 +8474,7 @@ class ContourResizable extends ContourBase {
|
|
|
7789
8474
|
const stopResize = (e) => {
|
|
7790
8475
|
if (!this._resizing) return;
|
|
7791
8476
|
this._resizing = false;
|
|
8477
|
+
if (this._splitValue) { this.setAttribute("value", this._splitValue); this._splitValue = null; }
|
|
7792
8478
|
const handle = this.querySelector(".c-resize-handle");
|
|
7793
8479
|
if (handle) {
|
|
7794
8480
|
handle.classList.remove("c-resize-handle--dragging");
|
|
@@ -8147,6 +8833,22 @@ class ContourMinimap extends ContourBase {
|
|
|
8147
8833
|
if (v) v.remove();
|
|
8148
8834
|
}
|
|
8149
8835
|
}
|
|
8836
|
+
enhance() {
|
|
8837
|
+
if (this._wiredMinimap) return;
|
|
8838
|
+
this._wiredMinimap = true;
|
|
8839
|
+
let dragging = false;
|
|
8840
|
+
this.addEventListener("pointerdown", (e) => {
|
|
8841
|
+
const vp = this.querySelector(".c-minimap__viewport");
|
|
8842
|
+
if (!vp || !vp.contains(e.target)) return;
|
|
8843
|
+
dragging = true;
|
|
8844
|
+
try { vp.setPointerCapture(e.pointerId); } catch (err) {}
|
|
8845
|
+
});
|
|
8846
|
+
this.addEventListener("pointermove", (e) => {
|
|
8847
|
+
if (!dragging) return;
|
|
8848
|
+
this.dispatchEvent(new CustomEvent("contour:move", { detail: { direction: "drag" }, bubbles: true, composed: true }));
|
|
8849
|
+
});
|
|
8850
|
+
this.addEventListener("pointerup", () => { dragging = false; });
|
|
8851
|
+
}
|
|
8150
8852
|
}
|
|
8151
8853
|
define("contour-minimap", ContourMinimap);
|
|
8152
8854
|
class ContourCoordinate extends ContourBase {
|
|
@@ -8162,8 +8864,57 @@ class ContourCoordinate extends ContourBase {
|
|
|
8162
8864
|
renderEmpty(this, "coordinate");
|
|
8163
8865
|
return;
|
|
8164
8866
|
}
|
|
8867
|
+
const format = this.getAttribute("format") || "decimal";
|
|
8868
|
+
let text = String(value);
|
|
8869
|
+
if (format === "dms") {
|
|
8870
|
+
// simple DMS conversion assuming decimal degrees "lat,lon"
|
|
8871
|
+
const parts = String(value).split(/[,\s]+/).map(Number);
|
|
8872
|
+
if (parts.length >= 2 && Number.isFinite(parts[0]) && Number.isFinite(parts[1])) {
|
|
8873
|
+
const toDMS = (d) => {
|
|
8874
|
+
const deg = Math.floor(Math.abs(d));
|
|
8875
|
+
const min = Math.floor((Math.abs(d) - deg) * 60);
|
|
8876
|
+
const sec = (((Math.abs(d) - deg) * 60) - min) * 60;
|
|
8877
|
+
return deg + "°" + min + "'" + sec.toFixed(1) + '"' + (d < 0 ? "S" : "N");
|
|
8878
|
+
};
|
|
8879
|
+
text = toDMS(parts[0]) + " " + toDMS(parts[1]);
|
|
8880
|
+
}
|
|
8881
|
+
} else if (format === "web-mercator") {
|
|
8882
|
+
const parts = String(value).split(/[,\s]+/).map(Number);
|
|
8883
|
+
if (parts.length >= 2 && Number.isFinite(parts[0]) && Number.isFinite(parts[1])) {
|
|
8884
|
+
const x = parts[1] * 20037508.34 / 180;
|
|
8885
|
+
const y = Math.log(Math.tan((90 + parts[0]) * Math.PI / 360)) / (Math.PI / 180) * 20037508.34 / 180;
|
|
8886
|
+
text = x.toFixed(2) + ", " + y.toFixed(2);
|
|
8887
|
+
}
|
|
8888
|
+
} else {
|
|
8889
|
+
text = formatValue(value, this.getAttribute("format"), this.getAttribute("locale"));
|
|
8890
|
+
}
|
|
8165
8891
|
const span = this.ensure(".c-coordinate__value", () => { const el = document.createElement("span"); el.className = "c-coordinate__value"; return el; });
|
|
8166
|
-
span.textContent =
|
|
8892
|
+
span.textContent = text;
|
|
8893
|
+
// copy button
|
|
8894
|
+
let btn = this.querySelector(".c-coordinate__copy");
|
|
8895
|
+
if (!btn) { btn = document.createElement("button"); btn.type = "button"; btn.className = "c-coordinate__copy"; btn.textContent = "Copy"; btn.setAttribute("aria-label", "Copy coordinate"); this.appendChild(btn); }
|
|
8896
|
+
btn.onclick = () => {
|
|
8897
|
+
try {
|
|
8898
|
+
if (navigator.clipboard && navigator.clipboard.writeText) {
|
|
8899
|
+
navigator.clipboard.writeText(text).catch(() => { fallbackCopy(text); });
|
|
8900
|
+
} else {
|
|
8901
|
+
fallbackCopy(text);
|
|
8902
|
+
}
|
|
8903
|
+
} catch (e) { fallbackCopy(text); }
|
|
8904
|
+
this.dispatchEvent(new CustomEvent("contour:copy", { detail: { text }, bubbles: true, composed: true }));
|
|
8905
|
+
};
|
|
8906
|
+
function fallbackCopy(t) {
|
|
8907
|
+
try {
|
|
8908
|
+
const ta = document.createElement("textarea");
|
|
8909
|
+
ta.value = t;
|
|
8910
|
+
ta.style.position = "fixed";
|
|
8911
|
+
ta.style.opacity = "0";
|
|
8912
|
+
document.body.appendChild(ta);
|
|
8913
|
+
ta.select();
|
|
8914
|
+
document.execCommand("copy");
|
|
8915
|
+
document.body.removeChild(ta);
|
|
8916
|
+
} catch (e) {}
|
|
8917
|
+
}
|
|
8167
8918
|
}
|
|
8168
8919
|
}
|
|
8169
8920
|
define("contour-coordinate", ContourCoordinate);
|
|
@@ -8184,19 +8935,32 @@ class ContourLayerPanel extends ContourBase {
|
|
|
8184
8935
|
const l = this.querySelector(".c-layer-panel__label");
|
|
8185
8936
|
if (l) l.remove();
|
|
8186
8937
|
}
|
|
8187
|
-
|
|
8938
|
+
// Slotted content support: authored .c-layer-panel__item children take
|
|
8939
|
+
// precedence over the JSON `items` attribute.
|
|
8940
|
+
const authoredLayerItems = Array.from(this.querySelectorAll(":scope > .c-layer-panel__item"));
|
|
8941
|
+
// Preserve user-toggled visibility across re-renders (B3-09): a src
|
|
8942
|
+
// reload must not re-check a layer the user un-checked.
|
|
8943
|
+
const savedVisibility = new Map();
|
|
8944
|
+
this.querySelectorAll(".c-layer-panel__item").forEach((el) => {
|
|
8945
|
+
const nm = el.querySelector(".c-layer-panel__name");
|
|
8946
|
+
const tg = el.querySelector(".c-layer-panel__toggle");
|
|
8947
|
+
if (nm && tg) savedVisibility.set(nm.textContent, tg.checked);
|
|
8948
|
+
});
|
|
8949
|
+
let parsed = null;
|
|
8950
|
+
if (authoredLayerItems.length) {
|
|
8951
|
+
parsed = authoredLayerItems.map((el) => {
|
|
8952
|
+
const nm = el.querySelector(".c-layer-panel__name");
|
|
8953
|
+
const tg = el.querySelector(".c-layer-panel__toggle");
|
|
8954
|
+
return { name: nm ? nm.textContent : "", visible: tg ? tg.checked : true };
|
|
8955
|
+
});
|
|
8956
|
+
authoredLayerItems.forEach((el) => el.remove());
|
|
8957
|
+
} else if (items) {
|
|
8188
8958
|
try {
|
|
8189
|
-
|
|
8190
|
-
// Preserve user-toggled visibility across re-renders (B3-09): a src
|
|
8191
|
-
// reload must not re-check a layer the user un-checked.
|
|
8192
|
-
const savedVisibility = new Map();
|
|
8193
|
-
this.querySelectorAll(".c-layer-panel__item").forEach((el) => {
|
|
8194
|
-
const nm = el.querySelector(".c-layer-panel__name");
|
|
8195
|
-
const tg = el.querySelector(".c-layer-panel__toggle");
|
|
8196
|
-
if (nm && tg) savedVisibility.set(nm.textContent, tg.checked);
|
|
8197
|
-
});
|
|
8959
|
+
parsed = JSON.parse(items);
|
|
8198
8960
|
Array.from(this.querySelectorAll(".c-layer-panel__item")).forEach((el) => el.remove());
|
|
8199
|
-
|
|
8961
|
+
} catch (e) { /* keep existing */ }
|
|
8962
|
+
}
|
|
8963
|
+
if (parsed) { parsed.forEach((it) => {
|
|
8200
8964
|
const name = typeof it === "string" ? it : (it.name || it.label || "");
|
|
8201
8965
|
const item = document.createElement("div");
|
|
8202
8966
|
item.className = "c-layer-panel__item" + (it.dragging ? " c-layer-panel__item--dragging" : "");
|
|
@@ -8219,10 +8983,34 @@ class ContourLayerPanel extends ContourBase {
|
|
|
8219
8983
|
opacity.setAttribute("aria-label", "Opacity of " + (name || "layer"));
|
|
8220
8984
|
opacity.value = (typeof it === "object" && it.opacity != null) ? it.opacity : "100";
|
|
8221
8985
|
item.appendChild(opacity);
|
|
8986
|
+
// rename input (hidden by default, toggled via button)
|
|
8987
|
+
const renameBtn = document.createElement("button");
|
|
8988
|
+
renameBtn.type = "button";
|
|
8989
|
+
renameBtn.className = "c-layer-panel__rename";
|
|
8990
|
+
renameBtn.textContent = "Rename";
|
|
8991
|
+
renameBtn.setAttribute("aria-label", "Rename " + (name || "layer"));
|
|
8992
|
+
item.appendChild(renameBtn);
|
|
8993
|
+
const dupBtn = document.createElement("button");
|
|
8994
|
+
dupBtn.type = "button";
|
|
8995
|
+
dupBtn.className = "c-layer-panel__duplicate";
|
|
8996
|
+
dupBtn.textContent = "Duplicate";
|
|
8997
|
+
dupBtn.setAttribute("aria-label", "Duplicate " + (name || "layer"));
|
|
8998
|
+
item.appendChild(dupBtn);
|
|
8999
|
+
const zoomBtn = document.createElement("button");
|
|
9000
|
+
zoomBtn.type = "button";
|
|
9001
|
+
zoomBtn.className = "c-layer-panel__zoom";
|
|
9002
|
+
zoomBtn.textContent = "Zoom";
|
|
9003
|
+
zoomBtn.setAttribute("aria-label", "Zoom to " + (name || "layer"));
|
|
9004
|
+
item.appendChild(zoomBtn);
|
|
9005
|
+
const projSel = document.createElement("select");
|
|
9006
|
+
projSel.className = "c-layer-panel__projection";
|
|
9007
|
+
projSel.setAttribute("aria-label", "Projection of " + (name || "layer"));
|
|
9008
|
+
["EPSG:4326","EPSG:3857"].forEach((p) => { const o = document.createElement("option"); o.value = p; o.textContent = p; projSel.appendChild(o); });
|
|
9009
|
+
item.appendChild(projSel);
|
|
8222
9010
|
this.appendChild(item);
|
|
8223
9011
|
});
|
|
8224
|
-
|
|
8225
|
-
|
|
9012
|
+
}
|
|
9013
|
+
if (!parsed && !authoredLayerItems.length && !items) {
|
|
8226
9014
|
Array.from(this.querySelectorAll(".c-layer-panel__item")).forEach((el) => el.remove());
|
|
8227
9015
|
renderEmpty(this, "layer-panel");
|
|
8228
9016
|
}
|
|
@@ -8240,13 +9028,35 @@ class ContourLayerPanel extends ContourBase {
|
|
|
8240
9028
|
this.dispatchEvent(new CustomEvent("contour:layer-visibility", { bubbles: true, composed: true, detail: { name, visible: e.target.checked } }));
|
|
8241
9029
|
} else if (e.target.classList.contains("c-layer-panel__opacity")) {
|
|
8242
9030
|
this.dispatchEvent(new CustomEvent("contour:layer-opacity", { bubbles: true, composed: true, detail: { name, opacity: Number(e.target.value) } }));
|
|
9031
|
+
} else if (e.target.classList.contains("c-layer-panel__projection")) {
|
|
9032
|
+
this.dispatchEvent(new CustomEvent("contour:layer-projection", { bubbles: true, composed: true, detail: { name, projection: e.target.value } }));
|
|
9033
|
+
}
|
|
9034
|
+
});
|
|
9035
|
+
this.addEventListener("click", (e) => {
|
|
9036
|
+
const btn = e.target && e.target.closest ? e.target.closest("button") : null;
|
|
9037
|
+
if (!btn || !this.contains(btn)) return;
|
|
9038
|
+
const item = btn.closest(".c-layer-panel__item");
|
|
9039
|
+
if (!item) return;
|
|
9040
|
+
const name = item.querySelector(".c-layer-panel__name")?.textContent || "";
|
|
9041
|
+
if (btn.classList.contains("c-layer-panel__rename")) {
|
|
9042
|
+
const newName = prompt("Rename layer", name);
|
|
9043
|
+
const trimmed = newName ? newName.trim() : "";
|
|
9044
|
+
if (trimmed && trimmed !== name) {
|
|
9045
|
+
const nm = item.querySelector(".c-layer-panel__name");
|
|
9046
|
+
if (nm) nm.textContent = trimmed;
|
|
9047
|
+
this.dispatchEvent(new CustomEvent("contour:layer-rename", { bubbles: true, composed: true, detail: { name, newName: trimmed } }));
|
|
9048
|
+
}
|
|
9049
|
+
} else if (btn.classList.contains("c-layer-panel__duplicate")) {
|
|
9050
|
+
this.dispatchEvent(new CustomEvent("contour:layer-duplicate", { bubbles: true, composed: true, detail: { name } }));
|
|
9051
|
+
} else if (btn.classList.contains("c-layer-panel__zoom")) {
|
|
9052
|
+
this.dispatchEvent(new CustomEvent("contour:layer-zoom", { bubbles: true, composed: true, detail: { name } }));
|
|
8243
9053
|
}
|
|
8244
9054
|
});
|
|
8245
9055
|
}
|
|
8246
9056
|
}
|
|
8247
9057
|
define("contour-layer-panel", ContourLayerPanel);
|
|
8248
9058
|
class ContourTimeSlider extends ContourBase {
|
|
8249
|
-
static get observed() { return ["label", "value"]; }
|
|
9059
|
+
static get observed() { return ["label", "value", "loop", "speed"]; }
|
|
8250
9060
|
static get properties() { return { label: { attribute: "label" }, value: { attribute: "value" }, src: { attribute: "src" } }; }
|
|
8251
9061
|
render() {
|
|
8252
9062
|
this.classList.add("c-time-slider");
|
|
@@ -8287,10 +9097,15 @@ class ContourTimeSlider extends ContourBase {
|
|
|
8287
9097
|
const track = this.querySelector(".c-time-slider__track");
|
|
8288
9098
|
if (!track) { stop(); return; }
|
|
8289
9099
|
const max = Number(track.max) || 100;
|
|
8290
|
-
const
|
|
9100
|
+
const loop = this.hasAttribute("loop");
|
|
9101
|
+
let next = (Number(track.value) || 0) + 1;
|
|
9102
|
+
if (next > max) {
|
|
9103
|
+
if (loop) next = 0;
|
|
9104
|
+
else next = max;
|
|
9105
|
+
}
|
|
8291
9106
|
track.value = String(next);
|
|
8292
9107
|
this.dispatchEvent(new CustomEvent("contour:time-change", { detail: { value: String(next) }, bubbles: true, composed: true }));
|
|
8293
|
-
if (next >= max) {
|
|
9108
|
+
if (!loop && next >= max) {
|
|
8294
9109
|
stop();
|
|
8295
9110
|
const btn = this.querySelector(".c-time-slider__play");
|
|
8296
9111
|
if (btn) {
|
|
@@ -8311,13 +9126,19 @@ class ContourTimeSlider extends ContourBase {
|
|
|
8311
9126
|
if (use) use.setAttribute("href", playing ? "#i-pause" : "#i-play");
|
|
8312
9127
|
if (playing) {
|
|
8313
9128
|
stop();
|
|
8314
|
-
|
|
9129
|
+
const speed = parseFloat(this.getAttribute("speed") || "1") || 1;
|
|
9130
|
+
const delay = Math.max(100, 1000 / speed);
|
|
9131
|
+
timer = setInterval(step, delay);
|
|
8315
9132
|
} else {
|
|
8316
9133
|
stop();
|
|
8317
9134
|
}
|
|
8318
9135
|
});
|
|
8319
9136
|
onDispose(this, stop);
|
|
8320
9137
|
}
|
|
9138
|
+
disconnectedCallback() {
|
|
9139
|
+
super.disconnectedCallback();
|
|
9140
|
+
this._wiredTimeSlider = false;
|
|
9141
|
+
}
|
|
8321
9142
|
}
|
|
8322
9143
|
define("contour-time-slider", ContourTimeSlider);
|
|
8323
9144
|
class ContourHexbin extends ContourBase {
|
|
@@ -8338,9 +9159,18 @@ class ContourHexbin extends ContourBase {
|
|
|
8338
9159
|
if (renderStates(this, "hexbin")) return;
|
|
8339
9160
|
const cells = remoteData(this, "cells");
|
|
8340
9161
|
const effectiveCells = cells || (this._remoteData && this._remoteData.cells ? JSON.stringify(this._remoteData.cells) : null);
|
|
8341
|
-
|
|
9162
|
+
// Slotted content support: authored .c-hexbin__cell children take
|
|
9163
|
+
// precedence over the JSON `cells` attribute.
|
|
9164
|
+
const authoredCells = Array.from(this.querySelectorAll(":scope > .c-hexbin__cell"));
|
|
9165
|
+
let parsed = null;
|
|
9166
|
+
if (authoredCells.length) {
|
|
9167
|
+
parsed = authoredCells.map((el) => el.textContent || el.getAttribute("title") || "");
|
|
9168
|
+
authoredCells.forEach((el) => el.remove());
|
|
9169
|
+
} else if (effectiveCells) {
|
|
9170
|
+
try { parsed = JSON.parse(effectiveCells); } catch (e) { parsed = null; }
|
|
9171
|
+
}
|
|
9172
|
+
if (parsed) {
|
|
8342
9173
|
try {
|
|
8343
|
-
const parsed = JSON.parse(effectiveCells);
|
|
8344
9174
|
Array.from(this.querySelectorAll(".c-hexbin__cell")).forEach((n) => n.remove());
|
|
8345
9175
|
const cols = Math.ceil(Math.sqrt(parsed.length || 1));
|
|
8346
9176
|
this.style.gridTemplateColumns = "repeat(" + cols + ", 1fr)";
|
|
@@ -8356,7 +9186,7 @@ class ContourHexbin extends ContourBase {
|
|
|
8356
9186
|
const tip = this.ensure(".c-hexbin__tooltip", () => { const el = document.createElement("div"); el.className = "c-hexbin__tooltip"; el.setAttribute("role", "tooltip"); el.setAttribute("hidden", ""); return el; });
|
|
8357
9187
|
tip.setAttribute("hidden", "");
|
|
8358
9188
|
} catch (e) { /* keep existing */ }
|
|
8359
|
-
} else {
|
|
9189
|
+
} else if (!parsed) {
|
|
8360
9190
|
Array.from(this.querySelectorAll(".c-hexbin__cell")).forEach((n) => n.remove());
|
|
8361
9191
|
renderEmpty(this, "hexbin");
|
|
8362
9192
|
}
|
|
@@ -8386,9 +9216,18 @@ class ContourFlowMap extends ContourBase {
|
|
|
8386
9216
|
if (renderStates(this, "flow-map")) return;
|
|
8387
9217
|
const nodes = remoteData(this, "nodes");
|
|
8388
9218
|
const effectiveNodes = nodes || (this._remoteData && this._remoteData.nodes ? JSON.stringify(this._remoteData.nodes) : null);
|
|
8389
|
-
|
|
9219
|
+
// Slotted content support: authored .c-flow-map__node children take
|
|
9220
|
+
// precedence over the JSON `nodes` attribute.
|
|
9221
|
+
const authoredNodes = Array.from(this.querySelectorAll(":scope > .c-flow-map__node"));
|
|
9222
|
+
let parsed = null;
|
|
9223
|
+
if (authoredNodes.length) {
|
|
9224
|
+
parsed = authoredNodes.map((el) => el.textContent || el.getAttribute("title") || "");
|
|
9225
|
+
authoredNodes.forEach((el) => el.remove());
|
|
9226
|
+
} else if (effectiveNodes) {
|
|
9227
|
+
try { parsed = JSON.parse(effectiveNodes); } catch (e) { parsed = null; }
|
|
9228
|
+
}
|
|
9229
|
+
if (parsed) {
|
|
8390
9230
|
try {
|
|
8391
|
-
const parsed = JSON.parse(effectiveNodes);
|
|
8392
9231
|
Array.from(this.querySelectorAll(".c-flow-map__node")).forEach((n) => n.remove());
|
|
8393
9232
|
parsed.forEach((n, i) => {
|
|
8394
9233
|
const node = document.createElement("span");
|
|
@@ -8401,7 +9240,7 @@ class ContourFlowMap extends ContourBase {
|
|
|
8401
9240
|
const tip = this.ensure(".c-flow-map__tooltip", () => { const el = document.createElement("div"); el.className = "c-flow-map__tooltip"; el.setAttribute("role", "tooltip"); el.setAttribute("hidden", ""); return el; });
|
|
8402
9241
|
tip.setAttribute("hidden", "");
|
|
8403
9242
|
} catch (e) { /* keep existing */ }
|
|
8404
|
-
} else {
|
|
9243
|
+
} else if (!parsed) {
|
|
8405
9244
|
Array.from(this.querySelectorAll(".c-flow-map__node")).forEach((n) => n.remove());
|
|
8406
9245
|
renderEmpty(this, "flow-map");
|
|
8407
9246
|
}
|
|
@@ -8439,9 +9278,18 @@ class ContourIsochrone extends ContourBase {
|
|
|
8439
9278
|
if (renderStates(this, "isochrone")) return;
|
|
8440
9279
|
const rings = remoteData(this, "rings");
|
|
8441
9280
|
const effectiveRings = rings || (this._remoteData && this._remoteData.rings ? JSON.stringify(this._remoteData.rings) : null);
|
|
8442
|
-
|
|
9281
|
+
// Slotted content support: authored .c-isochrone__ring children take
|
|
9282
|
+
// precedence over the JSON `rings` attribute.
|
|
9283
|
+
const authoredRings = Array.from(this.querySelectorAll(":scope > .c-isochrone__ring"));
|
|
9284
|
+
let parsed = null;
|
|
9285
|
+
if (authoredRings.length) {
|
|
9286
|
+
parsed = authoredRings.map((el) => el.textContent || el.getAttribute("title") || "");
|
|
9287
|
+
authoredRings.forEach((el) => el.remove());
|
|
9288
|
+
} else if (effectiveRings) {
|
|
9289
|
+
try { parsed = JSON.parse(effectiveRings); } catch (e) { parsed = null; }
|
|
9290
|
+
}
|
|
9291
|
+
if (parsed) {
|
|
8443
9292
|
try {
|
|
8444
|
-
const parsed = JSON.parse(effectiveRings);
|
|
8445
9293
|
Array.from(this.querySelectorAll(".c-isochrone__ring")).forEach((n) => n.remove());
|
|
8446
9294
|
parsed.forEach((r, i) => {
|
|
8447
9295
|
const ring = document.createElement("span");
|
|
@@ -8453,7 +9301,7 @@ class ContourIsochrone extends ContourBase {
|
|
|
8453
9301
|
const tip = this.ensure(".c-isochrone__tooltip", () => { const el = document.createElement("div"); el.className = "c-isochrone__tooltip"; el.setAttribute("role", "tooltip"); el.setAttribute("hidden", ""); return el; });
|
|
8454
9302
|
tip.setAttribute("hidden", "");
|
|
8455
9303
|
} catch (e) { /* keep existing */ }
|
|
8456
|
-
} else {
|
|
9304
|
+
} else if (!parsed) {
|
|
8457
9305
|
Array.from(this.querySelectorAll(".c-isochrone__ring")).forEach((n) => n.remove());
|
|
8458
9306
|
renderEmpty(this, "isochrone");
|
|
8459
9307
|
}
|
|
@@ -11035,8 +11883,8 @@ class ContourStyleSwitcher extends ContourBase {
|
|
|
11035
11883
|
define("contour-style-switcher", ContourStyleSwitcher);
|
|
11036
11884
|
|
|
11037
11885
|
class ContourStylePanel extends ContourBase {
|
|
11038
|
-
static get observed() { return ["title", "layers"]; }
|
|
11039
|
-
static get properties() { return { title: { attribute: "title" }, layers: { attribute: "layers" } }; }
|
|
11886
|
+
static get observed() { return ["title", "layers", "classification", "palette", "breaks", "opacity"]; }
|
|
11887
|
+
static get properties() { return { title: { attribute: "title" }, layers: { attribute: "layers" }, classification: { attribute: "classification" }, palette: { attribute: "palette" }, breaks: { attribute: "breaks" }, opacity: { attribute: "opacity" } }; }
|
|
11040
11888
|
render() {
|
|
11041
11889
|
this.classList.add("c-style-panel");
|
|
11042
11890
|
const title = this.getAttribute("title");
|
|
@@ -11046,11 +11894,28 @@ class ContourStylePanel extends ContourBase {
|
|
|
11046
11894
|
}
|
|
11047
11895
|
const layers = this.getAttribute("layers");
|
|
11048
11896
|
const body = this.ensure(".c-style-panel__body", () => { const el = document.createElement("div"); el.className = "c-style-panel__body"; return el; });
|
|
11049
|
-
|
|
11897
|
+
// Slotted content support: authored .c-style-panel__row children take
|
|
11898
|
+
// precedence over the JSON `layers` attribute.
|
|
11899
|
+
const authoredRows = Array.from(this.querySelectorAll(":scope > .c-style-panel__row"));
|
|
11900
|
+
let parsed = null;
|
|
11901
|
+
if (authoredRows.length) {
|
|
11902
|
+
parsed = authoredRows.map((row) => ({
|
|
11903
|
+
name: row.querySelector(".c-style-panel__name")?.textContent || "",
|
|
11904
|
+
color: row.querySelector(".c-style-panel__color")?.value,
|
|
11905
|
+
classification: row.querySelector(".c-style-panel__classification")?.value,
|
|
11906
|
+
palette: row.querySelector(".c-style-panel__palette")?.value,
|
|
11907
|
+
breaks: row.querySelector(".c-style-panel__breaks")?.value,
|
|
11908
|
+
opacity: row.querySelector(".c-style-panel__opacity")?.value,
|
|
11909
|
+
}));
|
|
11910
|
+
authoredRows.forEach((row) => row.remove());
|
|
11911
|
+
} else if (layers) {
|
|
11050
11912
|
try {
|
|
11051
|
-
|
|
11052
|
-
|
|
11053
|
-
|
|
11913
|
+
parsed = JSON.parse(layers);
|
|
11914
|
+
} catch (e) { parsed = null; }
|
|
11915
|
+
}
|
|
11916
|
+
if (parsed) {
|
|
11917
|
+
body.innerHTML = "";
|
|
11918
|
+
parsed.forEach((l) => {
|
|
11054
11919
|
const row = document.createElement("div");
|
|
11055
11920
|
row.className = "c-style-panel__row";
|
|
11056
11921
|
const name = document.createElement("span");
|
|
@@ -11062,11 +11927,63 @@ class ContourStylePanel extends ContourBase {
|
|
|
11062
11927
|
input.className = "c-style-panel__color";
|
|
11063
11928
|
if (typeof l === "object" && l.color) input.value = l.color;
|
|
11064
11929
|
row.appendChild(input);
|
|
11930
|
+
// classification method selector
|
|
11931
|
+
const clsSel = document.createElement("select");
|
|
11932
|
+
clsSel.className = "c-style-panel__classification";
|
|
11933
|
+
["equal","quantile","jenks","manual"].forEach((m) => { const o = document.createElement("option"); o.value = m; o.textContent = m; clsSel.appendChild(o); });
|
|
11934
|
+
if (typeof l === "object" && l.classification) clsSel.value = l.classification;
|
|
11935
|
+
row.appendChild(clsSel);
|
|
11936
|
+
// palette picker
|
|
11937
|
+
const pal = document.createElement("input");
|
|
11938
|
+
pal.type = "text";
|
|
11939
|
+
pal.className = "c-style-panel__palette";
|
|
11940
|
+
pal.placeholder = "palette";
|
|
11941
|
+
if (typeof l === "object" && l.palette) pal.value = l.palette;
|
|
11942
|
+
row.appendChild(pal);
|
|
11943
|
+
// breaks editor
|
|
11944
|
+
const breaks = document.createElement("input");
|
|
11945
|
+
breaks.type = "text";
|
|
11946
|
+
breaks.className = "c-style-panel__breaks";
|
|
11947
|
+
breaks.placeholder = "breaks";
|
|
11948
|
+
if (typeof l === "object" && l.breaks) breaks.value = (Array.isArray(l.breaks) ? l.breaks.join(",") : l.breaks);
|
|
11949
|
+
row.appendChild(breaks);
|
|
11950
|
+
// opacity control
|
|
11951
|
+
const op = document.createElement("input");
|
|
11952
|
+
op.type = "range";
|
|
11953
|
+
op.className = "c-style-panel__opacity";
|
|
11954
|
+
op.min = "0"; op.max = "100";
|
|
11955
|
+
op.value = (typeof l === "object" && l.opacity != null) ? l.opacity : "100";
|
|
11956
|
+
row.appendChild(op);
|
|
11065
11957
|
body.appendChild(row);
|
|
11066
11958
|
});
|
|
11067
|
-
} catch (e) { /* keep existing */ }
|
|
11068
11959
|
}
|
|
11069
11960
|
}
|
|
11961
|
+
enhance() {
|
|
11962
|
+
if (this._wiredStylePanel) return;
|
|
11963
|
+
this._wiredStylePanel = true;
|
|
11964
|
+
this.addEventListener("change", (e) => {
|
|
11965
|
+
const t = e.target;
|
|
11966
|
+
if (!t || !this.contains(t)) return;
|
|
11967
|
+
const row = t.closest(".c-style-panel__row");
|
|
11968
|
+
const name = row ? (row.querySelector(".c-style-panel__name")?.textContent || "") : "";
|
|
11969
|
+
if (t.classList.contains("c-style-panel__color")) {
|
|
11970
|
+
this.dispatchEvent(new CustomEvent("contour:style-resolved", { detail: { value: t.value, layer: name, property: "color" }, bubbles: true, composed: true }));
|
|
11971
|
+
} else if (t.classList.contains("c-style-panel__classification")) {
|
|
11972
|
+
this.dispatchEvent(new CustomEvent("contour:break-change", { detail: { value: t.value, layer: name }, bubbles: true, composed: true }));
|
|
11973
|
+
} else if (t.classList.contains("c-style-panel__opacity")) {
|
|
11974
|
+
this.dispatchEvent(new CustomEvent("contour:layer-opacity", { detail: { name, opacity: Number(t.value) }, bubbles: true, composed: true }));
|
|
11975
|
+
}
|
|
11976
|
+
});
|
|
11977
|
+
this.addEventListener("input", (e) => {
|
|
11978
|
+
const t = e.target;
|
|
11979
|
+
if (!t || !this.contains(t)) return;
|
|
11980
|
+
if (t.classList.contains("c-style-panel__palette") || t.classList.contains("c-style-panel__breaks")) {
|
|
11981
|
+
const row = t.closest(".c-style-panel__row");
|
|
11982
|
+
const name = row ? (row.querySelector(".c-style-panel__name")?.textContent || "") : "";
|
|
11983
|
+
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
|
+
}
|
|
11985
|
+
});
|
|
11986
|
+
}
|
|
11070
11987
|
}
|
|
11071
11988
|
define("contour-style-panel", ContourStylePanel);
|
|
11072
11989
|
|
|
@@ -12090,11 +13007,30 @@ class ContourTreeGrid extends ContourBase {
|
|
|
12090
13007
|
if (ADOPTED && key === ADOPTED_KEY) return ADOPTED;
|
|
12091
13008
|
ADOPTED_KEY = key;
|
|
12092
13009
|
ADOPTED = [];
|
|
13010
|
+
// Collect every rule a sheet carries, descending into @imported sheets,
|
|
13011
|
+
// because adoptedStyleSheets cannot hold @import rules (the platform
|
|
13012
|
+
// rejects them) and the imported sheets are not separate top-level entries
|
|
13013
|
+
// in document.styleSheets. Skipping them would hand the shadow root an
|
|
13014
|
+
// empty sheet.
|
|
13015
|
+
const collect = (sheet, out) => {
|
|
13016
|
+
let rules;
|
|
13017
|
+
try { rules = sheet.cssRules; } catch (e) { return; }
|
|
13018
|
+
if (!rules) return;
|
|
13019
|
+
for (const r of rules) {
|
|
13020
|
+
if (r instanceof CSSImportRule) {
|
|
13021
|
+
if (r.styleSheet) collect(r.styleSheet, out);
|
|
13022
|
+
} else {
|
|
13023
|
+
try { out.push(r.cssText); } catch (e) { /* unreadable */ }
|
|
13024
|
+
}
|
|
13025
|
+
}
|
|
13026
|
+
};
|
|
12093
13027
|
for (const sheet of document.styleSheets) {
|
|
12094
13028
|
try {
|
|
12095
13029
|
if (sheet.href && new URL(sheet.href).origin === location.origin) {
|
|
13030
|
+
const collected = [];
|
|
13031
|
+
collect(sheet, collected);
|
|
12096
13032
|
const built = new CSSStyleSheet();
|
|
12097
|
-
|
|
13033
|
+
if (collected.length) built.replaceSync(collected.join("\n"));
|
|
12098
13034
|
ADOPTED.push(built);
|
|
12099
13035
|
}
|
|
12100
13036
|
} catch (e) { /* cross-origin or unreadable */ }
|
|
@@ -12320,6 +13256,14 @@ connectedCallback() {
|
|
|
12320
13256
|
shadow("contour-shadow-kpi", `<div class="c-kpi" part="kpi"><div class="c-kpi__value" part="value"><slot name="value"></slot></div><div class="c-kpi__label" part="label"><slot name="label"></slot></div><div class="c-kpi__foot" part="foot"><slot name="delta"></slot><slot name="note"></slot></div></div>`);
|
|
12321
13257
|
shadow("contour-shadow-stat", `<div class="c-stat" part="stat"><div class="c-stat__value" part="value"><slot name="value"></slot></div><div class="c-stat__label" part="label"><slot name="label"></slot></div><div class="c-stat__delta" part="delta"><slot name="delta"></slot></div></div>`);
|
|
12322
13258
|
shadow("contour-shadow-meter", `<div class="c-meter" part="meter"><span class="c-meter__core" part="core"><span class="c-meter__value" part="value"><slot name="value"></slot></span><span class="c-meter__label" part="label"><slot name="label"></slot></span></span></div>`);
|
|
13259
|
+
shadow("contour-shadow-brownout", `<div class="c-brownout" part="brownout" data-level="0"><slot></slot></div>`);
|
|
13260
|
+
shadow("contour-shadow-widget-state", `<div class="c-widget-state" part="widget-state"><slot></slot></div>`);
|
|
13261
|
+
shadow("contour-shadow-donut", `<div class="c-donut" part="donut"><svg class="c-donut__ring" part="ring" viewBox="0 0 32 32"></svg><div class="c-donut__center" part="center"><slot name="value"></slot></div><div class="c-donut__list" part="list"><slot></slot></div></div>`);
|
|
13262
|
+
shadow("contour-shadow-axis", `<div class="c-axis" part="axis"><slot></slot></div>`);
|
|
13263
|
+
shadow("contour-shadow-brush", `<div class="c-brush" part="brush"><div class="c-brush__selection" part="selection"></div></div>`);
|
|
13264
|
+
shadow("contour-shadow-stacked-bar", `<div class="c-stacked-bar" part="bar"><slot></slot></div>`);
|
|
13265
|
+
shadow("contour-shadow-category", `<div class="c-category" part="category" role="listbox"><slot></slot></div>`);
|
|
13266
|
+
shadow("contour-shadow-gauge", `<div class="c-gauge" part="gauge"><svg class="c-gauge__dial" part="dial" aria-hidden="true" viewBox="0 0 100 100"><path class="c-gauge__track" part="track" d="M 10 90 A 40 40 0 0 1 90 90"></path><g class="c-gauge__zones"></g><line class="c-gauge__needle" part="needle" x1="50" y1="50" x2="50" y2="15"></line><circle class="c-gauge__hub" part="hub" cx="50" cy="50" r="4"></circle></svg><div class="c-gauge__value" part="value"><slot name="value"></slot></div><div class="c-gauge__band" part="band"><slot name="band"></slot></div></div>`);
|
|
12323
13267
|
shadow("contour-shadow-diff", `<div class="c-diff" part="diff"><div class="c-diff__line c-diff__line--del" part="before"><span class="c-diff__sign">−</span><span><slot name="before"></slot></span></div><div class="c-diff__line c-diff__line--add" part="after"><span class="c-diff__sign">+</span><span><slot name="after"></slot></span></div></div>`);
|
|
12324
13268
|
shadow("contour-shadow-do-dont", `<div class="c-do-dont" part="do-dont"><div class="c-do-dont__item c-do-dont__item--do" part="do"><slot name="do"></slot></div><div class="c-do-dont__item c-do-dont__item--dont" part="dont"><slot name="dont"></slot></div></div>`);
|
|
12325
13269
|
shadow("contour-shadow-threshold", `<div class="c-threshold" part="threshold"><span class="c-threshold__fill" part="value"></span><span class="c-threshold__target" part="target"></span></div>`);
|
|
@@ -12342,6 +13286,7 @@ connectedCallback() {
|
|
|
12342
13286
|
shadow("contour-shadow-table", `<div class="c-table-wrap" part="wrap"><table class="c-table" part="table"><thead><slot name="head"></slot></thead><tbody><slot></slot></tbody></table></div>`);
|
|
12343
13287
|
shadow("contour-shadow-chart", `<div class="c-chart" part="chart"><div class="c-chart__plot" part="plot"><slot></slot></div></div>`);
|
|
12344
13288
|
shadow("contour-shadow-bivariate", `<div class="c-bivariate" part="bivariate"><div class="c-bivariate__matrix" part="matrix"><slot></slot></div></div>`);
|
|
13289
|
+
shadow("contour-shadow-bivariate-legend", `<div class="c-bivariate-legend" part="legend"><div class="c-bivariate-legend__matrix" part="matrix"><slot></slot></div></div>`);
|
|
12345
13290
|
shadow("contour-shadow-expandable", `<details class="c-expandable" part="expandable"><summary class="c-expandable__summary"><slot name="summary"></slot></summary><div class="c-expandable__body" part="body"><slot></slot></div></details>`);
|
|
12346
13291
|
shadow("contour-shadow-disclosure", `<details class="c-disclosure" part="disclosure"><summary><slot name="summary"></slot></summary><div class="c-disclosure__body" part="body"><slot></slot></div></details>`);
|
|
12347
13292
|
shadow("contour-shadow-faq", `<div class="c-faq" part="faq"><div class="c-faq__question" part="question"><slot name="question"></slot></div><div class="c-faq__answer" part="answer"><slot name="answer"></slot></div></div>`);
|