@logicflow/core 2.2.0 → 2.2.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 (236) hide show
  1. package/dist/index.css +3 -2
  2. package/dist/index.min.js +1 -1
  3. package/dist/index.min.js.map +1 -1
  4. package/es/LogicFlow.d.ts +9 -0
  5. package/es/LogicFlow.js +0 -1
  6. package/es/constant/index.d.ts +1 -1
  7. package/es/constant/index.js +1 -1
  8. package/es/constant/theme.d.ts +136 -0
  9. package/es/constant/theme.js +680 -0
  10. package/es/index.css +3 -2
  11. package/es/model/GraphModel.d.ts +10 -2
  12. package/es/model/GraphModel.js +48 -14
  13. package/es/model/TransformModel.js +9 -9
  14. package/es/model/edge/BaseEdgeModel.js +7 -2
  15. package/es/model/edge/PolylineEdgeModel.d.ts +7 -0
  16. package/es/model/edge/PolylineEdgeModel.js +136 -7
  17. package/es/model/node/BaseNodeModel.d.ts +12 -1
  18. package/es/model/node/BaseNodeModel.js +9 -2
  19. package/es/model/node/HtmlNodeModel.d.ts +12 -0
  20. package/es/model/node/HtmlNodeModel.js +19 -0
  21. package/es/model/node/PolygonNodeModel.js +3 -3
  22. package/es/options.d.ts +4 -2
  23. package/es/style/index.css +3 -2
  24. package/es/style/index.less +3 -2
  25. package/es/style/raw.d.ts +1 -1
  26. package/es/style/raw.js +1 -1
  27. package/es/tool/MultipleSelectTool.js +10 -5
  28. package/es/util/drag.js +0 -1
  29. package/es/util/edge.d.ts +40 -1
  30. package/es/util/edge.js +43 -9
  31. package/es/util/geometry.d.ts +8 -0
  32. package/es/util/geometry.js +79 -0
  33. package/es/util/theme.d.ts +2 -65
  34. package/es/util/theme.js +4 -281
  35. package/es/view/Anchor.d.ts +1 -0
  36. package/es/view/Anchor.js +24 -21
  37. package/es/view/Control.d.ts +5 -0
  38. package/es/view/Control.js +44 -57
  39. package/es/view/edge/BaseEdge.js +9 -0
  40. package/es/view/edge/PolylineEdge.js +13 -2
  41. package/es/view/node/BaseNode.d.ts +1 -0
  42. package/es/view/node/BaseNode.js +23 -11
  43. package/es/view/node/HtmlNode.js +2 -4
  44. package/es/view/overlay/CanvasOverlay.js +5 -2
  45. package/es/view/overlay/Grid.d.ts +12 -1
  46. package/es/view/overlay/Grid.js +85 -23
  47. package/es/view/overlay/OutlineOverlay.d.ts +1 -0
  48. package/es/view/overlay/OutlineOverlay.js +18 -17
  49. package/es/view/overlay/gridConfig.d.ts +46 -0
  50. package/es/view/overlay/gridConfig.js +99 -0
  51. package/es/view/shape/Polygon.d.ts +0 -7
  52. package/es/view/shape/Polygon.js +12 -43
  53. package/lib/LogicFlow.d.ts +9 -0
  54. package/lib/LogicFlow.js +0 -1
  55. package/lib/constant/index.d.ts +1 -1
  56. package/lib/constant/index.js +16 -2
  57. package/lib/constant/theme.d.ts +136 -0
  58. package/lib/constant/theme.js +683 -0
  59. package/lib/index.css +3 -2
  60. package/lib/model/GraphModel.d.ts +10 -2
  61. package/lib/model/GraphModel.js +49 -15
  62. package/lib/model/TransformModel.js +9 -9
  63. package/lib/model/edge/BaseEdgeModel.js +7 -2
  64. package/lib/model/edge/PolylineEdgeModel.d.ts +7 -0
  65. package/lib/model/edge/PolylineEdgeModel.js +136 -7
  66. package/lib/model/node/BaseNodeModel.d.ts +12 -1
  67. package/lib/model/node/BaseNodeModel.js +9 -2
  68. package/lib/model/node/HtmlNodeModel.d.ts +12 -0
  69. package/lib/model/node/HtmlNodeModel.js +19 -0
  70. package/lib/model/node/PolygonNodeModel.js +3 -3
  71. package/lib/options.d.ts +4 -2
  72. package/lib/style/index.css +3 -2
  73. package/lib/style/index.less +3 -2
  74. package/lib/style/raw.d.ts +1 -1
  75. package/lib/style/raw.js +1 -1
  76. package/lib/tool/MultipleSelectTool.js +10 -5
  77. package/lib/util/drag.js +0 -1
  78. package/lib/util/edge.d.ts +40 -1
  79. package/lib/util/edge.js +43 -9
  80. package/lib/util/geometry.d.ts +8 -0
  81. package/lib/util/geometry.js +81 -1
  82. package/lib/util/theme.d.ts +2 -65
  83. package/lib/util/theme.js +15 -292
  84. package/lib/view/Anchor.d.ts +1 -0
  85. package/lib/view/Anchor.js +24 -21
  86. package/lib/view/Control.d.ts +5 -0
  87. package/lib/view/Control.js +44 -57
  88. package/lib/view/edge/BaseEdge.js +9 -0
  89. package/lib/view/edge/PolylineEdge.js +13 -2
  90. package/lib/view/node/BaseNode.d.ts +1 -0
  91. package/lib/view/node/BaseNode.js +22 -10
  92. package/lib/view/node/HtmlNode.js +1 -3
  93. package/lib/view/overlay/CanvasOverlay.js +5 -2
  94. package/lib/view/overlay/Grid.d.ts +12 -1
  95. package/lib/view/overlay/Grid.js +83 -21
  96. package/lib/view/overlay/OutlineOverlay.d.ts +1 -0
  97. package/lib/view/overlay/OutlineOverlay.js +18 -17
  98. package/lib/view/overlay/gridConfig.d.ts +46 -0
  99. package/lib/view/overlay/gridConfig.js +104 -0
  100. package/lib/view/shape/Polygon.d.ts +0 -7
  101. package/lib/view/shape/Polygon.js +13 -45
  102. package/package.json +6 -1
  103. package/.turbo/turbo-build$colon$dev.log +0 -10
  104. package/.turbo/turbo-build.log +0 -33
  105. package/CHANGELOG.md +0 -1849
  106. package/__tests__/algorithm/egde.test.ts +0 -131
  107. package/__tests__/algorithm/index.test.ts +0 -74
  108. package/__tests__/algorithm/outline.test.ts +0 -43
  109. package/__tests__/bugs/1545-spec.test.ts +0 -42
  110. package/__tests__/event/event.test.ts +0 -22
  111. package/__tests__/history/history.test.ts +0 -28
  112. package/__tests__/logicflow.test.ts +0 -575
  113. package/__tests__/model/graphmodel.test.ts +0 -87
  114. package/__tests__/util/compatible.test.ts +0 -48
  115. package/__tests__/util/edge.test.ts +0 -224
  116. package/__tests__/util/geometry.test.ts +0 -14
  117. package/__tests__/util/graph.test.ts +0 -16
  118. package/__tests__/util/matrix.test.ts +0 -41
  119. package/__tests__/util/node.test.ts +0 -68
  120. package/__tests__/util/sampling.test.ts +0 -12
  121. package/__tests__/util/vector.test.ts +0 -50
  122. package/__tests__/util/zIndex.test.ts +0 -10
  123. package/src/LogicFlow.tsx +0 -2008
  124. package/src/algorithm/edge.ts +0 -67
  125. package/src/algorithm/index.ts +0 -70
  126. package/src/algorithm/outline.ts +0 -77
  127. package/src/algorithm/rotate.ts +0 -55
  128. package/src/common/drag.ts +0 -219
  129. package/src/common/history.ts +0 -108
  130. package/src/common/index.ts +0 -6
  131. package/src/common/keyboard.ts +0 -108
  132. package/src/common/matrix.ts +0 -122
  133. package/src/common/vector.ts +0 -93
  134. package/src/constant/index.ts +0 -179
  135. package/src/event/event.md +0 -66
  136. package/src/event/eventArgs.ts +0 -643
  137. package/src/event/eventEmitter.ts +0 -156
  138. package/src/history/index.ts +0 -119
  139. package/src/index.less +0 -1
  140. package/src/index.ts +0 -26
  141. package/src/keyboard/index.ts +0 -112
  142. package/src/keyboard/shortcut.ts +0 -200
  143. package/src/model/BaseModel.ts +0 -250
  144. package/src/model/EditConfigModel.ts +0 -334
  145. package/src/model/GraphModel.ts +0 -1788
  146. package/src/model/NestedTransformModel.ts +0 -121
  147. package/src/model/SnaplineModel.ts +0 -256
  148. package/src/model/TransformModel.ts +0 -258
  149. package/src/model/edge/BaseEdgeModel.ts +0 -777
  150. package/src/model/edge/BezierEdgeModel.ts +0 -197
  151. package/src/model/edge/LineEdgeModel.ts +0 -36
  152. package/src/model/edge/PolylineEdgeModel.ts +0 -672
  153. package/src/model/edge/index.ts +0 -4
  154. package/src/model/index.ts +0 -9
  155. package/src/model/node/BaseNodeModel.ts +0 -949
  156. package/src/model/node/CircleNodeModel.ts +0 -91
  157. package/src/model/node/DiamondNodeModel.ts +0 -132
  158. package/src/model/node/EllipseNodeModel.ts +0 -98
  159. package/src/model/node/HtmlNodeModel.ts +0 -50
  160. package/src/model/node/PolygonNodeModel.ts +0 -150
  161. package/src/model/node/RectNodeModel.ts +0 -69
  162. package/src/model/node/TextNodeModel.ts +0 -54
  163. package/src/model/node/index.ts +0 -8
  164. package/src/options.ts +0 -145
  165. package/src/style/index.less +0 -261
  166. package/src/style/raw.ts +0 -220
  167. package/src/tool/MultipleSelectTool.tsx +0 -132
  168. package/src/tool/TextEditTool.tsx +0 -193
  169. package/src/tool/index.ts +0 -101
  170. package/src/typings.d.ts +0 -5
  171. package/src/util/animation.ts +0 -29
  172. package/src/util/browser.ts +0 -4
  173. package/src/util/compatible.ts +0 -15
  174. package/src/util/drag.ts +0 -220
  175. package/src/util/edge.ts +0 -1060
  176. package/src/util/geometry.ts +0 -55
  177. package/src/util/graph.ts +0 -46
  178. package/src/util/index.ts +0 -17
  179. package/src/util/matrix.ts +0 -129
  180. package/src/util/mobx.ts +0 -23
  181. package/src/util/node.ts +0 -543
  182. package/src/util/raf.ts +0 -28
  183. package/src/util/resize.ts +0 -606
  184. package/src/util/sampling.ts +0 -85
  185. package/src/util/theme.ts +0 -375
  186. package/src/util/uuid.ts +0 -26
  187. package/src/util/vector.ts +0 -93
  188. package/src/util/zIndex.ts +0 -6
  189. package/src/view/Anchor.tsx +0 -445
  190. package/src/view/Control.tsx +0 -512
  191. package/src/view/Graph.tsx +0 -141
  192. package/src/view/Rotate.tsx +0 -113
  193. package/src/view/behavior/dnd.ts +0 -162
  194. package/src/view/behavior/index.ts +0 -2
  195. package/src/view/behavior/snapline.ts +0 -16
  196. package/src/view/edge/AdjustPoint.tsx +0 -425
  197. package/src/view/edge/Arrow.tsx +0 -54
  198. package/src/view/edge/BaseEdge.tsx +0 -650
  199. package/src/view/edge/BezierEdge.tsx +0 -101
  200. package/src/view/edge/LineEdge.tsx +0 -81
  201. package/src/view/edge/PolylineEdge.tsx +0 -299
  202. package/src/view/edge/index.ts +0 -6
  203. package/src/view/index.ts +0 -8
  204. package/src/view/node/BaseNode.tsx +0 -571
  205. package/src/view/node/CircleNode.tsx +0 -21
  206. package/src/view/node/DiamondNode.tsx +0 -24
  207. package/src/view/node/EllipseNode.tsx +0 -22
  208. package/src/view/node/HtmlNode.tsx +0 -95
  209. package/src/view/node/PolygonNode.tsx +0 -28
  210. package/src/view/node/RectNode.tsx +0 -30
  211. package/src/view/node/TextNode.tsx +0 -39
  212. package/src/view/node/index.ts +0 -8
  213. package/src/view/overlay/BackgroundOverlay.tsx +0 -34
  214. package/src/view/overlay/BezierAdjustOverlay.tsx +0 -150
  215. package/src/view/overlay/CanvasOverlay.tsx +0 -288
  216. package/src/view/overlay/Grid.tsx +0 -162
  217. package/src/view/overlay/ModificationOverlay.tsx +0 -31
  218. package/src/view/overlay/OutlineOverlay.tsx +0 -170
  219. package/src/view/overlay/SnaplineOverlay.tsx +0 -44
  220. package/src/view/overlay/ToolOverlay.tsx +0 -65
  221. package/src/view/overlay/getTransformHoc.tsx +0 -50
  222. package/src/view/overlay/index.ts +0 -8
  223. package/src/view/shape/Circle.tsx +0 -41
  224. package/src/view/shape/Ellipse.tsx +0 -42
  225. package/src/view/shape/Line.tsx +0 -39
  226. package/src/view/shape/Path.tsx +0 -22
  227. package/src/view/shape/Polygon.tsx +0 -91
  228. package/src/view/shape/Polyline.tsx +0 -31
  229. package/src/view/shape/Rect.tsx +0 -44
  230. package/src/view/shape/Text.tsx +0 -169
  231. package/src/view/shape/index.ts +0 -8
  232. package/src/view/text/BaseText.tsx +0 -134
  233. package/src/view/text/LineText.tsx +0 -168
  234. package/src/view/text/index.ts +0 -2
  235. package/stats.html +0 -4842
  236. package/tsconfig.json +0 -18
package/src/util/theme.ts DELETED
@@ -1,375 +0,0 @@
1
- import { cloneDeep, merge, assign } from 'lodash-es'
2
- import LogicFlow from '../LogicFlow'
3
-
4
- export const defaultTheme: LogicFlow.Theme = {
5
- baseNode: {
6
- fill: '#fff',
7
- stroke: '#000',
8
- strokeWidth: 2,
9
- },
10
-
11
- baseEdge: {
12
- stroke: '#000',
13
- strokeWidth: 2,
14
- },
15
-
16
- rect: {},
17
- circle: {},
18
- diamond: {},
19
- ellipse: {},
20
- polygon: {},
21
-
22
- text: {
23
- color: '#000',
24
- stroke: 'none',
25
- fontSize: 12,
26
- background: {
27
- fill: 'transparent',
28
- },
29
- },
30
-
31
- anchor: {
32
- stroke: '#000',
33
- fill: '#fff',
34
- r: 4,
35
- hover: {
36
- r: 10,
37
- fill: '#949494',
38
- fillOpacity: 0.5,
39
- stroke: '#949494',
40
- },
41
- },
42
-
43
- anchorLine: {
44
- stroke: '#000',
45
- strokeWidth: 2,
46
- strokeDasharray: '3,2',
47
- },
48
-
49
- nodeText: {
50
- color: '#000',
51
- overflowMode: 'default',
52
- fontSize: 12,
53
- lineHeight: 1.2,
54
- },
55
-
56
- edgeText: {
57
- textWidth: 100,
58
- overflowMode: 'default',
59
- fontSize: 12,
60
- background: {
61
- fill: '#fff',
62
- },
63
- },
64
-
65
- line: {},
66
- polyline: {},
67
-
68
- bezier: {
69
- fill: 'none',
70
- adjustLine: {
71
- stroke: '#949494',
72
- },
73
- adjustAnchor: {
74
- r: 4,
75
- fill: '#949494',
76
- fillOpacity: 1,
77
- stroke: '#949494',
78
- },
79
- },
80
-
81
- arrow: {
82
- offset: 10,
83
- verticalLength: 5, // 箭头垂直于边的距离
84
- },
85
-
86
- snapline: {
87
- stroke: '#949494',
88
- strokeWidth: 1,
89
- },
90
-
91
- edgeAdjust: {
92
- r: 4,
93
- fill: '#fff',
94
- stroke: '#949494',
95
- strokeWidth: 2,
96
- },
97
-
98
- outline: {
99
- fill: 'transparent',
100
- stroke: '#949494',
101
- strokeDasharray: '3,3',
102
- hover: {
103
- stroke: '#949494',
104
- },
105
- },
106
-
107
- edgeAnimation: {
108
- stroke: 'red',
109
- strokeDasharray: '10,10',
110
- strokeDashoffset: '100%',
111
- animationName: 'lf_animate_dash',
112
- animationDuration: '20s',
113
- animationIterationCount: 'infinite',
114
- animationTimingFunction: 'linear',
115
- animationDirection: 'normal',
116
- },
117
-
118
- rotateControl: {
119
- stroke: '#000',
120
- fill: '#fff',
121
- strokeWidth: 1.5,
122
- },
123
-
124
- resizeControl: {
125
- width: 7,
126
- height: 7,
127
- fill: '#fff',
128
- stroke: '#000',
129
- },
130
-
131
- resizeOutline: {
132
- fill: 'none',
133
- stroke: 'transparent', // 矩形默认不显示调整边框
134
- strokeWidth: 1,
135
- strokeDasharray: '3,3',
136
- },
137
- }
138
- export const radiusMode: any = {
139
- rect: { radius: 8 },
140
- diamond: { radius: 8 },
141
- polygon: { radius: 8 },
142
- polyline: { radius: 8 },
143
- arrow: {
144
- strokeLinecap: 'round',
145
- strokeLinejoin: 'round',
146
- offset: 10,
147
- verticalLength: 5, // 箭头垂直于边的距离
148
- },
149
- snapline: {
150
- strokeLinecap: 'round',
151
- strokeLinejoin: 'round',
152
- stroke: '#949494',
153
- strokeWidth: 1,
154
- },
155
- outline: {
156
- radius: 8,
157
- fill: 'transparent',
158
- stroke: '#949494',
159
- strokeDasharray: '3,3',
160
- hover: {
161
- stroke: '#949494',
162
- },
163
- },
164
- resizeOutline: {
165
- radius: 8,
166
- fill: 'none',
167
- stroke: 'transparent', // 矩形默认不显示调整边框
168
- strokeWidth: 1,
169
- strokeDasharray: '3,3',
170
- },
171
- }
172
- export const darkMode: any = {
173
- baseNode: {
174
- fill: '#23272e',
175
- stroke: '#fefeff',
176
- },
177
- baseEdge: {
178
- stroke: '#fefeff',
179
- },
180
- rect: { radius: 8 },
181
- diamond: { radius: 8 },
182
- polygon: { radius: 8 },
183
- polyline: { radius: 8 },
184
- nodeText: {
185
- color: '#fefeff',
186
- overflowMode: 'default',
187
- fontSize: 12,
188
- lineHeight: 1.2,
189
- },
190
- arrow: {
191
- strokeLinecap: 'round',
192
- strokeLinejoin: 'round',
193
- offset: 10,
194
- verticalLength: 5, // 箭头垂直于边的距离
195
- },
196
- snapline: {
197
- strokeLinecap: 'round',
198
- strokeLinejoin: 'round',
199
- stroke: '#949494',
200
- strokeWidth: 1,
201
- },
202
- outline: {
203
- radius: 8,
204
- fill: 'transparent',
205
- stroke: '#949494',
206
- strokeDasharray: '3,3',
207
- hover: {
208
- stroke: '#949494',
209
- },
210
- },
211
- resizeOutline: {
212
- radius: 8,
213
- fill: 'none',
214
- stroke: 'transparent', // 矩形默认不显示调整边框
215
- strokeWidth: 1,
216
- strokeDasharray: '3,3',
217
- },
218
- }
219
- export const colorfulMode: any = {
220
- rect: { fill: '#72CBFF', stroke: '#3ABDF9', radius: 8 },
221
- circle: { fill: '#FFE075', stroke: '#F9CE3A', radius: 8 },
222
- ellipse: { fill: '#FFA8A8', stroke: '#FF6B66', radius: 8 },
223
- text: { fill: '#72CBFF', radius: 8 },
224
- diamond: { fill: '#96F7AF', stroke: '#40EF7E', radius: 8 },
225
- polygon: { fill: '#E0A8FF', stroke: '#C271FF', radius: 8 },
226
- polyline: { radius: 8 },
227
- arrow: {
228
- strokeLinecap: 'round',
229
- strokeLinejoin: 'round',
230
- offset: 10,
231
- verticalLength: 5, // 箭头垂直于边的距离
232
- },
233
- snapline: {
234
- strokeLinecap: 'round',
235
- strokeLinejoin: 'round',
236
- stroke: '#949494',
237
- strokeWidth: 1,
238
- },
239
- outline: {
240
- radius: 8,
241
- fill: 'transparent',
242
- stroke: '#949494',
243
- strokeDasharray: '3,3',
244
- hover: {
245
- stroke: '#949494',
246
- },
247
- },
248
- resizeOutline: {
249
- radius: 8,
250
- fill: 'none',
251
- stroke: 'transparent', // 矩形默认不显示调整边框
252
- strokeWidth: 1,
253
- strokeDasharray: '3,3',
254
- },
255
- }
256
-
257
- export const themeModeMap = {
258
- colorful: colorfulMode,
259
- dark: darkMode,
260
- radius: radiusMode,
261
- default: defaultTheme,
262
- }
263
-
264
- // 不同主题的背景色
265
- export const darkBackground = {
266
- background: '#23272e',
267
- }
268
- export const colorfulBackground = {
269
- background: '#fefeff',
270
- }
271
- export const defaultBackground = {
272
- background: '#ffffff',
273
- }
274
- export const backgroundModeMap = {
275
- colorful: colorfulBackground,
276
- dark: darkBackground,
277
- radius: defaultBackground,
278
- default: defaultBackground,
279
- }
280
-
281
- // 不同主题的网格样式
282
- export const darkGrid = {
283
- color: '#66676a',
284
- thickness: 1,
285
- }
286
- export const colorfulGrid = {
287
- color: '#dadada',
288
- thickness: 1,
289
- }
290
- export const defaultGrid = {
291
- color: '#acacac',
292
- thickness: 1,
293
- }
294
- export const gridModeMap = {
295
- colorful: colorfulGrid,
296
- dark: darkGrid,
297
- radius: defaultGrid,
298
- default: defaultGrid,
299
- }
300
-
301
- /* 主题(全局样式)相关工具方法 */
302
- export const setupTheme = (
303
- customTheme?: Partial<LogicFlow.Theme>,
304
- themeMode?: 'radius' | 'dark' | 'colorful' | 'default' | string,
305
- ): LogicFlow.Theme => {
306
- let theme = cloneDeep(defaultTheme)
307
- if (themeMode) {
308
- theme = merge(theme, themeModeMap[themeMode])
309
- }
310
- if (customTheme) {
311
- /**
312
- * 为了不让默认样式被覆盖,使用 merge 方法
313
- * @docs https://lodash.com/docs/4.17.15#merge
314
- * 例如:锚点主题 hover,用户传入如下 ->
315
- * lf.setTheme({
316
- * anchor: {
317
- * fill: 'red'
318
- * }
319
- * })
320
- *
321
- * 预期得到的结果如下:
322
- * {
323
- * // ...
324
- * anchor: {
325
- * stroke: '#000',
326
- * fill: 'red',
327
- * r: 4,
328
- * hover: {
329
- * r: 10,
330
- * fill: '#949494',
331
- * fillOpacity: 0.5,
332
- * stroke: '#949494',
333
- * },
334
- * },
335
- * // ...
336
- * }
337
- */
338
- theme = merge(theme, customTheme)
339
- }
340
- return theme
341
- }
342
-
343
- export const addThemeMode = (
344
- themeMode: string,
345
- style: Partial<LogicFlow.Theme>,
346
- ): void => {
347
- if (themeModeMap[themeMode]) {
348
- console.warn(`theme mode ${themeMode} already exists`)
349
- return
350
- }
351
- themeModeMap[themeMode] = style
352
- backgroundModeMap[themeMode] = style.background || defaultBackground
353
- gridModeMap[themeMode] = style.grid || defaultGrid
354
- }
355
-
356
- export const removeThemeMode = (themeMode: string): void => {
357
- delete themeModeMap[themeMode]
358
- delete backgroundModeMap[themeMode]
359
- delete gridModeMap[themeMode]
360
- }
361
-
362
- export const clearThemeMode = (): void => {
363
- const resetTheme = {
364
- colorful: {},
365
- dark: {},
366
- radius: {},
367
- default: {},
368
- }
369
- assign(themeModeMap, resetTheme)
370
- assign(backgroundModeMap, resetTheme)
371
- assign(gridModeMap, resetTheme)
372
- }
373
-
374
- /* 更新 theme 方法 */
375
- export const updateTheme = setupTheme
package/src/util/uuid.ts DELETED
@@ -1,26 +0,0 @@
1
- import { v4 as uuidV4 } from 'uuid'
2
- import LogicFlow from '../LogicFlow'
3
-
4
- import GraphData = LogicFlow.GraphData
5
-
6
- export const createUuid = (): string => uuidV4()
7
-
8
- /**
9
- * 重新刷新流程图的所有id
10
- */
11
- export const refreshGraphId = (
12
- graphData: GraphData,
13
- prefix = '',
14
- ): GraphData => {
15
- const nodeIdMap = graphData.nodes.reduce((nMap, node) => {
16
- nMap[node.id] = prefix + uuidV4()
17
- node.id = nMap[node.id]
18
- return nMap
19
- }, {})
20
- graphData.edges.forEach((edge) => {
21
- edge.id = prefix + uuidV4()
22
- edge.sourceNodeId = nodeIdMap[edge.sourceNodeId]
23
- edge.targetNodeId = nodeIdMap[edge.targetNodeId]
24
- })
25
- return graphData
26
- }
@@ -1,93 +0,0 @@
1
- function isVector(a1: any, a2: any): boolean {
2
- return !!(a1 instanceof Vector && a2 instanceof Vector)
3
- }
4
-
5
- class Base extends Array<number> {
6
- x: number
7
- y: number
8
- z: number
9
-
10
- constructor(x: number, y: number, z: number) {
11
- super(3)
12
- this[0] = x
13
- this[1] = y
14
- this[2] = z
15
- this.x = x
16
- this.y = y
17
- this.z = z
18
- Object.setPrototypeOf(this, Base.prototype)
19
- }
20
-
21
- add(v1: Vector | Point): Vector | Point {
22
- if (isVector(this, v1)) {
23
- return new Vector(this.x + v1.x, this.y + v1.y)
24
- }
25
- const z = this.z + v1.z
26
- return new Point((this.x + v1.x) / z, (this.y + v1.y) / z)
27
- }
28
-
29
- subtract(v1: Vector | Point): Vector | Point {
30
- if (isVector(this, v1)) {
31
- return new Vector(this.x - v1.x, this.y - v1.y)
32
- }
33
- const z = this.z - v1.z
34
- return z === 0
35
- ? new Vector(this.x - v1.x, this.y - v1.y)
36
- : new Point((this.x - v1.x) / z, (this.y - v1.y) / z)
37
- }
38
- }
39
-
40
- class Vector extends Base {
41
- constructor(x: number, y: number, z?: number) {
42
- super(x, y, z ?? 0)
43
- Object.setPrototypeOf(this, Vector.prototype)
44
- }
45
-
46
- toString(): string {
47
- return 'Vector'
48
- }
49
-
50
- dot(v1: Vector) {
51
- return v1.reduce((prev, cur, index) => prev + cur * this[index])
52
- }
53
-
54
- cross(v1: Vector) {
55
- return new Vector(
56
- this.y * v1.z - this.z * v1.y,
57
- this.z * v1.x - this.x * v1.z,
58
- this.x * v1.y - this.y * v1.x,
59
- )
60
- }
61
-
62
- getLength() {
63
- return Math.hypot(this.x, this.y)
64
- }
65
-
66
- normalize() {
67
- const len = this.getLength()
68
- return new Vector(this.x / len, this.y / len)
69
- }
70
-
71
- crossZ(v1: Vector) {
72
- return this.x * v1.y - this.y * v1.x
73
- }
74
-
75
- angle(v1: Vector) {
76
- const negative = this.crossZ(v1)
77
- const r = Math.acos(this.normalize().dot(v1.normalize()))
78
- return negative >= 0 ? r : -r
79
- }
80
- }
81
-
82
- class Point extends Base {
83
- constructor(x: number, y: number) {
84
- super(x, y, 1)
85
- Object.setPrototypeOf(this, Point.prototype)
86
- }
87
-
88
- toString(): string {
89
- return 'Point'
90
- }
91
- }
92
-
93
- export { Vector, Point }
@@ -1,6 +0,0 @@
1
- let maxIndex = 1000
2
- let minIndex = 999
3
-
4
- export const getZIndex = () => ++maxIndex
5
-
6
- export const getMinIndex = () => --minIndex