contour-ds 1.12.0 → 1.13.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/dist/build-manifest.json +80 -80
- package/dist/contour-wc-content.esm.js +8 -1
- package/dist/contour-wc-content.esm.min.js +1 -1
- package/dist/contour-wc-core.esm.js +15 -8
- package/dist/contour-wc-core.esm.min.js +1 -1
- package/dist/contour-wc-dashboard.esm.js +279 -20
- package/dist/contour-wc-dashboard.esm.min.js +1 -1
- package/dist/contour-wc-data.esm.js +279 -20
- package/dist/contour-wc-data.esm.min.js +1 -1
- package/dist/contour-wc-docs.esm.js +4 -0
- package/dist/contour-wc-feedback.esm.js +59 -7
- package/dist/contour-wc-feedback.esm.min.js +1 -1
- package/dist/contour-wc-forms.esm.js +20 -2
- package/dist/contour-wc-forms.esm.min.js +1 -1
- package/dist/contour-wc-interaction.esm.js +4 -0
- package/dist/contour-wc-layout.esm.js +4 -0
- package/dist/contour-wc-map.esm.js +4 -0
- package/dist/contour-wc-misc.esm.js +4 -0
- package/dist/contour-wc-navigation.esm.js +24 -14
- package/dist/contour-wc-navigation.esm.min.js +1 -1
- package/dist/contour-wc-ui.esm.js +290 -13
- package/dist/contour-wc-ui.esm.min.js +1 -1
- package/dist/contour-wc.esm.js +675 -65
- package/dist/contour-wc.esm.min.js +1 -1
- package/dist/contour-wc.js +675 -65
- package/dist/contour-wc.min.js +1 -1
- package/dist/contour.code-snippets +1 -1
- package/dist/contour.components.json +175 -16
- package/dist/contour.css +160 -1
- package/dist/contour.d.ts +6 -4
- package/dist/contour.html-data.json +68 -2
- package/dist/contour.min.css +1 -1
- package/dist/contour.react.d.ts +2 -2
- package/dist/contour.single.html +1 -1
- package/dist/contour.single.min.css +1 -1
- package/dist/contour.vue.d.ts +2 -2
- package/dist/contour.web-types.json +68 -3
- package/dist/custom-elements.json +265 -2
- 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 +1 -1
- 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 +2 -2
- 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 +1 -1
- package/dist/docs/type.md +1 -1
- package/dist/docs/webcomponents.md +1 -1
- 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 +13 -7
- package/dist/wc/content.mjs +4 -1
- package/dist/wc/core.mjs +1 -0
- package/dist/wc/data-chart.mjs +147 -12
- package/dist/wc/data-export.mjs +43 -5
- package/dist/wc/data-series.mjs +74 -0
- package/dist/wc/data-table.mjs +13 -5
- package/dist/wc/feedback.mjs +55 -7
- package/dist/wc/forms-input.mjs +16 -2
- package/dist/wc/index.mjs +1 -1
- package/dist/wc/navigation-menu.mjs +20 -14
- package/dist/wc/shadow.mjs +4 -0
- package/dist/wc/ui-atoms.mjs +134 -3
- package/dist/wc/ui-data.mjs +67 -0
- package/dist/wc/ui-feedback.mjs +8 -1
- package/dist/wc/ui-overlays.mjs +77 -9
- package/integrations/libreship/contract.json +9 -2
- package/package.json +1 -1
package/dist/wc/feedback.mjs
CHANGED
|
@@ -7,6 +7,33 @@ import { wireRemovable, modalContain } from './behaviours.mjs';
|
|
|
7
7
|
function overlayIsModal(host) {
|
|
8
8
|
return host.getAttribute("mode") !== "inline";
|
|
9
9
|
}
|
|
10
|
+
// U-12: a shared open-overlay stack. Nested overlays (a dialog inside a drawer,
|
|
11
|
+
// a sheet inside a dialog) must close only the topmost on Escape — without this a
|
|
12
|
+
// single Escape bubbled to every ancestor overlay and closed them all. Each
|
|
13
|
+
// overlay pushes on open and pops on close; the Escape handler acts only when it
|
|
14
|
+
// is the top of the stack, and stops the event so an ancestor handler never runs.
|
|
15
|
+
const overlayStack = [];
|
|
16
|
+
function overlayPush(host) {
|
|
17
|
+
const i = overlayStack.indexOf(host);
|
|
18
|
+
if (i >= 0) overlayStack.splice(i, 1);
|
|
19
|
+
overlayStack.push(host);
|
|
20
|
+
}
|
|
21
|
+
function overlayPop(host) {
|
|
22
|
+
const i = overlayStack.indexOf(host);
|
|
23
|
+
if (i >= 0) overlayStack.splice(i, 1);
|
|
24
|
+
}
|
|
25
|
+
function overlayIsTop(host) {
|
|
26
|
+
return overlayStack[overlayStack.length - 1] === host;
|
|
27
|
+
}
|
|
28
|
+
// U-12: the Escape branch shared by dialog/drawer/sheet. Returns true when the
|
|
29
|
+
// event was consumed (so the caller can `return`).
|
|
30
|
+
function overlayHandleEscape(host, e) {
|
|
31
|
+
if (e.key !== "Escape") return false;
|
|
32
|
+
if (!overlayIsTop(host)) return true; // a higher overlay owns this Escape
|
|
33
|
+
e.stopPropagation();
|
|
34
|
+
host.close();
|
|
35
|
+
return true;
|
|
36
|
+
}
|
|
10
37
|
// R31-12: an authored `open` at load displays the modal (CSS [open]) but never
|
|
11
38
|
// ran show(), so it was not actually modal — no aria-modal, no inert siblings,
|
|
12
39
|
// no focus inside. Engage the modal for an initial open without re-entering
|
|
@@ -15,6 +42,7 @@ function engageInitialModal(host) {
|
|
|
15
42
|
if (!host.hasAttribute("open") || host._modalEngaged) return;
|
|
16
43
|
host._modalEngaged = true;
|
|
17
44
|
host._overlayOpen = true;
|
|
45
|
+
overlayPush(host); // U-12: an initially-open overlay joins the stack.
|
|
18
46
|
host.classList.add("is-open");
|
|
19
47
|
if (overlayIsModal(host)) {
|
|
20
48
|
host.setAttribute("aria-modal", "true");
|
|
@@ -112,12 +140,14 @@ class ContourDialog extends ContourBase {
|
|
|
112
140
|
};
|
|
113
141
|
onDispose(this, () => {
|
|
114
142
|
if (this.hasAttribute("open")) modalContain(this, false);
|
|
143
|
+
overlayPop(this); // U-12
|
|
115
144
|
this._removeScrim();
|
|
116
145
|
});
|
|
117
146
|
// open attribute is written, never observed — no render re-entry.
|
|
118
147
|
this.show = () => {
|
|
119
148
|
if (this.hasAttribute("open")) return;
|
|
120
149
|
this._overlayOpen = true;
|
|
150
|
+
overlayPush(this); // U-12
|
|
121
151
|
this._dialogLastFocus = document.activeElement;
|
|
122
152
|
// Guard our own `open` write: syncDeclarativeOpen would otherwise see the
|
|
123
153
|
// attribute change (aria-modal is not set yet) and re-enter show(), firing
|
|
@@ -141,6 +171,7 @@ class ContourDialog extends ContourBase {
|
|
|
141
171
|
// a lower stacked dialog stays inert.
|
|
142
172
|
const wasOpen = this.hasAttribute("open") || this.hasAttribute("aria-modal") || this._overlayOpen;
|
|
143
173
|
this._overlayOpen = false;
|
|
174
|
+
overlayPop(this); // U-12
|
|
144
175
|
const dlg = this.querySelector("dialog") || (this.tagName === "DIALOG" ? this : null);
|
|
145
176
|
if (dlg && typeof dlg.close === "function") dlg.close();
|
|
146
177
|
// Guard our own `open` removal so syncDeclarativeOpen does not re-enter
|
|
@@ -169,9 +200,9 @@ class ContourDialog extends ContourBase {
|
|
|
169
200
|
// Backdrop click: clicking the host surface (not its content) closes.
|
|
170
201
|
if (e.target === this) this.close();
|
|
171
202
|
});
|
|
172
|
-
// Escape closes only while open;
|
|
203
|
+
// Escape closes only while open; a nested overlay closes only the topmost (U-12).
|
|
173
204
|
this.addEventListener("keydown", (e) => {
|
|
174
|
-
if (e.key === "Escape" && this.hasAttribute("open")) this
|
|
205
|
+
if (e.key === "Escape" && this.hasAttribute("open")) overlayHandleEscape(this, e);
|
|
175
206
|
});
|
|
176
207
|
engageInitialModal(this);
|
|
177
208
|
}
|
|
@@ -222,14 +253,25 @@ class ContourAlert extends ContourBase {
|
|
|
222
253
|
const t = this.querySelector(".c-alert__title");
|
|
223
254
|
if (t) t.remove();
|
|
224
255
|
}
|
|
225
|
-
// Authored children move into .c-alert__body (default slot); `body` attribute fills when no children.
|
|
256
|
+
// Authored children move into .c-alert__body (default slot); `body` attribute fills when no children.
|
|
226
257
|
const body = this.getAttribute("body");
|
|
227
258
|
const authored = Array.from(this.childNodes).filter((n) => {
|
|
228
|
-
|
|
259
|
+
// U-9: generated controls (action/close) are NOT authored children. Before
|
|
260
|
+
// this they were folded into the body on re-render, which wiped a changed
|
|
261
|
+
// `body` attribute in place (authored.length was truthy, so the body branch
|
|
262
|
+
// never ran). Excluding them keeps `body` authoritative across re-renders.
|
|
263
|
+
if (n.nodeType === 1 && n.classList && (n.classList.contains("c-alert__icon") || n.classList.contains("c-alert__title") || n.classList.contains("c-alert__body") || n.classList.contains("c-alert__action") || n.classList.contains("c-alert__close"))) return false;
|
|
229
264
|
if (n.nodeType === 3 && !n.textContent.trim()) return false;
|
|
230
265
|
return true;
|
|
231
266
|
});
|
|
232
|
-
|
|
267
|
+
// U-9: the `body` attribute is authoritative across re-renders. The base
|
|
268
|
+
// class unwraps the previous `.c-alert__body` content back to the host
|
|
269
|
+
// before re-rendering, so the old body text returns as an "authored" text
|
|
270
|
+
// node; drop those lifted text nodes so a changed `body` value wins.
|
|
271
|
+
if (body) {
|
|
272
|
+
for (const n of authored) { if (n.nodeType === 3 && n.parentNode === this) n.remove(); }
|
|
273
|
+
}
|
|
274
|
+
if (authored.length && !body) {
|
|
233
275
|
const b = this.ensure(".c-alert__body", () => { const el = document.createElement("div"); el.className = "c-alert__body"; return el; });
|
|
234
276
|
b.textContent = "";
|
|
235
277
|
for (const n of authored) b.appendChild(n);
|
|
@@ -782,11 +824,13 @@ class ContourDrawer extends ContourBase {
|
|
|
782
824
|
};
|
|
783
825
|
onDispose(this, () => {
|
|
784
826
|
if (this.hasAttribute("open") || this._overlayOpen) modalContain(this, false);
|
|
827
|
+
overlayPop(this); // U-12
|
|
785
828
|
this._removeScrim();
|
|
786
829
|
});
|
|
787
830
|
this.show = () => {
|
|
788
831
|
if (this.hasAttribute("open")) return;
|
|
789
832
|
this._overlayOpen = true;
|
|
833
|
+
overlayPush(this); // U-12
|
|
790
834
|
this._drawerLastFocus = document.activeElement;
|
|
791
835
|
// Guard our own `open` write (see ContourDialog.show): re-entry doubles
|
|
792
836
|
// contour:open and leaks a modalContain depth.
|
|
@@ -811,6 +855,7 @@ class ContourDrawer extends ContourBase {
|
|
|
811
855
|
// (or an open inline panel) must still release its state.
|
|
812
856
|
if (!this.hasAttribute("open") && !this._overlayOpen) return;
|
|
813
857
|
this._overlayOpen = false;
|
|
858
|
+
overlayPop(this); // U-12
|
|
814
859
|
// Guard our own `open` removal (see ContourDialog.close): re-entry
|
|
815
860
|
// doubles the close event and the modalContain release.
|
|
816
861
|
this._declarativeOpen = true;
|
|
@@ -831,7 +876,7 @@ class ContourDrawer extends ContourBase {
|
|
|
831
876
|
if (e.target === this) this.close();
|
|
832
877
|
});
|
|
833
878
|
this.addEventListener("keydown", (e) => {
|
|
834
|
-
if (e.key === "Escape" && this.hasAttribute("open")) this
|
|
879
|
+
if (e.key === "Escape" && this.hasAttribute("open")) overlayHandleEscape(this, e);
|
|
835
880
|
});
|
|
836
881
|
// Swipe-to-close (deferred P3): horizontal swipe past threshold closes.
|
|
837
882
|
let touchStartX = 0, touchStartY = 0;
|
|
@@ -938,11 +983,13 @@ class ContourSheet extends ContourBase {
|
|
|
938
983
|
};
|
|
939
984
|
onDispose(this, () => {
|
|
940
985
|
if (this.hasAttribute("open") || this._overlayOpen) modalContain(this, false);
|
|
986
|
+
overlayPop(this); // U-12
|
|
941
987
|
this._removeScrim();
|
|
942
988
|
});
|
|
943
989
|
this.show = () => {
|
|
944
990
|
if (this.hasAttribute("open")) return;
|
|
945
991
|
this._overlayOpen = true;
|
|
992
|
+
overlayPush(this); // U-12
|
|
946
993
|
this._sheetLastFocus = document.activeElement;
|
|
947
994
|
// Guard our own `open` write (see ContourDialog.show): re-entry doubles
|
|
948
995
|
// contour:open and leaks a modalContain depth.
|
|
@@ -965,6 +1012,7 @@ class ContourSheet extends ContourBase {
|
|
|
965
1012
|
// (or an open inline panel) must still release its state.
|
|
966
1013
|
if (!this.hasAttribute("open") && !this._overlayOpen) return;
|
|
967
1014
|
this._overlayOpen = false;
|
|
1015
|
+
overlayPop(this); // U-12
|
|
968
1016
|
// Guard our own `open` removal (see ContourDialog.close): re-entry
|
|
969
1017
|
// doubles the close event and the modalContain release.
|
|
970
1018
|
this._declarativeOpen = true;
|
|
@@ -985,7 +1033,7 @@ class ContourSheet extends ContourBase {
|
|
|
985
1033
|
if (e.target === this) this.close();
|
|
986
1034
|
});
|
|
987
1035
|
this.addEventListener("keydown", (e) => {
|
|
988
|
-
if (e.key === "Escape" && this.hasAttribute("open")) this
|
|
1036
|
+
if (e.key === "Escape" && this.hasAttribute("open")) overlayHandleEscape(this, e);
|
|
989
1037
|
});
|
|
990
1038
|
// Swipe-to-close (deferred P3): vertical swipe down past threshold closes.
|
|
991
1039
|
let touchStartY = 0, touchStartX = 0;
|
package/dist/wc/forms-input.mjs
CHANGED
|
@@ -138,6 +138,13 @@ class ContourTextarea extends ContourBase {
|
|
|
138
138
|
/**
|
|
139
139
|
* Input: an `<input>` wrapper with type, placeholder, required, value, disabled,
|
|
140
140
|
* error and help states. Form associated; emits `contour:input` / `contour:change`.
|
|
141
|
+
*
|
|
142
|
+
* The help/error message (`.c-input__message`) carries a per-instance `id` and is
|
|
143
|
+
* linked to the generated `<input>` with `aria-describedby`; `error` also sets
|
|
144
|
+
* `aria-invalid="true"`. The CSS `:user-valid` / `:user-invalid` de-emphasis is
|
|
145
|
+
* the visual half of that state — it activates only after the user has edited and
|
|
146
|
+
* blurred the control (the browser's `:user-*` heuristic), so a pristine field is
|
|
147
|
+
* never marked invalid before the user types.
|
|
141
148
|
*/
|
|
142
149
|
class ContourInputFull extends ContourBase {
|
|
143
150
|
static get observed() { return ["type", "placeholder", "required", "value", "disabled", "error", "help", "label", "name"]; }
|
|
@@ -171,10 +178,17 @@ class ContourInputFull extends ContourBase {
|
|
|
171
178
|
let msg = this.querySelector(".c-input__message");
|
|
172
179
|
if (err || help) {
|
|
173
180
|
if (!msg) { msg = document.createElement("div"); msg.className = "c-input__message"; this.appendChild(msg); }
|
|
181
|
+
// U-11: a stable per-instance id links the message to the control via
|
|
182
|
+
// aria-describedby, so a screen reader reads help/error on focus.
|
|
183
|
+
if (!msg.id) msg.id = contourId("input-message");
|
|
174
184
|
msg.textContent = err || help || "";
|
|
175
185
|
msg.classList.toggle("c-input__message--error", !!err);
|
|
176
|
-
|
|
177
|
-
if (
|
|
186
|
+
input.setAttribute("aria-describedby", msg.id);
|
|
187
|
+
} else if (msg) { msg.remove(); input.removeAttribute("aria-describedby"); }
|
|
188
|
+
// U-11: `aria-invalid` reflects the error state to AT (the CSS :user-invalid
|
|
189
|
+
// de-emphasis is the visual half; this is the semantic half).
|
|
190
|
+
if (err) { this.classList.add("is-error"); input.setAttribute("aria-invalid", "true"); }
|
|
191
|
+
else { this.classList.remove("is-error"); input.removeAttribute("aria-invalid"); }
|
|
178
192
|
}
|
|
179
193
|
enhance() {
|
|
180
194
|
const input = this.querySelector("input");
|
package/dist/wc/index.mjs
CHANGED
|
@@ -37,7 +37,7 @@ export { SHADOW_MARKUP, renderShadowDSD };
|
|
|
37
37
|
// Published version + readiness signal, fired after every fragment runs. The
|
|
38
38
|
// literal is a source-time fallback; the build stamps the package.json version.
|
|
39
39
|
/** Published component runtime version. */
|
|
40
|
-
export const CONTOUR_VERSION = "1.
|
|
40
|
+
export const CONTOUR_VERSION = "1.13.0";
|
|
41
41
|
if (typeof window !== "undefined") {
|
|
42
42
|
window.ContourVersion = CONTOUR_VERSION;
|
|
43
43
|
if (!window.Contour) {
|
|
@@ -520,8 +520,8 @@ class ContourBreadcrumb extends ContourBase {
|
|
|
520
520
|
}
|
|
521
521
|
define("contour-breadcrumb", ContourBreadcrumb);
|
|
522
522
|
class ContourPagination extends ContourBase {
|
|
523
|
-
|
|
524
|
-
|
|
523
|
+
static get observed() { return ["pages", "current", "index-base", "empty", "loading", "error", "retry", "src", "lazy", "refresh", "timeout", "skeleton", "persist", "cache-key", "no-cache"]; }
|
|
524
|
+
static get properties() { return { pages: { attribute: "pages" }, current: { attribute: "current" }, src: { attribute: "src" } }; }
|
|
525
525
|
render() {
|
|
526
526
|
this.classList.add("c-pagination");
|
|
527
527
|
// Pagination is a navigation landmark: APG names it; screen reader's landmark list is where readers look for "page N of M".
|
|
@@ -533,7 +533,12 @@ class ContourPagination extends ContourBase {
|
|
|
533
533
|
const pages = remoteData(this, "pages");
|
|
534
534
|
// Drop previously generated links so a re-render cannot stack a second set.
|
|
535
535
|
Array.from(this.querySelectorAll(".c-pagination__link")).forEach((n) => n.remove());
|
|
536
|
-
|
|
536
|
+
// U-8: controlled 0-based mode. `index-base="0"` makes `current`, the
|
|
537
|
+
// emitted `page`, and the button labels 0-based (0 .. pages-1), so a
|
|
538
|
+
// consumer with a 0-based in-memory model drives the pager directly. The
|
|
539
|
+
// default stays 1-based.
|
|
540
|
+
const base = this.getAttribute("index-base") === "0" ? 0 : 1;
|
|
541
|
+
let currentAttr = this.getAttribute("current") || String(base);
|
|
537
542
|
if (this.getAttribute("persist") === "storage" && this.id) {
|
|
538
543
|
try { const stored = localStorage.getItem("contour-pagination:" + this.id); if (stored !== null) currentAttr = stored; } catch (e) {}
|
|
539
544
|
} else if (this.getAttribute("persist") === "url") {
|
|
@@ -541,7 +546,7 @@ class ContourPagination extends ContourBase {
|
|
|
541
546
|
// `c-pagination` parameter.
|
|
542
547
|
try { const key = this.id ? "c-pagination-" + this.id : "c-pagination"; const v = new URLSearchParams(window.location.search).get(key); if (v !== null) currentAttr = v; } catch (e) {}
|
|
543
548
|
}
|
|
544
|
-
const current = parseInt(currentAttr, "10") ||
|
|
549
|
+
const current = parseInt(currentAttr, "10") || base;
|
|
545
550
|
// Publish current page as `page` attribute so state is readable without a click (activate handler sets it on navigation).
|
|
546
551
|
this.setAttribute("page", String(current));
|
|
547
552
|
if (pages) {
|
|
@@ -549,6 +554,7 @@ class ContourPagination extends ContourBase {
|
|
|
549
554
|
if (!Number.isFinite(count) || count < 1) {
|
|
550
555
|
try { const p = JSON.parse(pages); if (Array.isArray(p)) count = p.length; } catch (e) {}
|
|
551
556
|
}
|
|
557
|
+
const last = base + count - 1;
|
|
552
558
|
// Prev button.
|
|
553
559
|
const prev = document.createElement("button");
|
|
554
560
|
prev.type = "button";
|
|
@@ -556,17 +562,17 @@ class ContourPagination extends ContourBase {
|
|
|
556
562
|
prev.setAttribute("data-action", "prev");
|
|
557
563
|
setHTML(prev, '<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-chevron-left" /></svg>');
|
|
558
564
|
prev.setAttribute("aria-label", labelText(this, "prev", "Previous page"));
|
|
559
|
-
// Disable prev at page
|
|
560
|
-
if (current <=
|
|
565
|
+
// Disable prev at the first page.
|
|
566
|
+
if (current <= base) prev.setAttribute("disabled", "");
|
|
561
567
|
this.appendChild(prev);
|
|
562
568
|
// Ellipsis windowing: show first, last, current±1, with ellipsis for gaps. Keeps button count bounded for large page counts (60 pages → ~7 buttons).
|
|
563
|
-
const window = new Set([
|
|
564
|
-
if (current >
|
|
565
|
-
if (current <
|
|
566
|
-
const sorted = [...window].filter(p => p >=
|
|
567
|
-
let prevPage =
|
|
569
|
+
const window = new Set([base, last, current]);
|
|
570
|
+
if (current > base) window.add(current - 1);
|
|
571
|
+
if (current < last) window.add(current + 1);
|
|
572
|
+
const sorted = [...window].filter(p => p >= base && p <= last).sort((a, b) => a - b);
|
|
573
|
+
let prevPage = base - 1;
|
|
568
574
|
for (const i of sorted) {
|
|
569
|
-
if (prevPage && i - prevPage > 1) {
|
|
575
|
+
if (prevPage >= base && i - prevPage > 1) {
|
|
570
576
|
const gap = document.createElement("span");
|
|
571
577
|
gap.className = "c-pagination__ellipsis";
|
|
572
578
|
gap.textContent = "…";
|
|
@@ -590,8 +596,8 @@ class ContourPagination extends ContourBase {
|
|
|
590
596
|
next.setAttribute("data-action", "next");
|
|
591
597
|
setHTML(next, '<svg aria-hidden="true" viewBox="0 0 24 24"><use href="#i-chevron-right" /></svg>');
|
|
592
598
|
next.setAttribute("aria-label", labelText(this, "next", "Next page"));
|
|
593
|
-
// Disable next on last page.
|
|
594
|
-
if (current >=
|
|
599
|
+
// Disable next on the last page.
|
|
600
|
+
if (current >= last) next.setAttribute("disabled", "");
|
|
595
601
|
this.appendChild(next);
|
|
596
602
|
} else {
|
|
597
603
|
renderEmpty(this, "pagination");
|
package/dist/wc/shadow.mjs
CHANGED
|
@@ -422,6 +422,10 @@ import { setHTML, define, MODS, contourId, labelText } from './core.mjs';
|
|
|
422
422
|
// Shadow tabs are a styling shell: panels are authored by the consumer
|
|
423
423
|
shadow("contour-shadow-tabs", `<div class="c-tabs" part="tabs"><div class="c-tabs__list" part="list" role="tablist"><slot name="tabs"></slot></div><div class="c-tabs__panels" role="presentation"><slot></slot></div></div>`);
|
|
424
424
|
shadow("contour-shadow-breadcrumb", `<nav class="c-breadcrumb" part="breadcrumb" aria-label="Breadcrumb"><ol><slot></slot></ol></nav>`);
|
|
425
|
+
// U-17: contour-shadow-menu is a shadow-styled shell with role="menu"; the
|
|
426
|
+
// consumer slots `role="menuitem"` children. It has no open/focus state of its
|
|
427
|
+
// own — pair it with contour-context-menu (which owns open/Escape/focus
|
|
428
|
+
// return) or drive focus with the standard menu keyboard contract.
|
|
425
429
|
shadow("contour-shadow-menu", `<div class="c-menu" part="menu" role="menu"><slot></slot></div>`);
|
|
426
430
|
shadow("contour-shadow-combobox", `<div class="c-combobox" part="combobox"><input class="c-combobox__input" part="input" type="text" /><ul class="c-combobox__list" part="list" hidden><slot></slot></ul></div>`);
|
|
427
431
|
shadow("contour-shadow-chart", `<div class="c-chart" part="chart"><div class="c-chart__plot" part="plot"><slot></slot></div></div>`);
|
package/dist/wc/ui-atoms.mjs
CHANGED
|
@@ -333,13 +333,144 @@ class ContourLoading extends ContourBase {
|
|
|
333
333
|
}
|
|
334
334
|
define("contour-loading", ContourLoading);
|
|
335
335
|
/**
|
|
336
|
-
* Elevation: a
|
|
337
|
-
*
|
|
336
|
+
* Elevation profile: a filled area + line of elevation over distance, with an
|
|
337
|
+
* accessible data table and a selection event.
|
|
338
|
+
*
|
|
339
|
+
* Contract (U-16) — all inputs are JSON attribute strings:
|
|
340
|
+
* - `points`: the primary profile — an array of samples. A sample is a number
|
|
341
|
+
* (elevation at an even distance index), a `[distance, elevation]` pair, or an
|
|
342
|
+
* object `{ d|distance|x, e|elevation|y }`.
|
|
343
|
+
* - `series`: an array of profiles `{ label?, unit?, points }` for comparison;
|
|
344
|
+
* when present it overrides `points`.
|
|
345
|
+
* - `unit`: elevation unit label (`m`, `ft`, …), default `m`.
|
|
346
|
+
* - `distance-unit`: distance unit label (`km`, `mi`, …), default `km`.
|
|
347
|
+
* - `color`: CSS colour for the primary line/area (safeColor-guarded).
|
|
348
|
+
* Selecting a point (pointer move / click) emits `contour:elevation-select` with
|
|
349
|
+
* `{ index, distance, elevation, series, unit }` so a host geometry adapter can
|
|
350
|
+
* read the profile without owning the rendering.
|
|
338
351
|
*/
|
|
339
352
|
class ContourElevation extends ContourBase {
|
|
353
|
+
static get observed() { return ["points", "series", "unit", "distance-unit", "label", "title", "color", "empty"]; }
|
|
354
|
+
static get properties() { return { points: { attribute: "points" }, series: { attribute: "series" }, unit: { attribute: "unit" }, "distance-unit": { attribute: "distance-unit" }, label: { attribute: "label" }, title: { attribute: "title" }, color: { attribute: "color" } }; }
|
|
355
|
+
static normalizePoints(raw) {
|
|
356
|
+
const out = [];
|
|
357
|
+
(Array.isArray(raw) ? raw : []).forEach((p, i) => {
|
|
358
|
+
let d, e;
|
|
359
|
+
if (typeof p === "number") { d = i; e = p; }
|
|
360
|
+
else if (Array.isArray(p)) { d = Number(p[0]); e = Number(p[1]); }
|
|
361
|
+
else if (p && typeof p === "object") { d = Number(p.d ?? p.distance ?? p.x ?? i); e = Number(p.e ?? p.elevation ?? p.y); }
|
|
362
|
+
if (Number.isFinite(d) && Number.isFinite(e)) out.push({ d, e });
|
|
363
|
+
});
|
|
364
|
+
return out;
|
|
365
|
+
}
|
|
340
366
|
render() {
|
|
341
|
-
// .c-elevation carries --shadow-md (one ramp step); this raises the surface
|
|
367
|
+
// .c-elevation carries --shadow-md (one ramp step); this raises the surface.
|
|
342
368
|
this.classList.add("c-elevation");
|
|
369
|
+
const unit = this.getAttribute("unit") || "m";
|
|
370
|
+
const dUnit = this.getAttribute("distance-unit") || "km";
|
|
371
|
+
// Build the profile list: `series` (array) overrides a single `points`.
|
|
372
|
+
let profiles = [];
|
|
373
|
+
const rawSeries = this.getAttribute("series");
|
|
374
|
+
if (rawSeries) { try { const s = JSON.parse(rawSeries); if (Array.isArray(s)) profiles = s; } catch (e) { warnBadJson(this, "series", e); } }
|
|
375
|
+
if (!profiles.length) {
|
|
376
|
+
const rawPoints = this.getAttribute("points");
|
|
377
|
+
let pts = [];
|
|
378
|
+
if (rawPoints) { try { const p = JSON.parse(rawPoints); pts = ContourElevation.normalizePoints(p); } catch (e) { warnBadJson(this, "points", e); } }
|
|
379
|
+
if (pts.length) profiles = [{ points: pts }];
|
|
380
|
+
}
|
|
381
|
+
profiles = profiles.map((s, i) => ({ label: (s && s.label) || labelText(this, "profile", "Profile") + " " + (i + 1), unit: (s && s.unit) || unit, points: ContourElevation.normalizePoints(s && s.points) })).filter((s) => s.points.length);
|
|
382
|
+
if (!profiles.length) { renderEmpty(this, "elevation"); return; }
|
|
383
|
+
// Shared domains across every profile so overlays align.
|
|
384
|
+
let dMin = Infinity, dMax = -Infinity, eMin = Infinity, eMax = -Infinity;
|
|
385
|
+
profiles.forEach((s) => s.points.forEach((p) => { if (p.d < dMin) dMin = p.d; if (p.d > dMax) dMax = p.d; if (p.e < eMin) eMin = p.e; if (p.e > eMax) eMax = p.e; }));
|
|
386
|
+
if (dMax === dMin) dMax = dMin + 1;
|
|
387
|
+
if (eMax === eMin) { eMax = eMin + 1; eMin = eMin - 1; }
|
|
388
|
+
const W = 300, H = 120;
|
|
389
|
+
const x = (d) => ((d - dMin) / (dMax - dMin)) * W;
|
|
390
|
+
const y = (e) => H - ((e - eMin) / (eMax - eMin)) * H;
|
|
391
|
+
const primary = this.getAttribute("color") ? safeColor(this.getAttribute("color")) : null;
|
|
392
|
+
const frag = document.createDocumentFragment();
|
|
393
|
+
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
394
|
+
svg.setAttribute("viewBox", `0 0 ${W} ${H}`);
|
|
395
|
+
svg.setAttribute("preserveAspectRatio", "none");
|
|
396
|
+
svg.setAttribute("aria-hidden", "true");
|
|
397
|
+
svg.classList.add("c-elevation__svg");
|
|
398
|
+
profiles.forEach((s, si) => {
|
|
399
|
+
const color = si === 0 && primary ? primary : `var(--chart-${(si % 12) + 1})`;
|
|
400
|
+
const line = s.points.map((p, i) => `${i === 0 ? "M" : "L"}${x(p.d).toFixed(2)} ${y(p.e).toFixed(2)}`).join(" ");
|
|
401
|
+
if (si === 0) {
|
|
402
|
+
const area = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
403
|
+
area.setAttribute("class", "c-elevation__area");
|
|
404
|
+
area.style.setProperty("--c", color);
|
|
405
|
+
area.setAttribute("d", `${line} L${x(s.points[s.points.length - 1].d).toFixed(2)} ${H} L${x(s.points[0].d).toFixed(2)} ${H} Z`);
|
|
406
|
+
svg.appendChild(area);
|
|
407
|
+
}
|
|
408
|
+
const path = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
409
|
+
path.setAttribute("class", "c-elevation__line");
|
|
410
|
+
path.style.setProperty("--c", color);
|
|
411
|
+
path.setAttribute("d", line);
|
|
412
|
+
svg.appendChild(path);
|
|
413
|
+
});
|
|
414
|
+
frag.appendChild(svg);
|
|
415
|
+
const plot = this.ensure(".c-elevation__plot", () => { const el = document.createElement("div"); el.className = "c-elevation__plot"; return el; });
|
|
416
|
+
this.keepNode(plot);
|
|
417
|
+
plot.replaceChildren(frag);
|
|
418
|
+
// Axis readout: distance ends + elevation min/max, with units.
|
|
419
|
+
const axis = this.ensure(".c-elevation__axis", () => { const el = document.createElement("div"); el.className = "c-elevation__axis"; return el; });
|
|
420
|
+
axis.innerHTML = "";
|
|
421
|
+
const mk = (t) => { const s = document.createElement("span"); s.textContent = t; return s; };
|
|
422
|
+
axis.append(mk(formatValue(dMin) + " " + dUnit), mk(formatValue((dMin + dMax) / 2) + " " + dUnit), mk(formatValue(dMax) + " " + dUnit));
|
|
423
|
+
// Selection marker (primary profile), positioned by fraction.
|
|
424
|
+
const marker = this.ensure(".c-elevation__marker", () => { const el = document.createElement("div"); el.className = "c-elevation__marker"; el.setAttribute("aria-hidden", "true"); return el; });
|
|
425
|
+
marker.hidden = true;
|
|
426
|
+
// Accessible data table (visually hidden): distance + elevation per profile.
|
|
427
|
+
let table = this.querySelector(".c-elevation__data-table");
|
|
428
|
+
if (!table) { table = document.createElement("table"); table.className = "c-elevation__data-table visually-hidden"; this.appendChild(table); }
|
|
429
|
+
table.innerHTML = "";
|
|
430
|
+
const cap = document.createElement("caption");
|
|
431
|
+
cap.textContent = this.getAttribute("title") || this.getAttribute("aria-label") || labelText(this, "elevation-profile", "Elevation profile");
|
|
432
|
+
table.appendChild(cap);
|
|
433
|
+
const thead = document.createElement("thead");
|
|
434
|
+
const hr = document.createElement("tr");
|
|
435
|
+
const h0 = document.createElement("th"); h0.setAttribute("scope", "col"); h0.textContent = labelText(this, "distance", "Distance") + " (" + dUnit + ")"; hr.appendChild(h0);
|
|
436
|
+
profiles.forEach((s) => { const h = document.createElement("th"); h.setAttribute("scope", "col"); h.textContent = s.label + " (" + s.unit + ")"; hr.appendChild(h); });
|
|
437
|
+
thead.appendChild(hr); table.appendChild(thead);
|
|
438
|
+
const tbody = document.createElement("tbody");
|
|
439
|
+
const n = Math.max(...profiles.map((s) => s.points.length));
|
|
440
|
+
for (let i = 0; i < n; i++) {
|
|
441
|
+
const tr = document.createElement("tr");
|
|
442
|
+
const td0 = document.createElement("th"); td0.setAttribute("scope", "row");
|
|
443
|
+
const dp = profiles[0].points[i];
|
|
444
|
+
td0.textContent = dp ? formatValue(dp.d) : ""; tr.appendChild(td0);
|
|
445
|
+
profiles.forEach((s) => { const td = document.createElement("td"); const p = s.points[i]; td.textContent = p ? formatValue(p.e) : ""; tr.appendChild(td); });
|
|
446
|
+
tbody.appendChild(tr);
|
|
447
|
+
}
|
|
448
|
+
table.appendChild(tbody);
|
|
449
|
+
// Store the primary profile for the selection handler.
|
|
450
|
+
this._elevationPrimary = profiles[0];
|
|
451
|
+
this._elevationDomain = { dMin, dMax };
|
|
452
|
+
}
|
|
453
|
+
enhance() {
|
|
454
|
+
if (this._wiredElevation) return;
|
|
455
|
+
this._wiredElevation = true;
|
|
456
|
+
const select = (clientX) => {
|
|
457
|
+
const plot = this.querySelector(".c-elevation__plot");
|
|
458
|
+
const prof = this._elevationPrimary;
|
|
459
|
+
const dom = this._elevationDomain;
|
|
460
|
+
if (!plot || !prof || !dom || !prof.points.length) return;
|
|
461
|
+
const rect = plot.getBoundingClientRect();
|
|
462
|
+
if (!rect.width) return;
|
|
463
|
+
const frac = Math.max(0, Math.min(1, (clientX - rect.left) / rect.width));
|
|
464
|
+
const targetD = dom.dMin + frac * (dom.dMax - dom.dMin);
|
|
465
|
+
let best = 0, bestDiff = Infinity;
|
|
466
|
+
prof.points.forEach((p, i) => { const diff = Math.abs(p.d - targetD); if (diff < bestDiff) { bestDiff = diff; best = i; } });
|
|
467
|
+
const p = prof.points[best];
|
|
468
|
+
const marker = this.querySelector(".c-elevation__marker");
|
|
469
|
+
if (marker) { marker.hidden = false; marker.style.left = (frac * 100).toFixed(3) + "%"; }
|
|
470
|
+
this.dispatchEvent(new CustomEvent("contour:elevation-select", { bubbles: true, composed: true, detail: { index: best, distance: p.d, elevation: p.e, series: prof.label, unit: prof.unit } }));
|
|
471
|
+
};
|
|
472
|
+
this.addEventListener("pointermove", (e) => select(e.clientX));
|
|
473
|
+
this.addEventListener("click", (e) => select(e.clientX));
|
|
343
474
|
}
|
|
344
475
|
}
|
|
345
476
|
define("contour-elevation", ContourElevation);
|
package/dist/wc/ui-data.mjs
CHANGED
|
@@ -1071,8 +1071,59 @@ class ContourDataGrid extends ContourBase {
|
|
|
1071
1071
|
tr.setAttribute("aria-selected", String(keys.has(tr.dataset.rowKey)));
|
|
1072
1072
|
});
|
|
1073
1073
|
}
|
|
1074
|
+
// U-10: focus snapshot/restore. A full re-render (page/filter/rows change)
|
|
1075
|
+
// rebuilds the cells and drops focus to <body>; these capture the focused
|
|
1076
|
+
// cell's column + row key and restore focus to the same cell afterwards.
|
|
1077
|
+
_dgCaptureFocus() {
|
|
1078
|
+
// The base class drops the focused (generated) cell before render() runs,
|
|
1079
|
+
// so document.activeElement is already <body> here. Use the last cell the
|
|
1080
|
+
// user focused, recorded by the delegated focusin listener in enhance().
|
|
1081
|
+
if (this._dgFocus) return this._dgFocus;
|
|
1082
|
+
const el = document.activeElement;
|
|
1083
|
+
if (!el || !this.contains(el)) return null;
|
|
1084
|
+
const cell = el.closest ? el.closest("[role='gridcell'], [role='columnheader']") : null;
|
|
1085
|
+
if (!cell || !this.contains(cell)) return null;
|
|
1086
|
+
const tr = cell.parentElement;
|
|
1087
|
+
if (!tr) return null;
|
|
1088
|
+
return {
|
|
1089
|
+
rowKey: tr.dataset ? tr.dataset.rowKey : undefined,
|
|
1090
|
+
index: tr.dataset ? tr.dataset.index : undefined,
|
|
1091
|
+
col: Array.from(tr.children).indexOf(cell),
|
|
1092
|
+
isHeader: cell.getAttribute("role") === "columnheader",
|
|
1093
|
+
};
|
|
1094
|
+
}
|
|
1095
|
+
_dgRestoreFocus(snap) {
|
|
1096
|
+
if (!snap) return;
|
|
1097
|
+
// Deferred to a microtask so it runs AFTER the base class's generic
|
|
1098
|
+
// (index-based) focus preservation, which would otherwise land focus on
|
|
1099
|
+
// whatever focusable sits at the old index — often a columnheader, not the
|
|
1100
|
+
// same column's cell. The rowKey + column restore is the U-10 contract.
|
|
1101
|
+
queueMicrotask(() => {
|
|
1102
|
+
if (!this.isConnected) return;
|
|
1103
|
+
const active = document.activeElement;
|
|
1104
|
+
// A different control outside the grid now owns focus — do not steal it.
|
|
1105
|
+
if (active && active !== this && active !== document.body && !this.contains(active)) return;
|
|
1106
|
+
const table = this.querySelector(".c-data-grid__table");
|
|
1107
|
+
if (!table) return;
|
|
1108
|
+
let cell = null;
|
|
1109
|
+
if (snap.isHeader) {
|
|
1110
|
+
cell = table.querySelectorAll("thead th")[snap.col] || null;
|
|
1111
|
+
} else {
|
|
1112
|
+
let tr = null;
|
|
1113
|
+
if (snap.rowKey !== undefined) tr = Array.from(table.querySelectorAll("tbody tr[data-row-key]")).find((r) => r.dataset.rowKey === snap.rowKey) || null;
|
|
1114
|
+
if (!tr && snap.index != null) tr = table.querySelector('tr[data-index="' + snap.index + '"]');
|
|
1115
|
+
if (tr && tr.children[snap.col]) cell = tr.children[snap.col];
|
|
1116
|
+
}
|
|
1117
|
+
if (cell) {
|
|
1118
|
+
table.querySelectorAll('[tabindex="0"]').forEach((c) => c.setAttribute("tabindex", "-1"));
|
|
1119
|
+
cell.setAttribute("tabindex", "0");
|
|
1120
|
+
try { cell.focus(); } catch (e) {}
|
|
1121
|
+
}
|
|
1122
|
+
});
|
|
1123
|
+
}
|
|
1074
1124
|
render() {
|
|
1075
1125
|
this.classList.add("c-data-grid");
|
|
1126
|
+
const focusSnap = this._dgCaptureFocus();
|
|
1076
1127
|
if (this.hasAttribute("loading") || this.hasAttribute("error") || this.hasAttribute("empty")) {
|
|
1077
1128
|
const table = this.ensure(".c-data-grid__table", () => { const el = document.createElement("table"); el.className = "c-table c-data-grid__table"; el.setAttribute("role", "grid"); return el; });
|
|
1078
1129
|
const tbody = this.ensure("tbody", () => { const el = document.createElement("tbody"); return el; });
|
|
@@ -1196,6 +1247,8 @@ class ContourDataGrid extends ContourBase {
|
|
|
1196
1247
|
const first = table.querySelector("tbody td, thead th");
|
|
1197
1248
|
if (first) first.setAttribute("tabindex", "0");
|
|
1198
1249
|
}
|
|
1250
|
+
// U-10: restore focus to the same cell after the rebuild.
|
|
1251
|
+
this._dgRestoreFocus(focusSnap);
|
|
1199
1252
|
}
|
|
1200
1253
|
_rowHeight() {
|
|
1201
1254
|
const h = Number(this.getAttribute("row-height"));
|
|
@@ -1275,6 +1328,20 @@ class ContourDataGrid extends ContourBase {
|
|
|
1275
1328
|
enhance() {
|
|
1276
1329
|
if (this._wiredDataGrid) return;
|
|
1277
1330
|
this._wiredDataGrid = true;
|
|
1331
|
+
// U-10: remember the last focused cell so a re-render can restore focus to
|
|
1332
|
+
// the same row/column (the base drops the focused node before render runs).
|
|
1333
|
+
this.addEventListener("focusin", (e) => {
|
|
1334
|
+
const cell = e.target && e.target.closest ? e.target.closest("[role='gridcell'], [role='columnheader']") : null;
|
|
1335
|
+
if (!cell || !this.contains(cell)) return;
|
|
1336
|
+
const tr = cell.parentElement;
|
|
1337
|
+
if (!tr) return;
|
|
1338
|
+
this._dgFocus = {
|
|
1339
|
+
rowKey: tr.dataset ? tr.dataset.rowKey : undefined,
|
|
1340
|
+
index: tr.dataset ? tr.dataset.index : undefined,
|
|
1341
|
+
col: Array.from(tr.children).indexOf(cell),
|
|
1342
|
+
isHeader: cell.getAttribute("role") === "columnheader",
|
|
1343
|
+
};
|
|
1344
|
+
});
|
|
1278
1345
|
const wrap = () => this.querySelector(".c-data-grid__wrap");
|
|
1279
1346
|
const onScroll = () => {
|
|
1280
1347
|
const w = wrap();
|
package/dist/wc/ui-feedback.mjs
CHANGED
|
@@ -4,7 +4,14 @@ import { parseArrayAttr, renderEmpty } from './states.mjs';
|
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
6
|
* Tooltip: a popover-triggered tooltip with anchor association, delay, and
|
|
7
|
-
* viewport flip.
|
|
7
|
+
* viewport flip.
|
|
8
|
+
*
|
|
9
|
+
* Contract (U-17): `text` is the tooltip content; `anchor` (a selector, `#id`
|
|
10
|
+
* or CSS) links a trigger element; `trigger` is the event that opens it
|
|
11
|
+
* (`hover` default, or `focus`/`click`); `delay` is the hover delay in ms.
|
|
12
|
+
* Open state: the host gains `is-open` and the native `:popover-open` while
|
|
13
|
+
* shown; it closes on pointer-leave, blur, or Escape. Focus is never moved into
|
|
14
|
+
* a tooltip (it is non-interactive) and returns to the anchor on close.
|
|
8
15
|
*/
|
|
9
16
|
class ContourTooltip extends ContourBase {
|
|
10
17
|
static get observed() { return ["text", "anchor", "delay", "trigger"]; }
|