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