contour-ds 1.7.2 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +244 -326
- package/dist/agent-cookbook.json +960 -0
- package/dist/agent-examples.json +65 -0
- package/dist/agent-map-wiring.json +152 -0
- package/dist/agent-rules.json +16 -0
- package/dist/build-manifest.json +344 -126
- package/dist/contour-wc-content.esm.js +1939 -0
- package/dist/contour-wc-content.esm.min.js +1 -0
- package/dist/contour-wc-core.esm.js +3724 -0
- package/dist/contour-wc-core.esm.min.js +1 -0
- package/dist/contour-wc-dashboard.esm.js +6986 -0
- package/dist/contour-wc-dashboard.esm.min.js +1 -0
- package/dist/contour-wc-data.esm.js +6572 -0
- package/dist/contour-wc-data.esm.min.js +1 -0
- package/dist/contour-wc-docs.esm.js +976 -0
- package/dist/contour-wc-docs.esm.min.js +1 -0
- package/dist/contour-wc-feedback.esm.js +1742 -0
- package/dist/contour-wc-feedback.esm.min.js +1 -0
- package/dist/contour-wc-forms.esm.js +2437 -0
- package/dist/contour-wc-forms.esm.min.js +1 -0
- package/dist/contour-wc-interaction.esm.js +1343 -0
- package/dist/contour-wc-interaction.esm.min.js +1 -0
- package/dist/contour-wc-layout.esm.js +845 -0
- package/dist/contour-wc-layout.esm.min.js +1 -0
- package/dist/contour-wc-map.esm.js +2411 -0
- package/dist/contour-wc-map.esm.min.js +1 -0
- package/dist/contour-wc-misc.esm.js +945 -0
- package/dist/contour-wc-misc.esm.min.js +1 -0
- package/dist/contour-wc-navigation.esm.js +2842 -0
- package/dist/contour-wc-navigation.esm.min.js +1 -0
- package/dist/contour-wc-ui.esm.js +6519 -0
- package/dist/contour-wc-ui.esm.min.js +1 -0
- package/dist/contour-wc.esm.js +14435 -5723
- package/dist/contour-wc.esm.min.js +1 -1
- package/dist/contour-wc.js +14436 -5725
- package/dist/contour-wc.min.js +1 -1
- package/dist/contour.a11y.json +402 -0
- package/dist/contour.code-snippets +4534 -0
- package/dist/contour.components.json +4870 -1222
- package/dist/contour.css +6672 -4711
- package/dist/contour.d.ts +753 -1085
- package/dist/contour.esm.js +440 -18
- package/dist/contour.esm.min.js +1 -1
- package/dist/contour.html-data.json +11343 -0
- package/dist/contour.js +440 -18
- package/dist/contour.min.css +1 -1
- package/dist/contour.min.js +1 -1
- package/dist/contour.react.d.ts +422 -0
- package/dist/contour.single.html +17 -0
- package/dist/contour.single.min.css +1 -0
- package/dist/contour.themes.json +56 -12
- package/dist/contour.tokens.json +1318 -1053
- package/dist/contour.vue.d.ts +420 -0
- package/dist/contour.web-types.json +11703 -0
- package/dist/custom-elements.json +36120 -0
- package/dist/docs/actions.md +16 -6
- package/dist/docs/affordances.md +21 -85
- package/dist/docs/apireference.md +9 -5
- package/dist/docs/colour.md +10 -4
- package/dist/docs/componentindex.md +9 -22
- package/dist/docs/data.md +39 -58
- package/dist/docs/docs.md +12 -7
- package/dist/docs/feedback.md +30 -12
- package/dist/docs/field.md +28 -13
- package/dist/docs/forms.md +35 -19
- package/dist/docs/index.json +70 -61
- package/dist/docs/install.md +12 -7
- package/dist/docs/landing.md +7 -4
- package/dist/docs/mapengine.md +30 -8
- package/dist/docs/motion.md +12 -6
- package/dist/docs/navigation.md +31 -7
- package/dist/docs/overlays.md +32 -25
- package/dist/docs/overview.md +3 -2
- package/dist/docs/patterns.md +20 -10
- package/dist/docs/playground.md +11 -4
- package/dist/docs/principles.md +8 -6
- package/dist/docs/recipes.md +117 -13
- package/dist/docs/space.md +10 -6
- package/dist/docs/status.md +13 -14
- package/dist/docs/surfaces.md +17 -22
- package/dist/docs/theming.md +18 -32
- package/dist/docs/type.md +12 -5
- package/dist/docs/webcomponents.md +75 -33
- package/dist/hljs.css +1 -20
- package/dist/map-chrome.mapbox.css +68 -92
- package/dist/map-chrome.maplibre.css +68 -92
- 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/svg/icons.svg +367 -0
- package/dist/wc/behaviours.mjs +222 -192
- package/dist/wc/content.mjs +486 -142
- package/dist/wc/core.mjs +917 -395
- package/dist/wc/dashboard.mjs +252 -25
- package/dist/wc/data-chart.mjs +1333 -0
- package/dist/wc/data-export.mjs +391 -0
- package/dist/wc/data-gauge.mjs +779 -0
- package/dist/wc/data-geo.mjs +696 -0
- package/dist/wc/data-glyphs.mjs +133 -0
- package/dist/wc/data-legend.mjs +431 -0
- package/dist/wc/data-readout.mjs +227 -0
- package/dist/wc/data-series.mjs +1004 -0
- package/dist/wc/data-table.mjs +751 -0
- package/dist/wc/data.mjs +15 -3707
- package/dist/wc/docs.mjs +113 -19
- package/dist/wc/feedback.mjs +320 -116
- package/dist/wc/forms-controls.mjs +635 -0
- package/dist/wc/forms-field.mjs +547 -0
- package/dist/wc/forms-groups.mjs +347 -0
- package/dist/wc/forms-input.mjs +292 -0
- package/dist/wc/forms.mjs +10 -1122
- package/dist/wc/glyph.mjs +204 -0
- package/dist/wc/index.mjs +16 -7
- package/dist/wc/interaction.mjs +322 -75
- package/dist/wc/layout.mjs +100 -29
- package/dist/wc/map.mjs +888 -285
- package/dist/wc/misc.mjs +137 -26
- package/dist/wc/navigation-menu.mjs +735 -0
- package/dist/wc/navigation-shell.mjs +495 -0
- package/dist/wc/navigation-tree.mjs +995 -0
- package/dist/wc/navigation.mjs +9 -1636
- package/dist/wc/registration.mjs +1 -8
- package/dist/wc/shadow.mjs +285 -113
- package/dist/wc/states.mjs +75 -78
- package/dist/wc/svg.mjs +209 -34
- package/dist/wc/ui-atoms.mjs +608 -0
- package/dist/wc/ui-data.mjs +1404 -0
- package/dist/wc/ui-feedback.mjs +419 -0
- package/dist/wc/ui-inputs.mjs +1570 -0
- package/dist/wc/ui-menus.mjs +307 -0
- package/dist/wc/ui-overlays.mjs +1605 -0
- package/integrations/README.md +25 -5
- package/integrations/ai/CLAUDE.md +6 -3
- package/integrations/ai/COPILOT.md +14 -0
- package/integrations/ai/GEMINI.md +14 -0
- package/integrations/ai/WINDSURF.md +14 -0
- package/integrations/ai/v0-prompt.md +13 -1
- package/integrations/frameworks/README.md +235 -0
- package/integrations/native/README.md +0 -3
- package/integrations/native/style-dictionary.config.json +1 -1
- package/integrations/tailwind/contour-theme.css +71 -13
- package/integrations/validate-markup.mjs +172 -0
- package/package.json +103 -39
- package/dist/wc/ui.mjs +0 -3560
package/dist/wc/registration.mjs
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
import { define, simple } from './core.mjs';
|
|
2
|
-
// ---- Registration:
|
|
3
|
-
//
|
|
4
|
-
// Order is the contract. Every complex component above claims its own name and
|
|
5
|
-
// define() skips a name already claimed -- which is why
|
|
6
|
-
// <contour-menu items='["Cut"]'> builds a <ul> instead of only gaining a class.
|
|
7
|
-
// Move this loop back above the complex components and the scaffolding half of
|
|
8
|
-
// this file becomes dead code again: it did, and no gate noticed.
|
|
9
|
-
// Explicit defines (not a loop) so the coverage gate and tooling can see them.
|
|
2
|
+
// ---- Registration: class-only wrappers run last (define() skips claimed names) ----
|
|
10
3
|
define("contour-box", simple(["c-box"]));
|
|
11
4
|
define("contour-cluster", simple(["c-cluster"]));
|
|
12
5
|
define("contour-container", simple(["c-container"]));
|
package/dist/wc/shadow.mjs
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import { define, MODS,
|
|
1
|
+
import { setHTML, define, MODS, contourId, labelText } from './core.mjs';
|
|
2
2
|
import { wireTabs, wireSegmented, wireCombobox, wireTree, wireMenu, wirePagination, wireCopy, wireRemovable, wcReset } from './behaviours.mjs';
|
|
3
|
+
// R31-19: the text a shadow <label> shows through its <slot>, read from the
|
|
4
|
+
// light-tree assigned nodes (the shadow label's own textContent is empty).
|
|
5
|
+
const assignedText = (label) => {
|
|
6
|
+
const slot = label.querySelector("slot");
|
|
7
|
+
const nodes = slot ? slot.assignedElements({ flatten: true }) : [];
|
|
8
|
+
const text = nodes.map((n) => (n.textContent || "").trim()).join(" ").trim();
|
|
9
|
+
return text || (label.textContent || "").trim();
|
|
10
|
+
};
|
|
3
11
|
// ---- Shadow DOM wrappers (opt-in) ------------------------------------
|
|
4
|
-
//
|
|
5
|
-
// Every block below already ships a light-DOM element; a shadow wrapper is not
|
|
6
|
-
// extra capability, it is the same block handed to a consumer who wants an
|
|
7
|
-
// isolated root and named parts to style through ::part(). So the two tables
|
|
8
|
-
// name the same blocks and must stay in step with each other, which is what
|
|
9
|
-
// the contract gate checks.
|
|
10
|
-
//
|
|
11
|
-
// A CSSStyleSheet is adoptable by any number of roots, so the document's
|
|
12
|
-
// same-origin sheets are serialised and parsed ONCE and shared. Rebuilding
|
|
13
|
-
// them per instance re-parsed the whole 190 kB sheet for every element a page
|
|
14
|
-
// mounted. The cache is keyed on the sheet list, so a stylesheet linked after
|
|
15
|
-
// load is still picked up by the next element.
|
|
16
|
-
//
|
|
17
|
-
// The key counts what each sheet holds, not just how many sheets there are and
|
|
18
|
-
// what they are called: an inline <style> replaced by another inline <style>
|
|
19
|
-
// leaves both unchanged, and a cache keyed on identity alone would hand the
|
|
20
|
-
// next instance a parse of the sheet that is no longer on the page.
|
|
21
12
|
let ADOPTED = null;
|
|
22
13
|
let ADOPTED_KEY = "";
|
|
23
|
-
const
|
|
14
|
+
const _hashCss = (str) => {
|
|
15
|
+
let h = 2166136261;
|
|
16
|
+
for (let i = 0; i < str.length; i++) {
|
|
17
|
+
h ^= str.charCodeAt(i);
|
|
18
|
+
h = Math.imul(h, 16777619);
|
|
19
|
+
}
|
|
20
|
+
return (h >>> 0).toString(36);
|
|
21
|
+
};
|
|
22
|
+
export const adoptedSheets = () => {
|
|
24
23
|
let key = document.styleSheets.length + ":";
|
|
25
24
|
for (const sheet of document.styleSheets) {
|
|
26
|
-
let
|
|
27
|
-
try {
|
|
28
|
-
|
|
25
|
+
let sig = "-1";
|
|
26
|
+
try {
|
|
27
|
+
const rules = sheet.cssRules;
|
|
28
|
+
let text = "";
|
|
29
|
+
for (let i = 0; i < rules.length; i++) text += rules[i].cssText + "\n";
|
|
30
|
+
sig = rules.length + ":" + _hashCss(text);
|
|
31
|
+
} catch (e) { /* cross-origin: unreadable */ }
|
|
32
|
+
key += (sheet.href || "inline") + "~" + sig + "|";
|
|
29
33
|
}
|
|
30
34
|
if (ADOPTED && key === ADOPTED_KEY) return ADOPTED;
|
|
31
35
|
ADOPTED_KEY = key;
|
|
32
36
|
ADOPTED = [];
|
|
33
37
|
// Collect every rule a sheet carries, descending into @imported sheets,
|
|
34
|
-
// because adoptedStyleSheets cannot hold @import rules (the platform
|
|
35
|
-
// rejects them) and the imported sheets are not separate top-level entries
|
|
36
|
-
// in document.styleSheets. Skipping them would hand the shadow root an
|
|
37
|
-
// empty sheet.
|
|
38
38
|
const collect = (sheet, out) => {
|
|
39
39
|
let rules;
|
|
40
40
|
try { rules = sheet.cssRules; } catch (e) { return; }
|
|
@@ -49,7 +49,8 @@ import { define, MODS, REGISTERED, CONTOUR_EVENTS, contourId } from './core.mjs'
|
|
|
49
49
|
};
|
|
50
50
|
for (const sheet of document.styleSheets) {
|
|
51
51
|
try {
|
|
52
|
-
|
|
52
|
+
// Include same-origin linked sheets AND same-origin inline <style> sheets (!sheet.href).
|
|
53
|
+
if (!sheet.href || new URL(sheet.href).origin === location.origin) {
|
|
53
54
|
const collected = [];
|
|
54
55
|
collect(sheet, collected);
|
|
55
56
|
const built = new CSSStyleSheet();
|
|
@@ -62,34 +63,34 @@ import { define, MODS, REGISTERED, CONTOUR_EVENTS, contourId } from './core.mjs'
|
|
|
62
63
|
};
|
|
63
64
|
|
|
64
65
|
// One base for every wrapper: adopt the sheets, clone the subclass template,
|
|
65
|
-
// then keep the root's modifier classes in step with MODS on the host. The
|
|
66
|
-
// base classes are snapshotted at construction, so a re-render cannot
|
|
67
|
-
// accumulate a stale modifier the way an additive classList would.
|
|
68
66
|
const _ShadowParent = (typeof HTMLElement !== "undefined") ? HTMLElement : Object;
|
|
69
67
|
class ContourShadow extends _ShadowParent {
|
|
70
|
-
|
|
68
|
+
// R30-33: observe `labels` alongside the modifier attributes so a labels
|
|
69
|
+
// change re-runs _applyLabels(). applyMods() ignores it (it only maps MODS),
|
|
70
|
+
// so adding it here does not create a bogus modifier class.
|
|
71
|
+
static get observedAttributes() { return MODS.concat("labels"); }
|
|
71
72
|
constructor() {
|
|
72
73
|
super();
|
|
73
|
-
|
|
74
|
+
// Reuse a Declarative Shadow Root when the platform already attached one
|
|
75
|
+
// (SSR/DSD hydration); otherwise create and populate the shadow root.
|
|
76
|
+
let root = this.shadowRoot;
|
|
77
|
+
if (!root) {
|
|
78
|
+
root = this.attachShadow({ mode: "open" });
|
|
79
|
+
if (this.constructor.contourTemplate) {
|
|
80
|
+
root.appendChild(this.constructor.contourTemplate.content.cloneNode(true));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
74
83
|
const sheets = adoptedSheets();
|
|
75
|
-
if (sheets.length)
|
|
76
|
-
|
|
84
|
+
if (sheets.length) {
|
|
85
|
+
try { root.adoptedStyleSheets = sheets; } catch (e) { /* unsupported or read-only */ }
|
|
86
|
+
}
|
|
77
87
|
this._shadowBase = root.firstElementChild ? root.firstElementChild.className : "";
|
|
78
88
|
}
|
|
79
89
|
// Subclasses with behaviour beyond the template override this.
|
|
80
|
-
// Lifecycle note: listeners are attached to nodes inside the shadow root
|
|
81
|
-
// (root-owned), not to the host, so they are collected when the root is
|
|
82
|
-
// discarded on disconnect. No host-level disposers are required; the
|
|
83
|
-
// root-owner invariant is what keeps this leak-free (R11-08).
|
|
84
90
|
enhance(root) {
|
|
85
91
|
if (!root) root = this.shadowRoot;
|
|
86
92
|
if (!root) return;
|
|
87
93
|
// ARIA setup is idempotent (guards on hasAttribute), so it re-runs on
|
|
88
|
-
// slotchange to cover slotted content. Behaviour wiring is guarded by
|
|
89
|
-
// wcClaim inside each wire* function, so it stays one-shot.
|
|
90
|
-
// Native <button> already has an implicit role of "button"; do not
|
|
91
|
-
// inject a redundant role (WAI-ARIA Rule 1).
|
|
92
|
-
// ARIA: sync aria-expanded on disclosure/expandable details
|
|
93
94
|
root.querySelectorAll("details").forEach((d) => {
|
|
94
95
|
const summary = d.querySelector("summary");
|
|
95
96
|
if (summary && !summary.hasAttribute("aria-expanded")) {
|
|
@@ -144,28 +145,104 @@ import { define, MODS, REGISTERED, CONTOUR_EVENTS, contourId } from './core.mjs'
|
|
|
144
145
|
}
|
|
145
146
|
}
|
|
146
147
|
});
|
|
147
|
-
// ARIA: alert elements
|
|
148
|
+
// ARIA: alert elements are live regions, and the variant sets the volume.
|
|
148
149
|
root.querySelectorAll(".c-alert").forEach((el) => {
|
|
149
|
-
|
|
150
|
-
|
|
150
|
+
const urgent = el.classList.contains("c-alert--warning") || el.classList.contains("c-alert--danger");
|
|
151
|
+
const role = urgent ? "alert" : "status";
|
|
152
|
+
const live = urgent ? "assertive" : "polite";
|
|
153
|
+
if (!el.hasAttribute("role") || el.dataset.contourAutoRole) {
|
|
154
|
+
el.setAttribute("role", role);
|
|
155
|
+
el.dataset.contourAutoRole = role;
|
|
156
|
+
}
|
|
157
|
+
if (!el.hasAttribute("aria-live") || el.dataset.contourAutoLive) {
|
|
158
|
+
el.setAttribute("aria-live", live);
|
|
159
|
+
el.dataset.contourAutoLive = live;
|
|
160
|
+
}
|
|
151
161
|
});
|
|
152
162
|
// ARIA: required form fields
|
|
153
163
|
root.querySelectorAll("input[required], textarea[required], select[required]").forEach((el) => {
|
|
154
164
|
if (!el.hasAttribute("aria-required")) el.setAttribute("aria-required", "true");
|
|
155
165
|
});
|
|
156
166
|
// Interaction is delegated to the implementation the light-DOM wrappers
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
167
|
+
this._wireLabels(root);
|
|
168
|
+
this._wireClose(root);
|
|
169
|
+
}
|
|
170
|
+
// R31-22: the shadow callout/alert/tag/filter-pill close/remove buttons were
|
|
171
|
+
// inert — a control the reader could focus and never use. Wire them to
|
|
172
|
+
// dismiss the host (hide + emit contour:close/dismiss), once per host.
|
|
173
|
+
_wireClose(root) {
|
|
174
|
+
if (!root || this._wiredShadowClose) return;
|
|
175
|
+
const btns = root.querySelectorAll(".c-callout__close, .c-alert__close, .c-tag__remove, .c-filter-pill__remove");
|
|
176
|
+
if (!btns.length) return;
|
|
177
|
+
this._wiredShadowClose = true;
|
|
178
|
+
for (const b of btns) {
|
|
179
|
+
b.addEventListener("click", () => {
|
|
180
|
+
this.hidden = true;
|
|
181
|
+
this.dispatchEvent(new CustomEvent("contour:close", { bubbles: true, composed: true }));
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
// R31-03: a shadow <label> wrapping a <slot> does not label a slotted input.
|
|
186
|
+
// The input is in the light tree, the label in the shadow tree, and HTML's
|
|
187
|
+
// label/for association does not cross the boundary. Give the slotted
|
|
188
|
+
// control an id and point the shadow label's `for` at it, and mirror the
|
|
189
|
+
// field hint/error into aria-describedby. Idempotent.
|
|
190
|
+
_wireLabels(root) {
|
|
191
|
+
if (!root) return;
|
|
192
|
+
root.querySelectorAll("label").forEach((label) => {
|
|
193
|
+
const slot = label.querySelector("slot");
|
|
194
|
+
const field = label.closest(".c-field") || label.parentElement;
|
|
195
|
+
const host = this;
|
|
196
|
+
const controls = [];
|
|
197
|
+
if (slot) {
|
|
198
|
+
for (const n of slot.assignedElements({ flatten: true })) {
|
|
199
|
+
if (n.matches("input, textarea, select")) controls.push(n);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
// A field's input lives in a named "input" slot, not inside the label.
|
|
203
|
+
if (!controls.length && field) {
|
|
204
|
+
const inputSlot = field.querySelector('slot[name="input"]');
|
|
205
|
+
if (inputSlot) {
|
|
206
|
+
for (const n of inputSlot.assignedElements({ flatten: true })) {
|
|
207
|
+
if (n.matches("input, textarea, select")) controls.push(n);
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
for (const input of controls) {
|
|
212
|
+
if (!input.id) input.id = contourId("shadow-input");
|
|
213
|
+
if (!label.hasAttribute("for")) label.setAttribute("for", input.id);
|
|
214
|
+
// R31-19: `for` does not cross the shadow boundary — the label is in
|
|
215
|
+
// the shadow tree, the input in the light tree, so `label.control`
|
|
216
|
+
// is null and `input.labels` is empty. Give the input an explicit
|
|
217
|
+
// accessible name from the label's slotted text, and forward a label
|
|
218
|
+
// click to the control, so the visible label actually toggles it.
|
|
219
|
+
if (!input.hasAttribute("aria-label") && !input.hasAttribute("aria-labelledby")) {
|
|
220
|
+
const text = assignedText(label);
|
|
221
|
+
if (text) input.setAttribute("aria-label", text);
|
|
222
|
+
}
|
|
223
|
+
if (!input._contourLabelWired) {
|
|
224
|
+
input._contourLabelWired = true;
|
|
225
|
+
label.addEventListener("click", (e) => {
|
|
226
|
+
if (e.target.closest("a, button, input, textarea, select")) return;
|
|
227
|
+
try { input.click(); } catch (err) { /* control without click */ }
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
// Mirror the field hint/error into aria-describedby (once).
|
|
231
|
+
if (field && !input.hasAttribute("aria-describedby")) {
|
|
232
|
+
const hint = field.querySelector(".c-field__hint");
|
|
233
|
+
const err = field.querySelector(".c-field__error");
|
|
234
|
+
const ids = [];
|
|
235
|
+
if (hint) { if (!hint.id) hint.id = contourId("hint"); ids.push(hint.id); }
|
|
236
|
+
if (err) { if (!err.id) err.id = contourId("err"); ids.push(err.id); }
|
|
237
|
+
if (ids.length) input.setAttribute("aria-describedby", ids.join(" "));
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
});
|
|
165
241
|
}
|
|
166
|
-
connectedCallback() {
|
|
242
|
+
connectedCallback() {
|
|
167
243
|
this.applyMods();
|
|
168
244
|
try { this.enhance(this.shadowRoot); } catch (e) { /* ignore */ }
|
|
245
|
+
this._applyLabels();
|
|
169
246
|
// Wire behaviours now that slotted content is present.
|
|
170
247
|
try {
|
|
171
248
|
wcReset(this);
|
|
@@ -173,23 +250,47 @@ connectedCallback() {
|
|
|
173
250
|
wireMenu(this); wirePagination(this); wireCopy(this); wireRemovable(this);
|
|
174
251
|
} catch (e) { /* ignore */ }
|
|
175
252
|
// Re-wire behaviour when slotted content changes. Reset the wired set so
|
|
176
|
-
// behaviours can claim again now that slotted nodes exist.
|
|
177
|
-
//
|
|
178
|
-
// Guarded: this callback runs again whenever the host is moved in the
|
|
179
|
-
// DOM, and attaching the listener unconditionally accumulated one per
|
|
180
|
-
// move until a panel shuffled inside a tab re-wired on every slotchange
|
|
181
|
-
// it had already handled.
|
|
182
253
|
if (this.shadowRoot && !this._wiredSlotchange) {
|
|
183
254
|
this._wiredSlotchange = true;
|
|
184
255
|
this.shadowRoot.addEventListener("slotchange", () => {
|
|
185
256
|
try { this.enhance(this.shadowRoot);
|
|
257
|
+
this._applyLabels();
|
|
186
258
|
wireTabs(this); wireSegmented(this); wireCombobox(this); wireTree(this);
|
|
187
259
|
wireMenu(this); wirePagination(this); wireCopy(this); wireRemovable(this);
|
|
188
260
|
} catch (e) { /* ignore */ }
|
|
189
261
|
});
|
|
190
262
|
}
|
|
191
263
|
}
|
|
192
|
-
attributeChangedCallback() { this.applyMods(); }
|
|
264
|
+
attributeChangedCallback() { this.applyMods(); this._applyLabels(); }
|
|
265
|
+
// R30-33: localise the static aria-labels/copy baked into shadow templates.
|
|
266
|
+
// The light-DOM sweep (R30-13) routes literals through labelText(); the
|
|
267
|
+
// shadow layer has no such path because its markup is a static template
|
|
268
|
+
// string. This post-processes the rendered shadowRoot, replacing the
|
|
269
|
+
// English defaults with the host's `labels` overrides where present. It is
|
|
270
|
+
// idempotent and only touches nodes that still carry the default text, so
|
|
271
|
+
// an author's own shadow content (slotted) is never overwritten.
|
|
272
|
+
_applyLabels() {
|
|
273
|
+
const root = this.shadowRoot;
|
|
274
|
+
if (!root) return;
|
|
275
|
+
const set = (selector, key, fallback) => {
|
|
276
|
+
const node = root.querySelector(selector);
|
|
277
|
+
if (node) node.setAttribute("aria-label", labelText(this, key, fallback));
|
|
278
|
+
};
|
|
279
|
+
set(".c-callout__close", "close", "Close");
|
|
280
|
+
set(".c-alert__close", "close", "Close");
|
|
281
|
+
set(".c-tag__remove", "remove", "Remove");
|
|
282
|
+
set(".c-filter-pill__remove", "remove-filter", "Remove filter");
|
|
283
|
+
set(".c-breadcrumb", "breadcrumb", "Breadcrumb");
|
|
284
|
+
set(".c-spinner", "loading", "Loading");
|
|
285
|
+
set(".c-install__copy", "copy-command", "Copy command");
|
|
286
|
+
// The install/code copy buttons carry visible "Copy" text as well as an
|
|
287
|
+
// aria-label; localise both, but only while they still read "Copy" so a
|
|
288
|
+
// consumer who set their own label keeps it.
|
|
289
|
+
const copyBtn = root.querySelector(".c-install__copy, .c-code__copy");
|
|
290
|
+
if (copyBtn && copyBtn.textContent.trim() === "Copy") {
|
|
291
|
+
copyBtn.textContent = labelText(this, "copy", "Copy");
|
|
292
|
+
}
|
|
293
|
+
}
|
|
193
294
|
applyMods() {
|
|
194
295
|
const el = this.shadowRoot.firstElementChild;
|
|
195
296
|
if (!el || !this._shadowBase) return;
|
|
@@ -202,27 +303,43 @@ connectedCallback() {
|
|
|
202
303
|
}
|
|
203
304
|
}
|
|
204
305
|
el.className = (this._shadowBase + " " + mods.join(" ")).trim();
|
|
306
|
+
// An alert's live region follows its variant, and rewriting the class above
|
|
307
|
+
if (el.classList.contains("c-alert")) {
|
|
308
|
+
const urgent = el.classList.contains("c-alert--warning") || el.classList.contains("c-alert--danger");
|
|
309
|
+
const role = urgent ? "alert" : "status";
|
|
310
|
+
const live = urgent ? "assertive" : "polite";
|
|
311
|
+
if (!el.hasAttribute("role") || el.dataset.contourAutoRole) {
|
|
312
|
+
el.setAttribute("role", role);
|
|
313
|
+
el.dataset.contourAutoRole = role;
|
|
314
|
+
}
|
|
315
|
+
if (!el.hasAttribute("aria-live") || el.dataset.contourAutoLive) {
|
|
316
|
+
el.setAttribute("aria-live", live);
|
|
317
|
+
el.dataset.contourAutoLive = live;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
205
320
|
}
|
|
206
321
|
}
|
|
207
322
|
|
|
208
|
-
// Registers a wrapper. The template is
|
|
209
|
-
// cloned per instance, so the markup below is the markup the root gets.
|
|
323
|
+
// Registers a wrapper. The template markup is always recorded so Node/SSR
|
|
210
324
|
const SHADOW_PARTS_PUBLIC = {};
|
|
325
|
+
const SHADOW_MARKUP = {};
|
|
326
|
+
const recordParts = (name, markup) => {
|
|
327
|
+
SHADOW_PARTS_PUBLIC[name] = [...markup.matchAll(/part="([^"]+)"/g)]
|
|
328
|
+
.flatMap((m) => m[1].split(/\s+/))
|
|
329
|
+
.filter(Boolean);
|
|
330
|
+
};
|
|
211
331
|
const shadow = (name, markup) => {
|
|
332
|
+
SHADOW_MARKUP[name] = markup;
|
|
333
|
+
recordParts(name, markup);
|
|
212
334
|
if (typeof document === "undefined") return;
|
|
213
335
|
const tpl = document.createElement("template");
|
|
214
|
-
tpl
|
|
215
|
-
SHADOW_PARTS_PUBLIC[name] = [...tpl.content.querySelectorAll("[part]")]
|
|
216
|
-
.flatMap((node) => (node.getAttribute("part") || "").split(/\s+/))
|
|
217
|
-
.filter(Boolean);
|
|
336
|
+
setHTML(tpl, markup);
|
|
218
337
|
const cls = class extends ContourShadow {};
|
|
219
338
|
cls.contourTemplate = tpl;
|
|
220
339
|
define(name, cls);
|
|
221
340
|
};
|
|
222
341
|
|
|
223
342
|
// A wrapper that is one default slot needs no markup of its own: the element,
|
|
224
|
-
// the class, the part and the name all follow from the block, so the table
|
|
225
|
-
// holds the block and the tag.
|
|
226
343
|
const slotWrapper = (tag, block, part) =>
|
|
227
344
|
"<" + tag + ' class="c-' + block + '" part="' + (part || block) + '"' + (tag === "button" ? ' type="button"' : "") + "><slot></slot></" + tag + ">";
|
|
228
345
|
const SHADOW_SLOTS = {
|
|
@@ -242,7 +359,7 @@ connectedCallback() {
|
|
|
242
359
|
"toolbar", "tooltip", "tree", "version", "version-banner"
|
|
243
360
|
],
|
|
244
361
|
button: [
|
|
245
|
-
"btn", "pressable"
|
|
362
|
+
"btn", "pressable"
|
|
246
363
|
],
|
|
247
364
|
span: [
|
|
248
365
|
"avatar", "badge", "chip", "dot", "flag", "live-badge", "mark", "pill"
|
|
@@ -256,30 +373,22 @@ connectedCallback() {
|
|
|
256
373
|
label: [
|
|
257
374
|
"check", "radio", "switch"
|
|
258
375
|
],
|
|
259
|
-
select: [
|
|
260
|
-
"select"
|
|
261
|
-
],
|
|
262
376
|
nav: [
|
|
263
377
|
"docs-nav"
|
|
264
378
|
],
|
|
265
379
|
};
|
|
266
380
|
|
|
267
381
|
// Two wrappers name their part after the region it holds rather than after
|
|
268
|
-
// the block, and one names it after the banner. Pinned here because the part
|
|
269
|
-
// is the contract a consumer styles against. Declared before the loop that
|
|
270
|
-
// reads it: a const in a temporal dead zone throws at load and takes the
|
|
271
|
-
// whole file down with it.
|
|
272
382
|
const SHADOW_PARTS = {
|
|
273
383
|
"version-banner": "banner",
|
|
274
384
|
"contour-plot": "plot",
|
|
275
385
|
};
|
|
276
386
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
}
|
|
387
|
+
// The slot wrappers are recorded wherever this module runs. `shadow()` already
|
|
388
|
+
for (const [tag, blocks] of Object.entries(SHADOW_SLOTS)) {
|
|
389
|
+
for (const block of blocks) {
|
|
390
|
+
const part = SHADOW_PARTS[block] || block;
|
|
391
|
+
shadow("contour-shadow-" + block, slotWrapper(tag, block, part));
|
|
283
392
|
}
|
|
284
393
|
}
|
|
285
394
|
|
|
@@ -311,14 +420,10 @@ connectedCallback() {
|
|
|
311
420
|
shadow("contour-shadow-section-head", `<div class="c-section-head" part="head"><h2 class="c-section-head__title" part="title"><slot name="title"></slot></h2><p class="c-section-head__desc" part="desc"><slot name="desc"></slot></p></div>`);
|
|
312
421
|
shadow("contour-shadow-loading", `<div class="c-loading" part="loading"><span class="c-spinner" part="spinner"></span><slot></slot></div>`);
|
|
313
422
|
// Shadow tabs are a styling shell: panels are authored by the consumer
|
|
314
|
-
// (the light layer generates them from a `tabs` attribute). The default
|
|
315
|
-
// slot below is the panel container; consumers place `c-tabs__panel`
|
|
316
|
-
// elements (or any content) there. See §23 shadow-parity note.
|
|
317
423
|
shadow("contour-shadow-tabs", `<div class="c-tabs" part="tabs"><div class="c-tabs__list" part="list" role="tablist"><slot name="tabs"></slot></div><div class="c-tabs__panels" role="presentation"><slot></slot></div></div>`);
|
|
318
424
|
shadow("contour-shadow-breadcrumb", `<nav class="c-breadcrumb" part="breadcrumb" aria-label="Breadcrumb"><ol><slot></slot></ol></nav>`);
|
|
319
425
|
shadow("contour-shadow-menu", `<div class="c-menu" part="menu" role="menu"><slot></slot></div>`);
|
|
320
426
|
shadow("contour-shadow-combobox", `<div class="c-combobox" part="combobox"><input class="c-combobox__input" part="input" type="text" /><ul class="c-combobox__list" part="list" hidden><slot></slot></ul></div>`);
|
|
321
|
-
shadow("contour-shadow-table", `<div class="c-table-wrap" part="wrap"><table class="c-table" part="table"><thead><slot name="head"></slot></thead><tbody><slot></slot></tbody></table></div>`);
|
|
322
427
|
shadow("contour-shadow-chart", `<div class="c-chart" part="chart"><div class="c-chart__plot" part="plot"><slot></slot></div></div>`);
|
|
323
428
|
shadow("contour-shadow-bivariate", `<div class="c-bivariate" part="bivariate"><div class="c-bivariate__matrix" part="matrix"><slot></slot></div></div>`);
|
|
324
429
|
shadow("contour-shadow-bivariate-legend", `<div class="c-bivariate-legend" part="legend"><div class="c-bivariate-legend__matrix" part="matrix"><slot></slot></div></div>`);
|
|
@@ -329,9 +434,13 @@ connectedCallback() {
|
|
|
329
434
|
shadow("contour-shadow-header", `<header class="c-header" part="header"><div class="container c-header__inner" part="inner"><a class="c-brand" part="brand"><slot name="brand"></slot></a><nav class="c-header__nav" part="nav"><slot name="nav"></slot></nav><div class="c-header__actions" part="actions"><slot name="actions"></slot></div></div></header>`);
|
|
330
435
|
shadow("contour-shadow-footer", `<footer class="c-footer" part="footer"><div class="container c-footer__grid" part="grid"><div class="c-footer__brand" part="brand"><slot name="brand"></slot></div><div class="c-footer__links" part="links"><slot name="links"></slot></div></div></footer>`);
|
|
331
436
|
shadow("contour-shadow-container", `<div class="container" part="container"><slot></slot></div>`);
|
|
332
|
-
|
|
437
|
+
// R31-03: contour-shadow-input / -textarea / -select / -table / -scheme-toggle
|
|
438
|
+
// were removed. Each was a control shell that could not hold the state its
|
|
439
|
+
// light twin holds (no value, no options, no rows, no toggle), so it was a
|
|
440
|
+
// trap rather than a styling seam. Use the light <contour-input>,
|
|
441
|
+
// <contour-select>, <contour-table> and <contour-scheme-toggle>, or style a
|
|
442
|
+
// native control with the `.c-input` / `.c-table` classes directly.
|
|
333
443
|
shadow("contour-shadow-spinner", `<span class="c-spinner" part="spinner" aria-label="Loading"></span>`);
|
|
334
|
-
shadow("contour-shadow-textarea", `<textarea class="c-textarea" part="textarea"></textarea>`);
|
|
335
444
|
shadow("contour-shadow-code", `<pre class="c-code" part="code"><code><slot></slot></code><button class="c-code__copy" part="copy" type="button">Copy</button></pre>`);
|
|
336
445
|
// (folded in from the hand-written component that used to carry its own copy of the sheet logic)
|
|
337
446
|
shadow("contour-shadow-card", `<div class="c-card" part="card"> <div class="c-card__title" part="head"><slot name="title">Untitled</slot></div> <div class="c-card__body" part="body"><slot></slot></div> <div class="c-card__foot" part="foot"><slot name="foot"></slot></div> </div>`);
|
|
@@ -345,18 +454,18 @@ shadow("contour-shadow-filter-pill", `<span class="c-filter-pill" part="filter-p
|
|
|
345
454
|
|
|
346
455
|
// The dialog is the one wrapper with behaviour, because a close button that
|
|
347
456
|
// does not close is a control the reader cannot use.
|
|
457
|
+
const DIALOG_MARKUP = "<dialog class=\"c-dialog\" part=\"dialog\"> <div class=\"c-dialog__head\" part=\"head\"> <slot name=\"title\"></slot> <button class=\"c-btn c-btn--icon c-btn--ghost\" part=\"close\" type=\"button\" aria-label=\"Close\"> <svg aria-hidden=\"true\" viewBox=\"0 0 24 24\"><path d=\"m18 6-12 12M6 6l12 12\" fill=\"none\" stroke=\"currentColor\" stroke-width=\"1.7\" stroke-linecap=\"round\"/></svg> </button> </div> <div class=\"c-dialog__body\" part=\"body\"><slot></slot></div> <div class=\"c-dialog__foot\" part=\"foot\"><slot name=\"foot\"></slot></div> </dialog>";
|
|
458
|
+
SHADOW_MARKUP["contour-shadow-dialog"] = DIALOG_MARKUP;
|
|
459
|
+
recordParts("contour-shadow-dialog", DIALOG_MARKUP);
|
|
348
460
|
class ContourShadowDialog extends ContourShadow {
|
|
349
461
|
static contourTemplate = (typeof document !== "undefined") ? (() => {
|
|
350
462
|
const tpl = document.createElement("template");
|
|
351
|
-
tpl
|
|
463
|
+
setHTML(tpl, DIALOG_MARKUP);
|
|
352
464
|
return tpl;
|
|
353
465
|
})() : null;
|
|
354
466
|
enhance(root) {
|
|
355
467
|
super.enhance(root);
|
|
356
468
|
// The base constructor AND connectedCallback both call enhance; the base's
|
|
357
|
-
// own edits are idempotent by guard, so this override must guard as well
|
|
358
|
-
// or one native beforetoggle dispatches contour:open/close twice (measured
|
|
359
|
-
// open:2/close:2 for a single show()/close(), shadow-dialog-events probe).
|
|
360
469
|
if (this._wiredShadowDialog) return;
|
|
361
470
|
this._wiredShadowDialog = true;
|
|
362
471
|
const dlg = root.querySelector("dialog");
|
|
@@ -365,19 +474,22 @@ shadow("contour-shadow-filter-pill", `<span class="c-filter-pill" part="filter-p
|
|
|
365
474
|
if (dlg) {
|
|
366
475
|
let lastFocus = null;
|
|
367
476
|
// `<dialog>` fires no `show` or `close` events in this engine (measured
|
|
368
|
-
// bare-dialog probe, 2026-10-28): the only open/close signal is
|
|
369
|
-
// `beforetoggle` with a `newState`. The earlier `show`/`close` listeners
|
|
370
|
-
// were dead code, so the shadow twin's contour:open/contour:close never
|
|
371
|
-
// fired while the light twin's did — a parity break the dialog-family
|
|
372
|
-
// probe caught at opened:0, closed:0.
|
|
373
477
|
dlg.addEventListener("beforetoggle", (e) => {
|
|
374
478
|
if (e.newState === "open") {
|
|
375
479
|
lastFocus = document.activeElement;
|
|
480
|
+
// beforetoggle fires BEFORE dialog.open flips, so the attribute
|
|
481
|
+
// write must not re-enter attributeChangedCallback's show() path.
|
|
482
|
+
this._syncingOpenAttr = true;
|
|
483
|
+
if (!this.hasAttribute("open")) this.setAttribute("open", "");
|
|
484
|
+
this._syncingOpenAttr = false;
|
|
376
485
|
this.dispatchEvent(new CustomEvent("contour:open", { bubbles: true, composed: true }));
|
|
377
486
|
// Focus the close button or first focusable element
|
|
378
487
|
const focusable = dlg.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");
|
|
379
488
|
if (focusable) try { focusable.focus(); } catch (e) {}
|
|
380
489
|
} else if (e.newState === "closed") {
|
|
490
|
+
this._syncingOpenAttr = true;
|
|
491
|
+
if (this.hasAttribute("open")) this.removeAttribute("open");
|
|
492
|
+
this._syncingOpenAttr = false;
|
|
381
493
|
this.dispatchEvent(new CustomEvent("contour:close", { bubbles: true, composed: true }));
|
|
382
494
|
// Restore focus
|
|
383
495
|
if (lastFocus && typeof lastFocus.focus === "function") {
|
|
@@ -385,39 +497,99 @@ shadow("contour-shadow-filter-pill", `<span class="c-filter-pill" part="filter-p
|
|
|
385
497
|
}
|
|
386
498
|
}
|
|
387
499
|
});
|
|
388
|
-
// Focus trap: keep Tab within the dialog
|
|
500
|
+
// Focus trap: keep Tab within the dialog. R31-04: the focusables are not
|
|
501
|
+
// only in the shadow tree — slotted light-DOM controls (the dialog body
|
|
502
|
+
// is a <slot>) are real tab stops too, and `document.activeElement` is
|
|
503
|
+
// the shadow host, not the control. Collect both, and read the
|
|
504
|
+
// shadow-aware active element.
|
|
505
|
+
const collectFocusable = () => {
|
|
506
|
+
const sel = "button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])";
|
|
507
|
+
const out = Array.from(dlg.querySelectorAll(sel));
|
|
508
|
+
for (const slot of dlg.querySelectorAll("slot")) {
|
|
509
|
+
for (const n of slot.assignedElements({ flatten: true })) {
|
|
510
|
+
if (n.matches(sel)) out.push(n);
|
|
511
|
+
for (const sub of n.querySelectorAll(sel)) out.push(sub);
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
return out;
|
|
515
|
+
};
|
|
516
|
+
const activeEl = () => (this.shadowRoot && this.shadowRoot.activeElement) || document.activeElement;
|
|
389
517
|
dlg.addEventListener("keydown", (e) => {
|
|
390
518
|
if (e.key !== "Tab") return;
|
|
391
|
-
const focusables =
|
|
519
|
+
const focusables = collectFocusable();
|
|
392
520
|
if (!focusables.length) return;
|
|
393
521
|
const first = focusables[0];
|
|
394
522
|
const last = focusables[focusables.length - 1];
|
|
395
|
-
if (e.shiftKey &&
|
|
523
|
+
if (e.shiftKey && activeEl() === first) {
|
|
396
524
|
e.preventDefault();
|
|
397
525
|
last.focus();
|
|
398
|
-
} else if (!e.shiftKey &&
|
|
526
|
+
} else if (!e.shiftKey && activeEl() === last) {
|
|
399
527
|
e.preventDefault();
|
|
400
528
|
first.focus();
|
|
401
529
|
}
|
|
402
530
|
});
|
|
403
531
|
}
|
|
404
532
|
}
|
|
405
|
-
|
|
406
|
-
|
|
533
|
+
static get observedAttributes() { return [...super.observedAttributes, "open"]; }
|
|
534
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
535
|
+
super.attributeChangedCallback(name, oldValue, newValue);
|
|
536
|
+
// The host's `open` attribute drives the inner native dialog, matching
|
|
537
|
+
// the light family; without this the attribute was inert (R25-12).
|
|
538
|
+
if (name === "open" && this.shadowRoot && !this._syncingOpenAttr) {
|
|
539
|
+
const dlg = this.shadowRoot.querySelector("dialog");
|
|
540
|
+
if (dlg) {
|
|
541
|
+
if (newValue !== null && !dlg.open) this.show();
|
|
542
|
+
else if (newValue === null && dlg.open) this.close();
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
}
|
|
546
|
+
connectedCallback() {
|
|
547
|
+
super.connectedCallback();
|
|
548
|
+
// R31-33: an `open` attribute set before the element was connected (or a
|
|
549
|
+
// show() called while disconnected) must engage the dialog once it lands
|
|
550
|
+
// in the document; showModal() on a disconnected dialog throws.
|
|
551
|
+
if (this.hasAttribute("open")) this.show();
|
|
552
|
+
}
|
|
553
|
+
show() {
|
|
554
|
+
// R31-33: showModal() throws on a disconnected element. If not yet
|
|
555
|
+
// connected, leave the `open` attribute set; connectedCallback applies it.
|
|
556
|
+
if (!this.isConnected) { if (!this.hasAttribute("open")) this.setAttribute("open", ""); return; }
|
|
557
|
+
const d = this.shadowRoot?.querySelector("dialog");
|
|
558
|
+
if (d && !d.open) d.showModal();
|
|
559
|
+
}
|
|
560
|
+
close() { const d = this.shadowRoot?.querySelector("dialog"); if (d && d.open) d.close(); }
|
|
561
|
+
// Native-dialog parity with the light family (R20 T-32): showModal() is
|
|
562
|
+
showModal() { this.show(); }
|
|
563
|
+
get open() { return !!this.shadowRoot?.querySelector("dialog")?.open; }
|
|
564
|
+
set open(v) { if (v) this.show(); else this.close(); }
|
|
565
|
+
get returnValue() { return this.shadowRoot?.querySelector("dialog")?.returnValue ?? ""; }
|
|
566
|
+
set returnValue(v) { const d = this.shadowRoot?.querySelector("dialog"); if (d) d.returnValue = String(v); }
|
|
407
567
|
}
|
|
408
568
|
define("contour-shadow-dialog", ContourShadowDialog);
|
|
409
569
|
|
|
570
|
+
/**
|
|
571
|
+
* Render a Declarative Shadow DOM string for a registered contour-shadow-* element.
|
|
572
|
+
* Intended for SSR/string emission; returns null for unknown tags.
|
|
573
|
+
*/
|
|
574
|
+
const renderShadowDSD = (tag, attrs = "", light = "") => {
|
|
575
|
+
const markup = SHADOW_MARKUP[tag];
|
|
576
|
+
if (typeof markup !== "string") return null;
|
|
577
|
+
const attrStr = attrs ? (attrs.startsWith(" ") ? attrs : " " + attrs) : "";
|
|
578
|
+
return `<${tag}${attrStr}><template shadowrootmode="open">${markup}</template>${light}</${tag}>`;
|
|
579
|
+
};
|
|
580
|
+
|
|
410
581
|
// Published once, at the end, so the array holds what the browser was actually
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
582
|
+
const FROZEN_SHADOW_MARKUP = Object.freeze({ ...SHADOW_MARKUP });
|
|
583
|
+
if (typeof globalThis !== "undefined") {
|
|
584
|
+
globalThis.ContourShadowTemplates = FROZEN_SHADOW_MARKUP;
|
|
585
|
+
}
|
|
586
|
+
// Only the SHADOW vocabulary publishes here (R25-06). ContourElements and
|
|
414
587
|
if (typeof window !== "undefined") {
|
|
415
|
-
window.ContourElements = Object.freeze(REGISTERED.slice());
|
|
416
588
|
window.ContourShadowParts = Object.freeze(Object.fromEntries(
|
|
417
589
|
Object.entries(SHADOW_PARTS_PUBLIC).map(([name, parts]) => [name, Object.freeze([...new Set(parts)])]),
|
|
418
590
|
));
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
// "every dispatchEvent name has an entry" read meaningless.
|
|
422
|
-
window.ContourEvents = Object.freeze(CONTOUR_EVENTS);
|
|
591
|
+
if (!window.Contour) window.Contour = {};
|
|
592
|
+
try { window.Contour.shadowTemplates = FROZEN_SHADOW_MARKUP; } catch {}
|
|
423
593
|
}
|
|
594
|
+
|
|
595
|
+
export { SHADOW_MARKUP, renderShadowDSD };
|