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.
- package/README.md +80 -11
- package/dist/agent-rules.json +16 -0
- package/dist/build-manifest.json +181 -104
- 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 +6109 -1641
- package/dist/contour-wc.esm.min.js +1 -1
- package/dist/contour-wc.js +6108 -1641
- package/dist/contour-wc.min.js +1 -1
- package/dist/contour.code-snippets +4512 -0
- package/dist/contour.components.json +2597 -799
- package/dist/contour.css +5275 -4050
- 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 +23 -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 +263 -63
- package/dist/wc/core.mjs +390 -71
- package/dist/wc/dashboard.mjs +220 -13
- package/dist/wc/data.mjs +1075 -460
- package/dist/wc/docs.mjs +105 -12
- package/dist/wc/feedback.mjs +63 -14
- package/dist/wc/forms.mjs +733 -104
- package/dist/wc/index.mjs +9 -2
- package/dist/wc/interaction.mjs +182 -28
- package/dist/wc/layout.mjs +95 -25
- package/dist/wc/map.mjs +185 -118
- package/dist/wc/misc.mjs +124 -24
- package/dist/wc/navigation.mjs +384 -115
- 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 +1988 -476
- 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/docs.mjs
CHANGED
|
@@ -1,5 +1,45 @@
|
|
|
1
|
-
import { ContourBase, define, sanitizeHtml, headingTag } from './core.mjs';
|
|
1
|
+
import { ContourBase, define, onDispose, sanitizeHtml, headingTag, navKey, safeHref , warnBadJson, labelText } from './core.mjs';
|
|
2
2
|
import { loadRemote, remoteData, renderStates, renderEmpty, wireStates } from './states.mjs';
|
|
3
|
+
|
|
4
|
+
/* Route matching (CDS-075). The URL is the state for a documentation surface, so
|
|
5
|
+
the sidebar says where the reader is by marking the matching link
|
|
6
|
+
`aria-current="page"` — the shipped CSS already styles that attribute, and a
|
|
7
|
+
reader who cannot see the highlight still hears "current page".
|
|
8
|
+
|
|
9
|
+
Two ways to say where the reader is, in order:
|
|
10
|
+
1. a `current` attribute on the host, which is what a client-side router
|
|
11
|
+
sets after it navigates (a path, or a bare `#hash`);
|
|
12
|
+
2. the document's own location, which is what a static docs site has.
|
|
13
|
+
|
|
14
|
+
A bare hash also matches the last path segment, because that is the shape a
|
|
15
|
+
docs URL takes: `/docs/install` is the page `#install` points at. */
|
|
16
|
+
const routeKey = (value) => {
|
|
17
|
+
const raw = String(value == null ? "" : value).trim();
|
|
18
|
+
if (!raw) return "";
|
|
19
|
+
if (raw.startsWith("#")) return "hash:" + raw;
|
|
20
|
+
try {
|
|
21
|
+
const base = typeof location !== "undefined" ? location.href : "http://localhost/";
|
|
22
|
+
const url = new URL(raw, base);
|
|
23
|
+
return "path:" + url.pathname.replace(/\/+$/, "") + url.search;
|
|
24
|
+
} catch (e) {
|
|
25
|
+
return "raw:" + raw;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
const hereKey = (explicit) => {
|
|
30
|
+
const raw = String(explicit == null ? "" : explicit).trim();
|
|
31
|
+
if (raw) return routeKey(raw);
|
|
32
|
+
if (typeof location === "undefined") return "";
|
|
33
|
+
return "path:" + String(location.pathname || "").replace(/\/+$/, "") + (location.search || "");
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const hashMatchesHere = (hash) => {
|
|
37
|
+
if (typeof location === "undefined") return false;
|
|
38
|
+
if (location.hash && location.hash === hash) return true;
|
|
39
|
+
const segment = String(location.pathname || "").split("/").filter(Boolean).pop() || "";
|
|
40
|
+
return Boolean(segment) && hash === "#" + segment;
|
|
41
|
+
};
|
|
42
|
+
|
|
3
43
|
class ContourDocsNav extends ContourBase {
|
|
4
44
|
static get observed() { return ["items", "title", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton"]; }
|
|
5
45
|
static get properties() { return { items: { attribute: "items" }, title: { attribute: "title" }, src: { attribute: "src" } }; }
|
|
@@ -35,7 +75,7 @@ class ContourDocsNav extends ContourBase {
|
|
|
35
75
|
(g.links || g.items || []).forEach((l) => {
|
|
36
76
|
const a = document.createElement("a");
|
|
37
77
|
a.className = "c-docs-nav__link";
|
|
38
|
-
a.href = (typeof l === "string" ? "#" : (l.href || "#"));
|
|
78
|
+
a.href = safeHref(typeof l === "string" ? "#" : (l.href || "#"));
|
|
39
79
|
const label = typeof l === "string" ? l : (l.label || l);
|
|
40
80
|
if (typeof l === "object" && l !== null && l.badge) {
|
|
41
81
|
const b = document.createElement("span");
|
|
@@ -57,7 +97,7 @@ class ContourDocsNav extends ContourBase {
|
|
|
57
97
|
l.items.forEach((nl) => {
|
|
58
98
|
const na = document.createElement("a");
|
|
59
99
|
na.className = "c-docs-nav__link";
|
|
60
|
-
na.href = (typeof nl === "string" ? "#" : (nl.href || "#"));
|
|
100
|
+
na.href = safeHref(typeof nl === "string" ? "#" : (nl.href || "#"));
|
|
61
101
|
na.textContent = typeof nl === "string" ? nl : (nl.label || nl);
|
|
62
102
|
nested.appendChild(na);
|
|
63
103
|
});
|
|
@@ -70,13 +110,32 @@ class ContourDocsNav extends ContourBase {
|
|
|
70
110
|
group.appendChild(ul);
|
|
71
111
|
list.appendChild(group);
|
|
72
112
|
});
|
|
73
|
-
} catch (e) {
|
|
113
|
+
} catch (e) { warnBadJson(this, "attribute", e); }
|
|
74
114
|
} else if (!items && list) {
|
|
75
115
|
list.remove();
|
|
76
116
|
renderEmpty(this, "docs-nav");
|
|
77
117
|
} else if (!items && !list) {
|
|
78
118
|
renderEmpty(this, "docs-nav");
|
|
79
119
|
}
|
|
120
|
+
this.applyCurrent();
|
|
121
|
+
}
|
|
122
|
+
/* Mark the link the reader is on. Idempotent: it clears every other link
|
|
123
|
+
first, so a re-render or a route change cannot leave two "current" items. */
|
|
124
|
+
applyCurrent() {
|
|
125
|
+
const links = Array.from(this.querySelectorAll(".c-docs-nav__link"));
|
|
126
|
+
if (!links.length) return;
|
|
127
|
+
const explicit = this.getAttribute("current");
|
|
128
|
+
const here = hereKey(explicit);
|
|
129
|
+
links.forEach((a) => {
|
|
130
|
+
const href = a.getAttribute("href") || "";
|
|
131
|
+
const key = routeKey(href);
|
|
132
|
+
const hit = Boolean(here) && (
|
|
133
|
+
(key && key === here) ||
|
|
134
|
+
(href.startsWith("#") && !explicit && hashMatchesHere(href))
|
|
135
|
+
);
|
|
136
|
+
if (hit) a.setAttribute("aria-current", "page");
|
|
137
|
+
else a.removeAttribute("aria-current");
|
|
138
|
+
});
|
|
80
139
|
}
|
|
81
140
|
enhance() {
|
|
82
141
|
if (this._wiredDocsNav) return;
|
|
@@ -88,6 +147,25 @@ class ContourDocsNav extends ContourBase {
|
|
|
88
147
|
this.dispatchEvent(new CustomEvent("contour:docs-nav-select", { bubbles: true, composed: true, detail: { label, href: link.getAttribute("href") } }));
|
|
89
148
|
}
|
|
90
149
|
});
|
|
150
|
+
// Keyboard: roving tabindex over docs-nav links, Enter follows the link.
|
|
151
|
+
this.addEventListener("keydown", (e) => {
|
|
152
|
+
const links = Array.from(this.querySelectorAll(".c-docs-nav__link"));
|
|
153
|
+
if (!links.length) return;
|
|
154
|
+
if (!links.some((l) => l.tabIndex === 0)) links.forEach((l, i) => l.tabIndex = i === 0 ? 0 : -1);
|
|
155
|
+
navKey(e, links, { wrap: true, homeEnd: true, onNavigate: (i) => { links.forEach((l, j) => l.tabIndex = j === i ? 0 : -1); }, onKey: (k) => { if (k === "Enter") { const a = document.activeElement; if (a) { e.preventDefault(); a.click(); } } } });
|
|
156
|
+
});
|
|
157
|
+
// A static docs site navigates by changing the URL, so the highlight has to
|
|
158
|
+
// follow the URL rather than the click. A host that passes `current` owns
|
|
159
|
+
// the state and this listener is a no-op next to it.
|
|
160
|
+
if (typeof window !== "undefined" && window.addEventListener) {
|
|
161
|
+
const sync = () => this.applyCurrent();
|
|
162
|
+
window.addEventListener("hashchange", sync);
|
|
163
|
+
window.addEventListener("popstate", sync);
|
|
164
|
+
onDispose(this, () => {
|
|
165
|
+
window.removeEventListener("hashchange", sync);
|
|
166
|
+
window.removeEventListener("popstate", sync);
|
|
167
|
+
});
|
|
168
|
+
}
|
|
91
169
|
}
|
|
92
170
|
}
|
|
93
171
|
define("contour-docs-nav", ContourDocsNav);
|
|
@@ -99,7 +177,7 @@ class ContourDocsShell extends ContourBase {
|
|
|
99
177
|
this.setAttribute("role", "region");
|
|
100
178
|
const title = this.getAttribute("title");
|
|
101
179
|
if (title) {
|
|
102
|
-
const h = this.ensure(".c-docs-shell__title", () => { const el = document.createElement(headingTag(this, "
|
|
180
|
+
const h = this.ensure(".c-docs-shell__title", () => { const el = document.createElement(headingTag(this, "h2")); el.className = "c-docs-shell__title"; return el; });
|
|
103
181
|
h.textContent = title;
|
|
104
182
|
this.setAttribute("aria-label", title);
|
|
105
183
|
} else {
|
|
@@ -152,7 +230,7 @@ class ContourFileTree extends ContourBase {
|
|
|
152
230
|
// clear generated
|
|
153
231
|
Array.from(this.querySelectorAll(".c-file-tree__row")).forEach((n) => n.remove());
|
|
154
232
|
parsed.forEach((n) => renderNode(n, 0));
|
|
155
|
-
} catch (e) {
|
|
233
|
+
} catch (e) { warnBadJson(this, "attribute", e); }
|
|
156
234
|
}
|
|
157
235
|
}
|
|
158
236
|
}
|
|
@@ -167,14 +245,20 @@ class ContourChangelog extends ContourBase {
|
|
|
167
245
|
if (src) {
|
|
168
246
|
if (this.dataset.loaded === src) return;
|
|
169
247
|
this.dataset.loaded = "";
|
|
170
|
-
const loading = this.ensure(".c-changelog__loading", () => { const el = document.createElement("div"); el.className = "c-changelog__loading";
|
|
248
|
+
const loading = this.ensure(".c-changelog__loading", () => { const el = document.createElement("div"); el.className = "c-changelog__loading"; return el; });
|
|
249
|
+
loading.textContent = labelText(this, "loading", "Loading…");
|
|
171
250
|
// clear
|
|
172
251
|
Array.from(this.querySelectorAll(".c-changelog__entry, .c-changelog__error")).forEach((n) => n.remove());
|
|
173
252
|
if (!this.querySelector(".c-changelog__loading")) this.appendChild(loading);
|
|
174
|
-
fetch
|
|
253
|
+
// Abort the in-flight fetch when the host leaves the page, so a slow
|
|
254
|
+
// changelog cannot write into a detached element.
|
|
255
|
+
try { if (this._changelogAbort) this._changelogAbort.abort(); } catch (e) {}
|
|
256
|
+
this._changelogAbort = typeof AbortController !== "undefined" ? new AbortController() : null;
|
|
257
|
+
fetch(src, this._changelogAbort ? { signal: this._changelogAbort.signal } : undefined).then((r) => {
|
|
175
258
|
if (!r.ok) throw new Error("HTTP " + r.status);
|
|
176
259
|
return r.text();
|
|
177
260
|
}).then((text) => {
|
|
261
|
+
if (!this.isConnected) return;
|
|
178
262
|
const ld = this.querySelector(".c-changelog__loading");
|
|
179
263
|
if (ld) ld.remove();
|
|
180
264
|
this.dataset.loaded = src;
|
|
@@ -184,7 +268,7 @@ class ContourChangelog extends ContourBase {
|
|
|
184
268
|
if (!list.length) {
|
|
185
269
|
const empty = document.createElement("div");
|
|
186
270
|
empty.className = "c-changelog__empty";
|
|
187
|
-
empty.textContent = "No releases found.";
|
|
271
|
+
empty.textContent = labelText(this, "empty", "No releases found.");
|
|
188
272
|
this.appendChild(empty);
|
|
189
273
|
return;
|
|
190
274
|
}
|
|
@@ -211,15 +295,21 @@ class ContourChangelog extends ContourBase {
|
|
|
211
295
|
this.appendChild(det);
|
|
212
296
|
});
|
|
213
297
|
}).catch((err) => {
|
|
298
|
+
if (!this.isConnected) return;
|
|
214
299
|
const ld = this.querySelector(".c-changelog__loading");
|
|
215
300
|
if (ld) ld.remove();
|
|
216
301
|
const er = document.createElement("div");
|
|
217
302
|
er.className = "c-changelog__error";
|
|
218
|
-
er.textContent = "Failed to load changelog: " + (err && err.message ? err.message : err);
|
|
303
|
+
er.textContent = labelText(this, "load-error", "Failed to load changelog") + ": " + (err && err.message ? err.message : err);
|
|
219
304
|
this.appendChild(er);
|
|
220
305
|
});
|
|
221
306
|
}
|
|
222
307
|
}
|
|
308
|
+
disconnectedCallback() {
|
|
309
|
+
super.disconnectedCallback();
|
|
310
|
+
try { if (this._changelogAbort) this._changelogAbort.abort(); } catch (e) {}
|
|
311
|
+
this._changelogAbort = null;
|
|
312
|
+
}
|
|
223
313
|
}
|
|
224
314
|
define("contour-changelog", ContourChangelog);
|
|
225
315
|
|
|
@@ -257,10 +347,13 @@ class ContourChangelog extends ContourBase {
|
|
|
257
347
|
const line = raw.trimEnd();
|
|
258
348
|
if (/^###\s+/.test(line)) {
|
|
259
349
|
if (inList) { out.push("</ul>"); inList = false; }
|
|
260
|
-
out.push("<
|
|
350
|
+
out.push("<h3>" + escapeHtml(line.replace(/^###\s+/, "")) + "</h3>");
|
|
261
351
|
} else if (/^##\s+/.test(line)) {
|
|
262
352
|
if (inList) { out.push("</ul>"); inList = false; }
|
|
263
|
-
out.push("<
|
|
353
|
+
out.push("<h2>" + escapeHtml(line.replace(/^##\s+/, "")) + "</h2>");
|
|
354
|
+
} else if (/^#\s+/.test(line)) {
|
|
355
|
+
if (inList) { out.push("</ul>"); inList = false; }
|
|
356
|
+
out.push("<h2>" + escapeHtml(line.replace(/^#\s+/, "")) + "</h2>");
|
|
264
357
|
} else if (/^[-*]\s+/.test(line)) {
|
|
265
358
|
if (!inList) { out.push("<ul>"); inList = true; }
|
|
266
359
|
out.push("<li>" + escapeHtml(line.replace(/^[-*]\s+/, "")) + "</li>");
|
package/dist/wc/feedback.mjs
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
|
-
import { ContourBase, define, onDispose, sanitizeHtml, headingTag } from './core.mjs';
|
|
1
|
+
import { ContourBase, define, onDispose, sanitizeHtml, headingTag , warnBadJson, contourId } from './core.mjs';
|
|
2
2
|
import { loadRemote, remoteData, renderStates, renderEmpty, wireStates } from './states.mjs';
|
|
3
3
|
import { wireRemovable, modalContain } from './behaviours.mjs';
|
|
4
4
|
class ContourDialog extends ContourBase {
|
|
5
5
|
static get observed() { return ["title", "size", "heading"]; }
|
|
6
6
|
static get properties() { return { title: { attribute: "title" }, size: { attribute: "size" } }; }
|
|
7
|
+
// Native-dialog parity (R20 T-32): show() is already the modal path (it
|
|
8
|
+
// locks the document and inerts the background), so showModal() is its
|
|
9
|
+
// native-named alias, and the open property routes through show()/close()
|
|
10
|
+
// so events, focus and containment run on every transition. returnValue
|
|
11
|
+
// persists after close, like the platform's.
|
|
12
|
+
showModal() { this.show(); }
|
|
13
|
+
get open() { return this.hasAttribute("open"); }
|
|
14
|
+
set open(v) { if (v) this.show(); else this.close(); }
|
|
7
15
|
render() {
|
|
8
16
|
this.classList.add("c-dialog");
|
|
9
17
|
Array.from(this.classList).forEach((c) => { if (c.startsWith("c-dialog--")) this.classList.remove(c); });
|
|
@@ -23,11 +31,11 @@ class ContourDialog extends ContourBase {
|
|
|
23
31
|
closeBtn.className = "c-btn c-btn--icon c-btn--ghost c-dialog__close";
|
|
24
32
|
closeBtn.setAttribute("type", "button");
|
|
25
33
|
closeBtn.setAttribute("aria-label", "Close");
|
|
26
|
-
closeBtn.innerHTML = '<svg aria-hidden="true"><use href="#i-
|
|
34
|
+
closeBtn.innerHTML = '<svg aria-hidden="true"><use href="#i-x" /></svg>';
|
|
27
35
|
head.appendChild(closeBtn);
|
|
28
36
|
}
|
|
29
37
|
const h = head.querySelector(".c-dialog__title");
|
|
30
|
-
if (h) { h.textContent = title; if (!h.id) h.id = "contour-dialog-title
|
|
38
|
+
if (h) { h.textContent = title; if (!h.id) h.id = contourId("contour-dialog-title"); this.setAttribute("aria-labelledby", h.id); }
|
|
31
39
|
}
|
|
32
40
|
if (head && head.parentNode !== this) this.prepend(head);
|
|
33
41
|
// Wrap authored content in a body so it picks up the dialog's padding.
|
|
@@ -47,6 +55,7 @@ class ContourDialog extends ContourBase {
|
|
|
47
55
|
enhance() {
|
|
48
56
|
if (this._wiredDialog) return;
|
|
49
57
|
this._wiredDialog = true;
|
|
58
|
+
this.returnValue = "";
|
|
50
59
|
onDispose(this, () => { if (this.hasAttribute("open")) modalContain(this, false); });
|
|
51
60
|
// The open state is carried by the `open` attribute so CSS can target it
|
|
52
61
|
// and a caller can read host.open; it is written here and never observed,
|
|
@@ -107,11 +116,25 @@ class ContourAlert extends ContourBase {
|
|
|
107
116
|
}
|
|
108
117
|
render() {
|
|
109
118
|
this.classList.add("c-alert");
|
|
110
|
-
// ARIA:
|
|
111
|
-
//
|
|
112
|
-
//
|
|
113
|
-
|
|
114
|
-
|
|
119
|
+
// ARIA: the variant decides how loudly the message speaks. Warning and
|
|
120
|
+
// danger interrupt (role=alert / assertive); info, success and accent are
|
|
121
|
+
// announced politely (role=status / polite), because a static information
|
|
122
|
+
// alert that asserts itself on load talks over whatever the reader was
|
|
123
|
+
// already doing. The shadow layer carries the same rule.
|
|
124
|
+
const urgent = /^(warning|danger)$/.test(this.getAttribute("variant") || "");
|
|
125
|
+
const role = urgent ? "alert" : "status";
|
|
126
|
+
const live = urgent ? "assertive" : "polite";
|
|
127
|
+
// Written on the host so the loader's state nodes announce inside the
|
|
128
|
+
// region. Remember what this component wrote: an authored role/aria-live
|
|
129
|
+
// wins, and a variant change updates only a value the component itself set.
|
|
130
|
+
if (!this.hasAttribute("role") || this.getAttribute("role") === this._autoRole) {
|
|
131
|
+
this.setAttribute("role", role);
|
|
132
|
+
this._autoRole = role;
|
|
133
|
+
}
|
|
134
|
+
if (!this.hasAttribute("aria-live") || this.getAttribute("aria-live") === this._autoLive) {
|
|
135
|
+
this.setAttribute("aria-live", live);
|
|
136
|
+
this._autoLive = live;
|
|
137
|
+
}
|
|
115
138
|
wireStates(this);
|
|
116
139
|
loadRemote(this, "title");
|
|
117
140
|
if (renderStates(this, "alert")) return;
|
|
@@ -288,6 +311,8 @@ class ContourCallout extends ContourBase {
|
|
|
288
311
|
static get properties() { return { variant: { attribute: "variant" }, title: { attribute: "title" }, icon: { attribute: "icon" }, closable: { attribute: "closable", type: Boolean } }; }
|
|
289
312
|
render() {
|
|
290
313
|
this.classList.add("c-callout");
|
|
314
|
+
if (!this.hasAttribute("role")) this.setAttribute("role", "note");
|
|
315
|
+
if (!this.hasAttribute("aria-label")) this.setAttribute("aria-label", this.getAttribute("title") || "Callout");
|
|
291
316
|
Array.from(this.classList).forEach((c) => { if (c.startsWith("c-callout--")) this.classList.remove(c); });
|
|
292
317
|
const variant = this.getAttribute("variant");
|
|
293
318
|
if (variant) this.classList.add("c-callout--" + variant);
|
|
@@ -440,7 +465,7 @@ class ContourFaq extends ContourBase {
|
|
|
440
465
|
item.appendChild(a);
|
|
441
466
|
this.appendChild(item);
|
|
442
467
|
});
|
|
443
|
-
} catch (e) {
|
|
468
|
+
} catch (e) { warnBadJson(this, "attribute", e); }
|
|
444
469
|
} else if (!items) {
|
|
445
470
|
if (!question && !answer) {
|
|
446
471
|
renderEmpty(this, "faq");
|
|
@@ -466,6 +491,8 @@ class ContourAccordion extends ContourBase {
|
|
|
466
491
|
// The host is a plain container; the children carry .c-disclosure, which
|
|
467
492
|
// is the block that owns the styling. No .c-accordion rule exists, so the
|
|
468
493
|
// host class is dropped rather than invented.
|
|
494
|
+
if (!this.hasAttribute("role")) this.setAttribute("role", "region");
|
|
495
|
+
if (!this.hasAttribute("aria-label")) this.setAttribute("aria-label", "Accordion");
|
|
469
496
|
const authored = Array.from(this.children).filter((n) => n.tagName === "DETAILS");
|
|
470
497
|
wireStates(this);
|
|
471
498
|
loadRemote(this, "items");
|
|
@@ -488,7 +515,7 @@ class ContourAccordion extends ContourBase {
|
|
|
488
515
|
details.appendChild(body);
|
|
489
516
|
this.appendChild(details);
|
|
490
517
|
});
|
|
491
|
-
} catch (e) {
|
|
518
|
+
} catch (e) { warnBadJson(this, "attribute", e); }
|
|
492
519
|
} else if (!items && !authored.length) {
|
|
493
520
|
renderEmpty(this, "accordion");
|
|
494
521
|
}
|
|
@@ -549,6 +576,10 @@ define("contour-accordion", ContourAccordion);
|
|
|
549
576
|
class ContourDrawer extends ContourBase {
|
|
550
577
|
static get observed() { return ["title", "body", "size"]; }
|
|
551
578
|
static get properties() { return { title: { attribute: "title" }, body: { attribute: "body" }, size: { attribute: "size" } }; }
|
|
579
|
+
// Native-dialog parity (R20 T-32), same contract as contour-dialog.
|
|
580
|
+
showModal() { this.show(); }
|
|
581
|
+
get open() { return this.hasAttribute("open"); }
|
|
582
|
+
set open(v) { if (v) this.show(); else this.close(); }
|
|
552
583
|
render() {
|
|
553
584
|
this.classList.add("c-drawer");
|
|
554
585
|
Array.from(this.classList).forEach((c) => { if (c.startsWith("c-drawer--")) this.classList.remove(c); });
|
|
@@ -568,7 +599,7 @@ class ContourDrawer extends ContourBase {
|
|
|
568
599
|
closeBtn.className = "c-btn c-btn--icon c-btn--ghost c-drawer__close";
|
|
569
600
|
closeBtn.setAttribute("type", "button");
|
|
570
601
|
closeBtn.setAttribute("aria-label", "Close");
|
|
571
|
-
closeBtn.innerHTML = '<svg aria-hidden="true"><use href="#i-
|
|
602
|
+
closeBtn.innerHTML = '<svg aria-hidden="true"><use href="#i-x" /></svg>';
|
|
572
603
|
head.appendChild(closeBtn);
|
|
573
604
|
}
|
|
574
605
|
const t = head.querySelector(".c-drawer__title");
|
|
@@ -595,6 +626,7 @@ class ContourDrawer extends ContourBase {
|
|
|
595
626
|
enhance() {
|
|
596
627
|
if (this._wiredDrawer) return;
|
|
597
628
|
this._wiredDrawer = true;
|
|
629
|
+
this.returnValue = "";
|
|
598
630
|
onDispose(this, () => { if (this.hasAttribute("open")) modalContain(this, false); });
|
|
599
631
|
this._drawerLastFocus = null;
|
|
600
632
|
this.show = () => {
|
|
@@ -647,6 +679,10 @@ class ContourDrawer extends ContourBase {
|
|
|
647
679
|
class ContourSheet extends ContourBase {
|
|
648
680
|
static get observed() { return ["title", "body", "size"]; }
|
|
649
681
|
static get properties() { return { title: { attribute: "title" }, body: { attribute: "body" }, size: { attribute: "size" } }; }
|
|
682
|
+
// Native-dialog parity (R20 T-32), same contract as contour-dialog.
|
|
683
|
+
showModal() { this.show(); }
|
|
684
|
+
get open() { return this.hasAttribute("open"); }
|
|
685
|
+
set open(v) { if (v) this.show(); else this.close(); }
|
|
650
686
|
render() {
|
|
651
687
|
this.classList.add("c-sheet");
|
|
652
688
|
Array.from(this.classList).forEach((c) => { if (c.startsWith("c-sheet--")) this.classList.remove(c); });
|
|
@@ -666,7 +702,7 @@ class ContourSheet extends ContourBase {
|
|
|
666
702
|
closeBtn.className = "c-btn c-btn--icon c-btn--ghost c-sheet__close";
|
|
667
703
|
closeBtn.setAttribute("type", "button");
|
|
668
704
|
closeBtn.setAttribute("aria-label", "Close");
|
|
669
|
-
closeBtn.innerHTML = '<svg aria-hidden="true"><use href="#i-
|
|
705
|
+
closeBtn.innerHTML = '<svg aria-hidden="true"><use href="#i-x" /></svg>';
|
|
670
706
|
head.appendChild(closeBtn);
|
|
671
707
|
}
|
|
672
708
|
const t = head.querySelector(".c-sheet__title");
|
|
@@ -692,6 +728,7 @@ class ContourSheet extends ContourBase {
|
|
|
692
728
|
enhance() {
|
|
693
729
|
if (this._wiredSheet) return;
|
|
694
730
|
this._wiredSheet = true;
|
|
731
|
+
this.returnValue = "";
|
|
695
732
|
onDispose(this, () => { if (this.hasAttribute("open")) modalContain(this, false); });
|
|
696
733
|
this._sheetLastFocus = null;
|
|
697
734
|
this.show = () => {
|
|
@@ -742,8 +779,8 @@ class ContourSheet extends ContourBase {
|
|
|
742
779
|
}
|
|
743
780
|
define("contour-sheet", ContourSheet);
|
|
744
781
|
class ContourToast extends ContourBase {
|
|
745
|
-
static get observed() { return ["message", "variant", "duration"]; }
|
|
746
|
-
static get properties() { return { message: { attribute: "message" }, variant: { attribute: "variant" }, duration: { attribute: "duration", type: Number } }; }
|
|
782
|
+
static get observed() { return ["message", "variant", "duration", "action"]; }
|
|
783
|
+
static get properties() { return { message: { attribute: "message" }, variant: { attribute: "variant" }, duration: { attribute: "duration", type: Number }, action: { attribute: "action" } }; }
|
|
747
784
|
render() {
|
|
748
785
|
this.classList.add("c-toast");
|
|
749
786
|
if (!this.hasAttribute("role")) this.setAttribute("role", "status");
|
|
@@ -756,6 +793,15 @@ class ContourToast extends ContourBase {
|
|
|
756
793
|
const variant = this.getAttribute("variant");
|
|
757
794
|
Array.from(this.classList).forEach((c) => { if (c.startsWith("c-toast--")) this.classList.remove(c); });
|
|
758
795
|
if (variant) this.classList.add("c-toast--" + variant);
|
|
796
|
+
// Action button (e.g. "Undo"): scaffold from `action` attribute.
|
|
797
|
+
const action = this.getAttribute("action");
|
|
798
|
+
let btn = this.querySelector(".c-toast__action");
|
|
799
|
+
if (action) {
|
|
800
|
+
if (!btn) { btn = document.createElement("button"); btn.className = "c-toast__action"; btn.type = "button"; this.appendChild(btn); }
|
|
801
|
+
btn.textContent = action;
|
|
802
|
+
} else if (btn) {
|
|
803
|
+
btn.remove();
|
|
804
|
+
}
|
|
759
805
|
}
|
|
760
806
|
enhance() {
|
|
761
807
|
if (this._wiredToast) return;
|
|
@@ -792,6 +838,8 @@ class ContourExpandable extends ContourBase {
|
|
|
792
838
|
}
|
|
793
839
|
render() {
|
|
794
840
|
this.classList.add("c-expandable");
|
|
841
|
+
if (!this.hasAttribute("role")) this.setAttribute("role", "region");
|
|
842
|
+
if (!this.hasAttribute("aria-label")) this.setAttribute("aria-label", this.getAttribute("summary") || "Expandable");
|
|
795
843
|
const summary = this.getAttribute("summary");
|
|
796
844
|
if (summary) {
|
|
797
845
|
let captured = this.innerHTML.trim() ? this.innerHTML : (this._expandableContent || "");
|
|
@@ -835,6 +883,7 @@ class ContourToastHost extends ContourBase {
|
|
|
835
883
|
render() {
|
|
836
884
|
this.classList.add("c-toast-host");
|
|
837
885
|
if (!this.hasAttribute("role")) this.setAttribute("role", "status");
|
|
886
|
+
if (!this.hasAttribute("aria-label")) this.setAttribute("aria-label", "Toast host");
|
|
838
887
|
if (!this.hasAttribute("aria-live")) this.setAttribute("aria-live", "polite");
|
|
839
888
|
if (!this.hasAttribute("aria-atomic")) this.setAttribute("aria-atomic", "true");
|
|
840
889
|
}
|