@transitrix/diagrams 1.12.0 → 1.12.2
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/dist/capability-map/CapabilityCardNode.d.ts +1 -0
- package/dist/capability-map/CapabilityCardNode.js +5 -4
- package/dist/capability-map/CapabilityMapView.js +1 -0
- package/dist/capability-map/dsm-layout.js +5 -4
- package/dist/capability-map/dsm-schema.d.ts +1 -0
- package/dist/edge-path.d.ts +17 -0
- package/dist/edge-path.js +33 -4
- package/dist/fgca/index.d.ts +1 -1
- package/dist/fgca/index.js +1 -1
- package/dist/fgca/preview-layout.d.ts +24 -4
- package/dist/fgca/preview-layout.js +178 -2
- package/dist/goals/GoalNode.d.ts +1 -0
- package/dist/goals/GoalNode.js +5 -4
- package/dist/goals/GoalTreeView.js +1 -0
- package/dist/goals/layout.js +7 -5
- package/dist/goals/types.d.ts +2 -0
- package/dist/scope.d.ts +27 -0
- package/dist/scope.js +40 -0
- package/dist/webview/render-fgca.d.ts +3 -0
- package/dist/webview/render-fgca.js +5 -3
- package/dist/webview/render-goals.d.ts +3 -0
- package/dist/webview/render-goals.js +5 -5
- package/package.json +1 -1
- package/src/capability-map/CapabilityCardNode.tsx +8 -6
- package/src/capability-map/CapabilityMapView.tsx +1 -0
- package/src/capability-map/dsm-layout.ts +5 -4
- package/src/capability-map/dsm-schema.ts +1 -0
- package/src/edge-path.ts +45 -4
- package/src/fgca/index.ts +2 -0
- package/src/fgca/preview-layout.ts +205 -5
- package/src/goals/GoalNode.tsx +8 -6
- package/src/goals/GoalTreeView.tsx +1 -0
- package/src/goals/layout.ts +7 -5
- package/src/goals/types.ts +2 -0
- package/src/scope.ts +61 -0
- package/src/webview/render-fgca.ts +7 -2
- package/src/webview/render-goals.ts +7 -5
|
@@ -9,7 +9,7 @@ function latestMaturityLevel(cap) {
|
|
|
9
9
|
return [...cap.maturity].sort((a, b) => b.date.localeCompare(a.date))[0].level;
|
|
10
10
|
}
|
|
11
11
|
const CapabilityCardNode = memo(({ data }) => {
|
|
12
|
-
const { capability, theme, maturityColours, readOnly, isDropTarget, hasHiddenChildren, isCollapsed } = data;
|
|
12
|
+
const { capability, theme, maturityColours, readOnly, isDropTarget, hasChildren, hasHiddenChildren, isCollapsed } = data;
|
|
13
13
|
const maturity = latestMaturityLevel(capability);
|
|
14
14
|
const dotColour = maturity !== undefined ? maturityColours[maturity] : undefined;
|
|
15
15
|
return (_jsxs("div", { style: {
|
|
@@ -53,14 +53,15 @@ const CapabilityCardNode = memo(({ data }) => {
|
|
|
53
53
|
position: 'absolute', bottom: -8, right: -8, width: 16, height: 16,
|
|
54
54
|
borderRadius: '50%', border: '1px solid #fca5a5', background: '#ffffff',
|
|
55
55
|
color: '#dc2626', fontSize: 11, lineHeight: '14px', padding: 0, cursor: 'pointer',
|
|
56
|
-
}, children: "\u00D7" })), hasHiddenChildren && (_jsx("button", { type: "button", "aria-label": isCollapsed ? 'Expand branch' : 'Collapse branch', title: isCollapsed ? 'Expand branch' : 'Collapse branch', onClick: (e) => {
|
|
56
|
+
}, children: "\u00D7" })), (hasChildren || hasHiddenChildren) && (_jsx("button", { type: "button", "aria-label": isCollapsed || hasHiddenChildren ? 'Expand branch' : 'Collapse branch', title: isCollapsed || hasHiddenChildren ? 'Expand branch' : 'Collapse branch', onClick: (e) => {
|
|
57
57
|
e.stopPropagation();
|
|
58
58
|
data.onToggleCollapse(capability.id);
|
|
59
59
|
}, style: {
|
|
60
60
|
position: 'absolute', top: '50%', right: -8, transform: 'translateY(-50%)',
|
|
61
61
|
width: 16, height: 16, borderRadius: '50%', border: `1px solid ${theme.cardBorderColor}`,
|
|
62
|
-
background: '#ffffff', color: theme.cardBorderColor, fontSize: 11, lineHeight: '14px', padding: 0,
|
|
63
|
-
|
|
62
|
+
background: '#ffffff', color: theme.cardBorderColor, fontSize: 11, lineHeight: '14px', padding: 0,
|
|
63
|
+
cursor: 'pointer', zIndex: 10,
|
|
64
|
+
}, children: isCollapsed || hasHiddenChildren ? '+' : '−' }))] }));
|
|
64
65
|
});
|
|
65
66
|
CapabilityCardNode.displayName = 'CapabilityCardNode';
|
|
66
67
|
export default CapabilityCardNode;
|
|
@@ -101,6 +101,7 @@ function CapabilityMapViewInner({ map, layout: layoutProp, layoutOptions, theme:
|
|
|
101
101
|
maturityColours,
|
|
102
102
|
readOnly,
|
|
103
103
|
isDropTarget: hoveredId === n.id,
|
|
104
|
+
hasChildren: n.hasChildren,
|
|
104
105
|
hasHiddenChildren: n.hasHiddenChildren,
|
|
105
106
|
isCollapsed: collapsedIds.has(n.id),
|
|
106
107
|
onAddChild,
|
|
@@ -68,11 +68,12 @@ export function layoutCapabilityMap(map, options = {}) {
|
|
|
68
68
|
const cap = byId.get(id);
|
|
69
69
|
const allChildIds = children.get(id) ?? [];
|
|
70
70
|
const childIds = allChildIds.filter((c) => !hiddenSubtrees.has(c));
|
|
71
|
+
const hasChildren = allChildIds.length > 0;
|
|
71
72
|
const hasHiddenChildren = childIds.length < allChildIds.length;
|
|
72
73
|
if (childIds.length === 0) {
|
|
73
74
|
const y = getNextY(col);
|
|
74
75
|
advanceY(col, nodeHeight + nodeSep);
|
|
75
|
-
nodes.push({ id, x: col * (nodeWidth + rankSep), y, width: nodeWidth, height: nodeHeight, data: cap, hasHiddenChildren });
|
|
76
|
+
nodes.push({ id, x: col * (nodeWidth + rankSep), y, width: nodeWidth, height: nodeHeight, data: cap, hasChildren, hasHiddenChildren });
|
|
76
77
|
return { top: y, bottom: y + nodeHeight };
|
|
77
78
|
}
|
|
78
79
|
const spans = childIds.map((cid) => placeSubtree(cid, col + 1));
|
|
@@ -82,7 +83,7 @@ export function layoutCapabilityMap(map, options = {}) {
|
|
|
82
83
|
const curColY = getNextY(col);
|
|
83
84
|
const finalY = Math.max(parentY, curColY);
|
|
84
85
|
advanceY(col, finalY - curColY + nodeHeight + nodeSep);
|
|
85
|
-
nodes.push({ id, x: col * (nodeWidth + rankSep), y: finalY, width: nodeWidth, height: nodeHeight, data: cap, hasHiddenChildren });
|
|
86
|
+
nodes.push({ id, x: col * (nodeWidth + rankSep), y: finalY, width: nodeWidth, height: nodeHeight, data: cap, hasChildren, hasHiddenChildren });
|
|
86
87
|
for (const cid of childIds)
|
|
87
88
|
edges.push({ source: id, target: cid });
|
|
88
89
|
return { top: Math.min(finalY, spanTop), bottom: Math.max(finalY + nodeHeight, spanBottom) };
|
|
@@ -95,7 +96,7 @@ export function layoutCapabilityMap(map, options = {}) {
|
|
|
95
96
|
columnNextY.set(col, y + nodeSep);
|
|
96
97
|
}
|
|
97
98
|
if (nodes.length === 0) {
|
|
98
|
-
const rootNode = { id: 0, x: 0, y: 0, width: ROOT_WIDTH, height: nodeHeight, data: null, hasHiddenChildren: false };
|
|
99
|
+
const rootNode = { id: 0, x: 0, y: 0, width: ROOT_WIDTH, height: nodeHeight, data: null, hasChildren: false, hasHiddenChildren: false };
|
|
99
100
|
return { rootNode, nodes: [], edges: [], bounds: { x: 0, y: 0, width: ROOT_WIDTH, height: nodeHeight } };
|
|
100
101
|
}
|
|
101
102
|
const minX = Math.min(...nodes.map((n) => n.x));
|
|
@@ -107,7 +108,7 @@ export function layoutCapabilityMap(map, options = {}) {
|
|
|
107
108
|
const rootTop = Math.min(...l1Nodes.map((n) => n.y));
|
|
108
109
|
const rootBottom = Math.max(...l1Nodes.map((n) => n.y + n.height));
|
|
109
110
|
const rootY = rootTop + (rootBottom - rootTop) / 2 - nodeHeight / 2;
|
|
110
|
-
const rootNode = { id: 0, x: 0, y: rootY, width: ROOT_WIDTH, height: nodeHeight, data: null, hasHiddenChildren: false };
|
|
111
|
+
const rootNode = { id: 0, x: 0, y: rootY, width: ROOT_WIDTH, height: nodeHeight, data: null, hasChildren: l1Ids.length > 0, hasHiddenChildren: false };
|
|
111
112
|
const rootEdges = l1Ids
|
|
112
113
|
.filter((id) => !hiddenSubtrees.has(id))
|
|
113
114
|
.map((id) => ({ source: 'root', target: id }));
|
package/dist/edge-path.d.ts
CHANGED
|
@@ -6,6 +6,18 @@
|
|
|
6
6
|
export declare const EDGE_MIN_HANDLE = 64;
|
|
7
7
|
/** Multiplier applied to the base handle length. 1 = historical appearance. */
|
|
8
8
|
export declare const DEFAULT_EDGE_CURVATURE = 1;
|
|
9
|
+
/** Path shape for Goals / DGCA / DGA preview edges. Default matches today's cubic. */
|
|
10
|
+
export type EdgeStyle = 'straight' | 'bezier' | 'polyline';
|
|
11
|
+
export declare const DEFAULT_EDGE_STYLE: EdgeStyle;
|
|
12
|
+
export declare function parseEdgeStyle(v: unknown): EdgeStyle;
|
|
13
|
+
/** Straight segment — the arrowhead follows the chord, not the node edge. */
|
|
14
|
+
export declare function straightEdgePath(sx: number, sy: number, tx: number, ty: number): string;
|
|
15
|
+
/**
|
|
16
|
+
* Orthogonal (Manhattan) polyline: horizontal out, vertical, horizontal in.
|
|
17
|
+
* The last segment is horizontal so `marker-end` still meets the node's
|
|
18
|
+
* vertical edge the same way the cubic does.
|
|
19
|
+
*/
|
|
20
|
+
export declare function orthogonalEdgePath(sx: number, sy: number, tx: number, ty: number): string;
|
|
9
21
|
/**
|
|
10
22
|
* Builds the SVG `d` for a horizontal-tangent cubic Bézier from (sx,sy) to
|
|
11
23
|
* (tx,ty).
|
|
@@ -35,3 +47,8 @@ export declare function horizontalCubicEdgePath(sx: number, sy: number, tx: numb
|
|
|
35
47
|
* it — see `render-activities.ts`'s `blockingNodes`/`bowY` for the margin.
|
|
36
48
|
*/
|
|
37
49
|
export declare function bowedCubicEdgePath(sx: number, sy: number, tx: number, ty: number, bowY: number, curvature?: number): string;
|
|
50
|
+
/**
|
|
51
|
+
* Picks the SVG `d` for a Goals / DGCA / DGA preview edge.
|
|
52
|
+
* Unknown styles fall back to the historical cubic.
|
|
53
|
+
*/
|
|
54
|
+
export declare function previewEdgePath(sx: number, sy: number, tx: number, ty: number, style?: EdgeStyle, curvature?: number, entryCurvature?: number): string;
|
package/dist/edge-path.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
// Shared edge geometry for the static notation previews (Goals, FGCA, FGA,
|
|
2
|
-
// Activities).
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
// arrow reads as perpendicular to the node's vertical edge.
|
|
2
|
+
// Activities). The default path is a cubic Bézier with horizontal control
|
|
3
|
+
// handles so the marker-end arrow sits flush on the node's vertical edge.
|
|
4
|
+
// Goals / DGCA / DGA can switch to a straight chord or an orthogonal polyline.
|
|
6
5
|
//
|
|
7
6
|
// Pulling the path math here (rather than duplicating it inline in each
|
|
8
7
|
// preview) makes the configurable-curvature behaviour
|
|
@@ -26,6 +25,25 @@ const DY_FACTOR = 0.8;
|
|
|
26
25
|
const MAX_HANDLE = 160;
|
|
27
26
|
/** Multiplier applied to the base handle length. 1 = historical appearance. */
|
|
28
27
|
export const DEFAULT_EDGE_CURVATURE = 1;
|
|
28
|
+
export const DEFAULT_EDGE_STYLE = 'bezier';
|
|
29
|
+
export function parseEdgeStyle(v) {
|
|
30
|
+
if (v === 'straight' || v === 'bezier' || v === 'polyline')
|
|
31
|
+
return v;
|
|
32
|
+
return DEFAULT_EDGE_STYLE;
|
|
33
|
+
}
|
|
34
|
+
/** Straight segment — the arrowhead follows the chord, not the node edge. */
|
|
35
|
+
export function straightEdgePath(sx, sy, tx, ty) {
|
|
36
|
+
return `M${sx},${sy} L${tx},${ty}`;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Orthogonal (Manhattan) polyline: horizontal out, vertical, horizontal in.
|
|
40
|
+
* The last segment is horizontal so `marker-end` still meets the node's
|
|
41
|
+
* vertical edge the same way the cubic does.
|
|
42
|
+
*/
|
|
43
|
+
export function orthogonalEdgePath(sx, sy, tx, ty) {
|
|
44
|
+
const midX = sx + (tx - sx) / 2;
|
|
45
|
+
return `M${sx},${sy} H${midX} V${ty} H${tx}`;
|
|
46
|
+
}
|
|
29
47
|
/**
|
|
30
48
|
* Builds the SVG `d` for a horizontal-tangent cubic Bézier from (sx,sy) to
|
|
31
49
|
* (tx,ty).
|
|
@@ -66,3 +84,14 @@ export function bowedCubicEdgePath(sx, sy, tx, ty, bowY, curvature = DEFAULT_EDG
|
|
|
66
84
|
const handle = Math.max(EDGE_MIN_HANDLE, Math.min(Math.abs(dx) * DX_FACTOR, MAX_HANDLE)) * curvature;
|
|
67
85
|
return `M${sx},${sy} C${sx + handle},${bowY} ${tx - handle},${bowY} ${tx},${ty}`;
|
|
68
86
|
}
|
|
87
|
+
/**
|
|
88
|
+
* Picks the SVG `d` for a Goals / DGCA / DGA preview edge.
|
|
89
|
+
* Unknown styles fall back to the historical cubic.
|
|
90
|
+
*/
|
|
91
|
+
export function previewEdgePath(sx, sy, tx, ty, style = DEFAULT_EDGE_STYLE, curvature = DEFAULT_EDGE_CURVATURE, entryCurvature) {
|
|
92
|
+
if (style === 'straight')
|
|
93
|
+
return straightEdgePath(sx, sy, tx, ty);
|
|
94
|
+
if (style === 'polyline')
|
|
95
|
+
return orthogonalEdgePath(sx, sy, tx, ty);
|
|
96
|
+
return horizontalCubicEdgePath(sx, sy, tx, ty, curvature, entryCurvature);
|
|
97
|
+
}
|
package/dist/fgca/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export { buildFGCALayout, NODE_WIDTH, NODE_HEIGHT, COLUMN_GAP, ROW_GAP, COLUMN_BG } from "./layout";
|
|
2
2
|
export type { FGCALayoutInput } from "./layout";
|
|
3
|
-
export { layoutFGCAPreview, selectScopedFGCA, FGCA_NODE_W, FGCA_NODE_H, FGCA_HEADER_H, FGCA_PAD, FGCA_DEFAULT_COL_GAP, FGCA_DEFAULT_ROW_GAP, } from "./preview-layout";
|
|
3
|
+
export { layoutFGCAPreview, selectScopedFGCA, chainColumnOptions, sanitizeChainScope, FGCA_NODE_W, FGCA_NODE_H, FGCA_HEADER_H, FGCA_PAD, FGCA_DEFAULT_COL_GAP, FGCA_DEFAULT_ROW_GAP, } from "./preview-layout";
|
|
4
4
|
export type { FGCAPreviewColumn, FGCAPreviewDoc, FGCAPreviewLayout, FGCAPreviewLayoutOptions, FGCAPreviewNode, FGCAPreviewEdge, FGCAPreviewColumnPos, } from "./preview-layout";
|
|
5
5
|
export { buildChainTable } from "./chain-table";
|
|
6
6
|
export type { ChainTable, ChainTableCell, ChainColumn, ChainCell, ChainTableOptions } from "./chain-table";
|
package/dist/fgca/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { buildFGCALayout, NODE_WIDTH, NODE_HEIGHT, COLUMN_GAP, ROW_GAP, COLUMN_BG } from "./layout.js";
|
|
2
|
-
export { layoutFGCAPreview, selectScopedFGCA, FGCA_NODE_W, FGCA_NODE_H, FGCA_HEADER_H, FGCA_PAD, FGCA_DEFAULT_COL_GAP, FGCA_DEFAULT_ROW_GAP, } from "./preview-layout.js";
|
|
2
|
+
export { layoutFGCAPreview, selectScopedFGCA, chainColumnOptions, sanitizeChainScope, FGCA_NODE_W, FGCA_NODE_H, FGCA_HEADER_H, FGCA_PAD, FGCA_DEFAULT_COL_GAP, FGCA_DEFAULT_ROW_GAP, } from "./preview-layout.js";
|
|
3
3
|
export { buildChainTable } from "./chain-table.js";
|
|
4
4
|
export { validateFGCADoc } from "./validate.js";
|
|
5
5
|
export { ALL_FGCA_COLUMNS, FGCA_COLUMN_LABELS, } from "./types.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ChainColumnKey, ChainScope, FgcaScope } from '../scope.js';
|
|
2
2
|
export type FGCAPreviewColumn = 'driver' | 'goal' | 'change' | 'activity';
|
|
3
3
|
export interface FGCAPreviewFactor {
|
|
4
4
|
id: number | string;
|
|
@@ -37,26 +37,46 @@ export interface FGCAPreviewLayoutOptions {
|
|
|
37
37
|
colGap?: number;
|
|
38
38
|
/** Vertical gap (px) between stacked nodes within a column. Default matches the historical hardcoded value. */
|
|
39
39
|
rowGap?: number;
|
|
40
|
-
/** Trim to a level cap
|
|
41
|
-
scope?:
|
|
40
|
+
/** Trim to a level cap, a single root goal, or per-column chain filters. Defaults to 'all'. */
|
|
41
|
+
scope?: FgcaScope;
|
|
42
42
|
/** Entity node width (px). Default {@link FGCA_NODE_W}. */
|
|
43
43
|
nodeWidth?: number;
|
|
44
44
|
/** Entity node height (px). Default {@link FGCA_NODE_H}. */
|
|
45
45
|
nodeHeight?: number;
|
|
46
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* Dropdown options for one chain column, cascaded from the other selected
|
|
49
|
+
* filters (this column's own filter is ignored so the user can still switch it).
|
|
50
|
+
*/
|
|
51
|
+
export declare function chainColumnOptions(doc: FGCAPreviewDoc, scope: ChainScope, column: ChainColumnKey, hideChanges?: boolean): Array<{
|
|
52
|
+
id: string;
|
|
53
|
+
name: string;
|
|
54
|
+
}>;
|
|
55
|
+
/**
|
|
56
|
+
* Drop column filters that are no longer reachable given the others.
|
|
57
|
+
* `justChanged` is kept even when incompatible — the last pick wins, neighbours yield.
|
|
58
|
+
*/
|
|
59
|
+
export declare function sanitizeChainScope(doc: FGCAPreviewDoc, scope: ChainScope, opts?: {
|
|
60
|
+
justChanged?: ChainColumnKey;
|
|
61
|
+
hideChanges?: boolean;
|
|
62
|
+
}): ChainScope;
|
|
47
63
|
/**
|
|
48
64
|
* Trims a DGCA/DGA doc to a scope.
|
|
49
65
|
*
|
|
50
66
|
* DGCA/DGA goals are flat (no parent_id), so:
|
|
51
67
|
* - 'level' → goals with `(level ?? 0) <= maxLevel`.
|
|
52
68
|
* - 'root' → the single goal whose id matches `rootGoalId` (empty when absent).
|
|
69
|
+
* - 'chain' → AND of per-column ids (Driver / Goal / Change / Action); empty
|
|
70
|
+
* ids are All. DGA passes hideChanges so a Change filter is ignored.
|
|
53
71
|
*
|
|
54
72
|
* Factors, changes and activities are then kept only when they touch a visible
|
|
55
73
|
* goal: a factor referenced by a visible goal, a change whose `goal_id` is
|
|
56
74
|
* visible, an activity bound to a visible goal directly or via a visible
|
|
57
75
|
* change. Pure and exported so an access-control layer can reuse it.
|
|
58
76
|
*/
|
|
59
|
-
export declare function selectScopedFGCA(doc: FGCAPreviewDoc, scope:
|
|
77
|
+
export declare function selectScopedFGCA(doc: FGCAPreviewDoc, scope: FgcaScope, opts?: {
|
|
78
|
+
hideChanges?: boolean;
|
|
79
|
+
}): FGCAPreviewDoc;
|
|
60
80
|
export interface FGCAPreviewNode {
|
|
61
81
|
id: string;
|
|
62
82
|
x: number;
|
|
@@ -6,22 +6,198 @@
|
|
|
6
6
|
// so the gap geometry is unit-testable: the extension has no test harness.
|
|
7
7
|
//
|
|
8
8
|
// No React, no DOM, no vscode. Safe to call in Node.js or a test environment.
|
|
9
|
+
import { isChainScope } from '../scope.js';
|
|
9
10
|
import { ENTITY_NODE_SIZE } from '../node-size-presets.js';
|
|
11
|
+
function sid(id) {
|
|
12
|
+
return String(id);
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Every Driver–Goal–Change–Action thread in the document, plus a singleton
|
|
16
|
+
* path for any entity that is not on a connected thread (orphans). Used to
|
|
17
|
+
* AND column filters: a node stays visible when it appears on at least one
|
|
18
|
+
* path that includes every selected id.
|
|
19
|
+
*/
|
|
20
|
+
function enumerateChainPaths(doc) {
|
|
21
|
+
const paths = [];
|
|
22
|
+
const seen = {
|
|
23
|
+
driver: new Set(),
|
|
24
|
+
goal: new Set(),
|
|
25
|
+
change: new Set(),
|
|
26
|
+
activity: new Set(),
|
|
27
|
+
};
|
|
28
|
+
const mark = (p) => {
|
|
29
|
+
paths.push(p);
|
|
30
|
+
if (p.driverId)
|
|
31
|
+
seen.driver.add(p.driverId);
|
|
32
|
+
if (p.goalId)
|
|
33
|
+
seen.goal.add(p.goalId);
|
|
34
|
+
if (p.changeId)
|
|
35
|
+
seen.change.add(p.changeId);
|
|
36
|
+
if (p.activityId)
|
|
37
|
+
seen.activity.add(p.activityId);
|
|
38
|
+
};
|
|
39
|
+
const changes = doc.changes ?? [];
|
|
40
|
+
for (const g of doc.goals) {
|
|
41
|
+
const goalId = sid(g.id);
|
|
42
|
+
const driverIds = (g.factor ?? []).map(f => sid(f.id));
|
|
43
|
+
const drivers = driverIds.length > 0 ? driverIds : [undefined];
|
|
44
|
+
const goalChanges = changes.filter(c => sid(c.goal_id) === goalId);
|
|
45
|
+
const coveredActs = new Set(goalChanges.flatMap(c => c.activity_ids.map(sid)));
|
|
46
|
+
const directActs = doc.activities.filter(a => a.goal_id != null && sid(a.goal_id) === goalId && !coveredActs.has(sid(a.id)));
|
|
47
|
+
const slots = [];
|
|
48
|
+
for (const c of goalChanges) {
|
|
49
|
+
const acts = c.activity_ids.map(sid);
|
|
50
|
+
slots.push({ changeId: sid(c.id), activityIds: acts.length > 0 ? acts : [undefined] });
|
|
51
|
+
}
|
|
52
|
+
for (const a of directActs) {
|
|
53
|
+
slots.push({ changeId: undefined, activityIds: [sid(a.id)] });
|
|
54
|
+
}
|
|
55
|
+
if (slots.length === 0) {
|
|
56
|
+
slots.push({ changeId: undefined, activityIds: [undefined] });
|
|
57
|
+
}
|
|
58
|
+
for (const d of drivers) {
|
|
59
|
+
for (const slot of slots) {
|
|
60
|
+
for (const a of slot.activityIds) {
|
|
61
|
+
mark({ driverId: d, goalId, changeId: slot.changeId, activityId: a });
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
for (const f of doc.factors) {
|
|
67
|
+
const id = sid(f.id);
|
|
68
|
+
if (!seen.driver.has(id))
|
|
69
|
+
mark({ driverId: id });
|
|
70
|
+
}
|
|
71
|
+
for (const g of doc.goals) {
|
|
72
|
+
const id = sid(g.id);
|
|
73
|
+
if (!seen.goal.has(id))
|
|
74
|
+
mark({ goalId: id });
|
|
75
|
+
}
|
|
76
|
+
for (const c of changes) {
|
|
77
|
+
const id = sid(c.id);
|
|
78
|
+
if (!seen.change.has(id))
|
|
79
|
+
mark({ changeId: id, goalId: sid(c.goal_id) });
|
|
80
|
+
}
|
|
81
|
+
for (const a of doc.activities) {
|
|
82
|
+
const id = sid(a.id);
|
|
83
|
+
if (!seen.activity.has(id)) {
|
|
84
|
+
mark({ activityId: id, goalId: a.goal_id != null ? sid(a.goal_id) : undefined });
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
return paths;
|
|
88
|
+
}
|
|
89
|
+
function selectChainScopedFGCA(doc, scope, hideChanges) {
|
|
90
|
+
const driverId = scope.driverId || undefined;
|
|
91
|
+
const goalId = scope.goalId || undefined;
|
|
92
|
+
const changeId = hideChanges ? undefined : (scope.changeId || undefined);
|
|
93
|
+
const activityId = scope.activityId || undefined;
|
|
94
|
+
if (!driverId && !goalId && !changeId && !activityId)
|
|
95
|
+
return doc;
|
|
96
|
+
const matched = enumerateChainPaths(doc).filter(p => {
|
|
97
|
+
if (driverId && p.driverId !== driverId)
|
|
98
|
+
return false;
|
|
99
|
+
if (goalId && p.goalId !== goalId)
|
|
100
|
+
return false;
|
|
101
|
+
if (changeId && p.changeId !== changeId)
|
|
102
|
+
return false;
|
|
103
|
+
if (activityId && p.activityId !== activityId)
|
|
104
|
+
return false;
|
|
105
|
+
return true;
|
|
106
|
+
});
|
|
107
|
+
const driverIds = new Set();
|
|
108
|
+
const goalIds = new Set();
|
|
109
|
+
const changeIds = new Set();
|
|
110
|
+
const activityIds = new Set();
|
|
111
|
+
for (const p of matched) {
|
|
112
|
+
if (p.driverId)
|
|
113
|
+
driverIds.add(p.driverId);
|
|
114
|
+
if (p.goalId)
|
|
115
|
+
goalIds.add(p.goalId);
|
|
116
|
+
if (p.changeId)
|
|
117
|
+
changeIds.add(p.changeId);
|
|
118
|
+
if (p.activityId)
|
|
119
|
+
activityIds.add(p.activityId);
|
|
120
|
+
}
|
|
121
|
+
return {
|
|
122
|
+
factors: doc.factors.filter(f => driverIds.has(sid(f.id))),
|
|
123
|
+
goals: doc.goals.filter(g => goalIds.has(sid(g.id))),
|
|
124
|
+
changes: doc.changes === undefined ? undefined : doc.changes.filter(c => changeIds.has(sid(c.id))),
|
|
125
|
+
activities: doc.activities.filter(a => activityIds.has(sid(a.id))),
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
const CHAIN_COLUMN_KEYS = ['driverId', 'goalId', 'changeId', 'activityId'];
|
|
129
|
+
function columnEntities(doc, column) {
|
|
130
|
+
if (column === 'driverId')
|
|
131
|
+
return doc.factors.map(f => ({ id: sid(f.id), name: f.name ?? '' }));
|
|
132
|
+
if (column === 'goalId')
|
|
133
|
+
return doc.goals.map(g => ({ id: sid(g.id), name: g.name ?? '' }));
|
|
134
|
+
if (column === 'changeId')
|
|
135
|
+
return (doc.changes ?? []).map(c => ({ id: sid(c.id), name: c.name ?? '' }));
|
|
136
|
+
return doc.activities.map(a => ({ id: sid(a.id), name: a.name ?? '' }));
|
|
137
|
+
}
|
|
138
|
+
/**
|
|
139
|
+
* Dropdown options for one chain column, cascaded from the other selected
|
|
140
|
+
* filters (this column's own filter is ignored so the user can still switch it).
|
|
141
|
+
*/
|
|
142
|
+
export function chainColumnOptions(doc, scope, column, hideChanges = false) {
|
|
143
|
+
if (hideChanges && column === 'changeId')
|
|
144
|
+
return [];
|
|
145
|
+
const withoutSelf = { ...scope, mode: 'chain', [column]: undefined };
|
|
146
|
+
const filtered = selectChainScopedFGCA(doc, withoutSelf, hideChanges);
|
|
147
|
+
return columnEntities(filtered, column);
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Drop column filters that are no longer reachable given the others.
|
|
151
|
+
* `justChanged` is kept even when incompatible — the last pick wins, neighbours yield.
|
|
152
|
+
*/
|
|
153
|
+
export function sanitizeChainScope(doc, scope, opts = {}) {
|
|
154
|
+
const next = {
|
|
155
|
+
mode: 'chain',
|
|
156
|
+
driverId: scope.driverId || undefined,
|
|
157
|
+
goalId: scope.goalId || undefined,
|
|
158
|
+
changeId: opts.hideChanges ? undefined : (scope.changeId || undefined),
|
|
159
|
+
activityId: scope.activityId || undefined,
|
|
160
|
+
};
|
|
161
|
+
let changed = true;
|
|
162
|
+
while (changed) {
|
|
163
|
+
changed = false;
|
|
164
|
+
for (const key of CHAIN_COLUMN_KEYS) {
|
|
165
|
+
if (key === opts.justChanged)
|
|
166
|
+
continue;
|
|
167
|
+
if (opts.hideChanges && key === 'changeId')
|
|
168
|
+
continue;
|
|
169
|
+
const id = next[key];
|
|
170
|
+
if (!id)
|
|
171
|
+
continue;
|
|
172
|
+
const available = new Set(chainColumnOptions(doc, next, key, opts.hideChanges).map(o => o.id));
|
|
173
|
+
if (!available.has(id)) {
|
|
174
|
+
next[key] = undefined;
|
|
175
|
+
changed = true;
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
return next;
|
|
180
|
+
}
|
|
10
181
|
/**
|
|
11
182
|
* Trims a DGCA/DGA doc to a scope.
|
|
12
183
|
*
|
|
13
184
|
* DGCA/DGA goals are flat (no parent_id), so:
|
|
14
185
|
* - 'level' → goals with `(level ?? 0) <= maxLevel`.
|
|
15
186
|
* - 'root' → the single goal whose id matches `rootGoalId` (empty when absent).
|
|
187
|
+
* - 'chain' → AND of per-column ids (Driver / Goal / Change / Action); empty
|
|
188
|
+
* ids are All. DGA passes hideChanges so a Change filter is ignored.
|
|
16
189
|
*
|
|
17
190
|
* Factors, changes and activities are then kept only when they touch a visible
|
|
18
191
|
* goal: a factor referenced by a visible goal, a change whose `goal_id` is
|
|
19
192
|
* visible, an activity bound to a visible goal directly or via a visible
|
|
20
193
|
* change. Pure and exported so an access-control layer can reuse it.
|
|
21
194
|
*/
|
|
22
|
-
export function selectScopedFGCA(doc, scope) {
|
|
195
|
+
export function selectScopedFGCA(doc, scope, opts = {}) {
|
|
23
196
|
if (scope.mode === 'all')
|
|
24
197
|
return doc;
|
|
198
|
+
if (isChainScope(scope)) {
|
|
199
|
+
return selectChainScopedFGCA(doc, scope, opts.hideChanges === true);
|
|
200
|
+
}
|
|
25
201
|
const visibleGoals = scope.mode === 'level'
|
|
26
202
|
? doc.goals.filter(g => (g.level ?? 0) <= scope.maxLevel)
|
|
27
203
|
: doc.goals.filter(g => String(g.id) === scope.rootGoalId);
|
|
@@ -50,7 +226,7 @@ export const FGCA_DEFAULT_ROW_GAP = 20;
|
|
|
50
226
|
export function layoutFGCAPreview(inputDoc, options = {}) {
|
|
51
227
|
const { hideChanges = false, colGap = FGCA_DEFAULT_COL_GAP, rowGap = FGCA_DEFAULT_ROW_GAP, scope = { mode: 'all' }, nodeWidth = FGCA_NODE_W, nodeHeight = FGCA_NODE_H, } = options;
|
|
52
228
|
// Trim to scope first; everything below lays out the visible subset only.
|
|
53
|
-
const doc = selectScopedFGCA(inputDoc, scope);
|
|
229
|
+
const doc = selectScopedFGCA(inputDoc, scope, { hideChanges });
|
|
54
230
|
const colStride = nodeWidth + colGap;
|
|
55
231
|
const cols = hideChanges
|
|
56
232
|
? ['driver', 'goal', 'activity']
|
package/dist/goals/GoalNode.d.ts
CHANGED
package/dist/goals/GoalNode.js
CHANGED
|
@@ -13,7 +13,7 @@ function impactSign(f) {
|
|
|
13
13
|
return 'negative';
|
|
14
14
|
}
|
|
15
15
|
const GoalNode = memo(({ data }) => {
|
|
16
|
-
const { goal, theme, readOnly, isDropTarget, hasHiddenChildren, isCollapsed } = data;
|
|
16
|
+
const { goal, theme, readOnly, isDropTarget, hasChildren, hasHiddenChildren, isCollapsed } = data;
|
|
17
17
|
const [openPanel, setOpenPanel] = useState(null);
|
|
18
18
|
const positive = (goal.factors ?? []).filter((f) => impactSign(f) !== 'negative');
|
|
19
19
|
const negative = (goal.factors ?? []).filter((f) => impactSign(f) !== 'positive');
|
|
@@ -83,14 +83,15 @@ const GoalNode = memo(({ data }) => {
|
|
|
83
83
|
position: 'absolute', bottom: -8, right: -8, width: 16, height: 16,
|
|
84
84
|
borderRadius: '50%', border: '1px solid #fca5a5', background: '#ffffff',
|
|
85
85
|
color: '#dc2626', fontSize: 11, lineHeight: '14px', padding: 0, cursor: 'pointer',
|
|
86
|
-
}, children: "\u00D7" })), hasHiddenChildren && (_jsx("button", { type: "button", "aria-label": isCollapsed ? 'Expand branch' : 'Collapse branch', title: isCollapsed ? 'Expand branch' : 'Collapse branch', onClick: (e) => {
|
|
86
|
+
}, children: "\u00D7" })), (hasChildren || hasHiddenChildren) && (_jsx("button", { type: "button", "aria-label": isCollapsed || hasHiddenChildren ? 'Expand branch' : 'Collapse branch', title: isCollapsed || hasHiddenChildren ? 'Expand branch' : 'Collapse branch', onClick: (e) => {
|
|
87
87
|
e.stopPropagation();
|
|
88
88
|
data.onToggleCollapse(goal.id);
|
|
89
89
|
}, style: {
|
|
90
90
|
position: 'absolute', top: '50%', right: -8, transform: 'translateY(-50%)',
|
|
91
91
|
width: 16, height: 16, borderRadius: '50%', border: `1px solid ${theme.cardBorderColor}`,
|
|
92
|
-
background: '#ffffff', color: theme.cardBorderColor, fontSize: 11, lineHeight: '14px', padding: 0,
|
|
93
|
-
|
|
92
|
+
background: '#ffffff', color: theme.cardBorderColor, fontSize: 11, lineHeight: '14px', padding: 0,
|
|
93
|
+
cursor: 'pointer', zIndex: 10,
|
|
94
|
+
}, children: isCollapsed || hasHiddenChildren ? '+' : '−' }))] }));
|
|
94
95
|
});
|
|
95
96
|
GoalNode.displayName = 'GoalNode';
|
|
96
97
|
export default GoalNode;
|
|
@@ -122,6 +122,7 @@ function GoalTreeViewInner({ tree, layout: layoutProp, layoutOptions, theme: the
|
|
|
122
122
|
theme,
|
|
123
123
|
readOnly,
|
|
124
124
|
isDropTarget: hoveredId === n.id,
|
|
125
|
+
hasChildren: n.hasChildren,
|
|
125
126
|
hasHiddenChildren: n.hasHiddenChildren,
|
|
126
127
|
isCollapsed: collapsedIds.has(n.id),
|
|
127
128
|
onAddChild,
|
package/dist/goals/layout.js
CHANGED
|
@@ -100,14 +100,16 @@ export function layoutGoalTree(tree, options = {}) {
|
|
|
100
100
|
return { top: 0, bottom: 0 };
|
|
101
101
|
placed.add(id);
|
|
102
102
|
const col = levelToCol.get(goal.level) ?? 0;
|
|
103
|
-
const
|
|
104
|
-
const
|
|
105
|
-
const
|
|
103
|
+
const allChildIds = children.get(id) ?? [];
|
|
104
|
+
const childIds = allChildIds.filter(c => !hiddenSubtrees.has(c) && !placed.has(c));
|
|
105
|
+
const isCollapsedRoot = hiddenSet.has(id) && allChildIds.length > 0;
|
|
106
|
+
const hasChildren = allChildIds.length > 0;
|
|
107
|
+
const hasHiddenChildren = childIds.length < allChildIds.length;
|
|
106
108
|
if (childIds.length === 0) {
|
|
107
109
|
// Leaf: place at current column Y
|
|
108
110
|
const y = getNextY(col);
|
|
109
111
|
advanceY(col, nodeHeight + nodeSep);
|
|
110
|
-
nodes.push({ id, x: col * (nodeWidth + rankSep), y, width: nodeWidth, height: nodeHeight, data: goal, isCollapsedRoot, hasHiddenChildren });
|
|
112
|
+
nodes.push({ id, x: col * (nodeWidth + rankSep), y, width: nodeWidth, height: nodeHeight, data: goal, isCollapsedRoot, hasChildren, hasHiddenChildren });
|
|
111
113
|
return { top: y, bottom: y + nodeHeight };
|
|
112
114
|
}
|
|
113
115
|
// Place children first to get their span
|
|
@@ -122,7 +124,7 @@ export function layoutGoalTree(tree, options = {}) {
|
|
|
122
124
|
const curColY = getNextY(col);
|
|
123
125
|
const finalY = Math.max(parentY, curColY);
|
|
124
126
|
advanceY(col, finalY - curColY + nodeHeight + nodeSep);
|
|
125
|
-
nodes.push({ id, x: col * (nodeWidth + rankSep), y: finalY, width: nodeWidth, height: nodeHeight, data: goal, isCollapsedRoot, hasHiddenChildren });
|
|
127
|
+
nodes.push({ id, x: col * (nodeWidth + rankSep), y: finalY, width: nodeWidth, height: nodeHeight, data: goal, isCollapsedRoot, hasChildren, hasHiddenChildren });
|
|
126
128
|
for (const cid of childIds) {
|
|
127
129
|
edges.push({ source: id, target: cid });
|
|
128
130
|
}
|
package/dist/goals/types.d.ts
CHANGED
|
@@ -55,6 +55,8 @@ export interface LaidOutNode {
|
|
|
55
55
|
height: number;
|
|
56
56
|
data: Goal;
|
|
57
57
|
isCollapsedRoot: boolean;
|
|
58
|
+
/** True when this node has at least one child in the source tree (visible or hidden). */
|
|
59
|
+
hasChildren: boolean;
|
|
58
60
|
hasHiddenChildren: boolean;
|
|
59
61
|
}
|
|
60
62
|
export interface LaidOutEdge {
|
package/dist/scope.d.ts
CHANGED
|
@@ -8,10 +8,26 @@ export type Scope = {
|
|
|
8
8
|
mode: 'root';
|
|
9
9
|
rootGoalId: string;
|
|
10
10
|
};
|
|
11
|
+
/** Column filters on a DGCA/DGA chain. Empty / omitted id = All for that column. */
|
|
12
|
+
export type ChainColumnKey = 'driverId' | 'goalId' | 'changeId' | 'activityId';
|
|
13
|
+
export type ChainScope = {
|
|
14
|
+
mode: 'chain';
|
|
15
|
+
driverId?: string;
|
|
16
|
+
goalId?: string;
|
|
17
|
+
changeId?: string;
|
|
18
|
+
activityId?: string;
|
|
19
|
+
};
|
|
20
|
+
/** Scope accepted by DGCA/DGA layout — Goals tree still uses {@link Scope} only. */
|
|
21
|
+
export type FgcaScope = Scope | ChainScope;
|
|
11
22
|
/** Default scope — render everything. */
|
|
12
23
|
export declare const SCOPE_ALL: Scope;
|
|
24
|
+
export declare function isChainScope(scope: FgcaScope): scope is ChainScope;
|
|
25
|
+
/** True when at least one column filter is set. */
|
|
26
|
+
export declare function chainScopeActive(scope: ChainScope): boolean;
|
|
13
27
|
/** Warning code emitted when a root-mode scope names a goal that isn't in the document. */
|
|
14
28
|
export declare const SCOPE_MISSING_ROOT_CODE = "SCOPE-001";
|
|
29
|
+
/** Warning code emitted when a chain-column filter names an id that isn't in the document. */
|
|
30
|
+
export declare const SCOPE_MISSING_CHAIN_CODE = "SCOPE-002";
|
|
15
31
|
/**
|
|
16
32
|
* Returns the SCOPE-001 warning when `scope` is root-mode and `rootGoalId` is
|
|
17
33
|
* not among the document's goal ids; otherwise null. Goal ids are compared as
|
|
@@ -21,3 +37,14 @@ export declare const SCOPE_MISSING_ROOT_CODE = "SCOPE-001";
|
|
|
21
37
|
* functions independently return an empty layout in the same situation.
|
|
22
38
|
*/
|
|
23
39
|
export declare function checkScopeRoot(scope: Scope, goalIds: Iterable<string | number>): ValidationWarning | null;
|
|
40
|
+
/**
|
|
41
|
+
* Returns a SCOPE-002 warning when a chain filter names an id that is not in
|
|
42
|
+
* the document's corresponding column; otherwise null. Several missing ids
|
|
43
|
+
* are listed in one message.
|
|
44
|
+
*/
|
|
45
|
+
export declare function checkChainScope(scope: ChainScope, ids: {
|
|
46
|
+
drivers: Iterable<string | number>;
|
|
47
|
+
goals: Iterable<string | number>;
|
|
48
|
+
changes: Iterable<string | number>;
|
|
49
|
+
activities: Iterable<string | number>;
|
|
50
|
+
}, hideChanges?: boolean): ValidationWarning | null;
|
package/dist/scope.js
CHANGED
|
@@ -14,8 +14,17 @@
|
|
|
14
14
|
// subtree root and reuse exactly this filter. No RBAC here — just the filter.
|
|
15
15
|
/** Default scope — render everything. */
|
|
16
16
|
export const SCOPE_ALL = { mode: 'all' };
|
|
17
|
+
export function isChainScope(scope) {
|
|
18
|
+
return scope.mode === 'chain';
|
|
19
|
+
}
|
|
20
|
+
/** True when at least one column filter is set. */
|
|
21
|
+
export function chainScopeActive(scope) {
|
|
22
|
+
return !!(scope.driverId || scope.goalId || scope.changeId || scope.activityId);
|
|
23
|
+
}
|
|
17
24
|
/** Warning code emitted when a root-mode scope names a goal that isn't in the document. */
|
|
18
25
|
export const SCOPE_MISSING_ROOT_CODE = 'SCOPE-001';
|
|
26
|
+
/** Warning code emitted when a chain-column filter names an id that isn't in the document. */
|
|
27
|
+
export const SCOPE_MISSING_CHAIN_CODE = 'SCOPE-002';
|
|
19
28
|
/**
|
|
20
29
|
* Returns the SCOPE-001 warning when `scope` is root-mode and `rootGoalId` is
|
|
21
30
|
* not among the document's goal ids; otherwise null. Goal ids are compared as
|
|
@@ -36,3 +45,34 @@ export function checkScopeRoot(scope, goalIds) {
|
|
|
36
45
|
message: `Scope root goal "${scope.rootGoalId}" was not found in this document — nothing to show. Clear the scope or pick a goal that exists.`,
|
|
37
46
|
};
|
|
38
47
|
}
|
|
48
|
+
function idSetHas(ids, want) {
|
|
49
|
+
for (const id of ids) {
|
|
50
|
+
if (String(id) === want)
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
return false;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Returns a SCOPE-002 warning when a chain filter names an id that is not in
|
|
57
|
+
* the document's corresponding column; otherwise null. Several missing ids
|
|
58
|
+
* are listed in one message.
|
|
59
|
+
*/
|
|
60
|
+
export function checkChainScope(scope, ids, hideChanges = false) {
|
|
61
|
+
if (scope.mode !== 'chain')
|
|
62
|
+
return null;
|
|
63
|
+
const missing = [];
|
|
64
|
+
if (scope.driverId && !idSetHas(ids.drivers, scope.driverId))
|
|
65
|
+
missing.push(`driver "${scope.driverId}"`);
|
|
66
|
+
if (scope.goalId && !idSetHas(ids.goals, scope.goalId))
|
|
67
|
+
missing.push(`goal "${scope.goalId}"`);
|
|
68
|
+
if (!hideChanges && scope.changeId && !idSetHas(ids.changes, scope.changeId))
|
|
69
|
+
missing.push(`change "${scope.changeId}"`);
|
|
70
|
+
if (scope.activityId && !idSetHas(ids.activities, scope.activityId))
|
|
71
|
+
missing.push(`action "${scope.activityId}"`);
|
|
72
|
+
if (missing.length === 0)
|
|
73
|
+
return null;
|
|
74
|
+
return {
|
|
75
|
+
code: SCOPE_MISSING_CHAIN_CODE,
|
|
76
|
+
message: `Scope ${missing.join(', ')} was not found in this document — nothing to show for that filter. Clear the scope or pick an id that exists.`,
|
|
77
|
+
};
|
|
78
|
+
}
|