@unson/brainbase-mcp 0.50.26 → 0.50.28
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/package.json +2 -2
- package/ui/foundation-overview.js +3 -3
- package/ui/graph-projects-view.css +17 -0
- package/ui/graph-projects-view.js +224 -25
- package/ui/graph-registry-view.js +17 -17
- package/ui/graph-view-shared.js +50 -36
- package/ui/meeting-minutes.js +33 -21
- package/ui/objective-editor.js +6 -6
- package/ui/project-graph-entry.js +198 -19
- package/ui/project-graph.js +20 -0
- package/ui/project-overview.js +115 -3
- package/ui/project-workspace.css +132 -0
- package/ui/project-workspace.js +584 -44
- package/ui/workspace-kit.css +113 -3
- package/ui/workspace-kit.js +70 -9
|
@@ -58,7 +58,7 @@ function makeButton(doc, label, ariaLabel) {
|
|
|
58
58
|
return button;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
function makeGraph(model) {
|
|
61
|
+
function makeGraph(model, detailLayout = false) {
|
|
62
62
|
const graph = new MultiDirectedGraph();
|
|
63
63
|
for (const node of model.nodes) {
|
|
64
64
|
graph.addNode(node.id, {
|
|
@@ -73,6 +73,7 @@ function makeGraph(model) {
|
|
|
73
73
|
// ontology type. Unknown ontology types must still draw as circles.
|
|
74
74
|
type: 'circle',
|
|
75
75
|
highlighted: false,
|
|
76
|
+
detailCos: node.detailCos,
|
|
76
77
|
});
|
|
77
78
|
}
|
|
78
79
|
for (const edge of model.edges) {
|
|
@@ -81,7 +82,7 @@ function makeGraph(model) {
|
|
|
81
82
|
color: edge.color || DEFAULT_EDGE_COLOR,
|
|
82
83
|
baseColor: edge.color || DEFAULT_EDGE_COLOR,
|
|
83
84
|
size: 1,
|
|
84
|
-
type: 'arrow',
|
|
85
|
+
type: detailLayout ? 'line' : 'arrow',
|
|
85
86
|
});
|
|
86
87
|
}
|
|
87
88
|
return graph;
|
|
@@ -99,9 +100,15 @@ export function mountProjectGraph(container, options = {}) {
|
|
|
99
100
|
const signal = options?.signal;
|
|
100
101
|
if (signal?.aborted) throw abortError();
|
|
101
102
|
|
|
103
|
+
// Hosts may explicitly match an adopted surface with resolved existing
|
|
104
|
+
// tokens. The default renderer palette and personal Graph stay unchanged.
|
|
105
|
+
const theme = isRecord(options.visualTheme) ? options.visualTheme : {};
|
|
106
|
+
const detailLayout = options.layout === 'project-detail';
|
|
107
|
+
const themeColor = (key, fallback) => typeof theme[key] === 'string' && theme[key].trim() ? theme[key] : fallback;
|
|
108
|
+
|
|
102
109
|
const model = createProjectGraphModel(
|
|
103
110
|
{ nodes: options?.nodes, edges: options?.edges },
|
|
104
|
-
{ selectedId: options?.selectedId || null },
|
|
111
|
+
{ selectedId: options?.rootId || options?.selectedId || null, layout: options.layout },
|
|
105
112
|
);
|
|
106
113
|
const mountRoot = doc.createElement('div');
|
|
107
114
|
mountRoot.className = 'bb-project-graph';
|
|
@@ -136,46 +143,123 @@ export function mountProjectGraph(container, options = {}) {
|
|
|
136
143
|
let selectedId = null;
|
|
137
144
|
let neighborIds = new Set();
|
|
138
145
|
let destroyed = false;
|
|
146
|
+
let filterIds = null;
|
|
139
147
|
let abortListener = null;
|
|
140
|
-
|
|
141
|
-
|
|
148
|
+
let hoveredId = null;
|
|
149
|
+
let focusedId = null;
|
|
150
|
+
const nodeControls = new Map();
|
|
151
|
+
let rootFallback = null;
|
|
152
|
+
let rootFallbackState = null;
|
|
153
|
+
let popFrame = null;
|
|
154
|
+
let popProgress = 0;
|
|
155
|
+
let popElapsed = 0;
|
|
156
|
+
const nodeById = new Map(model.nodes.map(node => [node.id, node]));
|
|
157
|
+
const edgeById = new Map(model.edges.map(edge => [edge.id, edge]));
|
|
158
|
+
const nodeTimings = new Map(), edgeTimings = new Map();
|
|
159
|
+
const resume = (items, target, records) => { for (const item of Array.isArray(items) ? items : []) if (records.has(item.id) && Number.isFinite(item.elapsed) && Number.isFinite(item.delay) && item.elapsed < item.delay + 500) target.set(item.id, { offset: item.elapsed, delay: item.delay }); };
|
|
160
|
+
if (detailLayout) { resume(options.revealState?.nodes, nodeTimings, nodeById); resume(options.revealState?.edges, edgeTimings, edgeById); }
|
|
161
|
+
const fresh = (Array.isArray(options.freshNodeIds) ? options.freshNodeIds : []).filter(id => nodeById.has(id));
|
|
162
|
+
const delay = detailLayout ? Math.max(0, Number(options.revealDelay) || 0) : 0;
|
|
163
|
+
const stagger = detailLayout ? Math.max(0, Number(options.revealStagger) || 0) : 0;
|
|
164
|
+
fresh.forEach((id, index) => { if (!nodeTimings.has(id)) nodeTimings.set(id, { offset: 0, delay: delay + index * stagger }); });
|
|
165
|
+
if (detailLayout && (delay || stagger)) {
|
|
166
|
+
const peerRank = new Map(model.nodes.filter(node => node.id !== options.rootId).map((node, index) => [node.id, index]));
|
|
167
|
+
for (const edge of model.edges) if (!edgeTimings.has(edge.id) && (fresh.includes(edge.source) || fresh.includes(edge.target))) edgeTimings.set(edge.id, { offset: 0, delay: Math.max(peerRank.get(edge.source) ?? 0, peerRank.get(edge.target) ?? 0) * stagger });
|
|
168
|
+
}
|
|
169
|
+
const revealDuration = Math.max(0, ...[...nodeTimings.values(), ...edgeTimings.values()].map(timing => timing.delay + 500 - timing.offset));
|
|
170
|
+
const motionWindow = doc.defaultView;
|
|
171
|
+
const animateNewNodes = revealDuration > 0 && typeof motionWindow?.requestAnimationFrame === 'function' && !motionWindow.matchMedia?.('(prefers-reduced-motion: reduce)').matches;
|
|
172
|
+
if (!animateNewNodes) popProgress = 1;
|
|
142
173
|
let onZoomIn;
|
|
143
174
|
let onZoomOut;
|
|
144
175
|
let onReset;
|
|
145
176
|
|
|
146
177
|
const getNeighbors = () => neighborIds;
|
|
178
|
+
const viewScale = () => surface.clientWidth / 760;
|
|
179
|
+
const isMobile = () => detailLayout && motionWindow?.innerWidth <= 760;
|
|
180
|
+
const visualScale = () => { const scale = viewScale() / (renderer?.getCamera().ratio ?? 1); return isMobile() ? Math.max(1, scale) : scale; };
|
|
181
|
+
const metricScale = () => visualScale() * (renderer?.getCamera().ratio ?? 1);
|
|
182
|
+
const opacityColor = (color, opacity) => {
|
|
183
|
+
const hex = /^#([0-9a-f]{6})$/i.exec(color);
|
|
184
|
+
const rgb = hex ? [0, 2, 4].map(offset => parseInt(hex[1].slice(offset, offset + 2), 16)) : color.match(/[\d.]+/g)?.slice(0, 3);
|
|
185
|
+
const alpha = color.startsWith('rgba') ? Number(color.match(/[\d.]+/g)?.[3] ?? 1) : 1;
|
|
186
|
+
// Sigma uses ONE / ONE_MINUS_SRC_ALPHA, so WebGL colors must be premultiplied.
|
|
187
|
+
// Canvas label/ring opacity is handled separately in drawDetailLabel.
|
|
188
|
+
return rgb?.length === 3 ? `rgba(${rgb.map(component => Math.round(Number(component) * opacity)).join(',')},${alpha * opacity})` : color;
|
|
189
|
+
};
|
|
190
|
+
const fadedColor = color => opacityColor(color, .16);
|
|
191
|
+
const cubicEase = (progress, x1, y1, x2, y2) => {
|
|
192
|
+
if (progress <= 0 || progress >= 1) return progress;
|
|
193
|
+
const cubic = (u, a, b) => 3 * (1 - u) ** 2 * u * a + 3 * (1 - u) * u ** 2 * b + u ** 3;
|
|
194
|
+
let low = 0, high = 1;
|
|
195
|
+
for (let i = 0; i < 16; i += 1) { const middle = (low + high) / 2; if (cubic(middle, x1, x2) < progress) low = middle; else high = middle; }
|
|
196
|
+
return cubic((low + high) / 2, y1, y2);
|
|
197
|
+
};
|
|
147
198
|
|
|
199
|
+
const popNode = (nodeId, data) => {
|
|
200
|
+
if (theme.preserveRootLabel === true && nodeId === options.rootId) data = { ...data, label: nodeById.get(nodeId)?.label ?? data.label, forceLabel: true };
|
|
201
|
+
if (!nodeTimings.has(nodeId) || popProgress >= 1) return data;
|
|
202
|
+
const timing = nodeTimings.get(nodeId);
|
|
203
|
+
const progress = Math.max(0, Math.min(1, (popElapsed + timing.offset - timing.delay) / 500));
|
|
204
|
+
const t = progress - 1;
|
|
205
|
+
let scale = 1 + 2.70158 * t * t * t + 1.70158 * t * t;
|
|
206
|
+
if (detailLayout) {
|
|
207
|
+
scale = cubicEase(progress, .3, 1.4, .5, 1);
|
|
208
|
+
}
|
|
209
|
+
const factor = 0.2 + 0.8 * scale;
|
|
210
|
+
const opacity = Math.min(1, Math.max(0, scale));
|
|
211
|
+
return { ...data, size: data.size * factor, ...(detailLayout ? { color: opacityColor(data.color, opacity), detailPopScale: factor, detailPopOpacity: opacity } : {}) };
|
|
212
|
+
};
|
|
148
213
|
const nodeReducer = (nodeId, data) => {
|
|
149
214
|
const base = { ...data };
|
|
215
|
+
if (detailLayout) {
|
|
216
|
+
const root = nodeId === options.rootId;
|
|
217
|
+
const selected = nodeId === selectedId && !root;
|
|
218
|
+
const dim = !root && (filterIds && !filterIds.has(nodeId) || selectedId && selectedId !== options.rootId && !selected);
|
|
219
|
+
return popNode(nodeId, { ...base, size: (root ? 17 : selected ? 10 : 8) * metricScale(), color: dim ? fadedColor(base.baseColor) : base.baseColor, label: base.label, forceLabel: true, highlighted: false, detailRoot: root, detailSelected: selected || root && (!selectedId || selectedId === options.rootId), detailDim: Boolean(dim) });
|
|
220
|
+
}
|
|
221
|
+
if (filterIds && !filterIds.has(nodeId)) return popNode(nodeId, { ...base, color: themeColor('unrelated', UNRELATED_COLOR), label: null, forceLabel: false, size: Math.min(base.size, 4) });
|
|
150
222
|
const neighbors = getNeighbors();
|
|
151
|
-
if (!selectedId) return base;
|
|
223
|
+
if (!selectedId) return popNode(nodeId, base);
|
|
152
224
|
const presentation = projectGraphNodePresentation(
|
|
153
225
|
{ id: nodeId, size: base.size },
|
|
154
226
|
{ selectedId, neighborIds: neighbors },
|
|
155
227
|
);
|
|
156
228
|
const { state, ...visuals } = presentation;
|
|
157
|
-
if (state === 'selected') return { ...base, ...visuals, color: SELECTED_COLOR };
|
|
158
|
-
if (state === 'neighbor') return {
|
|
229
|
+
if (state === 'selected') return popNode(nodeId, { ...base, ...visuals, color: theme.preserveSelectedTypeColor === true ? base.baseColor || base.color || themeColor('selected', SELECTED_COLOR) : themeColor('selected', SELECTED_COLOR) });
|
|
230
|
+
if (state === 'neighbor') return popNode(nodeId, {
|
|
159
231
|
...base,
|
|
160
232
|
...visuals,
|
|
161
233
|
color: base.baseColor || PROJECT_GRAPH_TYPE_COLORS.unknown,
|
|
162
|
-
};
|
|
163
|
-
return {
|
|
234
|
+
});
|
|
235
|
+
return popNode(nodeId, {
|
|
164
236
|
...base,
|
|
165
237
|
...visuals,
|
|
166
|
-
color: UNRELATED_COLOR,
|
|
167
|
-
};
|
|
238
|
+
color: themeColor('unrelated', UNRELATED_COLOR),
|
|
239
|
+
});
|
|
168
240
|
};
|
|
169
241
|
|
|
170
242
|
const edgeReducer = (edgeId, data) => {
|
|
171
243
|
const edge = edgeById.get(edgeId);
|
|
172
244
|
const base = { ...data };
|
|
245
|
+
if (detailLayout && edge) {
|
|
246
|
+
const selected = selectedId && selectedId !== options.rootId && (edge.source === selectedId || edge.target === selectedId);
|
|
247
|
+
const dim = Boolean(filterIds && (!filterIds.has(edge.source) || !filterIds.has(edge.target)) || selectedId && selectedId !== options.rootId && !selected);
|
|
248
|
+
const color = themeColor(selected ? 'selected' : 'edge', base.baseColor || DEFAULT_EDGE_COLOR);
|
|
249
|
+
let displayColor = dim ? fadedColor(color) : color;
|
|
250
|
+
const timing = edgeTimings.get(edgeId);
|
|
251
|
+
if (timing && popProgress < 1) displayColor = opacityColor(displayColor, cubicEase(Math.max(0, Math.min(1, (popElapsed + timing.offset - timing.delay) / 500)), 0, 0, .58, 1));
|
|
252
|
+
return { ...base, label: null, forceLabel: false, // EdgeRectangleProgram feathers one device pixel inside its geometric width.
|
|
253
|
+
// Restore that coverage in screen space; keep the reference stroke width zoom-scaled.
|
|
254
|
+
size: (selected ? 2 : 1.2) * metricScale() + (renderer?.getCamera().ratio ?? 1) / (motionWindow?.devicePixelRatio || 1), color: displayColor };
|
|
255
|
+
}
|
|
256
|
+
if (filterIds && edge && (!filterIds.has(edge.source) || !filterIds.has(edge.target))) return { ...base, label: null, forceLabel: false, color: themeColor('unrelatedEdge', UNRELATED_EDGE_COLOR), size: 0.5 };
|
|
173
257
|
if (!selectedId || !edge) {
|
|
174
258
|
return {
|
|
175
259
|
...base,
|
|
176
260
|
label: null,
|
|
177
261
|
forceLabel: false,
|
|
178
|
-
color: base.baseColor || DEFAULT_EDGE_COLOR,
|
|
262
|
+
color: themeColor('edge', base.baseColor || DEFAULT_EDGE_COLOR),
|
|
179
263
|
};
|
|
180
264
|
}
|
|
181
265
|
const neighbors = getNeighbors();
|
|
@@ -188,7 +272,7 @@ export function mountProjectGraph(container, options = {}) {
|
|
|
188
272
|
...base,
|
|
189
273
|
label: null,
|
|
190
274
|
forceLabel: false,
|
|
191
|
-
color: UNRELATED_EDGE_COLOR,
|
|
275
|
+
color: themeColor('unrelatedEdge', UNRELATED_EDGE_COLOR),
|
|
192
276
|
size: 0.5,
|
|
193
277
|
};
|
|
194
278
|
}
|
|
@@ -196,12 +280,18 @@ export function mountProjectGraph(container, options = {}) {
|
|
|
196
280
|
...base,
|
|
197
281
|
label: presentation.showLabel ? edge.label : null,
|
|
198
282
|
forceLabel: presentation.forceLabel,
|
|
199
|
-
color: edge.color || DEFAULT_EDGE_COLOR,
|
|
283
|
+
color: themeColor('edge', edge.color || DEFAULT_EDGE_COLOR),
|
|
200
284
|
size: 1.5,
|
|
201
285
|
};
|
|
202
286
|
};
|
|
203
287
|
|
|
204
288
|
const updateStatus = () => {
|
|
289
|
+
if (detailLayout) {
|
|
290
|
+
const selected = nodeById.get(selectedId) ?? nodeById.get(options.rootId);
|
|
291
|
+
setText(status, `${selected?.label ?? ''}を選択中。 線は、記録された関係だけを表します。`);
|
|
292
|
+
status.setAttribute('aria-description', `${model.nodes.length}件の対象、${model.edges.length}件の関係。`);
|
|
293
|
+
return;
|
|
294
|
+
}
|
|
205
295
|
if (!selectedId) {
|
|
206
296
|
setText(status, `${model.nodes.length}件の対象、${model.edges.length}件の関係。点を選択すると周辺を強調します。`);
|
|
207
297
|
return;
|
|
@@ -218,14 +308,43 @@ export function mountProjectGraph(container, options = {}) {
|
|
|
218
308
|
const setSelected = (nextId, { notify = true } = {}) => {
|
|
219
309
|
if (destroyed) return;
|
|
220
310
|
selectedId = nextId && nodeById.has(nextId) ? nextId : null;
|
|
311
|
+
for (const [id, button] of nodeControls) button.setAttribute('aria-pressed', String(id === selectedId));
|
|
221
312
|
neighborIds = projectGraphNeighborIds(model.nodes, model.edges, selectedId);
|
|
222
313
|
updateStatus();
|
|
223
314
|
if (renderer) renderer.refresh();
|
|
224
315
|
if (notify) notifySelection();
|
|
225
316
|
};
|
|
226
317
|
|
|
318
|
+
const drawDetailLabel = (context, data) => {
|
|
319
|
+
const scale = visualScale() * (data.detailPopScale ?? 1);
|
|
320
|
+
const root = data.detailRoot;
|
|
321
|
+
const cos = data.detailCos;
|
|
322
|
+
const right = !root && cos > .25, left = !root && cos < -.25;
|
|
323
|
+
const dx = right ? 15 : left ? -15 : 0;
|
|
324
|
+
const modelNode = nodeById.get(data.key);
|
|
325
|
+
const dy = root ? 38 : right || left ? 4 : modelNode?.y > 290 ? -15 : 24;
|
|
326
|
+
let label = root || data.label.length <= 11 ? data.label : `${data.label.slice(0, 10)}…`;
|
|
327
|
+
context.save();context.globalAlpha = (data.detailDim ? .16 : 1) * (data.detailPopOpacity ?? 1);
|
|
328
|
+
context.beginPath();context.arc(data.x, data.y, data.size, 0, Math.PI * 2);
|
|
329
|
+
const focused = focusedId === data.key;
|
|
330
|
+
context.strokeStyle = themeColor(focused ? 'focus' : data.detailSelected ? 'selected' : 'paper', '#ffffff');context.lineWidth = (focused ? 4 : data.detailSelected ? 2.5 : 3) * scale;context.stroke();
|
|
331
|
+
context.font = `${root || data.detailSelected || hoveredId === data.key ? 700 : 500} ${(root ? 13 : 11.5) * scale}px ${theme.fontFamily || 'sans-serif'}`;
|
|
332
|
+
if (isMobile()) {
|
|
333
|
+
const x = data.x + dx * scale;
|
|
334
|
+
const available = Math.max(0, right ? surface.clientWidth - x - 4 : left ? x - 4 : 2 * Math.min(x - 4, surface.clientWidth - x - 4));
|
|
335
|
+
if (context.measureText(label).width > available) {
|
|
336
|
+
let text = data.label;
|
|
337
|
+
while (text.length && context.measureText(`${text}…`).width > available) text = text.slice(0, -1);
|
|
338
|
+
label = context.measureText(`${text}…`).width <= available ? `${text}…` : '';
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
context.textAlign = right ? 'left' : left ? 'right' : 'center';context.textBaseline = 'alphabetic';
|
|
342
|
+
context.lineJoin = 'round';context.lineWidth = 4 * scale;context.strokeStyle = themeColor('paper', '#ffffff');
|
|
343
|
+
context.strokeText(label, data.x + dx * scale, data.y + dy * scale);
|
|
344
|
+
context.fillStyle = themeColor(root || data.detailSelected || hoveredId === data.key ? 'ink' : 'slate', '#24324b');context.fillText(label, data.x + dx * scale, data.y + dy * scale);context.restore();
|
|
345
|
+
};
|
|
227
346
|
try {
|
|
228
|
-
renderer = new Sigma(makeGraph(model), surface, {
|
|
347
|
+
renderer = new Sigma(makeGraph(model, detailLayout), surface, {
|
|
229
348
|
allowInvalidContainer: true,
|
|
230
349
|
renderLabels: true,
|
|
231
350
|
renderEdgeLabels: true,
|
|
@@ -238,6 +357,7 @@ export function mountProjectGraph(container, options = {}) {
|
|
|
238
357
|
defaultEdgeColor: DEFAULT_EDGE_COLOR,
|
|
239
358
|
nodeReducer,
|
|
240
359
|
edgeReducer,
|
|
360
|
+
...(detailLayout ? { stagePadding: 0, itemSizesReference: 'screen', zoomToSizeRatioFunction: ratio => ratio, minCameraRatio: 1 / 1.8, maxCameraRatio: 1 / .7, enableCameraRotation: false, minEdgeThickness: .1, renderEdgeLabels: false, defaultDrawNodeLabel: drawDetailLabel, defaultDrawNodeHover: () => {} } : {}),
|
|
241
361
|
});
|
|
242
362
|
} catch (error) {
|
|
243
363
|
// A missing WebGL context is a renderer capability failure. Let the host
|
|
@@ -247,30 +367,86 @@ export function mountProjectGraph(container, options = {}) {
|
|
|
247
367
|
throw error;
|
|
248
368
|
}
|
|
249
369
|
|
|
370
|
+
if (detailLayout) renderer.setCustomBBox({ x: [0, 760], y: [0, 540] });
|
|
371
|
+
const onCameraUpdate = () => { if (isMobile()) renderer?.refresh(); };
|
|
372
|
+
if (detailLayout) renderer.getCamera().on('updated', onCameraUpdate);
|
|
373
|
+
|
|
250
374
|
if (signal?.aborted) {
|
|
251
375
|
renderer.kill();
|
|
252
376
|
mountRoot.remove();
|
|
253
377
|
throw abortError();
|
|
254
378
|
}
|
|
255
379
|
|
|
380
|
+
if (isRecord(options.cameraState) && ['x', 'y', 'angle', 'ratio'].every(key => Number.isFinite(options.cameraState[key])) && options.cameraState.ratio > 0) renderer.getCamera().setState(options.cameraState);
|
|
381
|
+
if (animateNewNodes) {
|
|
382
|
+
let started;
|
|
383
|
+
const advance = time => {
|
|
384
|
+
if (destroyed) return;
|
|
385
|
+
started ??= time;
|
|
386
|
+
popElapsed = time - started;
|
|
387
|
+
popProgress = Math.min(1, popElapsed / revealDuration);
|
|
388
|
+
renderer?.refresh();
|
|
389
|
+
popFrame = popProgress < 1 ? motionWindow.requestAnimationFrame(advance) : null;
|
|
390
|
+
};
|
|
391
|
+
popFrame = motionWindow.requestAnimationFrame(advance);
|
|
392
|
+
}
|
|
393
|
+
|
|
256
394
|
const onNodeClick = ({ node }) => setSelected(node);
|
|
257
395
|
const onStageClick = () => setSelected(null);
|
|
258
396
|
renderer.on('clickNode', onNodeClick);
|
|
259
397
|
renderer.on('clickStage', onStageClick);
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
398
|
+
const detailZoom = delta => {
|
|
399
|
+
const camera = renderer.getCamera(), state = camera.getState();
|
|
400
|
+
const ratio = 1 / Math.min(1.8, Math.max(.7, 1 / state.ratio + delta));
|
|
401
|
+
const root = { x: .5, y: .5 + 20 / 760 };
|
|
402
|
+
const next = { ratio, x: root.x + (state.x - root.x) * ratio / state.ratio, y: root.y + (state.y - root.y) * ratio / state.ratio };
|
|
403
|
+
camera.setState(next);
|
|
404
|
+
};
|
|
405
|
+
onZoomIn = () => detailLayout ? detailZoom(.2) : renderer?.getCamera().animatedZoom({ factor: 1.5 });
|
|
406
|
+
onZoomOut = () => detailLayout ? detailZoom(-.2) : renderer?.getCamera().animatedUnzoom({ factor: 1.5 });
|
|
407
|
+
onReset = () => detailLayout ? renderer?.getCamera().setState({ x: .5, y: .5, ratio: 1, angle: 0 }) : renderer?.getCamera().animatedReset();
|
|
263
408
|
zoomIn.addEventListener('click', onZoomIn);
|
|
264
409
|
zoomOut.addEventListener('click', onZoomOut);
|
|
265
410
|
reset.addEventListener('click', onReset);
|
|
266
411
|
setSelected(options?.selectedId || null, { notify: false });
|
|
412
|
+
if (detailLayout) {
|
|
413
|
+
const controls = doc.createElement('div');
|
|
414
|
+
controls.setAttribute('role', 'group');controls.setAttribute('aria-label', 'プロジェクトの関係グラフ');
|
|
415
|
+
for (const node of [...model.nodes.filter(node => node.id !== options.rootId), ...model.nodes.filter(node => node.id === options.rootId)]) {
|
|
416
|
+
const button = makeButton(doc, node.label, node.label);
|
|
417
|
+
button.className = 'bb-ws-visually-hidden bb-project-graph-node-focus';
|
|
418
|
+
button.setAttribute('data-graph-node-id', node.id);
|
|
419
|
+
button.setAttribute('aria-pressed', String(node.id === selectedId));
|
|
420
|
+
button.addEventListener('focus', () => { focusedId = node.id; renderer?.refresh(); });
|
|
421
|
+
button.addEventListener('blur', () => { if (focusedId === node.id) focusedId = null; renderer?.refresh(); });
|
|
422
|
+
button.addEventListener('click', () => setSelected(node.id));
|
|
423
|
+
nodeControls.set(node.id, button);controls.append(button);
|
|
424
|
+
}
|
|
425
|
+
mountRoot.insertBefore(controls, toolbar);
|
|
426
|
+
rootFallback = container.querySelector('[data-graph-root-fallback]');
|
|
427
|
+
if (rootFallback) {
|
|
428
|
+
rootFallbackState = { hidden: rootFallback.hidden, tabindex: rootFallback.getAttribute('tabindex'), ariaHidden: rootFallback.getAttribute('aria-hidden') };
|
|
429
|
+
rootFallback.hidden = true;rootFallback.setAttribute('tabindex', '-1');rootFallback.setAttribute('aria-hidden', 'true');
|
|
430
|
+
}
|
|
431
|
+
}
|
|
432
|
+
const onEnterNode = ({ node }) => { hoveredId = node; if (detailLayout) { surface.title = nodeById.get(node)?.label ?? ''; renderer.refresh(); } };
|
|
433
|
+
const onLeaveNode = () => { hoveredId = null; if (detailLayout) { surface.removeAttribute('title'); renderer.refresh(); } };
|
|
434
|
+
if (detailLayout) { renderer.on('enterNode', onEnterNode);renderer.on('leaveNode', onLeaveNode); }
|
|
267
435
|
|
|
268
436
|
const destroy = () => {
|
|
269
437
|
if (destroyed) return;
|
|
270
438
|
destroyed = true;
|
|
439
|
+
if (popFrame !== null) motionWindow?.cancelAnimationFrame?.(popFrame);
|
|
440
|
+
if (rootFallback && rootFallbackState) {
|
|
441
|
+
rootFallback.hidden = rootFallbackState.hidden;
|
|
442
|
+
for (const [attribute, value] of [['tabindex', rootFallbackState.tabindex], ['aria-hidden', rootFallbackState.ariaHidden]]) if (value === null) rootFallback.removeAttribute(attribute);else rootFallback.setAttribute(attribute, value);
|
|
443
|
+
}
|
|
444
|
+
nodeControls.clear();
|
|
271
445
|
if (signal && abortListener) signal.removeEventListener('abort', abortListener);
|
|
272
446
|
renderer?.off('clickNode', onNodeClick);
|
|
273
447
|
renderer?.off('clickStage', onStageClick);
|
|
448
|
+
if (detailLayout) { renderer?.off('enterNode', onEnterNode);renderer?.off('leaveNode', onLeaveNode); }
|
|
449
|
+
if (detailLayout) renderer?.getCamera().off('updated', onCameraUpdate);
|
|
274
450
|
zoomIn.removeEventListener('click', onZoomIn);
|
|
275
451
|
zoomOut.removeEventListener('click', onZoomOut);
|
|
276
452
|
reset.removeEventListener('click', onReset);
|
|
@@ -287,6 +463,9 @@ export function mountProjectGraph(container, options = {}) {
|
|
|
287
463
|
select: (nodeId) => setSelected(nodeId),
|
|
288
464
|
getSelectedId: () => selectedId,
|
|
289
465
|
getModel: () => model,
|
|
466
|
+
getCameraState: () => renderer?.getCamera().getState() ?? null,
|
|
467
|
+
getRevealState: () => animateNewNodes && popProgress < 1 ? { nodes: [...nodeTimings].map(([id, t]) => ({ id, elapsed: t.offset + popElapsed, delay: t.delay })), edges: [...edgeTimings].map(([id, t]) => ({ id, elapsed: t.offset + popElapsed, delay: t.delay })) } : null,
|
|
468
|
+
setFilter: (ids) => { filterIds = Array.isArray(ids) ? new Set(ids) : null; renderer?.refresh(); },
|
|
290
469
|
};
|
|
291
470
|
}
|
|
292
471
|
|
package/ui/project-graph.js
CHANGED
|
@@ -321,6 +321,13 @@ export function computeProjectGraphLayout(nodes, edges = EMPTY_ARRAY, { selected
|
|
|
321
321
|
/** Creates the fully positioned graph model used by the browser entry. */
|
|
322
322
|
export function createProjectGraphModel(input = {}, options = {}) {
|
|
323
323
|
const normalized = normalizeProjectGraph(input);
|
|
324
|
+
if (options.layout === 'project-detail') {
|
|
325
|
+
const order = new Map();
|
|
326
|
+
(input.nodes ?? []).forEach((node, index) => { if (node?.id && !order.has(node.id)) order.set(node.id, index); });
|
|
327
|
+
const nodes = normalized.nodes.slice().sort((a, b) => order.get(a.id) - order.get(b.id));
|
|
328
|
+
const positions = computeProjectDetailGraphLayout(nodes, options.selectedId);
|
|
329
|
+
return { ...normalized, nodes: nodes.map(node => ({ ...node, ...positions[node.id], size: node.id === options.selectedId ? 17 : 8 })) };
|
|
330
|
+
}
|
|
324
331
|
const positions = computeProjectGraphLayout(normalized.nodes, normalized.edges, options);
|
|
325
332
|
return {
|
|
326
333
|
...normalized,
|
|
@@ -328,6 +335,19 @@ export function createProjectGraphModel(input = {}, options = {}) {
|
|
|
328
335
|
};
|
|
329
336
|
}
|
|
330
337
|
|
|
338
|
+
/** Existing input order and real nodes only. Sigma y points up: SVG y=540-y. */
|
|
339
|
+
export function computeProjectDetailGraphLayout(nodes, rootId) {
|
|
340
|
+
const result = Object.create(null);
|
|
341
|
+
const peers = nodes.filter(node => node.id !== rootId);
|
|
342
|
+
if (nodes.some(node => node.id === rootId)) result[rootId] = { x: 380, y: 290 };
|
|
343
|
+
peers.forEach((node, index) => {
|
|
344
|
+
const angle = -Math.PI / 2 + index / peers.length * Math.PI * 2;
|
|
345
|
+
const radius = index % 2 ? 190 : 140;
|
|
346
|
+
result[node.id] = { x: Number((380 + Math.cos(angle) * radius * 1.12).toFixed(1)), y: Number((290 - Math.sin(angle) * radius).toFixed(1)), detailCos: Math.cos(angle) };
|
|
347
|
+
});
|
|
348
|
+
return result;
|
|
349
|
+
}
|
|
350
|
+
|
|
331
351
|
/**
|
|
332
352
|
* Lazy browser entry. Keeping the renderer behind this boundary means the
|
|
333
353
|
* local Graph screen can import this module in Node-based UI tests without
|
package/ui/project-overview.js
CHANGED
|
@@ -6,8 +6,8 @@
|
|
|
6
6
|
* shared Graph payload.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
import { formatDateTime, makeElement, textOrNull } from './graph-view-shared.js';
|
|
10
|
-
import { workspaceNotice } from './workspace-kit.js';
|
|
9
|
+
import { formatDateTime, makeElement, textOrNull, validityText } from './graph-view-shared.js';
|
|
10
|
+
import { workspaceNotice, workspaceSummaryCard, workspaceIdentityChip, workspaceAvatar, workspaceStatusPill, workspaceCardRow, workspaceActionIcon, workspaceButton } from './workspace-kit.js';
|
|
11
11
|
|
|
12
12
|
const MATERIAL_STATES = new Set(['ok', 'partial', 'unknown', 'failed', 'unavailable', 'loading']);
|
|
13
13
|
const BODY_STATES = new Set(['retrieved', 'unretrieved', 'unavailable', 'failed', 'unknown']);
|
|
@@ -53,7 +53,14 @@ function normalizeMaterialItem(item) {
|
|
|
53
53
|
const contentAsOf = normalizeDate(item.contentAsOf);
|
|
54
54
|
const updatedAt = normalizeDate(item.updatedAt);
|
|
55
55
|
if (!id && !relation && !source && !contentAsOf && !updatedAt && bodyState === 'unknown' && title === '資料名未確認') return null;
|
|
56
|
-
|
|
56
|
+
const normalized = { id, title, relation, source, bodyState, contentAsOf, updatedAt };
|
|
57
|
+
for (const key of ['body', 'description', 'summary', 'relatedTaskId', 'sourceRecordId', 'sourcePath', 'validFrom', 'validTo']) {
|
|
58
|
+
const value = cleanText(item[key]);
|
|
59
|
+
if (value) normalized[key] = value;
|
|
60
|
+
}
|
|
61
|
+
for (const key of ['relatedTaskIds', 'recordIds', 'unknowns']) if (Array.isArray(item[key])) normalized[key] = item[key].map(cleanText).filter(Boolean);
|
|
62
|
+
if (item.provenance && typeof item.provenance === 'object' && !Array.isArray(item.provenance)) normalized.provenance = { ...item.provenance };
|
|
63
|
+
return normalized;
|
|
57
64
|
}
|
|
58
65
|
|
|
59
66
|
function normalizeMaterials(value) {
|
|
@@ -261,3 +268,108 @@ export function renderProjectOverview(doc, value, { projectName = 'プロジェ
|
|
|
261
268
|
);
|
|
262
269
|
return root;
|
|
263
270
|
}
|
|
271
|
+
|
|
272
|
+
/** Existing material evidence retained while a host adopts the tabbed layout. */
|
|
273
|
+
export function renderProjectOverviewMaterials(doc, value, { projectName = 'プロジェクト', actions = {} } = {}) {
|
|
274
|
+
const overview = normalizeProjectOverview(value);
|
|
275
|
+
if (!overview) return null;
|
|
276
|
+
const root = makeElement(doc, 'div', { className: 'bb-pkw-overview-evidence' });
|
|
277
|
+
root.append(renderMaterials(doc, `${projectName}に直接紐づく資料`, overview.directMaterials, actions), renderMaterials(doc, '関連資料', overview.relatedMaterials, actions));
|
|
278
|
+
return root;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/** The opt-in overview only rearranges supplied values; it performs no reads. */
|
|
282
|
+
export function renderProjectDetailOverview(doc, detail, { actions = {}, config = {}, context = null, participants = [], participantNotice = null, participantCount = null } = {}) {
|
|
283
|
+
const project = detail.project;
|
|
284
|
+
const overview = normalizeProjectOverview(detail.overview);
|
|
285
|
+
const about = overview?.about ?? {};
|
|
286
|
+
const root = makeElement(doc, 'div', { className: 'bb-project-overview' });
|
|
287
|
+
const slotContext = { document: doc, project, detail, context, actions };
|
|
288
|
+
const facts = (items, className) => {
|
|
289
|
+
const list = makeElement(doc, 'dl', { className });
|
|
290
|
+
for (const [label, content, wide] of items) {
|
|
291
|
+
const item = makeElement(doc, 'div', { className: wide ? 'is-wide' : '' });
|
|
292
|
+
const value = makeElement(doc, 'dd', { className: content ? '' : 'is-unknown' });
|
|
293
|
+
value.append(typeof content === 'object' && content ? content : makeElement(doc, 'span', { text: content ?? '未確認' }));
|
|
294
|
+
item.append(makeElement(doc, 'dt', { text: label }), value); list.append(item);
|
|
295
|
+
}
|
|
296
|
+
return list;
|
|
297
|
+
};
|
|
298
|
+
const namedPerson = (name) => {
|
|
299
|
+
if (!name) return null;
|
|
300
|
+
const node = makeElement(doc, 'span', { className: 'bb-project-overview-person' });
|
|
301
|
+
node.append(workspaceAvatar(doc, { name }), makeElement(doc, 'span', { text: name })); return node;
|
|
302
|
+
};
|
|
303
|
+
const main = makeElement(doc, 'div');
|
|
304
|
+
const purpose = textOrNull(project.goal);
|
|
305
|
+
main.append(makeElement(doc, 'h3', { className: `bb-project-overview-purpose${purpose ? '' : ' is-unknown'}`, text: purpose ?? '目的はまだ登録されていません' }));
|
|
306
|
+
main.append(facts([
|
|
307
|
+
['現在の目標', about.goal, true],
|
|
308
|
+
['状態', project.status ? workspaceStatusPill(doc, { label: project.status, appearance: 'compact' }) : null],
|
|
309
|
+
['責任者', namedPerson(about.owner)],
|
|
310
|
+
['最終決裁', namedPerson(about.finalApprover)],
|
|
311
|
+
], 'bb-project-overview-facts'));
|
|
312
|
+
const principles = Array.isArray(project.decisionPrinciples) ? project.decisionPrinciples.map(textOrNull).filter(Boolean) : [];
|
|
313
|
+
const principleList = principles.length ? makeElement(doc, 'ul') : null;
|
|
314
|
+
for (const principle of principles) principleList.append(makeElement(doc, 'li', { text: principle }));
|
|
315
|
+
const identity = makeElement(doc, 'span', { className: 'bb-project-overview-identity' });
|
|
316
|
+
identity.append(makeElement(doc, 'code', { text: project.id }));
|
|
317
|
+
if (typeof config.onCopyId === 'function') {
|
|
318
|
+
const copy = workspaceButton(doc, { variant: 'icon', attrs: { 'aria-label': 'IDをコピー', title: 'IDをコピー' }, onClick: () => config.onCopyId(project.id, copy) });
|
|
319
|
+
copy.append(workspaceActionIcon(doc, 'copy')); identity.append(copy);
|
|
320
|
+
}
|
|
321
|
+
main.append(facts([
|
|
322
|
+
['判断の原則', principleList, true],
|
|
323
|
+
['有効期間', validityText(project.validFrom, project.validTo)],
|
|
324
|
+
['ID', identity],
|
|
325
|
+
['出典', about.source ?? textOrNull(detail.source?.authority) ?? textOrNull(detail.source)],
|
|
326
|
+
['取得日時', displayDate(about.asOf ?? detail.asOf)],
|
|
327
|
+
], 'bb-project-overview-fine'));
|
|
328
|
+
if (typeof config.onOpenFoundation === 'function') {
|
|
329
|
+
const foot = makeElement(doc, 'div', { className: 'bb-project-overview-footer' });
|
|
330
|
+
foot.append(makeElement(doc, 'button', { className: 'bb-project-overview-link', text: '目的と現状で見る', attrs: { type: 'button' } }));
|
|
331
|
+
foot.children[0].addEventListener('click', () => config.onOpenFoundation(project.id)); main.append(foot);
|
|
332
|
+
}
|
|
333
|
+
const next = typeof config.renderNext === 'function' ? config.renderNext(slotContext) : null;
|
|
334
|
+
const stripe = typeof config.getStripe === 'function' ? config.getStripe(project) : config.stripe;
|
|
335
|
+
root.append(workspaceSummaryCard(doc, { content: main, aside: next, stripe, label: 'このプロジェクトについて' }));
|
|
336
|
+
const heading = (title, count, unit = '件') => {
|
|
337
|
+
const node = makeElement(doc, 'div', { className: 'bb-project-overview-heading' });
|
|
338
|
+
node.append(makeElement(doc, 'h3', { text: title }));
|
|
339
|
+
if (count > 0) node.append(makeElement(doc, 'small', { text: `${count}${unit}` }));
|
|
340
|
+
return node;
|
|
341
|
+
};
|
|
342
|
+
// Empty checks historically mean unknown. Only an explicit successful state
|
|
343
|
+
// supplied alongside the array can establish that no checks remain.
|
|
344
|
+
const checks = overview?.checks ?? [];
|
|
345
|
+
if (checks.length || detail.overview?.checksState !== 'ok') {
|
|
346
|
+
const section = makeElement(doc, 'section', { className: 'bb-project-overview-checks', attrs: { 'aria-label': '次に確認すること' } });
|
|
347
|
+
section.append(heading('次に確認すること', checks.length));
|
|
348
|
+
if (!checks.length) section.append(makeElement(doc, 'p', { className: 'bb-pkw-muted', text: '確認事項は未確認です。' }));
|
|
349
|
+
for (const check of checks) {
|
|
350
|
+
const text = makeElement(doc, 'span'); text.append(makeElement(doc, 'strong', { text: check.title }));
|
|
351
|
+
if (check.summary) text.append(makeElement(doc, 'small', { text: check.summary }));
|
|
352
|
+
section.append(workspaceCardRow(doc, { cells: [text, workspaceStatusPill(doc, { label: '未確認', tone: 'warning', width: 68 })], stripe: 'var(--bb-color-warning-soft)', onSelect: check.recordId && actions.selectEntity ? () => actions.selectEntity(check.recordId) : undefined }));
|
|
353
|
+
}
|
|
354
|
+
root.append(section);
|
|
355
|
+
}
|
|
356
|
+
const people = makeElement(doc, 'section', { attrs: { 'aria-label': '関係者' } });
|
|
357
|
+
people.append(heading('関係者', participantCount, '人'));
|
|
358
|
+
if (participantNotice) people.append(participantNotice);
|
|
359
|
+
if (participants.length) {
|
|
360
|
+
const chips = makeElement(doc, 'div', { className: 'bb-project-overview-people' });
|
|
361
|
+
for (const edge of participants) {
|
|
362
|
+
const person = edge.counterpart;
|
|
363
|
+
chips.append(workspaceIdentityChip(doc, { name: person.name ?? person.title, detail: edge.role, label: `${person.name ?? person.title}を「情報を探す」で開く`, onClick: () => actions.selectEntity?.(person.id) }));
|
|
364
|
+
}
|
|
365
|
+
people.append(chips);
|
|
366
|
+
}
|
|
367
|
+
root.append(people);
|
|
368
|
+
if (typeof config.renderConnections === 'function') {
|
|
369
|
+
const connections = makeElement(doc, 'section', { className: 'bb-project-overview-connections', attrs: { 'aria-label': '接続先' } });
|
|
370
|
+
connections.append(heading('接続先'));
|
|
371
|
+
const content = config.renderConnections(slotContext); if (content) connections.append(content);
|
|
372
|
+
root.append(connections);
|
|
373
|
+
}
|
|
374
|
+
return root;
|
|
375
|
+
}
|