contour-ds 1.7.2 → 1.8.1
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 +80 -11
- package/dist/agent-rules.json +16 -0
- package/dist/build-manifest.json +181 -104
- package/dist/contour-wc-content.esm.js +5125 -0
- package/dist/contour-wc-content.esm.min.js +1 -0
- package/dist/contour-wc-dashboard.esm.js +8654 -0
- package/dist/contour-wc-dashboard.esm.min.js +1 -0
- package/dist/contour-wc-data.esm.js +8260 -0
- package/dist/contour-wc-data.esm.min.js +1 -0
- package/dist/contour-wc-docs.esm.js +4305 -0
- package/dist/contour-wc-docs.esm.min.js +1 -0
- package/dist/contour-wc-feedback.esm.js +4917 -0
- package/dist/contour-wc-feedback.esm.min.js +1 -0
- package/dist/contour-wc-forms.esm.js +5688 -0
- package/dist/contour-wc-forms.esm.min.js +1 -0
- package/dist/contour-wc-interaction.esm.js +4580 -0
- package/dist/contour-wc-interaction.esm.min.js +1 -0
- package/dist/contour-wc-layout.esm.js +4174 -0
- package/dist/contour-wc-layout.esm.min.js +1 -0
- package/dist/contour-wc-map.esm.js +5205 -0
- package/dist/contour-wc-map.esm.min.js +1 -0
- package/dist/contour-wc-misc.esm.js +4264 -0
- package/dist/contour-wc-misc.esm.min.js +1 -0
- package/dist/contour-wc-navigation.esm.js +5844 -0
- package/dist/contour-wc-navigation.esm.min.js +1 -0
- package/dist/contour-wc-ui.esm.js +9009 -0
- package/dist/contour-wc-ui.esm.min.js +1 -0
- package/dist/contour-wc.esm.js +6109 -1641
- package/dist/contour-wc.esm.min.js +1 -1
- package/dist/contour-wc.js +6108 -1641
- package/dist/contour-wc.min.js +1 -1
- package/dist/contour.code-snippets +4512 -0
- package/dist/contour.components.json +2597 -799
- package/dist/contour.css +5275 -4050
- package/dist/contour.d.ts +560 -1085
- package/dist/contour.esm.js +7 -0
- package/dist/contour.esm.min.js +1 -1
- package/dist/contour.html-data.json +10311 -0
- package/dist/contour.js +7 -0
- package/dist/contour.min.css +1 -1
- package/dist/contour.min.js +1 -1
- package/dist/contour.react.d.ts +420 -0
- package/dist/contour.single.html +17 -0
- package/dist/contour.single.min.css +1 -0
- package/dist/contour.tokens.json +940 -902
- package/dist/contour.vue.d.ts +418 -0
- package/dist/contour.web-types.json +10703 -0
- package/dist/custom-elements.json +30708 -0
- package/dist/docs/actions.md +3 -2
- package/dist/docs/affordances.md +23 -9
- package/dist/docs/apireference.md +1 -1
- package/dist/docs/colour.md +1 -1
- package/dist/docs/componentindex.md +6 -2
- package/dist/docs/data.md +7 -2
- package/dist/docs/docs.md +9 -2
- 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 +22 -20
- package/dist/docs/install.md +1 -1
- package/dist/docs/landing.md +1 -1
- package/dist/docs/mapengine.md +19 -2
- 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 +2 -2
- package/dist/docs/playground.md +22 -2
- package/dist/docs/principles.md +1 -1
- package/dist/docs/recipes.md +13 -8
- package/dist/docs/space.md +1 -1
- package/dist/docs/status.md +14 -2
- 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 +17 -3
- 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 +45 -57
- package/dist/wc/content.mjs +263 -63
- package/dist/wc/core.mjs +390 -71
- package/dist/wc/dashboard.mjs +220 -13
- package/dist/wc/data.mjs +1075 -460
- package/dist/wc/docs.mjs +105 -12
- package/dist/wc/feedback.mjs +63 -14
- package/dist/wc/forms.mjs +733 -104
- package/dist/wc/index.mjs +9 -2
- package/dist/wc/interaction.mjs +182 -28
- package/dist/wc/layout.mjs +95 -25
- package/dist/wc/map.mjs +185 -118
- package/dist/wc/misc.mjs +124 -24
- package/dist/wc/navigation.mjs +384 -115
- package/dist/wc/shadow.mjs +94 -18
- package/dist/wc/states.mjs +21 -3
- package/dist/wc/svg.mjs +104 -0
- package/dist/wc/ui.mjs +1988 -476
- package/integrations/README.md +2 -0
- package/integrations/ai/CLAUDE.md +3 -3
- package/integrations/frameworks/README.md +235 -0
- package/integrations/native/style-dictionary.config.json +1 -1
- package/integrations/tailwind/contour-theme.css +5 -6
- package/package.json +53 -24
package/dist/wc/misc.mjs
CHANGED
|
@@ -25,7 +25,7 @@ class ContourResizeObserver extends ContourBase {
|
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
define("contour-resize-observer", ContourResizeObserver);
|
|
28
|
-
import { ContourBase, define, onDispose } from './core.mjs';
|
|
28
|
+
import { ContourBase, define, onDispose, navKey , warnBadJson, labelText } from './core.mjs';
|
|
29
29
|
import { loadRemote, remoteData, remoteRefresh, renderStates, renderEmpty, wireStates } from './states.mjs';
|
|
30
30
|
class ContourReservedFull extends ContourBase {
|
|
31
31
|
static get observed() { return ["title"]; }
|
|
@@ -70,8 +70,10 @@ class ContourActivity extends ContourBase {
|
|
|
70
70
|
parsed.forEach((it, i) => {
|
|
71
71
|
const item = document.createElement("div");
|
|
72
72
|
item.className = "c-activity__item";
|
|
73
|
-
item.setAttribute("role", "
|
|
74
|
-
item
|
|
73
|
+
item.setAttribute("role", "button");
|
|
74
|
+
// The first item is the list's tab stop; otherwise the roving
|
|
75
|
+
// keydown handler never receives focus from the keyboard.
|
|
76
|
+
item.setAttribute("tabindex", i === 0 ? "0" : "-1");
|
|
75
77
|
const dot = document.createElement("span");
|
|
76
78
|
dot.className = "c-activity__dot c-activity__dot--" + (it.variant || "primary");
|
|
77
79
|
dot.setAttribute("aria-hidden", "true");
|
|
@@ -79,6 +81,7 @@ class ContourActivity extends ContourBase {
|
|
|
79
81
|
const text = document.createElement("span");
|
|
80
82
|
text.className = "c-activity__text";
|
|
81
83
|
text.textContent = typeof it === "string" ? it : (it.text || it.label || "");
|
|
84
|
+
if (!item.hasAttribute("aria-label")) item.setAttribute("aria-label", text.textContent);
|
|
82
85
|
item.appendChild(text);
|
|
83
86
|
if (it.time) {
|
|
84
87
|
const time = document.createElement("span");
|
|
@@ -88,7 +91,7 @@ class ContourActivity extends ContourBase {
|
|
|
88
91
|
}
|
|
89
92
|
this.appendChild(item);
|
|
90
93
|
});
|
|
91
|
-
} catch (e) {
|
|
94
|
+
} catch (e) { warnBadJson(this, "attribute", e); }
|
|
92
95
|
} else {
|
|
93
96
|
renderEmpty(this, "activity");
|
|
94
97
|
}
|
|
@@ -108,28 +111,112 @@ class ContourActivity extends ContourBase {
|
|
|
108
111
|
this.addEventListener("keydown", (e) => {
|
|
109
112
|
const items = Array.from(this.querySelectorAll(".c-activity__item"));
|
|
110
113
|
if (!items.length) return;
|
|
111
|
-
const
|
|
112
|
-
const idx = items.indexOf(active);
|
|
113
|
-
let next = -1;
|
|
114
|
-
if (e.key === "ArrowDown") next = idx < 0 ? 0 : Math.min(items.length - 1, idx + 1);
|
|
115
|
-
else if (e.key === "ArrowUp") next = idx < 0 ? 0 : Math.max(0, idx - 1);
|
|
116
|
-
else if (e.key === "Home") next = 0;
|
|
117
|
-
else if (e.key === "End") next = items.length - 1;
|
|
118
|
-
if (next >= 0 && next !== idx) {
|
|
119
|
-
e.preventDefault();
|
|
120
|
-
items[next].focus();
|
|
121
|
-
items[next].tabIndex = 0;
|
|
122
|
-
if (idx >= 0) items[idx].tabIndex = -1;
|
|
123
|
-
}
|
|
124
|
-
if ((e.key === "Enter" || e.key === " ") && idx >= 0) {
|
|
125
|
-
e.preventDefault();
|
|
126
|
-
const text = items[idx].querySelector(".c-activity__text")?.textContent || "";
|
|
127
|
-
this.dispatchEvent(new CustomEvent("contour:activity-select", { bubbles: true, composed: true, detail: { index: idx, text } }));
|
|
128
|
-
}
|
|
114
|
+
navKey(e, items, { wrap: false, homeEnd: true, onNavigate: (i) => { items.forEach((it, j) => it.tabIndex = j === i ? 0 : -1); }, onKey: () => { if (e.key === "Enter" || e.key === " ") { const idx = items.indexOf(document.activeElement); this.dispatchEvent(new CustomEvent("contour:activity-select", { bubbles: true, composed: true, detail: { index: idx, text: document.activeElement.querySelector(".c-activity__text")?.textContent || "" } })); } } });
|
|
129
115
|
});
|
|
130
116
|
}
|
|
131
117
|
}
|
|
132
118
|
define("contour-activity", ContourActivity);
|
|
119
|
+
class ContourActivityFeed extends ContourBase {
|
|
120
|
+
static get observed() { return ["items", "filter", "unread-only", "empty", "loading", "error", "labels", "src", "lazy", "refresh", "timeout", "skeleton"]; }
|
|
121
|
+
static get properties() { return { items: { attribute: "items" }, filter: { attribute: "filter" }, "unread-only": { attribute: "unread-only", type: Boolean } }; }
|
|
122
|
+
render() {
|
|
123
|
+
this.classList.add("c-activity-feed");
|
|
124
|
+
if (!this.hasAttribute("role")) this.setAttribute("role", "region");
|
|
125
|
+
if (!this.hasAttribute("aria-label")) this.setAttribute("aria-label", labelText(this, "title", "Activity feed"));
|
|
126
|
+
wireStates(this);
|
|
127
|
+
loadRemote(this, "items");
|
|
128
|
+
if (renderStates(this, "activity-feed")) return;
|
|
129
|
+
const items = remoteData(this, "items");
|
|
130
|
+
const filter = this.getAttribute("filter");
|
|
131
|
+
const unreadOnly = this.hasAttribute("unread-only");
|
|
132
|
+
let header = this.querySelector(".c-activity-feed__header");
|
|
133
|
+
if (!header) { header = document.createElement("div"); header.className = "c-activity-feed__header"; this.insertBefore(header, this.firstChild); }
|
|
134
|
+
let title = header.querySelector(".c-activity-feed__title");
|
|
135
|
+
if (!title) { title = document.createElement("div"); title.className = "c-activity-feed__title"; header.appendChild(title); }
|
|
136
|
+
title.textContent = labelText(this, "title", "Activity feed");
|
|
137
|
+
let toolbar = this.querySelector(".c-activity-feed__toolbar");
|
|
138
|
+
if (!toolbar) { toolbar = document.createElement("div"); toolbar.className = "c-activity-feed__toolbar"; this.appendChild(toolbar); }
|
|
139
|
+
const clear = toolbar.querySelector("[data-activity-clear]") || (() => { const b = document.createElement("button"); b.type = "button"; b.className = "c-btn c-btn--ghost c-btn--sm"; b.setAttribute("data-activity-clear", ""); b.textContent = labelText(this, "clear", "Clear all"); toolbar.appendChild(b); return b; })();
|
|
140
|
+
const unreadBtn = toolbar.querySelector("[data-activity-unread]") || (() => { const b = document.createElement("button"); b.type = "button"; b.className = "c-btn c-btn--ghost c-btn--sm"; b.setAttribute("data-activity-unread", ""); b.textContent = labelText(this, "unread", "Unread only"); toolbar.appendChild(b); return b; })();
|
|
141
|
+
if (unreadOnly) unreadBtn.setAttribute("aria-pressed", "true");
|
|
142
|
+
let list = this.querySelector(".c-activity-feed__list");
|
|
143
|
+
if (!list) { list = document.createElement("ol"); list.className = "c-activity-feed__list"; this.appendChild(list); }
|
|
144
|
+
if (items) {
|
|
145
|
+
try {
|
|
146
|
+
const parsed = JSON.parse(items);
|
|
147
|
+
let filtered = parsed;
|
|
148
|
+
if (filter) filtered = filtered.filter((it) => String(it.severity || it.type || "").toLowerCase() === filter.toLowerCase());
|
|
149
|
+
if (unreadOnly) filtered = filtered.filter((it) => !it.read);
|
|
150
|
+
Array.from(list.querySelectorAll(".c-activity-feed__item")).forEach((n) => n.remove());
|
|
151
|
+
if (filtered.length === 0) {
|
|
152
|
+
let empty = list.querySelector(".c-activity-feed__empty");
|
|
153
|
+
if (!empty) { empty = document.createElement("div"); empty.className = "c-activity-feed__empty"; empty.textContent = labelText(this, "empty", "No activity"); list.appendChild(empty); }
|
|
154
|
+
} else {
|
|
155
|
+
const empty = list.querySelector(".c-activity-feed__empty");
|
|
156
|
+
if (empty) empty.remove();
|
|
157
|
+
filtered.forEach((it, idx) => {
|
|
158
|
+
const item = document.createElement("li");
|
|
159
|
+
item.className = "c-activity-feed__item" + (it.read ? "" : " c-activity-feed__item--unread");
|
|
160
|
+
item.setAttribute("role", "button");
|
|
161
|
+
// The first item is the list's tab stop. With every item at -1 the
|
|
162
|
+
// keydown handler never saw focus inside the list, so arrows and
|
|
163
|
+
// Enter did nothing for a keyboard user.
|
|
164
|
+
item.setAttribute("tabindex", idx === 0 ? "0" : "-1");
|
|
165
|
+
const dot = document.createElement("span");
|
|
166
|
+
dot.className = "c-activity-feed__dot c-activity-feed__dot--" + (it.severity || "info");
|
|
167
|
+
dot.setAttribute("aria-hidden", "true");
|
|
168
|
+
item.appendChild(dot);
|
|
169
|
+
const text = document.createElement("span");
|
|
170
|
+
text.className = "c-activity-feed__text";
|
|
171
|
+
text.textContent = typeof it === "string" ? it : (it.text || it.label || "");
|
|
172
|
+
item.appendChild(text);
|
|
173
|
+
const time = document.createElement("time");
|
|
174
|
+
time.className = "c-activity-feed__time";
|
|
175
|
+
if (it.time) time.setAttribute("datetime", String(it.time));
|
|
176
|
+
time.textContent = it.time || "";
|
|
177
|
+
item.appendChild(time);
|
|
178
|
+
const sev = document.createElement("span");
|
|
179
|
+
sev.className = "c-activity-feed__severity";
|
|
180
|
+
sev.textContent = it.severity || "";
|
|
181
|
+
item.appendChild(sev);
|
|
182
|
+
list.appendChild(item);
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
} catch (e) { warnBadJson(this, "attribute", e); }
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
enhance() {
|
|
189
|
+
if (this._wiredActivityFeed) return;
|
|
190
|
+
this._wiredActivityFeed = true;
|
|
191
|
+
this.addEventListener("click", (e) => {
|
|
192
|
+
const btn = e.target && e.target.closest ? e.target.closest("button") : null;
|
|
193
|
+
if (!btn || !this.contains(btn)) return;
|
|
194
|
+
// Match the control, not its text: a localised `labels` value changes
|
|
195
|
+
// the words, and an equality test on "Clear all" then matched nothing.
|
|
196
|
+
if (btn.hasAttribute("data-activity-clear")) {
|
|
197
|
+
this.dispatchEvent(new CustomEvent("contour:activity-clear", { bubbles: true, composed: true, detail: {} }));
|
|
198
|
+
} else if (btn.hasAttribute("data-activity-unread")) {
|
|
199
|
+
this.toggleAttribute("unread-only");
|
|
200
|
+
this.dispatchEvent(new CustomEvent("contour:activity-filter", { bubbles: true, composed: true, detail: { unread: this.hasAttribute("unread-only") } }));
|
|
201
|
+
} else {
|
|
202
|
+
const item = e.target.closest(".c-activity-feed__item");
|
|
203
|
+
if (item && this.contains(item)) {
|
|
204
|
+
const items = Array.from(this.querySelectorAll(".c-activity-feed__item"));
|
|
205
|
+
const index = items.indexOf(item);
|
|
206
|
+
const text = item.querySelector(".c-activity-feed__text")?.textContent || "";
|
|
207
|
+
item.classList.remove("c-activity-feed__item--unread");
|
|
208
|
+
this.dispatchEvent(new CustomEvent("contour:activity-select", { bubbles: true, composed: true, detail: { index, text } }));
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
this.addEventListener("keydown", (e) => {
|
|
213
|
+
const items = Array.from(this.querySelectorAll(".c-activity-feed__item"));
|
|
214
|
+
if (!items.length) return;
|
|
215
|
+
navKey(e, items, { wrap: false, homeEnd: true, onNavigate: (i) => { items.forEach((it, j) => it.tabIndex = j === i ? 0 : -1); }, onKey: () => { if (e.key === "Enter" || e.key === " ") { const idx = items.indexOf(document.activeElement); this.dispatchEvent(new CustomEvent("contour:activity-select", { bubbles: true, composed: true, detail: { index: idx, text: document.activeElement.querySelector(".c-activity-feed__text")?.textContent || "" } })); } } });
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
define("contour-activity-feed", ContourActivityFeed);
|
|
133
220
|
class ContourAdvanced extends ContourBase {
|
|
134
221
|
static get observed() { return ["title"]; }
|
|
135
222
|
static get properties() { return { title: { attribute: "title" } }; }
|
|
@@ -147,10 +234,16 @@ class ContourAdvanced extends ContourBase {
|
|
|
147
234
|
if (this._wiredAdvanced) return;
|
|
148
235
|
this._wiredAdvanced = true;
|
|
149
236
|
this.addEventListener("click", (e) => {
|
|
237
|
+
// Only the title row toggles. A click anywhere used to fire the event,
|
|
238
|
+
// including on a nested button or input, so using the section toggled it.
|
|
239
|
+
const t = e.target && e.target.closest ? e.target.closest(".c-advanced__title") : null;
|
|
240
|
+
if (!t || !this.contains(t)) return;
|
|
150
241
|
const title = this.getAttribute("title") || "";
|
|
151
242
|
this.dispatchEvent(new CustomEvent("contour:advanced-toggle", { bubbles: true, composed: true, detail: { title } }));
|
|
152
243
|
});
|
|
153
244
|
this.addEventListener("keydown", (e) => {
|
|
245
|
+
// A key pressed inside an authored control belongs to that control.
|
|
246
|
+
if (e.target !== this) return;
|
|
154
247
|
if (e.key === "Enter" || e.key === " ") {
|
|
155
248
|
e.preventDefault();
|
|
156
249
|
const title = this.getAttribute("title") || "";
|
|
@@ -199,6 +292,13 @@ class ContourAffordance extends ContourBase {
|
|
|
199
292
|
const name = this.getAttribute("name") || "";
|
|
200
293
|
this.dispatchEvent(new CustomEvent("contour:affordance-activate", { bubbles: true, composed: true, detail: { name } }));
|
|
201
294
|
});
|
|
295
|
+
this.addEventListener("keydown", (e) => {
|
|
296
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
297
|
+
e.preventDefault();
|
|
298
|
+
const name = this.getAttribute("name") || "";
|
|
299
|
+
this.dispatchEvent(new CustomEvent("contour:affordance-activate", { bubbles: true, composed: true, detail: { name } }));
|
|
300
|
+
}
|
|
301
|
+
});
|
|
202
302
|
}
|
|
203
303
|
}
|
|
204
304
|
define("contour-affordance", ContourAffordance);
|
|
@@ -211,14 +311,14 @@ class ContourAffordances extends ContourBase {
|
|
|
211
311
|
if (!this.querySelector(".c-affordance")) {
|
|
212
312
|
const aff = document.createElement("div");
|
|
213
313
|
aff.className = "c-affordance";
|
|
214
|
-
const name = this.getAttribute("name") || this.getAttribute("title") || "Affordance";
|
|
314
|
+
const name = this.getAttribute("name") || this.getAttribute("title") || labelText(this, "affordance", "Affordance");
|
|
215
315
|
const n = document.createElement("div");
|
|
216
316
|
n.className = "c-affordance__name";
|
|
217
317
|
n.textContent = name;
|
|
218
318
|
aff.appendChild(n);
|
|
219
319
|
const demo = document.createElement("div");
|
|
220
320
|
demo.className = "c-affordance__demo";
|
|
221
|
-
demo.textContent = "Demo";
|
|
321
|
+
demo.textContent = labelText(this, "demo", "Demo");
|
|
222
322
|
aff.appendChild(demo);
|
|
223
323
|
this.appendChild(aff);
|
|
224
324
|
}
|