contour-ds 1.7.2 → 1.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. package/README.md +80 -11
  2. package/dist/agent-rules.json +16 -0
  3. package/dist/build-manifest.json +181 -104
  4. package/dist/contour-wc-content.esm.js +5125 -0
  5. package/dist/contour-wc-content.esm.min.js +1 -0
  6. package/dist/contour-wc-dashboard.esm.js +8654 -0
  7. package/dist/contour-wc-dashboard.esm.min.js +1 -0
  8. package/dist/contour-wc-data.esm.js +8260 -0
  9. package/dist/contour-wc-data.esm.min.js +1 -0
  10. package/dist/contour-wc-docs.esm.js +4305 -0
  11. package/dist/contour-wc-docs.esm.min.js +1 -0
  12. package/dist/contour-wc-feedback.esm.js +4917 -0
  13. package/dist/contour-wc-feedback.esm.min.js +1 -0
  14. package/dist/contour-wc-forms.esm.js +5688 -0
  15. package/dist/contour-wc-forms.esm.min.js +1 -0
  16. package/dist/contour-wc-interaction.esm.js +4580 -0
  17. package/dist/contour-wc-interaction.esm.min.js +1 -0
  18. package/dist/contour-wc-layout.esm.js +4174 -0
  19. package/dist/contour-wc-layout.esm.min.js +1 -0
  20. package/dist/contour-wc-map.esm.js +5205 -0
  21. package/dist/contour-wc-map.esm.min.js +1 -0
  22. package/dist/contour-wc-misc.esm.js +4264 -0
  23. package/dist/contour-wc-misc.esm.min.js +1 -0
  24. package/dist/contour-wc-navigation.esm.js +5844 -0
  25. package/dist/contour-wc-navigation.esm.min.js +1 -0
  26. package/dist/contour-wc-ui.esm.js +9009 -0
  27. package/dist/contour-wc-ui.esm.min.js +1 -0
  28. package/dist/contour-wc.esm.js +6109 -1641
  29. package/dist/contour-wc.esm.min.js +1 -1
  30. package/dist/contour-wc.js +6108 -1641
  31. package/dist/contour-wc.min.js +1 -1
  32. package/dist/contour.code-snippets +4512 -0
  33. package/dist/contour.components.json +2597 -799
  34. package/dist/contour.css +5275 -4050
  35. package/dist/contour.d.ts +560 -1085
  36. package/dist/contour.esm.js +7 -0
  37. package/dist/contour.esm.min.js +1 -1
  38. package/dist/contour.html-data.json +10311 -0
  39. package/dist/contour.js +7 -0
  40. package/dist/contour.min.css +1 -1
  41. package/dist/contour.min.js +1 -1
  42. package/dist/contour.react.d.ts +420 -0
  43. package/dist/contour.single.html +17 -0
  44. package/dist/contour.single.min.css +1 -0
  45. package/dist/contour.tokens.json +940 -902
  46. package/dist/contour.vue.d.ts +418 -0
  47. package/dist/contour.web-types.json +10703 -0
  48. package/dist/custom-elements.json +30708 -0
  49. package/dist/docs/actions.md +3 -2
  50. package/dist/docs/affordances.md +23 -9
  51. package/dist/docs/apireference.md +1 -1
  52. package/dist/docs/colour.md +1 -1
  53. package/dist/docs/componentindex.md +6 -2
  54. package/dist/docs/data.md +7 -2
  55. package/dist/docs/docs.md +9 -2
  56. package/dist/docs/feedback.md +1 -1
  57. package/dist/docs/field.md +1 -1
  58. package/dist/docs/forms.md +1 -1
  59. package/dist/docs/index.json +22 -20
  60. package/dist/docs/install.md +1 -1
  61. package/dist/docs/landing.md +1 -1
  62. package/dist/docs/mapengine.md +19 -2
  63. package/dist/docs/motion.md +1 -1
  64. package/dist/docs/navigation.md +1 -1
  65. package/dist/docs/overlays.md +1 -1
  66. package/dist/docs/overview.md +1 -1
  67. package/dist/docs/patterns.md +2 -2
  68. package/dist/docs/playground.md +22 -2
  69. package/dist/docs/principles.md +1 -1
  70. package/dist/docs/recipes.md +13 -8
  71. package/dist/docs/space.md +1 -1
  72. package/dist/docs/status.md +14 -2
  73. package/dist/docs/surfaces.md +1 -1
  74. package/dist/docs/theming.md +1 -1
  75. package/dist/docs/type.md +1 -1
  76. package/dist/docs/webcomponents.md +17 -3
  77. package/dist/registry/items/contour-core.json +2 -2
  78. package/dist/registry/items/contour-data.json +2 -2
  79. package/dist/registry/items/contour-docs.json +2 -2
  80. package/dist/registry/items/contour-landing.json +2 -2
  81. package/dist/registry/registry.json +8 -8
  82. package/dist/surfaces/contour-core.min.css +1 -1
  83. package/dist/surfaces/contour-data.min.css +1 -1
  84. package/dist/surfaces/contour-docs.min.css +1 -1
  85. package/dist/surfaces/contour-landing.min.css +1 -1
  86. package/dist/wc/behaviours.mjs +45 -57
  87. package/dist/wc/content.mjs +263 -63
  88. package/dist/wc/core.mjs +390 -71
  89. package/dist/wc/dashboard.mjs +220 -13
  90. package/dist/wc/data.mjs +1075 -460
  91. package/dist/wc/docs.mjs +105 -12
  92. package/dist/wc/feedback.mjs +63 -14
  93. package/dist/wc/forms.mjs +733 -104
  94. package/dist/wc/index.mjs +9 -2
  95. package/dist/wc/interaction.mjs +182 -28
  96. package/dist/wc/layout.mjs +95 -25
  97. package/dist/wc/map.mjs +185 -118
  98. package/dist/wc/misc.mjs +124 -24
  99. package/dist/wc/navigation.mjs +384 -115
  100. package/dist/wc/shadow.mjs +94 -18
  101. package/dist/wc/states.mjs +21 -3
  102. package/dist/wc/svg.mjs +104 -0
  103. package/dist/wc/ui.mjs +1988 -476
  104. package/integrations/README.md +2 -0
  105. package/integrations/ai/CLAUDE.md +3 -3
  106. package/integrations/frameworks/README.md +235 -0
  107. package/integrations/native/style-dictionary.config.json +1 -1
  108. package/integrations/tailwind/contour-theme.css +5 -6
  109. package/package.json +53 -24
package/dist/wc/index.mjs CHANGED
@@ -1,6 +1,9 @@
1
1
  /**
2
2
  * Contour web-component entry point.
3
3
  * Importing this module registers every light-DOM and shadow-DOM element.
4
+ * NOTE: This is the all-in convenience bundle (~740 kB minified).
5
+ * For production, prefer importing individual family bundles:
6
+ * `contour-ds/wc/<family>.mjs` (e.g. `contour-ds/wc/forms.mjs`, `contour-ds/wc/data.mjs`).
4
7
  * @module contour-wc
5
8
  */
6
9
 
@@ -23,12 +26,16 @@ import "./misc.mjs";
23
26
  import "./navigation.mjs";
24
27
  import "./ui.mjs";
25
28
  import "./registration.mjs";
26
- import "./shadow.mjs";
29
+ import { SHADOW_MARKUP, renderShadowDSD } from "./shadow.mjs";
30
+ export { SHADOW_MARKUP, renderShadowDSD };
27
31
 
28
32
  // Published version + readiness signal. Fires after every fragment has run, so
29
33
  // a consumer listening for `contour:ready` can assume the full registry exists.
34
+ // The version is stamped from package.json at build time (tools/build.mjs
35
+ // `stampVersion`); the literal here is the source-time fallback and is never
36
+ // shipped — the build replaces it with the package.json version.
30
37
  /** Published component runtime version. */
31
- export const CONTOUR_VERSION = "1.7.0";
38
+ export const CONTOUR_VERSION = "1.8.1";
32
39
  if (typeof window !== "undefined") {
33
40
  window.ContourVersion = CONTOUR_VERSION;
34
41
  if (!window.Contour) {
@@ -1,11 +1,12 @@
1
- import { ContourBase, define, onDispose } from './core.mjs';
2
- import { wireSegmented } from './behaviours.mjs';
1
+ import { ContourBase, define, onDispose , warnBadJson } from './core.mjs';
2
+ import { wireSegmented, modalContain } from './behaviours.mjs';
3
3
  class ContourPressableFull extends ContourBase {
4
4
  static get observed() { return ["disabled"]; }
5
5
  static get properties() { return { disabled: { attribute: "disabled", type: Boolean } }; }
6
6
  render() {
7
7
  this.classList.add("c-pressable");
8
8
  if (!this.hasAttribute("role")) this.setAttribute("role", "button");
9
+ if (!this.hasAttribute("aria-label")) this.setAttribute("aria-label", this.getAttribute("label") || "Pressable");
9
10
  if (this.hasAttribute("disabled")) {
10
11
  this.setAttribute("aria-disabled", "true");
11
12
  this.setAttribute("tabindex", "-1");
@@ -27,10 +28,34 @@ class ContourResizeHandleFull extends ContourBase {
27
28
  render() {
28
29
  this.classList.add("c-resize-handle");
29
30
  if (!this.hasAttribute("role")) this.setAttribute("role", "separator");
31
+ if (!this.hasAttribute("aria-valuenow")) this.setAttribute("aria-valuenow", "0");
30
32
  if (!this.hasAttribute("aria-label")) this.setAttribute("aria-label", "Resize handle");
31
33
  if (!this.hasAttribute("tabindex")) this.setAttribute("tabindex", "0");
32
34
  if (!this.hasAttribute("aria-orientation")) this.setAttribute("aria-orientation", "horizontal");
33
35
  }
36
+ enhance() {
37
+ if (this._wiredResizeHandle) return;
38
+ 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.
42
+ this.addEventListener("keydown", (e) => {
43
+ let delta = 0;
44
+ if (e.key === "ArrowLeft" || e.key === "ArrowDown") delta = -5;
45
+ 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;
48
+ else return;
49
+ 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));
55
+ this.setAttribute("aria-valuenow", String(next));
56
+ this.dispatchEvent(new CustomEvent("contour:resize", { bubbles: true, composed: true, detail: { value: next, delta } }));
57
+ });
58
+ }
34
59
  }
35
60
  define("contour-resize-handle", ContourResizeHandleFull);
36
61
  class ContourSearchTriggerFull extends ContourBase {
@@ -68,7 +93,6 @@ class ContourShortcutRowFull extends ContourBase {
68
93
  static get properties() { return { desc: { attribute: "desc" }, key: { attribute: "key" } }; }
69
94
  render() {
70
95
  this.classList.add("c-shortcut-row");
71
- this.setAttribute("role", "listitem");
72
96
  const key = this.getAttribute("key");
73
97
  const desc = this.getAttribute("desc");
74
98
  if (key) {
@@ -111,6 +135,9 @@ class ContourShortcutPanelFull extends ContourBase {
111
135
  static get properties() { return { title: { attribute: "title" }, open: { attribute: "open", type: Boolean } }; }
112
136
  render() {
113
137
  this.classList.add("c-shortcut-overlay");
138
+ if (!this.hasAttribute("role")) this.setAttribute("role", "dialog");
139
+ if (!this.hasAttribute("aria-modal")) this.setAttribute("aria-modal", "true");
140
+ if (!this.hasAttribute("aria-label")) this.setAttribute("aria-label", this.getAttribute("title") || "Keyboard shortcuts");
114
141
  const title = this.getAttribute("title");
115
142
  if (title) {
116
143
  const t = this.ensure(".c-shortcut-overlay__title", () => { const el = document.createElement("div"); el.className = "c-shortcut-overlay__title"; return el; });
@@ -119,8 +146,8 @@ class ContourShortcutPanelFull extends ContourBase {
119
146
  if (this.hasAttribute("open")) this.removeAttribute("hidden");
120
147
  else if (!this.hasAttribute("hidden")) this.setAttribute("hidden", "");
121
148
  }
122
- show() { this.setAttribute("open", ""); this.removeAttribute("hidden"); this.dispatchEvent(new CustomEvent("contour:open", { bubbles: true, composed: true })); }
123
- hide() { this.removeAttribute("open"); this.setAttribute("hidden", ""); this.dispatchEvent(new CustomEvent("contour:close", { bubbles: true, composed: true })); }
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 })); }
124
151
  toggle() { if (this.hasAttribute("open")) this.hide(); else this.show(); }
125
152
  enhance() {
126
153
  if (this._wiredShortcutOverlay) return;
@@ -159,6 +186,7 @@ class ContourRowActionFull extends ContourBase {
159
186
  }
160
187
  const label = this.getAttribute("label");
161
188
  if (label && !this.hasChildNodes()) this.textContent = label;
189
+ if (label && !this.hasAttribute("aria-label")) this.setAttribute("aria-label", label);
162
190
  }
163
191
  enhance() {
164
192
  if (this._wiredRowAction) return;
@@ -209,6 +237,7 @@ class ContourDraggable extends ContourBase {
209
237
  if (!this.hasAttribute("role")) this.setAttribute("role", "button");
210
238
  if (!this.hasAttribute("tabindex")) this.setAttribute("tabindex", "0");
211
239
  if (!this.hasAttribute("draggable")) this.setAttribute("draggable", "true");
240
+ if (!this.hasAttribute("aria-label")) this.setAttribute("aria-label", this.getAttribute("label") || "Draggable item");
212
241
  }
213
242
  // The value a drop partner receives: the authored `value` attribute, else
214
243
  // the `label`, else the element's own text. One shape, so a consumer's
@@ -257,31 +286,58 @@ class ContourDragHandle extends ContourBase {
257
286
  render() {
258
287
  this.classList.add("c-drag-handle");
259
288
  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.
291
+ const min = this.getAttribute("min") || "0";
292
+ const max = this.getAttribute("max") || "100";
293
+ if (!this.hasAttribute("aria-valuenow")) this.setAttribute("aria-valuenow", min);
294
+ if (!this.hasAttribute("aria-valuemin")) this.setAttribute("aria-valuemin", min);
295
+ if (!this.hasAttribute("aria-valuemax")) this.setAttribute("aria-valuemax", max);
260
296
  if (!this.hasAttribute("tabindex")) this.setAttribute("tabindex", "0");
297
+ if (!this.hasAttribute("aria-label")) this.setAttribute("aria-label", this.getAttribute("label") || "Drag handle");
261
298
  if (!this.hasAttribute("aria-orientation")) this.setAttribute("aria-orientation", "horizontal");
299
+ // Name the pane the handle resizes, when the author says which.
300
+ const controls = this.getAttribute("controls");
301
+ if (controls && !this.hasAttribute("aria-controls")) this.setAttribute("aria-controls", controls);
262
302
  }
263
303
  enhance() {
264
304
  if (this._wiredDragHandle) return;
265
305
  this._wiredDragHandle = true;
266
306
  this.addEventListener("keydown", (e) => {
307
+ const now = Number(this.getAttribute("aria-valuenow") || 0);
308
+ const min = Number(this.getAttribute("aria-valuemin") || 0);
309
+ const max = Number(this.getAttribute("aria-valuemax") || 100);
267
310
  let delta = 0;
268
311
  if (e.key === "ArrowLeft" || e.key === "ArrowDown") delta = -1;
269
312
  else if (e.key === "ArrowRight" || e.key === "ArrowUp") delta = 1;
270
- else if (e.key === "Home") delta = -Infinity;
271
- else if (e.key === "End") delta = Infinity;
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.
316
+ else if (e.key === "Home") delta = min - now;
317
+ else if (e.key === "End") delta = max - now;
272
318
  else return;
273
319
  e.preventDefault();
274
- this.dispatchEvent(new CustomEvent("contour:drag", { bubbles: true, composed: true, detail: { key: e.key, delta } }));
320
+ this.dispatchEvent(new CustomEvent("contour:drag", { bubbles: true, composed: true, detail: { key: e.key, delta, value: now } }));
275
321
  });
276
322
  }
277
323
  }
278
324
  define("contour-drag-handle", ContourDragHandle);
279
325
  class ContourDropIndicator extends ContourBase {
280
- static get observed() { return ["label"]; }
281
- static get properties() { return { label: { attribute: "label" } }; }
326
+ static get observed() { return ["label", "open"]; }
327
+ static get properties() { return { label: { attribute: "label" }, open: { attribute: "open", type: Boolean } }; }
282
328
  render() {
283
329
  this.classList.add("c-drop-indicator");
284
- this.classList.add("c-drop-indicator--visible");
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.
333
+ this.classList.toggle("c-drop-indicator--visible", this.hasAttribute("open"));
334
+ 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.
337
+ if (this.getAttribute("role") === "presentation") {
338
+ this.removeAttribute("aria-label");
339
+ this.removeAttribute("aria-labelledby");
340
+ }
285
341
  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(); });
286
342
  const label = this.getAttribute("label");
287
343
  if (label) {
@@ -296,6 +352,8 @@ class ContourDropZone extends ContourBase {
296
352
  static get properties() { return { label: { attribute: "label" } }; }
297
353
  render() {
298
354
  this.classList.add("c-drop-zone");
355
+ if (!this.hasAttribute("role")) this.setAttribute("role", "region");
356
+ if (!this.hasAttribute("aria-label")) this.setAttribute("aria-label", this.getAttribute("label") || "Drop zone");
299
357
  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(); });
300
358
  const label = this.getAttribute("label");
301
359
  if (label) {
@@ -345,16 +403,17 @@ class ContourResizable extends ContourBase {
345
403
  const vertical = this.getAttribute("direction") === "vertical";
346
404
  this.classList.add(vertical ? "c-resizable--vertical" : "c-resizable--horizontal");
347
405
  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.
348
408
  const p1 = document.createElement("div");
349
409
  p1.className = "c-resizable__pane";
350
- p1.textContent = "Pane A";
351
410
  const handle = document.createElement("div");
352
411
  handle.className = "c-resize-handle";
353
412
  handle.setAttribute("tabindex", "0");
354
413
  handle.setAttribute("role", "separator");
414
+ handle.setAttribute("aria-valuenow", "0");
355
415
  const p2 = document.createElement("div");
356
416
  p2.className = "c-resizable__pane";
357
- p2.textContent = "Pane B";
358
417
  this.appendChild(p1);
359
418
  this.appendChild(handle);
360
419
  this.appendChild(p2);
@@ -398,6 +457,8 @@ class ContourResizable extends ContourBase {
398
457
  if (!this._resizing) return;
399
458
  this._resizing = false;
400
459
  if (this._splitValue) { this.setAttribute("value", this._splitValue); this._splitValue = null; }
460
+ const rect = this.getBoundingClientRect();
461
+ this.dispatchEvent(new CustomEvent("contour:resize", { bubbles: true, composed: true, detail: { width: Math.round(rect.width), height: Math.round(rect.height) } }));
401
462
  const handle = this.querySelector(".c-resize-handle");
402
463
  if (handle) {
403
464
  handle.classList.remove("c-resize-handle--dragging");
@@ -415,31 +476,124 @@ class ContourResizable extends ContourBase {
415
476
  const cur = parseFloat(this.getAttribute("value")) || 50;
416
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)); } }
417
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)); } }
479
+ const r = this.getBoundingClientRect();
480
+ this.dispatchEvent(new CustomEvent("contour:resize", { bubbles: true, composed: true, detail: { width: Math.round(r.width), height: Math.round(r.height) } }));
418
481
  });
419
482
  }
420
483
  }
421
484
  define("contour-resizable", ContourResizable);
485
+ class ContourSplitView extends ContourBase {
486
+ static get observed() { return ["direction", "value", "left-label", "right-label"]; }
487
+ static get properties() { return { direction: { attribute: "direction" }, value: { attribute: "value" }, "left-label": { attribute: "left-label" }, "right-label": { attribute: "right-label" } }; }
488
+ render() {
489
+ this.classList.add("c-split-view");
490
+ this.setAttribute("role", "region");
491
+ const vertical = this.getAttribute("direction") === "vertical";
492
+ if (vertical) {
493
+ this.classList.add("c-split-view--vertical");
494
+ this.classList.remove("c-split-view--horizontal");
495
+ } else {
496
+ this.classList.add("c-split-view--horizontal");
497
+ this.classList.remove("c-split-view--vertical");
498
+ }
499
+ if (this.getAttribute("left-label")) this.setAttribute("aria-label", this.getAttribute("left-label"));
500
+ if (!this.querySelector(".c-split-view__pane")) {
501
+ const p1 = document.createElement("div");
502
+ p1.className = "c-split-view__pane c-split-view__pane--left";
503
+ if (this.getAttribute("left-label")) p1.setAttribute("aria-label", this.getAttribute("left-label"));
504
+ const divider = document.createElement("div");
505
+ divider.className = "c-split-view__divider";
506
+ divider.setAttribute("tabindex", "0");
507
+ divider.setAttribute("role", "separator");
508
+ divider.setAttribute("aria-valuenow", this.getAttribute("value") || "50");
509
+ divider.setAttribute("aria-label", "Split divider");
510
+ const p2 = document.createElement("div");
511
+ p2.className = "c-split-view__pane c-split-view__pane--right";
512
+ if (this.getAttribute("right-label")) p2.setAttribute("aria-label", this.getAttribute("right-label"));
513
+ this.appendChild(p1);
514
+ this.appendChild(divider);
515
+ this.appendChild(p2);
516
+ }
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.
519
+ if (!this.querySelector(".c-split-view__divider")) {
520
+ const divider = document.createElement("div");
521
+ divider.className = "c-split-view__divider";
522
+ divider.setAttribute("tabindex", "0");
523
+ divider.setAttribute("role", "separator");
524
+ divider.setAttribute("aria-valuenow", this.getAttribute("value") || "50");
525
+ divider.setAttribute("aria-label", "Split divider");
526
+ this.appendChild(divider);
527
+ }
528
+ const v = this.getAttribute("value") || "50";
529
+ const p1 = this.querySelector(".c-split-view__pane--left");
530
+ if (p1) p1.style.flex = `0 0 ${v}%`;
531
+ const divider = this.querySelector(".c-split-view__divider");
532
+ if (divider) divider.setAttribute("aria-valuenow", v);
533
+ }
534
+ enhance() {
535
+ if (this._wiredSplitView) return;
536
+ this._wiredSplitView = true;
537
+ const setSplit = (clientX, clientY) => {
538
+ const rect = this.getBoundingClientRect();
539
+ const vertical = this.classList.contains("c-split-view--vertical");
540
+ const span = vertical ? rect.height : rect.width;
541
+ const pos = vertical ? clientY - rect.top : clientX - rect.left;
542
+ const frac = span > 0 ? Math.min(0.9, Math.max(0.1, pos / span)) : 0.5;
543
+ const pct = Math.round(frac * 100);
544
+ const p1 = this.querySelector(".c-split-view__pane--left");
545
+ if (p1) p1.style.flex = `0 0 ${pct}%`;
546
+ const divider = this.querySelector(".c-split-view__divider");
547
+ if (divider) divider.setAttribute("aria-valuenow", String(pct));
548
+ this.setAttribute("value", String(pct));
549
+ };
550
+ this.addEventListener("pointerdown", (e) => {
551
+ const divider = this.querySelector(".c-split-view__divider");
552
+ if (!divider || e.target !== divider) return;
553
+ this._resizing = true;
554
+ divider.classList.add("c-split-view__divider--dragging");
555
+ if (divider.setPointerCapture) { try { divider.setPointerCapture(e.pointerId); } catch (err) { /* ignore */ } }
556
+ e.preventDefault();
557
+ });
558
+ this.addEventListener("pointermove", (e) => {
559
+ if (!this._resizing) return;
560
+ setSplit(e.clientX, e.clientY);
561
+ });
562
+ const stopResize = (e) => {
563
+ if (!this._resizing) return;
564
+ this._resizing = false;
565
+ const divider = this.querySelector(".c-split-view__divider");
566
+ if (divider) {
567
+ divider.classList.remove("c-split-view__divider--dragging");
568
+ if (divider.hasPointerCapture && divider.hasPointerCapture(e.pointerId)) {
569
+ try { divider.releasePointerCapture(e.pointerId); } catch (err) { /* ignore */ }
570
+ }
571
+ }
572
+ const r = this.getBoundingClientRect();
573
+ this.dispatchEvent(new CustomEvent("contour:split-change", { bubbles: true, composed: true, detail: { value: this.getAttribute("value"), width: Math.round(r.width), height: Math.round(r.height) } }));
574
+ };
575
+ this.addEventListener("pointerup", stopResize);
576
+ this.addEventListener("pointercancel", stopResize);
577
+ this.addEventListener("keydown", (e) => {
578
+ const divider = this.querySelector(".c-split-view__divider");
579
+ if (!divider || document.activeElement !== divider) return;
580
+ const cur = parseFloat(this.getAttribute("value")) || 50;
581
+ if (e.key === "ArrowLeft" || e.key === "ArrowDown") { e.preventDefault(); const nv = Math.max(10, cur - 5); const p1 = this.querySelector(".c-split-view__pane--left"); if (p1) p1.style.flex = `0 0 ${nv}%`; this.setAttribute("value", String(nv)); const d = this.querySelector(".c-split-view__divider"); if (d) d.setAttribute("aria-valuenow", String(nv)); }
582
+ else if (e.key === "ArrowRight" || e.key === "ArrowUp") { e.preventDefault(); const nv = Math.min(90, cur + 5); const p1 = this.querySelector(".c-split-view__pane--left"); if (p1) p1.style.flex = `0 0 ${nv}%`; this.setAttribute("value", String(nv)); const d = this.querySelector(".c-split-view__divider"); if (d) d.setAttribute("aria-valuenow", String(nv)); }
583
+ const r = this.getBoundingClientRect();
584
+ this.dispatchEvent(new CustomEvent("contour:split-change", { bubbles: true, composed: true, detail: { value: this.getAttribute("value"), width: Math.round(r.width), height: Math.round(r.height) } }));
585
+ });
586
+ }
587
+ }
588
+ define("contour-split-view", ContourSplitView);
422
589
  class ContourTableWrap extends ContourBase {
423
590
  static get observed() { return []; }
424
591
  static get properties() { return {}; }
425
592
  render() {
426
593
  this.classList.add("c-table-wrap");
427
594
  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(); });
428
- if (!this.querySelector("table")) {
429
- const t = document.createElement("table");
430
- t.className = "c-table";
431
- const thead = document.createElement("thead");
432
- const tr = document.createElement("tr");
433
- for (const h of ["A", "B"]) { const th = document.createElement("th"); th.textContent = h; tr.appendChild(th); }
434
- thead.appendChild(tr);
435
- t.appendChild(thead);
436
- const tbody = document.createElement("tbody");
437
- const tr2 = document.createElement("tr");
438
- for (const v of ["1", "2"]) { const td = document.createElement("td"); td.textContent = v; tr2.appendChild(td); }
439
- tbody.appendChild(tr2);
440
- t.appendChild(tbody);
441
- this.appendChild(t);
442
- }
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.
443
597
  }
444
598
  }
445
599
  define("contour-table-wrap", ContourTableWrap);
@@ -1,4 +1,4 @@
1
- import { ContourBase, define } from './core.mjs';
1
+ import { ContourBase, define, navKey, isRtl , warnBadJson } from './core.mjs';
2
2
  class ContourApp extends ContourBase {
3
3
  static get observed() { return ["title"]; }
4
4
  static get properties() { return { title: { attribute: "title" } }; }
@@ -14,6 +14,14 @@ import { ContourBase, define } from './core.mjs';
14
14
  const main = this.ensure(".c-app__main", () => { const el = document.createElement("main"); el.className = "c-app__main"; return el; });
15
15
  if (main.parentNode !== this) this.appendChild(main);
16
16
  if (header.parentNode !== this) this.insertBefore(header, main);
17
+ // The shell has one content region. Authored children left as siblings of
18
+ // the generated <main> took a share of the flex column and sat outside the
19
+ // document's only main landmark, which is neither the layout nor the
20
+ // outline the block describes.
21
+ Array.from(this.children).forEach((child) => {
22
+ if (child === header || child === main) return;
23
+ main.appendChild(child);
24
+ });
17
25
  }
18
26
  }
19
27
  define("contour-app", ContourApp);
@@ -22,7 +30,18 @@ import { ContourBase, define } from './core.mjs';
22
30
  static get properties() { return { title: { attribute: "title" } }; }
23
31
  render() {
24
32
  this.classList.add("c-app-body");
25
- const main = this.ensure(".c-app-body__main", () => { const el = document.createElement("main"); el.className = "c-app-body__main"; return el; });
33
+ // A document may have one visible <main>. Nested inside `contour-app` the
34
+ // shell already owns it, so the body's content region is a plain div; on
35
+ // its own it is the page's landmark.
36
+ const nested = !!(this.parentElement && this.parentElement.closest && this.parentElement.closest("contour-app"));
37
+ const tag = nested ? "div" : "main";
38
+ let main = this.querySelector(":scope > .c-app-body__main");
39
+ if (main && main.tagName.toLowerCase() !== tag) { main.remove(); main = null; }
40
+ if (!main) {
41
+ main = document.createElement(tag);
42
+ main.className = "c-app-body__main";
43
+ this.appendChild(main);
44
+ }
26
45
  const title = this.getAttribute("title");
27
46
  if (title) {
28
47
  const t = this.ensure(".c-app-body__title", () => { const el = document.createElement("div"); el.className = "c-app-body__title"; return el; });
@@ -40,15 +59,8 @@ class ContourBtnGroup extends ContourBase {
40
59
  this.classList.add("c-btn-group");
41
60
  this.setAttribute("role", "group");
42
61
  if (this.getAttribute("title")) this.setAttribute("aria-label", this.getAttribute("title"));
43
- if (!this.querySelector(".c-btn")) {
44
- for (const lbl of ["One", "Two", "Three"]) {
45
- const b = document.createElement("button");
46
- b.className = "c-btn c-btn--sm";
47
- b.type = "button";
48
- b.textContent = lbl;
49
- this.appendChild(b);
50
- }
51
- }
62
+ // A shipped component must not invent its own buttons: the author supplies
63
+ // the <button> children. The old code rendered One/Two/Three when empty.
52
64
  }
53
65
  enhance() {
54
66
  if (this._wiredBtnGroup) return;
@@ -64,20 +76,7 @@ class ContourBtnGroup extends ContourBase {
64
76
  this.addEventListener("keydown", (e) => {
65
77
  const buttons = Array.from(this.querySelectorAll(".c-btn"));
66
78
  if (!buttons.length) return;
67
- const active = document.activeElement;
68
- const idx = buttons.indexOf(active);
69
- let next = -1;
70
- const rtl = (this.getAttribute("dir") || document.documentElement.getAttribute("dir") || "").toLowerCase() === "rtl";
71
- if (e.key === "ArrowDown") next = idx < 0 ? 0 : Math.min(buttons.length - 1, idx + 1);
72
- else if (e.key === "ArrowUp") next = idx < 0 ? 0 : Math.max(0, idx - 1);
73
- else if (e.key === "ArrowRight") next = rtl ? (idx < 0 ? 0 : Math.max(0, idx - 1)) : (idx < 0 ? 0 : Math.min(buttons.length - 1, idx + 1));
74
- else if (e.key === "ArrowLeft") next = rtl ? (idx < 0 ? 0 : Math.min(buttons.length - 1, idx + 1)) : (idx < 0 ? 0 : Math.max(0, idx - 1));
75
- else if (e.key === "Home") next = 0;
76
- else if (e.key === "End") next = buttons.length - 1;
77
- if (next >= 0 && next !== idx) {
78
- e.preventDefault();
79
- buttons[next].focus();
80
- }
79
+ navKey(e, buttons, { wrap: false, homeEnd: true, rtl: isRtl(this) });
81
80
  });
82
81
  }
83
82
  }
@@ -165,3 +164,74 @@ class ContourBtnGroup extends ContourBase {
165
164
  }
166
165
  }
167
166
  define("contour-time-range", ContourTimeRange);
167
+
168
+ // Skip link: an <a> that is visually hidden until focused, then slides in at
169
+ // the top-left. The class does the work; the component wraps it so a consumer
170
+ // can drop <contour-skip-link href="#main"> into a page and get the link.
171
+ class ContourSkipLink extends ContourBase {
172
+ static get observed() { return ["href", "label"]; }
173
+ static get properties() { return { href: { attribute: "href" }, label: { attribute: "label" } }; }
174
+ render() {
175
+ const a = this.ensure("a", () => { const el = document.createElement("a"); el.className = "c-skip-link"; return el; });
176
+ a.setAttribute("href", this.getAttribute("href") || "#main");
177
+ a.textContent = this.getAttribute("label") || "Skip to content";
178
+ }
179
+ }
180
+ define("contour-skip-link", ContourSkipLink);
181
+
182
+ // Icon: renders a sprite <use> by name. The icon set is the guide's sprite;
183
+ // a consumer points `name` at an id and the <use> resolves it.
184
+ class ContourIcon extends ContourBase {
185
+ static get observed() { return ["name", "size", "label"]; }
186
+ static get properties() { return { name: { attribute: "name" }, size: { attribute: "size" }, label: { attribute: "label" } }; }
187
+ render() {
188
+ const name = this.getAttribute("name") || "";
189
+ const size = this.getAttribute("size");
190
+ const label = this.getAttribute("label");
191
+ this.innerHTML = "";
192
+ const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
193
+ svg.setAttribute("class", "c-icon");
194
+ svg.setAttribute("aria-hidden", "true");
195
+ if (size) svg.style.width = size, svg.style.height = size;
196
+ const use = document.createElementNS("http://www.w3.org/2000/svg", "use");
197
+ use.setAttribute("href", "#i-" + name);
198
+ svg.appendChild(use);
199
+ this.appendChild(svg);
200
+ if (label) { this.setAttribute("role", "img"); this.setAttribute("aria-label", label); }
201
+ else { this.removeAttribute("role"); this.removeAttribute("aria-label"); }
202
+ }
203
+ }
204
+ define("contour-icon", ContourIcon);
205
+
206
+ // Dashboard grid: a CSS grid of widget cells. The component is a layout
207
+ // primitive — it lays out its authored children in a responsive grid.
208
+ class ContourDashboardGrid extends ContourBase {
209
+ static get observed() { return ["cols", "gap"]; }
210
+ static get properties() { return { cols: { attribute: "cols" }, gap: { attribute: "gap" } }; }
211
+ render() {
212
+ this.classList.add("c-dashboard-grid");
213
+ const cols = this.getAttribute("cols");
214
+ if (cols) this.style.setProperty("--dashboard-grid-cols", cols);
215
+ const gap = this.getAttribute("gap");
216
+ if (gap) this.style.setProperty("--dashboard-grid-gap", gap);
217
+ }
218
+ }
219
+ define("contour-dashboard-grid", ContourDashboardGrid);
220
+
221
+ // Analysis stack: a vertical stack of analysis panels with a shared header.
222
+ class ContourAnalysisStack extends ContourBase {
223
+ static get observed() { return ["title"]; }
224
+ static get properties() { return { title: { attribute: "title" } }; }
225
+ render() {
226
+ this.classList.add("c-analysis-stack");
227
+ const title = this.getAttribute("title");
228
+ let header = this.querySelector(".c-analysis-stack__header");
229
+ if (title) {
230
+ if (!header) { header = document.createElement("div"); header.className = "c-analysis-stack__header"; this.prepend(header); }
231
+ let h = header.querySelector(".c-analysis-stack__title");
232
+ if (!h) { h = document.createElement("h3"); h.className = "c-analysis-stack__title"; header.appendChild(h); }
233
+ h.textContent = title;
234
+ } else if (header) header.remove();
235
+ }
236
+ }
237
+ define("contour-analysis-stack", ContourAnalysisStack);