contour-ds 1.9.0 → 1.10.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 +4 -4
- package/dist/build-manifest.json +205 -204
- package/dist/contour-wc-content.esm.js +1 -1
- package/dist/contour-wc-content.esm.min.js +1 -1
- package/dist/contour-wc-core.esm.js +712 -45
- package/dist/contour-wc-core.esm.min.js +1 -1
- package/dist/contour-wc-dashboard.esm.js +596 -90
- package/dist/contour-wc-dashboard.esm.min.js +1 -1
- package/dist/contour-wc-data.esm.js +467 -70
- package/dist/contour-wc-data.esm.min.js +1 -1
- package/dist/contour-wc-docs.esm.js +1 -1
- package/dist/contour-wc-docs.esm.min.js +1 -1
- package/dist/contour-wc-feedback.esm.js +260 -29
- package/dist/contour-wc-feedback.esm.min.js +1 -1
- package/dist/contour-wc-forms.esm.js +133 -40
- package/dist/contour-wc-forms.esm.min.js +1 -1
- package/dist/contour-wc-interaction.esm.js +64 -5
- package/dist/contour-wc-interaction.esm.min.js +1 -1
- package/dist/contour-wc-layout.esm.js +72 -10
- package/dist/contour-wc-layout.esm.min.js +1 -1
- package/dist/contour-wc-map.esm.js +69 -9
- package/dist/contour-wc-map.esm.min.js +1 -1
- package/dist/contour-wc-misc.esm.js +1 -1
- package/dist/contour-wc-misc.esm.min.js +1 -1
- package/dist/contour-wc-navigation.esm.js +136 -20
- package/dist/contour-wc-navigation.esm.min.js +1 -1
- package/dist/contour-wc-ui.esm.js +505 -80
- package/dist/contour-wc-ui.esm.min.js +1 -1
- package/dist/contour-wc.esm.js +2539 -320
- package/dist/contour-wc.esm.min.js +1 -1
- package/dist/contour-wc.js +2539 -320
- package/dist/contour-wc.min.js +1 -1
- package/dist/contour.code-snippets +44 -0
- package/dist/contour.components.json +12064 -135
- package/dist/contour.css +1368 -451
- package/dist/contour.d.ts +42 -21
- package/dist/contour.esm.js +138 -21
- package/dist/contour.esm.min.js +1 -1
- package/dist/contour.html-data.json +249 -9
- package/dist/contour.js +138 -21
- package/dist/contour.min.css +1 -1
- package/dist/contour.min.js +1 -1
- package/dist/contour.react.d.ts +5 -1
- package/dist/contour.single.html +2 -2
- package/dist/contour.single.min.css +1 -1
- package/dist/contour.tokens.json +36 -1
- package/dist/contour.vue.d.ts +5 -1
- package/dist/contour.web-types.json +241 -9
- package/dist/custom-elements.json +1225 -55
- package/dist/docs/actions.md +1 -1
- package/dist/docs/affordances.md +1 -1
- package/dist/docs/apireference.md +1 -1
- package/dist/docs/colour.md +1 -1
- package/dist/docs/componentindex.md +1 -1
- package/dist/docs/data.md +6 -2
- package/dist/docs/docs.md +1 -1
- package/dist/docs/feedback.md +1 -1
- package/dist/docs/field.md +1 -1
- package/dist/docs/forms.md +1 -1
- package/dist/docs/index.json +8 -8
- package/dist/docs/install.md +1 -1
- package/dist/docs/landing.md +1 -1
- package/dist/docs/mapengine.md +1 -1
- package/dist/docs/motion.md +1 -1
- package/dist/docs/navigation.md +1 -1
- package/dist/docs/overlays.md +1 -1
- package/dist/docs/overview.md +1 -1
- package/dist/docs/patterns.md +1 -1
- package/dist/docs/playground.md +1 -1
- package/dist/docs/principles.md +1 -1
- package/dist/docs/recipes.md +1 -1
- package/dist/docs/space.md +1 -1
- package/dist/docs/status.md +1 -1
- package/dist/docs/surfaces.md +1 -1
- package/dist/docs/theming.md +5 -2
- package/dist/docs/type.md +1 -1
- package/dist/docs/webcomponents.md +1 -1
- package/dist/hljs.css +34 -17
- package/dist/map-chrome-contract.json +26 -0
- package/dist/map-chrome.mapbox.css +121 -0
- package/dist/map-chrome.maplibre.css +121 -0
- package/dist/registry/items/contour-core.json +2 -2
- package/dist/registry/items/contour-data.json +2 -2
- package/dist/registry/items/contour-docs.json +2 -2
- package/dist/registry/items/contour-landing.json +2 -2
- package/dist/registry/registry.json +8 -8
- package/dist/surfaces/contour-core.min.css +1 -1
- package/dist/surfaces/contour-data.min.css +1 -1
- package/dist/surfaces/contour-docs.min.css +1 -1
- package/dist/surfaces/contour-landing.min.css +1 -1
- package/dist/wc/behaviours.mjs +11 -3
- package/dist/wc/core.mjs +307 -32
- package/dist/wc/dashboard.mjs +129 -20
- package/dist/wc/data-chart.mjs +170 -22
- package/dist/wc/data-export.mjs +150 -29
- package/dist/wc/data-gauge.mjs +11 -4
- package/dist/wc/data-geo.mjs +1 -1
- package/dist/wc/data-legend.mjs +15 -2
- package/dist/wc/data-readout.mjs +12 -1
- package/dist/wc/data-series.mjs +73 -5
- package/dist/wc/data-table.mjs +37 -8
- package/dist/wc/feedback.mjs +259 -28
- package/dist/wc/forms-controls.mjs +44 -16
- package/dist/wc/forms-field.mjs +46 -4
- package/dist/wc/forms-groups.mjs +31 -8
- package/dist/wc/forms-input.mjs +11 -11
- package/dist/wc/index.mjs +1 -1
- package/dist/wc/interaction.mjs +63 -4
- package/dist/wc/layout.mjs +72 -10
- package/dist/wc/map.mjs +68 -8
- package/dist/wc/navigation-menu.mjs +43 -9
- package/dist/wc/navigation-shell.mjs +39 -6
- package/dist/wc/navigation-tree.mjs +53 -4
- package/dist/wc/states.mjs +350 -9
- package/dist/wc/svg.mjs +43 -0
- package/dist/wc/ui-data.mjs +268 -28
- package/dist/wc/ui-feedback.mjs +36 -11
- package/dist/wc/ui-inputs.mjs +63 -25
- package/dist/wc/ui-overlays.mjs +138 -16
- package/integrations/ai/v0-prompt.md +1 -1
- package/integrations/frameworks/fixtures/authored/sample.jsx +15 -0
- package/integrations/frameworks/fixtures/authored/sample.vue +15 -0
- package/integrations/frameworks/fixtures/dist/rendered.html +32 -0
- package/integrations/libreship/contract.json +1025 -0
- package/integrations/native/README.md +24 -4
- package/integrations/native/build/android/colors.xml +278 -0
- package/integrations/native/build/flutter/contour_tokens.dart +280 -0
- package/integrations/native/build/ios/ContourTokens.swift +280 -0
- package/integrations/validate-markup.mjs +57 -7
- package/package.json +45 -18
package/dist/wc/ui-inputs.mjs
CHANGED
|
@@ -226,15 +226,15 @@ class ContourDateRange extends ContourBase {
|
|
|
226
226
|
const fd = new FormData();
|
|
227
227
|
if (start) fd.append(name, start);
|
|
228
228
|
if (end) fd.append(name, end);
|
|
229
|
-
this.
|
|
229
|
+
this._setFormValue(fd);
|
|
230
230
|
} else {
|
|
231
|
-
this.
|
|
231
|
+
this._setFormValue(null);
|
|
232
232
|
}
|
|
233
233
|
const missing = this.hasAttribute("required") && (!start || !end);
|
|
234
234
|
const inverted = !!(start && end && start > end);
|
|
235
|
-
if (missing) this.
|
|
236
|
-
else if (inverted) this.
|
|
237
|
-
else this.
|
|
235
|
+
if (missing) this._setValidity({ valueMissing: true }, "Both dates are required.");
|
|
236
|
+
else if (inverted) this._setValidity({ customError: true }, "Start must be on or before end.");
|
|
237
|
+
else this._setValidity({});
|
|
238
238
|
this._setCustomState("data-invalid", missing || inverted);
|
|
239
239
|
for (const input of this.querySelectorAll("input")) input.setAttribute("aria-invalid", String(missing || inverted));
|
|
240
240
|
}
|
|
@@ -533,12 +533,12 @@ class ContourDatePicker extends ContourBase {
|
|
|
533
533
|
const fd = new FormData();
|
|
534
534
|
if (s) fd.append(name, s);
|
|
535
535
|
if (e) fd.append(name, e);
|
|
536
|
-
this.
|
|
536
|
+
this._setFormValue(fd);
|
|
537
537
|
} else {
|
|
538
|
-
this.
|
|
538
|
+
this._setFormValue(null);
|
|
539
539
|
}
|
|
540
540
|
} else {
|
|
541
|
-
this.
|
|
541
|
+
this._setFormValue(start && start.value ? start.value : null);
|
|
542
542
|
}
|
|
543
543
|
this._syncValidity(this.hasAttribute("required") && !(start && start.value));
|
|
544
544
|
}
|
|
@@ -626,16 +626,28 @@ class ContourDatePicker extends ContourBase {
|
|
|
626
626
|
if (btn) btn.click();
|
|
627
627
|
return;
|
|
628
628
|
}
|
|
629
|
+
const isDisabled = (c) => c.disabled === true || c.getAttribute("aria-disabled") === "true";
|
|
629
630
|
let next = -1;
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
else if (e.key === "
|
|
633
|
-
else if (e.key === "
|
|
634
|
-
else if (e.key === "
|
|
635
|
-
else if (e.key === "
|
|
636
|
-
|
|
631
|
+
let delta = 0;
|
|
632
|
+
if (e.key === "ArrowRight") { next = i + 1; delta = 1; }
|
|
633
|
+
else if (e.key === "ArrowLeft") { next = i - 1; delta = -1; }
|
|
634
|
+
else if (e.key === "ArrowDown") { next = i + 7; delta = 7; }
|
|
635
|
+
else if (e.key === "ArrowUp") { next = i - 7; delta = -7; }
|
|
636
|
+
else if (e.key === "Home" || e.key === "End") {
|
|
637
|
+
// R34-14: Home/End land on the first/last *enabled* cell, not a disabled one.
|
|
638
|
+
e.preventDefault();
|
|
639
|
+
if (e.key === "Home") next = cells.findIndex((c) => !isDisabled(c));
|
|
640
|
+
else { for (let k = cells.length - 1; k >= 0; k--) { if (!isDisabled(cells[k])) { next = k; break; } } }
|
|
641
|
+
if (next < 0) return;
|
|
642
|
+
cells.forEach((cell, j) => cell.setAttribute("tabindex", j === next ? "0" : "-1"));
|
|
643
|
+
cells[next].focus();
|
|
644
|
+
return;
|
|
645
|
+
} else return;
|
|
637
646
|
e.preventDefault();
|
|
638
|
-
|
|
647
|
+
// R34-14: arrow navigation skips disabled (out-of-range) cells in the move
|
|
648
|
+
// direction instead of focusing a disabled button.
|
|
649
|
+
while (next >= 0 && next < cells.length && isDisabled(cells[next])) next += delta;
|
|
650
|
+
if (next < 0 || next >= cells.length || isDisabled(cells[next])) return;
|
|
639
651
|
cells.forEach((cell, j) => cell.setAttribute("tabindex", j === next ? "0" : "-1"));
|
|
640
652
|
cells[next].focus();
|
|
641
653
|
});
|
|
@@ -698,8 +710,8 @@ class ContourRating extends ContourBase {
|
|
|
698
710
|
if (!this._internals) return;
|
|
699
711
|
const name = this.getAttribute("name");
|
|
700
712
|
const value = this.getAttribute("value");
|
|
701
|
-
if (name && value) this.
|
|
702
|
-
else this.
|
|
713
|
+
if (name && value) this._setFormValue(value);
|
|
714
|
+
else this._setFormValue(null);
|
|
703
715
|
}
|
|
704
716
|
enhance() {
|
|
705
717
|
if (this._wiredRating) return;
|
|
@@ -817,6 +829,20 @@ class ContourColorPicker extends ContourBase {
|
|
|
817
829
|
const hasColor = /^#?[0-9a-f]{6}([0-9a-f]{2})?$/i.test(rawValue);
|
|
818
830
|
if (hasColor) { input.value = rawValue.slice(0, 7); this.removeAttribute("data-empty"); }
|
|
819
831
|
else { input.value = ""; this.setAttribute("data-empty", ""); }
|
|
832
|
+
// R34-20: the empty swatch is a CSS ::before pseudo (visual only); give
|
|
833
|
+
// assistive tech real text so an empty picker is not announced as a bare
|
|
834
|
+
// colour input. The pseudo stays for the visual, this carries the words.
|
|
835
|
+
let emptyNode = this.querySelector(".c-color-picker__empty");
|
|
836
|
+
if (!hasColor) {
|
|
837
|
+
if (!emptyNode) {
|
|
838
|
+
emptyNode = document.createElement("span");
|
|
839
|
+
emptyNode.className = "c-color-picker__empty visually-hidden";
|
|
840
|
+
this.appendChild(emptyNode);
|
|
841
|
+
}
|
|
842
|
+
emptyNode.textContent = labelText(this, "no-color", "No colour");
|
|
843
|
+
} else if (emptyNode) {
|
|
844
|
+
emptyNode.remove();
|
|
845
|
+
}
|
|
820
846
|
if (!input.hasAttribute("aria-label")) input.setAttribute("aria-label", label || "Color");
|
|
821
847
|
// R31-68: a required picker propagates `required` to the native input, so
|
|
822
848
|
// an empty (data-empty) value blocks form submission.
|
|
@@ -1123,12 +1149,19 @@ class ContourFileUpload extends ContourBase {
|
|
|
1123
1149
|
return f.type.toLowerCase() === a;
|
|
1124
1150
|
});
|
|
1125
1151
|
});
|
|
1126
|
-
if (valid.length === 0)
|
|
1127
|
-
|
|
1128
|
-
|
|
1152
|
+
if (valid.length === 0) {
|
|
1153
|
+
// R34-21: a fully rejected drop is announced, not swallowed.
|
|
1154
|
+
const msg = labelText(this, "file-rejected", "No files match the accepted types");
|
|
1155
|
+
this.dispatchEvent(new CustomEvent("contour:error", { bubbles: true, composed: true, detail: { src: "", message: msg, name: "file-rejected", status: 0 } }));
|
|
1156
|
+
return;
|
|
1157
|
+
}
|
|
1158
|
+
// R34-21: enforce multiple=false — keep only the first accepted file.
|
|
1159
|
+
const accepted = this.hasAttribute("multiple") ? valid : valid.slice(0, 1);
|
|
1160
|
+
assignFiles(i, accepted);
|
|
1161
|
+
renderPreview(accepted);
|
|
1129
1162
|
// R24-116: sync form value on drop.
|
|
1130
1163
|
this._syncFormValue();
|
|
1131
|
-
this.dispatchEvent(new CustomEvent("contour:change", { bubbles: true, composed: true, detail: { files:
|
|
1164
|
+
this.dispatchEvent(new CustomEvent("contour:change", { bubbles: true, composed: true, detail: { files: accepted } }));
|
|
1132
1165
|
} else {
|
|
1133
1166
|
assignFiles(i, e.dataTransfer.files);
|
|
1134
1167
|
renderPreview(e.dataTransfer.files);
|
|
@@ -1158,9 +1191,9 @@ class ContourFileUpload extends ContourBase {
|
|
|
1158
1191
|
// declared, not a hard-coded "file" key.
|
|
1159
1192
|
const key = this.getAttribute("name") || "file";
|
|
1160
1193
|
Array.from(inp.files).forEach((f) => fd.append(key, f));
|
|
1161
|
-
this.
|
|
1194
|
+
this._setFormValue(fd);
|
|
1162
1195
|
} else {
|
|
1163
|
-
this.
|
|
1196
|
+
this._setFormValue(null);
|
|
1164
1197
|
}
|
|
1165
1198
|
}
|
|
1166
1199
|
}
|
|
@@ -1264,6 +1297,11 @@ class ContourTagsInput extends ContourBase {
|
|
|
1264
1297
|
}
|
|
1265
1298
|
if (added.length) {
|
|
1266
1299
|
this.setAttribute("value", JSON.stringify(tags));
|
|
1300
|
+
// R34-22: one atomic contour:change for the whole batch (paste adds
|
|
1301
|
+
// many), so a consumer sees a single event with the full value rather
|
|
1302
|
+
// than a loop of per-tag notifications. contour:add still fires per
|
|
1303
|
+
// tag for granular listeners.
|
|
1304
|
+
this.dispatchEvent(new CustomEvent("contour:change", { bubbles: true, composed: true, detail: { value: tags } }));
|
|
1267
1305
|
for (const v of added) this.dispatchEvent(new CustomEvent("contour:add", { bubbles: true, composed: true, detail: { value: v } }));
|
|
1268
1306
|
}
|
|
1269
1307
|
// One composed announcement AFTER the writeback re-render, so the
|
|
@@ -1328,7 +1366,7 @@ class ContourTagsInput extends ContourBase {
|
|
|
1328
1366
|
// Form-value sync override: tags live as a JSON array on the host, so submit the host's value; required means at least one tag.
|
|
1329
1367
|
_syncFormValue() {
|
|
1330
1368
|
if (!this._internals) return;
|
|
1331
|
-
this.
|
|
1369
|
+
this._setFormValue(this.getAttribute("value") || "[]");
|
|
1332
1370
|
let count = 0;
|
|
1333
1371
|
try { const p = JSON.parse(this.getAttribute("value") || "[]"); count = Array.isArray(p) ? p.length : 0; } catch (err) { count = (this.getAttribute("value") || "").split(",").filter((s) => s.trim()).length; }
|
|
1334
1372
|
this._syncValidity(this.hasAttribute("required") && count === 0);
|
package/dist/wc/ui-overlays.mjs
CHANGED
|
@@ -340,18 +340,29 @@ class ContourAnimationControls extends ContourBase {
|
|
|
340
340
|
* `contour:drag` per move and `contour:dragend` on release (R20 T-11).
|
|
341
341
|
*/
|
|
342
342
|
class ContourAnnotation extends ContourBase {
|
|
343
|
-
static get observed() { return ["label", "x", "y"]; }
|
|
344
|
-
static get properties() { return { label: { attribute: "label" }, x: { attribute: "x" }, y: { attribute: "y" } }; }
|
|
343
|
+
static get observed() { return ["label", "x", "y", "kind", "locked"]; }
|
|
344
|
+
static get properties() { return { label: { attribute: "label" }, x: { attribute: "x" }, y: { attribute: "y" }, kind: { attribute: "kind" }, locked: { attribute: "locked", type: Boolean } }; }
|
|
345
345
|
render() {
|
|
346
346
|
this.classList.add("c-annotation");
|
|
347
347
|
this.setAttribute("role", "note");
|
|
348
348
|
if (!this.hasAttribute("tabindex")) this.setAttribute("tabindex", "0");
|
|
349
349
|
const label = this.getAttribute("label");
|
|
350
350
|
if (label) this.setAttribute("aria-label", label);
|
|
351
|
+
// R34-168: annotation kind (pin/text/arrow/box) is a shape+word, and a
|
|
352
|
+
// locked annotation is not draggable.
|
|
353
|
+
const kind = (this.getAttribute("kind") || "pin").toLowerCase();
|
|
354
|
+
this.dataset.kind = kind;
|
|
355
|
+
if (this.hasAttribute("locked")) this.setAttribute("aria-disabled", "true");
|
|
356
|
+
else this.removeAttribute("aria-disabled");
|
|
351
357
|
if (label) {
|
|
352
358
|
const l = this.ensure(".c-annotation__label", () => { const el = document.createElement("span"); el.className = "c-annotation__label"; return el; });
|
|
353
359
|
l.textContent = label;
|
|
354
360
|
}
|
|
361
|
+
// R34-168: edit/delete actions (icon+text small buttons).
|
|
362
|
+
const edit = this.ensure("button.c-annotation__edit", () => { const b = document.createElement("button"); b.type = "button"; b.className = "c-btn c-btn--sm c-btn--ghost c-annotation__edit"; b.setAttribute("data-annotation-edit", ""); b.textContent = labelText(this, "edit", "Edit"); return b; });
|
|
363
|
+
const del = this.ensure("button.c-annotation__delete", () => { const b = document.createElement("button"); b.type = "button"; b.className = "c-btn c-btn--sm c-btn--ghost c-annotation__delete"; b.setAttribute("data-annotation-delete", ""); b.textContent = labelText(this, "delete", "Delete"); return b; });
|
|
364
|
+
if (edit.parentNode !== this) this.appendChild(edit);
|
|
365
|
+
if (del.parentNode !== this) this.appendChild(del);
|
|
355
366
|
const x = this.getAttribute("x");
|
|
356
367
|
const y = this.getAttribute("y");
|
|
357
368
|
if (x !== null) this.style.setProperty("--annotation-x", x);
|
|
@@ -373,8 +384,18 @@ class ContourAnnotation extends ContourBase {
|
|
|
373
384
|
});
|
|
374
385
|
this.dispatchEvent(new CustomEvent("contour:drag", { bubbles: true, composed: true, detail: { delta: key ? 1 : 0, key: key || "pointer", value: x + "," + y } }));
|
|
375
386
|
};
|
|
387
|
+
// R34-168: edit/delete emit a single annotation-action event.
|
|
388
|
+
this.addEventListener("click", (e) => {
|
|
389
|
+
const t = e.target && e.target.closest ? e.target.closest("button") : null;
|
|
390
|
+
if (!t || !this.contains(t)) return;
|
|
391
|
+
const action = t.hasAttribute("data-annotation-edit") ? "edit" : t.hasAttribute("data-annotation-delete") ? "delete" : null;
|
|
392
|
+
if (!action) return;
|
|
393
|
+
e.stopPropagation();
|
|
394
|
+
this.dispatchEvent(new CustomEvent("contour:annotation-action", { bubbles: true, composed: true, detail: { action, kind: this.dataset.kind || "pin", label: this.getAttribute("label") || "" } }));
|
|
395
|
+
});
|
|
376
396
|
let drag = null;
|
|
377
397
|
this.addEventListener("pointerdown", (e) => {
|
|
398
|
+
if (this.hasAttribute("locked")) return; // R34-168: locked annotations do not drag.
|
|
378
399
|
if (e.button !== undefined && e.button !== 0) return;
|
|
379
400
|
const parent = this.offsetParent || this.parentElement;
|
|
380
401
|
if (!parent) return;
|
|
@@ -796,14 +817,48 @@ class ContourPopover extends ContourBase {
|
|
|
796
817
|
enhance() {
|
|
797
818
|
if (this._wiredPopover) return;
|
|
798
819
|
this._wiredPopover = true;
|
|
799
|
-
|
|
820
|
+
// R34-01: one canonical open/close mirror. Native light-dismiss, Escape,
|
|
821
|
+
// a `popovertarget` trigger and an explicit `hidePopover()` all flip the
|
|
822
|
+
// top layer without running the close button's handler, so the close
|
|
823
|
+
// transition is owned here (beforetoggle, both states) and every path
|
|
824
|
+
// funnels through the idempotent finalize* pair — exactly one
|
|
825
|
+
// `contour:close`, one trigger-state release, one focus restore.
|
|
826
|
+
let openState = false;
|
|
827
|
+
const focusables = () => Array.from(this.querySelectorAll('a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'));
|
|
828
|
+
const finalizeOpen = () => {
|
|
829
|
+
if (openState) return;
|
|
830
|
+
openState = true;
|
|
831
|
+
this.classList.add("is-open");
|
|
832
|
+
wcEmitOverlay(this, "contour:open", {});
|
|
833
|
+
const f = focusables();
|
|
834
|
+
if (f.length) { try { f[0].focus(); } catch (e) {} }
|
|
835
|
+
else { try { this.focus(); } catch (e) {} }
|
|
836
|
+
this._setPopoverTriggerExpanded(true);
|
|
837
|
+
};
|
|
838
|
+
const finalizeClose = () => {
|
|
839
|
+
if (!openState) return;
|
|
840
|
+
openState = false;
|
|
841
|
+
// If focus is still inside the popover it is about to be hidden with the
|
|
842
|
+
// top layer; return it to the anchor trigger (WCAG 2.4.3). Native
|
|
843
|
+
// light-dismiss usually moved focus already, in which case this is a
|
|
844
|
+
// no-op and never steals focus from elsewhere.
|
|
845
|
+
const restore = this.contains(document.activeElement) ? this._popoverAnchorEl : null;
|
|
846
|
+
this.classList.remove("is-open");
|
|
847
|
+
wcEmitOverlay(this, "contour:close", {});
|
|
848
|
+
this._setPopoverTriggerExpanded(false);
|
|
849
|
+
if (restore && typeof restore.focus === "function") { try { restore.focus(); } catch (e) {} }
|
|
850
|
+
};
|
|
851
|
+
const close = () => {
|
|
852
|
+
if (typeof this.hidePopover === "function") { try { this.hidePopover(); } catch (e) {} }
|
|
853
|
+
finalizeClose();
|
|
854
|
+
};
|
|
800
855
|
const keyHandler = (e) => {
|
|
801
|
-
const open = this.classList.contains("is-open") || this.matches(":popover-open");
|
|
856
|
+
const open = openState || this.classList.contains("is-open") || this.matches(":popover-open");
|
|
802
857
|
if (!open) return;
|
|
803
858
|
if (e.key === "Escape") { e.preventDefault(); close(); return; }
|
|
804
859
|
// Focus trap: keep Tab within the popover.
|
|
805
860
|
if (e.key === "Tab") {
|
|
806
|
-
const focusable =
|
|
861
|
+
const focusable = focusables();
|
|
807
862
|
if (!focusable.length) { e.preventDefault(); return; }
|
|
808
863
|
const first = focusable[0];
|
|
809
864
|
const last = focusable[focusable.length - 1];
|
|
@@ -813,17 +868,12 @@ class ContourPopover extends ContourBase {
|
|
|
813
868
|
};
|
|
814
869
|
document.addEventListener("keydown", keyHandler);
|
|
815
870
|
onDispose(this, () => document.removeEventListener("keydown", keyHandler));
|
|
816
|
-
//
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
wcEmitOverlay(this, "contour:open", {});
|
|
820
|
-
const focusable = this.querySelector('a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])');
|
|
821
|
-
if (focusable) { try { focusable.focus(); } catch (e) {} }
|
|
822
|
-
else { try { this.focus(); } catch (e) {} }
|
|
823
|
-
this._setPopoverTriggerExpanded(true);
|
|
824
|
-
};
|
|
871
|
+
// Canonical open AND close both come from the native toggle transition, so
|
|
872
|
+
// a close the component never initiated (Escape, light-dismiss, external
|
|
873
|
+
// hidePopover) still releases is-open, the trigger and focus exactly once.
|
|
825
874
|
this.addEventListener("beforetoggle", (e) => {
|
|
826
|
-
if (e.newState === "open")
|
|
875
|
+
if (e.newState === "open") finalizeOpen();
|
|
876
|
+
else if (e.newState === "closed") finalizeClose();
|
|
827
877
|
});
|
|
828
878
|
// Anchor wiring in render() (_applyPopoverAnchor) so post-upgrade anchor change re-anchors — enhance() is one-shot.
|
|
829
879
|
// Nested popover support: mark parent on nested open. Listen to contour:open and deprecated contour:show.
|
|
@@ -913,6 +963,8 @@ class ContourHoverCard extends ContourBase {
|
|
|
913
963
|
if (hideTimer) clearTimeout(hideTimer);
|
|
914
964
|
hideTimer = setTimeout(hide, 300);
|
|
915
965
|
};
|
|
966
|
+
// R34-15: open state is readable for the explicit touch/pen tap toggle.
|
|
967
|
+
const isOpen = () => (hasPopover ? this.matches(":popover-open") : this.classList.contains("is-open"));
|
|
916
968
|
// WCAG 1.4.13: hoverable — moving the pointer onto the card keeps it open.
|
|
917
969
|
this.addEventListener("mouseenter", cancelTimers);
|
|
918
970
|
this.addEventListener("mouseleave", scheduleHide);
|
|
@@ -937,13 +989,26 @@ class ContourHoverCard extends ContourBase {
|
|
|
937
989
|
const onLeave = () => { scheduleHide(); };
|
|
938
990
|
const onFocus = () => show(trigger);
|
|
939
991
|
const onBlur = () => { scheduleHide(); };
|
|
940
|
-
|
|
992
|
+
// R34-15: mouse hover and keyboard focus are the hover/focus paths above;
|
|
993
|
+
// a touch or pen tap is its own path — it toggles the card explicitly
|
|
994
|
+
// (there is no hover on a coarse pointer). A mouse click is swallowed so
|
|
995
|
+
// it does not immediately close a card the hover already opened.
|
|
996
|
+
let lastPointerType = "mouse";
|
|
997
|
+
const onPointerDown = (e) => { lastPointerType = e.pointerType || "mouse"; };
|
|
998
|
+
const onClick = (e) => {
|
|
999
|
+
if (e && e.preventDefault) e.preventDefault();
|
|
1000
|
+
if (lastPointerType === "touch" || lastPointerType === "pen") {
|
|
1001
|
+
if (isOpen()) hide(); else show(trigger);
|
|
1002
|
+
}
|
|
1003
|
+
};
|
|
1004
|
+
trigger.addEventListener("pointerdown", onPointerDown);
|
|
941
1005
|
trigger.addEventListener("mouseenter", onEnter);
|
|
942
1006
|
trigger.addEventListener("mouseleave", onLeave);
|
|
943
1007
|
trigger.addEventListener("focus", onFocus);
|
|
944
1008
|
trigger.addEventListener("blur", onBlur);
|
|
945
1009
|
trigger.addEventListener("click", onClick);
|
|
946
1010
|
this._hoverAnchorCleanup = () => {
|
|
1011
|
+
trigger.removeEventListener("pointerdown", onPointerDown);
|
|
947
1012
|
trigger.removeEventListener("mouseenter", onEnter);
|
|
948
1013
|
trigger.removeEventListener("mouseleave", onLeave);
|
|
949
1014
|
trigger.removeEventListener("focus", onFocus);
|
|
@@ -1383,6 +1448,63 @@ class ContourSideSheet extends ContourBase {
|
|
|
1383
1448
|
this.addEventListener("click", (e) => {
|
|
1384
1449
|
if (e.target === this) this.close();
|
|
1385
1450
|
});
|
|
1451
|
+
// R33-110 / R34-96: swipe-to-close, scoped to a dedicated edge zone.
|
|
1452
|
+
// Touch/pen only; a drag that starts within EDGE_ZONE px of the anchored
|
|
1453
|
+
// edge and is not on an interactive/scrollable control moves the sheet;
|
|
1454
|
+
// past 80 px toward the edge it closes, a shorter drag snaps back. The
|
|
1455
|
+
// old handler started on any pointerdown, so a horizontal drag on a
|
|
1456
|
+
// nested input, table or range slider closed the sheet from inside it.
|
|
1457
|
+
const EDGE_ZONE = 24; // px; the WCAG 2.5.8 target floor, kept physical
|
|
1458
|
+
const SWIPE_CLOSE = 80; // px past which the sheet commits to closing
|
|
1459
|
+
// A control that owns its own horizontal gesture must never yield to the
|
|
1460
|
+
// sheet's swipe (nested input/table/range/select/editable/canvas).
|
|
1461
|
+
const SWIPE_BLOCK = "input, select, textarea, button, a[href], [role=slider], [role=spinbutton], [contenteditable], table, .c-table-wrap, canvas, [data-no-swipe]";
|
|
1462
|
+
const onBlocked = (t) => t instanceof Element && !!t.closest(SWIPE_BLOCK);
|
|
1463
|
+
// The anchored edge is physical: side=end is the inline-end edge, which
|
|
1464
|
+
// is the right in LTR and the left under RTL.
|
|
1465
|
+
const nearEdge = (clientX) => {
|
|
1466
|
+
const r = this.getBoundingClientRect();
|
|
1467
|
+
const rtl = getComputedStyle(this).direction === "rtl";
|
|
1468
|
+
const atInlineStart = this.getAttribute("side") === "start";
|
|
1469
|
+
const nearLeft = rtl ? !atInlineStart : atInlineStart;
|
|
1470
|
+
return nearLeft ? (clientX - r.left) <= EDGE_ZONE : (r.right - clientX) <= EDGE_ZONE;
|
|
1471
|
+
};
|
|
1472
|
+
let sheetSwipe = null;
|
|
1473
|
+
const onSheetMove = (e) => {
|
|
1474
|
+
if (!sheetSwipe) return;
|
|
1475
|
+
const dx = e.clientX - sheetSwipe.x;
|
|
1476
|
+
sheetSwipe.dx = dx;
|
|
1477
|
+
if (!sheetSwipe.active && Math.abs(dx) > 8) { sheetSwipe.active = true; this.classList.add("is-swiping"); }
|
|
1478
|
+
if (sheetSwipe.active) this.style.setProperty("--sheet-swipe-x", dx + "px");
|
|
1479
|
+
};
|
|
1480
|
+
const endSheetSwipe = () => {
|
|
1481
|
+
window.removeEventListener("pointermove", onSheetMove);
|
|
1482
|
+
window.removeEventListener("pointerup", endSheetSwipe);
|
|
1483
|
+
window.removeEventListener("pointercancel", endSheetSwipe);
|
|
1484
|
+
if (!sheetSwipe) return;
|
|
1485
|
+
const { dx, active } = sheetSwipe;
|
|
1486
|
+
sheetSwipe = null;
|
|
1487
|
+
this.classList.remove("is-swiping");
|
|
1488
|
+
this.style.removeProperty("--sheet-swipe-x");
|
|
1489
|
+
const closing = this.getAttribute("side") === "start" ? dx < -SWIPE_CLOSE : dx > SWIPE_CLOSE;
|
|
1490
|
+
if (active && closing) this.close();
|
|
1491
|
+
};
|
|
1492
|
+
this.addEventListener("pointerdown", (e) => {
|
|
1493
|
+
if (!this.hasAttribute("open")) return;
|
|
1494
|
+
if (e.pointerType === "mouse") return; // mouse keeps text/scroll selection
|
|
1495
|
+
// R34-96: only a drag that begins in the dedicated edge zone, off any
|
|
1496
|
+
// interactive/scrollable control, may swipe the sheet closed.
|
|
1497
|
+
if (onBlocked(e.target) || !nearEdge(e.clientX)) return;
|
|
1498
|
+
sheetSwipe = { x: e.clientX, dx: 0, active: false };
|
|
1499
|
+
window.addEventListener("pointermove", onSheetMove);
|
|
1500
|
+
window.addEventListener("pointerup", endSheetSwipe);
|
|
1501
|
+
window.addEventListener("pointercancel", endSheetSwipe);
|
|
1502
|
+
});
|
|
1503
|
+
onDispose(this, () => {
|
|
1504
|
+
window.removeEventListener("pointermove", onSheetMove);
|
|
1505
|
+
window.removeEventListener("pointerup", endSheetSwipe);
|
|
1506
|
+
window.removeEventListener("pointercancel", endSheetSwipe);
|
|
1507
|
+
});
|
|
1386
1508
|
// Focus management: capture focus on open, restore on close; the transition guard decides whether a close happened.
|
|
1387
1509
|
let wasOpen = false;
|
|
1388
1510
|
const transition = () => {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
You generate UI using **Contour**, a token-driven design system for spatial
|
|
4
4
|
interfaces (routing engines, pedestrian simulators, map tooling, geospatial
|
|
5
|
-
dashboards). Dark and light themes,
|
|
5
|
+
dashboards). Dark and light themes, 258 components, 322 design tokens, zero
|
|
6
6
|
runtime dependencies.
|
|
7
7
|
|
|
8
8
|
## How to use it
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Authored React/JSX source. `className` is a static string, so the validator
|
|
2
|
+
// checks its class tokens against the shipped CSS/contract (R34-138).
|
|
3
|
+
export function RouteCard({ route, trips }) {
|
|
4
|
+
return (
|
|
5
|
+
<div className="c-card">
|
|
6
|
+
<div className="c-card__body">
|
|
7
|
+
<p className="c-prose">{route}</p>
|
|
8
|
+
<button className="c-btn c-btn--secondary" type="button">
|
|
9
|
+
Export GeoJSON
|
|
10
|
+
</button>
|
|
11
|
+
<span className="c-badge">{trips}</span>
|
|
12
|
+
</div>
|
|
13
|
+
</div>
|
|
14
|
+
);
|
|
15
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<!-- Authored Vue SFC source. A static `class` is checked; a dynamic
|
|
2
|
+
`:class` binding is skipped (its classes are not knowable from source). -->
|
|
3
|
+
<template>
|
|
4
|
+
<div class="c-card">
|
|
5
|
+
<div class="c-card__body">
|
|
6
|
+
<p class="c-prose">{{ route }}</p>
|
|
7
|
+
<button class="c-btn c-btn--ghost" type="button">Export GeoJSON</button>
|
|
8
|
+
<span class="c-tag" :class="{ 'is-active': active }">{{ trips }}</span>
|
|
9
|
+
</div>
|
|
10
|
+
</div>
|
|
11
|
+
</template>
|
|
12
|
+
|
|
13
|
+
<script setup>
|
|
14
|
+
defineProps({ route: String, trips: Number, active: Boolean });
|
|
15
|
+
</script>
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<!-- Rendered framework output (e.g. Astro/Vite/Next build): plain HTML a
|
|
3
|
+
consumer actually ships. The validator scans this the same as authored HTML. -->
|
|
4
|
+
<html lang="en">
|
|
5
|
+
<head>
|
|
6
|
+
<meta charset="utf-8" />
|
|
7
|
+
<title>Rendered fixture</title>
|
|
8
|
+
<link rel="stylesheet" href="../../dist/contour.min.css" />
|
|
9
|
+
</head>
|
|
10
|
+
<body>
|
|
11
|
+
<main class="c-stack">
|
|
12
|
+
<h1>Rendered fixture</h1>
|
|
13
|
+
<div class="c-card">
|
|
14
|
+
<div class="c-card__body">
|
|
15
|
+
<p class="c-prose">A rendered card.</p>
|
|
16
|
+
<button class="c-btn c-btn--primary" type="button">Export GeoJSON</button>
|
|
17
|
+
</div>
|
|
18
|
+
</div>
|
|
19
|
+
<div class="c-table-wrap">
|
|
20
|
+
<table class="c-table">
|
|
21
|
+
<caption>Trips</caption>
|
|
22
|
+
<thead>
|
|
23
|
+
<tr><th scope="col">Route</th><th scope="col">Trips</th></tr>
|
|
24
|
+
</thead>
|
|
25
|
+
<tbody>
|
|
26
|
+
<tr><td>North</td><td>42</td></tr>
|
|
27
|
+
</tbody>
|
|
28
|
+
</table>
|
|
29
|
+
</div>
|
|
30
|
+
</main>
|
|
31
|
+
</body>
|
|
32
|
+
</html>
|