contour-ds 1.9.0 → 1.10.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 +4 -4
- package/dist/build-manifest.json +205 -204
- package/dist/contour-wc-content.esm.js +1 -1
- package/dist/contour-wc-content.esm.min.js +1 -1
- package/dist/contour-wc-core.esm.js +712 -45
- package/dist/contour-wc-core.esm.min.js +1 -1
- package/dist/contour-wc-dashboard.esm.js +596 -90
- package/dist/contour-wc-dashboard.esm.min.js +1 -1
- package/dist/contour-wc-data.esm.js +467 -70
- package/dist/contour-wc-data.esm.min.js +1 -1
- package/dist/contour-wc-docs.esm.js +1 -1
- package/dist/contour-wc-docs.esm.min.js +1 -1
- package/dist/contour-wc-feedback.esm.js +260 -29
- package/dist/contour-wc-feedback.esm.min.js +1 -1
- package/dist/contour-wc-forms.esm.js +133 -40
- package/dist/contour-wc-forms.esm.min.js +1 -1
- package/dist/contour-wc-interaction.esm.js +64 -5
- package/dist/contour-wc-interaction.esm.min.js +1 -1
- package/dist/contour-wc-layout.esm.js +72 -10
- package/dist/contour-wc-layout.esm.min.js +1 -1
- package/dist/contour-wc-map.esm.js +69 -9
- package/dist/contour-wc-map.esm.min.js +1 -1
- package/dist/contour-wc-misc.esm.js +1 -1
- package/dist/contour-wc-misc.esm.min.js +1 -1
- package/dist/contour-wc-navigation.esm.js +136 -20
- package/dist/contour-wc-navigation.esm.min.js +1 -1
- package/dist/contour-wc-ui.esm.js +505 -80
- package/dist/contour-wc-ui.esm.min.js +1 -1
- package/dist/contour-wc.esm.js +2539 -320
- package/dist/contour-wc.esm.min.js +1 -1
- package/dist/contour-wc.js +2539 -320
- package/dist/contour-wc.min.js +1 -1
- package/dist/contour.code-snippets +44 -0
- package/dist/contour.components.json +12064 -135
- package/dist/contour.css +1368 -451
- package/dist/contour.d.ts +42 -21
- package/dist/contour.esm.js +138 -21
- package/dist/contour.esm.min.js +1 -1
- package/dist/contour.html-data.json +249 -9
- package/dist/contour.js +138 -21
- package/dist/contour.min.css +1 -1
- package/dist/contour.min.js +1 -1
- package/dist/contour.react.d.ts +5 -1
- package/dist/contour.single.html +2 -2
- package/dist/contour.single.min.css +1 -1
- package/dist/contour.tokens.json +36 -1
- package/dist/contour.vue.d.ts +5 -1
- package/dist/contour.web-types.json +241 -9
- package/dist/custom-elements.json +1225 -55
- 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 +6 -2
- 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 +8 -8
- 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 +5 -2
- package/dist/docs/type.md +1 -1
- package/dist/docs/webcomponents.md +1 -1
- package/dist/hljs.css +34 -17
- package/dist/map-chrome-contract.json +26 -0
- package/dist/map-chrome.mapbox.css +121 -0
- package/dist/map-chrome.maplibre.css +121 -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/behaviours.mjs +11 -3
- package/dist/wc/core.mjs +307 -32
- package/dist/wc/dashboard.mjs +129 -20
- package/dist/wc/data-chart.mjs +170 -22
- package/dist/wc/data-export.mjs +150 -29
- package/dist/wc/data-gauge.mjs +11 -4
- package/dist/wc/data-geo.mjs +1 -1
- package/dist/wc/data-legend.mjs +15 -2
- package/dist/wc/data-readout.mjs +12 -1
- package/dist/wc/data-series.mjs +73 -5
- package/dist/wc/data-table.mjs +37 -8
- package/dist/wc/feedback.mjs +259 -28
- package/dist/wc/forms-controls.mjs +44 -16
- package/dist/wc/forms-field.mjs +46 -4
- package/dist/wc/forms-groups.mjs +31 -8
- package/dist/wc/forms-input.mjs +11 -11
- package/dist/wc/index.mjs +1 -1
- package/dist/wc/interaction.mjs +63 -4
- package/dist/wc/layout.mjs +72 -10
- package/dist/wc/map.mjs +68 -8
- package/dist/wc/navigation-menu.mjs +43 -9
- package/dist/wc/navigation-shell.mjs +39 -6
- package/dist/wc/navigation-tree.mjs +53 -4
- package/dist/wc/states.mjs +350 -9
- package/dist/wc/svg.mjs +43 -0
- package/dist/wc/ui-data.mjs +268 -28
- package/dist/wc/ui-feedback.mjs +36 -11
- package/dist/wc/ui-inputs.mjs +63 -25
- package/dist/wc/ui-overlays.mjs +138 -16
- package/integrations/ai/v0-prompt.md +1 -1
- package/integrations/frameworks/fixtures/authored/sample.jsx +15 -0
- package/integrations/frameworks/fixtures/authored/sample.vue +15 -0
- package/integrations/frameworks/fixtures/dist/rendered.html +32 -0
- package/integrations/libreship/contract.json +1025 -0
- package/integrations/native/README.md +24 -4
- package/integrations/native/build/android/colors.xml +278 -0
- package/integrations/native/build/flutter/contour_tokens.dart +280 -0
- package/integrations/native/build/ios/ContourTokens.swift +280 -0
- package/integrations/validate-markup.mjs +57 -7
- package/package.json +45 -18
package/dist/wc/dashboard.mjs
CHANGED
|
@@ -10,6 +10,12 @@ import { ContourBase, define, formatValue, navKey , warnBadJson, labelText, appl
|
|
|
10
10
|
* stale -> data present but older than the freshness threshold
|
|
11
11
|
* ready -> data present and current (default)
|
|
12
12
|
*
|
|
13
|
+
* Analysis overlays (R34-162): on top of the load lifecycle a widget may be
|
|
14
|
+
* loading/stale/partial/filtered/selected/locked/pinned. That vocabulary is
|
|
15
|
+
* shared (states.mjs `ANALYSIS_STATES`): contour-widget-state reflects it as
|
|
16
|
+
* `data-analysis-state` and announces the label, so a dashboard shell badges
|
|
17
|
+
* every widget with one set of words rather than per-widget inventions.
|
|
18
|
+
*
|
|
13
19
|
* Components that participate:
|
|
14
20
|
* - contour-widget-state : renders the state chrome (loading/empty/error)
|
|
15
21
|
* via its `state` attribute; emits `contour:retry` on retry click.
|
|
@@ -209,8 +215,8 @@ class ContourDashFreshness extends ContourBase {
|
|
|
209
215
|
}
|
|
210
216
|
define("contour-dash-freshness", ContourDashFreshness);
|
|
211
217
|
class ContourSavedView extends ContourBase {
|
|
212
|
-
static get observed() { return ["name", "updated", "source", "active"]; }
|
|
213
|
-
static get properties() { return { name: { attribute: "name" }, updated: { attribute: "updated" }, source: { attribute: "source" }, active: { attribute: "active", type: Boolean } }; }
|
|
218
|
+
static get observed() { return ["name", "updated", "source", "active", "dirty", "conflict", "default"]; }
|
|
219
|
+
static get properties() { return { name: { attribute: "name" }, updated: { attribute: "updated" }, source: { attribute: "source" }, active: { attribute: "active", type: Boolean }, dirty: { attribute: "dirty", type: Boolean }, conflict: { attribute: "conflict", type: Boolean }, "default": { attribute: "default", type: Boolean } }; }
|
|
214
220
|
render() {
|
|
215
221
|
this.classList.add("c-saved-view");
|
|
216
222
|
this.setAttribute("role", "region");
|
|
@@ -237,7 +243,22 @@ class ContourSavedView extends ContourBase {
|
|
|
237
243
|
const updated = this.getAttribute("updated");
|
|
238
244
|
const source = this.getAttribute("source");
|
|
239
245
|
meta.replaceChildren();
|
|
246
|
+
// R34-163: lifecycle badges. Default/dirty/conflict are shape+word, never
|
|
247
|
+
// colour alone; they lead the meta line so a shell reads the view's state
|
|
248
|
+
// before its provenance.
|
|
249
|
+
const badges = [];
|
|
250
|
+
if (this.hasAttribute("default")) badges.push(labelText(this, "default", "Default"));
|
|
251
|
+
if (this.hasAttribute("dirty")) badges.push(labelText(this, "dirty", "Unsaved"));
|
|
252
|
+
if (this.hasAttribute("conflict")) badges.push(labelText(this, "conflict", "Conflict"));
|
|
253
|
+
badges.forEach((text, i) => {
|
|
254
|
+
if (i > 0 || updated || source) meta.appendChild(document.createTextNode(" · "));
|
|
255
|
+
const wrap = document.createElement("span");
|
|
256
|
+
wrap.className = "c-saved-view__badge";
|
|
257
|
+
wrap.textContent = text;
|
|
258
|
+
meta.appendChild(wrap);
|
|
259
|
+
});
|
|
240
260
|
if (updated) {
|
|
261
|
+
if (meta.childNodes.length) meta.appendChild(document.createTextNode(" · "));
|
|
241
262
|
const wrap = document.createElement("span");
|
|
242
263
|
wrap.textContent = `Updated ${updated}`;
|
|
243
264
|
meta.appendChild(wrap);
|
|
@@ -253,6 +274,21 @@ class ContourSavedView extends ContourBase {
|
|
|
253
274
|
// Controls matched by data-*, not text (localisation + R18-80 defect).
|
|
254
275
|
const apply = actions.querySelector(".c-saved-view__apply") || (() => { const b = document.createElement("button"); b.type = "button"; b.className = "c-btn c-btn--ghost c-btn--sm"; b.setAttribute("data-saved-view-apply", ""); actions.appendChild(b); return b; })();
|
|
255
276
|
applyLabel(apply, this, "apply", "Apply");
|
|
277
|
+
// R34-163: full lifecycle actions — rename, duplicate, share, and a
|
|
278
|
+
// default toggle — alongside apply/remove. Each is a small ghost button
|
|
279
|
+
// with an accessible name; the host owns the actual create/rename/share.
|
|
280
|
+
const lifecycle = [
|
|
281
|
+
["rename", "rename", "Rename"],
|
|
282
|
+
["duplicate", "duplicate", "Duplicate"],
|
|
283
|
+
["share", "share", "Share"],
|
|
284
|
+
];
|
|
285
|
+
lifecycle.forEach(([key, labelKey, fallback]) => {
|
|
286
|
+
const btn = actions.querySelector(`.c-saved-view__${key}`) || (() => { const b = document.createElement("button"); b.type = "button"; b.className = "c-btn c-btn--ghost c-btn--sm"; b.setAttribute(`data-saved-view-${key}`, ""); actions.appendChild(b); return b; })();
|
|
287
|
+
applyLabel(btn, this, labelKey, fallback);
|
|
288
|
+
});
|
|
289
|
+
const defBtn = actions.querySelector(".c-saved-view__default") || (() => { const b = document.createElement("button"); b.type = "button"; b.className = "c-btn c-btn--ghost c-btn--sm"; b.setAttribute("data-saved-view-default", ""); actions.appendChild(b); return b; })();
|
|
290
|
+
applyLabel(defBtn, this, "default", "Set as default");
|
|
291
|
+
defBtn.setAttribute("aria-pressed", this.hasAttribute("default") ? "true" : "false");
|
|
256
292
|
const remove = actions.querySelector(".c-saved-view__remove") || (() => { const b = document.createElement("button"); b.type = "button"; b.className = "c-btn c-btn--ghost c-btn--sm"; b.setAttribute("data-saved-view-remove", ""); actions.appendChild(b); return b; })();
|
|
257
293
|
applyLabel(remove, this, "remove", "Remove");
|
|
258
294
|
}
|
|
@@ -262,10 +298,20 @@ class ContourSavedView extends ContourBase {
|
|
|
262
298
|
this.addEventListener("click", (e) => {
|
|
263
299
|
const btn = e.target && e.target.closest ? e.target.closest("button") : null;
|
|
264
300
|
if (!btn || !this.contains(btn)) return;
|
|
301
|
+
const name = this.getAttribute("name");
|
|
265
302
|
if (btn.hasAttribute("data-saved-view-apply")) {
|
|
266
|
-
this.dispatchEvent(new CustomEvent("contour:apply", { bubbles: true, composed: true, detail: { name
|
|
303
|
+
this.dispatchEvent(new CustomEvent("contour:apply", { bubbles: true, composed: true, detail: { name } }));
|
|
267
304
|
} else if (btn.hasAttribute("data-saved-view-remove")) {
|
|
268
|
-
this.dispatchEvent(new CustomEvent("contour:remove", { bubbles: true, composed: true, detail: { name
|
|
305
|
+
this.dispatchEvent(new CustomEvent("contour:remove", { bubbles: true, composed: true, detail: { name } }));
|
|
306
|
+
} else if (btn.hasAttribute("data-saved-view-rename")) {
|
|
307
|
+
this.dispatchEvent(new CustomEvent("contour:rename", { bubbles: true, composed: true, detail: { name } }));
|
|
308
|
+
} else if (btn.hasAttribute("data-saved-view-duplicate")) {
|
|
309
|
+
this.dispatchEvent(new CustomEvent("contour:duplicate", { bubbles: true, composed: true, detail: { name } }));
|
|
310
|
+
} else if (btn.hasAttribute("data-saved-view-share")) {
|
|
311
|
+
this.dispatchEvent(new CustomEvent("contour:share", { bubbles: true, composed: true, detail: { name } }));
|
|
312
|
+
} else if (btn.hasAttribute("data-saved-view-default")) {
|
|
313
|
+
const next = !this.hasAttribute("default");
|
|
314
|
+
this.dispatchEvent(new CustomEvent("contour:default", { bubbles: true, composed: true, detail: { name, default: next } }));
|
|
269
315
|
}
|
|
270
316
|
});
|
|
271
317
|
}
|
|
@@ -337,9 +383,79 @@ class ContourProvenance extends ContourBase {
|
|
|
337
383
|
}
|
|
338
384
|
}
|
|
339
385
|
define("contour-provenance", ContourProvenance);
|
|
386
|
+
/** Parse a JSON object attribute into a plain map, or {} when absent/invalid. */
|
|
387
|
+
function parseJsonMap(raw) {
|
|
388
|
+
if (!raw) return {};
|
|
389
|
+
try { const v = JSON.parse(raw); return (v && typeof v === "object" && !Array.isArray(v)) ? v : {}; }
|
|
390
|
+
catch (e) { return {}; }
|
|
391
|
+
}
|
|
392
|
+
/** True for a GeoJSON-style geometry object (rendered as a scalar, not a group). */
|
|
393
|
+
function isGeometryObject(v) {
|
|
394
|
+
return !!(v && typeof v === "object" && !Array.isArray(v) && typeof v.type === "string" && ("coordinates" in v || "geometry" in v || "features" in v));
|
|
395
|
+
}
|
|
396
|
+
/** Render one inspector field (group/list/scalar) into `container` (R34-167). */
|
|
397
|
+
function addInspectorFields(container, data, ctx, depth) {
|
|
398
|
+
for (const [k, v] of Object.entries(data)) {
|
|
399
|
+
if (v && typeof v === "object" && !Array.isArray(v) && !isGeometryObject(v)) {
|
|
400
|
+
const group = document.createElement("div");
|
|
401
|
+
group.className = "c-feature-inspector__group";
|
|
402
|
+
const head = document.createElement("div");
|
|
403
|
+
head.className = "c-feature-inspector__group-label";
|
|
404
|
+
head.textContent = k;
|
|
405
|
+
group.appendChild(head);
|
|
406
|
+
addInspectorFields(group, v, ctx, depth + 1);
|
|
407
|
+
container.appendChild(group);
|
|
408
|
+
continue;
|
|
409
|
+
}
|
|
410
|
+
const field = document.createElement("div");
|
|
411
|
+
field.className = "c-feature-inspector__field";
|
|
412
|
+
const label = document.createElement("span");
|
|
413
|
+
label.className = "c-feature-inspector__label";
|
|
414
|
+
label.textContent = k;
|
|
415
|
+
const value = document.createElement("span");
|
|
416
|
+
value.className = "c-feature-inspector__value";
|
|
417
|
+
if (Array.isArray(v)) {
|
|
418
|
+
const list = document.createElement("ul");
|
|
419
|
+
list.className = "c-feature-inspector__list";
|
|
420
|
+
v.forEach((item) => {
|
|
421
|
+
const li = document.createElement("li");
|
|
422
|
+
li.textContent = (item && typeof item === "object") ? JSON.stringify(item) : String(item);
|
|
423
|
+
list.appendChild(li);
|
|
424
|
+
});
|
|
425
|
+
value.appendChild(list);
|
|
426
|
+
} else {
|
|
427
|
+
const type = ctx.types[k];
|
|
428
|
+
let text;
|
|
429
|
+
if (type === "timestamp" && v) { const d = new Date(v); text = Number.isNaN(d.getTime()) ? String(v) : d.toISOString(); }
|
|
430
|
+
else if (type === "geometry" || isGeometryObject(v)) text = geometrySummary(v);
|
|
431
|
+
else text = String(v);
|
|
432
|
+
if (ctx.units[k]) text += " " + ctx.units[k];
|
|
433
|
+
value.textContent = text;
|
|
434
|
+
if (ctx.conf[k] != null && ctx.conf[k] !== "") {
|
|
435
|
+
const bar = document.createElement("span");
|
|
436
|
+
bar.className = "c-feature-inspector__confidence";
|
|
437
|
+
bar.setAttribute("role", "img");
|
|
438
|
+
bar.setAttribute("aria-label", `Confidence ${ctx.conf[k]}`);
|
|
439
|
+
bar.dataset.confidence = String(ctx.conf[k]);
|
|
440
|
+
value.appendChild(document.createTextNode(" "));
|
|
441
|
+
value.appendChild(bar);
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
field.appendChild(label);
|
|
445
|
+
field.appendChild(value);
|
|
446
|
+
container.appendChild(field);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
/** Compact one-line summary of a geometry object (R34-167). */
|
|
450
|
+
function geometrySummary(v) {
|
|
451
|
+
if (!v || typeof v !== "object") return String(v);
|
|
452
|
+
if (v.type === "Point" && Array.isArray(v.coordinates)) return `Point (${v.coordinates.join(", ")})`;
|
|
453
|
+
if (Array.isArray(v.coordinates)) return `${v.type || "Geometry"} (${v.coordinates.length} pts)`;
|
|
454
|
+
return v.type || "Geometry";
|
|
455
|
+
}
|
|
340
456
|
class ContourFeatureInspector extends ContourBase {
|
|
341
|
-
static get observed() { return ["title", "open", "data", "actions"]; }
|
|
342
|
-
static get properties() { return { title: { attribute: "title" }, open: { attribute: "open", type: Boolean }, data: { attribute: "data" } }; }
|
|
457
|
+
static get observed() { return ["title", "open", "data", "actions", "units", "types", "confidence"]; }
|
|
458
|
+
static get properties() { return { title: { attribute: "title" }, open: { attribute: "open", type: Boolean }, data: { attribute: "data" }, units: { attribute: "units" }, types: { attribute: "types" }, confidence: { attribute: "confidence" } }; }
|
|
343
459
|
render() {
|
|
344
460
|
this.classList.add("c-feature-inspector");
|
|
345
461
|
if (!this.hasAttribute("role")) this.setAttribute("role", "region");
|
|
@@ -360,21 +476,14 @@ class ContourFeatureInspector extends ContourBase {
|
|
|
360
476
|
if (data) {
|
|
361
477
|
try {
|
|
362
478
|
const parsed = JSON.parse(data);
|
|
363
|
-
//
|
|
479
|
+
// R34-167: rich field schema. A plain object becomes a group (recursive), an
|
|
480
|
+
// array becomes a list, and a scalar is formatted by `types` (timestamp/
|
|
481
|
+
// geometry), suffixed by `units`, and badged with `confidence`.
|
|
364
482
|
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
label.className = "c-feature-inspector__label";
|
|
370
|
-
label.textContent = k;
|
|
371
|
-
const value = document.createElement("span");
|
|
372
|
-
value.className = "c-feature-inspector__value";
|
|
373
|
-
value.textContent = String(v);
|
|
374
|
-
field.appendChild(label);
|
|
375
|
-
field.appendChild(value);
|
|
376
|
-
body.appendChild(field);
|
|
377
|
-
}
|
|
483
|
+
const units = parseJsonMap(this.getAttribute("units"));
|
|
484
|
+
const types = parseJsonMap(this.getAttribute("types"));
|
|
485
|
+
const conf = parseJsonMap(this.getAttribute("confidence"));
|
|
486
|
+
addInspectorFields(body, parsed, { units, types, conf }, 0);
|
|
378
487
|
}
|
|
379
488
|
} catch (e) { warnBadJson(this, "attribute", e); }
|
|
380
489
|
}
|
package/dist/wc/data-chart.mjs
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import { setHTML, ContourBase, define, onDispose, formatValue, contourId, navKey, isRtl, cssLength , safeColor, warnBadJson, labelText } from './core.mjs';
|
|
2
2
|
import { loadRemote, remoteData, renderStates, renderEmpty, wireStates, remoteInvalidate, watchViewport, parseArrayAttr, stateLabel } from './states.mjs';
|
|
3
|
-
import { donutSlices, barRects, smoothPath, polylinePoints, contourPaths, niceTicks, isMissing } from './svg.mjs';
|
|
3
|
+
import { donutSlices, barRects, smoothPath, polylinePoints, contourPaths, niceTicks, isMissing, decimateMinMax } from './svg.mjs';
|
|
4
4
|
import { paintDonutGlyph, paintSparklineGlyph, paintPurityRing } from './glyph.mjs';
|
|
5
5
|
|
|
6
6
|
const STREAM_BUFFER_MAX = 600;
|
|
7
7
|
const capBuffer = (arr, max = STREAM_BUFFER_MAX) => {
|
|
8
8
|
if (!Array.isArray(arr) || arr.length <= max) return arr;
|
|
9
|
+
// R32-12: a numeric series is reduced with extrema-preserving buckets, so a
|
|
10
|
+
// short spike survives the 600-point cap instead of being stepped over by a
|
|
11
|
+
// fixed stride. Non-numeric payloads (histogram bins) keep the stride.
|
|
12
|
+
if (arr.every((v) => typeof v === "number" && Number.isFinite(v))) return decimateMinMax(arr, max);
|
|
9
13
|
const step = Math.ceil(arr.length / max);
|
|
10
14
|
const out = [];
|
|
11
15
|
for (let i = 0; i < arr.length; i += step) out.push(arr[i]);
|
|
@@ -100,6 +104,28 @@ class ContourChart extends ContourBase {
|
|
|
100
104
|
_showsBrush() {
|
|
101
105
|
return this.hasAttribute("brush") || this._rangeOverride !== undefined;
|
|
102
106
|
}
|
|
107
|
+
// R34-53: nearest-mark hit tolerance. Given a pointer position, return the
|
|
108
|
+
// closest visible mark within `tol` px — a mark whose box contains the
|
|
109
|
+
// pointer wins outright (a tall bar's centre is far from a click near its
|
|
110
|
+
// top), otherwise the nearest mark centre. Unlaid-out boxes (jsdom, a hidden
|
|
111
|
+
// plot) are skipped so a zero-size rect never captures a tap.
|
|
112
|
+
_nearestMark(clientX, clientY, tol = 22) {
|
|
113
|
+
const plot = this.querySelector(".c-chart__plot");
|
|
114
|
+
if (!plot) return null;
|
|
115
|
+
const marks = plot.querySelectorAll(".c-chart__bar, .c-chart__point, .c-donut__slice");
|
|
116
|
+
let best = null;
|
|
117
|
+
let bestScore = tol;
|
|
118
|
+
for (const m of marks) {
|
|
119
|
+
if (m.getAttribute("aria-hidden") === "true") continue;
|
|
120
|
+
const r = m.getBoundingClientRect();
|
|
121
|
+
if (!r.width && !r.height) continue;
|
|
122
|
+
const inside = clientX >= r.left && clientX <= r.right && clientY >= r.top && clientY <= r.bottom;
|
|
123
|
+
const centre = Math.hypot(clientX - (r.left + r.width / 2), clientY - (r.top + r.height / 2));
|
|
124
|
+
const score = inside ? 0 : centre;
|
|
125
|
+
if (score < bestScore) { bestScore = score; best = m; }
|
|
126
|
+
}
|
|
127
|
+
return best;
|
|
128
|
+
}
|
|
103
129
|
get range() {
|
|
104
130
|
const override = this._rangeOverride;
|
|
105
131
|
if (override !== undefined) return override ? override.slice() : null;
|
|
@@ -141,7 +167,7 @@ class ContourChart extends ContourBase {
|
|
|
141
167
|
if (own) return own;
|
|
142
168
|
const wide = safeColor(this.getAttribute("color"));
|
|
143
169
|
if (wide) return wide;
|
|
144
|
-
return "var(--chart-" + ((i %
|
|
170
|
+
return "var(--chart-" + ((i % 8) + 1) + ")";
|
|
145
171
|
}
|
|
146
172
|
// R25-14: legend opt-out. Presence-with-value flags follow the sparkline
|
|
147
173
|
// convention (F-FC11): "off"/"false"/"none"/"0" all mean off.
|
|
@@ -730,6 +756,26 @@ svg.setAttribute("role", "group");
|
|
|
730
756
|
}
|
|
731
757
|
}
|
|
732
758
|
// R25-03: gridlines/axis/note/brush shed last, over whatever the branches above built. The loading/error/skeleton returns are state chrome, not data chrome, and deliberately skip the shed table.
|
|
759
|
+
// R33-103: first-mount staggered reveal. The plot persists across renders
|
|
760
|
+
// (patchChildren reuses its marks), so the class is added once and cleared
|
|
761
|
+
// after the stagger — a streaming update that patches new marks in later
|
|
762
|
+
// never replays it. Reduced-motion collapses the animation (global reset).
|
|
763
|
+
if (!this._chartRevealed) {
|
|
764
|
+
const plot = this.querySelector(".c-chart__plot");
|
|
765
|
+
if (plot && plot.querySelector(".c-chart__bar, .c-chart__line, .c-chart__point, .c-donut__slice")) {
|
|
766
|
+
this._chartRevealed = true;
|
|
767
|
+
// Per-mark stagger delay is set inline (not in CSS): family-gate
|
|
768
|
+
// forbids raw ms in an animation-* declaration.
|
|
769
|
+
plot.querySelectorAll(".c-chart__bar, .c-chart__line, .c-chart__point, .c-donut__slice").forEach((mark, i) => {
|
|
770
|
+
mark.style.animationDelay = (Math.min(i, 11) * 30) + "ms";
|
|
771
|
+
});
|
|
772
|
+
plot.classList.add("is-revealing");
|
|
773
|
+
setTimeout(() => {
|
|
774
|
+
plot.classList.remove("is-revealing");
|
|
775
|
+
plot.querySelectorAll(".c-chart__bar, .c-chart__line, .c-chart__point, .c-donut__slice").forEach((mark) => mark.style.removeProperty("animation-delay"));
|
|
776
|
+
}, 600);
|
|
777
|
+
}
|
|
778
|
+
}
|
|
733
779
|
this._applyBrownout();
|
|
734
780
|
}
|
|
735
781
|
enhance() {
|
|
@@ -767,38 +813,100 @@ svg.setAttribute("role", "group");
|
|
|
767
813
|
detail: e.detail,
|
|
768
814
|
}));
|
|
769
815
|
});
|
|
770
|
-
// Zoom/pan (F-10
|
|
816
|
+
// Zoom/pan (F-10; R34-52 keyboard/touch/announced contract): wheel or
|
|
817
|
+
// `+`/`-`/`0` to zoom, drag or arrow keys to pan, double-click or `0` to
|
|
818
|
+
// reset. Pointer events with capture cover mouse, touch and pen; a
|
|
819
|
+
// two-pointer pinch zooms around its midpoint and `pointercancel` settles
|
|
820
|
+
// back without emitting a phantom change. Every committed change is
|
|
821
|
+
// announced through a polite live region and a `contour:chart-zoom`
|
|
822
|
+
// event, so a table, a minimap or an AT user follows the same viewport.
|
|
823
|
+
// `touch-action: pan-y` (CSS) keeps native vertical page scroll while the
|
|
824
|
+
// plot owns horizontal pan and pinch — the chart never traps the page.
|
|
771
825
|
if (this.hasAttribute("zoomable")) {
|
|
772
826
|
let zoom = 1, panX = 0, panY = 0;
|
|
773
827
|
const plot = this.querySelector(".c-chart__plot");
|
|
774
|
-
|
|
828
|
+
// A zoomable plot is a focusable control with its own instructions; the
|
|
829
|
+
// marks keep their roving tabindex inside it.
|
|
830
|
+
if (plot) {
|
|
831
|
+
plot.classList.add("c-chart__plot--zoomable");
|
|
832
|
+
if (!plot.hasAttribute("tabindex")) plot.setAttribute("tabindex", "0");
|
|
833
|
+
if (!plot.hasAttribute("aria-label")) {
|
|
834
|
+
plot.setAttribute("aria-label", labelText(this, "chart", "Chart") + ", zoomable. Use plus and minus to zoom, arrow keys to pan, 0 to reset.");
|
|
835
|
+
}
|
|
836
|
+
}
|
|
837
|
+
const status = this.ensure("[data-chart-zoom-status]", () => {
|
|
838
|
+
const el = document.createElement("span");
|
|
839
|
+
el.className = "visually-hidden";
|
|
840
|
+
el.setAttribute("data-chart-zoom-status", "");
|
|
841
|
+
el.setAttribute("role", "status");
|
|
842
|
+
el.setAttribute("aria-live", "polite");
|
|
843
|
+
return el;
|
|
844
|
+
});
|
|
845
|
+
const apply = (announce = true) => {
|
|
775
846
|
if (!plot) return;
|
|
776
847
|
plot.style.transform = `translate(${panX}px, ${panY}px) scale(${zoom})`;
|
|
777
848
|
plot.style.transformOrigin = "center center";
|
|
849
|
+
plot.classList.toggle("is-zoomed", zoom !== 1 || panX !== 0 || panY !== 0);
|
|
850
|
+
if (!announce) return;
|
|
851
|
+
status.textContent = `Zoom ${Math.round(zoom * 100)} percent`;
|
|
852
|
+
this.dispatchEvent(new CustomEvent("contour:chart-zoom", { bubbles: true, composed: true, detail: { zoom, panX, panY } }));
|
|
778
853
|
};
|
|
854
|
+
const zoomBy = (factor) => { zoom = Math.min(5, Math.max(0.5, zoom * factor)); apply(); };
|
|
855
|
+
const reset = () => { zoom = 1; panX = 0; panY = 0; apply(); };
|
|
779
856
|
this.addEventListener("wheel", (e) => {
|
|
780
857
|
e.preventDefault();
|
|
781
|
-
|
|
782
|
-
zoom = Math.min(5, Math.max(0.5, zoom * factor));
|
|
783
|
-
apply();
|
|
858
|
+
zoomBy(e.deltaY < 0 ? 1.1 : 0.9);
|
|
784
859
|
}, { passive: false });
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
860
|
+
// Pointer pan/pinch with capture; a single pointer pans, a second turns
|
|
861
|
+
// the gesture into a pinch-zoom around the two-pointer midpoint.
|
|
862
|
+
const pointers = new Map();
|
|
863
|
+
let dragging = false, startX = 0, startY = 0, startPanX = 0, startPanY = 0, pinchDist = 0, pinchZoom = 1;
|
|
864
|
+
const spread = () => { const p = [...pointers.values()]; return p.length >= 2 ? Math.hypot(p[0].x - p[1].x, p[0].y - p[1].y) : 0; };
|
|
865
|
+
this.addEventListener("pointerdown", (e) => {
|
|
866
|
+
if (e.pointerType === "mouse" && e.button !== 0) return;
|
|
867
|
+
pointers.set(e.pointerId, { x: e.clientX, y: e.clientY });
|
|
868
|
+
try { this.setPointerCapture(e.pointerId); } catch (err) { /* capture unsupported */ }
|
|
869
|
+
if (pointers.size === 1) {
|
|
870
|
+
dragging = true; startX = e.clientX; startY = e.clientY; startPanX = panX; startPanY = panY;
|
|
871
|
+
this.style.cursor = "grabbing";
|
|
872
|
+
} else if (pointers.size === 2) {
|
|
873
|
+
dragging = false; pinchDist = spread(); pinchZoom = zoom;
|
|
874
|
+
}
|
|
790
875
|
});
|
|
791
|
-
|
|
876
|
+
this.addEventListener("pointermove", (e) => {
|
|
877
|
+
if (!pointers.has(e.pointerId)) return;
|
|
878
|
+
pointers.set(e.pointerId, { x: e.clientX, y: e.clientY });
|
|
879
|
+
if (pointers.size >= 2 && pinchDist) {
|
|
880
|
+
zoom = Math.min(5, Math.max(0.5, pinchZoom * (spread() / pinchDist)));
|
|
881
|
+
apply();
|
|
882
|
+
return;
|
|
883
|
+
}
|
|
792
884
|
if (!dragging) return;
|
|
793
885
|
panX = startPanX + (e.clientX - startX);
|
|
794
886
|
panY = startPanY + (e.clientY - startY);
|
|
795
|
-
apply();
|
|
887
|
+
apply(false); // pan is not announced per-pixel; pointerup settles it
|
|
888
|
+
});
|
|
889
|
+
const endPointer = (e) => {
|
|
890
|
+
pointers.delete(e.pointerId);
|
|
891
|
+
try { this.releasePointerCapture(e.pointerId); } catch (err) { /* ignore */ }
|
|
892
|
+
if (pointers.size < 2) pinchDist = 0;
|
|
893
|
+
if (pointers.size === 0) { dragging = false; this.style.cursor = ""; apply(); }
|
|
796
894
|
};
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
895
|
+
this.addEventListener("pointerup", endPointer);
|
|
896
|
+
this.addEventListener("pointercancel", endPointer);
|
|
897
|
+
this.addEventListener("dblclick", reset);
|
|
898
|
+
// Keyboard (plot-focused only): +/= zoom in, -/_ zoom out, 0 reset,
|
|
899
|
+
// arrows pan. Marks keep their own Enter/Space/arrow contract.
|
|
900
|
+
this.addEventListener("keydown", (e) => {
|
|
901
|
+
if (e.target !== plot) return;
|
|
902
|
+
if (e.key === "+" || e.key === "=") { e.preventDefault(); zoomBy(1.1); }
|
|
903
|
+
else if (e.key === "-" || e.key === "_") { e.preventDefault(); zoomBy(0.9); }
|
|
904
|
+
else if (e.key === "0") { e.preventDefault(); reset(); }
|
|
905
|
+
else if (e.key === "ArrowLeft") { e.preventDefault(); panX += 20; apply(); }
|
|
906
|
+
else if (e.key === "ArrowRight") { e.preventDefault(); panX -= 20; apply(); }
|
|
907
|
+
else if (e.key === "ArrowUp") { e.preventDefault(); panY += 20; apply(); }
|
|
908
|
+
else if (e.key === "ArrowDown") { e.preventDefault(); panY -= 20; apply(); }
|
|
909
|
+
});
|
|
802
910
|
}
|
|
803
911
|
// Tooltip: show on hover of a mark. Cache the plot rect across mousemove events: it only changes on resize/scroll, so re-measuring on every pixel is wasted layout work (B3-22). A ResizeObserver invalidates the cache; scroll invalidates via the same observer-less fallback (recompute).
|
|
804
912
|
let plotRectCache = null;
|
|
@@ -873,6 +981,17 @@ svg.setAttribute("role", "group");
|
|
|
873
981
|
const series = parseInt(slice.getAttribute("data-series") || "1", 10);
|
|
874
982
|
const index = parseInt(slice.dataset.index || "0", 10);
|
|
875
983
|
this.dispatchEvent(new CustomEvent("contour:select", { bubbles: true, composed: true, detail: { series, index, value: slice.getAttribute("data-title") || slice.getAttribute("title") } }));
|
|
984
|
+
return;
|
|
985
|
+
}
|
|
986
|
+
// R34-53: nearest-mark selection with pointer tolerance. A tap that
|
|
987
|
+
// lands on the plot between marks — or on a thin bar/point too small
|
|
988
|
+
// for a 44px coarse target — still selects the closest datum, so
|
|
989
|
+
// pointer and keyboard share one selection path and one datum.
|
|
990
|
+
const nearest = this._nearestMark(e.clientX, e.clientY);
|
|
991
|
+
if (nearest) {
|
|
992
|
+
const series = parseInt(nearest.getAttribute("data-series") || "1", 10);
|
|
993
|
+
const index = parseInt(nearest.dataset.index || "0", 10);
|
|
994
|
+
this.dispatchEvent(new CustomEvent("contour:select", { bubbles: true, composed: true, detail: { series, index } }));
|
|
876
995
|
}
|
|
877
996
|
});
|
|
878
997
|
this.addEventListener("keydown", (e) => {
|
|
@@ -1234,7 +1353,7 @@ class ContourStreamingChart extends ContourBase {
|
|
|
1234
1353
|
// Stream cadence (BY-40). The layer had no timer at all — the literal gap the row names — so the chart gets its own `interval` loop rather than a second clock inside the loader. Each tick emits contour:tick and, when a src is present, re-validates through the loader's own cache path (remoteInvalidate + requestRender — the two steps the loader's refresh tick performs), so the shared cache and abort semantics stay the loader's. The loader's `refresh` attribute is NOT written here: an attribute a component writes to itself must never be observed, or the write re-enters render (measured by the gate). `pause` stops the loop; `interval` growth is clamped to the loader's own 1 s floor so the two cannot disagree.
|
|
1235
1354
|
const sync = () => {
|
|
1236
1355
|
const seconds = parseFloat(this.getAttribute("interval") || "");
|
|
1237
|
-
const want = Number.isFinite(seconds) && seconds > 0 && !this.hasAttribute("pause") && !this._streamPausedByUser && this._viewVisible !== false;
|
|
1356
|
+
const want = Number.isFinite(seconds) && seconds > 0 && !this.hasAttribute("pause") && !this._streamPausedByUser && this._viewVisible !== false && this._tabVisible !== false;
|
|
1238
1357
|
if (want === this._streamRunning) return;
|
|
1239
1358
|
this._streamRunning = want;
|
|
1240
1359
|
if (this._streamTimer !== undefined) { clearInterval(this._streamTimer); this._streamTimer = undefined; }
|
|
@@ -1243,7 +1362,11 @@ class ContourStreamingChart extends ContourBase {
|
|
|
1243
1362
|
this._streamTimer = setInterval(() => {
|
|
1244
1363
|
if (!this.isConnected || this.hasAttribute("pause")) return;
|
|
1245
1364
|
this._streamFrame += 1;
|
|
1246
|
-
|
|
1365
|
+
// R34-54: each tick carries its sequence (frame), emit timestamp and
|
|
1366
|
+
// the expected interval, so a consumer can detect a gap (a missing
|
|
1367
|
+
// tick beyond `interval`) and a stall (no tick for N intervals)
|
|
1368
|
+
// without a second clock.
|
|
1369
|
+
this.dispatchEvent(new CustomEvent("contour:tick", { detail: { frame: this._streamFrame, timestamp: Date.now(), interval: Math.max(1000, seconds * 1000) }, bubbles: true, composed: true }));
|
|
1247
1370
|
const src = this.getAttribute("src");
|
|
1248
1371
|
if (src) { remoteInvalidate(src); this.requestRender(); }
|
|
1249
1372
|
}, Math.max(1000, seconds * 1000));
|
|
@@ -1262,7 +1385,12 @@ class ContourStreamingChart extends ContourBase {
|
|
|
1262
1385
|
if (this._wiredStream) return;
|
|
1263
1386
|
this._wiredStream = true;
|
|
1264
1387
|
this._streamFrame = 0;
|
|
1265
|
-
|
|
1388
|
+
// R33-72: pause the stream while the tab is hidden (visibilitychange), and
|
|
1389
|
+
// resume when it returns. The document listener is removed on dispose.
|
|
1390
|
+
this._tabVisible = !document.hidden;
|
|
1391
|
+
const onVis = () => { this._tabVisible = !document.hidden; sync(); };
|
|
1392
|
+
document.addEventListener("visibilitychange", onVis);
|
|
1393
|
+
onDispose(this, () => { if (this._streamTimer !== undefined) { clearInterval(this._streamTimer); this._streamTimer = undefined; } document.removeEventListener("visibilitychange", onVis); });
|
|
1266
1394
|
// Keyboard: Space/Enter toggles pause (BY-08); internal flag prevents re-render re-entry.
|
|
1267
1395
|
this._streamPausedByUser = false;
|
|
1268
1396
|
// Delegate pause/play click on host: generated button dies on re-render; host listener survives (rule 12).
|
|
@@ -1331,3 +1459,23 @@ class ContourReferenceRule extends ContourBase {
|
|
|
1331
1459
|
}
|
|
1332
1460
|
}
|
|
1333
1461
|
define("contour-reference-rule", ContourReferenceRule);
|
|
1462
|
+
|
|
1463
|
+
/**
|
|
1464
|
+
* Small Multiples (R33-45): a grid of charts that share axes. Attributes:
|
|
1465
|
+
* `columns` (grid column count) and `label`. Slotted charts are laid out in a
|
|
1466
|
+
* responsive grid; the group is the shared-axis frame, the children are the
|
|
1467
|
+
* individual multiples.
|
|
1468
|
+
*/
|
|
1469
|
+
class ContourSmallMultiples extends ContourBase {
|
|
1470
|
+
static get observed() { return ["columns", "label"]; }
|
|
1471
|
+
static get properties() { return { columns: { attribute: "columns", type: Number }, label: { attribute: "label" } }; }
|
|
1472
|
+
render() {
|
|
1473
|
+
this.classList.add("c-small-multiples");
|
|
1474
|
+
if (!this.hasAttribute("role")) this.setAttribute("role", "group");
|
|
1475
|
+
const label = this.getAttribute("label");
|
|
1476
|
+
if (label) this.setAttribute("aria-label", label); else this.removeAttribute("aria-label");
|
|
1477
|
+
const cols = this.getAttribute("columns");
|
|
1478
|
+
if (cols) this.style.setProperty("--sm-cols", cols); else this.style.removeProperty("--sm-cols");
|
|
1479
|
+
}
|
|
1480
|
+
}
|
|
1481
|
+
define("contour-small-multiples", ContourSmallMultiples);
|