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
@@ -1,7 +1,7 @@
1
- import { ContourBase, define, onDispose , warnBadJson } from './core.mjs';
1
+ import { setHTML, ContourBase, define, onDispose , flagOn, warnBadJson, safeHref, labelText } from './core.mjs';
2
2
  import { wireSegmented, modalContain } from './behaviours.mjs';
3
3
  class ContourPressableFull extends ContourBase {
4
- static get observed() { return ["disabled"]; }
4
+ static get observed() { return ["disabled", "label"]; }
5
5
  static get properties() { return { disabled: { attribute: "disabled", type: Boolean } }; }
6
6
  render() {
7
7
  this.classList.add("c-pressable");
@@ -18,7 +18,13 @@ class ContourPressableFull extends ContourBase {
18
18
  enhance() {
19
19
  if (this._wiredPressable) return;
20
20
  this._wiredPressable = true;
21
+ // disabled pressable must not activate (capture phase fires first).
22
+ const isDisabled = () => this.hasAttribute("disabled") || this.getAttribute("aria-disabled") === "true";
23
+ this.addEventListener("click", (e) => {
24
+ if (isDisabled()) { e.preventDefault(); e.stopImmediatePropagation(); }
25
+ }, true);
21
26
  this.addEventListener("keydown", (e) => {
27
+ if (isDisabled()) { e.preventDefault(); e.stopImmediatePropagation(); return; }
22
28
  if (e.key === "Enter" || e.key === " ") { e.preventDefault(); this.click(); this.dispatchEvent(new CustomEvent("contour:activate", { bubbles: true, composed: true })); }
23
29
  });
24
30
  }
@@ -29,29 +35,25 @@ class ContourResizeHandleFull extends ContourBase {
29
35
  this.classList.add("c-resize-handle");
30
36
  if (!this.hasAttribute("role")) this.setAttribute("role", "separator");
31
37
  if (!this.hasAttribute("aria-valuenow")) this.setAttribute("aria-valuenow", "0");
32
- if (!this.hasAttribute("aria-label")) this.setAttribute("aria-label", "Resize handle");
38
+ if (!this.hasAttribute("aria-label")) this.setAttribute("aria-label", labelText(this, "resize-handle", "Resize handle"));
33
39
  if (!this.hasAttribute("tabindex")) this.setAttribute("tabindex", "0");
34
40
  if (!this.hasAttribute("aria-orientation")) this.setAttribute("aria-orientation", "horizontal");
35
41
  }
36
42
  enhance() {
37
43
  if (this._wiredResizeHandle) return;
38
44
  this._wiredResizeHandle = true;
39
- // Keyboard alternative for pointer resize: arrow keys nudge the split
40
- // value by 5%, Home/End jump to min/max. Dispatches contour:resize so a
41
- // host (c-resizable, c-split-view) can apply the change.
45
+ // Keyboard resize: arrows nudge 5%, Home/End to min/max; dispatches contour:resize.
42
46
  this.addEventListener("keydown", (e) => {
47
+ // Home/End send finite delta (±Infinity serialises to null).
48
+ const cur = Number(this.getAttribute("aria-valuenow")) || 0;
43
49
  let delta = 0;
44
50
  if (e.key === "ArrowLeft" || e.key === "ArrowDown") delta = -5;
45
51
  else if (e.key === "ArrowRight" || e.key === "ArrowUp") delta = 5;
46
- else if (e.key === "Home") delta = -Infinity;
47
- else if (e.key === "End") delta = Infinity;
52
+ else if (e.key === "Home") delta = -cur; // jump to min (0)
53
+ else if (e.key === "End") delta = 100 - cur; // jump to max (100)
48
54
  else return;
49
55
  e.preventDefault();
50
- const cur = Number(this.getAttribute("aria-valuenow")) || 0;
51
- let next;
52
- if (delta === -Infinity) next = 0;
53
- else if (delta === Infinity) next = 100;
54
- else next = Math.min(100, Math.max(0, cur + delta));
56
+ const next = Math.min(100, Math.max(0, cur + delta));
55
57
  this.setAttribute("aria-valuenow", String(next));
56
58
  this.dispatchEvent(new CustomEvent("contour:resize", { bubbles: true, composed: true, detail: { value: next, delta } }));
57
59
  });
@@ -82,7 +84,7 @@ class ContourShortcutListFull extends ContourBase {
82
84
  this.setAttribute("role", "list");
83
85
  const title = this.getAttribute("title");
84
86
  if (title) {
85
- const t = this.ensure(".c-shortcut-list__title", () => { const el = document.createElement("div"); el.className = "c-shortcut-list__title"; el.style.padding = "var(--space-sm)"; el.style.fontWeight = "var(--weight-semibold)"; return el; });
87
+ const t = this.ensure(".c-shortcut-list__title", () => { const el = document.createElement("div"); el.className = "c-shortcut-list__title"; return el; });
86
88
  t.textContent = title;
87
89
  }
88
90
  }
@@ -93,6 +95,8 @@ class ContourShortcutRowFull extends ContourBase {
93
95
  static get properties() { return { desc: { attribute: "desc" }, key: { attribute: "key" } }; }
94
96
  render() {
95
97
  this.classList.add("c-shortcut-row");
98
+ // rows get role=listitem so list > listitem is valid.
99
+ if (!this.hasAttribute("role")) this.setAttribute("role", "listitem");
96
100
  const key = this.getAttribute("key");
97
101
  const desc = this.getAttribute("desc");
98
102
  if (key) {
@@ -131,8 +135,8 @@ class ContourShortcutPanelFull extends ContourBase {
131
135
  }
132
136
  define("contour-shortcut-panel", ContourShortcutPanelFull);
133
137
  class ContourShortcutOverlayFull extends ContourBase {
134
- static get observed() { return ["title", "open"]; }
135
- static get properties() { return { title: { attribute: "title" }, open: { attribute: "open", type: Boolean } }; }
138
+ static get observed() { return ["title", "open", "keybind"]; }
139
+ static get properties() { return { title: { attribute: "title" }, open: { attribute: "open", type: Boolean }, keybind: { attribute: "keybind" } }; }
136
140
  render() {
137
141
  this.classList.add("c-shortcut-overlay");
138
142
  if (!this.hasAttribute("role")) this.setAttribute("role", "dialog");
@@ -146,15 +150,35 @@ class ContourShortcutPanelFull extends ContourBase {
146
150
  if (this.hasAttribute("open")) this.removeAttribute("hidden");
147
151
  else if (!this.hasAttribute("hidden")) this.setAttribute("hidden", "");
148
152
  }
149
- show() { this.setAttribute("open", ""); this.removeAttribute("hidden"); modalContain(this, true); this.dispatchEvent(new CustomEvent("contour:open", { bubbles: true, composed: true })); }
150
- hide() { this.removeAttribute("open"); this.setAttribute("hidden", ""); modalContain(this, false); this.dispatchEvent(new CustomEvent("contour:close", { bubbles: true, composed: true })); }
153
+ show() {
154
+ // R31-73: re-entry (a keydown plus a click) must not stack the modal lock.
155
+ if (this.hasAttribute("open")) return;
156
+ // capture opener, focus first focusable element.
157
+ this._opener = document.activeElement;
158
+ this.setAttribute("open", "");
159
+ this.removeAttribute("hidden");
160
+ modalContain(this, true);
161
+ this.dispatchEvent(new CustomEvent("contour:open", { bubbles: true, composed: true }));
162
+ const first = this.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");
163
+ if (first) first.focus();
164
+ }
165
+ hide() {
166
+ if (!this.hasAttribute("open")) return;
167
+ this.removeAttribute("open");
168
+ this.setAttribute("hidden", "");
169
+ modalContain(this, false);
170
+ this.dispatchEvent(new CustomEvent("contour:close", { bubbles: true, composed: true }));
171
+ // restore focus to the element that opened the overlay.
172
+ if (this._opener && typeof this._opener.focus === "function") this._opener.focus();
173
+ this._opener = null;
174
+ }
151
175
  toggle() { if (this.hasAttribute("open")) this.hide(); else this.show(); }
152
176
  enhance() {
153
177
  if (this._wiredShortcutOverlay) return;
154
178
  this._wiredShortcutOverlay = true;
155
- // Global registry: "?" (Shift+/) toggles the overlay; Escape closes.
179
+ // `keybind` opts into global "?" toggle: absent=off, bare=on, "false"=off. Escape closes while open regardless.
156
180
  const keyHandler = (e) => {
157
- if (e.key === "?" && !e.metaKey && !e.ctrlKey && !e.altKey) {
181
+ if (e.key === "?" && flagOn(this, "keybind") && !e.metaKey && !e.ctrlKey && !e.altKey) {
158
182
  const tag = (e.target && e.target.tagName) || "";
159
183
  if (tag === "INPUT" || tag === "TEXTAREA" || (e.target && e.target.isContentEditable)) return;
160
184
  e.preventDefault();
@@ -191,23 +215,28 @@ class ContourRowActionFull extends ContourBase {
191
215
  enhance() {
192
216
  if (this._wiredRowAction) return;
193
217
  this._wiredRowAction = true;
218
+ // disabled activation guard (same pattern as c-btn).
219
+ const isDisabled = () => this.hasAttribute("disabled") || this.getAttribute("aria-disabled") === "true";
220
+ this.addEventListener("click", (e) => {
221
+ if (isDisabled()) { e.preventDefault(); e.stopImmediatePropagation(); }
222
+ }, true);
194
223
  this.addEventListener("keydown", (e) => {
224
+ if (isDisabled()) { e.preventDefault(); e.stopImmediatePropagation(); return; }
195
225
  if (e.key === "Enter" || e.key === " ") { e.preventDefault(); this.click(); this.dispatchEvent(new CustomEvent("contour:activate", { bubbles: true, composed: true })); }
196
226
  });
197
227
  }
198
228
  }
199
229
  define("contour-row-action", ContourRowActionFull);
200
230
  class ContourSegmented extends ContourBase {
201
- static get observed() { return ["options", "selected", "label", "value"]; }
202
- static get properties() { return { options: { attribute: "options" }, selected: { attribute: "selected" }, label: { attribute: "label" }, value: { attribute: "value" } }; }
231
+ static get observed() { return ["options", "items", "selected", "label", "value"]; }
232
+ static get properties() { return { options: { attribute: "options" }, items: { attribute: "items" }, selected: { attribute: "selected" }, label: { attribute: "label" }, value: { attribute: "value" } }; }
203
233
  render() {
204
234
  this.classList.add("c-segmented");
205
- const options = this.getAttribute("options");
235
+ const options = this.getAttribute("options") || this.getAttribute("items");
206
236
  if (options) {
207
237
  let parsed = null;
208
238
  try { parsed = JSON.parse(options); } catch (e) { parsed = null; }
209
239
  if (Array.isArray(parsed)) {
210
- // Drop previously generated buttons.
211
240
  Array.from(this.querySelectorAll("button.c-segmented__option")).forEach((n) => n.remove());
212
241
  const selected = this.getAttribute("selected") || this.getAttribute("value");
213
242
  parsed.forEach((opt, i) => {
@@ -239,22 +268,14 @@ class ContourDraggable extends ContourBase {
239
268
  if (!this.hasAttribute("draggable")) this.setAttribute("draggable", "true");
240
269
  if (!this.hasAttribute("aria-label")) this.setAttribute("aria-label", this.getAttribute("label") || "Draggable item");
241
270
  }
242
- // The value a drop partner receives: the authored `value` attribute, else
243
- // the `label`, else the element's own text. One shape, so a consumer's
244
- // contour:drop handler sees the same detail a contour:dragstart carried.
245
- // `label` and `value` are shared-list attributes (they are not overridden
246
- // here), so the inherited full shared list stays the observed contract.
271
+ // _dragValue: value || label || textContent. Same detail for dragstart and drop.
247
272
  _dragValue() {
248
273
  return this.getAttribute("value") || this.getAttribute("label") || (this.textContent || "").trim() || "draggable";
249
274
  }
250
275
  enhance() {
251
276
  if (this._wiredDraggable) return;
252
277
  this._wiredDraggable = true;
253
- // Native drag-and-drop (BY-26). The platform owns the drag gesture; the
254
- // component owns the payload and the visual state. dragstart writes
255
- // text/plain (the portable payload nearly every drop partner can read),
256
- // marks the item with the shipped .c-draggable--dragging state, and
257
- // announces contour:dragstart so a dashboard can react before the drop.
278
+ // Native DnD (BY-26): dragstart writes text/plain payload, adds dragging state, dispatches contour:dragstart.
258
279
  this.addEventListener("dragstart", (e) => {
259
280
  if (!e.dataTransfer) return;
260
281
  const value = this._dragValue();
@@ -267,11 +288,7 @@ class ContourDraggable extends ContourBase {
267
288
  this.classList.remove("c-draggable--dragging");
268
289
  this.dispatchEvent(new CustomEvent("contour:dragend", { bubbles: true, composed: true, detail: { value: this._dragValue() } }));
269
290
  });
270
- // Keyboard alternative: HTML5 DnD has no keyboard story, so the focused
271
- // draggable offers ArrowUp/ArrowDown as a move action the consumer
272
- // handles exactly like a drop (the accessible reorder pattern). It rides
273
- // the same event vocabulary — contour:move {direction} — and never fakes
274
- // a drag it cannot perform.
291
+ // Keyboard move: ArrowUp/Down dispatches contour:move (DnD has no keyboard story).
275
292
  this.addEventListener("keydown", (e) => {
276
293
  if (e.key === "Enter" || e.key === " ") { e.preventDefault(); this.dispatchEvent(new CustomEvent("contour:activate", { bubbles: true, composed: true })); return; }
277
294
  if (e.key === "ArrowUp" || e.key === "ArrowDown") {
@@ -286,8 +303,7 @@ class ContourDragHandle extends ContourBase {
286
303
  render() {
287
304
  this.classList.add("c-drag-handle");
288
305
  if (!this.hasAttribute("role")) this.setAttribute("role", "separator");
289
- // A focusable separator is a range widget: a value without a range is an
290
- // incomplete one, and some AT expose it as an unlabelled slider.
306
+ // Focusable separator = range widget; needs value range for AT.
291
307
  const min = this.getAttribute("min") || "0";
292
308
  const max = this.getAttribute("max") || "100";
293
309
  if (!this.hasAttribute("aria-valuenow")) this.setAttribute("aria-valuenow", min);
@@ -299,6 +315,15 @@ class ContourDragHandle extends ContourBase {
299
315
  // Name the pane the handle resizes, when the author says which.
300
316
  const controls = this.getAttribute("controls");
301
317
  if (controls && !this.hasAttribute("aria-controls")) this.setAttribute("aria-controls", controls);
318
+ // grip glyph is the signifier; base rule gives size/cursor/ring.
319
+ const grip = this.ensure(".c-drag-handle__grip", () => {
320
+ const s = document.createElement("span");
321
+ s.className = "c-drag-handle__grip";
322
+ s.setAttribute("aria-hidden", "true");
323
+ setHTML(s, '<svg viewBox="0 0 24 24"><use href="#i-drag" /></svg>');
324
+ return s;
325
+ });
326
+ if (grip.parentNode !== this) this.appendChild(grip);
302
327
  }
303
328
  enhance() {
304
329
  if (this._wiredDragHandle) return;
@@ -310,9 +335,7 @@ class ContourDragHandle extends ContourBase {
310
335
  let delta = 0;
311
336
  if (e.key === "ArrowLeft" || e.key === "ArrowDown") delta = -1;
312
337
  else if (e.key === "ArrowRight" || e.key === "ArrowUp") delta = 1;
313
- // Home/End are absolute moves. A delta of ±Infinity serialises to null
314
- // the moment it crosses an event boundary, so send the finite distance
315
- // from the current value to the end it names.
338
+ // Home/End: finite delta to min/max (±Infinity serialises to null).
316
339
  else if (e.key === "Home") delta = min - now;
317
340
  else if (e.key === "End") delta = max - now;
318
341
  else return;
@@ -327,13 +350,10 @@ class ContourDropIndicator extends ContourBase {
327
350
  static get properties() { return { label: { attribute: "label" }, open: { attribute: "open", type: Boolean } }; }
328
351
  render() {
329
352
  this.classList.add("c-drop-indicator");
330
- // Visibility is a state, not a constant: the indicator is shown while a
331
- // drag is over a drop target, so it is only visible when `open` is set.
332
- // The old code stamped --visible on every render, so it was always on.
353
+ // Visible only while `open` is set (old code stamped --visible always on).
333
354
  this.classList.toggle("c-drop-indicator--visible", this.hasAttribute("open"));
334
355
  if (!this.hasAttribute("role")) this.setAttribute("role", "presentation");
335
- // A presentation role is purely decorative: strip any accessible name
336
- // so axe does not flag aria-label/aria-labelledby as prohibited.
356
+ // presentation role strips accessible name (axe prohibits on role=presentation).
337
357
  if (this.getAttribute("role") === "presentation") {
338
358
  this.removeAttribute("aria-label");
339
359
  this.removeAttribute("aria-labelledby");
@@ -358,16 +378,15 @@ class ContourDropZone extends ContourBase {
358
378
  const label = this.getAttribute("label");
359
379
  if (label) {
360
380
  const t = this.ensure(".c-drop-zone__label", () => { const el = document.createElement("p"); el.className = "c-drop-zone__label"; return el; });
361
- t.textContent = label;
381
+ // R31-150: an upload glyph makes the drop zone scannable.
382
+ setHTML(t, '<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-upload" /></svg>');
383
+ t.appendChild(document.createTextNode(" " + label));
362
384
  }
363
385
  }
364
386
  enhance() {
365
387
  if (this._wiredDropZone) return;
366
388
  this._wiredDropZone = true;
367
- // Native drop target (BY-26), delegated on the host (rule 12). dragover
368
- // is where the platform asks "may it land here?": a text/plain payload
369
- // is allowed (preventDefault + the shipped --active state), anything
370
- // else is refused (--reject, no preventDefault so the drop never lands).
389
+ // Native drop target (BY-26, host-delegated): dragover allows text/plain (--active), refuses others (--reject).
371
390
  const accepts = (e) => e.dataTransfer && Array.from(e.dataTransfer.types).includes("text/plain");
372
391
  const clear = () => { this.classList.remove("c-drop-zone--active", "c-drop-zone--reject"); };
373
392
  this.addEventListener("dragenter", (e) => {
@@ -388,9 +407,7 @@ class ContourDropZone extends ContourBase {
388
407
  const value = e.dataTransfer.getData("text/plain") || "";
389
408
  this.dispatchEvent(new CustomEvent("contour:drop", { bubbles: true, composed: true, detail: { value, label: this.getAttribute("label") } }));
390
409
  });
391
- // The keyboard path lives on the draggable (contour:move, BY-26):
392
- // HTML5 DnD has no keyboard story, and a target that only receives a
393
- // pointer gesture does not get a focus role it cannot act on alone.
410
+ // Keyboard path on the draggable (contour:move); target only needs pointer role.
394
411
  }
395
412
  }
396
413
  define("contour-drop-zone", ContourDropZone);
@@ -403,8 +420,7 @@ class ContourResizable extends ContourBase {
403
420
  const vertical = this.getAttribute("direction") === "vertical";
404
421
  this.classList.add(vertical ? "c-resizable--vertical" : "c-resizable--horizontal");
405
422
  if (!this.querySelector(".c-resizable__pane")) {
406
- // Structural panes only: the author fills them. The old code wrote
407
- // "Pane A"/"Pane B" into a shipped component.
423
+ // Structural panes only; author fills them (no invented Pane A/B).
408
424
  const p1 = document.createElement("div");
409
425
  p1.className = "c-resizable__pane";
410
426
  const handle = document.createElement("div");
@@ -419,6 +435,18 @@ class ContourResizable extends ContourBase {
419
435
  this.appendChild(p2);
420
436
  }
421
437
  const v = this._splitValue || this.getAttribute("value");
438
+ const handle = this.querySelector(".c-resize-handle");
439
+ if (handle) {
440
+ // R31-66: the first paint must already be a named separator, not an
441
+ // unnamed 0-valued handle that only becomes valid after a drag.
442
+ handle.setAttribute("role", "separator");
443
+ handle.setAttribute("tabindex", "0");
444
+ handle.setAttribute("aria-valuenow", String(Math.round(parseFloat(v) || 50)));
445
+ handle.setAttribute("aria-valuemin", "10");
446
+ handle.setAttribute("aria-valuemax", "90");
447
+ handle.setAttribute("aria-orientation", vertical ? "horizontal" : "vertical");
448
+ handle.setAttribute("aria-label", labelText(this, "resize-panels", "Resize panels"));
449
+ }
422
450
  if (v) {
423
451
  const p1 = this.querySelector(".c-resizable__pane");
424
452
  if (p1) p1.style.flex = `0 0 ${v}%`;
@@ -427,19 +455,31 @@ class ContourResizable extends ContourBase {
427
455
  enhance() {
428
456
  if (this._wiredResizable) return;
429
457
  this._wiredResizable = true;
430
- // Pointer resize (BY-27): the handle is generated on every render, so
431
- // the listeners are delegated on the host and re-query per event (rule
432
- // 12). Dragging sets the first pane's flex-basis; the second pane's
433
- // `flex: 1 1 0` takes the rest, so the split is the drag's own number.
458
+ // Pointer resize (BY-27): host-delegated listeners; first pane flex-basis = drag value. One split writer for pointer+keyboard.
459
+ const applySplit = (pct) => {
460
+ const p1 = this.querySelector(".c-resizable__pane");
461
+ if (p1) p1.style.flex = `0 0 ${pct}%`;
462
+ this._splitValue = String(pct);
463
+ // sync ARIA on handle so readers announce split position.
464
+ const handle = this.querySelector(".c-resize-handle");
465
+ if (handle) {
466
+ const vertical = this.classList.contains("c-resizable--vertical");
467
+ handle.setAttribute("role", "separator");
468
+ handle.setAttribute("aria-valuenow", String(pct));
469
+ handle.setAttribute("aria-valuemin", "10");
470
+ handle.setAttribute("aria-valuemax", "90");
471
+ handle.setAttribute("aria-orientation", vertical ? "horizontal" : "vertical");
472
+ handle.setAttribute("aria-label", labelText(this, "resize-panels", "Resize panels"));
473
+ handle.setAttribute("tabindex", "0");
474
+ }
475
+ };
434
476
  const setSplit = (clientX, clientY) => {
435
477
  const rect = this.getBoundingClientRect();
436
478
  const vertical = this.classList.contains("c-resizable--vertical");
437
479
  const span = vertical ? rect.height : rect.width;
438
480
  const pos = vertical ? clientY - rect.top : clientX - rect.left;
439
481
  const frac = span > 0 ? Math.min(0.9, Math.max(0.1, pos / span)) : 0.5;
440
- const p1 = this.querySelector(".c-resizable__pane");
441
- if (p1) p1.style.flex = `0 0 ${Math.round(frac * 100)}%`;
442
- this._splitValue = String(Math.round(frac * 100));
482
+ applySplit(Math.round(frac * 100));
443
483
  };
444
484
  this.addEventListener("pointerdown", (e) => {
445
485
  const handle = this.querySelector(".c-resize-handle");
@@ -474,14 +514,18 @@ class ContourResizable extends ContourBase {
474
514
  if (!handle || document.activeElement !== handle) return;
475
515
  const vertical = this.classList.contains("c-resizable--vertical");
476
516
  const cur = parseFloat(this.getAttribute("value")) || 50;
477
- if (e.key === "ArrowLeft" || e.key === "ArrowDown") { e.preventDefault(); setSplit && setSplit; const p1 = this.querySelector(".c-resizable__pane"); if (p1) { const nv = Math.max(10, cur - 5); p1.style.flex = `0 0 ${nv}%`; this.setAttribute("value", String(nv)); } }
478
- else if (e.key === "ArrowRight" || e.key === "ArrowUp") { e.preventDefault(); const p1 = this.querySelector(".c-resizable__pane"); if (p1) { const nv = Math.min(90, cur + 5); p1.style.flex = `0 0 ${nv}%`; this.setAttribute("value", String(nv)); } }
517
+ if (e.key === "ArrowLeft" || e.key === "ArrowDown") { e.preventDefault(); applySplit(Math.max(10, cur - 5)); this._splitValue = null; this.setAttribute("value", String(Math.max(10, cur - 5))); }
518
+ else if (e.key === "ArrowRight" || e.key === "ArrowUp") { e.preventDefault(); applySplit(Math.min(90, cur + 5)); this._splitValue = null; this.setAttribute("value", String(Math.min(90, cur + 5))); }
479
519
  const r = this.getBoundingClientRect();
480
520
  this.dispatchEvent(new CustomEvent("contour:resize", { bubbles: true, composed: true, detail: { width: Math.round(r.width), height: Math.round(r.height) } }));
481
521
  });
482
522
  }
483
523
  }
484
524
  define("contour-resizable", ContourResizable);
525
+ // R31-96: the ONE split primitive. `contour-split-view` is a generic two-pane
526
+ // resizer; `contour-split-map` (map before/after) and `contour-comparison`
527
+ // (chart A/B) are specialized compositions of it, not separate primitives. A
528
+ // new split need must extend this, not add a fourth.
485
529
  class ContourSplitView extends ContourBase {
486
530
  static get observed() { return ["direction", "value", "left-label", "right-label"]; }
487
531
  static get properties() { return { direction: { attribute: "direction" }, value: { attribute: "value" }, "left-label": { attribute: "left-label" }, "right-label": { attribute: "right-label" } }; }
@@ -500,43 +544,70 @@ class ContourSplitView extends ContourBase {
500
544
  if (!this.querySelector(".c-split-view__pane")) {
501
545
  const p1 = document.createElement("div");
502
546
  p1.className = "c-split-view__pane c-split-view__pane--left";
547
+ p1.setAttribute("role", "region");
503
548
  if (this.getAttribute("left-label")) p1.setAttribute("aria-label", this.getAttribute("left-label"));
504
549
  const divider = document.createElement("div");
505
550
  divider.className = "c-split-view__divider";
506
551
  divider.setAttribute("tabindex", "0");
507
552
  divider.setAttribute("role", "separator");
508
553
  divider.setAttribute("aria-valuenow", this.getAttribute("value") || "50");
509
- divider.setAttribute("aria-label", "Split divider");
554
+ divider.setAttribute("aria-valuemin", "10");
555
+ divider.setAttribute("aria-valuemax", "90");
556
+ divider.setAttribute("aria-orientation", vertical ? "horizontal" : "vertical");
557
+ divider.setAttribute("aria-label", labelText(this, "split-divider", "Split divider"));
510
558
  const p2 = document.createElement("div");
511
559
  p2.className = "c-split-view__pane c-split-view__pane--right";
560
+ p2.setAttribute("role", "region");
512
561
  if (this.getAttribute("right-label")) p2.setAttribute("aria-label", this.getAttribute("right-label"));
513
562
  this.appendChild(p1);
514
563
  this.appendChild(divider);
515
564
  this.appendChild(p2);
516
565
  }
517
- // The divider is the control surface: an author who supplies their own
518
- // panes still needs it, so create it independently of the pane guard.
566
+ // Divider created independently of pane guard; author panes still need it.
519
567
  if (!this.querySelector(".c-split-view__divider")) {
520
568
  const divider = document.createElement("div");
521
569
  divider.className = "c-split-view__divider";
522
570
  divider.setAttribute("tabindex", "0");
523
571
  divider.setAttribute("role", "separator");
524
572
  divider.setAttribute("aria-valuenow", this.getAttribute("value") || "50");
525
- divider.setAttribute("aria-label", "Split divider");
573
+ divider.setAttribute("aria-valuemin", "10");
574
+ divider.setAttribute("aria-valuemax", "90");
575
+ divider.setAttribute("aria-orientation", vertical ? "horizontal" : "vertical");
576
+ divider.setAttribute("aria-label", labelText(this, "split-divider", "Split divider"));
526
577
  this.appendChild(divider);
527
578
  }
528
579
  const v = this.getAttribute("value") || "50";
529
580
  const p1 = this.querySelector(".c-split-view__pane--left");
530
581
  if (p1) p1.style.flex = `0 0 ${v}%`;
531
582
  const divider = this.querySelector(".c-split-view__divider");
532
- if (divider) divider.setAttribute("aria-valuenow", v);
583
+ if (divider) {
584
+ divider.setAttribute("aria-valuenow", v);
585
+ divider.setAttribute("aria-valuemin", "10");
586
+ divider.setAttribute("aria-valuemax", "90");
587
+ divider.setAttribute("aria-orientation", vertical ? "horizontal" : "vertical");
588
+ }
533
589
  }
534
590
  enhance() {
535
591
  if (this._wiredSplitView) return;
536
592
  this._wiredSplitView = true;
593
+ // R31-114: the stylesheet stacks a horizontal split below 40rem. A media query
594
+ // cannot restyle its own container, so the class still says what the author
595
+ // asked for while the rendered axis says what the reader got — the drag maths
596
+ // and the separator's announced orientation follow the second.
597
+ const isColumn = () => getComputedStyle(this).flexDirection === "column";
598
+ const syncAxis = () => {
599
+ const d = this.querySelector(".c-split-view__divider");
600
+ if (d) d.setAttribute("aria-orientation", isColumn() ? "horizontal" : "vertical");
601
+ };
602
+ syncAxis();
603
+ if (typeof ResizeObserver === "function") {
604
+ const ro = new ResizeObserver(syncAxis);
605
+ ro.observe(this);
606
+ onDispose(this, () => ro.disconnect());
607
+ }
537
608
  const setSplit = (clientX, clientY) => {
538
609
  const rect = this.getBoundingClientRect();
539
- const vertical = this.classList.contains("c-split-view--vertical");
610
+ const vertical = isColumn();
540
611
  const span = vertical ? rect.height : rect.width;
541
612
  const pos = vertical ? clientY - rect.top : clientX - rect.left;
542
613
  const frac = span > 0 ? Math.min(0.9, Math.max(0.1, pos / span)) : 0.5;
@@ -592,8 +663,7 @@ class ContourTableWrap extends ContourBase {
592
663
  render() {
593
664
  this.classList.add("c-table-wrap");
594
665
  Array.from(this.childNodes).forEach((n) => { if (n.nodeType === Node.TEXT_NODE) n.remove(); else if (n.nodeType === Node.ELEMENT_NODE && n.tagName === "SPAN") n.remove(); });
595
- // A shipped component must not invent a table: the author supplies the
596
- // <table>. The old code rendered an A/B/1/2 grid when empty.
666
+ // Author supplies the <table>; component doesn't invent one (old code rendered A/B/1/2).
597
667
  }
598
668
  }
599
669
  define("contour-table-wrap", ContourTableWrap);
@@ -604,18 +674,18 @@ class ContourScrollArea extends ContourBase {
604
674
  this.classList.add("c-scroll-area");
605
675
  const title = this.getAttribute("title");
606
676
  if (title) {
607
- const t = this.ensure(".c-scroll-area__title", () => { const el = document.createElement("div"); el.className = "c-scroll-area__title"; el.style.padding = "var(--space-sm)"; el.style.fontWeight = "var(--weight-semibold)"; return el; });
677
+ const t = this.ensure(".c-scroll-area__title", () => { const el = document.createElement("div"); el.className = "c-scroll-area__title"; return el; });
608
678
  t.textContent = title;
609
679
  }
610
680
  }
611
681
  }
612
682
  define("contour-scroll-area", ContourScrollArea);
613
683
  class ContourBtn extends ContourBase {
614
- static get observed() { return ["variant", "size", "color", "label", "disabled"]; }
684
+ static get observed() { return ["variant", "size", "color", "label", "disabled", "href", "loading", "title"]; }
615
685
  static get properties() { return { variant: { attribute: "variant" }, size: { attribute: "size" }, color: { attribute: "color" }, label: { attribute: "label" }, disabled: { attribute: "disabled", type: Boolean } }; }
616
686
  render() {
617
687
  this.classList.add("c-btn");
618
- Array.from(this.classList).forEach((c) => { if (c.startsWith("c-btn--")) this.classList.remove(c); });
688
+ // keep authored variant classes; add attribute-driven ones on top.
619
689
  for (const attr of ["variant", "size", "color"]) {
620
690
  const val = this.getAttribute(attr);
621
691
  if (val) this.classList.add("c-btn--" + val);
@@ -628,14 +698,37 @@ class ContourBtn extends ContourBase {
628
698
  this.removeAttribute("aria-disabled");
629
699
  if (!this.hasAttribute("tabindex") || this.getAttribute("tabindex") === "-1") this.setAttribute("tabindex", "0");
630
700
  }
631
- const label = this.getAttribute("label");
701
+ // Name icon-only buttons from label/title when there is no text content.
702
+ const label = this.getAttribute("label") || this.getAttribute("title");
632
703
  if (label && !this.hasChildNodes()) this.textContent = label;
633
704
  if (label && !this.hasAttribute("aria-label")) this.setAttribute("aria-label", label);
705
+ // Loading state: expose data-loading + aria-busy so the spinner CSS and
706
+ // assistive technology both reflect the busy state.
707
+ if (this.hasAttribute("loading")) {
708
+ this.setAttribute("data-loading", "true");
709
+ this.setAttribute("aria-busy", "true");
710
+ } else {
711
+ this.removeAttribute("data-loading");
712
+ this.removeAttribute("aria-busy");
713
+ }
634
714
  }
635
715
  enhance() {
636
716
  if (this._wiredBtn) return;
637
717
  this._wiredBtn = true;
718
+ // disabled guard: no activation on click/keydown; capture-phase.
719
+ const isDisabled = () => this.hasAttribute("disabled") || this.getAttribute("aria-disabled") === "true";
720
+ this.addEventListener("click", (e) => {
721
+ if (isDisabled()) { e.preventDefault(); e.stopImmediatePropagation(); }
722
+ }, true);
723
+ // optional href mode — sanitize via safeHref and navigate on
724
+ // click/Enter (guard above keeps disabled buttons from navigating).
725
+ this.addEventListener("click", (e) => {
726
+ if (isDisabled()) return;
727
+ const href = safeHref(this.getAttribute("href"));
728
+ if (href && href !== "#") location.href = href;
729
+ });
638
730
  this.addEventListener("keydown", (e) => {
731
+ if (isDisabled()) { e.preventDefault(); e.stopImmediatePropagation(); return; }
639
732
  if (e.key === "Enter" || e.key === " ") { e.preventDefault(); this.click(); this.dispatchEvent(new CustomEvent("contour:activate", { bubbles: true, composed: true })); }
640
733
  });
641
734
  }