contour-ds 1.10.0 → 1.12.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/agent-map-wiring.json +2 -1
- package/dist/build-manifest.json +52 -52
- package/dist/contour-wc-content.esm.js +5 -0
- package/dist/contour-wc-core.esm.js +1 -1
- package/dist/contour-wc-core.esm.min.js +1 -1
- package/dist/contour-wc-dashboard.esm.js +173 -9
- package/dist/contour-wc-dashboard.esm.min.js +1 -1
- package/dist/contour-wc-data.esm.js +173 -9
- package/dist/contour-wc-data.esm.min.js +1 -1
- package/dist/contour-wc-docs.esm.js +5 -0
- package/dist/contour-wc-feedback.esm.js +5 -0
- package/dist/contour-wc-forms.esm.js +5 -0
- package/dist/contour-wc-interaction.esm.js +5 -0
- package/dist/contour-wc-layout.esm.js +5 -0
- package/dist/contour-wc-map.esm.js +110 -4
- package/dist/contour-wc-map.esm.min.js +1 -1
- package/dist/contour-wc-misc.esm.js +5 -0
- package/dist/contour-wc-navigation.esm.js +5 -0
- package/dist/contour-wc-ui.esm.js +82 -9
- package/dist/contour-wc-ui.esm.min.js +1 -1
- package/dist/contour-wc.esm.js +356 -23
- package/dist/contour-wc.esm.min.js +1 -1
- package/dist/contour-wc.js +356 -23
- package/dist/contour-wc.min.js +1 -1
- package/dist/contour.code-snippets +1 -1
- package/dist/contour.components.json +219 -35
- package/dist/contour.css +135 -0
- package/dist/contour.d.ts +55 -54
- package/dist/contour.html-data.json +40 -4
- 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 +40 -4
- package/dist/custom-elements.json +163 -1
- 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 +3 -1
- package/dist/docs/docs.md +1 -1
- package/dist/docs/feedback.md +1 -1
- package/dist/docs/field.md +1 -3
- 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/register.js +15 -0
- 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/data-chart.mjs +82 -5
- package/dist/wc/data-gauge.mjs +49 -4
- package/dist/wc/glyph.mjs +37 -0
- package/dist/wc/index.mjs +1 -1
- package/dist/wc/map.mjs +105 -4
- package/dist/wc/registration.mjs +5 -0
- package/dist/wc/ui-atoms.mjs +28 -7
- package/dist/wc/ui-data.mjs +49 -2
- package/integrations/libreship/contract.json +7 -2
- package/package.json +4 -1
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { CLASS_ONLY, CONTOUR_EVENTS, ContourBase, MERCATOR_MAX_LAT, MODS, OBSERVED, REGISTERED, applyLabel, bearing, clampLat, contourId, cssLength, define, flagOn, flagOnValue, formatValue, haversine, headingTag, iconMarkup, isRtl, labelText, levelFromAttributes, mercatorResolution, navKey, normaliseLng, onDispose, safeColor, safeHref, sanitizeHtml, setHTML, simple, statusIcon, supportsUntilFound, unwrapBounds, warnBadJson, wcEmitOverlay, withBrownout, PROPERTY_FIELDS, normalizeProperty, propertyDescriptor, propertyTypeOf, contourDiagnosticsEnabled, setContourDiagnostics, MARKER_SHAPES, arcPath, assignMarkers, barRects, compassNeedle, contourPaths, donutSlices, isMissing, marchingSquares, markerStyles, niceTicks, polylinePoints, scaleBarTicks, smoothPath, modalContain, wcReset, wireCombobox, wireCopy, wireMenu, wirePagination, wireRemovable, wireSegmented, wireTabs, wireTree, STATE_FALLBACK, loadRemote, parseArrayAttr, remoteData, remoteInvalidate, remoteRefresh, remoteVisible, renderEmpty, renderStates, stateLabel, virtualRange, watchViewport, wireStates } from "./contour-wc-core.esm.js";
|
|
2
2
|
|
|
3
3
|
// ---- Registration: class-only wrappers run last (define() skips claimed names) ----
|
|
4
|
+
// Layout atoms. Each is the element form of a layout primitive and is inert
|
|
5
|
+
// by design: no data attribute, no state, no events — the `c-*` class is the
|
|
6
|
+
// whole contract, and tools/check-layout.mjs pins the closed set. A
|
|
7
|
+
// `contour-cluster` is not a data component missing a payload; reach for a
|
|
8
|
+
// mark component (chart, legend, table) when the region carries data.
|
|
4
9
|
define("contour-box", simple(["c-box"]));
|
|
5
10
|
define("contour-cluster", simple(["c-cluster"]));
|
|
6
11
|
define("contour-container", simple(["c-container"]));
|
|
@@ -3102,13 +3107,24 @@ class ContourReferenceRule extends ContourBase {
|
|
|
3102
3107
|
|
|
3103
3108
|
/**
|
|
3104
3109
|
* Small Multiples (R33-45): a grid of charts that share axes. Attributes:
|
|
3105
|
-
* `columns` (grid column count) and `
|
|
3106
|
-
* responsive grid; the group is the shared-axis frame, the
|
|
3107
|
-
* individual multiples.
|
|
3110
|
+
* `columns` (grid column count), `label` and `multiples`. Slotted charts are
|
|
3111
|
+
* laid out in a responsive grid; the group is the shared-axis frame, the
|
|
3112
|
+
* children are the individual multiples.
|
|
3113
|
+
*
|
|
3114
|
+
* Data contract (U4): `multiples` is a JSON array of
|
|
3115
|
+
* `{ label, points, key?, value? }`. When it is present the frame renders one
|
|
3116
|
+
* cell per entry — a caption and an inline sparkline — so a consumer can drive
|
|
3117
|
+
* the grid from data without hand-authoring a child per multiple. Each cell is
|
|
3118
|
+
* a focusable `role="button"` that emits `contour:select` with
|
|
3119
|
+
* `{ index, key, label, value }`, where `value` defaults to the entry's last
|
|
3120
|
+
* finite point. When `multiples` is absent the frame is layout-only and slotted
|
|
3121
|
+
* children supply the marks, so the two forms are alternatives: a child that
|
|
3122
|
+
* selects bubbles its own `contour:select` through the frame, and a page still
|
|
3123
|
+
* listens once.
|
|
3108
3124
|
*/
|
|
3109
3125
|
class ContourSmallMultiples extends ContourBase {
|
|
3110
|
-
static get observed() { return ["columns", "label"]; }
|
|
3111
|
-
static get properties() { return { columns: { attribute: "columns", type: Number }, label: { attribute: "label" } }; }
|
|
3126
|
+
static get observed() { return ["columns", "label", "multiples"]; }
|
|
3127
|
+
static get properties() { return { columns: { attribute: "columns", type: Number }, label: { attribute: "label" }, multiples: { attribute: "multiples" } }; }
|
|
3112
3128
|
render() {
|
|
3113
3129
|
this.classList.add("c-small-multiples");
|
|
3114
3130
|
if (!this.hasAttribute("role")) this.setAttribute("role", "group");
|
|
@@ -3116,6 +3132,72 @@ class ContourSmallMultiples extends ContourBase {
|
|
|
3116
3132
|
if (label) this.setAttribute("aria-label", label); else this.removeAttribute("aria-label");
|
|
3117
3133
|
const cols = this.getAttribute("columns");
|
|
3118
3134
|
if (cols) this.style.setProperty("--sm-cols", cols); else this.style.removeProperty("--sm-cols");
|
|
3135
|
+
this._smEntries = null;
|
|
3136
|
+
const raw = this.getAttribute("multiples");
|
|
3137
|
+
if (!raw) return;
|
|
3138
|
+
let parsed;
|
|
3139
|
+
try { parsed = JSON.parse(raw); } catch (e) { return; } // malformed JSON leaves the frame layout-only
|
|
3140
|
+
if (!Array.isArray(parsed)) return;
|
|
3141
|
+
this._smEntries = parsed;
|
|
3142
|
+
parsed.forEach((entry, i) => this._renderCell(entry, i));
|
|
3143
|
+
}
|
|
3144
|
+
_renderCell(entry, index) {
|
|
3145
|
+
const item = entry && typeof entry === "object" ? entry : {};
|
|
3146
|
+
const points = Array.isArray(item.points) ? item.points.filter(Number.isFinite) : [];
|
|
3147
|
+
const name = item.label != null ? String(item.label) : `Multiple ${index + 1}`;
|
|
3148
|
+
const cell = document.createElement("figure");
|
|
3149
|
+
cell.className = "c-small-multiples__cell";
|
|
3150
|
+
cell.setAttribute("data-sm-index", String(index));
|
|
3151
|
+
cell.setAttribute("role", "button");
|
|
3152
|
+
cell.setAttribute("tabindex", "0");
|
|
3153
|
+
cell.setAttribute("aria-label", name);
|
|
3154
|
+
const cap = document.createElement("figcaption");
|
|
3155
|
+
cap.className = "c-small-multiples__label";
|
|
3156
|
+
cap.textContent = name;
|
|
3157
|
+
cell.appendChild(cap);
|
|
3158
|
+
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
3159
|
+
svg.setAttribute("class", "c-small-multiples__mark");
|
|
3160
|
+
svg.setAttribute("viewBox", "0 0 100 30");
|
|
3161
|
+
svg.setAttribute("preserveAspectRatio", "none");
|
|
3162
|
+
svg.setAttribute("aria-hidden", "true");
|
|
3163
|
+
if (points.length >= 2) {
|
|
3164
|
+
const min = Math.min(...points);
|
|
3165
|
+
const range = (Math.max(...points) - min) || 1;
|
|
3166
|
+
const n = points.length;
|
|
3167
|
+
const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
3168
|
+
path.setAttribute("d", points.map((p, i) => (i === 0 ? "M" : "L") + " " + (i * 100 / (n - 1)) + " " + (30 - ((p - min) / range) * 30)).join(" "));
|
|
3169
|
+
svg.appendChild(path);
|
|
3170
|
+
}
|
|
3171
|
+
cell.appendChild(svg);
|
|
3172
|
+
this.appendChild(cell);
|
|
3173
|
+
}
|
|
3174
|
+
enhance() {
|
|
3175
|
+
if (this._wiredSmallMultiples) return;
|
|
3176
|
+
this._wiredSmallMultiples = true;
|
|
3177
|
+
// Delegated on the host (rule 12): render() rebuilds the cells on every
|
|
3178
|
+
// attribute change, so a listener bound to a cell would be lost.
|
|
3179
|
+
const select = (e) => {
|
|
3180
|
+
const cell = e.target && e.target.closest ? e.target.closest(".c-small-multiples__cell[data-sm-index]") : null;
|
|
3181
|
+
if (!cell || !this.contains(cell)) return;
|
|
3182
|
+
const index = Number(cell.getAttribute("data-sm-index"));
|
|
3183
|
+
const entry = (this._smEntries || [])[index] || {};
|
|
3184
|
+
const points = Array.isArray(entry.points) ? entry.points.filter(Number.isFinite) : [];
|
|
3185
|
+
const value = entry.value != null ? entry.value : (points.length ? points[points.length - 1] : null);
|
|
3186
|
+
this.dispatchEvent(new CustomEvent("contour:select", { bubbles: true, composed: true, detail: {
|
|
3187
|
+
index,
|
|
3188
|
+
key: entry.key != null ? entry.key : null,
|
|
3189
|
+
label: entry.label != null ? String(entry.label) : "",
|
|
3190
|
+
value,
|
|
3191
|
+
} }));
|
|
3192
|
+
};
|
|
3193
|
+
this.addEventListener("click", select);
|
|
3194
|
+
this.addEventListener("keydown", (e) => {
|
|
3195
|
+
if (e.key !== "Enter" && e.key !== " ") return;
|
|
3196
|
+
const cell = e.target && e.target.closest ? e.target.closest(".c-small-multiples__cell[data-sm-index]") : null;
|
|
3197
|
+
if (!cell || !this.contains(cell)) return;
|
|
3198
|
+
e.preventDefault();
|
|
3199
|
+
select(e);
|
|
3200
|
+
});
|
|
3119
3201
|
}
|
|
3120
3202
|
}
|
|
3121
3203
|
define("contour-small-multiples", ContourSmallMultiples);
|
|
@@ -3693,8 +3775,9 @@ class ContourStackedBar extends ContourBase {
|
|
|
3693
3775
|
static get properties() { return { segments: { attribute: "segments" }, values: { attribute: "values" }, colors: { attribute: "colors" }, src: { attribute: "src" }, max: { attribute: "max" } }; }
|
|
3694
3776
|
render() {
|
|
3695
3777
|
this.classList.add("c-stacked-bar");
|
|
3696
|
-
// The
|
|
3697
|
-
//
|
|
3778
|
+
// The segments are selectable marks, not decoration: role=img would make
|
|
3779
|
+
// them presentational, so a named group holds focusable buttons and
|
|
3780
|
+
// `enhance()` emits `contour:select` (same contract as time-series).
|
|
3698
3781
|
if (!this.hasAttribute("role")) this.setAttribute("role", "group");
|
|
3699
3782
|
if (!this.hasAttribute("aria-label")) this.setAttribute("aria-label", labelText(this, "stacked-bar", "Stacked bar"));
|
|
3700
3783
|
wireStates(this);
|
|
@@ -3733,7 +3816,11 @@ class ContourStackedBar extends ContourBase {
|
|
|
3733
3816
|
el.dataset.color = (typeof seg === "object" && seg.color) ? seg.color : el.style.background;
|
|
3734
3817
|
const label = typeof seg === "object" ? (seg.label || "") : "";
|
|
3735
3818
|
el.setAttribute("data-title", label + " " + v);
|
|
3736
|
-
el.
|
|
3819
|
+
el.dataset.index = String(i);
|
|
3820
|
+
el.dataset.value = String(v);
|
|
3821
|
+
el.dataset.label = label;
|
|
3822
|
+
el.setAttribute("role", "button");
|
|
3823
|
+
el.setAttribute("tabindex", "-1");
|
|
3737
3824
|
el.setAttribute("aria-label", (label ? label + ": " : "") + v);
|
|
3738
3825
|
return el;
|
|
3739
3826
|
};
|
|
@@ -3759,8 +3846,48 @@ class ContourStackedBar extends ContourBase {
|
|
|
3759
3846
|
this.appendChild(track);
|
|
3760
3847
|
}
|
|
3761
3848
|
if (!segments.length) renderEmpty(this, "stacked-bar");
|
|
3849
|
+
// Roving entry point: one tab stop for the stack, arrows move within it.
|
|
3850
|
+
const marks = this.querySelectorAll(".c-stacked-bar__segment");
|
|
3851
|
+
marks.forEach((el, i) => el.setAttribute("tabindex", i === 0 ? "0" : "-1"));
|
|
3852
|
+
}
|
|
3853
|
+
enhance() {
|
|
3854
|
+
if (this._wiredStackedBar) return;
|
|
3855
|
+
this._wiredStackedBar = true;
|
|
3856
|
+
const marks = () => Array.from(this.querySelectorAll(".c-stacked-bar__segment"));
|
|
3857
|
+
const emit = (mark) => {
|
|
3858
|
+
this.dispatchEvent(new CustomEvent("contour:select", {
|
|
3859
|
+
bubbles: true,
|
|
3860
|
+
composed: true,
|
|
3861
|
+
detail: {
|
|
3862
|
+
index: Number(mark.dataset.index || "0"),
|
|
3863
|
+
key: mark.dataset.label || String(mark.dataset.index || "0"),
|
|
3864
|
+
label: mark.dataset.label || "",
|
|
3865
|
+
value: Number(mark.dataset.value || "0"),
|
|
3866
|
+
},
|
|
3867
|
+
}));
|
|
3868
|
+
};
|
|
3869
|
+
this.addEventListener("click", (e) => {
|
|
3870
|
+
const mark = e.target && e.target.closest ? e.target.closest(".c-stacked-bar__segment") : null;
|
|
3871
|
+
if (!mark || !this.contains(mark)) return;
|
|
3872
|
+
emit(mark);
|
|
3873
|
+
});
|
|
3874
|
+
this.addEventListener("keydown", (e) => {
|
|
3875
|
+
const mark = e.target && e.target.closest ? e.target.closest(".c-stacked-bar__segment") : null;
|
|
3876
|
+
if (!mark || !this.contains(mark)) return;
|
|
3877
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
3878
|
+
e.preventDefault();
|
|
3879
|
+
emit(mark);
|
|
3880
|
+
return;
|
|
3881
|
+
}
|
|
3882
|
+
const all = marks();
|
|
3883
|
+
navKey(e, all, {
|
|
3884
|
+
wrap: false,
|
|
3885
|
+
homeEnd: true,
|
|
3886
|
+
rtl: isRtl(this),
|
|
3887
|
+
onNavigate: (i) => all.forEach((m, j) => m.setAttribute("tabindex", j === i ? "0" : "-1")),
|
|
3888
|
+
});
|
|
3889
|
+
});
|
|
3762
3890
|
}
|
|
3763
|
-
enhance() {}
|
|
3764
3891
|
}
|
|
3765
3892
|
define("contour-stacked-bar", ContourStackedBar);
|
|
3766
3893
|
/**
|
|
@@ -6968,6 +7095,43 @@ export function paintPurityRing(ctx, {
|
|
|
6968
7095
|
}
|
|
6969
7096
|
}
|
|
6970
7097
|
|
|
7098
|
+
/**
|
|
7099
|
+
* Paint a purity ring into an `ImageData` buffer for sprite atlases.
|
|
7100
|
+
*
|
|
7101
|
+
* A MapLibre `addImage()` / sprite sheet wants pixels, not a live 2D context.
|
|
7102
|
+
* This allocates a canvas (an `OffscreenCanvas` in a worker, else a detached
|
|
7103
|
+
* `<canvas>`), paints the SAME ring `paintPurityRing` draws, and returns its
|
|
7104
|
+
* ImageData. Pass `opts.canvas` to reuse an atlas tile.
|
|
7105
|
+
*
|
|
7106
|
+
* It is the Contour visual, not every visual a consumer may already have: this
|
|
7107
|
+
* ring is a stroked track plus a stroked arc, whereas Libreship's atlas painter
|
|
7108
|
+
* draws a filled wedge. Migrating a wedge atlas therefore still needs that
|
|
7109
|
+
* painter or a deliberate visual change — the entry point removes the context
|
|
7110
|
+
* plumbing, not the design difference (LIBRESHIP.md §9.2).
|
|
7111
|
+
*
|
|
7112
|
+
* @param {object} [opts] same options as `paintPurityRing`, plus `canvas`.
|
|
7113
|
+
* @returns {ImageData}
|
|
7114
|
+
*/
|
|
7115
|
+
export function paintPurityRingPixels(opts = {}) {
|
|
7116
|
+
const size = Number(opts.size) || 32;
|
|
7117
|
+
let canvas = opts.canvas;
|
|
7118
|
+
if (!canvas) {
|
|
7119
|
+
if (typeof OffscreenCanvas !== "undefined") {
|
|
7120
|
+
canvas = new OffscreenCanvas(size, size);
|
|
7121
|
+
} else if (typeof document !== "undefined") {
|
|
7122
|
+
canvas = document.createElement("canvas");
|
|
7123
|
+
canvas.width = size;
|
|
7124
|
+
canvas.height = size;
|
|
7125
|
+
} else {
|
|
7126
|
+
throw new Error("paintPurityRingPixels: no OffscreenCanvas or document — pass opts.canvas");
|
|
7127
|
+
}
|
|
7128
|
+
}
|
|
7129
|
+
const ctx = canvas.getContext("2d");
|
|
7130
|
+
if (!ctx) throw new Error("paintPurityRingPixels: canvas.getContext('2d') returned null");
|
|
7131
|
+
paintPurityRing(ctx, { ...opts, size });
|
|
7132
|
+
return ctx.getImageData(0, 0, size, size);
|
|
7133
|
+
}
|
|
7134
|
+
|
|
6971
7135
|
|
|
6972
7136
|
/**
|
|
6973
7137
|
* Dashboard state machine (R13-06).
|