@logicflow/core 2.2.0-alpha.7 → 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 (137) hide show
  1. package/package.json +6 -1
  2. package/.turbo/turbo-build$colon$dev.log +0 -10
  3. package/.turbo/turbo-build.log +0 -33
  4. package/CHANGELOG.md +0 -1901
  5. package/__tests__/algorithm/egde.test.ts +0 -131
  6. package/__tests__/algorithm/index.test.ts +0 -74
  7. package/__tests__/algorithm/outline.test.ts +0 -43
  8. package/__tests__/bugs/1545-spec.test.ts +0 -42
  9. package/__tests__/event/event.test.ts +0 -22
  10. package/__tests__/history/history.test.ts +0 -28
  11. package/__tests__/logicflow.test.ts +0 -575
  12. package/__tests__/model/graphmodel.test.ts +0 -87
  13. package/__tests__/util/compatible.test.ts +0 -48
  14. package/__tests__/util/edge.test.ts +0 -224
  15. package/__tests__/util/geometry.test.ts +0 -14
  16. package/__tests__/util/graph.test.ts +0 -16
  17. package/__tests__/util/matrix.test.ts +0 -41
  18. package/__tests__/util/node.test.ts +0 -68
  19. package/__tests__/util/sampling.test.ts +0 -12
  20. package/__tests__/util/vector.test.ts +0 -50
  21. package/__tests__/util/zIndex.test.ts +0 -10
  22. package/src/LogicFlow.tsx +0 -2017
  23. package/src/algorithm/edge.ts +0 -67
  24. package/src/algorithm/index.ts +0 -70
  25. package/src/algorithm/outline.ts +0 -77
  26. package/src/algorithm/rotate.ts +0 -55
  27. package/src/common/drag.ts +0 -219
  28. package/src/common/history.ts +0 -108
  29. package/src/common/index.ts +0 -6
  30. package/src/common/keyboard.ts +0 -108
  31. package/src/common/matrix.ts +0 -122
  32. package/src/common/vector.ts +0 -93
  33. package/src/constant/index.ts +0 -179
  34. package/src/constant/theme.ts +0 -708
  35. package/src/event/event.md +0 -66
  36. package/src/event/eventArgs.ts +0 -643
  37. package/src/event/eventEmitter.ts +0 -156
  38. package/src/history/index.ts +0 -119
  39. package/src/index.less +0 -1
  40. package/src/index.ts +0 -26
  41. package/src/keyboard/index.ts +0 -112
  42. package/src/keyboard/shortcut.ts +0 -200
  43. package/src/model/BaseModel.ts +0 -250
  44. package/src/model/EditConfigModel.ts +0 -334
  45. package/src/model/GraphModel.ts +0 -1824
  46. package/src/model/NestedTransformModel.ts +0 -121
  47. package/src/model/SnaplineModel.ts +0 -256
  48. package/src/model/TransformModel.ts +0 -258
  49. package/src/model/edge/BaseEdgeModel.ts +0 -785
  50. package/src/model/edge/BezierEdgeModel.ts +0 -197
  51. package/src/model/edge/LineEdgeModel.ts +0 -36
  52. package/src/model/edge/PolylineEdgeModel.ts +0 -817
  53. package/src/model/edge/index.ts +0 -4
  54. package/src/model/index.ts +0 -9
  55. package/src/model/node/BaseNodeModel.ts +0 -959
  56. package/src/model/node/CircleNodeModel.ts +0 -91
  57. package/src/model/node/DiamondNodeModel.ts +0 -132
  58. package/src/model/node/EllipseNodeModel.ts +0 -98
  59. package/src/model/node/HtmlNodeModel.ts +0 -64
  60. package/src/model/node/PolygonNodeModel.ts +0 -152
  61. package/src/model/node/RectNodeModel.ts +0 -69
  62. package/src/model/node/TextNodeModel.ts +0 -54
  63. package/src/model/node/index.ts +0 -8
  64. package/src/options.ts +0 -150
  65. package/src/style/index.less +0 -262
  66. package/src/style/raw.ts +0 -221
  67. package/src/tool/MultipleSelectTool.tsx +0 -140
  68. package/src/tool/TextEditTool.tsx +0 -193
  69. package/src/tool/index.ts +0 -101
  70. package/src/typings.d.ts +0 -5
  71. package/src/util/animation.ts +0 -29
  72. package/src/util/browser.ts +0 -4
  73. package/src/util/compatible.ts +0 -15
  74. package/src/util/drag.ts +0 -219
  75. package/src/util/edge.ts +0 -1094
  76. package/src/util/geometry.ts +0 -154
  77. package/src/util/graph.ts +0 -46
  78. package/src/util/index.ts +0 -17
  79. package/src/util/matrix.ts +0 -129
  80. package/src/util/mobx.ts +0 -23
  81. package/src/util/node.ts +0 -543
  82. package/src/util/raf.ts +0 -28
  83. package/src/util/resize.ts +0 -606
  84. package/src/util/sampling.ts +0 -85
  85. package/src/util/theme.ts +0 -84
  86. package/src/util/uuid.ts +0 -26
  87. package/src/util/vector.ts +0 -93
  88. package/src/util/zIndex.ts +0 -6
  89. package/src/view/Anchor.tsx +0 -462
  90. package/src/view/Control.tsx +0 -510
  91. package/src/view/Graph.tsx +0 -141
  92. package/src/view/Rotate.tsx +0 -113
  93. package/src/view/behavior/dnd.ts +0 -162
  94. package/src/view/behavior/index.ts +0 -2
  95. package/src/view/behavior/snapline.ts +0 -16
  96. package/src/view/edge/AdjustPoint.tsx +0 -425
  97. package/src/view/edge/Arrow.tsx +0 -54
  98. package/src/view/edge/BaseEdge.tsx +0 -660
  99. package/src/view/edge/BezierEdge.tsx +0 -101
  100. package/src/view/edge/LineEdge.tsx +0 -81
  101. package/src/view/edge/PolylineEdge.tsx +0 -311
  102. package/src/view/edge/index.ts +0 -6
  103. package/src/view/index.ts +0 -8
  104. package/src/view/node/BaseNode.tsx +0 -585
  105. package/src/view/node/CircleNode.tsx +0 -21
  106. package/src/view/node/DiamondNode.tsx +0 -24
  107. package/src/view/node/EllipseNode.tsx +0 -22
  108. package/src/view/node/HtmlNode.tsx +0 -112
  109. package/src/view/node/PolygonNode.tsx +0 -28
  110. package/src/view/node/RectNode.tsx +0 -30
  111. package/src/view/node/TextNode.tsx +0 -39
  112. package/src/view/node/index.ts +0 -8
  113. package/src/view/overlay/BackgroundOverlay.tsx +0 -34
  114. package/src/view/overlay/BezierAdjustOverlay.tsx +0 -150
  115. package/src/view/overlay/CanvasOverlay.tsx +0 -290
  116. package/src/view/overlay/Grid.tsx +0 -319
  117. package/src/view/overlay/ModificationOverlay.tsx +0 -31
  118. package/src/view/overlay/OutlineOverlay.tsx +0 -158
  119. package/src/view/overlay/SnaplineOverlay.tsx +0 -44
  120. package/src/view/overlay/ToolOverlay.tsx +0 -65
  121. package/src/view/overlay/getTransformHoc.tsx +0 -50
  122. package/src/view/overlay/gridConfig.ts +0 -103
  123. package/src/view/overlay/index.ts +0 -8
  124. package/src/view/shape/Circle.tsx +0 -41
  125. package/src/view/shape/Ellipse.tsx +0 -42
  126. package/src/view/shape/Line.tsx +0 -39
  127. package/src/view/shape/Path.tsx +0 -22
  128. package/src/view/shape/Polygon.tsx +0 -54
  129. package/src/view/shape/Polyline.tsx +0 -31
  130. package/src/view/shape/Rect.tsx +0 -44
  131. package/src/view/shape/Text.tsx +0 -168
  132. package/src/view/shape/index.ts +0 -8
  133. package/src/view/text/BaseText.tsx +0 -134
  134. package/src/view/text/LineText.tsx +0 -168
  135. package/src/view/text/index.ts +0 -2
  136. package/stats.html +0 -4842
  137. package/tsconfig.json +0 -18
@@ -1,131 +0,0 @@
1
- import { getCrossPointOfLine, isInSegment } from '../../src/algorithm/edge'
2
-
3
- describe('algorithm/edge', () => {
4
- // one intersection
5
- test('one intersection', () => {
6
- const line1 = [
7
- {
8
- x: 0,
9
- y: 0,
10
- },
11
- {
12
- x: 10,
13
- y: 10,
14
- },
15
- ]
16
- const line2 = [
17
- {
18
- x: 10,
19
- y: 0,
20
- },
21
- {
22
- x: 0,
23
- y: 10,
24
- },
25
- ]
26
- expect(
27
- getCrossPointOfLine(line1[0], line1[1], line2[0], line2[1]),
28
- ).toBeTruthy()
29
- })
30
- // multiple intersection
31
- test('multiple intersection', () => {
32
- const line1 = [
33
- {
34
- x: 0,
35
- y: 0,
36
- },
37
- {
38
- x: 10,
39
- y: 10,
40
- },
41
- ]
42
- const line2 = [
43
- {
44
- x: 0,
45
- y: 0,
46
- },
47
- {
48
- x: 10,
49
- y: 10,
50
- },
51
- ]
52
- expect(
53
- getCrossPointOfLine(line1[0], line1[1], line2[0], line2[1]),
54
- ).toBeFalsy()
55
- })
56
- // no intersection
57
- test('intersection', () => {
58
- const line1 = [
59
- {
60
- x: 0,
61
- y: 0,
62
- },
63
- {
64
- x: 10,
65
- y: 10,
66
- },
67
- ]
68
- const line2 = [
69
- {
70
- x: 10,
71
- y: 0,
72
- },
73
- {
74
- x: 20,
75
- y: 10,
76
- },
77
- ]
78
- expect(
79
- getCrossPointOfLine(line1[0], line1[1], line2[0], line2[1]),
80
- ).toBeFalsy()
81
- })
82
-
83
- test('in segment', () => {
84
- const point = {
85
- x: 0,
86
- y: 0,
87
- }
88
- const line1 = [
89
- {
90
- x: -10,
91
- y: -10,
92
- },
93
- {
94
- x: 10,
95
- y: 10,
96
- },
97
- ]
98
- const line2 = [
99
- {
100
- x: -10,
101
- y: 10,
102
- },
103
- {
104
- x: 10,
105
- y: -10,
106
- },
107
- ]
108
- expect(isInSegment(point, line1[0], line1[1])).toBeTruthy()
109
- expect(isInSegment(point, line1[1], line1[0])).toBeTruthy()
110
- expect(isInSegment(point, line2[0], line2[1])).toBeTruthy()
111
- expect(isInSegment(point, line2[1], line2[0])).toBeTruthy()
112
- })
113
- // not in segment
114
- test('not in segment', () => {
115
- const point = {
116
- x: 10,
117
- y: 0,
118
- }
119
- const line = [
120
- {
121
- x: -10,
122
- y: -10,
123
- },
124
- {
125
- x: 10,
126
- y: 10,
127
- },
128
- ]
129
- expect(isInSegment(point, line[0], line[1])).toBeFalsy()
130
- })
131
- })
@@ -1,74 +0,0 @@
1
- import { getVerticalPointOfLine } from '../../src/algorithm'
2
-
3
- describe('algorithm/index', () => {
4
- test('getVerticalPointOfLine', () => {
5
- const config1 = {
6
- start: {
7
- x: 0,
8
- y: 0,
9
- },
10
- end: {
11
- x: 0,
12
- y: 10,
13
- },
14
- offset: 3,
15
- verticalLength: 3,
16
- type: 'start',
17
- }
18
-
19
- const config2 = {
20
- start: {
21
- x: 0,
22
- y: 0,
23
- },
24
- end: {
25
- x: 10,
26
- y: 0,
27
- },
28
- offset: 3,
29
- verticalLength: 3,
30
- type: 'end',
31
- }
32
-
33
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
34
- const config3 = {
35
- start: {
36
- x: 10,
37
- y: 10,
38
- },
39
- end: {
40
- x: 0,
41
- y: 0,
42
- },
43
- offset: 3,
44
- verticalLength: 3,
45
- type: 'start',
46
- }
47
-
48
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
49
- const config4 = {
50
- start: {
51
- x: 10,
52
- y: 10,
53
- },
54
- end: {
55
- x: 0,
56
- y: 0,
57
- },
58
- offset: 3,
59
- verticalLength: 3,
60
- type: 'end',
61
- }
62
- const res1 = getVerticalPointOfLine(config1)
63
- expect(Math.abs(res1.leftX) - 5 < Number.EPSILON).toBeTruthy()
64
- expect(Math.abs(res1.leftY) - 3 < Number.EPSILON).toBeTruthy()
65
- expect(Math.abs(res1.rightX) - 5 < Number.EPSILON).toBeTruthy()
66
- expect(Math.abs(res1.rightY) - 3 < Number.EPSILON).toBeTruthy()
67
-
68
- const res2 = getVerticalPointOfLine(config2)
69
- expect(Math.abs(res2.leftX) - 7 < Number.EPSILON).toBeTruthy()
70
- expect(Math.abs(res2.leftY) - 3 < Number.EPSILON).toBeTruthy()
71
- expect(Math.abs(res2.rightX) - 7 < Number.EPSILON).toBeTruthy()
72
- expect(Math.abs(res2.rightY) - 3 < Number.EPSILON).toBeTruthy()
73
- })
74
- })
@@ -1,43 +0,0 @@
1
- import { getEdgeOutline } from '../../src/algorithm/outline'
2
-
3
- describe('algorithm/outline', () => {
4
- test('get edge outline', () => {
5
- const edge1 = {
6
- modelType: 'line-edge',
7
- startPoint: {
8
- x: 0,
9
- y: 0,
10
- },
11
- endPoint: {
12
- x: 10,
13
- y: 10,
14
- },
15
- }
16
- expect(getEdgeOutline(edge1)).toEqual({
17
- x: -5,
18
- y: -5,
19
- x1: 15,
20
- y1: 15,
21
- })
22
- const edge2 = {
23
- modelType: 'polyline-edge',
24
- points: '0,0 10,10',
25
- }
26
- expect(getEdgeOutline(edge2)).toEqual({
27
- x: -4,
28
- y: -4,
29
- x1: 14,
30
- y1: 14,
31
- })
32
- const edge3 = {
33
- modelType: 'bezier-edge',
34
- path: 'M 270 195C 370 195,305 290,405 290',
35
- }
36
- expect(getEdgeOutline(edge3)).toEqual({
37
- x: 266,
38
- y: 191,
39
- x1: 409,
40
- y1: 294,
41
- })
42
- })
43
- })
@@ -1,42 +0,0 @@
1
- import LogicFlow from '../../src/index'
2
-
3
- import NodeConfig = LogicFlow.NodeConfig
4
- import TextConfig = LogicFlow.TextConfig
5
-
6
- type NodeConfigTextObj = NodeConfig & {
7
- text: TextConfig
8
- }
9
- describe('#1545', () => {
10
- const dom = document.createElement('div')
11
- dom.id = 'main-graph'
12
- document.body.appendChild(dom)
13
- const lf = new LogicFlow({
14
- container: dom,
15
- width: 1000,
16
- height: 1000,
17
- grid: true,
18
- })
19
-
20
- it('clone node text pos should snap to grid', () => {
21
- lf.render({
22
- nodes: [
23
- {
24
- id: 'node_id_1',
25
- type: 'rect',
26
- x: 300,
27
- y: 300,
28
- text: {
29
- x: 32,
30
- y: 19,
31
- value: '文本1',
32
- },
33
- },
34
- ],
35
- })
36
- const originNode = lf.getDataById('node_id_1') as NodeConfigTextObj
37
- const newNode = lf.cloneNode('node_id_1') as NodeConfigTextObj
38
- expect(originNode.x - originNode.text.x).toEqual(newNode.x - newNode.text.x)
39
- expect(originNode.y - originNode.text.y).toEqual(newNode.y - newNode.text.y)
40
- expect(originNode.text.value).toEqual(newNode.text.value)
41
- })
42
- })
@@ -1,22 +0,0 @@
1
- import EventEmitter from '../../src/event/eventEmitter'
2
-
3
- describe('event/eventEmitter', () => {
4
- const em = new EventEmitter()
5
- test('event emitter', () => {
6
- const fn = jest.fn()
7
- em.on('test', fn)
8
- em.emit('test', { a: 1 })
9
- expect(fn).toBeCalledWith({ a: 1 })
10
- em.off('test', fn)
11
- em.emit('test', { a: 1 })
12
- expect(fn).toBeCalledTimes(1)
13
-
14
- em.once('test1', fn)
15
- em.emit('test1', { a: 1 })
16
- expect(fn).toBeCalledTimes(2)
17
- em.once('test1', fn)
18
- em.emit('test1', { a: 1 })
19
- const test1Events = em.getEvents().test1
20
- expect(test1Events).toBeUndefined()
21
- })
22
- })
@@ -1,28 +0,0 @@
1
- import History from '../../src/history/History'
2
- import EventEmitter from '../../src/event/eventEmitter'
3
-
4
- describe('history', () => {
5
- const event = new EventEmitter()
6
- const history = new History(event)
7
- expect(history).toBeDefined()
8
- test('add', () => {
9
- history.add(1)
10
- expect(history.undos).toEqual([1])
11
- expect(history.redos).toEqual([])
12
- })
13
- test('undo', () => {
14
- history.add(1)
15
- history.add(2)
16
- history.undo()
17
- expect(history.undos).toEqual([])
18
- expect(history.redos).toEqual([2])
19
- })
20
- test('redo', () => {
21
- history.add(1)
22
- history.add(2)
23
- history.undo()
24
- history.redo()
25
- expect(history.undos).toEqual([])
26
- expect(history.redos).toEqual([])
27
- })
28
- })