contour-ds 1.1.2 → 1.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +30 -2
- package/dist/agent-rules.json +5 -1
- package/dist/build-manifest.json +94 -93
- package/dist/contour-wc.esm.js +4443 -534
- package/dist/contour-wc.esm.min.js +1 -1
- package/dist/contour-wc.js +4441 -528
- package/dist/contour-wc.min.js +1 -1
- package/dist/contour.components.json +4054 -171
- package/dist/contour.css +1325 -565
- package/dist/contour.d.ts +119 -62
- package/dist/contour.esm.js +23 -0
- package/dist/contour.esm.min.js +1 -1
- package/dist/contour.js +23 -0
- package/dist/contour.min.css +1 -1
- package/dist/contour.min.js +1 -1
- package/dist/contour.tokens.json +47 -2
- package/dist/docs/actions.md +6 -2
- package/dist/docs/affordances.md +19 -3
- package/dist/docs/apireference.md +30 -0
- package/dist/docs/colour.md +2 -2
- package/dist/docs/componentindex.md +39 -0
- package/dist/docs/data.md +38 -3
- package/dist/docs/docs.md +6 -2
- package/dist/docs/feedback.md +13 -3
- package/dist/docs/field.md +7 -2
- package/dist/docs/forms.md +35 -3
- package/dist/docs/index.json +44 -75
- package/dist/docs/install.md +4 -2
- package/dist/docs/landing.md +3 -2
- package/dist/docs/mapengine.md +9 -3
- package/dist/docs/motion.md +5 -2
- package/dist/docs/navigation.md +10 -3
- package/dist/docs/overlays.md +26 -3
- package/dist/docs/overview.md +2 -2
- package/dist/docs/patterns.md +38 -3
- package/dist/docs/playground.md +5 -2
- package/dist/docs/principles.md +2 -2
- package/dist/docs/recipes.md +7 -3
- package/dist/docs/space.md +2 -2
- package/dist/docs/status.md +19 -3
- package/dist/docs/surfaces.md +7 -3
- package/dist/docs/theming.md +5 -2
- package/dist/docs/type.md +2 -2
- package/dist/docs/webcomponents.md +26 -7
- package/dist/map-chrome.mapbox.css +4 -4
- package/dist/map-chrome.maplibre.css +4 -4
- 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 +69 -11
- package/dist/wc/content.mjs +163 -8
- package/dist/wc/core.mjs +177 -36
- package/dist/wc/dashboard.mjs +69 -4
- package/dist/wc/data.mjs +933 -128
- package/dist/wc/docs.mjs +118 -0
- package/dist/wc/feedback.mjs +75 -13
- package/dist/wc/forms.mjs +371 -34
- package/dist/wc/index.mjs +31 -3
- package/dist/wc/interaction.mjs +11 -6
- package/dist/wc/map.mjs +142 -38
- package/dist/wc/misc.mjs +29 -1
- package/dist/wc/navigation.mjs +424 -75
- package/dist/wc/registration.mjs +8 -4
- package/dist/wc/shadow.mjs +29 -12
- package/dist/wc/states.mjs +15 -0
- package/dist/wc/svg.mjs +10 -0
- package/dist/wc/ui.mjs +1767 -129
- package/package.json +39 -6
package/dist/wc/shadow.mjs
CHANGED
|
@@ -65,7 +65,8 @@ import { define, MODS, REGISTERED, CONTOUR_EVENTS, contourId } from './core.mjs'
|
|
|
65
65
|
// then keep the root's modifier classes in step with MODS on the host. The
|
|
66
66
|
// base classes are snapshotted at construction, so a re-render cannot
|
|
67
67
|
// accumulate a stale modifier the way an additive classList would.
|
|
68
|
-
|
|
68
|
+
const _ShadowParent = (typeof HTMLElement !== "undefined") ? HTMLElement : Object;
|
|
69
|
+
class ContourShadow extends _ShadowParent {
|
|
69
70
|
static get observedAttributes() { return MODS; }
|
|
70
71
|
constructor() {
|
|
71
72
|
super();
|
|
@@ -76,6 +77,10 @@ import { define, MODS, REGISTERED, CONTOUR_EVENTS, contourId } from './core.mjs'
|
|
|
76
77
|
this._shadowBase = root.firstElementChild ? root.firstElementChild.className : "";
|
|
77
78
|
}
|
|
78
79
|
// Subclasses with behaviour beyond the template override this.
|
|
80
|
+
// Lifecycle note: listeners are attached to nodes inside the shadow root
|
|
81
|
+
// (root-owned), not to the host, so they are collected when the root is
|
|
82
|
+
// discarded on disconnect. No host-level disposers are required; the
|
|
83
|
+
// root-owner invariant is what keeps this leak-free (R11-08).
|
|
79
84
|
enhance(root) {
|
|
80
85
|
if (!root) root = this.shadowRoot;
|
|
81
86
|
if (!root) return;
|
|
@@ -202,9 +207,14 @@ connectedCallback() {
|
|
|
202
207
|
|
|
203
208
|
// Registers a wrapper. The template is parsed once into a <template> and
|
|
204
209
|
// cloned per instance, so the markup below is the markup the root gets.
|
|
210
|
+
const SHADOW_PARTS_PUBLIC = {};
|
|
205
211
|
const shadow = (name, markup) => {
|
|
212
|
+
if (typeof document === "undefined") return;
|
|
206
213
|
const tpl = document.createElement("template");
|
|
207
214
|
tpl.innerHTML = markup;
|
|
215
|
+
SHADOW_PARTS_PUBLIC[name] = [...tpl.content.querySelectorAll("[part]")]
|
|
216
|
+
.flatMap((node) => (node.getAttribute("part") || "").split(/\s+/))
|
|
217
|
+
.filter(Boolean);
|
|
208
218
|
const cls = class extends ContourShadow {};
|
|
209
219
|
cls.contourTemplate = tpl;
|
|
210
220
|
define(name, cls);
|
|
@@ -264,10 +274,12 @@ connectedCallback() {
|
|
|
264
274
|
"contour-plot": "plot",
|
|
265
275
|
};
|
|
266
276
|
|
|
267
|
-
|
|
268
|
-
for (const
|
|
269
|
-
const
|
|
270
|
-
|
|
277
|
+
if (typeof document !== "undefined") {
|
|
278
|
+
for (const [tag, blocks] of Object.entries(SHADOW_SLOTS)) {
|
|
279
|
+
for (const block of blocks) {
|
|
280
|
+
const part = SHADOW_PARTS[block] || block;
|
|
281
|
+
shadow("contour-shadow-" + block, slotWrapper(tag, block, part));
|
|
282
|
+
}
|
|
271
283
|
}
|
|
272
284
|
}
|
|
273
285
|
|
|
@@ -334,11 +346,11 @@ shadow("contour-shadow-filter-pill", `<span class="c-filter-pill" part="filter-p
|
|
|
334
346
|
// The dialog is the one wrapper with behaviour, because a close button that
|
|
335
347
|
// does not close is a control the reader cannot use.
|
|
336
348
|
class ContourShadowDialog extends ContourShadow {
|
|
337
|
-
static contourTemplate = (() => {
|
|
349
|
+
static contourTemplate = (typeof document !== "undefined") ? (() => {
|
|
338
350
|
const tpl = document.createElement("template");
|
|
339
351
|
tpl.innerHTML = "<dialog class=\"c-dialog\" part=\"dialog\"> <div class=\"c-dialog__head\" part=\"head\"> <slot name=\"title\"></slot> <button class=\"c-btn c-btn--icon c-btn--ghost\" part=\"close\" type=\"button\" aria-label=\"Close\"> <svg aria-hidden=\"true\"><use href=\"#i-close\" /></svg> </button> </div> <div class=\"c-dialog__body\" part=\"body\"><slot></slot></div> <div class=\"c-dialog__foot\" part=\"foot\"><slot name=\"foot\"></slot></div> </dialog>";
|
|
340
352
|
return tpl;
|
|
341
|
-
})();
|
|
353
|
+
})() : null;
|
|
342
354
|
enhance(root) {
|
|
343
355
|
super.enhance(root);
|
|
344
356
|
// The base constructor AND connectedCallback both call enhance; the base's
|
|
@@ -399,8 +411,13 @@ shadow("contour-shadow-filter-pill", `<span class="c-filter-pill" part="filter-p
|
|
|
399
411
|
// handed rather than what the source appears to say. Frozen: a page that
|
|
400
412
|
// reshapes it would make the next reader's count wrong, which is the failure
|
|
401
413
|
// this array exists to prevent.
|
|
402
|
-
window
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
414
|
+
if (typeof window !== "undefined") {
|
|
415
|
+
window.ContourElements = Object.freeze(REGISTERED.slice());
|
|
416
|
+
window.ContourShadowParts = Object.freeze(Object.fromEntries(
|
|
417
|
+
Object.entries(SHADOW_PARTS_PUBLIC).map(([name, parts]) => [name, Object.freeze([...new Set(parts)])]),
|
|
418
|
+
));
|
|
419
|
+
// Same rule for the event vocabulary: the manifest is frozen at publish so a
|
|
420
|
+
// page cannot add names the source never emitted, which would make the gate's
|
|
421
|
+
// "every dispatchEvent name has an entry" read meaningless.
|
|
422
|
+
window.ContourEvents = Object.freeze(CONTOUR_EVENTS);
|
|
423
|
+
}
|
package/dist/wc/states.mjs
CHANGED
|
@@ -48,6 +48,7 @@ import { onDispose } from './core.mjs';
|
|
|
48
48
|
// Copy. A component overrides any of these through its own attribute, because a
|
|
49
49
|
// legend and a table should not both say "No data" — but a default must exist,
|
|
50
50
|
// because a state with no text is a state the reader cannot see.
|
|
51
|
+
/** Fallback state copy used when remote data is unavailable. */
|
|
51
52
|
export const STATE_FALLBACK = {
|
|
52
53
|
empty: "No data",
|
|
53
54
|
loading: "Loading…",
|
|
@@ -118,6 +119,7 @@ function leaveRequest(host) {
|
|
|
118
119
|
* prefers them. Reads nothing and writes nothing the component paints — the
|
|
119
120
|
* values come back through `remoteData`.
|
|
120
121
|
*/
|
|
122
|
+
/** Load remote data for the given fields on a host. */
|
|
121
123
|
export function loadRemote(host, fields) {
|
|
122
124
|
const src = host.getAttribute("src");
|
|
123
125
|
if (!src) {
|
|
@@ -247,6 +249,7 @@ export function loadRemote(host, fields) {
|
|
|
247
249
|
* websocket that says the tiles changed) without forcing a remount.
|
|
248
250
|
* @param {string} srcOrKey the URL — or the cache-key a host asked under
|
|
249
251
|
*/
|
|
252
|
+
/** Invalidate cached remote data by source or key. */
|
|
250
253
|
export function remoteInvalidate(srcOrKey) {
|
|
251
254
|
remoteCache.delete(srcOrKey);
|
|
252
255
|
}
|
|
@@ -306,6 +309,7 @@ function startFetch(host, src, entry) {
|
|
|
306
309
|
* The return is always the string the render body already parses, so adopting this
|
|
307
310
|
* changes no component's parsing.
|
|
308
311
|
*/
|
|
312
|
+
/** Read the cached remote data for a field. */
|
|
309
313
|
export function remoteData(host, field) {
|
|
310
314
|
const authored = host.getAttribute(field);
|
|
311
315
|
if (authored !== null) return authored;
|
|
@@ -333,11 +337,13 @@ export function remoteData(host, field) {
|
|
|
333
337
|
* timer scheduled here fires and clears `_remoteTimer`, so the guard has to be a
|
|
334
338
|
* flag that survives the tick or every re-render adds another loop.
|
|
335
339
|
*/
|
|
340
|
+
/** Refresh remote data for a host. */
|
|
336
341
|
export function remoteRefresh(host) {
|
|
337
342
|
const seconds = parseFloat(host.getAttribute("refresh") || "");
|
|
338
343
|
const want = host.hasAttribute("src") && Number.isFinite(seconds) && seconds > 0;
|
|
339
344
|
if (!want) {
|
|
340
345
|
if (host._remoteTimer !== undefined) { clearTimeout(host._remoteTimer); host._remoteTimer = undefined; }
|
|
346
|
+
host._remoteLoop = false;
|
|
341
347
|
return;
|
|
342
348
|
}
|
|
343
349
|
if (host._remoteLoop) return;
|
|
@@ -373,10 +379,12 @@ export function remoteRefresh(host) {
|
|
|
373
379
|
// observer disconnected) once it enters, so siblings keep watching.
|
|
374
380
|
let _sharedLazyIO = null;
|
|
375
381
|
const _sharedLazyTargets = new Map();
|
|
382
|
+
/** Whether remote data is currently visible. */
|
|
376
383
|
export function remoteVisible(host) {
|
|
377
384
|
if (!host.hasAttribute("lazy")) return true;
|
|
378
385
|
if (typeof IntersectionObserver !== "function") return true;
|
|
379
386
|
if (host._remoteVisible) return true;
|
|
387
|
+
if (host._lazyRegistered) return false;
|
|
380
388
|
if (!_sharedLazyIO) {
|
|
381
389
|
_sharedLazyIO = new IntersectionObserver((records) => {
|
|
382
390
|
for (const r of records) {
|
|
@@ -390,13 +398,16 @@ export function remoteVisible(host) {
|
|
|
390
398
|
}
|
|
391
399
|
const activate = () => {
|
|
392
400
|
host._remoteVisible = true;
|
|
401
|
+
host._lazyRegistered = false;
|
|
393
402
|
host.requestRender();
|
|
394
403
|
};
|
|
404
|
+
host._lazyRegistered = true;
|
|
395
405
|
_sharedLazyTargets.set(host, activate);
|
|
396
406
|
_sharedLazyIO.observe(host);
|
|
397
407
|
onDispose(host, () => {
|
|
398
408
|
_sharedLazyIO.unobserve(host);
|
|
399
409
|
_sharedLazyTargets.delete(host);
|
|
410
|
+
host._lazyRegistered = false;
|
|
400
411
|
});
|
|
401
412
|
return false;
|
|
402
413
|
}
|
|
@@ -416,6 +427,7 @@ export function remoteVisible(host) {
|
|
|
416
427
|
* and a dashboard that waits for leave that can never come is a dashboard that
|
|
417
428
|
* never resumes.
|
|
418
429
|
*/
|
|
430
|
+
/** Watch viewport intersection for lazy loading. */
|
|
419
431
|
export function watchViewport(host) {
|
|
420
432
|
if (host._contourViewWired) return () => {};
|
|
421
433
|
host._contourViewWired = true;
|
|
@@ -478,6 +490,7 @@ function skeletonRow(i, total) {
|
|
|
478
490
|
* because a retry in flight is not a failure, and either wins over `skeleton`,
|
|
479
491
|
* which is a placeholder for a state the host may already be in.
|
|
480
492
|
*/
|
|
493
|
+
/** Render loading/empty/error states for a block. */
|
|
481
494
|
export function renderStates(host, block, opts) {
|
|
482
495
|
const options = opts || {};
|
|
483
496
|
const loading = host.getAttribute("loading");
|
|
@@ -513,12 +526,14 @@ export function renderStates(host, block, opts) {
|
|
|
513
526
|
}
|
|
514
527
|
|
|
515
528
|
/** Paint the empty state — for a host with no data and no authored content. */
|
|
529
|
+
/** Render the empty state for a block. */
|
|
516
530
|
export function renderEmpty(host, block) {
|
|
517
531
|
host.appendChild(stateNode(block, "empty", host.getAttribute("empty") || STATE_FALLBACK.empty));
|
|
518
532
|
}
|
|
519
533
|
|
|
520
534
|
// Delegated on the host (AGENTS.md rule 12): the retry button is regenerated on
|
|
521
535
|
// every render, so a listener bound to the node would be dropped by the next pass.
|
|
536
|
+
/** Wire state (loading/empty/error) interactions for a host. */
|
|
522
537
|
export function wireStates(host) {
|
|
523
538
|
if (host._contourStatesWired) return;
|
|
524
539
|
host._contourStatesWired = true;
|
package/dist/wc/svg.mjs
CHANGED
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
* @param {number} endAngle end angle in radians
|
|
26
26
|
* @returns {string} SVG path `d` attribute
|
|
27
27
|
*/
|
|
28
|
+
/** Build an SVG arc path string. */
|
|
28
29
|
export function arcPath(cx, cy, r, inner, startAngle, endAngle) {
|
|
29
30
|
// Clamp non-finite inputs so a bad value cannot emit NaN/Infinity into the
|
|
30
31
|
// path string (B3-22). A degenerate slice collapses to a point.
|
|
@@ -61,6 +62,7 @@ export function arcPath(cx, cy, r, inner, startAngle, endAngle) {
|
|
|
61
62
|
* @param {number} [opts.gap=0.02] angular gap between slices in radians
|
|
62
63
|
* @returns {{path: string, value: number, index: number}[]}
|
|
63
64
|
*/
|
|
65
|
+
/** Compute donut slice geometry. */
|
|
64
66
|
export function donutSlices(values, opts) {
|
|
65
67
|
opts = opts || {};
|
|
66
68
|
const cx = opts.cx != null ? opts.cx : 100;
|
|
@@ -95,6 +97,7 @@ export function donutSlices(values, opts) {
|
|
|
95
97
|
* @param {number} [opts.max] override max value (defaults to max of values)
|
|
96
98
|
* @returns {{x:number,y:number,width:number,height:number}[]}
|
|
97
99
|
*/
|
|
100
|
+
/** Compute bar rectangle geometry. */
|
|
98
101
|
export function barRects(values, opts) {
|
|
99
102
|
opts = opts || {};
|
|
100
103
|
const width = opts.width != null ? opts.width : 300;
|
|
@@ -122,6 +125,7 @@ export function barRects(values, opts) {
|
|
|
122
125
|
* @param {number} [opts.min] override min
|
|
123
126
|
* @returns {string} "x,y x,y ..."
|
|
124
127
|
*/
|
|
128
|
+
/** Compute polyline point string. */
|
|
125
129
|
export function polylinePoints(values, opts) {
|
|
126
130
|
opts = opts || {};
|
|
127
131
|
const width = opts.width != null ? opts.width : 300;
|
|
@@ -146,6 +150,7 @@ export function polylinePoints(values, opts) {
|
|
|
146
150
|
* @param {object} [opts] same as polylinePoints
|
|
147
151
|
* @returns {string} SVG path `d` attribute
|
|
148
152
|
*/
|
|
153
|
+
/** Compute a smoothed SVG path. */
|
|
149
154
|
export function smoothPath(values, opts) {
|
|
150
155
|
const pts = polylinePoints(values, opts).split(" ").map((p) => p.split(",").map(Number));
|
|
151
156
|
if (!pts.length) return "";
|
|
@@ -171,6 +176,7 @@ export function smoothPath(values, opts) {
|
|
|
171
176
|
* @param {number} [width=3] half-width of the needle at the base
|
|
172
177
|
* @returns {string} SVG path `d` attribute
|
|
173
178
|
*/
|
|
179
|
+
/** Compute compass needle geometry. */
|
|
174
180
|
export function compassNeedle(cx, cy, length, angleDeg, width) {
|
|
175
181
|
angleDeg = angleDeg == null ? 0 : angleDeg;
|
|
176
182
|
width = width == null ? 3 : width;
|
|
@@ -196,6 +202,7 @@ export function compassNeedle(cx, cy, length, angleDeg, width) {
|
|
|
196
202
|
* @param {number} [segments=4] number of segments
|
|
197
203
|
* @returns {number[]} tick values from 0 to value inclusive
|
|
198
204
|
*/
|
|
205
|
+
/** Compute scale bar tick positions. */
|
|
199
206
|
export function scaleBarTicks(value, segments) {
|
|
200
207
|
value = Number(value) || 0;
|
|
201
208
|
segments = Math.max(1, Math.round(segments || 4));
|
|
@@ -206,7 +213,9 @@ export function scaleBarTicks(value, segments) {
|
|
|
206
213
|
return out;
|
|
207
214
|
}
|
|
208
215
|
// Marker shape encoding utility (G-13)
|
|
216
|
+
/** Supported marker shapes for chart series. */
|
|
209
217
|
export const MARKER_SHAPES = ["circle", "square", "triangle", "diamond", "star"];
|
|
218
|
+
/** Return CSS styles for a marker shape. */
|
|
210
219
|
export function markerStyles(shape) {
|
|
211
220
|
const map = {
|
|
212
221
|
circle: "border-radius:50%",
|
|
@@ -217,6 +226,7 @@ export function markerStyles(shape) {
|
|
|
217
226
|
};
|
|
218
227
|
return map[shape] || "";
|
|
219
228
|
}
|
|
229
|
+
/** Assign marker shapes to chart items. */
|
|
220
230
|
export function assignMarkers(items) {
|
|
221
231
|
return (items || []).map((it, i) => ({ ...it, marker: MARKER_SHAPES[i % MARKER_SHAPES.length] }));
|
|
222
232
|
}
|