contour-ds 1.8.1 → 1.9.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.
Files changed (147) hide show
  1. package/README.md +227 -378
  2. package/dist/agent-cookbook.json +960 -0
  3. package/dist/agent-examples.json +65 -0
  4. package/dist/agent-map-wiring.json +152 -0
  5. package/dist/build-manifest.json +320 -179
  6. package/dist/contour-wc-content.esm.js +479 -3665
  7. package/dist/contour-wc-content.esm.min.js +1 -1
  8. package/dist/contour-wc-core.esm.js +3724 -0
  9. package/dist/contour-wc-core.esm.min.js +1 -0
  10. package/dist/contour-wc-dashboard.esm.js +2713 -4381
  11. package/dist/contour-wc-dashboard.esm.min.js +1 -1
  12. package/dist/contour-wc-data.esm.js +2658 -4346
  13. package/dist/contour-wc-data.esm.min.js +1 -1
  14. package/dist/contour-wc-docs.esm.js +218 -3547
  15. package/dist/contour-wc-docs.esm.min.js +1 -1
  16. package/dist/contour-wc-feedback.esm.js +483 -3658
  17. package/dist/contour-wc-feedback.esm.min.js +1 -1
  18. package/dist/contour-wc-forms.esm.js +503 -3754
  19. package/dist/contour-wc-forms.esm.min.js +1 -1
  20. package/dist/contour-wc-interaction.esm.js +379 -3616
  21. package/dist/contour-wc-interaction.esm.min.js +1 -1
  22. package/dist/contour-wc-layout.esm.js +234 -3563
  23. package/dist/contour-wc-layout.esm.min.js +1 -1
  24. package/dist/contour-wc-map.esm.js +949 -3743
  25. package/dist/contour-wc-map.esm.min.js +1 -1
  26. package/dist/contour-wc-misc.esm.js +237 -3556
  27. package/dist/contour-wc-misc.esm.min.js +1 -1
  28. package/dist/contour-wc-navigation.esm.js +2235 -5237
  29. package/dist/contour-wc-navigation.esm.min.js +1 -1
  30. package/dist/contour-wc-ui.esm.js +4638 -7128
  31. package/dist/contour-wc-ui.esm.min.js +1 -1
  32. package/dist/contour-wc.esm.js +11971 -7727
  33. package/dist/contour-wc.esm.min.js +1 -1
  34. package/dist/contour-wc.js +11971 -7727
  35. package/dist/contour-wc.min.js +1 -1
  36. package/dist/contour.a11y.json +402 -0
  37. package/dist/contour.code-snippets +96 -74
  38. package/dist/contour.components.json +2591 -741
  39. package/dist/contour.css +2624 -1888
  40. package/dist/contour.d.ts +421 -228
  41. package/dist/contour.esm.js +433 -18
  42. package/dist/contour.esm.min.js +1 -1
  43. package/dist/contour.html-data.json +1231 -199
  44. package/dist/contour.js +433 -18
  45. package/dist/contour.min.css +1 -1
  46. package/dist/contour.min.js +1 -1
  47. package/dist/contour.react.d.ts +100 -98
  48. package/dist/contour.single.html +2 -2
  49. package/dist/contour.single.min.css +1 -1
  50. package/dist/contour.themes.json +56 -12
  51. package/dist/contour.tokens.json +482 -255
  52. package/dist/contour.vue.d.ts +100 -98
  53. package/dist/contour.web-types.json +1226 -226
  54. package/dist/custom-elements.json +7649 -2237
  55. package/dist/docs/actions.md +15 -6
  56. package/dist/docs/affordances.md +18 -96
  57. package/dist/docs/apireference.md +9 -5
  58. package/dist/docs/colour.md +10 -4
  59. package/dist/docs/componentindex.md +9 -26
  60. package/dist/docs/data.md +36 -60
  61. package/dist/docs/docs.md +10 -12
  62. package/dist/docs/feedback.md +30 -12
  63. package/dist/docs/field.md +28 -13
  64. package/dist/docs/forms.md +35 -19
  65. package/dist/docs/index.json +63 -56
  66. package/dist/docs/install.md +12 -7
  67. package/dist/docs/landing.md +7 -4
  68. package/dist/docs/mapengine.md +18 -13
  69. package/dist/docs/motion.md +12 -6
  70. package/dist/docs/navigation.md +31 -7
  71. package/dist/docs/overlays.md +32 -25
  72. package/dist/docs/overview.md +3 -2
  73. package/dist/docs/patterns.md +19 -9
  74. package/dist/docs/playground.md +9 -22
  75. package/dist/docs/principles.md +8 -6
  76. package/dist/docs/recipes.md +113 -14
  77. package/dist/docs/space.md +10 -6
  78. package/dist/docs/status.md +12 -25
  79. package/dist/docs/surfaces.md +17 -22
  80. package/dist/docs/theming.md +18 -32
  81. package/dist/docs/type.md +12 -5
  82. package/dist/docs/webcomponents.md +66 -38
  83. package/dist/hljs.css +1 -20
  84. package/dist/map-chrome.mapbox.css +68 -92
  85. package/dist/map-chrome.maplibre.css +68 -92
  86. package/dist/registry/items/contour-core.json +2 -2
  87. package/dist/registry/items/contour-data.json +2 -2
  88. package/dist/registry/items/contour-docs.json +2 -2
  89. package/dist/registry/items/contour-landing.json +2 -2
  90. package/dist/registry/registry.json +8 -8
  91. package/dist/surfaces/contour-core.min.css +1 -1
  92. package/dist/surfaces/contour-data.min.css +1 -1
  93. package/dist/surfaces/contour-docs.min.css +1 -1
  94. package/dist/surfaces/contour-landing.min.css +1 -1
  95. package/dist/svg/icons.svg +367 -0
  96. package/dist/wc/behaviours.mjs +190 -148
  97. package/dist/wc/content.mjs +273 -129
  98. package/dist/wc/core.mjs +598 -395
  99. package/dist/wc/dashboard.mjs +64 -44
  100. package/dist/wc/data-chart.mjs +1333 -0
  101. package/dist/wc/data-export.mjs +391 -0
  102. package/dist/wc/data-gauge.mjs +779 -0
  103. package/dist/wc/data-geo.mjs +696 -0
  104. package/dist/wc/data-glyphs.mjs +133 -0
  105. package/dist/wc/data-legend.mjs +431 -0
  106. package/dist/wc/data-readout.mjs +227 -0
  107. package/dist/wc/data-series.mjs +1004 -0
  108. package/dist/wc/data-table.mjs +751 -0
  109. package/dist/wc/data.mjs +15 -4322
  110. package/dist/wc/docs.mjs +12 -11
  111. package/dist/wc/feedback.mjs +277 -122
  112. package/dist/wc/forms-controls.mjs +635 -0
  113. package/dist/wc/forms-field.mjs +547 -0
  114. package/dist/wc/forms-groups.mjs +347 -0
  115. package/dist/wc/forms-input.mjs +292 -0
  116. package/dist/wc/forms.mjs +10 -1751
  117. package/dist/wc/glyph.mjs +204 -0
  118. package/dist/wc/index.mjs +11 -9
  119. package/dist/wc/interaction.mjs +173 -80
  120. package/dist/wc/layout.mjs +28 -27
  121. package/dist/wc/map.mjs +743 -207
  122. package/dist/wc/misc.mjs +31 -20
  123. package/dist/wc/navigation-menu.mjs +735 -0
  124. package/dist/wc/navigation-shell.mjs +495 -0
  125. package/dist/wc/navigation-tree.mjs +995 -0
  126. package/dist/wc/navigation.mjs +9 -1905
  127. package/dist/wc/registration.mjs +1 -8
  128. package/dist/wc/shadow.mjs +206 -110
  129. package/dist/wc/states.mjs +54 -75
  130. package/dist/wc/svg.mjs +118 -47
  131. package/dist/wc/ui-atoms.mjs +608 -0
  132. package/dist/wc/ui-data.mjs +1404 -0
  133. package/dist/wc/ui-feedback.mjs +419 -0
  134. package/dist/wc/ui-inputs.mjs +1570 -0
  135. package/dist/wc/ui-menus.mjs +307 -0
  136. package/dist/wc/ui-overlays.mjs +1605 -0
  137. package/integrations/README.md +23 -5
  138. package/integrations/ai/CLAUDE.md +3 -0
  139. package/integrations/ai/COPILOT.md +14 -0
  140. package/integrations/ai/GEMINI.md +14 -0
  141. package/integrations/ai/WINDSURF.md +14 -0
  142. package/integrations/ai/v0-prompt.md +13 -1
  143. package/integrations/native/README.md +0 -3
  144. package/integrations/tailwind/contour-theme.css +66 -7
  145. package/integrations/validate-markup.mjs +172 -0
  146. package/package.json +77 -42
  147. package/dist/wc/ui.mjs +0 -5072
@@ -0,0 +1,227 @@
1
+ import { ContourBase, define, onDispose, formatValue, contourId, navKey, isRtl, cssLength , safeColor, warnBadJson, labelText } from './core.mjs';
2
+ import { loadRemote, remoteData, renderStates, renderEmpty, wireStates, remoteInvalidate, watchViewport, parseArrayAttr, stateLabel } from './states.mjs';
3
+ import { donutSlices, barRects, smoothPath, polylinePoints, contourPaths } from './svg.mjs';
4
+ import { paintDonutGlyph, paintSparklineGlyph, paintPurityRing } from './glyph.mjs';
5
+
6
+ /**
7
+ * Readout: web component wrapper.
8
+ * Attributes: `rows`, `empty`, `loading`, `error`, `retry`, `src`, `lazy`, `refresh`, `timeout`, `skeleton`, `format`, `locale`.
9
+ */
10
+ class ContourReadout extends ContourBase {
11
+ static get observed() { return ["rows", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton", "format", "locale", "unit", "precision", "cache-key", "no-cache"]; }
12
+ static get properties() { return { rows: { attribute: "rows" }, format: { attribute: "format" }, locale: { attribute: "locale" }, precision: { attribute: "precision" }, src: { attribute: "src" } }; }
13
+ render() {
14
+ this.classList.add("c-readout");
15
+ wireStates(this);
16
+ loadRemote(this, "rows");
17
+ if (renderStates(this, "readout")) return;
18
+ const rows = remoteData(this, "rows");
19
+ Array.from(this.querySelectorAll(".c-readout__row")).forEach((n) => n.remove());
20
+ const authored = Array.from(this.children).filter((n) => !n.classList || !n.classList.contains("c-readout__row"));
21
+ if (rows && !authored.length) {
22
+ try {
23
+ const parsed = JSON.parse(rows);
24
+ parsed.forEach((r) => {
25
+ const row = document.createElement("div");
26
+ row.className = "c-readout__row";
27
+ const key = document.createElement("span");
28
+ key.className = "c-readout__key";
29
+ key.textContent = r.key || r[0];
30
+ const val = document.createElement("span");
31
+ val.className = "c-readout__value" + (r.primary ? " c-readout__value--primary" : "") + (r.accent ? " c-readout__value--accent" : "") + (r.coord ? " c-readout__value--coord" : "");
32
+ val.setAttribute("aria-live", "polite");
33
+ const rawVal = r.value !== undefined ? r.value : r[1];
34
+ const prec = r.precision !== undefined ? r.precision : this.getAttribute("precision");
35
+ if (prec !== null && prec !== "") val.dataset.precision = String(prec);
36
+ const displayVal = (prec !== null && prec !== "" && typeof rawVal === "number" && Number.isFinite(rawVal))
37
+ ? rawVal.toFixed(Math.max(0, Math.min(20, Number(prec) || 0)))
38
+ : rawVal;
39
+ val.textContent = formatValue(displayVal, this.getAttribute("format"), this.getAttribute("locale"), (r.unit !== undefined ? r.unit : this.getAttribute("unit")));
40
+ row.appendChild(key);
41
+ row.appendChild(val);
42
+ if (r.order) {
43
+ const ord = document.createElement("span");
44
+ ord.className = "c-readout__order";
45
+ ord.textContent = r.order;
46
+ row.appendChild(ord);
47
+ }
48
+ this.appendChild(row);
49
+ });
50
+ } catch (e) { warnBadJson(this, "attribute", e); }
51
+ } else if (!rows && !authored.length) {
52
+ renderEmpty(this, "readout");
53
+ }
54
+ }
55
+ }
56
+ define("contour-readout", ContourReadout);
57
+ /**
58
+ * Kpi: web component wrapper.
59
+ * Attributes: `value`, `label`, `delta`, `direction`, `note`, `variant`, `unit`, `format`, `locale`, `empty`, `loading`, `error`, `retry`, `src`, `lazy`, `refresh`, `timeout`, `skeleton`, `thresholds`, `threshold`, `sparkline`, `polarity`.
60
+ */
61
+ class ContourKpi extends ContourBase {
62
+ 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"]; }
63
+ static get properties() {
64
+ 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" } };
65
+ }
66
+ render() {
67
+ this.classList.add("c-kpi");
68
+ wireStates(this);
69
+ loadRemote(this, ["value", "label"]);
70
+ if (renderStates(this, "kpi")) return;
71
+ const value = remoteData(this, "value");
72
+ const label = remoteData(this, "label");
73
+ const delta = this.getAttribute("delta");
74
+ const variant = this.getAttribute("variant");
75
+ Array.from(this.classList).forEach((c) => { if (c.startsWith("c-kpi--")) this.classList.remove(c); });
76
+ if (variant) this.classList.add("c-kpi--" + variant);
77
+ if (value) {
78
+ const v = this.ensure(".c-kpi__value", () => { const el = document.createElement("div"); el.className = "c-kpi__value"; el.setAttribute("aria-live", "polite"); return el; });
79
+ v.textContent = formatValue(value, this.getAttribute("format"), this.getAttribute("locale"), this.getAttribute("unit"));
80
+ } else {
81
+ const v = this.querySelector(".c-kpi__value");
82
+ if (v) v.remove();
83
+ }
84
+ if (label) {
85
+ const h = this.ensure(".c-kpi__head", () => { const el = document.createElement("div"); el.className = "c-kpi__head"; return el; });
86
+ let l = h.querySelector(".c-kpi__label");
87
+ if (!l) { l = document.createElement("div"); l.className = "c-kpi__label"; h.appendChild(l); }
88
+ l.textContent = label;
89
+ if (h.parentNode !== this) this.insertBefore(h, this.firstChild);
90
+ } else {
91
+ const h = this.querySelector(".c-kpi__head");
92
+ if (h) h.remove();
93
+ }
94
+ if (delta) {
95
+ const f = this.ensure(".c-kpi__foot", () => { const el = document.createElement("div"); el.className = "c-kpi__foot"; return el; });
96
+ const d = f.querySelector(".c-delta") || document.createElement("span");
97
+ if (!d.parentNode) f.insertBefore(d, f.firstChild);
98
+ const dir = this.getAttribute("direction") || "up";
99
+ const polarity = this.getAttribute("polarity") || "neutral";
100
+ let tone = "neutral";
101
+ if (polarity === "good" || polarity === "up-good" || polarity === "auto") {
102
+ tone = (dir === "up") ? "good" : (dir === "down" ? "bad" : "neutral");
103
+ } else if (polarity === "bad" || polarity === "down-good") {
104
+ tone = (dir === "up") ? "bad" : (dir === "down" ? "good" : "neutral");
105
+ }
106
+ d.className = "c-delta c-delta--" + dir + " c-delta--" + tone;
107
+ // R31-57 (D13): the KPI delta was bare text, so polarity rode on
108
+ // colour alone. Render the same arrow contour-delta uses, then the
109
+ // signed value — shape carries the direction, colour is redundant.
110
+ d.textContent = "";
111
+ const icon = { up: "#i-arrow-up", down: "#i-arrow-down", flat: "#i-minus" }[dir] || "#i-arrow-up";
112
+ const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
113
+ svg.setAttribute("aria-hidden", "true");
114
+ const use = document.createElementNS("http://www.w3.org/2000/svg", "use");
115
+ use.setAttribute("href", icon);
116
+ svg.appendChild(use);
117
+ d.appendChild(svg);
118
+ d.appendChild(document.createTextNode(" " + delta));
119
+ } else {
120
+ const d = this.querySelector(".c-kpi__foot .c-delta");
121
+ if (d) d.remove();
122
+ }
123
+ const note = this.getAttribute("note");
124
+ if (note) {
125
+ const f = this.ensure(".c-kpi__foot", () => { const el = document.createElement("div"); el.className = "c-kpi__foot"; return el; });
126
+ const n = f.querySelector(".c-kpi__note") || (() => { const el = document.createElement("span"); el.className = "c-kpi__note"; f.appendChild(el); return el; })();
127
+ n.textContent = note;
128
+ } else {
129
+ const n = this.querySelector(".c-kpi__note");
130
+ if (n) n.remove();
131
+ }
132
+ const unit = this.getAttribute("unit");
133
+ const v = this.querySelector(".c-kpi__value");
134
+ if (v) {
135
+ if (unit) {
136
+ let u = v.querySelector(".c-kpi__unit");
137
+ if (!u) { u = document.createElement("span"); u.className = "c-kpi__unit"; v.appendChild(u); }
138
+ u.textContent = unit;
139
+ } else {
140
+ const u = v.querySelector(".c-kpi__unit");
141
+ if (u) u.remove();
142
+ }
143
+ }
144
+ const threshold = this.getAttribute("threshold") || this.getAttribute("thresholds");
145
+ if (threshold) {
146
+ const f = this.ensure(".c-kpi__foot", () => { const el = document.createElement("div"); el.className = "c-kpi__foot"; return el; });
147
+ let badge = f.querySelector(".c-kpi__threshold-badge");
148
+ if (!badge) { badge = document.createElement("span"); badge.className = "c-kpi__threshold-badge"; f.appendChild(badge); }
149
+ badge.textContent = threshold;
150
+ badge.setAttribute("part", "threshold-badge");
151
+ } else {
152
+ const b = this.querySelector(".c-kpi__threshold-badge");
153
+ if (b) b.remove();
154
+ }
155
+ // remove orphaned foot container when no children remain
156
+ const foot = this.querySelector(".c-kpi__foot");
157
+ if (foot && !foot.querySelector(".c-delta, .c-kpi__note, .c-kpi__threshold-badge")) foot.remove();
158
+ // Sparkline: draw series via contour-sparkline geometry.
159
+ const spark = this.getAttribute("sparkline");
160
+ const sparkOn = spark !== null && spark !== "" && spark !== "0" && spark.toLowerCase() !== "false";
161
+ const oldCanvas = this.querySelector(".c-kpi__sparkline-canvas");
162
+ if (oldCanvas) oldCanvas.remove();
163
+ if (sparkOn) {
164
+ let series = null;
165
+ try { series = JSON.parse(spark); } catch (e) { series = null; }
166
+ if (!Array.isArray(series)) series = null;
167
+ const nums = (series || []).map((v) => Number(v)).filter((n) => Number.isFinite(n));
168
+ if (nums.length > 1) {
169
+ const canvas = document.createElement("canvas");
170
+ canvas.className = "c-kpi__sparkline-canvas";
171
+ canvas.setAttribute("part", "sparkline-canvas");
172
+ canvas.setAttribute("aria-hidden", "true");
173
+ this.appendChild(canvas);
174
+ this._sparkSeries = nums;
175
+ // Draw after layout: the canvas has no box until it is in the
176
+ // document, and a 0-width canvas silently draws nothing.
177
+ const draw = () => {
178
+ if (!canvas.isConnected) return;
179
+ const w = canvas.clientWidth;
180
+ const h = canvas.clientHeight;
181
+ if (!w || !h) return;
182
+ const dpr = (typeof window !== "undefined" && window.devicePixelRatio) || 1;
183
+ canvas.width = Math.round(w * dpr);
184
+ canvas.height = Math.round(h * dpr);
185
+ const ctx = canvas.getContext && canvas.getContext("2d");
186
+ if (!ctx) return;
187
+ ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
188
+ ctx.clearRect(0, 0, w, h);
189
+ const lo = Math.min.apply(null, nums);
190
+ const hi = Math.max.apply(null, nums);
191
+ const range = (hi - lo) || 1;
192
+ const pad = 2;
193
+ const x = (i) => (i / (nums.length - 1)) * (w - pad * 2) + pad;
194
+ const y = (v) => h - pad - ((v - lo) / range) * (h - pad * 2);
195
+ // Resolve --chart-1 through a probe element so light-dark()/var() resolve against host scheme.
196
+ let stroke = getComputedStyle(this).getPropertyValue("--chart-1").trim();
197
+ if (!stroke || /^(var|light-dark)\(/.test(stroke)) {
198
+ const probe = document.createElement("span");
199
+ probe.style.display = "none";
200
+ probe.style.color = stroke || "var(--chart-1, #666)";
201
+ this.appendChild(probe);
202
+ stroke = getComputedStyle(probe).color || "#666";
203
+ probe.remove();
204
+ }
205
+ ctx.beginPath();
206
+ ctx.lineWidth = 1.5;
207
+ ctx.strokeStyle = stroke;
208
+ nums.forEach((v, i) => { const px = x(i), py = y(v); if (i === 0) ctx.moveTo(px, py); else ctx.lineTo(px, py); });
209
+ ctx.stroke();
210
+ };
211
+ // First draw on the next frame so the box has been laid out; a
212
+ // ResizeObserver keeps it correct when the host is resized.
213
+ if (typeof requestAnimationFrame === "function") requestAnimationFrame(draw);
214
+ else draw();
215
+ if (typeof ResizeObserver !== "undefined" && !this._sparkRO) {
216
+ this._sparkRO = new ResizeObserver(() => draw());
217
+ onDispose(this, () => { if (this._sparkRO) { this._sparkRO.disconnect(); this._sparkRO = null; } });
218
+ }
219
+ if (this._sparkRO) this._sparkRO.observe(canvas);
220
+ }
221
+ }
222
+ if (!value && !label) {
223
+ renderEmpty(this, "kpi");
224
+ }
225
+ }
226
+ }
227
+ define("contour-kpi", ContourKpi);