@xyo-network/react-node-renderer 7.5.8 → 7.5.11
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/browser/Cytoscape/CytoscapeElements.d.ts +2 -6
- package/dist/browser/Cytoscape/CytoscapeElements.d.ts.map +1 -1
- package/dist/browser/components/module/graph/Popper.d.ts +3 -2
- package/dist/browser/components/module/graph/Popper.d.ts.map +1 -1
- package/dist/browser/components/module/graph/node/hooks/useNodeElement.d.ts +8 -5
- package/dist/browser/components/module/graph/node/hooks/useNodeElement.d.ts.map +1 -1
- package/dist/browser/components/relational/graph/Graph.d.ts.map +1 -1
- package/dist/browser/hooks/cytoscape/elements/useRenderNewElements.d.ts +1 -1
- package/dist/browser/hooks/cytoscape/elements/useRenderNewElements.d.ts.map +1 -1
- package/dist/browser/index.mjs +362 -423
- package/dist/browser/index.mjs.map +1 -1
- package/package.json +188 -59
- package/src/Cytoscape/CytoscapeElements.ts +0 -96
- package/src/Cytoscape/CytoscapeIcons.tsx +0 -23
- package/src/Cytoscape/CytoscapeStyles.ts +0 -46
- package/src/Cytoscape/index.ts +0 -4
- package/src/Cytoscape/lib/CyNodeModuleTypes.ts +0 -1
- package/src/Cytoscape/lib/encodeSvg.ts +0 -19
- package/src/Cytoscape/lib/iconMap.ts +0 -12
- package/src/Cytoscape/lib/index.ts +0 -5
- package/src/Cytoscape/lib/layout/ColaLayout.ts +0 -5
- package/src/Cytoscape/lib/layout/ConcentricLayout.ts +0 -12
- package/src/Cytoscape/lib/layout/index.ts +0 -2
- package/src/Cytoscape/lib/parseModuleType.ts +0 -29
- package/src/components/cytoscape-extensions/WithExtensions.tsx +0 -16
- package/src/components/cytoscape-extensions/index.ts +0 -1
- package/src/components/index.ts +0 -3
- package/src/components/lib/RelationalGraphProps.ts +0 -16
- package/src/components/lib/index.ts +0 -1
- package/src/components/module/CardParser.stories.tsx +0 -36
- package/src/components/module/CardParser.tsx +0 -24
- package/src/components/module/graph/DetailsFlexbox.tsx +0 -22
- package/src/components/module/graph/GraphFlexBox.stories.tsx +0 -118
- package/src/components/module/graph/GraphFlexBox.tsx +0 -84
- package/src/components/module/graph/Popper.tsx +0 -77
- package/src/components/module/graph/index.ts +0 -1
- package/src/components/module/graph/node/Hover.tsx +0 -38
- package/src/components/module/graph/node/hooks/index.ts +0 -1
- package/src/components/module/graph/node/hooks/useNodeElement.tsx +0 -41
- package/src/components/module/graph/node/index.ts +0 -1
- package/src/components/module/index.ts +0 -2
- package/src/components/relational/graph/Graph.stories.tsx +0 -201
- package/src/components/relational/graph/Graph.tsx +0 -200
- package/src/components/relational/graph/GraphCola.stories.tsx +0 -187
- package/src/components/relational/graph/GraphCoseBilkent.stories.tsx +0 -186
- package/src/components/relational/graph/GraphDagre.stories.tsx +0 -186
- package/src/components/relational/graph/GraphEuler.stories.tsx +0 -187
- package/src/components/relational/graph/GraphEvents.stories.tsx +0 -82
- package/src/components/relational/graph/ProvidedNodeRenderer.tsx +0 -23
- package/src/components/relational/graph/index.ts +0 -2
- package/src/components/relational/graph/story/TestData.tsx +0 -51
- package/src/components/relational/graph/story/index.ts +0 -1
- package/src/components/relational/index.ts +0 -1
- package/src/contexts/CytoscapeInstance/Context.ts +0 -5
- package/src/contexts/CytoscapeInstance/Provider.tsx +0 -24
- package/src/contexts/CytoscapeInstance/State.ts +0 -8
- package/src/contexts/CytoscapeInstance/index.ts +0 -4
- package/src/contexts/CytoscapeInstance/use.ts +0 -5
- package/src/contexts/index.ts +0 -1
- package/src/hooks/cytoscape/elements/index.ts +0 -2
- package/src/hooks/cytoscape/elements/useCytoscapeElements.ts +0 -47
- package/src/hooks/cytoscape/elements/useElements.tsx +0 -15
- package/src/hooks/cytoscape/elements/useHoveredNode.tsx +0 -34
- package/src/hooks/cytoscape/elements/useNewElements.tsx +0 -17
- package/src/hooks/cytoscape/elements/useRenderNewElements.tsx +0 -17
- package/src/hooks/cytoscape/elements/useSelectedElement.tsx +0 -25
- package/src/hooks/cytoscape/index.ts +0 -4
- package/src/hooks/cytoscape/useCytoscapeOptions.ts +0 -29
- package/src/hooks/cytoscape/useCytoscapeStyle.tsx +0 -34
- package/src/hooks/cytoscape/useIcons.tsx +0 -22
- package/src/hooks/cytoscape/useModuleDetails.tsx +0 -83
- package/src/hooks/cytoscape/useRelationalGraphOptions.tsx +0 -23
- package/src/hooks/index.ts +0 -1
- package/src/index.ts +0 -4
- package/src/types/global.d.ts +0 -19
- package/src/types/images.d.ts +0 -5
- package/src/types/theme.d.ts +0 -1
package/dist/browser/index.mjs
CHANGED
|
@@ -1,60 +1,47 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
1
|
// src/components/module/CardParser.tsx
|
|
5
2
|
import { asArchivistInstance, isArchivistInstance } from "@xyo-network/archivist-model";
|
|
6
3
|
import { asDivinerInstance, isDivinerInstance } from "@xyo-network/diviner-model";
|
|
7
4
|
import { ArchivistCard } from "@xyo-network/react-archivist";
|
|
8
5
|
import { DivinerCard, ModuleCard } from "@xyo-network/react-module";
|
|
9
|
-
import
|
|
10
|
-
var ModuleCardParser =
|
|
6
|
+
import { jsx } from "react/jsx-runtime";
|
|
7
|
+
var ModuleCardParser = ({ mod }) => {
|
|
11
8
|
switch (true) {
|
|
12
9
|
case isArchivistInstance(mod): {
|
|
13
|
-
return /* @__PURE__ */
|
|
14
|
-
mod: asArchivistInstance(mod)
|
|
15
|
-
});
|
|
10
|
+
return /* @__PURE__ */ jsx(ArchivistCard, { mod: asArchivistInstance(mod) });
|
|
16
11
|
}
|
|
17
12
|
case isDivinerInstance(mod): {
|
|
18
|
-
return /* @__PURE__ */
|
|
19
|
-
mod: asDivinerInstance(mod)
|
|
20
|
-
});
|
|
13
|
+
return /* @__PURE__ */ jsx(DivinerCard, { mod: asDivinerInstance(mod) });
|
|
21
14
|
}
|
|
22
15
|
default: {
|
|
23
|
-
return /* @__PURE__ */
|
|
24
|
-
mod
|
|
25
|
-
});
|
|
16
|
+
return /* @__PURE__ */ jsx(ModuleCard, { mod });
|
|
26
17
|
}
|
|
27
18
|
}
|
|
28
|
-
}
|
|
19
|
+
};
|
|
29
20
|
|
|
30
21
|
// src/components/module/graph/GraphFlexBox.tsx
|
|
31
22
|
import { Button as Button3 } from "@mui/material";
|
|
32
|
-
import
|
|
23
|
+
import { useRef as useRef3 } from "react";
|
|
33
24
|
|
|
34
25
|
// src/contexts/CytoscapeInstance/Context.ts
|
|
35
26
|
import { createContextEx } from "@xylabs/react-shared";
|
|
36
27
|
var CytoscapeInstanceContext = createContextEx();
|
|
37
28
|
|
|
38
29
|
// src/contexts/CytoscapeInstance/Provider.tsx
|
|
39
|
-
import
|
|
40
|
-
|
|
30
|
+
import { useMemo, useState } from "react";
|
|
31
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
32
|
+
var CytoscapeInstanceProvider = ({ children, defaultInstance }) => {
|
|
41
33
|
const [cy, setCy] = useState(() => defaultInstance);
|
|
42
34
|
const value = useMemo(() => ({
|
|
43
35
|
cy,
|
|
44
36
|
provided: true,
|
|
45
37
|
setCy
|
|
46
|
-
}), [
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
]);
|
|
50
|
-
return /* @__PURE__ */ React2.createElement(CytoscapeInstanceContext, {
|
|
51
|
-
value
|
|
52
|
-
}, children);
|
|
53
|
-
}, "CytoscapeInstanceProvider");
|
|
38
|
+
}), [cy, setCy]);
|
|
39
|
+
return /* @__PURE__ */ jsx2(CytoscapeInstanceContext, { value, children });
|
|
40
|
+
};
|
|
54
41
|
|
|
55
42
|
// src/contexts/CytoscapeInstance/use.ts
|
|
56
43
|
import { useContextEx } from "@xylabs/react-shared";
|
|
57
|
-
var useCytoscapeInstance =
|
|
44
|
+
var useCytoscapeInstance = (required = false) => useContextEx(CytoscapeInstanceContext, "CytoscapeInstance", required);
|
|
58
45
|
|
|
59
46
|
// src/hooks/cytoscape/elements/useCytoscapeElements.ts
|
|
60
47
|
import { useAsyncEffect } from "@xylabs/react-async-effect";
|
|
@@ -68,7 +55,7 @@ import { exists, isFalsy } from "@xylabs/sdk-js";
|
|
|
68
55
|
import { isDefined } from "@xylabs/sdk-js";
|
|
69
56
|
import { renderToStaticMarkup } from "react-dom/server";
|
|
70
57
|
var dataUri = "data:image/svg+xml,";
|
|
71
|
-
var encodeSvg =
|
|
58
|
+
var encodeSvg = (reactElement, color) => {
|
|
72
59
|
const svgString = renderToStaticMarkup(reactElement);
|
|
73
60
|
const doc = new DOMParser().parseFromString(svgString, "text/html");
|
|
74
61
|
const svgElement = doc.querySelectorAll("svg")[0];
|
|
@@ -78,10 +65,10 @@ var encodeSvg = /* @__PURE__ */ __name((reactElement, color) => {
|
|
|
78
65
|
svgElement.style.fill = color ?? "black";
|
|
79
66
|
}
|
|
80
67
|
return `${dataUri}${globalThis.encodeURIComponent(svgElement.outerHTML)}`;
|
|
81
|
-
}
|
|
68
|
+
};
|
|
82
69
|
|
|
83
70
|
// src/Cytoscape/lib/iconMap.ts
|
|
84
|
-
var generateIconMap =
|
|
71
|
+
var generateIconMap = () => ({
|
|
85
72
|
archivist: "",
|
|
86
73
|
bridge: "",
|
|
87
74
|
diviner: "",
|
|
@@ -89,7 +76,7 @@ var generateIconMap = /* @__PURE__ */ __name(() => ({
|
|
|
89
76
|
node: "",
|
|
90
77
|
sentinel: "",
|
|
91
78
|
witness: ""
|
|
92
|
-
})
|
|
79
|
+
});
|
|
93
80
|
|
|
94
81
|
// src/Cytoscape/lib/layout/ColaLayout.ts
|
|
95
82
|
var ColaLayout = {
|
|
@@ -100,12 +87,12 @@ var ColaLayout = {
|
|
|
100
87
|
|
|
101
88
|
// src/Cytoscape/lib/layout/ConcentricLayout.ts
|
|
102
89
|
var ConcentricLayout = {
|
|
103
|
-
concentric:
|
|
90
|
+
concentric: function(node) {
|
|
104
91
|
return node.degree(false);
|
|
105
|
-
},
|
|
106
|
-
levelWidth:
|
|
92
|
+
},
|
|
93
|
+
levelWidth: function() {
|
|
107
94
|
return 2;
|
|
108
|
-
},
|
|
95
|
+
},
|
|
109
96
|
minNodeSpacing: 75,
|
|
110
97
|
name: "concentric"
|
|
111
98
|
};
|
|
@@ -117,7 +104,7 @@ import { isDivinerInstance as isDivinerInstance2 } from "@xyo-network/diviner-mo
|
|
|
117
104
|
import { isNodeInstance } from "@xyo-network/node-model";
|
|
118
105
|
import { isSentinelInstance } from "@xyo-network/sentinel-model";
|
|
119
106
|
import { isWitnessModule } from "@xyo-network/witness-model";
|
|
120
|
-
var parseModuleType =
|
|
107
|
+
var parseModuleType = (mod) => {
|
|
121
108
|
let type = "module";
|
|
122
109
|
if (mod) {
|
|
123
110
|
if (isArchivistInstance2(mod)) {
|
|
@@ -135,7 +122,7 @@ var parseModuleType = /* @__PURE__ */ __name((mod) => {
|
|
|
135
122
|
}
|
|
136
123
|
}
|
|
137
124
|
return type;
|
|
138
|
-
}
|
|
125
|
+
};
|
|
139
126
|
|
|
140
127
|
// src/Cytoscape/CytoscapeElements.ts
|
|
141
128
|
var CytoscapeElements = {
|
|
@@ -152,23 +139,13 @@ var CytoscapeElements = {
|
|
|
152
139
|
},
|
|
153
140
|
async buildElements(mod) {
|
|
154
141
|
const info = await CytoscapeElements.recurseNodes(mod);
|
|
155
|
-
const newElements = await this.buildElementsFromInfo(info, void 0, [
|
|
156
|
-
"activeNode"
|
|
157
|
-
]);
|
|
142
|
+
const newElements = await this.buildElementsFromInfo(info, void 0, ["activeNode"]);
|
|
158
143
|
return newElements;
|
|
159
144
|
},
|
|
160
145
|
async buildElementsFromInfo(info, root, classes = []) {
|
|
161
|
-
const newNode = CytoscapeElements.buildNode(info.mod, {
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}, classes);
|
|
165
|
-
const newEdge = root ? CytoscapeElements.buildEdge(root, newNode, {
|
|
166
|
-
depth: info.depth,
|
|
167
|
-
siblingCount: info.children.length
|
|
168
|
-
}) : void 0;
|
|
169
|
-
const newElements = [
|
|
170
|
-
newNode
|
|
171
|
-
];
|
|
146
|
+
const newNode = CytoscapeElements.buildNode(info.mod, { childCount: info.children.length, depth: info.depth }, classes);
|
|
147
|
+
const newEdge = root ? CytoscapeElements.buildEdge(root, newNode, { depth: info.depth, siblingCount: info.children.length }) : void 0;
|
|
148
|
+
const newElements = [newNode];
|
|
172
149
|
if (newEdge) {
|
|
173
150
|
newElements.push(newEdge);
|
|
174
151
|
}
|
|
@@ -190,11 +167,9 @@ var CytoscapeElements = {
|
|
|
190
167
|
}
|
|
191
168
|
};
|
|
192
169
|
},
|
|
193
|
-
buildRootNode:
|
|
194
|
-
return CytoscapeElements.buildNode(mod, {}, [
|
|
195
|
-
|
|
196
|
-
]);
|
|
197
|
-
}, "buildRootNode"),
|
|
170
|
+
buildRootNode: (mod) => {
|
|
171
|
+
return CytoscapeElements.buildNode(mod, {}, ["activeNode"]);
|
|
172
|
+
},
|
|
198
173
|
normalizeName(name) {
|
|
199
174
|
if (isFalsy(name)) return;
|
|
200
175
|
if (name.length > this.MaxNameLength) return `${name.slice(0, 20)}...`;
|
|
@@ -207,22 +182,29 @@ var CytoscapeElements = {
|
|
|
207
182
|
mod: root
|
|
208
183
|
};
|
|
209
184
|
if (maxDepth > 0) {
|
|
210
|
-
const children = await root.resolve("*", {
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}))).filter(exists);
|
|
185
|
+
const children = await root.resolve("*", { direction: "down", maxDepth: 1 });
|
|
186
|
+
info.children = (await Promise.all(
|
|
187
|
+
children.map(async (child) => {
|
|
188
|
+
if (child.address !== root.address) {
|
|
189
|
+
return await this.recurseNodes(child, maxDepth - 1, depth + 1);
|
|
190
|
+
}
|
|
191
|
+
})
|
|
192
|
+
)).filter(exists);
|
|
219
193
|
}
|
|
220
194
|
return info;
|
|
221
195
|
}
|
|
222
196
|
};
|
|
223
197
|
|
|
224
198
|
// src/Cytoscape/CytoscapeIcons.tsx
|
|
225
|
-
import {
|
|
199
|
+
import {
|
|
200
|
+
BubbleChartRounded as BubbleChartRoundedIcon,
|
|
201
|
+
Hub as HubIcon,
|
|
202
|
+
InsertLinkRounded as InsertLinkRoundedIcon,
|
|
203
|
+
Inventory2Rounded as Inventory2RoundedIcon,
|
|
204
|
+
QuestionMarkRounded as QuestionMarkRoundedIcon,
|
|
205
|
+
TimerRounded as TimerRoundedIcon,
|
|
206
|
+
VisibilityRounded as VisibilityRoundedIcon
|
|
207
|
+
} from "@mui/icons-material";
|
|
226
208
|
var CyIconSet = {
|
|
227
209
|
archivist: Inventory2RoundedIcon,
|
|
228
210
|
bridge: InsertLinkRoundedIcon,
|
|
@@ -234,7 +216,7 @@ var CyIconSet = {
|
|
|
234
216
|
};
|
|
235
217
|
|
|
236
218
|
// src/Cytoscape/CytoscapeStyles.ts
|
|
237
|
-
var NodeWithName =
|
|
219
|
+
var NodeWithName = (color, outlineColor) => ({
|
|
238
220
|
selector: "node[name]",
|
|
239
221
|
css: {
|
|
240
222
|
color,
|
|
@@ -246,25 +228,23 @@ var NodeWithName = /* @__PURE__ */ __name((color, outlineColor) => ({
|
|
|
246
228
|
"text-outline-width": "1px",
|
|
247
229
|
"text-valign": "top"
|
|
248
230
|
}
|
|
249
|
-
})
|
|
250
|
-
var Node =
|
|
231
|
+
});
|
|
232
|
+
var Node = (icons, bgColor, hideLabels = false) => ({
|
|
251
233
|
selector: "node",
|
|
252
234
|
css: {
|
|
253
235
|
"background-color": bgColor,
|
|
254
236
|
"background-height": "75%",
|
|
255
|
-
"background-image":
|
|
237
|
+
"background-image": (elem) => icons[elem.data("type")],
|
|
256
238
|
"background-width": "24",
|
|
257
239
|
"label": hideLabels ? void 0 : "data(name)",
|
|
258
240
|
"shape": "round-rectangle"
|
|
259
241
|
}
|
|
260
|
-
})
|
|
261
|
-
var NodeAsRoot =
|
|
242
|
+
});
|
|
243
|
+
var NodeAsRoot = (bgColor) => ({
|
|
262
244
|
selector: ".activeNode",
|
|
263
|
-
css: {
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
}), "NodeAsRoot");
|
|
267
|
-
var EdgeStyled = /* @__PURE__ */ __name((lineColor, targetArrowColor) => ({
|
|
245
|
+
css: { "background-color": bgColor }
|
|
246
|
+
});
|
|
247
|
+
var EdgeStyled = (lineColor, targetArrowColor) => ({
|
|
268
248
|
selector: "edge",
|
|
269
249
|
css: {
|
|
270
250
|
"curve-style": "bezier",
|
|
@@ -274,20 +254,21 @@ var EdgeStyled = /* @__PURE__ */ __name((lineColor, targetArrowColor) => ({
|
|
|
274
254
|
"target-arrow-shape": "triangle",
|
|
275
255
|
"width": 3
|
|
276
256
|
}
|
|
277
|
-
})
|
|
257
|
+
});
|
|
278
258
|
|
|
279
259
|
// src/hooks/cytoscape/elements/useCytoscapeElements.ts
|
|
280
|
-
var useCytoscapeElements =
|
|
260
|
+
var useCytoscapeElements = (mod) => {
|
|
281
261
|
const [elements, setElements] = useState2([]);
|
|
282
|
-
useAsyncEffect(
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
262
|
+
useAsyncEffect(
|
|
263
|
+
async () => {
|
|
264
|
+
const moduleInstance = mod?.deref();
|
|
265
|
+
if (moduleInstance) {
|
|
266
|
+
const newElements = await CytoscapeElements.buildElements(moduleInstance) ?? [];
|
|
267
|
+
setElements(newElements);
|
|
268
|
+
}
|
|
269
|
+
},
|
|
270
|
+
[mod]
|
|
271
|
+
);
|
|
291
272
|
useEffect(() => {
|
|
292
273
|
let attachedListener;
|
|
293
274
|
let detachedListener;
|
|
@@ -305,15 +286,17 @@ var useCytoscapeElements = /* @__PURE__ */ __name((mod) => {
|
|
|
305
286
|
attachedListener?.();
|
|
306
287
|
detachedListener?.();
|
|
307
288
|
};
|
|
308
|
-
}, [
|
|
309
|
-
mod
|
|
310
|
-
]);
|
|
289
|
+
}, [mod]);
|
|
311
290
|
return elements;
|
|
312
|
-
}
|
|
291
|
+
};
|
|
313
292
|
|
|
314
293
|
// src/hooks/cytoscape/elements/useHoveredNode.tsx
|
|
315
|
-
import {
|
|
316
|
-
|
|
294
|
+
import {
|
|
295
|
+
useCallback,
|
|
296
|
+
useEffect as useEffect2,
|
|
297
|
+
useState as useState3
|
|
298
|
+
} from "react";
|
|
299
|
+
var useHoveredNode = (renderedElements) => {
|
|
317
300
|
const { cy } = useCytoscapeInstance(true);
|
|
318
301
|
const [hoveredNode, setHoveredNode] = useState3();
|
|
319
302
|
const nodeListener = useCallback((node) => {
|
|
@@ -325,42 +308,31 @@ var useHoveredNode = /* @__PURE__ */ __name((renderedElements) => {
|
|
|
325
308
|
if (renderedElements) {
|
|
326
309
|
renderedElements.nodes().forEach(nodeListener);
|
|
327
310
|
}
|
|
328
|
-
}, [
|
|
329
|
-
nodeListener,
|
|
330
|
-
renderedElements
|
|
331
|
-
]);
|
|
311
|
+
}, [nodeListener, renderedElements]);
|
|
332
312
|
useEffect2(() => {
|
|
333
313
|
cy?.deref()?.ready(() => {
|
|
334
314
|
cy?.deref()?.nodes().forEach(nodeListener);
|
|
335
315
|
});
|
|
336
|
-
}, [
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
]);
|
|
340
|
-
return [
|
|
341
|
-
hoveredNode,
|
|
342
|
-
setHoveredNode
|
|
343
|
-
];
|
|
344
|
-
}, "useHoveredNode");
|
|
316
|
+
}, [cy, nodeListener]);
|
|
317
|
+
return [hoveredNode, setHoveredNode];
|
|
318
|
+
};
|
|
345
319
|
|
|
346
320
|
// src/hooks/cytoscape/elements/useNewElements.tsx
|
|
347
321
|
import { useWeakModuleFromNode } from "@xyo-network/react-node";
|
|
348
322
|
import { useMemo as useMemo2 } from "react";
|
|
349
|
-
var useNewElements =
|
|
323
|
+
var useNewElements = (selectedElement) => {
|
|
350
324
|
const selectedAddress = useMemo2(() => {
|
|
351
325
|
const { address: selectedAddress2 } = selectedElement?.data() ?? {};
|
|
352
326
|
return selectedAddress2;
|
|
353
|
-
}, [
|
|
354
|
-
selectedElement
|
|
355
|
-
]);
|
|
327
|
+
}, [selectedElement]);
|
|
356
328
|
const [mod] = useWeakModuleFromNode(selectedAddress);
|
|
357
329
|
const newElements = useCytoscapeElements(mod);
|
|
358
330
|
return newElements;
|
|
359
|
-
}
|
|
331
|
+
};
|
|
360
332
|
|
|
361
333
|
// src/hooks/cytoscape/elements/useRenderNewElements.tsx
|
|
362
334
|
import { useMemo as useMemo3 } from "react";
|
|
363
|
-
var useRenderNewElements =
|
|
335
|
+
var useRenderNewElements = (newElements = [], _hideLabels) => {
|
|
364
336
|
const { cy } = useCytoscapeInstance(true);
|
|
365
337
|
return useMemo3(() => {
|
|
366
338
|
if (newElements.length > 1) {
|
|
@@ -368,38 +340,31 @@ var useRenderNewElements = /* @__PURE__ */ __name((newElements = [], hideLabels)
|
|
|
368
340
|
cy?.deref()?.layout(ColaLayout).run();
|
|
369
341
|
return renderedElements;
|
|
370
342
|
}
|
|
371
|
-
}, [
|
|
372
|
-
|
|
373
|
-
hideLabels,
|
|
374
|
-
newElements
|
|
375
|
-
]);
|
|
376
|
-
}, "useRenderNewElements");
|
|
343
|
+
}, [cy, newElements]);
|
|
344
|
+
};
|
|
377
345
|
|
|
378
346
|
// src/hooks/cytoscape/elements/useSelectedElement.tsx
|
|
379
347
|
import { useState as useState4 } from "react";
|
|
380
|
-
var useSelectedElement =
|
|
348
|
+
var useSelectedElement = () => {
|
|
381
349
|
const [selectedElement, setSelectedElement] = useState4();
|
|
382
350
|
const { cy } = useCytoscapeInstance(true);
|
|
383
|
-
const updateStyles =
|
|
351
|
+
const updateStyles = (element) => {
|
|
384
352
|
const nodes = cy?.deref()?.nodes();
|
|
385
353
|
nodes?.toggleClass("activeNode", false);
|
|
386
354
|
element.toggleClass("activeNode", true);
|
|
387
|
-
}
|
|
388
|
-
const toggleSelectedElement =
|
|
355
|
+
};
|
|
356
|
+
const toggleSelectedElement = (address) => {
|
|
389
357
|
const selectedNode = cy?.deref()?.nodes(`[id="${address}"]`)?.[0];
|
|
390
358
|
if (selectedNode) {
|
|
391
359
|
setSelectedElement(selectedNode);
|
|
392
360
|
updateStyles(selectedNode);
|
|
393
361
|
}
|
|
394
|
-
}, "toggleSelectedElement");
|
|
395
|
-
return {
|
|
396
|
-
selectedElement,
|
|
397
|
-
toggleSelectedElement
|
|
398
362
|
};
|
|
399
|
-
|
|
363
|
+
return { selectedElement, toggleSelectedElement };
|
|
364
|
+
};
|
|
400
365
|
|
|
401
366
|
// src/hooks/cytoscape/elements/useElements.tsx
|
|
402
|
-
var useElements =
|
|
367
|
+
var useElements = (hideLabels) => {
|
|
403
368
|
const { selectedElement, toggleSelectedElement } = useSelectedElement();
|
|
404
369
|
const newElements = useNewElements(selectedElement);
|
|
405
370
|
const renderedElements = useRenderNewElements(newElements, hideLabels);
|
|
@@ -409,7 +374,7 @@ var useElements = /* @__PURE__ */ __name((hideLabels) => {
|
|
|
409
374
|
setHoveredNode,
|
|
410
375
|
toggleSelectedElement
|
|
411
376
|
};
|
|
412
|
-
}
|
|
377
|
+
};
|
|
413
378
|
|
|
414
379
|
// src/hooks/cytoscape/useCytoscapeOptions.ts
|
|
415
380
|
import { isDefined as isDefined2 } from "@xylabs/sdk-js";
|
|
@@ -422,26 +387,23 @@ import { useMemo as useMemo5 } from "react";
|
|
|
422
387
|
|
|
423
388
|
// src/hooks/cytoscape/useIcons.tsx
|
|
424
389
|
import { useTheme } from "@mui/material";
|
|
425
|
-
import
|
|
426
|
-
|
|
390
|
+
import { useMemo as useMemo4 } from "react";
|
|
391
|
+
import { jsx as jsx3 } from "react/jsx-runtime";
|
|
392
|
+
var useIcons = () => {
|
|
427
393
|
const theme = useTheme();
|
|
428
394
|
const icons = useMemo4(() => {
|
|
429
395
|
const iconMap = generateIconMap();
|
|
430
396
|
return Object.entries(CyIconSet).reduce((acc, [name, IconComponent]) => {
|
|
431
|
-
const icon = /* @__PURE__ */
|
|
432
|
-
fontSize: "small"
|
|
433
|
-
});
|
|
397
|
+
const icon = /* @__PURE__ */ jsx3(IconComponent, { fontSize: "small" });
|
|
434
398
|
acc[name] = encodeSvg(icon, theme.vars.palette.primary.contrastText);
|
|
435
399
|
return acc;
|
|
436
400
|
}, iconMap);
|
|
437
|
-
}, [
|
|
438
|
-
theme.vars.palette.primary.contrastText
|
|
439
|
-
]);
|
|
401
|
+
}, [theme.vars.palette.primary.contrastText]);
|
|
440
402
|
return icons;
|
|
441
|
-
}
|
|
403
|
+
};
|
|
442
404
|
|
|
443
405
|
// src/hooks/cytoscape/useCytoscapeStyle.tsx
|
|
444
|
-
var useCytoscapeStyle =
|
|
406
|
+
var useCytoscapeStyle = (hideLabels = false) => {
|
|
445
407
|
const theme = useTheme2();
|
|
446
408
|
const dark = useIsDark();
|
|
447
409
|
const icons = useIcons();
|
|
@@ -449,21 +411,23 @@ var useCytoscapeStyle = /* @__PURE__ */ __name((hideLabels = false) => {
|
|
|
449
411
|
// eslint-disable-next-line complexity
|
|
450
412
|
() => [
|
|
451
413
|
Node(icons, dark ? theme.colorSchemes.dark?.palette.primary.main : theme.colorSchemes.light?.palette.primary.main, hideLabels),
|
|
452
|
-
NodeWithName(
|
|
414
|
+
NodeWithName(
|
|
415
|
+
dark ? theme.colorSchemes.dark?.palette.primary.contrastText : theme.colorSchemes.light?.palette.primary.contrastText,
|
|
416
|
+
dark ? theme.colorSchemes.dark?.palette.text.primary : theme.colorSchemes.light?.palette.text.primary
|
|
417
|
+
),
|
|
453
418
|
NodeAsRoot(dark ? theme.colorSchemes.dark?.palette.secondary.main : theme.colorSchemes.light?.palette.secondary.main),
|
|
454
|
-
EdgeStyled(
|
|
419
|
+
EdgeStyled(
|
|
420
|
+
dark ? theme.colorSchemes.dark?.palette.divider : theme.colorSchemes.light?.palette.divider,
|
|
421
|
+
dark ? theme.colorSchemes.dark?.palette.divider : theme.colorSchemes.light?.palette.divider
|
|
422
|
+
)
|
|
455
423
|
],
|
|
456
|
-
[
|
|
457
|
-
icons,
|
|
458
|
-
hideLabels,
|
|
459
|
-
theme
|
|
460
|
-
]
|
|
424
|
+
[icons, hideLabels, theme, dark]
|
|
461
425
|
);
|
|
462
426
|
return style;
|
|
463
|
-
}
|
|
427
|
+
};
|
|
464
428
|
|
|
465
429
|
// src/hooks/cytoscape/useCytoscapeOptions.ts
|
|
466
|
-
var useCytoscapeOptions =
|
|
430
|
+
var useCytoscapeOptions = (elements, style, layout) => {
|
|
467
431
|
const defaultStyle = useCytoscapeStyle();
|
|
468
432
|
const resolvedLayout = layout ?? ConcentricLayout;
|
|
469
433
|
const resolvedStyle = style ?? defaultStyle;
|
|
@@ -475,19 +439,23 @@ var useCytoscapeOptions = /* @__PURE__ */ __name((elements, style, layout) => {
|
|
|
475
439
|
style: resolvedStyle
|
|
476
440
|
};
|
|
477
441
|
}
|
|
478
|
-
}, [
|
|
479
|
-
elements,
|
|
480
|
-
resolvedLayout,
|
|
481
|
-
resolvedStyle
|
|
482
|
-
]);
|
|
442
|
+
}, [elements, resolvedLayout, resolvedStyle]);
|
|
483
443
|
return options;
|
|
484
|
-
}
|
|
444
|
+
};
|
|
485
445
|
|
|
486
446
|
// src/hooks/cytoscape/useModuleDetails.tsx
|
|
487
447
|
import { usePromise } from "@xylabs/react-promise";
|
|
488
|
-
import {
|
|
489
|
-
|
|
490
|
-
|
|
448
|
+
import {
|
|
449
|
+
isDefined as isDefined3,
|
|
450
|
+
isDefinedNotNull,
|
|
451
|
+
isTruthy
|
|
452
|
+
} from "@xylabs/sdk-js";
|
|
453
|
+
import {
|
|
454
|
+
useCallback as useCallback2,
|
|
455
|
+
useEffect as useEffect3,
|
|
456
|
+
useState as useState5
|
|
457
|
+
} from "react";
|
|
458
|
+
var useModuleDetails = (rootModule, onFoundModule) => {
|
|
491
459
|
const { cy } = useCytoscapeInstance();
|
|
492
460
|
const [moduleAddress, setModuleAddress] = useState5();
|
|
493
461
|
const [foundModule] = usePromise(async () => {
|
|
@@ -497,10 +465,7 @@ var useModuleDetails = /* @__PURE__ */ __name((rootModule, onFoundModule) => {
|
|
|
497
465
|
const foundModule2 = await rootModuleInstance.resolve(moduleAddress);
|
|
498
466
|
return foundModule2 ?? null;
|
|
499
467
|
}
|
|
500
|
-
}, [
|
|
501
|
-
moduleAddress,
|
|
502
|
-
rootModule
|
|
503
|
-
]);
|
|
468
|
+
}, [moduleAddress, rootModule]);
|
|
504
469
|
const createObserver = useCallback2(() => {
|
|
505
470
|
return new ResizeObserver(() => {
|
|
506
471
|
if (moduleAddress === null) {
|
|
@@ -514,11 +479,7 @@ var useModuleDetails = /* @__PURE__ */ __name((rootModule, onFoundModule) => {
|
|
|
514
479
|
}, 100);
|
|
515
480
|
}
|
|
516
481
|
});
|
|
517
|
-
}, [
|
|
518
|
-
cy,
|
|
519
|
-
moduleAddress,
|
|
520
|
-
foundModule
|
|
521
|
-
]);
|
|
482
|
+
}, [cy, moduleAddress, foundModule]);
|
|
522
483
|
useEffect3(() => {
|
|
523
484
|
const resizeObserver = createObserver();
|
|
524
485
|
const container = cy?.deref()?.container();
|
|
@@ -528,24 +489,13 @@ var useModuleDetails = /* @__PURE__ */ __name((rootModule, onFoundModule) => {
|
|
|
528
489
|
return () => {
|
|
529
490
|
if (container) resizeObserver.unobserve(container);
|
|
530
491
|
};
|
|
531
|
-
}, [
|
|
532
|
-
cy,
|
|
533
|
-
moduleAddress,
|
|
534
|
-
foundModule,
|
|
535
|
-
rootModule
|
|
536
|
-
]);
|
|
492
|
+
}, [cy, moduleAddress, foundModule, rootModule, createObserver]);
|
|
537
493
|
useEffect3(() => {
|
|
538
494
|
if (foundModule) {
|
|
539
495
|
onFoundModule?.();
|
|
540
496
|
}
|
|
541
|
-
}, [
|
|
542
|
-
|
|
543
|
-
moduleAddress,
|
|
544
|
-
foundModule,
|
|
545
|
-
onFoundModule,
|
|
546
|
-
createObserver
|
|
547
|
-
]);
|
|
548
|
-
const onModuleDetails = /* @__PURE__ */ __name((address) => {
|
|
497
|
+
}, [cy, moduleAddress, foundModule, onFoundModule, createObserver]);
|
|
498
|
+
const onModuleDetails = (address) => {
|
|
549
499
|
const moduleNode = cy?.deref()?.nodes(`[id="${address}"]`);
|
|
550
500
|
const rootModuleNode = cy?.deref()?.nodes(`[id="${rootModule?.deref()?.address}"]`);
|
|
551
501
|
const foundModuleNode = cy?.deref()?.nodes(`[id="${foundModule?.address}"]`);
|
|
@@ -559,20 +509,17 @@ var useModuleDetails = /* @__PURE__ */ __name((rootModule, onFoundModule) => {
|
|
|
559
509
|
activeNode?.toggleClass("activeNode", true);
|
|
560
510
|
}
|
|
561
511
|
setModuleAddress(address);
|
|
562
|
-
}, "onModuleDetails");
|
|
563
|
-
return {
|
|
564
|
-
mod: foundModule,
|
|
565
|
-
onModuleDetails
|
|
566
512
|
};
|
|
567
|
-
|
|
513
|
+
return { mod: foundModule, onModuleDetails };
|
|
514
|
+
};
|
|
568
515
|
|
|
569
516
|
// src/hooks/cytoscape/useRelationalGraphOptions.tsx
|
|
570
517
|
import { useState as useState6 } from "react";
|
|
571
|
-
var useRelationalGraphOptions =
|
|
518
|
+
var useRelationalGraphOptions = (mod) => {
|
|
572
519
|
const [hideLabels, setHideLabels] = useState6(true);
|
|
573
|
-
const handleToggleLabels =
|
|
520
|
+
const handleToggleLabels = () => {
|
|
574
521
|
setHideLabels((oldValue) => !oldValue);
|
|
575
|
-
}
|
|
522
|
+
};
|
|
576
523
|
const elements = useCytoscapeElements(mod);
|
|
577
524
|
const style = useCytoscapeStyle(hideLabels);
|
|
578
525
|
const options = useCytoscapeOptions(elements, style, ConcentricLayout);
|
|
@@ -581,25 +528,38 @@ var useRelationalGraphOptions = /* @__PURE__ */ __name((mod) => {
|
|
|
581
528
|
hideLabels,
|
|
582
529
|
options
|
|
583
530
|
};
|
|
584
|
-
}
|
|
531
|
+
};
|
|
585
532
|
|
|
586
533
|
// src/components/cytoscape-extensions/WithExtensions.tsx
|
|
587
534
|
import cytoscape from "cytoscape";
|
|
588
535
|
import cola from "cytoscape-cola";
|
|
589
536
|
import coseBilkent from "cytoscape-cose-bilkent";
|
|
590
|
-
import
|
|
591
|
-
|
|
537
|
+
import { useMemo as useMemo7 } from "react";
|
|
538
|
+
import { Fragment, jsx as jsx4 } from "react/jsx-runtime";
|
|
539
|
+
var WithExtensions = ({ children }) => {
|
|
592
540
|
const initialized = useMemo7(() => {
|
|
593
541
|
cytoscape.use(cola);
|
|
594
542
|
cytoscape.use(coseBilkent);
|
|
595
543
|
return true;
|
|
596
544
|
}, []);
|
|
597
|
-
return /* @__PURE__ */
|
|
598
|
-
}
|
|
545
|
+
return /* @__PURE__ */ jsx4(Fragment, { children: initialized ? children : void 0 });
|
|
546
|
+
};
|
|
599
547
|
|
|
600
548
|
// src/components/relational/graph/Graph.tsx
|
|
601
|
-
import {
|
|
602
|
-
|
|
549
|
+
import {
|
|
550
|
+
Box,
|
|
551
|
+
Button,
|
|
552
|
+
ButtonGroup,
|
|
553
|
+
Card,
|
|
554
|
+
CardHeader,
|
|
555
|
+
Paper,
|
|
556
|
+
useTheme as useTheme3
|
|
557
|
+
} from "@mui/material";
|
|
558
|
+
import {
|
|
559
|
+
FlexCol,
|
|
560
|
+
FlexGrowRow,
|
|
561
|
+
FlexRow
|
|
562
|
+
} from "@xylabs/react-flexbox";
|
|
603
563
|
import { Identicon } from "@xylabs/react-identicon";
|
|
604
564
|
import { asAddress, isDefined as isDefined4 } from "@xylabs/sdk-js";
|
|
605
565
|
import { useWeakModuleFromNode as useWeakModuleFromNode2 } from "@xyo-network/react-node";
|
|
@@ -608,14 +568,17 @@ import cola2 from "cytoscape-cola";
|
|
|
608
568
|
import coseBilkentLayout from "cytoscape-cose-bilkent";
|
|
609
569
|
import dagre from "cytoscape-dagre";
|
|
610
570
|
import euler from "cytoscape-euler";
|
|
611
|
-
import
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
var
|
|
571
|
+
import {
|
|
572
|
+
useEffect as useEffect4,
|
|
573
|
+
useLayoutEffect,
|
|
574
|
+
useRef,
|
|
575
|
+
useState as useState7
|
|
576
|
+
} from "react";
|
|
577
|
+
import { jsx as jsx5, jsxs } from "react/jsx-runtime";
|
|
578
|
+
var applyLayout = (cy, name = "cola", options) => {
|
|
579
|
+
cy?.layout({ name, ...options }).run();
|
|
580
|
+
};
|
|
581
|
+
var loadLayout = (layout = "cola") => {
|
|
619
582
|
switch (layout) {
|
|
620
583
|
case "cose-bilkent": {
|
|
621
584
|
cytoscape2.use(coseBilkentLayout);
|
|
@@ -638,37 +601,48 @@ var loadLayout = /* @__PURE__ */ __name((layout = "cola") => {
|
|
|
638
601
|
break;
|
|
639
602
|
}
|
|
640
603
|
}
|
|
641
|
-
}
|
|
642
|
-
var ModuleHoverDetails =
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
}
|
|
661
|
-
|
|
604
|
+
};
|
|
605
|
+
var ModuleHoverDetails = ({
|
|
606
|
+
name,
|
|
607
|
+
address,
|
|
608
|
+
...props
|
|
609
|
+
}) => {
|
|
610
|
+
return /* @__PURE__ */ jsx5(Card, { elevation: 3, ...props, children: /* @__PURE__ */ jsx5(
|
|
611
|
+
CardHeader,
|
|
612
|
+
{
|
|
613
|
+
avatar: /* @__PURE__ */ jsx5(
|
|
614
|
+
Paper,
|
|
615
|
+
{
|
|
616
|
+
elevation: 6,
|
|
617
|
+
sx: { bgcolor: "#fff", p: 1 },
|
|
618
|
+
children: /* @__PURE__ */ jsx5(Identicon, { value: address, size: 24 })
|
|
619
|
+
}
|
|
620
|
+
),
|
|
621
|
+
title: name,
|
|
622
|
+
subheader: address
|
|
623
|
+
}
|
|
624
|
+
) });
|
|
625
|
+
};
|
|
626
|
+
var NodeRelationalGraphFlexBox = ({
|
|
627
|
+
actions,
|
|
628
|
+
children,
|
|
629
|
+
node,
|
|
630
|
+
layout,
|
|
631
|
+
layoutOptions,
|
|
632
|
+
showDetails,
|
|
633
|
+
detail,
|
|
634
|
+
options,
|
|
635
|
+
onHover,
|
|
636
|
+
...props
|
|
637
|
+
}) => {
|
|
662
638
|
const theme = useTheme3();
|
|
663
639
|
const [cy, setCy] = useState7();
|
|
664
640
|
const cytoscapeRef = useRef(null);
|
|
665
641
|
const [hoverBoundingBox, setHoverBoundingBox] = useState7();
|
|
666
642
|
const [hoverAddress, setHoverAddress] = useState7();
|
|
667
|
-
const [moduleInstance] = useWeakModuleFromNode2(hoverAddress, {
|
|
668
|
-
node
|
|
669
|
-
});
|
|
643
|
+
const [moduleInstance] = useWeakModuleFromNode2(hoverAddress, { node });
|
|
670
644
|
useEffect4(() => {
|
|
671
|
-
const listener =
|
|
645
|
+
const listener = ({ target }) => {
|
|
672
646
|
const cyNode = target;
|
|
673
647
|
const bb = cyNode?.renderedBoundingBox?.();
|
|
674
648
|
setHoverBoundingBox(bb);
|
|
@@ -682,20 +656,17 @@ var NodeRelationalGraphFlexBox = /* @__PURE__ */ __name(({ actions, children, no
|
|
|
682
656
|
onHover?.(asAddress(id));
|
|
683
657
|
}
|
|
684
658
|
}
|
|
685
|
-
}
|
|
659
|
+
};
|
|
686
660
|
cy?.on("mouseover tap", listener);
|
|
687
661
|
return () => {
|
|
688
662
|
cy?.off("mouseover tap", listener);
|
|
689
663
|
};
|
|
690
|
-
}, [
|
|
691
|
-
|
|
692
|
-
cy
|
|
693
|
-
]);
|
|
694
|
-
const handleReset = /* @__PURE__ */ __name(() => {
|
|
664
|
+
}, [onHover, cy]);
|
|
665
|
+
const handleReset = () => {
|
|
695
666
|
cy?.reset();
|
|
696
667
|
applyLayout(cy, layout ?? "euler", layoutOptions);
|
|
697
|
-
}
|
|
698
|
-
|
|
668
|
+
};
|
|
669
|
+
useLayoutEffect(() => {
|
|
699
670
|
let newCy;
|
|
700
671
|
const container = cytoscapeRef.current;
|
|
701
672
|
if (container) {
|
|
@@ -712,161 +683,115 @@ var NodeRelationalGraphFlexBox = /* @__PURE__ */ __name(({ actions, children, no
|
|
|
712
683
|
newCy?.destroy();
|
|
713
684
|
setCy(void 0);
|
|
714
685
|
};
|
|
715
|
-
}, [
|
|
716
|
-
options,
|
|
717
|
-
cytoscapeRef,
|
|
718
|
-
layoutOptions
|
|
719
|
-
]);
|
|
686
|
+
}, [options, cytoscapeRef, layoutOptions]);
|
|
720
687
|
useEffect4(() => {
|
|
721
688
|
if (cy) {
|
|
722
689
|
loadLayout(layout);
|
|
723
690
|
applyLayout(cy, layout ?? "cola", layoutOptions);
|
|
724
691
|
}
|
|
725
|
-
}, [
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
onClick: handleReset
|
|
752
|
-
}, "Reset")), /* @__PURE__ */ React5.createElement(FlexGrowRow, {
|
|
753
|
-
width: "100%",
|
|
754
|
-
alignItems: "start"
|
|
755
|
-
}, showDetails ? /* @__PURE__ */ React5.createElement(FlexCol, {
|
|
756
|
-
height: "100%",
|
|
757
|
-
width: "85%"
|
|
758
|
-
}, detail) : null, /* @__PURE__ */ React5.createElement(FlexCol, {
|
|
759
|
-
justifyContent: "start",
|
|
760
|
-
classes: "cytoscape-wrap",
|
|
761
|
-
width: showDetails ? "15%" : "100%",
|
|
762
|
-
height: showDetails ? "50%" : "100%",
|
|
763
|
-
border: showDetails ? `1px solid ${theme.vars.palette.divider}` : void 0
|
|
764
|
-
}, /* @__PURE__ */ React5.createElement(FlexCol, {
|
|
765
|
-
alignItems: "stretch",
|
|
766
|
-
position: "absolute",
|
|
767
|
-
width: "100%",
|
|
768
|
-
height: "100%",
|
|
769
|
-
ref: cytoscapeRef
|
|
770
|
-
}), children)));
|
|
771
|
-
}, "NodeRelationalGraphFlexBox");
|
|
692
|
+
}, [cy, layoutOptions, layout]);
|
|
693
|
+
return /* @__PURE__ */ jsxs(FlexCol, { id: "relational-graph-wrapper", ...props, children: [
|
|
694
|
+
hoverAddress && hoverBoundingBox ? /* @__PURE__ */ jsx5(Box, { position: "absolute", top: hoverBoundingBox.y1, left: hoverBoundingBox.x1, zIndex: 100, children: /* @__PURE__ */ jsx5(ModuleHoverDetails, { address: hoverAddress, name: moduleInstance?.deref()?.id ?? "Unknown" }) }) : null,
|
|
695
|
+
/* @__PURE__ */ jsx5(FlexRow, { justifyContent: "start", width: "100%", children: actions === null ? null : isDefined4(actions) ? /* @__PURE__ */ jsxs(ButtonGroup, { children: [
|
|
696
|
+
actions,
|
|
697
|
+
/* @__PURE__ */ jsx5(Button, { size: "small", variant: "contained", onClick: handleReset, children: "Reset View" })
|
|
698
|
+
] }) : /* @__PURE__ */ jsx5(Button, { size: "small", variant: "contained", onClick: handleReset, children: "Reset" }) }),
|
|
699
|
+
/* @__PURE__ */ jsxs(FlexGrowRow, { width: "100%", alignItems: "start", children: [
|
|
700
|
+
showDetails ? /* @__PURE__ */ jsx5(FlexCol, { height: "100%", width: "85%", children: detail }) : null,
|
|
701
|
+
/* @__PURE__ */ jsxs(
|
|
702
|
+
FlexCol,
|
|
703
|
+
{
|
|
704
|
+
justifyContent: "start",
|
|
705
|
+
classes: "cytoscape-wrap",
|
|
706
|
+
width: showDetails ? "15%" : "100%",
|
|
707
|
+
height: showDetails ? "50%" : "100%",
|
|
708
|
+
border: showDetails ? `1px solid ${theme.vars.palette.divider}` : void 0,
|
|
709
|
+
children: [
|
|
710
|
+
/* @__PURE__ */ jsx5(FlexCol, { alignItems: "stretch", position: "absolute", width: "100%", height: "100%", ref: cytoscapeRef }),
|
|
711
|
+
children
|
|
712
|
+
]
|
|
713
|
+
}
|
|
714
|
+
)
|
|
715
|
+
] })
|
|
716
|
+
] });
|
|
717
|
+
};
|
|
772
718
|
NodeRelationalGraphFlexBox.displayName = "NodeRelationalGraph";
|
|
773
719
|
var NodeRelationalGraph = NodeRelationalGraphFlexBox;
|
|
774
720
|
|
|
775
721
|
// src/components/relational/graph/ProvidedNodeRenderer.tsx
|
|
776
722
|
import { useWeakProvidedNode } from "@xyo-network/react-node";
|
|
777
|
-
import
|
|
778
|
-
var ProvidedNodeRenderer =
|
|
723
|
+
import { jsx as jsx6 } from "react/jsx-runtime";
|
|
724
|
+
var ProvidedNodeRenderer = ({ node, ...props }) => {
|
|
779
725
|
const [providedNode] = useWeakProvidedNode();
|
|
780
726
|
const elements = useCytoscapeElements(node ?? providedNode);
|
|
781
727
|
const options = useCytoscapeOptions(elements);
|
|
782
|
-
return /* @__PURE__ */
|
|
783
|
-
|
|
784
|
-
flexGrow: 1,
|
|
785
|
-
height: "100%",
|
|
786
|
-
options,
|
|
787
|
-
...props
|
|
788
|
-
});
|
|
789
|
-
}, "ProvidedNodeRenderer");
|
|
728
|
+
return /* @__PURE__ */ jsx6(NodeRelationalGraphFlexBox, { alignItems: "stretch", flexGrow: 1, height: "100%", options, ...props });
|
|
729
|
+
};
|
|
790
730
|
|
|
791
731
|
// src/components/module/graph/DetailsFlexbox.tsx
|
|
792
732
|
import { CancelRounded } from "@mui/icons-material";
|
|
793
733
|
import { IconButton } from "@mui/material";
|
|
794
734
|
import { FlexGrowCol, FlexRow as FlexRow2 } from "@xylabs/react-flexbox";
|
|
795
|
-
import
|
|
796
|
-
var DetailsFlexbox =
|
|
797
|
-
return /* @__PURE__ */
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
p: 2,
|
|
803
|
-
gap: 2
|
|
804
|
-
}, /* @__PURE__ */ React7.createElement(FlexRow2, {
|
|
805
|
-
justifyContent: "end"
|
|
806
|
-
}, /* @__PURE__ */ React7.createElement(IconButton, {
|
|
807
|
-
onClick: onClose,
|
|
808
|
-
size: "small"
|
|
809
|
-
}, /* @__PURE__ */ React7.createElement(CancelRounded, null))), children);
|
|
810
|
-
}, "DetailsFlexbox");
|
|
735
|
+
import { jsx as jsx7, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
736
|
+
var DetailsFlexbox = ({ children, onClose }) => {
|
|
737
|
+
return /* @__PURE__ */ jsxs2(FlexGrowCol, { alignItems: "end", justifyContent: "start", id: "module-detail", width: "100%", p: 2, gap: 2, children: [
|
|
738
|
+
/* @__PURE__ */ jsx7(FlexRow2, { justifyContent: "end", children: /* @__PURE__ */ jsx7(IconButton, { onClick: onClose, size: "small", children: /* @__PURE__ */ jsx7(CancelRounded, {}) }) }),
|
|
739
|
+
children
|
|
740
|
+
] });
|
|
741
|
+
};
|
|
811
742
|
|
|
812
743
|
// src/components/module/graph/node/Hover.tsx
|
|
813
744
|
import { styled } from "@mui/material";
|
|
814
745
|
import { FlexCol as FlexCol2 } from "@xylabs/react-flexbox";
|
|
815
|
-
import React8 from "react";
|
|
816
746
|
|
|
817
747
|
// src/components/module/graph/node/hooks/useNodeElement.tsx
|
|
818
|
-
import {
|
|
819
|
-
|
|
748
|
+
import {
|
|
749
|
+
useEffect as useEffect5,
|
|
750
|
+
useLayoutEffect as useLayoutEffect2,
|
|
751
|
+
useRef as useRef2,
|
|
752
|
+
useState as useState8
|
|
753
|
+
} from "react";
|
|
754
|
+
var useNodeElement = (node) => {
|
|
820
755
|
const ref = useRef2(null);
|
|
821
756
|
const [currentElement, setCurrentElement] = useState8(null);
|
|
822
757
|
const [boundingBox, setBoundingBox] = useState8(node?.renderedBoundingBox());
|
|
823
|
-
|
|
758
|
+
useLayoutEffect2(() => {
|
|
824
759
|
setCurrentElement(null);
|
|
825
|
-
}, [
|
|
826
|
-
node
|
|
827
|
-
]);
|
|
828
|
-
useEffect5(() => {
|
|
829
760
|
setBoundingBox(node?.renderedBoundingBox());
|
|
830
|
-
}, [
|
|
831
|
-
node
|
|
832
|
-
]);
|
|
761
|
+
}, [node]);
|
|
833
762
|
useEffect5(() => {
|
|
834
|
-
const listener =
|
|
763
|
+
const listener = () => {
|
|
835
764
|
setBoundingBox(node?.renderedBoundingBox());
|
|
836
|
-
}
|
|
765
|
+
};
|
|
837
766
|
node?.on("position", listener);
|
|
838
767
|
return () => {
|
|
839
768
|
node?.off("position", void 0, listener);
|
|
840
769
|
};
|
|
841
|
-
}, [
|
|
842
|
-
|
|
843
|
-
]);
|
|
844
|
-
useEffect5(() => {
|
|
770
|
+
}, [node]);
|
|
771
|
+
useLayoutEffect2(() => {
|
|
845
772
|
setCurrentElement(ref.current);
|
|
846
|
-
}, [
|
|
847
|
-
boundingBox
|
|
848
|
-
]);
|
|
773
|
+
}, [boundingBox]);
|
|
849
774
|
return {
|
|
850
775
|
boundingBox,
|
|
851
776
|
currentElement,
|
|
852
777
|
ref
|
|
853
778
|
};
|
|
854
|
-
}
|
|
779
|
+
};
|
|
855
780
|
|
|
856
781
|
// src/components/module/graph/node/Hover.tsx
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
782
|
+
import { Fragment as Fragment2, jsx as jsx8, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
783
|
+
var ModuleGraphNodeHover = ({ children, node }) => {
|
|
784
|
+
const {
|
|
785
|
+
boundingBox,
|
|
860
786
|
ref,
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
width: boundingBox?.w
|
|
865
|
-
|
|
866
|
-
}
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
})(() => ({
|
|
787
|
+
currentElement
|
|
788
|
+
} = useNodeElement(node);
|
|
789
|
+
return /* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
790
|
+
/* @__PURE__ */ jsx8(StyledNodeGhostElementFlexCol, { ref, left: boundingBox?.x1, height: boundingBox?.h, top: boundingBox?.y1, width: boundingBox?.w }),
|
|
791
|
+
node ? /* @__PURE__ */ jsx8(Fragment2, { children: children?.(currentElement) }) : null
|
|
792
|
+
] });
|
|
793
|
+
};
|
|
794
|
+
var StyledNodeGhostElementFlexCol = styled(FlexCol2, { name: "StyledNodeGhostElementFlexCol" })(() => ({
|
|
870
795
|
// For easier debugging of the 'ghost' element that matches the hovered cytoscape node
|
|
871
796
|
// backgroundColor: '#fff',
|
|
872
797
|
// opacity: 0.25,
|
|
@@ -877,91 +802,105 @@ var StyledNodeGhostElementFlexCol = styled(FlexCol2, {
|
|
|
877
802
|
|
|
878
803
|
// src/components/module/graph/Popper.tsx
|
|
879
804
|
import { CancelRounded as CancelRounded2 } from "@mui/icons-material";
|
|
880
|
-
import {
|
|
805
|
+
import {
|
|
806
|
+
Button as Button2,
|
|
807
|
+
Card as Card2,
|
|
808
|
+
CardActions,
|
|
809
|
+
CardHeader as CardHeader2,
|
|
810
|
+
IconButton as IconButton2,
|
|
811
|
+
Paper as Paper2,
|
|
812
|
+
Popper,
|
|
813
|
+
styled as styled2
|
|
814
|
+
} from "@mui/material";
|
|
881
815
|
import { Identicon as Identicon2 } from "@xylabs/react-identicon";
|
|
882
|
-
import
|
|
883
|
-
var ModuleHoverPopper =
|
|
816
|
+
import { Fragment as Fragment3, jsx as jsx9, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
817
|
+
var ModuleHoverPopper = ({
|
|
818
|
+
anchorEl,
|
|
819
|
+
onClose,
|
|
820
|
+
onModuleDetails,
|
|
821
|
+
onModuleExplore,
|
|
822
|
+
node,
|
|
823
|
+
...props
|
|
824
|
+
}) => {
|
|
884
825
|
const { address, name } = node?.data() ?? {};
|
|
885
|
-
return /* @__PURE__ */
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
826
|
+
return /* @__PURE__ */ jsx9(Fragment3, { children: anchorEl ? /* @__PURE__ */ jsx9(Popper, { anchorEl, ...props, children: /* @__PURE__ */ jsxs4(Card2, { elevation: 3, children: [
|
|
827
|
+
/* @__PURE__ */ jsx9(
|
|
828
|
+
CardHeader2,
|
|
829
|
+
{
|
|
830
|
+
action: onClose ? /* @__PURE__ */ jsx9(IconButton2, { size: "small", onClick: onClose, children: /* @__PURE__ */ jsx9(CancelRounded2, {}) }) : null,
|
|
831
|
+
avatar: /* @__PURE__ */ jsx9(
|
|
832
|
+
Paper2,
|
|
833
|
+
{
|
|
834
|
+
elevation: 6,
|
|
835
|
+
sx: { bgcolor: "#fff", p: 1 },
|
|
836
|
+
children: /* @__PURE__ */ jsx9(Identicon2, { value: address, size: 24 })
|
|
837
|
+
}
|
|
838
|
+
),
|
|
839
|
+
title: name,
|
|
840
|
+
subheader: address
|
|
900
841
|
}
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
size:
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
variant: "contained"
|
|
911
|
-
}, "Details") : null, onModuleExplore ? /* @__PURE__ */ React9.createElement(Button2, {
|
|
912
|
-
onClick: /* @__PURE__ */ __name(() => onModuleExplore?.(address), "onClick"),
|
|
913
|
-
size: "small",
|
|
914
|
-
variant: "contained"
|
|
915
|
-
}, "Explore") : null))) : null);
|
|
916
|
-
}, "ModuleHoverPopper");
|
|
917
|
-
var StyledModuleHoverPopper = styled2(ModuleHoverPopper, {
|
|
918
|
-
name: "StyledComponents"
|
|
919
|
-
})(() => ({
|
|
920
|
-
zIndex: 2
|
|
921
|
-
}));
|
|
922
|
-
var StyledCardActions = styled2(CardActions, {
|
|
923
|
-
name: "StyledCardActions"
|
|
924
|
-
})(() => ({
|
|
842
|
+
),
|
|
843
|
+
/* @__PURE__ */ jsxs4(StyledCardActions, { children: [
|
|
844
|
+
onModuleDetails ? /* @__PURE__ */ jsx9(Button2, { onClick: () => onModuleDetails?.(address), size: "small", variant: "contained", children: "Details" }) : null,
|
|
845
|
+
onModuleExplore ? /* @__PURE__ */ jsx9(Button2, { onClick: () => onModuleExplore?.(address), size: "small", variant: "contained", children: "Explore" }) : null
|
|
846
|
+
] })
|
|
847
|
+
] }) }) : null });
|
|
848
|
+
};
|
|
849
|
+
var StyledModuleHoverPopper = styled2(ModuleHoverPopper, { name: "StyledComponents" })(() => ({ zIndex: 2 }));
|
|
850
|
+
var StyledCardActions = styled2(CardActions, { name: "StyledCardActions" })(() => ({
|
|
925
851
|
display: "flex",
|
|
926
852
|
justifyContent: "center"
|
|
927
853
|
}));
|
|
928
854
|
|
|
929
855
|
// src/components/module/graph/GraphFlexBox.tsx
|
|
930
|
-
|
|
856
|
+
import { jsx as jsx10 } from "react/jsx-runtime";
|
|
857
|
+
var ModuleGraphFlexBox = ({
|
|
858
|
+
hideActions,
|
|
859
|
+
rootModule,
|
|
860
|
+
disableModuleDetails,
|
|
861
|
+
...props
|
|
862
|
+
}) => {
|
|
931
863
|
const cytoscapeRef = useRef3(null);
|
|
932
|
-
const {
|
|
933
|
-
|
|
864
|
+
const {
|
|
865
|
+
handleToggleLabels,
|
|
866
|
+
hideLabels,
|
|
867
|
+
options
|
|
868
|
+
} = useRelationalGraphOptions(rootModule ?? void 0);
|
|
869
|
+
const {
|
|
870
|
+
hoveredNode,
|
|
871
|
+
setHoveredNode,
|
|
872
|
+
toggleSelectedElement
|
|
873
|
+
} = useElements(hideLabels);
|
|
934
874
|
const { mod, onModuleDetails } = useModuleDetails(rootModule, () => setHoveredNode(void 0));
|
|
935
|
-
return /* @__PURE__ */
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
onClick: handleToggleLabels,
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
}, "ModuleGraphFlexBoxWithProvider");
|
|
875
|
+
return /* @__PURE__ */ jsx10(WithExtensions, { children: /* @__PURE__ */ jsx10(
|
|
876
|
+
NodeRelationalGraphFlexBox,
|
|
877
|
+
{
|
|
878
|
+
actions: mod ? null : hideActions ? null : /* @__PURE__ */ jsx10(Button3, { size: "small", onClick: handleToggleLabels, variant: "contained", children: "Toggle Labels" }),
|
|
879
|
+
showDetails: !!mod,
|
|
880
|
+
detail: /* @__PURE__ */ jsx10(DetailsFlexbox, { onClose: () => onModuleDetails(null) }),
|
|
881
|
+
options,
|
|
882
|
+
ref: cytoscapeRef,
|
|
883
|
+
width: "100%",
|
|
884
|
+
...props,
|
|
885
|
+
children: /* @__PURE__ */ jsx10(ModuleGraphNodeHover, { node: hoveredNode, children: (element) => /* @__PURE__ */ jsx10(
|
|
886
|
+
StyledModuleHoverPopper,
|
|
887
|
+
{
|
|
888
|
+
anchorEl: element,
|
|
889
|
+
container: cytoscapeRef.current,
|
|
890
|
+
node: hoveredNode,
|
|
891
|
+
onClose: () => setHoveredNode(void 0),
|
|
892
|
+
onModuleExplore: toggleSelectedElement,
|
|
893
|
+
onModuleDetails: disableModuleDetails ? void 0 : onModuleDetails,
|
|
894
|
+
placement: "top",
|
|
895
|
+
open: true
|
|
896
|
+
}
|
|
897
|
+
) })
|
|
898
|
+
}
|
|
899
|
+
) });
|
|
900
|
+
};
|
|
901
|
+
var ModuleGraphFlexBoxWithProvider = (props) => {
|
|
902
|
+
return /* @__PURE__ */ jsx10(CytoscapeInstanceProvider, { children: /* @__PURE__ */ jsx10(ModuleGraphFlexBox, { ...props }) });
|
|
903
|
+
};
|
|
965
904
|
export {
|
|
966
905
|
ColaLayout,
|
|
967
906
|
ConcentricLayout,
|