contour-ds 1.8.1 → 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 +227 -378
- package/dist/agent-cookbook.json +960 -0
- package/dist/agent-examples.json +65 -0
- package/dist/agent-map-wiring.json +152 -0
- package/dist/build-manifest.json +320 -179
- package/dist/contour-wc-content.esm.js +479 -3665
- package/dist/contour-wc-content.esm.min.js +1 -1
- 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 +2713 -4381
- package/dist/contour-wc-dashboard.esm.min.js +1 -1
- package/dist/contour-wc-data.esm.js +2658 -4346
- package/dist/contour-wc-data.esm.min.js +1 -1
- package/dist/contour-wc-docs.esm.js +218 -3547
- package/dist/contour-wc-docs.esm.min.js +1 -1
- package/dist/contour-wc-feedback.esm.js +483 -3658
- package/dist/contour-wc-feedback.esm.min.js +1 -1
- package/dist/contour-wc-forms.esm.js +503 -3754
- package/dist/contour-wc-forms.esm.min.js +1 -1
- package/dist/contour-wc-interaction.esm.js +379 -3616
- package/dist/contour-wc-interaction.esm.min.js +1 -1
- package/dist/contour-wc-layout.esm.js +234 -3563
- package/dist/contour-wc-layout.esm.min.js +1 -1
- package/dist/contour-wc-map.esm.js +949 -3743
- package/dist/contour-wc-map.esm.min.js +1 -1
- package/dist/contour-wc-misc.esm.js +237 -3556
- package/dist/contour-wc-misc.esm.min.js +1 -1
- package/dist/contour-wc-navigation.esm.js +2235 -5237
- package/dist/contour-wc-navigation.esm.min.js +1 -1
- package/dist/contour-wc-ui.esm.js +4638 -7128
- package/dist/contour-wc-ui.esm.min.js +1 -1
- package/dist/contour-wc.esm.js +11971 -7727
- package/dist/contour-wc.esm.min.js +1 -1
- package/dist/contour-wc.js +11971 -7727
- package/dist/contour-wc.min.js +1 -1
- package/dist/contour.a11y.json +402 -0
- package/dist/contour.code-snippets +96 -74
- package/dist/contour.components.json +2591 -741
- package/dist/contour.css +2624 -1888
- package/dist/contour.d.ts +421 -228
- package/dist/contour.esm.js +433 -18
- package/dist/contour.esm.min.js +1 -1
- package/dist/contour.html-data.json +1231 -199
- package/dist/contour.js +433 -18
- package/dist/contour.min.css +1 -1
- package/dist/contour.min.js +1 -1
- package/dist/contour.react.d.ts +100 -98
- package/dist/contour.single.html +2 -2
- package/dist/contour.single.min.css +1 -1
- package/dist/contour.themes.json +56 -12
- package/dist/contour.tokens.json +482 -255
- package/dist/contour.vue.d.ts +100 -98
- package/dist/contour.web-types.json +1226 -226
- package/dist/custom-elements.json +7649 -2237
- package/dist/docs/actions.md +15 -6
- package/dist/docs/affordances.md +18 -96
- package/dist/docs/apireference.md +9 -5
- package/dist/docs/colour.md +10 -4
- package/dist/docs/componentindex.md +9 -26
- package/dist/docs/data.md +36 -60
- package/dist/docs/docs.md +10 -12
- 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 +63 -56
- package/dist/docs/install.md +12 -7
- package/dist/docs/landing.md +7 -4
- package/dist/docs/mapengine.md +18 -13
- 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 +19 -9
- package/dist/docs/playground.md +9 -22
- package/dist/docs/principles.md +8 -6
- package/dist/docs/recipes.md +113 -14
- package/dist/docs/space.md +10 -6
- package/dist/docs/status.md +12 -25
- 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 +66 -38
- 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 +190 -148
- package/dist/wc/content.mjs +273 -129
- package/dist/wc/core.mjs +598 -395
- package/dist/wc/dashboard.mjs +64 -44
- 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 -4322
- package/dist/wc/docs.mjs +12 -11
- package/dist/wc/feedback.mjs +277 -122
- 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 -1751
- package/dist/wc/glyph.mjs +204 -0
- package/dist/wc/index.mjs +11 -9
- package/dist/wc/interaction.mjs +173 -80
- package/dist/wc/layout.mjs +28 -27
- package/dist/wc/map.mjs +743 -207
- package/dist/wc/misc.mjs +31 -20
- 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 -1905
- package/dist/wc/registration.mjs +1 -8
- package/dist/wc/shadow.mjs +206 -110
- package/dist/wc/states.mjs +54 -75
- package/dist/wc/svg.mjs +118 -47
- 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 +23 -5
- package/integrations/ai/CLAUDE.md +3 -0
- 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/native/README.md +0 -3
- package/integrations/tailwind/contour-theme.css +66 -7
- package/integrations/validate-markup.mjs +172 -0
- package/package.json +77 -42
- package/dist/wc/ui.mjs +0 -5072
package/dist/wc/feedback.mjs
CHANGED
|
@@ -1,14 +1,41 @@
|
|
|
1
|
-
import { ContourBase, define, onDispose, sanitizeHtml, headingTag , warnBadJson, contourId } from './core.mjs';
|
|
1
|
+
import { setHTML, ContourBase, define, onDispose, sanitizeHtml, headingTag , warnBadJson, contourId, flagOn, labelText, statusIcon } from './core.mjs';
|
|
2
2
|
import { loadRemote, remoteData, renderStates, renderEmpty, wireStates } from './states.mjs';
|
|
3
3
|
import { wireRemovable, modalContain } from './behaviours.mjs';
|
|
4
|
+
// R31-12: an authored `open` at load displays the modal (CSS [open]) but never
|
|
5
|
+
// ran show(), so it was not actually modal — no aria-modal, no inert siblings,
|
|
6
|
+
// no focus inside. Engage the modal for an initial open without re-entering
|
|
7
|
+
// show() (which returns early while `open` is already set). Idempotent per host.
|
|
8
|
+
function engageInitialModal(host) {
|
|
9
|
+
if (!host.hasAttribute("open") || host._modalEngaged) return;
|
|
10
|
+
host._modalEngaged = true;
|
|
11
|
+
host.setAttribute("aria-modal", "true");
|
|
12
|
+
modalContain(host, true);
|
|
13
|
+
const focusable = host.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");
|
|
14
|
+
if (focusable) { try { focusable.focus(); } catch (e) {} }
|
|
15
|
+
}
|
|
16
|
+
/** R31-34: a later `open` attribute write is the same contract as the property. */
|
|
17
|
+
function syncDeclarativeOpen(host, name, newValue, wired) {
|
|
18
|
+
if (name !== "open" || !wired || host._declarativeOpen) return;
|
|
19
|
+
host._declarativeOpen = true;
|
|
20
|
+
try {
|
|
21
|
+
if (newValue !== null && !host.hasAttribute("aria-modal")) {
|
|
22
|
+
host.removeAttribute("open");
|
|
23
|
+
host.show();
|
|
24
|
+
} else if (newValue === null && host.hasAttribute("aria-modal")) {
|
|
25
|
+
host.close();
|
|
26
|
+
}
|
|
27
|
+
} finally {
|
|
28
|
+
host._declarativeOpen = false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
4
31
|
class ContourDialog extends ContourBase {
|
|
5
|
-
static get observed() { return ["title", "size", "heading"]; }
|
|
32
|
+
static get observed() { return ["title", "size", "heading", "open"]; }
|
|
6
33
|
static get properties() { return { title: { attribute: "title" }, size: { attribute: "size" } }; }
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
34
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
35
|
+
if (name === "open") { syncDeclarativeOpen(this, name, newValue, this._wiredDialog); return; }
|
|
36
|
+
super.attributeChangedCallback(name, oldValue, newValue);
|
|
37
|
+
}
|
|
38
|
+
// Native-dialog parity (R20 T-32): showModal() aliases show(); open routes through show()/close(); returnValue persists.
|
|
12
39
|
showModal() { this.show(); }
|
|
13
40
|
get open() { return this.hasAttribute("open"); }
|
|
14
41
|
set open(v) { if (v) this.show(); else this.close(); }
|
|
@@ -30,8 +57,8 @@ class ContourDialog extends ContourBase {
|
|
|
30
57
|
const closeBtn = document.createElement("button");
|
|
31
58
|
closeBtn.className = "c-btn c-btn--icon c-btn--ghost c-dialog__close";
|
|
32
59
|
closeBtn.setAttribute("type", "button");
|
|
33
|
-
closeBtn.setAttribute("aria-label", "Close");
|
|
34
|
-
closeBtn
|
|
60
|
+
closeBtn.setAttribute("aria-label", labelText(this, "close", "Close"));
|
|
61
|
+
setHTML(closeBtn, '<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-x" /></svg>');
|
|
35
62
|
head.appendChild(closeBtn);
|
|
36
63
|
}
|
|
37
64
|
const h = head.querySelector(".c-dialog__title");
|
|
@@ -57,14 +84,15 @@ class ContourDialog extends ContourBase {
|
|
|
57
84
|
this._wiredDialog = true;
|
|
58
85
|
this.returnValue = "";
|
|
59
86
|
onDispose(this, () => { if (this.hasAttribute("open")) modalContain(this, false); });
|
|
60
|
-
|
|
61
|
-
// and a caller can read host.open; it is written here and never observed,
|
|
62
|
-
// so changing it cannot re-enter the render (the shared list excludes it
|
|
63
|
-
// for exactly this reason).
|
|
87
|
+
// open attribute is written, never observed — no render re-entry.
|
|
64
88
|
this.show = () => {
|
|
65
89
|
if (this.hasAttribute("open")) return;
|
|
66
90
|
this._dialogLastFocus = document.activeElement;
|
|
67
|
-
|
|
91
|
+
// Guard our own `open` write: syncDeclarativeOpen would otherwise see the
|
|
92
|
+
// attribute change (aria-modal is not set yet) and re-enter show(), firing
|
|
93
|
+
// contour:open twice and leaking a second modalContain depth.
|
|
94
|
+
this._declarativeOpen = true;
|
|
95
|
+
try { this.setAttribute("open", ""); } finally { this._declarativeOpen = false; }
|
|
68
96
|
this.setAttribute("aria-modal", "true");
|
|
69
97
|
const dlg = this.querySelector("dialog") || (this.tagName === "DIALOG" ? this : null);
|
|
70
98
|
if (dlg && typeof dlg.showModal === "function") { try { dlg.showModal(); } catch (e) {} }
|
|
@@ -75,10 +103,17 @@ class ContourDialog extends ContourBase {
|
|
|
75
103
|
this.dispatchEvent(new CustomEvent("contour:open", { bubbles: true, composed: true }));
|
|
76
104
|
};
|
|
77
105
|
this.close = () => {
|
|
78
|
-
|
|
106
|
+
// `open` may already be gone when close() is reached through
|
|
107
|
+
// syncDeclarativeOpen (the host removed the attribute first); an engaged
|
|
108
|
+
// modal (aria-modal still set) must still release its inert siblings, or
|
|
109
|
+
// a lower stacked dialog stays inert.
|
|
110
|
+
const wasOpen = this.hasAttribute("open") || this.hasAttribute("aria-modal");
|
|
79
111
|
const dlg = this.querySelector("dialog") || (this.tagName === "DIALOG" ? this : null);
|
|
80
112
|
if (dlg && typeof dlg.close === "function") dlg.close();
|
|
81
|
-
|
|
113
|
+
// Guard our own `open` removal so syncDeclarativeOpen does not re-enter
|
|
114
|
+
// close() (which would double the close event and the modalContain release).
|
|
115
|
+
this._declarativeOpen = true;
|
|
116
|
+
try { if (this.hasAttribute("open")) this.removeAttribute("open"); } finally { this._declarativeOpen = false; }
|
|
82
117
|
this.removeAttribute("aria-modal");
|
|
83
118
|
if (wasOpen) {
|
|
84
119
|
modalContain(this, false);
|
|
@@ -100,33 +135,26 @@ class ContourDialog extends ContourBase {
|
|
|
100
135
|
// Backdrop click: clicking the host surface (not its content) closes.
|
|
101
136
|
if (e.target === this) this.close();
|
|
102
137
|
});
|
|
103
|
-
|
|
104
|
-
// close to report, and an unconditional event is a claim the component
|
|
105
|
-
// cannot back (F-18).
|
|
138
|
+
// Escape closes only while open; unconditional event is a claim it can't back.
|
|
106
139
|
this.addEventListener("keydown", (e) => {
|
|
107
140
|
if (e.key === "Escape" && this.hasAttribute("open")) this.close();
|
|
108
141
|
});
|
|
142
|
+
engageInitialModal(this);
|
|
109
143
|
}
|
|
110
144
|
}
|
|
111
145
|
define("contour-dialog", ContourDialog);
|
|
112
146
|
class ContourAlert extends ContourBase {
|
|
113
|
-
static get observed() { return ["title", "body", "variant", "icon", "closable", "action", "actions", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton"]; }
|
|
147
|
+
static get observed() { return ["title", "body", "variant", "icon", "closable", "action", "actions", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton", "cache-key", "no-cache"]; }
|
|
114
148
|
static get properties() {
|
|
115
149
|
return { title: { attribute: "title" }, body: { attribute: "body" }, variant: { attribute: "variant" }, icon: { attribute: "icon" }, closable: { attribute: "closable", type: Boolean }, action: { attribute: "action" }, actions: { attribute: "actions" } };
|
|
116
150
|
}
|
|
117
151
|
render() {
|
|
118
152
|
this.classList.add("c-alert");
|
|
119
|
-
|
|
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.
|
|
153
|
+
// Urgent variants (warning/danger) = alert/assertive; others = status/polite (don't talk over reader).
|
|
124
154
|
const urgent = /^(warning|danger)$/.test(this.getAttribute("variant") || "");
|
|
125
155
|
const role = urgent ? "alert" : "status";
|
|
126
156
|
const live = urgent ? "assertive" : "polite";
|
|
127
|
-
|
|
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.
|
|
157
|
+
// Host-written role/aria-live so loader state announces inside region; authored wins.
|
|
130
158
|
if (!this.hasAttribute("role") || this.getAttribute("role") === this._autoRole) {
|
|
131
159
|
this.setAttribute("role", role);
|
|
132
160
|
this._autoRole = role;
|
|
@@ -141,11 +169,12 @@ class ContourAlert extends ContourBase {
|
|
|
141
169
|
const variant = this.getAttribute("variant");
|
|
142
170
|
Array.from(this.classList).forEach((c) => { if (c.startsWith("c-alert--")) this.classList.remove(c); });
|
|
143
171
|
if (variant) this.classList.add("c-alert--" + variant);
|
|
144
|
-
const
|
|
172
|
+
const iconAttr = this.getAttribute("icon");
|
|
173
|
+
const icon = iconAttr === "none" ? "" : (iconAttr || statusIcon(variant));
|
|
145
174
|
if (icon) {
|
|
146
175
|
const ic = this.ensure(".c-alert__icon", () => { const el = document.createElement("span"); el.className = "c-alert__icon"; return el; });
|
|
147
176
|
if (ic.parentNode === this && this.firstChild !== ic) this.prepend(ic);
|
|
148
|
-
ic
|
|
177
|
+
setHTML(ic, '<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#' + String(icon).replace(/[^a-zA-Z0-9_-]/g, "") + '" /></svg>');
|
|
149
178
|
} else {
|
|
150
179
|
const ic = this.querySelector(".c-alert__icon");
|
|
151
180
|
if (ic) ic.remove();
|
|
@@ -159,16 +188,25 @@ class ContourAlert extends ContourBase {
|
|
|
159
188
|
const t = this.querySelector(".c-alert__title");
|
|
160
189
|
if (t) t.remove();
|
|
161
190
|
}
|
|
191
|
+
// Authored children move into .c-alert__body (default slot); `body` attribute fills when no children.
|
|
162
192
|
const body = this.getAttribute("body");
|
|
163
|
-
|
|
193
|
+
const authored = Array.from(this.childNodes).filter((n) => {
|
|
194
|
+
if (n.nodeType === 1 && n.classList && (n.classList.contains("c-alert__icon") || n.classList.contains("c-alert__title") || n.classList.contains("c-alert__body"))) return false;
|
|
195
|
+
if (n.nodeType === 3 && !n.textContent.trim()) return false;
|
|
196
|
+
return true;
|
|
197
|
+
});
|
|
198
|
+
if (authored.length) {
|
|
199
|
+
const b = this.ensure(".c-alert__body", () => { const el = document.createElement("div"); el.className = "c-alert__body"; return el; });
|
|
200
|
+
b.textContent = "";
|
|
201
|
+
for (const n of authored) b.appendChild(n);
|
|
202
|
+
} else if (body) {
|
|
164
203
|
const b = this.ensure(".c-alert__body", () => { const el = document.createElement("div"); el.className = "c-alert__body"; return el; });
|
|
165
204
|
b.textContent = body;
|
|
166
205
|
} else {
|
|
167
206
|
const b = this.querySelector(".c-alert__body");
|
|
168
207
|
if (b) b.remove();
|
|
169
208
|
}
|
|
170
|
-
|
|
171
|
-
// different `action`/`actions` value does not leave stale buttons behind.
|
|
209
|
+
// Remove stale action buttons on re-render.
|
|
172
210
|
Array.from(this.querySelectorAll(".c-alert__action")).forEach((n) => n.remove());
|
|
173
211
|
const actionsAttr = this.getAttribute("actions");
|
|
174
212
|
let actionList = [];
|
|
@@ -186,12 +224,12 @@ class ContourAlert extends ContourBase {
|
|
|
186
224
|
a.textContent = label;
|
|
187
225
|
this.appendChild(a);
|
|
188
226
|
});
|
|
189
|
-
if (this
|
|
227
|
+
if (flagOn(this, "closable")) {
|
|
190
228
|
this.ensure(".c-alert__close", () => {
|
|
191
229
|
const btn = document.createElement("button");
|
|
192
230
|
btn.className = "c-alert__close";
|
|
193
231
|
btn.type = "button";
|
|
194
|
-
btn.setAttribute("aria-label", "Close");
|
|
232
|
+
btn.setAttribute("aria-label", labelText(this, "close", "Close"));
|
|
195
233
|
btn.textContent = "×";
|
|
196
234
|
return btn;
|
|
197
235
|
});
|
|
@@ -199,7 +237,7 @@ class ContourAlert extends ContourBase {
|
|
|
199
237
|
const btn = this.querySelector(".c-alert__close");
|
|
200
238
|
if (btn) btn.remove();
|
|
201
239
|
}
|
|
202
|
-
if (!title && !body && !icon) {
|
|
240
|
+
if (!title && !body && !icon && !authored.length) {
|
|
203
241
|
renderEmpty(this, "alert");
|
|
204
242
|
}
|
|
205
243
|
}
|
|
@@ -211,7 +249,7 @@ class ContourAlert extends ContourBase {
|
|
|
211
249
|
const actionBtn = e.target && e.target.closest ? e.target.closest(".c-alert__action") : null;
|
|
212
250
|
if (actionBtn && this.contains(actionBtn)) {
|
|
213
251
|
e.preventDefault();
|
|
214
|
-
this.dispatchEvent(new CustomEvent("contour:
|
|
252
|
+
this.dispatchEvent(new CustomEvent("contour:action", { bubbles: true, composed: true, detail: { label: actionBtn.textContent.trim() } }));
|
|
215
253
|
return;
|
|
216
254
|
}
|
|
217
255
|
const btn = e.target && e.target.closest ? e.target.closest(".c-alert__close") : null;
|
|
@@ -233,8 +271,7 @@ class ContourDisclosure extends ContourBase {
|
|
|
233
271
|
super.connectedCallback();
|
|
234
272
|
}
|
|
235
273
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
236
|
-
|
|
237
|
-
// container that holds it.
|
|
274
|
+
// Preserve authored content before base reset removes generated container.
|
|
238
275
|
const details = this.querySelector("details");
|
|
239
276
|
if (details) {
|
|
240
277
|
const body = details.querySelector(".c-disclosure__body");
|
|
@@ -258,37 +295,35 @@ class ContourDisclosure extends ContourBase {
|
|
|
258
295
|
if (icon) {
|
|
259
296
|
const ic = document.createElement("span");
|
|
260
297
|
ic.className = "c-disclosure__icon";
|
|
261
|
-
ic
|
|
298
|
+
setHTML(ic, '<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#' + String(icon).replace(/[^a-zA-Z0-9_-]/g, "") + '" /></svg>');
|
|
262
299
|
summ.appendChild(ic);
|
|
263
300
|
}
|
|
264
301
|
summ.appendChild(document.createTextNode(summary));
|
|
265
302
|
d.appendChild(summ);
|
|
266
303
|
const content = document.createElement("div");
|
|
267
304
|
content.className = "c-disclosure__body";
|
|
268
|
-
content
|
|
305
|
+
setHTML(content, captured);
|
|
269
306
|
d.appendChild(content);
|
|
270
307
|
return d;
|
|
271
308
|
});
|
|
272
|
-
// update summary if already existed
|
|
273
309
|
const summ = details.querySelector("summary");
|
|
274
310
|
if (summ) {
|
|
275
311
|
const ic = summ.querySelector(".c-disclosure__icon");
|
|
276
312
|
if (icon && !ic) {
|
|
277
313
|
const newIc = document.createElement("span");
|
|
278
314
|
newIc.className = "c-disclosure__icon";
|
|
279
|
-
newIc
|
|
315
|
+
setHTML(newIc, '<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#' + String(icon).replace(/[^a-zA-Z0-9_-]/g, "") + '" /></svg>');
|
|
280
316
|
summ.insertBefore(newIc, summ.firstChild);
|
|
281
317
|
} else if (!icon && ic) {
|
|
282
318
|
ic.remove();
|
|
283
319
|
}
|
|
284
|
-
// Update text content (remove icon text, set summary)
|
|
285
320
|
const textNodes = Array.from(summ.childNodes).filter(n => n.nodeType === 3);
|
|
286
321
|
textNodes.forEach(n => n.remove());
|
|
287
322
|
summ.appendChild(document.createTextNode(summary));
|
|
288
323
|
}
|
|
289
324
|
const body = details.querySelector(".c-disclosure__body");
|
|
290
|
-
if (body) body
|
|
291
|
-
if (details.parentNode !== this) { this
|
|
325
|
+
if (body) setHTML(body, captured);
|
|
326
|
+
if (details.parentNode !== this) { setHTML(this, ""); this.appendChild(details); }
|
|
292
327
|
} else {
|
|
293
328
|
const details = this.querySelector("details");
|
|
294
329
|
if (details) details.remove();
|
|
@@ -316,11 +351,12 @@ class ContourCallout extends ContourBase {
|
|
|
316
351
|
Array.from(this.classList).forEach((c) => { if (c.startsWith("c-callout--")) this.classList.remove(c); });
|
|
317
352
|
const variant = this.getAttribute("variant");
|
|
318
353
|
if (variant) this.classList.add("c-callout--" + variant);
|
|
319
|
-
const
|
|
354
|
+
const iconAttr = this.getAttribute("icon");
|
|
355
|
+
const icon = iconAttr === "none" ? "" : (iconAttr || statusIcon(variant));
|
|
320
356
|
if (icon) {
|
|
321
357
|
const ic = this.ensure(".c-callout__icon", () => { const el = document.createElement("span"); el.className = "c-callout__icon"; return el; });
|
|
322
358
|
if (ic.parentNode === this && this.firstChild !== ic) this.prepend(ic);
|
|
323
|
-
ic
|
|
359
|
+
setHTML(ic, '<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#' + String(icon).replace(/[^a-zA-Z0-9_-]/g, "") + '" /></svg>');
|
|
324
360
|
} else {
|
|
325
361
|
const ic = this.querySelector(".c-callout__icon");
|
|
326
362
|
if (ic) ic.remove();
|
|
@@ -334,12 +370,12 @@ class ContourCallout extends ContourBase {
|
|
|
334
370
|
const t = this.querySelector(".c-callout__title");
|
|
335
371
|
if (t) t.remove();
|
|
336
372
|
}
|
|
337
|
-
if (this
|
|
373
|
+
if (flagOn(this, "closable")) {
|
|
338
374
|
this.ensure(".c-callout__close", () => {
|
|
339
375
|
const btn = document.createElement("button");
|
|
340
376
|
btn.className = "c-callout__close";
|
|
341
377
|
btn.type = "button";
|
|
342
|
-
btn.setAttribute("aria-label", "Close");
|
|
378
|
+
btn.setAttribute("aria-label", labelText(this, "close", "Close"));
|
|
343
379
|
btn.textContent = "×";
|
|
344
380
|
return btn;
|
|
345
381
|
});
|
|
@@ -374,7 +410,7 @@ class ContourEmpty extends ContourBase {
|
|
|
374
410
|
const icon = this.getAttribute("icon");
|
|
375
411
|
if (icon) {
|
|
376
412
|
const ic = this.ensure(".c-empty__icon", () => { const el = document.createElement("span"); el.className = "c-empty__icon"; return el; });
|
|
377
|
-
ic
|
|
413
|
+
setHTML(ic, '<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#' + String(icon).replace(/[^a-zA-Z0-9_-]/g, "") + '" /></svg>');
|
|
378
414
|
} else {
|
|
379
415
|
const ic = this.querySelector(".c-empty__icon");
|
|
380
416
|
if (ic) ic.remove();
|
|
@@ -382,7 +418,7 @@ class ContourEmpty extends ContourBase {
|
|
|
382
418
|
const illustration = this.getAttribute("illustration");
|
|
383
419
|
if (illustration) {
|
|
384
420
|
const il = this.ensure(".c-empty__illustration", () => { const el = document.createElement("div"); el.className = "c-empty__illustration"; return el; });
|
|
385
|
-
il
|
|
421
|
+
setHTML(il, sanitizeHtml(illustration));
|
|
386
422
|
} else {
|
|
387
423
|
const il = this.querySelector(".c-empty__illustration");
|
|
388
424
|
if (il) il.remove();
|
|
@@ -402,10 +438,7 @@ class ContourEmpty extends ContourBase {
|
|
|
402
438
|
if (b) b.remove();
|
|
403
439
|
}
|
|
404
440
|
if (action) {
|
|
405
|
-
|
|
406
|
-
// element: the action is a real `.c-btn`. The invented action class
|
|
407
|
-
// matched no rule, so it styled nothing yet was the click hook in both
|
|
408
|
-
// layers — `data-empty-action` is the same hook without the invented name.
|
|
441
|
+
// empty state: real .c-btn action, hooked via data-empty-action.
|
|
409
442
|
const a = this.ensure("button.c-btn[data-empty-action]", () => {
|
|
410
443
|
const el = document.createElement("button");
|
|
411
444
|
el.className = "c-btn c-btn--primary";
|
|
@@ -420,15 +453,13 @@ class ContourEmpty extends ContourBase {
|
|
|
420
453
|
}
|
|
421
454
|
}
|
|
422
455
|
enhance() {
|
|
423
|
-
|
|
424
|
-
// One implementation, so the two layers cannot drift apart again: the shadow
|
|
425
|
-
// copy queried its root for slotted nodes, found none, and wired nothing.
|
|
456
|
+
// Interaction in behaviours.mjs; one impl so layers can't drift.
|
|
426
457
|
wireRemovable(this);
|
|
427
458
|
}
|
|
428
459
|
}
|
|
429
460
|
define("contour-empty", ContourEmpty);
|
|
430
461
|
class ContourFaq extends ContourBase {
|
|
431
|
-
static get observed() { return ["question", "answer", "items", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton"]; }
|
|
462
|
+
static get observed() { return ["question", "answer", "items", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton", "cache-key", "no-cache"]; }
|
|
432
463
|
static get properties() { return { question: { attribute: "question" }, answer: { attribute: "answer" }, items: { attribute: "items" }, src: { attribute: "src" } }; }
|
|
433
464
|
render() {
|
|
434
465
|
this.classList.add("c-faq");
|
|
@@ -444,9 +475,7 @@ class ContourFaq extends ContourBase {
|
|
|
444
475
|
const parsed = JSON.parse(items);
|
|
445
476
|
Array.from(this.querySelectorAll(".c-faq__item")).forEach((n) => n.remove());
|
|
446
477
|
parsed.forEach((it, i) => {
|
|
447
|
-
|
|
448
|
-
// summary, so the [open] styling and the marker hiding apply. The
|
|
449
|
-
// first item opens like the guide's own FAQ section does.
|
|
478
|
+
// Native details+summary; [open] styling and marker hiding apply. First item opens.
|
|
450
479
|
const item = document.createElement("details");
|
|
451
480
|
item.className = "c-faq__item";
|
|
452
481
|
if (i === 0) item.setAttribute("open", "");
|
|
@@ -456,7 +485,7 @@ class ContourFaq extends ContourBase {
|
|
|
456
485
|
const sign = document.createElement("span");
|
|
457
486
|
sign.className = "c-faq__sign";
|
|
458
487
|
sign.setAttribute("aria-hidden", "true");
|
|
459
|
-
sign
|
|
488
|
+
setHTML(sign, '<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-plus" /></svg>');
|
|
460
489
|
q.appendChild(sign);
|
|
461
490
|
item.appendChild(q);
|
|
462
491
|
const a = document.createElement("div");
|
|
@@ -476,7 +505,7 @@ class ContourFaq extends ContourBase {
|
|
|
476
505
|
q.textContent = question || "";
|
|
477
506
|
const sign = this.ensure(".c-faq__sign", () => { const el = document.createElement("span"); el.className = "c-faq__sign"; return el; }, q);
|
|
478
507
|
sign.setAttribute("aria-hidden", "true");
|
|
479
|
-
sign
|
|
508
|
+
setHTML(sign, '<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-plus" /></svg>');
|
|
480
509
|
const a = this.ensure(".c-faq__answer", () => { const el = document.createElement("div"); el.className = "c-faq__answer"; return el; }, item);
|
|
481
510
|
a.textContent = answer || "";
|
|
482
511
|
}
|
|
@@ -485,14 +514,12 @@ class ContourFaq extends ContourBase {
|
|
|
485
514
|
}
|
|
486
515
|
define("contour-faq", ContourFaq);
|
|
487
516
|
class ContourAccordion extends ContourBase {
|
|
488
|
-
static get observed() { return ["items", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton", "persist", "exclusive"]; }
|
|
517
|
+
static get observed() { return ["items", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton", "persist", "exclusive", "cache-key", "no-cache"]; }
|
|
489
518
|
static get properties() { return { items: { attribute: "items" }, exclusive: { attribute: "exclusive", type: Boolean }, src: { attribute: "src" } }; }
|
|
490
519
|
render() {
|
|
491
|
-
|
|
492
|
-
// is the block that owns the styling. No .c-accordion rule exists, so the
|
|
493
|
-
// host class is dropped rather than invented.
|
|
520
|
+
// Host is plain container; children carry .c-disclosure styling (no .c-accordion rule).
|
|
494
521
|
if (!this.hasAttribute("role")) this.setAttribute("role", "region");
|
|
495
|
-
if (!this.hasAttribute("aria-label")) this.setAttribute("aria-label", "Accordion");
|
|
522
|
+
if (!this.hasAttribute("aria-label")) this.setAttribute("aria-label", labelText(this, "accordion", "Accordion"));
|
|
496
523
|
const authored = Array.from(this.children).filter((n) => n.tagName === "DETAILS");
|
|
497
524
|
wireStates(this);
|
|
498
525
|
loadRemote(this, "items");
|
|
@@ -574,8 +601,12 @@ class ContourAccordion extends ContourBase {
|
|
|
574
601
|
}
|
|
575
602
|
define("contour-accordion", ContourAccordion);
|
|
576
603
|
class ContourDrawer extends ContourBase {
|
|
577
|
-
static get observed() { return ["title", "body", "size"]; }
|
|
604
|
+
static get observed() { return ["title", "body", "size", "open"]; }
|
|
578
605
|
static get properties() { return { title: { attribute: "title" }, body: { attribute: "body" }, size: { attribute: "size" } }; }
|
|
606
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
607
|
+
if (name === "open") { syncDeclarativeOpen(this, name, newValue, this._wiredDrawer); return; }
|
|
608
|
+
super.attributeChangedCallback(name, oldValue, newValue);
|
|
609
|
+
}
|
|
579
610
|
// Native-dialog parity (R20 T-32), same contract as contour-dialog.
|
|
580
611
|
showModal() { this.show(); }
|
|
581
612
|
get open() { return this.hasAttribute("open"); }
|
|
@@ -598,29 +629,38 @@ class ContourDrawer extends ContourBase {
|
|
|
598
629
|
const closeBtn = document.createElement("button");
|
|
599
630
|
closeBtn.className = "c-btn c-btn--icon c-btn--ghost c-drawer__close";
|
|
600
631
|
closeBtn.setAttribute("type", "button");
|
|
601
|
-
closeBtn.setAttribute("aria-label", "Close");
|
|
602
|
-
closeBtn
|
|
632
|
+
closeBtn.setAttribute("aria-label", labelText(this, "close", "Close"));
|
|
633
|
+
setHTML(closeBtn, '<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-x" /></svg>');
|
|
603
634
|
head.appendChild(closeBtn);
|
|
604
635
|
}
|
|
605
636
|
const t = head.querySelector(".c-drawer__title");
|
|
606
|
-
if (t) { t.textContent = title; if (!t.id) t.id = "contour-drawer-title
|
|
637
|
+
if (t) { t.textContent = title; if (!t.id) t.id = contourId("contour-drawer-title"); this.setAttribute("aria-labelledby", t.id); }
|
|
607
638
|
if (head.parentNode !== this) this.prepend(head);
|
|
608
639
|
} else if (head) {
|
|
640
|
+
// The generated head is going away, so a label that points at its
|
|
641
|
+
// title would dangle. Drop it only when it names the title we remove.
|
|
642
|
+
const t = head.querySelector(".c-drawer__title");
|
|
643
|
+
if (t && t.id && this.getAttribute("aria-labelledby") === t.id) this.removeAttribute("aria-labelledby");
|
|
609
644
|
head.remove();
|
|
610
645
|
}
|
|
611
|
-
|
|
612
|
-
// cannot re-enter the render — see the dialog); the `.is-open` class the
|
|
613
|
-
// CSS keys off is re-derived here because the base restores the authored
|
|
614
|
-
// class on every render and would otherwise drop it mid-lock.
|
|
646
|
+
// open state re-derived each render; base restores authored class.
|
|
615
647
|
if (this.hasAttribute("open")) this.classList.add("is-open"); else this.classList.remove("is-open");
|
|
648
|
+
// authored children move into .c-drawer__body; body attr fills if none.
|
|
616
649
|
const body = this.getAttribute("body");
|
|
617
|
-
const
|
|
618
|
-
|
|
619
|
-
|
|
650
|
+
const authored = Array.from(this.childNodes).filter((n) => {
|
|
651
|
+
if (n.nodeType === 1 && n.classList && (n.classList.contains("c-drawer__head") || n.classList.contains("c-drawer__body"))) return false;
|
|
652
|
+
if (n.nodeType === 3 && !n.textContent.trim()) return false;
|
|
653
|
+
return true;
|
|
654
|
+
});
|
|
655
|
+
if (authored.length) {
|
|
620
656
|
const el = this.ensure(".c-drawer__body", () => { const e = document.createElement("div"); e.className = "c-drawer__body"; return e; });
|
|
621
|
-
el.
|
|
622
|
-
} else if (
|
|
623
|
-
|
|
657
|
+
for (const n of authored) el.appendChild(n);
|
|
658
|
+
} else if (body) {
|
|
659
|
+
const el = this.ensure(".c-drawer__body", () => { const e = document.createElement("div"); e.className = "c-drawer__body"; return e; });
|
|
660
|
+
setHTML(el, sanitizeHtml(body));
|
|
661
|
+
} else {
|
|
662
|
+
const b = this.querySelector(".c-drawer__body");
|
|
663
|
+
if (b) b.remove();
|
|
624
664
|
}
|
|
625
665
|
}
|
|
626
666
|
enhance() {
|
|
@@ -632,7 +672,10 @@ class ContourDrawer extends ContourBase {
|
|
|
632
672
|
this.show = () => {
|
|
633
673
|
if (this.hasAttribute("open")) return;
|
|
634
674
|
this._drawerLastFocus = document.activeElement;
|
|
635
|
-
|
|
675
|
+
// Guard our own `open` write (see ContourDialog.show): re-entry doubles
|
|
676
|
+
// contour:open and leaks a modalContain depth.
|
|
677
|
+
this._declarativeOpen = true;
|
|
678
|
+
try { this.setAttribute("open", ""); } finally { this._declarativeOpen = false; }
|
|
636
679
|
this.setAttribute("aria-modal", "true");
|
|
637
680
|
this.classList.add("is-open");
|
|
638
681
|
modalContain(this, true);
|
|
@@ -641,8 +684,13 @@ class ContourDrawer extends ContourBase {
|
|
|
641
684
|
this.dispatchEvent(new CustomEvent("contour:open", { bubbles: true, composed: true }));
|
|
642
685
|
};
|
|
643
686
|
this.close = () => {
|
|
644
|
-
|
|
645
|
-
|
|
687
|
+
// `open` may already be gone via syncDeclarativeOpen; an engaged modal
|
|
688
|
+
// (aria-modal set) must still release its inert siblings.
|
|
689
|
+
if (!this.hasAttribute("open") && !this.hasAttribute("aria-modal")) return;
|
|
690
|
+
// Guard our own `open` removal (see ContourDialog.close): re-entry
|
|
691
|
+
// doubles the close event and the modalContain release.
|
|
692
|
+
this._declarativeOpen = true;
|
|
693
|
+
try { this.removeAttribute("open"); } finally { this._declarativeOpen = false; }
|
|
646
694
|
this.removeAttribute("aria-modal");
|
|
647
695
|
this.classList.remove("is-open");
|
|
648
696
|
modalContain(this, false);
|
|
@@ -673,12 +721,17 @@ class ContourDrawer extends ContourBase {
|
|
|
673
721
|
const dy = t.clientY - touchStartY;
|
|
674
722
|
if (Math.abs(dx) > 60 && Math.abs(dx) > Math.abs(dy) * 1.5) this.close();
|
|
675
723
|
}, { passive: true });
|
|
724
|
+
engageInitialModal(this);
|
|
676
725
|
}
|
|
677
726
|
}
|
|
678
727
|
define("contour-drawer", ContourDrawer);
|
|
679
728
|
class ContourSheet extends ContourBase {
|
|
680
|
-
static get observed() { return ["title", "body", "size"]; }
|
|
729
|
+
static get observed() { return ["title", "body", "size", "open"]; }
|
|
681
730
|
static get properties() { return { title: { attribute: "title" }, body: { attribute: "body" }, size: { attribute: "size" } }; }
|
|
731
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
732
|
+
if (name === "open") { syncDeclarativeOpen(this, name, newValue, this._wiredSheet); return; }
|
|
733
|
+
super.attributeChangedCallback(name, oldValue, newValue);
|
|
734
|
+
}
|
|
682
735
|
// Native-dialog parity (R20 T-32), same contract as contour-dialog.
|
|
683
736
|
showModal() { this.show(); }
|
|
684
737
|
get open() { return this.hasAttribute("open"); }
|
|
@@ -701,28 +754,38 @@ class ContourSheet extends ContourBase {
|
|
|
701
754
|
const closeBtn = document.createElement("button");
|
|
702
755
|
closeBtn.className = "c-btn c-btn--icon c-btn--ghost c-sheet__close";
|
|
703
756
|
closeBtn.setAttribute("type", "button");
|
|
704
|
-
closeBtn.setAttribute("aria-label", "Close");
|
|
705
|
-
closeBtn
|
|
757
|
+
closeBtn.setAttribute("aria-label", labelText(this, "close", "Close"));
|
|
758
|
+
setHTML(closeBtn, '<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-x" /></svg>');
|
|
706
759
|
head.appendChild(closeBtn);
|
|
707
760
|
}
|
|
708
761
|
const t = head.querySelector(".c-sheet__title");
|
|
709
|
-
if (t) { t.textContent = title; if (!t.id) t.id = "contour-sheet-title
|
|
762
|
+
if (t) { t.textContent = title; if (!t.id) t.id = contourId("contour-sheet-title"); this.setAttribute("aria-labelledby", t.id); }
|
|
710
763
|
if (head.parentNode !== this) this.prepend(head);
|
|
711
764
|
} else if (head) {
|
|
765
|
+
// The generated head is going away, so a label that points at its
|
|
766
|
+
// title would dangle. Drop it only when it names the title we remove.
|
|
767
|
+
const t = head.querySelector(".c-sheet__title");
|
|
768
|
+
if (t && t.id && this.getAttribute("aria-labelledby") === t.id) this.removeAttribute("aria-labelledby");
|
|
712
769
|
head.remove();
|
|
713
770
|
}
|
|
714
|
-
|
|
715
|
-
// cannot re-enter the render); the `.is-open` class is re-derived because
|
|
716
|
-
// the base restores the authored class on every render (see the drawer).
|
|
771
|
+
// open state re-derived each render (see drawer).
|
|
717
772
|
if (this.hasAttribute("open")) this.classList.add("is-open"); else this.classList.remove("is-open");
|
|
773
|
+
// authored children move into .c-sheet__body; body attr fills if none.
|
|
718
774
|
const body = this.getAttribute("body");
|
|
719
|
-
const
|
|
720
|
-
|
|
721
|
-
|
|
775
|
+
const authored = Array.from(this.childNodes).filter((n) => {
|
|
776
|
+
if (n.nodeType === 1 && n.classList && (n.classList.contains("c-sheet__head") || n.classList.contains("c-sheet__body"))) return false;
|
|
777
|
+
if (n.nodeType === 3 && !n.textContent.trim()) return false;
|
|
778
|
+
return true;
|
|
779
|
+
});
|
|
780
|
+
if (authored.length) {
|
|
722
781
|
const el = this.ensure(".c-sheet__body", () => { const e = document.createElement("div"); e.className = "c-sheet__body"; return e; });
|
|
723
|
-
el.
|
|
724
|
-
} else if (
|
|
725
|
-
|
|
782
|
+
for (const n of authored) el.appendChild(n);
|
|
783
|
+
} else if (body) {
|
|
784
|
+
const el = this.ensure(".c-sheet__body", () => { const e = document.createElement("div"); e.className = "c-sheet__body"; return e; });
|
|
785
|
+
setHTML(el, sanitizeHtml(body));
|
|
786
|
+
} else {
|
|
787
|
+
const b = this.querySelector(".c-sheet__body");
|
|
788
|
+
if (b) b.remove();
|
|
726
789
|
}
|
|
727
790
|
}
|
|
728
791
|
enhance() {
|
|
@@ -734,7 +797,10 @@ class ContourSheet extends ContourBase {
|
|
|
734
797
|
this.show = () => {
|
|
735
798
|
if (this.hasAttribute("open")) return;
|
|
736
799
|
this._sheetLastFocus = document.activeElement;
|
|
737
|
-
|
|
800
|
+
// Guard our own `open` write (see ContourDialog.show): re-entry doubles
|
|
801
|
+
// contour:open and leaks a modalContain depth.
|
|
802
|
+
this._declarativeOpen = true;
|
|
803
|
+
try { this.setAttribute("open", ""); } finally { this._declarativeOpen = false; }
|
|
738
804
|
this.setAttribute("aria-modal", "true");
|
|
739
805
|
this.classList.add("is-open");
|
|
740
806
|
modalContain(this, true);
|
|
@@ -743,8 +809,13 @@ class ContourSheet extends ContourBase {
|
|
|
743
809
|
this.dispatchEvent(new CustomEvent("contour:open", { bubbles: true, composed: true }));
|
|
744
810
|
};
|
|
745
811
|
this.close = () => {
|
|
746
|
-
|
|
747
|
-
|
|
812
|
+
// `open` may already be gone via syncDeclarativeOpen; an engaged modal
|
|
813
|
+
// (aria-modal set) must still release its inert siblings.
|
|
814
|
+
if (!this.hasAttribute("open") && !this.hasAttribute("aria-modal")) return;
|
|
815
|
+
// Guard our own `open` removal (see ContourDialog.close): re-entry
|
|
816
|
+
// doubles the close event and the modalContain release.
|
|
817
|
+
this._declarativeOpen = true;
|
|
818
|
+
try { this.removeAttribute("open"); } finally { this._declarativeOpen = false; }
|
|
748
819
|
this.removeAttribute("aria-modal");
|
|
749
820
|
this.classList.remove("is-open");
|
|
750
821
|
modalContain(this, false);
|
|
@@ -775,11 +846,12 @@ class ContourSheet extends ContourBase {
|
|
|
775
846
|
const dx = t.clientX - touchStartX;
|
|
776
847
|
if (dy > 60 && Math.abs(dy) > Math.abs(dx) * 1.5) this.close();
|
|
777
848
|
}, { passive: true });
|
|
849
|
+
engageInitialModal(this);
|
|
778
850
|
}
|
|
779
851
|
}
|
|
780
852
|
define("contour-sheet", ContourSheet);
|
|
781
853
|
class ContourToast extends ContourBase {
|
|
782
|
-
static get observed() { return ["message", "variant", "duration", "action"]; }
|
|
854
|
+
static get observed() { return ["message", "variant", "duration", "action", "icon"]; }
|
|
783
855
|
static get properties() { return { message: { attribute: "message" }, variant: { attribute: "variant" }, duration: { attribute: "duration", type: Number }, action: { attribute: "action" } }; }
|
|
784
856
|
render() {
|
|
785
857
|
this.classList.add("c-toast");
|
|
@@ -793,6 +865,16 @@ class ContourToast extends ContourBase {
|
|
|
793
865
|
const variant = this.getAttribute("variant");
|
|
794
866
|
Array.from(this.classList).forEach((c) => { if (c.startsWith("c-toast--")) this.classList.remove(c); });
|
|
795
867
|
if (variant) this.classList.add("c-toast--" + variant);
|
|
868
|
+
const iconAttr = this.getAttribute("icon");
|
|
869
|
+
const icon = iconAttr === "none" ? "" : (iconAttr || statusIcon(variant));
|
|
870
|
+
let ic = this.querySelector(".c-toast__icon");
|
|
871
|
+
if (icon) {
|
|
872
|
+
if (!ic) { ic = document.createElement("span"); ic.className = "c-toast__icon"; }
|
|
873
|
+
setHTML(ic, '<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#' + String(icon).replace(/[^a-zA-Z0-9_-]/g, "") + '" /></svg>');
|
|
874
|
+
if (this.firstChild !== ic) this.prepend(ic);
|
|
875
|
+
} else if (ic) {
|
|
876
|
+
ic.remove();
|
|
877
|
+
}
|
|
796
878
|
// Action button (e.g. "Undo"): scaffold from `action` attribute.
|
|
797
879
|
const action = this.getAttribute("action");
|
|
798
880
|
let btn = this.querySelector(".c-toast__action");
|
|
@@ -802,17 +884,69 @@ class ContourToast extends ContourBase {
|
|
|
802
884
|
} else if (btn) {
|
|
803
885
|
btn.remove();
|
|
804
886
|
}
|
|
887
|
+
// R31-65: a toast the reader cannot dismiss is a notification, not a
|
|
888
|
+
// message. The close action is part of the component at every duration.
|
|
889
|
+
let close = this.querySelector(".c-toast__close");
|
|
890
|
+
if (!close) {
|
|
891
|
+
close = document.createElement("button");
|
|
892
|
+
close.className = "c-toast__close";
|
|
893
|
+
close.type = "button";
|
|
894
|
+
close.setAttribute("aria-label", labelText(this, "close", "Close"));
|
|
895
|
+
close.textContent = "×";
|
|
896
|
+
this.appendChild(close);
|
|
897
|
+
}
|
|
805
898
|
}
|
|
806
899
|
enhance() {
|
|
807
900
|
if (this._wiredToast) return;
|
|
808
901
|
this._wiredToast = true;
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
if (
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
902
|
+
this.addEventListener("click", (e) => {
|
|
903
|
+
const close = e.target && e.target.closest ? e.target.closest(".c-toast__close") : null;
|
|
904
|
+
if (close) { e.preventDefault(); this._dismiss(); }
|
|
905
|
+
});
|
|
906
|
+
const pause = () => { clearTimeout(this._toastTimer); this._toastTimer = null; };
|
|
907
|
+
this.addEventListener("mouseenter", pause);
|
|
908
|
+
this.addEventListener("focusin", pause);
|
|
909
|
+
this.addEventListener("mouseleave", () => this._arm());
|
|
910
|
+
this.addEventListener("focusout", () => this._arm());
|
|
911
|
+
this._arm();
|
|
912
|
+
onDispose(this, () => clearTimeout(this._toastTimer));
|
|
913
|
+
}
|
|
914
|
+
_durationMs() {
|
|
915
|
+
const raw = (this._toastDuration != null) ? Number(this._toastDuration) : Number(this.duration);
|
|
916
|
+
if (raw === 0) return 0;
|
|
917
|
+
return raw > 0 ? raw : 4000;
|
|
918
|
+
}
|
|
919
|
+
_arm() {
|
|
920
|
+
clearTimeout(this._toastTimer);
|
|
921
|
+
this._toastTimer = null;
|
|
922
|
+
const ms = this._durationMs();
|
|
923
|
+
if (ms > 0) this._toastTimer = setTimeout(() => this._dismiss(), ms);
|
|
924
|
+
}
|
|
925
|
+
_dismiss() {
|
|
926
|
+
clearTimeout(this._toastTimer);
|
|
927
|
+
this._toastTimer = null;
|
|
928
|
+
this.setAttribute("hidden", "");
|
|
929
|
+
this.dispatchEvent(new CustomEvent("contour:close", { bubbles: true, composed: true }));
|
|
930
|
+
}
|
|
931
|
+
// Re-show a toast (e.g. from a trigger button): paint content directly
|
|
932
|
+
// (no observed-attribute writes, which would re-enter render), un-hide and
|
|
933
|
+
// restart the auto-dismiss timer. A bare toast hides rather than removing
|
|
934
|
+
// itself so a specimen — or a host that re-uses the node — can show it again.
|
|
935
|
+
show(message, opts) {
|
|
936
|
+
const msg = message != null ? String(message) : this.getAttribute("message");
|
|
937
|
+
const variant = (opts && opts.variant) || this.getAttribute("variant");
|
|
938
|
+
const action = (opts && opts.action) || this.getAttribute("action");
|
|
939
|
+
if (msg && !this.hasChildNodes()) this.textContent = msg;
|
|
940
|
+
Array.from(this.classList).forEach((c) => { if (c.startsWith("c-toast--")) this.classList.remove(c); });
|
|
941
|
+
if (variant) this.classList.add("c-toast--" + variant);
|
|
942
|
+
let btn = this.querySelector(".c-toast__action");
|
|
943
|
+
if (action) {
|
|
944
|
+
if (!btn) { btn = document.createElement("button"); btn.className = "c-toast__action"; btn.type = "button"; this.appendChild(btn); }
|
|
945
|
+
btn.textContent = action;
|
|
946
|
+
} else if (btn) btn.remove();
|
|
947
|
+
if (opts && opts.duration != null) this._toastDuration = Number(opts.duration);
|
|
948
|
+
this.removeAttribute("hidden");
|
|
949
|
+
this._arm();
|
|
816
950
|
}
|
|
817
951
|
}
|
|
818
952
|
define("contour-toast", ContourToast);
|
|
@@ -852,15 +986,15 @@ class ContourExpandable extends ContourBase {
|
|
|
852
986
|
d.appendChild(summ);
|
|
853
987
|
const content = document.createElement("div");
|
|
854
988
|
content.className = "c-expandable__body";
|
|
855
|
-
content
|
|
989
|
+
setHTML(content, captured);
|
|
856
990
|
d.appendChild(content);
|
|
857
991
|
return d;
|
|
858
992
|
});
|
|
859
993
|
const summ = details.querySelector("summary");
|
|
860
994
|
if (summ) summ.textContent = summary;
|
|
861
995
|
const body = details.querySelector(".c-expandable__body");
|
|
862
|
-
if (body) body
|
|
863
|
-
if (details.parentNode !== this) { this
|
|
996
|
+
if (body) setHTML(body, captured);
|
|
997
|
+
if (details.parentNode !== this) { setHTML(this, ""); this.appendChild(details); }
|
|
864
998
|
} else {
|
|
865
999
|
const details = this.querySelector("details");
|
|
866
1000
|
if (details) details.remove();
|
|
@@ -883,7 +1017,7 @@ class ContourToastHost extends ContourBase {
|
|
|
883
1017
|
render() {
|
|
884
1018
|
this.classList.add("c-toast-host");
|
|
885
1019
|
if (!this.hasAttribute("role")) this.setAttribute("role", "status");
|
|
886
|
-
if (!this.hasAttribute("aria-label")) this.setAttribute("aria-label", "Toast host");
|
|
1020
|
+
if (!this.hasAttribute("aria-label")) this.setAttribute("aria-label", labelText(this, "toast-host", "Toast host"));
|
|
887
1021
|
if (!this.hasAttribute("aria-live")) this.setAttribute("aria-live", "polite");
|
|
888
1022
|
if (!this.hasAttribute("aria-atomic")) this.setAttribute("aria-atomic", "true");
|
|
889
1023
|
}
|
|
@@ -900,6 +1034,13 @@ class ContourToastHost extends ContourBase {
|
|
|
900
1034
|
toast.setAttribute("aria-live", "polite");
|
|
901
1035
|
toast.setAttribute("aria-atomic", "true");
|
|
902
1036
|
if (opts.variant) toast.classList.add("c-toast--" + opts.variant);
|
|
1037
|
+
const icon = statusIcon(opts.variant);
|
|
1038
|
+
if (icon) {
|
|
1039
|
+
const ic = document.createElement("span");
|
|
1040
|
+
ic.className = "c-toast__icon";
|
|
1041
|
+
setHTML(ic, '<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#' + icon + '" /></svg>');
|
|
1042
|
+
toast.appendChild(ic);
|
|
1043
|
+
}
|
|
903
1044
|
toast.dataset.message = message == null ? "" : String(message);
|
|
904
1045
|
const text = document.createElement("span");
|
|
905
1046
|
text.className = "c-toast__text";
|
|
@@ -920,6 +1061,23 @@ class ContourToastHost extends ContourBase {
|
|
|
920
1061
|
});
|
|
921
1062
|
toast.appendChild(btn);
|
|
922
1063
|
}
|
|
1064
|
+
const close = document.createElement("button");
|
|
1065
|
+
close.type = "button";
|
|
1066
|
+
close.className = "c-toast__close";
|
|
1067
|
+
close.setAttribute("aria-label", labelText(this, "close", "Close"));
|
|
1068
|
+
close.textContent = "×";
|
|
1069
|
+
toast.appendChild(close);
|
|
1070
|
+
close.addEventListener("click", (e) => { e.stopPropagation(); dismiss(toast); });
|
|
1071
|
+
toast._arm = () => {
|
|
1072
|
+
clearTimeout(toast._timer);
|
|
1073
|
+
const d = opts.duration;
|
|
1074
|
+
const ms = d === 0 ? 0 : (d > 0 ? d : 4000);
|
|
1075
|
+
if (ms > 0) toast._timer = setTimeout(() => dismiss(toast), ms);
|
|
1076
|
+
};
|
|
1077
|
+
toast.addEventListener("mouseenter", () => clearTimeout(toast._timer));
|
|
1078
|
+
toast.addEventListener("focusin", () => clearTimeout(toast._timer));
|
|
1079
|
+
toast.addEventListener("mouseleave", toast._arm);
|
|
1080
|
+
toast.addEventListener("focusout", toast._arm);
|
|
923
1081
|
return toast;
|
|
924
1082
|
};
|
|
925
1083
|
const dismiss = (toast) => {
|
|
@@ -931,19 +1089,16 @@ class ContourToastHost extends ContourBase {
|
|
|
931
1089
|
pump();
|
|
932
1090
|
};
|
|
933
1091
|
const pump = () => {
|
|
934
|
-
|
|
935
|
-
//
|
|
1092
|
+
// R31-65: stack independent messages; each toast owns its timer and
|
|
1093
|
+
// close button. A host-level queue still dedups identical messages.
|
|
936
1094
|
while (this._toastQueue.length) {
|
|
937
1095
|
const next = this._toastQueue.shift();
|
|
938
1096
|
if (next._deduped) continue;
|
|
939
1097
|
const toast = buildToast(next.message, next.opts);
|
|
940
1098
|
this._toastActive = toast;
|
|
941
1099
|
this.appendChild(toast);
|
|
942
|
-
|
|
943
|
-
toast._timer = setTimeout(() => dismiss(toast), ms);
|
|
944
|
-
return;
|
|
1100
|
+
toast._arm();
|
|
945
1101
|
}
|
|
946
|
-
this._toastActive = null;
|
|
947
1102
|
};
|
|
948
1103
|
this.show = (message, opts) => {
|
|
949
1104
|
opts = opts || {};
|
|
@@ -952,7 +1107,7 @@ class ContourToastHost extends ContourBase {
|
|
|
952
1107
|
const active = this._toastActive;
|
|
953
1108
|
if (active && active.dataset && active.dataset.message === key && key !== "") {
|
|
954
1109
|
if (active._timer) { clearTimeout(active._timer); }
|
|
955
|
-
const ms = (opts.duration && opts.duration > 0) ? opts.duration :
|
|
1110
|
+
const ms = (opts.duration && opts.duration > 0) ? opts.duration : 4000;
|
|
956
1111
|
active._timer = setTimeout(() => dismiss(active), ms);
|
|
957
1112
|
return active;
|
|
958
1113
|
}
|