@reltio/components 1.4.1843 → 1.4.1845

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 (305) hide show
  1. package/cjs/EmptyState/EmptyState.d.ts +1 -0
  2. package/cjs/EmptyState/EmptyState.js +3 -1
  3. package/cjs/features/graph/DataModelGraph/DataModelGraph.d.ts +12 -0
  4. package/cjs/features/graph/DataModelGraph/DataModelGraph.js +28 -0
  5. package/cjs/features/graph/DataModelGraph/DataModelGraph.test.d.ts +1 -0
  6. package/cjs/features/graph/DataModelGraph/DataModelGraph.test.js +63 -0
  7. package/cjs/features/graph/DataModelGraph/components/DataModelCircleLayout/DataModelCircleLayuot.d.ts +11 -0
  8. package/cjs/features/graph/DataModelGraph/components/DataModelCircleLayout/DataModelCircleLayuot.js +21 -0
  9. package/cjs/features/graph/DataModelGraph/helpers/edgeLabelHelpers.d.ts +9 -0
  10. package/cjs/features/graph/DataModelGraph/helpers/edgeLabelHelpers.js +38 -0
  11. package/cjs/features/graph/DataModelGraph/helpers/edgeLabelHelpers.test.d.ts +1 -0
  12. package/cjs/features/graph/DataModelGraph/helpers/edgeLabelHelpers.test.js +74 -0
  13. package/cjs/features/graph/DataModelGraph/hooks/defaultGraph.test-data.d.ts +2 -0
  14. package/cjs/features/graph/DataModelGraph/hooks/defaultGraph.test-data.js +52 -0
  15. package/cjs/features/graph/DataModelGraph/hooks/useDataModelGraphAppearance.d.ts +17 -0
  16. package/cjs/features/graph/DataModelGraph/hooks/useDataModelGraphAppearance.js +139 -0
  17. package/cjs/features/graph/DataModelGraph/hooks/useDataModelGraphAppearance.test.d.ts +1 -0
  18. package/cjs/features/graph/DataModelGraph/hooks/useDataModelGraphAppearance.test.js +192 -0
  19. package/cjs/features/graph/DataModelGraph/hooks/useEdgeLabelsRenderer.d.ts +10 -0
  20. package/cjs/features/graph/DataModelGraph/hooks/useEdgeLabelsRenderer.js +171 -0
  21. package/cjs/features/graph/DataModelGraph/hooks/useEdgeLabelsRenderer.test.d.ts +1 -0
  22. package/cjs/features/graph/DataModelGraph/hooks/useEdgeLabelsRenderer.test.js +176 -0
  23. package/cjs/features/graph/DataModelGraph/hooks/useFakeCenterNode.d.ts +8 -0
  24. package/cjs/features/graph/DataModelGraph/hooks/useFakeCenterNode.js +36 -0
  25. package/cjs/features/graph/DataModelGraph/hooks/useFakeCenterNode.test.d.ts +1 -0
  26. package/cjs/features/graph/DataModelGraph/hooks/useFakeCenterNode.test.js +37 -0
  27. package/cjs/features/graph/DataModelGraph/hooks/useSelectedNodeRenderer.d.ts +2 -0
  28. package/cjs/features/graph/DataModelGraph/hooks/useSelectedNodeRenderer.js +41 -0
  29. package/cjs/features/graph/DataModelGraph/hooks/useSelectedNodeRenderer.test.d.ts +1 -0
  30. package/cjs/features/graph/DataModelGraph/hooks/useSelectedNodeRenderer.test.js +63 -0
  31. package/cjs/features/graph/DataModelGraph/icons/interaction.inline.svg.d.ts +1 -0
  32. package/cjs/features/graph/DataModelGraph/icons/interaction.inline.svg.js +4 -0
  33. package/cjs/features/graph/DataModelGraph/index.d.ts +1 -0
  34. package/cjs/features/graph/DataModelGraph/index.js +5 -0
  35. package/cjs/features/graph/DataModelGraph/styles.d.ts +1 -0
  36. package/cjs/features/graph/DataModelGraph/styles.js +26 -0
  37. package/cjs/features/graph/SigmaCustomRenderersContainer/SigmaCustomRenderersContainer.d.ts +6 -0
  38. package/cjs/features/graph/SigmaCustomRenderersContainer/SigmaCustomRenderersContainer.js +15 -0
  39. package/cjs/features/graph/SigmaCustomRenderersContainer/index.d.ts +1 -0
  40. package/cjs/features/graph/SigmaCustomRenderersContainer/index.js +5 -0
  41. package/cjs/features/graph/SigmaGraphContainer/SigmaGraphContainer.d.ts +9 -0
  42. package/cjs/features/graph/SigmaGraphContainer/SigmaGraphContainer.js +86 -0
  43. package/cjs/features/graph/SigmaGraphContainer/SigmaGraphContainer.test.d.ts +1 -0
  44. package/cjs/features/graph/SigmaGraphContainer/SigmaGraphContainer.test.js +26 -0
  45. package/cjs/features/graph/SigmaGraphContainer/index.d.ts +1 -0
  46. package/cjs/features/graph/SigmaGraphContainer/index.js +5 -0
  47. package/cjs/features/graph/SigmaGraphResizer/SigmaGraphResizer.d.ts +1 -0
  48. package/cjs/features/graph/SigmaGraphResizer/SigmaGraphResizer.js +40 -0
  49. package/cjs/features/graph/SigmaGraphResizer/SigmaGraphResizer.test.d.ts +1 -0
  50. package/cjs/features/graph/SigmaGraphResizer/SigmaGraphResizer.test.js +37 -0
  51. package/cjs/features/graph/SigmaGraphResizer/index.d.ts +1 -0
  52. package/cjs/features/graph/SigmaGraphResizer/index.js +5 -0
  53. package/cjs/features/graph/ZoomSlider/ZoomSlider.d.ts +7 -0
  54. package/cjs/features/graph/ZoomSlider/ZoomSlider.js +113 -0
  55. package/cjs/features/graph/ZoomSlider/ZoomSlider.test.d.ts +1 -0
  56. package/cjs/features/graph/ZoomSlider/ZoomSlider.test.js +83 -0
  57. package/cjs/features/graph/ZoomSlider/index.d.ts +1 -0
  58. package/cjs/features/graph/ZoomSlider/index.js +5 -0
  59. package/cjs/features/graph/ZoomSlider/styles.d.ts +1 -0
  60. package/cjs/features/graph/ZoomSlider/styles.js +63 -0
  61. package/cjs/features/graph/contexts/SigmaCustomRenderersContext.d.ts +9 -0
  62. package/cjs/features/graph/contexts/SigmaCustomRenderersContext.js +15 -0
  63. package/cjs/features/graph/hooks/useAnimatedGraphLayout.d.ts +13 -0
  64. package/cjs/features/graph/hooks/useAnimatedGraphLayout.js +35 -0
  65. package/cjs/features/graph/hooks/useCircleLayout.d.ts +9 -0
  66. package/cjs/features/graph/hooks/useCircleLayout.js +50 -0
  67. package/cjs/features/graph/hooks/useLoopRenderer.d.ts +5 -0
  68. package/cjs/features/graph/hooks/useLoopRenderer.js +47 -0
  69. package/cjs/features/graph/hooks/useLoopRenderer.test.d.ts +1 -0
  70. package/cjs/features/graph/hooks/useLoopRenderer.test.js +221 -0
  71. package/cjs/features/graph/hooks/useSigmaCustomRenderers.d.ts +7 -0
  72. package/cjs/features/graph/hooks/useSigmaCustomRenderers.js +95 -0
  73. package/cjs/features/graph/hooks/useSigmaCustomRenderers.test.d.ts +1 -0
  74. package/cjs/features/graph/hooks/useSigmaCustomRenderers.test.js +200 -0
  75. package/cjs/features/graph/index.d.ts +16 -0
  76. package/cjs/features/graph/index.js +34 -0
  77. package/cjs/features/graph/rendering/canvas/hover.d.ts +2 -0
  78. package/cjs/features/graph/rendering/canvas/hover.js +10 -0
  79. package/cjs/features/graph/rendering/canvas/hover.spec.d.ts +1 -0
  80. package/cjs/features/graph/rendering/canvas/hover.spec.js +26 -0
  81. package/cjs/features/graph/rendering/canvas/label.d.ts +7 -0
  82. package/cjs/features/graph/rendering/canvas/label.js +32 -0
  83. package/cjs/features/graph/rendering/canvas/label.spec.d.ts +1 -0
  84. package/cjs/features/graph/rendering/canvas/label.spec.js +81 -0
  85. package/cjs/features/graph/rendering/canvas/labelBackground.d.ts +9 -0
  86. package/cjs/features/graph/rendering/canvas/labelBackground.js +37 -0
  87. package/cjs/features/graph/rendering/canvas/labelBackground.spec.d.ts +1 -0
  88. package/cjs/features/graph/rendering/canvas/labelBackground.spec.js +92 -0
  89. package/cjs/features/graph/rendering/canvas/nodeArc.d.ts +10 -0
  90. package/cjs/features/graph/rendering/canvas/nodeArc.js +33 -0
  91. package/cjs/features/graph/rendering/canvas/selfRelationLoop.d.ts +11 -0
  92. package/cjs/features/graph/rendering/canvas/selfRelationLoop.js +73 -0
  93. package/cjs/features/graph/rendering/canvas/selfRelationLoop.spec.d.ts +1 -0
  94. package/cjs/features/graph/rendering/canvas/selfRelationLoop.spec.js +92 -0
  95. package/cjs/features/graph/rendering/canvas/tooltip.d.ts +2 -0
  96. package/cjs/features/graph/rendering/canvas/tooltip.js +28 -0
  97. package/cjs/features/graph/rendering/canvas/tooltip.spec.d.ts +1 -0
  98. package/cjs/features/graph/rendering/canvas/tooltip.spec.js +32 -0
  99. package/cjs/features/graph/rendering/canvas/utils.d.ts +4 -0
  100. package/cjs/features/graph/rendering/canvas/utils.js +10 -0
  101. package/cjs/features/graph/rendering/canvas/utils.spec.d.ts +1 -0
  102. package/cjs/features/graph/rendering/canvas/utils.spec.js +22 -0
  103. package/cjs/features/graph/rendering/icons/no_photo.inline.svg.d.ts +1 -0
  104. package/cjs/features/graph/rendering/icons/no_photo.inline.svg.js +4 -0
  105. package/cjs/features/graph/rendering/webgl/edge.arrowHead.d.ts +8 -0
  106. package/cjs/features/graph/rendering/webgl/edge.arrowHead.js +84 -0
  107. package/cjs/features/graph/rendering/webgl/edge.clamped.d.ts +29 -0
  108. package/cjs/features/graph/rendering/webgl/edge.clamped.js +176 -0
  109. package/cjs/features/graph/rendering/webgl/edge.dashed.d.ts +23 -0
  110. package/cjs/features/graph/rendering/webgl/edge.dashed.js +162 -0
  111. package/cjs/features/graph/rendering/webgl/edge.reversedArrowHead.d.ts +5 -0
  112. package/cjs/features/graph/rendering/webgl/edge.reversedArrowHead.js +32 -0
  113. package/cjs/features/graph/rendering/webgl/helpers/imageHelper.d.ts +17 -0
  114. package/cjs/features/graph/rendering/webgl/helpers/imageHelper.js +9 -0
  115. package/cjs/features/graph/rendering/webgl/helpers/imageHelper.spec.d.ts +1 -0
  116. package/cjs/features/graph/rendering/webgl/helpers/imageHelper.spec.js +29 -0
  117. package/cjs/features/graph/rendering/webgl/image.d.ts +17 -0
  118. package/cjs/features/graph/rendering/webgl/image.js +115 -0
  119. package/cjs/features/graph/rendering/webgl/node.border.d.ts +11 -0
  120. package/cjs/features/graph/rendering/webgl/node.border.js +79 -0
  121. package/cjs/features/graph/rendering/webgl/node.dashed.border.d.ts +11 -0
  122. package/cjs/features/graph/rendering/webgl/node.dashed.border.js +77 -0
  123. package/cjs/features/graph/rendering/webgl/node.image.d.ts +18 -0
  124. package/cjs/features/graph/rendering/webgl/node.image.js +147 -0
  125. package/cjs/features/graph/rendering/webgl/shaders/edge.clamped.vert.glsl.d.ts +1 -0
  126. package/cjs/features/graph/rendering/webgl/shaders/edge.clamped.vert.glsl.js +8 -0
  127. package/cjs/features/graph/rendering/webgl/shaders/edge.dashed.frag.glsl.d.ts +1 -0
  128. package/cjs/features/graph/rendering/webgl/shaders/edge.dashed.frag.glsl.js +8 -0
  129. package/cjs/features/graph/rendering/webgl/shaders/edge.dashed.vert.glsl.d.ts +1 -0
  130. package/cjs/features/graph/rendering/webgl/shaders/edge.dashed.vert.glsl.js +8 -0
  131. package/cjs/features/graph/rendering/webgl/shaders/node.border.frag.glsl.d.ts +1 -0
  132. package/cjs/features/graph/rendering/webgl/shaders/node.border.frag.glsl.js +9 -0
  133. package/cjs/features/graph/rendering/webgl/shaders/node.border.vert.glsl.d.ts +1 -0
  134. package/cjs/features/graph/rendering/webgl/shaders/node.border.vert.glsl.js +8 -0
  135. package/cjs/features/graph/rendering/webgl/shaders/node.dashed.border.frag.glsl.d.ts +1 -0
  136. package/cjs/features/graph/rendering/webgl/shaders/node.dashed.border.frag.glsl.js +8 -0
  137. package/cjs/features/graph/rendering/webgl/shaders/node.image.frag.glsl.d.ts +1 -0
  138. package/cjs/features/graph/rendering/webgl/shaders/node.image.frag.glsl.js +5 -0
  139. package/cjs/features/graph/rendering/webgl/shaders/node.image.vert.glsl.d.ts +1 -0
  140. package/cjs/features/graph/rendering/webgl/shaders/node.image.vert.glsl.js +8 -0
  141. package/cjs/features/graph/rendering/webgl/shaders/utils.d.ts +1 -0
  142. package/cjs/features/graph/rendering/webgl/shaders/utils.js +4 -0
  143. package/cjs/features/graph/types/graphDataTypes.d.ts +51 -0
  144. package/cjs/features/graph/types/graphDataTypes.js +8 -0
  145. package/cjs/features/graph/types/sigmaCustomRenderersTypes.d.ts +11 -0
  146. package/cjs/features/graph/types/sigmaCustomRenderersTypes.js +2 -0
  147. package/cjs/icons/EmptyLoading.d.ts +3 -0
  148. package/cjs/icons/EmptyLoading.js +150 -0
  149. package/cjs/icons/index.d.ts +1 -0
  150. package/cjs/icons/index.js +4 -2
  151. package/cjs/index.d.ts +1 -0
  152. package/cjs/index.js +2 -0
  153. package/esm/EmptyState/EmptyState.d.ts +1 -0
  154. package/esm/EmptyState/EmptyState.js +3 -1
  155. package/esm/features/graph/DataModelGraph/DataModelGraph.d.ts +12 -0
  156. package/esm/features/graph/DataModelGraph/DataModelGraph.js +21 -0
  157. package/esm/features/graph/DataModelGraph/DataModelGraph.test.d.ts +1 -0
  158. package/esm/features/graph/DataModelGraph/DataModelGraph.test.js +58 -0
  159. package/esm/features/graph/DataModelGraph/components/DataModelCircleLayout/DataModelCircleLayuot.d.ts +11 -0
  160. package/esm/features/graph/DataModelGraph/components/DataModelCircleLayout/DataModelCircleLayuot.js +17 -0
  161. package/esm/features/graph/DataModelGraph/helpers/edgeLabelHelpers.d.ts +9 -0
  162. package/esm/features/graph/DataModelGraph/helpers/edgeLabelHelpers.js +33 -0
  163. package/esm/features/graph/DataModelGraph/helpers/edgeLabelHelpers.test.d.ts +1 -0
  164. package/esm/features/graph/DataModelGraph/helpers/edgeLabelHelpers.test.js +72 -0
  165. package/esm/features/graph/DataModelGraph/hooks/defaultGraph.test-data.d.ts +2 -0
  166. package/esm/features/graph/DataModelGraph/hooks/defaultGraph.test-data.js +45 -0
  167. package/esm/features/graph/DataModelGraph/hooks/useDataModelGraphAppearance.d.ts +17 -0
  168. package/esm/features/graph/DataModelGraph/hooks/useDataModelGraphAppearance.js +135 -0
  169. package/esm/features/graph/DataModelGraph/hooks/useDataModelGraphAppearance.test.d.ts +1 -0
  170. package/esm/features/graph/DataModelGraph/hooks/useDataModelGraphAppearance.test.js +190 -0
  171. package/esm/features/graph/DataModelGraph/hooks/useEdgeLabelsRenderer.d.ts +10 -0
  172. package/esm/features/graph/DataModelGraph/hooks/useEdgeLabelsRenderer.js +167 -0
  173. package/esm/features/graph/DataModelGraph/hooks/useEdgeLabelsRenderer.test.d.ts +1 -0
  174. package/esm/features/graph/DataModelGraph/hooks/useEdgeLabelsRenderer.test.js +174 -0
  175. package/esm/features/graph/DataModelGraph/hooks/useFakeCenterNode.d.ts +8 -0
  176. package/esm/features/graph/DataModelGraph/hooks/useFakeCenterNode.js +32 -0
  177. package/esm/features/graph/DataModelGraph/hooks/useFakeCenterNode.test.d.ts +1 -0
  178. package/esm/features/graph/DataModelGraph/hooks/useFakeCenterNode.test.js +35 -0
  179. package/esm/features/graph/DataModelGraph/hooks/useSelectedNodeRenderer.d.ts +2 -0
  180. package/esm/features/graph/DataModelGraph/hooks/useSelectedNodeRenderer.js +37 -0
  181. package/esm/features/graph/DataModelGraph/hooks/useSelectedNodeRenderer.test.d.ts +1 -0
  182. package/esm/features/graph/DataModelGraph/hooks/useSelectedNodeRenderer.test.js +61 -0
  183. package/esm/features/graph/DataModelGraph/icons/interaction.inline.svg.d.ts +1 -0
  184. package/esm/features/graph/DataModelGraph/icons/interaction.inline.svg.js +1 -0
  185. package/esm/features/graph/DataModelGraph/index.d.ts +1 -0
  186. package/esm/features/graph/DataModelGraph/index.js +1 -0
  187. package/esm/features/graph/DataModelGraph/styles.d.ts +1 -0
  188. package/esm/features/graph/DataModelGraph/styles.js +23 -0
  189. package/esm/features/graph/SigmaCustomRenderersContainer/SigmaCustomRenderersContainer.d.ts +6 -0
  190. package/esm/features/graph/SigmaCustomRenderersContainer/SigmaCustomRenderersContainer.js +8 -0
  191. package/esm/features/graph/SigmaCustomRenderersContainer/index.d.ts +1 -0
  192. package/esm/features/graph/SigmaCustomRenderersContainer/index.js +1 -0
  193. package/esm/features/graph/SigmaGraphContainer/SigmaGraphContainer.d.ts +9 -0
  194. package/esm/features/graph/SigmaGraphContainer/SigmaGraphContainer.js +56 -0
  195. package/esm/features/graph/SigmaGraphContainer/SigmaGraphContainer.test.d.ts +1 -0
  196. package/esm/features/graph/SigmaGraphContainer/SigmaGraphContainer.test.js +21 -0
  197. package/esm/features/graph/SigmaGraphContainer/index.d.ts +1 -0
  198. package/esm/features/graph/SigmaGraphContainer/index.js +1 -0
  199. package/esm/features/graph/SigmaGraphResizer/SigmaGraphResizer.d.ts +1 -0
  200. package/esm/features/graph/SigmaGraphResizer/SigmaGraphResizer.js +10 -0
  201. package/esm/features/graph/SigmaGraphResizer/SigmaGraphResizer.test.d.ts +1 -0
  202. package/esm/features/graph/SigmaGraphResizer/SigmaGraphResizer.test.js +32 -0
  203. package/esm/features/graph/SigmaGraphResizer/index.d.ts +1 -0
  204. package/esm/features/graph/SigmaGraphResizer/index.js +1 -0
  205. package/esm/features/graph/ZoomSlider/ZoomSlider.d.ts +7 -0
  206. package/esm/features/graph/ZoomSlider/ZoomSlider.js +83 -0
  207. package/esm/features/graph/ZoomSlider/ZoomSlider.test.d.ts +1 -0
  208. package/esm/features/graph/ZoomSlider/ZoomSlider.test.js +78 -0
  209. package/esm/features/graph/ZoomSlider/index.d.ts +1 -0
  210. package/esm/features/graph/ZoomSlider/index.js +1 -0
  211. package/esm/features/graph/ZoomSlider/styles.d.ts +1 -0
  212. package/esm/features/graph/ZoomSlider/styles.js +60 -0
  213. package/esm/features/graph/contexts/SigmaCustomRenderersContext.d.ts +9 -0
  214. package/esm/features/graph/contexts/SigmaCustomRenderersContext.js +11 -0
  215. package/esm/features/graph/hooks/useAnimatedGraphLayout.d.ts +13 -0
  216. package/esm/features/graph/hooks/useAnimatedGraphLayout.js +31 -0
  217. package/esm/features/graph/hooks/useCircleLayout.d.ts +9 -0
  218. package/esm/features/graph/hooks/useCircleLayout.js +43 -0
  219. package/esm/features/graph/hooks/useLoopRenderer.d.ts +5 -0
  220. package/esm/features/graph/hooks/useLoopRenderer.js +43 -0
  221. package/esm/features/graph/hooks/useLoopRenderer.test.d.ts +1 -0
  222. package/esm/features/graph/hooks/useLoopRenderer.test.js +219 -0
  223. package/esm/features/graph/hooks/useSigmaCustomRenderers.d.ts +7 -0
  224. package/esm/features/graph/hooks/useSigmaCustomRenderers.js +91 -0
  225. package/esm/features/graph/hooks/useSigmaCustomRenderers.test.d.ts +1 -0
  226. package/esm/features/graph/hooks/useSigmaCustomRenderers.test.js +198 -0
  227. package/esm/features/graph/index.d.ts +16 -0
  228. package/esm/features/graph/index.js +17 -0
  229. package/esm/features/graph/rendering/canvas/hover.d.ts +2 -0
  230. package/esm/features/graph/rendering/canvas/hover.js +6 -0
  231. package/esm/features/graph/rendering/canvas/hover.spec.d.ts +1 -0
  232. package/esm/features/graph/rendering/canvas/hover.spec.js +24 -0
  233. package/esm/features/graph/rendering/canvas/label.d.ts +7 -0
  234. package/esm/features/graph/rendering/canvas/label.js +28 -0
  235. package/esm/features/graph/rendering/canvas/label.spec.d.ts +1 -0
  236. package/esm/features/graph/rendering/canvas/label.spec.js +79 -0
  237. package/esm/features/graph/rendering/canvas/labelBackground.d.ts +9 -0
  238. package/esm/features/graph/rendering/canvas/labelBackground.js +33 -0
  239. package/esm/features/graph/rendering/canvas/labelBackground.spec.d.ts +1 -0
  240. package/esm/features/graph/rendering/canvas/labelBackground.spec.js +90 -0
  241. package/esm/features/graph/rendering/canvas/nodeArc.d.ts +10 -0
  242. package/esm/features/graph/rendering/canvas/nodeArc.js +27 -0
  243. package/esm/features/graph/rendering/canvas/selfRelationLoop.d.ts +11 -0
  244. package/esm/features/graph/rendering/canvas/selfRelationLoop.js +69 -0
  245. package/esm/features/graph/rendering/canvas/selfRelationLoop.spec.d.ts +1 -0
  246. package/esm/features/graph/rendering/canvas/selfRelationLoop.spec.js +90 -0
  247. package/esm/features/graph/rendering/canvas/tooltip.d.ts +2 -0
  248. package/esm/features/graph/rendering/canvas/tooltip.js +25 -0
  249. package/esm/features/graph/rendering/canvas/tooltip.spec.d.ts +1 -0
  250. package/esm/features/graph/rendering/canvas/tooltip.spec.js +30 -0
  251. package/esm/features/graph/rendering/canvas/utils.d.ts +4 -0
  252. package/esm/features/graph/rendering/canvas/utils.js +6 -0
  253. package/esm/features/graph/rendering/canvas/utils.spec.d.ts +1 -0
  254. package/esm/features/graph/rendering/canvas/utils.spec.js +20 -0
  255. package/esm/features/graph/rendering/icons/no_photo.inline.svg.d.ts +1 -0
  256. package/esm/features/graph/rendering/icons/no_photo.inline.svg.js +1 -0
  257. package/esm/features/graph/rendering/webgl/edge.arrowHead.d.ts +8 -0
  258. package/esm/features/graph/rendering/webgl/edge.arrowHead.js +79 -0
  259. package/esm/features/graph/rendering/webgl/edge.clamped.d.ts +29 -0
  260. package/esm/features/graph/rendering/webgl/edge.clamped.js +171 -0
  261. package/esm/features/graph/rendering/webgl/edge.dashed.d.ts +23 -0
  262. package/esm/features/graph/rendering/webgl/edge.dashed.js +160 -0
  263. package/esm/features/graph/rendering/webgl/edge.reversedArrowHead.d.ts +5 -0
  264. package/esm/features/graph/rendering/webgl/edge.reversedArrowHead.js +27 -0
  265. package/esm/features/graph/rendering/webgl/helpers/imageHelper.d.ts +17 -0
  266. package/esm/features/graph/rendering/webgl/helpers/imageHelper.js +5 -0
  267. package/esm/features/graph/rendering/webgl/helpers/imageHelper.spec.d.ts +1 -0
  268. package/esm/features/graph/rendering/webgl/helpers/imageHelper.spec.js +27 -0
  269. package/esm/features/graph/rendering/webgl/image.d.ts +17 -0
  270. package/esm/features/graph/rendering/webgl/image.js +112 -0
  271. package/esm/features/graph/rendering/webgl/node.border.d.ts +11 -0
  272. package/esm/features/graph/rendering/webgl/node.border.js +76 -0
  273. package/esm/features/graph/rendering/webgl/node.dashed.border.d.ts +11 -0
  274. package/esm/features/graph/rendering/webgl/node.dashed.border.js +74 -0
  275. package/esm/features/graph/rendering/webgl/node.image.d.ts +18 -0
  276. package/esm/features/graph/rendering/webgl/node.image.js +144 -0
  277. package/esm/features/graph/rendering/webgl/shaders/edge.clamped.vert.glsl.d.ts +1 -0
  278. package/esm/features/graph/rendering/webgl/shaders/edge.clamped.vert.glsl.js +5 -0
  279. package/esm/features/graph/rendering/webgl/shaders/edge.dashed.frag.glsl.d.ts +1 -0
  280. package/esm/features/graph/rendering/webgl/shaders/edge.dashed.frag.glsl.js +5 -0
  281. package/esm/features/graph/rendering/webgl/shaders/edge.dashed.vert.glsl.d.ts +1 -0
  282. package/esm/features/graph/rendering/webgl/shaders/edge.dashed.vert.glsl.js +5 -0
  283. package/esm/features/graph/rendering/webgl/shaders/node.border.frag.glsl.d.ts +1 -0
  284. package/esm/features/graph/rendering/webgl/shaders/node.border.frag.glsl.js +6 -0
  285. package/esm/features/graph/rendering/webgl/shaders/node.border.vert.glsl.d.ts +1 -0
  286. package/esm/features/graph/rendering/webgl/shaders/node.border.vert.glsl.js +5 -0
  287. package/esm/features/graph/rendering/webgl/shaders/node.dashed.border.frag.glsl.d.ts +1 -0
  288. package/esm/features/graph/rendering/webgl/shaders/node.dashed.border.frag.glsl.js +5 -0
  289. package/esm/features/graph/rendering/webgl/shaders/node.image.frag.glsl.d.ts +1 -0
  290. package/esm/features/graph/rendering/webgl/shaders/node.image.frag.glsl.js +2 -0
  291. package/esm/features/graph/rendering/webgl/shaders/node.image.vert.glsl.d.ts +1 -0
  292. package/esm/features/graph/rendering/webgl/shaders/node.image.vert.glsl.js +5 -0
  293. package/esm/features/graph/rendering/webgl/shaders/utils.d.ts +1 -0
  294. package/esm/features/graph/rendering/webgl/shaders/utils.js +1 -0
  295. package/esm/features/graph/types/graphDataTypes.d.ts +51 -0
  296. package/esm/features/graph/types/graphDataTypes.js +5 -0
  297. package/esm/features/graph/types/sigmaCustomRenderersTypes.d.ts +11 -0
  298. package/esm/features/graph/types/sigmaCustomRenderersTypes.js +1 -0
  299. package/esm/icons/EmptyLoading.d.ts +3 -0
  300. package/esm/icons/EmptyLoading.js +145 -0
  301. package/esm/icons/index.d.ts +1 -0
  302. package/esm/icons/index.js +1 -0
  303. package/esm/index.d.ts +1 -0
  304. package/esm/index.js +2 -0
  305. package/package.json +2 -2
@@ -0,0 +1,190 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
13
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
14
+ return new (P || (P = Promise))(function (resolve, reject) {
15
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
16
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
17
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
18
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
19
+ });
20
+ };
21
+ var __generator = (this && this.__generator) || function (thisArg, body) {
22
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
23
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
24
+ function verb(n) { return function (v) { return step([n, v]); }; }
25
+ function step(op) {
26
+ if (f) throw new TypeError("Generator is already executing.");
27
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
28
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
29
+ if (y = 0, t) op = [op[0] & 2, t.value];
30
+ switch (op[0]) {
31
+ case 0: case 1: t = op; break;
32
+ case 4: _.label++; return { value: op[1], done: false };
33
+ case 5: _.label++; y = op[1]; op = [0]; continue;
34
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
35
+ default:
36
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
37
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
38
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
39
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
40
+ if (t[2]) _.ops.pop();
41
+ _.trys.pop(); continue;
42
+ }
43
+ op = body.call(thisArg, _);
44
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
45
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
46
+ }
47
+ };
48
+ var __rest = (this && this.__rest) || function (s, e) {
49
+ var t = {};
50
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
51
+ t[p] = s[p];
52
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
53
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
54
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
55
+ t[p[i]] = s[p[i]];
56
+ }
57
+ return t;
58
+ };
59
+ import { renderHook, act } from '@testing-library/react-hooks';
60
+ import { last } from 'ramda';
61
+ import { useSigma, useSetSettings, useRegisterEvents } from '@react-sigma/core';
62
+ import { DASHED_EDGE_COLOR, EDGE_COLOR, INACTIVE_EDGE_COLOR, INACTIVE_LABEL_COLOR, RELATED_DASHED_EDGE_COLOR, RELATED_EDGE_COLOR, SELECTED_EDGE_COLOR, useDataModelGraphAppearance } from './useDataModelGraphAppearance';
63
+ import { DataModelGraphNodeType } from '../../types/graphDataTypes';
64
+ import { createDefaultGraph } from './defaultGraph.test-data';
65
+ jest.mock('@react-sigma/core', function () {
66
+ var sigma = jest.requireActual('@react-sigma/core');
67
+ return __assign(__assign({}, sigma), { useSigma: jest.fn(), useRegisterEvents: jest.fn().mockReturnValue(jest.fn()), useSetSettings: jest.fn().mockReturnValue(jest.fn()), useSigmaContext: jest.fn().mockReturnValue({
68
+ container: {
69
+ style: {}
70
+ }
71
+ }) });
72
+ });
73
+ jest.mock('../../hooks/useLoopRenderer', function () { return ({
74
+ useLoopRenderer: jest.fn()
75
+ }); });
76
+ jest.mock('./useEdgeLabelsRenderer', function () { return ({
77
+ useEdgeLabelsRenderer: jest.fn()
78
+ }); });
79
+ jest.mock('./useSelectedNodeRenderer', function () { return ({
80
+ useSelectedNodeRenderer: jest.fn()
81
+ }); });
82
+ describe('useDataModelGraphAppearance tests', function () {
83
+ var setUp = function (props) {
84
+ var graph = createDefaultGraph();
85
+ useSigma.mockReturnValue({
86
+ getGraph: function () { return graph; }
87
+ });
88
+ return __assign({ graph: graph }, renderHook(useDataModelGraphAppearance, {
89
+ initialProps: __assign({ graph: graph, selectedNode: null, onNodeClick: jest.fn(), selectedEdge: null, onEdgeLabelClick: jest.fn() }, props)
90
+ }));
91
+ };
92
+ var setSettings = jest.fn();
93
+ var registerEvents = jest.fn();
94
+ beforeAll(function () {
95
+ useSetSettings.mockReturnValue(setSettings);
96
+ useRegisterEvents.mockReturnValue(registerEvents);
97
+ });
98
+ var getNodeReducer = function () { return last(setSettings.mock.calls)[0].nodeReducer; };
99
+ var getEdgeReducer = function () { return last(setSettings.mock.calls)[0].edgeReducer; };
100
+ var getEnterNode = function () { return last(registerEvents.mock.calls)[0].enterNode; };
101
+ var getClickNode = function () { return last(registerEvents.mock.calls)[0].clickNode; };
102
+ afterEach(function () {
103
+ jest.clearAllMocks();
104
+ });
105
+ it('should call onNodeClick on clickNode event', function () {
106
+ var onNodeClick = jest.fn();
107
+ setUp({ onNodeClick: onNodeClick });
108
+ var clickNode = getClickNode();
109
+ act(function () {
110
+ clickNode({ node: 'hca' });
111
+ });
112
+ expect(onNodeClick).toHaveBeenCalledWith('hca');
113
+ });
114
+ describe('nodes reducer behavior', function () {
115
+ var getDefaultNodeAttributes = function (_a) {
116
+ var _secondaryLabel = _a.secondaryLabel, attributes = __rest(_a, ["secondaryLabel"]);
117
+ return (__assign(__assign({}, attributes), { type: 'image', size: 28, color: 'rgba(55, 71, 79, 1)' }));
118
+ };
119
+ it('should apply default node style', function () {
120
+ var _a = setUp(), result = _a.result, graph = _a.graph;
121
+ var nodeReducer = getNodeReducer();
122
+ expect(nodeReducer('hcp', graph.getNodeAttributes('hcp'))).toEqual(__assign(__assign({}, getDefaultNodeAttributes(graph.getNodeAttributes('hcp'))), { image: 'HCP.svg', label: 'HCP', nodeType: DataModelGraphNodeType.entityType }));
123
+ expect(nodeReducer('hca', graph.getNodeAttributes('hca'))).toEqual(__assign(__assign({}, getDefaultNodeAttributes(graph.getNodeAttributes('hca'))), { image: 'HCA.svg', label: 'HCA', nodeType: DataModelGraphNodeType.entityType }));
124
+ expect(nodeReducer('gpo', graph.getNodeAttributes('gpo'))).toEqual(__assign(__assign({}, getDefaultNodeAttributes(graph.getNodeAttributes('gpo'))), { label: 'GPO', nodeType: DataModelGraphNodeType.entityType }));
125
+ expect(nodeReducer('prescriptions', graph.getNodeAttributes('prescriptions'))).toEqual(__assign(__assign({}, getDefaultNodeAttributes(graph.getNodeAttributes('prescriptions'))), { hasBorder: true, image: expect.stringContaining('data:image/svg+xml'), label: 'Prescriptions', nodeType: DataModelGraphNodeType.interactionType }));
126
+ expect(result.error).toBeUndefined();
127
+ });
128
+ it('should apply hovered node style', function () { return __awaiter(void 0, void 0, void 0, function () {
129
+ var _a, graph, result, enterNode, nodeReducer;
130
+ return __generator(this, function (_b) {
131
+ _a = setUp(), graph = _a.graph, result = _a.result;
132
+ enterNode = getEnterNode();
133
+ act(function () {
134
+ enterNode({ node: 'hcp' });
135
+ });
136
+ nodeReducer = getNodeReducer();
137
+ expect(nodeReducer('hcp', graph.getNodeAttributes('hcp'))).toEqual(__assign(__assign({}, getDefaultNodeAttributes(graph.getNodeAttributes('hcp'))), { image: 'HCP.svg', label: 'HCP', secondaryLabel: '12 attributes', nodeType: DataModelGraphNodeType.entityType }));
138
+ expect(result.error).toBeUndefined();
139
+ return [2 /*return*/];
140
+ });
141
+ }); });
142
+ it('should apply correct styles when selectedNode is specified', function () {
143
+ var _a = setUp({ selectedNode: 'hcp' }), graph = _a.graph, result = _a.result;
144
+ var nodeReducer = getNodeReducer();
145
+ expect(nodeReducer('hcp', graph.getNodeAttributes('hcp'))).toEqual(__assign(__assign({}, getDefaultNodeAttributes(graph.getNodeAttributes('hcp'))), { image: 'HCP.svg', label: 'HCP', secondaryLabel: '12 attributes', selected: true, zIndex: 100, nodeType: DataModelGraphNodeType.entityType }));
146
+ expect(nodeReducer('hca', graph.getNodeAttributes('hca'))).toEqual(__assign(__assign({}, getDefaultNodeAttributes(graph.getNodeAttributes('hca'))), { image: 'HCA.svg', label: 'HCA', nodeType: DataModelGraphNodeType.entityType }));
147
+ expect(nodeReducer('gpo', graph.getNodeAttributes('gpo'))).toEqual(__assign(__assign({}, getDefaultNodeAttributes(graph.getNodeAttributes('gpo'))), { label: 'GPO', nodeType: DataModelGraphNodeType.entityType, inactive: true, labelColor: INACTIVE_LABEL_COLOR, secondaryLabelColor: INACTIVE_LABEL_COLOR }));
148
+ expect(nodeReducer('prescriptions', graph.getNodeAttributes('prescriptions'))).toEqual(__assign(__assign({}, getDefaultNodeAttributes(graph.getNodeAttributes('prescriptions'))), { hasBorder: true, image: expect.stringContaining('data:image/svg+xml'), label: 'Prescriptions', nodeType: DataModelGraphNodeType.interactionType }));
149
+ expect(result.error).toBeUndefined();
150
+ });
151
+ it('should apply correct styles when selectedEdge is specified', function () {
152
+ var _a = setUp({ selectedEdge: 'hcp->hca' }), graph = _a.graph, result = _a.result;
153
+ var nodeReducer = getNodeReducer();
154
+ expect(nodeReducer('hcp', graph.getNodeAttributes('hcp'))).toEqual(__assign(__assign({}, getDefaultNodeAttributes(graph.getNodeAttributes('hcp'))), { image: 'HCP.svg', label: 'HCP', nodeType: DataModelGraphNodeType.entityType }));
155
+ expect(nodeReducer('hca', graph.getNodeAttributes('hca'))).toEqual(__assign(__assign({}, getDefaultNodeAttributes(graph.getNodeAttributes('hca'))), { image: 'HCA.svg', label: 'HCA', nodeType: DataModelGraphNodeType.entityType }));
156
+ expect(nodeReducer('gpo', graph.getNodeAttributes('gpo'))).toEqual(__assign(__assign({}, getDefaultNodeAttributes(graph.getNodeAttributes('gpo'))), { label: 'GPO', nodeType: DataModelGraphNodeType.entityType, inactive: true, labelColor: INACTIVE_LABEL_COLOR, secondaryLabelColor: INACTIVE_LABEL_COLOR }));
157
+ expect(nodeReducer('prescriptions', graph.getNodeAttributes('prescriptions'))).toEqual(__assign(__assign({}, getDefaultNodeAttributes(graph.getNodeAttributes('prescriptions'))), { hasBorder: true, image: expect.stringContaining('data:image/svg+xml'), label: 'Prescriptions', nodeType: DataModelGraphNodeType.interactionType, inactive: true, labelColor: INACTIVE_LABEL_COLOR, secondaryLabelColor: INACTIVE_LABEL_COLOR }));
158
+ expect(result.error).toBeUndefined();
159
+ });
160
+ });
161
+ describe('edges reducer behavior', function () {
162
+ var defaultEdgeStyle = {
163
+ size: 2
164
+ };
165
+ it('should apply default edge style', function () {
166
+ var _a = setUp(), result = _a.result, graph = _a.graph;
167
+ var edgeReducer = getEdgeReducer();
168
+ expect(edgeReducer('hcp->hca', graph.getEdgeAttributes('hcp->hca'))).toEqual(__assign(__assign({}, defaultEdgeStyle), { label: '1', color: EDGE_COLOR }));
169
+ expect(edgeReducer('hca->gpo', graph.getEdgeAttributes('hca->gpo'))).toEqual(__assign(__assign({}, defaultEdgeStyle), { label: '2', color: EDGE_COLOR }));
170
+ expect(edgeReducer('hcp->prescriptions', graph.getEdgeAttributes('hcp->prescriptions'))).toEqual(__assign(__assign({}, defaultEdgeStyle), { type: 'dashed', color: DASHED_EDGE_COLOR }));
171
+ expect(result.error).toBeUndefined();
172
+ });
173
+ it('should apply correct styles when selectedNode is specified', function () {
174
+ var _a = setUp({ selectedNode: 'hcp' }), graph = _a.graph, result = _a.result;
175
+ var edgeReducer = getEdgeReducer();
176
+ expect(edgeReducer('hcp->hca', graph.getEdgeAttributes('hcp->hca'))).toEqual(__assign(__assign({}, defaultEdgeStyle), { label: '1', color: RELATED_EDGE_COLOR }));
177
+ expect(edgeReducer('hca->gpo', graph.getEdgeAttributes('hca->gpo'))).toEqual(__assign(__assign({}, defaultEdgeStyle), { label: '2', color: INACTIVE_EDGE_COLOR, labelColor: INACTIVE_LABEL_COLOR }));
178
+ expect(edgeReducer('hcp->prescriptions', graph.getEdgeAttributes('hcp->prescriptions'))).toEqual(__assign(__assign({}, defaultEdgeStyle), { type: 'dashed', color: RELATED_DASHED_EDGE_COLOR }));
179
+ expect(result.error).toBeUndefined();
180
+ });
181
+ it('should apply correct styles when selectedEdge is specified', function () {
182
+ var _a = setUp({ selectedEdge: 'hcp->hca' }), graph = _a.graph, result = _a.result;
183
+ var edgeReducer = getEdgeReducer();
184
+ expect(edgeReducer('hcp->hca', graph.getEdgeAttributes('hcp->hca'))).toEqual(__assign(__assign({}, defaultEdgeStyle), { label: '1', color: SELECTED_EDGE_COLOR, selected: true }));
185
+ expect(edgeReducer('hca->gpo', graph.getEdgeAttributes('hca->gpo'))).toEqual(__assign(__assign({}, defaultEdgeStyle), { label: '2', color: INACTIVE_EDGE_COLOR, labelColor: INACTIVE_LABEL_COLOR }));
186
+ expect(edgeReducer('hcp->prescriptions', graph.getEdgeAttributes('hcp->prescriptions'))).toEqual(__assign(__assign({}, defaultEdgeStyle), { type: 'dashed', color: INACTIVE_EDGE_COLOR, labelColor: INACTIVE_LABEL_COLOR }));
187
+ expect(result.error).toBeUndefined();
188
+ });
189
+ });
190
+ });
@@ -0,0 +1,10 @@
1
+ import Graph from 'graphology';
2
+ export declare const CUSTOM_EDGE_LABELS_CANVAS_NAME = "customEdgeLabels";
3
+ export declare const EDGE_DOTS_CANVAS_NAME = "edgeDots";
4
+ export declare const HOVERS_CUSTOM_EDGE_LABELS_CANVAS_NAME = "customEdgeLabelsHovers";
5
+ type Props = {
6
+ graph: Graph;
7
+ onEdgeLabelClick: (edgeId: string, event: MouseEvent) => void;
8
+ };
9
+ export declare const useEdgeLabelsRenderer: ({ graph, onEdgeLabelClick }: Props) => string;
10
+ export {};
@@ -0,0 +1,167 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { useEffect, useState, useRef, useCallback } from 'react';
13
+ import { useRegisterEvents, useSigma } from '@react-sigma/core';
14
+ import { useSigmaCustomRenderers } from '../../hooks/useSigmaCustomRenderers';
15
+ import { DataModelGraphNodeType } from '../../types/graphDataTypes';
16
+ import { drawLabel } from '../../rendering/canvas/label';
17
+ import { getCanvasMousePos } from '../../rendering/canvas/utils';
18
+ import { getEdgeCenter } from '../helpers/edgeLabelHelpers';
19
+ export var CUSTOM_EDGE_LABELS_CANVAS_NAME = 'customEdgeLabels';
20
+ export var EDGE_DOTS_CANVAS_NAME = 'edgeDots';
21
+ export var HOVERS_CUSTOM_EDGE_LABELS_CANVAS_NAME = 'customEdgeLabelsHovers';
22
+ export var useEdgeLabelsRenderer = function (_a) {
23
+ var graph = _a.graph, onEdgeLabelClick = _a.onEdgeLabelClick;
24
+ var sigma = useSigma();
25
+ var settings = sigma.getSettings();
26
+ var registerEvents = useRegisterEvents();
27
+ var _b = useSigmaCustomRenderers(), addCustomRenderers = _b.addRenderers, canvasesRef = _b.canvasesRef;
28
+ var _c = canvasesRef.current, _d = CUSTOM_EDGE_LABELS_CANVAS_NAME, canvas = _c[_d];
29
+ var edgeLabelsPathsMap = useRef({});
30
+ var _e = useState(), hoveredEdgeLabel = _e[0], setHoveredEdgeLabel = _e[1];
31
+ var _f = useState(false), canvasIsAdded = _f[0], setCanvasIsAdded = _f[1];
32
+ var shouldRenderLabels = useCallback(function (edgeId, sourceId, targetId) {
33
+ var edgeDisplayData = sigma.getEdgeDisplayData(edgeId);
34
+ var sourceDisplayData = sigma.getNodeDisplayData(sourceId);
35
+ var targetDisplayData = sigma.getNodeDisplayData(targetId);
36
+ var relationEdge = [sourceDisplayData.nodeType, targetDisplayData.nodeType].every(function (type) { return type === DataModelGraphNodeType.entityType; });
37
+ return relationEdge && !edgeDisplayData.hidden;
38
+ }, [sigma]);
39
+ var drawEdgeLabel = useCallback(function (context, edgeId, sourceId, targetId) {
40
+ delete edgeLabelsPathsMap.current[edgeId];
41
+ var edgeDisplayData = sigma.getEdgeDisplayData(edgeId);
42
+ if (shouldRenderLabels(edgeId, sourceId, targetId)) {
43
+ var isHovered = hoveredEdgeLabel === edgeId;
44
+ var isSelected = edgeDisplayData.selected;
45
+ var fontScale = isHovered ? 1.2 : 1;
46
+ var _a = getEdgeCenter(edgeId, sourceId, targetId, sigma), x = _a.x, y = _a.y;
47
+ var path = drawLabel(context, {
48
+ label: edgeDisplayData.label,
49
+ labelColor: edgeDisplayData.labelColor,
50
+ x: x,
51
+ y: y,
52
+ size: sigma.scaleSize(4)
53
+ }, __assign(__assign({}, settings), { labelSize: settings.labelSize * fontScale }), {
54
+ backgroundColor: "rgba(250, 250, 250, ".concat(isSelected || isHovered ? '1' : '0.9', ")"),
55
+ borderColor: isSelected ? '#0072CE' : undefined
56
+ });
57
+ edgeLabelsPathsMap.current[edgeId] = path;
58
+ }
59
+ },
60
+ // eslint-disable-next-line react-hooks/exhaustive-deps
61
+ [sigma, hoveredEdgeLabel, shouldRenderLabels]);
62
+ var drawEdgeDot = useCallback(function (context, edgeId, sourceId, targetId) {
63
+ var edgeDisplayData = sigma.getEdgeDisplayData(edgeId);
64
+ if (shouldRenderLabels(edgeId, sourceId, targetId)) {
65
+ var isHovered = hoveredEdgeLabel === edgeId;
66
+ var isSelected = edgeDisplayData.selected;
67
+ var dotScale = isHovered || isSelected ? 1.4 : 1;
68
+ var circleRadius = sigma.scaleSize(2.5 * dotScale);
69
+ var _a = getEdgeCenter(edgeId, sourceId, targetId, sigma), x = _a.x, y = _a.y;
70
+ context.beginPath();
71
+ context.arc(x, y, circleRadius, 0, Math.PI * 2);
72
+ context.fillStyle = edgeDisplayData.color;
73
+ context.fill();
74
+ }
75
+ }, [sigma, hoveredEdgeLabel, shouldRenderLabels]);
76
+ useEffect(function () {
77
+ var timer;
78
+ var checkCanvas = function () {
79
+ var _a = canvasesRef.current, _b = CUSTOM_EDGE_LABELS_CANVAS_NAME, canvas = _a[_b];
80
+ if (canvas) {
81
+ setCanvasIsAdded(true);
82
+ }
83
+ else {
84
+ timer = setTimeout(checkCanvas, 100);
85
+ }
86
+ };
87
+ checkCanvas();
88
+ return function () {
89
+ clearTimeout(timer);
90
+ };
91
+ }, [canvasesRef]);
92
+ useEffect(function () {
93
+ registerEvents({
94
+ click: function (event) {
95
+ if (hoveredEdgeLabel) {
96
+ onEdgeLabelClick(hoveredEdgeLabel, event.original);
97
+ setHoveredEdgeLabel(null);
98
+ }
99
+ },
100
+ mousemove: function (event) {
101
+ if (!canvas)
102
+ return;
103
+ var context = canvas.context, canvasElement = canvas.canvasElement;
104
+ var _a = getCanvasMousePos(canvasElement, event.original), x = _a.x, y = _a.y;
105
+ var hoveredEdgeLabel = null;
106
+ for (var id in edgeLabelsPathsMap.current) {
107
+ var path = edgeLabelsPathsMap.current[id];
108
+ if (context.isPointInPath(path, x, y)) {
109
+ hoveredEdgeLabel = id;
110
+ break;
111
+ }
112
+ else {
113
+ hoveredEdgeLabel = null;
114
+ }
115
+ }
116
+ setHoveredEdgeLabel(hoveredEdgeLabel);
117
+ }
118
+ });
119
+ }, [sigma, canvas, registerEvents, hoveredEdgeLabel, onEdgeLabelClick, canvasIsAdded]);
120
+ useEffect(function () {
121
+ var _a;
122
+ addCustomRenderers((_a = {},
123
+ _a[CUSTOM_EDGE_LABELS_CANVAS_NAME] = {
124
+ renderer: function (context) {
125
+ graph.forEachEdge(function (edgeId, _edgeData, sourceId, targetId) {
126
+ if (edgeId !== hoveredEdgeLabel) {
127
+ drawEdgeLabel(context, edgeId, sourceId, targetId);
128
+ }
129
+ });
130
+ },
131
+ insertBefore: 'labels'
132
+ },
133
+ _a));
134
+ }, [addCustomRenderers, graph, drawEdgeLabel, hoveredEdgeLabel]);
135
+ useEffect(function () {
136
+ var _a;
137
+ addCustomRenderers((_a = {},
138
+ _a[EDGE_DOTS_CANVAS_NAME] = {
139
+ renderer: function (context) {
140
+ graph.forEachEdge(function (edgeId, _edgeData, sourceId, targetId) {
141
+ if (edgeId !== hoveredEdgeLabel) {
142
+ drawEdgeDot(context, edgeId, sourceId, targetId);
143
+ }
144
+ });
145
+ },
146
+ insertBefore: 'edgeLabels'
147
+ },
148
+ _a));
149
+ }, [addCustomRenderers, graph, drawEdgeDot, hoveredEdgeLabel]);
150
+ useEffect(function () {
151
+ var _a;
152
+ addCustomRenderers((_a = {},
153
+ _a[HOVERS_CUSTOM_EDGE_LABELS_CANVAS_NAME] = {
154
+ renderer: function (context) {
155
+ graph.forEachEdge(function (edgeId, _edgeData, sourceId, targetId) {
156
+ if (edgeId === hoveredEdgeLabel) {
157
+ drawEdgeLabel(context, edgeId, sourceId, targetId);
158
+ drawEdgeDot(context, edgeId, sourceId, targetId);
159
+ }
160
+ });
161
+ },
162
+ insertBefore: 'hovers'
163
+ },
164
+ _a));
165
+ }, [addCustomRenderers, graph, drawEdgeLabel, drawEdgeDot, hoveredEdgeLabel]);
166
+ return hoveredEdgeLabel;
167
+ };
@@ -0,0 +1,174 @@
1
+ var __assign = (this && this.__assign) || function () {
2
+ __assign = Object.assign || function(t) {
3
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
4
+ s = arguments[i];
5
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
6
+ t[p] = s[p];
7
+ }
8
+ return t;
9
+ };
10
+ return __assign.apply(this, arguments);
11
+ };
12
+ import { renderHook, act } from '@testing-library/react-hooks';
13
+ import { last } from 'ramda';
14
+ import { useRegisterEvents, useSigma } from '@react-sigma/core';
15
+ import { useSigmaCustomRenderers } from '../../hooks/useSigmaCustomRenderers';
16
+ import { drawLabel } from '../../rendering/canvas/label';
17
+ import { getCanvasMousePos } from '../../rendering/canvas/utils';
18
+ import { CUSTOM_EDGE_LABELS_CANVAS_NAME, EDGE_DOTS_CANVAS_NAME, HOVERS_CUSTOM_EDGE_LABELS_CANVAS_NAME, useEdgeLabelsRenderer } from './useEdgeLabelsRenderer';
19
+ import { createDefaultGraph } from './defaultGraph.test-data';
20
+ jest.mock('@react-sigma/core');
21
+ jest.mock('../../hooks/useSigmaCustomRenderers', function () { return ({
22
+ useSigmaCustomRenderers: jest.fn()
23
+ }); });
24
+ jest.mock('../../rendering/canvas/utils', function () { return ({
25
+ getCanvasMousePos: jest.fn()
26
+ }); });
27
+ jest.mock('../../rendering/canvas/label', function () { return ({
28
+ drawLabel: jest.fn().mockImplementation(jest.requireActual('../../rendering/canvas/label').drawLabel)
29
+ }); });
30
+ describe('useEdgeLabelsRenderer tests', function () {
31
+ var graph;
32
+ var setUp = function (props) {
33
+ graph = (props === null || props === void 0 ? void 0 : props.graph) || createDefaultGraph();
34
+ return renderHook(useEdgeLabelsRenderer, {
35
+ initialProps: __assign({ graph: graph, onEdgeLabelClick: jest.fn() }, props)
36
+ });
37
+ };
38
+ var getEdgeDisplayData = jest.fn().mockImplementation(function (edgeId) { return graph.getEdgeAttributes(edgeId); });
39
+ var getNodeDisplayData = jest.fn().mockImplementation(function (nodeId) { return graph.getNodeAttributes(nodeId); });
40
+ var renderers = {};
41
+ var addRenderers = function (rendererObject) { return Object.assign(renderers, rendererObject); };
42
+ var registerEvents = jest.fn();
43
+ var canvas = document.createElement('canvas');
44
+ var canvasContext = canvas.getContext('2d');
45
+ beforeEach(function () {
46
+ var _a;
47
+ useSigmaCustomRenderers.mockReturnValue({
48
+ addRenderers: addRenderers,
49
+ canvasesRef: {
50
+ current: (_a = {},
51
+ _a[CUSTOM_EDGE_LABELS_CANVAS_NAME] = {
52
+ canvasElement: canvas,
53
+ context: canvasContext
54
+ },
55
+ _a)
56
+ }
57
+ });
58
+ useSigma.mockReturnValue({
59
+ getEdgeDisplayData: getEdgeDisplayData,
60
+ getNodeDisplayData: getNodeDisplayData,
61
+ framedGraphToViewport: function (x) { return x; },
62
+ getSettings: function () { return ({
63
+ labelSize: 12,
64
+ labelColor: 'black'
65
+ }); },
66
+ scaleSize: function (x) { return x; }
67
+ });
68
+ useRegisterEvents.mockReturnValue(registerEvents);
69
+ getCanvasMousePos.mockImplementation(function (_canvas, event) { return ({ x: event.clientX, y: event.clientY }); });
70
+ });
71
+ afterEach(function () {
72
+ jest.clearAllMocks();
73
+ });
74
+ var getEdgesLabelsRenderer = function () { return renderers[CUSTOM_EDGE_LABELS_CANVAS_NAME]; };
75
+ var getDotsRenderer = function () { return renderers[EDGE_DOTS_CANVAS_NAME]; };
76
+ var getHoversRenderer = function () { return renderers[HOVERS_CUSTOM_EDGE_LABELS_CANVAS_NAME]; };
77
+ var getMousemove = function () { return last(registerEvents.mock.calls)[0].mousemove; };
78
+ var getClick = function () { return last(registerEvents.mock.calls)[0].click; };
79
+ var getCanvasContextEventTypes = function (context) {
80
+ return context._events.map(function (event) { return event.type; });
81
+ };
82
+ it('should call drawLabel with correct params', function () {
83
+ setUp();
84
+ var renderer = getEdgesLabelsRenderer().renderer;
85
+ act(function () {
86
+ renderer(canvasContext);
87
+ });
88
+ expect(drawLabel).toHaveBeenCalledTimes(2);
89
+ expect(drawLabel).toHaveBeenCalledWith(canvasContext, { label: '1', size: 4, x: 150, y: 100 }, { labelColor: 'black', labelSize: 12 }, { backgroundColor: 'rgba(250, 250, 250, 0.9)' });
90
+ expect(drawLabel).toHaveBeenCalledWith(canvasContext, { label: '2', size: 4, x: 250, y: 100 }, { labelColor: 'black', labelSize: 12 }, { backgroundColor: 'rgba(250, 250, 250, 0.9)' });
91
+ });
92
+ it('should draw dot in the center of edge', function () {
93
+ setUp();
94
+ var canvas = document.createElement('canvas');
95
+ var canvasContext = canvas.getContext('2d');
96
+ var renderer = getDotsRenderer().renderer;
97
+ act(function () {
98
+ renderer(canvasContext);
99
+ });
100
+ expect(getCanvasContextEventTypes(canvasContext)).toEqual([
101
+ 'beginPath',
102
+ 'arc',
103
+ 'fill',
104
+ 'beginPath',
105
+ 'arc',
106
+ 'fill'
107
+ ]);
108
+ expect(canvasContext.arc).toHaveBeenCalledWith(150, 100, 2.5, 0, 2 * Math.PI);
109
+ expect(canvasContext.arc).toHaveBeenCalledWith(250, 100, 2.5, 0, 2 * Math.PI);
110
+ });
111
+ it('should correctly draw a hover state of edge', function () {
112
+ setUp();
113
+ var hoversCanvas = document.createElement('canvas');
114
+ var hoversCanvasContext = hoversCanvas.getContext('2d');
115
+ var edgeLabelsRenderer = getEdgesLabelsRenderer().renderer;
116
+ act(function () {
117
+ edgeLabelsRenderer(canvasContext);
118
+ var mousemove = getMousemove();
119
+ var event = { original: { clientX: 170, clientY: 105 } };
120
+ canvasContext.isPointInPath.mockReturnValueOnce(true);
121
+ mousemove(event);
122
+ });
123
+ drawLabel.mockClear();
124
+ act(function () {
125
+ var hoversRenderer = getHoversRenderer().renderer;
126
+ hoversRenderer(hoversCanvasContext);
127
+ });
128
+ expect(getCanvasContextEventTypes(hoversCanvasContext)).toEqual(expect.arrayContaining(['beginPath', 'arc', 'fill']));
129
+ expect(hoversCanvasContext.arc).toBeCalledTimes(1);
130
+ expect(hoversCanvasContext.arc).toHaveBeenCalledWith(150, 100, 3.5, 0, 2 * Math.PI);
131
+ expect(drawLabel).toBeCalledTimes(1);
132
+ expect(drawLabel).toHaveBeenCalledWith(hoversCanvasContext, { label: '1', size: 4, x: 150, y: 100 }, { labelColor: 'black', labelSize: 12 * 1.2 }, { backgroundColor: 'rgba(250, 250, 250, 1)' });
133
+ });
134
+ it('mousemove event should work correctly if cursor over edge caption', function () {
135
+ var onEdgeLabelClick = jest.fn();
136
+ var result = setUp({ onEdgeLabelClick: onEdgeLabelClick }).result;
137
+ var renderer = getEdgesLabelsRenderer().renderer;
138
+ expect(result.current).toBe(undefined);
139
+ act(function () {
140
+ renderer(canvasContext);
141
+ var mousemove = getMousemove();
142
+ var event = { original: { clientX: 170, clientY: 105 } };
143
+ canvasContext.isPointInPath.mockReturnValueOnce(true);
144
+ mousemove(event);
145
+ });
146
+ expect(result.current).toBe('hcp->hca');
147
+ expect(onEdgeLabelClick).not.toHaveBeenCalled();
148
+ act(function () {
149
+ var click = getClick();
150
+ click({ original: { clientX: 170, clientY: 105 } });
151
+ });
152
+ expect(onEdgeLabelClick).toHaveBeenCalledWith('hcp->hca', { clientX: 170, clientY: 105 });
153
+ });
154
+ it('mousemove event should work correctly if cursor not over edge caption', function () {
155
+ var onEdgeLabelClick = jest.fn();
156
+ var result = setUp({ onEdgeLabelClick: onEdgeLabelClick }).result;
157
+ var renderer = getEdgesLabelsRenderer().renderer;
158
+ expect(result.current).toBe(undefined);
159
+ act(function () {
160
+ renderer(canvasContext);
161
+ var mousemove = getMousemove();
162
+ var event = { original: { clientX: 0, clientY: 0 } };
163
+ canvasContext.isPointInPath.mockReturnValueOnce(false);
164
+ mousemove(event);
165
+ });
166
+ expect(result.current).toBe(null);
167
+ expect(onEdgeLabelClick).not.toHaveBeenCalled();
168
+ act(function () {
169
+ var click = getClick();
170
+ click({ original: { clientX: 0, clientY: 0 } });
171
+ });
172
+ expect(onEdgeLabelClick).not.toHaveBeenCalled();
173
+ });
174
+ });
@@ -0,0 +1,8 @@
1
+ import Graph from 'graphology';
2
+ export declare const FAKE_CENTER_NODE_ID = "fakeCenterNodeId";
3
+ type Props = {
4
+ graph: Graph;
5
+ timeout?: number;
6
+ };
7
+ export declare const useFakeCenterNode: ({ graph, timeout }: Props) => void;
8
+ export {};
@@ -0,0 +1,32 @@
1
+ import { useEffect } from 'react';
2
+ import { useSigma } from '@react-sigma/core';
3
+ import { DataModelGraphNodeType } from '../../types/graphDataTypes';
4
+ export var FAKE_CENTER_NODE_ID = 'fakeCenterNodeId';
5
+ export var useFakeCenterNode = function (_a) {
6
+ var graph = _a.graph, timeout = _a.timeout;
7
+ var sigma = useSigma();
8
+ useEffect(function () {
9
+ graph.addNode(FAKE_CENTER_NODE_ID, {
10
+ type: 'circle',
11
+ hidden: true,
12
+ size: 0,
13
+ x: 1,
14
+ y: 1
15
+ });
16
+ graph.forEachNode(function (node) {
17
+ var nodeData = graph.getNodeAttributes(node);
18
+ if (nodeData.nodeType === DataModelGraphNodeType.entityType) {
19
+ graph.addEdge(node, FAKE_CENTER_NODE_ID, {
20
+ hidden: true
21
+ });
22
+ }
23
+ });
24
+ var timer = setTimeout(function () {
25
+ graph.dropNode(FAKE_CENTER_NODE_ID);
26
+ sigma.getGraph().dropNode(FAKE_CENTER_NODE_ID);
27
+ }, timeout);
28
+ return function () {
29
+ clearTimeout(timer);
30
+ };
31
+ }, [sigma, graph, timeout]);
32
+ };
@@ -0,0 +1,35 @@
1
+ import { renderHook, act } from '@testing-library/react-hooks';
2
+ import { useSigma } from '@react-sigma/core';
3
+ import { FAKE_CENTER_NODE_ID, useFakeCenterNode } from './useFakeCenterNode';
4
+ import { createDefaultGraph } from './defaultGraph.test-data';
5
+ jest.mock('@react-sigma/core', function () { return ({
6
+ useSigma: jest.fn()
7
+ }); });
8
+ describe('useFakeCenterNode tests', function () {
9
+ var graph, sigmaGraph;
10
+ var setUp = function () {
11
+ graph = createDefaultGraph();
12
+ return renderHook(useFakeCenterNode, {
13
+ initialProps: { graph: graph, timeout: 1000 }
14
+ });
15
+ };
16
+ var sigma = {
17
+ getGraph: jest.fn(function () { return sigmaGraph; })
18
+ };
19
+ beforeEach(function () {
20
+ useSigma.mockReturnValue(sigma);
21
+ });
22
+ afterEach(function () {
23
+ jest.clearAllMocks();
24
+ });
25
+ it('should add fake center node and edges on mount and drop it after timeout', function () {
26
+ jest.useFakeTimers();
27
+ setUp();
28
+ expect(graph.hasNode(FAKE_CENTER_NODE_ID)).toBe(true);
29
+ sigmaGraph = graph.copy();
30
+ act(function () {
31
+ jest.advanceTimersByTime(1000);
32
+ });
33
+ expect(graph.hasNode(FAKE_CENTER_NODE_ID)).toBe(false);
34
+ });
35
+ });
@@ -0,0 +1,2 @@
1
+ import Graph from 'graphology';
2
+ export declare const useSelectedNodeRenderer: (graph: Graph) => void;