@tinyactors/scxmljs 0.2.0-dev.0 → 0.2.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 +9 -9
- package/dist/explorer/element.d.ts +5 -3
- package/dist/explorer/element.js +523 -262
- package/dist/explorer/element.js.map +1 -1
- package/dist/explorer/strings.d.ts +41 -23
- package/dist/explorer/strings.js +24 -15
- package/dist/explorer/strings.js.map +1 -1
- package/dist/explorer/styles.d.ts +9 -1
- package/dist/explorer/styles.js +291 -150
- package/dist/explorer/styles.js.map +1 -1
- package/dist/explorer.d.ts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/model.d.ts +4 -1
- package/dist/model.js +7 -1
- package/dist/model.js.map +1 -1
- package/dist/session.d.ts +22 -9
- package/dist/session.js +53 -13
- package/dist/session.js.map +1 -1
- package/dist/themes/tinyactors.css +1 -0
- package/dist/trusted.d.ts +1 -0
- package/dist/ui/icons.d.ts +31 -0
- package/dist/ui/icons.js +186 -0
- package/dist/ui/icons.js.map +1 -0
- package/dist/ui/notation.d.ts +53 -0
- package/dist/ui/notation.js +117 -0
- package/dist/ui/notation.js.map +1 -0
- package/dist/ui/svg.d.ts +4 -0
- package/dist/ui/svg.js +26 -0
- package/dist/ui/svg.js.map +1 -1
- package/dist/ui/theme.d.ts +1 -1
- package/dist/ui/theme.js +6 -0
- package/dist/ui/theme.js.map +1 -1
- package/dist/view/describe.d.ts +17 -0
- package/dist/view/describe.js +49 -0
- package/dist/view/describe.js.map +1 -0
- package/dist/view/element.d.ts +39 -9
- package/dist/view/element.js +723 -86
- package/dist/view/element.js.map +1 -1
- package/dist/view/layout.d.ts +20 -0
- package/dist/view/layout.js +205 -29
- package/dist/view/layout.js.map +1 -1
- package/dist/view/strings.d.ts +34 -8
- package/dist/view/strings.js +19 -6
- package/dist/view/strings.js.map +1 -1
- package/dist/view/styles.d.ts +1 -1
- package/dist/view/styles.js +107 -21
- package/dist/view/styles.js.map +1 -1
- package/dist/view.d.ts +8 -4
- package/dist/view.js +6 -3
- package/dist/view.js.map +1 -1
- package/package.json +2 -2
package/dist/explorer/element.js
CHANGED
|
@@ -7,8 +7,10 @@
|
|
|
7
7
|
* chart), doors in/out of the focus, and the events accepted right now
|
|
8
8
|
* State detail for one state: actions, transitions, invokes, data
|
|
9
9
|
*
|
|
10
|
-
* No canvas, no pan/zoom: navigation is tree + breadcrumbs + drill-in
|
|
11
|
-
*
|
|
10
|
+
* No canvas, no pan/zoom: navigation is tree + breadcrumbs + drill-in. The focus
|
|
11
|
+
* fills the element; the tree and the inspector float over it as panels (two when
|
|
12
|
+
* wide, one with two pages when medium, a bottom sheet when narrow), playback and
|
|
13
|
+
* Follow sit in the bottom corners.
|
|
12
14
|
* Big charts: the tree is windowed, lists are grouped/filterable and cut off
|
|
13
15
|
* with "+N more", the focus switches from diagram to list when it gets crowded.
|
|
14
16
|
*
|
|
@@ -17,7 +19,7 @@
|
|
|
17
19
|
* detail:<id> in that state's detail pane
|
|
18
20
|
* event:<descriptor> in the row of that accepted event (e.g. a form for its data)
|
|
19
21
|
* service:<alias> in that service's card at the System level
|
|
20
|
-
* toolbar in the
|
|
22
|
+
* toolbar in the panel's head, after the breadcrumb
|
|
21
23
|
* empty-tree, empty-events, empty-detail replace the empty-state messages
|
|
22
24
|
*
|
|
23
25
|
* const x = document.querySelector("scxml-explorer");
|
|
@@ -39,7 +41,9 @@
|
|
|
39
41
|
import { PlaybackClock } from "../clock.js";
|
|
40
42
|
import { isAtomic } from "../model.js";
|
|
41
43
|
import { Announcer } from "../ui/announcer.js";
|
|
42
|
-
import
|
|
44
|
+
import * as icons from "../ui/icons.js";
|
|
45
|
+
import { actionGlyphs, eventName, glyph, NOTATION_CSS } from "../ui/notation.js";
|
|
46
|
+
import { arrowMarker, icon } from "../ui/svg.js";
|
|
43
47
|
import { lazySheet, themeSheet } from "../ui/theme.js";
|
|
44
48
|
import { placeLabels } from "./layout.js";
|
|
45
49
|
import { defaultStrings } from "./strings.js";
|
|
@@ -49,7 +53,14 @@ const DEFAULT_ROW = 30; // tree row height (px) unless --scxml-row-height says o
|
|
|
49
53
|
const DIAGRAM_MAX_CHILDREN = 9;
|
|
50
54
|
const LIST_PAGE = 40;
|
|
51
55
|
const DOORS_SHOWN = 6;
|
|
52
|
-
|
|
56
|
+
/** From this width on, the tree and the inspector each get a panel. */
|
|
57
|
+
const WIDE_WIDTH = 1280;
|
|
58
|
+
/** The sheet's lowest height (px): its handle and the strip of accepted events. */
|
|
59
|
+
const SHEET_LOW = 88;
|
|
60
|
+
/** How far from the top the sheet stops when it's all the way up (px). */
|
|
61
|
+
const SHEET_TOP = 8;
|
|
62
|
+
/** Only the kinds that behave differently get a mark; plain states and containers go without. */
|
|
63
|
+
const KIND_MARK = { parallel: "∥", final: "◎", history: "H" };
|
|
53
64
|
const kindOf = (s) => (s.kind === "state" ? (s.children.length ? "compound" : "atomic") : s.kind);
|
|
54
65
|
const SPEEDS = [
|
|
55
66
|
[0.25, "¼×"],
|
|
@@ -98,7 +109,9 @@ export class ScxmlExplorer extends ElementBase {
|
|
|
98
109
|
#selected;
|
|
99
110
|
#selectedService;
|
|
100
111
|
#follow = true;
|
|
101
|
-
#
|
|
112
|
+
#page = "tree";
|
|
113
|
+
#sheet = "low";
|
|
114
|
+
#layout = "panels";
|
|
102
115
|
#inspector = "events";
|
|
103
116
|
#crumbsExpanded = false;
|
|
104
117
|
// view state
|
|
@@ -113,9 +126,12 @@ export class ScxmlExplorer extends ElementBase {
|
|
|
113
126
|
#eventScope = "inherited";
|
|
114
127
|
#groupOpen = new Map();
|
|
115
128
|
#machineFilter = "";
|
|
129
|
+
/** leaf rows of the focus list opened in place */
|
|
130
|
+
#openRows = new Set();
|
|
131
|
+
/** the viewed machine's transitions taken in its last step, and the leaves it left then */
|
|
132
|
+
#fired = new Set();
|
|
133
|
+
#visited = new Set();
|
|
116
134
|
#strings = defaultStrings;
|
|
117
|
-
/** layout breakpoint, measured on the host (container queries decide the CSS) */
|
|
118
|
-
#narrow = false;
|
|
119
135
|
/** the tree's keyboard cursor (roving tabindex) */
|
|
120
136
|
#treeCursor;
|
|
121
137
|
#typeahead = { text: "", at: 0 };
|
|
@@ -178,7 +194,7 @@ export class ScxmlExplorer extends ElementBase {
|
|
|
178
194
|
if (width === this.#width)
|
|
179
195
|
return;
|
|
180
196
|
this.#width = width;
|
|
181
|
-
this.#
|
|
197
|
+
this.#setLayout(width === 0 ? "panels" : width <= NARROW_WIDTH ? "sheet" : width < WIDE_WIDTH ? "panel" : "panels");
|
|
182
198
|
this.#schedule();
|
|
183
199
|
}
|
|
184
200
|
/**
|
|
@@ -350,9 +366,25 @@ export class ScxmlExplorer extends ElementBase {
|
|
|
350
366
|
this.#selected = undefined;
|
|
351
367
|
this.#focusFilter = "";
|
|
352
368
|
this.#focusShowAll = false;
|
|
369
|
+
this.#openRows.clear();
|
|
370
|
+
this.#fired = new Set();
|
|
371
|
+
this.#visited = new Set();
|
|
353
372
|
if (!this.#expanded.has(key))
|
|
354
373
|
this.#expanded.set(key, activeExpansion(session.model, (s) => session.isActiveNode(s)));
|
|
374
|
+
// what the last step did: the transitions taken, and the leaves it left
|
|
375
|
+
let taken = [];
|
|
376
|
+
let leaves = session.configuration.filter(isAtomic);
|
|
377
|
+
const onMicro = (e) => taken.push(...e.transitions);
|
|
355
378
|
const onMacro = () => {
|
|
379
|
+
const now = session.configuration.filter(isAtomic);
|
|
380
|
+
if (taken.length) {
|
|
381
|
+
this.#fired = new Set(taken);
|
|
382
|
+
const left = leaves.filter((s) => !now.includes(s));
|
|
383
|
+
if (left.length)
|
|
384
|
+
this.#visited = new Set(left);
|
|
385
|
+
}
|
|
386
|
+
taken = [];
|
|
387
|
+
leaves = now;
|
|
356
388
|
// the first real configuration expands the active path once, whether or not we follow
|
|
357
389
|
if (!this.#seeded.has(key) && session.configuration.length) {
|
|
358
390
|
this.#seeded.add(key);
|
|
@@ -366,9 +398,11 @@ export class ScxmlExplorer extends ElementBase {
|
|
|
366
398
|
this.#applyFollow();
|
|
367
399
|
this.#schedule();
|
|
368
400
|
};
|
|
401
|
+
session.addEventListener("microstep", onMicro);
|
|
369
402
|
session.addEventListener("macrostep", onMacro);
|
|
370
403
|
session.addEventListener("done", onMacro);
|
|
371
404
|
this.#sessionListeners = () => {
|
|
405
|
+
session.removeEventListener("microstep", onMicro);
|
|
372
406
|
session.removeEventListener("macrostep", onMacro);
|
|
373
407
|
session.removeEventListener("done", onMacro);
|
|
374
408
|
};
|
|
@@ -415,7 +449,8 @@ export class ScxmlExplorer extends ElementBase {
|
|
|
415
449
|
this.#focusFilter = "";
|
|
416
450
|
this.#focusShowAll = false;
|
|
417
451
|
this.#doorsShowAll = { exits: false, entries: false };
|
|
418
|
-
this.#
|
|
452
|
+
if (this.#focus !== this.#lastFocus)
|
|
453
|
+
this.#openRows.clear();
|
|
419
454
|
const exp = this.#expanded.get(this.#machineKey);
|
|
420
455
|
if (exp)
|
|
421
456
|
for (const a of pathTo(s))
|
|
@@ -425,11 +460,16 @@ export class ScxmlExplorer extends ElementBase {
|
|
|
425
460
|
}
|
|
426
461
|
#setLevel(level) {
|
|
427
462
|
this.#level = level;
|
|
428
|
-
this.#tab = level === "system" ? "system" : "focus";
|
|
429
463
|
}
|
|
430
464
|
#showInspector(which) {
|
|
431
465
|
this.#inspector = which;
|
|
432
|
-
this.#
|
|
466
|
+
this.#showPage("inspector");
|
|
467
|
+
}
|
|
468
|
+
/** With one panel: show its tree or its inspector page (the sheet opens up from its low height to show it). */
|
|
469
|
+
#showPage(page) {
|
|
470
|
+
this.#page = page;
|
|
471
|
+
if (this.#layout === "sheet" && this.#sheet === "low")
|
|
472
|
+
this.#sheet = "half";
|
|
433
473
|
this.#schedule();
|
|
434
474
|
}
|
|
435
475
|
/** Change view state, then re-render. */
|
|
@@ -447,13 +487,13 @@ export class ScxmlExplorer extends ElementBase {
|
|
|
447
487
|
if (session)
|
|
448
488
|
this.#emit("scxml-select", { session, state: s });
|
|
449
489
|
this.#inspector = "detail";
|
|
450
|
-
this.#
|
|
451
|
-
this.#schedule();
|
|
490
|
+
this.#showPage("inspector");
|
|
452
491
|
}
|
|
453
492
|
// ──────────────────────────────── shell ────────────────────────────────
|
|
454
493
|
#buildShell() {
|
|
455
494
|
const h = html;
|
|
456
|
-
|
|
495
|
+
// the toolbar slot sits in the title row, after the title
|
|
496
|
+
const toolbar = h("slot", { name: "toolbar" });
|
|
457
497
|
const crumbs = h("nav", { class: "crumbs", part: "crumbs" });
|
|
458
498
|
const follow = h("button", { class: "follow", part: "follow", type: "button" });
|
|
459
499
|
follow.addEventListener("click", () => this.#setFollow(!this.#follow));
|
|
@@ -466,17 +506,19 @@ export class ScxmlExplorer extends ElementBase {
|
|
|
466
506
|
this.#treeScroll().scrollTop = 0;
|
|
467
507
|
this.#schedule();
|
|
468
508
|
});
|
|
469
|
-
|
|
470
|
-
activeOnly
|
|
471
|
-
|
|
509
|
+
// "only active states": the funnel glyph, a toggle
|
|
510
|
+
const activeOnly = h("button", { class: "filter", type: "button", part: "active-only", "aria-pressed": "false" }, icon(icons.funnel, 16));
|
|
511
|
+
activeOnly.addEventListener("click", () => {
|
|
512
|
+
this.#activeOnly = !this.#activeOnly;
|
|
513
|
+
activeOnly.setAttribute("aria-pressed", String(this.#activeOnly));
|
|
472
514
|
this.#schedule();
|
|
473
515
|
});
|
|
474
|
-
const activeOnlyText =
|
|
516
|
+
const activeOnlyText = activeOnly;
|
|
475
517
|
const treeViewport = h("div", { class: "tree-viewport", part: "tree", role: "tree" });
|
|
476
518
|
treeViewport.addEventListener("keydown", (e) => this.#treeKey(e));
|
|
477
519
|
const treeScroll = h("div", { class: "pane-scroll" }, treeViewport);
|
|
478
520
|
treeScroll.addEventListener("scroll", () => this.#renderTree(), { passive: true });
|
|
479
|
-
const treePane = h("section", { class: "pane tree-pane", part: "tree-pane", "data-tab": "tree" }, h("div", { class: "pane-head" }, treeTitle, treeCount), h("div", { class: "search" }, treeSearch,
|
|
521
|
+
const treePane = h("section", { class: "pane tree-pane", part: "tree-pane", "data-tab": "tree" }, h("div", { class: "pane-head" }, treeTitle, treeCount), h("div", { class: "search" }, treeSearch, activeOnly), treeScroll);
|
|
480
522
|
// center pane
|
|
481
523
|
const centerScroll = h("div", { class: "pane-scroll" });
|
|
482
524
|
const center = h("section", { class: "pane center", part: "focus-pane", "data-tab": "focus" }, centerScroll);
|
|
@@ -490,19 +532,23 @@ export class ScxmlExplorer extends ElementBase {
|
|
|
490
532
|
});
|
|
491
533
|
const scopes = h("div", { class: "scopes", part: "scopes", role: "group" });
|
|
492
534
|
const dataLabel = h("span", {});
|
|
493
|
-
const eventsHead = h("div", {}, h("div", { class: "search" }, eventSearch), scopes,
|
|
535
|
+
const eventsHead = h("div", {}, h("div", { class: "search" }, eventSearch), scopes,
|
|
536
|
+
// event data is rarely needed: behind a disclosure
|
|
537
|
+
h("details", { class: "data-field", part: "event-data" }, h("summary", {}, dataLabel), eventData));
|
|
494
538
|
const inspectorBody = h("div", { class: "pane-scroll" });
|
|
495
539
|
const inspector = h("section", { class: "pane inspector", part: "inspector", "data-tab": "events" }, h("div", { class: "pane-head" }, inspectorSwitch), eventsHead, inspectorBody);
|
|
496
|
-
// playback: pause / step / speed for a PlaybackClock
|
|
540
|
+
// playback: pause / step / speed for a PlaybackClock, in the header bar
|
|
497
541
|
const playToggle = h("button", { class: "play", part: "play", type: "button" });
|
|
498
542
|
playToggle.addEventListener("click", () => this.#clock?.toggle());
|
|
499
543
|
const stepButton = h("button", { class: "step", part: "step", type: "button" });
|
|
500
544
|
stepButton.addEventListener("click", () => this.#step());
|
|
501
|
-
const speeds = h("
|
|
545
|
+
const speeds = h("select", { class: "speeds", part: "speeds" });
|
|
546
|
+
speeds.addEventListener("change", () => {
|
|
547
|
+
if (this.#clock)
|
|
548
|
+
this.#clock.speed = Number(speeds.value);
|
|
549
|
+
});
|
|
502
550
|
const clockTime = h("span", { class: "clock-time", part: "clock" });
|
|
503
|
-
const
|
|
504
|
-
const lastStep = h("span", { class: "last-step", part: "last-step" });
|
|
505
|
-
const playback = h("div", { class: "playback", part: "playback", hidden: "" }, playToggle, stepButton, speeds, clockTime, clockQueue, lastStep);
|
|
551
|
+
const playback = h("div", { class: "playback", part: "playback", hidden: "" }, playToggle, stepButton, speeds, clockTime);
|
|
506
552
|
this.addEventListener("keydown", (e) => {
|
|
507
553
|
const target = e.composedPath()[0];
|
|
508
554
|
if (!this.#clock || /^(INPUT|TEXTAREA|SELECT|BUTTON)$/.test(target.tagName))
|
|
@@ -519,14 +565,37 @@ export class ScxmlExplorer extends ElementBase {
|
|
|
519
565
|
this.#step();
|
|
520
566
|
}
|
|
521
567
|
});
|
|
522
|
-
const tabs = h("nav", { class: "tabs", part: "tabs", role: "tablist" });
|
|
523
568
|
const strip = h("div", { class: "events-strip", part: "strip", role: "group" });
|
|
524
569
|
// polite live region: steps and sent events for screen readers (see `announce`)
|
|
525
570
|
const live = h("div", { class: "sr-only", role: "status", "aria-live": "polite", "aria-atomic": "true" });
|
|
526
|
-
|
|
571
|
+
// the panels float over the focus, like a map's: one at the side (tree, then the inspector as a
|
|
572
|
+
// page of it), two on wide screens (tree left, inspector right), a bottom sheet on narrow ones
|
|
573
|
+
const back = button("", () => this.#showPage("tree"), { class: "back", part: "back" });
|
|
574
|
+
const toInspector = button("", () => this.#showInspector("events"), {
|
|
575
|
+
class: "to-inspector",
|
|
576
|
+
part: "to-inspector",
|
|
577
|
+
});
|
|
578
|
+
treePane.querySelector(".pane-head").append(toInspector);
|
|
579
|
+
inspector.prepend(h("div", { class: "page-back" }, back));
|
|
580
|
+
const handle = h("button", { class: "sheet-handle", part: "sheet-handle", type: "button" });
|
|
581
|
+
handle.addEventListener("click", () => {
|
|
582
|
+
// the click that ends a drag isn't a tap on the handle
|
|
583
|
+
if (this.#dragged) {
|
|
584
|
+
this.#dragged = false;
|
|
585
|
+
return;
|
|
586
|
+
}
|
|
587
|
+
this.#update(() => (this.#sheet = this.#sheet === "low" ? "half" : this.#sheet === "half" ? "full" : "low"));
|
|
588
|
+
});
|
|
589
|
+
const panelBody = h("div", { class: "panel-body" }, treePane, inspector);
|
|
590
|
+
const panel = h("section", { class: "panel", part: "panel" }, handle, panelBody, strip);
|
|
591
|
+
const sidePanel = h("section", { class: "panel side-panel", part: "side-panel" });
|
|
592
|
+
playback.classList.add("corner", "corner-start");
|
|
593
|
+
follow.classList.add("corner", "corner-end");
|
|
594
|
+
const stage = h("div", { class: "stage" }, center, panel, sidePanel, playback, follow);
|
|
595
|
+
const shell = h("div", { class: "shell" }, stage, live);
|
|
527
596
|
this.#shadow.append(shell);
|
|
528
597
|
this.#el = {
|
|
529
|
-
|
|
598
|
+
toolbar,
|
|
530
599
|
crumbs,
|
|
531
600
|
follow,
|
|
532
601
|
treePane,
|
|
@@ -540,8 +609,13 @@ export class ScxmlExplorer extends ElementBase {
|
|
|
540
609
|
inspectorBody,
|
|
541
610
|
eventsHead,
|
|
542
611
|
eventData,
|
|
543
|
-
tabs,
|
|
544
612
|
strip,
|
|
613
|
+
panel,
|
|
614
|
+
panelBody,
|
|
615
|
+
sidePanel,
|
|
616
|
+
handle,
|
|
617
|
+
back,
|
|
618
|
+
toInspector,
|
|
545
619
|
live,
|
|
546
620
|
treeTitle,
|
|
547
621
|
treeSearch,
|
|
@@ -554,26 +628,109 @@ export class ScxmlExplorer extends ElementBase {
|
|
|
554
628
|
stepButton,
|
|
555
629
|
speeds,
|
|
556
630
|
clockTime,
|
|
557
|
-
|
|
558
|
-
lastStep,
|
|
631
|
+
shell,
|
|
559
632
|
};
|
|
560
633
|
this.#applyShellStrings();
|
|
634
|
+
this.#wireSheet();
|
|
635
|
+
this.#applyLayout();
|
|
636
|
+
}
|
|
637
|
+
/** How the panels sit: moves the inspector between the side panel and the single panel. */
|
|
638
|
+
#setLayout(layout) {
|
|
639
|
+
if (layout === this.#layout)
|
|
640
|
+
return;
|
|
641
|
+
this.#layout = layout;
|
|
642
|
+
this.#applyLayout();
|
|
643
|
+
}
|
|
644
|
+
#applyLayout() {
|
|
645
|
+
const { shell, inspector, panelBody, sidePanel } = this.#el;
|
|
646
|
+
shell.dataset.layout = this.#layout;
|
|
647
|
+
const home = this.#layout === "panels" ? sidePanel : panelBody;
|
|
648
|
+
if (inspector.parentElement !== home)
|
|
649
|
+
home.append(inspector);
|
|
650
|
+
}
|
|
651
|
+
/** What the sheet covers, so the focus keeps its content (and the corners) clear of it. */
|
|
652
|
+
#syncSheetHeight(panel = this.#el.panel) {
|
|
653
|
+
const covered = this.#layout === "sheet" ? panel.offsetHeight : 0;
|
|
654
|
+
this.#el.shell.style.setProperty("--sheet-h", `${covered || SHEET_LOW}px`);
|
|
655
|
+
}
|
|
656
|
+
/** Set while a drag on the sheet's handle is in progress or just ended (so it isn't also a click). */
|
|
657
|
+
#dragged = false;
|
|
658
|
+
/** The sheet: drag its handle (or its head) to any height; it settles at the nearest of three. */
|
|
659
|
+
#wireSheet() {
|
|
660
|
+
const { panel, handle } = this.#el;
|
|
661
|
+
let drag;
|
|
662
|
+
const startOn = [handle];
|
|
663
|
+
const move = (e) => {
|
|
664
|
+
if (!drag || e.pointerId !== drag.id)
|
|
665
|
+
return;
|
|
666
|
+
const dy = e.clientY - drag.y;
|
|
667
|
+
if (!this.#dragged && Math.abs(dy) < 6)
|
|
668
|
+
return;
|
|
669
|
+
this.#dragged = true;
|
|
670
|
+
panel.classList.add("dragging");
|
|
671
|
+
const max = (this.#el.shell.clientHeight || 600) - SHEET_TOP;
|
|
672
|
+
drag.to = Math.min(max, Math.max(SHEET_LOW, drag.h - dy));
|
|
673
|
+
panel.style.height = `${drag.to}px`;
|
|
674
|
+
};
|
|
675
|
+
const end = (e) => {
|
|
676
|
+
if (!drag || e.pointerId !== drag.id)
|
|
677
|
+
return;
|
|
678
|
+
const { el, to: h } = drag;
|
|
679
|
+
drag = undefined;
|
|
680
|
+
if (el.hasPointerCapture?.(e.pointerId))
|
|
681
|
+
el.releasePointerCapture(e.pointerId);
|
|
682
|
+
panel.classList.remove("dragging");
|
|
683
|
+
if (!this.#dragged)
|
|
684
|
+
return;
|
|
685
|
+
// the nearest height wins (the one the drag asked for: the panel may still be animating)
|
|
686
|
+
const total = this.#el.shell.clientHeight || 600;
|
|
687
|
+
const heights = [
|
|
688
|
+
["low", SHEET_LOW],
|
|
689
|
+
["half", total / 2],
|
|
690
|
+
["full", total - SHEET_TOP],
|
|
691
|
+
];
|
|
692
|
+
heights.sort((a, b) => Math.abs(a[1] - h) - Math.abs(b[1] - h));
|
|
693
|
+
panel.style.removeProperty("height");
|
|
694
|
+
this.#update(() => (this.#sheet = heights[0][0]));
|
|
695
|
+
};
|
|
696
|
+
for (const el of startOn) {
|
|
697
|
+
el.addEventListener("pointerdown", (e) => {
|
|
698
|
+
if (this.#layout !== "sheet" || e.button !== 0)
|
|
699
|
+
return;
|
|
700
|
+
const target = e.composedPath()[0];
|
|
701
|
+
if (el !== handle && target.closest?.("button, a, input"))
|
|
702
|
+
return;
|
|
703
|
+
// captured from the start: the pointer leaves the sheet as soon as it moves up
|
|
704
|
+
el.setPointerCapture?.(e.pointerId);
|
|
705
|
+
const h = panel.getBoundingClientRect().height;
|
|
706
|
+
drag = { id: e.pointerId, y: e.clientY, h, el, to: h };
|
|
707
|
+
this.#dragged = false;
|
|
708
|
+
});
|
|
709
|
+
el.addEventListener("pointermove", move);
|
|
710
|
+
el.addEventListener("pointerup", end);
|
|
711
|
+
el.addEventListener("pointercancel", end);
|
|
712
|
+
}
|
|
713
|
+
// the corners ride on the sheet as it moves (drags, and the transition between heights)
|
|
714
|
+
if (typeof ResizeObserver !== "undefined")
|
|
715
|
+
new ResizeObserver(() => this.#syncSheetHeight()).observe(panel);
|
|
561
716
|
}
|
|
562
717
|
/** The shell's static text, from `strings` (called again when they change). */
|
|
563
718
|
#applyShellStrings() {
|
|
564
719
|
const t = this.#strings;
|
|
565
720
|
const e = this.#el;
|
|
566
|
-
e.levels.setAttribute("aria-label", t.levelLabel);
|
|
567
721
|
// landmarks need unique names: with several explorers on a page, each host's aria-label
|
|
568
722
|
// (if the page gives one) names its breadcrumb
|
|
569
723
|
const host = this.getAttribute("aria-label");
|
|
570
724
|
e.crumbs.setAttribute("aria-label", host ? `${host}: ${t.breadcrumbLabel}` : t.breadcrumbLabel);
|
|
571
|
-
|
|
725
|
+
// the crosshair, then the name (on a phone only the crosshair shows; the name stays its accessible name)
|
|
726
|
+
e.follow.replaceChildren(icon(this.#follow ? icons.locateFixed : icons.locate, 16), html("span", { class: "follow-label" }, t.follow));
|
|
572
727
|
e.follow.title = t.followHint;
|
|
573
|
-
|
|
728
|
+
// the tree's heading is for screen readers: the tree speaks for itself
|
|
729
|
+
e.treeTitle.replaceChildren(srText(t.statesPane));
|
|
574
730
|
e.treeSearch.placeholder = t.findState;
|
|
575
731
|
e.treeSearch.setAttribute("aria-label", t.filterStates);
|
|
576
|
-
e.activeOnlyText.
|
|
732
|
+
e.activeOnlyText.setAttribute("aria-label", t.activeOnly);
|
|
733
|
+
e.activeOnlyText.title = t.activeOnly;
|
|
577
734
|
e.treeViewport.setAttribute("aria-label", t.treeLabel);
|
|
578
735
|
e.eventSearch.placeholder = t.findEvent;
|
|
579
736
|
e.eventSearch.setAttribute("aria-label", t.filterEvents);
|
|
@@ -581,11 +738,21 @@ export class ScxmlExplorer extends ElementBase {
|
|
|
581
738
|
e.dataLabel.textContent = t.eventData;
|
|
582
739
|
e.eventData.setAttribute("aria-label", t.eventDataLabel);
|
|
583
740
|
e.playToggle.title = t.playHint;
|
|
584
|
-
e.stepButton.
|
|
741
|
+
e.stepButton.replaceChildren(icon(icons.stepForward, 16));
|
|
742
|
+
e.stepButton.setAttribute("aria-label", t.step);
|
|
585
743
|
e.stepButton.title = t.stepHint;
|
|
586
744
|
e.speeds.setAttribute("aria-label", t.speedLabel);
|
|
587
|
-
e.
|
|
745
|
+
e.speeds.title = t.speedLabel;
|
|
588
746
|
e.strip.setAttribute("aria-label", t.acceptedEventsLabel);
|
|
747
|
+
// named from the start; the first render puts in the count
|
|
748
|
+
e.toInspector.textContent = `${t.accepts(0)} ›`;
|
|
749
|
+
e.handle.setAttribute("aria-label", t.sheetExpand);
|
|
750
|
+
e.handle.title = t.sheetExpand;
|
|
751
|
+
e.back.textContent = t.backToStates;
|
|
752
|
+
e.back.setAttribute("aria-label", t.backToStatesLabel);
|
|
753
|
+
// landmarks: unique names with several explorers on a page (see the breadcrumb above)
|
|
754
|
+
e.panel.setAttribute("aria-label", host ? `${host}: ${t.panelLabel}` : t.panelLabel);
|
|
755
|
+
e.sidePanel.setAttribute("aria-label", host ? `${host}: ${t.inspectorLabel}` : t.inspectorLabel);
|
|
589
756
|
}
|
|
590
757
|
#treeScroll() {
|
|
591
758
|
return this.#el.treeScroll;
|
|
@@ -610,27 +777,34 @@ export class ScxmlExplorer extends ElementBase {
|
|
|
610
777
|
if (!clock)
|
|
611
778
|
return;
|
|
612
779
|
const t = this.#strings;
|
|
613
|
-
const { playToggle, stepButton, speeds, clockTime
|
|
614
|
-
|
|
780
|
+
const { playToggle, stepButton, speeds, clockTime } = this.#el;
|
|
781
|
+
// icons with names: play / pause, step
|
|
782
|
+
const playing = String(clock.playing);
|
|
783
|
+
if (playToggle.dataset.playing !== playing) {
|
|
784
|
+
playToggle.dataset.playing = playing;
|
|
785
|
+
playToggle.replaceChildren(icon(clock.playing ? icons.pause : icons.play, 16));
|
|
786
|
+
playToggle.setAttribute("aria-label", clock.playing ? t.pause : t.play);
|
|
787
|
+
}
|
|
615
788
|
playToggle.setAttribute("aria-pressed", String(!clock.playing));
|
|
616
789
|
stepButton.disabled = clock.pending === 0;
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
790
|
+
const speed = String(clock.speed);
|
|
791
|
+
if (!speeds.options.length)
|
|
792
|
+
for (const [v, text] of SPEEDS)
|
|
793
|
+
speeds.append(html("option", { value: String(v) }, text));
|
|
794
|
+
if (![...speeds.options].some((o) => o.value === speed))
|
|
795
|
+
speeds.append(html("option", { value: speed }, `${speed}×`));
|
|
796
|
+
speeds.value = speed;
|
|
621
797
|
clockTime.textContent = t.clockTime(formatTime(clock.now()));
|
|
798
|
+
// what's pending is a detail: in the tooltip
|
|
622
799
|
const next = clock.nextTimerAt;
|
|
623
|
-
const queue = [];
|
|
800
|
+
const queue = [t.virtualTime];
|
|
624
801
|
if (clock.ready)
|
|
625
802
|
queue.push(t.queued(clock.ready));
|
|
626
803
|
if (next !== undefined)
|
|
627
804
|
queue.push(t.nextTimer(formatTime(Math.max(0, next - clock.now()))));
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
? `${ls.machine}: ${ls.event ?? t.start}${ls.moves.length ? ` · ${ls.moves.slice(0, 2).join(" · ")}${ls.moves.length > 2 ? ` +${ls.moves.length - 2}` : ""}` : ` · ${t.noTransition}`}`
|
|
632
|
-
: "";
|
|
633
|
-
lastStep.title = ls ? [ls.event ?? t.start, ...ls.moves].join("\n") : "";
|
|
805
|
+
if (queue.length === 1)
|
|
806
|
+
queue.push(t.idle);
|
|
807
|
+
clockTime.title = queue.join(" · ");
|
|
634
808
|
}
|
|
635
809
|
// ─────────────────────────────── render ───────────────────────────────
|
|
636
810
|
#schedule() {
|
|
@@ -654,6 +828,7 @@ export class ScxmlExplorer extends ElementBase {
|
|
|
654
828
|
this.#emit("scxml-focus", { session: m.session, state: this.#focus });
|
|
655
829
|
}
|
|
656
830
|
this.#renderPlayback();
|
|
831
|
+
this.#el.shell.dataset.level = this.#level;
|
|
657
832
|
this.#renderTop(m);
|
|
658
833
|
this.#renderTree();
|
|
659
834
|
if (this.#level === "system")
|
|
@@ -661,43 +836,35 @@ export class ScxmlExplorer extends ElementBase {
|
|
|
661
836
|
else
|
|
662
837
|
this.#renderFocus(m);
|
|
663
838
|
this.#renderInspector(m);
|
|
664
|
-
this.#
|
|
839
|
+
this.#renderPanels(m);
|
|
665
840
|
}
|
|
666
841
|
#renderTop(m) {
|
|
667
842
|
const h = html;
|
|
668
843
|
const t = this.#strings;
|
|
669
|
-
const {
|
|
670
|
-
levels.replaceChildren(...["system", "machine"].map((lv) => button(lv === "system" ? t.levelSystem : t.levelMachine, () => this.#navigate(() => this.#setLevel(lv), true), {
|
|
671
|
-
"aria-pressed": String(this.#level === lv),
|
|
672
|
-
})));
|
|
844
|
+
const { crumbs, follow } = this.#el;
|
|
673
845
|
follow.setAttribute("aria-pressed", String(this.#follow));
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
},
|
|
680
|
-
];
|
|
846
|
+
// a map's locate button: a crosshair; while following, a ring in its centre (shape, not only colour)
|
|
847
|
+
const crosshair = this.#follow ? icons.locateFixed : icons.locate;
|
|
848
|
+
if (follow.firstElementChild?.getAttribute("class") !== `icon icon-${crosshair[0]}`)
|
|
849
|
+
follow.firstElementChild?.replaceWith(icon(crosshair, 16));
|
|
850
|
+
const list = [];
|
|
681
851
|
if (this.#level === "machine") {
|
|
682
|
-
|
|
852
|
+
list.push({ text: t.levelSystem, go: () => this.#navigate(() => this.#setLevel("system"), true) });
|
|
853
|
+
// machines above this one (invoke chain), and this one unless it is the focus
|
|
683
854
|
const chain = [];
|
|
684
855
|
for (let x = m; x; x = x.parentKey ? this.#tracker.machines.get(x.parentKey) : undefined)
|
|
685
856
|
chain.unshift(x);
|
|
857
|
+
const atRoot = this.#focus === m.session.model.root;
|
|
686
858
|
for (const x of chain)
|
|
687
|
-
|
|
688
|
-
text: x.name,
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
});
|
|
692
|
-
for (const s of pathTo(this.#focus).slice(1))
|
|
693
|
-
list.push({ text: label(s), go: () => this.#focusOn(s), current: s === this.#focus && !this.#selected });
|
|
694
|
-
if (this.#selected && this.#selected !== this.#focus)
|
|
695
|
-
list.push({ text: label(this.#selected), go: () => this.#select(this.#selected), current: true });
|
|
859
|
+
if (x !== m || !atRoot)
|
|
860
|
+
list.push({ text: x.name, go: () => this.#navigate(() => this.#openMachine(x.key)) });
|
|
861
|
+
for (const s of pathTo(this.#focus).slice(1, -1))
|
|
862
|
+
list.push({ text: label(s), go: () => this.#focusOn(s) });
|
|
696
863
|
}
|
|
864
|
+
// long paths: the first place (the way to the System level), "…", and the place right above
|
|
697
865
|
let shown = list;
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
shown = narrow ? ["…", ...list.slice(-2)] : [list[0], list[1], "…", ...list.slice(-2)];
|
|
866
|
+
if (!this.#crumbsExpanded && list.length > 3)
|
|
867
|
+
shown = [list[0], "…", list.at(-1)];
|
|
701
868
|
crumbs.replaceChildren(...shown.flatMap((c, i) => {
|
|
702
869
|
const sep = i ? [h("span", { class: "sep", "aria-hidden": "true" }, "›")] : [];
|
|
703
870
|
if (c === "…")
|
|
@@ -705,12 +872,9 @@ export class ScxmlExplorer extends ElementBase {
|
|
|
705
872
|
...sep,
|
|
706
873
|
button("…", () => this.#update(() => (this.#crumbsExpanded = true)), { title: t.showWholePath, "aria-label": t.showWholePath }),
|
|
707
874
|
];
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
return [...sep, b];
|
|
712
|
-
}));
|
|
713
|
-
crumbs.scrollLeft = crumbs.scrollWidth; // narrow screens: keep the current place visible
|
|
875
|
+
return [...sep, button(c.text, c.go, { title: c.text, part: "crumb" })];
|
|
876
|
+
}), shown.length ? h("span", { class: "sep", "aria-hidden": "true" }, "›") : "");
|
|
877
|
+
crumbs.hidden = !shown.length;
|
|
714
878
|
}
|
|
715
879
|
// ── tree ──
|
|
716
880
|
#treeRows = [];
|
|
@@ -730,7 +894,8 @@ export class ScxmlExplorer extends ElementBase {
|
|
|
730
894
|
});
|
|
731
895
|
const rows = this.#treeRows;
|
|
732
896
|
const total = session.model.states.filter((s) => s.kind !== "scxml" && s.kind !== "history").length;
|
|
733
|
-
|
|
897
|
+
// a count only while it says something: how many states match the filter
|
|
898
|
+
this.#el.treeCount.textContent = this.#treeFilter ? t.matchesOf(rows.filter((r) => r.match).length, total) : "";
|
|
734
899
|
// the roving tabindex: while the tree has keyboard focus the cursor stays where the user put it;
|
|
735
900
|
// otherwise it tracks the selected / focused state, so tabbing in lands on "where we are"
|
|
736
901
|
const hadFocus = this.#shadow.activeElement?.getAttribute("role") === "treeitem";
|
|
@@ -777,7 +942,7 @@ export class ScxmlExplorer extends ElementBase {
|
|
|
777
942
|
...(r.expandable ? { "aria-expanded": String(r.expanded) } : {}),
|
|
778
943
|
style: `top:${i * ROW}px; padding-left:${6 + r.depth * 14}px`,
|
|
779
944
|
title: r.node.id,
|
|
780
|
-
}, twisty, h("span", { class: "
|
|
945
|
+
}, twisty, h("span", { class: "name" }, label(r.node)), kindMark(r.node),
|
|
781
946
|
// status in words, not only colour and weight
|
|
782
947
|
leafActive ? srText(`, ${t.active}`) : r.onActivePath ? srText(`, ${t.containsActive}`) : "");
|
|
783
948
|
row.addEventListener("click", () => {
|
|
@@ -926,20 +1091,31 @@ export class ScxmlExplorer extends ElementBase {
|
|
|
926
1091
|
? "list"
|
|
927
1092
|
: "diagram"
|
|
928
1093
|
: this.#focusMode;
|
|
929
|
-
|
|
1094
|
+
// list or diagram: two icon toggles; with neither pressed, the explorer picks ("auto")
|
|
1095
|
+
const toggle = (md, glyphDef, name) => {
|
|
1096
|
+
const b = button("", () => this.#update(() => (this.#focusMode = this.#focusMode === md ? "auto" : md)), {
|
|
1097
|
+
class: "icon-toggle",
|
|
1098
|
+
"aria-pressed": String(this.#focusMode === md),
|
|
1099
|
+
"aria-label": name,
|
|
1100
|
+
title: name,
|
|
1101
|
+
});
|
|
1102
|
+
b.append(icon(glyphDef, 16));
|
|
1103
|
+
return b;
|
|
1104
|
+
};
|
|
930
1105
|
const modeSwitch = focus.kind === "parallel"
|
|
931
1106
|
? ""
|
|
932
|
-
: h("div", { class: "mode", role: "group", "aria-label": t.layoutLabel },
|
|
933
|
-
|
|
934
|
-
})));
|
|
1107
|
+
: h("div", { class: "mode", role: "group", "aria-label": t.layoutLabel }, toggle("list", icons.list, t.layoutList), toggle("diagram", icons.network, t.layoutDiagram));
|
|
1108
|
+
// the status in words only when it isn't the normal case (an active focus)
|
|
935
1109
|
const status = session.status === "done"
|
|
936
|
-
? h("span", { class: "
|
|
1110
|
+
? h("span", { class: "status" }, t.terminated)
|
|
937
1111
|
: isActive(focus) || focus.kind === "scxml"
|
|
938
|
-
?
|
|
939
|
-
: h("span", { class: "
|
|
1112
|
+
? srText(t.active)
|
|
1113
|
+
: h("span", { class: "status" }, t.inactive);
|
|
1114
|
+
// one place says where we are: the breadcrumb (the places above) and the focus as the title.
|
|
1115
|
+
// Its kind and size are for screen readers; the last step shows in the colours, not a sentence
|
|
940
1116
|
const header = [
|
|
941
|
-
h("h2", { class: "title", part: "title" }, label(focus)),
|
|
942
|
-
|
|
1117
|
+
h("div", { class: "title-row" }, h("div", { class: "place" }, this.#el.crumbs, h("h2", { class: "title", part: "title" }, label(focus))), status, this.#el.toolbar, modeSwitch),
|
|
1118
|
+
srText(t.focusSummary(t.kind(kindOf(focus)), scope.children.length, descendantCount(focus))),
|
|
943
1119
|
];
|
|
944
1120
|
let body;
|
|
945
1121
|
if (mode === "lanes")
|
|
@@ -947,7 +1123,7 @@ export class ScxmlExplorer extends ElementBase {
|
|
|
947
1123
|
else if (mode === "diagram")
|
|
948
1124
|
body = this.#diagram(scope.children, scope.edges);
|
|
949
1125
|
else
|
|
950
|
-
body = this.#list(scope.children, scope.edges);
|
|
1126
|
+
body = this.#list(scope.children, scope.edges, session);
|
|
951
1127
|
const doors = (kind) => {
|
|
952
1128
|
const all = kind === "exits" ? scope.exits : scope.entries;
|
|
953
1129
|
if (!all.length)
|
|
@@ -955,31 +1131,43 @@ export class ScxmlExplorer extends ElementBase {
|
|
|
955
1131
|
const showAll = this.#doorsShowAll[kind];
|
|
956
1132
|
const shown = showAll ? all : all.slice(0, DOORS_SHOWN);
|
|
957
1133
|
return [
|
|
958
|
-
h("div", { class: "
|
|
959
|
-
h("div", { class: "doors", part: "doors" }, ...shown.map((d) => {
|
|
1134
|
+
h("div", { class: "doors", part: "doors", role: "group", "aria-label": kind === "exits" ? t.leavesTo : t.enteredFrom }, ...shown.map((d) => {
|
|
960
1135
|
const live = kind === "exits" && (d.child === focus ? isActive(focus) : isActive(d.child));
|
|
961
1136
|
const where = kind === "exits" ? label(d.other) : `${label(d.other)} → ${label(d.child)}`;
|
|
962
1137
|
const context = `${t.inState(d.other.parent ? label(d.other.parent) : t.machine)}${kind === "exits" && d.child !== focus ? ` · ${t.fromState(label(d.child))}` : ""}`;
|
|
1138
|
+
// a door: its glyph (out, or in), where it leads, and its events as notation; where
|
|
1139
|
+
// it sits ("in …, from …") is in the tooltip and the accessible name
|
|
963
1140
|
const el = h("div", {
|
|
964
1141
|
class: `door${live ? " live" : ""}`,
|
|
965
1142
|
part: parts("door", kind === "exits" ? "exit" : "entry", live && "live"),
|
|
966
1143
|
role: "link",
|
|
967
1144
|
tabindex: "0",
|
|
968
|
-
title: t.
|
|
1145
|
+
title: `${kind === "exits" ? t.leavesTo : t.enteredFrom} ${where} · ${context}\n${d.events.join(", ")}`,
|
|
969
1146
|
"aria-label": `${kind === "exits" ? t.leavesTo : t.enteredFrom}: ${where}, ${context}; ${d.events.join(", ")}`,
|
|
970
|
-
},
|
|
1147
|
+
}, glyph(kind === "exits" ? icons.doorOpen : icons.cornerDownRight, kind === "exits" ? t.leavesTo : t.enteredFrom, true), h("span", { class: "where" }, where),
|
|
1148
|
+
// the first event, and how many more (all of them in the tooltip)
|
|
1149
|
+
h("span", { class: "events" }, this.#eventName(d.events[0] ?? ""), d.events.length > 1 ? ` +${d.events.length - 1}` : ""));
|
|
971
1150
|
activate(el, () => this.#focusOn(d.other));
|
|
972
1151
|
return el;
|
|
973
1152
|
}), all.length > DOORS_SHOWN
|
|
974
|
-
? button(showAll ? t.showFewer : t.more(all.length - DOORS_SHOWN), () => this.#update(() => (this.#doorsShowAll[kind] = !showAll)), {
|
|
975
|
-
class: "more",
|
|
976
|
-
})
|
|
1153
|
+
? button(showAll ? t.showFewer : t.more(all.length - DOORS_SHOWN), () => this.#update(() => (this.#doorsShowAll[kind] = !showAll)), { class: "more" })
|
|
977
1154
|
: ""),
|
|
978
1155
|
];
|
|
979
1156
|
};
|
|
1157
|
+
// re-rendering replaces the rows: keep keyboard focus on the same control of the same state
|
|
1158
|
+
const had = this.#shadow.activeElement;
|
|
1159
|
+
const hadRow = had && out.contains(had) ? had.closest("[data-state]") : null;
|
|
1160
|
+
const hadKey = had?.dataset.key ?? (had?.classList.contains("select") ? "select" : undefined);
|
|
980
1161
|
const scroll = out.scrollTop;
|
|
981
1162
|
out.replaceChildren(...header, body, ...doors("exits"), ...doors("entries"));
|
|
982
1163
|
out.scrollTop = scroll;
|
|
1164
|
+
if (hadRow && hadKey) {
|
|
1165
|
+
const row = out.querySelector(`[data-state="${CSS.escape(hadRow.dataset.state)}"]`);
|
|
1166
|
+
(row?.querySelector(hadKey === "select" ? ".select" : `[data-key="${hadKey}"]`) ??
|
|
1167
|
+
row?.querySelector(".select"))?.focus({
|
|
1168
|
+
preventScroll: true,
|
|
1169
|
+
});
|
|
1170
|
+
}
|
|
983
1171
|
this.#diagramObserver?.disconnect();
|
|
984
1172
|
if (mode === "diagram") {
|
|
985
1173
|
const draw = () => this.#drawEdges(scope.edges, isActive);
|
|
@@ -999,8 +1187,8 @@ export class ScxmlExplorer extends ElementBase {
|
|
|
999
1187
|
}
|
|
1000
1188
|
}
|
|
1001
1189
|
}
|
|
1002
|
-
/**
|
|
1003
|
-
#card(c
|
|
1190
|
+
/** A diagram card: the name, and a drill-in for containers. The arrows carry the events. */
|
|
1191
|
+
#card(c) {
|
|
1004
1192
|
const h = html;
|
|
1005
1193
|
const t = this.#strings;
|
|
1006
1194
|
const s = c.node;
|
|
@@ -1008,6 +1196,7 @@ export class ScxmlExplorer extends ElementBase {
|
|
|
1008
1196
|
isAtomic(s) &&
|
|
1009
1197
|
(s.invokes.length > 0 ||
|
|
1010
1198
|
s.onentry.some((b) => [...b.getElementsByTagNameNS(s.element.namespaceURI, "send")].some((x) => x.getAttribute("type") && x.getAttribute("type") !== "scxml")));
|
|
1199
|
+
const visited = !c.onActivePath && this.#wasVisited(s);
|
|
1011
1200
|
const cls = [
|
|
1012
1201
|
"card",
|
|
1013
1202
|
c.onActivePath ? "path" : "",
|
|
@@ -1015,49 +1204,43 @@ export class ScxmlExplorer extends ElementBase {
|
|
|
1015
1204
|
waiting ? "waiting" : "",
|
|
1016
1205
|
s.kind === "final" ? "final" : "",
|
|
1017
1206
|
s === this.#selected ? "selected" : "",
|
|
1207
|
+
visited ? "visited" : "",
|
|
1018
1208
|
];
|
|
1019
|
-
const status = waiting ? t.waiting : c.onActivePath ? t.active : "";
|
|
1020
|
-
// a group, not a button: it holds its own controls (drill
|
|
1021
|
-
//
|
|
1209
|
+
const status = waiting ? t.waiting : c.onActivePath ? t.active : visited ? t.lastVisited : "";
|
|
1210
|
+
// a group, not a button: it holds its own controls (drill), and interactive elements must
|
|
1211
|
+
// not nest. The state's name is the card's primary button.
|
|
1022
1212
|
const name = [label(s), t.kind(kindOf(s)), status, c.initial && t.initial].filter(Boolean).join(", ");
|
|
1023
1213
|
const select = h("button", { type: "button", class: "name select", "aria-label": name, "aria-pressed": String(s === this.#selected) }, label(s));
|
|
1214
|
+
const meta = [
|
|
1215
|
+
waiting ? h("span", { class: "status" }, t.waiting) : "",
|
|
1216
|
+
this.#does(s) ?? "",
|
|
1217
|
+
c.descendants ? this.#inside(s, c.descendants) : "",
|
|
1218
|
+
].filter(Boolean);
|
|
1024
1219
|
const card = h("div", {
|
|
1025
1220
|
class: cls.filter(Boolean).join(" "),
|
|
1026
1221
|
part: parts("card", ...cls.slice(1)),
|
|
1027
1222
|
"data-state": s.id,
|
|
1028
1223
|
role: "group",
|
|
1029
1224
|
"aria-label": name,
|
|
1030
|
-
}, c.initial ? h("span", { class: "initial-mark", title: t.initial }) : "", h("div", { class: "card-head" },
|
|
1031
|
-
? ""
|
|
1032
|
-
: h("div", { class: "meta" }, c.descendants ? button(t.inside(c.descendants), (e) => this.#drillInto(e, s), { class: "drill" }) : "", c.invokes ? h("span", {}, t.invokes(c.invokes)) : "", c.internal ? h("span", { title: t.staysInside }, `↺ ${c.internal}`) : "", opts.eventsOnArrows && c.events.length ? h("span", { title: c.events.join("\n") }, t.events(c.events.length)) : ""), opts.compact || opts.eventsOnArrows || !c.events.length
|
|
1033
|
-
? ""
|
|
1034
|
-
: h("div", { class: "events" }, ...chips(c.events, 3, (ev) => this.#sendDescriptor(ev))), h("slot", { name: `state:${s.id}` }));
|
|
1225
|
+
}, c.initial ? h("span", { class: "initial-mark", title: t.initial }) : "", h("div", { class: "card-head" }, select, kindMark(s)), meta.length ? h("div", { class: "meta" }, ...meta) : "", h("slot", { name: `state:${s.id}` }));
|
|
1035
1226
|
this.#operable(card, s, select);
|
|
1036
1227
|
return card;
|
|
1037
1228
|
}
|
|
1229
|
+
/** Was this state (or one inside it) left in the viewed machine's last step? */
|
|
1230
|
+
#wasVisited(s) {
|
|
1231
|
+
for (const v of this.#visited)
|
|
1232
|
+
if (pathTo(v).includes(s))
|
|
1233
|
+
return true;
|
|
1234
|
+
return false;
|
|
1235
|
+
}
|
|
1038
1236
|
/**
|
|
1039
|
-
* Click / keyboard behaviour
|
|
1040
|
-
*
|
|
1041
|
-
* double-click drills in.
|
|
1237
|
+
* Click / keyboard behaviour of diagram cards: click and Space select,
|
|
1238
|
+
* Enter drills into a container (or selects a leaf), double-click drills in.
|
|
1042
1239
|
*/
|
|
1043
1240
|
#operable(el, s, keys = el) {
|
|
1044
1241
|
el.addEventListener("click", () => this.#select(s));
|
|
1045
1242
|
el.addEventListener("dblclick", () => isContainer(s) && this.#focusOn(s));
|
|
1046
|
-
keys
|
|
1047
|
-
if (e.target !== keys)
|
|
1048
|
-
return; // keys on other buttons inside belong to them
|
|
1049
|
-
if (e.key === "Enter") {
|
|
1050
|
-
e.preventDefault();
|
|
1051
|
-
if (isContainer(s))
|
|
1052
|
-
this.#focusOn(s);
|
|
1053
|
-
else
|
|
1054
|
-
this.#select(s);
|
|
1055
|
-
}
|
|
1056
|
-
else if (e.key === " ") {
|
|
1057
|
-
e.preventDefault();
|
|
1058
|
-
this.#select(s);
|
|
1059
|
-
}
|
|
1060
|
-
});
|
|
1243
|
+
onKeys(keys, (e) => (e.key === "Enter" && isContainer(s) ? this.#focusOn(s) : this.#select(s)));
|
|
1061
1244
|
}
|
|
1062
1245
|
#diagram(children, edges) {
|
|
1063
1246
|
const h = html;
|
|
@@ -1088,7 +1271,7 @@ export class ScxmlExplorer extends ElementBase {
|
|
|
1088
1271
|
column.push(c);
|
|
1089
1272
|
columns[r] = column;
|
|
1090
1273
|
}
|
|
1091
|
-
const diagram = h("div", { class: "diagram", part: "diagram" }, ...columns.filter(Boolean).map((col) => h("div", { class: "rank" }, ...col.map((c) => this.#card(c
|
|
1274
|
+
const diagram = h("div", { class: "diagram", part: "diagram" }, ...columns.filter(Boolean).map((col) => h("div", { class: "rank" }, ...col.map((c) => this.#card(c)))));
|
|
1092
1275
|
this.#diagramEl = diagram;
|
|
1093
1276
|
this.#rank = rank;
|
|
1094
1277
|
return diagram;
|
|
@@ -1149,27 +1332,28 @@ export class ScxmlExplorer extends ElementBase {
|
|
|
1149
1332
|
my = low - drop / 4;
|
|
1150
1333
|
}
|
|
1151
1334
|
const live = isActive(e.from);
|
|
1335
|
+
// the arrow the last step went along
|
|
1336
|
+
const fired = e.transitions.some((x) => this.#fired.has(x));
|
|
1152
1337
|
const p = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
1153
1338
|
p.setAttribute("d", dPath);
|
|
1154
|
-
p.setAttribute("class", `${live ? "live" : ""}${forward ? "" : " back"}`);
|
|
1339
|
+
p.setAttribute("class", `${live ? "live" : ""}${fired ? " fired" : ""}${forward ? "" : " back"}`);
|
|
1155
1340
|
p.setAttribute("marker-end", "url(#x-head)");
|
|
1156
1341
|
svg.append(p);
|
|
1157
1342
|
const text = e.events.length === 1 ? e.events[0] : `${e.events[0]} +${e.events.length - 1}`;
|
|
1158
1343
|
// label size: measured by the browser below; this estimate is only for layouts that can't measure
|
|
1159
|
-
requests.push({ cx: mx, cy: my, w: Math.min(120, 14 + text.length * 6.6), h: 18, edge: e, live });
|
|
1344
|
+
requests.push({ cx: mx, cy: my, w: Math.min(120, 14 + text.length * 6.6), h: 18, edge: e, live, fired });
|
|
1160
1345
|
}
|
|
1161
1346
|
svg.setAttribute("width", String(d.scrollWidth));
|
|
1162
1347
|
svg.setAttribute("height", String(d.scrollHeight + 80));
|
|
1163
1348
|
d.prepend(svg);
|
|
1164
1349
|
const labels = requests.map((r) => {
|
|
1165
1350
|
const e = r.edge;
|
|
1166
|
-
const text = e.events.length === 1 ? e.events[0] : `${e.events[0]} +${e.events.length - 1}`;
|
|
1167
1351
|
const lab = html("span", {
|
|
1168
|
-
class: `edge-label${r.live ? " live" : ""}`,
|
|
1169
|
-
part: parts("edge-label", r.live && "live"),
|
|
1170
|
-
title: e.events.join("\n")
|
|
1352
|
+
class: `edge-label${r.live ? " live" : ""}${r.fired ? " fired" : ""}`,
|
|
1353
|
+
part: parts("edge-label", r.live && "live", r.fired && "fired"),
|
|
1354
|
+
title: `${e.events.join("\n")}${r.fired ? `\n(${this.#strings.justTaken})` : ""}`,
|
|
1171
1355
|
tabindex: "-1",
|
|
1172
|
-
}, html("span", { class: "full" },
|
|
1356
|
+
}, html("span", { class: "full" }, this.#eventName(e.events[0]), e.events.length > 1 ? ` +${e.events.length - 1}` : ""), html("span", { class: "short" }, String(e.events.length)));
|
|
1173
1357
|
d.append(lab);
|
|
1174
1358
|
const measured = lab.getBoundingClientRect();
|
|
1175
1359
|
if (measured.width)
|
|
@@ -1194,7 +1378,7 @@ export class ScxmlExplorer extends ElementBase {
|
|
|
1194
1378
|
});
|
|
1195
1379
|
d.style.paddingBottom = edges.some((e) => (this.#rank.get(e.to) ?? 0) <= (this.#rank.get(e.from) ?? 0)) ? "72px" : "10px";
|
|
1196
1380
|
}
|
|
1197
|
-
#list(children, edges) {
|
|
1381
|
+
#list(children, edges, session) {
|
|
1198
1382
|
const h = html;
|
|
1199
1383
|
const t = this.#strings;
|
|
1200
1384
|
const q = this.#focusFilter.trim().toLowerCase();
|
|
@@ -1207,43 +1391,24 @@ export class ScxmlExplorer extends ElementBase {
|
|
|
1207
1391
|
neighbours.add(e.from);
|
|
1208
1392
|
}
|
|
1209
1393
|
const matches = children.filter((c) => !q || c.node.id.toLowerCase().includes(q));
|
|
1394
|
+
// the order says how near each state is: the active path (headed), then the states one
|
|
1395
|
+
// transition from it, then the rest. No headings for those two: the order is enough
|
|
1210
1396
|
const groups = [
|
|
1211
1397
|
[t.groupActivePath, matches.filter((c) => activeChildren.has(c.node))],
|
|
1212
|
-
[
|
|
1213
|
-
[
|
|
1398
|
+
[undefined, matches.filter((c) => !activeChildren.has(c.node) && neighbours.has(c.node))],
|
|
1399
|
+
[undefined, matches.filter((c) => !activeChildren.has(c.node) && !neighbours.has(c.node))],
|
|
1214
1400
|
];
|
|
1215
|
-
const outgoing = new Map();
|
|
1216
|
-
for (const e of edges) {
|
|
1217
|
-
const list = outgoing.get(e.from) ?? [];
|
|
1218
|
-
list.push(e);
|
|
1219
|
-
outgoing.set(e.from, list);
|
|
1220
|
-
}
|
|
1221
1401
|
let budget = this.#focusShowAll ? Infinity : LIST_PAGE;
|
|
1222
1402
|
const rows = [];
|
|
1223
1403
|
for (const [title, list] of groups) {
|
|
1224
1404
|
if (!list.length)
|
|
1225
1405
|
continue;
|
|
1226
|
-
|
|
1406
|
+
if (title)
|
|
1407
|
+
rows.push(h("div", { class: "list-group", role: "presentation" }, title));
|
|
1227
1408
|
for (const c of list) {
|
|
1228
1409
|
if (budget-- <= 0)
|
|
1229
1410
|
break;
|
|
1230
|
-
|
|
1231
|
-
const outs = outgoing.get(s) ?? [];
|
|
1232
|
-
const rowName = [label(s), t.kind(kindOf(s)), c.onActivePath && t.active].filter(Boolean).join(", ");
|
|
1233
|
-
const select = h("button", { type: "button", class: "name select", "aria-label": rowName }, label(s));
|
|
1234
|
-
const row = h("div", {
|
|
1235
|
-
class: `list-row${c.onActivePath ? " path" : ""}`,
|
|
1236
|
-
part: parts("list-row", c.onActivePath && "path"),
|
|
1237
|
-
"data-state": s.id,
|
|
1238
|
-
role: "group",
|
|
1239
|
-
"aria-label": rowName,
|
|
1240
|
-
}, h("span", { class: "kind", "aria-hidden": "true" }, KIND_ICON[kindOf(s)]), select, h("span", { class: "meta" }, c.onActivePath ? h("span", { class: "badge run" }, t.active) : "", c.descendants
|
|
1241
|
-
? button(`${c.descendants} →`, (e) => this.#drillInto(e, s), { class: "drill", title: t.statesInside(c.descendants) })
|
|
1242
|
-
: ""), outs.length || c.events.length
|
|
1243
|
-
? h("span", { class: "sub" }, ...outs.slice(0, 3).map((e) => h("span", { class: "chip muted", title: e.events.join("\n") }, `→ ${label(e.to)}`)), outs.length > 3 ? h("span", { class: "count" }, t.moreTargets(outs.length - 3)) : "", c.events.length ? h("span", { class: "count" }, `· ${t.events(c.events.length)}`) : "")
|
|
1244
|
-
: "");
|
|
1245
|
-
this.#operable(row, s, select);
|
|
1246
|
-
rows.push(row);
|
|
1411
|
+
rows.push(this.#listRow(c, session));
|
|
1247
1412
|
}
|
|
1248
1413
|
}
|
|
1249
1414
|
const hidden = matches.length - Math.min(matches.length, this.#focusShowAll ? Infinity : LIST_PAGE);
|
|
@@ -1261,16 +1426,105 @@ export class ScxmlExplorer extends ElementBase {
|
|
|
1261
1426
|
this.#renderNow();
|
|
1262
1427
|
this.#el.centerScroll.querySelector('.search input[type="search"]')?.focus();
|
|
1263
1428
|
});
|
|
1264
|
-
return h("div", { class: "search", style: "padding:0 0
|
|
1429
|
+
return h("div", { class: "search", style: "padding:0 0 8px" }, input);
|
|
1265
1430
|
})()
|
|
1266
1431
|
: "";
|
|
1267
1432
|
return h("div", {}, search, rows.length ? h("div", { class: "list", part: "list" }, ...rows) : h("div", { class: "empty", part: "empty" }, t.noStateMatches), hidden > 0
|
|
1268
1433
|
? button(t.showAll(matches.length), () => this.#update(() => (this.#focusShowAll = true)), {
|
|
1269
1434
|
class: "more",
|
|
1270
|
-
style: "margin-top:
|
|
1435
|
+
style: "margin-top:8px",
|
|
1271
1436
|
})
|
|
1272
1437
|
: "");
|
|
1273
1438
|
}
|
|
1439
|
+
/**
|
|
1440
|
+
* One state of the focus list. A leaf answers what it is, what it does and how to leave it:
|
|
1441
|
+
* its entry actions, and its transitions as "event → target" (buttons that send the event
|
|
1442
|
+
* while it's active). Clicking a leaf opens it in place; clicking a container drills in.
|
|
1443
|
+
*/
|
|
1444
|
+
#listRow(c, session) {
|
|
1445
|
+
const h = html;
|
|
1446
|
+
const t = this.#strings;
|
|
1447
|
+
const s = c.node;
|
|
1448
|
+
const leaf = !isContainer(s);
|
|
1449
|
+
const open = leaf && this.#openRows.has(s);
|
|
1450
|
+
const visited = !c.onActivePath && this.#wasVisited(s);
|
|
1451
|
+
const live = c.active && session.status === "running";
|
|
1452
|
+
const rowName = [label(s), t.kind(kindOf(s)), c.onActivePath && t.active, visited && t.lastVisited].filter(Boolean).join(", ");
|
|
1453
|
+
const select = h("button", { type: "button", class: "name select", "aria-label": rowName, ...(leaf ? { "aria-expanded": String(open) } : {}) }, label(s));
|
|
1454
|
+
const txs = s.transitions;
|
|
1455
|
+
const cls = ["list-row", c.onActivePath && "path", c.active && leaf && "active", visited && "visited", open && "open"];
|
|
1456
|
+
const row = h("div", {
|
|
1457
|
+
class: cls.filter(Boolean).join(" "),
|
|
1458
|
+
part: parts("list-row", ...cls.slice(1)),
|
|
1459
|
+
"data-state": s.id,
|
|
1460
|
+
role: "group",
|
|
1461
|
+
"aria-label": rowName,
|
|
1462
|
+
}, h("div", { class: "row-head" }, select, kindMark(s), visited ? h("span", { class: "visited-mark", part: "visited", "aria-hidden": "true" }, t.lastVisited) : "", !open ? (this.#does(s) ?? "") : "", c.descendants ? this.#inside(s, c.descendants) : ""), txs.length
|
|
1463
|
+
? h("div", { class: `exits${open ? " all" : ""}`, part: "row-exits", role: "list", "aria-label": t.transitionsTitle }, ...(open ? txs : txs.slice(0, 3)).map((tr) => this.#txItem(tr, live, open)), !open && txs.length > 3 ? h("span", { class: "count", role: "listitem" }, t.more(txs.length - 3)) : "")
|
|
1464
|
+
: "", open ? this.#rowDetail(s, session) : "");
|
|
1465
|
+
const go = leaf ? () => this.#update(() => (open ? this.#openRows.delete(s) : this.#openRows.add(s))) : () => this.#focusOn(s);
|
|
1466
|
+
// clicks inside the opened part (text, its own buttons) don't close the row
|
|
1467
|
+
row.addEventListener("click", (e) => !e.target.closest?.(".row-detail") && go());
|
|
1468
|
+
onKeys(select, go);
|
|
1469
|
+
return row;
|
|
1470
|
+
}
|
|
1471
|
+
/** "event → target", with a mark for a condition; a button that sends the event when `live`. */
|
|
1472
|
+
#txItem(tr, live, full) {
|
|
1473
|
+
const h = html;
|
|
1474
|
+
const t = this.#strings;
|
|
1475
|
+
const ev = tr.events.join(" ") || t.eventless;
|
|
1476
|
+
const to = tr.targets.map(label).join(", ") || t.stays;
|
|
1477
|
+
const fired = this.#fired.has(tr);
|
|
1478
|
+
const name = live && tr.events.length === 1 ? sendableName(tr.events[0]) : undefined;
|
|
1479
|
+
const attrs = {
|
|
1480
|
+
class: `tx${fired ? " fired" : ""}${tr.events.length ? "" : " auto"}`,
|
|
1481
|
+
part: parts("row-event", fired && "fired"),
|
|
1482
|
+
"data-key": String(tr.order),
|
|
1483
|
+
title: `${ev}${tr.cond ? ` [${tr.cond}]` : ""} → ${to}${fired ? ` · ${t.justTaken}` : ""}`,
|
|
1484
|
+
};
|
|
1485
|
+
const content = [
|
|
1486
|
+
h("span", { class: "ev" }, ...(tr.events.length ? tr.events.flatMap((e, i) => [i ? " " : "", this.#eventName(e)]) : [t.eventless])),
|
|
1487
|
+
tr.cond
|
|
1488
|
+
? full
|
|
1489
|
+
? h("span", { class: "guard" }, glyph(icons.diamond, t.guard(tr.cond), true), tr.cond)
|
|
1490
|
+
: glyph(icons.diamond, t.guard(tr.cond))
|
|
1491
|
+
: "",
|
|
1492
|
+
h("span", { class: "to" }, `→ ${to}`),
|
|
1493
|
+
fired ? srText(`, ${t.justTaken}`) : "",
|
|
1494
|
+
];
|
|
1495
|
+
if (!name)
|
|
1496
|
+
return h("span", { ...attrs, role: "listitem" }, ...content);
|
|
1497
|
+
const b = h("button", { ...attrs, class: `${attrs.class} ev-chip`, type: "button", "aria-label": `${t.sendEvent(name)} → ${to}` }, ...content);
|
|
1498
|
+
b.addEventListener("click", (e) => {
|
|
1499
|
+
e.stopPropagation();
|
|
1500
|
+
this.#send(name);
|
|
1501
|
+
});
|
|
1502
|
+
return h("span", { role: "listitem", class: "tx-item" }, b);
|
|
1503
|
+
}
|
|
1504
|
+
/** The opened part of a leaf row: every action, invoke and way in, and a link to the full detail. */
|
|
1505
|
+
#rowDetail(s, session) {
|
|
1506
|
+
const h = html;
|
|
1507
|
+
const t = this.#strings;
|
|
1508
|
+
const incoming = session.model.states.flatMap((x) => x.transitions.filter((tr) => tr.targets.includes(s)));
|
|
1509
|
+
const sources = [...new Set(incoming.map((tr) => label(tr.source)))];
|
|
1510
|
+
const items = this.#actionItems(s);
|
|
1511
|
+
return h("div", { class: "row-detail", part: "row-detail" }, items.length ? h("ul", { class: "actions" }, ...items) : "", sources.length
|
|
1512
|
+
? h("p", { class: "from" }, h("span", { class: "label" }, t.enteredFrom), ` ${sources.slice(0, 6).join(", ")}${sources.length > 6 ? ` +${sources.length - 6}` : ""}`)
|
|
1513
|
+
: "", button(t.openDetail, (e) => {
|
|
1514
|
+
e.stopPropagation();
|
|
1515
|
+
this.#select(s);
|
|
1516
|
+
}, { class: "drill", part: "open-detail" }));
|
|
1517
|
+
}
|
|
1518
|
+
/** Entry and exit actions, then invokes, as list items. */
|
|
1519
|
+
#actionItems(s) {
|
|
1520
|
+
const t = this.#strings;
|
|
1521
|
+
const actions = (blocks, tag) => blocks.flatMap((b) => Array.from(b.children, (a) => html("li", {}, html("b", {}, tag), describeAction(a))));
|
|
1522
|
+
return [
|
|
1523
|
+
...actions(s.onentry, t.entry),
|
|
1524
|
+
...actions(s.onexit, t.exit),
|
|
1525
|
+
...s.invokes.map((i) => html("li", {}, html("b", {}, i.element.getAttribute("type") ?? "scxml"), i.element.getAttribute("id") ?? i.element.getAttribute("src") ?? t.inline)),
|
|
1526
|
+
];
|
|
1527
|
+
}
|
|
1274
1528
|
#lanes(regions, isActive) {
|
|
1275
1529
|
const h = html;
|
|
1276
1530
|
const t = this.#strings;
|
|
@@ -1282,26 +1536,20 @@ export class ScxmlExplorer extends ElementBase {
|
|
|
1282
1536
|
title: r.node.id,
|
|
1283
1537
|
"aria-label": [label(r.node), r.onActivePath && t.active].filter(Boolean).join(", "),
|
|
1284
1538
|
});
|
|
1285
|
-
|
|
1539
|
+
return h("section", { class: `lane${r.onActivePath ? " path" : ""}`, part: parts("lane", r.onActivePath && "path"), "data-state": r.node.id }, h("div", { class: "lane-head" }, name, kindMark(r.node)), ...kids.slice(0, PER_LANE).map((k) => {
|
|
1286
1540
|
const on = isActive(k);
|
|
1541
|
+
const visited = !on && this.#wasVisited(k);
|
|
1287
1542
|
const row = h("div", {
|
|
1288
|
-
class: `lane-row${on ? " active" : ""}`,
|
|
1289
|
-
part: parts("lane-row", on && "active"),
|
|
1543
|
+
class: `lane-row${on ? " active" : ""}${visited ? " visited" : ""}`,
|
|
1544
|
+
part: parts("lane-row", on && "active", visited && "visited"),
|
|
1290
1545
|
role: "button",
|
|
1291
1546
|
tabindex: "0",
|
|
1292
|
-
"aria-label": [label(k), t.kind(kindOf(k)), on && t.active].filter(Boolean).join(", "),
|
|
1293
|
-
}, h("span", { class: "
|
|
1294
|
-
? h("span", {
|
|
1295
|
-
class: "dot",
|
|
1296
|
-
"aria-hidden": "true",
|
|
1297
|
-
style: "width:7px;height:7px;border-radius:50%;background:var(--x-run)",
|
|
1298
|
-
})
|
|
1299
|
-
: "");
|
|
1547
|
+
"aria-label": [label(k), t.kind(kindOf(k)), on && t.active, visited && t.lastVisited].filter(Boolean).join(", "),
|
|
1548
|
+
}, h("span", { class: "name" }, label(k)), kindMark(k));
|
|
1300
1549
|
// containers open as the focus, leaves are selected
|
|
1301
1550
|
activate(row, () => (isContainer(k) ? this.#focusOn(k) : this.#select(k)));
|
|
1302
1551
|
return row;
|
|
1303
1552
|
}), kids.length > PER_LANE ? button(t.openLane(kids.length - PER_LANE), () => this.#focusOn(r.node), { class: "more" }) : "");
|
|
1304
|
-
return lane;
|
|
1305
1553
|
}));
|
|
1306
1554
|
}
|
|
1307
1555
|
// ── system ──
|
|
@@ -1336,10 +1584,12 @@ export class ScxmlExplorer extends ElementBase {
|
|
|
1336
1584
|
title: [m.invokeid && tr.invokedAs(m.invokeid, m.invokedFrom), talk.length && tr.talksTo(talk.join(", "))]
|
|
1337
1585
|
.filter(Boolean)
|
|
1338
1586
|
.join("\n"),
|
|
1339
|
-
},
|
|
1587
|
+
},
|
|
1588
|
+
// running is the normal case: only other statuses are spelled out
|
|
1589
|
+
h("div", { class: "card-head" }, h("span", { class: "name" }, m.name), m.status === "running" ? "" : h("span", { class: "status" }, statusText)), m.activeLeaves.length
|
|
1340
1590
|
? h("div", { class: "leaves", title: m.activeLeaves.join(", ") }, m.activeLeaves.slice(0, compact ? 1 : 3).join(" · ") +
|
|
1341
1591
|
(m.activeLeaves.length > (compact ? 1 : 3) ? ` +${m.activeLeaves.length - (compact ? 1 : 3)}` : ""))
|
|
1342
|
-
: "", !compact && m.invokeid ? h("div", { class: "from" }, tr.invokedAs(m.invokeid, m.invokedFrom)) : ""
|
|
1592
|
+
: "", !compact && m.invokeid ? h("div", { class: "from" }, tr.invokedAs(m.invokeid, m.invokedFrom)) : "");
|
|
1343
1593
|
activate(card, () => this.#navigate(() => {
|
|
1344
1594
|
this.#setLevel("machine");
|
|
1345
1595
|
this.#openMachine(m.key);
|
|
@@ -1366,7 +1616,8 @@ export class ScxmlExplorer extends ElementBase {
|
|
|
1366
1616
|
tabindex: "0",
|
|
1367
1617
|
"aria-pressed": String(selected),
|
|
1368
1618
|
"aria-label": `${svc.label}, ${tr.traffic(out, inn)}`,
|
|
1369
|
-
|
|
1619
|
+
title: `${svc.key}\n${tr.trafficHint}: ${out} / ${inn}`,
|
|
1620
|
+
}, h("div", { class: "card-head" }, h("span", { class: "name" }, svc.label), out + inn ? h("span", { class: "status" }, tr.traffic(out, inn)) : ""), h("slot", { name: `service:${svc.label}` }));
|
|
1370
1621
|
activate(card, () => {
|
|
1371
1622
|
this.#selectedService = svc.key;
|
|
1372
1623
|
this.#inspector = "detail";
|
|
@@ -1390,7 +1641,7 @@ export class ScxmlExplorer extends ElementBase {
|
|
|
1390
1641
|
return h("div", { class: "search", style: "padding:0" }, input);
|
|
1391
1642
|
})()
|
|
1392
1643
|
: "";
|
|
1393
|
-
const sys = h("div", { class: "system", part: "system" }, h("div", { class: "col" }, h("div", { class: "col-title" }, tr.machines
|
|
1644
|
+
const sys = h("div", { class: "system", part: "system" }, h("div", { class: "col" }, h("div", { class: "col-title" }, tr.machines), filter, ...shownMachines.map(machineCard)), h("div", { class: "col" }, h("div", { class: "col-title" }, tr.services), ...services.map(serviceCard)));
|
|
1394
1645
|
const out = this.#el.centerScroll;
|
|
1395
1646
|
const scroll = out.scrollTop;
|
|
1396
1647
|
out.replaceChildren(h("h2", { class: "title", part: "title" }, tr.system), h("p", { class: "subtitle" }, tr.systemSummary(machines.length, services.length, [...t.links.values()].reduce((n, l) => n + total(l), 0))), sys);
|
|
@@ -1400,7 +1651,7 @@ export class ScxmlExplorer extends ElementBase {
|
|
|
1400
1651
|
const layoutKey = JSON.stringify([
|
|
1401
1652
|
compact,
|
|
1402
1653
|
q,
|
|
1403
|
-
shownMachines.map((m) => [m.key, m.activeLeaves.length > 0, !compact && !!m.invokeid
|
|
1654
|
+
shownMachines.map((m) => [m.key, m.activeLeaves.length > 0, !compact && !!m.invokeid]),
|
|
1404
1655
|
services.map((svc) => svc.key),
|
|
1405
1656
|
[...t.links.values()].map((l) => `${l.from}>${l.to}:${l.kind}`),
|
|
1406
1657
|
]);
|
|
@@ -1450,7 +1701,7 @@ export class ScxmlExplorer extends ElementBase {
|
|
|
1450
1701
|
p.setAttribute("class", "invoke");
|
|
1451
1702
|
}
|
|
1452
1703
|
else {
|
|
1453
|
-
// machine ↔ machine messages: the invoke line and the cards'
|
|
1704
|
+
// machine ↔ machine messages: the invoke line (and the cards' tooltips) already say it
|
|
1454
1705
|
if (!this.#tracker.services.has(l.to) && !this.#tracker.services.has(l.from))
|
|
1455
1706
|
continue;
|
|
1456
1707
|
const [m, svc] = this.#tracker.services.has(l.to) ? [a, b] : [b, a];
|
|
@@ -1483,22 +1734,30 @@ export class ScxmlExplorer extends ElementBase {
|
|
|
1483
1734
|
inherited: all.filter((e) => e.scope !== "elsewhere").length,
|
|
1484
1735
|
all: all.length,
|
|
1485
1736
|
};
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1737
|
+
// the System level has services to inspect, not a machine's accepted events
|
|
1738
|
+
const system = this.#level === "system";
|
|
1739
|
+
const which = system ? "detail" : this.#inspector;
|
|
1740
|
+
this.#el.inspectorSwitch.replaceChildren(...(system
|
|
1741
|
+
? [h("span", { class: "pane-title" }, t.serviceTab)]
|
|
1742
|
+
: [
|
|
1743
|
+
button(t.accepts(counts.inherited), () => this.#showInspector("events"), { "aria-pressed": String(which === "events") }),
|
|
1744
|
+
button(t.stateTab, () => this.#showInspector("detail"), { "aria-pressed": String(which === "detail") }),
|
|
1745
|
+
]));
|
|
1746
|
+
this.#el.eventsHead.style.display = which === "events" ? "" : "none";
|
|
1747
|
+
// a scope that adds nothing to the one before it is left out; with only one left, the switch is
|
|
1748
|
+
const scopes = [
|
|
1749
|
+
["here", counts.here, t.scopeHere],
|
|
1750
|
+
["inherited", counts.inherited, t.scopeInherited],
|
|
1751
|
+
["all", counts.all, t.scopeAll],
|
|
1752
|
+
].filter(([, n], i, list) => i === 0 || n !== list[i - 1][1]);
|
|
1753
|
+
this.#el.scopes.hidden = scopes.length < 2;
|
|
1754
|
+
const current = counts[this.#eventScope];
|
|
1755
|
+
this.#el.scopes.replaceChildren(...scopes.map(([k, n, text]) => button(text(n), () => this.#update(() => (this.#eventScope = k)), { "aria-pressed": String(n === current) })));
|
|
1497
1756
|
const body = this.#el.inspectorBody;
|
|
1498
1757
|
const scroll = body.scrollTop;
|
|
1499
|
-
if (
|
|
1758
|
+
if (which === "events")
|
|
1500
1759
|
body.replaceChildren(this.#eventsList(all));
|
|
1501
|
-
else if (
|
|
1760
|
+
else if (system)
|
|
1502
1761
|
body.replaceChildren(this.#serviceDetail());
|
|
1503
1762
|
else
|
|
1504
1763
|
body.replaceChildren(this.#stateDetail(this.#selected ?? focus, session));
|
|
@@ -1508,11 +1767,11 @@ export class ScxmlExplorer extends ElementBase {
|
|
|
1508
1767
|
this.#el.strip.replaceChildren(...strip.slice(0, 8).map((e) => {
|
|
1509
1768
|
const name = sendableName(e.descriptor);
|
|
1510
1769
|
const c = h("button", {
|
|
1511
|
-
class: `chip${name ? "" : " muted"}`,
|
|
1770
|
+
class: `chip ev-chip${name ? "" : " muted"}`,
|
|
1512
1771
|
type: "button",
|
|
1513
1772
|
title: e.transitions.map((x) => `${label(x.source)} → ${x.targets.map(label).join(" ") || t.internal}`).join("\n"),
|
|
1514
1773
|
...(name ? { "aria-label": t.sendEvent(name) } : { disabled: "" }),
|
|
1515
|
-
}, e.descriptor);
|
|
1774
|
+
}, this.#eventName(e.descriptor));
|
|
1516
1775
|
if (name)
|
|
1517
1776
|
c.addEventListener("click", () => this.#send(name));
|
|
1518
1777
|
return c;
|
|
@@ -1542,28 +1801,52 @@ export class ScxmlExplorer extends ElementBase {
|
|
|
1542
1801
|
const t = this.#strings;
|
|
1543
1802
|
const x = e.transitions[0];
|
|
1544
1803
|
const name = sendableName(e.descriptor);
|
|
1545
|
-
|
|
1546
|
-
|
|
1804
|
+
// the event's name is its send button
|
|
1805
|
+
const send = button("", () => name && this.#send(name), {
|
|
1806
|
+
class: "ev send ev-chip",
|
|
1547
1807
|
part: "send",
|
|
1548
1808
|
title: name ? t.sendEvent(name) : t.cannotSendWildcard,
|
|
1549
1809
|
"aria-label": name ? t.sendEvent(name) : `${e.descriptor}: ${t.cannotSendWildcard}`,
|
|
1550
1810
|
});
|
|
1811
|
+
send.append(this.#eventName(e.descriptor));
|
|
1551
1812
|
if (!name)
|
|
1552
1813
|
send.setAttribute("disabled", "");
|
|
1553
|
-
return h("div", { class: `ev-row scope-${e.scope}`, part: parts("event-row", e.scope) },
|
|
1814
|
+
return h("div", { class: `ev-row scope-${e.scope}`, part: parts("event-row", e.scope) }, send, h("span", {
|
|
1554
1815
|
class: "how",
|
|
1555
1816
|
title: e.transitions
|
|
1556
1817
|
.map((y) => `${label(y.source)}${y.guarded ? ` [${y.transition.cond}]` : ""} → ${y.targets.map(label).join(" ") || t.internal}`)
|
|
1557
1818
|
.join("\n"),
|
|
1558
|
-
},
|
|
1819
|
+
}, `${label(x.source)} `, x.guarded ? glyph(icons.diamond, t.guard(x.transition.cond ?? "")) : "", ` → ${x.targets.map(label).join(", ") || t.stays}`, e.transitions.length > 1 ? ` · +${e.transitions.length - 1}` : "",
|
|
1559
1820
|
// the scope in words, not only the colour of the event name
|
|
1560
|
-
e.scope !== "here" ?
|
|
1821
|
+
e.scope !== "here" ? " · " : "", e.scope !== "here" ? h("span", { class: "scope-tag" }, e.scope === "inherited" ? t.inherited : t.elsewhere) : ""), h("slot", { name: `event:${e.descriptor}` }));
|
|
1561
1822
|
}
|
|
1562
1823
|
#sendDescriptor(descriptor) {
|
|
1563
1824
|
const name = sendableName(descriptor);
|
|
1564
1825
|
if (name)
|
|
1565
1826
|
this.#send(name);
|
|
1566
1827
|
}
|
|
1828
|
+
/** An event's name, as written: the namespace quieter, its kind as the state colours. */
|
|
1829
|
+
#eventName(descriptor) {
|
|
1830
|
+
return eventName(descriptor);
|
|
1831
|
+
}
|
|
1832
|
+
/** What a state does on entry / exit and what it invokes, as glyphs. */
|
|
1833
|
+
#does(s) {
|
|
1834
|
+
const t = this.#strings;
|
|
1835
|
+
const el = actionGlyphs(s, { onEntry: t.onEntry, onExit: t.onExit, invokes: t.invokesGlyph, sends: t.sendsGlyph, logs: t.logsGlyph }, describeAction);
|
|
1836
|
+
el?.setAttribute("part", "row-actions");
|
|
1837
|
+
return el;
|
|
1838
|
+
}
|
|
1839
|
+
/** A container's size: the layers glyph and its number of states; the button that goes inside. */
|
|
1840
|
+
#inside(s, n) {
|
|
1841
|
+
const t = this.#strings;
|
|
1842
|
+
const b = button("", (e) => this.#drillInto(e, s), {
|
|
1843
|
+
class: "drill inside",
|
|
1844
|
+
title: t.statesInside(n),
|
|
1845
|
+
"aria-label": t.statesInside(n),
|
|
1846
|
+
});
|
|
1847
|
+
b.append(glyph(icons.layers, t.statesInside(n), true), html("span", { class: "n" }, String(n)));
|
|
1848
|
+
return b;
|
|
1849
|
+
}
|
|
1567
1850
|
#send(name) {
|
|
1568
1851
|
const machine = this.#machine;
|
|
1569
1852
|
const session = machine?.session;
|
|
@@ -1594,12 +1877,11 @@ export class ScxmlExplorer extends ElementBase {
|
|
|
1594
1877
|
const t = this.#strings;
|
|
1595
1878
|
const TX_PAGE = 30;
|
|
1596
1879
|
const incoming = session.model.states.flatMap((x) => x.transitions.filter((tr) => tr.targets.includes(s)));
|
|
1597
|
-
const actions = (blocks, tag) => blocks.flatMap((b) => Array.from(b.children).map((a) => h("li", {}, h("b", {}, tag), describeAction(a))));
|
|
1598
1880
|
const kv = (k, v) => [h("dt", {}, k), h("dd", {}, v)];
|
|
1599
1881
|
const txRows = s.transitions
|
|
1600
1882
|
.slice(0, TX_PAGE)
|
|
1601
1883
|
.map((tr) => h("tr", {}, h("td", { class: "ev" }, tr.events.join(" ") || "ε"), h("td", { class: "cond" }, tr.cond ?? ""), h("td", { class: "to" }, tr.targets.length ? tr.targets.map(label).join(", ") : tr.type === "internal" ? t.internal : `(${t.stays})`)));
|
|
1602
|
-
return h("div", { class: "detail", part: "detail" }, h("h2", { class: "title
|
|
1884
|
+
return h("div", { class: "detail", part: "detail" }, h("h2", { class: "title small" }, label(s)), h("p", { class: "subtitle" }, pathTo(s).slice(1, -1).map(label).join(" › ") || t.topLevel, session.isActiveNode(s) ? h("span", { class: "status active" }, t.active) : ""), h("dl", { class: "kv" }, ...kv(t.detailKind, t.kind(kindOf(s))), ...kv(t.detailId, s.id), ...(s.children.length ? kv(t.detailStates, t.directAndInside(s.children.length, descendantCount(s))) : []), ...(s.initial?.targets.length ? kv(t.detailInitial, s.initial.targets.map(label).join(", ")) : []), ...(s.historyType ? kv(t.detailHistory, s.historyType) : []), ...(s.data.length ? kv(t.detailData, s.data.map((d) => d.getAttribute("id")).join(", ")) : [])), isContainer(s) && s !== this.#focus
|
|
1603
1885
|
? button(t.focusState(label(s)), () => this.#focusOn(s), { class: "drill", style: "margin-top:8px" })
|
|
1604
1886
|
: "",
|
|
1605
1887
|
// authoring warnings about this state (model.warnings): likely mistakes that are still valid SCXML
|
|
@@ -1610,14 +1892,12 @@ export class ScxmlExplorer extends ElementBase {
|
|
|
1610
1892
|
return [
|
|
1611
1893
|
h("div", {}, h("div", { class: "section-title" }, t.warningsTitle, h("span", { class: "count" }, String(warnings.length))), h("ul", { class: "warnings" }, ...warnings.map((w) => h("li", { part: "warning", "data-code": w.code }, w.message)))),
|
|
1612
1894
|
];
|
|
1613
|
-
})(), s.onentry.length || s.onexit.length
|
|
1614
|
-
? h("div", {}, h("div", { class: "section-title" }, t.actions), h("ul", { class: "actions" }, ...
|
|
1615
|
-
: "", s.invokes.length
|
|
1616
|
-
? h("div", {}, h("div", { class: "section-title" }, t.invokesTitle), h("ul", { class: "actions" }, ...s.invokes.map((i) => h("li", {}, h("b", {}, i.element.getAttribute("type") ?? "scxml"), i.element.getAttribute("id") ?? i.element.getAttribute("src") ?? t.inline))))
|
|
1895
|
+
})(), s.onentry.length || s.onexit.length || s.invokes.length
|
|
1896
|
+
? h("div", {}, h("div", { class: "section-title" }, t.actions), h("ul", { class: "actions" }, ...this.#actionItems(s)))
|
|
1617
1897
|
: "", s.transitions.length
|
|
1618
|
-
? h("div", {}, h("div", { class: "section-title" }, t.transitionsTitle
|
|
1898
|
+
? h("div", {}, h("div", { class: "section-title" }, t.transitionsTitle), h("table", { class: "tx" }, h("thead", {}, h("tr", {}, h("th", { scope: "col" }, t.columnEvent), h("th", { scope: "col" }, t.columnIf), h("th", { scope: "col" }, t.columnTo))), h("tbody", {}, ...txRows)), s.transitions.length > TX_PAGE ? h("p", { class: "count" }, t.more(s.transitions.length - TX_PAGE)) : "")
|
|
1619
1899
|
: "", incoming.length
|
|
1620
|
-
? h("div", {}, h("div", { class: "section-title" }, t.enteredFrom
|
|
1900
|
+
? h("div", {}, h("div", { class: "section-title" }, t.enteredFrom), h("div", { class: "talks" }, ...incoming.slice(0, 12).map((tr) => {
|
|
1621
1901
|
const c = h("button", { class: "chip", type: "button", title: tr.events.join(" ") || "ε" }, `${label(tr.source)} ${tr.events[0] ? `(${tr.events[0]})` : ""}`);
|
|
1622
1902
|
c.addEventListener("click", () => this.#focusOn(tr.source));
|
|
1623
1903
|
return c;
|
|
@@ -1634,7 +1914,7 @@ export class ScxmlExplorer extends ElementBase {
|
|
|
1634
1914
|
return h("div", { class: "empty", part: "empty" }, h("slot", { name: "empty-detail" }, tr.selectService));
|
|
1635
1915
|
const traffic = svc.processor.traffic;
|
|
1636
1916
|
const links = t.linksOf(svc.key);
|
|
1637
|
-
return h("div", { class: "detail", part: "detail" }, h("h2", { class: "title
|
|
1917
|
+
return h("div", { class: "detail", part: "detail" }, h("h2", { class: "title small" }, svc.label), h("p", { class: "subtitle" }, svc.key), h("div", { class: "section-title" }, tr.talksWith), h("ul", { class: "actions" }, ...links.map((l) => {
|
|
1638
1918
|
const other = l.from === svc.key ? l.to : l.from;
|
|
1639
1919
|
const events = [...l.observed].sort((a, b) => b[1] - a[1]);
|
|
1640
1920
|
return h("li", {}, h("b", {}, l.from === svc.key ? "→" : "←"), `${t.machines.get(other)?.name ?? other}: `, events
|
|
@@ -1648,49 +1928,48 @@ export class ScxmlExplorer extends ElementBase {
|
|
|
1648
1928
|
.map((x) => h("li", {}, h("span", { class: "dir", "aria-hidden": "true" }, x.direction === "out" ? "↗" : "↙"), `${x.event} · ${t.machines.get(x.sessionId)?.name ?? x.sessionId}`))))
|
|
1649
1929
|
: "");
|
|
1650
1930
|
}
|
|
1651
|
-
// ──
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
const
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
this.#el.tabs.replaceChildren(...tabs.map(([t, text]) => button(text, () => {
|
|
1671
|
-
this.#tab = t;
|
|
1672
|
-
if (t === "system")
|
|
1673
|
-
this.#level = "system";
|
|
1674
|
-
if (t === "focus")
|
|
1675
|
-
this.#level = "machine";
|
|
1676
|
-
if (t === "events" || t === "detail")
|
|
1677
|
-
this.#inspector = t;
|
|
1678
|
-
this.#renderNow();
|
|
1679
|
-
}, { role: "tab", part: parts("tab", this.#tab === t && "selected"), "aria-selected": String(this.#tab === t) })));
|
|
1931
|
+
// ── panels ──
|
|
1932
|
+
/** Which page the single panel shows, the sheet's height, and the links between the pages. */
|
|
1933
|
+
#renderPanels(m) {
|
|
1934
|
+
const t = this.#strings;
|
|
1935
|
+
const { shell, back, toInspector, handle, panel } = this.#el;
|
|
1936
|
+
const system = this.#level === "system";
|
|
1937
|
+
// the System level has no tree: its panel is the inspector (services)
|
|
1938
|
+
const page = system ? "inspector" : this.#page;
|
|
1939
|
+
shell.dataset.page = page;
|
|
1940
|
+
shell.dataset.sheet = this.#sheet;
|
|
1941
|
+
back.hidden = system;
|
|
1942
|
+
const session = m.session;
|
|
1943
|
+
const accepted = session.status === "running" ? acceptedEvents(session, this.#focus).filter((e) => e.scope !== "elsewhere").length : 0;
|
|
1944
|
+
toInspector.textContent = `${t.accepts(accepted)} ›`;
|
|
1945
|
+
const open = this.#sheet !== "low";
|
|
1946
|
+
handle.setAttribute("aria-expanded", String(open));
|
|
1947
|
+
handle.setAttribute("aria-label", this.#sheet === "full" ? t.sheetCollapse : t.sheetExpand);
|
|
1948
|
+
handle.title = handle.getAttribute("aria-label");
|
|
1949
|
+
this.#syncSheetHeight(panel);
|
|
1680
1950
|
}
|
|
1681
1951
|
}
|
|
1682
1952
|
// ───────────────────────────────── helpers ─────────────────────────────────
|
|
1683
|
-
const explorerSheet = lazySheet(EXPLORER_CSS);
|
|
1953
|
+
const explorerSheet = lazySheet(EXPLORER_CSS + NOTATION_CSS);
|
|
1684
1954
|
/** Make a focusable element behave like a button: click, Enter and Space all run `fn`. */
|
|
1685
1955
|
function activate(el, fn) {
|
|
1686
1956
|
el.addEventListener("click", fn);
|
|
1957
|
+
onKeys(el, fn);
|
|
1958
|
+
}
|
|
1959
|
+
/** Enter and Space on `el` itself (not on controls inside it) run `fn` instead of its default. */
|
|
1960
|
+
function onKeys(el, fn) {
|
|
1687
1961
|
el.addEventListener("keydown", (e) => {
|
|
1688
1962
|
if (e.target !== el || (e.key !== "Enter" && e.key !== " "))
|
|
1689
1963
|
return;
|
|
1690
1964
|
e.preventDefault();
|
|
1691
|
-
fn();
|
|
1965
|
+
fn(e);
|
|
1692
1966
|
});
|
|
1693
1967
|
}
|
|
1968
|
+
/** The mark of a parallel, final or history state; screen readers get the kind from the row's name. */
|
|
1969
|
+
function kindMark(s) {
|
|
1970
|
+
const mark = KIND_MARK[kindOf(s)];
|
|
1971
|
+
return mark ? html("span", { class: "kind", "aria-hidden": "true" }, mark) : "";
|
|
1972
|
+
}
|
|
1694
1973
|
/** Text only screen readers see: status in words where the screen shows colour or shape. */
|
|
1695
1974
|
function srText(text) {
|
|
1696
1975
|
return html("span", { class: "sr-only" }, text);
|
|
@@ -1720,24 +1999,6 @@ function button(text, onClick, attrs = {}) {
|
|
|
1720
1999
|
b.addEventListener("click", onClick);
|
|
1721
2000
|
return b;
|
|
1722
2001
|
}
|
|
1723
|
-
/** Event chips with an overflow counter: never more than `max` visible. */
|
|
1724
|
-
function chips(events, max, onClick, muted = false) {
|
|
1725
|
-
const out = events.slice(0, max).map((ev) => {
|
|
1726
|
-
// muted chips are labels, not controls (they sit inside other controls)
|
|
1727
|
-
const c = muted
|
|
1728
|
-
? html("span", { class: "chip muted", title: ev }, ev)
|
|
1729
|
-
: html("button", { class: "chip", type: "button", title: ev }, ev);
|
|
1730
|
-
if (!muted)
|
|
1731
|
-
c.addEventListener("click", (e) => {
|
|
1732
|
-
e.stopPropagation();
|
|
1733
|
-
onClick(ev);
|
|
1734
|
-
});
|
|
1735
|
-
return c;
|
|
1736
|
-
});
|
|
1737
|
-
if (events.length > max)
|
|
1738
|
-
out.push(html("span", { class: "count", title: events.slice(max).join("\n") }, `+${events.length - max}`));
|
|
1739
|
-
return out;
|
|
1740
|
-
}
|
|
1741
2002
|
/** Number of layers the diagram would need (longest shortest-path from the initial child, +1 for unreachable ones). */
|
|
1742
2003
|
function estimateRanks(children, edges) {
|
|
1743
2004
|
const rank = new Map();
|