@popcorn245/cornfield 0.48.0 → 0.50.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/core/strings.js +14 -0
- package/explorer/check.js +7 -227
- package/explorer/connection.js +3 -3
- package/explorer/css/review.css +49 -0
- package/explorer/decision-model.js +6 -0
- package/explorer/engine/checks.js +252 -0
- package/explorer/engine/connection.js +36 -0
- package/explorer/engine/layers.js +1 -0
- package/explorer/engine/layout.js +8 -3
- package/explorer/engine/player.js +489 -0
- package/explorer/engine/proposal.js +373 -0
- package/explorer/engine/render.js +1 -0
- package/explorer/engine/sheets.js +40 -7
- package/explorer/engine/source.js +315 -0
- package/explorer/engine/theme-sheet.js +444 -0
- package/explorer/engine/topology.js +126 -0
- package/explorer/index.html +6 -59
- package/explorer/instance.js +87 -7
- package/explorer/page-address.js +59 -0
- package/explorer/page-pieces.js +33 -5
- package/explorer/page.js +20 -20
- package/explorer/panels.js +1 -3
- package/explorer/pieces/changes.js +495 -0
- package/explorer/pieces/decision.js +664 -0
- package/explorer/pieces/layers.js +4 -0
- package/explorer/pieces/map.js +117 -25
- package/explorer/pieces/node-panel.js +34 -1
- package/explorer/pieces/proposal.js +488 -0
- package/explorer/pieces/review.js +280 -0
- package/explorer/pieces/scope-link.js +50 -0
- package/explorer/pieces/scope.js +247 -0
- package/explorer/pieces/status.css +24 -0
- package/explorer/pieces/status.js +144 -0
- package/explorer/plugins.js +0 -10
- package/explorer/proposal.js +64 -697
- package/explorer/review-column.js +24 -439
- package/explorer/review.js +27 -673
- package/explorer/scenario-ui.js +32 -478
- package/explorer/sheets.js +8 -7
- package/explorer/view.js +12 -64
- package/explorer/waiting-line.js +7 -50
- package/package.json +1 -1
|
@@ -301,12 +301,16 @@ export function mount(root, inst, options = {}) {
|
|
|
301
301
|
scope.on('layers:redraw', renderLayerToggles);
|
|
302
302
|
scope.on('theme', renderLayerToggles); // the dots and the legends are drawn in the theme's colours
|
|
303
303
|
scope.on('view', syncView);
|
|
304
|
+
// The marks legend is there while a proposal is open (the proposal's bar says so: engine/proposal.js)
|
|
305
|
+
const showLegend = (open) => { const legend = own('proposal-legend'); if (legend) legend.hidden = !open; };
|
|
306
|
+
scope.on('proposal:draw', ({ open }) => showLegend(open));
|
|
304
307
|
// ... and when the map's own tokens change (a named theme, its stylesheet arriving, light and dark): the same signal the map is drawn again on
|
|
305
308
|
scope.own(mapStyleOf(inst).onChange(() => { if (!redrawing(inst)) renderLayerToggles(); }));
|
|
306
309
|
scope.own(() => made.forEach((el) => el.remove()));
|
|
307
310
|
|
|
308
311
|
syncView();
|
|
309
312
|
renderLayerToggles();
|
|
313
|
+
showLegend(!!inst.state.proposal);
|
|
310
314
|
|
|
311
315
|
return {
|
|
312
316
|
elements: made,
|
package/explorer/pieces/map.js
CHANGED
|
@@ -10,7 +10,9 @@
|
|
|
10
10
|
* const piece = mount(root, inst, options) -> { update, destroy, ... }
|
|
11
11
|
*
|
|
12
12
|
* root where the piece's elements go when `options.slots` names no place: an element or a shadow root (they go in a stage of their own there)
|
|
13
|
-
* inst the instance (instance.js) the map runs on; null makes one over `root`, which `destroy()` then ends too
|
|
13
|
+
* inst the instance (instance.js) the map runs on; null makes one over `root`, which `destroy()` then ends too. A scope's instance (pieces/scope.js):
|
|
14
|
+
* the map attaches its root to it (one map per scope: a second mount draws nothing and says why), takes the topology the scope's source
|
|
15
|
+
* holds unless it has one of its own, and does not end the instance when it ends
|
|
14
16
|
* options see below; `update(next)` takes the same keys and applies what changed
|
|
15
17
|
*
|
|
16
18
|
* Options, all optional:
|
|
@@ -20,6 +22,11 @@
|
|
|
20
22
|
* theme 'light' | 'dark' | 'auto': the ground the map is drawn for. 'auto' (and nothing) follows the document's own `data-theme`, else prefers-color-scheme
|
|
21
23
|
* renderer 'auto' | 'canvas2d'
|
|
22
24
|
* base, fetch, strings for a piece that makes its own instance
|
|
25
|
+
* src the base address of a cornfield server, for a piece with no scope around it: it makes a private scope of its own (pieces/scope.js) that reads
|
|
26
|
+
* the config and the topology from there, with the maintainer's session, and shows the states of that load (pieces/status.js). Not applied
|
|
27
|
+
* by `update`: a new server is a new instance, so the shell mounts the piece again. pieces/scope.js and what it loads are imported then,
|
|
28
|
+
* a chunk of the package's own, so a map that is handed its topology never loads them (the piece answers at once; see mountWithSource)
|
|
29
|
+
* useTheme, version, pageUrl, onAuth, onError for that private scope (see mountScope)
|
|
23
30
|
* slots { stage: Node }: the place the elements go before (cornfield's page: the marker in its stage). Without it they go in a stage of their own in `root`
|
|
24
31
|
* keysHelp the words the canvas is described by; default KEYS_HELP. cornfield's page, which has the node panel and Freeform, says KEYS_HELP_WITH_PANEL
|
|
25
32
|
* tokens the default `--corn-*` tokens (CSS text) to add, once, to the document, and to the shadow root the map's host is in if it is in one (adopt-tokens.js)
|
|
@@ -38,17 +45,17 @@
|
|
|
38
45
|
import { createInstance } from '../instance.js';
|
|
39
46
|
import { createMap } from '../engine/render.js';
|
|
40
47
|
import { mapStyleOf } from '../engine/map-style.js';
|
|
41
|
-
import {
|
|
48
|
+
import { layoutMap, setTopology as installTopology } from '../engine/topology.js';
|
|
42
49
|
import { initKeyboard, resetKeyboard } from '../engine/keyboard.js';
|
|
43
50
|
import { selectNode, clearSelection } from '../engine/selection.js';
|
|
44
51
|
import { stopFlight } from '../engine/fly.js';
|
|
45
52
|
import { scopeOf, place } from '../engine/piece.js';
|
|
46
53
|
import { createRenderer } from '../renderer.js';
|
|
47
54
|
import { bindCanvasInput } from '../input.js';
|
|
48
|
-
import { buildDataFlow } from '../flow-build.js';
|
|
49
55
|
import { resolveTheme } from '../theme-model.js';
|
|
50
56
|
import { escapeHtml } from '../../core/text.js';
|
|
51
57
|
import { adoptDefaultTokens } from './adopt-tokens.js';
|
|
58
|
+
import { scopeInfo } from './scope-link.js';
|
|
52
59
|
|
|
53
60
|
/** The keys of a map on its own (engine/keyboard.js): what the canvas is described by */
|
|
54
61
|
export const KEYS_HELP = 'Arrow keys pan, plus and minus zoom, 0 fits the map. N and P select the next and the previous node, Home and End the first and the last. F frames the selected node and what it lights. Escape clears the selection.';
|
|
@@ -70,6 +77,28 @@ export const markup = ({ keysHelp = KEYS_HELP } = {}) => ({
|
|
|
70
77
|
<canvas id="label-canvas" data-corn="label-canvas" aria-hidden="true"></canvas>`,
|
|
71
78
|
});
|
|
72
79
|
|
|
80
|
+
/**
|
|
81
|
+
* The piece of a second map in a scope: the engine holds one map per instance (its state has one canvas, one camera, one selection), so this one draws
|
|
82
|
+
* nothing. It says why, in its own stage (pieces/status.js), and tells the scope, which says it as `cornError` `{ kind: 'second-map' }`.
|
|
83
|
+
*/
|
|
84
|
+
function refused(root, inst, info) {
|
|
85
|
+
const made = place(inst, root, '<div data-corn="map-stage"></div>', null, 'stage');
|
|
86
|
+
const status = info.mountStatus(made[0], inst, { follow: false });
|
|
87
|
+
status.refuse('second-map');
|
|
88
|
+
inst.emit('piece:refused', { piece: 'map', reason: 'second-map', message: 'A scope holds one map.', host: root.nodeType === 11 ? /** @type {ShadowRoot} */ (root).host : root });
|
|
89
|
+
const none = () => {};
|
|
90
|
+
return {
|
|
91
|
+
inst,
|
|
92
|
+
refused: true,
|
|
93
|
+
update: none,
|
|
94
|
+
fit: none,
|
|
95
|
+
refresh: none,
|
|
96
|
+
focusNode: () => false,
|
|
97
|
+
applyTheme: none,
|
|
98
|
+
destroy() { status.destroy(); for (const el of made) el.remove(); },
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
|
|
73
102
|
/** The document or shadow root the map's host sits in: where the default tokens go */
|
|
74
103
|
function hostRootOf(root) {
|
|
75
104
|
const host = root.nodeType === 11 ? /** @type {ShadowRoot} */ (root).host : root;
|
|
@@ -82,9 +111,63 @@ function hostRootOf(root) {
|
|
|
82
111
|
* @param {object} [options]
|
|
83
112
|
*/
|
|
84
113
|
export function mount(root, inst, options = {}) {
|
|
114
|
+
if (!inst && options.src !== undefined && options.src !== null && options.src !== '') return mountWithSource(root, options);
|
|
115
|
+
return mountOn(root, inst, options, null);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* A map with a `src` and no scope around it makes a private scope on its own element: the same loading, the same states, one tag. The scope's code
|
|
120
|
+
* (pieces/scope.js and what it loads: the reads, the states, the server's theme) is a chunk of the package's own, imported the first time a map has
|
|
121
|
+
* a `src` (a map that is handed its topology never loads it). The piece answers at once: what it is told before the chunk is there is applied when it
|
|
122
|
+
* is, `fit`, `refresh` and `focusNode` do nothing until then (there is no map to act on yet), and `destroy` before then makes nothing.
|
|
123
|
+
*/
|
|
124
|
+
function mountWithSource(root, options) {
|
|
125
|
+
const host = root.nodeType === 11 ? /** @type {ShadowRoot} */ (root).host : root;
|
|
126
|
+
const pending = {};
|
|
127
|
+
let real = null;
|
|
128
|
+
let ended = false;
|
|
129
|
+
import('./scope.js').then(({ mountScope }) => {
|
|
130
|
+
if (ended) return;
|
|
131
|
+
const privateScope = mountScope(host, {
|
|
132
|
+
src: options.src, theme: options.theme, useTheme: options.useTheme, tokens: options.tokens, version: options.version, pageUrl: options.pageUrl,
|
|
133
|
+
onAuth: options.onAuth, onError: options.onError,
|
|
134
|
+
});
|
|
135
|
+
real = mountOn(root, privateScope.instance, { ...options, ...pending }, privateScope);
|
|
136
|
+
}, (err) => {
|
|
137
|
+
if (!ended && options.onError) options.onError({ kind: 'offline', message: `the map's loader did not load: ${err && err.message ? err.message : err}` });
|
|
138
|
+
});
|
|
139
|
+
return {
|
|
140
|
+
get inst() { return real ? real.inst : null; },
|
|
141
|
+
get map() { return real ? real.map : null; },
|
|
142
|
+
update(next = {}) { if (real) real.update(next); else Object.assign(pending, next); },
|
|
143
|
+
fit() { if (real) real.fit(); },
|
|
144
|
+
focusNode(id) { return real ? real.focusNode(id) : false; },
|
|
145
|
+
refresh() { if (real) real.refresh(); },
|
|
146
|
+
applyTheme(theme) { return real ? real.applyTheme(theme) : null; },
|
|
147
|
+
destroy() {
|
|
148
|
+
if (ended) return;
|
|
149
|
+
ended = true;
|
|
150
|
+
if (real) real.destroy();
|
|
151
|
+
real = null;
|
|
152
|
+
},
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/** The map on an instance: a scope's, its own private scope's (`privateScope`, which it ends when it ends), or one it makes */
|
|
157
|
+
function mountOn(root, inst, options, privateScope) {
|
|
85
158
|
const ownsInstance = !inst;
|
|
86
159
|
if (ownsInstance) inst = createInstance({ root, base: options.base || '', fetch: options.fetch, strings: options.strings });
|
|
160
|
+
// An instance that belongs to a scope holds one map: the map attaches its shadow root to it, and a second map is told why it has no map
|
|
161
|
+
const info = scopeInfo(inst);
|
|
162
|
+
let releaseRoot = () => {};
|
|
163
|
+
if (info) {
|
|
164
|
+
try { releaseRoot = inst.attach(root); } catch {
|
|
165
|
+
if (privateScope) privateScope.destroy();
|
|
166
|
+
return refused(root, inst, info);
|
|
167
|
+
}
|
|
168
|
+
}
|
|
87
169
|
const { state } = inst;
|
|
170
|
+
const source = info ? info.source : null;
|
|
88
171
|
if (options.tokens) {
|
|
89
172
|
// The defaults go on the document, whose :root every element inherits from (through every shadow root); where the map's host sits in a
|
|
90
173
|
// shadow root of the page's own, that root gets the sheet too, for the rules on the element's `theme` attribute, which match only there
|
|
@@ -94,9 +177,13 @@ export function mount(root, inst, options = {}) {
|
|
|
94
177
|
}
|
|
95
178
|
/** What the piece set up, undone by destroy() (the instance's own end runs it too, if the piece is still there) */
|
|
96
179
|
const scope = scopeOf(inst);
|
|
180
|
+
scope.own(releaseRoot);
|
|
181
|
+
if (privateScope) scope.own(() => privateScope.destroy());
|
|
97
182
|
const rendererOf = (v) => (v === 'canvas2d' ? 'canvas2d' : 'auto');
|
|
98
183
|
const themeOf = (v) => (v === 'light' || v === 'dark' ? v : 'auto');
|
|
99
184
|
const current = { renderer: rendererOf(options.renderer), theme: themeOf(options.theme), topology: undefined };
|
|
185
|
+
/** A topology the host handed to this map itself: it wins over the scope's source (the host's property is the host's choice) */
|
|
186
|
+
let ownTopology = options.topology !== undefined && options.topology !== null;
|
|
100
187
|
let ended = false;
|
|
101
188
|
let ready = false;
|
|
102
189
|
|
|
@@ -106,6 +193,12 @@ export function mount(root, inst, options = {}) {
|
|
|
106
193
|
const made = place(inst, root, slots ? html : `<div data-corn="map-stage">${html}</div>`, slots, 'stage');
|
|
107
194
|
const find = (sel) => made.map((el) => (el.matches(sel) ? el : el.querySelector(sel))).find(Boolean);
|
|
108
195
|
scope.own(() => { for (const el of [...made, state.canvas]) if (el) el.remove(); });
|
|
196
|
+
// What the person sees while the data loads and when it cannot be had (pieces/status.js): only a map that has a source
|
|
197
|
+
const stage = made.find((el) => el.matches('[data-corn="map-stage"]')) || null;
|
|
198
|
+
if (source && stage) {
|
|
199
|
+
const status = info.mountStatus(stage, inst, { onRetry: () => source.load(), focusMap: () => { if (state.canvas) state.canvas.focus(); } });
|
|
200
|
+
scope.own(status.destroy);
|
|
201
|
+
}
|
|
109
202
|
|
|
110
203
|
// -- what the engine needs on the state, in this order ------------------------------------------------------------------------------
|
|
111
204
|
state.canvas = find('[data-corn="map-canvas"]');
|
|
@@ -124,6 +217,7 @@ export function mount(root, inst, options = {}) {
|
|
|
124
217
|
/** The mode the map is drawn for: the element's own `theme`, else the document's `data-theme`, else the system's */
|
|
125
218
|
function mode() {
|
|
126
219
|
if (current.theme === 'light' || current.theme === 'dark') return current.theme;
|
|
220
|
+
if (info && (info.theme === 'light' || info.theme === 'dark')) return info.theme; // the scope's, when the map has none of its own
|
|
127
221
|
const root$ = inst.doc && inst.doc.documentElement;
|
|
128
222
|
const own = root$ ? root$.getAttribute('data-theme') : null;
|
|
129
223
|
if (own === 'light' || own === 'dark') return own;
|
|
@@ -138,6 +232,9 @@ export function mount(root, inst, options = {}) {
|
|
|
138
232
|
map.render();
|
|
139
233
|
}
|
|
140
234
|
state.theme = mode();
|
|
235
|
+
// The scope's server theme: its sheet goes into this root, and its tokens (on the scope's element) are read again once it is there or goes
|
|
236
|
+
if (info) scope.own(info.serverTheme.adopt(root));
|
|
237
|
+
if (info) { scope.on('theme', () => refresh()); scope.on('scope:theme', () => refresh()); }
|
|
141
238
|
if (lightQuery && lightQuery.addEventListener) { lightQuery.addEventListener('change', refresh); scope.own(() => lightQuery.removeEventListener('change', refresh)); }
|
|
142
239
|
const Mutation = inst.win && inst.win.MutationObserver;
|
|
143
240
|
if (Mutation && inst.doc && inst.doc.documentElement) { // the host page switching its own light and dark
|
|
@@ -149,14 +246,8 @@ export function mount(root, inst, options = {}) {
|
|
|
149
246
|
// -- the renderer, the layout --------------------------------------------------------------------------------------------------------
|
|
150
247
|
installRenderer();
|
|
151
248
|
|
|
152
|
-
/** Where nodes sit for the current view */
|
|
153
|
-
|
|
154
|
-
computeDegreeCentrality(inst);
|
|
155
|
-
if (state.view === 'dataflow' && state.flow) {
|
|
156
|
-
state.flow.tiers.forEach((tier) => tier.nodes.forEach((n) => { n.r = Math.min(n.r, 13); })); // all small in the lanes
|
|
157
|
-
computeLaneLayout(inst, state.flow);
|
|
158
|
-
} else layoutOrbit(inst);
|
|
159
|
-
}
|
|
249
|
+
/** Where nodes sit for the current view (engine/topology.js) */
|
|
250
|
+
const applyLayout = () => layoutMap(inst);
|
|
160
251
|
|
|
161
252
|
/** A fit asked for while the map has no box (a parent `display: none`, a box of no size) waits for one: fitted to nothing, the camera would be lost */
|
|
162
253
|
let fitWhenSized = false;
|
|
@@ -219,26 +310,21 @@ export function mount(root, inst, options = {}) {
|
|
|
219
310
|
|
|
220
311
|
bind();
|
|
221
312
|
scope.own(() => stopInput());
|
|
313
|
+
// The topology a scope's source holds (read from its server, or handed to the scope), unless this map has one of its own
|
|
314
|
+
const takeSource = () => {
|
|
315
|
+
if (ownTopology || !source || !source.topology || source.topology === current.topology) return;
|
|
316
|
+
current.topology = source.topology;
|
|
317
|
+
setTopology(source.topology);
|
|
318
|
+
};
|
|
319
|
+
if (source) scope.on('source', (detail) => { if (detail.state === 'ready') takeSource(); });
|
|
222
320
|
scope.own(map.watchSize());
|
|
223
321
|
map.resize();
|
|
224
322
|
|
|
225
323
|
// -- changes ---------------------------------------------------------------------------------------------------------------------------------
|
|
226
324
|
function setTopology(topology) {
|
|
227
|
-
const nodes = topology && Array.isArray(topology.nodes) ? topology.nodes.filter((n) => n && typeof n.id === 'string') : [];
|
|
228
|
-
const edges = topology && Array.isArray(topology.edges) ? topology.edges.filter((e) => e && typeof e.from === 'string' && typeof e.to === 'string') : [];
|
|
229
325
|
const keep = state.selectedNode ? state.selectedNode.id : null; // the selection outlives a new topology that has its node
|
|
230
|
-
|
|
231
|
-
state.baseNodes = nodes;
|
|
232
|
-
state.baseEdges = edges;
|
|
233
|
-
state.nodes = nodes.map((n) => ({ ...n }));
|
|
234
|
-
state.edges = edges.map((e) => ({ ...e }));
|
|
235
|
-
state.mapNodes = state.nodes;
|
|
236
|
-
state.mapEdges = state.edges;
|
|
237
|
-
state.flow = buildDataFlow(state.nodes, state.edges);
|
|
326
|
+
installTopology(inst, topology); // the base map, the data-flow preset and the selection kept or cleared (engine/topology.js)
|
|
238
327
|
const again = keep ? nodeById(keep) : null;
|
|
239
|
-
// The same id is the same selection (the instance says nothing); none is a change it says once
|
|
240
|
-
if (again) { state.selectedEdge = null; state.selectedNode = again; } else if (state.selectedNode || state.selectedEdge) { state.selectedNode = null; state.selectedEdge = null; }
|
|
241
|
-
inst.touchScene();
|
|
242
328
|
if (state.nodes.length) { applyLayout(); fit(); }
|
|
243
329
|
const asked = !again && pendingNode ? nodeById(pendingNode) : null; // the node the host asked for before the map had it
|
|
244
330
|
if (asked) selectNode(inst, asked, { source: 'api' });
|
|
@@ -286,7 +372,12 @@ export function mount(root, inst, options = {}) {
|
|
|
286
372
|
const value = themeOf(next.theme);
|
|
287
373
|
if (value !== current.theme) { current.theme = value; refresh(); }
|
|
288
374
|
}
|
|
289
|
-
if ('topology' in next
|
|
375
|
+
if ('topology' in next) {
|
|
376
|
+
ownTopology = next.topology !== undefined && next.topology !== null;
|
|
377
|
+
if (ownTopology && next.topology !== current.topology) { current.topology = next.topology; setTopology(next.topology); }
|
|
378
|
+
else if (!ownTopology && source && source.topology) { current.topology = undefined; takeSource(); } // the host took its map back: the scope's again
|
|
379
|
+
else if (!ownTopology && next.topology !== current.topology) { current.topology = next.topology; setTopology(next.topology); }
|
|
380
|
+
}
|
|
290
381
|
if ('view' in next) setView(next.view === 'dataflow' ? 'dataflow' : 'orbit');
|
|
291
382
|
if ('node' in next) {
|
|
292
383
|
const id = next.node == null || next.node === '' ? null : String(next.node);
|
|
@@ -313,6 +404,7 @@ export function mount(root, inst, options = {}) {
|
|
|
313
404
|
const first = {};
|
|
314
405
|
for (const key of ['topology', 'view', 'node']) if (options[key] !== undefined) first[key] = options[key];
|
|
315
406
|
update(first);
|
|
407
|
+
takeSource();
|
|
316
408
|
refresh();
|
|
317
409
|
|
|
318
410
|
return {
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
|
|
26
26
|
import { escapeHtml as escHtml } from '../../core/text.js';
|
|
27
27
|
import { flowSummary } from '../engine/flow-ui.js';
|
|
28
|
-
import { kindOfMark, fieldRows, MARK_WORDS } from '../proposal-model.js';
|
|
28
|
+
import { kindOfMark, fieldRows, MARK_WORDS, proposalPanelHtml } from '../proposal-model.js';
|
|
29
29
|
import { nodeMockupsHtml } from '../mockups-model.js';
|
|
30
30
|
import { collapseSheet, initSheets, isPhone, measureCovered, onCoveredChange, registerSheet, unregisterSheet, showSheet, onBackdrop } from '../engine/sheets.js';
|
|
31
31
|
import { panIntoView } from '../camera.js';
|
|
@@ -437,6 +437,38 @@ export function mount(root, inst, options = {}) {
|
|
|
437
437
|
inst.emit('node:painted', { node });
|
|
438
438
|
}
|
|
439
439
|
|
|
440
|
+
/**
|
|
441
|
+
* Fills the panel for an edge and opens it: what it is, and what the proposal says about it (the engine's `showEdge` selects it and says `node:show-edge`).
|
|
442
|
+
* As ever, an edge alone gets no sheet on a phone (the panel is opened, not `showSheet`ed), and Escape on the map does not close it.
|
|
443
|
+
*/
|
|
444
|
+
function showEdge(edge) {
|
|
445
|
+
if (!edge || gone) return;
|
|
446
|
+
const row = (label, value) => (value ? `<div class="hx-fact" data-corn="section"><div class="hx-fact-k">${escHtml(label)}</div><div class="hx-fact-v">${escHtml(value)}</div></div>` : '');
|
|
447
|
+
const kind = edge.kind || (edge.dashed ? 'usage' : 'ownership');
|
|
448
|
+
const facts = row('Kind', kind) + row('Flow', edge.flow) + row('Label', edge.label) + row('Reads', Array.isArray(edge.keys) ? edge.keys.join(', ') : '');
|
|
449
|
+
const title = own('drawer-title');
|
|
450
|
+
title.textContent = `${sections.nameOf(edge.from)} → ${sections.nameOf(edge.to)}`;
|
|
451
|
+
title.classList.remove('hx-mono');
|
|
452
|
+
own('drawer-badge').textContent = 'Edge';
|
|
453
|
+
own('drawer-host').textContent = '';
|
|
454
|
+
own('drawer-diff').hidden = true;
|
|
455
|
+
const lead = own('drawer-description');
|
|
456
|
+
lead.textContent = '';
|
|
457
|
+
lead.hidden = true;
|
|
458
|
+
metaList.innerHTML = `${facts ? `<div class="hx-facts">${facts}</div>` : ''}
|
|
459
|
+
<div class="hx-facts">
|
|
460
|
+
<div class="hx-fact" data-corn="section"><div class="hx-fact-k">From</div><div class="hx-fact-v"><button data-corn="node-link" type="button" class="hx-linkbtn" data-action="select-node" data-id="${escHtml(edge.from)}">${escHtml(sections.nameOf(edge.from))}</button></div></div>
|
|
461
|
+
<div class="hx-fact" data-corn="section"><div class="hx-fact-k">To</div><div class="hx-fact-v"><button data-corn="node-link" type="button" class="hx-linkbtn" data-action="select-node" data-id="${escHtml(edge.to)}">${escHtml(sections.nameOf(edge.to))}</button></div></div>
|
|
462
|
+
</div>${proposalPanelHtml(edge)}`;
|
|
463
|
+
addParts(metaList);
|
|
464
|
+
own('drawer-open-btn').hidden = true;
|
|
465
|
+
own('drawer-file-btn').hidden = true;
|
|
466
|
+
own('drawer-run-btn').hidden = true;
|
|
467
|
+
drawer.classList.add('drawer-open');
|
|
468
|
+
drawer.inert = false; // closed, the panel is inert (MAP-02): open for an edge, its links and its Close are reached as a node's are
|
|
469
|
+
backdrop.hidden = false;
|
|
470
|
+
}
|
|
471
|
+
|
|
440
472
|
/**
|
|
441
473
|
* On a phone the node's sheet covers the bottom of the map (engine/sheets.js): when the selected node is under it, or
|
|
442
474
|
* gets covered as the sheet expands, pan the map (never zoom it) so the node is in the part still showing (F32)
|
|
@@ -498,6 +530,7 @@ export function mount(root, inst, options = {}) {
|
|
|
498
530
|
|
|
499
531
|
scope.on('node:show', ({ node, frame }) => show(node, { frame }));
|
|
500
532
|
scope.on('node:close', close);
|
|
533
|
+
scope.on('node:show-edge', ({ edge }) => showEdge(edge));
|
|
501
534
|
// Enter on the map goes into the open panel: its title takes the focus, so a screen reader starts there and Tab goes on into it
|
|
502
535
|
scope.on('node:focus', () => {
|
|
503
536
|
const title = own('drawer-title');
|