@darajs/ui-causal-graph-editor 1.0.0-a.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.
Files changed (338) hide show
  1. package/LICENSE +201 -0
  2. package/dist/graph-viewer/causal-graph-editor.d.ts +44 -0
  3. package/dist/graph-viewer/causal-graph-editor.d.ts.map +1 -0
  4. package/dist/graph-viewer/causal-graph-editor.js +357 -0
  5. package/dist/graph-viewer/causal-graph-editor.js.map +1 -0
  6. package/dist/graph-viewer/utils/use-iterate-edges.d.ts +32 -0
  7. package/dist/graph-viewer/utils/use-iterate-edges.d.ts.map +1 -0
  8. package/dist/graph-viewer/utils/use-iterate-edges.js +34 -0
  9. package/dist/graph-viewer/utils/use-iterate-edges.js.map +1 -0
  10. package/dist/graph-viewer/utils/use-iterate-nodes.d.ts +32 -0
  11. package/dist/graph-viewer/utils/use-iterate-nodes.d.ts.map +1 -0
  12. package/dist/graph-viewer/utils/use-iterate-nodes.js +30 -0
  13. package/dist/graph-viewer/utils/use-iterate-nodes.js.map +1 -0
  14. package/dist/index.d.ts +22 -0
  15. package/dist/index.d.ts.map +1 -0
  16. package/dist/index.js +21 -0
  17. package/dist/index.js.map +1 -0
  18. package/dist/jest-setup.d.ts +18 -0
  19. package/dist/jest-setup.d.ts.map +1 -0
  20. package/dist/jest-setup.js +18 -0
  21. package/dist/jest-setup.js.map +1 -0
  22. package/dist/node-hierarchy-builder/index.d.ts +19 -0
  23. package/dist/node-hierarchy-builder/index.d.ts.map +1 -0
  24. package/dist/node-hierarchy-builder/index.js +18 -0
  25. package/dist/node-hierarchy-builder/index.js.map +1 -0
  26. package/dist/node-hierarchy-builder/layer-divider.d.ts +15 -0
  27. package/dist/node-hierarchy-builder/layer-divider.d.ts.map +1 -0
  28. package/dist/node-hierarchy-builder/layer-divider.js +122 -0
  29. package/dist/node-hierarchy-builder/layer-divider.js.map +1 -0
  30. package/dist/node-hierarchy-builder/layer-label-editor.d.ts +24 -0
  31. package/dist/node-hierarchy-builder/layer-label-editor.d.ts.map +1 -0
  32. package/dist/node-hierarchy-builder/layer-label-editor.js +93 -0
  33. package/dist/node-hierarchy-builder/layer-label-editor.js.map +1 -0
  34. package/dist/node-hierarchy-builder/layer.d.ts +35 -0
  35. package/dist/node-hierarchy-builder/layer.d.ts.map +1 -0
  36. package/dist/node-hierarchy-builder/layer.js +114 -0
  37. package/dist/node-hierarchy-builder/layer.js.map +1 -0
  38. package/dist/node-hierarchy-builder/node-hierarchy-builder.d.ts +27 -0
  39. package/dist/node-hierarchy-builder/node-hierarchy-builder.d.ts.map +1 -0
  40. package/dist/node-hierarchy-builder/node-hierarchy-builder.js +190 -0
  41. package/dist/node-hierarchy-builder/node-hierarchy-builder.js.map +1 -0
  42. package/dist/node-hierarchy-builder/node.d.ts +21 -0
  43. package/dist/node-hierarchy-builder/node.d.ts.map +1 -0
  44. package/dist/node-hierarchy-builder/node.js +90 -0
  45. package/dist/node-hierarchy-builder/node.js.map +1 -0
  46. package/dist/node-hierarchy-builder/shared.d.ts +93 -0
  47. package/dist/node-hierarchy-builder/shared.d.ts.map +1 -0
  48. package/dist/node-hierarchy-builder/shared.js +88 -0
  49. package/dist/node-hierarchy-builder/shared.js.map +1 -0
  50. package/dist/shared/causal-graph-store.d.ts +107 -0
  51. package/dist/shared/causal-graph-store.d.ts.map +1 -0
  52. package/dist/shared/causal-graph-store.js +142 -0
  53. package/dist/shared/causal-graph-store.js.map +1 -0
  54. package/dist/shared/editor-overlay/buttons/add-node-button.d.ts +7 -0
  55. package/dist/shared/editor-overlay/buttons/add-node-button.d.ts.map +1 -0
  56. package/dist/shared/editor-overlay/buttons/add-node-button.js +31 -0
  57. package/dist/shared/editor-overlay/buttons/add-node-button.js.map +1 -0
  58. package/dist/shared/editor-overlay/buttons/center-graph-button.d.ts +7 -0
  59. package/dist/shared/editor-overlay/buttons/center-graph-button.d.ts.map +1 -0
  60. package/dist/shared/editor-overlay/buttons/center-graph-button.js +32 -0
  61. package/dist/shared/editor-overlay/buttons/center-graph-button.js.map +1 -0
  62. package/dist/shared/editor-overlay/buttons/drag-mode-button.d.ts +27 -0
  63. package/dist/shared/editor-overlay/buttons/drag-mode-button.d.ts.map +1 -0
  64. package/dist/shared/editor-overlay/buttons/drag-mode-button.js +35 -0
  65. package/dist/shared/editor-overlay/buttons/drag-mode-button.js.map +1 -0
  66. package/dist/shared/editor-overlay/buttons/index.d.ts +21 -0
  67. package/dist/shared/editor-overlay/buttons/index.d.ts.map +1 -0
  68. package/dist/shared/editor-overlay/buttons/index.js +21 -0
  69. package/dist/shared/editor-overlay/buttons/index.js.map +1 -0
  70. package/dist/shared/editor-overlay/buttons/recalculate-layout-button.d.ts +7 -0
  71. package/dist/shared/editor-overlay/buttons/recalculate-layout-button.d.ts.map +1 -0
  72. package/dist/shared/editor-overlay/buttons/recalculate-layout-button.js +28 -0
  73. package/dist/shared/editor-overlay/buttons/recalculate-layout-button.js.map +1 -0
  74. package/dist/shared/editor-overlay/floating-elements.d.ts +29 -0
  75. package/dist/shared/editor-overlay/floating-elements.d.ts.map +1 -0
  76. package/dist/shared/editor-overlay/floating-elements.js +17 -0
  77. package/dist/shared/editor-overlay/floating-elements.js.map +1 -0
  78. package/dist/shared/editor-overlay/index.d.ts +22 -0
  79. package/dist/shared/editor-overlay/index.d.ts.map +1 -0
  80. package/dist/shared/editor-overlay/index.js +22 -0
  81. package/dist/shared/editor-overlay/index.js.map +1 -0
  82. package/dist/shared/editor-overlay/legend/index.d.ts +19 -0
  83. package/dist/shared/editor-overlay/legend/index.d.ts.map +1 -0
  84. package/dist/shared/editor-overlay/legend/index.js +19 -0
  85. package/dist/shared/editor-overlay/legend/index.js.map +1 -0
  86. package/dist/shared/editor-overlay/legend/legend-data.d.ts +34 -0
  87. package/dist/shared/editor-overlay/legend/legend-data.d.ts.map +1 -0
  88. package/dist/shared/editor-overlay/legend/legend-data.js +41 -0
  89. package/dist/shared/editor-overlay/legend/legend-data.js.map +1 -0
  90. package/dist/shared/editor-overlay/legend/legend-list.d.ts +6 -0
  91. package/dist/shared/editor-overlay/legend/legend-list.d.ts.map +1 -0
  92. package/dist/shared/editor-overlay/legend/legend-list.js +96 -0
  93. package/dist/shared/editor-overlay/legend/legend-list.js.map +1 -0
  94. package/dist/shared/editor-overlay/legend/legend.d.ts +7 -0
  95. package/dist/shared/editor-overlay/legend/legend.d.ts.map +1 -0
  96. package/dist/shared/editor-overlay/legend/legend.js +80 -0
  97. package/dist/shared/editor-overlay/legend/legend.js.map +1 -0
  98. package/dist/shared/editor-overlay/overlay.d.ts +35 -0
  99. package/dist/shared/editor-overlay/overlay.d.ts.map +1 -0
  100. package/dist/shared/editor-overlay/overlay.js +41 -0
  101. package/dist/shared/editor-overlay/overlay.js.map +1 -0
  102. package/dist/shared/editor-overlay/panel-content/edge/edge-editor.d.ts +8 -0
  103. package/dist/shared/editor-overlay/panel-content/edge/edge-editor.d.ts.map +1 -0
  104. package/dist/shared/editor-overlay/panel-content/edge/edge-editor.js +40 -0
  105. package/dist/shared/editor-overlay/panel-content/edge/edge-editor.js.map +1 -0
  106. package/dist/shared/editor-overlay/panel-content/edge/edge-info-content.d.ts +22 -0
  107. package/dist/shared/editor-overlay/panel-content/edge/edge-info-content.d.ts.map +1 -0
  108. package/dist/shared/editor-overlay/panel-content/edge/edge-info-content.js +36 -0
  109. package/dist/shared/editor-overlay/panel-content/edge/edge-info-content.js.map +1 -0
  110. package/dist/shared/editor-overlay/panel-content/edge/editor-props.d.ts +35 -0
  111. package/dist/shared/editor-overlay/panel-content/edge/editor-props.d.ts.map +1 -0
  112. package/dist/shared/editor-overlay/panel-content/edge/editor-props.js +2 -0
  113. package/dist/shared/editor-overlay/panel-content/edge/editor-props.js.map +1 -0
  114. package/dist/shared/editor-overlay/panel-content/edge/encoder-editor.d.ts +23 -0
  115. package/dist/shared/editor-overlay/panel-content/edge/encoder-editor.d.ts.map +1 -0
  116. package/dist/shared/editor-overlay/panel-content/edge/encoder-editor.js +10 -0
  117. package/dist/shared/editor-overlay/panel-content/edge/encoder-editor.js.map +1 -0
  118. package/dist/shared/editor-overlay/panel-content/edge/index.d.ts +18 -0
  119. package/dist/shared/editor-overlay/panel-content/edge/index.d.ts.map +1 -0
  120. package/dist/shared/editor-overlay/panel-content/edge/index.js +18 -0
  121. package/dist/shared/editor-overlay/panel-content/edge/index.js.map +1 -0
  122. package/dist/shared/editor-overlay/panel-content/edge/pag-editor.d.ts +23 -0
  123. package/dist/shared/editor-overlay/panel-content/edge/pag-editor.d.ts.map +1 -0
  124. package/dist/shared/editor-overlay/panel-content/edge/pag-editor.js +10 -0
  125. package/dist/shared/editor-overlay/panel-content/edge/pag-editor.js.map +1 -0
  126. package/dist/shared/editor-overlay/panel-content/edge/resolver-editor.d.ts +7 -0
  127. package/dist/shared/editor-overlay/panel-content/edge/resolver-editor.d.ts.map +1 -0
  128. package/dist/shared/editor-overlay/panel-content/edge/resolver-editor.js +31 -0
  129. package/dist/shared/editor-overlay/panel-content/edge/resolver-editor.js.map +1 -0
  130. package/dist/shared/editor-overlay/panel-content/edge/sections/constraint-editor.d.ts +27 -0
  131. package/dist/shared/editor-overlay/panel-content/edge/sections/constraint-editor.d.ts.map +1 -0
  132. package/dist/shared/editor-overlay/panel-content/edge/sections/constraint-editor.js +53 -0
  133. package/dist/shared/editor-overlay/panel-content/edge/sections/constraint-editor.js.map +1 -0
  134. package/dist/shared/editor-overlay/panel-content/edge/sections/description-editor.d.ts +15 -0
  135. package/dist/shared/editor-overlay/panel-content/edge/sections/description-editor.d.ts.map +1 -0
  136. package/dist/shared/editor-overlay/panel-content/edge/sections/description-editor.js +60 -0
  137. package/dist/shared/editor-overlay/panel-content/edge/sections/description-editor.js.map +1 -0
  138. package/dist/shared/editor-overlay/panel-content/edge/sections/direction-editor.d.ts +21 -0
  139. package/dist/shared/editor-overlay/panel-content/edge/sections/direction-editor.d.ts.map +1 -0
  140. package/dist/shared/editor-overlay/panel-content/edge/sections/direction-editor.js +90 -0
  141. package/dist/shared/editor-overlay/panel-content/edge/sections/direction-editor.js.map +1 -0
  142. package/dist/shared/editor-overlay/panel-content/edge/sections/edge-type-editor.d.ts +17 -0
  143. package/dist/shared/editor-overlay/panel-content/edge/sections/edge-type-editor.d.ts.map +1 -0
  144. package/dist/shared/editor-overlay/panel-content/edge/sections/edge-type-editor.js +61 -0
  145. package/dist/shared/editor-overlay/panel-content/edge/sections/edge-type-editor.js.map +1 -0
  146. package/dist/shared/editor-overlay/panel-content/edge/sections/index.d.ts +19 -0
  147. package/dist/shared/editor-overlay/panel-content/edge/sections/index.d.ts.map +1 -0
  148. package/dist/shared/editor-overlay/panel-content/edge/sections/index.js +19 -0
  149. package/dist/shared/editor-overlay/panel-content/edge/sections/index.js.map +1 -0
  150. package/dist/shared/editor-overlay/panel-content/index.d.ts +20 -0
  151. package/dist/shared/editor-overlay/panel-content/index.d.ts.map +1 -0
  152. package/dist/shared/editor-overlay/panel-content/index.js +20 -0
  153. package/dist/shared/editor-overlay/panel-content/index.js.map +1 -0
  154. package/dist/shared/editor-overlay/panel-content/node/index.d.ts +18 -0
  155. package/dist/shared/editor-overlay/panel-content/node/index.d.ts.map +1 -0
  156. package/dist/shared/editor-overlay/panel-content/node/index.js +18 -0
  157. package/dist/shared/editor-overlay/panel-content/node/index.js.map +1 -0
  158. package/dist/shared/editor-overlay/panel-content/node/label-editor.d.ts +11 -0
  159. package/dist/shared/editor-overlay/panel-content/node/label-editor.d.ts.map +1 -0
  160. package/dist/shared/editor-overlay/panel-content/node/label-editor.js +89 -0
  161. package/dist/shared/editor-overlay/panel-content/node/label-editor.js.map +1 -0
  162. package/dist/shared/editor-overlay/panel-content/node/node-info-content.d.ts +32 -0
  163. package/dist/shared/editor-overlay/panel-content/node/node-info-content.d.ts.map +1 -0
  164. package/dist/shared/editor-overlay/panel-content/node/node-info-content.js +12 -0
  165. package/dist/shared/editor-overlay/panel-content/node/node-info-content.js.map +1 -0
  166. package/dist/shared/editor-overlay/panel-content/panel-content.d.ts +17 -0
  167. package/dist/shared/editor-overlay/panel-content/panel-content.d.ts.map +1 -0
  168. package/dist/shared/editor-overlay/panel-content/panel-content.js +27 -0
  169. package/dist/shared/editor-overlay/panel-content/panel-content.js.map +1 -0
  170. package/dist/shared/editor-overlay/panel-content/panel-title.d.ts +12 -0
  171. package/dist/shared/editor-overlay/panel-content/panel-title.d.ts.map +1 -0
  172. package/dist/shared/editor-overlay/panel-content/panel-title.js +48 -0
  173. package/dist/shared/editor-overlay/panel-content/panel-title.js.map +1 -0
  174. package/dist/shared/editor-overlay/panel-content/styled.d.ts +9 -0
  175. package/dist/shared/editor-overlay/panel-content/styled.d.ts.map +1 -0
  176. package/dist/shared/editor-overlay/panel-content/styled.js +43 -0
  177. package/dist/shared/editor-overlay/panel-content/styled.js.map +1 -0
  178. package/dist/shared/editor-overlay/positional-divs.d.ts +14 -0
  179. package/dist/shared/editor-overlay/positional-divs.d.ts.map +1 -0
  180. package/dist/shared/editor-overlay/positional-divs.js +117 -0
  181. package/dist/shared/editor-overlay/positional-divs.js.map +1 -0
  182. package/dist/shared/editor-overlay/search-bar/index.d.ts +19 -0
  183. package/dist/shared/editor-overlay/search-bar/index.d.ts.map +1 -0
  184. package/dist/shared/editor-overlay/search-bar/index.js +19 -0
  185. package/dist/shared/editor-overlay/search-bar/index.js.map +1 -0
  186. package/dist/shared/editor-overlay/search-bar/search-bar.d.ts +21 -0
  187. package/dist/shared/editor-overlay/search-bar/search-bar.d.ts.map +1 -0
  188. package/dist/shared/editor-overlay/search-bar/search-bar.js +160 -0
  189. package/dist/shared/editor-overlay/search-bar/search-bar.js.map +1 -0
  190. package/dist/shared/editor-overlay/search-bar/use-search.d.ts +32 -0
  191. package/dist/shared/editor-overlay/search-bar/use-search.d.ts.map +1 -0
  192. package/dist/shared/editor-overlay/search-bar/use-search.js +75 -0
  193. package/dist/shared/editor-overlay/search-bar/use-search.js.map +1 -0
  194. package/dist/shared/graph-layout/circular-layout.d.ts +18 -0
  195. package/dist/shared/graph-layout/circular-layout.d.ts.map +1 -0
  196. package/dist/shared/graph-layout/circular-layout.js +38 -0
  197. package/dist/shared/graph-layout/circular-layout.js.map +1 -0
  198. package/dist/shared/graph-layout/common.d.ts +64 -0
  199. package/dist/shared/graph-layout/common.d.ts.map +1 -0
  200. package/dist/shared/graph-layout/common.js +42 -0
  201. package/dist/shared/graph-layout/common.js.map +1 -0
  202. package/dist/shared/graph-layout/custom-layout.d.ts +35 -0
  203. package/dist/shared/graph-layout/custom-layout.d.ts.map +1 -0
  204. package/dist/shared/graph-layout/custom-layout.js +29 -0
  205. package/dist/shared/graph-layout/custom-layout.js.map +1 -0
  206. package/dist/shared/graph-layout/fcose-layout.d.ts +88 -0
  207. package/dist/shared/graph-layout/fcose-layout.d.ts.map +1 -0
  208. package/dist/shared/graph-layout/fcose-layout.js +196 -0
  209. package/dist/shared/graph-layout/fcose-layout.js.map +1 -0
  210. package/dist/shared/graph-layout/force-atlas-layout.d.ts +79 -0
  211. package/dist/shared/graph-layout/force-atlas-layout.d.ts.map +1 -0
  212. package/dist/shared/graph-layout/force-atlas-layout.js +163 -0
  213. package/dist/shared/graph-layout/force-atlas-layout.js.map +1 -0
  214. package/dist/shared/graph-layout/index.d.ts +25 -0
  215. package/dist/shared/graph-layout/index.d.ts.map +1 -0
  216. package/dist/shared/graph-layout/index.js +25 -0
  217. package/dist/shared/graph-layout/index.js.map +1 -0
  218. package/dist/shared/graph-layout/marketing-layout.d.ts +30 -0
  219. package/dist/shared/graph-layout/marketing-layout.d.ts.map +1 -0
  220. package/dist/shared/graph-layout/marketing-layout.js +105 -0
  221. package/dist/shared/graph-layout/marketing-layout.js.map +1 -0
  222. package/dist/shared/graph-layout/planar-layout.d.ts +32 -0
  223. package/dist/shared/graph-layout/planar-layout.d.ts.map +1 -0
  224. package/dist/shared/graph-layout/planar-layout.js +95 -0
  225. package/dist/shared/graph-layout/planar-layout.js.map +1 -0
  226. package/dist/shared/graph-layout/spring-layout.d.ts +56 -0
  227. package/dist/shared/graph-layout/spring-layout.d.ts.map +1 -0
  228. package/dist/shared/graph-layout/spring-layout.js +148 -0
  229. package/dist/shared/graph-layout/spring-layout.js.map +1 -0
  230. package/dist/shared/parsers.d.ts +63 -0
  231. package/dist/shared/parsers.d.ts.map +1 -0
  232. package/dist/shared/parsers.js +176 -0
  233. package/dist/shared/parsers.js.map +1 -0
  234. package/dist/shared/pointer-context.d.ts +21 -0
  235. package/dist/shared/pointer-context.d.ts.map +1 -0
  236. package/dist/shared/pointer-context.js +23 -0
  237. package/dist/shared/pointer-context.js.map +1 -0
  238. package/dist/shared/rendering/background.d.ts +32 -0
  239. package/dist/shared/rendering/background.d.ts.map +1 -0
  240. package/dist/shared/rendering/background.js +91 -0
  241. package/dist/shared/rendering/background.js.map +1 -0
  242. package/dist/shared/rendering/colors.d.ts +27 -0
  243. package/dist/shared/rendering/colors.d.ts.map +1 -0
  244. package/dist/shared/rendering/colors.js +14 -0
  245. package/dist/shared/rendering/colors.js.map +1 -0
  246. package/dist/shared/rendering/edge/curve.d.ts +51 -0
  247. package/dist/shared/rendering/edge/curve.d.ts.map +1 -0
  248. package/dist/shared/rendering/edge/curve.js +122 -0
  249. package/dist/shared/rendering/edge/curve.js.map +1 -0
  250. package/dist/shared/rendering/edge/definitions.d.ts +71 -0
  251. package/dist/shared/rendering/edge/definitions.d.ts.map +1 -0
  252. package/dist/shared/rendering/edge/definitions.js +31 -0
  253. package/dist/shared/rendering/edge/definitions.js.map +1 -0
  254. package/dist/shared/rendering/edge/edge-object.d.ts +93 -0
  255. package/dist/shared/rendering/edge/edge-object.d.ts.map +1 -0
  256. package/dist/shared/rendering/edge/edge-object.js +483 -0
  257. package/dist/shared/rendering/edge/edge-object.js.map +1 -0
  258. package/dist/shared/rendering/edge/index.d.ts +19 -0
  259. package/dist/shared/rendering/edge/index.d.ts.map +1 -0
  260. package/dist/shared/rendering/edge/index.js +19 -0
  261. package/dist/shared/rendering/edge/index.js.map +1 -0
  262. package/dist/shared/rendering/edge/symbols.d.ts +40 -0
  263. package/dist/shared/rendering/edge/symbols.d.ts.map +1 -0
  264. package/dist/shared/rendering/edge/symbols.js +150 -0
  265. package/dist/shared/rendering/edge/symbols.js.map +1 -0
  266. package/dist/shared/rendering/engine.d.ts +342 -0
  267. package/dist/shared/rendering/engine.d.ts.map +1 -0
  268. package/dist/shared/rendering/engine.js +990 -0
  269. package/dist/shared/rendering/engine.js.map +1 -0
  270. package/dist/shared/rendering/node/definitions.d.ts +57 -0
  271. package/dist/shared/rendering/node/definitions.d.ts.map +1 -0
  272. package/dist/shared/rendering/node/definitions.js +2 -0
  273. package/dist/shared/rendering/node/definitions.js.map +1 -0
  274. package/dist/shared/rendering/node/index.d.ts +20 -0
  275. package/dist/shared/rendering/node/index.d.ts.map +1 -0
  276. package/dist/shared/rendering/node/index.js +19 -0
  277. package/dist/shared/rendering/node/index.js.map +1 -0
  278. package/dist/shared/rendering/node/node-object.d.ts +77 -0
  279. package/dist/shared/rendering/node/node-object.d.ts.map +1 -0
  280. package/dist/shared/rendering/node/node-object.js +241 -0
  281. package/dist/shared/rendering/node/node-object.js.map +1 -0
  282. package/dist/shared/rendering/node/utils.d.ts +33 -0
  283. package/dist/shared/rendering/node/utils.d.ts.map +1 -0
  284. package/dist/shared/rendering/node/utils.js +27 -0
  285. package/dist/shared/rendering/node/utils.js.map +1 -0
  286. package/dist/shared/rendering/svg.d.ts +26 -0
  287. package/dist/shared/rendering/svg.d.ts.map +1 -0
  288. package/dist/shared/rendering/svg.js +44 -0
  289. package/dist/shared/rendering/svg.js.map +1 -0
  290. package/dist/shared/rendering/text.d.ts +33 -0
  291. package/dist/shared/rendering/text.d.ts.map +1 -0
  292. package/dist/shared/rendering/text.js +107 -0
  293. package/dist/shared/rendering/text.js.map +1 -0
  294. package/dist/shared/rendering/texture-cache.d.ts +32 -0
  295. package/dist/shared/rendering/texture-cache.d.ts.map +1 -0
  296. package/dist/shared/rendering/texture-cache.js +76 -0
  297. package/dist/shared/rendering/texture-cache.js.map +1 -0
  298. package/dist/shared/rendering/use-render-engine.d.ts +86 -0
  299. package/dist/shared/rendering/use-render-engine.d.ts.map +1 -0
  300. package/dist/shared/rendering/use-render-engine.js +89 -0
  301. package/dist/shared/rendering/use-render-engine.js.map +1 -0
  302. package/dist/shared/rendering/utils.d.ts +24 -0
  303. package/dist/shared/rendering/utils.d.ts.map +1 -0
  304. package/dist/shared/rendering/utils.js +60 -0
  305. package/dist/shared/rendering/utils.js.map +1 -0
  306. package/dist/shared/serializer.d.ts +39 -0
  307. package/dist/shared/serializer.d.ts.map +1 -0
  308. package/dist/shared/serializer.js +131 -0
  309. package/dist/shared/serializer.js.map +1 -0
  310. package/dist/shared/settings-context.d.ts +56 -0
  311. package/dist/shared/settings-context.d.ts.map +1 -0
  312. package/dist/shared/settings-context.js +36 -0
  313. package/dist/shared/settings-context.js.map +1 -0
  314. package/dist/shared/styles.d.ts +4 -0
  315. package/dist/shared/styles.d.ts.map +1 -0
  316. package/dist/shared/styles.js +52 -0
  317. package/dist/shared/styles.js.map +1 -0
  318. package/dist/shared/use-causal-graph-editor.d.ts +19 -0
  319. package/dist/shared/use-causal-graph-editor.d.ts.map +1 -0
  320. package/dist/shared/use-causal-graph-editor.js +58 -0
  321. package/dist/shared/use-causal-graph-editor.js.map +1 -0
  322. package/dist/shared/use-drag-mode.d.ts +33 -0
  323. package/dist/shared/use-drag-mode.d.ts.map +1 -0
  324. package/dist/shared/use-drag-mode.js +75 -0
  325. package/dist/shared/use-drag-mode.js.map +1 -0
  326. package/dist/shared/use-edge-encoder.d.ts +45 -0
  327. package/dist/shared/use-edge-encoder.d.ts.map +1 -0
  328. package/dist/shared/use-edge-encoder.js +121 -0
  329. package/dist/shared/use-edge-encoder.js.map +1 -0
  330. package/dist/shared/utils.d.ts +52 -0
  331. package/dist/shared/utils.d.ts.map +1 -0
  332. package/dist/shared/utils.js +99 -0
  333. package/dist/shared/utils.js.map +1 -0
  334. package/dist/types.d.ts +213 -0
  335. package/dist/types.d.ts.map +1 -0
  336. package/dist/types.js +98 -0
  337. package/dist/types.js.map +1 -0
  338. package/package.json +123 -0
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Copyright 2023 Impulse Innovations Limited
3
+ *
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ export { GraphLayout } from './common';
18
+ export { default as CustomLayout } from './custom-layout';
19
+ export { default as MarketingLayout } from './marketing-layout';
20
+ export { default as PlanarLayout } from './planar-layout';
21
+ export { default as SpringLayout } from './spring-layout';
22
+ export { default as CircularLayout } from './circular-layout';
23
+ export { default as ForceAtlasLayout } from './force-atlas-layout';
24
+ export { default as FcoseLayout } from './fcose-layout';
25
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/shared/graph-layout/index.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAChE,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC1D,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACnE,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,30 @@
1
+ import { LayoutMapping, XYPosition } from 'graphology-layout/utils';
2
+ import { SimulationGraph } from '../../types';
3
+ import { GraphLayout, GraphLayoutBuilder } from './common';
4
+ export type TargetLocation = 'center' | 'bottom';
5
+ declare class MarketingLayoutBuilder extends GraphLayoutBuilder<MarketingLayout> {
6
+ _targetLocation: TargetLocation;
7
+ /**
8
+ * Sets the target location and returns the builder
9
+ *
10
+ * @param location location of the target node
11
+ */
12
+ targetLocation(location: TargetLocation): this;
13
+ build(): MarketingLayout;
14
+ }
15
+ /**
16
+ * The Marketing layout uses a force simulation with strong forces to lay out nodes in a way
17
+ * that works well with a low number of nodes.
18
+ * The layout does not keep the force simulation running, instead it manually runs a number of ticks
19
+ * whenever the layout is updated.
20
+ */
21
+ export default class MarketingLayout extends GraphLayout {
22
+ targetLocation: TargetLocation;
23
+ constructor(builder: MarketingLayoutBuilder);
24
+ applyLayout(graph: SimulationGraph): Promise<{
25
+ layout: LayoutMapping<XYPosition>;
26
+ }>;
27
+ static get Builder(): MarketingLayoutBuilder;
28
+ }
29
+ export {};
30
+ //# sourceMappingURL=marketing-layout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"marketing-layout.d.ts","sourceRoot":"","sources":["../../../src/shared/graph-layout/marketing-layout.tsx"],"names":[],"mappings":"AAkBA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAEpE,OAAO,EAAE,eAAe,EAA2B,MAAM,aAAa,CAAC;AAEvE,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE3D,MAAM,MAAM,cAAc,GAAG,QAAQ,GAAG,QAAQ,CAAC;AAEjD,cAAM,sBAAuB,SAAQ,kBAAkB,CAAC,eAAe,CAAC;IACpE,eAAe,EAAE,cAAc,CAAY;IAE3C;;;;OAIG;IACH,cAAc,CAAC,QAAQ,EAAE,cAAc,GAAG,IAAI;IAK9C,KAAK,IAAI,eAAe;CAI3B;AAED;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,WAAW;IAC7C,cAAc,EAAE,cAAc,CAAY;gBAErC,OAAO,EAAE,sBAAsB;IAK3C,WAAW,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC;QACzC,MAAM,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;KACrC,CAAC;IAqEF,MAAM,KAAK,OAAO,IAAI,sBAAsB,CAE3C;CACJ"}
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Copyright 2023 Impulse Innovations Limited
3
+ *
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import * as d3 from 'd3';
18
+ import { getD3Data, nodesToLayout } from '../parsers';
19
+ import { GraphLayout, GraphLayoutBuilder } from './common';
20
+ class MarketingLayoutBuilder extends GraphLayoutBuilder {
21
+ constructor() {
22
+ super(...arguments);
23
+ this._targetLocation = 'bottom';
24
+ }
25
+ /**
26
+ * Sets the target location and returns the builder
27
+ *
28
+ * @param location location of the target node
29
+ */
30
+ targetLocation(location) {
31
+ this._targetLocation = location;
32
+ return this;
33
+ }
34
+ build() {
35
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
36
+ return new MarketingLayout(this);
37
+ }
38
+ }
39
+ /**
40
+ * The Marketing layout uses a force simulation with strong forces to lay out nodes in a way
41
+ * that works well with a low number of nodes.
42
+ * The layout does not keep the force simulation running, instead it manually runs a number of ticks
43
+ * whenever the layout is updated.
44
+ */
45
+ export default class MarketingLayout extends GraphLayout {
46
+ constructor(builder) {
47
+ super(builder);
48
+ this.targetLocation = 'bottom';
49
+ this.targetLocation = builder._targetLocation;
50
+ }
51
+ applyLayout(graph) {
52
+ const [edges, nodes] = getD3Data(graph);
53
+ // Add some code in here to move the root of the graph up when there are no secondary nodes.
54
+ const simulation = d3
55
+ .forceSimulation(nodes)
56
+ .alphaMin(0.001)
57
+ // The link force pulls linked nodes together so they try to be a given distance apart
58
+ .force('link', d3
59
+ .forceLink(edges)
60
+ .id((d) => d.id)
61
+ .distance(() => this.nodeSize * 3)
62
+ .strength(this.targetLocation === 'center' ? 0.7 : 0.1))
63
+ // The charge force acts to push the nodes away from each other so they have space
64
+ .force('charge', d3.forceManyBody().strength(this.targetLocation === 'center' ? -1000 : -2000))
65
+ // The y force acts to split the different groups up vertically on the graph
66
+ .force('y', d3
67
+ .forceY()
68
+ .y((node) => {
69
+ if (node.group === 'target') {
70
+ return this.nodeSize * 10;
71
+ }
72
+ if (node.group === 'latent') {
73
+ return this.nodeSize * 2;
74
+ }
75
+ return this.nodeSize * 6;
76
+ })
77
+ .strength(this.targetLocation === 'center' ? 0 : 0.3))
78
+ // The collide force makes sure that the nodes never overlap with each other
79
+ .force('collide', d3.forceCollide(this.nodeSize + 10))
80
+ // The radial force aligns all the groups to increasing circle sizes out from a central point.
81
+ .force('radial', d3
82
+ .forceRadial((node) => {
83
+ if (node.group === 'target') {
84
+ return 0;
85
+ }
86
+ if (node.group === 'latent') {
87
+ return this.nodeSize * 8;
88
+ }
89
+ return this.nodeSize * 4;
90
+ }, 600, 400)
91
+ .strength((node) => {
92
+ if (this.targetLocation === 'center') {
93
+ return 1;
94
+ }
95
+ return node.group === 'other' ? 0.7 : 1;
96
+ }))
97
+ .stop();
98
+ simulation.tick(1000);
99
+ return Promise.resolve({ layout: nodesToLayout(simulation.nodes()) });
100
+ }
101
+ static get Builder() {
102
+ return new MarketingLayoutBuilder();
103
+ }
104
+ }
105
+ //# sourceMappingURL=marketing-layout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"marketing-layout.js","sourceRoot":"","sources":["../../../src/shared/graph-layout/marketing-layout.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAKzB,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAI3D,MAAM,sBAAuB,SAAQ,kBAAmC;IAAxE;;QACI,oBAAe,GAAmB,QAAQ,CAAC;IAgB/C,CAAC;IAdG;;;;OAIG;IACH,cAAc,CAAC,QAAwB;QACnC,IAAI,CAAC,eAAe,GAAG,QAAQ,CAAC;QAChC,OAAO,IAAI,CAAC;IAChB,CAAC;IAED,KAAK;QACD,mEAAmE;QACnE,OAAO,IAAI,eAAe,CAAC,IAAI,CAAC,CAAC;IACrC,CAAC;CACJ;AAED;;;;;GAKG;AACH,MAAM,CAAC,OAAO,OAAO,eAAgB,SAAQ,WAAW;IAGpD,YAAY,OAA+B;QACvC,KAAK,CAAC,OAAO,CAAC,CAAC;QAHZ,mBAAc,GAAmB,QAAQ,CAAC;QAI7C,IAAI,CAAC,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC;IAClD,CAAC;IAED,WAAW,CAAC,KAAsB;QAG9B,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,CAAC;QAExC,4FAA4F;QAC5F,MAAM,UAAU,GAAG,EAAE;aAChB,eAAe,CAAC,KAAK,CAAC;aACtB,QAAQ,CAAC,KAAK,CAAC;YAChB,sFAAsF;aACrF,KAAK,CACF,MAAM,EACN,EAAE;aACG,SAAS,CAAwE,KAAK,CAAC;aACvF,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;aACf,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,GAAG,CAAC,CAAC;aAC5B;YAED,OAAO,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;QAC7B,CAAC,EACD,GAAG,EACH,GAAG,CACN;aACA,QAAQ,CAAC,CAAC,IAAI,EAAE,EAAE;YACf,IAAI,IAAI,CAAC,cAAc,KAAK,QAAQ,EAAE;gBAClC,OAAO,CAAC,CAAC;aACZ;YACD,OAAO,IAAI,CAAC,KAAK,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;QAC5C,CAAC,CAAC,CACT;aACA,IAAI,EAAE,CAAC;QAEZ,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAEtB,OAAO,OAAO,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,aAAa,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;IAC1E,CAAC;IAED,MAAM,KAAK,OAAO;QACd,OAAO,IAAI,sBAAsB,EAAE,CAAC;IACxC,CAAC;CACJ"}
@@ -0,0 +1,32 @@
1
+ import { LayoutMapping, XYPosition } from 'graphology-layout/utils';
2
+ import { SimulationGraph } from '../../types';
3
+ import { GraphLayout, GraphLayoutBuilder } from './common';
4
+ export type DirectionType = 'horizontal' | 'vertical';
5
+ declare class PlanarLayoutBuilder extends GraphLayoutBuilder<PlanarLayout> {
6
+ _orientation: DirectionType;
7
+ /**
8
+ * Sets the nodes orientation
9
+ *
10
+ * @param direction vertical or horizontal
11
+ */
12
+ orientation(direction: DirectionType): this;
13
+ build(): PlanarLayout;
14
+ }
15
+ /**
16
+ * The Planar layout utilises the sugiyama algorithm to lay out nodes in a way that minimises
17
+ * edge crossings.
18
+ */
19
+ export default class PlanarLayout extends GraphLayout {
20
+ orientation: DirectionType;
21
+ constructor(builder: PlanarLayoutBuilder);
22
+ get supportsDrag(): boolean;
23
+ applyLayout(graph: SimulationGraph, forceUpdate?: (layout: LayoutMapping<XYPosition>, edgePoints: LayoutMapping<XYPosition[]>) => void): Promise<{
24
+ edgePoints?: LayoutMapping<XYPosition[]>;
25
+ layout: LayoutMapping<XYPosition>;
26
+ onAddEdge?: () => void | Promise<void>;
27
+ onAddNode?: () => void | Promise<void>;
28
+ }>;
29
+ static get Builder(): PlanarLayoutBuilder;
30
+ }
31
+ export {};
32
+ //# sourceMappingURL=planar-layout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"planar-layout.d.ts","sourceRoot":"","sources":["../../../src/shared/graph-layout/planar-layout.tsx"],"names":[],"mappings":"AAiBA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAEpE,OAAO,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9C,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE3D,MAAM,MAAM,aAAa,GAAG,YAAY,GAAG,UAAU,CAAC;AAEtD,cAAM,mBAAoB,SAAQ,kBAAkB,CAAC,YAAY,CAAC;IAC9D,YAAY,EAAE,aAAa,CAAgB;IAE3C;;;;OAIG;IACH,WAAW,CAAC,SAAS,EAAE,aAAa,GAAG,IAAI;IAK3C,KAAK,IAAI,YAAY;CAIxB;AAED;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,WAAW;IAC1C,WAAW,EAAE,aAAa,CAAgB;gBAErC,OAAO,EAAE,mBAAmB;IAMxC,IAAI,YAAY,IAAI,OAAO,CAE1B;IAED,WAAW,CACP,KAAK,EAAE,eAAe,EACtB,WAAW,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,CAAC,UAAU,CAAC,EAAE,UAAU,EAAE,aAAa,CAAC,UAAU,EAAE,CAAC,KAAK,IAAI,GACnG,OAAO,CAAC;QACP,UAAU,CAAC,EAAE,aAAa,CAAC,UAAU,EAAE,CAAC,CAAC;QACzC,MAAM,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;QAClC,SAAS,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QACvC,SAAS,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;KAC1C,CAAC;IAqDF,MAAM,KAAK,OAAO,IAAI,mBAAmB,CAExC;CACJ"}
@@ -0,0 +1,95 @@
1
+ /**
2
+ * Copyright 2023 Impulse Innovations Limited
3
+ *
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { coordQuad, sugiyama } from 'd3-dag';
18
+ import { dagGraphParser } from '../parsers';
19
+ import { GraphLayout, GraphLayoutBuilder } from './common';
20
+ class PlanarLayoutBuilder extends GraphLayoutBuilder {
21
+ constructor() {
22
+ super(...arguments);
23
+ this._orientation = 'horizontal';
24
+ }
25
+ /**
26
+ * Sets the nodes orientation
27
+ *
28
+ * @param direction vertical or horizontal
29
+ */
30
+ orientation(direction) {
31
+ this._orientation = direction;
32
+ return this;
33
+ }
34
+ build() {
35
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
36
+ return new PlanarLayout(this);
37
+ }
38
+ }
39
+ /**
40
+ * The Planar layout utilises the sugiyama algorithm to lay out nodes in a way that minimises
41
+ * edge crossings.
42
+ */
43
+ export default class PlanarLayout extends GraphLayout {
44
+ constructor(builder) {
45
+ super(builder);
46
+ this.orientation = 'horizontal';
47
+ this.orientation = builder._orientation;
48
+ }
49
+ // eslint-disable-next-line class-methods-use-this
50
+ get supportsDrag() {
51
+ return false;
52
+ }
53
+ applyLayout(graph, forceUpdate) {
54
+ // define an inner method so it can be called repeatedly when nodes or edges are added
55
+ const computeLayout = (currentGraph) => {
56
+ const dag = dagGraphParser(currentGraph);
57
+ /**
58
+ * The nodeSize is scaled for consistent spacing in the horizontal layout
59
+ */
60
+ const newDagLayout = sugiyama()
61
+ .nodeSize(() => [this.nodeSize * 3, this.nodeSize * 6])
62
+ .coord(coordQuad())(dag);
63
+ const edgePoints = newDagLayout.dag.links().reduce((acc, link) => {
64
+ acc[`${link.source.id}||${link.target.id}`] = link.points.map((point) => ({
65
+ x: this.orientation === 'vertical' ? point.x : point.y,
66
+ y: this.orientation === 'vertical' ? point.y : point.x,
67
+ }));
68
+ return acc;
69
+ }, {});
70
+ const newLayout = newDagLayout.dag.descendants().reduce((acc, node) => {
71
+ acc[node.id] = {
72
+ x: this.orientation === 'vertical' ? node.x : node.y,
73
+ y: this.orientation === 'vertical' ? node.y : node.x,
74
+ };
75
+ return acc;
76
+ }, {});
77
+ return { edgePoints, newLayout };
78
+ };
79
+ const { newLayout, edgePoints } = computeLayout(graph);
80
+ const recomputeLayout = () => {
81
+ const { newLayout: recomputedLayout, edgePoints: recomputedPoints } = computeLayout(graph);
82
+ forceUpdate(recomputedLayout, recomputedPoints);
83
+ };
84
+ return Promise.resolve({
85
+ edgePoints,
86
+ layout: newLayout,
87
+ onAddEdge: recomputeLayout,
88
+ onAddNode: recomputeLayout,
89
+ });
90
+ }
91
+ static get Builder() {
92
+ return new PlanarLayoutBuilder();
93
+ }
94
+ }
95
+ //# sourceMappingURL=planar-layout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"planar-layout.js","sourceRoot":"","sources":["../../../src/shared/graph-layout/planar-layout.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAW,SAAS,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAItD,OAAO,EAAe,cAAc,EAAE,MAAM,YAAY,CAAC;AACzD,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAI3D,MAAM,mBA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O,CAAC;YACnB,UAAU;YACV,MAAM,EAAE,SAAS;YACjB,SAAS,EAAE,eAAe;YAC1B,SAAS,EAAE,eAAe;SAC7B,CAAC,CAAC;IACP,CAAC;IAED,MAAM,KAAK,OAAO;QACd,OAAO,IAAI,mBAAmB,EAAE,CAAC;IACrC,CAAC;CACJ"}
@@ -0,0 +1,56 @@
1
+ import { LayoutMapping, XYPosition } from 'graphology-layout/utils';
2
+ import { SimulationGraph } from '../../types';
3
+ import { GraphLayout, GraphLayoutBuilder } from './common';
4
+ declare class SpringLayoutBuilder extends GraphLayoutBuilder<SpringLayout> {
5
+ _collisionForce: number;
6
+ _gravity: number;
7
+ _linkForce: number;
8
+ _warmupTicks: number;
9
+ /**
10
+ * Set the multiplier for collision force
11
+ *
12
+ * @param force force to set
13
+ */
14
+ collisionForce(force: number): this;
15
+ /**
16
+ * Set the multiplier for link force
17
+ *
18
+ * @param force force to set
19
+ */
20
+ linkForce(force: number): this;
21
+ /**
22
+ * Set the gravity force
23
+ *
24
+ * @param force force to set
25
+ */
26
+ gravity(force: number): this;
27
+ /**
28
+ * Sets the number of ticks to run the simulation for before displaying the layout
29
+ *
30
+ * @param ticks number of ticks to run before display
31
+ */
32
+ warmupTicks(ticks: number): this;
33
+ build(): SpringLayout;
34
+ }
35
+ /**
36
+ * The Spring layout uses a force simulation to position nodes.
37
+ * The layout keeps the simulation running as nodes are being dragged which produces the spring behaviour of edges.
38
+ */
39
+ export default class SpringLayout extends GraphLayout {
40
+ collisionForce: number;
41
+ gravity: number;
42
+ linkForce: number;
43
+ warmupTicks: number;
44
+ constructor(builder: SpringLayoutBuilder);
45
+ applyLayout(graph: SimulationGraph, forceUpdate: (layout: LayoutMapping<XYPosition>) => void): Promise<{
46
+ layout: LayoutMapping<XYPosition>;
47
+ onAddNode?: () => void | Promise<void>;
48
+ onCleanup?: () => void | Promise<void>;
49
+ onEndDrag?: () => void | Promise<void>;
50
+ onMove?: (nodeId: string, x: number, y: number) => void;
51
+ onStartDrag?: () => void | Promise<void>;
52
+ }>;
53
+ static get Builder(): SpringLayoutBuilder;
54
+ }
55
+ export {};
56
+ //# sourceMappingURL=spring-layout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spring-layout.d.ts","sourceRoot":"","sources":["../../../src/shared/graph-layout/spring-layout.tsx"],"names":[],"mappings":"AAkBA,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAGpE,OAAO,EAAoB,eAAe,EAAkB,MAAM,aAAa,CAAC;AAEhF,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE3D,cAAM,mBAAoB,SAAQ,kBAAkB,CAAC,YAAY,CAAC;IAC9D,eAAe,SAAK;IAEpB,QAAQ,SAAO;IAEf,UAAU,SAAK;IAEf,YAAY,SAAO;IAEnB;;;;OAIG;IACH,cAAc,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAKnC;;;;OAIG;IACH,SAAS,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK9B;;;;OAIG;IACH,OAAO,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAK5B;;;;OAIG;IACH,WAAW,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI;IAKhC,KAAK,IAAI,YAAY;CAIxB;AAED;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,YAAa,SAAQ,WAAW;IAC1C,cAAc,EAAE,MAAM,CAAC;IAEvB,OAAO,EAAE,MAAM,CAAC;IAEhB,SAAS,EAAE,MAAM,CAAC;IAElB,WAAW,EAAE,MAAM,CAAC;gBAEf,OAAO,EAAE,mBAAmB;IAQxC,WAAW,CACP,KAAK,EAAE,eAAe,EACtB,WAAW,EAAE,CAAC,MAAM,EAAE,aAAa,CAAC,UAAU,CAAC,KAAK,IAAI,GACzD,OAAO,CAAC;QACP,MAAM,EAAE,aAAa,CAAC,UAAU,CAAC,CAAC;QAClC,SAAS,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QACvC,SAAS,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QACvC,SAAS,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;QACvC,MAAM,CAAC,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,EAAE,CAAC,EAAE,MAAM,KAAK,IAAI,CAAC;QACxD,WAAW,CAAC,EAAE,MAAM,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;KAC5C,CAAC;IA4EF,MAAM,KAAK,OAAO,IAAI,mBAAmB,CAExC;CACJ"}
@@ -0,0 +1,148 @@
1
+ /**
2
+ * Copyright 2023 Impulse Innovations Limited
3
+ *
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import * as d3 from 'd3';
18
+ import debounce from 'lodash/debounce';
19
+ import { getD3Data, nodesToLayout } from '../parsers';
20
+ import { GraphLayout, GraphLayoutBuilder } from './common';
21
+ class SpringLayoutBuilder extends GraphLayoutBuilder {
22
+ constructor() {
23
+ super(...arguments);
24
+ this._collisionForce = 2;
25
+ this._gravity = -50;
26
+ this._linkForce = 5;
27
+ this._warmupTicks = 100;
28
+ }
29
+ /**
30
+ * Set the multiplier for collision force
31
+ *
32
+ * @param force force to set
33
+ */
34
+ collisionForce(force) {
35
+ this._collisionForce = force;
36
+ return this;
37
+ }
38
+ /**
39
+ * Set the multiplier for link force
40
+ *
41
+ * @param force force to set
42
+ */
43
+ linkForce(force) {
44
+ this._linkForce = force;
45
+ return this;
46
+ }
47
+ /**
48
+ * Set the gravity force
49
+ *
50
+ * @param force force to set
51
+ */
52
+ gravity(force) {
53
+ this._gravity = force;
54
+ return this;
55
+ }
56
+ /**
57
+ * Sets the number of ticks to run the simulation for before displaying the layout
58
+ *
59
+ * @param ticks number of ticks to run before display
60
+ */
61
+ warmupTicks(ticks) {
62
+ this._warmupTicks = ticks;
63
+ return this;
64
+ }
65
+ build() {
66
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
67
+ return new SpringLayout(this);
68
+ }
69
+ }
70
+ /**
71
+ * The Spring layout uses a force simulation to position nodes.
72
+ * The layout keeps the simulation running as nodes are being dragged which produces the spring behaviour of edges.
73
+ */
74
+ export default class SpringLayout extends GraphLayout {
75
+ constructor(builder) {
76
+ super(builder);
77
+ this.collisionForce = builder._collisionForce;
78
+ this.linkForce = builder._linkForce;
79
+ this.gravity = builder._gravity;
80
+ this.warmupTicks = builder._warmupTicks;
81
+ }
82
+ applyLayout(graph, forceUpdate) {
83
+ // We're modifying edges/nodes
84
+ let [edges, nodes] = getD3Data(graph);
85
+ const simulation = d3
86
+ .forceSimulation(nodes)
87
+ // The link force pulls linked nodes together so they try to be a given distance apart
88
+ .force('links', d3
89
+ .forceLink(edges)
90
+ .id((d) => d.id)
91
+ .distance(() => this.nodeSize * this.linkForce))
92
+ // The charge force acts to push the nodes away from each other so they have space
93
+ .force('charge', d3.forceManyBody().strength(this.gravity))
94
+ // The collide force makes sure that the nodes never overlap with each other
95
+ .force('collide', d3.forceCollide(this.nodeSize * this.collisionForce))
96
+ // The center force keeps nodes in the middle of the viewport
97
+ .force('center', d3.forceCenter())
98
+ .stop(); // don't start just yet
99
+ // Warm-up the simulation so the jump to the center isn't visible
100
+ simulation.tick(this.warmupTicks);
101
+ simulation
102
+ .on('tick', () => {
103
+ // On each tick, update simulation nodes
104
+ const newNodes = nodesToLayout(simulation.nodes());
105
+ // Force an update
106
+ forceUpdate(newNodes);
107
+ })
108
+ .restart();
109
+ const onAddNode = debounce(() => {
110
+ [edges, nodes] = getD3Data(graph);
111
+ // replace nodes, re-add link force
112
+ simulation
113
+ .nodes(nodes)
114
+ .force('links', d3
115
+ .forceLink(edges)
116
+ .id((d) => d.id)
117
+ .distance(() => this.nodeSize * this.linkForce))
118
+ .alpha(0.8)
119
+ .alphaTarget(0)
120
+ .restart();
121
+ }, 100);
122
+ return Promise.resolve({
123
+ layout: nodesToLayout(simulation.nodes()),
124
+ onAddNode,
125
+ onCleanup: () => {
126
+ simulation.stop();
127
+ },
128
+ onEndDrag: () => {
129
+ // let simulation run for a little bit after dragging finished
130
+ simulation.alpha(0.1).alphaTarget(0);
131
+ },
132
+ onMove: (nodeId, x, y) => {
133
+ const nodeIdx = nodes.findIndex((n) => n.id === nodeId);
134
+ nodes[nodeIdx].x = x;
135
+ nodes[nodeIdx].y = y;
136
+ },
137
+ onStartDrag: () => {
138
+ // target is higher than alpha so that the simulation will continue to run
139
+ // as long as we're dragging
140
+ simulation.alpha(0.3).alphaTarget(0.4).restart();
141
+ },
142
+ });
143
+ }
144
+ static get Builder() {
145
+ return new SpringLayoutBuilder();
146
+ }
147
+ }
148
+ //# sourceMappingURL=spring-layout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"spring-layout.js","sourceRoot":"","sources":["../../../src/shared/graph-layout/spring-layout.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAGzB,OAAO,QAAQ,MAAM,iBAAiB,CAAC;AAGvC,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACtD,OAAO,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAE3D,MAAM,mBAAoB,SAAQ,kBAAgC;IAAlE;;QACI,oBAAe,GAAG,CAAC,CAAC;QAEpB,aAAQ,GAAG,CAAC,EAAE,CAAC;QAEf,eAAU,GAA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,SAAS,CAAC,CACtD;iBACA,KAAK,CAAC,GAAG,CAAC;iBACV,WAAW,CAAC,CAAC,CAAC;iBACd,OAAO,EAAE,CAAC;QACnB,CAAC,EAAE,GAAG,CAAC,CAAC;QAER,OAAO,OAAO,CAAC,OAAO,CAAC;YACnB,MAAM,EAAE,aAAa,CAAC,UAAU,CAAC,KAAK,EAAE,CAAC;YACzC,SAAS;YACT,SAAS,EAAE,GAAG,EAAE;gBACZ,UAAU,CAAC,IAAI,EAAE,CAAC;YACtB,CAAC;YACD,SAAS,EAAE,GAAG,EAAE;gBACZ,8DAA8D;gBAC9D,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC;YACzC,CAAC;YACD,MAAM,EAAE,CAAC,MAAc,EAAE,CAAS,EAAE,CAAS,EAAE,EAAE;gBAC7C,MAAM,OAAO,GAAG,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,KAAK,MAAM,CAAC,CAAC;gBACxD,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;gBACrB,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;YACzB,CAAC;YACD,WAAW,EAAE,GAAG,EAAE;gBACd,0EAA0E;gBAC1E,4BAA4B;gBAC5B,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,CAAC;YACrD,CAAC;SACJ,CAAC,CAAC;IACP,CAAC;IAED,MAAM,KAAK,OAAO;QACd,OAAO,IAAI,mBAAmB,EAAE,CAAC;IACrC,CAAC;CACJ"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Copyright 2023 Impulse Innovations Limited
3
+ *
4
+ *
5
+ * Licensed under the Apache License, Version 2.0 (the "License");
6
+ * you may not use this file except in compliance with the License.
7
+ * You may obtain a copy of the License at
8
+ *
9
+ * http://www.apache.org/licenses/LICENSE-2.0
10
+ *
11
+ * Unless required by applicable law or agreed to in writing, software
12
+ * distributed under the License is distributed on an "AS IS" BASIS,
13
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ * See the License for the specific language governing permissions and
15
+ * limitations under the License.
16
+ */
17
+ import { Dag, DagNode } from 'd3-dag';
18
+ import { LayoutMapping, XYPosition } from 'graphology-layout/utils';
19
+ import { CausalGraph, CausalGraphEdge, CausalGraphNode, D3SimulationEdge, SimulationEdge, SimulationGraph, SimulationNode, SimulationNodeWithGroup } from '../types';
20
+ export type DagNodeData = SimulationNode & {
21
+ parentIds: string[];
22
+ };
23
+ /**
24
+ * This parses the graph structure into a Dag structure that the d3-dag library can understand
25
+ *
26
+ * @param rawData
27
+ */
28
+ export declare function dagGraphParser(graph: SimulationGraph): Dag<DagNode<DagNodeData>>;
29
+ /**
30
+ * Get graph edges in d3 expected format
31
+ *
32
+ * @param graph graph to get edges from
33
+ */
34
+ export declare function getD3Data(graph: SimulationGraph): [edges: D3SimulationEdge[], nodes: SimulationNodeWithGroup[]];
35
+ /**
36
+ * Format node data in a layoutmapping format
37
+ *
38
+ * @param nodes
39
+ */
40
+ export declare function nodesToLayout(nodes: SimulationNode[]): LayoutMapping<XYPosition>;
41
+ /**
42
+ * Parse a causal graph node into a simulation node
43
+ *
44
+ * @param nodeKey node id
45
+ * @param nodeData node data
46
+ * @param data whole graph data
47
+ * @param availableInputs optional list of input nodes
48
+ */
49
+ export declare function parseGraphNode(nodeKey: string, nodeData: CausalGraphNode, data: CausalGraph, availableInputs?: string[]): SimulationNode;
50
+ /**
51
+ * Parse a causal graph edge into simulation edge
52
+ *
53
+ * @param edgeData edge data
54
+ */
55
+ export declare function parseGraphEdge(edgeData: CausalGraphEdge): SimulationEdge;
56
+ /**
57
+ * Parses CausalGraph structure into a SimulationGraph representation
58
+ *
59
+ * @param data input CausalGraph structure
60
+ * @param availableInputs names of input nodes
61
+ */
62
+ export declare function causalGraphParser(data: CausalGraph, availableInputs?: string[], initialGraph?: SimulationGraph): SimulationGraph;
63
+ //# sourceMappingURL=parsers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parsers.d.ts","sourceRoot":"","sources":["../../src/shared/parsers.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAAE,GAAG,EAAE,OAAO,EAAe,MAAM,QAAQ,CAAC;AAEnD,OAAO,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAIpE,OAAO,EACH,WAAW,EACX,eAAe,EACf,eAAe,EACf,gBAAgB,EAIhB,cAAc,EACd,eAAe,EACf,cAAc,EACd,uBAAuB,EAC1B,MAAM,UAAU,CAAC;AAGlB,MAAM,MAAM,WAAW,GAAG,cAAc,GAAG;IACvC,SAAS,EAAE,MAAM,EAAE,CAAC;CACvB,CAAC;AAEF;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,eAAe,GAAG,GAAG,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAYhF;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,eAAe,GAAG,CAAC,KAAK,EAAE,gBAAgB,EAAE,EAAE,KAAK,EAAE,uBAAuB,EAAE,CAAC,CAqB/G;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,cAAc,EAAE,GAAG,aAAa,CAAC,UAAU,CAAC,CAShF;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAC1B,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,eAAe,EACzB,IAAI,EAAE,WAAW,EACjB,eAAe,CAAC,EAAE,MAAM,EAAE,GAC3B,cAAc,CA+BhB;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,eAAe,GAAG,cAAc,CAmBxE;AAMD;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC7B,IAAI,EAAE,WAAW,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