@molecule/app-feature-graph-view-angular 0.0.0-stage → 1.1.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/LICENSE +202 -0
- package/README.md +708 -2
- package/dist/graph-view.component.d.ts +123 -0
- package/dist/graph-view.component.d.ts.map +1 -0
- package/dist/graph-view.component.js +393 -0
- package/dist/graph-view.component.js.map +1 -0
- package/dist/index.d.ts +67 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +67 -0
- package/dist/index.js.map +1 -0
- package/dist/layout.d.ts +101 -0
- package/dist/layout.d.ts.map +1 -0
- package/dist/layout.js +239 -0
- package/dist/layout.js.map +1 -0
- package/dist/types.d.ts +99 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/package.json +73 -4
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import { type UIClassMap } from '@molecule/app-ui';
|
|
2
|
+
import { type ForceLayoutOptions } from './layout.js';
|
|
3
|
+
import type { GraphEdge, GraphEdgeRenderer, GraphLayout, GraphNode, GraphNodeRenderer, PositionedNode } from './types.js';
|
|
4
|
+
import * as i0 from "@angular/core";
|
|
5
|
+
/** One edge with both endpoints resolved. */
|
|
6
|
+
interface RenderableEdge {
|
|
7
|
+
/** The edge. */
|
|
8
|
+
edge: GraphEdge;
|
|
9
|
+
/** The positioned source node. */
|
|
10
|
+
src: PositionedNode;
|
|
11
|
+
/** The positioned target node. */
|
|
12
|
+
tgt: PositionedNode;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Force-directed graph view (Obsidian-style).
|
|
16
|
+
*
|
|
17
|
+
* Renders nodes + edges into an SVG, computing positions via a built-in
|
|
18
|
+
* minimal velocity-Verlet simulation. Three layouts are supported —
|
|
19
|
+
* `force` (default), `circular` and `grid` — and either nodes or edges
|
|
20
|
+
* can be overridden via custom templates.
|
|
21
|
+
*
|
|
22
|
+
* The host IS the outer `<div>` (`div[mol-graph-view]`), matching React's root
|
|
23
|
+
* exactly. Style is driven by `getClassMap()`. Inline styles are reserved for
|
|
24
|
+
* SVG geometry — `transform`, viewBox computation, stroke widths — which
|
|
25
|
+
* classes can't express.
|
|
26
|
+
*/
|
|
27
|
+
export declare class GraphView {
|
|
28
|
+
/** Nodes to render. */
|
|
29
|
+
nodes?: GraphNode[];
|
|
30
|
+
/** Edges to render. */
|
|
31
|
+
edges?: GraphEdge[];
|
|
32
|
+
/** Fired when the user clicks (or activates) a node. */
|
|
33
|
+
onNodeClick?: (node: GraphNode) => void;
|
|
34
|
+
/** Currently-selected node id (highlighted in the view). */
|
|
35
|
+
selectedNodeId?: string;
|
|
36
|
+
/** Layout strategy (defaults to `'force'` at read time). */
|
|
37
|
+
layout?: GraphLayout;
|
|
38
|
+
/** Custom node renderer template. */
|
|
39
|
+
nodeRenderer?: GraphNodeRenderer;
|
|
40
|
+
/** Custom edge renderer template. */
|
|
41
|
+
edgeRenderer?: GraphEdgeRenderer;
|
|
42
|
+
/** Force-layout tunables; ignored for non-force layouts. */
|
|
43
|
+
forceOptions?: ForceLayoutOptions;
|
|
44
|
+
/** Extra classes merged onto the outer wrapper. */
|
|
45
|
+
className?: string;
|
|
46
|
+
/** The bonded translation function. */
|
|
47
|
+
private readonly i18n;
|
|
48
|
+
/**
|
|
49
|
+
* The current class map.
|
|
50
|
+
* @returns The UIClassMap.
|
|
51
|
+
*/
|
|
52
|
+
cm(): UIClassMap;
|
|
53
|
+
/**
|
|
54
|
+
* Computes the wrapper class list.
|
|
55
|
+
* @returns The class string.
|
|
56
|
+
*/
|
|
57
|
+
classes(): string;
|
|
58
|
+
/**
|
|
59
|
+
* Computes the empty-state class list.
|
|
60
|
+
* @returns The class string.
|
|
61
|
+
*/
|
|
62
|
+
emptyClasses(): string;
|
|
63
|
+
/**
|
|
64
|
+
* The canvas' accessible name.
|
|
65
|
+
* @returns The translated label.
|
|
66
|
+
*/
|
|
67
|
+
ariaLabel(): string;
|
|
68
|
+
/**
|
|
69
|
+
* The empty-state message.
|
|
70
|
+
* @returns The translated message.
|
|
71
|
+
*/
|
|
72
|
+
emptyLabel(): string;
|
|
73
|
+
/**
|
|
74
|
+
* One node hit group's accessible name.
|
|
75
|
+
* @param node - The node.
|
|
76
|
+
* @returns The translated label.
|
|
77
|
+
*/
|
|
78
|
+
nodeAria(node: GraphNode): string;
|
|
79
|
+
/**
|
|
80
|
+
* World-space positions for every node, from the chosen layout. The force
|
|
81
|
+
* simulation is deterministic given a fixed seed, so repeated reads (change
|
|
82
|
+
* detection runs several) produce identical coordinates.
|
|
83
|
+
* @returns The positioned nodes.
|
|
84
|
+
*/
|
|
85
|
+
positionedNodes(): PositionedNode[];
|
|
86
|
+
/**
|
|
87
|
+
* The edges whose endpoints both exist, with both endpoints resolved.
|
|
88
|
+
* @returns The renderable edges, in input order.
|
|
89
|
+
*/
|
|
90
|
+
renderableEdges(): RenderableEdge[];
|
|
91
|
+
/**
|
|
92
|
+
* The SVG viewBox that fits the layout bounds.
|
|
93
|
+
* @returns The viewBox string.
|
|
94
|
+
*/
|
|
95
|
+
viewBox(): string;
|
|
96
|
+
/**
|
|
97
|
+
* Whether a node is the selected one.
|
|
98
|
+
* @param node - The node.
|
|
99
|
+
* @returns True when it matches `selectedNodeId`.
|
|
100
|
+
*/
|
|
101
|
+
isSelected(node: GraphNode): boolean;
|
|
102
|
+
/**
|
|
103
|
+
* The rendered radius of a node, scaled by its weight.
|
|
104
|
+
* @param node - The node.
|
|
105
|
+
* @returns The radius in world units.
|
|
106
|
+
*/
|
|
107
|
+
radius(node: GraphNode): number;
|
|
108
|
+
/**
|
|
109
|
+
* Calls `onNodeClick` for a node.
|
|
110
|
+
* @param node - The node.
|
|
111
|
+
*/
|
|
112
|
+
activate(node: GraphNode): void;
|
|
113
|
+
/**
|
|
114
|
+
* Activates a node on Enter or Space, as React's keydown handler does.
|
|
115
|
+
* @param event - The keyboard event.
|
|
116
|
+
* @param node - The node.
|
|
117
|
+
*/
|
|
118
|
+
keydown(event: KeyboardEvent, node: GraphNode): void;
|
|
119
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<GraphView, never>;
|
|
120
|
+
static ɵcmp: i0.ɵɵComponentDeclaration<GraphView, "div[mol-graph-view]", never, { "nodes": { "alias": "nodes"; "required": false; }; "edges": { "alias": "edges"; "required": false; }; "onNodeClick": { "alias": "onNodeClick"; "required": false; }; "selectedNodeId": { "alias": "selectedNodeId"; "required": false; }; "layout": { "alias": "layout"; "required": false; }; "nodeRenderer": { "alias": "nodeRenderer"; "required": false; }; "edgeRenderer": { "alias": "edgeRenderer"; "required": false; }; "forceOptions": { "alias": "forceOptions"; "required": false; }; "className": { "alias": "className"; "required": false; }; }, {}, never, never, true, never>;
|
|
121
|
+
}
|
|
122
|
+
export {};
|
|
123
|
+
//# sourceMappingURL=graph-view.component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph-view.component.d.ts","sourceRoot":"","sources":["../src/graph-view.component.ts"],"names":[],"mappings":"AAYA,OAAO,EAAe,KAAK,UAAU,EAAE,MAAM,kBAAkB,CAAA;AAE/D,OAAO,EAAe,KAAK,kBAAkB,EAAe,MAAM,aAAa,CAAA;AAC/E,OAAO,KAAK,EACV,SAAS,EACT,iBAAiB,EACjB,WAAW,EACX,SAAS,EACT,iBAAiB,EACjB,cAAc,EACf,MAAM,YAAY,CAAA;;AAKnB,6CAA6C;AAC7C,UAAU,cAAc;IACtB,gBAAgB;IAChB,IAAI,EAAE,SAAS,CAAA;IACf,kCAAkC;IAClC,GAAG,EAAE,cAAc,CAAA;IACnB,kCAAkC;IAClC,GAAG,EAAE,cAAc,CAAA;CACpB;AAED;;;;;;;;;;;;GAYG;AACH,qBAoHa,SAAS;IACpB,uBAAuB;IACvB,KAAK,CAAC,EAAE,SAAS,EAAE,CAAA;IACnB,uBAAuB;IACvB,KAAK,CAAC,EAAE,SAAS,EAAE,CAAA;IACnB,wDAAwD;IACxD,WAA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feature-graph-view-react`'s `<GraphView>` — the same props
|
|
4
|
+
* (React names), the same classes, and the same DOM for the same input.
|
|
5
|
+
*
|
|
6
|
+
* @module
|
|
7
|
+
*/
|
|
8
|
+
import { NgTemplateOutlet } from '@angular/common';
|
|
9
|
+
import { Component } from '@angular/core';
|
|
10
|
+
import { useTranslation } from '@molecule/app-angular';
|
|
11
|
+
import { getClassMap } from '@molecule/app-ui';
|
|
12
|
+
import { boundingBox, layoutNodes } from './layout.js';
|
|
13
|
+
import * as i0 from "@angular/core";
|
|
14
|
+
const _c0 = (a0, a1, a2) => ({ a0: a0, a1: a1, a2: a2 });
|
|
15
|
+
const _c1 = a0 => ({ a0: a0 });
|
|
16
|
+
const _forTrack0 = ($index, $item) => $item.edge.id;
|
|
17
|
+
const _forTrack1 = ($index, $item) => $item.id;
|
|
18
|
+
function GraphView_Conditional_0_Template(rf, ctx) { if (rf & 1) {
|
|
19
|
+
i0.ɵɵelementStart(0, "div", 2);
|
|
20
|
+
i0.ɵɵtext(1);
|
|
21
|
+
i0.ɵɵelementEnd();
|
|
22
|
+
} if (rf & 2) {
|
|
23
|
+
const ctx_r0 = i0.ɵɵnextContext();
|
|
24
|
+
i0.ɵɵclassMap(ctx_r0.emptyClasses());
|
|
25
|
+
i0.ɵɵstyleProp("inset", "0px")("display", "grid")("place-items", "center");
|
|
26
|
+
i0.ɵɵadvance();
|
|
27
|
+
i0.ɵɵtextInterpolate1(" ", ctx_r0.emptyLabel(), " ");
|
|
28
|
+
} }
|
|
29
|
+
function GraphView_Conditional_1_For_3_Conditional_0_Template(rf, ctx) { if (rf & 1) {
|
|
30
|
+
i0.ɵɵnamespaceSVG();
|
|
31
|
+
i0.ɵɵelementStart(0, "g");
|
|
32
|
+
i0.ɵɵelementContainer(1, 8);
|
|
33
|
+
i0.ɵɵelementEnd();
|
|
34
|
+
} if (rf & 2) {
|
|
35
|
+
const item_r2 = i0.ɵɵnextContext().$implicit;
|
|
36
|
+
const ctx_r0 = i0.ɵɵnextContext(2);
|
|
37
|
+
i0.ɵɵattribute("data-mol-id", "graph-view-edge-" + item_r2.edge.id);
|
|
38
|
+
i0.ɵɵadvance();
|
|
39
|
+
i0.ɵɵproperty("ngTemplateOutlet", ctx_r0.edgeRenderer)("ngTemplateOutletContext", i0.ɵɵpureFunction3(3, _c0, item_r2.edge, item_r2.src, item_r2.tgt));
|
|
40
|
+
} }
|
|
41
|
+
function GraphView_Conditional_1_For_3_Conditional_1_Template(rf, ctx) { if (rf & 1) {
|
|
42
|
+
i0.ɵɵnamespaceSVG();
|
|
43
|
+
i0.ɵɵelement(0, "line", 7);
|
|
44
|
+
} if (rf & 2) {
|
|
45
|
+
const item_r2 = i0.ɵɵnextContext().$implicit;
|
|
46
|
+
i0.ɵɵattribute("data-mol-id", "graph-view-edge-" + item_r2.edge.id)("x1", item_r2.src.x)("y1", item_r2.src.y)("x2", item_r2.tgt.x)("y2", item_r2.tgt.y);
|
|
47
|
+
} }
|
|
48
|
+
function GraphView_Conditional_1_For_3_Template(rf, ctx) { if (rf & 1) {
|
|
49
|
+
i0.ɵɵconditionalCreate(0, GraphView_Conditional_1_For_3_Conditional_0_Template, 2, 7, "g")(1, GraphView_Conditional_1_For_3_Conditional_1_Template, 1, 5, "line", 7);
|
|
50
|
+
} if (rf & 2) {
|
|
51
|
+
const ctx_r0 = i0.ɵɵnextContext(2);
|
|
52
|
+
i0.ɵɵconditional(ctx_r0.edgeRenderer ? 0 : 1);
|
|
53
|
+
} }
|
|
54
|
+
function GraphView_Conditional_1_For_6_Conditional_1_Template(rf, ctx) { if (rf & 1) {
|
|
55
|
+
i0.ɵɵnamespaceSVG();
|
|
56
|
+
i0.ɵɵelementContainer(0, 8);
|
|
57
|
+
} if (rf & 2) {
|
|
58
|
+
const node_r4 = i0.ɵɵnextContext().$implicit;
|
|
59
|
+
const ctx_r0 = i0.ɵɵnextContext(2);
|
|
60
|
+
i0.ɵɵproperty("ngTemplateOutlet", ctx_r0.nodeRenderer)("ngTemplateOutletContext", i0.ɵɵpureFunction1(2, _c1, node_r4));
|
|
61
|
+
} }
|
|
62
|
+
function GraphView_Conditional_1_For_6_Conditional_2_Template(rf, ctx) { if (rf & 1) {
|
|
63
|
+
i0.ɵɵnamespaceSVG();
|
|
64
|
+
i0.ɵɵelementStart(0, "g");
|
|
65
|
+
i0.ɵɵelement(1, "circle", 10);
|
|
66
|
+
i0.ɵɵelementStart(2, "text", 11);
|
|
67
|
+
i0.ɵɵtext(3);
|
|
68
|
+
i0.ɵɵelementEnd()();
|
|
69
|
+
} if (rf & 2) {
|
|
70
|
+
const node_r4 = i0.ɵɵnextContext().$implicit;
|
|
71
|
+
const ctx_r0 = i0.ɵɵnextContext(2);
|
|
72
|
+
i0.ɵɵattribute("data-mol-id", "graph-view-node-" + node_r4.id)("data-selected", ctx_r0.isSelected(node_r4) ? "true" : "false")("transform", "translate(" + node_r4.x + ", " + node_r4.y + ")");
|
|
73
|
+
i0.ɵɵadvance();
|
|
74
|
+
i0.ɵɵattribute("r", ctx_r0.radius(node_r4))("opacity", ctx_r0.isSelected(node_r4) ? 1 : 0.85)("stroke-width", ctx_r0.isSelected(node_r4) ? 2 : 0);
|
|
75
|
+
i0.ɵɵadvance();
|
|
76
|
+
i0.ɵɵstyleProp("pointer-events", "none")("user-select", "none");
|
|
77
|
+
i0.ɵɵattribute("x", ctx_r0.radius(node_r4) + 4)("opacity", ctx_r0.isSelected(node_r4) ? 1 : 0.75);
|
|
78
|
+
i0.ɵɵadvance();
|
|
79
|
+
i0.ɵɵtextInterpolate1(" ", node_r4.label, " ");
|
|
80
|
+
} }
|
|
81
|
+
function GraphView_Conditional_1_For_6_Template(rf, ctx) { if (rf & 1) {
|
|
82
|
+
const _r3 = i0.ɵɵgetCurrentView();
|
|
83
|
+
i0.ɵɵnamespaceSVG();
|
|
84
|
+
i0.ɵɵelementStart(0, "g", 9);
|
|
85
|
+
i0.ɵɵlistener("click", function GraphView_Conditional_1_For_6_Template_g_click_0_listener() { const node_r4 = i0.ɵɵrestoreView(_r3).$implicit; const ctx_r0 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r0.activate(node_r4)); })("keydown", function GraphView_Conditional_1_For_6_Template_g_keydown_0_listener($event) { const node_r4 = i0.ɵɵrestoreView(_r3).$implicit; const ctx_r0 = i0.ɵɵnextContext(2); return i0.ɵɵresetView(ctx_r0.keydown($event, node_r4)); });
|
|
86
|
+
i0.ɵɵconditionalCreate(1, GraphView_Conditional_1_For_6_Conditional_1_Template, 1, 4, "ng-container", 8)(2, GraphView_Conditional_1_For_6_Conditional_2_Template, 4, 13, "g");
|
|
87
|
+
i0.ɵɵelementEnd();
|
|
88
|
+
} if (rf & 2) {
|
|
89
|
+
const node_r4 = ctx.$implicit;
|
|
90
|
+
const ctx_r0 = i0.ɵɵnextContext(2);
|
|
91
|
+
i0.ɵɵstyleProp("cursor", ctx_r0.onNodeClick ? "pointer" : "default")("outline", "none");
|
|
92
|
+
i0.ɵɵattribute("data-mol-id", "graph-view-node-hit-" + node_r4.id)("aria-label", ctx_r0.nodeAria(node_r4));
|
|
93
|
+
i0.ɵɵadvance();
|
|
94
|
+
i0.ɵɵconditional(ctx_r0.nodeRenderer ? 1 : 2);
|
|
95
|
+
} }
|
|
96
|
+
function GraphView_Conditional_1_Template(rf, ctx) { if (rf & 1) {
|
|
97
|
+
i0.ɵɵnamespaceSVG();
|
|
98
|
+
i0.ɵɵelementStart(0, "svg", 3)(1, "g", 4);
|
|
99
|
+
i0.ɵɵrepeaterCreate(2, GraphView_Conditional_1_For_3_Template, 2, 1, null, null, _forTrack0);
|
|
100
|
+
i0.ɵɵelementEnd();
|
|
101
|
+
i0.ɵɵelementStart(4, "g", 5);
|
|
102
|
+
i0.ɵɵrepeaterCreate(5, GraphView_Conditional_1_For_6_Template, 3, 7, "g", 6, _forTrack1);
|
|
103
|
+
i0.ɵɵelementEnd()();
|
|
104
|
+
} if (rf & 2) {
|
|
105
|
+
const ctx_r0 = i0.ɵɵnextContext();
|
|
106
|
+
i0.ɵɵstyleProp("display", "block");
|
|
107
|
+
i0.ɵɵattribute("viewBox", ctx_r0.viewBox());
|
|
108
|
+
i0.ɵɵadvance(2);
|
|
109
|
+
i0.ɵɵrepeater(ctx_r0.renderableEdges());
|
|
110
|
+
i0.ɵɵadvance(3);
|
|
111
|
+
i0.ɵɵrepeater(ctx_r0.positionedNodes());
|
|
112
|
+
} }
|
|
113
|
+
/** Default base radius (world units) of an unweighted node. */
|
|
114
|
+
const NODE_RADIUS = 8;
|
|
115
|
+
/**
|
|
116
|
+
* Force-directed graph view (Obsidian-style).
|
|
117
|
+
*
|
|
118
|
+
* Renders nodes + edges into an SVG, computing positions via a built-in
|
|
119
|
+
* minimal velocity-Verlet simulation. Three layouts are supported —
|
|
120
|
+
* `force` (default), `circular` and `grid` — and either nodes or edges
|
|
121
|
+
* can be overridden via custom templates.
|
|
122
|
+
*
|
|
123
|
+
* The host IS the outer `<div>` (`div[mol-graph-view]`), matching React's root
|
|
124
|
+
* exactly. Style is driven by `getClassMap()`. Inline styles are reserved for
|
|
125
|
+
* SVG geometry — `transform`, viewBox computation, stroke widths — which
|
|
126
|
+
* classes can't express.
|
|
127
|
+
*/
|
|
128
|
+
export class GraphView {
|
|
129
|
+
/** Nodes to render. */
|
|
130
|
+
nodes;
|
|
131
|
+
/** Edges to render. */
|
|
132
|
+
edges;
|
|
133
|
+
/** Fired when the user clicks (or activates) a node. */
|
|
134
|
+
onNodeClick;
|
|
135
|
+
/** Currently-selected node id (highlighted in the view). */
|
|
136
|
+
selectedNodeId;
|
|
137
|
+
/** Layout strategy (defaults to `'force'` at read time). */
|
|
138
|
+
layout;
|
|
139
|
+
/** Custom node renderer template. */
|
|
140
|
+
nodeRenderer;
|
|
141
|
+
/** Custom edge renderer template. */
|
|
142
|
+
edgeRenderer;
|
|
143
|
+
/** Force-layout tunables; ignored for non-force layouts. */
|
|
144
|
+
forceOptions;
|
|
145
|
+
/** Extra classes merged onto the outer wrapper. */
|
|
146
|
+
className;
|
|
147
|
+
/** The bonded translation function. */
|
|
148
|
+
i18n = useTranslation();
|
|
149
|
+
/**
|
|
150
|
+
* The current class map.
|
|
151
|
+
* @returns The UIClassMap.
|
|
152
|
+
*/
|
|
153
|
+
cm() {
|
|
154
|
+
return getClassMap();
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Computes the wrapper class list.
|
|
158
|
+
* @returns The class string.
|
|
159
|
+
*/
|
|
160
|
+
classes() {
|
|
161
|
+
return this.cm().cn(this.cm().position('relative'), this.cm().surfaceSecondary, this.className);
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Computes the empty-state class list.
|
|
165
|
+
* @returns The class string.
|
|
166
|
+
*/
|
|
167
|
+
emptyClasses() {
|
|
168
|
+
return this.cm().cn(this.cm().position('absolute'), this.cm().sp('p', 6));
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* The canvas' accessible name.
|
|
172
|
+
* @returns The translated label.
|
|
173
|
+
*/
|
|
174
|
+
ariaLabel() {
|
|
175
|
+
return this.i18n.t('graphView.aria.canvas', {}, { defaultValue: 'Graph view' });
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* The empty-state message.
|
|
179
|
+
* @returns The translated message.
|
|
180
|
+
*/
|
|
181
|
+
emptyLabel() {
|
|
182
|
+
return this.i18n.t('graphView.empty', {}, { defaultValue: 'No nodes to display' });
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* One node hit group's accessible name.
|
|
186
|
+
* @param node - The node.
|
|
187
|
+
* @returns The translated label.
|
|
188
|
+
*/
|
|
189
|
+
nodeAria(node) {
|
|
190
|
+
return this.i18n.t('graphView.aria.node', { label: node.label }, { defaultValue: 'Node {{label}}' });
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* World-space positions for every node, from the chosen layout. The force
|
|
194
|
+
* simulation is deterministic given a fixed seed, so repeated reads (change
|
|
195
|
+
* detection runs several) produce identical coordinates.
|
|
196
|
+
* @returns The positioned nodes.
|
|
197
|
+
*/
|
|
198
|
+
positionedNodes() {
|
|
199
|
+
return layoutNodes(this.nodes ?? [], this.edges ?? [], this.layout ?? 'force', this.forceOptions);
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* The edges whose endpoints both exist, with both endpoints resolved.
|
|
203
|
+
* @returns The renderable edges, in input order.
|
|
204
|
+
*/
|
|
205
|
+
renderableEdges() {
|
|
206
|
+
const byId = new Map();
|
|
207
|
+
for (const node of this.positionedNodes())
|
|
208
|
+
byId.set(node.id, node);
|
|
209
|
+
const out = [];
|
|
210
|
+
for (const edge of this.edges ?? []) {
|
|
211
|
+
const src = byId.get(edge.source);
|
|
212
|
+
const tgt = byId.get(edge.target);
|
|
213
|
+
if (src && tgt)
|
|
214
|
+
out.push({ edge, src, tgt });
|
|
215
|
+
}
|
|
216
|
+
return out;
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* The SVG viewBox that fits the layout bounds.
|
|
220
|
+
* @returns The viewBox string.
|
|
221
|
+
*/
|
|
222
|
+
viewBox() {
|
|
223
|
+
const box = boundingBox(this.positionedNodes(), 40);
|
|
224
|
+
return box
|
|
225
|
+
? `${box.minX} ${box.minY} ${Math.max(1, box.maxX - box.minX)} ${Math.max(1, box.maxY - box.minY)}`
|
|
226
|
+
: '-100 -100 200 200';
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Whether a node is the selected one.
|
|
230
|
+
* @param node - The node.
|
|
231
|
+
* @returns True when it matches `selectedNodeId`.
|
|
232
|
+
*/
|
|
233
|
+
isSelected(node) {
|
|
234
|
+
return node.id === this.selectedNodeId;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* The rendered radius of a node, scaled by its weight.
|
|
238
|
+
* @param node - The node.
|
|
239
|
+
* @returns The radius in world units.
|
|
240
|
+
*/
|
|
241
|
+
radius(node) {
|
|
242
|
+
return NODE_RADIUS * Math.sqrt(Math.max(0.25, node.weight ?? 1));
|
|
243
|
+
}
|
|
244
|
+
/**
|
|
245
|
+
* Calls `onNodeClick` for a node.
|
|
246
|
+
* @param node - The node.
|
|
247
|
+
*/
|
|
248
|
+
activate(node) {
|
|
249
|
+
this.onNodeClick?.(node);
|
|
250
|
+
}
|
|
251
|
+
/**
|
|
252
|
+
* Activates a node on Enter or Space, as React's keydown handler does.
|
|
253
|
+
* @param event - The keyboard event.
|
|
254
|
+
* @param node - The node.
|
|
255
|
+
*/
|
|
256
|
+
keydown(event, node) {
|
|
257
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
258
|
+
event.preventDefault();
|
|
259
|
+
this.onNodeClick?.(node);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
static ɵfac = function GraphView_Factory(__ngFactoryType__) { return new (__ngFactoryType__ || GraphView)(); };
|
|
263
|
+
static ɵcmp = /*@__PURE__*/ i0.ɵɵdefineComponent({ type: GraphView, selectors: [["div", "mol-graph-view", ""]], hostAttrs: ["role", "application", "data-mol-id", "graph-view"], hostVars: 9, hostBindings: function GraphView_HostBindings(rf, ctx) { if (rf & 2) {
|
|
264
|
+
i0.ɵɵattribute("aria-label", ctx.ariaLabel());
|
|
265
|
+
i0.ɵɵclassMap(ctx.classes());
|
|
266
|
+
i0.ɵɵstyleProp("width", "100%")("height", "100%")("overflow", "hidden");
|
|
267
|
+
} }, inputs: { nodes: "nodes", edges: "edges", onNodeClick: "onNodeClick", selectedNodeId: "selectedNodeId", layout: "layout", nodeRenderer: "nodeRenderer", edgeRenderer: "edgeRenderer", forceOptions: "forceOptions", className: "className" }, decls: 2, vars: 1, consts: [["data-mol-id", "graph-view-empty", "role", "status", 3, "class", "inset", "display", "place-items"], ["data-mol-id", "graph-view-svg", "width", "100%", "height", "100%", "preserveAspectRatio", "xMidYMid meet", 3, "display"], ["data-mol-id", "graph-view-empty", "role", "status"], ["data-mol-id", "graph-view-svg", "width", "100%", "height", "100%", "preserveAspectRatio", "xMidYMid meet"], ["data-mol-id", "graph-view-edges"], ["data-mol-id", "graph-view-nodes"], ["role", "button", "tabindex", "0", 3, "cursor", "outline"], ["stroke", "currentColor", "stroke-width", "1", "opacity", "0.4"], [3, "ngTemplateOutlet", "ngTemplateOutletContext"], ["role", "button", "tabindex", "0", 3, "click", "keydown"], ["fill", "currentColor", "stroke", "currentColor"], ["y", "4", "font-size", "11", "fill", "currentColor"]], template: function GraphView_Template(rf, ctx) { if (rf & 1) {
|
|
268
|
+
i0.ɵɵconditionalCreate(0, GraphView_Conditional_0_Template, 2, 9, "div", 0)(1, GraphView_Conditional_1_Template, 7, 3, "svg", 1);
|
|
269
|
+
} if (rf & 2) {
|
|
270
|
+
i0.ɵɵconditional(ctx.positionedNodes().length === 0 ? 0 : 1);
|
|
271
|
+
} }, dependencies: [NgTemplateOutlet], encapsulation: 2 });
|
|
272
|
+
}
|
|
273
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassMetadata(GraphView, [{
|
|
274
|
+
type: Component,
|
|
275
|
+
args: [{
|
|
276
|
+
selector: 'div[mol-graph-view]',
|
|
277
|
+
standalone: true,
|
|
278
|
+
imports: [NgTemplateOutlet],
|
|
279
|
+
inputs: [
|
|
280
|
+
'nodes',
|
|
281
|
+
'edges',
|
|
282
|
+
'onNodeClick',
|
|
283
|
+
'selectedNodeId',
|
|
284
|
+
'layout',
|
|
285
|
+
'nodeRenderer',
|
|
286
|
+
'edgeRenderer',
|
|
287
|
+
'forceOptions',
|
|
288
|
+
'className',
|
|
289
|
+
],
|
|
290
|
+
host: {
|
|
291
|
+
role: 'application',
|
|
292
|
+
'[attr.aria-label]': 'ariaLabel()',
|
|
293
|
+
'data-mol-id': 'graph-view',
|
|
294
|
+
'[class]': 'classes()',
|
|
295
|
+
'[style.width]': '"100%"',
|
|
296
|
+
'[style.height]': '"100%"',
|
|
297
|
+
'[style.overflow]': '"hidden"',
|
|
298
|
+
},
|
|
299
|
+
template: `@if (positionedNodes().length === 0) {
|
|
300
|
+
<div
|
|
301
|
+
data-mol-id="graph-view-empty"
|
|
302
|
+
role="status"
|
|
303
|
+
[class]="emptyClasses()"
|
|
304
|
+
[style.inset]="'0px'"
|
|
305
|
+
[style.display]="'grid'"
|
|
306
|
+
[style.place-items]="'center'"
|
|
307
|
+
>
|
|
308
|
+
{{ emptyLabel() }}
|
|
309
|
+
</div>
|
|
310
|
+
} @else {
|
|
311
|
+
<svg
|
|
312
|
+
data-mol-id="graph-view-svg"
|
|
313
|
+
width="100%"
|
|
314
|
+
height="100%"
|
|
315
|
+
[attr.viewBox]="viewBox()"
|
|
316
|
+
preserveAspectRatio="xMidYMid meet"
|
|
317
|
+
[style.display]="'block'"
|
|
318
|
+
>
|
|
319
|
+
<g data-mol-id="graph-view-edges">
|
|
320
|
+
@for (item of renderableEdges(); track item.edge.id) {
|
|
321
|
+
@if (edgeRenderer) {
|
|
322
|
+
<g [attr.data-mol-id]="'graph-view-edge-' + item.edge.id">
|
|
323
|
+
<ng-container
|
|
324
|
+
[ngTemplateOutlet]="edgeRenderer"
|
|
325
|
+
[ngTemplateOutletContext]="{ a0: item.edge, a1: item.src, a2: item.tgt }"
|
|
326
|
+
/>
|
|
327
|
+
</g>
|
|
328
|
+
} @else {
|
|
329
|
+
<line
|
|
330
|
+
[attr.data-mol-id]="'graph-view-edge-' + item.edge.id"
|
|
331
|
+
[attr.x1]="item.src.x"
|
|
332
|
+
[attr.y1]="item.src.y"
|
|
333
|
+
[attr.x2]="item.tgt.x"
|
|
334
|
+
[attr.y2]="item.tgt.y"
|
|
335
|
+
stroke="currentColor"
|
|
336
|
+
stroke-width="1"
|
|
337
|
+
opacity="0.4"
|
|
338
|
+
/>
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
</g>
|
|
342
|
+
<g data-mol-id="graph-view-nodes">
|
|
343
|
+
@for (node of positionedNodes(); track node.id) {
|
|
344
|
+
<g
|
|
345
|
+
[attr.data-mol-id]="'graph-view-node-hit-' + node.id"
|
|
346
|
+
role="button"
|
|
347
|
+
[attr.aria-label]="nodeAria(node)"
|
|
348
|
+
tabindex="0"
|
|
349
|
+
(click)="activate(node)"
|
|
350
|
+
(keydown)="keydown($event, node)"
|
|
351
|
+
[style.cursor]="onNodeClick ? 'pointer' : 'default'"
|
|
352
|
+
[style.outline]="'none'"
|
|
353
|
+
>
|
|
354
|
+
@if (nodeRenderer) {
|
|
355
|
+
<ng-container
|
|
356
|
+
[ngTemplateOutlet]="nodeRenderer"
|
|
357
|
+
[ngTemplateOutletContext]="{ a0: node }"
|
|
358
|
+
/>
|
|
359
|
+
} @else {
|
|
360
|
+
<g
|
|
361
|
+
[attr.data-mol-id]="'graph-view-node-' + node.id"
|
|
362
|
+
[attr.data-selected]="isSelected(node) ? 'true' : 'false'"
|
|
363
|
+
[attr.transform]="'translate(' + node.x + ', ' + node.y + ')'"
|
|
364
|
+
>
|
|
365
|
+
<circle
|
|
366
|
+
[attr.r]="radius(node)"
|
|
367
|
+
fill="currentColor"
|
|
368
|
+
[attr.opacity]="isSelected(node) ? 1 : 0.85"
|
|
369
|
+
stroke="currentColor"
|
|
370
|
+
[attr.stroke-width]="isSelected(node) ? 2 : 0"
|
|
371
|
+
/>
|
|
372
|
+
<text
|
|
373
|
+
[attr.x]="radius(node) + 4"
|
|
374
|
+
y="4"
|
|
375
|
+
font-size="11"
|
|
376
|
+
fill="currentColor"
|
|
377
|
+
[attr.opacity]="isSelected(node) ? 1 : 0.75"
|
|
378
|
+
[style.pointer-events]="'none'"
|
|
379
|
+
[style.user-select]="'none'"
|
|
380
|
+
>
|
|
381
|
+
{{ node.label }}
|
|
382
|
+
</text>
|
|
383
|
+
</g>
|
|
384
|
+
}
|
|
385
|
+
</g>
|
|
386
|
+
}
|
|
387
|
+
</g>
|
|
388
|
+
</svg>
|
|
389
|
+
}`,
|
|
390
|
+
}]
|
|
391
|
+
}], null, null); })();
|
|
392
|
+
(() => { (typeof ngDevMode === "undefined" || ngDevMode) && i0.ɵsetClassDebugInfo(GraphView, { className: "GraphView", filePath: "graph-view.component.ts", lineNumber: 167 }); })();
|
|
393
|
+
//# sourceMappingURL=graph-view.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"graph-view.component.js","sourceRoot":"","sources":["../src/graph-view.component.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAA;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAA;AAEzC,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAA;AACtD,OAAO,EAAE,WAAW,EAAmB,MAAM,kBAAkB,CAAA;AAE/D,OAAO,EAAE,WAAW,EAA2B,WAAW,EAAE,MAAM,aAAa,CAAA;;;;;;;IA6DzE,8BAOC;IACC,YACF;IAAA,iBAAM;;;IANJ,oCAAwB;IAGxB,AADA,AADA,8BAAqB,mBACG,yBACM;IAE9B,cACF;IADE,oDACF;;;;IAaQ,yBAA0D;IACxD,2BAGE;IACJ,iBAAI;;;;;IAHA,cAAiC;IACjC,AADA,sDAAiC,+FACwC;;;;IAI7E,0BASE;;;;;;IAVF,AAPF,0FAAoB,0EAOX;;;IAPT,6CAkBC;;;;IAgBG,2BAGE;;;;IADA,AADA,sDAAiC,gEACO;;;;IAG1C,yBAIC;IACC,6BAME;IACF,gCAQC;IACC,YACF;IACF,AADE,iBAAO,EACL;;;;;IAjBA,cAAuB;;IAYvB,cAA+B;IAC/B,AADA,wCAA+B,uBACH;;IAE5B,cACF;IADE,8CACF;;;;;IAtCN,4BASC;IAHC,AADA,yMAAS,wBAAc,KAAC,sMACb,+BAAqB,KAAC;IAS/B,AALF,wGAAoB,qEAKX;IA0BX,iBAAI;;;;IAjCF,AADA,oEAAoD,mBAC5B;;IAExB,cA8BC;IA9BD,6CA8BC;;;;IAjEP,AARF,8BAOC,WACmC;IAChC,4FAoBC;IACH,iBAAI;IACJ,4BAAkC;IAChC,wFA2CC;IAEL,AADE,iBAAI,EACA;;;IAvEJ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cApHrB,SAAS;eAAC;gBACT,QAAQ,EAAE,qBAAqB;gBAC/B,UAAU,EAAE,IAAI;gBAChB,OAAO,EAAE,CAAC,gBAAgB,CAAC;gBAC3B,MAAM,EAAE;oBACN,OAAO;oBACP,OAAO;oBACP,aAAa;oBACb,gBAAgB;oBAChB,QAAQ;oBACR,cAAc;oBACd,cAAc;oBACd,cAAc;oBACd,WAAW;iBACZ;gBACD,IAAI,EAAE;oBACJ,IAAI,EAAE,aAAa;oBACnB,mBAAmB,EAAE,aAAa;oBAClC,aAAa,EAAE,YAAY;oBAC3B,SAAS,EAAE,WAAW;oBACtB,eAAe,EAAE,QAAQ;oBACzB,gBAAgB,EAAE,QAAQ;oBAC1B,kBAAkB,EAAE,UAAU;iBAC/B;gBACD,QAAQ,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;MA0FN;aACL;;kFACY,SAAS"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Angular force-directed graph view (Obsidian-style) — the counterpart of
|
|
3
|
+
* `@molecule/app-feature-graph-view-react`: the same exports, the same props
|
|
4
|
+
* (React names), and the same DOM for the same input.
|
|
5
|
+
*
|
|
6
|
+
* Exports:
|
|
7
|
+
* - `<GraphView>` (`div[mol-graph-view]`) — top-level node-and-edge
|
|
8
|
+
* visualization with built-in `force`, `circular`, and `grid` layouts,
|
|
9
|
+
* click + selection support, and pluggable node / edge templates.
|
|
10
|
+
* - `GraphNode`, `GraphEdge`, `GraphLayout`, `GraphPoint`, `PositionedNode`,
|
|
11
|
+
* `GraphNodeRenderer`, `GraphEdgeRenderer`, `GraphViewProps` types.
|
|
12
|
+
* - Pure layout helpers (`forceLayout`, `circularLayout`, `gridLayout`,
|
|
13
|
+
* `layoutNodes`, `boundingBox`, `createRng`).
|
|
14
|
+
*
|
|
15
|
+
* Used by note-taking and other apps to visualize page / note linkages
|
|
16
|
+
* the same way Obsidian does — a force-directed map of which notes link
|
|
17
|
+
* to which.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* import { Component } from '@angular/core'
|
|
22
|
+
* import { GraphView, type GraphEdge, type GraphNode } from '@molecule/app-feature-graph-view-angular'
|
|
23
|
+
*
|
|
24
|
+
* const noteNodes: GraphNode[] = [
|
|
25
|
+
* { id: 'a', label: 'Alpha' },
|
|
26
|
+
* { id: 'b', label: 'Beta', group: 'project', weight: 2 },
|
|
27
|
+
* ]
|
|
28
|
+
* const linkEdges: GraphEdge[] = [{ id: 'e1', source: 'a', target: 'b' }]
|
|
29
|
+
*
|
|
30
|
+
* @Component({
|
|
31
|
+
* selector: 'app-note-graph',
|
|
32
|
+
* standalone: true,
|
|
33
|
+
* imports: [GraphView],
|
|
34
|
+
* template: `<div mol-graph-view [nodes]="nodes" [edges]="edges" [onNodeClick]="open"></div>`,
|
|
35
|
+
* })
|
|
36
|
+
* export class NoteGraph {
|
|
37
|
+
* nodes = noteNodes
|
|
38
|
+
* edges = linkEdges
|
|
39
|
+
* open(node: GraphNode): void {
|
|
40
|
+
* console.log(`open ${node.id}`)
|
|
41
|
+
* }
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @remarks
|
|
46
|
+
* The root element fills 100% of its parent — the PARENT must have an
|
|
47
|
+
* explicit height (e.g. a fixed-height panel or a flex/grid track) or
|
|
48
|
+
* the graph renders zero-tall and appears blank.
|
|
49
|
+
*
|
|
50
|
+
* Interaction surface is click / keyboard-activate + `selectedNodeId`
|
|
51
|
+
* highlighting only. Nodes are NOT draggable and there is no built-in
|
|
52
|
+
* pan / zoom — the SVG `viewBox` auto-fits the layout bounds.
|
|
53
|
+
*
|
|
54
|
+
* The renderer props are Angular templates, rendered with `ngTemplateOutlet`:
|
|
55
|
+
* `nodeRenderer` receives the positioned node as `a0`; `edgeRenderer` receives
|
|
56
|
+
* the edge as `a0`, the source node as `a1` and the target node as `a2`.
|
|
57
|
+
*
|
|
58
|
+
* Layout is deterministic (seeded RNG), computed once per
|
|
59
|
+
* `(nodes, edges, layout, forceOptions)` change. `forceOptions` is
|
|
60
|
+
* ignored by the `circular` and `grid` layouts.
|
|
61
|
+
*
|
|
62
|
+
* @module
|
|
63
|
+
*/
|
|
64
|
+
export * from './graph-view.component.js';
|
|
65
|
+
export * from './layout.js';
|
|
66
|
+
export * from './types.js';
|
|
67
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AAEH,cAAc,2BAA2B,CAAA;AACzC,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Angular force-directed graph view (Obsidian-style) — the counterpart of
|
|
3
|
+
* `@molecule/app-feature-graph-view-react`: the same exports, the same props
|
|
4
|
+
* (React names), and the same DOM for the same input.
|
|
5
|
+
*
|
|
6
|
+
* Exports:
|
|
7
|
+
* - `<GraphView>` (`div[mol-graph-view]`) — top-level node-and-edge
|
|
8
|
+
* visualization with built-in `force`, `circular`, and `grid` layouts,
|
|
9
|
+
* click + selection support, and pluggable node / edge templates.
|
|
10
|
+
* - `GraphNode`, `GraphEdge`, `GraphLayout`, `GraphPoint`, `PositionedNode`,
|
|
11
|
+
* `GraphNodeRenderer`, `GraphEdgeRenderer`, `GraphViewProps` types.
|
|
12
|
+
* - Pure layout helpers (`forceLayout`, `circularLayout`, `gridLayout`,
|
|
13
|
+
* `layoutNodes`, `boundingBox`, `createRng`).
|
|
14
|
+
*
|
|
15
|
+
* Used by note-taking and other apps to visualize page / note linkages
|
|
16
|
+
* the same way Obsidian does — a force-directed map of which notes link
|
|
17
|
+
* to which.
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* ```ts
|
|
21
|
+
* import { Component } from '@angular/core'
|
|
22
|
+
* import { GraphView, type GraphEdge, type GraphNode } from '@molecule/app-feature-graph-view-angular'
|
|
23
|
+
*
|
|
24
|
+
* const noteNodes: GraphNode[] = [
|
|
25
|
+
* { id: 'a', label: 'Alpha' },
|
|
26
|
+
* { id: 'b', label: 'Beta', group: 'project', weight: 2 },
|
|
27
|
+
* ]
|
|
28
|
+
* const linkEdges: GraphEdge[] = [{ id: 'e1', source: 'a', target: 'b' }]
|
|
29
|
+
*
|
|
30
|
+
* @Component({
|
|
31
|
+
* selector: 'app-note-graph',
|
|
32
|
+
* standalone: true,
|
|
33
|
+
* imports: [GraphView],
|
|
34
|
+
* template: `<div mol-graph-view [nodes]="nodes" [edges]="edges" [onNodeClick]="open"></div>`,
|
|
35
|
+
* })
|
|
36
|
+
* export class NoteGraph {
|
|
37
|
+
* nodes = noteNodes
|
|
38
|
+
* edges = linkEdges
|
|
39
|
+
* open(node: GraphNode): void {
|
|
40
|
+
* console.log(`open ${node.id}`)
|
|
41
|
+
* }
|
|
42
|
+
* }
|
|
43
|
+
* ```
|
|
44
|
+
*
|
|
45
|
+
* @remarks
|
|
46
|
+
* The root element fills 100% of its parent — the PARENT must have an
|
|
47
|
+
* explicit height (e.g. a fixed-height panel or a flex/grid track) or
|
|
48
|
+
* the graph renders zero-tall and appears blank.
|
|
49
|
+
*
|
|
50
|
+
* Interaction surface is click / keyboard-activate + `selectedNodeId`
|
|
51
|
+
* highlighting only. Nodes are NOT draggable and there is no built-in
|
|
52
|
+
* pan / zoom — the SVG `viewBox` auto-fits the layout bounds.
|
|
53
|
+
*
|
|
54
|
+
* The renderer props are Angular templates, rendered with `ngTemplateOutlet`:
|
|
55
|
+
* `nodeRenderer` receives the positioned node as `a0`; `edgeRenderer` receives
|
|
56
|
+
* the edge as `a0`, the source node as `a1` and the target node as `a2`.
|
|
57
|
+
*
|
|
58
|
+
* Layout is deterministic (seeded RNG), computed once per
|
|
59
|
+
* `(nodes, edges, layout, forceOptions)` change. `forceOptions` is
|
|
60
|
+
* ignored by the `circular` and `grid` layouts.
|
|
61
|
+
*
|
|
62
|
+
* @module
|
|
63
|
+
*/
|
|
64
|
+
export * from './graph-view.component.js';
|
|
65
|
+
export * from './layout.js';
|
|
66
|
+
export * from './types.js';
|
|
67
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8DG;AAEH,cAAc,2BAA2B,CAAA;AACzC,cAAc,aAAa,CAAA;AAC3B,cAAc,YAAY,CAAA"}
|