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
@@ -34,7 +34,7 @@
34
34
  // listbox's options, an aria-controls target) takes it from here rather than
35
35
  // calling Math.random(), which can hand two instances the same id and then point
36
36
  // one control at another's list.
37
- import { contourId, supportsUntilFound, onDispose } from './core.mjs';
37
+ import { contourId, supportsUntilFound, onDispose, navKey, isRtl } from './core.mjs';
38
38
 
39
39
  // A host is wired once per behaviour. Re-entering is normal — the base class
40
40
  // calls enhance() after every render — so the guard lives in a WeakMap keyed on
@@ -127,21 +127,6 @@ const wcEmit = (host, name, detail) => {
127
127
  * The active tab is `[aria-selected="true"]`, which is the rule the sheet
128
128
  * paints, so no state class is ever written — and none is invented either.
129
129
  */
130
- // RTL awareness (BY2-A7): a horizontal control reverses its arrow keys in a
131
- // right-to-left context, so ArrowRight moves to the previous item and
132
- // ArrowLeft to the next. The direction is read from the host, then its
133
- // nearest ancestor, then the document — the same cascade the platform uses.
134
- function isRtl(host) {
135
- let el = host;
136
- while (el && el.nodeType === 1) {
137
- const d = el.getAttribute && el.getAttribute("dir");
138
- if (d) return d.toLowerCase() === "rtl";
139
- el = el.parentElement;
140
- }
141
- try { return (document.documentElement.getAttribute("dir") || "").toLowerCase() === "rtl"; }
142
- catch (e) { return false; }
143
- }
144
-
145
130
  /** Wire tab keyboard navigation and selection for a host. */
146
131
  export function wireTabs(host) {
147
132
  if (!wcClaim(host, "tabs")) return;
@@ -154,6 +139,7 @@ export function wireTabs(host) {
154
139
  const tabsOf = () => wcGroup(host, list, "[role='tab']");
155
140
  const activate = (tab, focus) => {
156
141
  const tabs = tabsOf();
142
+ if (!tab.id) tab.id = contourId("c-tab");
157
143
  tabs.forEach((t) => {
158
144
  const selected = t === tab;
159
145
  t.setAttribute("aria-selected", String(selected));
@@ -161,7 +147,12 @@ export function wireTabs(host) {
161
147
  const ctrl = t.getAttribute("aria-controls");
162
148
  if (!ctrl) return;
163
149
  const panel = wcOne(host, "#" + CSS.escape(ctrl)) || document.getElementById(ctrl);
164
- if (panel) panel.hidden = !selected;
150
+ if (panel) {
151
+ panel.hidden = !selected;
152
+ // A tabpanel is named by its tab: without this a screen reader
153
+ // announces the panel with no name.
154
+ if (selected) panel.setAttribute("aria-labelledby", t.id);
155
+ }
165
156
  });
166
157
  const panels = wcAll(host, panelSel);
167
158
  if (panels.length) {
@@ -173,12 +164,14 @@ export function wireTabs(host) {
173
164
  const name = tab.getAttribute("aria-controls") || tab.textContent || "";
174
165
  host.dispatchEvent(new CustomEvent("contour:tab-change", { bubbles: true, composed: true, detail: { index: tabs.indexOf(tab), label: name } }));
175
166
  };
176
- // Same-document View Transitions (BY-24). A consumer who names elements via
177
- // `data-view-transition` / `--view-transition-name` gets a cross-fade on a
178
- // tab swap; the morph must run inside startViewTransition so the browser
179
- // has an old and a new state to interpolate. The initial mount activation
180
- // below stays direct — a transition on load is a page fade nobody asked
181
- // for — and the plain swap is the entire fallback, because the CSS harness
167
+ // Same-document View Transitions (BY-24). A tab swap runs inside
168
+ // document.startViewTransition, so the browser cross-fades the whole
169
+ // document between the old and new panel. This is a document cross-fade,
170
+ // not a named-element morph: the component does not set
171
+ // --view-transition-name, and a consumer who names elements gets the
172
+ // browser's own morph on top of this. The initial mount activation below
173
+ // stays direct — a transition on load is a page fade nobody asked for —
174
+ // and the plain swap is the entire fallback, because the CSS harness
182
175
  // (components.css) is enhancement-only too.
183
176
  const runActivation = (tab, focus) => {
184
177
  // Keyboard activation must update aria-selected synchronously so assistive
@@ -196,7 +189,13 @@ export function wireTabs(host) {
196
189
  };
197
190
  wcListen(host, "click", (e) => {
198
191
  const tab = wcClosest(host, e.target, "[role='tab']");
199
- if (tab && tabsOf().includes(tab)) runActivation(tab, false);
192
+ if (tab && tabsOf().includes(tab)) {
193
+ // A button nested inside a tab (a close control, say) is its own
194
+ // target: activating the tab underneath it would be a surprise.
195
+ const inner = e.target && e.target.closest ? e.target.closest("button") : null;
196
+ if (inner && inner !== tab && tab.contains(inner)) return;
197
+ runActivation(tab, false);
198
+ }
200
199
  });
201
200
  wcListen(host, "keydown", (e) => {
202
201
  let tab = wcClosest(host, e.target, "[role='tab']");
@@ -343,15 +342,7 @@ export function wireSegmented(host) {
343
342
  const seg = groups.find((g) => wcGroup(host, g, "button").includes(btn));
344
343
  if (!seg) return;
345
344
  const opts = wcGroup(host, seg, "button");
346
- const idx = opts.indexOf(btn);
347
- let next = -1;
348
- const rtl = isRtl(host);
349
- if (e.key === "ArrowRight" || e.key === "ArrowDown") next = rtl ? Math.max(idx - 1, 0) : Math.min(idx + 1, opts.length - 1);
350
- else if (e.key === "ArrowLeft" || e.key === "ArrowUp") next = rtl ? Math.min(idx + 1, opts.length - 1) : Math.max(idx - 1, 0);
351
- else if (e.key === "Home") next = 0;
352
- else if (e.key === "End") next = opts.length - 1;
353
- else if (e.key === "Enter" || e.key === " ") { e.preventDefault(); activate(btn); return; }
354
- if (next >= 0 && next !== idx) { e.preventDefault(); opts[next].focus(); }
345
+ navKey(e, opts, { wrap: false, homeEnd: true, rtl: isRtl(host), onNavigate: (i) => activate(opts[i]), onKey: () => activate(btn) });
355
346
  });
356
347
  }
357
348
 
@@ -460,7 +451,7 @@ export function wireCombobox(host) {
460
451
  const selected = (host.getAttribute("value") || "").split(",").map((v) => v.trim()).filter(Boolean);
461
452
  const value = host._comboboxVirtual && host._comboboxFiltered
462
453
  ? host._comboboxFiltered.find((item) => item.index === Number(opt.dataset.optionIndex))?.value
463
- : opt.textContent.trim();
454
+ : (opt.dataset.optionValue != null ? opt.dataset.optionValue : opt.textContent.trim());
464
455
  const position = selected.indexOf(String(value));
465
456
  if (now && position >= 0) selected.splice(position, 1);
466
457
  if (!now && position < 0) selected.push(String(value));
@@ -470,8 +461,13 @@ export function wireCombobox(host) {
470
461
  field.focus();
471
462
  return;
472
463
  }
464
+ // Commit the option's value, not its label: the field shows the label, the
465
+ // form submits the value, and `contour:select` carries the value.
466
+ const value = opt.dataset.optionValue != null ? opt.dataset.optionValue : opt.textContent.trim();
473
467
  field.value = opt.textContent;
474
- wcEmit(host, "contour:select", { value: field.value });
468
+ host.setAttribute("value", value);
469
+ if (typeof host._syncFormValue === "function") host._syncFormValue();
470
+ wcEmit(host, "contour:select", { value });
475
471
  close();
476
472
  field.focus();
477
473
  };
@@ -793,16 +789,7 @@ export function wireTree(host) {
793
789
  }
794
790
  return;
795
791
  }
796
- let next = -1;
797
- if (e.key === "ArrowDown") next = Math.min(idx + 1, items.length - 1);
798
- else if (e.key === "ArrowUp") next = Math.max(idx - 1, 0);
799
- else if (e.key === "Home") next = 0;
800
- else if (e.key === "End") next = items.length - 1;
801
- if (next >= 0 && next !== idx) {
802
- e.preventDefault();
803
- items[next].focus();
804
- rove(items[next]);
805
- }
792
+ navKey(e, items, { wrap: false, homeEnd: true, onNavigate: (i) => rove(items[i]) });
806
793
  });
807
794
  }
808
795
 
@@ -865,17 +852,7 @@ export function wireMenu(host) {
865
852
  }
866
853
  }
867
854
 
868
- let next = -1;
869
- if (e.key === "ArrowDown") next = index < 0 ? 0 : Math.min(index + 1, its.length - 1);
870
- else if (e.key === "ArrowUp") next = index < 0 ? its.length - 1 : Math.max(index - 1, 0);
871
- else if (e.key === "Home") next = 0;
872
- else if (e.key === "End") next = its.length - 1;
873
- if (next >= 0) { e.preventDefault(); its[next].focus(); return; }
874
- if ((e.key === "Enter" || e.key === " ") && index >= 0 && !(target && target.getAttribute("aria-haspopup") === "menu")) {
875
- e.preventDefault();
876
- wcEmit(host, "contour:select", { index, label: its[index].textContent.trim() });
877
- closeAllSubmenus();
878
- }
855
+ navKey(e, its, { wrap: true, homeEnd: true, onKey: () => { if (e.key === "Enter" || e.key === " ") { const idx = its.indexOf(document.activeElement); if (idx >= 0 && !(target && target.getAttribute("aria-haspopup") === "menu")) { wcEmit(host, "contour:select", { index: idx, label: its[idx].textContent.trim() }); closeAllSubmenus(); } } } });
879
856
  // Typeahead (F-21): printable char jumps to the first item whose label
880
857
  // starts with the typed character.
881
858
  if (e.key.length === 1 && !e.ctrlKey && !e.metaKey && !e.altKey) {
@@ -972,7 +949,18 @@ export function wireCopy(host) {
972
949
  if (!btn) return;
973
950
  const owner = wcClosest(host, btn, ".c-code") || wcClosest(host, btn, ".c-install") || host;
974
951
  const src = owner.querySelector("code, .c-install__command");
975
- const text = (src ? src.textContent : owner.textContent) || "";
952
+ // A numbered block carries its gutter as elements inside the <code>, so
953
+ // `textContent` would copy the numbers and lose the line breaks between the
954
+ // line spans. Read the lines back instead: the gutter is dropped, the breaks
955
+ // are restored, and the clipboard gets the code the reader sees.
956
+ const readSource = (el) => {
957
+ const lines = el && el.querySelectorAll ? el.querySelectorAll(".c-code__line") : null;
958
+ if (!lines || !lines.length) return el ? el.textContent || "" : "";
959
+ return Array.from(lines).map((l) => Array.from(l.childNodes)
960
+ .filter((n) => !(n.classList && n.classList.contains("c-code__line-number")))
961
+ .map((n) => n.textContent).join("")).join("\n");
962
+ };
963
+ const text = readSource(src) || (src ? "" : owner.textContent) || "";
976
964
  // The confirmation is the one the system script paints for the guide's own
977
965
  // copy buttons: a label swap, `data-copied` (which the shipped CSS styles)
978
966
  // and an icon check on the trigger, reverted after the same beat. The