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.
Files changed (130) hide show
  1. package/README.md +4 -4
  2. package/dist/build-manifest.json +205 -204
  3. package/dist/contour-wc-content.esm.js +1 -1
  4. package/dist/contour-wc-content.esm.min.js +1 -1
  5. package/dist/contour-wc-core.esm.js +712 -45
  6. package/dist/contour-wc-core.esm.min.js +1 -1
  7. package/dist/contour-wc-dashboard.esm.js +596 -90
  8. package/dist/contour-wc-dashboard.esm.min.js +1 -1
  9. package/dist/contour-wc-data.esm.js +467 -70
  10. package/dist/contour-wc-data.esm.min.js +1 -1
  11. package/dist/contour-wc-docs.esm.js +1 -1
  12. package/dist/contour-wc-docs.esm.min.js +1 -1
  13. package/dist/contour-wc-feedback.esm.js +260 -29
  14. package/dist/contour-wc-feedback.esm.min.js +1 -1
  15. package/dist/contour-wc-forms.esm.js +133 -40
  16. package/dist/contour-wc-forms.esm.min.js +1 -1
  17. package/dist/contour-wc-interaction.esm.js +64 -5
  18. package/dist/contour-wc-interaction.esm.min.js +1 -1
  19. package/dist/contour-wc-layout.esm.js +72 -10
  20. package/dist/contour-wc-layout.esm.min.js +1 -1
  21. package/dist/contour-wc-map.esm.js +69 -9
  22. package/dist/contour-wc-map.esm.min.js +1 -1
  23. package/dist/contour-wc-misc.esm.js +1 -1
  24. package/dist/contour-wc-misc.esm.min.js +1 -1
  25. package/dist/contour-wc-navigation.esm.js +136 -20
  26. package/dist/contour-wc-navigation.esm.min.js +1 -1
  27. package/dist/contour-wc-ui.esm.js +505 -80
  28. package/dist/contour-wc-ui.esm.min.js +1 -1
  29. package/dist/contour-wc.esm.js +2539 -320
  30. package/dist/contour-wc.esm.min.js +1 -1
  31. package/dist/contour-wc.js +2539 -320
  32. package/dist/contour-wc.min.js +1 -1
  33. package/dist/contour.code-snippets +44 -0
  34. package/dist/contour.components.json +12064 -135
  35. package/dist/contour.css +1368 -451
  36. package/dist/contour.d.ts +42 -21
  37. package/dist/contour.esm.js +138 -21
  38. package/dist/contour.esm.min.js +1 -1
  39. package/dist/contour.html-data.json +249 -9
  40. package/dist/contour.js +138 -21
  41. package/dist/contour.min.css +1 -1
  42. package/dist/contour.min.js +1 -1
  43. package/dist/contour.react.d.ts +5 -1
  44. package/dist/contour.single.html +2 -2
  45. package/dist/contour.single.min.css +1 -1
  46. package/dist/contour.tokens.json +36 -1
  47. package/dist/contour.vue.d.ts +5 -1
  48. package/dist/contour.web-types.json +241 -9
  49. package/dist/custom-elements.json +1225 -55
  50. package/dist/docs/actions.md +1 -1
  51. package/dist/docs/affordances.md +1 -1
  52. package/dist/docs/apireference.md +1 -1
  53. package/dist/docs/colour.md +1 -1
  54. package/dist/docs/componentindex.md +1 -1
  55. package/dist/docs/data.md +6 -2
  56. package/dist/docs/docs.md +1 -1
  57. package/dist/docs/feedback.md +1 -1
  58. package/dist/docs/field.md +1 -1
  59. package/dist/docs/forms.md +1 -1
  60. package/dist/docs/index.json +8 -8
  61. package/dist/docs/install.md +1 -1
  62. package/dist/docs/landing.md +1 -1
  63. package/dist/docs/mapengine.md +1 -1
  64. package/dist/docs/motion.md +1 -1
  65. package/dist/docs/navigation.md +1 -1
  66. package/dist/docs/overlays.md +1 -1
  67. package/dist/docs/overview.md +1 -1
  68. package/dist/docs/patterns.md +1 -1
  69. package/dist/docs/playground.md +1 -1
  70. package/dist/docs/principles.md +1 -1
  71. package/dist/docs/recipes.md +1 -1
  72. package/dist/docs/space.md +1 -1
  73. package/dist/docs/status.md +1 -1
  74. package/dist/docs/surfaces.md +1 -1
  75. package/dist/docs/theming.md +5 -2
  76. package/dist/docs/type.md +1 -1
  77. package/dist/docs/webcomponents.md +1 -1
  78. package/dist/hljs.css +34 -17
  79. package/dist/map-chrome-contract.json +26 -0
  80. package/dist/map-chrome.mapbox.css +121 -0
  81. package/dist/map-chrome.maplibre.css +121 -0
  82. package/dist/registry/items/contour-core.json +2 -2
  83. package/dist/registry/items/contour-data.json +2 -2
  84. package/dist/registry/items/contour-docs.json +2 -2
  85. package/dist/registry/items/contour-landing.json +2 -2
  86. package/dist/registry/registry.json +8 -8
  87. package/dist/surfaces/contour-core.min.css +1 -1
  88. package/dist/surfaces/contour-data.min.css +1 -1
  89. package/dist/surfaces/contour-docs.min.css +1 -1
  90. package/dist/surfaces/contour-landing.min.css +1 -1
  91. package/dist/wc/behaviours.mjs +11 -3
  92. package/dist/wc/core.mjs +307 -32
  93. package/dist/wc/dashboard.mjs +129 -20
  94. package/dist/wc/data-chart.mjs +170 -22
  95. package/dist/wc/data-export.mjs +150 -29
  96. package/dist/wc/data-gauge.mjs +11 -4
  97. package/dist/wc/data-geo.mjs +1 -1
  98. package/dist/wc/data-legend.mjs +15 -2
  99. package/dist/wc/data-readout.mjs +12 -1
  100. package/dist/wc/data-series.mjs +73 -5
  101. package/dist/wc/data-table.mjs +37 -8
  102. package/dist/wc/feedback.mjs +259 -28
  103. package/dist/wc/forms-controls.mjs +44 -16
  104. package/dist/wc/forms-field.mjs +46 -4
  105. package/dist/wc/forms-groups.mjs +31 -8
  106. package/dist/wc/forms-input.mjs +11 -11
  107. package/dist/wc/index.mjs +1 -1
  108. package/dist/wc/interaction.mjs +63 -4
  109. package/dist/wc/layout.mjs +72 -10
  110. package/dist/wc/map.mjs +68 -8
  111. package/dist/wc/navigation-menu.mjs +43 -9
  112. package/dist/wc/navigation-shell.mjs +39 -6
  113. package/dist/wc/navigation-tree.mjs +53 -4
  114. package/dist/wc/states.mjs +350 -9
  115. package/dist/wc/svg.mjs +43 -0
  116. package/dist/wc/ui-data.mjs +268 -28
  117. package/dist/wc/ui-feedback.mjs +36 -11
  118. package/dist/wc/ui-inputs.mjs +63 -25
  119. package/dist/wc/ui-overlays.mjs +138 -16
  120. package/integrations/ai/v0-prompt.md +1 -1
  121. package/integrations/frameworks/fixtures/authored/sample.jsx +15 -0
  122. package/integrations/frameworks/fixtures/authored/sample.vue +15 -0
  123. package/integrations/frameworks/fixtures/dist/rendered.html +32 -0
  124. package/integrations/libreship/contract.json +1025 -0
  125. package/integrations/native/README.md +24 -4
  126. package/integrations/native/build/android/colors.xml +278 -0
  127. package/integrations/native/build/flutter/contour_tokens.dart +280 -0
  128. package/integrations/native/build/ios/ContourTokens.swift +280 -0
  129. package/integrations/validate-markup.mjs +57 -7
  130. package/package.json +45 -18
@@ -73,8 +73,24 @@ class ContourErrorBoundary extends ContourBase {
73
73
  define("contour-error-boundary", ContourErrorBoundary);
74
74
 
75
75
  class ContourDataExport extends ContourBase {
76
- static get observed() { return ["data", "format", "filename", "label"]; }
77
- static get properties() { return { data: { attribute: "data" }, format: { attribute: "format" }, filename: { attribute: "filename" }, label: { attribute: "label" } }; }
76
+ static get observed() { return ["data", "format", "filename", "label", "scope", "crs", "provenance", "selected"]; }
77
+ static get properties() { return { data: { attribute: "data" }, format: { attribute: "format" }, filename: { attribute: "filename" }, label: { attribute: "label" }, scope: { attribute: "scope" }, crs: { attribute: "crs" }, provenance: { attribute: "provenance" }, selected: { attribute: "selected" } }; }
78
+ // R34-164: export intent. `scope` narrows the `data` array to the rows a
79
+ // consumer means to export — visible / filtered / selected / all (default).
80
+ // `selected` is a JSON array of row keys (or rows carrying `selected: true`);
81
+ // `visible`/`filtered` read a per-row flag so a host that already computed the
82
+ // view can hand the full array and let the export honour the scope.
83
+ scopeRows(rows, scope) {
84
+ if (scope === "selected") {
85
+ let keys = null;
86
+ const sel = this.getAttribute("selected");
87
+ if (sel) { try { const a = JSON.parse(sel); if (Array.isArray(a)) keys = new Set(a.map((k) => String(k))); } catch (e) { warnBadJson(this, "selected", e); } }
88
+ return rows.filter((r) => (keys ? keys.has(String(r && (r.key ?? r.id ?? ""))) : !!(r && r.selected)));
89
+ }
90
+ if (scope === "visible") return rows.filter((r) => r && r.visible !== false);
91
+ if (scope === "filtered") return rows.filter((r) => r && r.filtered !== true);
92
+ return rows;
93
+ }
78
94
  render() {
79
95
  this.classList.add("c-data-export");
80
96
  if (!this.hasAttribute("role")) this.setAttribute("role", "group");
@@ -109,20 +125,26 @@ class ContourDataExport extends ContourBase {
109
125
  if (!btn || !this.contains(btn)) return;
110
126
  const rawFmt = (this.getAttribute("format") || "json").toLowerCase();
111
127
  const fmt = (rawFmt === "csv" || rawFmt === "json") ? rawFmt : (console.warn("[contour-data-export] unsupported format:", rawFmt), "json");
128
+ const scope = (this.getAttribute("scope") || "all").toLowerCase();
112
129
  const raw = this.getAttribute("data") || "[]";
130
+ let allRows = [];
131
+ let parsed = false;
132
+ try { const a = JSON.parse(raw); if (Array.isArray(a)) { allRows = a; parsed = true; } } catch (err) { warnBadJson(this, "data", err); }
133
+ const rows = this.scopeRows(allRows, scope);
134
+ const count = rows.length;
135
+ const total = allRows.length;
113
136
  let text = raw;
114
- if (fmt === "csv") {
115
- try {
116
- const arr = JSON.parse(raw);
117
- if (Array.isArray(arr)) {
118
- if (arr.length === 0) {
119
- text = "";
120
- } else {
121
- const keys = Object.keys(arr[0]);
122
- text = [keys.map(csvCell).join(",")].concat(arr.map((r) => keys.map((k) => csvCell(r[k])).join(","))).join("\r\n");
123
- }
137
+ if (parsed && (scope !== "all" || fmt === "csv")) {
138
+ if (fmt === "csv") {
139
+ if (rows.length === 0) {
140
+ text = "";
141
+ } else {
142
+ const keys = Object.keys(rows[0]);
143
+ text = [keys.map(csvCell).join(",")].concat(rows.map((r) => keys.map((k) => csvCell(r[k])).join(","))).join("\r\n");
124
144
  }
125
- } catch (err) { warnBadJson(this, "data", err); }
145
+ } else {
146
+ text = JSON.stringify(rows);
147
+ }
126
148
  }
127
149
  // R31-49: prepend a UTF-8 BOM to CSV so Excel/Sheets read non-ASCII
128
150
  // correctly; revoke the object URL asynchronously so the download has
@@ -130,23 +152,44 @@ class ContourDataExport extends ContourBase {
130
152
  // it in some engines).
131
153
  const blob = new Blob([fmt === "csv" ? "\uFEFF" + text : text], { type: fmt === "csv" ? "text/csv" : "application/json" });
132
154
  const url = URL.createObjectURL(blob);
155
+ const filename = this.getAttribute("filename") || ("export." + fmt);
133
156
  const a = document.createElement("a");
134
157
  a.href = url;
135
- a.download = this.getAttribute("filename") || ("export." + fmt);
158
+ a.download = filename;
136
159
  document.body.appendChild(a);
137
160
  a.click();
138
161
  a.remove();
139
162
  setTimeout(() => URL.revokeObjectURL(url), 0);
140
- this.dispatchEvent(new CustomEvent("contour:export", { bubbles: true, composed: true, detail: { format: fmt } }));
163
+ // R34-164: file metadata + intent so a host can report what was written
164
+ // (scope, count/total for progress, resolved filename, CRS/provenance).
165
+ const detail = { format: fmt, scope, count, total, filename };
166
+ const crs = this.getAttribute("crs");
167
+ if (crs) detail.crs = crs;
168
+ const provenance = this.getAttribute("provenance");
169
+ if (provenance) detail.provenance = provenance;
170
+ this.dispatchEvent(new CustomEvent("contour:export", { bubbles: true, composed: true, detail }));
141
171
  });
142
172
  }
143
173
  }
144
174
  define("contour-data-export", ContourDataExport);
145
175
 
146
176
  // Query builder: field/operator/value rows with AND/OR connectors, remove button per row, Add rule button; renders from `query` JSON, emits contour:change.
177
+ /**
178
+ * Read a rule's value from its type-aware editor (R34-165): a range is two
179
+ * inputs joined "low,high", a null checkbox is the string "null", everything
180
+ * else is the single control's value.
181
+ */
182
+ function readRuleValue(row) {
183
+ const low = row.querySelector('.c-query-builder__value[data-part="low"]');
184
+ const high = row.querySelector('.c-query-builder__value[data-part="high"]');
185
+ if (low || high) return [low ? low.value : "", high ? high.value : ""].join(",");
186
+ const nullBox = row.querySelector(".c-query-builder__null");
187
+ if (nullBox) return nullBox.checked ? "null" : "";
188
+ return row.querySelector(".c-query-builder__value")?.value || "";
189
+ }
147
190
  class ContourQueryBuilder extends ContourBase {
148
- static get observed() { return ["query", "fields"]; }
149
- static get properties() { return { query: { attribute: "query" }, fields: { attribute: "fields" } }; }
191
+ static get observed() { return ["query", "fields", "draft"]; }
192
+ static get properties() { return { query: { attribute: "query" }, fields: { attribute: "fields" }, draft: { attribute: "draft", type: Boolean } }; }
150
193
  // Single reader for whole component: add/remove/move/group-edit all need same DOM→query projection; three copies had drifted (connector never read, AND/OR edits silently dropped).
151
194
  readRules() {
152
195
  const rows = [];
@@ -155,13 +198,19 @@ class ContourQueryBuilder extends ContourBase {
155
198
  const conns = Array.from(this.querySelectorAll(".c-query-builder__connector__op"));
156
199
  nodes.forEach((r, i) => {
157
200
  const rule = {
201
+ // R34-165: stable identity. A rule keeps its `id` across structural edits so a
202
+ // consumer's optimistic write targets the same rule, not the row that slid into
203
+ // its index.
204
+ id: r.dataset.ruleId || ("r" + i),
158
205
  field: r.querySelector(".c-query-builder__field")?.value || "",
159
206
  op: r.querySelector(".c-query-builder__op")?.value || "=",
160
- value: r.querySelector(".c-query-builder__value")?.value || "",
207
+ value: readRuleValue(r),
161
208
  };
162
209
  if (i > 0 && conns[i - 1]) rule.connector = conns[i - 1].value || "AND";
163
210
  const g = r.closest(".c-query-builder__group");
164
211
  if (g) rule.group = g._groupName || "";
212
+ // R34-165: NOT is a per-rule negation, a shape+word toggle (never colour).
213
+ if (r.querySelector(".c-query-builder__not")?.getAttribute("aria-pressed") === "true") rule.not = true;
165
214
  rows.push(rule);
166
215
  });
167
216
  return rows;
@@ -178,17 +227,35 @@ class ContourQueryBuilder extends ContourBase {
178
227
  attributeChangedCallback(name, oldValue, newValue) {
179
228
  if (name === "query" && this._suppressQueryRender) return;
180
229
  super.attributeChangedCallback(name, oldValue, newValue);
230
+ // R34-165: removing `draft` finalizes the held draft into `query`.
231
+ if (name === "draft" && oldValue != null && newValue == null && this._draftRows) {
232
+ this.commitDraft();
233
+ }
181
234
  }
182
235
  // Write the model back and say so.
183
236
  commit(rows, rerender = true) {
184
- if (rerender) {
237
+ // R34-165: draft/commit. In draft mode edits are held locally and announced
238
+ // with draft:true; the author's `query` attribute is untouched until the
239
+ // draft is committed (attribute removed or commitDraft() called).
240
+ const draft = this.hasAttribute("draft");
241
+ if (draft) {
242
+ this._draftRows = rows;
243
+ } else if (rerender) {
185
244
  this.setAttribute("query", JSON.stringify(rows));
186
245
  } else {
187
246
  this._suppressQueryRender = true;
188
247
  try { this.setAttribute("query", JSON.stringify(rows)); }
189
248
  finally { this._suppressQueryRender = false; }
190
249
  }
191
- this.dispatchEvent(new CustomEvent("contour:change", { bubbles: true, composed: true, detail: { query: rows } }));
250
+ this.dispatchEvent(new CustomEvent("contour:change", { bubbles: true, composed: true, detail: { query: rows, draft } }));
251
+ }
252
+ // Finalize a draft: write it to `query` and announce draft:false (R34-165).
253
+ commitDraft() {
254
+ const rows = this._draftRows || this.readRules();
255
+ this._draftRows = null;
256
+ this.removeAttribute("draft");
257
+ this.setAttribute("query", JSON.stringify(rows));
258
+ this.dispatchEvent(new CustomEvent("contour:change", { bubbles: true, composed: true, detail: { query: rows, draft: false } }));
192
259
  }
193
260
  render() {
194
261
  this.classList.add("c-query-builder");
@@ -197,7 +264,12 @@ class ContourQueryBuilder extends ContourBase {
197
264
  if (fields) { try { fieldList = JSON.parse(fields); } catch (e) { fieldList = []; } }
198
265
  const query = this.getAttribute("query");
199
266
  let rules = [];
200
- if (query) { try { rules = JSON.parse(query); } catch (e) { rules = []; } }
267
+ // R34-165: in draft mode the rows come from the held draft, not the attr.
268
+ if (this.hasAttribute("draft") && this._draftRows) {
269
+ rules = this._draftRows;
270
+ } else if (query) { try { rules = JSON.parse(query); } catch (e) { rules = []; } }
271
+ // Field metadata (type/options) drives the value editor (R34-165).
272
+ const fieldMeta = (name) => fieldList.find((f) => (typeof f === "string" ? f : (f.value || f.label || "")) === name) || {};
201
273
  const list = this.ensure(".c-query-builder__list", () => { const el = document.createElement("div"); el.className = "c-query-builder__list"; return el; });
202
274
  Array.from(list.querySelectorAll(".c-query-builder__row, .c-query-builder__connector, .c-query-builder__group")).forEach((n) => n.remove());
203
275
  let currentGroup = null;
@@ -253,6 +325,7 @@ class ContourQueryBuilder extends ContourBase {
253
325
  }
254
326
  const row = document.createElement("div");
255
327
  row.className = "c-query-builder__row";
328
+ row.dataset.ruleId = rule.id || ("r" + i);
256
329
  const field = document.createElement("select");
257
330
  field.className = "c-input c-query-builder__field";
258
331
  field.setAttribute("aria-label", labelText(this, "field", "Field") + " " + (i + 1));
@@ -272,13 +345,53 @@ class ContourQueryBuilder extends ContourBase {
272
345
  if (o === rule.op) opt.selected = true;
273
346
  op.appendChild(opt);
274
347
  });
275
- const val = document.createElement("input");
276
- val.className = "c-input c-query-builder__value";
277
- val.type = "text";
278
- // Value attr is identity for base class restore; without it, control matched by index which shifts after structural edits (DW-4).
279
- val.setAttribute("value", rule.value || "");
280
- val.value = rule.value || "";
281
- val.setAttribute("aria-label", labelText(this, "value", "Value") + " " + (i + 1));
348
+ // R34-165: type-aware value editor from field metadata — date picker, enum
349
+ // select, null checkbox, range (two inputs), text fallback.
350
+ const meta = fieldMeta(rule.field);
351
+ const vtype = meta.type || "text";
352
+ const mkText = (type, value, part) => {
353
+ const el = document.createElement("input");
354
+ el.className = "c-input c-query-builder__value";
355
+ el.type = type;
356
+ if (part) el.dataset.part = part;
357
+ el.setAttribute("value", value || "");
358
+ el.value = value || "";
359
+ el.setAttribute("aria-label", labelText(this, "value", "Value") + " " + (i + 1) + (part ? " " + part : ""));
360
+ return el;
361
+ };
362
+ let val;
363
+ if (vtype === "enum" && Array.isArray(meta.options) && meta.options.length) {
364
+ val = document.createElement("select");
365
+ val.className = "c-input c-query-builder__value";
366
+ val.setAttribute("aria-label", labelText(this, "value", "Value") + " " + (i + 1));
367
+ meta.options.forEach((o) => {
368
+ const opt = document.createElement("option");
369
+ opt.value = typeof o === "string" ? o : (o.value ?? o);
370
+ opt.textContent = typeof o === "string" ? o : (o.label ?? o.value ?? o);
371
+ if (opt.value === rule.value) opt.selected = true;
372
+ val.appendChild(opt);
373
+ });
374
+ } else if (vtype === "null") {
375
+ val = document.createElement("input");
376
+ val.type = "checkbox";
377
+ val.className = "c-query-builder__value c-query-builder__null";
378
+ val.checked = rule.value === "null";
379
+ val.setAttribute("aria-label", labelText(this, "is-null", "Is null") + " " + (i + 1));
380
+ } else if (vtype === "range") {
381
+ const parts = String(rule.value || "").split(",");
382
+ val = document.createDocumentFragment();
383
+ val.appendChild(mkText("number", parts[0], "low"));
384
+ val.appendChild(mkText("number", parts[1], "high"));
385
+ } else {
386
+ val = mkText(vtype === "date" ? "date" : "text", rule.value);
387
+ }
388
+ // R34-165: NOT is a per-rule negation toggle (shape+word, aria-pressed).
389
+ const notBtn = document.createElement("button");
390
+ notBtn.type = "button";
391
+ notBtn.className = "c-btn c-btn--sm c-btn--ghost c-query-builder__not";
392
+ notBtn.setAttribute("aria-label", labelText(this, "negate", "Negate") + " " + (i + 1));
393
+ notBtn.setAttribute("aria-pressed", rule.not ? "true" : "false");
394
+ notBtn.textContent = "NOT";
282
395
  // Reordering (WC5-75): buttons not drag handles (pointer-only), so keyboard can reach same operation.
283
396
  const up = document.createElement("button");
284
397
  up.type = "button";
@@ -297,7 +410,7 @@ class ContourQueryBuilder extends ContourBase {
297
410
  remove.className = "c-btn c-btn--sm c-btn--ghost c-query-builder__remove";
298
411
  remove.setAttribute("aria-label", labelText(this, "remove-rule", "Remove rule") + " " + (i + 1));
299
412
  remove.textContent = "\u00d7";
300
- row.appendChild(field); row.appendChild(op); row.appendChild(val);
413
+ row.appendChild(field); row.appendChild(op); row.appendChild(val); row.appendChild(notBtn);
301
414
  row.appendChild(up); row.appendChild(down); row.appendChild(remove);
302
415
  if (currentGroup) currentGroup.appendChild(row); else list.appendChild(row);
303
416
  });
@@ -324,6 +437,14 @@ class ContourQueryBuilder extends ContourBase {
324
437
  this.addEventListener("click", (e) => {
325
438
  const t = e.target;
326
439
  if (!(t instanceof Element)) return;
440
+ // R34-165: NOT toggle flips aria-pressed and commits the negation.
441
+ const notBtn = t.closest(".c-query-builder__not");
442
+ if (notBtn) {
443
+ const next = notBtn.getAttribute("aria-pressed") !== "true";
444
+ notBtn.setAttribute("aria-pressed", String(next));
445
+ this.commit(this.readRules(), false);
446
+ return;
447
+ }
327
448
  if (t.closest(".c-query-builder__add")) {
328
449
  const conns = this.readRules().map((r) => r.connector);
329
450
  const rows = this.readRules();
@@ -444,8 +444,11 @@ class ContourBrush extends ContourBase {
444
444
  const max = () => parseFloat(this.getAttribute("max") || "100");
445
445
  const toValue = (clientX) => {
446
446
  const r = this.getBoundingClientRect();
447
- const ratio = Math.max(0, Math.min(1, (clientX - r.left) / (r.width || 1)));
448
- return min() + ratio * (max() - min());
447
+ // R34-09: in RTL the logical start is at the right, so the physical
448
+ // ratio is mirrored — the pointer maps to the same track unit either way.
449
+ const rtl = (this.ownerDocument.defaultView ? this.ownerDocument.defaultView.getComputedStyle(this).direction : "ltr") === "rtl";
450
+ const ratio = rtl ? (r.right - clientX) / (r.width || 1) : (clientX - r.left) / (r.width || 1);
451
+ return min() + Math.max(0, Math.min(1, ratio)) * (max() - min());
449
452
  };
450
453
  this.addEventListener("pointerdown", (e) => {
451
454
  const handle = e.target && e.target.classList && e.target.classList.contains("c-brush__handle") ? e.target : null;
@@ -520,11 +523,15 @@ class ContourBrush extends ContourBase {
520
523
  return;
521
524
  }
522
525
  let handled = true;
523
- if (e.key === "ArrowLeft" || e.key === "ArrowDown") {
526
+ // R34-09: in RTL the arrow keys follow the logical direction.
527
+ const rtl = (this.ownerDocument.defaultView ? this.ownerDocument.defaultView.getComputedStyle(this).direction : "ltr") === "rtl";
528
+ const leftKey = rtl ? "ArrowRight" : "ArrowLeft";
529
+ const rightKey = rtl ? "ArrowLeft" : "ArrowRight";
530
+ if (e.key === leftKey || e.key === "ArrowDown") {
524
531
  if (which === "start") ns -= step;
525
532
  else if (which === "end") ne -= step;
526
533
  else { const w = ne - ns; ns -= step; ne = ns + w; }
527
- } else if (e.key === "ArrowRight" || e.key === "ArrowUp") {
534
+ } else if (e.key === rightKey || e.key === "ArrowUp") {
528
535
  if (which === "start") ns += step;
529
536
  else if (which === "end") ne += step;
530
537
  else { const w = ne - ns; ne += step; ns = ne - w; }
@@ -41,7 +41,7 @@ class ContourMeasure extends ContourBase {
41
41
  }
42
42
  // unit selector
43
43
  let sel = this.querySelector(".c-measure__unit-select");
44
- if (!sel) { sel = document.createElement("select"); sel.className = "c-measure__unit-select"; sel.setAttribute("aria-label", labelText(this, "unit", "Unit")); sel.setAttribute("data-contour-label", "true"); this.appendChild(sel); }
44
+ if (!sel) { sel = document.createElement("select"); sel.className = "c-select c-measure__unit-select"; sel.setAttribute("aria-label", labelText(this, "unit", "Unit")); sel.setAttribute("data-contour-label", "true"); this.appendChild(sel); }
45
45
  ["m","km","mi","ft"].forEach((u) => {
46
46
  if (!sel.querySelector('option[value="' + u + '"]')) { const o = document.createElement("option"); o.value = u; o.textContent = u; sel.appendChild(o); }
47
47
  });
@@ -8,8 +8,8 @@ import { paintDonutGlyph, paintSparklineGlyph, paintPurityRing } from './glyph.m
8
8
  * Attributes: `title`, `ramp`, `scale`, `items`, `method`, `norm`, `selectable`, `empty`, `loading`, `error`, `retry`, `src`, `lazy`, `refresh`, `timeout`, `skeleton`, `glyphs`, `thresholds`, `breaks`, `no-data-color`, `size`, `table`, `classification`, `audit`, `continuous`, `ends`, `caption`.
9
9
  */
10
10
  class ContourLegend extends ContourBase {
11
- static get observed() { return ["title", "ramp", "scale", "items", "method", "norm", "selectable", "brownout", "brownout-level", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton", "glyphs", "thresholds", "breaks", "no-data-color", "no-data-label", "size", "table", "classification", "audit", "continuous", "ends", "caption", "graduated", "cache-key", "no-cache"]; }
12
- static get properties() { return { title: { attribute: "title" }, ramp: { attribute: "ramp" }, scale: { attribute: "scale" }, items: { attribute: "items" }, method: { attribute: "method" }, norm: { attribute: "norm" }, selectable: { attribute: "selectable", type: Boolean }, src: { attribute: "src" }, graduated: { attribute: "graduated", type: Boolean } }; }
11
+ static get observed() { return ["title", "ramp", "scale", "items", "method", "norm", "selectable", "brownout", "brownout-level", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton", "glyphs", "thresholds", "breaks", "no-data-color", "no-data-label", "size", "table", "classification", "audit", "continuous", "ends", "caption", "graduated", "cache-key", "no-cache", "domain", "reverse"]; }
12
+ static get properties() { return { title: { attribute: "title" }, ramp: { attribute: "ramp" }, scale: { attribute: "scale" }, items: { attribute: "items" }, method: { attribute: "method" }, norm: { attribute: "norm" }, selectable: { attribute: "selectable", type: Boolean }, src: { attribute: "src" }, graduated: { attribute: "graduated", type: Boolean }, domain: { attribute: "domain" }, reverse: { attribute: "reverse", type: Boolean } }; }
13
13
  render() {
14
14
  this.classList.add("c-legend");
15
15
  const graduated = this.hasAttribute("graduated");
@@ -231,6 +231,19 @@ class ContourLegend extends ContourBase {
231
231
  const c = this.querySelector(".c-legend__classification");
232
232
  if (c) c.remove();
233
233
  }
234
+ // R34-169: value domain + ramp direction. The domain names the mapped
235
+ // range; `reverse` flips the ramp so a high-is-low scale reads correctly.
236
+ const domain = this.getAttribute("domain");
237
+ if (domain) {
238
+ const d = this.ensure(".c-legend__domain", () => { const el = document.createElement("div"); el.className = "c-legend__domain"; return el; });
239
+ const parts = domain.split(",");
240
+ d.textContent = (labelText(this, "domain", "Domain") || "Domain") + ": " + parts.join(" – ");
241
+ } else {
242
+ const d = this.querySelector(".c-legend__domain");
243
+ if (d) d.remove();
244
+ }
245
+ if (this.hasAttribute("reverse")) this.classList.add("c-legend--reverse");
246
+ else this.classList.remove("c-legend--reverse");
234
247
  // data table (collapsible)
235
248
  const tableAttr = this.getAttribute("table");
236
249
  if (tableAttr) {
@@ -76,7 +76,18 @@ class ContourKpi extends ContourBase {
76
76
  if (variant) this.classList.add("c-kpi--" + variant);
77
77
  if (value) {
78
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"));
79
+ const text = formatValue(value, this.getAttribute("format"), this.getAttribute("locale"), this.getAttribute("unit"));
80
+ // R33-102: cross-fade the value when it changes (not on first render).
81
+ // The node may be recreated per render, so the last value is tracked on
82
+ // the host; each change restarts the one-shot animation.
83
+ const changed = this._kpiLastValue != null && this._kpiLastValue !== text;
84
+ this._kpiLastValue = text;
85
+ v.textContent = text;
86
+ if (changed) {
87
+ v.classList.remove("is-updating");
88
+ void v.offsetWidth;
89
+ v.classList.add("is-updating");
90
+ }
80
91
  } else {
81
92
  const v = this.querySelector(".c-kpi__value");
82
93
  if (v) v.remove();
@@ -1,5 +1,5 @@
1
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';
2
+ import { loadRemote, remoteData, renderStates, renderEmpty, wireStates, remoteInvalidate, watchViewport, parseArrayAttr, stateLabel, setAnalysisState } from './states.mjs';
3
3
  import { donutSlices, barRects, smoothPath, polylinePoints, contourPaths } from './svg.mjs';
4
4
  import { paintDonutGlyph, paintSparklineGlyph, paintPurityRing } from './glyph.mjs';
5
5
 
@@ -49,7 +49,10 @@ class ContourDonut extends ContourBase {
49
49
  const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
50
50
  svg.setAttribute("class", "c-donut__ring");
51
51
  svg.setAttribute("viewBox", "0 0 32 32");
52
- svg.setAttribute("role", "img");
52
+ // The ring holds focusable slice buttons, so it is a group, not an img
53
+ // (role=img would flatten the buttons out of the tree and nest
54
+ // interactive controls — axe nested-interactive).
55
+ svg.setAttribute("role", "group");
53
56
  const ringLabel = this.getAttribute("label") || "Donut chart";
54
57
  svg.setAttribute("aria-label", ringLabel);
55
58
  const slices = donutSlices(values, { cx: 16, cy: 16, r: 15, inner: 9, gap: 0.03 });
@@ -561,14 +564,37 @@ define("contour-pivot", ContourPivot);
561
564
  * Attributes: `loading`, `error`, `empty`, `retry`, `src`, `lazy`, `refresh`, `timeout`, `skeleton`.
562
565
  */
563
566
  class ContourWidgetState extends ContourBase {
564
- static get observed() { return ["loading", "error", "empty", "retry", "src", "lazy", "refresh", "timeout", "skeleton", "cache-key", "no-cache"]; }
565
- static get properties() { return { loading: { attribute: "loading" }, error: { attribute: "error" }, empty: { attribute: "empty" }, retry: { attribute: "retry" }, src: { attribute: "src" } }; }
567
+ static get observed() { return ["loading", "error", "empty", "retry", "src", "lazy", "refresh", "timeout", "skeleton", "cache-key", "no-cache", "analysis-state"]; }
568
+ static get properties() { return { loading: { attribute: "loading" }, error: { attribute: "error" }, empty: { attribute: "empty" }, retry: { attribute: "retry" }, src: { attribute: "src" }, "analysis-state": { attribute: "analysis-state" } }; }
566
569
  render() {
567
570
  this.classList.add("c-widget-state");
568
571
  wireStates(this);
569
572
  loadRemote(this, []);
570
573
  if (renderStates(this, "widget-state")) return;
571
- // if no state, render slotted content (already in DOM)
574
+ // R34-162: reflect the shared analysis state (loading/stale/partial/
575
+ // filtered/selected/locked/pinned) as data-analysis-state + a label so a
576
+ // dashboard shell and assistive tech read one vocabulary, not per-widget
577
+ // words. Rendered only in the ready branch — the load lifecycle owns the
578
+ // loading/error/empty chrome above.
579
+ const as = this.getAttribute("analysis-state");
580
+ if (as) {
581
+ const label = setAnalysisState(this, as);
582
+ let badge = this.querySelector(".c-widget-state__analysis");
583
+ if (!badge) {
584
+ badge = document.createElement("span");
585
+ badge.className = "c-widget-state__analysis visually-hidden";
586
+ badge.dataset.contourGenerated = "1";
587
+ this.appendChild(badge);
588
+ }
589
+ badge.textContent = label;
590
+ } else {
591
+ // No input analysis-state: clear any reflected badge unconditionally.
592
+ // (Reading `data-analysis-state` here made the class read an attribute
593
+ // it does not observe, so a post-upgrade change could not re-render.)
594
+ setAnalysisState(this, null);
595
+ const badge = this.querySelector(".c-widget-state__analysis");
596
+ if (badge) badge.remove();
597
+ }
572
598
  }
573
599
  enhance() {}
574
600
  }
@@ -908,9 +934,13 @@ class ContourThreshold extends ContourBase {
908
934
  const state = this.getAttribute("state") || (this._remoteData && this._remoteData.state);
909
935
  const label = this.getAttribute("label") || (this._remoteData && this._remoteData.label);
910
936
  if (!rValue && !target && !label) {
937
+ // A meter with no value is invalid ARIA (aria-valuenow required); the
938
+ // empty state is a status, not a meter.
939
+ this.setAttribute("role", "status");
911
940
  renderEmpty(this, "threshold");
912
941
  return;
913
942
  }
943
+ if (this.getAttribute("role") === "status") this.setAttribute("role", "meter");
914
944
  // R24-34: publish meter value range. fill=value, target=goal (both numbers) → announces real percentage, not bare string.
915
945
  // R31-57: clamp aria-valuenow into [0,100] (a value of 150 with max 100 is
916
946
  // invalid ARIA and the fill was invisible), and fold the target into the
@@ -1002,3 +1032,41 @@ class ContourMetricsFull extends ContourBase {
1002
1032
  enhance() { wireStates(this); }
1003
1033
  }
1004
1034
  define("contour-metrics", ContourMetricsFull);
1035
+
1036
+ /**
1037
+ * Selection Group (R33-43): a cross-component selection coordinator. Holds the
1038
+ * current selection (`selected`, a comma-separated id list) and broadcasts it to
1039
+ * slotted `[data-selection]` children (as `data-selected`) and to the page (as
1040
+ * `contour:selection`). A child's `contour:select` is adopted and rebroadcast,
1041
+ * so a map, table, chart and KPI stay linked without a global store.
1042
+ */
1043
+ class ContourSelectionGroup extends ContourBase {
1044
+ static get observed() { return ["selected", "mode"]; }
1045
+ static get properties() { return { selected: { attribute: "selected", controlled: true }, mode: { attribute: "mode" } }; }
1046
+ render() {
1047
+ this.classList.add("c-selection-group");
1048
+ if (!this.hasAttribute("role")) this.setAttribute("role", "group");
1049
+ const selected = (this.getAttribute("selected") || "").split(",").map((s) => s.trim()).filter(Boolean);
1050
+ for (const child of this.querySelectorAll("[data-selection]")) {
1051
+ child.setAttribute("data-selected", selected.includes(child.getAttribute("data-selection")) ? "true" : "false");
1052
+ }
1053
+ }
1054
+ enhance() {
1055
+ if (this._wiredSelGroup) return;
1056
+ this._wiredSelGroup = true;
1057
+ this.addEventListener("contour:select", (e) => {
1058
+ const detail = e.detail || {};
1059
+ const value = detail.value != null ? String(detail.value) : (detail.key != null ? String(detail.key) : "");
1060
+ // Reflect the adopted selection onto the children in place. Do NOT write
1061
+ // `selected` back to ourselves: it is an observed attribute, so the write
1062
+ // re-enters render (wc-contract). The page owns `selected`; we emit
1063
+ // `contour:selection` for it to round-trip.
1064
+ const selected = value ? [value] : [];
1065
+ for (const child of this.querySelectorAll("[data-selection]")) {
1066
+ child.setAttribute("data-selected", selected.includes(child.getAttribute("data-selection")) ? "true" : "false");
1067
+ }
1068
+ this.dispatchEvent(new CustomEvent("contour:selection", { bubbles: true, composed: true, detail: { value, mode: this.getAttribute("mode") || "single" } }));
1069
+ });
1070
+ }
1071
+ }
1072
+ define("contour-selection-group", ContourSelectionGroup);
@@ -1,5 +1,5 @@
1
1
  import { setHTML, ContourBase, define, onDispose, formatValue, contourId, navKey, isRtl, cssLength , safeColor, warnBadJson, labelText, flagOn } from './core.mjs';
2
- import { loadRemote, remoteData, renderStates, renderEmpty, wireStates, remoteInvalidate, watchViewport, parseArrayAttr, stateLabel } from './states.mjs';
2
+ import { loadRemote, remoteData, renderStates, renderEmpty, wireStates, remoteInvalidate, watchViewport, parseArrayAttr, stateLabel, virtualRange } from './states.mjs';
3
3
  import { donutSlices, barRects, smoothPath, polylinePoints, contourPaths } from './svg.mjs';
4
4
  import { paintDonutGlyph, paintSparklineGlyph, paintPurityRing } from './glyph.mjs';
5
5
 
@@ -105,6 +105,20 @@ class ContourTable extends ContourBase {
105
105
  if (!this.hasAttribute("role")) this.setAttribute("role", "region");
106
106
  // An authored label names the table; "Table" is the fallback.
107
107
  if (!this.hasAttribute("aria-label")) this.setAttribute("aria-label", this.getAttribute("title") || "Table");
108
+ // R34-123: a stable, announced selected-count. The region is visually
109
+ // hidden and polite, so the count is read without shifting the layout;
110
+ // clearing the selection (select-all off) resets it to empty.
111
+ let selStatus = this.querySelector(".c-table__selection-status");
112
+ if (!selStatus) {
113
+ selStatus = document.createElement("span");
114
+ selStatus.className = "c-table__selection-status visually-hidden";
115
+ selStatus.setAttribute("aria-live", "polite");
116
+ this.appendChild(selStatus);
117
+ }
118
+ const selCount = this._selectionControlled
119
+ ? (this._selectedKeys ? this._selectedKeys.size : 0)
120
+ : (this._selectedRows ? this._selectedRows.size : 0);
121
+ selStatus.textContent = selCount ? `${selCount} selected` : "";
108
122
  wireStates(this);
109
123
  loadRemote(this, "rows");
110
124
  if (renderStates(this, "table")) return;
@@ -113,7 +127,7 @@ class ContourTable extends ContourBase {
113
127
  const columns = this.getAttribute("columns");
114
128
  const rows = remoteData(this, "rows");
115
129
  // Slot composition: an authored table wins over the JSON attributes.
116
- const authored = Array.from(this.children).filter((n) => !n.classList || !n.classList.contains("c-table-wrap"));
130
+ const authored = Array.from(this.children).filter((n) => !n.classList || (!n.classList.contains("c-table-wrap") && !n.classList.contains("c-table__selection-status")));
117
131
  if (columns && rows && !authored.length) {
118
132
  try {
119
133
  const cols = JSON.parse(columns);
@@ -324,9 +338,10 @@ if (isFilter) {
324
338
  let windowStart = 0;
325
339
  let visibleData = pageData;
326
340
  if (useVirtual) {
327
- const maxStart = Math.max(0, pageData.length - windowSize);
328
- // Compute from wrapScrollTop, not wrap.scrollTop: clearing the body above already clamped the live scrollTop to 0, so reading it here would always yield windowStart 0 and the table would snap back to the first row on every scroll frame (DW-5).
329
- windowStart = Math.min(maxStart, Math.max(0, Math.floor(wrapScrollTop / rowHeight) - overscan));
341
+ // R34-58: the start clamp is the shared virtualRange geometry (the
342
+ // grid uses the same helper), so the table and grid agree on where a
343
+ // scroll offset lands; the table keeps its count-based window size.
344
+ windowStart = virtualRange(wrapScrollTop, rowHeight, (windowSize - overscan) * rowHeight, pageData.length, overscan).start;
330
345
  visibleData = pageData.slice(windowStart, windowStart + windowSize + overscan * 2);
331
346
  table.setAttribute("aria-rowcount", String(pageData.length + 1));
332
347
  // Record which window is on screen so the scroll handler can tell a scroll that moves the window from one that does not.
@@ -373,6 +388,7 @@ if (isSelect) {
373
388
  cb.type = "checkbox";
374
389
  cb.className = "c-table__row-select";
375
390
  cb.dataset.rowIndex = String(windowStart + ri);
391
+ cb.setAttribute("aria-label", labelText(this, "select-row", "Select row") + " " + (rowKey ?? (windowStart + ri + 1)));
376
392
  // The base class preserves form-control state across a re-render; UNKEYED checkboxes restore by position, which would paint the pre-sort checked positions onto the new row order (and a virtual window's onto different rows). The preserve key makes that restoration identity-based: a row's checked state follows its datum, and a row newly scrolled into the window keeps the state render gave it.
377
393
  cb.dataset.contourPreserveKey = rowKey;
378
394
  // Controlled mode checks by KEY (survives sort/filter/window moves); legacy mode keeps the positional contract. The checkbox's checked state is the ARIA reflection — a plain <table> row must not carry aria-selected (grid-only state).
@@ -464,6 +480,13 @@ if (isSelect) {
464
480
  }
465
481
  }
466
482
  // R25-04: re-assert the selection AFTER the base's form-control restore. That restore preserves user-typed state across a re-render and runs after render(); for a CONTROLLED selection the store-driven state is the truth, so the rendered checks are re-applied here — enhance() runs last on both the connect and the re-render path. Idempotent and window-sized; the select-all box keeps the base's own restoration.
483
+ // R34-123: refresh the announced selected-count without a full re-render.
484
+ _updateSelectionStatus() {
485
+ const st = this.querySelector(".c-table__selection-status");
486
+ if (!st) return;
487
+ const n = this._selectionControlled ? (this._selectedKeys ? this._selectedKeys.size : 0) : (this._selectedRows ? this._selectedRows.size : 0);
488
+ st.textContent = n ? `${n} selected` : "";
489
+ }
467
490
  _applySelectionToDom() {
468
491
  this.querySelectorAll(".c-table__row-select").forEach((cb) => {
469
492
  const idx = Number(cb.dataset.rowIndex);
@@ -496,14 +519,18 @@ if (isSelect) {
496
519
  const handleSort = (th) => {
497
520
  const idx = Number(th.dataset.sortIndex);
498
521
  if (!Number.isFinite(idx)) return;
522
+ // R34-122: three-state cycle — ascending → descending → none (reset), so
523
+ // a reader can clear the sort from the header without a separate control.
499
524
  if (this._sortCol === idx) {
500
- this._sortDir = (this._sortDir === 1) ? -1 : 1;
525
+ if (this._sortDir === 1) this._sortDir = -1;
526
+ else { this._sortCol = null; this._sortDir = 1; }
501
527
  } else {
502
528
  this._sortCol = idx;
503
529
  this._sortDir = 1;
504
530
  }
505
- this.dispatchEvent(new CustomEvent("contour:sort", { bubbles: true, composed: true, detail: { column: idx, direction: this._sortDir === 1 ? "ascending" : "descending" } }));
506
- this.dispatchEvent(new CustomEvent("contour:filter-change", { bubbles: true, composed: true, detail: { source: "table", filter: { sort: idx, sortDir: this._sortDir === 1 ? "ascending" : "descending" } } }));
531
+ const dir = this._sortCol === idx ? (this._sortDir === 1 ? "ascending" : "descending") : "none";
532
+ this.dispatchEvent(new CustomEvent("contour:sort", { bubbles: true, composed: true, detail: { column: idx, direction: dir } }));
533
+ this.dispatchEvent(new CustomEvent("contour:filter-change", { bubbles: true, composed: true, detail: { source: "table", filter: { sort: this._sortCol === idx ? idx : null, sortDir: dir } } }));
507
534
  this.requestRender();
508
535
  };
509
536
  this.addEventListener("click", (e) => {
@@ -596,6 +623,7 @@ if (isSelect) {
596
623
  if (cb.checked) this._selectedRows.add(idx); else this._selectedRows.delete(idx);
597
624
  }
598
625
  this._applySelectionToDom();
626
+ this._updateSelectionStatus();
599
627
  const rows = Array.from(this._selectedRows);
600
628
  const keys = this._selectionKeys();
601
629
  this.dispatchEvent(new CustomEvent("contour:select", { bubbles: true, composed: true, detail: { rows, key, index: idx } }));
@@ -618,6 +646,7 @@ if (isSelect) {
618
646
  this._selectedRows = new Set(all.checked ? cbs.map((c) => Number(c.dataset.rowIndex)) : []);
619
647
  }
620
648
  all.indeterminate = false;
649
+ this._updateSelectionStatus();
621
650
  const rows = Array.from(this._selectedRows);
622
651
  const keys = this._selectionKeys();
623
652
  this.dispatchEvent(new CustomEvent("contour:select", { bubbles: true, composed: true, detail: { rows } }));