contour-ds 1.13.0 → 1.14.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/dist/build-manifest.json +77 -77
- package/dist/contour-wc-core.esm.js +3 -1
- package/dist/contour-wc-core.esm.min.js +1 -1
- package/dist/contour-wc-dashboard.esm.js +160 -26
- package/dist/contour-wc-dashboard.esm.min.js +1 -1
- package/dist/contour-wc-data.esm.js +160 -26
- package/dist/contour-wc-data.esm.min.js +1 -1
- package/dist/contour-wc-feedback.esm.js +19 -14
- package/dist/contour-wc-feedback.esm.min.js +1 -1
- package/dist/contour-wc-forms.esm.js +38 -2
- package/dist/contour-wc-forms.esm.min.js +1 -1
- package/dist/contour-wc-interaction.esm.js +9 -0
- package/dist/contour-wc-interaction.esm.min.js +1 -1
- package/dist/contour-wc-navigation.esm.js +36 -12
- package/dist/contour-wc-navigation.esm.min.js +1 -1
- package/dist/contour-wc-ui.esm.js +68 -17
- package/dist/contour-wc-ui.esm.min.js +1 -1
- package/dist/contour-wc.esm.js +333 -72
- package/dist/contour-wc.esm.min.js +1 -1
- package/dist/contour-wc.js +333 -72
- package/dist/contour-wc.min.js +1 -1
- package/dist/contour.code-snippets +3 -3
- package/dist/contour.components.json +157 -13
- package/dist/contour.css +36 -3
- package/dist/contour.d.ts +15 -13
- package/dist/contour.html-data.json +78 -2
- package/dist/contour.min.css +1 -1
- package/dist/contour.single.html +1 -1
- package/dist/contour.single.min.css +1 -1
- package/dist/contour.web-types.json +78 -2
- package/dist/custom-elements.json +330 -0
- package/dist/docs/actions.md +1 -1
- package/dist/docs/affordances.md +1 -1
- package/dist/docs/apireference.md +1 -1
- package/dist/docs/colour.md +1 -1
- package/dist/docs/componentindex.md +1 -1
- package/dist/docs/data.md +1 -1
- package/dist/docs/docs.md +1 -1
- package/dist/docs/feedback.md +1 -1
- package/dist/docs/field.md +1 -1
- package/dist/docs/forms.md +1 -1
- package/dist/docs/index.json +2 -2
- package/dist/docs/install.md +1 -1
- package/dist/docs/landing.md +1 -1
- package/dist/docs/mapengine.md +1 -1
- package/dist/docs/motion.md +1 -1
- package/dist/docs/navigation.md +1 -1
- package/dist/docs/overlays.md +1 -1
- package/dist/docs/overview.md +1 -1
- package/dist/docs/patterns.md +1 -1
- package/dist/docs/playground.md +1 -1
- package/dist/docs/principles.md +1 -1
- package/dist/docs/recipes.md +1 -1
- package/dist/docs/space.md +1 -1
- package/dist/docs/status.md +1 -1
- package/dist/docs/surfaces.md +1 -1
- package/dist/docs/theming.md +1 -1
- package/dist/docs/type.md +1 -1
- package/dist/docs/webcomponents.md +1 -1
- package/dist/registry/items/contour-core.json +2 -2
- package/dist/registry/items/contour-data.json +2 -2
- package/dist/registry/items/contour-docs.json +2 -2
- package/dist/registry/items/contour-landing.json +2 -2
- package/dist/registry/registry.json +8 -8
- package/dist/surfaces/contour-core.min.css +1 -1
- package/dist/surfaces/contour-data.min.css +1 -1
- package/dist/surfaces/contour-docs.min.css +1 -1
- package/dist/surfaces/contour-landing.min.css +1 -1
- package/dist/wc/core.mjs +2 -0
- package/dist/wc/data-chart.mjs +56 -3
- package/dist/wc/data-gauge.mjs +17 -3
- package/dist/wc/data-geo.mjs +26 -11
- package/dist/wc/data-legend.mjs +49 -4
- package/dist/wc/data-readout.mjs +8 -3
- package/dist/wc/data-series.mjs +4 -2
- package/dist/wc/feedback.mjs +19 -14
- package/dist/wc/forms-controls.mjs +38 -2
- package/dist/wc/index.mjs +1 -1
- package/dist/wc/interaction.mjs +9 -0
- package/dist/wc/navigation-menu.mjs +31 -9
- package/dist/wc/navigation-tree.mjs +5 -3
- package/dist/wc/ui-data.mjs +4 -4
- package/dist/wc/ui-overlays.mjs +64 -13
- package/integrations/libreship/contract.json +13 -2
- package/package.json +1 -1
|
@@ -690,9 +690,9 @@ define("contour-readout", ContourReadout);
|
|
|
690
690
|
* Attributes: `value`, `label`, `delta`, `direction`, `note`, `variant`, `unit`, `format`, `locale`, `empty`, `loading`, `error`, `retry`, `src`, `lazy`, `refresh`, `timeout`, `skeleton`, `thresholds`, `threshold`, `sparkline`, `polarity`.
|
|
691
691
|
*/
|
|
692
692
|
class ContourKpi extends ContourBase {
|
|
693
|
-
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", "cache-key", "no-cache"]; }
|
|
693
|
+
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", "delta-tone", "cache-key", "no-cache"]; }
|
|
694
694
|
static get properties() {
|
|
695
|
-
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" } };
|
|
695
|
+
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" }, "delta-tone": { attribute: "delta-tone" } };
|
|
696
696
|
}
|
|
697
697
|
render() {
|
|
698
698
|
this.classList.add("c-kpi");
|
|
@@ -739,8 +739,13 @@ class ContourKpi extends ContourBase {
|
|
|
739
739
|
if (!d.parentNode) f.insertBefore(d, f.firstChild);
|
|
740
740
|
const dir = this.getAttribute("direction") || "up";
|
|
741
741
|
const polarity = this.getAttribute("polarity") || "neutral";
|
|
742
|
+
// U-28: `delta-tone` is an explicit override (good/bad/neutral); with
|
|
743
|
+
// out it, `polarity` derives the tone from the direction.
|
|
744
|
+
const explicitTone = (this.getAttribute("delta-tone") || "").toLowerCase();
|
|
742
745
|
let tone = "neutral";
|
|
743
|
-
if (
|
|
746
|
+
if (explicitTone === "good" || explicitTone === "bad" || explicitTone === "neutral") {
|
|
747
|
+
tone = explicitTone;
|
|
748
|
+
} else if (polarity === "good" || polarity === "up-good" || polarity === "auto") {
|
|
744
749
|
tone = (dir === "up") ? "good" : (dir === "down" ? "bad" : "neutral");
|
|
745
750
|
} else if (polarity === "bad" || polarity === "down-good") {
|
|
746
751
|
tone = (dir === "up") ? "bad" : (dir === "down" ? "good" : "neutral");
|
|
@@ -1742,7 +1747,7 @@ const normalizeChartBin = (bin) => {
|
|
|
1742
1747
|
*/
|
|
1743
1748
|
class ContourChart extends ContourBase {
|
|
1744
1749
|
static get updateMode() { return "keyed"; }
|
|
1745
|
-
static get observed() { return ["series", "axis", "color", "colors", "label", "legend", "brownout", "brownout-level", "empty", "loading", "error", "retry", "skeleton", "zoomable", "data-table", "brush", "brush-min", "brush-max", "brush-start", "brush-end", "note", "annotations", "mean-marker", "median-marker", "bucket-count", "limit-values", "title", "cache-key", "dir", "src"]; }
|
|
1750
|
+
static get observed() { return ["series", "axis", "color", "colors", "label", "legend", "brownout", "brownout-level", "empty", "loading", "error", "retry", "skeleton", "zoomable", "data-table", "brush", "brush-min", "brush-max", "brush-start", "brush-end", "note", "annotations", "mean-marker", "median-marker", "bin-labels", "bucket-count", "limit-values", "title", "cache-key", "dir", "src"]; }
|
|
1746
1751
|
static get properties() { return { series: { attribute: "series" }, axis: { attribute: "axis" }, color: { attribute: "color" }, colors: { attribute: "colors" }, label: { attribute: "label" }, legend: { attribute: "legend" }, zoomable: { attribute: "zoomable", type: Boolean }, brush: { attribute: "brush", type: Boolean }, note: { attribute: "note" }, annotations: { attribute: "annotations" }, "mean-marker": { attribute: "mean-marker", type: Boolean }, "median-marker": { attribute: "median-marker", type: Boolean }, "bucket-count": { attribute: "bucket-count" }, "limit-values": { attribute: "limit-values" } }; }
|
|
1747
1752
|
// U-4: JS formatters. The `axis` attribute is JSON, so a consumer cannot pass a
|
|
1748
1753
|
// function through it. These properties accept a function directly: `format`
|
|
@@ -1910,6 +1915,25 @@ class ContourChart extends ContourBase {
|
|
|
1910
1915
|
plot.appendChild(el);
|
|
1911
1916
|
});
|
|
1912
1917
|
}
|
|
1918
|
+
// U-19: direct per-bin labels. Positioned like the reference markers (a
|
|
1919
|
+
// fraction of the plot's width/height), decorative for AT because the data
|
|
1920
|
+
// table carries the authoritative values.
|
|
1921
|
+
_renderBinLabels(labels) {
|
|
1922
|
+
const plot = this._plot || this.querySelector(".c-chart__plot");
|
|
1923
|
+
if (!plot) return;
|
|
1924
|
+
Array.from(plot.querySelectorAll(".c-chart__bin-label")).forEach((n) => n.remove());
|
|
1925
|
+
if (!Array.isArray(labels) || !labels.length) return;
|
|
1926
|
+
labels.forEach((l) => {
|
|
1927
|
+
if (!l || !Number.isFinite(l.x) || !Number.isFinite(l.y)) return;
|
|
1928
|
+
const el = document.createElement("span");
|
|
1929
|
+
el.className = "c-chart__bin-label";
|
|
1930
|
+
el.style.left = (Math.max(0, Math.min(1, l.x)) * 100).toFixed(3) + "%";
|
|
1931
|
+
el.style.top = (Math.max(0, Math.min(1, l.y)) * 100).toFixed(3) + "%";
|
|
1932
|
+
el.textContent = l.text;
|
|
1933
|
+
el.setAttribute("aria-hidden", "true");
|
|
1934
|
+
plot.appendChild(el);
|
|
1935
|
+
});
|
|
1936
|
+
}
|
|
1913
1937
|
_renderValueAxis() {
|
|
1914
1938
|
const ax = this.querySelector(".c-chart__axis");
|
|
1915
1939
|
if (!ax) return;
|
|
@@ -2100,6 +2124,9 @@ class ContourChart extends ContourBase {
|
|
|
2100
2124
|
// collected while the histogram renders, then painted over the plot
|
|
2101
2125
|
// after patchChildren (which only manages the SVG marks in `frag`).
|
|
2102
2126
|
const pendingMarkers = [];
|
|
2127
|
+
// U-19: direct per-bin labels for a histogram, rendered as positioned
|
|
2128
|
+
// overlays after the plot is patched (like the reference markers).
|
|
2129
|
+
const pendingBinLabels = [];
|
|
2103
2130
|
// Structured series: an item may carry `values` plus a `type` ("donut" | "histogram" | "line") instead of a pre-computed `d` path, or carry pre-binned `bins` instead of raw `values`. The helpers in svg.mjs turn those into geometry so a consumer does not have to hand-compute arc or bar math.
|
|
2104
2131
|
const hasStructured = parsed.some((s) => s && (Array.isArray(s.values) || Array.isArray(s.bins)));
|
|
2105
2132
|
if (hasStructured) {
|
|
@@ -2221,7 +2248,8 @@ svg.setAttribute("role", "group");
|
|
|
2221
2248
|
svg.appendChild(rect);
|
|
2222
2249
|
});
|
|
2223
2250
|
}
|
|
2224
|
-
barRects(plotVals, backgroundVals.length ? { max: sharedMax } : undefined)
|
|
2251
|
+
const foregroundRects = barRects(plotVals, backgroundVals.length ? { max: sharedMax } : undefined);
|
|
2252
|
+
foregroundRects.forEach((r, ri) => {
|
|
2225
2253
|
if (r.missing) return; // R31-50: missing is not a zero bar
|
|
2226
2254
|
const rect = document.createElementNS("http://www.w3.org/2000/svg", "rect");
|
|
2227
2255
|
rect.setAttribute("class", "c-chart__bar");
|
|
@@ -2242,6 +2270,15 @@ svg.setAttribute("role", "group");
|
|
|
2242
2270
|
rect.dataset.index = String(ri);
|
|
2243
2271
|
svg.appendChild(rect);
|
|
2244
2272
|
});
|
|
2273
|
+
// U-19: direct per-bin labels — the count rides above each bar.
|
|
2274
|
+
if (flagOn(this, "bin-labels")) {
|
|
2275
|
+
foregroundRects.forEach((r, ri) => {
|
|
2276
|
+
if (r.missing) return;
|
|
2277
|
+
const val = bins ? bins[ri].count : (Array.isArray(s.values) ? s.values[ri] : ri);
|
|
2278
|
+
if (isMissing(val)) return;
|
|
2279
|
+
pendingBinLabels.push({ x: (r.x + r.width / 2) / 300, y: r.y / 120, text: formatValue(val) });
|
|
2280
|
+
});
|
|
2281
|
+
}
|
|
2245
2282
|
frag.appendChild(svg);
|
|
2246
2283
|
// U-2/U-3: position mean/median markers and annotations on the
|
|
2247
2284
|
// histogram's own x-domain (bins[0].x0 .. bins[last].x1), which
|
|
@@ -2391,6 +2428,8 @@ svg.setAttribute("role", "group");
|
|
|
2391
2428
|
patchChildren(plot, frag);
|
|
2392
2429
|
// U-2/U-3: paint mean/median markers and annotations over the plot.
|
|
2393
2430
|
this._renderChartMarkers(pendingMarkers);
|
|
2431
|
+
// U-19: paint the histogram's direct per-bin labels over the bars.
|
|
2432
|
+
this._renderBinLabels(pendingBinLabels);
|
|
2394
2433
|
// Styled tooltip element (positioned via --chart-tip-*). R25-03: shed at level ≥2. The hover/focus handlers re-query the tip per event and no-op when absent, so removing it is safe.
|
|
2395
2434
|
if (this.shed("tooltip", 2)) {
|
|
2396
2435
|
const oldTip = this.querySelector(".c-chart__tooltip");
|
|
@@ -2700,8 +2739,23 @@ svg.setAttribute("role", "group");
|
|
|
2700
2739
|
const tip = this.querySelector(".c-chart__tooltip");
|
|
2701
2740
|
if (!plot || !tip) return;
|
|
2702
2741
|
const mark = e.target && e.target.closest ? e.target.closest(".c-chart__bar, .c-chart__point, .c-chart__line, .c-donut__slice") : null;
|
|
2703
|
-
if (!mark || !plot.contains(mark)) { tip.setAttribute("hidden", ""); return; }
|
|
2742
|
+
if (!mark || !plot.contains(mark)) { tip.setAttribute("hidden", ""); this._lastHoverKey = null; return; }
|
|
2704
2743
|
const title = mark.getAttribute("data-title") || mark.getAttribute("title");
|
|
2744
|
+
// U-19: emit a bin-hover detail event when the hovered bar changes, so a
|
|
2745
|
+
// consumer can mirror a histogram highlight/tooltip without scraping the
|
|
2746
|
+
// light DOM on every pointer move. Bars only (points/lines/donut skip it).
|
|
2747
|
+
if (mark.classList.contains("c-chart__bar")) {
|
|
2748
|
+
const idxAttr = mark.getAttribute("data-index");
|
|
2749
|
+
const idx = idxAttr != null ? Number(idxAttr) : null;
|
|
2750
|
+
const si = Number(mark.getAttribute("data-series")) || 1;
|
|
2751
|
+
const hkey = si + ":" + (idxAttr != null ? idxAttr : "");
|
|
2752
|
+
if (this._lastHoverKey !== hkey) {
|
|
2753
|
+
this._lastHoverKey = hkey;
|
|
2754
|
+
const bin = idx != null && this._renderedBins ? (this._renderedBins[idx] || null) : null;
|
|
2755
|
+
const val = bin ? bin.count : (title != null ? title : null);
|
|
2756
|
+
this.dispatchEvent(new CustomEvent("contour:bin-hover", { bubbles: true, composed: true, detail: { index: idx, series: si, value: val, bin } }));
|
|
2757
|
+
}
|
|
2758
|
+
}
|
|
2705
2759
|
// U-4: a JS `tooltipFormat` builds the tip text from the mark's datum.
|
|
2706
2760
|
if (this._jsTooltipFormat) {
|
|
2707
2761
|
try {
|
|
@@ -2730,6 +2784,10 @@ svg.setAttribute("role", "group");
|
|
|
2730
2784
|
const hideTip = () => {
|
|
2731
2785
|
const tip = this.querySelector(".c-chart__tooltip");
|
|
2732
2786
|
if (tip) tip.setAttribute("hidden", "");
|
|
2787
|
+
if (this._lastHoverKey != null) {
|
|
2788
|
+
this._lastHoverKey = null;
|
|
2789
|
+
this.dispatchEvent(new CustomEvent("contour:bin-hover", { bubbles: true, composed: true, detail: { index: null, series: null, value: null, bin: null } }));
|
|
2790
|
+
}
|
|
2733
2791
|
};
|
|
2734
2792
|
// Host-delegated so the handlers survive re-renders (rule 12).
|
|
2735
2793
|
this.addEventListener("mousemove", showTip);
|
|
@@ -4045,8 +4103,8 @@ define("contour-stacked-bar", ContourStackedBar);
|
|
|
4045
4103
|
* it is not a reflected property.
|
|
4046
4104
|
*/
|
|
4047
4105
|
class ContourCategory extends ContourBase {
|
|
4048
|
-
static get observed() { return ["items", "search", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton", "note", "limit", "sort", "format", "locale", "unit", "cache-key", "no-cache"]; }
|
|
4049
|
-
static get properties() { return { items: { attribute: "items" }, src: { attribute: "src" }, note: { attribute: "note" }, limit: { attribute: "limit" }, sort: { attribute: "sort" }, format: { attribute: "format" }, locale: { attribute: "locale" }, unit: { attribute: "unit" } }; }
|
|
4106
|
+
static get observed() { return ["items", "search", "selected", "aria-label", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton", "note", "limit", "sort", "format", "locale", "unit", "cache-key", "no-cache"]; }
|
|
4107
|
+
static get properties() { return { items: { attribute: "items" }, selected: { attribute: "selected" }, src: { attribute: "src" }, note: { attribute: "note" }, limit: { attribute: "limit" }, sort: { attribute: "sort" }, format: { attribute: "format" }, locale: { attribute: "locale" }, unit: { attribute: "unit" } }; }
|
|
4050
4108
|
render() {
|
|
4051
4109
|
this.classList.add("c-category");
|
|
4052
4110
|
this.setAttribute("role", "listbox");
|
|
@@ -4087,13 +4145,27 @@ class ContourCategory extends ContourBase {
|
|
|
4087
4145
|
// produces a positive-width bar (a negative inline-size is invalid CSS
|
|
4088
4146
|
// and rendered nothing) and the sign is carried by the formatted value.
|
|
4089
4147
|
const max = items.reduce((m, it) => Math.max(m, Math.abs(typeof it === "object" ? (it.value || 0) : Number(it) || 0)), 0) || 1;
|
|
4148
|
+
// U-24: controlled selected values (JSON array or comma list), matched by
|
|
4149
|
+
// label or value. The host owns selection; a click still emits contour:select.
|
|
4150
|
+
const selectedRaw = this.getAttribute("selected");
|
|
4151
|
+
let selectedSet = new Set();
|
|
4152
|
+
if (selectedRaw) {
|
|
4153
|
+
try { const p = JSON.parse(selectedRaw); selectedSet = new Set((Array.isArray(p) ? p : [selectedRaw]).map(String)); }
|
|
4154
|
+
catch (e) { selectedSet = new Set(selectedRaw.split(",").map((s) => s.trim()).filter(Boolean)); }
|
|
4155
|
+
}
|
|
4090
4156
|
items.forEach((it, idx) => {
|
|
4091
4157
|
const value = (typeof it === "object") ? (it.value || 0) : (Number(it) || 0);
|
|
4092
4158
|
const label = (typeof it === "object") ? (it.label || it.name || "") : String(it);
|
|
4093
4159
|
const item = document.createElement("div");
|
|
4094
4160
|
item.className = "c-category__item";
|
|
4095
4161
|
item.setAttribute("role", "option");
|
|
4096
|
-
|
|
4162
|
+
const itemKey = typeof it === "object" ? String(it.key != null ? it.key : (it.label || it.name || "")) : String(it);
|
|
4163
|
+
const isSelected = selectedSet.has(itemKey) || selectedSet.has(String(value)) || selectedSet.has(String(label));
|
|
4164
|
+
item.setAttribute("aria-selected", isSelected ? "true" : "false");
|
|
4165
|
+
if (isSelected) item.classList.add("is-selected");
|
|
4166
|
+
// U-24: the option's accessible name carries the label and its value,
|
|
4167
|
+
// so a screen reader hears "Road: 1,204" rather than a bare bar.
|
|
4168
|
+
item.setAttribute("aria-label", String(label) + ": " + formatValue(value, this.getAttribute("format"), this.getAttribute("locale"), this.getAttribute("unit")));
|
|
4097
4169
|
item.setAttribute("tabindex", idx === 0 ? "0" : "-1");
|
|
4098
4170
|
const lbl = document.createElement("span");
|
|
4099
4171
|
lbl.className = "c-category__label";
|
|
@@ -4537,8 +4609,8 @@ define("contour-time-series", ContourTimeSeries);
|
|
|
4537
4609
|
* Attributes: `rows`, `columns`, `values`, `data`, `empty`, `loading`, `error`, `retry`, `src`, `lazy`, `refresh`, `timeout`, `skeleton`.
|
|
4538
4610
|
*/
|
|
4539
4611
|
class ContourPivot extends ContourBase {
|
|
4540
|
-
static get observed() { return ["rows", "columns", "values", "data", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton", "filter", "aggregate", "cache-key", "no-cache"]; }
|
|
4541
|
-
static get properties() { return { rows: { attribute: "rows" }, columns: { attribute: "columns" }, values: { attribute: "values" }, data: { attribute: "data" }, src: { attribute: "src" }, filter: { attribute: "filter" }, aggregate: { attribute: "aggregate" } }; }
|
|
4612
|
+
static get observed() { return ["rows", "columns", "values", "data", "label", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton", "filter", "aggregate", "cache-key", "no-cache"]; }
|
|
4613
|
+
static get properties() { return { rows: { attribute: "rows" }, columns: { attribute: "columns" }, values: { attribute: "values" }, data: { attribute: "data" }, label: { attribute: "label" }, src: { attribute: "src" }, filter: { attribute: "filter" }, aggregate: { attribute: "aggregate" } }; }
|
|
4542
4614
|
_aggregateFn(name) {
|
|
4543
4615
|
const n = (name || "sum").toLowerCase();
|
|
4544
4616
|
if (n === "avg" || n === "average" || n === "mean") return (vals) => vals.length ? vals.reduce((a,b)=>a+b,0)/vals.length : 0;
|
|
@@ -4671,6 +4743,8 @@ class ContourPivot extends ContourBase {
|
|
|
4671
4743
|
const table = document.createElement("table");
|
|
4672
4744
|
table.className = "c-table c-pivot__table";
|
|
4673
4745
|
table.setAttribute("role", "grid");
|
|
4746
|
+
// U-27: the generated table region carries an accessible name.
|
|
4747
|
+
table.setAttribute("aria-label", this.getAttribute("label") || labelText(this, "pivot", "Pivot table"));
|
|
4674
4748
|
table.setAttribute("aria-rowcount", String(visibleRows.length + 1));
|
|
4675
4749
|
table.setAttribute("aria-colcount", String(visibleCols.length + 1));
|
|
4676
4750
|
const thead = document.createElement("thead");
|
|
@@ -5335,8 +5409,8 @@ class ContourSelectionGroup extends ContourBase {
|
|
|
5335
5409
|
* Attributes: `title`, `ramp`, `scale`, `items`, `method`, `norm`, `selectable`, `empty`, `loading`, `error`, `retry`, `src`, `lazy`, `refresh`, `timeout`, `skeleton`, `glyphs`, `thresholds`, `breaks`, `no-data-color`, `size`, `table`, `classification`, `audit`, `continuous`, `ends`, `caption`.
|
|
5336
5410
|
*/
|
|
5337
5411
|
class ContourLegend extends ContourBase {
|
|
5338
|
-
static get observed() { return ["title", "ramp", "scale", "items", "method", "norm", "selectable", "brownout", "brownout-level", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton", "glyphs", "thresholds", "breaks", "no-data-color", "no-data-label", "size", "table", "classification", "audit", "continuous", "ends", "caption", "graduated", "cache-key", "no-cache", "domain", "reverse"]; }
|
|
5339
|
-
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" }, graduated: { attribute: "graduated", type: Boolean }, domain: { attribute: "domain" }, reverse: { attribute: "reverse", type: Boolean } }; }
|
|
5412
|
+
static get observed() { return ["title", "ramp", "scale", "items", "method", "norm", "selectable", "selected", "collapsible", "collapsed", "brownout", "brownout-level", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton", "glyphs", "thresholds", "breaks", "no-data-color", "no-data-label", "size", "table", "classification", "audit", "continuous", "ends", "caption", "graduated", "cache-key", "no-cache", "domain", "reverse"]; }
|
|
5413
|
+
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 }, selected: { attribute: "selected" }, collapsible: { attribute: "collapsible", type: Boolean }, collapsed: { attribute: "collapsed", type: Boolean }, src: { attribute: "src" }, graduated: { attribute: "graduated", type: Boolean }, domain: { attribute: "domain" }, reverse: { attribute: "reverse", type: Boolean } }; }
|
|
5340
5414
|
render() {
|
|
5341
5415
|
this.classList.add("c-legend");
|
|
5342
5416
|
const graduated = this.hasAttribute("graduated");
|
|
@@ -5382,18 +5456,31 @@ class ContourLegend extends ContourBase {
|
|
|
5382
5456
|
const list = this.ensure(".c-legend__items", () => { const el = document.createElement("div"); el.className = "c-legend__items"; return el; });
|
|
5383
5457
|
if (this.hasAttribute("selectable")) {
|
|
5384
5458
|
list.setAttribute("role", "group");
|
|
5459
|
+
list.setAttribute("aria-label", this.getAttribute("aria-label") || title || labelText(this, "legend-items", "Legend items"));
|
|
5385
5460
|
} else {
|
|
5386
|
-
// Host already has role="list"; inner container
|
|
5461
|
+
// Host already has role="list"; the inner container must stay generic.
|
|
5462
|
+
// Naming it would make it an accessible child that is not a listitem
|
|
5463
|
+
// (axe aria-required-children), so the name belongs on the host list.
|
|
5387
5464
|
list.removeAttribute("role");
|
|
5465
|
+
list.removeAttribute("aria-label");
|
|
5466
|
+
if (!this.hasAttribute("aria-label")) this.setAttribute("aria-label", title || labelText(this, "legend-items", "Legend items"));
|
|
5388
5467
|
}
|
|
5389
|
-
if (title) list.setAttribute("aria-label", title);
|
|
5390
5468
|
list.innerHTML = "";
|
|
5469
|
+
// U-23: controlled selected keys (JSON array or comma list) highlight
|
|
5470
|
+
// matching items via `is-selected` + aria-current.
|
|
5471
|
+
const selectedRaw = this.getAttribute("selected");
|
|
5472
|
+
let selectedSet = new Set();
|
|
5473
|
+
if (selectedRaw) {
|
|
5474
|
+
try { const p = JSON.parse(selectedRaw); selectedSet = new Set((Array.isArray(p) ? p : [selectedRaw]).map(String)); }
|
|
5475
|
+
catch (e) { selectedSet = new Set(selectedRaw.split(",").map((s) => s.trim()).filter(Boolean)); }
|
|
5476
|
+
}
|
|
5391
5477
|
parsed.forEach((it) => {
|
|
5392
5478
|
const label = typeof it === "string" ? it : (it.label || String(it));
|
|
5393
5479
|
const key = typeof it === "string" ? it : (it.key || it.label || String(it));
|
|
5394
5480
|
const item = document.createElement("div");
|
|
5395
5481
|
item.className = "c-legend__item";
|
|
5396
5482
|
item.setAttribute("tabindex", "-1");
|
|
5483
|
+
if (selectedSet.has(String(key))) { item.classList.add("is-selected"); item.setAttribute("aria-current", "true"); }
|
|
5397
5484
|
if (selectable) {
|
|
5398
5485
|
item.setAttribute("role", "button");
|
|
5399
5486
|
// Restore pressed state from host's set so re-render doesn't reset items to pressed=true; set tracks UNPRESSED keys.
|
|
@@ -5405,6 +5492,8 @@ class ContourLegend extends ContourBase {
|
|
|
5405
5492
|
// aria-selected is not valid on role="listitem"; omit for non-selectable legends
|
|
5406
5493
|
}
|
|
5407
5494
|
const sw = document.createElement("span");
|
|
5495
|
+
// U-23: the swatch is decorative; the item's label is its name.
|
|
5496
|
+
sw.setAttribute("aria-hidden", "true");
|
|
5408
5497
|
if (graduated) {
|
|
5409
5498
|
sw.className = "c-legend__swatch c-legend__swatch--graduated";
|
|
5410
5499
|
const gSize = it && it.size != null ? it.size : (it && it.value != null ? it.value : 1);
|
|
@@ -5460,6 +5549,22 @@ class ContourLegend extends ContourBase {
|
|
|
5460
5549
|
}
|
|
5461
5550
|
list.appendChild(item);
|
|
5462
5551
|
});
|
|
5552
|
+
// U-23: collapsible contract — a toggle button controls the list; the
|
|
5553
|
+
// `collapsed` attribute is the controlled state, so the host owns it.
|
|
5554
|
+
if (this.hasAttribute("collapsible")) {
|
|
5555
|
+
if (!list.id) list.id = contourId("legend-items");
|
|
5556
|
+
const toggle = this.ensure(".c-legend__toggle", () => { const el = document.createElement("button"); el.className = "c-btn c-btn--sm c-legend__toggle"; el.type = "button"; return el; });
|
|
5557
|
+
const collapsed = this._legendCollapsed != null ? this._legendCollapsed : this.hasAttribute("collapsed");
|
|
5558
|
+
toggle.textContent = collapsed ? labelText(this, "show-legend", "Show legend") : labelText(this, "hide-legend", "Hide legend");
|
|
5559
|
+
toggle.setAttribute("aria-expanded", String(!collapsed));
|
|
5560
|
+
toggle.setAttribute("aria-controls", list.id);
|
|
5561
|
+
list.hidden = collapsed;
|
|
5562
|
+
if (toggle.parentNode !== this) this.insertBefore(toggle, list);
|
|
5563
|
+
} else {
|
|
5564
|
+
const toggle = this.querySelector(".c-legend__toggle");
|
|
5565
|
+
if (toggle) toggle.remove();
|
|
5566
|
+
list.hidden = false;
|
|
5567
|
+
}
|
|
5463
5568
|
} catch (e) { warnBadJson(this, "attribute", e); }
|
|
5464
5569
|
} else {
|
|
5465
5570
|
const list = this.querySelector(".c-legend__items");
|
|
@@ -5619,6 +5724,9 @@ class ContourLegend extends ContourBase {
|
|
|
5619
5724
|
const ramp = this.getAttribute("ramp");
|
|
5620
5725
|
if (ramp) {
|
|
5621
5726
|
const r = this.ensure(".c-legend__ramp", () => { const el = document.createElement("div"); el.className = "c-legend__ramp"; return el; });
|
|
5727
|
+
// U-23: the ramp is a named scale, not an unlabelled div.
|
|
5728
|
+
r.setAttribute("role", "group");
|
|
5729
|
+
r.setAttribute("aria-label", this.getAttribute("aria-label") || this.getAttribute("title") || labelText(this, "legend-ramp", "Legend scale"));
|
|
5622
5730
|
r.style.background = safeColor(ramp);
|
|
5623
5731
|
// ramp routing: equal-width segments with break labels
|
|
5624
5732
|
const breaksAttr = this.getAttribute("breaks");
|
|
@@ -5667,6 +5775,17 @@ class ContourLegend extends ContourBase {
|
|
|
5667
5775
|
if (this._wiredLegend) return;
|
|
5668
5776
|
this._wiredLegend = true;
|
|
5669
5777
|
this.addEventListener("click", (e) => {
|
|
5778
|
+
// U-23: the collapsible toggle owns the `collapsed` attribute.
|
|
5779
|
+
const toggleBtn = e.target && e.target.closest ? e.target.closest(".c-legend__toggle") : null;
|
|
5780
|
+
if (toggleBtn && this.contains(toggleBtn)) {
|
|
5781
|
+
e.preventDefault();
|
|
5782
|
+
// U-23: toggle internal state and re-render. Writing the observed
|
|
5783
|
+
// `collapsed` attribute here would re-enter the render (wc-contract).
|
|
5784
|
+
const now = this._legendCollapsed != null ? this._legendCollapsed : this.hasAttribute("collapsed");
|
|
5785
|
+
this._legendCollapsed = !now;
|
|
5786
|
+
this.requestRender();
|
|
5787
|
+
return;
|
|
5788
|
+
}
|
|
5670
5789
|
// Read selectable PER-CLICK (not captured in enhance): handler uses current value if attribute added/removed later (LS-5 behavioral break).
|
|
5671
5790
|
if (!this.hasAttribute("selectable")) return;
|
|
5672
5791
|
const btn = e.target && e.target.closest ? e.target.closest(".c-legend__item") : null;
|
|
@@ -5779,8 +5898,8 @@ define("contour-legend", ContourLegend);
|
|
|
5779
5898
|
* Attributes: `label`, `value`, `point`, `line`, `empty`, `loading`, `error`, `retry`, `src`, `lazy`, `refresh`, `timeout`, `skeleton`.
|
|
5780
5899
|
*/
|
|
5781
5900
|
class ContourMeasure extends ContourBase {
|
|
5782
|
-
static get observed() { return ["label", "value", "point", "line", "unit", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton", "cache-key", "no-cache"]; }
|
|
5783
|
-
static get properties() { return { label: { attribute: "label" }, value: { attribute: "value" }, point: { attribute: "point" }, line: { attribute: "line" }, unit: { attribute: "unit" }, src: { attribute: "src" } }; }
|
|
5901
|
+
static get observed() { return ["label", "unit-label", "value", "point", "line", "unit", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton", "cache-key", "no-cache"]; }
|
|
5902
|
+
static get properties() { return { label: { attribute: "label" }, "unit-label": { attribute: "unit-label" }, value: { attribute: "value" }, point: { attribute: "point" }, line: { attribute: "line" }, unit: { attribute: "unit" }, src: { attribute: "src" } }; }
|
|
5784
5903
|
render() {
|
|
5785
5904
|
this.classList.add("c-measure");
|
|
5786
5905
|
this.setAttribute("role", "group");
|
|
@@ -5812,7 +5931,9 @@ class ContourMeasure extends ContourBase {
|
|
|
5812
5931
|
}
|
|
5813
5932
|
// unit selector
|
|
5814
5933
|
let sel = this.querySelector(".c-measure__unit-select");
|
|
5815
|
-
if (!sel) { sel = document.createElement("select"); sel.className = "c-select c-measure__unit-select"; sel.setAttribute("
|
|
5934
|
+
if (!sel) { sel = document.createElement("select"); sel.className = "c-select c-measure__unit-select"; sel.setAttribute("data-contour-label", "true"); this.appendChild(sel); }
|
|
5935
|
+
// U-29: the unit select accepts an explicit accessible name.
|
|
5936
|
+
sel.setAttribute("aria-label", this.getAttribute("unit-label") || labelText(this, "unit", "Unit"));
|
|
5816
5937
|
["m","km","mi","ft"].forEach((u) => {
|
|
5817
5938
|
if (!sel.querySelector('option[value="' + u + '"]')) { const o = document.createElement("option"); o.value = u; o.textContent = u; sel.appendChild(o); }
|
|
5818
5939
|
});
|
|
@@ -5926,11 +6047,19 @@ class ContourTimeline extends ContourBase {
|
|
|
5926
6047
|
define("contour-timeline", ContourTimeline);
|
|
5927
6048
|
/**
|
|
5928
6049
|
* Heatmap: web component wrapper.
|
|
5929
|
-
* Attributes: `cells`, `count`, `
|
|
6050
|
+
* Attributes: `cells`, `count`, `columns`, `values`, `legend`, `empty`,
|
|
6051
|
+
* `loading`, `error`, `retry`, `src`, `lazy`, `refresh`, `timeout`, `skeleton`.
|
|
6052
|
+
*
|
|
6053
|
+
* Cell geometry is arbitrary: `columns` sets the row width (rows = ceil(cells /
|
|
6054
|
+
* columns)); without it the grid is as square as possible. `cells`/`count`
|
|
6055
|
+
* defaults to the length of `values`, so a flat value list defines the shape.
|
|
6056
|
+
* Large data is bounded by a documented **cell budget of 200**: beyond it the
|
|
6057
|
+
* render is sampled to the first 200 cells and `contour:cap` reports
|
|
6058
|
+
* `{ series: 1, total, shown }` so a consumer knows the grid was truncated.
|
|
5930
6059
|
*/
|
|
5931
6060
|
class ContourHeatmap extends ContourBase {
|
|
5932
|
-
static get observed() { return ["cells", "count", "legend", "brownout", "brownout-level", "empty", "loading", "values", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton", "cache-key", "dir", "no-cache"]; }
|
|
5933
|
-
static get properties() { return { cells: { attribute: "cells" }, count: { attribute: "count" }, legend: { attribute: "legend" }, src: { attribute: "src" } }; }
|
|
6061
|
+
static get observed() { return ["cells", "count", "columns", "legend", "brownout", "brownout-level", "empty", "loading", "values", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton", "cache-key", "dir", "no-cache"]; }
|
|
6062
|
+
static get properties() { return { cells: { attribute: "cells" }, count: { attribute: "count" }, columns: { attribute: "columns" }, legend: { attribute: "legend" }, src: { attribute: "src" } }; }
|
|
5934
6063
|
render() {
|
|
5935
6064
|
this.classList.add("c-heatmap");
|
|
5936
6065
|
if (!this.hasAttribute("role")) this.setAttribute("role", "grid");
|
|
@@ -5942,7 +6071,7 @@ class ContourHeatmap extends ContourBase {
|
|
|
5942
6071
|
// precedence over the generated grid.
|
|
5943
6072
|
const authoredCells = Array.from(this.querySelectorAll(":scope > .c-heatmap__cell"));
|
|
5944
6073
|
if (authoredCells.length) {
|
|
5945
|
-
const cols = Math.ceil(Math.sqrt(authoredCells.length));
|
|
6074
|
+
const cols = Math.max(1, parseInt(this.getAttribute("columns") || "0", 10) || Math.ceil(Math.sqrt(authoredCells.length)));
|
|
5946
6075
|
this.style.gridTemplateColumns = "repeat(" + cols + ", 1fr)";
|
|
5947
6076
|
this.style.inlineSize = "16rem";
|
|
5948
6077
|
// Wrap authored cells in rows so gridcells have a required row parent
|
|
@@ -5958,13 +6087,18 @@ class ContourHeatmap extends ContourBase {
|
|
|
5958
6087
|
});
|
|
5959
6088
|
} else {
|
|
5960
6089
|
Array.from(this.querySelectorAll(".c-heatmap__cell")).forEach((n) => n.remove());
|
|
5961
|
-
|
|
5962
|
-
|
|
6090
|
+
let values = [];
|
|
6091
|
+
try { values = JSON.parse(this.getAttribute("values") || "[]"); } catch (e) { values = []; }
|
|
6092
|
+
if (!Array.isArray(values)) values = [];
|
|
6093
|
+
const HEATMAP_CELL_CAP = 200;
|
|
6094
|
+
const declaredCount = parseInt(this.getAttribute("cells") || this.getAttribute("count") || "0", 10) || 0;
|
|
6095
|
+
const requested = declaredCount > 0 ? declaredCount : values.length;
|
|
6096
|
+
const count = Math.min(HEATMAP_CELL_CAP, Math.max(0, requested));
|
|
6097
|
+
const cols = count > 0 ? Math.max(1, parseInt(this.getAttribute("columns") || "0", 10) || Math.ceil(Math.sqrt(count))) : 1;
|
|
5963
6098
|
this.style.gridTemplateColumns = "repeat(" + cols + ", 1fr)";
|
|
5964
6099
|
this.style.inlineSize = "16rem";
|
|
6100
|
+
if (requested > HEATMAP_CELL_CAP) this.dispatchEvent(new CustomEvent("contour:cap", { bubbles: true, composed: true, detail: { series: 1, total: requested, shown: HEATMAP_CELL_CAP } }));
|
|
5965
6101
|
if (count > 0) {
|
|
5966
|
-
let values = [];
|
|
5967
|
-
try { values = JSON.parse(this.getAttribute("values") || "[]"); } catch (e) { values = []; }
|
|
5968
6102
|
// Value→colour (DC-2): cells were all `--color-surface-1` (white boxes); now normalised to --chart-seq-1..7 ramp via --c; non-numeric falls back to empty surface.
|
|
5969
6103
|
const nums = values.map((v) => {
|
|
5970
6104
|
const n = Number(v);
|