@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
@@ -1,197 +0,0 @@
1
- import { get, assign, cloneDeep } from 'lodash-es'
2
- import { action, observable } from 'mobx'
3
- import BaseEdgeModel from './BaseEdgeModel'
4
- import { BaseNodeModel } from '../node'
5
- import LogicFlow from '../../LogicFlow'
6
- import GraphModel from '../GraphModel'
7
- import { ModelType } from '../../constant'
8
- import { getBezierControlPoints, IBezierControls } from '../../util'
9
-
10
- import Point = LogicFlow.Point
11
- import EdgeConfig = LogicFlow.EdgeConfig
12
-
13
- export class BezierEdgeModel extends BaseEdgeModel {
14
- modelType = ModelType.BEZIER_EDGE
15
-
16
- @observable offset!: number
17
- @observable path = ''
18
- constructor(data: EdgeConfig, graphModel: GraphModel) {
19
- super(data, graphModel)
20
- this.initEdgeData(data)
21
- this.setAttributes()
22
- }
23
- initEdgeData(data: EdgeConfig): void {
24
- this.offset = get(data, 'properties.offset', 100)
25
- super.initEdgeData(data)
26
- }
27
- getEdgeStyle() {
28
- const { bezier } = this.graphModel.theme
29
- const style = super.getEdgeStyle()
30
- const { style: customStyle = {} } = this.properties
31
- return {
32
- ...style,
33
- ...cloneDeep(bezier),
34
- ...cloneDeep(customStyle),
35
- }
36
- }
37
- getTextPosition(): Point {
38
- if (this.pointsList && this.pointsList.length > 0) {
39
- let pointsXSum = 0
40
- let pointsYSum = 0
41
- this.pointsList.forEach(({ x, y }) => {
42
- pointsXSum += x
43
- pointsYSum += y
44
- })
45
- return {
46
- x: pointsXSum / this.pointsList.length,
47
- y: pointsYSum / this.pointsList.length,
48
- }
49
- }
50
- return {
51
- x: (this.startPoint.x + this.endPoint.x) / 2,
52
- y: (this.startPoint.y + this.endPoint.y) / 2,
53
- }
54
- }
55
- getData() {
56
- const data = super.getData()
57
- const pointsList = this.pointsList.map(({ x, y }) => ({ x, y }))
58
- return {
59
- ...data,
60
- pointsList,
61
- }
62
- }
63
-
64
- /* 获取贝塞尔曲线的控制点 */
65
- private getControls(): IBezierControls {
66
- const start = this.startPoint
67
- const end = this.endPoint
68
- const points = getBezierControlPoints({
69
- start,
70
- end,
71
- sourceNode: this.sourceNode,
72
- targetNode: this.targetNode,
73
- offset: this.offset,
74
- })
75
- return points
76
- }
77
- /* 获取贝塞尔曲线的path */
78
- private getPath(points: Point[]): string {
79
- const [start, sNext, ePre, end] = points
80
- return `M ${start.x} ${start.y}
81
- C ${sNext.x} ${sNext.y},
82
- ${ePre.x} ${ePre.y},
83
- ${end.x} ${end.y}`
84
- }
85
- @action
86
- initPoints() {
87
- if (this.pointsList.length > 0) {
88
- this.path = this.getPath(this.pointsList)
89
- } else {
90
- this.updatePoints()
91
- }
92
- }
93
-
94
- @action
95
- updatePoints() {
96
- const { sNext, ePre } = this.getControls()
97
- this.updatePath(sNext, ePre)
98
- }
99
- updatePath(sNext: Point, ePre: Point) {
100
- sNext = cloneDeep(sNext)
101
- ePre = cloneDeep(ePre)
102
- const start = {
103
- x: this.startPoint.x,
104
- y: this.startPoint.y,
105
- }
106
- const end = {
107
- x: this.endPoint.x,
108
- y: this.endPoint.y,
109
- }
110
- if (!sNext || !ePre) {
111
- const control = this.getControls()
112
- sNext = control.sNext
113
- ePre = control.ePre
114
- }
115
- this.pointsList = [start, sNext, ePre, end]
116
- this.path = this.getPath(this.pointsList)
117
- }
118
- @action
119
- updateStartPoint(anchor: Point) {
120
- this.startPoint = Object.assign({}, anchor)
121
- this.updatePoints()
122
- }
123
-
124
- @action
125
- updateEndPoint(anchor: Point) {
126
- this.endPoint = Object.assign({}, anchor)
127
- this.updatePoints()
128
- }
129
- @action
130
- moveStartPoint(deltaX: number, deltaY: number): void {
131
- this.startPoint.x += deltaX
132
- this.startPoint.y += deltaY
133
- const [, sNext, ePre] = this.pointsList
134
- // 保持调整点一起移动
135
- sNext.x += deltaX
136
- sNext.y += deltaY
137
- this.updatePath(sNext, ePre)
138
- }
139
- @action
140
- moveEndPoint(deltaX: number, deltaY: number): void {
141
- this.endPoint.x += deltaX
142
- this.endPoint.y += deltaY
143
- const [, sNext, ePre] = this.pointsList
144
- // 保持调整点一起移动
145
- ePre.x += deltaX
146
- ePre.y += deltaY
147
- this.updatePath(sNext, ePre)
148
- }
149
- @action
150
- updateAdjustAnchor(anchor: Point, type: string) {
151
- if (type === 'sNext') {
152
- this.pointsList[1] = anchor
153
- } else if (type === 'ePre') {
154
- this.pointsList[2] = anchor
155
- }
156
- this.path = this.getPath(this.pointsList)
157
- if (this.text?.value) {
158
- this.setText(assign({}, this.text, this.textPosition))
159
- }
160
- }
161
- // 获取边调整的起点
162
- @action
163
- getAdjustStart() {
164
- return this.pointsList[0] || this.startPoint
165
- }
166
- // 获取边调整的终点
167
- @action
168
- getAdjustEnd() {
169
- const { pointsList } = this
170
- return pointsList[pointsList.length - 1] || this.endPoint
171
- }
172
- // 起终点拖拽调整过程中,进行曲线路径更新
173
- @action
174
- updateAfterAdjustStartAndEnd({
175
- startPoint,
176
- endPoint,
177
- sourceNode,
178
- targetNode,
179
- }: {
180
- startPoint: Point
181
- endPoint: Point
182
- sourceNode: BaseNodeModel
183
- targetNode: BaseNodeModel
184
- }) {
185
- const { sNext, ePre } = getBezierControlPoints({
186
- start: startPoint,
187
- end: endPoint,
188
- sourceNode,
189
- targetNode,
190
- offset: this.offset,
191
- })
192
- this.pointsList = [startPoint, sNext, ePre, endPoint]
193
- this.initPoints()
194
- }
195
- }
196
-
197
- export default BezierEdgeModel
@@ -1,36 +0,0 @@
1
- import { cloneDeep } from 'lodash-es'
2
- import LogicFlow from '../../LogicFlow'
3
- import BaseEdgeModel from './BaseEdgeModel'
4
- import { ModelType } from '../../constant'
5
-
6
- import Point = LogicFlow.Point
7
-
8
- export class LineEdgeModel extends BaseEdgeModel {
9
- modelType = ModelType.LINE_EDGE
10
- getEdgeStyle() {
11
- const { line } = this.graphModel.theme
12
- const style = super.getEdgeStyle()
13
- const { style: customStyle = {} } = this.properties
14
- return {
15
- ...style,
16
- ...cloneDeep(line),
17
- ...cloneDeep(customStyle),
18
- }
19
- }
20
- initEdgeData(data: LogicFlow.EdgeConfig): void {
21
- super.initEdgeData(data)
22
- this.points = this.getPath([this.startPoint, this.endPoint])
23
- }
24
- getPath(points: Point[]): string {
25
- const [start, end] = points
26
- return `${start.x},${start.y} ${end.x},${end.y}`
27
- }
28
- getTextPosition(): Point {
29
- return {
30
- x: (this.startPoint.x + this.endPoint.x) / 2,
31
- y: (this.startPoint.y + this.endPoint.y) / 2,
32
- }
33
- }
34
- }
35
-
36
- export default LineEdgeModel