@nanocollective/roster 0.1.0-beta.21 → 0.1.0-beta.22

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.
Files changed (58) hide show
  1. package/dist/worker/assets/assets/css/astryx.css +948 -0
  2. package/dist/worker/assets/assets/css/base.css +47 -112
  3. package/dist/worker/assets/assets/css/brain.css +15 -11
  4. package/dist/worker/assets/assets/css/graph.css +9 -12
  5. package/dist/worker/assets/assets/css/health.css +4 -7
  6. package/dist/worker/assets/assets/css/home.css +27 -29
  7. package/dist/worker/assets/assets/css/layout.css +10 -20
  8. package/dist/worker/assets/assets/css/markdown.css +1 -1
  9. package/dist/worker/assets/assets/css/runs.css +5 -3
  10. package/dist/worker/assets/assets/css/search.css +3 -6
  11. package/dist/worker/assets/assets/css/setup.css +3 -15
  12. package/dist/worker/assets/assets/js/app.js +2 -0
  13. package/dist/worker/assets/assets/js/astryx-ui.js +34 -0
  14. package/dist/worker/assets/assets/js/icons.js +2 -0
  15. package/dist/worker/assets/assets/js/select.js +362 -0
  16. package/dist/worker/assets/assets/js/views/graph.js +67 -28
  17. package/dist/worker/assets/assets/js/views/home.js +98 -112
  18. package/dist/worker/assets/assets/js/views/people.js +8 -2
  19. package/dist/worker/assets/assets/js/views/runs.js +3 -1
  20. package/dist/worker/assets/docs-images/brain.jpg +0 -0
  21. package/dist/worker/assets/docs-images/home.jpg +0 -0
  22. package/dist/worker/assets/docs-images/org.jpg +0 -0
  23. package/dist/worker/assets/docs-images/prompt.jpg +0 -0
  24. package/dist/worker/assets/docs-images/setup-org.jpg +0 -0
  25. package/dist/worker/assets/docs-images/setup-plan.jpg +0 -0
  26. package/dist/worker/assets/docs-images/staff.jpg +0 -0
  27. package/dist/worker/assets/index.html +8 -1
  28. package/dist/worker/index.js +1 -1
  29. package/docs/getting-started.md +1 -1
  30. package/docs/images/brain.jpg +0 -0
  31. package/docs/images/home.jpg +0 -0
  32. package/docs/images/org.jpg +0 -0
  33. package/docs/images/prompt.jpg +0 -0
  34. package/docs/images/setup-org.jpg +0 -0
  35. package/docs/images/setup-plan.jpg +0 -0
  36. package/docs/images/staff.jpg +0 -0
  37. package/docs/portal.md +12 -10
  38. package/package.json +7 -1
  39. package/templates/portal/css/astryx.css +948 -0
  40. package/templates/portal/css/base.css +47 -112
  41. package/templates/portal/css/brain.css +15 -11
  42. package/templates/portal/css/graph.css +9 -12
  43. package/templates/portal/css/health.css +4 -7
  44. package/templates/portal/css/home.css +27 -29
  45. package/templates/portal/css/layout.css +10 -20
  46. package/templates/portal/css/markdown.css +1 -1
  47. package/templates/portal/css/runs.css +5 -3
  48. package/templates/portal/css/search.css +3 -6
  49. package/templates/portal/css/setup.css +3 -15
  50. package/templates/portal/index.html +8 -1
  51. package/templates/portal/js/app.js +2 -0
  52. package/templates/portal/js/astryx-ui.js +34 -0
  53. package/templates/portal/js/icons.js +2 -0
  54. package/templates/portal/js/select.js +362 -0
  55. package/templates/portal/js/views/graph.js +67 -28
  56. package/templates/portal/js/views/home.js +98 -112
  57. package/templates/portal/js/views/people.js +8 -2
  58. package/templates/portal/js/views/runs.js +3 -1
@@ -0,0 +1,34 @@
1
+ /*
2
+ * Generated by scripts/astryx.mjs from @astryxdesign/core 0.7.11. Do not edit.
3
+ *
4
+ * Astryx's own class strings for the controls the portal builds in its own markup, element by
5
+ * element, as the React components put them. css/astryx.css carries their rules unchanged.
6
+ * Astryx: Copyright (c) Meta Platforms, Inc. and affiliates. MIT licence.
7
+ */
8
+
9
+ /** Selector: the trigger, the layer it opens, and a row in its list, with the row's states. */
10
+ export const SELECTOR = {
11
+ "frame": "x9f619 x1vjfegm x1litavf x1y0btm7 xvy26l8 x6q1khz xohk9ji x1832zxr xvdfih8 x10xzikg x12zzom9 xuedmi6 x12w9bfk xlr8y92 x1gnnqk1 x1xqjsvb xuihb5h x1a2a7pz x1n2onr6 x78zum5 x6s0dn4 x1qughib x1txdalj xh8yej3 xrrkdod x9ynric xcr08ib x1w61h2b x1tgivj0 x1ypdohk x16khyan x1uogy3y xe5am2i xj646f7",
12
+ "button": "x78zum5 x6s0dn4 x1qughib x1txdalj x1iyjqo2 xs83m0k x1r8uery xeuugli x1717udv x1ghz6dp xc342km xng3xce xjbqb8w xjb2p0i x1qlqyl8 x15bjb6t x1heor9g x1ypdohk x16khyan x1a2a7pz",
13
+ "buttonOpen": "x78zum5 x6s0dn4 x1qughib x1txdalj x1iyjqo2 xs83m0k x1r8uery xeuugli x1717udv x1ghz6dp xc342km xng3xce xjbqb8w xjb2p0i x1qlqyl8 x15bjb6t x1heor9g x1ypdohk x16khyan x1a2a7pz",
14
+ "value": "x1iyjqo2 xeuugli xb3r6kr xlyipyv xuxw1ft x1yc453h",
15
+ "chevron": "x3nfvp2 x6s0dn4 xl56j7k xv9yike xomy6nw x14eyxzr x1qzu985 x2lah0s x11xpdln xuedmi6 xlr8y92 x1g0ag68",
16
+ "chevronOpen": "x3nfvp2 x6s0dn4 xl56j7k xv9yike xomy6nw x14eyxzr x1qzu985 x2lah0s x11xpdln xuedmi6 xlr8y92 x1g0ag68 x19jd1h0",
17
+ "layer": "x9ynric xjm74w1 xxovm9e xw6l6zx x1j61x8r x1yc453h x7ssn7h xzugeeo x6mezaz x1i21sxh xp3md9m x19pm5ym xeaf4i8 x1lldw8n x1h4wwuj xxydokm x1qkaldv x1c9qq8g xdj266r x1lziwak xexx8yu x18d9i69 x1c1uobl xyri2b xc342km xng3xce x1rea2x4 xjbqb8w xrhngw9 xjsfl84 x1047aw6 xax9j7h xdt8ak2 x1rs4lu4 x1vii845 xojybgt x1qfll2g xyvxpqs x1f17rg1 x1ex41ac xypflj0 xihxjaz x9f619 xc0b1yq x3v4n1 x144kxal x119uzjn xrzjruh xl1vlw0 x2g3n7u xaqowwx x9uej1z x10got5w x128ha8g xskzprw",
18
+ "layerInner": "x1k57tk5 x1vidyx5 x1t137rt x1jhp3zv xx47ajj x1wfwxd8 x1vwwbsn x1n2onr6 x1prclbq xiki222 x11m9jtl x1i5ehqx",
19
+ "listbox": "x9f619 x2lwn1j x1uh1i8a x1odjw0f x1a2a7pz xu0wf1k x1hc1fzr x19991ni xuedmi6 x7jh41u xuh6ohu xwji4o3 x15tucas x1j4r261 x2hg6jq",
20
+ "option": "x9f619 x78zum5 x6s0dn4 x1qughib x1txdalj xh8yej3 xlsj2fj xh6dtrn x9ynric xcr08ib x1tgivj0 xjbqb8w xc342km xng3xce x1ypdohk x16khyan x1yc453h x1t137rt x1vofgu7",
21
+ "optionMain": "x78zum5 x6s0dn4 x1txdalj x98rzlu xeuugli",
22
+ "optionRow": "x1k57tk5 x11j6mr8 x1t137rt xciu248 x1uy843r x1wfwxd8 x1jumodi x78zum5 x6s0dn4 x1txdalj xw1s368 x1n2onr6 x9f619 x1yc453h xt970qd xnjsko4 x2u8bby xeuugli",
23
+ "optionLabelOuter": "x78zum5 xdt5ytf x98rzlu xeuugli x1yc453h",
24
+ "optionLabel": "x5tbw38 xjm74w1 xw6l6zx xb3r6kr xlyipyv xuxw1ft",
25
+ "optionEnd": "x3nfvp2 x6s0dn4 xl56j7k x2lah0s xgomdpo xjl7jj",
26
+ "check": "x3nfvp2 x6s0dn4 xl56j7k x2lah0s xqwr325 xomy6nw x14eyxzr x1qzu985",
27
+ "selected": "x1e4wzip",
28
+ "highlighted": "x1lmrjuc",
29
+ "keyboard": "xak0ai5 x9ssot5 x19bwoy8 x1c097ug",
30
+ "disabled": "xbyyjgo xt0e3qv"
31
+ };
32
+
33
+ /** The layer's inline style: `{anchor}` is the trigger's anchor name. */
34
+ export const LAYER_STYLE = "--x---_layer-keyboard-max-block-size: 100vh; --x---_layer-keyboard-overflow: visible; --x---_layer-keyboard-inset-block-end: initial; position-anchor: {anchor}; position-area: self-block-end span-self-inline-end; position-try-fallbacks: flip-block, flip-inline, flip-block flip-inline, --astryx-layer-slide-below-start-same, --astryx-layer-slide-below-start-opposite;";
@@ -45,6 +45,8 @@ const PATHS = {
45
45
  "<path d=\"m6 9 6 6 6-6\" />",
46
46
  "close":
47
47
  "<path d=\"M18 6 6 18\" /> <path d=\"m6 6 12 12\" />",
48
+ "trash":
49
+ "<path d=\"M3 6h18\" /> <path d=\"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6\" /> <path d=\"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2\" /> <line x1=\"10\" x2=\"10\" y1=\"11\" y2=\"17\" /> <line x1=\"14\" x2=\"14\" y1=\"11\" y2=\"17\" />",
48
50
  "closed":
49
51
  "<circle cx=\"12\" cy=\"12\" r=\"10\" /> <path d=\"m15 9-6 6\" /> <path d=\"m9 9 6 6\" />",
50
52
  "commit":
@@ -0,0 +1,362 @@
1
+ /* Dropdowns: Astryx's Selector, drawn over the native <select> it stands in for.
2
+ *
3
+ * Every view builds a plain <select>, reads `.value` and listens for `change`, and none of that
4
+ * changes. When one lands in the page, this puts Astryx's trigger beside it and hides it; the
5
+ * <select> stays the one place the value lives. A pick sets it and fires `change` on it, and a
6
+ * value set on it from code (or options added to it) repaints the trigger. The markup is
7
+ * Selector's own, element by element, with the class strings in astryx-ui.js; css/astryx.css has
8
+ * their rules unchanged, so this decides only what the control does, never what it looks like.
9
+ *
10
+ * What it does is the select-only combobox from the WAI-ARIA practices, which is what Selector
11
+ * is: focus stays on the trigger and `aria-activedescendant` names the highlighted row. Closed,
12
+ * the arrow keys, Enter and Space open it and typing picks by first letters, as a native one
13
+ * does. Open, the arrows, Home and End move, Enter, Space and Tab pick, and Escape closes it
14
+ * without closing the dialog it may sit in. The list is a popover, so the page's own top layer
15
+ * and light dismiss do the rest, placed by CSS anchor positioning as Astryx places it.
16
+ */
17
+
18
+ import { LAYER_STYLE, SELECTOR as C } from "./astryx-ui.js";
19
+
20
+ const CHEVRON = '<path d="M6 9l6 6 6-6"></path>';
21
+ const CHECK = '<path d="M5 13l4 4L19 7"></path>';
22
+ const svg = (body) =>
23
+ '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" ' +
24
+ 'stroke-width="1.5" stroke-linecap="round" stroke-linejoin="round" width="1em" height="1em" ' +
25
+ `aria-hidden="true">${body}</svg>`;
26
+
27
+ const node = (tag, className, attrs = {}) => {
28
+ const n = document.createElement(tag);
29
+ if (className) n.className = className;
30
+ for (const [k, v] of Object.entries(attrs)) n.setAttribute(k, v);
31
+ return n;
32
+ };
33
+
34
+ let ids = 0;
35
+
36
+ /** Puts the Astryx control beside one <select>. Calling it twice on the same one does nothing. */
37
+ export function enhanceSelect(select) {
38
+ if (select.dataset.astryx || select.multiple || !select.isConnected) return;
39
+ select.dataset.astryx = "1";
40
+ // Read here rather than at load: the tests' DOM shim has no HTMLSelectElement.
41
+ const PROTO = Object.getOwnPropertyDescriptor(HTMLSelectElement.prototype, "value");
42
+ const INDEX = Object.getOwnPropertyDescriptor(HTMLSelectElement.prototype, "selectedIndex");
43
+ const ANCHORED = globalThis.CSS?.supports?.("position-area: block-end") ?? false;
44
+ const id = `axsel-${++ids}`;
45
+ const anchor = `--${id}`;
46
+
47
+ const host = node("span", "axselect");
48
+ const frame = node("div", C.frame, { "data-variant": "input", "data-size": "md" });
49
+ frame.style.setProperty("anchor-name", anchor);
50
+ const button = node("button", C.button, {
51
+ type: "button",
52
+ role: "combobox",
53
+ "aria-haspopup": "listbox",
54
+ "aria-expanded": "false",
55
+ "aria-controls": `${id}-list`,
56
+ });
57
+ const value = node("span", C.value);
58
+ button.append(value);
59
+ const chevron = node("span", C.chevron, {
60
+ "aria-hidden": "true",
61
+ "data-state": "collapsed",
62
+ "data-size": "sm",
63
+ "data-color": "secondary",
64
+ });
65
+ chevron.innerHTML = svg(CHEVRON);
66
+ frame.append(button, chevron);
67
+
68
+ const layer = node("div", C.layer, { popover: "auto", "data-layer-anchored": "" });
69
+ layer.setAttribute("style", LAYER_STYLE.replaceAll("{anchor}", anchor));
70
+ const inner = node("div", C.layerInner);
71
+ const list = node("div", C.listbox, { id: `${id}-list`, role: "listbox" });
72
+ inner.append(list);
73
+ // A press on a row must not take focus from the trigger, which is where the keys go.
74
+ list.addEventListener("pointerdown", (e) => e.preventDefault());
75
+ layer.append(inner);
76
+ host.append(frame, layer);
77
+
78
+ // Whatever names the <select> names the control: its label, its title, its aria-label.
79
+ for (const a of ["title", "aria-label"]) {
80
+ if (select.hasAttribute(a)) button.setAttribute(a, select.getAttribute(a));
81
+ }
82
+ if (select.id) {
83
+ const label = document.querySelector(`label[for="${CSS.escape(select.id)}"]`);
84
+ if (label) {
85
+ label.id ||= `${id}-label`;
86
+ button.setAttribute("aria-labelledby", label.id);
87
+ label.addEventListener("click", (e) => {
88
+ e.preventDefault();
89
+ button.focus();
90
+ });
91
+ }
92
+ }
93
+ list.setAttribute("aria-label", button.getAttribute("aria-label") ?? select.title ?? "");
94
+
95
+ select.classList.add("axnative");
96
+ select.after(host);
97
+
98
+ let rows = [];
99
+ let active = -1;
100
+ let keyboard = false;
101
+
102
+ const options = () => [...select.options];
103
+ const enabled = (i) => i >= 0 && i < rows.length && !select.options[i].disabled;
104
+
105
+ function paintValue() {
106
+ const o = select.options[select.selectedIndex];
107
+ value.textContent = o ? o.textContent : "";
108
+ host.hidden = select.hidden;
109
+ button.disabled = select.disabled;
110
+ }
111
+
112
+ function paintRows() {
113
+ const chosen = select.selectedIndex;
114
+ rows = options().map((o, i) => {
115
+ const row = node("div", C.option, {
116
+ id: `${id}-item-${i}`,
117
+ role: "option",
118
+ "aria-selected": String(i === chosen),
119
+ "data-size": "md",
120
+ });
121
+ if (o.disabled) row.setAttribute("aria-disabled", "true");
122
+ const main = node("span", C.optionMain);
123
+ const line = node("div", C.optionRow, { "data-density": "balanced", "data-align": "center" });
124
+ const outer = node("span", C.optionLabelOuter);
125
+ const label = node("span", C.optionLabel);
126
+ label.textContent = o.textContent;
127
+ outer.append(label);
128
+ line.append(outer);
129
+ main.append(line);
130
+ const end = node("span", C.optionEnd);
131
+ if (i === chosen) {
132
+ row.setAttribute("data-selected", "selected");
133
+ const check = node("span", C.check, {
134
+ "aria-hidden": "true",
135
+ "data-size": "sm",
136
+ "data-color": "accent",
137
+ });
138
+ check.innerHTML = svg(CHECK);
139
+ end.append(check);
140
+ }
141
+ row.append(main, end);
142
+ row.addEventListener("pointermove", () => {
143
+ if (active !== i || keyboard) highlight(i, false);
144
+ });
145
+ row.addEventListener("click", () => {
146
+ if (enabled(i)) pick(i);
147
+ });
148
+ return row;
149
+ });
150
+ list.replaceChildren(...rows);
151
+ }
152
+
153
+ /** The classes a row wears: Selector's, plus each state it is in, as React composes them. */
154
+ function paintRow(i) {
155
+ const row = rows[i];
156
+ if (!row) return;
157
+ const o = select.options[i];
158
+ row.className = [
159
+ C.option,
160
+ i === active && C.highlighted,
161
+ i === active && keyboard && C.keyboard,
162
+ i === select.selectedIndex && C.selected,
163
+ o?.disabled && C.disabled,
164
+ ]
165
+ .filter(Boolean)
166
+ .join(" ");
167
+ }
168
+
169
+ function highlight(i, byKeyboard) {
170
+ const was = active;
171
+ active = i;
172
+ keyboard = byKeyboard;
173
+ paintRow(was);
174
+ paintRow(i);
175
+ if (i >= 0) {
176
+ button.setAttribute("aria-activedescendant", rows[i].id);
177
+ if (byKeyboard) rows[i].scrollIntoView({ block: "nearest" });
178
+ } else button.removeAttribute("aria-activedescendant");
179
+ }
180
+
181
+ const isOpen = () => layer.matches(":popover-open");
182
+
183
+ function open(byKeyboard) {
184
+ if (isOpen() || button.disabled) return;
185
+ paintRows();
186
+ rows.forEach((_, i) => paintRow(i));
187
+ layer.style.minInlineSize = `${frame.offsetWidth}px`;
188
+ layer.showPopover();
189
+ if (!ANCHORED) place();
190
+ const start = enabled(select.selectedIndex) ? select.selectedIndex : step(-1, 1);
191
+ highlight(start, byKeyboard);
192
+ }
193
+
194
+ function close() {
195
+ if (isOpen()) layer.hidePopover();
196
+ }
197
+
198
+ /** Where anchor positioning is missing: under the trigger, or over it when there is no room. */
199
+ function place() {
200
+ const r = frame.getBoundingClientRect();
201
+ const h = layer.offsetHeight;
202
+ const below = r.bottom + h + 8 <= innerHeight || r.top < h + 8;
203
+ layer.style.position = "fixed";
204
+ layer.style.margin = "0";
205
+ layer.style.left = `${Math.max(8, Math.min(r.left, innerWidth - layer.offsetWidth - 8))}px`;
206
+ layer.style.top = below ? `${r.bottom + 4}px` : `${r.top - h - 4}px`;
207
+ }
208
+
209
+ function pick(i) {
210
+ const changed = select.selectedIndex !== i;
211
+ INDEX.set.call(select, i);
212
+ paintValue();
213
+ close();
214
+ button.focus();
215
+ if (changed) {
216
+ select.dispatchEvent(new Event("input", { bubbles: true }));
217
+ select.dispatchEvent(new Event("change", { bubbles: true }));
218
+ }
219
+ }
220
+
221
+ /** The next enabled row from `from` in direction `dir`, or `from` itself at either end. */
222
+ function step(from, dir) {
223
+ for (let i = from + dir; i >= 0 && i < select.options.length; i += dir) {
224
+ if (!select.options[i].disabled) return i;
225
+ }
226
+ return from;
227
+ }
228
+
229
+ /* Typing picks by first letters: closed it changes the value, as a native one does; open
230
+ it moves the highlight. A pause of a second starts a new word. */
231
+ let typed = "";
232
+ let typedAt = 0;
233
+ function typeahead(ch) {
234
+ const now = Date.now();
235
+ typed = now - typedAt > 1000 ? ch : typed + ch;
236
+ typedAt = now;
237
+ const from = isOpen() ? active : select.selectedIndex;
238
+ const all = options();
239
+ const order = all.map((_, k) => (from + 1 + k) % all.length);
240
+ // The same letter pressed again cycles through the options that start with it.
241
+ const want = typed.split("").every((c) => c === typed[0]) ? typed[0] : typed;
242
+ const hit = order.find(
243
+ (i) => !all[i].disabled && all[i].textContent.trim().toLowerCase().startsWith(want),
244
+ );
245
+ if (hit === undefined) return;
246
+ if (isOpen()) highlight(hit, true);
247
+ else pick(hit);
248
+ }
249
+
250
+ button.addEventListener("click", () => (isOpen() ? close() : open(false)));
251
+ // Light dismiss closes the popover on the pointerdown before this click, which would reopen
252
+ // it at once. A press that starts on the trigger of an open list is a close, nothing more.
253
+ button.addEventListener("pointerdown", (e) => {
254
+ if (isOpen()) {
255
+ e.preventDefault();
256
+ close();
257
+ button.addEventListener("click", (c) => c.stopImmediatePropagation(), {
258
+ once: true,
259
+ capture: true,
260
+ });
261
+ }
262
+ });
263
+
264
+ button.addEventListener("keydown", (e) => {
265
+ const k = e.key;
266
+ if (!isOpen()) {
267
+ if (k === "ArrowDown" || k === "ArrowUp" || k === "Enter" || k === " ") {
268
+ e.preventDefault();
269
+ open(true);
270
+ if (k === "ArrowUp") highlight(step(select.options.length, -1), true);
271
+ } else if (k.length === 1 && !e.metaKey && !e.ctrlKey && !e.altKey) {
272
+ typeahead(k.toLowerCase());
273
+ }
274
+ return;
275
+ }
276
+ if (k === "Escape") {
277
+ // A dialog round this would close on the same key; this Escape is the list's.
278
+ e.preventDefault();
279
+ e.stopPropagation();
280
+ close();
281
+ } else if (k === "ArrowDown" || k === "ArrowUp") {
282
+ e.preventDefault();
283
+ if (e.altKey && k === "ArrowUp") {
284
+ if (enabled(active)) pick(active);
285
+ return;
286
+ }
287
+ highlight(step(active, k === "ArrowDown" ? 1 : -1), true);
288
+ } else if (k === "Home" || k === "End") {
289
+ e.preventDefault();
290
+ highlight(k === "Home" ? step(-1, 1) : step(select.options.length, -1), true);
291
+ } else if (k === "Enter" || k === " ") {
292
+ e.preventDefault();
293
+ if (enabled(active)) pick(active);
294
+ } else if (k === "Tab") {
295
+ if (enabled(active)) pick(active);
296
+ } else if (k.length === 1 && !e.metaKey && !e.ctrlKey && !e.altKey) {
297
+ e.preventDefault();
298
+ typeahead(k.toLowerCase());
299
+ }
300
+ });
301
+
302
+ layer.addEventListener("toggle", (e) => {
303
+ const shown = e.newState === "open";
304
+ button.setAttribute("aria-expanded", String(shown));
305
+ button.className = shown ? C.buttonOpen : C.button;
306
+ chevron.className = shown ? C.chevronOpen : C.chevron;
307
+ chevron.setAttribute("data-state", shown ? "expanded" : "collapsed");
308
+ if (!shown) highlight(-1, false);
309
+ });
310
+
311
+ /* Code that sets the value, swaps the options, hides or disables the <select> after this has
312
+ run is still the source of truth: each of those repaints the trigger. */
313
+ Object.defineProperty(select, "value", {
314
+ configurable: true,
315
+ get: () => PROTO.get.call(select),
316
+ set: (v) => {
317
+ PROTO.set.call(select, v);
318
+ paintValue();
319
+ },
320
+ });
321
+ Object.defineProperty(select, "selectedIndex", {
322
+ configurable: true,
323
+ get: () => INDEX.get.call(select),
324
+ set: (v) => {
325
+ INDEX.set.call(select, v);
326
+ paintValue();
327
+ },
328
+ });
329
+ new MutationObserver(() => {
330
+ paintValue();
331
+ if (isOpen()) paintRows();
332
+ }).observe(select, {
333
+ childList: true,
334
+ subtree: true,
335
+ characterData: true,
336
+ attributes: true,
337
+ attributeFilter: ["hidden", "disabled", "selected"],
338
+ });
339
+ select.addEventListener("change", paintValue);
340
+
341
+ paintValue();
342
+ }
343
+
344
+ /**
345
+ * Every <select> the page gains from here on gets the control, so no view has to remember to
346
+ * ask for it. Views build theirs detached and append them whole, so it is the arrival that is
347
+ * watched, and the work waits for the end of the task: by then the view has set the value.
348
+ */
349
+ export function installSelects(root = document.body) {
350
+ // The tests' DOM shim has no observers, and with nothing to watch there is nothing to do.
351
+ if (typeof MutationObserver !== "function") return;
352
+ const sweep = (n) => {
353
+ if (n.nodeType !== 1) return;
354
+ if (n.tagName === "SELECT") enhanceSelect(n);
355
+ else for (const s of n.querySelectorAll("select")) enhanceSelect(s);
356
+ };
357
+ new MutationObserver((records) => {
358
+ const added = records.flatMap((r) => [...r.addedNodes]);
359
+ if (added.length) queueMicrotask(() => added.forEach(sweep));
360
+ }).observe(root, { childList: true, subtree: true });
361
+ sweep(root);
362
+ }
@@ -53,8 +53,13 @@ function drawGraph(canvas, wrap, s) {
53
53
  }
54
54
  const groups = [...members.keys()].sort((a, b) => members.get(b).length - members.get(a).length);
55
55
 
56
- const PALETTE = ["#30d158","#0a84ff","#bf5af2","#ff9f0a","#64d2ff","#ff453a","#ffcc00","#ff375f","#5e5ce6","#ac8e68"];
57
- const colour = new Map(groups.map((g, i) => [g, PALETTE[i % PALETTE.length]]));
56
+ // Astryx's categorical colours, one per group. They are theme tokens, so a group keeps its
57
+ // hue in both themes at the strength each theme wants.
58
+ const PALETTE = ["blue", "green", "purple", "orange", "cyan", "red", "yellow", "pink", "teal", "gray"]
59
+ .map((c) => `--color-icon-${c}`);
60
+ const token = new Map(groups.map((g, i) => [g, PALETTE[i % PALETTE.length]]));
61
+ // For markup, which can take the token as it is.
62
+ const colour = new Map(groups.map((g) => [g, `var(${token.get(g)})`]));
58
63
 
59
64
  // The ring grows with the number of groups so they never crowd, and each group keeps its
60
65
  // angle for the life of the view. That angle is also the direction its members fan out in.
@@ -69,6 +74,9 @@ function drawGraph(canvas, wrap, s) {
69
74
  }));
70
75
 
71
76
  const radius = (n) => n.isGroup ? 16 + Math.sqrt(n.count) * 3.6 : 5.5;
77
+ /* What is drawn and clicked: never smaller on screen than a dot you can read a count in or
78
+ hit with a pointer, however far out the picture is fitted. The layout keeps `radius`. */
79
+ const seen = (n) => Math.max(radius(n), (n.isGroup ? 11 + Math.sqrt(n.count) * 1.4 : 4) / scale);
72
80
 
73
81
  /* Fan a group's members outward along its own angle, in shells, so a big group becomes a
74
82
  wedge pointing away from the middle rather than a ball sitting on its neighbours. */
@@ -148,7 +156,37 @@ function drawGraph(canvas, wrap, s) {
148
156
  recompute();
149
157
  }
150
158
 
151
- const css = (v) => getComputedStyle(document.documentElement).getPropertyValue(v).trim();
159
+ /* A canvas takes colours, not tokens, and the theme's tokens are light-dark() pairs that it
160
+ cannot parse: handed one, it keeps whatever colour it had before, which painted every label
161
+ in the last group's colour. So each token is resolved by an element that wears it, and the
162
+ answers are kept until the theme changes. */
163
+ const probe = el("span", { hidden: true });
164
+ wrap.append(probe);
165
+ const resolved = new Map();
166
+ const css = (v) => {
167
+ if (!resolved.has(v)) {
168
+ probe.style.color = `var(${v})`;
169
+ resolved.set(v, getComputedStyle(probe).color);
170
+ }
171
+ return resolved.get(v);
172
+ };
173
+ const hue = (g) => css(token.get(g) ?? "--ink-faint");
174
+ const forget = () => resolved.clear();
175
+ globalThis.MutationObserver &&
176
+ new MutationObserver(forget).observe(document.documentElement, { attributes: true, attributeFilter: ["data-theme"] });
177
+ globalThis.matchMedia?.("(prefers-color-scheme: dark)").addEventListener?.("change", forget);
178
+ const SANS = getComputedStyle(probe).fontFamily || "system-ui, sans-serif";
179
+
180
+ /** Text over the picture: a halo in the card's colour first, so no edge runs through it. */
181
+ function label(text, x, y, ink, weight, px) {
182
+ ctx.font = `${weight} ${px / scale}px ${SANS}`;
183
+ ctx.lineJoin = "round";
184
+ ctx.lineWidth = 4 / scale;
185
+ ctx.strokeStyle = css("--panel");
186
+ ctx.strokeText(text, x, y);
187
+ ctx.fillStyle = css(ink);
188
+ ctx.fillText(text, x, y);
189
+ }
152
190
  let tx = 0, ty = 0, scale = 0.8;
153
191
  let selected = null, hover = null, drag = null, panning = false, lx = 0, ly = 0, moved = 0;
154
192
  const ctx = canvas.getContext("2d");
@@ -166,9 +204,9 @@ function drawGraph(canvas, wrap, s) {
166
204
  };
167
205
  wrap.append(el("div", { className: "gtools" }, [
168
206
  search,
169
- el("button", { textContent: "open all", onclick: () => { for (const g of groups) if (!expanded.has(g)) toggle(g); } }),
170
- el("button", { textContent: "close all", onclick: () => { for (const g of [...expanded]) toggle(g); } }),
171
- el("button", { textContent: "fit", onclick: fit }),
207
+ el("button", { className: "ghbtn sm", textContent: "Open all", onclick: () => { for (const g of groups) if (!expanded.has(g)) toggle(g); } }),
208
+ el("button", { className: "ghbtn sm", textContent: "Close all", onclick: () => { for (const g of [...expanded]) toggle(g); } }),
209
+ el("button", { className: "ghbtn sm", textContent: "Fit", onclick: fit }),
172
210
  ]));
173
211
 
174
212
  const legend = el("div", { className: "legend" });
@@ -242,7 +280,8 @@ function drawGraph(canvas, wrap, s) {
242
280
  const xs = vis.map((n) => n.x), ys = vis.map((n) => n.y);
243
281
  const minx = Math.min(...xs), miny = Math.min(...ys);
244
282
  const w = Math.max(...xs) - minx || 1, h = Math.max(...ys) - miny || 1;
245
- scale = Math.min(1.6, Math.max(0.12, Math.min(rect.width / (w + 260), rect.height / (h + 260))));
283
+ // Room round the edge for the dots and the labels under them, which keep their size on screen.
284
+ scale = Math.min(1.6, Math.max(0.12, Math.min((rect.width - 200) / w, (rect.height - 110) / h)));
246
285
  tx = -(minx + w / 2) * scale;
247
286
  ty = -(miny + h / 2) * scale;
248
287
  }
@@ -311,7 +350,7 @@ function drawGraph(canvas, wrap, s) {
311
350
  for (const g of groups) {
312
351
  if (!expanded.has(g) || hidden.has(g)) continue;
313
352
  const gn = groupNodes.get(g);
314
- ctx.strokeStyle = colour.get(g); ctx.globalAlpha = 0.14;
353
+ ctx.strokeStyle = hue(g); ctx.globalAlpha = 0.18;
315
354
  ctx.lineWidth = 1 / scale;
316
355
  for (const id of members.get(g)) {
317
356
  const mn = memberNodes.get(id);
@@ -322,16 +361,18 @@ function drawGraph(canvas, wrap, s) {
322
361
 
323
362
  for (const e of edges) {
324
363
  const lit = !near || (near.has(e.a) && near.has(e.b));
325
- ctx.strokeStyle = near && lit ? css("--accent") : css("--line");
326
- ctx.globalAlpha = near ? (lit ? 0.95 : 0.07) : 0.62;
327
- ctx.lineWidth = Math.min(6, 0.8 + Math.log2(e.weight + 1) * 1.25) / Math.max(1, scale * 0.8);
364
+ // Hairlines, the same width on screen at any zoom; a link made many times is a little
365
+ // heavier, never a bar.
366
+ ctx.strokeStyle = near && lit ? css("--accent") : css("--border-strong");
367
+ ctx.globalAlpha = near ? (lit ? 0.9 : 0.08) : 0.9;
368
+ ctx.lineWidth = (1 + Math.min(1.5, Math.log2(e.weight) * 0.5)) / scale;
328
369
  ctx.beginPath(); ctx.moveTo(e.a.x, e.a.y); ctx.lineTo(e.b.x, e.b.y); ctx.stroke();
329
370
  }
330
371
  ctx.globalAlpha = 1;
331
372
 
332
373
  const painted = shown().sort((a, b) => (b.isGroup ? b.count : 0) - (a.isGroup ? a.count : 0));
333
374
  for (const n of painted) {
334
- const r = radius(n);
375
+ const r = seen(n);
335
376
  const dim = near && !near.has(n);
336
377
  ctx.globalAlpha = dim ? 0.13 : 1;
337
378
 
@@ -341,37 +382,35 @@ function drawGraph(canvas, wrap, s) {
341
382
  if (open) {
342
383
  // Hollow while open: the group is still here, and still the thing you click to fold.
343
384
  ctx.fillStyle = css("--panel"); ctx.fill();
344
- ctx.strokeStyle = colour.get(n.group); ctx.lineWidth = 2.4 / scale; ctx.stroke();
345
- ctx.fillStyle = colour.get(n.group);
385
+ ctx.strokeStyle = hue(n.group); ctx.lineWidth = 2 / scale; ctx.stroke();
386
+ ctx.fillStyle = hue(n.group);
346
387
  } else {
347
- ctx.fillStyle = colour.get(n.group); ctx.fill();
348
- ctx.fillStyle = css("--bg");
388
+ ctx.fillStyle = hue(n.group); ctx.fill();
389
+ ctx.fillStyle = css("--panel");
349
390
  }
350
- ctx.font = "600 " + Math.max(9, r * 0.6) + "px ui-monospace,monospace";
391
+ ctx.font = "600 " + Math.max(9, r * 0.62) + "px " + SANS;
351
392
  ctx.textAlign = "center"; ctx.textBaseline = "middle";
352
393
  ctx.fillText(String(n.count), n.x, n.y + 0.5);
353
394
  ctx.textBaseline = "alphabetic";
354
395
  const text = n.id.length > 24 ? n.id.slice(0, 23) + "..." : n.id;
355
- const fs = Math.max(10, 12 / scale);
356
- ctx.font = "600 " + fs + "px -apple-system,system-ui,sans-serif";
396
+ const fs = 12.5 / scale;
397
+ ctx.font = "600 " + fs + "px " + SANS;
357
398
  const w = ctx.measureText(text).width;
358
- const bx = n.x - w / 2, by = n.y + r + 6, bh = fs * 1.25;
399
+ const bx = n.x - w / 2, by = n.y + r + 6 / scale, bh = fs * 1.25;
359
400
  const clashes = labelBoxes.some((o) =>
360
401
  bx < o.x + o.w + 8 && bx + w + 8 > o.x && by < o.y + o.h + 4 && by + bh + 4 > o.y);
361
402
  if (!clashes || n === hover) {
362
403
  labelBoxes.push({ x: bx, y: by, w, h: bh });
363
404
  ctx.textAlign = "center";
364
- ctx.fillStyle = css(n === hover ? "--ink" : "--ink-dim");
365
- ctx.fillText(text, n.x, by + fs);
405
+ label(text, n.x, by + fs, n === hover ? "--ink" : "--ink", 600, 12.5);
366
406
  }
367
407
  ctx.textAlign = "left";
368
408
  } else {
369
- ctx.fillStyle = colour.get(n.group) ?? css("--ink-faint");
409
+ ctx.fillStyle = hue(n.group);
370
410
  ctx.beginPath(); ctx.arc(n.x, n.y, r, 0, 7); ctx.fill();
371
411
  if (n === selected || n === hover || scale > 1.05) {
372
- ctx.fillStyle = css(n === selected || n === hover ? "--ink" : "--ink-dim");
373
- ctx.font = Math.max(9, 10.5 / scale) + "px ui-monospace,monospace";
374
- ctx.fillText(n.id.length > 26 ? n.id.slice(0, 25) + "..." : n.id, n.x + r + 4, n.y + 3.5);
412
+ const text = n.id.length > 26 ? n.id.slice(0, 25) + "…" : n.id;
413
+ label(text, n.x + r + 5 / scale, n.y + 4 / scale, n === selected || n === hover ? "--ink" : "--ink-dim", 500, 11.5);
375
414
  }
376
415
  }
377
416
  if (n === selected || n === hover) {
@@ -396,8 +435,8 @@ function drawGraph(canvas, wrap, s) {
396
435
  const p = toWorld(ev);
397
436
  // Members first: an open group's node must never swallow a click meant for a fact.
398
437
  const vis = shown();
399
- return vis.filter((n) => !n.isGroup).find((n) => Math.hypot(n.x - p.x, n.y - p.y) < radius(n) + 6)
400
- ?? vis.filter((n) => n.isGroup).find((n) => Math.hypot(n.x - p.x, n.y - p.y) < radius(n) + 5);
438
+ return vis.filter((n) => !n.isGroup).find((n) => Math.hypot(n.x - p.x, n.y - p.y) < seen(n) + 6 / scale)
439
+ ?? vis.filter((n) => n.isGroup).find((n) => Math.hypot(n.x - p.x, n.y - p.y) < seen(n) + 5 / scale);
401
440
  };
402
441
 
403
442
  canvas.onpointerdown = (ev) => {