strategy-panel 1.0.1 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (341) hide show
  1. package/.fatherrc.ts +11 -26
  2. package/.umirc.ts +4 -0
  3. package/README.md +33 -33
  4. package/es/assets/decive.svg +1 -1
  5. package/es/assets/hand.svg +1 -1
  6. package/es/assets/lock.svg +8 -0
  7. package/es/components/canvas/component-tree-panel/category-tree/category-type.d.ts +1 -0
  8. package/es/{common/graph-common → components/canvas/component-tree-panel/category-tree}/category-type.js +28 -12
  9. package/es/{pages → components/canvas}/component-tree-panel/category-tree/index.d.ts +17 -16
  10. package/es/{pages → components/canvas}/component-tree-panel/category-tree/index.js +14 -14
  11. package/es/{pages → components/canvas}/component-tree-panel/category-tree/index.less +36 -36
  12. package/es/{pages → components/canvas}/component-tree-panel/category-tree/node-title.d.ts +12 -12
  13. package/es/{pages → components/canvas}/component-tree-panel/category-tree/node-title.js +5 -3
  14. package/es/{pages → components/canvas}/component-tree-panel/index.d.ts +17 -17
  15. package/es/{pages → components/canvas}/component-tree-panel/index.js +1 -0
  16. package/es/{pages → components/canvas}/component-tree-panel/index.less +1 -0
  17. package/es/{pages → components/canvas}/config-panel/components/condition-configuration/configure-modal/data-origin.d.ts +49 -49
  18. package/es/{pages → components/canvas}/config-panel/components/condition-configuration/configure-modal/data-origin.js +26 -34
  19. package/es/{pages → components/canvas}/config-panel/components/condition-configuration/configure-modal/index.d.ts +11 -11
  20. package/es/{pages → components/canvas}/config-panel/components/condition-configuration/configure-modal/index.js +15 -23
  21. package/es/{pages → components/canvas}/config-panel/components/condition-configuration/configure-modal/style.less +1 -1
  22. package/es/{pages → components/canvas}/config-panel/components/condition-configuration/cross-line.d.ts +9 -9
  23. package/es/{pages → components/canvas}/config-panel/components/condition-configuration/cross-line.js +6 -10
  24. package/es/{pages → components/canvas}/config-panel/components/condition-configuration/index.d.ts +10 -9
  25. package/es/{pages → components/canvas}/config-panel/components/condition-configuration/index.js +17 -13
  26. package/es/{pages → components/canvas}/config-panel/components/condition-configuration/style.less +74 -74
  27. package/es/{pages → components/canvas}/config-panel/components/time-trigger/components/cycle-time.d.ts +9 -9
  28. package/es/{pages → components/canvas}/config-panel/components/time-trigger/components/cycle-time.js +24 -33
  29. package/es/{pages → components/canvas}/config-panel/components/time-trigger/components/time-horizon.d.ts +10 -10
  30. package/es/{pages → components/canvas}/config-panel/components/time-trigger/components/time-horizon.js +18 -28
  31. package/es/{pages → components/canvas}/config-panel/components/time-trigger/delay-time.d.ts +9 -9
  32. package/es/components/canvas/config-panel/components/time-trigger/effective-time.d.ts +7 -0
  33. package/es/components/canvas/config-panel/components/time-trigger/effective-time.js +43 -0
  34. package/es/{pages → components/canvas}/config-panel/components/time-trigger/index.d.ts +9 -8
  35. package/es/{pages → components/canvas}/config-panel/components/time-trigger/index.js +18 -17
  36. package/es/{pages → components/canvas}/config-panel/components/time-trigger/interval-time.d.ts +9 -9
  37. package/es/{pages → components/canvas}/config-panel/components/time-trigger/interval-time.js +4 -8
  38. package/es/{pages → components/canvas}/config-panel/components/time-trigger/persistent-time.d.ts +9 -9
  39. package/es/components/canvas/config-panel/components/time-trigger/section-Detail.d.ts +10 -0
  40. package/es/components/canvas/config-panel/components/time-trigger/section-Detail.js +125 -0
  41. package/es/components/canvas/config-panel/components/time-trigger/section-time.d.ts +9 -0
  42. package/es/components/canvas/config-panel/components/time-trigger/section-time.js +81 -0
  43. package/es/{pages → components/canvas}/config-panel/components/time-trigger/timing-time.d.ts +9 -9
  44. package/es/{pages → components/canvas}/config-panel/components/time-trigger/timing-time.js +7 -11
  45. package/es/{pages → components/canvas}/config-panel/config-common.d.ts +38 -37
  46. package/es/{pages → components/canvas}/config-panel/config-common.js +9 -15
  47. package/es/{pages → components/canvas}/config-panel/index.d.ts +14 -13
  48. package/es/{pages → components/canvas}/config-panel/index.js +2 -2
  49. package/es/{pages → components/canvas}/config-panel/node-form.d.ts +23 -22
  50. package/es/{pages → components/canvas}/config-panel/node-form.js +14 -16
  51. package/es/{pages → components/canvas}/config-panel/style.less +90 -81
  52. package/es/{pages → components/canvas}/dag-canvas/canvas-content.d.ts +11 -10
  53. package/es/{pages → components/canvas}/dag-canvas/canvas-content.js +23 -12
  54. package/es/{pages → components/canvas}/dag-canvas/index.d.ts +23 -18
  55. package/es/{pages → components/canvas}/dag-canvas/index.js +5 -2
  56. package/es/{pages → components/canvas}/dag-canvas/preview.d.ts +10 -10
  57. package/es/components/canvas/dag-canvas/preview.js +53 -0
  58. package/es/{pages → components/canvas}/index.d.ts +48 -42
  59. package/es/{pages → components/canvas}/index.js +20 -10
  60. package/es/{pages → components/canvas}/index.less +2 -2
  61. package/es/{pages → components/canvas}/strategy-header/index.d.ts +48 -56
  62. package/es/components/canvas/strategy-header/index.js +210 -0
  63. package/es/{pages → components/canvas}/strategy-header/style.less +4 -3
  64. package/es/{pages → components/canvas}/strategy-header/theme-switch/index.d.ts +4 -4
  65. package/es/{pages → components/canvas}/strategy-header/theme-switch/index.js +2 -3
  66. package/es/index.d.ts +9 -8
  67. package/es/index.js +8 -7
  68. package/es/packages/graph-canvas/graph-common.d.ts +19 -0
  69. package/es/packages/graph-canvas/graph-common.js +19 -0
  70. package/es/packages/graph-canvas/graph-model/edge/group-edge/index.d.ts +4 -0
  71. package/es/packages/graph-canvas/graph-model/edge/group-edge/index.js +63 -0
  72. package/es/packages/graph-canvas/graph-model/edge/index.d.ts +2 -0
  73. package/es/packages/graph-canvas/graph-model/edge/index.js +2 -0
  74. package/es/packages/graph-canvas/graph-model/node/application-node/application-element.d.ts +9 -0
  75. package/es/packages/graph-canvas/graph-model/node/application-node/application-element.js +20 -0
  76. package/es/packages/graph-canvas/graph-model/node/application-node/application-element.less +17 -0
  77. package/es/packages/graph-canvas/graph-model/node/application-node/index.d.ts +7 -0
  78. package/es/{common/graph-common/shape/nodes/GroupNode.js → packages/graph-canvas/graph-model/node/application-node/index.js} +42 -22
  79. package/es/{common/graph-common/shape/nodes/CommonNode.d.ts → packages/graph-canvas/graph-model/node/common-node/index.d.ts} +7 -5
  80. package/es/{common/graph-common/shape/nodes/CommonNode.js → packages/graph-canvas/graph-model/node/common-node/index.js} +8 -7
  81. package/es/{common/graph-common/node-element → packages/graph-canvas/graph-model/node/common-node}/node-element.d.ts +9 -9
  82. package/es/{common/graph-common/node-element → packages/graph-canvas/graph-model/node/common-node}/node-element.js +16 -14
  83. package/es/{common/graph-common/node-element → packages/graph-canvas/graph-model/node/common-node}/node-element.less +4 -4
  84. package/es/{common/graph-common/node-element → packages/graph-canvas/graph-model/node/condition-node}/condition-element.d.ts +9 -9
  85. package/es/{common/graph-common/node-element → packages/graph-canvas/graph-model/node/condition-node}/condition-element.js +20 -15
  86. package/es/{common/graph-common/node-element → packages/graph-canvas/graph-model/node/condition-node}/condition-element.less +76 -81
  87. package/es/packages/graph-canvas/graph-model/node/condition-node/images/rhombus.svg +3 -0
  88. package/es/{common/graph-common/shape/nodes/ConditionJudgment.d.ts → packages/graph-canvas/graph-model/node/condition-node/index.d.ts} +5 -5
  89. package/es/{common/graph-common/shape/nodes/ConditionJudgment.js → packages/graph-canvas/graph-model/node/condition-node/index.js} +7 -6
  90. package/es/packages/graph-canvas/graph-model/node/index.d.ts +5 -0
  91. package/es/packages/graph-canvas/graph-model/node/index.js +5 -0
  92. package/es/packages/graph-canvas/graph-model/node/logical-node/images/AND.svg +11 -0
  93. package/es/packages/graph-canvas/graph-model/node/logical-node/images/OR.svg +11 -0
  94. package/es/packages/graph-canvas/graph-model/node/logical-node/images/XOR.svg +11 -0
  95. package/es/packages/graph-canvas/graph-model/node/logical-node/images/locking.svg +5 -0
  96. package/es/packages/graph-canvas/graph-model/node/logical-node/images/unlock.svg +5 -0
  97. package/es/packages/graph-canvas/graph-model/node/logical-node/index.d.ts +6 -0
  98. package/es/{common/graph-common/shape/nodes/LogicalNode.js → packages/graph-canvas/graph-model/node/logical-node/index.js} +15 -15
  99. package/es/packages/graph-canvas/graph-model/node/logical-node/logical-element.d.ts +9 -0
  100. package/es/{common/graph-common/node-element → packages/graph-canvas/graph-model/node/logical-node}/logical-element.js +36 -19
  101. package/es/{common/graph-common/node-element → packages/graph-canvas/graph-model/node/logical-node}/logical-element.less +4 -9
  102. package/es/packages/graph-canvas/graph-model/node/style.less +8 -0
  103. package/es/{common → packages/graph-canvas}/graph-utils/graph.d.ts +87 -83
  104. package/es/{common → packages/graph-canvas}/graph-utils/graph.js +8 -4
  105. package/es/{pages/rx-models/experiment-graph.d.ts → packages/graph-canvas/index.d.ts} +79 -82
  106. package/es/{pages/rx-models/experiment-graph.js → packages/graph-canvas/index.js} +285 -252
  107. package/es/packages/graph-canvas/node-types.d.ts +6 -0
  108. package/es/packages/graph-canvas/node-types.js +54 -0
  109. package/es/packages/graph-canvas/typings.d.ts +5 -0
  110. package/es/{common/constants → packages/graph-common}/global.d.ts +1 -1
  111. package/es/{common/constants → packages/graph-common}/graph.d.ts +12 -10
  112. package/es/{common/constants → packages/graph-common}/graph.js +4 -2
  113. package/es/{pages/rx-models → packages/graph-core}/graph-util.d.ts +182 -186
  114. package/es/{pages/rx-models → packages/graph-core}/graph-util.js +8 -15
  115. package/es/{pages/rx-models/graph-core.d.ts → packages/graph-core/index.d.ts} +96 -96
  116. package/es/{pages/rx-models/graph-core.js → packages/graph-core/index.js} +119 -87
  117. package/es/packages/graph-core/typing.d.ts +107 -0
  118. package/es/{common/graph-common → packages/graph-model}/connector/index.d.ts +1 -1
  119. package/es/packages/graph-model/connector/index.js +14 -0
  120. package/es/packages/graph-model/edge/edge.less +8 -0
  121. package/es/packages/graph-model/edge/index.d.ts +5 -0
  122. package/es/{common/graph-common/shape/edge.js → packages/graph-model/edge/index.js} +10 -61
  123. package/es/packages/graph-model/node/index.d.ts +7 -0
  124. package/es/{common/graph-common/shape/nodes/BaseNode.js → packages/graph-model/node/index.js} +12 -3
  125. package/es/{common/graph-common/node-element/common-element.less → packages/graph-model/node/node-basic.less} +1 -0
  126. package/es/{hooks → packages/hooks}/useObservableState.d.ts +3 -3
  127. package/es/packages/hooks/withMode.d.ts +3 -0
  128. package/es/packages/hooks/withMode.js +12 -0
  129. package/es/style/default.less +8 -0
  130. package/es/style/svgRaw.d.ts +1 -0
  131. package/es/style/svgRaw.js +1 -0
  132. package/es/typings.d.ts +2 -8
  133. package/es/utils/utils.d.ts +1 -1
  134. package/lib/assets/AND.svg +11 -0
  135. package/lib/assets/OR.svg +11 -0
  136. package/lib/assets/XOR.svg +11 -0
  137. package/lib/assets/add.svg +13 -0
  138. package/lib/assets/alarm.svg +11 -0
  139. package/lib/assets/application.svg +11 -0
  140. package/lib/assets/cancel.svg +13 -0
  141. package/lib/assets/check.svg +12 -0
  142. package/lib/assets/condition.svg +12 -0
  143. package/lib/assets/control.svg +11 -0
  144. package/lib/assets/decive.svg +11 -0
  145. package/lib/assets/delete.svg +11 -0
  146. package/lib/assets/device.svg +11 -0
  147. package/lib/assets/edit.svg +11 -0
  148. package/lib/assets/hand.svg +11 -0
  149. package/lib/assets/link.svg +11 -0
  150. package/lib/assets/lock.svg +8 -0
  151. package/lib/assets/logical.svg +12 -0
  152. package/lib/assets/notice.svg +11 -0
  153. package/lib/assets/order.svg +11 -0
  154. package/lib/assets/relation.svg +11 -0
  155. package/lib/assets/rhombus.svg +3 -0
  156. package/lib/assets/save.svg +13 -0
  157. package/lib/assets/time.svg +11 -0
  158. package/lib/assets/variate.svg +12 -0
  159. package/lib/components/canvas/component-tree-panel/category-tree/category-type.d.ts +1 -0
  160. package/lib/components/canvas/component-tree-panel/category-tree/category-type.js +111 -0
  161. package/lib/components/canvas/component-tree-panel/category-tree/index.d.ts +17 -0
  162. package/lib/components/canvas/component-tree-panel/category-tree/index.js +115 -0
  163. package/lib/components/canvas/component-tree-panel/category-tree/index.less +36 -0
  164. package/lib/components/canvas/component-tree-panel/category-tree/node-title.d.ts +12 -0
  165. package/lib/components/canvas/component-tree-panel/category-tree/node-title.js +75 -0
  166. package/lib/components/canvas/component-tree-panel/category-tree/node-title.less +113 -0
  167. package/lib/components/canvas/component-tree-panel/index.d.ts +17 -0
  168. package/lib/components/canvas/component-tree-panel/index.js +33 -0
  169. package/lib/components/canvas/component-tree-panel/index.less +52 -0
  170. package/lib/components/canvas/config-panel/components/condition-configuration/configure-modal/data-origin.d.ts +49 -0
  171. package/lib/components/canvas/config-panel/components/condition-configuration/configure-modal/data-origin.js +229 -0
  172. package/lib/components/canvas/config-panel/components/condition-configuration/configure-modal/index.d.ts +11 -0
  173. package/lib/components/canvas/config-panel/components/condition-configuration/configure-modal/index.js +187 -0
  174. package/lib/components/canvas/config-panel/components/condition-configuration/configure-modal/style.less +13 -0
  175. package/lib/components/canvas/config-panel/components/condition-configuration/cross-line.d.ts +9 -0
  176. package/lib/components/canvas/config-panel/components/condition-configuration/cross-line.js +57 -0
  177. package/lib/components/canvas/config-panel/components/condition-configuration/index.d.ts +10 -0
  178. package/lib/components/canvas/config-panel/components/condition-configuration/index.js +216 -0
  179. package/lib/components/canvas/config-panel/components/condition-configuration/style.less +74 -0
  180. package/lib/components/canvas/config-panel/components/time-trigger/components/cycle-time.d.ts +9 -0
  181. package/lib/components/canvas/config-panel/components/time-trigger/components/cycle-time.js +108 -0
  182. package/lib/components/canvas/config-panel/components/time-trigger/components/time-horizon.d.ts +10 -0
  183. package/lib/components/canvas/config-panel/components/time-trigger/components/time-horizon.js +78 -0
  184. package/lib/components/canvas/config-panel/components/time-trigger/delay-time.d.ts +9 -0
  185. package/lib/components/canvas/config-panel/components/time-trigger/delay-time.js +33 -0
  186. package/lib/components/canvas/config-panel/components/time-trigger/effective-time.d.ts +7 -0
  187. package/lib/components/canvas/config-panel/components/time-trigger/effective-time.js +58 -0
  188. package/lib/components/canvas/config-panel/components/time-trigger/index.d.ts +9 -0
  189. package/lib/components/canvas/config-panel/components/time-trigger/index.js +114 -0
  190. package/lib/components/canvas/config-panel/components/time-trigger/interval-time.d.ts +9 -0
  191. package/lib/components/canvas/config-panel/components/time-trigger/interval-time.js +63 -0
  192. package/lib/components/canvas/config-panel/components/time-trigger/persistent-time.d.ts +9 -0
  193. package/lib/components/canvas/config-panel/components/time-trigger/persistent-time.js +33 -0
  194. package/lib/components/canvas/config-panel/components/time-trigger/section-Detail.d.ts +10 -0
  195. package/lib/components/canvas/config-panel/components/time-trigger/section-Detail.js +140 -0
  196. package/lib/components/canvas/config-panel/components/time-trigger/section-time.d.ts +9 -0
  197. package/lib/components/canvas/config-panel/components/time-trigger/section-time.js +96 -0
  198. package/lib/components/canvas/config-panel/components/time-trigger/timing-time.d.ts +9 -0
  199. package/lib/components/canvas/config-panel/components/time-trigger/timing-time.js +65 -0
  200. package/lib/components/canvas/config-panel/config-common.d.ts +38 -0
  201. package/lib/components/canvas/config-panel/config-common.js +152 -0
  202. package/lib/components/canvas/config-panel/index.d.ts +14 -0
  203. package/lib/components/canvas/config-panel/index.js +68 -0
  204. package/lib/components/canvas/config-panel/node-form.d.ts +23 -0
  205. package/lib/components/canvas/config-panel/node-form.js +97 -0
  206. package/lib/components/canvas/config-panel/style.less +90 -0
  207. package/lib/components/canvas/dag-canvas/canvas-content.d.ts +11 -0
  208. package/lib/components/canvas/dag-canvas/canvas-content.js +130 -0
  209. package/lib/components/canvas/dag-canvas/canvas-content.less +5 -0
  210. package/lib/components/canvas/dag-canvas/index.d.ts +23 -0
  211. package/lib/components/canvas/dag-canvas/index.js +53 -0
  212. package/lib/components/canvas/dag-canvas/index.less +11 -0
  213. package/lib/components/canvas/dag-canvas/preview.d.ts +10 -0
  214. package/lib/components/canvas/dag-canvas/preview.js +73 -0
  215. package/lib/components/canvas/index.d.ts +48 -0
  216. package/lib/components/canvas/index.js +107 -0
  217. package/lib/components/canvas/index.less +50 -0
  218. package/lib/components/canvas/strategy-header/index.d.ts +48 -0
  219. package/lib/components/canvas/strategy-header/index.js +229 -0
  220. package/lib/components/canvas/strategy-header/style.less +23 -0
  221. package/lib/components/canvas/strategy-header/theme-switch/index.d.ts +4 -0
  222. package/lib/components/canvas/strategy-header/theme-switch/index.js +30 -0
  223. package/lib/components/canvas/strategy-header/theme-switch/style.less +11 -0
  224. package/lib/index.d.ts +9 -0
  225. package/lib/index.js +71 -0
  226. package/lib/packages/graph-canvas/graph-common.d.ts +19 -0
  227. package/lib/packages/graph-canvas/graph-common.js +27 -0
  228. package/lib/packages/graph-canvas/graph-model/edge/group-edge/edge.less +8 -0
  229. package/lib/packages/graph-canvas/graph-model/edge/group-edge/index.d.ts +4 -0
  230. package/lib/packages/graph-canvas/graph-model/edge/group-edge/index.js +74 -0
  231. package/lib/packages/graph-canvas/graph-model/edge/index.d.ts +2 -0
  232. package/lib/packages/graph-canvas/graph-model/edge/index.js +15 -0
  233. package/lib/packages/graph-canvas/graph-model/node/application-node/application-element.d.ts +9 -0
  234. package/lib/packages/graph-canvas/graph-model/node/application-node/application-element.js +31 -0
  235. package/lib/packages/graph-canvas/graph-model/node/application-node/application-element.less +17 -0
  236. package/lib/packages/graph-canvas/graph-model/node/application-node/index.d.ts +7 -0
  237. package/lib/packages/graph-canvas/graph-model/node/application-node/index.js +133 -0
  238. package/lib/packages/graph-canvas/graph-model/node/common-node/index.d.ts +7 -0
  239. package/lib/packages/graph-canvas/graph-model/node/common-node/index.js +133 -0
  240. package/lib/packages/graph-canvas/graph-model/node/common-node/node-element.d.ts +9 -0
  241. package/lib/packages/graph-canvas/graph-model/node/common-node/node-element.js +69 -0
  242. package/lib/packages/graph-canvas/graph-model/node/common-node/node-element.less +48 -0
  243. package/{es/common/graph-common/node-element/logical-element.d.ts → lib/packages/graph-canvas/graph-model/node/condition-node/condition-element.d.ts} +9 -9
  244. package/lib/packages/graph-canvas/graph-model/node/condition-node/condition-element.js +81 -0
  245. package/lib/packages/graph-canvas/graph-model/node/condition-node/condition-element.less +76 -0
  246. package/lib/packages/graph-canvas/graph-model/node/condition-node/images/rhombus.svg +3 -0
  247. package/{es/common/graph-common/shape/nodes/LogicalNode.d.ts → lib/packages/graph-canvas/graph-model/node/condition-node/index.d.ts} +5 -5
  248. package/lib/packages/graph-canvas/graph-model/node/condition-node/index.js +143 -0
  249. package/lib/packages/graph-canvas/graph-model/node/index.d.ts +5 -0
  250. package/lib/packages/graph-canvas/graph-model/node/index.js +39 -0
  251. package/lib/packages/graph-canvas/graph-model/node/logical-node/images/AND.svg +11 -0
  252. package/lib/packages/graph-canvas/graph-model/node/logical-node/images/OR.svg +11 -0
  253. package/lib/packages/graph-canvas/graph-model/node/logical-node/images/XOR.svg +11 -0
  254. package/lib/packages/graph-canvas/graph-model/node/logical-node/images/locking.svg +5 -0
  255. package/lib/packages/graph-canvas/graph-model/node/logical-node/images/unlock.svg +5 -0
  256. package/lib/packages/graph-canvas/graph-model/node/logical-node/index.d.ts +6 -0
  257. package/lib/packages/graph-canvas/graph-model/node/logical-node/index.js +143 -0
  258. package/lib/packages/graph-canvas/graph-model/node/logical-node/logical-element.d.ts +9 -0
  259. package/lib/packages/graph-canvas/graph-model/node/logical-node/logical-element.js +98 -0
  260. package/lib/packages/graph-canvas/graph-model/node/logical-node/logical-element.less +49 -0
  261. package/lib/packages/graph-canvas/graph-model/node/style.less +8 -0
  262. package/lib/packages/graph-canvas/graph-utils/graph.d.ts +87 -0
  263. package/lib/packages/graph-canvas/graph-utils/graph.js +124 -0
  264. package/lib/packages/graph-canvas/index.d.ts +79 -0
  265. package/lib/packages/graph-canvas/index.js +1292 -0
  266. package/lib/packages/graph-canvas/node-types.d.ts +6 -0
  267. package/lib/packages/graph-canvas/node-types.js +66 -0
  268. package/lib/packages/graph-canvas/typings.d.ts +5 -0
  269. package/lib/packages/graph-common/global.d.ts +1 -0
  270. package/lib/packages/graph-common/global.js +8 -0
  271. package/lib/packages/graph-common/graph.d.ts +12 -0
  272. package/lib/packages/graph-common/graph.js +37 -0
  273. package/lib/packages/graph-core/graph-util.d.ts +182 -0
  274. package/lib/packages/graph-core/graph-util.js +368 -0
  275. package/lib/packages/graph-core/index.d.ts +96 -0
  276. package/lib/packages/graph-core/index.js +798 -0
  277. package/lib/packages/graph-core/typing.d.ts +107 -0
  278. package/lib/packages/graph-model/connector/index.d.ts +1 -0
  279. package/lib/packages/graph-model/connector/index.js +17 -0
  280. package/lib/packages/graph-model/edge/edge.less +8 -0
  281. package/lib/packages/graph-model/edge/index.d.ts +5 -0
  282. package/lib/packages/graph-model/edge/index.js +73 -0
  283. package/lib/packages/graph-model/node/index.d.ts +7 -0
  284. package/lib/packages/graph-model/node/index.js +63 -0
  285. package/lib/packages/graph-model/node/node-basic.less +118 -0
  286. package/lib/packages/hooks/useObservableState.d.ts +3 -0
  287. package/lib/packages/hooks/useObservableState.js +55 -0
  288. package/lib/packages/hooks/withMode.d.ts +3 -0
  289. package/lib/packages/hooks/withMode.js +22 -0
  290. package/lib/style/basic.less +12 -0
  291. package/lib/style/default.less +10 -0
  292. package/lib/style/position.less +25 -0
  293. package/lib/style/svgRaw.d.ts +1 -0
  294. package/lib/style/svgRaw.js +8 -0
  295. package/lib/style/theme-light.less +7 -0
  296. package/lib/style/variable.less +3 -0
  297. package/lib/typings.d.ts +8 -0
  298. package/lib/utils/utils.d.ts +1 -0
  299. package/lib/utils/utils.js +13 -0
  300. package/package.json +38 -37
  301. package/tsconfig.json +1 -1
  302. package/es/common/graph-common/category-type.d.ts +0 -16
  303. package/es/common/graph-common/connector/index.js +0 -14
  304. package/es/common/graph-common/node-element/node-group.d.ts +0 -8
  305. package/es/common/graph-common/node-element/node-group.js +0 -395
  306. package/es/common/graph-common/node-element/node-group.less +0 -53
  307. package/es/common/graph-common/node-popover/index.d.ts +0 -7
  308. package/es/common/graph-common/node-popover/index.js +0 -11
  309. package/es/common/graph-common/node-popover/index.less +0 -5
  310. package/es/common/graph-common/node-types.d.ts +0 -28
  311. package/es/common/graph-common/node-types.js +0 -60
  312. package/es/common/graph-common/shape/edge.d.ts +0 -10
  313. package/es/common/graph-common/shape/node.d.ts +0 -6
  314. package/es/common/graph-common/shape/node.js +0 -6
  315. package/es/common/graph-common/shape/nodes/BaseNode.d.ts +0 -4
  316. package/es/common/graph-common/shape/nodes/GroupNode.d.ts +0 -4
  317. package/es/component/cut.d.ts +0 -10
  318. package/es/component/cut.js +0 -34
  319. package/es/component/cut.less +0 -6
  320. package/es/component/item-name.d.ts +0 -6
  321. package/es/component/item-name.js +0 -30
  322. package/es/component/keyword.d.ts +0 -9
  323. package/es/component/keyword.js +0 -26
  324. package/es/component/keyword.less +0 -11
  325. package/es/component/rx-component/rx-input.d.ts +0 -8
  326. package/es/component/rx-component/rx-input.js +0 -47
  327. package/es/hooks/withMode.d.ts +0 -1
  328. package/es/hooks/withMode.js +0 -16
  329. package/es/pages/dag-canvas/preview.js +0 -42
  330. package/es/pages/rx-models/graph-core.less +0 -14
  331. package/es/pages/rx-models/typing.d.ts +0 -126
  332. package/es/pages/strategy-header/index.js +0 -154
  333. /package/es/{pages → components/canvas}/component-tree-panel/category-tree/node-title.less +0 -0
  334. /package/es/{pages → components/canvas}/config-panel/components/time-trigger/delay-time.js +0 -0
  335. /package/es/{pages → components/canvas}/config-panel/components/time-trigger/persistent-time.js +0 -0
  336. /package/es/{pages → components/canvas}/dag-canvas/canvas-content.less +0 -0
  337. /package/es/{pages → components/canvas}/dag-canvas/index.less +0 -0
  338. /package/es/{pages → components/canvas}/strategy-header/theme-switch/style.less +0 -0
  339. /package/es/{common/graph-common/shape → packages/graph-canvas/graph-model/edge/group-edge}/edge.less +0 -0
  340. /package/es/{common/constants → packages/graph-common}/global.js +0 -0
  341. /package/es/{hooks → packages/hooks}/useObservableState.js +0 -0
@@ -0,0 +1,798 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.GraphCore = void 0;
7
+
8
+ var _x = require("@antv/x6");
9
+
10
+ var _rxjs = require("rxjs");
11
+
12
+ var _operators = require("rxjs/operators");
13
+
14
+ var _excluded = ["wrapper", "container", "nodes", "edges"];
15
+
16
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
17
+
18
+ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
19
+
20
+ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
21
+
22
+ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
23
+
24
+ function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
25
+
26
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
27
+
28
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
29
+
30
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
31
+
32
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
33
+
34
+ function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
35
+
36
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
37
+
38
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
39
+
40
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
41
+
42
+ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
43
+
44
+ function setCellsSelectedStatus(cells, selected) {
45
+ cells.forEach(function (cell) {
46
+ var data = cell.getData() || {};
47
+ cell.setData(_objectSpread(_objectSpread({}, data), {}, {
48
+ selected: selected
49
+ }));
50
+ });
51
+ }
52
+
53
+ var GraphCore = /*#__PURE__*/function () {
54
+ // 传入的 nodes 原始信息
55
+ // 传入的 edges 原始信息
56
+ // 当前画布右键点击信息
57
+ // 选中的节点
58
+ // 待复制的节点 id
59
+ // 窗口大小 resize 的订阅
60
+ // 右键菜单的订阅
61
+ // 节点右键菜单的订阅
62
+ // 选中节点的订阅
63
+ // 产生连线的订阅
64
+ // 连线已删除的订阅
65
+ // 节点移动的订阅
66
+ // 删除节点或连线的订阅
67
+ // 复制节点的订阅
68
+ // 撤销
69
+ function GraphCore(options) {
70
+ var _this = this;
71
+
72
+ _classCallCheck(this, GraphCore);
73
+
74
+ _defineProperty(this, "wrapper", void 0);
75
+
76
+ _defineProperty(this, "container", void 0);
77
+
78
+ _defineProperty(this, "nodeMetas", void 0);
79
+
80
+ _defineProperty(this, "edgeMetas", void 0);
81
+
82
+ _defineProperty(this, "options", void 0);
83
+
84
+ _defineProperty(this, "graph", void 0);
85
+
86
+ _defineProperty(this, "contextMenuInfo$", new _rxjs.BehaviorSubject(null));
87
+
88
+ _defineProperty(this, "selectedNodes$", new _rxjs.BehaviorSubject([]));
89
+
90
+ _defineProperty(this, "copyableNodeId$", new _rxjs.BehaviorSubject(''));
91
+
92
+ _defineProperty(this, "windowResizeSub", void 0);
93
+
94
+ _defineProperty(this, "contextMenuSub", void 0);
95
+
96
+ _defineProperty(this, "nodeContextMenuSub", void 0);
97
+
98
+ _defineProperty(this, "selectNodeSub", void 0);
99
+
100
+ _defineProperty(this, "connectNodeSub", void 0);
101
+
102
+ _defineProperty(this, "connectionRemovedSub", void 0);
103
+
104
+ _defineProperty(this, "moveNodesSub", void 0);
105
+
106
+ _defineProperty(this, "deleteNodeOrEdgeSub", void 0);
107
+
108
+ _defineProperty(this, "copyNodeSub", void 0);
109
+
110
+ _defineProperty(this, "undoNode", void 0);
111
+
112
+ _defineProperty(this, "resizeGraph", function () {
113
+ var graph = _this.graph,
114
+ wrapper = _this.wrapper;
115
+
116
+ if (graph && wrapper) {
117
+ requestAnimationFrame(function () {
118
+ var width = wrapper.clientWidth;
119
+ var height = wrapper.clientHeight;
120
+ graph.resize(width, height);
121
+ });
122
+ }
123
+ });
124
+
125
+ _defineProperty(this, "addNode", function (nodeMeta) {
126
+ var _this$nodeMetas;
127
+
128
+ (_this$nodeMetas = _this.nodeMetas) === null || _this$nodeMetas === void 0 ? void 0 : _this$nodeMetas.push(nodeMeta);
129
+ return _this.renderNode(nodeMeta);
130
+ });
131
+
132
+ _defineProperty(this, "addEdge", function (edgeMeta) {
133
+ var _this$edgeMetas;
134
+
135
+ (_this$edgeMetas = _this.edgeMetas) === null || _this$edgeMetas === void 0 ? void 0 : _this$edgeMetas.push(edgeMeta);
136
+ return _this.renderEdge(edgeMeta);
137
+ });
138
+
139
+ _defineProperty(this, "getNodeById", function (nodeId) {
140
+ var _this$graph;
141
+
142
+ var node = (_this$graph = _this.graph) === null || _this$graph === void 0 ? void 0 : _this$graph.getCellById(nodeId);
143
+
144
+ if (node !== null && node !== void 0 && node.isNode()) {
145
+ return node;
146
+ }
147
+
148
+ return undefined;
149
+ });
150
+
151
+ _defineProperty(this, "getNodes", function () {
152
+ var _this$graph2;
153
+
154
+ return ((_this$graph2 = _this.graph) === null || _this$graph2 === void 0 ? void 0 : _this$graph2.getNodes()) || [];
155
+ });
156
+
157
+ _defineProperty(this, "getEdgeById", function (nodeId) {
158
+ var _this$graph3;
159
+
160
+ var edge = (_this$graph3 = _this.graph) === null || _this$graph3 === void 0 ? void 0 : _this$graph3.getCellById(nodeId);
161
+
162
+ if (edge !== null && edge !== void 0 && edge.isEdge()) {
163
+ return edge;
164
+ }
165
+
166
+ return undefined;
167
+ });
168
+
169
+ _defineProperty(this, "getEdges", function () {
170
+ var _this$graph4;
171
+
172
+ return ((_this$graph4 = _this.graph) === null || _this$graph4 === void 0 ? void 0 : _this$graph4.getEdges()) || [];
173
+ });
174
+
175
+ _defineProperty(this, "getCellById", function (cellId) {
176
+ var _this$graph5;
177
+
178
+ var cell = (_this$graph5 = _this.graph) === null || _this$graph5 === void 0 ? void 0 : _this$graph5.getCellById(cellId);
179
+
180
+ if (cell !== null && cell !== void 0 && cell.isNode() || cell !== null && cell !== void 0 && cell.isEdge()) {
181
+ return cell;
182
+ }
183
+
184
+ return undefined;
185
+ });
186
+
187
+ _defineProperty(this, "getCells", function () {
188
+ var _this$graph6;
189
+
190
+ return ((_this$graph6 = _this.graph) === null || _this$graph6 === void 0 ? void 0 : _this$graph6.getCells()) || [];
191
+ });
192
+
193
+ _defineProperty(this, "updateNodeById", function (nodeId, handler) {
194
+ handler(_this.getNodeById(nodeId));
195
+ });
196
+
197
+ _defineProperty(this, "updateNodes", function (handler) {
198
+ handler(_this.getNodes());
199
+ });
200
+
201
+ _defineProperty(this, "updateEdgeById", function (edgeId, handler) {
202
+ var _this$graph7;
203
+
204
+ var edge = (_this$graph7 = _this.graph) === null || _this$graph7 === void 0 ? void 0 : _this$graph7.getCellById(edgeId);
205
+
206
+ if (edge !== null && edge !== void 0 && edge.isEdge()) {
207
+ handler(edge);
208
+ } else {
209
+ handler(undefined);
210
+ }
211
+ });
212
+
213
+ _defineProperty(this, "updateEdges", function (handler) {
214
+ var _this$graph8;
215
+
216
+ var edges = ((_this$graph8 = _this.graph) === null || _this$graph8 === void 0 ? void 0 : _this$graph8.getEdges()) || [];
217
+ handler(edges);
218
+ });
219
+
220
+ _defineProperty(this, "deleteNodes", function (nodes) {
221
+ var _this$graph9;
222
+
223
+ var target = [].concat(nodes); // @ts-ignore
224
+
225
+ _this.nodeMetas = _this.nodeMetas.filter(function (nodeMeta) {
226
+ return !target.includes(nodeMeta.id);
227
+ });
228
+ (_this$graph9 = _this.graph) === null || _this$graph9 === void 0 ? void 0 : _this$graph9.removeCells(target);
229
+ });
230
+
231
+ _defineProperty(this, "deleteEdges", function (edges) {
232
+ var _this$graph10;
233
+
234
+ var target = [].concat(edges);
235
+ var targetIds = target.map(function (i) {
236
+ return typeof i === 'string' ? i : i.id;
237
+ }); // @ts-ignore
238
+
239
+ _this.edgeMetas = _this.edgeMetas.filter(function (edgeMeta) {
240
+ return !targetIds.includes(edgeMeta.id);
241
+ });
242
+ (_this$graph10 = _this.graph) === null || _this$graph10 === void 0 ? void 0 : _this$graph10.removeCells(target);
243
+ });
244
+
245
+ _defineProperty(this, "clearContextMenuInfo", function () {
246
+ _this.contextMenuInfo$.next(null);
247
+ });
248
+
249
+ _defineProperty(this, "zoom", function (factor) {
250
+ if (typeof factor === 'number') {
251
+ var _this$graph11;
252
+
253
+ (_this$graph11 = _this.graph) === null || _this$graph11 === void 0 ? void 0 : _this$graph11.zoom(factor);
254
+ } else if (factor === 'fit') {
255
+ var _this$graph12;
256
+
257
+ (_this$graph12 = _this.graph) === null || _this$graph12 === void 0 ? void 0 : _this$graph12.zoomToFit({
258
+ padding: 12
259
+ });
260
+ } else if (factor === 'real') {
261
+ var _this$graph13, _this$graph14;
262
+
263
+ (_this$graph13 = _this.graph) === null || _this$graph13 === void 0 ? void 0 : _this$graph13.scale(1);
264
+ (_this$graph14 = _this.graph) === null || _this$graph14 === void 0 ? void 0 : _this$graph14.centerContent();
265
+ }
266
+ });
267
+
268
+ _defineProperty(this, "toggleSelectionEnabled", function (enabled) {
269
+ var graph = _this.graph;
270
+
271
+ if (graph) {
272
+ var needEnableRubberBand = typeof enabled === 'undefined' ? !graph.isRubberbandEnabled() : enabled;
273
+
274
+ if (needEnableRubberBand) {
275
+ graph.disablePanning();
276
+ graph.enableRubberband(); // graph.scroller.widget?.setCursor('crosshair', { silent: true })
277
+ } else {
278
+ graph.enablePanning();
279
+ graph.disableRubberband(); // graph.scroller.widget?.setCursor('grab', { silent: true })
280
+ }
281
+ }
282
+ });
283
+
284
+ _defineProperty(this, "selectNodes", function (ids) {
285
+ var graph = _this.graph;
286
+
287
+ if (graph) {
288
+ var target = [].concat(ids).map(function (i) {
289
+ return i.toString();
290
+ });
291
+ graph.cleanSelection();
292
+ graph.select(target);
293
+
294
+ if (!Array.isArray(ids)) {
295
+ var cell = graph.getCellById(ids);
296
+ graph.scrollToCell(cell);
297
+ }
298
+ }
299
+ });
300
+
301
+ _defineProperty(this, "unSelectNode", function () {
302
+ var graph = _this.graph;
303
+
304
+ if (graph) {
305
+ graph.cleanSelection();
306
+ }
307
+ });
308
+
309
+ _defineProperty(this, "redo", function () {
310
+ var graph = _this.graph;
311
+
312
+ if (graph) {
313
+ graph.redo();
314
+ }
315
+ });
316
+
317
+ _defineProperty(this, "undo", function () {
318
+ var graph = _this.graph;
319
+
320
+ if (graph) {
321
+ graph.undo();
322
+ }
323
+ });
324
+
325
+ _defineProperty(this, "setCopyableNodeId", function (id) {
326
+ _this.copyableNodeId$.next(id);
327
+ });
328
+
329
+ _defineProperty(this, "throwRenderError", function () {
330
+ if (!_this.wrapper) {
331
+ throw new Error('Wrapper element is needed.');
332
+ }
333
+
334
+ if (!_this.container) {
335
+ throw new Error('Container element is needed.');
336
+ }
337
+
338
+ if (!_this.nodeMetas) {
339
+ throw new Error('NodeMetas could not be empty');
340
+ }
341
+
342
+ if (!_this.edgeMetas) {
343
+ throw new Error('EdgeMetas could not be empty');
344
+ }
345
+ });
346
+
347
+ var _wrapper = options.wrapper,
348
+ container = options.container,
349
+ _nodes = options.nodes,
350
+ _edges = options.edges,
351
+ others = _objectWithoutProperties(options, _excluded);
352
+
353
+ this.setMeta(options);
354
+ this.options = others;
355
+ }
356
+
357
+ _createClass(GraphCore, [{
358
+ key: "setMeta",
359
+ value: function setMeta(params) {
360
+ var wrapper = params.wrapper,
361
+ container = params.container,
362
+ nodes = params.nodes,
363
+ edges = params.edges;
364
+
365
+ if (wrapper) {
366
+ this.setWrapper(wrapper);
367
+ }
368
+
369
+ if (container) {
370
+ this.setContainer(container);
371
+ }
372
+
373
+ if (nodes) {
374
+ this.setNodes(nodes);
375
+ }
376
+
377
+ if (edges) {
378
+ this.setEdges(edges);
379
+ }
380
+ }
381
+ }, {
382
+ key: "isMetaValid",
383
+ get: function get() {
384
+ var wrapper = this.wrapper,
385
+ container = this.container,
386
+ nodeMetas = this.nodeMetas,
387
+ edgeMetas = this.edgeMetas;
388
+ return !!wrapper && !!container && !!nodeMetas && !!edgeMetas;
389
+ }
390
+ }, {
391
+ key: "nodes",
392
+ get: function get() {
393
+ var _this$graph15;
394
+
395
+ return ((_this$graph15 = this.graph) === null || _this$graph15 === void 0 ? void 0 : _this$graph15.getNodes()) || [];
396
+ }
397
+ }, {
398
+ key: "setWrapper",
399
+ value: function setWrapper(wrapper) {
400
+ this.wrapper = wrapper;
401
+ }
402
+ }, {
403
+ key: "setContainer",
404
+ value: function setContainer(container) {
405
+ this.container = container;
406
+ this.options.container = container;
407
+ }
408
+ }, {
409
+ key: "setNodes",
410
+ value: function setNodes(nodes) {
411
+ this.nodeMetas = nodes;
412
+ }
413
+ }, {
414
+ key: "setEdges",
415
+ value: function setEdges(edges) {
416
+ this.edgeMetas = edges;
417
+ } // 渲染
418
+
419
+ }, {
420
+ key: "render",
421
+ value: function render(params) {
422
+ var _this2 = this;
423
+
424
+ console.log('<<<<<<< core >>>>>> render');
425
+ this.setMeta(params);
426
+
427
+ if (this.isMetaValid) {
428
+ var wrapper = this.wrapper,
429
+ options = this.options,
430
+ nodeMetas = this.nodeMetas,
431
+ edgeMetas = this.edgeMetas;
432
+ var width = wrapper.clientWidth - 12;
433
+ var height = wrapper.clientHeight;
434
+ var graph = new _x.Graph(_objectSpread(_objectSpread(_objectSpread({}, options), {}, {
435
+ width: width
436
+ }, params.options), {}, {
437
+ height: height
438
+ }));
439
+ this.graph = graph;
440
+ nodeMetas.forEach(function (nodeMeta) {
441
+ return _this2.renderNode(nodeMeta);
442
+ });
443
+ edgeMetas.forEach(function (edgeMeta) {
444
+ return _this2.renderEdge(edgeMeta);
445
+ });
446
+ this.afterLayout();
447
+
448
+ if (graph.isFrozen()) {
449
+ graph.unfreeze();
450
+ }
451
+
452
+ requestAnimationFrame(function () {
453
+ graph.centerContent();
454
+ }); // 处理窗口缩放
455
+
456
+ this.windowResizeSub = (0, _rxjs.fromEventPattern)(function (handler) {
457
+ window.addEventListener('resize', handler);
458
+ }, function (handler) {
459
+ window.removeEventListener('resize', handler);
460
+ }).subscribe(this.resizeGraph); // 处理右键菜单
461
+
462
+ var nodeContextMenuObs = (0, _rxjs.fromEventPattern)(function (handler) {
463
+ graph.on('node:contextmenu', function (data) {
464
+ handler({
465
+ type: 'node',
466
+ data: data
467
+ });
468
+ });
469
+ }, function (handler) {
470
+ graph.off('node:contextmenu', handler);
471
+ });
472
+ var edgeContextMenuObs = (0, _rxjs.fromEventPattern)(function (handler) {
473
+ graph.on('edge:contextmenu', function (data) {
474
+ handler({
475
+ type: 'edge',
476
+ data: data
477
+ });
478
+ });
479
+ }, function (handler) {
480
+ graph.off('edge:contextmenu', handler);
481
+ });
482
+ var graphContextMenuObs = (0, _rxjs.fromEventPattern)(function (handler) {
483
+ graph.on('blank:contextmenu', function (data) {
484
+ handler({
485
+ type: 'graph',
486
+ data: data
487
+ });
488
+ });
489
+ }, function (handler) {
490
+ graph.off('edge:contextmenu', handler);
491
+ });
492
+ this.nodeContextMenuSub = nodeContextMenuObs.subscribe(function (data) {
493
+ _this2.onNodeContextMenu(data);
494
+ });
495
+ this.contextMenuSub = (0, _rxjs.merge)(nodeContextMenuObs, edgeContextMenuObs, graphContextMenuObs).subscribe(function (data) {
496
+ if (_this2.validateContextMenu(data)) {
497
+ _this2.contextMenuInfo$.next(data);
498
+
499
+ _this2.onContextMenu(data);
500
+ }
501
+ }); // 处理节点选中事件
502
+
503
+ this.selectNodeSub = (0, _rxjs.fromEventPattern)(function (handler) {
504
+ graph.on('selection:changed', handler);
505
+ }, function (handler) {
506
+ graph.off('selection:changed', handler);
507
+ }).subscribe(function (args) {
508
+ var removed = args.removed,
509
+ selected = args.selected;
510
+ setCellsSelectedStatus(removed, false);
511
+ setCellsSelectedStatus(selected, true);
512
+
513
+ _this2.onSelectNodes(selected);
514
+ }); // 处理产生连线事件
515
+
516
+ this.connectNodeSub = (0, _rxjs.fromEventPattern)(function (handler) {
517
+ graph.on('edge:connected', handler);
518
+ }, function (handler) {
519
+ graph.off('edge:connected', handler);
520
+ }).subscribe(function (args) {
521
+ // TODO connectNode
522
+ console.log('<<<<<<< core >>>>>> connectNode', args);
523
+
524
+ _this2.onConnectNode(args);
525
+ }); // 处理连线删除事件
526
+
527
+ this.connectionRemovedSub = (0, _rxjs.fromEventPattern)(function (handler) {
528
+ graph.on('edge:removed', handler);
529
+ }, function (handler) {
530
+ graph.off('edge:removed', handler);
531
+ } // eslint-disable-next-line consistent-return
532
+ ).subscribe(function (args) {
533
+ _this2.onConnectionRemoved(args);
534
+ }); // 处理节点移动事件
535
+
536
+ var moveStarted = false; // 因为需要对移动事件做分片,区分两次移动事件,所以引入一个记录移动开始的变量
537
+
538
+ this.moveNodesSub = (0, _rxjs.fromEventPattern)(function (handler) {
539
+ graph.on('node:change:position', handler);
540
+ }, function (handler) {
541
+ graph.off('node:change:position', handler);
542
+ }).pipe((0, _operators.tap)(function (args) {
543
+ _this2.onMoveNodeStart(args);
544
+ }), (0, _operators.scan)(function (accum, args) {
545
+ var currentAccum = !moveStarted ? [] : accum;
546
+ var node = args.node;
547
+ var id = node.id;
548
+ var matchItemIndex = currentAccum.findIndex(function (item) {
549
+ return item.id === id;
550
+ });
551
+
552
+ if (matchItemIndex > -1) {
553
+ currentAccum.splice(matchItemIndex, 1, {
554
+ id: id,
555
+ data: args
556
+ });
557
+ } else {
558
+ currentAccum.push({
559
+ id: id,
560
+ data: args
561
+ });
562
+ }
563
+
564
+ return currentAccum;
565
+ }, []), (0, _operators.tap)(function () {
566
+ if (!moveStarted) {
567
+ moveStarted = true;
568
+ }
569
+ }), (0, _operators.debounceTime)(300), (0, _operators.tap)(function () {
570
+ if (moveStarted) {
571
+ moveStarted = false;
572
+ }
573
+ }), (0, _operators.map)(function (items) {
574
+ return items.map(function (item) {
575
+ return item.data;
576
+ });
577
+ })).subscribe(function (movedNodes) {
578
+ _this2.onMoveNodes(movedNodes);
579
+ }); // 处理删除节点或连线事件
580
+
581
+ this.deleteNodeOrEdgeSub = (0, _rxjs.fromEventPattern)(function (handler) {
582
+ graph.bindKey(['delete', 'backspace'], handler);
583
+ }, function () {
584
+ graph.unbindKey(['delete', 'backspace']);
585
+ }).subscribe(function () {
586
+ var selectedCells = graph.getSelectedCells();
587
+ var selectedNodes = selectedCells.filter(function (cell) {
588
+ return cell.isNode();
589
+ });
590
+ var selectedEdges = selectedCells.filter(function (cell) {
591
+ return cell.isEdge();
592
+ });
593
+
594
+ _this2.onDeleteNodeOrEdge({
595
+ nodes: selectedNodes,
596
+ edges: selectedEdges
597
+ });
598
+ }); // 处理删除节点或连线事件
599
+
600
+ this.undoNode = (0, _rxjs.fromEventPattern)(function (handler) {
601
+ graph.bindKey(['ctrl+z'], handler);
602
+ }, function () {
603
+ graph.unbindKey(['ctrl+z']);
604
+ }).subscribe(function () {
605
+ graph.undo();
606
+ }); // 处理节点复制事件
607
+
608
+ this.copyNodeSub = (0, _rxjs.fromEventPattern)(function (handler) {
609
+ graph.bindKey(['command+c', 'ctrl+c', 'command+v', 'ctrl+v'], handler);
610
+ }, function () {
611
+ graph.unbindKey(['command+c', 'ctrl+c', 'command+v', 'ctrl+v']);
612
+ }).subscribe(function (args) {
613
+ var _args = _slicedToArray(args, 2),
614
+ action = _args[1];
615
+
616
+ var selectedCells = graph.getSelectedCells().filter(function (cell) {
617
+ return _this2.validateNodeCopyable(cell);
618
+ });
619
+
620
+ var copyableNodeId = _this2.copyableNodeId$.getValue();
621
+
622
+ var copyableNode;
623
+
624
+ if (copyableNodeId) {
625
+ copyableNode = graph.getCellById(copyableNodeId);
626
+ }
627
+
628
+ switch (action) {
629
+ case 'command+c':
630
+ case 'ctrl+c':
631
+ if (selectedCells !== null && selectedCells !== void 0 && selectedCells.length) {
632
+ _this2.setCopyableNodeId(selectedCells[0].id); // 当前只支持单节点的复制粘贴
633
+
634
+ }
635
+
636
+ break;
637
+
638
+ case 'command+v':
639
+ case 'ctrl+v':
640
+ // @ts-ignore
641
+ if (copyableNode) {
642
+ _this2.onCopyNode(copyableNode);
643
+ }
644
+
645
+ break;
646
+
647
+ default:
648
+ }
649
+ });
650
+ } else {
651
+ this.throwRenderError();
652
+ }
653
+ }
654
+ }, {
655
+ key: "renderNode",
656
+ value: function renderNode(nodeMeta) {
657
+ console.log('<<<<<<< core >>>>>> renderNode => ', nodeMeta);
658
+ return this.graph.addNode(nodeMeta);
659
+ }
660
+ }, {
661
+ key: "renderEdge",
662
+ value: function renderEdge(edgeMeta) {
663
+ console.log('<<<<<<< core >>>>>> renderEdge => ', edgeMeta);
664
+ return this.graph.addEdge(edgeMeta);
665
+ }
666
+ }, {
667
+ key: "afterLayout",
668
+ value: function afterLayout() {
669
+ if (process.env.NODE_ENV === 'development') {
670
+ console.log('<<<<<<< core >>>>>> [GraphCore] call afterLayout');
671
+ }
672
+ }
673
+ }, {
674
+ key: "validateContextMenu",
675
+ value: function validateContextMenu(data) {
676
+ return !!data;
677
+ }
678
+ }, {
679
+ key: "onContextMenu",
680
+ value: function onContextMenu(data) {
681
+ if (process.env.NODE_ENV === 'development') {
682
+ console.log('<<<<<<< core >>>>>> [GraphCore] context menu info:', data);
683
+ }
684
+ }
685
+ }, {
686
+ key: "onNodeContextMenu",
687
+ value: function onNodeContextMenu(data) {
688
+ if (process.env.NODE_ENV === 'development') {
689
+ console.log('<<<<<<< core >>>>>> [GraphCore] context menu info:', data);
690
+ }
691
+ }
692
+ }, {
693
+ key: "onSelectNodes",
694
+ value: function onSelectNodes(nodes) {
695
+ this.selectedNodes$.next(nodes);
696
+
697
+ if (process.env.NODE_ENV === 'development') {
698
+ console.log('<<<<<<< core >>>>>> [GraphCore] select nodes:', nodes);
699
+ }
700
+ }
701
+ }, {
702
+ key: "onConnectNode",
703
+ value: function onConnectNode(args) {
704
+ if (process.env.NODE_ENV === 'development') {
705
+ console.log('<<<<<<< core >>>>>> [GraphCore] connect nodes:', args);
706
+ }
707
+ }
708
+ }, {
709
+ key: "onConnectionRemoved",
710
+ value: function onConnectionRemoved(args) {
711
+ if (process.env.NODE_ENV === 'development') {
712
+ console.log('<<<<<<< core >>>>>> [GraphCore] delete connection:', args);
713
+ }
714
+ }
715
+ }, {
716
+ key: "onMoveNodeStart",
717
+ value: function onMoveNodeStart(args) {
718
+ if (process.env.NODE_ENV === 'development') {
719
+ console.log('<<<<<<< core >>>>>> [GraphCore] move nodes start:', args);
720
+ }
721
+ }
722
+ }, {
723
+ key: "onMoveNodes",
724
+ value: function onMoveNodes(args) {
725
+ if (process.env.NODE_ENV === 'development') {
726
+ console.log('<<<<<<< core >>>>>> [GraphCore] move nodes:', args);
727
+ }
728
+ } // 按下删除键的回调,默认参数为当前选中的节点和边
729
+
730
+ }, {
731
+ key: "onDeleteNodeOrEdge",
732
+ value: function onDeleteNodeOrEdge(args) {
733
+ if (process.env.NODE_ENV === 'development') {
734
+ console.log('<<<<<<< core >>>>>> [GraphCore] delete nodes or edge:', args);
735
+ }
736
+ } // 校验节点是否可复制,为 true 则可被用于复制
737
+
738
+ }, {
739
+ key: "validateNodeCopyable",
740
+ value: function validateNodeCopyable(node) {
741
+ if (process.env.NODE_ENV === 'development') {
742
+ console.log('<<<<<<< core >>>>>> [GraphCore] validate nodes copyable:', node);
743
+ }
744
+
745
+ return true;
746
+ } // 按下粘贴键的回调,默认参数为待复制的节点
747
+
748
+ }, {
749
+ key: "onCopyNode",
750
+ value: function onCopyNode(copyNode) {
751
+ if (process.env.NODE_ENV === 'development') {
752
+ console.log('<<<<<<< core >>>>>> [GraphCore] copy nodes:', copyNode);
753
+ }
754
+ }
755
+ /* 以下为主动触发的方法 */
756
+
757
+ }, {
758
+ key: "dispose",
759
+ value: // 注销
760
+ function dispose() {
761
+ var _this$windowResizeSub, _this$contextMenuSub, _this$nodeContextMenu, _this$selectNodeSub, _this$connectNodeSub, _this$connectionRemov, _this$moveNodesSub, _this$deleteNodeOrEdg, _this$copyNodeSub;
762
+
763
+ (_this$windowResizeSub = this.windowResizeSub) === null || _this$windowResizeSub === void 0 ? void 0 : _this$windowResizeSub.unsubscribe();
764
+ (_this$contextMenuSub = this.contextMenuSub) === null || _this$contextMenuSub === void 0 ? void 0 : _this$contextMenuSub.unsubscribe();
765
+ (_this$nodeContextMenu = this.nodeContextMenuSub) === null || _this$nodeContextMenu === void 0 ? void 0 : _this$nodeContextMenu.unsubscribe();
766
+ (_this$selectNodeSub = this.selectNodeSub) === null || _this$selectNodeSub === void 0 ? void 0 : _this$selectNodeSub.unsubscribe();
767
+ (_this$connectNodeSub = this.connectNodeSub) === null || _this$connectNodeSub === void 0 ? void 0 : _this$connectNodeSub.unsubscribe();
768
+ (_this$connectionRemov = this.connectionRemovedSub) === null || _this$connectionRemov === void 0 ? void 0 : _this$connectionRemov.unsubscribe();
769
+ (_this$moveNodesSub = this.moveNodesSub) === null || _this$moveNodesSub === void 0 ? void 0 : _this$moveNodesSub.unsubscribe();
770
+ (_this$deleteNodeOrEdg = this.deleteNodeOrEdgeSub) === null || _this$deleteNodeOrEdg === void 0 ? void 0 : _this$deleteNodeOrEdg.unsubscribe();
771
+ (_this$copyNodeSub = this.copyNodeSub) === null || _this$copyNodeSub === void 0 ? void 0 : _this$copyNodeSub.unsubscribe(); // ! 这一步要注意放在图的事件订阅都取消了之后
772
+
773
+ if (this.wrapper) {
774
+ var _this$graph16;
775
+
776
+ var graphScroller = this.wrapper.querySelector('.x6-graph-scroller');
777
+
778
+ if (graphScroller) {
779
+ graphScroller.innerHTML = '';
780
+ graphScroller.setAttribute('style', '');
781
+ graphScroller.setAttribute('class', '');
782
+
783
+ if (this.container) {
784
+ this.container.innerHTML = '';
785
+ this.container.setAttribute('style', '');
786
+ this.container.setAttribute('class', '');
787
+ }
788
+ }
789
+
790
+ (_this$graph16 = this.graph) === null || _this$graph16 === void 0 ? void 0 : _this$graph16.dispose();
791
+ }
792
+ }
793
+ }]);
794
+
795
+ return GraphCore;
796
+ }();
797
+
798
+ exports.GraphCore = GraphCore;