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/interaction.mjs
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { ContourBase, define, onDispose } from './core.mjs';
|
|
2
|
-
import { wireSegmented } from './behaviours.mjs';
|
|
1
|
+
import { setHTML, ContourBase, define, onDispose , flagOn, warnBadJson, safeHref, labelText } from './core.mjs';
|
|
2
|
+
import { wireSegmented, modalContain } from './behaviours.mjs';
|
|
3
3
|
class ContourPressableFull extends ContourBase {
|
|
4
|
-
static get observed() { return ["disabled"]; }
|
|
4
|
+
static get observed() { return ["disabled", "label"]; }
|
|
5
5
|
static get properties() { return { disabled: { attribute: "disabled", type: Boolean } }; }
|
|
6
6
|
render() {
|
|
7
7
|
this.classList.add("c-pressable");
|
|
8
8
|
if (!this.hasAttribute("role")) this.setAttribute("role", "button");
|
|
9
|
+
if (!this.hasAttribute("aria-label")) this.setAttribute("aria-label", this.getAttribute("label") || "Pressable");
|
|
9
10
|
if (this.hasAttribute("disabled")) {
|
|
10
11
|
this.setAttribute("aria-disabled", "true");
|
|
11
12
|
this.setAttribute("tabindex", "-1");
|
|
@@ -17,7 +18,13 @@ class ContourPressableFull extends ContourBase {
|
|
|
17
18
|
enhance() {
|
|
18
19
|
if (this._wiredPressable) return;
|
|
19
20
|
this._wiredPressable = true;
|
|
21
|
+
// disabled pressable must not activate (capture phase fires first).
|
|
22
|
+
const isDisabled = () => this.hasAttribute("disabled") || this.getAttribute("aria-disabled") === "true";
|
|
23
|
+
this.addEventListener("click", (e) => {
|
|
24
|
+
if (isDisabled()) { e.preventDefault(); e.stopImmediatePropagation(); }
|
|
25
|
+
}, true);
|
|
20
26
|
this.addEventListener("keydown", (e) => {
|
|
27
|
+
if (isDisabled()) { e.preventDefault(); e.stopImmediatePropagation(); return; }
|
|
21
28
|
if (e.key === "Enter" || e.key === " ") { e.preventDefault(); this.click(); this.dispatchEvent(new CustomEvent("contour:activate", { bubbles: true, composed: true })); }
|
|
22
29
|
});
|
|
23
30
|
}
|
|
@@ -27,10 +34,30 @@ class ContourResizeHandleFull extends ContourBase {
|
|
|
27
34
|
render() {
|
|
28
35
|
this.classList.add("c-resize-handle");
|
|
29
36
|
if (!this.hasAttribute("role")) this.setAttribute("role", "separator");
|
|
30
|
-
if (!this.hasAttribute("aria-
|
|
37
|
+
if (!this.hasAttribute("aria-valuenow")) this.setAttribute("aria-valuenow", "0");
|
|
38
|
+
if (!this.hasAttribute("aria-label")) this.setAttribute("aria-label", labelText(this, "resize-handle", "Resize handle"));
|
|
31
39
|
if (!this.hasAttribute("tabindex")) this.setAttribute("tabindex", "0");
|
|
32
40
|
if (!this.hasAttribute("aria-orientation")) this.setAttribute("aria-orientation", "horizontal");
|
|
33
41
|
}
|
|
42
|
+
enhance() {
|
|
43
|
+
if (this._wiredResizeHandle) return;
|
|
44
|
+
this._wiredResizeHandle = true;
|
|
45
|
+
// Keyboard resize: arrows nudge 5%, Home/End to min/max; dispatches contour:resize.
|
|
46
|
+
this.addEventListener("keydown", (e) => {
|
|
47
|
+
// Home/End send finite delta (±Infinity serialises to null).
|
|
48
|
+
const cur = Number(this.getAttribute("aria-valuenow")) || 0;
|
|
49
|
+
let delta = 0;
|
|
50
|
+
if (e.key === "ArrowLeft" || e.key === "ArrowDown") delta = -5;
|
|
51
|
+
else if (e.key === "ArrowRight" || e.key === "ArrowUp") delta = 5;
|
|
52
|
+
else if (e.key === "Home") delta = -cur; // jump to min (0)
|
|
53
|
+
else if (e.key === "End") delta = 100 - cur; // jump to max (100)
|
|
54
|
+
else return;
|
|
55
|
+
e.preventDefault();
|
|
56
|
+
const next = Math.min(100, Math.max(0, cur + delta));
|
|
57
|
+
this.setAttribute("aria-valuenow", String(next));
|
|
58
|
+
this.dispatchEvent(new CustomEvent("contour:resize", { bubbles: true, composed: true, detail: { value: next, delta } }));
|
|
59
|
+
});
|
|
60
|
+
}
|
|
34
61
|
}
|
|
35
62
|
define("contour-resize-handle", ContourResizeHandleFull);
|
|
36
63
|
class ContourSearchTriggerFull extends ContourBase {
|
|
@@ -57,7 +84,7 @@ class ContourShortcutListFull extends ContourBase {
|
|
|
57
84
|
this.setAttribute("role", "list");
|
|
58
85
|
const title = this.getAttribute("title");
|
|
59
86
|
if (title) {
|
|
60
|
-
const t = this.ensure(".c-shortcut-list__title", () => { const el = document.createElement("div"); el.className = "c-shortcut-list__title";
|
|
87
|
+
const t = this.ensure(".c-shortcut-list__title", () => { const el = document.createElement("div"); el.className = "c-shortcut-list__title"; return el; });
|
|
61
88
|
t.textContent = title;
|
|
62
89
|
}
|
|
63
90
|
}
|
|
@@ -68,7 +95,8 @@ class ContourShortcutRowFull extends ContourBase {
|
|
|
68
95
|
static get properties() { return { desc: { attribute: "desc" }, key: { attribute: "key" } }; }
|
|
69
96
|
render() {
|
|
70
97
|
this.classList.add("c-shortcut-row");
|
|
71
|
-
|
|
98
|
+
// rows get role=listitem so list > listitem is valid.
|
|
99
|
+
if (!this.hasAttribute("role")) this.setAttribute("role", "listitem");
|
|
72
100
|
const key = this.getAttribute("key");
|
|
73
101
|
const desc = this.getAttribute("desc");
|
|
74
102
|
if (key) {
|
|
@@ -107,10 +135,13 @@ class ContourShortcutPanelFull extends ContourBase {
|
|
|
107
135
|
}
|
|
108
136
|
define("contour-shortcut-panel", ContourShortcutPanelFull);
|
|
109
137
|
class ContourShortcutOverlayFull extends ContourBase {
|
|
110
|
-
static get observed() { return ["title", "open"]; }
|
|
111
|
-
static get properties() { return { title: { attribute: "title" }, open: { attribute: "open", type: Boolean } }; }
|
|
138
|
+
static get observed() { return ["title", "open", "keybind"]; }
|
|
139
|
+
static get properties() { return { title: { attribute: "title" }, open: { attribute: "open", type: Boolean }, keybind: { attribute: "keybind" } }; }
|
|
112
140
|
render() {
|
|
113
141
|
this.classList.add("c-shortcut-overlay");
|
|
142
|
+
if (!this.hasAttribute("role")) this.setAttribute("role", "dialog");
|
|
143
|
+
if (!this.hasAttribute("aria-modal")) this.setAttribute("aria-modal", "true");
|
|
144
|
+
if (!this.hasAttribute("aria-label")) this.setAttribute("aria-label", this.getAttribute("title") || "Keyboard shortcuts");
|
|
114
145
|
const title = this.getAttribute("title");
|
|
115
146
|
if (title) {
|
|
116
147
|
const t = this.ensure(".c-shortcut-overlay__title", () => { const el = document.createElement("div"); el.className = "c-shortcut-overlay__title"; return el; });
|
|
@@ -119,15 +150,35 @@ class ContourShortcutPanelFull extends ContourBase {
|
|
|
119
150
|
if (this.hasAttribute("open")) this.removeAttribute("hidden");
|
|
120
151
|
else if (!this.hasAttribute("hidden")) this.setAttribute("hidden", "");
|
|
121
152
|
}
|
|
122
|
-
show() {
|
|
123
|
-
|
|
153
|
+
show() {
|
|
154
|
+
// R31-73: re-entry (a keydown plus a click) must not stack the modal lock.
|
|
155
|
+
if (this.hasAttribute("open")) return;
|
|
156
|
+
// capture opener, focus first focusable element.
|
|
157
|
+
this._opener = document.activeElement;
|
|
158
|
+
this.setAttribute("open", "");
|
|
159
|
+
this.removeAttribute("hidden");
|
|
160
|
+
modalContain(this, true);
|
|
161
|
+
this.dispatchEvent(new CustomEvent("contour:open", { bubbles: true, composed: true }));
|
|
162
|
+
const first = this.querySelector("button, [href], input, select, textarea, [tabindex]:not([tabindex='-1'])");
|
|
163
|
+
if (first) first.focus();
|
|
164
|
+
}
|
|
165
|
+
hide() {
|
|
166
|
+
if (!this.hasAttribute("open")) return;
|
|
167
|
+
this.removeAttribute("open");
|
|
168
|
+
this.setAttribute("hidden", "");
|
|
169
|
+
modalContain(this, false);
|
|
170
|
+
this.dispatchEvent(new CustomEvent("contour:close", { bubbles: true, composed: true }));
|
|
171
|
+
// restore focus to the element that opened the overlay.
|
|
172
|
+
if (this._opener && typeof this._opener.focus === "function") this._opener.focus();
|
|
173
|
+
this._opener = null;
|
|
174
|
+
}
|
|
124
175
|
toggle() { if (this.hasAttribute("open")) this.hide(); else this.show(); }
|
|
125
176
|
enhance() {
|
|
126
177
|
if (this._wiredShortcutOverlay) return;
|
|
127
178
|
this._wiredShortcutOverlay = true;
|
|
128
|
-
|
|
179
|
+
// `keybind` opts into global "?" toggle: absent=off, bare=on, "false"=off. Escape closes while open regardless.
|
|
129
180
|
const keyHandler = (e) => {
|
|
130
|
-
if (e.key === "?" && !e.metaKey && !e.ctrlKey && !e.altKey) {
|
|
181
|
+
if (e.key === "?" && flagOn(this, "keybind") && !e.metaKey && !e.ctrlKey && !e.altKey) {
|
|
131
182
|
const tag = (e.target && e.target.tagName) || "";
|
|
132
183
|
if (tag === "INPUT" || tag === "TEXTAREA" || (e.target && e.target.isContentEditable)) return;
|
|
133
184
|
e.preventDefault();
|
|
@@ -159,27 +210,33 @@ class ContourRowActionFull extends ContourBase {
|
|
|
159
210
|
}
|
|
160
211
|
const label = this.getAttribute("label");
|
|
161
212
|
if (label && !this.hasChildNodes()) this.textContent = label;
|
|
213
|
+
if (label && !this.hasAttribute("aria-label")) this.setAttribute("aria-label", label);
|
|
162
214
|
}
|
|
163
215
|
enhance() {
|
|
164
216
|
if (this._wiredRowAction) return;
|
|
165
217
|
this._wiredRowAction = true;
|
|
218
|
+
// disabled activation guard (same pattern as c-btn).
|
|
219
|
+
const isDisabled = () => this.hasAttribute("disabled") || this.getAttribute("aria-disabled") === "true";
|
|
220
|
+
this.addEventListener("click", (e) => {
|
|
221
|
+
if (isDisabled()) { e.preventDefault(); e.stopImmediatePropagation(); }
|
|
222
|
+
}, true);
|
|
166
223
|
this.addEventListener("keydown", (e) => {
|
|
224
|
+
if (isDisabled()) { e.preventDefault(); e.stopImmediatePropagation(); return; }
|
|
167
225
|
if (e.key === "Enter" || e.key === " ") { e.preventDefault(); this.click(); this.dispatchEvent(new CustomEvent("contour:activate", { bubbles: true, composed: true })); }
|
|
168
226
|
});
|
|
169
227
|
}
|
|
170
228
|
}
|
|
171
229
|
define("contour-row-action", ContourRowActionFull);
|
|
172
230
|
class ContourSegmented extends ContourBase {
|
|
173
|
-
static get observed() { return ["options", "selected", "label", "value"]; }
|
|
174
|
-
static get properties() { return { options: { attribute: "options" }, selected: { attribute: "selected" }, label: { attribute: "label" }, value: { attribute: "value" } }; }
|
|
231
|
+
static get observed() { return ["options", "items", "selected", "label", "value"]; }
|
|
232
|
+
static get properties() { return { options: { attribute: "options" }, items: { attribute: "items" }, selected: { attribute: "selected" }, label: { attribute: "label" }, value: { attribute: "value" } }; }
|
|
175
233
|
render() {
|
|
176
234
|
this.classList.add("c-segmented");
|
|
177
|
-
const options = this.getAttribute("options");
|
|
235
|
+
const options = this.getAttribute("options") || this.getAttribute("items");
|
|
178
236
|
if (options) {
|
|
179
237
|
let parsed = null;
|
|
180
238
|
try { parsed = JSON.parse(options); } catch (e) { parsed = null; }
|
|
181
239
|
if (Array.isArray(parsed)) {
|
|
182
|
-
// Drop previously generated buttons.
|
|
183
240
|
Array.from(this.querySelectorAll("button.c-segmented__option")).forEach((n) => n.remove());
|
|
184
241
|
const selected = this.getAttribute("selected") || this.getAttribute("value");
|
|
185
242
|
parsed.forEach((opt, i) => {
|
|
@@ -209,23 +266,16 @@ class ContourDraggable extends ContourBase {
|
|
|
209
266
|
if (!this.hasAttribute("role")) this.setAttribute("role", "button");
|
|
210
267
|
if (!this.hasAttribute("tabindex")) this.setAttribute("tabindex", "0");
|
|
211
268
|
if (!this.hasAttribute("draggable")) this.setAttribute("draggable", "true");
|
|
269
|
+
if (!this.hasAttribute("aria-label")) this.setAttribute("aria-label", this.getAttribute("label") || "Draggable item");
|
|
212
270
|
}
|
|
213
|
-
|
|
214
|
-
// the `label`, else the element's own text. One shape, so a consumer's
|
|
215
|
-
// contour:drop handler sees the same detail a contour:dragstart carried.
|
|
216
|
-
// `label` and `value` are shared-list attributes (they are not overridden
|
|
217
|
-
// here), so the inherited full shared list stays the observed contract.
|
|
271
|
+
// _dragValue: value || label || textContent. Same detail for dragstart and drop.
|
|
218
272
|
_dragValue() {
|
|
219
273
|
return this.getAttribute("value") || this.getAttribute("label") || (this.textContent || "").trim() || "draggable";
|
|
220
274
|
}
|
|
221
275
|
enhance() {
|
|
222
276
|
if (this._wiredDraggable) return;
|
|
223
277
|
this._wiredDraggable = true;
|
|
224
|
-
|
|
225
|
-
// component owns the payload and the visual state. dragstart writes
|
|
226
|
-
// text/plain (the portable payload nearly every drop partner can read),
|
|
227
|
-
// marks the item with the shipped .c-draggable--dragging state, and
|
|
228
|
-
// announces contour:dragstart so a dashboard can react before the drop.
|
|
278
|
+
// Native DnD (BY-26): dragstart writes text/plain payload, adds dragging state, dispatches contour:dragstart.
|
|
229
279
|
this.addEventListener("dragstart", (e) => {
|
|
230
280
|
if (!e.dataTransfer) return;
|
|
231
281
|
const value = this._dragValue();
|
|
@@ -238,11 +288,7 @@ class ContourDraggable extends ContourBase {
|
|
|
238
288
|
this.classList.remove("c-draggable--dragging");
|
|
239
289
|
this.dispatchEvent(new CustomEvent("contour:dragend", { bubbles: true, composed: true, detail: { value: this._dragValue() } }));
|
|
240
290
|
});
|
|
241
|
-
|
|
242
|
-
// draggable offers ArrowUp/ArrowDown as a move action the consumer
|
|
243
|
-
// handles exactly like a drop (the accessible reorder pattern). It rides
|
|
244
|
-
// the same event vocabulary — contour:move {direction} — and never fakes
|
|
245
|
-
// a drag it cannot perform.
|
|
291
|
+
// Keyboard move: ArrowUp/Down dispatches contour:move (DnD has no keyboard story).
|
|
246
292
|
this.addEventListener("keydown", (e) => {
|
|
247
293
|
if (e.key === "Enter" || e.key === " ") { e.preventDefault(); this.dispatchEvent(new CustomEvent("contour:activate", { bubbles: true, composed: true })); return; }
|
|
248
294
|
if (e.key === "ArrowUp" || e.key === "ArrowDown") {
|
|
@@ -257,31 +303,61 @@ class ContourDragHandle extends ContourBase {
|
|
|
257
303
|
render() {
|
|
258
304
|
this.classList.add("c-drag-handle");
|
|
259
305
|
if (!this.hasAttribute("role")) this.setAttribute("role", "separator");
|
|
306
|
+
// Focusable separator = range widget; needs value range for AT.
|
|
307
|
+
const min = this.getAttribute("min") || "0";
|
|
308
|
+
const max = this.getAttribute("max") || "100";
|
|
309
|
+
if (!this.hasAttribute("aria-valuenow")) this.setAttribute("aria-valuenow", min);
|
|
310
|
+
if (!this.hasAttribute("aria-valuemin")) this.setAttribute("aria-valuemin", min);
|
|
311
|
+
if (!this.hasAttribute("aria-valuemax")) this.setAttribute("aria-valuemax", max);
|
|
260
312
|
if (!this.hasAttribute("tabindex")) this.setAttribute("tabindex", "0");
|
|
313
|
+
if (!this.hasAttribute("aria-label")) this.setAttribute("aria-label", this.getAttribute("label") || "Drag handle");
|
|
261
314
|
if (!this.hasAttribute("aria-orientation")) this.setAttribute("aria-orientation", "horizontal");
|
|
315
|
+
// Name the pane the handle resizes, when the author says which.
|
|
316
|
+
const controls = this.getAttribute("controls");
|
|
317
|
+
if (controls && !this.hasAttribute("aria-controls")) this.setAttribute("aria-controls", controls);
|
|
318
|
+
// grip glyph is the signifier; base rule gives size/cursor/ring.
|
|
319
|
+
const grip = this.ensure(".c-drag-handle__grip", () => {
|
|
320
|
+
const s = document.createElement("span");
|
|
321
|
+
s.className = "c-drag-handle__grip";
|
|
322
|
+
s.setAttribute("aria-hidden", "true");
|
|
323
|
+
setHTML(s, '<svg viewBox="0 0 24 24"><use href="#i-drag" /></svg>');
|
|
324
|
+
return s;
|
|
325
|
+
});
|
|
326
|
+
if (grip.parentNode !== this) this.appendChild(grip);
|
|
262
327
|
}
|
|
263
328
|
enhance() {
|
|
264
329
|
if (this._wiredDragHandle) return;
|
|
265
330
|
this._wiredDragHandle = true;
|
|
266
331
|
this.addEventListener("keydown", (e) => {
|
|
332
|
+
const now = Number(this.getAttribute("aria-valuenow") || 0);
|
|
333
|
+
const min = Number(this.getAttribute("aria-valuemin") || 0);
|
|
334
|
+
const max = Number(this.getAttribute("aria-valuemax") || 100);
|
|
267
335
|
let delta = 0;
|
|
268
336
|
if (e.key === "ArrowLeft" || e.key === "ArrowDown") delta = -1;
|
|
269
337
|
else if (e.key === "ArrowRight" || e.key === "ArrowUp") delta = 1;
|
|
270
|
-
|
|
271
|
-
else if (e.key === "
|
|
338
|
+
// Home/End: finite delta to min/max (±Infinity serialises to null).
|
|
339
|
+
else if (e.key === "Home") delta = min - now;
|
|
340
|
+
else if (e.key === "End") delta = max - now;
|
|
272
341
|
else return;
|
|
273
342
|
e.preventDefault();
|
|
274
|
-
this.dispatchEvent(new CustomEvent("contour:drag", { bubbles: true, composed: true, detail: { key: e.key, delta } }));
|
|
343
|
+
this.dispatchEvent(new CustomEvent("contour:drag", { bubbles: true, composed: true, detail: { key: e.key, delta, value: now } }));
|
|
275
344
|
});
|
|
276
345
|
}
|
|
277
346
|
}
|
|
278
347
|
define("contour-drag-handle", ContourDragHandle);
|
|
279
348
|
class ContourDropIndicator extends ContourBase {
|
|
280
|
-
static get observed() { return ["label"]; }
|
|
281
|
-
static get properties() { return { label: { attribute: "label" } }; }
|
|
349
|
+
static get observed() { return ["label", "open"]; }
|
|
350
|
+
static get properties() { return { label: { attribute: "label" }, open: { attribute: "open", type: Boolean } }; }
|
|
282
351
|
render() {
|
|
283
352
|
this.classList.add("c-drop-indicator");
|
|
284
|
-
|
|
353
|
+
// Visible only while `open` is set (old code stamped --visible always on).
|
|
354
|
+
this.classList.toggle("c-drop-indicator--visible", this.hasAttribute("open"));
|
|
355
|
+
if (!this.hasAttribute("role")) this.setAttribute("role", "presentation");
|
|
356
|
+
// presentation role strips accessible name (axe prohibits on role=presentation).
|
|
357
|
+
if (this.getAttribute("role") === "presentation") {
|
|
358
|
+
this.removeAttribute("aria-label");
|
|
359
|
+
this.removeAttribute("aria-labelledby");
|
|
360
|
+
}
|
|
285
361
|
Array.from(this.childNodes).forEach((n) => { if (n.nodeType === Node.TEXT_NODE) n.remove(); else if (n.nodeType === Node.ELEMENT_NODE && n.tagName === "SPAN") n.remove(); });
|
|
286
362
|
const label = this.getAttribute("label");
|
|
287
363
|
if (label) {
|
|
@@ -296,20 +372,21 @@ class ContourDropZone extends ContourBase {
|
|
|
296
372
|
static get properties() { return { label: { attribute: "label" } }; }
|
|
297
373
|
render() {
|
|
298
374
|
this.classList.add("c-drop-zone");
|
|
375
|
+
if (!this.hasAttribute("role")) this.setAttribute("role", "region");
|
|
376
|
+
if (!this.hasAttribute("aria-label")) this.setAttribute("aria-label", this.getAttribute("label") || "Drop zone");
|
|
299
377
|
Array.from(this.childNodes).forEach((n) => { if (n.nodeType === Node.TEXT_NODE) n.remove(); else if (n.nodeType === Node.ELEMENT_NODE && n.tagName === "SPAN") n.remove(); });
|
|
300
378
|
const label = this.getAttribute("label");
|
|
301
379
|
if (label) {
|
|
302
380
|
const t = this.ensure(".c-drop-zone__label", () => { const el = document.createElement("p"); el.className = "c-drop-zone__label"; return el; });
|
|
303
|
-
|
|
381
|
+
// R31-150: an upload glyph makes the drop zone scannable.
|
|
382
|
+
setHTML(t, '<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-upload" /></svg>');
|
|
383
|
+
t.appendChild(document.createTextNode(" " + label));
|
|
304
384
|
}
|
|
305
385
|
}
|
|
306
386
|
enhance() {
|
|
307
387
|
if (this._wiredDropZone) return;
|
|
308
388
|
this._wiredDropZone = true;
|
|
309
|
-
|
|
310
|
-
// is where the platform asks "may it land here?": a text/plain payload
|
|
311
|
-
// is allowed (preventDefault + the shipped --active state), anything
|
|
312
|
-
// else is refused (--reject, no preventDefault so the drop never lands).
|
|
389
|
+
// Native drop target (BY-26, host-delegated): dragover allows text/plain (--active), refuses others (--reject).
|
|
313
390
|
const accepts = (e) => e.dataTransfer && Array.from(e.dataTransfer.types).includes("text/plain");
|
|
314
391
|
const clear = () => { this.classList.remove("c-drop-zone--active", "c-drop-zone--reject"); };
|
|
315
392
|
this.addEventListener("dragenter", (e) => {
|
|
@@ -330,9 +407,7 @@ class ContourDropZone extends ContourBase {
|
|
|
330
407
|
const value = e.dataTransfer.getData("text/plain") || "";
|
|
331
408
|
this.dispatchEvent(new CustomEvent("contour:drop", { bubbles: true, composed: true, detail: { value, label: this.getAttribute("label") } }));
|
|
332
409
|
});
|
|
333
|
-
|
|
334
|
-
// HTML5 DnD has no keyboard story, and a target that only receives a
|
|
335
|
-
// pointer gesture does not get a focus role it cannot act on alone.
|
|
410
|
+
// Keyboard path on the draggable (contour:move); target only needs pointer role.
|
|
336
411
|
}
|
|
337
412
|
}
|
|
338
413
|
define("contour-drop-zone", ContourDropZone);
|
|
@@ -345,21 +420,33 @@ class ContourResizable extends ContourBase {
|
|
|
345
420
|
const vertical = this.getAttribute("direction") === "vertical";
|
|
346
421
|
this.classList.add(vertical ? "c-resizable--vertical" : "c-resizable--horizontal");
|
|
347
422
|
if (!this.querySelector(".c-resizable__pane")) {
|
|
423
|
+
// Structural panes only; author fills them (no invented Pane A/B).
|
|
348
424
|
const p1 = document.createElement("div");
|
|
349
425
|
p1.className = "c-resizable__pane";
|
|
350
|
-
p1.textContent = "Pane A";
|
|
351
426
|
const handle = document.createElement("div");
|
|
352
427
|
handle.className = "c-resize-handle";
|
|
353
428
|
handle.setAttribute("tabindex", "0");
|
|
354
429
|
handle.setAttribute("role", "separator");
|
|
430
|
+
handle.setAttribute("aria-valuenow", "0");
|
|
355
431
|
const p2 = document.createElement("div");
|
|
356
432
|
p2.className = "c-resizable__pane";
|
|
357
|
-
p2.textContent = "Pane B";
|
|
358
433
|
this.appendChild(p1);
|
|
359
434
|
this.appendChild(handle);
|
|
360
435
|
this.appendChild(p2);
|
|
361
436
|
}
|
|
362
437
|
const v = this._splitValue || this.getAttribute("value");
|
|
438
|
+
const handle = this.querySelector(".c-resize-handle");
|
|
439
|
+
if (handle) {
|
|
440
|
+
// R31-66: the first paint must already be a named separator, not an
|
|
441
|
+
// unnamed 0-valued handle that only becomes valid after a drag.
|
|
442
|
+
handle.setAttribute("role", "separator");
|
|
443
|
+
handle.setAttribute("tabindex", "0");
|
|
444
|
+
handle.setAttribute("aria-valuenow", String(Math.round(parseFloat(v) || 50)));
|
|
445
|
+
handle.setAttribute("aria-valuemin", "10");
|
|
446
|
+
handle.setAttribute("aria-valuemax", "90");
|
|
447
|
+
handle.setAttribute("aria-orientation", vertical ? "horizontal" : "vertical");
|
|
448
|
+
handle.setAttribute("aria-label", labelText(this, "resize-panels", "Resize panels"));
|
|
449
|
+
}
|
|
363
450
|
if (v) {
|
|
364
451
|
const p1 = this.querySelector(".c-resizable__pane");
|
|
365
452
|
if (p1) p1.style.flex = `0 0 ${v}%`;
|
|
@@ -368,19 +455,31 @@ class ContourResizable extends ContourBase {
|
|
|
368
455
|
enhance() {
|
|
369
456
|
if (this._wiredResizable) return;
|
|
370
457
|
this._wiredResizable = true;
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
458
|
+
// Pointer resize (BY-27): host-delegated listeners; first pane flex-basis = drag value. One split writer for pointer+keyboard.
|
|
459
|
+
const applySplit = (pct) => {
|
|
460
|
+
const p1 = this.querySelector(".c-resizable__pane");
|
|
461
|
+
if (p1) p1.style.flex = `0 0 ${pct}%`;
|
|
462
|
+
this._splitValue = String(pct);
|
|
463
|
+
// sync ARIA on handle so readers announce split position.
|
|
464
|
+
const handle = this.querySelector(".c-resize-handle");
|
|
465
|
+
if (handle) {
|
|
466
|
+
const vertical = this.classList.contains("c-resizable--vertical");
|
|
467
|
+
handle.setAttribute("role", "separator");
|
|
468
|
+
handle.setAttribute("aria-valuenow", String(pct));
|
|
469
|
+
handle.setAttribute("aria-valuemin", "10");
|
|
470
|
+
handle.setAttribute("aria-valuemax", "90");
|
|
471
|
+
handle.setAttribute("aria-orientation", vertical ? "horizontal" : "vertical");
|
|
472
|
+
handle.setAttribute("aria-label", labelText(this, "resize-panels", "Resize panels"));
|
|
473
|
+
handle.setAttribute("tabindex", "0");
|
|
474
|
+
}
|
|
475
|
+
};
|
|
375
476
|
const setSplit = (clientX, clientY) => {
|
|
376
477
|
const rect = this.getBoundingClientRect();
|
|
377
478
|
const vertical = this.classList.contains("c-resizable--vertical");
|
|
378
479
|
const span = vertical ? rect.height : rect.width;
|
|
379
480
|
const pos = vertical ? clientY - rect.top : clientX - rect.left;
|
|
380
481
|
const frac = span > 0 ? Math.min(0.9, Math.max(0.1, pos / span)) : 0.5;
|
|
381
|
-
|
|
382
|
-
if (p1) p1.style.flex = `0 0 ${Math.round(frac * 100)}%`;
|
|
383
|
-
this._splitValue = String(Math.round(frac * 100));
|
|
482
|
+
applySplit(Math.round(frac * 100));
|
|
384
483
|
};
|
|
385
484
|
this.addEventListener("pointerdown", (e) => {
|
|
386
485
|
const handle = this.querySelector(".c-resize-handle");
|
|
@@ -398,6 +497,8 @@ class ContourResizable extends ContourBase {
|
|
|
398
497
|
if (!this._resizing) return;
|
|
399
498
|
this._resizing = false;
|
|
400
499
|
if (this._splitValue) { this.setAttribute("value", this._splitValue); this._splitValue = null; }
|
|
500
|
+
const rect = this.getBoundingClientRect();
|
|
501
|
+
this.dispatchEvent(new CustomEvent("contour:resize", { bubbles: true, composed: true, detail: { width: Math.round(rect.width), height: Math.round(rect.height) } }));
|
|
401
502
|
const handle = this.querySelector(".c-resize-handle");
|
|
402
503
|
if (handle) {
|
|
403
504
|
handle.classList.remove("c-resize-handle--dragging");
|
|
@@ -413,33 +514,156 @@ class ContourResizable extends ContourBase {
|
|
|
413
514
|
if (!handle || document.activeElement !== handle) return;
|
|
414
515
|
const vertical = this.classList.contains("c-resizable--vertical");
|
|
415
516
|
const cur = parseFloat(this.getAttribute("value")) || 50;
|
|
416
|
-
if (e.key === "ArrowLeft" || e.key === "ArrowDown") { e.preventDefault();
|
|
417
|
-
else if (e.key === "ArrowRight" || e.key === "ArrowUp") { e.preventDefault();
|
|
517
|
+
if (e.key === "ArrowLeft" || e.key === "ArrowDown") { e.preventDefault(); applySplit(Math.max(10, cur - 5)); this._splitValue = null; this.setAttribute("value", String(Math.max(10, cur - 5))); }
|
|
518
|
+
else if (e.key === "ArrowRight" || e.key === "ArrowUp") { e.preventDefault(); applySplit(Math.min(90, cur + 5)); this._splitValue = null; this.setAttribute("value", String(Math.min(90, cur + 5))); }
|
|
519
|
+
const r = this.getBoundingClientRect();
|
|
520
|
+
this.dispatchEvent(new CustomEvent("contour:resize", { bubbles: true, composed: true, detail: { width: Math.round(r.width), height: Math.round(r.height) } }));
|
|
418
521
|
});
|
|
419
522
|
}
|
|
420
523
|
}
|
|
421
524
|
define("contour-resizable", ContourResizable);
|
|
525
|
+
// R31-96: the ONE split primitive. `contour-split-view` is a generic two-pane
|
|
526
|
+
// resizer; `contour-split-map` (map before/after) and `contour-comparison`
|
|
527
|
+
// (chart A/B) are specialized compositions of it, not separate primitives. A
|
|
528
|
+
// new split need must extend this, not add a fourth.
|
|
529
|
+
class ContourSplitView extends ContourBase {
|
|
530
|
+
static get observed() { return ["direction", "value", "left-label", "right-label"]; }
|
|
531
|
+
static get properties() { return { direction: { attribute: "direction" }, value: { attribute: "value" }, "left-label": { attribute: "left-label" }, "right-label": { attribute: "right-label" } }; }
|
|
532
|
+
render() {
|
|
533
|
+
this.classList.add("c-split-view");
|
|
534
|
+
this.setAttribute("role", "region");
|
|
535
|
+
const vertical = this.getAttribute("direction") === "vertical";
|
|
536
|
+
if (vertical) {
|
|
537
|
+
this.classList.add("c-split-view--vertical");
|
|
538
|
+
this.classList.remove("c-split-view--horizontal");
|
|
539
|
+
} else {
|
|
540
|
+
this.classList.add("c-split-view--horizontal");
|
|
541
|
+
this.classList.remove("c-split-view--vertical");
|
|
542
|
+
}
|
|
543
|
+
if (this.getAttribute("left-label")) this.setAttribute("aria-label", this.getAttribute("left-label"));
|
|
544
|
+
if (!this.querySelector(".c-split-view__pane")) {
|
|
545
|
+
const p1 = document.createElement("div");
|
|
546
|
+
p1.className = "c-split-view__pane c-split-view__pane--left";
|
|
547
|
+
p1.setAttribute("role", "region");
|
|
548
|
+
if (this.getAttribute("left-label")) p1.setAttribute("aria-label", this.getAttribute("left-label"));
|
|
549
|
+
const divider = document.createElement("div");
|
|
550
|
+
divider.className = "c-split-view__divider";
|
|
551
|
+
divider.setAttribute("tabindex", "0");
|
|
552
|
+
divider.setAttribute("role", "separator");
|
|
553
|
+
divider.setAttribute("aria-valuenow", this.getAttribute("value") || "50");
|
|
554
|
+
divider.setAttribute("aria-valuemin", "10");
|
|
555
|
+
divider.setAttribute("aria-valuemax", "90");
|
|
556
|
+
divider.setAttribute("aria-orientation", vertical ? "horizontal" : "vertical");
|
|
557
|
+
divider.setAttribute("aria-label", labelText(this, "split-divider", "Split divider"));
|
|
558
|
+
const p2 = document.createElement("div");
|
|
559
|
+
p2.className = "c-split-view__pane c-split-view__pane--right";
|
|
560
|
+
p2.setAttribute("role", "region");
|
|
561
|
+
if (this.getAttribute("right-label")) p2.setAttribute("aria-label", this.getAttribute("right-label"));
|
|
562
|
+
this.appendChild(p1);
|
|
563
|
+
this.appendChild(divider);
|
|
564
|
+
this.appendChild(p2);
|
|
565
|
+
}
|
|
566
|
+
// Divider created independently of pane guard; author panes still need it.
|
|
567
|
+
if (!this.querySelector(".c-split-view__divider")) {
|
|
568
|
+
const divider = document.createElement("div");
|
|
569
|
+
divider.className = "c-split-view__divider";
|
|
570
|
+
divider.setAttribute("tabindex", "0");
|
|
571
|
+
divider.setAttribute("role", "separator");
|
|
572
|
+
divider.setAttribute("aria-valuenow", this.getAttribute("value") || "50");
|
|
573
|
+
divider.setAttribute("aria-valuemin", "10");
|
|
574
|
+
divider.setAttribute("aria-valuemax", "90");
|
|
575
|
+
divider.setAttribute("aria-orientation", vertical ? "horizontal" : "vertical");
|
|
576
|
+
divider.setAttribute("aria-label", labelText(this, "split-divider", "Split divider"));
|
|
577
|
+
this.appendChild(divider);
|
|
578
|
+
}
|
|
579
|
+
const v = this.getAttribute("value") || "50";
|
|
580
|
+
const p1 = this.querySelector(".c-split-view__pane--left");
|
|
581
|
+
if (p1) p1.style.flex = `0 0 ${v}%`;
|
|
582
|
+
const divider = this.querySelector(".c-split-view__divider");
|
|
583
|
+
if (divider) {
|
|
584
|
+
divider.setAttribute("aria-valuenow", v);
|
|
585
|
+
divider.setAttribute("aria-valuemin", "10");
|
|
586
|
+
divider.setAttribute("aria-valuemax", "90");
|
|
587
|
+
divider.setAttribute("aria-orientation", vertical ? "horizontal" : "vertical");
|
|
588
|
+
}
|
|
589
|
+
}
|
|
590
|
+
enhance() {
|
|
591
|
+
if (this._wiredSplitView) return;
|
|
592
|
+
this._wiredSplitView = true;
|
|
593
|
+
// R31-114: the stylesheet stacks a horizontal split below 40rem. A media query
|
|
594
|
+
// cannot restyle its own container, so the class still says what the author
|
|
595
|
+
// asked for while the rendered axis says what the reader got — the drag maths
|
|
596
|
+
// and the separator's announced orientation follow the second.
|
|
597
|
+
const isColumn = () => getComputedStyle(this).flexDirection === "column";
|
|
598
|
+
const syncAxis = () => {
|
|
599
|
+
const d = this.querySelector(".c-split-view__divider");
|
|
600
|
+
if (d) d.setAttribute("aria-orientation", isColumn() ? "horizontal" : "vertical");
|
|
601
|
+
};
|
|
602
|
+
syncAxis();
|
|
603
|
+
if (typeof ResizeObserver === "function") {
|
|
604
|
+
const ro = new ResizeObserver(syncAxis);
|
|
605
|
+
ro.observe(this);
|
|
606
|
+
onDispose(this, () => ro.disconnect());
|
|
607
|
+
}
|
|
608
|
+
const setSplit = (clientX, clientY) => {
|
|
609
|
+
const rect = this.getBoundingClientRect();
|
|
610
|
+
const vertical = isColumn();
|
|
611
|
+
const span = vertical ? rect.height : rect.width;
|
|
612
|
+
const pos = vertical ? clientY - rect.top : clientX - rect.left;
|
|
613
|
+
const frac = span > 0 ? Math.min(0.9, Math.max(0.1, pos / span)) : 0.5;
|
|
614
|
+
const pct = Math.round(frac * 100);
|
|
615
|
+
const p1 = this.querySelector(".c-split-view__pane--left");
|
|
616
|
+
if (p1) p1.style.flex = `0 0 ${pct}%`;
|
|
617
|
+
const divider = this.querySelector(".c-split-view__divider");
|
|
618
|
+
if (divider) divider.setAttribute("aria-valuenow", String(pct));
|
|
619
|
+
this.setAttribute("value", String(pct));
|
|
620
|
+
};
|
|
621
|
+
this.addEventListener("pointerdown", (e) => {
|
|
622
|
+
const divider = this.querySelector(".c-split-view__divider");
|
|
623
|
+
if (!divider || e.target !== divider) return;
|
|
624
|
+
this._resizing = true;
|
|
625
|
+
divider.classList.add("c-split-view__divider--dragging");
|
|
626
|
+
if (divider.setPointerCapture) { try { divider.setPointerCapture(e.pointerId); } catch (err) { /* ignore */ } }
|
|
627
|
+
e.preventDefault();
|
|
628
|
+
});
|
|
629
|
+
this.addEventListener("pointermove", (e) => {
|
|
630
|
+
if (!this._resizing) return;
|
|
631
|
+
setSplit(e.clientX, e.clientY);
|
|
632
|
+
});
|
|
633
|
+
const stopResize = (e) => {
|
|
634
|
+
if (!this._resizing) return;
|
|
635
|
+
this._resizing = false;
|
|
636
|
+
const divider = this.querySelector(".c-split-view__divider");
|
|
637
|
+
if (divider) {
|
|
638
|
+
divider.classList.remove("c-split-view__divider--dragging");
|
|
639
|
+
if (divider.hasPointerCapture && divider.hasPointerCapture(e.pointerId)) {
|
|
640
|
+
try { divider.releasePointerCapture(e.pointerId); } catch (err) { /* ignore */ }
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
const r = this.getBoundingClientRect();
|
|
644
|
+
this.dispatchEvent(new CustomEvent("contour:split-change", { bubbles: true, composed: true, detail: { value: this.getAttribute("value"), width: Math.round(r.width), height: Math.round(r.height) } }));
|
|
645
|
+
};
|
|
646
|
+
this.addEventListener("pointerup", stopResize);
|
|
647
|
+
this.addEventListener("pointercancel", stopResize);
|
|
648
|
+
this.addEventListener("keydown", (e) => {
|
|
649
|
+
const divider = this.querySelector(".c-split-view__divider");
|
|
650
|
+
if (!divider || document.activeElement !== divider) return;
|
|
651
|
+
const cur = parseFloat(this.getAttribute("value")) || 50;
|
|
652
|
+
if (e.key === "ArrowLeft" || e.key === "ArrowDown") { e.preventDefault(); const nv = Math.max(10, cur - 5); const p1 = this.querySelector(".c-split-view__pane--left"); if (p1) p1.style.flex = `0 0 ${nv}%`; this.setAttribute("value", String(nv)); const d = this.querySelector(".c-split-view__divider"); if (d) d.setAttribute("aria-valuenow", String(nv)); }
|
|
653
|
+
else if (e.key === "ArrowRight" || e.key === "ArrowUp") { e.preventDefault(); const nv = Math.min(90, cur + 5); const p1 = this.querySelector(".c-split-view__pane--left"); if (p1) p1.style.flex = `0 0 ${nv}%`; this.setAttribute("value", String(nv)); const d = this.querySelector(".c-split-view__divider"); if (d) d.setAttribute("aria-valuenow", String(nv)); }
|
|
654
|
+
const r = this.getBoundingClientRect();
|
|
655
|
+
this.dispatchEvent(new CustomEvent("contour:split-change", { bubbles: true, composed: true, detail: { value: this.getAttribute("value"), width: Math.round(r.width), height: Math.round(r.height) } }));
|
|
656
|
+
});
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
define("contour-split-view", ContourSplitView);
|
|
422
660
|
class ContourTableWrap extends ContourBase {
|
|
423
661
|
static get observed() { return []; }
|
|
424
662
|
static get properties() { return {}; }
|
|
425
663
|
render() {
|
|
426
664
|
this.classList.add("c-table-wrap");
|
|
427
665
|
Array.from(this.childNodes).forEach((n) => { if (n.nodeType === Node.TEXT_NODE) n.remove(); else if (n.nodeType === Node.ELEMENT_NODE && n.tagName === "SPAN") n.remove(); });
|
|
428
|
-
|
|
429
|
-
const t = document.createElement("table");
|
|
430
|
-
t.className = "c-table";
|
|
431
|
-
const thead = document.createElement("thead");
|
|
432
|
-
const tr = document.createElement("tr");
|
|
433
|
-
for (const h of ["A", "B"]) { const th = document.createElement("th"); th.textContent = h; tr.appendChild(th); }
|
|
434
|
-
thead.appendChild(tr);
|
|
435
|
-
t.appendChild(thead);
|
|
436
|
-
const tbody = document.createElement("tbody");
|
|
437
|
-
const tr2 = document.createElement("tr");
|
|
438
|
-
for (const v of ["1", "2"]) { const td = document.createElement("td"); td.textContent = v; tr2.appendChild(td); }
|
|
439
|
-
tbody.appendChild(tr2);
|
|
440
|
-
t.appendChild(tbody);
|
|
441
|
-
this.appendChild(t);
|
|
442
|
-
}
|
|
666
|
+
// Author supplies the <table>; component doesn't invent one (old code rendered A/B/1/2).
|
|
443
667
|
}
|
|
444
668
|
}
|
|
445
669
|
define("contour-table-wrap", ContourTableWrap);
|
|
@@ -450,18 +674,18 @@ class ContourScrollArea extends ContourBase {
|
|
|
450
674
|
this.classList.add("c-scroll-area");
|
|
451
675
|
const title = this.getAttribute("title");
|
|
452
676
|
if (title) {
|
|
453
|
-
const t = this.ensure(".c-scroll-area__title", () => { const el = document.createElement("div"); el.className = "c-scroll-area__title";
|
|
677
|
+
const t = this.ensure(".c-scroll-area__title", () => { const el = document.createElement("div"); el.className = "c-scroll-area__title"; return el; });
|
|
454
678
|
t.textContent = title;
|
|
455
679
|
}
|
|
456
680
|
}
|
|
457
681
|
}
|
|
458
682
|
define("contour-scroll-area", ContourScrollArea);
|
|
459
683
|
class ContourBtn extends ContourBase {
|
|
460
|
-
static get observed() { return ["variant", "size", "color", "label", "disabled"]; }
|
|
684
|
+
static get observed() { return ["variant", "size", "color", "label", "disabled", "href", "loading", "title"]; }
|
|
461
685
|
static get properties() { return { variant: { attribute: "variant" }, size: { attribute: "size" }, color: { attribute: "color" }, label: { attribute: "label" }, disabled: { attribute: "disabled", type: Boolean } }; }
|
|
462
686
|
render() {
|
|
463
687
|
this.classList.add("c-btn");
|
|
464
|
-
|
|
688
|
+
// keep authored variant classes; add attribute-driven ones on top.
|
|
465
689
|
for (const attr of ["variant", "size", "color"]) {
|
|
466
690
|
const val = this.getAttribute(attr);
|
|
467
691
|
if (val) this.classList.add("c-btn--" + val);
|
|
@@ -474,14 +698,37 @@ class ContourBtn extends ContourBase {
|
|
|
474
698
|
this.removeAttribute("aria-disabled");
|
|
475
699
|
if (!this.hasAttribute("tabindex") || this.getAttribute("tabindex") === "-1") this.setAttribute("tabindex", "0");
|
|
476
700
|
}
|
|
477
|
-
|
|
701
|
+
// Name icon-only buttons from label/title when there is no text content.
|
|
702
|
+
const label = this.getAttribute("label") || this.getAttribute("title");
|
|
478
703
|
if (label && !this.hasChildNodes()) this.textContent = label;
|
|
479
704
|
if (label && !this.hasAttribute("aria-label")) this.setAttribute("aria-label", label);
|
|
705
|
+
// Loading state: expose data-loading + aria-busy so the spinner CSS and
|
|
706
|
+
// assistive technology both reflect the busy state.
|
|
707
|
+
if (this.hasAttribute("loading")) {
|
|
708
|
+
this.setAttribute("data-loading", "true");
|
|
709
|
+
this.setAttribute("aria-busy", "true");
|
|
710
|
+
} else {
|
|
711
|
+
this.removeAttribute("data-loading");
|
|
712
|
+
this.removeAttribute("aria-busy");
|
|
713
|
+
}
|
|
480
714
|
}
|
|
481
715
|
enhance() {
|
|
482
716
|
if (this._wiredBtn) return;
|
|
483
717
|
this._wiredBtn = true;
|
|
718
|
+
// disabled guard: no activation on click/keydown; capture-phase.
|
|
719
|
+
const isDisabled = () => this.hasAttribute("disabled") || this.getAttribute("aria-disabled") === "true";
|
|
720
|
+
this.addEventListener("click", (e) => {
|
|
721
|
+
if (isDisabled()) { e.preventDefault(); e.stopImmediatePropagation(); }
|
|
722
|
+
}, true);
|
|
723
|
+
// optional href mode — sanitize via safeHref and navigate on
|
|
724
|
+
// click/Enter (guard above keeps disabled buttons from navigating).
|
|
725
|
+
this.addEventListener("click", (e) => {
|
|
726
|
+
if (isDisabled()) return;
|
|
727
|
+
const href = safeHref(this.getAttribute("href"));
|
|
728
|
+
if (href && href !== "#") location.href = href;
|
|
729
|
+
});
|
|
484
730
|
this.addEventListener("keydown", (e) => {
|
|
731
|
+
if (isDisabled()) { e.preventDefault(); e.stopImmediatePropagation(); return; }
|
|
485
732
|
if (e.key === "Enter" || e.key === " ") { e.preventDefault(); this.click(); this.dispatchEvent(new CustomEvent("contour:activate", { bubbles: true, composed: true })); }
|
|
486
733
|
});
|
|
487
734
|
}
|