contour-ds 1.7.2 → 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 (150) hide show
  1. package/README.md +244 -326
  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/agent-rules.json +16 -0
  6. package/dist/build-manifest.json +344 -126
  7. package/dist/contour-wc-content.esm.js +1939 -0
  8. package/dist/contour-wc-content.esm.min.js +1 -0
  9. package/dist/contour-wc-core.esm.js +3724 -0
  10. package/dist/contour-wc-core.esm.min.js +1 -0
  11. package/dist/contour-wc-dashboard.esm.js +6986 -0
  12. package/dist/contour-wc-dashboard.esm.min.js +1 -0
  13. package/dist/contour-wc-data.esm.js +6572 -0
  14. package/dist/contour-wc-data.esm.min.js +1 -0
  15. package/dist/contour-wc-docs.esm.js +976 -0
  16. package/dist/contour-wc-docs.esm.min.js +1 -0
  17. package/dist/contour-wc-feedback.esm.js +1742 -0
  18. package/dist/contour-wc-feedback.esm.min.js +1 -0
  19. package/dist/contour-wc-forms.esm.js +2437 -0
  20. package/dist/contour-wc-forms.esm.min.js +1 -0
  21. package/dist/contour-wc-interaction.esm.js +1343 -0
  22. package/dist/contour-wc-interaction.esm.min.js +1 -0
  23. package/dist/contour-wc-layout.esm.js +845 -0
  24. package/dist/contour-wc-layout.esm.min.js +1 -0
  25. package/dist/contour-wc-map.esm.js +2411 -0
  26. package/dist/contour-wc-map.esm.min.js +1 -0
  27. package/dist/contour-wc-misc.esm.js +945 -0
  28. package/dist/contour-wc-misc.esm.min.js +1 -0
  29. package/dist/contour-wc-navigation.esm.js +2842 -0
  30. package/dist/contour-wc-navigation.esm.min.js +1 -0
  31. package/dist/contour-wc-ui.esm.js +6519 -0
  32. package/dist/contour-wc-ui.esm.min.js +1 -0
  33. package/dist/contour-wc.esm.js +14435 -5723
  34. package/dist/contour-wc.esm.min.js +1 -1
  35. package/dist/contour-wc.js +14436 -5725
  36. package/dist/contour-wc.min.js +1 -1
  37. package/dist/contour.a11y.json +402 -0
  38. package/dist/contour.code-snippets +4534 -0
  39. package/dist/contour.components.json +4870 -1222
  40. package/dist/contour.css +6672 -4711
  41. package/dist/contour.d.ts +753 -1085
  42. package/dist/contour.esm.js +440 -18
  43. package/dist/contour.esm.min.js +1 -1
  44. package/dist/contour.html-data.json +11343 -0
  45. package/dist/contour.js +440 -18
  46. package/dist/contour.min.css +1 -1
  47. package/dist/contour.min.js +1 -1
  48. package/dist/contour.react.d.ts +422 -0
  49. package/dist/contour.single.html +17 -0
  50. package/dist/contour.single.min.css +1 -0
  51. package/dist/contour.themes.json +56 -12
  52. package/dist/contour.tokens.json +1318 -1053
  53. package/dist/contour.vue.d.ts +420 -0
  54. package/dist/contour.web-types.json +11703 -0
  55. package/dist/custom-elements.json +36120 -0
  56. package/dist/docs/actions.md +16 -6
  57. package/dist/docs/affordances.md +21 -85
  58. package/dist/docs/apireference.md +9 -5
  59. package/dist/docs/colour.md +10 -4
  60. package/dist/docs/componentindex.md +9 -22
  61. package/dist/docs/data.md +39 -58
  62. package/dist/docs/docs.md +12 -7
  63. package/dist/docs/feedback.md +30 -12
  64. package/dist/docs/field.md +28 -13
  65. package/dist/docs/forms.md +35 -19
  66. package/dist/docs/index.json +70 -61
  67. package/dist/docs/install.md +12 -7
  68. package/dist/docs/landing.md +7 -4
  69. package/dist/docs/mapengine.md +30 -8
  70. package/dist/docs/motion.md +12 -6
  71. package/dist/docs/navigation.md +31 -7
  72. package/dist/docs/overlays.md +32 -25
  73. package/dist/docs/overview.md +3 -2
  74. package/dist/docs/patterns.md +20 -10
  75. package/dist/docs/playground.md +11 -4
  76. package/dist/docs/principles.md +8 -6
  77. package/dist/docs/recipes.md +117 -13
  78. package/dist/docs/space.md +10 -6
  79. package/dist/docs/status.md +13 -14
  80. package/dist/docs/surfaces.md +17 -22
  81. package/dist/docs/theming.md +18 -32
  82. package/dist/docs/type.md +12 -5
  83. package/dist/docs/webcomponents.md +75 -33
  84. package/dist/hljs.css +1 -20
  85. package/dist/map-chrome.mapbox.css +68 -92
  86. package/dist/map-chrome.maplibre.css +68 -92
  87. package/dist/registry/items/contour-core.json +2 -2
  88. package/dist/registry/items/contour-data.json +2 -2
  89. package/dist/registry/items/contour-docs.json +2 -2
  90. package/dist/registry/items/contour-landing.json +2 -2
  91. package/dist/registry/registry.json +8 -8
  92. package/dist/surfaces/contour-core.min.css +1 -1
  93. package/dist/surfaces/contour-data.min.css +1 -1
  94. package/dist/surfaces/contour-docs.min.css +1 -1
  95. package/dist/surfaces/contour-landing.min.css +1 -1
  96. package/dist/svg/icons.svg +367 -0
  97. package/dist/wc/behaviours.mjs +222 -192
  98. package/dist/wc/content.mjs +486 -142
  99. package/dist/wc/core.mjs +917 -395
  100. package/dist/wc/dashboard.mjs +252 -25
  101. package/dist/wc/data-chart.mjs +1333 -0
  102. package/dist/wc/data-export.mjs +391 -0
  103. package/dist/wc/data-gauge.mjs +779 -0
  104. package/dist/wc/data-geo.mjs +696 -0
  105. package/dist/wc/data-glyphs.mjs +133 -0
  106. package/dist/wc/data-legend.mjs +431 -0
  107. package/dist/wc/data-readout.mjs +227 -0
  108. package/dist/wc/data-series.mjs +1004 -0
  109. package/dist/wc/data-table.mjs +751 -0
  110. package/dist/wc/data.mjs +15 -3707
  111. package/dist/wc/docs.mjs +113 -19
  112. package/dist/wc/feedback.mjs +320 -116
  113. package/dist/wc/forms-controls.mjs +635 -0
  114. package/dist/wc/forms-field.mjs +547 -0
  115. package/dist/wc/forms-groups.mjs +347 -0
  116. package/dist/wc/forms-input.mjs +292 -0
  117. package/dist/wc/forms.mjs +10 -1122
  118. package/dist/wc/glyph.mjs +204 -0
  119. package/dist/wc/index.mjs +16 -7
  120. package/dist/wc/interaction.mjs +322 -75
  121. package/dist/wc/layout.mjs +100 -29
  122. package/dist/wc/map.mjs +888 -285
  123. package/dist/wc/misc.mjs +137 -26
  124. package/dist/wc/navigation-menu.mjs +735 -0
  125. package/dist/wc/navigation-shell.mjs +495 -0
  126. package/dist/wc/navigation-tree.mjs +995 -0
  127. package/dist/wc/navigation.mjs +9 -1636
  128. package/dist/wc/registration.mjs +1 -8
  129. package/dist/wc/shadow.mjs +285 -113
  130. package/dist/wc/states.mjs +75 -78
  131. package/dist/wc/svg.mjs +209 -34
  132. package/dist/wc/ui-atoms.mjs +608 -0
  133. package/dist/wc/ui-data.mjs +1404 -0
  134. package/dist/wc/ui-feedback.mjs +419 -0
  135. package/dist/wc/ui-inputs.mjs +1570 -0
  136. package/dist/wc/ui-menus.mjs +307 -0
  137. package/dist/wc/ui-overlays.mjs +1605 -0
  138. package/integrations/README.md +25 -5
  139. package/integrations/ai/CLAUDE.md +6 -3
  140. package/integrations/ai/COPILOT.md +14 -0
  141. package/integrations/ai/GEMINI.md +14 -0
  142. package/integrations/ai/WINDSURF.md +14 -0
  143. package/integrations/ai/v0-prompt.md +13 -1
  144. package/integrations/frameworks/README.md +235 -0
  145. package/integrations/native/README.md +0 -3
  146. package/integrations/native/style-dictionary.config.json +1 -1
  147. package/integrations/tailwind/contour-theme.css +71 -13
  148. package/integrations/validate-markup.mjs +172 -0
  149. package/package.json +103 -39
  150. package/dist/wc/ui.mjs +0 -3560
@@ -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);