@cccsaurora/clue-ui 0.15.0-dev.27 → 0.15.0-dev.29

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.
Files changed (257) hide show
  1. package/ActionForm-DgfJwTzt.js +436 -0
  2. package/AnnotationPreview-BvNpZOP0.js +188 -0
  3. package/ClueEnrichContext-DXwLVp0M.js +518 -0
  4. package/FlexOne-BSYAhhtG.js +9 -0
  5. package/_Map-kgDsDYxq.js +64 -0
  6. package/_MapCache-DabaaWfq.js +161 -0
  7. package/_Uint8Array-BlVVH1tp.js +129 -0
  8. package/_baseAssignValue-CNbcU6Nb.js +25 -0
  9. package/_baseClone-D3a8Pa4T.js +284 -0
  10. package/_baseExtremum-B1o1zHjR.js +33 -0
  11. package/_baseFlatten-D4huXoEI.js +92 -0
  12. package/_baseGet-BSK_nnoz.js +109 -0
  13. package/_baseIsEqual-B5xLoweL.js +238 -0
  14. package/_baseIteratee-p6Nj07-n.js +126 -0
  15. package/_baseSlice-GAv_YFTT.js +20 -0
  16. package/_baseSum-D0WC1dN0.js +13 -0
  17. package/_baseUniq-CpupKWcL.js +89 -0
  18. package/_commonjsHelpers-CUmg6egw.js +6 -0
  19. package/_createAggregator-BpVy5xMi.js +63 -0
  20. package/_getPrototype-D1LAdQKO.js +5 -0
  21. package/_getTag-D3ToyefI.js +126 -0
  22. package/api/lookup/enrich.d.ts +10 -0
  23. package/api/lookup/index.d.ts +5 -0
  24. package/api/lookup/types.d.ts +5 -0
  25. package/api/lookup/types_detection.d.ts +5 -0
  26. package/cloneDeep-CjP5k9zW.js +8 -0
  27. package/components/AnnotationBody.d.ts +6 -0
  28. package/components/AnnotationBody.js +56 -0
  29. package/components/AnnotationDetailPopover.d.ts +14 -0
  30. package/components/AnnotationDetailPopover.js +61 -0
  31. package/components/AnnotationDetails.d.ts +8 -0
  32. package/components/AnnotationDetails.js +172 -0
  33. package/components/AnnotationEntry.d.ts +6 -0
  34. package/components/AnnotationEntry.js +59 -0
  35. package/components/AnnotationPreview.d.ts +14 -0
  36. package/components/AnnotationPreview.js +11 -0
  37. package/components/ClassificationChip.d.ts +11 -0
  38. package/components/ClassificationChip.js +52 -0
  39. package/components/CountBadge.d.ts +8 -0
  40. package/components/CountBadge.js +34 -0
  41. package/components/EnrichedCard.d.ts +14 -0
  42. package/components/EnrichedCard.js +162 -0
  43. package/components/EnrichedChip.d.ts +9 -0
  44. package/components/EnrichedChip.js +176 -0
  45. package/components/EnrichedTypography.d.ts +16 -0
  46. package/components/EnrichedTypography.js +178 -0
  47. package/components/ErrorBoundary.d.ts +15 -0
  48. package/components/ErrorBoundary.js +36 -0
  49. package/components/RetryFailedEnrichments.d.ts +2 -0
  50. package/components/RetryFailedEnrichments.js +13 -0
  51. package/components/SourcePicker.d.ts +2 -0
  52. package/components/SourcePicker.js +98 -0
  53. package/components/actions/ActionForm.d.ts +6 -0
  54. package/components/actions/ActionForm.js +16 -0
  55. package/components/actions/ExecutePopover.d.ts +10 -0
  56. package/components/actions/ExecutePopover.js +93 -0
  57. package/components/actions/ResultModal.d.ts +9 -0
  58. package/components/actions/ResultModal.js +46 -0
  59. package/components/actions/form/schemaAdapter.d.ts +3 -0
  60. package/components/actions/form/schemaAdapter.js +47 -0
  61. package/components/display/graph/ExpandMoreButton.d.ts +7 -0
  62. package/components/display/graph/ExpandMoreButton.js +18 -0
  63. package/components/display/graph/elements/NodeCard.d.ts +10 -0
  64. package/components/display/graph/elements/NodeCard.js +146 -0
  65. package/components/display/graph/elements/NodeTag.d.ts +9 -0
  66. package/components/display/graph/elements/NodeTag.js +17 -0
  67. package/components/display/graph/index.d.ts +9 -0
  68. package/components/display/graph/index.js +438 -0
  69. package/components/display/graph/visualizations/Leaf.d.ts +25 -0
  70. package/components/display/graph/visualizations/Leaf.js +125 -0
  71. package/components/display/graph/visualizations/cloud/index.d.ts +24 -0
  72. package/components/display/graph/visualizations/cloud/index.js +141 -0
  73. package/components/display/graph/visualizations/icons/BaseIcon.d.ts +12 -0
  74. package/components/display/graph/visualizations/icons/BaseIcon.js +37 -0
  75. package/components/display/graph/visualizations/icons/BugIcon.d.ts +5 -0
  76. package/components/display/graph/visualizations/icons/BugIcon.js +18 -0
  77. package/components/display/graph/visualizations/icons/HostIcon.d.ts +5 -0
  78. package/components/display/graph/visualizations/icons/HostIcon.js +24 -0
  79. package/components/display/graph/visualizations/icons/NetworkIcon.d.ts +5 -0
  80. package/components/display/graph/visualizations/icons/NetworkIcon.js +24 -0
  81. package/components/display/graph/visualizations/icons/ProcessIcon.d.ts +5 -0
  82. package/components/display/graph/visualizations/icons/ProcessIcon.js +18 -0
  83. package/components/display/graph/visualizations/icons/TargetIcon.d.ts +5 -0
  84. package/components/display/graph/visualizations/icons/TargetIcon.js +19 -0
  85. package/components/display/graph/visualizations/icons/index.d.ts +2 -0
  86. package/components/display/graph/visualizations/icons/index.js +16 -0
  87. package/components/display/graph/visualizations/panels/NodePanel.d.ts +8 -0
  88. package/components/display/graph/visualizations/panels/NodePanel.js +12 -0
  89. package/components/display/graph/visualizations/tree/BundleLine.d.ts +29 -0
  90. package/components/display/graph/visualizations/tree/BundleLine.js +121 -0
  91. package/components/display/graph/visualizations/tree/Triangle.d.ts +9 -0
  92. package/components/display/graph/visualizations/tree/Triangle.js +26 -0
  93. package/components/display/graph/visualizations/tree/index.d.ts +36 -0
  94. package/components/display/graph/visualizations/tree/index.js +485 -0
  95. package/components/display/graph/visualizations/tree/types.d.ts +11 -0
  96. package/components/display/graph/visualizations/tree/types.js +1 -0
  97. package/components/display/icons/Iconified.d.ts +9 -0
  98. package/components/display/icons/Iconified.js +29 -0
  99. package/components/display/json/index.d.ts +14 -0
  100. package/components/display/json/index.js +12 -0
  101. package/components/display/markdown/DynamicTabs.d.ts +8 -0
  102. package/components/display/markdown/DynamicTabs.js +26 -0
  103. package/components/display/markdown/index.d.ts +9 -0
  104. package/components/display/markdown/index.js +13389 -0
  105. package/components/display/markdown/markdownPlugins/tabs.d.ts +3 -0
  106. package/components/display/markdown/markdownPlugins/tabs.js +4 -0
  107. package/components/enrichment/EnrichPopover.d.ts +10 -0
  108. package/components/enrichment/EnrichPopover.js +88 -0
  109. package/components/fetchers/Fetcher.d.ts +17 -0
  110. package/components/fetchers/Fetcher.js +188 -0
  111. package/components/fetchers/PreviewModal.d.ts +8 -0
  112. package/components/fetchers/PreviewModal.js +22 -0
  113. package/components/fetchers/StatusChip.d.ts +8 -0
  114. package/components/fetchers/StatusChip.js +30 -0
  115. package/components/group/Entry.d.ts +8 -0
  116. package/components/group/Entry.js +15 -0
  117. package/components/group/Group.d.ts +12 -0
  118. package/components/group/Group.js +15 -0
  119. package/components/group/GroupControl.d.ts +4 -0
  120. package/components/group/GroupControl.js +103 -0
  121. package/components/stats/QueryStatus.d.ts +4 -0
  122. package/components/stats/QueryStatus.js +61 -0
  123. package/countBy-C69WslUA.js +14 -0
  124. package/data/event.d.ts +12 -0
  125. package/data/event.js +8 -0
  126. package/database/index.d.ts +4 -0
  127. package/database/index.js +4 -0
  128. package/database/selector.schema.json.d.ts +119 -0
  129. package/database/status.schema.json.d.ts +38 -0
  130. package/database/types.d.ts +64 -0
  131. package/debounce-bV0h5FC5.js +92 -0
  132. package/en/translation.json +135 -0
  133. package/fr/translation.json +135 -0
  134. package/get-D3C3lEU3.js +8 -0
  135. package/groupBy-DC2oOuBN.js +14 -0
  136. package/hooks/ClueActionContext.d.ts +86 -0
  137. package/hooks/ClueActionContext.js +18 -0
  138. package/hooks/ClueComponentContext.d.ts +10 -0
  139. package/hooks/ClueComponentContext.js +40 -0
  140. package/hooks/ClueConfigProvider.d.ts +12 -0
  141. package/hooks/ClueConfigProvider.js +23 -0
  142. package/hooks/ClueDatabaseContext.d.ts +10 -0
  143. package/hooks/ClueDatabaseContext.js +23 -0
  144. package/hooks/ClueEnrichContext.d.ts +6 -0
  145. package/hooks/ClueEnrichContext.js +15 -0
  146. package/hooks/ClueEnrichContextType.d.ts +113 -0
  147. package/hooks/ClueEnrichProps.d.ts +81 -0
  148. package/hooks/ClueFetcherContext.d.ts +35 -0
  149. package/hooks/ClueFetcherContext.js +88 -0
  150. package/hooks/ClueGroupContext.d.ts +14 -0
  151. package/hooks/ClueGroupContext.js +23 -0
  152. package/hooks/CluePopupContext.d.ts +24 -0
  153. package/hooks/CluePopupContext.js +12 -0
  154. package/hooks/ClueProvider.d.ts +9 -0
  155. package/hooks/ClueProvider.js +14 -0
  156. package/hooks/selectors.d.ts +10 -0
  157. package/hooks/selectors.js +24 -0
  158. package/hooks/useAnnotations.d.ts +24 -0
  159. package/hooks/useAnnotations.js +69 -0
  160. package/hooks/useClue.d.ts +4 -0
  161. package/hooks/useClue.js +8 -0
  162. package/hooks/useClueActions.d.ts +4 -0
  163. package/hooks/useClueActions.js +5 -0
  164. package/hooks/useClueConfig.d.ts +1 -0
  165. package/hooks/useClueConfig.js +8 -0
  166. package/hooks/useClueTypeConfig.d.ts +17 -0
  167. package/hooks/useClueTypeConfig.js +7 -0
  168. package/hooks/useComparator.d.ts +16 -0
  169. package/hooks/useComparator.js +1060 -0
  170. package/hooks/useErrors.d.ts +17 -0
  171. package/hooks/useErrors.js +35 -0
  172. package/hooks/useMyHighlights.d.ts +11 -0
  173. package/hooks/useMyHighlights.js +74 -0
  174. package/hooks/useMyLocalStorage.d.ts +16 -0
  175. package/hooks/useMyLocalStorage.js +80 -0
  176. package/iconify-CXMreGTg.js +1782 -0
  177. package/icons/Action.d.ts +9 -0
  178. package/icons/Action.js +90 -0
  179. package/icons/Assessment.d.ts +11 -0
  180. package/icons/Assessment.js +123 -0
  181. package/icons/Context.d.ts +12 -0
  182. package/icons/Context.js +83 -0
  183. package/icons/Opinion.d.ts +11 -0
  184. package/icons/Opinion.js +125 -0
  185. package/icons/iconMap.d.ts +7 -0
  186. package/icons/iconMap.js +10 -0
  187. package/identity-CPGTqrE4.js +6 -0
  188. package/index-BDVjGvMI.js +696 -0
  189. package/index-BDrtH5ec.js +465 -0
  190. package/index-C9lySIVX.js +1172 -0
  191. package/index-DJYqRcxJ.js +15750 -0
  192. package/index-Dn2NHyXg.js +17654 -0
  193. package/index.css +21 -0
  194. package/isEmpty-BQkZubqU.js +29 -0
  195. package/isNil-CIubwp4T.js +6 -0
  196. package/isObject-FTY-5JQX.js +7 -0
  197. package/isObjectLike-OAgjjZye.js +48 -0
  198. package/isSymbol-Xd2FsJyp.js +8 -0
  199. package/isUndefined-CE8h73dH.js +10 -0
  200. package/last-CUCl67Im.js +7 -0
  201. package/main.d.ts +42 -0
  202. package/main.js +70 -0
  203. package/package.json +28 -134
  204. package/public/manifest.json +16 -0
  205. package/public/robots.txt +3 -0
  206. package/public/svg/dark/clue-h.svg +52 -0
  207. package/public/svg/dark/clue-icon1-simple.svg +33 -0
  208. package/public/svg/dark/clue-icon1.svg +44 -0
  209. package/public/svg/dark/clue-icon2-simple.svg +26 -0
  210. package/public/svg/dark/clue-icon2.svg +37 -0
  211. package/public/svg/dark/clue-name.svg +14 -0
  212. package/public/svg/dark/clue-v.svg +52 -0
  213. package/public/svg/light/clue-h.svg +60 -0
  214. package/public/svg/light/clue-icon1-simple.svg +37 -0
  215. package/public/svg/light/clue-icon1.svg +48 -0
  216. package/public/svg/light/clue-icon2-simple.svg +30 -0
  217. package/public/svg/light/clue-icon2.svg +41 -0
  218. package/public/svg/light/clue-name.svg +14 -0
  219. package/public/svg/light/clue-v.svg +60 -0
  220. package/sortBy-B-UKp4GT.js +100 -0
  221. package/sumBy-MYkDPHZL.js +8 -0
  222. package/tabs-xGuUGsJd.js +254 -0
  223. package/text/Frequency.d.ts +9 -0
  224. package/text/Frequency.js +49 -0
  225. package/toFinite-CArjry_l.js +16 -0
  226. package/toNumber-DPxy1FBy.js +39 -0
  227. package/types/EnrichmentProps.d.ts +73 -0
  228. package/types/RunningActionData.d.ts +15 -0
  229. package/types/WithActionData.d.ts +9 -0
  230. package/types/action.d.ts +25 -0
  231. package/types/config.d.ts +16 -0
  232. package/types/fetcher.d.ts +60 -0
  233. package/types/graph.d.ts +101 -0
  234. package/types/lookup.d.ts +62 -0
  235. package/types/network.d.ts +9 -0
  236. package/useClueTypeConfig-D9ZSxa4F.js +3096 -0
  237. package/utils/chain.d.ts +14 -0
  238. package/utils/chain.js +106 -0
  239. package/utils/classificationParser.d.ts +195 -0
  240. package/utils/classificationParser.js +553 -0
  241. package/utils/constants.d.ts +26 -0
  242. package/utils/constants.js +36 -0
  243. package/utils/graph.d.ts +13 -0
  244. package/utils/graph.js +79 -0
  245. package/utils/hashUtil.d.ts +6 -0
  246. package/utils/hashUtil.js +11 -0
  247. package/utils/line.d.ts +28 -0
  248. package/utils/line.js +136 -0
  249. package/utils/loggerUtil.d.ts +6 -0
  250. package/utils/loggerUtil.js +8 -0
  251. package/utils/sessionStorage.d.ts +9 -0
  252. package/utils/sessionStorage.js +51 -0
  253. package/utils/utils.d.ts +13 -0
  254. package/utils/utils.js +11 -0
  255. package/utils/window.d.ts +3 -0
  256. package/utils/window.js +24 -0
  257. package/utils-CxIhC2xH.js +4182 -0
@@ -0,0 +1,438 @@
1
+ import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
+ import { useMemo, useRef, useState, useEffect, useCallback, createElement } from "react";
3
+ import { useTheme, lighten, darken, Stack, Card, Typography, alpha, Autocomplete, TextField, FormControl, InputLabel, Select, MenuItem, IconButton, Collapse } from "@mui/material";
4
+ import { p as parseEvent } from "../../../index-BDrtH5ec.js";
5
+ import { z as zoom, i as identity, s as select, t as transform, p as pointer } from "../../../index-DJYqRcxJ.js";
6
+ import useComparator from "../../../hooks/useComparator.js";
7
+ import { useMyLocalStorageItem } from "../../../hooks/useMyLocalStorage.js";
8
+ import { StorageKey } from "../../../utils/constants.js";
9
+ import { g as get } from "../../../get-D3C3lEU3.js";
10
+ import { cssImportant } from "../../../utils/graph.js";
11
+ import Iconified from "../icons/Iconified.js";
12
+ import ExpandMoreButton from "./ExpandMoreButton.js";
13
+ import Cloud from "./visualizations/cloud/index.js";
14
+ import NodePanel from "./visualizations/panels/NodePanel.js";
15
+ import Tree from "./visualizations/tree/index.js";
16
+ const Graph = ({ graph, sx = {} }) => {
17
+ var _a, _b, _c, _d, _e;
18
+ const theme = useTheme();
19
+ const isDark = useMemo(() => theme.palette.mode === "dark", [theme]);
20
+ const { runComparator } = useComparator();
21
+ const svgRef = useRef();
22
+ const pointRef = useRef();
23
+ const [showMousePos] = useMyLocalStorageItem(StorageKey.SHOW_MOUSE_POS, false);
24
+ const [showCoordinates] = useMyLocalStorageItem(StorageKey.SHOW_COORDINATES, false);
25
+ const [panelLocation] = useMyLocalStorageItem(StorageKey.PANEL_LOCATION, "vertical");
26
+ const [relativeMousePos, setRelativeMousePos] = useState(["0", "0"]);
27
+ const [absoluteMousePos, setAbsoluteMousePos] = useState(["0", "0"]);
28
+ const [showPanel, setShowPanel] = useState(false);
29
+ const nodeIds = useMemo(() => ((graph == null ? void 0 : graph.data) ?? []).flat(2).map((node) => node.id), [graph == null ? void 0 : graph.data]);
30
+ const zoom$1 = useMemo(() => zoom().scaleExtent([0.1, 6]), []);
31
+ const [currentZoom, setCurrentZoom] = useState(identity);
32
+ const [nodeId, setNodeId] = useState("");
33
+ const [selectedNodeIds, setSelectedNodeIds] = useState([]);
34
+ const [viz, setViz] = useState(
35
+ ((_b = (_a = graph == null ? void 0 : graph.metadata.display) == null ? void 0 : _a.visualization) == null ? void 0 : _b.type) ?? "tree"
36
+ );
37
+ const [hasError, setHasError] = useState(false);
38
+ useEffect(() => {
39
+ setShowPanel(selectedNodeIds.length > 0);
40
+ }, [selectedNodeIds]);
41
+ const labelKeys = useMemo(
42
+ () => {
43
+ var _a2, _b2;
44
+ return (_b2 = (_a2 = graph == null ? void 0 : graph.metadata.display) == null ? void 0 : _a2.displayField) == null ? void 0 : _b2.filter((entry) => (entry.zoom ?? Number.MAX_SAFE_INTEGER) > currentZoom.k);
45
+ },
46
+ [(_c = graph == null ? void 0 : graph.metadata.display) == null ? void 0 : _c.displayField, currentZoom.k]
47
+ );
48
+ const onNodeChange = useCallback((node) => {
49
+ setNodeId(node);
50
+ }, []);
51
+ const checkForNode = useCallback((_nodeId) => {
52
+ const selector = _nodeId === "view" ? _nodeId : `node-${_nodeId ?? "will\\%never\\$ever\\*exist"}`;
53
+ return select(`#${selector}`);
54
+ }, []);
55
+ const selectNode = useCallback(() => {
56
+ if (!nodeId) {
57
+ setHasError(true);
58
+ return;
59
+ }
60
+ const nodeToGet = checkForNode(nodeId.replace(/[^A-Za-z0-9]*/g, ""));
61
+ if (nodeToGet.empty()) {
62
+ setHasError(true);
63
+ return;
64
+ }
65
+ setHasError(false);
66
+ setSelectedNodeIds([nodeId]);
67
+ const clientRect = svgRef.current.getBoundingClientRect();
68
+ const svg = select(svgRef.current);
69
+ const box = nodeToGet.node().getBBox();
70
+ svg.transition().duration(500).call(
71
+ zoom$1.transform,
72
+ identity.translate(clientRect.width / 2, clientRect.height / 2).scale(4).translate(-box.x, -box.y)
73
+ );
74
+ }, [checkForNode, nodeId, zoom$1.transform]);
75
+ const onKeyPress = useCallback(
76
+ (event) => {
77
+ const parsedEvent = parseEvent(event);
78
+ if (parsedEvent.isCtrl && parsedEvent.isEnter) {
79
+ selectNode();
80
+ }
81
+ },
82
+ [selectNode]
83
+ );
84
+ const findNode = useCallback((id) => ((graph == null ? void 0 : graph.data) ?? []).flat().find((n) => n.id === id), [graph == null ? void 0 : graph.data]);
85
+ const resetZoom = useCallback(
86
+ (instant = false) => {
87
+ if (!graph) {
88
+ return;
89
+ }
90
+ const box = select(svgRef.current).select("#view").node().getBBox();
91
+ const clientRect = svgRef.current.getBoundingClientRect();
92
+ const zoomLevel = Math.min(clientRect.width / (box.width + 25), (clientRect.height - 96) / box.height);
93
+ let selection = select(svgRef.current);
94
+ if (!instant) {
95
+ selection = selection.transition().duration(500);
96
+ }
97
+ selection.call(
98
+ zoom$1.transform,
99
+ identity.translate(clientRect.width / 2, (clientRect.height + 96) / 2).scale(zoomLevel).translate(-box.width / 2, -box.height / 2 - 10)
100
+ );
101
+ },
102
+ [zoom$1.transform, graph]
103
+ );
104
+ const onNodeSelectionChanged = useCallback((_nodeIds) => setSelectedNodeIds(_nodeIds), []);
105
+ useEffect(() => {
106
+ if (!graph) {
107
+ return;
108
+ }
109
+ pointRef.current = svgRef.current.createSVGPoint();
110
+ select(svgRef.current).call(
111
+ zoom$1.on("zoom", (event) => {
112
+ setCurrentZoom == null ? void 0 : setCurrentZoom(event.transform);
113
+ select(svgRef.current).select("#view").attr("transform", event.transform);
114
+ })
115
+ );
116
+ }, [setCurrentZoom, zoom$1, viz, graph]);
117
+ useEffect(() => {
118
+ if (showMousePos) {
119
+ select(svgRef.current).on("mousemove", (event) => {
120
+ const _zoom = transform(select(svgRef.current).select("#view").node());
121
+ setAbsoluteMousePos(_zoom.invert(pointer(event)).map((n) => n.toFixed(0)));
122
+ setRelativeMousePos(pointer(event).map((n) => n.toFixed(0)));
123
+ });
124
+ }
125
+ }, [showMousePos, graph]);
126
+ useEffect(() => {
127
+ resetZoom();
128
+ }, [viz, graph == null ? void 0 : graph.data]);
129
+ useEffect(() => {
130
+ var _a2, _b2, _c2, _d2;
131
+ if ((_b2 = (_a2 = graph == null ? void 0 : graph.metadata.display) == null ? void 0 : _a2.visualization) == null ? void 0 : _b2.type) {
132
+ setViz((_d2 = (_c2 = graph == null ? void 0 : graph.metadata.display) == null ? void 0 : _c2.visualization) == null ? void 0 : _d2.type);
133
+ }
134
+ }, [(_e = (_d = graph == null ? void 0 : graph.metadata.display) == null ? void 0 : _d.visualization) == null ? void 0 : _e.type]);
135
+ const treeOptions = useMemo(
136
+ () => ({
137
+ textColor: theme.palette.text.primary,
138
+ backgroundColor: theme.palette.background.paper,
139
+ nodeColor: {
140
+ border: (isDark ? lighten : darken)(theme.palette.background.paper, 0.3),
141
+ center: "white"
142
+ }
143
+ }),
144
+ [isDark, theme.palette.background.paper, theme.palette.text.primary]
145
+ );
146
+ const cloudOptions = useMemo(
147
+ () => ({
148
+ textColor: theme.palette.text.primary,
149
+ backgroundColor: theme.palette.background.paper,
150
+ nodeColor: {
151
+ border: (isDark ? lighten : darken)(theme.palette.background.paper, 0.3),
152
+ center: "white"
153
+ }
154
+ }),
155
+ [isDark, theme.palette.background.paper, theme.palette.text.primary]
156
+ );
157
+ const visualizations = useMemo(
158
+ () => ({
159
+ tree: () => /* @__PURE__ */ jsx(
160
+ Tree,
161
+ {
162
+ svgRef,
163
+ graph,
164
+ labelKeys,
165
+ onNodeSelectionChanged,
166
+ zoom: currentZoom,
167
+ options: treeOptions
168
+ }
169
+ ),
170
+ cloud: () => /* @__PURE__ */ jsx(Cloud, { svgRef, graph, options: cloudOptions })
171
+ }),
172
+ [cloudOptions, currentZoom, graph, labelKeys, onNodeSelectionChanged, treeOptions]
173
+ );
174
+ const suggestions = useMemo(() => {
175
+ return nodeIds.flatMap((id) => {
176
+ var _a2, _b2;
177
+ const node = (((_a2 = graph == null ? void 0 : graph.data) == null ? void 0 : _a2.flat()) ?? []).find((_node) => _node.id === id);
178
+ if (!node) {
179
+ return { id, value: id };
180
+ }
181
+ const key = ((_b2 = labelKeys == null ? void 0 : labelKeys.filter((comparator) => runComparator(comparator, node)).pop()) == null ? void 0 : _b2.label) ?? "id";
182
+ const value = key.split(",").map((_key) => {
183
+ var _a3;
184
+ return (_a3 = get(node, _key)) == null ? void 0 : _a3.toString();
185
+ }).filter((val) => !!val).map((_value) => ({ id, value: _value.trim() }));
186
+ return value;
187
+ });
188
+ }, [graph == null ? void 0 : graph.data, labelKeys, nodeIds, runComparator]);
189
+ return /* @__PURE__ */ jsxs(
190
+ Stack,
191
+ {
192
+ direction: panelLocation === "vertical" ? "row" : "column",
193
+ spacing: 1,
194
+ overflow: "hidden",
195
+ height: "100%",
196
+ width: "100%",
197
+ sx,
198
+ children: [
199
+ /* @__PURE__ */ jsx(Stack, { direction: "column", spacing: 1, sx: { position: "relative", flex: 1 }, children: /* @__PURE__ */ jsxs(
200
+ Card,
201
+ {
202
+ variant: "outlined",
203
+ sx: {
204
+ flex: 1,
205
+ position: "relative",
206
+ maxHeight: `calc(100vh - 64px - ${theme.spacing(1)})`,
207
+ "& #viz": {
208
+ maxHeight: `calc(100vh - 64px - ${theme.spacing(1)})`,
209
+ width: "100%",
210
+ height: "100%",
211
+ backgroundColor: theme.palette.background.paper
212
+ },
213
+ "& .path": {
214
+ transition: theme.transitions.create(["opacity"], {
215
+ duration: theme.transitions.duration.short
216
+ })
217
+ },
218
+ "& .node": {
219
+ cursor: "pointer",
220
+ "& > path, & > text, & > polygon, & circle": {
221
+ transition: theme.transitions.create(["stroke", "fill", "fill-opacity", "stroke-opacity"], {
222
+ duration: theme.transitions.duration.short
223
+ })
224
+ },
225
+ "&.hover > .center": {
226
+ stroke: cssImportant(theme.palette.primary.main)
227
+ },
228
+ "&.hover > .border": {
229
+ stroke: cssImportant(theme.palette.primary.dark)
230
+ },
231
+ "&.selected > .center": {
232
+ stroke: cssImportant(theme.palette.success.main)
233
+ },
234
+ "&.selected > .border": {
235
+ stroke: cssImportant(theme.palette.success.dark)
236
+ },
237
+ "&.selected.hover > .center": {
238
+ stroke: cssImportant(theme.palette.primary.main)
239
+ },
240
+ "&.selected.hover > .border": {
241
+ stroke: cssImportant(theme.palette.primary.dark)
242
+ }
243
+ }
244
+ },
245
+ children: [
246
+ graph ? visualizations[viz]() : /* @__PURE__ */ jsxs(Fragment, { children: [
247
+ /* @__PURE__ */ jsx("svg", { id: "viz", ref: svgRef, children: /* @__PURE__ */ jsx("g", { id: "view" }) }),
248
+ /* @__PURE__ */ jsx(
249
+ Typography,
250
+ {
251
+ variant: "h1",
252
+ color: "text.secondary",
253
+ sx: {
254
+ position: "absolute",
255
+ top: "50%",
256
+ left: "50%",
257
+ opacity: 0.3,
258
+ transform: "translateX(-50%) translateY(-50%)"
259
+ },
260
+ children: "No dataset has been selected!"
261
+ }
262
+ )
263
+ ] }),
264
+ /* @__PURE__ */ jsx(
265
+ Stack,
266
+ {
267
+ direction: "column",
268
+ spacing: 1,
269
+ sx: {
270
+ position: "absolute",
271
+ top: theme.spacing(1),
272
+ left: theme.spacing(1),
273
+ right: theme.spacing(1)
274
+ },
275
+ children: /* @__PURE__ */ jsxs(
276
+ Stack,
277
+ {
278
+ direction: "row",
279
+ spacing: 1,
280
+ sx: {
281
+ "& > div:first-of-type": {
282
+ flex: 1,
283
+ maxWidth: "775px",
284
+ backgroundColor: alpha(theme.palette.background.paper, 0.8)
285
+ }
286
+ },
287
+ children: [
288
+ /* @__PURE__ */ jsx(
289
+ Autocomplete,
290
+ {
291
+ disablePortal: true,
292
+ onChange: (__, value) => onNodeChange(value.id),
293
+ onKeyDown: onKeyPress,
294
+ options: suggestions,
295
+ sx: { width: "400px" },
296
+ getOptionLabel: (option) => option.value,
297
+ filterOptions: (options, state) => options.filter((opt) => opt.value.toLowerCase().includes(state.inputValue)),
298
+ renderOption: (props, option) => /* @__PURE__ */ createElement("li", { ...props, key: option.id + option.value }, option.value),
299
+ renderInput: (params) => /* @__PURE__ */ jsx(
300
+ TextField,
301
+ {
302
+ ...params,
303
+ error: hasError,
304
+ label: "Enter a node ID, and press [ctrl + enter] to select it. [ctrl + space] will open an autocomplete menu."
305
+ }
306
+ )
307
+ }
308
+ ),
309
+ /* @__PURE__ */ jsxs(FormControl, { sx: { minWidth: "150px", backgroundColor: alpha(theme.palette.background.paper, 0.8) }, children: [
310
+ /* @__PURE__ */ jsx(InputLabel, { id: "viz-label", children: "Visualization" }),
311
+ /* @__PURE__ */ jsx(
312
+ Select,
313
+ {
314
+ label: "Visualization",
315
+ labelId: "viz-label",
316
+ value: viz,
317
+ onChange: (event) => setViz(event.target.value),
318
+ sx: { textTransform: "capitalize" },
319
+ children: Object.keys(visualizations).map((_viz) => /* @__PURE__ */ jsx(MenuItem, { value: _viz, sx: { textTransform: "capitalize" }, children: _viz }, _viz))
320
+ }
321
+ )
322
+ ] }),
323
+ /* @__PURE__ */ jsx(
324
+ ExpandMoreButton,
325
+ {
326
+ disabled: selectedNodeIds.length < 1,
327
+ expand: showPanel,
328
+ onClick: () => setShowPanel(!showPanel),
329
+ "aria-expanded": showPanel,
330
+ "aria-label": "show more",
331
+ size: "small",
332
+ sx: {
333
+ marginLeft: "auto !important",
334
+ alignSelf: "center"
335
+ },
336
+ children: /* @__PURE__ */ jsx(
337
+ Iconified,
338
+ {
339
+ icon: panelLocation === "vertical" ? "ic:baseline-chevron-left" : "ic:baseline-expand-more",
340
+ fontSize: "medium"
341
+ }
342
+ )
343
+ }
344
+ )
345
+ ]
346
+ }
347
+ )
348
+ }
349
+ ),
350
+ /* @__PURE__ */ jsx(
351
+ Card,
352
+ {
353
+ variant: showCoordinates ? "elevation" : "outlined",
354
+ elevation: showCoordinates ? 4 : 0,
355
+ sx: {
356
+ position: "absolute",
357
+ bottom: theme.spacing(0.5),
358
+ right: theme.spacing(0.5),
359
+ px: 1,
360
+ py: 0.5,
361
+ border: "none !important"
362
+ },
363
+ children: /* @__PURE__ */ jsxs(Stack, { direction: "row", spacing: 0.5, alignItems: "center", children: [
364
+ showCoordinates && /* @__PURE__ */ jsxs("span", { children: [
365
+ currentZoom.x.toFixed(0),
366
+ ", ",
367
+ currentZoom.y.toFixed(0),
368
+ " (",
369
+ currentZoom.k.toFixed(2),
370
+ "x)"
371
+ ] }),
372
+ /* @__PURE__ */ jsx(
373
+ IconButton,
374
+ {
375
+ size: showCoordinates ? "small" : "medium",
376
+ onClick: () => resetZoom(),
377
+ disabled: currentZoom.k === identity.k && currentZoom.x === 0 && currentZoom.y === 0,
378
+ children: /* @__PURE__ */ jsx(Iconified, { icon: "ic:baseline-refresh", fontSize: showCoordinates ? "small" : "medium" })
379
+ }
380
+ )
381
+ ] })
382
+ }
383
+ ),
384
+ showMousePos && /* @__PURE__ */ jsx(
385
+ Card,
386
+ {
387
+ variant: "elevation",
388
+ elevation: 4,
389
+ sx: {
390
+ position: "absolute",
391
+ bottom: theme.spacing(0.5),
392
+ left: theme.spacing(0.5),
393
+ px: 1,
394
+ py: 0.5
395
+ },
396
+ children: /* @__PURE__ */ jsx("code", { children: /* @__PURE__ */ jsxs(Stack, { direction: "row", spacing: 1, children: [
397
+ /* @__PURE__ */ jsxs("span", { children: [
398
+ "(abs: ",
399
+ absoluteMousePos.join(", "),
400
+ ")"
401
+ ] }),
402
+ /* @__PURE__ */ jsxs("span", { children: [
403
+ "(rel: ",
404
+ relativeMousePos.join(", "),
405
+ ")"
406
+ ] })
407
+ ] }) })
408
+ }
409
+ )
410
+ ]
411
+ }
412
+ ) }),
413
+ /* @__PURE__ */ jsx(
414
+ Collapse,
415
+ {
416
+ in: showPanel && selectedNodeIds.length > 0,
417
+ orientation: panelLocation === "vertical" ? "horizontal" : "vertical",
418
+ appear: true,
419
+ unmountOnExit: true,
420
+ children: /* @__PURE__ */ jsx(
421
+ Stack,
422
+ {
423
+ direction: "column",
424
+ spacing: 1,
425
+ sx: panelLocation === "vertical" ? { width: "450px", height: "100%" } : { width: "100%", height: "300px" },
426
+ pb: 1,
427
+ children: /* @__PURE__ */ jsx(NodePanel, { selectedNodeIds, findNode })
428
+ }
429
+ )
430
+ }
431
+ )
432
+ ]
433
+ }
434
+ );
435
+ };
436
+ export {
437
+ Graph as default
438
+ };
@@ -0,0 +1,25 @@
1
+ import { CSSProperties, FC, PropsWithChildren } from 'react';
2
+
3
+ interface LeafPropsType {
4
+ nodeId: string;
5
+ label?: string;
6
+ x: number;
7
+ y: number;
8
+ height: number;
9
+ nodeRadius: number;
10
+ nodeColor: {
11
+ border: string;
12
+ center: string;
13
+ };
14
+ nodeOpacity: number;
15
+ letterSize: number;
16
+ letterWidth: number;
17
+ textColor: string;
18
+ selected?: boolean;
19
+ alwaysShowText?: boolean;
20
+ style?: CSSProperties;
21
+ onHoverChanged?: (nodeId: string, isHovered: boolean) => void;
22
+ onClick?: (nodeId: string, isSelected: boolean, event: MouseEvent) => void;
23
+ }
24
+ declare const Leaf: FC<PropsWithChildren<LeafPropsType>>;
25
+ export default Leaf;
@@ -0,0 +1,125 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { i as isObjectLike, b as baseGetTag } from "../../../../isObjectLike-OAgjjZye.js";
3
+ import { useState, useMemo, useCallback, useEffect } from "react";
4
+ var numberTag = "[object Number]";
5
+ function isNumber(value) {
6
+ return typeof value == "number" || isObjectLike(value) && baseGetTag(value) == numberTag;
7
+ }
8
+ const DEFAULT_NODE_RADIUS = 10;
9
+ const Leaf = ({
10
+ nodeId,
11
+ label = nodeId,
12
+ x,
13
+ y,
14
+ height,
15
+ nodeRadius = DEFAULT_NODE_RADIUS,
16
+ nodeColor,
17
+ nodeOpacity = 1,
18
+ letterSize,
19
+ letterWidth,
20
+ textColor,
21
+ style = {},
22
+ selected = false,
23
+ alwaysShowText = false,
24
+ onHoverChanged,
25
+ onClick,
26
+ children
27
+ }) => {
28
+ const [isSelected, setIsSelected] = useState(selected);
29
+ const [isHovered, setIsHovered] = useState(false);
30
+ const classNames = useMemo(() => {
31
+ const _classNames = ["node"];
32
+ if (isHovered) {
33
+ _classNames.push("hover");
34
+ }
35
+ if (isSelected) {
36
+ _classNames.push("selected");
37
+ }
38
+ return _classNames;
39
+ }, [isHovered, isSelected]);
40
+ const handleOnClick = useCallback(
41
+ (event) => {
42
+ onClick == null ? void 0 : onClick(nodeId, !isSelected, event);
43
+ setIsSelected(!isSelected);
44
+ },
45
+ [nodeId, onClick, isSelected]
46
+ );
47
+ const handleOnHoverChanged = useCallback(
48
+ (value) => {
49
+ setIsHovered(value);
50
+ onHoverChanged == null ? void 0 : onHoverChanged(nodeId, value);
51
+ },
52
+ [nodeId, onHoverChanged]
53
+ );
54
+ useEffect(() => setIsSelected(selected), [selected]);
55
+ let strokeWidth = `${nodeRadius}px`;
56
+ if (style.strokeWidth) {
57
+ if (isNumber(style.strokeWidth)) {
58
+ strokeWidth = `${nodeRadius * style.strokeWidth}px`;
59
+ } else {
60
+ strokeWidth = style.strokeWidth;
61
+ }
62
+ }
63
+ return /* @__PURE__ */ jsxs(
64
+ "g",
65
+ {
66
+ id: "node-" + nodeId.replace(/[^A-Za-z0-9]*/g, ""),
67
+ style: { strokeLinecap: "round" },
68
+ className: classNames.join(" "),
69
+ onClick: handleOnClick,
70
+ onMouseOver: () => handleOnHoverChanged(true),
71
+ onMouseLeave: () => handleOnHoverChanged(false),
72
+ children: [
73
+ children,
74
+ /* @__PURE__ */ jsx(
75
+ "path",
76
+ {
77
+ className: "border",
78
+ d: `M ${x} ${y} L ${x} ${y + Math.max(height, 0)}`,
79
+ style: {
80
+ strokeOpacity: nodeOpacity,
81
+ ...style,
82
+ strokeWidth: `calc(${strokeWidth} * 2)`,
83
+ stroke: style.stroke ?? nodeColor.border
84
+ }
85
+ },
86
+ nodeId + "-border"
87
+ ),
88
+ /* @__PURE__ */ jsx(
89
+ "path",
90
+ {
91
+ className: "center",
92
+ d: `M ${x} ${y} L ${x} ${y + Math.max(height, 0)}`,
93
+ style: {
94
+ strokeOpacity: nodeOpacity,
95
+ ...style,
96
+ strokeWidth,
97
+ stroke: style.fill ?? nodeColor.center
98
+ }
99
+ },
100
+ nodeId + "-middle"
101
+ ),
102
+ (isHovered || alwaysShowText) && label.split("\n").reverse().map((_label, index, arr) => /* @__PURE__ */ jsx(
103
+ "text",
104
+ {
105
+ x: x + letterWidth,
106
+ y: y - letterSize / 2 + arr.length - index * letterSize,
107
+ fill: textColor,
108
+ style: {
109
+ cursor: "default",
110
+ fontFamily: '"Lucida Console", monospace',
111
+ fontSize: letterSize + "px",
112
+ fillOpacity: nodeOpacity
113
+ },
114
+ children: _label
115
+ },
116
+ nodeId + "-label-" + _label
117
+ ))
118
+ ]
119
+ },
120
+ nodeId
121
+ );
122
+ };
123
+ export {
124
+ Leaf as default
125
+ };
@@ -0,0 +1,24 @@
1
+ import { NestedDataset } from "../../../../../types/graph";
2
+ import { MutableRefObject } from 'react';
3
+
4
+ declare const DEFAULT_OPTIONS: {
5
+ width: string;
6
+ backgroundColor: string;
7
+ textColor: string;
8
+ nodeColor: {
9
+ border: string;
10
+ center: string;
11
+ };
12
+ letterSize: number;
13
+ letterWidth: number;
14
+ nodeRadius: number;
15
+ lineWidth: number;
16
+ circlePadding: any;
17
+ };
18
+ type Options = Partial<typeof DEFAULT_OPTIONS>;
19
+ declare const _default: import('react').NamedExoticComponent<{
20
+ svgRef?: MutableRefObject<SVGSVGElement>;
21
+ graph: NestedDataset;
22
+ options?: Options;
23
+ }>;
24
+ export default _default;