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