@popcorn245/cornfield 0.49.0 → 0.50.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/explorer/css/review.css +49 -0
- package/explorer/decision-model.js +6 -0
- package/explorer/engine/layout.js +8 -3
- package/explorer/engine/sheets.js +40 -7
- package/explorer/engine/topology.js +126 -0
- package/explorer/focus-room.js +1 -7
- package/explorer/focusables.js +1 -1
- package/explorer/forge-panel.js +36 -2630
- package/explorer/index.html +15 -147
- package/explorer/instance-state.js +0 -7
- package/explorer/instance.js +21 -2
- package/explorer/page-pieces.js +21 -2
- package/explorer/page.js +3 -3
- package/explorer/panels.js +1 -5
- package/explorer/pieces/changes.js +2 -9
- package/explorer/pieces/decision.js +10 -3
- package/explorer/pieces/layers.js +1 -0
- package/explorer/pieces/map.js +4 -23
- package/explorer/pieces/node-panel.js +15 -5
- package/explorer/pieces/proposal.js +9 -0
- package/explorer/pieces/review.js +280 -0
- package/explorer/pieces/work-agent.js +211 -0
- package/explorer/pieces/work-common.js +88 -0
- package/explorer/pieces/work-confirm.js +169 -0
- package/explorer/pieces/work-data.js +178 -0
- package/explorer/pieces/work-deploys.js +104 -0
- package/explorer/pieces/work-events.js +285 -0
- package/explorer/pieces/work-issues.js +43 -0
- package/explorer/pieces/work-markup.js +155 -0
- package/explorer/pieces/work-notes.js +177 -0
- package/explorer/pieces/work-paint.js +312 -0
- package/explorer/pieces/work-prs.js +253 -0
- package/explorer/pieces/work-runs.js +387 -0
- package/explorer/pieces/work-specs.js +71 -0
- package/explorer/pieces/work-threads.js +309 -0
- package/explorer/pieces/work.js +285 -0
- package/explorer/proposal.js +1 -2
- package/explorer/runs-map.js +108 -103
- package/explorer/runs-view.js +8 -6
- package/explorer/strings.js +1 -1
- package/explorer/view.js +6 -59
- package/explorer/waiting-model.js +12 -12
- package/explorer/waiting-view.js +6 -6
- package/package.json +1 -1
- package/explorer/feedback.js +0 -15
- package/explorer/waiting-line.js +0 -14
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* review.css: the review's own layout
|
|
3
|
+
* What only the one-tag review (explorer/pieces/review.js, `<corn-review>`) needs, and cornfield's page does not load: the box the whole review lives in,
|
|
4
|
+
* and the stage inside it that cornfield's page has in page.css. Every other rule the review reads is the pieces' own file (base, map, node-panel, proposal,
|
|
5
|
+
* changes, decision, sheets: review.js `STYLESHEETS` lists them in order, this one last).
|
|
6
|
+
* No rule here asks what the document says (`:root`, `html`, `body`, `[data-theme]`), sizes from the window (`vw`, `vh`) or is `position: fixed` unless it says why;
|
|
7
|
+
* a width rule is a container query on `corn-box` (the review's box), a height rule on `corn-page`. base.css loads first.
|
|
8
|
+
*/
|
|
9
|
+
/* The box: where the review lives in a host's page. It fills the host (which gives it a height) and is never under 24rem, so a review dropped in with no
|
|
10
|
+
height is visible. It is the query container every piece's width and height rule asks (`corn-box`: its width, `corn-page`: its height), as the body is
|
|
11
|
+
on cornfield's page. `contain: layout` makes it the containing block of its own `position: fixed` descendants (a phone's tap-away behind the node panel,
|
|
12
|
+
the modal scrims) and a stacking context, so nothing in it is placed against the window or above the host's own layers. `all: initial` first: the host's
|
|
13
|
+
font, line height, colour and text settings stop here, as the page's body sets them for the page. */
|
|
14
|
+
[data-corn="review"] {
|
|
15
|
+
all: initial;
|
|
16
|
+
position: relative;
|
|
17
|
+
display: flex;
|
|
18
|
+
flex-direction: column;
|
|
19
|
+
box-sizing: border-box;
|
|
20
|
+
width: 100%;
|
|
21
|
+
height: 100%;
|
|
22
|
+
min-height: 24rem;
|
|
23
|
+
overflow: hidden;
|
|
24
|
+
container: corn-box corn-page / size;
|
|
25
|
+
contain: layout;
|
|
26
|
+
background-color: var(--corn-ground);
|
|
27
|
+
background-image: var(--corn-ground-image);
|
|
28
|
+
color: var(--corn-text);
|
|
29
|
+
font-family: var(--corn-font);
|
|
30
|
+
-webkit-font-smoothing: antialiased;
|
|
31
|
+
user-select: none;
|
|
32
|
+
}
|
|
33
|
+
/* The stage: the map and what lies over it (page.css has it for the page, with the same rules as media queries: here the box is as wide as the review) */
|
|
34
|
+
.hx-stage { position: relative; flex: 1; width: 100%; min-height: 0; overflow: hidden; }
|
|
35
|
+
/* The scenario player is one bar under the map, to the right of the review column: the stage tells it how wide the column is (page.css, as container queries) */
|
|
36
|
+
@container corn-box (min-width: 768px) {
|
|
37
|
+
.hx-stage:has(.hx-review-column:not([hidden])) { --hx-col-w: 400px; }
|
|
38
|
+
}
|
|
39
|
+
@container corn-box (min-width: 768px) and (max-width: 1023px) {
|
|
40
|
+
.hx-stage:has(.hx-review-column:not([hidden])) { --hx-col-w: 320px; }
|
|
41
|
+
}
|
|
42
|
+
/* A topology with no nodes: the words in the middle of the stage, over the empty map */
|
|
43
|
+
.hx-review-empty { position: absolute; inset: 0; z-index: 1; display: flex; align-items: center; justify-content: center; margin: 0; padding: var(--corn-space-5); text-align: center; color: var(--corn-text-2); font-size: var(--corn-text-md); pointer-events: none; }
|
|
44
|
+
/* No header above the map and no hint on it: the bar sits at the top of the stage */
|
|
45
|
+
.hx-proposal-bar { top: 12px; }
|
|
46
|
+
/* A host's own rules on bare elements reach in (no shadow root: the host's CSS reaches each piece directly, spec 0011 D7); these are the few the pieces never
|
|
47
|
+
set, so they cannot be told apart from the host's: a border drawn round every canvas, an indent on every paragraph */
|
|
48
|
+
[data-corn="review"] canvas { border: 0; }
|
|
49
|
+
[data-corn="review"] :is(p, h1, h2, h3, h4) { text-indent: 0; font-variant: normal; }
|
|
@@ -131,6 +131,12 @@ export function askWords(reasons, verb = 'Approve') {
|
|
|
131
131
|
/** The reasons that ask now and the maintainer has not answered yet (`answered`: the keys confirmed with "Approve anyway"): at the end of the hold, only a new one asks again */
|
|
132
132
|
export const newReasons = (reasons, answered) => reasons.filter((r) => !answered.includes(r.key));
|
|
133
133
|
|
|
134
|
+
/**
|
|
135
|
+
* What the foot says, in place of Approve and Send back, for a proposal that names nothing to decide on: one a host handed in as an object with no
|
|
136
|
+
* cornfield server to send a review to (pieces/review.js with no `base`). Cornfield's own page always names its proposal, so it never says this.
|
|
137
|
+
*/
|
|
138
|
+
export const NOTHING_TO_DECIDE = 'Shown to read only: there is no cornfield server here to send an approval or a send back to.';
|
|
139
|
+
|
|
134
140
|
/**
|
|
135
141
|
* The line above Approve and what a press of it does, from the facts and the page's own state.
|
|
136
142
|
* @param {object} input
|
|
@@ -59,6 +59,9 @@ export function labelWidth(inst, node) {
|
|
|
59
59
|
const DATA_TYPES = ['store', 'table', 'rom'];
|
|
60
60
|
const CHILD_TYPE_ORDER = ['core', 'atom', 'molecule', 'token', 'page', 'service', 'external', 'stack', 'table', 'store', 'tool', 'app', 'pkg'];
|
|
61
61
|
|
|
62
|
+
/** How deep packTree nests a cluster's own clusters (a real map nests a few levels) */
|
|
63
|
+
const PACK_DEPTH = 64;
|
|
64
|
+
|
|
62
65
|
/** Concentric rings of `items` around (0, 0): returns the offsets and the radii used */
|
|
63
66
|
function ringPack(items, { first = 110, gap = 76, spacing = 90 } = {}) {
|
|
64
67
|
const offsets = [];
|
|
@@ -90,14 +93,16 @@ function ringPack(items, { first = 110, gap = 76, spacing = 90 } = {}) {
|
|
|
90
93
|
* `kidsOf(node)` says who hangs under a node. Returns `{ children, offsets, radii, subs, extent }`: `subs[i]` is the
|
|
91
94
|
* child i's own pack (or null), `extent` how far the whole thing reaches from the centre.
|
|
92
95
|
*/
|
|
93
|
-
function packTree(children, kidsOf, spacingOf, byOrder, seen = new Set()) {
|
|
96
|
+
function packTree(children, kidsOf, spacingOf, byOrder, seen = new Set(), depth = 0) {
|
|
94
97
|
const withSub = [];
|
|
95
98
|
const plain = [];
|
|
96
99
|
children.forEach((c) => {
|
|
97
|
-
|
|
100
|
+
// Deeper than PACK_DEPTH a child is packed as a leaf, and its own children are placed around it after (the last pass of layoutOrbit): a map
|
|
101
|
+
// nested thousands deep is laid out, never a stack overflow
|
|
102
|
+
const kids = seen.has(c.id) || depth >= PACK_DEPTH ? [] : kidsOf(c);
|
|
98
103
|
if (!kids.length) { plain.push(c); return; }
|
|
99
104
|
seen.add(c.id);
|
|
100
|
-
const sub = packTree(kids.sort(byOrder), kidsOf, spacingOf, byOrder, seen);
|
|
105
|
+
const sub = packTree(kids.sort(byOrder), kidsOf, spacingOf, byOrder, seen, depth + 1);
|
|
101
106
|
withSub.push({ c, sub, fp: sub.extent });
|
|
102
107
|
});
|
|
103
108
|
withSub.sort((a, b) => b.fp - a.fp);
|
|
@@ -37,6 +37,7 @@ function sheetsOf(inst) {
|
|
|
37
37
|
away: new Set(), // sheets displaced by the other of their group: open on the page, hidden until opened again
|
|
38
38
|
listeners: new Set(),
|
|
39
39
|
dock: null,
|
|
40
|
+
box: null, // the element whose width says phone, instead of the window's (setPhoneBox)
|
|
40
41
|
lastCovered: 0,
|
|
41
42
|
observers: [],
|
|
42
43
|
wiredDock: null,
|
|
@@ -44,7 +45,42 @@ function sheetsOf(inst) {
|
|
|
44
45
|
}));
|
|
45
46
|
}
|
|
46
47
|
|
|
47
|
-
|
|
48
|
+
/** The width of a box below which it is a phone's (the CSS's `@container corn-box (max-width: 767px)`) */
|
|
49
|
+
const PHONE_WIDTH = 768;
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Whether the instance is laid out as a phone: the window's width on cornfield's page (PHONE_QUERY), or, where the instance has a box of its own
|
|
53
|
+
* (`setPhoneBox`: the one-tag review in another app's page), that box's width, which is what the stylesheets' container queries ask
|
|
54
|
+
*/
|
|
55
|
+
export const isPhone = (inst) => {
|
|
56
|
+
const { box } = sheetsOf(inst);
|
|
57
|
+
if (box) return box.isConnected && box.clientWidth > 0 && box.clientWidth < PHONE_WIDTH;
|
|
58
|
+
return !!(inst.win && typeof inst.win.matchMedia === 'function' && inst.win.matchMedia(PHONE_QUERY).matches);
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/** Makes `el`'s width, not the window's, say whether the instance is a phone's (the review piece's box in another app's page); null goes back to the window's */
|
|
62
|
+
export function setPhoneBox(inst, el) {
|
|
63
|
+
sheetsOf(inst).box = el || null;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Calls `fn` when the instance becomes a phone's or stops being one (the window's width, or the phone box's). Returns how to stop. */
|
|
67
|
+
export function onPhoneChange(inst, fn) {
|
|
68
|
+
const { box } = sheetsOf(inst);
|
|
69
|
+
const RO = inst.win && inst.win.ResizeObserver;
|
|
70
|
+
if (box && typeof RO === 'function') {
|
|
71
|
+
let was = isPhone(inst);
|
|
72
|
+
const ro = new RO(() => { const now = isPhone(inst); if (now !== was) { was = now; fn(); } });
|
|
73
|
+
ro.observe(box);
|
|
74
|
+
const off = () => { ro.disconnect(); inst.release(off); };
|
|
75
|
+
inst.own(off);
|
|
76
|
+
return off;
|
|
77
|
+
}
|
|
78
|
+
if (inst.win && typeof inst.win.matchMedia === 'function') {
|
|
79
|
+
const mq = inst.win.matchMedia(PHONE_QUERY);
|
|
80
|
+
if (mq && mq.addEventListener) return inst.listen(mq, 'change', () => fn());
|
|
81
|
+
}
|
|
82
|
+
return () => {};
|
|
83
|
+
};
|
|
48
84
|
|
|
49
85
|
const stageOf = (inst, S) => (S.dock && S.dock.parentElement) || (inst.state.canvas ? inst.state.canvas.parentElement : null);
|
|
50
86
|
|
|
@@ -78,8 +114,8 @@ function apply(inst) {
|
|
|
78
114
|
}
|
|
79
115
|
const stage = stageOf(inst, S);
|
|
80
116
|
if (stage) stage.dataset.sheetOpen = model.expanded() || '';
|
|
81
|
-
// The expanded sheet is capped so the map keeps 35% of the screen: what is left under the stub, if there is one
|
|
82
|
-
if (S.dock && isPhone(inst)) S.dock.style.setProperty('--hx-sheet-cap', `${sheetCap(inst.win.innerHeight || 0, model.stubs())}px`);
|
|
117
|
+
// The expanded sheet is capped so the map keeps 35% of the screen (of the box, where the instance has one): what is left under the stub, if there is one
|
|
118
|
+
if (S.dock && isPhone(inst)) S.dock.style.setProperty('--hx-sheet-cap', `${sheetCap((S.box ? S.box.clientHeight : inst.win.innerHeight) || 0, model.stubs())}px`);
|
|
83
119
|
markLast(inst);
|
|
84
120
|
measureCovered(inst);
|
|
85
121
|
S.listeners.forEach((fn) => fn());
|
|
@@ -408,10 +444,7 @@ export function initSheets(inst) {
|
|
|
408
444
|
S.documentWired = true;
|
|
409
445
|
for (const type of ['pointerdown', 'touchstart', 'mousedown']) inst.listen(inst.root, type, (e) => onMapDown(inst, e), { passive: true, capture: true });
|
|
410
446
|
inst.listen(inst.root, 'keydown', (e) => onEscape(inst, e), true);
|
|
411
|
-
|
|
412
|
-
const mq = inst.win.matchMedia(PHONE_QUERY);
|
|
413
|
-
if (mq && mq.addEventListener) inst.listen(mq, 'change', () => { collapseAllSheets(inst); measureCovered(inst); });
|
|
414
|
-
}
|
|
447
|
+
onPhoneChange(inst, () => { collapseAllSheets(inst); measureCovered(inst); });
|
|
415
448
|
}
|
|
416
449
|
apply(inst);
|
|
417
450
|
}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module explorer/engine/topology
|
|
3
|
+
*
|
|
4
|
+
* Giving an instance its map (spec 0011 D2, D4: the engine half of the one-tag review). A host hands a topology in (`{ nodes, edges }`, the object
|
|
5
|
+
* topology.json holds); this is the one place it becomes the instance's state, for the map piece (pieces/map.js) and for the review piece
|
|
6
|
+
* (pieces/review.js), which both call it. Nothing here reads the address or fetches: a piece that loads a topology from a server hands the object over.
|
|
7
|
+
*
|
|
8
|
+
* setTopology(inst, topology) copies the nodes and edges in as the base map (the host's object is never changed: the layout writes on the copies),
|
|
9
|
+
* builds the data-flow preset, keeps the selection when its node is still there; returns whether it is
|
|
10
|
+
* layoutMap(inst, { placeLive }) where the nodes sit for the current view (orbit, or the data-flow lanes). With a proposal open (or live nodes
|
|
11
|
+
* laid in) the base is laid out on its own and the nodes that were there keep their places; only what a proposal adds
|
|
12
|
+
* is placed beside it (proposal-model.js), and the live layer by `placeLive` (cornfield's page hands live-model.js's,
|
|
13
|
+
* which no component carries). The ONE layout: cornfield's page (view.js), the map piece and the review piece all
|
|
14
|
+
* call it. The camera is the caller's
|
|
15
|
+
* setMap(inst, nodes, edges) the map the instance draws from `nodes` and `edges` (the base, or `applyProposal(base, proposal)` while a proposal is
|
|
16
|
+
* open), laid out by layoutMap. It is what the instance answers to the `map:set` ask of engine/proposal.js (the review
|
|
17
|
+
* piece answers it; cornfield's page answers with view.js, which lays in its live layer first and then calls layoutMap)
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { buildDataFlow } from '../flow-build.js';
|
|
21
|
+
import { orderAddedLast, pinLanes, placeAddedNodes } from '../proposal-model.js';
|
|
22
|
+
import { computeDegreeCentrality, computeLaneLayout, layoutOrbit } from './layout.js';
|
|
23
|
+
|
|
24
|
+
/** The nodes and edges of a topology that have what the engine needs (an id, and two ends), as arrays; anything else is dropped */
|
|
25
|
+
export function cleanTopology(topology) {
|
|
26
|
+
const nodes = topology && Array.isArray(topology.nodes) ? topology.nodes.filter((n) => n && typeof n.id === 'string') : [];
|
|
27
|
+
const edges = topology && Array.isArray(topology.edges) ? topology.edges.filter((e) => e && typeof e.from === 'string' && typeof e.to === 'string') : [];
|
|
28
|
+
return { nodes, edges };
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Makes `topology` the instance's base map. The selection outlives it when the new map has its node (the same id is the same selection, the
|
|
33
|
+
* instance says nothing), else it is cleared (the instance says so once). The scene is touched; laying out and drawing are the caller's.
|
|
34
|
+
* @param {ReturnType<import('../instance.js').createInstance>} inst
|
|
35
|
+
* @param {{ nodes?: object[], edges?: object[] } | null | undefined} topology
|
|
36
|
+
* @returns {boolean} whether the map has any nodes
|
|
37
|
+
*/
|
|
38
|
+
export function setTopology(inst, topology) {
|
|
39
|
+
const { state } = inst;
|
|
40
|
+
const { nodes, edges } = cleanTopology(topology);
|
|
41
|
+
const keep = state.selectedNode ? state.selectedNode.id : null;
|
|
42
|
+
// The host's object is never changed: the map works on copies (the layout writes positions on them)
|
|
43
|
+
state.baseNodes = nodes;
|
|
44
|
+
state.baseEdges = edges;
|
|
45
|
+
state.nodes = nodes.map((n) => ({ ...n }));
|
|
46
|
+
state.edges = edges.map((e) => ({ ...e }));
|
|
47
|
+
state.mapNodes = state.nodes;
|
|
48
|
+
state.mapEdges = state.edges;
|
|
49
|
+
state.flow = buildDataFlow(state.nodes, state.edges);
|
|
50
|
+
const again = keep ? state.nodes.find((n) => n.id === keep) || null : null;
|
|
51
|
+
if (again) { state.selectedEdge = null; state.selectedNode = again; } else if (state.selectedNode || state.selectedEdge) { state.selectedNode = null; state.selectedEdge = null; }
|
|
52
|
+
inst.touchScene();
|
|
53
|
+
return state.nodes.length > 0;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Where nodes sit for the current view: sizes by degree, then the data-flow lanes or the orbit. With a proposal open the base map is laid out on its
|
|
58
|
+
* own, exactly as it is with none, and the nodes that were there keep those places and sizes: opening a proposal, switching Before, Diff and After,
|
|
59
|
+
* and closing it never move a node that was already on the map; an added node takes a free cell in its lane, or a place beside its parent. Live
|
|
60
|
+
* nodes (cornfield's page lays its live layer in: view.js) are placed beside the code map the same way.
|
|
61
|
+
*/
|
|
62
|
+
export function layoutMap(inst, { placeLive } = {}) {
|
|
63
|
+
const { state } = inst;
|
|
64
|
+
computeDegreeCentrality(inst); // node sizes: by degree on the full map ...
|
|
65
|
+
if (state.view === 'dataflow' && state.flow) {
|
|
66
|
+
state.flow.tiers.forEach((tier) => tier.nodes.forEach((n) => { n.r = Math.min(n.r, 13); })); // ... all small in the lanes
|
|
67
|
+
if (!(state.proposal && state.baseNodes && lanesAround(inst))) computeLaneLayout(inst, state.flow);
|
|
68
|
+
} else if (state.baseNodes && (state.proposal || state.nodes.some((n) => n.live))) {
|
|
69
|
+
orbitAround(inst, placeLive); // the code map keeps its places; what a proposal adds and the live layer are placed beside it
|
|
70
|
+
} else layoutOrbit(inst);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Puts `nodes` and `edges` on the map and lays them out (layoutMap): the data-flow preset is rebuilt from them, an added node last in its lane.
|
|
75
|
+
*/
|
|
76
|
+
export function setMap(inst, nodes, edges) {
|
|
77
|
+
const { state } = inst;
|
|
78
|
+
state.mapNodes = nodes;
|
|
79
|
+
state.mapEdges = edges;
|
|
80
|
+
state.nodes = nodes;
|
|
81
|
+
state.edges = edges;
|
|
82
|
+
state.flow = buildDataFlow(nodes, edges);
|
|
83
|
+
orderAddedLast(state.flow); // an added node goes last in its lane, so the nodes that were there keep their rows
|
|
84
|
+
inst.touchScene();
|
|
85
|
+
layoutMap(inst);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** The data-flow lanes while a proposal is open: the base is laid out on its own and pinned, the added nodes take free cells; false when that cannot be done */
|
|
89
|
+
function lanesAround(inst) {
|
|
90
|
+
const { state } = inst;
|
|
91
|
+
const applied = { nodes: state.nodes, edges: state.edges };
|
|
92
|
+
const laid = state.baseNodes.map((n) => ({ ...n }));
|
|
93
|
+
state.nodes = laid;
|
|
94
|
+
state.edges = state.baseEdges;
|
|
95
|
+
computeDegreeCentrality(inst);
|
|
96
|
+
const baseFlow = buildDataFlow(laid, state.baseEdges);
|
|
97
|
+
baseFlow.tiers.forEach((tier) => tier.nodes.forEach((n) => { n.r = Math.min(n.r, 13); }));
|
|
98
|
+
computeLaneLayout(inst, baseFlow);
|
|
99
|
+
state.nodes = applied.nodes;
|
|
100
|
+
state.edges = applied.edges;
|
|
101
|
+
const pinned = pinLanes(state.flow, baseFlow);
|
|
102
|
+
inst.touchScene();
|
|
103
|
+
return pinned;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/** The orbit while a proposal is open (or live nodes are in): the base is laid out as it is with none, and only the added nodes are placed, next to their parent */
|
|
107
|
+
function orbitAround(inst, placeLive) {
|
|
108
|
+
const { state } = inst;
|
|
109
|
+
const applied = { nodes: state.nodes, edges: state.edges };
|
|
110
|
+
const laid = state.baseNodes.map((n) => ({ ...n }));
|
|
111
|
+
state.nodes = laid;
|
|
112
|
+
state.edges = state.baseEdges;
|
|
113
|
+
computeDegreeCentrality(inst);
|
|
114
|
+
layoutOrbit(inst); // also sets the rings
|
|
115
|
+
const at = new Map(laid.map((n) => [n.id, n]));
|
|
116
|
+
state.nodes = applied.nodes;
|
|
117
|
+
state.edges = applied.edges;
|
|
118
|
+
computeDegreeCentrality(inst);
|
|
119
|
+
state.nodes.forEach((n) => {
|
|
120
|
+
const was = at.get(n.id);
|
|
121
|
+
if (was) { n.x = was.x; n.y = was.y; n.r = was.r; }
|
|
122
|
+
});
|
|
123
|
+
placeAddedNodes(state.nodes, state.edges);
|
|
124
|
+
if (placeLive) placeLive(state.nodes, state.edges);
|
|
125
|
+
inst.touchScene();
|
|
126
|
+
}
|
package/explorer/focus-room.js
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
* A control that is tabbed to inside a strip that scrolls sideways (the Work panel's tabs) is brought fully into view, ring and all
|
|
5
5
|
* (CF review F54). A browser scrolls a focused control only until it is "mostly" visible, and the last tab was left a few pixels under
|
|
6
6
|
* the strip's edge, with its focus ring cut. `scroll-padding-inline` in css/work.css says how much room to leave; this asks for the scroll.
|
|
7
|
+
* The Work piece (pieces/work.js) listens for focus in its own root and asks.
|
|
7
8
|
*/
|
|
8
9
|
|
|
9
10
|
/** The strips: a scroll container whose children are tabbed to */
|
|
@@ -17,10 +18,3 @@ export function revealInStrip(el) {
|
|
|
17
18
|
el.scrollIntoView({ block: 'nearest', inline: 'nearest' });
|
|
18
19
|
return true;
|
|
19
20
|
}
|
|
20
|
-
|
|
21
|
-
/** Listens for focus on the whole page, once. Returns how to stop. */
|
|
22
|
-
export function watchFocusRoom(doc = document) {
|
|
23
|
-
const on = (event) => revealInStrip(event.target);
|
|
24
|
-
doc.addEventListener('focusin', on);
|
|
25
|
-
return () => doc.removeEventListener('focusin', on);
|
|
26
|
-
}
|
package/explorer/focusables.js
CHANGED
|
@@ -28,7 +28,7 @@ export function trapTab(e, root) {
|
|
|
28
28
|
const stops = focusableIn(root);
|
|
29
29
|
e.preventDefault();
|
|
30
30
|
if (!stops.length) return true;
|
|
31
|
-
const at = stops.indexOf(
|
|
31
|
+
const at = stops.indexOf(root.getRootNode().activeElement); // the focus in the dialog's own tree: a shadow root's, not the host's
|
|
32
32
|
const next = e.shiftKey ? (at <= 0 ? stops.length - 1 : at - 1) : (at === -1 || at === stops.length - 1 ? 0 : at + 1);
|
|
33
33
|
stops[next].focus();
|
|
34
34
|
return true;
|