contour-ds 1.7.1 → 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.
- package/README.md +80 -11
- package/dist/agent-rules.json +16 -0
- package/dist/build-manifest.json +184 -107
- package/dist/contour-wc-content.esm.js +5125 -0
- package/dist/contour-wc-content.esm.min.js +1 -0
- package/dist/contour-wc-dashboard.esm.js +8654 -0
- package/dist/contour-wc-dashboard.esm.min.js +1 -0
- package/dist/contour-wc-data.esm.js +8260 -0
- package/dist/contour-wc-data.esm.min.js +1 -0
- package/dist/contour-wc-docs.esm.js +4305 -0
- package/dist/contour-wc-docs.esm.min.js +1 -0
- package/dist/contour-wc-feedback.esm.js +4917 -0
- package/dist/contour-wc-feedback.esm.min.js +1 -0
- package/dist/contour-wc-forms.esm.js +5688 -0
- package/dist/contour-wc-forms.esm.min.js +1 -0
- package/dist/contour-wc-interaction.esm.js +4580 -0
- package/dist/contour-wc-interaction.esm.min.js +1 -0
- package/dist/contour-wc-layout.esm.js +4174 -0
- package/dist/contour-wc-layout.esm.min.js +1 -0
- package/dist/contour-wc-map.esm.js +5205 -0
- package/dist/contour-wc-map.esm.min.js +1 -0
- package/dist/contour-wc-misc.esm.js +4264 -0
- package/dist/contour-wc-misc.esm.min.js +1 -0
- package/dist/contour-wc-navigation.esm.js +5844 -0
- package/dist/contour-wc-navigation.esm.min.js +1 -0
- package/dist/contour-wc-ui.esm.js +9009 -0
- package/dist/contour-wc-ui.esm.min.js +1 -0
- package/dist/contour-wc.esm.js +6136 -1634
- package/dist/contour-wc.esm.min.js +1 -1
- package/dist/contour-wc.js +6135 -1634
- package/dist/contour-wc.min.js +1 -1
- package/dist/contour.code-snippets +4512 -0
- package/dist/contour.components.json +3321 -868
- package/dist/contour.css +5863 -3999
- package/dist/contour.d.ts +560 -1085
- package/dist/contour.esm.js +7 -0
- package/dist/contour.esm.min.js +1 -1
- package/dist/contour.html-data.json +10311 -0
- package/dist/contour.js +7 -0
- package/dist/contour.min.css +1 -1
- package/dist/contour.min.js +1 -1
- package/dist/contour.react.d.ts +420 -0
- package/dist/contour.single.html +17 -0
- package/dist/contour.single.min.css +1 -0
- package/dist/contour.tokens.json +940 -902
- package/dist/contour.vue.d.ts +418 -0
- package/dist/contour.web-types.json +10703 -0
- package/dist/custom-elements.json +30708 -0
- package/dist/docs/actions.md +3 -2
- package/dist/docs/affordances.md +25 -9
- package/dist/docs/apireference.md +1 -1
- package/dist/docs/colour.md +1 -1
- package/dist/docs/componentindex.md +6 -2
- package/dist/docs/data.md +7 -2
- package/dist/docs/docs.md +9 -2
- package/dist/docs/feedback.md +1 -1
- package/dist/docs/field.md +1 -1
- package/dist/docs/forms.md +1 -1
- package/dist/docs/index.json +22 -20
- package/dist/docs/install.md +1 -1
- package/dist/docs/landing.md +1 -1
- package/dist/docs/mapengine.md +19 -2
- package/dist/docs/motion.md +1 -1
- package/dist/docs/navigation.md +1 -1
- package/dist/docs/overlays.md +1 -1
- package/dist/docs/overview.md +1 -1
- package/dist/docs/patterns.md +2 -2
- package/dist/docs/playground.md +22 -2
- package/dist/docs/principles.md +1 -1
- package/dist/docs/recipes.md +13 -8
- package/dist/docs/space.md +1 -1
- package/dist/docs/status.md +14 -2
- package/dist/docs/surfaces.md +1 -1
- package/dist/docs/theming.md +1 -1
- package/dist/docs/type.md +1 -1
- package/dist/docs/webcomponents.md +17 -3
- package/dist/registry/items/contour-core.json +2 -2
- package/dist/registry/items/contour-data.json +2 -2
- package/dist/registry/items/contour-docs.json +2 -2
- package/dist/registry/items/contour-landing.json +2 -2
- package/dist/registry/registry.json +8 -8
- package/dist/surfaces/contour-core.min.css +1 -1
- package/dist/surfaces/contour-data.min.css +1 -1
- package/dist/surfaces/contour-docs.min.css +1 -1
- package/dist/surfaces/contour-landing.min.css +1 -1
- package/dist/wc/behaviours.mjs +45 -57
- package/dist/wc/content.mjs +264 -63
- package/dist/wc/core.mjs +390 -71
- package/dist/wc/dashboard.mjs +220 -13
- package/dist/wc/data.mjs +1094 -458
- package/dist/wc/docs.mjs +105 -12
- package/dist/wc/feedback.mjs +63 -14
- package/dist/wc/forms.mjs +739 -106
- package/dist/wc/index.mjs +9 -2
- package/dist/wc/interaction.mjs +184 -28
- package/dist/wc/layout.mjs +97 -27
- package/dist/wc/map.mjs +185 -118
- package/dist/wc/misc.mjs +124 -24
- package/dist/wc/navigation.mjs +384 -114
- package/dist/wc/shadow.mjs +94 -18
- package/dist/wc/states.mjs +21 -3
- package/dist/wc/svg.mjs +104 -0
- package/dist/wc/ui.mjs +1995 -478
- package/integrations/README.md +2 -0
- package/integrations/ai/CLAUDE.md +3 -3
- package/integrations/frameworks/README.md +235 -0
- package/integrations/native/style-dictionary.config.json +1 -1
- package/integrations/tailwind/contour-theme.css +5 -6
- package/package.json +53 -24
package/dist/wc/behaviours.mjs
CHANGED
|
@@ -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)
|
|
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
|
|
177
|
-
//
|
|
178
|
-
//
|
|
179
|
-
//
|
|
180
|
-
//
|
|
181
|
-
//
|
|
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))
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|